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

Function rte_lpm_lookup

dpdk/lib/lpm/rte_lpm.h:277–309  ·  view source on GitHub ↗

* Lookup an IP into the LPM table. * * @param lpm * LPM object handle * @param ip * IP to be looked up in the LPM table * @param next_hop * Next hop of the most specific rule found for IP (valid on lookup hit only) * @return * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit */

Source from the content-addressed store, hash-verified

275 * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
276 */
277static inline int
278rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
279{
280 unsigned tbl24_index = (ip >> 8);
281 uint32_t tbl_entry;
282 const uint32_t *ptbl;
283
284 /* DEBUG: Check user input arguments. */
285 RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (next_hop == NULL)), -EINVAL);
286
287 /* Copy tbl24 entry */
288 ptbl = (const uint32_t *)(&lpm->tbl24[tbl24_index]);
289 tbl_entry = *ptbl;
290
291 /* Memory ordering is not required in lookup. Because dataflow
292 * dependency exists, compiler or HW won't be able to re-order
293 * the operations.
294 */
295 /* Copy tbl8 entry (only if needed) */
296 if (unlikely((tbl_entry & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
297 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
298
299 unsigned tbl8_index = (uint8_t)ip +
300 (((uint32_t)tbl_entry & 0x00FFFFFF) *
301 RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
302
303 ptbl = (const uint32_t *)&lpm->tbl8[tbl8_index];
304 tbl_entry = *ptbl;
305 }
306
307 *next_hop = ((uint32_t)tbl_entry & 0x00FFFFFF);
308 return (tbl_entry & RTE_LPM_LOOKUP_SUCCESS) ? 0 : -ENOENT;
309}
310
311/**
312 * Lookup multiple IP addresses in an LPM table. This may be implemented as a

Callers 15

rte_lpm_lookupx4Function · 0.70
rte_table_lpm_lookupFunction · 0.50
test5Function · 0.50
test6Function · 0.50
test7Function · 0.50
test8Function · 0.50
test9Function · 0.50
test10Function · 0.50
test11Function · 0.50

Calls

no outgoing calls

Tested by 15

test5Function · 0.40
test6Function · 0.40
test7Function · 0.40
test8Function · 0.40
test9Function · 0.40
test10Function · 0.40
test11Function · 0.40
test12Function · 0.40
test13Function · 0.40
test14Function · 0.40
test17Function · 0.40
test20Function · 0.40