DPDK  21.11.8
Macros | Typedefs | Functions | Variables
rte_common.h File Reference
#include <stdint.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <rte_config.h>
#include <rte_os.h>

Go to the source code of this file.

Macros

#define RTE_STD_C11   __extension__
 
#define __rte_aligned(a)   __attribute__((__aligned__(a)))
 
#define __rte_packed   __attribute__((__packed__))
 
#define __rte_may_alias   __attribute__((__may_alias__))
 
#define RTE_DEPRECATED(x)
 
#define __rte_weak   __attribute__((__weak__))
 
#define __rte_used   __attribute__((used))
 
#define __rte_unused   __attribute__((__unused__))
 
#define __rte_restrict   __restrict
 
#define RTE_SET_USED(x)   (void)(x)
 
#define __rte_format_printf(format_index, first_arg)   __attribute__((format(printf, format_index, first_arg)))
 
#define __rte_alloc_size(...)
 
#define RTE_INIT_PRIO(func, prio)   static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void)
 
#define RTE_INIT(func)   RTE_INIT_PRIO(func, LAST)
 
#define RTE_FINI_PRIO(func, prio)   static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 
#define RTE_FINI(func)   RTE_FINI_PRIO(func, LAST)
 
#define __rte_noreturn   __attribute__((noreturn))
 
#define __rte_always_inline   inline __attribute__((always_inline))
 
#define __rte_noinline   __attribute__((noinline))
 
#define __rte_hot   __attribute__((hot))
 
#define __rte_cold   __attribute__((cold))
 
#define __rte_no_asan
 
#define RTE_PTR_ADD(ptr, x)   ((void*)((uintptr_t)(ptr) + (x)))
 
#define RTE_PTR_SUB(ptr, x)   ((void *)((uintptr_t)(ptr) - (x)))
 
#define RTE_PTR_DIFF(ptr1, ptr2)   ((uintptr_t)(ptr1) - (uintptr_t)(ptr2))
 
#define RTE_CAST_FIELD(var, field, type)   (*(type *)((uintptr_t)(var) + offsetof(typeof(*(var)), field)))
 
#define RTE_PTR_ALIGN_FLOOR(ptr, align)   ((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)(ptr), align))
 
#define RTE_ALIGN_FLOOR(val, align)   (typeof(val))((val) & (~((typeof(val))((align) - 1))))
 
#define RTE_PTR_ALIGN_CEIL(ptr, align)   RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align)
 
#define RTE_ALIGN_CEIL(val, align)   RTE_ALIGN_FLOOR(((val) + ((typeof(val)) (align) - 1)), align)
 
#define RTE_PTR_ALIGN(ptr, align)   RTE_PTR_ALIGN_CEIL(ptr, align)
 
#define RTE_ALIGN(val, align)   RTE_ALIGN_CEIL(val, align)
 
#define RTE_ALIGN_MUL_CEIL(v, mul)   ((((v) + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) * (typeof(v))(mul))
 
#define RTE_ALIGN_MUL_FLOOR(v, mul)   (((v) / ((typeof(v))(mul))) * (typeof(v))(mul))
 
#define RTE_ALIGN_MUL_NEAR(v, mul)
 
#define RTE_BUILD_BUG_ON(condition)   ((void)sizeof(char[1 - 2*!!(condition)]))
 
#define RTE_CACHE_LINE_MASK   (RTE_CACHE_LINE_SIZE-1)
 
#define RTE_CACHE_LINE_ROUNDUP(size)
 
#define RTE_CACHE_LINE_MIN_SIZE   64
 
#define __rte_cache_aligned   __rte_aligned(RTE_CACHE_LINE_SIZE)
 
#define __rte_cache_min_aligned   __rte_aligned(RTE_CACHE_LINE_MIN_SIZE)
 
#define RTE_IS_POWER_OF_2(n)   ((n) && !(((n) - 1) & (n)))
 
#define RTE_MIN(a, b)
 
#define RTE_MAX(a, b)
 
#define offsetof(TYPE, MEMBER)   __builtin_offsetof (TYPE, MEMBER)
 
#define container_of(ptr, type, member)
 
#define RTE_SWAP(a, b)
 
#define RTE_SIZEOF_FIELD(type, field)   (sizeof(((type *)0)->field))
 
#define RTE_STR(x)   _RTE_STR(x)
 
