iPXE
Macros | Typedefs | Functions
ring.h File Reference
#include "../xen-compat.h"

Go to the source code of this file.

Macros

#define xen_mb()   mb()
 
#define xen_rmb()   rmb()
 
#define xen_wmb()   wmb()
 
#define __RD2(_x)   (((_x) & 0x00000002) ? 0x2 : ((_x) & 0x1))
 
#define __RD4(_x)   (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2 : __RD2(_x))
 
#define __RD8(_x)   (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4 : __RD4(_x))
 
#define __RD16(_x)   (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8 : __RD8(_x))
 
#define __RD32(_x)   (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x))
 
#define __CONST_RING_SIZE(_s, _sz)
 
#define __RING_SIZE(_s, _sz)   (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
 
#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t)
 
#define SHARED_RING_INIT(_s)
 
#define FRONT_RING_ATTACH(_r, _s, _i, __size)
 
#define FRONT_RING_INIT(_r, _s, __size)   FRONT_RING_ATTACH(_r, _s, 0, __size)
 
#define XEN_FRONT_RING_INIT(r, s, size)
 
#define BACK_RING_ATTACH(_r, _s, _i, __size)
 
#define BACK_RING_INIT(_r, _s, __size)   BACK_RING_ATTACH(_r, _s, 0, __size)
 
#define RING_SIZE(_r)   ((_r)->nr_ents)
 
#define RING_FREE_REQUESTS(_r)   (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
 
#define RING_FULL(_r)   (RING_FREE_REQUESTS(_r) == 0)
 
#define XEN_RING_NR_UNCONSUMED_RESPONSES(_r)   ((_r)->sring->rsp_prod - (_r)->rsp_cons)
 
#define XEN_RING_NR_UNCONSUMED_REQUESTS(_r)
 
#define RING_HAS_UNCONSUMED_RESPONSES(_r)   XEN_RING_NR_UNCONSUMED_RESPONSES(_r)
 
#define RING_HAS_UNCONSUMED_REQUESTS(_r)   XEN_RING_NR_UNCONSUMED_REQUESTS(_r)
 
#define RING_GET_REQUEST(_r, _idx)   (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
 
#define RING_GET_RESPONSE(_r, _idx)   (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
 
#define RING_COPY_(type, r, idx, dest)
 
#define RING_COPY_REQUEST(r, idx, req)   RING_COPY_(REQUEST, r, idx, req)
 
#define RING_COPY_RESPONSE(r, idx, rsp)   RING_COPY_(RESPONSE, r, idx, rsp)
 
#define RING_REQUEST_CONS_OVERFLOW(_r, _cons)   (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
 
#define RING_REQUEST_PROD_OVERFLOW(_r, _prod)   (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
 
#define RING_RESPONSE_PROD_OVERFLOW(_r, _prod)   (((_prod) - (_r)->rsp_cons) > RING_SIZE(_r))
 
#define RING_PUSH_REQUESTS(_r)
 
#define RING_PUSH_RESPONSES(_r)
 
#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify)
 
#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify)
 
#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do)
 
#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do)
 
#define XEN_PAGE_SHIFT   12
 
#define XEN_FLEX_RING_SIZE(order)   (1UL << ((order) + XEN_PAGE_SHIFT - 1))
 
#define DEFINE_XEN_FLEX_RING(name)
 
#define DEFINE_XEN_FLEX_RING_AND_INTF(name)
 

Typedefs

typedef unsigned int RING_IDX
 

Functions

 FILE_LICENCE (MIT)
 

Macro Definition Documentation

◆ xen_mb

#define xen_mb ( )    mb()

Definition at line 33 of file ring.h.

◆ xen_rmb

#define xen_rmb ( )    rmb()

Definition at line 34 of file ring.h.

◆ xen_wmb

#define xen_wmb ( )    wmb()

Definition at line 35 of file ring.h.

◆ __RD2

#define __RD2 (   _x)    (((_x) & 0x00000002) ? 0x2 : ((_x) & 0x1))

Definition at line 41 of file ring.h.

◆ __RD4

#define __RD4 (   _x)    (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2 : __RD2(_x))

Definition at line 42 of file ring.h.

◆ __RD8

#define __RD8 (   _x)    (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4 : __RD4(_x))

Definition at line 43 of file ring.h.

◆ __RD16

#define __RD16 (   _x)    (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8 : __RD8(_x))

Definition at line 44 of file ring.h.

◆ __RD32

#define __RD32 (   _x)    (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x))

Definition at line 45 of file ring.h.

◆ __CONST_RING_SIZE

