Lines Matching refs:node

166 				   const struct lpm_trie_node *node,  in longest_prefix_match()  argument
169 u32 limit = min(node->prefixlen, key->prefixlen); in longest_prefix_match()
181 u64 diff = be64_to_cpu(*(__be64 *)node->data ^ in longest_prefix_match()
194 u32 diff = be32_to_cpu(*(__be32 *)&node->data[i] ^ in longest_prefix_match()
206 u16 diff = be16_to_cpu(*(__be16 *)&node->data[i] ^ in longest_prefix_match()
218 prefixlen += 8 - fls(node->data[i] ^ key->data[i]); in longest_prefix_match()
231 struct lpm_trie_node *node, *found = NULL; in trie_lookup_elem() local
239 for (node = rcu_dereference_check(trie->root, rcu_read_lock_bh_held()); in trie_lookup_elem()
240 node;) { in trie_lookup_elem()
248 matchlen = longest_prefix_match(trie, node, key); in trie_lookup_elem()
250 found = node; in trie_lookup_elem()
258 if (matchlen < node->prefixlen) in trie_lookup_elem()
264 if (!(node->flags & LPM_TREE_NODE_FLAG_IM)) in trie_lookup_elem()
265 found = node; in trie_lookup_elem()
271 next_bit = extract_bit(key->data, node->prefixlen); in trie_lookup_elem()
272 node = rcu_dereference_check(node->child[next_bit], in trie_lookup_elem()
285 struct lpm_trie_node *node; in lpm_trie_node_alloc() local
291 node = bpf_map_kmalloc_node(&trie->map, size, GFP_NOWAIT | __GFP_NOWARN, in lpm_trie_node_alloc()
293 if (!node) in lpm_trie_node_alloc()
296 node->flags = 0; in lpm_trie_node_alloc()
299 memcpy(node->data + trie->data_size, value, in lpm_trie_node_alloc()
302 return node; in lpm_trie_node_alloc()
310 struct lpm_trie_node *node, *im_node = NULL, *new_node = NULL; in trie_update_elem() local
353 while ((node = rcu_dereference_protected(*slot, in trie_update_elem()
355 matchlen = longest_prefix_match(trie, node, key); in trie_update_elem()
357 if (node->prefixlen != matchlen || in trie_update_elem()
358 node->prefixlen == key->prefixlen || in trie_update_elem()
359 node->prefixlen == trie->max_prefixlen) in trie_update_elem()
362 next_bit = extract_bit(key->data, node->prefixlen); in trie_update_elem()
363 slot = &node->child[next_bit]; in trie_update_elem()
369 if (!node) { in trie_update_elem()
377 if (node->prefixlen == matchlen) { in trie_update_elem()
378 new_node->child[0] = node->child[0]; in trie_update_elem()
379 new_node->child[1] = node->child[1]; in trie_update_elem()
381 if (!(node->flags & LPM_TREE_NODE_FLAG_IM)) in trie_update_elem()
385 kfree_rcu(node, rcu); in trie_update_elem()
394 next_bit = extract_bit(node->data, matchlen); in trie_update_elem()
395 rcu_assign_pointer(new_node->child[next_bit], node); in trie_update_elem()
408 memcpy(im_node->data, node->data, trie->data_size); in trie_update_elem()
412 rcu_assign_pointer(im_node->child[0], node); in trie_update_elem()
416 rcu_assign_pointer(im_node->child[1], node); in trie_update_elem()
442 struct lpm_trie_node *node, *parent; in trie_delete_elem() local
462 while ((node = rcu_dereference_protected( in trie_delete_elem()
464 matchlen = longest_prefix_match(trie, node, key); in trie_delete_elem()
466 if (node->prefixlen != matchlen || in trie_delete_elem()
467 node->prefixlen == key->prefixlen) in trie_delete_elem()
470 parent = node; in trie_delete_elem()
472 next_bit = extract_bit(key->data, node->prefixlen); in trie_delete_elem()
473 trim = &node->child[next_bit]; in trie_delete_elem()
476 if (!node || node->prefixlen != key->prefixlen || in trie_delete_elem()
477 node->prefixlen != matchlen || in trie_delete_elem()
478 (node->flags & LPM_TREE_NODE_FLAG_IM)) { in trie_delete_elem()
488 if (rcu_access_pointer(node->child[0]) && in trie_delete_elem()
489 rcu_access_pointer(node->child[1])) { in trie_delete_elem()
490 node->flags |= LPM_TREE_NODE_FLAG_IM; in trie_delete_elem()
502 !node->child[0] && !node->child[1]) { in trie_delete_elem()
503 if (node == rcu_access_pointer(parent->child[0])) in trie_delete_elem()
510 kfree_rcu(node, rcu); in trie_delete_elem()
518 if (node->child[0]) in trie_delete_elem()
519 rcu_assign_pointer(*trim, rcu_access_pointer(node->child[0])); in trie_delete_elem()
520 else if (node->child[1]) in trie_delete_elem()
521 rcu_assign_pointer(*trim, rcu_access_pointer(node->child[1])); in trie_delete_elem()
524 kfree_rcu(node, rcu); in trie_delete_elem()
580 struct lpm_trie_node *node; in trie_free() local
591 node = rcu_dereference_protected(*slot, 1); in trie_free()
592 if (!node) in trie_free()
595 if (rcu_access_pointer(node->child[0])) { in trie_free()
596 slot = &node->child[0]; in trie_free()
600 if (rcu_access_pointer(node->child[1])) { in trie_free()
601 slot = &node->child[1]; in trie_free()
605 kfree(node); in trie_free()
617 struct lpm_trie_node *node, *next_node = NULL, *parent, *search_root; in trie_get_next_key() local
652 for (node = search_root; node;) { in trie_get_next_key()
653 node_stack[++stack_ptr] = node; in trie_get_next_key()
654 matchlen = longest_prefix_match(trie, node, key); in trie_get_next_key()
655 if (node->prefixlen != matchlen || in trie_get_next_key()
656 node->prefixlen == key->prefixlen) in trie_get_next_key()
659 next_bit = extract_bit(key->data, node->prefixlen); in trie_get_next_key()
660 node = rcu_dereference(node->child[next_bit]); in trie_get_next_key()
662 if (!node || node->prefixlen != key->prefixlen || in trie_get_next_key()
663 (node->flags & LPM_TREE_NODE_FLAG_IM)) in trie_get_next_key()
669 node = node_stack[stack_ptr]; in trie_get_next_key()
672 if (rcu_dereference(parent->child[0]) == node) { in trie_get_next_key()
682 node = parent; in trie_get_next_key()
694 for (node = search_root; node;) { in trie_get_next_key()
695 if (node->flags & LPM_TREE_NODE_FLAG_IM) { in trie_get_next_key()
696 node = rcu_dereference(node->child[0]); in trie_get_next_key()
698 next_node = node; in trie_get_next_key()
699 node = rcu_dereference(node->child[0]); in trie_get_next_key()
700 if (!node) in trie_get_next_key()
701 node = rcu_dereference(next_node->child[1]); in trie_get_next_key()