Skip to contentSkip to conversation

nvmet: debugfs support

PATCH Superseded Hannes Reinecke 3 participants 13 messages Mar 20, 2024 – Mar 21, 2024

Subsystems (5)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover nvmet: debugfs support

Hi all,

taking up the original patchset for nvmet debugfs I've improved upon that submission by modifying the layout:

/dev/kernel/debug/nvmet
<subsysnqn>
ctrl<cntlid>
port
state
hostnqn
kato
queue<qnum>
host_traddr
sqsize
sqhead

The 'state' attribute is the value of the CSTS register; one can trigger a controller reset by writing 'fatal' into it (to set CSTS.CFS).

As usual, comments and reviews are welcome.

Hannes Reinecke (7):
nvmet: add debugfs support
nvmet: add debugfs support for queues
nvmet-tcp: implement queue_peer_traddr()
nvmet-rdma: implement queue_peer_traddr()
nvmet-fc: implement queue_peer_traddr()
nvme-fcloop: implement 'host_traddr'
lpfc_nvmet: implement 'host_traddr'

 drivers/nvme/target/Kconfig    |   9 ++
 drivers/nvme/target/Makefile   |   1 +
 drivers/nvme/target/core.c     |  32 ++++-
 drivers/nvme/target/debugfs.c  | 250 +++++++++++++++++++++++++++++++++
 drivers/nvme/target/debugfs.h  |  50 +++++++
 drivers/nvme/target/fc.c       |  25 ++++
 drivers/nvme/target/fcloop.c   |  12 ++
 drivers/nvme/target/nvmet.h    |  15 +-
 drivers/nvme/target/rdma.c     |  11 ++
 drivers/nvme/target/tcp.c      |  13 ++
 drivers/scsi/lpfc/lpfc_nvmet.c |  12 ++
 include/linux/nvme-fc-driver.h |   1 +
 12 files changed, 428 insertions(+), 3 deletions(-)
 create mode 100644 drivers/nvme/target/debugfs.c
 create mode 100644 drivers/nvme/target/debugfs.h
Signature · 1 line
2.35.3
#1 lore raw

PATCH v2 1/7 nvmet: add debugfs support

Add a debugfs hierarchy to display the configured subsystems and the controllers attached to the subsystems.

---
 drivers/nvme/target/Kconfig   |   9 ++
 drivers/nvme/target/Makefile  |   1 +
 drivers/nvme/target/core.c    |  22 +++-
 drivers/nvme/target/debugfs.c | 182 ++++++++++++++++++++++++++++++++++
 drivers/nvme/target/debugfs.h |  48 +++++++++
 drivers/nvme/target/nvmet.h   |   8 +-
 6 files changed, 267 insertions(+), 3 deletions(-)
 create mode 100644 drivers/nvme/target/debugfs.c
 create mode 100644 drivers/nvme/target/debugfs.h
drivers/nvme/target/Kconfig +9 -0
index 872dd1a0acd8..5740893ace6d 100644
@@ -18,6 +18,15 @@ config NVME_TARGET
 	  To configure the NVMe target you probably want to use the nvmetcli
 	  tool from http://git.infradead.org/users/hch/nvmetcli.git.
 
+config NVME_TARGET_DEBUGFS
+        bool "NVMe Target debugfs support"
+	depends on NVME_TARGET
+	help
+	  This enables debugfs support to display the connected controllers
+	  to each subsystem
+
+	  If unsure, say N.
+
 config NVME_TARGET_PASSTHRU
 	bool "NVMe Target Passthrough support"
 	depends on NVME_TARGET
drivers/nvme/target/Makefile +1 -0
index c66820102493..c402c44350b2 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_NVME_TARGET_TCP)		+= nvmet-tcp.o
 
 nvmet-y		+= core.o configfs.o admin-cmd.o fabrics-cmd.o \
 			discovery.o io-cmd-file.o io-cmd-bdev.o
