[dpdk-dev] [PATCH v4 1/1] examples/l3fwd: modify and modularize l3fwd code

2016-02-28 Thread Thomas Monjalon
2016-02-25 11:24, Piotr Azarewicz:
> Signed-off-by: Ravi Kerur 
> Signed-off-by: Piotr Azarewicz 
> 
> Tested-by: Tomasz Kulasek 
> Acked-by: Tomasz Kulasek 
> Acked-by: Konstantin Ananyev 

Applied, thanks


[dpdk-dev] [PATCH v4 1/1] examples/l3fwd: modify and modularize l3fwd code

2016-02-25 Thread 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.

Signed-off-by: Ravi Kerur 
Signed-off-by: Piotr Azarewicz 

Tested-by: Tomasz Kulasek 
Acked-by: Tomasz Kulasek 
Acked-by: Konstantin Ananyev 
---

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

diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile
index 68de8fc..5ce0ce0 100644
--- a/examples/l3fwd/Makefile
+++ b/examples/l3fwd/Makefile
@@ -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
diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h
new file mode 100644
index 000..f450269
--- /dev/null
+++ b/examples/l3fwd/l3fwd.h
@@ -0,0 +1,211 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2016 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