net/mlx5: fix return value of start operation
[dpdk.git] / drivers / net / bonding / rte_eth_bond_8023ad.c
index c1873aa..c452318 100644 (file)
@@ -1,34 +1,5 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
- *   All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of Intel Corporation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation
  */
 
 #include <stddef.h>
@@ -1022,37 +993,30 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev,
 }
 
 int
-bond_mode_8023ad_deactivate_slave(struct rte_eth_dev *bond_dev,
+bond_mode_8023ad_deactivate_slave(struct rte_eth_dev *bond_dev __rte_unused,
                uint16_t slave_id)
 {
-       struct bond_dev_private *internals = bond_dev->data->dev_private;
        void *pkt = NULL;
-       struct port *port;
-       uint16_t i;
+       struct port *port = NULL;
+       uint8_t old_partner_state;
 
-       /* Given slave must be in active list */
-       RTE_ASSERT(find_slave_by_id(internals->active_slaves,
-       internals->active_slave_count, slave_id) < internals->active_slave_count);
+       port = &mode_8023ad_ports[slave_id];
 
-       /* Exclude slave from transmit policy. If this slave is an aggregator
-        * make all aggregated slaves unselected to force selection logic
-        * to select suitable aggregator for this port. */
-       for (i = 0; i < internals->active_slave_count; i++) {
-               port = &mode_8023ad_ports[internals->active_slaves[i]];
-               if (port->aggregator_port_id != slave_id)
-                       continue;
+       ACTOR_STATE_CLR(port, AGGREGATION);
+       port->selected = UNSELECTED;
 
-               port->selected = UNSELECTED;
+       old_partner_state = port->partner_state;
+       record_default(port);
 
-               /* Use default aggregator */
-               port->aggregator_port_id = internals->active_slaves[i];
-       }
+       /* If partner timeout state changes then disable timer */
+       if (!((old_partner_state ^ port->partner_state) &
+                       STATE_LACP_SHORT_TIMEOUT))
+               timer_cancel(&port->current_while_timer);
 
-       port = &mode_8023ad_ports[slave_id];
-       port->selected = UNSELECTED;
-       port->actor_state &= ~(STATE_SYNCHRONIZATION | STATE_DISTRIBUTING |
-                       STATE_COLLECTING);
+       PARTNER_STATE_CLR(port, AGGREGATION);
+       ACTOR_STATE_CLR(port, EXPIRED);
 
+       /* flush rx/tx rings */
        while (rte_ring_dequeue(port->rx_ring, &pkt) == 0)
                rte_pktmbuf_free((struct rte_mbuf *)pkt);
 
@@ -1180,7 +1144,8 @@ bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev)
        uint8_t i;
 
        for (i = 0; i < internals->active_slave_count; i++)
-               bond_mode_8023ad_activate_slave(bond_dev, i);
+               bond_mode_8023ad_activate_slave(bond_dev,
+                               internals->active_slaves[i]);
 
        return 0;
 }