tg3: Update version to 3.104
[deliverable/linux.git] / net / 8021q / vlan_core.c
1 #include <linux/skbuff.h>
2 #include <linux/netdevice.h>
3 #include <linux/if_vlan.h>
4 #include <linux/netpoll.h>
5 #include "vlan.h"
6
7 /* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
8 int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
9 u16 vlan_tci, int polling)
10 {
11 if (netpoll_rx(skb))
12 return NET_RX_DROP;
13
14 if (skb_bond_should_drop(skb))
15 goto drop;
16
17 skb->vlan_tci = vlan_tci;
18 skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK);
19
20 if (!skb->dev)
21 goto drop;
22
23 return (polling ? netif_receive_skb(skb) : netif_rx(skb));
24
25 drop:
26 dev_kfree_skb_any(skb);
27 return NET_RX_DROP;
28 }
29 EXPORT_SYMBOL(__vlan_hwaccel_rx);
30
31 int vlan_hwaccel_do_receive(struct sk_buff *skb)
32 {
33 struct net_device *dev = skb->dev;
34 struct net_device_stats *stats;
35
36 skb->dev = vlan_dev_info(dev)->real_dev;
37 netif_nit_deliver(skb);
38
39 skb->dev = dev;
40 skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci);
41 skb->vlan_tci = 0;
42
43 stats = &dev->stats;
44 stats->rx_packets++;
45 stats->rx_bytes += skb->len;
46
47 switch (skb->pkt_type) {
48 case PACKET_BROADCAST:
49 break;
50 case PACKET_MULTICAST:
51 stats->multicast++;
52 break;
53 case PACKET_OTHERHOST:
54 /* Our lower layer thinks this is not local, let's make sure.
55 * This allows the VLAN to have a different MAC than the
56 * underlying device, and still route correctly. */
57 if (!compare_ether_addr(eth_hdr(skb)->h_dest,
58 dev->dev_addr))
59 skb->pkt_type = PACKET_HOST;
60 break;
61 };
62 return 0;
63 }
64
65 struct net_device *vlan_dev_real_dev(const struct net_device *dev)
66 {
67 return vlan_dev_info(dev)->real_dev;
68 }
69 EXPORT_SYMBOL(vlan_dev_real_dev);
70
71 u16 vlan_dev_vlan_id(const struct net_device *dev)
72 {
73 return vlan_dev_info(dev)->vlan_id;
74 }
75 EXPORT_SYMBOL(vlan_dev_vlan_id);
76
77 static gro_result_t
78 vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp,
79 unsigned int vlan_tci, struct sk_buff *skb)
80 {
81 struct sk_buff *p;
82
83 if (skb_bond_should_drop(skb))
84 goto drop;
85
86 skb->vlan_tci = vlan_tci;
87 skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK);
88
89 if (!skb->dev)
90 goto drop;
91
92 for (p = napi->gro_list; p; p = p->next) {
93 NAPI_GRO_CB(p)->same_flow =
94 p->dev == skb->dev && !compare_ether_header(
95 skb_mac_header(p), skb_gro_mac_header(skb));
96 NAPI_GRO_CB(p)->flush = 0;
97 }
98
99 return dev_gro_receive(napi, skb);
100
101 drop:
102 return GRO_DROP;
103 }
104
105 gro_result_t vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
106 unsigned int vlan_tci, struct sk_buff *skb)
107 {
108 if (netpoll_rx_on(skb))
109 return vlan_hwaccel_receive_skb(skb, grp, vlan_tci)
110 ? GRO_DROP : GRO_NORMAL;
111
112 skb_gro_reset_offset(skb);
113
114 return napi_skb_finish(vlan_gro_common(napi, grp, vlan_tci, skb), skb);
115 }
116 EXPORT_SYMBOL(vlan_gro_receive);
117
118 gro_result_t vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
119 unsigned int vlan_tci)
120 {
121 struct sk_buff *skb = napi_frags_skb(napi);
122
123 if (!skb)
124 return GRO_DROP;
125
126 if (netpoll_rx_on(skb)) {
127 skb->protocol = eth_type_trans(skb, skb->dev);
128 return vlan_hwaccel_receive_skb(skb, grp, vlan_tci)
129 ? GRO_DROP : GRO_NORMAL;
130 }
131
132 return napi_frags_finish(napi, skb,
133 vlan_gro_common(napi, grp, vlan_tci, skb));
134 }
135 EXPORT_SYMBOL(vlan_gro_frags);
This page took 0.038255 seconds and 5 git commands to generate.