Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/net/lib/libshmif further simplify & fix calculations



details:   https://anonhg.NetBSD.org/src/rev/a082a14f45b8
branches:  trunk
changeset: 757065:a082a14f45b8
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Aug 12 18:39:54 2010 +0000

description:
further simplify & fix calculations

diffstat:

 sys/rump/net/lib/libshmif/if_shmem.c |  21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diffs (71 lines):

diff -r 06f565ecc81f -r a082a14f45b8 sys/rump/net/lib/libshmif/if_shmem.c
--- a/sys/rump/net/lib/libshmif/if_shmem.c      Thu Aug 12 18:22:40 2010 +0000
+++ b/sys/rump/net/lib/libshmif/if_shmem.c      Thu Aug 12 18:39:54 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_shmem.c,v 1.17 2010/08/12 18:17:23 pooka Exp $      */
+/*     $NetBSD: if_shmem.c,v 1.18 2010/08/12 18:39:54 pooka Exp $      */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.17 2010/08/12 18:17:23 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.18 2010/08/12 18:39:54 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -79,7 +79,8 @@
        uint32_t sc_prevgen;
 };
 
-#define BUSMEM_SIZE (1024*1024) /* need write throttling? */
+#define BUSMEM_SIZE (1024*1024)
+#define BUSMEM_DATASIZE (BUSMEM_SIZE - sizeof(struct shmif_mem))
 
 static const uint32_t busversion = SHMIF_VERSION;
 
@@ -120,8 +121,8 @@
 {
        size_t chunk;
 
-       KASSERT(len < (BUSMEM_SIZE - IFMEM_DATA) && off <= BUSMEM_SIZE);
-       chunk = MIN(len, BUSMEM_SIZE - off);
+       KASSERT(len < (BUSMEM_DATASIZE) && off <= BUSMEM_DATASIZE);
+       chunk = MIN(len, BUSMEM_DATASIZE - off);
        memcpy(dest, sc->sc_busmem->shm_data + off, chunk);
        len -= chunk;
 
@@ -142,9 +143,9 @@
 {
        size_t chunk;
 
-       KASSERT(len < (BUSMEM_SIZE - IFMEM_DATA) && off <= BUSMEM_SIZE);
+       KASSERT(len < (BUSMEM_DATASIZE) && off <= BUSMEM_DATASIZE);
 
-       chunk = MIN(len, BUSMEM_SIZE - off);
+       chunk = MIN(len, BUSMEM_DATASIZE - off);
        memcpy(sc->sc_busmem->shm_data + off, data, chunk);
        len -= chunk;
 
@@ -170,8 +171,8 @@
        uint32_t newoff;
 
        newoff = oldoff + delta;
-       if (newoff >= BUSMEM_SIZE)
-               newoff -= (BUSMEM_SIZE - IFMEM_DATA);
+       if (newoff >= BUSMEM_DATASIZE)
+               newoff -= (BUSMEM_DATASIZE);
        return newoff;
 
 }
@@ -182,7 +183,7 @@
        uint32_t oldlen;
 
        busread(sc, &oldlen, oldoff, PKTLEN_SIZE);
-       KASSERT(oldlen < BUSMEM_SIZE - IFMEM_DATA);
+       KASSERT(oldlen < BUSMEM_DATASIZE);
 
        return advance(oldoff, PKTLEN_SIZE + oldlen);
 }



Home | Main Index | Thread Index | Old Index