DPDK patches and discussions
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
Cc: Konstantin Ananyev <konstantin.ananyev@intel.com>
Subject: [dpdk-dev] [PATCH v3 2/3] examples/l3fwd-acl: allow explicitly select classify method
Date: Tue,  6 Oct 2020 18:16:17 +0100	[thread overview]
Message-ID: <20201006171618.19374-3-konstantin.ananyev@intel.com> (raw)
In-Reply-To: <20201006171618.19374-1-konstantin.ananyev@intel.com>

Replace '--scalar' command-line option with new one: --alg=<algname>
to allow user explicitly select desired classify method.
This is an optional parameter, if not specified default classify
algorithm will be used.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 doc/guides/rel_notes/release_20_11.rst        |   5 +
 .../sample_app_ug/l3_forward_access_ctrl.rst  |   9 +-
 examples/l3fwd-acl/main.c                     | 103 ++++++++++++++++--
 3 files changed, 103 insertions(+), 14 deletions(-)

diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index 53343c780a..d5dbbd4e34 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -124,6 +124,11 @@ New Features
   Added new optional parameter ``--eth-dest`` for the ``l3fwd-acl`` to allow
   the user to specify the destination mac address for each ethernet port used.
 
+* **Allow explicitly select classify method for l3fwd-acl sample application.**
+
+  Replace ``--scalar`` command-line option with ``--alg=<value>``, to
+  to allow user explicitly select desired classify method.
+
 
 Removed Items
 -------------
diff --git a/doc/guides/sample_app_ug/l3_forward_access_ctrl.rst b/doc/guides/sample_app_ug/l3_forward_access_ctrl.rst
index 91004356ed..80dd8ba008 100644
--- a/doc/guides/sample_app_ug/l3_forward_access_ctrl.rst
+++ b/doc/guides/sample_app_ug/l3_forward_access_ctrl.rst
@@ -236,7 +236,7 @@ The application has a number of command line options:
 
 ..  code-block:: console
 
-    ./build/l3fwd-acl [EAL options] -- -p PORTMASK [-P] --config(port,queue,lcore)[,(port,queue,lcore)] --rule_ipv4 FILENAME rule_ipv6 FILENAME [--scalar] [--enable-jumbo [--max-pkt-len PKTLEN]] [--no-numa] [--eth-dest=X,MM:MM:MM:MM:MM:MM]
+    ./build/l3fwd-acl [EAL options] -- -p PORTMASK [-P] --config(port,queue,lcore)[,(port,queue,lcore)] --rule_ipv4 FILENAME rule_ipv6 FILENAME [--alg=<val>] [--enable-jumbo [--max-pkt-len PKTLEN]] [--no-numa] [--eth-dest=X,MM:MM:MM:MM:MM:MM]
 
 
 where,
@@ -252,7 +252,8 @@ where,
 
 *   --rule_ipv6 FILENAME: Specifies the IPv6 ACL and route rules file
 
-*   --scalar: Use a scalar function to perform rule lookup
+*   --alg=<val>: optional, ACL classify method to use, one of:
+    ``scalar|sse|avx2|neon|altivec``
 
 *   --enable-jumbo: optional, enables jumbo frames
 
@@ -270,7 +271,7 @@ To enable L3 forwarding between two ports, assuming that both ports are in the s
 
 ..  code-block:: console
 
-    ./build/l3fwd-acl -l 1,2 -n 4 -- -p 0x3 --config="(0,0,1),(1,0,2)" --rule_ipv4="./rule_ipv4.db" -- rule_ipv6="./rule_ipv6.db" --scalar
+    ./build/l3fwd-acl -l 1,2 -n 4 -- -p 0x3 --config="(0,0,1),(1,0,2)" --rule_ipv4="./rule_ipv4.db" -- rule_ipv6="./rule_ipv6.db" --alg=scalar
 
 In this command:
 
@@ -296,7 +297,7 @@ In this command:
 
 *   The --rule_ipv6 option specifies the reading of IPv6 rules sets from the ./ rule_ipv6.db file.
 
-*   The --scalar option specifies the performing of rule lookup with a scalar function.
+*   The --alg=scalar option specifies the performing of rule lookup with a scalar function.
 
 Explanation
 -----------
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index a5b8b11ee1..c27d4025e8 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -146,6 +146,32 @@ static struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
 /* ethernet addresses of ports */
 static struct rte_ether_hdr port_l2hdr[RTE_MAX_ETHPORTS];
 
