rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trevor Gross <tmgross@umich.edu>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: rust-for-linux@vger.kernel.org, andrew@lunn.ch, benno.lossin@proton.me
Subject: Re: [PATCH v3 1/2] rust: net::phy unified read/write API for C22 and C45 registers
Date: Thu, 6 Jun 2024 03:41:18 -0500	[thread overview]
Message-ID: <CALNs47sQeXZExxQK-vdx0zh6-aC376KYLbLcS6_e2rsFe_piZQ@mail.gmail.com> (raw)
In-Reply-To: <20240602231749.57111-2-fujita.tomonori@gmail.com>

On Sun, Jun 2, 2024 at 6:18 PM FUJITA Tomonori
<fujita.tomonori@gmail.com> wrote:
>
> Add the unified read/write API for C22 and C45 register. The

s/register/registers

> abstractions support access to only C22 registers now. Instead of
> adding read/write_c45 methods specifically for C45, a new reg module
> supports the unified API to access C22 and C45 registers with trait,
> by calling an appropriate phylib functions.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>

Sorry for the delays in reviews, this looks pretty good to me so far.
I like the cleanup of moving register logic to its own module.

> diff --git a/rust/kernel/net/phy/reg.rs b/rust/kernel/net/phy/reg.rs
> new file mode 100644
> index 000000000000..53a83e69b200
> --- /dev/null
> +++ b/rust/kernel/net/phy/reg.rs
> @@ -0,0 +1,174 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +// Copyright (C) 2024 FUJITA Tomonori <fujita.tomonori@gmail.com>
> +
> +//! PHY registers.
> +//!
> +//! This module provides an interface for PHY registers defined in IEEE 802.3
> +//! Clause 22 and 45.

Docs suggestion:

    PHY register interfaces.

    This module provides support for accessing PHY registers via Ethernet
    management interface clause 22 and 45, as defined in IEEE 802.3.

> +use super::Device;
> +use crate::build_assert;
> +use crate::error::*;
> +use crate::uapi;
> +
> +/// Accesses PHY registers.
> +///
> +/// This trait is used to implement the unified interface to access
> +/// C22 and C45 PHY registers.
> +pub trait Register {

Since we don't use this anywhere could it be sealed?

This might not even need to be public since it should probably only be
used as a method on `Device` (i.e. `my_device.read(C22::BMCR)` rather
than importing the trait and using `C22::BCMR::read(my_device)`).

> +    /// Reads a PHY register.
> +    fn read(&self, dev: &mut Device) -> Result<u16>;
> +
> +    /// Writes a PHY register.
> +    fn write(&self, dev: &mut Device, val: u16) -> Result;
> +}
> +

> +/// C22 registers.
> +pub struct C22(u8);

Docs suggestion:

    A single MDIO clause 22 register address (5 bits).

> +/// MDIO manageable devices.
> +pub struct Mmd(u8);

> +/// C45 registers.

Docs suggestion

    A single MDIO clause 45 register device and address.

    Clause 45 uses a 5-bit device address to access a specific MMD within a
    port, then a 16-bit register address to access a location within
that device.
    `C45` represents this by storing a [`Mmd`] and a register number.

> +pub struct C45 {
> +    devad: Mmd,
> +    regnum: u16,
> +}

- Trevor

  parent reply	other threads:[~2024-06-06  8:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-02 23:17 [PATCH v3 0/2] net::phy add unified API for C22 and C45 FUJITA Tomonori
2024-06-02 23:17 ` [PATCH v3 1/2] rust: net::phy unified read/write API for C22 and C45 registers FUJITA Tomonori
2024-06-03 14:02   ` Andrew Lunn
2024-06-03 14:03     ` Miguel Ojeda
2024-06-06  8:41   ` Trevor Gross [this message]
2024-06-06 23:02     ` FUJITA Tomonori
2024-06-06 23:43       ` Trevor Gross
2024-06-06 23:59         ` FUJITA Tomonori
2024-06-02 23:17 ` [PATCH v3 2/2] rust: net::phy unified genphy_read_status function " FUJITA Tomonori
2024-06-03 14:09   ` Andrew Lunn
2024-06-03 14:39     ` FUJITA Tomonori
2024-06-03 14:45       ` Andrew Lunn
2024-06-06  8:52   ` Trevor Gross
2024-06-06 23:07     ` FUJITA Tomonori

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=CALNs47sQeXZExxQK-vdx0zh6-aC376KYLbLcS6_e2rsFe_piZQ@mail.gmail.com \
    --to=tmgross@umich.edu \
    --cc=andrew@lunn.ch \
    --cc=benno.lossin@proton.me \
    --cc=fujita.tomonori@gmail.com \
    --cc=rust-for-linux@vger.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).