aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2014-08-27 20:04:52 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-28 01:59:40 -0400
commit5aed85cec29882d1c4b4b2a01cb75a99efdbe4ed (patch)
treec2a68a4275a8aefb66c4d1e359d76704c6894817
parent0d8bcdd383b8865e752a7e8edb4712c2e3902052 (diff)
net: dsa: allow switches to work without tagging
In case switch port tagging is disabled (voluntarily, or the switch just does not support it), allow us to continue using the defined set of dsa_device_ops in net/dsa/slave.c. We introduce dsa_protocol_is_tagged() to check whether we need to override skb->protocol and go through the DSA-specifif packet_type function, or if we just go on and receive the SKB through the normal path. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h6
-rw-r--r--include/net/dsa.h5
-rw-r--r--net/dsa/slave.c19
3 files changed, 26 insertions, 4 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 1875dc71422a..429801370d0c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1784,10 +1784,10 @@ void dev_net_set(struct net_device *dev, struct net *net)
1784static inline bool netdev_uses_dsa(struct net_device *dev) 1784static inline bool netdev_uses_dsa(struct net_device *dev)
1785{ 1785{
1786#ifdef CONFIG_NET_DSA 1786#ifdef CONFIG_NET_DSA
1787 return dev->dsa_ptr != NULL; 1787 if (dev->dsa_ptr != NULL)
1788#else 1788 return dsa_uses_tagged_protocol(dev->dsa_ptr);
1789 return false;
1790#endif 1789#endif
1790 return false;
1791} 1791}
1792 1792
1793/** 1793/**
diff --git a/include/net/dsa.h b/include/net/dsa.h
index dc357454ae3b..1035f6452d79 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -198,4 +198,9 @@ static inline void *ds_to_priv(struct dsa_switch *ds)
198 return (void *)(ds + 1); 198 return (void *)(ds + 1);
199} 199}
200 200
201static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
202{
203 return dst->tag_protocol != 0;
204}
205
201#endif 206#endif
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 03d2894a0f8a..241c2a1684cb 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -181,6 +181,17 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
181 return dst->ops->xmit(skb, dev); 181 return dst->ops->xmit(skb, dev);
182} 182}
183 183
184static netdev_tx_t dsa_slave_notag_xmit(struct sk_buff *skb,
185 struct net_device *dev)
186{
187 struct dsa_slave_priv *p = netdev_priv(dev);
188
189 skb->dev = p->parent->dst->master_netdev;
190 dev_queue_xmit(skb);
191
192 return NETDEV_TX_OK;
193}
194
184 195
185/* ethtool operations *******************************************************/ 196/* ethtool operations *******************************************************/
186static int 197static int
@@ -314,6 +325,11 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
314 .ndo_do_ioctl = dsa_slave_ioctl, 325 .ndo_do_ioctl = dsa_slave_ioctl,
315}; 326};
316 327
328static const struct dsa_device_ops notag_netdev_ops = {
329 .xmit = dsa_slave_notag_xmit,
330 .rcv = NULL,
331};
332
317static void dsa_slave_adjust_link(struct net_device *dev) 333static void dsa_slave_adjust_link(struct net_device *dev)
318{ 334{
319 struct dsa_slave_priv *p = netdev_priv(dev); 335 struct dsa_slave_priv *p = netdev_priv(dev);
@@ -415,7 +431,8 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
415 break; 431 break;
416#endif 432#endif
417 default: 433 default:
418 BUG(); 434 ds->dst->ops = &notag_netdev_ops;
435 break;
419 } 436 }
420 437
421 SET_NETDEV_DEV(slave_dev, parent); 438 SET_NETDEV_DEV(slave_dev, parent);