The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7b3ee39e73af36f49f471f7900baeb98ac3504d0
commit 7b3ee39e73af36f49f471f7900baeb98ac3504d0 Author: John Baldwin <j...@freebsd.org> AuthorDate: 2025-06-06 01:28:38 +0000 Commit: John Baldwin <j...@freebsd.org> CommitDate: 2025-06-06 01:28:38 +0000 libcam: Include nvme opcode and status code routines from nvme_util.c libcam in userspace also includes nvme_all.c which now depends on nvme_util.c, so add nvme_util.c to libcam's sources. This requires exporting the opcode and status code routines in nvme_util.c to userspace as well as the kernel. In turn, this means nvmecontrol now depends on libsbuf (which is already present in /lib). Reported by: viswhin, Jenkins Fixes: 60159a98a837 ("nvme: Move opcode and status code tables from base CAM to nvme_util.c") Sponsored by: Chelsio Communications --- lib/libcam/Makefile | 5 +++-- sbin/nvmecontrol/Makefile | 2 +- sys/dev/nvme/nvme.h | 13 ++++++++----- sys/dev/nvme/nvme_util.c | 4 ---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/libcam/Makefile b/lib/libcam/Makefile index c2f7b75bc878..d4efbbdf4d9b 100644 --- a/lib/libcam/Makefile +++ b/lib/libcam/Makefile @@ -3,7 +3,7 @@ PACKAGE= runtime LIB= cam SHLIBDIR?= /lib SRCS= camlib.c scsi_cmdparse.c scsi_all.c scsi_da.c scsi_sa.c cam.c \ - ata_all.c nvme_all.c smp_all.c scsi_wrap.c + ata_all.c nvme_all.c nvme_util.c smp_all.c scsi_wrap.c INCS= camlib.h scsi_wrap.h LIBADD= sbuf @@ -39,7 +39,8 @@ MLINKS+= cam.3 cam_open_device.3 \ ${SRCTOP}/sys/cam/ata \ ${SRCTOP}/sys/cam/nvme \ ${SRCTOP}/sys/cam/mmc \ - ${SRCTOP}/sys/cam/scsi + ${SRCTOP}/sys/cam/scsi \ + ${SRCTOP}/sys/dev/nvme CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys diff --git a/sbin/nvmecontrol/Makefile b/sbin/nvmecontrol/Makefile index 2abcd72dedfa..cf9c23548e36 100644 --- a/sbin/nvmecontrol/Makefile +++ b/sbin/nvmecontrol/Makefile @@ -30,7 +30,7 @@ SRCS+= telemetry.c CFLAGS+= -I${SRCTOP}/lib/libnvmf MAN= nvmecontrol.8 LDFLAGS+= -rdynamic -LIBADD+= nvmf util +LIBADD+= nvmf sbuf util SUBDIR= modules HAS_TESTS= SUBDIR.${MK_TESTS}+= tests diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h index 87f1da4d281d..17c5cdb4db87 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -35,6 +35,11 @@ #include <sys/param.h> #include <sys/endian.h> +#ifndef _KERNEL +#include <stdbool.h> +#endif + +struct sbuf; #define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command) #define NVME_RESET_CONTROLLER _IO('n', 1) @@ -1901,12 +1906,14 @@ struct nvme_hmb_desc { #define nvme_completion_is_error(cpl) \ (NVME_STATUS_GET_SC((cpl)->status) != 0 || NVME_STATUS_GET_SCT((cpl)->status) != 0) +void nvme_cpl_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf); +void nvme_opcode_sbuf(bool admin, uint8_t opc, struct sbuf *sb); +void nvme_sc_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf); void nvme_strvis(uint8_t *dst, const uint8_t *src, int dstlen, int srclen); #ifdef _KERNEL struct bio; -struct sbuf; struct thread; struct nvme_namespace; @@ -1927,10 +1934,6 @@ enum nvme_namespace_flags { NVME_NS_FLUSH_SUPPORTED = 0x2, }; -void nvme_cpl_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf); -void nvme_opcode_sbuf(bool admin, uint8_t opc, struct sbuf *sb); -void nvme_sc_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf); - int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr, struct nvme_pt_command *pt, uint32_t nsid, int is_user_buffer, diff --git a/sys/dev/nvme/nvme_util.c b/sys/dev/nvme/nvme_util.c index 050dfcfbef79..0a07653a7378 100644 --- a/sys/dev/nvme/nvme_util.c +++ b/sys/dev/nvme/nvme_util.c @@ -30,12 +30,9 @@ */ #include <sys/param.h> -#ifdef _KERNEL #include <sys/sbuf.h> -#endif #include <dev/nvme/nvme.h> -#ifdef _KERNEL #define OPC_ENTRY(x) [NVME_OPC_ ## x] = #x static const char *admin_opcode[256] = { @@ -269,7 +266,6 @@ nvme_cpl_sbuf(const struct nvme_completion *cpl, struct sbuf *sb) if (NVME_STATUS_GET_DNR(status) != 0) sbuf_printf(sb, " DNR"); } -#endif void nvme_strvis(uint8_t *dst, const uint8_t *src, int dstlen, int srclen)