+static const struct {
+	const char *name;
+	enum rte_acl_classify_alg alg;
+} acl_alg[] = {
+	{
+		.name = "scalar",
+		.alg = RTE_ACL_CLASSIFY_SCALAR,
+	},
+	{
+		.name = "sse",
+		.alg = RTE_ACL_CLASSIFY_SSE,
+	},
+	{
+		.name = "avx2",
+		.alg = RTE_ACL_CLASSIFY_AVX2,
+	},
+	{
+		.name = "neon",
+		.alg = RTE_ACL_CLASSIFY_NEON,
+	},
+	{
+		.name = "altivec",
+		.alg = RTE_ACL_CLASSIFY_ALTIVEC,
+	},
+};
+
 /***********************start of ACL part******************************/
 #ifdef DO_RFC_1812_CHECKS
 static inline int
@@ -166,7 +192,7 @@ send_single_packet(struct rte_mbuf *m, uint16_t port);
 #define OPTION_ENBJMO		"enable-jumbo"
 #define OPTION_RULE_IPV4	"rule_ipv4"
 #define OPTION_RULE_IPV6	"rule_ipv6"
-#define OPTION_SCALAR		"scalar"
+#define OPTION_ALG		"alg"
 #define OPTION_ETH_DEST		"eth-dest"
 #define ACL_DENY_SIGNATURE	0xf0000000
 #define RTE_LOGTYPE_L3FWDACL	RTE_LOGTYPE_USER3
@@ -441,7 +467,7 @@ static struct {
 static struct{
 	const char *rule_ipv4_name;
 	const char *rule_ipv6_name;
-	int scalar;
+	enum rte_acl_classify_alg alg;
 } parm_config;
 
 const char cb_port_delim[] = ":";
@@ -1094,13 +1120,58 @@ add_rules(const char *rule_path,
 	return 0;
 }
 
+static int
+usage_acl_alg(char *buf, size_t sz)
+{
+	uint32_t i, n, rc, tn;
+
+	n = 0;
+	tn = 0;
+	for (i = 0; i < RTE_DIM(acl_alg); i++) {
+		rc = snprintf(buf + n, sz - n,
+			i == RTE_DIM(acl_alg) - 1 ? "%s" : "%s|",
+			acl_alg[i].name);
+		tn += rc;
+		if (rc < sz - n)
+			n += rc;
+	}
+
+	return tn;
+}
+
+static const char *
+str_acl_alg(enum rte_acl_classify_alg alg)
+{
+	uint32_t i;
+
+	for (i = 0; i != RTE_DIM(acl_alg); i++) {
+		if (alg == acl_alg[i].alg)
+			return acl_alg[i].name;
+	}
+
+	return "default";
+}
+
+static enum rte_acl_classify_alg
+parse_acl_alg(const char *alg)
+{
+	uint32_t i;
+
+	for (i = 0; i != RTE_DIM(acl_alg); i++) {
+		if (strcmp(alg, acl_alg[i].name) == 0)
+			return acl_alg[i].alg;
+	}
+
+	return RTE_ACL_CLASSIFY_DEFAULT;
+}
+
 static void
 dump_acl_config(void)
 {
 	printf("ACL option are:\n");
 	printf(OPTION_RULE_IPV4": %s\n", parm_config.rule_ipv4_name);
 	printf(OPTION_RULE_IPV6": %s\n", parm_config.rule_ipv6_name);
-	printf(OPTION_SCALAR": %d\n", parm_config.scalar);
+	printf(OPTION_ALG": %s\n", str_acl_alg(parm_config.alg));
 }
 
 static int
@@ -1141,8 +1212,8 @@ setup_acl(struct rte_acl_rule *route_base,
 	if ((context = rte_acl_create(&acl_param)) == NULL)
 		rte_exit(EXIT_FAILURE, "Failed to create ACL context\n");
 
-	if (parm_config.scalar && rte_acl_set_ctx_classify(context,
-			RTE_ACL_CLASSIFY_SCALAR) != 0)
+	if (parm_config.alg != RTE_ACL_CLASSIFY_DEFAULT &&
+			rte_acl_set_ctx_classify(context, parm_config.alg) != 0)
 		rte_exit(EXIT_FAILURE,
 			"Failed to setup classify method for  ACL context\n");
 
@@ -1525,6 +1596,9 @@ init_lcore_rx_queues(void)
 static void
 print_usage(const char *prgname)
 {
+	char alg[PATH_MAX];
+
+	usage_acl_alg(alg, sizeof(alg));
 	printf("%s [EAL options] -- -p PORTMASK -P"
 		"--"OPTION_RULE_IPV4"=FILE"
 		"--"OPTION_RULE_IPV6"=FILE"
@@ -1546,8 +1620,8 @@ print_usage(const char *prgname)
 		"character '%c'.\n"
 		"  --"OPTION_RULE_IPV6"=FILE: specify the ipv6 rules "
 		"entries file.\n"
-		"  --"OPTION_SCALAR": Use scalar function to do lookup\n",
-		prgname, ACL_LEAD_CHAR, ROUTE_LEAD_CHAR);
+		"  --"OPTION_ALG": ACL classify method to use, one of: %s\n",
+		prgname, ACL_LEAD_CHAR, ROUTE_LEAD_CHAR, alg);
 }
 
 static int
@@ -1656,6 +1730,7 @@ parse_eth_dest(const char *optarg)
 	return NULL;
 }
 
