cam: Add a XPORT_NVMF for NVMe over Fabrics sims

Reviewed by:	ken, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44713
This commit is contained in:
John Baldwin 2024-05-02 16:29:26 -07:00
parent 59144db3fc
commit 07c6a62bab
5 changed files with 47 additions and 13 deletions

View File

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

View File

@ -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 <bsd.prog.mk>

View File

@ -44,6 +44,7 @@
#include <fcntl.h>
#include <ctype.h>
#include <err.h>
#include <libnvmf.h>
#include <libutil.h>
#include <limits.h>
#include <inttypes.h>
@ -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));
}
}
}

View File

@ -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 <cam/mmc/mmc_bus.h>
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;
};

View File

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