Subject: forcing out an Nway code word on media change
To: None <tech-net@netbsd.org>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-net
Date: 11/12/1999 11:09:04
As we discussed (on tech-kern, alas :-), this is a change that should
force a code word to go out to the link partner when you change media.

I haven't tested it yet; I will do so shortly.

        -- Jason R. Thorpe <thorpej@nas.nasa.gov>

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/12 18:33:43
***************
*** 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,106 ----
  	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 ((PHY_READ(sc, MII_ANER) & ANER_LPAN) != 0 &&
! 			 (sc->mii_capabilities & BMSR_ANEG) != 0) {
! 			/*
! 			 * Both we and our link partner support Nway.  Make
! 			 * sure we transmit a new code word so the link
! 			 * partner notices our media change.
! 			 */
! 			bmcr |= BMCR_AUTOEN|BMCR_STARTNEG;
! 		}
! 	}
  
  	PHY_WRITE(sc, MII_ANAR, anar);
  	PHY_WRITE(sc, MII_BMCR, bmcr);