#define __CONST_RING_SIZE (   _s,
  _sz 
)
Value:
(__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
sizeof(((struct _s##_sring *)0)->ring[0])))
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
#define __RD32(_x)
Definition: ring.h:45

Definition at line 53 of file ring.h.

◆ __RING_SIZE

#define __RING_SIZE (   _s,
  _sz 
)    (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))

Definition at line 59 of file ring.h.

◆ DEFINE_RING_TYPES

#define DEFINE_RING_TYPES (   __name,
  __req_t,
  __rsp_t 
)

Definition at line 93 of file ring.h.

◆ SHARED_RING_INIT

#define SHARED_RING_INIT (   _s)
Value:
do { \
(_s)->req_prod = (_s)->rsp_prod = 0; \
(_s)->req_event = (_s)->rsp_event = 1; \
(void)memset((_s)->pvt.pvt_pad, 0, sizeof((_s)->pvt.pvt_pad)); \
(void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \
} while(0)
void * memset(void *dest, int character, size_t len) __nonnull

Definition at line 155 of file ring.h.

◆ FRONT_RING_ATTACH

#define FRONT_RING_ATTACH (   _r,
  _s,
  _i,
  __size 
)
Value:
do { \
(_r)->req_prod_pvt = (_i); \
(_r)->rsp_cons = (_i); \
(_r)->nr_ents = __RING_SIZE(_s, __size); \
(_r)->sring = (_s); \
} while (0)
#define __RING_SIZE(_s, _sz)
Definition: ring.h:59

Definition at line 162 of file ring.h.

◆ FRONT_RING_INIT

#define FRONT_RING_INIT (   _r,
  _s,
  __size 
)    FRONT_RING_ATTACH(_r, _s, 0, __size)

Definition at line 169 of file ring.h.

◆ XEN_FRONT_RING_INIT

#define XEN_FRONT_RING_INIT (   r,
  s,
  size 
)
Value:
do { \
SHARED_RING_INIT(s); \
FRONT_RING_INIT(r, s, size); \
} while (0)
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
static const uint8_t r[3][4]
MD4 shift amounts.
Definition: md4.c:53

Definition at line 171 of file ring.h.

◆ BACK_RING_ATTACH

#define BACK_RING_ATTACH (   _r,
  _s,
  _i,
  __size 
)
Value:
do { \
(_r)->rsp_prod_pvt = (_i); \
(_r)->req_cons = (_i); \
(_r)->nr_ents = __RING_SIZE(_s, __size); \
(_r)->sring = (_s); \
} while (0)
#define __RING_SIZE(_s, _sz)
Definition: ring.h:59

Definition at line 176 of file ring.h.

◆ BACK_RING_INIT

#define BACK_RING_INIT (   _r,
  _s,
  __size 
)    BACK_RING_ATTACH(_r, _s, 0, __size)

Definition at line 183 of file ring.h.

◆ RING_SIZE

#define RING_SIZE (   _r)    ((_r)->nr_ents)

Definition at line 186 of file ring.h.

◆ RING_FREE_REQUESTS

#define RING_FREE_REQUESTS (   _r)    (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))

Definition at line 190 of file ring.h.

◆ RING_FULL

#define RING_FULL (   _r)    (RING_FREE_REQUESTS(_r) == 0)

Definition at line 196 of file ring.h.

◆ XEN_RING_NR_UNCONSUMED_RESPONSES

#define XEN_RING_NR_UNCONSUMED_RESPONSES (   _r)    ((_r)->sring->rsp_prod - (_r)->rsp_cons)

Definition at line 200 of file ring.h.

◆ XEN_RING_NR_UNCONSUMED_REQUESTS

#define XEN_RING_NR_UNCONSUMED_REQUESTS (   _r)
Value:
((((_r)->sring->req_prod - (_r)->req_cons) < \
(RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \
((_r)->sring->req_prod - (_r)->req_cons) : \
(RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
#define RING_SIZE(_r)
Definition: ring.h:186

Definition at line 212 of file ring.h.

◆ RING_HAS_UNCONSUMED_RESPONSES

#define RING_HAS_UNCONSUMED_RESPONSES (   _r)    XEN_RING_NR_UNCONSUMED_RESPONSES(_r)

Definition at line 229 of file ring.h.

◆ RING_HAS_UNCONSUMED_REQUESTS

#define RING_HAS_UNCONSUMED_REQUESTS (   _r)    XEN_RING_NR_UNCONSUMED_REQUESTS(_r)

Definition at line 230 of file ring.h.

◆ RING_GET_REQUEST

#define RING_GET_REQUEST (   _r,
  _idx 
)    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))

Definition at line 234 of file ring.h.

◆ RING_GET_RESPONSE

#define RING_GET_RESPONSE (   _r,
  _idx 
)    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))

Definition at line 237 of file ring.h.

◆ RING_COPY_

#define RING_COPY_ (   type,
  r,
  idx,
  dest 
)
Value:
do { \
/* Use volatile to force the copy into dest. */ \
*(dest) = *(volatile __typeof__(dest))RING_GET_##type(r, idx); \
} while (0)
static void * dest
Definition: strings.h:176
uint32_t type
Operating system type.
Definition: ena.h:12
static const uint8_t r[3][4]
MD4 shift amounts.
Definition: md4.c:53

Definition at line 249 of file ring.h.

◆ RING_COPY_REQUEST

#define RING_COPY_REQUEST (   r,
  idx,
  req 
)    RING_COPY_(REQUEST, r, idx, req)

Definition at line 254 of file ring.h.

◆ RING_COPY_RESPONSE

#define RING_COPY_RESPONSE (   r,
  idx,
  rsp 
)    RING_COPY_(RESPONSE, r, idx, rsp)

