From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Jianbo Liu <jianbol@nvidia.com>
Cc: "olteanv@gmail.com" <olteanv@gmail.com>,
"andrew@lunn.ch" <andrew@lunn.ch>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
"vivien.didelot@gmail.com" <vivien.didelot@gmail.com>,
Petr Machata <petrm@nvidia.com>,
"jhs@mojatatu.com" <jhs@mojatatu.com>,
"oss-drivers@corigine.com" <oss-drivers@corigine.com>,
"hkelam@marvell.com" <hkelam@marvell.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"leon@kernel.org" <leon@kernel.org>,
"peng.zhang@corigine.com" <peng.zhang@corigine.com>,
"louis.peens@netronome.com" <louis.peens@netronome.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"alexandre.belloni@bootlin.com" <alexandre.belloni@bootlin.com>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
"rajur@chelsio.com" <rajur@chelsio.com>,
Ido Schimmel <idosch@nvidia.com>,
"simon.horman@corigine.com" <simon.horman@corigine.com>,
"sbhatta@marvell.com" <sbhatta@marvell.com>,
"xiyou.wangcong@gmail.com" <xiyou.wangcong@gmail.com>,
Roi Dayan <roid@nvidia.com>, "kuba@kernel.org" <kuba@kernel.org>,
"baowen.zheng@corigine.com" <baowen.zheng@corigine.com>,
"jiri@resnulli.us" <jiri@resnulli.us>,
Saeed Mahameed <saeedm@nvidia.com>,
"sgoutham@marvell.com" <sgoutham@marvell.com>,
"gakula@marvell.com" <gakula@marvell.com>,
"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2 2/2] flow_offload: reject offload for all drivers with invalid police parameters
Date: Tue, 22 Feb 2022 10:09:30 +0000 [thread overview]
Message-ID: <20220222100929.gj2my4maclyrwz35@skbuf> (raw)
In-Reply-To: <6291dabcca7dd2d95b4961f660ec8b0226b8fbce.camel@nvidia.com>
[-- Attachment #1: Type: text/plain, Size: 350 bytes --]
Hi Jianbo,
On Tue, Feb 22, 2022 at 01:58:23AM +0000, Jianbo Liu wrote:
> Hi Vladimir,
>
> I'd love to hear your suggestion regarding where this validate function
> to be placed for drivers/net/ethernet/mscc, as it will be used by both
> ocelot_net.c and ocelot_flower.c.
>
> Thanks!
> Jianbo
Try the attached patch on top of yours.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ocelot-policer-validate.patch --]
[-- Type: text/x-diff; name="0001-ocelot-policer-validate.patch", Size: 7837 bytes --]
From d401f55a34390c27b35ae647d260e2b900528517 Mon Sep 17 00:00:00 2001
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: Tue, 22 Feb 2022 12:05:59 +0200
Subject: [PATCH] ocelot policer validate
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/ethernet/mscc/ocelot_flower.c | 38 ++++-----------------
drivers/net/ethernet/mscc/ocelot_net.c | 37 +++-----------------
drivers/net/ethernet/mscc/ocelot_police.c | 41 +++++++++++++++++++++++
drivers/net/ethernet/mscc/ocelot_police.h | 5 +++
4 files changed, 57 insertions(+), 64 deletions(-)
diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c
index 4680a62b4d9a..b3f5418dc622 100644
--- a/drivers/net/ethernet/mscc/ocelot_flower.c
+++ b/drivers/net/ethernet/mscc/ocelot_flower.c
@@ -6,6 +6,7 @@
#include <net/pkt_cls.h>
#include <net/tc_act/tc_gact.h>
#include <soc/mscc/ocelot_vcap.h>
+#include "ocelot_police.h"
#include "ocelot_vcap.h"
/* Arbitrarily chosen constants for encoding the VCAP block and lookup number
@@ -217,6 +218,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
bool ingress, struct flow_cls_offload *f,
struct ocelot_vcap_filter *filter)
{
+ const struct flow_action *action = &f->rule->action;
struct netlink_ext_ack *extack = f->common.extack;
bool allow_missing_goto_target = false;
const struct flow_action_entry *a;
@@ -244,7 +246,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
filter->goto_target = -1;
filter->type = OCELOT_VCAP_FILTER_DUMMY;
- flow_action_for_each(i, a, &f->rule->action) {
+ flow_action_for_each(i, a, action) {
switch (a->id) {
case FLOW_ACTION_DROP:
if (filter->block_id != VCAP_IS2) {
@@ -298,38 +300,10 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
return -EOPNOTSUPP;
}
- if (a->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 (a->police.notexceed.act_id != FLOW_ACTION_PIPE &&
- a->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 (a->police.notexceed.act_id == FLOW_ACTION_ACCEPT &&
- !flow_action_is_last_entry(&f->rule->action, a)) {
- 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 (a->police.peakrate_bytes_ps ||
- a->police.avrate || a->police.overhead) {
- NL_SET_ERR_MSG_MOD(extack,
- "Police offload is not supported when peakrate/avrate/overhead is configured");
- return -EOPNOTSUPP;
- }
+ err = ocelot_policer_validate(action, a, extack);
+ if (err)
+ return err;
- if (a->police.rate_pkt_ps) {
- NL_SET_ERR_MSG_MOD(extack,
- "QoS offload not support packets per second");
- return -EOPNOTSUPP;
- }
filter->action.police_ena = true;
pol_ix = a->hw_index + ocelot->vcap_pol.base;
diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
index 4e38d41dba29..5767e38c0c5a 100644
--- a/drivers/net/ethernet/mscc/ocelot_net.c
+++ b/drivers/net/ethernet/mscc/ocelot_net.c
@@ -14,6 +14,7 @@
#include <linux/phy/phy.h>
#include <net/pkt_cls.h>
#include "ocelot.h"
+#include "ocelot_police.h"
#include "ocelot_vcap.h"
#include "ocelot_fdma.h"
@@ -258,38 +259,10 @@ static int ocelot_setup_tc_cls_matchall(struct ocelot_port_private *priv,
return -EEXIST;
}
- if (action->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 (action->police.notexceed.act_id != FLOW_ACTION_PIPE &&
- action->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 (action->police.notexceed.act_id == FLOW_ACTION_ACCEPT &&
- !flow_action_is_last_entry(&f->rule->action, action)) {
- 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 (action->police.peakrate_bytes_ps ||
- action->police.avrate || action->police.overhead) {
- NL_SET_ERR_MSG_MOD(extack,
- "Police offload is not supported when peakrate/avrate/overhead is configured");
- return -EOPNOTSUPP;
- }
-
- if (action->police.rate_pkt_ps) {
- NL_SET_ERR_MSG_MOD(extack,
- "QoS offload not support packets per second");
- return -EOPNOTSUPP;
- }
+ err = ocelot_policer_validate(&f->rule->action, action,
+ extack);
+ if (err)
+ return err;
pol.rate = (u32)div_u64(action->police.rate_bytes_ps, 1000) * 8;
pol.burst = action->police.burst;
diff --git a/drivers/net/ethernet/mscc/ocelot_police.c b/drivers/net/ethernet/mscc/ocelot_police.c
index 6f5068c1041a..a65606bb84a0 100644
--- a/drivers/net/ethernet/mscc/ocelot_police.c
+++ b/drivers/net/ethernet/mscc/ocelot_police.c
@@ -154,6 +154,47 @@ int qos_policer_conf_set(struct ocelot *ocelot, int port, u32 pol_ix,
return 0;
}
+int ocelot_policer_validate(const struct flow_action *action,
+ const struct flow_action_entry *a,
+ struct netlink_ext_ack *extack)
+{
+ if (a->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 (a->police.notexceed.act_id != FLOW_ACTION_PIPE &&
+ a->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 (a->police.notexceed.act_id == FLOW_ACTION_ACCEPT &&
+ !flow_action_is_last_entry(action, a)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Offload not supported when conform action is ok, but police action is not last");
+ return -EOPNOTSUPP;
+ }
+
+ if (a->police.peakrate_bytes_ps ||
+ a->police.avrate || a->police.overhead) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Offload not supported when peakrate/avrate/overhead is configured");
+ return -EOPNOTSUPP;
+ }
+
+ if (a->police.rate_pkt_ps) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Offload does not support packets per second");
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(ocelot_policer_validate);
+
int ocelot_port_policer_add(struct ocelot *ocelot, int port,
struct ocelot_policer *pol)
{
diff --git a/drivers/net/ethernet/mscc/ocelot_police.h b/drivers/net/ethernet/mscc/ocelot_police.h
index 7adb05f71999..7552995f8b17 100644
--- a/drivers/net/ethernet/mscc/ocelot_police.h
+++ b/drivers/net/ethernet/mscc/ocelot_police.h
@@ -8,6 +8,7 @@
#define _MSCC_OCELOT_POLICE_H_
#include "ocelot.h"
+#include <net/flow_offload.h>
enum mscc_qos_rate_mode {
MSCC_QOS_RATE_MODE_DISABLED, /* Policer/shaper disabled */
@@ -33,4 +34,8 @@ struct qos_policer_conf {
int qos_policer_conf_set(struct ocelot *ocelot, int port, u32 pol_ix,
struct qos_policer_conf *conf);
+int ocelot_policer_validate(const struct flow_action *action,
+ const struct flow_action_entry *a,
+ struct netlink_ext_ack *extack);
+
#endif /* _MSCC_OCELOT_POLICE_H_ */
--
2.25.1
next prev parent reply other threads:[~2022-02-22 10:10 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
2022-02-17 13:57 ` Ido Schimmel
2022-02-22 1:58 ` Jianbo Liu
2022-02-22 10:09 ` Vladimir Oltean [this message]
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=20220222100929.gj2my4maclyrwz35@skbuf \
--to=vladimir.oltean@nxp.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=olteanv@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).