[dpdk-dev] [PATCH v5] distributor_app: new sample app

2014-10-01 Thread reshmapa
From: Reshma Pattan 

A new sample app that shows the usage of the distributor library. This
app works as follows:

* An RX thread runs which pulls packets from each ethernet port in turn
  and passes those packets to worker using a distributor component.
* The workers take the packets in turn, and determine the output port
  for those packets using basic l2forwarding doing an xor on the source
  port id.
* The RX thread takes the returned packets from the workers and enqueue
  those packets into an rte_ring structure.
* A TX thread pulls the packets off the rte_ring structure and then
  sends each packet out the output port specified previously by the worker
* Command-line option support provided only for portmask.

v5 change:
* Handled gracefull shutdown of rx and tx threads upon SIGINT.

Signed-off-by: Bruce Richardson 
Signed-off-by: Reshma Pattan 
---
 examples/Makefile |1 +
 examples/distributor_app/Makefile |   57 
 examples/distributor_app/main.c   |  600 +
 examples/distributor_app/main.h   |   46 +++
 4 files changed, 704 insertions(+), 0 deletions(-)
 create mode 100644 examples/distributor_app/Makefile
 create mode 100644 examples/distributor_app/main.c
 create mode 100644 examples/distributor_app/main.h

diff --git a/examples/Makefile b/examples/Makefile
index 6245f83..2ba82b0 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -66,5 +66,6 @@ DIRS-y += vhost
 DIRS-$(CONFIG_RTE_LIBRTE_XEN_DOM0) += vhost_xen
 DIRS-y += vmdq
 DIRS-y += vmdq_dcb
+DIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += distributor_app

 include $(RTE_SDK)/mk/rte.extsubdir.mk
diff --git a/examples/distributor_app/Makefile 
b/examples/distributor_app/Makefile
new file mode 100644
index 000..6a5bada
--- /dev/null
+++ b/examples/distributor_app/Makefile
@@ -0,0 +1,57 @@
+#   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 = distributor_app
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+
+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
+
+EXTRA_CFLAGS += -O3 -Wfatal-errors
+
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c
new file mode 100644
index 000..b6fa063
--- /dev/null
+++ b/examples/distributor_app/main.c
@@ -0,0 +1,600 @@
+/*-
+ *   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 

[dpdk-dev] [PATCH v4] distributor_app: gracefull shutdown of tx/rx threads on SIGINT

2014-10-01 Thread reshmapa
From: Reshma Pattan 

*Handled gracefull shutdown of rx and tx threads upon SIGINT.
*Gracefull shutdown of worker threads will be handled in
 future enhancements.

Signed-off-by: Reshma Pattan 
---
 examples/distributor_app/main.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c
index f555d93..b6fa063 100644
--- a/examples/distributor_app/main.c
+++ b/examples/distributor_app/main.c
@@ -85,6 +85,7 @@

 /* mask of enabled ports */
 static uint32_t enabled_port_mask = 0;
