1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

create limit for the number of supported virtio queues

This commit is contained in:
Stefan Lankes 2017-06-08 00:41:10 +02:00
parent fea0f31018
commit ae1b7e01c5

View file

@ -51,6 +51,7 @@
#define VENDOR_ID 0x1AF4
#define VIOIF_BUFFER_SIZE 0x2048
#define MIN(a, b) (a) < (b) ? (a) : (b)
#define QUEUE_LIMIT 256
static struct netif* mynetif = NULL;
@ -278,6 +279,11 @@ static int vioif_queue_setup(vioif_t* dev, uint32_t index)
memset((void*)vring_base, 0x00, total_size);
vring_init(&vq->vring, num, vring_base, PAGE_SIZE);
if (num > QUEUE_LIMIT) {
vq->vring.num = num = QUEUE_LIMIT;
LOG_INFO("vioif: set queue limit to %u (index %u)\n", vq->vring.num, index);
}
vq->virt_buffer = (uint64_t) page_alloc(num*VIOIF_BUFFER_SIZE, VMA_READ|VMA_WRITE|VMA_CACHEABLE);
if (BUILTIN_EXPECT(!vq->virt_buffer, 0)) {
LOG_INFO("Not enough memory to create buffer %u\n", index);