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:
committed by
Jakub Kicinski
parent
0d8c38d44f
commit
3603f26633
@ -4,20 +4,54 @@
|
|||||||
#include "act.h"
|
#include "act.h"
|
||||||
#include "en/tc_priv.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
|
static bool
|
||||||
tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state,
|
tc_act_can_offload_police(struct mlx5e_tc_act_parse_state *parse_state,
|
||||||
const struct flow_action_entry *act,
|
const struct flow_action_entry *act,
|
||||||
int act_index,
|
int act_index,
|
||||||
struct mlx5_flow_attr *attr)
|
struct mlx5_flow_attr *attr)
|
||||||
{
|
{
|
||||||
if (act->police.notexceed.act_id != FLOW_ACTION_PIPE &&
|
int err;
|
||||||
act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) {
|
|
||||||
NL_SET_ERR_MSG_MOD(parse_state->extack,
|
err = police_act_validate(act, parse_state->extack);
|
||||||
"Offload not supported when conform action is not pipe or ok");
|
if (err)
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (mlx5e_policer_validate(parse_state->flow_action, act,
|
|
||||||
parse_state->extack))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !!mlx5e_get_flow_meters(parse_state->flow->priv->mdev);
|
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;
|
struct mlx5e_flow_meter_handle *meter;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
err = mlx5e_policer_validate(&fl_act->action, act, fl_act->extack);
|
err = police_act_validate(act, fl_act->extack);
|
||||||
if (err)
|
if (err)
|
||||||
return 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_value(u32 flags, struct mlx5_flow_spec *spec);
|
||||||
void *mlx5e_get_match_headers_criteria(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__ */
|
#endif /* __MLX5_EN_TC_PRIV_H__ */
|
||||||
|
@ -4939,10 +4939,17 @@ static int apply_police_params(struct mlx5e_priv *priv, u64 rate,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mlx5e_policer_validate(const struct flow_action *action,
|
static int
|
||||||
|
tc_matchall_police_validate(const struct flow_action *action,
|
||||||
const struct flow_action_entry *act,
|
const struct flow_action_entry *act,
|
||||||
struct netlink_ext_ack *extack)
|
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) {
|
if (act->police.exceed.act_id != FLOW_ACTION_DROP) {
|
||||||
NL_SET_ERR_MSG_MOD(extack,
|
NL_SET_ERR_MSG_MOD(extack,
|
||||||
"Offload not supported when exceed action is not drop");
|
"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) {
|
flow_action_for_each(i, act, flow_action) {
|
||||||
switch (act->id) {
|
switch (act->id) {
|
||||||
case FLOW_ACTION_POLICE:
|
case FLOW_ACTION_POLICE:
|
||||||
if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE) {
|
err = tc_matchall_police_validate(flow_action, act, extack);
|
||||||
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);
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user