* rte_lpm_rcu_qsbr_add DQ mode functional test. * Reader and writer are in the same thread in this test. * - Create LPM which supports 1 tbl8 group at max * - Add RCU QSBR variable to LPM * - Add a rule with depth=28 (> 24) * - Register a reader thread (not a real thread) * - Reader lookup existing rule * - Writer delete the rule * - Reader lookup the rule * - Writer re-add the ru
| 1358 | * - Reader lookup the rule |
| 1359 | */ |
| 1360 | int32_t |
| 1361 | test20(void) |
| 1362 | { |
| 1363 | struct rte_lpm *lpm = NULL; |
| 1364 | struct rte_lpm_config config; |
| 1365 | size_t sz; |
| 1366 | struct rte_rcu_qsbr *qsv; |
| 1367 | int32_t status; |
| 1368 | uint32_t ip, next_hop, next_hop_return; |
| 1369 | uint8_t depth; |
| 1370 | struct rte_lpm_rcu_config rcu_cfg = {0}; |
| 1371 | |
| 1372 | config.max_rules = MAX_RULES; |
| 1373 | config.number_tbl8s = 1; |
| 1374 | config.flags = 0; |
| 1375 | |
| 1376 | lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config); |
| 1377 | TEST_LPM_ASSERT(lpm != NULL); |
| 1378 | |
| 1379 | /* Create RCU QSBR variable */ |
| 1380 | sz = rte_rcu_qsbr_get_memsize(1); |
| 1381 | qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz, |
| 1382 | RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); |
| 1383 | TEST_LPM_ASSERT(qsv != NULL); |
| 1384 | |
| 1385 | status = rte_rcu_qsbr_init(qsv, 1); |
| 1386 | TEST_LPM_ASSERT(status == 0); |
| 1387 | |
| 1388 | rcu_cfg.v = qsv; |
| 1389 | rcu_cfg.mode = RTE_LPM_QSBR_MODE_DQ; |
| 1390 | /* Attach RCU QSBR to LPM table */ |
| 1391 | status = rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg); |
| 1392 | TEST_LPM_ASSERT(status == 0); |
| 1393 | |
| 1394 | ip = RTE_IPV4(192, 0, 2, 100); |
| 1395 | depth = 28; |
| 1396 | next_hop = 1; |
| 1397 | status = rte_lpm_add(lpm, ip, depth, next_hop); |
| 1398 | TEST_LPM_ASSERT(status == 0); |
| 1399 | TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group); |
| 1400 | |
| 1401 | /* Register pseudo reader */ |
| 1402 | status = rte_rcu_qsbr_thread_register(qsv, 0); |
| 1403 | TEST_LPM_ASSERT(status == 0); |
| 1404 | rte_rcu_qsbr_thread_online(qsv, 0); |
| 1405 | |
| 1406 | status = rte_lpm_lookup(lpm, ip, &next_hop_return); |
| 1407 | TEST_LPM_ASSERT(status == 0); |
| 1408 | TEST_LPM_ASSERT(next_hop_return == next_hop); |
| 1409 | |
| 1410 | /* Writer update */ |
| 1411 | status = rte_lpm_delete(lpm, ip, depth); |
| 1412 | TEST_LPM_ASSERT(status == 0); |
| 1413 | TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid); |
| 1414 | |
| 1415 | status = rte_lpm_lookup(lpm, ip, &next_hop_return); |
| 1416 | TEST_LPM_ASSERT(status != 0); |
| 1417 |
nothing calls this directly
no test coverage detected