staticint mlxsw_sp_policer_validate(conststruct flow_action *action, conststruct flow_action_entry *act, struct netlink_ext_ack *extack)
{ if (act->police.exceed.act_id != FLOW_ACTION_DROP) {
NL_SET_ERR_MSG_MOD(extack, "Offload not supported when exceed action is not drop"); return -EOPNOTSUPP;
}
if (act->police.notexceed.act_id != FLOW_ACTION_PIPE &&
act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) {
NL_SET_ERR_MSG_MOD(extack, "Offload not supported when conform action is not pipe or ok"); return -EOPNOTSUPP;
}
if (act->police.notexceed.act_id == FLOW_ACTION_ACCEPT &&
!flow_action_is_last_entry(action, act)) {
NL_SET_ERR_MSG_MOD(extack, "Offload not supported when conform action is ok, but action is not last"); return -EOPNOTSUPP;
}
if (act->police.peakrate_bytes_ps ||
act->police.avrate || act->police.overhead) {
NL_SET_ERR_MSG_MOD(extack, "Offload not supported when peakrate/avrate/overhead is configured"); return -EOPNOTSUPP;
}
if (act->police.rate_pkt_ps) {
NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second"); return -EOPNOTSUPP;
}
return 0;
}
staticint mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_flow_block *block, struct mlxsw_sp_acl_rule_info *rulei, struct flow_action *flow_action, struct netlink_ext_ack *extack)
{ conststruct flow_action_entry *act; int mirror_act_count = 0; int police_act_count = 0; int sample_act_count = 0; int err, i;
if (!flow_action_has_entries(flow_action)) return 0; if (!flow_action_mixed_hw_stats_check(flow_action, extack)) return -EOPNOTSUPP;
act = flow_action_first_entry_get(flow_action); if (act->hw_stats & FLOW_ACTION_HW_STATS_DISABLED) { /* Nothing to do */
} elseif (act->hw_stats & FLOW_ACTION_HW_STATS_IMMEDIATE) { /* Count action is inserted first */
err = mlxsw_sp_acl_rulei_act_count(mlxsw_sp, rulei, extack); if (err) return err;
} else {
NL_SET_ERR_MSG_MOD(extack, "Unsupported action HW stats type"); return -EOPNOTSUPP;
}
flow_action_for_each(i, act, flow_action) { switch (act->id) { case FLOW_ACTION_ACCEPT:
err = mlxsw_sp_acl_rulei_act_terminate(rulei); if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append terminate action"); return err;
} break; case FLOW_ACTION_DROP: { bool ingress;
if (mlxsw_sp_flow_block_is_mixed_bound(block)) {
NL_SET_ERR_MSG_MOD(extack, "Drop action is not supported when block is bound to ingress and egress"); return -EOPNOTSUPP;
}
ingress = mlxsw_sp_flow_block_is_ingress_bound(block);
err = mlxsw_sp_acl_rulei_act_drop(rulei, ingress,
act->user_cookie, extack); if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append drop action"); return err;
}
/* Forbid block with this rulei to be bound * to ingress/egress in future. Ingress rule is * a blocker for egress and vice versa.
*/ if (ingress)
rulei->egress_bind_blocker = 1; else
rulei->ingress_bind_blocker = 1;
} break; case FLOW_ACTION_TRAP:
err = mlxsw_sp_acl_rulei_act_trap(rulei); if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append trap action"); return err;
} break; case FLOW_ACTION_GOTO: {
u32 chain_index = act->chain_index; struct mlxsw_sp_acl_ruleset *ruleset;
u16 group_id;
ruleset = mlxsw_sp_acl_ruleset_lookup(mlxsw_sp, block,
chain_index,
MLXSW_SP_ACL_PROFILE_FLOWER); if (IS_ERR(ruleset)) return PTR_ERR(ruleset);
if (mirror_act_count++) {
NL_SET_ERR_MSG_MOD(extack, "Multiple mirror actions per rule are not supported"); return -EOPNOTSUPP;
}
if (sample_act_count) {
NL_SET_ERR_MSG_MOD(extack, "Mirror action after sample action is not supported"); return -EOPNOTSUPP;
}
err = mlxsw_sp_acl_rulei_act_mirror(mlxsw_sp, rulei,
block, out_dev,
extack); if (err) return err;
} break; case FLOW_ACTION_VLAN_MANGLE: {
u16 proto = be16_to_cpu(act->vlan.proto);
u8 prio = act->vlan.prio;
u16 vid = act->vlan.vid;
err = mlxsw_sp_acl_rulei_act_vlan(mlxsw_sp, rulei,
act->id, vid,
proto, prio, extack); if (err) return err; break;
} case FLOW_ACTION_PRIORITY:
err = mlxsw_sp_acl_rulei_act_priority(mlxsw_sp, rulei,
act->priority,
extack); if (err) return err; break; case FLOW_ACTION_MANGLE: { enum flow_action_mangle_base htype = act->mangle.htype;
__be32 be_mask = (__force __be32) act->mangle.mask;
__be32 be_val = (__force __be32) act->mangle.val;
u32 offset = act->mangle.offset;
u32 mask = be32_to_cpu(be_mask);
u32 val = be32_to_cpu(be_val);
err = mlxsw_sp_acl_rulei_act_mangle(mlxsw_sp, rulei,
htype, offset,
mask, val, extack); if (err) return err; break;
} case FLOW_ACTION_POLICE: {
u32 burst;
if (police_act_count++) {
NL_SET_ERR_MSG_MOD(extack, "Multiple police actions per rule are not supported"); return -EOPNOTSUPP;
}
err = mlxsw_sp_policer_validate(flow_action, act, extack); if (err) return err;
/* The kernel might adjust the requested burst size so * that it is not exactly a power of two. Re-adjust it * here since the hardware only supports burst sizes * that are a power of two.
*/
burst = roundup_pow_of_two(act->police.burst);
err = mlxsw_sp_acl_rulei_act_police(mlxsw_sp, rulei,
act->hw_index,
act->police.rate_bytes_ps,
burst, extack); if (err) return err; break;
} case FLOW_ACTION_SAMPLE: { if (sample_act_count++) {
NL_SET_ERR_MSG_MOD(extack, "Multiple sample actions per rule are not supported"); return -EOPNOTSUPP;
}
if (mirror_act_count) {
NL_SET_ERR_MSG_MOD(extack, "Sample action after mirror action is not supported"); return -EOPNOTSUPP;
}
ingress_dev = __dev_get_by_index(block->net,
match->key->ingress_ifindex); if (!ingress_dev) {
NL_SET_ERR_MSG_MOD(extack, "Can't find specified ingress port to match on"); return -EINVAL;
}
if (!mlxsw_sp_port_dev_check(ingress_dev)) {
NL_SET_ERR_MSG_MOD(extack, "Can't match on non-mlxsw ingress port"); return -EINVAL;
}
mlxsw_sp_port = netdev_priv(ingress_dev); if (mlxsw_sp_port->mlxsw_sp != block->mlxsw_sp) {
NL_SET_ERR_MSG_MOD(extack, "Can't match on a port from different device"); return -EINVAL;
}
if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_TCP)) return 0;
if (ip_proto != IPPROTO_TCP) {
NL_SET_ERR_MSG_MOD(f->common.extack, "TCP keys supported only for TCP");
dev_err(mlxsw_sp->bus_info->dev, "TCP keys supported only for TCP\n"); return -EINVAL;
}
flow_rule_match_tcp(rule, &match);
if (match.mask->flags & htons(0x0E00)) {
NL_SET_ERR_MSG_MOD(f->common.extack, "TCP flags match not supported on reserved bits");
dev_err(mlxsw_sp->bus_info->dev, "TCP flags match not supported on reserved bits\n"); return -EINVAL;
}
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) { struct flow_match_vlan match;
flow_rule_match_vlan(rule, &match); if (mlxsw_sp_flow_block_is_egress_bound(block) &&
match.mask->vlan_id) {
NL_SET_ERR_MSG_MOD(f->common.extack, "vlan_id key is not supported on egress"); return -EOPNOTSUPP;
}
/* Forbid block with this rulei to be bound * to egress in future.
*/
rulei->egress_bind_blocker = 1;
if (match.mask->vlan_id != 0)
mlxsw_sp_acl_rulei_keymask_u32(rulei,
MLXSW_AFK_ELEMENT_VID,
match.key->vlan_id,
match.mask->vlan_id); if (match.mask->vlan_priority != 0)
mlxsw_sp_acl_rulei_keymask_u32(rulei,
MLXSW_AFK_ELEMENT_PCP,
match.key->vlan_priority,
match.mask->vlan_priority);
}
if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS)
mlxsw_sp_flower_parse_ipv4(rulei, f);
if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS)
mlxsw_sp_flower_parse_ipv6(rulei, f);
err = mlxsw_sp_flower_parse_ports(mlxsw_sp, rulei, f, ip_proto); if (err) return err;
err = mlxsw_sp_flower_parse_ports_range(mlxsw_sp, rulei, f, ip_proto); if (err) return err;
err = mlxsw_sp_flower_parse_tcp(mlxsw_sp, rulei, f, ip_proto); if (err) return err;
err = mlxsw_sp_mall_prio_get(block, f->common.chain_index,
&mall_min_prio, &mall_max_prio); if (err) { if (err == -ENOENT) /* No matchall filters installed on this chain. */ return 0;
NL_SET_ERR_MSG(f->common.extack, "Failed to get matchall priorities"); return err;
} if (ingress && f->common.prio <= mall_min_prio) {
NL_SET_ERR_MSG(f->common.extack, "Failed to add in front of existing matchall rules"); return -EOPNOTSUPP;
} if (!ingress && f->common.prio >= mall_max_prio) {
NL_SET_ERR_MSG(f->common.extack, "Failed to add behind of existing matchall rules"); return -EOPNOTSUPP;
} return 0;
}
ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, block,
f->common.chain_index,
MLXSW_SP_ACL_PROFILE_FLOWER, NULL); if (IS_ERR(ruleset)) return; /* put the reference to the ruleset kept in create */
mlxsw_sp_acl_ruleset_put(mlxsw_sp, ruleset);
mlxsw_sp_acl_ruleset_put(mlxsw_sp, ruleset);
}
ruleset = mlxsw_sp_acl_ruleset_lookup(mlxsw_sp, block,
chain_index,
MLXSW_SP_ACL_PROFILE_FLOWER); if (IS_ERR(ruleset)) /* In case there are no flower rules, the caller * receives -ENOENT to indicate there is no need * to check the priorities.
*/ return PTR_ERR(ruleset);
mlxsw_sp_acl_ruleset_prio_get(ruleset, p_min_prio, p_max_prio); return 0;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.