153a3b7e8SJerin Jacob /* SPDX-License-Identifier: BSD-3-Clause 253a3b7e8SJerin Jacob * Copyright(c) 2017 Cavium, Inc 3ffbae86fSJerin Jacob */ 4ffbae86fSJerin Jacob 5ffbae86fSJerin Jacob #include "test_perf_common.h" 6ffbae86fSJerin Jacob 741c219e6SJerin Jacob int 841c219e6SJerin Jacob perf_test_result(struct evt_test *test, struct evt_options *opt) 941c219e6SJerin Jacob { 1041c219e6SJerin Jacob RTE_SET_USED(opt); 116b1a14a8SPavan Nikhilesh int i; 126b1a14a8SPavan Nikhilesh uint64_t total = 0; 1341c219e6SJerin Jacob struct test_perf *t = evt_test_priv(test); 1441c219e6SJerin Jacob 156b1a14a8SPavan Nikhilesh printf("Packet distribution across worker cores :\n"); 166b1a14a8SPavan Nikhilesh for (i = 0; i < t->nb_workers; i++) 176b1a14a8SPavan Nikhilesh total += t->worker[i].processed_pkts; 186b1a14a8SPavan Nikhilesh for (i = 0; i < t->nb_workers; i++) 196b1a14a8SPavan Nikhilesh printf("Worker %d packets: "CLGRN"%"PRIx64" "CLNRM"percentage:" 206b1a14a8SPavan Nikhilesh CLGRN" %3.2f\n"CLNRM, i, 216b1a14a8SPavan Nikhilesh t->worker[i].processed_pkts, 226b1a14a8SPavan Nikhilesh (((double)t->worker[i].processed_pkts)/total) 236b1a14a8SPavan Nikhilesh * 100); 246b1a14a8SPavan Nikhilesh 2541c219e6SJerin Jacob return t->result; 2641c219e6SJerin Jacob } 2741c219e6SJerin Jacob 289d3aeb18SJerin Jacob static inline int 299d3aeb18SJerin Jacob perf_producer(void *arg) 309d3aeb18SJerin Jacob { 319a618803SPavan Nikhilesh int i; 329d3aeb18SJerin Jacob struct prod_data *p = arg; 339d3aeb18SJerin Jacob struct test_perf *t = p->t; 349d3aeb18SJerin Jacob struct evt_options *opt = t->opt; 359d3aeb18SJerin Jacob const uint8_t dev_id = p->dev_id; 369d3aeb18SJerin Jacob const uint8_t port = p->port_id; 379d3aeb18SJerin Jacob struct rte_mempool *pool = t->pool; 389d3aeb18SJerin Jacob const uint64_t nb_pkts = t->nb_pkts; 399d3aeb18SJerin Jacob const uint32_t nb_flows = t->nb_flows; 409d3aeb18SJerin Jacob uint32_t flow_counter = 0; 419d3aeb18SJerin Jacob uint64_t count = 0; 429a618803SPavan Nikhilesh struct perf_elt *m[BURST_SIZE + 1] = {NULL}; 439d3aeb18SJerin Jacob struct rte_event ev; 449d3aeb18SJerin Jacob 459d3aeb18SJerin Jacob if (opt->verbose_level > 1) 469d3aeb18SJerin Jacob printf("%s(): lcore %d dev_id %d port=%d queue %d\n", __func__, 479d3aeb18SJerin Jacob rte_lcore_id(), dev_id, port, p->queue_id); 489d3aeb18SJerin Jacob 499d3aeb18SJerin Jacob ev.event = 0; 509d3aeb18SJerin Jacob ev.op = RTE_EVENT_OP_NEW; 519d3aeb18SJerin Jacob ev.queue_id = p->queue_id; 529d3aeb18SJerin Jacob ev.sched_type = t->opt->sched_type_list[0]; 539d3aeb18SJerin Jacob ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL; 549d3aeb18SJerin Jacob ev.event_type = RTE_EVENT_TYPE_CPU; 559d3aeb18SJerin Jacob ev.sub_event_type = 0; /* stage 0 */ 569d3aeb18SJerin Jacob 579d3aeb18SJerin Jacob while (count < nb_pkts && t->done == false) { 589a618803SPavan Nikhilesh if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0) 599d3aeb18SJerin Jacob continue; 609a618803SPavan Nikhilesh for (i = 0; i < BURST_SIZE; i++) { 619d3aeb18SJerin Jacob ev.flow_id = flow_counter++ % nb_flows; 629a618803SPavan Nikhilesh ev.event_ptr = m[i]; 639a618803SPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles(); 649a618803SPavan Nikhilesh while (rte_event_enqueue_burst(dev_id, 659a618803SPavan Nikhilesh port, &ev, 1) != 1) { 669d3aeb18SJerin Jacob if (t->done) 679d3aeb18SJerin Jacob break; 689d3aeb18SJerin Jacob rte_pause(); 699a618803SPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles(); 709d3aeb18SJerin Jacob } 719a618803SPavan Nikhilesh } 729a618803SPavan Nikhilesh count += BURST_SIZE; 739d3aeb18SJerin Jacob } 749d3aeb18SJerin Jacob 759d3aeb18SJerin Jacob return 0; 769d3aeb18SJerin Jacob } 779d3aeb18SJerin Jacob 78d008f20bSPavan Nikhilesh static inline int 79d008f20bSPavan Nikhilesh perf_event_timer_producer(void *arg) 80d008f20bSPavan Nikhilesh { 819a618803SPavan Nikhilesh int i; 82d008f20bSPavan Nikhilesh struct prod_data *p = arg; 83d008f20bSPavan Nikhilesh struct test_perf *t = p->t; 84d008f20bSPavan Nikhilesh struct evt_options *opt = t->opt; 85d008f20bSPavan Nikhilesh uint32_t flow_counter = 0; 86d008f20bSPavan Nikhilesh uint64_t count = 0; 87d008f20bSPavan Nikhilesh uint64_t arm_latency = 0; 88d008f20bSPavan Nikhilesh const uint8_t nb_timer_adptrs = opt->nb_timer_adptrs; 89d008f20bSPavan Nikhilesh const uint32_t nb_flows = t->nb_flows; 90d008f20bSPavan Nikhilesh const uint64_t nb_timers = opt->nb_timers; 91d008f20bSPavan Nikhilesh struct rte_mempool *pool = t->pool; 929a618803SPavan Nikhilesh struct perf_elt *m[BURST_SIZE + 1] = {NULL}; 93d008f20bSPavan Nikhilesh struct rte_event_timer_adapter **adptr = t->timer_adptr; 9452553263SPavan Nikhilesh struct rte_event_timer tim; 95d008f20bSPavan Nikhilesh uint64_t timeout_ticks = opt->expiry_nsec / opt->timer_tick_nsec; 96d008f20bSPavan Nikhilesh 9752553263SPavan Nikhilesh memset(&tim, 0, sizeof(struct rte_event_timer)); 98d008f20bSPavan Nikhilesh timeout_ticks = opt->optm_timer_tick_nsec ? 99d008f20bSPavan Nikhilesh (timeout_ticks * opt->timer_tick_nsec) 100d008f20bSPavan Nikhilesh / opt->optm_timer_tick_nsec : timeout_ticks; 101d008f20bSPavan Nikhilesh timeout_ticks += timeout_ticks ? 0 : 1; 10252553263SPavan Nikhilesh tim.ev.event_type = RTE_EVENT_TYPE_TIMER; 10352553263SPavan Nikhilesh tim.ev.op = RTE_EVENT_OP_NEW; 10452553263SPavan Nikhilesh tim.ev.sched_type = t->opt->sched_type_list[0]; 10552553263SPavan Nikhilesh tim.ev.queue_id = p->queue_id; 10652553263SPavan Nikhilesh tim.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL; 10752553263SPavan Nikhilesh tim.state = RTE_EVENT_TIMER_NOT_ARMED; 10852553263SPavan Nikhilesh tim.timeout_ticks = timeout_ticks; 109d008f20bSPavan Nikhilesh 110d008f20bSPavan Nikhilesh if (opt->verbose_level > 1) 111d008f20bSPavan Nikhilesh printf("%s(): lcore %d\n", __func__, rte_lcore_id()); 112d008f20bSPavan Nikhilesh 113d008f20bSPavan Nikhilesh while (count < nb_timers && t->done == false) { 1149a618803SPavan Nikhilesh if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0) 115d008f20bSPavan Nikhilesh continue; 1169a618803SPavan Nikhilesh for (i = 0; i < BURST_SIZE; i++) { 1179a618803SPavan Nikhilesh rte_prefetch0(m[i + 1]); 1189a618803SPavan Nikhilesh m[i]->tim = tim; 1199a618803SPavan Nikhilesh m[i]->tim.ev.flow_id = flow_counter++ % nb_flows; 1209a618803SPavan Nikhilesh m[i]->tim.ev.event_ptr = m[i]; 1219a618803SPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles(); 122d008f20bSPavan Nikhilesh while (rte_event_timer_arm_burst( 123d008f20bSPavan Nikhilesh adptr[flow_counter % nb_timer_adptrs], 1249a618803SPavan Nikhilesh (struct rte_event_timer **)&m[i], 1) != 1) { 125d008f20bSPavan Nikhilesh if (t->done) 126d008f20bSPavan Nikhilesh break; 1279a618803SPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles(); 128d008f20bSPavan Nikhilesh } 1299a618803SPavan Nikhilesh arm_latency += rte_get_timer_cycles() - m[i]->timestamp; 1309a618803SPavan Nikhilesh } 1319a618803SPavan Nikhilesh count += BURST_SIZE; 132d008f20bSPavan Nikhilesh } 133d008f20bSPavan Nikhilesh fflush(stdout); 134d008f20bSPavan Nikhilesh rte_delay_ms(1000); 135d008f20bSPavan Nikhilesh printf("%s(): lcore %d Average event timer arm latency = %.3f us\n", 136d008f20bSPavan Nikhilesh __func__, rte_lcore_id(), (float)(arm_latency / count) / 137d008f20bSPavan Nikhilesh (rte_get_timer_hz() / 1000000)); 138d008f20bSPavan Nikhilesh return 0; 139d008f20bSPavan Nikhilesh } 140d008f20bSPavan Nikhilesh 14117b22d0bSPavan Nikhilesh static inline int 14217b22d0bSPavan Nikhilesh perf_event_timer_producer_burst(void *arg) 14317b22d0bSPavan Nikhilesh { 14417b22d0bSPavan Nikhilesh int i; 14517b22d0bSPavan Nikhilesh struct prod_data *p = arg; 14617b22d0bSPavan Nikhilesh struct test_perf *t = p->t; 14717b22d0bSPavan Nikhilesh struct evt_options *opt = t->opt; 14817b22d0bSPavan Nikhilesh uint32_t flow_counter = 0; 14917b22d0bSPavan Nikhilesh uint64_t count = 0; 15017b22d0bSPavan Nikhilesh uint64_t arm_latency = 0; 15117b22d0bSPavan Nikhilesh const uint8_t nb_timer_adptrs = opt->nb_timer_adptrs; 15217b22d0bSPavan Nikhilesh const uint32_t nb_flows = t->nb_flows; 15317b22d0bSPavan Nikhilesh const uint64_t nb_timers = opt->nb_timers; 15417b22d0bSPavan Nikhilesh struct rte_mempool *pool = t->pool; 15517b22d0bSPavan Nikhilesh struct perf_elt *m[BURST_SIZE + 1] = {NULL}; 15617b22d0bSPavan Nikhilesh struct rte_event_timer_adapter **adptr = t->timer_adptr; 15752553263SPavan Nikhilesh struct rte_event_timer tim; 15817b22d0bSPavan Nikhilesh uint64_t timeout_ticks = opt->expiry_nsec / opt->timer_tick_nsec; 15917b22d0bSPavan Nikhilesh 16052553263SPavan Nikhilesh memset(&tim, 0, sizeof(struct rte_event_timer)); 16117b22d0bSPavan Nikhilesh timeout_ticks = opt->optm_timer_tick_nsec ? 16217b22d0bSPavan Nikhilesh (timeout_ticks * opt->timer_tick_nsec) 16317b22d0bSPavan Nikhilesh / opt->optm_timer_tick_nsec : timeout_ticks; 16417b22d0bSPavan Nikhilesh timeout_ticks += timeout_ticks ? 0 : 1; 16552553263SPavan Nikhilesh tim.ev.event_type = RTE_EVENT_TYPE_TIMER; 16652553263SPavan Nikhilesh tim.ev.op = RTE_EVENT_OP_NEW; 16752553263SPavan Nikhilesh tim.ev.sched_type = t->opt->sched_type_list[0]; 16852553263SPavan Nikhilesh tim.ev.queue_id = p->queue_id; 16952553263SPavan Nikhilesh tim.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL; 17052553263SPavan Nikhilesh tim.state = RTE_EVENT_TIMER_NOT_ARMED; 17152553263SPavan Nikhilesh tim.timeout_ticks = timeout_ticks; 17217b22d0bSPavan Nikhilesh 17317b22d0bSPavan Nikhilesh if (opt->verbose_level > 1) 17417b22d0bSPavan Nikhilesh printf("%s(): lcore %d\n", __func__, rte_lcore_id()); 17517b22d0bSPavan Nikhilesh 17617b22d0bSPavan Nikhilesh while (count < nb_timers && t->done == false) { 17717b22d0bSPavan Nikhilesh if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0) 17817b22d0bSPavan Nikhilesh continue; 17917b22d0bSPavan Nikhilesh for (i = 0; i < BURST_SIZE; i++) { 18017b22d0bSPavan Nikhilesh rte_prefetch0(m[i + 1]); 18117b22d0bSPavan Nikhilesh m[i]->tim = tim; 18217b22d0bSPavan Nikhilesh m[i]->tim.ev.flow_id = flow_counter++ % nb_flows; 18317b22d0bSPavan Nikhilesh m[i]->tim.ev.event_ptr = m[i]; 18417b22d0bSPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles(); 18517b22d0bSPavan Nikhilesh } 18617b22d0bSPavan Nikhilesh rte_event_timer_arm_tmo_tick_burst( 18717b22d0bSPavan Nikhilesh adptr[flow_counter % nb_timer_adptrs], 18817b22d0bSPavan Nikhilesh (struct rte_event_timer **)m, 18917b22d0bSPavan Nikhilesh tim.timeout_ticks, 19017b22d0bSPavan Nikhilesh BURST_SIZE); 19117b22d0bSPavan Nikhilesh arm_latency += rte_get_timer_cycles() - m[i - 1]->timestamp; 19217b22d0bSPavan Nikhilesh count += BURST_SIZE; 19317b22d0bSPavan Nikhilesh } 19417b22d0bSPavan Nikhilesh fflush(stdout); 19517b22d0bSPavan Nikhilesh rte_delay_ms(1000); 19617b22d0bSPavan Nikhilesh printf("%s(): lcore %d Average event timer arm latency = %.3f us\n", 19717b22d0bSPavan Nikhilesh __func__, rte_lcore_id(), (float)(arm_latency / count) / 19817b22d0bSPavan Nikhilesh (rte_get_timer_hz() / 1000000)); 19917b22d0bSPavan Nikhilesh return 0; 20017b22d0bSPavan Nikhilesh } 20117b22d0bSPavan Nikhilesh 20259f697e3SPavan Nikhilesh static int 20359f697e3SPavan Nikhilesh perf_producer_wrapper(void *arg) 20459f697e3SPavan Nikhilesh { 20559f697e3SPavan Nikhilesh struct prod_data *p = arg; 20659f697e3SPavan Nikhilesh struct test_perf *t = p->t; 20759f697e3SPavan Nikhilesh /* Launch the producer function only in case of synthetic producer. */ 20859f697e3SPavan Nikhilesh if (t->opt->prod_type == EVT_PROD_TYPE_SYNT) 20959f697e3SPavan Nikhilesh return perf_producer(arg); 21017b22d0bSPavan Nikhilesh else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR && 21117b22d0bSPavan Nikhilesh !t->opt->timdev_use_burst) 212d008f20bSPavan Nikhilesh return perf_event_timer_producer(arg); 21317b22d0bSPavan Nikhilesh else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR && 21417b22d0bSPavan Nikhilesh t->opt->timdev_use_burst) 21517b22d0bSPavan Nikhilesh return perf_event_timer_producer_burst(arg); 21659f697e3SPavan Nikhilesh return 0; 21759f697e3SPavan Nikhilesh } 21859f697e3SPavan Nikhilesh 2199d3aeb18SJerin Jacob static inline uint64_t 2209d3aeb18SJerin Jacob processed_pkts(struct test_perf *t) 2219d3aeb18SJerin Jacob { 2229d3aeb18SJerin Jacob uint8_t i; 2239d3aeb18SJerin Jacob uint64_t total = 0; 2249d3aeb18SJerin Jacob 2259d3aeb18SJerin Jacob rte_smp_rmb(); 2269d3aeb18SJerin Jacob for (i = 0; i < t->nb_workers; i++) 2279d3aeb18SJerin Jacob total += t->worker[i].processed_pkts; 2289d3aeb18SJerin Jacob 2299d3aeb18SJerin Jacob return total; 2309d3aeb18SJerin Jacob } 2319d3aeb18SJerin Jacob 2329d3aeb18SJerin Jacob static inline uint64_t 2339d3aeb18SJerin Jacob total_latency(struct test_perf *t) 2349d3aeb18SJerin Jacob { 2359d3aeb18SJerin Jacob uint8_t i; 2369d3aeb18SJerin Jacob uint64_t total = 0; 2379d3aeb18SJerin Jacob 2389d3aeb18SJerin Jacob rte_smp_rmb(); 2399d3aeb18SJerin Jacob for (i = 0; i < t->nb_workers; i++) 2409d3aeb18SJerin Jacob total += t->worker[i].latency; 2419d3aeb18SJerin Jacob 2429d3aeb18SJerin Jacob return total; 2439d3aeb18SJerin Jacob } 2449d3aeb18SJerin Jacob 2459d3aeb18SJerin Jacob 2469d3aeb18SJerin Jacob int 2479d3aeb18SJerin Jacob perf_launch_lcores(struct evt_test *test, struct evt_options *opt, 2489d3aeb18SJerin Jacob int (*worker)(void *)) 2499d3aeb18SJerin Jacob { 2509d3aeb18SJerin Jacob int ret, lcore_id; 2519d3aeb18SJerin Jacob struct test_perf *t = evt_test_priv(test); 2529d3aeb18SJerin Jacob 2539d3aeb18SJerin Jacob int port_idx = 0; 2549d3aeb18SJerin Jacob /* launch workers */ 2559d3aeb18SJerin Jacob RTE_LCORE_FOREACH_SLAVE(lcore_id) { 2569d3aeb18SJerin Jacob if (!(opt->wlcores[lcore_id])) 2579d3aeb18SJerin Jacob continue; 2589d3aeb18SJerin Jacob 2599d3aeb18SJerin Jacob ret = rte_eal_remote_launch(worker, 2609d3aeb18SJerin Jacob &t->worker[port_idx], lcore_id); 2619d3aeb18SJerin Jacob if (ret) { 2629d3aeb18SJerin Jacob evt_err("failed to launch worker %d", lcore_id); 2639d3aeb18SJerin Jacob return ret; 2649d3aeb18SJerin Jacob } 2659d3aeb18SJerin Jacob port_idx++; 2669d3aeb18SJerin Jacob } 2679d3aeb18SJerin Jacob 2689d3aeb18SJerin Jacob /* launch producers */ 2699d3aeb18SJerin Jacob RTE_LCORE_FOREACH_SLAVE(lcore_id) { 2709d3aeb18SJerin Jacob if (!(opt->plcores[lcore_id])) 2719d3aeb18SJerin Jacob continue; 2729d3aeb18SJerin Jacob 27359f697e3SPavan Nikhilesh ret = rte_eal_remote_launch(perf_producer_wrapper, 27459f697e3SPavan Nikhilesh &t->prod[port_idx], lcore_id); 2759d3aeb18SJerin Jacob if (ret) { 2769d3aeb18SJerin Jacob evt_err("failed to launch perf_producer %d", lcore_id); 2779d3aeb18SJerin Jacob return ret; 2789d3aeb18SJerin Jacob } 2799d3aeb18SJerin Jacob port_idx++; 2809d3aeb18SJerin Jacob } 2819d3aeb18SJerin Jacob 282d008f20bSPavan Nikhilesh const uint64_t total_pkts = t->outstand_pkts; 2839d3aeb18SJerin Jacob 2849d3aeb18SJerin Jacob uint64_t dead_lock_cycles = rte_get_timer_cycles(); 2859d3aeb18SJerin Jacob int64_t dead_lock_remaining = total_pkts; 2869d3aeb18SJerin Jacob const uint64_t dead_lock_sample = rte_get_timer_hz() * 5; 2879d3aeb18SJerin Jacob 2889d3aeb18SJerin Jacob uint64_t perf_cycles = rte_get_timer_cycles(); 2899d3aeb18SJerin Jacob int64_t perf_remaining = total_pkts; 2909d3aeb18SJerin Jacob const uint64_t perf_sample = rte_get_timer_hz(); 2919d3aeb18SJerin Jacob 2929d3aeb18SJerin Jacob static float total_mpps; 2939d3aeb18SJerin Jacob static uint64_t samples; 2949d3aeb18SJerin Jacob 2959d3aeb18SJerin Jacob const uint64_t freq_mhz = rte_get_timer_hz() / 1000000; 2969d3aeb18SJerin Jacob int64_t remaining = t->outstand_pkts - processed_pkts(t); 2979d3aeb18SJerin Jacob 2989d3aeb18SJerin Jacob while (t->done == false) { 2999d3aeb18SJerin Jacob const uint64_t new_cycles = rte_get_timer_cycles(); 3009d3aeb18SJerin Jacob 3019d3aeb18SJerin Jacob if ((new_cycles - perf_cycles) > perf_sample) { 3029d3aeb18SJerin Jacob const uint64_t latency = total_latency(t); 3039d3aeb18SJerin Jacob const uint64_t pkts = processed_pkts(t); 3049d3aeb18SJerin Jacob 3059d3aeb18SJerin Jacob remaining = t->outstand_pkts - pkts; 3069d3aeb18SJerin Jacob float mpps = (float)(perf_remaining-remaining)/1000000; 3079d3aeb18SJerin Jacob 3089d3aeb18SJerin Jacob perf_remaining = remaining; 3099d3aeb18SJerin Jacob perf_cycles = new_cycles; 3109d3aeb18SJerin Jacob total_mpps += mpps; 3119d3aeb18SJerin Jacob ++samples; 31204716352SJerin Jacob if (opt->fwd_latency && pkts > 0) { 3139d3aeb18SJerin Jacob printf(CLGRN"\r%.3f mpps avg %.3f mpps [avg fwd latency %.3f us] "CLNRM, 3149d3aeb18SJerin Jacob mpps, total_mpps/samples, 3159d3aeb18SJerin Jacob (float)(latency/pkts)/freq_mhz); 3169d3aeb18SJerin Jacob } else { 3179d3aeb18SJerin Jacob printf(CLGRN"\r%.3f mpps avg %.3f mpps"CLNRM, 3189d3aeb18SJerin Jacob mpps, total_mpps/samples); 3199d3aeb18SJerin Jacob } 3209d3aeb18SJerin Jacob fflush(stdout); 3219d3aeb18SJerin Jacob 3229d3aeb18SJerin Jacob if (remaining <= 0) { 3239d3aeb18SJerin Jacob t->result = EVT_TEST_SUCCESS; 324d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_SYNT || 325d008f20bSPavan Nikhilesh opt->prod_type == 326d008f20bSPavan Nikhilesh EVT_PROD_TYPE_EVENT_TIMER_ADPTR) { 32759f697e3SPavan Nikhilesh t->done = true; 3289d3aeb18SJerin Jacob rte_smp_wmb(); 3299d3aeb18SJerin Jacob break; 3309d3aeb18SJerin Jacob } 3319d3aeb18SJerin Jacob } 33259f697e3SPavan Nikhilesh } 3339d3aeb18SJerin Jacob 33459f697e3SPavan Nikhilesh if (new_cycles - dead_lock_cycles > dead_lock_sample && 33547303784SErik Gabriel Carrillo (opt->prod_type == EVT_PROD_TYPE_SYNT || 33647303784SErik Gabriel Carrillo opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR)) { 3379d3aeb18SJerin Jacob remaining = t->outstand_pkts - processed_pkts(t); 3389d3aeb18SJerin Jacob if (dead_lock_remaining == remaining) { 3399d3aeb18SJerin Jacob rte_event_dev_dump(opt->dev_id, stdout); 3409d3aeb18SJerin Jacob evt_err("No schedules for seconds, deadlock"); 3419d3aeb18SJerin Jacob t->done = true; 3429d3aeb18SJerin Jacob rte_smp_wmb(); 3439d3aeb18SJerin Jacob break; 3449d3aeb18SJerin Jacob } 3459d3aeb18SJerin Jacob dead_lock_remaining = remaining; 3469d3aeb18SJerin Jacob dead_lock_cycles = new_cycles; 3479d3aeb18SJerin Jacob } 3489d3aeb18SJerin Jacob } 3499d3aeb18SJerin Jacob printf("\n"); 3509d3aeb18SJerin Jacob return 0; 3519d3aeb18SJerin Jacob } 3529d3aeb18SJerin Jacob 3533617aae5SPavan Nikhilesh static int 3543617aae5SPavan Nikhilesh perf_event_rx_adapter_setup(struct evt_options *opt, uint8_t stride, 3553617aae5SPavan Nikhilesh struct rte_event_port_conf prod_conf) 3563617aae5SPavan Nikhilesh { 3573617aae5SPavan Nikhilesh int ret = 0; 3583617aae5SPavan Nikhilesh uint16_t prod; 3593617aae5SPavan Nikhilesh struct rte_event_eth_rx_adapter_queue_conf queue_conf; 3603617aae5SPavan Nikhilesh 3613617aae5SPavan Nikhilesh memset(&queue_conf, 0, 3623617aae5SPavan Nikhilesh sizeof(struct rte_event_eth_rx_adapter_queue_conf)); 3633617aae5SPavan Nikhilesh queue_conf.ev.sched_type = opt->sched_type_list[0]; 3648728ccf3SThomas Monjalon RTE_ETH_FOREACH_DEV(prod) { 3653617aae5SPavan Nikhilesh uint32_t cap; 3663617aae5SPavan Nikhilesh 3673617aae5SPavan Nikhilesh ret = rte_event_eth_rx_adapter_caps_get(opt->dev_id, 3683617aae5SPavan Nikhilesh prod, &cap); 3693617aae5SPavan Nikhilesh if (ret) { 3703617aae5SPavan Nikhilesh evt_err("failed to get event rx adapter[%d]" 3713617aae5SPavan Nikhilesh " capabilities", 3723617aae5SPavan Nikhilesh opt->dev_id); 3733617aae5SPavan Nikhilesh return ret; 3743617aae5SPavan Nikhilesh } 3753617aae5SPavan Nikhilesh queue_conf.ev.queue_id = prod * stride; 3763617aae5SPavan Nikhilesh ret = rte_event_eth_rx_adapter_create(prod, opt->dev_id, 3773617aae5SPavan Nikhilesh &prod_conf); 3783617aae5SPavan Nikhilesh if (ret) { 3793617aae5SPavan Nikhilesh evt_err("failed to create rx adapter[%d]", prod); 3803617aae5SPavan Nikhilesh return ret; 3813617aae5SPavan Nikhilesh } 3823617aae5SPavan Nikhilesh ret = rte_event_eth_rx_adapter_queue_add(prod, prod, -1, 3833617aae5SPavan Nikhilesh &queue_conf); 3843617aae5SPavan Nikhilesh if (ret) { 3853617aae5SPavan Nikhilesh evt_err("failed to add rx queues to adapter[%d]", prod); 3863617aae5SPavan Nikhilesh return ret; 3873617aae5SPavan Nikhilesh } 3883617aae5SPavan Nikhilesh 389b0333c55SPavan Nikhilesh if (!(cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT)) { 390b0333c55SPavan Nikhilesh uint32_t service_id; 391b0333c55SPavan Nikhilesh 392b0333c55SPavan Nikhilesh rte_event_eth_rx_adapter_service_id_get(prod, 393b0333c55SPavan Nikhilesh &service_id); 394b0333c55SPavan Nikhilesh ret = evt_service_setup(service_id); 395b0333c55SPavan Nikhilesh if (ret) { 396b0333c55SPavan Nikhilesh evt_err("Failed to setup service core" 397b0333c55SPavan Nikhilesh " for Rx adapter\n"); 398b0333c55SPavan Nikhilesh return ret; 399b0333c55SPavan Nikhilesh } 400b0333c55SPavan Nikhilesh } 4013617aae5SPavan Nikhilesh } 4023617aae5SPavan Nikhilesh 4033617aae5SPavan Nikhilesh return ret; 4043617aae5SPavan Nikhilesh } 4053617aae5SPavan Nikhilesh 406d008f20bSPavan Nikhilesh static int 407d008f20bSPavan Nikhilesh perf_event_timer_adapter_setup(struct test_perf *t) 408d008f20bSPavan Nikhilesh { 409d008f20bSPavan Nikhilesh int i; 410d008f20bSPavan Nikhilesh int ret; 411d008f20bSPavan Nikhilesh struct rte_event_timer_adapter_info adapter_info; 412d008f20bSPavan Nikhilesh struct rte_event_timer_adapter *wl; 413d008f20bSPavan Nikhilesh uint8_t nb_producers = evt_nr_active_lcores(t->opt->plcores); 414d008f20bSPavan Nikhilesh uint8_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES; 415d008f20bSPavan Nikhilesh 416d008f20bSPavan Nikhilesh if (nb_producers == 1) 417d008f20bSPavan Nikhilesh flags |= RTE_EVENT_TIMER_ADAPTER_F_SP_PUT; 418d008f20bSPavan Nikhilesh 419d008f20bSPavan Nikhilesh for (i = 0; i < t->opt->nb_timer_adptrs; i++) { 420d008f20bSPavan Nikhilesh struct rte_event_timer_adapter_conf config = { 421d008f20bSPavan Nikhilesh .event_dev_id = t->opt->dev_id, 422d008f20bSPavan Nikhilesh .timer_adapter_id = i, 423d008f20bSPavan Nikhilesh .timer_tick_ns = t->opt->timer_tick_nsec, 424d008f20bSPavan Nikhilesh .max_tmo_ns = t->opt->max_tmo_nsec, 425c13b1ad7SPavan Nikhilesh .nb_timers = t->opt->pool_sz, 426d008f20bSPavan Nikhilesh .flags = flags, 427d008f20bSPavan Nikhilesh }; 428d008f20bSPavan Nikhilesh 429d008f20bSPavan Nikhilesh wl = rte_event_timer_adapter_create(&config); 430d008f20bSPavan Nikhilesh if (wl == NULL) { 431d008f20bSPavan Nikhilesh evt_err("failed to create event timer ring %d", i); 432d008f20bSPavan Nikhilesh return rte_errno; 433d008f20bSPavan Nikhilesh } 434d008f20bSPavan Nikhilesh 435d008f20bSPavan Nikhilesh memset(&adapter_info, 0, 436d008f20bSPavan Nikhilesh sizeof(struct rte_event_timer_adapter_info)); 437d008f20bSPavan Nikhilesh rte_event_timer_adapter_get_info(wl, &adapter_info); 438d008f20bSPavan Nikhilesh t->opt->optm_timer_tick_nsec = adapter_info.min_resolution_ns; 439d008f20bSPavan Nikhilesh 440d008f20bSPavan Nikhilesh if (!(adapter_info.caps & 441d008f20bSPavan Nikhilesh RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT)) { 442d008f20bSPavan Nikhilesh uint32_t service_id; 443d008f20bSPavan Nikhilesh 444d008f20bSPavan Nikhilesh rte_event_timer_adapter_service_id_get(wl, 445d008f20bSPavan Nikhilesh &service_id); 446d008f20bSPavan Nikhilesh ret = evt_service_setup(service_id); 447d008f20bSPavan Nikhilesh if (ret) { 448d008f20bSPavan Nikhilesh evt_err("Failed to setup service core" 449d008f20bSPavan Nikhilesh " for timer adapter\n"); 450d008f20bSPavan Nikhilesh return ret; 451d008f20bSPavan Nikhilesh } 452d008f20bSPavan Nikhilesh rte_service_runstate_set(service_id, 1); 453d008f20bSPavan Nikhilesh } 454d008f20bSPavan Nikhilesh t->timer_adptr[i] = wl; 455d008f20bSPavan Nikhilesh } 456d008f20bSPavan Nikhilesh return 0; 457d008f20bSPavan Nikhilesh } 458d008f20bSPavan Nikhilesh 459272de067SJerin Jacob int 46084a7513dSJerin Jacob perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt, 461535c630cSPavan Nikhilesh uint8_t stride, uint8_t nb_queues, 462535c630cSPavan Nikhilesh const struct rte_event_port_conf *port_conf) 46384a7513dSJerin Jacob { 46484a7513dSJerin Jacob struct test_perf *t = evt_test_priv(test); 4653617aae5SPavan Nikhilesh uint16_t port, prod; 46684a7513dSJerin Jacob int ret = -1; 46784a7513dSJerin Jacob 46884a7513dSJerin Jacob /* setup one port per worker, linking to all queues */ 46984a7513dSJerin Jacob for (port = 0; port < evt_nr_active_lcores(opt->wlcores); 47084a7513dSJerin Jacob port++) { 47184a7513dSJerin Jacob struct worker_data *w = &t->worker[port]; 47284a7513dSJerin Jacob 47384a7513dSJerin Jacob w->dev_id = opt->dev_id; 47484a7513dSJerin Jacob w->port_id = port; 47584a7513dSJerin Jacob w->t = t; 47684a7513dSJerin Jacob w->processed_pkts = 0; 47784a7513dSJerin Jacob w->latency = 0; 47884a7513dSJerin Jacob 479535c630cSPavan Nikhilesh ret = rte_event_port_setup(opt->dev_id, port, port_conf); 48084a7513dSJerin Jacob if (ret) { 48184a7513dSJerin Jacob evt_err("failed to setup port %d", port); 48284a7513dSJerin Jacob return ret; 48384a7513dSJerin Jacob } 48484a7513dSJerin Jacob 48584a7513dSJerin Jacob ret = rte_event_port_link(opt->dev_id, port, NULL, NULL, 0); 48684a7513dSJerin Jacob if (ret != nb_queues) { 48784a7513dSJerin Jacob evt_err("failed to link all queues to port %d", port); 48884a7513dSJerin Jacob return -EINVAL; 48984a7513dSJerin Jacob } 49084a7513dSJerin Jacob } 49184a7513dSJerin Jacob 49284a7513dSJerin Jacob /* port for producers, no links */ 4933617aae5SPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) { 4943617aae5SPavan Nikhilesh for ( ; port < perf_nb_event_ports(opt); port++) { 4953617aae5SPavan Nikhilesh struct prod_data *p = &t->prod[port]; 4963617aae5SPavan Nikhilesh p->t = t; 4973617aae5SPavan Nikhilesh } 4983617aae5SPavan Nikhilesh 499535c630cSPavan Nikhilesh ret = perf_event_rx_adapter_setup(opt, stride, *port_conf); 5003617aae5SPavan Nikhilesh if (ret) 5013617aae5SPavan Nikhilesh return ret; 502d008f20bSPavan Nikhilesh } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) { 503d008f20bSPavan Nikhilesh prod = 0; 504d008f20bSPavan Nikhilesh for ( ; port < perf_nb_event_ports(opt); port++) { 505d008f20bSPavan Nikhilesh struct prod_data *p = &t->prod[port]; 506d008f20bSPavan Nikhilesh p->queue_id = prod * stride; 507d008f20bSPavan Nikhilesh p->t = t; 508d008f20bSPavan Nikhilesh prod++; 509d008f20bSPavan Nikhilesh } 510d008f20bSPavan Nikhilesh 511d008f20bSPavan Nikhilesh ret = perf_event_timer_adapter_setup(t); 512d008f20bSPavan Nikhilesh if (ret) 513d008f20bSPavan Nikhilesh return ret; 5143617aae5SPavan Nikhilesh } else { 51584a7513dSJerin Jacob prod = 0; 51684a7513dSJerin Jacob for ( ; port < perf_nb_event_ports(opt); port++) { 51784a7513dSJerin Jacob struct prod_data *p = &t->prod[port]; 51884a7513dSJerin Jacob 51984a7513dSJerin Jacob p->dev_id = opt->dev_id; 52084a7513dSJerin Jacob p->port_id = port; 52184a7513dSJerin Jacob p->queue_id = prod * stride; 52284a7513dSJerin Jacob p->t = t; 52384a7513dSJerin Jacob 5243617aae5SPavan Nikhilesh ret = rte_event_port_setup(opt->dev_id, port, 525535c630cSPavan Nikhilesh port_conf); 52684a7513dSJerin Jacob if (ret) { 52784a7513dSJerin Jacob evt_err("failed to setup port %d", port); 52884a7513dSJerin Jacob return ret; 52984a7513dSJerin Jacob } 53084a7513dSJerin Jacob prod++; 53184a7513dSJerin Jacob } 5323617aae5SPavan Nikhilesh } 53384a7513dSJerin Jacob 53484a7513dSJerin Jacob return ret; 53584a7513dSJerin Jacob } 53684a7513dSJerin Jacob 53784a7513dSJerin Jacob int 538272de067SJerin Jacob perf_opt_check(struct evt_options *opt, uint64_t nb_queues) 539272de067SJerin Jacob { 540272de067SJerin Jacob unsigned int lcores; 541272de067SJerin Jacob 542b01974daSPavan Nikhilesh /* N producer + N worker + 1 master when producer cores are used 543b01974daSPavan Nikhilesh * Else N worker + 1 master when Rx adapter is used 544b01974daSPavan Nikhilesh */ 545b01974daSPavan Nikhilesh lcores = opt->prod_type == EVT_PROD_TYPE_SYNT ? 3 : 2; 546272de067SJerin Jacob 547272de067SJerin Jacob if (rte_lcore_count() < lcores) { 548272de067SJerin Jacob evt_err("test need minimum %d lcores", lcores); 549272de067SJerin Jacob return -1; 550272de067SJerin Jacob } 551272de067SJerin Jacob 552272de067SJerin Jacob /* Validate worker lcores */ 553272de067SJerin Jacob if (evt_lcores_has_overlap(opt->wlcores, rte_get_master_lcore())) { 554272de067SJerin Jacob evt_err("worker lcores overlaps with master lcore"); 555272de067SJerin Jacob return -1; 556272de067SJerin Jacob } 557272de067SJerin Jacob if (evt_lcores_has_overlap_multi(opt->wlcores, opt->plcores)) { 558272de067SJerin Jacob evt_err("worker lcores overlaps producer lcores"); 559272de067SJerin Jacob return -1; 560272de067SJerin Jacob } 561272de067SJerin Jacob if (evt_has_disabled_lcore(opt->wlcores)) { 562272de067SJerin Jacob evt_err("one or more workers lcores are not enabled"); 563272de067SJerin Jacob return -1; 564272de067SJerin Jacob } 565272de067SJerin Jacob if (!evt_has_active_lcore(opt->wlcores)) { 566272de067SJerin Jacob evt_err("minimum one worker is required"); 567272de067SJerin Jacob return -1; 568272de067SJerin Jacob } 569272de067SJerin Jacob 570902387eaSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_SYNT || 571902387eaSPavan Nikhilesh opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) { 572272de067SJerin Jacob /* Validate producer lcores */ 573b01974daSPavan Nikhilesh if (evt_lcores_has_overlap(opt->plcores, 574b01974daSPavan Nikhilesh rte_get_master_lcore())) { 575272de067SJerin Jacob evt_err("producer lcores overlaps with master lcore"); 576272de067SJerin Jacob return -1; 577272de067SJerin Jacob } 578272de067SJerin Jacob if (evt_has_disabled_lcore(opt->plcores)) { 579272de067SJerin Jacob evt_err("one or more producer lcores are not enabled"); 580272de067SJerin Jacob return -1; 581272de067SJerin Jacob } 582272de067SJerin Jacob if (!evt_has_active_lcore(opt->plcores)) { 583272de067SJerin Jacob evt_err("minimum one producer is required"); 584272de067SJerin Jacob return -1; 585272de067SJerin Jacob } 586b01974daSPavan Nikhilesh } 587272de067SJerin Jacob 588272de067SJerin Jacob if (evt_has_invalid_stage(opt)) 589272de067SJerin Jacob return -1; 590272de067SJerin Jacob 591272de067SJerin Jacob if (evt_has_invalid_sched_type(opt)) 592272de067SJerin Jacob return -1; 593272de067SJerin Jacob 594272de067SJerin Jacob if (nb_queues > EVT_MAX_QUEUES) { 595272de067SJerin Jacob evt_err("number of queues exceeds %d", EVT_MAX_QUEUES); 596272de067SJerin Jacob return -1; 597272de067SJerin Jacob } 598272de067SJerin Jacob if (perf_nb_event_ports(opt) > EVT_MAX_PORTS) { 599272de067SJerin Jacob evt_err("number of ports exceeds %d", EVT_MAX_PORTS); 600272de067SJerin Jacob return -1; 601272de067SJerin Jacob } 602272de067SJerin Jacob 603272de067SJerin Jacob /* Fixups */ 604d008f20bSPavan Nikhilesh if ((opt->nb_stages == 1 && 605d008f20bSPavan Nikhilesh opt->prod_type != EVT_PROD_TYPE_EVENT_TIMER_ADPTR) && 606d008f20bSPavan Nikhilesh opt->fwd_latency) { 607272de067SJerin Jacob evt_info("fwd_latency is valid when nb_stages > 1, disabling"); 608272de067SJerin Jacob opt->fwd_latency = 0; 609272de067SJerin Jacob } 610d008f20bSPavan Nikhilesh 611272de067SJerin Jacob if (opt->fwd_latency && !opt->q_priority) { 612272de067SJerin Jacob evt_info("enabled queue priority for latency measurement"); 613272de067SJerin Jacob opt->q_priority = 1; 614272de067SJerin Jacob } 6159d3aeb18SJerin Jacob if (opt->nb_pkts == 0) 6169d3aeb18SJerin Jacob opt->nb_pkts = INT64_MAX/evt_nr_active_lcores(opt->plcores); 617272de067SJerin Jacob 618272de067SJerin Jacob return 0; 619272de067SJerin Jacob } 620272de067SJerin Jacob 621272de067SJerin Jacob void 622272de067SJerin Jacob perf_opt_dump(struct evt_options *opt, uint8_t nb_queues) 623272de067SJerin Jacob { 624272de067SJerin Jacob evt_dump("nb_prod_lcores", "%d", evt_nr_active_lcores(opt->plcores)); 625272de067SJerin Jacob evt_dump_producer_lcores(opt); 626272de067SJerin Jacob evt_dump("nb_worker_lcores", "%d", evt_nr_active_lcores(opt->wlcores)); 627272de067SJerin Jacob evt_dump_worker_lcores(opt); 628272de067SJerin Jacob evt_dump_nb_stages(opt); 629272de067SJerin Jacob evt_dump("nb_evdev_ports", "%d", perf_nb_event_ports(opt)); 630272de067SJerin Jacob evt_dump("nb_evdev_queues", "%d", nb_queues); 631272de067SJerin Jacob evt_dump_queue_priority(opt); 632272de067SJerin Jacob evt_dump_sched_type_list(opt); 633b01974daSPavan Nikhilesh evt_dump_producer_type(opt); 634272de067SJerin Jacob } 635272de067SJerin Jacob 63641c219e6SJerin Jacob void 63741c219e6SJerin Jacob perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt) 63841c219e6SJerin Jacob { 639d008f20bSPavan Nikhilesh int i; 640d008f20bSPavan Nikhilesh struct test_perf *t = evt_test_priv(test); 64141c219e6SJerin Jacob 642d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) { 643d008f20bSPavan Nikhilesh for (i = 0; i < opt->nb_timer_adptrs; i++) 644d008f20bSPavan Nikhilesh rte_event_timer_adapter_stop(t->timer_adptr[i]); 645d008f20bSPavan Nikhilesh } 64641c219e6SJerin Jacob rte_event_dev_stop(opt->dev_id); 64741c219e6SJerin Jacob rte_event_dev_close(opt->dev_id); 64841c219e6SJerin Jacob } 64941c219e6SJerin Jacob 65041c219e6SJerin Jacob static inline void 65141c219e6SJerin Jacob perf_elt_init(struct rte_mempool *mp, void *arg __rte_unused, 65241c219e6SJerin Jacob void *obj, unsigned i __rte_unused) 65341c219e6SJerin Jacob { 65441c219e6SJerin Jacob memset(obj, 0, mp->elt_size); 65541c219e6SJerin Jacob } 65641c219e6SJerin Jacob 6573fc8de4fSPavan Nikhilesh #define NB_RX_DESC 128 6583fc8de4fSPavan Nikhilesh #define NB_TX_DESC 512 6593fc8de4fSPavan Nikhilesh int 6603fc8de4fSPavan Nikhilesh perf_ethdev_setup(struct evt_test *test, struct evt_options *opt) 6613fc8de4fSPavan Nikhilesh { 6628728ccf3SThomas Monjalon uint16_t i; 66377339255SIvan Ilchenko int ret; 6643fc8de4fSPavan Nikhilesh struct test_perf *t = evt_test_priv(test); 6653fc8de4fSPavan Nikhilesh struct rte_eth_conf port_conf = { 6663fc8de4fSPavan Nikhilesh .rxmode = { 6673fc8de4fSPavan Nikhilesh .mq_mode = ETH_MQ_RX_RSS, 66835b2d13fSOlivier Matz .max_rx_pkt_len = RTE_ETHER_MAX_LEN, 6693fc8de4fSPavan Nikhilesh .split_hdr_size = 0, 6703fc8de4fSPavan Nikhilesh }, 6713fc8de4fSPavan Nikhilesh .rx_adv_conf = { 6723fc8de4fSPavan Nikhilesh .rss_conf = { 6733fc8de4fSPavan Nikhilesh .rss_key = NULL, 6743fc8de4fSPavan Nikhilesh .rss_hf = ETH_RSS_IP, 6753fc8de4fSPavan Nikhilesh }, 6763fc8de4fSPavan Nikhilesh }, 6773fc8de4fSPavan Nikhilesh }; 6783fc8de4fSPavan Nikhilesh 679d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_SYNT || 680d008f20bSPavan Nikhilesh opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) 6813fc8de4fSPavan Nikhilesh return 0; 6823fc8de4fSPavan Nikhilesh 683d9a42a69SThomas Monjalon if (!rte_eth_dev_count_avail()) { 6843fc8de4fSPavan Nikhilesh evt_err("No ethernet ports found."); 6853fc8de4fSPavan Nikhilesh return -ENODEV; 6863fc8de4fSPavan Nikhilesh } 6873fc8de4fSPavan Nikhilesh 6888728ccf3SThomas Monjalon RTE_ETH_FOREACH_DEV(i) { 6894f5701f2SFerruh Yigit struct rte_eth_dev_info dev_info; 6904f5701f2SFerruh Yigit struct rte_eth_conf local_port_conf = port_conf; 6913fc8de4fSPavan Nikhilesh 69277339255SIvan Ilchenko ret = rte_eth_dev_info_get(i, &dev_info); 69377339255SIvan Ilchenko if (ret != 0) { 69477339255SIvan Ilchenko evt_err("Error during getting device (port %u) info: %s\n", 69577339255SIvan Ilchenko i, strerror(-ret)); 69677339255SIvan Ilchenko return ret; 69777339255SIvan Ilchenko } 6984f5701f2SFerruh Yigit 6994f5701f2SFerruh Yigit local_port_conf.rx_adv_conf.rss_conf.rss_hf &= 7004f5701f2SFerruh Yigit dev_info.flow_type_rss_offloads; 7014f5701f2SFerruh Yigit if (local_port_conf.rx_adv_conf.rss_conf.rss_hf != 7024f5701f2SFerruh Yigit port_conf.rx_adv_conf.rss_conf.rss_hf) { 7034f5701f2SFerruh Yigit evt_info("Port %u modified RSS hash function based on hardware support," 7044f5701f2SFerruh Yigit "requested:%#"PRIx64" configured:%#"PRIx64"\n", 7054f5701f2SFerruh Yigit i, 7064f5701f2SFerruh Yigit port_conf.rx_adv_conf.rss_conf.rss_hf, 7074f5701f2SFerruh Yigit local_port_conf.rx_adv_conf.rss_conf.rss_hf); 7084f5701f2SFerruh Yigit } 7094f5701f2SFerruh Yigit 7104f5701f2SFerruh Yigit if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) { 7113fc8de4fSPavan Nikhilesh evt_err("Failed to configure eth port [%d]", i); 7123fc8de4fSPavan Nikhilesh return -EINVAL; 7133fc8de4fSPavan Nikhilesh } 7143fc8de4fSPavan Nikhilesh 7153fc8de4fSPavan Nikhilesh if (rte_eth_rx_queue_setup(i, 0, NB_RX_DESC, 7163fc8de4fSPavan Nikhilesh rte_socket_id(), NULL, t->pool) < 0) { 7173fc8de4fSPavan Nikhilesh evt_err("Failed to setup eth port [%d] rx_queue: %d.", 7183fc8de4fSPavan Nikhilesh i, 0); 7193fc8de4fSPavan Nikhilesh return -EINVAL; 7203fc8de4fSPavan Nikhilesh } 7213fc8de4fSPavan Nikhilesh 7223fc8de4fSPavan Nikhilesh if (rte_eth_tx_queue_setup(i, 0, NB_TX_DESC, 7233fc8de4fSPavan Nikhilesh rte_socket_id(), NULL) < 0) { 7243fc8de4fSPavan Nikhilesh evt_err("Failed to setup eth port [%d] tx_queue: %d.", 7253fc8de4fSPavan Nikhilesh i, 0); 7263fc8de4fSPavan Nikhilesh return -EINVAL; 7273fc8de4fSPavan Nikhilesh } 7283fc8de4fSPavan Nikhilesh 729*70e51a0eSIvan Ilchenko ret = rte_eth_promiscuous_enable(i); 730*70e51a0eSIvan Ilchenko if (ret != 0) { 731*70e51a0eSIvan Ilchenko evt_err("Failed to enable promiscuous mode for eth port [%d]: %s", 732*70e51a0eSIvan Ilchenko i, rte_strerror(-ret)); 733*70e51a0eSIvan Ilchenko return ret; 734*70e51a0eSIvan Ilchenko } 7353fc8de4fSPavan Nikhilesh } 7363fc8de4fSPavan Nikhilesh 7373fc8de4fSPavan Nikhilesh return 0; 7383fc8de4fSPavan Nikhilesh } 7393fc8de4fSPavan Nikhilesh 7407f3daf34SPavan Nikhilesh void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt) 7417f3daf34SPavan Nikhilesh { 7428728ccf3SThomas Monjalon uint16_t i; 7437f3daf34SPavan Nikhilesh RTE_SET_USED(test); 7447f3daf34SPavan Nikhilesh 7457f3daf34SPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) { 7468728ccf3SThomas Monjalon RTE_ETH_FOREACH_DEV(i) { 7473617aae5SPavan Nikhilesh rte_event_eth_rx_adapter_stop(i); 7487f3daf34SPavan Nikhilesh rte_eth_dev_stop(i); 7497f3daf34SPavan Nikhilesh } 7507f3daf34SPavan Nikhilesh } 7517f3daf34SPavan Nikhilesh } 7527f3daf34SPavan Nikhilesh 75341c219e6SJerin Jacob int 75441c219e6SJerin Jacob perf_mempool_setup(struct evt_test *test, struct evt_options *opt) 75541c219e6SJerin Jacob { 75641c219e6SJerin Jacob struct test_perf *t = evt_test_priv(test); 75741c219e6SJerin Jacob 758d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_SYNT || 759d008f20bSPavan Nikhilesh opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) { 76041c219e6SJerin Jacob t->pool = rte_mempool_create(test->name, /* mempool name */ 76141c219e6SJerin Jacob opt->pool_sz, /* number of elements*/ 76241c219e6SJerin Jacob sizeof(struct perf_elt), /* element size*/ 76341c219e6SJerin Jacob 512, /* cache size*/ 76441c219e6SJerin Jacob 0, NULL, NULL, 76541c219e6SJerin Jacob perf_elt_init, /* obj constructor */ 76641c219e6SJerin Jacob NULL, opt->socket_id, 0); /* flags */ 7678577cc1aSPavan Nikhilesh } else { 7688577cc1aSPavan Nikhilesh t->pool = rte_pktmbuf_pool_create(test->name, /* mempool name */ 7698577cc1aSPavan Nikhilesh opt->pool_sz, /* number of elements*/ 7708577cc1aSPavan Nikhilesh 512, /* cache size*/ 7718577cc1aSPavan Nikhilesh 0, 7728577cc1aSPavan Nikhilesh RTE_MBUF_DEFAULT_BUF_SIZE, 7738577cc1aSPavan Nikhilesh opt->socket_id); /* flags */ 7748577cc1aSPavan Nikhilesh 7758577cc1aSPavan Nikhilesh } 7768577cc1aSPavan Nikhilesh 77741c219e6SJerin Jacob if (t->pool == NULL) { 77841c219e6SJerin Jacob evt_err("failed to create mempool"); 77941c219e6SJerin Jacob return -ENOMEM; 78041c219e6SJerin Jacob } 78141c219e6SJerin Jacob 78241c219e6SJerin Jacob return 0; 78341c219e6SJerin Jacob } 78441c219e6SJerin Jacob 78541c219e6SJerin Jacob void 78641c219e6SJerin Jacob perf_mempool_destroy(struct evt_test *test, struct evt_options *opt) 78741c219e6SJerin Jacob { 78841c219e6SJerin Jacob RTE_SET_USED(opt); 78941c219e6SJerin Jacob struct test_perf *t = evt_test_priv(test); 79041c219e6SJerin Jacob 79141c219e6SJerin Jacob rte_mempool_free(t->pool); 79241c219e6SJerin Jacob } 793ffbae86fSJerin Jacob 794ffbae86fSJerin Jacob int 795ffbae86fSJerin Jacob perf_test_setup(struct evt_test *test, struct evt_options *opt) 796ffbae86fSJerin Jacob { 797ffbae86fSJerin Jacob void *test_perf; 798ffbae86fSJerin Jacob 799ffbae86fSJerin Jacob test_perf = rte_zmalloc_socket(test->name, sizeof(struct test_perf), 800ffbae86fSJerin Jacob RTE_CACHE_LINE_SIZE, opt->socket_id); 801ffbae86fSJerin Jacob if (test_perf == NULL) { 802ffbae86fSJerin Jacob evt_err("failed to allocate test_perf memory"); 803ffbae86fSJerin Jacob goto nomem; 804ffbae86fSJerin Jacob } 805ffbae86fSJerin Jacob test->test_priv = test_perf; 806ffbae86fSJerin Jacob 807ffbae86fSJerin Jacob struct test_perf *t = evt_test_priv(test); 808ffbae86fSJerin Jacob 809d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) { 810d008f20bSPavan Nikhilesh t->outstand_pkts = opt->nb_timers * 811d008f20bSPavan Nikhilesh evt_nr_active_lcores(opt->plcores); 812d008f20bSPavan Nikhilesh t->nb_pkts = opt->nb_timers; 813d008f20bSPavan Nikhilesh } else { 814d008f20bSPavan Nikhilesh t->outstand_pkts = opt->nb_pkts * 815d008f20bSPavan Nikhilesh evt_nr_active_lcores(opt->plcores); 816d008f20bSPavan Nikhilesh t->nb_pkts = opt->nb_pkts; 817d008f20bSPavan Nikhilesh } 818d008f20bSPavan Nikhilesh 819ffbae86fSJerin Jacob t->nb_workers = evt_nr_active_lcores(opt->wlcores); 820ffbae86fSJerin Jacob t->done = false; 821ffbae86fSJerin Jacob t->nb_flows = opt->nb_flows; 822ffbae86fSJerin Jacob t->result = EVT_TEST_FAILED; 823ffbae86fSJerin Jacob t->opt = opt; 824ffbae86fSJerin Jacob memcpy(t->sched_type_list, opt->sched_type_list, 825ffbae86fSJerin Jacob sizeof(opt->sched_type_list)); 826ffbae86fSJerin Jacob return 0; 827ffbae86fSJerin Jacob nomem: 828ffbae86fSJerin Jacob return -ENOMEM; 829ffbae86fSJerin Jacob } 830ffbae86fSJerin Jacob 831ffbae86fSJerin Jacob void 832ffbae86fSJerin Jacob perf_test_destroy(struct evt_test *test, struct evt_options *opt) 833ffbae86fSJerin Jacob { 834ffbae86fSJerin Jacob RTE_SET_USED(opt); 835ffbae86fSJerin Jacob 836ffbae86fSJerin Jacob rte_free(test->test_priv); 837ffbae86fSJerin Jacob } 838