#define RTE_FMT(fmt, ...)   fmt "%.0s", __VA_ARGS__ ""
 
#define RTE_LEN2MASK(ln, tp)   ((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))
 
#define RTE_DIM(a)   (sizeof (a) / sizeof ((a)[0]))
 

Typedefs

typedef uint64_t phys_addr_t
 
typedef uint64_t rte_iova_t
 

Functions

static int rte_is_aligned (void *ptr, unsigned align)
 
static uint32_t rte_combine32ms1b (uint32_t x)
 
static uint64_t rte_combine64ms1b (uint64_t v)
 
static int rte_is_power_of_2 (uint32_t n)
 
static uint32_t rte_align32pow2 (uint32_t x)
 
static uint32_t rte_align32prevpow2 (uint32_t x)
 
static uint64_t rte_align64pow2 (uint64_t v)
 
static uint64_t rte_align64prevpow2 (uint64_t v)
 
static uint32_t rte_bsf32 (uint32_t v)
 
static int rte_bsf32_safe (uint32_t v, uint32_t *pos)
 
static uint32_t rte_log2_u32 (uint32_t v)
 
static int rte_fls_u32 (uint32_t x)
 
static int rte_bsf64 (uint64_t v)
 
static int rte_bsf64_safe (uint64_t v, uint32_t *pos)
 
static int rte_fls_u64 (uint64_t x)
 
static uint32_t rte_log2_u64 (uint64_t v)
 
static uint64_t rte_str_to_size (const char *str)
 
__rte_noreturn void rte_exit (int exit_code, const char *format,...) __rte_format_printf(2
 

Variables

__extension__ typedef void * RTE_MARKER [0]
 
__extension__ typedef uint8_t RTE_MARKER8 [0]
 
__extension__ typedef uint16_t RTE_MARKER16 [0]
 
__extension__ typedef uint32_t RTE_MARKER32 [0]
 
__extension__ typedef uint64_t RTE_MARKER64 [0]
 

Detailed Description

Generic, commonly-used macro and inline function definitions for DPDK.

Definition in file rte_common.h.

Macro Definition Documentation

◆ RTE_STD_C11

#define RTE_STD_C11   __extension__

C extension macro for environments lacking C11 features.

Examples:
examples/ip_pipeline/thread.c, and examples/ipsec-secgw/flow.c.

Definition at line 42 of file rte_common.h.

◆ __rte_aligned

#define __rte_aligned (   a)    __attribute__((__aligned__(a)))

Force alignment

Definition at line 71 of file rte_common.h.

◆ __rte_packed

struct rte_vxlan_gpe_hdr __rte_packed   __attribute__((__packed__))

◆ __rte_may_alias

#define __rte_may_alias   __attribute__((__may_alias__))

Macro to mark a type that is not subject to type-based aliasing rules

Definition at line 91 of file rte_common.h.

◆ RTE_DEPRECATED

#define RTE_DEPRECATED (   x)

Macro to mark macros and defines scheduled for removal

Definition at line 105 of file rte_common.h.

◆ __rte_weak

#define __rte_weak   __attribute__((__weak__))

Mark a function or variable to a weak reference.

Definition at line 111 of file rte_common.h.

◆ __rte_used

#define __rte_used   __attribute__((used))

Force symbol to be generated even if it appears to be unused.

Definition at line 116 of file rte_common.h.

◆ __rte_unused

#define __rte_unused   __attribute__((__unused__))

short definition to mark a function parameter unused

Examples:
examples/bond/main.c, examples/cmdline/commands.c, examples/cmdline/parse_obj_list.c, examples/ethtool/ethtool-app/ethapp.c, examples/ethtool/ethtool-app/main.c, examples/ethtool/lib/rte_ethtool.c, examples/fips_validation/fips_validation_aes.c, examples/fips_validation/fips_validation_gcm.c, examples/fips_validation/fips_validation_hmac.c, examples/fips_validation/fips_validation_sha.c, examples/fips_validation/fips_validation_tdes.c, examples/fips_validation/fips_validation_xts.c, examples/helloworld/main.c, examples/ip_fragmentation/main.c, examples/ip_pipeline/kni.c, examples/ip_pipeline/tap.c, examples/ip_pipeline/thread.c, examples/ip_reassembly/main.c, examples/ipsec-secgw/ipsec-secgw.c, examples/ipsec-secgw/parser.c, examples/ipv4_multicast/main.c, examples/kni/main.c, examples/l2fwd-jobstats/main.c, examples/l2fwd-keepalive/main.c, examples/l2fwd-keepalive/shm.c, examples/l2fwd/main.c, examples/l3fwd-acl/main.c, examples/l3fwd-power/main.c, examples/l3fwd/l3fwd_em.c, examples/l3fwd/l3fwd_fib.c, examples/l3fwd/l3fwd_lpm.c, examples/link_status_interrupt/main.c, examples/multi_process/client_server_mp/mp_server/main.c, examples/multi_process/hotplug_mp/commands.c, examples/multi_process/simple_mp/main.c, examples/multi_process/simple_mp/mp_commands.c, examples/multi_process/symmetric_mp/main.c, examples/ntb/ntb_fwd.c, examples/packet_ordering/main.c, examples/performance-thread/common/arch/arm64/ctx.c, examples/performance-thread/common/lthread_cond.c, examples/performance-thread/common/lthread_mutex.c, examples/performance-thread/l3fwd-thread/main.c, examples/performance-thread/pthread_shim/main.c, examples/pipeline/cli.c, examples/pipeline/obj.c, examples/pipeline/thread.c, examples/qos_meter/main.c, examples/qos_sched/cmdline.c, examples/qos_sched/main.c, examples/rxtx_callbacks/main.c, examples/server_node_efd/server/main.c, examples/timer/main.c, examples/vdpa/main.c, examples/vhost/main.c, examples/vhost_blk/blk.c, examples/vhost_blk/vhost_blk.c, examples/vm_power_manager/channel_manager.c, examples/vm_power_manager/channel_monitor.c, examples/vm_power_manager/guest_cli/vm_power_cli_guest.c, examples/vm_power_manager/main.c, examples/vm_power_manager/oob_monitor_nop.c, examples/vm_power_manager/vm_power_cli.c, and examples/vmdq/main.c.

Definition at line 123 of file rte_common.h.

◆ __rte_restrict

#define __rte_restrict   __restrict

Mark pointer as restricted with regard to pointer aliasing.

Examples:
examples/performance-thread/pthread_shim/pthread_shim.c.

Definition at line 129 of file rte_common.h.

◆ RTE_SET_USED

#define RTE_SET_USED (   x)    (void)(x)

definition to mark a variable or function parameter as used so as to avoid a compiler warning

Examples:
examples/bbdev_app/main.c, examples/ipsec-secgw/ipsec-secgw.c, examples/l3fwd-graph/main.c, examples/l3fwd-power/main.c, examples/link_status_interrupt/main.c, and examples/service_cores/main.c.

Definition at line 138 of file rte_common.h.

◆ __rte_format_printf

#define __rte_format_printf (   format_index,
  first_arg 
)    __attribute__((format(printf, format_index, first_arg)))

