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 v2 09/17] spp_primary: add patterns of rte_flow
Date: Wed, 19 Feb 2020 20:49:39 +0900
Message-ID: <20200219114947.14134-10-x-fn-spp-ml@ntt-tx.co.jp> (raw)
In-Reply-To: <20200218063720.6597-1-x-fn-spp-ml@ntt-tx.co.jp>

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

To support rte_flow in SPP, this patch adds the following
patterns of rte_flow.
   - eth
   - vlan
Additional files should be added when new pattern should be
newly supported by SPP.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@ntt-tx.co.jp>
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/primary/flow/pattern/eth.c  | 63 +++++++++++++++++++++++++++++
 src/primary/flow/pattern/eth.h  | 13 ++++++
 src/primary/flow/pattern/vlan.c | 71 +++++++++++++++++++++++++++++++++
 src/primary/flow/pattern/vlan.h | 13 ++++++
 4 files changed, 160 insertions(+)
 create mode 100644 src/primary/flow/pattern/eth.c
 create mode 100644 src/primary/flow/pattern/eth.h
 create mode 100644 src/primary/flow/pattern/vlan.c
 create mode 100644 src/primary/flow/pattern/vlan.h

diff --git a/src/primary/flow/pattern/eth.c b/src/primary/flow/pattern/eth.c
new file mode 100644
index 0000000..d718b77
--- /dev/null
+++ b/src/primary/flow/pattern/eth.c
@@ -0,0 +1,63 @@
+/* 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 "eth.h"
+
+/* Define item "eth" operations */
+struct flow_detail_ops eth_ops_list[] = {
+	{
+		.token = "src",
+		.offset = offsetof(struct rte_flow_item_eth, src),
+		.size = sizeof(struct rte_ether_addr),
+		.flg_value = 1,
+		.parse_detail = str_to_rte_ether_addr,
+	},
+	{
+		.token = "dst",
+		.offset = offsetof(struct rte_flow_item_eth, dst),
+		.size = sizeof(struct rte_ether_addr),
+		.flg_value = 1,
+		.parse_detail = str_to_rte_ether_addr,
+	},
+	{
+		.token = "type",
+		.offset = offsetof(struct rte_flow_item_eth, type),
+		.size = sizeof(rte_be16_t),
+		.flg_value = 1,
+		.parse_detail = str_to_rte_be16_t,
+	},
+	{
+		.token = NULL,
+	},
+};
+
+int
+append_item_eth_json(const void *element, int buf_size, char *pattern_str)
+{
+	const struct rte_flow_item_eth *eth = element;
+	char dst_mac[RTE_ETHER_ADDR_FMT_SIZE] = { 0 };
+	char src_mac[RTE_ETHER_ADDR_FMT_SIZE] = { 0 };
+	char tmp_str[128] = { 0 };
+
+	rte_ether_format_addr(dst_mac, RTE_ETHER_ADDR_FMT_SIZE, &eth->dst);
+	rte_ether_format_addr(src_mac, RTE_ETHER_ADDR_FMT_SIZE, &eth->src);
+
+	snprintf(tmp_str, 128,
+		"{\"dst\":\"%s\","
+		"\"src\":\"%s\","
+		"\"type\":\"0x%04x\"}",
+		dst_mac, src_mac, eth->type);
+
+	if ((int)strlen(pattern_str) + (int)strlen(tmp_str)
+		> buf_size)
+		return -1;
+
+	strncat(pattern_str, tmp_str, strlen(tmp_str));
+
+	return 0;
+}
diff --git a/src/primary/flow/pattern/eth.h b/src/primary/flow/pattern/eth.h
new file mode 100644
index 0000000..550813e
--- /dev/null
+++ b/src/primary/flow/pattern/eth.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _PRIMARY_FLOW_PATTERN_ETH_H_
+#define _PRIMARY_FLOW_PATTERN_ETH_H_
+
+extern struct flow_detail_ops eth_ops_list[];
+
+int append_item_eth_json(const void *element, int buf_size,
+	char *pattern_str);
+
+#endif
diff --git a/src/primary/flow/pattern/vlan.c b/src/primary/flow/pattern/vlan.c
new file mode 100644
index 0000000..3ca8ebc
--- /dev/null
+++ b/src/primary/flow/pattern/vlan.c
@@ -0,0 +1,71 @@
+/* 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 "vlan.h"
+
+/* Define item "vlan" operations */
+struct flow_detail_ops vlan_ops_list[] = {
+	{
+		.token = "tci",
+		.offset = offsetof(struct rte_flow_item_vlan, tci),
+		.size = sizeof(rte_be16_t),
+		.flg_value = 1,
+		.parse_detail = str_to_tci,
+	},
+	{
+		.token = "pcp",
+		.offset = offsetof(struct rte_flow_item_vlan, tci),
+		.size = sizeof(rte_be16_t),
+		.flg_value = 1,
+		.parse_detail = set_pcp_in_tci,
+	},
+	{
+		.token = "dei",
+		.offset = offsetof(struct rte_flow_item_vlan, tci),
+		.size = sizeof(rte_be16_t),
+		.flg_value = 1,
+		.parse_detail = set_dei_in_tci,
+	},
+	{
+		.token = "vid",
+		.offset = offsetof(struct rte_flow_item_vlan, tci),
+		.size = sizeof(rte_be16_t),
+		.flg_value = 1,
+		.parse_detail = set_vid_in_tci,
+	},
+	{
+		.token = "inner_type",
+		.offset = offsetof(struct rte_flow_item_vlan, inner_type),
+		.size = sizeof(rte_be16_t),
+		.flg_value = 1,
+		.parse_detail = str_to_rte_be16_t,
+	},
+	{
+		.token = NULL,
+	},
+};
+
+int
+append_item_vlan_json(const void *element, int buf_size, char *pattern_str)
+{
+	const struct rte_flow_item_vlan *vlan = element;
+	char tmp_str[128] = { 0 };
+
+	snprintf(tmp_str, 128,
+		"{\"tci\":\"0x%04x\","
+		"\"inner_type\":\"0x%04x\"}",
+		vlan->tci, vlan->inner_type);
+
+	if ((int)strlen(pattern_str) + (int)strlen(tmp_str)
+		> buf_size)
+		return -1;
+
+	strncat(pattern_str, tmp_str, strlen(tmp_str));
+
+	return 0;
+}
diff --git a/src/primary/flow/pattern/vlan.h b/src/primary/flow/pattern/vlan.h
new file mode 100644
index 0000000..50aef96
--- /dev/null
+++ b/src/primary/flow/pattern/vlan.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _PRIMARY_FLOW_PATTERN_VLAN_H_
+#define _PRIMARY_FLOW_PATTERN_VLAN_H_
+
+extern struct flow_detail_ops vlan_ops_list[];
+
+int append_item_vlan_json(const void *element, int buf_size,
+	char *pattern_str);
+
+#endif
-- 
2.17.1


  parent reply	other threads:[~2020-02-19 11:50 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18  6:37 [spp] [PATCH 00/17] Adding Hardware offload capability x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 01/17] shared: add support of multi-queue x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 02/17] spp_vf: " x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 03/17] spp_mirror: " x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 04/17] spp_pcap: " x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 05/17] spp_primary: " x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 06/17] spp_primary: add support of rte_flow x-fn-spp-ml
2020-02-19  2:24   ` Yasufumi Ogawa
2020-02-19 11:57     ` [spp] (x-fn-spp-ml 118) " Hideyuki Yamashita
2020-02-18  6:37 ` [spp] [PATCH 07/17] spp_primary: add common function " x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 08/17] spp_primary: add attribute " x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 09/17] spp_primary: add patterns " x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 10/17] spp_primary: add actions " x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 11/17] bin: add parameter for hardrare offload x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 12/17] cli: add support of hardware offload x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 13/17] cli: add support of rte_flow in vf x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 14/17] cli: add support of rte_flow in mirror x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 15/17] cli: add support of rte_flow in nfv x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 16/17] spp-ctl: add APIs for flow rules x-fn-spp-ml
2020-02-18  6:37 ` [spp] [PATCH 17/17] spp_nfv: add support of multi-queue x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 00/17] Adding Hardware offload capability x-fn-spp-ml
2020-02-21  8:17   ` Yasufumi Ogawa
2020-02-25  5:49     ` [spp] (x-fn-spp-ml 177) " Hideyuki Yamashita
2020-02-19 11:49 ` [spp] [PATCH v2 01/17] shared: add support of multi-queue x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 02/17] spp_vf: " x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 03/17] spp_mirror: " x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 04/17] spp_pcap: " x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 05/17] spp_primary: " x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 06/17] spp_primary: add support of rte_flow x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 07/17] spp_primary: add common function " x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 08/17] spp_primary: add attribute " x-fn-spp-ml
2020-02-19 11:49 ` x-fn-spp-ml [this message]
2020-02-19 11:49 ` [spp] [PATCH v2 10/17] spp_primary: add actions " x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 11/17] bin: add parameter for hardrare offload x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 12/17] cli: add support of hardware offload x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 13/17] cli: add support of rte_flow in vf x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 14/17] cli: add support of rte_flow in mirror x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 15/17] cli: add support of rte_flow in nfv x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 16/17] spp-ctl: add APIs for flow rules x-fn-spp-ml
2020-02-19 11:49 ` [spp] [PATCH v2 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=20200219114947.14134-10-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

Soft Patch Panel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ https://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git