Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/dev/pci Pull up following revision(s) (requested by m...



details:   https://anonhg.NetBSD.org/src/rev/f548425b7090
branches:  netbsd-8
changeset: 435142:f548425b7090
user:      snj <snj%NetBSD.org@localhost>
date:      Thu Jul 26 20:40:39 2018 +0000

description:
Pull up following revision(s) (requested by msaitoh in ticket #928):
        sys/dev/pci/if_wm.c: 1.573-1.576, 1.579 and 1.582 via patch
wm(4):
- Count timeout correctly. This change reduce timeout value for 80003
  as expected. Reported by mouse@.
- Print "device timeout (lost interrupt)"  when all descriptors in a
  queue are free.
- Rename txq_watchdog to txq_sending to make the meaning clear.
- KNF. No functional change.

diffstat:

 sys/dev/pci/if_wm.c |  419 ++++++++++++++++++++++++++-------------------------
 1 files changed, 214 insertions(+), 205 deletions(-)

diffs (truncated from 1357 to 300 lines):

diff -r 4bbb3a317929 -r f548425b7090 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Thu Jul 26 20:37:42 2018 +0000
+++ b/sys/dev/pci/if_wm.c       Thu Jul 26 20:40:39 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.508.4.20 2018/06/07 17:42:25 martin Exp $  */
+/*     $NetBSD: if_wm.c,v 1.508.4.21 2018/07/26 20:40:39 snj Exp $     */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.20 2018/06/07 17:42:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.21 2018/07/26 20:40:39 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -193,7 +193,7 @@
 /*
  * Transmit descriptor list size.  Due to errata, we can only have
  * 256 hardware descriptors in the ring on < 82544, but we use 4096
- * on >= 82544.  We tell the upper layers that they can queue a lot
+ * on >= 82544. We tell the upper layers that they can queue a lot
  * of packets, and we go ahead and manage up to 64 (16 for the i82547)
  * of them at a time.
  *
@@ -247,13 +247,13 @@
 
 typedef union txdescs {
        wiseman_txdesc_t sctxu_txdescs[WM_NTXDESC_82544];
-       nq_txdesc_t      sctxu_nq_txdescs[WM_NTXDESC_82544];
+       nq_txdesc_t      sctxu_nq_txdescs[WM_NTXDESC_82544];
 } txdescs_t;
 
 typedef union rxdescs {
        wiseman_rxdesc_t sctxu_rxdescs[WM_NRXDESC];
-       ext_rxdesc_t      sctxu_ext_rxdescs[WM_NRXDESC]; /* 82574 only */
-       nq_rxdesc_t      sctxu_nq_rxdescs[WM_NRXDESC]; /* 82575 and newer */
+       ext_rxdesc_t      sctxu_ext_rxdescs[WM_NRXDESC]; /* 82574 only */
+       nq_rxdesc_t      sctxu_nq_rxdescs[WM_NRXDESC]; /* 82575 and newer */
 } rxdescs_t;
 
 #define        WM_CDTXOFF(txq, x)      ((txq)->txq_descsize * (x))
@@ -271,9 +271,9 @@
 };
 
 /*
- * Software state for receive buffers.  Each descriptor gets a
- * 2k (MCLBYTES) buffer and a DMA map.  For packets which fill
- * more than one buffer, we chain them together.
+ * Software state for receive buffers. Each descriptor gets a 2k (MCLBYTES)
+ * buffer and a DMA map. For packets which fill more than one buffer, we chain
+ * them together.
  */
 struct wm_rxsoft {
        struct mbuf *rxs_mbuf;          /* head of our mbuf chain */
@@ -301,14 +301,14 @@
        struct evcnt qname##_ev_##evname;
 
 #define WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, evtype)       \
-       do{                                                             \
+       do {                                                            \
                snprintf((q)->qname##_##evname##_evcnt_name,            \
                    sizeof((q)->qname##_##evname##_evcnt_name),         \
                    "%s%02d%s", #qname, (qnum), #evname);               \
                evcnt_attach_dynamic(&(q)->qname##_ev_##evname,         \
                    (evtype), NULL, (xname),                            \
                    (q)->qname##_##evname##_evcnt_name);                \
-       }while(0)
+       } while (0)
 
 #define WM_Q_MISC_EVCNT_ATTACH(qname, evname, q, qnum, xname)          \
        WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, EVCNT_TYPE_MISC)
@@ -333,7 +333,7 @@
        int txq_ndesc;                  /* must be a power of two */
        size_t txq_descsize;            /* a tx descriptor size */
        txdescs_t *txq_descs_u;
-        bus_dmamap_t txq_desc_dmamap;  /* control data DMA map */
+       bus_dmamap_t txq_desc_dmamap;   /* control data DMA map */
        bus_dma_segment_t txq_desc_seg; /* control data segment */
        int txq_desc_rseg;              /* real number of control segment */
 #define        txq_desc_dma    txq_desc_dmamap->dm_segs[0].ds_addr
@@ -370,7 +370,7 @@
 
        bool txq_stopping;
 
-       bool txq_watchdog;
+       bool txq_sending;
        time_t txq_lastsent;
 
        uint32_t txq_packets;           /* for AIM */
@@ -384,7 +384,7 @@
                                                /* XXX not used? */
 
        WM_Q_EVCNT_DEFINE(txq, txipsum)         /* IP checksums comp. out-bound */
-       WM_Q_EVCNT_DEFINE(txq,txtusum)          /* TCP/UDP cksums comp. out-bound */
+       WM_Q_EVCNT_DEFINE(txq, txtusum)         /* TCP/UDP cksums comp. out-bound */
        WM_Q_EVCNT_DEFINE(txq, txtusum6)        /* TCP/UDP v6 cksums comp. out-bound */
        WM_Q_EVCNT_DEFINE(txq, txtso)           /* TCP seg offload out-bound (IPv4) */
        WM_Q_EVCNT_DEFINE(txq, txtso6)          /* TCP seg offload out-bound (IPv6) */
@@ -442,7 +442,7 @@
 };
 
 struct wm_queue {
-       int wmq_id;                     /* index of transmit and receive queues */
+       int wmq_id;                     /* index of TX/RX queues */
        int wmq_intr_idx;               /* index of MSI-X tables */
 
        uint32_t wmq_itr;               /* interrupt interval per queue. */
@@ -547,7 +547,7 @@
        /* Event counters. */
        struct evcnt sc_ev_linkintr;    /* Link interrupts */
 
-        /* WM_T_82542_2_1 only */
+       /* WM_T_82542_2_1 only */
        struct evcnt sc_ev_tx_xoff;     /* Tx PAUSE(!0) frames */
        struct evcnt sc_ev_tx_xon;      /* Tx PAUSE(0) frames */
        struct evcnt sc_ev_rx_xoff;     /* Rx PAUSE(!0) frames */
@@ -669,7 +669,7 @@
 #endif
 static inline void wm_io_write(struct wm_softc *, int, uint32_t);
 static inline void wm_82575_write_8bit_ctlr_reg(struct wm_softc *, uint32_t,
-       uint32_t, uint32_t);
+    uint32_t, uint32_t);
 static inline void wm_set_dma_addr(volatile wiseman_addr_t *, bus_addr_t);
 
 /*
@@ -690,8 +690,10 @@
 static bool    wm_suspend(device_t, const pmf_qual_t *);
 static bool    wm_resume(device_t, const pmf_qual_t *);
 static void    wm_watchdog(struct ifnet *);
-static void    wm_watchdog_txq(struct ifnet *, struct wm_txqueue *, uint16_t *);
-static void    wm_watchdog_txq_locked(struct ifnet *, struct wm_txqueue *, uint16_t *);
+static void    wm_watchdog_txq(struct ifnet *, struct wm_txqueue *,
+    uint16_t *);
+static void    wm_watchdog_txq_locked(struct ifnet *, struct wm_txqueue *,
+    uint16_t *);
 static void    wm_tick(void *);
 static int     wm_ifflags_cb(struct ethercom *);
 static int     wm_ioctl(struct ifnet *, u_long, void *);
@@ -765,14 +767,16 @@
 static void    wm_start_locked(struct ifnet *);
 static int     wm_transmit(struct ifnet *, struct mbuf *);
 static void    wm_transmit_locked(struct ifnet *, struct wm_txqueue *);
-static void    wm_send_common_locked(struct ifnet *, struct wm_txqueue *, bool);
+static void    wm_send_common_locked(struct ifnet *, struct wm_txqueue *,
+    bool);
 static int     wm_nq_tx_offload(struct wm_softc *, struct wm_txqueue *,
     struct wm_txsoft *, uint32_t *, uint32_t *, bool *);
 static void    wm_nq_start(struct ifnet *);
 static void    wm_nq_start_locked(struct ifnet *);
 static int     wm_nq_transmit(struct ifnet *, struct mbuf *);
 static void    wm_nq_transmit_locked(struct ifnet *, struct wm_txqueue *);
-static void    wm_nq_send_common_locked(struct ifnet *, struct wm_txqueue *, bool);
+static void    wm_nq_send_common_locked(struct ifnet *, struct wm_txqueue *,
+    bool);
 static void    wm_deferred_start_locked(struct wm_txqueue *);
 static void    wm_handle_queue(void *);
 /* Interrupt */
@@ -797,7 +801,7 @@
 static void    wm_tbi_serdes_set_linkled(struct wm_softc *);
 /* GMII related */
 static void    wm_gmii_reset(struct wm_softc *);
-static void    wm_gmii_setup_phytype(struct wm_softc *sc, uint32_t, uint16_t);
+static void    wm_gmii_setup_phytype(struct wm_softc *, uint32_t, uint16_t);
 static int     wm_get_phy_id_82575(struct wm_softc *);
 static void    wm_gmii_mediainit(struct wm_softc *, pci_product_id_t);
 static int     wm_gmii_mediachange(struct ifnet *);
@@ -874,7 +878,7 @@
 static int32_t wm_ich8_cycle_init(struct wm_softc *);
 static int32_t wm_ich8_flash_cycle(struct wm_softc *, uint32_t);
 static int32_t wm_read_ich8_data(struct wm_softc *, uint32_t, uint32_t,
-       uint32_t *);
+    uint32_t *);
 static int32_t wm_read_ich8_byte(struct wm_softc *, uint32_t, uint8_t *);
 static int32_t wm_read_ich8_word(struct wm_softc *, uint32_t, uint16_t *);
 static int32_t wm_read_ich8_dword(struct wm_softc *, uint32_t, uint32_t *);
@@ -1642,13 +1646,13 @@
        if (sc->sc_type == WM_T_82574) {
                ext_rxdesc_t *rxd = &rxq->rxq_ext_descs[start];
                rxd->erx_data.erxd_addr =
-                       htole64(rxs->rxs_dmamap->dm_segs[0].ds_addr + sc->sc_align_tweak);
+                   htole64(rxs->rxs_dmamap->dm_segs[0].ds_addr + sc->sc_align_tweak);
                rxd->erx_data.erxd_dd = 0;
        } else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
                nq_rxdesc_t *rxd = &rxq->rxq_nq_descs[start];
 
                rxd->nqrx_data.nrxd_paddr =
-                       htole64(rxs->rxs_dmamap->dm_segs[0].ds_addr + sc->sc_align_tweak);
+                   htole64(rxs->rxs_dmamap->dm_segs[0].ds_addr + sc->sc_align_tweak);
                /* Currently, split header is not supported. */
                rxd->nqrx_data.nrxd_haddr = 0;
        } else {
@@ -1806,7 +1810,7 @@
        case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
        case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
                memh_valid = (pci_mapreg_map(pa, WM_PCI_MMBA,
-                   memtype, 0, &memt, &memh, NULL, &memsize) == 0);
+                       memtype, 0, &memt, &memh, NULL, &memsize) == 0);
                break;
        default:
                memh_valid = 0;
