[dpdk-dev] [PATCH v5 2/6] Support for unique interface naming of pmds

2014-06-18 Thread Declan Doherty
Adding support to rte_eth_dev_data structure to support unique
name identifier for ethdevs to support adding slave ethdevs
(specifically virtual devices which have no public unique
identifier) to a link bonding device. This changes the API
rte_eth_dev_allocate() to require a const char *name when
allocating a ethdev, which also verifies that the name is
unique and hasn?t been already used by an existed allocated
rte_eth_dev. Also contains updates to virtual pmd?s to now call
the API with a name parameter.

Signed-off-by: Declan Doherty 
---
 lib/librte_ether/rte_ethdev.c|   32 +++--
 lib/librte_ether/rte_ethdev.h|7 +-
 lib/librte_pmd_pcap/rte_eth_pcap.c   |   22 ++--
 lib/librte_pmd_ring/rte_eth_ring.c   |   32 +++--
 lib/librte_pmd_ring/rte_eth_ring.h   |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c |2 +-
 6 files changed, 66 insertions(+), 32 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7256841..d938603 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -65,6 +65,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_ether.h"
 #include "rte_ethdev.h"
@@ -153,21 +154,40 @@ rte_eth_dev_data_alloc(void)
RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
 }

+static struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+   unsigned i;
+
+   for (i = 0; i < nb_ports; i++) {
+   if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+   return &rte_eth_devices[i];
+   }
+   return NULL;
+}
+
 struct rte_eth_dev *
-rte_eth_dev_allocate(void)
+rte_eth_dev_allocate(const char *name)
 {
struct rte_eth_dev *eth_dev;

if (nb_ports == RTE_MAX_ETHPORTS) {
-   PMD_DEBUG_TRACE("Reached maximum number of ethernet ports\n");
+   PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
return NULL;
}

if (rte_eth_dev_data == NULL)
rte_eth_dev_data_alloc();

+   if (rte_eth_dev_allocated(name) != NULL) {
+   PMD_DEBUG_TRACE("Ethernet Device with name %s already 
allocated!\n");
+   return NULL;
+   }
+
eth_dev = &rte_eth_devices[nb_ports];
eth_dev->data = &rte_eth_dev_data[nb_ports];
+   rte_snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
+   "%s", name);
eth_dev->data->port_id = nb_ports++;
return eth_dev;
 }
@@ -178,11 +198,17 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 {
struct eth_driver*eth_drv;
struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
int diag;

eth_drv = (struct eth_driver *)pci_drv;

-   eth_dev = rte_eth_dev_allocate();
+   /* Create unique Ethernet device name using PCI address */
+   rte_snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d",
+   pci_dev->addr.bus, pci_dev->addr.devid, 
pci_dev->addr.function);
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
if (eth_dev == NULL)
return -ENOMEM;

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2406e45..50df654 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1497,6 +1497,8 @@ struct rte_eth_dev_sriov {
 };
 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)

+#define RTE_ETH_NAME_MAX_LEN (32)
+
 /**
  * @internal
  * The data part, with no function pointers, associated with each ethernet 
device.
@@ -1505,6 +1507,8 @@ struct rte_eth_dev_sriov {
  * processes in a multi-process configuration.
  */
 struct rte_eth_dev_data {
+   char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
+
void **rx_queues; /**< Array of pointers to RX queues. */
void **tx_queues; /**< Array of pointers to TX queues. */
uint16_t nb_rx_queues; /**< Number of RX queues. */
@@ -1560,10 +1564,11 @@ extern uint8_t rte_eth_dev_count(void);
  * Allocates a new ethdev slot for an ethernet device and returns the pointer
  * to that slot for the driver to use.
  *
+ * @param  nameUnique identifier name for each Ethernet device
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(void);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);

 struct eth_driver;
 /**
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c 
b/lib/librte_pmd_pcap/rte_eth_pcap.c
index b3dbbda..12b7e0c 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -534,7 +534,7 @@ open_tx_iface(const char *key __rte_unused, const char 
*value, void 

[dpdk-dev] [PATCH v5 1/6] Link Bonding Library (lib/librte_pmd_bond)

2014-06-18 Thread Declan Doherty
Initial release with support for
 Mode 0 - Round Robin
 Mode 1 - Active Backup
 Mode 2 - Balance -> Supports 3 transmit polices (layer 2, layer 2+3, layer 3+4)
 Mode 3 - Broadcast

Signed-off-by: Declan Doherty 
---
 config/common_bsdapp   |5 +
 config/common_linuxapp |5 +
 lib/Makefile   |1 +
 lib/librte_pmd_bond/Makefile   |   32 +
 lib/librte_pmd_bond/rte_eth_bond.c | 2148 
 lib/librte_pmd_bond/rte_eth_bond.h |  255 +
 mk/rte.app.mk  |5 +
 7 files changed, 2451 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 989e1da..214398b 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -206,6 +206,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 5b896c3..2bf90df 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -244,6 +244,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Compile Xen PMD
 #
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
diff --git a/lib/Makefile b/lib/Makefile
index c58c0c9..88e875f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -49,6 +49,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl
diff --git a/lib/librte_pmd_bond/Makefile b/lib/librte_pmd_bond/Makefile
new file mode 100644
index 000..51f6159
--- /dev/null
+++ b/lib/librte_pmd_bond/Makefile
@@ -0,0 +1,32 @@
+# 
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_bond.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond.c
+
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_eth_bond.h
+
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_malloc
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_kvargs
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_bond/rte_eth_bond.c 
b/lib/librte_pmd_bond/rte_eth_bond.c
new file mode 100644
index 000..69e7bae
--- /dev/null
+++ b/lib/librte_pmd_bond/rte_eth_bond.c
@@ -0,0 +1,2148 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#inclu

[dpdk-dev] [PATCH v5 6/6] Link Bonding Library doxygen additions

2014-06-18 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 doc/doxy-api-index.md |1 +
 doc/doxy-api.conf |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/doc/doxy-api-index.md b/doc/doxy-api-index.md
index 7b26e98..ee3ad4f 100644
--- a/doc/doxy-api-index.md
+++ b/doc/doxy-api-index.md
@@ -36,6 +36,7 @@ API {#index}
 There are many libraries, so their headers may be grouped by topics:

 - **device**:
+  [bond]   (@ref rte_eth_bond.h),
   [ethdev] (@ref rte_ethdev.h),
   [devargs](@ref rte_devargs.h),
   [KNI](@ref rte_kni.h),
diff --git a/doc/doxy-api.conf b/doc/doxy-api.conf
index f380d9a..b15a340 100644
--- a/doc/doxy-api.conf
+++ b/doc/doxy-api.conf
@@ -30,6 +30,7 @@

 PROJECT_NAME= DPDK
 INPUT   = doc/doxy-api-index.md \
+  lib/librte_pmd_bond \
   lib/librte_eal/common/include \
   lib/librte_acl \
   lib/librte_distributor \
-- 
1.7.0.7



[dpdk-dev] [PATCH v5 4/6] Link bonding Unit Tests

2014-06-18 Thread Declan Doherty
Including:
 - code to generate packet bursts for testing rx and tx
   functionality of bonded device
 - virtual/stubbed out ethdev for use as slave ethdev in testing

Signed-off-by: Declan Doherty 
---
 app/test/Makefile |4 +-
 app/test/commands.c   |7 +
 app/test/packet_burst_generator.c |  287 +++
 app/test/packet_burst_generator.h |   78 +
 app/test/test.h   |1 +
 app/test/test_link_bonding.c  | 3958 +
 app/test/virtual_pmd.c|  574 ++
 app/test/virtual_pmd.h|   74 +
 8 files changed, 4982 insertions(+), 1 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 9c52460..643f1b9 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -102,7 +102,9 @@ SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor_perf.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_devargs.c
-
+SRCS-$(CONFIG_RTE_APP_TEST) += virtual_pmd.c
+SRCS-$(CONFIG_RTE_APP_TEST) += packet_burst_generator.c
+SRCS-$(CONFIG_RTE_APP_TEST) += test_link_bonding.c
 ifeq ($(CONFIG_RTE_APP_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
diff --git a/app/test/commands.c b/app/test/commands.c
index c9dc085..5f23420 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -159,6 +159,10 @@ static void cmd_autotest_parsed(void *parsed_result,
ret = test_timer();
if (!strcmp(res->autotest, "timer_perf_autotest"))
ret = test_timer_perf();
+#ifdef RTE_LIBRTE_PMD_BOND
+   if (!strcmp(res->autotest, "link_bonding_autotest"))
+   ret = test_link_bonding();
+#endif
if (!strcmp(res->autotest, "mempool_autotest"))
ret = test_mempool();
if (!strcmp(res->autotest, "mempool_perf_autotest"))
@@ -227,6 +231,9 @@ cmdline_parse_token_string_t cmd_autotest_autotest =
"alarm_autotest#interrupt_autotest#"
"version_autotest#eal_fs_autotest#"
"cmdline_autotest#func_reentrancy_autotest#"
+#ifdef RTE_LIBRTE_PMD_BOND
+   "link_bonding_autotest#"
+#endif
"mempool_perf_autotest#hash_perf_autotest#"
"memcpy_perf_autotest#ring_perf_autotest#"
"red_autotest#meter_autotest#sched_autotest#"
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
new file mode 100644
index 000..5d539f1
--- /dev/null
+++ b/app/test/packet_burst_generator.c
@@ -0,0 +1,287 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include "packet_burst_generator.h"
+
+#define UDP_SRC_PORT 1024
+#define UDP_DST_PORT 1024
+
+
+#define IP_DEFTTL  64   /* from RFC 1340. */
+#define IP_VERSION 0

[dpdk-dev] [PATCH v5 0/6] Link Bonding Library

2014-06-18 Thread Declan Doherty
This patch contains the initial release of the Link Bonding PMD Library

Supporting bonding modes:
 0 - Round Robin
 1 - Active Backup
 2 - Balance (Supporting 3 transmission polices)
layer 2, layer 2+3, layer 3+4
 3 - Broadcast

Version 5 of patch set:
Contains changes to EAL code to allow initialisation of Bonded devices from 
application startup options. rte_eal_init now calls rte_eal_pci_probe 
between calling rte_eal_dev_init with PRE and POST PCI probe flags. This gets
around polluting the eal pci code with references to link bonding devices.
Also rte_eal_pci_probe can now be called multiple times and will not try to
re-initialize the driver if one already exists, this means that existing
applications which currently call rte_eal_pci_probe will not be affected
by this change


Patch Set Description:
 0001 - librte_pmd_bond + makefile changes
 0002 - librte_ether changes to support unique naming of pmds 
 0003 - librte_eal changes to support bonding device intialization
 0005 - link bonding unti test suite
 0005 - testpmd link bonding support changes
 0006 - doxygen additions


Declan Doherty (6):
  Link Bonding Library (lib/librte_pmd_bond)
  Support for unique interface naming of pmds
  EAL support for link bonding device initialization
  Link bonding Unit Tests
  testpmd link bonding additions
  Link Bonding Library doxygen additions

 app/test-pmd/cmdline.c  |  579 
 app/test-pmd/config.c   |4 +-
 app/test-pmd/parameters.c   |3 +
 app/test-pmd/testpmd.c  |   40 +-
 app/test-pmd/testpmd.h  |2 +
 app/test/Makefile   |4 +-
 app/test/commands.c |7 +
 app/test/packet_burst_generator.c   |  287 ++
 app/test/packet_burst_generator.h   |   78 +
 app/test/test.h |1 +
 app/test/test_link_bonding.c| 3958 +++
 app/test/virtual_pmd.c  |  574 
 app/test/virtual_pmd.h  |   74 +
 config/common_bsdapp|5 +
 config/common_linuxapp  |5 +
 doc/doxy-api-index.md   |1 +
 doc/doxy-api.conf   |1 +
 lib/Makefile|1 +
 lib/librte_eal/bsdapp/eal/eal.c |   10 +-
 lib/librte_eal/common/eal_common_dev.c  |   58 +-
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 -
 lib/librte_eal/common/include/rte_dev.h |   13 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 lib/librte_ether/rte_ethdev.c   |   32 +-
 lib/librte_ether/rte_ethdev.h   |7 +-
 lib/librte_pmd_bond/Makefile|   32 +
 lib/librte_pmd_bond/rte_eth_bond.c  | 2148 +++
 lib/librte_pmd_bond/rte_eth_bond.h  |  255 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c  |   22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  |   32 +-
 lib/librte_pmd_ring/rte_eth_ring.h  |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|2 +-
 mk/rte.app.mk   |5 +
 34 files changed, 8193 insertions(+), 71 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h



[dpdk-dev] [PATCH v5 3/6] EAL support for link bonding device initialization

2014-06-18 Thread Declan Doherty
Updating functionality in EAL to support adding link bonding
devices via ?vdev option. Link bonding devices will be
initialized after all physical devices have been probed and
initialized.

Signed-off-by: Declan Doherty 
---
 lib/librte_eal/bsdapp/eal/eal.c |   10 -
 lib/librte_eal/common/eal_common_dev.c  |   58 ++
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 ---
 lib/librte_eal/common/include/rte_dev.h |   13 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 6 files changed, 73 insertions(+), 29 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index a1f014f..c53f63e 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -874,7 +874,7 @@ rte_eal_init(int argc, char **argv)

rte_eal_mcfg_complete();

-   if (rte_eal_dev_init() < 0)
+   if (rte_eal_dev_init(PMD_INIT_PRE_PCI_PROBE) < 0)
rte_panic("Cannot init pmd devices\n");

RTE_LCORE_FOREACH_SLAVE(i) {
@@ -906,6 +906,14 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
rte_eal_mp_wait_lcore();

+   /* Probe & Initialize PCI devices */
+   if (rte_eal_pci_probe())
+   rte_panic("Cannot probe PCI\n");
+
+   /* Initialize any outstanding devices */
+   if (rte_eal_dev_init(PMD_INIT_POST_PCI_PROBE) < 0)
+   rte_panic("Cannot init pmd devices\n");
+
return fctret;
 }

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..8e80093 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -62,7 +62,7 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_dev_init(void)
+rte_eal_dev_init(uint8_t init_pri)
 {
struct rte_devargs *devargs;
struct rte_driver *driver;
@@ -80,30 +80,52 @@ rte_eal_dev_init(void)
continue;

TAILQ_FOREACH(driver, &dev_driver_list, next) {
-   if (driver->type != PMD_VDEV)
-   continue;
+   /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device,
+* virtual devices are initialized pre PCI probing and 
bonded
+* device are post pci probing */
+   if ((driver->type == PMD_VDEV && init_pri ==
+   PMD_INIT_PRE_PCI_PROBE) ||
+   (driver->type == PMD_BDEV && init_pri ==
+   PMD_INIT_POST_PCI_PROBE)) {

-   /* search a driver prefix in virtual device name */
-   if (!strncmp(driver->name, devargs->virtual.drv_name,
-   strlen(driver->name))) {
-   driver->init(devargs->virtual.drv_name,
-   devargs->args);
-   break;
+   /* search a driver prefix in virtual device 
name */
+   if (!strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   printf("init (%u) %s\n", init_pri, 
devargs->virtual.drv_name);
+   driver->init(devargs->virtual.drv_name,
+   devargs->args);
+   break;
+   }
}
}

-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   /* If initializing pre PCI probe, then we don't expect a bonded 
driver
+* to be found */
+   if (init_pri == PMD_INIT_PRE_PCI_PROBE &&
+   strncmp(RTE_PMD_BOND, devargs->virtual.drv_name,
+   strlen(RTE_PMD_BOND)) != 0) {
+   if (driver == NULL) {
+   rte_panic("no driver found for virtual device 
%s\n",
+   devargs->virtual.drv_name);
+   }
+   } else if (init_pri == PMD_INIT_POST_PCI_PROBE &&
+   strncmp(RTE_PMD_BOND, devargs->virtual.drv_name,
+   strlen(RTE_PMD_BOND)) == 0) {
+   if (driver == NULL) {
+   rte_panic("no driver f

[dpdk-dev] [PATCH v5 5/6] testpmd link bonding additions

2014-06-18 Thread Declan Doherty
 - Includes the ability to create new bonded devices.
 - Add /remove bonding slave devices.
 - Interogate bonded device stats/configuration
 - Change bonding modes and select balance transmit polices

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c|  579 +
 app/test-pmd/config.c |4 +-
 app/test-pmd/parameters.c |3 +
 app/test-pmd/testpmd.c|   40 +++-
 app/test-pmd/testpmd.h|2 +
 5 files changed, 619 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index e3e51fc..967c058 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -84,6 +84,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_LIBRTE_PMD_BOND
+#include 
+#endif

 #include "testpmd.h"

@@ -404,6 +407,31 @@ static void cmd_help_long_parsed(void *parsed_result,
"   Show the bypass configuration for a bypass enabled 
NIC"
" using the lowest port on the NIC.\n\n"
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+   "create bonded device (mode) (socket)\n"
+   "   Create a new bonded device with specific 
bonding mode and socket.\n\n"
+
+   "add bonding slave (slave_id) (port_id)\n"
+   "   Add a slave device to a bonded device.\n\n"
+
+   "remove bonding slave (slave_id) (port_id)\n"
+   "   Remove a slave device from a bonded device.\n\n"
+
+   "set bonding mode (value) (port_id)\n"
+   "   Set the bonding mode on a bonded device.\n\n"
+
+   "set bonding primary (slave_id) (port_id)\n"
+   "   Set the primary slave for a bonded device.\n\n"
+
+   "show bonding config (port_id)\n"
+   "   Show the bonding config for port_id.\n\n"
+
+   "set bonding mac_addr (port_id) (address)\n"
+   "   Set the MAC address of a bonded device.\n\n"
+
+   "set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
+   "   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+#endif

, list_pkt_forwarding_modes()
);
@@ -3031,6 +3059,547 @@ cmdline_parse_inst_t cmd_show_bypass_config = {
 };
 #endif

+#ifdef RTE_LIBRTE_PMD_BOND
+/* *** SET BONDING MODE *** */
+struct cmd_set_bonding_mode_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mode;
+   uint8_t value;
+   uint8_t port_id;
+};
+
+static void cmd_set_bonding_mode_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bonding_mode_result *res = parsed_result;
+   portid_t port_id = res->port_id;
+
+   /* Set the bonding mode for the relevant port. */
+   if (0 != rte_eth_bond_mode_set(port_id, res->value))
+   printf("\t Failed to set bonding mode for port = %d.\n", 
port_id);
+}
+
+cmdline_parse_token_string_t cmd_setbonding_mode_set =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_setbonding_mode_mode =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   mode, "mode");
+cmdline_parse_token_num_t cmd_setbonding_mode_value =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   value, UINT8);
+cmdline_parse_token_num_t cmd_setbonding_mode_port =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_set_bonding_mode = {
+   .f = cmd_set_bonding_mode_parsed,
+   .help_str = "set bonding mode (mode_value) (port_id): Set the 
bonding mode for port_id",
+   .data = NULL,
+   .tokens = {
+   (void *) &cmd_setbonding_mode_set,
+   (void *) &cmd_setbonding_mode_bonding,
+   (void *) &cmd_setbonding_mode_mode,
+   (void *) &cmd_setbonding_mode_value,
+   (void *) &cmd_setbonding_mode_port,
+   NULL
+   }
+};
+
+/* *** SET BALANCE XMIT POLICY *** */
+struct cmd_set_bonding_balance_xmit_policy_result {
+  

[dpdk-dev] [PATCH v6 0/6] Link Bonding Library

2014-06-24 Thread Declan Doherty
This patch contains the initial release of the Link Bonding PMD Library

Supporting bonding modes:
 0 - Round Robin
 1 - Active Backup
 2 - Balance (Supporting 3 transmission polices)
layer 2, layer 2+3, layer 3+4
 3 - Broadcast

Version 6 of patch set:
Small fix for tx burst function in round robin mode which caused packets
not to be distributed evenly across slaves if the burst sizes is continually 1. 

Patch Set Description:
 0001 - librte_pmd_bond + makefile changes
 0002 - librte_ether changes to support unique naming of pmds 
 0003 - librte_eal changes to support bonding device intialization
 0005 - link bonding unti test suite
 0005 - testpmd link bonding support changes
 0006 - doxygen additions


Declan Doherty (6):
  Link Bonding Library (lib/librte_pmd_bond)
  Support for unique interface naming of pmds
  EAL support for link bonding device initialization
  Link bonding Unit Tests
  testpmd link bonding additions
  Link Bonding Library doxygen additions

 app/test-pmd/cmdline.c  |  579 
 app/test-pmd/config.c   |4 +-
 app/test-pmd/parameters.c   |3 +
 app/test-pmd/testpmd.c  |   40 +-
 app/test-pmd/testpmd.h  |2 +
 app/test/Makefile   |4 +-
 app/test/commands.c |7 +
 app/test/packet_burst_generator.c   |  287 ++
 app/test/packet_burst_generator.h   |   78 +
 app/test/test.h |1 +
 app/test/test_link_bonding.c| 3958 +++
 app/test/virtual_pmd.c  |  574 
 app/test/virtual_pmd.h  |   74 +
 config/common_bsdapp|5 +
 config/common_linuxapp  |5 +
 doc/doxy-api-index.md   |1 +
 doc/doxy-api.conf   |1 +
 lib/Makefile|1 +
 lib/librte_eal/bsdapp/eal/eal.c |   10 +-
 lib/librte_eal/common/eal_common_dev.c  |   58 +-
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 -
 lib/librte_eal/common/include/rte_dev.h |   13 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 lib/librte_ether/rte_ethdev.c   |   32 +-
 lib/librte_ether/rte_ethdev.h   |7 +-
 lib/librte_pmd_bond/Makefile|   32 +
 lib/librte_pmd_bond/rte_eth_bond.c  | 2142 +++
 lib/librte_pmd_bond/rte_eth_bond.h  |  255 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c  |   22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  |   32 +-
 lib/librte_pmd_ring/rte_eth_ring.h  |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|2 +-
 mk/rte.app.mk   |5 +
 34 files changed, 8187 insertions(+), 71 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h



[dpdk-dev] [PATCH v6 2/6] Support for unique interface naming of pmds

2014-06-24 Thread Declan Doherty
Adding support to rte_eth_dev_data structure to support unique
name identifier for ethdevs to support adding slave ethdevs
(specifically virtual devices which have no public unique
identifier) to a link bonding device. This changes the API
rte_eth_dev_allocate() to require a const char *name when
allocating a ethdev, which also verifies that the name is
unique and hasn?t been already used by an existed allocated
rte_eth_dev. Also contains updates to virtual pmd?s to now call
the API with a name parameter.

Signed-off-by: Declan Doherty 
---
 lib/librte_ether/rte_ethdev.c|   32 +++--
 lib/librte_ether/rte_ethdev.h|7 +-
 lib/librte_pmd_pcap/rte_eth_pcap.c   |   22 ++--
 lib/librte_pmd_ring/rte_eth_ring.c   |   32 +++--
 lib/librte_pmd_ring/rte_eth_ring.h   |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c |2 +-
 6 files changed, 66 insertions(+), 32 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7256841..d938603 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -65,6 +65,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_ether.h"
 #include "rte_ethdev.h"
@@ -153,21 +154,40 @@ rte_eth_dev_data_alloc(void)
RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
 }

+static struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+   unsigned i;
+
+   for (i = 0; i < nb_ports; i++) {
+   if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+   return &rte_eth_devices[i];
+   }
+   return NULL;
+}
+
 struct rte_eth_dev *
-rte_eth_dev_allocate(void)
+rte_eth_dev_allocate(const char *name)
 {
struct rte_eth_dev *eth_dev;

if (nb_ports == RTE_MAX_ETHPORTS) {
-   PMD_DEBUG_TRACE("Reached maximum number of ethernet ports\n");
+   PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
return NULL;
}

if (rte_eth_dev_data == NULL)
rte_eth_dev_data_alloc();

+   if (rte_eth_dev_allocated(name) != NULL) {
+   PMD_DEBUG_TRACE("Ethernet Device with name %s already 
allocated!\n");
+   return NULL;
+   }
+
eth_dev = &rte_eth_devices[nb_ports];
eth_dev->data = &rte_eth_dev_data[nb_ports];
+   rte_snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
+   "%s", name);
eth_dev->data->port_id = nb_ports++;
return eth_dev;
 }
@@ -178,11 +198,17 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 {
struct eth_driver*eth_drv;
struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
int diag;

eth_drv = (struct eth_driver *)pci_drv;

-   eth_dev = rte_eth_dev_allocate();
+   /* Create unique Ethernet device name using PCI address */
+   rte_snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d",
+   pci_dev->addr.bus, pci_dev->addr.devid, 
pci_dev->addr.function);
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
if (eth_dev == NULL)
return -ENOMEM;

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2406e45..50df654 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1497,6 +1497,8 @@ struct rte_eth_dev_sriov {
 };
 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)

