Skip to content

Commit 30e77e0

Browse files
damien-lemoalkeithbusch
authored andcommitted
nvme: Move opcode string helper functions declarations
Move the declaration of all helper functions converting NVMe command opcodes and status codes into strings from drivers/nvme/host/nvme.h into include/linux/nvme.h, together with the commands definitions. This allows NVMe target drivers to call these functions without having to include a host header file. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Tested-by: Rick Wertenbroek <[email protected]> Tested-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 002bb02 commit 30e77e0

File tree

2 files changed

+40
-39
lines changed

2 files changed

+40
-39
lines changed

drivers/nvme/host/nvme.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,43 +1182,4 @@ static inline bool nvme_multi_css(struct nvme_ctrl *ctrl)
11821182
return (ctrl->ctrl_config & NVME_CC_CSS_MASK) == NVME_CC_CSS_CSI;
11831183
}
11841184

1185-
#ifdef CONFIG_NVME_VERBOSE_ERRORS
1186-
const char *nvme_get_error_status_str(u16 status);
1187-
const char *nvme_get_opcode_str(u8 opcode);
1188-
const char *nvme_get_admin_opcode_str(u8 opcode);
1189-
const char *nvme_get_fabrics_opcode_str(u8 opcode);
1190-
#else /* CONFIG_NVME_VERBOSE_ERRORS */
1191-
static inline const char *nvme_get_error_status_str(u16 status)
1192-
{
1193-
return "I/O Error";
1194-
}
1195-
static inline const char *nvme_get_opcode_str(u8 opcode)
1196-
{
1197-
return "I/O Cmd";
1198-
}
1199-
static inline const char *nvme_get_admin_opcode_str(u8 opcode)
1200-
{
1201-
return "Admin Cmd";
1202-
}
1203-
1204-
static inline const char *nvme_get_fabrics_opcode_str(u8 opcode)
1205-
{
1206-
return "Fabrics Cmd";
1207-
}
1208-
#endif /* CONFIG_NVME_VERBOSE_ERRORS */
1209-
1210-
static inline const char *nvme_opcode_str(int qid, u8 opcode)
1211-
{
1212-
return qid ? nvme_get_opcode_str(opcode) :
1213-
nvme_get_admin_opcode_str(opcode);
1214-
}
1215-
1216-
static inline const char *nvme_fabrics_opcode_str(
1217-
int qid, const struct nvme_command *cmd)
1218-
{
1219-
if (nvme_is_fabrics(cmd))
1220-
return nvme_get_fabrics_opcode_str(cmd->fabrics.fctype);
1221-
1222-
return nvme_opcode_str(qid, cmd->common.opcode);
1223-
}
12241185
#endif /* _NVME_H */

include/linux/nvme.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,46 @@ static inline bool nvme_is_fabrics(const struct nvme_command *cmd)
18961896
return cmd->common.opcode == nvme_fabrics_command;
18971897
}
18981898

1899+
#ifdef CONFIG_NVME_VERBOSE_ERRORS
1900+
const char *nvme_get_error_status_str(u16 status);
1901+
const char *nvme_get_opcode_str(u8 opcode);
1902+
const char *nvme_get_admin_opcode_str(u8 opcode);
1903+
const char *nvme_get_fabrics_opcode_str(u8 opcode);
1904+
#else /* CONFIG_NVME_VERBOSE_ERRORS */
1905+
static inline const char *nvme_get_error_status_str(u16 status)
1906+
{
1907+
return "I/O Error";
1908+
}
1909+
static inline const char *nvme_get_opcode_str(u8 opcode)
1910+
{
1911+
return "I/O Cmd";
1912+
}
1913+
static inline const char *nvme_get_admin_opcode_str(u8 opcode)
1914+
{
1915+
return "Admin Cmd";
1916+
}
1917+
1918+
static inline const char *nvme_get_fabrics_opcode_str(u8 opcode)
1919+
{
1920+
return "Fabrics Cmd";
1921+
}
1922+
#endif /* CONFIG_NVME_VERBOSE_ERRORS */
1923+
1924+
static inline const char *nvme_opcode_str(int qid, u8 opcode)
1925+
{
1926+
return qid ? nvme_get_opcode_str(opcode) :
1927+
nvme_get_admin_opcode_str(opcode);
1928+
}
1929+
1930+
static inline const char *nvme_fabrics_opcode_str(
1931+
int qid, const struct nvme_command *cmd)
1932+
{
1933+
if (nvme_is_fabrics(cmd))
1934+
return nvme_get_fabrics_opcode_str(cmd->fabrics.fctype);
1935+
1936+
return nvme_opcode_str(qid, cmd->common.opcode);
1937+
}
1938+
18991939
struct nvme_error_slot {
19001940
__le64 error_count;
19011941
__le16 sqid;

0 commit comments

Comments
 (0)