Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/mii Fix a bug that rlphy might ignore the link partn...



details:   https://anonhg.NetBSD.org/src/rev/d98141c292ed
branches:  trunk
changeset: 447302:d98141c292ed
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Jan 07 05:01:10 2019 +0000

description:
Fix a bug that rlphy might ignore the link partner's advertised speed.

diffstat:

 sys/dev/mii/rlphy.c |  22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diffs (54 lines):

diff -r c20d503ea965 -r d98141c292ed sys/dev/mii/rlphy.c
--- a/sys/dev/mii/rlphy.c       Mon Jan 07 03:00:39 2019 +0000
+++ b/sys/dev/mii/rlphy.c       Mon Jan 07 05:01:10 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rlphy.c,v 1.30 2016/07/07 06:55:41 msaitoh Exp $       */
+/*     $NetBSD: rlphy.c,v 1.31 2019/01/07 05:01:10 msaitoh Exp $       */
 /*     $OpenBSD: rlphy.c,v 1.20 2005/07/31 05:27:30 pvalchev Exp $     */
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rlphy.c,v 1.30 2016/07/07 06:55:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rlphy.c,v 1.31 2019/01/07 05:01:10 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -209,7 +209,7 @@
        struct rlphy_softc *rsc = (void *)sc;
        struct mii_data *mii = sc->mii_pdata;
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       int bmsr, bmcr, anlpar;
+       int bmsr, bmcr, anar, anlpar, result;
 
        mii->mii_media_status = IFM_AVALID;
        mii->mii_media_active = IFM_ETHER;
@@ -240,17 +240,19 @@
                        return;
                }
 
-               if ((anlpar = PHY_READ(sc, MII_ANAR) &
-                   PHY_READ(sc, MII_ANLPAR))) {
-                       if (anlpar & ANLPAR_TX_FD)
+               anar = PHY_READ(sc, MII_ANAR);
+               anlpar = PHY_READ(sc, MII_ANLPAR);
+               result = anar & anlpar;
+               if (result != 0) {
+                       if (result & ANLPAR_TX_FD)
                                mii->mii_media_active |= IFM_100_TX|IFM_FDX;
-                       else if (anlpar & ANLPAR_T4)
+                       else if (result & ANLPAR_T4)
                                mii->mii_media_active |= IFM_100_T4|IFM_HDX;
-                       else if (anlpar & ANLPAR_TX)
+                       else if (result & ANLPAR_TX)
                                mii->mii_media_active |= IFM_100_TX|IFM_HDX;
-                       else if (anlpar & ANLPAR_10_FD)
+                       else if (result & ANLPAR_10_FD)
                                mii->mii_media_active |= IFM_10_T|IFM_FDX;
-                       else if (anlpar & ANLPAR_10)
+                       else if (result & ANLPAR_10)
                                mii->mii_media_active |= IFM_10_T|IFM_HDX;
                        else
                                mii->mii_media_active |= IFM_NONE;



Home | Main Index | Thread Index | Old Index