On Tue, Oct 8, 2024 at 9:40 AM Akhil Goyal <gak...@marvell.com> wrote:
>
> Added an internal API for PMDs to get raw device pointer
> from a device id.
>
> Signed-off-by: Akhil Goyal <gak...@marvell.com>
> ---
> - resend patch for main branch separated from rvu_lf raw driver
> https://patches.dpdk.org/project/dpdk/list/?series=32949
>
>  lib/rawdev/rte_rawdev_pmd.h | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h
> index 22b406444d..8339122348 100644
> --- a/lib/rawdev/rte_rawdev_pmd.h
> +++ b/lib/rawdev/rte_rawdev_pmd.h
> @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name)
>         return NULL;
>  }
>
> +/**
> + * Get the rte_rawdev structure device pointer for given device ID.
> + *
> + * @param dev_id
> + *   raw device index.
> + *
> + * @return
> + *   - The rte_rawdev structure pointer for the given device ID.
> + */
> +static inline struct rte_rawdev *
> +rte_rawdev_pmd_get_dev(uint8_t dev_id)
> +{
> +       struct rte_rawdev *dev;
> +
> +       if (dev_id >= RTE_RAWDEV_MAX_DEVS)
> +               return NULL;
> +
> +       dev = &rte_rawdevs[dev_id];
> +       if (dev->attached == RTE_RAWDEV_ATTACHED)
> +               return dev;
> +
> +       return NULL;
> +}
> +

This seems simple enough and we have the same kind of helper in other
device class libraries.
But I would like to better understand the driver API that requires this.


-- 
David Marchand

Reply via email to