Check format string and its arguments at compile-time.

GCC on Windows assumes MS-specific format string by default, even if the underlying stdio implementation is ANSI-compliant, so this must be overridden.

Definition at line 151 of file rte_common.h.

◆ __rte_alloc_size

#define __rte_alloc_size (   ...)

Tells compiler that the function returns a value that points to memory, where the size is given by the one or two arguments. Used by compiler to validate object size.

Definition at line 164 of file rte_common.h.

◆ RTE_INIT_PRIO

#define RTE_INIT_PRIO (   func,
  prio 
)    static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void)

Run function before main() with high priority.

Parameters
funcConstructor function.
prioPriority number must be above 100. Lowest number is the first to run.

Definition at line 185 of file rte_common.h.

◆ RTE_INIT

#define RTE_INIT (   func)    RTE_INIT_PRIO(func, LAST)

Run function before main() with low priority.

The constructor will be run after prioritized constructors.

Parameters
funcConstructor function.
Examples:
examples/performance-thread/common/lthread_diag.c, examples/performance-thread/common/lthread_sched.c, examples/performance-thread/common/lthread_tls.c, and examples/performance-thread/pthread_shim/pthread_shim.c.

Definition at line 197 of file rte_common.h.

◆ RTE_FINI_PRIO

#define RTE_FINI_PRIO (   func,
  prio 
)    static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)

Run after main() with low priority.

Parameters
funcDestructor function name.
prioPriority number must be above 100. Lowest number is the last to run.

Definition at line 210 of file rte_common.h.

◆ RTE_FINI

#define RTE_FINI (   func)    RTE_FINI_PRIO(func, LAST)

Run after main() with high priority.

The destructor will be run before prioritized destructors.

Parameters
funcDestructor function name.

Definition at line 222 of file rte_common.h.

◆ __rte_noreturn

#define __rte_noreturn   __attribute__((noreturn))

◆ __rte_always_inline

#define __rte_always_inline   inline __attribute__((always_inline))

◆ __rte_noinline

#define __rte_noinline   __attribute__((noinline))

◆ __rte_hot

#define __rte_hot   __attribute__((hot))

Hint function in the hot path

Definition at line 243 of file rte_common.h.

◆ __rte_cold

#define __rte_cold   __attribute__((cold))

Hint function in the cold path

Definition at line 248 of file rte_common.h.

◆ __rte_no_asan

#define __rte_no_asan

Disable AddressSanitizer on some code

Definition at line 260 of file rte_common.h.

◆ RTE_PTR_ADD

#define RTE_PTR_ADD (   ptr,
 
)    ((void*)((uintptr_t)(ptr) + (x)))

add a byte-value offset to a pointer

Examples:
examples/ipsec-secgw/esp.c, and examples/ipsec-secgw/ipsec_worker.c.

Definition at line 268 of file rte_common.h.

◆ RTE_PTR_SUB

#define RTE_PTR_SUB (   ptr,
 
)    ((void *)((uintptr_t)(ptr) - (x)))

subtract a byte-value offset from a pointer

Definition at line 273 of file rte_common.h.

◆ RTE_PTR_DIFF

#define RTE_PTR_DIFF (   ptr1,
  ptr2 
)    ((uintptr_t)(ptr1) - (uintptr_t)(ptr2))

get the difference between two pointer values, i.e. how far apart in bytes are the locations they point two. It is assumed that ptr1 is greater than ptr2.

Examples:
examples/ipsec-secgw/sa.c, examples/ipsec-secgw/sp4.c, and examples/ipsec-secgw/sp6.c.

Definition at line 280 of file rte_common.h.

◆ RTE_CAST_FIELD

#define RTE_CAST_FIELD (   var,
  field,
  type 
)    (*(type *)((uintptr_t)(var) + offsetof(typeof(*(var)), field)))

Workaround to cast a const field of a structure to non-const type.

Definition at line 285 of file rte_common.h.

◆ RTE_PTR_ALIGN_FLOOR

#define RTE_PTR_ALIGN_FLOOR (   ptr,
  align 
)    ((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)(ptr), align))

Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as the first parameter, and point to an address no higher than the first parameter. Second parameter must be a power-of-two value.

Definition at line 297 of file rte_common.h.

◆ RTE_ALIGN_FLOOR

#define RTE_ALIGN_FLOOR (   val,
  align 
)    (typeof(val))((val) & (~((typeof(val))((align) - 1))))

Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first parameter, and will be no bigger than the first parameter. Second parameter must be a power-of-two value.

Examples:
examples/performance-thread/l3fwd-thread/main.c.

Definition at line 306 of file rte_common.h.

◆ RTE_PTR_ALIGN_CEIL

#define RTE_PTR_ALIGN_CEIL (   ptr,
  align 
)    RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align)

Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as the first parameter, and point to an address no lower than the first parameter. Second parameter must be a power-of-two value.

Definition at line 315 of file rte_common.h.

◆ RTE_ALIGN_CEIL

#define RTE_ALIGN_CEIL (   val,
  align 
)    RTE_ALIGN_FLOOR(((val) + ((typeof(val)) (align) - 1)), align)

Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first parameter, and will be no lower than the first parameter. Second parameter must be a power-of-two value.

Examples:
examples/bbdev_app/main.c, examples/fips_validation/fips_dev_self_test.c, and examples/ipsec-secgw/esp.c.

Definition at line 324 of file rte_common.h.

◆ RTE_PTR_ALIGN

#define RTE_PTR_ALIGN (   ptr,
  align 
)    RTE_PTR_ALIGN_CEIL(ptr, align)

Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as the first parameter, and point to an address no lower than the first parameter. Second parameter must be a power-of-two value. This function is the same as RTE_PTR_ALIGN_CEIL

Definition at line 334 of file rte_common.h.

◆ RTE_ALIGN

