Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/dev Pull up the following, requested by msaitoh in ti...



details:   https://anonhg.NetBSD.org/src/rev/f29d38f895c6
branches:  netbsd-8
changeset: 1026369:f29d38f895c6
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Nov 20 15:11:31 2021 +0000

description:
Pull up the following, requested by msaitoh in ticket #1707:

        sys/dev/pci/if_wm.c                             1.716-1.718 via patch
        sys/dev/pci/if_wmreg.h                          1.121
        sys/dev/mii/ihphy.c                             1.20

- Fix a bug that device timeout still happens when the link is down
  on ICH/PCH. Fixes PR kern/56478.
- Add some sysctl info for debugging.
- ihphy(4): Don't power down the PHY when the interface goes down.
- Use macro. Fix comment.

diffstat:

 sys/dev/mii/ihphy.c    |    5 +-
 sys/dev/pci/if_wm.c    |  133 ++++++++++++++++++++++++++++++++++++++++++------
 sys/dev/pci/if_wmreg.h |    6 +-
 3 files changed, 120 insertions(+), 24 deletions(-)

diffs (284 lines):

diff -r d78a4bb33161 -r f29d38f895c6 sys/dev/mii/ihphy.c
--- a/sys/dev/mii/ihphy.c       Sun Oct 31 14:49:33 2021 +0000
+++ b/sys/dev/mii/ihphy.c       Sat Nov 20 15:11:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ihphy.c,v 1.10.8.2 2020/01/24 18:40:45 martin Exp $    */
+/*     $NetBSD: ihphy.c,v 1.10.8.3 2021/11/20 15:11:32 martin Exp $    */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.10.8.2 2020/01/24 18:40:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.10.8.3 2021/11/20 15:11:32 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -216,7 +216,6 @@
 
        case MII_DOWN:
                mii_phy_down(sc);
-               PHY_WRITE(sc, MII_BMCR, BMCR_PDOWN);
                return 0;
        }
 
diff -r d78a4bb33161 -r f29d38f895c6 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Sun Oct 31 14:49:33 2021 +0000
+++ b/sys/dev/pci/if_wm.c       Sat Nov 20 15:11:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.508.4.43 2021/10/23 11:49:22 martin Exp $  */
+/*     $NetBSD: if_wm.c,v 1.508.4.44 2021/11/20 15:11:31 martin Exp $  */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.43 2021/10/23 11:49:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.44 2021/11/20 15:11:31 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1042,6 +1042,8 @@
 static void    wm_set_linkdown_discard(struct wm_softc *);
 static void    wm_clear_linkdown_discard(struct wm_softc *);
 
+static int     wm_sysctl_tdh_handler(SYSCTLFN_PROTO);
+static int     wm_sysctl_tdt_handler(SYSCTLFN_PROTO);
 #ifdef WM_DEBUG
 static int     wm_sysctl_debug(SYSCTLFN_PROTO);
 #endif
@@ -3114,8 +3116,12 @@
 
        sc->sc_txrx_use_workqueue = false;
 
-       if (wm_phy_need_linkdown_discard(sc))
+       if (wm_phy_need_linkdown_discard(sc)) {
+               DPRINTF(sc, WM_DEBUG_LINK,
+                   ("%s: %s: Set linkdown discard flag\n",
+                       device_xname(sc->sc_dev), __func__));
                wm_set_linkdown_discard(sc);
+       }
 
        wm_init_sysctls(sc);
 
@@ -3566,10 +3572,12 @@
                splx(s);
 #endif
                if (error == 0 && wm_phy_need_linkdown_discard(sc)) {
-                       if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE)
+                       if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE) {
+                               DPRINTF(sc, WM_DEBUG_LINK,
+                                   ("%s: %s: Set linkdown discard flag\n",
+                                       device_xname(sc->sc_dev), __func__));
                                wm_set_linkdown_discard(sc);
-                       else
-                               wm_clear_linkdown_discard(sc);
+                       }
                }
                break;
        case SIOCINITIFADDR:
@@ -3585,14 +3593,14 @@
                        break;
                }
                WM_CORE_UNLOCK(sc);
-               if (((ifp->if_flags & IFF_UP) == 0) && wm_phy_need_linkdown_discard(sc))
-                       wm_clear_linkdown_discard(sc);
                /*FALLTHROUGH*/
        default:
                if (cmd == SIOCSIFFLAGS && wm_phy_need_linkdown_discard(sc)) {
-                       if (((ifp->if_flags & IFF_UP) == 0) && ((ifr->ifr_flags & IFF_UP) != 0)) {
-                               wm_clear_linkdown_discard(sc);
-                       } else if (((ifp->if_flags & IFF_UP) != 0) && ((ifr->ifr_flags & IFF_UP) == 0)) {
+                       if (((ifp->if_flags & IFF_UP) != 0) &&
+                           ((ifr->ifr_flags & IFF_UP) == 0)) {
+                               DPRINTF(sc, WM_DEBUG_LINK,
+                                   ("%s: %s: Set linkdown discard flag\n",
+                                       device_xname(sc->sc_dev), __func__));
                                wm_set_linkdown_discard(sc);
                        }
                }
@@ -5903,6 +5911,7 @@
                    sc->sc_queue[i].sysctlname, SYSCTL_DESCR("Queue Name"),
                    NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0)
                        break;
+
                if (sysctl_createv(log, 0, &qnode, &cnode,
                    CTLFLAG_READONLY, CTLTYPE_INT,
                    "txq_free", SYSCTL_DESCR("TX queue free"),
@@ -5911,10 +5920,58 @@
                        break;
                if (sysctl_createv(log, 0, &qnode, &cnode,
                    CTLFLAG_READONLY, CTLTYPE_INT,
+                   "txd_head", SYSCTL_DESCR("TX descriptor head"),
+                   wm_sysctl_tdh_handler, 0, (void *)txq,
+                   0, CTL_CREATE, CTL_EOL) != 0)
+                       break;
+               if (sysctl_createv(log, 0, &qnode, &cnode,
+                   CTLFLAG_READONLY, CTLTYPE_INT,
+                   "txd_tail", SYSCTL_DESCR("TX descriptor tail"),
+                   wm_sysctl_tdt_handler, 0, (void *)txq,
+                   0, CTL_CREATE, CTL_EOL) != 0)
+                       break;
+               if (sysctl_createv(log, 0, &qnode, &cnode,
+                   CTLFLAG_READONLY, CTLTYPE_INT,
                    "txq_next", SYSCTL_DESCR("TX queue next"),
                    NULL, 0, &txq->txq_next,
                    0, CTL_CREATE, CTL_EOL) != 0)
                        break;
+               if (sysctl_createv(log, 0, &qnode, &cnode,
+                   CTLFLAG_READONLY, CTLTYPE_INT,
+                   "txq_sfree", SYSCTL_DESCR("TX queue sfree"),
+                   NULL, 0, &txq->txq_sfree,
+                   0, CTL_CREATE, CTL_EOL) != 0)
+                       break;
+               if (sysctl_createv(log, 0, &qnode, &cnode,
+                   CTLFLAG_READONLY, CTLTYPE_INT,
+                   "txq_snext", SYSCTL_DESCR("TX queue snext"),
+                   NULL, 0, &txq->txq_snext,
+                   0, CTL_CREATE, CTL_EOL) != 0)
+                       break;
+               if (sysctl_createv(log, 0, &qnode, &cnode,
+                   CTLFLAG_READONLY, CTLTYPE_INT,
+                   "txq_sdirty", SYSCTL_DESCR("TX queue sdirty"),
+                   NULL, 0, &txq->txq_sdirty,
+                   0, CTL_CREATE, CTL_EOL) != 0)
+                       break;
+               if (sysctl_createv(log, 0, &qnode, &cnode,
+                   CTLFLAG_READONLY, CTLTYPE_INT,
+                   "txq_flags", SYSCTL_DESCR("TX queue flags"),
+                   NULL, 0, &txq->txq_flags,
+                   0, CTL_CREATE, CTL_EOL) != 0)
+                       break;
+               if (sysctl_createv(log, 0, &qnode, &cnode,
+                   CTLFLAG_READONLY, CTLTYPE_BOOL,
+                   "txq_stopping", SYSCTL_DESCR("TX queue stopping"),
+                   NULL, 0, &txq->txq_stopping,
+                   0, CTL_CREATE, CTL_EOL) != 0)
+                       break;
+               if (sysctl_createv(log, 0, &qnode, &cnode,
+                   CTLFLAG_READONLY, CTLTYPE_BOOL,
+                   "txq_sending", SYSCTL_DESCR("TX queue sending"),
+                   NULL, 0, &txq->txq_sending,
+                   0, CTL_CREATE, CTL_EOL) != 0)
+                       break;
 
                if (sysctl_createv(log, 0, &qnode, &cnode,
                    CTLFLAG_READONLY, CTLTYPE_INT,
@@ -7335,7 +7392,9 @@
        wm_init_tx_regs(sc, wmq, txq);
        wm_init_tx_buffer(sc, txq);
 
-       txq->txq_flags = 0; /* Clear WM_TXQ_NO_SPACE */
+       /* Clear other than WM_TXQ_LINKDOWN_DISCARD */
+       txq->txq_flags &= WM_TXQ_LINKDOWN_DISCARD;
+
        txq->txq_sending = false;
 }
 
@@ -9357,13 +9416,21 @@
                DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> up %s\n",
                        device_xname(sc->sc_dev),
                        (status & STATUS_FD) ? "FDX" : "HDX"));
-               if (wm_phy_need_linkdown_discard(sc))
+               if (wm_phy_need_linkdown_discard(sc)) {
+                       DPRINTF(sc, WM_DEBUG_LINK,
+                           ("%s: linkintr: Clear linkdown discard flag\n",
+                               device_xname(dev)));
                        wm_clear_linkdown_discard(sc);
+               }
        } else {
-               if (wm_phy_need_linkdown_discard(sc))
-                       wm_set_linkdown_discard(sc);
                DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n",
                        device_xname(sc->sc_dev)));
