[net-next RFC PATCH v2 0/3] net: phy: support multi PHY in phy_driver Was: net: phy: detach PHY driver OPs from phy_driver struct

From: Christian Marangi
Date: Tue Feb 20 2024 - 14:51:42 EST


This is an alternative implementation of "net: phy: detach PHY driver OPs
from phy_driver struct" with the same object in mind.
v2 is used to keep track of the similar attempts but this is the 3rd try
to accomplish the same object.

As was pointed out in the previous series, deatching OPs is a way too big
change (although IMHO needed, but I understand the problem with downstream
and ugly code). As suggested and was already an idea discussed privately,
a more easier approach is introduce an alternative way in phy_driver
struct to declare PHY with the use of an array of IDs.

The second attempt to this had a fundamental problem, as pointed out by
Florian, it did cause an ABI change in sysfs. This was caused by the fact
that sysfs entry are created dased on the first name the PHY driver is
registreted and changing the dev name after (although wrong) also doesn't
update the sysfs name.

The only solution to this problem is to register one driver for each PHY
ID like it's done currently.

This was the case for attempt 1 (detached OPs) and is implemented here in
the 3rd attempt.

To accomplish this, the mdiodrv has to be moved in a separate struct and
defined for each PHY the phy_driver supports (this is already the case
for each phy_driver struct). With this change, we can keep the current
phy_driver struct and support defining multi PHY.

Each PHY will be registered as a separate driver, (even if they are defined
in the same phy_driver struct) permitting to register it directly
with the right name.

For single PHY implementation, the phy_driver is internally converted to
ids implementation by dynamically allocating the table with only one
entry.

This is needed to handle the move of mdiodrv from the phy_driver struct
to a more specific one for each PHY ID.

Changes v2:
- Drop c45 patch
- Complete rework to handle specifi names for PHYs (no ABI
regression)

Christian Marangi (3):
net: phy: add support for defining multiple PHY IDs in PHY driver
net: phy: aquantia: group common OPs for PHYs where possible
net: phy: bcm7xxx: rework phy_driver table to new multiple PHY ID
format

drivers/net/phy/aquantia/aquantia_main.c | 170 +++++++++--------------
drivers/net/phy/bcm7xxx.c | 140 +++++++++++--------
drivers/net/phy/phy_device.c | 127 ++++++++++++-----
include/linux/phy.h | 38 ++++-
4 files changed, 275 insertions(+), 200 deletions(-)

--
2.43.0