Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Roi Dayan <roid@nvidia.com>
Cc: David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@mellanox.com>,
	netdev@vger.kernel.org, oss-drivers@corigine.com,
	Baowen Zheng <baowen.zheng@corigine.com>,
	Louis Peens <louis.peens@corigine.com>
Subject: Re: [PATCH net-next 1/3] flow_offload: allow user to offload tc action to net device
Date: Thu, 22 Jul 2021 15:19:11 +0200	[thread overview]
Message-ID: <20210722131909.GB31574@corigine.com> (raw)
In-Reply-To: <2b7f3729-2f87-881b-6b1f-d21ed2df3b20@nvidia.com>

On Thu, Jul 22, 2021 at 03:24:07PM +0300, Roi Dayan wrote:
> 
> 
> On 2021-07-22 12:19 PM, Simon Horman wrote:
> > From: Baowen Zheng <baowen.zheng@corigine.com>
> > 
> > Use flow_indr_dev_register/flow_indr_dev_setup_offload to
> > offload tc action.
> > 
> > We offload the tc action mainly for ovs meter configuration.
> > Make some basic changes for different vendors to return EOPNOTSUPP.
> > 
> > We need to call tc_cleanup_flow_action to clean up tc action entry since
> > in tc_setup_action, some actions may hold dev refcnt, especially the mirror
> > action.
> > 
> > As per review from the RFC, the kernel test robot will fail to run, so
> > we add CONFIG_NET_CLS_ACT control for the action offload.
> > 
> > Signed-off-by: Baowen Zheng <baowen.zheng@corigine.com>
> > Signed-off-by: Louis Peens <louis.peens@corigine.com>
> > Signed-off-by: Simon Horman <simon.horman@corigine.com>
> > ---
> >   drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |  2 +-
> >   .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |  3 ++
> >   .../ethernet/netronome/nfp/flower/offload.c   |  3 ++
> >   include/linux/netdevice.h                     |  1 +
> >   include/net/flow_offload.h                    | 15 ++++++++
> >   include/net/pkt_cls.h                         | 15 ++++++++
> >   net/core/flow_offload.c                       | 26 +++++++++++++-
> >   net/sched/act_api.c                           | 33 +++++++++++++++++
> >   net/sched/cls_api.c                           | 36 ++++++++++++++++---
> >   9 files changed, 128 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
> > index 5e4429b14b8c..edbbf7b4df77 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
> > @@ -1951,7 +1951,7 @@ static int bnxt_tc_setup_indr_cb(struct net_device *netdev, struct Qdisc *sch, v
> >   				 void *data,
> >   				 void (*cleanup)(struct flow_block_cb *block_cb))
> >   {
> > -	if (!bnxt_is_netdev_indr_offload(netdev))
> > +	if (!netdev || !bnxt_is_netdev_indr_offload(netdev))
> >   		return -EOPNOTSUPP;
> >   	switch (type) {
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> > index 059799e4f483..111daacc4cc3 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
> > @@ -486,6 +486,9 @@ int mlx5e_rep_indr_setup_cb(struct net_device *netdev, struct Qdisc *sch, void *
> >   			    void *data,
> >   			    void (*cleanup)(struct flow_block_cb *block_cb))
> >   {
> > +	if (!netdev)
> > +		return -EOPNOTSUPP;
> > +
> >   	switch (type) {
> >   	case TC_SETUP_BLOCK:
> >   		return mlx5e_rep_indr_setup_block(netdev, sch, cb_priv, type_data,
> > diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c
> > index 2406d33356ad..88bbc86347b4 100644
> > --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c
> > +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c
> > @@ -1869,6 +1869,9 @@ nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void *
> >   			    void *data,
> >   			    void (*cleanup)(struct flow_block_cb *block_cb))
> >   {
> > +	if (!netdev)
> > +		return -EOPNOTSUPP;
> > +
> >   	if (!nfp_fl_is_netdev_to_offload(netdev))
> >   		return -EOPNOTSUPP;
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index 42f6f866d5f3..b138219baf6f 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -923,6 +923,7 @@ enum tc_setup_type {
> >   	TC_SETUP_QDISC_TBF,
> >   	TC_SETUP_QDISC_FIFO,
> >   	TC_SETUP_QDISC_HTB,
> > +	TC_SETUP_ACT,
> >   };
> >   /* These structures hold the attributes of bpf state that are being passed
> > diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
> > index 69c9eabf8325..26644596fd54 100644
> > --- a/include/net/flow_offload.h
> > +++ b/include/net/flow_offload.h
> > @@ -553,6 +553,21 @@ struct flow_cls_offload {
> >   	u32 classid;
> >   };
> > +enum flow_act_command {
> > +	FLOW_ACT_REPLACE,
> > +	FLOW_ACT_DESTROY,
> > +	FLOW_ACT_STATS,
> > +};
> > +
> > +struct flow_offload_action {
> > +	struct netlink_ext_ack *extack;
> > +	enum flow_act_command command;
> > +	struct flow_stats stats;
> > +	struct flow_action action;
> > +};
> > +
> > +struct flow_offload_action *flow_action_alloc(unsigned int num_actions);
> > +
> >   static inline struct flow_rule *
> >   flow_cls_offload_flow_rule(struct flow_cls_offload *flow_cmd)
> >   {
> > diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
> > index ec7823921bd2..cd4cf6b10f5d 100644
> > --- a/include/net/pkt_cls.h
> > +++ b/include/net/pkt_cls.h
> > @@ -266,6 +266,9 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts)
> >   	for (; 0; (void)(i), (void)(a), (void)(exts))
> >   #endif
> > +#define tcf_act_for_each_action(i, a, actions) \
> > +	for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++)
> > +
> >   static inline void
> >   tcf_exts_stats_update(const struct tcf_exts *exts,
> >   		      u64 bytes, u64 packets, u64 drops, u64 lastuse,
> > @@ -536,8 +539,19 @@ tcf_match_indev(struct sk_buff *skb, int ifindex)
> >   	return ifindex == skb->skb_iif;
> >   }
> > +#ifdef CONFIG_NET_CLS_ACT
> >   int tc_setup_flow_action(struct flow_action *flow_action,
> >   			 const struct tcf_exts *exts);
> > +#else
> > +static inline int tc_setup_flow_action(struct flow_action *flow_action,
> > +				       const struct tcf_exts *exts)
> > +{
> > +		return 0;
> > +}
> > +#endif
> > +
> > +int tc_setup_action(struct flow_action *flow_action,
> > +		    struct tc_action *actions[]);
> >   void tc_cleanup_flow_action(struct flow_action *flow_action);
> >   int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
> > @@ -558,6 +572,7 @@ int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp,
> >   			  enum tc_setup_type type, void *type_data,
> >   			  void *cb_priv, u32 *flags, unsigned int *in_hw_count);
> >   unsigned int tcf_exts_num_actions(struct tcf_exts *exts);
> > +unsigned int tcf_act_num_actions(struct tc_action *actions[]);
> >   #ifdef CONFIG_NET_CLS_ACT
> >   int tcf_qevent_init(struct tcf_qevent *qe, struct Qdisc *sch,
> > diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
> > index 715b67f6c62f..0fa2f75cc9b3 100644
> > --- a/net/core/flow_offload.c
> > +++ b/net/core/flow_offload.c
> > @@ -27,6 +27,27 @@ struct flow_rule *flow_rule_alloc(unsigned int num_actions)
> >   }
> >   EXPORT_SYMBOL(flow_rule_alloc);
> > +struct flow_offload_action *flow_action_alloc(unsigned int num_actions)
> > +{
> > +	struct flow_offload_action *fl_action;
> > +	int i;
> > +
> > +	fl_action = kzalloc(struct_size(fl_action, action.entries, num_actions),
> > +			    GFP_KERNEL);
> > +	if (!fl_action)
> > +		return NULL;
> 
> Hi Simon,
> 
> Our automatic tests got a trace from flow_action_alloc()
> introduced in this series.
> I don't have specific commands right now but maybe its easy
> to reproduce with option CONFIG_DEBUG_ATOMIC_SLEEP=y
> 
> fl_dump->fl_hw_update_stats->fl_hw_update_stats->tcf_exts_stats_update
>   ->tcf_action_update_hw_stats->tcf_action_offload_cmd_pre->
>     ->flow_action_alloc
> 
> Thanks,
> Roi

Thanks Roi,

we'll look into this.

  reply	other threads:[~2021-07-22 13:19 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22  9:19 [PATCH net-next 0/3] flow_offload: hardware offload of TC actions Simon Horman
2021-07-22  9:19 ` [PATCH net-next 1/3] flow_offload: allow user to offload tc action to net device Simon Horman
2021-07-22 12:24   ` Roi Dayan
2021-07-22 13:19     ` Simon Horman [this message]
2021-07-22 13:29   ` Vlad Buslov
2021-07-22 13:33     ` Jamal Hadi Salim
2021-07-27 13:04       ` Simon Horman
2021-07-27 14:38         ` Vlad Buslov
2021-07-27 16:13           ` Jamal Hadi Salim
2021-07-27 16:47             ` Vlad Buslov
2021-07-28  7:46               ` Simon Horman
2021-07-28  8:05                 ` Vlad Buslov
2021-07-28 13:51                 ` Jamal Hadi Salim
2021-07-28 14:46                   ` Simon Horman
2021-07-30 10:17                     ` Jamal Hadi Salim
2021-07-30 11:40                       ` Vlad Buslov
2021-08-03  9:57                         ` Jamal Hadi Salim
2021-08-03 12:02                           ` tc offload debug-ability Jamal Hadi Salim
2021-08-03 12:14                             ` Vlad Buslov
2021-08-03 12:50                               ` Jamal Hadi Salim
2021-08-03 13:34                                 ` Ido Schimmel
2021-07-30 13:20                       ` [PATCH net-next 1/3] flow_offload: allow user to offload tc action to net device Simon Horman
2021-08-03 10:14                         ` Jamal Hadi Salim
2021-08-03 11:36                           ` Simon Horman
2021-08-03 11:45                             ` Jamal Hadi Salim
2021-08-03 12:31                               ` Simon Horman
2021-08-03 13:01                                 ` Jamal Hadi Salim
2021-08-03 14:46                                   ` Simon Horman
2021-07-22 13:57   ` kernel test robot
2021-07-22 15:31   ` kernel test robot
2021-08-03 10:50   ` Jamal Hadi Salim
2021-08-03 11:05   ` Jamal Hadi Salim
2021-08-03 11:31     ` Simon Horman
2021-07-22  9:19 ` [PATCH net-next 2/3] flow_offload: add process to delete offloaded actions from " Simon Horman
2021-07-22 14:25   ` Vlad Buslov
2021-07-22 14:50   ` kernel test robot
2021-07-22 17:07   ` kernel test robot
2021-08-03 10:59   ` Jamal Hadi Salim
2021-07-22  9:19 ` [PATCH net-next 3/3] flow_offload: add process to update action stats from hardware Simon Horman
2021-07-22 14:55   ` Vlad Buslov
2021-08-03 11:24   ` Jamal Hadi Salim
2021-08-03 11:35     ` Simon Horman

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=20210722131909.GB31574@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=baowen.zheng@corigine.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@mellanox.com \
    --cc=kuba@kernel.org \
    --cc=louis.peens@corigine.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@corigine.com \
    --cc=roid@nvidia.com \
    --cc=xiyou.wangcong@gmail.com \
    --subject='Re: [PATCH net-next 1/3] flow_offload: allow user to offload tc action to net device' \
    /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

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).