@@ -1874,8 +1878,8 @@
        pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, preg);
 
        /* power up chip */
-       if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self,
-           NULL)) && error != EOPNOTSUPP) {
+       if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self, NULL))
+           && error != EOPNOTSUPP) {
                aprint_error_dev(sc->sc_dev, "cannot activate %d\n", error);
                return;
        }
@@ -1932,7 +1936,7 @@
                        counts[PCI_INTR_TYPE_INTX] = 1;
                        goto alloc_retry;
                }
-       } else  if (pci_intr_type(pc, sc->sc_intrs[0]) == PCI_INTR_TYPE_MSI) {
+       } else if (pci_intr_type(pc, sc->sc_intrs[0]) == PCI_INTR_TYPE_MSI) {
                wm_adjust_qnum(sc, 0);  /* must not use multiqueue */
                error = wm_setup_legacy(sc);
                if (error) {
@@ -1958,7 +1962,7 @@
         * Check the function ID (unit number of the chip).
         */
        if ((sc->sc_type == WM_T_82546) || (sc->sc_type == WM_T_82546_3)
-           || (sc->sc_type ==  WM_T_82571) || (sc->sc_type == WM_T_80003)
+           || (sc->sc_type == WM_T_82571) || (sc->sc_type == WM_T_80003)
            || (sc->sc_type == WM_T_82575) || (sc->sc_type == WM_T_82576)
            || (sc->sc_type == WM_T_82580)
            || (sc->sc_type == WM_T_I350) || (sc->sc_type == WM_T_I354))
@@ -1985,7 +1989,7 @@
                if (sc->sc_type == WM_T_82547) {
                        callout_init(&sc->sc_txfifo_ch, CALLOUT_FLAGS);
                        callout_setfunc(&sc->sc_txfifo_ch,
-                                       wm_82547_txfifo_stall, sc);
+                           wm_82547_txfifo_stall, sc);
                        aprint_verbose_dev(sc->sc_dev,
                            "using 82547 Tx FIFO stall work-around\n");
                }
@@ -2040,7 +2044,7 @@
                                            512 << bytecnt, 512 << maxb);
                                        pcix_cmd = (pcix_cmd &
                                            ~PCIX_CMD_BYTECNT_MASK) |
