net: add rte prefix to ether structures
[dpdk.git] / drivers / net / bonding / rte_eth_bond_api.c
index 206a5c7..0fc4c5e 100644 (file)
@@ -19,7 +19,10 @@ int
 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
        /* Check valid pointer */
-       if (eth_dev->device->driver->name == NULL)
+       if (eth_dev == NULL ||
+               eth_dev->device == NULL ||
+               eth_dev->device->driver == NULL ||
+               eth_dev->device->driver->name == NULL)
                return -1;
 
        /* return 0 if driver name matches */
@@ -73,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);
@@ -126,6 +129,12 @@ deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
        RTE_ASSERT(active_count < RTE_DIM(internals->active_slaves));
        internals->active_slave_count = active_count;
 
+       /* Resetting active_slave when reaches to max
+        * no of slaves in active list
+        */
+       if (internals->active_slave >= active_count)
+               internals->active_slave = 0;
+
        if (eth_dev->data->dev_started) {
                if (internals->mode == BONDING_MODE_8023AD) {
                        bond_mode_8023ad_start(eth_dev);
@@ -245,9 +254,9 @@ slave_rte_flow_prepare(uint16_t slave_id, struct bond_dev_private *internals)
        }
        TAILQ_FOREACH(flow, &internals->flow_list, next) {
                flow->flows[slave_id] = rte_flow_create(slave_port_id,
-                                                       &flow->fd->attr,
-                                                       flow->fd->items,
-                                                       flow->fd->actions,
+                                                       flow->rule.attr,
+                                                       flow->rule.pattern,
+                                                       flow->rule.actions,
                                                        &ferror);
                if (flow->flows[slave_id] == NULL) {
                        RTE_BOND_LOG(ERR, "Cannot create flow for slave"
@@ -399,6 +408,43 @@ eth_bond_slave_inherit_dev_info_tx_next(struct bond_dev_private *internals,
                             internals->tx_queue_offload_capa;
 }
 
+static void
+eth_bond_slave_inherit_desc_lim_first(struct rte_eth_desc_lim *bond_desc_lim,
+               const struct rte_eth_desc_lim *slave_desc_lim)
+{
+       memcpy(bond_desc_lim, slave_desc_lim, sizeof(*bond_desc_lim));
+}
+
+static int
+eth_bond_slave_inherit_desc_lim_next(struct rte_eth_desc_lim *bond_desc_lim,
+               const struct rte_eth_desc_lim *slave_desc_lim)
+{
+       bond_desc_lim->nb_max = RTE_MIN(bond_desc_lim->nb_max,
+                                       slave_desc_lim->nb_max);
+       bond_desc_lim->nb_min = RTE_MAX(bond_desc_lim->nb_min,
+                                       slave_desc_lim->nb_min);
+       bond_desc_lim->nb_align = RTE_MAX(bond_desc_lim->nb_align,
+                                         slave_desc_lim->nb_align);
+
+       if (bond_desc_lim->nb_min > bond_desc_lim->nb_max ||
+           bond_desc_lim->nb_align > bond_desc_lim->nb_max) {
+               RTE_BOND_LOG(ERR, "Failed to inherit descriptor limits");
+               return -EINVAL;
+       }
+
+       /* Treat maximum number of segments equal to 0 as unspecified */
+       if (slave_desc_lim->nb_seg_max != 0 &&
+           (bond_desc_lim->nb_seg_max == 0 ||
+            slave_desc_lim->nb_seg_max < bond_desc_lim->nb_seg_max))
+               bond_desc_lim->nb_seg_max = slave_desc_lim->nb_seg_max;
+       if (slave_desc_lim->nb_mtu_seg_max != 0 &&
+           (bond_desc_lim->nb_mtu_seg_max == 0 ||
+            slave_desc_lim->nb_mtu_seg_max < bond_desc_lim->nb_mtu_seg_max))
+               bond_desc_lim->nb_mtu_seg_max = slave_desc_lim->nb_mtu_seg_max;
+
+       return 0;
+}
+
 static int
 __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
 {
@@ -444,10 +490,6 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
                        }
                }
 
-               /* Inherit eth dev link properties from first slave */
-               link_properties_set(bonded_eth_dev,
-                               &(slave_eth_dev->data->dev_link));
-
                /* Make primary slave */
                internals->primary_port = slave_port_id;
                internals->current_primary_port = slave_port_id;
@@ -458,9 +500,26 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
 
                eth_bond_slave_inherit_dev_info_rx_first(internals, &dev_info);
                eth_bond_slave_inherit_dev_info_tx_first(internals, &dev_info);
+
+               eth_bond_slave_inherit_desc_lim_first(&internals->rx_desc_lim,
+                                                     &dev_info.rx_desc_lim);
+               eth_bond_slave_inherit_desc_lim_first(&internals->tx_desc_lim,
+                                                     &dev_info.tx_desc_lim);
        } else {
+               int ret;
+
                eth_bond_slave_inherit_dev_info_rx_next(internals, &dev_info);
                eth_bond_slave_inherit_dev_info_tx_next(internals, &dev_info);
+
+               ret = eth_bond_slave_inherit_desc_lim_next(
+                               &internals->rx_desc_lim, &dev_info.rx_desc_lim);
+               if (ret != 0)
+                       return ret;
+
+               ret = eth_bond_slave_inherit_desc_lim_next(
+                               &internals->tx_desc_lim, &dev_info.tx_desc_lim);
+               if (ret != 0)
+                       return ret;
        }
 
        bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &=
@@ -737,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;
@@ -781,7 +840,7 @@ rte_eth_bond_active_slaves_get(uint16_t bonded_port_id, uint16_t slaves[],
 
 int
 rte_eth_bond_mac_address_set(uint16_t bonded_port_id,
-               struct ether_addr *mac_addr)
+               struct rte_ether_addr *mac_addr)
 {
        struct rte_eth_dev *bonded_eth_dev;
        struct bond_dev_private *internals;