Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci No, functional change:



details:   https://anonhg.NetBSD.org/src/rev/93798c819890
branches:  trunk
changeset: 348458:93798c819890
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Oct 19 08:55:23 2016 +0000

description:
No, functional change:
- Add WM_DEBUG_LOCK
- Add some KASSERT
- Modify comment.

diffstat:

 sys/dev/pci/if_wm.c |  127 +++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 112 insertions(+), 15 deletions(-)

diffs (truncated from 404 to 300 lines):

diff -r b0d98a4ed465 -r 93798c819890 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Wed Oct 19 08:22:57 2016 +0000
+++ b/sys/dev/pci/if_wm.c       Wed Oct 19 08:55:23 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.419 2016/10/19 08:22:57 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.420 2016/10/19 08:55:23 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.419 2016/10/19 08:22:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.420 2016/10/19 08:55:23 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -143,15 +143,16 @@
 #include <dev/pci/if_wmvar.h>
 
 #ifdef WM_DEBUG
-#define        WM_DEBUG_LINK           0x01
-#define        WM_DEBUG_TX             0x02
-#define        WM_DEBUG_RX             0x04
-#define        WM_DEBUG_GMII           0x08
-#define        WM_DEBUG_MANAGE         0x10
-#define        WM_DEBUG_NVM            0x20
-#define        WM_DEBUG_INIT           0x40
+#define        WM_DEBUG_LINK           __BIT(0)
+#define        WM_DEBUG_TX             __BIT(1)
+#define        WM_DEBUG_RX             __BIT(2)
+#define        WM_DEBUG_GMII           __BIT(3)
+#define        WM_DEBUG_MANAGE         __BIT(4)
+#define        WM_DEBUG_NVM            __BIT(5)
+#define        WM_DEBUG_INIT           __BIT(6)
+#define        WM_DEBUG_LOCK           __BIT(7)
 int    wm_debug = WM_DEBUG_TX | WM_DEBUG_RX | WM_DEBUG_LINK | WM_DEBUG_GMII
-    | WM_DEBUG_MANAGE | WM_DEBUG_NVM | WM_DEBUG_INIT;
+    | WM_DEBUG_MANAGE | WM_DEBUG_NVM | WM_DEBUG_INIT | WM_DEBUG_LOCK;
 
 #define        DPRINTF(x, y)   if (wm_debug & (x)) printf y
 #else
@@ -2846,6 +2847,7 @@
 
        DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
+
 #ifndef WM_MPSAFE
        s = splnet();
 #endif
@@ -3093,6 +3095,7 @@
 
        DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
+
        if (sc->sc_type >= WM_T_82544)
                mta_reg = WMREG_CORDOVA_MTA;
        else
@@ -3227,6 +3230,7 @@
 
        DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
+
        /* Deal with VLAN enables. */
        if (VLAN_ATTACHED(&sc->sc_ethercom))
                sc->sc_ctrl |= CTRL_VME;
@@ -3310,7 +3314,10 @@
        uint32_t reg = 0;
        int i;
 
