iPXE
netfront.h File Reference

Xen netfront driver. More...

#include <ipxe/xen.h>
#include <xen/io/netif.h>

Go to the source code of this file.

Data Structures

struct  netfront_ring
 A netfront descriptor ring. More...
struct  netfront_nic
 A netfront NIC. More...

Macros

#define NETFRONT_NUM_TX_DESC   16
 Number of transmit ring entries.
#define NETFRONT_NUM_RX_DESC   32
 Number of receive ring entries.
#define NETFRONT_RX_FILL   18
 Receive ring fill level.
#define tx_sring   tx.sring.tx
 Transmit shared ring field.
#define rx_sring   rx.sring.rx
 Receive shared ring field.

Enumerations

enum  netfront_ref_index {
  NETFRONT_REF_TX_RING = 0 , NETFRONT_REF_TX_BASE , NETFRONT_REF_RX_RING = ( NETFRONT_REF_TX_BASE + NETFRONT_NUM_TX_DESC ) , NETFRONT_REF_RX_BASE ,
  NETFRONT_REF_COUNT = ( NETFRONT_REF_RX_BASE + NETFRONT_NUM_RX_DESC )
}
 Grant reference indices. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static __attribute__ ((always_inline)) void netfront_init_ring(struct netfront_ring *ring
 Initialise descriptor ring.

Variables

static const char * ref_key
static const char grant_ref_t ref = ref
static const char grant_ref_t unsigned int count = count
static const char grant_ref_t unsigned int struct io_buffer ** iobufs = iobufs
static const char grant_ref_t unsigned int struct io_buffer grant_ref_trefs = refs
static const char grant_ref_t unsigned int struct io_buffer grant_ref_t uint8_tids

Detailed Description

Xen netfront driver.

Definition in file netfront.h.

Macro Definition Documentation

◆ NETFRONT_NUM_TX_DESC

#define NETFRONT_NUM_TX_DESC   16

Number of transmit ring entries.

Definition at line 17 of file netfront.h.

Referenced by netfront_probe().

◆ NETFRONT_NUM_RX_DESC

#define NETFRONT_NUM_RX_DESC   32

Number of receive ring entries.

Definition at line 20 of file netfront.h.

Referenced by netfront_probe().

◆ NETFRONT_RX_FILL

#define NETFRONT_RX_FILL   18

Receive ring fill level.

The xen-netback driver from kernels 3.18 to 4.2 inclusive have a bug (CA-163395) which prevents packet reception if fewer than 18 receive descriptors are available. This was fixed in upstream kernel commit d5d4852 ("xen-netback: require fewer guest Rx slots when not using GSO").

We provide 18 receive descriptors to avoid unpleasant silent failures on these kernel versions.

Definition at line 33 of file netfront.h.

Referenced by netfront_refill_rx().

◆ tx_sring

#define tx_sring   tx.sring.tx

Transmit shared ring field.

Definition at line 193 of file netfront.h.

◆ rx_sring

#define rx_sring   rx.sring.rx

Receive shared ring field.

Definition at line 196 of file netfront.h.

Enumeration Type Documentation

◆ netfront_ref_index

Grant reference indices.

Enumerator
NETFRONT_REF_TX_RING 

Transmit ring grant reference index.

NETFRONT_REF_TX_BASE 

Transmit descriptor grant reference base index.

NETFRONT_REF_RX_RING 

Receive ring grant reference index.

NETFRONT_REF_RX_BASE 

Receive descriptor grant reference base index.

NETFRONT_REF_COUNT 

Total number of grant references required.

Definition at line 36 of file netfront.h.

36 {
37 /** Transmit ring grant reference index */
39 /** Transmit descriptor grant reference base index */
41 /** Receive ring grant reference index */
43 /** Receive descriptor grant reference base index */
45 /** Total number of grant references required */
47};
#define NETFRONT_NUM_RX_DESC
Number of receive ring entries.
Definition netfront.h:20
@ NETFRONT_REF_TX_RING
Transmit ring grant reference index.
Definition netfront.h:38
@ NETFRONT_REF_COUNT
Total number of grant references required.
Definition netfront.h:46
@ NETFRONT_REF_TX_BASE
Transmit descriptor grant reference base index.
Definition netfront.h:40
@ NETFRONT_REF_RX_RING
Receive ring grant reference index.
Definition netfront.h:42
@ NETFRONT_REF_RX_BASE
Receive descriptor grant reference base index.
Definition netfront.h:44
#define NETFRONT_NUM_TX_DESC
Number of transmit ring entries.
Definition netfront.h:17

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ __attribute__()

__attribute__ ( (always_inline) )
inlinestatic

Initialise descriptor ring.

Check whether or not descriptor ring is empty.

Check whether or not descriptor ring is full.

Calculate descriptor ring remaining space.

Calculate descriptor ring fill level.

Parameters
ringDescriptor ring
ref_keyShared ring grant reference key
refShared ring grant reference
countMaxium number of used descriptors
iobufsI/O buffers
refsI/O buffer grant references
idsBuffer IDs
ringDescriptor ring
fillFill level
ringDescriptor ring
spaceNumber of unused entries
ringDescriptor ring
is_fullRing is full
ringDescriptor ring
is_emptyRing is empty

Definition at line 111 of file netfront.h.

112 {
113 unsigned int fill_level;
114
115 fill_level = ( ring->id_prod - ring->id_cons );
116 assert ( fill_level <= ring->count );
117 return fill_level;
118}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
static unsigned int count
Number of entries.
Definition dwmac.h:220

References assert, count, netfront_ring::id_cons, and netfront_ring::id_prod.

Variable Documentation

◆ ref_key

const char* ref_key

Definition at line 92 of file netfront.h.

◆ ref

grant_ref_t ref = ref

Definition at line 93 of file netfront.h.

Referenced by netfront_push(), xengrant_alloc(), and xengrant_free().

◆ count

ring count = count

Definition at line 93 of file netfront.h.

◆ iobufs

ring iobufs = iobufs

Definition at line 94 of file netfront.h.

◆ refs

ring refs = refs

Definition at line 94 of file netfront.h.

Referenced by xengrant_alloc(), and xengrant_free().

◆ ids

ring ids
Initial value:
{
ring->ref_key = ref_key
static const char * ref_key
Definition netfront.h:92

Definition at line 95 of file netfront.h.