* [PATCH 7/9] [ETH]: Start net device with carrier down
[not found] <e665d9ff8b50796ce65c503604453056217bfc8a.1221537369.git.tpiepho@freescale.com>
@ 2008-09-24 21:20 ` Trent Piepho
2008-09-24 21:32 ` Stephen Hemminger
2008-09-24 22:24 ` David Miller
0 siblings, 2 replies; 6+ messages in thread
From: Trent Piepho @ 2008-09-24 21:20 UTC (permalink / raw)
To: netdev; +Cc: Trent Piepho, Andy Fleming
Because it _is_ down when the device starts.
The device's carrier status is controlled via the functions
netif_carrier_on() and netif_carrier_off(). These set or clear a bit
indicating the lower level link aka carrier is down, and if the state
changed, they fire off a routing netlink event.
The problem is that when the device is first created and opened, the state
bit indicating the carrier is down isn't set, i.e. the state is wrong.
When the carrier comes up for the first time no netlink event is sent,
since the device state indicated the carrier was already up.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
CC: Andy Fleming <afleming@freescale.com>
---
net/ethernet/eth.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index a80839b..cdba6d0 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -333,6 +333,7 @@ void ether_setup(struct net_device *dev)
dev->addr_len = ETH_ALEN;
dev->tx_queue_len = 1000; /* Ethernet wants good queues */
dev->flags = IFF_BROADCAST|IFF_MULTICAST;
+ dev->state = 1 << __LINK_STATE_NOCARRIER;
memset(dev->broadcast, 0xFF, ETH_ALEN);
--
1.5.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 7/9] [ETH]: Start net device with carrier down
2008-09-24 21:20 ` [PATCH 7/9] [ETH]: Start net device with carrier down Trent Piepho
@ 2008-09-24 21:32 ` Stephen Hemminger
2008-09-24 22:25 ` David Miller
2008-09-24 22:24 ` David Miller
1 sibling, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2008-09-24 21:32 UTC (permalink / raw)
To: Trent Piepho; +Cc: netdev, Trent Piepho, Andy Fleming
On Wed, 24 Sep 2008 14:20:55 -0700
Trent Piepho <tpiepho@freescale.com> wrote:
> Because it _is_ down when the device starts.
>
> The device's carrier status is controlled via the functions
> netif_carrier_on() and netif_carrier_off(). These set or clear a bit
> indicating the lower level link aka carrier is down, and if the state
> changed, they fire off a routing netlink event.
>
> The problem is that when the device is first created and opened, the state
> bit indicating the carrier is down isn't set, i.e. the state is wrong.
> When the carrier comes up for the first time no netlink event is sent,
> since the device state indicated the carrier was already up.
>
> Signed-off-by: Trent Piepho <tpiepho@freescale.com>
> CC: Andy Fleming <afleming@freescale.com>
> ---
> net/ethernet/eth.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
> index a80839b..cdba6d0 100644
> --- a/net/ethernet/eth.c
> +++ b/net/ethernet/eth.c
> @@ -333,6 +333,7 @@ void ether_setup(struct net_device *dev)
> dev->addr_len = ETH_ALEN;
> dev->tx_queue_len = 1000; /* Ethernet wants good queues */
> dev->flags = IFF_BROADCAST|IFF_MULTICAST;
> + dev->state = 1 << __LINK_STATE_NOCARRIER;
>
> memset(dev->broadcast, 0xFF, ETH_ALEN);
>
This breaks devices that never call netif_carrier_on.
Standard practice is to call netif_carrier_off after allocation but before
register_netdev
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 7/9] [ETH]: Start net device with carrier down
2008-09-24 21:20 ` [PATCH 7/9] [ETH]: Start net device with carrier down Trent Piepho
2008-09-24 21:32 ` Stephen Hemminger
@ 2008-09-24 22:24 ` David Miller
2008-09-24 22:43 ` Trent Piepho
1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2008-09-24 22:24 UTC (permalink / raw)
To: tpiepho; +Cc: netdev, afleming
From: Trent Piepho <tpiepho@freescale.com>
Date: Wed, 24 Sep 2008 14:20:55 -0700
> The problem is that when the device is first created and opened, the state
> bit indicating the carrier is down isn't set, i.e. the state is wrong.
> When the carrier comes up for the first time no netlink event is sent,
> since the device state indicated the carrier was already up.
It works properly if the device driver does as it is supposed to,
which is invoke netif_carrier_off() in it's ->open() method in this
situation.
Please fix the drivers where this is not happening.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 7/9] [ETH]: Start net device with carrier down
2008-09-24 21:32 ` Stephen Hemminger
@ 2008-09-24 22:25 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2008-09-24 22:25 UTC (permalink / raw)
To: shemminger; +Cc: tpiepho, netdev, afleming
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Wed, 24 Sep 2008 14:32:03 -0700
> This breaks devices that never call netif_carrier_on.
>
> Standard practice is to call netif_carrier_off after allocation but before
> register_netdev
Or in ->open()
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 7/9] [ETH]: Start net device with carrier down
2008-09-24 22:24 ` David Miller
@ 2008-09-24 22:43 ` Trent Piepho
2008-10-02 21:12 ` [PATCH v2] gianfar: Create " Trent Piepho
0 siblings, 1 reply; 6+ messages in thread
From: Trent Piepho @ 2008-09-24 22:43 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Fleming Andy, Stephen Hemminger
On Wed, 24 Sep 2008, David Miller wrote:
> From: Trent Piepho <tpiepho@freescale.com>
> Date: Wed, 24 Sep 2008 14:20:55 -0700
>
>> The problem is that when the device is first created and opened, the state
>> bit indicating the carrier is down isn't set, i.e. the state is wrong.
>> When the carrier comes up for the first time no netlink event is sent,
>> since the device state indicated the carrier was already up.
>
> It works properly if the device driver does as it is supposed to,
> which is invoke netif_carrier_off() in it's ->open() method in this
> situation.
>
> Please fix the drivers where this is not happening.
I tried that first, but if the carrier is already up, opening the interface
generated extra rt-netlink messages for carrier down then carrier up, even
though the carrier was up all along.
But maybe I didn't have it at the right place in the open() method. I'll try
Stephen's suggestion to put it after allocation but before register_netdev()
and see if the problem is still there.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] gianfar: Create net device with carrier down
2008-09-24 22:43 ` Trent Piepho
@ 2008-10-02 21:12 ` Trent Piepho
0 siblings, 0 replies; 6+ messages in thread
From: Trent Piepho @ 2008-10-02 21:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Stephen Hemminger, Trent Piepho, Andy Fleming
The device's carrier status is controlled via the functions
netif_carrier_on() and netif_carrier_off(). These set or clear a bit
indicating the carrier (aka lower level link) is down, and if the state
changed, they fire off a routing netlink event.
Add a call to netif_carrier_off() before register_netdev() so that the
newly created device will be set to carrier down. Then when the carrier
comes up for the first time, a netlink event will be generated, as the
carrier changed from down to up. Otherwise the initial carrier up will
appear to be changing the status from up to up, and so no event is
generated since that's not a change.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
CC: Andy Fleming <afleming@freescale.com>
---
This uses Stephen's suggestion, which works fine. I had already tried this
in ->open(), but that creates bogus carrier up->carrier down->carrier up
netlink events when the device is opened.
drivers/net/gianfar.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index a671270..484cf69 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -339,6 +339,9 @@ static int gfar_probe(struct platform_device *pdev)
/* Enable most messages by default */
priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1;
+ /* Carrier starts down, phylib will bring it up */
+ netif_carrier_off(dev);
+
err = register_netdev(dev);
if (err) {
--
1.5.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-10-02 21:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <e665d9ff8b50796ce65c503604453056217bfc8a.1221537369.git.tpiepho@freescale.com>
2008-09-24 21:20 ` [PATCH 7/9] [ETH]: Start net device with carrier down Trent Piepho
2008-09-24 21:32 ` Stephen Hemminger
2008-09-24 22:25 ` David Miller
2008-09-24 22:24 ` David Miller
2008-09-24 22:43 ` Trent Piepho
2008-10-02 21:12 ` [PATCH v2] gianfar: Create " Trent Piepho
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).