DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] Few enhancements for l3fwd-acl
@ 2020-09-07 16:39 Konstantin Ananyev
  2020-09-07 16:39 ` [dpdk-dev] [PATCH 1/2] examples/l3fwd-acl: add source and destination MAC update Konstantin Ananyev
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-09-07 16:39 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Konstantin Ananyev (2):
  examples/l3fwd-acl: add source and destination MAC update
  examples/l3fwd-acl: allow explicitly select classify method

 doc/guides/rel_notes/release_20_11.rst        |  10 ++
 .../sample_app_ug/l3_forward_access_ctrl.rst  |  11 +-
 examples/l3fwd-acl/main.c                     | 154 ++++++++++++++++--
 3 files changed, 156 insertions(+), 19 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH 1/2] examples/l3fwd-acl: add source and destination MAC update
  2020-09-07 16:39 [dpdk-dev] [PATCH 0/2] Few enhancements for l3fwd-acl Konstantin Ananyev
@ 2020-09-07 16:39 ` 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
  2 siblings, 0 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-09-07 16:39 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Introduces two changes into l3fwd-acl behaviour to make
it behave in the same way as l3fwd:
 - Add a command-line parameter to allow the user to specify the
   destination mac address for each ethernet port used.
 - While forwarding the packet update source and destination mac
   addresses.

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  |  4 +-
 examples/l3fwd-acl/main.c                     | 51 +++++++++++++++++--
 3 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index df227a177..e9e1fba1c 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Add new command-line parameter for l3wfd-acl sample application.**
+
+  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.
+
 
 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 a44fbcd52..91004356e 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]
+    ./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]
 
 
 where,
@@ -260,6 +260,8 @@ where,
 
 *   --no-numa: optional, disables numa awareness
 
+*   --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet destination for port X
+
 For example, consider a dual processor socket platform with 8 physical cores, where cores 0-7 and 16-23 appear on socket 0,
 while cores 8-15 and 24-31 appear on socket 1.
 
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 112ec3d2c..39175398e 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -39,6 +39,9 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 
+#include <cmdline_parse.h>
+#include <cmdline_parse_etheraddr.h>
+
 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
 #define L3FWDACL_DEBUG
 #endif
@@ -81,9 +84,6 @@
 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
 
-/* ethernet addresses of ports */
-static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
-
 /* mask of enabled ports */
 static uint32_t enabled_port_mask;
 static int promiscuous_on; /**< Ports set in promiscuous mode off by default. */
@@ -143,6 +143,9 @@ static struct rte_eth_conf port_conf = {
 
 static struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
 
+/* ethernet addresses of ports */
+static struct rte_ether_hdr port_l2hdr[RTE_MAX_ETHPORTS];
+
 /***********************start of ACL part******************************/
 #ifdef DO_RFC_1812_CHECKS
 static inline int
@@ -164,6 +167,7 @@ send_single_packet(struct rte_mbuf *m, uint16_t port);
 #define OPTION_RULE_IPV4	"rule_ipv4"
 #define OPTION_RULE_IPV6	"rule_ipv6"
 #define OPTION_SCALAR		"scalar"
+#define OPTION_ETH_DEST		"eth-dest"
 #define ACL_DENY_SIGNATURE	0xf0000000
 #define RTE_LOGTYPE_L3FWDACL	RTE_LOGTYPE_USER3
 #define acl_log(format, ...)	RTE_LOG(ERR, L3FWDACL, format, ##__VA_ARGS__)
@@ -1275,9 +1279,14 @@ send_single_packet(struct rte_mbuf *m, uint16_t port)
 {
 	uint32_t lcore_id;
 	struct lcore_conf *qconf;
+	struct rte_ether_hdr *eh;
 
 	lcore_id = rte_lcore_id();
 
+	/* update src and dst mac*/
+	eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
+	memcpy(eh, &port_l2hdr[port], sizeof(eh->d_addr) + sizeof(eh->s_addr));
+
 	qconf = &lcore_conf[lcore_id];
 	rte_eth_tx_buffer(port, qconf->tx_queue_id[port],
 			qconf->tx_buffer[port], m);
@@ -1627,6 +1636,26 @@ parse_config(const char *q_arg)
 	return 0;
 }
 
+static const char *
+parse_eth_dest(const char *optarg)
+{
+	unsigned long portid;
+	char *port_end;
+
+	errno = 0;
+	portid = strtoul(optarg, &port_end, 0);
+	if (errno != 0 || port_end == optarg || *port_end++ != ',')
+		return "Invalid format";
+	else if (portid >= RTE_MAX_ETHPORTS)
+		return "port value exceeds RTE_MAX_ETHPORTS("
+			RTE_STR(RTE_MAX_ETHPORTS) ")";
+
+	if (cmdline_parse_etheraddr(NULL, port_end, &port_l2hdr[portid].d_addr,
+			sizeof(port_l2hdr[portid].d_addr)) < 0)
+		return "Invalid ethernet address";
+	return NULL;
+}
+
 /* Parse the argument given in the command line of the application */
 static int
 parse_args(int argc, char **argv)
@@ -1642,6 +1671,7 @@ parse_args(int argc, char **argv)
 		{OPTION_RULE_IPV4, 1, 0, 0},
 		{OPTION_RULE_IPV6, 1, 0, 0},
 		{OPTION_SCALAR, 0, 0, 0},
+		{OPTION_ETH_DEST, 1, 0, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -1737,6 +1767,16 @@ parse_args(int argc, char **argv)
 					OPTION_SCALAR, sizeof(OPTION_SCALAR)))
 				parm_config.scalar = 1;
 
