Data Accelerator Offload
Loading...
Searching...
No Matches
Macros | Functions
dao_util.h File Reference

Go to the source code of this file.

Macros

#define DAO_FREE(ptr)
 
#define DAO_ROUNDUP(x, y)   ((((x) + ((y) - 1)) / (y)) * (y))
 
#define DAO_ROUNDDOWN(x, y)   ((x / y) * y)
 
#define DAO_BIT(nr)   (1UL << (nr))
 
#define DAO_BIT_ULL(nr)   (1ULL << (nr))
 
#define DAO_BITS_PER_LONG_LONG   (__SIZEOF_LONG_LONG__ * 8)
 
#define DAO_GENMASK_ULL(h, l)   (((~0ULL) << (l)) & (~0ULL >> (DAO_BITS_PER_LONG_LONG - 1 - (h))))
 
#define DAO_STATIC_ASSERT(s)   _Static_assert(s, #s)
 
#define DAO_TAILQ_FOREACH_SAFE(var, head, field, tvar)
 

Functions

static bool dao_check_bit_is_set (int n, int pos)
 
int dao_pci_bdf_to_hw_func (const char *pci_bdf)
 
static volatile void * dao_dev_memcpy (volatile void *d, const volatile void *s, size_t l)
 
static void dao_dev_memset (volatile void *d, uint8_t val, size_t l)
 
static void dao_dev_memzero (volatile void *d, size_t l)
 

Detailed Description

DAO Utils

It includes some useful utilities for efficient implementation.

Definition in file dao_util.h.

Macro Definition Documentation

◆ DAO_FREE

#define DAO_FREE (   ptr)
Value:
do { \
free(ptr); \
ptr = NULL; \
} while (0)

Free a pointer and assign to NULL

Definition at line 22 of file dao_util.h.

◆ DAO_ROUNDUP

#define DAO_ROUNDUP (   x,
 
)    ((((x) + ((y) - 1)) / (y)) * (y))

Roundup x to be exact multiple of y

Definition at line 33 of file dao_util.h.

◆ DAO_ROUNDDOWN

#define DAO_ROUNDDOWN (   x,
 
)    ((x / y) * y)

Round-down x to be exact multiple of y

Definition at line 40 of file dao_util.h.

◆ DAO_BIT

#define DAO_BIT (   nr)    (1UL << (nr))

Bit in unsigned long.

Definition at line 47 of file dao_util.h.

◆ DAO_BIT_ULL

#define DAO_BIT_ULL (   nr)    (1ULL << (nr))

Bit in unsigned long long.

Definition at line 54 of file dao_util.h.

◆ DAO_BITS_PER_LONG_LONG

#define DAO_BITS_PER_LONG_LONG   (__SIZEOF_LONG_LONG__ * 8)

Bits in unsigned long long.

Definition at line 61 of file dao_util.h.

◆ DAO_GENMASK_ULL

#define DAO_GENMASK_ULL (   h,
 
)    (((~0ULL) << (l)) & (~0ULL >> (DAO_BITS_PER_LONG_LONG - 1 - (h))))

Unsigned long long bitmask with bits set between high and low positions.

Definition at line 68 of file dao_util.h.

◆ DAO_STATIC_ASSERT

#define DAO_STATIC_ASSERT (   s)    _Static_assert(s, #s)

STATIC ASSERT API

Definition at line 75 of file dao_util.h.

◆ DAO_TAILQ_FOREACH_SAFE

#define DAO_TAILQ_FOREACH_SAFE (   var,
  head,
  field,
  tvar 
)
Value:
for ((var) = TAILQ_FIRST((head)); (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
(var) = (tvar))

This macro permits both remove and free var within the loop safely.

Definition at line 82 of file dao_util.h.

Function Documentation

◆ dao_check_bit_is_set()

static bool dao_check_bit_is_set ( int  n,
int  pos 
)
inlinestatic

Check if bit is set in a no

Check if bit at given position is set for a given no.

Parameters
nInput number
posBit position

Definition at line 95 of file dao_util.h.

◆ dao_pci_bdf_to_hw_func()

int dao_pci_bdf_to_hw_func ( const char *  pci_bdf)

Derive HW function from its PCI BDF

Derive the Hardware func component from its PCI BDF notation

Parameters
pci_bdfPCI BDF source string
Return values
<0 Failure > 0 Success: hw function value

◆ dao_dev_memcpy()

static volatile void * dao_dev_memcpy ( volatile void *  d,
const volatile void *  s,
size_t  l 
)
inlinestatic

API to memcpy on volatile memory

Parameters
dDestination location
sSource location
lLength in bytes.
Returns
Destination pointer on success.

Definition at line 126 of file dao_util.h.

◆ dao_dev_memset()

static void dao_dev_memset ( volatile void *  d,
uint8_t  val,
size_t  l 
)
inlinestatic

API to memset on volatile memory

Parameters
dDestination location.
valValue to memset with.
lLength in bytes.

Definition at line 152 of file dao_util.h.

◆ dao_dev_memzero()

static void dao_dev_memzero ( volatile void *  d,
size_t  l 
)
inlinestatic

API to zero on volatile memory

Parameters
dDestination location.
lLength in bytes.

Definition at line 173 of file dao_util.h.