Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Aug 2023 22:26:10 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7eb538974c49 - main - cam mmc_xpt/nvme_xpt: Add _sbuf variants of {an,de}nounce xport and proto ops
Message-ID:  <202308012226.371MQAKg045603@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=7eb538974c49857a590c79c91f1e4f1c107b5f7d

commit 7eb538974c49857a590c79c91f1e4f1c107b5f7d
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-08-01 22:23:25 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-08-01 22:23:25 +0000

    cam mmc_xpt/nvme_xpt: Add _sbuf variants of {an,de}nounce xport and proto ops
    
    Reviewed by:    imp
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D41261
---
 sys/cam/mmc/mmc_xpt.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
 sys/cam/nvme/nvme_xpt.c | 42 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/sys/cam/mmc/mmc_xpt.c b/sys/cam/mmc/mmc_xpt.c
index 8fee7b4cad58..0930717b0a2a 100644
--- a/sys/cam/mmc/mmc_xpt.c
+++ b/sys/cam/mmc/mmc_xpt.c
@@ -74,6 +74,8 @@ static void mmc_dev_async(uint32_t async_code, struct cam_eb *bus,
 static void	 mmc_action(union ccb *start_ccb);
 static void	 mmc_dev_advinfo(union ccb *start_ccb);
 static void	 mmc_announce_periph(struct cam_periph *periph);
+static void	 mmc_announce_periph_sbuf(struct cam_periph *periph,
+    struct sbuf *sb);
 static void	 mmc_scan_lun(struct cam_periph *periph,
     struct cam_path *path, cam_flags flags, union ccb *ccb);
 
@@ -84,7 +86,9 @@ static void	 mmcprobe_cleanup(struct cam_periph *periph);
 static void	 mmcprobe_done(struct cam_periph *periph, union ccb *done_ccb);
 
 static void mmc_proto_announce(struct cam_ed *device);
+static void mmc_proto_announce_sbuf(struct cam_ed *device, struct sbuf *sb);
 static void mmc_proto_denounce(struct cam_ed *device);
+static void mmc_proto_denounce_sbuf(struct cam_ed *device, struct sbuf *sb);
 static void mmc_proto_debug_out(union ccb *ccb);
 
 typedef enum {
@@ -148,6 +152,7 @@ static struct xpt_xport_ops mmc_xport_ops = {
 	.action = mmc_action,
 	.async = mmc_dev_async,
 	.announce = mmc_announce_periph,
+	.announce_sbuf = mmc_announce_periph_sbuf,
 };
 
 #define MMC_XPT_XPORT(x, X)				\
@@ -162,7 +167,9 @@ MMC_XPT_XPORT(mmc, MMCSD);
 
 static struct xpt_proto_ops mmc_proto_ops = {
 	.announce = mmc_proto_announce,
+	.announce_sbuf = mmc_proto_announce_sbuf,
 	.denounce = mmc_proto_denounce,
+	.denounce_sbuf = mmc_proto_denounce_sbuf,
 	.debug_out = mmc_proto_debug_out,
 };
 
@@ -399,6 +406,29 @@ mmc_announce_periph(struct cam_periph *periph)
 	    ("XPT info: CLK %04d, ...\n", cts.proto_specific.mmc.ios.clock));
 }
 
+static void
+mmc_announce_periph_sbuf(struct cam_periph *periph, struct sbuf *sb)
+{
+	struct	ccb_pathinq cpi;
+	struct	ccb_trans_settings cts;
+	struct	cam_path *path = periph->path;
+
+	cam_periph_assert(periph, MA_OWNED);
+
+	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("mmc_announce_periph"));
+
+	memset(&cts, 0, sizeof(cts));
+	xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
+	cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
+	cts.type = CTS_TYPE_CURRENT_SETTINGS;
+	xpt_action((union ccb*)&cts);
+	if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
+		return;
+	xpt_path_inq(&cpi, periph->path);
+	CAM_DEBUG(path, CAM_DEBUG_INFO,
+	    ("XPT info: CLK %04d, ...\n", cts.proto_specific.mmc.ios.clock));
+}
+
 void
 mmccam_start_discovery(struct cam_sim *sim)
 {
@@ -480,6 +510,12 @@ mmc_proto_announce(struct cam_ed *device)
 	sbuf_putbuf(&sb);
 }
 
+static void
+mmc_proto_announce_sbuf(struct cam_ed *device, struct sbuf *sb)
+{
+	mmc_print_ident(&device->mmc_ident_data, sb);
+}
+
 static void
 mmc_proto_denounce(struct cam_ed *device)
 {
@@ -487,6 +523,12 @@ mmc_proto_denounce(struct cam_ed *device)
 	mmc_proto_announce(device);
 }
 
