From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 7844FA04F1;
	Sun,  8 Dec 2019 12:55:52 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 01EE61BE83;
	Sun,  8 Dec 2019 12:55:46 +0100 (CET)
Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com
 [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 8CB841BE83
 for <dev@dpdk.org>; Sun,  8 Dec 2019 12:55:44 +0100 (CET)
Received: from pps.filterd (m0045849.ppops.net [127.0.0.1])
 by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id
 xB8BpXxH006265; Sun, 8 Dec 2019 03:55:43 -0800
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=pfpt0818;
 bh=8ub6eZ/SYyu2YScDsBBFEG4ZESKG1hp9f1Q6PDcURvM=;
 b=O8ENEJKqdq3dzteIc9AwVnOQFgadQ3AUFS5Dl4cv9ej72CwoTO/I0ZjPfZeal6fVR1v8
 iUH0Wcgbul5UHiUpOShjiz4/hYaTXfue2i5W/P6N2YpHPj8B+7KQLU8gf16se/nxoRXV
 92Q58hRGfGDarYSS+6hi09E+b8RB0jN5ymxwOD0KWgmY+Ux+/jgZoyHiaMwaZx5RYhzu
 f9M0+imAkyqPbFpcX7QfUKVmoAeOnStHYMdBciBMQDQ4w3butmA1/XuJQnxNwu86dG/j
 P5xvgvLXd2bsWwhnvAAHia4MxTp6/8KCcCmQl9n//mk8/1ObBgo5t7AHDI/581ldKM7n PA== 
Received: from sc-exch03.marvell.com ([199.233.58.183])
 by mx0a-0016f401.pphosted.com with ESMTP id 2wrbawjj1v-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Sun, 08 Dec 2019 03:55:43 -0800
Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com
 (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 8 Dec
 2019 03:55:42 -0800
Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com
 (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend
 Transport; Sun, 8 Dec 2019 03:55:42 -0800
Received: from ajoseph83.caveonetworks.com.com (unknown [10.29.45.60])
 by maili.marvell.com (Postfix) with ESMTP id 8E2533F703F;
 Sun,  8 Dec 2019 03:55:37 -0800 (PST)
From: Anoob Joseph <anoobj@marvell.com>
To: Akhil Goyal <akhil.goyal@nxp.com>, Declan Doherty
 <declan.doherty@intel.com>, Thomas Monjalon <thomas@monjalon.net>
CC: Vamsi Attunuru <vattunuru@marvell.com>, Jerin Jacob <jerinj@marvell.com>, 
 Narayana Prasad <pathreya@marvell.com>, Kiran Kumar K
 <kirankumark@marvell.com>, Nithin Dabilpuram <ndabilpuram@marvell.com>,
 "Pavan Nikhilesh" <pbhagavatula@marvell.com>, Ankur Dwivedi
 <adwivedi@marvell.com>, Anoob Joseph <anoobj@marvell.com>,
 Archana Muniganti <marchana@marvell.com>,
 Tejasree Kondoj <ktejasree@marvell.com>, Lukasz
 Bartosik <lbartosik@marvell.com>, <dev@dpdk.org>
Date: Sun, 8 Dec 2019 17:24:41 +0530
Message-ID: <1575806094-28391-3-git-send-email-anoobj@marvell.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1575806094-28391-1-git-send-email-anoobj@marvell.com>
References: <1575806094-28391-1-git-send-email-anoobj@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572
 definitions=2019-12-08_03:2019-12-05,2019-12-08 signatures=0
Subject: [dpdk-dev] [PATCH 02/15] common/octeontx2: add routine to check if
	rte_eth_dev belongs to otx2
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

From: Vamsi Attunuru <vattunuru@marvell.com>

This routine returns true if given rte_eth_dev belongs to octeontx2

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
---
 drivers/common/octeontx2/otx2_common.c               | 20 ++++++++++++++++++++
 drivers/common/octeontx2/otx2_common.h               |  2 ++
 .../octeontx2/rte_common_octeontx2_version.map       |  1 +
 3 files changed, 23 insertions(+)

diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
index 7e45366..116db0f 100644
--- a/drivers/common/octeontx2/otx2_common.c
+++ b/drivers/common/octeontx2/otx2_common.c
@@ -3,6 +3,7 @@
  */
 
 #include <rte_atomic.h>
+#include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_log.h>
 
@@ -23,6 +24,25 @@ otx2_npa_set_defaults(struct otx2_idev_cfg *idev)
 
 /**
  * @internal
+ * Check if rte_eth_dev is otx2_eth_dev
+ */
+uint8_t
+otx2_is_ethdev(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+
+	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+
+	if (pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_PF ||
+	    pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_VF ||
+	    pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_AF_VF)
+		return 1;
+
+	return 0;
+}
+
+/**
+ * @internal
  * Get intra device config structure.
  */
 struct otx2_idev_cfg *
diff --git a/drivers/common/octeontx2/otx2_common.h b/drivers/common/octeontx2/otx2_common.h
index f62c45d..d32e59a 100644
--- a/drivers/common/octeontx2/otx2_common.h
+++ b/drivers/common/octeontx2/otx2_common.h
@@ -8,6 +8,7 @@
 #include <rte_atomic.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
+#include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
 #include <rte_io.h>
@@ -70,6 +71,7 @@ struct otx2_idev_cfg *otx2_intra_dev_get_cfg(void);
 void otx2_sso_pf_func_set(uint16_t sso_pf_func);
 uint16_t otx2_sso_pf_func_get(void);
 uint16_t otx2_npa_pf_func_get(void);
+uint8_t otx2_is_ethdev(struct rte_eth_dev *eth_dev);
 struct otx2_npa_lf *otx2_npa_lf_obj_get(void);
 void otx2_npa_set_defaults(struct otx2_idev_cfg *idev);
 int otx2_npa_lf_active(void *dev);
diff --git a/drivers/common/octeontx2/rte_common_octeontx2_version.map b/drivers/common/octeontx2/rte_common_octeontx2_version.map
index adad21a..dac2283 100644
--- a/drivers/common/octeontx2/rte_common_octeontx2_version.map
+++ b/drivers/common/octeontx2/rte_common_octeontx2_version.map
@@ -6,6 +6,7 @@ DPDK_20.0 {
 	otx2_dev_priv_init;
 	otx2_disable_irqs;
 	otx2_intra_dev_get_cfg;
+	otx2_is_ethdev;
 	otx2_logtype_base;
 	otx2_logtype_dpi;
 	otx2_logtype_mbox;
-- 
2.7.4