From 221bfa4d75df92cddc4deebaa1f568be6bd44ced Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 27 Jan 2001 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2001-01-27 --- ip/gre.c | 2 +- ip/icmp.c | 2 +- ip/ipaux.c | 6 ++++-- ip/ipmux.c | 2 +- ip/tcp.c | 15 +++++++-------- pc/etherga620.c | 7 ++++--- pc/etherwavelan.c | 14 ++++++++++++-- pc/fns.h | 6 ++++++ pc/kpmemmove.c | 21 +++++++++++++++++++++ pc/mp.c | 15 ++++++++++++++- port/devkprof.c | 3 ++- port/portdat.h | 1 + port/qio.c | 41 +++++++++++++++++++++++++++++++++-------- port/taslock.c | 4 ++-- 14 files changed, 109 insertions(+), 30 deletions(-) create mode 100644 pc/kpmemmove.c diff --git a/ip/gre.c b/ip/gre.c index 6ff233424dd8967c44a1fb91994258a57cac1f95..54e38997a9a0dc82b4767cdcf08aae85d073458b 100644 --- a/ip/gre.c +++ b/ip/gre.c @@ -94,7 +94,7 @@ grestate(Conv *c, char *state, int n) static void grecreate(Conv *c) { - c->rq = qopen(64*1024, 0, 0, c); + c->rq = qopen(64*1024, 1, 0, c); c->wq = qopen(64*1024, 0, 0, 0); } diff --git a/ip/icmp.c b/ip/icmp.c index 9b2fb4f8a7a58400aadb15c507b0d6b1613f2db7..9db10da49fdba76f62863267738d9a173b92139f 100644 --- a/ip/icmp.c +++ b/ip/icmp.c @@ -120,7 +120,7 @@ icmpstate(Conv *c, char *state, int n) static void icmpcreate(Conv *c) { - c->rq = qopen(64*1024, 0, 0, c); + c->rq = qopen(64*1024, 1, 0, c); c->wq = qopen(64*1024, 0, 0, 0); } diff --git a/ip/ipaux.c b/ip/ipaux.c index 480fd08056a726f02c81f07cae637c8212502ed9..4dd93dd26ce031375d5d6ab4ab629baf4c5d725d 100644 --- a/ip/ipaux.c +++ b/ip/ipaux.c @@ -252,8 +252,10 @@ isv4(uchar *ip) void v4tov6(uchar *v6, uchar *v4) { - memmove(v6, v4prefix, IPv4off); - memmove(v6 + IPv4off, v4, IPv4addrlen); + v6[0] = *(ulong)v4prefix; + v6[1] = *(ulong)(v4prefix+4); + v6[2] = *(ulong)(v4prefix+8); + v6[3] = *(ulong)v4; } int diff --git a/ip/ipmux.c b/ip/ipmux.c index cf91da6ccb3b41fd7ef5090d2027f61571545703..f30a9a07d75f9f8e70ea1531c09eefc8612562da 100644 --- a/ip/ipmux.c +++ b/ip/ipmux.c @@ -586,7 +586,7 @@ ipmuxcreate(Conv *c) { Ipmuxrock *r; - c->rq = qopen(64*1024, 0, 0, c); + c->rq = qopen(64*1024, 1, 0, c); c->wq = qopen(64*1024, 0, 0, 0); r = (Ipmuxrock*)(c->ptcl); r->chain = nil; diff --git a/ip/tcp.c b/ip/tcp.c index f756464ec267ba9fdc7ed79cb75ab27c02998b0d..6b0f9c16ad05da98f66af5a8d3f3ac9594e19fb1 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -332,10 +332,10 @@ tcpstate(Conv *c, char *state, int n) s = (Tcpctl*)(c->ptcl); return snprint(state, n, - "%s srtt %d mdev %d cwin %d swin %d rwin %d timer.start %d timer.count %d\n", + "%s srtt %d mdev %d cwin %d swin %d rwin %d timer.start %d timer.count %d rerecv %d\n", tcpstates[s->state], s->srtt, s->mdev, s->cwind, s->snd.wnd, s->rcv.wnd, - s->timer.start, s->timer.count); + s->timer.start, s->timer.count, s->rerecv); } static int @@ -484,7 +484,7 @@ tcpacktimer(void *v) static void tcpcreate(Conv *c) { - c->rq = qopen(QMAX, 0, tcpacktimer, c); + c->rq = qopen(QMAX, -1, tcpacktimer, c); c->wq = qopen(2*QMAX, 0, 0, 0); } @@ -770,7 +770,7 @@ htontcp(Tcp *tcph, Block *data, Tcphdr *ph, Tcpctl *tcb) } else { dlen = 0; - data = allocb(hdrlen + TCP_PKT); + data = allocb(hdrlen + TCP_PKT + 64); /* the 64 pad is to meet mintu's */ if(data == nil) return nil; data->wp += hdrlen + TCP_PKT; @@ -2137,7 +2137,6 @@ int tcptrim(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length) { ushort len; - Block *nbp; uchar accept; int dupcnt, excess; @@ -2197,9 +2196,9 @@ tcptrim(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length) if(excess > 0) { tcb->rerecv += excess; *length -= excess; - nbp = copyblock(*bp, *length); - freeblist(*bp); - *bp = nbp; + *bp = trimblock(*bp, 0, *length); + if(*bp == nil) + panic("presotto is a boofhead"); seg->flags &= ~FIN; } return 0; diff --git a/pc/etherga620.c b/pc/etherga620.c index 8e6db83cb5a9ff4540b05cd0d5d3c3f05776a7f9..d62a749ca11401d4e30d85a3c2d3398a0238494b 100644 --- a/pc/etherga620.c +++ b/pc/etherga620.c @@ -228,7 +228,7 @@ enum { /* Host/NIC Interface ring sizes */ }; enum { - NrsrHI = 128, /* Fill-level of Rsr (m.b. < Nrsr) */ + NrsrHI = 256, /* (WAS 128) Fill-level of Rsr (m.b. < Nrsr) */ NrsrLO = 64, /* Level at which to top-up ring */ NrjrHI = 0, /* Fill-level of Rjr (m.b. < Nrjr) */ NrjrLO = 0, /* Level at which to top-up ring */ @@ -665,11 +665,11 @@ ga620init(Ether* edev) * These defaults are based on the tuning hints in the Alteon * Host/NIC Software Interface Definition and example software. */ - csr32w(ctlr, Rct, 100); + csr32w(ctlr, Rct, 1000); /* was 100 */ csr32w(ctlr, Sct, 0); csr32w(ctlr, St, 100000); csr32w(ctlr, SmcBD, Nsr/4); - csr32w(ctlr, RmcBD, 6); + csr32w(ctlr, RmcBD, 100); /* was 6 */ /* * Enable DMA Assist Logic. @@ -993,6 +993,7 @@ ga620pnp(Ether* edev) edev->irq = ctlr->pcidev->intl; edev->tbdf = ctlr->pcidev->tbdf; edev->mbps = 1000; + edev->oq = qopen(512*1024, 1, 0, 0); /* * Check if the adapter's station address is to be overridden. diff --git a/pc/etherwavelan.c b/pc/etherwavelan.c index cd617a02b40a0c589868af2ba5384b5ea193f400..b49a53dac1a08870af40ac143dde60b33fa4dd45 100644 --- a/pc/etherwavelan.c +++ b/pc/etherwavelan.c @@ -152,6 +152,7 @@ enum WCmdMsk = 0x003f, WCmdAccRd = 0x0021, WCmdAccWr = 0x0121, + WCmdBusy = 0x8000, WCmdTxFree = 0x000b|0x0100, WR_Parm0 = 0x02, WR_Parm1 = 0x04, @@ -313,7 +314,11 @@ w_cmd(Ctlr *ctlr, ushort cmd, ushort arg) int i; int rc; +if(csr_ins(ctlr, WR_Cmd) & WCmdBusy) + print("busy\n"); csr_outs(ctlr, WR_Parm0, arg); + csr_outs(ctlr, WR_Parm1, 0); + csr_outs(ctlr, WR_Parm2, 0); csr_outs(ctlr, WR_Cmd, cmd); for (i = 0; itype,0,1)) return; @@ -400,6 +406,7 @@ static void ltv_outs(Ctlr* ctlr, int type, ushort val) { Wltv l; +delay(100); l.type = type; l.val = val; @@ -424,6 +431,7 @@ ltv_outstr(Ctlr* ctlr, int type, char *val) { Wltv l; int len; +delay(100); len = strlen(val); if(len > sizeof(l.s)) @@ -589,10 +597,11 @@ w_enable(Ether* ether) w_intdis(ctlr); w_cmd(ctlr, WCmdDis, 0); w_intdis(ctlr); +delay(100); if(w_cmd(ctlr, WCmdIni, 0)) return -1; - w_intdis(ctlr); + ltv_outs(ctlr, WTyp_Tick, 8); ltv_outs(ctlr, WTyp_MaxLen, ctlr->maxlen); ltv_outs(ctlr, WTyp_Ptype, ctlr->ptype); @@ -1159,7 +1168,7 @@ ctl(Ether* ether, void* buf, long n) ctlr->keyid = key; kp = &ctlr->key[key-1]; kp->len = strlen(cb->f[1]); - if (kp->len > WKeyLen) +// if (kp->len > WKeyLen) kp->len = WKeyLen; memset(kp->dat, 0, sizeof(kp->dat)); strncpy(kp->dat, cb->f[1], kp->len); @@ -1361,6 +1370,7 @@ reset(Ether* ether) } w_intdis(ctlr); +delay(500); if (w_cmd(ctlr,WCmdIni,0)){ print("#l%d: init failed\n", ether->ctlrno); goto abort; diff --git a/pc/fns.h b/pc/fns.h index 6841d974650eb49c737e63a64186da626ec51047..cbea642561671c3f1faa7928ae27d6cb48217523 100644 --- a/pc/fns.h +++ b/pc/fns.h @@ -134,3 +134,9 @@ ulong TK2MS(ulong); /* ticks to milliseconds */ #define PADDR(a) ((ulong)(a)&~KZERO) #define dcflush(a, b) + +/* + * wrapper around memmove that causes kprof to credit caller for time + */ +// extern void *kpmemmove(void*, void*, long); +// #define memmove kpmemmove diff --git a/pc/kpmemmove.c b/pc/kpmemmove.c new file mode 100644 index 0000000000000000000000000000000000000000..60540b7c1e317f3f72366b8ec9ba439ca126c07c --- /dev/null +++ b/pc/kpmemmove.c @@ -0,0 +1,21 @@ +#include "u.h" +#include "../port/lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "../port/error.h" + +#undef memmove + +void * +kpmemmove(void *s, void *d, long n) +{ + void *p; + if(up == nil) + return memmove(s, d, n); + + up->kppc = getcallerpc(&s); + p = memmove(s, d, n); + up->kppc = 0; + return p; +} diff --git a/pc/mp.c b/pc/mp.c index ed345ac39f10a670ab7fde521a92bb094be62ac6..f52189623918d382702421582fcc7a0f9928d0c1 100644 --- a/pc/mp.c +++ b/pc/mp.c @@ -462,6 +462,8 @@ mpstartap(Apic* apic) void mpinit(void) { + int ncpu; + char *cp; PCMP *pcmp; uchar *e, *p; Apic *apic, *bpapic; @@ -562,11 +564,22 @@ mpinit(void) /* * Initialise the application processors. */ + if(cp = getconf("*ncpu")){ + ncpu = strtol(cp, 0, 0); + if(ncpu < 1) + ncpu = 1; + } + else + ncpu = MaxAPICNO; memmove((void*)APBOOTSTRAP, apbootstrap, sizeof(apbootstrap)); for(apic = mpapic; apic <= &mpapic[MaxAPICNO]; apic++){ + if(ncpu <= 1) + break; if((apic->flags & (PcmpBP|PcmpEN)) == PcmpEN - && apic->type == PcmpPROCESSOR) + && apic->type == PcmpPROCESSOR){ mpstartap(apic); + ncpu--; + } } /* diff --git a/port/devkprof.c b/port/devkprof.c index 2a85e6252c2295decd20d524dc3957fab0480af4..95d0cc31fb551df35589f832265e90222fbd8d63 100644 --- a/port/devkprof.c +++ b/port/devkprof.c @@ -41,7 +41,8 @@ _kproftimer(ulong pc) */ if(pc>=(ulong)spllo && pc<=(ulong)spldone) pc = m->splpc; - + if(up && up->kppc) + pc = up->kppc; kprof.buf[0] += TK2MS(1); if(kprof.minpc<=pc && pclimit = q->inilim = limit; q->kick = kick; q->arg = arg; - q->state = msg ? Qmsg : 0; + q->state = 0; + if(msg > 0) + q->state |= Qmsg; + else if(msg < 0) + q->state |= Qcoalesce; + q->state |= Qstarve; q->eof = 0; q->noblock = 0; @@ -865,15 +871,34 @@ long qread(Queue *q, void *vp, int len) { Block *b; + int m; + uchar *p; + uchar *e; - b = qbread(q, len); - if(b == 0) - return 0; + p = vp; - len = BLEN(b); - memmove(vp, b->rp, len); - freeb(b); - return len; + if((q->state & Qcoalesce) == 0){ + b = qbread(q, len); + if(b == 0) + return 0; + + m = BLEN(b); + memmove(p, b->rp, m); + freeb(b); + return m; + } + + for(e = p + len; p < e; p += m){ + b = qbread(q, e-p); + if(b == 0) + return 0; + + m = BLEN(b); + memmove(p, b->rp, m); + freeb(b); + } + + return p-(uchar*)vp; } static int diff --git a/port/taslock.c b/port/taslock.c index 19a763f72a15b9a8baf4a91d124b7de24bb7d093..bc4bcaca22779cfdde101a8df8406c5ebc482eab 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -170,7 +170,7 @@ unlock(Lock *l) print("unlock of ilock: pc %lux, held by %lux\n", getcallerpc(&l), l->pc); l->pc = 0; l->key = 0; - coherence(); + //coherence(); } void @@ -186,7 +186,7 @@ iunlock(Lock *l) sr = l->sr; l->pc = 0; l->key = 0; - coherence(); + //coherence(); m->splpc = getcallerpc(&l); splxpc(sr);