XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
virtionet.c File Reference
#include <pcie.h>
#include <Hal/AA64/aa64lowlevel.h>
#include <Hal/AA64/gic.h>
#include <Fs/Dev/devinput.h>
#include <Drivers/virtio.h>
#include <Drivers/uart.h>
#include <Mm/pmmngr.h>
#include <aucon.h>
#include <Mm/vmmngr.h>
#include <Hal/AA64/sched.h>
Include dependency graph for virtionet.c:

Classes

struct  VirtioNetCfg
 

Macros

#define VIRTIO_F_VERSION_1   (1ull << 32)
 
#define RX_BUFFER_COUNT   8
 
#define RX_BUFFER_SIZE   2048
 
#define VIRTIO_PCI_CAP_ID   0x09
 
#define VIRTIO_PCI_CAP_COMMON_CFG   1
 
#define VIRTIO_PCI_CAP_DEVICE_CFG   4
 

Functions

void AuVirtioNetHandler (int spiNum)
 AuVirtioNetHandler – interrupt handler for virtio-net-dev.
 
void AuVirtioNetNotifyQueue (struct VirtioCommonCfg *cfg, uint16_t queueIdx)
 AuVirtioNetNotifyQueue – notify queue.
 
void AuVirtioNetRxinitialize (struct VirtioCommonCfg *common)
 AuVirtioNetRxInitialize – initialize rx queue.
 
void AuVirtioNetTxinitialize (struct VirtioCommonCfg *common)
 AuVirtioNetTxInitialize – initialize tx queue.
 
void AuVirtioNetInitialize (uint64_t device)
 AuVirtioNetInitialize – initialize the virtio network device.
 

Variables

struct VirtioQueuerxqueue
 
struct VirtioQueuetxqueue
 
volatile uint8_tnotifyBase
 
uint32_t notifyOffMultiplier
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

BSD 2-Clause License

Copyright (c) 2022-2025, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ RX_BUFFER_COUNT

#define RX_BUFFER_COUNT   8

◆ RX_BUFFER_SIZE

#define RX_BUFFER_SIZE   2048

◆ VIRTIO_F_VERSION_1

#define VIRTIO_F_VERSION_1   (1ull << 32)

◆ VIRTIO_PCI_CAP_COMMON_CFG

#define VIRTIO_PCI_CAP_COMMON_CFG   1

◆ VIRTIO_PCI_CAP_DEVICE_CFG

#define VIRTIO_PCI_CAP_DEVICE_CFG   4

◆ VIRTIO_PCI_CAP_ID

#define VIRTIO_PCI_CAP_ID   0x09

Function Documentation

◆ AuVirtioNetHandler()

void AuVirtioNetHandler ( int  spiNum)

AuVirtioNetHandler – interrupt handler for virtio-net-dev.

Parameters
spiNum– shared peripheral interrupt number passed by system

◆ AuVirtioNetInitialize()

void AuVirtioNetInitialize ( uint64_t  device)

AuVirtioNetInitialize – initialize the virtio network device.

Parameters
device– device address passed by PCIe

feature negotiation

enable RX+TX queue

◆ AuVirtioNetNotifyQueue()

void AuVirtioNetNotifyQueue ( struct VirtioCommonCfg cfg,
uint16_t  queueIdx 
)

AuVirtioNetNotifyQueue – notify queue.

Parameters
cfg– Pointer to common queue
queueIdx– queue number, zero – rx queue, one – tx queue

◆ AuVirtioNetRxinitialize()

void AuVirtioNetRxinitialize ( struct VirtioCommonCfg common)

AuVirtioNetRxInitialize – initialize rx queue.

Parameters
common– pointer to virtio common config

◆ AuVirtioNetTxinitialize()

void AuVirtioNetTxinitialize ( struct VirtioCommonCfg common)

AuVirtioNetTxInitialize – initialize tx queue.

Parameters
common– pointer to virtio common config

Variable Documentation

◆ notifyBase

volatile uint8_t* notifyBase

◆ notifyOffMultiplier

uint32_t notifyOffMultiplier

◆ rxqueue

struct VirtioQueue* rxqueue

◆ txqueue

struct VirtioQueue* txqueue