From: Trevor Gross <tmgross@umich.edu>
To: Wedson Almeida Filho <wedsonaf@gmail.com>
Cc: FUJITA Tomonori <fujita.tomonori@gmail.com>,
rust-for-linux@vger.kernel.org, andrew@lunn.ch,
miguel.ojeda.sandonis@gmail.com, benno.lossin@proton.me
Subject: Re: [RFC PATCH v3 1/3] rust: core abstractions for network PHY drivers
Date: Tue, 10 Oct 2023 18:50:01 -0400 [thread overview]
Message-ID: <CALNs47svn98i7O5Gfm6nXo_N0VFod+1LVj0oe2j_q46yGAiZHw@mail.gmail.com> (raw)
In-Reply-To: <CANeycqoBEWBJfvmto4uCNpnTHa8U4Y8D8_tHOtvxZrNgL-Ro_g@mail.gmail.com>
Linking in some context, discussion is somewhat fragmented across this
patch series. This is an old set anyway, the latest is at
https://lore.kernel.org/rust-for-linux/ZSQXqX2%2Flhf5ICZP@gpd/T/#t -
but I don't think anything reviewed has changed.
On Tue, Oct 10, 2023 at 3:19 PM Wedson Almeida Filho <wedsonaf@gmail.com> wrote:
> > + /// Returns true if the link is up.
> > + pub fn get_link(&mut self) -> bool {
> > + const LINK_IS_UP: u32 = 1;
>
> Where is this coming from?
>
> > + let phydev = self.0.get();
> > + // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`.
> > + unsafe { (*phydev).link() == LINK_IS_UP }
>
> Wouldn't it be more future-proof to do (*phydev).link() != 0? That's
> what the C side does.
I suggested it as more clear hint about the magic value, logic could
potentially be flipped though
https://lore.kernel.org/rust-for-linux/CALNs47vyW+A5uwCQ-ug03373xj+QMehx=1pXZ8ViS2jZ8KhfxQ@mail.gmail.com/
> > + /// Sets the speed of the PHY.
> > + pub fn set_speed(&mut self, speed: u32) {
> > + let phydev = self.0.get();
> > + // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`.
> > + unsafe { (*phydev).speed = speed as i32 };
> > + }
>
> Should we perhaps saturate `speed` to `i32::MAX` so that it doesn't
> become negative?
https://lore.kernel.org/rust-for-linux/96800001-5d19-4b48-b43e-0cfbeccb48c1@lunn.ch/
I agree that saturating probably isn't a bad idea here, but the C side
does validate it
> > +/// ```ignore
> > +///
> > +/// use kernel::net::phy::{self, DeviceId, Driver};
> > +/// use kernel::prelude::*;
> > +///
> > +/// kernel::module_phy_driver! {
> > +/// drivers: [PhyAX88772A, PhyAX88772C, PhyAX88796B],
> > +/// device_table: [
> > +/// DeviceId::new_with_driver::<PhyAX88772A>(),
> > +/// DeviceId::new_with_driver::<PhyAX88772C>(),
> > +/// DeviceId::new_with_driver::<PhyAX88796B>()
> > +/// ],
>
> I don't like the fact that we need to repeat names in `driver` and
> `device_table`. A single list should suffice, no?
I agree, but there needs to be a way to use a driver more than once
with different IDs. See
https://lore.kernel.org/rust-for-linux/CALNs47vyW+A5uwCQ-ug03373xj+QMehx=1pXZ8ViS2jZ8KhfxQ@mail.gmail.com/
and the followup, maybe you have a better suggestion
next prev parent reply other threads:[~2023-10-10 22:50 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-28 22:55 [RFC PATCH v3 0/3] Rust abstractions for network PHY drivers FUJITA Tomonori
2023-09-28 22:55 ` [RFC PATCH v3 1/3] rust: core " FUJITA Tomonori
2023-09-29 6:03 ` Greg KH
2023-09-29 8:38 ` FUJITA Tomonori
2023-09-29 9:11 ` Trevor Gross
2023-10-02 14:08 ` Andrew Lunn
2023-10-02 16:24 ` Miguel Ojeda
2023-10-02 19:08 ` Andrew Lunn
2023-10-09 12:25 ` Miguel Ojeda
2023-10-09 15:50 ` Andrew Lunn
2023-10-09 16:16 ` Miguel Ojeda
2023-10-09 16:29 ` Andrew Lunn
2023-10-10 17:31 ` Miguel Ojeda
2023-10-02 16:37 ` Trevor Gross
2023-09-29 11:39 ` Miguel Ojeda
2023-09-29 12:23 ` Andrew Lunn
2023-10-01 13:08 ` FUJITA Tomonori
2023-09-29 8:50 ` Trevor Gross
2023-09-29 18:42 ` Miguel Ojeda
2023-10-10 19:19 ` Wedson Almeida Filho
2023-10-10 20:28 ` Andrew Lunn
2023-10-10 21:00 ` Wedson Almeida Filho
2023-10-10 23:34 ` Andrew Lunn
2023-10-11 1:56 ` Wedson Almeida Filho
2023-10-11 5:17 ` FUJITA Tomonori
2023-10-10 22:50 ` Trevor Gross [this message]
2023-10-10 22:53 ` Miguel Ojeda
2023-10-10 23:06 ` FUJITA Tomonori
2023-10-10 23:12 ` Trevor Gross
2023-10-11 23:57 ` FUJITA Tomonori
2023-10-12 3:09 ` Trevor Gross
2023-10-12 3:16 ` FUJITA Tomonori
2023-10-12 4:20 ` Trevor Gross
2023-10-12 15:05 ` Andrew Lunn
2023-10-11 6:56 ` FUJITA Tomonori
2023-10-11 14:28 ` Wedson Almeida Filho
2023-10-11 14:59 ` FUJITA Tomonori
2023-10-11 23:28 ` FUJITA Tomonori
2023-10-11 17:35 ` Trevor Gross
2023-09-28 22:55 ` [RFC PATCH v3 2/3] MAINTAINERS: add Rust PHY abstractions to the ETHERNET PHY LIBRARY FUJITA Tomonori
2023-09-28 22:55 ` [RFC PATCH v3 3/3] net: phy: add Rust Asix PHY driver 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=CALNs47svn98i7O5Gfm6nXo_N0VFod+1LVj0oe2j_q46yGAiZHw@mail.gmail.com \
--to=tmgross@umich.edu \
--cc=andrew@lunn.ch \
--cc=benno.lossin@proton.me \
--cc=fujita.tomonori@gmail.com \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/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).