From nobody Fri May 03 00:15:48 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VVrtX61fFz5KJwH; Fri, 3 May 2024 00:15:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VVrtX46gqz4QRd; Fri, 3 May 2024 00:15:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714695348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cq4gSl8asu/tsqAcIFNNeE/aFR2KrYBMVHiOgFvdeRw=; b=PIWAsP875ofQ6G8QbDRSVxw7Y8F/R5DlFCH83a4jJZkZXxhRggj3yr6jT6uFOg7EMrifLI Vd9qab0+eEiDVLg9jk9jvDFtEDtilLSyKxs4fMJk4dbh+pQsMqsBx8qi9xEXoqbRU4JYMW xmQ0e5SBOP1xTiYbXb4DO2MVVDsvGXTFR6p3R6i+F7aUrW39b/Jw63z16xQcAe8GYt65QJ CWvkQwK8qi2GOU8At04EVygB6u4uUYvNWoqMhUahg7BbzlZWHBGZtoItMoZaSL1fkI9b5o ev3ZCHd5yC9Yln0loomq9cdP9ijHy1mxTWzy9agt1IvvvtIkiaHxoxw2UfiJMQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714695348; a=rsa-sha256; cv=none; b=Rkc9VUCkkuOsoxuLvR0EFDa90ytGlv2uEbXQth4LEnxOIymHcgDQVha9EjeTVawEk4sA9z c9x6L2itBFvapXp+bIDCjs0ZSnFw4t2V0h+HP9wdJy382MEV/K6FeAUhG0RntlcCHok01w J/0WOqVGDb1119VKXZpxJBMkHpC92YYo6eYkdf1WR9emKliKzxgcs/NiGGxW2lN1RiZVMJ Y4N8zuJFal7o5L9HQgrw+gL9TG7X0Ydp6r1ROTr+fwwmiz4wh6BL2EFfeY+OBtNd1aGA5V OxENy36iGRdOXGh/XB5STmCkGmBhBU6qCBa3tQXv9mTjaPM57K/9Q+6PaSOGmg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714695348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cq4gSl8asu/tsqAcIFNNeE/aFR2KrYBMVHiOgFvdeRw=; b=sKWszZOXdGUWZMcwmeQhKfmSdR8i9TcqG9Wd3LqJy4cwVEgnyDP/dnz8xBdMi64uYFr1Hg 1HKWkJQBOUtmtJaTVMVEsCoOgjQQZMRN89MRXN4QpBy8PlkwISmyT1tbGxgY5BA4bZetau b4HII17Aj4i+r45NC0G98Ee+JYNQPAQEFRYZ/hmWZ/oUaHrU41b45w2Omi9ubzRevaHf7p NnqFe3WPc4dq3blrR2QOyMHXJ4stE6EXcOdivoztyz3CGT/sipt9b52SnwYdoUw+tkyY3e wiMOPUcTO3xnId6XGPxIbLbY+v24x5Y6zmjB+BOCfZL54FN0Wpvti4bEd/EFvw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VVrtX3Ls7zNcs; Fri, 3 May 2024 00:15:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4430Fmp5079167; Fri, 3 May 2024 00:15:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4430Fm1m079164; Fri, 3 May 2024 00:15:48 GMT (envelope-from git) Date: Fri, 3 May 2024 00:15:48 GMT Message-Id: <202405030015.4430Fm1m079164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 07c6a62bab69 - main - cam: Add a XPORT_NVMF for NVMe over Fabrics sims List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 07c6a62bab69296f2514dc99046ac701c4392f78 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=07c6a62bab69296f2514dc99046ac701c4392f78 commit 07c6a62bab69296f2514dc99046ac701c4392f78 Author: John Baldwin AuthorDate: 2024-05-02 23:29:26 +0000 Commit: John Baldwin CommitDate: 2024-05-02 23:29:26 +0000 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 --- rescue/rescue/Makefile | 1 + sbin/camcontrol/Makefile | 3 ++- sbin/camcontrol/camcontrol.c | 37 ++++++++++++++++++++++++++----------- sys/cam/cam_ccb.h | 18 +++++++++++++++++- sys/cam/nvme/nvme_xpt.c | 1 + 5 files changed, 47 insertions(+), 13 deletions(-) diff --git a/rescue/rescue/Makefile b/rescue/rescue/Makefile index 6dceea6f5077..2c31323c2507 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 b04eb5614c62..64703f656a89 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 db26b45ac508..3aa91eb00ecf 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 66b374008aa5..15e136e8a072 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 86127aca7b0f..d2cb6ff11fd4 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