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 9803B436A6; Fri, 8 Dec 2023 08:56:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E17F42FB1; Fri, 8 Dec 2023 08:56:15 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 8746442F04 for ; Fri, 8 Dec 2023 08:56:14 +0100 (CET) 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 3B81Pcea028655; Thu, 7 Dec 2023 23:56:13 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=4HqyGDtYgjCLZwbIGileoU9ASOxC2fTesyN3XFXOkcY=; b=b9qPCP6aAhs9aRKwbS0vq9Ht1I6TT3sXMwuXxrSj/ZEG50hI8Uxg3XNr1zgLy+dtMSmq PQPlaXv9Sfve+obAPyQuRlBdFRAKjB5Mkpk/4m1j/B3LfD083wyW8j4Z4uqfWolzWYUX 7iAxvTz5eI6IkxRQMdYuQY9RsH5W2oLqAYfyATyIWftmTE9Gf4oqXqHTfiTy1USab8x0 +2Tub55YQ+/6BvanpFv5pbMxo+P1IphGY1pDZpfaI+pBI2HhAfEtzhoBYhBVAnjpcwRp U38qzJVDQG496Q9eDhPN7PQdMuGpkgr24+U4Mr4A28599OD4Gt7kN7/Q/RDh5QekQS/F yA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3uubddc623-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 07 Dec 2023 23:56:13 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 7 Dec 2023 23:56:12 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 7 Dec 2023 23:56:11 -0800 Received: from localhost.localdomain (unknown [10.28.36.157]) by maili.marvell.com (Postfix) with ESMTP id BA30F3F7088; Thu, 7 Dec 2023 23:56:08 -0800 (PST) From: Amit Prakash Shukla To: Chengwen Feng , Kevin Laatz , Bruce Richardson CC: , , , , , , Amit Prakash Shukla Subject: [PATCH] lib/dmadev: get DMA device using device ID Date: Fri, 8 Dec 2023 13:25:25 +0530 Message-ID: <20231208075526.2696553-1-amitprakashs@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: EIu955RxbO-13awpU2wDOf8oggwHi0jZ X-Proofpoint-GUID: EIu955RxbO-13awpU2wDOf8oggwHi0jZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-08_04,2023-12-07_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 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; local: *; }; -- 2.25.1