+			if (!strncmp(lgopts[option_index].name, OPTION_ETH_DEST,
+					sizeof(OPTION_ETH_DEST))) {
+				const char *serr = parse_eth_dest(optarg);
+				if (serr != NULL) {
+					printf("invalid %s value:\"%s\": %s\n",
+						OPTION_ETH_DEST, optarg, serr);
+					print_usage(prgname);
+					return -1;
+				}
+			}
 
 			break;
 
@@ -1965,13 +2005,14 @@ main(int argc, char **argv)
 				"rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
 				ret, portid);
 
-		ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+		ret = rte_eth_macaddr_get(portid, &port_l2hdr[portid].s_addr);
 		if (ret < 0)
 			rte_exit(EXIT_FAILURE,
 				"rte_eth_macaddr_get: err=%d, port=%d\n",
 				ret, portid);
 
-		print_ethaddr(" Address:", &ports_eth_addr[portid]);
+		print_ethaddr("Dst MAC:", &port_l2hdr[portid].d_addr);
+		print_ethaddr(", Src MAC:", &port_l2hdr[portid].s_addr);
 		printf(", ");
 
 		/* init memory */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH 2/2] examples/l3fwd-acl: allow explicitly select classify method
  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 ` Konstantin Ananyev
  2020-09-15 17:04 ` [dpdk-dev] [PATCH v2 0/3] Few enhancements for l3fwd-acl Konstantin Ananyev
  2 siblings, 0 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-09-07 16:39 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

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 e9e1fba1c..01b1aae2e 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -60,6 +60,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 91004356e..80dd8ba00 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 39175398e..e0f7701cd 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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v2 0/3] Few enhancements for l3fwd-acl
  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 ` Konstantin Ananyev
  2020-09-15 17:04   ` [dpdk-dev] [PATCH v2 1/3] examples/l3fwd-acl: add source and destination MAC update Konstantin Ananyev
                     ` (3 more replies)
  2 siblings, 4 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-09-15 17:04 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Improve l3fwd-acl usability.
Allow to specify destination MAC and explicitly select classify algorithm.

hese patch series depends on:
https://patches.dpdk.org/project/dpdk/list/?series=12241
to be applied first.

Konstantin Ananyev (3):
  examples/l3fwd-acl: add source and destination MAC update
  examples/l3fwd-acl: allow explicitly select classify method
  examples/l3fwd-acl: add support for AVX512

 doc/guides/rel_notes/release_20_11.rst        |  10 ++
 .../sample_app_ug/l3_forward_access_ctrl.rst  |  11 +-
 examples/l3fwd-acl/main.c                     | 158 ++++++++++++++++--
 3 files changed, 160 insertions(+), 19 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v2 1/3] examples/l3fwd-acl: add source and destination MAC update
  2020-09-15 17:04 ` [dpdk-dev] [PATCH v2 0/3] Few enhancements for l3fwd-acl Konstantin Ananyev
@ 2020-09-15 17:04   ` Konstantin Ananyev
  2020-09-15 17:04   ` [dpdk-dev] [PATCH v2 2/3] examples/l3fwd-acl: allow explicitly select classify method Konstantin Ananyev
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-09-15 17:04 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Introduces two changes into l3fwd-acl behaviour to make
it behave in the same way as l3fwd:
 - Add a command-line parameter to allow the user to specify the
   destination mac address for each ethernet port used.
 - While forwarding the packet update source and destination mac
   addresses.

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  |  4 +-
 examples/l3fwd-acl/main.c                     | 51 +++++++++++++++++--
 3 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index acdd12ef9..cfc275f7e 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -60,6 +60,11 @@ New Features
   Added new ``RTE_ACL_CLASSIFY_AVX512`` vector implementation,
   which can processup to 32 flows in parallel. Requires AVX512 support.
 
+* **Add new command-line parameter for l3wfd-acl sample application.**
+
+  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.
+
 
 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 a44fbcd52..91004356e 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]
+    ./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]
 
 
 where,
@@ -260,6 +260,8 @@ where,
 
 *   --no-numa: optional, disables numa awareness
 
+*   --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet destination for port X
+
 For example, consider a dual processor socket platform with 8 physical cores, where cores 0-7 and 16-23 appear on socket 0,
 while cores 8-15 and 24-31 appear on socket 1.
 
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 112ec3d2c..39175398e 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -39,6 +39,9 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 
+#include <cmdline_parse.h>
+#include <cmdline_parse_etheraddr.h>
+
 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
 #define L3FWDACL_DEBUG
 #endif
@@ -81,9 +84,6 @@
 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
 
-/* ethernet addresses of ports */
-static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
-
 /* mask of enabled ports */
 static uint32_t enabled_port_mask;
 static int promiscuous_on; /**< Ports set in promiscuous mode off by default. */
