Lines Matching +full:test +full:- +full:rules
1 // SPDX-License-Identifier: BSD-3-Clause
3 * Microchip VCAP API kunit test suite
6 #include <kunit/test.h>
11 /* First we have the test infrastructure that emulates the platform
39 if (kslist->cnt > 0) { in test_val_keyset()
40 switch (admin->vtype) { in test_val_keyset()
42 for (idx = 0; idx < kslist->cnt; idx++) { in test_val_keyset()
43 if (kslist->keysets[idx] == VCAP_KFS_ETAG) in test_val_keyset()
44 return kslist->keysets[idx]; in test_val_keyset()
45 if (kslist->keysets[idx] == VCAP_KFS_PURE_5TUPLE_IP4) in test_val_keyset()
46 return kslist->keysets[idx]; in test_val_keyset()
47 if (kslist->keysets[idx] == VCAP_KFS_NORMAL_5TUPLE_IP4) in test_val_keyset()
48 return kslist->keysets[idx]; in test_val_keyset()
49 if (kslist->keysets[idx] == VCAP_KFS_NORMAL_7TUPLE) in test_val_keyset()
50 return kslist->keysets[idx]; in test_val_keyset()
54 for (idx = 0; idx < kslist->cnt; idx++) { in test_val_keyset()
55 if (kslist->keysets[idx] == VCAP_KFS_MAC_ETYPE) in test_val_keyset()
56 return kslist->keysets[idx]; in test_val_keyset()
57 if (kslist->keysets[idx] == VCAP_KFS_ARP) in test_val_keyset()
58 return kslist->keysets[idx]; in test_val_keyset()
59 if (kslist->keysets[idx] == VCAP_KFS_IP_7TUPLE) in test_val_keyset()
60 return kslist->keysets[idx]; in test_val_keyset()
65 __func__, __LINE__, admin->vtype); in test_val_keyset()
69 return -EINVAL; in test_val_keyset()
77 if (admin->vinst == 0 || admin->vinst == 2) in test_add_def_fields()
87 memset(admin->cache.keystream, 0, test_cache_erase_count); in test_cache_erase()
88 memset(admin->cache.maskstream, 0, test_cache_erase_count); in test_cache_erase()
89 memset(admin->cache.actionstream, 0, test_cache_erase_count); in test_cache_erase()
112 keystr = &admin->cache.keystream[start]; in test_cache_read()
113 mskstr = &admin->cache.maskstream[start]; in test_cache_read()
126 actstr = &admin->cache.actionstream[start]; in test_cache_read()
135 admin->cache.counter = test_hw_cache.counter; in test_cache_read()
136 admin->cache.sticky = test_hw_cache.sticky; in test_cache_read()
153 keystr = &admin->cache.keystream[start]; in test_cache_write()
154 mskstr = &admin->cache.maskstream[start]; in test_cache_write()
167 actstr = &admin->cache.actionstream[start]; in test_cache_write()
176 test_hw_cache.counter = admin->cache.counter; in test_cache_write()
177 test_hw_cache.sticky = admin->cache.sticky; in test_cache_write()
236 INIT_LIST_HEAD(&admin->list); in vcap_test_api_init()
237 INIT_LIST_HEAD(&admin->rules); in vcap_test_api_init()
238 INIT_LIST_HEAD(&admin->enabled); in vcap_test_api_init()
239 mutex_init(&admin->lock); in vcap_test_api_init()
240 list_add_tail(&admin->list, &test_vctrl.list); in vcap_test_api_init()
246 static void test_vcap_xn_rule_creator(struct kunit *test, int cid, in test_vcap_xn_rule_creator() argument
285 KUNIT_ASSERT_NE(test, VCAP_KFS_NO_VALUE, keyset); in test_vcap_xn_rule_creator()
290 KUNIT_EXPECT_PTR_NE(test, NULL, rule); in test_vcap_xn_rule_creator()
304 KUNIT_EXPECT_EQ(test, 0, ret); in test_vcap_xn_rule_creator()
305 KUNIT_EXPECT_EQ(test, keyset, rule->keyset); in test_vcap_xn_rule_creator()
306 KUNIT_EXPECT_EQ(test, actionset, rule->actionset); in test_vcap_xn_rule_creator()
307 KUNIT_EXPECT_EQ(test, size, ri->size); in test_vcap_xn_rule_creator()
311 KUNIT_EXPECT_EQ(test, 0, ret); in test_vcap_xn_rule_creator()
312 KUNIT_EXPECT_EQ(test, expected_addr, ri->addr); in test_vcap_xn_rule_creator()
326 /* Define the test cases. */
328 static void vcap_api_set_bit_1_test(struct kunit *test) in vcap_api_set_bit_1_test() argument
341 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[0]); in vcap_api_set_bit_1_test()
342 KUNIT_EXPECT_EQ(test, (u32)BIT(20), stream[1]); in vcap_api_set_bit_1_test()
345 static void vcap_api_set_bit_0_test(struct kunit *test) in vcap_api_set_bit_0_test() argument
358 KUNIT_EXPECT_EQ(test, (u32)~0, stream[0]); in vcap_api_set_bit_0_test()
359 KUNIT_EXPECT_EQ(test, (u32)~0, stream[1]); in vcap_api_set_bit_0_test()
360 KUNIT_EXPECT_EQ(test, (u32)~BIT(11), stream[2]); in vcap_api_set_bit_0_test()
363 static void vcap_api_iterator_init_test(struct kunit *test) in vcap_api_iterator_init_test() argument
380 KUNIT_EXPECT_EQ(test, 52, iter.sw_width); in vcap_api_iterator_init_test()
381 KUNIT_EXPECT_EQ(test, 86 + 2, iter.offset); in vcap_api_iterator_init_test()
382 KUNIT_EXPECT_EQ(test, 3, iter.reg_idx); in vcap_api_iterator_init_test()
383 KUNIT_EXPECT_EQ(test, 4, iter.reg_bitpos); in vcap_api_iterator_init_test()
387 KUNIT_EXPECT_EQ(test, 49, iter.sw_width); in vcap_api_iterator_init_test()
388 KUNIT_EXPECT_EQ(test, 134 + 7, iter.offset); in vcap_api_iterator_init_test()
389 KUNIT_EXPECT_EQ(test, 5, iter.reg_idx); in vcap_api_iterator_init_test()
390 KUNIT_EXPECT_EQ(test, 11, iter.reg_bitpos); in vcap_api_iterator_init_test()
393 static void vcap_api_iterator_next_test(struct kunit *test) in vcap_api_iterator_next_test() argument
409 KUNIT_EXPECT_EQ(test, 49, iter.sw_width); in vcap_api_iterator_next_test()
410 KUNIT_EXPECT_EQ(test, 86 + 5, iter.offset); in vcap_api_iterator_next_test()
411 KUNIT_EXPECT_EQ(test, 3, iter.reg_idx); in vcap_api_iterator_next_test()
412 KUNIT_EXPECT_EQ(test, 10, iter.reg_bitpos); in vcap_api_iterator_next_test()
416 KUNIT_EXPECT_EQ(test, 91 + 1, iter.offset); in vcap_api_iterator_next_test()
417 KUNIT_EXPECT_EQ(test, 3, iter.reg_idx); in vcap_api_iterator_next_test()
418 KUNIT_EXPECT_EQ(test, 11, iter.reg_bitpos); in vcap_api_iterator_next_test()
423 KUNIT_EXPECT_EQ(test, 92 + 6 + 2, iter.offset); in vcap_api_iterator_next_test()
424 KUNIT_EXPECT_EQ(test, 4, iter.reg_idx); in vcap_api_iterator_next_test()
425 KUNIT_EXPECT_EQ(test, 2, iter.reg_bitpos); in vcap_api_iterator_next_test()
428 static void vcap_api_encode_typegroups_test(struct kunit *test) in vcap_api_encode_typegroups_test() argument
443 KUNIT_EXPECT_EQ(test, (u32)0x8, stream[0]); in vcap_api_encode_typegroups_test()
444 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[1]); in vcap_api_encode_typegroups_test()
445 KUNIT_EXPECT_EQ(test, (u32)0x1, stream[2]); in vcap_api_encode_typegroups_test()
446 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[3]); in vcap_api_encode_typegroups_test()
447 KUNIT_EXPECT_EQ(test, (u32)0x3, stream[4]); in vcap_api_encode_typegroups_test()
448 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[5]); in vcap_api_encode_typegroups_test()
449 KUNIT_EXPECT_EQ(test, (u32)0x5, stream[6]); in vcap_api_encode_typegroups_test()
450 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[7]); in vcap_api_encode_typegroups_test()
451 KUNIT_EXPECT_EQ(test, (u32)0x2, stream[8]); in vcap_api_encode_typegroups_test()
452 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[9]); in vcap_api_encode_typegroups_test()
453 KUNIT_EXPECT_EQ(test, (u32)27, stream[10]); in vcap_api_encode_typegroups_test()
454 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[11]); in vcap_api_encode_typegroups_test()
457 static void vcap_api_encode_bit_test(struct kunit *test) in vcap_api_encode_bit_test() argument
473 KUNIT_EXPECT_EQ(test, 48, iter.offset); in vcap_api_encode_bit_test()
474 KUNIT_EXPECT_EQ(test, 1, iter.reg_idx); in vcap_api_encode_bit_test()
475 KUNIT_EXPECT_EQ(test, 16, iter.reg_bitpos); in vcap_api_encode_bit_test()
479 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[0]); in vcap_api_encode_bit_test()
480 KUNIT_EXPECT_EQ(test, (u32)BIT(16), stream[1]); in vcap_api_encode_bit_test()
481 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[2]); in vcap_api_encode_bit_test()
484 static void vcap_api_encode_field_test(struct kunit *test) in vcap_api_encode_field_test() argument
506 KUNIT_EXPECT_EQ(test, 91, iter.offset); in vcap_api_encode_field_test()
507 KUNIT_EXPECT_EQ(test, 3, iter.reg_idx); in vcap_api_encode_field_test()
508 KUNIT_EXPECT_EQ(test, 10, iter.reg_bitpos); in vcap_api_encode_field_test()
512 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[0]); in vcap_api_encode_field_test()
513 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[1]); in vcap_api_encode_field_test()
514 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[2]); in vcap_api_encode_field_test()
515 KUNIT_EXPECT_EQ(test, (u32)(0x5 << 10), stream[3]); in vcap_api_encode_field_test()
516 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[4]); in vcap_api_encode_field_test()
520 KUNIT_EXPECT_EQ(test, (u32)0x8, stream[0]); in vcap_api_encode_field_test()
521 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[1]); in vcap_api_encode_field_test()
522 KUNIT_EXPECT_EQ(test, (u32)0x1, stream[2]); in vcap_api_encode_field_test()
523 KUNIT_EXPECT_EQ(test, (u32)(0x5 << 10), stream[3]); in vcap_api_encode_field_test()
524 KUNIT_EXPECT_EQ(test, (u32)0x3, stream[4]); in vcap_api_encode_field_test()
525 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[5]); in vcap_api_encode_field_test()
526 KUNIT_EXPECT_EQ(test, (u32)0x5, stream[6]); in vcap_api_encode_field_test()
527 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[7]); in vcap_api_encode_field_test()
528 KUNIT_EXPECT_EQ(test, (u32)0x2, stream[8]); in vcap_api_encode_field_test()
529 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[9]); in vcap_api_encode_field_test()
530 KUNIT_EXPECT_EQ(test, (u32)27, stream[10]); in vcap_api_encode_field_test()
531 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[11]); in vcap_api_encode_field_test()
535 static void vcap_api_encode_short_field_test(struct kunit *test) in vcap_api_encode_short_field_test() argument
555 KUNIT_EXPECT_EQ(test, 1, iter.regs_per_sw); in vcap_api_encode_short_field_test()
556 KUNIT_EXPECT_EQ(test, 21, iter.sw_width); in vcap_api_encode_short_field_test()
557 KUNIT_EXPECT_EQ(test, 25 + 3 + 2, iter.offset); in vcap_api_encode_short_field_test()
558 KUNIT_EXPECT_EQ(test, 1, iter.reg_idx); in vcap_api_encode_short_field_test()
559 KUNIT_EXPECT_EQ(test, 25 + 3 + 2 - sw_width, iter.reg_bitpos); in vcap_api_encode_short_field_test()
563 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[0]); in vcap_api_encode_short_field_test()
564 KUNIT_EXPECT_EQ(test, (u32)(0x5 << (25 + 3 + 2 - sw_width)), stream[1]); in vcap_api_encode_short_field_test()
565 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[2]); in vcap_api_encode_short_field_test()
566 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[3]); in vcap_api_encode_short_field_test()
567 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[4]); in vcap_api_encode_short_field_test()
568 KUNIT_EXPECT_EQ(test, (u32)0x0, stream[5]); in vcap_api_encode_short_field_test()
572 KUNIT_EXPECT_EQ(test, (u32)7, stream[0]); in vcap_api_encode_short_field_test()
573 KUNIT_EXPECT_EQ(test, (u32)((0x5 << (25 + 3 + 2 - sw_width)) + 3), stream[1]); in vcap_api_encode_short_field_test()
574 KUNIT_EXPECT_EQ(test, (u32)1, stream[2]); in vcap_api_encode_short_field_test()
575 KUNIT_EXPECT_EQ(test, (u32)0, stream[3]); in vcap_api_encode_short_field_test()
576 KUNIT_EXPECT_EQ(test, (u32)0, stream[4]); in vcap_api_encode_short_field_test()
577 KUNIT_EXPECT_EQ(test, (u32)0, stream[5]); in vcap_api_encode_short_field_test()
580 static void vcap_api_encode_keyfield_test(struct kunit *test) in vcap_api_encode_keyfield_test() argument
621 KUNIT_EXPECT_EQ(test, (u32)0x0, keywords[0]); in vcap_api_encode_keyfield_test()
622 KUNIT_EXPECT_EQ(test, (u32)0x0, keywords[1]); in vcap_api_encode_keyfield_test()
623 KUNIT_EXPECT_EQ(test, (u32)(0x04a1 << 6), keywords[2]); in vcap_api_encode_keyfield_test()
624 KUNIT_EXPECT_EQ(test, (u32)0x0, keywords[3]); in vcap_api_encode_keyfield_test()
625 KUNIT_EXPECT_EQ(test, (u32)0x0, keywords[4]); in vcap_api_encode_keyfield_test()
626 KUNIT_EXPECT_EQ(test, (u32)0x0, keywords[5]); in vcap_api_encode_keyfield_test()
627 KUNIT_EXPECT_EQ(test, (u32)0x0, keywords[6]); in vcap_api_encode_keyfield_test()
630 KUNIT_EXPECT_EQ(test, (u32)0x0, maskwords[0]); in vcap_api_encode_keyfield_test()
631 KUNIT_EXPECT_EQ(test, (u32)0x0, maskwords[1]); in vcap_api_encode_keyfield_test()
632 KUNIT_EXPECT_EQ(test, (u32)(0x0fff << 6), maskwords[2]); in vcap_api_encode_keyfield_test()
633 KUNIT_EXPECT_EQ(test, (u32)0x0, maskwords[3]); in vcap_api_encode_keyfield_test()
634 KUNIT_EXPECT_EQ(test, (u32)0x0, maskwords[4]); in vcap_api_encode_keyfield_test()
635 KUNIT_EXPECT_EQ(test, (u32)0x0, maskwords[5]); in vcap_api_encode_keyfield_test()
636 KUNIT_EXPECT_EQ(test, (u32)0x0, maskwords[6]); in vcap_api_encode_keyfield_test()
639 static void vcap_api_encode_max_keyfield_test(struct kunit *test) in vcap_api_encode_max_keyfield_test() argument
700 KUNIT_EXPECT_EQ(test, keyres[idx], keywords[idx]); in vcap_api_encode_max_keyfield_test()
703 KUNIT_EXPECT_EQ(test, mskres[idx], maskwords[idx]); in vcap_api_encode_max_keyfield_test()
706 static void vcap_api_encode_actionfield_test(struct kunit *test) in vcap_api_encode_actionfield_test() argument
744 KUNIT_EXPECT_EQ(test, (u32)0x0, actwords[0]); in vcap_api_encode_actionfield_test()
745 KUNIT_EXPECT_EQ(test, (u32)((0x32 << (35 + 2 + 1 - sw_width)) & 0x1fffff), actwords[1]); in vcap_api_encode_actionfield_test()
746 KUNIT_EXPECT_EQ(test, (u32)((0x32 >> ((2 * sw_width) - 38 - 1))), actwords[2]); in vcap_api_encode_actionfield_test()
747 KUNIT_EXPECT_EQ(test, (u32)0x0, actwords[3]); in vcap_api_encode_actionfield_test()
748 KUNIT_EXPECT_EQ(test, (u32)0x0, actwords[4]); in vcap_api_encode_actionfield_test()
749 KUNIT_EXPECT_EQ(test, (u32)0x0, actwords[5]); in vcap_api_encode_actionfield_test()
750 KUNIT_EXPECT_EQ(test, (u32)0x0, actwords[6]); in vcap_api_encode_actionfield_test()
753 static void vcap_api_keyfield_typegroup_test(struct kunit *test) in vcap_api_keyfield_typegroup_test() argument
758 KUNIT_EXPECT_PTR_NE(test, NULL, tg); in vcap_api_keyfield_typegroup_test()
759 KUNIT_EXPECT_EQ(test, 0, tg[0].offset); in vcap_api_keyfield_typegroup_test()
760 KUNIT_EXPECT_EQ(test, 2, tg[0].width); in vcap_api_keyfield_typegroup_test()
761 KUNIT_EXPECT_EQ(test, 2, tg[0].value); in vcap_api_keyfield_typegroup_test()
762 KUNIT_EXPECT_EQ(test, 156, tg[1].offset); in vcap_api_keyfield_typegroup_test()
763 KUNIT_EXPECT_EQ(test, 1, tg[1].width); in vcap_api_keyfield_typegroup_test()
764 KUNIT_EXPECT_EQ(test, 0, tg[1].value); in vcap_api_keyfield_typegroup_test()
765 KUNIT_EXPECT_EQ(test, 0, tg[2].offset); in vcap_api_keyfield_typegroup_test()
766 KUNIT_EXPECT_EQ(test, 0, tg[2].width); in vcap_api_keyfield_typegroup_test()
767 KUNIT_EXPECT_EQ(test, 0, tg[2].value); in vcap_api_keyfield_typegroup_test()
770 KUNIT_EXPECT_PTR_EQ(test, NULL, tg); in vcap_api_keyfield_typegroup_test()
773 static void vcap_api_actionfield_typegroup_test(struct kunit *test) in vcap_api_actionfield_typegroup_test() argument
778 KUNIT_EXPECT_PTR_NE(test, NULL, tg); in vcap_api_actionfield_typegroup_test()
779 KUNIT_EXPECT_EQ(test, 0, tg[0].offset); in vcap_api_actionfield_typegroup_test()
780 KUNIT_EXPECT_EQ(test, 3, tg[0].width); in vcap_api_actionfield_typegroup_test()
781 KUNIT_EXPECT_EQ(test, 4, tg[0].value); in vcap_api_actionfield_typegroup_test()
782 KUNIT_EXPECT_EQ(test, 110, tg[1].offset); in vcap_api_actionfield_typegroup_test()
783 KUNIT_EXPECT_EQ(test, 2, tg[1].width); in vcap_api_actionfield_typegroup_test()
784 KUNIT_EXPECT_EQ(test, 0, tg[1].value); in vcap_api_actionfield_typegroup_test()
785 KUNIT_EXPECT_EQ(test, 220, tg[2].offset); in vcap_api_actionfield_typegroup_test()
786 KUNIT_EXPECT_EQ(test, 2, tg[2].width); in vcap_api_actionfield_typegroup_test()
787 KUNIT_EXPECT_EQ(test, 0, tg[2].value); in vcap_api_actionfield_typegroup_test()
788 KUNIT_EXPECT_EQ(test, 0, tg[3].offset); in vcap_api_actionfield_typegroup_test()
789 KUNIT_EXPECT_EQ(test, 0, tg[3].width); in vcap_api_actionfield_typegroup_test()
790 KUNIT_EXPECT_EQ(test, 0, tg[3].value); in vcap_api_actionfield_typegroup_test()
793 KUNIT_EXPECT_PTR_EQ(test, NULL, tg); in vcap_api_actionfield_typegroup_test()
796 static void vcap_api_vcap_keyfields_test(struct kunit *test) in vcap_api_vcap_keyfields_test() argument
801 KUNIT_EXPECT_PTR_NE(test, NULL, ft); in vcap_api_vcap_keyfields_test()
805 KUNIT_EXPECT_PTR_EQ(test, NULL, ft); in vcap_api_vcap_keyfields_test()
809 KUNIT_EXPECT_PTR_EQ(test, NULL, ft); in vcap_api_vcap_keyfields_test()
812 static void vcap_api_vcap_actionfields_test(struct kunit *test) in vcap_api_vcap_actionfields_test() argument
817 KUNIT_EXPECT_PTR_NE(test, NULL, ft); in vcap_api_vcap_actionfields_test()
820 KUNIT_EXPECT_PTR_EQ(test, NULL, ft); in vcap_api_vcap_actionfields_test()
823 KUNIT_EXPECT_PTR_EQ(test, NULL, ft); in vcap_api_vcap_actionfields_test()
826 static void vcap_api_encode_rule_keyset_test(struct kunit *test) in vcap_api_encode_rule_keyset_test() argument
901 KUNIT_EXPECT_EQ(test, -EINVAL, ret); in vcap_api_encode_rule_keyset_test()
906 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_keyset_test()
910 KUNIT_EXPECT_EQ(test, (u32)0x00000042, keywords[0]); in vcap_api_encode_rule_keyset_test()
911 KUNIT_EXPECT_EQ(test, (u32)0x00000000, keywords[1]); in vcap_api_encode_rule_keyset_test()
912 KUNIT_EXPECT_EQ(test, (u32)0x00000000, keywords[2]); in vcap_api_encode_rule_keyset_test()
913 KUNIT_EXPECT_EQ(test, (u32)0x00020100, keywords[3]); in vcap_api_encode_rule_keyset_test()
914 KUNIT_EXPECT_EQ(test, (u32)0x60504030, keywords[4]); in vcap_api_encode_rule_keyset_test()
915 KUNIT_EXPECT_EQ(test, (u32)0x00000000, keywords[5]); in vcap_api_encode_rule_keyset_test()
916 KUNIT_EXPECT_EQ(test, (u32)0x00000000, keywords[6]); in vcap_api_encode_rule_keyset_test()
917 KUNIT_EXPECT_EQ(test, (u32)0x0002aaee, keywords[7]); in vcap_api_encode_rule_keyset_test()
918 KUNIT_EXPECT_EQ(test, (u32)0x00000000, keywords[8]); in vcap_api_encode_rule_keyset_test()
919 KUNIT_EXPECT_EQ(test, (u32)0x00000000, keywords[9]); in vcap_api_encode_rule_keyset_test()
920 KUNIT_EXPECT_EQ(test, (u32)0x00000000, keywords[10]); in vcap_api_encode_rule_keyset_test()
921 KUNIT_EXPECT_EQ(test, (u32)0x00000000, keywords[11]); in vcap_api_encode_rule_keyset_test()
924 KUNIT_EXPECT_EQ(test, (u32)~0x00b07f80, maskwords[0]); in vcap_api_encode_rule_keyset_test()
925 KUNIT_EXPECT_EQ(test, (u32)~0xfff00000, maskwords[1]); in vcap_api_encode_rule_keyset_test()
926 KUNIT_EXPECT_EQ(test, (u32)~0xfffffffc, maskwords[2]); in vcap_api_encode_rule_keyset_test()
927 KUNIT_EXPECT_EQ(test, (u32)~0xfff000ff, maskwords[3]); in vcap_api_encode_rule_keyset_test()
928 KUNIT_EXPECT_EQ(test, (u32)~0x00000000, maskwords[4]); in vcap_api_encode_rule_keyset_test()
929 KUNIT_EXPECT_EQ(test, (u32)~0xfffffff0, maskwords[5]); in vcap_api_encode_rule_keyset_test()
930 KUNIT_EXPECT_EQ(test, (u32)~0xfffffffe, maskwords[6]); in vcap_api_encode_rule_keyset_test()
931 KUNIT_EXPECT_EQ(test, (u32)~0xfffc0001, maskwords[7]); in vcap_api_encode_rule_keyset_test()
932 KUNIT_EXPECT_EQ(test, (u32)~0xffffffff, maskwords[8]); in vcap_api_encode_rule_keyset_test()
933 KUNIT_EXPECT_EQ(test, (u32)~0xffffffff, maskwords[9]); in vcap_api_encode_rule_keyset_test()
934 KUNIT_EXPECT_EQ(test, (u32)~0xffffffff, maskwords[10]); in vcap_api_encode_rule_keyset_test()
935 KUNIT_EXPECT_EQ(test, (u32)~0xffffffff, maskwords[11]); in vcap_api_encode_rule_keyset_test()
938 static void vcap_api_encode_rule_actionset_test(struct kunit *test) in vcap_api_encode_rule_actionset_test() argument
977 /* We allow rules with no actions */ in vcap_api_encode_rule_actionset_test()
978 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_actionset_test()
983 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_actionset_test()
986 KUNIT_EXPECT_EQ(test, (u32)0x00000002, actwords[0]); in vcap_api_encode_rule_actionset_test()
987 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[1]); in vcap_api_encode_rule_actionset_test()
988 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[2]); in vcap_api_encode_rule_actionset_test()
989 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[3]); in vcap_api_encode_rule_actionset_test()
990 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[4]); in vcap_api_encode_rule_actionset_test()
991 KUNIT_EXPECT_EQ(test, (u32)0x00100000, actwords[5]); in vcap_api_encode_rule_actionset_test()
992 KUNIT_EXPECT_EQ(test, (u32)0x06400010, actwords[6]); in vcap_api_encode_rule_actionset_test()
993 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[7]); in vcap_api_encode_rule_actionset_test()
994 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[8]); in vcap_api_encode_rule_actionset_test()
995 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[9]); in vcap_api_encode_rule_actionset_test()
996 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[10]); in vcap_api_encode_rule_actionset_test()
997 KUNIT_EXPECT_EQ(test, (u32)0x00000000, actwords[11]); in vcap_api_encode_rule_actionset_test()
1004 list_for_each_entry_safe(ckf, next_ckf, &rule->keyfields, ctrl.list) { in vcap_free_ckf()
1005 list_del(&ckf->ctrl.list); in vcap_free_ckf()
1010 static void vcap_api_rule_add_keyvalue_test(struct kunit *test) in vcap_api_rule_add_keyvalue_test() argument
1031 INIT_LIST_HEAD(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1033 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_keyvalue_test()
1034 ret = list_empty(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1035 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_keyvalue_test()
1036 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield, in vcap_api_rule_add_keyvalue_test()
1038 KUNIT_EXPECT_EQ(test, VCAP_KF_LOOKUP_FIRST_IS, kf->ctrl.key); in vcap_api_rule_add_keyvalue_test()
1039 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, kf->ctrl.type); in vcap_api_rule_add_keyvalue_test()
1040 KUNIT_EXPECT_EQ(test, 0x0, kf->data.u1.value); in vcap_api_rule_add_keyvalue_test()
1041 KUNIT_EXPECT_EQ(test, 0x1, kf->data.u1.mask); in vcap_api_rule_add_keyvalue_test()
1044 INIT_LIST_HEAD(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1046 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_keyvalue_test()
1047 ret = list_empty(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1048 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_keyvalue_test()
1049 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield, in vcap_api_rule_add_keyvalue_test()
1051 KUNIT_EXPECT_EQ(test, VCAP_KF_LOOKUP_FIRST_IS, kf->ctrl.key); in vcap_api_rule_add_keyvalue_test()
1052 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, kf->ctrl.type); in vcap_api_rule_add_keyvalue_test()
1053 KUNIT_EXPECT_EQ(test, 0x1, kf->data.u1.value); in vcap_api_rule_add_keyvalue_test()
1054 KUNIT_EXPECT_EQ(test, 0x1, kf->data.u1.mask); in vcap_api_rule_add_keyvalue_test()
1057 INIT_LIST_HEAD(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1060 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_keyvalue_test()
1061 ret = list_empty(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1062 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_keyvalue_test()
1063 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield, in vcap_api_rule_add_keyvalue_test()
1065 KUNIT_EXPECT_EQ(test, VCAP_KF_LOOKUP_FIRST_IS, kf->ctrl.key); in vcap_api_rule_add_keyvalue_test()
1066 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, kf->ctrl.type); in vcap_api_rule_add_keyvalue_test()
1067 KUNIT_EXPECT_EQ(test, 0x0, kf->data.u1.value); in vcap_api_rule_add_keyvalue_test()
1068 KUNIT_EXPECT_EQ(test, 0x0, kf->data.u1.mask); in vcap_api_rule_add_keyvalue_test()
1071 INIT_LIST_HEAD(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1073 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_keyvalue_test()
1074 ret = list_empty(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1075 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_keyvalue_test()
1076 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield, in vcap_api_rule_add_keyvalue_test()
1078 KUNIT_EXPECT_EQ(test, VCAP_KF_TYPE, kf->ctrl.key); in vcap_api_rule_add_keyvalue_test()
1079 KUNIT_EXPECT_EQ(test, VCAP_FIELD_U32, kf->ctrl.type); in vcap_api_rule_add_keyvalue_test()
1080 KUNIT_EXPECT_EQ(test, 0x98765432, kf->data.u32.value); in vcap_api_rule_add_keyvalue_test()
1081 KUNIT_EXPECT_EQ(test, 0xff00ffab, kf->data.u32.mask); in vcap_api_rule_add_keyvalue_test()
1084 INIT_LIST_HEAD(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1086 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_keyvalue_test()
1087 ret = list_empty(&rule->keyfields); in vcap_api_rule_add_keyvalue_test()
1088 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_keyvalue_test()
1089 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield, in vcap_api_rule_add_keyvalue_test()
1091 KUNIT_EXPECT_EQ(test, VCAP_KF_L3_IP6_SIP, kf->ctrl.key); in vcap_api_rule_add_keyvalue_test()
1092 KUNIT_EXPECT_EQ(test, VCAP_FIELD_U128, kf->ctrl.type); in vcap_api_rule_add_keyvalue_test()
1094 KUNIT_EXPECT_EQ(test, dip.value[idx], kf->data.u128.value[idx]); in vcap_api_rule_add_keyvalue_test()
1096 KUNIT_EXPECT_EQ(test, dip.mask[idx], kf->data.u128.mask[idx]); in vcap_api_rule_add_keyvalue_test()
1105 &rule->actionfields, ctrl.list) { in vcap_free_caf()
1106 list_del(&caf->ctrl.list); in vcap_free_caf()
1111 static void vcap_api_rule_add_actionvalue_test(struct kunit *test) in vcap_api_rule_add_actionvalue_test() argument
1126 INIT_LIST_HEAD(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1128 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_actionvalue_test()
1129 ret = list_empty(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1130 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_actionvalue_test()
1131 af = list_first_entry(&rule->actionfields, in vcap_api_rule_add_actionvalue_test()
1133 KUNIT_EXPECT_EQ(test, VCAP_AF_POLICE_ENA, af->ctrl.action); in vcap_api_rule_add_actionvalue_test()
1134 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, af->ctrl.type); in vcap_api_rule_add_actionvalue_test()
1135 KUNIT_EXPECT_EQ(test, 0x0, af->data.u1.value); in vcap_api_rule_add_actionvalue_test()
1138 INIT_LIST_HEAD(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1140 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_actionvalue_test()
1141 ret = list_empty(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1142 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_actionvalue_test()
1143 af = list_first_entry(&rule->actionfields, in vcap_api_rule_add_actionvalue_test()
1145 KUNIT_EXPECT_EQ(test, VCAP_AF_POLICE_ENA, af->ctrl.action); in vcap_api_rule_add_actionvalue_test()
1146 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, af->ctrl.type); in vcap_api_rule_add_actionvalue_test()
1147 KUNIT_EXPECT_EQ(test, 0x1, af->data.u1.value); in vcap_api_rule_add_actionvalue_test()
1150 INIT_LIST_HEAD(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1152 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_actionvalue_test()
1153 ret = list_empty(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1154 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_actionvalue_test()
1155 af = list_first_entry(&rule->actionfields, in vcap_api_rule_add_actionvalue_test()
1157 KUNIT_EXPECT_EQ(test, VCAP_AF_POLICE_ENA, af->ctrl.action); in vcap_api_rule_add_actionvalue_test()
1158 KUNIT_EXPECT_EQ(test, VCAP_FIELD_BIT, af->ctrl.type); in vcap_api_rule_add_actionvalue_test()
1159 KUNIT_EXPECT_EQ(test, 0x0, af->data.u1.value); in vcap_api_rule_add_actionvalue_test()
1162 INIT_LIST_HEAD(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1164 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_actionvalue_test()
1165 ret = list_empty(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1166 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_actionvalue_test()
1167 af = list_first_entry(&rule->actionfields, in vcap_api_rule_add_actionvalue_test()
1169 KUNIT_EXPECT_EQ(test, VCAP_AF_TYPE, af->ctrl.action); in vcap_api_rule_add_actionvalue_test()
1170 KUNIT_EXPECT_EQ(test, VCAP_FIELD_U32, af->ctrl.type); in vcap_api_rule_add_actionvalue_test()
1171 KUNIT_EXPECT_EQ(test, 0x98765432, af->data.u32.value); in vcap_api_rule_add_actionvalue_test()
1174 INIT_LIST_HEAD(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1176 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_add_actionvalue_test()
1177 ret = list_empty(&rule->actionfields); in vcap_api_rule_add_actionvalue_test()
1178 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_add_actionvalue_test()
1179 af = list_first_entry(&rule->actionfields, in vcap_api_rule_add_actionvalue_test()
1181 KUNIT_EXPECT_EQ(test, VCAP_AF_MASK_MODE, af->ctrl.action); in vcap_api_rule_add_actionvalue_test()
1182 KUNIT_EXPECT_EQ(test, VCAP_FIELD_U32, af->ctrl.type); in vcap_api_rule_add_actionvalue_test()
1183 KUNIT_EXPECT_EQ(test, 0xaabbccdd, af->data.u32.value); in vcap_api_rule_add_actionvalue_test()
1187 static void vcap_api_rule_find_keyset_basic_test(struct kunit *test) in vcap_api_rule_find_keyset_basic_test() argument
1229 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_rule_find_keyset_basic_test()
1230 KUNIT_EXPECT_EQ(test, 1, matches.cnt); in vcap_api_rule_find_keyset_basic_test()
1231 KUNIT_EXPECT_EQ(test, VCAP_KFS_MAC_ETYPE, matches.keysets[0]); in vcap_api_rule_find_keyset_basic_test()
1234 static void vcap_api_rule_find_keyset_failed_test(struct kunit *test) in vcap_api_rule_find_keyset_failed_test() argument
1276 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_find_keyset_failed_test()
1277 KUNIT_EXPECT_EQ(test, 0, matches.cnt); in vcap_api_rule_find_keyset_failed_test()
1278 KUNIT_EXPECT_EQ(test, VCAP_KFS_NO_VALUE, matches.keysets[0]); in vcap_api_rule_find_keyset_failed_test()
1281 static void vcap_api_rule_find_keyset_many_test(struct kunit *test) in vcap_api_rule_find_keyset_many_test() argument
1323 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_rule_find_keyset_many_test()
1324 KUNIT_EXPECT_EQ(test, 6, matches.cnt); in vcap_api_rule_find_keyset_many_test()
1325 KUNIT_EXPECT_EQ(test, VCAP_KFS_ARP, matches.keysets[0]); in vcap_api_rule_find_keyset_many_test()
1326 KUNIT_EXPECT_EQ(test, VCAP_KFS_IP4_OTHER, matches.keysets[1]); in vcap_api_rule_find_keyset_many_test()
1327 KUNIT_EXPECT_EQ(test, VCAP_KFS_IP4_TCP_UDP, matches.keysets[2]); in vcap_api_rule_find_keyset_many_test()
1328 KUNIT_EXPECT_EQ(test, VCAP_KFS_IP6_STD, matches.keysets[3]); in vcap_api_rule_find_keyset_many_test()
1329 KUNIT_EXPECT_EQ(test, VCAP_KFS_IP_7TUPLE, matches.keysets[4]); in vcap_api_rule_find_keyset_many_test()
1330 KUNIT_EXPECT_EQ(test, VCAP_KFS_MAC_ETYPE, matches.keysets[5]); in vcap_api_rule_find_keyset_many_test()
1333 static void vcap_api_encode_rule_test(struct kunit *test) in vcap_api_encode_rule_test() argument
1382 KUNIT_EXPECT_PTR_NE(test, NULL, rule); in vcap_api_encode_rule_test()
1387 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1389 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1391 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1394 KUNIT_EXPECT_EQ(test, -EINVAL, ret); in vcap_api_encode_rule_test()
1397 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1400 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1403 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1407 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1409 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1411 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1413 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1417 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1421 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1422 KUNIT_EXPECT_EQ(test, VCAP_KFS_MAC_ETYPE, rule->keyset); in vcap_api_encode_rule_test()
1423 KUNIT_EXPECT_EQ(test, VCAP_AFS_BASE_TYPE, rule->actionset); in vcap_api_encode_rule_test()
1424 KUNIT_EXPECT_EQ(test, 6, ri->size); in vcap_api_encode_rule_test()
1425 KUNIT_EXPECT_EQ(test, 2, ri->keyset_sw_regs); in vcap_api_encode_rule_test()
1426 KUNIT_EXPECT_EQ(test, 4, ri->actionset_sw_regs); in vcap_api_encode_rule_test()
1430 rule->vcap_chain_id, rule->cookie, true); in vcap_api_encode_rule_test()
1431 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1435 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1436 KUNIT_EXPECT_EQ(test, 792, is2_admin.last_used_addr); in vcap_api_encode_rule_test()
1438 KUNIT_EXPECT_EQ(test, expwriteaddr[idx], test_updateaddr[idx]); in vcap_api_encode_rule_test()
1441 ret = list_empty(&is2_admin.rules); in vcap_api_encode_rule_test()
1442 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_encode_rule_test()
1443 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1446 rule->cookie, false); in vcap_api_encode_rule_test()
1449 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_encode_rule_test()
1454 static void vcap_api_set_rule_counter_test(struct kunit *test) in vcap_api_set_rule_counter_test() argument
1485 list_add_tail(&ri.list, &is2_admin.rules); in vcap_api_set_rule_counter_test()
1486 list_add_tail(&ri2.list, &is2_admin.rules); in vcap_api_set_rule_counter_test()
1491 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_set_rule_counter_test()
1493 KUNIT_EXPECT_EQ(test, 1002, test_hw_counter_id); in vcap_api_set_rule_counter_test()
1494 KUNIT_EXPECT_EQ(test, 0, test_hw_cache.counter); in vcap_api_set_rule_counter_test()
1495 KUNIT_EXPECT_EQ(test, false, test_hw_cache.sticky); in vcap_api_set_rule_counter_test()
1496 KUNIT_EXPECT_EQ(test, 600, test_updateaddr[0]); in vcap_api_set_rule_counter_test()
1499 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_set_rule_counter_test()
1501 KUNIT_EXPECT_EQ(test, 2002, test_hw_counter_id); in vcap_api_set_rule_counter_test()
1502 KUNIT_EXPECT_EQ(test, 101, test_hw_cache.counter); in vcap_api_set_rule_counter_test()
1503 KUNIT_EXPECT_EQ(test, true, test_hw_cache.sticky); in vcap_api_set_rule_counter_test()
1504 KUNIT_EXPECT_EQ(test, 700, test_updateaddr[1]); in vcap_api_set_rule_counter_test()
1507 static void vcap_api_get_rule_counter_test(struct kunit *test) in vcap_api_get_rule_counter_test() argument
1541 list_add_tail(&ri.list, &is2_admin.rules); in vcap_api_get_rule_counter_test()
1542 list_add_tail(&ri2.list, &is2_admin.rules); in vcap_api_get_rule_counter_test()
1545 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_get_rule_counter_test()
1547 KUNIT_EXPECT_EQ(test, 1011, test_hw_counter_id); in vcap_api_get_rule_counter_test()
1548 KUNIT_EXPECT_EQ(test, 55, ctr.value); in vcap_api_get_rule_counter_test()
1549 KUNIT_EXPECT_EQ(test, true, ctr.sticky); in vcap_api_get_rule_counter_test()
1550 KUNIT_EXPECT_EQ(test, 400, test_updateaddr[0]); in vcap_api_get_rule_counter_test()
1556 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_get_rule_counter_test()
1558 KUNIT_EXPECT_EQ(test, 2012, test_hw_counter_id); in vcap_api_get_rule_counter_test()
1559 KUNIT_EXPECT_EQ(test, 22, ctr2.value); in vcap_api_get_rule_counter_test()
1560 KUNIT_EXPECT_EQ(test, false, ctr2.sticky); in vcap_api_get_rule_counter_test()
1561 KUNIT_EXPECT_EQ(test, 300, test_updateaddr[1]); in vcap_api_get_rule_counter_test()
1564 static void vcap_api_rule_insert_in_order_test(struct kunit *test) in vcap_api_rule_insert_in_order_test() argument
1588 /* Create rules with different sizes and check that they are placed in vcap_api_rule_insert_in_order_test()
1591 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 10, 500, 12, 780); in vcap_api_rule_insert_in_order_test()
1592 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 20, 400, 6, 774); in vcap_api_rule_insert_in_order_test()
1593 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 30, 300, 3, 771); in vcap_api_rule_insert_in_order_test()
1594 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 40, 200, 2, 768); in vcap_api_rule_insert_in_order_test()
1602 static void vcap_api_rule_insert_reverse_order_test(struct kunit *test) in vcap_api_rule_insert_reverse_order_test() argument
1629 /* Create rules with different sizes and check that they are placed in vcap_api_rule_insert_reverse_order_test()
1632 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 20, 200, 2, 798); in vcap_api_rule_insert_reverse_order_test()
1633 KUNIT_EXPECT_EQ(test, 0, test_move_offset); in vcap_api_rule_insert_reverse_order_test()
1634 KUNIT_EXPECT_EQ(test, 0, test_move_count); in vcap_api_rule_insert_reverse_order_test()
1635 KUNIT_EXPECT_EQ(test, 0, test_move_addr); in vcap_api_rule_insert_reverse_order_test()
1637 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 30, 300, 3, 795); in vcap_api_rule_insert_reverse_order_test()
1638 KUNIT_EXPECT_EQ(test, 6, test_move_offset); in vcap_api_rule_insert_reverse_order_test()
1639 KUNIT_EXPECT_EQ(test, 3, test_move_count); in vcap_api_rule_insert_reverse_order_test()
1640 KUNIT_EXPECT_EQ(test, 798, test_move_addr); in vcap_api_rule_insert_reverse_order_test()
1642 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 40, 400, 6, 792); in vcap_api_rule_insert_reverse_order_test()
1643 KUNIT_EXPECT_EQ(test, 6, test_move_offset); in vcap_api_rule_insert_reverse_order_test()
1644 KUNIT_EXPECT_EQ(test, 6, test_move_count); in vcap_api_rule_insert_reverse_order_test()
1645 KUNIT_EXPECT_EQ(test, 792, test_move_addr); in vcap_api_rule_insert_reverse_order_test()
1647 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 50, 500, 12, 780); in vcap_api_rule_insert_reverse_order_test()
1648 KUNIT_EXPECT_EQ(test, 18, test_move_offset); in vcap_api_rule_insert_reverse_order_test()
1649 KUNIT_EXPECT_EQ(test, 12, test_move_count); in vcap_api_rule_insert_reverse_order_test()
1650 KUNIT_EXPECT_EQ(test, 786, test_move_addr); in vcap_api_rule_insert_reverse_order_test()
1653 list_for_each_entry(elem, &admin.rules, list) { in vcap_api_rule_insert_reverse_order_test()
1654 KUNIT_EXPECT_EQ(test, exp_addr[idx], elem->addr); in vcap_api_rule_insert_reverse_order_test()
1657 KUNIT_EXPECT_EQ(test, 768, admin.last_used_addr); in vcap_api_rule_insert_reverse_order_test()
1665 static void vcap_api_rule_remove_at_end_test(struct kunit *test) in vcap_api_rule_remove_at_end_test() argument
1691 /* Create rules with different sizes and check that they are placed in vcap_api_rule_remove_at_end_test()
1694 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 10, 500, 12, 780); in vcap_api_rule_remove_at_end_test()
1695 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 20, 400, 6, 774); in vcap_api_rule_remove_at_end_test()
1696 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 30, 300, 3, 771); in vcap_api_rule_remove_at_end_test()
1697 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 40, 200, 2, 768); in vcap_api_rule_remove_at_end_test()
1699 /* Remove rules again from the end */ in vcap_api_rule_remove_at_end_test()
1701 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_remove_at_end_test()
1702 KUNIT_EXPECT_EQ(test, 0, test_move_addr); in vcap_api_rule_remove_at_end_test()
1703 KUNIT_EXPECT_EQ(test, 0, test_move_offset); in vcap_api_rule_remove_at_end_test()
1704 KUNIT_EXPECT_EQ(test, 0, test_move_count); in vcap_api_rule_remove_at_end_test()
1705 KUNIT_EXPECT_EQ(test, 768, test_init_start); in vcap_api_rule_remove_at_end_test()
1706 KUNIT_EXPECT_EQ(test, 2, test_init_count); in vcap_api_rule_remove_at_end_test()
1707 KUNIT_EXPECT_EQ(test, 771, admin.last_used_addr); in vcap_api_rule_remove_at_end_test()
1710 KUNIT_EXPECT_EQ(test, ret, 0); in vcap_api_rule_remove_at_end_test()
1711 KUNIT_EXPECT_EQ(test, 0, test_move_addr); in vcap_api_rule_remove_at_end_test()
1712 KUNIT_EXPECT_EQ(test, 0, test_move_offset); in vcap_api_rule_remove_at_end_test()
1713 KUNIT_EXPECT_EQ(test, 0, test_move_count); in vcap_api_rule_remove_at_end_test()
1714 KUNIT_EXPECT_EQ(test, 771, test_init_start); in vcap_api_rule_remove_at_end_test()
1715 KUNIT_EXPECT_EQ(test, 3, test_init_count); in vcap_api_rule_remove_at_end_test()
1716 KUNIT_EXPECT_EQ(test, 774, admin.last_used_addr); in vcap_api_rule_remove_at_end_test()
1719 KUNIT_EXPECT_EQ(test, ret, 0); in vcap_api_rule_remove_at_end_test()
1720 KUNIT_EXPECT_EQ(test, 0, test_move_addr); in vcap_api_rule_remove_at_end_test()
1721 KUNIT_EXPECT_EQ(test, 0, test_move_offset); in vcap_api_rule_remove_at_end_test()
1722 KUNIT_EXPECT_EQ(test, 0, test_move_count); in vcap_api_rule_remove_at_end_test()
1723 KUNIT_EXPECT_EQ(test, 774, test_init_start); in vcap_api_rule_remove_at_end_test()
1724 KUNIT_EXPECT_EQ(test, 6, test_init_count); in vcap_api_rule_remove_at_end_test()
1725 KUNIT_EXPECT_EQ(test, 780, admin.last_used_addr); in vcap_api_rule_remove_at_end_test()
1728 KUNIT_EXPECT_EQ(test, ret, 0); in vcap_api_rule_remove_at_end_test()
1729 KUNIT_EXPECT_EQ(test, 0, test_move_addr); in vcap_api_rule_remove_at_end_test()
1730 KUNIT_EXPECT_EQ(test, 0, test_move_offset); in vcap_api_rule_remove_at_end_test()
1731 KUNIT_EXPECT_EQ(test, 0, test_move_count); in vcap_api_rule_remove_at_end_test()
1732 KUNIT_EXPECT_EQ(test, 780, test_init_start); in vcap_api_rule_remove_at_end_test()
1733 KUNIT_EXPECT_EQ(test, 12, test_init_count); in vcap_api_rule_remove_at_end_test()
1734 KUNIT_EXPECT_EQ(test, 3072, admin.last_used_addr); in vcap_api_rule_remove_at_end_test()
1737 static void vcap_api_rule_remove_in_middle_test(struct kunit *test) in vcap_api_rule_remove_in_middle_test() argument
1751 .last_valid_addr = 800 - 1, in vcap_api_rule_remove_in_middle_test()
1762 /* Create rules with different sizes and check that they are placed in vcap_api_rule_remove_in_middle_test()
1765 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 10, 500, 12, 780); in vcap_api_rule_remove_in_middle_test()
1766 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 20, 400, 6, 774); in vcap_api_rule_remove_in_middle_test()
1767 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 30, 300, 3, 771); in vcap_api_rule_remove_in_middle_test()
1768 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 40, 200, 2, 768); in vcap_api_rule_remove_in_middle_test()
1770 /* Remove rules in the middle */ in vcap_api_rule_remove_in_middle_test()
1773 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_remove_in_middle_test()
1774 KUNIT_EXPECT_EQ(test, 768, test_move_addr); in vcap_api_rule_remove_in_middle_test()
1775 KUNIT_EXPECT_EQ(test, -6, test_move_offset); in vcap_api_rule_remove_in_middle_test()
1776 KUNIT_EXPECT_EQ(test, 6, test_move_count); in vcap_api_rule_remove_in_middle_test()
1777 KUNIT_EXPECT_EQ(test, 768, test_init_start); in vcap_api_rule_remove_in_middle_test()
1778 KUNIT_EXPECT_EQ(test, 6, test_init_count); in vcap_api_rule_remove_in_middle_test()
1779 KUNIT_EXPECT_EQ(test, 774, admin.last_used_addr); in vcap_api_rule_remove_in_middle_test()
1783 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_remove_in_middle_test()
1784 KUNIT_EXPECT_EQ(test, 774, test_move_addr); in vcap_api_rule_remove_in_middle_test()
1785 KUNIT_EXPECT_EQ(test, -4, test_move_offset); in vcap_api_rule_remove_in_middle_test()
1786 KUNIT_EXPECT_EQ(test, 2, test_move_count); in vcap_api_rule_remove_in_middle_test()
1787 KUNIT_EXPECT_EQ(test, 774, test_init_start); in vcap_api_rule_remove_in_middle_test()
1788 KUNIT_EXPECT_EQ(test, 4, test_init_count); in vcap_api_rule_remove_in_middle_test()
1789 KUNIT_EXPECT_EQ(test, 778, admin.last_used_addr); in vcap_api_rule_remove_in_middle_test()
1793 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_remove_in_middle_test()
1794 KUNIT_EXPECT_EQ(test, 778, test_move_addr); in vcap_api_rule_remove_in_middle_test()
1795 KUNIT_EXPECT_EQ(test, -20, test_move_offset); in vcap_api_rule_remove_in_middle_test()
1796 KUNIT_EXPECT_EQ(test, 2, test_move_count); in vcap_api_rule_remove_in_middle_test()
1797 KUNIT_EXPECT_EQ(test, 778, test_init_start); in vcap_api_rule_remove_in_middle_test()
1798 KUNIT_EXPECT_EQ(test, 20, test_init_count); in vcap_api_rule_remove_in_middle_test()
1799 KUNIT_EXPECT_EQ(test, 798, admin.last_used_addr); in vcap_api_rule_remove_in_middle_test()
1803 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_remove_in_middle_test()
1804 KUNIT_EXPECT_EQ(test, 0, test_move_addr); in vcap_api_rule_remove_in_middle_test()
1805 KUNIT_EXPECT_EQ(test, 0, test_move_offset); in vcap_api_rule_remove_in_middle_test()
1806 KUNIT_EXPECT_EQ(test, 0, test_move_count); in vcap_api_rule_remove_in_middle_test()
1807 KUNIT_EXPECT_EQ(test, 798, test_init_start); in vcap_api_rule_remove_in_middle_test()
1808 KUNIT_EXPECT_EQ(test, 2, test_init_count); in vcap_api_rule_remove_in_middle_test()
1809 KUNIT_EXPECT_EQ(test, 800, admin.last_used_addr); in vcap_api_rule_remove_in_middle_test()
1812 static void vcap_api_rule_remove_in_front_test(struct kunit *test) in vcap_api_rule_remove_in_front_test() argument
1826 .last_valid_addr = 800 - 1, in vcap_api_rule_remove_in_front_test()
1837 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 10, 500, 12, 780); in vcap_api_rule_remove_in_front_test()
1838 KUNIT_EXPECT_EQ(test, 780, admin.last_used_addr); in vcap_api_rule_remove_in_front_test()
1842 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_remove_in_front_test()
1843 KUNIT_EXPECT_EQ(test, 0, test_move_addr); in vcap_api_rule_remove_in_front_test()
1844 KUNIT_EXPECT_EQ(test, 0, test_move_offset); in vcap_api_rule_remove_in_front_test()
1845 KUNIT_EXPECT_EQ(test, 0, test_move_count); in vcap_api_rule_remove_in_front_test()
1846 KUNIT_EXPECT_EQ(test, 780, test_init_start); in vcap_api_rule_remove_in_front_test()
1847 KUNIT_EXPECT_EQ(test, 12, test_init_count); in vcap_api_rule_remove_in_front_test()
1848 KUNIT_EXPECT_EQ(test, 800, admin.last_used_addr); in vcap_api_rule_remove_in_front_test()
1850 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 20, 400, 6, 792); in vcap_api_rule_remove_in_front_test()
1851 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 30, 300, 3, 789); in vcap_api_rule_remove_in_front_test()
1852 test_vcap_xn_rule_creator(test, 10000, VCAP_USER_QOS, 40, 200, 2, 786); in vcap_api_rule_remove_in_front_test()
1856 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_rule_remove_in_front_test()
1857 KUNIT_EXPECT_EQ(test, 786, test_move_addr); in vcap_api_rule_remove_in_front_test()
1858 KUNIT_EXPECT_EQ(test, -8, test_move_offset); in vcap_api_rule_remove_in_front_test()
1859 KUNIT_EXPECT_EQ(test, 6, test_move_count); in vcap_api_rule_remove_in_front_test()
1860 KUNIT_EXPECT_EQ(test, 786, test_init_start); in vcap_api_rule_remove_in_front_test()
1861 KUNIT_EXPECT_EQ(test, 8, test_init_count); in vcap_api_rule_remove_in_front_test()
1862 KUNIT_EXPECT_EQ(test, 794, admin.last_used_addr); in vcap_api_rule_remove_in_front_test()
1875 static void vcap_api_next_lookup_basic_test(struct kunit *test) in vcap_api_next_lookup_basic_test() argument
1899 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_basic_test()
1901 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_basic_test()
1903 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_basic_test()
1906 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_basic_test()
1908 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_basic_test()
1911 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_basic_test()
1913 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_basic_test()
1916 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_basic_test()
1918 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_basic_test()
1921 static void vcap_api_next_lookup_advanced_test(struct kunit *test) in vcap_api_next_lookup_advanced_test() argument
1970 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_advanced_test()
1972 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_advanced_test()
1975 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_advanced_test()
1977 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_advanced_test()
1979 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_advanced_test()
1981 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_advanced_test()
1983 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_advanced_test()
1985 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_advanced_test()
1988 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_advanced_test()
1990 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_next_lookup_advanced_test()
1993 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_advanced_test()
1995 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_next_lookup_advanced_test()
1998 static void vcap_api_filter_unsupported_keys_test(struct kunit *test) in vcap_api_filter_unsupported_keys_test() argument
2042 ckf->ctrl.key = keylist[idx]; in vcap_api_filter_unsupported_keys_test()
2043 list_add_tail(&ckf->ctrl.list, &ri.data.keyfields); in vcap_api_filter_unsupported_keys_test()
2047 KUNIT_EXPECT_EQ(test, 14, ARRAY_SIZE(keylist)); in vcap_api_filter_unsupported_keys_test()
2052 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_filter_unsupported_keys_test()
2057 KUNIT_EXPECT_EQ(test, expected[idx], ckf->ctrl.key); in vcap_api_filter_unsupported_keys_test()
2058 list_del(&ckf->ctrl.list); in vcap_api_filter_unsupported_keys_test()
2062 KUNIT_EXPECT_EQ(test, 7, idx); in vcap_api_filter_unsupported_keys_test()
2065 static void vcap_api_filter_keylist_test(struct kunit *test) in vcap_api_filter_keylist_test() argument
2166 ckf->ctrl.key = keylist[idx]; in vcap_api_filter_keylist_test()
2167 list_add_tail(&ckf->ctrl.list, &ri.data.keyfields); in vcap_api_filter_keylist_test()
2171 KUNIT_EXPECT_EQ(test, 38, ARRAY_SIZE(keylist)); in vcap_api_filter_keylist_test()
2177 KUNIT_EXPECT_EQ(test, 0, ret); in vcap_api_filter_keylist_test()
2182 KUNIT_EXPECT_EQ(test, expected[idx], ckf->ctrl.key); in vcap_api_filter_keylist_test()
2183 list_del(&ckf->ctrl.list); in vcap_api_filter_keylist_test()
2187 KUNIT_EXPECT_EQ(test, 26, idx); in vcap_api_filter_keylist_test()
2190 static void vcap_api_rule_chain_path_test(struct kunit *test) in vcap_api_rule_chain_path_test() argument
2227 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_rule_chain_path_test()
2230 KUNIT_EXPECT_EQ(test, true, ret); in vcap_api_rule_chain_path_test()
2233 KUNIT_EXPECT_EQ(test, false, ret); in vcap_api_rule_chain_path_test()
2236 KUNIT_EXPECT_EQ(test, 1000000, chain); in vcap_api_rule_chain_path_test()
2239 KUNIT_EXPECT_EQ(test, 1100000, chain); in vcap_api_rule_chain_path_test()
2242 KUNIT_EXPECT_EQ(test, 8000000, chain); in vcap_api_rule_chain_path_test()