Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_nvme.c
Show First 20 Lines • Show All 795 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
nvme_set_feature_queues(struct pci_nvme_softc* sc, struct nvme_command* command, | nvme_set_feature_queues(struct pci_nvme_softc* sc, struct nvme_command* command, | ||||
struct nvme_completion* compl) | struct nvme_completion* compl) | ||||
{ | { | ||||
uint16_t nqr; /* Number of Queues Requested */ | uint16_t nqr; /* Number of Queues Requested */ | ||||
nqr = command->cdw11 & 0xFFFF; | nqr = command->cdw11 & 0xFFFF; | ||||
if (nqr == 0xffff) { | if (nqr == 0xffff) { | ||||
WPRINTF(("%s: Illegal NSQR value %#x\n", __func__, nqr)); | WPRINTF(("%s: Illegal NSQR value %#x\r\n", __func__, nqr)); | ||||
pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD); | pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
sc->num_squeues = ONE_BASED(nqr); | sc->num_squeues = ONE_BASED(nqr); | ||||
if (sc->num_squeues > sc->max_queues) { | if (sc->num_squeues > sc->max_queues) { | ||||
DPRINTF(("NSQR=%u is greater than max %u\n", sc->num_squeues, | DPRINTF(("NSQR=%u is greater than max %u\r\n", sc->num_squeues, | ||||
sc->max_queues)); | sc->max_queues)); | ||||
sc->num_squeues = sc->max_queues; | sc->num_squeues = sc->max_queues; | ||||
} | } | ||||
nqr = (command->cdw11 >> 16) & 0xFFFF; | nqr = (command->cdw11 >> 16) & 0xFFFF; | ||||
if (nqr == 0xffff) { | if (nqr == 0xffff) { | ||||
WPRINTF(("%s: Illegal NCQR value %#x\n", __func__, nqr)); | WPRINTF(("%s: Illegal NCQR value %#x\r\n", __func__, nqr)); | ||||
pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD); | pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
sc->num_cqueues = ONE_BASED(nqr); | sc->num_cqueues = ONE_BASED(nqr); | ||||
if (sc->num_cqueues > sc->max_queues) { | if (sc->num_cqueues > sc->max_queues) { | ||||
DPRINTF(("NCQR=%u is greater than max %u\n", sc->num_cqueues, | DPRINTF(("NCQR=%u is greater than max %u\r\n", sc->num_cqueues, | ||||
sc->max_queues)); | sc->max_queues)); | ||||
sc->num_cqueues = sc->max_queues; | sc->num_cqueues = sc->max_queues; | ||||
} | } | ||||
compl->cdw0 = NVME_FEATURE_NUM_QUEUES(sc); | compl->cdw0 = NVME_FEATURE_NUM_QUEUES(sc); | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,068 Lines • ▼ Show 20 Lines | if (!strcmp("maxq", xopts)) { | ||||
if (sc->nvstore.ctx == NULL) { | if (sc->nvstore.ctx == NULL) { | ||||
perror("Could not open backing file"); | perror("Could not open backing file"); | ||||
free(uopt); | free(uopt); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
sc->nvstore.type = NVME_STOR_BLOCKIF; | sc->nvstore.type = NVME_STOR_BLOCKIF; | ||||
sc->nvstore.size = blockif_size(sc->nvstore.ctx); | sc->nvstore.size = blockif_size(sc->nvstore.ctx); | ||||
} else { | } else { | ||||
fprintf(stderr, "Invalid option %s\n", xopts); | fprintf(stderr, "Invalid option %s\r\n", xopts); | ||||
free(uopt); | free(uopt); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
optidx++; | optidx++; | ||||
} | } | ||||
free(uopt); | free(uopt); | ||||
if (sc->nvstore.ctx == NULL || sc->nvstore.size == 0) { | if (sc->nvstore.ctx == NULL || sc->nvstore.size == 0) { | ||||
fprintf(stderr, "backing store not specified\n"); | fprintf(stderr, "backing store not specified\r\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (sectsz == 512 || sectsz == 4096 || sectsz == 8192) | if (sectsz == 512 || sectsz == 4096 || sectsz == 8192) | ||||
sc->nvstore.sectsz = sectsz; | sc->nvstore.sectsz = sectsz; | ||||
else if (sc->nvstore.type != NVME_STOR_RAM) | else if (sc->nvstore.type != NVME_STOR_RAM) | ||||
sc->nvstore.sectsz = blockif_sectsz(sc->nvstore.ctx); | sc->nvstore.sectsz = blockif_sectsz(sc->nvstore.ctx); | ||||
for (sc->nvstore.sectsz_bits = 9; | for (sc->nvstore.sectsz_bits = 9; | ||||
(1 << sc->nvstore.sectsz_bits) < sc->nvstore.sectsz; | (1 << sc->nvstore.sectsz_bits) < sc->nvstore.sectsz; | ||||
sc->nvstore.sectsz_bits++); | sc->nvstore.sectsz_bits++); | ||||
if (sc->max_queues <= 0 || sc->max_queues > NVME_QUEUES) | if (sc->max_queues <= 0 || sc->max_queues > NVME_QUEUES) | ||||
sc->max_queues = NVME_QUEUES; | sc->max_queues = NVME_QUEUES; | ||||
if (sc->max_qentries <= 0) { | if (sc->max_qentries <= 0) { | ||||
fprintf(stderr, "Invalid qsz option\n"); | fprintf(stderr, "Invalid qsz option\r\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (sc->ioslots <= 0) { | if (sc->ioslots <= 0) { | ||||
fprintf(stderr, "Invalid ioslots option\n"); | fprintf(stderr, "Invalid ioslots option\r\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
pci_nvme_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) | pci_nvme_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |