Skip to contentSkip to conversation

Modify and modularize l3fwd code

PATCH New Ravi Kerur 5 participants 13 messages Dec 21, 2015 – Feb 28, 2016

lore
Share & tools
lore

Ravi Kerur

author
#0 lore raw

PATCH 1/1 Modify and modularize l3fwd code

Many thanks to Intel team (Konstantin, Bruce and Declan) for below proposal to make changes to l3fwd code, their valuable inputs during interal review and help in performance tests.

The main problem with l3fwd is that it is too monolithic with everything being in one file, and the various options all controlled by compile time flags. This means that it's hard to read and understand, and when making any changes, you need to go to a lot of work to try and ensure you cover all the code paths, since a compile of the app will not touch large parts of the l3fwd codebase.

Following changes were done to fix the issues mentioned above

> Split out the various lpm and hash specific functionality into separate
files, so that l3fwd code has one file for common code e.g. args processing, mempool creation, and then individual files for the various forwarding approaches.

Following are new file lists

main.c (Common code for args processing, memppol creation, etc) l3fwd_em.c (Hash/Exact match aka 'EM' functionality) l3fwd_em_sse.h (SSE4_1 buffer optimizated 'EM' code) l3fwd_lpm.c (Longest Prefix Match aka 'LPM' functionality) l3fwd_lpm_sse.h (SSE4_1 buffer optimizated 'LPM' code) l3fwd.h (Common include for 'EM' and 'LPM')

> The choosing of the lpm/hash path should be done at runtime, not
compile time, via a command-line argument. This will ensure that both code paths get compiled in a single go

Following examples show runtime options provided

Select 'LPM' or 'EM' based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (EM) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

Options "E" and "L" are mutualy-exclusive.

If none selected, "L" is default.

Ravi Kerur (1):
Modify and modularize l3fwd code

 examples/l3fwd/Makefile        |    9 +-
 examples/l3fwd/l3fwd.h         |  209 ++++
 examples/l3fwd/l3fwd_em.c      |  773 ++++++++++++++
 examples/l3fwd/l3fwd_em_sse.h  |  479 +++++++++
 examples/l3fwd/l3fwd_lpm.c     |  414 ++++++++
 examples/l3fwd/l3fwd_lpm_sse.h |  610 +++++++++++
 examples/l3fwd/main.c          | 2202 ++++------------------------------------
 7 files changed, 2694 insertions(+), 2002 deletions(-)
 create mode 100644 examples/l3fwd/l3fwd.h
 create mode 100644 examples/l3fwd/l3fwd_em.c
 create mode 100644 examples/l3fwd/l3fwd_em_sse.h
 create mode 100644 examples/l3fwd/l3fwd_lpm.c
 create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/1 Modify and modularize l3fwd code

v1:
> Rebase to latest code base for DPDK team review.

Intel team's (Konstantin, Bruce and Declan) review comments

v4<-v3:
> Fix code review comments from Konstantin
> Move buffer optimization code into l3fwd_lpm_sse.h
and l3fwd_em_sse.h for LPM and EM respectively
> Add compile time __SSE4_1__ for header file inclusion > Tested with CONFIG_RTE_MACHINE=default for non
__SSE4_1__ compilation and build
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v3<-v2:
> Fix code review comments from Bruce
> Fix multiple static definitions
> Move local #defines to C files, common #defines
to H file.
> Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em > Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm > Pass additional parameter to send_single_packet
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v2<-v1:
> Fix errors in GCC 5.1
> Restore "static inline" functions, rearrange
functions to take "static inline" into account
> Duplicate main_loop for LPM and EM

v1:
> Split main.c into following 3 files
> main.c, (parsing, buffer alloc, and other utilities) > l3fwd_lpm.c, (Longest Prefix Match functions) > l3fwd_em.c, (Exact Match f.e. Hash functions) > l3fwd.h, (Common defines and prototypes)

> Select LPM or EM based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

> Options "E" and "L" are mutualy-exclusive.

> Use function pointers during initialiation of relevant
data structures.

> Remove unwanted #ifdefs in the code with exception to
> DO_RFC_1812_CHECKS
> RTE_MACHINE_CPUFLAG_SSE4_2

> Compiled for
> i686-native-linuxapp-gcc
> x86_64-native-linuxapp-gcc
> x86_x32-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc

> Tested on
> Ubuntu 14.04 (GCC 4.8.4)
> FreeBSD 10.0 (GCC 4.8)
> I217 and I218 respectively.

---
 examples/l3fwd/Makefile        |    9 +-
 examples/l3fwd/l3fwd.h         |  209 ++++
 examples/l3fwd/l3fwd_em.c      |  773 ++++++++++++++
 examples/l3fwd/l3fwd_em_sse.h  |  479 +++++++++
 examples/l3fwd/l3fwd_lpm.c     |  414 ++++++++
 examples/l3fwd/l3fwd_lpm_sse.h |  610 +++++++++++
 examples/l3fwd/main.c          | 2202 ++++------------------------------------
 7 files changed, 2694 insertions(+), 2002 deletions(-)
 create mode 100644 examples/l3fwd/l3fwd.h
 create mode 100644 examples/l3fwd/l3fwd_em.c
 create mode 100644 examples/l3fwd/l3fwd_em_sse.h
 create mode 100644 examples/l3fwd/l3fwd_lpm.c
 create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h
examples/l3fwd/Makefile +2 -7
index 68de8fc..94a2282 100644
@@ -42,15 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l3fwd
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c
 
+CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3 $(USER_FLAGS)
 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/l3fwd.h new file +209 -0

209 lines not on this page · raw message

examples/l3fwd/l3fwd_em.c new file +773 -0

773 lines not on this page · raw message

examples/l3fwd/l3fwd_em_sse.h new file +479 -0

479 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm.c new file +414 -0

414 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm_sse.h new file +610 -0

610 lines not on this page · raw message

examples/l3fwd/main.c +207 -1995

498 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.9.1

Part of the diff is not shown here. View the raw message.

Acked-by on v1 1/1
#2 lore raw
Quoted 64 lines

From: Ravi Kerur [mailto:[email protected]]
Sent: Monday, December 21, 2015 11:13 PM
To: [email protected]
Cc: Richardson, Bruce; Doherty, Declan; Ananyev, Konstantin; Ravi Kerur
Subject: [PATCH v1] Modify and modularize l3fwd code

v1:
> Rebase to latest code base for DPDK team review.

Intel team's (Konstantin, Bruce and Declan) review comments

v4<-v3:
> Fix code review comments from Konstantin
> Move buffer optimization code into l3fwd_lpm_sse.h
and l3fwd_em_sse.h for LPM and EM respectively
> Add compile time __SSE4_1__ for header file inclusion > Tested with CONFIG_RTE_MACHINE=default for non
__SSE4_1__ compilation and build
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v3<-v2:
> Fix code review comments from Bruce
> Fix multiple static definitions
> Move local #defines to C files, common #defines
to H file.
> Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em > Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm > Pass additional parameter to send_single_packet
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v2<-v1:
> Fix errors in GCC 5.1
> Restore "static inline" functions, rearrange
functions to take "static inline" into account
> Duplicate main_loop for LPM and EM

v1:
> Split main.c into following 3 files
> main.c, (parsing, buffer alloc, and other utilities) > l3fwd_lpm.c, (Longest Prefix Match functions) > l3fwd_em.c, (Exact Match f.e. Hash functions) > l3fwd.h, (Common defines and prototypes)

> Select LPM or EM based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

> Options "E" and "L" are mutualy-exclusive.

> Use function pointers during initialiation of relevant
data structures.

> Remove unwanted #ifdefs in the code with exception to
> DO_RFC_1812_CHECKS
> RTE_MACHINE_CPUFLAG_SSE4_2

> Compiled for
> i686-native-linuxapp-gcc
> x86_64-native-linuxapp-gcc
> x86_x32-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc

Quoted 7 lines

> Tested on
> Ubuntu 14.04 (GCC 4.8.4)
> FreeBSD 10.0 (GCC 4.8)
> I217 and I218 respectively.

---

Great effort, thanks for doing it.

Tested-by Acked-by on v1 1/1
#3 lore raw
In reply to Ravi Kerur
Quoted 64 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Tuesday, December 22, 2015 00:13
To: [email protected]
Subject: [dpdk-dev] [PATCH v1] Modify and modularize l3fwd code

v1:
> Rebase to latest code base for DPDK team review.

Intel team's (Konstantin, Bruce and Declan) review comments

v4<-v3:
> Fix code review comments from Konstantin
> Move buffer optimization code into l3fwd_lpm_sse.h
and l3fwd_em_sse.h for LPM and EM respectively
> Add compile time __SSE4_1__ for header file inclusion > Tested with CONFIG_RTE_MACHINE=default for non
__SSE4_1__ compilation and build
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v3<-v2:
> Fix code review comments from Bruce
> Fix multiple static definitions
> Move local #defines to C files, common #defines
to H file.
> Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em > Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm > Pass additional parameter to send_single_packet
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v2<-v1:
> Fix errors in GCC 5.1
> Restore "static inline" functions, rearrange
functions to take "static inline" into account
> Duplicate main_loop for LPM and EM

v1:
> Split main.c into following 3 files
> main.c, (parsing, buffer alloc, and other utilities) > l3fwd_lpm.c, (Longest Prefix Match functions) > l3fwd_em.c, (Exact Match f.e. Hash functions) > l3fwd.h, (Common defines and prototypes)

> Select LPM or EM based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

> Options "E" and "L" are mutualy-exclusive.

> Use function pointers during initialiation of relevant
data structures.

> Remove unwanted #ifdefs in the code with exception to
> DO_RFC_1812_CHECKS
> RTE_MACHINE_CPUFLAG_SSE4_2

> Compiled for
> i686-native-linuxapp-gcc
> x86_64-native-linuxapp-gcc
> x86_x32-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc

Quoted 7 lines

> Tested on
> Ubuntu 14.04 (GCC 4.8.4)
> FreeBSD 10.0 (GCC 4.8)
> I217 and I218 respectively.

---

#6 lore raw

2016-02-16 12:09, Azarewicz, PiotrX T:

Quoted 8 lines

Hi Thomas,

Quoted 6 lines

Hi Ravi,

2016-02-02 12:01, Kulasek, TomaszX:

Quoted 2 lines
Quoted 7 lines
Quoted 4 lines

I'm sorry that another patch was applied before this one. Please could you rebase it?
It is too big to do it myself safely.
Thanks

I rebased this patch.
May I send it ? and if yes should I add Signed-off-by?

Yes please, as v2 (with --in-reply-to), and yes.
Thanks

#7 lore raw

PATCH v2 1/1 examples/l3fwd: modify and modularize l3fwd code

In reply to Ravi Kerur

Many thanks to Intel team (Konstantin, Bruce and Declan) for below proposal to
make changes to l3fwd code, their valuable inputs during interal review and help
in performance tests.

The main problem with l3fwd is that it is too monolithic with everything being
in one file, and the various options all controlled by compile time flags. This
means that it's hard to read and understand, and when making any changes, you need
to go to a lot of work to try and ensure you cover all the code paths, since a
compile of the app will not touch large parts of the l3fwd codebase.

Following changes were done to fix the issues mentioned above

> Split out the various lpm and hash specific functionality into
separate
files, so that l3fwd code has one file for common code e.g. args processing, mempool creation, and then individual files for the
various
forwarding approaches.

Following are new file lists

main.c (Common code for args processing, memppol creation, etc) l3fwd_em.c (Hash/Exact match aka 'EM' functionality) l3fwd_em_sse.h (SSE4_1 buffer optimizated 'EM' code) l3fwd_lpm.c (Longest Prefix Match aka 'LPM' functionality) l3fwd_lpm_sse.h (SSE4_1 buffer optimizated 'LPM' code) l3fwd.h (Common include for 'EM' and 'LPM')

> The choosing of the lpm/hash path should be done at runtime, not
compile time, via a command-line argument. This will ensure that both code paths get compiled in a single go

Following examples show runtime options provided

Select 'LPM' or 'EM' based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (EM) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

Options "E" and "L" are mutualy-exclusive.

If none selected, "L" is default.

---

v2 changes:
Rebase to latest code

v1 changes:
Rebase to latest code base for DPDK team review. Intel team's (Konstantin, Bruce and Declan) review comments

v4<-v3:
> Fix code review comments from Konstantin
> Move buffer optimization code into l3fwd_lpm_sse.h
and l3fwd_em_sse.h for LPM and EM respectively
> Add compile time __SSE4_1__ for header file inclusion > Tested with CONFIG_RTE_MACHINE=default for non
__SSE4_1__ compilation and build
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v3<-v2:
> Fix code review comments from Bruce
> Fix multiple static definitions
> Move local #defines to C files, common #defines
to H file.
> Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em > Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm > Pass additional parameter to send_single_packet
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v2<-v1:
> Fix errors in GCC 5.1
> Restore "static inline" functions, rearrange
functions to take "static inline" into account
> Duplicate main_loop for LPM and EM

v1:
> Split main.c into following 3 files
> main.c, (parsing, buffer alloc, and other utilities) > l3fwd_lpm.c, (Longest Prefix Match functions) > l3fwd_em.c, (Exact Match f.e. Hash functions) > l3fwd.h, (Common defines and prototypes)

> Select LPM or EM based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

> Options "E" and "L" are mutualy-exclusive.

> Use function pointers during initialiation of relevant
data structures.

> Remove unwanted #ifdefs in the code with exception to
> DO_RFC_1812_CHECKS
> RTE_MACHINE_CPUFLAG_SSE4_2

> Compiled for
> i686-native-linuxapp-gcc
> x86_64-native-linuxapp-gcc
> x86_x32-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc

> Tested on
> Ubuntu 14.04 (GCC 4.8.4)
> FreeBSD 10.0 (GCC 4.8)
> I217 and I218 respectively.

 examples/l3fwd/Makefile        |    9 +-
 examples/l3fwd/l3fwd.h         |  211 ++++
 examples/l3fwd/l3fwd_em.c      |  776 ++++++++++++++
 examples/l3fwd/l3fwd_em_sse.h  |  479 +++++++++
 examples/l3fwd/l3fwd_lpm.c     |  417 ++++++++
 examples/l3fwd/l3fwd_lpm_sse.h |  610 +++++++++++
 examples/l3fwd/main.c          | 2207 ++++------------------------------------
 7 files changed, 2703 insertions(+), 2006 deletions(-)
 create mode 100644 examples/l3fwd/l3fwd.h
 create mode 100644 examples/l3fwd/l3fwd_em.c
 create mode 100644 examples/l3fwd/l3fwd_em_sse.h
 create mode 100644 examples/l3fwd/l3fwd_lpm.c
 create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h
examples/l3fwd/Makefile +2 -7
index 68de8fc..94a2282 100644
@@ -42,15 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l3fwd
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c
 
+CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3 $(USER_FLAGS)
 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/l3fwd.h new file +211 -0

211 lines not on this page · raw message

examples/l3fwd/l3fwd_em.c new file +776 -0

776 lines not on this page · raw message

examples/l3fwd/l3fwd_em_sse.h new file +479 -0

479 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm.c new file +417 -0

417 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm_sse.h new file +610 -0

610 lines not on this page · raw message

examples/l3fwd/main.c +208 -1999

490 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.5

Part of the diff is not shown here. View the raw message.

#8 lore raw

PATCH v3 1/1 examples/l3fwd: modify and modularize l3fwd code

The main problem with l3fwd is that it is too monolithic with everything being
in one file, and the various options all controlled by compile time flags. This
means that it's hard to read and understand, and when making any changes, you need
to go to a lot of work to try and ensure you cover all the code paths, since a
compile of the app will not touch large parts of the l3fwd codebase.

Following changes were done to fix the issues mentioned above

> Split out the various lpm and hash specific functionality into
separate
files, so that l3fwd code has one file for common code e.g. args processing, mempool creation, and then individual files for the
various
forwarding approaches.

Following are new file lists

main.c (Common code for args processing, memppol creation, etc) l3fwd_em.c (Hash/Exact match aka 'EM' functionality) l3fwd_em_sse.h (SSE4_1 buffer optimizated 'EM' code) l3fwd_lpm.c (Longest Prefix Match aka 'LPM' functionality) l3fwd_lpm_sse.h (SSE4_1 buffer optimizated 'LPM' code) l3fwd.h (Common include for 'EM' and 'LPM')

> The choosing of the lpm/hash path should be done at runtime, not
compile time, via a command-line argument. This will ensure that both code paths get compiled in a single go

Following examples show runtime options provided

Select 'LPM' or 'EM' based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (EM) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

Options "E" and "L" are mutualy-exclusive.

If none selected, "L" is default.

---

v3 changes:
add missed fix 'fix build without SSE4.1':
- move l3fwd_lpm_no_opt_send_packets() to l3fwd_lpm.h
- move l3fwd_em_no_opt_send_packets() to l3fwd_em.h
- add #elses which provide proper headers respectively

     l3fwd_lpm.h/l3fwd_lpm.h or l3fwd_lpm_sse.h/l3fwd_lpm_sse.h

v2 changes:
Rebase to latest code

v1 changes:
Rebase to latest code base for DPDK team review. Intel team's (Konstantin, Bruce and Declan) review comments

