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:
Naveen Nagar 2021-10-06 08:53:30 +02:00 committed by Klaus Jensen
parent a6de6ed509
commit 763c05dfb0
4 changed files with 47 additions and 12 deletions

View file

@ -112,10 +112,11 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp)
[7] = { .ds = 12, .ms = 64 },
};
memcpy(&id_ns->lbaf, &lbaf, sizeof(lbaf));
id_ns->nlbaf = 7;
ns->nlbaf = 8;
for (i = 0; i <= id_ns->nlbaf; i++) {
memcpy(&id_ns->lbaf, &lbaf, sizeof(lbaf));
for (i = 0; i < ns->nlbaf; i++) {
NvmeLBAF *lbaf = &id_ns->lbaf[i];
if (lbaf->ds == ds) {
if (lbaf->ms == ms) {
@ -126,12 +127,14 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp)
}
/* add non-standard lba format */
id_ns->nlbaf++;
id_ns->lbaf[id_ns->nlbaf].ds = ds;
id_ns->lbaf[id_ns->nlbaf].ms = ms;
id_ns->flbas |= id_ns->nlbaf;
id_ns->lbaf[ns->nlbaf].ds = ds;
id_ns->lbaf[ns->nlbaf].ms = ms;
ns->nlbaf++;
id_ns->flbas |= i;
lbaf_found:
id_ns->nlbaf = ns->nlbaf - 1;
nvme_ns_init_format(ns);
return 0;