From: Zhi Wang <zhiw@nvidia.com>
To: <rust-for-linux@vger.kernel.org>
Cc: <dakr@kernel.org>, <bhelgaas@google.com>,
<kwilczynski@kernel.org>, <ojeda@kernel.org>,
<alex.gaynor@gmail.com>, <boqun.feng@gmail.com>,
<gary@garyguo.net>, <bjorn3_gh@protonmail.com>,
<lossin@kernel.org>, <a.hindborg@kernel.org>,
<aliceryhl@google.com>, <tmgross@umich.edu>,
<linux-kernel@vger.kernel.org>, <cjia@nvidia.com>,
<smitra@nvidia.com>, <ankita@nvidia.com>, <aniketa@nvidia.com>,
<kwankhede@nvidia.com>, <targupta@nvidia.com>, <zhiw@nvidia.com>,
<zhiwang@kernel.org>, <alwilliamson@nvidia.com>,
<acourbot@nvidia.com>, <joelagnelf@nvidia.com>,
<jhubbard@nvidia.com>, <jgg@nvidia.com>
Subject: [RFC 0/2] rust: introduce abstractions for fwctl
Date: Thu, 30 Oct 2025 16:03:11 +0000 [thread overview]
Message-ID: <20251030160315.451841-1-zhiw@nvidia.com> (raw)
In the NVIDIA vGPU RFC [1], the vGPU type blobs must be provided to the GSP
before userspace can enumerate available vGPU types and create vGPU
instances. The original design relied on the firmware loading interface,
but fwctl is a more natural fit for this use case, as it is designed for
uploading configuration or firmware data required before the device becomes
operational.
This patch introduces a Rust abstraction over the fwctl subsystem,
providing safe and idiomatic bindings.
The new `fwctl` module allows Rust drivers to integrate with the existing
C-side fwctl core through a typed trait interface. It provides:
- `FwCtlOps` trait — defines driver-specific operations such as
`open_uctx()`, `close_uctx()`, `info()`, and `fw_rpc()`.
Each Rust driver implements this trait to describe its own per-FD
user-context behavior and RPC handling.
- `FwCtlUCtx<T>` — a generic wrapper around `struct fwctl_uctx`
embedding driver-specific context data, providing safe conversion
from raw C pointers and access to the parent device.
- `Registration<T>` — safe registration and automatic unregistration
of `struct fwctl_device` objects using the kernel’s device model.
- `FwCtlVTable<T>` — a static vtable bridging C callbacks and Rust
trait methods, ensuring type safety across the FFI boundary.
`rust/kernel/lib.rs` is updated to conditionally include this module
under `CONFIG_FWCTL`.
[1] https://lore.kernel.org/all/20250903221111.3866249-1-zhiw@nvidia.com/
Zhi Wang (2):
rust: introduce abstractions for fwctl
samples: rust: fwctl: add sample code for FwCtl
include/uapi/fwctl/fwctl.h | 1 +
rust/bindings/bindings_helper.h | 1 +
rust/kernel/fwctl.rs | 254 ++++++++++++++++++++++++++++++
rust/kernel/lib.rs | 2 +
samples/rust/Kconfig | 11 ++
samples/rust/Makefile | 1 +
samples/rust/rust_driver_fwctl.rs | 123 +++++++++++++++
7 files changed, 393 insertions(+)
create mode 100644 rust/kernel/fwctl.rs
create mode 100644 samples/rust/rust_driver_fwctl.rs
--
2.47.3
next reply other threads:[~2025-10-30 16:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 16:03 Zhi Wang [this message]
2025-10-30 16:03 ` [RFC 1/2] rust: introduce abstractions for fwctl Zhi Wang
2025-10-30 16:22 ` Jason Gunthorpe
2025-10-30 17:19 ` Zhi Wang
2025-10-30 17:24 ` Danilo Krummrich
2025-10-30 17:21 ` Danilo Krummrich
2025-10-30 16:47 ` Danilo Krummrich
2025-11-02 17:26 ` Danilo Krummrich
2025-11-02 22:52 ` Jason Gunthorpe
2025-11-02 18:33 ` Danilo Krummrich
2025-11-02 22:55 ` Jason Gunthorpe
2025-11-03 9:55 ` Zhi Wang
2025-11-03 10:36 ` Danilo Krummrich
2025-10-30 16:03 ` [RFC 2/2] samples: rust: fwctl: add sample code for FwCtl Zhi Wang
2025-10-30 17:29 ` [RFC 0/2] rust: introduce abstractions for fwctl Zhi Wang
2025-10-30 17:52 ` Danilo Krummrich
2025-10-30 17:54 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251030160315.451841-1-zhiw@nvidia.com \
--to=zhiw@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=alwilliamson@nvidia.com \
--cc=aniketa@nvidia.com \
--cc=ankita@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=cjia@nvidia.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=kwankhede@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=smitra@nvidia.com \
--cc=targupta@nvidia.com \
--cc=tmgross@umich.edu \
--cc=zhiwang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).