* [PATCH v4 1/2] nvme-tcp: expose per-queue socket addresses via sysfs
2026-11-23 17:37 [PATCH v4 0/2] nvme-tcp: NIC topology aware I/O queue scaling and queue info export Nilay Shroff
@ 2026-11-23 17:37 ` Nilay Shroff
2026-11-23 17:37 ` [PATCH v4 2/2] nvme: document NVMe/TCP per-queue address sysfs attribute Nilay Shroff
1 sibling, 0 replies; 3+ messages in thread
From: Nilay Shroff @ 2026-11-23 17:37 UTC (permalink / raw)
To: kbusch, dwagner, hch, hare, sagi, chaitanyak, gjoyce
Cc: linux-nvme, Nilay Shroff
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:
- traddr: Peer transport address
- trsvcid: Peer transport service identifier
- host_traddr: Host transport address
- host_trsvcid: Host 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).
No changes to I/O behavior are expected.
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
drivers/nvme/host/tcp.c | 50 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index f1d29d9f75cc..c7e736df71d2 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2123,14 +2123,64 @@ 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, "traddr=%pI4,trsvcid=%hu,host_traddr=%pI4,host_trsvcid=%hu\n",
+ &dip->sin_addr.s_addr, ntohs(dip->sin_port),
+ &sip->sin_addr.s_addr, ntohs(sip->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;
+
+ ret = sysfs_emit(buf, "traddr=%pI6c,trsvcid=%hu,host_traddr=%pI6c,host_trsvcid=%hu\n",
+ &dip6->sin6_addr, ntohs(dip6->sin6_port),
+ &sip6->sin6_addr, ntohs(sip6->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
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v4 2/2] nvme: document NVMe/TCP per-queue address sysfs attribute
2026-11-23 17:37 [PATCH v4 0/2] nvme-tcp: NIC topology aware I/O queue scaling and queue info export Nilay Shroff
2026-11-23 17:37 ` [PATCH v4 1/2] nvme-tcp: expose per-queue socket addresses via sysfs Nilay Shroff
@ 2026-11-23 17:37 ` Nilay Shroff
1 sibling, 0 replies; 3+ messages in thread
From: Nilay Shroff @ 2026-11-23 17:37 UTC (permalink / raw)
To: kbusch, dwagner, hch, hare, sagi, chaitanyak, gjoyce
Cc: linux-nvme, Nilay Shroff
Document the per-I/O-queue "address" sysfs attribute introduced
for NVMe/TCP. The attribute is available at:
/sys/class/nvme/nvmeX/queues/<qid>/address
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
Documentation/ABI/stable/sysfs-nvme | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/Documentation/ABI/stable/sysfs-nvme b/Documentation/ABI/stable/sysfs-nvme
index fcfd0426866c..953ecee81c43 100644
--- a/Documentation/ABI/stable/sysfs-nvme
+++ b/Documentation/ABI/stable/sysfs-nvme
@@ -534,3 +534,21 @@ 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: November 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:
+
+ traddr: Peer transport address (IPv4/IPv6).
+ trsvcid: Peer transport service identifier (TCP port).
+ host_traddr: Local transport address (IPv4/IPv6).
+ host_trsvcid: Local 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.
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread