Skip to content

Commit 7da1df8

Browse files
committed
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 6465c07 commit 7da1df8

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

libnvme/src/nvme/util.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ 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_OVERLAPPING_RANGE:
117+
return "Overlapping Range: LBA range type data structure";
118+
default:
119+
break;
120+
}
121+
122+
return NULL;
123+
};
124+
106125
/**
107126
* nvme_opcode_status_to_string() - Returns nvme opcode status string.
108127
* @status: Return status from an nvme passthrough command
@@ -120,8 +139,18 @@ nvme_opcode_status_to_string(int status, bool admin, __u8 opcode)
120139
const char *s = NULL;
121140

122141
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);
142+
if (admin) {
143+
switch (opcode) {
144+
case nvme_admin_sanitize_ns:
145+
s = nvme_sanitize_ns_status_to_string(sc);
146+
break;
147+
case nvme_admin_set_features:
148+
s = nvme_set_features_status_to_string(sc);
149+
break;
150+
default:
151+
break;
152+
}
153+
}
125154
}
126155

127156
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)