Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Jan 2025 20:49:39 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: 4298ce72f650 - main - nvme/nvmf: Add NVME_GET_CONTROLLER_DATA ioctl to fetch cached cdata
Message-ID:  <202501312049.50VKndqK063323@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=4298ce72f650f1e93b4f43681446df2c1f8cab57

commit 4298ce72f650f1e93b4f43681446df2c1f8cab57
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-01-31 20:46:49 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-01-31 20:46:49 +0000

    nvme/nvmf: Add NVME_GET_CONTROLLER_DATA ioctl to fetch cached cdata
    
    Both nvme and nvmf cache a copy of the controller's identify data in
    the softc.  Add an ioctl to fetch this copy of the cdata.  This is
    primarily useful for allowing commands like 'nvmecontrol devlist' to
    work against a disconnected Fabrics host.
    
    Reviewed by:    dab, imp
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D48218
---
 sys/dev/nvme/nvme.h       | 1 +
 sys/dev/nvme/nvme_ctrlr.c | 3 +++
 sys/dev/nvmf/host/nvmf.c  | 3 +++
 3 files changed, 7 insertions(+)

diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 5a18d69c96f4..a08abcb4aec6 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -40,6 +40,7 @@
 #define	NVME_RESET_CONTROLLER		_IO('n', 1)
 #define	NVME_GET_NSID			_IOR('n', 2, struct nvme_get_nsid)
 #define	NVME_GET_MAX_XFER_SIZE		_IOR('n', 3, uint64_t)
+#define	NVME_GET_CONTROLLER_DATA	_IOR('n', 4, struct nvme_controller_data)
 
 #define	NVME_IO_TEST			_IOWR('n', 100, struct nvme_io_test)
 #define	NVME_BIO_TEST			_IOWR('n', 101, struct nvme_io_test)
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 29c165899f7f..98a9e62f851b 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1443,6 +1443,9 @@ nvme_ctrlr_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag,
 	case NVME_GET_MAX_XFER_SIZE:
 		*(uint64_t *)arg = ctrlr->max_xfer_size;
 		break;
+	case NVME_GET_CONTROLLER_DATA:
+		memcpy(arg, &ctrlr->cdata, sizeof(ctrlr->cdata));
+		break;
 	/* Linux Compatible (see nvme_linux.h) */
 	case NVME_IOCTL_ID:
 		td->td_retval[0] = 0xfffffffful;
diff --git a/sys/dev/nvmf/host/nvmf.c b/sys/dev/nvmf/host/nvmf.c
index 94205666accf..befe93dbbbc0 100644
--- a/sys/dev/nvmf/host/nvmf.c
+++ b/sys/dev/nvmf/host/nvmf.c
@@ -1107,6 +1107,9 @@ nvmf_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag,
 	case NVME_GET_MAX_XFER_SIZE:
 		*(uint64_t *)arg = sc->max_xfer_size;
 		return (0);
+	case NVME_GET_CONTROLLER_DATA:
+		memcpy(arg, sc->cdata, sizeof(*sc->cdata));
+		return (0);
 	case NVMF_RECONNECT_PARAMS:
 		nv = (struct nvmf_ioc_nv *)arg;
 		return (nvmf_reconnect_params(sc, nv));



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