From nobody Thu Apr 2 01:54:50 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BAFA3E5562 for ; Tue, 3 Mar 2026 21:15:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772572554; cv=none; b=bISKPn+m36p/kWExO2mcW5CVjJGjmsDShGyRbr+DRHis4dChRoAwjRgBJC9H7p9knJKbQRFqD2HSyAMBuSYRMtXQEYzUulxWNj+gjl1a2SRx5BxqTWyNBfhFZM0i8/zKi9zOKhjjFN5504dnv/dNq9J/BXf3yZorowCcg/G6VCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772572554; c=relaxed/simple; bh=njU3I9YW/zDKjP+0RxMLdIuH1MmdjiC7YPBjwAwiJ4w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uHCwTxpltzq0lpq2CMKsHXI7gBcE2z7DKTRHg5+x0x3SMyQBS/uAAF4IUtEfsWyx6VQijp1oDEJgMzW3E8A2bqN2g2J0OwPlT0uHhoWfcAr/wfW4rEdBoxG7Tr5wEmbkzCPJtMWOBYox/QQI9a6WW8GHCm+NFHQP7Iv/gBO1ymM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dwcPEOXW; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=BwmBIwlY; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dwcPEOXW"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="BwmBIwlY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772572551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nsl81xXoWOrG7fZ6D3nnOVMYFTWE73QzzhAJNIpS3Uk=; b=dwcPEOXWn4opOtp5G4RGm5qe6Qz8rm7pfGdh0iMeUmwtKZG1yxHkIjnz/6sJhozPAg+jGw BPhmntvzfQDpKMFQMutl5w4Jxup0LEhbRpr7gCvdTgViYsgeXzt/BoyBXL0C3zI7P4NxJL YVXY5CJRUTZn9VOUgJbM7LkXFNyw/XU= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-59-oztYZ0TCMrGHZuGN68z-Zw-1; Tue, 03 Mar 2026 16:15:50 -0500 X-MC-Unique: oztYZ0TCMrGHZuGN68z-Zw-1 X-Mimecast-MFC-AGG-ID: oztYZ0TCMrGHZuGN68z-Zw_1772572550 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-50340e2b4dfso653365131cf.3 for ; Tue, 03 Mar 2026 13:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1772572550; x=1773177350; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Nsl81xXoWOrG7fZ6D3nnOVMYFTWE73QzzhAJNIpS3Uk=; b=BwmBIwlYkgPM4nkteh9HIu+jXvgEbaJgWAQeo4P4bfoSxoTsSw2yHO4p/KeeRtmaFr OIBl1288NNGOuT5B3vU45YNr1CgHAImY3BNMyNOY9UInFpWDcJnsGYGYsfvai85jUyxf LcfJsOKvlKYcRYUTSa3YbLyJbvOV1OcCYDZxoL/qspwKphq8UEDAGDPMWFXdreO69EEB OUnRu4allFNpQ+kRiLMMqCxS9MMAeGFk4VP2w5Tnko6gVPcR0GVcquRUCtpNtNZsyt6s pELoOZ17E7il4HBJul69sT3fXRR7OFjvCy0V1zDO8Q7R5jBazfMIJEJl37jU3TcxoIz1 68Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772572550; x=1773177350; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Nsl81xXoWOrG7fZ6D3nnOVMYFTWE73QzzhAJNIpS3Uk=; b=FmsVETrp4vp+5+2TpSl9kricm06FMgk4qdr6vt1KiNoocyLEs00vk5z7lJa9HeovZm dGq8X62x5wSmIdqrYVljpb6VlTcRzW1OW697i263hUGGhEClokS9Qw4Aq2U0QqGKkmQB DUjOfU5NfBEL1sOARGz0Gk2HpBSWzZ8O77Wg2TvrBpkV9jewQGEU8Tkl12TNOTpRKPgd h9HsXhQNEOBM6jeccODOomIAE+udTEv6FqrQeSURT2QNzyEAhT7wS+2yk0t3KZh7NJrq zvTmDKYuoZMmrugUpb3mtwmAaYOXaYQTypcPs8nG4ie1jtW7n6oGYABj34BGPI0VZN60 Nrng== X-Forwarded-Encrypted: i=1; AJvYcCUdUsZUTvqWefclMpWtW5OH0XITLsHjWfFLr2qxcY52DIO3v1nZK19rHBGsjEILoNODQPmQA8ymMkSnNT8=@vger.kernel.org X-Gm-Message-State: AOJu0YxBh4i4FNZv/mqFwTvUx1wgNCmRdjNRh8HONTCHyf83bySpC1bC /E1O6rdP0tnmYPVrm15qnL+Nm10nt+hAi8ZmtRxlg7YRXg5ebHYio4C9tPIsC52QEtBlHCicl9I kKc7qpvyDWWqGqJJYxh/6aHk8I9vOUsVCLsJ4sPZSMxFvDU6LWOfmiS1QsaaKbf5Nbw== X-Gm-Gg: ATEYQzzxsevTOrHttXh4+ydXOfs4V9LObEbfLCccRaZxePtjMPAFOED+4IqTpA9uDsg tWsJsnLIS2cXvJBHNjf5baFcRgv+LPMadxcW0k3q1R74Qz79+Ckl6iscuIdJ0QLmccb0QFIbJve abr9ISmwM5yQ7DpT0oUgcL8NdXUVl2B2ctKvodcLH8YDQbS5HXBcb9UXj9JqdIUOm7k6ayf45z2 hHa0Brg21lQM7uRVEa67Gs1f2AR/JxcY8/E9J4h4LvdX8SmnK1Ik5MnriJ2+Jc/Ra11iU4plVW/ 31uYvP8awYUBIR2mpAXDB+mVKbNOhSpj0LefENoJX68S4Ucm04xdF0xx4jEqaEAEf9CGYr+cGnn cfhFJ0bKf6/61dPl9brttzOHhJg== X-Received: by 2002:a05:622a:1895:b0:4f1:ccea:6744 with SMTP id d75a77b69052e-507528db6e5mr222734381cf.58.1772572549555; Tue, 03 Mar 2026 13:15:49 -0800 (PST) X-Received: by 2002:a05:622a:1895:b0:4f1:ccea:6744 with SMTP id d75a77b69052e-507528db6e5mr222733911cf.58.1772572549028; Tue, 03 Mar 2026 13:15:49 -0800 (PST) Received: from [172.16.1.8] ([2607:f2c0:b1e3:9a00:3c7:56c2:f819:96d2]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5074481c0e5sm156286991cf.0.2026.03.03.13.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 13:15:47 -0800 (PST) From: Peter Colberg Date: Tue, 03 Mar 2026 16:15:28 -0500 Subject: [PATCH v3 08/10] rust: pci: add num_vf(), to return number of VFs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260303-rust-pci-sriov-v3-8-4443c35f0c88@redhat.com> References: <20260303-rust-pci-sriov-v3-0-4443c35f0c88@redhat.com> In-Reply-To: <20260303-rust-pci-sriov-v3-0-4443c35f0c88@redhat.com> To: Danilo Krummrich , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Abdiel Janulgue , Daniel Almeida , Robin Murphy , Greg Kroah-Hartman , Dave Ertman , Ira Weiny , Leon Romanovsky , David Airlie , Simona Vetter , Jonathan Corbet , Xu Yilun , Tom Rix , Moritz Fischer , "Rafael J. Wysocki" , Boqun Feng Cc: linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot , Alistair Popple , Joel Fernandes , John Hubbard , Zhi Wang , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-fpga@vger.kernel.org, driver-core@lists.linux.dev, Peter Colberg , Jason Gunthorpe X-Mailer: b4 0.14.2 Add a method to return the number of Virtual Functions (VF) enabled for a Physical Function (PF). Signed-off-by: Peter Colberg --- rust/kernel/pci.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index df39ad3f0d5fd898b034609efb03368f83c2a2e9..581930d0afe98ccc29d729e4d9a= ab75b4144e46c 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -498,6 +498,13 @@ pub fn is_virtfn(&self) -> bool { unsafe { (*self.as_raw()).is_virtfn() !=3D 0 } } =20 + /// Returns the number of Virtual Functions (VF) enabled for a Physica= l Function (PF). + #[cfg(CONFIG_PCI_IOV)] + pub fn num_vf(&self) -> i32 { + // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`. + unsafe { bindings::pci_num_vf(self.as_raw()) } + } + /// Returns the size of the given PCI BAR resource. pub fn resource_len(&self, bar: u32) -> Result { if !Bar::index_is_valid(bar) { --=20 2.53.0