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 6F24245931; Sat, 7 Sep 2024 21:33:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 258364060A; Sat, 7 Sep 2024 21:33:23 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A8F6640395 for ; Sat, 7 Sep 2024 21:33:21 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 487JRrD7028682; Sat, 7 Sep 2024 12:33:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=l c1pzOA4RYQkjhhdgtR/UPnMuXI0hrCZbvQ4311NYec=; b=h6Y+4eaSEUZaw6VaM PHdzykgwa2vqBs5riuMrZRjCrJDNgQUh/68gm0uRBZJjMk04mgAofXLpc7/zaqz9 ih0UcAd+aKJi45SNayHImCUqbBdLYDZTFNo+AoRFa2oSkgrl+JQP3FVYo+TR5TBH SY8kH7DIDUL0d2f6F8ECyoi3RabNoykFeb7hCfzS4n9LE0NexPcvEQi4XFTihA8r JtusMyyN3toYafg9cT7w/VURt1yPlhCimKiFKTJUTN5VYwGVvTugwyOgHr4bLOD2 dWmeFjRiMpbuO9lyCJVSyqaAUv5vXXmTXEQOFqU2goy+5T42HIl10ghotBe6ygKv TTqGw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41gpbf8km3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:20 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 7 Sep 2024 12:33:19 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Sat, 7 Sep 2024 12:33:19 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id CCF163F707A; Sat, 7 Sep 2024 12:33:16 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 1/9] rawdev: add API to get device from index Date: Sun, 8 Sep 2024 01:03:03 +0530 Message-ID: <20240907193311.1342310-2-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: uvNdI1F3Hiv3db_c7ulRIw7xWrLd82Gf X-Proofpoint-ORIG-GUID: uvNdI1F3Hiv3db_c7ulRIw7xWrLd82Gf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 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 Added an internal API for PMDs to get raw device pointer from a device id. Signed-off-by: Akhil Goyal --- lib/rawdev/rte_rawdev_pmd.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h index 22b406444d..8339122348 100644 --- a/lib/rawdev/rte_rawdev_pmd.h +++ b/lib/rawdev/rte_rawdev_pmd.h @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name) return NULL; } +/** + * Get the rte_rawdev structure device pointer for given device ID. + * + * @param dev_id + * raw device index. + * + * @return + * - The rte_rawdev structure pointer for the given device ID. + */ +static inline struct rte_rawdev * +rte_rawdev_pmd_get_dev(uint8_t dev_id) +{ + struct rte_rawdev *dev; + + if (dev_id >= RTE_RAWDEV_MAX_DEVS) + return NULL; + + dev = &rte_rawdevs[dev_id]; + if (dev->attached == RTE_RAWDEV_ATTACHED) + return dev; + + return NULL; +} + /** * Validate if the raw device index is a valid attached raw device. * -- 2.25.1