[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALNs47tWNNi2GXHAwwT=A1LP=xWwXvrPy4xVapqMQOeyeN0+9Q@mail.gmail.com>
Date: Thu, 1 Feb 2024 14:02:03 -0600
From: Trevor Gross <tmgross@...ch.edu>
To: Christina Quast <contact@...istina-quast.de>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...sung.com>,
Alice Ryhl <aliceryhl@...gle.com>, FUJITA Tomonori <fujita.tomonori@...il.com>,
Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Heiko Stuebner <heiko@...ech.de>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-rockchip@...ts.infradead.org
Subject: Re: [PATCH v2 2/3] rust: phy: add some phy_driver and genphy_ functions
On Thu, Feb 1, 2024 at 12:07 PM Christina Quast
<contact@...istina-quast.de> wrote:
> diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
> index e457b3c7cb2f..373a4d358e9f 100644
> --- a/rust/kernel/net/phy.rs
> +++ b/rust/kernel/net/phy.rs
> @@ -95,6 +95,22 @@ pub fn phy_id(&self) -> u32 {
> unsafe { (*phydev).phy_id }
> }
>
> + /// Gets the current crossover of the PHY.
> + pub fn mdix(&self) -> u8 {
Are possible values for mdix always ETH_TP_MDI{,_INVALID,_X,_AUTO}? If
so, this would be better as an enum.
> + let phydev = self.0.get();
> + // SAFETY: The struct invariant ensures that we may access
> + // this field without additional synchronization.
> + unsafe { (*phydev).mdix }
> + }
> +
> /// Gets the state of PHY state machine states.
> pub fn state(&self) -> DeviceState {
> let phydev = self.0.get();
> @@ -300,6 +316,15 @@ pub fn genphy_read_abilities(&mut self) -> Result {
> // So it's just an FFI call.
> to_result(unsafe { bindings::genphy_read_abilities(phydev) })
> }
> +
> + /// Writes BMCR
> + pub fn genphy_config_aneg(&mut self) -> Result {
The docs need an update here
> + let phydev = self.0.get();
> + // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`.
> + // So it's just an FFI call.
> + // second param = false => autoneg not requested
> + to_result(unsafe { bindings::__genphy_config_aneg(phydev, false) })
I assume you did this since the non-dunder `genphy_config_aneg` is
inline. I think that is ok since the implementation is so minimal, but
you could also add a binding helper and call that (rust/helpers.c).
> + }
> }
>
> /// Defines certain other features this PHY supports (like interrupts).
> @@ -583,6 +608,12 @@ fn soft_reset(_dev: &mut Device) -> Result {
> Err(code::ENOTSUPP)
> }
>
> + /// Called to initialize the PHY,
> + /// including after a reset
Docs wrapping
> + fn config_init(_dev: &mut Device) -> Result {
> + Err(code::ENOTSUPP)
> + }
These have been changed to raise a build error rather than ENOTSUPP in
recent , see [1]. That patch is in net-next so you should see it next
time you rebase.
Also - these functions are meant for the vtable and don't do anything
if they are not wired up. See the create_phy_driver function, you will
need to add the field.
> /// Probes the hardware to determine what abilities it has.
> fn get_features(_dev: &mut Device) -> Result {
> Err(code::ENOTSUPP)
>
> --
> 2.43.0
>
[1]: https://lore.kernel.org/rust-for-linux/20240125014502.3527275-2-fujita.tomonori@gmail.com/
Powered by blists - more mailing lists