Re: [PATCH net-next 1/3] net: netdevsim: Add PHY support in netdevsim

From: Simon Horman
Date: Fri Jul 04 2025 - 08:43:53 EST


On Wed, Jul 02, 2025 at 10:28:03AM +0200, Maxime Chevallier wrote:
> With the introduction of phy_link_topology, we have the ability to keep
> track of PHY devices that sit behind a net_device. While we still can
> only attach one single PHY to a netdev, we can look at all these PHYs
> through netlink, with the ETHTOOL_MSG_PHY_GET command.
>
> Moreover, netlink commands that are targeting PHY devices also now
> allow specifying which PHY we want to address in a given netlink
> command.
>
> That whole process comes with its own complexity, and a few bugs were
> dicovered over the months following the introduction of

Hi Maxime,

As it seems like there will be a v2 anyway: discovered

> phy_link_topology.

...

> +static struct phy_driver nsim_virtual_phy_drv[] = {
> + {
> + .name = "Netdevsim virtual PHY driver",
> + .get_features = nsim_get_features,
> + .match_phy_device = nsim_match_phy_device,
> + .config_aneg = nsim_config_aneg,
> + .read_status = nsim_read_status,
> + },
> +};
> +
> +module_phy_driver(nsim_virtual_phy_drv);

I see that this has been flagged by Kernel Test Robot,
but as I had already written most of this it seems worth sending anyway.

I am somewhat guessing at the why here, but
I see build failures with this patch applied:

ld: drivers/net/netdevsim/phy.o: in function `phy_module_init':
phy.c:(.init.text+0x0): multiple definition of `init_module'; drivers/net/netdevsim/netdev.o:netdev.c:(.init.text+0x0): first defined here
ld: drivers/net/netdevsim/phy.o: in function `phy_module_exit':
phy.c:(.exit.text+0x0): multiple definition of `cleanup_module'; drivers/net/netdevsim/netdev.o:netdev.c:(.exit.text+0x0): first defined here

I am guessing that this is because above module_phy_driver() will define
init_module and phy_module_exit functions. But the following lines near
the end of drivers/net/netdevsim/netdev.c also define functions with those
names.

module_init(nsim_module_init);
module_exit(nsim_module_exit);

...