[dpdk-dev,1/2] add rte_bus->probe
Checks
Commit Message
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
lib/librte_eal/common/eal_common_bus.c | 7 ++++---
lib/librte_eal/common/include/rte_bus.h | 3 +++
lib/librte_eal/linuxapp/eal/eal_pci.c | 1 +
3 files changed, 8 insertions(+), 3 deletions(-)
Comments
On Tuesday 10 January 2017 11:32 PM, Ferruh Yigit wrote:
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> lib/librte_eal/common/eal_common_bus.c | 7 ++++---
> lib/librte_eal/common/include/rte_bus.h | 3 +++
> lib/librte_eal/linuxapp/eal/eal_pci.c | 1 +
> 3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
> index f8c2e03..e8d1143 100644
> --- a/lib/librte_eal/common/eal_common_bus.c
> +++ b/lib/librte_eal/common/eal_common_bus.c
> @@ -145,6 +145,7 @@ rte_eal_bus_register(struct rte_bus *bus)
> /* A bus should mandatorily have the scan and match implemented */
> RTE_VERIFY(bus->scan);
> RTE_VERIFY(bus->match);
> + RTE_VERIFY(bus->probe);
v6 of my patches would include the above.
>
> /* Initialize the driver and device list associated with the bus */
> TAILQ_INIT(&(bus->driver_list));
> @@ -195,19 +196,19 @@ rte_eal_bus_scan(void)
> }
>
> static int
> -perform_probe(struct rte_bus *bus __rte_unused, struct rte_driver *driver,
> +perform_probe(struct rte_bus *bus, struct rte_driver *driver,
> struct rte_device *device)
> {
> int ret;
>
> - if (!driver->probe) {
> + if (!bus->probe) {
> RTE_LOG(ERR, EAL, "Driver (%s) doesn't support probe.\n",
> driver->name);
> /* This is not an error - just a badly implemented PMD */
> return 0;
> }
>
> - ret = driver->probe(driver, device);
> + ret = bus->probe(driver, device);
> if (ret < 0)
> /* One of the probes failed */
> RTE_LOG(ERR, EAL, "Probe failed for (%s).\n", driver->name);
Substantial code has shuffled in v6, including removal of this function.
But again, I agree with your changes.
> diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
> index 07c30c4..ce1f56a 100644
> --- a/lib/librte_eal/common/include/rte_bus.h
> +++ b/lib/librte_eal/common/include/rte_bus.h
> @@ -135,6 +135,8 @@ typedef int (*bus_scan_t)(struct rte_bus *bus);
> */
> typedef int (*bus_match_t)(struct rte_driver *drv, struct rte_device *dev);
>
> +typedef int (*bus_probe_t)(struct rte_driver *drv, struct rte_device *dev);
> +
> /**
> * A structure describing a generic bus.
> */
> @@ -147,6 +149,7 @@ struct rte_bus {
> const char *name; /**< Name of the bus */
> bus_scan_t scan; /**< Scan for devices attached to bus */
> bus_match_t match;
> + bus_probe_t probe;
> /**< Match device with drivers associated with the bus */
> };
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index 314effa..837adf6 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -726,6 +726,7 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
> struct rte_bus pci_bus = {
> .scan = rte_eal_pci_scan,
> .match = rte_eal_pci_match,
> + .probe = rte_eal_pci_probe,
> };
>
> RTE_REGISTER_BUS(pci, pci_bus);
>
On 1/11/2017 4:53 AM, Shreyansh Jain wrote:
> On Tuesday 10 January 2017 11:32 PM, Ferruh Yigit wrote:
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>> lib/librte_eal/common/eal_common_bus.c | 7 ++++---
>> lib/librte_eal/common/include/rte_bus.h | 3 +++
>> lib/librte_eal/linuxapp/eal/eal_pci.c | 1 +
>> 3 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
>> index f8c2e03..e8d1143 100644
>> --- a/lib/librte_eal/common/eal_common_bus.c
>> +++ b/lib/librte_eal/common/eal_common_bus.c
>> @@ -145,6 +145,7 @@ rte_eal_bus_register(struct rte_bus *bus)
>> /* A bus should mandatorily have the scan and match implemented */
>> RTE_VERIFY(bus->scan);
>> RTE_VERIFY(bus->match);
>> + RTE_VERIFY(bus->probe);
>
> v6 of my patches would include the above.
Since I am aware of you are working on something similar, I added this
(in a dirty way) just to able to test next patch.
Thanks,
ferruh
<...>
> -----Original Message-----
> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Wednesday, January 11, 2017 8:34 PM
> To: Shreyansh Jain <shreyansh.jain@nxp.com>; dev@dpdk.org
> Cc: Stephen Hemminger <sthemmin@microsoft.com>; Jan Blunck
> <jblunck@infradead.org>
> Subject: Re: [PATCH 1/2] add rte_bus->probe
>
> On 1/11/2017 4:53 AM, Shreyansh Jain wrote:
> > On Tuesday 10 January 2017 11:32 PM, Ferruh Yigit wrote:
> >> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> >> ---
> >> lib/librte_eal/common/eal_common_bus.c | 7 ++++---
> >> lib/librte_eal/common/include/rte_bus.h | 3 +++
> >> lib/librte_eal/linuxapp/eal/eal_pci.c | 1 +
> >> 3 files changed, 8 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/lib/librte_eal/common/eal_common_bus.c
> b/lib/librte_eal/common/eal_common_bus.c
> >> index f8c2e03..e8d1143 100644
> >> --- a/lib/librte_eal/common/eal_common_bus.c
> >> +++ b/lib/librte_eal/common/eal_common_bus.c
> >> @@ -145,6 +145,7 @@ rte_eal_bus_register(struct rte_bus *bus)
> >> /* A bus should mandatorily have the scan and match implemented */
> >> RTE_VERIFY(bus->scan);
> >> RTE_VERIFY(bus->match);
> >> + RTE_VERIFY(bus->probe);
> >
> > v6 of my patches would include the above.
>
> Since I am aware of you are working on something similar, I added this
> (in a dirty way) just to able to test next patch.
:) I understood this after sending my mail. I understand your point.
>
> Thanks,
> ferruh
>
> <...>
@@ -145,6 +145,7 @@ rte_eal_bus_register(struct rte_bus *bus)
/* A bus should mandatorily have the scan and match implemented */
RTE_VERIFY(bus->scan);
RTE_VERIFY(bus->match);
+ RTE_VERIFY(bus->probe);
/* Initialize the driver and device list associated with the bus */
TAILQ_INIT(&(bus->driver_list));
@@ -195,19 +196,19 @@ rte_eal_bus_scan(void)
}
static int
-perform_probe(struct rte_bus *bus __rte_unused, struct rte_driver *driver,
+perform_probe(struct rte_bus *bus, struct rte_driver *driver,
struct rte_device *device)
{
int ret;
- if (!driver->probe) {
+ if (!bus->probe) {
RTE_LOG(ERR, EAL, "Driver (%s) doesn't support probe.\n",
driver->name);
/* This is not an error - just a badly implemented PMD */
return 0;
}
- ret = driver->probe(driver, device);
+ ret = bus->probe(driver, device);
if (ret < 0)
/* One of the probes failed */
RTE_LOG(ERR, EAL, "Probe failed for (%s).\n", driver->name);
@@ -135,6 +135,8 @@ typedef int (*bus_scan_t)(struct rte_bus *bus);
*/
typedef int (*bus_match_t)(struct rte_driver *drv, struct rte_device *dev);
+typedef int (*bus_probe_t)(struct rte_driver *drv, struct rte_device *dev);
+
/**
* A structure describing a generic bus.
*/
@@ -147,6 +149,7 @@ struct rte_bus {
const char *name; /**< Name of the bus */
bus_scan_t scan; /**< Scan for devices attached to bus */
bus_match_t match;
+ bus_probe_t probe;
/**< Match device with drivers associated with the bus */
};
@@ -726,6 +726,7 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
struct rte_bus pci_bus = {
.scan = rte_eal_pci_scan,
.match = rte_eal_pci_match,
+ .probe = rte_eal_pci_probe,
};
RTE_REGISTER_BUS(pci, pci_bus);