.. 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,
* --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
.. 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:
* 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
-----------
/* 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
#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
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[] = ":";
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
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");
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"
"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
{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}
};
}
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))) {