Merge "master" into "wdp".
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / include / linux / if_vlan.h
1 #ifndef __LINUX_IF_VLAN_WRAPPER_H
2 #define __LINUX_IF_VLAN_WRAPPER_H 1
3
4 #include_next <linux/if_vlan.h>
5 #include <linux/skbuff.h>
6
7 /* All of these were introduced in a single commit preceding 2.6.33, so
8  * presumably all of them or none of them are present. */
9 #ifndef VLAN_PRIO_MASK
10 #define VLAN_PRIO_MASK          0xe000 /* Priority Code Point */
11 #define VLAN_PRIO_SHIFT         13
12 #define VLAN_CFI_MASK           0x1000 /* Canonical Format Indicator */
13 #define VLAN_TAG_PRESENT        VLAN_CFI_MASK
14 #endif
15
16 /*
17  * The behavior of __vlan_put_tag() has changed over time:
18  *
19  *      - In 2.6.26 and earlier, it adjusted both MAC and network header
20  *        pointers.  (The latter didn't make any sense.)
21  *
22  *      - In 2.6.27 and 2.6.28, it did not adjust any header pointers at all.
23  *
24  *      - In 2.6.29 and later, it adjusts the MAC header pointer only.
25  *
26  * This is the version from 2.6.33.  We unconditionally substitute this version
27  * to avoid the need to guess whether the version in the kernel tree is
28  * acceptable.
29  */
30 #define __vlan_put_tag rpl_vlan_put_tag
31 static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
32 {
33         struct vlan_ethhdr *veth;
34
35         if (skb_cow_head(skb, VLAN_HLEN) < 0) {
36                 kfree_skb(skb);
37                 return NULL;
38         }
39         veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
40
41         /* Move the mac addresses to the beginning of the new header. */
42         memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
43         skb->mac_header -= VLAN_HLEN;
44
45         /* first, the ethernet type */
46         veth->h_vlan_proto = htons(ETH_P_8021Q);
47
48         /* now, the TCI */
49         veth->h_vlan_TCI = htons(vlan_tci);
50
51         skb->protocol = htons(ETH_P_8021Q);
52
53         return skb;
54 }
55
56 #endif  /* linux/if_vlan.h wrapper */