1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
19 #ifdef __INTEL_COMPILER
20 #pragma warning(disable:2259) /* conversion may lose significant bits */
21 #pragma warning(disable:181) /* Arg incompatible with format string */
24 /**< structures for testing rte_pie performance and function */
25 struct test_rte_pie_config { /**< Test structure for RTE_PIE config */
26 struct rte_pie_config *pconfig; /**< RTE_PIE configuration parameters */
27 uint8_t num_cfg; /**< Number of RTE_PIE configs to test */
28 uint16_t qdelay_ref; /**< Latency Target (milliseconds) */
29 uint16_t *dp_update_interval; /**< Update interval for drop probability
32 uint16_t *max_burst; /**< Max Burst Allowance (milliseconds) */
33 uint16_t tailq_th; /**< Tailq drop threshold (packet counts) */
36 struct test_queue { /**< Test structure for RTE_PIE Queues */
37 struct rte_pie *pdata_in; /**< RTE_PIE runtime data input */
38 struct rte_pie *pdata_out; /**< RTE_PIE runtime data output*/
39 uint32_t num_queues; /**< Number of RTE_PIE queues to test */
40 uint32_t *qlen; /**< Queue size */
41 uint32_t q_ramp_up; /**< Num of enqueues to ramp up the queue */
42 double drop_tolerance; /**< Drop tolerance of packets not enqueued */
45 struct test_var { /**< Test variables used for testing RTE_PIE */
46 uint32_t num_iterations; /**< Number of test iterations */
47 uint32_t num_ops; /**< Number of test operations */
48 uint64_t clk_freq; /**< CPU clock frequency */
49 uint32_t *dropped; /**< Test operations dropped */
50 uint32_t *enqueued; /**< Test operations enqueued */
51 uint32_t *dequeued; /**< Test operations dequeued */
54 struct test_config { /**< Primary test structure for RTE_PIE */
55 const char *ifname; /**< Interface name */
56 const char *msg; /**< Test message for display */
57 const char *htxt; /**< Header txt display for result output */
58 struct test_rte_pie_config *tconfig; /**< Test structure for RTE_PIE config */
59 struct test_queue *tqueue; /**< Test structure for RTE_PIE Queues */
60 struct test_var *tvar; /**< Test variables used for testing RTE_PIE */
61 uint32_t *tlevel; /**< Queue levels */
69 /**< Test structure to define tests to run */
71 struct test_config *testcfg;
72 enum test_result (*testfn)(struct test_config *cfg);
77 uint64_t clk_min; /**< min clocks */
78 uint64_t clk_max; /**< max clocks */
79 uint64_t clk_avgc; /**< count to calc average */
80 double clk_avg; /**< cumulative sum to calc average */
84 static const uint64_t port_speed_bytes = (10ULL*1000ULL*1000ULL*1000ULL)/8ULL;
85 static double inv_cycles_per_byte;
87 static void init_port_ts(uint64_t cpu_clock)
89 double cycles_per_byte = (double)(cpu_clock) / (double)(port_speed_bytes);
90 inv_cycles_per_byte = 1.0 / cycles_per_byte;
93 static uint64_t get_port_ts(void)
95 return (uint64_t)((double)rte_rdtsc() * inv_cycles_per_byte);
98 static void rdtsc_prof_init(struct rdtsc_prof *p, const char *name)
100 p->clk_min = (uint64_t)(-1LL);
107 static inline void rdtsc_prof_start(struct rdtsc_prof *p)
109 p->clk_start = rte_rdtsc_precise();
112 static inline void rdtsc_prof_end(struct rdtsc_prof *p)
114 uint64_t clk_start = rte_rdtsc() - p->clk_start;
117 p->clk_avg += (double) clk_start;
119 if (clk_start > p->clk_max)
120 p->clk_max = clk_start;
121 if (clk_start < p->clk_min)
122 p->clk_min = clk_start;
125 static void rdtsc_prof_print(struct rdtsc_prof *p)
127 if (p->clk_avgc > 0) {
128 printf("RDTSC stats for %s: n=%" PRIu64 ", min=%" PRIu64
129 ",max=%" PRIu64 ", avg=%.1f\n",
134 (p->clk_avg / ((double) p->clk_avgc)));
138 static uint16_t rte_pie_get_active(const struct rte_pie_config *pie_cfg,
141 /**< Flag for activating/deactivating pie */
142 RTE_SET_USED(pie_cfg);
146 static void rte_pie_set_active(const struct rte_pie_config *pie_cfg,
150 /**< Flag for activating/deactivating pie */
151 RTE_SET_USED(pie_cfg);
152 pie->active = active;
156 * Read the drop probability
158 static double rte_pie_get_drop_prob(const struct rte_pie_config *pie_cfg,
161 /**< Current packet drop probability */
162 RTE_SET_USED(pie_cfg);
163 return pie->drop_prob;
166 static double rte_pie_get_avg_dq_time(const struct rte_pie_config *pie_cfg,
169 /**< Current packet drop probability */
170 RTE_SET_USED(pie_cfg);
171 return pie->avg_dq_time;
174 static double calc_drop_rate(uint32_t enqueued, uint32_t dropped)
176 return (double)dropped / ((double)enqueued + (double)dropped);
180 * check if drop rate matches drop probability within tolerance
182 static int check_drop_rate(double *diff, double drop_rate, double drop_prob,
185 double abs_diff = 0.0;
188 abs_diff = fabs(drop_rate - drop_prob);
189 if ((int)abs_diff == 0) {
192 *diff = (abs_diff / drop_prob) * 100.0;
193 if (*diff > tolerance)
200 * initialize the test rte_pie config
202 static enum test_result
203 test_rte_pie_init(struct test_config *tcfg)
207 tcfg->tvar->clk_freq = rte_get_timer_hz();
208 init_port_ts(tcfg->tvar->clk_freq);
210 for (i = 0; i < tcfg->tconfig->num_cfg; i++) {
211 if (rte_pie_config_init(&tcfg->tconfig->pconfig[i],
212 (uint16_t)tcfg->tconfig->qdelay_ref,
213 (uint16_t)tcfg->tconfig->dp_update_interval[i],
214 (uint16_t)tcfg->tconfig->max_burst[i],
215 (uint16_t)tcfg->tconfig->tailq_th) != 0) {
220 *tcfg->tqueue->qlen = 0;
221 *tcfg->tvar->dropped = 0;
222 *tcfg->tvar->enqueued = 0;
228 * enqueue until actual queue size reaches target level
231 increase_qsize(struct rte_pie_config *pie_cfg,
239 for (i = 0; i < attempts; i++) {
245 ret = rte_pie_enqueue(pie_cfg, pie, *qlen, pkt_len, get_port_ts());
247 * check if target actual queue size has been reached
259 * functional test enqueue/dequeue packets
262 enqueue_dequeue_func(struct rte_pie_config *pie_cfg,
271 for (i = 0; i < num_ops; i++) {
277 ret = rte_pie_enqueue(pie_cfg, pie, *qlen, sizeof(uint32_t),
287 * setup default values for the Functional test structures
289 static struct rte_pie_config ft_wpconfig[1];
290 static struct rte_pie ft_rtdata[1];
291 static uint32_t ft_q[] = {0};
292 static uint32_t ft_dropped[] = {0};
293 static uint32_t ft_enqueued[] = {0};
294 static uint16_t ft_max_burst[] = {64};
295 static uint16_t ft_dp_update_interval[] = {150};
297 static struct test_rte_pie_config ft_tconfig = {
298 .pconfig = ft_wpconfig,
299 .num_cfg = RTE_DIM(ft_wpconfig),
301 .dp_update_interval = ft_dp_update_interval,
302 .max_burst = ft_max_burst,
306 static struct test_queue ft_tqueue = {
307 .pdata_in = ft_rtdata,
308 .num_queues = RTE_DIM(ft_rtdata),
314 static struct test_var ft_tvar = {
318 .dropped = ft_dropped,
319 .enqueued = ft_enqueued,
323 * Test F1: functional test 1
325 static uint32_t ft_tlevels[] = {6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66,
326 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144};
328 static struct test_config func_test_config1 = {
329 .ifname = "functional test interface",
330 .msg = "functional test : use one pie configuration\n\n",
341 .tconfig = &ft_tconfig,
342 .tqueue = &ft_tqueue,
344 .tlevel = ft_tlevels,
347 static enum test_result func_test1(struct test_config *tcfg)
349 enum test_result result = PASS;
352 printf("%s", tcfg->msg);
354 if (test_rte_pie_init(tcfg) != PASS) {
359 printf("%s", tcfg->htxt);
362 * reset rte_pie run-time data
364 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
365 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
366 *tcfg->tvar->enqueued = 0;
367 *tcfg->tvar->dropped = 0;
369 if (increase_qsize(&tcfg->tconfig->pconfig[i],
370 tcfg->tqueue->pdata_in,
373 tcfg->tqueue->q_ramp_up) != 0) {
374 fprintf(stderr, "Fail: increase qsize\n");
379 for (i = 0; i < RTE_DIM(ft_tlevels); i++) {
380 const char *label = NULL;
383 double drop_rate = 1.0;
384 double drop_prob = 0.0;
387 enqueue_dequeue_func(&tcfg->tconfig->pconfig[i],
388 tcfg->tqueue->pdata_in,
391 tcfg->tvar->enqueued,
392 tcfg->tvar->dropped);
394 drop_rate = calc_drop_rate(*tcfg->tvar->enqueued,
395 *tcfg->tvar->dropped);
396 drop_prob = rte_pie_get_drop_prob(NULL, tcfg->tqueue->pdata_in);
398 if (drop_prob != 0) {
399 fprintf(stderr, "Fail: check drop prob\n");
403 if (drop_rate != 0) {
404 fprintf(stderr, "Fail: check drop rate\n");
409 active = rte_pie_get_active(NULL, tcfg->tqueue->pdata_in);
410 printf("%s%-16u%-12u%-12u%-12.4lf%-12.4lf%-12.4lf%-12.4lf%-8i\n",
411 label, prob, *tcfg->tvar->enqueued, *tcfg->tvar->dropped,
412 drop_prob * 100.0, drop_rate * 100.0, diff,
413 (double)tcfg->tqueue->drop_tolerance, active);
420 * Test F2: functional test 2
422 static uint32_t ft2_tlevel[] = {127};
423 static uint16_t ft2_max_burst[] = {1, 2, 8, 16, 32, 64, 128, 256, 512, 1024};
424 static uint16_t ft2_dp_update_interval[] = {
425 10, 20, 50, 150, 300, 600, 900, 1200, 1500, 3000};
426 static struct rte_pie_config ft2_pconfig[10];
428 static struct test_rte_pie_config ft2_tconfig = {
429 .pconfig = ft2_pconfig,
430 .num_cfg = RTE_DIM(ft2_pconfig),
432 .dp_update_interval = ft2_dp_update_interval,
433 .max_burst = ft2_max_burst,
437 static struct test_config func_test_config2 = {
438 .ifname = "functional test 2 interface",
439 .msg = "functional test 2 : use several PIE configurations,\n"
440 " compare drop rate to drop probability\n\n",
441 .htxt = "PIE config "
450 .tconfig = &ft2_tconfig,
451 .tqueue = &ft_tqueue,
453 .tlevel = ft2_tlevel,
456 static enum test_result func_test2(struct test_config *tcfg)
458 enum test_result result = PASS;
461 printf("%s", tcfg->msg);
463 printf("%s", tcfg->htxt);
465 for (i = 0; i < tcfg->tconfig->num_cfg; i++) {
467 double drop_rate = 0.0;
468 double drop_prob = 0.0;
471 if (test_rte_pie_init(tcfg) != PASS) {
476 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
477 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
478 *tcfg->tvar->enqueued = 0;
479 *tcfg->tvar->dropped = 0;
481 if (increase_qsize(&tcfg->tconfig->pconfig[i],
482 tcfg->tqueue->pdata_in,
485 tcfg->tqueue->q_ramp_up) != 0) {
490 enqueue_dequeue_func(&tcfg->tconfig->pconfig[i],
491 tcfg->tqueue->pdata_in,
494 tcfg->tvar->enqueued,
495 tcfg->tvar->dropped);
497 avg = rte_pie_get_avg_dq_time(NULL, tcfg->tqueue->pdata_in);
499 drop_rate = calc_drop_rate(*tcfg->tvar->enqueued,
500 *tcfg->tvar->dropped);
501 drop_prob = rte_pie_get_drop_prob(NULL, tcfg->tqueue->pdata_in);
503 if (!check_drop_rate(&diff, drop_rate, drop_prob,
504 (double)tcfg->tqueue->drop_tolerance)) {
505 fprintf(stderr, "Fail: drop rate outside tolerance\n");
509 printf("%-15u%-15u%-15u%-15u%-15.4lf%-15.4lf%-15.4lf%-15.4lf\n",
510 i, avg, *tcfg->tvar->enqueued, *tcfg->tvar->dropped,
511 drop_prob * 100.0, drop_rate * 100.0, diff,
512 (double)tcfg->tqueue->drop_tolerance);
518 static uint32_t ft3_qlen[] = {100};
520 static struct test_rte_pie_config ft3_tconfig = {
521 .pconfig = ft_wpconfig,
522 .num_cfg = RTE_DIM(ft_wpconfig),
524 .dp_update_interval = ft_dp_update_interval,
525 .max_burst = ft_max_burst,
529 static struct test_queue ft3_tqueue = {
530 .pdata_in = ft_rtdata,
531 .num_queues = RTE_DIM(ft_rtdata),
537 static struct test_var ft3_tvar = {
541 .dropped = ft_dropped,
542 .enqueued = ft_enqueued,
546 * Test F3: functional test 3
548 static uint32_t ft3_tlevels[] = {64, 127, 222};
550 static struct test_config func_test_config3 = {
551 .ifname = "functional test interface",
552 .msg = "functional test 2 : use one pie configuration\n"
553 "using non zero qlen\n\n",
564 .tconfig = &ft3_tconfig,
565 .tqueue = &ft3_tqueue,
567 .tlevel = ft3_tlevels,
570 static enum test_result func_test3(struct test_config *tcfg)
572 enum test_result result = PASS;
575 printf("%s", tcfg->msg);
577 if (test_rte_pie_init(tcfg) != PASS) {
582 printf("%s", tcfg->htxt);
585 * reset rte_pie run-time data
587 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
588 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
589 *tcfg->tvar->enqueued = 0;
590 *tcfg->tvar->dropped = 0;
592 if (increase_qsize(&tcfg->tconfig->pconfig[i],
593 tcfg->tqueue->pdata_in,
596 tcfg->tqueue->q_ramp_up) != 0) {
597 fprintf(stderr, "Fail: increase qsize\n");
602 for (i = 0; i < RTE_DIM(ft_tlevels); i++) {
603 const char *label = NULL;
606 double drop_rate = 1.0;
607 double drop_prob = 0.0;
610 enqueue_dequeue_func(&tcfg->tconfig->pconfig[i],
611 tcfg->tqueue->pdata_in,
614 tcfg->tvar->enqueued,
615 tcfg->tvar->dropped);
617 drop_rate = calc_drop_rate(*tcfg->tvar->enqueued,
618 *tcfg->tvar->dropped);
619 drop_prob = rte_pie_get_drop_prob(NULL, tcfg->tqueue->pdata_in);
621 if (drop_prob != 0) {
622 fprintf(stderr, "Fail: check drop prob\n");
626 if (drop_rate != 0) {
627 fprintf(stderr, "Fail: check drop rate\n");
632 active = rte_pie_get_active(NULL, tcfg->tqueue->pdata_in);
633 printf("%s%-16u%-12u%-12u%-12.4lf%-12.4lf%-12.4lf%-12.4lf%-8i\n",
634 label, prob, *tcfg->tvar->enqueued, *tcfg->tvar->dropped,
635 drop_prob * 100.0, drop_rate * 100.0, diff,
636 (double)tcfg->tqueue->drop_tolerance, active);
643 * setup default values for the Performance test structures
645 static struct rte_pie_config pt_wrconfig[1];
646 static struct rte_pie pt_rtdata[1];
647 static struct rte_pie pt_wtdata[1];
648 static uint32_t pt_q[] = {0};
649 static uint32_t pt_dropped[] = {0};
650 static uint32_t pt_enqueued[] = {0};
651 static uint32_t pt_dequeued[] = {0};
652 static uint16_t pt_max_burst[] = {64};
653 static uint16_t pt_dp_update_interval[] = {150};
655 static struct test_rte_pie_config pt_tconfig = {
656 .pconfig = pt_wrconfig,
657 .num_cfg = RTE_DIM(pt_wrconfig),
659 .dp_update_interval = pt_dp_update_interval,
660 .max_burst = pt_max_burst,
664 static struct test_queue pt_tqueue = {
665 .pdata_in = pt_rtdata,
666 .num_queues = RTE_DIM(pt_rtdata),
668 .q_ramp_up = 1000000,
669 .drop_tolerance = 0, /* 0 percent */
672 static struct test_rte_pie_config pt_tconfig2 = {
673 .pconfig = pt_wrconfig,
674 .num_cfg = RTE_DIM(pt_wrconfig),
676 .dp_update_interval = pt_dp_update_interval,
677 .max_burst = pt_max_burst,
681 static struct test_queue pt_tqueue2 = {
682 .pdata_in = pt_rtdata,
683 .pdata_out = pt_wtdata,
684 .num_queues = RTE_DIM(pt_rtdata),
686 .q_ramp_up = 1000000,
687 .drop_tolerance = 0, /* 0 percent */
691 * enqueue/dequeue packets
693 * rte_sched_port_enqueue(port, in_mbufs, 10);
694 * rte_sched_port_dequeue(port, out_mbufs, 10);
696 static void enqueue_dequeue_perf(struct rte_pie_config *pie_cfg,
697 struct rte_pie *pie_in,
698 struct rte_pie *pie_out,
704 struct rdtsc_prof *prof)
708 if (pie_cfg == NULL) {
709 printf("%s: Error: PIE configuration cannot be empty.\n", __func__);
713 if (pie_in == NULL) {
714 printf("%s: Error: PIE enqueue data cannot be empty.\n", __func__);
718 for (i = 0; i < num_ops; i++) {
726 rdtsc_prof_start(prof);
727 ret = rte_pie_enqueue(pie_cfg, pie_in, *qlen,
728 1000*sizeof(uint32_t), ts);
729 rdtsc_prof_end(prof);
736 if (pie_out != NULL) {
738 rdtsc_prof_start(prof);
739 rte_pie_dequeue(pie_out, 1000*sizeof(uint32_t), ts);
740 rdtsc_prof_end(prof);
748 * Setup test structures for tests P1
749 * performance tests 1
751 static uint32_t pt1_tlevel[] = {80};
753 static struct test_var perf1_tvar = {
757 .dropped = pt_dropped,
758 .enqueued = pt_enqueued
761 static struct test_config perf_test_config = {
762 .ifname = "performance test 1 interface",
763 .msg = "performance test 1 : use one PIE configuration,\n"
764 " measure enqueue performance\n\n",
765 .tconfig = &pt_tconfig,
766 .tqueue = &pt_tqueue,
768 .tlevel = pt1_tlevel,
772 * Performance test function to measure enqueue performance.
775 static enum test_result perf_test(struct test_config *tcfg)
777 enum test_result result = PASS;
778 struct rdtsc_prof prof = {0, 0, 0, 0, 0.0, NULL};
781 printf("%s", tcfg->msg);
783 rdtsc_prof_init(&prof, "enqueue");
785 if (test_rte_pie_init(tcfg) != PASS) {
791 * initialize the rte_pie run time data structure
793 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
794 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
795 *tcfg->tvar->enqueued = 0;
796 *tcfg->tvar->dropped = 0;
798 enqueue_dequeue_perf(tcfg->tconfig->pconfig,
799 tcfg->tqueue->pdata_in,
803 tcfg->tvar->enqueued,
805 tcfg->tvar->dequeued,
808 total = *tcfg->tvar->enqueued + *tcfg->tvar->dropped;
810 printf("\ntotal: %u, enqueued: %u (%.2lf%%), dropped: %u (%.2lf%%)\n",
811 total, *tcfg->tvar->enqueued,
812 ((double)(*tcfg->tvar->enqueued) / (double)total) * 100.0,
813 *tcfg->tvar->dropped,
814 ((double)(*tcfg->tvar->dropped) / (double)total) * 100.0);
816 rdtsc_prof_print(&prof);
824 * Setup test structures for tests P2
825 * performance tests 2
827 static uint32_t pt2_tlevel[] = {80};
829 static struct test_var perf2_tvar = {
833 .dropped = pt_dropped,
834 .enqueued = pt_enqueued,
835 .dequeued = pt_dequeued
838 static struct test_config perf_test_config2 = {
839 .ifname = "performance test 2 interface",
840 .msg = "performance test 2 : use one PIE configuration,\n"
841 " measure enqueue & dequeue performance\n\n",
842 .tconfig = &pt_tconfig2,
843 .tqueue = &pt_tqueue2,
845 .tlevel = pt2_tlevel,
849 * Performance test function to measure enqueue & dequeue performance.
852 static enum test_result perf_test2(struct test_config *tcfg)
854 enum test_result result = PASS;
855 struct rdtsc_prof prof = {0, 0, 0, 0, 0.0, NULL};
858 printf("%s", tcfg->msg);
860 rdtsc_prof_init(&prof, "enqueue");
862 if (test_rte_pie_init(tcfg) != PASS) {
868 * initialize the rte_pie run time data structure
870 rte_pie_rt_data_init(tcfg->tqueue->pdata_in);
871 rte_pie_set_active(NULL, tcfg->tqueue->pdata_in, 1);
872 *tcfg->tvar->enqueued = 0;
873 *tcfg->tvar->dequeued = 0;
874 *tcfg->tvar->dropped = 0;
876 enqueue_dequeue_perf(tcfg->tconfig->pconfig,
877 tcfg->tqueue->pdata_in,
878 tcfg->tqueue->pdata_out,
881 tcfg->tvar->enqueued,
883 tcfg->tvar->dequeued,
886 total = *tcfg->tvar->enqueued + *tcfg->tvar->dropped;
888 printf("\ntotal: %u, dequeued: %u (%.2lf%%), dropped: %u (%.2lf%%)\n",
889 total, *tcfg->tvar->dequeued,
890 ((double)(*tcfg->tvar->dequeued) / (double)total) * 100.0,
891 *tcfg->tvar->dropped,
892 ((double)(*tcfg->tvar->dropped) / (double)total) * 100.0);
894 rdtsc_prof_print(&prof);
900 * define the functional tests to be executed fast
902 struct tests func_pie_tests_quick[] = {
903 { &func_test_config1, func_test1 },
904 { &func_test_config2, func_test2 },
908 * define the functional and performance tests to be executed
910 struct tests func_pie_tests[] = {
911 { &func_test_config1, func_test1 },
912 { &func_test_config2, func_test2 },
913 { &func_test_config3, func_test3 },
916 struct tests perf_pie_tests[] = {
917 { &perf_test_config, perf_test },
918 { &perf_test_config2, perf_test2 },
922 * function to execute the required pie tests
924 static void run_tests(struct tests *test_type, uint32_t test_count,
925 uint32_t *num_tests, uint32_t *num_pass)
927 enum test_result result = PASS;
929 static const char *bar_str = "-------------------------------------"
930 "-------------------------------------------";
931 static const char *bar_pass_str = "-------------------------------------"
932 "<pass>-------------------------------------";
933 static const char *bar_fail_str = "-------------------------------------"
934 "<fail>-------------------------------------";
936 for (i = 0; i < test_count; i++) {
937 printf("\n%s\n", bar_str);
938 result = test_type[i].testfn(test_type[i].testcfg);
940 if (result == PASS) {
942 printf("%s\n", bar_pass_str);
944 printf("%s\n", bar_fail_str);
950 * check if functions accept invalid parameters
952 * First, all functions will be called without initialized PIE
953 * Then, all of them will be called with NULL/invalid parameters
955 * Some functions are not tested as they are performance-critical and thus
956 * don't do any parameter checking.
959 test_invalid_parameters(void)
961 struct rte_pie_config config;
962 static const char *shf_str = "rte_pie_config_init should have failed!";
963 static const char *shf_rt_str = "rte_pie_rt_data_init should have failed!";
966 if (rte_pie_rt_data_init(NULL) == 0) {
967 printf("%i: %s\n", __LINE__, shf_rt_str);
972 if (rte_pie_config_init(NULL, 0, 0, 0, 0) == 0) {
973 printf("%i%s\n", __LINE__, shf_str);
977 /* qdelay_ref <= 0 */
978 if (rte_pie_config_init(&config, 0, 1, 1, 1) == 0) {
979 printf("%i%s\n", __LINE__, shf_str);
983 /* dp_update_interval <= 0 */
984 if (rte_pie_config_init(&config, 1, 0, 1, 1) == 0) {
985 printf("%i%s\n", __LINE__, shf_str);
990 if (rte_pie_config_init(&config, 1, 1, 0, 1) == 0) {
991 printf("%i%s\n", __LINE__, shf_str);
996 if (rte_pie_config_init(&config, 1, 1, 1, 0) == 0) {
997 printf("%i%s\n", __LINE__, shf_str);
1001 RTE_SET_USED(config);
1007 show_stats(const uint32_t num_tests, const uint32_t num_pass)
1009 if (num_pass == num_tests)
1010 printf("[total: %u, pass: %u]\n", num_tests, num_pass);
1012 printf("[total: %u, pass: %u, fail: %u]\n", num_tests, num_pass,
1013 num_tests - num_pass);
1017 tell_the_result(const uint32_t num_tests, const uint32_t num_pass)
1019 return (num_pass == num_tests) ? 0 : 1;
1025 uint32_t num_tests = 0;
1026 uint32_t num_pass = 0;
1028 if (test_invalid_parameters() < 0)
1031 run_tests(func_pie_tests_quick, RTE_DIM(func_pie_tests_quick),
1032 &num_tests, &num_pass);
1033 show_stats(num_tests, num_pass);
1034 return tell_the_result(num_tests, num_pass);
1040 uint32_t num_tests = 0;
1041 uint32_t num_pass = 0;
1043 run_tests(perf_pie_tests, RTE_DIM(perf_pie_tests), &num_tests, &num_pass);
1044 show_stats(num_tests, num_pass);
1045 return tell_the_result(num_tests, num_pass);
1051 uint32_t num_tests = 0;
1052 uint32_t num_pass = 0;
1054 if (test_invalid_parameters() < 0)
1057 run_tests(func_pie_tests, RTE_DIM(func_pie_tests), &num_tests, &num_pass);
1058 run_tests(perf_pie_tests, RTE_DIM(perf_pie_tests), &num_tests, &num_pass);
1059 show_stats(num_tests, num_pass);
1060 return tell_the_result(num_tests, num_pass);
1063 REGISTER_TEST_COMMAND(pie_autotest, test_pie);
1064 REGISTER_TEST_COMMAND(pie_perf, test_pie_perf);
1065 REGISTER_TEST_COMMAND(pie_all, test_pie_all);