From d2113c13645fb749edb0480fa8b648d3ddbc9818 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 12 Dec 1997 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1997-12-12 --- pc/etherelnk3.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/pc/etherelnk3.c b/pc/etherelnk3.c index d540914e9045b80b0733686b56747e1edeea1ef8..2e37f02736699d8a15156c0acc755603ada401b4 100644 --- a/pc/etherelnk3.c +++ b/pc/etherelnk3.c @@ -366,7 +366,7 @@ enum { /* 3C90x extended register set */ updnLastFrag = 0x80000000, /* (dpd->len) */ Nup = 32, - Ndn = 32, + Ndn = 64, }; /* @@ -694,24 +694,19 @@ static void txstart905(Ether* ether) { Ctlr *ctlr; - int dnlistptr, port; + int port, stalled, timeo; Block *bp; Pd *pd; ctlr = ether->ctlr; port = ether->port; - COMMAND(port, Stall, dnStall); - while(STATUS(port) & commandInProgress) - ; - /* * Free any completed packets. */ - dnlistptr = inl(port+DnListPtr); pd = ctlr->dntail; while(ctlr->dnq){ - if(PADDR(&pd->np) == dnlistptr) + if(PADDR(&pd->np) == inl(port+DnListPtr)) break; if(pd->bp){ freeb(pd->bp); @@ -722,6 +717,7 @@ txstart905(Ether* ether) } ctlr->dntail = pd; + stalled = 0; while(ctlr->dnq < (ctlr->ndn-1)){ bp = qget(ether->oq); if(bp == nil) @@ -734,11 +730,20 @@ txstart905(Ether* ether) pd->len = updnLastFrag|BLEN(bp); pd->bp = bp; - if(ctlr->dnq == 0) - ctlr->dntail = pd; + if(stalled == 0 && ctlr->dnq && inl(port+DnListPtr)){ + COMMAND(port, Stall, dnStall); + for(timeo = 100; (STATUS(port) & commandInProgress) && timeo; timeo--) + ; + if(timeo == 0) + print("#l%d: dnstall %d\n", ether->ctlrno, timeo); + stalled = 1; + } + ctlr->dnhead->np = PADDR(&pd->np); ctlr->dnhead->control &= ~dnIndicate; ctlr->dnhead = pd; + if(ctlr->dnq == 0) + ctlr->dntail = pd; ctlr->dnq++; ctlr->dnqueued++; @@ -751,10 +756,10 @@ txstart905(Ether* ether) * If the adapter is not currently processing anything * and there is something on the queue, start it processing. */ - if(dnlistptr == 0 && ctlr->dnq) + if(inl(port+DnListPtr) == 0 && ctlr->dnq) outl(port+DnListPtr, PADDR(&ctlr->dnhead->np)); - - COMMAND(port, Stall, dnUnStall); + if(stalled) + COMMAND(port, Stall, dnUnStall); } static void @@ -1030,7 +1035,12 @@ interrupt(Ureg*, void* arg) COMMAND(port, SetTxStartThresh, ctlr->txthreshold>>ctlr->ts); if(ctlr->busmaster == 2) outl(port+TxFreeThresh, HOWMANY(ETHERMAXTU, 256)); + if(ctlr->dnenabled) + status |= dnComplete; } + + print("#l%d: txstatus 0x%uX, threshold %d\n", + ether->ctlrno, s, ctlr->txthreshold); COMMAND(port, TxEnable, 0); ether->oerrs++; status &= ~txComplete; @@ -1740,8 +1750,6 @@ etherelnk3reset(Ether* ether) COMMAND(port, SetTxStartThresh, ctlr->txthreshold>>ctlr->ts); COMMAND(port, SetRxEarlyThresh, rxearly>>ctlr->ts); -COMMAND(port, AcknowledgeInterrupt, interruptLatch); - iunlock(&ctlr->wlock); /*