net/mlx5: Expose SW RoCE monitor matched packets counter
Subsystems (6)
Tariq Toukan
maintainerPATCH 1/1 net/mlx5: Expose SW RoCE monitor matched packets counter
From: Moshe Shemesh <[email protected]>
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
--- Documentation/networking/devlink/mlx5.rst | 6 +++ .../mellanox/mlx5/core/diag/reporter_vnic.c | 39 ++++++++++++------- 2 files changed, 31 insertions(+), 14 deletions(-)
Documentation/networking/devlink/mlx5.rst +6 -0
@@ -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:
drivers/net/ethernet/mellanox/mlx5/core/diag/reporter_vnic.c +25 -14
@@ -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
Signature · 1 line
2.44.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 18 lines
From: Moshe Shemesh <[email protected]>
Add the
sw_roce_monitor_matched_packetscounter 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_REGis now needed by more than one counter, move its read to
[ ... ]
sw_roce_monitor_matched_packets: 17
Quoted 3 lines
Signed-off-by Moshe Shemesh <[email protected]>Reviewed-by Shay Drori <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1