mlxsw: spectrum_router: Add nexthop trap action support

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.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ido Schimmel 2021-03-22 17:58:48 +02:00 committed by David S. Miller
parent 1be2361e3c
commit fc199d7c08

View file

@ -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;