src/dpdk/lib/librte_lpm/rte_lpm6.c
static int
simulate_add(struct rte_lpm6 *lpm, const uint8_t *masked_ip, uint8_t depth)
{
	struct rte_lpm6_tbl_entry *tbl;
	struct rte_lpm6_tbl_entry *tbl_next = NULL;
	int ret, i;

	/* number of new tables needed for a step */
	uint32_t need_tbl_nb;
	/* total number of new tables needed */
	uint32_t total_need_tbl_nb;

	/* Inspect the first three bytes through tbl24 on the first step. */
	ret = simulate_add_step(lpm, lpm->tbl24, &tbl_next, masked_ip,
		ADD_FIRST_BYTE, 1, depth, &need_tbl_nb);
	total_need_tbl_nb = need_tbl_nb;
	/*
	 * Inspect one by one the rest of the bytes until
	 * the process is completed.
	 */
	for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && ret == 1; i++) {
		tbl = tbl_next;
		ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1,
			(uint8_t)(i + 1), depth, &need_tbl_nb);
		total_need_tbl_nb += need_tbl_nb;
	}

	if (tbl8_available(lpm) < total_need_tbl_nb)
		/* not enough tbl8 to add a rule */
		return -ENOSPC;

	return 0;
}
/*
 * Simulate adding a route to LPM
 *
 *	Returns:
 *    0 on success
 *    -ENOSPC not enough tbl8 left
 */
Simulate adding a route to LPM
Returns:
0 on success
-ENOSPC not enough tbl8 left
Simulate adding a route to LPM Returns : 0 on success - ENOSPC not enough tbl8 left
static int
simulate_add(struct rte_lpm6 *lpm, const uint8_t *masked_ip, uint8_t depth)
{
	struct rte_lpm6_tbl_entry *tbl;
	struct rte_lpm6_tbl_entry *tbl_next = NULL;
	int ret, i;
	uint32_t need_tbl_nb;
	uint32_t total_need_tbl_nb;
	ret = simulate_add_step(lpm, lpm->tbl24, &tbl_next, masked_ip,
		ADD_FIRST_BYTE, 1, depth, &need_tbl_nb);
	total_need_tbl_nb = need_tbl_nb;
	for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && ret == 1; i++) {
		tbl = tbl_next;
		ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1,
			(uint8_t)(i + 1), depth, &need_tbl_nb);
		total_need_tbl_nb += need_tbl_nb;
	}
	if (tbl8_available(lpm) < total_need_tbl_nb)
		return -ENOSPC;
	return 0;
}
static int simulate_add ( struct rte_lpm6 * lpm , const uint8_t * masked_ip , uint8_t depth ) { struct rte_lpm6_tbl_entry * tbl ; struct rte_lpm6_tbl_entry * tbl_next = NULL ; int ret , i ; uint32_t need_tbl_nb ; uint32_t total_need_tbl_nb ; ret = simulate_add_step ( lpm , lpm -> tbl24 , & tbl_next , masked_ip , ADD_FIRST_BYTE , 1 , depth , & need_tbl_nb ) ; total_need_tbl_nb = need_tbl_nb ; for ( i = ADD_FIRST_BYTE ; i < RTE_LPM6_IPV6_ADDR_SIZE && ret == 1 ; i ++ ) { tbl = tbl_next ; ret = simulate_add_step ( lpm , tbl , & tbl_next , masked_ip , 1 , ( uint8_t ) ( i + 1 ) , depth , & need_tbl_nb ) ; total_need_tbl_nb += need_tbl_nb ; } if ( tbl8_available ( lpm ) < total_need_tbl_nb ) return - ENOSPC ; return 0 ; }
Simulate adding a route to LPM
      Returns:
    0 on success
    -ENOSPC not enough tbl8 left
Simulate adding a route to LPM Returns : 0 on success - ENOSPC not enough tbl8 left
/* number of new tables needed for a step */ /* total number of new tables needed */ /* Inspect the first three bytes through tbl24 on the first step. */ /*
	 * Inspect one by one the rest of the bytes until
	 * the process is completed.
	 */ /* not enough tbl8 to add a rule */