diff --git a/rescue/rescue/Makefile b/rescue/rescue/Makefile index 6dceea6f507..2c31323c250 100644 --- a/rescue/rescue/Makefile +++ b/rescue/rescue/Makefile @@ -144,6 +144,7 @@ CRUNCH_PROGS_usr.sbin+= zdb # CRUNCH_PROGS+= devd CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma +CRUNCH_LIBS_camcontrol+= ${LIBNVMF} .if ${MK_ZFS} != "no" CRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt CRUNCH_LIBS_zfs+= ${LIBBE} \ diff --git a/sbin/camcontrol/Makefile b/sbin/camcontrol/Makefile index b04eb5614c6..64703f656a8 100644 --- a/sbin/camcontrol/Makefile +++ b/sbin/camcontrol/Makefile @@ -24,7 +24,8 @@ SRCS+= nvme_util.c .if ${MACHINE_CPUARCH} == "arm" WARNS?= 3 .endif -LIBADD= cam sbuf util +CFLAGS+= -I${SRCTOP}/lib/libnvmf +LIBADD= cam nvmf sbuf util MAN= camcontrol.8 .include diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c index db26b45ac50..3aa91eb00ec 100644 --- a/sbin/camcontrol/camcontrol.c +++ b/sbin/camcontrol/camcontrol.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -5378,6 +5379,26 @@ cts_print(struct cam_device *device, struct ccb_trans_settings *cts) sata->caps); } } + if (cts->transport == XPORT_NVME) { + struct ccb_trans_settings_nvme *nvme = + &cts->xport_specific.nvme; + + if (nvme->valid & CTS_NVME_VALID_LINK) { + fprintf(stdout, "%sPCIe lanes: %d (%d max)\n", pathstr, + nvme->lanes, nvme->max_lanes); + fprintf(stdout, "%sPCIe Generation: %d (%d max)\n", pathstr, + nvme->speed, nvme->max_speed); + } + } + if (cts->transport == XPORT_NVMF) { + struct ccb_trans_settings_nvmf *nvmf = + &cts->xport_specific.nvmf; + + if (nvmf->valid & CTS_NVMF_VALID_TRTYPE) { + fprintf(stdout, "%sTransport: %s\n", pathstr, + nvmf_transport_type(nvmf->trtype)); + } + } if (cts->protocol == PROTO_ATA) { struct ccb_trans_settings_ata *ata= &cts->proto_specific.ata; @@ -5399,19 +5420,13 @@ cts_print(struct cam_device *device, struct ccb_trans_settings *cts) } } if (cts->protocol == PROTO_NVME) { - struct ccb_trans_settings_nvme *nvmex = - &cts->xport_specific.nvme; + struct ccb_trans_settings_nvme *nvme = + &cts->proto_specific.nvme; - if (nvmex->valid & CTS_NVME_VALID_SPEC) { + if (nvme->valid & CTS_NVME_VALID_SPEC) { fprintf(stdout, "%sNVMe Spec: %d.%d\n", pathstr, - NVME_MAJOR(nvmex->spec), - NVME_MINOR(nvmex->spec)); - } - if (nvmex->valid & CTS_NVME_VALID_LINK) { - fprintf(stdout, "%sPCIe lanes: %d (%d max)\n", pathstr, - nvmex->lanes, nvmex->max_lanes); - fprintf(stdout, "%sPCIe Generation: %d (%d max)\n", pathstr, - nvmex->speed, nvmex->max_speed); + NVME_MAJOR(nvme->spec), + NVME_MINOR(nvme->spec)); } } } diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h index 66b374008aa..15e136e8a07 100644 --- a/sys/cam/cam_ccb.h +++ b/sys/cam/cam_ccb.h @@ -297,9 +297,10 @@ typedef enum { XPORT_SRP, /* SCSI RDMA Protocol */ XPORT_NVME, /* NVMe over PCIe */ XPORT_MMCSD, /* MMC, SD, SDIO card */ + XPORT_NVMF, /* NVMe over Fabrics */ } cam_xport; -#define XPORT_IS_NVME(t) ((t) == XPORT_NVME) +#define XPORT_IS_NVME(t) ((t) == XPORT_NVME || (t) == XPORT_NVMF) #define XPORT_IS_ATA(t) ((t) == XPORT_ATA || (t) == XPORT_SATA) #define XPORT_IS_SCSI(t) ((t) != XPORT_UNKNOWN && \ (t) != XPORT_UNSPECIFIED && \ @@ -653,6 +654,12 @@ struct ccb_pathinq_settings_nvme { _Static_assert(sizeof(struct ccb_pathinq_settings_nvme) == 64, "ccb_pathinq_settings_nvme too big"); +struct ccb_pathinq_settings_nvmf { + uint32_t nsid; /* Namespace ID for this path */ + uint8_t trtype; + char dev_name[NVME_DEV_NAME_LEN]; /* nvme controller dev name for this device */ +}; + #define PATHINQ_SETTINGS_SIZE 128 struct ccb_pathinq { @@ -684,6 +691,7 @@ struct ccb_pathinq { struct ccb_pathinq_settings_fc fc; struct ccb_pathinq_settings_sas sas; struct ccb_pathinq_settings_nvme nvme; + struct ccb_pathinq_settings_nvmf nvmf; char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE]; } xport_specific; u_int maxio; /* Max supported I/O size, in bytes. */ @@ -1050,6 +1058,13 @@ struct ccb_trans_settings_nvme uint8_t max_speed; /* PCIe generation for each lane */ }; +struct ccb_trans_settings_nvmf +{ + u_int valid; /* Which fields to honor */ +#define CTS_NVMF_VALID_TRTYPE 0x01 + uint8_t trtype; +}; + #include struct ccb_trans_settings_mmc { struct mmc_ios ios; @@ -1122,6 +1137,7 @@ struct ccb_trans_settings { struct ccb_trans_settings_pata ata; struct ccb_trans_settings_sata sata; struct ccb_trans_settings_nvme nvme; + struct ccb_trans_settings_nvmf nvmf; } xport_specific; }; diff --git a/sys/cam/nvme/nvme_xpt.c b/sys/cam/nvme/nvme_xpt.c index 86127aca7b0..d2cb6ff11fd 100644 --- a/sys/cam/nvme/nvme_xpt.c +++ b/sys/cam/nvme/nvme_xpt.c @@ -175,6 +175,7 @@ static struct xpt_xport nvme_xport_ ## x = { \ CAM_XPT_XPORT(nvme_xport_ ## x); NVME_XPT_XPORT(nvme, NVME); +NVME_XPT_XPORT(nvmf, NVMF); #undef NVME_XPT_XPORT