From: Nilay Shroff <nilay@linux.ibm.com>
To: kbusch@kernel.org, dwagner@suse.de, hch@lst.de, hare@suse.de,
sagi@grimberg.me, chaitanyak@nvidia.com, gjoyce@linux.ibm.com
Cc: linux-nvme@lists.infradead.org
Subject: [PATCH v5 1/1] nvme-tcp: expose per-queue socket addresses via sysfs
Date: Tue, 1 Dec 2026 15:21:44 +0530 [thread overview]
Message-ID: <20261201095146.510810-4-nilay@linux.ibm.com> (raw)
In-Reply-To: <20261201095146.510810-3-nilay@linux.ibm.com>
Add a read-only per-queue sysfs attribute named "address" to expose
the socket addresses associated with each NVMe/TCP I/O queue.
The attribute reports the socket's peer and local endpoint information
using the following fields:
- sip: Local transport address (IPv4/IPv6). For IPv6, appends
%<scope-id> if used for connection.
- sport: Local transport service identifier.
- dip: Peer transport address (IPV4/IPv6). For IPv6, appends
%<scope-id> if used for connection.
- dport: Peer transport service identifier
The attribute is available at:
/sys/class/nvme/nvmeX/queues/<qid>/address
Together with the existing per-queue "io_cpu" attribute, this
information helps correlate NVMe/TCP I/O queues with network stack
components and tune their interaction, including IRQ affinity,
RPS/RFS, XPS and NIC flow steering (ntuple).
Also, document the per-IO-queue "address" sysfs attribute in
Documentation/ABI/stable/sysfs-nvme.
No changes to I/O behavior are expected.
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
Documentation/ABI/stable/sysfs-nvme | 25 ++++++++++++
drivers/nvme/host/tcp.c | 59 +++++++++++++++++++++++++++++
2 files changed, 84 insertions(+)
diff --git a/Documentation/ABI/stable/sysfs-nvme b/Documentation/ABI/stable/sysfs-nvme
index fcfd0426866c..7dec65e306e7 100644
--- a/Documentation/ABI/stable/sysfs-nvme
+++ b/Documentation/ABI/stable/sysfs-nvme
@@ -534,3 +534,28 @@ Description:
managed: (RO) Shows who owns the CPU placement. 1 while
io_cpu is driver managed, 0 once the user assigned it,
for the life of the controller.
+
+What: /sys/class/nvme/nvmeX/queues/<qid>/address
+Date: December 2026
+KernelVersion: 7.5
+Contact: Nilay Shroff <nilay@linux.ibm.com>
+Description:
+ (RO) Shows the socket endpoint addresses associated with
+ an NVMe/TCP I/O queue. The output contains the following
+ comma-separated fields:
+
+ sip: Local transport address (IPv4/IPv6). For IPv6,
+ appends %<scope-id> if scope-id is used for
+ connection.
+
+ sport: Local transport service identifier (TCP port).
+
+ dip: Peer transport address (IPv4/IPv6). For Ipv6,
+ appends %<scope-id> if scope-id is used for
+ connection.
+
+ dport: Peer transport service identifier (TCP port).
+
+ Returns an empty result if the I/O queue is not live.
+ Returns error if host or peer transport address can't be
+ determined or transport address family is unsupported.
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index cf3c98b188bd..05cf7000ef67 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2127,14 +2127,73 @@ static ssize_t managed_show(struct kobject *kobj, struct kobj_attribute *attr,
!test_bit(NVME_TCP_Q_IO_CPU_USER, &queue->flags));
}
+static ssize_t address_show(struct kobject *kobj, struct kobj_attribute *attr,
+ char *buf)
+{
+ struct nvme_tcp_queue *queue = nvme_queue_info_data(kobj);
+ struct sockaddr_storage src, dst;
+ int ret = 0;
+
+ mutex_lock(&queue->queue_lock);
+
+ if (!test_bit(NVME_TCP_Q_LIVE, &queue->flags))
+ goto out;
+
+ ret = kernel_getsockname(queue->sock, (struct sockaddr *)&src);
+ if (ret <= 0)
+ goto out;
+
+ ret = kernel_getpeername(queue->sock, (struct sockaddr *)&dst);
+ if (ret <= 0)
+ goto out;
+
+ if (src.ss_family != dst.ss_family) {
+ ret = -EAFNOSUPPORT;
+ goto out;
+ }
+
+ if (src.ss_family == AF_INET) {
+ struct sockaddr_in *sip = (struct sockaddr_in *)&src;
+ struct sockaddr_in *dip = (struct sockaddr_in *)&dst;
+
+ ret = sysfs_emit(buf, "sip=%pI4,sport=%hu,dip=%pI4,dport=%hu\n",
+ &sip->sin_addr.s_addr, ntohs(sip->sin_port),
+ &dip->sin_addr.s_addr, ntohs(dip->sin_port));
+ } else if (src.ss_family == AF_INET6) {
+ struct sockaddr_in6 *sip6 = (struct sockaddr_in6 *)&src;
+ struct sockaddr_in6 *dip6 = (struct sockaddr_in6 *)&dst;
+
+ if (sip6->sin6_scope_id || dip6->sin6_scope_id)
+ ret = sysfs_emit(buf, "sip=%pI6c%%%u,sport=%hu,dip=%pI6c%%%u,dport=%hu\n",
+ &sip6->sin6_addr, sip6->sin6_scope_id,
+ ntohs(sip6->sin6_port),
+ &dip6->sin6_addr, dip6->sin6_scope_id,
+ ntohs(dip6->sin6_port));
+ else
+ ret = sysfs_emit(buf, "sip=%pI6c,sport=%hu,dip=%pI6c,dport=%hu\n",
+ &sip6->sin6_addr,
+ ntohs(sip6->sin6_port),
+ &dip6->sin6_addr,
+ ntohs(dip6->sin6_port));
+ } else {
+ ret = -EAFNOSUPPORT;
+ }
+out:
+ mutex_unlock(&queue->queue_lock);
+ return ret;
+}
+
static struct kobj_attribute nvme_tcp_io_cpu_attr =
__ATTR(io_cpu, 0644, io_cpu_show, io_cpu_store);
static struct kobj_attribute nvme_tcp_managed_attr =
__ATTR_RO(managed);
+static struct kobj_attribute nvme_tcp_address_attr =
+ __ATTR_RO(address);
static struct attribute *nvme_tcp_queue_attrs[] = {
&nvme_tcp_io_cpu_attr.attr,
&nvme_tcp_managed_attr.attr,
+ &nvme_tcp_address_attr.attr,
NULL,
};
ATTRIBUTE_GROUPS(nvme_tcp_queue);
--
2.53.0
next prev parent reply other threads:[~2026-12-01 9:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 9:51 [PATCH v5 0/1] nvme-tcp: NIC topology aware I/O queue scaling and queue info export Nilay Shroff
2026-12-01 9:51 ` Nilay Shroff [this message]
2026-12-01 10:04 ` [PATCH v5 1/1] nvme-tcp: expose per-queue socket addresses via sysfs sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201095146.510810-4-nilay@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=chaitanyak@nvidia.com \
--cc=dwagner@suse.de \
--cc=gjoyce@linux.ibm.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox