Skip to content

Commit 838b6c9

Browse files
committed
Merge branch 'mlxsw-support-for-nexthop-group-statistics'
Petr Machata says: ==================== mlxsw: Support for nexthop group statistics ECMP is a fundamental component in L3 designs. However, it's fragile. Many factors influence whether an ECMP group will operate as intended: hash policy (i.e. the set of fields that contribute to ECMP hash calculation), neighbor validity, hash seed (which might lead to polarization) or the type of ECMP group used (hash-threshold or resilient). At the same time, collection of statistics that would help an operator determine that the group performs as desired, is difficult. Support for nexthop group statistics and their HW collection has been introduced recently. In this patch set, add HW stats collection support to mlxsw. This patchset progresses as follows: - Patches #1 and #2 add nexthop IDs to notifiers. - Patches #3 and #4 are code-shaping. - Patches #5, #6 and #7 adjust the flow counter code. - Patches #8 and #9 add HW nexthop counters. - Patch #10 adjusts the HW counter code to allow sharing the same counter for several resilient group buckets with the same NH ID. - Patch #11 adds a selftest. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents e5b7aef + a22b042 commit 838b6c9

File tree

14 files changed

+505
-46
lines changed

14 files changed

+505
-46
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,15 @@ MLXSW_ITEM32(tx, hdr, fid, 0x08, 16, 16);
176176
MLXSW_ITEM32(tx, hdr, type, 0x0C, 0, 4);
177177

178178
int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
179-
unsigned int counter_index, u64 *packets,
180-
u64 *bytes)
179+
unsigned int counter_index, bool clear,
180+
u64 *packets, u64 *bytes)
181181
{
182+
enum mlxsw_reg_mgpc_opcode op = clear ? MLXSW_REG_MGPC_OPCODE_CLEAR :
183+
MLXSW_REG_MGPC_OPCODE_NOP;
182184
char mgpc_pl[MLXSW_REG_MGPC_LEN];
183185
int err;
184186

185-
mlxsw_reg_mgpc_pack(mgpc_pl, counter_index, MLXSW_REG_MGPC_OPCODE_NOP,
187+
mlxsw_reg_mgpc_pack(mgpc_pl, counter_index, op,
186188
MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
187189
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl);
188190
if (err)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,8 @@ int mlxsw_sp_port_kill_vid(struct net_device *dev,
706706
int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
707707
u16 vid_end, bool is_member, bool untagged);
708708
int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
709-
unsigned int counter_index, u64 *packets,
710-
u64 *bytes);
709+
unsigned int counter_index, bool clear,
710+
u64 *packets, u64 *bytes);
711711
int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
712712
unsigned int *p_counter_index);
713713
void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
10241024
rulei = mlxsw_sp_acl_rule_rulei(rule);
10251025
if (rulei->counter_valid) {
10261026
err = mlxsw_sp_flow_counter_get(mlxsw_sp, rulei->counter_index,
1027-
&current_packets,
1027+
false, &current_packets,
10281028
&current_bytes);
10291029
if (err)
10301030
return err;

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,9 +1181,11 @@ static int mlxsw_sp_dpipe_table_adj_counters_update(void *priv, bool enable)
11811181
char ratr_pl[MLXSW_REG_RATR_LEN];
11821182
struct mlxsw_sp *mlxsw_sp = priv;
11831183
struct mlxsw_sp_nexthop *nh;
1184+
unsigned int n_done = 0;
11841185
u32 adj_hash_index = 0;
11851186
u32 adj_index = 0;
11861187
u32 adj_size = 0;
1188+
int err;
11871189

11881190
mlxsw_sp_nexthop_for_each(nh, mlxsw_sp->router) {
11891191
if (!mlxsw_sp_nexthop_is_forward(nh) ||
@@ -1192,15 +1194,27 @@ static int mlxsw_sp_dpipe_table_adj_counters_update(void *priv, bool enable)
11921194

11931195
mlxsw_sp_nexthop_indexes(nh, &adj_index, &adj_size,
11941196
&adj_hash_index);
1195-
if (enable)
1196-
mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh);
1197-
else
1198-
mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh);
1197+
if (enable) {
1198+
err = mlxsw_sp_nexthop_counter_enable(mlxsw_sp, nh);
1199+
if (err)
1200+
goto err_counter_enable;
1201+
} else {
1202+
mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh);
1203+
}
11991204
mlxsw_sp_nexthop_eth_update(mlxsw_sp,
12001205
adj_index + adj_hash_index, nh,
12011206
true, ratr_pl);
1207+
n_done++;
12021208
}
12031209
return 0;
1210+
1211+
err_counter_enable:
1212+
mlxsw_sp_nexthop_for_each(nh, mlxsw_sp->router) {
1213+
if (!n_done--)
1214+
break;
1215+
mlxsw_sp_nexthop_counter_disable(mlxsw_sp, nh);
1216+
}
1217+
return err;
12041218
}
12051219

12061220
static u64

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static int mlxsw_sp_mr_tcam_route_stats(struct mlxsw_sp *mlxsw_sp,
361361
struct mlxsw_sp_mr_tcam_route *route = route_priv;
362362

363363
return mlxsw_sp_flow_counter_get(mlxsw_sp, route->counter_index,
364-
packets, bytes);
364+
false, packets, bytes);
365365
}
366366

367367
static int

0 commit comments

Comments
 (0)