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 38FC845ADF; Tue, 8 Oct 2024 09:40:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1601E4042E; Tue, 8 Oct 2024 09:40:16 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 26BFB402D4 for ; Tue, 8 Oct 2024 09:40:15 +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 49835Rea025296; Tue, 8 Oct 2024 00:40:10 -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=P SK7Q2mHUXM+s7Fvx+1eKb88zzKIv5ACJEkr4NSBmWg=; b=isWHtGLOi5aVVQLqu LLzVO8/DA0JrwbTtfMOUiNNszOG9dp8DNSxBvnMDDSidGcR3ZPgmSiubacrSxHOy sdvfJXipliJM6Lme6Y3ujKVSrEKcz5cdskM6I+OG33EE9XeAqWfYtfGo+JgO1KFg IJp3mplSxYEvEz1FrdPVqRaNp2f7xzIWb0EL92xYCFMkV+hsyUoco+w7U49g0rc9 M6fWcDAY0b08Vqk9Ku1r7b34UI4tjXWq+rGPnQu2N15vZ3wgCFsd+Tho/g0kv6FA E9UbXIWF3aDP+F8nqcgDRjbueN42o9GYD2uZaUKbTXHXcVz69bXaU1kw0ncEyZ5q 30owA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 424vg88e77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 00:40:09 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 8 Oct 2024 00:40:08 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 8 Oct 2024 00:40:08 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id EAE363F705D; Tue, 8 Oct 2024 00:40:05 -0700 (PDT) From: Akhil Goyal To: CC: , , , , Akhil Goyal Subject: [PATCH v2] rawdev: add API to get device from index Date: Tue, 8 Oct 2024 13:10:00 +0530 Message-ID: <20241008074000.3745855-1-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-2-gakhil@marvell.com> References: <20240907193311.1342310-2-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: iTE5aPhBzjWPi5GjlZFvyN_STZbfzcM3 X-Proofpoint-GUID: iTE5aPhBzjWPi5GjlZFvyN_STZbfzcM3 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 --- - resend patch for main branch separated from rvu_lf raw driver https://patches.dpdk.org/project/dpdk/list/?series=32949 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