Re: [dpdk-dev] [dpdk-stable] [PATCH v4] net/bonding: per-slave intermediate rx ring

2018-08-22 Thread Eric Kinzie
On Wed Aug 22 11:42:37 + 2018, Matan Azrad wrote:
> Hi Luca
> 
> From: Luca Boccassi
> > On Wed, 2018-08-22 at 07:09 +, Matan Azrad wrote:
> > > Hi Chas
> > >
> > > From: Chas Williams
> > > > On Tue, Aug 21, 2018 at 11:43 AM Matan Azrad  > > > .com> wrote:
> > > > Hi Chas
> > > >
> > > > From: Chas Williams
> > > > > On Tue, Aug 21, 2018 at 6:56 AM Matan Azrad  > > > > x.com>
> > > > > wrote:
> > > > > Hi
> > > > >
> > > > > From: Chas Williams
> > > > > > This will need to be implemented for some of the other RX burst
> > > > > > methods at some point for other modes to see this performance
> > > > > > improvement (with the exception of active-backup).
> > > > >
> > > > > Yes, I think it should be done at least to
> > > > > bond_ethdev_rx_burst_8023ad_fast_queue (should be easy) for now.
> > > > >
> > > > > There is some duplicated code between the various RX paths.
> > > > > I would like to eliminate that as much as possible, so I was going
> > > > > to give that some thought first.
> > > >
> > > > There is no reason to stay this function as is while its twin is
> > > > changed.
> > > >
> > > > Unfortunately, this is all the patch I have at this time.
> > > >
> > > >
> > > > >
> > > > >
> > > > > > On Thu, Aug 16, 2018 at 9:32 AM Luca Boccassi  > > > > > ian.org> wrote:
> > > > > >
> > > > > > > During bond 802.3ad receive, a burst of packets is fetched
> > > > > > > from each slave into a local array and appended to per-slave
> > > > > > > ring buffer.
> > > > > > > Packets are taken from the head of the ring buffer and
> > > > > > > returned to the caller.  The number of mbufs provided to each
> > > > > > > slave is sufficient to meet the requirements of the ixgbe
> > > > > > > vector receive.
> > > > >
> > > > > Luca,
> > > > >
> > > > > Can you explain these requirements of ixgbe?
> > > > >
> > > > > The ixgbe (and some other Intel PMDs) have vectorized RX routines
> > > > > that are more efficient (if not faster) taking advantage of some
> > > > > advanced CPU instructions.  I think you need to be receiving at
> > > > > least 32 packets or more.
> > > >
> > > > So, why to do it in bond which is a generic driver for all the
> > > > vendors PMDs, If for ixgbe and other Intel nics it is better you can
> > > > force those PMDs to receive always 32 packets and to manage a ring
> > > > by themselves.
> > > >
> > > > The drawback of the ring is some additional latency on the receive
> > > > path.
> > > > In testing, the additional latency hasn't been an issue for bonding.
> > >
> > > When bonding does processing slower it may be a bottleneck for the
> > > packet processing for some application.
> > >
> > > > The bonding PMD has a fair bit of overhead associated with the RX
> > > > and TX path calculations.  Most applications can just arrange to
> > > > call the RX path with a sufficiently large receive.  Bonding can't
> > > > do this.
> > >
> > > I didn't talk on application I talked on the slave PMDs, The slave PMD
> > > can manage a ring by itself if it helps for its own performance.
> > > The bonding should not be oriented to specific PMDs.
> > 
> > The issue though is that the performance problem is not with the individual
> > PMDs - it's with bonding. There were no reports regarding the individual
> > PMDs.
> > This comes from reports from customers from real world production
> > deployments - the issue of bonding being too slow was raised multiple times.
> > This patch addresses those issues, again in production deployments, where
> > it's been used for years, to users and customers satisfaction.
> 
> From Chas I understood that using burst of 32 helps for some slave PMDs 
> performance which makes sense.
> I can't understand how the extra copy phases improves the bonding itself 
> performance:
> 
> You added 2 copy phases in the bonding RX function:
> 1. Get packets from the slave to a local array.
> 2. Copy packet pointers from a local array to the ring array.
> 3. Copy packet pointers from the ring array to the application array.
> 
> Each packet arriving to the application must pass the above 3 phases(in a 
> specific call or in previous calls).
> 
> Without this patch we have only -
> Get packets from the slave to the application array.
> 
> Can you explain how the extra copies improves the bonding performance?
> 
> Looks like it improves the slaves PMDs and because of that the bonding PMD 
> performance becomes better.

I'm not sure that adding more buffer management to the vector PMDs will
improve the drivers' performance; it's just that calling the rx function
in such a way that it returns no data wastes time.  The bonding driver
is already an exercise in buffer management so adding this layer of
indirection here makes sense in my opinion, as does hiding the details
of the consituent interfaces where possible.


> > So I'd like to share this improvement rather than keeping it private - 
> > because
> > I'm nice that wa

Re: [dpdk-dev] [PATCH] net/bonding: allow configuring jumbo frames without slaves

2017-04-09 Thread Eric Kinzie
On Fri Apr 07 18:07:12 +0300 2017, Ilya Maximets wrote:
> Currently, 'rte_eth_dev_configure' fails on attempt to setup
> max_rx_pkt_len > 2048 if no slaves was added to bonded device.
> 
> For example:
> 
>   rte_eth_dev_attach("eth_bond0,slave=05:00.0,mode=l34", &id)
>   conf.rxmode.jumbo_frame = 1;
>   conf.rxmode.max_rx_pkt_len = 9000;
>   rte_eth_dev_configure(id, 1, 1, &conf)
> 
> Result:
>   EAL: Initializing pmd_bond for eth_bond0
>   EAL: Create bonded device eth_bond0 on port 4 in mode 2 on socket 0.
>   rte_eth_dev_configure: ethdev port_id=4 \
>   max_rx_pkt_len 9018 > max valid value 2048
> 
> It's expected that slaves will be added to bonded device inside
> 'rte_eth_dev_configure' and proper 'max_rx_pktlen' configured
> for all of them.
> 
> Failure happens because of hardcoded low value of 'max_rx_pktlen'.
> Increasing of this value to ETHER_MAX_JUMBO_FRAME_LEN will allow
> above scenario (attach + configure).
> 
> It is important because it is the way OVS wants to work with
> all DPDK devices (including virtual).
> Changing the default hardcoded value makes no harm because
> all the slaves' related code uses only 'candidate_max_rx_pktlen'
> variable.
> 
> CC: sta...@dpdk.org
> Fixes: 6cfc6a4f0d61 ("net/bonding: inherit maximum Rx packet length")
> Signed-off-by: Ilya Maximets 
> ---
>  drivers/net/bonding/rte_eth_bond_pmd.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
> b/drivers/net/bonding/rte_eth_bond_pmd.c
> index c398fdb..0c8cc40 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -1689,8 +1689,9 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct 
> rte_eth_dev_info *dev_info)
>  
>   dev_info->max_mac_addrs = 1;
>  
> - dev_info->max_rx_pktlen = internals->candidate_max_rx_pktlen ?
> -   internals->candidate_max_rx_pktlen : 2048;
> + dev_info->max_rx_pktlen = internals->candidate_max_rx_pktlen
> +       ? internals->candidate_max_rx_pktlen
> +   : ETHER_MAX_JUMBO_FRAME_LEN;
>  
>   dev_info->max_rx_queues = (uint16_t)128;
>   dev_info->max_tx_queues = (uint16_t)512;
> -- 
> 2.7.4
> 

Reviewed-by: Eric Kinzie 



[dpdk-dev] [PATCH] Revert "bonding: use existing enslaved device queues"

2016-10-13 Thread Eric Kinzie
On Wed Oct 12 16:24:21 +0100 2016, Bruce Richardson wrote:
> On Wed, Oct 12, 2016 at 04:24:54PM +0300, Ilya Maximets wrote:
> > On 07.10.2016 05:02, Eric Kinzie wrote:
> > > On Wed Sep 07 15:28:10 +0300 2016, Ilya Maximets wrote:
> > >> This reverts commit 5b7bb2bda5519b7800f814df64d4e015282140e5.
> > >>
> > >> It is necessary to reconfigure all queues every time because 
> > >> configuration
> > >> can be changed.
> > >>
> > >> For example, if we're reconfiguring bonding device with new memory pool,
> > >> already configured queues will still use the old one. And if the old
> > >> mempool be freed, application likely will panic in attempt to use
> > >> freed mempool.
> > >>
> > >> This happens when we use the bonding device with OVS 2.6 while MTU
> > >> reconfiguration:
> > >>
> > >> PANIC in rte_mempool_get_ops():
> > >> assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)" failed
> > >>
> > >> Cc: 
> > >> Signed-off-by: Ilya Maximets 
> > >> ---
> > >>  drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++
> > >>  1 file changed, 2 insertions(+), 8 deletions(-)
> > >>
> > >> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
> > >> b/drivers/net/bonding/rte_eth_bond_pmd.c
> > >> index b20a272..eb5b6d1 100644
> > >> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> > >> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> > >> @@ -1305,8 +1305,6 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
> > >>  struct bond_rx_queue *bd_rx_q;
> > >>  struct bond_tx_queue *bd_tx_q;
> > >>  
> > >> -uint16_t old_nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
> > >> -uint16_t old_nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
> > >>  int errval;
> > >>  uint16_t q_id;
> > >>  
> > >> @@ -1347,9 +1345,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
> > >>  }
> > >>  
> > >>  /* Setup Rx Queues */
> > >> -/* Use existing queues, if any */
> > >> -for (q_id = old_nb_rx_queues;
> > >> - q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
> > >> +for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; 
> > >> q_id++) {
> > >>  bd_rx_q = (struct bond_rx_queue 
> > >> *)bonded_eth_dev->data->rx_queues[q_id];
> > >>  
> > >>  errval = 
> > >> rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
> > >> @@ -1365,9 +1361,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
> > >>  }
> > >>  
> > >>  /* Setup Tx Queues */
> > >> -/* Use existing queues, if any */
> > >> -for (q_id = old_nb_tx_queues;
> > >> - q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
> > >> +for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; 
> > >> q_id++) {
> > >>  bd_tx_q = (struct bond_tx_queue 
> > >> *)bonded_eth_dev->data->tx_queues[q_id];
> > >>  
> > >>  errval = 
> > >> rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
> > >> -- 
> > >> 2.7.4
> > >>
> > > 
> > > NAK
> > > 
> > > There are still some users of this code.  Let's give them a chance to
> > > comment before removing it.
> > 
> > Hi Eric,
> > 
> > Are these users in CC-list? If not, could you, please, add them?
> > This patch awaits in mail-list already more than a month. I think, it's 
> > enough
> > time period for all who wants to say something. Patch fixes a real bug that
> > prevent using of DPDK bonding in all applications that reconfigures devices
> > in runtime including OVS.
> > 
> Agreed.
> 
> Eric, does reverting this patch cause you problems directly, or is your 
> concern
> just with regards to potential impact to others?
> 
> Thanks,
> /Bruce

This won't impact me directly.  The users are CCed (different thread)
and I haven't seen any comment, so I no longer have any objection to
reverting this change.

Eric



[dpdk-dev] [PATCH] Revert "bonding: use existing enslaved device queues"

2016-10-06 Thread Eric Kinzie
On Wed Sep 07 15:28:10 +0300 2016, Ilya Maximets wrote:
> This reverts commit 5b7bb2bda5519b7800f814df64d4e015282140e5.
> 
> It is necessary to reconfigure all queues every time because configuration
> can be changed.
> 
> For example, if we're reconfiguring bonding device with new memory pool,
> already configured queues will still use the old one. And if the old
> mempool be freed, application likely will panic in attempt to use
> freed mempool.
> 
> This happens when we use the bonding device with OVS 2.6 while MTU
> reconfiguration:
> 
> PANIC in rte_mempool_get_ops():
> assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)" failed
> 
> Cc: 
> Signed-off-by: Ilya Maximets 
> ---
>  drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
> b/drivers/net/bonding/rte_eth_bond_pmd.c
> index b20a272..eb5b6d1 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -1305,8 +1305,6 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
>   struct bond_rx_queue *bd_rx_q;
>   struct bond_tx_queue *bd_tx_q;
>  
> - uint16_t old_nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
> - uint16_t old_nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
>   int errval;
>   uint16_t q_id;
>  
> @@ -1347,9 +1345,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
>   }
>  
>   /* Setup Rx Queues */
> - /* Use existing queues, if any */
> - for (q_id = old_nb_rx_queues;
> -  q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
> + for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
>   bd_rx_q = (struct bond_rx_queue 
> *)bonded_eth_dev->data->rx_queues[q_id];
>  
>   errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, 
> q_id,
> @@ -1365,9 +1361,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
>   }
>  
>   /* Setup Tx Queues */
> - /* Use existing queues, if any */
> - for (q_id = old_nb_tx_queues;
> -  q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
> + for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
>   bd_tx_q = (struct bond_tx_queue 
> *)bonded_eth_dev->data->tx_queues[q_id];
>  
>   errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, 
> q_id,
> -- 
> 2.7.4
> 

NAK

There are still some users of this code.  Let's give them a chance to
comment before removing it.


Thanks,

Eric


[dpdk-dev] [PATCH 2/2] net/bonding: enable slave VLAN filter

2016-08-04 Thread Eric Kinzie
SR-IOV virtual functions cannot rely on promiscuous mode for the reception
of VLAN tagged frames.  Program the vlan filter for each slave when a
vlan is configured for the bonding master.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_api.c |   68 
 drivers/net/bonding/rte_eth_bond_pmd.c |   36 +++
 drivers/net/bonding/rte_eth_bond_private.h |4 ++
 3 files changed, 108 insertions(+)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 3c16973..a556f7b 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -166,6 +166,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
 {
struct bond_dev_private *internals = NULL;
struct rte_eth_dev *eth_dev = NULL;
+   uint32_t vlan_filter_bmp_size;

/* now do all data allocation - for eth_dev structure, dummy pci driver
 * and internal (private) data
@@ -260,6 +261,27 @@ rte_eth_bond_create(const char *name, uint8_t mode, 
uint8_t socket_id)
goto err;
}

+   vlan_filter_bmp_size =
+   rte_bitmap_get_memory_footprint(ETHER_MAX_VLAN_ID+1);
+   internals->vlan_filter_bmpmem = rte_malloc(name, vlan_filter_bmp_size,
+  RTE_CACHE_LINE_SIZE);
+   if (internals->vlan_filter_bmpmem == NULL) {
+   RTE_BOND_LOG(ERR,
+"Failed to allocate vlan bitmap for bonded device 
%u\n",
+eth_dev->data->port_id);
+   goto err;
+   }
+
+   internals->vlan_filter_bmp = rte_bitmap_init(ETHER_MAX_VLAN_ID+1,
+   internals->vlan_filter_bmpmem, vlan_filter_bmp_size);
+   if (internals->vlan_filter_bmp == NULL) {
+   RTE_BOND_LOG(ERR,
+"Failed to init vlan bitmap for bonded device 
%u\n",
+eth_dev->data->port_id);
+   rte_free(internals->vlan_filter_bmpmem);
+   goto err;
+   }
+
return eth_dev->data->port_id;

 err:
@@ -299,6 +321,9 @@ rte_eth_bond_free(const char *name)
eth_dev->rx_pkt_burst = NULL;
eth_dev->tx_pkt_burst = NULL;

+   internals = eth_dev->data->dev_private;
+   rte_bitmap_free(internals->vlan_filter_bmp);
+   rte_free(internals->vlan_filter_bmpmem);
rte_free(eth_dev->data->dev_private);
rte_free(eth_dev->data->mac_addrs);

@@ -308,6 +333,46 @@ rte_eth_bond_free(const char *name)
 }

 static int
+slave_vlan_filter_set(uint8_t bonded_port_id, uint8_t slave_port_id)
+{
+   struct rte_eth_dev *bonded_eth_dev;
+   struct bond_dev_private *internals;
+   int found;
+   int res = 0;
+   uint64_t slab = 0;
+   uint32_t pos = 0;
+   uint16_t first;
+
+   bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+   if (bonded_eth_dev->data->dev_conf.rxmode.hw_vlan_filter == 0)
+   return 0;
+
+   internals = bonded_eth_dev->data->dev_private;
+   found = rte_bitmap_scan(internals->vlan_filter_bmp, &pos, &slab);
+   first = pos;
+
+   if (!found)
+   return 0;
+
+   do {
+   uint32_t i;
+   uint64_t mask;
+
+   for (i = 0, mask = 1;
+i < RTE_BITMAP_SLAB_BIT_SIZE;
+i ++, mask <<= 1) {
+   if (unlikely(slab & mask))
+   res = rte_eth_dev_vlan_filter(slave_port_id,
+ (uint16_t)pos, 1);
+   }
+   found = rte_bitmap_scan(internals->vlan_filter_bmp,
+   &pos, &slab);
+   } while (found && first != pos && res == 0);
+
+   return res;
+}
+
+static int
 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
struct rte_eth_dev *bonded_eth_dev, *slave_eth_dev;
@@ -427,6 +492,9 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
activate_slave(bonded_eth_dev, slave_port_id);
}
}
+
+   slave_vlan_filter_set(bonded_port_id, slave_port_id);
+
return 0;

 }
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 25fe00a..0b6caf6 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1335,6 +1335,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
bonded_eth_dev->data->dev_conf.rxmode.mq_mode;
}

+   slave_eth_dev->data->dev_conf.rxmode.hw_vlan_filter =
+

[dpdk-dev] [PATCH 1/2] net/bonding: validate speed after link up

2016-08-04 Thread Eric Kinzie
It's possible for the bonding driver to mistakenly reject an interface
based in it's, as yet, unnegotiated link speed and duplex.  Always allow
the interface to be added to the bonding interface but require link
properties validation to succeed before slave is activated.

Fixes: 2efb58cbab6e ("bond: new link bonding library")

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_api.c |   15 ---
 drivers/net/bonding/rte_eth_bond_pmd.c |   10 ++
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 203ebe9..3c16973 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -373,21 +373,6 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
internals->candidate_max_rx_pktlen = dev_info.max_rx_pktlen;

} else {
-   /* Check slave link properties are supported if props are set,
-* all slaves must be the same */
-   if (internals->link_props_set) {
-   if 
(link_properties_valid(&(bonded_eth_dev->data->dev_link),
- 
&(slave_eth_dev->data->dev_link))) {
-   slave_eth_dev->data->dev_flags &= 
(~RTE_ETH_DEV_BONDED_SLAVE);
-   RTE_BOND_LOG(ERR,
-   "Slave port %d link 
speed/duplex not supported",
-   slave_port_id);
-   return -1;
-   }
-   } else {
-   link_properties_set(bonded_eth_dev,
-   &(slave_eth_dev->data->dev_link));
-   }
internals->rx_offload_capa &= dev_info.rx_offload_capa;
internals->tx_offload_capa &= dev_info.tx_offload_capa;
internals->flow_type_rss_offloads &= 
dev_info.flow_type_rss_offloads;
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index b20a272..25fe00a 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1985,6 +1985,16 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum 
rte_eth_event_type type,
/* Inherit eth dev link properties from first active 
slave */
link_properties_set(bonded_eth_dev,
&(slave_eth_dev->data->dev_link));
+   } else {
+   if (link_properties_valid(
+   &bonded_eth_dev->data->dev_link, &link) != 0) {
+   slave_eth_dev->data->dev_flags &=
+   (~RTE_ETH_DEV_BONDED_SLAVE);
+   RTE_LOG(ERR, PMD,
+   "port %u invalid speed/duplex\n",
+   port_id);
+   return;
+   }
}

activate_slave(bonded_eth_dev, port_id);
-- 
1.7.10.4



[dpdk-dev] [PATCH 0/2] bonding link validation and vlan filters

2016-08-04 Thread Eric Kinzie
This series contains a fix to the validation of interfaces added to a
bond group and an enhancement to allow reception of tagged frames on
slave interfaces that are virtual functions.

Eric Kinzie (2):
  net/bonding: validate speed after link up
  net/bonding: enable slave VLAN filter

 drivers/net/bonding/rte_eth_bond_api.c |   83 +++-
 drivers/net/bonding/rte_eth_bond_pmd.c |   46 +++
 drivers/net/bonding/rte_eth_bond_private.h |4 ++
 3 files changed, 118 insertions(+), 15 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH v2 2/2] bond mode 4: tests for external state machine

