TianoCore EDK2 master
Loading...
Searching...
No Matches
SnpInitialize.c File Reference

Go to the source code of this file.

Functions

STATIC EFI_STATUS EFIAPI VirtioNetInitRing (IN OUT VNET_DEV *Dev, IN UINT16 Selector, OUT VRING *Ring, OUT VOID **Mapping)
 
STATIC EFI_STATUS EFIAPI VirtioNetInitTx (IN OUT VNET_DEV *Dev)
 
STATIC EFI_STATUS EFIAPI VirtioNetInitRx (IN OUT VNET_DEV *Dev)
 
EFI_STATUS EFIAPI VirtioNetInitialize (IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN UINTN ExtraRxBufferSize OPTIONAL, IN UINTN ExtraTxBufferSize OPTIONAL)
 

Detailed Description

Implementation of the SNP.Initialize() function and its private helpers if any.

Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Inc, All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SnpInitialize.c.

Function Documentation

◆ VirtioNetInitialize()

EFI_STATUS EFIAPI VirtioNetInitialize ( IN EFI_SIMPLE_NETWORK_PROTOCOL This,
IN UINTN ExtraRxBufferSize  OPTIONAL,
IN UINTN ExtraTxBufferSize  OPTIONAL 
)

Resets a network adapter and allocates the transmit and receive buffers required by the network interface; optionally, also requests allocation of additional transmit and receive buffers.

Parameters
ThisThe protocol instance pointer.
ExtraRxBufferSizeThe size, in bytes, of the extra receive buffer space that the driver should allocate for the network interface. Some network interfaces will not be able to use the extra buffer, and the caller will not know if it is actually being used.
ExtraTxBufferSizeThe size, in bytes, of the extra transmit buffer space that the driver should allocate for the network interface. Some network interfaces will not be able to use the extra buffer, and the caller will not know if it is actually being used.
Return values
EFI_SUCCESSThe network interface was initialized.
EFI_NOT_STARTEDThe network interface has not been started.
EFI_OUT_OF_RESOURCESThere was not enough memory for the transmit and receive buffers.
EFI_INVALID_PARAMETEROne or more of the parameters has an unsupported value.
EFI_DEVICE_ERRORThe command could not be sent to the network interface.
EFI_UNSUPPORTEDThis function is not supported by the network interface.

Definition at line 489 of file SnpInitialize.c.

◆ VirtioNetInitRing()

STATIC EFI_STATUS EFIAPI VirtioNetInitRing ( IN OUT VNET_DEV Dev,
IN UINT16  Selector,
OUT VRING Ring,
OUT VOID **  Mapping 
)

Initialize a virtio ring for a specific transfer direction of the virtio-net device.

This function may only be called by VirtioNetInitialize().

Parameters
[in,out]DevThe VNET_DEV driver instance about to enter the EfiSimpleNetworkInitialized state.
[in]SelectorIdentifies the transfer direction (virtio queue) of the network device.
[out]RingThe virtio-ring inside the VNET_DEV structure, corresponding to Selector.
[out]MappingA resulting token to pass to VirtioNetUninitRing()
Return values
EFI_UNSUPPORTEDThe queue size reported by the virtio-net device is too small.
Returns
Status codes from VIRTIO_CFG_WRITE(), VIRTIO_CFG_READ(), VirtioRingInit() and VirtioRingMap().
Return values
EFI_SUCCESSRing initialized.

Definition at line 45 of file SnpInitialize.c.

◆ VirtioNetInitRx()

STATIC EFI_STATUS EFIAPI VirtioNetInitRx ( IN OUT VNET_DEV Dev)

Set up static scaffolding for the VirtioNetReceive() SNP method and enable live device operation.

This function may only be called as VirtioNetInitialize()'s final step.

The structures laid out and resources configured include:

  • destination area for the host to write virtio-net request headers and packet data into,
  • select polling over RX interrupt,
  • fully populate the RX queue with a static pattern of virtio descriptor chains.
Parameters
[in,out]DevThe VNET_DEV driver instance about to enter the EfiSimpleNetworkInitialized state.
Returns
Status codes from VIRTIO_CFG_WRITE() or VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages or VirtioMapAllBytesInSharedBuffer().
Return values
EFI_SUCCESSRX setup successful. The device is live and may already be writing to the receive area.

Definition at line 311 of file SnpInitialize.c.

◆ VirtioNetInitTx()

STATIC EFI_STATUS EFIAPI VirtioNetInitTx ( IN OUT VNET_DEV Dev)

Set up static scaffolding for the VirtioNetTransmit() and VirtioNetGetStatus() SNP methods.

This function may only be called by VirtioNetInitialize().

The structures laid out and resources configured include:

  • fully populate the TX queue with a static pattern of virtio descriptor chains,
  • tracking of heads of free descriptor chains from the above,
  • one common virtio-net request header (never modified by the host) for all pending TX packets,
  • select polling over TX interrupt.
Parameters
[in,out]DevThe VNET_DEV driver instance about to enter the EfiSimpleNetworkInitialized state.
Return values
EFI_OUT_OF_RESOURCESFailed to allocate the stack to track the heads of free descriptor chains or failed to init TxBufCollection.
Returns
Status codes from VIRTIO_DEVICE_PROTOCOL. AllocateSharedPages() or VirtioMapAllBytesInSharedBuffer()
Return values
EFI_SUCCESSTX setup successful.

Definition at line 154 of file SnpInitialize.c.