@@ -143,6 +143,9 @@ static struct rte_eth_conf port_conf = {
 
 static struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
 
+/* ethernet addresses of ports */
+static struct rte_ether_hdr port_l2hdr[RTE_MAX_ETHPORTS];
+
 /***********************start of ACL part******************************/
 #ifdef DO_RFC_1812_CHECKS
 static inline int
@@ -164,6 +167,7 @@ send_single_packet(struct rte_mbuf *m, uint16_t port);
 #define OPTION_RULE_IPV4	"rule_ipv4"
 #define OPTION_RULE_IPV6	"rule_ipv6"
 #define OPTION_SCALAR		"scalar"
+#define OPTION_ETH_DEST		"eth-dest"
 #define ACL_DENY_SIGNATURE	0xf0000000
 #define RTE_LOGTYPE_L3FWDACL	RTE_LOGTYPE_USER3
 #define acl_log(format, ...)	RTE_LOG(ERR, L3FWDACL, format, ##__VA_ARGS__)
@@ -1275,9 +1279,14 @@ send_single_packet(struct rte_mbuf *m, uint16_t port)
 {
 	uint32_t lcore_id;
 	struct lcore_conf *qconf;
+	struct rte_ether_hdr *eh;
 
 	lcore_id = rte_lcore_id();
 
+	/* update src and dst mac*/
+	eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
+	memcpy(eh, &port_l2hdr[port], sizeof(eh->d_addr) + sizeof(eh->s_addr));
+
 	qconf = &lcore_conf[lcore_id];
 	rte_eth_tx_buffer(port, qconf->tx_queue_id[port],
 			qconf->tx_buffer[port], m);
@@ -1627,6 +1636,26 @@ parse_config(const char *q_arg)
 	return 0;
 }
 
+static const char *
+parse_eth_dest(const char *optarg)
+{
+	unsigned long portid;
+	char *port_end;
+
+	errno = 0;
+	portid = strtoul(optarg, &port_end, 0);
+	if (errno != 0 || port_end == optarg || *port_end++ != ',')
+		return "Invalid format";
+	else if (portid >= RTE_MAX_ETHPORTS)
+		return "port value exceeds RTE_MAX_ETHPORTS("
+			RTE_STR(RTE_MAX_ETHPORTS) ")";
+
+	if (cmdline_parse_etheraddr(NULL, port_end, &port_l2hdr[portid].d_addr,
+			sizeof(port_l2hdr[portid].d_addr)) < 0)
+		return "Invalid ethernet address";
+	return NULL;
+}
+
 /* Parse the argument given in the command line of the application */
 static int
 parse_args(int argc, char **argv)
@@ -1642,6 +1671,7 @@ parse_args(int argc, char **argv)
 		{OPTION_RULE_IPV4, 1, 0, 0},
 		{OPTION_RULE_IPV6, 1, 0, 0},
 		{OPTION_SCALAR, 0, 0, 0},
+		{OPTION_ETH_DEST, 1, 0, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -1737,6 +1767,16 @@ parse_args(int argc, char **argv)
 					OPTION_SCALAR, sizeof(OPTION_SCALAR)))
 				parm_config.scalar = 1;
 
+			if (!strncmp(lgopts[option_index].name, OPTION_ETH_DEST,
+					sizeof(OPTION_ETH_DEST))) {
+				const char *serr = parse_eth_dest(optarg);
+				if (serr != NULL) {
+					printf("invalid %s value:\"%s\": %s\n",
+						OPTION_ETH_DEST, optarg, serr);
+					print_usage(prgname);
+					return -1;
+				}
+			}
 
 			break;
 
@@ -1965,13 +2005,14 @@ main(int argc, char **argv)
 				"rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
 				ret, portid);
 
-		ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+		ret = rte_eth_macaddr_get(portid, &port_l2hdr[portid].s_addr);
 		if (ret < 0)
 			rte_exit(EXIT_FAILURE,
 				"rte_eth_macaddr_get: err=%d, port=%d\n",
 				ret, portid);
 
-		print_ethaddr(" Address:", &ports_eth_addr[portid]);
+		print_ethaddr("Dst MAC:", &port_l2hdr[portid].d_addr);
+		print_ethaddr(", Src MAC:", &port_l2hdr[portid].s_addr);
 		printf(", ");
 
 		/* init memory */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v2 2/3] examples/l3fwd-acl: allow explicitly select classify method
  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   ` 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
  3 siblings, 0 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-09-15 17:04 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

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 cfc275f7e..1bc41b56d 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -65,6 +65,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 91004356e..80dd8ba00 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 39175398e..e0f7701cd 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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v2 3/3] examples/l3fwd-acl: add support for AVX512
  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   ` Konstantin Ananyev
  2020-10-06 17:16   ` [dpdk-dev] [PATCH v3 0/3] Few enhancements for l3fwd-acl Konstantin Ananyev
  3 siblings, 0 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-09-15 17:04 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Add ability to select AVX512 classify algorithm.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 doc/guides/sample_app_ug/l3_forward_access_ctrl.rst | 2 +-
 examples/l3fwd-acl/main.c                           | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

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 80dd8ba00..6e4d17a2a 100644
--- a/doc/guides/sample_app_ug/l3_forward_access_ctrl.rst
+++ b/doc/guides/sample_app_ug/l3_forward_access_ctrl.rst
@@ -253,7 +253,7 @@ where,
 *   --rule_ipv6 FILENAME: Specifies the IPv6 ACL and route rules file
 
 *   --alg=<val>: optional, ACL classify method to use, one of:
-    ``scalar|sse|avx2|neon|altivec``
+    ``scalar|sse|avx2|neon|altivec|avx512``
 
 *   --enable-jumbo: optional, enables jumbo frames
 
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index e0f7701cd..1a27d9d75 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -170,6 +170,10 @@ static const struct {
 		.name = "altivec",
 		.alg = RTE_ACL_CLASSIFY_ALTIVEC,
 	},
+	{
+		.name = "avx512",
+		.alg = RTE_ACL_CLASSIFY_AVX512,
+	},
 };
 
 /***********************start of ACL part******************************/
-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v3 0/3] Few enhancements for l3fwd-acl
  2020-09-15 17:04 ` [dpdk-dev] [PATCH v2 0/3] Few enhancements for l3fwd-acl Konstantin Ananyev
                     ` (2 preceding siblings ...)
  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   ` Konstantin Ananyev
  2020-10-06 17:16     ` [dpdk-dev] [PATCH v3 1/3] examples/l3fwd-acl: add source and destination MAC update Konstantin Ananyev
                       ` (3 more replies)
  3 siblings, 4 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-10-06 17:16 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Improve l3fwd-acl usability.