2016-05-27 Thread Eric Kinzie
  This adds test cases for exercising the external state machine API to
  the mode 4 autotest.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |  215 ++--
 1 file changed, 206 insertions(+), 9 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 31640cd..aa729ad 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -151,6 +151,8 @@ static struct rte_eth_conf default_pmd_conf = {
.lpbk_mode = 0,
 };

+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); 
_i++)

@@ -320,8 +322,26 @@ remove_slave(struct slave_conf *slave)
return 0;
 }

+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+   struct ether_hdr *hdr;
+   struct slow_protocol_frame *slow_hdr;
+
+   RTE_VERIFY(lacp_pkt != NULL);
+
+   hdr = rte_pktmbuf_mtod(lacp_pkt, struct ether_hdr *);
+   RTE_VERIFY(hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_SLOW));
+
+   slow_hdr = rte_pktmbuf_mtod(lacp_pkt, struct slow_protocol_frame *);
+   RTE_VERIFY(slow_hdr->slow_protocol.subtype == SLOW_SUBTYPE_LACP);
+
+   lacpdu_rx_count[slave_id]++;
+   rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
uint8_t i;

@@ -337,9 +357,17 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, 
uint8_t start)
rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
rte_eth_promiscuous_disable(test_params.bonded_port_id);

-   if (start)
-   
TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-   "Failed to start bonded device");
+   if (external_sm) {
+   struct rte_eth_bond_8023ad_conf conf;
+
+   rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+   conf.slowrx_cb = lacp_recv_cb;
+   rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+   }
+
+   TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+   "Failed to start bonded device");

return TEST_SUCCESS;
 }
@@ -640,7 +668,7 @@ test_mode4_lacp(void)
 {
int retval;

-   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -738,7 +766,8 @@ test_mode4_rx(void)
struct ether_addr dst_mac;
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT,
+ 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -915,7 +944,7 @@ test_mode4_tx_burst(void)
struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -1099,7 +1128,8 @@ test_mode4_marker(void)
uint8_t i, j;
const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);

-   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT,
+ 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -1184,7 +1214,8 @@ test_mode4_expired(void)

struct rte_eth_bond_8023ad_conf conf;

-   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT,
+ 0);
/* Set custom timeouts to make test last shorter. */
rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
conf.fast_periodic_ms = 100;
@@ -1266,6 +1297,156 @@ test_mode4_expired(void)
 }

 static int
+test_mode4_ext_ctrl(void)
+{
+   /*
+* configure bonded interface without the external sm enabled
+*   . try to transmit lacpdu (should fail)
+*   . try to set collecting 

[dpdk-dev] [PATCH v2 1/2] bond mode 4: allow external state machine

2016-05-27 Thread Eric Kinzie
Provide functions to allow an external 802.3ad state machine to transmit
and recieve LACPDUs and to set the collection/distribution flags on
slave interfaces.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c |  323 +++--
 drivers/net/bonding/rte_eth_bond_8023ad.h |   83 ++
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   14 +-
 drivers/net/bonding/rte_eth_bond_version.map  |   16 +
 4 files changed, 404 insertions(+), 32 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index c0ed44d..48a50e4 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -39,9 +39,12 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -1005,7 +1008,7 @@ bond_mode_8023ad_mac_address_update(struct rte_eth_dev 
*bond_dev)
bond_mode_8023ad_start(bond_dev);
 }

-void
+static void
 bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
@@ -1023,26 +1026,36 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

-void
-bond_mode_8023ad_setup(struct rte_eth_dev *dev,
+static void
+bond_mode_8023ad_conf_get_v1607(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
-   struct rte_eth_bond_8023ad_conf def_conf;
struct bond_dev_private *internals = dev->data->dev_private;
struct mode8023ad_private *mode4 = &internals->mode4;
-   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;

-   if (conf == NULL) {
-   conf = &def_conf;
-   conf->fast_periodic_ms = BOND_8023AD_FAST_PERIODIC_MS;
-   conf->slow_periodic_ms = BOND_8023AD_SLOW_PERIODIC_MS;
-   conf->short_timeout_ms = BOND_8023AD_SHORT_TIMEOUT_MS;
-   conf->long_timeout_ms = BOND_8023AD_LONG_TIMEOUT_MS;
-   conf->aggregate_wait_timeout_ms = 
BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS;
-   conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
-   conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
-   conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
-   }
+   bond_mode_8023ad_conf_get(dev, conf);
+   conf->slowrx_cb = mode4->slowrx_cb;
+}
+
+static void
+bond_mode_8023ad_conf_get_default(struct rte_eth_bond_8023ad_conf *conf)
+{
+   conf->fast_periodic_ms = BOND_8023AD_FAST_PERIODIC_MS;
+   conf->slow_periodic_ms = BOND_8023AD_SLOW_PERIODIC_MS;
+   conf->short_timeout_ms = BOND_8023AD_SHORT_TIMEOUT_MS;
+   conf->long_timeout_ms = BOND_8023AD_LONG_TIMEOUT_MS;
+   conf->aggregate_wait_timeout_ms = BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS;
+   conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
+   conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
+   conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
+   conf->slowrx_cb = NULL;
+}
+
+static void
+bond_mode_8023ad_conf_assign(struct mode8023ad_private *mode4,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;

mode4->fast_periodic_timeout = conf->fast_periodic_ms * ms_ticks;
mode4->slow_periodic_timeout = conf->slow_periodic_ms * ms_ticks;
@@ -1054,6 +1067,48 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
 }

+static void
+bond_mode_8023ad_setup_v1604(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct rte_eth_bond_8023ad_conf def_conf;
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (conf == NULL) {
+   conf = &def_conf;
+   bond_mode_8023ad_conf_get_default(conf);
+   }
+
+   bond_mode_8023ad_stop(dev);
+   bond_mode_8023ad_conf_assign(mode4, conf);
+
+   if (dev->data->dev_started)
+   bond_mode_8023ad_start(dev);
+}
+
+
+void
+bond_mode_8023ad_setup(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct rte_eth_bond_8023ad_conf def_conf;
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (conf == NULL) {
+   conf = &def_conf;
+   bond_mode_802

[dpdk-dev] [PATCH v2 0/2] bond mode 4 external sm api

2016-05-27 Thread Eric Kinzie
This patchset introduces the ability to use an external 802.3ad state
machine for mode 4 bonding.  Functions to alter the mux state and to
allow LACPDUs to be sent and received from outside of the bonding PMD
are provided.

v2 changes:
  . fix checkpatch errors

Eric Kinzie (2):
  bond mode 4: allow external state machine
  bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c|  215 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  323 +++--
 drivers/net/bonding/rte_eth_bond_8023ad.h |   83 ++
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   14 +-
 drivers/net/bonding/rte_eth_bond_version.map  |   16 +
 5 files changed, 610 insertions(+), 41 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH 2/2] bond mode 4: tests for external state machine

2016-05-26 Thread Eric Kinzie
From: Eric Kinzie 

  This adds test cases for exercising the external state machine API to
  the mode 4 autotest.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |  210 ++--
 1 file changed, 201 insertions(+), 9 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 31640cd..91622b7 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -151,6 +151,8 @@ static struct rte_eth_conf default_pmd_conf = {
.lpbk_mode = 0,
 };

+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); 
_i++)

@@ -320,8 +322,26 @@ remove_slave(struct slave_conf *slave)
return 0;
 }

+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+   struct ether_hdr *hdr;
+   struct slow_protocol_frame *slow_hdr;
+
+   RTE_VERIFY(lacp_pkt != NULL);
+
+   hdr = rte_pktmbuf_mtod(lacp_pkt, struct ether_hdr *);
+   RTE_VERIFY(hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_SLOW));
+
+   slow_hdr = rte_pktmbuf_mtod(lacp_pkt, struct slow_protocol_frame *);
+   RTE_VERIFY(slow_hdr->slow_protocol.subtype == SLOW_SUBTYPE_LACP);
+
+   lacpdu_rx_count[slave_id]++;
+   rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
uint8_t i;

@@ -337,9 +357,17 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, 
uint8_t start)
rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
rte_eth_promiscuous_disable(test_params.bonded_port_id);

-   if (start)
-   
TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-   "Failed to start bonded device");
+   if (external_sm) {
+   struct rte_eth_bond_8023ad_conf conf;
+
+   rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+   conf.slowrx_cb = lacp_recv_cb;
+   rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+   }
+
+   TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+   "Failed to start bonded device");

return TEST_SUCCESS;
 }
@@ -640,7 +668,7 @@ test_mode4_lacp(void)
 {
int retval;

-   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -738,7 +766,7 @@ test_mode4_rx(void)
struct ether_addr dst_mac;
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -915,7 +943,7 @@ test_mode4_tx_burst(void)
struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -1099,7 +1127,7 @@ test_mode4_marker(void)
uint8_t i, j;
const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);

-   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -1184,7 +1212,7 @@ test_mode4_expired(void)

struct rte_eth_bond_8023ad_conf conf;

-   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
0);
/* Set custom timeouts to make test last shorter. */
rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
conf.fast_periodic_ms = 100;
@@ -1266,6 +1294,156 @@ test_mode4_expired(void)
 }

 static int
+test_mode4_ext_ctrl(void)
+{
+   /*
+* configure bonded interface without the external sm enabled
+*   . try to transmit lacpdu (should fail)
+*   . try to set collecting and distributing flags (should fail)
+* reconfigure w/external sm
+*   . transmit one lacpdu on each slave using new api
+

[dpdk-dev] [PATCH 1/2] bond mode 4: allow external state machine

2016-05-26 Thread Eric Kinzie
From: Eric Kinzie 

Provide functions to allow an external 802.3ad state machine to transmit
and recieve LACPDUs and to set the collection/distribution flags on
slave interfaces.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c |  318 +++--
 drivers/net/bonding/rte_eth_bond_8023ad.h |   82 ++
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   14 +-
 drivers/net/bonding/rte_eth_bond_version.map  |   16 ++
 4 files changed, 400 insertions(+), 30 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index c0ed44d..32e0746 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -39,9 +39,12 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -1005,7 +1008,7 @@ bond_mode_8023ad_mac_address_update(struct rte_eth_dev 
*bond_dev)
bond_mode_8023ad_start(bond_dev);
 }

-void
+static void
 bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
@@ -1023,26 +1026,36 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

-void
-bond_mode_8023ad_setup(struct rte_eth_dev *dev,
+static void
+bond_mode_8023ad_conf_get_v1607(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
-   struct rte_eth_bond_8023ad_conf def_conf;
struct bond_dev_private *internals = dev->data->dev_private;
struct mode8023ad_private *mode4 = &internals->mode4;
-   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;

-   if (conf == NULL) {
-   conf = &def_conf;
-   conf->fast_periodic_ms = BOND_8023AD_FAST_PERIODIC_MS;
-   conf->slow_periodic_ms = BOND_8023AD_SLOW_PERIODIC_MS;
-   conf->short_timeout_ms = BOND_8023AD_SHORT_TIMEOUT_MS;
-   conf->long_timeout_ms = BOND_8023AD_LONG_TIMEOUT_MS;
-   conf->aggregate_wait_timeout_ms = 
BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS;
-   conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
-   conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
-   conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
-   }
+   bond_mode_8023ad_conf_get(dev, conf);
+   conf->slowrx_cb = mode4->slowrx_cb;
+}
+
+static void
+bond_mode_8023ad_conf_get_default(struct rte_eth_bond_8023ad_conf *conf)
+{
+   conf->fast_periodic_ms = BOND_8023AD_FAST_PERIODIC_MS;
+   conf->slow_periodic_ms = BOND_8023AD_SLOW_PERIODIC_MS;
+   conf->short_timeout_ms = BOND_8023AD_SHORT_TIMEOUT_MS;
+   conf->long_timeout_ms = BOND_8023AD_LONG_TIMEOUT_MS;
+   conf->aggregate_wait_timeout_ms = BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS;
+   conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
+   conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
+   conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
+   conf->slowrx_cb = NULL;
+}
+
+static void
+bond_mode_8023ad_conf_assign(struct mode8023ad_private *mode4,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;

mode4->fast_periodic_timeout = conf->fast_periodic_ms * ms_ticks;
mode4->slow_periodic_timeout = conf->slow_periodic_ms * ms_ticks;
@@ -1054,6 +1067,48 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
 }

+static void
+bond_mode_8023ad_setup_v1604(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct rte_eth_bond_8023ad_conf def_conf;
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (conf == NULL) {
+   conf = &def_conf;
+   bond_mode_8023ad_conf_get_default(conf);
+   }
+
+   bond_mode_8023ad_stop(dev);
+   bond_mode_8023ad_conf_assign(mode4, conf);
+
+   if (dev->data->dev_started)
+   bond_mode_8023ad_start(dev);
+}
+
+
+void
+bond_mode_8023ad_setup(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct rte_eth_bond_8023ad_conf def_conf;
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (conf == NULL) {
+   conf = &def_conf;
+  

[dpdk-dev] [PATCH 0/2] bond mode 4 external sm api

2016-05-26 Thread Eric Kinzie
This patchset introduces the ability to use an external 802.3ad state
machine for mode 4 bonding.  Functions to alter the mux state and to
allow LACPDUs to be sent and received from outside of the bonding PMD
are provided.

Eric Kinzie (2):
  bond mode 4: allow external state machine
  bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c|  210 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  318 +++--
 drivers/net/bonding/rte_eth_bond_8023ad.h |   82 ++
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   14 +-
 drivers/net/bonding/rte_eth_bond_version.map  |   16 ++
 5 files changed, 601 insertions(+), 39 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH v3] bond: inherit maximum rx packet length

2016-05-06 Thread Eric Kinzie
  Instead of a hard-coded maximum receive length, allow the bond interface
  to inherit this limit from the slave interfaces.  This allows
  an application that uses jumbo frames to pass realistic values to
  rte_eth_dev_configure without causing an error.

  Before the bond interface is configured, allow slaves with any
  max_rx_pktlen to be added and remember the lowest of these values as
  a candidate value.  During dev_configure, set the bond device's
  max_rx_pktlen to the candidate value.  After this point only slaves
  with a max_rx_pktlen greater or equal to that of the bonding device
  can be added.

  If all slaves are removed, the bond device's pktlen is cleared.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_api.c | 18 +-
 drivers/net/bonding/rte_eth_bond_pmd.c |  6 +-
 drivers/net/bonding/rte_eth_bond_private.h |  3 +++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index e9247b5..aa0be5d 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -247,6 +247,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
internals->active_slave_count = 0;
internals->rx_offload_capa = 0;
internals->tx_offload_capa = 0;
+   internals->candidate_max_rx_pktlen = 0;
+   internals->max_rx_pktlen = 0;

/* Initially allow to choose any offload type */
internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
@@ -331,9 +333,15 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)

/* Add slave details to bonded device */
slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE;
-   slave_add(internals, slave_eth_dev);

rte_eth_dev_info_get(slave_port_id, &dev_info);
+   if (dev_info.max_rx_pktlen < internals->max_rx_pktlen) {
+   RTE_BOND_LOG(ERR, "Slave (port %u) max_rx_pktlen too small",
+slave_port_id);
+   return -1;
+   }
+
+   slave_add(internals, slave_eth_dev);

/* We need to store slaves reta_size to be able to synchronize RETA for 
all
 * slave devices even if its sizes are different.
@@ -365,6 +373,9 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
internals->tx_offload_capa = dev_info.tx_offload_capa;
internals->flow_type_rss_offloads = 
dev_info.flow_type_rss_offloads;

+   /* Inherit first slave's max rx packet size */
+   internals->candidate_max_rx_pktlen = dev_info.max_rx_pktlen;
+
} else {
/* Check slave link properties are supported if props are set,
 * all slaves must be the same */
@@ -391,6 +402,9 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
if (internals->reta_size > dev_info.reta_size)
internals->reta_size = dev_info.reta_size;

+   if (!internals->max_rx_pktlen
+   && dev_info.max_rx_pktlen < 
internals->candidate_max_rx_pktlen)
+   internals->candidate_max_rx_pktlen = 
dev_info.max_rx_pktlen;
}

bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &=
@@ -536,6 +550,8 @@ __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
internals->tx_offload_capa = 0;
internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
internals->reta_size = 0;
+   internals->candidate_max_rx_pktlen = 0;
+   internals->max_rx_pktlen = 0;
}
return 0;
 }
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 54788cf..0d39191 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1650,7 +1650,8 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)

dev_info->max_mac_addrs = 1;

-   dev_info->max_rx_pktlen = (uint32_t)2048;
+   dev_info->max_rx_pktlen = internals->candidate_max_rx_pktlen ?
+ internals->candidate_max_rx_pktlen : 2048;

dev_info->max_rx_queues = (uint16_t)128;
dev_info->max_tx_queues = (uint16_t)512;
@@ -2294,6 +2295,9 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
}
}

+   /* set the max_rx_pktlen */
+   internals->max_rx_pktlen = internals->candidate_max_rx_pktlen;
+
/*
 * if no kvlist, it means that this bonded device has been created
 * through the bonding api.
diff --git a/drivers/net/bonding/rte_eth_bond_private.h 
b/drivers/net/bonding/r

[dpdk-dev] [PATCH v3] bond: inherit maximum rx packet length

2016-05-06 Thread Eric Kinzie
v2 changes:
 - remove type cast on constant
 - check max_rx_pktlen when adding a slave to make sure it is >= max
   packet length of existing slave interfaces

v3 changes:
 - allow slaves with any max rx packet length to be added to the bonding
   interface until it is configured.  After bond_ethdev_configure()
   only slaves with max pktlen greater than that of the bond device
   can be added.  The bond device assumes the smallest of the slave max
   pktlen values.
 - reset bond device's max_rx_pktlen when last slave removed

Eric Kinzie (1):
  bond: inherit maximum rx packet length

 drivers/net/bonding/rte_eth_bond_api.c | 18 +-
 drivers/net/bonding/rte_eth_bond_pmd.c |  6 +-
 drivers/net/bonding/rte_eth_bond_private.h |  3 +++
 3 files changed, 25 insertions(+), 2 deletions(-)

-- 
2.1.4



[dpdk-dev] [PATCH] bond: inherit maximum rx packet length

2016-04-29 Thread Eric Kinzie
On Tue Apr 26 11:51:53 +0100 2016, Declan Doherty wrote:
> On 14/04/16 18:23, Eric Kinzie wrote:
> >   Instead of a hard-coded maximum receive length, allow the bond interface
> >   to inherit this limit from the first slave added.  This allows
> >   an application that uses jumbo frames to pass realistic values to
> >   rte_eth_dev_configure without causing an error.
> >
> >Signed-off-by: Eric Kinzie 
> >---
> ...
> >
> 
> Hey Eric, just one small thing, I think it probably makes sense to
> return the max rx pktlen for all slaves, so as we add each slave
> just check if that the slave being value is larger than the current
> value.
> 
> @@ -385,6 +389,10 @@ __eth_bond_slave_add_lock_free(uint8_t
> bonded_port_id, uint8_t slave_port_id)
> internals->tx_offload_capa &= dev_info.tx_offload_capa;
> internals->flow_type_rss_offloads &=
> dev_info.flow_type_rss_offloads;
> 
> +   /* If new slave's max rx packet size is larger than
> current value then override */
> +   if (dev_info.max_rx_pktlen > internals->max_rx_pktlen)
> +   internals->max_rx_pktlen = dev_info.max_rx_pktlen;
> +
> 
> Declan

