#include "io.h"
#include "../port/error.h"
#include "../port/netif.h"
-#include "etherif.h"
+#include "../port/etherif.h"
/*
* virtio ethernet driver
blocks[i] = nil;
- b->wp = b->rp + u->len;
- etheriq(edev, b, 1);
+ b->wp = b->rp + u->len - VheaderSize;
+ etheriq(edev, b);
q->lastused++;
}
}
{
Ctlr *ctlr = edev->ctlr;
outb(ctlr->port+Qstatus, 0);
+ pciclrbme(ctlr->pcidev);
}
static void
c->typ = typ;
c->pcidev = p;
+ pcienable(p);
c->id = (p->did<<16)|p->vid;
/* ยง3.1.2 Legacy Device Initialization */
for(i=0; i<nelem(c->queue); i++){
outs(c->port+Qselect, i);
n = ins(c->port+Qsize);
- if(n == 0 || (n & (n-1)) != 0)
+ if(n == 0 || (n & (n-1)) != 0){
+ if(i < 2)
+ print("ethervirtio: queue %d has invalid size %d\n", i, n);
break;
+ }
if(initqueue(&c->queue[i], n) < 0)
break;
coherence();
outl(c->port+Qaddr, PADDR(c->queue[i].desc)/VBY2PG);
}
+ if(i < 2){
+ print("ethervirtio: no queues\n");
+ pcidisable(p);
+ free(c);
+ continue;
+ }
c->nqueue = i;
if(h == nil)
Ctlr *ctlr;
int i;
- if(ctlrhead == nil) {
+ if(ctlrhead == nil)
ctlrhead = pciprobe(1);
- }
for(ctlr = ctlrhead; ctlr != nil; ctlr = ctlr->next){
if(ctlr->active)
edev->attach = attach;
edev->shutdown = shutdown;
- edev->interrupt = interrupt;
edev->ifstat = ifstat;
if((ctlr->feat & (Fctrlvq|Fctrlrx)) == (Fctrlvq|Fctrlrx)){
edev->promiscuous = promiscuous;
}
+ pcisetbme(ctlr->pcidev);
+ intrenable(edev->irq, interrupt, edev, edev->tbdf, edev->name);
+
return 0;
}