2015-02-05 20:25:32

by Pavel Machek

[permalink] [raw]
Subject: Ethernet: how to disable gigabit support

Hi!

This happened on more than one project: there's gigabit-capable chip,
but the connector is not designed for gigabit speed.

I'd like to have speed autonegotiation, but not offer gigabit (as it
will not work).

Is there way to do that without hacking the kernel? Should mii-tool do
that?

Thanks,
Pavel

root@ib8315:~# mii-tool.net-tools -A 100baseTx,10baseT eth1
restarting autonegotiation...
root@ib8315:~# [32432.443883] libphy: mdio@e0024520:01 - Link is Down

root@ib8315:~# [32435.447863] libphy: mdio@e0024520:01 - Link is Up - 1000/Full

root@ib8315:~# mii-tool.net-tools -v eth1
eth1: negotiated 1000baseT-FD flow-control, link ok
product info: vendor 00:01:c1, model 3 rev 1
basic mode: autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 1000baseT-FD 100baseTx-FD 100baseTx-HD
10baseT-FD 10baseT-HD
advertising: 1000baseT-FD 100baseTx-FD 100baseTx-HD
10baseT-FD 10baseT-HD
link partner: 1000baseT-FD 100baseTx-FD 100baseTx-HD
10baseT-FD 10baseT-HD flow-control
root@ib8315:~# mii-tool.net-tools -V
$Id: mii-tool.c,v 1.9 2006/09/27 20:59:18 ecki Exp $
(Author: David Hinds based on Donald Becker's mii-diag)
net-tools 1.60
root@ib8315:~#

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


2015-02-05 22:45:10

by Florian Fainelli

[permalink] [raw]
Subject: Re: Ethernet: how to disable gigabit support

On 05/02/15 12:25, Pavel Machek wrote:
> Hi!
>
> This happened on more than one project: there's gigabit-capable chip,
> but the connector is not designed for gigabit speed.
>
> I'd like to have speed autonegotiation, but not offer gigabit (as it
> will not work).
>
> Is there way to do that without hacking the kernel? Should mii-tool do
> that?

Since you use the PHY library, you should be able to do something like
this in your PHY driver prior to starting the PHY state machine:

phydev->supported &= PHY_BASIC_FEATURES (effectively masking Gigabit
capability)

See drivers/net/ethernet/broadcom/genet/bcmmii.c for instance where this
is done based on the type of interface (RevMII, MII) we are connected to.

>
> Thanks,
> Pavel
>
> root@ib8315:~# mii-tool.net-tools -A 100baseTx,10baseT eth1
> restarting autonegotiation...
> root@ib8315:~# [32432.443883] libphy: mdio@e0024520:01 - Link is Down
>
> root@ib8315:~# [32435.447863] libphy: mdio@e0024520:01 - Link is Up - 1000/Full
>
> root@ib8315:~# mii-tool.net-tools -v eth1
> eth1: negotiated 1000baseT-FD flow-control, link ok
> product info: vendor 00:01:c1, model 3 rev 1
> basic mode: autonegotiation enabled
> basic status: autonegotiation complete, link ok
> capabilities: 1000baseT-FD 100baseTx-FD 100baseTx-HD
> 10baseT-FD 10baseT-HD
> advertising: 1000baseT-FD 100baseTx-FD 100baseTx-HD
> 10baseT-FD 10baseT-HD
> link partner: 1000baseT-FD 100baseTx-FD 100baseTx-HD
> 10baseT-FD 10baseT-HD flow-control
> root@ib8315:~# mii-tool.net-tools -V
> $Id: mii-tool.c,v 1.9 2006/09/27 20:59:18 ecki Exp $
> (Author: David Hinds based on Donald Becker's mii-diag)
> net-tools 1.60
> root@ib8315:~#
>
>


--
Florian

2015-02-06 11:01:08

by Maciej W. Rozycki

[permalink] [raw]
Subject: Re: Ethernet: how to disable gigabit support

On Thu, 5 Feb 2015, Pavel Machek wrote:

> This happened on more than one project: there's gigabit-capable chip,
> but the connector is not designed for gigabit speed.
>
> I'd like to have speed autonegotiation, but not offer gigabit (as it
> will not work).
>
> Is there way to do that without hacking the kernel? Should mii-tool do
> that?

It used to work for me with a 3Com 3c905C adapter when I needed to force
full duplex for an old non-negotiating 100baseTx-FD network switch.