Declan, I sent an updated patch but now release that I mis-read your
comments.  Is it a good idea to change the value once it's been set?
My patch now refuses to add a slave with a pktlen value that's smaller
than that of the first slave.

Eric



[dpdk-dev] [PATCH v2] bond: inherit maximum rx packet length

2016-04-29 Thread Eric Kinzie
  Instead of a hard-coded maximum receive length, allow the bond interface
  to inherit this limit from the first slave added.  This allows
  an application that uses jumbo frames to pass realistic values to
  rte_eth_dev_configure without causing an error.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_api.c | 12 +++-
 drivers/net/bonding/rte_eth_bond_pmd.c |  2 +-
 drivers/net/bonding/rte_eth_bond_private.h |  2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index e9247b5..acc1c32 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -247,6 +247,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
internals->active_slave_count = 0;
internals->rx_offload_capa = 0;
internals->tx_offload_capa = 0;
+   internals->max_rx_pktlen = 2048;

/* Initially allow to choose any offload type */
internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
@@ -331,9 +332,15 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)

/* Add slave details to bonded device */
slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE;
-   slave_add(internals, slave_eth_dev);

rte_eth_dev_info_get(slave_port_id, &dev_info);
+   if (dev_info.max_rx_pktlen < internals->max_rx_pktlen) {
+   RTE_BOND_LOG(ERR, "Slave (port %u) max_rx_pktlen too small",
+slave_port_id);
+   return -1;
+   }
+
+   slave_add(internals, slave_eth_dev);

/* We need to store slaves reta_size to be able to synchronize RETA for 
all
 * slave devices even if its sizes are different.
@@ -365,6 +372,9 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
internals->tx_offload_capa = dev_info.tx_offload_capa;
internals->flow_type_rss_offloads = 
dev_info.flow_type_rss_offloads;

+   /* Inherit first slave's max rx packet size */
+   internals->max_rx_pktlen = dev_info.max_rx_pktlen;
+
} else {
/* Check slave link properties are supported if props are set,
 * all slaves must be the same */
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 54788cf..189fb47 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1650,7 +1650,7 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)

dev_info->max_mac_addrs = 1;

-   dev_info->max_rx_pktlen = (uint32_t)2048;
+   dev_info->max_rx_pktlen = internals->max_rx_pktlen;

dev_info->max_rx_queues = (uint16_t)128;
dev_info->max_tx_queues = (uint16_t)512;
diff --git a/drivers/net/bonding/rte_eth_bond_private.h 
b/drivers/net/bonding/rte_eth_bond_private.h
index 8312397..79ca69d 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -169,6 +169,8 @@ struct bond_dev_private {

struct rte_kvargs *kvlist;
uint8_t slave_update_idx;
+
+   uint32_t max_rx_pktlen;
 };

 extern const struct eth_dev_ops default_dev_ops;
-- 
2.1.4



[dpdk-dev] [PATCH v2] bond: inherit maximum rx packet length

2016-04-29 Thread Eric Kinzie
v2 changes:
 - remove type cast on constant
 - check max_rx_pktlen when adding a slave to make sure it is >= max
   packet length of existing slave interfaces

Eric Kinzie (1):
  bond: inherit maximum rx packet length

 drivers/net/bonding/rte_eth_bond_api.c | 12 +++-
 drivers/net/bonding/rte_eth_bond_pmd.c |  2 +-
 drivers/net/bonding/rte_eth_bond_private.h |  2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)

-- 
2.1.4



[dpdk-dev] [PATCH] bond: inherit maximum rx packet length

2016-04-14 Thread Eric Kinzie
  Instead of a hard-coded maximum receive length, allow the bond interface
  to inherit this limit from the first slave added.  This allows
  an application that uses jumbo frames to pass realistic values to
  rte_eth_dev_configure without causing an error.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_api.c |4 
 drivers/net/bonding/rte_eth_bond_pmd.c |2 +-
 drivers/net/bonding/rte_eth_bond_private.h |2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index e9247b5..b763b37 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -247,6 +247,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
internals->active_slave_count = 0;
internals->rx_offload_capa = 0;
internals->tx_offload_capa = 0;
+   internals->max_rx_pktlen = (uint32_t)2048;

/* Initially allow to choose any offload type */
internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK;
@@ -365,6 +366,9 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
internals->tx_offload_capa = dev_info.tx_offload_capa;
internals->flow_type_rss_offloads = 
dev_info.flow_type_rss_offloads;

+   /* Inherit first slave's max rx packet size */
+   internals->max_rx_pktlen = dev_info.max_rx_pktlen;
+
} else {
/* Check slave link properties are supported if props are set,
 * all slaves must be the same */
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 54788cf..189fb47 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1650,7 +1650,7 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)

dev_info->max_mac_addrs = 1;

-   dev_info->max_rx_pktlen = (uint32_t)2048;
+   dev_info->max_rx_pktlen = internals->max_rx_pktlen;

dev_info->max_rx_queues = (uint16_t)128;
dev_info->max_tx_queues = (uint16_t)512;
diff --git a/drivers/net/bonding/rte_eth_bond_private.h 
b/drivers/net/bonding/rte_eth_bond_private.h
index 8312397..79ca69d 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -169,6 +169,8 @@ struct bond_dev_private {

struct rte_kvargs *kvlist;
uint8_t slave_update_idx;
+
+   uint32_t max_rx_pktlen;
 };

 extern const struct eth_dev_ops default_dev_ops;
-- 
1.7.10.4



[dpdk-dev] [PATCH] bond: use existing enslaved device queues

2016-03-24 Thread Eric Kinzie
This solves issues when an active device is added to a bond.

If a device to be enslaved already has transmit and/or receive queues
allocated, use those and then create any additional queues that are
necessary.

Fixes: 2efb58cbab6e ("bond: new link bonding library")

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_pmd.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 011150a..7472e9d 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1305,6 +1305,8 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
struct bond_rx_queue *bd_rx_q;
struct bond_tx_queue *bd_tx_q;

+   uint16_t old_nb_tx_queues = slave_eth_dev->data->nb_tx_queues;
+   uint16_t old_nb_rx_queues = slave_eth_dev->data->nb_rx_queues;
int errval;
uint16_t q_id;

@@ -1345,7 +1347,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
}

/* Setup Rx Queues */
-   for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
+   /* Use existing queues, if any */
+   for (q_id = old_nb_rx_queues;
+q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
bd_rx_q = (struct bond_rx_queue 
*)bonded_eth_dev->data->rx_queues[q_id];

errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, 
q_id,
@@ -1361,7 +1365,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
}

/* Setup Tx Queues */
-   for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
+   /* Use existing queues, if any */
+   for (q_id = old_nb_tx_queues;
+q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
bd_tx_q = (struct bond_tx_queue 
*)bonded_eth_dev->data->tx_queues[q_id];

errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, 
q_id,
-- 
1.7.10.4



[dpdk-dev] [PATCH v2 4/6] bond mode 4: allow external state machine

2016-03-01 Thread Eric Kinzie
On Thu Feb 25 15:22:35 + 2016, Iremonger, Bernard wrote:
> Hi Eric,
> 
> 
> > > @@ -157,6 +159,7 @@ struct rte_eth_bond_8023ad_conf {
> > >   uint32_t tx_period_ms;
> > >   uint32_t rx_marker_period_ms;
> > >   uint32_t update_timeout_ms;
> > > + rte_eth_bond_8023ad_ext_slowrx_fn slowrx_cb;
> > >   };
> > 
> > This still is a likely an ABI break, previously discussed around here:
> > http://dpdk.org/ml/archives/dev/2015-November/027321.html
> > 
> > It might not be embedded anywhere in DPDK codebase, but there's no
> > telling what others might have done with it (have an array of them, embed in
> > other structs etc).
> > 
> > Also ultimately ABI compatibility goes both ways: when the library soname
> > does not change then an application is free to assume both downgrading and
> > upgrading are safe. In this case, upgrading *might* be okay, downgrading
> > certainly is not. So by that measure it definitely is an ABI break.
> > 
> > [...]
> > > diff --git a/drivers/net/bonding/rte_eth_bond_version.map
> > > b/drivers/net/bonding/rte_eth_bond_version.map
> > > index 22bd920..33d73ff 100644
> > > --- a/drivers/net/bonding/rte_eth_bond_version.map
> > > +++ b/drivers/net/bonding/rte_eth_bond_version.map
> > > @@ -27,3 +27,9 @@ DPDK_2.1 {
> > >   rte_eth_bond_free;
> > >
> > >   } DPDK_2.0;
> > > +
> > > +DPDK_2.2 {
> > > + rte_eth_bond_8023ad_ext_collect;
> > > + rte_eth_bond_8023ad_ext_distrib;
> > > + rte_eth_bond_8023ad_ext_slowtx;
> > > +} DPDK_2.1;
> > >
> > 
> > These symbols are not part of DPDK 2.2, the version here is wrong.
> > Technically it would not actually matter much but better not to confuse
> > things unnecessarily.
> > 
> > - Panu -
> 
> It looks like Panu's points are valid, a V3 of this patch set which takes 
> care of these issues will be needed.
> 
> Patches 1/6, 5/6 and 6/6 of the patch set are bug fixes, so each patch should 
> contain a fixes line.
> Patches 2/6, 3/6 and 4/6 are a new feature, the release notes should be 
> updated for this feature.
> 
> Could I suggest splitting the patch set into two patch sets, a bug fix patch 
> set and a new feature patch set.
> 
> Regards,
> 
> Bernard.

Bernard, a v3 is on the way.  I included only things that are fixes,
but the patch set doesn't quite match the set of patch numbers you listed
above.  1/6 (bond: use existing enslaved device queues) is an improvement,
but doesn't really fix anything that was broken, so I left that out.
2/6 (bond mode 4: copy entire config structure) and 3/6 (bond mode 4:
do not ignore multicast) fix bugs and are included.


Eric



[dpdk-dev] [PATCH V3 4/4] bond: do not activate slave twice

2016-03-01 Thread Eric Kinzie
From: Eric Kinzie 

The current code for detecting link during slave addition can cause a
slave interface to be activated twice -- once during slave_configure()
and again at the end of __eth_bond_slave_add_lock_free().  This will
either cause the active slave count to be incorrect or will cause the
802.3ad activation function to panic.  Ensure that the interface is not
activated more than once.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 drivers/net/bonding/rte_eth_bond_api.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 630a461..def22d0 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -432,7 +432,11 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
!internals->user_defined_primary_port)
bond_ethdev_primary_set(internals,
slave_port_id);
-   activate_slave(bonded_eth_dev, slave_port_id);
+
+   if (find_slave_by_id(internals->active_slaves,
+internals->active_slave_count,
+slave_port_id) == 
internals->active_slave_count)
+   activate_slave(bonded_eth_dev, slave_port_id);
}
}
return 0;
-- 
2.1.4



[dpdk-dev] [PATCH V3 3/4] bond: active slaves with no primary

2016-03-01 Thread Eric Kinzie
From: Eric Kinzie 

If the link state of a slave is "up" when added, it is added to the list
of active slaves but, even if it is the only slave, is not selected as
the primary interface.  Generally, handling of link state interrupts
selects an interface to be primary, but only if the active count is zero.
This change avoids the situation where there are active slaves but
no primary.

Fixes: 2efb58cbab6e ("bond: new link bonding library")

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 drivers/net/bonding/rte_eth_bond_api.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 8a000c8..630a461 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -427,8 +427,13 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
if (bonded_eth_dev->data->dev_started) {
rte_eth_link_get_nowait(slave_port_id, &link_props);

-if (link_props.link_status == 1)
+if (link_props.link_status == 1) {
+   if (internals->active_slave_count == 0 &&
+   !internals->user_defined_primary_port)
+   bond_ethdev_primary_set(internals,
+   slave_port_id);
activate_slave(bonded_eth_dev, slave_port_id);
+   }
}
return 0;

-- 
2.1.4



[dpdk-dev] [PATCH V3 2/4] bond mode 4: do not ignore multicast

2016-03-01 Thread Eric Kinzie
From: Eric Kinzie 

The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous
mode in order to receive LACPDUs and must filter unwanted packets
after the traffic has been "collected".  Allow broadcast and multicast
through so that ARP and IPv6 neighbor discovery continue to work.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 app/test/test_link_bonding_mode4.c | 7 +--
 drivers/net/bonding/rte_eth_bond_pmd.c | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 713368d..31640cd 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -747,8 +747,11 @@ test_mode4_rx(void)
rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
ether_addr_copy(&bonded_mac, &dst_mac);

-   /* Assert that dst address is not bonding address */
-   dst_mac.addr_bytes[0]++;
+   /* Assert that dst address is not bonding address.  Do not set the
+* least significant bit of the zero byte as this would create a
+* multicast address.
+*/
+   dst_mac.addr_bytes[0] += 2;

/* First try with promiscuous mode enabled.
 * Add 2 packets to each slave. First with bonding MAC address, second 
with
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index b63c886..011150a 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -171,6 +171,7 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
 * mode and packet address does not match. */
if (unlikely(hdr->ether_type == ether_type_slow_be ||
!collecting || (!promisc &&
+   !is_multicast_ether_addr(&hdr->d_addr) 
&&
!is_same_ether_addr(&bond_mac, 
&hdr->d_addr {

if (hdr->ether_type == ether_type_slow_be) {
-- 
2.1.4



[dpdk-dev] [PATCH V3 1/4] bond mode 4: copy entire config structure

2016-03-01 Thread Eric Kinzie
From: Eric Kinzie 

Copy all needed fields from the mode8023ad_private structure in
bond_mode_8023ad_conf_get().  This help ensure that a subsequent call
to rte_eth_bond_8023ad_setup() is not passed uninitialized data that
would result in either incorrect behavior or a failed sanity check.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index b3b30f6..1b7e93a 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1019,6 +1019,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

 void
-- 
2.1.4



[dpdk-dev] [PATCH V3 0/4] bonding: fixes and enhancements

2016-03-01 Thread Eric Kinzie
These are bug fixes and some small enhancements to allow bonding
to work with external control (teamd). Please consider integrating
these into DPDK 2.2

Changes in v2:
- remove "bond: handle slaves with fewer queues than bonding device"
- remove "bond: per-slave intermediate rx ring"

Changes in v3:
This version has only fixes.  Patches with new functionality have been
removed and will be submitted separately.
- remove "bond mode 4: allow external state machine"
- remove "bond: use existing enslaved device queues"

Eric Kinzie (4):
  bond mode 4: copy entire config structure
  bond mode 4: do not ignore multicast
  bond: active slaves with no primary
  bond: do not activate slave twice

 app/test/test_link_bonding_mode4.c|  7 +--
 drivers/net/bonding/rte_eth_bond_8023ad.c |  1 +
 drivers/net/bonding/rte_eth_bond_api.c| 13 +++--
 drivers/net/bonding/rte_eth_bond_pmd.c|  1 +
 4 files changed, 18 insertions(+), 4 deletions(-)

-- 
2.1.4



[dpdk-dev] [PATCH v2 6/6] bond: do not activate slave twice

2016-02-19 Thread Eric Kinzie
From: Eric Kinzie 

The current code for detecting link during slave addition can cause a
slave interface to be activated twice -- once during slave_configure()
and again at the end of __eth_bond_slave_add_lock_free().  This will
either cause the active slave count to be incorrect or will cause the
802.3ad activation function to panic.  Ensure that the interface is not
activated more than once.

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 drivers/net/bonding/rte_eth_bond_api.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 630a461..def22d0 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -432,7 +432,11 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
!internals->user_defined_primary_port)
bond_ethdev_primary_set(internals,
slave_port_id);
-   activate_slave(bonded_eth_dev, slave_port_id);
+
+   if (find_slave_by_id(internals->active_slaves,
+internals->active_slave_count,
+slave_port_id) == 
internals->active_slave_count)
+   activate_slave(bonded_eth_dev, slave_port_id);
}
}
return 0;
-- 
1.7.10.4



[dpdk-dev] [PATCH v2 5/6] bond: active slaves with no primary

2016-02-19 Thread Eric Kinzie
From: Eric Kinzie 

If the link state of a slave is "up" when added, it is added to the list
of active slaves but, even if it is the only slave, is not selected as
the primary interface.  Generally, handling of link state interrupts
selects an interface to be primary, but only if the active count is zero.
This change avoids the situation where there are active slaves but
no primary.

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 drivers/net/bonding/rte_eth_bond_api.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 8a000c8..630a461 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -427,8 +427,13 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, 
uint8_t slave_port_id)
if (bonded_eth_dev->data->dev_started) {
rte_eth_link_get_nowait(slave_port_id, &link_props);

-if (link_props.link_status == 1)
+if (link_props.link_status == 1) {
+   if (internals->active_slave_count == 0 &&
+   !internals->user_defined_primary_port)
+   bond_ethdev_primary_set(internals,
+   slave_port_id);
activate_slave(bonded_eth_dev, slave_port_id);
+   }
}
return 0;

-- 
1.7.10.4



[dpdk-dev] [PATCH v2 4/6] bond mode 4: allow external state machine

2016-02-19 Thread Eric Kinzie
From: Eric Kinzie 

Provide functions to allow an external 802.3ad state machine to transmit
and recieve LACPDUs and to set the collection/distribution flags on
slave interfaces.

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c |  173 +
 drivers/net/bonding/rte_eth_bond_8023ad.h |   44 ++
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |2 +
 drivers/net/bonding/rte_eth_bond_version.map  |6 +
 4 files changed, 225 insertions(+)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 1b7e93a..a260e06 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -42,6 +42,8 @@

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -1020,6 +1022,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
 }

 void
@@ -1041,8 +1044,11 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
+   conf->slowrx_cb = NULL;
}

+   bond_mode_8023ad_stop(dev);
+
mode4->fast_periodic_timeout = conf->fast_periodic_ms * ms_ticks;
mode4->slow_periodic_timeout = conf->slow_periodic_ms * ms_ticks;
mode4->short_timeout = conf->short_timeout_ms * ms_ticks;
@@ -1051,6 +1057,10 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->tx_period_timeout = conf->tx_period_ms * ms_ticks;
mode4->rx_marker_timeout = conf->rx_marker_period_ms * ms_ticks;
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
+   mode4->slowrx_cb = conf->slowrx_cb;
+
+   if (dev->data->dev_started)
+   bond_mode_8023ad_start(dev);
 }

 int
@@ -1068,6 +1078,13 @@ bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev)
 int
 bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
 {
+   struct bond_dev_private *internals = bond_dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (mode4->slowrx_cb)
+   return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 
1000,
+   &bond_mode_8023ad_ext_periodic_cb, bond_dev);
+
return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 1000,
&bond_mode_8023ad_periodic_cb, bond_dev);
 }
@@ -1075,6 +1092,13 @@ bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
 void
 bond_mode_8023ad_stop(struct rte_eth_dev *bond_dev)
 {
+   struct bond_dev_private *internals = bond_dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (mode4->slowrx_cb) {
+   rte_eal_alarm_cancel(&bond_mode_8023ad_ext_periodic_cb, 
bond_dev);
+   return;
+   }
rte_eal_alarm_cancel(&bond_mode_8023ad_periodic_cb, bond_dev);
 }

@@ -1221,3 +1245,152 @@ rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t 
slave_id,
info->agg_port_id = port->aggregator_port_id;
return 0;
 }
+
+int
+rte_eth_bond_8023ad_ext_collect(uint8_t port_id, uint8_t slave_id, int enabled)
+{
+   struct rte_eth_dev *bond_dev;
+   struct bond_dev_private *internals;
+   struct mode8023ad_private *mode4;
+   struct port *port;
+
+   if (rte_eth_bond_mode_get(port_id) != BONDING_MODE_8023AD)
+   return -EINVAL;
+
+   bond_dev = &rte_eth_devices[port_id];
+
+   if (!bond_dev->data->dev_started)
+   return -EINVAL;
+
+   internals = bond_dev->data->dev_private;
+   if (find_slave_by_id(internals->active_slaves,
+   internals->active_slave_count, slave_id) ==
+   internals->active_slave_count)
+   return -EINVAL;
+
+   mode4 = &internals->mode4;
+   if (mode4->slowrx_cb == NULL)
+   return -EINVAL;
+
+   port = &mode_8023ad_ports[slave_id];
+
+   if (enabled)
+   ACTOR_STATE_SET(port, COLLECTING);
+   else
+   ACTOR_STATE_CLR(port, COLLECTING);
+
+   return 0;
+}
+
+int
+rte_eth_bond_8023ad_ext_

[dpdk-dev] [PATCH v2 3/6] bond mode 4: do not ignore multicast

2016-02-19 Thread Eric Kinzie
From: Eric Kinzie 

The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous
mode in order to receive LACPDUs and must filter unwanted packets
after the traffic has been "collected".  Allow broadcast and multicast
through so that ARP and IPv6 neighbor discovery continue to work.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 app/test/test_link_bonding_mode4.c |7 +--
 drivers/net/bonding/rte_eth_bond_pmd.c |1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 713368d..31640cd 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -747,8 +747,11 @@ test_mode4_rx(void)
rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
ether_addr_copy(&bonded_mac, &dst_mac);

-   /* Assert that dst address is not bonding address */
-   dst_mac.addr_bytes[0]++;
+   /* Assert that dst address is not bonding address.  Do not set the
+* least significant bit of the zero byte as this would create a
+* multicast address.
+*/
+   dst_mac.addr_bytes[0] += 2;

/* First try with promiscuous mode enabled.
 * Add 2 packets to each slave. First with bonding MAC address, second 
with
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 2f193db..b938a68 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -171,6 +171,7 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
 * mode and packet address does not match. */
if (unlikely(hdr->ether_type == ether_type_slow_be ||
!collecting || (!promisc &&
+   !is_multicast_ether_addr(&hdr->d_addr) 
&&
!is_same_ether_addr(&bond_mac, 
&hdr->d_addr {

if (hdr->ether_type == ether_type_slow_be) {
-- 
1.7.10.4



[dpdk-dev] [PATCH v2 2/6] bond mode 4: copy entire config structure

2016-02-19 Thread Eric Kinzie
From: Eric Kinzie 

Copy all needed fields from the mode8023ad_private structure in
bond_mode_8023ad_conf_get().  This help ensure that a subsequent call
to rte_eth_bond_8023ad_setup() is not passed uninitialized data that
would result in either incorrect behavior or a failed sanity check.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index b3b30f6..1b7e93a 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1019,6 +1019,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

 void
-- 
1.7.10.4



[dpdk-dev] [PATCH v2 1/6] bond: use existing enslaved device queues

2016-02-19 Thread Eric Kinzie
This solves issues when an active device is added to a bond.

If a device to be enslaved already has transmit and/or receive queues
allocated, use those and then create any additional queues that are
necessary.

Signed-off-by: Eric Kinzie 
Signed-off-by: Stephen Hemminger 
Acked-by: Declan Doherty 
---
 drivers/net/bonding/rte_eth_bond_pmd.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index b63c886..2f193db 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1344,7 +1344,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
}

/* Setup Rx Queues */
-   for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
+   /* Use existing queues, if any */
+   for (q_id = slave_eth_dev->data->nb_rx_queues;
+q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
bd_rx_q = (struct bond_rx_queue 
*)bonded_eth_dev->data->rx_queues[q_id];

errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, 
q_id,
@@ -1360,7 +1362,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
}

/* Setup Tx Queues */
-   for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
+   /* Use existing queues, if any */
+   for (q_id = slave_eth_dev->data->nb_tx_queues;
+q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
bd_tx_q = (struct bond_tx_queue 
*)bonded_eth_dev->data->tx_queues[q_id];

errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, 
q_id,
-- 
1.7.10.4



[dpdk-dev] [PATCH v2 0/6] bonding: fixes and enhancements

2016-02-19 Thread Eric Kinzie
These are bug fixes and some small enhancements to allow bonding
to work with external control (teamd). Please consider integrating
these into DPDK 2.2

Changes in v2:
- remove "bond: handle slaves with fewer queues than bonding device"
- remove "bond: per-slave intermediate rx ring"

Eric Kinzie (6):
  bond: use existing enslaved device queues
  bond mode 4: copy entire config structure
  bond mode 4: do not ignore multicast
  bond mode 4: allow external state machine
  bond: active slaves with no primary
  bond: do not activate slave twice

 app/test/test_link_bonding_mode4.c|7 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  174 +
 drivers/net/bonding/rte_eth_bond_8023ad.h |   44 ++
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |2 +
 drivers/net/bonding/rte_eth_bond_api.c|   13 +-
 drivers/net/bonding/rte_eth_bond_pmd.c|9 +-
 drivers/net/bonding/rte_eth_bond_version.map  |6 +
 7 files changed, 249 insertions(+), 6 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH 6/8] bond: handle slaves with fewer queues than bonding device

2015-12-04 Thread Eric Kinzie
On Fri Dec 04 19:36:09 +0100 2015, Andriy Berestovskyy wrote:
> Hi guys,
> I'm not quite sure if we can support less TX queues on a slave that easy:
> 
> > queue_id = bond_slave_txqid(internals, i, bd_tx_q->queue_id);
> > num_tx_slave = rte_eth_tx_burst(slaves[i], queue_id,
> >  slave_bufs[i], slave_nb_pkts[i]);
> 
> It seems that two different lcores might end up writing to the same
> slave queue at the same time, isn't it?
> 
> Regards,
> Andriy

Andriy, I think you're probably right about this.  Perhaps it should
instead refuse to add or refuse to activate a slave with too few
tx queues.  Could probably fix this with another layer of buffering
so that an lcore with a valid tx queue could pick up the mbufs later,
but this doesn't seem very appealing.

Eric


> On Fri, Dec 4, 2015 at 6:14 PM, Stephen Hemminger
>  wrote:
> > From: Eric Kinzie 
> >
> > In the event that the bonding device has a greater number of tx and/or rx
> > queues than the slave being added, track the queue limits of the slave.
> > On receive, ignore queue identifiers beyond what the slave interface
> > can support.  During transmit, pick a different queue id to use if the
> > intended queue is not available on the slave.
> >
> > Signed-off-by: Eric Kinzie 
> > Signed-off-by: Stephen Hemminger 
> > ---
> >  drivers/net/bonding/rte_eth_bond_api.c |   6 +-
> >  drivers/net/bonding/rte_eth_bond_pmd.c | 141 
> > +
> >  drivers/net/bonding/rte_eth_bond_private.h |   5 +-
> >  3 files changed, 129 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
> > b/drivers/net/bonding/rte_eth_bond_api.c
> > index 630a461..64058ff 100644
> > --- a/drivers/net/bonding/rte_eth_bond_api.c
> > +++ b/drivers/net/bonding/rte_eth_bond_api.c
> > @@ -340,11 +340,11 @@ __eth_bond_slave_add_lock_free(uint8_t 
> > bonded_port_id, uint8_t slave_port_id)
> >
> > slave_eth_dev = &rte_eth_devices[slave_port_id];
> >
> > -   /* Add slave details to bonded device */
> > -   slave_add(internals, slave_eth_dev);
> > -
> > rte_eth_dev_info_get(slave_port_id, &dev_info);
> >
> > +   /* Add slave details to bonded device */
> > +   slave_add(internals, slave_eth_dev, &dev_info);
> > +
> > /* We need to store slaves reta_size to be able to synchronize RETA 
> > for all
> >  * slave devices even if its sizes are different.
> >  */
> > diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
> > b/drivers/net/bonding/rte_eth_bond_pmd.c
> > index 77582dd..868e66b 100644
> > --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> > +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> > @@ -76,6 +76,47 @@ get_vlan_offset(struct ether_hdr *eth_hdr, uint16_t 
> > *proto)
> > return vlan_offset;
> >  }
> >
> > +static uint8_t
> > +bond_active_slaves_by_rxqid(struct bond_dev_private *internals, int 
> > queue_id,
> > +   uint8_t slaves[])
> > +{
> > +   struct bond_slave_details *slave_details;
> > +   uint8_t num_of_slaves;
> > +   uint8_t i = 0;
> > +
> > +   num_of_slaves = internals->active_slave_count;
> > +   memcpy(slaves, internals->active_slaves,
> > +   sizeof(internals->active_slaves[0]) * 
> > num_of_slaves);
> > +
> > +   if (num_of_slaves < 1 || internals->kvlist)
> > +   return num_of_slaves;
> > +
> > +   /* remove slaves that don't have a queue numbered "queue_id" */
> > +   while (i < num_of_slaves) {
> > +   slave_details = &internals->slaves[i];
> > +   if (unlikely(queue_id >= slave_details->nb_rx_queues)) {
> > +   slaves[i] = slaves[num_of_slaves-1];
> > +   num_of_slaves--;
> > +   } else
> > +   i++;
> > +   }
> > +
> > +   return num_of_slaves;
> > +}
> > +
> > +static int
> > +bond_slave_txqid(struct bond_dev_private *internals, uint8_t slave_id,
> > +   int queue_id)
> > +{
> > +   struct bond_slave_details *slave_details;
> > +
> > +   if (internals->kvlist)
> > +   return queue_id;
> > +
> > +   slave_details = &internals->slaves[slave_id];
> > +   return queue_id % slave_details->nb_tx_queues;
> > +}
> > +
> >  static u

[dpdk-dev] [PATCH v6 3/4] bond mode 4: allow external state machine

2015-11-20 Thread Eric Kinzie
On Tue Nov 03 11:48:57 + 2015, Ferruh Yigit wrote:
> On Tue, Nov 03, 2015 at 01:31:45PM +0200, Panu Matilainen wrote:
> > On 11/03/2015 01:02 PM, Ferruh Yigit wrote:
> >> On Tue, Nov 03, 2015 at 08:48:16AM +0200, Panu Matilainen wrote:
> >>> On 11/02/2015 06:42 PM, Eric Kinzie wrote:
> >>>> On Mon Nov 02 12:23:47 +0200 2015, Panu Matilainen wrote:
> >>>>> On 11/01/2015 08:17 PM, Thomas Monjalon wrote:
> >>>>>> 2015-10-19 08:36, Eric Kinzie:
> >>>>>>> Size of struct rte_eth_bond_8023ad_conf changed.  Increment 
> >>>>>>> LIBABIVER
> >>>>>>> and version bond_mode_8023ad_setup and bond_mode_8023ad_conf_get
> >>>>>>> functions.
> >>>>>> [...]
> >>>>>>> +VERSION_SYMBOL(bond_mode_8023ad_setup, _v20, 2.0);
> >>>>>> [...]
> >>>>>>> +BIND_DEFAULT_SYMBOL(bond_mode_8023ad_setup, _v22, 2.2);
> >>>>>>> +MAP_STATIC_SYMBOL(void bond_mode_8023ad_setup(struct rte_eth_dev 
> >>>>>>> *dev, struct rte_eth_bond_8023ad_conf *conf), \
> >>>>>>> +   bond_mode_8023ad_setup_v22);
> >>>>>>
> >>>>>> I'm sorry it doesn't work well when trying to build a combined lib:
> >>>>>>
> >>>>>> ld: libdpdk.so: version node not found for symbol 
> >>>>>> bond_mode_8023ad_setup@@DPDK_2.2
> >>>>>>
> >>>>>> The symbols are OK in the .o file:
> >>>>>> 2340 g F .text  0171 
> >>>>>> bond_mode_8023ad_setup@@DPDK_2.2
> >>>>>> 2260 g F .text  00da 
> >>>>>> bond_mode_8023ad_setup at DPDK_2.0
> >>>>>> 2260 g F .text  00da 
> >>>>>> bond_mode_8023ad_setup_v20
> >>>>>> 2340 g F .text  0171 
> >>>>>> bond_mode_8023ad_setup_v22
> >>>>>>  *UND*   bond_mode_8023ad_setup
> >>>>>>
> >>>>>> I don't understand the problem and I am considering disabling 
> >>>>>> versioning in
> >>>>>> combined library.
> >>>>>>
> >>>>>> Any idea?
> >>>>>>
> >>>>>
> >>>>> The .map additions look incorrect to me:
> >>>>>
> >>>>>> diff --git a/drivers/net/bonding/rte_eth_bond_version.map 
> >>>>>> b/drivers/net/bonding/rte_eth_bond_version.map
> >>>>>> index 22bd920..7f78717 100644
> >>>>>> --- a/drivers/net/bonding/rte_eth_bond_version.map
> >>>>>> +++ b/drivers/net/bonding/rte_eth_bond_version.map
> >>>>>> @@ -17,6 +17,9 @@  DPDK_2.0 {
> >>>>>>rte_eth_bond_slaves_get;
> >>>>>>rte_eth_bond_xmit_policy_get;
> >>>>>>rte_eth_bond_xmit_policy_set;
> >>>>>> +  rte_eth_bond_8023ad_ext_collect;
> >>>>>> +  rte_eth_bond_8023ad_ext_distrib;
> >>>>>> +  rte_eth_bond_8023ad_ext_slowtx;
> >>>>>
> >>>>> These symbols didn't exist in DPDK 2.0 but are only being added
> >>>>> here. So why are they being added to the 2.0 section?
> >>>>
> >>>> Yes, I think these should probably be moved.
> >>>>
> >>>>
> >>>>>>
> >>>>>>local: *;
> >>>>>> };
> >>>>>> @@ -27,3 +30,10 @@  DPDK_2.1 {
> >>>>>>rte_eth_bond_free;
> >>>>>>
> >>>>>> } DPDK_2.0;
> >>>>>> +
> >>>>>> +DPDK_2.2 {
> >>>>>> +  local
> >>>>>> +
> >>>>>> +  bond_mode_8023ad_conf_get;
> >>>>>> +  bond_mode_8023ad_setup;
> >>>>>> +} DPDK_2.1;
> >>>>>
> >>>>> These are marked local, as in, "not exported" which doesn't seem
> >>>>> right. Also they're lacking the rte_eth_ prefix. AFAICS this is what
> >>>>> the symbol export map should look like here:
> >>>>
> >>>&

[dpdk-dev] [PATCH v6 3/4] bond mode 4: allow external state machine

2015-11-03 Thread Eric Kinzie
On Tue Nov 03 10:30:56 +0200 2015, Panu Matilainen wrote:
> On 11/03/2015 10:16 AM, Thomas Monjalon wrote:
> >2015-11-03 08:48, Panu Matilainen:
> >>On 11/02/2015 06:42 PM, Eric Kinzie wrote:
> >>>On Mon Nov 02 12:23:47 +0200 2015, Panu Matilainen wrote:
> >>>>On 11/01/2015 08:17 PM, Thomas Monjalon wrote:
> >>>>>2015-10-19 08:36, Eric Kinzie:
> >>>>>>Size of struct rte_eth_bond_8023ad_conf changed.  Increment 
> >>>>>> LIBABIVER
> >>>>>>and version bond_mode_8023ad_setup and bond_mode_8023ad_conf_get
> >>>>>>functions.
> >>>>>[...]
> >>>>>>+VERSION_SYMBOL(bond_mode_8023ad_setup, _v20, 2.0);
> >>>>>[...]
> >>>>>>+BIND_DEFAULT_SYMBOL(bond_mode_8023ad_setup, _v22, 2.2);
> >>>>>>+MAP_STATIC_SYMBOL(void bond_mode_8023ad_setup(struct rte_eth_dev *dev, 
> >>>>>>struct rte_eth_bond_8023ad_conf *conf), \
> >>>>>>+ bond_mode_8023ad_setup_v22);
> >>>>>
> >>>>>I'm sorry it doesn't work well when trying to build a combined lib:
> >>>>>
> >>>>>ld: libdpdk.so: version node not found for symbol 
> >>>>>bond_mode_8023ad_setup@@DPDK_2.2
> >>>>>
> >>>>>The symbols are OK in the .o file:
> >>>>>2340 g F .text  0171 
> >>>>>bond_mode_8023ad_setup@@DPDK_2.2
> >>>>>2260 g F .text  00da bond_mode_8023ad_setup 
> >>>>>at DPDK_2.0
> >>>>>2260 g F .text  00da 
> >>>>>bond_mode_8023ad_setup_v20
> >>>>>2340 g F .text  0171 
> >>>>>bond_mode_8023ad_setup_v22
> >>>>> *UND*   bond_mode_8023ad_setup
> >>>>>
> >>>>>I don't understand the problem and I am considering disabling versioning 
> >>>>>in
> >>>>>combined library.
> >>>>>
> >>>>>Any idea?
> >>>>>
> >>>>
> >>>>The .map additions look incorrect to me:
> >>>>
> >>>>>diff --git a/drivers/net/bonding/rte_eth_bond_version.map 
> >>>>>b/drivers/net/bonding/rte_eth_bond_version.map
> >>>>>index 22bd920..7f78717 100644
> >>>>>--- a/drivers/net/bonding/rte_eth_bond_version.map
> >>>>>+++ b/drivers/net/bonding/rte_eth_bond_version.map
> >>>>>@@ -17,6 +17,9 @@  DPDK_2.0 {
> >>>>> rte_eth_bond_slaves_get;
> >>>>> rte_eth_bond_xmit_policy_get;
> >>>>> rte_eth_bond_xmit_policy_set;
> >>>>>+rte_eth_bond_8023ad_ext_collect;
> >>>>>+rte_eth_bond_8023ad_ext_distrib;
> >>>>>+rte_eth_bond_8023ad_ext_slowtx;
> >>>>
> >>>>These symbols didn't exist in DPDK 2.0 but are only being added
> >>>>here. So why are they being added to the 2.0 section?
> >>>
> >>>Yes, I think these should probably be moved.
> >>>
> >>>
> >>>>>
> >>>>> local: *;
> >>>>>};
> >>>>>@@ -27,3 +30,10 @@  DPDK_2.1 {
> >>>>> rte_eth_bond_free;
> >>>>>
> >>>>>} DPDK_2.0;
> >>>>>+
> >>>>>+DPDK_2.2 {
> >>>>>+local
> >>>>>+
> >>>>>+bond_mode_8023ad_conf_get;
> >>>>>+bond_mode_8023ad_setup;
> >>>>>+} DPDK_2.1;
> >>>>
> >>>>These are marked local, as in, "not exported" which doesn't seem
> >>>>right. Also they're lacking the rte_eth_ prefix. AFAICS this is what
> >>>>the symbol export map should look like here:
> >>>
> >>>
> >>>These were not exported to begin with.  But after versioning these
> >>>functions, they are exported unless explicitly declared to be local here.
> >>>
> >>
> >>And this does not ring any warning bells? :)
> >>
> >>Sorry, I was not looking at the patch as a whole. You're declaring these
> >>symbols as exported with the versioning macros, eg
> >>
> >>BIND_DEFAULT_SYMBOL(bond_mode_8023ad

[dpdk-dev] [PATCH v6 3/4] bond mode 4: allow external state machine

2015-11-02 Thread Eric Kinzie
On Mon Nov 02 12:23:47 +0200 2015, Panu Matilainen wrote:
> On 11/01/2015 08:17 PM, Thomas Monjalon wrote:
> >2015-10-19 08:36, Eric Kinzie:
> >>   Size of struct rte_eth_bond_8023ad_conf changed.  Increment LIBABIVER
> >>   and version bond_mode_8023ad_setup and bond_mode_8023ad_conf_get
> >>   functions.
> >[...]
> >>+VERSION_SYMBOL(bond_mode_8023ad_setup, _v20, 2.0);
> >[...]
> >>+BIND_DEFAULT_SYMBOL(bond_mode_8023ad_setup, _v22, 2.2);
> >>+MAP_STATIC_SYMBOL(void bond_mode_8023ad_setup(struct rte_eth_dev *dev, 
> >>struct rte_eth_bond_8023ad_conf *conf), \
> >>+ bond_mode_8023ad_setup_v22);
> >
> >I'm sorry it doesn't work well when trying to build a combined lib:
> >
> >ld: libdpdk.so: version node not found for symbol 
> >bond_mode_8023ad_setup@@DPDK_2.2
> >
> >The symbols are OK in the .o file:
> >2340 g F .text  0171 
> >bond_mode_8023ad_setup@@DPDK_2.2
> >2260 g F .text  00da bond_mode_8023ad_setup at 
> >DPDK_2.0
> >2260 g F .text  00da bond_mode_8023ad_setup_v20
> >2340 g F .text  0171 bond_mode_8023ad_setup_v22
> > *UND*   bond_mode_8023ad_setup
> >
> >I don't understand the problem and I am considering disabling versioning in
> >combined library.
> >
> >Any idea?
> >
> 
> The .map additions look incorrect to me:
> 
> >diff --git a/drivers/net/bonding/rte_eth_bond_version.map 
> >b/drivers/net/bonding/rte_eth_bond_version.map
> >index 22bd920..7f78717 100644
> >--- a/drivers/net/bonding/rte_eth_bond_version.map
> >+++ b/drivers/net/bonding/rte_eth_bond_version.map
> >@@ -17,6 +17,9 @@  DPDK_2.0 {
> > rte_eth_bond_slaves_get;
> > rte_eth_bond_xmit_policy_get;
> > rte_eth_bond_xmit_policy_set;
> >+rte_eth_bond_8023ad_ext_collect;
> >+rte_eth_bond_8023ad_ext_distrib;
> >+rte_eth_bond_8023ad_ext_slowtx;
> 
> These symbols didn't exist in DPDK 2.0 but are only being added
> here. So why are they being added to the 2.0 section?

Yes, I think these should probably be moved.


> >
> > local: *;
> > };
> >@@ -27,3 +30,10 @@  DPDK_2.1 {
> > rte_eth_bond_free;
> >
> > } DPDK_2.0;
> >+
> >+DPDK_2.2 {
> >+local
> >+
> >+bond_mode_8023ad_conf_get;
> >+bond_mode_8023ad_setup;
> >+} DPDK_2.1;
> 
> These are marked local, as in, "not exported" which doesn't seem
> right. Also they're lacking the rte_eth_ prefix. AFAICS this is what
> the symbol export map should look like here:


These were not exported to begin with.  But after versioning these
functions, they are exported unless explicitly declared to be local here.


> DPDK_2.2 {
> global:
> 
> rte_eth_bond_8023ad_ext_collect;
> rte_eth_bond_8023ad_ext_distrib;
> rte_eth_bond_8023ad_ext_slowtx;
> rte_eth_bond_mode_8023ad_conf_get;
> rte_eth_bond_mode_8023ad_setup;
> } DPDK_2.1;
> 
> That said, problems with symbol versioning and the combined library
> were predicted from the start, once the individual library versions
> start advancing. For one, the combined library itself is not
> versioned at all it is offending the ABI policy all the time.
> 
> Replacing the library with a linker script, as suggested before by
> Neil Horman and Sergio Gonzales Monroy would eliminate these
> problems.
> 
>   - Panu -
> 
> 


[dpdk-dev] [PATCH v6 4/4] bond mode 4: tests for external state machine

2015-10-19 Thread Eric Kinzie
From: Eric Kinzie 

  This adds test cases for exercising the external state machine API to
  the mode 4 autotest.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |  210 ++--
 1 file changed, 201 insertions(+), 9 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index d785393..6a459cd 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -151,6 +151,8 @@ static struct rte_eth_conf default_pmd_conf = {
.lpbk_mode = 0,
 };

+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); 
_i++)

@@ -320,8 +322,26 @@ remove_slave(struct slave_conf *slave)
return 0;
 }

+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+   struct ether_hdr *hdr;
+   struct slow_protocol_frame *slow_hdr;
+
+   RTE_VERIFY(lacp_pkt != NULL);
+
+   hdr = rte_pktmbuf_mtod(lacp_pkt, struct ether_hdr *);
+   RTE_VERIFY(hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_SLOW));
+
+   slow_hdr = rte_pktmbuf_mtod(lacp_pkt, struct slow_protocol_frame *);
+   RTE_VERIFY(slow_hdr->slow_protocol.subtype == SLOW_SUBTYPE_LACP);
+
+   lacpdu_rx_count[slave_id]++;
+   rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
uint8_t i;

