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 561B0A00C2; Thu, 13 Oct 2022 10:48:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 763E742DDC; Thu, 13 Oct 2022 10:48:00 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id E5FA542DCC for ; Thu, 13 Oct 2022 10:47:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665650879; x=1697186879; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=7W8znKeYbDEr40Ux4RlbGj9iAxAIFzLDPHz6SHRcgz8=; b=TWoQZQlzu//XCaE2oNPfT/f8xagOwYF96eYzLo6iqOFiPXzudnAHBON3 MGLtXN1HdD3peFrIWlK/1gAClIBQrdYIA5KKbbYxXPkjcRVS+ESfGd/A+ 9D8RnAKBV7LnR7z+ABgql97SLut+9Jj9yKRihl4/hutE6p7LCViqdAKwZ ivpUz9udn6YwX+DL7qm2BgJIPMIuV09JGtTsOr7Widu3Dym/S/kLNnPGU mDl6itL42IOZAs2vZ/8hys1EYGbFLtHjEe3Xr45+LE1NMr/eJ2cxccBEK AQnLGDSdH0negfhi48qKSxJ5JGR4C5ngXkC29NyCubxQk1ntOotIaBUpc A==; X-IronPort-AV: E=McAfee;i="6500,9779,10498"; a="288292691" X-IronPort-AV: E=Sophos;i="5.95,180,1661842800"; d="scan'208";a="288292691" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2022 01:47:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10498"; a="658100415" X-IronPort-AV: E=Sophos;i="5.95,180,1661842800"; d="scan'208";a="658100415" Received: from dpdk-dipei.sh.intel.com ([10.67.110.251]) by orsmga008.jf.intel.com with ESMTP; 13 Oct 2022 01:47:55 -0700 From: Andy Pei 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 v4 3/8] vdpa/ifc: set max queues based on virtio spec Date: Thu, 13 Oct 2022 16:44:29 +0800 Message-Id: <1665650674-291949-4-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1665650674-291949-1-git-send-email-andy.pei@intel.com> References: <1661229305-240952-2-git-send-email-andy.pei@intel.com> <1665650674-291949-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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Set max_queues according to virtio spec. For virtio BLK device, set max_queues to the value of num_queues in struct virtio_blk_config For virtio NET device, read num_queues from struct ifcvf_pci_common_cfg, get the queue pair number using num_queues and set max_queues to it. Signed-off-by: Andy Pei Signed-off-by: Huang Wei --- drivers/vdpa/ifc/base/ifcvf.h | 2 +- drivers/vdpa/ifc/ifcvf_vdpa.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.h index d16d9ab..1e133c0 100644 --- a/drivers/vdpa/ifc/base/ifcvf.h +++ b/drivers/vdpa/ifc/base/ifcvf.h @@ -21,7 +21,7 @@ #define IFCVF_SUBSYS_NET_DEVICE_ID 0x0001 #define IFCVF_SUBSYS_BLK_DEVICE_ID 0x0002 -#define IFCVF_MAX_QUEUES 1 +#define IFCVF_MAX_QUEUES 32 #ifndef VIRTIO_F_IOMMU_PLATFORM #define VIRTIO_F_IOMMU_PLATFORM 33 diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index 008cf89..5a24204 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -26,6 +26,12 @@ #include "base/ifcvf.h" +/* + * RTE_MIN() cannot be used since braced-group within expression allowed + * only inside a function. + */ +#define MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2)) + RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.vdpa.ifcvf, NOTICE); #define DRV_LOG(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \ @@ -1512,6 +1518,7 @@ struct rte_vdpa_dev_info dev_info[] = { uint64_t capacity = 0; uint8_t *byte; uint32_t i; + uint16_t queue_pairs; if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; @@ -1559,7 +1566,6 @@ struct rte_vdpa_dev_info dev_info[] = { } internal->configured = 0; - internal->max_queues = IFCVF_MAX_QUEUES; features = ifcvf_get_features(&internal->hw); device_id = ifcvf_pci_get_device_type(pci_dev); @@ -1570,6 +1576,14 @@ struct rte_vdpa_dev_info dev_info[] = { if (device_id == VIRTIO_ID_NET) { internal->hw.device_type = IFCVF_NET; + /* + * ifc device always has CTRL_VQ, + * and supports VIRTIO_NET_F_CTRL_VQ feature. + */ + queue_pairs = (internal->hw.common_cfg->num_queues - 1) / 2; + DRV_LOG(INFO, "%s support %u queue pairs", pci_dev->name, + queue_pairs); + internal->max_queues = MIN(IFCVF_MAX_QUEUES, queue_pairs); internal->features = features & ~(1ULL << VIRTIO_F_IOMMU_PLATFORM); internal->features |= dev_info[IFCVF_NET].features; @@ -1609,6 +1623,9 @@ struct rte_vdpa_dev_info dev_info[] = { internal->hw.blk_cfg->geometry.sectors); DRV_LOG(DEBUG, "num_queues: 0x%08x", internal->hw.blk_cfg->num_queues); + + internal->max_queues = MIN(IFCVF_MAX_QUEUES, + internal->hw.blk_cfg->num_queues); } list->internal = internal; -- 1.8.3.1