vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

commit 5324a21439b8ad818d63b2db7159a1149e4c005c
parent 757d3773121cde3586e68bd2ade633bbfde3501c
Author: yiyus <yiyu.jgl@gmail.com>
Date:   Sat, 17 Jul 2010 16:43:38 +0200

more a/*.ed updates (new devether.ed)

Diffstat:
src/9vx/a/devether.c | 38+++++++++++++++++++-------------------
src/9vx/a/devether.ed | 34++++++++++++++++++++++++++++++++++
src/9vx/a/devmnt.c | 6+++---
src/9vx/a/devpipe.c | 2+-
src/9vx/a/etherif.ed | 3+++
src/9vx/a/etherif.h | 2+-
src/9vx/makea | 8+++++++-
7 files changed, 68 insertions(+), 25 deletions(-)

diff --git a/src/9vx/a/devether.c b/src/9vx/a/devether.c @@ -11,7 +11,6 @@ #include "etherif.h" extern int memsize; - static Ether *etherxx[MaxEther]; Chan* @@ -163,11 +162,7 @@ etheriq(Ether* ether, Block* bp, int fromwire) /* is it for me? */ tome = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; fromme = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0; - // if(tome||fromme) - // iprint("XXX PACK: %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux -> %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux%s[%d]%s\n", - // pkt->s[0], pkt->s[1], pkt->s[2],pkt->s[3], pkt->s[4], pkt->s[5], - // pkt->d[0], pkt->d[1], pkt->d[2],pkt->d[3], pkt->d[4], pkt->d[5], - // (tome ? " <<--" : ""), len, (fromme ? " -->>" : "")); + /* * Multiplex the packet to all the connections which want it. * If the packet is not to be used subsequently (fromwire != 0), @@ -175,7 +170,7 @@ etheriq(Ether* ether, Block* bp, int fromwire) * saving a copy of the data (usual case hopefully). */ for(fp = ether->ni.f; fp < ep; fp++){ - if((f = *fp) != nil) + if(f = *fp) if(f->type == type || f->type < 0) if(tome || multi || f->prom){ /* Don't want to hear bridged packets */ @@ -184,14 +179,18 @@ etheriq(Ether* ether, Block* bp, int fromwire) if(!f->headersonly){ if(fromwire && fx == 0) fx = f; - else if((xbp = iallocb(len)) != nil){ + else if(xbp = iallocb(len)){ memmove(xbp->wp, pkt, len); xbp->wp += len; - if(qpass(f->in, xbp) < 0) + if(qpass(f->in, xbp) < 0) { + print("soverflow for f->in\n"); ether->ni.soverflows++; + } } - else + else { + print("soverflow iallocb\n"); ether->ni.soverflows++; + } } else etherrtrace(f, pkt, len); @@ -199,8 +198,10 @@ etheriq(Ether* ether, Block* bp, int fromwire) } if(fx){ - if(qpass(fx->in, bp) < 0) + if(qpass(fx->in, bp) < 0) { + print("soverflow for fx->in\n"); ether->ni.soverflows++; + } return 0; } if(fromwire){ @@ -238,6 +239,8 @@ etheroq(Ether* ether, Block* bp) } if(!loopback){ + if(qfull(ether->oq)) + print("etheroq: WARNING: ether->oq full!\n"); qbwrite(ether->oq, bp); if(ether->transmit != nil) ether->transmit(ether); @@ -378,7 +381,7 @@ etherprobe(int cardno, int ctlrno) memset(ether, 0, sizeof(Ether)); ether->ctlrno = ctlrno; ether->tbdf = BUSUNKNOWN; - ether->ni.mbps = 100; + ether->ni.mbps = 10; ether->minmtu = ETHERMINTU; ether->maxmtu = ETHERMAXTU; @@ -433,24 +436,21 @@ etherprobe(int cardno, int ctlrno) lg = 14; /* allocate larger output queues for higher-speed interfaces */ bsz = 1UL << (lg + 17); /* 2ⁱ⁷ = 128K, bsz = 2ⁿ × 128K */ - while (bsz > memsize && bsz >= 128*1024) + while (bsz > memsize && bsz > 128*1024) bsz /= 2; netifinit(&ether->ni, name, Ntypes, bsz); - while (ether->oq == nil && bsz >= 128*1024) { - bsz /= 2; + if(ether->oq == nil) { ether->oq = qopen(bsz, Qmsg, 0, 0); ether->ni.limit = bsz; } if(ether->oq == nil) - panic("etherreset %s", name); + panic("etherreset %s: can't allocate output queue of %ld bytes", + name, bsz); ether->ni.alen = Eaddrlen; memmove(ether->ni.addr, ether->ea, Eaddrlen); memset(ether->ni.bcast, 0xFF, Eaddrlen); - // iprint("XXX EADDR: %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux\n", - // ether->ea[0], ether->ea[1], ether->ea[2],ether->ea[3], ether->ea[4], ether->ea[5]); - return ether; } diff --git a/src/9vx/a/devether.ed b/src/9vx/a/devether.ed @@ -0,0 +1,34 @@ +/"pool\.h"/d +/^static Ether/i +extern int memsize; +. +,s!mainmem->maxsize / 8!memsize!g +,s/MACHP(0)->ticks/MACHP(0)->tscticks/g +/isaconfig/;/}/d +/cistrcmp/;+1d +/getconf/;+2d +/intrenable/-6;+6d +,s/(etherxx\[chan->dev\]/(\&etherxx\[chan->dev\]->ni/ +/^ethercreate/ s/Chan\*, char\*, int, ulong/Chan* ch, char* c, int i, ulong ul/ +/^etherwrite/ s/vlong/vlong v/ +/^etherbwrite/ s/ulong/ulong u/ +/activemulti(/ s/ether/\&&->ni/ +/netifread(/ s/ether/\&&->ni/ +/netifwrite(/ s/ether/\&&->ni/ +/netifinit(/ s/ether/\&&->ni/ +,s/ether->inpackets/ether->ni.inpackets/g +,s/ether->f/ether->ni.f/g +,s/ether->soverflows/ether->ni.soverflows/g +,s/ether->outpackets/ether->ni.outpackets/g +,s/ether->bcast/ether->ni.bcast/g +,s/ether->prom/ether->ni.prom/g +,s/ether->mbps/ether->ni.mbps/g +,s/ether->alen/ether->ni.alen/g +,s/ether->addr/ether->ni.addr/g +,s/ether->limit/ether->ni.limit/g +,s/ether->nopt/ether->isac.nopt/g +,s/ether->opt/ether->isac.opt/g +,s/ether->mem/ether->isac.mem/g +,s/ether->size/ether->isac.size/g +,s/ether->port/ether->isac.port/g +,s/ether->irq/ether->isac.irq/g diff --git a/src/9vx/a/devmnt.c b/src/9vx/a/devmnt.c @@ -81,7 +81,7 @@ void (*mntstats)(int, Chan*, uvlong, ulong); static void mntreset(void) { - mntalloc.id = 10; /* 1-9 are reserved for devfs */ + mntalloc.id = 1; mntalloc.tagmask[0] = 1; /* don't allow 0 as a tag */ mntalloc.tagmask[NMASK-1] = 0x80000000UL; /* don't allow NOTAG */ fmtinstall('F', fcallfmt); @@ -772,7 +772,7 @@ mountrpc(Mnt *m, Mntrpc *r) cn = "?"; if(r->c != nil && r->c->path != nil) cn = r->c->path->s; - print("mnt: proc %s %lud: mismatch from %s %s rep 0x%lux tag %d fid %d T%d R%d rp %d\n", + print("mnt: proc %s %lud: mismatch from %s %s rep %#p tag %d fid %d T%d R%d rp %d\n", up->text, up->pid, sn, cn, r, r->request.tag, r->request.fid, r->request.type, r->reply.type, r->reply.tag); @@ -1107,8 +1107,8 @@ mntfree(Mntrpc *r) lock(&mntalloc.lk); if(mntalloc.nrpcfree >= 10){ free(r->rpc); - free(r); freetag(r->request.tag); + free(r); } else{ r->list = mntalloc.rpcfree; diff --git a/src/9vx/a/devpipe.c b/src/9vx/a/devpipe.c @@ -310,7 +310,7 @@ pipewrite(Chan *c, void *va, long n, vlong offset) Pipe *p; if(!islo()) - print("pipewrite hi %lux\n", getcallerpc(&c)); + print("pipewrite hi %#p\n", getcallerpc(&c)); if(waserror()) { /* avoid notes when pipe is a mounted queue */ if((c->flag & CMSG) == 0) diff --git a/src/9vx/a/etherif.ed b/src/9vx/a/etherif.ed @@ -0,0 +1,3 @@ +/ISAConf/ s/;/ isac;/ +/Netif/ s/;/ ni;/ +/NEXT/ s/((x)+1)/((uint)(x)+1)/ diff --git a/src/9vx/a/etherif.h b/src/9vx/a/etherif.h @@ -5,7 +5,7 @@ enum { typedef struct Ether Ether; struct Ether { - ISAConf isac; + ISAConf isac; /* hardware info */ int ctlrno; int tbdf; /* type+busno+devno+funcno */ diff --git a/src/9vx/makea b/src/9vx/makea @@ -7,10 +7,16 @@ orig=$HOME/plan9 if [ $# -gt 0 ]; then if [ $1 == "-r" ]; then shift - orig=$1/sys/src/9 + orig=$1 shift fi fi +orig=$orig/sys/src/9 + +if [ ! -d $orig ]; then + echo "Error: $orig is not a valid Plan9 root" 1>&2 + exit 1 +fi files=a/*.ed if [ $# -gt 0 ]; then