@@ -337,9 +357,17 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, 
uint8_t start)
rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
rte_eth_promiscuous_disable(test_params.bonded_port_id);

-   if (start)
-   
TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-   "Failed to start bonded device");
+   if (external_sm) {
+   struct rte_eth_bond_8023ad_conf conf;
+
+   rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+   conf.slowrx_cb = lacp_recv_cb;
+   rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+   }
+
+   TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+   "Failed to start bonded device");

return TEST_SUCCESS;
 }
@@ -642,7 +670,7 @@ test_mode4_lacp(void)
 {
int retval;

-   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -740,7 +768,7 @@ test_mode4_rx(void)
struct ether_addr dst_mac;
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -917,7 +945,7 @@ test_mode4_tx_burst(void)
struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -1101,7 +1129,7 @@ test_mode4_marker(void)
uint8_t i, j;
const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);

-   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -1186,7 +1214,7 @@ test_mode4_expired(void)

struct rte_eth_bond_8023ad_conf conf;

-   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
0);
/* Set custom timeouts to make test last shorter. */
rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
conf.fast_periodic_ms = 100;
@@ -1268,6 +1296,156 @@ test_mode4_expired(void)
 }

 static int
+test_mode4_ext_ctrl(void)
+{
+   /*
+* configure bonded interface without the external sm enabled
+*   . try to transmit lacpdu (should fail)
+*   . try to set collecting and distributing flags (should fail)
+* reconfigure w/external sm
+*   . transmit one lacpdu on each slave using new api
+

[dpdk-dev] [PATCH v6 3/4] bond mode 4: allow external state machine

2015-10-19 Thread Eric Kinzie
From: Eric Kinzie 

  Provide functions to allow an external 802.3ad state machine to transmit
  and recieve LACPDUs and to set the collection/distribution flags on
  slave interfaces.

  Size of struct rte_eth_bond_8023ad_conf changed.  Increment LIBABIVER
  and version bond_mode_8023ad_setup and bond_mode_8023ad_conf_get
  functions.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/Makefile  |2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  240 -
 drivers/net/bonding/rte_eth_bond_8023ad.h |   44 
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
 drivers/net/bonding/rte_eth_bond_version.map  |   10 +
 5 files changed, 321 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile
index dee0875..8b892ca 100644
--- a/drivers/net/bonding/Makefile
+++ b/drivers/net/bonding/Makefile
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)

 EXPORT_MAP := rte_eth_bond_version.map

-LIBABIVER := 1
+LIBABIVER := 2

 #
 # all source are stored in SRCS-y
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 08f679f..0461fb5 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -39,9 +39,12 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -999,7 +1002,28 @@ bond_mode_8023ad_mac_address_update(struct rte_eth_dev 
*bond_dev)
 }

 void
-bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
+bond_mode_8023ad_conf_get_v20(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;
+
+   conf->fast_periodic_ms = mode4->fast_periodic_timeout / ms_ticks;
+   conf->slow_periodic_ms = mode4->slow_periodic_timeout / ms_ticks;
+   conf->short_timeout_ms = mode4->short_timeout / ms_ticks;
+   conf->long_timeout_ms = mode4->long_timeout / ms_ticks;
+   conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
+   conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
+   conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
+}
+
+VERSION_SYMBOL(bond_mode_8023ad_conf_get, _v20, 2.0);
+
+void
+bond_mode_8023ad_conf_get_v22(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
struct bond_dev_private *internals = dev->data->dev_private;
@@ -1014,10 +1038,15 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
 }

+BIND_DEFAULT_SYMBOL(bond_mode_8023ad_conf_get, _v22, 2.2);
+MAP_STATIC_SYMBOL(void bond_mode_8023ad_conf_get(struct rte_eth_dev *dev, 
struct rte_eth_bond_8023ad_conf *conf), \
+ bond_mode_8023ad_conf_get_v22);
+
 void
-bond_mode_8023ad_setup(struct rte_eth_dev *dev,
+bond_mode_8023ad_setup_v20(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
struct rte_eth_bond_8023ad_conf def_conf;
@@ -1047,6 +1076,50 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
 }

+VERSION_SYMBOL(bond_mode_8023ad_setup, _v20, 2.0);
+
+void
+bond_mode_8023ad_setup_v22(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct rte_eth_bond_8023ad_conf def_conf;
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;
+
+   if (conf == NULL) {
+   conf = &def_conf;
+   conf->fast_periodic_ms = BOND_8023AD_FAST_PERIODIC_MS;
+   conf->slow_periodic_ms = BOND_8023AD_SLOW_PERIODIC_MS;
+   conf->short_timeout_ms = BOND_8023AD_SHORT_TIMEOUT_MS;
+   conf->long_timeout_ms = BOND_8023AD_LONG_TIMEOUT_MS;
+   conf->aggregate_wait_timeout_ms = 
BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS;
+   conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
+   conf->rx_marker_

[dpdk-dev] [PATCH v6 2/4] bond mode 4: do not ignore multicast

2015-10-19 Thread Eric Kinzie
From: Eric Kinzie 

The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous
mode in order to receive LACPDUs and must filter unwanted packets
after the traffic has been "collected".  Allow broadcast and multicast
through so that ARP and IPv6 neighbor discovery continue to work.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |7 +--
 drivers/net/bonding/rte_eth_bond_pmd.c |1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 460539d..d785393 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -749,8 +749,11 @@ test_mode4_rx(void)
rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
ether_addr_copy(&bonded_mac, &dst_mac);

-   /* Assert that dst address is not bonding address */
-   dst_mac.addr_bytes[0]++;
+   /* Assert that dst address is not bonding address.  Do not set the
+* least significant bit of the zero byte as this would create a
+* multicast address.
+*/
+   dst_mac.addr_bytes[0] += 2;

/* First try with promiscuous mode enabled.
 * Add 2 packets to each slave. First with bonding MAC address, second 
with
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5cc6372..733022b 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -170,6 +170,7 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
 * mode and packet address does not match. */
if (unlikely(hdr->ether_type == ether_type_slow_be ||
!collecting || (!promisc &&
+   !is_multicast_ether_addr(&hdr->d_addr) 
&&
!is_same_ether_addr(&bond_mac, 
&hdr->d_addr {

if (hdr->ether_type == ether_type_slow_be) {
-- 
1.7.10.4



[dpdk-dev] [PATCH v6 1/4] bond mode 4: copy entire config structure

2015-10-19 Thread Eric Kinzie
From: Eric Kinzie 

  Copy all needed fields from the mode8023ad_private structure in
  bond_mode_8023ad_conf_get().  This help ensure that a subsequent call
  to rte_eth_bond_8023ad_setup() is not passed uninitialized data that
  would result in either incorrect behavior or a failed sanity check.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index c0f0b99..08f679f 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1013,6 +1013,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

 void
-- 
1.7.10.4



[dpdk-dev] [PATCH v6 0/4] bonding corrections and additions

2015-10-19 Thread Eric Kinzie
This patchset makes a couple of small corrections to the bonding driver
and introduces the ability to use an external state machine for mode
4 operation.

Changes in v2:
  . eliminate external_sm field in 802.3ad configuration 
(rte_eth_bond_8023ad_conf).
  . stop bonding device before changing the periodic callback function.
start again if needed.
  . remove unnecessary calls to valid_bonded_port_id().
  . do not check for NULL tx_ring.
  . return error in rte_eth_bond_8023ad_ext_slowtx() if packet is not LACP.
  . remove check for external sm configuration in periodic callback
  . check for valid LACPDU in test application's rx callback
  . add "Fixes:" tags

Changes in v3:
  . update rte_eth_bond_version.map

Changes in v4:
  . version functions that modify slowrx_cb

Changes in v5:
  . remove "__vsym" from source files and use updated symbol version macros

Changes in v6:
  . updated symbols have version 2.2
  . specify versioned local symbol names in map so they don't become exported

Eric Kinzie (4):
  bond mode 4: copy entire config structure
  bond mode 4: do not ignore multicast
  bond mode 4: allow external state machine
  bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c|  217 ++-
 drivers/net/bonding/Makefile  |2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  241 -
 drivers/net/bonding/rte_eth_bond_8023ad.h |   44 
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
 drivers/net/bonding/rte_eth_bond_pmd.c|1 +
 drivers/net/bonding/rte_eth_bond_version.map  |   10 +
 7 files changed, 529 insertions(+), 14 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH v5 4/4] bond mode 4: tests for external state machine

2015-09-30 Thread Eric Kinzie
From: Eric Kinzie 

  This adds test cases for exercising the external state machine API to
  the mode 4 autotest.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |  210 ++--
 1 file changed, 201 insertions(+), 9 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index d785393..6a459cd 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -151,6 +151,8 @@ static struct rte_eth_conf default_pmd_conf = {
.lpbk_mode = 0,
 };

+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); 
_i++)

@@ -320,8 +322,26 @@ remove_slave(struct slave_conf *slave)
return 0;
 }

+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+   struct ether_hdr *hdr;
+   struct slow_protocol_frame *slow_hdr;
+
+   RTE_VERIFY(lacp_pkt != NULL);
+
+   hdr = rte_pktmbuf_mtod(lacp_pkt, struct ether_hdr *);
+   RTE_VERIFY(hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_SLOW));
+
+   slow_hdr = rte_pktmbuf_mtod(lacp_pkt, struct slow_protocol_frame *);
+   RTE_VERIFY(slow_hdr->slow_protocol.subtype == SLOW_SUBTYPE_LACP);
+
+   lacpdu_rx_count[slave_id]++;
+   rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
uint8_t i;

@@ -337,9 +357,17 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, 
uint8_t start)
rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
rte_eth_promiscuous_disable(test_params.bonded_port_id);

-   if (start)
-   
TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-   "Failed to start bonded device");
+   if (external_sm) {
+   struct rte_eth_bond_8023ad_conf conf;
+
+   rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+   conf.slowrx_cb = lacp_recv_cb;
+   rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+   }
+
+   TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+   "Failed to start bonded device");

return TEST_SUCCESS;
 }
@@ -642,7 +670,7 @@ test_mode4_lacp(void)
 {
int retval;

-   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -740,7 +768,7 @@ test_mode4_rx(void)
struct ether_addr dst_mac;
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -917,7 +945,7 @@ test_mode4_tx_burst(void)
struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -1101,7 +1129,7 @@ test_mode4_marker(void)
uint8_t i, j;
const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);

-   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -1186,7 +1214,7 @@ test_mode4_expired(void)

struct rte_eth_bond_8023ad_conf conf;

-   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
0);
/* Set custom timeouts to make test last shorter. */
rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
conf.fast_periodic_ms = 100;
@@ -1268,6 +1296,156 @@ test_mode4_expired(void)
 }

 static int
+test_mode4_ext_ctrl(void)
+{
+   /*
+* configure bonded interface without the external sm enabled
+*   . try to transmit lacpdu (should fail)
+*   . try to set collecting and distributing flags (should fail)
+* reconfigure w/external sm
+*   . transmit one lacpdu on each slave using new api
+

[dpdk-dev] [PATCH v5 3/4] bond mode 4: allow external state machine

2015-09-30 Thread Eric Kinzie
From: Eric Kinzie 

  Provide functions to allow an external 802.3ad state machine to transmit
  and recieve LACPDUs and to set the collection/distribution flags on
  slave interfaces.

  Size of struct rte_eth_bond_8023ad_conf changed.  Increment LIBABIVER
  and version bond_mode_8023ad_setup and bond_mode_8023ad_conf_get
  functions.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/Makefile  |2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  240 -
 drivers/net/bonding/rte_eth_bond_8023ad.h |   44 
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
 drivers/net/bonding/rte_eth_bond_version.map  |3 +
 5 files changed, 314 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile
index dee0875..8b892ca 100644
--- a/drivers/net/bonding/Makefile
+++ b/drivers/net/bonding/Makefile
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)

 EXPORT_MAP := rte_eth_bond_version.map

-LIBABIVER := 1
+LIBABIVER := 2

 #
 # all source are stored in SRCS-y
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 08f679f..312ec11 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -39,9 +39,12 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -999,7 +1002,28 @@ bond_mode_8023ad_mac_address_update(struct rte_eth_dev 
*bond_dev)
 }

 void
-bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
+bond_mode_8023ad_conf_get_v20(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;
+
+   conf->fast_periodic_ms = mode4->fast_periodic_timeout / ms_ticks;
+   conf->slow_periodic_ms = mode4->slow_periodic_timeout / ms_ticks;
+   conf->short_timeout_ms = mode4->short_timeout / ms_ticks;
+   conf->long_timeout_ms = mode4->long_timeout / ms_ticks;
+   conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
+   conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
+   conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
+}
+
+VERSION_SYMBOL(bond_mode_8023ad_conf_get, _v20, 2.0);
+
+void
+bond_mode_8023ad_conf_get_v21(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
struct bond_dev_private *internals = dev->data->dev_private;
@@ -1014,10 +1038,15 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
 }

+BIND_DEFAULT_SYMBOL(bond_mode_8023ad_conf_get, _v21, 2.1);
+MAP_STATIC_SYMBOL(void bond_mode_8023ad_conf_get(struct rte_eth_dev *dev, 
struct rte_eth_bond_8023ad_conf *conf), \
+ bond_mode_8023ad_conf_get_v21);
+
 void
-bond_mode_8023ad_setup(struct rte_eth_dev *dev,
+bond_mode_8023ad_setup_v20(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
struct rte_eth_bond_8023ad_conf def_conf;
@@ -1047,6 +1076,50 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
 }

+VERSION_SYMBOL(bond_mode_8023ad_setup, _v20, 2.0);
+
+void
+bond_mode_8023ad_setup_v21(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct rte_eth_bond_8023ad_conf def_conf;
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;
+
+   if (conf == NULL) {
+   conf = &def_conf;
+   conf->fast_periodic_ms = BOND_8023AD_FAST_PERIODIC_MS;
+   conf->slow_periodic_ms = BOND_8023AD_SLOW_PERIODIC_MS;
+   conf->short_timeout_ms = BOND_8023AD_SHORT_TIMEOUT_MS;
+   conf->long_timeout_ms = BOND_8023AD_LONG_TIMEOUT_MS;
+   conf->aggregate_wait_timeout_ms = 
BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS;
+   conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
+   conf->rx_marker_

[dpdk-dev] [PATCH v5 2/4] bond mode 4: do not ignore multicast

2015-09-30 Thread Eric Kinzie
From: Eric Kinzie 

The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous
mode in order to receive LACPDUs and must filter unwanted packets
after the traffic has been "collected".  Allow broadcast and multicast
through so that ARP and IPv6 neighbor discovery continue to work.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |7 +--
 drivers/net/bonding/rte_eth_bond_pmd.c |1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 460539d..d785393 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -749,8 +749,11 @@ test_mode4_rx(void)
rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
ether_addr_copy(&bonded_mac, &dst_mac);

-   /* Assert that dst address is not bonding address */
-   dst_mac.addr_bytes[0]++;
+   /* Assert that dst address is not bonding address.  Do not set the
+* least significant bit of the zero byte as this would create a
+* multicast address.
+*/
+   dst_mac.addr_bytes[0] += 2;

/* First try with promiscuous mode enabled.
 * Add 2 packets to each slave. First with bonding MAC address, second 
with
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5cc6372..733022b 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -170,6 +170,7 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
 * mode and packet address does not match. */
if (unlikely(hdr->ether_type == ether_type_slow_be ||
!collecting || (!promisc &&
+   !is_multicast_ether_addr(&hdr->d_addr) 
&&
!is_same_ether_addr(&bond_mac, 
&hdr->d_addr {

if (hdr->ether_type == ether_type_slow_be) {
-- 
1.7.10.4



[dpdk-dev] [PATCH v5 1/4] bond mode 4: copy entire config structure

2015-09-30 Thread Eric Kinzie
From: Eric Kinzie 

  Copy all needed fields from the mode8023ad_private structure in
  bond_mode_8023ad_conf_get().  This help ensure that a subsequent call
  to rte_eth_bond_8023ad_setup() is not passed uninitialized data that
  would result in either incorrect behavior or a failed sanity check.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index c0f0b99..08f679f 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1013,6 +1013,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

 void
-- 
1.7.10.4



[dpdk-dev] [PATCH v5 0/4] bonding corrections and additions

2015-09-30 Thread Eric Kinzie
This patchset makes a couple of small corrections to the bonding driver
and introduces the ability to use an external state machine for mode
4 operation.

Changes in v2:
  . eliminate external_sm field in 802.3ad configuration 
(rte_eth_bond_8023ad_conf).
  . stop bonding device before changing the periodic callback function.
start again if needed.
  . remove unnecessary calls to valid_bonded_port_id().
  . do not check for NULL tx_ring.
  . return error in rte_eth_bond_8023ad_ext_slowtx() if packet is not LACP.
  . remove check for external sm configuration in periodic callback
  . check for valid LACPDU in test application's rx callback
  . add "Fixes:" tags

Changes in v3:
  . update rte_eth_bond_version.map

Changes in v4:
  . version functions that modify slowrx_cb

Changes in v5:
  . remove "__vsym" from source files and use updated symbol version macros

Eric Kinzie (4):
  bond mode 4: copy entire config structure
  bond mode 4: do not ignore multicast
  bond mode 4: allow external state machine
  bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c|  217 ++-
 drivers/net/bonding/Makefile  |2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  241 -
 drivers/net/bonding/rte_eth_bond_8023ad.h |   44 
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
 drivers/net/bonding/rte_eth_bond_pmd.c|1 +
 drivers/net/bonding/rte_eth_bond_version.map  |3 +
 7 files changed, 522 insertions(+), 14 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH 2/2] ixgbe: add memory barriers in vector rx/tx

2015-06-25 Thread Eric Kinzie
Add write memory barrier before writing tail pointer.

Fixes c95584dc2b18 ("ixgbe: new vectorized functions for Rx/Tx")

Signed-off-by: Eric Kinzie 
---
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec.c 
b/drivers/net/ixgbe/ixgbe_rxtx_vec.c
index abd10f6..b601de8 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec.c
@@ -123,6 +123,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
 (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));

/* Update the tail pointer on the NIC */
+   rte_wmb();
IXGBE_PCI_REG_WRITE(rxq->rdt_reg_addr, rx_id);
 }

@@ -645,6 +646,8 @@ ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf 
**tx_pkts,

txq->tx_tail = tx_id;

+   /* update tail pointer */
+   rte_wmb();
IXGBE_PCI_REG_WRITE(txq->tdt_reg_addr, txq->tx_tail);

return nb_pkts;
-- 
1.7.10.4



[dpdk-dev] [PATCH 1/2] ixgbe: vector rx rearm after queue reset

2015-06-25 Thread Eric Kinzie
zero values in ixgbe_reset_rx_queue() used by vector receive so that
rearming the rx queue happens at the right time.  Not doing so can in
some cases result in the software inadvertently setting the card's rx
tail pointer equal to the head pointer, which indicates that there are
no descriptors available.  This causes receive to stop indefinitely
on that queue.

Fixes: 01fa1d6215fa ("ixgbe: unify Rx setup")

Signed-off-by: Eric Kinzie 
---
 drivers/net/ixgbe/ixgbe_rxtx.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 3ace8a8..1e840b6 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2261,6 +2261,10 @@ ixgbe_reset_rx_queue(struct ixgbe_adapter *adapter, 
struct ixgbe_rx_queue *rxq)
rxq->nb_rx_hold = 0;
rxq->pkt_first_seg = NULL;
rxq->pkt_last_seg = NULL;
+#ifdef RTE_IXGBE_INC_VECTOR
+   rxq->rxrearm_nb = 0;
+   rxq->rxrearm_start = 0;
+#endif
 }

 int
-- 
1.7.10.4



[dpdk-dev] [PATCH 0/2] ixgbe vector rx/tx changes

2015-06-25 Thread Eric Kinzie
Clear values specific to ixgbe vector RX during queue reset.

I've also include a patch that adds a memory barrier before writing the
rx/tx tail pointer registers in ixgbe_rxtx_vec.c.  The non-vector code
has such barriers which looks right to me.  Comments?

Eric Kinzie (2):
  ixgbe: vector rx rearm after queue reset
  ixgbe: add memory barriers in vector rx/tx

 drivers/net/ixgbe/ixgbe_rxtx.c |4 
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |3 +++
 2 files changed, 7 insertions(+)

-- 
1.7.10.4



[dpdk-dev] [PATCH] ixgbe: fall back to non-vector rx

2015-05-26 Thread Eric Kinzie
The ixgbe driver refuses to receive any packets when vector receive
is enabled and fewer than the minimum number of required mbufs (32)
are supplied.  This makes it incompatible with the bonding driver
which, during receive, may start out with enough buffers but as it
collects packets from each of the enslaved interfaces can drop below
that threshold.  Instead of just giving up when insufficient buffers are
supplied fall back to the original, non-vector, ixgbe receive function.

Signed-off-by: Eric Kinzie 
---
 drivers/net/ixgbe/ixgbe_rxtx.c |   10 +-
 drivers/net/ixgbe/ixgbe_rxtx.h |4 
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |4 ++--
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 4f9ab22..fbba0ab 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -1088,9 +1088,9 @@ ixgbe_rx_fill_from_stage(struct ixgbe_rx_queue *rxq, 
struct rte_mbuf **rx_pkts,
return nb_pkts;
 }

-static inline uint16_t
-rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
-uint16_t nb_pkts)
+uint16_t
+ixgbe_rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+  uint16_t nb_pkts)
 {
struct ixgbe_rx_queue *rxq = (struct ixgbe_rx_queue *)rx_queue;
uint16_t nb_rx = 0;
@@ -1158,14 +1158,14 @@ ixgbe_recv_pkts_bulk_alloc(void *rx_queue, struct 
rte_mbuf **rx_pkts,
return 0;

if (likely(nb_pkts <= RTE_PMD_IXGBE_RX_MAX_BURST))
-   return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
+   return ixgbe_rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);

/* request is relatively large, chunk it up */
nb_rx = 0;
while (nb_pkts) {
uint16_t ret, n;
n = (uint16_t)RTE_MIN(nb_pkts, RTE_PMD_IXGBE_RX_MAX_BURST);
-   ret = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
+   ret = ixgbe_rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
nb_rx = (uint16_t)(nb_rx + ret);
nb_pkts = (uint16_t)(nb_pkts - ret);
if (ret < n)
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index af36438..811e514 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -283,6 +283,10 @@ uint16_t ixgbe_recv_scattered_pkts_vec(void *rx_queue,
 int ixgbe_rx_vec_dev_conf_condition_check(struct rte_eth_dev *dev);
 int ixgbe_rxq_vec_setup(struct ixgbe_rx_queue *rxq);

+uint16_t ixgbe_rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts);
+
+
 #ifdef RTE_IXGBE_INC_VECTOR

 uint16_t ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec.c 
b/drivers/net/ixgbe/ixgbe_rxtx_vec.c
index abd10f6..d27424c 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec.c
@@ -181,7 +181,7 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
  * in one loop
  *
  * Notice:
- * - nb_pkts < RTE_IXGBE_VPMD_RX_BURST, just return no packet
+ * - nb_pkts < RTE_IXGBE_VPMD_RX_BURST, fall back to non-vector receive
  * - nb_pkts > RTE_IXGBE_VPMD_RX_BURST, only scan RTE_IXGBE_VPMD_RX_BURST
  *   numbers of DD bit
  * - don't support ol_flags for rss and csum err
@@ -206,7 +206,7 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct 
rte_mbuf **rx_pkts,
__m128i dd_check, eop_check;

if (unlikely(nb_pkts < RTE_IXGBE_VPMD_RX_BURST))
-   return 0;
+   return ixgbe_rx_recv_pkts(rxq, rx_pkts, nb_pkts);

/* Just the act of getting into the function from the application is
 * going to cost about 7 cycles */
-- 
1.7.10.4



[dpdk-dev] [PATCH] ixgbe fall back to non-vector rx

2015-05-26 Thread Eric Kinzie
This change addresses an issue found using the bonding driver
with ixgbe interfaces that have vector operations enabled
(CONFIG_RTE_IXGBE_INC_VECTOR=y).

Eric Kinzie (1):
  ixgbe: fall back to non-vector rx

 drivers/net/ixgbe/ixgbe_rxtx.c |   10 +-
 drivers/net/ixgbe/ixgbe_rxtx.h |4 
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |4 ++--
 3 files changed, 11 insertions(+), 7 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH v4 4/4] bond mode 4: tests for external state machine

2015-05-26 Thread Eric Kinzie
From: Eric Kinzie 

  This adds test cases for exercising the external state machine API to
  the mode 4 autotest.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |  210 ++--
 1 file changed, 201 insertions(+), 9 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index d785393..6a459cd 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -151,6 +151,8 @@ static struct rte_eth_conf default_pmd_conf = {
.lpbk_mode = 0,
 };

+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); 
_i++)

@@ -320,8 +322,26 @@ remove_slave(struct slave_conf *slave)
return 0;
 }

+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+   struct ether_hdr *hdr;
+   struct slow_protocol_frame *slow_hdr;
+
+   RTE_VERIFY(lacp_pkt != NULL);
+
+   hdr = rte_pktmbuf_mtod(lacp_pkt, struct ether_hdr *);
+   RTE_VERIFY(hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_SLOW));
+
+   slow_hdr = rte_pktmbuf_mtod(lacp_pkt, struct slow_protocol_frame *);
+   RTE_VERIFY(slow_hdr->slow_protocol.subtype == SLOW_SUBTYPE_LACP);
+
+   lacpdu_rx_count[slave_id]++;
+   rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
uint8_t i;

@@ -337,9 +357,17 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, 
uint8_t start)
rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
rte_eth_promiscuous_disable(test_params.bonded_port_id);

-   if (start)
-   
TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-   "Failed to start bonded device");
+   if (external_sm) {
+   struct rte_eth_bond_8023ad_conf conf;
+
+   rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+   conf.slowrx_cb = lacp_recv_cb;
+   rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+   }
+
+   TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+   "Failed to start bonded device");

return TEST_SUCCESS;
 }
@@ -642,7 +670,7 @@ test_mode4_lacp(void)
 {
int retval;

-   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -740,7 +768,7 @@ test_mode4_rx(void)
struct ether_addr dst_mac;
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -917,7 +945,7 @@ test_mode4_tx_burst(void)
struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -1101,7 +1129,7 @@ test_mode4_marker(void)
uint8_t i, j;
const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);

-   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -1186,7 +1214,7 @@ test_mode4_expired(void)

struct rte_eth_bond_8023ad_conf conf;

-   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
0);
/* Set custom timeouts to make test last shorter. */
rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
conf.fast_periodic_ms = 100;
@@ -1268,6 +1296,156 @@ test_mode4_expired(void)
 }

 static int
+test_mode4_ext_ctrl(void)
+{
+   /*
+* configure bonded interface without the external sm enabled
+*   . try to transmit lacpdu (should fail)
+*   . try to set collecting and distributing flags (should fail)
+* reconfigure w/external sm
+*   . transmit one lacpdu on each slave using new api
+

[dpdk-dev] [PATCH v4 3/4] bond mode 4: allow external state machine

2015-05-26 Thread Eric Kinzie
From: Eric Kinzie 

  Provide functions to allow an external 802.3ad state machine to transmit
  and recieve LACPDUs and to set the collection/distribution flags on
  slave interfaces.

  Size of struct rte_eth_bond_8023ad_conf changed.  Increment LIBABIVER
  and version bond_mode_8023ad_setup and bond_mode_8023ad_conf_get
  functions.

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/Makefile  |2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  240 -
 drivers/net/bonding/rte_eth_bond_8023ad.h |   44 
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
 drivers/net/bonding/rte_eth_bond_version.map  |7 +
 5 files changed, 316 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile
index 83ccce3..d7e3f10 100644
--- a/drivers/net/bonding/Makefile
+++ b/drivers/net/bonding/Makefile
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)

 EXPORT_MAP := rte_eth_bond_version.map

-LIBABIVER := 1
+LIBABIVER := 2

 #
 # all source are stored in SRCS-y
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 1009d5b..06534ae 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -39,9 +39,12 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -998,8 +1001,8 @@ bond_mode_8023ad_mac_address_update(struct rte_eth_dev 
*bond_dev)
bond_mode_8023ad_start(bond_dev);
 }

-void
-bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
+void __vsym
+bond_mode_8023ad_conf_get_v20(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
struct bond_dev_private *internals = dev->data->dev_private;
@@ -1014,10 +1017,34 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
 }

-void
-bond_mode_8023ad_setup(struct rte_eth_dev *dev,
+VERSION_SYMBOL(bond_mode_8023ad_conf_get, _v20, 2.0);
+
+void __vsym
+bond_mode_8023ad_conf_get_v21(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;
+
+   conf->fast_periodic_ms = mode4->fast_periodic_timeout / ms_ticks;
+   conf->slow_periodic_ms = mode4->slow_periodic_timeout / ms_ticks;
+   conf->short_timeout_ms = mode4->short_timeout / ms_ticks;
+   conf->long_timeout_ms = mode4->long_timeout / ms_ticks;
+   conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
+   conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
+   conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
+}
+
+BIND_DEFAULT_SYMBOL(bond_mode_8023ad_conf_get, _v21, 2.1);
+
+void __vsym
+bond_mode_8023ad_setup_v20(struct rte_eth_dev *dev,
struct rte_eth_bond_8023ad_conf *conf)
 {
struct rte_eth_bond_8023ad_conf def_conf;
@@ -1047,6 +1074,48 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
 }

+VERSION_SYMBOL(bond_mode_8023ad_setup, _v20, 2.0);
+
+void __vsym
+bond_mode_8023ad_setup_v21(struct rte_eth_dev *dev,
+   struct rte_eth_bond_8023ad_conf *conf)
+{
+   struct rte_eth_bond_8023ad_conf def_conf;
+   struct bond_dev_private *internals = dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+   uint64_t ms_ticks = rte_get_tsc_hz() / 1000;
+
+   if (conf == NULL) {
+   conf = &def_conf;
+   conf->fast_periodic_ms = BOND_8023AD_FAST_PERIODIC_MS;
+   conf->slow_periodic_ms = BOND_8023AD_SLOW_PERIODIC_MS;
+   conf->short_timeout_ms = BOND_8023AD_SHORT_TIMEOUT_MS;
+   conf->long_timeout_ms = BOND_8023AD_LONG_TIMEOUT_MS;
+   conf->aggregate_wait_timeout_ms = 
BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS;
+   conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
+   conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
+   conf->update_timeout_ms 

[dpdk-dev] [PATCH v4 2/4] bond mode 4: do not ignore multicast

2015-05-26 Thread Eric Kinzie
From: Eric Kinzie 

The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous
mode in order to receive LACPDUs and must filter unwanted packets
after the traffic has been "collected".  Allow broadcast and multicast
through so that ARP and IPv6 neighbor discovery continue to work.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |7 +--
 drivers/net/bonding/rte_eth_bond_pmd.c |1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 460539d..d785393 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -749,8 +749,11 @@ test_mode4_rx(void)
rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
ether_addr_copy(&bonded_mac, &dst_mac);

-   /* Assert that dst address is not bonding address */
-   dst_mac.addr_bytes[0]++;
+   /* Assert that dst address is not bonding address.  Do not set the
+* least significant bit of the zero byte as this would create a
+* multicast address.
+*/
+   dst_mac.addr_bytes[0] += 2;

/* First try with promiscuous mode enabled.
 * Add 2 packets to each slave. First with bonding MAC address, second 
with
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index c937e6b..1691300 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -170,6 +170,7 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
 * mode and packet address does not match. */
if (unlikely(hdr->ether_type == ether_type_slow_be ||
!collecting || (!promisc &&
+   !is_multicast_ether_addr(&hdr->d_addr) 
&&
!is_same_ether_addr(&bond_mac, 
&hdr->d_addr {

if (hdr->ether_type == ether_type_slow_be) {
-- 
1.7.10.4



[dpdk-dev] [PATCH v4 1/4] bond mode 4: copy entire config structure

2015-05-26 Thread Eric Kinzie
From: Eric Kinzie 

  Copy all needed fields from the mode8023ad_private structure in
  bond_mode_8023ad_conf_get().  This help ensure that a subsequent call
  to rte_eth_bond_8023ad_setup() is not passed uninitialized data that
  would result in either incorrect behavior or a failed sanity check.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 97a828e..1009d5b 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1013,6 +1013,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

 void
-- 
1.7.10.4



[dpdk-dev] [PATCH v4 0/4] bonding corrections and additions

2015-05-26 Thread Eric Kinzie
This patchset makes a couple of small corrections to the bonding driver
and introduces the ability to use an external state machine for mode
4 operation.

Changes in v2:
  . eliminate external_sm field in 802.3ad configuration 
(rte_eth_bond_8023ad_conf).
  . stop bonding device before changing the periodic callback function.
start again if needed.
  . remove unnecessary calls to valid_bonded_port_id().
  . do not check for NULL tx_ring.
  . return error in rte_eth_bond_8023ad_ext_slowtx() if packet is not LACP.
  . remove check for external sm configuration in periodic callback
  . check for valid LACPDU in test application's rx callback
  . add "Fixes:" tags

Changes in v3:
  . update rte_eth_bond_version.map

Changes in v4:
  . version functions that modify slowrx_cb

Eric Kinzie (4):
  bond mode 4: copy entire config structure
  bond mode 4: do not ignore multicast
  bond mode 4: allow external state machine
  bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c|  217 ++-
 drivers/net/bonding/Makefile  |2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  241 -
 drivers/net/bonding/rte_eth_bond_8023ad.h |   44 
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   28 +++
 drivers/net/bonding/rte_eth_bond_pmd.c|1 +
 drivers/net/bonding/rte_eth_bond_version.map  |7 +
 7 files changed, 524 insertions(+), 16 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH v3 4/4] bond mode 4: tests for external state machine

2015-04-22 Thread Eric Kinzie
From: Eric Kinzie 

  This adds test cases for exercising the external state machine API to
  the mode 4 autotest.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |  210 ++--
 1 file changed, 201 insertions(+), 9 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 5a726af..c191ac5 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -155,6 +155,8 @@ static struct rte_eth_conf default_pmd_conf = {
.lpbk_mode = 0,
 };

+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); 
_i++)

@@ -324,8 +326,26 @@ remove_slave(struct slave_conf *slave)
return 0;
 }

+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+   struct ether_hdr *hdr;
+   struct slow_protocol_frame *slow_hdr;
+
+   RTE_VERIFY(lacp_pkt != NULL);
+
+   hdr = rte_pktmbuf_mtod(lacp_pkt, struct ether_hdr *);
+   RTE_VERIFY(hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_SLOW));
+
+   slow_hdr = rte_pktmbuf_mtod(lacp_pkt, struct slow_protocol_frame *);
+   RTE_VERIFY(slow_hdr->slow_protocol.subtype == SLOW_SUBTYPE_LACP);
+
+   lacpdu_rx_count[slave_id]++;
+   rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
uint8_t i;

@@ -341,9 +361,17 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, 
uint8_t start)
rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
rte_eth_promiscuous_disable(test_params.bonded_port_id);

-   if (start)
-   
TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-   "Failed to start bonded device");
+   if (external_sm) {
+   struct rte_eth_bond_8023ad_conf conf;
+
+   rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+   conf.slowrx_cb = lacp_recv_cb;
+   rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+   }
+
+   TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+   "Failed to start bonded device");

return TEST_SUCCESS;
 }
@@ -648,7 +676,7 @@ test_mode4_lacp(void)
 {
int retval;

-   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -746,7 +774,7 @@ test_mode4_rx(void)
struct ether_addr dst_mac;
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -923,7 +951,7 @@ test_mode4_tx_burst(void)
struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -1107,7 +1135,7 @@ test_mode4_marker(void)
uint8_t i, j;
const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);

-   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -1192,7 +1220,7 @@ test_mode4_expired(void)

struct rte_eth_bond_8023ad_conf conf;

-   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
0);
/* Set custom timeouts to make test last shorter. */
rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
conf.fast_periodic_ms = 100;
@@ -1274,6 +1302,156 @@ test_mode4_expired(void)
 }

 static int
+test_mode4_ext_ctrl(void)
+{
+   /*
+* configure bonded interface without the external sm enabled
+*   . try to transmit lacpdu (should fail)
+*   . try to set collecting and distributing flags (should fail)
+* reconfigure w/external sm
+*   . transmit one lacpdu on each slave using new api
+

[dpdk-dev] [PATCH v3 3/4] bond mode 4: allow external state machine

2015-04-22 Thread Eric Kinzie
From: Eric Kinzie 

  Provide functions to allow an external 802.3ad state machine to transmit
  and recieve LACPDUs and to set the collection/distribution flags on
  slave interfaces.

Signed-off-by: Eric Kinzie 
---
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |  173 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad.h |   44 ++
 lib/librte_pmd_bond/rte_eth_bond_8023ad_private.h |2 +
 lib/librte_pmd_bond/rte_eth_bond_version.map  |3 +
 4 files changed, 222 insertions(+)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c 
b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
index 1009d5b..326e899 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
@@ -42,6 +42,8 @@

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -1014,6 +1016,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
 }

 void
@@ -1035,8 +1038,11 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
+   conf->slowrx_cb = NULL;
}

+   bond_mode_8023ad_stop(dev);
+
mode4->fast_periodic_timeout = conf->fast_periodic_ms * ms_ticks;
mode4->slow_periodic_timeout = conf->slow_periodic_ms * ms_ticks;
mode4->short_timeout = conf->short_timeout_ms * ms_ticks;
@@ -1045,6 +1051,10 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->tx_period_timeout = conf->tx_period_ms * ms_ticks;
mode4->rx_marker_timeout = conf->rx_marker_period_ms * ms_ticks;
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
+   mode4->slowrx_cb = conf->slowrx_cb;
+
+   if (dev->data->dev_started)
+   bond_mode_8023ad_start(dev);
 }

 int
@@ -1062,6 +1072,13 @@ bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev)
 int
 bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
 {
+   struct bond_dev_private *internals = bond_dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (mode4->slowrx_cb)
+   return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 
1000,
+   &bond_mode_8023ad_ext_periodic_cb, bond_dev);
+
return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 1000,
&bond_mode_8023ad_periodic_cb, bond_dev);
 }
@@ -1069,6 +1086,13 @@ bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
 void
 bond_mode_8023ad_stop(struct rte_eth_dev *bond_dev)
 {
+   struct bond_dev_private *internals = bond_dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (mode4->slowrx_cb) {
+   rte_eal_alarm_cancel(&bond_mode_8023ad_ext_periodic_cb, 
bond_dev);
+   return;
+   }
rte_eal_alarm_cancel(&bond_mode_8023ad_periodic_cb, bond_dev);
 }

@@ -1215,3 +1239,152 @@ rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t 
slave_id,
info->agg_port_id = port->aggregator_port_id;
return 0;
 }
+
+int
+rte_eth_bond_8023ad_ext_collect(uint8_t port_id, uint8_t slave_id, int enabled)
+{
+   struct rte_eth_dev *bond_dev;
+   struct bond_dev_private *internals;
+   struct mode8023ad_private *mode4;
+   struct port *port;
+
+   if (rte_eth_bond_mode_get(port_id) != BONDING_MODE_8023AD)
+   return -EINVAL;
+
+   bond_dev = &rte_eth_devices[port_id];
+
+   if (!bond_dev->data->dev_started)
+   return -EINVAL;
+
+   internals = bond_dev->data->dev_private;
+   if (find_slave_by_id(internals->active_slaves,
+   internals->active_slave_count, slave_id) ==
+   internals->active_slave_count)
+   return -EINVAL;
+
+   mode4 = &internals->mode4;
+   if (mode4->slowrx_cb == NULL)
+   return -EINVAL;
+
+   port = &mode_8023ad_ports[slave_id];
+
+   if (enabled)
+   ACTOR_STATE_SET(port, COLLECTING);
+   else
+   ACTOR_STATE_CLR(port, COLLECTING);
+
+   return 0;
+}
+
+int
+rte_eth_bond_8023ad_ext_distrib(uint8_t port_id, uint8_t slave_id, int e

[dpdk-dev] [PATCH v3 2/4] bond mode 4: do not ignore multicast

2015-04-22 Thread Eric Kinzie
From: Eric Kinzie 

The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous
mode in order to receive LACPDUs and must filter unwanted packets
after the traffic has been "collected".  Allow broadcast and multicast
through so that ARP and IPv6 neighbor discovery continue to work.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |7 +--
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 02380f9..5a726af 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -755,8 +755,11 @@ test_mode4_rx(void)
rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
ether_addr_copy(&bonded_mac, &dst_mac);

-   /* Assert that dst address is not bonding address */
-   dst_mac.addr_bytes[0]++;
+   /* Assert that dst address is not bonding address.  Do not set the
+* least significant bit of the zero byte as this would create a
+* multicast address.
+*/
+   dst_mac.addr_bytes[0] += 2;

/* First try with promiscuous mode enabled.
 * Add 2 packets to each slave. First with bonding MAC address, second 
with
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index c937e6b..1691300 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -170,6 +170,7 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
 * mode and packet address does not match. */
if (unlikely(hdr->ether_type == ether_type_slow_be ||
!collecting || (!promisc &&
+   !is_multicast_ether_addr(&hdr->d_addr) 
&&
!is_same_ether_addr(&bond_mac, 
&hdr->d_addr {

if (hdr->ether_type == ether_type_slow_be) {
-- 
1.7.10.4



[dpdk-dev] [PATCH v3 1/4] bond mode 4: copy entire config structure

2015-04-22 Thread Eric Kinzie
From: Eric Kinzie 

  Copy all needed fields from the mode8023ad_private structure in
  bond_mode_8023ad_conf_get().  This help ensure that a subsequent call
  to rte_eth_bond_8023ad_setup() is not passed uninitialized data that
  would result in either incorrect behavior or a failed sanity check.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c 
b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
index 97a828e..1009d5b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
@@ -1013,6 +1013,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

 void
-- 
1.7.10.4



[dpdk-dev] [PATCH v3 0/4] bonding corrections and additions

2015-04-22 Thread Eric Kinzie
This patchset makes a couple of small corrections to the bonding driver
and introduces the ability to use an external state machine for mode
4 operation.

Changes in v2:
  . eliminate external_sm field in 802.3ad configuration 
(rte_eth_bond_8023ad_conf).
  . stop bonding device before changing the periodic callback function.
start again if needed.
  . remove unnecessary calls to valid_bonded_port_id().
  . do not check for NULL tx_ring.
  . return error in rte_eth_bond_8023ad_ext_slowtx() if packet is not LACP.
  . remove check for external sm configuration in periodic callback
  . check for valid LACPDU in test application's rx callback
  . add "Fixes:" tags

Changes in v3:
  . update rte_eth_bond_version.map

Eric Kinzie (4):
  bond mode 4: copy entire config structure
  bond mode 4: do not ignore multicast
  bond mode 4: allow external state machine
  bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c|  217 +++--
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |  174 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad.h |   44 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad_private.h |2 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c|1 +
 lib/librte_pmd_bond/rte_eth_bond_version.map  |3 +
 6 files changed, 430 insertions(+), 11 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH v2 4/4] bond mode 4: tests for external state machine

2015-04-20 Thread Eric Kinzie
From: Eric Kinzie 

  This adds test cases for exercising the external state machine API to
  the mode 4 autotest.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |  210 ++--
 1 file changed, 201 insertions(+), 9 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 5a726af..c191ac5 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -155,6 +155,8 @@ static struct rte_eth_conf default_pmd_conf = {
.lpbk_mode = 0,
 };

+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); 
_i++)

@@ -324,8 +326,26 @@ remove_slave(struct slave_conf *slave)
return 0;
 }

+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+   struct ether_hdr *hdr;
+   struct slow_protocol_frame *slow_hdr;
+
+   RTE_VERIFY(lacp_pkt != NULL);
+
+   hdr = rte_pktmbuf_mtod(lacp_pkt, struct ether_hdr *);
+   RTE_VERIFY(hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_SLOW));
+
+   slow_hdr = rte_pktmbuf_mtod(lacp_pkt, struct slow_protocol_frame *);
+   RTE_VERIFY(slow_hdr->slow_protocol.subtype == SLOW_SUBTYPE_LACP);
+
+   lacpdu_rx_count[slave_id]++;
+   rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
uint8_t i;

@@ -341,9 +361,17 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, 
uint8_t start)
rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
rte_eth_promiscuous_disable(test_params.bonded_port_id);

-   if (start)
-   
TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-   "Failed to start bonded device");
+   if (external_sm) {
+   struct rte_eth_bond_8023ad_conf conf;
+
+   rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+   conf.slowrx_cb = lacp_recv_cb;
+   rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+   }
+
+   TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+   "Failed to start bonded device");

return TEST_SUCCESS;
 }
@@ -648,7 +676,7 @@ test_mode4_lacp(void)
 {
int retval;

-   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -746,7 +774,7 @@ test_mode4_rx(void)
struct ether_addr dst_mac;
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -923,7 +951,7 @@ test_mode4_tx_burst(void)
struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -1107,7 +1135,7 @@ test_mode4_marker(void)
uint8_t i, j;
const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);

-   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -1192,7 +1220,7 @@ test_mode4_expired(void)

struct rte_eth_bond_8023ad_conf conf;

-   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
0);
/* Set custom timeouts to make test last shorter. */
rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
conf.fast_periodic_ms = 100;
@@ -1274,6 +1302,156 @@ test_mode4_expired(void)
 }

 static int
+test_mode4_ext_ctrl(void)
+{
+   /*
+* configure bonded interface without the external sm enabled
+*   . try to transmit lacpdu (should fail)
+*   . try to set collecting and distributing flags (should fail)
+* reconfigure w/external sm
+*   . transmit one lacpdu on each slave using new api
+

[dpdk-dev] [PATCH v2 3/4] bond mode 4: allow external state machine

2015-04-20 Thread Eric Kinzie
From: Eric Kinzie 

  Provide functions to allow an external 802.3ad state machine to transmit
  and recieve LACPDUs and to set the collection/distribution flags on
  slave interfaces.

Signed-off-by: Eric Kinzie 
---
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |  173 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad.h |   44 ++
 lib/librte_pmd_bond/rte_eth_bond_8023ad_private.h |2 +
 3 files changed, 219 insertions(+)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c 
b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
index 1009d5b..326e899 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
@@ -42,6 +42,8 @@

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -1014,6 +1016,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
 }

 void
@@ -1035,8 +1038,11 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
+   conf->slowrx_cb = NULL;
}

+   bond_mode_8023ad_stop(dev);
+
mode4->fast_periodic_timeout = conf->fast_periodic_ms * ms_ticks;
mode4->slow_periodic_timeout = conf->slow_periodic_ms * ms_ticks;
mode4->short_timeout = conf->short_timeout_ms * ms_ticks;
@@ -1045,6 +1051,10 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->tx_period_timeout = conf->tx_period_ms * ms_ticks;
mode4->rx_marker_timeout = conf->rx_marker_period_ms * ms_ticks;
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
+   mode4->slowrx_cb = conf->slowrx_cb;
+
+   if (dev->data->dev_started)
+   bond_mode_8023ad_start(dev);
 }

 int
@@ -1062,6 +1072,13 @@ bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev)
 int
 bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
 {
+   struct bond_dev_private *internals = bond_dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (mode4->slowrx_cb)
+   return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 
1000,
+   &bond_mode_8023ad_ext_periodic_cb, bond_dev);
+
return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 1000,
&bond_mode_8023ad_periodic_cb, bond_dev);
 }
@@ -1069,6 +1086,13 @@ bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
 void
 bond_mode_8023ad_stop(struct rte_eth_dev *bond_dev)
 {
+   struct bond_dev_private *internals = bond_dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (mode4->slowrx_cb) {
+   rte_eal_alarm_cancel(&bond_mode_8023ad_ext_periodic_cb, 
bond_dev);
+   return;
+   }
rte_eal_alarm_cancel(&bond_mode_8023ad_periodic_cb, bond_dev);
 }

@@ -1215,3 +1239,152 @@ rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t 
slave_id,
info->agg_port_id = port->aggregator_port_id;
return 0;
 }
+
+int
+rte_eth_bond_8023ad_ext_collect(uint8_t port_id, uint8_t slave_id, int enabled)
+{
+   struct rte_eth_dev *bond_dev;
+   struct bond_dev_private *internals;
+   struct mode8023ad_private *mode4;
+   struct port *port;
+
+   if (rte_eth_bond_mode_get(port_id) != BONDING_MODE_8023AD)
+   return -EINVAL;
+
+   bond_dev = &rte_eth_devices[port_id];
+
+   if (!bond_dev->data->dev_started)
+   return -EINVAL;
+
+   internals = bond_dev->data->dev_private;
+   if (find_slave_by_id(internals->active_slaves,
+   internals->active_slave_count, slave_id) ==
+   internals->active_slave_count)
+   return -EINVAL;
+
+   mode4 = &internals->mode4;
+   if (mode4->slowrx_cb == NULL)
+   return -EINVAL;
+
+   port = &mode_8023ad_ports[slave_id];
+
+   if (enabled)
+   ACTOR_STATE_SET(port, COLLECTING);
+   else
+   ACTOR_STATE_CLR(port, COLLECTING);
+
+   return 0;
+}
+
+int
+rte_eth_bond_8023ad_ext_distrib(uint8_t port_id, uint8_t slave_id, int enabled)
+{
+   struct rte_eth_dev *bond_dev;
+   struct 

[dpdk-dev] [PATCH v2 2/4] bond mode 4: do not ignore multicast

2015-04-20 Thread Eric Kinzie
From: Eric Kinzie 

The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous
mode in order to receive LACPDUs and must filter unwanted packets
after the traffic has been "collected".  Allow broadcast and multicast
through so that ARP and IPv6 neighbor discovery continue to work.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |7 +--
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 02380f9..5a726af 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -755,8 +755,11 @@ test_mode4_rx(void)
rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
ether_addr_copy(&bonded_mac, &dst_mac);

-   /* Assert that dst address is not bonding address */
-   dst_mac.addr_bytes[0]++;
+   /* Assert that dst address is not bonding address.  Do not set the
+* least significant bit of the zero byte as this would create a
+* multicast address.
+*/
+   dst_mac.addr_bytes[0] += 2;

/* First try with promiscuous mode enabled.
 * Add 2 packets to each slave. First with bonding MAC address, second 
with
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index c937e6b..1691300 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -170,6 +170,7 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
 * mode and packet address does not match. */
if (unlikely(hdr->ether_type == ether_type_slow_be ||
!collecting || (!promisc &&
+   !is_multicast_ether_addr(&hdr->d_addr) 
&&
!is_same_ether_addr(&bond_mac, 
&hdr->d_addr {

if (hdr->ether_type == ether_type_slow_be) {
-- 
1.7.10.4



[dpdk-dev] [PATCH v2 1/4] bond mode 4: copy entire config structure

2015-04-20 Thread Eric Kinzie
From: Eric Kinzie 

  Copy all needed fields from the mode8023ad_private structure in
  bond_mode_8023ad_conf_get().  This help ensure that a subsequent call
  to rte_eth_bond_8023ad_setup() is not passed uninitialized data that
  would result in either incorrect behavior or a failed sanity check.

Fixes: 46fb43683679 ("bond: add mode 4")

Signed-off-by: Eric Kinzie 
---
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c 
b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
index 97a828e..1009d5b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
@@ -1013,6 +1013,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

 void
-- 
1.7.10.4



[dpdk-dev] [PATCH v2 0/4] bonding corrections and additions

2015-04-20 Thread Eric Kinzie
This patchset makes a couple of small corrections to the bonding driver
and introduces the ability to use an external state machine for mode
4 operation.

Changes in v2:
  . eliminate external_sm field in 802.3ad configuration 
(rte_eth_bond_8023ad_conf).
  . stop bonding device before changing the periodic callback function.
start again if needed.
  . remove unnecessary calls to valid_bonded_port_id().
  . do not check for NULL tx_ring.
  . return error in rte_eth_bond_8023ad_ext_slowtx() if packet is not LACP.
  . remove check for external sm configuration in periodic callback
  . check for valid LACPDU in test application's rx callback
  . add "Fixes:" tags

Eric Kinzie (4):
  bond mode 4: copy entire config structure
  bond mode 4: do not ignore multicast
  bond mode 4: allow external state machine
  bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c|  217 +++--
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |  174 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad.h |   44 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad_private.h |2 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c|1 +
 5 files changed, 427 insertions(+), 11 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH 1/5] bond: use existing enslaved device queues

2015-04-14 Thread Eric Kinzie
On Fri Apr 10 09:40:09 +0200 2015, Pawel Wodkowski wrote:
> On 2015-04-06 19:01, Eric Kinzie wrote:
> >If a device to be enslaved already has transmit and/or receive queues
> >allocated, use those and then create any additional queues that are
> >necessary.
> >
> >Signed-off-by: Eric Kinzie 
> >---
> >  lib/librte_pmd_bond/rte_eth_bond_pmd.c |8 ++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> >diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
> >b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> >index c937e6b..4fd7d97 100644
> >--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> >+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> >@@ -1318,7 +1318,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
> > }
> >
> > /* Setup Rx Queues */
> >-for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
> >+/* Use existing queues, if any */
> >+for (q_id = slave_eth_dev->data->nb_rx_queues;
> >+ q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
> > bd_rx_q = (struct bond_rx_queue 
> > *)bonded_eth_dev->data->rx_queues[q_id];
> >
> > errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, 
> > q_id,
> >@@ -1334,7 +1336,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
> > }
> >
> > /* Setup Tx Queues */
> >-for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
> >+/* Use existing queues, if any */
> >+for (q_id = slave_eth_dev->data->nb_tx_queues;
> >+ q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
> > bd_tx_q = (struct bond_tx_queue 
> > *)bonded_eth_dev->data->tx_queues[q_id];
> >
> > errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, 
> > q_id,
> >
> 
> Why you want to do that?
> 
> As far as I am aware (but Declan Doherty should speak here to) purpose
> of this part of code is to have configuration of queues in slaves
> consistent with bd_rx_q/bd_tx_q. If you skip reconfiguration of queues
> that are already configured in port you can have them configured
> in different way after enslaving.
> 
> So again: what is the purpose of doing so?
> 
> -- 
> Pawel

Pawel,

I generally test things I've just built using virtio devices and calling
rte_eth_tx_queue_setup() more than once for a given queue id fails.
However, it seems that most PMDs allow re-allocating device queues while
virtio does not (xenvirt also seems to lack this functionality), so I
don't think my approach here is right.  I'll remove this patch when I
send the next version of this series.

Thanks,

Eric



[dpdk-dev] [PATCH 4/5] bond mode 4: allow external state machine

2015-04-07 Thread Eric Kinzie
On Tue Apr 07 16:18:08 +0200 2015, Pawel Wodkowski wrote:
> On 2015-04-06 19:01, Eric Kinzie wrote:
> 
> Interesting patch. I will closer look at this tomorrow.
> 
> For now I have first comments:
> 
> >+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
> >+
> >  #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
> >  #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " 
> > fmt, \
> > bond_dbg_get_time_diff_ms(), slave_id, \
> >@@ -1014,6 +1016,8 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
> > conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
> > conf->update_timeout_ms = mode4->update_timeout_us / 1000;
> > conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
> >+conf->slowrx_cb = mode4->slowrx_cb;
> >+conf->external_sm = mode4->external_sm;
> 
> mode4->external_sm flag realy needed? Why do not use
> mode4->slowrx_cb as external state machine indicator?

I'll remove the external_sm flag.  You're correct, it's not needed.


> >  }
> >
> >  void
> >@@ -1035,6 +1039,8 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
> > conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
> > conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
> > conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
> >+conf->slowrx_cb = NULL;
> >+conf->external_sm = 0;
> > }
> >
> > mode4->fast_periodic_timeout = conf->fast_periodic_ms * ms_ticks;
> >@@ -1045,6 +1051,8 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
> > mode4->tx_period_timeout = conf->tx_period_ms * ms_ticks;
> > mode4->rx_marker_timeout = conf->rx_marker_period_ms * ms_ticks;
> > mode4->update_timeout_us = conf->update_timeout_ms * 1000;
> >+mode4->slowrx_cb = conf->slowrx_cb;
> >+mode4->external_sm = conf->external_sm;
> >  }
> >
> >  int
> >@@ -1062,6 +1070,13 @@ bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev)
> >  int
> >  bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
> >  {
> >+struct bond_dev_private *internals = bond_dev->data->dev_private;
> >+struct mode8023ad_private *mode4 = &internals->mode4;
> >+
> >+if (mode4->external_sm)
> >+return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 
> >1000,
> >+&bond_mode_8023ad_ext_periodic_cb, bond_dev);
> >+
> > return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 1000,
> > &bond_mode_8023ad_periodic_cb, bond_dev);
> >  }
> >@@ -1069,6 +1084,13 @@ bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
> >  void
> >  bond_mode_8023ad_stop(struct rte_eth_dev *bond_dev)
> >  {
> >+struct bond_dev_private *internals = bond_dev->data->dev_private;
> >+struct mode8023ad_private *mode4 = &internals->mode4;
> >+
> >+if (mode4->external_sm) {
> 
> This is bad idea. If bond_mode_8023ad_setup will be called you might
> have two handlers running for while. You should stop mode 4 by
> invoking bond_mode_8023ad_stop() before you set mode4->external_sm
> and then, if mode 4 was running, start it again.

Thanks, I'll make that change.



> Also, maybe a renaming "external_sm" to "state_machine_cb", set it
> to against default one and using it without "if()" will simplify
> code. It is no crucial but will eliminate couple of if's. In
> rte_eth_bond_8023ad_ext_slowtx() you can compare it against default
> one.
> 
> >+rte_eal_alarm_cancel(&bond_mode_8023ad_ext_periodic_cb, 
> >bond_dev);
> >+return;
> >+}
> > rte_eal_alarm_cancel(&bond_mode_8023ad_periodic_cb, bond_dev);
> >  }
> >
> >@@ -1215,3 +1237,156 @@ rte_eth_bond_8023ad_slave_info(uint8_t port_id, 
> >uint8_t slave_id,
> > info->agg_port_id = port->aggregator_port_id;
> > return 0;
> >  }
> 
> -- 
> Pawel


[dpdk-dev] [PATCH 5/5] bond mode 4: tests for external state machine

2015-04-06 Thread Eric Kinzie
  This adds test cases for exercising the external state machine API to
  the mode 4 autotest.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |  201 ++--
 1 file changed, 192 insertions(+), 9 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 5a726af..a37b59c 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -155,6 +155,8 @@ static struct rte_eth_conf default_pmd_conf = {
.lpbk_mode = 0,
 };

+static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };
+
 #define FOR_EACH(_i, _item, _array, _size) \
for (_i = 0, _item = &_array[0]; _i < _size && (_item = &_array[_i]); 
_i++)

@@ -324,8 +326,16 @@ remove_slave(struct slave_conf *slave)
return 0;
 }

+static void
+lacp_recv_cb(uint8_t slave_id, struct rte_mbuf *lacp_pkt)
+{
+   lacpdu_rx_count[slave_id]++;
+   RTE_VERIFY(lacp_pkt != NULL);
+   rte_pktmbuf_free(lacp_pkt);
+}
+
 static int
-initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t start)
+initialize_bonded_device_with_slaves(uint8_t slave_count, uint8_t external_sm)
 {
uint8_t i;

@@ -341,9 +351,18 @@ initialize_bonded_device_with_slaves(uint8_t slave_count, 
uint8_t start)
rte_eth_bond_8023ad_setup(test_params.bonded_port_id, NULL);
rte_eth_promiscuous_disable(test_params.bonded_port_id);

-   if (start)
-   
TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
-   "Failed to start bonded device");
+   if (external_sm) {
+   struct rte_eth_bond_8023ad_conf conf;
+
+   rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
+   conf.external_sm = 1;
+   conf.slowrx_cb = lacp_recv_cb;
+   rte_eth_bond_8023ad_setup(test_params.bonded_port_id, &conf);
+
+   }
+
+   TEST_ASSERT_SUCCESS(rte_eth_dev_start(test_params.bonded_port_id),
+   "Failed to start bonded device");

return TEST_SUCCESS;
 }
@@ -648,7 +667,7 @@ test_mode4_lacp(void)
 {
int retval;

-   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_LACP_SLAVE_COUT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -746,7 +765,7 @@ test_mode4_rx(void)
struct ether_addr dst_mac;
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_PROMISC_SLAVE_COUNT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -923,7 +942,7 @@ test_mode4_tx_burst(void)
struct ether_addr dst_mac = { { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00 } };
struct ether_addr bonded_mac;

-   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 1);
+   retval = initialize_bonded_device_with_slaves(TEST_TX_SLAVE_COUNT, 0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

retval = bond_handshake();
@@ -1107,7 +1126,7 @@ test_mode4_marker(void)
uint8_t i, j;
const uint16_t ethtype_slow_be = rte_be_to_cpu_16(ETHER_TYPE_SLOW);

-   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_MARKER_SLAVE_COUT, 
0);
TEST_ASSERT_SUCCESS(retval, "Failed to initialize bonded device");

/* Test LACP handshake function */
@@ -1192,7 +1211,7 @@ test_mode4_expired(void)

struct rte_eth_bond_8023ad_conf conf;

-   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
1);
+   retval = initialize_bonded_device_with_slaves(TEST_EXPIRED_SLAVE_COUNT, 
0);
/* Set custom timeouts to make test last shorter. */
rte_eth_bond_8023ad_conf_get(test_params.bonded_port_id, &conf);
conf.fast_periodic_ms = 100;
@@ -1274,6 +1293,156 @@ test_mode4_expired(void)
 }

 static int
+test_mode4_ext_ctrl(void)
+{
+   /*
+* configure bonded interface without the external sm enabled
+*   . try to transmit lacpdu (should fail)
+*   . try to set collecting and distributing flags (should fail)
+* reconfigure w/external sm
+*   . transmit one lacpdu on each slave using new api
+*   . make sure each slave receives one lacpdu using the callback api
+*   . transmit one data pdu on each slave (should fail)
+*   . enable distribution and collection, send one data pdu each again
+*/
+
+   int retval;
+   struct slave_conf *slave = NULL;
+   uint8_t i;
+
+   struct rte_mbuf *lacp_tx_buf[SL

[dpdk-dev] [PATCH 4/5] bond mode 4: allow external state machine

2015-04-06 Thread Eric Kinzie
  Provide functions to allow an external 802.3ad state machine to transmit
  and recieve LACPDUs and to set the collection/distribution flags on
  slave interfaces.

Signed-off-by: Eric Kinzie 
---
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |  175 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad.h |   44 ++
 lib/librte_pmd_bond/rte_eth_bond_8023ad_private.h |2 +
 3 files changed, 221 insertions(+)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c 
b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
index 1009d5b..29cd962 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
@@ -42,6 +42,8 @@

 #include "rte_eth_bond_private.h"

+static void bond_mode_8023ad_ext_periodic_cb(void *arg);
+
 #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD
 #define MODE4_DEBUG(fmt, ...) RTE_LOG(DEBUG, PMD, "%6u [Port %u: %s] " fmt, \
bond_dbg_get_time_diff_ms(), slave_id, \
@@ -1014,6 +1016,8 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
+   conf->slowrx_cb = mode4->slowrx_cb;
+   conf->external_sm = mode4->external_sm;
 }

 void
@@ -1035,6 +1039,8 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
conf->tx_period_ms = BOND_8023AD_TX_MACHINE_PERIOD_MS;
conf->rx_marker_period_ms = BOND_8023AD_RX_MARKER_PERIOD_MS;
conf->update_timeout_ms = BOND_MODE_8023AX_UPDATE_TIMEOUT_MS;
+   conf->slowrx_cb = NULL;
+   conf->external_sm = 0;
}

mode4->fast_periodic_timeout = conf->fast_periodic_ms * ms_ticks;
@@ -1045,6 +1051,8 @@ bond_mode_8023ad_setup(struct rte_eth_dev *dev,
mode4->tx_period_timeout = conf->tx_period_ms * ms_ticks;
mode4->rx_marker_timeout = conf->rx_marker_period_ms * ms_ticks;
mode4->update_timeout_us = conf->update_timeout_ms * 1000;
+   mode4->slowrx_cb = conf->slowrx_cb;
+   mode4->external_sm = conf->external_sm;
 }

 int
@@ -1062,6 +1070,13 @@ bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev)
 int
 bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
 {
+   struct bond_dev_private *internals = bond_dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (mode4->external_sm)
+   return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 
1000,
+   &bond_mode_8023ad_ext_periodic_cb, bond_dev);
+
return rte_eal_alarm_set(BOND_MODE_8023AX_UPDATE_TIMEOUT_MS * 1000,
&bond_mode_8023ad_periodic_cb, bond_dev);
 }
@@ -1069,6 +1084,13 @@ bond_mode_8023ad_start(struct rte_eth_dev *bond_dev)
 void
 bond_mode_8023ad_stop(struct rte_eth_dev *bond_dev)
 {
+   struct bond_dev_private *internals = bond_dev->data->dev_private;
+   struct mode8023ad_private *mode4 = &internals->mode4;
+
+   if (mode4->external_sm) {
+   rte_eal_alarm_cancel(&bond_mode_8023ad_ext_periodic_cb, 
bond_dev);
+   return;
+   }
rte_eal_alarm_cancel(&bond_mode_8023ad_periodic_cb, bond_dev);
 }

@@ -1215,3 +1237,156 @@ rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t 
slave_id,
info->agg_port_id = port->aggregator_port_id;
return 0;
 }
+
+int
+rte_eth_bond_8023ad_ext_collect(uint8_t port_id, uint8_t slave_id, int enabled)
+{
+   struct rte_eth_dev *bond_dev;
+   struct bond_dev_private *internals;
+   struct mode8023ad_private *mode4;
+   struct port *port;
+
+   if (valid_bonded_port_id(port_id) != 0 ||
+   rte_eth_bond_mode_get(port_id) != BONDING_MODE_8023AD)
+   return -EINVAL;
+
+   bond_dev = &rte_eth_devices[port_id];
+
+   internals = bond_dev->data->dev_private;
+   if (find_slave_by_id(internals->active_slaves,
+   internals->active_slave_count, slave_id) ==
+   internals->active_slave_count)
+   return -EINVAL;
+
+   mode4 = &internals->mode4;
+   if (mode4->slowrx_cb == NULL || !mode4->external_sm)
+   return -EINVAL;
+
+   port = &mode_8023ad_ports[slave_id];
+
+   if (enabled)
+   ACTOR_STATE_SET(port, COLLECTING);
+   else
+   ACTOR_STATE_CLR(port, COLLECTING);
+
+   return 0;
+}
+
+int
+rte_eth_bond_8023ad_ext_distrib(uint8_t port_id, uint8_t slave_id, int enabled)
+{
+   struct rte_eth_dev *bond_dev;
+   struct bond_dev_private *internals;
+   struct mode8023ad_private *mode4;
+   struct port *port;
+
+   if (valid_bonded_port_id(port

[dpdk-dev] [PATCH 3/5] bond mode 4: do not ignore multicast

2015-04-06 Thread Eric Kinzie
The bonding PMD in mode 4 puts all enslaved interfaces into promiscuous
mode in order to receive LACPDUs and must filter unwanted packets
after the traffic has been "collected".  Allow broadcast and multicast
through so that ARP and IPv6 neighbor discovery continue to work.

Signed-off-by: Eric Kinzie 
---
 app/test/test_link_bonding_mode4.c |7 +--
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/app/test/test_link_bonding_mode4.c 
b/app/test/test_link_bonding_mode4.c
index 02380f9..5a726af 100644
--- a/app/test/test_link_bonding_mode4.c
+++ b/app/test/test_link_bonding_mode4.c
@@ -755,8 +755,11 @@ test_mode4_rx(void)
rte_eth_macaddr_get(test_params.bonded_port_id, &bonded_mac);
ether_addr_copy(&bonded_mac, &dst_mac);

-   /* Assert that dst address is not bonding address */
-   dst_mac.addr_bytes[0]++;
+   /* Assert that dst address is not bonding address.  Do not set the
+* least significant bit of the zero byte as this would create a
+* multicast address.
+*/
+   dst_mac.addr_bytes[0] += 2;

/* First try with promiscuous mode enabled.
 * Add 2 packets to each slave. First with bonding MAC address, second 
with
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 4fd7d97..8631e12 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -170,7 +170,8 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
 * mode and packet address does not match. */
if (unlikely(hdr->ether_type == ether_type_slow_be ||
!collecting || (!promisc &&
-   !is_same_ether_addr(&bond_mac, 
&hdr->d_addr {
+   (!is_multicast_ether_addr(&hdr->d_addr) 
&&
+!is_same_ether_addr(&bond_mac, 
&hdr->d_addr) {

if (hdr->ether_type == ether_type_slow_be) {

bond_mode_8023ad_handle_slow_pkt(internals, slaves[i],
-- 
1.7.10.4



[dpdk-dev] [PATCH 2/5] bond mode 4: copy entire config structure

2015-04-06 Thread Eric Kinzie
  Copy all needed fields from the mode8023ad_private structure in
  bond_mode_8023ad_conf_get().

Signed-off-by: Eric Kinzie 
---
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c 
b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
index 97a828e..1009d5b 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_8023ad.c
@@ -1013,6 +1013,7 @@ bond_mode_8023ad_conf_get(struct rte_eth_dev *dev,
conf->aggregate_wait_timeout_ms = mode4->aggregate_wait_timeout / 
ms_ticks;
conf->tx_period_ms = mode4->tx_period_timeout / ms_ticks;
conf->update_timeout_ms = mode4->update_timeout_us / 1000;
+   conf->rx_marker_period_ms = mode4->rx_marker_timeout / ms_ticks;
 }

 void
-- 
1.7.10.4



[dpdk-dev] [PATCH 1/5] bond: use existing enslaved device queues

2015-04-06 Thread Eric Kinzie
If a device to be enslaved already has transmit and/or receive queues
allocated, use those and then create any additional queues that are
necessary.

Signed-off-by: Eric Kinzie 
---
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c 
b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index c937e6b..4fd7d97 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -1318,7 +1318,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
}

/* Setup Rx Queues */
-   for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
+   /* Use existing queues, if any */
+   for (q_id = slave_eth_dev->data->nb_rx_queues;
+q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
bd_rx_q = (struct bond_rx_queue 
*)bonded_eth_dev->data->rx_queues[q_id];

errval = rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, 
q_id,
@@ -1334,7 +1336,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
}

/* Setup Tx Queues */
-   for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
+   /* Use existing queues, if any */
+   for (q_id = slave_eth_dev->data->nb_tx_queues;
+q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
bd_tx_q = (struct bond_tx_queue 
*)bonded_eth_dev->data->tx_queues[q_id];

errval = rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, 
q_id,
-- 
1.7.10.4



[dpdk-dev] [PATCH 0/5] bonding corrections and additions

2015-04-06 Thread Eric Kinzie
This patchset makes a couple of small corrections to the bonding driver
and introduces the ability to use an external state machine for mode
4 operation.

Eric Kinzie (5):
  bond: use existing enslaved device queues
  bond mode 4: copy entire config structure
  bond mode 4: do not ignore multicast
  bond mode 4: allow external state machine
  bond mode 4: tests for external state machine

 app/test/test_link_bonding_mode4.c|  208 +++--
 lib/librte_pmd_bond/rte_eth_bond_8023ad.c |  176 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad.h |   44 +
 lib/librte_pmd_bond/rte_eth_bond_8023ad_private.h |2 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c|   11 +-
 5 files changed, 427 insertions(+), 14 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH v2 1/4] Link Bonding Library

2014-06-09 Thread Eric Kinzie
On Wed Jun 04 16:18:53 +0100 2014, Declan Doherty wrote:
> - Broadcast TX burst broadcast bug fix
> - Add/remove slave behavior fix
> - Checkpatch fixes

Declan, would you consider the following change to rte_bond.c?  The two
header files from librte_cmdline don't seem to be necessary.

 Eric


--- a/lib/librte_bond/rte_bond.c
+++ b/lib/librte_bond/rte_bond.c
@@ -44,9 +44,6 @@
 #include 
 #include 

-#include 
-#include 
-
 #include "rte_bond.h"

 static const char *driver_name = "Link Bonding PMD";