Definition at line 255 of file ring.h.

◆ RING_REQUEST_CONS_OVERFLOW

#define RING_REQUEST_CONS_OVERFLOW (   _r,
  _cons 
)    (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))

Definition at line 258 of file ring.h.

◆ RING_REQUEST_PROD_OVERFLOW

#define RING_REQUEST_PROD_OVERFLOW (   _r,
  _prod 
)    (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))

Definition at line 262 of file ring.h.

◆ RING_RESPONSE_PROD_OVERFLOW

#define RING_RESPONSE_PROD_OVERFLOW (   _r,
  _prod 
)    (((_prod) - (_r)->rsp_cons) > RING_SIZE(_r))

Definition at line 266 of file ring.h.

◆ RING_PUSH_REQUESTS

#define RING_PUSH_REQUESTS (   _r)
Value:
do { \
xen_wmb(); /* back sees requests /before/ updated producer index */ \
(_r)->sring->req_prod = (_r)->req_prod_pvt; \
} while (0)

Definition at line 269 of file ring.h.

◆ RING_PUSH_RESPONSES

#define RING_PUSH_RESPONSES (   _r)
Value:
do { \
xen_wmb(); /* front sees resps /before/ updated producer index */ \
(_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \
} while (0)

Definition at line 274 of file ring.h.

◆ RING_PUSH_REQUESTS_AND_CHECK_NOTIFY

#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (   _r,
  _notify 
)
Value:
do { \
RING_IDX __old = (_r)->sring->req_prod; \
RING_IDX __new = (_r)->req_prod_pvt; \
xen_wmb(); /* back sees requests /before/ updated producer index */ \
(_r)->sring->req_prod = __new; \
xen_mb(); /* back sees new requests /before/ we check req_event */ \
(_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \
(RING_IDX)(__new - __old)); \
} while (0)
unsigned int RING_IDX
Definition: ring.h:38
#define xen_mb()
Definition: ring.h:33

Definition at line 309 of file ring.h.

◆ RING_PUSH_RESPONSES_AND_CHECK_NOTIFY

#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY (   _r,
  _notify 
)
Value:
do { \
RING_IDX __old = (_r)->sring->rsp_prod; \
RING_IDX __new = (_r)->rsp_prod_pvt; \
xen_wmb(); /* front sees resps /before/ updated producer index */ \
(_r)->sring->rsp_prod = __new; \
xen_mb(); /* front sees new resps /before/ we check rsp_event */ \
(_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \
(RING_IDX)(__new - __old)); \
} while (0)
unsigned int RING_IDX
Definition: ring.h:38
#define xen_mb()
Definition: ring.h:33

Definition at line 319 of file ring.h.

◆ RING_FINAL_CHECK_FOR_REQUESTS

#define RING_FINAL_CHECK_FOR_REQUESTS (   _r,
  _work_to_do 
)
Value:
do { \
(_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \
if (_work_to_do) break; \
(_r)->sring->req_event = (_r)->req_cons + 1; \
xen_mb(); \
(_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \
} while (0)
#define RING_HAS_UNCONSUMED_REQUESTS(_r)
Definition: ring.h:230

Definition at line 329 of file ring.h.

◆ RING_FINAL_CHECK_FOR_RESPONSES

#define RING_FINAL_CHECK_FOR_RESPONSES (   _r,
  _work_to_do 
)
Value:
do { \
(_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \
if (_work_to_do) break; \
(_r)->sring->rsp_event = (_r)->rsp_cons + 1; \
xen_mb(); \
(_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \
} while (0)
#define RING_HAS_UNCONSUMED_RESPONSES(_r)
Definition: ring.h:229

Definition at line 337 of file ring.h.

◆ XEN_PAGE_SHIFT

#define XEN_PAGE_SHIFT   12

Definition at line 392 of file ring.h.

◆ XEN_FLEX_RING_SIZE

#define XEN_FLEX_RING_SIZE (   order)    (1UL << ((order) + XEN_PAGE_SHIFT - 1))

Definition at line 394 of file ring.h.

◆ DEFINE_XEN_FLEX_RING

#define DEFINE_XEN_FLEX_RING (   name)

Definition at line 397 of file ring.h.

◆ DEFINE_XEN_FLEX_RING_AND_INTF

#define DEFINE_XEN_FLEX_RING_AND_INTF (   name)
Value:
struct name##_data_intf { \
RING_IDX in_cons, in_prod; \
\
uint8_t pad1[56]; \
\
RING_IDX out_cons, out_prod; \
\
uint8_t pad2[56]; \
\
RING_IDX ring_order; \
grant_ref_t ref[]; \
}; \
DEFINE_XEN_FLEX_RING(name)
const char * name
Definition: ath9k_hw.c:1984
static const char grant_ref_t ref
Definition: netfront.h:91
uint16_t pad1
Unused.
Definition: bzimage.h:53
uint8_t pad2[3]
Unused.
Definition: bzimage.h:63

Definition at line 473 of file ring.h.

Typedef Documentation

◆ RING_IDX

typedef unsigned int RING_IDX

Definition at line 38 of file ring.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( MIT  )