Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/a2f8d31c4482
branches:  netbsd-9
changeset: 1026368:a2f8d31c4482
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Nov 20 14:59:04 2021 +0000

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

        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 5f03a4f2f9cb -r a2f8d31c4482 sys/dev/mii/ihphy.c
--- a/sys/dev/mii/ihphy.c       Sat Nov 06 13:43:17 2021 +0000
+++ b/sys/dev/mii/ihphy.c       Sat Nov 20 14:59:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ihphy.c,v 1.14.4.1 2020/01/26 11:11:13 martin Exp $    */
+/*     $NetBSD: ihphy.c,v 1.14.4.2 2021/11/20 14:59:04 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.14.4.1 2020/01/26 11:11:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.14.4.2 2021/11/20 14:59:04 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -210,7 +210,6 @@
 
        case MII_DOWN:
                mii_phy_down(sc);
-               PHY_WRITE(sc, MII_BMCR, BMCR_PDOWN);
                return 0;
        }
 
diff -r 5f03a4f2f9cb -r a2f8d31c4482 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Sat Nov 06 13:43:17 2021 +0000
+++ b/sys/dev/pci/if_wm.c       Sat Nov 20 14:59:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.645.2.11 2021/10/21 14:30:10 martin Exp $  */
+/*     $NetBSD: if_wm.c,v 1.645.2.12 2021/11/20 14:59:04 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.645.2.11 2021/10/21 14:30:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.645.2.12 2021/11/20 14:59:04 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1067,6 +1067,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
@@ -3153,8 +3155,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);
 
@@ -3625,10 +3631,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:
@@ -3644,14 +3652,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);
                        }
                }
@@ -5993,6 +6001,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"),
@@ -6001,10 +6010,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,
@@ -7428,7 +7485,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;
 }
 
@@ -9453,13 +9512,21 @@
                DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> up %s\n",
                        device_xname(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(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);
@@ -10482,9 +10549,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:
@@ -17113,7 +17180,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)
@@ -17131,6 +17226,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 5f03a4f2f9cb -r a2f8d31c4482 sys/dev/pci/if_wmreg.h
--- a/sys/dev/pci/if_wmreg.h    Sat Nov 06 13:43:17 2021 +0000
+++ b/sys/dev/pci/if_wmreg.h    Sat Nov 20 14:59:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wmreg.h,v 1.115.2.3 2020/09/23 08:46:54 martin Exp $        */
+/*     $NetBSD: if_wmreg.h,v 1.115.2.4 2021/11/20 14:59:04 martin Exp $        */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -974,8 +974,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