Source-Changes-HG archive

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

[src/trunk]: src Move txintr_setup() stuff from lmc_interrupt() and do it in ...



details:   https://anonhg.NetBSD.org/src/rev/9147184870e1
branches:  trunk
changeset: 324253:9147184870e1
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Jun 25 09:32:28 2018 +0000

description:
Move txintr_setup() stuff from lmc_interrupt() and do it in ifnet_start().
Now we can use bpf_mtap() in the TX path. Not tested.

diffstat:

 doc/TODO.smpnet      |   4 +-
 sys/dev/pci/if_lmc.c |  55 +++++++++++++++++++++++++++++++++++++++++----------
 sys/dev/pci/if_lmc.h |   3 +-
 3 files changed, 47 insertions(+), 15 deletions(-)

diffs (147 lines):

diff -r 22d0589bfc25 -r 9147184870e1 doc/TODO.smpnet
--- a/doc/TODO.smpnet   Mon Jun 25 04:59:42 2018 +0000
+++ b/doc/TODO.smpnet   Mon Jun 25 09:32:28 2018 +0000
@@ -1,4 +1,4 @@
-$NetBSD: TODO.smpnet,v 1.19 2018/02/27 14:28:01 maxv Exp $
+$NetBSD: TODO.smpnet,v 1.20 2018/06/25 09:32:28 msaitoh Exp $
 
 MP-safe components
 ==================
@@ -104,7 +104,7 @@
 
  - sca_frame_process() @ sys/dev/ic/hd64570.c
  - en_intr() @ sys/dev/ic/midway.c
- - rxintr_cleanup() and txintr_cleanup() @ sys/dev/pci/if_lmc.c
+ - rxintr_cleanup() @ sys/dev/pci/if_lmc.c
  - ipr_rx_data_rdy() @ sys/netisdn/i4b_ipr.c
 
 Ideally we should make the functions run in softint somehow, but we don't have
diff -r 22d0589bfc25 -r 9147184870e1 sys/dev/pci/if_lmc.c
--- a/sys/dev/pci/if_lmc.c      Mon Jun 25 04:59:42 2018 +0000
+++ b/sys/dev/pci/if_lmc.c      Mon Jun 25 09:32:28 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_lmc.c,v 1.64 2018/02/07 06:18:11 mrg Exp $ */
+/* $NetBSD: if_lmc.c,v 1.65 2018/06/25 09:32:28 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2002-2006 David Boggs. <boggs%boggs.palo-alto.ca.us@localhost>
@@ -74,7 +74,7 @@
  */
 
 # include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.64 2018/02/07 06:18:11 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.65 2018/06/25 09:32:28 msaitoh Exp $");
 # include <sys/param.h>        /* OS version */
 # include "opt_inet.h" /* INET6, INET */
 # include "opt_altq_enabled.h" /* ALTQ */
@@ -3388,7 +3388,7 @@
     }
   else
     /* Process tx pkts; do not process rx pkts. */
-    lmc_interrupt(sc, 0, 0);
+    ifnet_start(ifp);
 
   return error;
   }
@@ -3466,9 +3466,43 @@
 ifnet_start(struct ifnet *ifp)
   {
   softc_t *sc = IFP2SC(ifp);
-
-  /* Process tx pkts; do not process rx pkts. */
-  lmc_interrupt(sc, 0, 0);
+  int activity;
+
+  /* Do this FIRST!  Otherwise UPs deadlock and MPs spin. */
+  WRITE_CSR(sc, TLP_STATUS, READ_CSR(sc, TLP_STATUS));
+
+  /* If any CPU is inside this critical section, then */
+  /*  other CPUs should go away without doing anything. */
+  if (BOTTOM_TRYLOCK(sc) == 0)
+    {
+    sc->status.cntrs.lck_intr++;
+    return;
+    }
+
+  /* In Linux, pci_alloc_consistent() means DMA */
+  /*  descriptors do not need explicit syncing? */
+#if BSD
+  {
+  struct desc_ring *ring = &sc->txring;
+  DMA_SYNC(sc->txring.map, sc->txring.size_descs,
+   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+  }
+#endif
+
+  do
+    {
+    activity = txintr_setup(sc);
+    } while (activity);
+
+#if BSD
+  {
+  struct desc_ring *ring = &sc->txring;
+  DMA_SYNC(sc->txring.map, sc->txring.size_descs,
+   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+  }
+#endif
+
+  BOTTOM_UNLOCK(sc);
   }
 
 static void  /* context: softirq */
@@ -4294,7 +4328,7 @@
     sc->status.cntrs.ipackets++;
 
     /* Berkeley Packet Filter */
-    LMC_BPF_MTAP(sc, first_mbuf);
+    bpf_mtap_softint(sc->ifp, first_mbuf);
 
     /* Give this good packet to the network stacks. */
     sc->quota--;
@@ -4444,9 +4478,6 @@
         /* Include CRC and one flag byte in output byte count. */
         sc->status.cntrs.obytes += m->m_pkthdr.len + sc->config.crc_len +1;
         sc->status.cntrs.opackets++;
-
-        /* Berkeley Packet Filter */
-        LMC_BPF_MTAP(sc, m);
        }
 
       m_freem(m);
@@ -4564,6 +4595,9 @@
   /* Enqueue the mbuf; txintr_cleanup will free it. */
   mbuf_enqueue(ring, sc->tx_mbuf);
 
+  /* Berkeley Packet Filter */
+  bpf_mtap(sc->ifp, sc->tx_mbuf);
+
   /* The transmitter has room for another packet. */
   sc->tx_mbuf = NULL;
 
@@ -4969,7 +5003,6 @@
   do
     {
     activity  = txintr_cleanup(sc);
-    activity += txintr_setup(sc);
     activity += rxintr_cleanup(sc);
     activity += rxintr_setup(sc);
     } while (activity);
diff -r 22d0589bfc25 -r 9147184870e1 sys/dev/pci/if_lmc.h
--- a/sys/dev/pci/if_lmc.h      Mon Jun 25 04:59:42 2018 +0000
+++ b/sys/dev/pci/if_lmc.h      Mon Jun 25 09:32:28 2018 +0000
@@ -1,5 +1,5 @@
 /*-
- * $NetBSD: if_lmc.h,v 1.24 2017/01/24 09:05:28 ozaki-r Exp $
+ * $NetBSD: if_lmc.h,v 1.25 2018/06/25 09:32:28 msaitoh Exp $
  *
  * Copyright (c) 2002-2006 David Boggs. (boggs%boggs.palo-alto.ca.us@localhost)
  * All rights reserved.
@@ -984,7 +984,6 @@
 # define SLEEP(usecs)          tsleep(sc, PZERO, DEVICE_NAME, 1+(usecs/tick))
 # define DMA_SYNC(map, size, flags) bus_dmamap_sync(ring->tag, map, 0, size, flags)
 # define DMA_LOAD(map, addr, size)  bus_dmamap_load(ring->tag, map, addr, size, 0, BUS_DMA_NOWAIT)
-#  define LMC_BPF_MTAP(sc, mbuf)       bpf_mtap_softint((sc)->ifp, mbuf)
 #  define LMC_BPF_ATTACH(sc, dlt, len)                 \
        do {                                            \
                bpf_attach((sc)->ifp, dlt, len);        \



Home | Main Index | Thread Index | Old Index