#define RTE_ALIGN (   val,
  align 
)    RTE_ALIGN_CEIL(val, align)

Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first parameter, and will be no lower than the first parameter. Second parameter must be a power-of-two value. This function is the same as RTE_ALIGN_CEIL

Examples:
examples/l2fwd-crypto/main.c.

Definition at line 343 of file rte_common.h.

◆ RTE_ALIGN_MUL_CEIL

#define RTE_ALIGN_MUL_CEIL (   v,
  mul 
)    ((((v) + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) * (typeof(v))(mul))

Macro to align a value to the multiple of given value. The resultant value will be of the same type as the first parameter and will be no lower than the first parameter.

Definition at line 350 of file rte_common.h.

◆ RTE_ALIGN_MUL_FLOOR

#define RTE_ALIGN_MUL_FLOOR (   v,
  mul 
)    (((v) / ((typeof(v))(mul))) * (typeof(v))(mul))

Macro to align a value to the multiple of given value. The resultant value will be of the same type as the first parameter and will be no higher than the first parameter.

Definition at line 358 of file rte_common.h.

◆ RTE_ALIGN_MUL_NEAR

#define RTE_ALIGN_MUL_NEAR (   v,
  mul 
)
Value:
({ \
typeof(v) ceil = RTE_ALIGN_MUL_CEIL(v, mul); \
typeof(v) floor = RTE_ALIGN_MUL_FLOOR(v, mul); \
(ceil - (v)) > ((v) - floor) ? floor : ceil; \
})
#define RTE_ALIGN_MUL_FLOOR(v, mul)
Definition: rte_common.h:358
#define RTE_ALIGN_MUL_CEIL(v, mul)
Definition: rte_common.h:350

Macro to align value to the nearest multiple of the given value. The resultant value might be greater than or less than the first parameter whichever difference is the lowest.

Definition at line 366 of file rte_common.h.

◆ RTE_BUILD_BUG_ON

#define RTE_BUILD_BUG_ON (   condition)    ((void)sizeof(char[1 - 2*!!(condition)]))

Triggers an error at compilation time if the condition is true.

Definition at line 395 of file rte_common.h.

◆ RTE_CACHE_LINE_MASK

#define RTE_CACHE_LINE_MASK   (RTE_CACHE_LINE_SIZE-1)

Cache line mask.

Definition at line 400 of file rte_common.h.

◆ RTE_CACHE_LINE_ROUNDUP

#define RTE_CACHE_LINE_ROUNDUP (   size)
Value:
(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
RTE_CACHE_LINE_SIZE))

Return the first cache-aligned value greater or equal to size.

Examples:
examples/flow_classify/flow_classify.c.

Definition at line 403 of file rte_common.h.

◆ RTE_CACHE_LINE_MIN_SIZE

#define RTE_CACHE_LINE_MIN_SIZE   64

Cache line size in terms of log2 Minimum Cache line size.

Definition at line 417 of file rte_common.h.

◆ __rte_cache_aligned

struct rte_regexdev __rte_cache_aligned   __rte_aligned(RTE_CACHE_LINE_SIZE)

◆ __rte_cache_min_aligned

struct rte_eth_txq_info __rte_cache_min_aligned   __rte_aligned(RTE_CACHE_LINE_MIN_SIZE)

Force minimum cache line alignment.

Definition at line 423 of file rte_common.h.

◆ RTE_IS_POWER_OF_2

#define RTE_IS_POWER_OF_2 (   n)    ((n) && !(((n) - 1) & (n)))

Macro to return 1 if n is a power of 2, 0 otherwise

Definition at line 504 of file rte_common.h.

◆ RTE_MIN

#define RTE_MIN (   a,
 
)

◆ RTE_MAX

#define RTE_MAX (   a,
 
)

◆ offsetof

#define offsetof (   TYPE,
  MEMBER 
)    __builtin_offsetof (TYPE, MEMBER)

◆ container_of

#define container_of (   ptr,
  type,
  member 
)
Value:
__extension__ ({ \
const typeof(((type *)0)->member) *_ptr = (ptr); \
__rte_unused type *_target_ptr = \
(type *)(ptr); \
(type *)(((uintptr_t)_ptr) - offsetof(type, member)); \
})
#define offsetof(TYPE, MEMBER)
Definition: rte_common.h:773

Return pointer to the wrapping struct instance.

Example:

struct wrapper { ... struct child c; ... };