+
 /* Parse the argument given in the command line of the application */
 static int
 parse_args(int argc, char **argv)
@@ -1670,7 +1745,7 @@ parse_args(int argc, char **argv)
 		{OPTION_ENBJMO, 0, 0, 0},
 		{OPTION_RULE_IPV4, 1, 0, 0},
 		{OPTION_RULE_IPV6, 1, 0, 0},
-		{OPTION_SCALAR, 0, 0, 0},
+		{OPTION_ALG, 1, 0, 0},
 		{OPTION_ETH_DEST, 1, 0, 0},
 		{NULL, 0, 0, 0}
 	};
@@ -1764,8 +1839,16 @@ parse_args(int argc, char **argv)
 			}
 
 			if (!strncmp(lgopts[option_index].name,
-					OPTION_SCALAR, sizeof(OPTION_SCALAR)))
-				parm_config.scalar = 1;
+					OPTION_ALG, sizeof(OPTION_ALG))) {
+				parm_config.alg = parse_acl_alg(optarg);
+				if (parm_config.alg ==
+						RTE_ACL_CLASSIFY_DEFAULT) {
+					printf("unknown %s value:\"%s\"\n",
+						OPTION_ALG, optarg);
+					print_usage(prgname);
+					return -1;
+				}
+			}
 
 			if (!strncmp(lgopts[option_index].name, OPTION_ETH_DEST,
 					sizeof(OPTION_ETH_DEST))) {
-- 
2.17.1


  parent reply	other threads:[~2020-10-06 17:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-07 16:39 [dpdk-dev] [PATCH 0/2] Few enhancements for l3fwd-acl Konstantin Ananyev
2020-09-07 16:39 ` [dpdk-dev] [PATCH 1/2] examples/l3fwd-acl: add source and destination MAC update Konstantin Ananyev
2020-09-07 16:39 ` [dpdk-dev] [PATCH 2/2] examples/l3fwd-acl: allow explicitly select classify method Konstantin Ananyev
2020-09-15 17:04 ` [dpdk-dev] [PATCH v2 0/3] Few enhancements for l3fwd-acl Konstantin Ananyev
2020-09-15 17:04   ` [dpdk-dev] [PATCH v2 1/3] examples/l3fwd-acl: add source and destination MAC update Konstantin Ananyev
2020-09-15 17:04   ` [dpdk-dev] [PATCH v2 2/3] examples/l3fwd-acl: allow explicitly select classify method Konstantin Ananyev
2020-09-15 17:04   ` [dpdk-dev] [PATCH v2 3/3] examples/l3fwd-acl: add support for AVX512 Konstantin Ananyev
2020-10-06 17:16   ` [dpdk-dev] [PATCH v3 0/3] Few enhancements for l3fwd-acl Konstantin Ananyev
2020-10-06 17:16     ` [dpdk-dev] [PATCH v3 1/3] examples/l3fwd-acl: add source and destination MAC update Konstantin Ananyev
2020-10-15 11:58       ` David Marchand
2020-10-15 13:06         ` Ananyev, Konstantin
2020-10-16 12:19           ` David Marchand
2020-10-16 13:14             ` Ananyev, Konstantin
2020-10-06 17:16     ` Konstantin Ananyev [this message]
2020-10-06 17:16     ` [dpdk-dev] [PATCH v3 3/3] examples/l3fwd-acl: add support for AVX512 Konstantin Ananyev
2020-10-15 12:11       ` David Marchand
2020-10-15 12:42         ` Ananyev, Konstantin
2020-10-16 13:12     ` [dpdk-dev] [PATCH v4 0/2] Few enhancements for l3fwd-acl Konstantin Ananyev
2020-10-16 13:12       ` [dpdk-dev] [PATCH v4 1/2] examples/l3fwd-acl: add source and destination MAC update Konstantin Ananyev
2020-10-16 13:12       ` [dpdk-dev] [PATCH v4 2/2] examples/l3fwd-acl: allow explicitly select classify method Konstantin Ananyev
2020-10-19  7:03       ` [dpdk-dev] [PATCH v4 0/2] Few enhancements for l3fwd-acl David Marchand

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=20201006171618.19374-3-konstantin.ananyev@intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=dev@dpdk.org \
    /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).