]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
mi: Add nvme_mi_ctrl_id to retrieve controller ID
authorJeremy Kerr <jk@codeconstruct.com.au>
Thu, 27 Apr 2023 07:07:46 +0000 (15:07 +0800)
committerDaniel Wagner <wagi@monom.org>
Thu, 27 Apr 2023 13:15:39 +0000 (15:15 +0200)
Controllers may be scanned through nvme_mi_scan_ep, in which case the
caller will not have access to the underlying controller IDs.

Add an accessor function to retrieve the controller ID for use in
subsequent commands (like namespace attach).

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
src/libnvme-mi.map
src/nvme/mi.c
src/nvme/mi.h

index 0b8b5b7f692770d753a9427de0e4f7de8a25a7d9..f1ce71252a2480245b5ca888e31de79bfa2ecc42 100644 (file)
@@ -1,3 +1,8 @@
+LIBNVME_MI_1_5 {
+       global:
+               nvme_mi_ctrl_id;
+};
+
 LIBNVME_MI_1_4 {
         global:
                 nvme_mi_admin_get_log_page;
index 6b20edc40065aeb746056424f735166a89551f63..3799f35cb3ad8bd890dd3b34dc4e67fbb17d8b6d 100644 (file)
@@ -304,6 +304,11 @@ struct nvme_mi_ctrl *nvme_mi_init_ctrl(nvme_mi_ep_t ep, __u16 ctrl_id)
        return ctrl;
 }
 
+__u16 nvme_mi_ctrl_id(nvme_mi_ctrl_t ctrl)
+{
+       return ctrl->id;
+}
+
 int nvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan)
 {
        struct nvme_ctrl_list list;
index d22e1a5d726a9f91dc31f161009e480ade4111f4..211cb2925a540424a968a9a56ab22906b7712988 100644 (file)
@@ -654,6 +654,20 @@ nvme_mi_ctrl_t nvme_mi_init_ctrl(nvme_mi_ep_t ep, __u16 ctrl_id);
  */
 void nvme_mi_close_ctrl(nvme_mi_ctrl_t ctrl);
 
+/**
+ * nvme_mi_ctrl_id() - get the ID of a controller
+ * @ctrl: controller to query
+ *
+ * Retrieve the ID of the controller, as defined by hardware, and available
+ * in the Identify (Controller List) data. This is the value passed to
+ * @nvme_mi_init_ctrl, but may have been created internally via
+ * @nvme_mi_scan_ep.
+ *
+ * Return: the (locally-stored) ID of this controller.
+ */
+__u16 nvme_mi_ctrl_id(nvme_mi_ctrl_t ctrl);
+
+
 /**
  * nvme_mi_endpoint_desc - Get a string describing a MI endpoint.
  * @ep: endpoint to describe