]> git.droids-corp.org - dpdk.git/commitdiff
net/virtio: fix PCI ops assignment
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Mon, 1 Feb 2021 20:31:38 +0000 (21:31 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 2 Feb 2021 23:48:11 +0000 (00:48 +0100)
VIRTIO_OPS() macro relies on the port ID stored in the
virtio_hw struct. Issue is that it is used before being
assigned at init time. It results in all devices setting
ops on port ID 0, causing crash later when calling ops
for port IDs other than 0.

This patch ensures port ID assignment is done at early
primary process probe time, before it is being used.

Bugzilla ID: 631
Fixes: 512e27eeb743 ("net/virtio: move PCI specific dev init to PCI ethdev init")
Reported-by: Wei Ling <weix.ling@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Tested-by: Wei Ling <weix.ling@intel.com>
drivers/net/virtio/virtio_ethdev.c
drivers/net/virtio/virtio_pci_ethdev.c

index e030fe31f454c40c6d4c57f860d883b1fc5fb35b..333a5243a9a22cc5c1f0924585bf77e97818f9d2 100644 (file)
@@ -1838,7 +1838,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
                return -ENOMEM;
        }
 
-       hw->port_id = eth_dev->data->port_id;
        rte_spinlock_init(&hw->state_lock);
 
        /* reset device and negotiate default features */
index 1b818c45655cb01d7cd04742444a848b1a8b38f5..3bb5c6268b1f9c3ad0bdb2a29403abb930f66c80 100644 (file)
@@ -77,6 +77,7 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev)
        int ret;
 
        if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+               hw->port_id = eth_dev->data->port_id;
                ret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), dev);
                if (ret) {
                        PMD_INIT_LOG(ERR, "Failed to init PCI device\n");