* Re: [PATCH] leds: triggers: netdev: add a check, whether device is up [not found] ` <95ff53a1d1b9102c81a05076f40d47242579fc37.camel@gmail.com> @ 2023-11-04 16:41 ` Andrew Lunn 2023-11-04 17:12 ` Russell King (Oracle) [not found] ` <970325157b7598b6367c293380cace3624e6cb88.camel@gmail.com> 1 sibling, 1 reply; 5+ messages in thread From: Andrew Lunn @ 2023-11-04 16:41 UTC (permalink / raw) To: Klaus Kudielka; +Cc: David S . Miller, Jakub Kicinski, netdev, Russell King [Changes the Cc: list. Dropping LED people, adding a few netdev people] On Sat, Nov 04, 2023 at 04:27:45PM +0100, Klaus Kudielka wrote: > On Sat, 2023-11-04 at 15:29 +0100, Andrew Lunn wrote: > > On Sat, Nov 04, 2023 at 01:58:40PM +0100, Klaus Kudielka wrote: > > > Some net devices do not report NO-CARRIER, if they haven't been brought > > > up. > > > > Hi Klaus > > > > We should probably fix the driver. What device is it? > > > > > In that case, the netdev trigger results in a wrong link state being > > > displayed. Fix this, by adding a check, whether the device is up. > > > > Is it wrong? Maybe the carrier really is up, even if the interface is > > admin down. Broadcast packets are being received by the > > hardware. Maybe there is a BMC sharing the link and it is active? > > My particular example is Turris Omnia, eth2 (WAN), connected to SFP. > SFP module is inserted, but no fiber connected, so definitely no carrier. > > *Without* the patch: > > After booting, the device is down, but netdev trigger reports "link" active. > This looks wrong to me. > > I can then "ip link set eth2 up", and the "link" goes away - as I > would have expected it to be from the beginning. Thanks for the details. A brain dump... You do see a lot of MAC drivers doing a netif_carrier_off() in there probe function. That suggests the carrier is on by default. I doubt we can change that, we would break all the drivers which assume the carrier is on by default, probably virtual devices and some real devices. Often the MAC and PHY are connected in the open() callback, when using phylib. So that is too late. phylink_create() is however mostly used in the probe function. So it could set the carrier to off by default. Russell, what do you think? Turris Omnia uses mvneta. That does not turn the carrier off in its probe function. So a quick fix would be to add it. However, that then becomes pointless if we make phylink_create() disable the carrier. Andrew ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: triggers: netdev: add a check, whether device is up 2023-11-04 16:41 ` [PATCH] leds: triggers: netdev: add a check, whether device is up Andrew Lunn @ 2023-11-04 17:12 ` Russell King (Oracle) 0 siblings, 0 replies; 5+ messages in thread From: Russell King (Oracle) @ 2023-11-04 17:12 UTC (permalink / raw) To: Andrew Lunn; +Cc: Klaus Kudielka, David S . Miller, Jakub Kicinski, netdev On Sat, Nov 04, 2023 at 05:41:54PM +0100, Andrew Lunn wrote: > [Changes the Cc: list. Dropping LED people, adding a few netdev > people] > > On Sat, Nov 04, 2023 at 04:27:45PM +0100, Klaus Kudielka wrote: > > After booting, the device is down, but netdev trigger reports "link" active. > > This looks wrong to me. > > > > I can then "ip link set eth2 up", and the "link" goes away - as I > > would have expected it to be from the beginning. > > Thanks for the details. > > A brain dump... > > You do see a lot of MAC drivers doing a netif_carrier_off() in there > probe function. That suggests the carrier is on by default. I doubt we > can change that, we would break all the drivers which assume the > carrier is on by default, probably virtual devices and some real > devices. Note that one of the things that phylink will do is call netif_carrier_off() when phylink_start() is called to ensure that the netdev state matches its internal state. > Often the MAC and PHY are connected in the open() callback, when using > phylib. So that is too late. phylink_create() is however mostly used > in the probe function. So it could set the carrier to off by default. > Russell, what do you think? I was going to ask whether that would be a good idea - since it means that the carrier is in the right state at probe time as well as after phylink_start() has been called. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <970325157b7598b6367c293380cace3624e6cb88.camel@gmail.com>]
* Re: [PATCH] leds: triggers: netdev: add a check, whether device is up [not found] ` <970325157b7598b6367c293380cace3624e6cb88.camel@gmail.com> @ 2023-11-04 16:46 ` Andrew Lunn 2023-11-04 17:42 ` Russell King (Oracle) 0 siblings, 1 reply; 5+ messages in thread From: Andrew Lunn @ 2023-11-04 16:46 UTC (permalink / raw) To: Klaus Kudielka; +Cc: David S . Miller, Jakub Kicinski, netdev, Russell King On Sat, Nov 04, 2023 at 05:32:19PM +0100, Klaus Kudielka wrote: > On Sat, 2023-11-04 at 16:27 +0100, Klaus Kudielka wrote: > > > > phylink_start() is the first one that does netif_carrier_off() and thus > > sets the NOCARRIER bit, but that only happens when bringing the device up. > > > > Before that, I would not know who cares about setting the NOCARRIER bit. > > A different, driver-specific solution could be like this (tested and working): > > --- a/drivers/net/ethernet/marvell/mvneta.c > +++ b/drivers/net/ethernet/marvell/mvneta.c > @@ -5690,6 +5690,7 @@ static int mvneta_probe(struct platform_device *pdev) > /* 9676 == 9700 - 20 and rounding to 8 */ > dev->max_mtu = 9676; > > + netif_carrier_off(dev); > err = register_netdev(dev); > if (err < 0) { > dev_err(&pdev->dev, "failed to register\n"); > > > Would that be the "correct" approach? Crossing emails. Its a better approach. But it fixes just one driver. If we can do this in phylink_create(), we fix it in a lot of drivers with a single change... Andrew ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: triggers: netdev: add a check, whether device is up 2023-11-04 16:46 ` Andrew Lunn @ 2023-11-04 17:42 ` Russell King (Oracle) 2023-11-04 19:46 ` Klaus Kudielka 0 siblings, 1 reply; 5+ messages in thread From: Russell King (Oracle) @ 2023-11-04 17:42 UTC (permalink / raw) To: Andrew Lunn; +Cc: Klaus Kudielka, David S . Miller, Jakub Kicinski, netdev On Sat, Nov 04, 2023 at 05:46:44PM +0100, Andrew Lunn wrote: > On Sat, Nov 04, 2023 at 05:32:19PM +0100, Klaus Kudielka wrote: > > On Sat, 2023-11-04 at 16:27 +0100, Klaus Kudielka wrote: > > > > > > phylink_start() is the first one that does netif_carrier_off() and thus > > > sets the NOCARRIER bit, but that only happens when bringing the device up. > > > > > > Before that, I would not know who cares about setting the NOCARRIER bit. > > > > A different, driver-specific solution could be like this (tested and working): > > > > --- a/drivers/net/ethernet/marvell/mvneta.c > > +++ b/drivers/net/ethernet/marvell/mvneta.c > > @@ -5690,6 +5690,7 @@ static int mvneta_probe(struct platform_device *pdev) > > /* 9676 == 9700 - 20 and rounding to 8 */ > > dev->max_mtu = 9676; > > > > + netif_carrier_off(dev); > > err = register_netdev(dev); > > if (err < 0) { > > dev_err(&pdev->dev, "failed to register\n"); > > > > > > Would that be the "correct" approach? > > Crossing emails. > > Its a better approach. But it fixes just one driver. If we can do this > in phylink_create(), we fix it in a lot of drivers with a single > change... ... and I think we should. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: triggers: netdev: add a check, whether device is up 2023-11-04 17:42 ` Russell King (Oracle) @ 2023-11-04 19:46 ` Klaus Kudielka 0 siblings, 0 replies; 5+ messages in thread From: Klaus Kudielka @ 2023-11-04 19:46 UTC (permalink / raw) To: Russell King (Oracle), Andrew Lunn Cc: David S . Miller, Jakub Kicinski, netdev On Sat, 2023-11-04 at 17:42 +0000, Russell King (Oracle) wrote: > On Sat, Nov 04, 2023 at 05:46:44PM +0100, Andrew Lunn wrote: > > On Sat, Nov 04, 2023 at 05:32:19PM +0100, Klaus Kudielka wrote: > > > On Sat, 2023-11-04 at 16:27 +0100, Klaus Kudielka wrote: > > > > > > > > phylink_start() is the first one that does netif_carrier_off() and thus > > > > sets the NOCARRIER bit, but that only happens when bringing the device up. > > > > > > > > Before that, I would not know who cares about setting the NOCARRIER bit. > > > > > > A different, driver-specific solution could be like this (tested and working): > > > > > > --- a/drivers/net/ethernet/marvell/mvneta.c > > > +++ b/drivers/net/ethernet/marvell/mvneta.c > > > @@ -5690,6 +5690,7 @@ static int mvneta_probe(struct platform_device *pdev) > > > /* 9676 == 9700 - 20 and rounding to 8 */ > > > dev->max_mtu = 9676; > > > > > > + netif_carrier_off(dev); > > > err = register_netdev(dev); > > > if (err < 0) { > > > dev_err(&pdev->dev, "failed to register\n"); > > > > > > > > > Would that be the "correct" approach? > > > > Crossing emails. > > > > Its a better approach. But it fixes just one driver. If we can do this > > in phylink_create(), we fix it in a lot of drivers with a single > > change... > > ... and I think we should. > So, the patch below also results in correct behaviour of the netdev trigger with eth2 down, but I'm not so sure whether it really covers all desired cases. Any advice? --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1616,6 +1616,7 @@ struct phylink *phylink_create(struct phylink_config *config, pl->config = config; if (config->type == PHYLINK_NETDEV) { pl->netdev = to_net_dev(config->dev); + netif_carrier_off(pl->netdev); } else if (config->type == PHYLINK_DEV) { pl->dev = config->dev; } else { Best regards, Klaus ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-04 19:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20231104125840.27914-1-klaus.kudielka@gmail.com>
[not found] ` <0e3fb790-74f2-4bb3-b41e-65baa3b00093@lunn.ch>
[not found] ` <95ff53a1d1b9102c81a05076f40d47242579fc37.camel@gmail.com>
2023-11-04 16:41 ` [PATCH] leds: triggers: netdev: add a check, whether device is up Andrew Lunn
2023-11-04 17:12 ` Russell King (Oracle)
[not found] ` <970325157b7598b6367c293380cace3624e6cb88.camel@gmail.com>
2023-11-04 16:46 ` Andrew Lunn
2023-11-04 17:42 ` Russell King (Oracle)
2023-11-04 19:46 ` Klaus Kudielka
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).