Allow to specify destination MAC and explicitly select classify algorithm.

Depends-on: series-12721 ("acl: introduce AVX512 classify methods")

Konstantin Ananyev (3):
  examples/l3fwd-acl: add source and destination MAC update
  examples/l3fwd-acl: allow explicitly select classify method
  examples/l3fwd-acl: add support for AVX512

 doc/guides/rel_notes/release_20_11.rst        |  10 ++
 .../sample_app_ug/l3_forward_access_ctrl.rst  |  11 +-
 examples/l3fwd-acl/main.c                     | 162 ++++++++++++++++--
 3 files changed, 164 insertions(+), 19 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v3 1/3] examples/l3fwd-acl: add source and destination MAC update
  2020-10-06 17:16   ` [dpdk-dev] [PATCH v3 0/3] Few enhancements for l3fwd-acl Konstantin Ananyev
@ 2020-10-06 17:16     ` Konstantin Ananyev
  2020-10-15 11:58       ` David Marchand
  2020-10-06 17:16     ` [dpdk-dev] [PATCH v3 2/3] examples/l3fwd-acl: allow explicitly select classify method Konstantin Ananyev
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 21+ messages in thread
From: Konstantin Ananyev @ 2020-10-06 17:16 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Introduces two changes into l3fwd-acl behaviour to make
it behave in the same way as l3fwd:
 - Add a command-line parameter to allow the user to specify the
   destination mac address for each ethernet port used.
 - While forwarding the packet update source and destination mac
   addresses.

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  |  4 +-
 examples/l3fwd-acl/main.c                     | 51 +++++++++++++++++--
 3 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index fc6c5de8d9..53343c780a 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -119,6 +119,11 @@ New Features
   * Added new ``RTE_ACL_CLASSIFY_AVX512X32`` vector implementation,
     which can process up to 32 flows in parallel. Requires AVX512 support.
 
+* **Add new command-line parameter for l3wfd-acl sample application.**
+
+  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.
+
 
 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 a44fbcd52c..91004356ed 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]
+    ./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]
 
 
 where,
@@ -260,6 +260,8 @@ where,
 
 *   --no-numa: optional, disables numa awareness
 
+*   --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet destination for port X
+
 For example, consider a dual processor socket platform with 8 physical cores, where cores 0-7 and 16-23 appear on socket 0,
 while cores 8-15 and 24-31 appear on socket 1.
 
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 4386584667..a5b8b11ee1 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -39,6 +39,9 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 
+#include <cmdline_parse.h>
+#include <cmdline_parse_etheraddr.h>
+
 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
 #define L3FWDACL_DEBUG
 #endif
@@ -81,9 +84,6 @@
 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
 
-/* ethernet addresses of ports */
-static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
-
 /* mask of enabled ports */
 static uint32_t enabled_port_mask;
 static int promiscuous_on; /**< Ports set in promiscuous mode off by default. */
@@ -143,6 +143,9 @@ static struct rte_eth_conf port_conf = {
 
 static struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
 
+/* ethernet addresses of ports */
+static struct rte_ether_hdr port_l2hdr[RTE_MAX_ETHPORTS];
+
 /***********************start of ACL part******************************/
 #ifdef DO_RFC_1812_CHECKS
 static inline int
@@ -164,6 +167,7 @@ send_single_packet(struct rte_mbuf *m, uint16_t port);
 #define OPTION_RULE_IPV4	"rule_ipv4"
 #define OPTION_RULE_IPV6	"rule_ipv6"
 #define OPTION_SCALAR		"scalar"
+#define OPTION_ETH_DEST		"eth-dest"
 #define ACL_DENY_SIGNATURE	0xf0000000
 #define RTE_LOGTYPE_L3FWDACL	RTE_LOGTYPE_USER3
 #define acl_log(format, ...)	RTE_LOG(ERR, L3FWDACL, format, ##__VA_ARGS__)
@@ -1275,9 +1279,14 @@ send_single_packet(struct rte_mbuf *m, uint16_t port)
 {
 	uint32_t lcore_id;
 	struct lcore_conf *qconf;
+	struct rte_ether_hdr *eh;
 
 	lcore_id = rte_lcore_id();
 
+	/* update src and dst mac*/
+	eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
+	memcpy(eh, &port_l2hdr[port], sizeof(eh->d_addr) + sizeof(eh->s_addr));
+
 	qconf = &lcore_conf[lcore_id];
 	rte_eth_tx_buffer(port, qconf->tx_queue_id[port],
 			qconf->tx_buffer[port], m);
@@ -1627,6 +1636,26 @@ parse_config(const char *q_arg)
 	return 0;
 }
 
+static const char *
+parse_eth_dest(const char *optarg)
+{
+	unsigned long portid;
+	char *port_end;
+
+	errno = 0;
+	portid = strtoul(optarg, &port_end, 0);
+	if (errno != 0 || port_end == optarg || *port_end++ != ',')
+		return "Invalid format";
+	else if (portid >= RTE_MAX_ETHPORTS)
+		return "port value exceeds RTE_MAX_ETHPORTS("
+			RTE_STR(RTE_MAX_ETHPORTS) ")";
+
+	if (cmdline_parse_etheraddr(NULL, port_end, &port_l2hdr[portid].d_addr,
+			sizeof(port_l2hdr[portid].d_addr)) < 0)
+		return "Invalid ethernet address";
+	return NULL;
+}
+
 /* Parse the argument given in the command line of the application */
 static int
 parse_args(int argc, char **argv)
@@ -1642,6 +1671,7 @@ parse_args(int argc, char **argv)
 		{OPTION_RULE_IPV4, 1, 0, 0},
 		{OPTION_RULE_IPV6, 1, 0, 0},
 		{OPTION_SCALAR, 0, 0, 0},
+		{OPTION_ETH_DEST, 1, 0, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -1737,6 +1767,16 @@ parse_args(int argc, char **argv)
 					OPTION_SCALAR, sizeof(OPTION_SCALAR)))
 				parm_config.scalar = 1;
 
