Soft Patch Panel
 help / color / mirror / Atom feed
From: x-fn-spp-ml@ntt-tx.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH v3 10/17] spp_primary: add actions of rte_flow
Date: Tue, 25 Feb 2020 14:56:32 +0900	[thread overview]
Message-ID: <20200225055639.31616-11-x-fn-spp-ml@ntt-tx.co.jp> (raw)
In-Reply-To: <20200219112155.13964-1-yamashita.hideyuki@ntt-tx.co.jp>

From: Hideyuki Yamashita <yamashita.hideyuki@ntt-tx.co.jp>

To support rte_flow in SPP, this patch adds the following
actions of rte_flow.
   - queue
   - jump
   - pop_vlan
   - push_vlan
   - set_vlan_vid
   - set_vlan_pcp
Additional files should be added when new actions should be
newly supported by SPP.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@ntt-tx.co.jp>
Signed-off-by: Naoki Takada <ntakada14@gmail.com>
---
 src/primary/flow/action/jump.c            | 42 ++++++++++++++++++++++
 src/primary/flow/action/jump.h            | 12 +++++++
 src/primary/flow/action/of_push_vlan.c    | 44 +++++++++++++++++++++++
 src/primary/flow/action/of_push_vlan.h    | 13 +++++++
 src/primary/flow/action/of_set_vlan_pcp.c | 44 +++++++++++++++++++++++
 src/primary/flow/action/of_set_vlan_pcp.h | 13 +++++++
 src/primary/flow/action/of_set_vlan_vid.c | 44 +++++++++++++++++++++++
 src/primary/flow/action/of_set_vlan_vid.h | 13 +++++++
 src/primary/flow/action/queue.c           | 42 ++++++++++++++++++++++
 src/primary/flow/action/queue.h           | 13 +++++++
 10 files changed, 280 insertions(+)
 create mode 100644 src/primary/flow/action/jump.c
 create mode 100644 src/primary/flow/action/jump.h
 create mode 100644 src/primary/flow/action/of_push_vlan.c
 create mode 100644 src/primary/flow/action/of_push_vlan.h
 create mode 100644 src/primary/flow/action/of_set_vlan_pcp.c
 create mode 100644 src/primary/flow/action/of_set_vlan_pcp.h
 create mode 100644 src/primary/flow/action/of_set_vlan_vid.c
 create mode 100644 src/primary/flow/action/of_set_vlan_vid.h
 create mode 100644 src/primary/flow/action/queue.c
 create mode 100644 src/primary/flow/action/queue.h

