DPDK patches and discussions
 help / color / mirror / Atom feed
From: fengchengwen <fengchengwen@huawei.com>
To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>, <dev@dpdk.org>
Cc: <anoobj@marvell.com>, Vamsi Attunuru <vattunuru@marvell.com>
Subject: Re: [PATCH 1/4] dmadev: add function to get list of device identifiers
Date: Sun, 8 Oct 2023 09:40:37 +0800	[thread overview]
Message-ID: <8658f856-b7f9-f366-ed2c-3700e0d42749@huawei.com> (raw)
In-Reply-To: <20230810122111.2329-2-gmuthukrishn@marvell.com>

Hi Gowrishankar,

This could create a help function in test, just like:

func() {
    RTE_DMA_FOREACH_DEV(i) {
        rte_dma_info_get(i, &dev_info);
        if (strncmp(dev_info->dev_name, xxx)
            ...
    }
}


If some application (not test) should pick some specific device, I suggest
add more general API, e.g.

typedef int (*rte_dma_filter_fn)(struct rte_dma_info *dev_info, void *param);
uint16_t
rte_dma_get_devs_by_filter(rte_dma_filter_fn fn, void *param, uint16_t *dev_ids, uint16_t nb_ids) {
    RTE_DMA_FOREACH_DEV(i) {
        rte_dma_info_get(i, &dev_info);
        if (fn(&dev_info, param) == 0) {
            // add to out list
        }
    }
}

So we could filter special name-prefix/capability/multi-vchans

Thanks.

On 2023/8/10 20:21, Gowrishankar Muthukrishnan wrote:
> Add a function to get list of device identifiers for a given driver
> name.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
>  lib/dmadev/rte_dmadev.c | 20 ++++++++++++++++++++
>  lib/dmadev/rte_dmadev.h | 21 +++++++++++++++++++++
>  lib/dmadev/version.map  |  1 +
>  3 files changed, 42 insertions(+)
> 
> diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
> index 8c095e1f35..f2a106564d 100644
> --- a/lib/dmadev/rte_dmadev.c
> +++ b/lib/dmadev/rte_dmadev.c
> @@ -388,6 +388,26 @@ rte_dma_get_dev_id_by_name(const char *name)
>  	return dev->data->dev_id;
>  }
>  
> +uint8_t
> +rte_dma_get_dev_list_by_driver(const char *name, int16_t *devs, uint8_t nb_devs)
> +{
> +	uint8_t i, count = 0;
> +
> +	if (name == NULL)
> +		return count;
> +
> +	for (i = 0; i < dma_devices_max && count < nb_devs; i++) {
> +		if (rte_dma_devices[i].state == RTE_DMA_DEV_UNUSED)
> +			continue;
> +
> +		if (strncmp(rte_dma_devices[i].device->driver->name,
> +					name, strlen(name) + 1) == 0)
> +			devs[count++] = i;
> +	}
> +
> +	return count;
> +}
> +
>  bool
>  rte_dma_is_valid(int16_t dev_id)
>  {
> diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
> index e61d71959e..689062a686 100644
> --- a/lib/dmadev/rte_dmadev.h
> +++ b/lib/dmadev/rte_dmadev.h
> @@ -191,6 +191,27 @@ int rte_dma_dev_max(size_t dev_max);
>  __rte_experimental
>  int rte_dma_get_dev_id_by_name(const char *name);
>  
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change without prior notice.
> + *
> + * Get the list of device identifiers for the DMA driver.
> + *
> + * @param name
> + *   DMA driver name.
> + * @param devs
> + *   Output devices identifiers.
> + * @param nb_devs
> + *   Maximal number of devices.
> + *
> + * @return
> + *   Returns number of device identifiers.
> + */
> +__rte_experimental
> +uint8_t rte_dma_get_dev_list_by_driver(const char *name,
> +				       int16_t *devs,
> +				       uint8_t nb_devs);
> +
>  /**
>   * @warning
>   * @b EXPERIMENTAL: this API may change without prior notice.
> diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
> index 7031d6b335..b4d56b41a0 100644
> --- a/lib/dmadev/version.map
> +++ b/lib/dmadev/version.map
> @@ -7,6 +7,7 @@ EXPERIMENTAL {
>  	rte_dma_dev_max;
>  	rte_dma_dump;
>  	rte_dma_get_dev_id_by_name;
> +	rte_dma_get_dev_list_by_driver;
>  	rte_dma_info_get;
>  	rte_dma_is_valid;
>  	rte_dma_next_dev;
> 

  reply	other threads:[~2023-10-08  1:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10 12:21 [PATCH 0/4] test/dma: run tests as per configured pmd Gowrishankar Muthukrishnan
2023-08-10 12:21 ` [PATCH 1/4] dmadev: add function to get list of device identifiers Gowrishankar Muthukrishnan
2023-10-08  1:40   ` fengchengwen [this message]
2023-08-10 12:21 ` [PATCH 2/4] test/dma: run tests according to PMD Gowrishankar Muthukrishnan
2023-08-10 12:21 ` [PATCH 3/4] dma/cnxk: update PCI driver name Gowrishankar Muthukrishnan
2023-08-10 12:21 ` [PATCH 4/4] test/dma: enable cnxk tests Gowrishankar Muthukrishnan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8658f856-b7f9-f366-ed2c-3700e0d42749@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gmuthukrishn@marvell.com \
    --cc=vattunuru@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).