From: FUJITA Tomonori <fujita.tomonori@gmail.com>
To: tmgross@umich.edu
Cc: andrew@lunn.ch, fujita.tomonori@gmail.com,
rust-for-linux@vger.kernel.org, benno.lossin@proton.me
Subject: Re: [RFC PATCH v1 0/4] Rust abstractions for network PHY drivers
Date: Tue, 19 Sep 2023 15:24:44 +0900 (JST) [thread overview]
Message-ID: <20230919.152444.1457385307728133204.ubuntu@gmail.com> (raw)
In-Reply-To: <CALNs47taHGkhjPH6j=JtmCAAqgTz=px5gsb6T_TN-TfPeu+Y4A@mail.gmail.com>
Hi,
On Mon, 18 Sep 2023 19:46:57 -0400
Trevor Gross <tmgross@umich.edu> wrote:
>> > [1]: @Fujita I know you have mentioned there are times where a driver
>> > does not always have one mask. I can't find anything and am not sure
>> > how this would work since `phy_driver` has `phy_id` and `phy_id_mask`
>> > fields - do you mind linking an example? The above could probably be
>> > adjusted to work with this
>>
>> drivers/met/phy/meson-gxl.c does some funky things:
>>
>> static struct phy_driver meson_gxl_phy[] = {
>> {
>> PHY_ID_MATCH_EXACT(0x01814400),
>> .name = "Meson GXL Internal PHY",
>> [ ... ]
>> }, {
>> PHY_ID_MATCH_EXACT(0x01803301),
>> .name = "Meson G12A Internal PHY",
>> [ ... ]
>> },
>> };
>>
>> static struct mdio_device_id __maybe_unused meson_gxl_tbl[] = {
>> { PHY_ID_MATCH_VENDOR(0x01814400) },
>> { PHY_ID_MATCH_VENDOR(0x01803301) },
>> { }
>>
>> So the phy_driver wants an exact match, but the module is loaded based
>> on the vendor OUIs.
>>
>> icplus.c:
>>
>> static struct mdio_device_id __maybe_unused icplus_tbl[] = {
>> { PHY_ID_MATCH_MODEL(IP175C_PHY_ID) },
>> { PHY_ID_MATCH_MODEL(IP1001_PHY_ID) },
>> { PHY_ID_MATCH_EXACT(IP101A_PHY_ID) },
>> { }
>> };
>>
>> The devices seem to not have unique IDs, so:
>>
>> static int ip101a_g_match_phy_device(struct phy_device *phydev, bool ip101a)
>> {
>> [ ... ]
>> }
>>
>> Its a variant on Murphy's law. If vendors can get something wrong,
>> some vendor will get it wrong at some point.
>>
>> Andrew
>
> Thanks for the references here, I see I misunderstood exactly the
> problem was. In this case, maybe we could do something like this:
>
> trait Driver {
> const PHY_ID: u32,
> const PHY_ID_MASK: PhyIdMask,
> // Default to the same value
> const PHY_DEVICE_ID_MASK: PhyIdMask = Self::PHY_ID_MASK,
> const NAME: &'static CStr;
> // ...
> }
>
> `PHY_ID_MASK` would be used to create the `phy_driver`,
> `PHY_DEVICE_ID_MASK` creates the `mdio_device`. That can be
> overridden in cases like the Meson G where they aren't the same.
>
> I think that the icplus situation is already possible with `match_phy_device`
drivers/net/phy/adin1100.c
static struct phy_driver adin_driver[] = {
{
.phy_id = PHY_ID_ADIN1100,
.phy_id_mask = 0xffffffcf,
.name = "ADIN1100",
.get_features = adin_get_features,
.soft_reset = adin_soft_reset,
.probe = adin_probe,
.config_aneg = adin_config_aneg,
.read_status = adin_read_status,
.set_loopback = adin_set_loopback,
.suspend = adin_suspend,
.resume = adin_resume,
.get_sqi = adin_get_sqi,
.get_sqi_max = adin_get_sqi_max,
},
};
module_phy_driver(adin_driver);
static struct mdio_device_id __maybe_unused adin_tbl[] = {
{ PHY_ID_MATCH_MODEL(PHY_ID_ADIN1100) },
{ PHY_ID_MATCH_MODEL(PHY_ID_ADIN1110) },
{ PHY_ID_MATCH_MODEL(PHY_ID_ADIN2111) },
{ }
};
This registers one driver but registers three mdio_device_ids.
bcm87xx.c registers two drivers but registers no
mdio_device_id. realtek.c registers 10 drivers but only one
mdio_device_id. There are some drivers that do unique.
I think that to separate registations of drivers and mdio_device_id is
the cleanest way.
next prev parent reply other threads:[~2023-09-19 6:24 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 13:36 [RFC PATCH v1 0/4] Rust abstractions for network PHY drivers FUJITA Tomonori
2023-09-13 13:36 ` [RFC PATCH v1 1/4] rust: core " FUJITA Tomonori
2023-09-13 20:11 ` Andrew Lunn
2023-09-13 20:49 ` Boqun Feng
2023-09-13 21:05 ` Andrew Lunn
2023-09-13 21:32 ` Boqun Feng
2023-09-14 4:10 ` Trevor Gross
2023-09-13 22:14 ` Miguel Ojeda
2023-09-14 0:30 ` Andrew Lunn
2023-09-14 11:03 ` Miguel Ojeda
2023-09-14 12:24 ` Andrew Lunn
2023-09-17 9:44 ` FUJITA Tomonori
2023-09-17 10:17 ` FUJITA Tomonori
2023-09-17 15:06 ` Andrew Lunn
2023-09-17 18:42 ` Trevor Gross
2023-09-17 19:08 ` Andrew Lunn
2023-09-18 0:49 ` Trevor Gross
2023-09-18 1:18 ` Andrew Lunn
2023-09-18 2:22 ` Trevor Gross
2023-09-18 3:44 ` FUJITA Tomonori
2023-09-18 13:13 ` Andrew Lunn
2023-09-18 6:01 ` FUJITA Tomonori
2023-09-14 5:47 ` Trevor Gross
2023-09-14 10:17 ` Jarkko Sakkinen
2023-09-14 19:46 ` Trevor Gross
2023-09-14 12:39 ` Andrew Lunn
2023-09-14 19:42 ` Trevor Gross
2023-09-14 19:53 ` Trevor Gross
2023-09-18 9:56 ` Finn Behrens
2023-09-18 13:22 ` Andrew Lunn
2023-09-18 10:22 ` Benno Lossin
2023-09-18 13:09 ` FUJITA Tomonori
2023-09-18 15:20 ` Benno Lossin
2023-09-19 10:26 ` FUJITA Tomonori
2023-09-20 13:24 ` Benno Lossin
2023-09-13 13:36 ` [RFC PATCH v1 2/4] rust: phy: add module device table support FUJITA Tomonori
2023-09-14 6:26 ` Trevor Gross
2023-09-14 7:23 ` Trevor Gross
2023-09-17 6:30 ` FUJITA Tomonori
2023-09-17 15:13 ` Andrew Lunn
2023-09-13 13:36 ` [RFC PATCH v1 3/4] MAINTAINERS: add Rust PHY abstractions file to the ETHERNET PHY LIBRARY FUJITA Tomonori
2023-09-13 18:57 ` Andrew Lunn
2023-09-17 12:32 ` FUJITA Tomonori
2023-09-19 12:06 ` Miguel Ojeda
2023-09-19 16:33 ` Andrew Lunn
2023-09-22 23:17 ` Trevor Gross
2023-09-23 0:05 ` Miguel Ojeda
2023-09-23 1:36 ` Andrew Lunn
2023-09-23 10:19 ` Miguel Ojeda
2023-09-23 14:42 ` Andrew Lunn
2023-10-09 12:26 ` Miguel Ojeda
2023-09-13 13:36 ` [RFC PATCH v1 4/4] sample: rust: add Asix PHY driver FUJITA Tomonori
2023-09-13 14:11 ` Andrew Lunn
2023-09-13 16:53 ` Greg KH
2023-09-13 18:50 ` Andrew Lunn
2023-09-13 18:59 ` Greg KH
2023-09-13 20:20 ` Andrew Lunn
2023-09-13 20:38 ` Greg KH
2023-09-13 16:56 ` Greg KH
2023-09-13 18:43 ` Andrew Lunn
2023-09-13 19:15 ` Andrew Lunn
2023-09-17 11:28 ` FUJITA Tomonori
2023-09-17 15:46 ` Andrew Lunn
2023-09-18 8:35 ` FUJITA Tomonori
2023-09-18 13:37 ` Andrew Lunn
2023-09-24 9:12 ` FUJITA Tomonori
2023-09-24 9:59 ` Miguel Ojeda
2023-09-24 15:31 ` Andrew Lunn
2023-09-24 17:31 ` Miguel Ojeda
2023-09-24 17:44 ` Andrew Lunn
2023-09-24 18:44 ` Miguel Ojeda
2023-09-18 22:23 ` [RFC PATCH v1 0/4] Rust abstractions for network PHY drivers Trevor Gross
2023-09-18 22:48 ` Andrew Lunn
2023-09-18 23:46 ` Trevor Gross
2023-09-19 6:24 ` FUJITA Tomonori [this message]
2023-09-19 7:41 ` Trevor Gross
2023-09-19 16:12 ` Andrew Lunn
2023-09-19 6:16 ` FUJITA Tomonori
2023-09-19 8:05 ` Trevor Gross
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=20230919.152444.1457385307728133204.ubuntu@gmail.com \
--to=fujita.tomonori@gmail.com \
--cc=andrew@lunn.ch \
--cc=benno.lossin@proton.me \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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).