| 643 | } |
| 644 | |
| 645 | static __rte_noinline int32_t |
| 646 | add_depth_big(struct __rte_lpm *i_lpm, uint32_t ip_masked, uint8_t depth, |
| 647 | uint32_t next_hop) |
| 648 | { |
| 649 | #define group_idx next_hop |
| 650 | uint32_t tbl24_index; |
| 651 | int32_t tbl8_group_index, tbl8_group_start, tbl8_group_end, tbl8_index, |
| 652 | tbl8_range, i; |
| 653 | |
| 654 | tbl24_index = (ip_masked >> 8); |
| 655 | tbl8_range = depth_to_range(depth); |
| 656 | |
| 657 | if (!i_lpm->lpm.tbl24[tbl24_index].valid) { |
| 658 | /* Search for a free tbl8 group. */ |
| 659 | tbl8_group_index = tbl8_alloc(i_lpm); |
| 660 | |
| 661 | /* Check tbl8 allocation was successful. */ |
| 662 | if (tbl8_group_index < 0) { |
| 663 | return tbl8_group_index; |
| 664 | } |
| 665 | |
| 666 | /* Find index into tbl8 and range. */ |
| 667 | tbl8_index = (tbl8_group_index * |
| 668 | RTE_LPM_TBL8_GROUP_NUM_ENTRIES) + |
| 669 | (ip_masked & 0xFF); |
| 670 | |
| 671 | /* Set tbl8 entry. */ |
| 672 | for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) { |
| 673 | struct rte_lpm_tbl_entry new_tbl8_entry = { |
| 674 | .valid = VALID, |
| 675 | .depth = depth, |
| 676 | .valid_group = i_lpm->lpm.tbl8[i].valid_group, |
| 677 | .next_hop = next_hop, |
| 678 | }; |
| 679 | __atomic_store(&i_lpm->lpm.tbl8[i], &new_tbl8_entry, |
| 680 | __ATOMIC_RELAXED); |
| 681 | } |
| 682 | |
| 683 | /* |
| 684 | * Update tbl24 entry to point to new tbl8 entry. Note: The |
| 685 | * ext_flag and tbl8_index need to be updated simultaneously, |
| 686 | * so assign whole structure in one go |
| 687 | */ |
| 688 | |
| 689 | struct rte_lpm_tbl_entry new_tbl24_entry = { |
| 690 | .group_idx = tbl8_group_index, |
| 691 | .valid = VALID, |
| 692 | .valid_group = 1, |
| 693 | .depth = 0, |
| 694 | }; |
| 695 | |
| 696 | /* The tbl24 entry must be written only after the |
| 697 | * tbl8 entries are written. |
| 698 | */ |
| 699 | __atomic_store(&i_lpm->lpm.tbl24[tbl24_index], &new_tbl24_entry, |
| 700 | __ATOMIC_RELEASE); |
| 701 | |
| 702 | } /* If valid entry but not extended calculate the index into Table8. */ |
no test coverage detected