]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
mi: Add Identify helper for ns-descs and primary-ctrl-caps
authorJinliang Wang <jinliangw@google.com>
Tue, 11 Oct 2022 17:20:58 +0000 (10:20 -0700)
committerDaniel Wagner <dwagner@suse.de>
Fri, 21 Oct 2022 08:06:25 +0000 (10:06 +0200)
This change adds two helpers for the Identify command, retrieving the
namespace identification descriptior list and primary controller capabilities
data structure.

Signed-off-by: Jinliang Wang <jinliangw@google.com>
src/nvme/mi.h

index 74252a971f08cb75a606c71452556d6131bee2fa..5b1766039b88c8b8777c7f10e66a35f668b6f88d 100644 (file)
@@ -1055,6 +1055,27 @@ static inline int nvme_mi_admin_identify_ns(nvme_mi_ctrl_t ctrl, __u32 nsid,
                                               nsid, ns);
 }
 
+/**
+ * nvme_mi_admin_identify_ns_descs() - Perform an Admin identify Namespace
+ * Identification Descriptor list command for a namespace
+ * @ctrl: Controller to process identify command
+ * @nsid: Namespace ID
+ * @descs: Namespace Identification Descriptor list to populate
+ *
+ * Perform an Identify namespace identification description list command,
+ * setting the namespace identification description list in @descs
+ *
+ * Return: The nvme command status if a response was received (see
+ * &enum nvme_status_field) or -1 with errno set otherwise.
+ */
+static inline int nvme_mi_admin_identify_ns_descs(nvme_mi_ctrl_t ctrl,
+                                                 __u32 nsid,
+                                                 struct nvme_ns_id_desc *descs)
+{
+       return nvme_mi_admin_identify_cns_nsid(ctrl, NVME_IDENTIFY_CNS_NS_DESC_LIST,
+                                              nsid, descs);
+}
+
 /**
  * nvme_mi_admin_identify_allocated_ns() - Perform an Admin identify command
  * for an allocated namespace
@@ -1254,6 +1275,43 @@ static inline int nvme_mi_admin_identify_active_ns_list(nvme_mi_ctrl_t ctrl,
        return nvme_mi_admin_identify(ctrl, &args);
 }
 
+/**
+ * nvme_mi_admin_identify_primary_ctrl() - Perform an Admin identify for
+ * primary controller capabilities data structure.
+ * @ctrl: Controller to process identify command
+ * @cntid: Controller ID to specify
+ * @cap: Primary Controller Capabilities data structure to populate
+ *
+ * Perform an Identify command to get the Primary Controller Capabilities data
+ * for the controller specified by @cntid
+ *
+ * Will return an error if the length of the response data (from the
+ * controller) is not a full &NVME_IDENTIFY_DATA_SIZE, so @cap will be
+ * be fully populated on success.
+ *
+ * Return: 0 on success, non-zero on failure
+ *
+ * See: &struct nvme_primary_ctrl_cap
+ */
+static inline int nvme_mi_admin_identify_primary_ctrl(nvme_mi_ctrl_t ctrl,
+                                                     __u16 cntid,
+                                                     struct nvme_primary_ctrl_cap *cap)
+{
+       struct nvme_identify_args args = {
+               .result = NULL,
+               .data = cap,
+               .args_size = sizeof(args),
+               .cns = NVME_IDENTIFY_CNS_PRIMARY_CTRL_CAP,
+               .csi = NVME_CSI_NVM,
+               .nsid = NVME_NSID_NONE,
+               .cntid = cntid,
+               .cns_specific_id = NVME_CNSSPECID_NONE,
+               .uuidx = NVME_UUID_NONE,
+       };
+
+       return nvme_mi_admin_identify(ctrl, &args);
+}
+
 /**
  * nvme_mi_admin_identify_secondary_ctrl_list() - Perform an Admin identify for
  * a secondary controller list.