#include <types/nums.h>
#include <global.h>
Go to the source code of this file.
|
void | NetStq (u32 iob) |
| Processes received packets from the VirtIO queue.
|
void | VirtnetInit (u32 iob) |
| Initializes the VirtIO network queue and allocates RX buffers.
|
void | VirtnetNegotiate (u32 iob) |
| Performs device negotiation with the VirtIO network device.
|
void | VirtnetSetup () |
| Performs full setup of the VirtIO network device.
|
◆ MAX_RX_DESCS
◆ VIRTIO_MAX_SAFE_QSIZE
#define VIRTIO_MAX_SAFE_QSIZE 16 |
◆ VIRTIO_PCI_GUEST_FEATURES
#define VIRTIO_PCI_GUEST_FEATURES 0x04 |
◆ VIRTIO_PCI_HOST_FEATURES
#define VIRTIO_PCI_HOST_FEATURES 0x00 |
◆ VIRTIO_PCI_QUEUE_NOTIFY
#define VIRTIO_PCI_QUEUE_NOTIFY 0x10 |
◆ VIRTIO_PCI_QUEUE_NUM
#define VIRTIO_PCI_QUEUE_NUM 0x0C |
◆ VIRTIO_PCI_QUEUE_PFN
#define VIRTIO_PCI_QUEUE_PFN 0x08 |
◆ VIRTIO_PCI_QUEUE_SEL
#define VIRTIO_PCI_QUEUE_SEL 0x0E |
◆ VIRTIO_PCI_STATUS
#define VIRTIO_PCI_STATUS 0x12 |
◆ VIRTIO_STATUS_ACKNOWLEDGE
#define VIRTIO_STATUS_ACKNOWLEDGE 1 |
◆ VIRTIO_STATUS_DRIVER
#define VIRTIO_STATUS_DRIVER 2 |
◆ VIRTIO_STATUS_DRIVER_OK
#define VIRTIO_STATUS_DRIVER_OK 4 |
◆ VIRTQ_DESC_F_NEXT
#define VIRTQ_DESC_F_NEXT 1 |
◆ VIRTQ_DESC_F_WRITE
#define VIRTQ_DESC_F_WRITE 2 |
◆ virtq_avail
◆ virtq_desc
◆ virtq_used
◆ NetStq()
Processes received packets from the VirtIO queue.
Iterates over the used ring to find received packets, prints their contents in hex, and recycles the RX buffers by re-adding the descriptors to the avail ring.
- Parameters
-
iob | The I/O base address for the VirtIO device. |
Definition at line 138 of file virtio.c.
◆ VirtnetInit()
void VirtnetInit |
( |
u32 | iob | ) |
|
Initializes the VirtIO network queue and allocates RX buffers.
- Selects RX queue 0 via PCI register.
- Allocates a 4 KiB block for the VirtIO queue and zeroes it.
- Determines the queue size from the device, clamping if needed.
- Initializes descriptor structures:
- desc: descriptors for received packets
- avail: list of available descriptors
- used: list of used descriptors from the device
- Allocates individual 2 KiB RX buffers for each descriptor.
- Notifies the device that the queue is ready and available.
- Parameters
-
iob | The I/O base address for the VirtIO device. |
Definition at line 78 of file virtio.c.
◆ VirtnetNegotiate()
void VirtnetNegotiate |
( |
u32 | iob | ) |
|
Performs device negotiation with the VirtIO network device.
Resets the VirtIO network device and negotiates feature support by writing appropriate status flags to the I/O port.
- Parameters
-
iob | The I/O base address for the VirtIO device. |
Definition at line 41 of file virtio.c.
◆ VirtnetSetup()
Performs full setup of the VirtIO network device.
Finds the VirtIO network device on the PCI bus, reads its IRQ, sets the interrupt handler, unmasks the IRQ, and performs negotiation and initialization.
Definition at line 176 of file virtio.c.