+nvmet-$(CONFIG_NVME_TARGET_DEBUGFS)	+= debugfs.o
 nvmet-$(CONFIG_NVME_TARGET_PASSTHRU)	+= passthru.o
 nvmet-$(CONFIG_BLK_DEV_ZONED)		+= zns.o
 nvmet-$(CONFIG_NVME_TARGET_AUTH)	+= fabrics-cmd-auth.o auth.o
drivers/nvme/target/core.c +21 -1
index 1d1a7026e817..6cd1b92fc500 100644
@@ -16,6 +16,7 @@
 #include "trace.h"
 
 #include "nvmet.h"
+#include "debugfs.h"
 
 struct kmem_cache *nvmet_bvec_cache;
 struct workqueue_struct *buffered_io_wq;
@@ -1463,6 +1464,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
 	mutex_lock(&subsys->lock);
 	list_add_tail(&ctrl->subsys_entry, &subsys->ctrls);
 	nvmet_setup_p2p_ns_map(ctrl, req);
+	nvmet_debugfs_ctrl_setup(ctrl);
 	mutex_unlock(&subsys->lock);
 
 	*ctrlp = ctrl;
@@ -1497,6 +1499,8 @@ static void nvmet_ctrl_free(struct kref *ref)
 
 	nvmet_destroy_auth(ctrl);
 
+	nvmet_debugfs_ctrl_free(ctrl);
+
 	ida_free(&cntlid_ida, ctrl->cntlid);
 
 	nvmet_async_events_free(ctrl);
@@ -1610,8 +1614,14 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
 	INIT_LIST_HEAD(&subsys->ctrls);
 	INIT_LIST_HEAD(&subsys->hosts);
 
+	ret = nvmet_debugfs_subsys_setup(subsys);
+	if (ret)
+		goto free_subsysnqn;
+
 	return subsys;
 
+free_subsysnqn:
+	kfree(subsys->subsysnqn);
 free_fr:
 	kfree(subsys->firmware_rev);
 free_mn:
@@ -1628,6 +1638,8 @@ static void nvmet_subsys_free(struct kref *ref)
 
 	WARN_ON_ONCE(!xa_empty(&subsys->namespaces));
 
+	nvmet_debugfs_subsys_free(subsys);
+
 	xa_destroy(&subsys->namespaces);
 	nvmet_passthru_subsys_free(subsys);
 
@@ -1681,11 +1693,18 @@ static int __init nvmet_init(void)
 	if (error)
 		goto out_free_nvmet_work_queue;
 
-	error = nvmet_init_configfs();
+	error = nvmet_init_debugfs();
 	if (error)
 		goto out_exit_discovery;
+
+	error = nvmet_init_configfs();
+	if (error)
+		goto out_exit_debugfs;
+
 	return 0;
 
+out_exit_debugfs:
+	nvmet_exit_debugfs();
 out_exit_discovery:
 	nvmet_exit_discovery();
 out_free_nvmet_work_queue:
