ethervirtio: report correct length; fail gracefully if we can't initialize queues

This commit is contained in:
aiju 2017-06-12 11:25:12 +00:00
parent 45411c31dc
commit 48c5da7a64

View file

@ -324,7 +324,7 @@ rxproc(void *v)
blocks[i] = nil;
b->wp = b->rp + u->len;
b->wp = b->rp + u->len - VheaderSize;
etheriq(edev, b, 1);
q->lastused++;
}
@ -591,13 +591,21 @@ pciprobe(int typ)
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");
free(c);
continue;
}
c->nqueue = i;
if(h == nil)