-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net/mlx5: Add vnic devlink health reporter to PFs/VFs
Create a vnic devlink health reporter for PFs/VFs interfaces. The reporter's diagnose callback displays the values of vNIC/vport transport debug counters of PFs/VFs, as follows: $ 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 Moreover, add documentation on the reporter functionality and the counters description. While at it, expose the vNIC counters diagnose function to be used by the downstream patch, which will reveal the counters for representor interfaces. Signed-off-by: Maher Sanalla <msanalla@nvidia.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
- Loading branch information
Maher Sanalla
authored and
Saeed Mahameed
committed
Apr 21, 2023
1 parent
0a43141
commit b0bc615
Showing
6 changed files
with
177 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
drivers/net/ethernet/mellanox/mlx5/core/diag/reporter_vnic.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB | ||
/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. */ | ||
|
||
#include "reporter_vnic.h" | ||
#include "devlink.h" | ||
|
||
#define VNIC_ENV_GET64(vnic_env_stats, c) \ | ||
MLX5_GET64(query_vnic_env_out, (vnic_env_stats)->query_vnic_env_out, \ | ||
vport_env.c) | ||
|
||
struct mlx5_vnic_diag_stats { | ||
__be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)]; | ||
}; | ||
|
||
int mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev, | ||
struct devlink_fmsg *fmsg, | ||
u16 vport_num, bool other_vport) | ||
{ | ||
u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {}; | ||
struct mlx5_vnic_diag_stats vnic; | ||
int err; | ||
|
||
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); | ||
MLX5_SET(query_vnic_env_in, in, other_vport, !!other_vport); | ||
|
||
err = mlx5_cmd_exec_inout(dev, query_vnic_env, in, &vnic.query_vnic_env_out); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_pair_nest_start(fmsg, "vNIC env counters"); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_obj_nest_start(fmsg); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_u64_pair_put(fmsg, "total_error_queues", | ||
VNIC_ENV_GET64(&vnic, total_error_queues)); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_u64_pair_put(fmsg, "send_queue_priority_update_flow", | ||
VNIC_ENV_GET64(&vnic, send_queue_priority_update_flow)); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_u64_pair_put(fmsg, "comp_eq_overrun", | ||
VNIC_ENV_GET64(&vnic, comp_eq_overrun)); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_u64_pair_put(fmsg, "async_eq_overrun", | ||
VNIC_ENV_GET64(&vnic, async_eq_overrun)); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_u64_pair_put(fmsg, "cq_overrun", | ||
VNIC_ENV_GET64(&vnic, cq_overrun)); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_u64_pair_put(fmsg, "invalid_command", | ||
VNIC_ENV_GET64(&vnic, invalid_command)); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_u64_pair_put(fmsg, "quota_exceeded_command", | ||
VNIC_ENV_GET64(&vnic, quota_exceeded_command)); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_u64_pair_put(fmsg, "nic_receive_steering_discard", | ||
VNIC_ENV_GET64(&vnic, nic_receive_steering_discard)); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_obj_nest_end(fmsg); | ||
if (err) | ||
return err; | ||
|
||
err = devlink_fmsg_pair_nest_end(fmsg); | ||
if (err) | ||
return err; | ||
|
||
return 0; | ||
} | ||
|
||
static int mlx5_reporter_vnic_diagnose(struct devlink_health_reporter *reporter, | ||
struct devlink_fmsg *fmsg, | ||
struct netlink_ext_ack *extack) | ||
{ | ||
struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter); | ||
|
||
return mlx5_reporter_vnic_diagnose_counters(dev, fmsg, 0, false); | ||
} | ||
|
||
static const struct devlink_health_reporter_ops mlx5_reporter_vnic_ops = { | ||
.name = "vnic", | ||
.diagnose = mlx5_reporter_vnic_diagnose, | ||
}; | ||
|
||
void mlx5_reporter_vnic_create(struct mlx5_core_dev *dev) | ||
{ | ||
struct mlx5_core_health *health = &dev->priv.health; | ||
struct devlink *devlink = priv_to_devlink(dev); | ||
|
||
health->vnic_reporter = | ||
devlink_health_reporter_create(devlink, | ||
&mlx5_reporter_vnic_ops, | ||
0, dev); | ||
if (IS_ERR(health->vnic_reporter)) | ||
mlx5_core_warn(dev, | ||
"Failed to create vnic reporter, err = %ld\n", | ||
PTR_ERR(health->vnic_reporter)); | ||
} | ||
|
||
void mlx5_reporter_vnic_destroy(struct mlx5_core_dev *dev) | ||
{ | ||
struct mlx5_core_health *health = &dev->priv.health; | ||
|
||
if (!IS_ERR_OR_NULL(health->vnic_reporter)) | ||
devlink_health_reporter_destroy(health->vnic_reporter); | ||
} |
16 changes: 16 additions & 0 deletions
16
drivers/net/ethernet/mellanox/mlx5/core/diag/reporter_vnic.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB | ||
* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. | ||
*/ | ||
#ifndef __MLX5_REPORTER_VNIC_H | ||
#define __MLX5_REPORTER_VNIC_H | ||
|
||
#include "mlx5_core.h" | ||
|
||
void mlx5_reporter_vnic_create(struct mlx5_core_dev *dev); | ||
void mlx5_reporter_vnic_destroy(struct mlx5_core_dev *dev); | ||
|
||
int mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev, | ||
struct devlink_fmsg *fmsg, | ||
u16 vport_num, bool other_vport); | ||
|
||
#endif /* __MLX5_REPORTER_VNIC_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters