netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: rpjday@crashcourse.ca, netdev@vger.kernel.org, andrew@lunn.ch
Subject: Re: how PHY driver is notified that cable is unplugged? (possibly related to IFF_RUNNING flag)
Date: Wed, 1 Aug 2018 10:31:16 -0700	[thread overview]
Message-ID: <4dc00fa3-daef-bfdb-cb50-6bcddaa2d2c9@gmail.com> (raw)
In-Reply-To: <20180801085826.Horde.rj4qsfJlofF1IKzzUQgwFrO@crashcourse.ca>

On 08/01/2018 05:58 AM, rpjday@crashcourse.ca wrote:
> 
>   (warning that i have a few questions that are probably trivial until i
> get up to speed
> with networking code.)
> 
>   a colleague asked for advice about the following -- apparently a new
> PHY driver works
> properly when being brought up with "ifconfig <ifname> up", part of that
> process
> apparently setting the IFF_RUNNING net_device flags bit. so far, so good.
> 
>   now, when the cable is physically unplugged, the claim is that there
> is no obvious
> status change for that port, accompanied by the suggestion that it is
> that IFF_RUNNING
> flag bit that is not being unset.
> 
>   asking a more general question, where can i read up on the proper
> protocol for
> a driver being notified of, and properly handling, physical
> disconnection on that
> port? and, of course, the cable being plugged back in.

The basic mechanism used by the PHY library is to read the standard
Basic Mode Status Register and check the Link status bit to determine
what the state of the link is set. This event can be triggered either
through polling, or the use of an interrupt that the PHY is generating.

Once the link state is determined, because the PHY device is "connected"
to a network device, the PHY library can call netif_carrier_{on,off}
against the network device attached to the PHY and that propagates
through the networking stack and sets the appropriate bits, including
IFF_RUNNING.

Hope this helps.
-- 
Florian

  reply	other threads:[~2018-08-01 19:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01 12:58 how PHY driver is notified that cable is unplugged? (possibly related to IFF_RUNNING flag) rpjday
2018-08-01 17:31 ` Florian Fainelli [this message]
2018-08-01 21:45   ` Robert P. J. Day

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=4dc00fa3-daef-bfdb-cb50-6bcddaa2d2c9@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=netdev@vger.kernel.org \
    --cc=rpjday@crashcourse.ca \
    /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).