1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
13 #include <rte_cycles.h>
14 #include <rte_meter.h>
16 #define mlog(format, ...) do{\
17 printf("Line %d:",__LINE__);\
18 printf(format, ##__VA_ARGS__);\
22 #define melog(format, ...) do{\
23 printf("Line %d:",__LINE__);\
24 printf(format, ##__VA_ARGS__);\
25 printf(" failed!\n");\
29 #define TM_TEST_SRTCM_CIR_DF 46000000
30 #define TM_TEST_SRTCM_CBS_DF 2048
31 #define TM_TEST_SRTCM_EBS_DF 4096
33 #define TM_TEST_TRTCM_CIR_DF 46000000
34 #define TM_TEST_TRTCM_PIR_DF 69000000
35 #define TM_TEST_TRTCM_EIR_DF 69000000
36 #define TM_TEST_TRTCM_CBS_DF 2048
37 #define TM_TEST_TRTCM_PBS_DF 4096
38 #define TM_TEST_TRTCM_EBS_DF 4096
40 static struct rte_meter_srtcm_params sparams =
41 {.cir = TM_TEST_SRTCM_CIR_DF,
42 .cbs = TM_TEST_SRTCM_CBS_DF,
43 .ebs = TM_TEST_SRTCM_EBS_DF,};
45 static struct rte_meter_trtcm_params tparams=
46 {.cir = TM_TEST_TRTCM_CIR_DF,
47 .pir = TM_TEST_TRTCM_PIR_DF,
48 .cbs = TM_TEST_TRTCM_CBS_DF,
49 .pbs = TM_TEST_TRTCM_PBS_DF,};
51 static struct rte_meter_trtcm_rfc4115_params rfc4115params =
52 {.cir = TM_TEST_TRTCM_CIR_DF,
53 .eir = TM_TEST_TRTCM_EIR_DF,
54 .cbs = TM_TEST_TRTCM_CBS_DF,
55 .ebs = TM_TEST_TRTCM_EBS_DF,};
58 * functional test for rte_meter_srtcm_config
61 tm_test_srtcm_config(void)
63 #define SRTCM_CFG_MSG "srtcm_config"
64 struct rte_meter_srtcm_profile sp;
65 struct rte_meter_srtcm_params sparams1;
67 /* invalid parameter test */
68 if (rte_meter_srtcm_profile_config(NULL, NULL) == 0)
70 if (rte_meter_srtcm_profile_config(&sp, NULL) == 0)
72 if (rte_meter_srtcm_profile_config(NULL, &sparams) == 0)
75 /* cbs and ebs can't both be zero */
79 if (rte_meter_srtcm_profile_config(&sp, &sparams1) == 0)
82 /* cir should never be 0 */
85 if (rte_meter_srtcm_profile_config(&sp, &sparams1) == 0)
88 /* one of ebs and cbs can be zero, should be successful */
91 if (rte_meter_srtcm_profile_config(&sp, &sparams1) != 0)
96 if (rte_meter_srtcm_profile_config(&sp, &sparams1) != 0)
99 /* usual parameter, should be successful */
100 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
101 melog(SRTCM_CFG_MSG);
108 * functional test for rte_meter_trtcm_config
111 tm_test_trtcm_config(void)
113 struct rte_meter_trtcm_profile tp;
114 struct rte_meter_trtcm_params tparams1;
115 #define TRTCM_CFG_MSG "trtcm_config"
117 /* invalid parameter test */
118 if (rte_meter_trtcm_profile_config(NULL, NULL) == 0)
119 melog(TRTCM_CFG_MSG);
120 if (rte_meter_trtcm_profile_config(&tp, NULL) == 0)
121 melog(TRTCM_CFG_MSG);
122 if (rte_meter_trtcm_profile_config(NULL, &tparams) == 0)
123 melog(TRTCM_CFG_MSG);
125 /* cir, cbs, pir and pbs never be zero */
128 if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
129 melog(TRTCM_CFG_MSG);
133 if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
134 melog(TRTCM_CFG_MSG);
138 if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
139 melog(TRTCM_CFG_MSG);
143 if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
144 melog(TRTCM_CFG_MSG);
146 /* pir should be greater or equal to cir */
148 tparams1.pir = tparams1.cir - 1;
149 if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
150 melog(TRTCM_CFG_MSG" pir < cir test");
152 /* usual parameter, should be successful */
153 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
154 melog(TRTCM_CFG_MSG);
160 * functional test for rte_meter_trtcm_rfc4115_config
163 tm_test_trtcm_rfc4115_config(void)
165 struct rte_meter_trtcm_rfc4115_profile tp;
166 struct rte_meter_trtcm_rfc4115_params rfc4115params1;
167 #define TRTCM_RFC4115_CFG_MSG "trtcm_rfc4115_config"
169 /* invalid parameter test */
170 if (rte_meter_trtcm_rfc4115_profile_config(NULL, NULL) == 0)
171 melog(TRTCM_RFC4115_CFG_MSG);
172 if (rte_meter_trtcm_rfc4115_profile_config(&tp, NULL) == 0)
173 melog(TRTCM_RFC4115_CFG_MSG);
174 if (rte_meter_trtcm_rfc4115_profile_config(NULL, &rfc4115params) == 0)
175 melog(TRTCM_RFC4115_CFG_MSG);
178 * cbs and pbs should be none-zero if cir and eir are none-zero
181 rfc4115params1 = rfc4115params;
182 rfc4115params1.cbs = 0;
183 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params1) == 0)
184 melog(TRTCM_RFC4115_CFG_MSG);
186 rfc4115params1 = rfc4115params;
187 rfc4115params1.ebs = 0;
188 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params1) == 0)
189 melog(TRTCM_RFC4115_CFG_MSG);
191 /* usual parameter, should be successful */
192 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
193 melog(TRTCM_RFC4115_CFG_MSG);
199 * functional test for rte_meter_srtcm_color_blind_check
202 tm_test_srtcm_color_blind_check(void)
204 #define SRTCM_BLIND_CHECK_MSG "srtcm_blind_check"
205 struct rte_meter_srtcm_profile sp;
206 struct rte_meter_srtcm sm;
208 uint64_t hz = rte_get_tsc_hz();
211 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
212 melog(SRTCM_BLIND_CHECK_MSG);
213 if (rte_meter_srtcm_config(&sm, &sp) != 0)
214 melog(SRTCM_BLIND_CHECK_MSG);
215 time = rte_get_tsc_cycles() + hz;
216 if (rte_meter_srtcm_color_blind_check(
217 &sm, &sp, time, TM_TEST_SRTCM_CBS_DF - 1)
219 melog(SRTCM_BLIND_CHECK_MSG" GREEN");
222 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
223 melog(SRTCM_BLIND_CHECK_MSG);
224 if (rte_meter_srtcm_config(&sm, &sp) != 0)
225 melog(SRTCM_BLIND_CHECK_MSG);
226 time = rte_get_tsc_cycles() + hz;
227 if (rte_meter_srtcm_color_blind_check(
228 &sm, &sp, time, TM_TEST_SRTCM_CBS_DF + 1)
230 melog(SRTCM_BLIND_CHECK_MSG" YELLOW");
232 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
233 melog(SRTCM_BLIND_CHECK_MSG);
234 if (rte_meter_srtcm_config(&sm, &sp) != 0)
235 melog(SRTCM_BLIND_CHECK_MSG);
236 time = rte_get_tsc_cycles() + hz;
237 if (rte_meter_srtcm_color_blind_check(
238 &sm, &sp, time, (uint32_t)sp.ebs - 1) != RTE_COLOR_YELLOW)
239 melog(SRTCM_BLIND_CHECK_MSG" YELLOW");
242 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
243 melog(SRTCM_BLIND_CHECK_MSG);
244 if (rte_meter_srtcm_config(&sm, &sp) != 0)
245 melog(SRTCM_BLIND_CHECK_MSG);
246 time = rte_get_tsc_cycles() + hz;
247 if (rte_meter_srtcm_color_blind_check(
248 &sm, &sp, time, TM_TEST_SRTCM_EBS_DF + 1)
250 melog(SRTCM_BLIND_CHECK_MSG" RED");
257 * functional test for rte_meter_trtcm_color_blind_check
260 tm_test_trtcm_color_blind_check(void)
262 #define TRTCM_BLIND_CHECK_MSG "trtcm_blind_check"
265 struct rte_meter_trtcm_profile tp;
266 struct rte_meter_trtcm tm;
267 uint64_t hz = rte_get_tsc_hz();
270 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
271 melog(TRTCM_BLIND_CHECK_MSG);
272 if (rte_meter_trtcm_config(&tm, &tp) != 0)
273 melog(TRTCM_BLIND_CHECK_MSG);
274 time = rte_get_tsc_cycles() + hz;
275 if (rte_meter_trtcm_color_blind_check(
276 &tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1)
278 melog(TRTCM_BLIND_CHECK_MSG" GREEN");
281 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
282 melog(TRTCM_BLIND_CHECK_MSG);
283 if (rte_meter_trtcm_config(&tm, &tp) != 0)
284 melog(TRTCM_BLIND_CHECK_MSG);
285 time = rte_get_tsc_cycles() + hz;
286 if (rte_meter_trtcm_color_blind_check(
287 &tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1)
289 melog(TRTCM_BLIND_CHECK_MSG" YELLOW");
291 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
292 melog(TRTCM_BLIND_CHECK_MSG);
293 if (rte_meter_trtcm_config(&tm, &tp) != 0)
294 melog(TRTCM_BLIND_CHECK_MSG);
295 time = rte_get_tsc_cycles() + hz;
296 if (rte_meter_trtcm_color_blind_check(
297 &tm, &tp, time, TM_TEST_TRTCM_PBS_DF - 1)
299 melog(TRTCM_BLIND_CHECK_MSG" YELLOW");
302 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
303 melog(TRTCM_BLIND_CHECK_MSG);
304 if (rte_meter_trtcm_config(&tm, &tp) != 0)
305 melog(TRTCM_BLIND_CHECK_MSG);
306 time = rte_get_tsc_cycles() + hz;
307 if (rte_meter_trtcm_color_blind_check(
308 &tm, &tp, time, TM_TEST_TRTCM_PBS_DF + 1)
310 melog(TRTCM_BLIND_CHECK_MSG" RED");
316 * functional test for rte_meter_trtcm_rfc4115_color_blind_check
319 tm_test_trtcm_rfc4115_color_blind_check(void)
321 #define TRTCM_RFC4115_BLIND_CHECK_MSG "trtcm_rfc4115_blind_check"
324 struct rte_meter_trtcm_rfc4115_profile tp;
325 struct rte_meter_trtcm_rfc4115 tm;
326 uint64_t hz = rte_get_tsc_hz();
329 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
330 melog(TRTCM_RFC4115_BLIND_CHECK_MSG);
331 if (rte_meter_trtcm_rfc4115_config(&tm, &tp) != 0)
332 melog(TRTCM_RFC4115_BLIND_CHECK_MSG);
333 time = rte_get_tsc_cycles() + hz;
334 if (rte_meter_trtcm_rfc4115_color_blind_check(
335 &tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1)
337 melog(TRTCM_RFC4115_BLIND_CHECK_MSG" GREEN");
340 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
341 melog(TRTCM_RFC4115_BLIND_CHECK_MSG);
342 if (rte_meter_trtcm_rfc4115_config(&tm, &tp) != 0)
343 melog(TRTCM_RFC4115_BLIND_CHECK_MSG);
344 time = rte_get_tsc_cycles() + hz;
345 if (rte_meter_trtcm_rfc4115_color_blind_check(
346 &tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1)
348 melog(TRTCM_RFC4115_BLIND_CHECK_MSG" YELLOW");
350 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
351 melog(TRTCM_RFC4115_BLIND_CHECK_MSG);
352 if (rte_meter_trtcm_rfc4115_config(&tm, &tp) != 0)
353 melog(TRTCM_RFC4115_BLIND_CHECK_MSG);
354 time = rte_get_tsc_cycles() + hz;
355 if (rte_meter_trtcm_rfc4115_color_blind_check(
356 &tm, &tp, time, TM_TEST_TRTCM_EBS_DF - 1)
358 melog(TRTCM_RFC4115_BLIND_CHECK_MSG" YELLOW");
361 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
362 melog(TRTCM_RFC4115_BLIND_CHECK_MSG);
363 if (rte_meter_trtcm_rfc4115_config(&tm, &tp) != 0)
364 melog(TRTCM_RFC4115_BLIND_CHECK_MSG);
365 time = rte_get_tsc_cycles() + hz;
366 if (rte_meter_trtcm_rfc4115_color_blind_check(
367 &tm, &tp, time, TM_TEST_TRTCM_EBS_DF + 1)
369 melog(TRTCM_RFC4115_BLIND_CHECK_MSG" RED");
376 * @in[4] : the flags packets carries.
377 * @in[4] : the flags function expect to return.
378 * It will do blind check at the time of 1 second from beginning.
379 * At the time, it will use packets length of cbs -1, cbs + 1,
380 * ebs -1 and ebs +1 with flag in[0], in[1], in[2] and in[3] to do
381 * aware check, expect flag out[0], out[1], out[2] and out[3]
385 tm_test_srtcm_aware_check
386 (enum rte_color in[4], enum rte_color out[4])
388 #define SRTCM_AWARE_CHECK_MSG "srtcm_aware_check"
389 struct rte_meter_srtcm_profile sp;
390 struct rte_meter_srtcm sm;
392 uint64_t hz = rte_get_tsc_hz();
394 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
395 melog(SRTCM_AWARE_CHECK_MSG);
396 if (rte_meter_srtcm_config(&sm, &sp) != 0)
397 melog(SRTCM_AWARE_CHECK_MSG);
398 time = rte_get_tsc_cycles() + hz;
399 if (rte_meter_srtcm_color_aware_check(
400 &sm, &sp, time, TM_TEST_SRTCM_CBS_DF - 1, in[0]) != out[0])
401 melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[0], out[0]);
403 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
404 melog(SRTCM_AWARE_CHECK_MSG);
405 if (rte_meter_srtcm_config(&sm, &sp) != 0)
406 melog(SRTCM_AWARE_CHECK_MSG);
407 time = rte_get_tsc_cycles() + hz;
408 if (rte_meter_srtcm_color_aware_check(
409 &sm, &sp, time, TM_TEST_SRTCM_CBS_DF + 1, in[1]) != out[1])
410 melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[1], out[1]);
412 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
413 melog(SRTCM_AWARE_CHECK_MSG);
414 if (rte_meter_srtcm_config(&sm, &sp) != 0)
415 melog(SRTCM_AWARE_CHECK_MSG);
416 time = rte_get_tsc_cycles() + hz;
417 if (rte_meter_srtcm_color_aware_check(
418 &sm, &sp, time, TM_TEST_SRTCM_EBS_DF - 1, in[2]) != out[2])
419 melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[2], out[2]);
421 if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
422 melog(SRTCM_AWARE_CHECK_MSG);
423 if (rte_meter_srtcm_config(&sm, &sp) != 0)
424 melog(SRTCM_AWARE_CHECK_MSG);
425 time = rte_get_tsc_cycles() + hz;
426 if (rte_meter_srtcm_color_aware_check(
427 &sm, &sp, time, TM_TEST_SRTCM_EBS_DF + 1, in[3]) != out[3])
428 melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[3], out[3]);
435 * functional test for rte_meter_srtcm_color_aware_check
438 tm_test_srtcm_color_aware_check(void)
440 enum rte_color in[4], out[4];
443 * test 4 points that will produce green, yellow, yellow, red flag
444 * if using blind check
447 /* previouly have a green, test points should keep unchanged */
448 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_GREEN;
449 out[0] = RTE_COLOR_GREEN;
450 out[1] = RTE_COLOR_YELLOW;
451 out[2] = RTE_COLOR_YELLOW;
452 out[3] = RTE_COLOR_RED;
453 if (tm_test_srtcm_aware_check(in, out) != 0)
457 * previously have a yellow, green & yellow = yellow
460 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_YELLOW;
461 out[0] = RTE_COLOR_YELLOW;
462 out[1] = RTE_COLOR_YELLOW;
463 out[2] = RTE_COLOR_YELLOW;
464 out[3] = RTE_COLOR_RED;
465 if (tm_test_srtcm_aware_check(in, out) != 0)
469 * previously have a red, red & green = red
472 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_RED;
473 out[0] = RTE_COLOR_RED;
474 out[1] = RTE_COLOR_RED;
475 out[2] = RTE_COLOR_RED;
476 out[3] = RTE_COLOR_RED;
477 if (tm_test_srtcm_aware_check(in, out) != 0)
484 * @in[4] : the flags packets carries.
485 * @in[4] : the flags function expect to return.
486 * It will do blind check at the time of 1 second from beginning.
487 * At the time, it will use packets length of cbs -1, cbs + 1,
488 * ebs -1 and ebs +1 with flag in[0], in[1], in[2] and in[3] to do
489 * aware check, expect flag out[0], out[1], out[2] and out[3]
492 tm_test_trtcm_aware_check
493 (enum rte_color in[4], enum rte_color out[4])
495 #define TRTCM_AWARE_CHECK_MSG "trtcm_aware_check"
496 struct rte_meter_trtcm_profile tp;
497 struct rte_meter_trtcm tm;
499 uint64_t hz = rte_get_tsc_hz();
501 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
502 melog(TRTCM_AWARE_CHECK_MSG);
503 if (rte_meter_trtcm_config(&tm, &tp) != 0)
504 melog(TRTCM_AWARE_CHECK_MSG);
505 time = rte_get_tsc_cycles() + hz;
506 if (rte_meter_trtcm_color_aware_check(
507 &tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1, in[0]) != out[0])
508 melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[0], out[0]);
510 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
511 melog(TRTCM_AWARE_CHECK_MSG);
512 if (rte_meter_trtcm_config(&tm, &tp) != 0)
513 melog(TRTCM_AWARE_CHECK_MSG);
514 time = rte_get_tsc_cycles() + hz;
515 if (rte_meter_trtcm_color_aware_check(
516 &tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1, in[1]) != out[1])
517 melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[1], out[1]);
519 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
520 melog(TRTCM_AWARE_CHECK_MSG);
521 if (rte_meter_trtcm_config(&tm, &tp) != 0)
522 melog(TRTCM_AWARE_CHECK_MSG);
523 time = rte_get_tsc_cycles() + hz;
524 if (rte_meter_trtcm_color_aware_check(
525 &tm, &tp, time, TM_TEST_TRTCM_PBS_DF - 1, in[2]) != out[2])
526 melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[2], out[2]);
528 if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
529 melog(TRTCM_AWARE_CHECK_MSG);
530 if (rte_meter_trtcm_config(&tm, &tp) != 0)
531 melog(TRTCM_AWARE_CHECK_MSG);
532 time = rte_get_tsc_cycles() + hz;
533 if (rte_meter_trtcm_color_aware_check(
534 &tm, &tp, time, TM_TEST_TRTCM_PBS_DF + 1, in[3]) != out[3])
535 melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[3], out[3]);
542 * functional test for rte_meter_trtcm_color_aware_check
546 tm_test_trtcm_color_aware_check(void)
548 enum rte_color in[4], out[4];
550 * test 4 points that will produce green, yellow, yellow, red flag
551 * if using blind check
554 /* previouly have a green, test points should keep unchanged */
555 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_GREEN;
556 out[0] = RTE_COLOR_GREEN;
557 out[1] = RTE_COLOR_YELLOW;
558 out[2] = RTE_COLOR_YELLOW;
559 out[3] = RTE_COLOR_RED;
560 if (tm_test_trtcm_aware_check(in, out) != 0)
563 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_YELLOW;
564 out[0] = RTE_COLOR_YELLOW;
565 out[1] = RTE_COLOR_YELLOW;
566 out[2] = RTE_COLOR_YELLOW;
567 out[3] = RTE_COLOR_RED;
568 if (tm_test_trtcm_aware_check(in, out) != 0)
571 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_RED;
572 out[0] = RTE_COLOR_RED;
573 out[1] = RTE_COLOR_RED;
574 out[2] = RTE_COLOR_RED;
575 out[3] = RTE_COLOR_RED;
576 if (tm_test_trtcm_aware_check(in, out) != 0)
583 * @in[4] : the flags packets carries.
584 * @in[4] : the flags function expect to return.
585 * It will do blind check at the time of 1 second from beginning.
586 * At the time, it will use packets length of cbs -1, cbs + 1,
587 * ebs -1 and ebs +1 with flag in[0], in[1], in[2] and in[3] to do
588 * aware check, expect flag out[0], out[1], out[2] and out[3]
591 tm_test_trtcm_rfc4115_aware_check
592 (enum rte_color in[4], enum rte_color out[4])
594 #define TRTCM_RFC4115_AWARE_CHECK_MSG "trtcm_rfc4115_aware_check"
595 struct rte_meter_trtcm_rfc4115_profile tp;
596 struct rte_meter_trtcm_rfc4115 tm;
598 uint64_t hz = rte_get_tsc_hz();
600 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
601 melog(TRTCM_AWARE_CHECK_MSG);
602 if (rte_meter_trtcm_rfc4115_config(&tm, &tp) != 0)
603 melog(TRTCM_RFC4115_AWARE_CHECK_MSG);
604 time = rte_get_tsc_cycles() + hz;
605 if (rte_meter_trtcm_rfc4115_color_aware_check(
606 &tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1, in[0]) != out[0])
607 melog(TRTCM_RFC4115_AWARE_CHECK_MSG" %u:%u", in[0], out[0]);
609 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
610 melog(TRTCM_RFC4115_AWARE_CHECK_MSG);
611 if (rte_meter_trtcm_rfc4115_config(&tm, &tp) != 0)
612 melog(TRTCM_RFC4115_AWARE_CHECK_MSG);
613 time = rte_get_tsc_cycles() + hz;
614 if (rte_meter_trtcm_rfc4115_color_aware_check(
615 &tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1, in[1]) != out[1])
616 melog(TRTCM_RFC4115_AWARE_CHECK_MSG" %u:%u", in[1], out[1]);
618 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
619 melog(TRTCM_RFC4115_AWARE_CHECK_MSG);
620 if (rte_meter_trtcm_rfc4115_config(&tm, &tp) != 0)
621 melog(TRTCM_RFC4115_AWARE_CHECK_MSG);
622 time = rte_get_tsc_cycles() + hz;
623 if (rte_meter_trtcm_rfc4115_color_aware_check(
624 &tm, &tp, time, TM_TEST_TRTCM_EBS_DF - 1, in[2]) != out[2])
625 melog(TRTCM_RFC4115_AWARE_CHECK_MSG" %u:%u", in[2], out[2]);
627 if (rte_meter_trtcm_rfc4115_profile_config(&tp, &rfc4115params) != 0)
628 melog(TRTCM_RFC4115_AWARE_CHECK_MSG);
629 if (rte_meter_trtcm_rfc4115_config(&tm, &tp) != 0)
630 melog(TRTCM_RFC4115_AWARE_CHECK_MSG);
631 time = rte_get_tsc_cycles() + hz;
632 if (rte_meter_trtcm_rfc4115_color_aware_check(
633 &tm, &tp, time, TM_TEST_TRTCM_EBS_DF + 1, in[3]) != out[3])
634 melog(TRTCM_RFC4115_AWARE_CHECK_MSG" %u:%u", in[3], out[3]);
640 * functional test for rte_meter_trtcm_rfc4115_color_aware_check
643 tm_test_trtcm_rfc4115_color_aware_check(void)
645 enum rte_color in[4], out[4];
647 * test 4 points that will produce green, yellow, yellow, red flag
648 * if using blind check
651 /* previouly have a green, test points should keep unchanged */
652 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_GREEN;
653 out[0] = RTE_COLOR_GREEN;
654 out[1] = RTE_COLOR_YELLOW;
655 out[2] = RTE_COLOR_YELLOW;
656 out[3] = RTE_COLOR_RED;
657 if (tm_test_trtcm_rfc4115_aware_check(in, out) != 0)
660 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_YELLOW;
661 out[0] = RTE_COLOR_YELLOW;
662 out[1] = RTE_COLOR_YELLOW;
663 out[2] = RTE_COLOR_YELLOW;
664 out[3] = RTE_COLOR_RED;
665 if (tm_test_trtcm_rfc4115_aware_check(in, out) != 0)
668 in[0] = in[1] = in[2] = in[3] = RTE_COLOR_RED;
669 out[0] = RTE_COLOR_RED;
670 out[1] = RTE_COLOR_RED;
671 out[2] = RTE_COLOR_RED;
672 out[3] = RTE_COLOR_RED;
673 if (tm_test_trtcm_rfc4115_aware_check(in, out) != 0)
680 * test main entrance for library meter
685 if (tm_test_srtcm_config() != 0)
688 if (tm_test_trtcm_config() != 0)
691 if (tm_test_trtcm_rfc4115_config() != 0)
694 if (tm_test_srtcm_color_blind_check() != 0)
697 if (tm_test_trtcm_color_blind_check() != 0)
700 if (tm_test_trtcm_rfc4115_color_blind_check() != 0)
703 if (tm_test_srtcm_color_aware_check() != 0)
706 if (tm_test_trtcm_color_aware_check() != 0)
709 if (tm_test_trtcm_rfc4115_color_aware_check() != 0)
716 REGISTER_TEST_COMMAND(meter_autotest, test_meter);