summaryrefslogtreecommitdiffstats
path: root/net/dsa/dsa.c
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2017-04-08 11:55:23 -0400
committerDavid S. Miller <davem@davemloft.net>2017-04-08 16:49:36 -0400
commita86d8becc3f04a5e350b5a17530e6a01495c00a5 (patch)
tree93e0c28cdfcac7bb616f9b767c4a782a2e620bce /net/dsa/dsa.c
parent16c5dcb13a371feae0e680e6518775b5335b37d8 (diff)
net: dsa: Factor bottom tag receive functions
All DSA tag receive functions do strictly the same thing after they have located the originating source port from their tag specific protocol: - push ETH_HLEN bytes - set pkt_type to PACKET_HOST - call eth_type_trans() - bump up counters - call netif_receive_skb() Factor all of that into dsa_switch_rcv(). This also makes us return a pointer to a sk_buff, which makes us symetric with the xmit function. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r--net/dsa/dsa.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index d370c8bfa372..1fb9cf7aaaf4 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -23,6 +23,7 @@
23#include <linux/sysfs.h> 23#include <linux/sysfs.h>
24#include <linux/phy_fixed.h> 24#include <linux/phy_fixed.h>
25#include <linux/gpio/consumer.h> 25#include <linux/gpio/consumer.h>
26#include <linux/etherdevice.h>
26#include <net/dsa.h> 27#include <net/dsa.h>
27#include "dsa_priv.h" 28#include "dsa_priv.h"
28 29
@@ -900,6 +901,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
900 struct packet_type *pt, struct net_device *orig_dev) 901 struct packet_type *pt, struct net_device *orig_dev)
901{ 902{
902 struct dsa_switch_tree *dst = dev->dsa_ptr; 903 struct dsa_switch_tree *dst = dev->dsa_ptr;
904 struct sk_buff *nskb = NULL;
903 905
904 if (unlikely(dst == NULL)) { 906 if (unlikely(dst == NULL)) {
905 kfree_skb(skb); 907 kfree_skb(skb);
@@ -910,7 +912,23 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
910 if (!skb) 912 if (!skb)
911 return 0; 913 return 0;
912 914
913 return dst->rcv(skb, dev, pt, orig_dev); 915 nskb = dst->rcv(skb, dev, pt, orig_dev);
916 if (!nskb) {
917 kfree_skb(skb);
918 return 0;
919 }
920
921 skb = nskb;
922 skb_push(skb, ETH_HLEN);
923 skb->pkt_type = PACKET_HOST;
924 skb->protocol = eth_type_trans(skb, skb->dev);
925
926 skb->dev->stats.rx_packets++;
927 skb->dev->stats.rx_bytes += skb->len;
928
929 netif_receive_skb(skb);
930
931 return 0;
914} 932}
915 933
916static struct packet_type dsa_pack_type __read_mostly = { 934static struct packet_type dsa_pack_type __read_mostly = {