ethdev: add an argument to internal callback function
[dpdk.git] / drivers / net / bonding / rte_eth_bond_pmd.c
index e19fc5e..9e38ec9 100644 (file)
@@ -1335,6 +1335,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
                                bonded_eth_dev->data->dev_conf.rxmode.mq_mode;
        }
 
+       slave_eth_dev->data->dev_conf.rxmode.hw_vlan_filter =
+                       bonded_eth_dev->data->dev_conf.rxmode.hw_vlan_filter;
+
        /* Configure device */
        errval = rte_eth_dev_configure(slave_eth_dev->data->port_id,
                        bonded_eth_dev->data->nb_rx_queues,
@@ -1637,7 +1640,10 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 void
 bond_ethdev_close(struct rte_eth_dev *dev)
 {
+       struct bond_dev_private *internals = dev->data->dev_private;
+
        bond_ethdev_free_queues(dev);
+       rte_bitmap_reset(internals->vlan_filter_bmp);
 }
 
 /* forward declaration */
@@ -1666,6 +1672,35 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        dev_info->reta_size = internals->reta_size;
 }
 
+static int
+bond_ethdev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
+{
+       int res;
+       uint8_t i;
+       struct bond_dev_private *internals = dev->data->dev_private;
+
+       /* don't do this while a slave is being added */
+       rte_spinlock_lock(&internals->lock);
+
+       if (on)
+               rte_bitmap_set(internals->vlan_filter_bmp, vlan_id);
+       else
+               rte_bitmap_clear(internals->vlan_filter_bmp, vlan_id);
+
+       for (i = 0; i < internals->slave_count; i++) {
+               uint8_t port_id = internals->slaves[i].port_id;
+
+               res = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
+               if (res == ENOTSUP)
+                       RTE_LOG(WARNING, PMD,
+                               "Setting VLAN filter on slave port %u not supported.\n",
+                               port_id);
+       }
+
+       rte_spinlock_unlock(&internals->lock);
+       return 0;
+}
+
 static int
 bond_ethdev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
                uint16_t nb_rx_desc, unsigned int socket_id __rte_unused,
@@ -1923,7 +1958,7 @@ bond_ethdev_delayed_lsc_propagation(void *arg)
                return;
 
        _rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
-                       RTE_ETH_EVENT_INTR_LSC);
+                       RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 void
@@ -1985,6 +2020,16 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
                        /* Inherit eth dev link properties from first active slave */
                        link_properties_set(bonded_eth_dev,
                                        &(slave_eth_dev->data->dev_link));
+               } else {
+                       if (link_properties_valid(
+                               &bonded_eth_dev->data->dev_link, &link) != 0) {
+                               slave_eth_dev->data->dev_flags &=
+                                       (~RTE_ETH_DEV_BONDED_SLAVE);
+                               RTE_LOG(ERR, PMD,
+                                       "port %u invalid speed/duplex\n",
+                                       port_id);
+                               return;
+                       }
                }
 
                activate_slave(bonded_eth_dev, port_id);
@@ -2034,7 +2079,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
                                                (void *)bonded_eth_dev);
                        else
                                _rte_eth_dev_callback_process(bonded_eth_dev,
-                                               RTE_ETH_EVENT_INTR_LSC);
+                                               RTE_ETH_EVENT_INTR_LSC, NULL);
 
                } else {
                        if (internals->link_down_delay_ms > 0)
@@ -2043,7 +2088,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
                                                (void *)bonded_eth_dev);
                        else
                                _rte_eth_dev_callback_process(bonded_eth_dev,
-                                               RTE_ETH_EVENT_INTR_LSC);
+                                               RTE_ETH_EVENT_INTR_LSC, NULL);
                }
        }
 }
@@ -2161,6 +2206,7 @@ const struct eth_dev_ops default_dev_ops = {
        .dev_close            = bond_ethdev_close,
        .dev_configure        = bond_ethdev_configure,
        .dev_infos_get        = bond_ethdev_info,
+       .vlan_filter_set      = bond_ethdev_vlan_filter_set,
        .rx_queue_setup       = bond_ethdev_rx_queue_setup,
        .tx_queue_setup       = bond_ethdev_tx_queue_setup,
        .rx_queue_release     = bond_ethdev_rx_queue_release,
@@ -2177,7 +2223,7 @@ const struct eth_dev_ops default_dev_ops = {
 };
 
 static int
-bond_init(const char *name, const char *params)
+bond_probe(const char *name, const char *params)
 {
        struct bond_dev_private *internals;
        struct rte_kvargs *kvlist;
@@ -2244,7 +2290,7 @@ parse_error:
 }
 
 static int
-bond_uninit(const char *name)
+bond_remove(const char *name)
 {
        int  ret;
 
@@ -2509,16 +2555,13 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 }
 
 static struct rte_vdev_driver bond_drv = {
-       .driver = {
-               .type = PMD_VDEV,
-       },
-       .init = bond_init,
-       .uninit = bond_uninit,
+       .probe = bond_probe,
+       .remove = bond_remove,
 };
 
-DRIVER_REGISTER_VDEV(net_bonding, bond_drv);
+RTE_PMD_REGISTER_VDEV(net_bonding, bond_drv);
 
-DRIVER_REGISTER_PARAM_STRING(net_bonding,
+RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
        "slave=<ifc> "
        "primary=<ifc> "
        "mode=[0-6] "