> root@ib8315:~# mii-tool.net-tools -A 100baseTx,10baseT eth1
> restarting autonegotiation...
> root@ib8315:~# [32432.443883] libphy: mdio@e0024520:01 - Link is Down
>
> root@ib8315:~# [32435.447863] libphy: mdio@e0024520:01 - Link is Up - 1000/Full
>
> root@ib8315:~# mii-tool.net-tools -v eth1
> eth1: negotiated 1000baseT-FD flow-control, link ok
> product info: vendor 00:01:c1, model 3 rev 1
> basic mode: autonegotiation enabled
> basic status: autonegotiation complete, link ok
> capabilities: 1000baseT-FD 100baseTx-FD 100baseTx-HD
> 10baseT-FD 10baseT-HD
> advertising: 1000baseT-FD 100baseTx-FD 100baseTx-HD
> 10baseT-FD 10baseT-HD
> link partner: 1000baseT-FD 100baseTx-FD 100baseTx-HD
> 10baseT-FD 10baseT-HD flow-control
> root@ib8315:~# mii-tool.net-tools -V
> $Id: mii-tool.c,v 1.9 2006/09/27 20:59:18 ecki Exp $
> (Author: David Hinds based on Donald Becker's mii-diag)
> net-tools 1.60
> root@ib8315:~#

You may have to spell out media names in full, e.g.:

# mii-tool -A 100baseTx-FD,100baseTx-HD,10baseT-FD,10baseT-HD eth1

Also the driver may have a way to override the capabilities advertised via
a module parameter. This is what I eventually ended up with with the
3c905C adapter.

Maciej

2015-02-06 13:57:10

by Pavel Machek

[permalink] [raw]
Subject: Re: Ethernet: how to disable gigabit support

On Thu 2015-02-05 14:44:55, Florian Fainelli wrote:
> On 05/02/15 12:25, Pavel Machek wrote:
> > Hi!
> >
> > This happened on more than one project: there's gigabit-capable chip,
> > but the connector is not designed for gigabit speed.
> >
> > I'd like to have speed autonegotiation, but not offer gigabit (as it
> > will not work).
> >
> > Is there way to do that without hacking the kernel? Should mii-tool do
> > that?
>
> Since you use the PHY library, you should be able to do something like
> this in your PHY driver prior to starting the PHY state machine:
>
> phydev->supported &= PHY_BASIC_FEATURES (effectively masking Gigabit
> capability)

Thanks, that did the trick.
Pavel
(But still it would be nice to have a generic way of doing this,
using something like mii-tool.)

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-07 14:36:02

by Bruno Prémont

[permalink] [raw]
Subject: Re: Ethernet: how to disable gigabit support

On Fri, 06 February 2015 Pavel Machek wrote:
> On Thu 2015-02-05 14:44:55, Florian Fainelli wrote:
> > On 05/02/15 12:25, Pavel Machek wrote:
> > > This happened on more than one project: there's gigabit-capable chip,
> > > but the connector is not designed for gigabit speed.
> > >
> > > I'd like to have speed autonegotiation, but not offer gigabit (as it
> > > will not work).
> > >
> > > Is there way to do that without hacking the kernel? Should mii-tool do
> > > that?
> >
> > Since you use the PHY library, you should be able to do something like
> > this in your PHY driver prior to starting the PHY state machine:
> >
> > phydev->supported &= PHY_BASIC_FEATURES (effectively masking Gigabit
> > capability)
>
> Thanks, that did the trick.
> Pavel
> (But still it would be nice to have a generic way of doing this,
> using something like mii-tool.)

You can use ethtool to do so:

ethtool -s ethX advertise 0x0f

c.f. man ethtool:
advertise N
Sets the speed and duplex advertised by autonegotiation. The argument is
a hexadecimal value using one or a combination of the following values:

0x001 10 Half
0x002 10 Full
0x004 100 Half
0x008 100 Full
0x010 1000 Half (not supported by IEEE standards)
0x020 1000 Full
0x8000 2500 Full (not supported by IEEE standards)
0x1000 10000 Full
0x20000 20000MLD2 Full (not supported by IEEE standards)
0x40000 20000KR2 Full (not supported by IEEE standards)

Bruno

2015-02-12 14:13:12

by Florian Fainelli

[permalink] [raw]
Subject: Re: Ethernet: how to disable gigabit support

2015-02-06 5:57 GMT-08:00 Pavel Machek <[email protected]>:
> On Thu 2015-02-05 14:44:55, Florian Fainelli wrote:
>> On 05/02/15 12:25, Pavel Machek wrote:
>> > Hi!
>> >
>> > This happened on more than one project: there's gigabit-capable chip,
>> > but the connector is not designed for gigabit speed.
>> >
>> > I'd like to have speed autonegotiation, but not offer gigabit (as it
>> > will not work).
>> >
>> > Is there way to do that without hacking the kernel? Should mii-tool do
>> > that?
>>
>> Since you use the PHY library, you should be able to do something like
>> this in your PHY driver prior to starting the PHY state machine:
>>
>> phydev->supported &= PHY_BASIC_FEATURES (effectively masking Gigabit
>> capability)
>
> Thanks, that did the trick.
> Pavel
> (But still it would be nice to have a generic way of doing this,
> using something like mii-tool.)

You can also force that by setting the "max-speed" property in the
Ethernet PHY node, the PHY library will populate the supported bitmask
accordingly and remove speeds which are not supposed to be supported.

I have to admit it has been a while since I used mii-tool, so the
ioctl() side on the PHY library might be off.
--
Florian