]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
Fix a bug where CSI was not passed to to nvme_ns_mgmt
authorAndreas Hindborg <andreas.hindborg@wdc.com>
Fri, 17 Sep 2021 14:21:28 +0000 (16:21 +0200)
committerAndreas Hindborg <andreas.hindborg@wdc.com>
Wed, 29 Sep 2021 13:11:04 +0000 (15:11 +0200)
Signed-off-by: Andreas Hindborg <andreas.hindborg@wdc.com>
src/nvme/ioctl.c
src/nvme/ioctl.h

index 0863467fa1e5a83957fda62076cce1345c745157..9a8526d6527f4b1306e358e4813dc7441e6e84d9 100644 (file)
@@ -249,6 +249,8 @@ enum nvme_cmd_dword_fields {
        NVME_NAMESPACE_ATTACH_CDW10_SEL_MASK                    = 0xf,
        NVME_NAMESPACE_MGMT_CDW10_SEL_SHIFT                     = 0,
        NVME_NAMESPACE_MGMT_CDW10_SEL_MASK                      = 0xf,
+       NVME_NAMESPACE_MGMT_CDW11_CSI_SHIFT                     = 24,
+       NVME_NAMESPACE_MGMT_CDW11_CSI_MASK                      = 0xff,
        NVME_VIRT_MGMT_CDW10_ACT_SHIFT                          = 0,
        NVME_VIRT_MGMT_CDW10_RT_SHIFT                           = 8,
        NVME_VIRT_MGMT_CDW10_CNTLID_SHIFT                       = 16,
@@ -1246,33 +1248,36 @@ int nvme_format_nvm(int fd, __u32 nsid, __u8 lbaf,
 }
 
 int nvme_ns_mgmt(int fd, __u32 nsid, enum nvme_ns_mgmt_sel sel,
-                struct nvme_id_ns *ns, __u32 *result, __u32 timeout)
+                struct nvme_id_ns *ns, __u32 *result, __u32 timeout, __u8 csi)
 {
-       __u32 cdw10 = NVME_SET(sel, NAMESPACE_MGMT_CDW10_SEL);
+       __u32 cdw10    = NVME_SET(sel, NAMESPACE_MGMT_CDW10_SEL);
+       __u32 cdw11    = NVME_SET(csi, NAMESPACE_MGMT_CDW11_CSI);
        __u32 data_len = ns ? sizeof(*ns) : 0;
 
        struct nvme_passthru_cmd cmd = {
-               .nsid           = nsid,
-               .opcode         = nvme_admin_ns_mgmt,
-               .cdw10          = cdw10,
-               .timeout_ms     = timeout,
-               .data_len       = data_len,
-               .addr           = (__u64)(uintptr_t)ns,
+               .nsid       = nsid,
+               .opcode     = nvme_admin_ns_mgmt,
+               .cdw10      = cdw10,
+               .cdw11      = cdw11,
+               .timeout_ms = timeout,
+               .data_len   = data_len,
+               .addr       = (__u64)(uintptr_t)ns,
        };
 
        return nvme_submit_admin_passthru(fd, &cmd, result);
 }
 
 int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns, __u32 *nsid,
-                       __u32 timeout)
+                       __u32 timeout, __u8 csi)
 {
-       return nvme_ns_mgmt(fd, NVME_NSID_NONE, NVME_NS_MGMT_SEL_CREATE, ns, nsid,
-                           timeout);
+       return nvme_ns_mgmt(fd, NVME_NSID_NONE, NVME_NS_MGMT_SEL_CREATE, ns,
+                           nsid, timeout, csi);
 }
 
 int nvme_ns_mgmt_delete(int fd, __u32 nsid)
 {
-       return nvme_ns_mgmt(fd, nsid, NVME_NS_MGMT_SEL_DELETE, NULL, NULL, 0);
+       return nvme_ns_mgmt(fd, nsid, NVME_NS_MGMT_SEL_DELETE, NULL, NULL, 0,
+                           0);
 }
 
 int nvme_ns_attach(int fd, __u32 nsid, enum nvme_ns_attach_sel sel,
index 2b5a2108a84a965dde2209aa0e829cf30e8f3691..a040da5d0b306b4d658adcb0a1b78f23cb82efc1 100644 (file)
@@ -2279,17 +2279,19 @@ int nvme_format_nvm(int fd, __u32 nsid, __u8 lbaf,
 /**
  * nvme_ns_mgmt() -
  * @fd:                File descriptor of nvme device
+ * @csi:               Command Set Identifier
  */
 int nvme_ns_mgmt(int fd, __u32 nsid, enum nvme_ns_mgmt_sel sel,
-                struct nvme_id_ns *ns, __u32 *result, __u32 timeout);
+                struct nvme_id_ns *ns, __u32 *result, __u32 timeout, __u8 csi);
 
 /**
  * nvme_ns_mgmt_create() -
  * @fd:                File descriptor of nvme device
- * @ns:                Namespace identifiaction that defines creation parameters
- * @nsid:      On success, set to the namespace id that was created
- * @timeout:   Overide the default timeout to this value in milliseconds;
- *             set to 0 to use the system default.
+ * @ns:                Namespace identification that defines ns creation parameters
+ * @nsid:              On success, set to the namespace id that was created
+ * @timeout:           Overide the default timeout to this value in milliseconds;
+ *                     set to 0 to use the system default.
+ * @csi:               Command Set Identifier
  *
  * On successful creation, the namespace exists in the subsystem, but is not
  * attached to any controller. Use the &nvme_ns_attach_ctrls() to assign the
@@ -2299,7 +2301,7 @@ int nvme_ns_mgmt(int fd, __u32 nsid, enum nvme_ns_mgmt_sel sel,
  * &enum nvme_status_field) or -1 with errno set otherwise.
  */
 int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns, __u32 *nsid,
-                       __u32 timeout);
+                       __u32 timeout, __u8 csi);
 
 /**
  * nvme_ns_mgmt_delete() -