+#define RTE_ETH_NAME_MAX_LEN (32)
+
 /**
  * @internal
  * The data part, with no function pointers, associated with each ethernet 
device.
@@ -1505,6 +1507,8 @@ struct rte_eth_dev_sriov {
  * processes in a multi-process configuration.
  */
 struct rte_eth_dev_data {
+   char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
+
void **rx_queues; /**< Array of pointers to RX queues. */
void **tx_queues; /**< Array of pointers to TX queues. */
uint16_t nb_rx_queues; /**< Number of RX queues. */
@@ -1560,10 +1564,11 @@ extern uint8_t rte_eth_dev_count(void);
  * Allocates a new ethdev slot for an ethernet device and returns the pointer
  * to that slot for the driver to use.
  *
+ * @param  nameUnique identifier name for each Ethernet device
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(void);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);

 struct eth_driver;
 /**
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c 
b/lib/librte_pmd_pcap/rte_eth_pcap.c
index b3dbbda..12b7e0c 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -534,7 +534,7 @@ open_tx_iface(const char *key __rte_unused, const char 
*value, void 

[dpdk-dev] [PATCH v6 3/6] EAL support for link bonding device initialization

2014-06-24 Thread Declan Doherty
Updating functionality in EAL to support adding link bonding
devices via ?vdev option. Link bonding devices will be
initialized after all physical devices have been probed and
initialized.

Signed-off-by: Declan Doherty 
---
 lib/librte_eal/bsdapp/eal/eal.c |   10 -
 lib/librte_eal/common/eal_common_dev.c  |   58 ++
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 ---
 lib/librte_eal/common/include/rte_dev.h |   13 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 6 files changed, 73 insertions(+), 29 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index a1f014f..c53f63e 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -874,7 +874,7 @@ rte_eal_init(int argc, char **argv)

rte_eal_mcfg_complete();

-   if (rte_eal_dev_init() < 0)
+   if (rte_eal_dev_init(PMD_INIT_PRE_PCI_PROBE) < 0)
rte_panic("Cannot init pmd devices\n");

RTE_LCORE_FOREACH_SLAVE(i) {
@@ -906,6 +906,14 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
rte_eal_mp_wait_lcore();

+   /* Probe & Initialize PCI devices */
+   if (rte_eal_pci_probe())
+   rte_panic("Cannot probe PCI\n");
+
+   /* Initialize any outstanding devices */
+   if (rte_eal_dev_init(PMD_INIT_POST_PCI_PROBE) < 0)
+   rte_panic("Cannot init pmd devices\n");
+
return fctret;
 }

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..8e80093 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -62,7 +62,7 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_dev_init(void)
+rte_eal_dev_init(uint8_t init_pri)
 {
struct rte_devargs *devargs;
struct rte_driver *driver;
@@ -80,30 +80,52 @@ rte_eal_dev_init(void)
continue;

TAILQ_FOREACH(driver, &dev_driver_list, next) {
-   if (driver->type != PMD_VDEV)
-   continue;
+   /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device,
+* virtual devices are initialized pre PCI probing and 
bonded
+* device are post pci probing */
+   if ((driver->type == PMD_VDEV && init_pri ==
+   PMD_INIT_PRE_PCI_PROBE) ||
+   (driver->type == PMD_BDEV && init_pri ==
+   PMD_INIT_POST_PCI_PROBE)) {

-   /* search a driver prefix in virtual device name */
-   if (!strncmp(driver->name, devargs->virtual.drv_name,
-   strlen(driver->name))) {
-   driver->init(devargs->virtual.drv_name,
-   devargs->args);
-   break;
+   /* search a driver prefix in virtual device 
name */
+   if (!strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   printf("init (%u) %s\n", init_pri, 
devargs->virtual.drv_name);
+   driver->init(devargs->virtual.drv_name,
+   devargs->args);
+   break;
+   }
}
}

-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   /* If initializing pre PCI probe, then we don't expect a bonded 
driver
+* to be found */
+   if (init_pri == PMD_INIT_PRE_PCI_PROBE &&
+   strncmp(RTE_PMD_BOND, devargs->virtual.drv_name,
+   strlen(RTE_PMD_BOND)) != 0) {
+   if (driver == NULL) {
+   rte_panic("no driver found for virtual device 
%s\n",
+   devargs->virtual.drv_name);
+   }
+   } else if (init_pri == PMD_INIT_POST_PCI_PROBE &&
+   strncmp(RTE_PMD_BOND, devargs->virtual.drv_name,
+   strlen(RTE_PMD_BOND)) == 0) {
+   if (driver == NULL) {
+   rte_panic("no driver f

[dpdk-dev] [PATCH v6 5/6] testpmd link bonding additions

2014-06-24 Thread Declan Doherty
 - Includes the ability to create new bonded devices.
 - Add /remove bonding slave devices.
 - Interogate bonded device stats/configuration
 - Change bonding modes and select balance transmit polices

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c|  579 +
 app/test-pmd/config.c |4 +-
 app/test-pmd/parameters.c |3 +
 app/test-pmd/testpmd.c|   40 +++-
 app/test-pmd/testpmd.h|2 +
 5 files changed, 619 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 3298360..fcc6449 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -84,6 +84,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_LIBRTE_PMD_BOND
+#include 
+#endif

 #include "testpmd.h"

@@ -404,6 +407,31 @@ static void cmd_help_long_parsed(void *parsed_result,
"   Show the bypass configuration for a bypass enabled 
NIC"
" using the lowest port on the NIC.\n\n"
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+   "create bonded device (mode) (socket)\n"
+   "   Create a new bonded device with specific 
bonding mode and socket.\n\n"
+
+   "add bonding slave (slave_id) (port_id)\n"
+   "   Add a slave device to a bonded device.\n\n"
+
+   "remove bonding slave (slave_id) (port_id)\n"
+   "   Remove a slave device from a bonded device.\n\n"
+
+   "set bonding mode (value) (port_id)\n"
+   "   Set the bonding mode on a bonded device.\n\n"
+
+   "set bonding primary (slave_id) (port_id)\n"
+   "   Set the primary slave for a bonded device.\n\n"
+
+   "show bonding config (port_id)\n"
+   "   Show the bonding config for port_id.\n\n"
+
+   "set bonding mac_addr (port_id) (address)\n"
+   "   Set the MAC address of a bonded device.\n\n"
+
+   "set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
+   "   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+#endif

, list_pkt_forwarding_modes()
);
@@ -3031,6 +3059,547 @@ cmdline_parse_inst_t cmd_show_bypass_config = {
 };
 #endif

+#ifdef RTE_LIBRTE_PMD_BOND
+/* *** SET BONDING MODE *** */
+struct cmd_set_bonding_mode_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mode;
+   uint8_t value;
+   uint8_t port_id;
+};
+
+static void cmd_set_bonding_mode_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bonding_mode_result *res = parsed_result;
+   portid_t port_id = res->port_id;
+
+   /* Set the bonding mode for the relevant port. */
+   if (0 != rte_eth_bond_mode_set(port_id, res->value))
+   printf("\t Failed to set bonding mode for port = %d.\n", 
port_id);
+}
+
+cmdline_parse_token_string_t cmd_setbonding_mode_set =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_setbonding_mode_mode =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   mode, "mode");
+cmdline_parse_token_num_t cmd_setbonding_mode_value =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   value, UINT8);
+cmdline_parse_token_num_t cmd_setbonding_mode_port =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_set_bonding_mode = {
+   .f = cmd_set_bonding_mode_parsed,
+   .help_str = "set bonding mode (mode_value) (port_id): Set the 
bonding mode for port_id",
+   .data = NULL,
+   .tokens = {
+   (void *) &cmd_setbonding_mode_set,
+   (void *) &cmd_setbonding_mode_bonding,
+   (void *) &cmd_setbonding_mode_mode,
+   (void *) &cmd_setbonding_mode_value,
+   (void *) &cmd_setbonding_mode_port,
+   NULL
+   }
+};
+
+/* *** SET BALANCE XMIT POLICY *** */
+struct cmd_set_bonding_balance_xmit_policy_result {
+  

[dpdk-dev] [PATCH v6 1/6] Link Bonding Library (lib/librte_pmd_bond)

2014-06-24 Thread Declan Doherty
Initial release with support for
 Mode 0 - Round Robin
 Mode 1 - Active Backup
 Mode 2 - Balance -> Supports 3 transmit polices (layer 2, layer 2+3, layer 3+4)
 Mode 3 - Broadcast

Signed-off-by: Declan Doherty 
---
 config/common_bsdapp   |5 +
 config/common_linuxapp |5 +
 lib/Makefile   |1 +
 lib/librte_pmd_bond/Makefile   |   32 +
 lib/librte_pmd_bond/rte_eth_bond.c | 2142 
 lib/librte_pmd_bond/rte_eth_bond.h |  255 +
 mk/rte.app.mk  |5 +
 7 files changed, 2445 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 989e1da..214398b 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -206,6 +206,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 5b896c3..2bf90df 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -244,6 +244,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Compile Xen PMD
 #
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
diff --git a/lib/Makefile b/lib/Makefile
index c58c0c9..88e875f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -49,6 +49,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl
diff --git a/lib/librte_pmd_bond/Makefile b/lib/librte_pmd_bond/Makefile
new file mode 100644
index 000..51f6159
--- /dev/null
+++ b/lib/librte_pmd_bond/Makefile
@@ -0,0 +1,32 @@
+# 
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_bond.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond.c
+
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_eth_bond.h
+
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_malloc
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_kvargs
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_bond/rte_eth_bond.c 
b/lib/librte_pmd_bond/rte_eth_bond.c
new file mode 100644
index 000..1b0cf81
--- /dev/null
+++ b/lib/librte_pmd_bond/rte_eth_bond.c
@@ -0,0 +1,2142 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#inclu

[dpdk-dev] [PATCH v6 6/6] Link Bonding Library doxygen additions

2014-06-24 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 doc/doxy-api-index.md |1 +
 doc/doxy-api.conf |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/doc/doxy-api-index.md b/doc/doxy-api-index.md
index 7b26e98..ee3ad4f 100644
--- a/doc/doxy-api-index.md
+++ b/doc/doxy-api-index.md
@@ -36,6 +36,7 @@ API {#index}
 There are many libraries, so their headers may be grouped by topics:

 - **device**:
+  [bond]   (@ref rte_eth_bond.h),
   [ethdev] (@ref rte_ethdev.h),
   [devargs](@ref rte_devargs.h),
   [KNI](@ref rte_kni.h),
diff --git a/doc/doxy-api.conf b/doc/doxy-api.conf
index f380d9a..b15a340 100644
--- a/doc/doxy-api.conf
+++ b/doc/doxy-api.conf
@@ -30,6 +30,7 @@

 PROJECT_NAME= DPDK
 INPUT   = doc/doxy-api-index.md \
+  lib/librte_pmd_bond \
   lib/librte_eal/common/include \
   lib/librte_acl \
   lib/librte_distributor \
-- 
1.7.0.7



[dpdk-dev] [PATCH v6 4/6] Link bonding Unit Tests

2014-06-24 Thread Declan Doherty
Including:
 - code to generate packet bursts for testing rx and tx
   functionality of bonded device
 - virtual/stubbed out ethdev for use as slave ethdev in testing

Signed-off-by: Declan Doherty 
---
 app/test/Makefile |4 +-
 app/test/commands.c   |7 +
 app/test/packet_burst_generator.c |  287 +++
 app/test/packet_burst_generator.h |   78 +
 app/test/test.h   |1 +
 app/test/test_link_bonding.c  | 3958 +
 app/test/virtual_pmd.c|  574 ++
 app/test/virtual_pmd.h|   74 +
 8 files changed, 4982 insertions(+), 1 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 9c52460..643f1b9 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -102,7 +102,9 @@ SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor_perf.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_devargs.c
-
+SRCS-$(CONFIG_RTE_APP_TEST) += virtual_pmd.c
+SRCS-$(CONFIG_RTE_APP_TEST) += packet_burst_generator.c
+SRCS-$(CONFIG_RTE_APP_TEST) += test_link_bonding.c
 ifeq ($(CONFIG_RTE_APP_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
diff --git a/app/test/commands.c b/app/test/commands.c
index c9dc085..5f23420 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -159,6 +159,10 @@ static void cmd_autotest_parsed(void *parsed_result,
ret = test_timer();
if (!strcmp(res->autotest, "timer_perf_autotest"))
ret = test_timer_perf();
+#ifdef RTE_LIBRTE_PMD_BOND
+   if (!strcmp(res->autotest, "link_bonding_autotest"))
+   ret = test_link_bonding();
+#endif
if (!strcmp(res->autotest, "mempool_autotest"))
ret = test_mempool();
if (!strcmp(res->autotest, "mempool_perf_autotest"))
@@ -227,6 +231,9 @@ cmdline_parse_token_string_t cmd_autotest_autotest =
"alarm_autotest#interrupt_autotest#"
"version_autotest#eal_fs_autotest#"
"cmdline_autotest#func_reentrancy_autotest#"
+#ifdef RTE_LIBRTE_PMD_BOND
+   "link_bonding_autotest#"
+#endif
"mempool_perf_autotest#hash_perf_autotest#"
"memcpy_perf_autotest#ring_perf_autotest#"
"red_autotest#meter_autotest#sched_autotest#"
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
new file mode 100644
index 000..5d539f1
--- /dev/null
+++ b/app/test/packet_burst_generator.c
@@ -0,0 +1,287 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include "packet_burst_generator.h"
+
+#define UDP_SRC_PORT 1024
+#define UDP_DST_PORT 1024
+
+
+#define IP_DEFTTL  64   /* from RFC 1340. */
+#define IP_VERSION 0

[dpdk-dev] [PATCH v7 3/6] EAL support for link bonding device initialization

2014-06-24 Thread Declan Doherty
Updating functionality in EAL to support adding link bonding
devices via ?vdev option. Link bonding devices will be
initialized after all physical devices have been probed and
initialized.

Signed-off-by: Declan Doherty 
---
 lib/librte_eal/bsdapp/eal/eal.c |   10 -
 lib/librte_eal/common/eal_common_dev.c  |   58 ++
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 ---
 lib/librte_eal/common/include/rte_dev.h |   13 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 6 files changed, 73 insertions(+), 29 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index a1f014f..c53f63e 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -874,7 +874,7 @@ rte_eal_init(int argc, char **argv)

rte_eal_mcfg_complete();

-   if (rte_eal_dev_init() < 0)
+   if (rte_eal_dev_init(PMD_INIT_PRE_PCI_PROBE) < 0)
rte_panic("Cannot init pmd devices\n");

RTE_LCORE_FOREACH_SLAVE(i) {
@@ -906,6 +906,14 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
rte_eal_mp_wait_lcore();

+   /* Probe & Initialize PCI devices */
+   if (rte_eal_pci_probe())
+   rte_panic("Cannot probe PCI\n");
+
+   /* Initialize any outstanding devices */
+   if (rte_eal_dev_init(PMD_INIT_POST_PCI_PROBE) < 0)
+   rte_panic("Cannot init pmd devices\n");
+
return fctret;
 }

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..8e80093 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -62,7 +62,7 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_dev_init(void)
+rte_eal_dev_init(uint8_t init_pri)
 {
struct rte_devargs *devargs;
struct rte_driver *driver;
@@ -80,30 +80,52 @@ rte_eal_dev_init(void)
continue;

TAILQ_FOREACH(driver, &dev_driver_list, next) {
-   if (driver->type != PMD_VDEV)
-   continue;
+   /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device,
+* virtual devices are initialized pre PCI probing and 
bonded
+* device are post pci probing */
+   if ((driver->type == PMD_VDEV && init_pri ==
+   PMD_INIT_PRE_PCI_PROBE) ||
+   (driver->type == PMD_BDEV && init_pri ==
+   PMD_INIT_POST_PCI_PROBE)) {

-   /* search a driver prefix in virtual device name */
-   if (!strncmp(driver->name, devargs->virtual.drv_name,
-   strlen(driver->name))) {
-   driver->init(devargs->virtual.drv_name,
-   devargs->args);
-   break;
+   /* search a driver prefix in virtual device 
name */
+   if (!strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   printf("init (%u) %s\n", init_pri, 
devargs->virtual.drv_name);
+   driver->init(devargs->virtual.drv_name,
+   devargs->args);
+   break;
+   }
}
}

-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   /* If initializing pre PCI probe, then we don't expect a bonded 
driver
+* to be found */
+   if (init_pri == PMD_INIT_PRE_PCI_PROBE &&
+   strncmp(RTE_PMD_BOND, devargs->virtual.drv_name,
+   strlen(RTE_PMD_BOND)) != 0) {
+   if (driver == NULL) {
+   rte_panic("no driver found for virtual device 
%s\n",
+   devargs->virtual.drv_name);
+   }
+   } else if (init_pri == PMD_INIT_POST_PCI_PROBE &&
+   strncmp(RTE_PMD_BOND, devargs->virtual.drv_name,
+   strlen(RTE_PMD_BOND)) == 0) {
+   if (driver == NULL) {
+   rte_panic("no driver f

[dpdk-dev] [PATCH v7 0/6] Link Bonding Library

2014-06-24 Thread Declan Doherty
This patch contains the initial release of the Link Bonding PMD Library

Supporting bonding modes:
 0 - Round Robin
 1 - Active Backup
 2 - Balance (Supporting 3 transmission polices)
layer 2, layer 2+3, layer 3+4
 3 - Broadcast

Version 6 of patch set:
Debug tracing formatting issue in rte_eth_dev_allocate


Patch Set Description:
 0001 - librte_pmd_bond + makefile changes
 0002 - librte_ether changes to support unique naming of pmds 
 0003 - librte_eal changes to support bonding device intialization
 0005 - link bonding unti test suite
 0005 - testpmd link bonding support changes
 0006 - doxygen additions


Declan Doherty (6):
  Link Bonding Library (lib/librte_pmd_bond)
  Support for unique interface naming of pmds
  EAL support for link bonding device initialization
  Link bonding Unit Tests
  testpmd link bonding additions
  Link Bonding Library doxygen additions

 app/test-pmd/cmdline.c  |  579 
 app/test-pmd/config.c   |4 +-
 app/test-pmd/parameters.c   |3 +
 app/test-pmd/testpmd.c  |   40 +-
 app/test-pmd/testpmd.h  |2 +
 app/test/Makefile   |4 +-
 app/test/commands.c |7 +
 app/test/packet_burst_generator.c   |  287 ++
 app/test/packet_burst_generator.h   |   78 +
 app/test/test.h |1 +
 app/test/test_link_bonding.c| 3958 +++
 app/test/virtual_pmd.c  |  574 
 app/test/virtual_pmd.h  |   74 +
 config/common_bsdapp|5 +
 config/common_linuxapp  |5 +
 doc/doxy-api-index.md   |1 +
 doc/doxy-api.conf   |1 +
 lib/Makefile|1 +
 lib/librte_eal/bsdapp/eal/eal.c |   10 +-
 lib/librte_eal/common/eal_common_dev.c  |   58 +-
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 -
 lib/librte_eal/common/include/rte_dev.h |   13 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 lib/librte_ether/rte_ethdev.c   |   33 +-
 lib/librte_ether/rte_ethdev.h   |7 +-
 lib/librte_pmd_bond/Makefile|   32 +
 lib/librte_pmd_bond/rte_eth_bond.c  | 2142 +++
 lib/librte_pmd_bond/rte_eth_bond.h  |  255 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c  |   22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  |   32 +-
 lib/librte_pmd_ring/rte_eth_ring.h  |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|2 +-
 mk/rte.app.mk   |5 +
 34 files changed, 8188 insertions(+), 71 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h



[dpdk-dev] [PATCH v7 5/6] testpmd link bonding additions

2014-06-24 Thread Declan Doherty
 - Includes the ability to create new bonded devices.
 - Add /remove bonding slave devices.
 - Interogate bonded device stats/configuration
 - Change bonding modes and select balance transmit polices

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c|  579 +
 app/test-pmd/config.c |4 +-
 app/test-pmd/parameters.c |3 +
 app/test-pmd/testpmd.c|   40 +++-
 app/test-pmd/testpmd.h|2 +
 5 files changed, 619 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 3298360..fcc6449 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -84,6 +84,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_LIBRTE_PMD_BOND
+#include 
+#endif

 #include "testpmd.h"

@@ -404,6 +407,31 @@ static void cmd_help_long_parsed(void *parsed_result,
"   Show the bypass configuration for a bypass enabled 
NIC"
" using the lowest port on the NIC.\n\n"
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+   "create bonded device (mode) (socket)\n"
+   "   Create a new bonded device with specific 
bonding mode and socket.\n\n"
+
+   "add bonding slave (slave_id) (port_id)\n"
+   "   Add a slave device to a bonded device.\n\n"
+
+   "remove bonding slave (slave_id) (port_id)\n"
+   "   Remove a slave device from a bonded device.\n\n"
+
+   "set bonding mode (value) (port_id)\n"
+   "   Set the bonding mode on a bonded device.\n\n"
+
+   "set bonding primary (slave_id) (port_id)\n"
+   "   Set the primary slave for a bonded device.\n\n"
+
+   "show bonding config (port_id)\n"
+   "   Show the bonding config for port_id.\n\n"
+
+   "set bonding mac_addr (port_id) (address)\n"
+   "   Set the MAC address of a bonded device.\n\n"
+
+   "set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
+   "   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+#endif

, list_pkt_forwarding_modes()
);
@@ -3031,6 +3059,547 @@ cmdline_parse_inst_t cmd_show_bypass_config = {
 };
 #endif

+#ifdef RTE_LIBRTE_PMD_BOND
+/* *** SET BONDING MODE *** */
+struct cmd_set_bonding_mode_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mode;
+   uint8_t value;
+   uint8_t port_id;
+};
+
+static void cmd_set_bonding_mode_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bonding_mode_result *res = parsed_result;
+   portid_t port_id = res->port_id;
+
+   /* Set the bonding mode for the relevant port. */
+   if (0 != rte_eth_bond_mode_set(port_id, res->value))
+   printf("\t Failed to set bonding mode for port = %d.\n", 
port_id);
+}
+
+cmdline_parse_token_string_t cmd_setbonding_mode_set =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_setbonding_mode_mode =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   mode, "mode");
+cmdline_parse_token_num_t cmd_setbonding_mode_value =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   value, UINT8);
+cmdline_parse_token_num_t cmd_setbonding_mode_port =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_set_bonding_mode = {
+   .f = cmd_set_bonding_mode_parsed,
+   .help_str = "set bonding mode (mode_value) (port_id): Set the 
bonding mode for port_id",
+   .data = NULL,
+   .tokens = {
+   (void *) &cmd_setbonding_mode_set,
+   (void *) &cmd_setbonding_mode_bonding,
+   (void *) &cmd_setbonding_mode_mode,
+   (void *) &cmd_setbonding_mode_value,
+   (void *) &cmd_setbonding_mode_port,
+   NULL
+   }
+};
+
+/* *** SET BALANCE XMIT POLICY *** */
+struct cmd_set_bonding_balance_xmit_policy_result {
+  

[dpdk-dev] [PATCH v7 4/6] Link bonding Unit Tests

2014-06-24 Thread Declan Doherty
Including:
 - code to generate packet bursts for testing rx and tx
   functionality of bonded device
 - virtual/stubbed out ethdev for use as slave ethdev in testing

Signed-off-by: Declan Doherty 
---
 app/test/Makefile |4 +-
 app/test/commands.c   |7 +
 app/test/packet_burst_generator.c |  287 +++
 app/test/packet_burst_generator.h |   78 +
 app/test/test.h   |1 +
 app/test/test_link_bonding.c  | 3958 +
 app/test/virtual_pmd.c|  574 ++
 app/test/virtual_pmd.h|   74 +
 8 files changed, 4982 insertions(+), 1 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 9c52460..643f1b9 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -102,7 +102,9 @@ SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor_perf.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_devargs.c
-
+SRCS-$(CONFIG_RTE_APP_TEST) += virtual_pmd.c
+SRCS-$(CONFIG_RTE_APP_TEST) += packet_burst_generator.c
+SRCS-$(CONFIG_RTE_APP_TEST) += test_link_bonding.c
 ifeq ($(CONFIG_RTE_APP_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
diff --git a/app/test/commands.c b/app/test/commands.c
index c9dc085..5f23420 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -159,6 +159,10 @@ static void cmd_autotest_parsed(void *parsed_result,
ret = test_timer();
if (!strcmp(res->autotest, "timer_perf_autotest"))
ret = test_timer_perf();
+#ifdef RTE_LIBRTE_PMD_BOND
+   if (!strcmp(res->autotest, "link_bonding_autotest"))
+   ret = test_link_bonding();
+#endif
if (!strcmp(res->autotest, "mempool_autotest"))
ret = test_mempool();
if (!strcmp(res->autotest, "mempool_perf_autotest"))
@@ -227,6 +231,9 @@ cmdline_parse_token_string_t cmd_autotest_autotest =
"alarm_autotest#interrupt_autotest#"
"version_autotest#eal_fs_autotest#"
"cmdline_autotest#func_reentrancy_autotest#"
+#ifdef RTE_LIBRTE_PMD_BOND
+   "link_bonding_autotest#"
+#endif
"mempool_perf_autotest#hash_perf_autotest#"
"memcpy_perf_autotest#ring_perf_autotest#"
"red_autotest#meter_autotest#sched_autotest#"
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
new file mode 100644
index 000..5d539f1
--- /dev/null
+++ b/app/test/packet_burst_generator.c
@@ -0,0 +1,287 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include "packet_burst_generator.h"
+
+#define UDP_SRC_PORT 1024
+#define UDP_DST_PORT 1024
+
+
+#define IP_DEFTTL  64   /* from RFC 1340. */
+#define IP_VERSION 0

[dpdk-dev] [PATCH v7 6/6] Link Bonding Library doxygen additions

2014-06-24 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 doc/doxy-api-index.md |1 +
 doc/doxy-api.conf |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/doc/doxy-api-index.md b/doc/doxy-api-index.md
index 7b26e98..ee3ad4f 100644
--- a/doc/doxy-api-index.md
+++ b/doc/doxy-api-index.md
@@ -36,6 +36,7 @@ API {#index}
 There are many libraries, so their headers may be grouped by topics:

 - **device**:
+  [bond]   (@ref rte_eth_bond.h),
   [ethdev] (@ref rte_ethdev.h),
   [devargs](@ref rte_devargs.h),
   [KNI](@ref rte_kni.h),
diff --git a/doc/doxy-api.conf b/doc/doxy-api.conf
index f380d9a..b15a340 100644
--- a/doc/doxy-api.conf
+++ b/doc/doxy-api.conf
@@ -30,6 +30,7 @@

 PROJECT_NAME= DPDK
 INPUT   = doc/doxy-api-index.md \
+  lib/librte_pmd_bond \
   lib/librte_eal/common/include \
   lib/librte_acl \
   lib/librte_distributor \
-- 
1.7.0.7



[dpdk-dev] [PATCH v7 1/6] Link Bonding Library (lib/librte_pmd_bond)

2014-06-24 Thread Declan Doherty
Initial release with support for
 Mode 0 - Round Robin
 Mode 1 - Active Backup
 Mode 2 - Balance -> Supports 3 transmit polices (layer 2, layer 2+3, layer 3+4)
 Mode 3 - Broadcast

Signed-off-by: Declan Doherty 
---
 config/common_bsdapp   |5 +
 config/common_linuxapp |5 +
 lib/Makefile   |1 +
 lib/librte_pmd_bond/Makefile   |   32 +
 lib/librte_pmd_bond/rte_eth_bond.c | 2142 
 lib/librte_pmd_bond/rte_eth_bond.h |  255 +
 mk/rte.app.mk  |5 +
 7 files changed, 2445 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 989e1da..214398b 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -206,6 +206,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 5b896c3..2bf90df 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -244,6 +244,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Compile Xen PMD
 #
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
diff --git a/lib/Makefile b/lib/Makefile
index c58c0c9..88e875f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -49,6 +49,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl
diff --git a/lib/librte_pmd_bond/Makefile b/lib/librte_pmd_bond/Makefile
new file mode 100644
index 000..51f6159
--- /dev/null
+++ b/lib/librte_pmd_bond/Makefile
@@ -0,0 +1,32 @@
+# 
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_bond.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond.c
+
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_eth_bond.h
+
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_malloc
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_kvargs
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_bond/rte_eth_bond.c 
b/lib/librte_pmd_bond/rte_eth_bond.c
new file mode 100644
index 000..1b0cf81
--- /dev/null
+++ b/lib/librte_pmd_bond/rte_eth_bond.c
@@ -0,0 +1,2142 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#inclu

[dpdk-dev] [PATCH v7 2/6] Support for unique interface naming of pmds

2014-06-24 Thread Declan Doherty
Adding support to rte_eth_dev_data structure to support unique
name identifier for ethdevs to support adding slave ethdevs
(specifically virtual devices which have no public unique
identifier) to a link bonding device. This changes the API
rte_eth_dev_allocate() to require a const char *name when
allocating a ethdev, which also verifies that the name is
unique and hasn?t been already used by an existed allocated
rte_eth_dev. Also contains updates to virtual pmd?s to now call
the API with a name parameter.

Signed-off-by: Declan Doherty 
---
 lib/librte_ether/rte_ethdev.c|   33 +++--
 lib/librte_ether/rte_ethdev.h|7 +-
 lib/librte_pmd_pcap/rte_eth_pcap.c   |   22 ++--
 lib/librte_pmd_ring/rte_eth_ring.c   |   32 +++-
 lib/librte_pmd_ring/rte_eth_ring.h   |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c |2 +-
 6 files changed, 67 insertions(+), 32 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7256841..2225c0a 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -65,6 +65,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_ether.h"
 #include "rte_ethdev.h"
@@ -153,21 +154,41 @@ rte_eth_dev_data_alloc(void)
RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
 }

+static struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+   unsigned i;
+
+   for (i = 0; i < nb_ports; i++) {
+   if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+   return &rte_eth_devices[i];
+   }
+   return NULL;
+}
+
 struct rte_eth_dev *
-rte_eth_dev_allocate(void)
+rte_eth_dev_allocate(const char *name)
 {
struct rte_eth_dev *eth_dev;

if (nb_ports == RTE_MAX_ETHPORTS) {
-   PMD_DEBUG_TRACE("Reached maximum number of ethernet ports\n");
+   PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
return NULL;
}

if (rte_eth_dev_data == NULL)
rte_eth_dev_data_alloc();

+   if (rte_eth_dev_allocated(name) != NULL) {
+   PMD_DEBUG_TRACE("Ethernet Device with name %s already 
allocated!\n",
+   name);
+   return NULL;
+   }
+
eth_dev = &rte_eth_devices[nb_ports];
eth_dev->data = &rte_eth_dev_data[nb_ports];
+   rte_snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
+   "%s", name);
eth_dev->data->port_id = nb_ports++;
return eth_dev;
 }
@@ -178,11 +199,17 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 {
struct eth_driver*eth_drv;
struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
int diag;

eth_drv = (struct eth_driver *)pci_drv;

-   eth_dev = rte_eth_dev_allocate();
+   /* Create unique Ethernet device name using PCI address */
+   rte_snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d",
+   pci_dev->addr.bus, pci_dev->addr.devid, 
pci_dev->addr.function);
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
if (eth_dev == NULL)
return -ENOMEM;

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2406e45..50df654 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1497,6 +1497,8 @@ struct rte_eth_dev_sriov {
 };
 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)

+#define RTE_ETH_NAME_MAX_LEN (32)
+
 /**
  * @internal
  * The data part, with no function pointers, associated with each ethernet 
device.
@@ -1505,6 +1507,8 @@ struct rte_eth_dev_sriov {
  * processes in a multi-process configuration.
  */
 struct rte_eth_dev_data {
+   char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
+
void **rx_queues; /**< Array of pointers to RX queues. */
void **tx_queues; /**< Array of pointers to TX queues. */
uint16_t nb_rx_queues; /**< Number of RX queues. */
@@ -1560,10 +1564,11 @@ extern uint8_t rte_eth_dev_count(void);
  * Allocates a new ethdev slot for an ethernet device and returns the pointer
  * to that slot for the driver to use.
  *
+ * @param  nameUnique identifier name for each Ethernet device
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(void);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);

 struct eth_driver;
 /**
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c 
b/lib/librte_pmd_pcap/rte_eth_pcap.c
index b3dbbda..12b7e0c 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -534,7 +534,7 @@ open_tx_iface(const char *key __rte_unused

[dpdk-dev] [PATCH v8 3/6] EAL support for link bonding device initialization

2014-06-25 Thread Declan Doherty
Updating functionality in EAL to support adding link bonding
devices via ?vdev option. Link bonding devices will be
initialized after all physical devices have been probed and
initialized.

Signed-off-by: Declan Doherty 
---
 lib/librte_eal/bsdapp/eal/eal.c |   10 -
 lib/librte_eal/common/eal_common_dev.c  |   58 ++
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 ---
 lib/librte_eal/common/include/rte_dev.h |   13 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 6 files changed, 73 insertions(+), 29 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index a1f014f..c53f63e 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -874,7 +874,7 @@ rte_eal_init(int argc, char **argv)

rte_eal_mcfg_complete();

-   if (rte_eal_dev_init() < 0)
+   if (rte_eal_dev_init(PMD_INIT_PRE_PCI_PROBE) < 0)
rte_panic("Cannot init pmd devices\n");

RTE_LCORE_FOREACH_SLAVE(i) {
@@ -906,6 +906,14 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
rte_eal_mp_wait_lcore();

+   /* Probe & Initialize PCI devices */
+   if (rte_eal_pci_probe())
+   rte_panic("Cannot probe PCI\n");
+
+   /* Initialize any outstanding devices */
+   if (rte_eal_dev_init(PMD_INIT_POST_PCI_PROBE) < 0)
+   rte_panic("Cannot init pmd devices\n");
+
return fctret;
 }

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..8e80093 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -62,7 +62,7 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_dev_init(void)
+rte_eal_dev_init(uint8_t init_pri)
 {
struct rte_devargs *devargs;
struct rte_driver *driver;
@@ -80,30 +80,52 @@ rte_eal_dev_init(void)
continue;

TAILQ_FOREACH(driver, &dev_driver_list, next) {
-   if (driver->type != PMD_VDEV)
-   continue;
+   /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device,
+* virtual devices are initialized pre PCI probing and 
bonded
+* device are post pci probing */
+   if ((driver->type == PMD_VDEV && init_pri ==
+   PMD_INIT_PRE_PCI_PROBE) ||
+   (driver->type == PMD_BDEV && init_pri ==
+   PMD_INIT_POST_PCI_PROBE)) {

-   /* search a driver prefix in virtual device name */
-   if (!strncmp(driver->name, devargs->virtual.drv_name,
-   strlen(driver->name))) {
-   driver->init(devargs->virtual.drv_name,
-   devargs->args);
-   break;
+   /* search a driver prefix in virtual device 
name */
+   if (!strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   printf("init (%u) %s\n", init_pri, 
devargs->virtual.drv_name);
+   driver->init(devargs->virtual.drv_name,
+   devargs->args);
+   break;
+   }
}
}

-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   /* If initializing pre PCI probe, then we don't expect a bonded 
driver
+* to be found */
+   if (init_pri == PMD_INIT_PRE_PCI_PROBE &&
+   strncmp(RTE_PMD_BOND, devargs->virtual.drv_name,
+   strlen(RTE_PMD_BOND)) != 0) {
+   if (driver == NULL) {
+   rte_panic("no driver found for virtual device 
%s\n",
+   devargs->virtual.drv_name);
+   }
+   } else if (init_pri == PMD_INIT_POST_PCI_PROBE &&
+   strncmp(RTE_PMD_BOND, devargs->virtual.drv_name,
+   strlen(RTE_PMD_BOND)) == 0) {
+   if (driver == NULL) {
+   rte_panic("no driver f

[dpdk-dev] [PATCH v8 6/6] Link Bonding Library doxygen additions

2014-06-25 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 doc/doxy-api-index.md |1 +
 doc/doxy-api.conf |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/doc/doxy-api-index.md b/doc/doxy-api-index.md
index 7b26e98..ee3ad4f 100644
--- a/doc/doxy-api-index.md
+++ b/doc/doxy-api-index.md
@@ -36,6 +36,7 @@ API {#index}
 There are many libraries, so their headers may be grouped by topics:

 - **device**:
+  [bond]   (@ref rte_eth_bond.h),
   [ethdev] (@ref rte_ethdev.h),
   [devargs](@ref rte_devargs.h),
   [KNI](@ref rte_kni.h),
diff --git a/doc/doxy-api.conf b/doc/doxy-api.conf
index f380d9a..b15a340 100644
--- a/doc/doxy-api.conf
+++ b/doc/doxy-api.conf
@@ -30,6 +30,7 @@

 PROJECT_NAME= DPDK
 INPUT   = doc/doxy-api-index.md \
+  lib/librte_pmd_bond \
   lib/librte_eal/common/include \
   lib/librte_acl \
   lib/librte_distributor \
-- 
1.7.0.7



[dpdk-dev] [PATCH v8 1/6] Link Bonding Library (lib/librte_pmd_bond)

2014-06-25 Thread Declan Doherty
Initial release with support for
 Mode 0 - Round Robin
 Mode 1 - Active Backup
 Mode 2 - Balance -> Supports 3 transmit polices (layer 2, layer 2+3, layer 3+4)
 Mode 3 - Broadcast

Signed-off-by: Declan Doherty 
---
 config/common_bsdapp   |5 +
 config/common_linuxapp |5 +
 lib/Makefile   |1 +
 lib/librte_pmd_bond/Makefile   |   34 +
 lib/librte_pmd_bond/rte_eth_bond.h |  255 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c |  670 +++
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 1228 
 lib/librte_pmd_bond/rte_eth_bond_private.h |  218 +
 lib/librte_pmd_bond/rte_eth_bond_vargs.c   |  255 ++
 mk/rte.app.mk  |5 +
 10 files changed, 2676 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_api.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_pmd.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_private.h
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_vargs.c

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 989e1da..214398b 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -206,6 +206,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 5b896c3..2bf90df 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -244,6 +244,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Compile Xen PMD
 #
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
diff --git a/lib/Makefile b/lib/Makefile
index c58c0c9..88e875f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -49,6 +49,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl
diff --git a/lib/librte_pmd_bond/Makefile b/lib/librte_pmd_bond/Makefile
new file mode 100644
index 000..4128f61
--- /dev/null
+++ b/lib/librte_pmd_bond/Makefile
@@ -0,0 +1,34 @@
+# 
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_bond.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond_api.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond_pmd.c
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond_vargs.c
+
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_eth_bond.h
+
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_malloc
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_kvargs
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_bond/rte_eth_bond.h 
b/lib/librte_pmd_bond/rte_eth_bond.h
new file mode 100644
index 000..7cf9dd8
--- /dev/null
+++ b/lib/librte_pmd_bond/rte_eth_bond.h
@@ -0,0 +1,255 @@
+/*-
+ *   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,

[dpdk-dev] [PATCH v8 2/6] Support for unique interface naming of pmds

2014-06-25 Thread Declan Doherty
Adding support to rte_eth_dev_data structure to support unique
name identifier for ethdevs to support adding slave ethdevs
(specifically virtual devices which have no public unique
identifier) to a link bonding device. This changes the API
rte_eth_dev_allocate() to require a const char *name when
allocating a ethdev, which also verifies that the name is
unique and hasn?t been already used by an existed allocated
rte_eth_dev. Also contains updates to virtual pmd?s to now call
the API with a name parameter.

Signed-off-by: Declan Doherty 
---
 lib/librte_ether/rte_ethdev.c|   32 +++--
 lib/librte_ether/rte_ethdev.h|7 +-
 lib/librte_pmd_pcap/rte_eth_pcap.c   |   22 ++--
 lib/librte_pmd_ring/rte_eth_ring.c   |   32 +++--
 lib/librte_pmd_ring/rte_eth_ring.h   |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c |2 +-
 6 files changed, 66 insertions(+), 32 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7256841..d938603 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -65,6 +65,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_ether.h"
 #include "rte_ethdev.h"
@@ -153,21 +154,40 @@ rte_eth_dev_data_alloc(void)
RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
 }

+static struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+   unsigned i;
+
+   for (i = 0; i < nb_ports; i++) {
+   if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+   return &rte_eth_devices[i];
+   }
+   return NULL;
+}
+
 struct rte_eth_dev *
-rte_eth_dev_allocate(void)
+rte_eth_dev_allocate(const char *name)
 {
struct rte_eth_dev *eth_dev;

if (nb_ports == RTE_MAX_ETHPORTS) {
-   PMD_DEBUG_TRACE("Reached maximum number of ethernet ports\n");
+   PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
return NULL;
}

if (rte_eth_dev_data == NULL)
rte_eth_dev_data_alloc();

+   if (rte_eth_dev_allocated(name) != NULL) {
+   PMD_DEBUG_TRACE("Ethernet Device with name %s already 
allocated!\n");
+   return NULL;
+   }
+
eth_dev = &rte_eth_devices[nb_ports];
eth_dev->data = &rte_eth_dev_data[nb_ports];
+   rte_snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
+   "%s", name);
eth_dev->data->port_id = nb_ports++;
return eth_dev;
 }
@@ -178,11 +198,17 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 {
struct eth_driver*eth_drv;
struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
int diag;

eth_drv = (struct eth_driver *)pci_drv;

-   eth_dev = rte_eth_dev_allocate();
+   /* Create unique Ethernet device name using PCI address */
+   rte_snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d",
+   pci_dev->addr.bus, pci_dev->addr.devid, 
pci_dev->addr.function);
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
if (eth_dev == NULL)
return -ENOMEM;

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2406e45..50df654 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1497,6 +1497,8 @@ struct rte_eth_dev_sriov {
 };
 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)

+#define RTE_ETH_NAME_MAX_LEN (32)
+
 /**
  * @internal
  * The data part, with no function pointers, associated with each ethernet 
device.
@@ -1505,6 +1507,8 @@ struct rte_eth_dev_sriov {
  * processes in a multi-process configuration.
  */
 struct rte_eth_dev_data {
+   char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
+
void **rx_queues; /**< Array of pointers to RX queues. */
void **tx_queues; /**< Array of pointers to TX queues. */
uint16_t nb_rx_queues; /**< Number of RX queues. */
@@ -1560,10 +1564,11 @@ extern uint8_t rte_eth_dev_count(void);
  * Allocates a new ethdev slot for an ethernet device and returns the pointer
  * to that slot for the driver to use.
  *
+ * @param  nameUnique identifier name for each Ethernet device
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(void);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);

 struct eth_driver;
 /**
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c 
b/lib/librte_pmd_pcap/rte_eth_pcap.c
index b3dbbda..12b7e0c 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -534,7 +534,7 @@ open_tx_iface(const char *key __rte_unused, const char 
*value, void 

[dpdk-dev] [PATCH v8 4/6] Link bonding Unit Tests

2014-06-25 Thread Declan Doherty
Including:
 - code to generate packet bursts for testing rx and tx
   functionality of bonded device
 - virtual/stubbed out ethdev for use as slave ethdev in testing

Signed-off-by: Declan Doherty 
---
 app/test/Makefile |4 +-
 app/test/commands.c   |7 +
 app/test/packet_burst_generator.c |  287 +++
 app/test/packet_burst_generator.h |   78 +
 app/test/test.h   |1 +
 app/test/test_link_bonding.c  | 3958 +
 app/test/virtual_pmd.c|  574 ++
 app/test/virtual_pmd.h|   74 +
 8 files changed, 4982 insertions(+), 1 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 9c52460..643f1b9 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -102,7 +102,9 @@ SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor_perf.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_devargs.c
-
+SRCS-$(CONFIG_RTE_APP_TEST) += virtual_pmd.c
+SRCS-$(CONFIG_RTE_APP_TEST) += packet_burst_generator.c
+SRCS-$(CONFIG_RTE_APP_TEST) += test_link_bonding.c
 ifeq ($(CONFIG_RTE_APP_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
diff --git a/app/test/commands.c b/app/test/commands.c
index c9dc085..5f23420 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -159,6 +159,10 @@ static void cmd_autotest_parsed(void *parsed_result,
ret = test_timer();
if (!strcmp(res->autotest, "timer_perf_autotest"))
ret = test_timer_perf();
+#ifdef RTE_LIBRTE_PMD_BOND
+   if (!strcmp(res->autotest, "link_bonding_autotest"))
+   ret = test_link_bonding();
+#endif
if (!strcmp(res->autotest, "mempool_autotest"))
ret = test_mempool();
if (!strcmp(res->autotest, "mempool_perf_autotest"))
@@ -227,6 +231,9 @@ cmdline_parse_token_string_t cmd_autotest_autotest =
"alarm_autotest#interrupt_autotest#"
"version_autotest#eal_fs_autotest#"
"cmdline_autotest#func_reentrancy_autotest#"
+#ifdef RTE_LIBRTE_PMD_BOND
+   "link_bonding_autotest#"
+#endif
"mempool_perf_autotest#hash_perf_autotest#"
"memcpy_perf_autotest#ring_perf_autotest#"
"red_autotest#meter_autotest#sched_autotest#"
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
new file mode 100644
index 000..5d539f1
--- /dev/null
+++ b/app/test/packet_burst_generator.c
@@ -0,0 +1,287 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include "packet_burst_generator.h"
+
+#define UDP_SRC_PORT 1024
+#define UDP_DST_PORT 1024
+
+
+#define IP_DEFTTL  64   /* from RFC 1340. */
+#define IP_VERSION 0

[dpdk-dev] [PATCH v8 0/6] Link Bonding Library

2014-06-25 Thread Declan Doherty
This patch contains the initial release of the Link Bonding PMD Library

Supporting bonding modes:
 0 - Round Robin
 1 - Active Backup
 2 - Balance (Supporting 3 transmission polices)
layer 2, layer 2+3, layer 3+4
 3 - Broadcast

Version 8 of patch set:
This version splits the bonding library into 3 C files, containing the
PMD specific code, the argument parsing code, and the public API code


Patch Set Description:
 0001 - librte_pmd_bond + makefile changes
 0002 - librte_ether changes to support unique naming of pmds 
 0003 - librte_eal changes to support bonding device intialization
 0005 - link bonding unti test suite
 0005 - testpmd link bonding support changes
 0006 - doxygen additions

Declan Doherty (6):
  Link Bonding Library (lib/librte_pmd_bond)
  Support for unique interface naming of pmds
  EAL support for link bonding device initialization
  Link bonding Unit Tests
  testpmd link bonding additions
  Link Bonding Library doxygen additions

 app/test-pmd/cmdline.c  |  579 
 app/test-pmd/config.c   |4 +-
 app/test-pmd/parameters.c   |3 +
 app/test-pmd/testpmd.c  |   40 +-
 app/test-pmd/testpmd.h  |2 +
 app/test/Makefile   |4 +-
 app/test/commands.c |7 +
 app/test/packet_burst_generator.c   |  287 ++
 app/test/packet_burst_generator.h   |   78 +
 app/test/test.h |1 +
 app/test/test_link_bonding.c| 3958 +++
 app/test/virtual_pmd.c  |  574 
 app/test/virtual_pmd.h  |   74 +
 config/common_bsdapp|5 +
 config/common_linuxapp  |5 +
 doc/doxy-api-index.md   |1 +
 doc/doxy-api.conf   |1 +
 lib/Makefile|1 +
 lib/librte_eal/bsdapp/eal/eal.c |   10 +-
 lib/librte_eal/common/eal_common_dev.c  |   58 +-
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 -
 lib/librte_eal/common/include/rte_dev.h |   13 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 lib/librte_ether/rte_ethdev.c   |   32 +-
 lib/librte_ether/rte_ethdev.h   |7 +-
 lib/librte_pmd_bond/Makefile|   34 +
 lib/librte_pmd_bond/rte_eth_bond.h  |  255 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c  |  670 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c  | 1228 +
 lib/librte_pmd_bond/rte_eth_bond_private.h  |  218 ++
 lib/librte_pmd_bond/rte_eth_bond_vargs.c|  255 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c  |   22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  |   32 +-
 lib/librte_pmd_ring/rte_eth_ring.h  |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|2 +-
 mk/rte.app.mk   |5 +
 37 files changed, 8418 insertions(+), 71 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_api.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_pmd.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_private.h
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_vargs.c



[dpdk-dev] [PATCH v8 5/6] testpmd link bonding additions

2014-06-25 Thread Declan Doherty
 - Includes the ability to create new bonded devices.
 - Add /remove bonding slave devices.
 - Interogate bonded device stats/configuration
 - Change bonding modes and select balance transmit polices

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c|  579 +
 app/test-pmd/config.c |4 +-
 app/test-pmd/parameters.c |3 +
 app/test-pmd/testpmd.c|   40 +++-
 app/test-pmd/testpmd.h|2 +
 5 files changed, 619 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 3298360..fcc6449 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -84,6 +84,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_LIBRTE_PMD_BOND
+#include 
+#endif

 #include "testpmd.h"

@@ -404,6 +407,31 @@ static void cmd_help_long_parsed(void *parsed_result,
"   Show the bypass configuration for a bypass enabled 
NIC"
" using the lowest port on the NIC.\n\n"
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+   "create bonded device (mode) (socket)\n"
+   "   Create a new bonded device with specific 
bonding mode and socket.\n\n"
+
+   "add bonding slave (slave_id) (port_id)\n"
+   "   Add a slave device to a bonded device.\n\n"
+
+   "remove bonding slave (slave_id) (port_id)\n"
+   "   Remove a slave device from a bonded device.\n\n"
+
+   "set bonding mode (value) (port_id)\n"
+   "   Set the bonding mode on a bonded device.\n\n"
+
+   "set bonding primary (slave_id) (port_id)\n"
+   "   Set the primary slave for a bonded device.\n\n"
+
+   "show bonding config (port_id)\n"
+   "   Show the bonding config for port_id.\n\n"
+
+   "set bonding mac_addr (port_id) (address)\n"
+   "   Set the MAC address of a bonded device.\n\n"
+
+   "set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
+   "   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+#endif

, list_pkt_forwarding_modes()
);
@@ -3031,6 +3059,547 @@ cmdline_parse_inst_t cmd_show_bypass_config = {
 };
 #endif

+#ifdef RTE_LIBRTE_PMD_BOND
+/* *** SET BONDING MODE *** */
+struct cmd_set_bonding_mode_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mode;
+   uint8_t value;
+   uint8_t port_id;
+};
+
+static void cmd_set_bonding_mode_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bonding_mode_result *res = parsed_result;
+   portid_t port_id = res->port_id;
+
+   /* Set the bonding mode for the relevant port. */
+   if (0 != rte_eth_bond_mode_set(port_id, res->value))
+   printf("\t Failed to set bonding mode for port = %d.\n", 
port_id);
+}
+
+cmdline_parse_token_string_t cmd_setbonding_mode_set =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_setbonding_mode_mode =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   mode, "mode");
+cmdline_parse_token_num_t cmd_setbonding_mode_value =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   value, UINT8);
+cmdline_parse_token_num_t cmd_setbonding_mode_port =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_set_bonding_mode = {
+   .f = cmd_set_bonding_mode_parsed,
+   .help_str = "set bonding mode (mode_value) (port_id): Set the 
bonding mode for port_id",
+   .data = NULL,
+   .tokens = {
+   (void *) &cmd_setbonding_mode_set,
+   (void *) &cmd_setbonding_mode_bonding,
+   (void *) &cmd_setbonding_mode_mode,
+   (void *) &cmd_setbonding_mode_value,
+   (void *) &cmd_setbonding_mode_port,
+   NULL
+   }
+};
+
+/* *** SET BALANCE XMIT POLICY *** */
+struct cmd_set_bonding_balance_xmit_policy_result {
+  

[dpdk-dev] [PATCH v10 0/5] link bonding

2014-06-27 Thread Declan Doherty
Fixed copyright in link bonding library Makefile 

Declan Doherty (5):
  bond: new link bonding library
  ethdev: add unique name to devices
  eal: support link bonding device initialization
  bond: unit tests
  bond: testpmd support

 app/test-pmd/cmdline.c  |  579 
 app/test-pmd/config.c   |4 +-
 app/test-pmd/parameters.c   |3 +
 app/test-pmd/testpmd.c  |   40 +-
 app/test-pmd/testpmd.h  |2 +
 app/test/Makefile   |4 +-
 app/test/commands.c |7 +
 app/test/packet_burst_generator.c   |  287 ++
 app/test/packet_burst_generator.h   |   78 +
 app/test/test.h |1 +
 app/test/test_link_bonding.c| 3958 +++
 app/test/virtual_pmd.c  |  574 
 app/test/virtual_pmd.h  |   74 +
 config/common_bsdapp|5 +
 config/common_linuxapp  |5 +
 doc/doxy-api-index.md   |1 +
 doc/doxy-api.conf   |1 +
 lib/Makefile|1 +
 lib/librte_eal/bsdapp/eal/eal.c |   10 +-
 lib/librte_eal/common/eal_common_dev.c  |   58 +-
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 -
 lib/librte_eal/common/include/rte_dev.h |   14 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 lib/librte_ether/rte_ethdev.c   |   31 +-
 lib/librte_ether/rte_ethdev.h   |7 +-
 lib/librte_pmd_bond/Makefile|   61 +
 lib/librte_pmd_bond/rte_eth_bond.h  |  255 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c  |  662 +
 lib/librte_pmd_bond/rte_eth_bond_args.c |  252 ++
 lib/librte_pmd_bond/rte_eth_bond_pmd.c  | 1212 
 lib/librte_pmd_bond/rte_eth_bond_private.h  |  215 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c  |   22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  |   32 +-
 lib/librte_pmd_ring/rte_eth_ring.h  |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|2 +-
 mk/rte.app.mk   |4 +
 37 files changed, 8414 insertions(+), 71 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_api.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_args.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_pmd.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_private.h



[dpdk-dev] [PATCH v10 3/5] eal: support link bonding device initialization

2014-06-27 Thread Declan Doherty
Updating functionality in EAL to support adding link bonding
devices via ?vdev option. Link bonding devices will be
initialized after all physical devices have been probed and
initialized.

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 lib/librte_eal/bsdapp/eal/eal.c |   10 -
 lib/librte_eal/common/eal_common_dev.c  |   58 ++
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 ---
 lib/librte_eal/common/include/rte_dev.h |   14 ++-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 6 files changed, 74 insertions(+), 29 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index a1f014f..c53f63e 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -874,7 +874,7 @@ rte_eal_init(int argc, char **argv)

rte_eal_mcfg_complete();

-   if (rte_eal_dev_init() < 0)
+   if (rte_eal_dev_init(PMD_INIT_PRE_PCI_PROBE) < 0)
rte_panic("Cannot init pmd devices\n");

RTE_LCORE_FOREACH_SLAVE(i) {
@@ -906,6 +906,14 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
rte_eal_mp_wait_lcore();

+   /* Probe & Initialize PCI devices */
+   if (rte_eal_pci_probe())
+   rte_panic("Cannot probe PCI\n");
+
+   /* Initialize any outstanding devices */
+   if (rte_eal_dev_init(PMD_INIT_POST_PCI_PROBE) < 0)
+   rte_panic("Cannot init pmd devices\n");
+
return fctret;
 }

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..1194419 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -62,7 +62,7 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_dev_init(void)
+rte_eal_dev_init(uint8_t init_pri)
 {
struct rte_devargs *devargs;
struct rte_driver *driver;
@@ -80,30 +80,52 @@ rte_eal_dev_init(void)
continue;

TAILQ_FOREACH(driver, &dev_driver_list, next) {
-   if (driver->type != PMD_VDEV)
-   continue;
+   /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device,
+* virtual devices are initialized pre PCI probing and 
bonded
+* device are post pci probing */
+   if ((driver->type == PMD_VDEV && init_pri ==
+   PMD_INIT_PRE_PCI_PROBE) ||
+   (driver->type == PMD_BDEV && init_pri ==
+   PMD_INIT_POST_PCI_PROBE)) {

-   /* search a driver prefix in virtual device name */
-   if (!strncmp(driver->name, devargs->virtual.drv_name,
-   strlen(driver->name))) {
-   driver->init(devargs->virtual.drv_name,
-   devargs->args);
-   break;
+   /* search a driver prefix in virtual device 
name */
+   if (!strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   printf("init (%u) %s\n", init_pri, 
devargs->virtual.drv_name);
+   driver->init(devargs->virtual.drv_name,
+   devargs->args);
+   break;
+   }
}
}

-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   /* If initializing pre PCI probe, then we don't expect a bonded 
driver
+* to be found */
+   if (init_pri == PMD_INIT_PRE_PCI_PROBE &&
+   strncmp(PMD_BOND_NAME, 
devargs->virtual.drv_name,
+   strlen(PMD_BOND_NAME)) != 0) {
+   if (driver == NULL) {
+   rte_panic("no driver found for virtual device 
%s\n",
+   devargs->virtual.drv_name);
+   }
+   } else if (init_pri == PMD_INIT_POST_PCI_PROBE &&
+   strncmp(PMD_BOND_NAME, 
devargs->virtual.drv_name,
+   strlen(PMD_BOND_NAME)) == 0) {
+ 

[dpdk-dev] [PATCH v10 2/5] ethdev: add unique name to devices

2014-06-27 Thread Declan Doherty
Adding support to rte_eth_dev_data structure to support unique
name identifier for ethdevs to support adding slave ethdevs
(specifically virtual devices which have no public unique
identifier) to a link bonding device. This changes the API
rte_eth_dev_allocate() to require a const char *name when
allocating a ethdev, which also verifies that the name is
unique and hasn?t been already used by an existed allocated
rte_eth_dev. Also contains updates to virtual pmd?s to now call
the API with a name parameter.

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 lib/librte_ether/rte_ethdev.c|   31 ++--
 lib/librte_ether/rte_ethdev.h|7 +-
 lib/librte_pmd_pcap/rte_eth_pcap.c   |   22 ++--
 lib/librte_pmd_ring/rte_eth_ring.c   |   32 +++--
 lib/librte_pmd_ring/rte_eth_ring.h   |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c |2 +-
 6 files changed, 65 insertions(+), 32 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ef81a76..0ebb8fb 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -65,6 +65,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_ether.h"
 #include "rte_ethdev.h"
@@ -153,21 +154,39 @@ rte_eth_dev_data_alloc(void)
RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
 }

+static struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+   unsigned i;
+
+   for (i = 0; i < nb_ports; i++) {
+   if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+   return &rte_eth_devices[i];
+   }
+   return NULL;
+}
+
 struct rte_eth_dev *
-rte_eth_dev_allocate(void)
+rte_eth_dev_allocate(const char *name)
 {
struct rte_eth_dev *eth_dev;

if (nb_ports == RTE_MAX_ETHPORTS) {
-   PMD_DEBUG_TRACE("Reached maximum number of ethernet ports\n");
+   PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
return NULL;
}

if (rte_eth_dev_data == NULL)
rte_eth_dev_data_alloc();

+   if (rte_eth_dev_allocated(name) != NULL) {
+   PMD_DEBUG_TRACE("Ethernet Device with name %s already 
allocated!\n");
+   return NULL;
+   }
+
eth_dev = &rte_eth_devices[nb_ports];
eth_dev->data = &rte_eth_dev_data[nb_ports];
+   snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = nb_ports++;
return eth_dev;
 }
@@ -178,11 +197,17 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 {
struct eth_driver*eth_drv;
struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
int diag;

eth_drv = (struct eth_driver *)pci_drv;

-   eth_dev = rte_eth_dev_allocate();
+   /* Create unique Ethernet device name using PCI address */
+   snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d",
+   pci_dev->addr.bus, pci_dev->addr.devid, 
pci_dev->addr.function);
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
if (eth_dev == NULL)
return -ENOMEM;

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2406e45..50df654 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1497,6 +1497,8 @@ struct rte_eth_dev_sriov {
 };
 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)

+#define RTE_ETH_NAME_MAX_LEN (32)
+
 /**
  * @internal
  * The data part, with no function pointers, associated with each ethernet 
device.
@@ -1505,6 +1507,8 @@ struct rte_eth_dev_sriov {
  * processes in a multi-process configuration.
  */
 struct rte_eth_dev_data {
+   char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
+
void **rx_queues; /**< Array of pointers to RX queues. */
void **tx_queues; /**< Array of pointers to TX queues. */
uint16_t nb_rx_queues; /**< Number of RX queues. */
@@ -1560,10 +1564,11 @@ extern uint8_t rte_eth_dev_count(void);
  * Allocates a new ethdev slot for an ethernet device and returns the pointer
  * to that slot for the driver to use.
  *
+ * @param  nameUnique identifier name for each Ethernet device
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(void);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);

 struct eth_driver;
 /**
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c 
b/lib/librte_pmd_pcap/rte_eth_pcap.c
index b3dbbda..12b7e0c 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -534,7 +534,7 @@ open_tx_iface(const char *key __rte_unused, const char 
*value, void *extra_args)

[dpdk-dev] [PATCH v10 5/5] bond: testpmd support

2014-06-27 Thread Declan Doherty
 - Includes the ability to create new bonded devices.
 - Add /remove bonding slave devices.
 - Interogate bonded device stats/configuration
 - Change bonding modes and select balance transmit polices

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 app/test-pmd/cmdline.c|  579 +
 app/test-pmd/config.c |4 +-
 app/test-pmd/parameters.c |3 +
 app/test-pmd/testpmd.c|   40 +++-
 app/test-pmd/testpmd.h|2 +
 5 files changed, 619 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f61a31c..345be11 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -84,6 +84,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_LIBRTE_PMD_BOND
+#include 
+#endif

 #include "testpmd.h"

@@ -412,6 +415,31 @@ static void cmd_help_long_parsed(void *parsed_result,
"   Show the bypass configuration for a bypass enabled 
NIC"
" using the lowest port on the NIC.\n\n"
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+   "create bonded device (mode) (socket)\n"
+   "   Create a new bonded device with specific 
bonding mode and socket.\n\n"
+
+   "add bonding slave (slave_id) (port_id)\n"
+   "   Add a slave device to a bonded device.\n\n"
+
+   "remove bonding slave (slave_id) (port_id)\n"
+   "   Remove a slave device from a bonded device.\n\n"
+
+   "set bonding mode (value) (port_id)\n"
+   "   Set the bonding mode on a bonded device.\n\n"
+
+   "set bonding primary (slave_id) (port_id)\n"
+   "   Set the primary slave for a bonded device.\n\n"
+
+   "show bonding config (port_id)\n"
+   "   Show the bonding config for port_id.\n\n"
+
+   "set bonding mac_addr (port_id) (address)\n"
+   "   Set the MAC address of a bonded device.\n\n"
+
+   "set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
+   "   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+#endif

, list_pkt_forwarding_modes()
);
@@ -3039,6 +3067,547 @@ cmdline_parse_inst_t cmd_show_bypass_config = {
 };
 #endif

+#ifdef RTE_LIBRTE_PMD_BOND
+/* *** SET BONDING MODE *** */
+struct cmd_set_bonding_mode_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mode;
+   uint8_t value;
+   uint8_t port_id;
+};
+
+static void cmd_set_bonding_mode_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bonding_mode_result *res = parsed_result;
+   portid_t port_id = res->port_id;
+
+   /* Set the bonding mode for the relevant port. */
+   if (0 != rte_eth_bond_mode_set(port_id, res->value))
+   printf("\t Failed to set bonding mode for port = %d.\n", 
port_id);
+}
+
+cmdline_parse_token_string_t cmd_setbonding_mode_set =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_setbonding_mode_mode =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   mode, "mode");
+cmdline_parse_token_num_t cmd_setbonding_mode_value =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   value, UINT8);
+cmdline_parse_token_num_t cmd_setbonding_mode_port =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_set_bonding_mode = {
+   .f = cmd_set_bonding_mode_parsed,
+   .help_str = "set bonding mode (mode_value) (port_id): Set the 
bonding mode for port_id",
+   .data = NULL,
+   .tokens = {
+   (void *) &cmd_setbonding_mode_set,
+   (void *) &cmd_setbonding_mode_bonding,
+   (void *) &cmd_setbonding_mode_mode,
+   (void *) &cmd_setbonding_mode_value,
+   (void *) &cmd_setbonding_mode_port,
+   NULL
+   }
+};
+
+/* *** SET BALANCE XMIT POLICY *** 

[dpdk-dev] [PATCH v10 1/5] bond: new link bonding library

2014-06-27 Thread Declan Doherty
Initial release with support for
 Mode 0 - Round Robin
 Mode 1 - Active Backup
 Mode 2 - Balance -> Supports 3 transmit polices (layer 2, layer 2+3, layer 3+4)
 Mode 3 - Broadcast

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 config/common_bsdapp   |5 +
 config/common_linuxapp |5 +
 doc/doxy-api-index.md  |1 +
 doc/doxy-api.conf  |1 +
 lib/Makefile   |1 +
 lib/librte_pmd_bond/Makefile   |   61 ++
 lib/librte_pmd_bond/rte_eth_bond.h |  255 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c |  662 +++
 lib/librte_pmd_bond/rte_eth_bond_args.c|  252 ++
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 1212 
 lib/librte_pmd_bond/rte_eth_bond_private.h |  215 +
 mk/rte.app.mk  |4 +
 12 files changed, 2674 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_api.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_args.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_pmd.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_private.h

diff --git a/config/common_bsdapp b/config/common_bsdapp
index d5db4ab..c243b0c 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -206,6 +206,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y

 #
+# Compile link bonding PMD library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index c5c0cb6..6237ce5 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -244,6 +244,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n

 #
+# Compile link bonding PMD library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Compile Xen PMD
 #
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
diff --git a/doc/doxy-api-index.md b/doc/doxy-api-index.md
index 7b26e98..d72659a 100644
--- a/doc/doxy-api-index.md
+++ b/doc/doxy-api-index.md
@@ -38,6 +38,7 @@ There are many libraries, so their headers may be grouped by 
topics:
 - **device**:
   [ethdev] (@ref rte_ethdev.h),
   [devargs](@ref rte_devargs.h),
+  [bond]   (@ref rte_eth_bond.h),
   [KNI](@ref rte_kni.h),
   [PCI](@ref rte_pci.h),
   [PCI IDs](@ref rte_pci_dev_ids.h)
diff --git a/doc/doxy-api.conf b/doc/doxy-api.conf
index f380d9a..1fd4492 100644
--- a/doc/doxy-api.conf
+++ b/doc/doxy-api.conf
@@ -47,6 +47,7 @@ INPUT   = doc/doxy-api-index.md \
   lib/librte_pipeline \
   lib/librte_port \
   lib/librte_power \
+  lib/librte_pmd_bond \
   lib/librte_ring \
   lib/librte_sched \
   lib/librte_table \
diff --git a/lib/Makefile b/lib/Makefile
index c58c0c9..10c5bb3 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -44,6 +44,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
diff --git a/lib/librte_pmd_bond/Makefile b/lib/librte_pmd_bond/Makefile
new file mode 100644
index 000..21998f7
--- /dev/null
+++ b/lib/librte_pmd_bond/Makefile
@@ -0,0 +1,61 @@
+#   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 AN

[dpdk-dev] [PATCH v10 4/5] bond: unit tests

2014-06-27 Thread Declan Doherty
Including:
 - code to generate packet bursts for testing rx and tx
   functionality of bonded device
 - virtual/stubbed out ethdev for use as slave ethdev in testing

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 app/test/Makefile |4 +-
 app/test/commands.c   |7 +
 app/test/packet_burst_generator.c |  287 +++
 app/test/packet_burst_generator.h |   78 +
 app/test/test.h   |1 +
 app/test/test_link_bonding.c  | 3958 +
 app/test/virtual_pmd.c|  574 ++
 app/test/virtual_pmd.h|   74 +
 8 files changed, 4982 insertions(+), 1 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 45d0cf2..cec2f2f 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -102,7 +102,9 @@ SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor_perf.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_devargs.c
-
+SRCS-$(CONFIG_RTE_APP_TEST) += virtual_pmd.c
+SRCS-$(CONFIG_RTE_APP_TEST) += packet_burst_generator.c
+SRCS-$(CONFIG_RTE_APP_TEST) += test_link_bonding.c
 ifeq ($(CONFIG_RTE_APP_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
diff --git a/app/test/commands.c b/app/test/commands.c
index c9dc085..5f23420 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -159,6 +159,10 @@ static void cmd_autotest_parsed(void *parsed_result,
ret = test_timer();
if (!strcmp(res->autotest, "timer_perf_autotest"))
ret = test_timer_perf();
+#ifdef RTE_LIBRTE_PMD_BOND
+   if (!strcmp(res->autotest, "link_bonding_autotest"))
+   ret = test_link_bonding();
+#endif
if (!strcmp(res->autotest, "mempool_autotest"))
ret = test_mempool();
if (!strcmp(res->autotest, "mempool_perf_autotest"))
@@ -227,6 +231,9 @@ cmdline_parse_token_string_t cmd_autotest_autotest =
"alarm_autotest#interrupt_autotest#"
"version_autotest#eal_fs_autotest#"
"cmdline_autotest#func_reentrancy_autotest#"
+#ifdef RTE_LIBRTE_PMD_BOND
+   "link_bonding_autotest#"
+#endif
"mempool_perf_autotest#hash_perf_autotest#"
"memcpy_perf_autotest#ring_perf_autotest#"
"red_autotest#meter_autotest#sched_autotest#"
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
new file mode 100644
index 000..5d539f1
--- /dev/null
+++ b/app/test/packet_burst_generator.c
@@ -0,0 +1,287 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include "packet_burst_generator.h"
+
+#define UDP_SRC_PORT 1024
+#define UDP_DST_PORT 1024
+
+
+#define IP_DEFTTL  64   /* from RFC 1340. */
+#def

[dpdk-dev] [PATCH v11 0/5] link bonding library

2014-06-29 Thread Declan Doherty
Hi Thomas,
This patchset contains the name change fix in the link bonding library
makefile. I have also put a change into the unit test application makefile
so that the link bonding tests are not built if the library is also not being
built. It doesn't make sense to split the bonding libraries APIs into a seperate
library, as they are directly coupled to with the bonding library implmentation

Declan Doherty (5):
  bond: new link bonding library
  ethdev: add unique name to devices
  eal: support link bonding device initialization
  bond: unit tests
  bond: testpmd support

 app/test-pmd/cmdline.c  |  579 
 app/test-pmd/config.c   |4 +-
 app/test-pmd/parameters.c   |3 +
 app/test-pmd/testpmd.c  |   40 +-
 app/test-pmd/testpmd.h  |2 +
 app/test/Makefile   |6 +-
 app/test/commands.c |7 +
 app/test/packet_burst_generator.c   |  287 ++
 app/test/packet_burst_generator.h   |   78 +
 app/test/test.h |1 +
 app/test/test_link_bonding.c| 3958 +++
 app/test/virtual_pmd.c  |  574 
 app/test/virtual_pmd.h  |   74 +
 config/common_bsdapp|5 +
 config/common_linuxapp  |5 +
 doc/doxy-api-index.md   |1 +
 doc/doxy-api.conf   |1 +
 lib/Makefile|1 +
 lib/librte_eal/bsdapp/eal/eal.c |   10 +-
 lib/librte_eal/common/eal_common_dev.c  |   58 +-
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 -
 lib/librte_eal/common/include/rte_dev.h |   14 +-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 lib/librte_ether/rte_ethdev.c   |   31 +-
 lib/librte_ether/rte_ethdev.h   |7 +-
 lib/librte_pmd_bond/Makefile|   61 +
 lib/librte_pmd_bond/rte_eth_bond.h  |  255 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c  |  662 +
 lib/librte_pmd_bond/rte_eth_bond_args.c |  252 ++
 lib/librte_pmd_bond/rte_eth_bond_pmd.c  | 1212 
 lib/librte_pmd_bond/rte_eth_bond_private.h  |  215 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c  |   22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  |   32 +-
 lib/librte_pmd_ring/rte_eth_ring.h  |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|2 +-
 mk/rte.app.mk   |4 +
 37 files changed, 8416 insertions(+), 71 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_api.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_args.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_pmd.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_private.h



[dpdk-dev] [PATCH v11 2/5] ethdev: add unique name to devices

2014-06-29 Thread Declan Doherty
Adding support to rte_eth_dev_data structure to support unique
name identifier for ethdevs to support adding slave ethdevs
(specifically virtual devices which have no public unique
identifier) to a link bonding device. This changes the API
rte_eth_dev_allocate() to require a const char *name when
allocating a ethdev, which also verifies that the name is
unique and hasn?t been already used by an existed allocated
rte_eth_dev. Also contains updates to virtual pmd?s to now call
the API with a name parameter.

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 lib/librte_ether/rte_ethdev.c|   31 ++--
 lib/librte_ether/rte_ethdev.h|7 +-
 lib/librte_pmd_pcap/rte_eth_pcap.c   |   22 ++--
 lib/librte_pmd_ring/rte_eth_ring.c   |   32 +++--
 lib/librte_pmd_ring/rte_eth_ring.h   |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c |2 +-
 6 files changed, 65 insertions(+), 32 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ef81a76..0ebb8fb 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -65,6 +65,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_ether.h"
 #include "rte_ethdev.h"
@@ -153,21 +154,39 @@ rte_eth_dev_data_alloc(void)
RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
 }

+static struct rte_eth_dev *
+rte_eth_dev_allocated(const char *name)
+{
+   unsigned i;
+
+   for (i = 0; i < nb_ports; i++) {
+   if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+   return &rte_eth_devices[i];
+   }
+   return NULL;
+}
+
 struct rte_eth_dev *
-rte_eth_dev_allocate(void)
+rte_eth_dev_allocate(const char *name)
 {
struct rte_eth_dev *eth_dev;

if (nb_ports == RTE_MAX_ETHPORTS) {
-   PMD_DEBUG_TRACE("Reached maximum number of ethernet ports\n");
+   PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
return NULL;
}

if (rte_eth_dev_data == NULL)
rte_eth_dev_data_alloc();

+   if (rte_eth_dev_allocated(name) != NULL) {
+   PMD_DEBUG_TRACE("Ethernet Device with name %s already 
allocated!\n");
+   return NULL;
+   }
+
eth_dev = &rte_eth_devices[nb_ports];
eth_dev->data = &rte_eth_dev_data[nb_ports];
+   snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
eth_dev->data->port_id = nb_ports++;
return eth_dev;
 }
@@ -178,11 +197,17 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 {
struct eth_driver*eth_drv;
struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
int diag;

eth_drv = (struct eth_driver *)pci_drv;

-   eth_dev = rte_eth_dev_allocate();
+   /* Create unique Ethernet device name using PCI address */
+   snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d",
+   pci_dev->addr.bus, pci_dev->addr.devid, 
pci_dev->addr.function);
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
if (eth_dev == NULL)
return -ENOMEM;

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2406e45..50df654 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1497,6 +1497,8 @@ struct rte_eth_dev_sriov {
 };
 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)

+#define RTE_ETH_NAME_MAX_LEN (32)
+
 /**
  * @internal
  * The data part, with no function pointers, associated with each ethernet 
device.
@@ -1505,6 +1507,8 @@ struct rte_eth_dev_sriov {
  * processes in a multi-process configuration.
  */
 struct rte_eth_dev_data {
+   char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
+
void **rx_queues; /**< Array of pointers to RX queues. */
void **tx_queues; /**< Array of pointers to TX queues. */
uint16_t nb_rx_queues; /**< Number of RX queues. */
@@ -1560,10 +1564,11 @@ extern uint8_t rte_eth_dev_count(void);
  * Allocates a new ethdev slot for an ethernet device and returns the pointer
  * to that slot for the driver to use.
  *
+ * @param  nameUnique identifier name for each Ethernet device
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(void);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);

 struct eth_driver;
 /**
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c 
b/lib/librte_pmd_pcap/rte_eth_pcap.c
index b3dbbda..12b7e0c 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -534,7 +534,7 @@ open_tx_iface(const char *key __rte_unused, const char 
*value, void *extra_args)

[dpdk-dev] [PATCH v11 3/5] eal: support link bonding device initialization

2014-06-29 Thread Declan Doherty
Updating functionality in EAL to support adding link bonding
devices via ?vdev option. Link bonding devices will be
initialized after all physical devices have been probed and
initialized.

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 lib/librte_eal/bsdapp/eal/eal.c |   10 -
 lib/librte_eal/common/eal_common_dev.c  |   58 ++
 lib/librte_eal/common/eal_common_pci.c  |3 +
 lib/librte_eal/common/include/eal_private.h |7 ---
 lib/librte_eal/common/include/rte_dev.h |   14 ++-
 lib/librte_eal/linuxapp/eal/eal.c   |   11 +-
 6 files changed, 74 insertions(+), 29 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index a1f014f..c53f63e 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -874,7 +874,7 @@ rte_eal_init(int argc, char **argv)

rte_eal_mcfg_complete();

-   if (rte_eal_dev_init() < 0)
+   if (rte_eal_dev_init(PMD_INIT_PRE_PCI_PROBE) < 0)
rte_panic("Cannot init pmd devices\n");

RTE_LCORE_FOREACH_SLAVE(i) {
@@ -906,6 +906,14 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
rte_eal_mp_wait_lcore();

+   /* Probe & Initialize PCI devices */
+   if (rte_eal_pci_probe())
+   rte_panic("Cannot probe PCI\n");
+
+   /* Initialize any outstanding devices */
+   if (rte_eal_dev_init(PMD_INIT_POST_PCI_PROBE) < 0)
+   rte_panic("Cannot init pmd devices\n");
+
return fctret;
 }

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..1194419 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -62,7 +62,7 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_dev_init(void)
+rte_eal_dev_init(uint8_t init_pri)
 {
struct rte_devargs *devargs;
struct rte_driver *driver;
@@ -80,30 +80,52 @@ rte_eal_dev_init(void)
continue;

TAILQ_FOREACH(driver, &dev_driver_list, next) {
-   if (driver->type != PMD_VDEV)
-   continue;
+   /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device,
+* virtual devices are initialized pre PCI probing and 
bonded
+* device are post pci probing */
+   if ((driver->type == PMD_VDEV && init_pri ==
+   PMD_INIT_PRE_PCI_PROBE) ||
+   (driver->type == PMD_BDEV && init_pri ==
+   PMD_INIT_POST_PCI_PROBE)) {

-   /* search a driver prefix in virtual device name */
-   if (!strncmp(driver->name, devargs->virtual.drv_name,
-   strlen(driver->name))) {
-   driver->init(devargs->virtual.drv_name,
-   devargs->args);
-   break;
+   /* search a driver prefix in virtual device 
name */
+   if (!strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   printf("init (%u) %s\n", init_pri, 
devargs->virtual.drv_name);
+   driver->init(devargs->virtual.drv_name,
+   devargs->args);
+   break;
+   }
}
}

-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   /* If initializing pre PCI probe, then we don't expect a bonded 
driver
+* to be found */
+   if (init_pri == PMD_INIT_PRE_PCI_PROBE &&
+   strncmp(PMD_BOND_NAME, 
devargs->virtual.drv_name,
+   strlen(PMD_BOND_NAME)) != 0) {
+   if (driver == NULL) {
+   rte_panic("no driver found for virtual device 
%s\n",
+   devargs->virtual.drv_name);
+   }
+   } else if (init_pri == PMD_INIT_POST_PCI_PROBE &&
+   strncmp(PMD_BOND_NAME, 
devargs->virtual.drv_name,
+   strlen(PMD_BOND_NAME)) == 0) {
+ 

[dpdk-dev] [PATCH v11 5/5] bond: testpmd support

2014-06-29 Thread Declan Doherty
 - Includes the ability to create new bonded devices.
 - Add /remove bonding slave devices.
 - Interogate bonded device stats/configuration
 - Change bonding modes and select balance transmit polices

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 app/test-pmd/cmdline.c|  579 +
 app/test-pmd/config.c |4 +-
 app/test-pmd/parameters.c |3 +
 app/test-pmd/testpmd.c|   40 +++-
 app/test-pmd/testpmd.h|2 +
 5 files changed, 619 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f61a31c..345be11 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -84,6 +84,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_LIBRTE_PMD_BOND
+#include 
+#endif

 #include "testpmd.h"

@@ -412,6 +415,31 @@ static void cmd_help_long_parsed(void *parsed_result,
"   Show the bypass configuration for a bypass enabled 
NIC"
" using the lowest port on the NIC.\n\n"
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+   "create bonded device (mode) (socket)\n"
+   "   Create a new bonded device with specific 
bonding mode and socket.\n\n"
+
+   "add bonding slave (slave_id) (port_id)\n"
+   "   Add a slave device to a bonded device.\n\n"
+
+   "remove bonding slave (slave_id) (port_id)\n"
+   "   Remove a slave device from a bonded device.\n\n"
+
+   "set bonding mode (value) (port_id)\n"
+   "   Set the bonding mode on a bonded device.\n\n"
+
+   "set bonding primary (slave_id) (port_id)\n"
+   "   Set the primary slave for a bonded device.\n\n"
+
+   "show bonding config (port_id)\n"
+   "   Show the bonding config for port_id.\n\n"
+
+   "set bonding mac_addr (port_id) (address)\n"
+   "   Set the MAC address of a bonded device.\n\n"
+
+   "set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
+   "   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+#endif

, list_pkt_forwarding_modes()
);
@@ -3039,6 +3067,547 @@ cmdline_parse_inst_t cmd_show_bypass_config = {
 };
 #endif

+#ifdef RTE_LIBRTE_PMD_BOND
+/* *** SET BONDING MODE *** */
+struct cmd_set_bonding_mode_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mode;
+   uint8_t value;
+   uint8_t port_id;
+};
+
+static void cmd_set_bonding_mode_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bonding_mode_result *res = parsed_result;
+   portid_t port_id = res->port_id;
+
+   /* Set the bonding mode for the relevant port. */
+   if (0 != rte_eth_bond_mode_set(port_id, res->value))
+   printf("\t Failed to set bonding mode for port = %d.\n", 
port_id);
+}
+
+cmdline_parse_token_string_t cmd_setbonding_mode_set =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_setbonding_mode_mode =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   mode, "mode");
+cmdline_parse_token_num_t cmd_setbonding_mode_value =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   value, UINT8);
+cmdline_parse_token_num_t cmd_setbonding_mode_port =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_set_bonding_mode = {
+   .f = cmd_set_bonding_mode_parsed,
+   .help_str = "set bonding mode (mode_value) (port_id): Set the 
bonding mode for port_id",
+   .data = NULL,
+   .tokens = {
+   (void *) &cmd_setbonding_mode_set,
+   (void *) &cmd_setbonding_mode_bonding,
+   (void *) &cmd_setbonding_mode_mode,
+   (void *) &cmd_setbonding_mode_value,
+   (void *) &cmd_setbonding_mode_port,
+   NULL
+   }
+};
+
+/* *** SET BALANCE XMIT POLICY *** 

[dpdk-dev] [PATCH v11 1/5] bond: new link bonding library

2014-06-29 Thread Declan Doherty
Initial release with support for
 Mode 0 - Round Robin
 Mode 1 - Active Backup
 Mode 2 - Balance -> Supports 3 transmit polices (layer 2, layer 2+3, layer 3+4)
 Mode 3 - Broadcast

Signed-off-by: Declan Doherty 
---
 config/common_bsdapp   |5 +
 config/common_linuxapp |5 +
 doc/doxy-api-index.md  |1 +
 doc/doxy-api.conf  |1 +
 lib/Makefile   |1 +
 lib/librte_pmd_bond/Makefile   |   61 ++
 lib/librte_pmd_bond/rte_eth_bond.h |  255 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c |  662 +++
 lib/librte_pmd_bond/rte_eth_bond_args.c|  252 ++
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 1212 
 lib/librte_pmd_bond/rte_eth_bond_private.h |  215 +
 mk/rte.app.mk  |4 +
 12 files changed, 2674 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_api.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_args.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_pmd.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond_private.h

diff --git a/config/common_bsdapp b/config/common_bsdapp
index d5db4ab..c243b0c 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -206,6 +206,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y

 #
+# Compile link bonding PMD library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index c5c0cb6..6237ce5 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -244,6 +244,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n

 #
+# Compile link bonding PMD library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Compile Xen PMD
 #
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
diff --git a/doc/doxy-api-index.md b/doc/doxy-api-index.md
index 7b26e98..d72659a 100644
--- a/doc/doxy-api-index.md
+++ b/doc/doxy-api-index.md
@@ -38,6 +38,7 @@ There are many libraries, so their headers may be grouped by 
topics:
 - **device**:
   [ethdev] (@ref rte_ethdev.h),
   [devargs](@ref rte_devargs.h),
+  [bond]   (@ref rte_eth_bond.h),
   [KNI](@ref rte_kni.h),
   [PCI](@ref rte_pci.h),
   [PCI IDs](@ref rte_pci_dev_ids.h)
diff --git a/doc/doxy-api.conf b/doc/doxy-api.conf
index f380d9a..1fd4492 100644
--- a/doc/doxy-api.conf
+++ b/doc/doxy-api.conf
@@ -47,6 +47,7 @@ INPUT   = doc/doxy-api-index.md \
   lib/librte_pipeline \
   lib/librte_port \
   lib/librte_power \
+  lib/librte_pmd_bond \
   lib/librte_ring \
   lib/librte_sched \
   lib/librte_table \
diff --git a/lib/Makefile b/lib/Makefile
index c58c0c9..10c5bb3 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -44,6 +44,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
diff --git a/lib/librte_pmd_bond/Makefile b/lib/librte_pmd_bond/Makefile
new file mode 100644
index 000..953d75e
--- /dev/null
+++ b/lib/librte_pmd_bond/Makefile
@@ -0,0 +1,61 @@
+#   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 PARTI

[dpdk-dev] [PATCH v11 4/5] bond: unit tests

2014-06-29 Thread Declan Doherty
Including:
 - code to generate packet bursts for testing rx and tx
   functionality of bonded device
 - virtual/stubbed out ethdev for use as slave ethdev in testing

Signed-off-by: Declan Doherty 
Acked-by: Pablo de Lara 
---
 app/test/Makefile |6 +-
 app/test/commands.c   |7 +
 app/test/packet_burst_generator.c |  287 +++
 app/test/packet_burst_generator.h |   78 +
 app/test/test.h   |1 +
 app/test/test_link_bonding.c  | 3958 +
 app/test/virtual_pmd.c|  574 ++
 app/test/virtual_pmd.h|   74 +
 8 files changed, 4984 insertions(+), 1 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 45d0cf2..e1b2c03 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -102,7 +102,11 @@ SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor_perf.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_devargs.c
-
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y)
+SRCS-$(CONFIG_RTE_APP_TEST) += virtual_pmd.c
+SRCS-$(CONFIG_RTE_APP_TEST) += packet_burst_generator.c
+SRCS-$(CONFIG_RTE_APP_TEST) += test_link_bonding.c
+endif
 ifeq ($(CONFIG_RTE_APP_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
diff --git a/app/test/commands.c b/app/test/commands.c
index c9dc085..5f23420 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -159,6 +159,10 @@ static void cmd_autotest_parsed(void *parsed_result,
ret = test_timer();
if (!strcmp(res->autotest, "timer_perf_autotest"))
ret = test_timer_perf();
+#ifdef RTE_LIBRTE_PMD_BOND
+   if (!strcmp(res->autotest, "link_bonding_autotest"))
+   ret = test_link_bonding();
+#endif
if (!strcmp(res->autotest, "mempool_autotest"))
ret = test_mempool();
if (!strcmp(res->autotest, "mempool_perf_autotest"))
@@ -227,6 +231,9 @@ cmdline_parse_token_string_t cmd_autotest_autotest =
"alarm_autotest#interrupt_autotest#"
"version_autotest#eal_fs_autotest#"
"cmdline_autotest#func_reentrancy_autotest#"
+#ifdef RTE_LIBRTE_PMD_BOND
+   "link_bonding_autotest#"
+#endif
"mempool_perf_autotest#hash_perf_autotest#"
"memcpy_perf_autotest#ring_perf_autotest#"
"red_autotest#meter_autotest#sched_autotest#"
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
new file mode 100644
index 000..5d539f1
--- /dev/null
+++ b/app/test/packet_burst_generator.c
@@ -0,0 +1,287 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include "packet_burst_generator.h"
+
+#define UDP_SRC_PORT 1024
+#define UDP_DST_PORT 1024
+
+
+#d

[dpdk-dev] [PATCH v6 2/8] bond: removing switch statement from rx burst method

2014-11-07 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 65 +++---
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index de0cd56..f2fe930 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -59,35 +59,38 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, 
uint16_t nb_pkts)

internals = bd_rx_q->dev_private;

-   switch (internals->mode) {
-   case BONDING_MODE_ROUND_ROBIN:
-#ifdef RTE_MBUF_REFCNT
-   case BONDING_MODE_BROADCAST:
-#endif
-   case BONDING_MODE_BALANCE:
-   for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
-   /* Offset of pointer to *bufs increases as packets are 
received
-* from other slaves */
-   num_rx_slave = 
rte_eth_rx_burst(internals->active_slaves[i],
-   bd_rx_q->queue_id, bufs + num_rx_total, 
nb_pkts);
-   if (num_rx_slave) {
-   num_rx_total += num_rx_slave;
-   nb_pkts -= num_rx_slave;
-   }
+
+   for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
+   /* Offset of pointer to *bufs increases as packets are received
+* from other slaves */
+   num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
+   bd_rx_q->queue_id, bufs + num_rx_total, 
nb_pkts);
+   if (num_rx_slave) {
+   num_rx_total += num_rx_slave;
+   nb_pkts -= num_rx_slave;
}
-   break;
-   case BONDING_MODE_ACTIVE_BACKUP:
-   num_rx_slave = rte_eth_rx_burst(internals->current_primary_port,
-   bd_rx_q->queue_id, bufs, nb_pkts);
-   if (num_rx_slave)
-   num_rx_total = num_rx_slave;
-   break;
}
+
return num_rx_total;
 }

 static uint16_t
-bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
+bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
+   uint16_t nb_pkts)
+{
+   struct bond_dev_private *internals;
+
+   /* Cast to structure, containing bonded device's port id and queue id */
+   struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
+
+   internals = bd_rx_q->dev_private;
+
+   return rte_eth_rx_burst(internals->current_primary_port,
+   bd_rx_q->queue_id, bufs, nb_pkts);
+}
+
+static uint16_t
+bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts)
 {
struct bond_dev_private *dev_private;
@@ -136,7 +139,7 @@ bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf 
**bufs,
 }

 static uint16_t
-bond_ethdev_tx_active_backup(void *queue,
+bond_ethdev_tx_burst_active_backup(void *queue,
struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
struct bond_dev_private *internals;
@@ -272,7 +275,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t 
slave_count, uint8_t policy)
 }

 static uint16_t
-bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
+   uint16_t nb_pkts)
 {
struct bond_dev_private *internals;
struct bond_tx_queue *bd_tx_q;
@@ -486,24 +490,27 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int 
mode)

switch (mode) {
case BONDING_MODE_ROUND_ROBIN:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
case BONDING_MODE_ACTIVE_BACKUP:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
break;
case BONDING_MODE_BALANCE:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_balance;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
 #ifdef RTE_MBUF_REFCNT
case BONDING_MODE_BROADCAST:
eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
 #endif
default:
return -1;
}

-   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
internals->mode = mode;

return 0;
-- 
1.7.12.2



[dpdk-dev] [PATCH v6 1/8] bond: link status interrupt support

2014-11-07 Thread Declan Doherty
Adding support for lsc interrupt from bonded device to link
bonding library with supporting unit tests in the test application.

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   | 213 +++--
 lib/librte_pmd_bond/rte_eth_bond_api.c |   4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   6 +
 3 files changed, 189 insertions(+), 34 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 214d2a2..e1c5596 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -224,10 +225,15 @@ static struct rte_eth_txconf tx_conf_default = {
 };

 static int
-configure_ethdev(uint8_t port_id, uint8_t start)
+configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 {
int q_id;

+   if (en_isr)
+   default_pmd_conf.intr_conf.lsc = 1;
+   else
+   default_pmd_conf.intr_conf.lsc = 0;
+
if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
test_params->nb_tx_q, &default_pmd_conf) != 0) {
goto error;
@@ -312,7 +318,7 @@ test_setup(void)

printf("Created virtual ethdev %s\n", pmd_name);

-   retval = 
configure_ethdev(test_params->slave_port_ids[i], 1);
+   retval = 
configure_ethdev(test_params->slave_port_ids[i], 1, 0);
if (retval != 0) {
printf("Failed to configure virtual ethdev 
%s\n", pmd_name);
return -1;
@@ -341,7 +347,7 @@ test_create_bonded_device(void)
TEST_ASSERT(test_params->bonded_port_id >= 0,
"Failed to create bonded ethdev %s", 
BONDED_DEV_NAME);

-   
TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
+   
TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
"Failed to configure bonded ethdev %s", 
BONDED_DEV_NAME);
}

@@ -1081,12 +1087,12 @@ test_set_explicit_bonded_mac(void)


 static int
-initialize_bonded_device_with_slaves(uint8_t bonding_mode,
+initialize_bonded_device_with_slaves(uint8_t bonding_mode, uint8_t bond_en_isr,
uint8_t number_of_slaves, uint8_t enable_slave)
 {
/* configure bonded device */
-   TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
-   "Failed to configure bonding port (%d) in mode %d "
+   TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
+   bond_en_isr), "Failed to configure bonding port (%d) in 
mode %d "
"with (%d) slaves.", test_params->bonded_port_id, 
bonding_mode,
number_of_slaves);

@@ -1119,8 +1125,8 @@ test_adding_slave_after_bonded_device_started(void)
 {
int i;

-   if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 
0) !=
-   0)
+   if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 
4, 0)
+   != 0)
return -1;

/* Enabled slave devices */
@@ -1144,6 +1150,144 @@ test_adding_slave_after_bonded_device_started(void)
return remove_slaves_and_stop_bonded_device();
 }

+#define TEST_STATUS_INTERRUPT_SLAVE_COUNT  4
+#define TEST_LSC_WAIT_TIMEOUT_MS   500
+
+int test_lsc_interupt_count;
+
+static pthread_mutex_t mutex;
+static pthread_cond_t cvar;
+
+static void
+test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
+   enum rte_eth_event_type type  __rte_unused, void *param 
__rte_unused)
+{
+   pthread_mutex_lock(&mutex);
+   test_lsc_interupt_count++;
+
+   pthread_cond_signal(&cvar);
+   pthread_mutex_unlock(&mutex);
+}
+
+static inline int
+lsc_timeout(int wait_us)
+{
+   int retval = 0;
+
+   struct timespec ts;
+   struct timeval tp;
+
+   gettimeofday(&tp, NULL);
+
+   /* Convert from timeval to timespec */
+   ts.tv_sec  = tp.tv_sec;
+   ts.tv_nsec = tp.tv_usec * 1000;
+   ts.tv_nsec += wait_us * 1000;
+
+   pthread_mutex_lock(&mutex);
+   if (test_lsc_interupt_count < 1)
+   retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+
+   pthread_mutex_unlock(&mutex);
+
+   return retval;
+}
+
+static int
+test_status_interrupt(void)
+{
+   int slave_count;
+   uint8_t slaves[RTE_MAX_ETHPORTS];
+
+   pthread_mutex_init(&mutex, NULL);
+   pthread_cond_init(&cvar, NULL);
+
+   /* initialized bonding device with T slaves */
+   if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
+   TEST_S

[dpdk-dev] [PATCH v6 0/8] link bonding

2014-11-07 Thread Declan Doherty
v6:
- Re-based to dpdk.org addressing associated issues for MBUF_REFCNT
- Added details to testpmd user guide for new command to set link status 
polling interval.

v5:
- Fix uninitialized variable in broadcast_tx_burst function which caused a
  build error in 32-bit build
- Address unit test issue which is exposed by new test in mode 4/5 patch sets

v4:
- Rebased to account for changes in master.
- Fix for rte_eth_bond_slaves_get() introduced in v3 patch set
- Addressed issue around disabling/enabling link status polling around adding/
  removing slaves devices.

v3 :
- Typo fix for the bond free mbufs patch.
- Rebased to account for changes in the mbuf patches.
- Add support for slave devices which don't support link status interrupts 
- Tidy up the link bonding unit test so that all tests use the new test macros.

v2 :
Addresses issues with the logic around the handling of fail transmissions.
In this version all modes behave in a manner similar to a standard PMD,
returning the number of successfully transmitted mbufs and with the failing
mbufs at the end of bufs array for freeing / retransmission by the 
application software

v1:

This patch set adds support for link status interrupt in the link bonding
pmd. It also contains some patches to tidy up the code structure and to
of the link bonding code and to fix bugs relating to transmission 
failures in the under lying slave pmd which could lead to leaked mbufs. 


Declan Doherty (8):
  bond: link status interrupt support
  bond: removing switch statement from rx burst method
  bond: fix naming inconsistency in tx_burst_round_robin
  bond: free mbufs if transmission fails in bonding tx_burst functions
  test app: adding support for generating variable sized packet
  testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist
  bond: lsc polling support
  bond: unit test test macro refactor

 app/test-pmd/cmdline.c  |   65 +-
 app/test-pmd/testpmd.c  |3 +-
 app/test-pmd/testpmd.h  |2 +-
 app/test/packet_burst_generator.c   |   25 +-
 app/test/packet_burst_generator.h   |6 +-
 app/test/test.h |7 +-
 app/test/test_link_bonding.c| 3347 ++-
 app/test/virtual_pmd.c  |   96 +-
 app/test/virtual_pmd.h  |   53 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   19 +
 lib/librte_pmd_bond/rte_eth_bond.h  |   80 +
 lib/librte_pmd_bond/rte_eth_bond_api.c  |  319 ++-
 lib/librte_pmd_bond/rte_eth_bond_args.c |   28 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c  |  553 +++--
 lib/librte_pmd_bond/rte_eth_bond_private.h  |   71 +-
 15 files changed, 2715 insertions(+), 1959 deletions(-)

-- 
1.7.12.2



[dpdk-dev] [PATCH v6 3/8] bond: fix naming inconsistency in tx_burst_round_robin

2014-11-07 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index f2fe930..6e770af 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -93,7 +93,7 @@ static uint16_t
 bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts)
 {
-   struct bond_dev_private *dev_private;
+   struct bond_dev_private *internals;
struct bond_tx_queue *bd_tx_q;

struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_pkts];
@@ -108,13 +108,13 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct 
rte_mbuf **bufs,
int i, cs_idx = 0;

bd_tx_q = (struct bond_tx_queue *)queue;
-   dev_private = bd_tx_q->dev_private;
+   internals = bd_tx_q->dev_private;

/* Copy slave list to protect against slave up/down changes during tx
 * bursting */
-   num_of_slaves = dev_private->active_slave_count;
-   memcpy(slaves, dev_private->active_slaves,
-   sizeof(dev_private->active_slaves[0]) * num_of_slaves);
+   num_of_slaves = internals->active_slave_count;
+   memcpy(slaves, internals->active_slaves,
+   sizeof(internals->active_slaves[0]) * num_of_slaves);

if (num_of_slaves < 1)
return num_tx_total;
-- 
1.7.12.2



[dpdk-dev] [PATCH v6 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist

2014-11-07 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c | 2 +-
 app/test-pmd/testpmd.c | 3 ++-
 app/test-pmd/testpmd.h | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4c3fc76..be12c13 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3642,7 +3642,7 @@ static void cmd_create_bonded_device_parsed(void 
*parsed_result,

/* Update number of ports */
nb_ports = rte_eth_dev_count();
-   reconfig(port_id);
+   reconfig(port_id, res->socket);
rte_eth_promiscuous_enable(port_id);
}

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index f76406f..5740804 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -630,7 +630,7 @@ init_config(void)


 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
struct rte_port *port;

@@ -649,6 +649,7 @@ reconfig(portid_t new_port_id)
/* set flag to initialize port/queue */
port->need_reconfig = 1;
port->need_reconfig_queues = 1;
+   port->socket_id = socket_id;

init_port_config();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 9cbfeac..5a3423c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -457,7 +457,7 @@ void fwd_config_display(void);
 void rxtx_config_display(void);
 void fwd_config_setup(void);
 void set_def_fwd_config(void);
-void reconfig(portid_t new_port_id);
+void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);

 void port_mtu_set(portid_t port_id, uint16_t mtu);
-- 
1.7.12.2



[dpdk-dev] [PATCH v6 5/8] test app: adding support for generating variable sized packet

2014-11-07 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test/packet_burst_generator.c | 25 -
 app/test/packet_burst_generator.h |  6 +-
 app/test/test_link_bonding.c  | 14 +-
 3 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index 9e747a4..b2824dc 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -74,8 +74,7 @@ static inline void
 copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
 {
if (offset + len <= pkt->data_len) {
-   rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset,
-   buf, (size_t) len);
+   rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset, buf, 
(size_t) len);
return;
}
copy_buf_to_pkt_segs(buf, len, pkt, offset);
@@ -191,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t 
src_addr,
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */

-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
-   TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t  tx_pkt_nb_segs = 1;

 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+   uint8_t pkt_len, uint8_t nb_pkt_segs)
 {
int i, nb_pkt = 0;
size_t eth_hdr_size;
@@ -221,9 +212,9 @@ nomore_mbuf:
break;
}

-   pkt->data_len = tx_pkt_seg_lengths[0];
+   pkt->data_len = pkt_len;
pkt_seg = pkt;
-   for (i = 1; i < tx_pkt_nb_segs; i++) {
+   for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->next = rte_pktmbuf_alloc(mp);
if (pkt_seg->next == NULL) {
pkt->nb_segs = i;
@@ -231,7 +222,7 @@ nomore_mbuf:
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
-   pkt_seg->data_len = tx_pkt_seg_lengths[i];
+   pkt_seg->data_len = pkt_len;
}
pkt_seg->next = NULL; /* Last segment of packet. */

@@ -259,8 +250,8 @@ nomore_mbuf:
 * Complete first mbuf of packet and append it to the
 * burst of packets to be transmitted.
 */
-   pkt->nb_segs = tx_pkt_nb_segs;
-   pkt->pkt_len = tx_pkt_length;
+   pkt->nb_segs = nb_pkt_segs;
+   pkt->pkt_len = pkt_len;
pkt->l2_len = eth_hdr_size;

if (ipv4) {
diff --git a/app/test/packet_burst_generator.h 
b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -47,6 +47,9 @@ extern "C" {
 #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
((c & 0xff) << 8) | (d & 0xff))

+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
+

 void
 initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
@@ -68,7 +71,8 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t 
src_addr,
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+   uint8_t pkt_len, uint8_t nb_pkt_segs);

 #ifdef __cplusplus
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index af19066..547ee78 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -1341,7 +1341,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, 
uint16_t burst_size,
/* Generate burst of packets to transmit */
generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
pkts_burst, test_params->pkt_eth_hdr, vlan, ip_hdr, 
ipv4,
-   test_params->pkt_udp_hdr, burst_size);
+   test_params->pkt_udp_hdr, burst_size, 
PACKET_BURST_GEN_PKT_LEN_128,
+   1);
if (generated_burst_size != burst_size) {
printf("Failed to generate packet burst");
return -1;
@@ -2059,7 +20

[dpdk-dev] [PATCH v6 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions

2014-11-07 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   | 393 -
 app/test/virtual_pmd.c |  79 +--
 app/test/virtual_pmd.h |   7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  83 +--
 4 files changed, 524 insertions(+), 38 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index e1c5596..af19066 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -663,6 +663,9 @@ enable_bonded_slaves(void)
int i;

for (i = 0; i < test_params->bonded_slave_count; i++) {
+   
virtual_ethdev_tx_burst_fn_set_success(test_params->slave_port_ids[i],
+   1);
+
virtual_ethdev_simulate_link_status_interrupt(
test_params->slave_port_ids[i], 1);
}
@@ -1416,6 +1419,135 @@ test_roundrobin_tx_burst(void)
 }

 static int
+verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
+{
+   int i, refcnt;
+
+   for (i = 0; i < nb_mbufs; i++) {
+   refcnt = rte_mbuf_refcnt_read(mbufs[i]);
+   TEST_ASSERT_EQUAL(refcnt, val,
+   "mbuf ref count (%d)is not the expected value (%d)",
+   refcnt, val);
+   }
+   return 0;
+}
+
+
+static void
+free_mbufs(struct rte_mbuf **mbufs, int nb_mbufs)
+{
+   int i;
+
+   for (i = 0; i < nb_mbufs; i++)
+   rte_pktmbuf_free(mbufs[i]);
+}
+
+#define TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT  (2)
+#define TEST_RR_SLAVE_TX_FAIL_BURST_SIZE   (64)
+#define TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT(22)
+#define TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX(1)
+
+static int
+test_roundrobin_tx_burst_slave_tx_fail(void)
+{
+   struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
+   struct rte_mbuf *expected_tx_fail_pkts[MAX_PKT_BURST];
+
+   struct rte_eth_stats port_stats;
+
+   int i, first_fail_idx, tx_count;
+
+   TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+   BONDING_MODE_ROUND_ROBIN, 0,
+   TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+   "Failed to intialise bonded device");
+
+   /* Generate test bursts of packets to transmit */
+   TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE, 0, 1, 0, 0, 0),
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE,
+   "Failed to generate test packet burst");
+
+   /* Copy references to packets which we expect not to be transmitted */
+   first_fail_idx = (TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   (TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT *
+   TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)) +
+   TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX;
+
+   for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+   expected_tx_fail_pkts[i] = pkt_burst[first_fail_idx +
+   (i * TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)];
+   }
+
+   /* Set virtual slave to only fail transmission of
+* TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT packets in burst */
+   virtual_ethdev_tx_burst_fn_set_success(
+   
test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+   0);
+
+   virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+   
test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+   tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE);
+
+   TEST_ASSERT_EQUAL(tx_count, TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+   "Transmitted (%d) an unexpected (%d) number of 
packets", tx_count,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+   /* Verify that failed packet are expected failed packets */
+   for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+   TEST_ASSERT_EQUAL(expected_tx_fail_pkts[i], pkt_burst[i + 
tx_count],
+   "expected mbuf (%d) pointer %p not expected 
pointer %p",
+   i, expected_tx_fail_pkts[i], pkt_burst[i + 
tx_count]);
+   }
+
+   /* Verify bonded port tx stats */
+   rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+   TEST_ASSERT_EQUAL(port_stats.opackets,
+   (uint64_t)TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+   "Bonded Port (%d) 

[dpdk-dev] [PATCH v6 8/8] bond: unit test test macro refactor

2014-11-07 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c | 2574 +-
 1 file changed, 1036 insertions(+), 1538 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 4aa57a7..aa6a52f 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -31,6 +31,7 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include "unistd.h"
 #include 
 #include 
 #include 
@@ -265,7 +266,7 @@ static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
 static int
 test_setup(void)
 {
-   int i, retval, nb_mbuf_per_pool;
+   int i, nb_mbuf_per_pool;
struct ether_addr *mac_addr = (struct ether_addr *)slave_mac;

/* Allocate ethernet packet header with space for VLAN header */
@@ -273,10 +274,8 @@ test_setup(void)
test_params->pkt_eth_hdr = malloc(sizeof(struct ether_hdr) +
sizeof(struct vlan_hdr));

-   if (test_params->pkt_eth_hdr == NULL) {
-   printf("ethernet header struct allocation failed!\n");
-   return -1;
-   }
+   TEST_ASSERT_NOT_NULL(test_params->pkt_eth_hdr,
+   "Ethernet header struct allocation failed!");
}

nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX + DEF_PKT_BURST +
@@ -286,10 +285,8 @@ test_setup(void)
MBUF_SIZE, MBUF_CACHE_SIZE, sizeof(struct 
rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, 
NULL,
rte_socket_id(), 0);
-   if (test_params->mbuf_pool == NULL) {
-   printf("rte_mempool_create failed\n");
-   return -1;
-   }
+   TEST_ASSERT_NOT_NULL(test_params->mbuf_pool,
+   "rte_mempool_create failed");
}

/* Create / Initialize virtual eth devs */
@@ -303,20 +300,12 @@ test_setup(void)

test_params->slave_port_ids[i] = 
virtual_ethdev_create(pmd_name,
mac_addr, rte_socket_id(), 1);
-   if (test_params->slave_port_ids[i] < 0) {
-   printf("Failed to create virtual virtual ethdev 
%s\n", pmd_name);
-   return -1;
-   }
+   TEST_ASSERT(test_params->slave_port_ids[i] >= 0,
+   "Failed to create virtual virtual 
ethdev %s", pmd_name);

-   printf("Created virtual ethdev %s\n", pmd_name);
-
-   retval = 
configure_ethdev(test_params->slave_port_ids[i], 1, 0);
-   if (retval != 0) {
-   printf("Failed to configure virtual ethdev 
%s\n", pmd_name);
-   return -1;
-   }
-
-   printf("Configured virtual ethdev %s\n", pmd_name);
+   TEST_ASSERT_SUCCESS(configure_ethdev(
+   test_params->slave_port_ids[i], 1, 0),
+   "Failed to configure virtual ethdev 
%s", pmd_name);
}
slaves_initialized = 1;
}
@@ -350,14 +339,14 @@ test_create_bonded_device(void)
current_slave_count = 
rte_eth_bond_slaves_get(test_params->bonded_port_id,
slaves, RTE_MAX_ETHPORTS);

-   TEST_ASSERT(current_slave_count == 0,
+   TEST_ASSERT_EQUAL(current_slave_count, 0,
"Number of slaves %d is great than expected %d.",
current_slave_count, 0);

current_slave_count = rte_eth_bond_active_slaves_get(
test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS);

-   TEST_ASSERT(current_slave_count == 0,
+   TEST_ASSERT_EQUAL(current_slave_count, 0,
"Number of active slaves %d is great than expected %d.",
current_slave_count, 0);

@@ -375,30 +364,21 @@ test_create_bonded_device_with_invalid_params(void)
/* Invalid name */
port_id = rte_eth_bond_create(NULL, test_params->bonding_mode,
rte_socket_id());
-   if (port_id >= 0) {
-   printf("Created bonded device unexpectedly.\n");
-   return -1;
-   }
+   TEST_ASSERT(port_id < 0, "Created bonded device unexpectedly");

test_params->bonding_mode = INVALID_BONDING_MODE;

/* Invalid bonding mode */
port_id = rte_eth_bond_create(BONDED_DEV_NAME, 
test_params->bonding_mode,

[dpdk-dev] [PATCH v6 7/8] bond: lsc polling support

2014-11-07 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c  |  63 +
 app/test/test.h |   7 +-
 app/test/test_link_bonding.c| 265 ---
 app/test/virtual_pmd.c  |  17 +-
 app/test/virtual_pmd.h  |  48 +++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  19 ++
 lib/librte_pmd_bond/rte_eth_bond.h  |  80 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c  | 315 ++
 lib/librte_pmd_bond/rte_eth_bond_args.c |  28 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c  | 393 +---
 lib/librte_pmd_bond/rte_eth_bond_private.h  |  71 +++--
 11 files changed, 958 insertions(+), 348 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index be12c13..ee8c121 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -462,6 +462,9 @@ static void cmd_help_long_parsed(void *parsed_result,

"set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
"   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+
+   "set bonding mon_period (port_id) (value) \n"
+   "   Set the bonding link status monitoring polling 
period in ms.\n\n"
 #endif

, list_pkt_forwarding_modes()
@@ -3733,6 +3736,65 @@ cmdline_parse_inst_t cmd_set_bond_mac_addr = {
}
 };

+
+/* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
+struct cmd_set_bond_mon_period_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mon_period;
+   uint8_t port_num;
+   uint32_t period_ms;
+};
+
+static void cmd_set_bond_mon_period_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bond_mon_period_result *res = parsed_result;
+   int ret;
+
+   if (res->port_num >= nb_ports) {
+   printf("Port id %d must be less than %d\n", res->port_num, 
nb_ports);
+   return;
+   }
+
+   ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
+
+   /* check the return value and print it if is < 0 */
+   if (ret < 0)
+   printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
+}
+
+cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
+   mon_period, "mon_period");
+cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
+   TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
+   port_num, UINT8);
+cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
+   TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
+   period_ms, UINT32);
+
+cmdline_parse_inst_t cmd_set_bond_mon_period = {
+   .f = cmd_set_bond_mon_period_parsed,
+   .data = (void *) 0,
+   .help_str = "set bonding mon_period (port_id) (period_ms): ",
+   .tokens = {
+   (void *)&cmd_set_bond_mon_period_set,
+   (void *)&cmd_set_bond_mon_period_bonding,
+   (void *)&cmd_set_bond_mon_period_mon_period,
+   (void *)&cmd_set_bond_mon_period_portnum,
+   (void *)&cmd_set_bond_mon_period_period_ms,
+   NULL
+   }
+};
+
 #endif /* RTE_LIBRTE_PMD_BOND */

 /* *** SET FORWARDING MODE *** */
@@ -7787,6 +7849,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *) &cmd_create_bonded_device,
(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
+   (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
 #endif
(cmdline_parse_inst_t *)&cmd_vlan_offload,
(cmdline_parse_inst_t *)&cmd_vlan_tpid,
diff --git a/app/test/test.h b/app/test/test.h
index 98ab804..24b1640 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -62,14 +62,15 @@

 #define TEST_ASSERT_SUCCESS(val, msg, ...) do {
   

[dpdk-dev] [PATCH 0/2] enablement of avx512 instruction support in aesni_mb_pmd

2016-12-02 Thread Declan Doherty
In patchset "AESNI MB PMD updates"
(http://dpdk.org/ml/archives/dev/2016-December/050976.html) the AESNI 
Multi-Buffer Crypto for IPsec library which the aesni_mb_pmd depends on is 
updated to v0.44

The first patch in this patchset enables support for the AVX512 accelerated
functions added in the new version of the library to the aesni_mb_pmd.

The second patch add a new initialisation option which allows the user to
explicitly select which set of SIMD functions to use from the base library.


Declan Doherty (2):
  crypto/aesni_mb: enablement of avx512 support in IPsec_mb library
  crypto/aesni_mb: add new option to select SIMD mode

 drivers/crypto/aesni_mb/aesni_mb_ops.h |  28 +++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 142 ++---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h |   7 +
 lib/librte_cryptodev/rte_cryptodev.h   |   2 +
 4 files changed, 161 insertions(+), 18 deletions(-)

-- 
2.5.5



[dpdk-dev] [PATCH 1/2] crypto/aesni_mb: enablement of avx512 support in IPsec_mb library

2016-12-02 Thread Declan Doherty
Release v0.44 of Intel(R) Multi-Buffer Crypto for IPsec library adds support for
AVX512 instructions. This patch enables the new AVX512 accelerated functions
from the aesni_mb_pmd crypto poll mode driver.

This patch set requires that the aesni_mb_pmd is linked against the version 0.44
or greater of the Multi-Buffer Crypto for IPsec library.

Signed-off-by: Declan Doherty 
---
 drivers/crypto/aesni_mb/aesni_mb_ops.h | 28 +++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c |  7 ++-
 lib/librte_cryptodev/rte_cryptodev.h   |  2 ++
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/aesni_mb/aesni_mb_ops.h 
b/drivers/crypto/aesni_mb/aesni_mb_ops.h
index 0c119bf..2d41d73 100644
--- a/drivers/crypto/aesni_mb/aesni_mb_ops.h
+++ b/drivers/crypto/aesni_mb/aesni_mb_ops.h
@@ -44,7 +44,8 @@ enum aesni_mb_vector_mode {
RTE_AESNI_MB_NOT_SUPPORTED = 0,
RTE_AESNI_MB_SSE,
RTE_AESNI_MB_AVX,
-   RTE_AESNI_MB_AVX2
+   RTE_AESNI_MB_AVX2,
+   RTE_AESNI_MB_AVX512
 };
 
 typedef void (*md5_one_block_t)(void *data, void *digest);
@@ -203,6 +204,31 @@ static const struct aesni_mb_ops job_ops[] = {
aes_xcbc_expand_key_avx2
}
}
+   },
+   [RTE_AESNI_MB_AVX512] = {
+   .job = {
+   init_mb_mgr_avx512,
+   get_next_job_avx512,
+   submit_job_avx512,
+   get_completed_job_avx512,
+   flush_job_avx512
+   },
+   .aux = {
+   .one_block = {
+   md5_one_block_avx512,
+   sha1_one_block_avx512,
+   sha224_one_block_avx512,
+   sha256_one_block_avx512,
+   sha384_one_block_avx512,
+   sha512_one_block_avx512
+   },
+   .keyexp = {
+   aes_keyexp_128_avx512,
+   aes_keyexp_192_avx512,
+   aes_keyexp_256_avx512,
+   aes_xcbc_expand_key_avx512
+   }
+   }
}
 };
 
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index f07cd07..c400b17 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -613,7 +613,9 @@ cryptodev_aesni_mb_create(const char *name,
}
 
/* Check CPU for supported vector instruction set */
-   if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+   if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+   vector_mode = RTE_AESNI_MB_AVX512;
+   else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
vector_mode = RTE_AESNI_MB_AVX2;
else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
vector_mode = RTE_AESNI_MB_AVX;
@@ -660,6 +662,9 @@ cryptodev_aesni_mb_create(const char *name,
case RTE_AESNI_MB_AVX2:
dev->feature_flags |= RTE_CRYPTODEV_FF_CPU_AVX2;
break;
+   case RTE_AESNI_MB_AVX512:
+   dev->feature_flags |= RTE_CRYPTODEV_FF_CPU_AVX512;
+   break;
default:
break;
}
diff --git a/lib/librte_cryptodev/rte_cryptodev.h 
b/lib/librte_cryptodev/rte_cryptodev.h
index 8f63e8f..29d8eec 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -225,6 +225,8 @@ struct rte_cryptodev_capabilities {
 /**< Utilises CPU AES-NI instructions */
 #defineRTE_CRYPTODEV_FF_HW_ACCELERATED (1ULL << 7)
 /**< Operations are off-loaded to an external hardware accelerator */
+#defineRTE_CRYPTODEV_FF_CPU_AVX512 (1ULL << 8)
+/**< Utilises CPU SIMD AVX512 instructions */
 
 
 /**
-- 
2.5.5



[dpdk-dev] [PATCH 2/2] crypto/aesni_mb: add new option to select SIMD mode

2016-12-02 Thread Declan Doherty
Add new initialisation option to the aesni_mb_pmd to allow the user to specify
which set of SIMD functions to load from the AESNI Multi-Buffer Crypto for IPsec
library.

Signed-off-by: Declan Doherty 
---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 141 ++---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h |   7 +
 2 files changed, 129 insertions(+), 19 deletions(-)

diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index c400b17..70b1d20 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -594,17 +594,16 @@ aesni_mb_pmd_dequeue_burst(void *queue_pair, struct 
rte_crypto_op **ops,
return nb_dequeued;
 }
 
-
 static int cryptodev_aesni_mb_remove(const char *name);
 
 static int
 cryptodev_aesni_mb_create(const char *name,
-   struct rte_crypto_vdev_init_params *init_params)
+   struct rte_crypto_vdev_init_params *init_params,
+   struct aesni_mb_init_params *aesni_mb_init_params)
 {
struct rte_cryptodev *dev;
char crypto_dev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
struct aesni_mb_private *internals;
-   enum aesni_mb_vector_mode vector_mode;
 
/* Check CPU for support for AES instruction set */
if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AES)) {
@@ -612,18 +611,50 @@ cryptodev_aesni_mb_create(const char *name,
return -EFAULT;
}
 
-   /* Check CPU for supported vector instruction set */
-   if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
-   vector_mode = RTE_AESNI_MB_AVX512;
-   else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
-   vector_mode = RTE_AESNI_MB_AVX2;
-   else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
-   vector_mode = RTE_AESNI_MB_AVX;
-   else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
-   vector_mode = RTE_AESNI_MB_SSE;
-   else {
-   MB_LOG_ERR("Vector instructions are not supported by CPU");
-   return -EFAULT;
+
+   switch(aesni_mb_init_params->mode) {
+   case RTE_AESNI_MB_AVX512:
+   if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) {
+   MB_LOG_ERR("specified instruction set AVX512 "
+   "not supported by CPU");
+   return -EFAULT;
+   }
+   break;
+   case RTE_AESNI_MB_AVX2:
+   if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2)) {
+   MB_LOG_ERR("specified instruction set AVX2 "
+   "not supported by CPU");
+   return -EFAULT;
+   }
+   break;
+   case RTE_AESNI_MB_AVX:
+   if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX)) {
+   MB_LOG_ERR("specified instruction set AVX "
+   "not supported by CPU");
+   return -EFAULT;
+   }
+   break;
+   case RTE_AESNI_MB_SSE:
+   if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1)) {
+   MB_LOG_ERR("specified instruction set SSE "
+   "not supported by CPU");
+   return -EFAULT;
+   }
+   break;
+   default:
+   /* Check CPU for supported vector instruction set */
+   if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+   aesni_mb_init_params->mode = RTE_AESNI_MB_AVX512;
+   else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+   aesni_mb_init_params->mode = RTE_AESNI_MB_AVX2;
+   else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
+   aesni_mb_init_params->mode = RTE_AESNI_MB_AVX;
+   else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
+   aesni_mb_init_params->mode = RTE_AESNI_MB_SSE;
+   else {
+   MB_LOG_ERR("Vector instructions are not supported by 
CPU");
+   return -EFAULT;
+   }
}
 
/* create a unique device name */
@@ -652,7 +683,7 @@ cryptodev_aesni_mb_create(const char *name,
RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
RTE_CRYPTODEV_FF_CPU_AESNI;
 
-   switch (vector_mode) {
+   switch (aesni_mb_init_params->mode) {
case RTE_AESNI_MB_SSE:
dev->feature_flags |= RTE_CRYPTODEV_FF_CPU_SSE;
break;
@@ -672,7 +703,7 @@ cryptodev_aesni_mb_create(const char *name,
/* Set vector instructions mode supported */
internals = dev->data->dev_private;
 
-   internals->vector_mo

Re: [dpdk-dev] [PATCH 2/2] crypto/aesni_mb: add new option to select SIMD mode

2016-12-02 Thread Declan Doherty

On 02/12/16 10:37, Thomas Monjalon wrote:

2016-12-02 09:46, Declan Doherty:

Add new initialisation option to the aesni_mb_pmd to allow the user to specify
which set of SIMD functions to load from the AESNI Multi-Buffer Crypto for IPsec
library.


Why let user choose? Isn't the most recent the better?

This PMD and other software crypto PMDs could (should?) override the CFLAGS
like rte_acl do, in order to be able to use recent SIMD functions even if it
was globally disabled by the compilation target.
See my comment in the rte_memset thread.




In general yes, I was mainly using this to allow quick performance 
comparisons between different platforms and different instruction sets 
on the same platform without recompilation, but I admit that this is 
probably not a normal end user use case.


I'll look at the CFLAGS options you mention and address in a V2.


Re: [dpdk-dev] [PATCH] Scheduler: add driver for scheduler crypto pmd

2016-12-02 Thread Declan Doherty

On 02/12/16 14:57, Bruce Richardson wrote:

On Fri, Dec 02, 2016 at 03:31:24PM +0100, Thomas Monjalon wrote:

2016-12-02 14:15, Fan Zhang:

This patch provides the initial implementation of the scheduler poll mode
driver using DPDK cryptodev framework.

Scheduler PMD is used to schedule and enqueue the crypto ops to the
hardware and/or software crypto devices attached to it (slaves). The
dequeue operation from the slave(s), and the possible dequeued crypto op
reordering, are then carried out by the scheduler.

The scheduler PMD can be used to fill the throughput gap between the
physical core and the existing cryptodevs to increase the overall
performance. For example, if a physical core has higher crypto op
processing rate than a cryptodev, the scheduler PMD can be introduced to
attach more than one cryptodevs.

This initial implementation is limited to supporting the following
scheduling modes:

- CRYPTO_SCHED_SW_ROUND_ROBIN_MODE (round robin amongst attached software
slave cryptodevs, to set this mode, the scheduler should have been
attached 1 or more software cryptodevs.

- CRYPTO_SCHED_HW_ROUND_ROBIN_MODE (round robin amongst attached hardware
slave cryptodevs (QAT), to set this mode, the scheduler should have
been attached 1 or more QATs.


Could it be implemented on top of the eventdev API?


Not really. The eventdev API is for different types of scheduling
between multiple sources that are all polling for packets, compared to
this, which is more analgous - as I understand it - to the bonding PMD
for ethdev.

To make something like this work with an eventdev API you would need to
use one of the following models:
* have worker cores for offloading packets to the different crypto
  blocks pulling from the eventdev APIs. This would make it difficult to
  do any "smart" scheduling of crypto operations between the blocks,
  e.g. that one crypto instance may be better at certain types of
  operations than another.
* move the logic in this driver into an existing eventdev instance,
  which uses the eventdev api rather than the crypto APIs and so has an
  extra level of "structure abstraction" that has to be worked though.
  It's just not really a good fit.

So for this workload, I believe the pseudo-cryptodev instance is the
best way to go.

/Bruce




As Bruce says this is much more analogous to the ethdev bonding driver, 
the main idea is to allow different crypto op scheduling mechanisms to 
be defined transparently to an application. This could be load-balancing 
across multiple hw crypto devices, or having a software crypto device to 
act as a backup device for a hw accelerator if it becomes 
oversubscribed. I think the main advantage of a crypto-scheduler 
approach means that the data path of the application doesn't need to 
have any knowledge that scheduling is happening at all, it is just using 
a different crypto device id, which is then manages the distribution of 
crypto work.





[dpdk-dev] [PATCH 0/6] link bonding

2014-08-19 Thread Declan Doherty
This patch set adds support for link status interrupt in the link bonding
pmd. It also contains some patches to tidy up the code structure and to
of the link bonding code and to fix bugs relating to transmission 
failures in the under lying slave pmd which could lead to leaked mbufs.  


Declan Doherty (6):
  bond: link status interrupt support
  bond: removing switch statement from rx burst method
  bond: fix naming inconsistency in tx_burst_round_robin
  bond: free mbufs if transmission fails in bonding tx_burst functions
  test app: adding support for generating variable sized packets
  testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist

 app/test-pmd/cmdline.c |2 +-
 app/test-pmd/testpmd.c |3 +-
 app/test-pmd/testpmd.h |2 +-
 app/test/packet_burst_generator.c  |   22 +--
 app/test/packet_burst_generator.h  |6 +-
 app/test/test_link_bonding.c   |  234 ++--
 lib/librte_pmd_bond/rte_eth_bond_api.c |4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  124 +++--
 8 files changed, 295 insertions(+), 102 deletions(-)



[dpdk-dev] [PATCH 1/6] bond: link status interrupt support

2014-08-19 Thread Declan Doherty
Adding support for lsc interrupt from bonded device to link
bonding library with supporting unit tests in the test application.

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   |  216 +++-
 lib/librte_pmd_bond/rte_eth_bond_api.c |4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |6 +
 3 files changed, 192 insertions(+), 34 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 5c1303e..02823b6 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -224,10 +225,15 @@ static struct rte_eth_txconf tx_conf_default = {
 };

 static int
-configure_ethdev(uint8_t port_id, uint8_t start)
+configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 {
int q_id;

+   if (en_isr)
+   default_pmd_conf.intr_conf.lsc = 1;
+   else
+   default_pmd_conf.intr_conf.lsc = 0;
+
if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
test_params->nb_tx_q, &default_pmd_conf) != 0) {
goto error;
@@ -312,7 +318,7 @@ test_setup(void)

printf("Created virtual ethdev %s\n", pmd_name);

-   retval = 
configure_ethdev(test_params->slave_port_ids[i], 1);
+   retval = 
configure_ethdev(test_params->slave_port_ids[i], 1, 0);
if (retval != 0) {
printf("Failed to configure virtual ethdev 
%s\n", pmd_name);
return -1;
@@ -341,7 +347,7 @@ test_create_bonded_device(void)
TEST_ASSERT(test_params->bonded_port_id >= 0,
"Failed to create bonded ethdev %s", 
BONDED_DEV_NAME);

-   
TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
+   
TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
"Failed to configure bonded ethdev %s", 
BONDED_DEV_NAME);
}

@@ -1078,12 +1084,12 @@ test_set_explicit_bonded_mac(void)


 static int
-initialize_bonded_device_with_slaves(uint8_t bonding_mode,
+initialize_bonded_device_with_slaves(uint8_t bonding_mode, uint8_t bond_en_isr,
uint8_t number_of_slaves, uint8_t enable_slave)
 {
/* configure bonded device */
-   TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
-   "Failed to configure bonding port (%d) in mode %d "
+   TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
+   bond_en_isr), "Failed to configure bonding port (%d) in 
mode %d "
"with (%d) slaves.", test_params->bonded_port_id, 
bonding_mode,
number_of_slaves);

@@ -1116,8 +1122,8 @@ test_adding_slave_after_bonded_device_started(void)
 {
int i;

-   if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 
0) !=
-   0)
+   if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 
4, 0)
+   != 0)
return -1;

/* Enabled slave devices */
@@ -1141,6 +1147,147 @@ test_adding_slave_after_bonded_device_started(void)
return remove_slaves_and_stop_bonded_device();
 }

+#define TEST_STATUS_INTERRUPT_SLAVE_COUNT  4
+#define TEST_LSC_WAIT_TIMEOUT_MS   500
+
+int test_lsc_interupt_count;
+
+static pthread_mutex_t mutex;
+static pthread_cond_t cvar;
+
+static void
+test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
+   enum rte_eth_event_type type  __rte_unused, void *param 
__rte_unused)
+{
+   pthread_mutex_lock(&mutex);
+   test_lsc_interupt_count++;
+
+   pthread_cond_signal(&cvar);
+   pthread_mutex_unlock(&mutex);
+}
+
+static inline int
+lsc_timeout(int wait_us)
+{
+   int retval = 0;
+
+   struct timespec ts;
+   struct timeval tp;
+
+   gettimeofday(&tp, NULL);
+
+   /* Convert from timeval to timespec */
+   ts.tv_sec  = tp.tv_sec;
+   ts.tv_nsec = tp.tv_usec * 1000;
+   ts.tv_nsec += wait_us * 1000;
+
+   pthread_mutex_lock(&mutex);
+   if (test_lsc_interupt_count < 1)
+   retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+
+   pthread_mutex_unlock(&mutex);
+
+   if (test_lsc_interupt_count  < 1)
+   return retval;
+
+   return 0;
+}
+
+static int
+test_status_interrupt(void)
+{
+   int slave_count;
+   uint8_t slaves[RTE_MAX_ETHPORTS];
+
+   pthread_mutex_init(&mutex, NULL);
+   pthread_cond_init(&cvar, NULL);
+
+   /* initialized bonding device with T slaves */
+   if (in

[dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method

2014-08-19 Thread Declan Doherty
Splitting rx burst function into seperate functions to avoid the need for 
a switch statement and also to match the structure of the tx burst functions.

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   62 ++--
 1 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index cd3eecf..683b146 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -59,33 +59,37 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, 
uint16_t nb_pkts)

internals = bd_rx_q->dev_private;

-   switch (internals->mode) {
-   case BONDING_MODE_ROUND_ROBIN:
-   case BONDING_MODE_BROADCAST:
-   case BONDING_MODE_BALANCE:
-   for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
-   /* Offset of pointer to *bufs increases as packets are 
received
-* from other slaves */
-   num_rx_slave = 
rte_eth_rx_burst(internals->active_slaves[i],
-   bd_rx_q->queue_id, bufs + num_rx_total, 
nb_pkts);
-   if (num_rx_slave) {
-   num_rx_total += num_rx_slave;
-   nb_pkts -= num_rx_slave;
-   }
+   for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
+   /* Offset of pointer to *bufs increases as packets are received
+* from other slaves */
+   num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
+   bd_rx_q->queue_id, bufs + num_rx_total, 
nb_pkts);
+   if (num_rx_slave) {
+   num_rx_total += num_rx_slave;
+   nb_pkts -= num_rx_slave;
}
-   break;
-   case BONDING_MODE_ACTIVE_BACKUP:
-   num_rx_slave = rte_eth_rx_burst(internals->current_primary_port,
-   bd_rx_q->queue_id, bufs, nb_pkts);
-   if (num_rx_slave)
-   num_rx_total = num_rx_slave;
-   break;
}
+
return num_rx_total;
 }

 static uint16_t
-bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
+bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
+   uint16_t nb_pkts)
+{
+   struct bond_dev_private *internals;
+
+   /* Cast to structure, containing bonded device's port id and queue id */
+   struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
+
+   internals = bd_rx_q->dev_private;
+
+   return rte_eth_rx_burst(internals->current_primary_port,
+   bd_rx_q->queue_id, bufs, nb_pkts);
+}
+
+static uint16_t
+bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts)
 {
struct bond_dev_private *dev_private;
@@ -134,7 +138,7 @@ bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf 
**bufs,
 }

 static uint16_t
-bond_ethdev_tx_active_backup(void *queue,
+bond_ethdev_tx_burst_active_backup(void *queue,
struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
struct bond_dev_private *internals;
@@ -270,7 +274,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t 
slave_count, uint8_t policy)
 }

 static uint16_t
-bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
+   uint16_t nb_pkts)
 {
struct bond_dev_private *internals;
struct bond_tx_queue *bd_tx_q;
@@ -480,22 +485,25 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int 
mode)

switch (mode) {
case BONDING_MODE_ROUND_ROBIN:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
case BONDING_MODE_ACTIVE_BACKUP:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
break;
case BONDING_MODE_BALANCE:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_balance;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
case BONDING_MODE_BROADCAST:
eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
default:
return -1;
}

-   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
internals->mode = mode;

return 0;
-- 
1.7.0.7



[dpdk-dev] [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin

2014-08-19 Thread Declan Doherty
Renaming struct bond_dev_pritvate *dev_private to internals to match convention 
used in other pmds

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 683b146..70123fc 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -92,7 +92,7 @@ static uint16_t
 bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts)
 {
-   struct bond_dev_private *dev_private;
+   struct bond_dev_private *internals;
struct bond_tx_queue *bd_tx_q;

struct rte_mbuf *slave_bufs[RTE_MAX_ETHPORTS][nb_pkts];
@@ -107,13 +107,13 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct 
rte_mbuf **bufs,
int i, cs_idx = 0;

bd_tx_q = (struct bond_tx_queue *)queue;
-   dev_private = bd_tx_q->dev_private;
+   internals = bd_tx_q->dev_private;

/* Copy slave list to protect against slave up/down changes during tx
 * bursting */
-   num_of_slaves = dev_private->active_slave_count;
-   memcpy(slaves, dev_private->active_slaves,
-   sizeof(dev_private->active_slaves[0]) * num_of_slaves);
+   num_of_slaves = internals->active_slave_count;
+   memcpy(slaves, internals->active_slaves,
+   sizeof(internals->active_slaves[0]) * num_of_slaves);

if (num_of_slaves < 1)
return num_tx_total;
-- 
1.7.0.7



[dpdk-dev] [PATCH 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions

2014-08-19 Thread Declan Doherty
Fixing a number of corner cases that if transmission failed on slave devices 
then this
could lead to leaked mbufs 


Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   |4 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   46 +---
 2 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 02823b6..3c265ee 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -3415,7 +3415,7 @@ test_broadcast_tx_burst(void)
/* Send burst on bonded port */
nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
burst_size);
-   if (nb_tx != burst_size * test_params->bonded_slave_count) {
+   if (nb_tx != burst_size) {
printf("Bonded Port (%d) rx burst failed, packets transmitted 
value (%u) not as expected (%d)\n",
test_params->bonded_port_id,
nb_tx, burst_size);
@@ -3770,7 +3770,7 @@ 
test_broadcast_verify_slave_link_status_change_behaviour(void)
}

if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[0][0],
-   burst_size) != (burst_size * slave_count)) {
+   burst_size) != burst_size) {
printf("rte_eth_tx_burst failed\n");
return -1;
}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 70123fc..ae9726e 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -101,7 +101,7 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct 
rte_mbuf **bufs,
uint8_t num_of_slaves;
uint8_t slaves[RTE_MAX_ETHPORTS];

-   uint16_t num_tx_total = 0;
+   uint16_t num_tx_total = 0, num_tx_slave;

static int slave_idx = 0;
int i, cs_idx = 0;
@@ -130,9 +130,17 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct 
rte_mbuf **bufs,

/* Send packet burst on each slave device */
for (i = 0; i < num_of_slaves; i++)
-   if (slave_nb_pkts[i] > 0)
-   num_tx_total += rte_eth_tx_burst(slaves[i],
+   if (slave_nb_pkts[i] > 0) {
+   num_tx_slave = rte_eth_tx_burst(slaves[i],
bd_tx_q->queue_id, slave_bufs[i], 
slave_nb_pkts[i]);
+   num_tx_total += num_tx_slave;
+
+   /* if tx burst fails, free unsent mbufs */
+   while (unlikely(num_tx_slave < slave_nb_pkts[i])) {
+   rte_pktmbuf_free(slave_bufs[i][num_tx_slave]);
+   num_tx_slave++;
+   }
+   }

return num_tx_total;
 }
@@ -283,7 +291,7 @@ bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf 
**bufs,
uint8_t num_of_slaves;
uint8_t slaves[RTE_MAX_ETHPORTS];

-   uint16_t num_tx_total = 0;
+   uint16_t num_tx_total = 0, num_tx_slave = 0;

int i, op_slave_id;

@@ -315,11 +323,19 @@ bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf 
**bufs,
/* Send packet burst on each slave device */
for (i = 0; i < num_of_slaves; i++) {
if (slave_nb_pkts[i] > 0) {
-   num_tx_total += rte_eth_tx_burst(slaves[i], 
bd_tx_q->queue_id,
+   num_tx_slave = rte_eth_tx_burst(slaves[i], 
bd_tx_q->queue_id,
slave_bufs[i], slave_nb_pkts[i]);
+   num_tx_total += num_tx_slave;
+
+   /* if tx burst fails, free unsent mbufs */
+   while (unlikely(num_tx_slave < slave_nb_pkts[i])) {
+   rte_pktmbuf_free(slave_bufs[i][num_tx_slave]);
+   num_tx_slave++;
+   }
}
}

+
return num_tx_total;
 }

@@ -333,7 +349,7 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf 
**bufs,
uint8_t num_of_slaves;
uint8_t slaves[RTE_MAX_ETHPORTS];

-   uint16_t num_tx_total = 0;
+   uint16_t num_tx_slave = 0, max_tx_pkts = 0;

int i;

@@ -354,11 +370,21 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct 
rte_mbuf **bufs,
rte_mbuf_refcnt_update(bufs[i], num_of_slaves - 1);

/* Transmit burst on each active slave */
-   for (i = 0; i < num_of_slaves; i++)
-   num_tx_total += rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
-   bufs, nb_pkts);
+   for (i = 0; i < num_of_slaves; i++) {
+   num_tx_slave = rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
+   bufs, nb_pkts);

-   return num_tx_total;
+

[dpdk-dev] [PATCH 5/6] test app: adding support for generating variable sized packets

2014-08-19 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test/packet_burst_generator.c |   22 +++---
 app/test/packet_burst_generator.h |6 +-
 app/test/test_link_bonding.c  |   14 +-
 3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index 5d539f1..9ce6472 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -190,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t 
src_addr,
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */

-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
-   TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t  tx_pkt_nb_segs = 1;

 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+   uint8_t pkt_len, uint8_t nb_pkt_segs)
 {
int i, nb_pkt = 0;
size_t eth_hdr_size;
@@ -220,9 +212,9 @@ nomore_mbuf:
break;
}

-   pkt->pkt.data_len = tx_pkt_seg_lengths[0];
+   pkt->pkt.data_len = pkt_len;
pkt_seg = pkt;
-   for (i = 1; i < tx_pkt_nb_segs; i++) {
+   for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->pkt.next = rte_pktmbuf_alloc(mp);
if (pkt_seg->pkt.next == NULL) {
pkt->pkt.nb_segs = i;
@@ -230,7 +222,7 @@ nomore_mbuf:
goto nomore_mbuf;
}
pkt_seg = pkt_seg->pkt.next;
-   pkt_seg->pkt.data_len = tx_pkt_seg_lengths[i];
+   pkt_seg->pkt.data_len = pkt_len;
}
pkt_seg->pkt.next = NULL; /* Last segment of packet. */

@@ -258,8 +250,8 @@ nomore_mbuf:
 * Complete first mbuf of packet and append it to the
 * burst of packets to be transmitted.
 */
-   pkt->pkt.nb_segs = tx_pkt_nb_segs;
-   pkt->pkt.pkt_len = tx_pkt_length;
+   pkt->pkt.nb_segs = nb_pkt_segs;
+   pkt->pkt.pkt_len = pkt_len;
pkt->pkt.vlan_macip.f.l2_len = eth_hdr_size;

if (ipv4) {
diff --git a/app/test/packet_burst_generator.h 
b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -47,6 +47,9 @@ extern "C" {
 #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
((c & 0xff) << 8) | (d & 0xff))

+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
+

 void
 initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
@@ -68,7 +71,8 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t 
src_addr,
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+   uint8_t pkt_len, uint8_t nb_pkt_segs);

 #ifdef __cplusplus
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 3c265ee..d31c553 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -1338,7 +1338,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, 
uint16_t burst_size,
/* Generate burst of packets to transmit */
generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
pkts_burst, test_params->pkt_eth_hdr, vlan, ip_hdr, 
ipv4,
-   test_params->pkt_udp_hdr, burst_size);
+   test_params->pkt_udp_hdr, burst_size, 
PACKET_BURST_GEN_PKT_LEN_128,
+   1);
if (generated_burst_size != burst_size) {
printf("Failed to generate packet burst");
return -1;
@@ -1927,7 +1928,7 @@ test_activebackup_tx_burst(void)
/* Generate a burst of packets to transmit */
generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
pkts_burst, test_params->pkt_eth_hdr, 0, 
test_params->pkt_ipv4_hdr,
-   1, test_params->pkt_udp_hdr, burst_size);
+   1, test_params->pkt_udp_hd

[dpdk-dev] [PATCH 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist

2014-08-19 Thread Declan Doherty
Fix for "show port info" command which displays the incorrect "connected to 
socket"
when port is a link bonding port. 

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c |2 +-
 app/test-pmd/testpmd.c |3 ++-
 app/test-pmd/testpmd.h |2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 345be11..8cc4937 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3515,7 +3515,7 @@ static void cmd_create_bonded_device_parsed(void 
*parsed_result,

/* Update number of ports */
nb_ports = rte_eth_dev_count();
-   reconfig(port_id);
+   reconfig(port_id, res->socket);
rte_eth_promiscuous_enable(port_id);
}

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e8a4b45..58ed03c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -627,7 +627,7 @@ init_config(void)


 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
struct rte_port *port;

@@ -646,6 +646,7 @@ reconfig(portid_t new_port_id)
/* set flag to initialize port/queue */
port->need_reconfig = 1;
port->need_reconfig_queues = 1;
+   port->socket_id = socket_id;

init_port_config();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index ac86bfe..207eacb 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -455,7 +455,7 @@ void fwd_config_display(void);
 void rxtx_config_display(void);
 void fwd_config_setup(void);
 void set_def_fwd_config(void);
-void reconfig(portid_t new_port_id);
+void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);

 void port_mtu_set(portid_t port_id, uint16_t mtu);
-- 
1.7.0.7



[dpdk-dev] [PATCH] doc: link bonding related updates to programmers guide

2014-12-01 Thread Declan Doherty
Adding details for link status interrupts and link status polling.
Adding details for mode 4 / mode 5
Tidying up rst document to conform to 80 character line limit
Adding diagrams to explain bonding modes

Signed-off-by: Declan Doherty 
---
 doc/guides/prog_guide/img/bond-mode-0.svg  | 638 +
 doc/guides/prog_guide/img/bond-mode-1.svg  | 724 +++
 doc/guides/prog_guide/img/bond-mode-2.svg  | 702 ++
 doc/guides/prog_guide/img/bond-mode-3.svg  | 702 ++
 doc/guides/prog_guide/img/bond-mode-4.svg  | 784 +
 doc/guides/prog_guide/img/bond-mode-5.svg  | 642 +
 doc/guides/prog_guide/img/bond-overview.svg| 121 
 .../prog_guide/link_bonding_poll_mode_drv_lib.rst  | 366 +++---
 8 files changed, 4579 insertions(+), 100 deletions(-)
 create mode 100644 doc/guides/prog_guide/img/bond-mode-0.svg
 create mode 100644 doc/guides/prog_guide/img/bond-mode-1.svg
 create mode 100644 doc/guides/prog_guide/img/bond-mode-2.svg
 create mode 100644 doc/guides/prog_guide/img/bond-mode-3.svg
 create mode 100644 doc/guides/prog_guide/img/bond-mode-4.svg
 create mode 100644 doc/guides/prog_guide/img/bond-mode-5.svg
 create mode 100644 doc/guides/prog_guide/img/bond-overview.svg

