From: Nilay Shroff Date: Tue, 26 Mar 2024 06:57:23 +0000 (+0530) Subject: tree: Add NVM subsystem controller identifier X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d638f037623742003c5ef0ba6127b981e925b351;p=users%2Fsagi%2Flibnvme.git tree: Add NVM subsystem controller identifier 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 Link: https://lore.kernel.org/r/20240326065752.164286-1-nilay@linux.ibm.com Signed-off-by: Daniel Wagner --- diff --git a/src/libnvme.map b/src/libnvme.map index c03a99d1..8710c41f 100644 --- a/src/libnvme.map +++ b/src/libnvme.map @@ -9,6 +9,7 @@ LIBNVME_1.9 { nvme_submit_passthru; nvme_submit_passthru64; nvme_update_key; + nvme_ctrl_get_cntlid; }; LIBNVME_1_8 { diff --git a/src/nvme/private.h b/src/nvme/private.h index 11744c25..723740be 100644 --- a/src/nvme/private.h +++ b/src/nvme/private.h @@ -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; diff --git a/src/nvme/tree.c b/src/nvme/tree.c index 584e3f6a..6efdf992 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -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); diff --git a/src/nvme/tree.h b/src/nvme/tree.h index a30e8eb7..5e82579c 100644 --- a/src/nvme/tree.h +++ b/src/nvme/tree.h @@ -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