net/virtio: fix Virtio-PCI ops assignment
PATCH v2 1/1 net/virtio: fix Virtio-PCI ops assignment
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
--- drivers/net/virtio/virtio_ethdev.c | 1 - drivers/net/virtio/virtio_pci_ethdev.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio/virtio_ethdev.c +0 -1
@@ -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 */
drivers/net/virtio/virtio_pci_ethdev.c +1 -0
@@ -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" );
Signature · 1 line
2.29.2
Quoted 7 lines · Maxime Coquelin
VIRTIO_OPS()macro relies on the port ID stored in thevirtio_hwstruct. 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.
Quoted 8 lines
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 <[email protected]>Signed-off-by Maxime Coquelin <[email protected]>
Signature · 1 line
David Marchand
Ferruh Yigit
AppliedQuoted 15 lines · David Marchand
Quoted 13 lines · Maxime Coquelin
VIRTIO_OPS()macro relies on the port ID stored in thevirtio_hwstruct. 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")
Quoted 7 lines
Quoted 2 lines
Reported-by Wei Ling <[email protected]>Signed-off-by Maxime Coquelin <[email protected]>Reviewed-by David Marchand <[email protected]>Tested-by Wei Ling <[email protected]>
Applied to dpdk-next-net/main, thanks.
Quoted 9 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, February 2, 2021 04:32 AM
To: [email protected]; Wang, Yinan <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]; [email protected]; Ling, WeiX <[email protected]>; Jiang, YuX <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Subject: [PATCH v2] net/virtio: fix Virtio-PCI ops assignment