Commit fc199d7c authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

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: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1be2361e
...@@ -2847,6 +2847,8 @@ enum mlxsw_sp_nexthop_action { ...@@ -2847,6 +2847,8 @@ enum mlxsw_sp_nexthop_action {
MLXSW_SP_NEXTHOP_ACTION_FORWARD, MLXSW_SP_NEXTHOP_ACTION_FORWARD,
/* Nexthop discards packets */ /* Nexthop discards packets */
MLXSW_SP_NEXTHOP_ACTION_DISCARD, MLXSW_SP_NEXTHOP_ACTION_DISCARD,
/* Nexthop traps packets */
MLXSW_SP_NEXTHOP_ACTION_TRAP,
}; };
struct mlxsw_sp_nexthop_key { struct mlxsw_sp_nexthop_key {
...@@ -3418,11 +3420,23 @@ static int __mlxsw_sp_nexthop_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index, ...@@ -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, mlxsw_reg_ratr_pack(ratr_pl, MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY,
true, MLXSW_REG_RATR_TYPE_ETHERNET, true, MLXSW_REG_RATR_TYPE_ETHERNET,
adj_index, rif_index); 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_set(ratr_pl,
MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS); MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS);
else break;
mlxsw_reg_ratr_eth_entry_pack(ratr_pl, neigh_entry->ha); 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) if (nh->counter_valid)
mlxsw_reg_ratr_counter_pack(ratr_pl, nh->counter_index, true); mlxsw_reg_ratr_counter_pack(ratr_pl, nh->counter_index, true);
else else
...@@ -3495,16 +3509,18 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp, ...@@ -3495,16 +3509,18 @@ mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp,
if (nh->update || reallocate) { if (nh->update || reallocate) {
int err = 0; int err = 0;
switch (nh->type) { /* When action is discard or trap, the nexthop must be
case MLXSW_SP_NEXTHOP_TYPE_ETH: * programmed as an Ethernet nexthop.
err = mlxsw_sp_nexthop_update */
(mlxsw_sp, adj_index, nh); if (nh->type == MLXSW_SP_NEXTHOP_TYPE_ETH ||
break; nh->action == MLXSW_SP_NEXTHOP_ACTION_DISCARD ||
case MLXSW_SP_NEXTHOP_TYPE_IPIP: nh->action == MLXSW_SP_NEXTHOP_ACTION_TRAP)
err = mlxsw_sp_nexthop_ipip_update err = mlxsw_sp_nexthop_update(mlxsw_sp,
(mlxsw_sp, adj_index, nh); adj_index, nh);
break; else
} err = mlxsw_sp_nexthop_ipip_update(mlxsw_sp,
adj_index,
nh);
if (err) if (err)
return err; return err;
nh->update = 0; nh->update = 0;
......
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