diff --git a/doc/guides/prog_guide/img/bond-mode-0.svg 
b/doc/guides/prog_guide/img/bond-mode-0.svg
new file mode 100644
index 000..eff0edb
--- /dev/null
+++ b/doc/guides/prog_guide/img/bond-mode-0.svg
@@ -0,0 +1,638 @@
+
+
+
+http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="332.15576"
+   height="334.46951"
+   viewBox="0 0 265.725 267.57566"
+   xml:space="preserve"
+   color-interpolation-filters="sRGB"
+   class="st16"
+   id="svg3406"
+   version="1.1"
+   inkscape:version="0.48.5 r10040"
+   sodipodi:docname="bond-mode-0.svg"
+   
style="font-size:12px;fill:none;stroke-linecap:square;stroke-miterlimit:3;overflow:visible">image/svg+xmlhttp://purl.org/dc/dcmitype/StillImage"; 
/>
+   .st1 {visibility:visible}
+   .st2 
{fill:#5b9bd5;fill-opacity:0.25;filter:url(#filter_2);stroke:#5b9bd5;stroke-opacity:0.25}
+   .st3 {fill:#4f87bb;stroke:#40709c;stroke-width:0.75}
+   .st4 {fill:#fe;font-family:Calibri;font-size:0.86em}
+   .st5 {fill:url(#grad0-11);stroke:#4f87bb;stroke-width:0.75}
+   .st6 {fill:#4f87bb;font-family:Calibri;font-size:0.86em}
+   .st7 
{fill:#759fcc;fill-opacity:0.25;filter:url(#filter_2);stroke:#759fcc;stroke-opacity:0.25}
+   .st8 {fill:#668bb3;stroke:#547395;stroke-width:0.75}
+   .st9 
{fill:#5b9bd5;fill-opacity:0.22;filter:url(#filter_2);stroke:#5b9bd5;stroke-opacity:0.22}
+   .st10 {fill:#5b9bd5;stroke:#c7c8c8;stroke-width:0.25}
+   .st11 
{fill:#759fcc;fill-opacity:0.22;filter:url(#filter_2);stroke:#759fcc;stroke-opacity:0.22}
+   .st12 {fill:#759fcc;stroke:#c7c8c8;stroke-width:0.25}
+   .st13 {fill:url(#grad0-40);stroke:#a6b6cd;stroke-width:0.75}
+   .st14 
{fill:#70ad47;fill-opacity:0.25;filter:url(#filter_2);stroke:#70ad47;stroke-opacity:0.25}
+   .st15 {fill:#61973d;stroke:#507e31;stroke-width:0.75}
+   .st16 
{fill:none;fill-rule:evenodd;font-size:12px;overflow:visible;stroke-linecap:square;stroke-miterlimit:3}
+   Page-4Rectangle.7User ApplicationUser Application
+Sheet.2Rectangle.38DPDKDPDK
+Rectangle.16bonded ethdevbonded ethdev
+Rectangle.11ethdev portethdev port
+Rectangle.14ethdev portethdev port
+Rectangle.15ethdev portethdev port
+Simple Double Arrow.14Simple ArrowSimple Arrow.37Simple Arrow.38Simple Arrow.39Square.11411
+Square.11522
+Square.11633
+Square.11744
+Square.11855
+Square.12011
+Square.12122
+Square.12233
+Square.12344
+Square.12455
+
\ No newline at end of file
diff --git a/doc/guides/prog_guide/img/bond-mode-1.svg 
b/doc/guides/prog_guide/img/bond-mode-1.svg
new file mode 100644
index 000..c177e85
--- /dev/null
+++ b/doc/guides/prog_guide/img/bond-mode-1.svg
@@ -0,0 +1,724 @@
+
+
+
+http://schemas.microsoft.com/visio/2003/SVGExtensions/";
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg&qu

[dpdk-dev] [PATCH] bond: fix for mac assignment to slaves device

2014-12-05 Thread Declan Doherty
Adding call to mac_address_slaves_update from the lsc handler when the
first slave become active to propagate any mac changes made while
devices are inactive

Changed removing slave logic to use memmove instead of memcpy to move
data within the same array, as this was corrupting the slave array.

Adding unit test to cover failing assignment scenarios

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   | 192 -
 app/test/virtual_pmd.c |   1 -
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  14 ++-
 3 files changed, 199 insertions(+), 8 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index f62c490..4523de6 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -454,7 +454,7 @@ test_remove_slave_from_bonded_device(void)

mac_addr = (struct ether_addr *)slave_mac;
mac_addr->addr_bytes[ETHER_ADDR_LEN-1] =
-   
test_params->slave_port_ids[test_params->bonded_slave_count-1];
+   test_params->bonded_slave_count-1;

rte_eth_macaddr_get(

test_params->slave_port_ids[test_params->bonded_slave_count-1],
@@ -810,8 +810,7 @@ test_set_primary_slave(void)
test_params->bonded_port_id);

expected_mac_addr = (struct ether_addr *)&slave_mac;
-   expected_mac_addr->addr_bytes[ETHER_ADDR_LEN-1] =
-   test_params->slave_port_ids[i];
+   expected_mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;

/* Check primary slave MAC */
rte_eth_macaddr_get(test_params->slave_port_ids[i], 
&read_mac_addr);
@@ -928,6 +927,192 @@ test_set_explicit_bonded_mac(void)
return 0;
 }

+#define BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT (3)
+
+static int
+test_set_bonded_port_initialization_mac_assignment(void)
+{
+   int i, slave_count, bonded_port_id;
+
+   uint8_t slaves[RTE_MAX_ETHPORTS];
+   int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT];
+
+   struct ether_addr slave_mac_addr, bonded_mac_addr, read_mac_addr;
+
+   /* Initialize default values for MAC addresses */
+   memcpy(&slave_mac_addr, slave_mac, sizeof(struct ether_addr));
+   memcpy(&bonded_mac_addr, slave_mac, sizeof(struct ether_addr));
+
+   /*
+* 1. a - Create / configure  bonded / slave ethdevs
+*/
+   bonded_port_id = rte_eth_bond_create("ethdev_bond_mac_ass_test",
+   BONDING_MODE_ACTIVE_BACKUP, rte_socket_id());
+   TEST_ASSERT(bonded_port_id > 0, "failed to create bonded device");
+
+   TEST_ASSERT_SUCCESS(configure_ethdev(bonded_port_id, 0, 0),
+   "Failed to configure bonded ethdev");
+
+   for (i = 0; i < BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT; i++) {
+   char pmd_name[RTE_ETH_NAME_MAX_LEN];
+
+   slave_mac_addr.addr_bytes[ETHER_ADDR_LEN-1] = i + 100;
+
+   snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_slave_%d", i);
+
+   slave_port_ids[i] = virtual_ethdev_create(pmd_name,
+   &slave_mac_addr, rte_socket_id(), 1);
+
+   TEST_ASSERT(slave_port_ids[i] >= 0,
+   "Failed to create slave ethdev %s", pmd_name);
+
+   TEST_ASSERT_SUCCESS(configure_ethdev(slave_port_ids[i], 1, 0),
+   "Failed to configure virtual ethdev %s",
+   pmd_name);
+   }
+
+
+   /*
+* 2. Add slave ethdevs to bonded device
+*/
+   for (i = 0; i < BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT; i++) {
+   TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(bonded_port_id,
+   slave_port_ids[i]),
+   "Failed to add slave (%d) to bonded port (%d).",
+   slave_port_ids[i], bonded_port_id);
+   }
+
+   slave_count = rte_eth_bond_slaves_get(bonded_port_id, slaves,
+   RTE_MAX_ETHPORTS);
+   TEST_ASSERT_EQUAL(BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT, slave_count,
+   "Number of slaves (%d) is not as expected (%d)",
+   slave_count, BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT);
+
+
+   /*
+* 3. Set explicit MAC address on bonded ethdev
+*/
+   bonded_mac_addr.addr_bytes[ETHER_ADDR_LEN-2] = 0xFF;
+   bonded_mac_addr.addr_bytes[ETHER_ADDR_LEN-1] = 0xAA;
+
+   TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+   bonded_port_id, &bonded_mac_addr),
+   "Failed to set MAC address on bonded port (%d)",
+   bonded_port_id);
+
+
+   /* 4. a - Start bonded ethd

[dpdk-dev] [PATCH v2] bond: fix for mac assignment to slaves device

2014-12-08 Thread Declan Doherty
-V2:
Tidies up the slave_remove function as per Pawel's comments.

Adding call to mac_address_slaves_update from the lsc handler when the
first slave become active to propagate any mac changes made while
devices are inactive

Changed removing slave logic to use memmove instead of memcpy to move
data within the same array, as this was corrupting the slave array.

Adding unit test to cover failing assignment scenarios

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   | 192 -
 app/test/virtual_pmd.c |   1 -
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  19 ++--
 3 files changed, 200 insertions(+), 12 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index f62c490..4523de6 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -454,7 +454,7 @@ test_remove_slave_from_bonded_device(void)

mac_addr = (struct ether_addr *)slave_mac;
mac_addr->addr_bytes[ETHER_ADDR_LEN-1] =
-   
test_params->slave_port_ids[test_params->bonded_slave_count-1];
+   test_params->bonded_slave_count-1;

rte_eth_macaddr_get(

test_params->slave_port_ids[test_params->bonded_slave_count-1],
@@ -810,8 +810,7 @@ test_set_primary_slave(void)
test_params->bonded_port_id);

expected_mac_addr = (struct ether_addr *)&slave_mac;
-   expected_mac_addr->addr_bytes[ETHER_ADDR_LEN-1] =
-   test_params->slave_port_ids[i];
+   expected_mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;

/* Check primary slave MAC */
rte_eth_macaddr_get(test_params->slave_port_ids[i], 
&read_mac_addr);
@@ -928,6 +927,192 @@ test_set_explicit_bonded_mac(void)
return 0;
 }

+#define BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT (3)
+
+static int
+test_set_bonded_port_initialization_mac_assignment(void)
+{
+   int i, slave_count, bonded_port_id;
+
+   uint8_t slaves[RTE_MAX_ETHPORTS];
+   int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT];
+
+   struct ether_addr slave_mac_addr, bonded_mac_addr, read_mac_addr;
+
+   /* Initialize default values for MAC addresses */
+   memcpy(&slave_mac_addr, slave_mac, sizeof(struct ether_addr));
+   memcpy(&bonded_mac_addr, slave_mac, sizeof(struct ether_addr));
+
+   /*
+* 1. a - Create / configure  bonded / slave ethdevs
+*/
+   bonded_port_id = rte_eth_bond_create("ethdev_bond_mac_ass_test",
+   BONDING_MODE_ACTIVE_BACKUP, rte_socket_id());
+   TEST_ASSERT(bonded_port_id > 0, "failed to create bonded device");
+
+   TEST_ASSERT_SUCCESS(configure_ethdev(bonded_port_id, 0, 0),
+   "Failed to configure bonded ethdev");
+
+   for (i = 0; i < BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT; i++) {
+   char pmd_name[RTE_ETH_NAME_MAX_LEN];
+
+   slave_mac_addr.addr_bytes[ETHER_ADDR_LEN-1] = i + 100;
+
+   snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_slave_%d", i);
+
+   slave_port_ids[i] = virtual_ethdev_create(pmd_name,
+   &slave_mac_addr, rte_socket_id(), 1);
+
+   TEST_ASSERT(slave_port_ids[i] >= 0,
+   "Failed to create slave ethdev %s", pmd_name);
+
+   TEST_ASSERT_SUCCESS(configure_ethdev(slave_port_ids[i], 1, 0),
+   "Failed to configure virtual ethdev %s",
+   pmd_name);
+   }
+
+
+   /*
+* 2. Add slave ethdevs to bonded device
+*/
+   for (i = 0; i < BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT; i++) {
+   TEST_ASSERT_SUCCESS(rte_eth_bond_slave_add(bonded_port_id,
+   slave_port_ids[i]),
+   "Failed to add slave (%d) to bonded port (%d).",
+   slave_port_ids[i], bonded_port_id);
+   }
+
+   slave_count = rte_eth_bond_slaves_get(bonded_port_id, slaves,
+   RTE_MAX_ETHPORTS);
+   TEST_ASSERT_EQUAL(BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT, slave_count,
+   "Number of slaves (%d) is not as expected (%d)",
+   slave_count, BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT);
+
+
+   /*
+* 3. Set explicit MAC address on bonded ethdev
+*/
+   bonded_mac_addr.addr_bytes[ETHER_ADDR_LEN-2] = 0xFF;
+   bonded_mac_addr.addr_bytes[ETHER_ADDR_LEN-1] = 0xAA;
+
+   TEST_ASSERT_SUCCESS(rte_eth_bond_mac_address_set(
+   bonded_port_id, &bonded_mac_addr),
+   "Failed to set MAC address on bonded port (%d)",
+  

[dpdk-dev] [PATCH] doc: add license header to link bonding diagrams

2014-12-08 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 doc/guides/prog_guide/img/bond-mode-0.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-1.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-2.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-3.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-4.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-5.svg   | 34 +
 doc/guides/prog_guide/img/bond-overview.svg | 34 +
 7 files changed, 238 insertions(+)

diff --git a/doc/guides/prog_guide/img/bond-mode-0.svg 
b/doc/guides/prog_guide/img/bond-mode-0.svg
index eff0edb..e9742c7 100644
--- a/doc/guides/prog_guide/img/bond-mode-0.svg
+++ b/doc/guides/prog_guide/img/bond-mode-0.svg
@@ -1,4 +1,38 @@
 
+
 

 
+
 

 
+
 

 
+
 

 
+
 

 
+
 

 
+
 http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>
 
 http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:ev="http://www.w3.org/2001/xml-events";
-- 
1.7.12.2



[dpdk-dev] [PATCH] bond: static analysis issues fix

2014-12-12 Thread Declan Doherty
Fixes for link bonding library identified by static analysis tool

- Overflow check for active_slaves array in activate_slave function
- Allocation check of pci_id_table in rte_eth_bond_create
- Use of eth_dev pointer in mac_address_get/set before NULL check

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_api.c | 12 
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  8 
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c 
b/lib/librte_pmd_bond/rte_eth_bond_api.c
index ef5ddf4..9cb1c1f 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -115,8 +115,11 @@ activate_slave(struct rte_eth_dev *eth_dev, uint8_t 
port_id)
if (internals->mode == BONDING_MODE_8023AD)
bond_mode_8023ad_activate_slave(eth_dev, port_id);

-   internals->active_slaves[internals->active_slave_count] = port_id;
-   internals->active_slave_count++;
+   if (internals->active_slave_count <
+   RTE_DIM(internals->active_slaves) - 1) {
+   internals->active_slaves[internals->active_slave_count] = 
port_id;
+   internals->active_slave_count++;
+   }
 }

 void
@@ -144,7 +147,8 @@ deactivate_slave(struct rte_eth_dev *eth_dev, uint8_t 
port_id)
sizeof(internals->active_slaves[0]));
}

-   internals->active_slave_count = active_count;
+   internals->active_slave_count = active_count < RTE_MAX_ETHPORTS ?
+   active_count : RTE_MAX_ETHPORTS - 1;

if (eth_dev->data->dev_started && internals->mode == 
BONDING_MODE_8023AD)
bond_mode_8023ad_start(eth_dev);
@@ -210,7 +214,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
goto err;
}
pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, 
socket_id);
-   if (pci_drv == NULL) {
+   if (pci_id_table == NULL) {
RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
goto err;
}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 3db473b..bb4a537 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -764,8 +764,6 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct 
ether_addr *dst_mac_addr)
 {
struct ether_addr *mac_addr;

-   mac_addr = eth_dev->data->mac_addrs;
-
if (eth_dev == NULL) {
RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", 
__func__);
return -1;
@@ -776,6 +774,8 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct 
ether_addr *dst_mac_addr)
return -1;
}

+   mac_addr = eth_dev->data->mac_addrs;
+
ether_addr_copy(mac_addr, dst_mac_addr);
return 0;
 }
@@ -785,8 +785,6 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct 
ether_addr *new_mac_addr)
 {
struct ether_addr *mac_addr;

-   mac_addr = eth_dev->data->mac_addrs;
-
if (eth_dev == NULL) {
RTE_BOND_LOG(ERR, "NULL pointer eth_dev specified");
return -1;
@@ -797,6 +795,8 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct 
ether_addr *new_mac_addr)
return -1;
}

+   mac_addr = eth_dev->data->mac_addrs;
+
/* If new MAC is different to current MAC then update */
if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
-- 
1.7.12.2



[dpdk-dev] [PATCH v2] bond: static analysis issues fix

2014-12-15 Thread Declan Doherty
-v2:
Incorporates Pawel's comments regarding assertion's check on activate_slave 
array indexing

Fixes for link bonding library identified by static analysis tool

- Overflow assert for active_slaves array in activate_slave function
- Allocation check of pci_id_table in rte_eth_bond_create
- Use of eth_dev pointer in mac_address_get/set before NULL check

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_api.c | 7 ++-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 8 
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c 
b/lib/librte_pmd_bond/rte_eth_bond_api.c
index ef5ddf4..87a6a23 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -115,8 +115,12 @@ activate_slave(struct rte_eth_dev *eth_dev, uint8_t 
port_id)
if (internals->mode == BONDING_MODE_8023AD)
bond_mode_8023ad_activate_slave(eth_dev, port_id);

+   RTE_VERIFY(internals->active_slave_count <
+   (RTE_DIM(internals->active_slaves) - 1));
+
internals->active_slaves[internals->active_slave_count] = port_id;
internals->active_slave_count++;
+
 }

 void
@@ -144,6 +148,7 @@ deactivate_slave(struct rte_eth_dev *eth_dev, uint8_t 
port_id)
sizeof(internals->active_slaves[0]));
}

+   RTE_VERIFY(active_count < RTE_DIM(internals->active_slaves));
internals->active_slave_count = active_count;

if (eth_dev->data->dev_started && internals->mode == 
BONDING_MODE_8023AD)
@@ -210,7 +215,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
goto err;
}
pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, 
socket_id);
-   if (pci_drv == NULL) {
+   if (pci_id_table == NULL) {
RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
goto err;
}
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 3db473b..bb4a537 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -764,8 +764,6 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct 
ether_addr *dst_mac_addr)
 {
struct ether_addr *mac_addr;

-   mac_addr = eth_dev->data->mac_addrs;
-
if (eth_dev == NULL) {
RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", 
__func__);
return -1;
@@ -776,6 +774,8 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct 
ether_addr *dst_mac_addr)
return -1;
}

+   mac_addr = eth_dev->data->mac_addrs;
+
ether_addr_copy(mac_addr, dst_mac_addr);
return 0;
 }
@@ -785,8 +785,6 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct 
ether_addr *new_mac_addr)
 {
struct ether_addr *mac_addr;

-   mac_addr = eth_dev->data->mac_addrs;
-
if (eth_dev == NULL) {
RTE_BOND_LOG(ERR, "NULL pointer eth_dev specified");
return -1;
@@ -797,6 +795,8 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct 
ether_addr *new_mac_addr)
return -1;
}

+   mac_addr = eth_dev->data->mac_addrs;
+
/* If new MAC is different to current MAC then update */
if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
-- 
1.7.12.2



[dpdk-dev] [PATCH] bond: vlan flags misinterpreted in xmit_slave_hash function

2014-12-16 Thread Declan Doherty
- Split transmit hashing function into separate functions to reduce branching
  and to make code clearer.
- Add IPv4 IHL parameters to rte_ip.h
- Fixed VLAN tag support in hashing functions and add support for TCP
  in layer 4 header hashing.
- Fixed incorrect flag set in test application packet generator.

Signed-off-by: Declan Doherty 
---
 app/test/packet_burst_generator.c  |   2 +-
 lib/librte_net/rte_ip.h|   2 +
 lib/librte_pmd_bond/rte_eth_bond_api.c |   8 ++
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 161 -
 lib/librte_pmd_bond/rte_eth_bond_private.h |  15 +++
 5 files changed, 115 insertions(+), 73 deletions(-)

diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index b2824dc..4a89663 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -97,7 +97,7 @@ initialize_eth_header(struct ether_hdr *eth_hdr, struct 
ether_addr *src_mac,
vhdr->eth_proto =  rte_cpu_to_be_16(ETHER_TYPE_IPv4);
vhdr->vlan_tci = van_id;
} else {
-   eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_VLAN);
+   eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
}

 }
diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
index 46f0497..c97ee0a 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -109,6 +109,8 @@ struct ipv4_hdr {
   (((b) & 0xff) << 16) | \
   (((c) & 0xff) << 8)  | \
   ((d) & 0xff))
+#define IPV4_HDR_IHL_MASK  (0x0f)
+#define IPV4_FIELD_WIDTH   (4)

 /* Fragment Offset * Flags. */
 #defineIPV4_HDR_DF_SHIFT   14
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c 
b/lib/librte_pmd_bond/rte_eth_bond_api.c
index ef5ddf4..fb015a8 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -268,6 +268,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
internals->mode = BONDING_MODE_INVALID;
internals->current_primary_port = 0;
internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
+   internals->xmit_hash = xmit_l2_hash;
internals->user_defined_mac = 0;
internals->link_props_set = 0;

@@ -710,9 +711,16 @@ rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, 
uint8_t policy)

switch (policy) {
case BALANCE_XMIT_POLICY_LAYER2:
+   internals->balance_xmit_policy = policy;
+   internals->xmit_hash = xmit_l2_hash;
+   break;
case BALANCE_XMIT_POLICY_LAYER23:
+   internals->balance_xmit_policy = policy;
+   internals->xmit_hash = xmit_l23_hash;
+   break;
case BALANCE_XMIT_POLICY_LAYER34:
internals->balance_xmit_policy = policy;
+   internals->xmit_hash = xmit_l34_hash;
break;

default:
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 3db473b..dc1a828 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -31,6 +31,8 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
+#include 
+
 #include 
 #include 
 #include 
@@ -48,6 +50,9 @@
 #include "rte_eth_bond_8023ad_private.h"

 #define REORDER_PERIOD_MS 10
+
+#define HASH_L4_PORTS(h) ((h)->src_port ^ (h)->dst_port)
+
 /* Table for statistics in mode 5 TLB */
 static uint64_t tlb_last_obytets[RTE_MAX_ETHPORTS];

@@ -276,90 +281,104 @@ ipv6_hash(struct ipv6_hdr *ipv6_hdr)
(word_src_addr[3] ^ word_dst_addr[3]);
 }

-static uint32_t
-udp_hash(struct udp_hdr *hdr)
+static inline size_t
+get_vlan_offset(struct ether_hdr *eth_hdr)
 {
-   return hdr->src_port ^ hdr->dst_port;
+   size_t vlan_offset = 0;
+
+   /* Calculate VLAN offset */
+   if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == eth_hdr->ether_type) {
+   struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1);
+   vlan_offset = sizeof(struct vlan_hdr);
+
+   while (rte_cpu_to_be_16(ETHER_TYPE_VLAN) ==
+   vlan_hdr->eth_proto) {
+   vlan_hdr = vlan_hdr + 1;
+   vlan_offset += sizeof(struct vlan_hdr);
+   }
+   }
+   return vlan_offset;
 }

-static inline uint16_t
-xmit_slave_hash(const struct rte_mbuf *buf, uint8_t slave_count, uint8_t 
policy)
+uint16_t
+xmit_l2_hash(const struct rte_mbuf *buf, uint8_t slave_count)
 {
-   struct ether_hdr *eth_hdr;
-   struct udp_hdr *udp_hdr;
-   size_t eth_offset = 0;
-   uint32_t hash = 0;
-
-   if (slave_count == 1)
-   retu

[dpdk-dev] [PATCH v2] bond: vlan flags misinterpreted in xmit_slave_hash function

2014-12-16 Thread Declan Doherty
This patch contains a fix for link bonding handling of vlan tagged packets in 
mode 3 and 5.
Currently xmit_slave_hash function misinterprets the PKT_RX_VLAN_PKT flag to 
mean that
there is a vlan tag within the packet when in actually means that there is a 
valid entry
in the vlan_tci field in the mbuf.

-v2:
doxygen comments for rte_ip.h

- Fixed VLAN tag support in hashing functions.
- Adds support for TCP in layer 4 header hashing.
- Splits transmit hashing function into separate functions for each policy to
  reduce branching and to make the code clearer.
- Fixed incorrect flag set in test application packet generator.

Signed-off-by: Declan Doherty 
---
 app/test/packet_burst_generator.c  |   2 +-
 lib/librte_net/rte_ip.h|   8 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c |   8 ++
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 162 -
 lib/librte_pmd_bond/rte_eth_bond_private.h |  15 +++
 5 files changed, 122 insertions(+), 73 deletions(-)

diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index b2824dc..4a89663 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -97,7 +97,7 @@ initialize_eth_header(struct ether_hdr *eth_hdr, struct 
ether_addr *src_mac,
vhdr->eth_proto =  rte_cpu_to_be_16(ETHER_TYPE_IPv4);
vhdr->vlan_tci = van_id;
} else {
-   eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_VLAN);
+   eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
}

 }
diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
index 46f0497..3446e1c 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -110,6 +110,14 @@ struct ipv4_hdr {
   (((c) & 0xff) << 8)  | \
   ((d) & 0xff))

+/** Internet header length mask for version_ihl field */
+#define IPV4_HDR_IHL_MASK  (0x0f)
+/**
+ * Internet header length field multiplier (IHL field specifies overall header
+ * length in number of 4-byte words)
+ */
+#define IPV4_IHL_MULTIPLIER(4)
+
 /* Fragment Offset * Flags. */
 #defineIPV4_HDR_DF_SHIFT   14
 #defineIPV4_HDR_MF_SHIFT   13
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c 
b/lib/librte_pmd_bond/rte_eth_bond_api.c
index ef5ddf4..fb015a8 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -268,6 +268,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
internals->mode = BONDING_MODE_INVALID;
internals->current_primary_port = 0;
internals->balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2;
+   internals->xmit_hash = xmit_l2_hash;
internals->user_defined_mac = 0;
internals->link_props_set = 0;

@@ -710,9 +711,16 @@ rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, 
uint8_t policy)

switch (policy) {
case BALANCE_XMIT_POLICY_LAYER2:
+   internals->balance_xmit_policy = policy;
+   internals->xmit_hash = xmit_l2_hash;
+   break;
case BALANCE_XMIT_POLICY_LAYER23:
+   internals->balance_xmit_policy = policy;
+   internals->xmit_hash = xmit_l23_hash;
+   break;
case BALANCE_XMIT_POLICY_LAYER34:
internals->balance_xmit_policy = policy;
+   internals->xmit_hash = xmit_l34_hash;
break;

default:
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 3db473b..c055911 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -31,6 +31,8 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
+#include 
+
 #include 
 #include 
 #include 
@@ -48,6 +50,9 @@
 #include "rte_eth_bond_8023ad_private.h"

 #define REORDER_PERIOD_MS 10
+
+#define HASH_L4_PORTS(h) ((h)->src_port ^ (h)->dst_port)
+
 /* Table for statistics in mode 5 TLB */
 static uint64_t tlb_last_obytets[RTE_MAX_ETHPORTS];

@@ -276,90 +281,105 @@ ipv6_hash(struct ipv6_hdr *ipv6_hdr)
(word_src_addr[3] ^ word_dst_addr[3]);
 }

-static uint32_t
-udp_hash(struct udp_hdr *hdr)
+static inline size_t
+get_vlan_offset(struct ether_hdr *eth_hdr)
 {
-   return hdr->src_port ^ hdr->dst_port;
+   size_t vlan_offset = 0;
+
+   /* Calculate VLAN offset */
+   if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == eth_hdr->ether_type) {
+   struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1);
+   vlan_offset = sizeof(struct vlan_hdr);
+
+   while (rte_cpu_to_be_16(ETHER_TYPE_VLAN) ==
+   vlan_hdr->eth_proto) {
+   

[dpdk-dev] [PATCH v3 0/3] bond: static analysis issues fix

2014-12-17 Thread Declan Doherty
-v3:
Split patches 

-v2:
Incorporates Pawel's comments regarding assertion's check on activate_slave 
array indexing

Fixes for link bonding library identified by static analysis tool

- Overflow assert for active_slaves array in activate_slave function
- Allocation check of pci_id_table in rte_eth_bond_create
- Use of eth_dev pointer in mac_address_get/set before NULL check


Declan Doherty (3):
  bond: add bounds check before assigning active slave count value
  bond: fix pci_id_table allocation check in rte_eth_bond_create
  bond: eth_dev parameter used before NULL check mac_address_get/set

 lib/librte_pmd_bond/rte_eth_bond_api.c | 6 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 8 
 2 files changed, 9 insertions(+), 5 deletions(-)

-- 
1.7.12.2



[dpdk-dev] [PATCH v3 2/3] bond: fix pci_id_table allocation check in rte_eth_bond_create

2014-12-17 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c 
b/lib/librte_pmd_bond/rte_eth_bond_api.c
index b124784..c2a99a3 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -214,7 +214,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
goto err;
}
pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, 
socket_id);
-   if (pci_drv == NULL) {
+   if (pci_id_table == NULL) {
RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
goto err;
}
-- 
1.7.12.2



[dpdk-dev] [PATCH v3 1/3] bond: add bounds check before assigning active slave count value

2014-12-17 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_api.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c 
b/lib/librte_pmd_bond/rte_eth_bond_api.c
index ef5ddf4..b124784 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -115,6 +115,9 @@ activate_slave(struct rte_eth_dev *eth_dev, uint8_t port_id)
if (internals->mode == BONDING_MODE_8023AD)
bond_mode_8023ad_activate_slave(eth_dev, port_id);

+   RTE_VERIFY(internals->active_slave_count <
+   (RTE_DIM(internals->active_slaves) - 1));
+
internals->active_slaves[internals->active_slave_count] = port_id;
internals->active_slave_count++;
 }
@@ -144,6 +147,7 @@ deactivate_slave(struct rte_eth_dev *eth_dev, uint8_t 
port_id)
sizeof(internals->active_slaves[0]));
}

+   RTE_VERIFY(active_count < RTE_DIM(internals->active_slaves));
internals->active_slave_count = active_count;

if (eth_dev->data->dev_started && internals->mode == 
BONDING_MODE_8023AD)
-- 
1.7.12.2



[dpdk-dev] [PATCH v3 3/3] bond: eth_dev parameter used before NULL check in mac_address_get/set

2014-12-17 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 3db473b..bb4a537 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -764,8 +764,6 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct 
ether_addr *dst_mac_addr)
 {
struct ether_addr *mac_addr;

-   mac_addr = eth_dev->data->mac_addrs;
-
if (eth_dev == NULL) {
RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", 
__func__);
return -1;
@@ -776,6 +774,8 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct 
ether_addr *dst_mac_addr)
return -1;
}

+   mac_addr = eth_dev->data->mac_addrs;
+
ether_addr_copy(mac_addr, dst_mac_addr);
return 0;
 }
@@ -785,8 +785,6 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct 
ether_addr *new_mac_addr)
 {
struct ether_addr *mac_addr;

-   mac_addr = eth_dev->data->mac_addrs;
-
if (eth_dev == NULL) {
RTE_BOND_LOG(ERR, "NULL pointer eth_dev specified");
return -1;
@@ -797,6 +795,8 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct 
ether_addr *new_mac_addr)
return -1;
}

+   mac_addr = eth_dev->data->mac_addrs;
+
/* If new MAC is different to current MAC then update */
if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0)
memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr));
-- 
1.7.12.2



[dpdk-dev] [PATCH 0/2] link bonding unit test fix

2014-07-21 Thread Declan Doherty

fix for link bonding unit tests which are failing due to change introduced in 
rte_eth_dev_configure which now explicitly checks in pmd supports link status 
chnage interrupts.

Also adds some common test macros to the test application for unit testing


Declan Doherty (2):
  test app:
  bond: unit test suite fix

 app/test/test.c|   53 
 app/test/test.h|   82 ++
 app/test/test_link_bonding.c   |  491 
 app/test/virtual_pmd.c |1 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   92 +++---
 5 files changed, 356 insertions(+), 363 deletions(-)



[dpdk-dev] [PATCH 1/2] test app:

2014-07-21 Thread Declan Doherty
- Adding common test assertion macros for unit testing
- Structs for encapsulating unit tests / test suites data.
- test suite runner method

Signed-off-by: Declan Doherty 
---
 app/test/test.c |   53 +++
 app/test/test.h |   82 +++
 2 files changed, 135 insertions(+), 0 deletions(-)

diff --git a/app/test/test.c b/app/test/test.c
index a41e43d..589a168 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -153,3 +153,56 @@ main(int argc, char **argv)

return 0;
 }
+
+
+int
+unit_test_suite_runner(struct unit_test_suite *suite)
+{
+   int retval, i = 0;
+
+   if (suite->suite_name)
+   printf("Test Suite : %s\n", suite->suite_name);
+
+   if (suite->setup)
+   if (suite->setup() != 0)
+   return -1;
+
+   while (suite->unit_test_cases[i].testcase) {
+   /* Run test case setup */
+   if (suite->unit_test_cases[i].setup) {
+   retval = suite->unit_test_cases[i].setup();
+   if (retval != 0)
+   return retval;
+   }
+
+   /* Run test case */
+   if (suite->unit_test_cases[i].testcase() == 0) {
+   printf("TestCase %2d: %s\n", i,
+   suite->unit_test_cases[i].success_msg ?
+   suite->unit_test_cases[i].success_msg :
+   "passed");
+   }
+   else {
+   printf("TestCase %2d: %s\n", i, 
suite->unit_test_cases[i].fail_msg ?
+   suite->unit_test_cases[i].fail_msg :
+   "failed");
+   return -1;
+   }
+
+   /* Run test case teardown */
+   if (suite->unit_test_cases[i].teardown) {
+   retval = suite->unit_test_cases[i].teardown();
+   if (retval != 0)
+   return retval;
+   }
+
+   i++;
+   }
+
+   /* Run test suite teardown */
+   if (suite->teardown)
+   if (suite->teardown() != 0)
+   return -1;
+
+   return 0;
+}
diff --git a/app/test/test.h b/app/test/test.h
index c00e1d6..181c38e 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -34,6 +34,88 @@
 #ifndef _TEST_H_
 #define _TEST_H_

