Module Name:    src
Committed By:   martin
Date:           Tue Aug  7 13:02:31 UTC 2018

Modified Files:
        src/doc [netbsd-8]: TODO.smpnet
        src/sys/dev/pci [netbsd-8]: if_lmc.c if_lmc.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #950):

        sys/dev/pci/if_lmc.h: revision 1.25
        sys/dev/pci/if_lmc.c: revision 1.65
        doc/TODO.smpnet: revision 1.20

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.


To generate a diff of this commit:
cvs rdiff -u -r1.11.6.1 -r1.11.6.2 src/doc/TODO.smpnet
cvs rdiff -u -r1.63 -r1.63.6.1 src/sys/dev/pci/if_lmc.c
cvs rdiff -u -r1.24 -r1.24.6.1 src/sys/dev/pci/if_lmc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/TODO.smpnet
diff -u src/doc/TODO.smpnet:1.11.6.1 src/doc/TODO.smpnet:1.11.6.2
--- src/doc/TODO.smpnet:1.11.6.1	Sat Oct 21 19:43:54 2017
+++ src/doc/TODO.smpnet	Tue Aug  7 13:02:31 2018
@@ -1,4 +1,4 @@
-$NetBSD: TODO.smpnet,v 1.11.6.1 2017/10/21 19:43:54 snj Exp $
+$NetBSD: TODO.smpnet,v 1.11.6.2 2018/08/07 13:02:31 martin Exp $
 
 MP-safe components
 ==================
@@ -96,7 +96,7 @@ This is the list of the functions that h
 
  - 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

Index: src/sys/dev/pci/if_lmc.c
diff -u src/sys/dev/pci/if_lmc.c:1.63 src/sys/dev/pci/if_lmc.c:1.63.6.1
--- src/sys/dev/pci/if_lmc.c:1.63	Tue Jan 24 09:05:28 2017
+++ src/sys/dev/pci/if_lmc.c	Tue Aug  7 13:02:31 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_lmc.c,v 1.63 2017/01/24 09:05:28 ozaki-r Exp $ */
+/* $NetBSD: if_lmc.c,v 1.63.6.1 2018/08/07 13:02:31 martin Exp $ */
 
 /*-
  * Copyright (c) 2002-2006 David Boggs. <bo...@boggs.palo-alto.ca.us>
@@ -74,7 +74,7 @@
  */
 
 # include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.63 2017/01/24 09:05:28 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.63.6.1 2018/08/07 13:02:31 martin Exp $");
 # include <sys/param.h>	/* OS version */
 # include "opt_inet.h"	/* INET6, INET */
 # include "opt_altq_enabled.h" /* ALTQ */
@@ -3388,7 +3388,7 @@ ifnet_output(struct ifnet *ifp, struct m
     }
   else
     /* Process tx pkts; do not process rx pkts. */
-    lmc_interrupt(sc, 0, 0);
+    ifnet_start(ifp);
 
   return error;
   }
@@ -3466,9 +3466,43 @@ static void  /* context: process */
 ifnet_start(struct ifnet *ifp)
   {
   softc_t *sc = IFP2SC(ifp);
+  int activity;
 
-  /* Process tx pkts; do not process rx pkts. */
-  lmc_interrupt(sc, 0, 0);
+  /* 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 @@ rxintr_cleanup(softc_t *sc)
     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 @@ txintr_cleanup(softc_t *sc)
         /* 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 @@ txintr_setup(softc_t *sc)
   /* 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 @@ lmc_interrupt(void *arg, int quota, int 
   do
     {
     activity  = txintr_cleanup(sc);
-    activity += txintr_setup(sc);
     activity += rxintr_cleanup(sc);
     activity += rxintr_setup(sc);
     } while (activity);

Index: src/sys/dev/pci/if_lmc.h
diff -u src/sys/dev/pci/if_lmc.h:1.24 src/sys/dev/pci/if_lmc.h:1.24.6.1
--- src/sys/dev/pci/if_lmc.h:1.24	Tue Jan 24 09:05:28 2017
+++ src/sys/dev/pci/if_lmc.h	Tue Aug  7 13:02:31 2018
@@ -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.24.6.1 2018/08/07 13:02:31 martin Exp $
  *
  * Copyright (c) 2002-2006 David Boggs. (bo...@boggs.palo-alto.ca.us)
  * All rights reserved.
@@ -984,7 +984,6 @@ typedef int intr_return_t;
 # 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);	\

Reply via email to