Date: Thu, 20 Feb 2025 15:40:42 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: 11509c6ef2fb - main - nvmft: Export more info for a ctl port for use by ctladm Message-ID: <202502201540.51KFegPO016932@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=11509c6ef2fb3e6a83211109cba98da7560b5e12 commit 11509c6ef2fb3e6a83211109cba98da7560b5e12 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2025-02-20 15:14:42 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2025-02-20 15:31:20 +0000 nvmft: Export more info for a ctl port for use by ctladm In particular, export a "port" entry as well as an array of "host" entries for each active connection. Reviewed by: asomers Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48775 --- sys/dev/nvmf/controller/ctl_frontend_nvmf.c | 26 ++++++++++++++++++++++++++ sys/dev/nvmf/controller/nvmft_var.h | 1 + 2 files changed, 27 insertions(+) diff --git a/sys/dev/nvmf/controller/ctl_frontend_nvmf.c b/sys/dev/nvmf/controller/ctl_frontend_nvmf.c index a28a613e23aa..658b47699c1d 100644 --- a/sys/dev/nvmf/controller/ctl_frontend_nvmf.c +++ b/sys/dev/nvmf/controller/ctl_frontend_nvmf.c @@ -95,6 +95,30 @@ nvmft_offline(void *arg) mtx_unlock(&np->lock); } +static int +nvmft_info(void *arg, struct sbuf *sb) +{ + struct nvmft_port *np = arg; + struct nvmft_controller *ctrlr; + int retval; + + mtx_lock(&np->lock); + retval = sbuf_printf(sb, "\t<port>%s,p,%u</port>\n", np->cdata.subnqn, + np->portid); + if (retval != 0) + goto out; + + TAILQ_FOREACH(ctrlr, &np->controllers, link) { + retval = sbuf_printf(sb, "\t<host id=\"%u\">%s</host>\n", + ctrlr->cntlid, ctrlr->hostnqn); + if (retval != 0) + break; + } +out: + mtx_unlock(&np->lock); + return (retval); +} + static int nvmft_lun_enable(void *arg, int lun_id) { @@ -803,6 +827,7 @@ nvmft_port_create(struct ctl_req *req) np = malloc(sizeof(*np), M_NVMFT, M_WAITOK | M_ZERO); refcount_init(&np->refs, 1); + np->portid = portid; np->max_io_qsize = max_io_qsize; np->cap = _nvmf_controller_cap(max_io_qsize, enable_timeout / 500); mtx_init(&np->lock, "nvmft port", NULL, MTX_DEF); @@ -834,6 +859,7 @@ nvmft_port_create(struct ctl_req *req) port->virtual_port = 0; port->port_online = nvmft_online; port->port_offline = nvmft_offline; + port->port_info = nvmft_info; port->onoff_arg = np; port->lun_enable = nvmft_lun_enable; port->lun_disable = nvmft_lun_disable; diff --git a/sys/dev/nvmf/controller/nvmft_var.h b/sys/dev/nvmf/controller/nvmft_var.h index 6d20e2c8ac11..85032b2dc55f 100644 --- a/sys/dev/nvmf/controller/nvmft_var.h +++ b/sys/dev/nvmf/controller/nvmft_var.h @@ -33,6 +33,7 @@ struct nvmft_port { struct nvme_firmware_page fp; uint64_t cap; uint32_t max_io_qsize; + uint16_t portid; bool online; struct mtx lock;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502201540.51KFegPO016932>