Module Name: src
Committed By: msaitoh
Date: Mon Jun 25 09:32:28 UTC 2018
Modified Files:
src/doc: TODO.smpnet
src/sys/dev/pci: if_lmc.c if_lmc.h
Log Message:
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.19 -r1.20 src/doc/TODO.smpnet
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pci/if_lmc.c
cvs rdiff -u -r1.24 -r1.25 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.19 src/doc/TODO.smpnet:1.20
--- src/doc/TODO.smpnet:1.19 Tue Feb 27 14:28:01 2018
+++ src/doc/TODO.smpnet Mon Jun 25 09:32:28 2018
@@ -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 @@ 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.64 src/sys/dev/pci/if_lmc.c:1.65
--- src/sys/dev/pci/if_lmc.c:1.64 Wed Feb 7 06:18:11 2018
+++ src/sys/dev/pci/if_lmc.c Mon Jun 25 09:32:28 2018
@@ -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. <[email protected]>
@@ -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 @@ 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.25
--- src/sys/dev/pci/if_lmc.h:1.24 Tue Jan 24 09:05:28 2017
+++ src/sys/dev/pci/if_lmc.h Mon Jun 25 09:32:28 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.25 2018/06/25 09:32:28 msaitoh Exp $
*
* Copyright (c) 2002-2006 David Boggs. ([email protected])
* 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); \