Lines Matching refs:rule

33 					      struct vcap_rule *rule,
75 struct vcap_rule *rule)
78 vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS, VCAP_BIT_1);
80 vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS, VCAP_BIT_0);
245 /* Helper function to create a rule of a specific size */
250 struct vcap_rule *rule;
287 /* Allocate the rule */
288 rule = vcap_alloc_rule(&test_vctrl, &test_netdev, cid, user, priority,
290 KUNIT_EXPECT_PTR_NE(test, NULL, rule);
292 ri = (struct vcap_rule_internal *)rule;
294 /* Override rule keyset */
295 ret = vcap_set_rule_set_keyset(rule, keyset);
297 /* Add rule actions : there must be at least one action */
298 ret = vcap_rule_add_action_u32(rule, VCAP_AF_ISDX_VAL, 0);
300 /* Override rule actionset */
301 ret = vcap_set_rule_set_actionset(rule, actionset);
303 ret = vcap_val_rule(rule, ETH_P_ALL);
305 KUNIT_EXPECT_EQ(test, keyset, rule->keyset);
306 KUNIT_EXPECT_EQ(test, actionset, rule->actionset);
309 /* Add rule with write callback */
310 ret = vcap_add_rule(rule);
313 vcap_free_rule(rule);
316 /* Prepare testing rule deletion */
589 struct vcap_rule_internal rule = {
615 vcap_encode_keyfield(&rule, &ckf, &rf, tgt);
650 struct vcap_rule_internal rule = {
693 vcap_encode_keyfield(&rule, &ckf, &rf, tgt);
713 struct vcap_rule_internal rule = {
738 vcap_encode_actionfield(&rule, &caf, &rf, tgt);
834 struct vcap_rule_internal rule = {
896 INIT_LIST_HEAD(&rule.data.keyfields);
897 ret = vcap_encode_rule_keyset(&rule);
901 list_add_tail(&ckf[idx].ctrl.list, &rule.data.keyfields);
902 ret = vcap_encode_rule_keyset(&rule);
905 /* The key and mask values below are from an actual Sparx5 rule config */
944 struct vcap_rule_internal rule = {
972 INIT_LIST_HEAD(&rule.data.actionfields);
973 ret = vcap_encode_rule_actionset(&rule);
978 list_add_tail(&caf[idx].ctrl.list, &rule.data.actionfields);
979 ret = vcap_encode_rule_actionset(&rule);
982 /* The action values below are from an actual Sparx5 rule config */
997 static void vcap_free_ckf(struct vcap_rule *rule)
1001 list_for_each_entry_safe(ckf, next_ckf, &rule->keyfields, ctrl.list) {
1019 struct vcap_rule *rule = (struct vcap_rule *)&ri;
1028 INIT_LIST_HEAD(&rule->keyfields);
1029 ret = vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS, VCAP_BIT_0);
1031 ret = list_empty(&rule->keyfields);
1033 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield,
1039 vcap_free_ckf(rule);
1041 INIT_LIST_HEAD(&rule->keyfields);
1042 ret = vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS, VCAP_BIT_1);
1044 ret = list_empty(&rule->keyfields);
1046 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield,
1052 vcap_free_ckf(rule);
1054 INIT_LIST_HEAD(&rule->keyfields);
1055 ret = vcap_rule_add_key_bit(rule, VCAP_KF_LOOKUP_FIRST_IS,
1058 ret = list_empty(&rule->keyfields);
1060 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield,
1066 vcap_free_ckf(rule);
1068 INIT_LIST_HEAD(&rule->keyfields);
1069 ret = vcap_rule_add_key_u32(rule, VCAP_KF_TYPE, 0x98765432, 0xff00ffab);
1071 ret = list_empty(&rule->keyfields);
1073 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield,
1079 vcap_free_ckf(rule);
1081 INIT_LIST_HEAD(&rule->keyfields);
1082 ret = vcap_rule_add_key_u128(rule, VCAP_KF_L3_IP6_SIP, &dip);
1084 ret = list_empty(&rule->keyfields);
1086 kf = list_first_entry(&rule->keyfields, struct vcap_client_keyfield,
1094 vcap_free_ckf(rule);
1097 static void vcap_free_caf(struct vcap_rule *rule)
1102 &rule->actionfields, ctrl.list) {
1119 struct vcap_rule *rule = (struct vcap_rule *)&ri;
1123 INIT_LIST_HEAD(&rule->actionfields);
1124 ret = vcap_rule_add_action_bit(rule, VCAP_AF_POLICE_ENA, VCAP_BIT_0);
1126 ret = list_empty(&rule->actionfields);
1128 af = list_first_entry(&rule->actionfields,
1133 vcap_free_caf(rule);
1135 INIT_LIST_HEAD(&rule->actionfields);
1136 ret = vcap_rule_add_action_bit(rule, VCAP_AF_POLICE_ENA, VCAP_BIT_1);
1138 ret = list_empty(&rule->actionfields);
1140 af = list_first_entry(&rule->actionfields,
1145 vcap_free_caf(rule);
1147 INIT_LIST_HEAD(&rule->actionfields);
1148 ret = vcap_rule_add_action_bit(rule, VCAP_AF_POLICE_ENA, VCAP_BIT_ANY);
1150 ret = list_empty(&rule->actionfields);
1152 af = list_first_entry(&rule->actionfields,
1157 vcap_free_caf(rule);
1159 INIT_LIST_HEAD(&rule->actionfields);
1160 ret = vcap_rule_add_action_u32(rule, VCAP_AF_TYPE, 0x98765432);
1162 ret = list_empty(&rule->actionfields);
1164 af = list_first_entry(&rule->actionfields,
1169 vcap_free_caf(rule);
1171 INIT_LIST_HEAD(&rule->actionfields);
1172 ret = vcap_rule_add_action_u32(rule, VCAP_AF_MASK_MODE, 0xaabbccdd);
1174 ret = list_empty(&rule->actionfields);
1176 af = list_first_entry(&rule->actionfields,
1181 vcap_free_caf(rule);
1351 struct vcap_rule *rule;
1376 /* Allocate the rule */
1377 rule = vcap_alloc_rule(&test_vctrl, &test_netdev, vcap_chain_id, user,
1379 KUNIT_EXPECT_PTR_NE(test, NULL, rule);
1380 ri = (struct vcap_rule_internal *)rule;
1382 /* Add rule keys */
1383 ret = vcap_rule_add_key_u48(rule, VCAP_KF_L2_DMAC, &dmac);
1385 ret = vcap_rule_add_key_u48(rule, VCAP_KF_L2_SMAC, &smac);
1387 ret = vcap_rule_add_key_bit(rule, VCAP_KF_ETYPE_LEN_IS, VCAP_BIT_1);
1390 ret = vcap_rule_add_key_bit(rule, VCAP_KF_ETYPE_LEN_IS, VCAP_BIT_1);
1392 ret = vcap_rule_add_key_bit(rule, VCAP_KF_IF_IGR_PORT_MASK_L3,
1395 ret = vcap_rule_add_key_u32(rule, VCAP_KF_IF_IGR_PORT_MASK_RNG,
1398 ret = vcap_rule_add_key_u32(rule, VCAP_KF_IF_IGR_PORT_MASK,
1402 /* Add rule actions */
1403 ret = vcap_rule_add_action_bit(rule, VCAP_AF_POLICE_ENA, VCAP_BIT_1);
1405 ret = vcap_rule_add_action_u32(rule, VCAP_AF_CNT_ID, id);
1407 ret = vcap_rule_add_action_u32(rule, VCAP_AF_MATCH_ID, 1);
1409 ret = vcap_rule_add_action_u32(rule, VCAP_AF_MATCH_ID_MASK, 1);
1413 ret = vcap_set_rule_set_actionset(rule, VCAP_AFS_BASE_TYPE);
1417 ret = vcap_val_rule(rule, ETH_P_ALL);
1419 KUNIT_EXPECT_EQ(test, VCAP_KFS_MAC_ETYPE, rule->keyset);
1420 KUNIT_EXPECT_EQ(test, VCAP_AFS_BASE_TYPE, rule->actionset);
1425 /* Enable lookup, so the rule will be written */
1427 rule->vcap_chain_id, rule->cookie, true);
1430 /* Add rule with write callback */
1431 ret = vcap_add_rule(rule);
1437 /* Check that the rule has been added */
1443 rule->cookie, false);
1445 vcap_free_rule(rule);
1447 /* Check that the rule has been freed: tricky to access since this
1450 KUNIT_EXPECT_PTR_NE(test, NULL, rule);
1451 ret = list_empty(&rule->keyfields);
1453 ret = list_empty(&rule->actionfields);
2042 /* Add all keys to the rule */
2054 /* Drop unsupported keys from the rule */
2059 /* Check remaining keys in the rule */
2166 /* Add all keys to the rule */
2178 /* Drop listed keys from the rule */
2184 /* Check remaining keys in the rule */