net/bonding: fix burst hash computation
authorRadu Nicolau <radu.nicolau@intel.com>
Mon, 29 Jan 2018 14:36:03 +0000 (14:36 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 31 Jan 2018 19:57:29 +0000 (20:57 +0100)
Wrong function was used for l23 and l34 hashing
slave index was incremented twice.

Fixes: 09150784a776 ("net/bonding: burst mode hash calculation")
Cc: stable@dpdk.org
Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
drivers/net/bonding/rte_eth_bond_api.c
drivers/net/bonding/rte_eth_bond_pmd.c

index b73cb73..149e9e1 100644 (file)
@@ -665,12 +665,15 @@ rte_eth_bond_xmit_policy_set(uint16_t bonded_port_id, uint8_t policy)
        switch (policy) {
        case BALANCE_XMIT_POLICY_LAYER2:
                internals->balance_xmit_policy = policy;
+               internals->burst_xmit_hash = burst_xmit_l2_hash;
                break;
        case BALANCE_XMIT_POLICY_LAYER23:
                internals->balance_xmit_policy = policy;
+               internals->burst_xmit_hash = burst_xmit_l23_hash;
                break;
        case BALANCE_XMIT_POLICY_LAYER34:
                internals->balance_xmit_policy = policy;
+               internals->burst_xmit_hash = burst_xmit_l34_hash;
                break;
 
        default:
index 92ad688..c34c325 100644 (file)
@@ -800,7 +800,7 @@ burst_xmit_l2_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
 
                hash = ether_hash(eth_hdr);
 
-               slaves[i++] = (hash ^= hash >> 8) % slave_count;
+               slaves[i] = (hash ^= hash >> 8) % slave_count;
        }
 }
 
@@ -838,7 +838,7 @@ burst_xmit_l23_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
                hash ^= hash >> 16;
                hash ^= hash >> 8;
 
-               slaves[i++] = hash % slave_count;
+               slaves[i] = hash % slave_count;
        }
 }
 
@@ -907,7 +907,7 @@ burst_xmit_l34_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
                hash ^= hash >> 16;
                hash ^= hash >> 8;
 
-               slaves[i++] = hash % slave_count;
+               slaves[i] = hash % slave_count;
        }
 }
 
@@ -1229,7 +1229,7 @@ bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
        /* Number of mbufs for transmission on each slave */
        uint16_t slave_nb_bufs[RTE_MAX_ETHPORTS] = { 0 };
        /* Mapping array generated by hash function to map mbufs to slaves */
-       uint16_t bufs_slave_port_idxs[RTE_MAX_ETHPORTS] = { 0 };
+       uint16_t bufs_slave_port_idxs[nb_bufs];
 
        uint16_t slave_tx_count, slave_tx_fail_count[RTE_MAX_ETHPORTS] = { 0 };
        uint16_t total_tx_count = 0, total_tx_fail_count = 0;