1 #include <linux/skbuff.h>
2 #include <linux/netdevice.h>
3 #include <linux/if_vlan.h>
6 struct vlan_hwaccel_cb
{
7 struct net_device
*dev
;
10 static inline struct vlan_hwaccel_cb
*vlan_hwaccel_cb(struct sk_buff
*skb
)
12 return (struct vlan_hwaccel_cb
*)skb
->cb
;
15 /* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
16 int __vlan_hwaccel_rx(struct sk_buff
*skb
, struct vlan_group
*grp
,
17 u16 vlan_tci
, int polling
)
19 struct vlan_hwaccel_cb
*cb
= vlan_hwaccel_cb(skb
);
21 if (skb_bond_should_drop(skb
)) {
22 dev_kfree_skb_any(skb
);
26 skb
->vlan_tci
= vlan_tci
;
27 cb
->dev
= vlan_group_get_device(grp
, vlan_tci
& VLAN_VID_MASK
);
29 return (polling
? netif_receive_skb(skb
) : netif_rx(skb
));
31 EXPORT_SYMBOL(__vlan_hwaccel_rx
);
33 int vlan_hwaccel_do_receive(struct sk_buff
*skb
)
35 struct vlan_hwaccel_cb
*cb
= vlan_hwaccel_cb(skb
);
36 struct net_device
*dev
= cb
->dev
;
37 struct net_device_stats
*stats
;
39 netif_nit_deliver(skb
);
47 skb
->priority
= vlan_get_ingress_priority(dev
, skb
->vlan_tci
);
50 dev
->last_rx
= jiffies
;
54 stats
->rx_bytes
+= skb
->len
;
56 switch (skb
->pkt_type
) {
57 case PACKET_BROADCAST
:
59 case PACKET_MULTICAST
:
62 case PACKET_OTHERHOST
:
63 /* Our lower layer thinks this is not local, let's make sure.
64 * This allows the VLAN to have a different MAC than the
65 * underlying device, and still route correctly. */
66 if (!compare_ether_addr(eth_hdr(skb
)->h_dest
,
68 skb
->pkt_type
= PACKET_HOST
;
74 struct net_device
*vlan_dev_real_dev(const struct net_device
*dev
)
76 return vlan_dev_info(dev
)->real_dev
;
78 EXPORT_SYMBOL_GPL(vlan_dev_real_dev
);
80 u16
vlan_dev_vlan_id(const struct net_device
*dev
)
82 return vlan_dev_info(dev
)->vlan_id
;
84 EXPORT_SYMBOL_GPL(vlan_dev_vlan_id
);