> From: Parav Pandit <[email protected]>
> Sent: Friday, July 3, 2020 2:43 PM
> 
> Create a mlx5 bus driver framework for invoking drivers of multiple classes
> who have registered with the mlx5_pci bus driver.

[..]
> diff --git a/drivers/bus/mlx5_pci/mlx5_pci_bus.c
> b/drivers/bus/mlx5_pci/mlx5_pci_bus.c
> index 66db3c7b0..7344c2083 100644
> --- a/drivers/bus/mlx5_pci/mlx5_pci_bus.c
> +++ b/drivers/bus/mlx5_pci/mlx5_pci_bus.c
> @@ -2,13 +2,521 @@
>   * Copyright 2020 Mellanox Technologies, Ltd
>   */
> +static int
> +mlx5_bus_pci_dma_map(struct rte_pci_device *pci_dev, void *addr,
> +                  uint64_t iova, size_t len)
> +{
> +     struct rte_mlx5_pci_driver *class;
> +     struct rte_mlx5_pci_driver *temp;
> +     struct mlx5_pci_device *dev;
> +     int ret = -EINVAL;
> +
> +     dev = pci_to_mlx5_device(pci_dev);
> +     if (!dev)
> +             return -ENODEV;
> +     TAILQ_FOREACH_REVERSE(class, &drv_list, mlx5_pci_bus_drv_head,
> next) {
> +             if (device_class_enabled(dev, class->dev_class) &&
> +                 class->pci_driver.dma_map) {
> +                     ret = class->pci_driver.dma_map(pci_dev, addr,
> +                                                     iova, len);
> +                     if (ret)
> +                             goto map_err;
> +             }
> +     }
> +     return ret;
> +map_err:
> +     TAILQ_FOREACH(temp, &drv_list, next) {

I made a mistake in reusing the logic of the dma_unmap() callback here.
This loop needs to follow same sequence as that what dma_map() does.
I will send the fix. Will wait for some time to gather if there are comments.

> +             if (temp == class)
> +                     break;
> +             if (device_class_enabled(dev, temp->dev_class) &&
> +                 temp->pci_driver.dma_map && temp-
> >pci_driver.dma_unmap)
> +                     temp->pci_driver.dma_unmap(pci_dev, addr, iova,
> len);
> +     }
> +     return ret;
> +}

Reply via email to