ethdev: allow using devices with shortened PCI addresses
PATCH 1/1 ethdev: allow using devices with shortened PCI addresses
When using a secondary process, e.g. pdump, not all PCI devices will be probed correctly if the primary process has allowlisted devices using the shortened syntax, omitting the initial "0000:" domain. This is due to the strcmp failing to match a full address with a shortened one.
Fix this issue by comparing the device names/addresses normally and then having a special case second comparison for devices which start with "0000:".
--- lib/ethdev/ethdev_driver.c | 6 ++++++ 1 file changed, 6 insertions(+)
lib/ethdev/ethdev_driver.c +6 -0
@@ -156,6 +156,7 @@ rte_eth_dev_attach_secondary(const char *name)uint16_t i;struct rte_eth_dev *eth_dev =NULL ; +/* Synchronize port attachment to primary port creation and release. */ rte_spinlock_lock (rte_mcfg_ethdev_get_lock ());
@@ -165,6 +166,11 @@ rte_eth_dev_attach_secondary(const char *name)for (i =0 ; i <RTE_MAX_ETHPORTS ; i++) {if (strcmp (eth_dev_shared_data->data[i].name, name) ==0 )break ; + +/* for PCI devices, allow specifying name without a leading "0000:" */ +if (strncmp (name,"0000:" ,5 ) ==0 &&/* is PCI address */ +strcmp (eth_dev_shared_data->data[i].name, &name[5 ]) ==0 ) +break ; }if (i ==RTE_MAX_ETHPORTS ) { RTE_ETHDEV_LOG_LINE(ERR,
Signature · 1 line
2.43.0
19/11/2024 16:57, Bruce Richardson:
Quoted 21 lines
When using a secondary process, e.g. pdump, not all PCI devices will be probed correctly if the primary process has allowlisted devices using the shortened syntax, omitting the initial "0000:" domain. This is due to the strcmp failing to match a full address with a shortened one.
Fix this issue by comparing the device names/addresses normally and then having a special case second comparison for devices which start with "0000:".
Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")Signed-off-by Bruce Richardson <[email protected]>--- lib/ethdev/ethdev_driver.c | 6 ++++++ 1 file changed, 6 insertions(+)lib/ethdev/ethdev_driver.c +0
-0
lib/ethdev/ethdev_driver.c rte_eth_dev_attach_secondary(const char *name) · line 173
Quoted 4 lines
lib/ethdev/ethdev_driver.c +4
-0+/* for PCI devices, allow specifying name without a leading "0000:" */ +if (strncmp (name,"0000:" ,5 ) ==0 &&/* is PCI address */ +strcmp (eth_dev_shared_data->data[i].name, &name[5 ]) ==0 ) +break ;
I'm afraid it is not enough in all cases.
Shani is preparing a patch which uses the same PCI address formatting in all cases.
Quoted 18 lines · Thomas Monjalon
19/11/2024 16:57, Bruce Richardson:
Quoted 17 lines
When using a secondary process, e.g. pdump, not all PCI devices will be probed correctly if the primary process has allowlisted devices using the shortened syntax, omitting the initial "0000:" domain. This is due to the strcmp failing to match a full address with a shortened one.
Fix this issue by comparing the device names/addresses normally and then having a special case second comparison for devices which start with "0000:".
Fixes d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")Signed-off-by Bruce Richardson <[email protected]>--- lib/ethdev/ethdev_driver.c | 6 ++++++ 1 file changed, 6 insertions(+)
Quoted 13 lines
lib/ethdev/ethdev_driver.c rte_eth_dev_attach_secondary(const char *name) · line 173
Quoted 8 lines
lib/ethdev/ethdev_driver.c +4
-0+/* for PCI devices, allow specifying name without a leading "0000:" */ +if (strncmp (name,"0000:" ,5 ) ==0 &&/* is PCI address */ +strcmp (eth_dev_shared_data->data[i].name, &name[5 ]) ==0 ) +break ;I'm afraid it is not enough in all cases.
Shani is preparing a patch which uses the same PCI address formatting in all cases.
Great. I'll test that patch when it gets submitted.
/Bruce.