aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/dsa.h
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2014-08-27 20:04:46 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-28 01:59:39 -0400
commit3e8a72d1dae374cf6fc1dba97cec663585845ff9 (patch)
tree83a2ebc590d0dc90d27515dc15bf6323cb2a6c1b /include/net/dsa.h
parent8663dc2002b02abfe5dfb0fb7e544b81982ad95b (diff)
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>
Diffstat (limited to 'include/net/dsa.h')
-rw-r--r--include/net/dsa.h20
1 files changed, 3 insertions, 17 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 6efce384451e..6e26f1e4d8ce 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -59,6 +59,8 @@ struct dsa_platform_data {
59 struct dsa_chip_data *chip; 59 struct dsa_chip_data *chip;
60}; 60};
61 61
62struct dsa_device_ops;
63
62struct dsa_switch_tree { 64struct dsa_switch_tree {
63 /* 65 /*
64 * Configuration data for the platform device that owns 66 * Configuration data for the platform device that owns
@@ -71,6 +73,7 @@ struct dsa_switch_tree {
71 * protocol to use. 73 * protocol to use.
72 */ 74 */
73 struct net_device *master_netdev; 75 struct net_device *master_netdev;
76 const struct dsa_device_ops *ops;
74 __be16 tag_protocol; 77 __be16 tag_protocol;
75 78
76 /* 79 /*
@@ -186,21 +189,4 @@ static inline void *ds_to_priv(struct dsa_switch *ds)
186 return (void *)(ds + 1); 189 return (void *)(ds + 1);
187} 190}
188 191
189/*
190 * The original DSA tag format and some other tag formats have no
191 * ethertype, which means that we need to add a little hack to the
192 * networking receive path to make sure that received frames get
193 * the right ->protocol assigned to them when one of those tag
194 * formats is in use.
195 */
196static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst)
197{
198 return !!(dst->tag_protocol == htons(ETH_P_DSA));
199}
200
201static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst)
202{
203 return !!(dst->tag_protocol == htons(ETH_P_TRAILER));
204}
205
206#endif 192#endif