From nobody Tue Dec 2 02:29:53 2025 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 E44EC320CC2 for ; Wed, 19 Nov 2025 22:19:26 +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=1763590769; cv=none; b=O3D3VVgKFb3n8QQqSjs1LlSiFkf5aLFuAQXV0W8Z2XVaOaDS9kqR0MIBSvBswLAzH5SIE059IwQ0qbpXJoFbNhUWb+EzrWRrCKKaMlhV/COlUMD2QNnCpab+dqUppC5q6Lwm3i5+dffEf+vxjszj7MNg61z5JW5dfrTPZZ/z+IY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763590769; c=relaxed/simple; bh=96vzRx7vAI2mBmrVDn/9P0AmXFPaMNtBzGQHfEQkyQc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e1KwM/Ef7YemsNuFI/zXF+bqOxJiYdNRQlusqKxjmGVs8XEMuY/9RorcKdGFMtLDezuJXiBYJ/8JfzOffbr7yJti9AJbEmXsT5ZAQxcotLUB1qUtbESI/m3LsqUqhEPMS1vxc94MZ/Igo36kzy1WM9OFK3csuiw/XAwX4/GUlFg= 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=IhjRSaSW; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Bli+iDJg; 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="IhjRSaSW"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Bli+iDJg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763590765; 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=s8tI4EYN4JDf7RLWnoc2eVOO/7lGndZZgrSr2xQc/es=; b=IhjRSaSWjamIEIDgZTlE+xxRbx0fvouWbOb+04fW8530V7Z3hd4xyfaP42JqTOvIv8IxmQ VuXulG096Yrts13P10zDTGxET30rxN4jMr/qWaYRnELoIeDIlgN9FUotMgVf5k601xDmRq +cyJyiVMqZC+mD+R+1FyhIU4rQYCBac= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-9-rr-vFH2PNmajbkygiXPi8Q-1; Wed, 19 Nov 2025 17:19:24 -0500 X-MC-Unique: rr-vFH2PNmajbkygiXPi8Q-1 X-Mimecast-MFC-AGG-ID: rr-vFH2PNmajbkygiXPi8Q_1763590764 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-88234e4a694so11047626d6.3 for ; Wed, 19 Nov 2025 14:19:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763590764; x=1764195564; 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=s8tI4EYN4JDf7RLWnoc2eVOO/7lGndZZgrSr2xQc/es=; b=Bli+iDJgSQoOU8fxk8xpW1Lti52bOhJZuqZJqsEaI9g4YVc6eWCDTlhhOSV7KWUZ6l ZvpORWr0qi9aziLXKJ0wi3oX3UIl95islCT2kZ3xZdZPYdu89KPY6OZefdfvtYXXKHR1 WJPE5/wbE+cIReBz/X6z4mugtBt34gGOw2eR5U55chgsDNp4jp6OOU58T4nLCTb3Edee ikwuwlL18qtBsq2q47aGAhNky0xLVehA9fX7y6dapQVo3HAxt25MHBdDIAnh7HXisggh UoWN1aE/hUairWASIejlD/UYgtg6rY4l1AMmv3Rqx12V9SxoiL4U/hGJZyOHraoB2lBo EcJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763590764; x=1764195564; 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=s8tI4EYN4JDf7RLWnoc2eVOO/7lGndZZgrSr2xQc/es=; b=W+B0J3FqLwac9dDTHOLJ2CYEwae+b+JZaKlltOEnHBRSrIdVjRUj8o1uPEa1Uc9kdm qyKxm67/eAN/kL7PJVkj2buiSIQ2upyAJU7TIzY2wogIBNhZehceyZ0ba5ZvRQflF9s4 xv2sb0io90C6RsJXHZ876sqsgj2Cgpq+HndAXwUrYqPZl1ct1EY+0DSApC7YJPC/gchY xdb0Uy4ONAw8pgOnaW6Xrd7W/Kt4OFYn/W7oocJCSWPmMWzdGnb6LYNaM1zrGZXiogIj D2dIcmM6c00sk6cOYEK0Ay33mAZgF5Td2GyHtZxoAIOnGdgCSP009eWdZazM+Dur0is1 D7kQ== X-Forwarded-Encrypted: i=1; AJvYcCUnXVK1vU4qLhZp8L5valQJ0j8KilIrr11Kj7dDniv9otpuKQTVf97L4SNRpwZ0ibCWxe1/umsBDG6kWoE=@vger.kernel.org X-Gm-Message-State: AOJu0YzrPfKkctRUgX8QZNgLv1g/EMsuNHUN2TSnzNcVGqIxH6QMDzcD CjgwGHkzkbZ+GDyw8B/7+UHykQpyKO+yxWx0KiKZmMIQ+jF6wUqghaysEVgSO/EYawpAfpkvFHU iVOyQRo00oAUyre3iSClURkOtnEozA1Q0+cwaak7hXqkUuwHqM2DX0k4KiXgfDFGpLg== X-Gm-Gg: ASbGncuOQzMJbmM8iULk21oiWJMpZCNczmOQwdkYKkMBZUZkwTxjMrHTThZ9aApPkw6 QwtKKWHtG4tAyXB9qWGZuQXw06F+GRyeFXRSkItSbrKRZ3QLSkJwrOuoaOiafJMYkEi0GzwKakR 4f7nCDRVO1gOm20DdX5UjzmtP8KGxBgtFtNNKhaNJpiUgkMg2Ev/8URQnUsKhNIsEJBBSebW62M Ug6yXHR2yYvQayiMw1k6vDoCU2u8/REVZti366sIPceo/jpMVrP0eDvH/wVURPdt4pV+eRf5rv5 GVdWGEJwomYK1b7AhLtrtf60Smt6A2S+fwfuYPju7FKWByfIB75o4Blpn7TTkdt7odDNsJa0cC3 OywLsgeHirBVzBg== X-Received: by 2002:ad4:5aee:0:b0:880:4b32:a0fa with SMTP id 6a1803df08f44-8846e126e0fmr15483556d6.41.1763590763805; Wed, 19 Nov 2025 14:19:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBivjBhOPSe6mET8GARncZ+tJIO6qjaG8DWoG+YM0pRYYJOOFxIiTqJbhAXlSbK26RHnOI+A== X-Received: by 2002:ad4:5aee:0:b0:880:4b32:a0fa with SMTP id 6a1803df08f44-8846e126e0fmr15483256d6.41.1763590763106; Wed, 19 Nov 2025 14:19:23 -0800 (PST) Received: from [172.16.1.8] ([2607:f2c0:b141:ac00:ca1:dc8c:d6d0:7e87]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8846e447304sm4426866d6.4.2025.11.19.14.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 14:19:22 -0800 (PST) From: Peter Colberg Date: Wed, 19 Nov 2025 17:19:09 -0500 Subject: [PATCH 5/8] rust: pci: add vtable attribute to pci::Driver trait 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: <20251119-rust-pci-sriov-v1-5-883a94599a97@redhat.com> References: <20251119-rust-pci-sriov-v1-0-883a94599a97@redhat.com> In-Reply-To: <20251119-rust-pci-sriov-v1-0-883a94599a97@redhat.com> To: Danilo Krummrich , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Boqun Feng , 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 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 , Peter Colberg , Jason Gunthorpe X-Mailer: b4 0.14.2 Add the #[vtable] attribute to pci::Driver trait and implementations, to prepare a subsequent patch that adds an optional bus callback sriov_configure() to enable or disable the SR-IOV capability. Suggested-by: Danilo Krummrich Signed-off-by: Peter Colberg --- rust/kernel/pci.rs | 1 + samples/rust/rust_dma.rs | 1 + samples/rust/rust_driver_auxiliary.rs | 1 + samples/rust/rust_driver_pci.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index edb2bd41c8a14c8cfc421b26cda4dc84f75b546d..24dda12f6402098a1a323f3b5aa= e884201b26d89 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -275,6 +275,7 @@ macro_rules! pci_device_table { ///``` /// Drivers must implement this trait in order to get a PCI driver registe= red. Please refer to the /// `Adapter` documentation for an example. +#[vtable] pub trait Driver: Send { /// The type holding information about each device id supported by the= driver. // TODO: Use `associated_type_defaults` once stabilized: diff --git a/samples/rust/rust_dma.rs b/samples/rust/rust_dma.rs index f53bce2a73e3bb619372798c33bc3f13e580fdfc..96aa906984d8a40c5270bb2a7bc= f9650a41b7c9e 100644 --- a/samples/rust/rust_dma.rs +++ b/samples/rust/rust_dma.rs @@ -51,6 +51,7 @@ unsafe impl kernel::transmute::FromBytes for MyStruct {} [(pci::DeviceId::from_id(pci::Vendor::REDHAT, 0x5), ())] ); =20 +#[vtable] impl pci::Driver for DmaSampleDriver { type IdInfo =3D (); const ID_TABLE: pci::IdTable =3D &PCI_TABLE; diff --git a/samples/rust/rust_driver_auxiliary.rs b/samples/rust/rust_driv= er_auxiliary.rs index 5761ea314f447643b8023b05ab7e92b60e6a1e17..23488fa6179fcc8c7a44df949d5= eeeb1b132bd2d 100644 --- a/samples/rust/rust_driver_auxiliary.rs +++ b/samples/rust/rust_driver_auxiliary.rs @@ -64,6 +64,7 @@ struct ParentDriver { [(pci::DeviceId::from_id(pci::Vendor::REDHAT, 0x5), ())] ); =20 +#[vtable] impl pci::Driver for ParentDriver { type IdInfo =3D (); =20 diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci= .rs index 5823787bea8ec3e9a38ab3e4941f6c88d70e00b4..400db907e061a6a782b1cfebe9e= 5744815cc2843 100644 --- a/samples/rust/rust_driver_pci.rs +++ b/samples/rust/rust_driver_pci.rs @@ -60,6 +60,7 @@ fn testdev(index: &TestIndex, bar: &Bar0) -> Result { } } =20 +#[vtable] impl pci::Driver for SampleDriver { type IdInfo =3D TestIndex; =20 --=20 2.51.1