Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"ifconfig media off"?

19 views
Skip to first unread message

Stefan Bethke

unread,
Dec 12, 2011, 6:56:22 PM12/12/11
to
I'm currently writing a driver to configure an ethernet switch chip (see TL-WR1043ND on -embedded).

I noticed that there doesn't seem to be a way to power down a phy right now through the ifconfig media command.

Would there be objections to extend the media subtype definitions to include an "off", "poweroff" or "down" media subtype, and add code to the relevant phy drivers to power down the phy for this media subtype?

The difference between media subtype "none" and this new one would be that there will be no link, even if there is a physical connection. With media subtype "none", a 10 MBit/s half-duplex connection is established, potentially confusing the remote end about the availability of this link. On the local side, the link is down, so no packets are exchanged.


Stefan

--
Stefan Bethke <s...@lassitu.de> Fon +49 151 14070811



_______________________________________________
freeb...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net...@freebsd.org"

YongHyeon PYUN

unread,
Dec 12, 2011, 9:50:41 PM12/12/11
to
On Tue, Dec 13, 2011 at 12:56:22AM +0100, Stefan Bethke wrote:
> I'm currently writing a driver to configure an ethernet switch chip (see TL-WR1043ND on -embedded).
>
> I noticed that there doesn't seem to be a way to power down a phy right now through the ifconfig media command.
>
> Would there be objections to extend the media subtype definitions to include an "off", "poweroff" or "down" media subtype, and add code to the relevant phy drivers to power down the phy for this media subtype?
>
> The difference between media subtype "none" and this new one would be that there will be no link, even if there is a physical connection. With media subtype "none", a 10 MBit/s half-duplex connection is established, potentially confusing the remote end about the availability of this link. On the local side, the link is down, so no packets are exchanged.
>

I think "none" means "isolated" so should have no established link
and probably you can also power down the PHY.
I vaguely guess the PHY of switch chip does not correctly support
isolated mode so you may have wanted to power down.

sth...@nethelp.no

unread,
Dec 13, 2011, 4:09:18 AM12/13/11
to
> > I'm currently writing a driver to configure an ethernet switch chip (see TL-WR1043ND on -embedded).
> >
> > I noticed that there doesn't seem to be a way to power down a phy right now through the ifconfig media command.
> >
> > Would there be objections to extend the media subtype definitions to include an "off", "poweroff" or "down" media subtype, and add code to the relevant phy drivers to power down the phy for this media subtype?
> >
> > The difference between media subtype "none" and this new one would be that there will be no link, even if there is a physical connection. With media subtype "none", a 10 MBit/s half-duplex connection is established, potentially confusing the remote end about the availability of this link. On the local side, the link is down, so no packets are exchanged.

I have actually wanted this capability for quite a while now. Working
for an ISP and being used to routers and switches where ports can be
completely turned off, I see this as a welcome addition to FreeBSD.

Steinar Haug, Nethelp consulting, sth...@nethelp.no

Andre Oppermann

unread,
Dec 13, 2011, 4:44:05 AM12/13/11
to
On 13.12.2011 03:50, YongHyeon PYUN wrote:
> On Tue, Dec 13, 2011 at 12:56:22AM +0100, Stefan Bethke wrote:
>> I'm currently writing a driver to configure an ethernet switch chip (see TL-WR1043ND on -embedded).
>>
>> I noticed that there doesn't seem to be a way to power down a phy right now through the ifconfig media command.
>>
>> Would there be objections to extend the media subtype definitions to include an "off", "poweroff" or "down" media subtype, and add code to the relevant phy drivers to power down the phy for this media subtype?
>>
>> The difference between media subtype "none" and this new one would be that there will be no link, even if there is a physical connection. With media subtype "none", a 10 MBit/s half-duplex connection is established, potentially confusing the remote end about the availability of this link. On the local side, the link is down, so no packets are exchanged.
>>
>
> I think "none" means "isolated" so should have no established link
> and probably you can also power down the PHY.
> I vaguely guess the PHY of switch chip does not correctly support
> isolated mode so you may have wanted to power down.

