The Pedigree Project 0.1
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
VirtioNet Class Reference
+ Inheritance diagram for VirtioNet:
+ Collaboration diagram for VirtioNet:

Classes

struct  Slot
 

Public Member Functions

 VirtioNet (Device *pciDevice)
 
bool initialise ()
 
void getName (String &name) override
 
bool send (size_t length, uintptr_t buffer) override
 
bool setStationInfo (const StationInfo &info) override
 
const StationInfo & getStationInfo () override
 
bool isConnected () override
 
IrqDisposition irq (irq_id_t number) override
 
- Public Member Functions inherited from Network
 Network (Network *pDev)
 
virtual Type getType ()
 
virtual void dump (String &str)
 
virtual void gotPacket ()
 
virtual void droppedPacket ()
 Called when a packet is dropped by the system.
 
virtual void badPacket ()
 
- Public Member Functions inherited from Device
 Device (Device *p)
 
Device * getParent () const
 
void setParent (Device *p)
 
virtual const String & getSpecificType ()
 
virtual void setSpecificType (String str)
 
void setPciPosition (uint32_t bus, uint32_t device, uint32_t func)
 
void setPciIdentifiers (uint8_t classCode, uint8_t subclassCode, uint16_t vendorId, uint16_t deviceId, uint8_t progIf)
 
void setPciConfigHeader (const PciBus::ConfigSpace &space)
 
PciBus::ConfigSpace getPciConfigHeader () const
 
uint8_t getPciClassCode ()
 
uint8_t getPciSubclassCode ()
 
uint16_t getPciVendorId ()
 
uint16_t getPciDeviceId ()
 
uint8_t getPciProgInterface ()
 
uint32_t getPciBusPosition ()
 
uint32_t getPciDevicePosition ()
 
uint32_t getPciFunctionNumber ()
 
Device * getPhysicalFunction () const
 
size_t getVirtualFunctionIndex () const
 
void setVirtualFunction (Device *physicalFunction, size_t index)
 
virtual Vector< Address * > & addresses ()
 
virtual uintptr_t getInterruptNumber ()
 
virtual void setInterruptNumber (uintptr_t n)
 
void addChild (Device *pDevice)
 
Device * getChild (size_t n)
 
size_t getNumChildren ()
 
void removeChild (size_t n)
 
void removeChild (Device *d)
 
void replaceChild (Device *src, Device *dest)
 
- Public Member Functions inherited from IrqHandler
virtual bool acceptsSpuriousInterrupts () const
 

Private Member Functions

void reclaimTransmit ()
 
bool postReceive (Slot &slot)
 
 VirtioNet (const VirtioNet &)=delete
 
VirtioNet & operator= (const VirtioNet &)=delete
 

Private Attributes

Device * m_PciDevice
 
Virtio::PciTransport m_Transport
 
Virtio::Queue m_RxQueue
 
Virtio::Queue m_TxQueue
 
MemoryRegion m_RxRegion
 
MemoryRegion m_TxRegion
 
Mutex m_Lock
 
Slot m_RxSlots [MaxRxSlots]
 
Slot m_TxSlots [MaxTxSlots]
 
size_t m_RxCount
 
size_t m_TxCount
 
size_t m_NextTx
 
irq_id_t m_IrqId
 
bool m_HasStatus
 
bool m_NetworkRegistered
 
bool m_Initialised
 
bool m_Stopping
 

Static Private Attributes

static constexpr size_t BufferSize = 2048
 
static constexpr size_t MaxRxSlots = 64
 
static constexpr size_t MaxTxSlots = 32
 

Additional Inherited Members

- Public Types inherited from Device
enum  Type {
  Generic , Root , Disk , Bus ,
  Display , Network , Sound , Console ,
  Mouse , Controller , UsbController , UsbGeneric ,
  UsbContainer
}
 
typedef Device *(* Callback) (Device *)
 
