|
ginnOS
The reference: libc, the libraries and the kernel
|
the virtio network device (see virtio_net.h). More...
#include "virtio_net.h"#include "common/memory.h"#include "drivers/pci/pci_irq.h"#include "drivers/virtio/virtio.h"#include "kernel/klog/klog.h"#include "kernel/memory/mmio.h"#include "kernel/memory/page.h"#include "kernel/memory/phys.h"#include "kernel/memory/pmm.h"#include "kernel/net/netif.h"Macros | |
| #define | DEVICE_ID_LEGACY 0x1000 |
| #define | DEVICE_ID_MODERN 0x1041 |
| #define | F_MAC 5 |
| #define | HEADER_SIZE 12 |
| #define | BUFFER_SIZE 2048 |
| #define | RECEIVE_QUEUE 0 |
| #define | SEND_QUEUE 1 |
Functions | |
| bool | virtio_net_init (void) |
| find a virtio network device, set it up and register it as eth0. | |
the virtio network device (see virtio_net.h).
queue 0 receives and queue 1 sends. each frame has a 12-byte header in front of it (struct virtio_net_hdr with num_buffers). the driver asks for no offloads, so the header is all zero on send and is skipped on receive.
buffers are 2 KiB, two to a page, one for each descriptor of a queue. the receive buffers are all given to the device at the start, and each is given back after its frame is handled. a send buffer is free again when the device gives it back.
| #define DEVICE_ID_LEGACY 0x1000 |
| #define DEVICE_ID_MODERN 0x1041 |
| #define F_MAC 5 |
| #define HEADER_SIZE 12 |
| #define BUFFER_SIZE 2048 |
| #define RECEIVE_QUEUE 0 |
| #define SEND_QUEUE 1 |
| bool virtio_net_init | ( | void | ) |
find a virtio network device, set it up and register it as eth0.