There is a difference between "none" with "status: no carrier" where no ethernet
connection is established, but can be brought up the moment a cable is plugged in,
and "poweroff" where the PHY itself is powered down and won't notice a cable being
plugged in unless configure to auto-select or a particular speed.

Considering that PHY devices are relatively power hungry a poweroff state may be
quite useful to conserve battery power.

--
Andre

Stefan Bethke

unread,
Dec 13, 2011, 5:04:51 AM12/13/11
to
Am 13.12.2011 um 03:50 schrieb YongHyeon PYUN:

> On Tue, Dec 13, 2011 at 12:56:22AM +0100, Stefan Bethke wrote:
>> I'm currently writing a driver to configure an ethernet switch chip (see TL-WR1043ND on -embedded).
>>
>> I noticed that there doesn't seem to be a way to power down a phy right now through the ifconfig media command.
>>
>> Would there be objections to extend the media subtype definitions to include an "off", "poweroff" or "down" media subtype, and add code to the relevant phy drivers to power down the phy for this media subtype?
>>
>> The difference between media subtype "none" and this new one would be that there will be no link, even if there is a physical connection. With media subtype "none", a 10 MBit/s half-duplex connection is established, potentially confusing the remote end about the availability of this link. On the local side, the link is down, so no packets are exchanged.
>>
>
> I think "none" means "isolated" so should have no established link
> and probably you can also power down the PHY.
> I vaguely guess the PHY of switch chip does not correctly support
> isolated mode so you may have wanted to power down.


After looking at the code a bit more, I think the common code just doesn't set the BMCR_PDOWN (but clears it when bringing up the PHY).

Index: sys/dev/mii/mii_physubr.c
===================================================================
--- sys/dev/mii/mii_physubr.c (revision 228402)
+++ sys/dev/mii/mii_physubr.c (working copy)
@@ -58,7 +58,7 @@
*/
static const struct mii_media mii_media_table[MII_NMEDIA] = {
/* None */
- { BMCR_ISO, ANAR_CSMA,
+ { BMCR_ISO | BMCR_PDOWN, ANAR_CSMA,
0, },

/* 10baseT */

I've opened kern/163240.
http://www.freebsd.org/cgi/query-pr.cgi?pr=163240


Stefan

--
Stefan Bethke <s...@lassitu.de> Fon +49 151 14070811



Eugene Grosbein

unread,
Dec 13, 2011, 11:12:24 AM12/13/11
to
13.12.2011 06:56, Stefan Bethke пишет:
> I'm currently writing a driver to configure an ethernet switch chip (see TL-WR1043ND on -embedded).
>
> I noticed that there doesn't seem to be a way to power down a phy right now through the ifconfig media command.
>
> Would there be objections to extend the media subtype definitions to include an "off", "poweroff" or "down" media subtype, and add code to the relevant phy drivers to power down the phy for this media subtype?
>
> The difference between media subtype "none" and this new one would be that there will be no link, even if there is a physical connection. With media subtype "none", a 10 MBit/s half-duplex connection is established, potentially confusing the remote end about the availability of this link. On the local side, the link is down, so no packets are exchanged.

Some network drivers do not use our 'miibus' code, for example Intel em(4) and igb(4) drivers.
I run lots of FreeBSD routers with em/igb interfaces bundled as lagg(4) trunks
connected to Cisco core routers using PortChannels in LACP mode.

As I do not want to abide huge LACP timeouts when one of lagg ports should be brought down,
I've patched em/igb drivers to bring link down with "ifconfig down" command:

http://unix.derkeiler.com/Mailing-Lists/FreeBSD/net/2010-12/msg00058.html
http://unix.derkeiler.com/Mailing-Lists/FreeBSD/net/2010-12/msg00081.html

Eugene Grosbein

YongHyeon PYUN

unread,
Dec 13, 2011, 1:53:48 PM12/13/11
to
On Tue, Dec 13, 2011 at 11:04:51AM +0100, Stefan Bethke wrote:
> Am 13.12.2011 um 03:50 schrieb YongHyeon PYUN:
>
> > On Tue, Dec 13, 2011 at 12:56:22AM +0100, Stefan Bethke wrote:
> >> I'm currently writing a driver to configure an ethernet switch chip (see TL-WR1043ND on -embedded).
> >>
> >> I noticed that there doesn't seem to be a way to power down a phy right now through the ifconfig media command.
> >>
> >> Would there be objections to extend the media subtype definitions to include an "off", "poweroff" or "down" media subtype, and add code to the relevant phy drivers to power down the phy for this media subtype?
> >>
> >> The difference between media subtype "none" and this new one would be that there will be no link, even if there is a physical connection. With media subtype "none", a 10 MBit/s half-duplex connection is established, potentially confusing the remote end about the availability of this link. On the local side, the link is down, so no packets are exchanged.
> >>
> >
> > I think "none" means "isolated" so should have no established link
> > and probably you can also power down the PHY.
> > I vaguely guess the PHY of switch chip does not correctly support
> > isolated mode so you may have wanted to power down.
>
>
> After looking at the code a bit more, I think the common code just doesn't set the BMCR_PDOWN (but clears it when bringing up the PHY).
>

Yes, and most PHYs could be powered down when BMCR_ISO is chosen.
I'm not sure whether this could be applied to hardwares that
support multiple PHYs(i.e. internal and external transceivers)
though. Marius may have some opinions on this(CCed).
However powering down PHY with BMCR_ISO looks natural to me.

> Index: sys/dev/mii/mii_physubr.c
> ===================================================================
> --- sys/dev/mii/mii_physubr.c (revision 228402)
> +++ sys/dev/mii/mii_physubr.c (working copy)
> @@ -58,7 +58,7 @@
> */
> static const struct mii_media mii_media_table[MII_NMEDIA] = {
> /* None */
> - { BMCR_ISO, ANAR_CSMA,
> + { BMCR_ISO | BMCR_PDOWN, ANAR_CSMA,
> 0, },
>
> /* 10baseT */
>
> I've opened kern/163240.
> http://www.freebsd.org/cgi/query-pr.cgi?pr=163240
>
>
> Stefan
>
> --
> Stefan Bethke <s...@lassitu.de> Fon +49 151 14070811

YongHyeon PYUN

unread,
Dec 13, 2011, 2:11:51 PM12/13/11
to
On Tue, Dec 13, 2011 at 10:44:05AM +0100, Andre Oppermann wrote:
> On 13.12.2011 03:50, YongHyeon PYUN wrote:
> >On Tue, Dec 13, 2011 at 12:56:22AM +0100, Stefan Bethke wrote:
> >>I'm currently writing a driver to configure an ethernet switch chip (see
> >>TL-WR1043ND on -embedded).
> >>
> >>I noticed that there doesn't seem to be a way to power down a phy right
> >>now through the ifconfig media command.
> >>
> >>Would there be objections to extend the media subtype definitions to
> >>include an "off", "poweroff" or "down" media subtype, and add code to the
> >>relevant phy drivers to power down the phy for this media subtype?
> >>
> >>The difference between media subtype "none" and this new one would be
> >>that there will be no link, even if there is a physical connection. With
> >>media subtype "none", a 10 MBit/s half-duplex connection is established,
> >>potentially confusing the remote end about the availability of this link.
> >>On the local side, the link is down, so no packets are exchanged.
> >>
> >
> >I think "none" means "isolated" so should have no established link
> >and probably you can also power down the PHY.
> >I vaguely guess the PHY of switch chip does not correctly support
> >isolated mode so you may have wanted to power down.
>
> There is a difference between "none" with "status: no carrier" where no
> ethernet
> connection is established, but can be brought up the moment a cable is
> plugged in,
> and "poweroff" where the PHY itself is powered down and won't notice a
> cable being
> plugged in unless configure to auto-select or a particular speed.
>

Many gigabit PHY drivers already puts the PHY into powerdown state
when you select 'none'.

> Considering that PHY devices are relatively power hungry a poweroff state
> may be
> quite useful to conserve battery power.
>

Powering down the PHY would be the minimal and easy way that
achieves some power. But more power saving should be implemented
in ethernet controller side(i.e. removing clock to MII/PHY module
etc).
In addition, you shall always have to use network so powering down
may not be available option. Implementing EEE framework for
various PHYs would be the way to go.

> --
> Andre
0 new messages