netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <mleitner@redhat.com>
To: Oz Shlomo <ozsh@nvidia.com>
Cc: Pedro Tammela <pctammela@mojatatu.com>,
	netdev@vger.kernel.org, Saeed Mahameed <saeedm@nvidia.com>,
	Roi Dayan <roid@nvidia.com>, Jiri Pirko <jiri@nvidia.com>,
	Simon Horman <simon.horman@corigine.com>,
	Baowen Zheng <baowen.zheng@corigine.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Edward Cree <ecree.xilinx@gmail.com>
Subject: Re: [PATCH net-next 2/9] net/sched: act_pedit, setup offload action for action stats query
Date: Fri, 3 Feb 2023 07:31:36 -0800	[thread overview]
Message-ID: <CALnP8ZZtqkumhUrRtCAqQDHQfEydG0YaszZrafjuXL2CV_oDCw@mail.gmail.com> (raw)
In-Reply-To: <cfbbbbbe-0a23-749f-f611-6d2438f797e4@nvidia.com>

On Thu, Feb 02, 2023 at 09:21:15AM +0200, Oz Shlomo wrote:
>
> On 01/02/2023 22:59, Pedro Tammela wrote:
> > On 01/02/2023 13:10, Oz Shlomo wrote:
> > > A single tc pedit action may be translated to multiple flow_offload
> > > actions.
> > > Offload only actions that translate to a single pedit command value.
> > >
> > > Signed-off-by: Oz Shlomo <ozsh@nvidia.com>
> > > ---
> > >   net/sched/act_pedit.c | 24 +++++++++++++++++++++++-
> > >   1 file changed, 23 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> > > index a0378e9f0121..abceef794f28 100644
> > > --- a/net/sched/act_pedit.c
> > > +++ b/net/sched/act_pedit.c
> > > @@ -522,7 +522,29 @@ static int tcf_pedit_offload_act_setup(struct
> > > tc_action *act, void *entry_data,
> > >           }
> > >           *index_inc = k;
> > >       } else {
> > > -        return -EOPNOTSUPP;
> > > +        struct flow_offload_action *fl_action = entry_data;
> > > +        u32 last_cmd;
> > > +        int k;
> > > +
> > > +        for (k = 0; k < tcf_pedit_nkeys(act); k++) {
> > > +            u32 cmd = tcf_pedit_cmd(act, k);
> > > +
> > > +            if (k && cmd != last_cmd)
> > > +                return -EOPNOTSUPP;
> >
> > I believe an extack message here is very valuable
> Sure thing, I will add one
> >
> > > +
> > > +            last_cmd = cmd;
> > > +            switch (cmd) {
> > > +            case TCA_PEDIT_KEY_EX_CMD_SET:
> > > +                fl_action->id = FLOW_ACTION_MANGLE;
> > > +                break;
> > > +            case TCA_PEDIT_KEY_EX_CMD_ADD:
> > > +                fl_action->id = FLOW_ACTION_ADD;
> > > +                break;
> > > +            default:
> > > +                NL_SET_ERR_MSG_MOD(extack, "Unsupported pedit
> > > command offload");
> > > +                return -EOPNOTSUPP;
> > > +            }
> > > +        }
> >
> > Shouldn't this switch case be outside of the for-loop?
>
> You are right, this can be done outside the for loop.

To before the for-loop, that is?
Because otherwise it will parse all commands and then fail, which seems heavier
than how it is here.

- validate the first one
- ensure the rest follows

>
> I will refactor the code
>
> >
> > >       }
> > >         return 0;
> >
>

  reply	other threads:[~2023-02-03 15:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 16:10 [PATCH net-next 0/9] net: flow_offload: add support for per action hw stats Oz Shlomo
2023-02-01 16:10 ` [PATCH net-next 1/9] net/sched: optimize action stats api calls Oz Shlomo
2023-02-03 14:34   ` Simon Horman
2023-02-01 16:10 ` [PATCH net-next 2/9] net/sched: act_pedit, setup offload action for action stats query Oz Shlomo
2023-02-01 20:59   ` Pedro Tammela
2023-02-02  7:21     ` Oz Shlomo
2023-02-03 15:31       ` Marcelo Ricardo Leitner [this message]
2023-02-05 13:00         ` Oz Shlomo
2023-02-01 16:10 ` [PATCH net-next 3/9] net/sched: pass flow_stats instead of multiple stats args Oz Shlomo
2023-02-03 14:34   ` Simon Horman
2023-02-01 16:10 ` [PATCH net-next 4/9] net/sched: introduce flow_offload action cookie Oz Shlomo
2023-02-03 14:38   ` Simon Horman
2023-02-01 16:10 ` [PATCH net-next 5/9] net/sched: support per action hw stats Oz Shlomo
2023-02-03 14:33   ` Simon Horman
2023-02-05 13:01     ` Oz Shlomo
2023-02-03 14:51   ` Simon Horman
2023-02-05 13:02     ` Oz Shlomo
2023-02-01 16:10 ` [PATCH net-next 6/9] net/mlx5e: TC, add hw counter to branching actions Oz Shlomo
2023-02-01 16:10 ` [PATCH net-next 7/9] net/mlx5e: TC, store tc action cookies per attr Oz Shlomo
2023-02-03 16:11   ` Marcelo Ricardo Leitner
2023-02-05 13:13     ` Oz Shlomo
2023-02-01 16:10 ` [PATCH net-next 8/9] net/sched: TC, map tc action cookie to a hw counter Oz Shlomo
2023-02-01 16:10 ` [PATCH net-next 9/9] net/sched: TC, support per action stats Oz Shlomo

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=CALnP8ZZtqkumhUrRtCAqQDHQfEydG0YaszZrafjuXL2CV_oDCw@mail.gmail.com \
    --to=mleitner@redhat.com \
    --cc=baowen.zheng@corigine.com \
    --cc=ecree.xilinx@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=ozsh@nvidia.com \
    --cc=pctammela@mojatatu.com \
    --cc=roid@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=simon.horman@corigine.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).