summaryrefslogtreecommitdiff
path: root/datapath/vlan.c
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2010-12-30 20:48:38 -0800
committerJesse Gross <jesse@nicira.com>2011-02-07 13:49:00 -0800
commit6e0ce48e27d5a845bdc8b57fb41bcec8a54f336a (patch)
treed5c2313b0b239c9d5c67e5a963ce724b97b9d055 /datapath/vlan.c
parenta992ec0b06bfddc4e8c2a50d79362b3dfb286dd5 (diff)
downloadopenvswitch-6e0ce48e27d5a845bdc8b57fb41bcec8a54f336a.tar.gz
datapath: Add vlan acceleration field for older kernels.
Kernels prior to 2.6.27 did not have a vlan_tci field in struct sk_buff for vlan acceleration. It's very convenient to use this field for manipulating vlan tags, so we would like to use it as the primary mechanism. To enable this, this commit adds similar infrastructure to the OVS_CB on the kernels that need it and a set of functions to use the correct location. Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'datapath/vlan.c')
-rw-r--r--datapath/vlan.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/datapath/vlan.c b/datapath/vlan.c
new file mode 100644
index 000000000..9aebecd0e
--- /dev/null
+++ b/datapath/vlan.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 Nicira Networks.
+ * Distributed under the terms of the GNU GPL version 2.
+ *
+ * Significant portions of this file may be copied from parts of the Linux
+ * kernel, by Linus Torvalds and others.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/if_vlan.h>
+#include <linux/skbuff.h>
+
+#include "datapath.h"
+#include "vlan.h"
+
+#ifdef NEED_VLAN_FIELD
+void vlan_copy_skb_tci(struct sk_buff *skb)
+{
+ OVS_CB(skb)->vlan_tci = 0;
+}
+
+u16 vlan_get_tci(struct sk_buff *skb)
+{
+ return OVS_CB(skb)->vlan_tci;
+}
+
+void vlan_set_tci(struct sk_buff *skb, u16 vlan_tci)
+{
+ OVS_CB(skb)->vlan_tci = vlan_tci;
+}
+
+bool vlan_tx_tag_present(struct sk_buff *skb)
+{
+ return OVS_CB(skb)->vlan_tci & VLAN_TAG_PRESENT;
+}
+
+u16 vlan_tx_tag_get(struct sk_buff *skb)
+{
+ return OVS_CB(skb)->vlan_tci & ~VLAN_TAG_PRESENT;
+}
+
+struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, u16 vlan_tci)
+{
+ OVS_CB(skb)->vlan_tci = vlan_tci | VLAN_TAG_PRESENT;
+ return skb;
+}
+#endif /* NEED_VLAN_FIELD */