net/virtio: unmap PCI device in secondary process
[dpdk.git] / drivers / net / virtio / virtio_user_ethdev.c
index 3ecbb41..a7d7063 100644 (file)
@@ -60,12 +60,15 @@ virtio_user_write_dev_config(struct virtio_hw *hw, size_t offset,
        struct virtio_user_dev *dev = virtio_user_get_dev(hw);
 
        if ((offset == offsetof(struct virtio_net_config, mac)) &&
-           (length == RTE_ETHER_ADDR_LEN))
+           (length == RTE_ETHER_ADDR_LEN)) {
                for (i = 0; i < RTE_ETHER_ADDR_LEN; ++i)
                        dev->mac_addr[i] = ((const uint8_t *)src)[i];
-       else
+               virtio_user_dev_set_mac(dev);
+               virtio_user_dev_get_mac(dev);
+       } else {
                PMD_DRV_LOG(ERR, "not supported offset=%zu, len=%d",
                            offset, length);
+       }
 }
 
 static void
@@ -395,7 +398,7 @@ virtio_user_backend_type(const char *path)
                if (errno == ENOENT)
                        return VIRTIO_USER_BACKEND_VHOST_USER;
 
-               PMD_INIT_LOG(ERR, "Stat fails: %s (%s)\n", path,
+               PMD_INIT_LOG(ERR, "Stat fails: %s (%s)", path,
                             strerror(errno));
                return VIRTIO_USER_BACKEND_UNKNOWN;
        }
@@ -654,9 +657,16 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
                goto end;
        }
 
+       /*
+        * Virtio-user requires using virtual addresses for the descriptors
+        * buffers, whatever other devices require
+        */
+       hw->use_va = true;
+
        /* previously called by pci probing for physical dev */
        if (eth_virtio_dev_init(eth_dev) < 0) {
                PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
+               virtio_user_dev_uninit(dev);
                virtio_user_eth_dev_free(eth_dev);
                goto end;
        }
@@ -679,14 +689,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
        ret = 0;
 
 end:
-       if (kvlist)
-               rte_kvargs_free(kvlist);
-       if (path)
-               free(path);
-       if (mac_addr)
-               free(mac_addr);
-       if (ifname)
-               free(ifname);
+       rte_kvargs_free(kvlist);
+       free(path);
+       free(mac_addr);
+       free(ifname);
        return ret;
 }
 
@@ -766,7 +772,6 @@ static struct rte_vdev_driver virtio_user_driver = {
        .remove = virtio_user_pmd_remove,
        .dma_map = virtio_user_pmd_dma_map,
        .dma_unmap = virtio_user_pmd_dma_unmap,
-       .drv_flags = RTE_VDEV_DRV_NEED_IOVA_AS_VA,
 };
 
 RTE_PMD_REGISTER_VDEV(net_virtio_user, virtio_user_driver);