+			if (!strncmp(lgopts[option_index].name, OPTION_ETH_DEST,
+					sizeof(OPTION_ETH_DEST))) {
+				const char *serr = parse_eth_dest(optarg);
+				if (serr != NULL) {
+					printf("invalid %s value:\"%s\": %s\n",
+						OPTION_ETH_DEST, optarg, serr);
+					print_usage(prgname);
+					return -1;
+				}
+			}
 
 			break;
 
@@ -1962,13 +2002,14 @@ main(int argc, char **argv)
 				"rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
 				ret, portid);
 
-		ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+		ret = rte_eth_macaddr_get(portid, &port_l2hdr[portid].s_addr);
 		if (ret < 0)
 			rte_exit(EXIT_FAILURE,
 				"rte_eth_macaddr_get: err=%d, port=%d\n",
 				ret, portid);
 
-		print_ethaddr(" Address:", &ports_eth_addr[portid]);
+		print_ethaddr("Dst MAC:", &port_l2hdr[portid].d_addr);
+		print_ethaddr(", Src MAC:", &port_l2hdr[portid].s_addr);
 		printf(", ");
 
 		/* init memory */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] examples/l3fwd-acl: allow explicitly select classify method
  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-06 17:16     ` Konstantin Ananyev
  2020-10-06 17:16     ` [dpdk-dev] [PATCH v3 3/3] examples/l3fwd-acl: add support for AVX512 Konstantin Ananyev
  2020-10-16 13:12     ` [dpdk-dev] [PATCH v4 0/2] Few enhancements for l3fwd-acl Konstantin Ananyev
  3 siblings, 0 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-10-06 17:16 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v3 3/3] examples/l3fwd-acl: add support for AVX512
  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-06 17:16     ` [dpdk-dev] [PATCH v3 2/3] examples/l3fwd-acl: allow explicitly select classify method Konstantin Ananyev
@ 2020-10-06 17:16     ` Konstantin Ananyev
  2020-10-15 12:11       ` David Marchand
  2020-10-16 13:12     ` [dpdk-dev] [PATCH v4 0/2] Few enhancements for l3fwd-acl Konstantin Ananyev
  3 siblings, 1 reply; 21+ messages in thread
From: Konstantin Ananyev @ 2020-10-06 17:16 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Add ability to select AVX512 classify algorithm.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
Depends-on: series-12721 ("acl: introduce AVX512 classify methods")

 doc/guides/sample_app_ug/l3_forward_access_ctrl.rst | 2 +-
 examples/l3fwd-acl/main.c                           | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

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 80dd8ba008..6e4d17a2a8 100644
--- a/doc/guides/sample_app_ug/l3_forward_access_ctrl.rst
+++ b/doc/guides/sample_app_ug/l3_forward_access_ctrl.rst
@@ -253,7 +253,7 @@ where,
 *   --rule_ipv6 FILENAME: Specifies the IPv6 ACL and route rules file
 
 *   --alg=<val>: optional, ACL classify method to use, one of:
-    ``scalar|sse|avx2|neon|altivec``
+    ``scalar|sse|avx2|neon|altivec|avx512x16|avx512x32``
 
 *   --enable-jumbo: optional, enables jumbo frames
 
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index c27d4025e8..cbb92abdb3 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -170,6 +170,14 @@ static const struct {
 		.name = "altivec",
 		.alg = RTE_ACL_CLASSIFY_ALTIVEC,
 	},
+	{
+		.name = "avx512x16",
+		.alg = RTE_ACL_CLASSIFY_AVX512X16,
+	},
+	{
+		.name = "avx512x32",
+		.alg = RTE_ACL_CLASSIFY_AVX512X32,
+	},
 };
 
 /***********************start of ACL part******************************/
-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] examples/l3fwd-acl: add source and destination MAC update
  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
  0 siblings, 1 reply; 21+ messages in thread
From: David Marchand @ 2020-10-15 11:58 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: dev

On Tue, Oct 6, 2020 at 7:17 PM Konstantin Ananyev
<konstantin.ananyev@intel.com> wrote:
>
> Introduces two changes into l3fwd-acl behaviour to make
> it behave in the same way as l3fwd:
>  - Add a command-line parameter to allow the user to specify the
>    destination mac address for each ethernet port used.
>  - While forwarding the packet update source and destination mac
>    addresses.

This new parameter is optional, but I see no default for l2
destination in the patch.
How does it work when you won't set this option?


Bonus question, what keeps us from merging this example with l3fwd?


-- 
David Marchand


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/3] examples/l3fwd-acl: add support for AVX512
  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
  0 siblings, 1 reply; 21+ messages in thread
From: David Marchand @ 2020-10-15 12:11 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: dev

On Tue, Oct 6, 2020 at 7:17 PM Konstantin Ananyev
<konstantin.ananyev@intel.com> wrote:
>
> Add ability to select AVX512 classify algorithm.
>
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

No need to separate this from patch 2, right?


-- 
David Marchand


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/3] examples/l3fwd-acl: add support for AVX512
  2020-10-15 12:11       ` David Marchand