struct child *x = obtain(...); struct wrapper *w = container_of(x, struct wrapper, c);

Definition at line 791 of file rte_common.h.

◆ RTE_SWAP

#define RTE_SWAP (   a,
 
)
Value:
__extension__ ({ \
typeof (a) _a = a; \
a = b; \
b = _a; \
})

Swap two variables.

Definition at line 800 of file rte_common.h.

◆ RTE_SIZEOF_FIELD

#define RTE_SIZEOF_FIELD (   type,
  field 
)    (sizeof(((type *)0)->field))

Get the size of a field in a structure.

Parameters
typeThe type of the structure.
fieldThe field in the structure.
Returns
The size of the field in the structure, in bytes.

Definition at line 817 of file rte_common.h.

◆ RTE_STR

#define RTE_STR (   x)    _RTE_STR(x)

Take a macro value and get a string version of it

Examples:
examples/l3fwd-acl/main.c, and examples/vhost_crypto/main.c.

Definition at line 821 of file rte_common.h.

◆ RTE_FMT

#define RTE_FMT (   fmt,
  ... 
)    fmt "%.0s", __VA_ARGS__ ""

ISO C helpers to modify format strings using variadic macros. This is a replacement for the ", ## __VA_ARGS__" GNU extension. An empty s argument is appended to avoid a dangling comma.

Definition at line 828 of file rte_common.h.

◆ RTE_LEN2MASK

#define RTE_LEN2MASK (   ln,
  tp 
)    ((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))

Mask value of type "tp" for the first "ln" bit set.

Examples:
examples/ip_fragmentation/main.c, examples/ip_reassembly/main.c, and examples/l3fwd-power/main.c.

Definition at line 833 of file rte_common.h.

◆ RTE_DIM

#define RTE_DIM (   a)    (sizeof (a) / sizeof ((a)[0]))

Typedef Documentation

◆ phys_addr_t

typedef uint64_t phys_addr_t

Physical address

Definition at line 428 of file rte_common.h.

◆ rte_iova_t

typedef uint64_t rte_iova_t

IO virtual address type. When the physical addressing mode (IOVA as PA) is in use, the translation from an IO virtual address (IOVA) to a physical address is a direct mapping, i.e. the same value. Otherwise, in virtual mode (IOVA as VA), an IOMMU may do the translation.

Definition at line 438 of file rte_common.h.

Function Documentation

◆ rte_is_aligned()

static int rte_is_aligned ( void *  ptr,
unsigned  align 
)
inlinestatic

Checks if a pointer is aligned to a given power-of-two value

Parameters
ptrThe pointer whose alignment is to be checked
alignThe power-of-two value to which the ptr should be aligned
Returns
True(1) where the pointer is correctly aligned, false(0) otherwise

Definition at line 385 of file rte_common.h.

◆ rte_combine32ms1b()

static uint32_t rte_combine32ms1b ( uint32_t  x)
inlinestatic

Combines 32b inputs most significant set bits into the least significant bits to construct a value with the same MSBs as x but all 1's under it.

Parameters
xThe integer whose MSBs need to be combined with its LSBs
Returns
The combined value.

Definition at line 465 of file rte_common.h.

◆ rte_combine64ms1b()

static uint64_t rte_combine64ms1b ( uint64_t  v)
inlinestatic

Combines 64b inputs most significant set bits into the least significant bits to construct a value with the same MSBs as x but all 1's under it.

Parameters
vThe integer whose MSBs need to be combined with its LSBs
Returns
The combined value.

Definition at line 487 of file rte_common.h.

◆ rte_is_power_of_2()

static int rte_is_power_of_2 ( uint32_t  n)
inlinestatic

Returns true if n is a power of 2

Parameters
nNumber to check
Returns
1 if true, 0 otherwise
Examples:
examples/ipsec-secgw/event_helper.c.

Definition at line 513 of file rte_common.h.

◆ rte_align32pow2()

static uint32_t rte_align32pow2 ( uint32_t  x)
inlinestatic

Aligns input parameter to the next power of 2

Parameters
xThe integer value to align
Returns
Input parameter aligned to the next power of 2
Examples:
examples/bbdev_app/main.c, and examples/ipsec-secgw/sad.c.

Definition at line 528 of file rte_common.h.

◆ rte_align32prevpow2()

static uint32_t rte_align32prevpow2 ( uint32_t  x)
inlinestatic

Aligns input parameter to the previous power of 2

Parameters
xThe integer value to align
Returns
Input parameter aligned to the previous power of 2

Definition at line 546 of file rte_common.h.

◆ rte_align64pow2()

static uint64_t rte_align64pow2 ( uint64_t  v)
inlinestatic

Aligns 64b input parameter to the next power of 2

Parameters
vThe 64b value to align
Returns
Input parameter aligned to the next power of 2

Definition at line 563 of file rte_common.h.

◆ rte_align64prevpow2()

static uint64_t rte_align64prevpow2 ( uint64_t  v)
inlinestatic

Aligns 64b input parameter to the previous power of 2

Parameters
vThe 64b value to align
Returns
Input parameter aligned to the previous power of 2

Definition at line 581 of file rte_common.h.

◆ rte_bsf32()

static uint32_t rte_bsf32 ( uint32_t  v)
inlinestatic

Searches the input parameter for the least significant set bit (starting from zero). If a least significant 1 bit is found, its bit index is returned. If the content of the input parameter is zero, then the content of the return value is undefined.

Parameters
vinput parameter, should not be zero.
Returns
least significant set bit in the input parameter.

Definition at line 624 of file rte_common.h.

◆ rte_bsf32_safe()

static int rte_bsf32_safe ( uint32_t  v,
uint32_t *  pos 
)
inlinestatic

Searches the input parameter for the least significant set bit (starting from zero). Safe version (checks for input parameter being zero).

Warning
pos must be a valid pointer. It is not checked!
Parameters
vThe input parameter.
posIf v was not 0, this value will contain position of least significant bit within the input parameter.
Returns
Returns 0 if v was 0, otherwise returns 1.

Definition at line 644 of file rte_common.h.

◆ rte_log2_u32()

static uint32_t rte_log2_u32 ( uint32_t  v)
inlinestatic

Return the rounded-up log2 of a integer.

Note
Contrary to the logarithm mathematical operation, rte_log2_u32(0) == 0 and not -inf.
Parameters
vThe input parameter.
Returns
The rounded-up log2 of the input, or 0 if the input is 0.

Definition at line 665 of file rte_common.h.

◆ rte_fls_u32()

static int rte_fls_u32 ( uint32_t  x)
inlinestatic

Return the last (most-significant) bit set.

Note
The last (most significant) bit is at position 32.
rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32
Parameters
xThe input parameter.
Returns
The last (most-significant) bit set, or 0 if the input is 0.

Definition at line 686 of file rte_common.h.

◆ rte_bsf64()

static int rte_bsf64 ( uint64_t  v)
inlinestatic

Searches the input parameter for the least significant set bit (starting from zero). If a least significant 1 bit is found, its bit index is returned. If the content of the input parameter is zero, then the content of the return value is undefined.

Parameters
vinput parameter, should not be zero.
Returns
least significant set bit in the input parameter.

Definition at line 703 of file rte_common.h.

◆ rte_bsf64_safe()

static int rte_bsf64_safe ( uint64_t  v,
uint32_t *  pos 
)
inlinestatic

Searches the input parameter for the least significant set bit (starting from zero). Safe version (checks for input parameter being zero).

Warning
pos must be a valid pointer. It is not checked!
Parameters
vThe input parameter.
posIf v was not 0, this value will contain position of least significant bit within the input parameter.
Returns
Returns 0 if v was 0, otherwise returns 1.

Definition at line 723 of file rte_common.h.

◆ rte_fls_u64()

static int rte_fls_u64 ( uint64_t  x)
inlinestatic

Return the last (most-significant) bit set.

Note
The last (most significant) bit is at position 64.
rte_fls_u64(0) = 0, rte_fls_u64(1) = 1, rte_fls_u64(0x8000000000000000) = 64
Parameters
xThe input parameter.
Returns
The last (most-significant) bit set, or 0 if the input is 0.

Definition at line 745 of file rte_common.h.

◆ rte_log2_u64()

static uint32_t rte_log2_u64 ( uint64_t  v)
inlinestatic

Return the rounded-up log2 of a 64-bit integer.

Note
Contrary to the logarithm mathematical operation, rte_log2_u64(0) == 0 and not -inf.
Parameters
vThe input parameter.
Returns
The rounded-up log2 of the input, or 0 if the input is 0.

Definition at line 762 of file rte_common.h.

◆ rte_str_to_size()

static uint64_t rte_str_to_size ( const char *  str)
inlinestatic

Converts a numeric string to the equivalent uint64_t value. As well as straight number conversion, also recognises the suffixes k, m and g for kilobytes, megabytes and gigabytes respectively.

If a negative number is passed in i.e. a string with the first non-black character being "-", zero is returned. Zero is also returned in the case of an error with the strtoull call in the function.

Parameters
strString containing number to convert.
Returns
Number.

Definition at line 854 of file rte_common.h.

◆ rte_exit()

__rte_noreturn void rte_exit ( int  exit_code,
const char *  format,
  ... 
)

Function to terminate the application immediately, printing an error message and returning the exit_code back to the shell.

This function never returns

Parameters
exit_codeThe exit code to be returned by the application
formatThe format string to be used for printing the message. This can include printf format characters which will be expanded using any further parameters to the function.
Examples:
examples/bbdev_app/main.c, examples/bond/main.c, examples/distributor/main.c, examples/dma/dmafwd.c, examples/ethtool/ethtool-app/main.c, examples/eventdev_pipeline/main.c, examples/eventdev_pipeline/pipeline_worker_generic.c, examples/eventdev_pipeline/pipeline_worker_tx.c, examples/fips_validation/main.c, examples/flow_classify/flow_classify.c, examples/flow_filtering/main.c, examples/ip_fragmentation/main.c, examples/ip_reassembly/main.c, examples/ipsec-secgw/ipsec-secgw.c, examples/ipsec-secgw/rt.c, examples/ipsec-secgw/sa.c, examples/ipsec-secgw/sp4.c, examples/ipsec-secgw/sp6.c, examples/ipv4_multicast/main.c, examples/kni/main.c, examples/l2fwd-cat/l2fwd-cat.c, examples/l2fwd-crypto/main.c, examples/l2fwd-jobstats/main.c, examples/l2fwd-keepalive/main.c, examples/l2fwd/main.c, examples/l3fwd-acl/main.c, examples/l3fwd-graph/main.c, examples/l3fwd-power/main.c, examples/l3fwd/l3fwd_em.c, examples/l3fwd/l3fwd_event.c, examples/l3fwd/l3fwd_fib.c, examples/l3fwd/l3fwd_lpm.c, examples/l3fwd/main.c, examples/link_status_interrupt/main.c, examples/multi_process/client_server_mp/mp_client/client.c, examples/multi_process/client_server_mp/mp_server/init.c, examples/multi_process/simple_mp/main.c, examples/multi_process/symmetric_mp/main.c, examples/ntb/ntb_fwd.c, examples/packet_ordering/main.c, examples/performance-thread/l3fwd-thread/main.c, examples/performance-thread/pthread_shim/main.c, examples/ptpclient/ptpclient.c, examples/qos_meter/main.c, examples/qos_sched/cfg_file.c, examples/qos_sched/init.c, examples/rxtx_callbacks/main.c, examples/server_node_efd/node/node.c, examples/server_node_efd/server/init.c, examples/service_cores/main.c, examples/skeleton/basicfwd.c, examples/vdpa/main.c, examples/vhost/main.c, examples/vhost_blk/vhost_blk.c, examples/vhost_crypto/main.c, examples/vm_power_manager/guest_cli/main.c, examples/vm_power_manager/main.c, examples/vmdq/main.c, and examples/vmdq_dcb/main.c.

Variable Documentation

◆ RTE_MARKER

__extension__ typedef void* RTE_MARKER[0]

Generic marker for any place in a structure.

Definition at line 444 of file rte_common.h.

◆ RTE_MARKER8

__extension__ typedef uint8_t RTE_MARKER8[0]

Marker for 1B alignment in a structure.

Definition at line 446 of file rte_common.h.

◆ RTE_MARKER16

__extension__ typedef uint16_t RTE_MARKER16[0]

Marker for 2B alignment in a structure.

Definition at line 448 of file rte_common.h.

◆ RTE_MARKER32

__extension__ typedef uint32_t RTE_MARKER32[0]

Marker for 4B alignment in a structure.

Definition at line 450 of file rte_common.h.

◆ RTE_MARKER64

__extension__ typedef uint64_t RTE_MARKER64[0]

Marker for 8B alignment in a structure.

Definition at line 452 of file rte_common.h.