From nobody Tue Sep 22 19:46:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585731; cv=none; d=zohomail.com; s=zohoarc; b=gOMKO0JfpHSxhnz09eCZtkN1knoDk41w8mstowAsvzzDbgYkOEVyDdhK7GODBk5e9u3wKMTQNrHKYNMVFG3nbTQOj87RtyZZo9PEHUg9Bc24IWGml0yWtl1P1P9Hm4SrhxVRkkEkbfm5b1IP42FVLtb20pkxMLEXMKxH6HzzfIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585731; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jnSLmeLJV6kE0iVS5+3SJmFGhHsRiD3c0F7TGZf1V5w=; b=BagKM3/a9Afs1z1uDrqEg+97N/DH9YK9yMPKTCrEhNSSxZidi4Y3POK7EXpT8/l1VwiwV1PjkZwEhi2R1wcENof2vDNQirnoOCG/qoPfpzQzVPg1McuISLau/q9uwwKbunJEfhXQZm4tDCFw5vK3qKAYi9DcaHFtzkygeJFmWa8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585731250357.5204379439525; Thu, 4 Jun 2026 08:08:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328016.1592683 (Exim 4.92) (envelope-from ) id 1wV9gA-0004ub-DE; Thu, 04 Jun 2026 15:08:18 +0000 Received: by outflank-mailman (output) from mailman id 1328016.1592683; Thu, 04 Jun 2026 15:08:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gA-0004u3-7s; Thu, 04 Jun 2026 15:08:18 +0000 Received: by outflank-mailman (input) for mailman id 1328016; Thu, 04 Jun 2026 15:02:00 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9a4-00042c-BJ for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:00 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9a3-001rSt-OC for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:01:59 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219360-2eae-0a2a0a5409dd-0a2a4507c166-22 for ; Thu, 04 Jun 2026 17:01:59 +0200 Received: from [209.85.215.175] (helo=mail-pg1-f175.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a219365-229c-0a2a45070019-d155d7afc424-3 for ; Thu, 04 Jun 2026 17:01:59 +0200 Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-c85ba774551so327339a12.0 for ; Thu, 04 Jun 2026 08:01:58 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:5e::]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85df0bdbe4sm5661594a12.32.2026.06.04.08.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:01:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585317; x=1781190117; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jnSLmeLJV6kE0iVS5+3SJmFGhHsRiD3c0F7TGZf1V5w=; b=iJ1YGbqoa8QOMwaWUrkdZORVJR6dj/LiNaQRp8CVVAEzaHuNhmZiPE3z1Mmk0/Hjgi E/p+xnWqmcJ5/o2YExAjA7nMYPPyk7SZGqqPhaLLfyK9ULrwec6b3USG8tewMeuxkVcN 92hXBlUmqDx/lU6LekzhC3Utn+vkn8LTujDJx3j98TD5tJk+ABnhNJcvlfc0Hk6XgSqs Hk9+iuhzlkO2Sutk1FlGdBnPtp7A/89TrzTqasfwF7VqCixbxJkL9AEl0Bci/eg6sFIq C4c/9NcRx6nRDS2C0xK96SnFJ87o0P9Hm40TRmICbJXCxf+7R1m2OOIKATgyIFEvvXa2 f5gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585317; x=1781190117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jnSLmeLJV6kE0iVS5+3SJmFGhHsRiD3c0F7TGZf1V5w=; b=BJHTgApGjPvDQNPlNWEjXZ5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05:6a21:6083:b0:3a3:a9c4:3d60 with SMTP id adf61e73a8af0-3b4975cdbe8mr9228482637.27.1780585316708; Thu, 04 Jun 2026 08:01:56 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 01/12] PCI: Add helpers to identify SR-IOV PFs/VFs. Date: Thu, 4 Jun 2026 08:01:42 -0700 Message-ID: <20260604150153.3619662-2-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1780585319-0956BC48-CEA36D05/0/0 X-purgate-type: clean X-purgate-size: 1975 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585733221154100 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis Throughout core the pci_dev attribute is_physfn is used to determine whether or not a PF has SR-IOV active. And is_virtfn is used to check if a device is a SR-IOV VF. These attributes should be generalized to represent PFs/VFs for any type of virtualization. So in preparation, wrap the existing usage in helpers and use helpers in subsequent patches to ease the transition. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- include/linux/pci.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 2c4454583c11..28892243f49f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -604,6 +604,16 @@ static inline struct pci_dev *pci_physfn(struct pci_de= v *dev) return dev; } =20 +static inline bool pci_is_sriov_physfn(const struct pci_dev *dev) +{ + return dev->is_physfn; +} + +static inline bool pci_is_sriov_virtfn(const struct pci_dev *dev) +{ + return dev->is_virtfn; +} + struct pci_dev *pci_alloc_dev(struct pci_bus *bus); =20 #define to_pci_dev(n) container_of(n, struct pci_dev, dev) @@ -1277,6 +1287,7 @@ void pcibios_setup_bridge(struct pci_bus *bus, unsign= ed long type); void pci_sort_breadthfirst(void); #define dev_is_pci(d) ((d)->bus =3D=3D &pci_bus_type) #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false)) +#define dev_is_sriov_pf(d) ((dev_is_pci(d) ? pci_is_sriov_physfn(to_pci_de= v(d)) : false)) =20 /* Generic PCI functions exported to card drivers */ =20 @@ -2207,6 +2218,7 @@ static inline struct pci_dev *pci_dev_get(struct pci_= dev *dev) { return NULL; } =20 #define dev_is_pci(d) (false) #define dev_is_pf(d) (false) +#define dev_is_sriov_pf(d) (false) static inline bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags) { return false; } static inline int pci_irqd_intx_xlate(struct irq_domain *d, --=20 2.52.0