+#define TEST_ASSERT(cond, msg, ...) do {   
\
+   if (!(cond)) {  
\
+   printf("TestCase %s() line %d failed: " 
\
+   msg "\n", __func__, __LINE__, ##__VA_ARGS__);   
\
+   return -1;  
\
+   }   
\
+} while (0)
+
+#define TEST_ASSERT_EQUAL(a, b, msg, ...)  {   
\
+   if (!(a == b)) {
\
+   printf("TestCase %s() line %d failed: " 
\
+   msg "\n", __func__, __LINE__, ##__VA_ARGS__);   
\
+   return -1;  
\
+   }   
\
+} while (0)
+
+#define TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) do { 
\
+   if (!(a != b)) {
\
+   printf("TestCase %s() line %d failed: " 
\
+   msg "\n", __func__, __LINE__, ##__VA_ARGS__);   
\
+   return -1;  
\
+   }   
\
+} while (0)
+
+#define TEST_ASSERT_SUCCESS(val, msg, ...) do {
\
+   if (!(val == 0)) {  
\
+   printf("Test

[dpdk-dev] [PATCH 2/2] bond: unit test suite fix

2014-07-21 Thread Declan Doherty
 - Fix bonding unit test suite which was failing due to a change
   in pmd configuration behaviour introduced in commit
   a130f531187249a88edc1a5c29307f0d01abd827
 - Added fixes to allow the abiltiy to re-run test suite from test
   application without restarting application

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   |  491 
 app/test/virtual_pmd.c |1 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   92 +++---
 3 files changed, 221 insertions(+), 363 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 3f14278..5c1303e 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -122,7 +122,7 @@ static struct udp_hdr pkt_udp_hdr;

 static struct link_bonding_unittest_params default_params  = {
.bonded_port_id = -1,
-   .slave_port_ids = { 0 },
+   .slave_port_ids = { -1 },
.bonded_slave_count = 0,
.bonding_mode = BONDING_MODE_ROUND_ROBIN,

@@ -258,10 +258,11 @@ configure_ethdev(uint8_t port_id, uint8_t start)
return 0;

 error:
-   printf("Failed to configure ethdev %d", port_id);
+   printf("Failed to configure ethdev %d\n", port_id);
return -1;
 }

+static int slaves_initialized;

 static int
 test_setup(void)
@@ -270,46 +271,56 @@ test_setup(void)
struct ether_addr *mac_addr = (struct ether_addr *)slave_mac;

/* Allocate ethernet packet header with space for VLAN header */
-   test_params->pkt_eth_hdr = malloc(sizeof(struct ether_hdr) +
-   sizeof(struct vlan_hdr));
if (test_params->pkt_eth_hdr == NULL) {
-   printf("ethernet header struct allocation failed!\n");
-   return -1;
-   }
+   test_params->pkt_eth_hdr = malloc(sizeof(struct ether_hdr) +
+   sizeof(struct vlan_hdr));

+   if (test_params->pkt_eth_hdr == NULL) {
+   printf("ethernet header struct allocation failed!\n");
+   return -1;
+   }
+   }

nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX + DEF_PKT_BURST +
RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST;
-
-   test_params->mbuf_pool = rte_mempool_create("MBUF_POOL", 
nb_mbuf_per_pool,
-   MBUF_SIZE, MBUF_CACHE_SIZE, sizeof(struct 
rte_pktmbuf_pool_private),
-   rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
-   rte_socket_id(), 0);
if (test_params->mbuf_pool == NULL) {
-   printf("rte_mempool_create failed\n");
-   return -1;
+   test_params->mbuf_pool = rte_mempool_create("MBUF_POOL", 
nb_mbuf_per_pool,
+   MBUF_SIZE, MBUF_CACHE_SIZE, sizeof(struct 
rte_pktmbuf_pool_private),
+   rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, 
NULL,
+   rte_socket_id(), 0);
+   if (test_params->mbuf_pool == NULL) {
+   printf("rte_mempool_create failed\n");
+   return -1;
+   }
}

/* Create / Initialize virtual eth devs */
-   for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++) {
-   char pmd_name[RTE_ETH_NAME_MAX_LEN];
+   if (!slaves_initialized) {
+   for (i = 0; i < TEST_MAX_NUMBER_OF_PORTS; i++) {
+   char pmd_name[RTE_ETH_NAME_MAX_LEN];

-   mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;
+   mac_addr->addr_bytes[ETHER_ADDR_LEN-1] = i;

-   snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "test_slave_pmd_%d", 
i);
+   snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_virt_%d", 
i);

-   test_params->slave_port_ids[i] = virtual_ethdev_create(pmd_name,
-   mac_addr, rte_socket_id());
-   if (test_params->slave_port_ids[i] < 0) {
-   printf("Failed to create virtual pmd eth device.\n");
-   return -1;
-   }
+   test_params->slave_port_ids[i] = 
virtual_ethdev_create(pmd_name,
+   mac_addr, rte_socket_id());
+   if (test_params->slave_port_ids[i] < 0) {
+   printf("Failed to create virtual virtual ethdev 
%s\n", pmd_name);
+   return -1;
+   }

-   retval = configure_ethdev(test_params->slave_port_ids[i], 1);
-   if (retval != 0) {
-   printf("Failed to configure virtual pmd eth device.\n");
-   return -1;
+ 

[dpdk-dev] [PATCH v3 0/5] Link Bonding PMD Library

2014-06-13 Thread Declan Doherty
This patch contains the initial release of the Link Bonding PMD Library

Supporting bonding modes:
 0 - Round Robin
 1 - Active Backup
 2 - Balance (Supporting 3 transmission polices)
layer 2, layer 2+3, layer 3+4
 3 - Broadcast


Version 3 of this patch set add the following functionality changes
 - Link bonding command line option parsing / initialization support
 - Unique name identifier to rte_eth_dev_data struct to identify
   virtual ethdev's which are to be added to bondded device from
   command line.
 - Updates to EAL to support initialization of link bonding devices

Patch Set Description:
 0001 - librte_pmd_bond + makefile changes
 0002 - librte_eal / librte_ether changes to support bonding device 
intialization
 0003 - link bonding unti test suite
 0004 - testpmd link bonding support changes
 0005 - doxygen additions


 app/test-pmd/cmdline.c  |  571 
 app/test-pmd/config.c   |4 +-
 app/test-pmd/parameters.c   |3 +
 app/test-pmd/testpmd.c  |   37 +-
 app/test-pmd/testpmd.h  |2 +
 app/test/Makefile   |4 +-
 app/test/commands.c |7 +
 app/test/packet_burst_generator.c   |  288 ++
 app/test/packet_burst_generator.h   |   78 +
 app/test/test.h |1 +
 app/test/test_link_bonding.c| 3958 +++
 app/test/virtual_pmd.c  |  574 
 app/test/virtual_pmd.h  |   74 +
 config/common_bsdapp|5 +
 config/common_linuxapp  |5 +
 doc/doxy-api-index.md   |1 +
 doc/doxy-api.conf   |1 +
 lib/Makefile|1 +
 lib/librte_eal/common/eal_common_dev.c  |   66 +-
 lib/librte_eal/common/eal_common_pci.c  |6 +
 lib/librte_eal/common/include/eal_private.h |7 +
 lib/librte_eal/common/include/rte_dev.h |1 +
 lib/librte_ether/rte_ethdev.c   |   34 +-
 lib/librte_ether/rte_ethdev.h   |7 +-
 lib/librte_pmd_bond/Makefile|   32 +
 lib/librte_pmd_bond/rte_eth_bond.c  | 2149 +++
 lib/librte_pmd_bond/rte_eth_bond.h  |  255 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c  |   22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  |   32 +-
 lib/librte_pmd_ring/rte_eth_ring.h  |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|2 +-
 mk/rte.app.mk   |5 +
 32 files changed, 8192 insertions(+), 43 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h

-- 
1.8.5.3



[dpdk-dev] [PATCH v3 2/5] Link Bonding PMD Library (librte_eal/librte_ether link bonding support changes)

2014-06-13 Thread Declan Doherty
Updating functionality in EAL to support adding link bonding
devices via ???vdev option. Link bonding devices will be
initialized after all physical devices have been probed and
initialized.

Signed-off-by: Declan Doherty 
---
 lib/librte_eal/common/eal_common_dev.c  | 66 +++--
 lib/librte_eal/common/eal_common_pci.c  |  6 +++
 lib/librte_eal/common/include/eal_private.h |  7 +++
 lib/librte_eal/common/include/rte_dev.h |  1 +
 lib/librte_ether/rte_ethdev.c   | 34 +--
 lib/librte_ether/rte_ethdev.h   |  7 ++-
 lib/librte_pmd_pcap/rte_eth_pcap.c  | 22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  | 32 +++---
 lib/librte_pmd_ring/rte_eth_ring.h  |  3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|  2 +-
 10 files changed, 144 insertions(+), 36 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..b50c908 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -75,14 +75,28 @@ rte_eal_dev_init(void)

/* call the init function for each virtual device */
TAILQ_FOREACH(devargs, &devargs_list, next) {
+   uint8_t bdev = 0;

if (devargs->type != RTE_DEVTYPE_VIRTUAL)
continue;

TAILQ_FOREACH(driver, &dev_driver_list, next) {
-   if (driver->type != PMD_VDEV)
+   /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device*/
+   if (driver->type != PMD_VDEV && driver->type != 
PMD_BDEV)
continue;

+   /*
+* Bonded devices are not initialize here, we do it 
later in
+* rte_eal_bonded_dev_init() after all physical devices 
have been
+* probed and initialized
+*/
+   if (driver->type == PMD_BDEV &&
+   !strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   bdev = 1;
+   break;
+   }
+
/* search a driver prefix in virtual device name */
if (!strncmp(driver->name, devargs->virtual.drv_name,
strlen(driver->name))) {
@@ -92,9 +106,9 @@ rte_eal_dev_init(void)
}
}

-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   if (driver == NULL && !bdev) {
+   rte_panic("no driver found for %s and is not a bonded 
vdev %d\n",
+ devargs->virtual.drv_name, bdev);
}
}

@@ -107,3 +121,47 @@ rte_eal_dev_init(void)
}
return 0;
 }
+
+#ifdef RTE_LIBRTE_PMD_BOND
+int
+rte_eal_bonded_dev_init(void)
+{
+   struct rte_devargs *devargs;
+   struct rte_driver *driver;
+
+   TAILQ_FOREACH(devargs, &devargs_list, next) {
+   int vdev = 0;
+
+   if (devargs->type != RTE_DEVTYPE_VIRTUAL)
+   continue;
+
+   TAILQ_FOREACH(driver, &dev_driver_list, next) {
+   if (driver->type != PMD_VDEV && driver->type != 
PMD_BDEV)
+   continue;
+
+   /* Virtual devices have already been initialized so we 
skip them
+* here*/
+   if (driver->type == PMD_VDEV &&
+   !strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   vdev = 1;
+   break;
+   }
+
+   /* search a driver prefix in bonded device name */
+   if (!strncmp(driver->name, devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   driver->init(devargs->virtual.drv_name, 
devargs->args);
+   break;
+   }
+   }
+
+   if (driver == NULL && !vdev) {
+   rte_panic("no driver found for %s\n",
+   devargs->virtual.drv_name);
+   }
+   }
+   return 0;
+}
+#endif
+
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_c

[dpdk-dev] [PATCH v3 5/5] Link Bonding PMD Library (Doxygen Additions)

2014-06-13 Thread Declan Doherty
Signed-off-by: Declan Doherty 
---
 doc/doxy-api-index.md | 1 +
 doc/doxy-api.conf | 1 +
 2 files changed, 2 insertions(+)

diff --git a/doc/doxy-api-index.md b/doc/doxy-api-index.md
index 6e75a6e..a4d2e57 100644
--- a/doc/doxy-api-index.md
+++ b/doc/doxy-api-index.md
@@ -36,6 +36,7 @@ API {#index}
 There are many libraries, so their headers may be grouped by topics:

 - **device**:
+  [bond]   (@ref rte_eth_bond.h),
   [ethdev] (@ref rte_ethdev.h),
   [devargs](@ref rte_devargs.h),
   [KNI](@ref rte_kni.h),
diff --git a/doc/doxy-api.conf b/doc/doxy-api.conf
index 9df7356..92f8c59 100644
--- a/doc/doxy-api.conf
+++ b/doc/doxy-api.conf
@@ -30,6 +30,7 @@

 PROJECT_NAME= DPDK
 INPUT   = doc/doxy-api-index.md \
+  lib/librte_pmd_bond \
   lib/librte_eal/common/include \
   lib/librte_distributor \
   lib/librte_ether \
-- 
1.8.5.3



[dpdk-dev] [PATCH v3 1/5] Link Bonding PMD Library

2014-06-13 Thread Declan Doherty
Link Bonding Library (lib/librte_pmd_bond) initial release with support for
 Mode 0 - Round Robin
 Mode 1 - Active Backup
 Mode 2 - Balance -> Supports 3 transmit polices (layer 2, layer 2+3, layer 3+4)
 Mode 3 - Broadcast


Signed-off-by: Declan Doherty 
---
 config/common_bsdapp   |5 +
 config/common_linuxapp |5 +
 lib/Makefile   |1 +
 lib/librte_pmd_bond/Makefile   |   32 +
 lib/librte_pmd_bond/rte_eth_bond.c | 2149 
 lib/librte_pmd_bond/rte_eth_bond.h |  255 +
 mk/rte.app.mk  |5 +
 7 files changed, 2452 insertions(+)
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h

diff --git a/config/common_bsdapp b/config/common_bsdapp
index ec7b159..545d760 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -187,6 +187,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 7c143eb..eb2e3d0 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -216,6 +216,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Compile Xen PMD
 #
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
diff --git a/lib/Makefile b/lib/Makefile
index 8cdfa7d..66232a9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -47,6 +47,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
 DIRS-$(CONFIG_RTE_LIBRTE_NET) += librte_net
diff --git a/lib/librte_pmd_bond/Makefile b/lib/librte_pmd_bond/Makefile
new file mode 100644
index 000..9275830
--- /dev/null
+++ b/lib/librte_pmd_bond/Makefile
@@ -0,0 +1,32 @@
+# 
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_bond.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond.c
+
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_eth_bond.h
+
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_malloc
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_kvargs
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_bond/rte_eth_bond.c 
b/lib/librte_pmd_bond/rte_eth_bond.c
new file mode 100644
index 000..01d917d
--- /dev/null
+++ b/lib/librte_pmd_bond/rte_eth_bond.c
@@ -0,0 +1,2149 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#inclu

[dpdk-dev] [PATCH v3 3/5] Link Bonding PMD Library (Unit Test Suite)

2014-06-13 Thread Declan Doherty
Link bonding unit tests, including:
 - code to generate packet bursts for testing rx and tx
   functionality of bonded device
 - virtual/stubbed out ethdev for use as slave ethdev in testing


Signed-off-by: Declan Doherty 
---
 app/test/Makefile |4 +-
 app/test/commands.c   |7 +
 app/test/packet_burst_generator.c |  288 +++
 app/test/packet_burst_generator.h |   78 +
 app/test/test.h   |1 +
 app/test/test_link_bonding.c  | 3958 +
 app/test/virtual_pmd.c|  574 ++
 app/test/virtual_pmd.h|   74 +
 8 files changed, 4983 insertions(+), 1 deletion(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 3b050c3..02eff0f 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -96,7 +96,9 @@ SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor_perf.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_devargs.c
-
+SRCS-$(CONFIG_RTE_APP_TEST) += virtual_pmd.c
+SRCS-$(CONFIG_RTE_APP_TEST) += packet_burst_generator.c
+SRCS-$(CONFIG_RTE_APP_TEST) += test_link_bonding.c
 ifeq ($(CONFIG_RTE_APP_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
diff --git a/app/test/commands.c b/app/test/commands.c
index 016410d..c31389d 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -157,6 +157,10 @@ static void cmd_autotest_parsed(void *parsed_result,
ret = test_timer();
if (!strcmp(res->autotest, "timer_perf_autotest"))
ret = test_timer_perf();
+#ifdef RTE_LIBRTE_PMD_BOND
+   if (!strcmp(res->autotest, "link_bonding_autotest"))
+   ret = test_link_bonding();
+#endif
if (!strcmp(res->autotest, "mempool_autotest"))
ret = test_mempool();
if (!strcmp(res->autotest, "mempool_perf_autotest"))
@@ -225,6 +229,9 @@ cmdline_parse_token_string_t cmd_autotest_autotest =
"alarm_autotest#interrupt_autotest#"
"version_autotest#eal_fs_autotest#"
"cmdline_autotest#func_reentrancy_autotest#"
+#ifdef RTE_LIBRTE_PMD_BOND
+   "link_bonding_autotest#"
+#endif
"mempool_perf_autotest#hash_perf_autotest#"
"memcpy_perf_autotest#ring_perf_autotest#"
"red_autotest#meter_autotest#sched_autotest#"
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
new file mode 100644
index 000..38db383
--- /dev/null
+++ b/app/test/packet_burst_generator.c
@@ -0,0 +1,288 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include "packet_burst_generator.h"
+
+#define UDP_SRC_PORT 1024
+#define UDP_DST_PORT 1024
+
+
+#define IP_DEFTTL  64   /* from RFC 1340. */
+#def

[dpdk-dev] [PATCH v3 4/5] Link Bonding PMD Library (testpmd link bonding API support)

2014-06-13 Thread Declan Doherty
Adding link bonding support to testpmd.
 - Includes the ability to create new bonded devices.
 - Add /remove bonding slave devices.
 - Interogate bonded device stats/configuration
 - Change bonding modes and select balance transmit polices

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c| 571 ++
 app/test-pmd/config.c |   4 +-
 app/test-pmd/parameters.c |   3 +
 app/test-pmd/testpmd.c|  37 ++-
 app/test-pmd/testpmd.h|   2 +
 5 files changed, 611 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4678977..fd220e7 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -84,6 +84,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_LIBRTE_PMD_BOND
+#include 
+#endif

 #include "testpmd.h"

@@ -400,6 +403,31 @@ static void cmd_help_long_parsed(void *parsed_result,
"   Show the bypass configuration for a bypass enabled 
NIC"
" using the lowest port on the NIC.\n\n"
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+   "create bonded device (mode) (socket)\n"
+   "   Create a new bonded device with specific 
bonding mode and socket.\n\n"
+
+   "add bonding slave (slave_id) (port_id)\n"
+   "   Add a slave device to a bonded device.\n\n"
+
+   "remove bonding slave (slave_id) (port_id)\n"
+   "   Remove a slave device from a bonded device.\n\n"
+
+   "set bonding mode (value) (port_id)\n"
+   "   Set the bonding mode on a bonded device.\n\n"
+
+   "set bonding primary (slave_id) (port_id)\n"
+   "   Set the primary slave for a bonded device.\n\n"
+
+   "show bonding config (port_id)\n"
+   "   Show the bonding config for port_id.\n\n"
+
+   "set bonding mac_addr (port_id) (address)\n"
+   "   Set the MAC address of a bonded device.\n\n"
+
+   "set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
+   "   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+#endif

, list_pkt_forwarding_modes()
);
@@ -2856,6 +2884,539 @@ cmdline_parse_inst_t cmd_show_bypass_config = {
 };
 #endif

+#ifdef RTE_LIBRTE_PMD_BOND
+/* *** SET BONDING MODE *** */
+struct cmd_set_bonding_mode_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mode;
+   uint8_t value;
+   uint8_t port_id;
+};
+
+static void cmd_set_bonding_mode_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bonding_mode_result *res = parsed_result;
+   portid_t port_id = res->port_id;
+
+   /* Set the bonding mode for the relevant port. */
+   if (0 != rte_eth_bond_mode_set(port_id, res->value))
+   printf("\t Failed to set bonding mode for port = %d.\n", 
port_id);
+}
+
+cmdline_parse_token_string_t cmd_setbonding_mode_set =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_setbonding_mode_mode =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   mode, "mode");
+cmdline_parse_token_num_t cmd_setbonding_mode_value =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   value, UINT8);
+cmdline_parse_token_num_t cmd_setbonding_mode_port =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_set_bonding_mode = {
+   .f = cmd_set_bonding_mode_parsed,
+   .help_str = "set bonding mode (mode_value) (port_id): Set the 
bonding mode for port_id",
+   .data = NULL,
+   .tokens = {
+   (void *) &cmd_setbonding_mode_set,
+   (void *) &cmd_setbonding_mode_bonding,
+   (void *) &cmd_setbonding_mode_mode,
+   (void *) &cmd_setbonding_mode_value,
+   (void *) &cmd_setbonding_mode_port,
+   NULL
+   }
+};
+
+/* *** SET BALANCE XMIT POLICY *** 

[dpdk-dev] [PATCH v4 0/6] Link Bonding Library

2014-06-16 Thread Declan Doherty
AThis patch contains the initial release of the Link Bonding PMD Library

Supporting bonding modes:
 0 - Round Robin
 1 - Active Backup
 2 - Balance (Supporting 3 transmission polices)
layer 2, layer 2+3, layer 3+4
 3 - Broadcast

Version 4 of patch set:
 - Fixes some checkpatch formatting issues
 - Splits unique pmd naming and link bonding intialization changes in
   EAL into separate patches

Patch Set Description:
 0001 - librte_pmd_bond + makefile changes
 0002 - librte_ether changes to support unique naming of pmds 
 0003 - librte_eal changes to support bonding device intialization
 0005 - link bonding unti test suite
 0005 - testpmd link bonding support changes
 0006 - doxygen additions

Declan Doherty (6):
  Link Bonding Library (lib/librte_pmd_bond) initial release with
support for Mode 0 - Round Robin Mode 1 - Active Backup Mode 2 -
Balance -> Supports 3 transmit polices (layer 2, layer 2+3, la Mode
3 - Broadcast
  Support for unique interface naming of pmds
  EAL support for link bonding device initialization
  Link bonding Unit Tests
  testpmd link bonding additions
  Link Bonding Library doxygen additions

 app/test-pmd/cmdline.c  |  571 
 app/test-pmd/config.c   |4 +-
 app/test-pmd/parameters.c   |3 +
 app/test-pmd/testpmd.c  |   37 +-
 app/test-pmd/testpmd.h  |2 +
 app/test/Makefile   |4 +-
 app/test/commands.c |7 +
 app/test/packet_burst_generator.c   |  288 ++
 app/test/packet_burst_generator.h   |   78 +
 app/test/test.h |1 +
 app/test/test_link_bonding.c| 3958 +++
 app/test/virtual_pmd.c  |  574 
 app/test/virtual_pmd.h  |   74 +
 config/common_bsdapp|5 +
 config/common_linuxapp  |5 +
 doc/doxy-api-index.md   |1 +
 doc/doxy-api.conf   |1 +
 lib/Makefile|1 +
 lib/librte_eal/common/eal_common_dev.c  |   66 +-
 lib/librte_eal/common/eal_common_pci.c  |6 +
 lib/librte_eal/common/include/eal_private.h |7 +
 lib/librte_eal/common/include/rte_dev.h |1 +
 lib/librte_ether/rte_ethdev.c   |   33 +-
 lib/librte_ether/rte_ethdev.h   |7 +-
 lib/librte_pmd_bond/Makefile|   32 +
 lib/librte_pmd_bond/rte_eth_bond.c  | 2149 +++
 lib/librte_pmd_bond/rte_eth_bond.h  |  255 ++
 lib/librte_pmd_pcap/rte_eth_pcap.c  |   22 +-
 lib/librte_pmd_ring/rte_eth_ring.c  |   32 +-
 lib/librte_pmd_ring/rte_eth_ring.h  |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c|2 +-
 mk/rte.app.mk   |5 +
 32 files changed, 8191 insertions(+), 43 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h



[dpdk-dev] [PATCH v4 3/6] EAL support for link bonding device initialization

2014-06-16 Thread Declan Doherty
Updating functionality in EAL to support adding link bonding
devices via ?vdev option. Link bonding devices will be
initialized after all physical devices have been probed and
initialized.

Signed-off-by: Declan Doherty 
---
 lib/librte_eal/common/eal_common_dev.c  |   66 +--
 lib/librte_eal/common/eal_common_pci.c  |6 +++
 lib/librte_eal/common/include/eal_private.h |7 +++
 lib/librte_eal/common/include/rte_dev.h |1 +
 4 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index eae5656..b50c908 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -75,14 +75,28 @@ rte_eal_dev_init(void)

/* call the init function for each virtual device */
TAILQ_FOREACH(devargs, &devargs_list, next) {
+   uint8_t bdev = 0;

if (devargs->type != RTE_DEVTYPE_VIRTUAL)
continue;

TAILQ_FOREACH(driver, &dev_driver_list, next) {
-   if (driver->type != PMD_VDEV)
+   /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded 
device*/
+   if (driver->type != PMD_VDEV && driver->type != 
PMD_BDEV)
continue;

+   /*
+* Bonded devices are not initialize here, we do it 
later in
+* rte_eal_bonded_dev_init() after all physical devices 
have been
+* probed and initialized
+*/
+   if (driver->type == PMD_BDEV &&
+   !strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   bdev = 1;
+   break;
+   }
+
/* search a driver prefix in virtual device name */
if (!strncmp(driver->name, devargs->virtual.drv_name,
strlen(driver->name))) {
@@ -92,9 +106,9 @@ rte_eal_dev_init(void)
}
}

-   if (driver == NULL) {
-   rte_panic("no driver found for %s\n",
- devargs->virtual.drv_name);
+   if (driver == NULL && !bdev) {
+   rte_panic("no driver found for %s and is not a bonded 
vdev %d\n",
+ devargs->virtual.drv_name, bdev);
}
}

@@ -107,3 +121,47 @@ rte_eal_dev_init(void)
}
return 0;
 }
+
+#ifdef RTE_LIBRTE_PMD_BOND
+int
+rte_eal_bonded_dev_init(void)
+{
+   struct rte_devargs *devargs;
+   struct rte_driver *driver;
+
+   TAILQ_FOREACH(devargs, &devargs_list, next) {
+   int vdev = 0;
+
+   if (devargs->type != RTE_DEVTYPE_VIRTUAL)
+   continue;
+
+   TAILQ_FOREACH(driver, &dev_driver_list, next) {
+   if (driver->type != PMD_VDEV && driver->type != 
PMD_BDEV)
+   continue;
+
+   /* Virtual devices have already been initialized so we 
skip them
+* here*/
+   if (driver->type == PMD_VDEV &&
+   !strncmp(driver->name, 
devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   vdev = 1;
+   break;
+   }
+
+   /* search a driver prefix in bonded device name */
+   if (!strncmp(driver->name, devargs->virtual.drv_name,
+   strlen(driver->name))) {
+   driver->init(devargs->virtual.drv_name, 
devargs->args);
+   break;
+   }
+   }
+
+   if (driver == NULL && !vdev) {
+   rte_panic("no driver found for %s\n",
+   devargs->virtual.drv_name);
+   }
+   }
+   return 0;
+}
+#endif
+
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 4d877ea..9b584f5 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -166,7 +166,13 @@ rte_eal_pci_probe(void)
 dev->addr.devid, dev->addr.function);
}

+#ifdef RTE_LIBRTE_PMD_BOND
+   /* After all physical PCI devices have been probed and initialized then 
we
+  

[dpdk-dev] [PATCH v4 2/6] Support for unique interface naming of pmds

2014-06-16 Thread Declan Doherty
Adding support to rte_eth_dev_data structure to support unique
name identifier for ethdevs to support adding slave ethdevs
(specifically virtual devices which have no public unique
identifier) to a link bonding device. This changes the API
rte_eth_dev_allocate() to require a const char *name when
allocating a ethdev, which also verifies that the name is
unique and hasn?t been already used by an existed allocated
rte_eth_dev. Also contains updates to virtual pmd?s to now call
the API with a name parameter.

Signed-off-by: Declan Doherty 
---
 lib/librte_ether/rte_ethdev.c|   33 +++--
 lib/librte_ether/rte_ethdev.h|7 +-
 lib/librte_pmd_pcap/rte_eth_pcap.c   |   22 ++--
 lib/librte_pmd_ring/rte_eth_ring.c   |   32 +++-
 lib/librte_pmd_ring/rte_eth_ring.h   |3 +-
 lib/librte_pmd_xenvirt/rte_eth_xenvirt.c |2 +-
 6 files changed, 67 insertions(+), 32 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 8011b8b..e5373fe 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_ether.h"
 #include "rte_ethdev.h"
@@ -152,8 +153,21 @@ rte_eth_dev_data_alloc(void)
RTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));
 }

+static int
+rte_eth_dev_name_unique(const char *name)
+{
+   unsigned i;
+
+   for (i = 0; i < nb_ports; i++) {
+   if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+   return -1;
+   }
+
+   return 0;
+}
+
 struct rte_eth_dev *
-rte_eth_dev_allocate(void)
+rte_eth_dev_allocate(const char *name)
 {
struct rte_eth_dev *eth_dev;

@@ -165,23 +179,36 @@ rte_eth_dev_allocate(void)
if (rte_eth_dev_data == NULL)
rte_eth_dev_data_alloc();

+   if (rte_eth_dev_name_unique(name)) {
+   PMD_DEBUG_TRACE("Ethernet Device with name %s already 
allocated!\n");
+   return NULL;
+   }
+
eth_dev = &rte_eth_devices[nb_ports];
eth_dev->data = &rte_eth_dev_data[nb_ports];
+   rte_snprintf(eth_dev->data->name, sizeof(eth_dev->data->name),
+   "%s", name);
eth_dev->data->port_id = nb_ports++;
return eth_dev;
 }

 static int
 rte_eth_dev_init(struct rte_pci_driver *pci_drv,
-struct rte_pci_device *pci_dev)
+   struct rte_pci_device *pci_dev)
 {
struct eth_driver*eth_drv;
struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
int diag;

eth_drv = (struct eth_driver *)pci_drv;

-   eth_dev = rte_eth_dev_allocate();
+   /* Create unique ethdev name from pci address */
+   rte_snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "%d:%d.%d",
+   pci_dev->addr.bus, pci_dev->addr.devid, 
pci_dev->addr.function);
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
if (eth_dev == NULL)
return -ENOMEM;

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 67eda50..27ed0ab 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1233,6 +1233,8 @@ struct rte_eth_dev_sriov {
 };
 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)

+#define RTE_ETH_NAME_MAX_LEN (32)
+
 /**
  * @internal
  * The data part, with no function pointers, associated with each ethernet 
device.
@@ -1241,6 +1243,8 @@ struct rte_eth_dev_sriov {
  * processes in a multi-process configuration.
  */
 struct rte_eth_dev_data {
+   char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
+
void **rx_queues; /**< Array of pointers to RX queues. */
void **tx_queues; /**< Array of pointers to TX queues. */
uint16_t nb_rx_queues; /**< Number of RX queues. */
@@ -1293,10 +1297,11 @@ extern uint8_t rte_eth_dev_count(void);
  * Allocates a new ethdev slot for an ethernet device and returns the pointer
  * to that slot for the driver to use.
  *
+ * @param  nameUnique identifier name for each Ethernet device
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(void);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);

 struct eth_driver;
 /**
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c 
b/lib/librte_pmd_pcap/rte_eth_pcap.c
index b3dbbda..12b7e0c 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -534,7 +534,7 @@ open_tx_iface(const char *key __rte_unused, const char 
*value, void *extra_args)


 static int
-rte_pmd_init_internals(const unsigned nb_rx_queues,
+rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
const u

[dpdk-dev] [PATCH v4 1/6] Link Bonding Library (lib/librte_pmd_bond) initial release with support for Mode 0 - Round Robin Mode 1 - Active Backup Mode 2 - Balance -> Supports 3 transmit polices (layer

2014-06-16 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 config/common_bsdapp   |5 +
 config/common_linuxapp |5 +
 lib/Makefile   |1 +
 lib/librte_pmd_bond/Makefile   |   32 +
 lib/librte_pmd_bond/rte_eth_bond.c | 2149 
 lib/librte_pmd_bond/rte_eth_bond.h |  255 +
 mk/rte.app.mk  |5 +
 7 files changed, 2452 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_bond/Makefile
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.c
 create mode 100644 lib/librte_pmd_bond/rte_eth_bond.h

diff --git a/config/common_bsdapp b/config/common_bsdapp
index ef8eeab..6846cba 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -189,6 +189,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=y

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 9f93569..3039591 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -218,6 +218,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n

 #
+# Compile link bonding pmd library
+#
+CONFIG_RTE_LIBRTE_PMD_BOND=y
+
+#
 # Compile Xen PMD
 #
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
diff --git a/lib/Makefile b/lib/Makefile
index a9f94b4..5b025c7 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -47,6 +47,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl
diff --git a/lib/librte_pmd_bond/Makefile b/lib/librte_pmd_bond/Makefile
new file mode 100644
index 000..51f6159
--- /dev/null
+++ b/lib/librte_pmd_bond/Makefile
@@ -0,0 +1,32 @@
+# 
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_bond.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += rte_eth_bond.c
+
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_eth_bond.h
+
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_malloc
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += lib/librte_kvargs
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_bond/rte_eth_bond.c 
b/lib/librte_pmd_bond/rte_eth_bond.c
new file mode 100644
index 000..01d917d
--- /dev/null
+++ b/lib/librte_pmd_bond/rte_eth_bond.c
@@ -0,0 +1,2149 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "rte_eth_bond.h"
+
+/* Link Bonding KVARG option defintions for --vdev  */
+#d

[dpdk-dev] [PATCH v4 6/6] Link Bonding Library doxygen additions

2014-06-16 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 doc/doxy-api-index.md |1 +
 doc/doxy-api.conf |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/doc/doxy-api-index.md b/doc/doxy-api-index.md
