Tue Oct 20 23:21:54 2009 UTC ()
printf -> rumpuser_dprintf
(can't use printf while holding spinlock)


(pooka)
diff -r1.7 -r1.8 src/sys/rump/net/lib/libshmif/if_shmem.c

cvs diff -r1.7 -r1.8 src/sys/rump/net/lib/libshmif/if_shmem.c (expand / switch to unified diff)

--- src/sys/rump/net/lib/libshmif/if_shmem.c 2009/05/26 19:03:05 1.7
+++ src/sys/rump/net/lib/libshmif/if_shmem.c 2009/10/20 23:21:53 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_shmem.c,v 1.7 2009/05/26 19:03:05 pooka Exp $ */ 1/* $NetBSD: if_shmem.c,v 1.8 2009/10/20 23:21:53 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by The Nokia Foundation. 6 * Development of this software was supported by The Nokia Foundation.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -18,48 +18,48 @@ @@ -18,48 +18,48 @@
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.7 2009/05/26 19:03:05 pooka Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.8 2009/10/20 23:21:53 pooka Exp $");
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/fcntl.h> 34#include <sys/fcntl.h>
35#include <sys/kmem.h> 35#include <sys/kmem.h>
36#include <sys/kthread.h> 36#include <sys/kthread.h>
37#include <sys/lock.h> 37#include <sys/lock.h>
38#include <sys/atomic.h> 38#include <sys/atomic.h>
39 39
40#include <net/if.h> 40#include <net/if.h>
41#include <net/if_ether.h> 41#include <net/if_ether.h>
42 42
43#include <netinet/in.h> 43#include <netinet/in.h>
44#include <netinet/in_var.h> 44#include <netinet/in_var.h>
45 45
46#include <rump/rump.h> 46#include <rump/rump.h>
47#include <rump/rumpuser.h> 47#include <rump/rumpuser.h>
48 48
49#include "rump_private.h" 49#include "rump_private.h"
50 50
51#if 0 51#if 0
52#define DPRINTF(x) printf x 52#define DPRINTF(x) rumpuser_dprintf x
53#else 53#else
54#define DPRINTF(x) 54#define DPRINTF(x)
55#endif 55#endif
56 56
57/* 57/*
58 * A virtual ethernet interface which uses shared memory from a 58 * A virtual ethernet interface which uses shared memory from a
59 * memory mapped file as the bus. 59 * memory mapped file as the bus.
60 */ 60 */
61 61
62static int shmif_init(struct ifnet *); 62static int shmif_init(struct ifnet *);
63static int shmif_ioctl(struct ifnet *, u_long, void *); 63static int shmif_ioctl(struct ifnet *, u_long, void *);
64static void shmif_start(struct ifnet *); 64static void shmif_start(struct ifnet *);
65static void shmif_stop(struct ifnet *, int); 65static void shmif_stop(struct ifnet *, int);
@@ -336,27 +336,27 @@ shmif_rcv(void *arg) @@ -336,27 +336,27 @@ shmif_rcv(void *arg)
336 } 336 }
337 337
338 DPRINTF(("waiting %d/%d\n", sc->sc_nextpacket, sc->sc_prevgen)); 338 DPRINTF(("waiting %d/%d\n", sc->sc_nextpacket, sc->sc_prevgen));
339 339
340 KASSERT(m->m_flags & M_EXT); 340 KASSERT(m->m_flags & M_EXT);
341 lockbus(sc); 341 lockbus(sc);
342 lastpkt = *BUSCTRL_ATOFF(sc, IFMEM_LASTPACKET); 342 lastpkt = *BUSCTRL_ATOFF(sc, IFMEM_LASTPACKET);
343 busgen = *BUSCTRL_ATOFF(sc, IFMEM_GENERATION); 343 busgen = *BUSCTRL_ATOFF(sc, IFMEM_GENERATION);
344 lastnext = nextpktoff(sc, lastpkt); 344 lastnext = nextpktoff(sc, lastpkt);
345 if ((lastnext > sc->sc_nextpacket && busgen > sc->sc_prevgen) 345 if ((lastnext > sc->sc_nextpacket && busgen > sc->sc_prevgen)
346 || (busgen > sc->sc_prevgen+1)) { 346 || (busgen > sc->sc_prevgen+1)) {
347 nextpkt = lastpkt; 347 nextpkt = lastpkt;
348 sc->sc_prevgen = busgen; 348 sc->sc_prevgen = busgen;
349 printf("DROPPING\n"); 349 rumpuser_dprintf("DROPPING\n");
350 } else { 350 } else {
351 nextpkt = sc->sc_nextpacket; 351 nextpkt = sc->sc_nextpacket;
352 } 352 }
353 353
354 /* need more data? */ 354 /* need more data? */
355 if (lastnext == nextpkt && sc->sc_prevgen == busgen){ 355 if (lastnext == nextpkt && sc->sc_prevgen == busgen){
356 unlockbus(sc); 356 unlockbus(sc);
357 error = 0; 357 error = 0;
358 rumpuser_writewatchfile_wait(sc->sc_kq, NULL, &error); 358 rumpuser_writewatchfile_wait(sc->sc_kq, NULL, &error);
359 if (__predict_false(error)) 359 if (__predict_false(error))
360 printf("shmif_rcv: wait failed %d\n", error); 360 printf("shmif_rcv: wait failed %d\n", error);
361 continue; 361 continue;
362 } 362 }