net: dsa: reduce number of protocol hooks
DSA is currently registering one packet_type function per EtherType it needs to intercept in the receive path of a DSA-enabled Ethernet device. Right now we have three of them: trailer, DSA and eDSA, and there might be more in the future, this will not scale to the addition of new protocols. This patch proceeds with adding a new layer of abstraction and two new functions: dsa_switch_rcv() which will dispatch into the tag-protocol specific receive function implemented by net/dsa/tag_*.c dsa_slave_xmit() which will dispatch into the tag-protocol specific transmit function implemented by net/dsa/tag_*.c When we do create the per-port slave network devices, we iterate over the switch protocol to assign the DSA-specific receive and transmit operations. A new fake ethertype value is used: ETH_P_XDSA to illustrate the fact that this is no longer going to look like ETH_P_DSA or ETH_P_TRAILER like it used to be. This allows us to greatly simplify the check in eth_type_trans() and always override the skb->protocol with ETH_P_XDSA for Ethernet switches tagged protocol, while also reducing the number repetitive slave netdevice_ops assignments. Signed-off-by:Florian Fainelli <f.fainelli@gmail.com> Signed-off-by:
David S. Miller <davem@davemloft.net>
Showing
- include/linux/netdevice.h 12 additions, 16 deletionsinclude/linux/netdevice.h
- include/net/dsa.h 3 additions, 17 deletionsinclude/net/dsa.h
- include/uapi/linux/if_ether.h 1 addition, 0 deletionsinclude/uapi/linux/if_ether.h
- net/dsa/dsa.c 21 additions, 18 deletionsnet/dsa/dsa.c
- net/dsa/dsa_priv.h 3 additions, 6 deletionsnet/dsa/dsa_priv.h
- net/dsa/slave.c 14 additions, 31 deletionsnet/dsa/slave.c
- net/dsa/tag_dsa.c 4 additions, 4 deletionsnet/dsa/tag_dsa.c
- net/dsa/tag_edsa.c 4 additions, 4 deletionsnet/dsa/tag_edsa.c
- net/dsa/tag_trailer.c 4 additions, 4 deletionsnet/dsa/tag_trailer.c
- net/ethernet/eth.c 2 additions, 5 deletionsnet/ethernet/eth.c
Loading
Please register or sign in to comment