1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
7 #ifdef RTE_EXEC_ENV_WINDOWS
12 printf("pie not supported on Windows, skipping test\n");
19 printf("pie_perf not supported on Windows, skipping test\n");
26 printf("pie_all not supported on Windows, skipping test\n");
44 #ifdef __INTEL_COMPILER
45 #pragma warning(disable:2259) /* conversion may lose significant bits */
46 #pragma warning(disable:181) /* Arg incompatible with format string */
49 /**< structures for testing rte_pie performance and function */
50 struct test_rte_pie_config { /**< Test structure for RTE_PIE config */
51 struct rte_pie_config *pconfig; /**< RTE_PIE configuration parameters */
52 uint8_t num_cfg; /**< Number of RTE_PIE configs to test */
53 uint16_t qdelay_ref; /**< Latency Target (milliseconds) */
54 uint16_t *dp_update_interval; /**< Update interval for drop probability
57 uint16_t *max_burst; /**< Max Burst Allowance (milliseconds) */
58 uint16_t tailq_th; /**< Tailq drop threshold (packet counts) */
61 struct test_queue { /**< Test structure for RTE_PIE Queues */
62 struct rte_pie *pdata_in; /**< RTE_PIE runtime data input */
63 struct rte_pie *pdata_out; /**< RTE_PIE runtime data output*/
64 uint32_t num_queues; /**< Number of RTE_PIE queues to test */
65 uint32_t *qlen; /**< Queue size */
66 uint32_t q_ramp_up; /**< Num of enqueues to ramp up the queue */
67 double drop_tolerance; /**< Drop tolerance of packets not enqueued */
70 struct test_var { /**< Test variables used for testing RTE_PIE */
71 uint32_t num_iterations; /**< Number of test iterations */
72 uint32_t num_ops; /**< Number of test operations */
73 uint64_t clk_freq; /**< CPU clock frequency */
74 uint32_t *dropped; /**< Test operations dropped */
75 uint32_t *enqueued; /**< Test operations enqueued */
76 uint32_t *dequeued; /**< Test operations dequeued */
79 struct test_config { /**< Primary test structure for RTE_PIE */
80 const char *ifname; /**< Interface name */
81 const char *msg; /**< Test message for display */
82 const char *htxt; /**< Header txt display for result output */
83 struct test_rte_pie_config *tconfig; /**< Test structure for RTE_PIE config */
84 struct test_queue *tqueue; /**< Test structure for RTE_PIE Queues */
85 struct test_var *tvar; /**< Test variables used for testing RTE_PIE */
86 uint32_t *tlevel; /**< Queue levels */
94 /**< Test structure to define tests to run */
96 struct test_config *testcfg;
97 enum test_result (*testfn)(struct test_config *cfg);
102 uint64_t clk_min; /**< min clocks */
103 uint64_t clk_max; /**< max clocks */
104 uint64_t clk_avgc; /**< count to calc average */
105 double clk_avg; /**< cumulative sum to calc average */
109 static const uint64_t port_speed_bytes = (10ULL*1000ULL*1000ULL*1000ULL)/8ULL;
110 static double inv_cycles_per_byte;
112 static void init_port_ts(uint64_t cpu_clock)
114 double cycles_per_byte = (double)(cpu_clock) / (double)(port_speed_bytes);
115 inv_cycles_per_byte = 1.0 / cycles_per_byte;
118 static uint64_t get_port_ts(void)
120 return (uint64_t)((double)rte_rdtsc() * inv_cycles_per_byte);
123 static void rdtsc_prof_init(struct rdtsc_prof *p, const char *name)
125 p->clk_min = (uint64_t)(-1LL);
132 static inline void rdtsc_prof_start(struct rdtsc_prof *p)
134 p->clk_start = rte_rdtsc_precise();
137 static inline void rdtsc_prof_end(struct rdtsc_prof *p)
139 uint64_t clk_start = rte_rdtsc() - p->clk_start;
142 p->clk_avg += (double) clk_start;
144 if (clk_start > p->clk_max)
145 p->clk_max = clk_start;
146 if (clk_start < p->clk_min)
147 p->clk_min = clk_start;
150 static void rdtsc_prof_print(struct rdtsc_prof *p)
152 if (p->clk_avgc > 0) {
153 printf("RDTSC stats for %s: n=%" PRIu64 ", min=%" PRIu64
154 ",max=%" PRIu64 ", avg=%.1f\n",
159 (p->clk_avg / ((double) p->clk_avgc)));
163 static uint16_t rte_pie_get_active(const struct rte_pie_config *pie_cfg,
166 /**< Flag for activating/deactivating pie */
167 RTE_SET_USED(pie_cfg);
171 static void rte_pie_set_active(const struct rte_pie_config *pie_cfg,
175 /**< Flag for activating/deactivating pie */
176 RTE_SET_USED(pie_cfg);
177 pie->active = active;
181 * Read the drop probability
183 static double rte_pie_get_drop_prob(const struct rte_pie_config *pie_cfg,
186 /**< Current packet drop probability */
187 RTE_SET_USED(pie_cfg);
188 return pie->drop_prob;
191 static double rte_pie_get_avg_dq_time(const struct rte_pie_config *pie_cfg,
194 /**< Current packet drop probability */
195 RTE_SET_USED(pie_cfg);
196 return pie->avg_dq_time;
199 static double calc_drop_rate(uint32_t enqueued, uint32_t dropped)
201 return (double)dropped / ((double)enqueued + (double)dropped);
205 * check if drop rate matches drop probability within tolerance
207 static int check_drop_rate(double *diff, double drop_rate, double drop_prob,
210 double abs_diff = 0.0;
213 abs_diff = fabs(drop_rate - drop_prob);
214 if ((int)abs_diff == 0) {
217 *diff = (abs_diff / drop_prob) * 100.0;
218 if (*diff > tolerance)
225 * initialize the test rte_pie config
227 static enum test_result
228 test_rte_pie_init(struct test_config *tcfg)
232 tcfg->tvar->clk_freq = rte_get_timer_hz();
233 init_port_ts(tcfg->tvar->clk_freq);
235 for (i = 0; i < tcfg->tconfig->num_cfg; i++) {
236 if (rte_pie_config_init(&tcfg->tconfig->pconfig[i],
237 (uint16_t)tcfg->tconfig->qdelay_ref,
238 (uint16_t)tcfg->tconfig->dp_update_interval[i],
239 (uint16_t)tcfg->tconfig->max_burst[i],
240 (uint16_t)tcfg->tconfig->tailq_th) != 0) {
245 *tcfg->tqueue->qlen = 0;
246 *tcfg->tvar->dropped = 0;
247 *tcfg->tvar->enqueued = 0;
253 * enqueue until actual queue size reaches target level
256 increase_qsize(struct rte_pie_config *pie_cfg,
264 for (i = 0; i < attempts; i++) {
270 ret = rte_pie_enqueue(pie_cfg, pie, *qlen, pkt_len, get_port_ts());
272 * check if target actual queue size has been reached
284 * functional test enqueue/dequeue packets
287 enqueue_dequeue_func(struct rte_pie_config *pie_cfg,
296 for (i = 0; i < num_ops; i++) {
302 ret = rte_pie_enqueue(pie_cfg, pie, *qlen, sizeof(uint32_t),
312 * setup default values for the Functional test structures
314 static struct rte_pie_config ft_wpconfig[1];
315 static struct rte_pie ft_rtdata[1];
316 static uint32_t ft_q[] = {0};
317 static uint32_t ft_dropped[] = {0};
318 static uint32_t ft_enqueued[] = {0};
319 static uint16_t ft_max_burst[] = {64};
320 static uint16_t ft_dp_update_interval[] = {150};
322 static struct test_rte_pie_config ft_tconfig = {
323 .pconfig = ft_wpconfig,
324 .num_cfg = RTE_DIM(ft_wpconfig),
326 .dp_update_interval = ft_dp_update_interval,
327 .max_burst = ft_max_burst,
331 static struct test_queue ft_tqueue = {
332 .pdata_in = ft_rtdata,
333 .num_queues = RTE_DIM(ft_rtdata),
339 static struct test_var ft_tvar = {
343 .dropped = ft_dropped,
344 .enqueued = ft_enqueued,
348 * Test F1: functional test 1
350 static uint32_t ft_tlevels[] = {6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66,
351 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144};
353 static struct test_config func_test_config1 = {
354 .ifname = "functional test interface",
355 .msg = "functional test : use one pie configuration\n\n",
366 .tconfig = &ft_tconfig,
367 .tqueue = &ft_tqueue,
369 .tlevel = ft_tlevels,
372 static enum test_result func_test1(struct test_config *tcfg)
374 enum test_result result = PASS;
377 printf("%s", tcfg->msg);
379 if (test_rte_pie_init(tcfg) != PASS) {
384 printf("%s", tcfg->htxt);
387 * reset rte_pie run-time data
389 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
390 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
391 *tcfg->tvar->enqueued = 0;
392 *tcfg->tvar->dropped = 0;
394 if (increase_qsize(&tcfg->tconfig->pconfig[i],
395 tcfg->tqueue->pdata_in,
398 tcfg->tqueue->q_ramp_up) != 0) {
399 fprintf(stderr, "Fail: increase qsize\n");
404 for (i = 0; i < RTE_DIM(ft_tlevels); i++) {
405 const char *label = NULL;
408 double drop_rate = 1.0;
409 double drop_prob = 0.0;
412 enqueue_dequeue_func(&tcfg->tconfig->pconfig[i],
413 tcfg->tqueue->pdata_in,
416 tcfg->tvar->enqueued,
417 tcfg->tvar->dropped);
419 drop_rate = calc_drop_rate(*tcfg->tvar->enqueued,
420 *tcfg->tvar->dropped);
421 drop_prob = rte_pie_get_drop_prob(NULL, tcfg->tqueue->pdata_in);
423 if (drop_prob != 0) {
424 fprintf(stderr, "Fail: check drop prob\n");
428 if (drop_rate != 0) {
429 fprintf(stderr, "Fail: check drop rate\n");
434 active = rte_pie_get_active(NULL, tcfg->tqueue->pdata_in);
435 printf("%s%-16u%-12u%-12u%-12.4lf%-12.4lf%-12.4lf%-12.4lf%-8i\n",
436 label, prob, *tcfg->tvar->enqueued, *tcfg->tvar->dropped,
437 drop_prob * 100.0, drop_rate * 100.0, diff,
438 (double)tcfg->tqueue->drop_tolerance, active);
445 * Test F2: functional test 2
447 static uint32_t ft2_tlevel[] = {127};
448 static uint16_t ft2_max_burst[] = {1, 2, 8, 16, 32, 64, 128, 256, 512, 1024};
449 static uint16_t ft2_dp_update_interval[] = {
450 10, 20, 50, 150, 300, 600, 900, 1200, 1500, 3000};
451 static struct rte_pie_config ft2_pconfig[10];
453 static struct test_rte_pie_config ft2_tconfig = {
454 .pconfig = ft2_pconfig,
455 .num_cfg = RTE_DIM(ft2_pconfig),
457 .dp_update_interval = ft2_dp_update_interval,
458 .max_burst = ft2_max_burst,
462 static struct test_config func_test_config2 = {
463 .ifname = "functional test 2 interface",
464 .msg = "functional test 2 : use several PIE configurations,\n"
465 " compare drop rate to drop probability\n\n",
466 .htxt = "PIE config "
475 .tconfig = &ft2_tconfig,
476 .tqueue = &ft_tqueue,
478 .tlevel = ft2_tlevel,
481 static enum test_result func_test2(struct test_config *tcfg)
483 enum test_result result = PASS;
486 printf("%s", tcfg->msg);
488 printf("%s", tcfg->htxt);
490 for (i = 0; i < tcfg->tconfig->num_cfg; i++) {
492 double drop_rate = 0.0;
493 double drop_prob = 0.0;
496 if (test_rte_pie_init(tcfg) != PASS) {
501 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
502 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
503 *tcfg->tvar->enqueued = 0;
504 *tcfg->tvar->dropped = 0;
506 if (increase_qsize(&tcfg->tconfig->pconfig[i],
507 tcfg->tqueue->pdata_in,
510 tcfg->tqueue->q_ramp_up) != 0) {
515 enqueue_dequeue_func(&tcfg->tconfig->pconfig[i],
516 tcfg->tqueue->pdata_in,
519 tcfg->tvar->enqueued,
520 tcfg->tvar->dropped);
522 avg = rte_pie_get_avg_dq_time(NULL, tcfg->tqueue->pdata_in);
524 drop_rate = calc_drop_rate(*tcfg->tvar->enqueued,
525 *tcfg->tvar->dropped);
526 drop_prob = rte_pie_get_drop_prob(NULL, tcfg->tqueue->pdata_in);
528 if (!check_drop_rate(&diff, drop_rate, drop_prob,
529 (double)tcfg->tqueue->drop_tolerance)) {
530 fprintf(stderr, "Fail: drop rate outside tolerance\n");
534 printf("%-15u%-15u%-15u%-15u%-15.4lf%-15.4lf%-15.4lf%-15.4lf\n",
535 i, avg, *tcfg->tvar->enqueued, *tcfg->tvar->dropped,
536 drop_prob * 100.0, drop_rate * 100.0, diff,
537 (double)tcfg->tqueue->drop_tolerance);
543 static uint32_t ft3_qlen[] = {100};
545 static struct test_rte_pie_config ft3_tconfig = {
546 .pconfig = ft_wpconfig,
547 .num_cfg = RTE_DIM(ft_wpconfig),
549 .dp_update_interval = ft_dp_update_interval,
550 .max_burst = ft_max_burst,
554 static struct test_queue ft3_tqueue = {
555 .pdata_in = ft_rtdata,
556 .num_queues = RTE_DIM(ft_rtdata),
562 static struct test_var ft3_tvar = {
566 .dropped = ft_dropped,
567 .enqueued = ft_enqueued,
571 * Test F3: functional test 3
573 static uint32_t ft3_tlevels[] = {64, 127, 222};
575 static struct test_config func_test_config3 = {
576 .ifname = "functional test interface",
577 .msg = "functional test 2 : use one pie configuration\n"
578 "using non zero qlen\n\n",
589 .tconfig = &ft3_tconfig,
590 .tqueue = &ft3_tqueue,
592 .tlevel = ft3_tlevels,
595 static enum test_result func_test3(struct test_config *tcfg)
597 enum test_result result = PASS;
600 printf("%s", tcfg->msg);
602 if (test_rte_pie_init(tcfg) != PASS) {
607 printf("%s", tcfg->htxt);
610 * reset rte_pie run-time data
612 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
613 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
614 *tcfg->tvar->enqueued = 0;
615 *tcfg->tvar->dropped = 0;
617 if (increase_qsize(&tcfg->tconfig->pconfig[i],
618 tcfg->tqueue->pdata_in,
621 tcfg->tqueue->q_ramp_up) != 0) {
622 fprintf(stderr, "Fail: increase qsize\n");
627 for (i = 0; i < RTE_DIM(ft_tlevels); i++) {
628 const char *label = NULL;
631 double drop_rate = 1.0;
632 double drop_prob = 0.0;
635 enqueue_dequeue_func(&tcfg->tconfig->pconfig[i],
636 tcfg->tqueue->pdata_in,
639 tcfg->tvar->enqueued,
640 tcfg->tvar->dropped);
642 drop_rate = calc_drop_rate(*tcfg->tvar->enqueued,
643 *tcfg->tvar->dropped);
644 drop_prob = rte_pie_get_drop_prob(NULL, tcfg->tqueue->pdata_in);
646 if (drop_prob != 0) {
647 fprintf(stderr, "Fail: check drop prob\n");
651 if (drop_rate != 0) {
652 fprintf(stderr, "Fail: check drop rate\n");
657 active = rte_pie_get_active(NULL, tcfg->tqueue->pdata_in);
658 printf("%s%-16u%-12u%-12u%-12.4lf%-12.4lf%-12.4lf%-12.4lf%-8i\n",
659 label, prob, *tcfg->tvar->enqueued, *tcfg->tvar->dropped,
660 drop_prob * 100.0, drop_rate * 100.0, diff,
661 (double)tcfg->tqueue->drop_tolerance, active);
668 * setup default values for the Performance test structures
670 static struct rte_pie_config pt_wrconfig[1];
671 static struct rte_pie pt_rtdata[1];
672 static struct rte_pie pt_wtdata[1];
673 static uint32_t pt_q[] = {0};
674 static uint32_t pt_dropped[] = {0};
675 static uint32_t pt_enqueued[] = {0};
676 static uint32_t pt_dequeued[] = {0};
677 static uint16_t pt_max_burst[] = {64};
678 static uint16_t pt_dp_update_interval[] = {150};
680 static struct test_rte_pie_config pt_tconfig = {
681 .pconfig = pt_wrconfig,
682 .num_cfg = RTE_DIM(pt_wrconfig),
684 .dp_update_interval = pt_dp_update_interval,
685 .max_burst = pt_max_burst,
689 static struct test_queue pt_tqueue = {
690 .pdata_in = pt_rtdata,
691 .num_queues = RTE_DIM(pt_rtdata),
693 .q_ramp_up = 1000000,
694 .drop_tolerance = 0, /* 0 percent */
697 static struct test_rte_pie_config pt_tconfig2 = {
698 .pconfig = pt_wrconfig,
699 .num_cfg = RTE_DIM(pt_wrconfig),
701 .dp_update_interval = pt_dp_update_interval,
702 .max_burst = pt_max_burst,
706 static struct test_queue pt_tqueue2 = {
707 .pdata_in = pt_rtdata,
708 .pdata_out = pt_wtdata,
709 .num_queues = RTE_DIM(pt_rtdata),
711 .q_ramp_up = 1000000,
712 .drop_tolerance = 0, /* 0 percent */
716 * enqueue/dequeue packets
718 * rte_sched_port_enqueue(port, in_mbufs, 10);
719 * rte_sched_port_dequeue(port, out_mbufs, 10);
721 static void enqueue_dequeue_perf(struct rte_pie_config *pie_cfg,
722 struct rte_pie *pie_in,
723 struct rte_pie *pie_out,
729 struct rdtsc_prof *prof)
733 if (pie_cfg == NULL) {
734 printf("%s: Error: PIE configuration cannot be empty.\n", __func__);
738 if (pie_in == NULL) {
739 printf("%s: Error: PIE enqueue data cannot be empty.\n", __func__);
743 for (i = 0; i < num_ops; i++) {
751 rdtsc_prof_start(prof);
752 ret = rte_pie_enqueue(pie_cfg, pie_in, *qlen,
753 1000*sizeof(uint32_t), ts);
754 rdtsc_prof_end(prof);
761 if (pie_out != NULL) {
763 rdtsc_prof_start(prof);
764 rte_pie_dequeue(pie_out, 1000*sizeof(uint32_t), ts);
765 rdtsc_prof_end(prof);
773 * Setup test structures for tests P1
774 * performance tests 1
776 static uint32_t pt1_tlevel[] = {80};
778 static struct test_var perf1_tvar = {
782 .dropped = pt_dropped,
783 .enqueued = pt_enqueued
786 static struct test_config perf_test_config = {
787 .ifname = "performance test 1 interface",
788 .msg = "performance test 1 : use one PIE configuration,\n"
789 " measure enqueue performance\n\n",
790 .tconfig = &pt_tconfig,
791 .tqueue = &pt_tqueue,
793 .tlevel = pt1_tlevel,
797 * Performance test function to measure enqueue performance.
800 static enum test_result perf_test(struct test_config *tcfg)
802 enum test_result result = PASS;
803 struct rdtsc_prof prof = {0, 0, 0, 0, 0.0, NULL};
806 printf("%s", tcfg->msg);
808 rdtsc_prof_init(&prof, "enqueue");
810 if (test_rte_pie_init(tcfg) != PASS) {
816 * initialize the rte_pie run time data structure
818 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
819 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
820 *tcfg->tvar->enqueued = 0;
821 *tcfg->tvar->dropped = 0;
823 enqueue_dequeue_perf(tcfg->tconfig->pconfig,
824 tcfg->tqueue->pdata_in,
828 tcfg->tvar->enqueued,
830 tcfg->tvar->dequeued,
833 total = *tcfg->tvar->enqueued + *tcfg->tvar->dropped;
835 printf("\ntotal: %u, enqueued: %u (%.2lf%%), dropped: %u (%.2lf%%)\n",
836 total, *tcfg->tvar->enqueued,
837 ((double)(*tcfg->tvar->enqueued) / (double)total) * 100.0,
838 *tcfg->tvar->dropped,
839 ((double)(*tcfg->tvar->dropped) / (double)total) * 100.0);
841 rdtsc_prof_print(&prof);
849 * Setup test structures for tests P2
850 * performance tests 2
852 static uint32_t pt2_tlevel[] = {80};
854 static struct test_var perf2_tvar = {
858 .dropped = pt_dropped,
859 .enqueued = pt_enqueued,
860 .dequeued = pt_dequeued
863 static struct test_config perf_test_config2 = {
864 .ifname = "performance test 2 interface",
865 .msg = "performance test 2 : use one PIE configuration,\n"
866 " measure enqueue & dequeue performance\n\n",
867 .tconfig = &pt_tconfig2,
868 .tqueue = &pt_tqueue2,
870 .tlevel = pt2_tlevel,
874 * Performance test function to measure enqueue & dequeue performance.
877 static enum test_result perf_test2(struct test_config *tcfg)
879 enum test_result result = PASS;
880 struct rdtsc_prof prof = {0, 0, 0, 0, 0.0, NULL};
883 printf("%s", tcfg->msg);
885 rdtsc_prof_init(&prof, "enqueue");
887 if (test_rte_pie_init(tcfg) != PASS) {
893 * initialize the rte_pie run time data structure
895 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
896 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
897 *tcfg->tvar->enqueued = 0;
898 *tcfg->tvar->dequeued = 0;
899 *tcfg->tvar->dropped = 0;
901 enqueue_dequeue_perf(tcfg->tconfig->pconfig,
902 tcfg->tqueue->pdata_in,
903 tcfg->tqueue->pdata_out,
906 tcfg->tvar->enqueued,
908 tcfg->tvar->dequeued,
911 total = *tcfg->tvar->enqueued + *tcfg->tvar->dropped;
913 printf("\ntotal: %u, dequeued: %u (%.2lf%%), dropped: %u (%.2lf%%)\n",
914 total, *tcfg->tvar->dequeued,
915 ((double)(*tcfg->tvar->dequeued) / (double)total) * 100.0,
916 *tcfg->tvar->dropped,
917 ((double)(*tcfg->tvar->dropped) / (double)total) * 100.0);
919 rdtsc_prof_print(&prof);
925 * define the functional tests to be executed fast
927 struct tests func_pie_tests_quick[] = {
928 { &func_test_config1, func_test1 },
929 { &func_test_config2, func_test2 },
933 * define the functional and performance tests to be executed
935 struct tests func_pie_tests[] = {
936 { &func_test_config1, func_test1 },
937 { &func_test_config2, func_test2 },
938 { &func_test_config3, func_test3 },
941 struct tests perf_pie_tests[] = {
942 { &perf_test_config, perf_test },
943 { &perf_test_config2, perf_test2 },
947 * function to execute the required pie tests
949 static void run_tests(struct tests *test_type, uint32_t test_count,
950 uint32_t *num_tests, uint32_t *num_pass)
952 enum test_result result = PASS;
954 static const char *bar_str = "-------------------------------------"
955 "-------------------------------------------";
956 static const char *bar_pass_str = "-------------------------------------"
957 "<pass>-------------------------------------";
958 static const char *bar_fail_str = "-------------------------------------"
959 "<fail>-------------------------------------";
961 for (i = 0; i < test_count; i++) {
962 printf("\n%s\n", bar_str);
963 result = test_type[i].testfn(test_type[i].testcfg);
965 if (result == PASS) {
967 printf("%s\n", bar_pass_str);
969 printf("%s\n", bar_fail_str);
975 * check if functions accept invalid parameters
977 * First, all functions will be called without initialized PIE
978 * Then, all of them will be called with NULL/invalid parameters
980 * Some functions are not tested as they are performance-critical and thus
981 * don't do any parameter checking.
984 test_invalid_parameters(void)
986 struct rte_pie_config config;
987 static const char *shf_str = "rte_pie_config_init should have failed!";
988 static const char *shf_rt_str = "rte_pie_rt_data_init should have failed!";
991 if (rte_pie_rt_data_init(NULL) == 0) {
992 printf("%i: %s\n", __LINE__, shf_rt_str);
997 if (rte_pie_config_init(NULL, 0, 0, 0, 0) == 0) {
998 printf("%i%s\n", __LINE__, shf_str);
1002 /* qdelay_ref <= 0 */
1003 if (rte_pie_config_init(&config, 0, 1, 1, 1) == 0) {
1004 printf("%i%s\n", __LINE__, shf_str);
1008 /* dp_update_interval <= 0 */
1009 if (rte_pie_config_init(&config, 1, 0, 1, 1) == 0) {
1010 printf("%i%s\n", __LINE__, shf_str);
1014 /* max_burst <= 0 */
1015 if (rte_pie_config_init(&config, 1, 1, 0, 1) == 0) {
1016 printf("%i%s\n", __LINE__, shf_str);
1021 if (rte_pie_config_init(&config, 1, 1, 1, 0) == 0) {
1022 printf("%i%s\n", __LINE__, shf_str);
1026 RTE_SET_USED(config);
1032 show_stats(const uint32_t num_tests, const uint32_t num_pass)
1034 if (num_pass == num_tests)
1035 printf("[total: %u, pass: %u]\n", num_tests, num_pass);
1037 printf("[total: %u, pass: %u, fail: %u]\n", num_tests, num_pass,
1038 num_tests - num_pass);
1042 tell_the_result(const uint32_t num_tests, const uint32_t num_pass)
1044 return (num_pass == num_tests) ? 0 : 1;
1050 uint32_t num_tests = 0;
1051 uint32_t num_pass = 0;
1053 if (test_invalid_parameters() < 0)
1056 run_tests(func_pie_tests_quick, RTE_DIM(func_pie_tests_quick),
1057 &num_tests, &num_pass);
1058 show_stats(num_tests, num_pass);
1059 return tell_the_result(num_tests, num_pass);
1065 uint32_t num_tests = 0;
1066 uint32_t num_pass = 0;
1068 run_tests(perf_pie_tests, RTE_DIM(perf_pie_tests), &num_tests, &num_pass);
1069 show_stats(num_tests, num_pass);
1070 return tell_the_result(num_tests, num_pass);
1076 uint32_t num_tests = 0;
1077 uint32_t num_pass = 0;
1079 if (test_invalid_parameters() < 0)
1082 run_tests(func_pie_tests, RTE_DIM(func_pie_tests), &num_tests, &num_pass);
1083 run_tests(perf_pie_tests, RTE_DIM(perf_pie_tests), &num_tests, &num_pass);
1084 show_stats(num_tests, num_pass);
1085 return tell_the_result(num_tests, num_pass);
1088 #endif /* !RTE_EXEC_ENV_WINDOWS */
1090 REGISTER_TEST_COMMAND(pie_autotest, test_pie);
1091 REGISTER_TEST_COMMAND(pie_perf, test_pie_perf);
1092 REGISTER_TEST_COMMAND(pie_all, test_pie_all);