From ef1d1140da4a0f49c8263d70f33392cd46e17bd1 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 6 Aug 1997 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1997-08-06 --- ip/devip.c | 4 ++-- ip/il.c | 4 ++-- ip/ip.c | 6 ++++-- ip/ip.h | 3 +++ ip/netlog.c | 2 ++ ip/tcp.c | 1 + ip/udp.c | 20 ++++++-------------- pc/ether82557.c | 40 ++++++++++++++++++++-------------------- pc/etherelnk3.c | 2 +- port/qio.c | 1 + 10 files changed, 42 insertions(+), 41 deletions(-) diff --git a/ip/devip.c b/ip/devip.c index 54fe3ceba81626daaefe44b7ea8c575080e6bf81..2605ade1efc970117fe30056759ff674ad8323ac 100644 --- a/ip/devip.c +++ b/ip/devip.c @@ -918,9 +918,9 @@ Fspcolstats(char *buf, int len) n = 0; for(p = fs.p; *p; p++) n += snprint(buf + n, len - n, - "%s: csum %d hlen %d len %d order %d rexmit %d\n", + "%s: csum %d hlen %d len %d order %d rexmit %d wc %d\n", (*p)->name, (*p)->csumerr, (*p)->hlenerr, (*p)->lenerr, - (*p)->order, (*p)->rexmit); + (*p)->order, (*p)->rexmit, (*p)->wclosed); return n; } diff --git a/ip/il.c b/ip/il.c index b13b858a265958611a8e76f2aeb2c1f2cc8ed8ab..fa7e185bd44f4f08e891863a671c497f0784ff95 100644 --- a/ip/il.c +++ b/ip/il.c @@ -128,7 +128,7 @@ enum Seconds = 1000, Iltickms = 100, /* time base */ - Ackkeepalive = 6000*Iltickms, + Ackkeepalive = 600*Seconds, Acktime = 2*Iltickms, /* max time twixt message rcvd & ack sent */ Slowtime = 90*Seconds, /* max time waiting for an ack before hangup */ @@ -1015,7 +1015,7 @@ loop: void ilbackoff(Ilcb *ic) { - ic->fasttime += ic->fasttime<<1; + ic->fasttime += ic->fasttime>>1; } char* diff --git a/ip/ip.c b/ip/ip.c index ca1348d8afd0cb0f153873702417ccf29d444cf4..66028cc30f40fbe32f6bc7c117531a134105f3aa 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -224,6 +224,8 @@ initfrag(int size) void (*ipextprotoiput)(Block*); +//#define DBG(x) if((logmask & Logipmsg) && (iponly == 0 || x == iponly))netlog + void ipiput(Media *m, Block *bp) { @@ -232,8 +234,8 @@ ipiput(Media *m, Block *bp) ushort frag; int notforme; -/* h = (Iphdr *)(bp->rp); - netlog(Logip, "ipiput %I %I len %d proto %d\n", h->src, h->dst, BLEN(bp), h->proto);*/ +// h = (Iphdr *)(bp->rp); +// DBG(nhgetl(h->src))(Logipmsg, "ipiput %I %I len %d proto %d\n", h->src, h->dst, BLEN(bp), h->proto); /* Ensure we have enough data to process */ if(BLEN(bp) < IPHDR) { diff --git a/ip/ip.h b/ip/ip.h index 31589bcffb4cec23efdc6d2f968c9879328c6a54..5cd2ed796ea9a05640f39808ef18d8bb2063dd57 100644 --- a/ip/ip.h +++ b/ip/ip.h @@ -183,6 +183,7 @@ struct Proto ulong lenerr; /* short packet */ ulong order; /* out of order */ ulong rexmit; /* retransmissions */ + ulong wclosed; /* window closed */ }; struct Fs @@ -218,6 +219,8 @@ enum Logppp= 1<<10, Logtcpmsg= 1<<11, Logigmp= 1<<12, + Logudpmsg= 1<<13, + Logipmsg= 1<<14, }; extern int logmask; /* mask of things to debug */ diff --git a/ip/netlog.c b/ip/netlog.c index a8c3306e42bd570636497bf199117878efe209ed..75698b43d67c4c941b9003ec80e4b232766a79b2 100644 --- a/ip/netlog.c +++ b/ip/netlog.c @@ -46,6 +46,8 @@ static Logflag flags[] = { "ilmsg", Logil|Logilmsg, }, { "gre", Loggre, }, { "tcpmsg", Logtcp|Logtcpmsg, }, + { "udpmsg", Logudp|Logudpmsg, }, + { "ipmsg", Logip|Logipmsg, }, { nil, 0, }, }; diff --git a/ip/tcp.c b/ip/tcp.c index efc0432bb1030efdd03ea5c6cd5cb9aed8b41427..54929477d8423dc832a7e3e77f0d620412c44361 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -1469,6 +1469,7 @@ tcpoutput(Conv *s) * window probes to one */ if(tcb->snd.wnd == 0){ + tcp.wclosed++; if(sent != 0) { if ((tcb->flags&FORCE) == 0) break; diff --git a/ip/udp.c b/ip/udp.c index e8011ef3d581abe7cfd9d83df985aa6d7fd79038..903727c2ebc60c49cd1a3b49c1d0f336afce0bfe 100644 --- a/ip/udp.c +++ b/ip/udp.c @@ -95,8 +95,8 @@ udpannounce(Conv *c, char** argv, int argc) static void udpcreate(Conv *c) { - c->rq = qopen(16*1024, 1, 0, 0); - c->wq = qopen(16*1024, 0, 0, 0); + c->rq = qopen(64*1024, 1, 0, 0); + c->wq = qopen(64*1024, 0, 0, 0); } static void @@ -124,7 +124,7 @@ udpkick(Conv *c, int l) Udphdr *uh; ushort rport; Ipaddr laddr, raddr; - Block *bp, *f; + Block *bp; Udpcb *ucb; int dlen, ptcllen; @@ -158,18 +158,7 @@ udpkick(Conv *c, int l) laddr = 0; } - /* Round packet up to even number of bytes */ dlen = blocklen(bp); - if(dlen & 1) { - for(f = bp; f->next; f = f->next) - ; - if(f->wp >= f->lim) { - f->next = allocb(1); - f = f->next; - } - *f->wp++ = 0; - dlen++; - } /* Make space to fit udp & ip header */ bp = padblock(bp, UDP_IPHDR+UDP_HDRSIZE); @@ -267,6 +256,9 @@ udpiput(Media *m, Block *bp) return; } + netlog(Logudpmsg, "udp: %I.%d -> %I.%d l %d\n", uh->udpsrc, rport, + uh->udpdst, lport, len); + ucb = (Udpcb*)c->ptcl; if(ucb->headers) { diff --git a/pc/ether82557.c b/pc/ether82557.c index 022d588306132904fdb4c7b1e8aab066d1a01133..56f955fe7c51fed9302334b34bdb1ff9c0eb7593 100644 --- a/pc/ether82557.c +++ b/pc/ether82557.c @@ -1,10 +1,11 @@ /* * Intel 82557 Fast Ethernet PCI Bus LAN Controller * as found on the Intel EtherExpress PRO/100B. This chip is full - * of smarts, unfortunately none of them are in the right place. + * of smarts, unfortunately they're not all in the right place. * To do: * the PCI scanning code could be made common to other adapters; * auto-negotiation; + * full-duplex; * optionally use memory-mapped registers. */ #include "u.h" @@ -27,7 +28,7 @@ enum { enum { /* CSR */ Status = 0x00, /* byte or word (word includes Ack) */ Ack = 0x01, /* byte */ - Command = 0x02, /* byte or word (word includes Interrupt) */ + CommandR = 0x02, /* byte or word (word includes Interrupt) */ Interrupt = 0x03, /* byte */ General = 0x04, /* dword */ Port = 0x08, /* dword */ @@ -298,10 +299,10 @@ custart(Ctlr* ctlr) ctlr->cbqbusy = 1; ilock(&ctlr->rlock); - while(csr8r(ctlr, Command)) + while(csr8r(ctlr, CommandR)) ; csr32w(ctlr, General, PADDR(&ctlr->cbqhead->command)); - csr8w(ctlr, Command, CUstart); + csr8w(ctlr, CommandR, CUstart); iunlock(&ctlr->rlock); } @@ -338,10 +339,10 @@ attach(Ether* ether) ilock(&ctlr->rlock); status = csr16r(ctlr, Status); if((status & RUstatus) == RUidle){ - while(csr8r(ctlr, Command)) + while(csr8r(ctlr, CommandR)) ; csr32w(ctlr, General, PADDR(ctlr->rfdhead->rp)); - csr8w(ctlr, Command, RUstart); + csr8w(ctlr, CommandR, RUstart); } iunlock(&ctlr->rlock); } @@ -378,9 +379,9 @@ ifstat(Ether* ether, void* a, long n, ulong offset) ctlr->dump[16] = 0; ilock(&ctlr->rlock); - while(csr8r(ctlr, Command)) + while(csr8r(ctlr, CommandR)) ; - csr8w(ctlr, Command, DumpSC); + csr8w(ctlr, CommandR, DumpSC); iunlock(&ctlr->rlock); /* @@ -535,9 +536,9 @@ interrupt(Ureg*, void* arg) if(status & StatRNR){ lock(&ctlr->rlock); - while(csr8r(ctlr, Command)) + while(csr8r(ctlr, CommandR)) ; - csr8w(ctlr, Command, RUresume); + csr8w(ctlr, CommandR, RUresume); unlock(&ctlr->rlock); status &= ~StatRNR; @@ -726,9 +727,8 @@ reset(Ether* ether) } /* - * Any adapter matches if no ether->port is supplied, otherwise the - * ports must match. First see if an adapter that fits the bill has - * already been found. If not, scan for another. + * Any adapter matches if no port is supplied, + * otherwise the ports must match. */ port = 0; bpp = &adapter; @@ -763,19 +763,19 @@ reset(Ether* ether) csr32w(ctlr, Port, 0); delay(1); - while(csr8r(ctlr, Command)) + while(csr8r(ctlr, CommandR)) ; csr32w(ctlr, General, 0); - csr8w(ctlr, Command, LoadRUB); + csr8w(ctlr, CommandR, LoadRUB); - while(csr8r(ctlr, Command)) + while(csr8r(ctlr, CommandR)) ; - csr8w(ctlr, Command, LoadCUB); + csr8w(ctlr, CommandR, LoadCUB); - while(csr8r(ctlr, Command)) + while(csr8r(ctlr, CommandR)) ; csr32w(ctlr, General, PADDR(ctlr->dump)); - csr8w(ctlr, Command, LoadDCA); + csr8w(ctlr, CommandR, LoadDCA); iunlock(&ctlr->rlock); /* @@ -827,7 +827,7 @@ reset(Ether* ether) * the station address with the Individual Address Setup command. */ memset(ea, 0, Eaddrlen); - if(!memcmp(ea, ether->ea, Eaddrlen)){ + if(memcmp(ea, ether->ea, Eaddrlen) == 0){ for(i = 0; i < Eaddrlen/2; i++){ x = hy93c46r(ctlr, i); ether->ea[2*i] = x; diff --git a/pc/etherelnk3.c b/pc/etherelnk3.c index 12c9f1cfa23a9f6ae2cc1c44f2ea0f0bd244d163..81edbd63413f047d10fe236210a5e42d4f5b5616 100644 --- a/pc/etherelnk3.c +++ b/pc/etherelnk3.c @@ -6,7 +6,7 @@ * autoSelect; * PCI latency timer and master enable; * errata list; - * 3C90x full busmastering; + * limit 3C90x transmit queue; * rewrite all initialisation. * * Product ID: diff --git a/port/qio.c b/port/qio.c index a59960211a9c508799d9890be0f3afd310438d60..032cbbe9d76151fd768cd72bccdd6a69adaa1f6f 100644 --- a/port/qio.c +++ b/port/qio.c @@ -1043,6 +1043,7 @@ qclose(Queue *q) /* mark it */ ilock(q); q->state |= Qclosed; + q->state &= ~(Qflow|Qstarve); strcpy(q->err, Ehungup); bfirst = q->bfirst; q->bfirst = 0;