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 6ADD043AC2; Fri, 9 Feb 2024 09:18:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EACF6402AF; Fri, 9 Feb 2024 09:18:48 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id EA56340293 for ; Fri, 9 Feb 2024 09:18:46 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TWRXG0yHZz1gyVr; Fri, 9 Feb 2024 16:16:46 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 35126140444; Fri, 9 Feb 2024 16:18:44 +0800 (CST) Received: from [10.48.2.83] (10.48.2.83) 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; Fri, 9 Feb 2024 16:18:42 +0800 Message-ID: <069660f9-2940-23de-4b6a-beaea1acf944@huawei.com> Date: Fri, 9 Feb 2024 16:18:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH v2] lib/dmadev: get DMA device using device ID Content-Language: en-US To: Thomas Monjalon , Amit Prakash Shukla CC: Kevin Laatz , Bruce Richardson , , , , , , References: <20231208075526.2696553-1-amitprakashs@marvell.com> <20231219110027.16443-1-amitprakashs@marvell.com> <2341512.n0HT0TaD9V@thomas> From: fengchengwen In-Reply-To: <2341512.n0HT0TaD9V@thomas> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.48.2.83] X-ClientProxiedBy: dggpeml100011.china.huawei.com (7.185.36.193) To dggpeml500024.china.huawei.com (7.185.36.10) 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 Thomas, On 2024/2/9 0:25, Thomas Monjalon wrote: > 19/12/2023 12:00, Amit Prakash Shukla: >> +struct rte_dma_dev * >> +rte_dma_pmd_get_dev_by_id(const int dev_id) > const does not make sense here for an int parameter. I think it could be OK with const even if the parameter is not pointer. However, most DPDK APIs do not have const for simple types (e.g. int/uin16_t). In this aspect, I think it's also OK to remove const of here for consistency. > >> +{ >> + if (!rte_dma_is_valid(dev_id)) >> + return NULL; >> + >> + return &rte_dma_devices[dev_id]; >> +} > [...] >> +/** >> + * @internal >> + * Get the rte_dma_dev structure device pointer for the device id. >> + * >> + * @param dev_id >> + * Device ID value to select the device structure. > This comment is not explanatory. > What is an ID? Where does it come from? > Where can we see such ID for DMA device? This new API is used in the event-dma driver of cnxk [1]: The rte_event_dma_adapter_vchan_add has parameter of dma_dev_id, and it then invoke (*dev->dev_ops->dma_adapter_vchan_add)(dev, dma_dev_id, vchan, event), at cnxk driver, this ops will check whether the DMA is cnxk_dmadev_pci_driver. I think this is because the cnxk's event-and-dma implement has deep coupling (because the cnxk's event device could interact with another vendor's dma device). Maybe we should think of a better way to solve this kind of coupling problem. Thanks [1] https://patches.dpdk.org/project/dpdk/patch/20231208082835.2817601-3-amitprakashs@marvell.com/ > >> + * >> + * @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); > Again, const does not make sense here. > > Chengwen, please can you comment this patch as you maintain dmadev? > >