diff options
Diffstat (limited to 'example/switch/odp_switch.c')
-rw-r--r-- | example/switch/odp_switch.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/example/switch/odp_switch.c b/example/switch/odp_switch.c index 989016fc8..f30d468f7 100644 --- a/example/switch/odp_switch.c +++ b/example/switch/odp_switch.c @@ -971,9 +971,10 @@ static void gbl_args_init(args_t *args) int main(int argc, char **argv) { odph_helper_options_t helper_options; - odph_odpthread_t thread_tbl[MAX_WORKERS]; + odph_thread_t thread_tbl[MAX_WORKERS]; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param[MAX_WORKERS]; int i, j; - int cpu; int num_workers; odp_shm_t shm; odp_cpumask_t cpumask; @@ -984,7 +985,6 @@ int main(int argc, char **argv) int if_count; odp_instance_t instance; odp_init_t init_param; - odph_odpthread_params_t thr_params; signal(SIGINT, sig_handler); @@ -1097,27 +1097,23 @@ int main(int argc, char **argv) stats = gbl_args->stats; - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; - thr_params.start = run_worker; + odph_thread_common_param_init(&thr_common); + thr_common.instance = instance; + thr_common.cpumask = &cpumask; /* Create worker threads */ - cpu = odp_cpumask_first(&cpumask); for (i = 0; i < num_workers; ++i) { - odp_cpumask_t thd_mask; - for (j = 0; j < MAX_PKTIOS; j++) gbl_args->thread[i].stats[j] = &stats[i][j]; - thr_params.arg = &gbl_args->thread[i]; - - odp_cpumask_zero(&thd_mask); - odp_cpumask_set(&thd_mask, cpu); - odph_odpthreads_create(&thread_tbl[i], &thd_mask, &thr_params); - cpu = odp_cpumask_next(&cpumask, cpu); + odph_thread_param_init(&thr_param[i]); + thr_param[i].start = run_worker; + thr_param[i].arg = &gbl_args->thread[i]; + thr_param[i].thr_type = ODP_THREAD_WORKER; } + odph_thread_create(thread_tbl, &thr_common, thr_param, num_workers); + /* Start packet receive and transmit */ for (i = 0; i < if_count; ++i) { odp_pktio_t pktio; @@ -1136,8 +1132,7 @@ int main(int argc, char **argv) odp_atomic_store_u32(&gbl_args->exit_threads, 1); /* Master thread waits for other threads to exit */ - for (i = 0; i < num_workers; ++i) - odph_odpthreads_join(&thread_tbl[i]); + odph_thread_join(thread_tbl, num_workers); /* Stop and close used pktio devices */ for (i = 0; i < if_count; i++) { |