net/qede/base: use function pointers for spq async callback
[dpdk.git] / drivers / net / bonding / rte_eth_bond_pmd.c
index 383e27c..d783320 100644 (file)
@@ -175,12 +175,13 @@ const struct rte_flow_attr flow_attr_8023ad = {
 int
 bond_ethdev_8023ad_flow_verify(struct rte_eth_dev *bond_dev,
                uint8_t slave_port) {
+       struct rte_eth_dev_info slave_info;
        struct rte_flow_error error;
        struct bond_dev_private *internals = (struct bond_dev_private *)
                        (bond_dev->data->dev_private);
 
-       struct rte_flow_action_queue lacp_queue_conf = {
-               .index = internals->mode4.dedicated_queues.rx_qid,
+       const struct rte_flow_action_queue lacp_queue_conf = {
+               .index = 0,
        };
 
        const struct rte_flow_action actions[] = {
@@ -195,8 +196,21 @@ bond_ethdev_8023ad_flow_verify(struct rte_eth_dev *bond_dev,
 
        int ret = rte_flow_validate(slave_port, &flow_attr_8023ad,
                        flow_item_8023ad, actions, &error);
-       if (ret < 0)
+       if (ret < 0) {
+               RTE_BOND_LOG(ERR, "%s: %s (slave_port=%d queue_id=%d)",
+                               __func__, error.message, slave_port,
+                               internals->mode4.dedicated_queues.rx_qid);
+               return -1;
+       }
+
+       rte_eth_dev_info_get(slave_port, &slave_info);
+       if (slave_info.max_rx_queues < bond_dev->data->nb_rx_queues ||
+                       slave_info.max_tx_queues < bond_dev->data->nb_tx_queues) {
+               RTE_BOND_LOG(ERR,
+                       "%s: Slave %d capabilities doesn't allow to allocate additional queues",
+                       __func__, slave_port);
                return -1;
+       }
 
        return 0;
 }
@@ -206,7 +220,7 @@ bond_8023ad_slow_pkt_hw_filter_supported(uint8_t port_id) {
        struct rte_eth_dev *bond_dev = &rte_eth_devices[port_id];
        struct bond_dev_private *internals = (struct bond_dev_private *)
                        (bond_dev->data->dev_private);
-       struct rte_eth_dev_info bond_info, slave_info;
+       struct rte_eth_dev_info bond_info;
        uint8_t idx;
 
        /* Verify if all slaves in bonding supports flow director and */
@@ -217,9 +231,6 @@ bond_8023ad_slow_pkt_hw_filter_supported(uint8_t port_id) {
                internals->mode4.dedicated_queues.tx_qid = bond_info.nb_tx_queues;
 
                for (idx = 0; idx < internals->slave_count; idx++) {
-                       rte_eth_dev_info_get(internals->slaves[idx].port_id,
-                                       &slave_info);
-
                        if (bond_ethdev_8023ad_flow_verify(bond_dev,
                                        internals->slaves[idx].port_id) != 0)
                                return -1;
@@ -2535,6 +2546,9 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
                /* Remove from active slave list */
                deactivate_slave(bonded_eth_dev, port_id);
 
+               if (internals->active_slave_count < 1)
+                       lsc_flag = 1;
+
                /* Update primary id, take first active slave from list or if none
                 * available set to -1 */
                if (port_id == internals->current_primary_port) {
@@ -2822,7 +2836,7 @@ bond_probe(struct rte_vdev_device *dev)
        const char *name;
        struct bond_dev_private *internals;
        struct rte_kvargs *kvlist;
-       uint8_t bonding_mode, socket_id;
+       uint8_t bonding_mode, socket_id/*, agg_mode*/;
        int  arg_count, port_id;
 
        if (!dev)
@@ -2949,6 +2963,7 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
        struct rte_kvargs *kvlist = internals->kvlist;
        int arg_count;
        uint8_t port_id = dev - rte_eth_devices;
+       uint8_t agg_mode;
 
        static const uint8_t default_rss_key[40] = {
                0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, 0x41, 0x67, 0x25, 0x3D,
@@ -3036,6 +3051,21 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
                return -1;
        }
 
+       if (rte_kvargs_count(kvlist, PMD_BOND_AGG_MODE_KVARG) == 1) {
+               if (rte_kvargs_process(kvlist,
+                               PMD_BOND_AGG_MODE_KVARG,
+                               &bond_ethdev_parse_slave_agg_mode_kvarg,
+                               &agg_mode) != 0) {
+                       RTE_LOG(ERR, EAL,
+                                       "Failed to parse agg selection mode for bonded device %s\n",
+                                       name);
+               }
+               if (internals->mode == BONDING_MODE_8023AD)
+                       if (agg_mode != 0)
+                               rte_eth_bond_8023ad_agg_selection_set(port_id,
+                                               agg_mode);
+       }
+
        /* Parse/add slave ports to bonded device */
        if (rte_kvargs_count(kvlist, PMD_BOND_SLAVE_PORT_KVARG) > 0) {
                struct bond_ethdev_slave_ports slave_ports;
@@ -3199,6 +3229,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
        "primary=<ifc> "
        "mode=[0-6] "
        "xmit_policy=[l2 | l23 | l34] "
+       "agg_mode=[count | stable | bandwidth] "
        "socket_id=<int> "
        "mac=<mac addr> "
        "lsc_poll_period_ms=<int> "