netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jianbo Liu <jianbol@nvidia.com>
To: "olteanv@gmail.com" <olteanv@gmail.com>
Cc: "andrew@lunn.ch" <andrew@lunn.ch>,
	"claudiu.manoil@nxp.com" <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>,
	"vladimir.oltean@nxp.com" <vladimir.oltean@nxp.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 01:58:23 +0000	[thread overview]
Message-ID: <6291dabcca7dd2d95b4961f660ec8b0226b8fbce.camel@nvidia.com> (raw)
In-Reply-To: <20220217124935.p7pbgv2cfmhpshxv@skbuf>

On Thu, 2022-02-17 at 14:49 +0200, Vladimir Oltean wrote:
> 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.

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

  parent reply	other threads:[~2022-02-22  1:58 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 [this message]
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=6291dabcca7dd2d95b4961f660ec8b0226b8fbce.camel@nvidia.com \
    --to=jianbol@nvidia.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=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=vladimir.oltean@nxp.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).