Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/pci Pull up the following revisions, requested by...



details:   https://anonhg.NetBSD.org/src/rev/325bd48c4efe
branches:  netbsd-9
changeset: 373196:325bd48c4efe
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Jan 23 13:59:04 2023 +0000

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

        sys/dev/pci/if_wm.c                             1.764-1.767 via patch
        sys/dev/pci/if_wmreg.h                          1.128

- Workaround for some hypervisor environments. The environments
  cannot stop e1000 interrupt immediately.
- Rename nq_txdesc' member "nqrx_ctx" to "nqtx_ctx". No functional
  change.
- Add comment. Modify comment.
- KNF.

diffstat:

 sys/dev/pci/if_wm.c    |  111 +++++++++++++++++++++++++++---------------------
 sys/dev/pci/if_wmreg.h |    4 +-
 2 files changed, 65 insertions(+), 50 deletions(-)

diffs (truncated from 366 to 300 lines):

diff -r 58bc8bea3d62 -r 325bd48c4efe sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Mon Jan 23 13:43:07 2023 +0000
+++ b/sys/dev/pci/if_wm.c       Mon Jan 23 13:59:04 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.645.2.14 2022/09/07 10:05:42 martin Exp $  */
+/*     $NetBSD: if_wm.c,v 1.645.2.15 2023/01/23 13: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.14 2022/09/07 10:05:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.645.2.15 2023/01/23 13:59:04 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -490,6 +490,7 @@
        char sysctlname[32];            /* Name for sysctl */
 
        bool wmq_txrx_use_workqueue;
+       bool wmq_wq_enqueued;
        struct work wmq_cookie;
        void *wmq_si;
        krndsource_t rnd_source;        /* random source */
