mirror of https://gitee.com/openkylin/linux.git
mlxsw: spectrum: Allow different traps to have different actions
Up until now we only trapped packets to CPU, but we are going to allow some packets to be mirrored (trap & forward) to CPU. Extend the Rx listener with 'action' member. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
93393b339d
commit
63a811417d
|
@ -87,6 +87,7 @@ struct mlxsw_rx_listener {
|
||||||
void (*func)(struct sk_buff *skb, u8 local_port, void *priv);
|
void (*func)(struct sk_buff *skb, u8 local_port, void *priv);
|
||||||
u8 local_port;
|
u8 local_port;
|
||||||
u16 trap_id;
|
u16 trap_id;
|
||||||
|
enum mlxsw_reg_hpkt_action action;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mlxsw_event_listener {
|
struct mlxsw_event_listener {
|
||||||
|
|
|
@ -2570,39 +2570,40 @@ static void mlxsw_sp_rx_listener_func(struct sk_buff *skb, u8 local_port,
|
||||||
netif_receive_skb(skb);
|
netif_receive_skb(skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MLXSW_SP_RXL(_func, _trap_id) \
|
#define MLXSW_SP_RXL(_func, _trap_id, _action) \
|
||||||
{ \
|
{ \
|
||||||
.func = _func, \
|
.func = _func, \
|
||||||
.local_port = MLXSW_PORT_DONT_CARE, \
|
.local_port = MLXSW_PORT_DONT_CARE, \
|
||||||
.trap_id = MLXSW_TRAP_ID_##_trap_id, \
|
.trap_id = MLXSW_TRAP_ID_##_trap_id, \
|
||||||
|
.action = MLXSW_REG_HPKT_ACTION_##_action, \
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct mlxsw_rx_listener mlxsw_sp_rx_listener[] = {
|
static const struct mlxsw_rx_listener mlxsw_sp_rx_listener[] = {
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, FDB_MC),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, FDB_MC, TRAP_TO_CPU),
|
||||||
/* Traps for specific L2 packet types, not trapped as FDB MC */
|
/* Traps for specific L2 packet types, not trapped as FDB MC */
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, STP),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, STP, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LACP),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LACP, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, EAPOL),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, EAPOL, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LLDP),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LLDP, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MMRP),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MMRP, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MVRP),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MVRP, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, RPVST),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, RPVST, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, DHCP),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, DHCP, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_QUERY),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_QUERY, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V1_REPORT),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V1_REPORT, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V2_REPORT),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V2_REPORT, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V2_LEAVE),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V2_LEAVE, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V3_REPORT),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V3_REPORT, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, ARPBC),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, ARPBC, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, ARPUC),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, ARPUC, TRAP_TO_CPU),
|
||||||
/* L3 traps */
|
/* L3 traps */
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MTUERROR),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MTUERROR, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, TTLERROR),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, TTLERROR, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LBERROR),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LBERROR, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, OSPF),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, OSPF, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IP2ME),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IP2ME, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, RTR_INGRESS0),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, RTR_INGRESS0, TRAP_TO_CPU),
|
||||||
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, HOST_MISS_IPV4),
|
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, HOST_MISS_IPV4, TRAP_TO_CPU),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp)
|
static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp)
|
||||||
|
@ -2629,7 +2630,7 @@ static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp)
|
||||||
if (err)
|
if (err)
|
||||||
goto err_rx_listener_register;
|
goto err_rx_listener_register;
|
||||||
|
|
||||||
mlxsw_reg_hpkt_pack(hpkt_pl, MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
|
mlxsw_reg_hpkt_pack(hpkt_pl, mlxsw_sp_rx_listener[i].action,
|
||||||
mlxsw_sp_rx_listener[i].trap_id);
|
mlxsw_sp_rx_listener[i].trap_id);
|
||||||
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(hpkt), hpkt_pl);
|
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(hpkt), hpkt_pl);
|
||||||
if (err)
|
if (err)
|
||||||
|
|
Loading…
Reference in New Issue