mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
net/mlx5e: TC, allow meter jump control action
Separate the matchall police action validation from flower validation. Isolate the action validation logic in the police action parser. Signed-off-by: Oz Shlomo <ozsh@nvidia.com> Reviewed-by: Roi Dayan <roid@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Link: https://lore.kernel.org/r/20221203221337.29267-12-saeed@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
0d8c38d44f
commit
3603f26633
@ -4,20 +4,54 @@
|
||||
#include "act.h"
|
||||
#include "en/tc_priv.h"
|
||||
|
||||
static bool police_act_validate_control(enum flow_action_id act_id,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (act_id != FLOW_ACTION_PIPE &&
|
||||
act_id != FLOW_ACTION_ACCEPT &&
|
||||
act_id != FLOW_ACTION_JUMP &&
|
||||
act_id != FLOW_ACTION_DROP) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Offload not supported when conform-exceed action is not pipe, ok, jump or drop");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int police_act_validate(const struct flow_action_entry *act,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (!police_act_validate_control(act->police.exceed.act_id, extack) ||
|
||||
!police_act_validate_control(act->police.notexceed.act_id, extack))
|
||||
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;
|
||||
}
|
||||
|
||||
static bool
|
||||
tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state,
|
||||
const struct flow_action_entry *act,
|
||||
int act_index,
|
||||
struct mlx5_flow_attr *attr)
|
||||
{
|
||||
if (act->police.notexceed.act_id != FLOW_ACTION_PIPE &&
|
||||
act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) {
|
||||
NL_SET_ERR_MSG_MOD(parse_state->extack,
|
||||
"Offload not supported when conform action is not pipe or ok");
|
||||
return false;
|
||||
}
|
||||
if (mlx5e_policer_validate(parse_state->flow_action, act,
|
||||
parse_state->extack))
|
||||
int err;
|
||||
|
||||
err = police_act_validate(act, parse_state->extack);
|
||||
if (err)
|
||||
return false;
|
||||
|
||||
return !!mlx5e_get_flow_meters(parse_state->flow->priv->mdev);
|
||||
@ -79,7 +113,7 @@ tc_act_police_offload(struct mlx5e_priv *priv,
|
||||
struct mlx5e_flow_meter_handle *meter;
|
||||
int err = 0;
|
||||
|
||||
err = mlx5e_policer_validate(&fl_act->action, act, fl_act->extack);
|
||||
err = police_act_validate(act, fl_act->extack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -211,8 +211,4 @@ struct mlx5e_flow_meters *mlx5e_get_flow_meters(struct mlx5_core_dev *dev);
|
||||
void *mlx5e_get_match_headers_value(u32 flags, struct mlx5_flow_spec *spec);
|
||||
void *mlx5e_get_match_headers_criteria(u32 flags, struct mlx5_flow_spec *spec);
|
||||
|
||||
int mlx5e_policer_validate(const struct flow_action *action,
|
||||
const struct flow_action_entry *act,
|
||||
struct netlink_ext_ack *extack);
|
||||
|
||||
#endif /* __MLX5_EN_TC_PRIV_H__ */
|
||||
|
@ -4939,10 +4939,17 @@ static int apply_police_params(struct mlx5e_priv *priv, u64 rate,
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5e_policer_validate(const struct flow_action *action,
|
||||
const struct flow_action_entry *act,
|
||||
struct netlink_ext_ack *extack)
|
||||
static int
|
||||
tc_matchall_police_validate(const struct flow_action *action,
|
||||
const struct flow_action_entry *act,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Offload not supported when conform action is not continue");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (act->police.exceed.act_id != FLOW_ACTION_DROP) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Offload not supported when exceed action is not drop");
|
||||
@ -4993,13 +5000,7 @@ static int scan_tc_matchall_fdb_actions(struct mlx5e_priv *priv,
|
||||
flow_action_for_each(i, act, flow_action) {
|
||||
switch (act->id) {
|
||||
case FLOW_ACTION_POLICE:
|
||||
if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Offload not supported when conform action is not continue");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
err = mlx5e_policer_validate(flow_action, act, extack);
|
||||
err = tc_matchall_police_validate(flow_action, act, extack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user