| 512 | } |
| 513 | |
| 514 | static int |
| 515 | acl_resolve_leaf(struct acl_build_context *context, |
| 516 | struct rte_acl_node *node_a, |
| 517 | struct rte_acl_node *node_b, |
| 518 | struct rte_acl_node **node_c) |
| 519 | { |
| 520 | uint32_t n; |
| 521 | int combined_priority = ACL_PRIORITY_EQUAL; |
| 522 | |
| 523 | for (n = 0; n < context->cfg.num_categories; n++) { |
| 524 | if (node_a->mrt->priority[n] != node_b->mrt->priority[n]) { |
| 525 | combined_priority |= (node_a->mrt->priority[n] > |
| 526 | node_b->mrt->priority[n]) ? |
| 527 | ACL_PRIORITY_NODE_A : ACL_PRIORITY_NODE_B; |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | /* |
| 532 | * if node a is higher or equal priority for all categories, |
| 533 | * then return node_a. |
| 534 | */ |
| 535 | if (combined_priority == ACL_PRIORITY_NODE_A || |
| 536 | combined_priority == ACL_PRIORITY_EQUAL) { |
| 537 | *node_c = node_a; |
| 538 | return 0; |
| 539 | } |
| 540 | |
| 541 | /* |
| 542 | * if node b is higher or equal priority for all categories, |
| 543 | * then return node_b. |
| 544 | */ |
| 545 | if (combined_priority == ACL_PRIORITY_NODE_B) { |
| 546 | *node_c = node_b; |
| 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | /* |
| 551 | * mixed priorities - create a new node with the highest priority |
| 552 | * for each category. |
| 553 | */ |
| 554 | |
| 555 | /* force new duplication. */ |
| 556 | node_a->next = NULL; |
| 557 | |
| 558 | *node_c = acl_dup_node(context, node_a); |
| 559 | for (n = 0; n < context->cfg.num_categories; n++) { |
| 560 | if ((*node_c)->mrt->priority[n] < node_b->mrt->priority[n]) { |
| 561 | (*node_c)->mrt->priority[n] = node_b->mrt->priority[n]; |
| 562 | (*node_c)->mrt->results[n] = node_b->mrt->results[n]; |
| 563 | } |
| 564 | } |
| 565 | return 0; |
| 566 | } |
| 567 | |
| 568 | /* |
| 569 | * Merge nodes A and B together, |
no test coverage detected