v4<-v3:
> Fix code review comments from Konstantin
> Move buffer optimization code into l3fwd_lpm_sse.h
and l3fwd_em_sse.h for LPM and EM respectively
> Add compile time __SSE4_1__ for header file inclusion > Tested with CONFIG_RTE_MACHINE=default for non
__SSE4_1__ compilation and build
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v3<-v2:
> Fix code review comments from Bruce
> Fix multiple static definitions
> Move local #defines to C files, common #defines
to H file.
> Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em > Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm > Pass additional parameter to send_single_packet
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v2<-v1:
> Fix errors in GCC 5.1
> Restore "static inline" functions, rearrange
functions to take "static inline" into account
> Duplicate main_loop for LPM and EM

v1:
> Split main.c into following 3 files
> main.c, (parsing, buffer alloc, and other utilities) > l3fwd_lpm.c, (Longest Prefix Match functions) > l3fwd_em.c, (Exact Match f.e. Hash functions) > l3fwd.h, (Common defines and prototypes)

> Select LPM or EM based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

> Options "E" and "L" are mutualy-exclusive.

> Use function pointers during initialiation of relevant
data structures.

> Remove unwanted #ifdefs in the code with exception to
> DO_RFC_1812_CHECKS
> RTE_MACHINE_CPUFLAG_SSE4_2

> Compiled for
> i686-native-linuxapp-gcc
> x86_64-native-linuxapp-gcc
> x86_x32-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc

> Tested on
> Ubuntu 14.04 (GCC 4.8.4)
> FreeBSD 10.0 (GCC 4.8)
> I217 and I218 respectively.

 examples/l3fwd/Makefile        |   11 +-
 examples/l3fwd/l3fwd.h         |  211 ++++
 examples/l3fwd/l3fwd_em.c      |  749 ++++++++++++++
 examples/l3fwd/l3fwd_em.h      |   66 ++
 examples/l3fwd/l3fwd_em_sse.h  |  479 +++++++++
 examples/l3fwd/l3fwd_lpm.c     |  305 ++++++
 examples/l3fwd/l3fwd_lpm.h     |  151 +++
 examples/l3fwd/l3fwd_lpm_sse.h |  610 +++++++++++
 examples/l3fwd/main.c          | 2209 ++++------------------------------------
 9 files changed, 2783 insertions(+), 2008 deletions(-)
 create mode 100644 examples/l3fwd/l3fwd.h
 create mode 100644 examples/l3fwd/l3fwd_em.c
 create mode 100644 examples/l3fwd/l3fwd_em.h
 create mode 100644 examples/l3fwd/l3fwd_em_sse.h
 create mode 100644 examples/l3fwd/l3fwd_lpm.c
 create mode 100644 examples/l3fwd/l3fwd_lpm.h
 create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h
examples/l3fwd/Makefile +3 -8
index 68de8fc..5ce0ce0 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,15 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l3fwd
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c
 
+CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3 $(USER_FLAGS)
 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/l3fwd.h new file +211 -0

211 lines not on this page · raw message

examples/l3fwd/l3fwd_em.c new file +749 -0

749 lines not on this page · raw message

examples/l3fwd/l3fwd_em.h new file +66 -0

66 lines not on this page · raw message

examples/l3fwd/l3fwd_em_sse.h new file +479 -0

479 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm.c new file +305 -0

305 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm.h new file +151 -0

151 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm_sse.h new file +610 -0

610 lines not on this page · raw message

examples/l3fwd/main.c +209 -2000

405 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.5

Part of the diff is not shown here. View the raw message.

#9 lore raw

Re: [PATCH v3 1/1] examples/l3fwd: modify and modularize l3fwd code

Hi,

When compiling for i686, there are some errors:

2016-02-18 10:08, Piotr Azarewicz:

Quoted 1 line

+ printf("Hash: Adding 0x%" PRIx64 " keys\n", IPV4_L3FWD_EM_NUM_ROUTES);

[...]

Quoted 1 line

+ printf("Hash: Adding 0x%" PRIx64 "keys\n", IPV6_L3FWD_EM_NUM_ROUTES);

examples/l3fwd/l3fwd_em.c:437:9: error:
format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘unsigned int’

#10 lore raw

Re: [PATCH v3 1/1] examples/l3fwd: modify and modularize l3fwd code

Quoted 7 lines

Hi,

When compiling for i686, there are some errors:

2016-02-18 10:08, Piotr Azarewicz:

Quoted 1 line

+ printf("Hash: Adding 0x%" PRIx64 " keys\n",

Quoted 8 lines

IPV4_L3FWD_EM_NUM_ROUTES);
[...]

Quoted 1 line

+ printf("Hash: Adding 0x%" PRIx64 "keys\n",

IPV6_L3FWD_EM_NUM_ROUTES);

