Merge l3fwd-acl and l3fwd
v4 cover Merge l3fwd-acl and l3fwd
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds file read options to build LPM and EM tables.
Ravi Kerur (3):
Merge l3fwd-acl and l3fwd code.
LPM config file read option.
EM config file read option.
examples/l3fwd-acl/Makefile | 56 - examples/l3fwd-acl/main.c | 2079 ------------------------------------- examples/l3fwd/Makefile | 2 +- examples/l3fwd/l3fwd.h | 92 ++ examples/l3fwd/l3fwd_acl.c | 1033 ++++++++++++++++++ examples/l3fwd/l3fwd_acl.h | 234 +++++ examples/l3fwd/l3fwd_acl_scalar.h | 182 ++++ examples/l3fwd/l3fwd_em.c | 390 +++++-- examples/l3fwd/l3fwd_lpm.c | 323 ++++-- examples/l3fwd/main.c | 232 +++-- 10 files changed, 2283 insertions(+), 2340 deletions(-) delete mode 100644 examples/l3fwd-acl/Makefile delete mode 100644 examples/l3fwd-acl/main.c create mode 100644 examples/l3fwd/l3fwd_acl.c create mode 100644 examples/l3fwd/l3fwd_acl.h create mode 100644 examples/l3fwd/l3fwd_acl_scalar.h
Signature · 1 line
2.7.4
PATCH v4 1/3 Merge l3fwd-acl and l3fwd code.
v4:
> Initialize rss_hf to IP for LPM, EM and ACL. > Update rss_hf with l4 in parse_args for ACL. > Fix pending checkpatch code indentation warning.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch errors and warnings related to non strings
greater than 80 characters.
> MACRO GET_CB_FIELD and strings greater than 80 characters
warnings are not fixed.
v1:
l3fwd-acl changes:
> Merge common init code in l3fwd-acl and l3fwd into
main.c.
> Move non-critical inline functions to l3fwd_acl.h. > Move critial packet processing inline functions to
l3fwd_acl_scalar.h
> Move l3fwd-acl init code to l3fwd_acl.c. > Delete l3fwd-acl directory.
l3fwd changes:
> Add '-A' as an option for ACL processing. > Merge parsing options from l3fwd-acl and l3fwd. Retain
l3fwd-acl definitions.
> Move specific setup functions (setup_acl, setup_lpm
and setup_hash).
Testing:
> Compiled successfully for x86_64-native-linuxapp-gcc
> Tested LPM, EM and ACL basic functionality.
--- examples/l3fwd-acl/Makefile | 56 - examples/l3fwd-acl/main.c | 2079 ------------------------------------- examples/l3fwd/Makefile | 2 +- examples/l3fwd/l3fwd.h | 49 + examples/l3fwd/l3fwd_acl.c | 1064 +++++++++++++++++++ examples/l3fwd/l3fwd_acl.h | 263 +++++ examples/l3fwd/l3fwd_acl_scalar.h | 182 ++++ examples/l3fwd/l3fwd_em.c | 14 +- examples/l3fwd/l3fwd_lpm.c | 23 +- examples/l3fwd/main.c | 209 ++-- 10 files changed, 1722 insertions(+), 2219 deletions(-) delete mode 100644 examples/l3fwd-acl/Makefile delete mode 100644 examples/l3fwd-acl/main.c create mode 100644 examples/l3fwd/l3fwd_acl.c create mode 100644 examples/l3fwd/l3fwd_acl.h create mode 100644 examples/l3fwd/l3fwd_acl_scalar.h
examples/l3fwd-acl/Makefile deleted +0 -56
@@ -1,56 +0,0 @@ -# BSD LICENSE -# -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Intel Corporation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overriden by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = l3fwd-acl - -# all source are stored in SRCS-y -SRCS-y := main.c - -CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) - -# workaround for a gcc bug with noreturn attribute -# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 -ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) -CFLAGS_main.o += -Wno-return-type -endif - -include $(RTE_SDK)/mk/rte.extapp.mk
examples/l3fwd-acl/main.c deleted +0 -2079
2,079 lines not on this page · raw message
examples/l3fwd/Makefile +1 -1
@@ -42,7 +42,7 @@ include $(RTE_SDK)/mk/rte.vars.mk APP = l3fwd # all source are stored in SRCS-y -SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c +SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c l3fwd_acl.c CFLAGS += -I$(SRCDIR) CFLAGS += -O3 $(USER_FLAGS)
examples/l3fwd/l3fwd.h +49 -0
95 lines not on this page · raw message
examples/l3fwd/l3fwd_acl.c new file +1064 -0
762 lines not on this page · raw message
examples/l3fwd/l3fwd_acl.h new file +263 -0
263 lines not on this page · raw message
examples/l3fwd/l3fwd_acl_scalar.h new file +182 -0
182 lines not on this page · raw message
examples/l3fwd/main.c +145 -64
209 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.4
Part of the diff is not shown here. View the raw message.
v5 cover examples/l3fwd: merge l3fwd-acl code into l3fwd
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds file read options to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: Merge l3fwd-acl code into l3fwd
examples/l3fwd: add config file support for LPM
examples/l3fwd: add config file support for EM
examples/l3fwd-acl/Makefile | 56 - examples/l3fwd-acl/main.c | 2079 ------------------------------------- examples/l3fwd/Makefile | 2 +- examples/l3fwd/l3fwd.h | 77 ++ examples/l3fwd/l3fwd_acl.c | 1033 ++++++++++++++++++ examples/l3fwd/l3fwd_acl.h | 234 +++++ examples/l3fwd/l3fwd_acl_scalar.h | 182 ++++ examples/l3fwd/l3fwd_em.c | 390 +++++-- examples/l3fwd/l3fwd_lpm.c | 323 ++++-- examples/l3fwd/main.c | 250 +++-- 10 files changed, 2286 insertions(+), 2340 deletions(-) delete mode 100644 examples/l3fwd-acl/Makefile delete mode 100644 examples/l3fwd-acl/main.c create mode 100644 examples/l3fwd/l3fwd_acl.c create mode 100644 examples/l3fwd/l3fwd_acl.h create mode 100644 examples/l3fwd/l3fwd_acl_scalar.h
Signature · 1 line
2.7.4
PATCH v5 1/3 examples/l3fwd: merge l3fwd-acl code into l3fwd
Merge l3fwd-acl code into l3fwd with '-A' cmdline option to run ACL.
v5:
> None.
v4:
> Initialize rss_hf to IP for LPM, EM and ACL. > Update rss_hf with l4 in parse_args for ACL. > Fix pending checkpatch code indentation warning.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch errors and warnings related to non strings
greater than 80 characters.
> MACRO GET_CB_FIELD and strings greater than 80 characters
warnings are not fixed.
v1:
l3fwd-acl changes:
> Merge common init code in l3fwd-acl and l3fwd into
main.c.
> Move non-critical inline functions to l3fwd_acl.h. > Move critial packet processing inline functions to
l3fwd_acl_scalar.h
> Move l3fwd-acl init code to l3fwd_acl.c. > Delete l3fwd-acl directory.
l3fwd changes:
> Add '-A' as an option for ACL processing. > Merge parsing options from l3fwd-acl and l3fwd. Retain
l3fwd-acl definitions.
> Move specific setup functions (setup_acl, setup_lpm
and setup_hash).
Testing:
> Compiled successfully for x86_64-native-linuxapp-gcc
> Tested LPM, EM and ACL basic functionality.
--- examples/l3fwd-acl/Makefile | 56 - examples/l3fwd-acl/main.c | 2079 ------------------------------------- examples/l3fwd/Makefile | 2 +- examples/l3fwd/l3fwd.h | 49 + examples/l3fwd/l3fwd_acl.c | 1064 +++++++++++++++++++ examples/l3fwd/l3fwd_acl.h | 263 +++++ examples/l3fwd/l3fwd_acl_scalar.h | 182 ++++ examples/l3fwd/l3fwd_em.c | 14 +- examples/l3fwd/l3fwd_lpm.c | 23 +- examples/l3fwd/main.c | 209 ++-- 10 files changed, 1722 insertions(+), 2219 deletions(-) delete mode 100644 examples/l3fwd-acl/Makefile delete mode 100644 examples/l3fwd-acl/main.c create mode 100644 examples/l3fwd/l3fwd_acl.c create mode 100644 examples/l3fwd/l3fwd_acl.h create mode 100644 examples/l3fwd/l3fwd_acl_scalar.h
examples/l3fwd-acl/Makefile deleted +0 -56
@@ -1,56 +0,0 @@ -# BSD LICENSE -# -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Intel Corporation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overriden by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = l3fwd-acl - -# all source are stored in SRCS-y -SRCS-y := main.c - -CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) - -# workaround for a gcc bug with noreturn attribute -# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 -ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) -CFLAGS_main.o += -Wno-return-type -endif - -include $(RTE_SDK)/mk/rte.extapp.mk
examples/l3fwd-acl/main.c deleted +0 -2079
2,079 lines not on this page · raw message
examples/l3fwd/Makefile +1 -1
@@ -42,7 +42,7 @@ include $(RTE_SDK)/mk/rte.vars.mk APP = l3fwd # all source are stored in SRCS-y -SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c +SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c l3fwd_acl.c CFLAGS += -I$(SRCDIR) CFLAGS += -O3 $(USER_FLAGS)
examples/l3fwd/l3fwd.h +49 -0
95 lines not on this page · raw message
examples/l3fwd/l3fwd_acl.c new file +1064 -0
762 lines not on this page · raw message
examples/l3fwd/l3fwd_acl.h new file +263 -0
263 lines not on this page · raw message
examples/l3fwd/l3fwd_acl_scalar.h new file +182 -0
182 lines not on this page · raw message
examples/l3fwd/main.c +145 -64
209 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.4
Part of the diff is not shown here. View the raw message.
Re: [PATCH v5 1/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
Quoted 11 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Wednesday, March 8, 2017 9:32 PM
To: [email protected]; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Cc: Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [PATCH v5 1/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
Quoted 1 line
Merge l3fwd-acl code into l3fwd with '-A' cmdline option to run ACL.
Hi Ravi,
The subject line and commit message are okay. the only issue is that the version information should be after a triple dash line so that is doesn't appear in the commit message.
The version information is intended for reviewers so that know what has changed since the last version. Just put the following before it:
---
Quoted 8 lines
v5:
> None.v4:
> Initializerss_hfto IP for LPM, EM and ACL. > Updaterss_hfwith l4 inparse_argsfor ACL. > Fix pending checkpatch code indentation warning.
This applies to all the commit messages.
John
v6 cover examples/l3fwd: merge l3fwd-acl code into l3fwd
In reply to Ravi KerurThis patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exact
examples/l3fwd-acl/Makefile | 56 - examples/l3fwd-acl/main.c | 2079 ------------------------------------- examples/l3fwd/Makefile | 2 +- examples/l3fwd/l3fwd.h | 77 ++ examples/l3fwd/l3fwd_acl.c | 1033 ++++++++++++++++++ examples/l3fwd/l3fwd_acl.h | 234 +++++ examples/l3fwd/l3fwd_acl_scalar.h | 182 ++++ examples/l3fwd/l3fwd_em.c | 390 +++++-- examples/l3fwd/l3fwd_lpm.c | 323 ++++-- examples/l3fwd/main.c | 250 +++-- 10 files changed, 2286 insertions(+), 2340 deletions(-) delete mode 100644 examples/l3fwd-acl/Makefile delete mode 100644 examples/l3fwd-acl/main.c create mode 100644 examples/l3fwd/l3fwd_acl.c create mode 100644 examples/l3fwd/l3fwd_acl.h create mode 100644 examples/l3fwd/l3fwd_acl_scalar.h
Signature · 1 line
2.7.4
PATCH v6 1/3 examples/l3fwd: merge l3fwd-acl code into l3fwd
Merge l3fwd-acl code into l3fwd with '-A' cmdline option to run ACL. Performance critical ACL inline functions are moved from l3fwd-acl/main.c to l3fwd/l3fwd_acl_scalar.h.
---
v6:
> Change commit message format.
v5:
> None.
v4:
> Initialize rss_hf to IP for LPM, EM and ACL. > Update rss_hf with l4 in parse_args for ACL. > Fix pending checkpatch code indentation warning.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch errors and warnings related to non strings
greater than 80 characters.
> MACRO GET_CB_FIELD and strings greater than 80 characters
warnings are not fixed.
v1:
l3fwd-acl changes:
> Merge common init code in l3fwd-acl and l3fwd into main.c. > Move non-critical inline functions to l3fwd_acl.h. > Move critial packet processing inline functions to
l3fwd_acl_scalar.h
> Move l3fwd-acl init code to l3fwd_acl.c.
> Delete l3fwd-acl directory.
l3fwd changes:
> Add '-A' as an option for ACL processing. > Merge parsing options from l3fwd-acl and l3fwd. Retain
l3fwd-acl definitions.
> Move specific setup functions (setup_acl, setup_lpm
and setup_hash).
Testing:
> Compiled successfully for x86_64-native-linuxapp-gcc > Tested LPM, EM and ACL basic functionality.
--- examples/l3fwd-acl/Makefile | 56 - examples/l3fwd-acl/main.c | 2079 ------------------------------------- examples/l3fwd/Makefile | 2 +- examples/l3fwd/l3fwd.h | 49 + examples/l3fwd/l3fwd_acl.c | 1064 +++++++++++++++++++ examples/l3fwd/l3fwd_acl.h | 263 +++++ examples/l3fwd/l3fwd_acl_scalar.h | 182 ++++ examples/l3fwd/l3fwd_em.c | 14 +- examples/l3fwd/l3fwd_lpm.c | 23 +- examples/l3fwd/main.c | 209 ++-- 10 files changed, 1722 insertions(+), 2219 deletions(-) delete mode 100644 examples/l3fwd-acl/Makefile delete mode 100644 examples/l3fwd-acl/main.c create mode 100644 examples/l3fwd/l3fwd_acl.c create mode 100644 examples/l3fwd/l3fwd_acl.h create mode 100644 examples/l3fwd/l3fwd_acl_scalar.h
examples/l3fwd-acl/Makefile deleted +0 -56
@@ -1,56 +0,0 @@ -# BSD LICENSE -# -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Intel Corporation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overriden by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = l3fwd-acl - -# all source are stored in SRCS-y -SRCS-y := main.c - -CFLAGS += -O3 -CFLAGS += $(WERROR_FLAGS) - -# workaround for a gcc bug with noreturn attribute -# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 -ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) -CFLAGS_main.o += -Wno-return-type -endif - -include $(RTE_SDK)/mk/rte.extapp.mk
examples/l3fwd-acl/main.c deleted +0 -2079
2,079 lines not on this page · raw message
examples/l3fwd/Makefile +1 -1
@@ -42,7 +42,7 @@ include $(RTE_SDK)/mk/rte.vars.mk APP = l3fwd # all source are stored in SRCS-y -SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c +SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c l3fwd_acl.c CFLAGS += -I$(SRCDIR) CFLAGS += -O3 $(USER_FLAGS)
examples/l3fwd/l3fwd.h +49 -0
95 lines not on this page · raw message
examples/l3fwd/l3fwd_acl.c new file +1064 -0
762 lines not on this page · raw message
examples/l3fwd/l3fwd_acl.h new file +263 -0
263 lines not on this page · raw message
examples/l3fwd/l3fwd_acl_scalar.h new file +182 -0
182 lines not on this page · raw message
examples/l3fwd/main.c +145 -64
209 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.4
Part of the diff is not shown here. View the raw message.
PATCH v6 2/3 examples/l3fwd: add config file support for lpm
In reply to Ravi KerurAdd support to read from config file to build ipv4 and ipv6 longest prefix match forwarding tables.
---
v6:
> Change commit message format.
v5:
> Change is_bypass_line from inline to non-line.
v4:
> No changes.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch warnings related to code > MACRO GET_CB_FIELD checkpatch warning not fixed
v1:
> Remove static array configuration of Destination IP, MASK and IF_OUT for LPM and LPM6 config. > Add reading configuration from a file. > Format of configuration file is as follows #LPM route entries Dest-IP/Mask IF_OUT L1.1.1.0/24 0 L2.1.1.0/24 1 L3.1.1.0/24 2 ... #LPM6 route entries Dest-IP/Mask IF_OUT L1111:1111:1111:1111:0000:0000:0000:0000/48 0 L2111:1111:1111:1111:0000:0000:0000:0000/48 1 L3111:1111:1111:1111:0000:0000:0000:0000/48 2 ...
--- examples/l3fwd/l3fwd.h | 28 +++++ examples/l3fwd/l3fwd_acl.c | 39 +----- examples/l3fwd/l3fwd_acl.h | 29 ----- examples/l3fwd/l3fwd_lpm.c | 308 +++++++++++++++++++++++++++++++++++++-------- examples/l3fwd/main.c | 47 ++++++- 5 files changed, 332 insertions(+), 119 deletions(-)
examples/l3fwd/l3fwd.h +28 -0
@@ -94,6 +94,29 @@#define ACL_LEAD_CHAR ('@')#define ROUTE_LEAD_CHAR ('R')#define COMMENT_LEAD_CHAR ('#') +#define LPM_LEAD_CHAR ('L') +#define EM_LEAD_CHAR ('E') + +#define IPV6_ADDR_LEN 16 +#define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) +#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) + +#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ + unsigned long val; \ + char *end; \ + errno = 0; \ + val = strtoul((in), &end, (base)); \ + if (errno != 0 || end[0] != (dlm) || val > (lim)) \ + return -EINVAL; \ + (fd) = (typeof(fd))val; \ + (in) = end + 1; \ +} while (0) + +struct parm_cfg { +const char *rule_ipv4_name; +const char *rule_ipv6_name; +int scalar; +};struct mbuf_table {uint16_t len;
@@ -134,6 +157,8 @@ extern xmm_t val_eth[RTE_MAX_ETHPORTS];extern struct lcore_conf lcore_conf[RTE_MAX_LCORE ]; +extern struct parm_cfg parm_config; +extern int numa_on;/**< NUMA is enabled by default. */ /* Send burst of packets on an output interface */
@@ -287,4 +312,7 @@ l3fwd_acl_set_rule_ipv6_name(const char *optarg);void l3fwd_acl_set_rule_ipv4_name (const char *optarg); +int +is_bypass_line (const char *buff); +#endif /* __L3_FWD_H__ */
examples/l3fwd/l3fwd_acl.c +4 -35
@@ -147,10 +147,6 @@ struct rte_acl_field_def ipv4_defs[NUM_FIELDS_IPV4] = { }, }; -#define IPV6_ADDR_LEN 16 -#define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) -#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) -enum {PROTO_FIELD_IPV6 ,SRC1_FIELD_IPV6 ,
@@ -297,12 +293,6 @@ static struct {const char cb_port_delim[] =":" ; -static struct { -const char *rule_ipv4_name; -const char *rule_ipv6_name; -int scalar; -} parm_config; -/* * Print and dump ACL/Route rules functions are defined in * following header file.
@@ -316,27 +306,6 @@ static struct {#include "l3fwd_acl_scalar.h" /* -* API's called during initialization to setup ACL rules. -*/ -void -l3fwd_acl_set_rule_ipv4_name (const char *optarg) -{ - parm_config.rule_ipv4_name = optarg; -} - -void -l3fwd_acl_set_rule_ipv6_name (const char *optarg) -{ - parm_config.rule_ipv6_name = optarg; -} - -void -l3fwd_acl_set_scalar (void ) -{ - parm_config.scalar =1 ; -} - -/* * Parses IPV6 address, exepcts the following format: * XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX (where X - is a hexedecimal digit). */
@@ -566,7 +535,7 @@ parse_cb_ipv4vlan_rule(char *str, struct rte_acl_rule *v, int has_userdata) } static int -add_rules(const char *rule_path, +acl_add_rules(const char *rule_path, struct rte_acl_rule **proute_base, unsigned int *proute_num, struct rte_acl_rule **pacl_base,
@@ -764,8 +733,8 @@ setup_acl(const int socket_id __attribute__((unused)))dump_acl_config (); -/* Load rules from the input file */ -if (add_rules (parm_config.rule_ipv4_name, &route_base_ipv4, +/* Load rules from the input file */ +if (acl_add_rules (parm_config.rule_ipv4_name, &route_base_ipv4, &route_num_ipv4, &acl_base_ipv4, &acl_num_ipv4,sizeof (struct acl4_rule ), &parse_cb_ipv4vlan_rule) <0 )rte_exit (EXIT_FAILURE ,"Failed to add rules\n" );
@@ -776,7 +745,7 @@ setup_acl(const int socket_id __attribute__((unused)))acl_log ("IPv4 ACL entries %u:\n" , acl_num_ipv4);dump_ipv4_rules ((struct acl4_rule *)acl_base_ipv4, acl_num_ipv4,1 ); -if (add_rules (parm_config.rule_ipv6_name, &route_base_ipv6, +if (acl_add_rules (parm_config.rule_ipv6_name, &route_base_ipv6, &route_num_ipv6, &acl_base_ipv6, &acl_num_ipv6,sizeof (struct acl6_rule ), &parse_cb_ipv6_rule) <0 )
examples/l3fwd/l3fwd_acl.h +0 -29
@@ -55,17 +55,6 @@#define MBUF_IPV6_2PROTO (m) \ rte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV62PROTO) -#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ - unsigned long val; \ - char *end; \ - errno = 0; \ - val = strtoul((in), &end, (base)); \ - if (errno != 0 || end[0] != (dlm) || val > (lim)) \ - return -EINVAL; \ - (fd) = (typeof(fd))val; \ - (in) = end + 1; \ -} while (0) -/* * ACL rules should have higher priorities than route ones to ensure ACL rule * always be found when input packets have multi-matches in the database.
@@ -163,24 +152,6 @@ print_one_ipv6_rule(struct acl6_rule *rule, int extra) rule->data.userdata); } -/* Bypass comment and empty lines */ -static inline int -is_bypass_line (char *buff) -{ -int i =0 ; - -/* comment line */ -if (buff[0 ] ==COMMENT_LEAD_CHAR ) -return 1 ; -/* empty line */ -while (buff[i] !='\0' ) { -if (!isspace (buff[i])) -return 0 ; - i++; - } -return 1 ; -} -#ifdef L3FWDACL_DEBUG static inline void dump_acl4_rule (struct rte_mbuf *m,uint32_t sig)
examples/l3fwd/l3fwd_lpm.c +256 -52
370 lines not on this page · raw message
examples/l3fwd/main.c +44 -3
77 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 3/3 examples/l3fwd: add config file support for exact
In reply to Ravi KerurAdd support to read from config file to build ipv4 and ipv6 exact match forwarding tables.
---
v6:
> Change commit message format
v5:
> No changes.
v4:
> No changes.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch warnings.
v1:
> Remove static array configuration of Dest IP,Src IP, Dest port, Src port, Proto and IF_OUT for EM and EM6 config. > Add reading configuration from a file. > Format of configuration file is as follows #EM route entries, #Dest-IP Src-IP Dest-port Src-port Proto IF_OUT E101.0.0.0 100.10.0.0 101 11 0x06 0 E201.0.0.0 200.20.0.0 102 12 0x06 1 E111.0.0.0 211.30.0.0 101 11 0x06 2 ... #EM6 route entries #Dest-IP Src-IP Dest-port Src-port Proto IF_OUT Efe80:0000:0000:0000:021e:67ff:fe00:0000 fe80:0000:0000:0000:021b:21ff:fe91:3805 101 11 0x06 0 Efe90:0000:0000:0000:021e:67ff:fe00:0000 fe90:0000:0000:0000:021b:21ff:fe91:3805 102 12 0x06 1 ...
--- examples/l3fwd/l3fwd_em.c | 376 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 303 insertions(+), 73 deletions(-)
examples/l3fwd/l3fwd_em.c +303 -73
@@ -95,8 +95,14 @@ union ipv4_5tuple_host {#define XMM_NUM_IN_IPV6_5TUPLE 3struct ipv6_5tuple { -uint8_t ip_dst[IPV6_ADDR_LEN ]; -uint8_t ip_src[IPV6_ADDR_LEN ]; +union { +uint8_t ip_dst[IPV6_ADDR_LEN ]; +uint32_t ip32_dst[4 ]; + }; +union { +uint8_t ip_src[IPV6_ADDR_LEN ]; +uint32_t ip32_src[4 ]; + };uint16_t port_dst;uint16_t port_src;uint8_t proto;
@@ -116,47 +122,24 @@ union ipv6_5tuple_host {xmm_t xmm[XMM_NUM_IN_IPV6_5TUPLE ]; }; - - -struct ipv4_l3fwd_em_route { -struct ipv4_5tuple key; -uint8_t if_out; +enum { +CB_FLD_DST_ADDR , +CB_FLD_SRC_ADDR , +CB_FLD_DST_PORT , +CB_FLD_SRC_PORT , +CB_FLD_PROTO , +CB_FLD_IF_OUT , +CB_FLD_MAX }; -struct ipv6_l3fwd_em_route { -struct ipv6_5tuple key; +struct em_rule { +union { +struct ipv4_5tuple v4_key; +struct ipv6_5tuple v6_key; + };uint8_t if_out; }; -static struct ipv4_l3fwd_em_route ipv4_l3fwd_em_route_array[] = { - {{IPv4 (101 ,0 ,0 ,0 ),IPv4 (100 ,10 ,0 ,1 ),101 ,11 ,IPPROTO_TCP },0 }, - {{IPv4 (201 ,0 ,0 ,0 ),IPv4 (200 ,20 ,0 ,1 ),102 ,12 ,IPPROTO_TCP },1 }, - {{IPv4 (111 ,0 ,0 ,0 ),IPv4 (100 ,30 ,0 ,1 ),101 ,11 ,IPPROTO_TCP },2 }, - {{IPv4 (211 ,0 ,0 ,0 ),IPv4 (200 ,40 ,0 ,1 ),102 ,12 ,IPPROTO_TCP },3 }, -}; - -static struct ipv6_l3fwd_em_route ipv6_l3fwd_em_route_array[] = { - {{ - {0xfe ,0x80 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0x80 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -101 ,11 ,IPPROTO_TCP },0 }, - - {{ - {0xfe ,0x90 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0x90 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -102 ,12 ,IPPROTO_TCP },1 }, - - {{ - {0xfe ,0xa0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0xa0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -101 ,11 ,IPPROTO_TCP },2 }, - - {{ - {0xfe ,0xb0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0xb0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -102 ,12 ,IPPROTO_TCP },3 }, -}; -struct rte_hash *ipv4_l3fwd_em_lookup_struct[NB_SOCKETS ];struct rte_hash *ipv6_l3fwd_em_lookup_struct[NB_SOCKETS ];
@@ -233,12 +216,6 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,return init_val; } -#define IPV4_L3FWD_EM_NUM_ROUTES \ - (sizeof(ipv4_l3fwd_em_route_array) / sizeof(ipv4_l3fwd_em_route_array[0])) - -#define IPV6_L3FWD_EM_NUM_ROUTES \ - (sizeof(ipv6_l3fwd_em_route_array) / sizeof(ipv6_l3fwd_em_route_array[0])) - static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned;
@@ -338,6 +315,224 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, void *lookup_struct)#include "l3fwd_em.h" #endif +static int +em_parse_v6_addr (const char *in,const char **end,uint32_t v[IPV6_ADDR_U32 ], +char dlm) +{ +uint32_t addr[IPV6_ADDR_U16 ]; + +GET_CB_FIELD (in, addr[0 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[1 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[2 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[3 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[4 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[5 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[6 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[7 ],16 ,UINT16_MAX , dlm); + + *end = in; + + v[0 ] = (addr[0 ] <<16 ) + addr[1 ]; + v[1 ] = (addr[2 ] <<16 ) + addr[3 ]; + v[2 ] = (addr[4 ] <<16 ) + addr[5 ]; + v[3 ] = (addr[6 ] <<16 ) + addr[7 ]; + +return 0 ; +} + +static int +em_parse_v6_net (const char *in,uint32_t *v) +{ +int32_t rc; +const char *mp; + +/* get address. */ + rc =em_parse_v6_addr (in, &mp, v,0 ); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_addr failed %d\n" , rc); +return rc; + } +return 0 ; +} + +static int +em_parse_v6_rule (char *str,struct em_rule *v) +{ +int i, rc; +char *s, *sp, *in[CB_FLD_MAX ]; +static const char *dlm =" \t\n" ; +int dim =CB_FLD_MAX ; + s = str; + +for (i =0 ; i != dim; i++, s =NULL ) { + in[i] =strtok_r (s, dlm, &sp); +if (in[i] ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"strtok failed\n" ); +return -EINVAL ; + } + } + + rc =em_parse_v6_net (in[CB_FLD_DST_ADDR ], v->v6_key.ip32_dst); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_net failed for dst %d\n" , rc); +return rc; + } + rc =em_parse_v6_net (in[CB_FLD_SRC_ADDR ], v->v6_key.ip32_src); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_net failed for src %d\n" , rc); +return rc; + } +/* source port. */ +GET_CB_FIELD (in[CB_FLD_SRC_PORT ], v->v6_key.port_src,0 ,UINT16_MAX ,0 ); +/* destination port. */ +GET_CB_FIELD (in[CB_FLD_DST_PORT ], v->v6_key.port_dst,0 ,UINT16_MAX ,0 ); +/* protocol. */ +GET_CB_FIELD (in[CB_FLD_PROTO ], v->v6_key.proto,0 ,UINT8_MAX ,0 ); +/* out interface. */ +GET_CB_FIELD (in[CB_FLD_IF_OUT ], v->if_out,0 ,UINT8_MAX ,0 ); + +return 0 ; +} + +static int +em_parse_v4_net (const char *in,uint32_t *addr) +{ +uint8_t a, b, c, d; + +GET_CB_FIELD (in, a,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, b,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, c,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, d,0 ,UINT8_MAX ,0 ); + + addr[0 ] =IPv4 (a, b, c, d); +return 0 ; +} + +static int +em_parse_v4_rule (char *str,struct em_rule *v) +{ +int i, rc; +char *s, *sp, *in[CB_FLD_MAX ]; +static const char *dlm =" \t\n" ; +int dim =CB_FLD_MAX ; + s = str; + +for (i =0 ; i != dim; i++, s =NULL ) { + in[i] =strtok_r (s, dlm, &sp); +if (in[i] ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_rule strtok fail\n" ); +return -EINVAL ; + } + } + + rc =em_parse_v4_net (in[CB_FLD_DST_ADDR ], &(v->v4_key.ip_dst)); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_net dst failed %d\n" , rc); +return rc; + } + rc =em_parse_v4_net (in[CB_FLD_SRC_ADDR ], &(v->v4_key.ip_src)); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_net src failed %d\n" , rc); +return rc; + } +/* source port. */ +GET_CB_FIELD (in[CB_FLD_SRC_PORT ], v->v4_key.port_src,0 ,UINT16_MAX ,0 ); +/* destination port. */ +GET_CB_FIELD (in[CB_FLD_DST_PORT ], v->v4_key.port_dst,0 ,UINT16_MAX ,0 ); +/* protocol. */ +GET_CB_FIELD (in[CB_FLD_PROTO ], v->v4_key.proto,0 ,UINT8_MAX ,0 ); +/* out interface. */ +GET_CB_FIELD (in[CB_FLD_IF_OUT ], v->if_out,0 ,UINT8_MAX ,0 ); + +return 0 ; +} + +static int +em_add_rules (const char *rule_path, +struct em_rule **proute_base, +unsigned int *proute_num, +int (*parser)(char *,struct em_rule *)) +{ +uint8_t *route_rules; +struct em_rule *next; +unsigned int route_num =0 ; +unsigned int route_cnt =0 ; +char buff[LINE_MAX ]; +FILE *fh =fopen (rule_path,"rb" ); +unsigned int i =0 , rule_size =sizeof (*next); + +if (fh ==NULL ) +rte_exit (EXIT_FAILURE ,"%s: Open %s failed\n" , __func__, + rule_path); + +while ((fgets (buff,LINE_MAX , fh) !=NULL )) { +if (buff[0 ] ==EM_LEAD_CHAR ) + route_num++; + } + +if (route_num ==0 ) +rte_exit (EXIT_FAILURE ,"Not find any route entries in %s!\n" , + rule_path); + +fseek (fh,0 ,SEEK_SET ); + + route_rules =calloc (route_num, rule_size); + +if (route_rules ==NULL ) +rte_exit (EXIT_FAILURE ,"%s: failed to malloc memory\n" , + __func__); + + i =0 ; +while (fgets (buff,LINE_MAX , fh) !=NULL ) { + i++; + +if (is_bypass_line (buff)) +continue ; + +char s = buff[0 ]; + +/* Route entry */ +if (s ==EM_LEAD_CHAR ) + next = (struct em_rule *)(route_rules + + route_cnt * rule_size); + +/* Illegal line */ +else +rte_exit (EXIT_FAILURE , +"%s Line %u: should start with leading " +"char %c\n" , + rule_path, i,EM_LEAD_CHAR ); + +if (parser (buff +1 , next) !=0 ) +rte_exit (EXIT_FAILURE , +"%s Line %u: parse rules error\n" , + rule_path, i); + + route_cnt++; + } + +fclose (fh); + + *proute_base = (struct em_rule *)route_rules; + *proute_num = route_cnt; + +return 0 ; +} + +static int +check_em_config (void ) +{ +if (parm_config.rule_ipv4_name ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"EM IPv4 rule file not specified\n" ); +return -1 ; + }else if (parm_config.rule_ipv6_name ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"EM IPv6 rule file not specified\n" ); +return -1 ; + } + +return 0 ; +} +static void convert_ipv4_5tuple (struct ipv4_5tuple *key1,union ipv4_5tuple_host *key2)
@@ -378,16 +573,24 @@ populate_ipv4_few_flow_into_table(const struct rte_hash *h) {uint32_t i;int32_t ret; +struct em_rule *route_base_v4; +unsigned int route_num_v4 =0 ; mask0 = (rte_xmm_t ){.u32 = {BIT_8_TO_15 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; -for (i =0 ; i <IPV4_L3FWD_EM_NUM_ROUTES ; i++) { -struct ipv4_l3fwd_em_route entry; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv4_name, + &route_base_v4, &route_num_v4, + &em_parse_v4_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v4 rules\n" ); + +for (i =0 ; i < route_num_v4; i++) { +struct em_rule entry;union ipv4_5tuple_host newkey; - entry = ipv4_l3fwd_em_route_array[i]; -convert_ipv4_5tuple (&entry.key, &newkey); + entry = route_base_v4[i]; +convert_ipv4_5tuple (&entry.v4_key, &newkey); ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 ) { rte_exit(EXIT_FAILURE, "Unable to add entry %" PRIu32
@@ -396,7 +599,7 @@ populate_ipv4_few_flow_into_table(const struct rte_hash *h) ipv4_l3fwd_out_if[ret] = entry.if_out; }printf ("Hash: Adding 0x%" PRIx64" keys\n" , - (uint64_t )IPV4_L3FWD_EM_NUM_ROUTES ); + (uint64_t )route_num_v4); }#define BIT_16_TO_23 0x00ff0000
@@ -405,18 +608,26 @@ populate_ipv6_few_flow_into_table(const struct rte_hash *h) {uint32_t i;int32_t ret; +struct em_rule *route_base_v6; +unsigned int route_num_v6 =0 ; mask1 = (rte_xmm_t ){.u32 = {BIT_16_TO_23 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; mask2 = (rte_xmm_t ){.u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } }; -for (i =0 ; i <IPV6_L3FWD_EM_NUM_ROUTES ; i++) { -struct ipv6_l3fwd_em_route entry; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv6_name, + &route_base_v6, &route_num_v6, + &em_parse_v6_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v6 rules\n" ); + +for (i =0 ; i < route_num_v6; i++) { +struct em_rule entry;union ipv6_5tuple_host newkey; - entry = ipv6_l3fwd_em_route_array[i]; -convert_ipv6_5tuple (&entry.key, &newkey); + entry = route_base_v6[i]; +convert_ipv6_5tuple (&entry.v6_key, &newkey); ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 ) { rte_exit(EXIT_FAILURE, "Unable to add entry %" PRIu32
@@ -425,7 +636,7 @@ populate_ipv6_few_flow_into_table(const struct rte_hash *h) ipv6_l3fwd_out_if[ret] = entry.if_out; }printf ("Hash: Adding 0x%" PRIx64"keys\n" , - (uint64_t )IPV6_L3FWD_EM_NUM_ROUTES ); + (uint64_t )route_num_v6); }#define NUMBER_PORT_USED 4
@@ -434,12 +645,20 @@ populate_ipv4_many_flow_into_table(const struct rte_hash *h, unsigned int nr_flow) {unsigned i; +struct em_rule *route_base_v4; +unsigned int route_num_v4 =0 ; mask0 = (rte_xmm_t ){.u32 = {BIT_8_TO_15 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv4_name, + &route_base_v4, &route_num_v4, + &em_parse_v4_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v4 rules\n" ); +for (i =0 ; i < nr_flow; i++) { -struct ipv4_l3fwd_em_route entry; +struct em_rule entry;union ipv4_5tuple_host newkey; uint8_t a = (uint8_t)
@@ -453,23 +672,23 @@ populate_ipv4_many_flow_into_table(const struct rte_hash *h,memset (&entry,0 ,sizeof (entry));switch (i & (NUMBER_PORT_USED -1 )) {case 0 : - entry = ipv4_l3fwd_em_route_array[0 ]; - entry.key.ip_dst =IPv4 (101 , c, b, a); + entry = route_base_v4[0 ]; + entry.v4_key.ip_dst =IPv4 (101 , c, b, a);break ;case 1 : - entry = ipv4_l3fwd_em_route_array[1 ]; - entry.key.ip_dst =IPv4 (201 , c, b, a); + entry = route_base_v4[1 ]; + entry.v4_key.ip_dst =IPv4 (201 , c, b, a);break ;case 2 : - entry = ipv4_l3fwd_em_route_array[2 ]; - entry.key.ip_dst =IPv4 (111 , c, b, a); + entry = route_base_v4[2 ]; + entry.v4_key.ip_dst =IPv4 (111 , c, b, a);break ;case 3 : - entry = ipv4_l3fwd_em_route_array[3 ]; - entry.key.ip_dst =IPv4 (211 , c, b, a); + entry = route_base_v4[3 ]; + entry.v4_key.ip_dst =IPv4 (211 , c, b, a);break ; }; -convert_ipv4_5tuple (&entry.key, &newkey); +convert_ipv4_5tuple (&entry.v4_key, &newkey);int32_t ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 )
@@ -486,13 +705,21 @@ populate_ipv6_many_flow_into_table(const struct rte_hash *h, unsigned int nr_flow) {unsigned i; +struct em_rule *route_base_v6; +unsigned int route_num_v6 =0 ; mask1 = (rte_xmm_t ){.u32 = {BIT_16_TO_23 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; mask2 = (rte_xmm_t ){.u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } }; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv6_name, + &route_base_v6, &route_num_v6, + &em_parse_v6_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v6 rules\n" ); +for (i =0 ; i < nr_flow; i++) { -struct ipv6_l3fwd_em_route entry; +struct em_rule entry;union ipv6_5tuple_host newkey; uint8_t a = (uint8_t)
@@ -506,22 +733,22 @@ populate_ipv6_many_flow_into_table(const struct rte_hash *h,memset (&entry,0 ,sizeof (entry));switch (i & (NUMBER_PORT_USED -1 )) {case 0 : - entry = ipv6_l3fwd_em_route_array[0 ]; + entry = route_base_v6[0 ];break ;case 1 : - entry = ipv6_l3fwd_em_route_array[1 ]; + entry = route_base_v6[1 ];break ;case 2 : - entry = ipv6_l3fwd_em_route_array[2 ]; + entry = route_base_v6[2 ];break ;case 3 : - entry = ipv6_l3fwd_em_route_array[3 ]; + entry = route_base_v6[3 ];break ; }; - entry.key.ip_dst[13 ] = c; - entry.key.ip_dst[14 ] = b; - entry.key.ip_dst[15 ] = a; -convert_ipv6_5tuple (&entry.key, &newkey); + entry.v6_key.ip_dst[13 ] = c; + entry.v6_key.ip_dst[14 ] = b; + entry.v6_key.ip_dst[15 ] = a; +convert_ipv6_5tuple (&entry.v6_key, &newkey);int32_t ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 )
@@ -746,6 +973,9 @@ setup_hash(const int socketid)char s[64 ]; +if (check_em_config () !=0 ) +rte_exit (EXIT_FAILURE ,"Failed to get valid EM options\n" ); +/* create ipv4 hash */ snprintf (s,sizeof (s),"ipv4_l3fwd_hash_%d" , socketid); ipv4_l3fwd_hash_params.name = s;
Signature · 1 line
2.7.4
Re: [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
In reply to Ravi Kerur10/03/2017 21:58, Ravi Kerur:
Quoted 7 lines
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exact
Anyone to review please?
Re: [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
In reply to Ravi KerurQuoted 7 lines · rkerur at gmail.com (Ravi Kerur)
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exact
Hi Ravi,
These l3fwd patches are in patchwork for a long time, I am updating the patchset as rejected, if it is still relevant please send a new version on top of latest repo.
Sorry for any inconvenience caused.
For reference patches:
https://patches.dpdk.org/patch/21696/
https://patches.dpdk.org/patch/21695/
https://patches.dpdk.org/patch/21697/
Re: [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
23/01/2019 17:32, Ferruh Yigit:
Quoted 17 lines · rkerur at gmail.com (Ravi Kerur)
Quoted 7 lines
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exactHi Ravi,
These l3fwd patches are in patchwork for a long time, I am updating the patchset as rejected, if it is still relevant please send a new version on top of latest repo.
Sorry for any inconvenience caused.
Quoted 7 lines
For reference patches:
https://patches.dpdk.org/patch/21696/
https://patches.dpdk.org/patch/21695/
https://patches.dpdk.org/patch/21697/
This work was going in the right direction.
Konstantin, as the maintainer of the ACL library,
do you think it is worth to keep this example as standalone or merged?
Re: [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
Quoted 32 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, January 23, 2019 5:11 PM
To: Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Ravi Kerur <[email protected]>; dpdk-dev <[email protected]>; Mcnamara, John <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd23/01/2019 17:32, Ferruh Yigit:
Quoted 22 lines · rkerur at gmail.com (Ravi Kerur)
Quoted 7 lines
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exactHi Ravi,
These l3fwd patches are in patchwork for a long time, I am updating the patchset as rejected, if it is still relevant please send a new version on top of latest repo.
Sorry for any inconvenience caused.
For reference patches:
https://patches.dpdk.org/patch/21696/
https://patches.dpdk.org/patch/21695/
https://patches.dpdk.org/patch/21697/
Quoted 5 lines
Quoted 2 lines
This work was going in the right direction.
Totally agree.
Quoted 2 lines
Konstantin, as the maintainer of the ACL library,
do you think it is worth to keep this example as standalone or merged?
My vote is definitely for merging.
That would give us single l3fwd app with 3 different routing methods (lpm, hash, acl) selectable at run-time, plus routing tables in config file. Konstantin
Re: [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
23/01/2019 18:20, Ananyev, Konstantin:
Quoted 30 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 23 lines
23/01/2019 17:32, Ferruh Yigit:
Quoted 22 lines · rkerur at gmail.com (Ravi Kerur)
Quoted 7 lines
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exactHi Ravi,
These l3fwd patches are in patchwork for a long time, I am updating the patchset as rejected, if it is still relevant please send a new version on top of latest repo.
Sorry for any inconvenience caused.
For reference patches:
https://patches.dpdk.org/patch/21696/
https://patches.dpdk.org/patch/21695/
https://patches.dpdk.org/patch/21697/Quoted 5 lines
Quoted 2 lines
This work was going in the right direction.
Quoted 8 lines
Totally agree.
Quoted 2 lines
Konstantin, as the maintainer of the ACL library,
do you think it is worth to keep this example as standalone or merged?My vote is definitely for merging.
That would give us single l3fwd app with 3 different routing methods (lpm, hash, acl) selectable at run-time, plus routing tables in config file.
OK, so we just need to find a volunteer.
Ravi started the work a long time ago and did not receive enough review. I'm afraid he's not available anymore.
Re: [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
Quoted 33 lines · Thomas Monjalon
23/01/2019 18:20, Ananyev, Konstantin:
Quoted 32 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 23 lines
23/01/2019 17:32, Ferruh Yigit:
Quoted 22 lines · rkerur at gmail.com (Ravi Kerur)
Quoted 7 lines
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exactHi Ravi,
These l3fwd patches are in patchwork for a long time, I am updating the patchset as rejected, if it is still relevant please send a new version on top of latest repo.
Sorry for any inconvenience caused.
For reference patches:
https://patches.dpdk.org/patch/21696/
https://patches.dpdk.org/patch/21695/
https://patches.dpdk.org/patch/21697/Quoted 5 lines
Quoted 2 lines
This work was going in the right direction.
Totally agree.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Konstantin, as the maintainer of the ACL library,
do you think it is worth to keep this example as standalone or merged?My vote is definitely for merging.
That would give us single l3fwd app with 3 different routing methods (lpm, hash, acl) selectable at run-time, plus routing tables in config file.OK, so we just need to find a volunteer.
There was a "Nice to have - Future" section in Roadmap webpage [1], does it help putting there?
Also we talked about GSOC recently, can this be an item for it?
[1]
http://core.dpdk.org/roadmap/#future
Quoted 4 lines
Ravi started the work a long time ago and did not receive enough review. I'm afraid he's not available anymore.
Re: [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
23/01/2019 20:36, Ferruh Yigit:
Quoted 37 lines · Thomas Monjalon
Quoted 36 lines
23/01/2019 18:20, Ananyev, Konstantin:
Quoted 35 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 23 lines
23/01/2019 17:32, Ferruh Yigit:
Quoted 22 lines · rkerur at gmail.com (Ravi Kerur)
Quoted 7 lines
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exactHi Ravi,
These l3fwd patches are in patchwork for a long time, I am updating the patchset as rejected, if it is still relevant please send a new version on top of latest repo.
Sorry for any inconvenience caused.
For reference patches:
https://patches.dpdk.org/patch/21696/
https://patches.dpdk.org/patch/21695/
https://patches.dpdk.org/patch/21697/Quoted 5 lines
Quoted 2 lines
This work was going in the right direction.
Totally agree.
Quoted 2 lines
Konstantin, as the maintainer of the ACL library,
do you think it is worth to keep this example as standalone or merged?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
My vote is definitely for merging.
That would give us single l3fwd app with 3 different routing methods (lpm, hash, acl) selectable at run-time, plus routing tables in config file.OK, so we just need to find a volunteer.
There was a "Nice to have - Future" section in Roadmap webpage [1], does it help putting there?
Yes
Quoted 1 line
Also we talked about GSOC recently, can this be an item for it?
Yes
Good suggestions :)
Re: [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd
In reply to Ananyev, KonstantinHi all,
Quoted 1 line
My vote is definitely for merging.
+1 for this, this seems very reasonable
Regards,
Rami Rosen
Quoted 56 lines · Konstantin
Quoted 33 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, January 23, 2019 5:11 PM
To: Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>
Cc: Ravi Kerur <[email protected]>; dpdk-dev <[email protected]>; Mcnamara, John <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 0/3] examples/l3fwd: merge l3fwd-acl code into l3fwd23/01/2019 17:32, Ferruh Yigit:
Quoted 22 lines · rkerur at gmail.com (Ravi Kerur)
Quoted 7 lines
This patchset merges l3fwd-acl and l3fwd code into common directory. Adds config file read option to build LPM and EM tables.
Ravi Kerur (3):
examples/l3fwd: merge l3fwd-acl code into l3fwd examples/l3fwd: add config file support for lpm examples/l3fwd: add config file support for exactHi Ravi,
These l3fwd patches are in patchwork for a long time, I am updating the patchset as rejected, if it is still relevant please send a new version on top of latest repo.
Sorry for any inconvenience caused.
For reference patches:
https://patches.dpdk.org/patch/21696/
https://patches.dpdk.org/patch/21695/
https://patches.dpdk.org/patch/21697/Quoted 5 lines
Quoted 2 lines
This work was going in the right direction.
Totally agree.
Quoted 2 lines
Konstantin, as the maintainer of the ACL library,
do you think it is worth to keep this example as standalone or merged?My vote is definitely for merging.
That would give us single l3fwd app with 3 different routing methods (lpm, hash, acl) selectable at run-time, plus routing tables in config file. Konstantin
PATCH v5 2/3 examples/l3fwd: add config file support for LPM
In reply to Ravi KerurAdd config file support for v4 and v6 to build forwarding tables.
v5:
> Changes is_bypass_line from inline to non-line.
v4:
> No changes.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch warnings related to code > MACRO GET_CB_FIELD checkpatch warning not fixed
v1:
> Remove static array configuration of Destination IP, MASK and IF_OUT for LPM and LPM6 config. > Add reading configuration from a file. > Format of configuration file is as follows #LPM route entries Dest-IP/Mask IF_OUT L1.1.1.0/24 0 L2.1.1.0/24 1 L3.1.1.0/24 2 ... #LPM6 route entries Dest-IP/Mask IF_OUT L1111:1111:1111:1111:0000:0000:0000:0000/48 0 L2111:1111:1111:1111:0000:0000:0000:0000/48 1 L3111:1111:1111:1111:0000:0000:0000:0000/48 2 ...
--- examples/l3fwd/l3fwd.h | 28 +++++ examples/l3fwd/l3fwd_acl.c | 39 +----- examples/l3fwd/l3fwd_acl.h | 29 ----- examples/l3fwd/l3fwd_lpm.c | 308 +++++++++++++++++++++++++++++++++++++-------- examples/l3fwd/main.c | 47 ++++++- 5 files changed, 332 insertions(+), 119 deletions(-)
examples/l3fwd/l3fwd.h +28 -0
@@ -94,6 +94,29 @@#define ACL_LEAD_CHAR ('@')#define ROUTE_LEAD_CHAR ('R')#define COMMENT_LEAD_CHAR ('#') +#define LPM_LEAD_CHAR ('L') +#define EM_LEAD_CHAR ('E') + +#define IPV6_ADDR_LEN 16 +#define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) +#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) + +#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ + unsigned long val; \ + char *end; \ + errno = 0; \ + val = strtoul((in), &end, (base)); \ + if (errno != 0 || end[0] != (dlm) || val > (lim)) \ + return -EINVAL; \ + (fd) = (typeof(fd))val; \ + (in) = end + 1; \ +} while (0) + +struct parm_cfg { +const char *rule_ipv4_name; +const char *rule_ipv6_name; +int scalar; +};struct mbuf_table {uint16_t len;
@@ -134,6 +157,8 @@ extern xmm_t val_eth[RTE_MAX_ETHPORTS];extern struct lcore_conf lcore_conf[RTE_MAX_LCORE ]; +extern struct parm_cfg parm_config; +extern int numa_on;/**< NUMA is enabled by default. */ /* Send burst of packets on an output interface */
@@ -287,4 +312,7 @@ l3fwd_acl_set_rule_ipv6_name(const char *optarg);void l3fwd_acl_set_rule_ipv4_name (const char *optarg); +int +is_bypass_line (char *buff); +#endif /* __L3_FWD_H__ */
examples/l3fwd/l3fwd_acl.c +4 -35
@@ -147,10 +147,6 @@ struct rte_acl_field_def ipv4_defs[NUM_FIELDS_IPV4] = { }, }; -#define IPV6_ADDR_LEN 16 -#define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) -#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) -enum {PROTO_FIELD_IPV6 ,SRC1_FIELD_IPV6 ,
@@ -297,12 +293,6 @@ static struct {const char cb_port_delim[] =":" ; -static struct { -const char *rule_ipv4_name; -const char *rule_ipv6_name; -int scalar; -} parm_config; -/* * Print and dump ACL/Route rules functions are defined in * following header file.
@@ -316,27 +306,6 @@ static struct {#include "l3fwd_acl_scalar.h" /* -* API's called during initialization to setup ACL rules. -*/ -void -l3fwd_acl_set_rule_ipv4_name (const char *optarg) -{ - parm_config.rule_ipv4_name = optarg; -} - -void -l3fwd_acl_set_rule_ipv6_name (const char *optarg) -{ - parm_config.rule_ipv6_name = optarg; -} - -void -l3fwd_acl_set_scalar (void ) -{ - parm_config.scalar =1 ; -} - -/* * Parses IPV6 address, exepcts the following format: * XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX (where X - is a hexedecimal digit). */
@@ -566,7 +535,7 @@ parse_cb_ipv4vlan_rule(char *str, struct rte_acl_rule *v, int has_userdata) } static int -add_rules(const char *rule_path, +acl_add_rules(const char *rule_path, struct rte_acl_rule **proute_base, unsigned int *proute_num, struct rte_acl_rule **pacl_base,
@@ -764,8 +733,8 @@ setup_acl(const int socket_id __attribute__((unused)))dump_acl_config (); -/* Load rules from the input file */ -if (add_rules (parm_config.rule_ipv4_name, &route_base_ipv4, +/* Load rules from the input file */ +if (acl_add_rules (parm_config.rule_ipv4_name, &route_base_ipv4, &route_num_ipv4, &acl_base_ipv4, &acl_num_ipv4,sizeof (struct acl4_rule ), &parse_cb_ipv4vlan_rule) <0 )rte_exit (EXIT_FAILURE ,"Failed to add rules\n" );
@@ -776,7 +745,7 @@ setup_acl(const int socket_id __attribute__((unused)))acl_log ("IPv4 ACL entries %u:\n" , acl_num_ipv4);dump_ipv4_rules ((struct acl4_rule *)acl_base_ipv4, acl_num_ipv4,1 ); -if (add_rules (parm_config.rule_ipv6_name, &route_base_ipv6, +if (acl_add_rules (parm_config.rule_ipv6_name, &route_base_ipv6, &route_num_ipv6, &acl_base_ipv6, &acl_num_ipv6,sizeof (struct acl6_rule ), &parse_cb_ipv6_rule) <0 )
examples/l3fwd/l3fwd_acl.h +0 -29
@@ -55,17 +55,6 @@#define MBUF_IPV6_2PROTO (m) \ rte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV62PROTO) -#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ - unsigned long val; \ - char *end; \ - errno = 0; \ - val = strtoul((in), &end, (base)); \ - if (errno != 0 || end[0] != (dlm) || val > (lim)) \ - return -EINVAL; \ - (fd) = (typeof(fd))val; \ - (in) = end + 1; \ -} while (0) -/* * ACL rules should have higher priorities than route ones to ensure ACL rule * always be found when input packets have multi-matches in the database.
@@ -163,24 +152,6 @@ print_one_ipv6_rule(struct acl6_rule *rule, int extra) rule->data.userdata); } -/* Bypass comment and empty lines */ -static inline int -is_bypass_line (char *buff) -{ -int i =0 ; - -/* comment line */ -if (buff[0 ] ==COMMENT_LEAD_CHAR ) -return 1 ; -/* empty line */ -while (buff[i] !='\0' ) { -if (!isspace (buff[i])) -return 0 ; - i++; - } -return 1 ; -} -#ifdef L3FWDACL_DEBUG static inline void dump_acl4_rule (struct rte_mbuf *m,uint32_t sig)
examples/l3fwd/l3fwd_lpm.c +256 -52
370 lines not on this page · raw message
examples/l3fwd/main.c +44 -3
77 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 2/3] examples/l3fwd: add config file support for LPM
Quoted 11 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Wednesday, March 8, 2017 9:32 PM
To: [email protected]; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Cc: Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [PATCH v5 2/3] examples/l3fwd: add config file support for LPM
Quoted 1 line
Add config file support for v4 and v6 to build forwarding tables.
Hi Ravi,
The subject line is fine. The body might be better saying IPv4 and IPv6 since I initially thought you were referring to the versions below.
Quoted 6 lines
v5:
> Changesis_bypass_linefrom inline to non-line.v4:
> No changes.
Same comment as before about ---.
John.
PATCH v5 3/3 examples/l3fwd: add config file support for EM
In reply to Ravi KerurAdd config file support for v4 and v6 to build exact match forwarding tables.
v5:
> No changes.
v4:
> No changes.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch warnings.
v1:
> Remove static array configuration of Dest IP,Src IP, Dest port, Src port, Proto and IF_OUT for EM and EM6 config. > Add reading configuration from a file. > Format of configuration file is as follows #EM route entries, #Dest-IP Src-IP Dest-port Src-port Proto IF_OUT E101.0.0.0 100.10.0.0 101 11 0x06 0 E201.0.0.0 200.20.0.0 102 12 0x06 1 E111.0.0.0 211.30.0.0 101 11 0x06 2 ... #EM6 route entries #Dest-IP Src-IP Dest-port Src-port Proto IF_OUT Efe80:0000:0000:0000:021e:67ff:fe00:0000 fe80:0000:0000:0000:021b:21ff:fe91:3805 101 11 0x06 0 Efe90:0000:0000:0000:021e:67ff:fe00:0000 fe90:0000:0000:0000:021b:21ff:fe91:3805 102 12 0x06 1 ...
--- examples/l3fwd/l3fwd_em.c | 376 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 303 insertions(+), 73 deletions(-)
examples/l3fwd/l3fwd_em.c +303 -73
@@ -95,8 +95,14 @@ union ipv4_5tuple_host {#define XMM_NUM_IN_IPV6_5TUPLE 3struct ipv6_5tuple { -uint8_t ip_dst[IPV6_ADDR_LEN ]; -uint8_t ip_src[IPV6_ADDR_LEN ]; +union { +uint8_t ip_dst[IPV6_ADDR_LEN ]; +uint32_t ip32_dst[4 ]; + }; +union { +uint8_t ip_src[IPV6_ADDR_LEN ]; +uint32_t ip32_src[4 ]; + };uint16_t port_dst;uint16_t port_src;uint8_t proto;
@@ -116,47 +122,24 @@ union ipv6_5tuple_host {xmm_t xmm[XMM_NUM_IN_IPV6_5TUPLE ]; }; - - -struct ipv4_l3fwd_em_route { -struct ipv4_5tuple key; -uint8_t if_out; +enum { +CB_FLD_DST_ADDR , +CB_FLD_SRC_ADDR , +CB_FLD_DST_PORT , +CB_FLD_SRC_PORT , +CB_FLD_PROTO , +CB_FLD_IF_OUT , +CB_FLD_MAX }; -struct ipv6_l3fwd_em_route { -struct ipv6_5tuple key; +struct em_rule { +union { +struct ipv4_5tuple v4_key; +struct ipv6_5tuple v6_key; + };uint8_t if_out; }; -static struct ipv4_l3fwd_em_route ipv4_l3fwd_em_route_array[] = { - {{IPv4 (101 ,0 ,0 ,0 ),IPv4 (100 ,10 ,0 ,1 ),101 ,11 ,IPPROTO_TCP },0 }, - {{IPv4 (201 ,0 ,0 ,0 ),IPv4 (200 ,20 ,0 ,1 ),102 ,12 ,IPPROTO_TCP },1 }, - {{IPv4 (111 ,0 ,0 ,0 ),IPv4 (100 ,30 ,0 ,1 ),101 ,11 ,IPPROTO_TCP },2 }, - {{IPv4 (211 ,0 ,0 ,0 ),IPv4 (200 ,40 ,0 ,1 ),102 ,12 ,IPPROTO_TCP },3 }, -}; - -static struct ipv6_l3fwd_em_route ipv6_l3fwd_em_route_array[] = { - {{ - {0xfe ,0x80 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0x80 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -101 ,11 ,IPPROTO_TCP },0 }, - - {{ - {0xfe ,0x90 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0x90 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -102 ,12 ,IPPROTO_TCP },1 }, - - {{ - {0xfe ,0xa0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0xa0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -101 ,11 ,IPPROTO_TCP },2 }, - - {{ - {0xfe ,0xb0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0xb0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -102 ,12 ,IPPROTO_TCP },3 }, -}; -struct rte_hash *ipv4_l3fwd_em_lookup_struct[NB_SOCKETS ];struct rte_hash *ipv6_l3fwd_em_lookup_struct[NB_SOCKETS ];
@@ -233,12 +216,6 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,return init_val; } -#define IPV4_L3FWD_EM_NUM_ROUTES \ - (sizeof(ipv4_l3fwd_em_route_array) / sizeof(ipv4_l3fwd_em_route_array[0])) - -#define IPV6_L3FWD_EM_NUM_ROUTES \ - (sizeof(ipv6_l3fwd_em_route_array) / sizeof(ipv6_l3fwd_em_route_array[0])) - static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned;
@@ -338,6 +315,224 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, void *lookup_struct)#include "l3fwd_em.h" #endif +static int +em_parse_v6_addr (const char *in,const char **end,uint32_t v[IPV6_ADDR_U32 ], +char dlm) +{ +uint32_t addr[IPV6_ADDR_U16 ]; + +GET_CB_FIELD (in, addr[0 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[1 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[2 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[3 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[4 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[5 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[6 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[7 ],16 ,UINT16_MAX , dlm); + + *end = in; + + v[0 ] = (addr[0 ] <<16 ) + addr[1 ]; + v[1 ] = (addr[2 ] <<16 ) + addr[3 ]; + v[2 ] = (addr[4 ] <<16 ) + addr[5 ]; + v[3 ] = (addr[6 ] <<16 ) + addr[7 ]; + +return 0 ; +} + +static int +em_parse_v6_net (const char *in,uint32_t *v) +{ +int32_t rc; +const char *mp; + +/* get address. */ + rc =em_parse_v6_addr (in, &mp, v,0 ); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_addr failed %d\n" , rc); +return rc; + } +return 0 ; +} + +static int +em_parse_v6_rule (char *str,struct em_rule *v) +{ +int i, rc; +char *s, *sp, *in[CB_FLD_MAX ]; +static const char *dlm =" \t\n" ; +int dim =CB_FLD_MAX ; + s = str; + +for (i =0 ; i != dim; i++, s =NULL ) { + in[i] =strtok_r (s, dlm, &sp); +if (in[i] ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"strtok failed\n" ); +return -EINVAL ; + } + } + + rc =em_parse_v6_net (in[CB_FLD_DST_ADDR ], v->v6_key.ip32_dst); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_net failed for dst %d\n" , rc); +return rc; + } + rc =em_parse_v6_net (in[CB_FLD_SRC_ADDR ], v->v6_key.ip32_src); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_net failed for src %d\n" , rc); +return rc; + } +/* source port. */ +GET_CB_FIELD (in[CB_FLD_SRC_PORT ], v->v6_key.port_src,0 ,UINT16_MAX ,0 ); +/* destination port. */ +GET_CB_FIELD (in[CB_FLD_DST_PORT ], v->v6_key.port_dst,0 ,UINT16_MAX ,0 ); +/* protocol. */ +GET_CB_FIELD (in[CB_FLD_PROTO ], v->v6_key.proto,0 ,UINT8_MAX ,0 ); +/* out interface. */ +GET_CB_FIELD (in[CB_FLD_IF_OUT ], v->if_out,0 ,UINT8_MAX ,0 ); + +return 0 ; +} + +static int +em_parse_v4_net (const char *in,uint32_t *addr) +{ +uint8_t a, b, c, d; + +GET_CB_FIELD (in, a,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, b,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, c,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, d,0 ,UINT8_MAX ,0 ); + + addr[0 ] =IPv4 (a, b, c, d); +return 0 ; +} + +static int +em_parse_v4_rule (char *str,struct em_rule *v) +{ +int i, rc; +char *s, *sp, *in[CB_FLD_MAX ]; +static const char *dlm =" \t\n" ; +int dim =CB_FLD_MAX ; + s = str; + +for (i =0 ; i != dim; i++, s =NULL ) { + in[i] =strtok_r (s, dlm, &sp); +if (in[i] ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_rule strtok fail\n" ); +return -EINVAL ; + } + } + + rc =em_parse_v4_net (in[CB_FLD_DST_ADDR ], &(v->v4_key.ip_dst)); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_net dst failed %d\n" , rc); +return rc; + } + rc =em_parse_v4_net (in[CB_FLD_SRC_ADDR ], &(v->v4_key.ip_src)); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_net src failed %d\n" , rc); +return rc; + } +/* source port. */ +GET_CB_FIELD (in[CB_FLD_SRC_PORT ], v->v4_key.port_src,0 ,UINT16_MAX ,0 ); +/* destination port. */ +GET_CB_FIELD (in[CB_FLD_DST_PORT ], v->v4_key.port_dst,0 ,UINT16_MAX ,0 ); +/* protocol. */ +GET_CB_FIELD (in[CB_FLD_PROTO ], v->v4_key.proto,0 ,UINT8_MAX ,0 ); +/* out interface. */ +GET_CB_FIELD (in[CB_FLD_IF_OUT ], v->if_out,0 ,UINT8_MAX ,0 ); + +return 0 ; +} + +static int +em_add_rules (const char *rule_path, +struct em_rule **proute_base, +unsigned int *proute_num, +int (*parser)(char *,struct em_rule *)) +{ +uint8_t *route_rules; +struct em_rule *next; +unsigned int route_num =0 ; +unsigned int route_cnt =0 ; +char buff[LINE_MAX ]; +FILE *fh =fopen (rule_path,"rb" ); +unsigned int i =0 , rule_size =sizeof (*next); + +if (fh ==NULL ) +rte_exit (EXIT_FAILURE ,"%s: Open %s failed\n" , __func__, + rule_path); + +while ((fgets (buff,LINE_MAX , fh) !=NULL )) { +if (buff[0 ] ==EM_LEAD_CHAR ) + route_num++; + } + +if (route_num ==0 ) +rte_exit (EXIT_FAILURE ,"Not find any route entries in %s!\n" , + rule_path); + +fseek (fh,0 ,SEEK_SET ); + + route_rules =calloc (route_num, rule_size); + +if (route_rules ==NULL ) +rte_exit (EXIT_FAILURE ,"%s: failed to malloc memory\n" , + __func__); + + i =0 ; +while (fgets (buff,LINE_MAX , fh) !=NULL ) { + i++; + +if (is_bypass_line (buff)) +continue ; + +char s = buff[0 ]; + +/* Route entry */ +if (s ==EM_LEAD_CHAR ) + next = (struct em_rule *)(route_rules + + route_cnt * rule_size); + +/* Illegal line */ +else +rte_exit (EXIT_FAILURE , +"%s Line %u: should start with leading " +"char %c\n" , + rule_path, i,EM_LEAD_CHAR ); + +if (parser (buff +1 , next) !=0 ) +rte_exit (EXIT_FAILURE , +"%s Line %u: parse rules error\n" , + rule_path, i); + + route_cnt++; + } + +fclose (fh); + + *proute_base = (struct em_rule *)route_rules; + *proute_num = route_cnt; + +return 0 ; +} + +static int +check_em_config (void ) +{ +if (parm_config.rule_ipv4_name ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"EM IPv4 rule file not specified\n" ); +return -1 ; + }else if (parm_config.rule_ipv6_name ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"EM IPv6 rule file not specified\n" ); +return -1 ; + } + +return 0 ; +} +static void convert_ipv4_5tuple (struct ipv4_5tuple *key1,union ipv4_5tuple_host *key2)
@@ -378,16 +573,24 @@ populate_ipv4_few_flow_into_table(const struct rte_hash *h) {uint32_t i;int32_t ret; +struct em_rule *route_base_v4; +unsigned int route_num_v4 =0 ; mask0 = (rte_xmm_t ){.u32 = {BIT_8_TO_15 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; -for (i =0 ; i <IPV4_L3FWD_EM_NUM_ROUTES ; i++) { -struct ipv4_l3fwd_em_route entry; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv4_name, + &route_base_v4, &route_num_v4, + &em_parse_v4_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v4 rules\n" ); + +for (i =0 ; i < route_num_v4; i++) { +struct em_rule entry;union ipv4_5tuple_host newkey; - entry = ipv4_l3fwd_em_route_array[i]; -convert_ipv4_5tuple (&entry.key, &newkey); + entry = route_base_v4[i]; +convert_ipv4_5tuple (&entry.v4_key, &newkey); ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 ) { rte_exit(EXIT_FAILURE, "Unable to add entry %" PRIu32
@@ -396,7 +599,7 @@ populate_ipv4_few_flow_into_table(const struct rte_hash *h) ipv4_l3fwd_out_if[ret] = entry.if_out; }printf ("Hash: Adding 0x%" PRIx64" keys\n" , - (uint64_t )IPV4_L3FWD_EM_NUM_ROUTES ); + (uint64_t )route_num_v4); }#define BIT_16_TO_23 0x00ff0000
@@ -405,18 +608,26 @@ populate_ipv6_few_flow_into_table(const struct rte_hash *h) {uint32_t i;int32_t ret; +struct em_rule *route_base_v6; +unsigned int route_num_v6 =0 ; mask1 = (rte_xmm_t ){.u32 = {BIT_16_TO_23 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; mask2 = (rte_xmm_t ){.u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } }; -for (i =0 ; i <IPV6_L3FWD_EM_NUM_ROUTES ; i++) { -struct ipv6_l3fwd_em_route entry; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv6_name, + &route_base_v6, &route_num_v6, + &em_parse_v6_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v6 rules\n" ); + +for (i =0 ; i < route_num_v6; i++) { +struct em_rule entry;union ipv6_5tuple_host newkey; - entry = ipv6_l3fwd_em_route_array[i]; -convert_ipv6_5tuple (&entry.key, &newkey); + entry = route_base_v6[i]; +convert_ipv6_5tuple (&entry.v6_key, &newkey); ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 ) { rte_exit(EXIT_FAILURE, "Unable to add entry %" PRIu32
@@ -425,7 +636,7 @@ populate_ipv6_few_flow_into_table(const struct rte_hash *h) ipv6_l3fwd_out_if[ret] = entry.if_out; }printf ("Hash: Adding 0x%" PRIx64"keys\n" , - (uint64_t )IPV6_L3FWD_EM_NUM_ROUTES ); + (uint64_t )route_num_v6); }#define NUMBER_PORT_USED 4
@@ -434,12 +645,20 @@ populate_ipv4_many_flow_into_table(const struct rte_hash *h, unsigned int nr_flow) {unsigned i; +struct em_rule *route_base_v4; +unsigned int route_num_v4 =0 ; mask0 = (rte_xmm_t ){.u32 = {BIT_8_TO_15 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv4_name, + &route_base_v4, &route_num_v4, + &em_parse_v4_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v4 rules\n" ); +for (i =0 ; i < nr_flow; i++) { -struct ipv4_l3fwd_em_route entry; +struct em_rule entry;union ipv4_5tuple_host newkey; uint8_t a = (uint8_t)
@@ -453,23 +672,23 @@ populate_ipv4_many_flow_into_table(const struct rte_hash *h,memset (&entry,0 ,sizeof (entry));switch (i & (NUMBER_PORT_USED -1 )) {case 0 : - entry = ipv4_l3fwd_em_route_array[0 ]; - entry.key.ip_dst =IPv4 (101 , c, b, a); + entry = route_base_v4[0 ]; + entry.v4_key.ip_dst =IPv4 (101 , c, b, a);break ;case 1 : - entry = ipv4_l3fwd_em_route_array[1 ]; - entry.key.ip_dst =IPv4 (201 , c, b, a); + entry = route_base_v4[1 ]; + entry.v4_key.ip_dst =IPv4 (201 , c, b, a);break ;case 2 : - entry = ipv4_l3fwd_em_route_array[2 ]; - entry.key.ip_dst =IPv4 (111 , c, b, a); + entry = route_base_v4[2 ]; + entry.v4_key.ip_dst =IPv4 (111 , c, b, a);break ;case 3 : - entry = ipv4_l3fwd_em_route_array[3 ]; - entry.key.ip_dst =IPv4 (211 , c, b, a); + entry = route_base_v4[3 ]; + entry.v4_key.ip_dst =IPv4 (211 , c, b, a);break ; }; -convert_ipv4_5tuple (&entry.key, &newkey); +convert_ipv4_5tuple (&entry.v4_key, &newkey);int32_t ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 )
@@ -486,13 +705,21 @@ populate_ipv6_many_flow_into_table(const struct rte_hash *h, unsigned int nr_flow) {unsigned i; +struct em_rule *route_base_v6; +unsigned int route_num_v6 =0 ; mask1 = (rte_xmm_t ){.u32 = {BIT_16_TO_23 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; mask2 = (rte_xmm_t ){.u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } }; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv6_name, + &route_base_v6, &route_num_v6, + &em_parse_v6_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v6 rules\n" ); +for (i =0 ; i < nr_flow; i++) { -struct ipv6_l3fwd_em_route entry; +struct em_rule entry;union ipv6_5tuple_host newkey; uint8_t a = (uint8_t)
@@ -506,22 +733,22 @@ populate_ipv6_many_flow_into_table(const struct rte_hash *h,memset (&entry,0 ,sizeof (entry));switch (i & (NUMBER_PORT_USED -1 )) {case 0 : - entry = ipv6_l3fwd_em_route_array[0 ]; + entry = route_base_v6[0 ];break ;case 1 : - entry = ipv6_l3fwd_em_route_array[1 ]; + entry = route_base_v6[1 ];break ;case 2 : - entry = ipv6_l3fwd_em_route_array[2 ]; + entry = route_base_v6[2 ];break ;case 3 : - entry = ipv6_l3fwd_em_route_array[3 ]; + entry = route_base_v6[3 ];break ; }; - entry.key.ip_dst[13 ] = c; - entry.key.ip_dst[14 ] = b; - entry.key.ip_dst[15 ] = a; -convert_ipv6_5tuple (&entry.key, &newkey); + entry.v6_key.ip_dst[13 ] = c; + entry.v6_key.ip_dst[14 ] = b; + entry.v6_key.ip_dst[15 ] = a; +convert_ipv6_5tuple (&entry.v6_key, &newkey);int32_t ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 )
@@ -746,6 +973,9 @@ setup_hash(const int socketid)char s[64 ]; +if (check_em_config () !=0 ) +rte_exit (EXIT_FAILURE ,"Failed to get valid EM options\n" ); +/* create ipv4 hash */ snprintf (s,sizeof (s),"ipv4_l3fwd_hash_%d" , socketid); ipv4_l3fwd_hash_params.name = s;
Signature · 1 line
2.7.4
Re: [PATCH v5 3/3] examples/l3fwd: add config file support for EM
Quoted 11 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Wednesday, March 8, 2017 9:32 PM
To: [email protected]; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Cc: Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [PATCH v5 3/3] examples/l3fwd: add config file support for EM
Quoted 2 lines
Add config file support for v4 and v6 to build exact match forwarding tables.
Hi Ravi,
Same comment about Ipv4 and IPv6 and ---.
Also it is probably better to use "exact match" instead of "EM" in the subject. It isn't as well known an acronym as LPM.
John
Re: [PATCH v5 3/3] examples/l3fwd: add config file support for EM
Hi John,
Quoted 15 lines · John
Quoted 9 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Wednesday, March 8, 2017 9:32 PM
To: [email protected]; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Cc: Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [PATCH v5 3/3] examples/l3fwd: add config filesupport
Quoted 4 lines
for EM
Add config file support for v4 and v6 to build exact match forwarding tables.
Quoted 8 lines
Hi Ravi,
Same comment about Ipv4 and IPv6 and ---.
Also it is probably better to use "exact match" instead of "EM" in the subject. It isn't as well known an acronym as LPM.
I will make changes to all patches and send out updated version.
Thanks.
Quoted 2 lines
John
PATCH v4 2/3 LPM config file read option.
In reply to Ravi Kerurv4:
> No changes.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch warnings related to code > MACRO GET_CB_FIELD checkpatch warning not fixed
v1:
> Remove static array configuration of Destination IP, MASK and IF_OUT for LPM and LPM6 config. > Add reading configuration from a file. > Format of configuration file is as follows #LPM route entries Dest-IP/Mask IF_OUT L1.1.1.0/24 0 L2.1.1.0/24 1 L3.1.1.0/24 2 ... #LPM6 route entries Dest-IP/Mask IF_OUT L1111:1111:1111:1111:0000:0000:0000:0000/48 0 L2111:1111:1111:1111:0000:0000:0000:0000/48 1 L3111:1111:1111:1111:0000:0000:0000:0000/48 2 ...
--- examples/l3fwd/l3fwd.h | 43 +++++++ examples/l3fwd/l3fwd_acl.c | 39 +----- examples/l3fwd/l3fwd_acl.h | 29 ----- examples/l3fwd/l3fwd_lpm.c | 308 +++++++++++++++++++++++++++++++++++++-------- examples/l3fwd/main.c | 29 ++++- 5 files changed, 329 insertions(+), 119 deletions(-)
examples/l3fwd/l3fwd.h +43 -0
@@ -94,6 +94,47 @@#define ACL_LEAD_CHAR ('@')#define ROUTE_LEAD_CHAR ('R')#define COMMENT_LEAD_CHAR ('#') +#define LPM_LEAD_CHAR ('L') +#define EM_LEAD_CHAR ('E') + +#define IPV6_ADDR_LEN 16 +#define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) +#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) + +#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ + unsigned long val; \ + char *end; \ + errno = 0; \ + val = strtoul((in), &end, (base)); \ + if (errno != 0 || end[0] != (dlm) || val > (lim)) \ + return -EINVAL; \ + (fd) = (typeof(fd))val; \ + (in) = end + 1; \ +} while (0) + +/* Bypass comment and empty lines */ +static inline int +is_bypass_line (char *buff) +{ +int i =0 ; + +/* comment line */ +if (buff[0 ] ==COMMENT_LEAD_CHAR ) +return 1 ; +/* empty line */ +while (buff[i] !='\0' ) { +if (!isspace (buff[i])) +return 0 ; + i++; + } +return 1 ; +} + +struct parm_cfg { +const char *rule_ipv4_name; +const char *rule_ipv6_name; +int scalar; +};struct mbuf_table {uint16_t len;
@@ -134,6 +175,8 @@ extern xmm_t val_eth[RTE_MAX_ETHPORTS];extern struct lcore_conf lcore_conf[RTE_MAX_LCORE ]; +extern struct parm_cfg parm_config; +extern int numa_on;/**< NUMA is enabled by default. */ /* Send burst of packets on an output interface */
examples/l3fwd/l3fwd_acl.c +4 -35
@@ -147,10 +147,6 @@ struct rte_acl_field_def ipv4_defs[NUM_FIELDS_IPV4] = { }, }; -#define IPV6_ADDR_LEN 16 -#define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) -#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) -enum {PROTO_FIELD_IPV6 ,SRC1_FIELD_IPV6 ,
@@ -297,12 +293,6 @@ static struct {const char cb_port_delim[] =":" ; -static struct { -const char *rule_ipv4_name; -const char *rule_ipv6_name; -int scalar; -} parm_config; -/* * Print and dump ACL/Route rules functions are defined in * following header file.
@@ -316,27 +306,6 @@ static struct {#include "l3fwd_acl_scalar.h" /* -* API's called during initialization to setup ACL rules. -*/ -void -l3fwd_acl_set_rule_ipv4_name (const char *optarg) -{ - parm_config.rule_ipv4_name = optarg; -} - -void -l3fwd_acl_set_rule_ipv6_name (const char *optarg) -{ - parm_config.rule_ipv6_name = optarg; -} - -void -l3fwd_acl_set_scalar (void ) -{ - parm_config.scalar =1 ; -} - -/* * Parses IPV6 address, exepcts the following format: * XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX (where X - is a hexedecimal digit). */
@@ -566,7 +535,7 @@ parse_cb_ipv4vlan_rule(char *str, struct rte_acl_rule *v, int has_userdata) } static int -add_rules(const char *rule_path, +acl_add_rules(const char *rule_path, struct rte_acl_rule **proute_base, unsigned int *proute_num, struct rte_acl_rule **pacl_base,
@@ -764,8 +733,8 @@ setup_acl(const int socket_id __attribute__((unused)))dump_acl_config (); -/* Load rules from the input file */ -if (add_rules (parm_config.rule_ipv4_name, &route_base_ipv4, +/* Load rules from the input file */ +if (acl_add_rules (parm_config.rule_ipv4_name, &route_base_ipv4, &route_num_ipv4, &acl_base_ipv4, &acl_num_ipv4,sizeof (struct acl4_rule ), &parse_cb_ipv4vlan_rule) <0 )rte_exit (EXIT_FAILURE ,"Failed to add rules\n" );
@@ -776,7 +745,7 @@ setup_acl(const int socket_id __attribute__((unused)))acl_log ("IPv4 ACL entries %u:\n" , acl_num_ipv4);dump_ipv4_rules ((struct acl4_rule *)acl_base_ipv4, acl_num_ipv4,1 ); -if (add_rules (parm_config.rule_ipv6_name, &route_base_ipv6, +if (acl_add_rules (parm_config.rule_ipv6_name, &route_base_ipv6, &route_num_ipv6, &acl_base_ipv6, &acl_num_ipv6,sizeof (struct acl6_rule ), &parse_cb_ipv6_rule) <0 )
examples/l3fwd/l3fwd_acl.h +0 -29
@@ -55,17 +55,6 @@#define MBUF_IPV6_2PROTO (m) \ rte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV62PROTO) -#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ - unsigned long val; \ - char *end; \ - errno = 0; \ - val = strtoul((in), &end, (base)); \ - if (errno != 0 || end[0] != (dlm) || val > (lim)) \ - return -EINVAL; \ - (fd) = (typeof(fd))val; \ - (in) = end + 1; \ -} while (0) -/* * ACL rules should have higher priorities than route ones to ensure ACL rule * always be found when input packets have multi-matches in the database.
@@ -163,24 +152,6 @@ print_one_ipv6_rule(struct acl6_rule *rule, int extra) rule->data.userdata); } -/* Bypass comment and empty lines */ -static inline int -is_bypass_line (char *buff) -{ -int i =0 ; - -/* comment line */ -if (buff[0 ] ==COMMENT_LEAD_CHAR ) -return 1 ; -/* empty line */ -while (buff[i] !='\0' ) { -if (!isspace (buff[i])) -return 0 ; - i++; - } -return 1 ; -} -#ifdef L3FWDACL_DEBUG static inline void dump_acl4_rule (struct rte_mbuf *m,uint32_t sig)
examples/l3fwd/l3fwd_lpm.c +256 -52
370 lines not on this page · raw message
examples/l3fwd/main.c +26 -3
@@ -126,6 +126,8 @@ uint32_t hash_entry_number = HASH_ENTRY_NUMBER_DEFAULT;struct lcore_conf lcore_conf[RTE_MAX_LCORE ]; +struct parm_cfg parm_config; +struct lcore_params {uint8_t port_id;uint8_t queue_id;
@@ -212,6 +214,27 @@ static struct l3fwd_lkp_mode l3fwd_acl_lkp = { };/* +* API's called during initialization to setup ACL/LPM/EM rules. +*/ +static void +l3fwd_set_rule_ipv4_name (const char *optarg) +{ + parm_config.rule_ipv4_name = optarg; +} + +static void +l3fwd_set_rule_ipv6_name (const char *optarg) +{ + parm_config.rule_ipv6_name = optarg; +} + +static void +l3fwd_set_scalar (void ) +{ + parm_config.scalar =1 ; +} + +/* * Setup lookup methods for forwarding. * Currently exact-match and longest-prefix-match * are supported ones.
@@ -689,15 +712,15 @@ parse_args(int argc, char **argv)break ;case CMD_LINE_OPT_RULE_IPV4 : -l3fwd_acl_set_rule_ipv4_name (optarg); +l3fwd_set_rule_ipv4_name (optarg);break ;case CMD_LINE_OPT_RULE_IPV6 : -l3fwd_acl_set_rule_ipv6_name (optarg); +l3fwd_set_rule_ipv6_name (optarg);break ;case CMD_LINE_OPT_SCALAR : -l3fwd_acl_set_scalar (); +l3fwd_set_scalar ();break ;default :
Signature · 1 line
2.7.4
Re: [v4 2/3] LPM config file read option.
Quoted 16 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Sunday, March 5, 2017 7:47 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>; Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [v4 2/3] LPM config file read option....
examples/l3fwd/l3fwd.h +5
-0+ +#define IPV6_ADDR_LEN 16 +#define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) +#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) +
examples/l3fwd/l3fwd.h line 113
Quoted 10 lines
examples/l3fwd/l3fwd.h +10
-0+#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ + unsigned long val; \ + char *end; \ + errno = 0; \ + val = strtoul((in), &end, (base)); \ + if (errno != 0 || end[0] != (dlm) || val > (lim)) \ + return -EINVAL; \ + (fd) = (typeof(fd))val; \ + (in) = end + 1; \ +} while (0)
Hi,
It is probably worth putting a comment before this macro to explain what it does. Also, it isn't clear, to me, what CB stands for. Also, having a return in the middle of the macro might be problematic if it is used in a function with a different, or not, return value.
John
Re: [v4 2/3] LPM config file read option.
Quoted 39 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Mcnamara, John
Sent: Monday, March 6, 2017 1:57 PM
To: Ravi Kerur <[email protected]>; [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: Re: [dpdk-dev] [v4 2/3] LPM config file read option.Quoted 14 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Sunday, March 5, 2017 7:47 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>; Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [v4 2/3] LPM config file read option....
examples/l3fwd/l3fwd.h +5
-0+ +#define IPV6_ADDR_LEN 16 +#define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) +#define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) +examples/l3fwd/l3fwd.h line 113
Quoted 10 lines
examples/l3fwd/l3fwd.h +10
-0+#define GET_CB_FIELD (in, fd, base, lim, dlm) do { \ + unsigned long val; \ + char *end; \ + errno = 0; \ + val = strtoul((in), &end, (base)); \ + if (errno != 0 || end[0] != (dlm) || val > (lim)) \ + return -EINVAL; \ + (fd) = (typeof(fd))val; \ + (in) = end + 1; \ +} while (0)Hi,
Quoted 5 lines
It is probably worth putting a comment before this macro to explain what it does. Also, it isn't clear, to me, what CB stands for. Also, having a return in the middle of the macro might be problematic if it is used in a function with a different, or not, return value.
Nevermind. I see that this macro was already there and you just moved it. So, it is not your problem. :-)
John
PATCH v4 3/3 EM config file read option.
In reply to Ravi Kerurv4:
> No changes.
v3:
> Fix additional checkpatch coding style issues.
v2:
> Fix checkpatch warnings.
v1:
> Remove static array configuration of Dest IP,Src IP, Dest
port, Src port, Proto and IF_OUT for EM and EM6 config.
> Add reading configuration from a file.
> Format of configuration file is as follows
#EM route entries,
#Dest-IP Src-IP Dest-port Src-port Proto IF_OUT
E101.0.0.0 100.10.0.0 101 11 0x06 0
E201.0.0.0 200.20.0.0 102 12 0x06 1
E111.0.0.0 211.30.0.0 101 11 0x06 2
...
#EM6 route entries
#Dest-IP Src-IP Dest-port Src-port Proto IF_OUT
Efe80:0000:0000:0000:021e:67ff:fe00:0000
fe80:0000:0000:0000:021b:21ff:fe91:3805 101 11 0x06 0
Efe90:0000:0000:0000:021e:67ff:fe00:0000
fe90:0000:0000:0000:021b:21ff:fe91:3805 102 12 0x06 1
...--- examples/l3fwd/l3fwd_em.c | 376 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 303 insertions(+), 73 deletions(-)
examples/l3fwd/l3fwd_em.c +303 -73
@@ -95,8 +95,14 @@ union ipv4_5tuple_host {#define XMM_NUM_IN_IPV6_5TUPLE 3struct ipv6_5tuple { -uint8_t ip_dst[IPV6_ADDR_LEN ]; -uint8_t ip_src[IPV6_ADDR_LEN ]; +union { +uint8_t ip_dst[IPV6_ADDR_LEN ]; +uint32_t ip32_dst[4 ]; + }; +union { +uint8_t ip_src[IPV6_ADDR_LEN ]; +uint32_t ip32_src[4 ]; + };uint16_t port_dst;uint16_t port_src;uint8_t proto;
@@ -116,47 +122,24 @@ union ipv6_5tuple_host {xmm_t xmm[XMM_NUM_IN_IPV6_5TUPLE ]; }; - - -struct ipv4_l3fwd_em_route { -struct ipv4_5tuple key; -uint8_t if_out; +enum { +CB_FLD_DST_ADDR , +CB_FLD_SRC_ADDR , +CB_FLD_DST_PORT , +CB_FLD_SRC_PORT , +CB_FLD_PROTO , +CB_FLD_IF_OUT , +CB_FLD_MAX }; -struct ipv6_l3fwd_em_route { -struct ipv6_5tuple key; +struct em_rule { +union { +struct ipv4_5tuple v4_key; +struct ipv6_5tuple v6_key; + };uint8_t if_out; }; -static struct ipv4_l3fwd_em_route ipv4_l3fwd_em_route_array[] = { - {{IPv4 (101 ,0 ,0 ,0 ),IPv4 (100 ,10 ,0 ,1 ),101 ,11 ,IPPROTO_TCP },0 }, - {{IPv4 (201 ,0 ,0 ,0 ),IPv4 (200 ,20 ,0 ,1 ),102 ,12 ,IPPROTO_TCP },1 }, - {{IPv4 (111 ,0 ,0 ,0 ),IPv4 (100 ,30 ,0 ,1 ),101 ,11 ,IPPROTO_TCP },2 }, - {{IPv4 (211 ,0 ,0 ,0 ),IPv4 (200 ,40 ,0 ,1 ),102 ,12 ,IPPROTO_TCP },3 }, -}; - -static struct ipv6_l3fwd_em_route ipv6_l3fwd_em_route_array[] = { - {{ - {0xfe ,0x80 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0x80 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -101 ,11 ,IPPROTO_TCP },0 }, - - {{ - {0xfe ,0x90 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0x90 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -102 ,12 ,IPPROTO_TCP },1 }, - - {{ - {0xfe ,0xa0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0xa0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -101 ,11 ,IPPROTO_TCP },2 }, - - {{ - {0xfe ,0xb0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1e ,0x67 ,0xff ,0xfe ,0 ,0 ,0 }, - {0xfe ,0xb0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02 ,0x1b ,0x21 ,0xff ,0xfe ,0x91 ,0x38 ,0x05 }, -102 ,12 ,IPPROTO_TCP },3 }, -}; -struct rte_hash *ipv4_l3fwd_em_lookup_struct[NB_SOCKETS ];struct rte_hash *ipv6_l3fwd_em_lookup_struct[NB_SOCKETS ];
@@ -233,12 +216,6 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len,return init_val; } -#define IPV4_L3FWD_EM_NUM_ROUTES \ - (sizeof(ipv4_l3fwd_em_route_array) / sizeof(ipv4_l3fwd_em_route_array[0])) - -#define IPV6_L3FWD_EM_NUM_ROUTES \ - (sizeof(ipv6_l3fwd_em_route_array) / sizeof(ipv6_l3fwd_em_route_array[0])) - static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned;
@@ -338,6 +315,224 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, void *lookup_struct)#include "l3fwd_em.h" #endif +static int +em_parse_v6_addr (const char *in,const char **end,uint32_t v[IPV6_ADDR_U32 ], +char dlm) +{ +uint32_t addr[IPV6_ADDR_U16 ]; + +GET_CB_FIELD (in, addr[0 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[1 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[2 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[3 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[4 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[5 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[6 ],16 ,UINT16_MAX ,':' ); +GET_CB_FIELD (in, addr[7 ],16 ,UINT16_MAX , dlm); + + *end = in; + + v[0 ] = (addr[0 ] <<16 ) + addr[1 ]; + v[1 ] = (addr[2 ] <<16 ) + addr[3 ]; + v[2 ] = (addr[4 ] <<16 ) + addr[5 ]; + v[3 ] = (addr[6 ] <<16 ) + addr[7 ]; + +return 0 ; +} + +static int +em_parse_v6_net (const char *in,uint32_t *v) +{ +int32_t rc; +const char *mp; + +/* get address. */ + rc =em_parse_v6_addr (in, &mp, v,0 ); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_addr failed %d\n" , rc); +return rc; + } +return 0 ; +} + +static int +em_parse_v6_rule (char *str,struct em_rule *v) +{ +int i, rc; +char *s, *sp, *in[CB_FLD_MAX ]; +static const char *dlm =" \t\n" ; +int dim =CB_FLD_MAX ; + s = str; + +for (i =0 ; i != dim; i++, s =NULL ) { + in[i] =strtok_r (s, dlm, &sp); +if (in[i] ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"strtok failed\n" ); +return -EINVAL ; + } + } + + rc =em_parse_v6_net (in[CB_FLD_DST_ADDR ], v->v6_key.ip32_dst); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_net failed for dst %d\n" , rc); +return rc; + } + rc =em_parse_v6_net (in[CB_FLD_SRC_ADDR ], v->v6_key.ip32_src); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v6_net failed for src %d\n" , rc); +return rc; + } +/* source port. */ +GET_CB_FIELD (in[CB_FLD_SRC_PORT ], v->v6_key.port_src,0 ,UINT16_MAX ,0 ); +/* destination port. */ +GET_CB_FIELD (in[CB_FLD_DST_PORT ], v->v6_key.port_dst,0 ,UINT16_MAX ,0 ); +/* protocol. */ +GET_CB_FIELD (in[CB_FLD_PROTO ], v->v6_key.proto,0 ,UINT8_MAX ,0 ); +/* out interface. */ +GET_CB_FIELD (in[CB_FLD_IF_OUT ], v->if_out,0 ,UINT8_MAX ,0 ); + +return 0 ; +} + +static int +em_parse_v4_net (const char *in,uint32_t *addr) +{ +uint8_t a, b, c, d; + +GET_CB_FIELD (in, a,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, b,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, c,0 ,UINT8_MAX ,'.' ); +GET_CB_FIELD (in, d,0 ,UINT8_MAX ,0 ); + + addr[0 ] =IPv4 (a, b, c, d); +return 0 ; +} + +static int +em_parse_v4_rule (char *str,struct em_rule *v) +{ +int i, rc; +char *s, *sp, *in[CB_FLD_MAX ]; +static const char *dlm =" \t\n" ; +int dim =CB_FLD_MAX ; + s = str; + +for (i =0 ; i != dim; i++, s =NULL ) { + in[i] =strtok_r (s, dlm, &sp); +if (in[i] ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_rule strtok fail\n" ); +return -EINVAL ; + } + } + + rc =em_parse_v4_net (in[CB_FLD_DST_ADDR ], &(v->v4_key.ip_dst)); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_net dst failed %d\n" , rc); +return rc; + } + rc =em_parse_v4_net (in[CB_FLD_SRC_ADDR ], &(v->v4_key.ip_src)); +if (rc !=0 ) { +RTE_LOG (ERR ,L3FWD ,"parse_v4_net src failed %d\n" , rc); +return rc; + } +/* source port. */ +GET_CB_FIELD (in[CB_FLD_SRC_PORT ], v->v4_key.port_src,0 ,UINT16_MAX ,0 ); +/* destination port. */ +GET_CB_FIELD (in[CB_FLD_DST_PORT ], v->v4_key.port_dst,0 ,UINT16_MAX ,0 ); +/* protocol. */ +GET_CB_FIELD (in[CB_FLD_PROTO ], v->v4_key.proto,0 ,UINT8_MAX ,0 ); +/* out interface. */ +GET_CB_FIELD (in[CB_FLD_IF_OUT ], v->if_out,0 ,UINT8_MAX ,0 ); + +return 0 ; +} + +static int +em_add_rules (const char *rule_path, +struct em_rule **proute_base, +unsigned int *proute_num, +int (*parser)(char *,struct em_rule *)) +{ +uint8_t *route_rules; +struct em_rule *next; +unsigned int route_num =0 ; +unsigned int route_cnt =0 ; +char buff[LINE_MAX ]; +FILE *fh =fopen (rule_path,"rb" ); +unsigned int i =0 , rule_size =sizeof (*next); + +if (fh ==NULL ) +rte_exit (EXIT_FAILURE ,"%s: Open %s failed\n" , __func__, + rule_path); + +while ((fgets (buff,LINE_MAX , fh) !=NULL )) { +if (buff[0 ] ==EM_LEAD_CHAR ) + route_num++; + } + +if (route_num ==0 ) +rte_exit (EXIT_FAILURE ,"Not find any route entries in %s!\n" , + rule_path); + +fseek (fh,0 ,SEEK_SET ); + + route_rules =calloc (route_num, rule_size); + +if (route_rules ==NULL ) +rte_exit (EXIT_FAILURE ,"%s: failed to malloc memory\n" , + __func__); + + i =0 ; +while (fgets (buff,LINE_MAX , fh) !=NULL ) { + i++; + +if (is_bypass_line (buff)) +continue ; + +char s = buff[0 ]; + +/* Route entry */ +if (s ==EM_LEAD_CHAR ) + next = (struct em_rule *)(route_rules + + route_cnt * rule_size); + +/* Illegal line */ +else +rte_exit (EXIT_FAILURE , +"%s Line %u: should start with leading " +"char %c\n" , + rule_path, i,EM_LEAD_CHAR ); + +if (parser (buff +1 , next) !=0 ) +rte_exit (EXIT_FAILURE , +"%s Line %u: parse rules error\n" , + rule_path, i); + + route_cnt++; + } + +fclose (fh); + + *proute_base = (struct em_rule *)route_rules; + *proute_num = route_cnt; + +return 0 ; +} + +static int +check_em_config (void ) +{ +if (parm_config.rule_ipv4_name ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"EM IPv4 rule file not specified\n" ); +return -1 ; + }else if (parm_config.rule_ipv6_name ==NULL ) { +RTE_LOG (ERR ,L3FWD ,"EM IPv6 rule file not specified\n" ); +return -1 ; + } + +return 0 ; +} +static void convert_ipv4_5tuple (struct ipv4_5tuple *key1,union ipv4_5tuple_host *key2)
@@ -378,16 +573,24 @@ populate_ipv4_few_flow_into_table(const struct rte_hash *h) {uint32_t i;int32_t ret; +struct em_rule *route_base_v4; +unsigned int route_num_v4 =0 ; mask0 = (rte_xmm_t ){.u32 = {BIT_8_TO_15 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; -for (i =0 ; i <IPV4_L3FWD_EM_NUM_ROUTES ; i++) { -struct ipv4_l3fwd_em_route entry; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv4_name, + &route_base_v4, &route_num_v4, + &em_parse_v4_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v4 rules\n" ); + +for (i =0 ; i < route_num_v4; i++) { +struct em_rule entry;union ipv4_5tuple_host newkey; - entry = ipv4_l3fwd_em_route_array[i]; -convert_ipv4_5tuple (&entry.key, &newkey); + entry = route_base_v4[i]; +convert_ipv4_5tuple (&entry.v4_key, &newkey); ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 ) { rte_exit(EXIT_FAILURE, "Unable to add entry %" PRIu32
@@ -396,7 +599,7 @@ populate_ipv4_few_flow_into_table(const struct rte_hash *h) ipv4_l3fwd_out_if[ret] = entry.if_out; }printf ("Hash: Adding 0x%" PRIx64" keys\n" , - (uint64_t )IPV4_L3FWD_EM_NUM_ROUTES ); + (uint64_t )route_num_v4); }#define BIT_16_TO_23 0x00ff0000
@@ -405,18 +608,26 @@ populate_ipv6_few_flow_into_table(const struct rte_hash *h) {uint32_t i;int32_t ret; +struct em_rule *route_base_v6; +unsigned int route_num_v6 =0 ; mask1 = (rte_xmm_t ){.u32 = {BIT_16_TO_23 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; mask2 = (rte_xmm_t ){.u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } }; -for (i =0 ; i <IPV6_L3FWD_EM_NUM_ROUTES ; i++) { -struct ipv6_l3fwd_em_route entry; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv6_name, + &route_base_v6, &route_num_v6, + &em_parse_v6_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v6 rules\n" ); + +for (i =0 ; i < route_num_v6; i++) { +struct em_rule entry;union ipv6_5tuple_host newkey; - entry = ipv6_l3fwd_em_route_array[i]; -convert_ipv6_5tuple (&entry.key, &newkey); + entry = route_base_v6[i]; +convert_ipv6_5tuple (&entry.v6_key, &newkey); ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 ) { rte_exit(EXIT_FAILURE, "Unable to add entry %" PRIu32
@@ -425,7 +636,7 @@ populate_ipv6_few_flow_into_table(const struct rte_hash *h) ipv6_l3fwd_out_if[ret] = entry.if_out; }printf ("Hash: Adding 0x%" PRIx64"keys\n" , - (uint64_t )IPV6_L3FWD_EM_NUM_ROUTES ); + (uint64_t )route_num_v6); }#define NUMBER_PORT_USED 4
@@ -434,12 +645,20 @@ populate_ipv4_many_flow_into_table(const struct rte_hash *h, unsigned int nr_flow) {unsigned i; +struct em_rule *route_base_v4; +unsigned int route_num_v4 =0 ; mask0 = (rte_xmm_t ){.u32 = {BIT_8_TO_15 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv4_name, + &route_base_v4, &route_num_v4, + &em_parse_v4_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v4 rules\n" ); +for (i =0 ; i < nr_flow; i++) { -struct ipv4_l3fwd_em_route entry; +struct em_rule entry;union ipv4_5tuple_host newkey; uint8_t a = (uint8_t)
@@ -453,23 +672,23 @@ populate_ipv4_many_flow_into_table(const struct rte_hash *h,memset (&entry,0 ,sizeof (entry));switch (i & (NUMBER_PORT_USED -1 )) {case 0 : - entry = ipv4_l3fwd_em_route_array[0 ]; - entry.key.ip_dst =IPv4 (101 , c, b, a); + entry = route_base_v4[0 ]; + entry.v4_key.ip_dst =IPv4 (101 , c, b, a);break ;case 1 : - entry = ipv4_l3fwd_em_route_array[1 ]; - entry.key.ip_dst =IPv4 (201 , c, b, a); + entry = route_base_v4[1 ]; + entry.v4_key.ip_dst =IPv4 (201 , c, b, a);break ;case 2 : - entry = ipv4_l3fwd_em_route_array[2 ]; - entry.key.ip_dst =IPv4 (111 , c, b, a); + entry = route_base_v4[2 ]; + entry.v4_key.ip_dst =IPv4 (111 , c, b, a);break ;case 3 : - entry = ipv4_l3fwd_em_route_array[3 ]; - entry.key.ip_dst =IPv4 (211 , c, b, a); + entry = route_base_v4[3 ]; + entry.v4_key.ip_dst =IPv4 (211 , c, b, a);break ; }; -convert_ipv4_5tuple (&entry.key, &newkey); +convert_ipv4_5tuple (&entry.v4_key, &newkey);int32_t ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 )
@@ -486,13 +705,21 @@ populate_ipv6_many_flow_into_table(const struct rte_hash *h, unsigned int nr_flow) {unsigned i; +struct em_rule *route_base_v6; +unsigned int route_num_v6 =0 ; mask1 = (rte_xmm_t ){.u32 = {BIT_16_TO_23 ,ALL_32_BITS ,ALL_32_BITS ,ALL_32_BITS } }; mask2 = (rte_xmm_t ){.u32 = {ALL_32_BITS ,ALL_32_BITS ,0 ,0 } }; +/* Load rules from the input file */ +if (em_add_rules (parm_config.rule_ipv6_name, + &route_base_v6, &route_num_v6, + &em_parse_v6_rule) <0 ) +rte_exit (EXIT_FAILURE ,"Failed to add em v6 rules\n" ); +for (i =0 ; i < nr_flow; i++) { -struct ipv6_l3fwd_em_route entry; +struct em_rule entry;union ipv6_5tuple_host newkey; uint8_t a = (uint8_t)
@@ -506,22 +733,22 @@ populate_ipv6_many_flow_into_table(const struct rte_hash *h,memset (&entry,0 ,sizeof (entry));switch (i & (NUMBER_PORT_USED -1 )) {case 0 : - entry = ipv6_l3fwd_em_route_array[0 ]; + entry = route_base_v6[0 ];break ;case 1 : - entry = ipv6_l3fwd_em_route_array[1 ]; + entry = route_base_v6[1 ];break ;case 2 : - entry = ipv6_l3fwd_em_route_array[2 ]; + entry = route_base_v6[2 ];break ;case 3 : - entry = ipv6_l3fwd_em_route_array[3 ]; + entry = route_base_v6[3 ];break ; }; - entry.key.ip_dst[13 ] = c; - entry.key.ip_dst[14 ] = b; - entry.key.ip_dst[15 ] = a; -convert_ipv6_5tuple (&entry.key, &newkey); + entry.v6_key.ip_dst[13 ] = c; + entry.v6_key.ip_dst[14 ] = b; + entry.v6_key.ip_dst[15 ] = a; +convert_ipv6_5tuple (&entry.v6_key, &newkey);int32_t ret =rte_hash_add_key (h, (void *) &newkey);if (ret <0 )
@@ -746,6 +973,9 @@ setup_hash(const int socketid)char s[64 ]; +if (check_em_config () !=0 ) +rte_exit (EXIT_FAILURE ,"Failed to get valid EM options\n" ); +/* create ipv4 hash */ snprintf (s,sizeof (s),"ipv4_l3fwd_hash_%d" , socketid); ipv4_l3fwd_hash_params.name = s;
Signature · 1 line
2.7.4
Re: [v4 3/3] EM config file read option.
Quoted 31 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Sunday, March 5, 2017 7:47 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>; Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [v4 3/3] EM config file read option.v4:
> No changes.v3:
> Fix additional checkpatch coding style issues.v2:
> Fix checkpatch warnings.v1:
> Remove static array configuration of Dest IP,Src IP, Dest port, Src port, Proto and IF_OUT for EM and EM6 config. > Add reading configuration from a file. > Format of configuration file is as follows #EM route entries, #Dest-IP Src-IP Dest-port Src-port Proto IF_OUT E101.0.0.0 100.10.0.0 101 11 0x06 0 E201.0.0.0 200.20.0.0 102 12 0x06 1 E111.0.0.0 211.30.0.0 101 11 0x06 2 ...
Quoted 7 lines
#EM6 route entries
#Dest-IP Src-IP Dest-port Src-port Proto IF_OUT
Efe80:0000:0000:0000:021e:67ff:fe00:0000
fe80:0000:0000:0000:021b:21ff:fe91:3805 101 11 0x06 0
Efe90:0000:0000:0000:021e:67ff:fe00:0000
fe90:0000:0000:0000:021b:21ff:fe91:3805 102 12 0x06 1
...Hi Ravi,
Just a note on the structure of the commit message for this and the other patches. The first thing to do if you are new to contributing to DPDK is to have a read through the guidelines on "Contributing Code to DPDK":
http://dpdk.org/doc/guides/contributing/patches.html
In particular the subject line should contain the component that is being modified. Something like:
examples/l3fwd: add config file support for exact match
Do a git log examples/l3fwd to see some other examples and have a look at the following "Commit Messages: Subject Line" section of the above guidelines
http://dpdk.org/doc/guides/contributing/patches.html#commit-messages-subject-line
The body of the message should contain a short description of what you are changing, at a high level, and why you are changing it. See also:
http://dpdk.org/doc/guides/contributing/patches.html#commit-messages-body
The version information in your commit message is good but that should be included after the --- line so that it is part of the patch but not part of the commit message.
John.
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Sunday, March 5, 2017 7:47 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>; Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [v4 0/3] Merge l3fwd-acl and l3fwdThis patchset merges l3fwd-acl and l3fwd code into common directory. Adds file read options to build LPM and EM tables.
Hi Ravi,
Thanks to this. It seems like a good change. There are probably too many L2/L3 variants and some of them should be merged.
Note, you will also have to merge the sample app guides in some sensible way:
http://dpdk.org/doc/guides/sample_app_ug/l3_forward.html
http://dpdk.org/doc/guides/sample_app_ug/l3_forward_access_ctrl.html
John
Hi John,
Should I work with documentation team to update the document? If yes, please let me know the contact information.
Thanks.
Quoted 26 lines · John
Quoted 5 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Sunday, March 5, 2017 7:47 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Richardson,Bruce
Quoted 5 lines
<[email protected]>; Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [v4 0/3] Merge l3fwd-acl and l3fwdThis patchset merges l3fwd-acl and l3fwd code into common directory. Adds file read options to build LPM and EM tables.
Hi Ravi,
Thanks to this. It seems like a good change. There are probably too many L2/L3 variants and some of them should be merged.
Note, you will also have to merge the sample app guides in some sensible way:
http://dpdk.org/doc/guides/sample_app_ug/l3_forward.html
http://dpdk.org/doc/guides/sample_app_ug/l3_forward_access_ctrl.htmlJohn
John, Konstantin,
Kindly let me know new 'v5' patch follows dpdk guidelines?
I just followed what's in the dpdk contributing code guidelines.
- git format-patch -3 -o patch/ -v 5 --cover-letter
- git send-email --to [email protected] --in-reply-to <v4-MSGID> patch/*
Thanks.
Quoted 37 lines · Ravi Kerur
Hi John,
Should I work with documentation team to update the document? If yes, please let me know the contact information.
Thanks.
Quoted 26 lines · John
Quoted 5 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Sunday, March 5, 2017 7:47 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Richardson,Bruce
Quoted 5 lines
<[email protected]>; Ravi Kerur <[email protected]>
Subject: [dpdk-dev] [v4 0/3] Merge l3fwd-acl and l3fwdThis patchset merges l3fwd-acl and l3fwd code into common directory. Adds file read options to build LPM and EM tables.
Hi Ravi,
Thanks to this. It seems like a good change. There are probably too many L2/L3 variants and some of them should be merged.
Note, you will also have to merge the sample app guides in some sensible way:
http://dpdk.org/doc/guides/sample_app_ug/l3_forward.html
http://dpdk.org/doc/guides/sample_app_ug/l3_forward_access_ctrl.htmlJohn
Quoted 10 lines
From: Ravi Kerur [mailto:[email protected]]
Sent: Wednesday, March 8, 2017 9:51 PM
To: Mcnamara, John <[email protected]>
Cc: [email protected]; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: Re: [dpdk-dev] [v4 0/3] Merge l3fwd-acl and l3fwdKindly let me know new 'v5' patch follows dpdk guidelines?
Hi Ravi,
In general the commit messages don't meet the guidelines, so it is probably worth reading through the guidelines again:
http://dpdk.org/doc/guides/contributing/patches.html
In particular have a look at the sections on the "subject line" and the "message body".
I'll make some other comments to your patches to help you along.
Thanks,
John
Quoted 10 lines
From: Ravi Kerur [mailto:[email protected]]
Sent: Monday, March 6, 2017 11:21 PM
To: Mcnamara, John <[email protected]>
Cc: [email protected]; Ananyev, Konstantin <[email protected]>;
Richardson, Bruce <[email protected]>
Subject: Re: [dpdk-dev] [v4 0/3] Merge l3fwd-acl and l3fwdShould I work with documentation team to update the document? If yes, please let me know the contact information.
Hi Ravi,
There isn't any documentation team. Unfortunately. :-)
The raw documentation is in text format and is generally updated by the developer submitting a patch.
There is already docs for l3fwd and l3fwd_acl so all that is required is to merge them. However, you will need to take some care to remove the duplicate sections and to make sure that the merged doc makes sense as a whole.
See the documentation guidelines:
http://dpdk.org/doc/guides/contributing/documentation.html
John
Hi John,
Quoted 18 lines · John
Quoted 10 lines
From: Ravi Kerur [mailto:[email protected]]
Sent: Monday, March 6, 2017 11:21 PM
To: Mcnamara, John <[email protected]>
Cc: [email protected]; Ananyev, Konstantin <[email protected]>;
Richardson, Bruce <[email protected]>
Subject: Re: [dpdk-dev] [v4 0/3] Merge l3fwd-acl and l3fwdShould I work with documentation team to update the document? If yes, please let me know the contact information.
Hi Ravi,
There isn't any documentation team. Unfortunately. :-)
The raw documentation is in text format and is generally updated by the developer submitting a patch.
Quoted 8 lines
There is already docs for l3fwd and
l3fwd_aclso all that is required is to merge them. However, you will need to take some care to remove the duplicate sections and to make sure that the merged doc makes sense as a whole.See the documentation guidelines:
Thanks. I realized after skimming through the documents and seeing a 'doc:' prefix for review. Some clarifications on merging 'l3fwd' and 'l3fwd-acl'
1. Instead of wholesale merger of both 'l3fwd' and 'l3fwd-acl', does it make sense to
a. Modify 'l3fwd' document by adding ACL processing information ('-A' cmdline) and providing a link or reference to existing 'l3fwd-acl' documentation since nothing has changed in terms of 'l3fwd-acl'.
b. Add file read options for 'exact match' and 'longest prefix match' in 'l3fwd' documentation.
Thanks.
Quoted 4 lines
John
Hi John, Konstantin,
Quoted 40 lines · Ravi Kerur
Hi John,
Quoted 18 lines · John
Quoted 10 lines
From: Ravi Kerur [mailto:[email protected]]
Sent: Monday, March 6, 2017 11:21 PM
To: Mcnamara, John <[email protected]>
Cc: [email protected]; Ananyev, Konstantin <[email protected]>;
Richardson, Bruce <[email protected]>
Subject: Re: [dpdk-dev] [v4 0/3] Merge l3fwd-acl and l3fwdShould I work with documentation team to update the document? If yes, please let me know the contact information.
Hi Ravi,
There isn't any documentation team. Unfortunately. :-)
The raw documentation is in text format and is generally updated by the developer submitting a patch.
Quoted 8 lines
There is already docs for l3fwd and
l3fwd_aclso all that is required is to merge them. However, you will need to take some care to remove the duplicate sections and to make sure that the merged doc makes sense as a whole.See the documentation guidelines:
Thanks. I realized after skimming through the documents and seeing a 'doc:' prefix for review. Some clarifications on merging 'l3fwd' and 'l3fwd-acl'
1. Instead of wholesale merger of both 'l3fwd' and 'l3fwd-acl', does it make sense to
Quoted 7 lines
a. Modify 'l3fwd' document by adding ACL processing information ('-A' cmdline) and providing a link or reference to existing 'l3fwd-acl' documentation since nothing has changed in terms of 'l3fwd-acl'.
b. Add file read options for 'exact match' and 'longest prefix match' in 'l3fwd' documentation.
Kindly let me know how you want me to proceed with the changes to documentation?
Thanks.
Quoted 9 lines
Thanks.
Quoted 4 lines
John