diff options
Diffstat (limited to 'src/vppinfra/vec_bootstrap.h')
-rw-r--r-- | src/vppinfra/vec_bootstrap.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/vppinfra/vec_bootstrap.h b/src/vppinfra/vec_bootstrap.h index fbb01b685ca..879703c8f6a 100644 --- a/src/vppinfra/vec_bootstrap.h +++ b/src/vppinfra/vec_bootstrap.h @@ -58,11 +58,14 @@ typedef struct u64 len; #else u32 len; /**< Number of elements in vector (NOT its allocated length). */ - u32 dlmalloc_header_offset; /**< offset to memory allocator offset */ + u8 numa_id; /**< NUMA id */ + u8 vpad[3]; /**< pad to 8 bytes */ #endif u8 vector_data[0]; /**< Vector data . */ } vec_header_t; +#define VEC_NUMA_UNSPECIFIED (0xFF) + /** \brief Find the vector header Given the user's pointer to a vector, find the corresponding @@ -128,7 +131,7 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align) /** \brief Number of elements in vector (lvalue-capable) - _vec_len (v) does not check for null, but can be used as a lvalue + _vec_len (v) does not check for null, but can be used as an lvalue (e.g. _vec_len (v) = 99). */ @@ -142,6 +145,20 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align) #define vec_len(v) ((v) ? _vec_len(v) : 0) +/** \brief Vector's NUMA id (lvalue-capable) + + _vec_numa(v) does not check for null, but can be used as an lvalue + (e.g. _vec_numa(v) = 1). +*/ + +#define _vec_numa(v) (_vec_find(v)->numa_id) + +/** \brief Return vector's NUMA ID (rvalue-only, NULL tolerant) + vec_numa(v) checks for NULL, but cannot be used as an lvalue. +*/ +#define vec_numa(v) ((v) ? _vec_numa(v) : 0) + + /** \brief Number of data bytes in vector. */ #define vec_bytes(v) (vec_len (v) * sizeof (v[0])) @@ -208,6 +225,17 @@ for (var = vec_end (vec) - 1; var >= (vec); var--) #define vec_foreach_index_backwards(var,v) \ for ((var) = vec_len((v)) - 1; (var) >= 0; (var)--) +/** \brief return the NUMA index for a vector */ +always_inline uword +vec_get_numa (void *v) +{ + vec_header_t *vh; + if (v == 0) + return 0; + vh = _vec_find (v); + return vh->numa_id; +} + #endif /* included_clib_vec_bootstrap_h */ /* |