Sat Feb 28 16:15:19 2009 UTC ()
don't require the ifnum return pointer.


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

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

--- src/sys/rump/net/lib/libshmif/if_shmem.c 2009/02/28 15:28:46 1.1
+++ src/sys/rump/net/lib/libshmif/if_shmem.c 2009/02/28 16:15:19 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_shmem.c,v 1.1 2009/02/28 15:28:46 pooka Exp $ */ 1/* $NetBSD: if_shmem.c,v 1.2 2009/02/28 16:15:19 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,27 +18,27 @@ @@ -18,27 +18,27 @@
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.1 2009/02/28 15:28:46 pooka Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.2 2009/02/28 16:15:19 pooka Exp $");
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/condvar.h> 34#include <sys/condvar.h>
35#include <sys/fcntl.h> 35#include <sys/fcntl.h>
36#include <sys/kmem.h> 36#include <sys/kmem.h>
37#include <sys/kthread.h> 37#include <sys/kthread.h>
38#include <sys/lock.h> 38#include <sys/lock.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>
@@ -72,26 +72,31 @@ struct shmif_sc { @@ -72,26 +72,31 @@ struct shmif_sc {
72#define IFMEM_GENERATION (8) 72#define IFMEM_GENERATION (8)
73#define IFMEM_LASTPACKET (12) 73#define IFMEM_LASTPACKET (12)
74#define IFMEM_WAKEUP (16) 74#define IFMEM_WAKEUP (16)
75#define IFMEM_DATA (20) 75#define IFMEM_DATA (20)
76 76
77#define BUSCTRL_ATOFF(sc, off) ((uint32_t *)(sc->sc_busmem+(off))) 77#define BUSCTRL_ATOFF(sc, off) ((uint32_t *)(sc->sc_busmem+(off)))
78 78
79#define BUSMEM_SIZE 65536 /* enough? */ 79#define BUSMEM_SIZE 65536 /* enough? */
80 80
81static void shmif_rcv(void *); 81static void shmif_rcv(void *);
82 82
83static uint32_t numif; 83static uint32_t numif;
84 84
 85/*
 86 * This locking needs work and will misbehave severely if:
 87 * 1) the backing memory has to be paged in
 88 * 2) some lockholder exits while holding the lock
 89 */
85static void 90static void
86lockbus(struct shmif_sc *sc) 91lockbus(struct shmif_sc *sc)
87{ 92{
88 93
89 __cpu_simple_lock((__cpu_simple_lock_t *)sc->sc_busmem); 94 __cpu_simple_lock((__cpu_simple_lock_t *)sc->sc_busmem);
90} 95}
91 96
92static void 97static void
93unlockbus(struct shmif_sc *sc) 98unlockbus(struct shmif_sc *sc)
94{ 99{
95 100
96 __cpu_simple_unlock((__cpu_simple_lock_t *)sc->sc_busmem); 101 __cpu_simple_unlock((__cpu_simple_lock_t *)sc->sc_busmem);
97} 102}
@@ -219,27 +224,28 @@ rump_shmif_create(const char *path, int  @@ -219,27 +224,28 @@ rump_shmif_create(const char *path, int
219 224
220 sprintf(ifp->if_xname, "shmif%d", mynum); 225 sprintf(ifp->if_xname, "shmif%d", mynum);
221 ifp->if_softc = sc; 226 ifp->if_softc = sc;
222 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 227 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
223 ifp->if_init = shmif_init; 228 ifp->if_init = shmif_init;
224 ifp->if_ioctl = shmif_ioctl; 229 ifp->if_ioctl = shmif_ioctl;
225 ifp->if_start = shmif_start; 230 ifp->if_start = shmif_start;
226 ifp->if_stop = shmif_stop; 231 ifp->if_stop = shmif_stop;
227 ifp->if_mtu = 1518; 232 ifp->if_mtu = 1518;
228 233
229 if_attach(ifp); 234 if_attach(ifp);
230 ether_ifattach(ifp, enaddr); 235 ether_ifattach(ifp, enaddr);
231 236
232 *ifnum = mynum; 237 if (ifnum)
 238 *ifnum = mynum;
233 return 0; 239 return 0;
234 240
235 fail: 241 fail:
236 panic("rump_shmemif_create: fixme"); 242 panic("rump_shmemif_create: fixme");
237} 243}
238 244
239static int 245static int
240shmif_init(struct ifnet *ifp) 246shmif_init(struct ifnet *ifp)
241{ 247{
242 248
243 ifp->if_flags |= IFF_RUNNING; 249 ifp->if_flags |= IFF_RUNNING;
244 return 0; 250 return 0;
245} 251}