mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
hw/nvme: add support for the lbafee hbs feature
Add support for up to 64 LBA formats through the LBAFEE field of the Host Behavior Support feature. Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Naveen Nagar <naveen.n1@samsung.com> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
This commit is contained in:
parent
a6de6ed509
commit
763c05dfb0
4 changed files with 47 additions and 12 deletions
|
@ -5165,6 +5165,7 @@ static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeRequest *req)
|
|||
uint32_t nsid = le32_to_cpu(cmd->nsid);
|
||||
uint8_t fid = NVME_GETSETFEAT_FID(dw10);
|
||||
uint8_t save = NVME_SETFEAT_SAVE(dw10);
|
||||
uint16_t status;
|
||||
int i;
|
||||
|
||||
trace_pci_nvme_setfeat(nvme_cid(req), nsid, fid, save, dw11);
|
||||
|
@ -5287,8 +5288,26 @@ static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeRequest *req)
|
|||
case NVME_TIMESTAMP:
|
||||
return nvme_set_feature_timestamp(n, req);
|
||||
case NVME_HOST_BEHAVIOR_SUPPORT:
|
||||
return nvme_h2c(n, (uint8_t *)&n->features.hbs,
|
||||
sizeof(n->features.hbs), req);
|
||||
status = nvme_h2c(n, (uint8_t *)&n->features.hbs,
|
||||
sizeof(n->features.hbs), req);
|
||||
if (status) {
|
||||
return status;
|
||||
}
|
||||
|
||||
for (i = 1; i <= NVME_MAX_NAMESPACES; i++) {
|
||||
ns = nvme_ns(n, i);
|
||||
|
||||
if (!ns) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ns->id_ns.nlbaf = ns->nlbaf - 1;
|
||||
if (!n->features.hbs.lbafee) {
|
||||
ns->id_ns.nlbaf = MIN(ns->id_ns.nlbaf, 15);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
case NVME_COMMAND_SET_PROFILE:
|
||||
if (dw11 & 0x1ff) {
|
||||
trace_pci_nvme_err_invalid_iocsci(dw11 & 0x1ff);
|
||||
|
@ -5479,10 +5498,13 @@ static const AIOCBInfo nvme_format_aiocb_info = {
|
|||
static void nvme_format_set(NvmeNamespace *ns, uint8_t lbaf, uint8_t mset,
|
||||
uint8_t pi, uint8_t pil)
|
||||
{
|
||||
uint8_t lbafl = lbaf & 0xf;
|
||||
uint8_t lbafu = lbaf >> 4;
|
||||
|
||||
trace_pci_nvme_format_set(ns->params.nsid, lbaf, mset, pi, pil);
|
||||
|
||||
ns->id_ns.dps = (pil << 3) | pi;
|
||||
ns->id_ns.flbas = lbaf | (mset << 4);
|
||||
ns->id_ns.flbas = (lbafu << 5) | (mset << 4) | lbafl;
|
||||
|
||||
nvme_ns_init_format(ns);
|
||||
}
|
||||
|
@ -5596,6 +5618,7 @@ static uint16_t nvme_format(NvmeCtrl *n, NvmeRequest *req)
|
|||
uint8_t mset = (dw10 >> 4) & 0x1;
|
||||
uint8_t pi = (dw10 >> 5) & 0x7;
|
||||
uint8_t pil = (dw10 >> 8) & 0x1;
|
||||
uint8_t lbafu = (dw10 >> 12) & 0x3;
|
||||
uint16_t status;
|
||||
|
||||
iocb = qemu_aio_get(&nvme_format_aiocb_info, NULL, nvme_misc_cb, req);
|
||||
|
@ -5612,6 +5635,10 @@ static uint16_t nvme_format(NvmeCtrl *n, NvmeRequest *req)
|
|||
iocb->broadcast = (nsid == NVME_NSID_BROADCAST);
|
||||
iocb->offset = 0;
|
||||
|
||||
if (n->features.hbs.lbafee) {
|
||||
iocb->lbaf |= lbafu << 4;
|
||||
}
|
||||
|
||||
if (!iocb->broadcast) {
|
||||
if (!nvme_nsid_valid(n, nsid)) {
|
||||
status = NVME_INVALID_NSID | NVME_DNR;
|
||||
|
@ -6587,6 +6614,7 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
|
|||
id->cntlid = cpu_to_le16(n->cntlid);
|
||||
|
||||
id->oaes = cpu_to_le32(NVME_OAES_NS_ATTR);
|
||||
id->ctratt |= cpu_to_le32(NVME_CTRATT_ELBAS);
|
||||
|
||||
id->rab = 6;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue