Soft Patch Panel
 help / color / mirror / Atom feed
From: x-fn-spp-ml@ntt-tx.co.jp
To: ferruh.yigit@intel.com, yasufum.o@gmail.com
Cc: spp@dpdk.org
Subject: [spp] [PATCH 08/17] spp_primary: add attribute of rte_flow
Date: Tue, 18 Feb 2020 15:37:11 +0900
Message-ID: <20200218063720.6597-9-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 provides support of various
attribute of rte_flow.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@ntt-tx.co.jp>
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/primary/flow/attr.c | 105 ++++++++++++++++++++++++++++++++++++++++
 src/primary/flow/attr.h |  13 +++++
 2 files changed, 118 insertions(+)
 create mode 100644 src/primary/flow/attr.c
 create mode 100644 src/primary/flow/attr.h

diff --git a/src/primary/flow/attr.c b/src/primary/flow/attr.c
new file mode 100644
index 0000000..8be7319
--- /dev/null
+++ b/src/primary/flow/attr.c
@@ -0,0 +1,105 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <rte_flow.h>
+
+#include "attr.h"
+
+int
+parse_flow_attr(char *token_list[], int *index,
+	struct rte_flow_attr *attr)
+{
+	int ret;
+	char *token;
+	char *end;
+	unsigned long temp = 0;
+
+	while (token_list[*index] != NULL) {
+		token = token_list[*index];
+
+		if (!strcmp(token, "group")) {
+			/* "group" requires option argument */
+			if (token_list[*index + 1] == NULL) {
+				ret = -1;
+				break;
+			}
+
+			temp = strtoul(token_list[*index + 1], &end, 10);
+			if (end == NULL || *end != '\0') {
+				ret = -1;
+				break;
+			}
+
+			attr->group = (uint32_t)temp;
+			(*index)++;
+
+		} else if (!strcmp(token, "priority")) {
+			/* "priority" requires option argument */
+			if (token_list[*index + 1] == NULL) {
+				ret = -1;
+				break;
+			}
+
+			temp = strtoul(token_list[*index + 1], &end, 10);
+			if (end == NULL || *end != '\0') {
+				ret = -1;
+				break;
+			}
+
+			attr->priority = (uint32_t)temp;
+			(*index)++;
+
+		} else if (!strcmp(token, "ingress")) {
+			attr->ingress = 1;
+
+		} else if (!strcmp(token, "egress")) {
+			attr->egress = 1;
+
+		} else if (!strcmp(token, "transfer")) {
+			attr->transfer = 1;
+
+		} else if (!strcmp(token, "pattern")) {
+			/* Attribute parameter end */
+			ret = 0;
+			break;
+
+		} else {
+			/* Illegal parameter */
+			ret = -1;
+			break;
+
+		}
+
+		(*index)++;
+	}
+
+	if (token_list[*index] == NULL)
+		ret = -1;
+
+	return ret;
+}
+
+int
+append_flow_attr_json(const struct rte_flow_attr *attr, int buf_size,
+	char *attr_str)
+{
+	char tmp_str[128] = { 0 };
+
+	snprintf(tmp_str, 128,
+		"{\"group\":%d,"
+		"\"priority\":%d,"
+		"\"ingress\":%d,"
+		"\"egress\":%d,"
+		"\"transfer\":%d}",
+		attr->group, attr->priority, attr->ingress,
+		attr->egress, attr->transfer);
+
+	if ((int)strlen(attr_str) + (int)strlen(tmp_str)
+		> buf_size)
+		return -1;
+
+	strncat(attr_str, tmp_str, strlen(tmp_str));
+
+	return 0;
+}
diff --git a/src/primary/flow/attr.h b/src/primary/flow/attr.h
new file mode 100644
index 0000000..5fb22e3
--- /dev/null
+++ b/src/primary/flow/attr.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _PRIMARY_FLOW_ATTR_H_
+#define _PRIMARY_FLOW_ATTR_H_
+
+int parse_flow_attr(char *token_list[], int *index,
+	struct rte_flow_attr *attr);
+int append_flow_attr_json(const struct rte_flow_attr *attr,
+	int buf_size, char *attr_str);
+
+#endif
-- 
2.17.1


  parent reply	other threads:[~2020-02-18  6:37 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 ` x-fn-spp-ml [this message]
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 ` [spp] [PATCH v2 09/17] spp_primary: add patterns " x-fn-spp-ml
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=20200218063720.6597-9-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