+static void
+mmc_proto_denounce_sbuf(struct cam_ed *device, struct sbuf *sb)
+{
+	mmc_proto_announce_sbuf(device, sb);
+}
+
 static void
 mmc_proto_debug_out(union ccb *ccb)
 {
diff --git a/sys/cam/nvme/nvme_xpt.c b/sys/cam/nvme/nvme_xpt.c
index 0662f476536c..d2968d1019d1 100644
--- a/sys/cam/nvme/nvme_xpt.c
+++ b/sys/cam/nvme/nvme_xpt.c
@@ -157,8 +157,14 @@ static void	 nvme_dev_async(uint32_t async_code,
 				void *async_arg);
 static void	 nvme_action(union ccb *start_ccb);
 static void	 nvme_announce_periph(struct cam_periph *periph);
+static void	 nvme_announce_periph_sbuf(struct cam_periph *periph,
+    struct sbuf *sb);
 static void	 nvme_proto_announce(struct cam_ed *device);
+static void	 nvme_proto_announce_sbuf(struct cam_ed *device,
+    struct sbuf *sb);
 static void	 nvme_proto_denounce(struct cam_ed *device);
+static void	 nvme_proto_denounce_sbuf(struct cam_ed *device,
+    struct sbuf *sb);
 static void	 nvme_proto_debug_out(union ccb *ccb);
 
 static struct xpt_xport_ops nvme_xport_ops = {
@@ -166,6 +172,7 @@ static struct xpt_xport_ops nvme_xport_ops = {
 	.action = nvme_action,
 	.async = nvme_dev_async,
 	.announce = nvme_announce_periph,
+	.announce_sbuf = nvme_announce_periph_sbuf,
 };
 #define NVME_XPT_XPORT(x, X)			\
 static struct xpt_xport nvme_xport_ ## x = {	\
@@ -181,7 +188,9 @@ NVME_XPT_XPORT(nvme, NVME);
 
 static struct xpt_proto_ops nvme_proto_ops = {
 	.announce = nvme_proto_announce,
+	.announce_sbuf = nvme_proto_announce_sbuf,
 	.denounce = nvme_proto_denounce,
+	.denounce_sbuf = nvme_proto_denounce_sbuf,
 	.debug_out = nvme_proto_debug_out,
 };
 static struct xpt_proto nvme_proto = {
@@ -783,14 +792,12 @@ nvme_dev_async(uint32_t async_code, struct cam_eb *bus, struct cam_et *target,
 }
 
 static void
-nvme_announce_periph(struct cam_periph *periph)
+nvme_announce_periph_sbuf(struct cam_periph *periph, struct sbuf *sb)
 {
 	struct	ccb_pathinq cpi;
 	struct	ccb_trans_settings cts;
 	struct	cam_path *path = periph->path;
 	struct ccb_trans_settings_nvme	*nvmex;
-	struct sbuf	sb;
-	char		buffer[120];
 
 	cam_periph_assert(periph, MA_OWNED);
 
@@ -805,20 +812,29 @@ nvme_announce_periph(struct cam_periph *periph)
 
 	/* Ask the SIM for its base transfer speed */
 	xpt_path_inq(&cpi, periph->path);
-	sbuf_new(&sb, buffer, sizeof(buffer), SBUF_FIXEDLEN);
-	sbuf_printf(&sb, "%s%d: nvme version %d.%d",
+	sbuf_printf(sb, "%s%d: nvme version %d.%d",
 	    periph->periph_name, periph->unit_number,
 	    NVME_MAJOR(cts.protocol_version),
 	    NVME_MINOR(cts.protocol_version));
 	if (cts.transport == XPORT_NVME) {
 		nvmex = &cts.proto_specific.nvme;
 		if (nvmex->valid & CTS_NVME_VALID_LINK)
-			sbuf_printf(&sb,
+			sbuf_printf(sb,
 			    " x%d (max x%d) lanes PCIe Gen%d (max Gen%d) link",
 			    nvmex->lanes, nvmex->max_lanes,
 			    nvmex->speed, nvmex->max_speed);
 	}
-	sbuf_printf(&sb, "\n");
+	sbuf_printf(sb, "\n");
+}
+
+static void
+nvme_announce_periph(struct cam_periph *periph)
+{
+	struct sbuf	sb;
+	char		buffer[120];
+
+	sbuf_new(&sb, buffer, sizeof(buffer), SBUF_FIXEDLEN);
+	nvme_announce_periph_sbuf(periph, &sb);
 	sbuf_finish(&sb);
 	sbuf_putbuf(&sb);
 }
@@ -835,6 +851,12 @@ nvme_proto_announce(struct cam_ed *device)
 	sbuf_putbuf(&sb);
 }
 
+static void
+nvme_proto_announce_sbuf(struct cam_ed *device, struct sbuf *sb)
+{
+	nvme_print_ident(device->nvme_cdata, device->nvme_data, sb);
+}
+
 static void
 nvme_proto_denounce(struct cam_ed *device)
 {
@@ -847,6 +869,12 @@ nvme_proto_denounce(struct cam_ed *device)
 	sbuf_putbuf(&sb);
 }
 
+static void
+nvme_proto_denounce_sbuf(struct cam_ed *device, struct sbuf *sb)
+{
+	nvme_print_ident_short(device->nvme_cdata, device->nvme_data, sb);
+}
+
 static void
 nvme_proto_debug_out(union ccb *ccb)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308012226.371MQAKg045603>