bus/pci: get PCI address from rte_device
PATCH 1/1 bus/pci: get PCI address from rte_device
From: Elena Agostini <[email protected]>
In DPDK 22.11 pci bus related structure have been hidden internally so the application doesn't have a direct access to those info anymore.
This patch introduces a get function to retrieve a PCI address from an rte_device handler.
--- drivers/bus/pci/pci_common.c | 15 +++++++++++++++ drivers/bus/pci/rte_bus_pci.h | 13 +++++++++++++ 2 files changed, 28 insertions(+)
drivers/bus/pci/pci_common.c +15 -0
@@ -884,6 +884,21 @@ rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable)return 0 ; } +const struct rte_pci_addr * +rte_pci_get_addr (const struct rte_device *dev) +{ +const struct rte_pci_device *pci_dev; + +if (!dev) { + rte_errno =EINVAL ; +return NULL ; + } + + pci_dev =RTE_DEV_TO_PCI_CONST (dev); + +return &pci_dev->addr; +} +struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan,
drivers/bus/pci/rte_bus_pci.h +13 -0
@@ -68,6 +68,19 @@ void rte_pci_unmap_device(struct rte_pci_device *dev);*/ void rte_pci_dump (FILE *f); +/** +* Return PCI device address of an rte_device +* +* @param dev +* A pointer to a rte_device structure describing the device +* to use +* +* @return +* PCI address of the device on success, NULL if no driver +* is found for the device. +*/ +const struct rte_pci_addr *rte_pci_get_addr (const struct rte_device *dev); +/** * Find device's extended PCI capability. *
Signature · 1 line
2.34.1
30/05/2023 13:42, [email protected]:
Quoted 2 lines
This patch introduces a get function to retrieve a PCI address from an
rte_devicehandler.
[...]
drivers/bus/pci/pci_common.c rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable) · line 892
Quoted 6 lines
drivers/bus/pci/pci_common.c +6
-0+const struct rte_pci_addr * +rte_pci_get_addr (const struct rte_device *dev) +{ +const struct rte_pci_device *pci_dev; + +if (!dev) {
Please compare pointer with == NULL
drivers/bus/pci/pci_common.c rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable) · line 895
Quoted 3 lines
drivers/bus/pci/pci_common.c +3
-0+ rte_errno =EINVAL ; +return NULL ; + }
Can we check the bus type here?
Quoted 5 lines
drivers/bus/pci/pci_common.c +5
-0+ + pci_dev =RTE_DEV_TO_PCI_CONST (dev); + +return &pci_dev->addr; +}
[...]
Quoted 2 lines
+/**
+ * Return PCI device address of anrte_device
You can replace rte_device with "generic device" and add a dot :)
Quoted 4 lines
+ *
+ * @param dev
+ * A pointer to arte_devicestructure describing the device
+ * to use
Do it simpler: pointer to the generic device structure.
Quoted 4 lines
+ *
+ * @return
+ * PCI address of the device on success, NULL if no driver
+ * is found for the device.
Not exactly, it can return NULL if the device is not PCI.
Quoted 2 lines
+ */
+const structrte_pci_addr*rte_pci_get_addr(const struct rte_device *dev);
Quoted 10 lines · On Tue, May 30, 2023 at 1:48 PM <[email protected]> wrote:
From: Elena Agostini <[email protected]>
In DPDK 22.11 pci bus related structure have been hidden internally so the application doesn't have a direct access to those info anymore.
This patch introduces a get function to retrieve a PCI address from an
rte_devicehandler.Signed-off-by Elena Agostini <[email protected]>
(no need to Cc: stable, I removed it)
I would prefer we don't add specific bus API when there is an alternative.
The PCI address is already reported as a string in the generic device object name.
I checked the different ways this name is set and afaics, it is consistent:
- devarg case https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n112
+ https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_params.c#n117
- no devarg case
https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n115 +
https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n100
Would that be enough for your usecase?
Signature · 1 line
David Marchand
Quoted 25 lines · On Tue, May 30, 2023 at 1:48 PM [email protected]<mailto:[email protected]…
Quoted 10 lines
From: Elena Agostini [email protected]<mailto:[email protected]>
In DPDK 22.11 pci bus related structure have been hidden internally so the application doesn't have a direct access to those info anymore.
This patch introduces a get function to retrieve a PCI address from an
rte_devicehandler.(no need to Cc: stable, I removed it)
I would prefer we don't add specific bus API when there is an alternative.
The PCI address is already reported as a string in the generic device object name.
I checked the different ways this name is set and afaics, it is consistent:
- devarg case https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n112
+ https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_params.c#n117
- no devarg case
https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n115 +
https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n100
Quoted 1 line
Would that be enough for your usecase?
No as I need to parse anyway the PCI address string in the form of domain/bus/devid/function. DPDK already does it through a well-organized and exposed structure like rte_pci_addr. Why not to use it?
Also, the device name can be changed as it’s exposed to application level.
Quoted 4 lines
--
David Marchand
Quoted 51 lines · Elena Agostini
Quoted 50 lines · On Tue, May 30, 2023 at 1:48 PM [email protected] wrote:
Quoted 13 lines
From: Elena Agostini [email protected]
In DPDK 22.11 pci bus related structure have been hidden internally
so the application doesn't have a direct access to those info anymore.
Quoted 7 lines
This patch introduces a get function to retrieve a PCI address
from an
rte_devicehandler.Signed-off-by Elena Agostini [email protected](no need to Cc: stable, I removed it)
I would prefer we don't add specific bus API when there is an alternative.
The PCI address is already reported as a string in the generic device
object name.
I checked the different ways this name is set and afaics, it is consistent:
- devarg case https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n112
+ https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_params.c#n117
- no devarg case
https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n115 +
https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n100
Quoted 5 lines
Quoted 1 line
Would that be enough for your usecase?
No as I need to parse anyway the PCI address string in the form of domain/bus/devid/function.
I am curious. Can you explain why you would need such information?
Quoted 2 lines
Also, the device name can be changed as it’s exposed to application level.
?
If you mean the application can bust the device name, well, it's the application problem.
Signature · 1 line
David Marchand
Quoted 52 lines · On Wed, May 31, 2023 at 10:44 AM Elena Agostini…
Quoted 51 lines
Quoted 50 lines · On Tue, May 30, 2023 at 1:48 PM [email protected]<mailto:[email protected]…
Quoted 13 lines
From: Elena Agostini [email protected]<mailto:[email protected]>
In DPDK 22.11 pci bus related structure have been hidden internally
so the application doesn't have a direct access to those info anymore.
Quoted 7 lines
This patch introduces a get function to retrieve a PCI address
from an
rte_devicehandler.(no need to Cc: stable, I removed it)
I would prefer we don't add specific bus API when there is an alternative.
The PCI address is already reported as a string in the generic device
object name.
I checked the different ways this name is set and afaics, it is consistent:
- devarg case https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n112
+ https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_params.c#n117
- no devarg case
https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n115 +
https://git.dpdk.org/dpdk/tree/drivers/bus/pci/pci_common.c#n100
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Would that be enough for your usecase?
No as I need to parse anyway the PCI address string in the form of domain/bus/devid/function.>
I am curious. Can you explain why you would need such information?>
Use-case is the Aerial 5G where two processes have to exchange info about PCI devices sending messages according to some specific format.
Quoted 10 lines
Quoted 2 lines
Also, the device name can be changed as it’s exposed to application level.>
?
If you mean the application can bust the device name, well, it's the application problem.>--
David Marchand
(I reformatted the mail a bit)
Quoted 14 lines · Elena Agostini
Quoted 13 lines · On Wed, May 31, 2023 at 10:44 AM Elena Agostini [email protected] wrote:
Quoted 12 lines
Quoted 12 lines · On Tue, May 30, 2023 at 1:48 PM [email protected] wrote:
Quoted 6 lines
From: Elena Agostini [email protected]
In DPDK 22.11 pci bus related structure have been hidden internally so the application doesn't have a direct access to those info anymore. This patch introduces a get function to retrieve a PCI address from anrte_devicehandler.Signed-off-by Elena Agostini [email protected]I would prefer we don't add specific bus API when there is an alternative. The PCI address is already reported as a string in the generic device object name.
Would that be enough for your usecase?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
No as I need to parse anyway the PCI address string in the form of domain/bus/devid/function.
I am curious. Can you explain why you would need such information?
Use-case is the Aerial 5G where two processes have to exchange info about PCI devices sending messages according to some specific format.
It seems strange that different processes need to exchange this bus level information.
For dataplane, having a simpler metadata (like a portid maybe?) is better than a domain/bus/devid/function quartet.
For controlplane, having an abstraction or a human readable string is probably better too.
In any case, for what you request here, the application can parse the generic device name into a rte_pci_addr via rte_pci_addr_parse(). Is it not enough?
Signature · 1 line
David Marchand
Quoted 32 lines · David Marchand
(I reformatted the mail a bit)
Quoted 14 lines · Elena Agostini
Quoted 13 lines · On Wed, May 31, 2023 at 10:44 AM Elena Agostini [email protected] wrote:
Quoted 12 lines
Quoted 12 lines · On Tue, May 30, 2023 at 1:48 PM [email protected] wrote:
Quoted 6 lines
From: Elena Agostini [email protected]
In DPDK 22.11 pci bus related structure have been hidden internally so the application doesn't have a direct access to those info anymore. This patch introduces a get function to retrieve a PCI address from anrte_devicehandler.Signed-off-by Elena Agostini [email protected]I would prefer we don't add specific bus API when there is an alternative. The PCI address is already reported as a string in the generic device object name.
Would that be enough for your usecase?Quoted 6 lines
Quoted 3 lines
Quoted 1 line
No as I need to parse anyway the PCI address string in the form of domain/bus/devid/function.
I am curious. Can you explain why you would need such information?
Use-case is the Aerial 5G where two processes have to exchange info about PCI devices sending messages according to some specific format.
It seems strange that different processes need to exchange this bus level information.
For dataplane, having a simpler metadata (like a portid maybe?) is better than a domain/bus/devid/function quartet.
For controlplane, having an abstraction or a human readable string is probably better too.
Quoted 3 lines
In any case, for what you request here, the application can parse the generic device name into a
rte_pci_addrviarte_pci_addr_parse(). Is it not enough?
No reply for some time now, marking this patch as rejected.
Signature · 1 line
David Marchand