From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CA281436B3; Sat, 9 Dec 2023 08:11:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C139402F1; Sat, 9 Dec 2023 08:11:40 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id D44F8402DF for ; Sat, 9 Dec 2023 08:11:38 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SnK1b4cNvzWj8Q; Sat, 9 Dec 2023 15:11:31 +0800 (CST) Received: from [10.67.121.161] (10.67.121.161) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sat, 9 Dec 2023 15:11:34 +0800 Subject: Re: [PATCH] lib/dmadev: get DMA device using device ID To: Amit Prakash Shukla , Kevin Laatz , Bruce Richardson CC: , , , , , References: <20231208075526.2696553-1-amitprakashs@marvell.com> From: fengchengwen Message-ID: <6a4a2eb0-fb33-ea1c-ee1a-738640f188d7@huawei.com> Date: Sat, 9 Dec 2023 15:11:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20231208075526.2696553-1-amitprakashs@marvell.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.161] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Amit, On 2023/12/8 15:55, Amit Prakash Shukla wrote: > DMA library has a function to get DMA device based on device name but > there is no function to get DMA device using device id. > > Added a function that lookup for the dma device using device id and > returns the pointer to the same. > > Signed-off-by: Amit Prakash Shukla > --- > lib/dmadev/rte_dmadev.c | 9 +++++++++ > lib/dmadev/rte_dmadev_pmd.h | 14 ++++++++++++++ > lib/dmadev/version.map | 1 + > 3 files changed, 24 insertions(+) > > diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c > index 4e5e420c82..83f49e77f2 100644 > --- a/lib/dmadev/rte_dmadev.c > +++ b/lib/dmadev/rte_dmadev.c > @@ -397,6 +397,15 @@ rte_dma_is_valid(int16_t dev_id) > rte_dma_devices[dev_id].state != RTE_DMA_DEV_UNUSED; > } > > +struct rte_dma_dev * > +rte_dma_pmd_get_dev_by_id(const int dev_id) > +{ > + if (!rte_dma_is_valid(dev_id)) > + return NULL; > + > + return &rte_dma_devices[dev_id]; > +} > + > uint16_t > rte_dma_count_avail(void) > { > diff --git a/lib/dmadev/rte_dmadev_pmd.h b/lib/dmadev/rte_dmadev_pmd.h > index c61cedfb23..f68c3ac6aa 100644 > --- a/lib/dmadev/rte_dmadev_pmd.h > +++ b/lib/dmadev/rte_dmadev_pmd.h > @@ -167,6 +167,20 @@ struct rte_dma_dev *rte_dma_pmd_allocate(const char *name, int numa_node, > __rte_internal > int rte_dma_pmd_release(const char *name); > > +/** > + * @internal > + * Get the rte_dma_dev structure device pointer for the device id. > + * > + * @param dev_id > + * Device ID value to select the device structure. > + * > + * @return > + * - rte_dma_dev structure pointer for the given device ID on success, NULL > + * otherwise. > + */ > +__rte_internal > +struct rte_dma_dev *rte_dma_pmd_get_dev_by_id(const int dev_id); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map > index 2a3736514c..2cd57c43d3 100644 > --- a/lib/dmadev/version.map > +++ b/lib/dmadev/version.map > @@ -26,6 +26,7 @@ INTERNAL { > rte_dma_fp_objs; > rte_dma_pmd_allocate; > rte_dma_pmd_release; > + rte_dma_pmd_get_dev_by_id; Should arranged alphabetically in version.map With above fixed Acked-by: Chengwen Feng Thanks > > local: *; > }; >