- Static Public Member Functions inherited from Network
static EXPORTED_PUBLIC uint32_t convertToIpv4 (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
 
static EXPORTED_PUBLIC IpAddress convertToIpv6 (uint8_t a, uint8_t b=0, uint8_t c=0, uint8_t d=0, uint8_t e=0, uint8_t f=0, uint8_t g=0, uint8_t h=0, uint8_t i=0, uint8_t j=0, uint8_t k=0, uint8_t l=0, uint8_t m=0, uint8_t n=0, uint8_t o=0, uint8_t p=0)
 
static EXPORTED_PUBLIC uint16_t calculateChecksum (uintptr_t buffer, size_t nBytes)
 
- Static Public Member Functions inherited from Device
static bool treeLockHeldByCurrentThread ()
 
static void foreach (Callback callback, Device *root=0)
 
template<class F , class... Args>
static void foreach (pedigree_std::Callable< F > &callback, Device *root, Args... args)
 
static void addToRoot (Device *device)
 
static void searchByVendorId (uint16_t vendorId, void(*callback)(Device *), Device *root=0)
 
static void searchByVendorIdAndDeviceId (uint16_t vendorId, uint16_t deviceId, void(*callback)(Device *), Device *root=0)
 
static void searchByClass (uint16_t classCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassAndSubclass (uint16_t classCode, uint16_t subclassCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassSubclassAndProgInterface (uint16_t classCode, uint16_t subclassCode, uint8_t progInterface, void(*callback)(Device *), Device *root=0)
 
- Protected Member Functions inherited from Device
 NOT_COPYABLE_OR_ASSIGNABLE (Device)
 
- Protected Member Functions inherited from IrqHandler
virtual ~IrqHandler ()
 
- Protected Member Functions inherited from IrqHandlerBase
virtual ~IrqHandlerBase ()
 
- Static Protected Member Functions inherited from Device
static Device & root ()
 
- Protected Attributes inherited from Network
StationInfo m_StationInfo
 
- Protected Attributes inherited from Device
Vector< Address * > m_Addresses
 
Vector< Device * > m_Children
 
Device * m_pParent
 
Device * m_PhysicalFunction
 
size_t m_VirtualFunctionIndex
 
uintptr_t m_InterruptNumber
 
String m_SpecificType
 
PciBus::ConfigSpace m_ConfigHeader
 
uint8_t m_ClassCode
 
uint8_t m_SubclassCode
 
uint16_t m_VendorId
 
uint16_t m_DeviceId
 
uint8_t m_ProgInterface
 
uint32_t m_PciBusPos
 
uint32_t m_PciDevicePos
 
uint32_t m_PciFunctionNum
 
- Static Protected Attributes inherited from Device
static Device m_Root
 
static Mutex m_TreeLock
 

Detailed Description

Definition at line 13 of file VirtioNet.h.

Constructor & Destructor Documentation

◆ VirtioNet()

VirtioNet::VirtioNet ( Device *  pciDevice)
explicit

Definition at line 38 of file VirtioNet.cc.

◆ ~VirtioNet()

VirtioNet::~VirtioNet ( )
override

Definition at line 60 of file VirtioNet.cc.

Member Function Documentation

◆ getName()

void VirtioNet::getName ( String &  str)
overridevirtual

Stores the device's name in str.

Reimplemented from Network.

Definition at line 152 of file VirtioNet.cc.

◆ getStationInfo()

const StationInfo & VirtioNet::getStationInfo ( )
overridevirtual

Gets station information (such as IP addresses)

Reimplemented from Network.

Definition at line 225 of file VirtioNet.cc.

◆ initialise()

bool VirtioNet::initialise ( )

Definition at line 80 of file VirtioNet.cc.

◆ irq()

IrqDisposition VirtioNet::irq ( irq_id_t  number)
overridevirtual

Handles a pending IRQ in thread context.

Implements IrqHandler.

Definition at line 241 of file VirtioNet.cc.

References Network::badPacket(), Network::gotPacket(), NetworkStack::instance(), Quiesced, and NetworkStack::receive().

◆ isConnected()

bool VirtioNet::isConnected ( )
overridevirtual

Is this device actually connected to a network?

Reimplemented from Network.

Definition at line 229 of file VirtioNet.cc.

◆ postReceive()

bool VirtioNet::postReceive ( Slot &  slot)
private

Definition at line 156 of file VirtioNet.cc.

◆ reclaimTransmit()

void VirtioNet::reclaimTransmit ( )
private

Definition at line 161 of file VirtioNet.cc.

◆ send()

bool VirtioNet::send ( size_t  nBytes,
uintptr_t  buffer 
)
overridevirtual

Sends a given packet through the device.

Parameters
nBytesThe number of bytes to send.
bufferA buffer with the packet to send

Implements Network.

Definition at line 169 of file VirtioNet.cc.

◆ setStationInfo()

bool VirtioNet::setStationInfo ( const StationInfo &  info)
overridevirtual

Sets station information (such as IP addresses)

Parameters
infoThe information to set as the station info

Reimplemented from Network.

Definition at line 208 of file VirtioNet.cc.

References StationInfo::gateway, and StationInfo::nDnsServers.

Member Data Documentation

◆ BufferSize

constexpr size_t VirtioNet::BufferSize = 2048
staticconstexprprivate

Definition at line 27 of file VirtioNet.h.

◆ m_HasStatus

bool VirtioNet::m_HasStatus
private

Definition at line 53 of file VirtioNet.h.

◆ m_Initialised

bool VirtioNet::m_Initialised
private

Definition at line 55 of file VirtioNet.h.

◆ m_IrqId

irq_id_t VirtioNet::m_IrqId
private

Definition at line 52 of file VirtioNet.h.

◆ m_Lock

Mutex VirtioNet::m_Lock
private

Definition at line 46 of file VirtioNet.h.

◆ m_NetworkRegistered

bool VirtioNet::m_NetworkRegistered
private

Definition at line 54 of file VirtioNet.h.

◆ m_NextTx

size_t VirtioNet::m_NextTx
private

Definition at line 51 of file VirtioNet.h.

◆ m_PciDevice

Device* VirtioNet::m_PciDevice
private

Definition at line 40 of file VirtioNet.h.

◆ m_RxCount

size_t VirtioNet::m_RxCount
private

Definition at line 49 of file VirtioNet.h.

◆ m_RxQueue

Virtio::Queue VirtioNet::m_RxQueue
private

Definition at line 42 of file VirtioNet.h.

◆ m_RxRegion

MemoryRegion VirtioNet::m_RxRegion
private

Definition at line 44 of file VirtioNet.h.

◆ m_RxSlots

Slot VirtioNet::m_RxSlots[MaxRxSlots]
private

Definition at line 47 of file VirtioNet.h.

◆ m_Stopping

bool VirtioNet::m_Stopping
private

Definition at line 56 of file VirtioNet.h.

◆ m_Transport

Virtio::PciTransport VirtioNet::m_Transport
private

Definition at line 41 of file VirtioNet.h.

◆ m_TxCount

size_t VirtioNet::m_TxCount
private

Definition at line 50 of file VirtioNet.h.

◆ m_TxQueue

Virtio::Queue VirtioNet::m_TxQueue
private

Definition at line 43 of file VirtioNet.h.

◆ m_TxRegion

MemoryRegion VirtioNet::m_TxRegion
private

Definition at line 45 of file VirtioNet.h.

◆ m_TxSlots

Slot VirtioNet::m_TxSlots[MaxTxSlots]
private

Definition at line 48 of file VirtioNet.h.

◆ MaxRxSlots

constexpr size_t VirtioNet::MaxRxSlots = 64
staticconstexprprivate

Definition at line 28 of file VirtioNet.h.

◆ MaxTxSlots

constexpr size_t VirtioNet::MaxTxSlots = 32
staticconstexprprivate

Definition at line 29 of file VirtioNet.h.


The documentation for this class was generated from the following files: