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

Hannes Reinecke hare at kernel.org
Wed Mar 20 07:40:14 PDT 2024


Implement callback to display the peer transport address.

Signed-off-by: Hannes Reinecke <hare at kernel.org>
---
 drivers/nvme/target/rdma.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index f2bb9d95ecf4..16183c554a3d 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -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)
-- 
2.35.3




More information about the Linux-nvme mailing list