Lines Matching +full:valid +full:- +full:mask
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
19 prestera_acl_ruleset_put(template->ruleset); in prestera_flower_template_free()
20 list_del(&template->list); in prestera_flower_template_free()
29 list_for_each_entry_safe(template, tmp, &block->template_list, list) in prestera_flower_template_cleanup()
41 if (act->chain_index <= chain_index) in prestera_flower_parse_goto_action()
43 return -EINVAL; in prestera_flower_parse_goto_action()
45 if (rule->re_arg.jump.valid) in prestera_flower_parse_goto_action()
46 return -EEXIST; in prestera_flower_parse_goto_action()
48 ruleset = prestera_acl_ruleset_get(block->sw->acl, block, in prestera_flower_parse_goto_action()
49 act->chain_index); in prestera_flower_parse_goto_action()
53 rule->re_arg.jump.valid = 1; in prestera_flower_parse_goto_action()
54 rule->re_arg.jump.i.index = prestera_acl_ruleset_index_get(ruleset); in prestera_flower_parse_goto_action()
56 rule->jump_ruleset = ruleset; in prestera_flower_parse_goto_action()
70 /* whole struct (rule->re_arg) must be initialized with 0 */ in prestera_flower_parse_actions()
75 return -EOPNOTSUPP; in prestera_flower_parse_actions()
78 if (act->hw_stats & FLOW_ACTION_HW_STATS_DISABLED) { in prestera_flower_parse_actions()
80 } else if (act->hw_stats & FLOW_ACTION_HW_STATS_DELAYED) { in prestera_flower_parse_actions()
82 rule->re_arg.count.valid = true; in prestera_flower_parse_actions()
83 err = prestera_acl_chain_to_client(chain_index, block->ingress, in prestera_flower_parse_actions()
84 &rule->re_arg.count.client); in prestera_flower_parse_actions()
89 return -EOPNOTSUPP; in prestera_flower_parse_actions()
93 switch (act->id) { in prestera_flower_parse_actions()
95 if (rule->re_arg.accept.valid) in prestera_flower_parse_actions()
96 return -EEXIST; in prestera_flower_parse_actions()
98 rule->re_arg.accept.valid = 1; in prestera_flower_parse_actions()
101 if (rule->re_arg.drop.valid) in prestera_flower_parse_actions()
102 return -EEXIST; in prestera_flower_parse_actions()
104 rule->re_arg.drop.valid = 1; in prestera_flower_parse_actions()
107 if (rule->re_arg.trap.valid) in prestera_flower_parse_actions()
108 return -EEXIST; in prestera_flower_parse_actions()
110 rule->re_arg.trap.valid = 1; in prestera_flower_parse_actions()
113 if (rule->re_arg.police.valid) in prestera_flower_parse_actions()
114 return -EEXIST; in prestera_flower_parse_actions()
116 rule->re_arg.police.valid = 1; in prestera_flower_parse_actions()
117 rule->re_arg.police.rate = in prestera_flower_parse_actions()
118 act->police.rate_bytes_ps; in prestera_flower_parse_actions()
119 rule->re_arg.police.burst = act->police.burst; in prestera_flower_parse_actions()
120 rule->re_arg.police.ingress = block->ingress; in prestera_flower_parse_actions()
132 return -EOPNOTSUPP; in prestera_flower_parse_actions()
144 struct prestera_acl_match *r_match = &rule->re_key.match; in prestera_flower_parse_meta()
148 __be16 key, mask; in prestera_flower_parse_meta() local
152 if (match.mask->l2_miss) { in prestera_flower_parse_meta()
153 NL_SET_ERR_MSG_MOD(f->common.extack, "Can't match on \"l2_miss\""); in prestera_flower_parse_meta()
154 return -EOPNOTSUPP; in prestera_flower_parse_meta()
157 if (match.mask->ingress_ifindex != 0xFFFFFFFF) { in prestera_flower_parse_meta()
158 NL_SET_ERR_MSG_MOD(f->common.extack, in prestera_flower_parse_meta()
159 "Unsupported ingress ifindex mask"); in prestera_flower_parse_meta()
160 return -EINVAL; in prestera_flower_parse_meta()
163 ingress_dev = __dev_get_by_index(block->net, in prestera_flower_parse_meta()
164 match.key->ingress_ifindex); in prestera_flower_parse_meta()
166 NL_SET_ERR_MSG_MOD(f->common.extack, in prestera_flower_parse_meta()
168 return -EINVAL; in prestera_flower_parse_meta()
172 NL_SET_ERR_MSG_MOD(f->common.extack, in prestera_flower_parse_meta()
174 return -EINVAL; in prestera_flower_parse_meta()
178 mask = htons(0x1FFF << 3); in prestera_flower_parse_meta()
179 key = htons(port->hw_id << 3); in prestera_flower_parse_meta()
180 rule_match_set(r_match->key, SYS_PORT, key); in prestera_flower_parse_meta()
181 rule_match_set(r_match->mask, SYS_PORT, mask); in prestera_flower_parse_meta()
183 mask = htons(0x3FF); in prestera_flower_parse_meta()
184 key = htons(port->dev_id); in prestera_flower_parse_meta()
185 rule_match_set(r_match->key, SYS_DEV, key); in prestera_flower_parse_meta()
186 rule_match_set(r_match->mask, SYS_DEV, mask); in prestera_flower_parse_meta()
196 struct flow_dissector *dissector = f_rule->match.dissector; in prestera_flower_parse()
197 struct prestera_acl_match *r_match = &rule->re_key.match; in prestera_flower_parse()
204 if (dissector->used_keys & in prestera_flower_parse()
215 NL_SET_ERR_MSG_MOD(f->common.extack, "Unsupported key"); in prestera_flower_parse()
216 return -EOPNOTSUPP; in prestera_flower_parse()
219 prestera_acl_rule_priority_set(rule, f->common.prio); in prestera_flower_parse()
231 addr_type = match.key->addr_type; in prestera_flower_parse()
233 if (flow_rule_has_control_flags(match.mask->flags, in prestera_flower_parse()
234 f->common.extack)) in prestera_flower_parse()
235 return -EOPNOTSUPP; in prestera_flower_parse()
242 n_proto_key = match.key->n_proto; in prestera_flower_parse()
243 n_proto_mask = match.mask->n_proto; in prestera_flower_parse()
245 if (ntohs(match.key->n_proto) == ETH_P_ALL) { in prestera_flower_parse()
250 rule_match_set(r_match->key, ETH_TYPE, n_proto_key); in prestera_flower_parse()
251 rule_match_set(r_match->mask, ETH_TYPE, n_proto_mask); in prestera_flower_parse()
253 rule_match_set(r_match->key, IP_PROTO, match.key->ip_proto); in prestera_flower_parse()
254 rule_match_set(r_match->mask, IP_PROTO, match.mask->ip_proto); in prestera_flower_parse()
255 ip_proto = match.key->ip_proto; in prestera_flower_parse()
263 /* DA key, mask */ in prestera_flower_parse()
264 rule_match_set_n(r_match->key, in prestera_flower_parse()
265 ETH_DMAC_0, &match.key->dst[0], 4); in prestera_flower_parse()
266 rule_match_set_n(r_match->key, in prestera_flower_parse()
267 ETH_DMAC_1, &match.key->dst[4], 2); in prestera_flower_parse()
269 rule_match_set_n(r_match->mask, in prestera_flower_parse()
270 ETH_DMAC_0, &match.mask->dst[0], 4); in prestera_flower_parse()
271 rule_match_set_n(r_match->mask, in prestera_flower_parse()
272 ETH_DMAC_1, &match.mask->dst[4], 2); in prestera_flower_parse()
274 /* SA key, mask */ in prestera_flower_parse()
275 rule_match_set_n(r_match->key, in prestera_flower_parse()
276 ETH_SMAC_0, &match.key->src[0], 4); in prestera_flower_parse()
277 rule_match_set_n(r_match->key, in prestera_flower_parse()
278 ETH_SMAC_1, &match.key->src[4], 2); in prestera_flower_parse()
280 rule_match_set_n(r_match->mask, in prestera_flower_parse()
281 ETH_SMAC_0, &match.mask->src[0], 4); in prestera_flower_parse()
282 rule_match_set_n(r_match->mask, in prestera_flower_parse()
283 ETH_SMAC_1, &match.mask->src[4], 2); in prestera_flower_parse()
291 rule_match_set(r_match->key, IP_SRC, match.key->src); in prestera_flower_parse()
292 rule_match_set(r_match->mask, IP_SRC, match.mask->src); in prestera_flower_parse()
294 rule_match_set(r_match->key, IP_DST, match.key->dst); in prestera_flower_parse()
295 rule_match_set(r_match->mask, IP_DST, match.mask->dst); in prestera_flower_parse()
303 (f->common.extack, in prestera_flower_parse()
305 return -EINVAL; in prestera_flower_parse()
310 rule_match_set(r_match->key, L4_PORT_SRC, match.key->src); in prestera_flower_parse()
311 rule_match_set(r_match->mask, L4_PORT_SRC, match.mask->src); in prestera_flower_parse()
313 rule_match_set(r_match->key, L4_PORT_DST, match.key->dst); in prestera_flower_parse()
314 rule_match_set(r_match->mask, L4_PORT_DST, match.mask->dst); in prestera_flower_parse()
324 tp_key = htonl(ntohs(match.key->tp_min.src) | in prestera_flower_parse()
325 (ntohs(match.key->tp_max.src) << 16)); in prestera_flower_parse()
326 tp_mask = htonl(ntohs(match.mask->tp_min.src) | in prestera_flower_parse()
327 (ntohs(match.mask->tp_max.src) << 16)); in prestera_flower_parse()
328 rule_match_set(r_match->key, L4_PORT_RANGE_SRC, tp_key); in prestera_flower_parse()
329 rule_match_set(r_match->mask, L4_PORT_RANGE_SRC, tp_mask); in prestera_flower_parse()
332 tp_key = htonl(ntohs(match.key->tp_min.dst) | in prestera_flower_parse()
333 (ntohs(match.key->tp_max.dst) << 16)); in prestera_flower_parse()
334 tp_mask = htonl(ntohs(match.mask->tp_min.dst) | in prestera_flower_parse()
335 (ntohs(match.mask->tp_max.dst) << 16)); in prestera_flower_parse()
336 rule_match_set(r_match->key, L4_PORT_RANGE_DST, tp_key); in prestera_flower_parse()
337 rule_match_set(r_match->mask, L4_PORT_RANGE_DST, tp_mask); in prestera_flower_parse()
345 if (match.mask->vlan_id != 0) { in prestera_flower_parse()
346 __be16 key = cpu_to_be16(match.key->vlan_id); in prestera_flower_parse()
347 __be16 mask = cpu_to_be16(match.mask->vlan_id); in prestera_flower_parse() local
349 rule_match_set(r_match->key, VLAN_ID, key); in prestera_flower_parse()
350 rule_match_set(r_match->mask, VLAN_ID, mask); in prestera_flower_parse()
353 rule_match_set(r_match->key, VLAN_TPID, match.key->vlan_tpid); in prestera_flower_parse()
354 rule_match_set(r_match->mask, VLAN_TPID, match.mask->vlan_tpid); in prestera_flower_parse()
362 rule_match_set(r_match->key, ICMP_TYPE, match.key->type); in prestera_flower_parse()
363 rule_match_set(r_match->mask, ICMP_TYPE, match.mask->type); in prestera_flower_parse()
365 rule_match_set(r_match->key, ICMP_CODE, match.key->code); in prestera_flower_parse()
366 rule_match_set(r_match->mask, ICMP_CODE, match.mask->code); in prestera_flower_parse()
369 return prestera_flower_parse_actions(block, rule, &f->rule->action, in prestera_flower_parse()
370 f->common.chain_index, in prestera_flower_parse()
371 f->common.extack); in prestera_flower_parse()
382 if (err == -ENOENT) in prestera_flower_prio_check()
387 NL_SET_ERR_MSG(f->common.extack, "Failed to get matchall priorities"); in prestera_flower_prio_check()
391 if (f->common.prio <= mall_prio_max && block->ingress) { in prestera_flower_prio_check()
392 NL_SET_ERR_MSG(f->common.extack, in prestera_flower_prio_check()
394 return -EOPNOTSUPP; in prestera_flower_prio_check()
396 if (f->common.prio >= mall_prio_min && !block->ingress) { in prestera_flower_prio_check()
397 NL_SET_ERR_MSG(f->common.extack, "Failed to add behind of existing matchall rules"); in prestera_flower_prio_check()
398 return -EOPNOTSUPP; in prestera_flower_prio_check()
409 ruleset = prestera_acl_ruleset_lookup(block->sw->acl, block, chain_index); in prestera_flower_prio_get()
421 struct prestera_acl *acl = block->sw->acl; in prestera_flower_replace()
429 ruleset = prestera_acl_ruleset_get(acl, block, f->common.chain_index); in prestera_flower_replace()
434 rule = prestera_acl_rule_create(ruleset, f->cookie, in prestera_flower_replace()
435 f->common.chain_index); in prestera_flower_replace()
451 err = prestera_acl_rule_add(block->sw, rule); in prestera_flower_replace()
472 ruleset = prestera_acl_ruleset_lookup(block->sw->acl, block, in prestera_flower_destroy()
473 f->common.chain_index); in prestera_flower_destroy()
477 rule = prestera_acl_rule_lookup(ruleset, f->cookie); in prestera_flower_destroy()
479 prestera_acl_rule_del(block->sw, rule); in prestera_flower_destroy()
500 err = -ENOMEM; in prestera_flower_tmplt_create()
505 ruleset = prestera_acl_ruleset_get(block->sw->acl, block, in prestera_flower_tmplt_create()
506 f->common.chain_index); in prestera_flower_tmplt_create()
508 err = -EINVAL; in prestera_flower_tmplt_create()
513 err = prestera_acl_ruleset_keymask_set(ruleset, rule.re_key.match.mask); in prestera_flower_tmplt_create()
526 template->ruleset = ruleset; in prestera_flower_tmplt_create()
527 template->chain_index = f->common.chain_index; in prestera_flower_tmplt_create()
528 list_add_rcu(&template->list, &block->template_list); in prestera_flower_tmplt_create()
536 NL_SET_ERR_MSG_MOD(f->common.extack, "Create chain template failed"); in prestera_flower_tmplt_create()
545 list_for_each_entry_safe(template, tmp, &block->template_list, list) in prestera_flower_tmplt_destroy()
546 if (template->chain_index == f->common.chain_index) { in prestera_flower_tmplt_destroy()
563 ruleset = prestera_acl_ruleset_lookup(block->sw->acl, block, in prestera_flower_stats()
564 f->common.chain_index); in prestera_flower_stats()
568 rule = prestera_acl_rule_lookup(ruleset, f->cookie); in prestera_flower_stats()
570 err = -EINVAL; in prestera_flower_stats()
574 err = prestera_acl_rule_get_stats(block->sw->acl, rule, &packets, in prestera_flower_stats()
579 flow_stats_update(&f->stats, bytes, packets, 0, lastuse, in prestera_flower_stats()