From patchwork Mon Jan 10 05:19:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12708228 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DEF6C433F5 for ; Mon, 10 Jan 2022 05:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233367AbiAJF1J (ORCPT ); Mon, 10 Jan 2022 00:27:09 -0500 Received: from mga01.intel.com ([192.55.52.88]:9535 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238719AbiAJF05 (ORCPT ); Mon, 10 Jan 2022 00:26:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641792417; x=1673328417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ioRk7cwXbBNQJIQEP8s7EVvCPiqFelLbAYEXA+lwOtU=; b=HxcrfeQNEvh5Rot0B4VkbW5Wo1HPx9YTVMj4pSjDo8WZU86cX8PILWZJ JoDHkYt4l/vR0tppgzFGbCLLF9UvVDvObEmbn+Fj2u6tn9CL9zWwsSkBr Mnwberf9W1LnsZUjURTiIhq6aSkOvFfhd4kgc2ZCP16HMAsJ/CSf7Bbyq uDvzPDbZzwk11k2x4wsNXFi6nNQP7T6kdbph/x9UVH0PbVGTn0LQOTUxz 9F7ZK6/55bDSlI0GZYEZQLYVKpas0Yv8p++nmcM0YiplYOKxBbNSB5Ohg VHYAb1RwYjs2BPcUPRkU6XungpCoxM79jFAbf5n1FiLF+sRMoD1KI9F4H A==; X-IronPort-AV: E=McAfee;i="6200,9189,10222"; a="267479510" X-IronPort-AV: E=Sophos;i="5.88,276,1635231600"; d="scan'208";a="267479510" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2022 21:26:57 -0800 X-IronPort-AV: E=Sophos;i="5.88,276,1635231600"; d="scan'208";a="489892284" Received: from unknown (HELO cra01infra01.deacluster.intel.com) ([10.240.193.73]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2022 21:26:55 -0800 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, Zhu Lingshan Subject: [PATCH 3/7] vDPA/ifcvf: implement device MSIX vector allocation helper Date: Mon, 10 Jan 2022 13:19:43 +0800 Message-Id: <20220110051947.84901-4-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220110051947.84901-1-lingshan.zhu@intel.com> References: <20220110051947.84901-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This commit implements a MSIX vector allocation helper Signed-off-by: Zhu Lingshan --- drivers/vdpa/ifcvf/ifcvf_main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index 6dc75ca70b37..64fc78eaa1a9 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -58,6 +58,30 @@ static void ifcvf_free_irq(struct ifcvf_adapter *adapter, int queues) ifcvf_free_irq_vectors(pdev); } +static int ifcvf_alloc_vectors(struct ifcvf_adapter *adapter) +{ + struct pci_dev *pdev = adapter->pdev; + struct ifcvf_hw *vf = &adapter->vf; + u16 max_intr = 0; + u16 ret = 0; + + /* all queues and config interrupt */ + max_intr = vf->nr_vring + 1; + ret = pci_alloc_irq_vectors(pdev, 1, max_intr, PCI_IRQ_MSIX|PCI_IRQ_AFFINITY); + + if (ret < 0) { + IFCVF_ERR(pdev, "Failed to alloc IRQ vectors\n"); + return ret; + } + + if (ret < max_intr) + IFCVF_INFO(pdev, + "Requested %u vectors, however only %u allocated, lower performance\n", + max_intr, ret); + + return ret; +} + static int ifcvf_request_irq(struct ifcvf_adapter *adapter) { struct pci_dev *pdev = adapter->pdev;