Add encoding for MI/NVMe status values#502
Merged
igaw merged 2 commits intolinux-nvme:masterfrom Oct 24, 2022
Merged
Conversation
We curerently have some overloading in the status values returned from the nvme_* API, as the NVMe CDW3 values overlap with the recently-introduced NVMe-MI response header status. This change introduces a new encoding for the return values of MI functions, where we use a set of bits in the return value to encode whether the value is either a MI status value or a NVMe status value. We leave room for future expansion too, by defining three bits of possible type values. This has minimal change to the current API, as we're using 0 for the current NVMe status codes, so they are all unchanged. Since the MI values alised those, they will have high bits set now, but we couldn't previously distinguish them from the NVMe values anyway. Fixes: linux-nvme#456 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Add a function, similar to nvme_status_to_string(), that returns a string value of the spec-defined wording for each status value. We keep this in the mi object for now, to keep the existing division of libnvme.so/libnvme-mi.so Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Codecov Report
@@ Coverage Diff @@
## master #502 +/- ##
==========================================
- Coverage 24.20% 24.17% -0.03%
==========================================
Files 31 31
Lines 5946 5953 +7
Branches 1225 1230 +5
==========================================
Hits 1439 1439
- Misses 4028 4031 +3
- Partials 479 483 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As a fix for #456, this PR adds a new encoding for the status values of the
nvme_mi_*andnvme_*API, with the latter being completely unchanged.To do this, we use the top set of bits in the
intreturn value as an encoding of the "type" of status value; possible types are currently NVMe (as existing, from CDW3), and MI (from the status field of the MI header). The most-significant bit is already used for the sign bit (where negative values already represent internal errors, rather than NVMe status), so we use the next three significant bits to represent a type, and allow for future expansion of the possible types in futureFor NVMe status, we only need the lower 15 bits of the int; for MI, we only need the lower 8.
So, an NVMe status value is encoded as
(ie, exactly matching the existing usage in the API)
and an MI status value encoded as:
(ie, indicating MI in the type bits)
Corresponding changes to
nvme-clicoming soon in a draft PR.As always: comments, questions and feedback are most welcome.