netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Balakumaran Kannan <kumaran.4353@gmail.com>
To: davem@davemloft.net, stephen@networkplumber.org,
	avi.kp.137@gmail.com, edumazet@google.com,
	netdev@vger.kernel.org
Subject: [PATCH 1/1] net: Set NOCARRIER bit of etherdev state at initialization
Date: Fri, 23 May 2014 22:31:35 +0530	[thread overview]
Message-ID: <537F7EEF.3060701@gmail.com> (raw)

For any etherdev 'netif_carrier_ok' should succeed only after phy
layer determines carrier state through auto-negotiation or setting
it forcibly.

So ethernet drivers should set '__LINK_STATE_NOCARRIER' bit of
'dev->state' using 'netif_carrier_off' call at driver initialization.
As it is common for all ethernet devices, 'netif_carrier_off' call
could be moved to 'ether_setup'.

Signed-off-by: Balakumaran Kannan <kumaran.4353@gmail.com>
---
'netif_carrier_off' could be called anywhere in between
'alloc_etherdev' and 'phy_start'. For example,
1. e1000 driver calls at the end of 'e1000_probe'
2. intel i40e driver calls at the beginning of 'i40e_open'
3. realtek r8169 driver calls at the end of 'rtl_init_one'

But some driver misses this call. For example smsc911x driver doesn't
call 'netif_carrier_off' before calling 'phy_start'. So device starts
performing dhcp and IPv6 DAD even if carrier is not ready.

So it is better to move 'netif_carrier_off' call to 'ether_setup'. And
drivers can remove this call from their initialization functions.
---
 net/ethernet/eth.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 5dc638c..45f6703 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -369,6 +369,9 @@ void ether_setup(struct net_device *dev)
 
 	memset(dev->broadcast, 0xFF, ETH_ALEN);
 
+	/* Carrier state should be off initially */
+	netif_carrier_off(dev);
+
 }
 EXPORT_SYMBOL(ether_setup);
 
-- 
1.8.3.2

             reply	other threads:[~2014-05-23 17:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 17:01 Balakumaran Kannan [this message]
2014-05-23 17:38 ` [PATCH 1/1] net: Set NOCARRIER bit of etherdev state at initialization Dan Williams
2014-05-23 18:15   ` David Miller
2014-05-24 13:22     ` Balakumaran Kannan
2014-05-27 15:24       ` Dan Williams

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=537F7EEF.3060701@gmail.com \
    --to=kumaran.4353@gmail.com \
    --cc=avi.kp.137@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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).