Lines Matching +full:common +full:- +full:rules

1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /* Copyright (c) 2017-2020 Mellanox Technologies. All rights reserved */
18 list_for_each_entry(mall_entry, &block->mall.list, list) in mlxsw_sp_mall_entry_find()
19 if (mall_entry->cookie == cookie) in mlxsw_sp_mall_entry_find()
30 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_mall_port_mirror_add()
36 if (!mall_entry->mirror.to_dev) { in mlxsw_sp_mall_port_mirror_add()
38 return -EINVAL; in mlxsw_sp_mall_port_mirror_add()
41 agent_parms.to_dev = mall_entry->mirror.to_dev; in mlxsw_sp_mall_port_mirror_add()
42 err = mlxsw_sp_span_agent_get(mlxsw_sp, &mall_entry->mirror.span_id, in mlxsw_sp_mall_port_mirror_add()
50 mall_entry->ingress); in mlxsw_sp_mall_port_mirror_add()
56 trigger = mall_entry->ingress ? MLXSW_SP_SPAN_TRIGGER_INGRESS : in mlxsw_sp_mall_port_mirror_add()
58 parms.span_id = mall_entry->mirror.span_id; in mlxsw_sp_mall_port_mirror_add()
70 mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, mall_entry->ingress); in mlxsw_sp_mall_port_mirror_add()
72 mlxsw_sp_span_agent_put(mlxsw_sp, mall_entry->mirror.span_id); in mlxsw_sp_mall_port_mirror_add()
80 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_mall_port_mirror_del()
84 trigger = mall_entry->ingress ? MLXSW_SP_SPAN_TRIGGER_INGRESS : in mlxsw_sp_mall_port_mirror_del()
86 parms.span_id = mall_entry->mirror.span_id; in mlxsw_sp_mall_port_mirror_del()
88 mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, mall_entry->ingress); in mlxsw_sp_mall_port_mirror_del()
89 mlxsw_sp_span_agent_put(mlxsw_sp, mall_entry->mirror.span_id); in mlxsw_sp_mall_port_mirror_del()
95 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_mall_port_sample_set()
98 mlxsw_reg_mpsc_pack(mpsc_pl, mlxsw_sp_port->local_port, enable, rate); in mlxsw_sp_mall_port_sample_set()
99 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpsc), mpsc_pl); in mlxsw_sp_mall_port_sample_set()
107 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_mall_port_sample_add()
111 if (mall_entry->ingress) in mlxsw_sp_mall_port_sample_add()
115 trigger.local_port = mlxsw_sp_port->local_port; in mlxsw_sp_mall_port_sample_add()
117 &mall_entry->sample.params, in mlxsw_sp_mall_port_sample_add()
122 err = mlxsw_sp->mall_ops->sample_add(mlxsw_sp, mlxsw_sp_port, in mlxsw_sp_mall_port_sample_add()
137 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_mall_port_sample_del()
140 if (mall_entry->ingress) in mlxsw_sp_mall_port_sample_del()
144 trigger.local_port = mlxsw_sp_port->local_port; in mlxsw_sp_mall_port_sample_del()
146 mlxsw_sp->mall_ops->sample_del(mlxsw_sp, mlxsw_sp_port, mall_entry); in mlxsw_sp_mall_port_sample_del()
155 switch (mall_entry->type) { in mlxsw_sp_mall_port_rule_add()
164 return -EINVAL; in mlxsw_sp_mall_port_rule_add()
172 switch (mall_entry->type) { in mlxsw_sp_mall_port_rule_del()
188 if (list_empty(&block->mall.list)) in mlxsw_sp_mall_prio_update()
190 block->mall.min_prio = UINT_MAX; in mlxsw_sp_mall_prio_update()
191 block->mall.max_prio = 0; in mlxsw_sp_mall_prio_update()
192 list_for_each_entry(mall_entry, &block->mall.list, list) { in mlxsw_sp_mall_prio_update()
193 if (mall_entry->priority < block->mall.min_prio) in mlxsw_sp_mall_prio_update()
194 block->mall.min_prio = mall_entry->priority; in mlxsw_sp_mall_prio_update()
195 if (mall_entry->priority > block->mall.max_prio) in mlxsw_sp_mall_prio_update()
196 block->mall.max_prio = mall_entry->priority; in mlxsw_sp_mall_prio_update()
206 __be16 protocol = f->common.protocol; in mlxsw_sp_mall_replace()
213 if (!flow_offload_has_one_action(&f->rule->action)) { in mlxsw_sp_mall_replace()
214 NL_SET_ERR_MSG(f->common.extack, "Only singular actions are supported"); in mlxsw_sp_mall_replace()
215 return -EOPNOTSUPP; in mlxsw_sp_mall_replace()
218 if (f->common.chain_index) { in mlxsw_sp_mall_replace()
219 NL_SET_ERR_MSG(f->common.extack, "Only chain 0 is supported"); in mlxsw_sp_mall_replace()
220 return -EOPNOTSUPP; in mlxsw_sp_mall_replace()
224 NL_SET_ERR_MSG(f->common.extack, "Only not mixed bound blocks are supported"); in mlxsw_sp_mall_replace()
225 return -EOPNOTSUPP; in mlxsw_sp_mall_replace()
228 err = mlxsw_sp_flower_prio_get(mlxsw_sp, block, f->common.chain_index, in mlxsw_sp_mall_replace()
231 if (err != -ENOENT) { in mlxsw_sp_mall_replace()
232 NL_SET_ERR_MSG(f->common.extack, "Failed to get flower priorities"); in mlxsw_sp_mall_replace()
242 NL_SET_ERR_MSG(f->common.extack, "matchall rules only supported with 'all' protocol"); in mlxsw_sp_mall_replace()
243 return -EOPNOTSUPP; in mlxsw_sp_mall_replace()
248 return -ENOMEM; in mlxsw_sp_mall_replace()
249 mall_entry->cookie = f->cookie; in mlxsw_sp_mall_replace()
250 mall_entry->priority = f->common.prio; in mlxsw_sp_mall_replace()
251 mall_entry->ingress = mlxsw_sp_flow_block_is_ingress_bound(block); in mlxsw_sp_mall_replace()
253 if (flower_prio_valid && mall_entry->ingress && in mlxsw_sp_mall_replace()
254 mall_entry->priority >= flower_min_prio) { in mlxsw_sp_mall_replace()
255 NL_SET_ERR_MSG(f->common.extack, "Failed to add behind existing flower rules"); in mlxsw_sp_mall_replace()
256 err = -EOPNOTSUPP; in mlxsw_sp_mall_replace()
259 if (flower_prio_valid && !mall_entry->ingress && in mlxsw_sp_mall_replace()
260 mall_entry->priority <= flower_max_prio) { in mlxsw_sp_mall_replace()
261 NL_SET_ERR_MSG(f->common.extack, "Failed to add in front of existing flower rules"); in mlxsw_sp_mall_replace()
262 err = -EOPNOTSUPP; in mlxsw_sp_mall_replace()
266 act = &f->rule->action.entries[0]; in mlxsw_sp_mall_replace()
268 switch (act->id) { in mlxsw_sp_mall_replace()
270 mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_MIRROR; in mlxsw_sp_mall_replace()
271 mall_entry->mirror.to_dev = act->dev; in mlxsw_sp_mall_replace()
274 mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_SAMPLE; in mlxsw_sp_mall_replace()
275 mall_entry->sample.params.psample_group = act->sample.psample_group; in mlxsw_sp_mall_replace()
276 mall_entry->sample.params.truncate = act->sample.truncate; in mlxsw_sp_mall_replace()
277 mall_entry->sample.params.trunc_size = act->sample.trunc_size; in mlxsw_sp_mall_replace()
278 mall_entry->sample.params.rate = act->sample.rate; in mlxsw_sp_mall_replace()
281 err = -EOPNOTSUPP; in mlxsw_sp_mall_replace()
285 list_for_each_entry(binding, &block->binding_list, list) { in mlxsw_sp_mall_replace()
286 err = mlxsw_sp_mall_port_rule_add(binding->mlxsw_sp_port, in mlxsw_sp_mall_replace()
287 mall_entry, f->common.extack); in mlxsw_sp_mall_replace()
292 block->rule_count++; in mlxsw_sp_mall_replace()
293 if (mall_entry->ingress) in mlxsw_sp_mall_replace()
294 block->egress_blocker_rule_count++; in mlxsw_sp_mall_replace()
296 block->ingress_blocker_rule_count++; in mlxsw_sp_mall_replace()
297 list_add_tail(&mall_entry->list, &block->mall.list); in mlxsw_sp_mall_replace()
302 list_for_each_entry_continue_reverse(binding, &block->binding_list, in mlxsw_sp_mall_replace()
304 mlxsw_sp_mall_port_rule_del(binding->mlxsw_sp_port, mall_entry); in mlxsw_sp_mall_replace()
316 mall_entry = mlxsw_sp_mall_entry_find(block, f->cookie); in mlxsw_sp_mall_destroy()
318 NL_SET_ERR_MSG(f->common.extack, "Entry not found"); in mlxsw_sp_mall_destroy()
322 list_del(&mall_entry->list); in mlxsw_sp_mall_destroy()
323 if (mall_entry->ingress) in mlxsw_sp_mall_destroy()
324 block->egress_blocker_rule_count--; in mlxsw_sp_mall_destroy()
326 block->ingress_blocker_rule_count--; in mlxsw_sp_mall_destroy()
327 block->rule_count--; in mlxsw_sp_mall_destroy()
328 list_for_each_entry(binding, &block->binding_list, list) in mlxsw_sp_mall_destroy()
329 mlxsw_sp_mall_port_rule_del(binding->mlxsw_sp_port, mall_entry); in mlxsw_sp_mall_destroy()
330 kfree_rcu(mall_entry, rcu); /* sample RX packets may be in-flight */ in mlxsw_sp_mall_destroy()
341 list_for_each_entry(mall_entry, &block->mall.list, list) { in mlxsw_sp_mall_port_bind()
350 list_for_each_entry_continue_reverse(mall_entry, &block->mall.list, in mlxsw_sp_mall_port_bind()
361 list_for_each_entry(mall_entry, &block->mall.list, list) in mlxsw_sp_mall_port_unbind()
368 if (chain_index || list_empty(&block->mall.list)) in mlxsw_sp_mall_prio_get()
369 /* In case there are no matchall rules, the caller in mlxsw_sp_mall_prio_get()
370 * receives -ENOENT to indicate there is no need in mlxsw_sp_mall_prio_get()
373 return -ENOENT; in mlxsw_sp_mall_prio_get()
374 *p_min_prio = block->mall.min_prio; in mlxsw_sp_mall_prio_get()
375 *p_max_prio = block->mall.max_prio; in mlxsw_sp_mall_prio_get()
384 u32 rate = mall_entry->sample.params.rate; in mlxsw_sp1_mall_sample_add()
386 if (!mall_entry->ingress) { in mlxsw_sp1_mall_sample_add()
388 return -EOPNOTSUPP; in mlxsw_sp1_mall_sample_add()
393 return -EOPNOTSUPP; in mlxsw_sp1_mall_sample_add()
421 u32 rate = mall_entry->sample.params.rate; in mlxsw_sp2_mall_sample_add()
425 err = mlxsw_sp_span_agent_get(mlxsw_sp, &mall_entry->sample.span_id, in mlxsw_sp2_mall_sample_add()
433 mall_entry->ingress); in mlxsw_sp2_mall_sample_add()
439 span_trigger = mall_entry->ingress ? MLXSW_SP_SPAN_TRIGGER_INGRESS : in mlxsw_sp2_mall_sample_add()
441 trigger_parms.span_id = mall_entry->sample.span_id; in mlxsw_sp2_mall_sample_add()
453 mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, mall_entry->ingress); in mlxsw_sp2_mall_sample_add()
455 mlxsw_sp_span_agent_put(mlxsw_sp, mall_entry->sample.span_id); in mlxsw_sp2_mall_sample_add()
466 span_trigger = mall_entry->ingress ? MLXSW_SP_SPAN_TRIGGER_INGRESS : in mlxsw_sp2_mall_sample_del()
468 trigger_parms.span_id = mall_entry->sample.span_id; in mlxsw_sp2_mall_sample_del()
471 mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, mall_entry->ingress); in mlxsw_sp2_mall_sample_del()
472 mlxsw_sp_span_agent_put(mlxsw_sp, mall_entry->sample.span_id); in mlxsw_sp2_mall_sample_del()