]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: Add cntrltype and dctype to the controller object
authorMartin Belanger <martin.belanger@dell.com>
Wed, 16 Feb 2022 15:11:05 +0000 (10:11 -0500)
committerDaniel Wagner <dwagner@suse.de>
Mon, 21 Feb 2022 11:34:54 +0000 (12:34 +0100)
The Discovery Controller Type (dctype) is a new attribute defined
in TP8010. This new attribute, as well as the existing Controller
Type (cntrltype) attributes will now be exposed through the sysfs
starting with kernel 5.18. For older kernels, the cntrltype and
dctype must be retrieved by performing a Identify command.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
[dwagner: Removed nvme_fetch_cntrltype_dctype_from_id]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/nvme/private.h
src/nvme/tree.c

index 43c65ea52b82069c05c861795dcf5688512e2dca..bea1ae9e6e99654e0e8fe51fe6e15d0c0f7ea853 100644 (file)
@@ -80,6 +80,8 @@ struct nvme_ctrl {
        char *traddr;
        char *trsvcid;
        char *dhchap_key;
+       char *cntrltype;
+       char *dctype;
        bool discovery_ctrl;
        bool discovered;
        bool persistent;
index 51bbf1492f724c88648670225f0e7e105e343fd3..33be5f5e87400cafeb01babcc5cf5ee26c54573b 100644 (file)
@@ -860,6 +860,8 @@ void nvme_deconfigure_ctrl(nvme_ctrl_t c)
        FREE_CTRL_ATTR(c->serial);
        FREE_CTRL_ATTR(c->sqsize);
        FREE_CTRL_ATTR(c->address);
+       FREE_CTRL_ATTR(c->dctype);
+       FREE_CTRL_ATTR(c->cntrltype);
 }
 
 int nvme_disconnect_ctrl(nvme_ctrl_t c)
@@ -1129,6 +1131,9 @@ static int nvme_configure_ctrl(nvme_root_t r, nvme_ctrl_t c, const char *path,
                free(c->dhchap_key);
                c->dhchap_key = NULL;
        }
+       c->cntrltype = nvme_get_ctrl_attr(c, "cntrltype");
+       c->dctype = nvme_get_ctrl_attr(c, "dctype");
+
        return 0;
 }