d948f596fe
Assume we have two virtio ports, 00:03.0 and 00:04.0. The first one is
managed by the kernel driver, while the later one is managed by DPDK.
Now we start the primary process. 00:03.0 will be skipped by DPDK virtio
PMD driver (since it's being used by the kernel). 00:04.0 would be
successfully initiated by DPDK virtio PMD (if nothing abnormal happens).
After that, we would get a port id 0, and all the related info needed
by virtio (virtio_hw) is stored at rte_eth_dev_data[0].
Then we start the secondary process. As usual, 00:03.0 will be firstly
probed. It firstly tries to get a local eth_dev structure for it (by
rte_eth_dev_allocate):
port_id = rte_eth_dev_find_free_port();
...
eth_dev = &rte_eth_devices[port_id];
eth_dev->data = &rte_eth_dev_data[port_id];
...
return eth_dev;
Since it's a first PCI device, port_id will be 0. eth_dev->data would
then point to rte_eth_dev_data[0]. And here things start going wrong,
as rte_eth_dev_data[0] actually stores the virtio_hw for 00:04.0.
That said, in the secondary process, DPDK will continue to drive PCI
device 00.03.0 (despite the fact it's been managed by kernel), with
the info from PCI device 00:04.0. Which is wrong.
The fix is to attach the port already registered by the primary process.
That is, iterate the rte_eth_dev_data[], and get the port id who's PCI
ID matches the current PCI device.
This would let us maintain same port ID for the same PCI device, keeping
the chance of referencing to wrong data minimal.
Fixes:
|
||
---|---|---|
.. | ||
librte_acl | ||
librte_cfgfile | ||
librte_cmdline | ||
librte_compat | ||
librte_cryptodev | ||
librte_distributor | ||
librte_eal | ||
librte_ether | ||
librte_hash | ||
librte_ip_frag | ||
librte_jobstats | ||
librte_kni | ||
librte_kvargs | ||
librte_lpm | ||
librte_mbuf | ||
librte_mempool | ||
librte_meter | ||
librte_net | ||
librte_pdump | ||
librte_pipeline | ||
librte_port | ||
librte_power | ||
librte_reorder | ||
librte_ring | ||
librte_sched | ||
librte_table | ||
librte_timer | ||
librte_vhost | ||
Makefile |