Re: [PATCH v2 3/3] net: phy: add Rust Asix PHY driver
From: Andrew Lunn <andrew@lunn.ch>
Date: 2023-10-07 00:20:32
Also in:
rust-for-linux
On Sat, Oct 07, 2023 at 08:54:00AM +0900, FUJITA Tomonori wrote:
quoted hunk ↗ jump to hunk
On Fri, 6 Oct 2023 18:55:23 +0200 Andrew Lunn [off-list ref] wrote:quoted
quoted
How about adding CONFIG_RUST_PHYLIB to the first patch. Not selectable, it's just a flag for Rust PHYLIB support.We have to be careful with names. To some extent, CONFIG_PHYLIB means the core of phylib. So it could be that CONFIG_RUST_PHYLIB means the core of phylib written in rust? I doubt that will ever happen, but we are setting a naming scheme here which i expect others will blindly cut/paste. What we actually want is a symbol which represents the Rust binding onto the phylib core. So i think it should have BINDING, or WRAPPER or something like that in the name.Good point. Let's save CONFIG_PHYLIB for someday.quoted
quoted
diff --git a/init/Kconfig b/init/Kconfig index 4b4e3df1658d..2b6627aeb98c 100644 --- a/init/Kconfig +++ b/init/Kconfig@@ -1889,7 +1889,7 @@ config RUST depends on !GCC_PLUGINS depends on !RANDSTRUCT depends on !DEBUG_INFO_BTF || PAHOLE_HAS_LANG_EXCLUDEdepends on PHYLIB=y + select RUST_PHYLIBI know the rust build system is rather limited at the moment, but is this required? Is it possible to build the rust code without the phylib binding? Can your `RUST_PHYLIB` add phylib.rs to a Makefile target only if it is enabled?A short-term solution could work, I think. config RUST bool "Rust support" depends on HAVE_RUST depends on RUST_IS_AVAILABLE depends on !MODVERSIONS depends on !GCC_PLUGINS depends on !RANDSTRUCT depends on !DEBUG_INFO_BTF || PAHOLE_HAS_LANG_EXCLUDE select CONSTRUCTORS help Enables Rust support in the kernel. This allows other Rust-related options, like drivers written in Rust, to be selected. It is also required to be able to load external kernel modules written in Rust. See Documentation/rust/ for more information. If unsure, say N. config RUST_PHYLIB_BINDING bool "PHYLIB bindings support" depends on RUST depends on PHYLIB=y help Adds support needed for PHY drivers written in Rust. It provides a wrapper around the C phlib core. Then we can conditionally build build the PHYLIB bindings.diff --git a/rust/kernel/net.rs b/rust/kernel/net.rs index fbb6d9683012..33fc1531a6c0 100644 --- a/rust/kernel/net.rs +++ b/rust/kernel/net.rs@@ -2,4 +2,5 @@ //! Networking. +#[cfg(CONFIG_RUST_BINDINGS_PHYLIB)] pub mod phy;
This looks reasonable. If you spin a new version with all these Kconfig changes, i will do some compile testing. Andrew