From patchwork Tue Sep 19 11:41:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Prakash Shukla X-Patchwork-Id: 131624 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 18C3942607; Tue, 19 Sep 2023 13:42:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC1ED40278; Tue, 19 Sep 2023 13:42:00 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 035BF40276 for ; Tue, 19 Sep 2023 13:41:58 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38J6aNBv007718; Tue, 19 Sep 2023 04:41:57 -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=dlHYjOtu+gaomfSDWX500bIZY+gjZb1UIAH217NJopo=; b=OaRf5e2zqbhU9gW7idf9WhDvi3TvCy0An/k8qoU9dnkZihHaJd49xdSQPZEtfAh0aE5S pffm3rU89ddn14sDFwfcGyaJhlysg/elLSCC5/RUOKMvG7OBzC+lw6Ly4OtIl9RBb6gu L8LMTCH4IvqFqOf3sQR3IN60iRG5gjLR8nS9NE2hOnqDGSjBcxwtteG9mzA1/qgR/D5M ZHqCYlfOaxVt1DCRYTZ9Ow/fgl+6vuiZoxrGLL/NFyZ8rPzPJHu+jyy1Bvn+WaHaeZtn ArswZT8flQvGoTqptGCPEwI2gZ/g5DpBh9rBjDUqgwb2Fe5iTfCSx0I3CANgcj0G4bZp yw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3t6skwbf0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 19 Sep 2023 04:41:57 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 19 Sep 2023 04:41:56 -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; Tue, 19 Sep 2023 04:41:56 -0700 Received: from localhost.localdomain (unknown [10.28.36.157]) by maili.marvell.com (Postfix) with ESMTP id DFE583F7097; Tue, 19 Sep 2023 04:41:51 -0700 (PDT) From: Amit Prakash Shukla To: Chengwen Feng , Kevin Laatz , Bruce Richardson CC: , , , , , , , , , , , Amit Prakash Shukla Subject: [PATCH v2] dmadev: get DMA device using device ID Date: Tue, 19 Sep 2023 17:11:37 +0530 Message-ID: <20230919114137.2466750-1-amitprakashs@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918123227.1562074-1-amitprakashs@marvell.com> References: <20230918123227.1562074-1-amitprakashs@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 79ITkSYDPCQpGL9kMxoOf6LiINCEYQ2V X-Proofpoint-ORIG-GUID: 79ITkSYDPCQpGL9kMxoOf6LiINCEYQ2V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-19_06,2023-09-19_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 --- v2: - Dropped patch with dma event op structure. - Resolved review suggestions. lib/dmadev/rte_dmadev.c | 12 ++++++++++++ lib/dmadev/rte_dmadev_pmd.h | 15 +++++++++++++++ lib/dmadev/version.map | 1 + 3 files changed, 28 insertions(+) diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index bf7d5ec519..d82464f0ca 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -121,6 +121,18 @@ dma_find_by_name(const char *name) return NULL; } +struct rte_dma_dev* +rte_dma_pmd_dev_get(uint8_t dev_id) +{ + if (rte_dma_devices == NULL || dev_id >= dma_devices_max) + return NULL; + + if (rte_dma_devices[dev_id].state == RTE_DMA_DEV_UNUSED) + return NULL; + + return &rte_dma_devices[dev_id]; +} + static void dma_fp_object_dummy(struct rte_dma_fp_object *obj); static int diff --git a/lib/dmadev/rte_dmadev_pmd.h b/lib/dmadev/rte_dmadev_pmd.h index c61cedfb23..b1f50c3931 100644 --- a/lib/dmadev/rte_dmadev_pmd.h +++ b/lib/dmadev/rte_dmadev_pmd.h @@ -167,6 +167,21 @@ 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. + * + * @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_dev_get(uint8_t dev_id); + #ifdef __cplusplus } #endif diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map index 7031d6b335..22aaa73419 100644 --- a/lib/dmadev/version.map +++ b/lib/dmadev/version.map @@ -25,6 +25,7 @@ INTERNAL { rte_dma_fp_objs; rte_dma_pmd_allocate; + rte_dma_pmd_dev_get; rte_dma_pmd_release; local: *;