Link Bonding Library
Re: [PATCH v7 3/6] EAL support for link bonding device initialization
In reply to a message not in the archiveHi Declan,
2014-06-24 17:03, Declan Doherty:
Quoted 4 lines
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.
[...]
Quoted 37 lines
lib/librte_eal/common/eal_common_dev.c +13
-9@@ -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,
lib/librte_eal/common/eal_common_dev.c rte_eal_dev_init(void) · line 103
Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +4
-3+ 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
Quoted 35 lines
lib/librte_eal/common/eal_common_dev.c +23
-6+* 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 found for bonded device %s\n" , + devargs->virtual.drv_name); + } } } -/* Once the vdevs are initalized, start calling all the pdev drivers */ - TAILQ_FOREACH(driver, &dev_driver_list, next) { -if (driver->type !=PMD_PDEV ) -continue ; -/* PDEV drivers don't get passed any parameters */ - driver->init (NULL ,NULL ); +/* Once the vdevs are initialized, start calling all the pdev drivers */ +if (init_pri ==PMD_INIT_PRE_PCI_PROBE ) { + TAILQ_FOREACH(driver, &dev_driver_list, next) { +if (driver->type !=PMD_PDEV ) +continue ; +/* PDEV drivers don't get passed any parameters */ + driver->init (NULL ,NULL ); + } }return 0 ;}
[...]
Quoted 23 lines
lib/librte_eal/linuxapp/eal/eal.c +2
-1@@ -75,6 +75,7 @@#include <rte_atomic.h> #include <malloc_heap.h> #include <rte_eth_ring.h> +#include <rte_dev.h> #include "eal_private.h" #include "eal_thread.h" @@ -1097,7 +1098,7 @@ rte_eal_init(int argc, char **argv)RTE_LOG (DEBUG ,EAL ,"Master core %u is ready (tid=%x)\n" , rte_config.master_lcore, (int )thread_id); -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) {@@ -1127,6 +1128,14 @@ rte_eal_init(int argc, char **argv)rte_eal_mp_remote_launch (sync_func,NULL ,SKIP_MASTER );rte_eal_mp_wait_lcore ();
lib/librte_eal/linuxapp/eal/eal.c rte_eal_init(int argc, char **argv) · line 1140
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal.c +8
-0+/* 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; }
Not sure to understand why you need to split rte_eal_dev_init() in 2 steps. Should it be possible to keep existing rte_eal_dev_init() behaviour and makes further initialization when calling rte_eth_dev_configure()?
I've seen it's empty for bonding device:
static intbond_ethdev_configure(struct rte_eth_dev *dev __rte_unused)
{
return 0;
}Thanks
Signature · 1 line
Thomas
Re: [PATCH v7 6/6] Link Bonding Library doxygen additions
In reply to Thomas MonjalonQuoted 7 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, June 25, 2014 2:44 PM
To: Doherty, Declan
Cc: [email protected]
Subject: Re: [PATCH v7 6/6] Link Bonding Library doxygen additions
Quoted 8 lines
Hi Declan,
Since bonding library is a PMD, there should have no need of integrate it in the API documentation.
I hadn't time to review it yet, so I would miss something.
Do you mean it can be used directly by the application with a specific API? In this case, you could explain it in the commit log.
Hi Thomas, the bonding library has a API which supports creation and management of bonded devices directly from within applications, but more importantly provides the APIs required to dynamically add and remove slaves from a bonded device, this functionality will be required to support live migration of VMs using bonded ports in a future releases.
Re: [PATCH v7 6/6] Link Bonding Library doxygen additions
In reply to a message not in the archive2014-06-25 14:19, Doherty, Declan:
Quoted 16 lines
Quoted 7 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, June 25, 2014 2:44 PM
To: Doherty, Declan
Cc: [email protected]
Subject: Re: [PATCH v7 6/6] Link Bonding Library doxygen additionsQuoted 8 lines
Hi Declan,
Since bonding library is a PMD, there should have no need of integrate it in the API documentation.
I hadn't time to review it yet, so I would miss something.
Do you mean it can be used directly by the application with a specific API?
In this case, you could explain it in the commit log.
Quoted 5 lines
Hi Thomas, the bonding library has a API which supports creation and management of bonded devices directly from within applications, but more importantly provides the APIs required to dynamically add and remove slaves from a bonded device, this functionality will be required to support live migration of VMs using bonded ports in a future releases.
OK. Could I suggest to split rte_eth_bond.c in 2 files?
1 file for the library matching the API and 1 file for the PMD layer? I feel it would be easier to read and maintain.
Thanks
Signature · 1 line
Thomas
Re: [PATCH v7 3/6] EAL support for link bonding device initialization
In reply to Thomas MonjalonQuoted 25 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, June 25, 2014 2:55 PM
To: Doherty, Declan
Cc: [email protected]
Subject: Re: [PATCH v7 3/6] EAL support for link bonding device initializationHi Declan,
2014-06-24 17:03, Declan Doherty:
Quoted 4 lines
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.
[...]
Not sure to understand why you need to split
rte_eal_dev_init()in 2 steps. Should it be possible to keep existingrte_eal_dev_init()behaviour and makes further initialization when callingrte_eth_dev_configure()?
I've seen it's empty for bonding device:
Quoted 3 lines
Thanks
--
Thomas
Hi Thomas, that need to split rte_eal_dev_init into 2 steps doesn't come explicitly from the bonded device itself, as a bonded device could be created at any time during initialization, the issue arises from the fact that none of physical devices are allocated/initialized until after pci_probe_all_drivers() is called, this puts an explicit constraint on when it is possible to create a bonded device which has physical devices as slaves, as the phyiscal devices don't exist at the initial call to rte_eal_dev_init() and therefore can't be added as slaves to the bonded device.
It isn't possible to keep the rte_eal_dev_init() behavior and use rte_eth_dev_configure() to complete initialization without radically changing the behavior of the bonding library, and the current functionality of
rte_eth_bond_slave_add(), as this would need to no longer actually add a slave,
but to save the name of a slave to be retrieved at some point in the future to be added as a slave to the bonded device.
Declan
Re: [PATCH v7 3/6] EAL support for link bonding device initialization
In reply to a message not in the archive2014-06-25 14:41, Doherty, Declan:
Quoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
Not sure to understand why you need to split
rte_eal_dev_init()in 2 steps.
Should it be possible to keep existingrte_eal_dev_init()behaviour and makes further initialization when callingrte_eth_dev_configure()?
I've seen it's empty for bonding device:
Quoted 15 lines
Hi Thomas, that need to split
rte_eal_dev_initinto 2 steps doesn't come explicitly from the bonded device itself, as a bonded device could be created at any time during initialization, the issue arises from the fact that none of physical devices are allocated/initialized until afterpci_probe_all_drivers()is called, this puts an explicit constraint on when it is possible to create a bonded device which has physical devices as slaves, as the phyiscal devices don't exist at the initial call torte_eal_dev_init()and therefore can't be added as slaves to the bonded device.
It isn't possible to keep therte_eal_dev_init()behavior and userte_eth_dev_configure()to complete initialization without radically changing the behavior of the bonding library, and the current functionality ofrte_eth_bond_slave_add(), as this would need to no longer actually add a slave, but to save the name of a slave to be retrieved at some point in the future to be added as a slave to the bonded device.
I'm sure it would be much cleaner if you split rte_eth_bond_slave_add() instead of splitting rte_eal_dev_init().
If I understand well, you should first save kvargs for slaves and add them at configure time.
Then you could remove PMD_BDEV type and use PMD_VDEV.
I know it's an additional work but API cleaning really deserves it.
Thanks
Signature · 1 line
Thomas
Re: [PATCH v7 3/6] EAL support for link bonding device initialization
Quoted 33 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Wednesday, June 25, 2014 9:01 AM
To: Doherty, Declan
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 3/6] EAL support for link bonding device initialization2014-06-25 14:41, Doherty, Declan:
Quoted 8 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
Not sure to understand why you need to split
rte_eal_dev_init()in 2 steps.
Should it be possible to keep existingrte_eal_dev_init()behaviour and makes further initialization when callingrte_eth_dev_configure()?
I've seen it's empty for bonding device:Quoted 15 lines
Hi Thomas, that need to split
rte_eal_dev_initinto 2 steps doesn't come explicitly from the bonded device itself, as a bonded device could be created at any time during initialization, the issue arises from the fact that none of physical devices are allocated/initialized until afterpci_probe_all_drivers()is called, this puts an explicit constraint on when it is possible to create a bonded device which has physical devices as slaves, as the phyiscal devices don't exist at the initial call torte_eal_dev_init()and therefore can't be added as slaves to the bonded device.
It isn't possible to keep therte_eal_dev_init()behavior and userte_eth_dev_configure()to complete initialization without radically changing the behavior of the bonding library, and the current functionality ofrte_eth_bond_slave_add(), as this would need to no longer actually add a slave, but to save the name of a slave to be retrieved at some point in the future to be added as a slave to the bonded device.
Quoted 9 lines
I'm sure it would be much cleaner if you split
rte_eth_bond_slave_add()instead of splittingrte_eal_dev_init().
If I understand well, you should first save kvargs for slaves and add them at configure time.Then you could remove
PMD_BDEVtype and usePMD_VDEV.I know it's an additional work but API cleaning really deserves it.
Or else we could just go back to the earlier versions of the submission and accept the fact that some types of devices are designed to be used from code via an API and that we don't need to be able to set up every type of device via the application command-line. The code for this feature and rework to EAL has just got continually more complicated every time due to the need to continually workaround gotchas when trying to enable this for second-level ethdevs.
/Bruce
v8 cover Link Bonding Library
In reply to a message not in the archiveThis 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
PATCH v8 1/6 Link Bonding Library (lib/librte_pmd_bond)
In reply to a message not in the archiveInitial 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
--- 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
config/common_bsdapp +5 -0
@@ -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
config/common_linuxapp +5 -0
@@ -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
lib/Makefile +1 -0
@@ -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
lib/librte_pmd_bond/Makefile new file +34 -0
@@ -0,0 +1,34 @@ +# <COPYRIGHT_TAG> + +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
lib/librte_pmd_bond/rte_eth_bond.h new file +255 -0
255 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_api.c new file +670 -0
670 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_pmd.c new file +1228 -0
1,228 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_private.h new file +218 -0
218 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_vargs.c new file +255 -0
255 lines not on this page · raw message
mk/rte.app.mk +5 -0
@@ -205,8 +205,13 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) LDLIBS += -lrte_pmd_pcap -lpcap endif +ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y) +LDLIBS += -lrte_pmd_bond endif +endif + + LDLIBS += $(EXECENV_LDLIBS) LDLIBS += --end-group
Signature · 1 line
1.7.0.7
PATCH v8 2/6 Support for unique interface naming of pmds
In reply to a message not in the archiveAdding 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.
--- 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(-)
lib/librte_ether/rte_ethdev.c +29 -3
@@ -65,6 +65,7 @@#include <rte_mbuf.h> #include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_string_fns.h> #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 ;
lib/librte_ether/rte_ethdev.h +6 -1
@@ -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 name Unique 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 ;/**
lib/librte_pmd_pcap/rte_eth_pcap.c +11 -11
@@ -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 unsigned nb_tx_queues, const unsigned numa_node, struct pmd_internals **internals,
@@ -558,20 +558,20 @@ rte_pmd_init_internals(const unsigned nb_rx_queues,/* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data =rte_zmalloc_socket (NULL ,sizeof (*data),0 , numa_node); + data =rte_zmalloc_socket (name,sizeof (*data),0 , numa_node);if (data ==NULL ) goto error; - pci_dev =rte_zmalloc_socket (NULL ,sizeof (*pci_dev),0 , numa_node); + pci_dev =rte_zmalloc_socket (name,sizeof (*pci_dev),0 , numa_node);if (pci_dev ==NULL ) goto error; - *internals =rte_zmalloc_socket (NULL ,sizeof (**internals),0 , numa_node); + *internals =rte_zmalloc_socket (name,sizeof (**internals),0 , numa_node);if (*internals ==NULL ) goto error;/* reserve an ethdev entry */ - *eth_dev =rte_eth_dev_allocate (); + *eth_dev =rte_eth_dev_allocate (name);if (*eth_dev ==NULL ) goto error;
@@ -617,7 +617,7 @@ rte_pmd_init_internals(const unsigned nb_rx_queues, } static int -rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[], +rte_eth_from_pcaps_n_dumpers(const char *name, pcap_t * const rx_queues[], const unsigned nb_rx_queues, pcap_dumper_t * const tx_queues[], const unsigned nb_tx_queues,
@@ -634,7 +634,7 @@ rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[],if (tx_queues ==NULL && nb_tx_queues >0 )return -1 ; -if (rte_pmd_init_internals (nb_rx_queues, nb_tx_queues, numa_node, +if (rte_pmd_init_internals (name, nb_rx_queues, nb_tx_queues, numa_node, &internals, ð_dev, kvlist) <0 )return -1 ;
@@ -652,7 +652,7 @@ rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[], } static int -rte_eth_from_pcaps(pcap_t * const rx_queues[], +rte_eth_from_pcaps(const char *name, pcap_t * const rx_queues[], const unsigned nb_rx_queues, pcap_t * const tx_queues[], const unsigned nb_tx_queues,
@@ -669,7 +669,7 @@ rte_eth_from_pcaps(pcap_t * const rx_queues[],if (tx_queues ==NULL && nb_tx_queues >0 )return -1 ; -if (rte_pmd_init_internals (nb_rx_queues, nb_tx_queues, numa_node, +if (rte_pmd_init_internals (name, nb_rx_queues, nb_tx_queues, numa_node, &internals, ð_dev, kvlist) <0 )return -1 ;
@@ -760,10 +760,10 @@ rte_pmd_pcap_devinit(const char *name, const char *params)return -1 ;if (using_dumpers) -return rte_eth_from_pcaps_n_dumpers (pcaps.pcaps, pcaps.num_of_rx, +return rte_eth_from_pcaps_n_dumpers (name, pcaps.pcaps, pcaps.num_of_rx, dumpers.dumpers, dumpers.num_of_tx, numa_node, kvlist); -return rte_eth_from_pcaps (pcaps.pcaps, pcaps.num_of_rx, dumpers.pcaps, +return rte_eth_from_pcaps (name, pcaps.pcaps, pcaps.num_of_rx, dumpers.pcaps, dumpers.num_of_tx, numa_node, kvlist); }
lib/librte_pmd_ring/rte_eth_ring.c +17 -15
@@ -219,7 +219,7 @@ static struct eth_dev_ops ops = { }; int -rte_eth_from_rings(struct rte_ring *const rx_queues[], +rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], const unsigned nb_rx_queues, struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
@@ -243,20 +243,20 @@ rte_eth_from_rings(struct rte_ring *const rx_queues[],/* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data =rte_zmalloc_socket (NULL ,sizeof (*data),0 , numa_node); + data =rte_zmalloc_socket (name,sizeof (*data),0 , numa_node);if (data ==NULL ) goto error; - pci_dev =rte_zmalloc_socket (NULL ,sizeof (*pci_dev),0 , numa_node); + pci_dev =rte_zmalloc_socket (name,sizeof (*pci_dev),0 , numa_node);if (pci_dev ==NULL ) goto error; - internals =rte_zmalloc_socket (NULL ,sizeof (*internals),0 , numa_node); + internals =rte_zmalloc_socket (name,sizeof (*internals),0 , numa_node);if (internals ==NULL ) goto error;/* reserve an ethdev entry */ - eth_dev =rte_eth_dev_allocate (); + eth_dev =rte_eth_dev_allocate (name);if (eth_dev ==NULL ) goto error;
@@ -335,7 +335,7 @@ eth_dev_ring_create(const char *name, const unsigned numa_node,return -1 ; } -if (rte_eth_from_rings (rxtx, num_rings, rxtx, num_rings, numa_node)) +if (rte_eth_from_rings (name, rxtx, num_rings, rxtx, num_rings, numa_node))return -1 ;return 0 ;
@@ -352,29 +352,31 @@ eth_dev_ring_pair_create(const char *name, const unsigned numa_node,struct rte_ring *rx[RTE_PMD_RING_MAX_RX_RINGS ];struct rte_ring *tx[RTE_PMD_RING_MAX_TX_RINGS ];unsigned i; -char rng_name[RTE_RING_NAMESIZE ]; +char rx_rng_name[RTE_RING_NAMESIZE ]; +char tx_rng_name[RTE_RING_NAMESIZE ];unsigned num_rings =RTE_MIN (RTE_PMD_RING_MAX_RX_RINGS ,RTE_PMD_RING_MAX_TX_RINGS );for (i =0 ; i < num_rings; i++) { -rte_snprintf (rng_name,sizeof (rng_name),"ETH_RX%u_%s" , i, name); +rte_snprintf (rx_rng_name,sizeof (rx_rng_name),"ETH_RX%u_%s" , i, name); rx[i] = (action ==DEV_CREATE ) ? -rte_ring_create (rng_name,1024 , numa_node, +rte_ring_create (rx_rng_name,1024 , numa_node,RING_F_SP_ENQ |RING_F_SC_DEQ ) : -rte_ring_lookup (rng_name); +rte_ring_lookup (rx_rng_name);if (rx[i] ==NULL )return -1 ; -rte_snprintf (rng_name,sizeof (rng_name),"ETH_TX%u_%s" , i, name); +rte_snprintf (tx_rng_name,sizeof (tx_rng_name),"ETH_TX%u_%s" , i, name); tx[i] = (action ==DEV_CREATE ) ? -rte_ring_create (rng_name,1024 , numa_node, +rte_ring_create (tx_rng_name,1024 , numa_node,RING_F_SP_ENQ |RING_F_SC_DEQ ): -rte_ring_lookup (rng_name); +rte_ring_lookup (tx_rng_name);if (tx[i] ==NULL )return -1 ; } -if (rte_eth_from_rings (rx, num_rings, tx, num_rings, numa_node) || -rte_eth_from_rings (tx, num_rings, rx, num_rings, numa_node) ) +if (rte_eth_from_rings (rx_rng_name, rx, num_rings, tx, num_rings, + numa_node) ||rte_eth_from_rings (tx_rng_name, tx, num_rings, rx, + num_rings, numa_node))return -1 ;return 0 ;
lib/librte_pmd_ring/rte_eth_ring.h +2 -1
@@ -40,7 +40,8 @@ extern "C" {#include <rte_ring.h> -int rte_eth_from_rings(struct rte_ring * const rx_queues[], +int rte_eth_from_rings(const char *name, + struct rte_ring * const rx_queues[], const unsigned nb_rx_queues, struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
lib/librte_pmd_xenvirt/rte_eth_xenvirt.c +1 -1
@@ -647,7 +647,7 @@ eth_dev_xenvirt_create(const char *name, const char *params, goto err;/* reserve an ethdev entry */ - eth_dev =rte_eth_dev_allocate (); + eth_dev =rte_eth_dev_allocate (name);if (eth_dev ==NULL ) goto err;
Signature · 1 line
1.7.0.7
PATCH v8 3/6 EAL support for link bonding device initialization
In reply to a message not in the archiveUpdating 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.
--- 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(-)
lib/librte_eal/bsdapp/eal/eal.c +9 -1
@@ -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; }
lib/librte_eal/common/eal_common_dev.c +40 -18
77 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +3 -0
@@ -150,6 +150,9 @@ rte_eal_pci_probe(void) probe_all =1 ; TAILQ_FOREACH(dev, &pci_device_list, next) { +/* check if device has already been initialized */ +if (dev->driver !=NULL ) +continue ;/* set devargs in PCI structure */ devargs =pci_devargs_lookup (dev);
lib/librte_eal/common/include/eal_private.h +0 -7
@@ -196,11 +196,4 @@ int rte_eal_intr_init(void);*/ int rte_eal_alarm_init (void ); -/** -* This function initialises any virtual devices -* -* This function is private to the EAL. -*/ -int rte_eal_dev_init (void ); -#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/common/include/rte_dev.h +11 -2
@@ -62,6 +62,15 @@ typedef int (rte_dev_init_t)(const char *name, const char *args);enum pmd_type {PMD_VDEV =0 ,PMD_PDEV =1 , +PMD_BDEV =2 ,/**< Poll Mode Driver Bonded Device*/ +}; + +#define RTE_PMD_BOND ("eth_bond") +/** +* Driver initialization */ +enum pmd_init_priority { +PMD_INIT_PRE_PCI_PROBE =0 , +PMD_INIT_POST_PCI_PROBE =1 , };/**
@@ -93,9 +102,9 @@ void rte_eal_driver_register(struct rte_driver *driver);void rte_eal_driver_unregister (struct rte_driver *driver);/** -* Initalize all the registered drivers in this process +* Initialize all the registered drivers in this process */ -int rte_eal_dev_init (void ); +int rte_eal_dev_init (uint8_t init_priority);#define PMD_REGISTER_DRIVER (d)\ void devinitfn_ ##d(void);\
lib/librte_eal/linuxapp/eal/eal.c +10 -1
@@ -75,6 +75,7 @@#include <rte_atomic.h> #include <malloc_heap.h> #include <rte_eth_ring.h> +#include <rte_dev.h> #include "eal_private.h" #include "eal_thread.h"
@@ -1097,7 +1098,7 @@ rte_eal_init(int argc, char **argv)RTE_LOG (DEBUG ,EAL ,"Master core %u is ready (tid=%x)\n" , rte_config.master_lcore, (int )thread_id); -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) {
@@ -1127,6 +1128,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; }
Signature · 1 line
1.7.0.7
PATCH v8 4/6 Link bonding Unit Tests
In reply to a message not in the archiveIncluding:
- 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
--- 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
app/test/Makefile +3 -1
@@ -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
app/test/commands.c +7 -0
@@ -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#"
app/test/packet_burst_generator.c new file +287 -0
287 lines not on this page · raw message
app/test/packet_burst_generator.h new file +78 -0
78 lines not on this page · raw message
app/test/test.h +1 -0
@@ -97,6 +97,7 @@ int test_distributor(void);int test_distributor_perf (void );int test_kvargs (void );int test_devargs (void ); +int test_link_bonding (void );int test_pci_run;
app/test/test_link_bonding.c new file +3958 -0
2,599 lines not on this page · raw message
app/test/virtual_pmd.c new file +574 -0
574 lines not on this page · raw message
app/test/virtual_pmd.h new file +74 -0
74 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.0.7
Part of the diff is not shown here. View the raw message.
PATCH v8 5/6 testpmd link bonding additions
In reply to a message not in the archive - 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
--- 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(-)
app/test-pmd/cmdline.c +579 -0
@@ -84,6 +84,9 @@#include <cmdline_socket.h> #include <cmdline.h> #include <rte_pci_dev_ids.h> +#ifdef RTE_LIBRTE_PMD_BOND +#include <rte_eth_bond.h> +#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 { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t balance_xmit_policy; +uint8_t port_id; +cmdline_fixed_string_t policy; +}; + +static void cmd_set_bonding_balance_xmit_policy_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; +portid_t port_id = res->port_id; +uint8_t policy; + +if (!strcmp (res->policy,"l2" )) { + policy =BALANCE_XMIT_POLICY_LAYER2 ; + }else if (!strcmp (res->policy,"l23" )) { + policy =BALANCE_XMIT_POLICY_LAYER23 ; + }else if (!strcmp (res->policy,"l34" )) { + policy =BALANCE_XMIT_POLICY_LAYER34 ; + }else { +printf ("\t Invalid xmit policy selection" ); +return ; + } + +/* Set the bonding mode for the relevant port. */ +if (0 !=rte_eth_bond_xmit_policy_set (port_id, policy)) { +printf ("\t Failed to set bonding balance xmit policy for port = %d.\n" , + port_id); + } +} + +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + set,"set" ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + balance_xmit_policy,"balance_xmit_policy" ); +cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + port_id,UINT8 ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + policy,"l2#l23#l34" ); + +cmdline_parse_inst_t cmd_set_balance_xmit_policy = { + .f = cmd_set_bonding_balance_xmit_policy_parsed, + .help_str ="set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_setbonding_balance_xmit_policy_set, + (void *)&cmd_setbonding_balance_xmit_policy_bonding, + (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, + (void *)&cmd_setbonding_balance_xmit_policy_port, + (void *)&cmd_setbonding_balance_xmit_policy_policy, +NULL + } +}; + +/* *** SHOW NIC BONDING CONFIGURATION *** */ +struct cmd_show_bonding_config_result { +cmdline_fixed_string_t show; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t config; +uint8_t port_id; +}; + +static void cmd_show_bonding_config_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_show_bonding_config_result *res = parsed_result; +int bonding_mode; +uint8_t slaves[RTE_MAX_ETHPORTS ]; +int num_slaves, num_active_slaves; +int primary_id; +int i; +portid_t port_id = res->port_id; + +/* Display the bonding mode.*/ + bonding_mode =rte_eth_bond_mode_get (port_id); +if (bonding_mode <0 ) { +printf ("\tFailed to get bonding mode for port = %d\n" , port_id); +return ; + }else +printf ("\tBonding mode: %d\n" , bonding_mode); + +if (bonding_mode ==BONDING_MODE_BALANCE ) { +int balance_xmit_policy; + + balance_xmit_policy =rte_eth_bond_xmit_policy_get (port_id); +if (balance_xmit_policy <0 ) { +printf ("\tFailed to get balance xmit policy for port = %d\n" , + port_id); +return ; + }else { +printf ("\tBalance Xmit Policy: " ); + +switch (balance_xmit_policy) { +case BALANCE_XMIT_POLICY_LAYER2 : +printf ("BALANCE_XMIT_POLICY_LAYER2" ); +break ; +case BALANCE_XMIT_POLICY_LAYER23 : +printf ("BALANCE_XMIT_POLICY_LAYER23" ); +break ; +case BALANCE_XMIT_POLICY_LAYER34 : +printf ("BALANCE_XMIT_POLICY_LAYER34" ); +break ; + } +printf ("\n" ); + } + } + + num_slaves =rte_eth_bond_slaves_get (port_id, slaves,RTE_MAX_ETHPORTS ); + +if (num_slaves <0 ) { +printf ("\tFailed to get slave list for port = %d\n" , port_id); +return ; + } +if (num_slaves >0 ) { +printf ("\tSlaves (%d): [" , num_slaves); +for (i =0 ; i < num_slaves -1 ; i++) +printf ("%d " , slaves[i]); + +printf ("%d]\n" , slaves[num_slaves -1 ]); + }else { +printf ("\tSlaves: []\n" ); + + } + + num_active_slaves =rte_eth_bond_active_slaves_get (port_id, slaves, +RTE_MAX_ETHPORTS ); + +if (num_active_slaves <0 ) { +printf ("\tFailed to get active slave list for port = %d\n" , port_id); +return ; + } +if (num_active_slaves >0 ) { +printf ("\tActive Slaves (%d): [" , num_active_slaves); +for (i =0 ; i < num_active_slaves -1 ; i++) +printf ("%d " , slaves[i]); + +printf ("%d]\n" , slaves[num_active_slaves -1 ]); + + }else { +printf ("\tActive Slaves: []\n" ); + + } + + primary_id =rte_eth_bond_primary_get (port_id); +if (primary_id <0 ) { +printf ("\tFailed to get primary slave for port = %d\n" , port_id); +return ; + }else +printf ("\tPrimary: [%d]\n" , primary_id); + +} + +cmdline_parse_token_string_t cmd_showbonding_config_show = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + show,"show" ); +cmdline_parse_token_string_t cmd_showbonding_config_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_showbonding_config_config = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + config,"config" ); +cmdline_parse_token_num_t cmd_showbonding_config_port = +TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_show_bonding_config = { + .f = cmd_show_bonding_config_parsed, + .help_str ="show bonding config (port_id): Show the bonding config for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_showbonding_config_show, + (void *)&cmd_showbonding_config_bonding, + (void *)&cmd_showbonding_config_config, + (void *)&cmd_showbonding_config_port, +NULL + } +}; + +/* *** SET BONDING PRIMARY *** */ +struct cmd_set_bonding_primary_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t primary; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_set_bonding_primary_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bonding_primary_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_primary_set (master_port_id, slave_port_id)) { +printf ("\t Failed to set primary slave for port = %d.\n" , + master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_setbonding_primary_set = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + set,"set" ); +cmdline_parse_token_string_t cmd_setbonding_primary_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_setbonding_primary_primary = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + primary,"primary" ); +cmdline_parse_token_num_t cmd_setbonding_primary_slave = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_setbonding_primary_port = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_set_bonding_primary = { + .f = cmd_set_bonding_primary_parsed, + .help_str ="set bonding primary (slave_id) (port_id): Set the primary slave for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_setbonding_primary_set, + (void *)&cmd_setbonding_primary_bonding, + (void *)&cmd_setbonding_primary_primary, + (void *)&cmd_setbonding_primary_slave, + (void *)&cmd_setbonding_primary_port, +NULL + } +}; + +/* *** ADD SLAVE *** */ +struct cmd_add_bonding_slave_result { +cmdline_fixed_string_t add; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t slave; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_add_bonding_slave_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_add_bonding_slave_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_slave_add (master_port_id, slave_port_id)) { +printf ("\t Failed to add slave %d to master port = %d.\n" , + slave_port_id, master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_addbonding_slave_add = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + add,"add" ); +cmdline_parse_token_string_t cmd_addbonding_slave_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_addbonding_slave_slave = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + slave,"slave" ); +cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = +TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_addbonding_slave_port = +TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_add_bonding_slave = { + .f = cmd_add_bonding_slave_parsed, + .help_str ="add bonding slave (slave_id) (port_id): Add a slave device to a bonded device" , + .data =NULL , + .tokens = { + (void *)&cmd_addbonding_slave_add, + (void *)&cmd_addbonding_slave_bonding, + (void *)&cmd_addbonding_slave_slave, + (void *)&cmd_addbonding_slave_slaveid, + (void *)&cmd_addbonding_slave_port, +NULL + } +}; + +/* *** REMOVE SLAVE *** */ +struct cmd_remove_bonding_slave_result { +cmdline_fixed_string_t remove; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t slave; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_remove_bonding_slave_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_remove_bonding_slave_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_slave_remove (master_port_id, slave_port_id)) { +printf ("\t Failed to remove slave %d from master port = %d.\n" , + slave_port_id, master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_removebonding_slave_remove = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + remove,"remove" ); +cmdline_parse_token_string_t cmd_removebonding_slave_bonding = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_removebonding_slave_slave = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + slave,"slave" ); +cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = + TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_removebonding_slave_port = + TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_remove_bonding_slave = { + .f = cmd_remove_bonding_slave_parsed, + .help_str ="remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device" , + .data =NULL , + .tokens = { + (void *)&cmd_removebonding_slave_remove, + (void *)&cmd_removebonding_slave_bonding, + (void *)&cmd_removebonding_slave_slave, + (void *)&cmd_removebonding_slave_slaveid, + (void *)&cmd_removebonding_slave_port, +NULL + } +}; + +/* *** CREATE BONDED DEVICE *** */ +struct cmd_create_bonded_device_result { +cmdline_fixed_string_t create; +cmdline_fixed_string_t bonded; +cmdline_fixed_string_t device; +uint8_t mode; +uint8_t socket; +}; + +static int bond_dev_num =0 ; + +static void cmd_create_bonded_device_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_create_bonded_device_result *res = parsed_result; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +int port_id; + +if (test_done ==0 ) { +printf ("Please stop forwarding first\n" ); +return ; + } + +rte_snprintf (ethdev_name,RTE_ETH_NAME_MAX_LEN ,"eth_bond_testpmd_%d" , + bond_dev_num++); + +/* Create a new bonded device. */ + port_id =rte_eth_bond_create (ethdev_name, res->mode, res->socket); +if (port_id <0 ) { +printf ("\t Failed to create bonded device.\n" ); +return ; + }else { +printf ("Created new bonded device %s on (port %d).\n" , ethdev_name, + port_id); + +/* Update number of ports */ + nb_ports =rte_eth_dev_count (); +reconfig (port_id); +rte_eth_promiscuous_enable (port_id); + } + +} + +cmdline_parse_token_string_t cmd_createbonded_device_create = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + create,"create" ); +cmdline_parse_token_string_t cmd_createbonded_device_bonded = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + bonded,"bonded" ); +cmdline_parse_token_string_t cmd_createbonded_device_device = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + device,"device" ); +cmdline_parse_token_num_t cmd_createbonded_device_mode = + TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, + mode,UINT8 ); +cmdline_parse_token_num_t cmd_createbonded_device_socket = + TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, + socket,UINT8 ); + +cmdline_parse_inst_t cmd_create_bonded_device = { + .f = cmd_create_bonded_device_parsed, + .help_str ="create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket" , + .data =NULL , + .tokens = { + (void *)&cmd_createbonded_device_create, + (void *)&cmd_createbonded_device_bonded, + (void *)&cmd_createbonded_device_device, + (void *)&cmd_createbonded_device_mode, + (void *)&cmd_createbonded_device_socket, +NULL + } +}; + +/* *** SET MAC ADDRESS IN BONDED DEVICE *** */ +struct cmd_set_bond_mac_addr_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t mac_addr; +uint8_t port_num; +struct ether_addr address; +}; + +static void cmd_set_bond_mac_addr_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bond_mac_addr_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_mac_address_set (res->port_num, &res->address); + +/* 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_mac_addr_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); +cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, +"bonding" ); +cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, +"mac_addr" ); +cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8); +cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); + +cmdline_parse_inst_t cmd_set_bond_mac_addr = { + .f = cmd_set_bond_mac_addr_parsed, + .data = (void *)0 , + .help_str ="set bonding mac_addr (port_id) (address): " , + .tokens = { + (void *)&cmd_set_bond_mac_addr_set, + (void *)&cmd_set_bond_mac_addr_bonding, + (void *)&cmd_set_bond_mac_addr_mac, + (void *)&cmd_set_bond_mac_addr_portnum, + (void *)&cmd_set_bond_mac_addr_addr, +NULL + } +}; + +#endif /* RTE_LIBRTE_PMD_BOND */ +/* *** SET FORWARDING MODE *** */ struct cmd_set_fwd_mode_result {cmdline_fixed_string_t set;
@@ -6572,6 +7141,16 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, (cmdline_parse_inst_t *)&cmd_show_bypass_config, #endif +#ifdef RTE_LIBRTE_PMD_BOND + (cmdline_parse_inst_t *) &cmd_set_bonding_mode, + (cmdline_parse_inst_t *) &cmd_show_bonding_config, + (cmdline_parse_inst_t *) &cmd_set_bonding_primary, + (cmdline_parse_inst_t *) &cmd_add_bonding_slave, + (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, + (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, +#endif (cmdline_parse_inst_t *)&cmd_vlan_offload, (cmdline_parse_inst_t *)&cmd_vlan_tpid, (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
app/test-pmd/config.c +3 -1
@@ -252,6 +252,7 @@ void port_infos_display(portid_t port_id) {struct rte_port *port; +struct ether_addr mac_addr;struct rte_eth_link link;int vlan_offload;struct rte_mempool * mp;
@@ -265,7 +266,8 @@ port_infos_display(portid_t port_id)rte_eth_link_get_nowait (port_id, &link);printf ("\n%s Infos for port %-2d %s\n" , info_border, port_id, info_border); -print_ethaddr ("MAC address: " , &port->eth_addr); +rte_eth_macaddr_get (port_id, &mac_addr); +print_ethaddr ("MAC address: " , &mac_addr);printf ("\nConnect to socket: %u" , port->socket_id);if (port_numa[port_id] !=NUMA_NO_CONFIG ) {
app/test-pmd/parameters.c +3 -0
@@ -75,6 +75,9 @@#include <cmdline_parse.h> #include <cmdline_parse_etheraddr.h> #endif +#ifdef RTE_LIBRTE_PMD_BOND +#include <rte_eth_bond.h> +#endif #include "testpmd.h"
app/test-pmd/testpmd.c +32 -8
@@ -300,7 +300,7 @@ struct rte_fdir_conf fdir_conf = { .drop_queue = 127, }; -static volatile int test_done =1 ;/* stop packet forwarding when set to 1. */ +volatile int test_done =1 ;/* stop packet forwarding when set to 1. */ struct queue_stats_mappings tx_queue_stats_mappings_array[MAX_TX_QUEUE_STATS_MAPPINGS ];struct queue_stats_mappings rx_queue_stats_mappings_array[MAX_RX_QUEUE_STATS_MAPPINGS ];
@@ -625,6 +625,32 @@ init_config(void)rte_exit (EXIT_FAILURE ,"FAIL from init_fwd_streams()\n" ); } + +void +reconfig (portid_t new_port_id) +{ +struct rte_port *port; + +/* Reconfiguration of Ethernet ports. */ + ports =rte_realloc (ports, +sizeof (struct rte_port ) * nb_ports, +CACHE_LINE_SIZE ); +if (ports ==NULL ) { +rte_exit (EXIT_FAILURE ,"rte_realloc(%d struct rte_port) failed\n" , + nb_ports); + } + + port = &ports[new_port_id]; +rte_eth_dev_info_get (new_port_id, &port->dev_info); + +/* set flag to initialize port/queue */ + port->need_reconfig =1 ; + port->need_reconfig_queues =1 ; + +init_port_config (); +} + +int init_fwd_streams (void ) {
@@ -1252,7 +1278,7 @@ start_port(portid_t pid)portid_t pi;queueid_t qi;struct rte_port *port; -uint8_t *mac_addr; +struct ether_addr mac_addr;if (test_done ==0 ) {printf ("Please stop forwarding first\n" );
@@ -1380,10 +1406,11 @@ start_port(portid_t pid) RTE_PORT_HANDLING, RTE_PORT_STARTED) == 0)printf ("Port %d can not be set into started\n" , pi); - mac_addr = port->eth_addr.addr_bytes; +rte_eth_macaddr_get (pi, &mac_addr);printf ("Port %d: %02X:%02X:%02X:%02X:%02X:%02X\n" , pi, - mac_addr[0 ], mac_addr[1 ], mac_addr[2 ], - mac_addr[3 ], mac_addr[4 ], mac_addr[5 ]); + mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], + mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], + mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ]);/* at least one port started, need checking link status */ need_check_link_status =1 ;
@@ -1826,9 +1853,6 @@ main(int argc, char** argv)if (diag <0 )rte_panic ("Cannot init EAL\n" ); -if (rte_eal_pci_probe ()) -rte_panic ("Cannot probe PCI\n" ); - nb_ports = (portid_t )rte_eth_dev_count ();if (nb_ports ==0 ) rte_exit(EXIT_FAILURE, "No probed ethernet devices - "
app/test-pmd/testpmd.h +2 -0
@@ -279,6 +279,7 @@ extern uint16_t port_topology; /**< set by "--port-topology" parameter */extern uint8_t no_flush_rx;/**<set by "--no-flush-rx" parameter */ extern uint8_t mp_anon;/**< set by "--mp-anon" parameter */ extern uint8_t no_link_check;/**<set by "--disable-link-check" parameter */ +extern volatile int test_done;/* stop packet forwarding when set to 1. */ #ifdef RTE_NIC_BYPASS extern uint32_t bypass_timeout;/**< Store the NIC bypass watchdog timeout */
@@ -452,6 +453,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);int init_fwd_streams (void );void port_mtu_set (portid_t port_id,uint16_t mtu);
Signature · 1 line
1.7.0.7
PATCH v8 6/6 Link Bonding Library doxygen additions
In reply to a message not in the archive--- doc/doxy-api-index.md | 1 + doc/doxy-api.conf | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
doc/doxy-api-index.md +1 -0
@@ -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),
doc/doxy-api.conf +1 -0
@@ -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 \
Signature · 1 line
1.7.0.7
De Lara Guarch, Pablo
Acked-by Pablo de LaraQuoted 79 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Wednesday, June 25, 2014 9:08 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v8 0/6] Link Bonding LibraryThis 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+43 - 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 codePatch Set Description:
0001 -librte_pmd_bond+ makefile changes
0002 -librte_etherchanges to support unique naming of pmds 0003 -librte_ealchanges to support bonding device intialization 0005 - link bonding unti test suite
0005 - testpmd link bonding support changes
0006 - doxygen additionsDeclan 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 additionsapp/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
Quoted 8 lines
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
v9 cover link bonding
In reply to a message not in the archiveHi Declan,
I've made some adjustments in your patches.
* Some renaming:
- RTE_PMD_BOND / PMD_BOND_KVARG -> PMD_BOND_NAME
- rte_pmd_bond_init -> bond_init
- rte_pmd_bond_drv -> bond_drv
- rte_eth_bond_vargs.c -> rte_eth_bond_args.c
* Some moves in doxygen configuration
* Removed rte_snprintf usages
* Reword commit logs
bond: new link bonding library
ethdev: add unique name to devices
eal: support link bonding device initialization
bond: unit tests
bond: testpmd support
But there is still something wrong in the Makefile:
the copyright is missing. I cannot add it by myself, so please send a v10 based on this v9 with copyright added.
Thanks
PATCH v9 1/5 bond: new link bonding library
In reply to a message not in the archiveFrom: Declan Doherty <[email protected]>
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
--- 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 | 32 + 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, 2645 insertions(+) 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
config/common_bsdapp +5 -0
@@ -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
config/common_linuxapp +5 -0
@@ -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
doc/doxy-api-index.md +1 -0
@@ -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)
doc/doxy-api.conf +1 -0
@@ -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 \
lib/Makefile +1 -0
@@ -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
lib/librte_pmd_bond/Makefile new file +32 -0
@@ -0,0 +1,32 @@ +# <COPYRIGHT_TAG> + +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
lib/librte_pmd_bond/rte_eth_bond.h new file +255 -0
255 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_api.c new file +662 -0
662 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_args.c new file +252 -0
252 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_pmd.c new file +1212 -0
1,212 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_private.h new file +215 -0
215 lines not on this page · raw message
mk/rte.app.mk +4 -0
@@ -205,6 +205,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) LDLIBS += -lrte_pmd_pcap -lpcap endif +ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y) +LDLIBS += -lrte_pmd_bond +endif + endif LDLIBS += $(EXECENV_LDLIBS)
Signature · 1 line
2.0.0
PATCH v9 2/5 ethdev: add unique name to devices
In reply to a message not in the archiveFrom: Declan Doherty <[email protected]>
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.
--- 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(-)
lib/librte_ether/rte_ethdev.c +28 -3
@@ -65,6 +65,7 @@#include <rte_mbuf.h> #include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_string_fns.h> #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 ;
lib/librte_ether/rte_ethdev.h +6 -1
@@ -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 name Unique 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 ;/**
lib/librte_pmd_pcap/rte_eth_pcap.c +11 -11
@@ -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 unsigned nb_tx_queues, const unsigned numa_node, struct pmd_internals **internals,
@@ -558,20 +558,20 @@ rte_pmd_init_internals(const unsigned nb_rx_queues,/* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data =rte_zmalloc_socket (NULL ,sizeof (*data),0 , numa_node); + data =rte_zmalloc_socket (name,sizeof (*data),0 , numa_node);if (data ==NULL ) goto error; - pci_dev =rte_zmalloc_socket (NULL ,sizeof (*pci_dev),0 , numa_node); + pci_dev =rte_zmalloc_socket (name,sizeof (*pci_dev),0 , numa_node);if (pci_dev ==NULL ) goto error; - *internals =rte_zmalloc_socket (NULL ,sizeof (**internals),0 , numa_node); + *internals =rte_zmalloc_socket (name,sizeof (**internals),0 , numa_node);if (*internals ==NULL ) goto error;/* reserve an ethdev entry */ - *eth_dev =rte_eth_dev_allocate (); + *eth_dev =rte_eth_dev_allocate (name);if (*eth_dev ==NULL ) goto error;
@@ -617,7 +617,7 @@ rte_pmd_init_internals(const unsigned nb_rx_queues, } static int -rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[], +rte_eth_from_pcaps_n_dumpers(const char *name, pcap_t * const rx_queues[], const unsigned nb_rx_queues, pcap_dumper_t * const tx_queues[], const unsigned nb_tx_queues,
@@ -634,7 +634,7 @@ rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[],if (tx_queues ==NULL && nb_tx_queues >0 )return -1 ; -if (rte_pmd_init_internals (nb_rx_queues, nb_tx_queues, numa_node, +if (rte_pmd_init_internals (name, nb_rx_queues, nb_tx_queues, numa_node, &internals, ð_dev, kvlist) <0 )return -1 ;
@@ -652,7 +652,7 @@ rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[], } static int -rte_eth_from_pcaps(pcap_t * const rx_queues[], +rte_eth_from_pcaps(const char *name, pcap_t * const rx_queues[], const unsigned nb_rx_queues, pcap_t * const tx_queues[], const unsigned nb_tx_queues,
@@ -669,7 +669,7 @@ rte_eth_from_pcaps(pcap_t * const rx_queues[],if (tx_queues ==NULL && nb_tx_queues >0 )return -1 ; -if (rte_pmd_init_internals (nb_rx_queues, nb_tx_queues, numa_node, +if (rte_pmd_init_internals (name, nb_rx_queues, nb_tx_queues, numa_node, &internals, ð_dev, kvlist) <0 )return -1 ;
@@ -760,10 +760,10 @@ rte_pmd_pcap_devinit(const char *name, const char *params)return -1 ;if (using_dumpers) -return rte_eth_from_pcaps_n_dumpers (pcaps.pcaps, pcaps.num_of_rx, +return rte_eth_from_pcaps_n_dumpers (name, pcaps.pcaps, pcaps.num_of_rx, dumpers.dumpers, dumpers.num_of_tx, numa_node, kvlist); -return rte_eth_from_pcaps (pcaps.pcaps, pcaps.num_of_rx, dumpers.pcaps, +return rte_eth_from_pcaps (name, pcaps.pcaps, pcaps.num_of_rx, dumpers.pcaps, dumpers.num_of_tx, numa_node, kvlist); }
lib/librte_pmd_ring/rte_eth_ring.c +17 -15
@@ -219,7 +219,7 @@ static struct eth_dev_ops ops = { }; int -rte_eth_from_rings(struct rte_ring *const rx_queues[], +rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], const unsigned nb_rx_queues, struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
@@ -243,20 +243,20 @@ rte_eth_from_rings(struct rte_ring *const rx_queues[],/* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data =rte_zmalloc_socket (NULL ,sizeof (*data),0 , numa_node); + data =rte_zmalloc_socket (name,sizeof (*data),0 , numa_node);if (data ==NULL ) goto error; - pci_dev =rte_zmalloc_socket (NULL ,sizeof (*pci_dev),0 , numa_node); + pci_dev =rte_zmalloc_socket (name,sizeof (*pci_dev),0 , numa_node);if (pci_dev ==NULL ) goto error; - internals =rte_zmalloc_socket (NULL ,sizeof (*internals),0 , numa_node); + internals =rte_zmalloc_socket (name,sizeof (*internals),0 , numa_node);if (internals ==NULL ) goto error;/* reserve an ethdev entry */ - eth_dev =rte_eth_dev_allocate (); + eth_dev =rte_eth_dev_allocate (name);if (eth_dev ==NULL ) goto error;
@@ -335,7 +335,7 @@ eth_dev_ring_create(const char *name, const unsigned numa_node,return -1 ; } -if (rte_eth_from_rings (rxtx, num_rings, rxtx, num_rings, numa_node)) +if (rte_eth_from_rings (name, rxtx, num_rings, rxtx, num_rings, numa_node))return -1 ;return 0 ;
@@ -352,29 +352,31 @@ eth_dev_ring_pair_create(const char *name, const unsigned numa_node,struct rte_ring *rx[RTE_PMD_RING_MAX_RX_RINGS ];struct rte_ring *tx[RTE_PMD_RING_MAX_TX_RINGS ];unsigned i; -char rng_name[RTE_RING_NAMESIZE ]; +char rx_rng_name[RTE_RING_NAMESIZE ]; +char tx_rng_name[RTE_RING_NAMESIZE ];unsigned num_rings =RTE_MIN (RTE_PMD_RING_MAX_RX_RINGS ,RTE_PMD_RING_MAX_TX_RINGS );for (i =0 ; i < num_rings; i++) { -snprintf (rng_name,sizeof (rng_name),"ETH_RX%u_%s" , i, name); +snprintf (rx_rng_name,sizeof (rx_rng_name),"ETH_RX%u_%s" , i, name); rx[i] = (action ==DEV_CREATE ) ? -rte_ring_create (rng_name,1024 , numa_node, +rte_ring_create (rx_rng_name,1024 , numa_node,RING_F_SP_ENQ |RING_F_SC_DEQ ) : -rte_ring_lookup (rng_name); +rte_ring_lookup (rx_rng_name);if (rx[i] ==NULL )return -1 ; -snprintf (rng_name,sizeof (rng_name),"ETH_TX%u_%s" , i, name); +snprintf (tx_rng_name,sizeof (tx_rng_name),"ETH_TX%u_%s" , i, name); tx[i] = (action ==DEV_CREATE ) ? -rte_ring_create (rng_name,1024 , numa_node, +rte_ring_create (tx_rng_name,1024 , numa_node,RING_F_SP_ENQ |RING_F_SC_DEQ ): -rte_ring_lookup (rng_name); +rte_ring_lookup (tx_rng_name);if (tx[i] ==NULL )return -1 ; } -if (rte_eth_from_rings (rx, num_rings, tx, num_rings, numa_node) || -rte_eth_from_rings (tx, num_rings, rx, num_rings, numa_node) ) +if (rte_eth_from_rings (rx_rng_name, rx, num_rings, tx, num_rings, + numa_node) ||rte_eth_from_rings (tx_rng_name, tx, num_rings, rx, + num_rings, numa_node))return -1 ;return 0 ;
lib/librte_pmd_ring/rte_eth_ring.h +2 -1
@@ -40,7 +40,8 @@ extern "C" {#include <rte_ring.h> -int rte_eth_from_rings(struct rte_ring * const rx_queues[], +int rte_eth_from_rings(const char *name, + struct rte_ring * const rx_queues[], const unsigned nb_rx_queues, struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
lib/librte_pmd_xenvirt/rte_eth_xenvirt.c +1 -1
@@ -647,7 +647,7 @@ eth_dev_xenvirt_create(const char *name, const char *params, goto err;/* reserve an ethdev entry */ - eth_dev =rte_eth_dev_allocate (); + eth_dev =rte_eth_dev_allocate (name);if (eth_dev ==NULL ) goto err;
Signature · 1 line
2.0.0
PATCH v9 3/5 eal: support link bonding device initialization
In reply to a message not in the archiveFrom: Declan Doherty <[email protected]>
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.
--- 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(-)
lib/librte_eal/bsdapp/eal/eal.c +9 -1
@@ -919,7 +919,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) {
@@ -951,6 +951,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; }
lib/librte_eal/common/eal_common_dev.c +40 -18
77 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +3 -0
@@ -150,6 +150,9 @@ rte_eal_pci_probe(void) probe_all =1 ; TAILQ_FOREACH(dev, &pci_device_list, next) { +/* check if device has already been initialized */ +if (dev->driver !=NULL ) +continue ;/* set devargs in PCI structure */ devargs =pci_devargs_lookup (dev);
lib/librte_eal/common/include/eal_private.h +0 -7
@@ -196,11 +196,4 @@ int rte_eal_intr_init(void);*/ int rte_eal_alarm_init (void ); -/** -* This function initialises any virtual devices -* -* This function is private to the EAL. -*/ -int rte_eal_dev_init (void ); -#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/common/include/rte_dev.h +12 -2
@@ -62,6 +62,16 @@ typedef int (rte_dev_init_t)(const char *name, const char *args);enum pmd_type {PMD_VDEV =0 ,PMD_PDEV =1 , +PMD_BDEV =2 ,/**< Poll Mode Driver Bonded Device*/ +}; + +#define PMD_BOND_NAME "eth_bond" + +/** +* Driver initialization */ +enum pmd_init_priority { +PMD_INIT_PRE_PCI_PROBE =0 , +PMD_INIT_POST_PCI_PROBE =1 , };/**
@@ -93,9 +103,9 @@ void rte_eal_driver_register(struct rte_driver *driver);void rte_eal_driver_unregister (struct rte_driver *driver);/** -* Initalize all the registered drivers in this process +* Initialize all the registered drivers in this process */ -int rte_eal_dev_init (void ); +int rte_eal_dev_init (uint8_t init_priority);#define PMD_REGISTER_DRIVER (d)\ void devinitfn_ ##d(void);\
lib/librte_eal/linuxapp/eal/eal.c +10 -1
@@ -75,6 +75,7 @@#include <rte_atomic.h> #include <malloc_heap.h> #include <rte_eth_ring.h> +#include <rte_dev.h> #include "eal_private.h" #include "eal_thread.h"
@@ -1142,7 +1143,7 @@ rte_eal_init(int argc, char **argv)RTE_LOG (DEBUG ,EAL ,"Master core %u is ready (tid=%x)\n" , rte_config.master_lcore, (int )thread_id); -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) {
@@ -1172,6 +1173,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; }
Signature · 1 line
2.0.0
PATCH v9 4/5 bond: unit tests
In reply to a message not in the archiveFrom: Declan Doherty <[email protected]>
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
--- 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 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
app/test/Makefile +3 -1
@@ -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
app/test/commands.c +7 -0
@@ -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#"
app/test/packet_burst_generator.c new file +287 -0
287 lines not on this page · raw message
app/test/packet_burst_generator.h new file +78 -0
78 lines not on this page · raw message
app/test/test.h +1 -0
@@ -97,6 +97,7 @@ int test_distributor(void);int test_distributor_perf (void );int test_kvargs (void );int test_devargs (void ); +int test_link_bonding (void );int test_pci_run;
app/test/test_link_bonding.c new file +3958 -0
2,599 lines not on this page · raw message
app/test/virtual_pmd.c new file +574 -0
574 lines not on this page · raw message
app/test/virtual_pmd.h new file +74 -0
74 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.0.0
Part of the diff is not shown here. View the raw message.
PATCH v9 5/5 bond: testpmd support
In reply to a message not in the archiveFrom: Declan Doherty <[email protected]>
- 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
--- 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(-)
app/test-pmd/cmdline.c +579 -0
@@ -84,6 +84,9 @@#include <cmdline_socket.h> #include <cmdline.h> #include <rte_pci_dev_ids.h> +#ifdef RTE_LIBRTE_PMD_BOND +#include <rte_eth_bond.h> +#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 { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t balance_xmit_policy; +uint8_t port_id; +cmdline_fixed_string_t policy; +}; + +static void cmd_set_bonding_balance_xmit_policy_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; +portid_t port_id = res->port_id; +uint8_t policy; + +if (!strcmp (res->policy,"l2" )) { + policy =BALANCE_XMIT_POLICY_LAYER2 ; + }else if (!strcmp (res->policy,"l23" )) { + policy =BALANCE_XMIT_POLICY_LAYER23 ; + }else if (!strcmp (res->policy,"l34" )) { + policy =BALANCE_XMIT_POLICY_LAYER34 ; + }else { +printf ("\t Invalid xmit policy selection" ); +return ; + } + +/* Set the bonding mode for the relevant port. */ +if (0 !=rte_eth_bond_xmit_policy_set (port_id, policy)) { +printf ("\t Failed to set bonding balance xmit policy for port = %d.\n" , + port_id); + } +} + +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + set,"set" ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + balance_xmit_policy,"balance_xmit_policy" ); +cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + port_id,UINT8 ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + policy,"l2#l23#l34" ); + +cmdline_parse_inst_t cmd_set_balance_xmit_policy = { + .f = cmd_set_bonding_balance_xmit_policy_parsed, + .help_str ="set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_setbonding_balance_xmit_policy_set, + (void *)&cmd_setbonding_balance_xmit_policy_bonding, + (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, + (void *)&cmd_setbonding_balance_xmit_policy_port, + (void *)&cmd_setbonding_balance_xmit_policy_policy, +NULL + } +}; + +/* *** SHOW NIC BONDING CONFIGURATION *** */ +struct cmd_show_bonding_config_result { +cmdline_fixed_string_t show; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t config; +uint8_t port_id; +}; + +static void cmd_show_bonding_config_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_show_bonding_config_result *res = parsed_result; +int bonding_mode; +uint8_t slaves[RTE_MAX_ETHPORTS ]; +int num_slaves, num_active_slaves; +int primary_id; +int i; +portid_t port_id = res->port_id; + +/* Display the bonding mode.*/ + bonding_mode =rte_eth_bond_mode_get (port_id); +if (bonding_mode <0 ) { +printf ("\tFailed to get bonding mode for port = %d\n" , port_id); +return ; + }else +printf ("\tBonding mode: %d\n" , bonding_mode); + +if (bonding_mode ==BONDING_MODE_BALANCE ) { +int balance_xmit_policy; + + balance_xmit_policy =rte_eth_bond_xmit_policy_get (port_id); +if (balance_xmit_policy <0 ) { +printf ("\tFailed to get balance xmit policy for port = %d\n" , + port_id); +return ; + }else { +printf ("\tBalance Xmit Policy: " ); + +switch (balance_xmit_policy) { +case BALANCE_XMIT_POLICY_LAYER2 : +printf ("BALANCE_XMIT_POLICY_LAYER2" ); +break ; +case BALANCE_XMIT_POLICY_LAYER23 : +printf ("BALANCE_XMIT_POLICY_LAYER23" ); +break ; +case BALANCE_XMIT_POLICY_LAYER34 : +printf ("BALANCE_XMIT_POLICY_LAYER34" ); +break ; + } +printf ("\n" ); + } + } + + num_slaves =rte_eth_bond_slaves_get (port_id, slaves,RTE_MAX_ETHPORTS ); + +if (num_slaves <0 ) { +printf ("\tFailed to get slave list for port = %d\n" , port_id); +return ; + } +if (num_slaves >0 ) { +printf ("\tSlaves (%d): [" , num_slaves); +for (i =0 ; i < num_slaves -1 ; i++) +printf ("%d " , slaves[i]); + +printf ("%d]\n" , slaves[num_slaves -1 ]); + }else { +printf ("\tSlaves: []\n" ); + + } + + num_active_slaves =rte_eth_bond_active_slaves_get (port_id, slaves, +RTE_MAX_ETHPORTS ); + +if (num_active_slaves <0 ) { +printf ("\tFailed to get active slave list for port = %d\n" , port_id); +return ; + } +if (num_active_slaves >0 ) { +printf ("\tActive Slaves (%d): [" , num_active_slaves); +for (i =0 ; i < num_active_slaves -1 ; i++) +printf ("%d " , slaves[i]); + +printf ("%d]\n" , slaves[num_active_slaves -1 ]); + + }else { +printf ("\tActive Slaves: []\n" ); + + } + + primary_id =rte_eth_bond_primary_get (port_id); +if (primary_id <0 ) { +printf ("\tFailed to get primary slave for port = %d\n" , port_id); +return ; + }else +printf ("\tPrimary: [%d]\n" , primary_id); + +} + +cmdline_parse_token_string_t cmd_showbonding_config_show = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + show,"show" ); +cmdline_parse_token_string_t cmd_showbonding_config_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_showbonding_config_config = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + config,"config" ); +cmdline_parse_token_num_t cmd_showbonding_config_port = +TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_show_bonding_config = { + .f = cmd_show_bonding_config_parsed, + .help_str ="show bonding config (port_id): Show the bonding config for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_showbonding_config_show, + (void *)&cmd_showbonding_config_bonding, + (void *)&cmd_showbonding_config_config, + (void *)&cmd_showbonding_config_port, +NULL + } +}; + +/* *** SET BONDING PRIMARY *** */ +struct cmd_set_bonding_primary_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t primary; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_set_bonding_primary_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bonding_primary_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_primary_set (master_port_id, slave_port_id)) { +printf ("\t Failed to set primary slave for port = %d.\n" , + master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_setbonding_primary_set = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + set,"set" ); +cmdline_parse_token_string_t cmd_setbonding_primary_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_setbonding_primary_primary = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + primary,"primary" ); +cmdline_parse_token_num_t cmd_setbonding_primary_slave = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_setbonding_primary_port = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_set_bonding_primary = { + .f = cmd_set_bonding_primary_parsed, + .help_str ="set bonding primary (slave_id) (port_id): Set the primary slave for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_setbonding_primary_set, + (void *)&cmd_setbonding_primary_bonding, + (void *)&cmd_setbonding_primary_primary, + (void *)&cmd_setbonding_primary_slave, + (void *)&cmd_setbonding_primary_port, +NULL + } +}; + +/* *** ADD SLAVE *** */ +struct cmd_add_bonding_slave_result { +cmdline_fixed_string_t add; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t slave; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_add_bonding_slave_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_add_bonding_slave_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_slave_add (master_port_id, slave_port_id)) { +printf ("\t Failed to add slave %d to master port = %d.\n" , + slave_port_id, master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_addbonding_slave_add = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + add,"add" ); +cmdline_parse_token_string_t cmd_addbonding_slave_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_addbonding_slave_slave = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + slave,"slave" ); +cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = +TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_addbonding_slave_port = +TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_add_bonding_slave = { + .f = cmd_add_bonding_slave_parsed, + .help_str ="add bonding slave (slave_id) (port_id): Add a slave device to a bonded device" , + .data =NULL , + .tokens = { + (void *)&cmd_addbonding_slave_add, + (void *)&cmd_addbonding_slave_bonding, + (void *)&cmd_addbonding_slave_slave, + (void *)&cmd_addbonding_slave_slaveid, + (void *)&cmd_addbonding_slave_port, +NULL + } +}; + +/* *** REMOVE SLAVE *** */ +struct cmd_remove_bonding_slave_result { +cmdline_fixed_string_t remove; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t slave; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_remove_bonding_slave_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_remove_bonding_slave_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_slave_remove (master_port_id, slave_port_id)) { +printf ("\t Failed to remove slave %d from master port = %d.\n" , + slave_port_id, master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_removebonding_slave_remove = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + remove,"remove" ); +cmdline_parse_token_string_t cmd_removebonding_slave_bonding = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_removebonding_slave_slave = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + slave,"slave" ); +cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = + TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_removebonding_slave_port = + TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_remove_bonding_slave = { + .f = cmd_remove_bonding_slave_parsed, + .help_str ="remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device" , + .data =NULL , + .tokens = { + (void *)&cmd_removebonding_slave_remove, + (void *)&cmd_removebonding_slave_bonding, + (void *)&cmd_removebonding_slave_slave, + (void *)&cmd_removebonding_slave_slaveid, + (void *)&cmd_removebonding_slave_port, +NULL + } +}; + +/* *** CREATE BONDED DEVICE *** */ +struct cmd_create_bonded_device_result { +cmdline_fixed_string_t create; +cmdline_fixed_string_t bonded; +cmdline_fixed_string_t device; +uint8_t mode; +uint8_t socket; +}; + +static int bond_dev_num =0 ; + +static void cmd_create_bonded_device_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_create_bonded_device_result *res = parsed_result; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +int port_id; + +if (test_done ==0 ) { +printf ("Please stop forwarding first\n" ); +return ; + } + +snprintf (ethdev_name,RTE_ETH_NAME_MAX_LEN ,"eth_bond_testpmd_%d" , + bond_dev_num++); + +/* Create a new bonded device. */ + port_id =rte_eth_bond_create (ethdev_name, res->mode, res->socket); +if (port_id <0 ) { +printf ("\t Failed to create bonded device.\n" ); +return ; + }else { +printf ("Created new bonded device %s on (port %d).\n" , ethdev_name, + port_id); + +/* Update number of ports */ + nb_ports =rte_eth_dev_count (); +reconfig (port_id); +rte_eth_promiscuous_enable (port_id); + } + +} + +cmdline_parse_token_string_t cmd_createbonded_device_create = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + create,"create" ); +cmdline_parse_token_string_t cmd_createbonded_device_bonded = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + bonded,"bonded" ); +cmdline_parse_token_string_t cmd_createbonded_device_device = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + device,"device" ); +cmdline_parse_token_num_t cmd_createbonded_device_mode = + TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, + mode,UINT8 ); +cmdline_parse_token_num_t cmd_createbonded_device_socket = + TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, + socket,UINT8 ); + +cmdline_parse_inst_t cmd_create_bonded_device = { + .f = cmd_create_bonded_device_parsed, + .help_str ="create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket" , + .data =NULL , + .tokens = { + (void *)&cmd_createbonded_device_create, + (void *)&cmd_createbonded_device_bonded, + (void *)&cmd_createbonded_device_device, + (void *)&cmd_createbonded_device_mode, + (void *)&cmd_createbonded_device_socket, +NULL + } +}; + +/* *** SET MAC ADDRESS IN BONDED DEVICE *** */ +struct cmd_set_bond_mac_addr_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t mac_addr; +uint8_t port_num; +struct ether_addr address; +}; + +static void cmd_set_bond_mac_addr_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bond_mac_addr_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_mac_address_set (res->port_num, &res->address); + +/* 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_mac_addr_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); +cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, +"bonding" ); +cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, +"mac_addr" ); +cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8); +cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); + +cmdline_parse_inst_t cmd_set_bond_mac_addr = { + .f = cmd_set_bond_mac_addr_parsed, + .data = (void *)0 , + .help_str ="set bonding mac_addr (port_id) (address): " , + .tokens = { + (void *)&cmd_set_bond_mac_addr_set, + (void *)&cmd_set_bond_mac_addr_bonding, + (void *)&cmd_set_bond_mac_addr_mac, + (void *)&cmd_set_bond_mac_addr_portnum, + (void *)&cmd_set_bond_mac_addr_addr, +NULL + } +}; + +#endif /* RTE_LIBRTE_PMD_BOND */ +/* *** SET FORWARDING MODE *** */ struct cmd_set_fwd_mode_result {cmdline_fixed_string_t set;
@@ -6572,6 +7141,16 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, (cmdline_parse_inst_t *)&cmd_show_bypass_config, #endif +#ifdef RTE_LIBRTE_PMD_BOND + (cmdline_parse_inst_t *) &cmd_set_bonding_mode, + (cmdline_parse_inst_t *) &cmd_show_bonding_config, + (cmdline_parse_inst_t *) &cmd_set_bonding_primary, + (cmdline_parse_inst_t *) &cmd_add_bonding_slave, + (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, + (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, +#endif (cmdline_parse_inst_t *)&cmd_vlan_offload, (cmdline_parse_inst_t *)&cmd_vlan_tpid, (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
app/test-pmd/config.c +3 -1
@@ -252,6 +252,7 @@ void port_infos_display(portid_t port_id) {struct rte_port *port; +struct ether_addr mac_addr;struct rte_eth_link link;int vlan_offload;struct rte_mempool * mp;
@@ -265,7 +266,8 @@ port_infos_display(portid_t port_id)rte_eth_link_get_nowait (port_id, &link);printf ("\n%s Infos for port %-2d %s\n" , info_border, port_id, info_border); -print_ethaddr ("MAC address: " , &port->eth_addr); +rte_eth_macaddr_get (port_id, &mac_addr); +print_ethaddr ("MAC address: " , &mac_addr);printf ("\nConnect to socket: %u" , port->socket_id);if (port_numa[port_id] !=NUMA_NO_CONFIG ) {
app/test-pmd/parameters.c +3 -0
@@ -75,6 +75,9 @@#include <cmdline_parse.h> #include <cmdline_parse_etheraddr.h> #endif +#ifdef RTE_LIBRTE_PMD_BOND +#include <rte_eth_bond.h> +#endif #include "testpmd.h"
app/test-pmd/testpmd.c +32 -8
@@ -300,7 +300,7 @@ struct rte_fdir_conf fdir_conf = { .drop_queue = 127, }; -static volatile int test_done =1 ;/* stop packet forwarding when set to 1. */ +volatile int test_done =1 ;/* stop packet forwarding when set to 1. */ struct queue_stats_mappings tx_queue_stats_mappings_array[MAX_TX_QUEUE_STATS_MAPPINGS ];struct queue_stats_mappings rx_queue_stats_mappings_array[MAX_RX_QUEUE_STATS_MAPPINGS ];
@@ -625,6 +625,32 @@ init_config(void)rte_exit (EXIT_FAILURE ,"FAIL from init_fwd_streams()\n" ); } + +void +reconfig (portid_t new_port_id) +{ +struct rte_port *port; + +/* Reconfiguration of Ethernet ports. */ + ports =rte_realloc (ports, +sizeof (struct rte_port ) * nb_ports, +CACHE_LINE_SIZE ); +if (ports ==NULL ) { +rte_exit (EXIT_FAILURE ,"rte_realloc(%d struct rte_port) failed\n" , + nb_ports); + } + + port = &ports[new_port_id]; +rte_eth_dev_info_get (new_port_id, &port->dev_info); + +/* set flag to initialize port/queue */ + port->need_reconfig =1 ; + port->need_reconfig_queues =1 ; + +init_port_config (); +} + +int init_fwd_streams (void ) {
@@ -1252,7 +1278,7 @@ start_port(portid_t pid)portid_t pi;queueid_t qi;struct rte_port *port; -uint8_t *mac_addr; +struct ether_addr mac_addr;if (test_done ==0 ) {printf ("Please stop forwarding first\n" );
@@ -1380,10 +1406,11 @@ start_port(portid_t pid) RTE_PORT_HANDLING, RTE_PORT_STARTED) == 0)printf ("Port %d can not be set into started\n" , pi); - mac_addr = port->eth_addr.addr_bytes; +rte_eth_macaddr_get (pi, &mac_addr);printf ("Port %d: %02X:%02X:%02X:%02X:%02X:%02X\n" , pi, - mac_addr[0 ], mac_addr[1 ], mac_addr[2 ], - mac_addr[3 ], mac_addr[4 ], mac_addr[5 ]); + mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], + mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], + mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ]);/* at least one port started, need checking link status */ need_check_link_status =1 ;
@@ -1826,9 +1853,6 @@ main(int argc, char** argv)if (diag <0 )rte_panic ("Cannot init EAL\n" ); -if (rte_eal_pci_probe ()) -rte_panic ("Cannot probe PCI\n" ); - nb_ports = (portid_t )rte_eth_dev_count ();if (nb_ports ==0 ) rte_exit(EXIT_FAILURE, "No probed ethernet devices - "
app/test-pmd/testpmd.h +2 -0
@@ -281,6 +281,7 @@ extern uint16_t port_topology; /**< set by "--port-topology" parameter */extern uint8_t no_flush_rx;/**<set by "--no-flush-rx" parameter */ extern uint8_t mp_anon;/**< set by "--mp-anon" parameter */ extern uint8_t no_link_check;/**<set by "--disable-link-check" parameter */ +extern volatile int test_done;/* stop packet forwarding when set to 1. */ #ifdef RTE_NIC_BYPASS extern uint32_t bypass_timeout;/**< Store the NIC bypass watchdog timeout */
@@ -454,6 +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);int init_fwd_streams (void );void port_mtu_set (portid_t port_id,uint16_t mtu);
Signature · 1 line
2.0.0
Re: [PATCH v9 1/5] bond: new link bonding library
In reply to a message not in the archive2014-06-27 01:57, Thomas Monjalon:
Quoted 1 line
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_BOND) +=
rte_eth_bond_vargs.c
I forgot to rename the file here to rte_eth_bond_args.c.
Signature · 1 line
Thomas
v10 cover link bonding
In reply to a message not in the archiveFixed 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
PATCH v10 1/5 bond: new link bonding library
In reply to a message not in the archiveInitial 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
--- 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
config/common_bsdapp +5 -0
@@ -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
config/common_linuxapp +5 -0
@@ -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
doc/doxy-api-index.md +1 -0
@@ -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)
doc/doxy-api.conf +1 -0
@@ -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 \
lib/Makefile +1 -0
@@ -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
lib/librte_pmd_bond/Makefile new file +61 -0
61 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond.h new file +255 -0
255 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_api.c new file +662 -0
662 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_args.c new file +252 -0
252 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_pmd.c new file +1212 -0
1,212 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_private.h new file +215 -0
215 lines not on this page · raw message
mk/rte.app.mk +4 -0
@@ -205,6 +205,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) LDLIBS += -lrte_pmd_pcap -lpcap endif +ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y) +LDLIBS += -lrte_pmd_bond +endif + endif LDLIBS += $(EXECENV_LDLIBS)
Signature · 1 line
1.7.0.7
PATCH v10 2/5 ethdev: add unique name to devices
In reply to a message not in the archiveAdding 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.
--- 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(-)
lib/librte_ether/rte_ethdev.c +28 -3
@@ -65,6 +65,7 @@#include <rte_mbuf.h> #include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_string_fns.h> #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 ;
lib/librte_ether/rte_ethdev.h +6 -1
@@ -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 name Unique 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 ;/**
lib/librte_pmd_pcap/rte_eth_pcap.c +11 -11
@@ -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 unsigned nb_tx_queues, const unsigned numa_node, struct pmd_internals **internals,
@@ -558,20 +558,20 @@ rte_pmd_init_internals(const unsigned nb_rx_queues,/* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data =rte_zmalloc_socket (NULL ,sizeof (*data),0 , numa_node); + data =rte_zmalloc_socket (name,sizeof (*data),0 , numa_node);if (data ==NULL ) goto error; - pci_dev =rte_zmalloc_socket (NULL ,sizeof (*pci_dev),0 , numa_node); + pci_dev =rte_zmalloc_socket (name,sizeof (*pci_dev),0 , numa_node);if (pci_dev ==NULL ) goto error; - *internals =rte_zmalloc_socket (NULL ,sizeof (**internals),0 , numa_node); + *internals =rte_zmalloc_socket (name,sizeof (**internals),0 , numa_node);if (*internals ==NULL ) goto error;/* reserve an ethdev entry */ - *eth_dev =rte_eth_dev_allocate (); + *eth_dev =rte_eth_dev_allocate (name);if (*eth_dev ==NULL ) goto error;
@@ -617,7 +617,7 @@ rte_pmd_init_internals(const unsigned nb_rx_queues, } static int -rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[], +rte_eth_from_pcaps_n_dumpers(const char *name, pcap_t * const rx_queues[], const unsigned nb_rx_queues, pcap_dumper_t * const tx_queues[], const unsigned nb_tx_queues,
@@ -634,7 +634,7 @@ rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[],if (tx_queues ==NULL && nb_tx_queues >0 )return -1 ; -if (rte_pmd_init_internals (nb_rx_queues, nb_tx_queues, numa_node, +if (rte_pmd_init_internals (name, nb_rx_queues, nb_tx_queues, numa_node, &internals, ð_dev, kvlist) <0 )return -1 ;
@@ -652,7 +652,7 @@ rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[], } static int -rte_eth_from_pcaps(pcap_t * const rx_queues[], +rte_eth_from_pcaps(const char *name, pcap_t * const rx_queues[], const unsigned nb_rx_queues, pcap_t * const tx_queues[], const unsigned nb_tx_queues,
@@ -669,7 +669,7 @@ rte_eth_from_pcaps(pcap_t * const rx_queues[],if (tx_queues ==NULL && nb_tx_queues >0 )return -1 ; -if (rte_pmd_init_internals (nb_rx_queues, nb_tx_queues, numa_node, +if (rte_pmd_init_internals (name, nb_rx_queues, nb_tx_queues, numa_node, &internals, ð_dev, kvlist) <0 )return -1 ;
@@ -760,10 +760,10 @@ rte_pmd_pcap_devinit(const char *name, const char *params)return -1 ;if (using_dumpers) -return rte_eth_from_pcaps_n_dumpers (pcaps.pcaps, pcaps.num_of_rx, +return rte_eth_from_pcaps_n_dumpers (name, pcaps.pcaps, pcaps.num_of_rx, dumpers.dumpers, dumpers.num_of_tx, numa_node, kvlist); -return rte_eth_from_pcaps (pcaps.pcaps, pcaps.num_of_rx, dumpers.pcaps, +return rte_eth_from_pcaps (name, pcaps.pcaps, pcaps.num_of_rx, dumpers.pcaps, dumpers.num_of_tx, numa_node, kvlist); }
lib/librte_pmd_ring/rte_eth_ring.c +17 -15
@@ -219,7 +219,7 @@ static struct eth_dev_ops ops = { }; int -rte_eth_from_rings(struct rte_ring *const rx_queues[], +rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], const unsigned nb_rx_queues, struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
@@ -243,20 +243,20 @@ rte_eth_from_rings(struct rte_ring *const rx_queues[],/* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data =rte_zmalloc_socket (NULL ,sizeof (*data),0 , numa_node); + data =rte_zmalloc_socket (name,sizeof (*data),0 , numa_node);if (data ==NULL ) goto error; - pci_dev =rte_zmalloc_socket (NULL ,sizeof (*pci_dev),0 , numa_node); + pci_dev =rte_zmalloc_socket (name,sizeof (*pci_dev),0 , numa_node);if (pci_dev ==NULL ) goto error; - internals =rte_zmalloc_socket (NULL ,sizeof (*internals),0 , numa_node); + internals =rte_zmalloc_socket (name,sizeof (*internals),0 , numa_node);if (internals ==NULL ) goto error;/* reserve an ethdev entry */ - eth_dev =rte_eth_dev_allocate (); + eth_dev =rte_eth_dev_allocate (name);if (eth_dev ==NULL ) goto error;
@@ -335,7 +335,7 @@ eth_dev_ring_create(const char *name, const unsigned numa_node,return -1 ; } -if (rte_eth_from_rings (rxtx, num_rings, rxtx, num_rings, numa_node)) +if (rte_eth_from_rings (name, rxtx, num_rings, rxtx, num_rings, numa_node))return -1 ;return 0 ;
@@ -352,29 +352,31 @@ eth_dev_ring_pair_create(const char *name, const unsigned numa_node,struct rte_ring *rx[RTE_PMD_RING_MAX_RX_RINGS ];struct rte_ring *tx[RTE_PMD_RING_MAX_TX_RINGS ];unsigned i; -char rng_name[RTE_RING_NAMESIZE ]; +char rx_rng_name[RTE_RING_NAMESIZE ]; +char tx_rng_name[RTE_RING_NAMESIZE ];unsigned num_rings =RTE_MIN (RTE_PMD_RING_MAX_RX_RINGS ,RTE_PMD_RING_MAX_TX_RINGS );for (i =0 ; i < num_rings; i++) { -snprintf (rng_name,sizeof (rng_name),"ETH_RX%u_%s" , i, name); +snprintf (rx_rng_name,sizeof (rx_rng_name),"ETH_RX%u_%s" , i, name); rx[i] = (action ==DEV_CREATE ) ? -rte_ring_create (rng_name,1024 , numa_node, +rte_ring_create (rx_rng_name,1024 , numa_node,RING_F_SP_ENQ |RING_F_SC_DEQ ) : -rte_ring_lookup (rng_name); +rte_ring_lookup (rx_rng_name);if (rx[i] ==NULL )return -1 ; -snprintf (rng_name,sizeof (rng_name),"ETH_TX%u_%s" , i, name); +snprintf (tx_rng_name,sizeof (tx_rng_name),"ETH_TX%u_%s" , i, name); tx[i] = (action ==DEV_CREATE ) ? -rte_ring_create (rng_name,1024 , numa_node, +rte_ring_create (tx_rng_name,1024 , numa_node,RING_F_SP_ENQ |RING_F_SC_DEQ ): -rte_ring_lookup (rng_name); +rte_ring_lookup (tx_rng_name);if (tx[i] ==NULL )return -1 ; } -if (rte_eth_from_rings (rx, num_rings, tx, num_rings, numa_node) || -rte_eth_from_rings (tx, num_rings, rx, num_rings, numa_node) ) +if (rte_eth_from_rings (rx_rng_name, rx, num_rings, tx, num_rings, + numa_node) ||rte_eth_from_rings (tx_rng_name, tx, num_rings, rx, + num_rings, numa_node))return -1 ;return 0 ;
lib/librte_pmd_ring/rte_eth_ring.h +2 -1
@@ -40,7 +40,8 @@ extern "C" {#include <rte_ring.h> -int rte_eth_from_rings(struct rte_ring * const rx_queues[], +int rte_eth_from_rings(const char *name, + struct rte_ring * const rx_queues[], const unsigned nb_rx_queues, struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
lib/librte_pmd_xenvirt/rte_eth_xenvirt.c +1 -1
@@ -647,7 +647,7 @@ eth_dev_xenvirt_create(const char *name, const char *params, goto err;/* reserve an ethdev entry */ - eth_dev =rte_eth_dev_allocate (); + eth_dev =rte_eth_dev_allocate (name);if (eth_dev ==NULL ) goto err;
Signature · 1 line
1.7.0.7
PATCH v10 3/5 eal: support link bonding device initialization
In reply to a message not in the archiveUpdating 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.
--- 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(-)
lib/librte_eal/bsdapp/eal/eal.c +9 -1
@@ -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; }
lib/librte_eal/common/eal_common_dev.c +40 -18
77 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +3 -0
@@ -150,6 +150,9 @@ rte_eal_pci_probe(void) probe_all =1 ; TAILQ_FOREACH(dev, &pci_device_list, next) { +/* check if device has already been initialized */ +if (dev->driver !=NULL ) +continue ;/* set devargs in PCI structure */ devargs =pci_devargs_lookup (dev);
lib/librte_eal/common/include/eal_private.h +0 -7
@@ -196,11 +196,4 @@ int rte_eal_intr_init(void);*/ int rte_eal_alarm_init (void ); -/** -* This function initialises any virtual devices -* -* This function is private to the EAL. -*/ -int rte_eal_dev_init (void ); -#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/common/include/rte_dev.h +12 -2
@@ -62,6 +62,16 @@ typedef int (rte_dev_init_t)(const char *name, const char *args);enum pmd_type {PMD_VDEV =0 ,PMD_PDEV =1 , +PMD_BDEV =2 ,/**< Poll Mode Driver Bonded Device*/ +}; + +#define PMD_BOND_NAME "eth_bond" + +/** +* Driver initialization */ +enum pmd_init_priority { +PMD_INIT_PRE_PCI_PROBE =0 , +PMD_INIT_POST_PCI_PROBE =1 , };/**
@@ -93,9 +103,9 @@ void rte_eal_driver_register(struct rte_driver *driver);void rte_eal_driver_unregister (struct rte_driver *driver);/** -* Initalize all the registered drivers in this process +* Initialize all the registered drivers in this process */ -int rte_eal_dev_init (void ); +int rte_eal_dev_init (uint8_t init_priority);#define PMD_REGISTER_DRIVER (d)\ void devinitfn_ ##d(void);\
lib/librte_eal/linuxapp/eal/eal.c +10 -1
@@ -75,6 +75,7 @@#include <rte_atomic.h> #include <malloc_heap.h> #include <rte_eth_ring.h> +#include <rte_dev.h> #include "eal_private.h" #include "eal_thread.h"
@@ -1097,7 +1098,7 @@ rte_eal_init(int argc, char **argv)RTE_LOG (DEBUG ,EAL ,"Master core %u is ready (tid=%x)\n" , rte_config.master_lcore, (int )thread_id); -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) {
@@ -1127,6 +1128,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; }
Signature · 1 line
1.7.0.7
PATCH v10 4/5 bond: unit tests
In reply to a message not in the archiveIncluding:
- 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
--- 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
app/test/Makefile +3 -1
@@ -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
app/test/commands.c +7 -0
@@ -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#"
app/test/packet_burst_generator.c new file +287 -0
287 lines not on this page · raw message
app/test/packet_burst_generator.h new file +78 -0
78 lines not on this page · raw message
app/test/test.h +1 -0
@@ -97,6 +97,7 @@ int test_distributor(void);int test_distributor_perf (void );int test_kvargs (void );int test_devargs (void ); +int test_link_bonding (void );int test_pci_run;
app/test/test_link_bonding.c new file +3958 -0
2,599 lines not on this page · raw message
app/test/virtual_pmd.c new file +574 -0
574 lines not on this page · raw message
app/test/virtual_pmd.h new file +74 -0
74 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.0.7
Part of the diff is not shown here. View the raw message.
PATCH v10 5/5 bond: testpmd support
In reply to a message not in the archive - 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
--- 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(-)
app/test-pmd/cmdline.c +579 -0
@@ -84,6 +84,9 @@#include <cmdline_socket.h> #include <cmdline.h> #include <rte_pci_dev_ids.h> +#ifdef RTE_LIBRTE_PMD_BOND +#include <rte_eth_bond.h> +#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 *** */ +struct cmd_set_bonding_balance_xmit_policy_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t balance_xmit_policy; +uint8_t port_id; +cmdline_fixed_string_t policy; +}; + +static void cmd_set_bonding_balance_xmit_policy_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; +portid_t port_id = res->port_id; +uint8_t policy; + +if (!strcmp (res->policy,"l2" )) { + policy =BALANCE_XMIT_POLICY_LAYER2 ; + }else if (!strcmp (res->policy,"l23" )) { + policy =BALANCE_XMIT_POLICY_LAYER23 ; + }else if (!strcmp (res->policy,"l34" )) { + policy =BALANCE_XMIT_POLICY_LAYER34 ; + }else { +printf ("\t Invalid xmit policy selection" ); +return ; + } + +/* Set the bonding mode for the relevant port. */ +if (0 !=rte_eth_bond_xmit_policy_set (port_id, policy)) { +printf ("\t Failed to set bonding balance xmit policy for port = %d.\n" , + port_id); + } +} + +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + set,"set" ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + balance_xmit_policy,"balance_xmit_policy" ); +cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + port_id,UINT8 ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + policy,"l2#l23#l34" ); + +cmdline_parse_inst_t cmd_set_balance_xmit_policy = { + .f = cmd_set_bonding_balance_xmit_policy_parsed, + .help_str ="set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_setbonding_balance_xmit_policy_set, + (void *)&cmd_setbonding_balance_xmit_policy_bonding, + (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, + (void *)&cmd_setbonding_balance_xmit_policy_port, + (void *)&cmd_setbonding_balance_xmit_policy_policy, +NULL + } +}; + +/* *** SHOW NIC BONDING CONFIGURATION *** */ +struct cmd_show_bonding_config_result { +cmdline_fixed_string_t show; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t config; +uint8_t port_id; +}; + +static void cmd_show_bonding_config_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_show_bonding_config_result *res = parsed_result; +int bonding_mode; +uint8_t slaves[RTE_MAX_ETHPORTS ]; +int num_slaves, num_active_slaves; +int primary_id; +int i; +portid_t port_id = res->port_id; + +/* Display the bonding mode.*/ + bonding_mode =rte_eth_bond_mode_get (port_id); +if (bonding_mode <0 ) { +printf ("\tFailed to get bonding mode for port = %d\n" , port_id); +return ; + }else +printf ("\tBonding mode: %d\n" , bonding_mode); + +if (bonding_mode ==BONDING_MODE_BALANCE ) { +int balance_xmit_policy; + + balance_xmit_policy =rte_eth_bond_xmit_policy_get (port_id); +if (balance_xmit_policy <0 ) { +printf ("\tFailed to get balance xmit policy for port = %d\n" , + port_id); +return ; + }else { +printf ("\tBalance Xmit Policy: " ); + +switch (balance_xmit_policy) { +case BALANCE_XMIT_POLICY_LAYER2 : +printf ("BALANCE_XMIT_POLICY_LAYER2" ); +break ; +case BALANCE_XMIT_POLICY_LAYER23 : +printf ("BALANCE_XMIT_POLICY_LAYER23" ); +break ; +case BALANCE_XMIT_POLICY_LAYER34 : +printf ("BALANCE_XMIT_POLICY_LAYER34" ); +break ; + } +printf ("\n" ); + } + } + + num_slaves =rte_eth_bond_slaves_get (port_id, slaves,RTE_MAX_ETHPORTS ); + +if (num_slaves <0 ) { +printf ("\tFailed to get slave list for port = %d\n" , port_id); +return ; + } +if (num_slaves >0 ) { +printf ("\tSlaves (%d): [" , num_slaves); +for (i =0 ; i < num_slaves -1 ; i++) +printf ("%d " , slaves[i]); + +printf ("%d]\n" , slaves[num_slaves -1 ]); + }else { +printf ("\tSlaves: []\n" ); + + } + + num_active_slaves =rte_eth_bond_active_slaves_get (port_id, slaves, +RTE_MAX_ETHPORTS ); + +if (num_active_slaves <0 ) { +printf ("\tFailed to get active slave list for port = %d\n" , port_id); +return ; + } +if (num_active_slaves >0 ) { +printf ("\tActive Slaves (%d): [" , num_active_slaves); +for (i =0 ; i < num_active_slaves -1 ; i++) +printf ("%d " , slaves[i]); + +printf ("%d]\n" , slaves[num_active_slaves -1 ]); + + }else { +printf ("\tActive Slaves: []\n" ); + + } + + primary_id =rte_eth_bond_primary_get (port_id); +if (primary_id <0 ) { +printf ("\tFailed to get primary slave for port = %d\n" , port_id); +return ; + }else +printf ("\tPrimary: [%d]\n" , primary_id); + +} + +cmdline_parse_token_string_t cmd_showbonding_config_show = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + show,"show" ); +cmdline_parse_token_string_t cmd_showbonding_config_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_showbonding_config_config = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + config,"config" ); +cmdline_parse_token_num_t cmd_showbonding_config_port = +TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_show_bonding_config = { + .f = cmd_show_bonding_config_parsed, + .help_str ="show bonding config (port_id): Show the bonding config for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_showbonding_config_show, + (void *)&cmd_showbonding_config_bonding, + (void *)&cmd_showbonding_config_config, + (void *)&cmd_showbonding_config_port, +NULL + } +}; + +/* *** SET BONDING PRIMARY *** */ +struct cmd_set_bonding_primary_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t primary; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_set_bonding_primary_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bonding_primary_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_primary_set (master_port_id, slave_port_id)) { +printf ("\t Failed to set primary slave for port = %d.\n" , + master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_setbonding_primary_set = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + set,"set" ); +cmdline_parse_token_string_t cmd_setbonding_primary_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_setbonding_primary_primary = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + primary,"primary" ); +cmdline_parse_token_num_t cmd_setbonding_primary_slave = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_setbonding_primary_port = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_set_bonding_primary = { + .f = cmd_set_bonding_primary_parsed, + .help_str ="set bonding primary (slave_id) (port_id): Set the primary slave for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_setbonding_primary_set, + (void *)&cmd_setbonding_primary_bonding, + (void *)&cmd_setbonding_primary_primary, + (void *)&cmd_setbonding_primary_slave, + (void *)&cmd_setbonding_primary_port, +NULL + } +}; + +/* *** ADD SLAVE *** */ +struct cmd_add_bonding_slave_result { +cmdline_fixed_string_t add; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t slave; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_add_bonding_slave_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_add_bonding_slave_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_slave_add (master_port_id, slave_port_id)) { +printf ("\t Failed to add slave %d to master port = %d.\n" , + slave_port_id, master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_addbonding_slave_add = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + add,"add" ); +cmdline_parse_token_string_t cmd_addbonding_slave_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_addbonding_slave_slave = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + slave,"slave" ); +cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = +TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_addbonding_slave_port = +TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_add_bonding_slave = { + .f = cmd_add_bonding_slave_parsed, + .help_str ="add bonding slave (slave_id) (port_id): Add a slave device to a bonded device" , + .data =NULL , + .tokens = { + (void *)&cmd_addbonding_slave_add, + (void *)&cmd_addbonding_slave_bonding, + (void *)&cmd_addbonding_slave_slave, + (void *)&cmd_addbonding_slave_slaveid, + (void *)&cmd_addbonding_slave_port, +NULL + } +}; + +/* *** REMOVE SLAVE *** */ +struct cmd_remove_bonding_slave_result { +cmdline_fixed_string_t remove; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t slave; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_remove_bonding_slave_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_remove_bonding_slave_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_slave_remove (master_port_id, slave_port_id)) { +printf ("\t Failed to remove slave %d from master port = %d.\n" , + slave_port_id, master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_removebonding_slave_remove = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + remove,"remove" ); +cmdline_parse_token_string_t cmd_removebonding_slave_bonding = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_removebonding_slave_slave = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + slave,"slave" ); +cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = + TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_removebonding_slave_port = + TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_remove_bonding_slave = { + .f = cmd_remove_bonding_slave_parsed, + .help_str ="remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device" , + .data =NULL , + .tokens = { + (void *)&cmd_removebonding_slave_remove, + (void *)&cmd_removebonding_slave_bonding, + (void *)&cmd_removebonding_slave_slave, + (void *)&cmd_removebonding_slave_slaveid, + (void *)&cmd_removebonding_slave_port, +NULL + } +}; + +/* *** CREATE BONDED DEVICE *** */ +struct cmd_create_bonded_device_result { +cmdline_fixed_string_t create; +cmdline_fixed_string_t bonded; +cmdline_fixed_string_t device; +uint8_t mode; +uint8_t socket; +}; + +static int bond_dev_num =0 ; + +static void cmd_create_bonded_device_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_create_bonded_device_result *res = parsed_result; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +int port_id; + +if (test_done ==0 ) { +printf ("Please stop forwarding first\n" ); +return ; + } + +snprintf (ethdev_name,RTE_ETH_NAME_MAX_LEN ,"eth_bond_testpmd_%d" , + bond_dev_num++); + +/* Create a new bonded device. */ + port_id =rte_eth_bond_create (ethdev_name, res->mode, res->socket); +if (port_id <0 ) { +printf ("\t Failed to create bonded device.\n" ); +return ; + }else { +printf ("Created new bonded device %s on (port %d).\n" , ethdev_name, + port_id); + +/* Update number of ports */ + nb_ports =rte_eth_dev_count (); +reconfig (port_id); +rte_eth_promiscuous_enable (port_id); + } + +} + +cmdline_parse_token_string_t cmd_createbonded_device_create = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + create,"create" ); +cmdline_parse_token_string_t cmd_createbonded_device_bonded = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + bonded,"bonded" ); +cmdline_parse_token_string_t cmd_createbonded_device_device = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + device,"device" ); +cmdline_parse_token_num_t cmd_createbonded_device_mode = + TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, + mode,UINT8 ); +cmdline_parse_token_num_t cmd_createbonded_device_socket = + TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, + socket,UINT8 ); + +cmdline_parse_inst_t cmd_create_bonded_device = { + .f = cmd_create_bonded_device_parsed, + .help_str ="create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket" , + .data =NULL , + .tokens = { + (void *)&cmd_createbonded_device_create, + (void *)&cmd_createbonded_device_bonded, + (void *)&cmd_createbonded_device_device, + (void *)&cmd_createbonded_device_mode, + (void *)&cmd_createbonded_device_socket, +NULL + } +}; + +/* *** SET MAC ADDRESS IN BONDED DEVICE *** */ +struct cmd_set_bond_mac_addr_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t mac_addr; +uint8_t port_num; +struct ether_addr address; +}; + +static void cmd_set_bond_mac_addr_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bond_mac_addr_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_mac_address_set (res->port_num, &res->address); + +/* 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_mac_addr_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); +cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, +"bonding" ); +cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, +"mac_addr" ); +cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8); +cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); + +cmdline_parse_inst_t cmd_set_bond_mac_addr = { + .f = cmd_set_bond_mac_addr_parsed, + .data = (void *)0 , + .help_str ="set bonding mac_addr (port_id) (address): " , + .tokens = { + (void *)&cmd_set_bond_mac_addr_set, + (void *)&cmd_set_bond_mac_addr_bonding, + (void *)&cmd_set_bond_mac_addr_mac, + (void *)&cmd_set_bond_mac_addr_portnum, + (void *)&cmd_set_bond_mac_addr_addr, +NULL + } +}; + +#endif /* RTE_LIBRTE_PMD_BOND */ +/* *** SET FORWARDING MODE *** */ struct cmd_set_fwd_mode_result {cmdline_fixed_string_t set;
@@ -6768,6 +7337,16 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, (cmdline_parse_inst_t *)&cmd_show_bypass_config, #endif +#ifdef RTE_LIBRTE_PMD_BOND + (cmdline_parse_inst_t *) &cmd_set_bonding_mode, + (cmdline_parse_inst_t *) &cmd_show_bonding_config, + (cmdline_parse_inst_t *) &cmd_set_bonding_primary, + (cmdline_parse_inst_t *) &cmd_add_bonding_slave, + (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, + (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, +#endif (cmdline_parse_inst_t *)&cmd_vlan_offload, (cmdline_parse_inst_t *)&cmd_vlan_tpid, (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
app/test-pmd/config.c +3 -1
@@ -252,6 +252,7 @@ void port_infos_display(portid_t port_id) {struct rte_port *port; +struct ether_addr mac_addr;struct rte_eth_link link;int vlan_offload;struct rte_mempool * mp;
@@ -265,7 +266,8 @@ port_infos_display(portid_t port_id)rte_eth_link_get_nowait (port_id, &link);printf ("\n%s Infos for port %-2d %s\n" , info_border, port_id, info_border); -print_ethaddr ("MAC address: " , &port->eth_addr); +rte_eth_macaddr_get (port_id, &mac_addr); +print_ethaddr ("MAC address: " , &mac_addr);printf ("\nConnect to socket: %u" , port->socket_id);if (port_numa[port_id] !=NUMA_NO_CONFIG ) {
app/test-pmd/parameters.c +3 -0
@@ -75,6 +75,9 @@#include <cmdline_parse.h> #include <cmdline_parse_etheraddr.h> #endif +#ifdef RTE_LIBRTE_PMD_BOND +#include <rte_eth_bond.h> +#endif #include "testpmd.h"
app/test-pmd/testpmd.c +32 -8
@@ -300,7 +300,7 @@ struct rte_fdir_conf fdir_conf = { .drop_queue = 127, }; -static volatile int test_done =1 ;/* stop packet forwarding when set to 1. */ +volatile int test_done =1 ;/* stop packet forwarding when set to 1. */ struct queue_stats_mappings tx_queue_stats_mappings_array[MAX_TX_QUEUE_STATS_MAPPINGS ];struct queue_stats_mappings rx_queue_stats_mappings_array[MAX_RX_QUEUE_STATS_MAPPINGS ];
@@ -625,6 +625,32 @@ init_config(void)rte_exit (EXIT_FAILURE ,"FAIL from init_fwd_streams()\n" ); } + +void +reconfig (portid_t new_port_id) +{ +struct rte_port *port; + +/* Reconfiguration of Ethernet ports. */ + ports =rte_realloc (ports, +sizeof (struct rte_port ) * nb_ports, +CACHE_LINE_SIZE ); +if (ports ==NULL ) { +rte_exit (EXIT_FAILURE ,"rte_realloc(%d struct rte_port) failed\n" , + nb_ports); + } + + port = &ports[new_port_id]; +rte_eth_dev_info_get (new_port_id, &port->dev_info); + +/* set flag to initialize port/queue */ + port->need_reconfig =1 ; + port->need_reconfig_queues =1 ; + +init_port_config (); +} + +int init_fwd_streams (void ) {
@@ -1252,7 +1278,7 @@ start_port(portid_t pid)portid_t pi;queueid_t qi;struct rte_port *port; -uint8_t *mac_addr; +struct ether_addr mac_addr;if (test_done ==0 ) {printf ("Please stop forwarding first\n" );
@@ -1380,10 +1406,11 @@ start_port(portid_t pid) RTE_PORT_HANDLING, RTE_PORT_STARTED) == 0)printf ("Port %d can not be set into started\n" , pi); - mac_addr = port->eth_addr.addr_bytes; +rte_eth_macaddr_get (pi, &mac_addr);printf ("Port %d: %02X:%02X:%02X:%02X:%02X:%02X\n" , pi, - mac_addr[0 ], mac_addr[1 ], mac_addr[2 ], - mac_addr[3 ], mac_addr[4 ], mac_addr[5 ]); + mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], + mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], + mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ]);/* at least one port started, need checking link status */ need_check_link_status =1 ;
@@ -1826,9 +1853,6 @@ main(int argc, char** argv)if (diag <0 )rte_panic ("Cannot init EAL\n" ); -if (rte_eal_pci_probe ()) -rte_panic ("Cannot probe PCI\n" ); - nb_ports = (portid_t )rte_eth_dev_count ();if (nb_ports ==0 ) rte_exit(EXIT_FAILURE, "No probed ethernet devices - "
app/test-pmd/testpmd.h +2 -0
@@ -281,6 +281,7 @@ extern uint16_t port_topology; /**< set by "--port-topology" parameter */extern uint8_t no_flush_rx;/**<set by "--no-flush-rx" parameter */ extern uint8_t mp_anon;/**< set by "--mp-anon" parameter */ extern uint8_t no_link_check;/**<set by "--disable-link-check" parameter */ +extern volatile int test_done;/* stop packet forwarding when set to 1. */ #ifdef RTE_NIC_BYPASS extern uint32_t bypass_timeout;/**< Store the NIC bypass watchdog timeout */
@@ -454,6 +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);int init_fwd_streams (void );void port_mtu_set (portid_t port_id,uint16_t mtu);
Signature · 1 line
1.7.0.7
Re: [PATCH v10 0/5] link bonding
In reply to a message not in the archive2014-06-27 11:18, Declan Doherty:
Quoted 1 line
Fixed copyright in link bonding library
Makefile
A small fix is needed in Makefile for renaming of file rte_eth_bond_args.c.
And more important, it cannot be built as an optional shared library as test applications call functions from the specific API.
The best design would be to have a base library always linked and an optional PMD layer.
Signature · 1 line
Thomas
v11 cover link bonding library
In reply to a message not in the archiveHi 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
PATCH v11 1/5 bond: new link bonding library
In reply to a message not in the archiveInitial 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
--- 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
config/common_bsdapp +5 -0
@@ -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
config/common_linuxapp +5 -0
@@ -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
doc/doxy-api-index.md +1 -0
@@ -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)
doc/doxy-api.conf +1 -0
@@ -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 \
lib/Makefile +1 -0
@@ -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
lib/librte_pmd_bond/Makefile new file +61 -0
61 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond.h new file +255 -0
255 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_api.c new file +662 -0
662 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_args.c new file +252 -0
252 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_pmd.c new file +1212 -0
1,212 lines not on this page · raw message
lib/librte_pmd_bond/rte_eth_bond_private.h new file +215 -0
215 lines not on this page · raw message
mk/rte.app.mk +4 -0
@@ -205,6 +205,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) LDLIBS += -lrte_pmd_pcap -lpcap endif +ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y) +LDLIBS += -lrte_pmd_bond +endif + endif LDLIBS += $(EXECENV_LDLIBS)
Signature · 1 line
1.7.0.7
PATCH v11 2/5 ethdev: add unique name to devices
In reply to a message not in the archiveAdding 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.
--- 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(-)
lib/librte_ether/rte_ethdev.c +28 -3
@@ -65,6 +65,7 @@#include <rte_mbuf.h> #include <rte_errno.h> #include <rte_spinlock.h> +#include <rte_string_fns.h> #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 ;
lib/librte_ether/rte_ethdev.h +6 -1
@@ -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 name Unique 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 ;/**
lib/librte_pmd_pcap/rte_eth_pcap.c +11 -11
@@ -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 unsigned nb_tx_queues, const unsigned numa_node, struct pmd_internals **internals,
@@ -558,20 +558,20 @@ rte_pmd_init_internals(const unsigned nb_rx_queues,/* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data =rte_zmalloc_socket (NULL ,sizeof (*data),0 , numa_node); + data =rte_zmalloc_socket (name,sizeof (*data),0 , numa_node);if (data ==NULL ) goto error; - pci_dev =rte_zmalloc_socket (NULL ,sizeof (*pci_dev),0 , numa_node); + pci_dev =rte_zmalloc_socket (name,sizeof (*pci_dev),0 , numa_node);if (pci_dev ==NULL ) goto error; - *internals =rte_zmalloc_socket (NULL ,sizeof (**internals),0 , numa_node); + *internals =rte_zmalloc_socket (name,sizeof (**internals),0 , numa_node);if (*internals ==NULL ) goto error;/* reserve an ethdev entry */ - *eth_dev =rte_eth_dev_allocate (); + *eth_dev =rte_eth_dev_allocate (name);if (*eth_dev ==NULL ) goto error;
@@ -617,7 +617,7 @@ rte_pmd_init_internals(const unsigned nb_rx_queues, } static int -rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[], +rte_eth_from_pcaps_n_dumpers(const char *name, pcap_t * const rx_queues[], const unsigned nb_rx_queues, pcap_dumper_t * const tx_queues[], const unsigned nb_tx_queues,
@@ -634,7 +634,7 @@ rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[],if (tx_queues ==NULL && nb_tx_queues >0 )return -1 ; -if (rte_pmd_init_internals (nb_rx_queues, nb_tx_queues, numa_node, +if (rte_pmd_init_internals (name, nb_rx_queues, nb_tx_queues, numa_node, &internals, ð_dev, kvlist) <0 )return -1 ;
@@ -652,7 +652,7 @@ rte_eth_from_pcaps_n_dumpers(pcap_t * const rx_queues[], } static int -rte_eth_from_pcaps(pcap_t * const rx_queues[], +rte_eth_from_pcaps(const char *name, pcap_t * const rx_queues[], const unsigned nb_rx_queues, pcap_t * const tx_queues[], const unsigned nb_tx_queues,
@@ -669,7 +669,7 @@ rte_eth_from_pcaps(pcap_t * const rx_queues[],if (tx_queues ==NULL && nb_tx_queues >0 )return -1 ; -if (rte_pmd_init_internals (nb_rx_queues, nb_tx_queues, numa_node, +if (rte_pmd_init_internals (name, nb_rx_queues, nb_tx_queues, numa_node, &internals, ð_dev, kvlist) <0 )return -1 ;
@@ -760,10 +760,10 @@ rte_pmd_pcap_devinit(const char *name, const char *params)return -1 ;if (using_dumpers) -return rte_eth_from_pcaps_n_dumpers (pcaps.pcaps, pcaps.num_of_rx, +return rte_eth_from_pcaps_n_dumpers (name, pcaps.pcaps, pcaps.num_of_rx, dumpers.dumpers, dumpers.num_of_tx, numa_node, kvlist); -return rte_eth_from_pcaps (pcaps.pcaps, pcaps.num_of_rx, dumpers.pcaps, +return rte_eth_from_pcaps (name, pcaps.pcaps, pcaps.num_of_rx, dumpers.pcaps, dumpers.num_of_tx, numa_node, kvlist); }
lib/librte_pmd_ring/rte_eth_ring.c +17 -15
@@ -219,7 +219,7 @@ static struct eth_dev_ops ops = { }; int -rte_eth_from_rings(struct rte_ring *const rx_queues[], +rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], const unsigned nb_rx_queues, struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
@@ -243,20 +243,20 @@ rte_eth_from_rings(struct rte_ring *const rx_queues[],/* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data =rte_zmalloc_socket (NULL ,sizeof (*data),0 , numa_node); + data =rte_zmalloc_socket (name,sizeof (*data),0 , numa_node);if (data ==NULL ) goto error; - pci_dev =rte_zmalloc_socket (NULL ,sizeof (*pci_dev),0 , numa_node); + pci_dev =rte_zmalloc_socket (name,sizeof (*pci_dev),0 , numa_node);if (pci_dev ==NULL ) goto error; - internals =rte_zmalloc_socket (NULL ,sizeof (*internals),0 , numa_node); + internals =rte_zmalloc_socket (name,sizeof (*internals),0 , numa_node);if (internals ==NULL ) goto error;/* reserve an ethdev entry */ - eth_dev =rte_eth_dev_allocate (); + eth_dev =rte_eth_dev_allocate (name);if (eth_dev ==NULL ) goto error;
@@ -335,7 +335,7 @@ eth_dev_ring_create(const char *name, const unsigned numa_node,return -1 ; } -if (rte_eth_from_rings (rxtx, num_rings, rxtx, num_rings, numa_node)) +if (rte_eth_from_rings (name, rxtx, num_rings, rxtx, num_rings, numa_node))return -1 ;return 0 ;
@@ -352,29 +352,31 @@ eth_dev_ring_pair_create(const char *name, const unsigned numa_node,struct rte_ring *rx[RTE_PMD_RING_MAX_RX_RINGS ];struct rte_ring *tx[RTE_PMD_RING_MAX_TX_RINGS ];unsigned i; -char rng_name[RTE_RING_NAMESIZE ]; +char rx_rng_name[RTE_RING_NAMESIZE ]; +char tx_rng_name[RTE_RING_NAMESIZE ];unsigned num_rings =RTE_MIN (RTE_PMD_RING_MAX_RX_RINGS ,RTE_PMD_RING_MAX_TX_RINGS );for (i =0 ; i < num_rings; i++) { -snprintf (rng_name,sizeof (rng_name),"ETH_RX%u_%s" , i, name); +snprintf (rx_rng_name,sizeof (rx_rng_name),"ETH_RX%u_%s" , i, name); rx[i] = (action ==DEV_CREATE ) ? -rte_ring_create (rng_name,1024 , numa_node, +rte_ring_create (rx_rng_name,1024 , numa_node,RING_F_SP_ENQ |RING_F_SC_DEQ ) : -rte_ring_lookup (rng_name); +rte_ring_lookup (rx_rng_name);if (rx[i] ==NULL )return -1 ; -snprintf (rng_name,sizeof (rng_name),"ETH_TX%u_%s" , i, name); +snprintf (tx_rng_name,sizeof (tx_rng_name),"ETH_TX%u_%s" , i, name); tx[i] = (action ==DEV_CREATE ) ? -rte_ring_create (rng_name,1024 , numa_node, +rte_ring_create (tx_rng_name,1024 , numa_node,RING_F_SP_ENQ |RING_F_SC_DEQ ): -rte_ring_lookup (rng_name); +rte_ring_lookup (tx_rng_name);if (tx[i] ==NULL )return -1 ; } -if (rte_eth_from_rings (rx, num_rings, tx, num_rings, numa_node) || -rte_eth_from_rings (tx, num_rings, rx, num_rings, numa_node) ) +if (rte_eth_from_rings (rx_rng_name, rx, num_rings, tx, num_rings, + numa_node) ||rte_eth_from_rings (tx_rng_name, tx, num_rings, rx, + num_rings, numa_node))return -1 ;return 0 ;
lib/librte_pmd_ring/rte_eth_ring.h +2 -1
@@ -40,7 +40,8 @@ extern "C" {#include <rte_ring.h> -int rte_eth_from_rings(struct rte_ring * const rx_queues[], +int rte_eth_from_rings(const char *name, + struct rte_ring * const rx_queues[], const unsigned nb_rx_queues, struct rte_ring *const tx_queues[], const unsigned nb_tx_queues,
lib/librte_pmd_xenvirt/rte_eth_xenvirt.c +1 -1
@@ -647,7 +647,7 @@ eth_dev_xenvirt_create(const char *name, const char *params, goto err;/* reserve an ethdev entry */ - eth_dev =rte_eth_dev_allocate (); + eth_dev =rte_eth_dev_allocate (name);if (eth_dev ==NULL ) goto err;
Signature · 1 line
1.7.0.7
PATCH v11 3/5 eal: support link bonding device initialization
In reply to a message not in the archiveUpdating 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.
--- 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(-)
lib/librte_eal/bsdapp/eal/eal.c +9 -1
@@ -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; }
lib/librte_eal/common/eal_common_dev.c +40 -18
77 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +3 -0
@@ -150,6 +150,9 @@ rte_eal_pci_probe(void) probe_all =1 ; TAILQ_FOREACH(dev, &pci_device_list, next) { +/* check if device has already been initialized */ +if (dev->driver !=NULL ) +continue ;/* set devargs in PCI structure */ devargs =pci_devargs_lookup (dev);
lib/librte_eal/common/include/eal_private.h +0 -7
@@ -196,11 +196,4 @@ int rte_eal_intr_init(void);*/ int rte_eal_alarm_init (void ); -/** -* This function initialises any virtual devices -* -* This function is private to the EAL. -*/ -int rte_eal_dev_init (void ); -#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/common/include/rte_dev.h +12 -2
@@ -62,6 +62,16 @@ typedef int (rte_dev_init_t)(const char *name, const char *args);enum pmd_type {PMD_VDEV =0 ,PMD_PDEV =1 , +PMD_BDEV =2 ,/**< Poll Mode Driver Bonded Device*/ +}; + +#define PMD_BOND_NAME "eth_bond" + +/** +* Driver initialization */ +enum pmd_init_priority { +PMD_INIT_PRE_PCI_PROBE =0 , +PMD_INIT_POST_PCI_PROBE =1 , };/**
@@ -93,9 +103,9 @@ void rte_eal_driver_register(struct rte_driver *driver);void rte_eal_driver_unregister (struct rte_driver *driver);/** -* Initalize all the registered drivers in this process +* Initialize all the registered drivers in this process */ -int rte_eal_dev_init (void ); +int rte_eal_dev_init (uint8_t init_priority);#define PMD_REGISTER_DRIVER (d)\ void devinitfn_ ##d(void);\
lib/librte_eal/linuxapp/eal/eal.c +10 -1
@@ -75,6 +75,7 @@#include <rte_atomic.h> #include <malloc_heap.h> #include <rte_eth_ring.h> +#include <rte_dev.h> #include "eal_private.h" #include "eal_thread.h"
@@ -1097,7 +1098,7 @@ rte_eal_init(int argc, char **argv)RTE_LOG (DEBUG ,EAL ,"Master core %u is ready (tid=%x)\n" , rte_config.master_lcore, (int )thread_id); -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) {
@@ -1127,6 +1128,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; }
Signature · 1 line
1.7.0.7
PATCH v11 4/5 bond: unit tests
In reply to a message not in the archiveIncluding:
- 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
--- 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
app/test/Makefile +5 -1
@@ -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
app/test/commands.c +7 -0
@@ -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#"
app/test/packet_burst_generator.c new file +287 -0
287 lines not on this page · raw message
app/test/packet_burst_generator.h new file +78 -0
78 lines not on this page · raw message
app/test/test.h +1 -0
@@ -97,6 +97,7 @@ int test_distributor(void);int test_distributor_perf (void );int test_kvargs (void );int test_devargs (void ); +int test_link_bonding (void );int test_pci_run;
app/test/test_link_bonding.c new file +3958 -0
2,597 lines not on this page · raw message
app/test/virtual_pmd.c new file +574 -0
574 lines not on this page · raw message
app/test/virtual_pmd.h new file +74 -0
74 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.0.7
Part of the diff is not shown here. View the raw message.
PATCH v11 5/5 bond: testpmd support
In reply to a message not in the archive - 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
--- 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(-)
app/test-pmd/cmdline.c +579 -0
@@ -84,6 +84,9 @@#include <cmdline_socket.h> #include <cmdline.h> #include <rte_pci_dev_ids.h> +#ifdef RTE_LIBRTE_PMD_BOND +#include <rte_eth_bond.h> +#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 *** */ +struct cmd_set_bonding_balance_xmit_policy_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t balance_xmit_policy; +uint8_t port_id; +cmdline_fixed_string_t policy; +}; + +static void cmd_set_bonding_balance_xmit_policy_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; +portid_t port_id = res->port_id; +uint8_t policy; + +if (!strcmp (res->policy,"l2" )) { + policy =BALANCE_XMIT_POLICY_LAYER2 ; + }else if (!strcmp (res->policy,"l23" )) { + policy =BALANCE_XMIT_POLICY_LAYER23 ; + }else if (!strcmp (res->policy,"l34" )) { + policy =BALANCE_XMIT_POLICY_LAYER34 ; + }else { +printf ("\t Invalid xmit policy selection" ); +return ; + } + +/* Set the bonding mode for the relevant port. */ +if (0 !=rte_eth_bond_xmit_policy_set (port_id, policy)) { +printf ("\t Failed to set bonding balance xmit policy for port = %d.\n" , + port_id); + } +} + +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + set,"set" ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + balance_xmit_policy,"balance_xmit_policy" ); +cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + port_id,UINT8 ); +cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, + policy,"l2#l23#l34" ); + +cmdline_parse_inst_t cmd_set_balance_xmit_policy = { + .f = cmd_set_bonding_balance_xmit_policy_parsed, + .help_str ="set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_setbonding_balance_xmit_policy_set, + (void *)&cmd_setbonding_balance_xmit_policy_bonding, + (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, + (void *)&cmd_setbonding_balance_xmit_policy_port, + (void *)&cmd_setbonding_balance_xmit_policy_policy, +NULL + } +}; + +/* *** SHOW NIC BONDING CONFIGURATION *** */ +struct cmd_show_bonding_config_result { +cmdline_fixed_string_t show; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t config; +uint8_t port_id; +}; + +static void cmd_show_bonding_config_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_show_bonding_config_result *res = parsed_result; +int bonding_mode; +uint8_t slaves[RTE_MAX_ETHPORTS ]; +int num_slaves, num_active_slaves; +int primary_id; +int i; +portid_t port_id = res->port_id; + +/* Display the bonding mode.*/ + bonding_mode =rte_eth_bond_mode_get (port_id); +if (bonding_mode <0 ) { +printf ("\tFailed to get bonding mode for port = %d\n" , port_id); +return ; + }else +printf ("\tBonding mode: %d\n" , bonding_mode); + +if (bonding_mode ==BONDING_MODE_BALANCE ) { +int balance_xmit_policy; + + balance_xmit_policy =rte_eth_bond_xmit_policy_get (port_id); +if (balance_xmit_policy <0 ) { +printf ("\tFailed to get balance xmit policy for port = %d\n" , + port_id); +return ; + }else { +printf ("\tBalance Xmit Policy: " ); + +switch (balance_xmit_policy) { +case BALANCE_XMIT_POLICY_LAYER2 : +printf ("BALANCE_XMIT_POLICY_LAYER2" ); +break ; +case BALANCE_XMIT_POLICY_LAYER23 : +printf ("BALANCE_XMIT_POLICY_LAYER23" ); +break ; +case BALANCE_XMIT_POLICY_LAYER34 : +printf ("BALANCE_XMIT_POLICY_LAYER34" ); +break ; + } +printf ("\n" ); + } + } + + num_slaves =rte_eth_bond_slaves_get (port_id, slaves,RTE_MAX_ETHPORTS ); + +if (num_slaves <0 ) { +printf ("\tFailed to get slave list for port = %d\n" , port_id); +return ; + } +if (num_slaves >0 ) { +printf ("\tSlaves (%d): [" , num_slaves); +for (i =0 ; i < num_slaves -1 ; i++) +printf ("%d " , slaves[i]); + +printf ("%d]\n" , slaves[num_slaves -1 ]); + }else { +printf ("\tSlaves: []\n" ); + + } + + num_active_slaves =rte_eth_bond_active_slaves_get (port_id, slaves, +RTE_MAX_ETHPORTS ); + +if (num_active_slaves <0 ) { +printf ("\tFailed to get active slave list for port = %d\n" , port_id); +return ; + } +if (num_active_slaves >0 ) { +printf ("\tActive Slaves (%d): [" , num_active_slaves); +for (i =0 ; i < num_active_slaves -1 ; i++) +printf ("%d " , slaves[i]); + +printf ("%d]\n" , slaves[num_active_slaves -1 ]); + + }else { +printf ("\tActive Slaves: []\n" ); + + } + + primary_id =rte_eth_bond_primary_get (port_id); +if (primary_id <0 ) { +printf ("\tFailed to get primary slave for port = %d\n" , port_id); +return ; + }else +printf ("\tPrimary: [%d]\n" , primary_id); + +} + +cmdline_parse_token_string_t cmd_showbonding_config_show = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + show,"show" ); +cmdline_parse_token_string_t cmd_showbonding_config_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_showbonding_config_config = +TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, + config,"config" ); +cmdline_parse_token_num_t cmd_showbonding_config_port = +TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_show_bonding_config = { + .f = cmd_show_bonding_config_parsed, + .help_str ="show bonding config (port_id): Show the bonding config for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_showbonding_config_show, + (void *)&cmd_showbonding_config_bonding, + (void *)&cmd_showbonding_config_config, + (void *)&cmd_showbonding_config_port, +NULL + } +}; + +/* *** SET BONDING PRIMARY *** */ +struct cmd_set_bonding_primary_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t primary; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_set_bonding_primary_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bonding_primary_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_primary_set (master_port_id, slave_port_id)) { +printf ("\t Failed to set primary slave for port = %d.\n" , + master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_setbonding_primary_set = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + set,"set" ); +cmdline_parse_token_string_t cmd_setbonding_primary_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_setbonding_primary_primary = +TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, + primary,"primary" ); +cmdline_parse_token_num_t cmd_setbonding_primary_slave = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_setbonding_primary_port = +TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_set_bonding_primary = { + .f = cmd_set_bonding_primary_parsed, + .help_str ="set bonding primary (slave_id) (port_id): Set the primary slave for port_id" , + .data =NULL , + .tokens = { + (void *)&cmd_setbonding_primary_set, + (void *)&cmd_setbonding_primary_bonding, + (void *)&cmd_setbonding_primary_primary, + (void *)&cmd_setbonding_primary_slave, + (void *)&cmd_setbonding_primary_port, +NULL + } +}; + +/* *** ADD SLAVE *** */ +struct cmd_add_bonding_slave_result { +cmdline_fixed_string_t add; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t slave; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_add_bonding_slave_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_add_bonding_slave_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_slave_add (master_port_id, slave_port_id)) { +printf ("\t Failed to add slave %d to master port = %d.\n" , + slave_port_id, master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_addbonding_slave_add = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + add,"add" ); +cmdline_parse_token_string_t cmd_addbonding_slave_bonding = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_addbonding_slave_slave = +TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, + slave,"slave" ); +cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = +TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_addbonding_slave_port = +TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_add_bonding_slave = { + .f = cmd_add_bonding_slave_parsed, + .help_str ="add bonding slave (slave_id) (port_id): Add a slave device to a bonded device" , + .data =NULL , + .tokens = { + (void *)&cmd_addbonding_slave_add, + (void *)&cmd_addbonding_slave_bonding, + (void *)&cmd_addbonding_slave_slave, + (void *)&cmd_addbonding_slave_slaveid, + (void *)&cmd_addbonding_slave_port, +NULL + } +}; + +/* *** REMOVE SLAVE *** */ +struct cmd_remove_bonding_slave_result { +cmdline_fixed_string_t remove; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t slave; +uint8_t slave_id; +uint8_t port_id; +}; + +static void cmd_remove_bonding_slave_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_remove_bonding_slave_result *res = parsed_result; +portid_t master_port_id = res->port_id; +portid_t slave_port_id = res->slave_id; + +/* Set the primary slave for a bonded device. */ +if (0 !=rte_eth_bond_slave_remove (master_port_id, slave_port_id)) { +printf ("\t Failed to remove slave %d from master port = %d.\n" , + slave_port_id, master_port_id); +return ; + } +init_port_config (); +} + +cmdline_parse_token_string_t cmd_removebonding_slave_remove = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + remove,"remove" ); +cmdline_parse_token_string_t cmd_removebonding_slave_bonding = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + bonding,"bonding" ); +cmdline_parse_token_string_t cmd_removebonding_slave_slave = + TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, + slave,"slave" ); +cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = + TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, + slave_id,UINT8 ); +cmdline_parse_token_num_t cmd_removebonding_slave_port = + TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, + port_id,UINT8 ); + +cmdline_parse_inst_t cmd_remove_bonding_slave = { + .f = cmd_remove_bonding_slave_parsed, + .help_str ="remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device" , + .data =NULL , + .tokens = { + (void *)&cmd_removebonding_slave_remove, + (void *)&cmd_removebonding_slave_bonding, + (void *)&cmd_removebonding_slave_slave, + (void *)&cmd_removebonding_slave_slaveid, + (void *)&cmd_removebonding_slave_port, +NULL + } +}; + +/* *** CREATE BONDED DEVICE *** */ +struct cmd_create_bonded_device_result { +cmdline_fixed_string_t create; +cmdline_fixed_string_t bonded; +cmdline_fixed_string_t device; +uint8_t mode; +uint8_t socket; +}; + +static int bond_dev_num =0 ; + +static void cmd_create_bonded_device_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_create_bonded_device_result *res = parsed_result; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +int port_id; + +if (test_done ==0 ) { +printf ("Please stop forwarding first\n" ); +return ; + } + +snprintf (ethdev_name,RTE_ETH_NAME_MAX_LEN ,"eth_bond_testpmd_%d" , + bond_dev_num++); + +/* Create a new bonded device. */ + port_id =rte_eth_bond_create (ethdev_name, res->mode, res->socket); +if (port_id <0 ) { +printf ("\t Failed to create bonded device.\n" ); +return ; + }else { +printf ("Created new bonded device %s on (port %d).\n" , ethdev_name, + port_id); + +/* Update number of ports */ + nb_ports =rte_eth_dev_count (); +reconfig (port_id); +rte_eth_promiscuous_enable (port_id); + } + +} + +cmdline_parse_token_string_t cmd_createbonded_device_create = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + create,"create" ); +cmdline_parse_token_string_t cmd_createbonded_device_bonded = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + bonded,"bonded" ); +cmdline_parse_token_string_t cmd_createbonded_device_device = + TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, + device,"device" ); +cmdline_parse_token_num_t cmd_createbonded_device_mode = + TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, + mode,UINT8 ); +cmdline_parse_token_num_t cmd_createbonded_device_socket = + TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, + socket,UINT8 ); + +cmdline_parse_inst_t cmd_create_bonded_device = { + .f = cmd_create_bonded_device_parsed, + .help_str ="create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket" , + .data =NULL , + .tokens = { + (void *)&cmd_createbonded_device_create, + (void *)&cmd_createbonded_device_bonded, + (void *)&cmd_createbonded_device_device, + (void *)&cmd_createbonded_device_mode, + (void *)&cmd_createbonded_device_socket, +NULL + } +}; + +/* *** SET MAC ADDRESS IN BONDED DEVICE *** */ +struct cmd_set_bond_mac_addr_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t bonding; +cmdline_fixed_string_t mac_addr; +uint8_t port_num; +struct ether_addr address; +}; + +static void cmd_set_bond_mac_addr_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_set_bond_mac_addr_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_mac_address_set (res->port_num, &res->address); + +/* 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_mac_addr_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); +cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, +"bonding" ); +cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = + TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, +"mac_addr" ); +cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8); +cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); + +cmdline_parse_inst_t cmd_set_bond_mac_addr = { + .f = cmd_set_bond_mac_addr_parsed, + .data = (void *)0 , + .help_str ="set bonding mac_addr (port_id) (address): " , + .tokens = { + (void *)&cmd_set_bond_mac_addr_set, + (void *)&cmd_set_bond_mac_addr_bonding, + (void *)&cmd_set_bond_mac_addr_mac, + (void *)&cmd_set_bond_mac_addr_portnum, + (void *)&cmd_set_bond_mac_addr_addr, +NULL + } +}; + +#endif /* RTE_LIBRTE_PMD_BOND */ +/* *** SET FORWARDING MODE *** */ struct cmd_set_fwd_mode_result {cmdline_fixed_string_t set;
@@ -6768,6 +7337,16 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, (cmdline_parse_inst_t *)&cmd_show_bypass_config, #endif +#ifdef RTE_LIBRTE_PMD_BOND + (cmdline_parse_inst_t *) &cmd_set_bonding_mode, + (cmdline_parse_inst_t *) &cmd_show_bonding_config, + (cmdline_parse_inst_t *) &cmd_set_bonding_primary, + (cmdline_parse_inst_t *) &cmd_add_bonding_slave, + (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, + (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, +#endif (cmdline_parse_inst_t *)&cmd_vlan_offload, (cmdline_parse_inst_t *)&cmd_vlan_tpid, (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
app/test-pmd/config.c +3 -1
@@ -252,6 +252,7 @@ void port_infos_display(portid_t port_id) {struct rte_port *port; +struct ether_addr mac_addr;struct rte_eth_link link;int vlan_offload;struct rte_mempool * mp;
@@ -265,7 +266,8 @@ port_infos_display(portid_t port_id)rte_eth_link_get_nowait (port_id, &link);printf ("\n%s Infos for port %-2d %s\n" , info_border, port_id, info_border); -print_ethaddr ("MAC address: " , &port->eth_addr); +rte_eth_macaddr_get (port_id, &mac_addr); +print_ethaddr ("MAC address: " , &mac_addr);printf ("\nConnect to socket: %u" , port->socket_id);if (port_numa[port_id] !=NUMA_NO_CONFIG ) {
app/test-pmd/parameters.c +3 -0
@@ -75,6 +75,9 @@#include <cmdline_parse.h> #include <cmdline_parse_etheraddr.h> #endif +#ifdef RTE_LIBRTE_PMD_BOND +#include <rte_eth_bond.h> +#endif #include "testpmd.h"
app/test-pmd/testpmd.c +32 -8
@@ -300,7 +300,7 @@ struct rte_fdir_conf fdir_conf = { .drop_queue = 127, }; -static volatile int test_done =1 ;/* stop packet forwarding when set to 1. */ +volatile int test_done =1 ;/* stop packet forwarding when set to 1. */ struct queue_stats_mappings tx_queue_stats_mappings_array[MAX_TX_QUEUE_STATS_MAPPINGS ];struct queue_stats_mappings rx_queue_stats_mappings_array[MAX_RX_QUEUE_STATS_MAPPINGS ];
@@ -625,6 +625,32 @@ init_config(void)rte_exit (EXIT_FAILURE ,"FAIL from init_fwd_streams()\n" ); } + +void +reconfig (portid_t new_port_id) +{ +struct rte_port *port; + +/* Reconfiguration of Ethernet ports. */ + ports =rte_realloc (ports, +sizeof (struct rte_port ) * nb_ports, +CACHE_LINE_SIZE ); +if (ports ==NULL ) { +rte_exit (EXIT_FAILURE ,"rte_realloc(%d struct rte_port) failed\n" , + nb_ports); + } + + port = &ports[new_port_id]; +rte_eth_dev_info_get (new_port_id, &port->dev_info); + +/* set flag to initialize port/queue */ + port->need_reconfig =1 ; + port->need_reconfig_queues =1 ; + +init_port_config (); +} + +int init_fwd_streams (void ) {
@@ -1252,7 +1278,7 @@ start_port(portid_t pid)portid_t pi;queueid_t qi;struct rte_port *port; -uint8_t *mac_addr; +struct ether_addr mac_addr;if (test_done ==0 ) {printf ("Please stop forwarding first\n" );
@@ -1380,10 +1406,11 @@ start_port(portid_t pid) RTE_PORT_HANDLING, RTE_PORT_STARTED) == 0)printf ("Port %d can not be set into started\n" , pi); - mac_addr = port->eth_addr.addr_bytes; +rte_eth_macaddr_get (pi, &mac_addr);printf ("Port %d: %02X:%02X:%02X:%02X:%02X:%02X\n" , pi, - mac_addr[0 ], mac_addr[1 ], mac_addr[2 ], - mac_addr[3 ], mac_addr[4 ], mac_addr[5 ]); + mac_addr.addr_bytes[0 ], mac_addr.addr_bytes[1 ], + mac_addr.addr_bytes[2 ], mac_addr.addr_bytes[3 ], + mac_addr.addr_bytes[4 ], mac_addr.addr_bytes[5 ]);/* at least one port started, need checking link status */ need_check_link_status =1 ;
@@ -1826,9 +1853,6 @@ main(int argc, char** argv)if (diag <0 )rte_panic ("Cannot init EAL\n" ); -if (rte_eal_pci_probe ()) -rte_panic ("Cannot probe PCI\n" ); - nb_ports = (portid_t )rte_eth_dev_count ();if (nb_ports ==0 ) rte_exit(EXIT_FAILURE, "No probed ethernet devices - "
app/test-pmd/testpmd.h +2 -0
@@ -281,6 +281,7 @@ extern uint16_t port_topology; /**< set by "--port-topology" parameter */extern uint8_t no_flush_rx;/**<set by "--no-flush-rx" parameter */ extern uint8_t mp_anon;/**< set by "--mp-anon" parameter */ extern uint8_t no_link_check;/**<set by "--disable-link-check" parameter */ +extern volatile int test_done;/* stop packet forwarding when set to 1. */ #ifdef RTE_NIC_BYPASS extern uint32_t bypass_timeout;/**< Store the NIC bypass watchdog timeout */
@@ -454,6 +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);int init_fwd_streams (void );void port_mtu_set (portid_t port_id,uint16_t mtu);
Signature · 1 line
1.7.0.7
Re: [PATCH v11 4/5] bond: unit tests
In reply to a message not in the archiveHi Declan,
2014-06-29 18:49, Declan Doherty:
app/test/Makefile SRCS-$(CONFIG_RTE_APP_TEST) += test_ivshmem.c · line 112
Quoted 8 lines
app/test/Makefile +5
-0+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
I think there is a cleaner way to fix build without bonding. See my patch proposal below:
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_BOND) += test_link_bonding.c
SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
Signature · 1 line
Thomas
Re: [PATCH v11 1/5] bond: new link bonding library
In reply to a message not in the archiveHi Declan,
2014-06-29 18:49, Declan Doherty:
mk/rte.app.mk ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) · line 212
Quoted 11 lines
mk/rte.app.mk +4
-0@@ -205,6 +205,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) LDLIBS += -lrte_pmd_pcap -lpcap endif +ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y) +LDLIBS += -lrte_pmd_bond +endif + endif
This part is linking bonding library only in case of static libraries. But this library has a specific API. So it cannot be a plugin and must always be linked. That's why I suggested to split the library.
Instead, I suggest to always link with bonding library. See my proposal below:
mk/rte.app.mk +6 -1
@@ -175,7 +175,12 @@ LDLIBS += -lrte_pmd_xenvirt LDLIBS += -lxenstore endif +ifeq ($(CONFIG_RTE_LIBRTE_PMD_BOND),y) +LDLIBS += -lrte_pmd_bond +endif + ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n) +# plugins (link only if static libraries) ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y) LDLIBS += -lrte_pmd_vmxnet3_uio
@@ -205,7 +210,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) LDLIBS += -lrte_pmd_pcap -lpcap endif -endif +endif # plugins (link only if static libraries)
Adding comments to explain plugin section will be clearer.
Signature · 1 line
Thomas
Re: [PATCH v11 0/5] link bonding library
In reply to a message not in the archiveHi Declan,
2014-06-29 18:49, Declan Doherty:
Quoted 6 lines
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
You fixed optional building but there is still an issue when building shared library.
As you don't want to split the library to separate the PMD plugin from the specific API, I suggest to not consider it as a plugin (unlike other PMDs).
I've sent some patches about these 2 topics. If you agree, I'll apply them, merged with your serie.
Thanks
Signature · 1 line
Thomas
Re: [PATCH v11 0/5] link bonding library
Quoted 22 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, June 30, 2014 10:21 AM
To: Doherty, Declan
Cc: [email protected]
Subject: Re: [PATCH v11 0/5] link bonding libraryHi Declan,
2014-06-29 18:49, Declan Doherty:
Quoted 6 lines
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
You fixed optional building but there is still an issue when building shared library.
As you don't want to split the library to separate the PMD plugin from the specific API, I suggest to not consider it as a plugin (unlike other PMDs).
Quoted 6 lines
I've sent some patches about these 2 topics. If you agree, I'll apply them, merged with your serie.
Thanks
--
Thomas
Hi Thomas,
I'm happy for you to apply the makefile changes you have suggested and not consider the bonding PMD as a plugin, I think this makes the most sense considering it is a purely software library.
Thanks
Declan
Re: [PATCH v11 1/5] bond: new link bonding library
In reply to a message not in the archiveHi Declan,
Quoted 21 lines · 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 - BroadcastSigned-off-by Declan Doherty <[email protected]>--- 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 +++++
Quoted 11 lines
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
I see a potential problem with bond_ethdev_rx_burst( ).
We could receive more packets than the caller asked for, and overrun the caller's rte_mbuf * array.
The fix could be something like this:
lib/librte_pmd_bond/rte_eth_bond_pmd.c +0 -0
@@ -73,13 +73,15 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf
**bufs, uint16_t nb_pkts)
case BONDING_MODE_ROUND_ROBIN:
case BONDING_MODE_BROADCAST:
case BONDING_MODE_BALANCE:
- for (i = 0; i < internals->active_slave_count; i++) {
+ for (i = 0; i < internals->active_slave_count && nb_pkts;
i++) {
/* Offset of pointer to *bufs increases as packetsare 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)
+ if (num_rx_slave) {
num_rx_total += num_rx_slave;
+ nb_pkts -= num_rx_slave;
+ }
}
break;
case BONDING_MODE_ACTIVE_BACKUP:--
Regards,
Robert
Re: [PATCH v11 1/5] bond: new link bonding library
In reply to a message not in the archiveHi Declan,
Do you confirm we should merge the Robert's patch in rc3?
2014-06-30 18:29, Robert Sanford:
Quoted 30 lines
I see a potential problem with
bond_ethdev_rx_burst( ).
We could receive more packets than the caller asked for, and overrun the caller'srte_mbuf* array.
The fix could be something like this:lib/librte_pmd_bond/rte_eth_bond_pmd.c +1
-1@@ -73,13 +73,15 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)case BONDING_MODE_ROUND_ROBIN :case BONDING_MODE_BROADCAST :case BONDING_MODE_BALANCE : -for (i =0 ; i < internals->active_slave_count; i++) { +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);lib/librte_pmd_bond/rte_eth_bond_pmd.c +3
-1-if (num_rx_slave) +if (num_rx_slave) { num_rx_total += num_rx_slave; + nb_pkts -= num_rx_slave; + } }break ;case BONDING_MODE_ACTIVE_BACKUP :
Re: [PATCH v11 1/5] bond: new link bonding library
In reply to a message not in the archiveFrom: Robert Sanford [mailto:[email protected]]
Sent: Monday, June 30, 2014 11:30 PM
To: Doherty, Declan
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v11 1/5] bond: new link bonding library
Hi Declan,
On Sun, Jun 29, 2014 at 1:49 PM, Declan Doherty <[email protected]<mailto:[email protected]>> wrote:
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
--- config/common_bsdapp | 5 + config/common_linuxapp | 5 + doc/doxy-api-index.md<http://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<http://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
I see a potential problem with bond_ethdev_rx_burst( ).
We could receive more packets than the caller asked for, and overrun the caller's rte_mbuf * array. The fix could be something like this:
lib/librte_pmd_bond/rte_eth_bond_pmd.c +4 -2
@@ -73,13 +73,15 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)case BONDING_MODE_ROUND_ROBIN :case BONDING_MODE_BROADCAST :case BONDING_MODE_BALANCE : -for (i =0 ; i < internals->active_slave_count; i++) { +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) +if (num_rx_slave) { num_rx_total += num_rx_slave; + nb_pkts -= num_rx_slave; + } }break ;case BONDING_MODE_ACTIVE_BACKUP :
--
Regards,
Robert
Hi Robert, yes I see this could be an issue, although this currently shouldn’t cause an issue, as the currently supported bonding modes only expected to receive data on one slave at any time, if they are being used as part of a ether channel but when we add further bonding modes are which receive data on multiple slaves this would definitely be a problem.
Thomas, I’ve tested the above changes, is it possible to integrate this patch with the patchset for link bonding for the rc3.
Thanks
Declan
Re: [PATCH v11 1/5] bond: new link bonding library
In reply to a message not in the archive2014-07-01 14:19, Doherty, Declan:
Quoted 8 lines
Hi Robert, yes I see this could be an issue, although this currently shouldn’t cause an issue, as the currently supported bonding modes only expected to receive data on one slave at any time, if they are being used as part of a ether channel but when we add further bonding modes are which receive data on multiple slaves this would definitely be a problem.
Thomas, I’ve tested the above changes, is it possible to integrate this patch with the patchset for link bonding for the rc3.
No problem.
It will be in.
Thanks Declan & Robert
Signature · 1 line
Thomas
Re: [PATCH v11 0/5] link bonding library
In reply to a message not in the archive2014-06-30 09:28, Doherty, Declan:
Quoted 21 lines
Quoted 21 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]Hi Declan,
2014-06-29 18:49, Declan Doherty:
Quoted 8 lines
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 implmentationYou fixed optional building but there is still an issue when building shared library.
As you don't want to split the library to separate the PMD plugin from the specific API, I suggest to not consider it as a plugin (unlike other PMDs).
Quoted 6 lines
Quoted 2 lines
I've sent some patches about these 2 topics. If you agree, I'll apply them, merged with your serie.
I'm happy for you to apply the makefile changes you have suggested and not consider the bonding PMD as a plugin, I think this makes the most sense considering it is a purely software library.
Applied with Robert's changes for version 1.7.0.
Thanks for all these revisions (v11 is currently the best score :)
Signature · 1 line
Thomas