Virtio handle batched and suppressed requests

This commit is contained in:
Ernest Wong 2018-05-31 22:54:40 +12:00 committed by Fabian
parent 03b4776881
commit 309175f23d
2 changed files with 21 additions and 3 deletions

View file

@ -116,8 +116,13 @@ function Virtio9p(filesystem, cpu, bus) {
{
return;
}
var bufchain = this.virtqueue.pop_request();
this.ReceiveRequest(bufchain);
while(this.virtqueue.has_request())
{
var bufchain = this.virtqueue.pop_request();
this.ReceiveRequest(bufchain);
}
this.virtqueue.notify_me_after(0);
this.virtqueue.flush_replies();
},
],
},
@ -212,7 +217,6 @@ Virtio9p.prototype.SendError = function (tag, errormsg, errorcode) {
Virtio9p.prototype.SendReply = function (bufchain) {
bufchain.set_next_blob(this.replybuffer.subarray(0, this.replybuffersize));
this.virtqueue.push_reply(bufchain);
this.virtqueue.flush_replies();
}
Virtio9p.prototype.ReceiveRequest = function (bufchain) {

View file

@ -1237,6 +1237,20 @@ VirtQueue.prototype.flush_replies = function()
}
};
/**
* If using VIRTIO_F_RING_EVENT_IDX, device must tell driver when
* to get notifications or else driver won't notify regularly.
* @param {number} num_skipped_requests Zero = get notified in the next request.
*/
VirtQueue.prototype.notify_me_after = function(num_skipped_requests)
{
dbg_assert(num_skipped_requests >= 0, "Must skip a non-negative number of requests");
// The 16 bit idx field wraps around after 2^16
var avail_event = this.avail.get_idx() + num_skipped_requests & 0xFFFF;
this.used.set_avail_event(avail_event);
};
/**
* @param {number} address
*/