@ 2020-10-15 12:42         ` Ananyev, Konstantin
  0 siblings, 0 replies; 21+ messages in thread
From: Ananyev, Konstantin @ 2020-10-15 12:42 UTC (permalink / raw)
  To: David Marchand; +Cc: dev


> On Tue, Oct 6, 2020 at 7:17 PM Konstantin Ananyev
> <konstantin.ananyev@intel.com> wrote:
> >
> > Add ability to select AVX512 classify algorithm.
> >
> > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 
> No need to separate this from patch 2, right?
> 

Yes, could be squashed into one, I think.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] examples/l3fwd-acl: add source and destination MAC update
  2020-10-15 11:58       ` David Marchand
@ 2020-10-15 13:06         ` Ananyev, Konstantin
  2020-10-16 12:19           ` David Marchand
  0 siblings, 1 reply; 21+ messages in thread
From: Ananyev, Konstantin @ 2020-10-15 13:06 UTC (permalink / raw)
  To: David Marchand; +Cc: dev


> On Tue, Oct 6, 2020 at 7:17 PM Konstantin Ananyev
> <konstantin.ananyev@intel.com> wrote:
> >
> > Introduces two changes into l3fwd-acl behaviour to make
> > it behave in the same way as l3fwd:
> >  - Add a command-line parameter to allow the user to specify the
> >    destination mac address for each ethernet port used.
> >  - While forwarding the packet update source and destination mac
> >    addresses.
> 
> This new parameter is optional, but I see no default for l2
> destination in the patch.
> How does it work when you won't set this option?

Ah yes, forgot to init l2 dst array with some default values.
Will fix and re-spin then.

> 
> 
> Bonus question, what keeps us from merging this example with l3fwd?

Nothing, except the effort required.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] examples/l3fwd-acl: add source and destination MAC update
  2020-10-15 13:06         ` Ananyev, Konstantin
@ 2020-10-16 12:19           ` David Marchand
  2020-10-16 13:14             ` Ananyev, Konstantin
  0 siblings, 1 reply; 21+ messages in thread
From: David Marchand @ 2020-10-16 12:19 UTC (permalink / raw)
  To: Ananyev, Konstantin; +Cc: dev

On Thu, Oct 15, 2020 at 3:06 PM Ananyev, Konstantin
<konstantin.ananyev@intel.com> wrote:
> > On Tue, Oct 6, 2020 at 7:17 PM Konstantin Ananyev
> > <konstantin.ananyev@intel.com> wrote:
> > >
> > > Introduces two changes into l3fwd-acl behaviour to make
> > > it behave in the same way as l3fwd:
> > >  - Add a command-line parameter to allow the user to specify the
> > >    destination mac address for each ethernet port used.
> > >  - While forwarding the packet update source and destination mac
> > >    addresses.
> >
> > This new parameter is optional, but I see no default for l2
> > destination in the patch.
> > How does it work when you won't set this option?
>
> Ah yes, forgot to init l2 dst array with some default values.
> Will fix and re-spin then.

Ok, waiting for it, and squash patch 3 as suggested.
Thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v4 0/2] Few enhancements for l3fwd-acl
  2020-10-06 17:16   ` [dpdk-dev] [PATCH v3 0/3] Few enhancements for l3fwd-acl Konstantin Ananyev
                       ` (2 preceding siblings ...)
  2020-10-06 17:16     ` [dpdk-dev] [PATCH v3 3/3] examples/l3fwd-acl: add support for AVX512 Konstantin Ananyev
@ 2020-10-16 13:12     ` Konstantin Ananyev
  2020-10-16 13:12       ` [dpdk-dev] [PATCH v4 1/2] examples/l3fwd-acl: add source and destination MAC update Konstantin Ananyev
                         ` (2 more replies)
  3 siblings, 3 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-10-16 13:12 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

v3 -> v4:
  Address David comments:
  - squash patches #2 and #3 into one
  - set default values for dest MACs

Improve l3fwd-acl usability.
Allow to specify destination MAC and explicitly select classify algorithm.

Konstantin Ananyev (2):
  examples/l3fwd-acl: add source and destination MAC update
  examples/l3fwd-acl: allow explicitly select classify method

 doc/guides/rel_notes/release_20_11.rst        |  10 +
 .../sample_app_ug/l3_forward_access_ctrl.rst  |  11 +-
 examples/l3fwd-acl/main.c                     | 178 ++++++++++++++++--
 3 files changed, 180 insertions(+), 19 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v4 1/2] examples/l3fwd-acl: add source and destination MAC update
  2020-10-16 13:12     ` [dpdk-dev] [PATCH v4 0/2] Few enhancements for l3fwd-acl Konstantin Ananyev
