#include "io.h"
#include "../port/error.h"
#include "../port/netif.h"
+#include "../port/etherif.h"
-#include "etherif.h"
#include "ethermii.h"
#include "../ip/ip.h"
Mii *mii;
int port;
+ int linkchg; /* link status changed? */
+ uvlong starttime; /* last activity time */
+
/* stats */
ulong intrs;
ulong newintrs;
static void
etheractive(Ether *ether)
{
- ether->starttime = TK2MS(MACHP(0)->ticks)/1000;
+ Ctlr *ctlr = ether->ctlr;
+ ctlr->starttime = TK2MS(MACHP(0)->ticks)/1000;
}
static void
ethercheck(Ether *ether)
{
- if (ether->starttime != 0 &&
- TK2MS(MACHP(0)->ticks)/1000 - ether->starttime > Etherstuck) {
+ Ctlr *ctlr = ether->ctlr;
+ if (ctlr->starttime != 0 &&
+ TK2MS(MACHP(0)->ticks)/1000 - ctlr->starttime > Etherstuck) {
etheractive(ether);
if (ether->ctlrno == 0) /* only complain about main ether */
iprint("#l%d: ethernet stuck\n", ether->ctlrno);
* in memory (mv-s104860-u0 ยง8.3.4.1)
*/
b->rp += 2;
- etheriq(ether, b, 1);
+ etheriq(ether, b);
etheractive(ether);
if (i % (Nrx / 2) == 0) {
rxreplenish(ctlr);
*/
if(irqe & IEphystschg) {
ether->link = (reg->ps0 & PS0linkup) != 0;
- ether->linkchg = 1;
+ ctlr->linkchg = 1;
}
if(irqe & IEtxerrq(Qno))
ether->oerrs++;
irq &= ~(Irxerr | Irxerrq(Qno));
}
- if(ether->linkchg && (reg->ps1 & PS1an_done)) {
+ if(ctlr->linkchg && (reg->ps1 & PS1an_done)) {
handled++;
ether->link = (reg->ps0 & PS0linkup) != 0;
- ether->linkchg = 0;
+ ctlr->linkchg = 0;
}
ctlr->newintrs++;
p = seprint(p, e, "transmitted broadcast frames: %lud\n", ctlr->txbcastpkt);
p = seprint(p, e, "transmitted multicast frames: %lud\n", ctlr->txmcastpkt);
p = seprint(p, e, "transmit frames dropped by collision: %lud\n", ctlr->txcollpktdrop);
- p = seprint(p, e, "misaligned buffers: %lud\n", ether->pktsmisaligned);
p = seprint(p, e, "bad mac control frames: %lud\n", ctlr->badmacctlpkts);
p = seprint(p, e, "transmitted flow control messages: %lud\n", ctlr->txflctl);
ether->irq = IRQ0gbe1sum;
break;
default:
- panic("ether1116: bad ether ctlr #%d", ether->ctlrno);
+ return -1;
}
ctlr->reg = (Gbereg*)soc.ether[ether->ctlrno];
ether->attach = attach;
ether->transmit = transmit;
- ether->interrupt = interrupt;
ether->ifstat = ifstat;
ether->shutdown = shutdown;
ether->ctl = ctl;
ether->arg = ether;
ether->promiscuous = promiscuous;
ether->multicast = multicast;
+
+ intrenable(Irqlo, ether->irq, interrupt, ether, ether->name);
+
return 0;
}