-       /* wait for eeprom to reload */
+       DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
+       /* Wait for eeprom to reload */
        switch (sc->sc_type) {
        case WM_T_ICH10:
        case WM_T_PCH:
@@ -3345,7 +3352,10 @@
        uint32_t reg;
        int i;
 
-       /* wait for eeprom to reload */
+       DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
+       /* Wait for eeprom to reload */
        switch (sc->sc_type) {
        case WM_T_82542_2_0:
        case WM_T_82542_2_1:
@@ -3425,6 +3435,7 @@
 
        DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
+
        /* For 82571 variant, 80003 and ICHs */
        if (((sc->sc_type >= WM_T_82571) && (sc->sc_type <= WM_T_82583))
            || (sc->sc_type >= WM_T_80003)) {
@@ -3657,6 +3668,8 @@
 
        DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
+       KASSERT(sc->sc_type != 0);
+
        /*
         * Allocate on-chip memory according to the MTU size.
         * The Packet Buffer Allocation register must be written
@@ -4492,6 +4505,7 @@
        DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
        KASSERT(WM_CORE_LOCKED(sc));
+
        /*
         * *_HDR_ALIGNED_P is constant 1 if __NO_STRICT_ALIGMENT is set.
         * There is a small but measurable benefit to avoiding the adjusment
@@ -5694,6 +5708,8 @@
     struct wm_txqueue *txq)
 {
 
+       DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
        KASSERT(mutex_owned(txq->txq_lock));
 
        if (sc->sc_type < WM_T_82543) {
@@ -5896,6 +5912,7 @@
 
        DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
+
        for (i = 0; i < sc->sc_nqueues; i++) {
                struct wm_queue *wmq = &sc->sc_queue[i];
                struct wm_txqueue *txq = &wmq->wmq_txq;
@@ -7764,7 +7781,8 @@
 
        DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
-       /* get phy semaphore */
+
+       /* Get phy semaphore */
        switch (sc->sc_type) {
        case WM_T_82571:
        case WM_T_82572:
@@ -9901,6 +9919,9 @@
        uint32_t reg, val;
        int i;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        for (i = 0; i < wordcnt; i++) {
                /* Clear SK and DI. */
                reg = CSR_READ(sc, WMREG_EECD) & ~(EECD_SK | EECD_DI);
@@ -10051,6 +10072,9 @@
        int i;
        uint8_t opc;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        /* Clear SK and CS. */
        reg = CSR_READ(sc, WMREG_EECD) & ~(EECD_SK | EECD_CS);
        CSR_WRITE(sc, WMREG_EECD, reg);
@@ -10118,6 +10142,9 @@
        int i, eerd = 0;
        int error = 0;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        for (i = 0; i < wordcnt; i++) {
                eerd = ((offset + i) << EERD_ADDR_SHIFT) | EERD_START;
 
@@ -10466,6 +10493,9 @@
        uint16_t word = 0;
        uint16_t i = 0;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        /*
         * We need to know which is the valid flash bank.  In the event
         * that we didn't allocate eeprom_shadow_ram, we may not be
@@ -10527,6 +10557,9 @@
        uint32_t dword = 0;
        uint16_t i = 0;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        /*
         * We need to know which is the valid flash bank.  In the event
         * that we didn't allocate eeprom_shadow_ram, we may not be
@@ -10584,6 +10617,9 @@
        uint16_t i;
        uint8_t record_type, word_address;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        for (i = 0; i < INVM_SIZE; i++) {
                invm_dword = CSR_READ(sc, WM_INVM_DATA_REG(i));
                /* Get record type */
@@ -10684,7 +10720,10 @@
        int x;
        int ret = 0;
 
-       /* always success */
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
+       /* Always success */
        if ((sc->sc_flags & WM_F_EEPROM_FLASH) != 0)
                return 0;
 
@@ -10745,7 +10784,10 @@
 {
        uint32_t reg;
 
-       /* always success */
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
+       /* Always success */
        if ((sc->sc_flags & WM_F_EEPROM_FLASH) != 0)
                return;
 
@@ -11005,6 +11047,9 @@
 {
        int rv;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        if (sc->sc_flags & WM_F_EEPROM_INVALID)
                return 1;
 
@@ -11086,16 +11131,27 @@
        return 0;
 }
 
+/*
+ * Put hardware semaphore.
+ * Same as e1000_put_hw_semaphore_generic()
+ */
 static void
 wm_put_swsm_semaphore(struct wm_softc *sc)
 {
        uint32_t swsm;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        swsm = CSR_READ(sc, WMREG_SWSM);
        swsm &= ~(SWSM_SMBI | SWSM_SWESMBI);
        CSR_WRITE(sc, WMREG_SWSM, swsm);
 }
 
+/*
+ * Get SW/FW semaphore.
+ * Same as e1000_acquire_swfw_sync_82575().
+ */
 static int
 wm_get_swfw_semaphore(struct wm_softc *sc, uint16_t mask)
 {
@@ -11104,6 +11160,9 @@
        uint32_t fwmask = mask << SWFW_FIRM_SHIFT;
        int timeout = 200;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        for (timeout = 0; timeout < 200; timeout++) {
                if (sc->sc_flags & WM_F_LOCK_SWSM) {
                        if (wm_get_swsm_semaphore(sc)) {
@@ -11135,6 +11194,9 @@
 {
        uint32_t swfw_sync;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        if (sc->sc_flags & WM_F_LOCK_SWSM) {
                while (wm_get_swsm_semaphore(sc) != 0)
                        continue;
@@ -11152,6 +11214,9 @@
        uint32_t ext_ctrl;
        int timeout = 200;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        for (timeout = 0; timeout < 200; timeout++) {
                ext_ctrl = CSR_READ(sc, WMREG_EXTCNFCTR);
                ext_ctrl |= EXTCNFCTR_MDIO_SW_OWNERSHIP;
@@ -11172,6 +11237,9 @@
 {
        uint32_t ext_ctrl;
 
+       DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n",



Home | Main Index | Thread Index | Old Index