Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example: fix mi identify failed with error cntid #779

Merged

Conversation

zhangjian3032
Copy link
Contributor

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.

@igaw igaw requested a review from jk-ozlabs February 7, 2024 13:51
Copy link
Collaborator

@jk-ozlabs jk-ozlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core of this change looks good (setting CNTID to 0), but you have unrelated changes that break input validation on the controller id passed from the command-line.

If you can remove those unrelated changes, then we should be fine.

examples/mi-mctp.c Outdated Show resolved Hide resolved
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>
@zhangjian3032 zhangjian3032 force-pushed the dev-example-fix-mi-identify-error branch from 9da7ce1 to 67f4e8a Compare February 8, 2024 02:53
Copy link
Collaborator

@jk-ozlabs jk-ozlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, LGTM! Thanks for the fix.

@igaw igaw merged commit 24a5580 into linux-nvme:master Feb 8, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants