Commit 89b34322 authored by Gal Pressman's avatar Gal Pressman Committed by Jakub Kicinski

net/mlx5e: Use ethtool_sprintf/puts() to fill stats strings

Use ethtool_sprintf/puts() helper functions which handle the common
pattern of printing a string into the ethtool strings interface and
incrementing the string pointer by ETH_GSTRING_LEN.

Change the fill_strings callback to accept a **data pointer, and remove
the index and return value.
Signed-off-by: default avatarGal Pressman <gal@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240402133043.56322-4-tariqt@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 9ac9299d
...@@ -78,13 +78,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(ipsec_hw) ...@@ -78,13 +78,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(ipsec_hw)
unsigned int i; unsigned int i;
if (!priv->ipsec) if (!priv->ipsec)
return idx; return;
for (i = 0; i < NUM_IPSEC_HW_COUNTERS; i++) for (i = 0; i < NUM_IPSEC_HW_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, mlx5e_ipsec_hw_stats_desc[i].format);
mlx5e_ipsec_hw_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(ipsec_hw) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(ipsec_hw)
...@@ -115,9 +112,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(ipsec_sw) ...@@ -115,9 +112,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(ipsec_sw)
if (priv->ipsec) if (priv->ipsec)
for (i = 0; i < NUM_IPSEC_SW_COUNTERS; i++) for (i = 0; i < NUM_IPSEC_SW_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, mlx5e_ipsec_sw_stats_desc[i].format);
mlx5e_ipsec_sw_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(ipsec_sw) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(ipsec_sw)
......
...@@ -95,7 +95,7 @@ int mlx5e_ktls_init(struct mlx5e_priv *priv); ...@@ -95,7 +95,7 @@ int mlx5e_ktls_init(struct mlx5e_priv *priv);
void mlx5e_ktls_cleanup(struct mlx5e_priv *priv); void mlx5e_ktls_cleanup(struct mlx5e_priv *priv);
int mlx5e_ktls_get_count(struct mlx5e_priv *priv); int mlx5e_ktls_get_count(struct mlx5e_priv *priv);
int mlx5e_ktls_get_strings(struct mlx5e_priv *priv, uint8_t *data); void mlx5e_ktls_get_strings(struct mlx5e_priv *priv, uint8_t **data);
int mlx5e_ktls_get_stats(struct mlx5e_priv *priv, u64 *data); int mlx5e_ktls_get_stats(struct mlx5e_priv *priv, u64 *data);
#else #else
...@@ -144,10 +144,7 @@ static inline bool mlx5e_is_ktls_rx(struct mlx5_core_dev *mdev) ...@@ -144,10 +144,7 @@ static inline bool mlx5e_is_ktls_rx(struct mlx5_core_dev *mdev)
static inline int mlx5e_ktls_init(struct mlx5e_priv *priv) { return 0; } static inline int mlx5e_ktls_init(struct mlx5e_priv *priv) { return 0; }
static inline void mlx5e_ktls_cleanup(struct mlx5e_priv *priv) { } static inline void mlx5e_ktls_cleanup(struct mlx5e_priv *priv) { }
static inline int mlx5e_ktls_get_count(struct mlx5e_priv *priv) { return 0; } static inline int mlx5e_ktls_get_count(struct mlx5e_priv *priv) { return 0; }
static inline int mlx5e_ktls_get_strings(struct mlx5e_priv *priv, uint8_t *data) static inline void mlx5e_ktls_get_strings(struct mlx5e_priv *priv, uint8_t **data) { }
{
return 0;
}
static inline int mlx5e_ktls_get_stats(struct mlx5e_priv *priv, u64 *data) static inline int mlx5e_ktls_get_stats(struct mlx5e_priv *priv, u64 *data)
{ {
......
...@@ -58,20 +58,17 @@ int mlx5e_ktls_get_count(struct mlx5e_priv *priv) ...@@ -58,20 +58,17 @@ int mlx5e_ktls_get_count(struct mlx5e_priv *priv)
return ARRAY_SIZE(mlx5e_ktls_sw_stats_desc); return ARRAY_SIZE(mlx5e_ktls_sw_stats_desc);
} }
int mlx5e_ktls_get_strings(struct mlx5e_priv *priv, uint8_t *data) void mlx5e_ktls_get_strings(struct mlx5e_priv *priv, uint8_t **data)
{ {
unsigned int i, n, idx = 0; unsigned int i, n;
if (!priv->tls) if (!priv->tls)
return 0; return;
n = mlx5e_ktls_get_count(priv); n = mlx5e_ktls_get_count(priv);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, mlx5e_ktls_sw_stats_desc[i].format);
mlx5e_ktls_sw_stats_desc[i].format);
return n;
} }
int mlx5e_ktls_get_stats(struct mlx5e_priv *priv, u64 *data) int mlx5e_ktls_get_stats(struct mlx5e_priv *priv, u64 *data)
......
...@@ -38,16 +38,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(macsec_hw) ...@@ -38,16 +38,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(macsec_hw)
unsigned int i; unsigned int i;
if (!priv->macsec) if (!priv->macsec)
return idx; return;
if (!mlx5e_is_macsec_device(priv->mdev)) if (!mlx5e_is_macsec_device(priv->mdev))
return idx; return;
for (i = 0; i < NUM_MACSEC_HW_COUNTERS; i++) for (i = 0; i < NUM_MACSEC_HW_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, mlx5e_macsec_hw_stats_desc[i].format);
mlx5e_macsec_hw_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(macsec_hw) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(macsec_hw)
......
...@@ -135,9 +135,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(sw_rep) ...@@ -135,9 +135,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(sw_rep)
int i; int i;
for (i = 0; i < NUM_VPORT_REP_SW_COUNTERS; i++) for (i = 0; i < NUM_VPORT_REP_SW_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, sw_rep_stats_desc[i].format);
sw_rep_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(sw_rep) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(sw_rep)
...@@ -176,11 +174,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep) ...@@ -176,11 +174,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep)
int i; int i;
for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++) for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, vport_rep_stats_desc[i].format); ethtool_puts(data, vport_rep_stats_desc[i].format);
for (i = 0; i < NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev); i++) for (i = 0; i < NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev); i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, vport_rep_loopback_stats_desc[i].format);
vport_rep_loopback_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport_rep) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport_rep)
......
...@@ -97,10 +97,10 @@ void mlx5e_stats_fill_strings(struct mlx5e_priv *priv, u8 *data) ...@@ -97,10 +97,10 @@ void mlx5e_stats_fill_strings(struct mlx5e_priv *priv, u8 *data)
{ {
mlx5e_stats_grp_t *stats_grps = priv->profile->stats_grps; mlx5e_stats_grp_t *stats_grps = priv->profile->stats_grps;
const unsigned int num_stats_grps = stats_grps_num(priv); const unsigned int num_stats_grps = stats_grps_num(priv);
int i, idx = 0; int i;
for (i = 0; i < num_stats_grps; i++) for (i = 0; i < num_stats_grps; i++)
idx = stats_grps[i]->fill_strings(priv, data, idx); stats_grps[i]->fill_strings(priv, &data);
} }
/* Concrete NIC Stats */ /* Concrete NIC Stats */
...@@ -257,8 +257,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(sw) ...@@ -257,8 +257,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(sw)
int i; int i;
for (i = 0; i < NUM_SW_COUNTERS; i++) for (i = 0; i < NUM_SW_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, sw_stats_desc[i].format); ethtool_puts(data, sw_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(sw) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(sw)
...@@ -591,14 +590,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(qcnt) ...@@ -591,14 +590,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(qcnt)
int i; int i;
for (i = 0; i < NUM_Q_COUNTERS && q_counter_any(priv); i++) for (i = 0; i < NUM_Q_COUNTERS && q_counter_any(priv); i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, q_stats_desc[i].format);
q_stats_desc[i].format);
for (i = 0; i < NUM_DROP_RQ_COUNTERS && priv->drop_rq_q_counter; i++) for (i = 0; i < NUM_DROP_RQ_COUNTERS && priv->drop_rq_q_counter; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, drop_rq_stats_desc[i].format);
drop_rq_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(qcnt) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(qcnt)
...@@ -685,18 +680,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vnic_env) ...@@ -685,18 +680,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vnic_env)
int i; int i;
for (i = 0; i < NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev); i++) for (i = 0; i < NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev); i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, vnic_env_stats_steer_desc[i].format);
vnic_env_stats_steer_desc[i].format);
for (i = 0; i < NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev); i++) for (i = 0; i < NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev); i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, vnic_env_stats_dev_oob_desc[i].format);
vnic_env_stats_dev_oob_desc[i].format);
for (i = 0; i < NUM_VNIC_ENV_DROP_COUNTERS(priv->mdev); i++) for (i = 0; i < NUM_VNIC_ENV_DROP_COUNTERS(priv->mdev); i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, vnic_env_stats_drop_desc[i].format);
vnic_env_stats_drop_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vnic_env) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vnic_env)
...@@ -798,13 +788,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport) ...@@ -798,13 +788,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport)
int i; int i;
for (i = 0; i < NUM_VPORT_COUNTERS; i++) for (i = 0; i < NUM_VPORT_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, vport_stats_desc[i].format); ethtool_puts(data, vport_stats_desc[i].format);
for (i = 0; i < NUM_VPORT_LOOPBACK_COUNTERS(priv->mdev); i++) for (i = 0; i < NUM_VPORT_LOOPBACK_COUNTERS(priv->mdev); i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, vport_loopback_stats_desc[i].format);
vport_loopback_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport)
...@@ -868,8 +855,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(802_3) ...@@ -868,8 +855,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(802_3)
int i; int i;
for (i = 0; i < NUM_PPORT_802_3_COUNTERS; i++) for (i = 0; i < NUM_PPORT_802_3_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, pport_802_3_stats_desc[i].format); ethtool_puts(data, pport_802_3_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(802_3) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(802_3)
...@@ -1029,8 +1015,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(2863) ...@@ -1029,8 +1015,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(2863)
int i; int i;
for (i = 0; i < NUM_PPORT_2863_COUNTERS; i++) for (i = 0; i < NUM_PPORT_2863_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, pport_2863_stats_desc[i].format); ethtool_puts(data, pport_2863_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(2863) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(2863)
...@@ -1088,8 +1073,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(2819) ...@@ -1088,8 +1073,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(2819)
int i; int i;
for (i = 0; i < NUM_PPORT_2819_COUNTERS; i++) for (i = 0; i < NUM_PPORT_2819_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, pport_2819_stats_desc[i].format); ethtool_puts(data, pport_2819_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(2819) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(2819)
...@@ -1215,21 +1199,18 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(phy) ...@@ -1215,21 +1199,18 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(phy)
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
int i; int i;
strcpy(data + (idx++) * ETH_GSTRING_LEN, "link_down_events_phy"); ethtool_puts(data, "link_down_events_phy");
if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group)) if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
return idx; return;
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS; i++) for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, pport_phy_statistical_stats_desc[i].format);
pport_phy_statistical_stats_desc[i].format);
if (MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters)) if (MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters))
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS; i++) for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data,
pport_phy_statistical_err_lanes_stats_desc[i].format); pport_phy_statistical_err_lanes_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy)
...@@ -1436,9 +1417,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(eth_ext) ...@@ -1436,9 +1417,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(eth_ext)
if (MLX5_CAP_PCAM_FEATURE((priv)->mdev, rx_buffer_fullness_counters)) if (MLX5_CAP_PCAM_FEATURE((priv)->mdev, rx_buffer_fullness_counters))
for (i = 0; i < NUM_PPORT_ETH_EXT_COUNTERS; i++) for (i = 0; i < NUM_PPORT_ETH_EXT_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, pport_eth_ext_stats_desc[i].format);
pport_eth_ext_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(eth_ext) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(eth_ext)
...@@ -1516,19 +1495,16 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(pcie) ...@@ -1516,19 +1495,16 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(pcie)
if (MLX5_CAP_MCAM_FEATURE((priv)->mdev, pcie_performance_group)) if (MLX5_CAP_MCAM_FEATURE((priv)->mdev, pcie_performance_group))
for (i = 0; i < NUM_PCIE_PERF_COUNTERS; i++) for (i = 0; i < NUM_PCIE_PERF_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, pcie_perf_stats_desc[i].format);
pcie_perf_stats_desc[i].format);
if (MLX5_CAP_MCAM_FEATURE((priv)->mdev, tx_overflow_buffer_pkt)) if (MLX5_CAP_MCAM_FEATURE((priv)->mdev, tx_overflow_buffer_pkt))
for (i = 0; i < NUM_PCIE_PERF_COUNTERS64; i++) for (i = 0; i < NUM_PCIE_PERF_COUNTERS64; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, pcie_perf_stats_desc64[i].format);
pcie_perf_stats_desc64[i].format);
if (MLX5_CAP_MCAM_FEATURE((priv)->mdev, pcie_outbound_stalled)) if (MLX5_CAP_MCAM_FEATURE((priv)->mdev, pcie_outbound_stalled))
for (i = 0; i < NUM_PCIE_PERF_STALL_COUNTERS; i++) for (i = 0; i < NUM_PCIE_PERF_STALL_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data,
pcie_perf_stall_stats_desc[i].format); pcie_perf_stall_stats_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(pcie) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(pcie)
...@@ -1609,18 +1585,18 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(per_port_buff_congest) ...@@ -1609,18 +1585,18 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(per_port_buff_congest)
int i, prio; int i, prio;
if (!MLX5_CAP_GEN(mdev, sbcam_reg)) if (!MLX5_CAP_GEN(mdev, sbcam_reg))
return idx; return;
for (prio = 0; prio < NUM_PPORT_PRIO; prio++) { for (prio = 0; prio < NUM_PPORT_PRIO; prio++) {
for (i = 0; i < NUM_PPORT_PER_TC_PRIO_COUNTERS; i++) for (i = 0; i < NUM_PPORT_PER_TC_PRIO_COUNTERS; i++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data,
pport_per_tc_prio_stats_desc[i].format, prio); pport_per_tc_prio_stats_desc[i].format,
prio);
for (i = 0; i < NUM_PPORT_PER_TC_CONGEST_PRIO_COUNTERS; i++) for (i = 0; i < NUM_PPORT_PER_TC_CONGEST_PRIO_COUNTERS; i++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data,
pport_per_tc_congest_prio_stats_desc[i].format, prio); pport_per_tc_congest_prio_stats_desc[i].format,
prio);
} }
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(per_port_buff_congest) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(per_port_buff_congest)
...@@ -1728,19 +1704,17 @@ static int mlx5e_grp_per_prio_traffic_get_num_stats(void) ...@@ -1728,19 +1704,17 @@ static int mlx5e_grp_per_prio_traffic_get_num_stats(void)
return NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * NUM_PPORT_PRIO; return NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * NUM_PPORT_PRIO;
} }
static int mlx5e_grp_per_prio_traffic_fill_strings(struct mlx5e_priv *priv, static void mlx5e_grp_per_prio_traffic_fill_strings(struct mlx5e_priv *priv,
u8 *data, u8 **data)
int idx)
{ {
int i, prio; int i, prio;
for (prio = 0; prio < NUM_PPORT_PRIO; prio++) { for (prio = 0; prio < NUM_PPORT_PRIO; prio++) {
for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++) for (i = 0; i < NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS; i++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data,
pport_per_prio_traffic_stats_desc[i].format, prio); pport_per_prio_traffic_stats_desc[i].format,
prio);
} }
return idx;
} }
static int mlx5e_grp_per_prio_traffic_fill_stats(struct mlx5e_priv *priv, static int mlx5e_grp_per_prio_traffic_fill_stats(struct mlx5e_priv *priv,
...@@ -1816,9 +1790,8 @@ static int mlx5e_grp_per_prio_pfc_get_num_stats(struct mlx5e_priv *priv) ...@@ -1816,9 +1790,8 @@ static int mlx5e_grp_per_prio_pfc_get_num_stats(struct mlx5e_priv *priv)
NUM_PPORT_PFC_STALL_COUNTERS(priv); NUM_PPORT_PFC_STALL_COUNTERS(priv);
} }
static int mlx5e_grp_per_prio_pfc_fill_strings(struct mlx5e_priv *priv, static void mlx5e_grp_per_prio_pfc_fill_strings(struct mlx5e_priv *priv,
u8 *data, u8 **data)
int idx)
{ {
unsigned long pfc_combined; unsigned long pfc_combined;
int i, prio; int i, prio;
...@@ -1829,23 +1802,22 @@ static int mlx5e_grp_per_prio_pfc_fill_strings(struct mlx5e_priv *priv, ...@@ -1829,23 +1802,22 @@ static int mlx5e_grp_per_prio_pfc_fill_strings(struct mlx5e_priv *priv,
char pfc_string[ETH_GSTRING_LEN]; char pfc_string[ETH_GSTRING_LEN];
snprintf(pfc_string, sizeof(pfc_string), "prio%d", prio); snprintf(pfc_string, sizeof(pfc_string), "prio%d", prio);
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data,
pport_per_prio_pfc_stats_desc[i].format, pfc_string); pport_per_prio_pfc_stats_desc[i].format,
pfc_string);
} }
} }
if (mlx5e_query_global_pause_combined(priv)) { if (mlx5e_query_global_pause_combined(priv)) {
for (i = 0; i < NUM_PPORT_PER_PRIO_PFC_COUNTERS; i++) { for (i = 0; i < NUM_PPORT_PER_PRIO_PFC_COUNTERS; i++) {
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data,
pport_per_prio_pfc_stats_desc[i].format, "global"); pport_per_prio_pfc_stats_desc[i].format,
"global");
} }
} }
for (i = 0; i < NUM_PPORT_PFC_STALL_COUNTERS(priv); i++) for (i = 0; i < NUM_PPORT_PFC_STALL_COUNTERS(priv); i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, pport_pfc_stall_stats_desc[i].format);
pport_pfc_stall_stats_desc[i].format);
return idx;
} }
static int mlx5e_grp_per_prio_pfc_fill_stats(struct mlx5e_priv *priv, static int mlx5e_grp_per_prio_pfc_fill_stats(struct mlx5e_priv *priv,
...@@ -1887,9 +1859,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(per_prio) ...@@ -1887,9 +1859,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(per_prio)
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(per_prio) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(per_prio)
{ {
idx = mlx5e_grp_per_prio_traffic_fill_strings(priv, data, idx); mlx5e_grp_per_prio_traffic_fill_strings(priv, data);
idx = mlx5e_grp_per_prio_pfc_fill_strings(priv, data, idx); mlx5e_grp_per_prio_pfc_fill_strings(priv, data);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(per_prio) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(per_prio)
...@@ -1944,12 +1915,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(pme) ...@@ -1944,12 +1915,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(pme)
int i; int i;
for (i = 0; i < NUM_PME_STATUS_STATS; i++) for (i = 0; i < NUM_PME_STATUS_STATS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, mlx5e_pme_status_desc[i].format); ethtool_puts(data, mlx5e_pme_status_desc[i].format);
for (i = 0; i < NUM_PME_ERR_STATS; i++) for (i = 0; i < NUM_PME_ERR_STATS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, mlx5e_pme_error_desc[i].format); ethtool_puts(data, mlx5e_pme_error_desc[i].format);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(pme) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(pme)
...@@ -1979,7 +1948,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(tls) ...@@ -1979,7 +1948,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(tls)
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(tls) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(tls)
{ {
return idx + mlx5e_ktls_get_strings(priv, data + idx * ETH_GSTRING_LEN); mlx5e_ktls_get_strings(priv, data);
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(tls) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(tls)
...@@ -2264,10 +2233,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(qos) ...@@ -2264,10 +2233,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(qos)
for (qid = 0; qid < max_qos_sqs; qid++) for (qid = 0; qid < max_qos_sqs; qid++)
for (i = 0; i < NUM_QOS_SQ_STATS; i++) for (i = 0; i < NUM_QOS_SQ_STATS; i++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, qos_sq_stats_desc[i].format, qid);
qos_sq_stats_desc[i].format, qid);
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(qos) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(qos)
...@@ -2312,29 +2278,29 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(ptp) ...@@ -2312,29 +2278,29 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(ptp)
int i, tc; int i, tc;
if (!priv->tx_ptp_opened && !priv->rx_ptp_opened) if (!priv->tx_ptp_opened && !priv->rx_ptp_opened)
return idx; return;
for (i = 0; i < NUM_PTP_CH_STATS; i++) for (i = 0; i < NUM_PTP_CH_STATS; i++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_puts(data, ptp_ch_stats_desc[i].format);
"%s", ptp_ch_stats_desc[i].format);
if (priv->tx_ptp_opened) { if (priv->tx_ptp_opened) {
for (tc = 0; tc < priv->max_opened_tc; tc++) for (tc = 0; tc < priv->max_opened_tc; tc++)
for (i = 0; i < NUM_PTP_SQ_STATS; i++) for (i = 0; i < NUM_PTP_SQ_STATS; i++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data,
ptp_sq_stats_desc[i].format, tc); ptp_sq_stats_desc[i].format,
tc);
for (tc = 0; tc < priv->max_opened_tc; tc++) for (tc = 0; tc < priv->max_opened_tc; tc++)
for (i = 0; i < NUM_PTP_CQ_STATS; i++) for (i = 0; i < NUM_PTP_CQ_STATS; i++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data,
ptp_cq_stats_desc[i].format, tc); ptp_cq_stats_desc[i].format,
tc);
} }
if (priv->rx_ptp_opened) { if (priv->rx_ptp_opened) {
for (i = 0; i < NUM_PTP_RQ_STATS; i++) for (i = 0; i < NUM_PTP_RQ_STATS; i++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, ptp_rq_stats_desc[i].format,
ptp_rq_stats_desc[i].format, MLX5E_PTP_CHANNEL_IX); MLX5E_PTP_CHANNEL_IX);
} }
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(ptp) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(ptp)
...@@ -2394,38 +2360,29 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(channels) ...@@ -2394,38 +2360,29 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(channels)
for (i = 0; i < max_nch; i++) for (i = 0; i < max_nch; i++)
for (j = 0; j < NUM_CH_STATS; j++) for (j = 0; j < NUM_CH_STATS; j++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, ch_stats_desc[j].format, i);
ch_stats_desc[j].format, i);
for (i = 0; i < max_nch; i++) { for (i = 0; i < max_nch; i++) {
for (j = 0; j < NUM_RQ_STATS; j++) for (j = 0; j < NUM_RQ_STATS; j++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, rq_stats_desc[j].format, i);
rq_stats_desc[j].format, i);
for (j = 0; j < NUM_XSKRQ_STATS * is_xsk; j++) for (j = 0; j < NUM_XSKRQ_STATS * is_xsk; j++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, xskrq_stats_desc[j].format, i);
xskrq_stats_desc[j].format, i);
for (j = 0; j < NUM_RQ_XDPSQ_STATS; j++) for (j = 0; j < NUM_RQ_XDPSQ_STATS; j++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, rq_xdpsq_stats_desc[j].format, i);
rq_xdpsq_stats_desc[j].format, i);
} }
for (tc = 0; tc < priv->max_opened_tc; tc++) for (tc = 0; tc < priv->max_opened_tc; tc++)
for (i = 0; i < max_nch; i++) for (i = 0; i < max_nch; i++)
for (j = 0; j < NUM_SQ_STATS; j++) for (j = 0; j < NUM_SQ_STATS; j++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, sq_stats_desc[j].format,
sq_stats_desc[j].format, i + tc * max_nch);
i + tc * max_nch);
for (i = 0; i < max_nch; i++) { for (i = 0; i < max_nch; i++) {
for (j = 0; j < NUM_XSKSQ_STATS * is_xsk; j++) for (j = 0; j < NUM_XSKSQ_STATS * is_xsk; j++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, xsksq_stats_desc[j].format, i);
xsksq_stats_desc[j].format, i);
for (j = 0; j < NUM_XDPSQ_STATS; j++) for (j = 0; j < NUM_XDPSQ_STATS; j++)
sprintf(data + (idx++) * ETH_GSTRING_LEN, ethtool_sprintf(data, xdpsq_stats_desc[j].format, i);
xdpsq_stats_desc[j].format, i);
} }
return idx;
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(channels) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(channels)
......
...@@ -71,7 +71,7 @@ struct mlx5e_priv; ...@@ -71,7 +71,7 @@ struct mlx5e_priv;
struct mlx5e_stats_grp { struct mlx5e_stats_grp {
u16 update_stats_mask; u16 update_stats_mask;
int (*get_num_stats)(struct mlx5e_priv *priv); int (*get_num_stats)(struct mlx5e_priv *priv);
int (*fill_strings)(struct mlx5e_priv *priv, u8 *data, int idx); void (*fill_strings)(struct mlx5e_priv *priv, u8 **data);
int (*fill_stats)(struct mlx5e_priv *priv, u64 *data, int idx); int (*fill_stats)(struct mlx5e_priv *priv, u64 *data, int idx);
void (*update_stats)(struct mlx5e_priv *priv); void (*update_stats)(struct mlx5e_priv *priv);
}; };
...@@ -87,7 +87,7 @@ typedef const struct mlx5e_stats_grp *const mlx5e_stats_grp_t; ...@@ -87,7 +87,7 @@ typedef const struct mlx5e_stats_grp *const mlx5e_stats_grp_t;
void MLX5E_STATS_GRP_OP(grp, update_stats)(struct mlx5e_priv *priv) void MLX5E_STATS_GRP_OP(grp, update_stats)(struct mlx5e_priv *priv)
#define MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(grp) \ #define MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(grp) \
int MLX5E_STATS_GRP_OP(grp, fill_strings)(struct mlx5e_priv *priv, u8 *data, int idx) void MLX5E_STATS_GRP_OP(grp, fill_strings)(struct mlx5e_priv *priv, u8 **data)
#define MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(grp) \ #define MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(grp) \
int MLX5E_STATS_GRP_OP(grp, fill_stats)(struct mlx5e_priv *priv, u64 *data, int idx) int MLX5E_STATS_GRP_OP(grp, fill_stats)(struct mlx5e_priv *priv, u64 *data, int idx)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment