From patchwork Thu Aug 10 12:21:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 130078 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 438BB43026; Thu, 10 Aug 2023 14:21:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73A8D43258; Thu, 10 Aug 2023 14:21:25 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 3631A410FD for ; Thu, 10 Aug 2023 14:21:23 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37A8XuGU020364; Thu, 10 Aug 2023 05:21:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=x2wDxxaIZQZ0NBFj8AKdsO3q4vSAfQsYu5w3pnH9QCQ=; b=aA7HLyVwZ0IYs4arN1dM3Hl3dRmunym+i+tXmtZrb1NJp5gns/z5l2+Ji72kS+Z1y7FW stKzz40zwnWpBZiaPflq2CwCAgJAuC1PTIPedFpH7IVfEwMhhQ6yeRO2J4ANcUUjQ0mO pP3vje7Zmb51yt+6X6AE++1rgqvmxMPLdpUjxy0dPVNNo8ZbunD+Bo028jbuPTtyjiCx ynvvC5M84jiE39hYStd3BtTh0diTWBRiSy+osr6OJuTtZo9/cgmOADIaFiMhPdBdQKFE CALae9M6IZUAxvC2BtNbApPCcMh4+99altm/NFEXcs7pb5guXuLGO4s6+AcUt6KN2Pfx PA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3scj5makkg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 10 Aug 2023 05:21:22 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 10 Aug 2023 05:21:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 10 Aug 2023 05:21:20 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id E26735B6935; Thu, 10 Aug 2023 05:21:17 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , Chengwen Feng , "Vamsi Attunuru" , Gowrishankar Muthukrishnan Subject: [PATCH 1/4] dmadev: add function to get list of device identifiers Date: Thu, 10 Aug 2023 17:51:08 +0530 Message-ID: <20230810122111.2329-2-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230810122111.2329-1-gmuthukrishn@marvell.com> References: <20230810122111.2329-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: lhoheL-OSEf7gXPzcR-pg4dJb5XyNLfl X-Proofpoint-GUID: lhoheL-OSEf7gXPzcR-pg4dJb5XyNLfl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-10_10,2023-08-10_01,2023-05-22_02 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 Add a function to get list of device identifiers for a given driver name. Signed-off-by: Gowrishankar Muthukrishnan --- 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;