[v3,1/3] drivers/bus: move driver assignment to end of probing
Checks
Commit Message
The PCI mapping requires to know the PCI driver to use,
even before the probing is done. That's why the PCI driver is
referenced early inside the PCI device structure. See
1d20a073fa5e ("bus/pci: reference driver structure before mapping")
However the rte_driver does not need to be referenced in rte_device
before the device probing is done.
By moving back this assignment at the end of the device probing,
it becomes possible to make clear the status of a rte_device.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/bus/ifpga/ifpga_bus.c | 9 ++++-----
drivers/bus/pci/pci_common.c | 7 +++----
drivers/bus/pci/rte_bus_pci.h | 2 +-
drivers/bus/vdev/vdev.c | 5 ++---
drivers/bus/vmbus/vmbus_common.c | 5 +++--
drivers/net/i40e/i40e_vf_representor.c | 3 ---
drivers/net/mlx4/mlx4.c | 1 -
drivers/net/mlx5/mlx5.c | 1 -
lib/librte_eal/common/include/rte_dev.h | 2 +-
9 files changed, 14 insertions(+), 21 deletions(-)
Comments
On 10/8/18 1:09 AM, Thomas Monjalon wrote:
> The PCI mapping requires to know the PCI driver to use,
> even before the probing is done. That's why the PCI driver is
> referenced early inside the PCI device structure. See
> 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
>
> However the rte_driver does not need to be referenced in rte_device
> before the device probing is done.
> By moving back this assignment at the end of the device probing,
> it becomes possible to make clear the status of a rte_device.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
On 10/8/18 1:09 AM, Thomas Monjalon wrote:
> The PCI mapping requires to know the PCI driver to use,
> even before the probing is done. That's why the PCI driver is
> referenced early inside the PCI device structure. See
> 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
>
> However the rte_driver does not need to be referenced in rte_device
> before the device probing is done.
> By moving back this assignment at the end of the device probing,
> it becomes possible to make clear the status of a rte_device.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> index c7695d108..d63e68045 100644
> --- a/drivers/bus/pci/pci_common.c
> +++ b/drivers/bus/pci/pci_common.c
> @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
> * driver flags for adjusting configuration.
> */
> dev->driver = dr;
> - dev->device.driver = &dr->driver;
It breaks net/sfc and I guess other drivers which use
rte_eth_dma_zone_reserve()
from probe. The function makes zone name using dev->device->driver->name.
Andrew.
11/10/2018 12:53, Andrew Rybchenko:
> On 10/8/18 1:09 AM, Thomas Monjalon wrote:
> > The PCI mapping requires to know the PCI driver to use,
> > even before the probing is done. That's why the PCI driver is
> > referenced early inside the PCI device structure. See
> > 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
> >
> > However the rte_driver does not need to be referenced in rte_device
> > before the device probing is done.
> > By moving back this assignment at the end of the device probing,
> > it becomes possible to make clear the status of a rte_device.
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> > diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> > index c7695d108..d63e68045 100644
> > --- a/drivers/bus/pci/pci_common.c
> > +++ b/drivers/bus/pci/pci_common.c
> > @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
> > * driver flags for adjusting configuration.
> > */
> > dev->driver = dr;
> > - dev->device.driver = &dr->driver;
>
> It breaks net/sfc and I guess other drivers which use
> rte_eth_dma_zone_reserve()
> from probe. The function makes zone name using dev->device->driver->name.
Please, can you show code line where we does such access?
I checked such access before and did not find some.
Anyway, it can be fixed by accessing rte_pci_driver->driver->name.
Note that rte_pci_driver is referenced in rte_pci_device.
On 10/11/18 2:45 PM, Thomas Monjalon wrote:
> 11/10/2018 12:53, Andrew Rybchenko:
>> On 10/8/18 1:09 AM, Thomas Monjalon wrote:
>>> The PCI mapping requires to know the PCI driver to use,
>>> even before the probing is done. That's why the PCI driver is
>>> referenced early inside the PCI device structure. See
>>> 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
>>>
>>> However the rte_driver does not need to be referenced in rte_device
>>> before the device probing is done.
>>> By moving back this assignment at the end of the device probing,
>>> it becomes possible to make clear the status of a rte_device.
>>>
>>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
>>> ---
>>> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
>>> index c7695d108..d63e68045 100644
>>> --- a/drivers/bus/pci/pci_common.c
>>> +++ b/drivers/bus/pci/pci_common.c
>>> @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
>>> * driver flags for adjusting configuration.
>>> */
>>> dev->driver = dr;
>>> - dev->device.driver = &dr->driver;
>> It breaks net/sfc and I guess other drivers which use
>> rte_eth_dma_zone_reserve()
>> from probe. The function makes zone name using dev->device->driver->name.
> Please, can you show code line where we does such access?
>
> I checked such access before and did not find some.
> Anyway, it can be fixed by accessing rte_pci_driver->driver->name.
> Note that rte_pci_driver is referenced in rte_pci_device.
Below in snprintf(), in theory it can be called for vdev as well.
const struct rte_memzone *
rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char
*ring_name,
uint16_t queue_id, size_t size, unsigned align,
int socket_id)
{
char z_name[RTE_MEMZONE_NAMESIZE];
const struct rte_memzone *mz;
snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
dev->device->driver->name, ring_name,
dev->data->port_id, queue_id);
mz = rte_memzone_lookup(z_name);
if (mz)
return mz;
return rte_memzone_reserve_aligned(z_name, size, socket_id,
RTE_MEMZONE_IOVA_CONTIG, align);
}
11/10/2018 13:54, Andrew Rybchenko:
> On 10/11/18 2:45 PM, Thomas Monjalon wrote:
> > 11/10/2018 12:53, Andrew Rybchenko:
> >> On 10/8/18 1:09 AM, Thomas Monjalon wrote:
> >>> The PCI mapping requires to know the PCI driver to use,
> >>> even before the probing is done. That's why the PCI driver is
> >>> referenced early inside the PCI device structure. See
> >>> 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
> >>>
> >>> However the rte_driver does not need to be referenced in rte_device
> >>> before the device probing is done.
> >>> By moving back this assignment at the end of the device probing,
> >>> it becomes possible to make clear the status of a rte_device.
> >>>
> >>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> >>> ---
> >>> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> >>> index c7695d108..d63e68045 100644
> >>> --- a/drivers/bus/pci/pci_common.c
> >>> +++ b/drivers/bus/pci/pci_common.c
> >>> @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
> >>> * driver flags for adjusting configuration.
> >>> */
> >>> dev->driver = dr;
> >>> - dev->device.driver = &dr->driver;
> >> It breaks net/sfc and I guess other drivers which use
> >> rte_eth_dma_zone_reserve()
> >> from probe. The function makes zone name using dev->device->driver->name.
> > Please, can you show code line where we does such access?
> >
> > I checked such access before and did not find some.
> > Anyway, it can be fixed by accessing rte_pci_driver->driver->name.
> > Note that rte_pci_driver is referenced in rte_pci_device.
>
> Below in snprintf(), in theory it can be called for vdev as well.
>
> const struct rte_memzone *
> rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char
> *ring_name,
> uint16_t queue_id, size_t size, unsigned align,
> int socket_id)
> {
> char z_name[RTE_MEMZONE_NAMESIZE];
> const struct rte_memzone *mz;
>
> snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> dev->device->driver->name, ring_name,
> dev->data->port_id, queue_id);
I see, I missed it.
I think it's strange to use rte_device name for ethdev memory.
Should we use the ethdev name instead?
snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
- dev->device->driver->name, ring_name,
+ dev->data->name, ring_name,
dev->data->port_id, queue_id);
On 10/11/18 3:59 PM, Thomas Monjalon wrote:
> 11/10/2018 13:54, Andrew Rybchenko:
>> On 10/11/18 2:45 PM, Thomas Monjalon wrote:
>>> 11/10/2018 12:53, Andrew Rybchenko:
>>>> On 10/8/18 1:09 AM, Thomas Monjalon wrote:
>>>>> The PCI mapping requires to know the PCI driver to use,
>>>>> even before the probing is done. That's why the PCI driver is
>>>>> referenced early inside the PCI device structure. See
>>>>> 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
>>>>>
>>>>> However the rte_driver does not need to be referenced in rte_device
>>>>> before the device probing is done.
>>>>> By moving back this assignment at the end of the device probing,
>>>>> it becomes possible to make clear the status of a rte_device.
>>>>>
>>>>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
>>>>> ---
>>>>> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
>>>>> index c7695d108..d63e68045 100644
>>>>> --- a/drivers/bus/pci/pci_common.c
>>>>> +++ b/drivers/bus/pci/pci_common.c
>>>>> @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
>>>>> * driver flags for adjusting configuration.
>>>>> */
>>>>> dev->driver = dr;
>>>>> - dev->device.driver = &dr->driver;
>>>> It breaks net/sfc and I guess other drivers which use
>>>> rte_eth_dma_zone_reserve()
>>>> from probe. The function makes zone name using dev->device->driver->name.
>>> Please, can you show code line where we does such access?
>>>
>>> I checked such access before and did not find some.
>>> Anyway, it can be fixed by accessing rte_pci_driver->driver->name.
>>> Note that rte_pci_driver is referenced in rte_pci_device.
>> Below in snprintf(), in theory it can be called for vdev as well.
>>
>> const struct rte_memzone *
>> rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char
>> *ring_name,
>> uint16_t queue_id, size_t size, unsigned align,
>> int socket_id)
>> {
>> char z_name[RTE_MEMZONE_NAMESIZE];
>> const struct rte_memzone *mz;
>>
>> snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
>> dev->device->driver->name, ring_name,
>> dev->data->port_id, queue_id);
> I see, I missed it.
>
> I think it's strange to use rte_device name for ethdev memory.
> Should we use the ethdev name instead?
>
> snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> - dev->device->driver->name, ring_name,
> + dev->data->name, ring_name,
> dev->data->port_id, queue_id);
data->name could be update to 63 characters (RTE_DEV_NAME_MAX_LEN=64).
RTE_MEMZONE_NAMESIZE is 32. Sounds like a problem.
It is especially a problem if name may be specified/set by user.
Right now device driver writer knows the driver name, choose ring name and
have limits on port and queue ID. So, the writer at least has possibility to
be sure that the results will always fit z_name.
11/10/2018 15:15, Andrew Rybchenko:
> On 10/11/18 3:59 PM, Thomas Monjalon wrote:
> > 11/10/2018 13:54, Andrew Rybchenko:
> >> On 10/11/18 2:45 PM, Thomas Monjalon wrote:
> >>> 11/10/2018 12:53, Andrew Rybchenko:
> >>>> On 10/8/18 1:09 AM, Thomas Monjalon wrote:
> >>>>> The PCI mapping requires to know the PCI driver to use,
> >>>>> even before the probing is done. That's why the PCI driver is
> >>>>> referenced early inside the PCI device structure. See
> >>>>> 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
> >>>>>
> >>>>> However the rte_driver does not need to be referenced in rte_device
> >>>>> before the device probing is done.
> >>>>> By moving back this assignment at the end of the device probing,
> >>>>> it becomes possible to make clear the status of a rte_device.
> >>>>>
> >>>>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> >>>>> ---
> >>>>> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> >>>>> index c7695d108..d63e68045 100644
> >>>>> --- a/drivers/bus/pci/pci_common.c
> >>>>> +++ b/drivers/bus/pci/pci_common.c
> >>>>> @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
> >>>>> * driver flags for adjusting configuration.
> >>>>> */
> >>>>> dev->driver = dr;
> >>>>> - dev->device.driver = &dr->driver;
> >>>> It breaks net/sfc and I guess other drivers which use
> >>>> rte_eth_dma_zone_reserve()
> >>>> from probe. The function makes zone name using dev->device->driver->name.
> >>> Please, can you show code line where we does such access?
> >>>
> >>> I checked such access before and did not find some.
> >>> Anyway, it can be fixed by accessing rte_pci_driver->driver->name.
> >>> Note that rte_pci_driver is referenced in rte_pci_device.
> >> Below in snprintf(), in theory it can be called for vdev as well.
> >>
> >> const struct rte_memzone *
> >> rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char
> >> *ring_name,
> >> uint16_t queue_id, size_t size, unsigned align,
> >> int socket_id)
> >> {
> >> char z_name[RTE_MEMZONE_NAMESIZE];
> >> const struct rte_memzone *mz;
> >>
> >> snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> >> dev->device->driver->name, ring_name,
> >> dev->data->port_id, queue_id);
> > I see, I missed it.
> >
> > I think it's strange to use rte_device name for ethdev memory.
> > Should we use the ethdev name instead?
> >
> > snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> > - dev->device->driver->name, ring_name,
> > + dev->data->name, ring_name,
> > dev->data->port_id, queue_id);
>
> data->name could be update to 63 characters (RTE_DEV_NAME_MAX_LEN=64).
> RTE_MEMZONE_NAMESIZE is 32. Sounds like a problem.
> It is especially a problem if name may be specified/set by user.
>
> Right now device driver writer knows the driver name, choose ring name and
> have limits on port and queue ID. So, the writer at least has possibility to
> be sure that the results will always fit z_name.
What about removing the device name from the memzone name?
It is already unique thanks to port_id, queue_id and ring_name.
On 10/11/18 6:29 PM, Thomas Monjalon wrote:
> 11/10/2018 15:15, Andrew Rybchenko:
>> On 10/11/18 3:59 PM, Thomas Monjalon wrote:
>>> 11/10/2018 13:54, Andrew Rybchenko:
>>>> On 10/11/18 2:45 PM, Thomas Monjalon wrote:
>>>>> 11/10/2018 12:53, Andrew Rybchenko:
>>>>>> On 10/8/18 1:09 AM, Thomas Monjalon wrote:
>>>>>>> The PCI mapping requires to know the PCI driver to use,
>>>>>>> even before the probing is done. That's why the PCI driver is
>>>>>>> referenced early inside the PCI device structure. See
>>>>>>> 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
>>>>>>>
>>>>>>> However the rte_driver does not need to be referenced in rte_device
>>>>>>> before the device probing is done.
>>>>>>> By moving back this assignment at the end of the device probing,
>>>>>>> it becomes possible to make clear the status of a rte_device.
>>>>>>>
>>>>>>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
>>>>>>> ---
>>>>>>> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
>>>>>>> index c7695d108..d63e68045 100644
>>>>>>> --- a/drivers/bus/pci/pci_common.c
>>>>>>> +++ b/drivers/bus/pci/pci_common.c
>>>>>>> @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
>>>>>>> * driver flags for adjusting configuration.
>>>>>>> */
>>>>>>> dev->driver = dr;
>>>>>>> - dev->device.driver = &dr->driver;
>>>>>> It breaks net/sfc and I guess other drivers which use
>>>>>> rte_eth_dma_zone_reserve()
>>>>>> from probe. The function makes zone name using dev->device->driver->name.
>>>>> Please, can you show code line where we does such access?
>>>>>
>>>>> I checked such access before and did not find some.
>>>>> Anyway, it can be fixed by accessing rte_pci_driver->driver->name.
>>>>> Note that rte_pci_driver is referenced in rte_pci_device.
>>>> Below in snprintf(), in theory it can be called for vdev as well.
>>>>
>>>> const struct rte_memzone *
>>>> rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char
>>>> *ring_name,
>>>> uint16_t queue_id, size_t size, unsigned align,
>>>> int socket_id)
>>>> {
>>>> char z_name[RTE_MEMZONE_NAMESIZE];
>>>> const struct rte_memzone *mz;
>>>>
>>>> snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
>>>> dev->device->driver->name, ring_name,
>>>> dev->data->port_id, queue_id);
>>> I see, I missed it.
>>>
>>> I think it's strange to use rte_device name for ethdev memory.
>>> Should we use the ethdev name instead?
>>>
>>> snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
>>> - dev->device->driver->name, ring_name,
>>> + dev->data->name, ring_name,
>>> dev->data->port_id, queue_id);
>> data->name could be update to 63 characters (RTE_DEV_NAME_MAX_LEN=64).
>> RTE_MEMZONE_NAMESIZE is 32. Sounds like a problem.
>> It is especially a problem if name may be specified/set by user.
>>
>> Right now device driver writer knows the driver name, choose ring name and
>> have limits on port and queue ID. So, the writer at least has possibility to
>> be sure that the results will always fit z_name.
> What about removing the device name from the memzone name?
> It is already unique thanks to port_id, queue_id and ring_name.
Driver name is nice since it simplify buggy code identification, but
not that critical. Maybe we should highlight that it is ethdev
(not other port/queue), i.e. ethdev_%s_%d_%d, to be sure
that port_id and queue_id uniquely identify it.
11/10/2018 17:41, Andrew Rybchenko:
> On 10/11/18 6:29 PM, Thomas Monjalon wrote:
> > 11/10/2018 15:15, Andrew Rybchenko:
> >> On 10/11/18 3:59 PM, Thomas Monjalon wrote:
> >>> 11/10/2018 13:54, Andrew Rybchenko:
> >>>> On 10/11/18 2:45 PM, Thomas Monjalon wrote:
> >>>>> 11/10/2018 12:53, Andrew Rybchenko:
> >>>>>> On 10/8/18 1:09 AM, Thomas Monjalon wrote:
> >>>>>>> The PCI mapping requires to know the PCI driver to use,
> >>>>>>> even before the probing is done. That's why the PCI driver is
> >>>>>>> referenced early inside the PCI device structure. See
> >>>>>>> 1d20a073fa5e ("bus/pci: reference driver structure before mapping")
> >>>>>>>
> >>>>>>> However the rte_driver does not need to be referenced in rte_device
> >>>>>>> before the device probing is done.
> >>>>>>> By moving back this assignment at the end of the device probing,
> >>>>>>> it becomes possible to make clear the status of a rte_device.
> >>>>>>>
> >>>>>>> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> >>>>>>> ---
> >>>>>>> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> >>>>>>> index c7695d108..d63e68045 100644
> >>>>>>> --- a/drivers/bus/pci/pci_common.c
> >>>>>>> +++ b/drivers/bus/pci/pci_common.c
> >>>>>>> @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
> >>>>>>> * driver flags for adjusting configuration.
> >>>>>>> */
> >>>>>>> dev->driver = dr;
> >>>>>>> - dev->device.driver = &dr->driver;
> >>>>>> It breaks net/sfc and I guess other drivers which use
> >>>>>> rte_eth_dma_zone_reserve()
> >>>>>> from probe. The function makes zone name using dev->device->driver->name.
> >>>>> Please, can you show code line where we does such access?
> >>>>>
> >>>>> I checked such access before and did not find some.
> >>>>> Anyway, it can be fixed by accessing rte_pci_driver->driver->name.
> >>>>> Note that rte_pci_driver is referenced in rte_pci_device.
> >>>> Below in snprintf(), in theory it can be called for vdev as well.
> >>>>
> >>>> const struct rte_memzone *
> >>>> rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char
> >>>> *ring_name,
> >>>> uint16_t queue_id, size_t size, unsigned align,
> >>>> int socket_id)
> >>>> {
> >>>> char z_name[RTE_MEMZONE_NAMESIZE];
> >>>> const struct rte_memzone *mz;
> >>>>
> >>>> snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> >>>> dev->device->driver->name, ring_name,
> >>>> dev->data->port_id, queue_id);
> >>> I see, I missed it.
> >>>
> >>> I think it's strange to use rte_device name for ethdev memory.
> >>> Should we use the ethdev name instead?
> >>>
> >>> snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
> >>> - dev->device->driver->name, ring_name,
> >>> + dev->data->name, ring_name,
> >>> dev->data->port_id, queue_id);
> >> data->name could be update to 63 characters (RTE_DEV_NAME_MAX_LEN=64).
> >> RTE_MEMZONE_NAMESIZE is 32. Sounds like a problem.
> >> It is especially a problem if name may be specified/set by user.
> >>
> >> Right now device driver writer knows the driver name, choose ring name and
> >> have limits on port and queue ID. So, the writer at least has possibility to
> >> be sure that the results will always fit z_name.
> > What about removing the device name from the memzone name?
> > It is already unique thanks to port_id, queue_id and ring_name.
>
> Driver name is nice since it simplify buggy code identification, but
> not that critical. Maybe we should highlight that it is ethdev
> (not other port/queue), i.e. ethdev_%s_%d_%d, to be sure
> that port_id and queue_id uniquely identify it.
OK, I send a patch then.
@@ -280,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv,
/* reference driver structure */
afu_dev->driver = drv;
- afu_dev->device.driver = &drv->driver;
/* call the driver probe() function */
ret = drv->probe(afu_dev);
- if (ret) {
+ if (ret)
afu_dev->driver = NULL;
- afu_dev->device.driver = NULL;
- }
+ else
+ afu_dev->device.driver = &drv->driver;
return ret;
}
@@ -302,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
return -1;
/* Check if a driver is already loaded */
- if (afu_dev->driver != NULL)
+ if (afu_dev->device.driver != NULL)
return 0;
TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
@@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
* driver flags for adjusting configuration.
*/
dev->driver = dr;
- dev->device.driver = &dr->driver;
if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
/* map resources for devices that use igb_uio */
ret = rte_pci_map_device(dev);
if (ret != 0) {
dev->driver = NULL;
- dev->device.driver = NULL;
return ret;
}
}
@@ -176,7 +174,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
ret = dr->probe(dr, dev);
if (ret) {
dev->driver = NULL;
- dev->device.driver = NULL;
if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) &&
/* Don't unmap if device is unsupported and
* driver needs mapped resources.
@@ -184,6 +181,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
!(ret > 0 &&
(dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES)))
rte_pci_unmap_device(dev);
+ } else {
+ dev->device.driver = &dr->driver;
}
return ret;
@@ -244,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
return -1;
/* Check if a driver is already loaded */
- if (dev->driver != NULL)
+ if (dev->device.driver != NULL)
return 0;
FOREACH_DRIVER_ON_PCIBUS(dr) {
@@ -62,7 +62,7 @@ struct rte_pci_device {
struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
/**< PCI Memory Resource */
struct rte_intr_handle intr_handle; /**< Interrupt handle */
- struct rte_pci_driver *driver; /**< Associated driver */
+ struct rte_pci_driver *driver; /**< PCI driver used in probing */
uint16_t max_vfs; /**< sriov enable if not zero */
enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */
char name[PCI_PRI_STR_SIZE+1]; /**< PCI location (ASCII) */
@@ -150,10 +150,9 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
if (vdev_parse(name, &driver))
return -1;
- dev->device.driver = &driver->driver;
ret = driver->probe(dev);
- if (ret)
- dev->device.driver = NULL;
+ if (ret == 0)
+ dev->device.driver = &driver->driver;
return ret;
}
@@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,
/* reference driver structure */
dev->driver = dr;
- dev->device.driver = &dr->driver;
if (dev->device.numa_node < 0) {
VMBUS_LOG(WARNING, " Invalid NUMA socket, default to 0");
@@ -124,6 +123,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,
if (ret) {
dev->driver = NULL;
rte_vmbus_unmap_device(dev);
+ } else {
+ dev->device.driver = &dr->driver;
}
return ret;
@@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)
int rc;
/* Check if a driver is already loaded */
- if (dev->driver != NULL) {
+ if (dev->device.driver != NULL) {
VMBUS_LOG(DEBUG, "VMBUS driver already loaded");
return 0;
}
@@ -487,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
if (representor->vf_id >= pf->vf_num)
return -ENODEV;
- /** representor shares the same driver as it's PF device */
- ethdev->device->driver = representor->adapter->eth_dev->device->driver;
-
/* Set representor device ops */
ethdev->dev_ops = &i40e_representor_dev_ops;
@@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
eth_dev->data->mac_addrs = priv->mac;
eth_dev->device = &pci_dev->device;
rte_eth_copy_pci_info(eth_dev, pci_dev);
- eth_dev->device->driver = &mlx4_driver.driver;
/* Initialize local interrupt handle for current port. */
priv->intr_handle = (struct rte_intr_handle){
.fd = -1,
@@ -1081,7 +1081,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
priv->dev_data = eth_dev->data;
eth_dev->data->mac_addrs = priv->mac;
eth_dev->device = dpdk_dev;
- eth_dev->device->driver = &mlx5_driver.driver;
err = mlx5_uar_init_primary(eth_dev);
if (err) {
err = rte_errno;
@@ -156,7 +156,7 @@ struct rte_driver {
struct rte_device {
TAILQ_ENTRY(rte_device) next; /**< Next device */
const char *name; /**< Device name */
- const struct rte_driver *driver;/**< Associated driver */
+ const struct rte_driver *driver; /**< Driver assigned after probing */
const struct rte_bus *bus; /**< Bus handle assigned on scan */
int numa_node; /**< NUMA node connection */
struct rte_devargs *devargs; /**< Device user arguments */