|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
38 #ifndef included_sparse_vec_h
39 #define included_sparse_vec_h
54 #define SPARSE_VEC_IS_RANGE (1 << 0)
55 #define SPARSE_VEC_IS_VALID_RANGE (1 << 1)
68 #define SPARSE_VEC_INVALID_INDEX (0)
77 ASSERT (sparse_index_bits <= 16);
79 v = _vec_resize ((
void *) 0,
110 i = sparse_index /
BITS (
h->is_member_bitmap[0]);
111 b = sparse_index %
BITS (
h->is_member_bitmap[0]);
116 w =
h->is_member_bitmap[
i];
119 if (
PREDICT_FALSE (maybe_range == 0 && insert == 0 && w == 0))
124 return h->member_counts[
i] + 1;
127 is_member = (w & (1ULL <<
b)) != 0;
131 u8 r =
h->range_flags[d];
132 u8 is_range, is_valid_range;
137 is_member = is_range ? is_valid_range : is_member;
142 *insert = !is_member;
147 h->is_member_bitmap[
i] = w;
148 for (j =
i + 1; j <
vec_len (
h->member_counts); j++)
149 h->member_counts[j] += 1;
155 d = is_member ? d : 0;
157 return is_member + d;
173 uword b0, b1, w0, w1, v0, v1;
175 u8 is_member0, is_member1;
179 i0 = si0 /
BITS (
h->is_member_bitmap[0]);
180 i1 = si1 /
BITS (
h->is_member_bitmap[0]);
182 b0 = si0 %
BITS (
h->is_member_bitmap[0]);
183 b1 = si1 %
BITS (
h->is_member_bitmap[0]);
191 w0 =
h->is_member_bitmap[i0];
192 w1 =
h->is_member_bitmap[i1];
197 *i0_return =
h->member_counts[i0] + 1;
198 *i1_return =
h->member_counts[i1] + 1;
202 v0 = w0 & ((1ULL << b0) - 1);
203 v1 = w1 & ((1ULL << b1) - 1);
206 d0 =
h->member_counts[i0] + (v0 != 0);
207 d1 =
h->member_counts[i1] + (v1 != 0);
216 is_member0 = (w0 & (1ULL << b0)) != 0;
217 is_member1 = (w1 & (1ULL << b1)) != 0;
219 d0 = is_member0 ? d0 : 0;
220 d1 = is_member1 ? d1 : 0;
222 *i0_return = is_member0 + d0;
223 *i1_return = is_member1 + d1;
226 #define sparse_vec_free(v) vec_free(v)
228 #define sparse_vec_elt_at_index(v,i) \
229 vec_elt_at_index ((v), sparse_vec_index ((v), (i)))
231 #define sparse_vec_validate(v,i) \
237 (v) = sparse_vec_new (sizeof ((v)[0]), BITS (u16)); \
239 _i = sparse_vec_index_internal ((v), (i), \
243 vec_insert_ha ((v), 1, _i, \
244 sizeof (sparse_vec_header_t), \
#define count_trailing_zeros(x)
vnet_hw_if_output_node_runtime_t * r
#define SPARSE_VEC_IS_VALID_RANGE
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static uword sparse_vec_index_internal(void *v, uword sparse_index, uword maybe_range, u32 *insert)
static uword sparse_vec_index(void *v, uword sparse_index)
static void * vec_header(void *v, uword header_bytes)
Find a user vector header.
sll srl srl sll sra u16x4 i
static uword count_set_bits(uword x)
static void sparse_vec_index2(void *v, u32 si0, u32 si1, u32 *i0_return, u32 *i1_return)
static sparse_vec_header_t * sparse_vec_header(void *v)
#define SPARSE_VEC_IS_RANGE
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
static uword min_log2(uword x)
static uword is_pow2(uword x)
static void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)