qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Saif Abrar <saif.abrar@linux.vnet.ibm.com>
To: kbusch@kernel.org, its@irrelevant.dk, foss@defmacro.it
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, npiggin@gmail.com,
	saif.abrar@linux.vnet.ibm.com, nikhilks@linux.ibm.com,
	stefanha@redhat.com, fam@euphon.net, philmd@linaro.org
Subject: [PATCH v4 2/2] hw/nvme: Add property for user-specified IEEE-OUI ID
Date: Thu, 27 Nov 2025 06:02:51 -0600	[thread overview]
Message-ID: <20251127120322.2997269-3-saif.abrar@linux.vnet.ibm.com> (raw)
In-Reply-To: <20251127120322.2997269-1-saif.abrar@linux.vnet.ibm.com>

User-specified IEEE-OUI ID (Identify Controller bytes 75:73)
is to be specified in LE format.
(e.g. ieee_oui=0xABCDEF => Byte[73]=0xEF, Byte[74]=0xCD, Byte[75]=0xAB)

Signed-off-by: Saif Abrar <saif.abrar@linux.vnet.ibm.com>
---
v3 -> v4: Resolve merge commits when moving to the latest repo.

 hw/nvme/ctrl.c | 24 ++++++++++++++++++++++++
 hw/nvme/nvme.h |  2 ++
 2 files changed, 26 insertions(+)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index d857be5496..c66524c78c 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -9131,6 +9131,10 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
         id->ieee[0] = 0xb3;
         id->ieee[1] = 0x02;
         id->ieee[2] = 0x00;
+     } else if (n->params.ieee_oui) {
+        id->ieee[0] = extract32(n->params.ieee_oui, 0,  8);
+        id->ieee[1] = extract32(n->params.ieee_oui, 8,  8);
+        id->ieee[2] = extract32(n->params.ieee_oui, 16, 8);
     } else {
         id->ieee[0] = 0x00;
         id->ieee[1] = 0x54;
@@ -9384,6 +9388,24 @@ static void nvme_exit(PCIDevice *pci_dev)
     memory_region_del_subregion(&n->bar0, &n->iomem);
 }
 
+static void nvme_prop_ieee_set(Object *obj, Visitor *v, const char *name,
+        void *opaque, Error **errp)
+{
+    Property *prop = opaque;
+    uint32_t *val = object_field_prop_ptr(obj, prop);
+    if (!visit_type_uint32(v, name, val, errp)) {
+        return;
+    }
+}
+
+static const PropertyInfo nvme_prop_ieee = {
+    .type = "uint32",
+    .description = "IEEE OUI: Identify Controller bytes 75:73\
+ in LE format. (e.g. ieee_oui=0xABCDEF => Byte[73]=0xEF, Byte[74]=0xCD,\
+ Byte[75]=0xAB)",
+    .set = nvme_prop_ieee_set,
+};
+
 static const Property nvme_props[] = {
     DEFINE_BLOCK_PROPERTIES(NvmeCtrl, namespace.blkconf),
     DEFINE_PROP_LINK("pmrdev", NvmeCtrl, pmr.dev, TYPE_MEMORY_BACKEND,
@@ -9431,6 +9453,8 @@ static const Property nvme_props[] = {
     DEFINE_PROP_UINT16("id_subsys_vendor", NvmeCtrl,
                                                     params.id_subsys_vendor, 0),
     DEFINE_PROP_UINT16("id_subsys", NvmeCtrl, params.id_subsys, 0),
+    DEFINE_PROP("ieee_oui", NvmeCtrl, params.ieee_oui, nvme_prop_ieee,
+                uint32_t),
 };
 
 static void nvme_get_smart_warning(Object *obj, Visitor *v, const char *name,
diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 65fb168bc9..be49acaec6 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -576,6 +576,8 @@ typedef struct NvmeParams {
     uint16_t id_device;
     uint16_t id_subsys_vendor;
     uint16_t id_subsys;
+
+    uint32_t ieee_oui;
 } NvmeParams;
 
 typedef struct NvmeCtrl {
-- 
2.47.3



  parent reply	other threads:[~2025-11-27 12:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 12:02 [PATCH v4 0/2] hw/nvme: Properties for PCI vendor/dev IDs and IEEE-OUI Saif Abrar
2025-11-27 12:02 ` [PATCH v4 1/2] hw/nvme: Add properties for PCI vendor/device IDs Saif Abrar
2025-11-27 12:02 ` Saif Abrar [this message]
2025-12-12 10:00 ` [PATCH v4 0/2] hw/nvme: Properties for PCI vendor/dev IDs and IEEE-OUI Jesper Devantier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251127120322.2997269-3-saif.abrar@linux.vnet.ibm.com \
    --to=saif.abrar@linux.vnet.ibm.com \
    --cc=fam@euphon.net \
    --cc=foss@defmacro.it \
    --cc=its@irrelevant.dk \
    --cc=kbusch@kernel.org \
    --cc=nikhilks@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).