drivers/net: share vdev data to secondary process
[dpdk.git] / drivers / net / vhost / rte_eth_vhost.c
index fea13eb..99a7727 100644 (file)
@@ -1362,9 +1362,22 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
        int client_mode = 0;
        int dequeue_zero_copy = 0;
        int iommu_support = 0;
+       struct rte_eth_dev *eth_dev;
+       const char *name = rte_vdev_device_name(dev);
+
+       RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name);
 
-       RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n",
-               rte_vdev_device_name(dev));
+       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 = &ops;
+               return 0;
+       }
 
        kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
        if (kvlist == NULL)