@@ -2289,7 +2290,7 @@
                                aprint_error_dev(sc->sc_dev,
                                    "unable to find PCIX capability\n");
                        else if (sc->sc_type != WM_T_82545_3 &&
-                                sc->sc_type != WM_T_82546_3) {
+                           sc->sc_type != WM_T_82546_3) {
                                /*
                                 * Work around a problem caused by the BIOS
                                 * setting the max memory read byte count
@@ -3673,7 +3674,7 @@
                ifp->if_oerrors++;
 #ifdef WM_DEBUG
                for (i = txq->txq_sdirty; i != txq->txq_snext;
-                   i = WM_NEXTTXS(txq, i)) {
+                    i = WM_NEXTTXS(txq, i)) {
                        txs = &txq->txq_soft[i];
                        printf("txs %d tx %d -> %d\n",
                            i, txs->txs_firstdesc, txs->txs_lastdesc);
@@ -3834,9 +3835,9 @@
            crcerrs + algnerrc + symerrc + rxerrc + sec + cexterr + rlec;
 
        /*
-        * WMREG_RNBC is incremented when there are no available buffers in host
-        * memory. It does not mean the number of dropped packets, because an
-        * Ethernet controller can receive packets in such case if there is
+        * WMREG_RNBC is incremented when there are no available buffers in
+        * host memory. It does not mean the number of dropped packets, because
+        * an Ethernet controller can receive packets in such case if there is
         * space in the phy's FIFO.
         *
         * If you want to know the nubmer of WMREG_RMBC, you should use such as
@@ -4153,7 +4154,7 @@
 
        return 0;
 
- bad:
+bad:
        return -1;
 }
 
@@ -4442,10 +4443,10 @@
 
        goto setit;
 
- allmulti:
+allmulti:
        sc->sc_rctl |= RCTL_MPE;
 
- setit:
+setit:
        if (sc->sc_type >= WM_T_PCH2) {
                if (((ec->ec_capabilities & ETHERCAP_JUMBO_MTU) != 0)
                    && (ifp->if_mtu > ETHERMTU))
@@ -4836,7 +4837,8 @@
                 * LCD Write Enable bits are set in the NVM. When both NVM bits
                 * are cleared, SW will configure them instead.
                 */
-               DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s: Configure SMBus and LED\n",
+               DPRINTF(sc, WM_DEBUG_INIT,
+                   ("%s: %s: Configure SMBus and LED\n",
                        device_xname(sc->sc_dev), __func__));
                if ((rv = wm_write_smbus_addr(sc)) != 0)
                        goto release;
@@ -5147,15 +5149,15 @@
                CSR_WRITE(sc, WMREG_TARC0, tarc0);
 
                switch (sc->sc_type) {
-               /*
-                * 8257[12] Errata No.52, 82573 Errata No.43 and some others.
-                * Avoid RSS Hash Value bug.
-                */
                case WM_T_82571:
                case WM_T_82572:
                case WM_T_82573:
                case WM_T_80003:
                case WM_T_ICH8:
+                       /*
+                        * 8257[12] Errata No.52, 82573 Errata No.43 and some
+                        * others to avoid RSS Hash Value bug.
+                        */
                        reg = CSR_READ(sc, WMREG_RFCTL);
                        reg |= WMREG_RFCTL_NEWIPV6EXDIS |WMREG_RFCTL_IPV6EXDIS;
                        CSR_WRITE(sc, WMREG_RFCTL, reg);
@@ -5560,6 +5562,11 @@
                CSR_WRITE(sc, WMREG_CTRL, reg);
                /* Don't insert a completion barrier when reset */
                delay(20*1000);
+               /*
+                * The EXTCNFCTR_MDIO_SW_OWNERSHIP bit is cleared by the reset,
+                * so don't use sc->phy.release(sc). Release sc_ich_phymtx
+                * only. See also wm_get_swflag_ich8lan().
+                */
                mutex_exit(sc->sc_ich_phymtx);
                break;
        case WM_T_82580:
@@ -6181,7 +6188,7 @@
        kcpuset_destroy(affinity);
        return 0;
 
- fail:
+fail:
        for (qidx = 0; qidx < txrx_established; qidx++) {
                struct wm_queue *wmq = &sc->sc_queue[qidx];
                pci_intr_disestablish(sc->sc_pc,sc->sc_ihs[wmq->wmq_intr_idx]);
@@ -6258,7 +6265,8 @@
                 * So, overwrite counter field by software.
                 */
                if (sc->sc_type == WM_T_82575)
-                       eitr |= __SHIFTIN(wmq->wmq_itr, EITR_COUNTER_MASK_82575);
+                       eitr |= __SHIFTIN(wmq->wmq_itr,
+                           EITR_COUNTER_MASK_82575);
                else
                        eitr |= EITR_CNT_INGR;
 
@@ -6359,7 +6367,8 @@
                goto err;
 
        rv = sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_READWRITE,
-           CTLTYPE_BOOL, "txrx_workqueue", SYSCTL_DESCR("Use workqueue for packet processing"),
+           CTLTYPE_BOOL, "txrx_workqueue",
+           SYSCTL_DESCR("Use workqueue for packet processing"),
            NULL, 0, &sc->sc_txrx_use_workqueue, 0, CTL_CREATE, CTL_EOL);
        if (rv != 0)
                goto teardown;
@@ -7062,7 +7071,7 @@
        ifp->if_flags |= IFF_RUNNING;
        ifp->if_flags &= ~IFF_OACTIVE;
 
- out:
+out:
        /* Save last flags for the callback */
        sc->sc_if_flags = ifp->if_flags;
        sc->sc_ec_capenable = ec->ec_capenable;
@@ -7291,7 +7300,7 @@
                return 1;
        }
 
- send_packet:
+send_packet:
        txq->txq_fifo_head += len;
        if (txq->txq_fifo_head >= txq->txq_fifo_size)
                txq->txq_fifo_head -= txq->txq_fifo_size;
@@ -7356,14 +7365,14 @@
 
        return 0;
 
- fail_3:
+fail_3:
        bus_dmamap_destroy(sc->sc_dmat, txq->txq_desc_dmamap);
- fail_2:
+fail_2:
        bus_dmamem_unmap(sc->sc_dmat, (void *)txq->txq_descs_u,
            WM_TXDESCS_SIZE(txq));
- fail_1:
+fail_1:
        bus_dmamem_free(sc->sc_dmat, &txq->txq_desc_seg, txq->txq_desc_rseg);
- fail_0:
+fail_0:
        return error;
 }
 
@@ -7481,7 +7490,7 @@
 
        return 0;
 
