src/dpdk/lib/librte_lpm/rte_lpm6.c
static inline int
simulate_add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl,
		struct rte_lpm6_tbl_entry **next_tbl, const uint8_t *ip,
		uint8_t bytes, uint8_t first_byte, uint8_t depth,
		uint32_t *need_tbl_nb)
{
	uint32_t entry_ind;
	uint8_t bits_covered;
	uint32_t next_tbl_ind;

	/*
	 * Calculate index to the table based on the number and position
	 * of the bytes being inspected in this step.
	 */
	entry_ind = get_bitshift(ip, first_byte, bytes);

	/* Number of bits covered in this step */
	bits_covered = (uint8_t)((bytes+first_byte-1)*BYTE_SIZE);

	if (depth <= bits_covered) {
		*need_tbl_nb = 0;
		return 0;
	}

	if (tbl[entry_ind].valid == 0 || tbl[entry_ind].ext_entry == 0) {
		/* from this point on a new table is needed on each level
		 * that is not covered yet
		 */
		depth -= bits_covered;
		uint32_t cnt = depth >> 3; /* depth / BYTE_SIZE */
		if (depth & 7) /* 0b00000111 */
			/* if depth % 8 > 0 then one more table is needed
			 * for those last bits
			 */
			cnt++;

		*need_tbl_nb = cnt;
		return 0;
	}

	next_tbl_ind = tbl[entry_ind].lpm6_tbl8_gindex;
	*next_tbl = &(lpm->tbl8[next_tbl_ind *
		RTE_LPM6_TBL8_GROUP_NUM_ENTRIES]);
	*need_tbl_nb = 0;
	return 1;
}
/*
 * 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.
 */
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.
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 .
static inline int
simulate_add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl,
		struct rte_lpm6_tbl_entry **next_tbl, const uint8_t *ip,
		uint8_t bytes, uint8_t first_byte, uint8_t depth,
		uint32_t *need_tbl_nb)
{
	uint32_t entry_ind;
	uint8_t bits_covered;
	uint32_t next_tbl_ind;
	entry_ind = get_bitshift(ip, first_byte, bytes);
	bits_covered = (uint8_t)((bytes+first_byte-1)*BYTE_SIZE);
	if (depth <= bits_covered) {
		*need_tbl_nb = 0;
		return 0;
	}
	if (tbl[entry_ind].valid == 0 || tbl[entry_ind].ext_entry == 0) {
		depth -= bits_covered;
		uint32_t cnt = depth >> 3; 
		if (depth & 7) 
			cnt++;
		*need_tbl_nb = cnt;
		return 0;
	}
	next_tbl_ind = tbl[entry_ind].lpm6_tbl8_gindex;
	*next_tbl = &(lpm->tbl8[next_tbl_ind *
		RTE_LPM6_TBL8_GROUP_NUM_ENTRIES]);
	*need_tbl_nb = 0;
	return 1;
}
static inline int simulate_add_step ( struct rte_lpm6 * lpm , struct rte_lpm6_tbl_entry * tbl , struct rte_lpm6_tbl_entry * * next_tbl , const uint8_t * ip , uint8_t bytes , uint8_t first_byte , uint8_t depth , uint32_t * need_tbl_nb ) { uint32_t entry_ind ; uint8_t bits_covered ; uint32_t next_tbl_ind ; entry_ind = get_bitshift ( ip , first_byte , bytes ) ; bits_covered = ( uint8_t ) ( ( bytes + first_byte - 1 ) * BYTE_SIZE ) ; if ( depth <= bits_covered ) { * need_tbl_nb = 0 ; return 0 ; } if ( tbl [ entry_ind ] . valid == 0 || tbl [ entry_ind ] . ext_entry == 0 ) { depth -= bits_covered ; uint32_t cnt = depth >> 3 ; if ( depth & 7 ) cnt ++ ; * need_tbl_nb = cnt ; return 0 ; } next_tbl_ind = tbl [ entry_ind ] . lpm6_tbl8_gindex ; * next_tbl = & ( lpm -> tbl8 [ next_tbl_ind * RTE_LPM6_TBL8_GROUP_NUM_ENTRIES ] ) ; * need_tbl_nb = 0 ; return 1 ; }
Simulate adding a new route to the LPM counting number
 of new tables that will be needed
Simulate adding a new route to the LPM counting number of new tables that will be needed
/*
	 * Calculate index to the table based on the number and position
	 * of the bytes being inspected in this step.
	 */ /* Number of bits covered in this step */ /* from this point on a new table is needed on each level
		 * that is not covered yet
		 */ /* depth / BYTE_SIZE */ /* 0b00000111 */ /* if depth % 8 > 0 then one more table is needed
			 * for those last bits
			 */