@ 2020-10-16 13:12       ` 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
  2 siblings, 0 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-10-16 13:12 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

Introduces two changes into l3fwd-acl behaviour to make
it behave in the same way as l3fwd:
   - Add a command-line parameter to allow the user to specify the
     destination mac address for each ethernet port used.
   - While forwarding the packet update source and destination mac
     addresses.

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  |  4 +-
 examples/l3fwd-acl/main.c                     | 67 +++++++++++++++++--
 3 files changed, 70 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index cda5b2f5b2..3b23a9a206 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -276,6 +276,11 @@ New Features
   * Added scatter gather support.
   * Added NIST GCMVS complaint GMAC test method support.
 
+* **Add new command-line parameter for l3wfd-acl sample application.**
+
+  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.
+
 
 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 a44fbcd52c..91004356ed 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]
+    ./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]
 
 
 where,
@@ -260,6 +260,8 @@ where,
 
 *   --no-numa: optional, disables numa awareness
 
+*   --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet destination for port X
+
 For example, consider a dual processor socket platform with 8 physical cores, where cores 0-7 and 16-23 appear on socket 0,
 while cores 8-15 and 24-31 appear on socket 1.
 
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 4386584667..16e9530b3b 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -39,6 +39,9 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 
+#include <cmdline_parse.h>
+#include <cmdline_parse_etheraddr.h>
+
 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
 #define L3FWDACL_DEBUG
 #endif
@@ -81,9 +84,6 @@
 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
 
-/* ethernet addresses of ports */
-static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
-
 /* mask of enabled ports */
 static uint32_t enabled_port_mask;
 static int promiscuous_on; /**< Ports set in promiscuous mode off by default. */
@@ -143,6 +143,9 @@ static struct rte_eth_conf port_conf = {
 
 static struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
 
+/* ethernet addresses of ports */
+static struct rte_ether_hdr port_l2hdr[RTE_MAX_ETHPORTS];
+
 /***********************start of ACL part******************************/
 #ifdef DO_RFC_1812_CHECKS
 static inline int
@@ -164,6 +167,7 @@ send_single_packet(struct rte_mbuf *m, uint16_t port);
 #define OPTION_RULE_IPV4	"rule_ipv4"
 #define OPTION_RULE_IPV6	"rule_ipv6"
 #define OPTION_SCALAR		"scalar"
+#define OPTION_ETH_DEST		"eth-dest"
 #define ACL_DENY_SIGNATURE	0xf0000000
 #define RTE_LOGTYPE_L3FWDACL	RTE_LOGTYPE_USER3
 #define acl_log(format, ...)	RTE_LOG(ERR, L3FWDACL, format, ##__VA_ARGS__)
@@ -1275,9 +1279,14 @@ send_single_packet(struct rte_mbuf *m, uint16_t port)
 {
 	uint32_t lcore_id;
 	struct lcore_conf *qconf;
+	struct rte_ether_hdr *eh;
 
 	lcore_id = rte_lcore_id();
 
+	/* update src and dst mac*/
+	eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
+	memcpy(eh, &port_l2hdr[port], sizeof(eh->d_addr) + sizeof(eh->s_addr));
+
 	qconf = &lcore_conf[lcore_id];
 	rte_eth_tx_buffer(port, qconf->tx_queue_id[port],
 			qconf->tx_buffer[port], m);
@@ -1627,6 +1636,26 @@ parse_config(const char *q_arg)
 	return 0;
 }
 
+static const char *
+parse_eth_dest(const char *optarg)
+{
+	unsigned long portid;
+	char *port_end;
+
+	errno = 0;
+	portid = strtoul(optarg, &port_end, 0);
+	if (errno != 0 || port_end == optarg || *port_end++ != ',')
+		return "Invalid format";
+	else if (portid >= RTE_MAX_ETHPORTS)
+		return "port value exceeds RTE_MAX_ETHPORTS("
+			RTE_STR(RTE_MAX_ETHPORTS) ")";
+
+	if (cmdline_parse_etheraddr(NULL, port_end, &port_l2hdr[portid].d_addr,
+			sizeof(port_l2hdr[portid].d_addr)) < 0)
+		return "Invalid ethernet address";
+	return NULL;
+}
+
 /* Parse the argument given in the command line of the application */
 static int
 parse_args(int argc, char **argv)
@@ -1642,6 +1671,7 @@ parse_args(int argc, char **argv)
 		{OPTION_RULE_IPV4, 1, 0, 0},
 		{OPTION_RULE_IPV6, 1, 0, 0},
 		{OPTION_SCALAR, 0, 0, 0},
+		{OPTION_ETH_DEST, 1, 0, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -1737,6 +1767,16 @@ parse_args(int argc, char **argv)
 					OPTION_SCALAR, sizeof(OPTION_SCALAR)))
 				parm_config.scalar = 1;
 
+			if (!strncmp(lgopts[option_index].name, OPTION_ETH_DEST,
+					sizeof(OPTION_ETH_DEST))) {
+				const char *serr = parse_eth_dest(optarg);
+				if (serr != NULL) {
+					printf("invalid %s value:\"%s\": %s\n",
+						OPTION_ETH_DEST, optarg, serr);
+					print_usage(prgname);
+					return -1;
+				}
+			}
 
 			break;
 
@@ -1862,6 +1902,20 @@ check_all_ports_link_status(uint32_t port_mask)
 	}
 }
 
+/*
+ * build-up default vaues for dest MACs.
+ */
+static void
+set_default_dest_mac(void)
+{
+	uint32_t i;
+
+	for (i = 0; i != RTE_DIM(port_l2hdr); i++) {
+		port_l2hdr[i].d_addr.addr_bytes[0] = RTE_ETHER_LOCAL_ADMIN_ADDR;
+		port_l2hdr[i].d_addr.addr_bytes[5] = i;
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1883,6 +1937,8 @@ main(int argc, char **argv)
 	argc -= ret;
 	argv += ret;
 
+	set_default_dest_mac();
+
 	/* parse application arguments (after the EAL ones) */
 	ret = parse_args(argc, argv);
 	if (ret < 0)
@@ -1962,13 +2018,14 @@ main(int argc, char **argv)
 				"rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
 				ret, portid);
 
-		ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+		ret = rte_eth_macaddr_get(portid, &port_l2hdr[portid].s_addr);
 		if (ret < 0)
 			rte_exit(EXIT_FAILURE,
 				"rte_eth_macaddr_get: err=%d, port=%d\n",
 				ret, portid);
 
-		print_ethaddr(" Address:", &ports_eth_addr[portid]);
+		print_ethaddr("Dst MAC:", &port_l2hdr[portid].d_addr);
+		print_ethaddr(", Src MAC:", &port_l2hdr[portid].s_addr);
 		printf(", ");
 
 		/* init memory */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [dpdk-dev] [PATCH v4 2/2] examples/l3fwd-acl: allow explicitly select classify method
  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       ` Konstantin Ananyev
  2020-10-19  7:03       ` [dpdk-dev] [PATCH v4 0/2] Few enhancements for l3fwd-acl David Marchand
  2 siblings, 0 replies; 21+ messages in thread
From: Konstantin Ananyev @ 2020-10-16 13:12 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev

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                     | 111 ++++++++++++++++--
 3 files changed, 111 insertions(+), 14 deletions(-)

diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index 3b23a9a206..ee5781458b 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -281,6 +281,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..c2d4ca73ab 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|avx512x16|avx512x32``
 
 *   --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 16e9530b3b..4aa325072a 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -146,6 +146,40 @@ 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,
+	},
+	{
+		.name = "avx512x16",
+		.alg = RTE_ACL_CLASSIFY_AVX512X16,
+	},
+	{
+		.name = "avx512x32",
+		.alg = RTE_ACL_CLASSIFY_AVX512X32,
+	},
+};
+
 /***********************start of ACL part******************************/
 #ifdef DO_RFC_1812_CHECKS
 static inline int
@@ -166,7 +200,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 +475,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 +1128,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 +1220,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 +1604,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 +1628,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 +1738,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 +1753,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 +1847,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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] examples/l3fwd-acl: add source and destination MAC update
  2020-10-16 12:19           ` David Marchand