- fail:
+fail:
        for (i = 0; i < WM_TXQUEUELEN(txq); i++) {
                if (txq->txq_soft[i].txs_dmamap != NULL)
                        bus_dmamap_destroy(sc->sc_dmat,
@@ -7672,7 +7681,7 @@
 
        return 0;
 
- fail_2:
+fail_2:
        for (i = 0; i < rx_done; i++) {
                struct wm_rxqueue *rxq = &sc->sc_queue[i].wmq_rxq;
                wm_free_rx_buffer(sc, rxq);
@@ -7680,7 +7689,7 @@
                if (rxq->rxq_lock)
                        mutex_obj_free(rxq->rxq_lock);
        }
- fail_1:
+fail_1:
        for (i = 0; i < tx_done; i++) {
                struct wm_txqueue *txq = &sc->sc_queue[i].wmq_txq;
                pcq_destroy(txq->txq_interq);
@@ -7692,7 +7701,7 @@
 
        kmem_free(sc->sc_queue,
            sizeof(struct wm_queue) * sc->sc_nqueues);
- fail_0:
+fail_0:
        return error;
 }
 
@@ -8899,12 +8908,12 @@
         * however it does not cause problems.
         */
        /* Fill in the context descriptor. */
-       txq->txq_nq_descs[txq->txq_next].nqrx_ctx.nqtxc_vl_len =
+       txq->txq_nq_descs[txq->txq_next].nqtx_ctx.nqtxc_vl_len =
            htole32(vl_len);
-       txq->txq_nq_descs[txq->txq_next].nqrx_ctx.nqtxc_sn = 0;
-       txq->txq_nq_descs[txq->txq_next].nqrx_ctx.nqtxc_cmd =
+       txq->txq_nq_descs[txq->txq_next].nqtx_ctx.nqtxc_sn = 0;
+       txq->txq_nq_descs[txq->txq_next].nqtx_ctx.nqtxc_cmd =
            htole32(cmdc);
-       txq->txq_nq_descs[txq->txq_next].nqrx_ctx.nqtxc_mssidx =
+       txq->txq_nq_descs[txq->txq_next].nqtx_ctx.nqtxc_mssidx =
            htole32(mssidx);
        wm_cdtxsync(txq, txq->txq_next, 1, BUS_DMASYNC_PREWRITE);
        DPRINTF(sc, WM_DEBUG_TX,
@@ -9067,7 +9076,7 @@
 
                DPRINTF(sc, WM_DEBUG_TX,
                    ("%s: TX: have packet to transmit: %p\n",
-                   device_xname(sc->sc_dev), m0));
+                       device_xname(sc->sc_dev), m0));
 
                txs = &txq->txq_soft[txq->txq_snext];
                dmamap = txs->txs_dmamap;
@@ -10288,9 +10297,13 @@
 wm_sched_handle_queue(struct wm_softc *sc, struct wm_queue *wmq)
 {
 
-       if (wmq->wmq_txrx_use_workqueue)
-               workqueue_enqueue(sc->sc_queue_wq, &wmq->wmq_cookie, curcpu());
-       else
+       if (wmq->wmq_txrx_use_workqueue) {
+               if (!wmq->wmq_wq_enqueued) {
+                       wmq->wmq_wq_enqueued = true;
+                       workqueue_enqueue(sc->sc_queue_wq, &wmq->wmq_cookie,
+                           curcpu());
+               }
+       } else
                softint_schedule(wmq->wmq_si);
 }
 
@@ -10589,8 +10602,10 @@
        struct wm_queue *wmq = container_of(wk, struct wm_queue, wmq_cookie);
 
        /*
-        * "enqueued flag" is not required here.
-        */
+        * Some qemu environment workaround.  They don't stop interrupt
+        * immediately.
+        */
+       wmq->wmq_wq_enqueued = false;
        wm_handle_queue(wmq);
 }
 
@@ -12073,7 +12088,7 @@
  */
 static int
 wm_access_phy_wakeup_reg_bm(device_t dev, int offset, int16_t *val, int rd,
-       bool page_set)
+    bool page_set)
 {
        struct wm_softc *sc = device_private(dev);
        uint16_t regnum = BM_PHY_REG_NUM(offset);
@@ -12462,8 +12477,8 @@
 
        CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
        CSR_WRITE(sc, WMREG_TCTL, sc->sc_tctl);
-       CSR_WRITE(sc, (sc->sc_type < WM_T_82543) ? WMREG_OLD_FCRTL
-                                                : WMREG_FCRTL, sc->sc_fcrtl);
+       CSR_WRITE(sc, (sc->sc_type < WM_T_82543) ?
+           WMREG_OLD_FCRTL : WMREG_FCRTL, sc->sc_fcrtl);
        if (sc->sc_type == WM_T_80003) {
                switch (IFM_SUBTYPE(mii->mii_media_active)) {
                case IFM_1000_T:
@@ -14571,7 +14586,7 @@



Home | Main Index | Thread Index | Old Index