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 EBA2DA0560;
	Tue, 18 Oct 2022 08:23:54 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3E9C4427EA;
	Tue, 18 Oct 2022 08:23:45 +0200 (CEST)
Received: from mga12.intel.com (mga12.intel.com [192.55.52.136])
 by mails.dpdk.org (Postfix) with ESMTP id 0E7694161A
 for <dev@dpdk.org>; Tue, 18 Oct 2022 08:23:43 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1666074224; x=1697610224;
 h=from:to:cc:subject:date:message-id:in-reply-to: references;
 bh=u6gMBbApdXSB3Ld3Jjg3QEGS4spcCcxNroeYHYyn54Q=;
 b=Jz4m3nqnDKYlKkbk/4SRERcrwVqgmG99SBKkYHIbGwzJVjIWdtpgPm66
 UmLNOqQC64WcpjyAF6bTN8aDH+aK2sEEJaq84Bu7Cyw3bjrY7YsvKbQeS
 SxRmfLeMh4x5QkIVZaSwVo6MfwgbqFSsSO/iD5NdUstEuts9PB/+Rwuxe
 GTxR0otXuAFZL/0bNHBPmSddboOqkgbdyw2DIsVqqQJD7RmA0fC4NSSW5
 gHcxb8OrpAVOF/Mlusvj5urQJDyimoMo7mkYE0vojU3Gak1ft+ANg72vg
 tySx/+Ge2QFoLqJGIZHnHAUP9Se490pmQnZnGS++Ml+S5PyY0jReuZunu Q==;
X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="285732765"
X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="285732765"
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 17 Oct 2022 23:23:40 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="659655841"
X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="659655841"
Received: from dpdk-dipei.sh.intel.com ([10.67.110.251])
 by orsmga008.jf.intel.com with ESMTP; 17 Oct 2022 23:23:38 -0700
From: Andy Pei <andy.pei@intel.com>
To: dev@dpdk.org
Cc: chenbo.xia@intel.com, rosen.xu@intel.com, wei.huang@intel.com,
 gang.cao@intel.com, maxime.coquelin@redhat.com
Subject: [PATCH v7 05/12] vdpa/ifc: only configure enabled queue
Date: Tue, 18 Oct 2022 14:19:30 +0800
Message-Id: <1666073977-175484-6-git-send-email-andy.pei@intel.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1666073977-175484-1-git-send-email-andy.pei@intel.com>
References: <1661229305-240952-2-git-send-email-andy.pei@intel.com>
 <1666073977-175484-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

When configuring the hardware queue, we only configure queues which
have been enabled by vhost.

Signed-off-by: Andy Pei <andy.pei@intel.com>
Signed-off-by: Huang Wei <wei.huang@intel.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
---
 drivers/vdpa/ifc/base/ifcvf.c |  3 +++
 drivers/vdpa/ifc/ifcvf_vdpa.c | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
index b377126..30bb8cb 100644
--- a/drivers/vdpa/ifc/base/ifcvf.c
+++ b/drivers/vdpa/ifc/base/ifcvf.c
@@ -252,6 +252,9 @@
 
 	ifcvf_enable_mq(hw);
 	for (i = 0; i < hw->nr_vring; i++) {
+		if (!hw->vring[i].enable)
+			continue;
+
 		IFCVF_WRITE_REG16(i, &cfg->queue_select);
 		io_write64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo,
 				&cfg->queue_desc_hi);
diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 5a24204..0c3407a 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -284,6 +284,8 @@ struct rte_vdpa_dev_info {
 	rte_vhost_get_negotiated_features(vid, &hw->req_features);
 
 	for (i = 0; i < nr_vring; i++) {
+		if (!hw->vring[i].enable)
+			continue;
 		rte_vhost_get_vhost_vring(vid, i, &vq);
 		gpa = hva_to_gpa(vid, (uint64_t)(uintptr_t)vq.desc);
 		if (gpa == 0) {
@@ -499,6 +501,8 @@ struct rte_vdpa_dev_info {
 
 	vring.kickfd = -1;
 	for (qid = 0; qid < q_num; qid++) {
+		if (!hw->vring[qid].enable)
+			continue;
 		ev.events = EPOLLIN | EPOLLPRI;
 		rte_vhost_get_vhost_vring(internal->vid, qid, &vring);
 		ev.data.u64 = qid | (uint64_t)vring.kickfd << 32;
@@ -1058,6 +1062,8 @@ struct rte_vdpa_dev_info {
 	struct rte_vdpa_device *vdev;
 	struct internal_list *list;
 	struct ifcvf_internal *internal;
+	struct ifcvf_hw *hw;
+	uint16_t i;
 
 	vdev = rte_vhost_get_vdpa_device(vid);
 	list = find_internal_resource_by_vdev(vdev);
@@ -1071,11 +1077,17 @@ struct rte_vdpa_dev_info {
 	rte_atomic32_set(&internal->dev_attached, 1);
 	update_datapath(internal);
 
-	if (rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true) != 0)
-		DRV_LOG(NOTICE, "vDPA (%s): software relay is used.",
+	hw = &internal->hw;
+	for (i = 0; i < hw->nr_vring; i++) {
+		if (!hw->vring[i].enable)
+			continue;
+		if (rte_vhost_host_notifier_ctrl(vid, i, true) != 0)
+			DRV_LOG(NOTICE, "vDPA (%s): software relay is used.",
 				vdev->device->name);
+	}
 
 	internal->configured = 1;
+	DRV_LOG(INFO, "vDPA device %s is configured", vdev->device->name);
 	return 0;
 }
 
-- 
1.8.3.1