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

Function test8

dpdk/app/test/test_lpm.c:364–442  ·  view source on GitHub ↗

* Use rte_lpm_add to add rules which effect only the second half of the lpm * table. Use all possible depths ranging from 1..32. Set the next hop = to the * depth. Check lookup hit for on every add and check for lookup miss on the * first half of the lpm table after each add. Finally delete all rules going * backwards (i.e. from depth = 32 ..1) and carry out a lookup after each * delete. The

Source from the content-addressed store, hash-verified

362 * previous depth value (i.e. depth -1).
363 */
364int32_t
365test8(void)
366{
367 xmm_t ipx4;
368 uint32_t hop[4];
369 struct rte_lpm *lpm = NULL;
370 struct rte_lpm_config config;
371
372 config.max_rules = MAX_RULES;
373 config.number_tbl8s = NUMBER_TBL8S;
374 config.flags = 0;
375 uint32_t ip1 = RTE_IPV4(127, 255, 255, 255), ip2 = RTE_IPV4(128, 0, 0, 0);
376 uint32_t next_hop_add, next_hop_return;
377 uint8_t depth;
378 int32_t status = 0;
379
380 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
381 TEST_LPM_ASSERT(lpm != NULL);
382
383 /* Loop with rte_lpm_add. */
384 for (depth = 1; depth <= 32; depth++) {
385 /* Let the next_hop_add value = depth. Just for change. */
386 next_hop_add = depth;
387
388 status = rte_lpm_add(lpm, ip2, depth, next_hop_add);
389 TEST_LPM_ASSERT(status == 0);
390
391 /* Check IP in first half of tbl24 which should be empty. */
392 status = rte_lpm_lookup(lpm, ip1, &next_hop_return);
393 TEST_LPM_ASSERT(status == -ENOENT);
394
395 status = rte_lpm_lookup(lpm, ip2, &next_hop_return);
396 TEST_LPM_ASSERT((status == 0) &&
397 (next_hop_return == next_hop_add));
398
399 ipx4 = vect_set_epi32(ip2, ip1, ip2, ip1);
400 rte_lpm_lookupx4(lpm, ipx4, hop, UINT32_MAX);
401 TEST_LPM_ASSERT(hop[0] == UINT32_MAX);
402 TEST_LPM_ASSERT(hop[1] == next_hop_add);
403 TEST_LPM_ASSERT(hop[2] == UINT32_MAX);
404 TEST_LPM_ASSERT(hop[3] == next_hop_add);
405 }
406
407 /* Loop with rte_lpm_delete. */
408 for (depth = 32; depth >= 1; depth--) {
409 next_hop_add = (uint8_t) (depth - 1);
410
411 status = rte_lpm_delete(lpm, ip2, depth);
412 TEST_LPM_ASSERT(status == 0);
413
414 status = rte_lpm_lookup(lpm, ip2, &next_hop_return);
415
416 if (depth != 1) {
417 TEST_LPM_ASSERT((status == 0) &&
418 (next_hop_return == next_hop_add));
419 } else {
420 TEST_LPM_ASSERT(status == -ENOENT);
421 }

Callers

nothing calls this directly

Calls 7

vect_set_epi32Function · 0.85
rte_lpm_createFunction · 0.50
rte_lpm_addFunction · 0.50
rte_lpm_lookupFunction · 0.50
rte_lpm_lookupx4Function · 0.50
rte_lpm_deleteFunction · 0.50
rte_lpm_freeFunction · 0.50

Tested by

no test coverage detected