Skip to content

Commit

Permalink
mlxsw: spectrum: Simplify traps definition
Browse files Browse the repository at this point in the history
Instead of copying & pasting the same struct initialization for every
Rx listener, just use a macro.

Signed-off-by: Ido Schimmel <[email protected]>
Signed-off-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
idosch authored and davem330 committed Aug 26, 2016
1 parent 6bc506b commit 93393b3
Showing 1 changed file with 31 additions and 115 deletions.
146 changes: 31 additions & 115 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -2570,123 +2570,39 @@ static void mlxsw_sp_rx_listener_func(struct sk_buff *skb, u8 local_port,
netif_receive_skb(skb);
}

#define MLXSW_SP_RXL(_func, _trap_id) \
{ \
.func = _func, \
.local_port = MLXSW_PORT_DONT_CARE, \
.trap_id = MLXSW_TRAP_ID_##_trap_id, \
}

static const struct mlxsw_rx_listener mlxsw_sp_rx_listener[] = {
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_FDB_MC,
},
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, FDB_MC),
/* Traps for specific L2 packet types, not trapped as FDB MC */
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_STP,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_LACP,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_EAPOL,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_LLDP,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_MMRP,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_MVRP,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_RPVST,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_DHCP,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_IGMP_QUERY,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_IGMP_V1_REPORT,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_IGMP_V2_REPORT,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_IGMP_V2_LEAVE,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_IGMP_V3_REPORT,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_ARPBC,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_ARPUC,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_MTUERROR,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_TTLERROR,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_LBERROR,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_OSPF,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_IP2ME,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_RTR_INGRESS0,
},
{
.func = mlxsw_sp_rx_listener_func,
.local_port = MLXSW_PORT_DONT_CARE,
.trap_id = MLXSW_TRAP_ID_HOST_MISS_IPV4,
},
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, STP),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LACP),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, EAPOL),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LLDP),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MMRP),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MVRP),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, RPVST),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, DHCP),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_QUERY),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V1_REPORT),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V2_REPORT),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V2_LEAVE),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IGMP_V3_REPORT),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, ARPBC),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, ARPUC),
/* L3 traps */
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, MTUERROR),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, TTLERROR),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, LBERROR),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, OSPF),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, IP2ME),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, RTR_INGRESS0),
MLXSW_SP_RXL(mlxsw_sp_rx_listener_func, HOST_MISS_IPV4),
};

static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp)
Expand Down

0 comments on commit 93393b3

Please sign in to comment.