+               if (wm_phy_need_linkdown_discard(sc)) {
+                       DPRINTF(sc, WM_DEBUG_LINK,
+                           ("%s: linkintr: Set linkdown discard flag\n",
+                               device_xname(dev)));
+                       wm_set_linkdown_discard(sc);
+               }
        }
        if ((sc->sc_type == WM_T_ICH8) && (link == false))
                wm_gig_downshift_workaround_ich8lan(sc);
@@ -10268,9 +10335,9 @@
        } else {
                /* It's not the first call. Use PHY OUI and model */
                switch (phy_oui) {
-               case MII_OUI_ATTANSIC: /* XXX ??? */
+               case MII_OUI_ATTANSIC: /* atphy(4) */
                        switch (phy_model) {
-                       case 0x0004: /* XXX */
+                       case MII_MODEL_ATTANSIC_AR8021:
                                new_phytype = WMPHY_82578;
                                break;
                        default:
@@ -16372,7 +16439,35 @@
        CSR_WRITE(sc, WMREG_FEXTNVM9, reg);
 }
 
-/* Sysctl function */
+/* Sysctl functions */
+static int
+wm_sysctl_tdh_handler(SYSCTLFN_ARGS)
+{
+       struct sysctlnode node = *rnode;
+       struct wm_txqueue *txq = (struct wm_txqueue *)node.sysctl_data;
+       struct wm_queue *wmq = container_of(txq, struct wm_queue, wmq_txq);
+       struct wm_softc *sc = txq->txq_sc; 
+       uint32_t reg;
+
+       reg = CSR_READ(sc, WMREG_TDH(wmq->wmq_id));
+       node.sysctl_data = &reg;
+       return sysctl_lookup(SYSCTLFN_CALL(&node));
+}
+
+static int
+wm_sysctl_tdt_handler(SYSCTLFN_ARGS)
+{
+       struct sysctlnode node = *rnode;
+       struct wm_txqueue *txq = (struct wm_txqueue *)node.sysctl_data;
+       struct wm_queue *wmq = container_of(txq, struct wm_queue, wmq_txq);
+       struct wm_softc *sc = txq->txq_sc; 
+       uint32_t reg;
+
+       reg = CSR_READ(sc, WMREG_TDT(wmq->wmq_id));
+       node.sysctl_data = &reg;
+       return sysctl_lookup(SYSCTLFN_CALL(&node));
+}
+
 #ifdef WM_DEBUG
 static int
 wm_sysctl_debug(SYSCTLFN_ARGS)
@@ -16390,6 +16485,8 @@
                return error;
 
        sc->sc_debug = dflags;
+       device_printf(sc->sc_dev, "TARC0: %08x\n", CSR_READ(sc, WMREG_TARC0));
+       device_printf(sc->sc_dev, "TDT0: %08x\n", CSR_READ(sc, WMREG_TDT(0)));
 
        return 0;
 }
diff -r d78a4bb33161 -r f29d38f895c6 sys/dev/pci/if_wmreg.h
--- a/sys/dev/pci/if_wmreg.h    Sun Oct 31 14:49:33 2021 +0000
+++ b/sys/dev/pci/if_wmreg.h    Sat Nov 20 15:11:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wmreg.h,v 1.98.6.12 2020/08/05 17:22:46 martin Exp $        */
+/*     $NetBSD: if_wmreg.h,v 1.98.6.13 2021/11/20 15:11:32 martin Exp $        */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -973,8 +973,8 @@
 #define        WMREG_PHPM      0x0e14  /* PHY Power Management */
 #define        PHPM_SPD_EN             __BIT(0)        /* Smart Power Down */
 #define        PHPM_D0A_LPLU           __BIT(1)        /* D0 Low Power Link Up */
-#define        PHPM_NOND0A_LPLU        __BIT(2)        /* D0 Low Power Link Up */
-#define        PHPM_NOND0A_GBE_DIS     __BIT(3)        /* D0 Low Power Link Up */
+#define        PHPM_NOND0A_LPLU        __BIT(2)        /* Non-D0a LPLU */
+#define        PHPM_NOND0A_GBE_DIS     __BIT(3)        /* Disable 1G in non-D0a */
 #define        PHPM_GO_LINK_D          __BIT(5)        /* Go Link Disconnect */
 
 #define WMREG_EEER     0x0e30  /* Energy Efficiency Ethernet "EEE" */



Home | Main Index | Thread Index | Old Index