From nobody Fri Dec 19 00:32:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1640097505619694.2630855131375; Tue, 21 Dec 2021 06:38:25 -0800 (PST) Received: from localhost ([::1]:37036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzgHY-0008EQ-EP for importer@patchew.org; Tue, 21 Dec 2021 09:38:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzgE0-0000D3-Lg; Tue, 21 Dec 2021 09:34:44 -0500 Received: from mga17.intel.com ([192.55.52.151]:6387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzgDy-0002Pf-Sc; Tue, 21 Dec 2021 09:34:44 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2021 06:34:39 -0800 Received: from lmaniak-dev.igk.intel.com ([10.55.249.72]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2021 06:34:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640097282; x=1671633282; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+tVJrRKbVrsdnOGHPnQkFqVb6d9sHTTuQGLqwO4otaE=; b=YkTaOAyD5sHdLWZ0PI3gIDSyA6NWeiB790/qrVa1XOR5KFI44QiTrUxw P+3Anlv/tz8ZnqjVYbhRL2jjLl/WLGUCoPcXbPHHatEXzq29UAqDIGo5e WYsQQb4Ck6D8DaEMv+sSTSpO1rzSd4sjOcD4Xrl/SyuAzIBbAlPuRY2BP mpgqSLqniUouM8jWwitt8u8tP172Okgo9dKetupY66afj/sp2nbm03EVE zmoISRI/ZLzxvD0stmJ1+JxWw3wrCLcpa+wywIApGupafL9Brs2UASBWs 9W+Ezyg2HijIUTVWnkp8MWiXQ6Ie4WIe0rxJIWGxeW6gEUfIUApgcOT1a g==; X-IronPort-AV: E=McAfee;i="6200,9189,10204"; a="221079237" X-IronPort-AV: E=Sophos;i="5.88,223,1635231600"; d="scan'208";a="221079237" X-IronPort-AV: E=Sophos;i="5.88,223,1635231600"; d="scan'208";a="484429213" From: Lukasz Maniak To: qemu-devel@nongnu.org Subject: [PATCH v3 03/15] pcie: Add a helper to the SR/IOV API Date: Tue, 21 Dec 2021 15:32:34 +0100 Message-Id: <20211221143246.2052050-4-lukasz.maniak@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221143246.2052050-1-lukasz.maniak@linux.intel.com> References: <20211221143246.2052050-1-lukasz.maniak@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=192.55.52.151; envelope-from=lukasz.maniak@linux.intel.com; helo=mga17.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-block@nongnu.org, "Michael S. Tsirkin" , =?UTF-8?q?=C5=81ukasz=20Gieryk?= , Lukasz Maniak , Keith Busch , Klaus Jensen , Knut Omang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1640097507115100001 From: =C5=81ukasz Gieryk Convenience function for retrieving the PCIDevice object of the N-th VF. Signed-off-by: =C5=81ukasz Gieryk Reviewed-by: Knut Omang --- hw/pci/pcie_sriov.c | 10 +++++++++- include/hw/pci/pcie_sriov.h | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 501a1ff433..be8c907e06 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -280,8 +280,16 @@ uint16_t pcie_sriov_vf_number(PCIDevice *dev) return dev->exp.sriov_vf.vf_number; } =20 - PCIDevice *pcie_sriov_get_pf(PCIDevice *dev) { return dev->exp.sriov_vf.pf; } + +PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n) +{ + assert(!pci_is_vf(dev)); + if (n < dev->exp.sriov_pf.num_vfs) { + return dev->exp.sriov_pf.vf[n]; + } + return NULL; +} diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 0974f00054..cd2aebd3a6 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -64,4 +64,9 @@ uint16_t pcie_sriov_vf_number(PCIDevice *dev); */ PCIDevice *pcie_sriov_get_pf(PCIDevice *dev); =20 +/* Get the n-th VF of this physical function - only valid for PF. + * Returns NULL if index is invalid + */ +PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n); + #endif /* QEMU_PCIE_SRIOV_H */ --=20 2.25.1