net/bonding: fix slave id types
authorDavid Marchand <david.marchand@redhat.com>
Wed, 20 Mar 2019 11:47:20 +0000 (12:47 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 21 Mar 2019 20:09:16 +0000 (21:09 +0100)
Caught by code review, with port id conversion to 16bits, the slave id
have been extended to 16bits as well (both slave index and count).

Fixes: f8244c6399d9 ("ethdev: increase port id range")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/bonding/rte_eth_bond_8023ad.c
drivers/net/bonding/rte_eth_bond_alb.c
drivers/net/bonding/rte_eth_bond_api.c
drivers/net/bonding/rte_eth_bond_pmd.c
drivers/net/bonding/rte_eth_bond_private.h

index dac23ac..1e6a3fc 100644 (file)
@@ -664,7 +664,7 @@ max_index(uint64_t *a, int n)
  * @param port_pos                     Port to assign.
  */
 static void
-selection_logic(struct bond_dev_private *internals, uint8_t slave_id)
+selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 {
        struct port *agg, *port;
        uint16_t slaves_count, new_agg_id, i, j = 0;
@@ -781,7 +781,7 @@ link_speed_key(uint16_t speed) {
 }
 
 static void
-rx_machine_update(struct bond_dev_private *internals, uint8_t slave_id,
+rx_machine_update(struct bond_dev_private *internals, uint16_t slave_id,
                struct rte_mbuf *lacp_pkt) {
        struct lacpdu_header *lacp;
        struct lacpdu_actor_partner_params *partner;
@@ -812,8 +812,8 @@ bond_mode_8023ad_periodic_cb(void *arg)
        struct rte_eth_link link_info;
        struct ether_addr slave_addr;
        struct rte_mbuf *lacp_pkt = NULL;
-
-       uint8_t i, slave_id;
+       uint16_t slave_id;
+       uint16_t i;
 
 
        /* Update link status on each port */
@@ -1156,7 +1156,7 @@ int
 bond_mode_8023ad_enable(struct rte_eth_dev *bond_dev)
 {
        struct bond_dev_private *internals = bond_dev->data->dev_private;
-       uint8_t i;
+       uint16_t i;
 
        for (i = 0; i < internals->active_slave_count; i++)
                bond_mode_8023ad_activate_slave(bond_dev,
index c3891c7..d3e16d4 100644 (file)
@@ -18,10 +18,10 @@ simple_hash(uint8_t *hash_start, int hash_size)
        return hash;
 }
 
-static uint8_t
+static uint16_t
 calculate_slave(struct bond_dev_private *internals)
 {
-       uint8_t idx;
+       uint16_t idx;
 
        idx = (internals->mode6.last_slave + 1) % internals->active_slave_count;
        internals->mode6.last_slave = idx;
index b55752e..a23988d 100644 (file)
@@ -76,7 +76,7 @@ void
 activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
 {
        struct bond_dev_private *internals = eth_dev->data->dev_private;
-       uint8_t active_count = internals->active_slave_count;
+       uint16_t active_count = internals->active_slave_count;
 
        if (internals->mode == BONDING_MODE_8023AD)
                bond_mode_8023ad_activate_slave(eth_dev, port_id);
@@ -796,7 +796,7 @@ rte_eth_bond_slaves_get(uint16_t bonded_port_id, uint16_t slaves[],
                        uint16_t len)
 {
        struct bond_dev_private *internals;
-       uint8_t i;
+       uint16_t i;
 
        if (valid_bonded_port_id(bonded_port_id) != 0)
                return -1;
index df0a3b4..bbe2568 100644 (file)
@@ -353,7 +353,7 @@ bond_ethdev_tx_burst_8023ad_fast_queue(void *queue, struct rte_mbuf **bufs,
 
        for (i = 0; i < nb_bufs; i++) {
                /* Populate slave mbuf arrays with mbufs for that slave. */
-               uint8_t slave_idx = bufs_slave_port_idxs[i];
+               uint16_t slave_idx = bufs_slave_port_idxs[i];
 
                slave_bufs[slave_idx][slave_nb_bufs[slave_idx]++] = bufs[i];
        }
@@ -404,8 +404,9 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct rte_mbuf **bufs,
 
        uint8_t collecting;  /* current slave collecting status */
        const uint8_t promisc = internals->promiscuous_en;
-       uint8_t i, j, k;
        uint8_t subtype;
+       uint8_t j, k;
+       uint16_t i;
 
        /* Copy slave list to protect against slave up/down changes during tx
         * bursting */
@@ -774,7 +775,7 @@ ipv6_hash(struct ipv6_hdr *ipv6_hdr)
 
 void
 burst_xmit_l2_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
-               uint8_t slave_count, uint16_t *slaves)
+               uint16_t slave_count, uint16_t *slaves)
 {
        struct ether_hdr *eth_hdr;
        uint32_t hash;
@@ -791,7 +792,7 @@ burst_xmit_l2_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
 
 void
 burst_xmit_l23_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
-               uint8_t slave_count, uint16_t *slaves)
+               uint16_t slave_count, uint16_t *slaves)
 {
        uint16_t i;
        struct ether_hdr *eth_hdr;
@@ -829,7 +830,7 @@ burst_xmit_l23_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
 
 void
 burst_xmit_l34_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
-               uint8_t slave_count, uint16_t *slaves)
+               uint16_t slave_count, uint16_t *slaves)
 {
        struct ether_hdr *eth_hdr;
        uint16_t proto;
@@ -899,7 +900,7 @@ burst_xmit_l34_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
 struct bwg_slave {
        uint64_t bwg_left_int;
        uint64_t bwg_left_remainder;
-       uint8_t slave;
+       uint16_t slave;
 };
 
 void
@@ -952,11 +953,12 @@ bond_ethdev_update_tlb_slave_cb(void *arg)
        struct bond_dev_private *internals = arg;
        struct rte_eth_stats slave_stats;
        struct bwg_slave bwg_array[RTE_MAX_ETHPORTS];
-       uint8_t slave_count;
+       uint16_t slave_count;
        uint64_t tx_bytes;
 
        uint8_t update_stats = 0;
-       uint8_t i, slave_id;
+       uint16_t slave_id;
+       uint16_t i;
 
        internals->slave_update_idx++;
 
@@ -1243,7 +1245,7 @@ bond_ethdev_tx_burst_balance(void *queue, struct rte_mbuf **bufs,
 
        for (i = 0; i < nb_bufs; i++) {
                /* Populate slave mbuf arrays with mbufs for that slave. */
-               uint8_t slave_idx = bufs_slave_port_idxs[i];
+               uint16_t slave_idx = bufs_slave_port_idxs[i];
 
                slave_bufs[slave_idx][slave_nb_bufs[slave_idx]++] = bufs[i];
        }
@@ -1354,7 +1356,7 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf **bufs,
                         * Populate slave mbuf arrays with mbufs for that
                         * slave
                         */
-                       uint8_t slave_idx = bufs_slave_port_idxs[i];
+                       uint16_t slave_idx = bufs_slave_port_idxs[i];
 
                        slave_bufs[slave_idx][slave_nb_bufs[slave_idx]++] =
                                        bufs[i];
@@ -1396,8 +1398,9 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs,
        struct bond_dev_private *internals;
        struct bond_tx_queue *bd_tx_q;
 
-       uint8_t tx_failed_flag = 0, num_of_slaves;
        uint16_t slaves[RTE_MAX_ETHPORTS];
+       uint8_t tx_failed_flag = 0;
+       uint16_t num_of_slaves;
 
        uint16_t max_nb_of_tx_pkts = 0;
 
@@ -1948,7 +1951,7 @@ void
 slave_remove(struct bond_dev_private *internals,
                struct rte_eth_dev *slave_eth_dev)
 {
-       uint8_t i;
+       uint16_t i;
 
        for (i = 0; i < internals->slave_count; i++)
                if (internals->slaves[i].port_id ==
@@ -2147,7 +2150,7 @@ void
 bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 {
        struct bond_dev_private *internals = eth_dev->data->dev_private;
-       uint8_t i;
+       uint16_t i;
 
        if (internals->mode == BONDING_MODE_8023AD) {
                struct port *port;
@@ -2243,7 +2246,7 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
         */
        if (internals->slave_count > 0) {
                struct rte_eth_dev_info slave_info;
-               uint8_t idx;
+               uint16_t idx;
 
                for (idx = 0; idx < internals->slave_count; idx++) {
                        rte_eth_dev_info_get(internals->slaves[idx].port_id,
@@ -2656,9 +2659,10 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
        struct rte_eth_link link;
        int rc = -1;
 
-       int i, valid_slave = 0;
-       uint8_t active_pos;
        uint8_t lsc_flag = 0;
+       int valid_slave = 0;
+       uint16_t active_pos;
+       uint16_t i;
 
        if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
                return rc;
index 032ffed..8afef39 100644 (file)
@@ -100,7 +100,7 @@ struct rte_flow {
 };
 
 typedef void (*burst_xmit_hash_t)(struct rte_mbuf **buf, uint16_t nb_pkts,
-               uint8_t slave_count, uint16_t *slaves);
+               uint16_t slave_count, uint16_t *slaves);
 
 /** Link Bonding PMD device private configuration Structure */
 struct bond_dev_private {
@@ -256,15 +256,15 @@ slave_add(struct bond_dev_private *internals,
 
 void
 burst_xmit_l2_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
-               uint8_t slave_count, uint16_t *slaves);
+               uint16_t slave_count, uint16_t *slaves);
 
 void
 burst_xmit_l23_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
-               uint8_t slave_count, uint16_t *slaves);
+               uint16_t slave_count, uint16_t *slaves);
 
 void
 burst_xmit_l34_hash(struct rte_mbuf **buf, uint16_t nb_pkts,
-               uint8_t slave_count, uint16_t *slaves);
+               uint16_t slave_count, uint16_t *slaves);
 
 
 void