NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
operations for DOCA Types
Collaboration diagram for operations for DOCA Types:

Macros

#define DOCA_SHIFT(_x)   (__doca_builtin_ffsll(_x) - 1)
 
#define DOCA_HTOBE16(_x)   _byteswap_ushort(_x)
 
#define DOCA_HTOBE32(_x)   _byteswap_ulong(_x)
 
#define DOCA_BETOH16(_x)   _byteswap_ushort(_x)
 
#define DOCA_BETOH32(_x)   _byteswap_ulong(_x)
 
#define DOCA_U8_GENMASK(_h, _l)   ((UINT8_MAX - (UINT8_C(1) << (_l)) + 1) & (UINT8_MAX >> (8 - 1 - (_h))))
 
#define DOCA_U8P_GENMASK(_h, _l, _p)
 
#define DOCA_BE16_GENMASK(_h, _l)    (DOCA_HTOBE16((UINT16_MAX - (UINT16_C(1) << (_l)) + 1) & (UINT16_MAX >> (16 - 1 - (_h)))))
 
#define DOCA_BE16P_GENMASK(_h, _l, _p)
 
#define DOCA_BE32_GENMASK(_h, _l)    (DOCA_HTOBE32((UINT32_MAX - (UINT32_C(1) << (_l)) + 1) & (UINT32_MAX >> (32 - 1 - (_h)))))
 
#define DOCA_BE32P_GENMASK(_h, _l, _p)
 
#define DOCA_U8_SET(_m, _v)   ((_v << DOCA_SHIFT(_m)) & _m)
 
#define DOCA_U8P_SET(_m, _v, _p)
 
#define DOCA_BE16_SET(_m, _v)   ((DOCA_HTOBE16(_v << DOCA_SHIFT(DOCA_BETOH16(_m)))) & _m)
 
#define DOCA_BE16P_SET(_m, _v, _p)
 
#define DOCA_BE32_SET(_m, _v)   ((DOCA_HTOBE32(_v << DOCA_SHIFT(DOCA_BETOH32(_m)))) & _m)
 
#define DOCA_BE32P_SET(_m, _v, _p)
 
#define DOCA_U8_GET(_m, _f)   (((_m) & (_f)) >> DOCA_SHIFT((_m)))
 
#define DOCA_BE16_GET(_m, _f)   ((DOCA_BETOH16((_m) & (_f)) >> DOCA_SHIFT(DOCA_BETOH16(_m))))
 
#define DOCA_BE32_GET(_m, _f)   ((DOCA_BETOH32((_m) & (_f)) >> DOCA_SHIFT(DOCA_BETOH32(_m))))
 

Functions

static int __doca_builtin_ffsll (long long x)
 

Detailed Description

DOCA bitfield introduces bitfield operations on DOCA type that are common for many libraries.

Macro Definition Documentation

◆ DOCA_BE16_GENMASK

#define DOCA_BE16_GENMASK (   _h,
  _l 
)     (DOCA_HTOBE16((UINT16_MAX - (UINT16_C(1) << (_l)) + 1) & (UINT16_MAX >> (16 - 1 - (_h)))))

DOCA_BE16_GENMASK() - generate continuous mask from _l bit to _h bit, return in big endian For example, DOCA_BE16_GENMASK(11, 4) -> htons(0x0FF0)

Parameters
_llowest bit
_hhighest bit

Definition at line 161 of file doca_bitfield.h.

◆ DOCA_BE16_GET

#define DOCA_BE16_GET (   _m,
  _f 
)    ((DOCA_BETOH16((_m) & (_f)) >> DOCA_SHIFT(DOCA_BETOH16(_m))))

DOCA_BE16_GET() - get a bitfield segment value

Parameters
_mdoca_be16_t, shifted mask defined field's width and position
_fdoca_be16_t, entire register value

DOCA_BE16_GET() get the field value in host endian specified by _m from the register passed in as _f by masking and shifting it down

Definition at line 304 of file doca_bitfield.h.

◆ DOCA_BE16_SET

#define DOCA_BE16_SET (   _m,
  _v 
)    ((DOCA_HTOBE16(_v << DOCA_SHIFT(DOCA_BETOH16(_m)))) & _m)

DOCA_BE16_SET() - set a bitfield segment in big endian and return

Parameters
_mdoca_be16_t, shifted mask defined field's width and position
_vhost endian, value to set in field

DOCA_BE16_SET() mask and shift up the value and return in doca_be16_t The return value should be logical OR with other fields in register.

Definition at line 237 of file doca_bitfield.h.

◆ DOCA_BE16P_GENMASK

#define DOCA_BE16P_GENMASK (   _h,
  _l,
  _p 
)
Value:
do { \
*(doca_be16_t *)_p = DOCA_BE16_GENMASK(_h, _l); \
} while (0)
#define DOCA_BE16_GENMASK(_h, _l)
uint16_t doca_be16_t
Declare DOCA endianity types.
Definition: doca_types.h:120

DOCA_BE16P_GENMASK() - generate continuous mask from _l bit to _h bit, put in _p pointed memory in big endian

Parameters
_llowest bit
_hhighest bit
_ppointer of doca_be16_t

Definition at line 172 of file doca_bitfield.h.

◆ DOCA_BE16P_SET

#define DOCA_BE16P_SET (   _m,
  _v,
  _p 
)
Value:
do { \
doca_be16_t _tmp = *(doca_be16_t *)_p; \
\
_tmp |= DOCA_BE16_SET(_m, _v); \
*_p = _tmp; \
} while (0);
#define DOCA_BE16_SET(_m, _v)

DOCA_BE16P_SET() - set a bitfield segment in _p pointed doca_be16_t field

Parameters
_mdoca_be16_t, shifted mask defined field's width and position
_vhost endian, value to set in field
_pdoca_be16_t, pointer to field

DOCA_BE16P_SET() mask and shift up the value and logical OR with other fields in doca_be16_t

Definition at line 248 of file doca_bitfield.h.

◆ DOCA_BE32_GENMASK

#define DOCA_BE32_GENMASK (   _h,
  _l 
)     (DOCA_HTOBE32((UINT32_MAX - (UINT32_C(1) << (_l)) + 1) & (UINT32_MAX >> (32 - 1 - (_h)))))

DOCA_BE32_GENMASK() - generate continuous mask from _l bit to _h bit, return in big endian For example, DOCA_BE32_GENMASK(23, 4) -> htonl(0x00FFFFF0)

Parameters
_llowest bit
_hhighest bit

Definition at line 184 of file doca_bitfield.h.

◆ DOCA_BE32_GET

#define DOCA_BE32_GET (   _m,
  _f 
)    ((DOCA_BETOH32((_m) & (_f)) >> DOCA_SHIFT(DOCA_BETOH32(_m))))

DOCA_BE32_GET() - get a bitfield segment value

Parameters
_mdoca_be32_t, shifted mask defined field's width and position
_fdoca_be32_t, entire register value

DOCA_BE32_GET() get the field value in host endian specified by _m from the register passed in as _f by masking and shifting it down

Definition at line 315 of file doca_bitfield.h.

◆ DOCA_BE32_SET

#define DOCA_BE32_SET (   _m,
  _v 
)    ((DOCA_HTOBE32(_v << DOCA_SHIFT(DOCA_BETOH32(_m)))) & _m)

DOCA_BE32_SET() - set a bitfield segment in big endian and return

Parameters
_mdoca_be32_t, shifted mask defined field's width and position
_vhost endian, value to set in field

DOCA_BE32_SET() mask and shift up the value and return in doca_be32_t The return value should be logical OR with other fields in register.

Definition at line 265 of file doca_bitfield.h.

◆ DOCA_BE32P_GENMASK

#define DOCA_BE32P_GENMASK (   _h,
  _l,
  _p 
)
Value:
do { \
*(doca_be32_t *)_p = DOCA_BE32_GENMASK(_h, _l); \
} while (0)
#define DOCA_BE32_GENMASK(_h, _l)
uint32_t doca_be32_t
Definition: doca_types.h:121

DOCA_BE32P_GENMASK() - generate continuous mask from _l bit to _h bit, put in _p pointed memory in big endian

Parameters
_llowest bit
_hhighest bit
_ppointer of doca_be32_t

Definition at line 195 of file doca_bitfield.h.

◆ DOCA_BE32P_SET

#define DOCA_BE32P_SET (   _m,
  _v,
  _p 
)
Value:
do { \
doca_be32_t _tmp = *(doca_be32_t *)_p; \
\
_tmp |= DOCA_BE32_SET(_m, _v); \
*_p = _tmp; \
} while (0);
#define DOCA_BE32_SET(_m, _v)

DOCA_BE32P_SET() - set a bitfield segment in _p pointed doca_be32_t field

Parameters
_mdoca_be32_t, shifted mask defined field's width and position
_vhost endian, value to set in field
_pdoca_be32_t, pointer to field

DOCA_BE32P_SET() mask and shift up the value and logical OR with other fields in doca_be32_t

Definition at line 276 of file doca_bitfield.h.

◆ DOCA_BETOH16

#define DOCA_BETOH16 (   _x)    _byteswap_ushort(_x)

DOCA_BETOH16() - convert 16bit to host endian from big endian

Parameters
_xvalue

Definition at line 121 of file doca_bitfield.h.

◆ DOCA_BETOH32

#define DOCA_BETOH32 (   _x)    _byteswap_ulong(_x)

DOCA_BETOH32() - convert 32bit to host endian from big endian

Parameters
_xvalue

Definition at line 128 of file doca_bitfield.h.

◆ DOCA_HTOBE16

#define DOCA_HTOBE16 (   _x)    _byteswap_ushort(_x)

DOCA_HTOBE16() - convert 16bit type to big endian from host endian

Parameters
_xvalue

Definition at line 107 of file doca_bitfield.h.

◆ DOCA_HTOBE32

#define DOCA_HTOBE32 (   _x)    _byteswap_ulong(_x)

DOCA_HTOBE32() - convert 32bit type to big endian from host endian

Parameters
_xvalue

Definition at line 114 of file doca_bitfield.h.

◆ DOCA_SHIFT

#define DOCA_SHIFT (   _x)    (__doca_builtin_ffsll(_x) - 1)

DOCA_SHIFT() - get number of bits shifted

Parameters
_xvalue

Definition at line 100 of file doca_bitfield.h.

◆ DOCA_U8_GENMASK

#define DOCA_U8_GENMASK (   _h,
  _l 
)    ((UINT8_MAX - (UINT8_C(1) << (_l)) + 1) & (UINT8_MAX >> (8 - 1 - (_h))))

DOCA_U8_GENMASK() - generate continuous mask from _l bit to _h bit, return in host endian For example, DOCA_U8_GENMASK(7, 4) -> 0xF0

Parameters
_llowest bit
_hhighest bit

Definition at line 139 of file doca_bitfield.h.

◆ DOCA_U8_GET

#define DOCA_U8_GET (   _m,
  _f 
)    (((_m) & (_f)) >> DOCA_SHIFT((_m)))

DOCA_U8_GET() - get a bitfield segment value

Parameters
_muint8_t, shifted mask defined field's width and position
_fuint8_t, entire register value

DOCA_U8_GET() get the field value in host endian specified by _m from the register passed in as _f by masking and shifting it down

Definition at line 293 of file doca_bitfield.h.

◆ DOCA_U8_SET

#define DOCA_U8_SET (   _m,
  _v 
)    ((_v << DOCA_SHIFT(_m)) & _m)

DOCA_U8_SET() - set a bitfield segment in host endian and return

Parameters
_muint8_t, shifted mask defined field's width and position
_vhost endian, value to set in field

DOCA_U8_SET() mask and shift up the value and return in uint8_t The return value should be logical OR with other fields in register.

Definition at line 209 of file doca_bitfield.h.

◆ DOCA_U8P_GENMASK

#define DOCA_U8P_GENMASK (   _h,
  _l,
  _p 
)
Value:
do { \
*(uint8_t *)_p = DOCA_U8_GENMASK(_h, _l); \
} while (0)
#define DOCA_U8_GENMASK(_h, _l)

DOCA_U8P_GENMASK() - generate continuous mask from _l bit to _h bit, put in _p pointed memory in host endian

Parameters
_llowest bit
_hhighest bit
_ppointer of uint8_t

Definition at line 149 of file doca_bitfield.h.

◆ DOCA_U8P_SET

#define DOCA_U8P_SET (   _m,
  _v,
  _p 
)
Value:
do { \
uint8_t _tmp = *(uint8_t *)_p; \
\
_tmp |= DOCA_U8_SET(_m, _v); \
*_p = _tmp; \
} while (0);
#define DOCA_U8_SET(_m, _v)

DOCA_U8P_SET() - set a bitfield segment in _p pointed uint8_t field

Parameters
_muint8_t, shifted mask defined field's width and position
_vhost endian, value to set in field
_puint8_t, pointer to field

DOCA_U8P_SET() mask and shift up the value and logical OR with other fields in uint8_t

Definition at line 220 of file doca_bitfield.h.

Function Documentation

◆ __doca_builtin_ffsll()

static int __doca_builtin_ffsll ( long long  x)
static

__doca_builtin_ffsll() - internal implementation on windows, equal to gnu's __builtin_ffsll();

Parameters
xvalue
Returns
: the least significant 1-bit index plus one; if x is zero, return zero.

Definition at line 84 of file doca_bitfield.h.