Subject: Re: forcing out an Nway code word on media change
To: None <>
From: Jason Thorpe <>
List: tech-net
Date: 11/13/1999 14:34:42
On Sat, 13 Nov 1999 16:15:18 +0100 
 Matthias Drochner <> wrote:

 > Can we always assume that the ANER has the LPAN bit set if the
 > partner supports NWAY at this point? A switch should start an
 > autonegotiotion cycle when the link is established, but I didn't
 > find out whether our ANER gets set if we don't have autonegotiation
 > enabled (the BMCR_AUTOEN bit) at this time. The standard doesn't
 > go into details here. (Btw, does "isolated" mean "link down"?)

Right, that's one of my main concerns, that the link partner won't
see ANER_LPAN unless we set BMCR_AUTOEN.

 > There is also a bootstrap problem if two machines are connected
 > point-to-point.
 > I don't see what this condition is necessary for, so I'd remove it.

So, the issue is that if the partner is *NOT* Nway-capable, and we
start an Nway cycle on our end (using BMCR_STARTNEG), then we have
a problem; the Nway will never enter FLP_GOOD state, so we will never
have a link-up condition.

Perhaps we can do the following instead: if we support Nway (i.e. BMSR_ANEG),
always set BMCR_AUTOEN.  This should ensure that our link partner always
sees ANER_LPAN[*].  If we see ANER_LPAN for our link partner, then also set
BMCR_STARTNEG to force out a code word.

[*] Not only do I wish the standard were more clear here, I wish I *had*
a copy of it.  Sadly, it's probably a pretty penny for that from IEEE.

BTW, "isolated" in this case means the user set media of "none" (which
has the effect of isolating the PHY from the MII bus).

        -- Jason R. Thorpe <>

Index: mii_physubr.c
RCS file: /cvsroot/syssrc/sys/dev/mii/mii_physubr.c,v
retrieving revision 1.8
diff -c -r1.8 mii_physubr.c
*** mii_physubr.c	1999/11/12 18:13:00	1.8
--- mii_physubr.c	1999/11/13 22:21:57
*** 88,95 ****
  	anar = mii_media_table[ife->ifm_data].mm_anar;
  	bmcr = mii_media_table[ife->ifm_data].mm_bmcr;
! 	if (ife->ifm_media & IFM_LOOP)
! 		bmcr |= BMCR_LOOP;
  	PHY_WRITE(sc, MII_ANAR, anar);
  	PHY_WRITE(sc, MII_BMCR, bmcr);
--- 88,114 ----
  	anar = mii_media_table[ife->ifm_data].mm_anar;
  	bmcr = mii_media_table[ife->ifm_data].mm_bmcr;
! 	if ((bmcr & BMCR_ISO) == 0) {
! 		if (ife->ifm_media & IFM_LOOP)
! 			bmcr |= BMCR_LOOP;
! 		else {
! 			/*
! 			 * If we support Nway, set BMCR_AUTOEN so
! 			 * that our link partner sees ANER_LPAN.
! 			 */
! 			if (sc->mii_capabilities & BMSR_ANEG)
! 				bmcr |= BMCR_AUTOEN;
! 			/*
! 			 * If our link partner supports Nway, make
! 			 * sure we transmit a code word to them so
! 			 * that they can update their link speed and
! 			 * duplex mode when ours changes.
! 			 */
! 			if (PHY_READ(sc, MII_ANER) & ANER_LPAN)
! 				bmcr |= BMCR_STARTNEG;
! 		}
! 	}
  	PHY_WRITE(sc, MII_ANAR, anar);
  	PHY_WRITE(sc, MII_BMCR, bmcr);