From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 35C09A04FD;
	Mon, 23 May 2022 12:23:19 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id DA0F242B70;
	Mon, 23 May 2022 12:22:53 +0200 (CEST)
Received: from mga18.intel.com (mga18.intel.com [134.134.136.126])
 by mails.dpdk.org (Postfix) with ESMTP id DA19442B79
 for <dev@dpdk.org>; Mon, 23 May 2022 12:22:51 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1653301372; x=1684837372;
 h=from:to:cc:subject:date:message-id:in-reply-to: references;
 bh=Qu7juAmgtVYsisb6vCFxoUVwpeslaOFM73ygvAAh+tY=;
 b=IV1bnfdNQmQ4/0FWaUx7pSd/i3J7xiNXuSTVmDQfoxh0HRCDf2Nq778/
 q1BhE+D/6Seo7/pbE2u8aUTaYUSujA4go8z0hl9exFPGhbZ9tmuIyuRP1
 UFVCFZfh7/F2FwI1gTu6TeaxJw41yhk7Owp+A6do53UeNRLl+EfLo4MHl
 R/mRmOmNaHUuV02aC+kJC3oxQ0qmPg/J/dqWTGNeG9EjGh95Qr40lCuiw
 7j/WjJQgvc62EvdfRFHEdD5NNPiXmwyizNftGcfaYUZoYJ2fxmJxPFIBn
 DI7FwPXLluZtYmytyiJ2x5zMpG3Y4Gi/2/Fi9HofHRY1NIPv6rYBfIxkM g==;
X-IronPort-AV: E=McAfee;i="6400,9594,10355"; a="255239363"
X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="255239363"
Received: from orsmga006.jf.intel.com ([10.7.209.51])
 by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 23 May 2022 03:22:51 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="547889474"
Received: from dpdk-dipei.sh.intel.com ([10.67.110.238])
 by orsmga006.jf.intel.com with ESMTP; 23 May 2022 03:22:48 -0700
From: Andy Pei <andy.pei@intel.com>
To: dev@dpdk.org
Cc: chenbo.xia@intel.com, maxime.coquelin@redhat.com, gang.cao@intel.com,
 changpeng.liu@intel.com, rosen.xu@intel.com, qimaix.xiao@intel.com
Subject: [PATCH v9 08/13] vdpa/ifc: add get device type ops to ifc driver
Date: Mon, 23 May 2022 17:35:19 +0800
Message-Id: <1653298524-232138-9-git-send-email-andy.pei@intel.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1653298524-232138-1-git-send-email-andy.pei@intel.com>
References: <1643093258-47258-2-git-send-email-andy.pei@intel.com>
 <1653298524-232138-1-git-send-email-andy.pei@intel.com>
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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

Add get device type ops to ifc driver.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 7a0bdb4..1c5746a 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -1189,6 +1189,29 @@ struct rte_vdpa_dev_info {
 	return 0;
 }
 
+static int
+ifcvf_get_device_type(struct rte_vdpa_device *vdev,
+	uint32_t *type)
+{
+	struct ifcvf_internal *internal;
+	struct internal_list *list;
+
+	list = find_internal_resource_by_vdev(vdev);
+	if (list == NULL) {
+		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -1;
+	}
+
+	internal = list->internal;
+
+	if (internal->hw.device_type == IFCVF_BLK)
+		*type = RTE_VHOST_VDPA_DEVICE_TYPE_BLK;
+	else
+		*type = RTE_VHOST_VDPA_DEVICE_TYPE_NET;
+
+	return 0;
+}
+
 static struct rte_vdpa_dev_ops ifcvf_net_ops = {
 	.get_queue_num = ifcvf_get_queue_num,
 	.get_features = ifcvf_get_vdpa_features,
@@ -1201,6 +1224,7 @@ struct rte_vdpa_dev_info {
 	.get_vfio_group_fd = ifcvf_get_vfio_group_fd,
 	.get_vfio_device_fd = ifcvf_get_vfio_device_fd,
 	.get_notify_area = ifcvf_get_notify_area,
+	.get_dev_type = ifcvf_get_device_type,
 };
 
 static inline int
@@ -1327,6 +1351,7 @@ struct rte_vdpa_dev_info {
 	.get_vfio_device_fd = ifcvf_get_vfio_device_fd,
 	.get_notify_area = ifcvf_get_notify_area,
 	.get_config = ifcvf_blk_get_config,
+	.get_dev_type = ifcvf_get_device_type,
 };
 
 struct rte_vdpa_dev_info dev_info[] = {
-- 
1.8.3.1