-                                          (maxb << PCIX_CMD_BYTECNT_SHIFT);
+                                           (maxb << PCIX_CMD_BYTECNT_SHIFT);
                                        pci_conf_write(pa->pa_pc, pa->pa_tag,
                                            sc->sc_pcixe_capoff + PCIX_CMD,
                                            pcix_cmd);
@@ -2199,7 +2203,7 @@
                /* SPI */
                sc->sc_flags |= WM_F_EEPROM_SPI;
                wm_nvm_set_addrbits_size_eecd(sc);
-               if((sc->sc_type == WM_T_80003)
+               if ((sc->sc_type == WM_T_80003)
                    || (sc->sc_nvm_wordsize < (1 << 15))) {
                        sc->nvm.read = wm_nvm_read_eerd;
                        /* Don't use WM_F_LOCK_EECD because we use EERD */
@@ -2252,8 +2256,8 @@
                sc->sc_flashh = sc->sc_sh;
                sc->sc_ich8_flash_base = 0;
                sc->sc_nvm_wordsize =
-                       (((CSR_READ(sc, WMREG_STRAP) >> 1) & 0x1F) + 1)
-                       * NVM_SIZE_MULTIPLIER;
+                   (((CSR_READ(sc, WMREG_STRAP) >> 1) & 0x1F) + 1)
+                   * NVM_SIZE_MULTIPLIER;
                /* It is size in bytes, we want words */
                sc->sc_nvm_wordsize /= 2;
                /* assume 2 banks */
@@ -2828,7 +2832,7 @@
        ether_set_ifflags_cb(&sc->sc_ethercom, wm_ifflags_cb);
        if_register(ifp);
        rnd_attach_source(&sc->rnd_source, xname, RND_TYPE_NET,
-                         RND_FLAG_DEFAULT);
+           RND_FLAG_DEFAULT);
 
 #ifdef WM_EVENT_COUNTERS
        /* Attach event counters. */
@@ -3006,7 +3010,7 @@
 {
 
        mutex_enter(txq->txq_lock);
-       if (txq->txq_watchdog &&
+       if (txq->txq_sending &&
            time_uptime - txq->txq_lastsent > wm_watchdog_timeout) {
                wm_watchdog_txq_locked(ifp, txq, hang);
        }
@@ -3014,7 +3018,8 @@
 }
 
 static void
-wm_watchdog_txq_locked(struct ifnet *ifp, struct wm_txqueue *txq, uint16_t *hang)
+wm_watchdog_txq_locked(struct ifnet *ifp, struct wm_txqueue *txq,
+    uint16_t *hang)
 {
        struct wm_softc *sc = ifp->if_softc;
        struct wm_queue *wmq = container_of(txq, struct wm_queue, wmq_txq);
@@ -3026,10 +3031,14 @@
         * before we report an error.



Home | Main Index | Thread Index | Old Index