- __atomic_fetch_add(&gwrites,
- 2 * NUM_LDEPTH_ROUTE_ENTRIES * RCU_ITERATIONS,
- __ATOMIC_RELAXED);
-
- return 0;
-}
-
-/*
- * Functional test:
- * 2 writers, rest are readers
- */
-static int
-test_lpm_rcu_perf_multi_writer(void)
-{
- struct rte_lpm_config config;
- size_t sz;
- unsigned int i;
- uint16_t core_id;
- struct rte_lpm_rcu_config rcu_cfg = {0};
-
- if (rte_lcore_count() < 3) {
- printf("Not enough cores for lpm_rcu_perf_autotest, expecting at least 3\n");
- return TEST_SKIPPED;
- }
-
- num_cores = 0;
- RTE_LCORE_FOREACH_SLAVE(core_id) {
- enabled_core_ids[num_cores] = core_id;
- num_cores++;
- }
-
- printf("\nPerf test: 2 writers, %d readers, RCU integration enabled\n",
- num_cores - 2);
-
- /* Create LPM table */
- config.max_rules = NUM_LDEPTH_ROUTE_ENTRIES;
- config.number_tbl8s = NUM_LDEPTH_ROUTE_ENTRIES;
- config.flags = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
- TEST_LPM_ASSERT(lpm != NULL);
-
- /* Init RCU variable */
- sz = rte_rcu_qsbr_get_memsize(num_cores);
- rv = (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz,
- RTE_CACHE_LINE_SIZE);
- rte_rcu_qsbr_init(rv, num_cores);
-
- rcu_cfg.v = rv;
- /* Assign the RCU variable to LPM */
- if (rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg) != 0) {
- printf("RCU variable assignment failed\n");
- goto error;
- }
-
- writer_done = 0;
- __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
- __atomic_store_n(&gwrites, 0, __ATOMIC_RELAXED);
-
- __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
-
- /* Launch reader threads */
- for (i = 2; i < num_cores; i++)
- rte_eal_remote_launch(test_lpm_rcu_qsbr_reader, NULL,
- enabled_core_ids[i]);
-
- /* Launch writer threads */
- for (i = 0; i < 2; i++)
- rte_eal_remote_launch(test_lpm_rcu_qsbr_writer,
- (void *)(uintptr_t)i,
- enabled_core_ids[i]);
-
- /* Wait for writer threads */
- for (i = 0; i < 2; i++)
- if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
- goto error;
-
- printf("Total LPM Adds: %d\n",
- 2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
- printf("Total LPM Deletes: %d\n",
- 2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
- printf("Average LPM Add/Del: %"PRIu64" cycles\n",
- __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) /
- __atomic_load_n(&gwrites, __ATOMIC_RELAXED)
- );
-
- /* Wait and check return value from reader threads */
- writer_done = 1;
- for (i = 2; i < num_cores; i++)
- if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
- goto error;
-
- rte_lpm_free(lpm);
- rte_free(rv);
- lpm = NULL;
- rv = NULL;
-
- /* Test without RCU integration */
- printf("\nPerf test: 2 writers, %d readers, RCU integration disabled\n",
- num_cores - 2);
-
- /* Create LPM table */
- config.max_rules = NUM_LDEPTH_ROUTE_ENTRIES;
- config.number_tbl8s = NUM_LDEPTH_ROUTE_ENTRIES;
- config.flags = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
- TEST_LPM_ASSERT(lpm != NULL);
-
- writer_done = 0;
- __atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
- __atomic_store_n(&gwrites, 0, __ATOMIC_RELAXED);
- __atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
-
- /* Launch reader threads */
- for (i = 2; i < num_cores; i++)
- rte_eal_remote_launch(test_lpm_reader, NULL,
- enabled_core_ids[i]);
-
- /* Launch writer threads */
- for (i = 0; i < 2; i++)
- rte_eal_remote_launch(test_lpm_rcu_qsbr_writer,
- (void *)(uintptr_t)i,
- enabled_core_ids[i]);
-
- /* Wait for writer threads */
- for (i = 0; i < 2; i++)
- if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
- goto error;
-
- printf("Total LPM Adds: %d\n",
- 2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
- printf("Total LPM Deletes: %d\n",
- 2 * ITERATIONS * NUM_LDEPTH_ROUTE_ENTRIES);
- printf("Average LPM Add/Del: %"PRIu64" cycles\n",
- __atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED) /
- __atomic_load_n(&gwrites, __ATOMIC_RELAXED)
- );
-
- writer_done = 1;
- /* Wait and check return value from reader threads */
- for (i = 2; i < num_cores; i++)
- if (rte_eal_wait_lcore(enabled_core_ids[i]) < 0)
- goto error;
-
- rte_lpm_free(lpm);