MCPcopy Create free account
hub / github.com/F-Stack/f-stack / acl_add_ptr

Function acl_add_ptr

dpdk/lib/acl/acl_bld.c:249–303  ·  view source on GitHub ↗

* Add a pointer (ptr) to a node. */

Source from the content-addressed store, hash-verified

247 * Add a pointer (ptr) to a node.
248 */
249static int
250acl_add_ptr(struct acl_build_context *context,
251 struct rte_acl_node *node,
252 struct rte_acl_node *ptr,
253 struct rte_acl_bitset *bits)
254{
255 uint32_t n, num_ptrs;
256 struct rte_acl_ptr_set *ptrs = NULL;
257
258 /*
259 * If there's already a pointer to the same node, just add to the bitset
260 */
261 for (n = 0; n < node->num_ptrs; n++) {
262 if (node->ptrs[n].ptr != NULL) {
263 if (node->ptrs[n].ptr == ptr) {
264 acl_include(&node->ptrs[n].values, bits, -1);
265 acl_include(&node->values, bits, -1);
266 return 0;
267 }
268 }
269 }
270
271 /* if there's no room for another pointer, make room */
272 if (node->num_ptrs >= node->max_ptrs) {
273 /* add room for more pointers */
274 num_ptrs = node->max_ptrs + ACL_PTR_ALLOC;
275 ptrs = acl_build_alloc(context, num_ptrs, sizeof(*ptrs));
276
277 /* copy current points to new memory allocation */
278 if (node->ptrs != NULL) {
279 memcpy(ptrs, node->ptrs,
280 node->num_ptrs * sizeof(*ptrs));
281 acl_build_free(context, node->max_ptrs * sizeof(*ptrs),
282 node->ptrs);
283 }
284 node->ptrs = ptrs;
285 node->max_ptrs = num_ptrs;
286 }
287
288 /* Find available ptr and add a new pointer to this node */
289 for (n = node->min_add; n < node->max_ptrs; n++) {
290 if (node->ptrs[n].ptr == NULL) {
291 node->ptrs[n].ptr = ptr;
292 acl_include(&node->ptrs[n].values, bits, 0);
293 acl_include(&node->values, bits, -1);
294 if (ptr != NULL)
295 ptr->ref_count++;
296 if (node->num_ptrs <= n)
297 node->num_ptrs = n + 1;
298 return 0;
299 }
300 }
301
302 return 0;
303}
304
305/*
306 * Add a pointer for a range of values

Callers 4

acl_add_ptr_rangeFunction · 0.85
acl_copy_ptrFunction · 0.85
acl_merge_trieFunction · 0.85
acl_gen_mask_trieFunction · 0.85

Calls 4

acl_includeFunction · 0.85
acl_build_allocFunction · 0.85
acl_build_freeFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected