X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_pmd_bond%2Frte_eth_bond_pmd.c;h=5979ce5b1e0f8ca69edb0cd4d6c7094b73bf996e;hb=ea672a8b1655bbb44876d2550ff56f384968a43b;hp=048de7f3b755287005c0d49859ef9da5140f659f;hpb=6de597c04fab110ee74478cbdc06a78546f3001f;p=dpdk.git diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c index 048de7f3b7..5979ce5b1e 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c @@ -198,14 +198,14 @@ xmit_slave_hash(const struct rte_mbuf *buf, uint8_t slave_count, uint8_t policy) switch (policy) { case BALANCE_XMIT_POLICY_LAYER2: - eth_hdr = (struct ether_hdr *)buf->pkt.data; + eth_hdr = (struct ether_hdr *)buf->data; hash = ether_hash(eth_hdr); hash ^= hash >> 8; return hash % slave_count; case BALANCE_XMIT_POLICY_LAYER23: - eth_hdr = (struct ether_hdr *)buf->pkt.data; + eth_hdr = (struct ether_hdr *)buf->data; if (buf->ol_flags & PKT_RX_VLAN_PKT) eth_offset = sizeof(struct ether_hdr) + sizeof(struct vlan_hdr); @@ -678,8 +678,8 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev) for (i = 0; i < internals->slave_count; i++) { if (slave_configure(eth_dev, &(rte_eth_devices[internals->slaves[i]])) != 0) { - RTE_LOG(ERR, PMD, - "bonded port (%d) failed to reconfigure slave device %d)", + RTE_LOG(ERR, PMD, "bonded port " + "(%d) failed to reconfigure slave device (%d)\n)", eth_dev->data->port_id, internals->slaves[i]); return -1; } @@ -920,17 +920,12 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type, struct bond_dev_private *internals; struct rte_eth_link link; - int i, bonded_port_id, valid_slave, active_pos = -1; - - if (type != RTE_ETH_EVENT_INTR_LSC) - return; + int i, valid_slave = 0, active_pos = -1; - if (param == NULL) + if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL) return; - bonded_port_id = *(uint8_t *)param; - - bonded_eth_dev = &rte_eth_devices[bonded_port_id]; + bonded_eth_dev = &rte_eth_devices[*(uint8_t *)param]; slave_eth_dev = &rte_eth_devices[port_id]; if (valid_bonded_ethdev(bonded_eth_dev)) @@ -963,48 +958,51 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type, rte_eth_link_get_nowait(port_id, &link); if (link.link_status) { - if (active_pos == -1) { - /* if no active slave ports then set this port to be primary port */ - if (internals->active_slave_count == 0) { - /* If first active slave, then change link status */ - bonded_eth_dev->data->dev_link.link_status = 1; - internals->current_primary_port = port_id; + if (active_pos >= 0) + return; + + /* if no active slave ports then set this port to be primary port */ + if (internals->active_slave_count < 1) { + /* If first active slave, then change link status */ + bonded_eth_dev->data->dev_link.link_status = 1; + internals->current_primary_port = port_id; + + /* Inherit eth dev link properties from first active slave */ + link_properties_set(bonded_eth_dev, + &(slave_eth_dev->data->dev_link)); + } + internals->active_slaves[internals->active_slave_count++] = port_id; - /* Inherit eth dev link properties from first active slave */ - link_properties_set(bonded_eth_dev, - &(slave_eth_dev->data->dev_link)); + /* If user has defined the primary port then default to using it */ + if (internals->user_defined_primary_port && + internals->primary_port == port_id) + bond_ethdev_primary_set(internals, port_id); + } else { + if (active_pos < 0) + return; - } - internals->active_slaves[internals->active_slave_count++] = port_id; + /* Remove from active slave list */ + for (i = active_pos; i < (internals->active_slave_count - 1); i++) + internals->active_slaves[i] = internals->active_slaves[i+1]; + + internals->active_slave_count--; - /* If user has defined the primary port then default to using it */ - if (internals->user_defined_primary_port && - internals->primary_port == port_id) - bond_ethdev_primary_set(internals, port_id); + /* No active slaves, change link status to down and reset other + * link properties */ + if (internals->active_slave_count < 1) { + bonded_eth_dev->data->dev_link.link_status = 0; + link_properties_reset(bonded_eth_dev); } - } else { - if (active_pos != -1) { - /* Remove from active slave list */ - for (i = active_pos; i < (internals->active_slave_count - 1); i++) - internals->active_slaves[i] = internals->active_slaves[i+1]; - - internals->active_slave_count--; - - /* No active slaves, change link status to down and reset other - * link properties */ - if (internals->active_slave_count == 0) - link_properties_reset(bonded_eth_dev); - - /* Update primary id, take first active slave from list or if none - * available set to -1 */ - if (port_id == internals->current_primary_port) { - if (internals->active_slave_count > 0) - bond_ethdev_primary_set(internals, - internals->active_slaves[0]); - else - internals->current_primary_port = internals->primary_port; - } + + /* Update primary id, take first active slave from list or if none + * available set to -1 */ + if (port_id == internals->current_primary_port) { + if (internals->active_slave_count > 0) + bond_ethdev_primary_set(internals, + internals->active_slaves[0]); + else + internals->current_primary_port = internals->primary_port; } } }