diff --git a/src/primary/flow/action/jump.c b/src/primary/flow/action/jump.c
new file mode 100644
index 0000000..b643015
--- /dev/null
+++ b/src/primary/flow/action/jump.c
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <rte_flow.h>
+
+#include "primary/flow/flow.h"
+#include "primary/flow/common.h"
+#include "jump.h"
+
+/* Define action "jump" operations */
+struct flow_detail_ops jump_ops_list[] = {
+	{
+		.token = "group",
+		.offset = offsetof(struct rte_flow_action_jump, group),
+		.size = sizeof(uint32_t),
+		.flg_value = 1,
+		.parse_detail = str_to_uint32_t,
+	},
+	{
+		.token = NULL,
+	},
+};
+
+int
+append_action_jump_json(const void *conf, int buf_size, char *action_str)
+{
+	const struct rte_flow_action_jump *jump = conf;
+	char tmp_str[64] = { 0 };
+
+	snprintf(tmp_str, 64,
+		"{\"group\":%d}",
+		jump->group);
+
+	if ((int)strlen(action_str) + (int)strlen(tmp_str)
+		> buf_size)
+		return -1;
+
+	strncat(action_str, tmp_str, strlen(tmp_str));
+
+	return 0;
+}
diff --git a/src/primary/flow/action/jump.h b/src/primary/flow/action/jump.h
new file mode 100644
index 0000000..f8c6a60
--- /dev/null
+++ b/src/primary/flow/action/jump.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _PRIMARY_FLOW_ACTION_JUMP_H_
+#define _PRIMARY_FLOW_ACTION_JUMP_H_
+
+extern struct flow_detail_ops jump_ops_list[];
+
+int append_action_jump_json(const void *conf, int buf_size, char *action_str);
+
+#endif
diff --git a/src/primary/flow/action/of_push_vlan.c b/src/primary/flow/action/of_push_vlan.c
new file mode 100644
index 0000000..749490e
--- /dev/null
+++ b/src/primary/flow/action/of_push_vlan.c
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Claus1
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <rte_flow.h>
+
+#include "primary/flow/flow.h"
+#include "primary/flow/common.h"
+#include "of_push_vlan.h"
+
+/* Define action "of_push_vlan" operations */
+struct flow_detail_ops of_push_vlan_ops_list[] = {
+	{
+		.token = "ethertype",
+		.offset = offsetof(struct rte_flow_action_of_push_vlan,
+			ethertype),
+		.size = sizeof(rte_be16_t),
+		.flg_value = 1,
+		.parse_detail = str_to_rte_be16_t,
+	},
+	{
+		.token = NULL,
+	},
+};
+
+int
+append_action_of_push_vlan_json(const void *conf, int buf_size,
+	char *action_str)
+{
+	const struct rte_flow_action_of_push_vlan *of_push_vlan = conf;
+	char tmp_str[64] = { 0 };
+
+	snprintf(tmp_str, 64,
+		"{\"ethertype\":\"0x%04x\"}",
+		of_push_vlan->ethertype);
+
+	if ((int)strlen(action_str) + (int)strlen(tmp_str)
+		> buf_size)
+		return -1;
+
+	strncat(action_str, tmp_str, strlen(tmp_str));
+
+	return 0;
+}
diff --git a/src/primary/flow/action/of_push_vlan.h b/src/primary/flow/action/of_push_vlan.h
new file mode 100644
index 0000000..7c37ab1
--- /dev/null
+++ b/src/primary/flow/action/of_push_vlan.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _PRIMARY_FLOW_ACTION_OF_PUSH_VLAN_H_
+#define _PRIMARY_FLOW_ACTION_OF_PUSH_VLAN_H_
+
+extern struct flow_detail_ops of_push_vlan_ops_list[];
+
+int append_action_of_push_vlan_json(const void *conf, int buf_size,
+	char *action_str);
+
+#endif
diff --git a/src/primary/flow/action/of_set_vlan_pcp.c b/src/primary/flow/action/of_set_vlan_pcp.c
new file mode 100644
index 0000000..33e23d5
--- /dev/null
+++ b/src/primary/flow/action/of_set_vlan_pcp.c
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <rte_flow.h>
+
+#include "primary/flow/flow.h"
+#include "primary/flow/common.h"
+#include "of_set_vlan_pcp.h"
+
+/* Define action "of_set_vlan_pcp" operations */
+struct flow_detail_ops of_set_vlan_pcp_ops_list[] = {
+	{
+		.token = "vlan_pcp",
+		.offset = offsetof(struct rte_flow_action_of_set_vlan_pcp,
+			vlan_pcp),
+		.size = sizeof(uint8_t),
+		.flg_value = 1,
+		.parse_detail = str_to_pcp,
+	},
+	{
+		.token = NULL,
+	},
+};
+
+int
+append_action_of_set_vlan_pcp_json(const void *conf, int buf_size,
+	char *action_str)
+{
+	const struct rte_flow_action_of_set_vlan_pcp *pcp = conf;
+	char tmp_str[64] = { 0 };
+
+	snprintf(tmp_str, 64,
+		"{\"vlan_pcp\":\"0x%01x\"}",
+		pcp->vlan_pcp);
+
+	if ((int)strlen(action_str) + (int)strlen(tmp_str)
+		> buf_size)
+		return -1;
+
+	strncat(action_str, tmp_str, strlen(tmp_str));
+
+	return 0;
+}
diff --git a/src/primary/flow/action/of_set_vlan_pcp.h b/src/primary/flow/action/of_set_vlan_pcp.h
new file mode 100644
index 0000000..3f8a4b3
--- /dev/null
+++ b/src/primary/flow/action/of_set_vlan_pcp.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _PRIMARY_FLOW_ACTION_OF_SET_VLAN_PCP_H_
+#define _PRIMARY_FLOW_ACTION_OF_SET_VLAN_PCP_H_
+
+extern struct flow_detail_ops of_set_vlan_pcp_ops_list[];
+
+int append_action_of_set_vlan_pcp_json(const void *conf, int buf_size,
+	char *action_str);
+
+#endif
diff --git a/src/primary/flow/action/of_set_vlan_vid.c b/src/primary/flow/action/of_set_vlan_vid.c
new file mode 100644
index 0000000..930cef5
--- /dev/null
+++ b/src/primary/flow/action/of_set_vlan_vid.c
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <rte_flow.h>
+
+#include "primary/flow/flow.h"
+#include "primary/flow/common.h"
+#include "of_set_vlan_vid.h"
+
+/* Define action "of_set_vlan_vid" operations */
+struct flow_detail_ops of_set_vlan_vid_ops_list[] = {
+	{
+		.token = "vlan_vid",
+		.offset = offsetof(struct rte_flow_action_of_set_vlan_vid,
+			vlan_vid),
+		.size = sizeof(rte_be16_t),
+		.flg_value = 1,
+		.parse_detail = str_to_rte_be16_t,
+	},
+	{
+		.token = NULL,
+	},
+};
+
+int
+append_action_of_set_vlan_vid_json(const void *conf, int buf_size,
+	char *action_str)
+{
+	const struct rte_flow_action_of_set_vlan_vid *vid = conf;
+	char tmp_str[64] = { 0 };
+
+	snprintf(tmp_str, 64,
+		"{\"vlan_vid\":\"0x%04x\"}",
+		vid->vlan_vid);
+
+	if ((int)strlen(action_str) + (int)strlen(tmp_str)
+		> buf_size)
+		return -1;
+
+	strncat(action_str, tmp_str, strlen(tmp_str));
+
+	return 0;
+}
diff --git a/src/primary/flow/action/of_set_vlan_vid.h b/src/primary/flow/action/of_set_vlan_vid.h
new file mode 100644
index 0000000..a0abe85
--- /dev/null
+++ b/src/primary/flow/action/of_set_vlan_vid.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _PRIMARY_FLOW_ACTION_OF_SET_VLAN_VID_H_
+#define _PRIMARY_FLOW_ACTION_OF_SET_VLAN_VID_H_
+
+extern struct flow_detail_ops of_set_vlan_vid_ops_list[];
+
+int append_action_of_set_vlan_vid_json(const void *conf, int buf_size,
+	char *action_str);
+
+#endif
diff --git a/src/primary/flow/action/queue.c b/src/primary/flow/action/queue.c
new file mode 100644
index 0000000..f7bcdce
--- /dev/null
+++ b/src/primary/flow/action/queue.c
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <rte_flow.h>
+
+#include "primary/flow/flow.h"
+#include "primary/flow/common.h"
+#include "queue.h"
+
+/* Define action "queue" operations */
+struct flow_detail_ops queue_ops_list[] = {
+	{
+		.token = "index",
+		.offset = offsetof(struct rte_flow_action_queue, index),
+		.size = sizeof(uint16_t),
+		.flg_value = 1,
+		.parse_detail = str_to_uint16_t,
+	},
+	{
+		.token = NULL,
+	},
+};
+
+int
+append_action_queue_json(const void *conf, int buf_size, char *action_str)
+{
+	const struct rte_flow_action_queue *queue = conf;
+	char tmp_str[64] = { 0 };
+
+	snprintf(tmp_str, 64,
+		"{\"index\":%d}",
+		queue->index);
+
+	if ((int)strlen(action_str) + (int)strlen(tmp_str)
+		> buf_size)
+		return -1;
+
+	strncat(action_str, tmp_str, strlen(tmp_str));
+
+	return 0;
+}
diff --git a/src/primary/flow/action/queue.h b/src/primary/flow/action/queue.h
new file mode 100644
index 0000000..22816c7
--- /dev/null
+++ b/src/primary/flow/action/queue.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _PRIMARY_FLOW_ACTION_QUEUE_H_
+#define _PRIMARY_FLOW_ACTION_QUEUE_H_
+
+extern struct flow_detail_ops queue_ops_list[];
+
+int append_action_queue_json(const void *conf, int buf_size,
+	char *action_str);
+
+#endif
-- 
2.17.1


  parent reply	other threads:[~2020-02-25  5:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200219112155.13964-1-yamashita.hideyuki@ntt-tx.co.jp>
2020-02-25  5:56 ` [spp] [PATCH v3 00/17] Adding Hardware offload capability x-fn-spp-ml
2020-02-25 10:37   ` Yasufumi Ogawa
2020-02-25  5:56 ` [spp] [PATCH v3 01/17] shared: add support of multi-queue x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 02/17] spp_vf: " x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 03/17] spp_mirror: " x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 04/17] spp_pcap: " x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 05/17] spp_primary: " x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 06/17] spp_primary: add support of rte_flow x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 07/17] spp_primary: add common function " x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 08/17] spp_primary: add attribute " x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 09/17] spp_primary: add patterns " x-fn-spp-ml
2020-02-25  5:56 ` x-fn-spp-ml [this message]
2020-02-25  5:56 ` [spp] [PATCH v3 11/17] bin: add parameter for hardrare offload x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 12/17] cli: add support of hardware offload x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 13/17] cli: add support of rte_flow in vf x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 14/17] cli: add support of rte_flow in mirror x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 15/17] cli: add support of rte_flow in nfv x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 16/17] spp-ctl: add APIs for flow rules x-fn-spp-ml
2020-02-25  5:56 ` [spp] [PATCH v3 17/17] spp_nfv: add support of multi-queue x-fn-spp-ml

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200225055639.31616-11-x-fn-spp-ml@ntt-tx.co.jp \
    --to=x-fn-spp-ml@ntt-tx.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    --cc=yasufum.o@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).