From: Vladimir Oltean <olteanv@gmail.com>
To: Jianbo Liu <jianbol@nvidia.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, andrew@lunn.ch,
vivien.didelot@gmail.com, f.fainelli@gmail.com,
davem@davemloft.net, kuba@kernel.org, rajur@chelsio.com,
claudiu.manoil@nxp.com, sgoutham@marvell.com, gakula@marvell.com,
sbhatta@marvell.com, hkelam@marvell.com, saeedm@nvidia.com,
leon@kernel.org, idosch@nvidia.com, petrm@nvidia.com,
alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com,
simon.horman@corigine.com, jhs@mojatatu.com,
xiyou.wangcong@gmail.com, jiri@resnulli.us,
baowen.zheng@corigine.com, louis.peens@netronome.com,
peng.zhang@corigine.com, oss-drivers@corigine.com,
roid@nvidia.com
Subject: Re: [PATCH net-next v2 2/2] flow_offload: reject offload for all drivers with invalid police parameters
Date: Thu, 17 Feb 2022 14:49:35 +0200 [thread overview]
Message-ID: <20220217124935.p7pbgv2cfmhpshxv@skbuf> (raw)
In-Reply-To: <20220217082803.3881-3-jianbol@nvidia.com>
On Thu, Feb 17, 2022 at 08:28:03AM +0000, Jianbo Liu wrote:
> As more police parameters are passed to flow_offload, driver can check
> them to make sure hardware handles packets in the way indicated by tc.
> The conform-exceed control should be drop/pipe or drop/ok. Besides,
> for drop/ok, the police should be the last action. As hardware can't
> configure peakrate/avrate/overhead, offload should not be supported if
> any of them is configured.
>
> Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
> Reviewed-by: Roi Dayan <roid@nvidia.com>
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> ---
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
But could we cut down on line length a little? Example for sja1105
(messages were also shortened):
diff --git a/drivers/net/dsa/sja1105/sja1105_flower.c b/drivers/net/dsa/sja1105/sja1105_flower.c
index 8a14df8cf91e..54a16369a39e 100644
--- a/drivers/net/dsa/sja1105/sja1105_flower.c
+++ b/drivers/net/dsa/sja1105/sja1105_flower.c
@@ -300,6 +300,46 @@ static int sja1105_flower_parse_key(struct sja1105_private *priv,
return -EOPNOTSUPP;
}
+static int sja1105_policer_validate(const struct flow_action *action,
+ const struct 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;
+}
+
int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
struct flow_cls_offload *cls, bool ingress)
{
@@ -321,39 +361,10 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
flow_action_for_each(i, act, &rule->action) {
switch (act->id) {
case FLOW_ACTION_POLICE:
- if (act->police.exceed.act_id != FLOW_ACTION_DROP) {
- NL_SET_ERR_MSG_MOD(extack,
- "Police offload is not supported when the 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,
- "Police offload is not supported when the conform action is not pipe or ok");
- return -EOPNOTSUPP;
- }
-
- if (act->police.notexceed.act_id == FLOW_ACTION_ACCEPT &&
- !flow_action_is_last_entry(&rule->action, act)) {
- NL_SET_ERR_MSG_MOD(extack,
- "Police offload is not supported when the conform action is ok, but police action is not last");
- return -EOPNOTSUPP;
- }
-
- if (act->police.peakrate_bytes_ps ||
- act->police.avrate || act->police.overhead) {
- NL_SET_ERR_MSG_MOD(extack,
- "Police offload is 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");
- rc = -EOPNOTSUPP;
+ rc = sja1105_policer_validate(&rule->action, act,
+ extack);
+ if (rc)
goto out;
- }
rc = sja1105_flower_policer(priv, port, extack, cookie,
&key,
Also, if you create a "validate" function for every driver, you'll
remove code duplication for those drivers that support both matchall and
flower policers.
next prev parent reply other threads:[~2022-02-17 12:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 8:28 [PATCH net-next v2 0/2] flow_offload: add tc police parameters Jianbo Liu
2022-02-17 8:28 ` [PATCH net-next v2 1/2] net: flow_offload: add tc police action parameters Jianbo Liu
2022-02-17 10:25 ` Baowen Zheng
2022-02-17 12:10 ` Roi Dayan
2022-02-18 1:46 ` Baowen Zheng
2022-02-18 2:22 ` Jianbo Liu
2022-02-23 1:54 ` Jianbo Liu
2022-02-17 8:28 ` [PATCH net-next v2 2/2] flow_offload: reject offload for all drivers with invalid police parameters Jianbo Liu
2022-02-17 12:49 ` Vladimir Oltean [this message]
2022-02-17 13:57 ` Ido Schimmel
2022-02-22 1:58 ` Jianbo Liu
2022-02-22 10:09 ` Vladimir Oltean
2022-02-22 10:27 ` Jianbo Liu
2022-02-22 10:29 ` Baowen Zheng
2022-02-22 16:31 ` Ido Schimmel
2022-02-17 11:34 ` [PATCH net-next v2 0/2] flow_offload: add tc " Simon Horman
2022-02-17 11:52 ` Roi Dayan
2022-02-18 10:38 ` Simon Horman
2022-02-17 11:56 ` Ido Schimmel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220217124935.p7pbgv2cfmhpshxv@skbuf \
--to=olteanv@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=baowen.zheng@corigine.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=gakula@marvell.com \
--cc=hkelam@marvell.com \
--cc=idosch@nvidia.com \
--cc=jhs@mojatatu.com \
--cc=jianbol@nvidia.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=louis.peens@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
--cc=petrm@nvidia.com \
--cc=rajur@chelsio.com \
--cc=roid@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.com \
--cc=simon.horman@corigine.com \
--cc=vivien.didelot@gmail.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox