Commit f20fd544 authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by David S. Miller
Browse files

rust: core abstractions for network PHY drivers

This patch adds abstractions to implement network PHY drivers; the
driver registration and bindings for some of callback functions in
struct phy_driver and many genphy_ functions.

This feature is enabled with CONFIG_RUST_PHYLIB_ABSTRACTIONS=y.

This patch enables unstable const_maybe_uninit_zeroed feature for
kernel crate to enable unsafe code to handle a constant value with
uninitialized data. With the feature, the abstractions can initialize
a phy_driver structure with zero easily; instead of initializing all
the members by hand. It's supposed to be stable in the not so distant
future.

Link: https://github.com/rust-lang/rust/pull/116218



Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f3c2caac
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -60,6 +60,14 @@ config FIXED_PHY

	  Currently tested with mpc866ads and mpc8349e-mitx.

config RUST_PHYLIB_ABSTRACTIONS
        bool "Rust PHYLIB abstractions 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 phylib core.

config SFP
	tristate "SFP cage support"
	depends on I2C && PHYLINK
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@

#include <kunit/test.h>
#include <linux/errname.h>
#include <linux/ethtool.h>
#include <linux/mdio.h>
#include <linux/phy.h>
#include <linux/slab.h>
#include <linux/refcount.h>
#include <linux/wait.h>
+3 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#![no_std]
#![feature(allocator_api)]
#![feature(coerce_unsized)]
#![feature(const_maybe_uninit_zeroed)]
#![feature(dispatch_from_dyn)]
#![feature(new_uninit)]
#![feature(offset_of)]
@@ -38,6 +39,8 @@
pub mod ioctl;
#[cfg(CONFIG_KUNIT)]
pub mod kunit;
#[cfg(CONFIG_NET)]
pub mod net;
pub mod prelude;
pub mod print;
mod static_assert;

rust/kernel/net.rs

0 → 100644
+6 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

//! Networking.

#[cfg(CONFIG_RUST_PHYLIB_ABSTRACTIONS)]
pub mod phy;

rust/kernel/net/phy.rs

0 → 100644
+755 −0

File added.

Preview size limit exceeded, changes collapsed.