Skip to content

Commit

Permalink
nfp: flower: add validation of for police actions which are independe…
Browse files Browse the repository at this point in the history
…nt of flows

Validation of police actions was added to offload drivers in
commit d97b4b1 ("flow_offload: reject offload for all drivers with
invalid police parameters")

This patch extends that validation in the nfp driver to include
police actions which are created independently of flows.

Signed-off-by: Ziyang Chen <[email protected]>
Reviewed-by: Baowen Zheng <[email protected]>
Reviewed-by: Louis Peens <[email protected]>
Signed-off-by: Simon Horman <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
ziyang0371 authored and kuba-moo committed Sep 20, 2022
1 parent 4fa37e4 commit 9f1a948
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions drivers/net/ethernet/netronome/nfp/flower/qos_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,29 @@ int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress,

static int nfp_policer_validate(const struct flow_action *action,
const struct flow_action_entry *act,
struct netlink_ext_ack *extack)
struct netlink_ext_ack *extack,
bool ingress)
{
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_CONTINUE &&
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 continue, pipe or ok");
return -EOPNOTSUPP;
if (ingress) {
if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE &&
act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) {
NL_SET_ERR_MSG_MOD(extack,
"Offload not supported when conform action is not continue or ok");
return -EOPNOTSUPP;
}
} else {
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 &&
Expand Down Expand Up @@ -218,7 +227,7 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev,
return -EOPNOTSUPP;
}

err = nfp_policer_validate(&flow->rule->action, action, extack);
err = nfp_policer_validate(&flow->rule->action, action, extack, true);
if (err)
return err;

Expand Down Expand Up @@ -687,6 +696,7 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act,
bool pps_support, pps;
bool add = false;
u64 rate;
int err;

pps_support = !!(fl_priv->flower_ext_feats & NFP_FL_FEATS_QOS_PPS);

Expand All @@ -698,6 +708,11 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act,
"unsupported offload: qos rate limit offload requires police action");
continue;
}

err = nfp_policer_validate(&fl_act->action, action, extack, false);
if (err)
return err;

if (action->police.rate_bytes_ps > 0) {
rate = action->police.rate_bytes_ps;
burst = action->police.burst;
Expand Down

0 comments on commit 9f1a948

Please sign in to comment.