examples/l3fwd/l3fwd_em.c:437:9: error:
format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘unsigned int’

Thanks Thomas, v4 will be done.
Piotr

#11 lore raw

PATCH v4 1/1 examples/l3fwd: modify and modularize l3fwd code

In reply to Piotr Azarewicz

The main problem with l3fwd is that it is too monolithic with everything being
in one file, and the various options all controlled by compile time flags. This
means that it's hard to read and understand, and when making any changes, you need
to go to a lot of work to try and ensure you cover all the code paths, since a
compile of the app will not touch large parts of the l3fwd codebase.

Following changes were done to fix the issues mentioned above

> Split out the various lpm and hash specific functionality into
separate
files, so that l3fwd code has one file for common code e.g. args processing, mempool creation, and then individual files for the
various
forwarding approaches.

Following are new file lists

main.c (Common code for args processing, memppol creation, etc) l3fwd_em.c (Hash/Exact match aka 'EM' functionality) l3fwd_em_sse.h (SSE4_1 buffer optimizated 'EM' code) l3fwd_lpm.c (Longest Prefix Match aka 'LPM' functionality) l3fwd_lpm_sse.h (SSE4_1 buffer optimizated 'LPM' code) l3fwd.h (Common include for 'EM' and 'LPM')

> The choosing of the lpm/hash path should be done at runtime, not
compile time, via a command-line argument. This will ensure that both code paths get compiled in a single go

Following examples show runtime options provided

Select 'LPM' or 'EM' based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (EM) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

Options "E" and "L" are mutualy-exclusive.

If none selected, "L" is default.

---

v4 changes:
fix compilation for i686
examples/l3fwd/l3fwd_em.c:437:2: error:
format '%llx' expects argument of type 'long long unsigned int', but argument 2 has type 'unsigned int'
solution:
-printf("Hash: Adding 0x%" PRIx64 " keys\n", IPV4_L3FWD_EM_NUM_ROUTES); +printf("Hash: Adding 0x%" PRIx64 " keys\n", (uint64_t)IPV4_L3FWD_EM_NUM_ROUTES);

v3 changes:
add missed fix 'fix build without SSE4.1':
- move l3fwd_lpm_no_opt_send_packets() to l3fwd_lpm.h
- move l3fwd_em_no_opt_send_packets() to l3fwd_em.h
- add #elses which provide proper headers respectively

     l3fwd_lpm.h/l3fwd_em.h or l3fwd_lpm_sse.h/l3fwd_em_sse.h

v2 changes:
rebase to latest code

 examples/l3fwd/Makefile        |   11 +-
 examples/l3fwd/l3fwd.h         |  211 ++++
 examples/l3fwd/l3fwd_em.c      |  751 ++++++++++++++
 examples/l3fwd/l3fwd_em.h      |   66 ++
 examples/l3fwd/l3fwd_em_sse.h  |  479 +++++++++
 examples/l3fwd/l3fwd_lpm.c     |  305 ++++++
 examples/l3fwd/l3fwd_lpm.h     |  151 +++
 examples/l3fwd/l3fwd_lpm_sse.h |  610 +++++++++++
 examples/l3fwd/main.c          | 2209 ++++------------------------------------
 9 files changed, 2785 insertions(+), 2008 deletions(-)
 create mode 100644 examples/l3fwd/l3fwd.h
 create mode 100644 examples/l3fwd/l3fwd_em.c
 create mode 100644 examples/l3fwd/l3fwd_em.h
 create mode 100644 examples/l3fwd/l3fwd_em_sse.h
 create mode 100644 examples/l3fwd/l3fwd_lpm.c
 create mode 100644 examples/l3fwd/l3fwd_lpm.h
 create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h
examples/l3fwd/Makefile +3 -8
index 68de8fc..5ce0ce0 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,15 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l3fwd
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c
 
+CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3 $(USER_FLAGS)
 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/l3fwd.h new file +211 -0

211 lines not on this page · raw message

examples/l3fwd/l3fwd_em.c new file +751 -0

751 lines not on this page · raw message

examples/l3fwd/l3fwd_em.h new file +66 -0

66 lines not on this page · raw message

examples/l3fwd/l3fwd_em_sse.h new file +479 -0

479 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm.c new file +305 -0

305 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm.h new file +151 -0

151 lines not on this page · raw message

examples/l3fwd/l3fwd_lpm_sse.h new file +610 -0

610 lines not on this page · raw message

examples/l3fwd/main.c +209 -2000

403 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.5

Part of the diff is not shown here. View the raw message.