The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
virtio_net.c File Reference

the virtio network device (see virtio_net.h). More...

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.

Detailed Description

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.

Macro Definition Documentation

◆ DEVICE_ID_LEGACY

#define DEVICE_ID_LEGACY   0x1000

◆ DEVICE_ID_MODERN

#define DEVICE_ID_MODERN   0x1041

◆ F_MAC

#define F_MAC   5

◆ HEADER_SIZE

#define HEADER_SIZE   12

◆ BUFFER_SIZE

#define BUFFER_SIZE   2048

◆ RECEIVE_QUEUE

#define RECEIVE_QUEUE   0

◆ SEND_QUEUE

#define SEND_QUEUE   1

Function Documentation

◆ virtio_net_init()

bool virtio_net_init ( void )

find a virtio network device, set it up and register it as eth0.

Returns
false if there is none or it cannot be set up.