+volatile uint8_t quit_signal = 0;

 static volatile struct app_stats {
struct {
@@ -221,7 +222,7 @@ struct lcore_params {
struct rte_ring *r;
 };

-static __attribute__((noreturn)) void
+static int
 lcore_rx(struct lcore_params *p)
 {
struct rte_distributor *d = p->d;
@@ -244,7 +245,7 @@ lcore_rx(struct lcore_params *p)

printf("\nCore %u doing packet RX.\n", rte_lcore_id());
port = 0;
-   for (;;) {
+   while (!quit_signal) {
/* skip ports that are not enabled */
if ((enabled_port_mask & (1 << port)) == 0) {
if (++port == nb_ports)
@@ -307,7 +308,7 @@ flush_all_ports(struct output_buffer *tx_buffers, uint8_t 
nb_ports)
}
 }

-static __attribute__((noreturn)) void
+static int
 lcore_tx(struct rte_ring *in_r)
 {
static struct output_buffer tx_buffers[RTE_MAX_ETHPORTS];
@@ -328,7 +329,7 @@ lcore_tx(struct rte_ring *in_r)
}

printf("\nCore %u doing packet TX.\n", rte_lcore_id());
-   for (;;) {
+   while (!quit_signal) {
for (port = 0; port < nb_ports; port++) {
/* skip ports that are not enabled */
if ((enabled_port_mask & (1 << port)) == 0)
@@ -370,7 +371,6 @@ lcore_tx(struct rte_ring *in_r)
}
 }

-
 static __attribute__((noreturn)) void
 lcore_worker(struct lcore_params *p)
 {
@@ -415,7 +415,7 @@ int_handler(int sig_num)
printf(" - Out Errs:  %"PRIu64"\n", eth_stats.oerrors);
printf(" - Mbuf Errs: %"PRIu64"\n", eth_stats.rx_nombuf);
}
-   exit(0);
+   quit_signal = 1;
 }

 /* display usage */
-- 
1.7.4.1



[dpdk-dev] [PATCH v3] distributor_app: new sample app

2014-09-30 Thread reshmapa
From: Reshma Pattan 

A new sample app that shows the usage of the distributor library. This
app works as follows:

* An RX thread runs which pulls packets from each ethernet port in turn
  and passes those packets to worker using a distributor component.
* The workers take the packets in turn, and determine the output port
  for those packets using basic l2forwarding doing an xor on the source
  port id.
* The RX thread takes the returned packets from the workers and enqueue
  those packets into an rte_ring structure.
* A TX thread pulls the packets off the rte_ring structure and then
  sends each packet out the output port specified previously by the worker
* Command-line option support provided only for portmask.

Signed-off-by: Bruce Richardson 
Signed-off-by: Reshma Pattan
---
 examples/Makefile |1 +
 examples/distributor_app/Makefile |   57 
 examples/distributor_app/main.c   |  600 +
 examples/distributor_app/main.h   |   46 +++
 4 files changed, 704 insertions(+), 0 deletions(-)
 create mode 100644 examples/distributor_app/Makefile
 create mode 100644 examples/distributor_app/main.c
 create mode 100644 examples/distributor_app/main.h

diff --git a/examples/Makefile b/examples/Makefile
index 6245f83..2ba82b0 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -66,5 +66,6 @@ DIRS-y += vhost
 DIRS-$(CONFIG_RTE_LIBRTE_XEN_DOM0) += vhost_xen
 DIRS-y += vmdq
 DIRS-y += vmdq_dcb
+DIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += distributor_app

 include $(RTE_SDK)/mk/rte.extsubdir.mk
diff --git a/examples/distributor_app/Makefile 
b/examples/distributor_app/Makefile
new file mode 100644
index 000..6a5bada
--- /dev/null
+++ b/examples/distributor_app/Makefile
@@ -0,0 +1,57 @@
+#   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 = distributor_app
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+
+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
+
+EXTRA_CFLAGS += -O3 -Wfatal-errors
+
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c
new file mode 100644
index 000..f555d93
--- /dev/null
+++ b/examples/distributor_app/main.c
@@ -0,0 +1,600 @@
+/*-
+ *   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 

[dpdk-dev] [PATCH v2] distributor_app: new sample app

2014-09-24 Thread reshmapa
From: Reshma Pattan 

A new sample app that shows the usage of the distributor library. This
app works as follows:

* An RX thread runs which pulls packets from each ethernet port in turn
  and passes those packets to worker using a distributor component.
* The workers take the packets in turn, and determine the output port
  for those packets using basic l2forwarding doing an xor on the source
  port id.
* The RX thread takes the returned packets from the workers and enqueue
  those packets into an rte_ring structure.
* A TX thread pulls the packets off the rte_ring structure and then
  sends each packet out the output port specified previously by the worker
* Command-line option support provided only for portmask.

Signed-off-by: Bruce Richardson 
Signed-off-by: Reshma Pattan 
---
 examples/Makefile |   1 +
 examples/distributor_app/Makefile |  57 
 examples/distributor_app/main.c   | 585 ++
 examples/distributor_app/main.h   |  46 +++
 4 files changed, 689 insertions(+)
 create mode 100644 examples/distributor_app/Makefile
 create mode 100644 examples/distributor_app/main.c
 create mode 100644 examples/distributor_app/main.h

diff --git a/examples/Makefile b/examples/Makefile
index 6245f83..2ba82b0 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -66,5 +66,6 @@ DIRS-y += vhost
 DIRS-$(CONFIG_RTE_LIBRTE_XEN_DOM0) += vhost_xen
 DIRS-y += vmdq
 DIRS-y += vmdq_dcb
+DIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += distributor_app

 include $(RTE_SDK)/mk/rte.extsubdir.mk
diff --git a/examples/distributor_app/Makefile 
b/examples/distributor_app/Makefile
new file mode 100644
index 000..394785d
--- /dev/null
+++ b/examples/distributor_app/Makefile
@@ -0,0 +1,57 @@
+#   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-default-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# binary name
+APP = distributor_app
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+
+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
+
+EXTRA_CFLAGS += -O3 -Wfatal-errors
+
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c
new file mode 100644
index 000..628810a
--- /dev/null
+++ b/examples/distributor_app/main.c
@@ -0,0 +1,585 @@
+/*-
+ *   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 

[dpdk-dev] [PATCH 3/3] distributor_app: removed extra spaces

2014-09-16 Thread reshmapa
From: Reshma Pattan 

Changes in V2:

Signed-off-by: Reshma Pattan 
---
 examples/distributor_app/main.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c
index fab8199..b064a3a 100644
--- a/examples/distributor_app/main.c
+++ b/examples/distributor_app/main.c
@@ -230,7 +230,7 @@ lcore_rx(struct lcore_params *p)
printf("\nCore %u doing packet RX.\n", rte_lcore_id());
port = 0;
for (;;) {
-   /* skip ports that are not enabled */ 
+   /* skip ports that are not enabled */
if ((enabled_port_mask & (1 << port)) == 0){
if (++port == nb_ports)
port = 0;
@@ -283,7 +283,7 @@ flush_all_ports(struct output_buffer *tx_buffers, uint8_t 
nb_ports)
for (outp = 0; outp < nb_ports; outp++) {
/* skip ports that are not enabled */
if ((enabled_port_mask & (1 << outp)) == 0){
-   continue; 
+   continue;
}

if (tx_buffers[outp].count == 0)
@@ -302,7 +302,7 @@ lcore_tx(struct rte_ring *in_r)
uint8_t port;

for (port = 0; port < nb_ports; port++){
-   /* skip ports that are not enabled */ 
+   /* skip ports that are not enabled */
if ((enabled_port_mask & (1 << port)) == 0){
continue;
}
@@ -316,7 +316,7 @@ lcore_tx(struct rte_ring *in_r)
printf("\nCore %u doing packet TX.\n", rte_lcore_id());
for (;;) {
for (port = 0; port < nb_ports; port++) {
-   /* skip ports that are not enabled */ 
+   /* skip ports that are not enabled */
if ((enabled_port_mask & (1 << port)) == 0){
continue;
}
@@ -431,16 +431,16 @@ parse_portmask(const char *portmask)
 }

 /* Parse the argument given in the command line of the application */
-static int 
+static int
 parse_args(int argc, char **argv)
 {
 int opt;
 char **argvopt;
 int option_index;
 char *prgname = argv[0];
-static struct option lgopts[] = { 
+static struct option lgopts[] = {
 {NULL, 0, 0, 0}
-};  
+};

 argvopt = argv;

@@ -454,8 +454,8 @@ parse_args(int argc, char **argv)
 if (enabled_port_mask == 0) {
 printf("invalid portmask\n");
 print_usage(prgname);
-return -1; 
-}   
+return -1;
+}
 break;

default:
@@ -499,7 +499,7 @@ MAIN(int argc, char *argv[])

 /* parse application arguments (after the EAL ones) */
 ret = parse_args(argc, argv);
-if (ret < 0) 
+if (ret < 0)
 rte_exit(EXIT_FAILURE, "Invalid distributor parameters\n");

if (rte_lcore_count() < 3)
@@ -549,7 +549,7 @@ MAIN(int argc, char *argv[])
 if (!nb_ports_available) {
 rte_exit(EXIT_FAILURE,
 "All available ports are disabled. Please set 
portmask.\n");
-}   
+}

d = rte_distributor_create("PKT_DIST", rte_socket_id(),
rte_lcore_count() - 2);
-- 
1.8.3.1



[dpdk-dev] [PATCH 2/3] distributor_app: code review comments implementation

2014-09-16 Thread reshmapa
From: Reshma Pattan 

* support provided for command-line option portmask.
* removed -g option in make file
* spacing adjustment in header files inclusion in main.c
* removal of const +3 in delcarration of rte_mbuf inside
  output_buffer structure declaration

Changes in V2:

Signed-off-by: Reshma Pattan 
---
 examples/distributor_app/Makefile |   2 +-
 examples/distributor_app/main.c   | 137 --
 2 files changed, 133 insertions(+), 6 deletions(-)

diff --git a/examples/distributor_app/Makefile 
b/examples/distributor_app/Makefile
index d46746e..394785d 100644
--- a/examples/distributor_app/Makefile
+++ b/examples/distributor_app/Makefile
@@ -52,6 +52,6 @@ ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 CFLAGS_main.o += -Wno-return-type
 endif

-EXTRA_CFLAGS += -O3 -g -Wfatal-errors
+EXTRA_CFLAGS += -O3 -Wfatal-errors

 include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c
index 45d5bc1..fab8199 100644
--- a/examples/distributor_app/main.c
+++ b/examples/distributor_app/main.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -42,6 +43,7 @@
 #include 
 #include 
 #include 
+
 #include "main.h"

 #define RX_RING_SIZE 256
@@ -66,6 +68,9 @@
 #define BURST_SIZE 32
 #define RTE_RING_SZ 1024

+/* mask of enabled ports */
+static uint32_t enabled_port_mask = 0;
+
 static volatile struct app_stats {
struct {
uint64_t rx_pkts;
@@ -127,7 +132,7 @@ static const struct rte_eth_txconf tx_conf_default = {

 struct output_buffer {
unsigned count;
-   struct rte_mbuf *mbufs[BURST_SIZE + 3];
+   struct rte_mbuf *mbufs[BURST_SIZE];
 };

 /*
@@ -210,16 +215,27 @@ lcore_rx(struct lcore_params *p)
const int socket_id = rte_socket_id();
uint8_t port;

-   for (port = 0; port < nb_ports; port++)
+   for (port = 0; port < nb_ports; port++){
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0){
+   continue;
+   }
if (rte_eth_dev_socket_id(port) > 0 &&
rte_eth_dev_socket_id(port) != socket_id)
printf("WARNING, port %u is on remote NUMA node to "
"RX thread.\n\tPerformance will not "
"be optimal.\n", port);
+   }

printf("\nCore %u doing packet RX.\n", rte_lcore_id());
port = 0;
for (;;) {
+   /* skip ports that are not enabled */ 
+   if ((enabled_port_mask & (1 << port)) == 0){
+   if (++port == nb_ports)
+   port = 0;
+   continue;
+   }
struct rte_mbuf *bufs[BURST_SIZE*2];
const uint16_t nb_rx = rte_eth_rx_burst(port, 0, bufs,
BURST_SIZE);
@@ -265,6 +281,11 @@ flush_all_ports(struct output_buffer *tx_buffers, uint8_t 
nb_ports)
 {
uint8_t outp;
for (outp = 0; outp < nb_ports; outp++) {
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << outp)) == 0){
+   continue; 
+   }
+
if (tx_buffers[outp].count == 0)
continue;

@@ -280,16 +301,25 @@ lcore_tx(struct rte_ring *in_r)
const int socket_id = rte_socket_id();
uint8_t port;

-   for (port = 0; port < nb_ports; port++)
+   for (port = 0; port < nb_ports; port++){
+   /* skip ports that are not enabled */ 
+   if ((enabled_port_mask & (1 << port)) == 0){
+   continue;
+   }
if (rte_eth_dev_socket_id(port) > 0 &&
rte_eth_dev_socket_id(port) != socket_id)
printf("WARNING, port %u is on remote NUMA node to "
"TX thread.\n\tPerformance will not "
"be optimal.\n", port);
+   }

printf("\nCore %u doing packet TX.\n", rte_lcore_id());
for (;;) {
for (port = 0; port < nb_ports; port++) {
+   /* skip ports that are not enabled */ 
+   if ((enabled_port_mask & (1 << port)) == 0){
+   continue;
+   }
struct rte_mbuf *bufs[BURST_SIZE];
const uint16_t nb_rx = rte_ring_dequeue_burst(in_r,
(void *)bufs, BURST_SIZE);
@@ -313,6 +343,10 @@ lcore_tx(struct rte_ring *in_r)
/* workers should update in_port to hold the
 * output port value */
outp = bufs[i]->pkt.in_port;
+   

[dpdk-dev] [PATCH 1/3] distributor_app: new sample app

2014-09-16 Thread reshmapa
From: Bruce Richardson 

A new sample app that shows the usage of the distributor library. This
app works as follows:

* An RX thread runs which pulls packets from each ethernet port in turn
  and passes those packets to worker using a distributor component.
* The workers take the packets in turn, and determine the output port
  for those packets using basic l2forwarding doing an xor on the source
  port id.
* The RX thread takes the returned packets from the workers and enqueue
  those packets into an rte_ring structure.
* A TX thread pulls the packets off the rte_ring structure and then
  sends each packet out the output port specified previously by the worker

The app takes no command-line parameters other than those passed to the
EAL. The cores to be used are specified via the EAL coremask and the
ports to be used can be specified using the EAL whitelisting and
blacklisting support.
---
 examples/Makefile |   1 +
 examples/distributor_app/Makefile |  57 +
 examples/distributor_app/main.c   | 459 ++
 examples/distributor_app/main.h   |  46 
 4 files changed, 563 insertions(+)
 create mode 100644 examples/distributor_app/Makefile
 create mode 100644 examples/distributor_app/main.c
 create mode 100644 examples/distributor_app/main.h

diff --git a/examples/Makefile b/examples/Makefile
index d6b08c2..3164aab 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -64,5 +64,6 @@ DIRS-y += vhost
 DIRS-$(CONFIG_RTE_LIBRTE_XEN_DOM0) += vhost_xen
 DIRS-y += vmdq
 DIRS-y += vmdq_dcb
+DIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += distributor_app

 include $(RTE_SDK)/mk/rte.extsubdir.mk
diff --git a/examples/distributor_app/Makefile 
b/examples/distributor_app/Makefile
new file mode 100644
index 000..d46746e
--- /dev/null
+++ b/examples/distributor_app/Makefile
@@ -0,0 +1,57 @@
+#   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-default-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# binary name
+APP = distributor_app
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+
+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
+
+EXTRA_CFLAGS += -O3 -g -Wfatal-errors
+
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/distributor_app/main.c b/examples/distributor_app/main.c
new file mode 100644
index 000..45d5bc1
--- /dev/null
+++ b/examples/distributor_app/main.c
@@ -0,0 +1,459 @@
+/*-
+ *   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 

[dpdk-dev] [PATCH 0/3] distributor_app: new sample application for distributor library

2014-09-16 Thread reshmapa
From: Reshma Pattan 

A new sample app that shows the usage of the distributor library. This
app works as follows:

*An RX thread runs which pulls packets from each ethernet port in turn
and passes those packets to worker using a distributor component.

*The workers take the packets in turn, and determine the output port
for those packets using basic l2forwarding doing an xor on the source
port id.

*The RX thread takes the returned packets from the workers and enqueue
those packets into an rte_ring structure.

*A TX thread pulls the packets off the rte_ring structure and then
sends each packet out the output port specified previously by the worker

Bruce Richardson (1):
  distributor_app: new sample app

Reshma Pattan (2):
  distributor_app: code review comments implementation
  distributor_app: removed extra spaces

 examples/Makefile |   1 +
 examples/distributor_app/Makefile |  57 
 examples/distributor_app/main.c   | 586 ++
 examples/distributor_app/main.h   |  46 +++
 4 files changed, 690 insertions(+)
 create mode 100644 examples/distributor_app/Makefile
 create mode 100644 examples/distributor_app/main.c
 create mode 100644 examples/distributor_app/main.h

-- 
1.8.3.1