Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci - Set duplex correctly when user setting is not ...



details:   https://anonhg.NetBSD.org/src/rev/22bcc2cfad6c
branches:  trunk
changeset: 461254:22bcc2cfad6c
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Nov 21 02:59:43 2019 +0000

description:
- Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
  the current active link status.

diffstat:

 sys/dev/pci/if_vge.c |  43 ++++++++++++++++++++++---------------------
 1 files changed, 22 insertions(+), 21 deletions(-)

diffs (72 lines):

diff -r 51320943c645 -r 22bcc2cfad6c sys/dev/pci/if_vge.c
--- a/sys/dev/pci/if_vge.c      Wed Nov 20 21:56:19 2019 +0000
+++ b/sys/dev/pci/if_vge.c      Thu Nov 21 02:59:43 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.76 2019/11/19 09:54:07 msaitoh Exp $ */
+/* $NetBSD: if_vge.c,v 1.77 2019/11/21 02:59:43 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.76 2019/11/19 09:54:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.77 2019/11/21 02:59:43 msaitoh Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -1928,33 +1928,34 @@
         * always implied, so we turn on the forced mode bit but leave
         * the FDX bit cleared.
         */
-
        dctl = CSR_READ_1(sc, VGE_DIAGCTL);
 
-       switch (IFM_SUBTYPE(ife->ifm_media)) {
-       case IFM_AUTO:
+       if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
                dctl &= ~VGE_DIAGCTL_MACFORCE;
                dctl &= ~VGE_DIAGCTL_FDXFORCE;
-               break;
-       case IFM_1000_T:
+       } else {
+               u_int ifmword;
+
+               /* If the link is up, use the current active media. */
+               if ((mii->mii_media_status & IFM_ACTIVE) != 0)
+                       ifmword = mii->mii_media_active;
+               else
+                       ifmword = ife->ifm_media;
+
                dctl |= VGE_DIAGCTL_MACFORCE;
-               dctl &= ~VGE_DIAGCTL_FDXFORCE;
-               dctl |= VGE_DIAGCTL_GMII;
-               break;
-       case IFM_100_TX:
-       case IFM_10_T:
-               dctl |= VGE_DIAGCTL_MACFORCE;
-               dctl &= ~VGE_DIAGCTL_GMII;
-               if ((ife->ifm_media & IFM_FDX) != 0)
+               if ((ifmword & IFM_FDX) != 0)
                        dctl |= VGE_DIAGCTL_FDXFORCE;
                else
                        dctl &= ~VGE_DIAGCTL_FDXFORCE;
-               break;
-       default:
-               printf("%s: unknown media type: %x\n",
-                   device_xname(sc->sc_dev),
-                   IFM_SUBTYPE(ife->ifm_media));
-               break;
+
+               if (IFM_SUBTYPE(ifmword) == IFM_1000_T) {
+                       /*
+                        * It means the user setting is not auto but it's
+                        * 1000baseT-FDX or 1000baseT.
+                        */
+                       dctl |= VGE_DIAGCTL_GMII;
+               } else
+                       dctl &= ~VGE_DIAGCTL_GMII;
        }
 
        CSR_WRITE_1(sc, VGE_DIAGCTL, dctl);



Home | Main Index | Thread Index | Old Index