| 571 | } |
| 572 | |
| 573 | static __rte_noinline int32_t |
| 574 | add_depth_small(struct __rte_lpm *i_lpm, uint32_t ip, uint8_t depth, |
| 575 | uint32_t next_hop) |
| 576 | { |
| 577 | #define group_idx next_hop |
| 578 | uint32_t tbl24_index, tbl24_range, tbl8_index, tbl8_group_end, i, j; |
| 579 | |
| 580 | /* Calculate the index into Table24. */ |
| 581 | tbl24_index = ip >> 8; |
| 582 | tbl24_range = depth_to_range(depth); |
| 583 | |
| 584 | for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) { |
| 585 | /* |
| 586 | * For invalid OR valid and non-extended tbl 24 entries set |
| 587 | * entry. |
| 588 | */ |
| 589 | if (!i_lpm->lpm.tbl24[i].valid || (i_lpm->lpm.tbl24[i].valid_group == 0 && |
| 590 | i_lpm->lpm.tbl24[i].depth <= depth)) { |
| 591 | |
| 592 | struct rte_lpm_tbl_entry new_tbl24_entry = { |
| 593 | .next_hop = next_hop, |
| 594 | .valid = VALID, |
| 595 | .valid_group = 0, |
| 596 | .depth = depth, |
| 597 | }; |
| 598 | |
| 599 | /* Setting tbl24 entry in one go to avoid race |
| 600 | * conditions |
| 601 | */ |
| 602 | __atomic_store(&i_lpm->lpm.tbl24[i], &new_tbl24_entry, |
| 603 | __ATOMIC_RELEASE); |
| 604 | |
| 605 | continue; |
| 606 | } |
| 607 | |
| 608 | if (i_lpm->lpm.tbl24[i].valid_group == 1) { |
| 609 | /* If tbl24 entry is valid and extended calculate the |
| 610 | * index into tbl8. |
| 611 | */ |
| 612 | tbl8_index = i_lpm->lpm.tbl24[i].group_idx * |
| 613 | RTE_LPM_TBL8_GROUP_NUM_ENTRIES; |
| 614 | tbl8_group_end = tbl8_index + |
| 615 | RTE_LPM_TBL8_GROUP_NUM_ENTRIES; |
| 616 | |
| 617 | for (j = tbl8_index; j < tbl8_group_end; j++) { |
| 618 | if (!i_lpm->lpm.tbl8[j].valid || |
| 619 | i_lpm->lpm.tbl8[j].depth <= depth) { |
| 620 | struct rte_lpm_tbl_entry |
| 621 | new_tbl8_entry = { |
| 622 | .valid = VALID, |
| 623 | .valid_group = VALID, |
| 624 | .depth = depth, |
| 625 | .next_hop = next_hop, |
| 626 | }; |
| 627 | |
| 628 | /* |
| 629 | * Setting tbl8 entry in one go to avoid |
| 630 | * race conditions |
no test coverage detected