X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbonding%2Frte_eth_bond_8023ad.c;h=5fe004e551dee4a29d68ca67e6f5025c6c24a4a1;hb=fb5e90694022544507f9ff8ce002fd85c65620b3;hp=7d8da2b318f550d948a729d6752a02cbbdcaa4df;hpb=dfbc596c2e1418780f77954e1859ffec9aebfe4f;p=dpdk.git diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index 7d8da2b318..5fe004e551 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.c +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c @@ -12,7 +12,7 @@ #include #include -#include "rte_eth_bond_private.h" +#include "eth_bond_private.h" static void bond_mode_8023ad_ext_periodic_cb(void *arg); #ifdef RTE_LIBRTE_BOND_DEBUG_8023AD @@ -356,16 +356,28 @@ rx_machine(struct bond_dev_private *internals, uint16_t slave_id, timer_set(&port->current_while_timer, timeout); ACTOR_STATE_CLR(port, EXPIRED); + SM_FLAG_CLR(port, EXPIRED); return; /* No state change */ } /* If CURRENT state timer is not running (stopped or expired) * transit to EXPIRED state from DISABLED or CURRENT */ if (!timer_is_running(&port->current_while_timer)) { - ACTOR_STATE_SET(port, EXPIRED); - PARTNER_STATE_CLR(port, SYNCHRONIZATION); - PARTNER_STATE_SET(port, LACP_SHORT_TIMEOUT); - timer_set(&port->current_while_timer, internals->mode4.short_timeout); + if (SM_FLAG(port, EXPIRED)) { + port->selected = UNSELECTED; + memcpy(&port->partner, &port->partner_admin, + sizeof(struct port_params)); + record_default(port); + ACTOR_STATE_CLR(port, EXPIRED); + timer_cancel(&port->current_while_timer); + } else { + SM_FLAG_SET(port, EXPIRED); + ACTOR_STATE_SET(port, EXPIRED); + PARTNER_STATE_CLR(port, SYNCHRONIZATION); + PARTNER_STATE_SET(port, LACP_SHORT_TIMEOUT); + timer_set(&port->current_while_timer, + internals->mode4.short_timeout); + } } } @@ -673,9 +685,8 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id) uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0}; uint64_t agg_count[RTE_MAX_ETHPORTS] = {0}; uint16_t default_slave = 0; - uint16_t mode_count_id; - uint16_t mode_band_id; struct rte_eth_link link_info; + uint16_t agg_new_idx = 0; int ret; slaves = internals->active_slaves; @@ -696,8 +707,8 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id) slaves[i], rte_strerror(-ret)); continue; } - agg_count[agg->aggregator_port_id] += 1; - agg_bandwidth[agg->aggregator_port_id] += link_info.link_speed; + agg_count[i] += 1; + agg_bandwidth[i] += link_info.link_speed; /* Actors system ID is not checked since all slave device have the same * ID (MAC address). */ @@ -718,22 +729,22 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id) switch (internals->mode4.agg_selection) { case AGG_COUNT: - mode_count_id = max_index(agg_count, slaves_count); - new_agg_id = mode_count_id; + agg_new_idx = max_index(agg_count, slaves_count); + new_agg_id = slaves[agg_new_idx]; break; case AGG_BANDWIDTH: - mode_band_id = max_index(agg_bandwidth, slaves_count); - new_agg_id = mode_band_id; + agg_new_idx = max_index(agg_bandwidth, slaves_count); + new_agg_id = slaves[agg_new_idx]; break; case AGG_STABLE: if (default_slave == slaves_count) - new_agg_id = slave_id; + new_agg_id = slaves[slave_id]; else new_agg_id = slaves[default_slave]; break; default: if (default_slave == slaves_count) - new_agg_id = slave_id; + new_agg_id = slaves[slave_id]; else new_agg_id = slaves[default_slave]; break; @@ -799,7 +810,8 @@ rx_machine_update(struct bond_dev_private *internals, uint16_t slave_id, RTE_ASSERT(lacp->lacpdu.subtype == SLOW_SUBTYPE_LACP); partner = &lacp->lacpdu.partner; - if (rte_is_same_ether_addr(&partner->port_params.system, + if (rte_is_zero_ether_addr(&partner->port_params.system) || + rte_is_same_ether_addr(&partner->port_params.system, &internals->mode4.mac_addr)) { /* This LACP frame is sending to the bonding port * so pass it to rx_machine. @@ -1021,6 +1033,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, port->actor.port_number = rte_cpu_to_be_16(slave_id + 1); memcpy(&port->partner, &initial, sizeof(struct port_params)); + memcpy(&port->partner_admin, &initial, sizeof(struct port_params)); /* default states */ port->actor_state = STATE_AGGREGATION | STATE_LACP_ACTIVE | STATE_DEFAULTED; @@ -1044,7 +1057,7 @@ bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, RTE_ASSERT(port->tx_ring == NULL); socket_id = rte_eth_dev_socket_id(slave_id); - if (socket_id == (int)LCORE_ID_ANY) + if (socket_id == -1) socket_id = rte_socket_id(); element_size = sizeof(struct slow_protocol_frame) + @@ -1321,8 +1334,7 @@ bond_mode_8023ad_handle_slow_pkt(struct bond_dev_private *internals, rte_eth_macaddr_get(slave_id, &m_hdr->eth_hdr.s_addr); if (internals->mode4.dedicated_queues.enabled == 0) { - int retval = rte_ring_enqueue(port->tx_ring, pkt); - if (retval != 0) { + if (rte_ring_enqueue(port->tx_ring, pkt) != 0) { /* reset timer */ port->rx_marker_timer = 0; wrn = WRN_TX_QUEUE_FULL; @@ -1342,8 +1354,7 @@ bond_mode_8023ad_handle_slow_pkt(struct bond_dev_private *internals, } } else if (likely(subtype == SLOW_SUBTYPE_LACP)) { if (internals->mode4.dedicated_queues.enabled == 0) { - int retval = rte_ring_enqueue(port->rx_ring, pkt); - if (retval != 0) { + if (rte_ring_enqueue(port->rx_ring, pkt) != 0) { /* If RX fing full free lacpdu message and drop packet */ wrn = WRN_RX_QUEUE_FULL; goto free_out; @@ -1387,11 +1398,12 @@ rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id, struct bond_dev_private *internals; struct mode8023ad_private *mode4; + if (valid_bonded_port_id(port_id) != 0) + return -EINVAL; + bond_dev = &rte_eth_devices[port_id]; internals = bond_dev->data->dev_private; - if (valid_bonded_port_id(port_id) != 0) - return -EINVAL; if (internals->mode != 4) return -EINVAL; @@ -1408,11 +1420,12 @@ int rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id) struct bond_dev_private *internals; struct mode8023ad_private *mode4; + if (valid_bonded_port_id(port_id) != 0) + return -EINVAL; + bond_dev = &rte_eth_devices[port_id]; internals = bond_dev->data->dev_private; - if (valid_bonded_port_id(port_id) != 0) - return -EINVAL; if (internals->mode != 4) return -EINVAL; mode4 = &internals->mode4; @@ -1665,12 +1678,14 @@ int rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port) { int retval = 0; - struct rte_eth_dev *dev = &rte_eth_devices[port]; - struct bond_dev_private *internals = (struct bond_dev_private *) - dev->data->dev_private; + struct rte_eth_dev *dev; + struct bond_dev_private *internals; - if (check_for_bonded_ethdev(dev) != 0) - return -1; + if (valid_bonded_port_id(port) != 0) + return -EINVAL; + + dev = &rte_eth_devices[port]; + internals = dev->data->dev_private; if (bond_8023ad_slow_pkt_hw_filter_supported(port) != 0) return -1; @@ -1689,12 +1704,14 @@ int rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port) { int retval = 0; - struct rte_eth_dev *dev = &rte_eth_devices[port]; - struct bond_dev_private *internals = (struct bond_dev_private *) - dev->data->dev_private; + struct rte_eth_dev *dev; + struct bond_dev_private *internals; - if (check_for_bonded_ethdev(dev) != 0) - return -1; + if (valid_bonded_port_id(port) != 0) + return -EINVAL; + + dev = &rte_eth_devices[port]; + internals = dev->data->dev_private; /* Device must be stopped to set up slow queue */ if (dev->data->dev_started)