Global replace of Nicira Networks.
[sliver-openvswitch.git] / datapath / vlan.c
1 /*
2  * Copyright (c) 2007-2011 Nicira, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 2 of the GNU General Public
6  * License as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301, USA
17  */
18
19 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
21 #include <linux/if_vlan.h>
22 #include <linux/skbuff.h>
23
24 #include "datapath.h"
25 #include "vlan.h"
26
27 #ifdef NEED_VLAN_FIELD
28 void vlan_copy_skb_tci(struct sk_buff *skb)
29 {
30         OVS_CB(skb)->vlan_tci = 0;
31 }
32
33 u16 vlan_get_tci(struct sk_buff *skb)
34 {
35         return OVS_CB(skb)->vlan_tci;
36 }
37
38 void vlan_set_tci(struct sk_buff *skb, u16 vlan_tci)
39 {
40         OVS_CB(skb)->vlan_tci = vlan_tci;
41 }
42
43 bool vlan_tx_tag_present(struct sk_buff *skb)
44 {
45         return OVS_CB(skb)->vlan_tci & VLAN_TAG_PRESENT;
46 }
47
48 u16 vlan_tx_tag_get(struct sk_buff *skb)
49 {
50         return OVS_CB(skb)->vlan_tci & ~VLAN_TAG_PRESENT;
51 }
52
53 struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, u16 vlan_tci)
54 {
55         OVS_CB(skb)->vlan_tci = vlan_tci | VLAN_TAG_PRESENT;
56         return skb;
57 }
58 #endif /* NEED_VLAN_FIELD */