mlxsw: Preparations for resilient nexthop groups
Subsystems (3)
cover mlxsw: Preparations for resilient nexthop groups
From: Ido Schimmel <[email protected]>
This patchset contains preparations for resilient nexthop groups support in mlxsw. A follow-up patchset will add support and selftests. Most of the patches are trivial and small to make review easier.
Patchset overview:
Patch #1 removes RTNL assertion in nexthop notifier block since it is not needed. The assertion will trigger when mlxsw starts processing notifications related to resilient groups as not all are emitted with RTNL held.
Patches #2-#9 gradually add support for nexthops with trap action. Up until now mlxsw did not program nexthops whose neighbour entry was not resolved. This will not work with resilient groups as their size is fixed and the nexthop mapped to each bucket is determined by the nexthop code. Therefore, nexthops whose neighbour entry is not resolved will be programmed to trap packets to the CPU in order to trigger neighbour resolution.
Patch #10 is a non-functional change to allow for code reuse between regular nexthop groups and resilient ones.
Patch #11 avoids unnecessary neighbour updates in hardware. See the commit message for a detailed explanation.
Patches #12-#14 add support for additional nexthop group sizes that are supported by Spectrum-{2,3} ASICs.
Ido Schimmel (14):
mlxsw: spectrum_router: Remove RTNL assertion
mlxsw: spectrum_router: Consolidate nexthop helpers
mlxsw: spectrum_router: Only provide MAC address for valid nexthops
mlxsw: spectrum_router: Adjust comments on nexthop fields
mlxsw: spectrum_router: Introduce nexthop action field
mlxsw: spectrum_router: Prepare for nexthops with trap action
mlxsw: spectrum_router: Add nexthop trap action support
mlxsw: spectrum_router: Rename nexthop update function to reflect its
type
mlxsw: spectrum_router: Encapsulate nexthop update in a function
mlxsw: spectrum_router: Break nexthop group entry validation to a
separate function
mlxsw: spectrum_router: Avoid unnecessary neighbour updates
mlxsw: spectrum_router: Create per-ASIC router operations
mlxsw: spectrum_router: Encode adjacency group size ranges in an array
mlxsw: spectrum_router: Add Spectrum-{2, 3} adjacency group size
ranges
.../net/ethernet/mellanox/mlxsw/spectrum.c | 6 +- .../net/ethernet/mellanox/mlxsw/spectrum.h | 8 +- .../ethernet/mellanox/mlxsw/spectrum_dpipe.c | 19 +- .../ethernet/mellanox/mlxsw/spectrum_router.c | 277 +++++++++++++----- .../ethernet/mellanox/mlxsw/spectrum_router.h | 9 +- 5 files changed, 218 insertions(+), 101 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/14 mlxsw: spectrum_router: Remove RTNL assertion
From: Ido Schimmel <[email protected]>
Remove the RTNL assertion in the nexthop notifier block. The assertion is not needed given RTNL is never assumed to be taken.
This is a preparation for future patches where mlxsw will start handling nexthop events that are not always sent with RTNL held.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +0 -2
@@ -4699,8 +4699,6 @@ static int mlxsw_sp_nexthop_obj_event(struct notifier_block *nb,mutex_lock (&router->lock); -ASSERT_RTNL (); -switch (event) {case NEXTHOP_EVENT_REPLACE : err =mlxsw_sp_nexthop_obj_new (router->mlxsw_sp, info);
Signature · 1 line
2.29.2
PATCH 2/14 mlxsw: spectrum_router: Consolidate nexthop helpers
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
The helper mlxsw_sp_nexthop_offload() is actually interested in finding out if the nexthop is both written to the adjacency table and forwarding packets (as opposed to discarding them).
Rename it to mlxsw_sp_nexthop_is_forward() and remove mlxsw_sp_nexthop_is_discard().
--- .../net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 15 ++++++--------- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 9 ++------- .../net/ethernet/mellanox/mlxsw/spectrum_router.h | 3 +-- 3 files changed, 9 insertions(+), 18 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c +6 -9
@@ -912,9 +912,8 @@ static u64 mlxsw_sp_dpipe_table_adj_size(struct mlxsw_sp *mlxsw_sp)u64 size =0 ;mlxsw_sp_nexthop_for_each (nh, mlxsw_sp->router) -if (mlxsw_sp_nexthop_offload (nh) && - !mlxsw_sp_nexthop_group_has_ipip (nh) && - !mlxsw_sp_nexthop_is_discard (nh)) +if (mlxsw_sp_nexthop_is_forward (nh) && + !mlxsw_sp_nexthop_group_has_ipip (nh)) size++;return size; }
@@ -1105,9 +1104,8 @@ mlxsw_sp_dpipe_table_adj_entries_get(struct mlxsw_sp *mlxsw_sp, nh_skip = nh_count; nh_count =0 ;mlxsw_sp_nexthop_for_each (nh, mlxsw_sp->router) { -if (!mlxsw_sp_nexthop_offload (nh) || -mlxsw_sp_nexthop_group_has_ipip (nh) || -mlxsw_sp_nexthop_is_discard (nh)) +if (!mlxsw_sp_nexthop_is_forward (nh) || +mlxsw_sp_nexthop_group_has_ipip (nh))continue ;if (nh_count < nh_skip)
@@ -1187,9 +1185,8 @@ static int mlxsw_sp_dpipe_table_adj_counters_update(void *priv, bool enable)u32 adj_size =0 ;mlxsw_sp_nexthop_for_each (nh, mlxsw_sp->router) { -if (!mlxsw_sp_nexthop_offload (nh) || -mlxsw_sp_nexthop_group_has_ipip (nh) || -mlxsw_sp_nexthop_is_discard (nh)) +if (!mlxsw_sp_nexthop_is_forward (nh) || +mlxsw_sp_nexthop_group_has_ipip (nh))continue ; mlxsw_sp_nexthop_indexes(nh, &adj_index, &adj_size,
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +2 -7
@@ -2979,9 +2979,9 @@ struct mlxsw_sp_nexthop *mlxsw_sp_nexthop_next(struct mlxsw_sp_router *router,return list_next_entry (nh, router_list_node); } -bool mlxsw_sp_nexthop_offload (struct mlxsw_sp_nexthop *nh) +bool mlxsw_sp_nexthop_is_forward (const struct mlxsw_sp_nexthop *nh) { -return nh->offloaded; +return nh->offloaded && !nh->discard; }unsigned char *mlxsw_sp_nexthop_ha (struct mlxsw_sp_nexthop *nh)
@@ -3036,11 +3036,6 @@ bool mlxsw_sp_nexthop_group_has_ipip(struct mlxsw_sp_nexthop *nh)return false; } -bool mlxsw_sp_nexthop_is_discard (const struct mlxsw_sp_nexthop *nh) -{ -return nh->discard; -} -static const struct rhashtable_params mlxsw_sp_nexthop_group_vr_ht_params = { .key_offset = offsetof(struct mlxsw_sp_nexthop_group_vr_entry , key), .head_offset = offsetof(struct mlxsw_sp_nexthop_group_vr_entry , ht_node),
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +1 -2
@@ -195,13 +195,12 @@ mlxsw_sp_ipip_demote_tunnel_by_saddr(struct mlxsw_sp *mlxsw_sp, const struct mlxsw_sp_ipip_entry *except);struct mlxsw_sp_nexthop *mlxsw_sp_nexthop_next (struct mlxsw_sp_router *router,struct mlxsw_sp_nexthop *nh); -bool mlxsw_sp_nexthop_offload (struct mlxsw_sp_nexthop *nh); +bool mlxsw_sp_nexthop_is_forward (const struct mlxsw_sp_nexthop *nh);unsigned char *mlxsw_sp_nexthop_ha (struct mlxsw_sp_nexthop *nh);int mlxsw_sp_nexthop_indexes (struct mlxsw_sp_nexthop *nh,u32 *p_adj_index,u32 *p_adj_size,u32 *p_adj_hash_index);struct mlxsw_sp_rif *mlxsw_sp_nexthop_rif (struct mlxsw_sp_nexthop *nh);bool mlxsw_sp_nexthop_group_has_ipip (struct mlxsw_sp_nexthop *nh); -bool mlxsw_sp_nexthop_is_discard (const struct mlxsw_sp_nexthop *nh);#define mlxsw_sp_nexthop_for_each (nh, router) \ for (nh = mlxsw_sp_nexthop_next(router, NULL); nh; \ nh = mlxsw_sp_nexthop_next(router, nh))
Signature · 1 line
2.29.2
PATCH 3/14 mlxsw: spectrum_router: Only provide MAC address for valid nexthops
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
The helper returns the MAC address associated with the nexthop. It is only valid when the nexthop forwards packets and when it is an Ethernet nexthop. Reflect this in the checks the helper is performing.
This is not an issue because the sole caller of the function only invokes it for such nexthops.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +2 -1
@@ -2986,7 +2986,8 @@ bool mlxsw_sp_nexthop_is_forward(const struct mlxsw_sp_nexthop *nh)unsigned char *mlxsw_sp_nexthop_ha (struct mlxsw_sp_nexthop *nh) { -if (!nh->offloaded) +if (nh->type !=MLXSW_SP_NEXTHOP_TYPE_ETH || + !mlxsw_sp_nexthop_is_forward (nh))return NULL ;return nh->neigh_entry->ha; }
Signature · 1 line
2.29.2
PATCH 4/14 mlxsw: spectrum_router: Adjust comments on nexthop fields
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
The comments assume that nexthops are simple Ethernet nexthops that are programmed to forward packets to the associated neighbour. This is no longer the case, as both IPinIP and blackhole nexthops are now supported.
Adjust the comments to reflect these changes.
--- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +6 -6
@@ -2862,14 +2862,14 @@ struct mlxsw_sp_nexthop {int norm_nh_weight;int num_adj_entries;struct mlxsw_sp_rif *rif; - u8 should_offload:1, /* set indicates this neigh is connected and -* should be put to KVD linear area of this group. + u8 should_offload:1, /* set indicates this nexthop should be written +* to the adjacency table. */ - offloaded:1, /* set in case the neigh is actually put into -* KVD linear area of this group. + offloaded:1, /* set indicates this nexthop was written to the +* adjacency table. */ - update:1, /* set indicates that MAC of this neigh should be -* updated in HW + update:1, /* set indicates this nexthop should be updated in the +* adjacency table (f.e., its MAC changed). */ discard:1; /* nexthop is programmed to discard packets */enum mlxsw_sp_nexthop_type type;
Signature · 1 line
2.29.2
PATCH 5/14 mlxsw: spectrum_router: Introduce nexthop action field
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Currently, the action associated with the nexthop is assumed to be 'forward' unless the 'discard' bit is set.
Instead, simplify this by introducing a dedicated field to represent the action of the nexthop. This will allow us to more easily introduce more actions, such as trap.
--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +17 -8
@@ -2842,6 +2842,13 @@ enum mlxsw_sp_nexthop_type { MLXSW_SP_NEXTHOP_TYPE_IPIP, }; +enum mlxsw_sp_nexthop_action { +/* Nexthop forwards packets to an egress RIF */ +MLXSW_SP_NEXTHOP_ACTION_FORWARD , +/* Nexthop discards packets */ +MLXSW_SP_NEXTHOP_ACTION_DISCARD , +}; +struct mlxsw_sp_nexthop_key {struct fib_nh *fib_nh; };
@@ -2868,10 +2875,10 @@ struct mlxsw_sp_nexthop { offloaded:1 ,/* set indicates this nexthop was written to the * adjacency table. */ - update:1, /* set indicates this nexthop should be updated in the + update:1; /* set indicates this nexthop should be updated in the* adjacency table (f.e., its MAC changed). */ - discard:1; /* nexthop is programmed to discard packets */ +enum mlxsw_sp_nexthop_action action;enum mlxsw_sp_nexthop_type type;union {struct mlxsw_sp_neigh_entry *neigh_entry;
@@ -2981,7 +2988,7 @@ struct mlxsw_sp_nexthop *mlxsw_sp_nexthop_next(struct mlxsw_sp_router *router,bool mlxsw_sp_nexthop_is_forward (const struct mlxsw_sp_nexthop *nh) { -return nh->offloaded && !nh->discard; +return nh->offloaded && nh->action ==MLXSW_SP_NEXTHOP_ACTION_FORWARD ; }unsigned char *mlxsw_sp_nexthop_ha (struct mlxsw_sp_nexthop *nh)
@@ -3408,7 +3415,7 @@ static int __mlxsw_sp_nexthop_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index,mlxsw_reg_ratr_pack (ratr_pl,MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY , true,MLXSW_REG_RATR_TYPE_ETHERNET , adj_index, nh->rif->rif_index); -if (nh->discard) +if (nh->action ==MLXSW_SP_NEXTHOP_ACTION_DISCARD )mlxsw_reg_ratr_trap_action_set (ratr_pl,MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS );else
@@ -3828,10 +3835,12 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,static void __mlxsw_sp_nexthop_neigh_update (struct mlxsw_sp_nexthop *nh,bool removing) { -if (!removing) +if (!removing) { + nh->action =MLXSW_SP_NEXTHOP_ACTION_FORWARD ; nh->should_offload =1 ; -else + }else { nh->should_offload =0 ; + } nh->update =1 ; }
@@ -4342,7 +4351,7 @@ static void mlxsw_sp_nexthop_obj_blackhole_init(struct mlxsw_sp *mlxsw_sp, {u16 lb_rif_index = mlxsw_sp->router->lb_rif_index; - nh->discard =1 ; + nh->action =MLXSW_SP_NEXTHOP_ACTION_DISCARD ; nh->should_offload =1 ;/* While nexthops that discard packets do not forward packets * via an egress RIF, they still need to be programmed using a
@@ -4405,7 +4414,7 @@ mlxsw_sp_nexthop_obj_init(struct mlxsw_sp *mlxsw_sp,static void mlxsw_sp_nexthop_obj_fini (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_nexthop *nh) { -if (nh->discard) +if (nh->action ==MLXSW_SP_NEXTHOP_ACTION_DISCARD )mlxsw_sp_nexthop_obj_blackhole_fini (mlxsw_sp, nh);mlxsw_sp_nexthop_type_fini (mlxsw_sp, nh);list_del (&nh->router_list_node);
Signature · 1 line
2.29.2
PATCH 6/14 mlxsw: spectrum_router: Prepare for nexthops with trap action
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Nexthops that need to be programmed with a trap action might not have a valid router interface (RIF) associated with them. Therefore, use the loopback RIF created during initialization to program them to the device.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +4 -1
@@ -3411,10 +3411,13 @@ static int __mlxsw_sp_nexthop_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index, {struct mlxsw_sp_neigh_entry *neigh_entry = nh->neigh_entry;char ratr_pl[MLXSW_REG_RATR_LEN ]; +u16 rif_index; + rif_index = nh->rif ? nh->rif->rif_index : + mlxsw_sp->router->lb_rif_index;mlxsw_reg_ratr_pack (ratr_pl,MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY , true,MLXSW_REG_RATR_TYPE_ETHERNET , - adj_index, nh->rif->rif_index); + adj_index, rif_index);if (nh->action ==MLXSW_SP_NEXTHOP_ACTION_DISCARD )mlxsw_reg_ratr_trap_action_set (ratr_pl,MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS );
Signature · 1 line
2.29.2
PATCH 7/14 mlxsw: spectrum_router: Add nexthop trap action support
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Currently, nexthops are programmed with either forward or discard action (for blackhole nexthops). Nexthops that do not have a valid MAC address (neighbour) or router interface (RIF) are simply not written to the adjacency table.
In resilient nexthop groups, the size of the group must remain fixed and the kernel is in complete control of the layout of the adjacency table. A nexthop without a valid MAC or RIF will therefore be written with a trap action, to trigger neighbour resolution.
Allow such nexthops to be programmed to the adjacency table to enable above mentioned use case.
--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +29 -13
@@ -2847,6 +2847,8 @@ enum mlxsw_sp_nexthop_action {MLXSW_SP_NEXTHOP_ACTION_FORWARD ,/* Nexthop discards packets */ MLXSW_SP_NEXTHOP_ACTION_DISCARD , +/* Nexthop traps packets */ + MLXSW_SP_NEXTHOP_ACTION_TRAP, }; struct mlxsw_sp_nexthop_key {
@@ -3418,11 +3420,23 @@ static int __mlxsw_sp_nexthop_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index,mlxsw_reg_ratr_pack (ratr_pl,MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY , true,MLXSW_REG_RATR_TYPE_ETHERNET , adj_index, rif_index); -if (nh->action ==MLXSW_SP_NEXTHOP_ACTION_DISCARD ) +switch (nh->action) { +case MLXSW_SP_NEXTHOP_ACTION_FORWARD : +mlxsw_reg_ratr_eth_entry_pack (ratr_pl, neigh_entry->ha); +break ; +case MLXSW_SP_NEXTHOP_ACTION_DISCARD :mlxsw_reg_ratr_trap_action_set (ratr_pl,MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS ); -else -mlxsw_reg_ratr_eth_entry_pack (ratr_pl, neigh_entry->ha); +break ; +case MLXSW_SP_NEXTHOP_ACTION_TRAP : +mlxsw_reg_ratr_trap_action_set (ratr_pl, +MLXSW_REG_RATR_TRAP_ACTION_TRAP ); +mlxsw_reg_ratr_trap_id_set (ratr_pl,MLXSW_TRAP_ID_RTR_EGRESS0 ); +break ; +default : +WARN_ON_ONCE (1 ); +return -EINVAL ; + }if (nh->counter_valid)mlxsw_reg_ratr_counter_pack (ratr_pl, nh->counter_index, true);else
@@ -3495,16 +3509,18 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp,if (nh->update || reallocate) {int err =0 ; -switch (nh->type) { -case MLXSW_SP_NEXTHOP_TYPE_ETH : - err =mlxsw_sp_nexthop_update - (mlxsw_sp, adj_index, nh); -break ; -case MLXSW_SP_NEXTHOP_TYPE_IPIP : - err =mlxsw_sp_nexthop_ipip_update - (mlxsw_sp, adj_index, nh); -break ; - } +/* When action is discard or trap, the nexthop must be +* programmed as an Ethernet nexthop. +*/ +if (nh->type ==MLXSW_SP_NEXTHOP_TYPE_ETH || + nh->action ==MLXSW_SP_NEXTHOP_ACTION_DISCARD || + nh->action ==MLXSW_SP_NEXTHOP_ACTION_TRAP ) + err =mlxsw_sp_nexthop_update (mlxsw_sp, + adj_index, nh); +else + err =mlxsw_sp_nexthop_ipip_update (mlxsw_sp, + adj_index, + nh);if (err)return err; nh->update =0 ;
Signature · 1 line
2.29.2
PATCH 8/14 mlxsw: spectrum_router: Rename nexthop update function to reflect its type
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
mlxsw_sp_nexthop_update() is used to update the configuration of Ethernet-type nexthops, as opposed to mlxsw_sp_nexthop_ipip_update(), which is used to update IPinIP-type nexthops.
Rename the function to mlxsw_sp_nexthop_eth_update(), so that it is consistent with mlxsw_sp_nexthop_ipip_update().
It will allow us to introduce mlxsw_sp_nexthop_update() in a follow-up patch, which calls either of above mentioned function based on the nexthop's type.
--- .../ethernet/mellanox/mlxsw/spectrum_dpipe.c | 4 ++-- .../ethernet/mellanox/mlxsw/spectrum_router.c | 17 ++++++++++------- .../ethernet/mellanox/mlxsw/spectrum_router.h | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c +2 -2
@@ -1195,8 +1195,8 @@ static int mlxsw_sp_dpipe_table_adj_counters_update(void *priv, bool enable)mlxsw_sp_nexthop_counter_alloc (mlxsw_sp, nh); elsemlxsw_sp_nexthop_counter_free (mlxsw_sp ,nh ); -mlxsw_sp_nexthop_update (mlxsw_sp, - adj_index + adj_hash_index, nh); +mlxsw_sp_nexthop_eth_update (mlxsw_sp, + adj_index + adj_hash_index, nh); }return 0 ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +10 -7
@@ -3408,8 +3408,9 @@ static int mlxsw_sp_adj_index_mass_update(struct mlxsw_sp *mlxsw_sp,return err; } -static int __mlxsw_sp_nexthop_update (struct mlxsw_sp *mlxsw_sp,u32 adj_index, -struct mlxsw_sp_nexthop *nh) +static int __mlxsw_sp_nexthop_eth_update (struct mlxsw_sp *mlxsw_sp, +u32 adj_index, +struct mlxsw_sp_nexthop *nh) {struct mlxsw_sp_neigh_entry *neigh_entry = nh->neigh_entry;char ratr_pl[MLXSW_REG_RATR_LEN ];
@@ -3445,15 +3446,16 @@ static int __mlxsw_sp_nexthop_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index,return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (ratr), ratr_pl); } -int mlxsw_sp_nexthop_update (struct mlxsw_sp *mlxsw_sp,u32 adj_index, -struct mlxsw_sp_nexthop *nh) +int mlxsw_sp_nexthop_eth_update (struct mlxsw_sp *mlxsw_sp,u32 adj_index, +struct mlxsw_sp_nexthop *nh) {int i;for (i =0 ; i < nh->num_adj_entries; i++) {int err; - err =__mlxsw_sp_nexthop_update (mlxsw_sp, adj_index + i, nh); + err =__mlxsw_sp_nexthop_eth_update (mlxsw_sp, adj_index + i, + nh);if (err)return err; }
@@ -3515,8 +3517,9 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp,if (nh->type ==MLXSW_SP_NEXTHOP_TYPE_ETH || nh->action ==MLXSW_SP_NEXTHOP_ACTION_DISCARD || nh->action ==MLXSW_SP_NEXTHOP_ACTION_TRAP ) - err =mlxsw_sp_nexthop_update (mlxsw_sp, - adj_index, nh); + err =mlxsw_sp_nexthop_eth_update (mlxsw_sp, + adj_index, + nh);else err = mlxsw_sp_nexthop_ipip_update(mlxsw_sp, adj_index,
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +2 -2
@@ -206,8 +206,8 @@ bool mlxsw_sp_nexthop_group_has_ipip(struct mlxsw_sp_nexthop *nh); nh = mlxsw_sp_nexthop_next(router, nh))int mlxsw_sp_nexthop_counter_get (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_nexthop *nh,u64 *p_counter); -int mlxsw_sp_nexthop_update (struct mlxsw_sp *mlxsw_sp,u32 adj_index, -struct mlxsw_sp_nexthop *nh); +int mlxsw_sp_nexthop_eth_update (struct mlxsw_sp *mlxsw_sp,u32 adj_index, +struct mlxsw_sp_nexthop *nh);void mlxsw_sp_nexthop_counter_alloc (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_nexthop *nh); void mlxsw_sp_nexthop_counter_free(struct mlxsw_sp *mlxsw_sp,
Signature · 1 line
2.29.2
PATCH 9/14 mlxsw: spectrum_router: Encapsulate nexthop update in a function
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Encapsulate this functionality in a separate function, so that it could be invoked by follow-up patches, when replacing a nexthop bucket that is part of a resilient nexthop group.
--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +15 -13
@@ -3491,6 +3491,20 @@ static int mlxsw_sp_nexthop_ipip_update(struct mlxsw_sp *mlxsw_sp,return 0 ; } +static int mlxsw_sp_nexthop_update (struct mlxsw_sp *mlxsw_sp,u32 adj_index, +struct mlxsw_sp_nexthop *nh) +{ +/* When action is discard or trap, the nexthop must be +* programmed as an Ethernet nexthop. +*/ +if (nh->type ==MLXSW_SP_NEXTHOP_TYPE_ETH || + nh->action ==MLXSW_SP_NEXTHOP_ACTION_DISCARD || + nh->action ==MLXSW_SP_NEXTHOP_ACTION_TRAP ) +return mlxsw_sp_nexthop_eth_update (mlxsw_sp, adj_index, nh); +else +return mlxsw_sp_nexthop_ipip_update (mlxsw_sp, adj_index, nh); +} + static int mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop_group_info *nhgi,
@@ -3511,19 +3525,7 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp,if (nh->update || reallocate) {int err =0 ; -/* When action is discard or trap, the nexthop must be -* programmed as an Ethernet nexthop. -*/ -if (nh->type ==MLXSW_SP_NEXTHOP_TYPE_ETH || - nh->action ==MLXSW_SP_NEXTHOP_ACTION_DISCARD || - nh->action ==MLXSW_SP_NEXTHOP_ACTION_TRAP ) - err =mlxsw_sp_nexthop_eth_update (mlxsw_sp, - adj_index, - nh); -else - err =mlxsw_sp_nexthop_ipip_update (mlxsw_sp, - adj_index, - nh); + err =mlxsw_sp_nexthop_update (mlxsw_sp, adj_index, nh);if (err)return err; nh->update =0 ;
Signature · 1 line
2.29.2
PATCH 10/14 mlxsw: spectrum_router: Break nexthop group entry validation to a separate function
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
The validation of a nexthop group entry is also necessary for resilient nexthop groups, so break the validation to a separate function to allow for code reuse in subsequent patches.
--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +25 -11
@@ -4296,6 +4296,29 @@ mlxsw_sp_nexthop_obj_single_validate(struct mlxsw_sp *mlxsw_sp,return err; } +static int +mlxsw_sp_nexthop_obj_group_entry_validate (struct mlxsw_sp *mlxsw_sp, +const struct nh_notifier_single_info *nh, +struct netlink_ext_ack *extack) +{ +int err; + + err =mlxsw_sp_nexthop_obj_single_validate (mlxsw_sp, nh, extack); +if (err) +return err; + +/* Device only nexthops with an IPIP device are programmed as +* encapsulating adjacency entries. +*/ +if (!nh->gw_family && !nh->is_reject && + !mlxsw_sp_netdev_ipip_type (mlxsw_sp, nh->dev,NULL )) { +NL_SET_ERR_MSG_MOD (extack,"Nexthop group entry does not have a gateway" ); +return -EINVAL ; + } + +return 0 ; +} + static int mlxsw_sp_nexthop_obj_group_validate(struct mlxsw_sp *mlxsw_sp, const struct nh_notifier_grp_info *nh_grp,
@@ -4313,19 +4336,10 @@ mlxsw_sp_nexthop_obj_group_validate(struct mlxsw_sp *mlxsw_sp,int err; nh = &nh_grp->nh_entries[i].nh; - err =mlxsw_sp_nexthop_obj_single_validate (mlxsw_sp, nh, - extack); + err =mlxsw_sp_nexthop_obj_group_entry_validate (mlxsw_sp, nh, + extack);if (err)return err; - -/* Device only nexthops with an IPIP device are programmed as -* encapsulating adjacency entries. -*/ -if (!nh->gw_family && !nh->is_reject && - !mlxsw_sp_netdev_ipip_type (mlxsw_sp, nh->dev,NULL )) { -NL_SET_ERR_MSG_MOD (extack,"Nexthop group entry does not have a gateway" ); -return -EINVAL ; - } }return 0 ;
Signature · 1 line
2.29.2
PATCH 11/14 mlxsw: spectrum_router: Avoid unnecessary neighbour updates
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Avoid updating neighbour and adjacency entries in hardware when the neighbour is already connected and its MAC address did not change. This can happen, for example, when neighbour transitions between valid states such as 'NUD_REACHABLE' and 'NUD_DELAY'.
This is especially important for resilient hashing as these updates will result in adjacency entries being marked as active.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +4 -0
@@ -2662,6 +2662,10 @@ static void mlxsw_sp_router_neigh_event_work(struct work_struct *work) goto out; } +if (neigh_entry->connected && entry_connected && + !memcmp (neigh_entry->ha, ha,ETH_ALEN )) + goto out; +memcpy (neigh_entry->ha, ha,ETH_ALEN );mlxsw_sp_neigh_entry_update (mlxsw_sp, neigh_entry, entry_connected); mlxsw_sp_nexthop_neigh_update(mlxsw_sp, neigh_entry, !entry_connected,
Signature · 1 line
2.29.2
PATCH 12/14 mlxsw: spectrum_router: Create per-ASIC router operations
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
There are several differences in the router module between Spectrum-1 and Spectrum-{2,3}. Currently, this is only apparent in the router interface (RIF) operations that are split between these ASICs.
A subsequent patch is going to introduce another difference between these ASICs.
Create per-ASIC router operations that will encapsulate all these differences. For now, these operations are only used to set the per-ASIC RIF operations in 'mlxsw_sp->router->rif_ops_arr'. Note that this fields was unused since commit 1f5b23033937 ("mlxsw: spectrum: Set RIF ops per ASIC type").
--- .../net/ethernet/mellanox/mlxsw/spectrum.c | 6 +-- .../net/ethernet/mellanox/mlxsw/spectrum.h | 8 ++-- .../ethernet/mellanox/mlxsw/spectrum_router.c | 37 +++++++++++++++++-- 3 files changed, 41 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +3 -3
@@ -2934,7 +2934,6 @@ static int mlxsw_sp1_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->acl_tcam_ops = &mlxsw_sp1_acl_tcam_ops; mlxsw_sp->nve_ops_arr = mlxsw_sp1_nve_ops_arr; mlxsw_sp->mac_mask = mlxsw_sp1_mac_mask; - mlxsw_sp->rif_ops_arr = mlxsw_sp1_rif_ops_arr; mlxsw_sp->sb_vals = &mlxsw_sp1_sb_vals; mlxsw_sp->sb_ops = &mlxsw_sp1_sb_ops; mlxsw_sp->port_type_speed_ops = &mlxsw_sp1_port_type_speed_ops;
@@ -2943,6 +2942,7 @@ static int mlxsw_sp1_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->policer_core_ops = &mlxsw_sp1_policer_core_ops; mlxsw_sp->trap_ops = &mlxsw_sp1_trap_ops; mlxsw_sp->mall_ops = &mlxsw_sp1_mall_ops; + mlxsw_sp->router_ops = &mlxsw_sp1_router_ops; mlxsw_sp->listeners = mlxsw_sp1_listener; mlxsw_sp->listeners_count =ARRAY_SIZE (mlxsw_sp1_listener); mlxsw_sp->lowest_shaper_bs =MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 ;
@@ -2965,7 +2965,6 @@ static int mlxsw_sp2_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; - mlxsw_sp->rif_ops_arr = mlxsw_sp2_rif_ops_arr; mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; mlxsw_sp->sb_ops = &mlxsw_sp2_sb_ops; mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops;
@@ -2974,6 +2973,7 @@ static int mlxsw_sp2_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; + mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; mlxsw_sp->lowest_shaper_bs =MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 ;return mlxsw_sp_init (mlxsw_core, mlxsw_bus_info, extack);
@@ -2994,7 +2994,6 @@ static int mlxsw_sp3_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; - mlxsw_sp->rif_ops_arr = mlxsw_sp2_rif_ops_arr; mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops;
@@ -3003,6 +3002,7 @@ static int mlxsw_sp3_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; + mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; mlxsw_sp->lowest_shaper_bs =MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 ;return mlxsw_sp_init (mlxsw_core, mlxsw_bus_info, extack);
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +4 -4
@@ -87,10 +87,10 @@ enum mlxsw_sp_rif_type { MLXSW_SP_RIF_TYPE_MAX, }; -struct mlxsw_sp_rif_ops ; +struct mlxsw_sp_router_ops ; -extern const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[]; -extern const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[]; +extern const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops; +extern const struct mlxsw_sp_router_ops mlxsw_sp2_router_ops;struct mlxsw_sp_switchdev_ops ;
@@ -180,7 +180,6 @@ struct mlxsw_sp {const struct mlxsw_sp_acl_rulei_ops *acl_rulei_ops;const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops;const struct mlxsw_sp_nve_ops **nve_ops_arr; -const struct mlxsw_sp_rif_ops **rif_ops_arr;const struct mlxsw_sp_sb_vals *sb_vals;const struct mlxsw_sp_sb_ops *sb_ops;const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
@@ -189,6 +188,7 @@ struct mlxsw_sp {const struct mlxsw_sp_policer_core_ops *policer_core_ops;const struct mlxsw_sp_trap_ops *trap_ops;const struct mlxsw_sp_mall_ops *mall_ops; +const struct mlxsw_sp_router_ops *router_ops;const struct mlxsw_listener *listeners;size_t listeners_count;u32 lowest_shaper_bs;
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +34 -3
@@ -113,6 +113,10 @@ struct mlxsw_sp_rif_ops {void (*fdb_del)(struct mlxsw_sp_rif *rif,const char *mac); }; +struct mlxsw_sp_router_ops { +int (*init)(struct mlxsw_sp *mlxsw_sp); +}; +static struct mlxsw_sp_rif *mlxsw_sp_rif_find_by_dev (const struct mlxsw_sp *mlxsw_sp,const struct net_device *dev);
@@ -7712,7 +7716,7 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp,int i, err; type =mlxsw_sp_dev_rif_type (mlxsw_sp, params->dev); - ops = mlxsw_sp->rif_ops_arr[type]; + ops = mlxsw_sp->router->rif_ops_arr[type]; vr =mlxsw_sp_vr_get (mlxsw_sp, tb_id ? :RT_TABLE_MAIN , extack);if (IS_ERR (vr))
@@ -8910,7 +8914,7 @@ static const struct mlxsw_sp_rif_ops mlxsw_sp1_rif_ipip_lb_ops = { .deconfigure = mlxsw_sp1_rif_ipip_lb_deconfigure, }; -const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[] = { +static const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[] = { [MLXSW_SP_RIF_TYPE_SUBPORT ] = &mlxsw_sp_rif_subport_ops, [MLXSW_SP_RIF_TYPE_VLAN ] = &mlxsw_sp_rif_vlan_emu_ops, [MLXSW_SP_RIF_TYPE_FID ] = &mlxsw_sp_rif_fid_ops,
@@ -9095,7 +9099,7 @@ static const struct mlxsw_sp_rif_ops mlxsw_sp2_rif_ipip_lb_ops = { .deconfigure = mlxsw_sp2_rif_ipip_lb_deconfigure, }; -const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[] = { +static const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[] = { [MLXSW_SP_RIF_TYPE_SUBPORT ] = &mlxsw_sp_rif_subport_ops, [MLXSW_SP_RIF_TYPE_VLAN ] = &mlxsw_sp_rif_vlan_emu_ops, [MLXSW_SP_RIF_TYPE_FID ] = &mlxsw_sp_rif_fid_ops,
@@ -9347,6 +9351,28 @@ static void mlxsw_sp_lb_rif_fini(struct mlxsw_sp *mlxsw_sp)mlxsw_sp_router_ul_rif_put (mlxsw_sp, mlxsw_sp->router->lb_rif_index); } +static int mlxsw_sp1_router_init (struct mlxsw_sp *mlxsw_sp) +{ + mlxsw_sp->router->rif_ops_arr = mlxsw_sp1_rif_ops_arr; + +return 0 ; +} + +const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops = { + .init = mlxsw_sp1_router_init, +}; + +static int mlxsw_sp2_router_init (struct mlxsw_sp *mlxsw_sp) +{ + mlxsw_sp->router->rif_ops_arr = mlxsw_sp2_rif_ops_arr; + +return 0 ; +} + +const struct mlxsw_sp_router_ops mlxsw_sp2_router_ops = { + .init = mlxsw_sp2_router_init, +}; +int mlxsw_sp_router_init (struct mlxsw_sp *mlxsw_sp,struct netlink_ext_ack *extack) {
@@ -9360,6 +9386,10 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp, mlxsw_sp->router = router; router->mlxsw_sp = mlxsw_sp; + err = mlxsw_sp->router_ops->init (mlxsw_sp); +if (err) + goto err_router_ops_init; + err =mlxsw_sp_router_xm_init (mlxsw_sp);if (err) goto err_xm_init;
@@ -9500,6 +9530,7 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp, err_ll_op_ctx_init:mlxsw_sp_router_xm_fini (mlxsw_sp); err_xm_init: +err_router_ops_init:mutex_destroy (&mlxsw_sp->router->lock);kfree (mlxsw_sp->router);return err;
Signature · 1 line
2.29.2
PATCH 13/14 mlxsw: spectrum_router: Encode adjacency group size ranges in an array
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
The device supports a fixed set of adjacency group sizes. Encode these sizes in an array, so that the next patch will be able to split it between Spectrum-1 and Spectrum-{2,3}, which support different size ranges.
--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 65 +++++++++++++------ 1 file changed, 44 insertions(+), 21 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +44 -21
@@ -3559,34 +3559,57 @@ mlxsw_sp_nexthop_fib_entries_update(struct mlxsw_sp *mlxsw_sp,return 0 ; } +struct mlxsw_sp_adj_grp_size_range { +u16 start;/* Inclusive */ +u16 end;/* Inclusive */ +}; + +/* Ordered by range start value */ +static const struct mlxsw_sp_adj_grp_size_range +mlxsw_sp_adj_grp_size_ranges[] = { + { .start =1 , .end =64 }, + { .start =512 , .end =512 }, + { .start =1024 , .end =1024 }, + { .start =2048 , .end =2048 }, + { .start =4096 , .end =4096 }, +}; +static void mlxsw_sp_adj_grp_size_round_up (u16 *p_adj_grp_size) { -/* Valid sizes for an adjacency group are: -* 1-64, 512, 1024, 2048 and 4096. -*/ -if (*p_adj_grp_size <=64 ) -return ; -else if (*p_adj_grp_size <=512 ) - *p_adj_grp_size =512 ; -else if (*p_adj_grp_size <=1024 ) - *p_adj_grp_size =1024 ; -else if (*p_adj_grp_size <=2048 ) - *p_adj_grp_size =2048 ; -else - *p_adj_grp_size =4096 ; +int i; + +for (i =0 ; i <ARRAY_SIZE (mlxsw_sp_adj_grp_size_ranges); i++) { +const struct mlxsw_sp_adj_grp_size_range *size_range; + + size_range = &mlxsw_sp_adj_grp_size_ranges[i]; + +if (*p_adj_grp_size >= size_range->start && + *p_adj_grp_size <= size_range->end) +return ; + +if (*p_adj_grp_size <= size_range->end) { + *p_adj_grp_size = size_range->end; +return ; + } + } }static void mlxsw_sp_adj_grp_size_round_down (u16 *p_adj_grp_size,unsigned int alloc_size) { -if (alloc_size >=4096 ) - *p_adj_grp_size =4096 ; -else if (alloc_size >=2048 ) - *p_adj_grp_size =2048 ; -else if (alloc_size >=1024 ) - *p_adj_grp_size =1024 ; -else if (alloc_size >=512 ) - *p_adj_grp_size =512 ; +size_t arr_size =ARRAY_SIZE (mlxsw_sp_adj_grp_size_ranges); +int i; + +for (i = arr_size -1 ; i >=0 ; i--) { +const struct mlxsw_sp_adj_grp_size_range *size_range; + + size_range = &mlxsw_sp_adj_grp_size_ranges[i]; + +if (alloc_size >= size_range->end) { + *p_adj_grp_size = size_range->end; +return ; + } + } } static int mlxsw_sp_fix_adj_grp_size(struct mlxsw_sp *mlxsw_sp,
Signature · 1 line
2.29.2
PATCH 14/14 mlxsw: spectrum_router: Add Spectrum-{2, 3} adjacency group size ranges
In reply to Ido SchimmelFrom: Ido Schimmel <[email protected]>
Spectrum-{2,3} support different adjacency group size ranges compared to Spectrum-1. Add an array describing these ranges and change the common code to use the array which was set during the per-ASIC initialization.
--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 40 ++++++++++++++----- .../ethernet/mellanox/mlxsw/spectrum_router.h | 2 + 2 files changed, 32 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +30 -10
@@ -3566,7 +3566,7 @@ struct mlxsw_sp_adj_grp_size_range {/* Ordered by range start value */ static const struct mlxsw_sp_adj_grp_size_range -mlxsw_sp_adj_grp_size_ranges[] = { +mlxsw_sp1_adj_grp_size_ranges[] = { { .start =1 , .end =64 }, { .start =512 , .end =512 }, { .start =1024 , .end =1024 },
@@ -3574,14 +3574,26 @@ mlxsw_sp_adj_grp_size_ranges[] = { { .start = 4096, .end = 4096 }, }; -static void mlxsw_sp_adj_grp_size_round_up (u16 *p_adj_grp_size) +/* Ordered by range start value */ +static const struct mlxsw_sp_adj_grp_size_range +mlxsw_sp2_adj_grp_size_ranges[] = { + { .start =1 , .end =128 }, + { .start =256 , .end =256 }, + { .start =512 , .end =512 }, + { .start =1024 , .end =1024 }, + { .start =2048 , .end =2048 }, + { .start =4096 , .end =4096 }, +}; + +static void mlxsw_sp_adj_grp_size_round_up (const struct mlxsw_sp *mlxsw_sp, +u16 *p_adj_grp_size) {int i; -for (i =0 ; i <ARRAY_SIZE (mlxsw_sp_adj_grp_size_ranges); i++) { +for (i =0 ; i < mlxsw_sp->router->adj_grp_size_ranges_count; i++) {const struct mlxsw_sp_adj_grp_size_range *size_range; - size_range = &mlxsw_sp_adj_grp_size_ranges[i]; + size_range = &mlxsw_sp->router->adj_grp_size_ranges[i];if (*p_adj_grp_size >= size_range->start && *p_adj_grp_size <= size_range->end)
@@ -3594,16 +3606,16 @@ static void mlxsw_sp_adj_grp_size_round_up(u16 *p_adj_grp_size) } } -static void mlxsw_sp_adj_grp_size_round_down (u16 *p_adj_grp_size, +static void mlxsw_sp_adj_grp_size_round_down (const struct mlxsw_sp *mlxsw_sp, +u16 *p_adj_grp_size,unsigned int alloc_size) { -size_t arr_size =ARRAY_SIZE (mlxsw_sp_adj_grp_size_ranges);int i; -for (i = arr_size -1 ; i >=0 ; i--) { +for (i = mlxsw_sp->router->adj_grp_size_ranges_count -1 ; i >=0 ; i--) {const struct mlxsw_sp_adj_grp_size_range *size_range; - size_range = &mlxsw_sp_adj_grp_size_ranges[i]; + size_range = &mlxsw_sp->router->adj_grp_size_ranges[i];if (alloc_size >= size_range->end) { *p_adj_grp_size = size_range->end;
@@ -3621,7 +3633,7 @@ static int mlxsw_sp_fix_adj_grp_size(struct mlxsw_sp *mlxsw_sp,/* Round up the requested group size to the next size supported * by the device and make sure the request can be satisfied. */ -mlxsw_sp_adj_grp_size_round_up (p_adj_grp_size); +mlxsw_sp_adj_grp_size_round_up (mlxsw_sp, p_adj_grp_size); err =mlxsw_sp_kvdl_alloc_count_query (mlxsw_sp,MLXSW_SP_KVDL_ENTRY_TYPE_ADJ , *p_adj_grp_size, &alloc_size);
@@ -3631,7 +3643,7 @@ static int mlxsw_sp_fix_adj_grp_size(struct mlxsw_sp *mlxsw_sp,* entries than requested. Try to use as much of them as * possible. */ -mlxsw_sp_adj_grp_size_round_down (p_adj_grp_size, alloc_size); +mlxsw_sp_adj_grp_size_round_down (mlxsw_sp, p_adj_grp_size, alloc_size);return 0 ; }
@@ -9376,7 +9388,11 @@ static void mlxsw_sp_lb_rif_fini(struct mlxsw_sp *mlxsw_sp)static int mlxsw_sp1_router_init (struct mlxsw_sp *mlxsw_sp) { +size_t size_ranges_count =ARRAY_SIZE (mlxsw_sp1_adj_grp_size_ranges); + mlxsw_sp->router->rif_ops_arr = mlxsw_sp1_rif_ops_arr; + mlxsw_sp->router->adj_grp_size_ranges = mlxsw_sp1_adj_grp_size_ranges; + mlxsw_sp->router->adj_grp_size_ranges_count = size_ranges_count;return 0 ; }
@@ -9387,7 +9403,11 @@ const struct mlxsw_sp_router_ops mlxsw_sp1_router_ops = {static int mlxsw_sp2_router_init (struct mlxsw_sp *mlxsw_sp) { +size_t size_ranges_count =ARRAY_SIZE (mlxsw_sp2_adj_grp_size_ranges); + mlxsw_sp->router->rif_ops_arr = mlxsw_sp2_rif_ops_arr; + mlxsw_sp->router->adj_grp_size_ranges = mlxsw_sp2_adj_grp_size_ranges; + mlxsw_sp->router->adj_grp_size_ranges_count = size_ranges_count;return 0 ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +2 -0
@@ -78,6 +78,8 @@ struct mlxsw_sp_router {struct mlxsw_sp_fib_entry_op_ctx *ll_op_ctx;u16 lb_rif_index;struct mlxsw_sp_router_xm *xm; +const struct mlxsw_sp_adj_grp_size_range *adj_grp_size_ranges; +size_t adj_grp_size_ranges_count; };struct mlxsw_sp_fib_entry_priv {
Signature · 1 line
2.29.2
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Mon, 22 Mar 2021 17:58:41 +0200 you wrote:
From: Ido Schimmel <[email protected]>
This patchset contains preparations for resilient nexthop groups support in mlxsw. A follow-up patchset will add support and selftests. Most of the patches are trivial and small to make review easier.
Patchset overview:
[...]
Here is the summary with links:
- [net-next,01/14] mlxsw: spectrum_router: Remove RTNL assertion
https://git.kernel.org/netdev/net-next/c/08c99b92d76c - [net-next,02/14] mlxsw: spectrum_router: Consolidate nexthop helpers https://git.kernel.org/netdev/net-next/c/26df5acc275b - [net-next,03/14] mlxsw: spectrum_router: Only provide MAC address for valid nexthops https://git.kernel.org/netdev/net-next/c/c6a5011bec09 - [net-next,04/14] mlxsw: spectrum_router: Adjust comments on nexthop fields https://git.kernel.org/netdev/net-next/c/248136fa251a - [net-next,05/14] mlxsw: spectrum_router: Introduce nexthop action field https://git.kernel.org/netdev/net-next/c/031d5c160656 - [net-next,06/14] mlxsw: spectrum_router: Prepare for nexthops with trap action https://git.kernel.org/netdev/net-next/c/1be2361e3ca7 - [net-next,07/14] mlxsw: spectrum_router: Add nexthop trap action support https://git.kernel.org/netdev/net-next/c/fc199d7c08c8 - [net-next,08/14] mlxsw: spectrum_router: Rename nexthop update function to reflect its type https://git.kernel.org/netdev/net-next/c/424603ccdd5e - [net-next,09/14] mlxsw: spectrum_router: Encapsulate nexthop update in a function https://git.kernel.org/netdev/net-next/c/29017c643476 - [net-next,10/14] mlxsw: spectrum_router: Break nexthop group entry validation to a separate function https://git.kernel.org/netdev/net-next/c/40f5429fce69 - [net-next,11/14] mlxsw: spectrum_router: Avoid unnecessary neighbour updates https://git.kernel.org/netdev/net-next/c/c1efd50002c0 - [net-next,12/14] mlxsw: spectrum_router: Create per-ASIC router operations https://git.kernel.org/netdev/net-next/c/d354fdd923e7 - [net-next,13/14] mlxsw: spectrum_router: Encode adjacency group size ranges in an array https://git.kernel.org/netdev/net-next/c/164fa130dd16 - [net-next,14/14] mlxsw: spectrum_router: Add Spectrum-{2, 3} adjacency group size ranges https://git.kernel.org/netdev/net-next/c/ea037b236a05
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html