@ 2020-10-16 13:14             ` Ananyev, Konstantin
  0 siblings, 0 replies; 21+ messages in thread
From: Ananyev, Konstantin @ 2020-10-16 13:14 UTC (permalink / raw)
  To: David Marchand; +Cc: dev


> On Thu, Oct 15, 2020 at 3:06 PM Ananyev, Konstantin
> <konstantin.ananyev@intel.com> wrote:
> > > On Tue, Oct 6, 2020 at 7:17 PM Konstantin Ananyev
> > > <konstantin.ananyev@intel.com> wrote:
> > > >
> > > > Introduces two changes into l3fwd-acl behaviour to make
> > > > it behave in the same way as l3fwd:
> > > >  - Add a command-line parameter to allow the user to specify the
> > > >    destination mac address for each ethernet port used.
> > > >  - While forwarding the packet update source and destination mac
> > > >    addresses.
> > >
> > > This new parameter is optional, but I see no default for l2
> > > destination in the patch.
> > > How does it work when you won't set this option?
> >
> > Ah yes, forgot to init l2 dst array with some default values.
> > Will fix and re-spin then.
> 
> Ok, waiting for it, and squash patch 3 as suggested.
> Thanks.
> 

Just sent.
Thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [dpdk-dev] [PATCH v4 0/2] Few enhancements for l3fwd-acl
  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       ` David Marchand
  2 siblings, 0 replies; 21+ messages in thread
From: David Marchand @ 2020-10-19  7:03 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: dev

On Fri, Oct 16, 2020 at 3:13 PM Konstantin Ananyev
<konstantin.ananyev@intel.com> wrote:
>
> v3 -> v4:
>   Address David comments:
>   - squash patches #2 and #3 into one
>   - set default values for dest MACs
>
> Improve l3fwd-acl usability.
> Allow to specify destination MAC and explicitly select classify algorithm.
>
> Konstantin Ananyev (2):
>   examples/l3fwd-acl: add source and destination MAC update
>   examples/l3fwd-acl: allow explicitly select classify method
>
>  doc/guides/rel_notes/release_20_11.rst        |  10 +
>  .../sample_app_ug/l3_forward_access_ctrl.rst  |  11 +-
>  examples/l3fwd-acl/main.c                     | 178 ++++++++++++++++--
>  3 files changed, 180 insertions(+), 19 deletions(-)

Rewrote release notes under a single "l3fwd-acl" entry.
Series applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-10-19  7:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` [dpdk-dev] [PATCH v3 2/3] examples/l3fwd-acl: allow explicitly select classify method Konstantin Ananyev
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

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).