[ovs-dev,1/4] compat: Add act_pedit compatibility for old kernels

Submitted by Roi Dayan on Aug. 8, 2017, 2:21 p.m.

Details

Message ID 1502202114-57266-2-git-send-email-roid@mellanox.com
State Changes Requested
Headers show

Commit Message

Roi Dayan Aug. 8, 2017, 2:21 p.m.
From: Paul Blakey <paulb@mellanox.com>

Added compatibility for action pedit.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
---
 acinclude.m4                    |  7 ++++
 include/linux/automake.mk       |  1 +
 include/linux/tc_act/tc_pedit.h | 72 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+)
 create mode 100644 include/linux/tc_act/tc_pedit.h

Patch hide | download patch | download mbox

diff --git a/acinclude.m4 b/acinclude.m4
index 7195fbf..158bb6e 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -188,6 +188,13 @@  AC_DEFUN([OVS_CHECK_LINUX_TC], [
     ])],
     [AC_DEFINE([HAVE_TCA_TUNNEL_KEY_ENC_DST_PORT], [1],
                [Define to 1 if TCA_TUNNEL_KEY_ENC_DST_PORT is avaiable.])])
+
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([#include <linux/tc_act/tc_pedit.h>], [
+        int x = TCA_PEDIT_KEY_EX_HDR_TYPE_UDP;
+    ])],
+    [AC_DEFINE([HAVE_TCA_PEDIT_KEY_EX_HDR_TYPE_UDP], [1],
+               [Define to 1 if TCA_PEDIT_KEY_EX_HDR_TYPE_UDP is avaiable.])])
 ])
 
 dnl OVS_CHECK_DPDK
diff --git a/include/linux/automake.mk b/include/linux/automake.mk
index 093204e..b464fe0 100644
--- a/include/linux/automake.mk
+++ b/include/linux/automake.mk
@@ -1,4 +1,5 @@ 
 noinst_HEADERS += \
 	include/linux/pkt_cls.h \
+	include/linux/tc_act/tc_pedit.h \
 	include/linux/tc_act/tc_tunnel_key.h \
 	include/linux/tc_act/tc_vlan.h
diff --git a/include/linux/tc_act/tc_pedit.h b/include/linux/tc_act/tc_pedit.h
new file mode 100644
index 0000000..d9c2af6
--- /dev/null
+++ b/include/linux/tc_act/tc_pedit.h
@@ -0,0 +1,72 @@ 
+#ifndef __LINUX_TC_ACT_TC_PEDIT_WRAPPER_H
+#define __LINUX_TC_ACT_TC_PEDIT_WRAPPER_H 1
+
+#if defined(__KERNEL__) || defined(HAVE_TCA_PEDIT_KEY_EX_HDR_TYPE_UDP)
+#include_next <linux/tc_act/tc_pedit.h>
+#else
+
+#include <linux/types.h>
+#include <linux/pkt_cls.h>
+
+#define TCA_ACT_PEDIT 7
+
+enum {
+	TCA_PEDIT_UNSPEC,
+	TCA_PEDIT_TM,
+	TCA_PEDIT_PARMS,
+	TCA_PEDIT_PAD,
+	TCA_PEDIT_PARMS_EX,
+	TCA_PEDIT_KEYS_EX,
+	TCA_PEDIT_KEY_EX,
+	__TCA_PEDIT_MAX
+};
+#define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1)
+
+enum {
+	TCA_PEDIT_KEY_EX_HTYPE = 1,
+	TCA_PEDIT_KEY_EX_CMD = 2,
+	__TCA_PEDIT_KEY_EX_MAX
+};
+#define TCA_PEDIT_KEY_EX_MAX (__TCA_PEDIT_KEY_EX_MAX - 1)
+
+ /* TCA_PEDIT_KEY_EX_HDR_TYPE_NETWROK is a special case for legacy users. It
+  * means no specific header type - offset is relative to the network layer
+  */
+enum pedit_header_type {
+	TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK = 0,
+	TCA_PEDIT_KEY_EX_HDR_TYPE_ETH = 1,
+	TCA_PEDIT_KEY_EX_HDR_TYPE_IP4 = 2,
+	TCA_PEDIT_KEY_EX_HDR_TYPE_IP6 = 3,
+	TCA_PEDIT_KEY_EX_HDR_TYPE_TCP = 4,
+	TCA_PEDIT_KEY_EX_HDR_TYPE_UDP = 5,
+	__PEDIT_HDR_TYPE_MAX,
+};
+#define TCA_PEDIT_HDR_TYPE_MAX (__PEDIT_HDR_TYPE_MAX - 1)
+
+enum pedit_cmd {
+	TCA_PEDIT_KEY_EX_CMD_SET = 0,
+	TCA_PEDIT_KEY_EX_CMD_ADD = 1,
+	__PEDIT_CMD_MAX,
+};
+#define TCA_PEDIT_CMD_MAX (__PEDIT_CMD_MAX - 1)
+
+struct tc_pedit_key {
+	__u32           mask;  /* AND */
+	__u32           val;   /*XOR */
+	__u32           off;  /*offset */
+	__u32           at;
+	__u32           offmask;
+	__u32           shift;
+};
+
+struct tc_pedit_sel {
+	tc_gen;
+	unsigned char           nkeys;
+	unsigned char           flags;
+	struct tc_pedit_key     keys[0];
+};
+#define tc_pedit tc_pedit_sel
+
+#endif /* __KERNEL__ || HAVE_TCA_PEDIT_KEY_EX_HDR_TYPE_UDP */
+
+#endif /* __LINUX_TC_ACT_TC_PEDIT_WRAPPER_H */