DPDK 25.03.0-rc0
|
Go to the source code of this file.
Macros | |
#define | RTE_BIT64(nr) (UINT64_C(1) << (nr)) |
#define | RTE_BIT32(nr) (UINT32_C(1) << (nr)) |
#define | RTE_SHIFT_VAL32(val, nr) (UINT32_C(val) << (nr)) |
#define | RTE_SHIFT_VAL64(val, nr) (UINT64_C(val) << (nr)) |
#define | RTE_GENMASK32(high, low) (((~UINT32_C(0)) << (low)) & (~UINT32_C(0) >> (31u - (high)))) |
#define | RTE_GENMASK64(high, low) (((~UINT64_C(0)) << (low)) & (~UINT64_C(0) >> (63u - (high)))) |
#define | RTE_FIELD_GET32(mask, reg) ((typeof(mask))(((reg) & (mask)) >> rte_ctz32(mask))) |
#define | RTE_FIELD_GET64(mask, reg) ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask))) |
#define | rte_bit_test(addr, nr) |
#define | rte_bit_set(addr, nr) |
#define | rte_bit_clear(addr, nr) |
#define | rte_bit_assign(addr, nr, value) |
#define | rte_bit_flip(addr, nr) |
#define | rte_bit_atomic_test(addr, nr, memory_order) |
#define | rte_bit_atomic_set(addr, nr, memory_order) |
#define | rte_bit_atomic_clear(addr, nr, memory_order) |
#define | rte_bit_atomic_assign(addr, nr, value, memory_order) |
#define | rte_bit_atomic_flip(addr, nr, memory_order) |
#define | rte_bit_atomic_test_and_set(addr, nr, memory_order) |
#define | rte_bit_atomic_test_and_clear(addr, nr, memory_order) |
#define | rte_bit_atomic_test_and_assign(addr, nr, value, memory_order) |
#define | RTE_IS_POWER_OF_2(n) ((n) && !(((n) - 1) & (n))) |
Functions | |
static uint32_t | rte_bit_relaxed_get32 (unsigned int nr, volatile uint32_t *addr) |
static void | rte_bit_relaxed_set32 (unsigned int nr, volatile uint32_t *addr) |
static void | rte_bit_relaxed_clear32 (unsigned int nr, volatile uint32_t *addr) |
static uint32_t | rte_bit_relaxed_test_and_set32 (unsigned int nr, volatile uint32_t *addr) |
static uint32_t | rte_bit_relaxed_test_and_clear32 (unsigned int nr, volatile uint32_t *addr) |
static uint64_t | rte_bit_relaxed_get64 (unsigned int nr, volatile uint64_t *addr) |
static void | rte_bit_relaxed_set64 (unsigned int nr, volatile uint64_t *addr) |
static void | rte_bit_relaxed_clear64 (unsigned int nr, volatile uint64_t *addr) |
static uint64_t | rte_bit_relaxed_test_and_set64 (unsigned int nr, volatile uint64_t *addr) |
static uint64_t | rte_bit_relaxed_test_and_clear64 (unsigned int nr, volatile uint64_t *addr) |
static unsigned int | rte_clz32 (uint32_t v) |
static unsigned int | rte_clz64 (uint64_t v) |
static unsigned int | rte_ctz32 (uint32_t v) |
static unsigned int | rte_ctz64 (uint64_t v) |
static unsigned int | rte_popcount32 (uint32_t v) |
static unsigned int | rte_popcount64 (uint64_t v) |
static uint32_t | rte_combine32ms1b (uint32_t x) |
static uint64_t | rte_combine64ms1b (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_bsf64 (uint64_t v) |
static int | rte_bsf64_safe (uint64_t v, uint32_t *pos) |
static uint32_t | rte_fls_u32 (uint32_t x) |
static uint32_t | rte_fls_u64 (uint64_t x) |
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_log2_u32 (uint32_t v) |
static uint32_t | rte_log2_u64 (uint64_t v) |
Bit Operations
This file provides functionality for low-level, single-word arithmetic and bit-level operations, such as counting or setting individual bits.
Definition in file rte_bitops.h.
#define RTE_BIT64 | ( | nr | ) | (UINT64_C(1) << (nr)) |
Get the uint64_t value for a specified bit set.
nr | The bit number in range of 0 to 63. |
Definition at line 36 of file rte_bitops.h.
#define RTE_BIT32 | ( | nr | ) | (UINT32_C(1) << (nr)) |
Get the uint32_t value for a specified bit set.
nr | The bit number in range of 0 to 31. |
Definition at line 44 of file rte_bitops.h.
#define RTE_SHIFT_VAL32 | ( | val, | |
nr | |||
) | (UINT32_C(val) << (nr)) |
Get the uint32_t shifted value.
val | The value to be shifted. |
nr | The shift number in range of 0 to (32 - width of val). |
Definition at line 54 of file rte_bitops.h.
#define RTE_SHIFT_VAL64 | ( | val, | |
nr | |||
) | (UINT64_C(val) << (nr)) |
Get the uint64_t shifted value.
val | The value to be shifted. |
nr | The shift number in range of 0 to (64 - width of val). |
Definition at line 64 of file rte_bitops.h.
#define RTE_GENMASK32 | ( | high, | |
low | |||
) | (((~UINT32_C(0)) << (low)) & (~UINT32_C(0) >> (31u - (high)))) |
Generate a contiguous 32-bit mask starting at bit position low and ending at position high.
high | High bit position. |
low | Low bit position. |
Definition at line 75 of file rte_bitops.h.
#define RTE_GENMASK64 | ( | high, | |
low | |||
) | (((~UINT64_C(0)) << (low)) & (~UINT64_C(0) >> (63u - (high)))) |
Generate a contiguous 64-bit mask starting at bit position low and ending at position high.
high | High bit position. |
low | Low bit position. |
Definition at line 87 of file rte_bitops.h.
#define RTE_FIELD_GET32 | ( | mask, | |
reg | |||
) | ((typeof(mask))(((reg) & (mask)) >> rte_ctz32(mask))) |
Extract a 32-bit field element.
mask | Shifted mask. |
reg | Value of entire bitfield. |
Definition at line 98 of file rte_bitops.h.
#define RTE_FIELD_GET64 | ( | mask, | |
reg | |||
) | ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask))) |
Extract a 64-bit field element.
mask | Shifted mask. |
reg | Value of entire bitfield. |
Definition at line 109 of file rte_bitops.h.
#define rte_bit_test | ( | addr, | |
nr | |||
) |
Test bit in word.
Generic selection macro to test the value of a bit in a 32-bit or 64-bit word. The type of operation depends on the type of the addr
parameter.
This macro does not give any guarantees in regards to memory ordering or atomicity.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
Definition at line 130 of file rte_bitops.h.
#define rte_bit_set | ( | addr, | |
nr | |||
) |
Set bit in word.
Generic selection macro to set a bit in a 32-bit or 64-bit word. The type of operation depends on the type of the addr
parameter.
This macro does not give any guarantees in regards to memory ordering or atomicity.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
Definition at line 160 of file rte_bitops.h.
#define rte_bit_clear | ( | addr, | |
nr | |||
) |
Clear bit in word.
Generic selection macro to clear a bit in a 32-bit or 64-bit word. The type of operation depends on the type of the addr
parameter.
This macro does not give any guarantees in regards to memory ordering or atomicity.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
Definition at line 186 of file rte_bitops.h.
#define rte_bit_assign | ( | addr, | |
nr, | |||
value | |||
) |
Assign a value to a bit in word.
Generic selection macro to assign a value to a bit in a 32-bit or 64-bit word. The type of operation depends on the type of the addr
parameter.
This macro does not give any guarantees in regards to memory ordering or atomicity.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
value | The new value of the bit - true for '1', or false for '0'. |
Definition at line 213 of file rte_bitops.h.
#define rte_bit_flip | ( | addr, | |
nr | |||
) |
Flip a bit in word.
Generic selection macro to change the value of a bit to '0' if '1' or '1' if '0' in a 32-bit or 64-bit word. The type of operation depends on the type of the addr
parameter.
This macro does not give any guarantees in regards to memory ordering or atomicity.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
Definition at line 239 of file rte_bitops.h.
#define rte_bit_atomic_test | ( | addr, | |
nr, | |||
memory_order | |||
) |
Test if a particular bit in a word is set with a particular memory order.
Test a bit with the resulting memory load ordered as per the specified memory order.
addr | A pointer to the word to query. |
nr | The index of the bit. |
memory_order | The memory order to use. |
Definition at line 266 of file rte_bitops.h.
#define rte_bit_atomic_set | ( | addr, | |
nr, | |||
memory_order | |||
) |
Atomically set bit in word.
Generic selection macro to atomically set bit specified by nr
in the word pointed to by addr
to '1', with the memory ordering as specified by memory_order
.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
memory_order | The memory order to use. |
Definition at line 295 of file rte_bitops.h.
#define rte_bit_atomic_clear | ( | addr, | |
nr, | |||
memory_order | |||
) |
Atomically clear bit in word.
Generic selection macro to atomically set bit specified by nr
in the word pointed to by addr
to '0', with the memory ordering as specified by memory_order
.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
memory_order | The memory order to use. |
Definition at line 320 of file rte_bitops.h.
#define rte_bit_atomic_assign | ( | addr, | |
nr, | |||
value, | |||
memory_order | |||
) |
Atomically assign a value to bit in word.
Generic selection macro to atomically set bit specified by nr
in the word pointed to by addr
to the value indicated by value
, with the memory ordering as specified with memory_order
.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
value | The new value of the bit - true for '1', or false for '0'. |
memory_order | The memory order to use. |
Definition at line 347 of file rte_bitops.h.
#define rte_bit_atomic_flip | ( | addr, | |
nr, | |||
memory_order | |||
) |
Atomically flip bit in word.
Generic selection macro to atomically negate the value of the bit specified by nr
in the word pointed to by addr
to the value indicated by value
, with the memory ordering as specified with memory_order
.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
memory_order | The memory order to use. |
Definition at line 373 of file rte_bitops.h.
#define rte_bit_atomic_test_and_set | ( | addr, | |
nr, | |||
memory_order | |||
) |
Atomically test and set a bit in word.
Generic selection macro to atomically test and set bit specified by nr
in the word pointed to by addr
to '1', with the memory ordering as specified with memory_order
.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
memory_order | The memory order to use. |
Definition at line 400 of file rte_bitops.h.
#define rte_bit_atomic_test_and_clear | ( | addr, | |
nr, | |||
memory_order | |||
) |
Atomically test and clear a bit in word.
Generic selection macro to atomically test and clear bit specified by nr
in the word pointed to by addr
to '0', with the memory ordering as specified with memory_order
.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
memory_order | The memory order to use. |
Definition at line 427 of file rte_bitops.h.
#define rte_bit_atomic_test_and_assign | ( | addr, | |
nr, | |||
value, | |||
memory_order | |||
) |
Atomically test and assign a bit in word.
Generic selection macro to atomically test and assign bit specified by nr
in the word pointed to by addr
the value specified by value
, with the memory ordering as specified with memory_order
.
addr | A pointer to the word to modify. |
nr | The index of the bit. |
value | The new value of the bit - true for '1', or false for '0'. |
memory_order | The memory order to use. |
Definition at line 457 of file rte_bitops.h.
#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 1216 of file rte_bitops.h.
|
inlinestatic |
Get the target bit from a 32-bit value without memory ordering.
nr | The target bit to get. |
addr | The address holding the bit. |
Definition at line 674 of file rte_bitops.h.
|
inlinestatic |
Set the target bit in a 32-bit value to 1 without memory ordering.
nr | The target bit to set. |
addr | The address holding the bit. |
Definition at line 691 of file rte_bitops.h.
|
inlinestatic |
Clear the target bit in a 32-bit value to 0 without memory ordering.
nr | The target bit to clear. |
addr | The address holding the bit. |
Definition at line 708 of file rte_bitops.h.
|
inlinestatic |
Return the original bit from a 32-bit value, then set it to 1 without memory ordering.
nr | The target bit to get and set. |
addr | The address holding the bit. |
Definition at line 728 of file rte_bitops.h.
|
inlinestatic |
Return the original bit from a 32-bit value, then clear it to 0 without memory ordering.
nr | The target bit to get and clear. |
addr | The address holding the bit. |
Definition at line 750 of file rte_bitops.h.
|
inlinestatic |
Get the target bit from a 64-bit value without memory ordering.
nr | The target bit to get. |
addr | The address holding the bit. |
Definition at line 773 of file rte_bitops.h.
|
inlinestatic |
Set the target bit in a 64-bit value to 1 without memory ordering.
nr | The target bit to set. |
addr | The address holding the bit. |
Definition at line 790 of file rte_bitops.h.
|
inlinestatic |
Clear the target bit in a 64-bit value to 0 without memory ordering.
nr | The target bit to clear. |
addr | The address holding the bit. |
Definition at line 807 of file rte_bitops.h.
|
inlinestatic |
Return the original bit from a 64-bit value, then set it to 1 without memory ordering.
nr | The target bit to get and set. |
addr | The address holding the bit. |
Definition at line 827 of file rte_bitops.h.
|
inlinestatic |
Return the original bit from a 64-bit value, then clear it to 0 without memory ordering.
nr | The target bit to get and clear. |
addr | The address holding the bit. |
Definition at line 849 of file rte_bitops.h.
|
inlinestatic |
Get the count of leading 0-bits in v.
v | The value. |
Definition at line 972 of file rte_bitops.h.
|
inlinestatic |
Get the count of leading 0-bits in v.
v | The value. |
Definition at line 986 of file rte_bitops.h.
|
inlinestatic |
Get the count of trailing 0-bits in v.
v | The value. |
Definition at line 1000 of file rte_bitops.h.
|
inlinestatic |
Get the count of trailing 0-bits in v.
v | The value. |
Definition at line 1014 of file rte_bitops.h.
|
inlinestatic |
Get the count of 1-bits in v.
v | The value. |
Definition at line 1028 of file rte_bitops.h.
|
inlinestatic |
Get the count of 1-bits in v.
v | The value. |
Definition at line 1042 of file rte_bitops.h.
|
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.
x | The integer whose MSBs need to be combined with its LSBs |
Definition at line 1060 of file rte_bitops.h.
|
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.
v | The integer whose MSBs need to be combined with its LSBs |
Definition at line 1082 of file rte_bitops.h.
|
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.
v | input parameter, should not be zero. |
Definition at line 1106 of file rte_bitops.h.
|
inlinestatic |
Searches the input parameter for the least significant set bit (starting from zero). Safe version (checks for input parameter being zero).
pos
must be a valid pointer. It is not checked!v | The input parameter. |
pos | If v was not 0, this value will contain position of least significant bit within the input parameter. |
v
was 0, otherwise returns 1. Definition at line 1126 of file rte_bitops.h.
|
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.
v | input parameter, should not be zero. |
Definition at line 1147 of file rte_bitops.h.
|
inlinestatic |
Searches the input parameter for the least significant set bit (starting from zero). Safe version (checks for input parameter being zero).
pos
must be a valid pointer. It is not checked!v | The input parameter. |
pos | If v was not 0, this value will contain position of least significant bit within the input parameter. |
v
was 0, otherwise returns 1. Definition at line 1167 of file rte_bitops.h.
|
inlinestatic |
Return the last (most-significant) bit set.
x | The input parameter. |
Definition at line 1188 of file rte_bitops.h.
|
inlinestatic |
Return the last (most-significant) bit set.
x | The input parameter. |
Definition at line 1206 of file rte_bitops.h.
|
inlinestatic |
Returns true if n is a power of 2
n | Number to check |
Definition at line 1225 of file rte_bitops.h.
|
inlinestatic |
Aligns input parameter to the next power of 2
x | The integer value to align |
Definition at line 1240 of file rte_bitops.h.
|
inlinestatic |
Aligns input parameter to the previous power of 2
x | The integer value to align |
Definition at line 1258 of file rte_bitops.h.
|
inlinestatic |
Aligns 64b input parameter to the next power of 2
v | The 64b value to align |
Definition at line 1275 of file rte_bitops.h.
|
inlinestatic |
Aligns 64b input parameter to the previous power of 2
v | The 64b value to align |
Definition at line 1293 of file rte_bitops.h.
|
inlinestatic |
Return the rounded-up log2 of a integer.
v | The input parameter. |
Definition at line 1312 of file rte_bitops.h.
|
inlinestatic |
Return the rounded-up log2 of a 64-bit integer.
v | The input parameter. |
Definition at line 1332 of file rte_bitops.h.