Netdev List
 help / color / mirror / Atom feed
From: Vivien Didelot <vivien.didelot@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: netdev <netdev@vger.kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	Po Liu <po.liu@nxp.com>, Xiaoliang Yang <xiaoliang.yang@nxp.com>,
	Mingkai Hu <mingkai.hu@nxp.com>,
	Christian Herber <christian.herber@nxp.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Alexandru Marginean <alexandru.marginean@nxp.com>,
	vlad@buslov.dev, Jiri Pirko <jiri@mellanox.com>,
	Ido Schimmel <idosch@mellanox.com>,
	Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next 4/6] net: dsa: sja1105: support flow-based redirection via virtual links
Date: Mon, 4 May 2020 15:24:28 -0400	[thread overview]
Message-ID: <20200504152428.GB950689@t480s.localdomain> (raw)
In-Reply-To: <CA+h21howxs23VkvTVk3BiepQz7Z1vXgRiE1w+F1eeHYqYZmLpA@mail.gmail.com>

Hi Vladimir,

On Mon, 4 May 2020 21:38:26 +0300, Vladimir Oltean <olteanv@gmail.com> wrote:
> Hi Vivien,
> 
> On Mon, 4 May 2020 at 21:23, Vivien Didelot <vivien.didelot@gmail.com> wrote:
> >
> > On Mon, 4 May 2020 14:19:13 -0400, Vivien Didelot <vivien.didelot@gmail.com> wrote:
> > > Hi Vladimir,
> > >
> > > On Mon,  4 May 2020 00:10:33 +0300, Vladimir Oltean <olteanv@gmail.com> wrote:
> > > > +           case FLOW_ACTION_REDIRECT: {
> > > > +                   struct dsa_port *to_dp;
> > > > +
> > > > +                   if (!dsa_slave_dev_check(act->dev)) {
> > > > +                           NL_SET_ERR_MSG_MOD(extack,
> > > > +                                              "Destination not a switch port");
> > > > +                           return -EOPNOTSUPP;
> > > > +                   }
> > > > +
> > > > +                   to_dp = dsa_slave_to_port(act->dev);
> > >
> > > Instead of exporting two DSA core internal functions, I would rather expose
> > > a new helper for drivers, such as this one:
> > >
> > >     struct dsa_port *dsa_dev_to_port(struct net_device *dev)
> > >     {
> > >         if (!dsa_slave_dev_check(dev))
> > >             return -EOPNOTSUPP;
> >
> > Oops, NULL, not an integer error code, but you get the idea of public helpers.
> >
> > >
> > >         return dsa_slave_to_port(dev);
> > >     }
> > >
> > > The naming might not be the best, this helper could even be mirroring-specific,
> > > I didn't really check the requirements for this functionality yet.
> > >
> > >
> > > Thank you,
> > >
> > >       Vivien
> 
> How about
> 
> int dsa_slave_get_port_index(struct net_device *dev)
> {
>     if (!dsa_slave_dev_check(dev))
>         return -EINVAL;
> 
>     return dsa_slave_to_port(dev)->index;
> }
> EXPORT_SYMBOL_GPL(dsa_slave_get_port_index);
> 
> also, where to put it? slave.c I suppose?

dsa.c is the place for private implementation of public functions. "slave"
is a core term, no need to expose it. Public helpers exposed in dsa.h usually
scope the dsa_switch structure and an optional port index. mv88e6xxx allows
mirroring an external device port, so dsa_port would be preferred, but this
can wait. So I'm thinking about implementing the following:

net/dsa/dsa.c:

int dsa_to_port_index(struct dsa_switch *ds, struct net_device *dev)
{
    struct dsa_port *dp;

    if (!dsa_slave_dev_check(dev))
        return -ENODEV;

    dp = dsa_slave_to_port(dev);

    if (dp->ds != ds)
        return -EINVAL;

    return dp->index;
}

include/net/dsa.h:

int dsa_to_port_index(struct dsa_switch *ds, struct net_device *dev);


What do you think?

	Vivien

  reply	other threads:[~2020-05-04 19:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 21:10 [PATCH net-next 0/6] tc-gate offload for SJA1105 DSA switch Vladimir Oltean
2020-05-03 21:10 ` [PATCH net-next 1/6] net: dsa: export dsa_slave_dev_check and dsa_slave_to_port Vladimir Oltean
2020-05-03 22:45   ` Florian Fainelli
2020-05-03 22:47     ` Vladimir Oltean
2020-05-03 22:56       ` Florian Fainelli
2020-05-03 21:10 ` [PATCH net-next 2/6] net: dsa: sja1105: add static tables for virtual links Vladimir Oltean
2020-05-03 21:10 ` [PATCH net-next 3/6] net: dsa: sja1105: make room for virtual link parsing in flower offload Vladimir Oltean
2020-05-03 21:10 ` [PATCH net-next 4/6] net: dsa: sja1105: support flow-based redirection via virtual links Vladimir Oltean
2020-05-04 18:19   ` Vivien Didelot
2020-05-04 18:23     ` Vivien Didelot
2020-05-04 18:38       ` Vladimir Oltean
2020-05-04 19:24         ` Vivien Didelot [this message]
2020-05-04 19:40           ` Vladimir Oltean
2020-05-03 21:10 ` [PATCH net-next 5/6] net: dsa: sja1105: implement tc-gate using time-triggered " Vladimir Oltean
2020-05-05 14:25   ` kbuild test robot
2020-05-05 14:35     ` Vladimir Oltean
2020-05-03 21:10 ` [PATCH net-next 6/6] docs: net: dsa: sja1105: document intended usage of " Vladimir Oltean

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=20200504152428.GB950689@t480s.localdomain \
    --to=vivien.didelot@gmail.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=christian.herber@nxp.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=kuba@kernel.org \
    --cc=mingkai.hu@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=po.liu@nxp.com \
    --cc=vinicius.gomes@intel.com \
    --cc=vlad@buslov.dev \
    --cc=vladimir.oltean@nxp.com \
    --cc=xiaoliang.yang@nxp.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