MCPcopy Create free account
hub / github.com/F-Stack/f-stack / add_step

Function add_step

dpdk/lib/lpm/rte_lpm6.c:647–805  ·  view source on GitHub ↗

* Partially adds a new route to the data structure (tbl24+tbl8s). * It returns 0 on success, a negative number on failure, or 1 if * the process needs to be continued by calling the function again. */

Source from the content-addressed store, hash-verified

645 * the process needs to be continued by calling the function again.
646 */
647static inline int
648add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl,
649 uint32_t tbl_ind, struct rte_lpm6_tbl_entry **next_tbl,
650 uint32_t *next_tbl_ind, uint8_t *ip, uint8_t bytes,
651 uint8_t first_byte, uint8_t depth, uint32_t next_hop,
652 uint8_t is_new_rule)
653{
654 uint32_t entry_ind, tbl_range, tbl8_group_start, tbl8_group_end, i;
655 uint32_t tbl8_gindex;
656 uint8_t bits_covered;
657 int ret;
658
659 /*
660 * Calculate index to the table based on the number and position
661 * of the bytes being inspected in this step.
662 */
663 entry_ind = get_bitshift(ip, first_byte, bytes);
664
665 /* Number of bits covered in this step */
666 bits_covered = (uint8_t)((bytes+first_byte-1)*BYTE_SIZE);
667
668 /*
669 * If depth if smaller than this number (ie this is the last step)
670 * expand the rule across the relevant positions in the table.
671 */
672 if (depth <= bits_covered) {
673 tbl_range = 1 << (bits_covered - depth);
674
675 for (i = entry_ind; i < (entry_ind + tbl_range); i++) {
676 if (!tbl[i].valid || (tbl[i].ext_entry == 0 &&
677 tbl[i].depth <= depth)) {
678
679 struct rte_lpm6_tbl_entry new_tbl_entry = {
680 .next_hop = next_hop,
681 .depth = depth,
682 .valid = VALID,
683 .valid_group = VALID,
684 .ext_entry = 0,
685 };
686
687 tbl[i] = new_tbl_entry;
688
689 } else if (tbl[i].ext_entry == 1) {
690
691 /*
692 * If tbl entry is valid and extended calculate the index
693 * into next tbl8 and expand the rule across the data structure.
694 */
695 tbl8_gindex = tbl[i].lpm6_tbl8_gindex *
696 RTE_LPM6_TBL8_GROUP_NUM_ENTRIES;
697 expand_rule(lpm, tbl8_gindex, depth, depth,
698 next_hop, VALID);
699 }
700 }
701
702 /* update tbl8 rule reference counter */
703 if (tbl_ind != TBL24_IND && is_new_rule)
704 lpm->tbl8_hdrs[tbl_ind].ref_cnt++;

Callers 1

rte_lpm6_addFunction · 0.70

Calls 5

memsetFunction · 0.85
get_bitshiftFunction · 0.70
expand_ruleFunction · 0.70
tbl8_getFunction · 0.70
init_tbl8_headerFunction · 0.70

Tested by

no test coverage detected