Skip to contentSkip to conversation

Add optional-counters binding support

PATCH Applied Patrisious Haddad 2 participants 4 messages Mar 19, 2025 – Mar 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Add optional-counters binding support

Add optional-counters binding support together with new packets/bytes counters. Previously optional-counters were on a per link basis, this series allows users to bind optional-counters to a specific counter, which allows tracking optional-counter over a specific QP group.

The support is added for both binding modes, automatic and manual, in both cases the bound optional counters are those that are currently configured over the link when trying to bind the QP.

In addition introduce four new optional-counters :
rdma_tx_bytes, rdma_tx_packets, rdma_rx_bytes, rdma_rx_packets That just as their name implies allow tracking RDMA egress and ingress traffic.

This is exposed to users through the iproute2 package which needs to be updated as well to provide the support for this feature.

Example commands:
- rdma stat set link rocep8s0f0/1 optional-counters rdma_tx_bytes,rdma_rx_packets
Enables rdma_tx_bytes and rdma_rx_packets optional-counters over the link.

- rdma stat qp set link rocep8s0f0/1 auto type on optional-counters on Enabled link automatic counter binding for QPs of same type, with optional-counter binding support.

- rdma stat qp bind link rocep8s0f0/1 lqpn 134 Manually bind QP number 134 to all available counters.

- rdma stat qp bind link rocep8s0f0/1 lqpn 134 cntn 4 Manually bind QP number 134 to counter number 4 depending on its configured counters.

Thanks

Patrisious Haddad (2):
rdma: update uapi headers
rdma: Add optional-counter option to rdma stat bind commands

 man/man8/rdma-statistic.8             |  6 ++++
 rdma/include/uapi/rdma/rdma_netlink.h |  2 ++
 rdma/stat.c                           | 50 +++++++++++++++++++++++++--
 rdma/utils.c                          |  1 +
 4 files changed, 57 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.0
#1 lore raw

PATCH 1/2 rdma: update uapi headers

Update rdma_netlink.h file upto kernel commit da3711074f52 ("RDMA/core: Add support to optional-counters binding configuration")

---
 rdma/include/uapi/rdma/rdma_netlink.h | 2 ++
 1 file changed, 2 insertions(+)
rdma/include/uapi/rdma/rdma_netlink.h +2 -0
index 28404085..ec8c19ca 100644
@@ -580,6 +580,8 @@ enum rdma_nldev_attr {
 	RDMA_NLDEV_ATTR_EVENT_TYPE,		/* u8 */
 
 	RDMA_NLDEV_SYS_ATTR_MONITOR_MODE,	/* u8 */
+
+	RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED,	/* u8 */
 	/*
 	 * Always the end
 	 */
Signature · 1 line
2.47.0
#2 lore raw

PATCH 2/2 rdma: Add optional-counter option to rdma stat bind commands

In reply to Patrisious Haddad

Add a new optional filter named optional-counter to commands:
rdma stat qp set link [link_name] auto

The new filter value can be either on or off and it must be the last provided filter in the command, not providing it would be the same as off.

It indicates that when binding counters to a QP we also want the currently enabled optional-counters on the link to be bound as well.

In addition Adjust rdma statistic man page to reflect the new optional-counter changes.

---
 man/man8/rdma-statistic.8 |  6 +++++
 rdma/stat.c               | 50 +++++++++++++++++++++++++++++++++++++--
 rdma/utils.c              |  1 +
 3 files changed, 55 insertions(+), 2 deletions(-)
man/man8/rdma-statistic.8 +6 -0
index 7dd2b02c..337e31ef 100644
@@ -39,6 +39,7 @@ rdma-statistic \- RDMA statistic counter configuration
 .B auto
 .RI "{ " CRITERIA " | "
 .BR off " }"
+.B [ optional-counters | on/off ]
 
 .ti -8
 .B rdma statistic
@@ -180,6 +181,11 @@ rdma statistic qp set link mlx5_2/1 auto type on
 On device mlx5_2 port 1, for each new user QP bind it with a counter automatically. Per counter for QPs with same qp type.
 .RE
 .PP
+rdma statistic qp set link mlx5_2/1 auto type on optional-counters on
+.RS 4
+On device mlx5_2 port 1, for each new user QP bind it with a counter automatically. Per counter for QPs with same qp type. Whilst also binding the currently enabled optional-counters.
+.RE
+.PP
 rdma statistic qp set link mlx5_2/1 auto pid on
 .RS 4
 On device mlx5_2 port 1, for each new user QP bind it with a counter automatically. Per counter for QPs with same pid.
rdma/stat.c +48 -2

101 lines not on this page · raw message

rdma/utils.c +1 -0
index 07cb0224..87003b2c 100644
@@ -479,6 +479,7 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
 	[RDMA_NLDEV_ATTR_PARENT_NAME] = MNL_TYPE_STRING,
 	[RDMA_NLDEV_ATTR_EVENT_TYPE] = MNL_TYPE_U8,
 	[RDMA_NLDEV_SYS_ATTR_MONITOR_MODE] = MNL_TYPE_U8,
+	[RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED] = MNL_TYPE_U8,
 };
 
 static int rd_attr_check(const struct nlattr *attr, int *typep)
Signature · 1 line
2.47.0
#3 lore raw
In reply to Patrisious Haddad
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Hello:

This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Quoted 10 lines · On Wed, 19 Mar 2025 10:25:24 +0200 you wrote:

Add optional-counters binding support together with new packets/bytes counters. Previously optional-counters were on a per link basis, this series allows users to bind optional-counters to a specific counter, which allows tracking optional-counter over a specific QP group.

The support is added for both binding modes, automatic and manual, in both cases the bound optional counters are those that are currently configured over the link when trying to bind the QP.

[...]

Here is the summary with links:
- [iproute2-next,1/2] rdma: update uapi headers

    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=85860c7dce2c
  - [iproute2-next,2/2] rdma: Add optional-counter option to rdma stat bind commands
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=a03f40534f6c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html