]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: Add NVM subsystem controller identifier
authorNilay Shroff <nilay@linux.ibm.com>
Tue, 26 Mar 2024 06:57:23 +0000 (12:27 +0530)
committerDaniel Wagner <dwagner@suse.de>
Wed, 3 Apr 2024 09:57:15 +0000 (11:57 +0200)
This commit introduces a field "cntlid" for controller,
that contains the NVM subsystem unique identifier assigned
to each controller device in an NVM subsystem.

While attaching a namespace, typically user needs to specify the
controller identifier (cntlid). The cntlid could be referenced from
sysfs (/sys/class/nvme/nvmeX/cntlid) but it would be nice to have
a direct option.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Link: https://lore.kernel.org/r/20240326065752.164286-1-nilay@linux.ibm.com
Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/libnvme.map
src/nvme/private.h
src/nvme/tree.c
src/nvme/tree.h

index c03a99d1010a12081969e1fb469223a089d05ec3..8710c41f5d7ab06db87af990c875af7a63079ba8 100644 (file)
@@ -9,6 +9,7 @@ LIBNVME_1.9 {
                nvme_submit_passthru;
                nvme_submit_passthru64;
                nvme_update_key;
+               nvme_ctrl_get_cntlid;
 };
 
 LIBNVME_1_8 {
index 11744c2575265c2fc14031ff5b929cb2e9431311..723740bed4ec43fdc8b8acc596d04dd8a6ccd01c 100644 (file)
@@ -86,6 +86,7 @@ struct nvme_ctrl {
        char *dhchap_key;
        char *dhchap_ctrl_key;
        char *cntrltype;
+       char *cntlid;
        char *dctype;
        char *phy_slot;
        bool discovery_ctrl;
index 584e3f6afa0d2e55dbd6b1cb71a61802bc293839..6efdf99297e257da633ebf35d72beca6d3c8b6f3 100644 (file)
@@ -1008,6 +1008,11 @@ const char *nvme_ctrl_get_dhchap_host_key(nvme_ctrl_t c)
        return c->dhchap_key;
 }
 
+const char *nvme_ctrl_get_cntlid(nvme_ctrl_t c)
+{
+       return c->cntlid;
+}
+
 void nvme_ctrl_set_dhchap_host_key(nvme_ctrl_t c, const char *key)
 {
        if (c->dhchap_key) {
@@ -1117,6 +1122,7 @@ void nvme_deconfigure_ctrl(nvme_ctrl_t c)
        FREE_CTRL_ATTR(c->address);
        FREE_CTRL_ATTR(c->dctype);
        FREE_CTRL_ATTR(c->cntrltype);
+       FREE_CTRL_ATTR(c->cntlid);
        FREE_CTRL_ATTR(c->phy_slot);
 }
 
@@ -1800,6 +1806,7 @@ static int nvme_configure_ctrl(nvme_root_t r, nvme_ctrl_t c, const char *path,
                }
        }
        c->cntrltype = nvme_get_ctrl_attr(c, "cntrltype");
+       c->cntlid = nvme_get_ctrl_attr(c, "cntlid");
        c->dctype = nvme_get_ctrl_attr(c, "dctype");
        c->phy_slot = nvme_ctrl_lookup_phy_slot(r, c->address);
 
index a30e8eb75dd6138321a816cdfff90910ca3fdfd8..5e82579cb90cd59f40ce42c3369b3955113059ad 100644 (file)
@@ -1025,6 +1025,14 @@ const char *nvme_ctrl_get_host_iface(nvme_ctrl_t c);
  */
 const char *nvme_ctrl_get_dhchap_host_key(nvme_ctrl_t c);
 
+/**
+ *  nvme_ctrl_get_cntlid() - Controller id
+ *  @c:        Controller to be checked
+ *
+ *  Return : Controller id of @c
+ */
+const char *nvme_ctrl_get_cntlid(nvme_ctrl_t c);
+
 /**
  * nvme_ctrl_set_dhchap_host_key() - Set host key
  * @c:         Host for which the key should be set