]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
example: fix mi identify failed with error cntid
authorJian Zhang <zhangjian.3032@bytedance.com>
Wed, 7 Feb 2024 11:06:17 +0000 (19:06 +0800)
committerDaniel Wagner <wagi@monom.org>
Thu, 8 Feb 2024 09:12:43 +0000 (10:12 +0100)
This command failed when we try to identify a controller that the
controller id is 1.

Refer to the `Figure 273: Identify - CNS Values`:
+-----------+-------+
| CNS Value | CNTID |
+-----------+-------+
| 01h       | N     |
+-----------+-------+
When CNS is 01h, the CNTID field is ignored.

See `Figure 270: Identify - Command Dword 10`:
If this field is not used as part of the Identify operation, then
* host software shall clear this field to 0h for backwards compatibility
(0h is a valid controller identifier);
* and the controller shall ignore this field.

This filed is set to controller id in the example code, but it should be
0 when CNS is 1.

PS: The NVMe that we are testing does not ignore the CNTID field and
returns an error when the CNTID field is not 0.

Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
examples/mi-mctp.c

index 801924913d660cdf1d9cb864a680c94191afbfed..e0b7644e6a16f4c161479ab323c2d5320b13fc57 100644 (file)
@@ -201,7 +201,7 @@ int do_identify(nvme_mi_ep_t ep, int argc, char **argv)
 
        partial = argc > 2 && !strcmp(argv[2], "--partial");
 
-       ctrl = nvme_mi_init_ctrl(ep, tmp);
+       ctrl = nvme_mi_init_ctrl(ep, ctrl_id);
        if (!ctrl) {
                warn("can't create controller");
                return -1;
@@ -211,7 +211,7 @@ int do_identify(nvme_mi_ep_t ep, int argc, char **argv)
        id_args.args_size = sizeof(id_args);
        id_args.cns = NVME_IDENTIFY_CNS_CTRL;
        id_args.nsid = NVME_NSID_NONE;
-       id_args.cntid = ctrl_id;
+       id_args.cntid = 0;
        id_args.csi = NVME_CSI_NVM;
 
        /* for this example code, we can either do a full or partial identify;