The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5304a20ff148ddd82e39dbc1ca6bc08dc5deffa4
commit 5304a20ff148ddd82e39dbc1ca6bc08dc5deffa4 Author: John Baldwin <j...@freebsd.org> AuthorDate: 2025-06-04 15:14:13 +0000 Commit: John Baldwin <j...@freebsd.org> CommitDate: 2025-06-04 15:14:13 +0000 cam nvme: Add nvme_command_string Replace nvme_cmd_string and nvme_opcode_string with a single function. nvme_cmd_string was already using an sbuf around a caller-supplied string, so use the same pattern for the entire command string. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D50651 --- sys/cam/nvme/nvme_all.c | 19 ++----------------- sys/cam/nvme/nvme_all.h | 3 +-- sys/cam/nvme/nvme_xpt.c | 7 +++---- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/sys/cam/nvme/nvme_all.c b/sys/cam/nvme/nvme_all.c index 3f264e2ff6eb..4145aa16ed49 100644 --- a/sys/cam/nvme/nvme_all.c +++ b/sys/cam/nvme/nvme_all.c @@ -269,22 +269,7 @@ nvme_print_ident_short(const struct nvme_controller_data *cdata, } const char * -nvme_op_string(const struct nvme_command *cmd, int admin) -{ - const char *s; - - if (admin) - s = admin_opcode[cmd->opc]; - else - s = nvm_opcode[cmd->opc]; - if (s == NULL) - return ("UNKNOWN"); - else - return (s); -} - -const char * -nvme_cmd_string(const struct nvme_command *cmd, char *cmd_string, size_t len) +nvme_command_string(struct ccb_nvmeio *nvmeio, char *cmd_string, size_t len) { struct sbuf sb; int error; @@ -293,7 +278,7 @@ nvme_cmd_string(const struct nvme_command *cmd, char *cmd_string, size_t len) return (""); sbuf_new(&sb, cmd_string, len, SBUF_FIXEDLEN); - nvme_cmd_sbuf(cmd, &sb); + nvme_command_sbuf(nvmeio, &sb); error = sbuf_finish(&sb); if (error != 0 && diff --git a/sys/cam/nvme/nvme_all.h b/sys/cam/nvme/nvme_all.h index a32668ddc1fb..17c068b825be 100644 --- a/sys/cam/nvme/nvme_all.h +++ b/sys/cam/nvme/nvme_all.h @@ -42,11 +42,10 @@ struct sbuf; void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *); void nvme_print_ident_short(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *); -const char *nvme_op_string(const struct nvme_command *, int admin); -const char *nvme_cmd_string(const struct nvme_command *, char *, size_t); void nvme_opcode_sbuf(bool admin, uint8_t opc, struct sbuf *sb); void nvme_cmd_sbuf(const struct nvme_command *, struct sbuf *sb); int nvme_command_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb); +const char *nvme_command_string(struct ccb_nvmeio *nvmeio, char *, size_t); void nvme_cpl_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf); int nvme_status_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb); const void *nvme_get_identify_cntrl(struct cam_periph *); diff --git a/sys/cam/nvme/nvme_xpt.c b/sys/cam/nvme/nvme_xpt.c index 47c0bde1df37..bac9e6441040 100644 --- a/sys/cam/nvme/nvme_xpt.c +++ b/sys/cam/nvme/nvme_xpt.c @@ -833,14 +833,13 @@ nvme_proto_denounce_sbuf(struct cam_ed *device, struct sbuf *sb) static void nvme_proto_debug_out(union ccb *ccb) { - char cdb_str[(sizeof(struct nvme_command) * 3) + 1]; + char command_str[128]; if (ccb->ccb_h.func_code != XPT_NVME_IO && ccb->ccb_h.func_code != XPT_NVME_ADMIN) return; CAM_DEBUG(ccb->ccb_h.path, - CAM_DEBUG_CDB,("%s. NCB: %s\n", nvme_op_string(&ccb->nvmeio.cmd, - ccb->ccb_h.func_code == XPT_NVME_ADMIN), - nvme_cmd_string(&ccb->nvmeio.cmd, cdb_str, sizeof(cdb_str)))); + CAM_DEBUG_CDB,("%s\n", nvme_command_string(&ccb->nvmeio, + command_str, sizeof(command_str)))); }