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

Function test21

dpdk/app/test/test_lpm.c:1487–1564  ·  view source on GitHub ↗

* rte_lpm_rcu_qsbr_add sync mode functional test. * 1 Reader and 1 writer. They cannot be in the same thread in this test. * - Create LPM which supports 1 tbl8 group at max * - Add RCU QSBR variable with sync mode to LPM * - Register a reader thread. Reader keeps looking up a specific rule. * - Writer keeps adding and deleting a specific rule with depth=28 (> 24) */

Source from the content-addressed store, hash-verified

1485 * - Writer keeps adding and deleting a specific rule with depth=28 (> 24)
1486 */
1487int32_t
1488test21(void)
1489{
1490 struct rte_lpm_config config;
1491 size_t sz;
1492 int32_t status;
1493 uint32_t i, next_hop;
1494 uint8_t depth;
1495 struct rte_lpm_rcu_config rcu_cfg = {0};
1496
1497 if (rte_lcore_count() < 2) {
1498 printf("Not enough cores for %s, expecting at least 2\n",
1499 __func__);
1500 return TEST_SKIPPED;
1501 }
1502
1503 config.max_rules = MAX_RULES;
1504 config.number_tbl8s = 1;
1505 config.flags = 0;
1506
1507 g_lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1508 TEST_LPM_ASSERT(g_lpm != NULL);
1509
1510 /* Create RCU QSBR variable */
1511 sz = rte_rcu_qsbr_get_memsize(1);
1512 g_v = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
1513 RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
1514 TEST_LPM_ASSERT(g_v != NULL);
1515
1516 status = rte_rcu_qsbr_init(g_v, 1);
1517 TEST_LPM_ASSERT(status == 0);
1518
1519 rcu_cfg.v = g_v;
1520 rcu_cfg.mode = RTE_LPM_QSBR_MODE_SYNC;
1521 /* Attach RCU QSBR to LPM table */
1522 status = rte_lpm_rcu_qsbr_add(g_lpm, &rcu_cfg);
1523 TEST_LPM_ASSERT(status == 0);
1524
1525 writer_done = 0;
1526 /* Launch reader thread */
1527 rte_eal_remote_launch(test_lpm_rcu_qsbr_reader, NULL,
1528 rte_get_next_lcore(-1, 1, 0));
1529
1530 depth = 28;
1531 next_hop = 1;
1532 status = rte_lpm_add(g_lpm, g_ip, depth, next_hop);
1533 if (status != 0) {
1534 printf("%s: Failed to add rule\n", __func__);
1535 goto error;
1536 }
1537
1538 /* Writer update */
1539 for (i = 0; i < WRITER_ITERATIONS; i++) {
1540 status = rte_lpm_delete(g_lpm, g_ip, depth);
1541 if (status != 0) {
1542 printf("%s: Failed to delete rule at iteration %d\n",
1543 __func__, i);
1544 goto error;

Callers

nothing calls this directly

Calls 14

rte_lcore_countFunction · 0.85
rte_rcu_qsbr_get_memsizeFunction · 0.85
rte_zmalloc_socketFunction · 0.85
rte_rcu_qsbr_initFunction · 0.85
rte_lpm_rcu_qsbr_addFunction · 0.85
rte_eal_remote_launchFunction · 0.85
rte_get_next_lcoreFunction · 0.85
rte_eal_mp_wait_lcoreFunction · 0.85
rte_freeFunction · 0.85
printfFunction · 0.50
rte_lpm_createFunction · 0.50
rte_lpm_addFunction · 0.50

Tested by

no test coverage detected