drivers/net: share vdev data to secondary process
[dpdk.git] / drivers / net / bonding / rte_eth_bond_pmd.c
index 8847d20..09696ea 100644 (file)
@@ -2975,7 +2975,7 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
        /* Set mode 4 default configuration */
        bond_mode_8023ad_setup(eth_dev, NULL);
        if (bond_ethdev_mode_set(eth_dev, mode)) {
-               RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
+               RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode to %d\n",
                                 eth_dev->data->port_id, mode);
                goto err;
        }
@@ -3021,6 +3021,7 @@ bond_probe(struct rte_vdev_device *dev)
        uint8_t bonding_mode, socket_id/*, agg_mode*/;
        int  arg_count, port_id;
        uint8_t agg_mode;
+       struct rte_eth_dev *eth_dev;
 
        if (!dev)
                return -EINVAL;
@@ -3028,6 +3029,18 @@ bond_probe(struct rte_vdev_device *dev)
        name = rte_vdev_device_name(dev);
        RTE_LOG(INFO, EAL, "Initializing pmd_bond for %s\n", name);
 
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
+           strlen(rte_vdev_device_args(dev)) == 0) {
+               eth_dev = rte_eth_dev_attach_secondary(name);
+               if (!eth_dev) {
+                       RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+                       return -1;
+               }
+               /* TODO: request info from primary to set up Rx and Tx */
+               eth_dev->dev_ops = &default_dev_ops;
+               return 0;
+       }
+
        kvlist = rte_kvargs_parse(rte_vdev_device_args(dev),
                pmd_bond_init_valid_arguments);
        if (kvlist == NULL)
@@ -3145,6 +3158,10 @@ bond_remove(struct rte_vdev_device *dev)
        eth_dev->tx_pkt_burst = NULL;
 
        internals = eth_dev->data->dev_private;
+       /* Try to release mempool used in mode6. If the bond
+        * device is not mode6, free the NULL is not problem.
+        */
+       rte_mempool_free(internals->mode6.mempool);
        rte_bitmap_free(internals->vlan_filter_bmp);
        rte_free(internals->vlan_filter_bmpmem);
        rte_free(eth_dev->data->dev_private);