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:		60159a98a8 ("nvme: Move opcode and status code tables from base CAM to nvme_util.c")
Sponsored by:	Chelsio Communications
This commit is contained in:
John Baldwin 2025-06-05 21:28:38 -04:00
parent 934df0ca61
commit 7b3ee39e73
4 changed files with 12 additions and 12 deletions

View file

@ -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

View file

@ -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

View file

@ -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,

View file

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