Skip to content

Commit 075ab8a

Browse files
Nogah Frankeldavem330
authored andcommitted
mlxsw: spectrum: Collect tclass related stats periodically
Add more statistics to be collected from the HW periodically. These stats are tclass based (beside ECN marked packet, that exist only port based). They are needed to expose RED qdisc stats and xstats correctly. Signed-off-by: Nogah Frankel <nogahf@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0afc122 commit 075ab8a

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,38 @@ static int mlxsw_sp_port_get_hw_stats(struct net_device *dev,
13241324
return err;
13251325
}
13261326

1327+
static void
1328+
mlxsw_sp_port_get_hw_xstats(struct net_device *dev,
1329+
struct mlxsw_sp_port_xstats *xstats)
1330+
{
1331+
char ppcnt_pl[MLXSW_REG_PPCNT_LEN];
1332+
int err, i;
1333+
1334+
err = mlxsw_sp_port_get_stats_raw(dev, MLXSW_REG_PPCNT_EXT_CNT, 0,
1335+
ppcnt_pl);
1336+
if (!err)
1337+
xstats->ecn = mlxsw_reg_ppcnt_ecn_marked_get(ppcnt_pl);
1338+
1339+
for (i = 0; i < TC_MAX_QUEUE; i++) {
1340+
err = mlxsw_sp_port_get_stats_raw(dev,
1341+
MLXSW_REG_PPCNT_TC_CONG_TC,
1342+
i, ppcnt_pl);
1343+
if (!err)
1344+
xstats->wred_drop[i] =
1345+
mlxsw_reg_ppcnt_wred_discard_get(ppcnt_pl);
1346+
1347+
err = mlxsw_sp_port_get_stats_raw(dev, MLXSW_REG_PPCNT_TC_CNT,
1348+
i, ppcnt_pl);
1349+
if (err)
1350+
continue;
1351+
1352+
xstats->backlog[i] =
1353+
mlxsw_reg_ppcnt_tc_transmit_queue_get(ppcnt_pl);
1354+
xstats->tail_drop[i] =
1355+
mlxsw_reg_ppcnt_tc_no_buffer_discard_uc_get(ppcnt_pl);
1356+
}
1357+
}
1358+
13271359
static void update_stats_cache(struct work_struct *work)
13281360
{
13291361
struct mlxsw_sp_port *mlxsw_sp_port =
@@ -1335,6 +1367,8 @@ static void update_stats_cache(struct work_struct *work)
13351367

13361368
mlxsw_sp_port_get_hw_stats(mlxsw_sp_port->dev,
13371369
&mlxsw_sp_port->periodic_hw_stats.stats);
1370+
mlxsw_sp_port_get_hw_xstats(mlxsw_sp_port->dev,
1371+
&mlxsw_sp_port->periodic_hw_stats.xstats);
13381372

13391373
out:
13401374
mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw,

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ struct mlxsw_sp_qdisc {
213213
enum mlxsw_sp_qdisc_type type;
214214
};
215215

216+
/* No need an internal lock; At worse - miss a single periodic iteration */
217+
struct mlxsw_sp_port_xstats {
218+
u64 ecn;
219+
u64 wred_drop[TC_MAX_QUEUE];
220+
u64 tail_drop[TC_MAX_QUEUE];
221+
u64 backlog[TC_MAX_QUEUE];
222+
};
223+
216224
struct mlxsw_sp_port {
217225
struct net_device *dev;
218226
struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats;
@@ -242,6 +250,7 @@ struct mlxsw_sp_port {
242250
struct {
243251
#define MLXSW_HW_STATS_UPDATE_TIME HZ
244252
struct rtnl_link_stats64 stats;
253+
struct mlxsw_sp_port_xstats xstats;
245254
struct delayed_work update_dw;
246255
} periodic_hw_stats;
247256
struct mlxsw_sp_port_sample *sample;

0 commit comments

Comments
 (0)