Skip to content

Commit cdf693f

Browse files
ikegami-tigaw
authored andcommitted
nvme: add get and set features specific status code string
Since the status code is duplicated with the fw-download status code. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent e1a3564 commit cdf693f

3 files changed

Lines changed: 58 additions & 3 deletions

File tree

libnvme/src/nvme/types.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8215,6 +8215,11 @@ struct nvme_mi_vpd_hdr {
82158215
* @NVME_SC_NS_INSUFFICIENT_CAP: Namespace Insufficient Capacity: Creating
82168216
* the namespace requires more free space
82178217
* than is currently available.
8218+
* @NVME_SC_FEAT_IOCS_COMBINATION_REJECTED: Set Features - I/O Command Set
8219+
* Combination Rejected: This error indicates
8220+
* that the controller did not accept the
8221+
* request to select the requested I/O
8222+
* Command Set Combination.
82188223
* @NVME_SC_NS_ID_UNAVAILABLE: Namespace Identifier Unavailable: The
82198224
* number of namespaces supported has been
82208225
* exceeded.
@@ -8306,6 +8311,10 @@ struct nvme_mi_vpd_hdr {
83068311
* suspended.
83078312
* @NVME_SC_CONTROLLER_DATA_QUEUE_FULL: The controller detected that a
83088313
* Controller Data Queue became full.
8314+
* @NVME_SC_INVALID_POWER_LIMIT: Invalid Power Limit: The power limit
8315+
* specified for the Power Limit feature is
8316+
* invalid because that power limit prohibits
8317+
* all operational power states.
83098318
* @NVME_SC_BAD_ATTRIBUTES: Conflicting Dataset Management Attributes
83108319
* @NVME_SC_INVALID_PI: Invalid Protection Information
83118320
* @NVME_SC_READ_ONLY: Attempted Write to Read Only Range
@@ -8535,6 +8544,7 @@ enum nvme_status_field {
85358544
NVME_SC_FW_ACTIVATE_PROHIBITED = 0x13,
85368545
NVME_SC_OVERLAPPING_RANGE = 0x14,
85378546
NVME_SC_NS_INSUFFICIENT_CAP = 0x15,
8547+
NVME_SC_FEAT_IOCS_COMBINATION_REJECTED = 0x15,
85388548
NVME_SC_NS_ID_UNAVAILABLE = 0x16,
85398549
NVME_SC_NS_ALREADY_ATTACHED = 0x18,
85408550
NVME_SC_NS_IS_PRIVATE = 0x19,
@@ -8582,6 +8592,11 @@ enum nvme_status_field {
85828592
NVME_SC_CONTROLLER_NOT_SUSPENDED = 0x3A,
85838593
NVME_SC_CONTROLLER_DATA_QUEUE_FULL = 0x3B,
85848594

8595+
/*
8596+
* Command Set Specific - Set Features
8597+
*/
8598+
NVME_SC_INVALID_POWER_LIMIT = 0x3e,
8599+
85858600
/*
85868601
* I/O Command Set Specific - NVM commands:
85878602
*/

libnvme/src/nvme/util.h

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,35 @@ nvme_sanitize_ns_status_to_string(__u16 sc)
103103
return NULL;
104104
};
105105

106+
/**
107+
* nvme_set_features_status_to_string() - Returns set features status string.
108+
* @sc: Return status code from an set features command
109+
*
110+
* Return: The set features status string if it is a specific status code.
111+
*/
112+
static inline const char *
113+
nvme_set_features_status_to_string(__u16 sc)
114+
{
115+
switch (sc) {
116+
case NVME_SC_FEATURE_NOT_SAVEABLE:
117+
case NVME_SC_FEATURE_NOT_CHANGEABLE:
118+
case NVME_SC_FEATURE_NOT_PER_NS:
119+
break;
120+
case NVME_SC_OVERLAPPING_RANGE:
121+
return "Overlapping Range: LBA range type data structure";
122+
case NVME_SC_FEAT_IOCS_COMBINATION_REJECTED:
123+
return "I/O Command Set Combination Rejected";
124+
case NVME_SC_INVALID_CONTROLER_DATA_QUEUE:
125+
break;
126+
case NVME_SC_INVALID_POWER_LIMIT:
127+
return "Invalid Power Limit";
128+
default:
129+
break;
130+
}
131+
132+
return NULL;
133+
};
134+
106135
/**
107136
* nvme_opcode_status_to_string() - Returns nvme opcode status string.
108137
* @status: Return status from an nvme passthrough command
@@ -120,8 +149,18 @@ nvme_opcode_status_to_string(int status, bool admin, __u8 opcode)
120149
const char *s = NULL;
121150

122151
if (status >= 0 && sct == NVME_SCT_CMD_SPECIFIC) {
123-
if (admin && opcode == nvme_admin_sanitize_ns)
124-
s = nvme_sanitize_ns_status_to_string(sc);
152+
if (admin) {
153+
switch (opcode) {
154+
case nvme_admin_sanitize_ns:
155+
s = nvme_sanitize_ns_status_to_string(sc);
156+
break;
157+
case nvme_admin_set_features:
158+
s = nvme_set_features_status_to_string(sc);
159+
break;
160+
default:
161+
break;
162+
}
163+
}
125164
}
126165

127166
if (s)

nvme.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6995,7 +6995,8 @@ static int set_feature(int argc, char **argv, struct command *acmd, struct plugi
69956995
err = nvme_set_features(hdl, cfg.nsid, cfg.fid, cfg.sv, cfg.value, cfg.cdw12,
69966996
0, cfg.uidx, 0, buf, cfg.data_len, &result);
69976997
if (err) {
6998-
nvme_show_err("set-feature", err);
6998+
nvme_show_admin_cmd_err("set-feature", nvme_admin_set_features,
6999+
err);
69997000
return err;
70007001
}
70017002

0 commit comments

Comments
 (0)