* Merge nodes A and B together, * returns a node that is the path for the intersection * * If match node (leaf on trie) * For each category * return node = highest priority result * * Create C as a duplicate of A to point to child intersections * If any pointers in C intersect with any in B * For each intersection * merge children * remove intersection from C pointer * add a poin
| 589 | * return C |
| 590 | */ |
| 591 | static int |
| 592 | acl_merge_trie(struct acl_build_context *context, |
| 593 | struct rte_acl_node *node_a, struct rte_acl_node *node_b, |
| 594 | uint32_t level, struct rte_acl_node **return_c) |
| 595 | { |
| 596 | uint32_t n, m, ptrs_c, ptrs_b; |
| 597 | uint32_t min_add_c, min_add_b; |
| 598 | int node_intersect_type; |
| 599 | struct rte_acl_bitset node_intersect; |
| 600 | struct rte_acl_node *node_c; |
| 601 | struct rte_acl_node *node_a_next; |
| 602 | int node_b_refs; |
| 603 | int node_a_refs; |
| 604 | |
| 605 | node_c = node_a; |
| 606 | node_a_next = node_a->next; |
| 607 | min_add_c = 0; |
| 608 | min_add_b = 0; |
| 609 | node_a_refs = node_a->num_ptrs; |
| 610 | node_b_refs = 0; |
| 611 | node_intersect_type = 0; |
| 612 | |
| 613 | /* Resolve leaf nodes (matches) */ |
| 614 | if (node_a->match_flag != 0) { |
| 615 | acl_resolve_leaf(context, node_a, node_b, return_c); |
| 616 | return 0; |
| 617 | } |
| 618 | |
| 619 | /* |
| 620 | * Create node C as a copy of node A, and do: C = merge(A,B); |
| 621 | * If node A can be used instead (A==C), then later we'll |
| 622 | * destroy C and return A. |
| 623 | */ |
| 624 | if (level > 0) |
| 625 | node_c = acl_dup_node(context, node_a); |
| 626 | |
| 627 | /* |
| 628 | * If the two node transitions intersect then merge the transitions. |
| 629 | * Check intersection for entire node (all pointers) |
| 630 | */ |
| 631 | node_intersect_type = acl_intersect_type(&node_c->values, |
| 632 | &node_b->values, |
| 633 | &node_intersect); |
| 634 | |
| 635 | if (node_intersect_type & ACL_INTERSECT) { |
| 636 | |
| 637 | min_add_b = node_b->min_add; |
| 638 | node_b->min_add = node_b->num_ptrs; |
| 639 | ptrs_b = node_b->num_ptrs; |
| 640 | |
| 641 | min_add_c = node_c->min_add; |
| 642 | node_c->min_add = node_c->num_ptrs; |
| 643 | ptrs_c = node_c->num_ptrs; |
| 644 | |
| 645 | for (n = 0; n < ptrs_c; n++) { |
| 646 | if (node_c->ptrs[n].ptr == NULL) { |
| 647 | node_a_refs--; |
| 648 | continue; |
no test coverage detected