index 83303a1..8338a9b 100644
--- a/doc/doxy-api-index.md
+++ b/doc/doxy-api-index.md
@@ -36,6 +36,7 @@ API {#index}
 There are many libraries, so their headers may be grouped by topics:

 - **device**:
+  [bond]   (@ref rte_eth_bond.h),
   [ethdev] (@ref rte_ethdev.h),
   [devargs](@ref rte_devargs.h),
   [KNI](@ref rte_kni.h),
diff --git a/doc/doxy-api.conf b/doc/doxy-api.conf
index e5a8520..3af8dad 100644
--- a/doc/doxy-api.conf
+++ b/doc/doxy-api.conf
@@ -30,6 +30,7 @@

 PROJECT_NAME= DPDK
 INPUT   = doc/doxy-api-index.md \
+  lib/librte_pmd_bond \
   lib/librte_eal/common/include \
   lib/librte_acl \
   lib/librte_distributor \
-- 
1.7.0.7



[dpdk-dev] [PATCH v4 5/6] testpmd link bonding additions

2014-06-16 Thread Declan Doherty
 - Includes the ability to create new bonded devices.
 - Add /remove bonding slave devices.
 - Interogate bonded device stats/configuration
 - Change bonding modes and select balance transmit polices

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c|  571 +
 app/test-pmd/config.c |4 +-
 app/test-pmd/parameters.c |3 +
 app/test-pmd/testpmd.c|   37 +++-
 app/test-pmd/testpmd.h|2 +
 5 files changed, 611 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4678977..fd220e7 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -84,6 +84,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_LIBRTE_PMD_BOND
+#include 
+#endif

 #include "testpmd.h"

@@ -400,6 +403,31 @@ static void cmd_help_long_parsed(void *parsed_result,
"   Show the bypass configuration for a bypass enabled 
NIC"
" using the lowest port on the NIC.\n\n"
 #endif
+#ifdef RTE_LIBRTE_PMD_BOND
+   "create bonded device (mode) (socket)\n"
+   "   Create a new bonded device with specific 
bonding mode and socket.\n\n"
+
+   "add bonding slave (slave_id) (port_id)\n"
+   "   Add a slave device to a bonded device.\n\n"
+
+   "remove bonding slave (slave_id) (port_id)\n"
+   "   Remove a slave device from a bonded device.\n\n"
+
+   "set bonding mode (value) (port_id)\n"
+   "   Set the bonding mode on a bonded device.\n\n"
+
+   "set bonding primary (slave_id) (port_id)\n"
+   "   Set the primary slave for a bonded device.\n\n"
+
+   "show bonding config (port_id)\n"
+   "   Show the bonding config for port_id.\n\n"
+
+   "set bonding mac_addr (port_id) (address)\n"
+   "   Set the MAC address of a bonded device.\n\n"
+
+   "set bonding xmit_balance_policy (port_id) 
(l2|l23|l34)\n"
+   "   Set the transmit balance policy for bonded 
device running in balance mode.\n\n"
+#endif

, list_pkt_forwarding_modes()
);
@@ -2856,6 +2884,539 @@ cmdline_parse_inst_t cmd_show_bypass_config = {
 };
 #endif

+#ifdef RTE_LIBRTE_PMD_BOND
+/* *** SET BONDING MODE *** */
+struct cmd_set_bonding_mode_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t bonding;
+   cmdline_fixed_string_t mode;
+   uint8_t value;
+   uint8_t port_id;
+};
+
+static void cmd_set_bonding_mode_parsed(void *parsed_result,
+   __attribute__((unused))  struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_set_bonding_mode_result *res = parsed_result;
+   portid_t port_id = res->port_id;
+
+   /* Set the bonding mode for the relevant port. */
+   if (0 != rte_eth_bond_mode_set(port_id, res->value))
+   printf("\t Failed to set bonding mode for port = %d.\n", 
port_id);
+}
+
+cmdline_parse_token_string_t cmd_setbonding_mode_set =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   set, "set");
+cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   bonding, "bonding");
+cmdline_parse_token_string_t cmd_setbonding_mode_mode =
+TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
+   mode, "mode");
+cmdline_parse_token_num_t cmd_setbonding_mode_value =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   value, UINT8);
+cmdline_parse_token_num_t cmd_setbonding_mode_port =
+TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_set_bonding_mode = {
+   .f = cmd_set_bonding_mode_parsed,
+   .help_str = "set bonding mode (mode_value) (port_id): Set the 
bonding mode for port_id",
+   .data = NULL,
+   .tokens = {
+   (void *) &cmd_setbonding_mode_set,
+   (void *) &cmd_setbonding_mode_bonding,
+   (void *) &cmd_setbonding_mode_mode,
+   (void *) &cmd_setbonding_mode_value,
+   (void *) &cmd_setbonding_mode_port,
+   NULL
+   }
+};
+
+/* *** SET BALANCE XMIT POLICY *** */
+struct cmd_set_bonding_balance_xmit_policy_result {
+  

[dpdk-dev] [PATCH v4 4/6] Link bonding Unit Tests

2014-06-16 Thread Declan Doherty
Including:
 - code to generate packet bursts for testing rx and tx
   functionality of bonded device
 - virtual/stubbed out ethdev for use as slave ethdev in testing

Signed-off-by: Declan Doherty 
---
 app/test/Makefile |4 +-
 app/test/commands.c   |7 +
 app/test/packet_burst_generator.c |  288 +++
 app/test/packet_burst_generator.h |   78 +
 app/test/test.h   |1 +
 app/test/test_link_bonding.c  | 3958 +
 app/test/virtual_pmd.c|  574 ++
 app/test/virtual_pmd.h|   74 +
 8 files changed, 4983 insertions(+), 1 deletions(-)
 create mode 100644 app/test/packet_burst_generator.c
 create mode 100644 app/test/packet_burst_generator.h
 create mode 100644 app/test/test_link_bonding.c
 create mode 100644 app/test/virtual_pmd.c
 create mode 100644 app/test/virtual_pmd.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 3b050c3..02eff0f 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -96,7 +96,9 @@ SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_distributor_perf.c
 SRCS-$(CONFIG_RTE_APP_TEST) += test_devargs.c
-
+SRCS-$(CONFIG_RTE_APP_TEST) += virtual_pmd.c
+SRCS-$(CONFIG_RTE_APP_TEST) += packet_burst_generator.c
+SRCS-$(CONFIG_RTE_APP_TEST) += test_link_bonding.c
 ifeq ($(CONFIG_RTE_APP_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += test_acl.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
diff --git a/app/test/commands.c b/app/test/commands.c
index 016410d..c31389d 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -157,6 +157,10 @@ static void cmd_autotest_parsed(void *parsed_result,
ret = test_timer();
if (!strcmp(res->autotest, "timer_perf_autotest"))
ret = test_timer_perf();
+#ifdef RTE_LIBRTE_PMD_BOND
+   if (!strcmp(res->autotest, "link_bonding_autotest"))
+   ret = test_link_bonding();
+#endif
if (!strcmp(res->autotest, "mempool_autotest"))
ret = test_mempool();
if (!strcmp(res->autotest, "mempool_perf_autotest"))
@@ -225,6 +229,9 @@ cmdline_parse_token_string_t cmd_autotest_autotest =
"alarm_autotest#interrupt_autotest#"
"version_autotest#eal_fs_autotest#"
"cmdline_autotest#func_reentrancy_autotest#"
+#ifdef RTE_LIBRTE_PMD_BOND
+   "link_bonding_autotest#"
+#endif
"mempool_perf_autotest#hash_perf_autotest#"
"memcpy_perf_autotest#ring_perf_autotest#"
"red_autotest#meter_autotest#sched_autotest#"
diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
new file mode 100644
index 000..38db383
--- /dev/null
+++ b/app/test/packet_burst_generator.c
@@ -0,0 +1,288 @@
+/*-
+ *   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.
+ */
+
+#include 
+#include 
+
+#include "packet_burst_generator.h"
+
+#define UDP_SRC_PORT 1024
+#define UDP_DST_PORT 1024
+
+
+#define IP_DEFTTL  64   /* from RFC 1340. */
+#define IP_VERSION 0

[dpdk-dev] bond: mode 4 promiscuous mode

2015-05-20 Thread Declan Doherty
On 15/05/15 14:36, Andriy Berestovskyy wrote:
> Hey guys,
> Can we in function bond_mode_8023ad_activate_slave() try to add to the
> slave bond and LACP multicast MACs first? And then we would fall back
> into promiscuous mode if the adding has failed.
>
> In other words:
>
> if (rte_eth_dev_mac_addr_add(slave_id, bond_mac) != 0
>  || rte_eth_dev_mac_addr_add(slave_id, lacp_mac) != 0) {
>  ...
>  rte_eth_promiscuous_enable(slave_id)
> }
>
> Seems to work fine on my setup, but I might miss something.
>
> Regards,
> Andriy
>

Hey Andriy,

that sounds like a sensible idea, if you want to submit your changes in 
a patch or rfc that would be great, I'll have a look and will get them 
tested by our validation team.

Thanks
Declan


[dpdk-dev] [PATCH v3 3/5] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist

2014-09-23 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c |2 +-
 app/test-pmd/testpmd.c |3 ++-
 app/test-pmd/testpmd.h |2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 67321f7..ed76eea 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3614,7 +3614,7 @@ static void cmd_create_bonded_device_parsed(void 
*parsed_result,

/* Update number of ports */
nb_ports = rte_eth_dev_count();
-   reconfig(port_id);
+   reconfig(port_id, res->socket);
rte_eth_promiscuous_enable(port_id);
}

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 9f6cdc4..66e3c7c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -628,7 +628,7 @@ init_config(void)


 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
struct rte_port *port;

@@ -647,6 +647,7 @@ reconfig(portid_t new_port_id)
/* set flag to initialize port/queue */
port->need_reconfig = 1;
port->need_reconfig_queues = 1;
+   port->socket_id = socket_id;

init_port_config();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 142091d..7b78cc5 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -455,7 +455,7 @@ void fwd_config_display(void);
 void rxtx_config_display(void);
 void fwd_config_setup(void);
 void set_def_fwd_config(void);
-void reconfig(portid_t new_port_id);
+void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);

 void port_mtu_set(portid_t port_id, uint16_t mtu);
-- 
1.7.4.1



[dpdk-dev] [PATCH v3 1/5] bond: free mbufs if transmission fails in bonding tx_burst functions

2014-09-23 Thread Declan Doherty
Fixing a number of corner cases that if transmission failed on slave devices 
then this
could lead to leaked mbufs 

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   |  393 +++-
 app/test/virtual_pmd.c |   80 +--
 app/test/virtual_pmd.h |7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   83 ++--
 4 files changed, 525 insertions(+), 38 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index cce32ed..1a847eb 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -663,6 +663,9 @@ enable_bonded_slaves(void)
int i;

for (i = 0; i < test_params->bonded_slave_count; i++) {
+   
virtual_ethdev_tx_burst_fn_set_success(test_params->slave_port_ids[i],
+   1);
+
virtual_ethdev_simulate_link_status_interrupt(
test_params->slave_port_ids[i], 1);
}
@@ -1413,6 +1416,135 @@ test_roundrobin_tx_burst(void)
 }

 static int
+verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
+{
+   int i, refcnt;
+
+   for (i = 0; i < nb_mbufs; i++) {
+   refcnt = rte_mbuf_refcnt_read(mbufs[i]);
+   TEST_ASSERT_EQUAL(refcnt, val,
+   "mbuf ref count (%d)is not the expected value (%d)",
+   refcnt, val);
+   }
+   return 0;
+}
+
+
+static void
+free_mbufs(struct rte_mbuf **mbufs, int nb_mbufs)
+{
+   int i;
+
+   for (i = 0; i < nb_mbufs; i++)
+   rte_pktmbuf_free(mbufs[i]);
+}
+
+#define TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT  (2)
+#define TEST_RR_SLAVE_TX_FAIL_BURST_SIZE   (64)
+#define TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT(22)
+#define TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX(1)
+
+static int
+test_roundrobin_tx_burst_slave_tx_fail(void)
+{
+   struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
+   struct rte_mbuf *expected_tx_fail_pkts[MAX_PKT_BURST];
+
+   struct rte_eth_stats port_stats;
+
+   int i, first_fail_idx, tx_count;
+
+   TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+   BONDING_MODE_ROUND_ROBIN, 0,
+   TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+   "Failed to intialise bonded device");
+
+   /* Generate test bursts of packets to transmit */
+   TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE, 0, 1, 0, 0, 0),
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE,
+   "Failed to generate test packet burst");
+
+   /* Copy references to packets which we expect not to be transmitted */
+   first_fail_idx = (TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   (TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT *
+   TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)) +
+   TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX;
+
+   for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+   expected_tx_fail_pkts[i] = pkt_burst[first_fail_idx +
+   (i * TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)];
+   }
+
+   /* Set virtual slave to only fail transmission of
+* TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT packets in burst */
+   virtual_ethdev_tx_burst_fn_set_success(
+   
test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+   0);
+
+   virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+   
test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+   tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE);
+
+   TEST_ASSERT_EQUAL(tx_count, TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+   "Transmitted (%d) an unexpected (%d) number of 
packets", tx_count,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+   /* Verify that failed packet are expected failed packets */
+   for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+   TEST_ASSERT_EQUAL(expected_tx_fail_pkts[i], pkt_burst[i + 
tx_count],
+   "expected mbuf (%d) pointer %p not expected 
pointer %p",
+   i, expected_tx_fail_pkts[i], pkt_burst[i + 
tx_count]);
+   }
+
+   /* Verify bonded port tx stats */
+   rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+   TEST_ASSERT_EQUAL(port_stats.opackets,
+   (uint64_t)TEST

[dpdk-dev] [PATCH v3 4/5] bond: lsc polling support

2014-09-23 Thread Declan Doherty
Adds link status polling functionality to bonding device as well as API
to set polling interval and link up / down propagation delay.
Also contains unit tests for testing polling functionailty.


Signed-off-by: Declan Doherty 
---
 app/test/test.h|7 +-
 app/test/test_link_bonding.c   |  258 ---
 app/test/virtual_pmd.c |   17 +-
 app/test/virtual_pmd.h |   48 +++-
 lib/librte_pmd_bond/rte_eth_bond.h |   80 ++
 lib/librte_pmd_bond/rte_eth_bond_api.c |  309 +++
 lib/librte_pmd_bond/rte_eth_bond_args.c|   30 ++-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  387 +---
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 --
 9 files changed, 861 insertions(+), 346 deletions(-)

diff --git a/app/test/test.h b/app/test/test.h
index 98ab804..24b1640 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -62,14 +62,15 @@

 #define TEST_ASSERT_SUCCESS(val, msg, ...) do {
\
if (!(val == 0)) {  
\
-   printf("TestCase %s() line %d failed: " 
\
-   msg "\n", __func__, __LINE__, ##__VA_ARGS__);   
\
+   printf("TestCase %s() line %d failed (err %d): "
\
+   msg "\n", __func__, __LINE__, val,  
\
+   ##__VA_ARGS__); 
\
return -1;  
\
}   
\
 } while (0)

 #define TEST_ASSERT_FAIL(val, msg, ...) do {   
\
-   if (!(val != -1)) { 
\
+   if (!(val != 0)) {  
\
printf("TestCase %s() line %d failed: " 
\
msg "\n", __func__, __LINE__, ##__VA_ARGS__);   
\
return -1;  
\
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 50355a3..c32b685 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -234,42 +234,34 @@ configure_ethdev(uint8_t port_id, uint8_t start, uint8_t 
en_isr)
else
default_pmd_conf.intr_conf.lsc = 0;

-   if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
-   test_params->nb_tx_q, &default_pmd_conf) != 0) {
-   goto error;
-   }
+   TEST_ASSERT_SUCCESS(rte_eth_dev_configure(port_id, test_params->nb_rx_q,
+   test_params->nb_tx_q, &default_pmd_conf),
+   "rte_eth_dev_configure for port %d failed", port_id);

-   for (q_id = 0; q_id < test_params->nb_rx_q; q_id++) {
-   if (rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
+   for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
+   TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, 
RX_RING_SIZE,
rte_eth_dev_socket_id(port_id), 
&rx_conf_default,
-   test_params->mbuf_pool) < 0) {
-   goto error;
-   }
-   }
+   test_params->mbuf_pool) ,
+   "rte_eth_rx_queue_setup for port %d failed", 
port_id);

-   for (q_id = 0; q_id < test_params->nb_tx_q; q_id++) {
-   if (rte_eth_tx_queue_setup(port_id, q_id, TX_RING_SIZE,
-   rte_eth_dev_socket_id(port_id), 
&tx_conf_default) < 0) {
-   printf("Failed to setup tx queue (%d).\n", q_id);
-   goto error;
-   }
-   }
+   for (q_id = 0; q_id < test_params->nb_tx_q; q_id++)
+   TEST_ASSERT_SUCCESS(rte_eth_tx_queue_setup(port_id, q_id, 
TX_RING_SIZE,
+   rte_eth_dev_socket_id(port_id), 
&tx_conf_default),
+   "rte_eth_tx_queue_setup for port %d failed", 
port_id);

-   if (start) {
-   if (rte_eth_dev_start(port_id) < 0) {
-   printf("Failed to start device (%d).\n", port_id);
-   goto error;
-   }
-   }
-   re

[dpdk-dev] [PATCH v3 5/5] bond: unit test test macro refactor

2014-09-23 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c | 2574 +-
 1 files changed, 1036 insertions(+), 1538 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index c32b685..c4fcaf7 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -31,6 +31,7 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include "unistd.h"
 #include 
 #include 
 #include 
@@ -265,7 +266,7 @@ static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER;
 static int
 test_setup(void)
 {
-   int i, retval, nb_mbuf_per_pool;
+   int i, nb_mbuf_per_pool;
struct ether_addr *mac_addr = (struct ether_addr *)slave_mac;

/* Allocate ethernet packet header with space for VLAN header */
@@ -273,10 +274,8 @@ test_setup(void)
test_params->pkt_eth_hdr = malloc(sizeof(struct ether_hdr) +
sizeof(struct vlan_hdr));

-   if (test_params->pkt_eth_hdr == NULL) {
-   printf("ethernet header struct allocation failed!\n");
-   return -1;
-   }
+   TEST_ASSERT_NOT_NULL(test_params->pkt_eth_hdr,
+   "Ethernet header struct allocation failed!");
}

nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX + DEF_PKT_BURST +
@@ -286,10 +285,8 @@ test_setup(void)
MBUF_SIZE, MBUF_CACHE_SIZE, sizeof(struct 
rte_pktmbuf_pool_private),
rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, 
NULL,
rte_socket_id(), 0);
-   if (test_params->mbuf_pool == NULL) {
-   printf("rte_mempool_create failed\n");
-   return -1;
-   }
+   TEST_ASSERT_NOT_NULL(test_params->mbuf_pool,
+   "rte_mempool_create failed");
}

/* Create / Initialize virtual eth devs */
@@ -303,20 +300,12 @@ test_setup(void)

test_params->slave_port_ids[i] = 
virtual_ethdev_create(pmd_name,
mac_addr, rte_socket_id(), 1);
-   if (test_params->slave_port_ids[i] < 0) {
-   printf("Failed to create virtual virtual ethdev 
%s\n", pmd_name);
-   return -1;
-   }
+   TEST_ASSERT(test_params->slave_port_ids[i] >= 0,
+   "Failed to create virtual virtual 
ethdev %s", pmd_name);

-   printf("Created virtual ethdev %s\n", pmd_name);
-
-   retval = 
configure_ethdev(test_params->slave_port_ids[i], 1, 0);
-   if (retval != 0) {
-   printf("Failed to configure virtual ethdev 
%s\n", pmd_name);
-   return -1;
-   }
-
-   printf("Configured virtual ethdev %s\n", pmd_name);
+   TEST_ASSERT_SUCCESS(configure_ethdev(
+   test_params->slave_port_ids[i], 1, 0),
+   "Failed to configure virtual ethdev 
%s", pmd_name);
}
slaves_initialized = 1;
}
@@ -350,14 +339,14 @@ test_create_bonded_device(void)
current_slave_count = 
rte_eth_bond_slaves_get(test_params->bonded_port_id,
slaves, RTE_MAX_ETHPORTS);

-   TEST_ASSERT(current_slave_count == 0,
+   TEST_ASSERT_EQUAL(current_slave_count, 0,
"Number of slaves %d is great than expected %d.",
current_slave_count, 0);

current_slave_count = rte_eth_bond_active_slaves_get(
test_params->bonded_port_id, slaves, RTE_MAX_ETHPORTS);

-   TEST_ASSERT(current_slave_count == 0,
+   TEST_ASSERT_EQUAL(current_slave_count, 0,
"Number of active slaves %d is great than expected %d.",
current_slave_count, 0);

@@ -375,30 +364,21 @@ test_create_bonded_device_with_invalid_params(void)
/* Invalid name */
port_id = rte_eth_bond_create(NULL, test_params->bonding_mode,
rte_socket_id());
-   if (port_id >= 0) {
-   printf("Created bonded device unexpectedly.\n");
-   return -1;
-   }
+   TEST_ASSERT(port_id < 0, "Created bonded device unexpectedly");

test_params->bonding_mode = INVALID_BONDING_MODE;

/* Invalid bonding mode */
port_id = rte_eth_bond_create(BONDED_DEV_NAME, 
test_params->bonding_mode,

[dpdk-dev] [PATCH v3 0/5] link bonding

2014-09-23 Thread Declan Doherty
This patch set contains a typo fix for the bond free mbufs patch aswell
as updates to the test app patch to rebase for changes in the mbuf patches
. It also contains a patch to add support for slave devices which don't
support link status interrupts and also a patch to tidy up the link bonding
unit test so that all tests use the new test macros.

Declan Doherty (5):
  bond: free mbufs if transmission fails in bonding tx_burst functions
  test app: adding support for generating variable sized packet
  testpmd: adding parameter to reconfig method to set socket_id when
adding new port to portlist
  bond: lsc polling support
  bond: unit test test macro refactor

 app/test-pmd/cmdline.c |2 +-
 app/test-pmd/testpmd.c |3 +-
 app/test-pmd/testpmd.h |2 +-
 app/test/packet_burst_generator.c  |   25 +-
 app/test/packet_burst_generator.h  |6 +-
 app/test/test.h|7 +-
 app/test/test_link_bonding.c   | 3245 ++--
 app/test/virtual_pmd.c |   97 +-
 app/test/virtual_pmd.h |   53 +-
 lib/librte_pmd_bond/rte_eth_bond.h |   80 +
 lib/librte_pmd_bond/rte_eth_bond_api.c |  309 ++-
 lib/librte_pmd_bond/rte_eth_bond_args.c|   30 +-
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  470 +++-
 lib/librte_pmd_bond/rte_eth_bond_private.h |   71 +-
 14 files changed, 2450 insertions(+), 1950 deletions(-)

-- 
1.7.4.1



[dpdk-dev] [PATCH v3 2/5] test app: adding support for generating variable sized packet

2014-09-23 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test/packet_burst_generator.c |   25 -
 app/test/packet_burst_generator.h |6 +-
 app/test/test_link_bonding.c  |   14 +-
 3 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index 9e747a4..b2824dc 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -74,8 +74,7 @@ static inline void
 copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
 {
if (offset + len <= pkt->data_len) {
-   rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset,
-   buf, (size_t) len);
+   rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset, buf, 
(size_t) len);
return;
}
copy_buf_to_pkt_segs(buf, len, pkt, offset);
@@ -191,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t 
src_addr,
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */

-#define TXONLY_DEF_PACKET_LEN 64
-#define TXONLY_DEF_PACKET_LEN_128 128
-
-uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;
-uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {
-   TXONLY_DEF_PACKET_LEN_128,
-};
-
-uint8_t  tx_pkt_nb_segs = 1;

 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst)
+   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+   uint8_t pkt_len, uint8_t nb_pkt_segs)
 {
int i, nb_pkt = 0;
size_t eth_hdr_size;
@@ -221,9 +212,9 @@ nomore_mbuf:
break;
}

-   pkt->data_len = tx_pkt_seg_lengths[0];
+   pkt->data_len = pkt_len;
pkt_seg = pkt;
-   for (i = 1; i < tx_pkt_nb_segs; i++) {
+   for (i = 1; i < nb_pkt_segs; i++) {
pkt_seg->next = rte_pktmbuf_alloc(mp);
if (pkt_seg->next == NULL) {
pkt->nb_segs = i;
@@ -231,7 +222,7 @@ nomore_mbuf:
goto nomore_mbuf;
}
pkt_seg = pkt_seg->next;
-   pkt_seg->data_len = tx_pkt_seg_lengths[i];
+   pkt_seg->data_len = pkt_len;
}
pkt_seg->next = NULL; /* Last segment of packet. */

@@ -259,8 +250,8 @@ nomore_mbuf:
 * Complete first mbuf of packet and append it to the
 * burst of packets to be transmitted.
 */
-   pkt->nb_segs = tx_pkt_nb_segs;
-   pkt->pkt_len = tx_pkt_length;
+   pkt->nb_segs = nb_pkt_segs;
+   pkt->pkt_len = pkt_len;
pkt->l2_len = eth_hdr_size;

if (ipv4) {
diff --git a/app/test/packet_burst_generator.h 
b/app/test/packet_burst_generator.h
index 5b3cd6c..f86589e 100644
--- a/app/test/packet_burst_generator.h
+++ b/app/test/packet_burst_generator.h
@@ -47,6 +47,9 @@ extern "C" {
 #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \
((c & 0xff) << 8) | (d & 0xff))

+#define PACKET_BURST_GEN_PKT_LEN 60
+#define PACKET_BURST_GEN_PKT_LEN_128 128
+

 void
 initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
@@ -68,7 +71,8 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t 
src_addr,
 int
 generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr,
-   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst);
+   uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst,
+   uint8_t pkt_len, uint8_t nb_pkt_segs);

 #ifdef __cplusplus
 }
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 1a847eb..50355a3 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -1338,7 +1338,8 @@ generate_test_burst(struct rte_mbuf **pkts_burst, 
uint16_t burst_size,
/* Generate burst of packets to transmit */
generated_burst_size = generate_packet_burst(test_params->mbuf_pool,
pkts_burst, test_params->pkt_eth_hdr, vlan, ip_hdr, 
ipv4,
-   test_params->pkt_udp_hdr, burst_size);
+   test_params->pkt_udp_hdr, burst_size, 
PACKET_BURST_GEN_PKT_LEN_128,
+   1);
if (generated_burst_size != burst_size) {
printf("Failed to generate packet burst");
return -1;
@@ -2056,7 +20

[dpdk-dev] [PATCH v4 2/8] bond: removing switch statement from rx burst method

2014-09-30 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c | 62 +++---
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index aca2dcf..348e28f 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -59,33 +59,37 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, 
uint16_t nb_pkts)

internals = bd_rx_q->dev_private;

-   switch (internals->mode) {
-   case BONDING_MODE_ROUND_ROBIN:
-   case BONDING_MODE_BROADCAST:
-   case BONDING_MODE_BALANCE:
-   for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
-   /* Offset of pointer to *bufs increases as packets are 
received
-* from other slaves */
-   num_rx_slave = 
rte_eth_rx_burst(internals->active_slaves[i],
-   bd_rx_q->queue_id, bufs + num_rx_total, 
nb_pkts);
-   if (num_rx_slave) {
-   num_rx_total += num_rx_slave;
-   nb_pkts -= num_rx_slave;
-   }
+   for (i = 0; i < internals->active_slave_count && nb_pkts; i++) {
+   /* Offset of pointer to *bufs increases as packets are received
+* from other slaves */
+   num_rx_slave = rte_eth_rx_burst(internals->active_slaves[i],
+   bd_rx_q->queue_id, bufs + num_rx_total, 
nb_pkts);
+   if (num_rx_slave) {
+   num_rx_total += num_rx_slave;
+   nb_pkts -= num_rx_slave;
}
-   break;
-   case BONDING_MODE_ACTIVE_BACKUP:
-   num_rx_slave = rte_eth_rx_burst(internals->current_primary_port,
-   bd_rx_q->queue_id, bufs, nb_pkts);
-   if (num_rx_slave)
-   num_rx_total = num_rx_slave;
-   break;
}
+
return num_rx_total;
 }

 static uint16_t
-bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf **bufs,
+bond_ethdev_rx_burst_active_backup(void *queue, struct rte_mbuf **bufs,
+   uint16_t nb_pkts)
+{
+   struct bond_dev_private *internals;
+
+   /* Cast to structure, containing bonded device's port id and queue id */
+   struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)queue;
+
+   internals = bd_rx_q->dev_private;
+
+   return rte_eth_rx_burst(internals->current_primary_port,
+   bd_rx_q->queue_id, bufs, nb_pkts);
+}
+
+static uint16_t
+bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts)
 {
struct bond_dev_private *dev_private;
@@ -134,7 +138,7 @@ bond_ethdev_tx_round_robin(void *queue, struct rte_mbuf 
**bufs,
 }

 static uint16_t
-bond_ethdev_tx_active_backup(void *queue,
+bond_ethdev_tx_burst_active_backup(void *queue,
struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
struct bond_dev_private *internals;
@@ -270,7 +274,8 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t 
slave_count, uint8_t policy)
 }

 static uint16_t
-bond_ethdev_tx_balance(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
+   uint16_t nb_pkts)
 {
struct bond_dev_private *internals;
struct bond_tx_queue *bd_tx_q;
@@ -480,22 +485,25 @@ bond_ethdev_mode_set(struct rte_eth_dev *eth_dev, int 
mode)

switch (mode) {
case BONDING_MODE_ROUND_ROBIN:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_round_robin;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_round_robin;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
case BONDING_MODE_ACTIVE_BACKUP:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_active_backup;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_active_backup;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst_active_backup;
break;
case BONDING_MODE_BALANCE:
-   eth_dev->tx_pkt_burst = bond_ethdev_tx_balance;
+   eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_balance;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
case BONDING_MODE_BROADCAST:
eth_dev->tx_pkt_burst = bond_ethdev_tx_burst_broadcast;
+   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
break;
default:
return -1;
}

-   eth_dev->rx_pkt_burst = bond_ethdev_rx_burst;
internals->mode = mode;

return 0;
-- 
1.7.12.2



[dpdk-dev] [PATCH v4 1/8] bond: link status interrupt support

2014-09-30 Thread Declan Doherty
Adding support for lsc interrupt from bonded device to link
bonding library with supporting unit tests in the test application.

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   | 213 +++--
 lib/librte_pmd_bond/rte_eth_bond_api.c |   4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |   6 +
 3 files changed, 189 insertions(+), 34 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index db5b180..cce32ed 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -224,10 +225,15 @@ static struct rte_eth_txconf tx_conf_default = {
 };

 static int
-configure_ethdev(uint8_t port_id, uint8_t start)
+configure_ethdev(uint8_t port_id, uint8_t start, uint8_t en_isr)
 {
int q_id;

+   if (en_isr)
+   default_pmd_conf.intr_conf.lsc = 1;
+   else
+   default_pmd_conf.intr_conf.lsc = 0;
+
if (rte_eth_dev_configure(port_id, test_params->nb_rx_q,
test_params->nb_tx_q, &default_pmd_conf) != 0) {
goto error;
@@ -312,7 +318,7 @@ test_setup(void)

printf("Created virtual ethdev %s\n", pmd_name);

-   retval = 
configure_ethdev(test_params->slave_port_ids[i], 1);
+   retval = 
configure_ethdev(test_params->slave_port_ids[i], 1, 0);
if (retval != 0) {
printf("Failed to configure virtual ethdev 
%s\n", pmd_name);
return -1;
@@ -341,7 +347,7 @@ test_create_bonded_device(void)
TEST_ASSERT(test_params->bonded_port_id >= 0,
"Failed to create bonded ethdev %s", 
BONDED_DEV_NAME);

-   
TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
+   
TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0, 0),
"Failed to configure bonded ethdev %s", 
BONDED_DEV_NAME);
}

@@ -1078,12 +1084,12 @@ test_set_explicit_bonded_mac(void)


 static int
-initialize_bonded_device_with_slaves(uint8_t bonding_mode,
+initialize_bonded_device_with_slaves(uint8_t bonding_mode, uint8_t bond_en_isr,
uint8_t number_of_slaves, uint8_t enable_slave)
 {
/* configure bonded device */
-   TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0),
-   "Failed to configure bonding port (%d) in mode %d "
+   TEST_ASSERT_SUCCESS(configure_ethdev(test_params->bonded_port_id, 0,
+   bond_en_isr), "Failed to configure bonding port (%d) in 
mode %d "
"with (%d) slaves.", test_params->bonded_port_id, 
bonding_mode,
number_of_slaves);

@@ -1116,8 +1122,8 @@ test_adding_slave_after_bonded_device_started(void)
 {
int i;

-   if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 4, 
0) !=
-   0)
+   if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 0, 
4, 0)
+   != 0)
return -1;

/* Enabled slave devices */
@@ -1141,6 +1147,144 @@ test_adding_slave_after_bonded_device_started(void)
return remove_slaves_and_stop_bonded_device();
 }

+#define TEST_STATUS_INTERRUPT_SLAVE_COUNT  4
+#define TEST_LSC_WAIT_TIMEOUT_MS   500
+
+int test_lsc_interupt_count;
+
+static pthread_mutex_t mutex;
+static pthread_cond_t cvar;
+
+static void
+test_bonding_lsc_event_callback(uint8_t port_id __rte_unused,
+   enum rte_eth_event_type type  __rte_unused, void *param 
__rte_unused)
+{
+   pthread_mutex_lock(&mutex);
+   test_lsc_interupt_count++;
+
+   pthread_cond_signal(&cvar);
+   pthread_mutex_unlock(&mutex);
+}
+
+static inline int
+lsc_timeout(int wait_us)
+{
+   int retval = 0;
+
+   struct timespec ts;
+   struct timeval tp;
+
+   gettimeofday(&tp, NULL);
+
+   /* Convert from timeval to timespec */
+   ts.tv_sec  = tp.tv_sec;
+   ts.tv_nsec = tp.tv_usec * 1000;
+   ts.tv_nsec += wait_us * 1000;
+
+   pthread_mutex_lock(&mutex);
+   if (test_lsc_interupt_count < 1)
+   retval = pthread_cond_timedwait(&cvar, &mutex, &ts);
+
+   pthread_mutex_unlock(&mutex);
+
+   return retval;
+}
+
+static int
+test_status_interrupt(void)
+{
+   int slave_count;
+   uint8_t slaves[RTE_MAX_ETHPORTS];
+
+   pthread_mutex_init(&mutex, NULL);
+   pthread_cond_init(&cvar, NULL);
+
+   /* initialized bonding device with T slaves */
+   if (initialize_bonded_device_with_slaves(BONDING_MODE_ROUND_ROBIN, 1,
+   TEST_S

[dpdk-dev] [PATCH v4 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist

2014-09-30 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test-pmd/cmdline.c | 2 +-
 app/test-pmd/testpmd.c | 3 ++-
 app/test-pmd/testpmd.h | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 225f669..15ca493 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3614,7 +3614,7 @@ static void cmd_create_bonded_device_parsed(void 
*parsed_result,

/* Update number of ports */
nb_ports = rte_eth_dev_count();
-   reconfig(port_id);
+   reconfig(port_id, res->socket);
rte_eth_promiscuous_enable(port_id);
}

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 9f6cdc4..66e3c7c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -628,7 +628,7 @@ init_config(void)


 void
-reconfig(portid_t new_port_id)
+reconfig(portid_t new_port_id, unsigned socket_id)
 {
struct rte_port *port;

@@ -647,6 +647,7 @@ reconfig(portid_t new_port_id)
/* set flag to initialize port/queue */
port->need_reconfig = 1;
port->need_reconfig_queues = 1;
+   port->socket_id = socket_id;

init_port_config();
 }
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 9cbfeac..5a3423c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -457,7 +457,7 @@ void fwd_config_display(void);
 void rxtx_config_display(void);
 void fwd_config_setup(void);
 void set_def_fwd_config(void);
-void reconfig(portid_t new_port_id);
+void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);

 void port_mtu_set(portid_t port_id, uint16_t mtu);
-- 
1.7.12.2



[dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions

2014-09-30 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 app/test/test_link_bonding.c   | 393 -
 app/test/virtual_pmd.c |  80 +--
 app/test/virtual_pmd.h |   7 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  83 +--
 4 files changed, 525 insertions(+), 38 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index cce32ed..1a847eb 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -663,6 +663,9 @@ enable_bonded_slaves(void)
int i;

for (i = 0; i < test_params->bonded_slave_count; i++) {
+   
virtual_ethdev_tx_burst_fn_set_success(test_params->slave_port_ids[i],
+   1);
+
virtual_ethdev_simulate_link_status_interrupt(
test_params->slave_port_ids[i], 1);
}
@@ -1413,6 +1416,135 @@ test_roundrobin_tx_burst(void)
 }

 static int
+verify_mbufs_ref_count(struct rte_mbuf **mbufs, int nb_mbufs, int val)
+{
+   int i, refcnt;
+
+   for (i = 0; i < nb_mbufs; i++) {
+   refcnt = rte_mbuf_refcnt_read(mbufs[i]);
+   TEST_ASSERT_EQUAL(refcnt, val,
+   "mbuf ref count (%d)is not the expected value (%d)",
+   refcnt, val);
+   }
+   return 0;
+}
+
+
+static void
+free_mbufs(struct rte_mbuf **mbufs, int nb_mbufs)
+{
+   int i;
+
+   for (i = 0; i < nb_mbufs; i++)
+   rte_pktmbuf_free(mbufs[i]);
+}
+
+#define TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT  (2)
+#define TEST_RR_SLAVE_TX_FAIL_BURST_SIZE   (64)
+#define TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT(22)
+#define TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX(1)
+
+static int
+test_roundrobin_tx_burst_slave_tx_fail(void)
+{
+   struct rte_mbuf *pkt_burst[MAX_PKT_BURST];
+   struct rte_mbuf *expected_tx_fail_pkts[MAX_PKT_BURST];
+
+   struct rte_eth_stats port_stats;
+
+   int i, first_fail_idx, tx_count;
+
+   TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
+   BONDING_MODE_ROUND_ROBIN, 0,
+   TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT, 1),
+   "Failed to intialise bonded device");
+
+   /* Generate test bursts of packets to transmit */
+   TEST_ASSERT_EQUAL(generate_test_burst(pkt_burst,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE, 0, 1, 0, 0, 0),
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE,
+   "Failed to generate test packet burst");
+
+   /* Copy references to packets which we expect not to be transmitted */
+   first_fail_idx = (TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   (TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT *
+   TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)) +
+   TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX;
+
+   for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+   expected_tx_fail_pkts[i] = pkt_burst[first_fail_idx +
+   (i * TEST_RR_SLAVE_TX_FAIL_SLAVE_COUNT)];
+   }
+
+   /* Set virtual slave to only fail transmission of
+* TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT packets in burst */
+   virtual_ethdev_tx_burst_fn_set_success(
+   
test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+   0);
+
+   virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(
+   
test_params->slave_port_ids[TEST_RR_SLAVE_TX_FAIL_FAILING_SLAVE_IDX],
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+   tx_count = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkt_burst,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE);
+
+   TEST_ASSERT_EQUAL(tx_count, TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+   "Transmitted (%d) an unexpected (%d) number of 
packets", tx_count,
+   TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT);
+
+   /* Verify that failed packet are expected failed packets */
+   for (i = 0; i < TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT; i++) {
+   TEST_ASSERT_EQUAL(expected_tx_fail_pkts[i], pkt_burst[i + 
tx_count],
+   "expected mbuf (%d) pointer %p not expected 
pointer %p",
+   i, expected_tx_fail_pkts[i], pkt_burst[i + 
tx_count]);
+   }
+
+   /* Verify bonded port tx stats */
+   rte_eth_stats_get(test_params->bonded_port_id, &port_stats);
+
+   TEST_ASSERT_EQUAL(port_stats.opackets,
+   (uint64_t)TEST_RR_SLAVE_TX_FAIL_BURST_SIZE -
+   TEST_RR_SLAVE_TX_FAIL_PACKETS_COUNT,
+   "Bonded Port (%d) 

  1   2   3   4   5   6   >