From: Tariq Toukan <tariqt@nvidia.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, <netdev@vger.kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Gal Pressman <gal@nvidia.com>, Jiri Pirko <jiri@resnulli.us>,
"Jonathan Corbet" <corbet@lwn.net>,
Leon Romanovsky <leon@kernel.org>, <linux-doc@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, Mark Bloch <mbloch@nvidia.com>,
Moshe Shemesh <moshe@nvidia.com>,
Randy Dunlap <rdunlap@infradead.org>,
Saeed Mahameed <saeedm@nvidia.com>, Shay Drori <shayd@nvidia.com>,
Shuah Khan <skhan@linuxfoundation.org>,
Simon Horman <horms@kernel.org>, Tariq Toukan <tariqt@nvidia.com>
Subject: [PATCH net-next] net/mlx5: Expose SW RoCE monitor matched packets counter
Date: Wed, 25 Nov 2026 23:23:43 +0200 [thread overview]
Message-ID: <20261125212344.243989-1-tariqt@nvidia.com> (raw)
From: Moshe Shemesh <moshe@nvidia.com>
Add the sw_roce_monitor_matched_packets counter to the vnic health
reporter diagnose.
- sw_roce_monitor_matched_packets
number of packets generated by the Ethernet SQs of the vNIC that
matched the configured SW RoCE monitor classifier. The classifier
is currently set to RoCEv2 only, so the counter collects statistics
of software-generated RoCEv2 packets transmitted from the Ethernet
SQs of the selected managed vHCA.
The counter is exposed only when the device reports support through
NIC_CAP_REG.sw_roce_monitor_classifier. As NIC_CAP_REG is now needed by
more than one counter, move its read to
mlx5_reporter_vnic_diagnose_counters() so that a single read serves all
of its users.
Example access:
$ devlink health diagnose pci/0000:08:00.0 reporter vnic
vNIC env counters:
total_error_queues: 0 send_queue_priority_update_flow: 0
comp_eq_overrun: 0 async_eq_overrun: 0 cq_overrun: 0
invalid_command: 0 quota_exceeded_command: 0
nic_receive_steering_discard: 0 icm_consumption: 1032
bar_uar_access: 1279 odp_local_triggered_page_fault: 20
odp_remote_triggered_page_fault: 34
sw_roce_monitor_matched_packets: 17
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Shay Drori <shayd@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
Documentation/networking/devlink/mlx5.rst | 6 +++
.../mellanox/mlx5/core/diag/reporter_vnic.c | 39 ++++++++++++-------
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/Documentation/networking/devlink/mlx5.rst b/Documentation/networking/devlink/mlx5.rst
index 9421c89951a0..eedb6d1379b2 100644
--- a/Documentation/networking/devlink/mlx5.rst
+++ b/Documentation/networking/devlink/mlx5.rst
@@ -410,6 +410,12 @@ Description of the vnic counters:
number of locally-triggered page-faults due to ODP.
- odp_remote_triggered_page_fault
number of remotly-triggered page-faults due to ODP.
+- sw_roce_monitor_matched_packets
+ number of packets generated by the Ethernet SQs of the vNIC that
+ matched the configured SW RoCE monitor classifier. When the
+ classifier is set to RoCEv2, the counter collects statistics of
+ software-generated RoCEv2 packets transmitted from the Ethernet SQs
+ of the selected managed vHCA.
User commands examples:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/diag/reporter_vnic.c b/drivers/net/ethernet/mellanox/mlx5/core/diag/reporter_vnic.c
index 7cae0c6e5e8a..b15ce5fdb576 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/diag/reporter_vnic.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/diag/reporter_vnic.c
@@ -15,29 +15,31 @@ struct mlx5_vnic_diag_stats {
__be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)];
};
+static int mlx5_reporter_vnic_query_nic_cap(struct mlx5_core_dev *dev, u32 *out)
+{
+ u32 in[MLX5_ST_SZ_DW(nic_cap_reg)] = {};
+ int err;
+
+ err = mlx5_core_access_reg(dev, in, sizeof(in), out,
+ MLX5_ST_SZ_BYTES(nic_cap_reg),
+ MLX5_REG_NIC_CAP, 0, 0);
+ if (err)
+ mlx5_core_warn(dev, "Reading nic_cap_reg failed. err = %d\n",
+ err);
+
+ return err;
+}
+
static void mlx5_reporter_vnic_diagnose_counter_icm(struct mlx5_core_dev *dev,
struct devlink_fmsg *fmsg,
u16 vport_num, bool other_vport)
{
u32 out_icm_reg[MLX5_ST_SZ_DW(vhca_icm_ctrl_reg)] = {};
u32 in_icm_reg[MLX5_ST_SZ_DW(vhca_icm_ctrl_reg)] = {};
- u32 out_reg[MLX5_ST_SZ_DW(nic_cap_reg)] = {};
- u32 in_reg[MLX5_ST_SZ_DW(nic_cap_reg)] = {};
u32 cur_alloc_icm;
- int vhca_icm_ctrl;
u16 vhca_id;
int err;
- err = mlx5_core_access_reg(dev, in_reg, sizeof(in_reg), out_reg,
- sizeof(out_reg), MLX5_REG_NIC_CAP, 0, 0);
- if (err) {
- mlx5_core_warn(dev, "Reading nic_cap_reg failed. err = %d\n", err);
- return;
- }
- vhca_icm_ctrl = MLX5_GET(nic_cap_reg, out_reg, vhca_icm_ctrl);
- if (!vhca_icm_ctrl)
- return;
-
MLX5_SET(vhca_icm_ctrl_reg, in_icm_reg, vhca_id_valid, other_vport);
if (other_vport) {
err = mlx5_vport_get_vhca_id(dev, vport_num, &vhca_id);
@@ -64,7 +66,9 @@ void mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev,
u16 vport_num, bool other_vport)
{
u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {};
+ u32 cap_reg[MLX5_ST_SZ_DW(nic_cap_reg)] = {};
struct mlx5_vnic_diag_stats vnic;
+ bool cap_reg_valid = false;
MLX5_SET(query_vnic_env_in, in, opcode, MLX5_CMD_OP_QUERY_VNIC_ENV);
MLX5_SET(query_vnic_env_in, in, vport_number, vport_num);
@@ -72,6 +76,9 @@ void mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev,
mlx5_cmd_exec_inout(dev, query_vnic_env, in, &vnic.query_vnic_env_out);
+ if (MLX5_CAP_GEN(dev, nic_cap_reg))
+ cap_reg_valid = !mlx5_reporter_vnic_query_nic_cap(dev, cap_reg);
+
devlink_fmsg_pair_nest_start(fmsg, "vNIC env counters");
devlink_fmsg_obj_nest_start(fmsg);
@@ -105,7 +112,7 @@ void mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev,
devlink_fmsg_u64_pair_put(fmsg, "handled_pkt_steering_fail",
VNIC_ENV_GET64(&vnic, handled_pkt_steering_fail));
}
- if (MLX5_CAP_GEN(dev, nic_cap_reg))
+ if (cap_reg_valid && MLX5_GET(nic_cap_reg, cap_reg, vhca_icm_ctrl))
mlx5_reporter_vnic_diagnose_counter_icm(dev, fmsg, vport_num, other_vport);
if (MLX5_CAP_GEN(dev, vnic_env_cnt_bar_uar_access))
devlink_fmsg_u32_pair_put(fmsg, "bar_uar_access",
@@ -116,6 +123,10 @@ void mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev,
devlink_fmsg_u32_pair_put(fmsg, "odp_remote_triggered_page_fault",
VNIC_ENV_GET(&vnic, odp_remote_triggered_page_fault));
}
+ if (cap_reg_valid &&
+ MLX5_GET(nic_cap_reg, cap_reg, sw_roce_monitor_classifier))
+ devlink_fmsg_u32_pair_put(fmsg, "sw_roce_monitor_matched_packets",
+ VNIC_ENV_GET(&vnic, sw_roce_monitor_matched_packets));
devlink_fmsg_obj_nest_end(fmsg);
devlink_fmsg_pair_nest_end(fmsg);
base-commit: 612848d37e68b858e15815175f1c5e609e09d719
--
2.44.0
next reply other threads:[~2026-11-25 21:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 21:23 Tariq Toukan [this message]
2026-11-25 21:31 ` [PATCH net-next] net/mlx5: Expose SW RoCE monitor matched packets counter sashiko-bot
2026-11-26 11:33 ` kernel test robot
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=20261125212344.243989-1-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=saeedm@nvidia.com \
--cc=shayd@nvidia.com \
--cc=skhan@linuxfoundation.org \
/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