@@ -1702,6 +1721,7 @@ static int __init nvmet_init(void)
 static void __exit nvmet_exit(void)
 {
 	nvmet_exit_configfs();
+	nvmet_exit_debugfs();
 	nvmet_exit_discovery();
 	ida_destroy(&cntlid_ida);
 	destroy_workqueue(nvmet_wq);
drivers/nvme/target/debugfs.c new file +182 -0

182 lines not on this page · raw message

drivers/nvme/target/debugfs.h new file +48 -0

48 lines not on this page · raw message

drivers/nvme/target/nvmet.h +6 -2
index 765da2b932c5..f0371163cb26 100644
@@ -233,7 +233,9 @@ struct nvmet_ctrl {
 
 	struct device		*p2p_client;
 	struct radix_tree_root	p2p_ns_map;
-
+#ifdef CONFIG_NVME_TARGET_DEBUGFS
+	struct dentry		*debugfs_dir;
+#endif
 	spinlock_t		error_lock;
 	u64			err_counter;
 	struct nvme_error_slot	slots[NVMET_ERROR_LOG_SLOTS];
@@ -269,7 +271,9 @@ struct nvmet_subsys {
 
 	struct list_head	hosts;
 	bool			allow_any_host;
-
+#ifdef CONFIG_NVME_TARGET_DEBUGFS
+	struct dentry		*debugfs_dir;
+#endif
 	u16			max_qid;
 
 	u64			ver;
Signature · 1 line
2.35.3
#2 lore raw

PATCH v2 2/7 nvmet: add debugfs support for queues

In reply to Hannes Reinecke

Add debugfs entries to display the status of the controller queues.

---
 drivers/nvme/target/core.c    | 10 ++++++
 drivers/nvme/target/debugfs.c | 68 +++++++++++++++++++++++++++++++++++
 drivers/nvme/target/debugfs.h |  2 ++
 drivers/nvme/target/nvmet.h   |  7 ++++
 4 files changed, 87 insertions(+)
drivers/nvme/target/core.c +10 -0
index 6cd1b92fc500..66c31ff04ce5 100644
@@ -791,6 +791,7 @@ void nvmet_sq_setup(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq,
 	sq->size = size;
 
 	ctrl->sqs[qid] = sq;
+	nvmet_debugfs_queue_setup(ctrl, sq);
 }
 
 static void nvmet_confirm_sq(struct percpu_ref *ref)
@@ -815,6 +816,7 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)
 	wait_for_completion(&sq->free_done);
 	percpu_ref_exit(&sq->ref);
 	nvmet_auth_sq_free(sq);
+	nvmet_debugfs_queue_free(sq);
 
 	if (ctrl) {
 		/*
@@ -855,6 +857,14 @@ int nvmet_sq_init(struct nvmet_sq *sq)
 }
 EXPORT_SYMBOL_GPL(nvmet_sq_init);
 
+ssize_t nvmet_sq_peeraddr(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq,
+		char *traddr, size_t traddr_len)
+{
+	if (!ctrl->ops->queue_peertraddr)
+		return -EOPNOTSUPP;
+	return ctrl->ops->queue_peertraddr(ctrl, sq, traddr, traddr_len);
+}
+
 static inline u16 nvmet_check_ana_state(struct nvmet_port *port,
 		struct nvmet_ns *ns)
 {
drivers/nvme/target/debugfs.c +68 -0

74 lines not on this page · raw message

drivers/nvme/target/debugfs.h +2 -0
index a2c6a949ff0f..5192f8012b79 100644
@@ -14,6 +14,8 @@ int nvmet_debugfs_subsys_setup(struct nvmet_subsys *subsys);
 void nvmet_debugfs_subsys_free(struct nvmet_subsys *subsys);
 int nvmet_debugfs_ctrl_setup(struct nvmet_ctrl *ctrl);
 void nvmet_debugfs_ctrl_free(struct nvmet_ctrl *ctrl);
+int nvmet_debugfs_queue_setup(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq);
+void nvmet_debugfs_queue_free(struct nvmet_sq *sq);
 
 int __init nvmet_init_debugfs(void);
 void nvmet_exit_debugfs(void);
drivers/nvme/target/nvmet.h +7 -0
index f0371163cb26..fae6493fd87a 100644
@@ -109,6 +109,9 @@ struct nvmet_sq {
 	u16			size;
 	u32			sqhd;
 	bool			sqhd_disabled;
+#ifdef CONFIG_NVME_TARGET_DEBUGFS
+	struct dentry		*debugfs_dir;
+#endif
 #ifdef CONFIG_NVME_TARGET_AUTH
 	bool			authenticated;
 	struct delayed_work	auth_expired_work;
@@ -365,6 +368,8 @@ struct nvmet_fabrics_ops {
 	void (*discovery_chg)(struct nvmet_port *port);
 	u8 (*get_mdts)(const struct nvmet_ctrl *ctrl);
 	u16 (*get_max_queue_size)(const struct nvmet_ctrl *ctrl);
+	ssize_t (*queue_peertraddr)(struct nvmet_ctrl *ctrl,
+			struct nvmet_sq *sq, char *traddr, size_t traddr_len);
 };
 
 #define NVMET_MAX_INLINE_BIOVEC	8
@@ -498,6 +503,8 @@ void nvmet_sq_setup(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq, u16 qid,
 		u16 size);
 void nvmet_sq_destroy(struct nvmet_sq *sq);
 int nvmet_sq_init(struct nvmet_sq *sq);
+ssize_t nvmet_sq_peeraddr(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq,
+		char *traddr, size_t traddr_len);
 
 void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl);
 
Signature · 1 line
2.35.3
#3 lore raw

PATCH v2 3/7 nvmet-tcp: implement queue_peer_traddr()

In reply to Hannes Reinecke

Implement callback to display the peer transport address.

---
 drivers/nvme/target/tcp.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/nvme/target/tcp.c +13 -0
index 4718d4d87a85..4b2cef897a66 100644
@@ -2201,6 +2201,18 @@ static void nvmet_tcp_disc_port_addr(struct nvmet_req *req,
 	}
 }
 
+static ssize_t nvmet_tcp_disc_peer_addr(struct nvmet_ctrl *ctrl,
+			struct nvmet_sq *sq, char *traddr, size_t traddr_len)
+{
+	struct nvmet_tcp_queue *queue =
+		container_of(sq, struct nvmet_tcp_queue, nvme_sq);
+
+	if (queue->sockaddr_peer.ss_family == AF_UNSPEC)
+		return -EINVAL;
+	return snprintf(traddr, traddr_len, "%pISc",
+			(struct sockaddr *)&queue->sockaddr_peer);
+}
+
 static const struct nvmet_fabrics_ops nvmet_tcp_ops = {
 	.owner			= THIS_MODULE,
 	.type			= NVMF_TRTYPE_TCP,
@@ -2211,6 +2223,7 @@ static const struct nvmet_fabrics_ops nvmet_tcp_ops = {
 	.delete_ctrl		= nvmet_tcp_delete_ctrl,
 	.install_queue		= nvmet_tcp_install_queue,
 	.disc_traddr		= nvmet_tcp_disc_port_addr,
+	.queue_peertraddr	= nvmet_tcp_disc_peer_addr,
 };
 
 static int __init nvmet_tcp_init(void)
Signature · 1 line
2.35.3
maintainer
#4 lore raw

Re: [PATCH 3/7] nvmet-tcp: implement queue_peer_traddr()

Quoted 1 line · Hannes Reinecke

Implement callback to display the peer transport address.

s/peer/host

Quoted 29 lines
---
  drivers/nvme/target/tcp.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/nvme/target/tcp.c +12 -0
index 4718d4d87a85..4b2cef897a66 100644
@@ -2201,6 +2201,18 @@ static void nvmet_tcp_disc_port_addr(struct nvmet_req *req,
  	}
  }
 
+static ssize_t nvmet_tcp_disc_peer_addr(struct nvmet_ctrl *ctrl,
+			struct nvmet_sq *sq, char *traddr, size_t traddr_len)
+{
+	struct nvmet_tcp_queue *queue =
+		container_of(sq, struct nvmet_tcp_queue, nvme_sq);
+
+	if (queue->sockaddr_peer.ss_family == AF_UNSPEC)
+		return -EINVAL;
+	return snprintf(traddr, traddr_len, "%pISc",
+			(struct sockaddr *)&queue->sockaddr_peer);
+}
+
  static const struct nvmet_fabrics_ops nvmet_tcp_ops = {
  	.owner			= THIS_MODULE,
  	.type			= NVMF_TRTYPE_TCP,

drivers/nvme/target/tcp.c static const struct nvmet_fabrics_ops nvmet_tcp_ops = { · line 2226

Quoted 4 lines
drivers/nvme/target/tcp.c +1 -0
@@ -2211,6 +2223,7 @@ static const struct nvmet_fabrics_ops nvmet_tcp_ops = {
  	.delete_ctrl		= nvmet_tcp_delete_ctrl,
  	.install_queue		= nvmet_tcp_install_queue,
  	.disc_traddr		= nvmet_tcp_disc_port_addr,
+	.queue_peertraddr	= nvmet_tcp_disc_peer_addr,

host_traddr, and it should really be per controller, and be taken from the admin queue. Not sure how this would ever be different across queues in the same ctrl

#5 lore raw

Re: [PATCH 3/7] nvmet-tcp: implement queue_peer_traddr()

Quoted 7 lines · Sagi Grimberg
Quoted 1 line · Hannes Reinecke

Implement callback to display the peer transport address.

s/peer/host

Ok.

Quoted 29 lines
Quoted 29 lines

---
  drivers/nvme/target/tcp.c | 13 +++++++++++++

  1 file changed, 13 insertions(+)
drivers/nvme/target/tcp.c +12 -0
index 4718d4d87a85..4b2cef897a66 100644
@@ -2201,6 +2201,18 @@ static void nvmet_tcp_disc_port_addr(struct 
 nvmet_req *req,
       }
   }
+static ssize_t nvmet_tcp_disc_peer_addr(struct nvmet_ctrl *ctrl,
+            struct nvmet_sq *sq, char *traddr, size_t traddr_len)
+{
+    struct nvmet_tcp_queue *queue =
+        container_of(sq, struct nvmet_tcp_queue, nvme_sq);
+
+    if (queue->sockaddr_peer.ss_family == AF_UNSPEC)
+        return -EINVAL;
+    return snprintf(traddr, traddr_len, "%pISc",
+            (struct sockaddr *)&queue->sockaddr_peer);
+}
+
   static const struct nvmet_fabrics_ops nvmet_tcp_ops = {
       .owner            = THIS_MODULE,
       .type            = NVMF_TRTYPE_TCP,
@@ -2211,6 +2223,7 @@ static const struct nvmet_fabrics_ops 
Quoted 8 lines

drivers/nvme/target/tcp.c static const struct nvmet_fabrics_ops nvmet_tcp_ops = { · line 2226

Quoted 5 lines
drivers/nvme/target/tcp.c +1 -0
 nvmet_tcp_ops = {
       .delete_ctrl        = nvmet_tcp_delete_ctrl,
       .install_queue        = nvmet_tcp_install_queue,
       .disc_traddr        = nvmet_tcp_disc_port_addr,
+    .queue_peertraddr    = nvmet_tcp_disc_peer_addr,

host_traddr, and it should really be per controller, and be taken from the admin queue. Not sure how this would ever be different across queues in the same ctrl

Okay, not a problem. Felt a bit odd in doing so, but okay.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#6 lore raw

PATCH v2 4/7 nvmet-rdma: implement queue_peer_traddr()

In reply to Hannes Reinecke

Implement callback to display the peer transport address.

---
 drivers/nvme/target/rdma.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/nvme/target/rdma.c +11 -0
index f2bb9d95ecf4..16183c554a3d 100644
@@ -2014,6 +2014,16 @@ static void nvmet_rdma_disc_port_addr(struct nvmet_req *req,
 	}
 }
 
+static ssize_t nvmet_rdma_disc_peer_addr(struct nvmet_ctrl *ctrl,
+		struct nvmet_sq *nvme_sq, char *traddr, size_t traddr_len)
+{
+	struct nvmet_rdma_queue *queue =
+		container_of(nvme_sq, struct nvmet_rdma_queue, nvme_sq);
+
+	return snprintf(traddr, traddr_len, "%pISc",
+			(struct sockaddr *)&queue->cm_id->route.addr.dst_addr);
+}
+
 static u8 nvmet_rdma_get_mdts(const struct nvmet_ctrl *ctrl)
 {
 	if (ctrl->pi_support)
@@ -2040,6 +2050,7 @@ static const struct nvmet_fabrics_ops nvmet_rdma_ops = {
 	.disc_traddr		= nvmet_rdma_disc_port_addr,
 	.get_mdts		= nvmet_rdma_get_mdts,
 	.get_max_queue_size	= nvmet_rdma_get_max_queue_size,
+	.queue_peertraddr	= nvmet_rdma_disc_peer_addr,
 };
 
 static void nvmet_rdma_remove_one(struct ib_device *ib_device, void *client_data)
Signature · 1 line
2.35.3
#7 lore raw

PATCH v2 5/7 nvmet-fc: implement queue_peer_traddr()

In reply to Hannes Reinecke

Implement callback to display the peer transport address by adding a callback 'host_traddr' for nvmet_fc_target_template.

---
 drivers/nvme/target/fc.c       | 25 +++++++++++++++++++++++++
 include/linux/nvme-fc-driver.h |  1 +
 2 files changed, 26 insertions(+)
drivers/nvme/target/fc.c +25 -0
index fd229f310c93..b0fedff44e51 100644
@@ -2931,6 +2931,30 @@ nvmet_fc_discovery_chg(struct nvmet_port *port)
 		tgtport->ops->discovery_event(&tgtport->fc_target_port);
 }
 
+static ssize_t
+nvmet_fc_peer_addr(struct nvmet_ctrl *ctrl,
+		   struct nvmet_sq *sq, char *traddr, size_t traddr_size)
+{
+	struct nvmet_fc_tgt_queue *queue =
+		container_of(sq, struct nvmet_fc_tgt_queue, nvme_sq);
+	struct nvmet_fc_tgtport *tgtport = queue->assoc ? queue->assoc->tgtport : NULL;
+	struct nvmet_fc_hostport *hostport = queue->assoc ? queue->assoc->hostport : NULL;
+	ssize_t ret = 0;
+
+	if (!tgtport || !nvmet_fc_tgtport_get(tgtport))
+		return -ENODEV;
+	if (!hostport) {
+		ret = -ENODEV;
+		goto out_put;
+	}
+
+	if (tgtport->ops->host_traddr)
+		ret = tgtport->ops->host_traddr(hostport->hosthandle, traddr, traddr_size);
+out_put:
+	nvmet_fc_tgtport_put(tgtport);
+	return ret;
+}
+
 static const struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = {
 	.owner			= THIS_MODULE,
 	.type			= NVMF_TRTYPE_FC,
@@ -2940,6 +2964,7 @@ static const struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = {
 	.queue_response		= nvmet_fc_fcp_nvme_cmd_done,
 	.delete_ctrl		= nvmet_fc_delete_ctrl,
 	.discovery_chg		= nvmet_fc_discovery_chg,
+	.queue_peertraddr	= nvmet_fc_peer_addr,
 };
 
 static int __init nvmet_fc_init_module(void)
include/linux/nvme-fc-driver.h +1 -0
index 4109f1bd6128..885f2951041b 100644
@@ -975,6 +975,7 @@ struct nvmet_fc_target_template {
 	void (*ls_abort)(struct nvmet_fc_target_port *targetport,
 				void *hosthandle, struct nvmefc_ls_req *lsreq);
 	void (*host_release)(void *hosthandle);
+	ssize_t (*host_traddr)(void *hosthandle, char *traddr, size_t traddr_size);
 
 	u32	max_hw_queues;
 	u16	max_sgl_segments;
Signature · 1 line
2.35.3
#8 lore raw

PATCH v2 6/7 nvme-fcloop: implement 'host_traddr'

In reply to Hannes Reinecke

Implement the 'host_traddr' callback to display the host transport address for nvmet debugfs.

---
 drivers/nvme/target/fcloop.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/nvme/target/fcloop.c +12 -0
index 913cd2ec7a6f..7a32fb54a7c8 100644
@@ -492,6 +492,17 @@ fcloop_t2h_host_release(void *hosthandle)
 	/* host handle ignored for now */
 }
 
+static ssize_t
+fcloop_t2h_host_traddr(void *hosthandle, char *traddr, size_t traddr_len)
+{
+	struct fcloop_rport *rport = hosthandle;
+
+	return snprintf(traddr, traddr_len,
+			"nn-0x%llx:pn-0x%llx",
+			rport->lport->localport->node_name,
+			rport->lport->localport->port_name);
+}
+
 /*
  * Simulate reception of RSCN and converting it to a initiator transport
  * call to rescan a remote port.
@@ -1074,6 +1085,7 @@ static struct nvmet_fc_target_template tgttemplate = {
 	.ls_req			= fcloop_t2h_ls_req,
 	.ls_abort		= fcloop_t2h_ls_abort,
 	.host_release		= fcloop_t2h_host_release,
+	.host_traddr		= fcloop_t2h_host_traddr,
 	.max_hw_queues		= FCLOOP_HW_QUEUES,
 	.max_sgl_segments	= FCLOOP_SGL_SEGS,
 	.max_dif_sgl_segments	= FCLOOP_SGL_SEGS,
Signature · 1 line
2.35.3
#9 lore raw

PATCH v2 7/7 lpfc_nvmet: implement 'host_traddr'

In reply to Hannes Reinecke

Implement the 'host_traddr' callback to display the host transport address for nvmet debugfs.

---
 drivers/scsi/lpfc/lpfc_nvmet.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/scsi/lpfc/lpfc_nvmet.c +12 -0
index 425328d9c2d8..f927be625966 100644
@@ -1363,6 +1363,17 @@ lpfc_nvmet_ls_abort(struct nvmet_fc_target_port *targetport,
 		atomic_inc(&lpfc_nvmet->xmt_ls_abort);
 }
 
+static ssize_t
+lpfc_nvmet_host_traddr(void *hosthandle, char *traddr, size_t traddr_size)
+{
+	struct lpfc_nodelist *ndlp = hosthandle;
+
+	return snprintf(traddr, traddr_size,
+			"nn-0x%08llx:pn-0x%08llx",
+			wwn_to_u64(ndlp->nlp_nodename.u.wwn),
+			wwn_to_u64(ndlp->nlp_portname.u.wwn));
+}
+
 static void
 lpfc_nvmet_host_release(void *hosthandle)
 {
@@ -1413,6 +1424,7 @@ static struct nvmet_fc_target_template lpfc_tgttemplate = {
 	.ls_req         = lpfc_nvmet_ls_req,
 	.ls_abort       = lpfc_nvmet_ls_abort,
 	.host_release   = lpfc_nvmet_host_release,
+	.host_traddr    = lpfc_nvmet_host_traddr,
 
 	.max_hw_queues  = 1,
 	.max_sgl_segments = LPFC_NVMET_DEFAULT_SEGS,
Signature · 1 line
2.35.3
maintainer
#10 lore raw
In reply to Hannes Reinecke
Quoted 6 lines · Hannes Reinecke

Hi all,

taking up the original patchset for nvmet debugfs
I've improved upon that submission by modifying
the layout:

Quoted 9 lines

/dev/kernel/debug/nvmet
<subsysnqn>
ctrl<cntlid>
port
state
hostnqn
kato
queue<qnum>
host_traddr

Why is host_traddr per queue?

#11 lore raw
Quoted 19 lines · Sagi Grimberg
Quoted 6 lines · Hannes Reinecke

Hi all,

taking up the original patchset for nvmet debugfs
I've improved upon that submission by modifying
the layout:

Quoted 9 lines

/dev/kernel/debug/nvmet
   <subsysnqn>
     ctrl<cntlid>
       port
       state
       hostnqn
       kato
       queue<qnum>
         host_traddr

Quoted 1 line

Why is host_traddr per queue?

Blame TCP. We're having one connection per queue, and as such the peer address is a per-queue thingie.
And it really felt daft to look for queue 0 to get the peer address of the controller.
Unless we declare TCP the odd man out, and store the peer address per controller. Certainly would make sense for FC and loop.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
maintainer
#12 lore raw
Quoted 20 lines · Hannes Reinecke
Quoted 19 lines · Sagi Grimberg
Quoted 15 lines · Hannes Reinecke

Hi all,

taking up the original patchset for nvmet debugfs
I've improved upon that submission by modifying
the layout:

/dev/kernel/debug/nvmet
   <subsysnqn>
     ctrl<cntlid>
       port
       state
       hostnqn
       kato
       queue<qnum>
         host_traddr

Quoted 8 lines
Quoted 1 line

Why is host_traddr per queue?

Blame TCP. We're having one connection per queue, and as such the peer address is a per-queue thingie.
And it really felt daft to look for queue 0 to get the peer address of the controller.
Unless we declare TCP the odd man out, and store the peer address per controller. Certainly would make sense for FC and loop.

It will never be different, I say just take it from queue 0...