mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
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>
This commit is contained in:
parent
8663dc2002
commit
3e8a72d1da
10 changed files with 68 additions and 105 deletions
|
@ -181,11 +181,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
|
|||
* variants has been configured on the receiving interface,
|
||||
* and if so, set skb->protocol without looking at the packet.
|
||||
*/
|
||||
if (unlikely(netdev_uses_dsa_tags(dev)))
|
||||
return htons(ETH_P_DSA);
|
||||
|
||||
if (unlikely(netdev_uses_trailer_tags(dev)))
|
||||
return htons(ETH_P_TRAILER);
|
||||
if (unlikely(netdev_uses_dsa(dev)))
|
||||
return htons(ETH_P_XDSA);
|
||||
|
||||
if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN))
|
||||
return eth->h_proto;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue