* Simulate adding a new route to the LPM counting number * of new tables that will be needed * * It returns 0 on success, or 1 if * the process needs to be continued by calling the function again. */
| 593 | * the process needs to be continued by calling the function again. |
| 594 | */ |
| 595 | static inline int |
| 596 | simulate_add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl, |
| 597 | struct rte_lpm6_tbl_entry **next_tbl, const uint8_t *ip, |
| 598 | uint8_t bytes, uint8_t first_byte, uint8_t depth, |
| 599 | uint32_t *need_tbl_nb) |
| 600 | { |
| 601 | uint32_t entry_ind; |
| 602 | uint8_t bits_covered; |
| 603 | uint32_t next_tbl_ind; |
| 604 | |
| 605 | /* |
| 606 | * Calculate index to the table based on the number and position |
| 607 | * of the bytes being inspected in this step. |
| 608 | */ |
| 609 | entry_ind = get_bitshift(ip, first_byte, bytes); |
| 610 | |
| 611 | /* Number of bits covered in this step */ |
| 612 | bits_covered = (uint8_t)((bytes+first_byte-1)*BYTE_SIZE); |
| 613 | |
| 614 | if (depth <= bits_covered) { |
| 615 | *need_tbl_nb = 0; |
| 616 | return 0; |
| 617 | } |
| 618 | |
| 619 | if (tbl[entry_ind].valid == 0 || tbl[entry_ind].ext_entry == 0) { |
| 620 | /* from this point on a new table is needed on each level |
| 621 | * that is not covered yet |
| 622 | */ |
| 623 | depth -= bits_covered; |
| 624 | uint32_t cnt = depth >> 3; /* depth / BYTE_SIZE */ |
| 625 | if (depth & 7) /* 0b00000111 */ |
| 626 | /* if depth % 8 > 0 then one more table is needed |
| 627 | * for those last bits |
| 628 | */ |
| 629 | cnt++; |
| 630 | |
| 631 | *need_tbl_nb = cnt; |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | next_tbl_ind = tbl[entry_ind].lpm6_tbl8_gindex; |
| 636 | *next_tbl = &(lpm->tbl8[next_tbl_ind * |
| 637 | RTE_LPM6_TBL8_GROUP_NUM_ENTRIES]); |
| 638 | *need_tbl_nb = 0; |
| 639 | return 1; |
| 640 | } |
| 641 | |
| 642 | /* |
| 643 | * Partially adds a new route to the data structure (tbl24+tbl8s). |
no test coverage detected