tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: half-/full-duplex ethernet and ifconfig



Dave,

I did a lot of experimenting (and groveling thru code), and here are my
conclusions:
-- If I set only the media, then the mediaopt is assumed to be 0, so it
wipes away everything that was there, including "full-duplex", so the link
Is half-duplex.
-- If "full-duplex" is not displayed for "ifconfig wm0", then the link is
half-duplex.
-- There is no explicit way to set 'half-duplex'. IFM_HDX is not used -
the lack of IFM_FDX is used.

-- For'media', one may set either a "speed" (e.g., 100baseTX), or
'autoselect', but not both.
-- If "autoselect" is not set for media, then there is no autonegotiation.
-- If autoselect is set for media, then the link autonegotiates to its
fullest capability.

Based on the above:
-- 'ifconfig wm0 media 10baseT' - the link is running at 10 mbit,
half-duplex and there is no autonegotiation.
-- 'ifconfig wm0 media 10baseT mediaopt full-duplex' - the link is running
at 10 mbit, full-duplex and there is no autonegotiation.

-- A subsequent 'ifconfig wmo media autoselect' will cause the link to
autonegotiate to 1000baseT and full-duplex.







On 11/13/12 6:56 PM, "David Young" <dyoung%pobox.com@localhost> wrote:

>Today I noticed a funny thing about the ethernet media settings that I
>can see and choose through 'ifconfig wm0':
>
>        supported Ethernet media:
>                media none
>                media 10baseT
>                media 10baseT mediaopt full-duplex
>                media 100baseTX
>                media 100baseTX mediaopt full-duplex
>                media 1000baseT
>                media 1000baseT mediaopt full-duplex
>                media autoselect
>
>What's the difference between 'media 10baseT' and 'media 10baseT
>mediaopt full-duplex' ?
>
>I thought at first that if I did 'ifconfig wm0 media 10baseT' then it
>was up to my NIC and its link partner to negotiate the duplex setting.
>I.e., that if I don't specify a duplex setting, then the system assumes
>that I don't care.  I also expected that whichever duplex setting was
>negotiated, I could read it out again using 'ifconfig wm0'.  So if I set
>'ifconfig wm0 media 10baseT', I should see either
>
>        media: Ethernet 10baseT (10baseT full-duplex)
>        status: active
>
>or
>
>        media: Ethernet 10baseT (10baseT half-duplex)
>        status: active
>
>since the kernel defines non-zero flags for both (IFM_HDX, IFM_FDX).
>Instead, I see this:
>
>        media: Ethernet 10baseT
>        status: active
>
>Grovelling a bit in the ifconfig(8) code, I see that that
>parentheses-less output means the "active" (negotiated) media and the
>"current" (selected) media setting are the same: they're both Ethernet
>10baseT.
>
>Digging deeper, I find these lines in mii_phy_add_media():
>
>        if (sc->mii_capabilities & BMSR_10THDX) {
>                ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst),
>                    MII_MEDIA_10_T);
>                PRINT("10baseT");
>        }
>        if (sc->mii_capabilities & BMSR_10TFDX) {
>                ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX,
>sc->mii_inst),
>                    MII_MEDIA_10_T_FDX);
>                PRINT("10baseT-FDX");
>                fdx = 1;
>        }
>
>This tells me that we're using 0, not IFM_HDX, to represent
>"half-duplex"---or do I have the wrong interpretation---and there is no
>way to select a rate setting independent of a duplex setting.
>
>But hold on a minute, I see some PHY drivers are using both IFM_HDX
>IFM_FDX at least to tell what the negotiated media is:
>
>% grep IFM_HDX ../../dev/mii/*
>../../dev/mii/atphy.c:          mii->mii_media_active |= IFM_HDX;
>../../dev/mii/bmtphy.c:                 mii->mii_media_active |= IFM_HDX;
>../../dev/mii/brgphy.c:                         mii->mii_media_active |=
>IFM_HDX;
>../../dev/mii/etphy.c:          mii->mii_media_active |= IFM_HDX;
>../../dev/mii/rdcphy.c:         mii->mii_media_active |= IFM_HDX;
>../../dev/mii/rgephy.c:                 mii->mii_media_active |= IFM_HDX;
>../../dev/mii/rgephy.c:                 mii->mii_media_active |= IFM_HDX;
>
>I am having a hard time seeing the design intention here, can someone
>help me out?
>
>Dave
>
>-- 
>David Young
>dyoung%pobox.com@localhost    Urbana, IL    (217) 721-9981


Home | Main Index | Thread Index | Old Index