linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
	"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
	"vivien.didelot@gmail.com" <vivien.didelot@gmail.com>,
	"andrew@lunn.ch" <andrew@lunn.ch>
Subject: Re: [PATCH net-next v7 8/9] net: lan966x: Extend switchdev bridge flags
Date: Sat, 18 Dec 2021 13:55:43 +0100	[thread overview]
Message-ID: <20211218125543.anb7fapwpywwsryx@soft-dev3-1.localhost> (raw)
In-Reply-To: <20211217174000.febeewxdio6dbmb6@skbuf>

The 12/17/2021 17:40, Vladimir Oltean wrote:
> 
> On Fri, Dec 17, 2021 at 04:53:52PM +0100, Horatiu Vultur wrote:
> > Currently allow a port to be part or not of the multicast flooding mask.
> > By implementing the switchdev calls SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS
> > and SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS.
> >
> > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> > ---
> >  .../microchip/lan966x/lan966x_switchdev.c     | 34 +++++++++++++++++++
> >  1 file changed, 34 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c b/drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c
> > index cef9e690fb82..af227b33cb3f 100644
> > --- a/drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c
> > +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c
> > @@ -9,6 +9,34 @@ static struct notifier_block lan966x_netdevice_nb __read_mostly;
> >  static struct notifier_block lan966x_switchdev_nb __read_mostly;
> >  static struct notifier_block lan966x_switchdev_blocking_nb __read_mostly;
> >
> > +static void lan966x_port_bridge_flags(struct lan966x_port *port,
> > +                                   struct switchdev_brport_flags flags)
> > +{
> > +     u32 val = lan_rd(port->lan966x, ANA_PGID(PGID_MC));
> > +
> > +     val = ANA_PGID_PGID_GET(val);
> 
> Ideally you'd want to read PGID_MC only if you know that BR_MCAST_FLOOD
> is the flag getting changed. Otherwise you'd have to refactor this when
> you add support for more brport flags.

I can see your point. I will refactor this now, such that when new flags
are added this should not be changed.

> 
> > +
> > +     if (flags.mask & BR_MCAST_FLOOD) {
> > +             if (flags.val & BR_MCAST_FLOOD)
> > +                     val |= BIT(port->chip_port);
> > +             else
> > +                     val &= ~BIT(port->chip_port);
> > +     }
> > +
> > +     lan_rmw(ANA_PGID_PGID_SET(val),
> > +             ANA_PGID_PGID,
> > +             port->lan966x, ANA_PGID(PGID_MC));
> > +}
> > +
> > +static int lan966x_port_pre_bridge_flags(struct lan966x_port *port,
> > +                                      struct switchdev_brport_flags flags)
> > +{
> > +     if (flags.mask & ~BR_MCAST_FLOOD)
> > +             return -EINVAL;
> > +
> > +     return 0;
> > +}
> > +
> >  static void lan966x_update_fwd_mask(struct lan966x *lan966x)
> >  {
> >       int i;
> > @@ -67,6 +95,12 @@ static int lan966x_port_attr_set(struct net_device *dev, const void *ctx,
> >               return 0;
> >
> >       switch (attr->id) {
> > +     case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
> > +             lan966x_port_bridge_flags(port, attr->u.brport_flags);
> > +             break;
> > +     case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS:
> > +             err = lan966x_port_pre_bridge_flags(port, attr->u.brport_flags);
> > +             break;
> >       case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
> >               lan966x_port_stp_state_set(port, attr->u.stp_state);
> >               break;
> > --
> > 2.33.0
> >

-- 
/Horatiu

  reply	other threads:[~2021-12-18 12:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 15:53 [PATCH net-next v7 0/9] net: lan966x: Add switchdev and vlan support Horatiu Vultur
2021-12-17 15:53 ` [PATCH net-next v7 1/9] net: lan966x: Add registers that are used for switch and vlan functionality Horatiu Vultur
2021-12-17 15:53 ` [PATCH net-next v7 2/9] dt-bindings: net: lan966x: Extend with the analyzer interrupt Horatiu Vultur
2021-12-17 15:53 ` [PATCH net-next v7 3/9] net: lan966x: add support for interrupts from analyzer Horatiu Vultur
2021-12-17 15:53 ` [PATCH net-next v7 4/9] net: lan966x: More MAC table functionality Horatiu Vultur
2021-12-17 15:53 ` [PATCH net-next v7 5/9] net: lan966x: Remove .ndo_change_rx_flags Horatiu Vultur
2021-12-17 15:53 ` [PATCH net-next v7 6/9] net: lan966x: Add support to offload the forwarding Horatiu Vultur
2021-12-17 17:44   ` Vladimir Oltean
2021-12-18 12:56     ` Horatiu Vultur
2021-12-17 15:53 ` [PATCH net-next v7 7/9] net: lan966x: Add vlan support Horatiu Vultur
2021-12-17 18:14   ` Vladimir Oltean
2021-12-18 13:00     ` Horatiu Vultur
2021-12-17 15:53 ` [PATCH net-next v7 8/9] net: lan966x: Extend switchdev bridge flags Horatiu Vultur
2021-12-17 17:40   ` Vladimir Oltean
2021-12-18 12:55     ` Horatiu Vultur [this message]
2021-12-17 15:53 ` [PATCH net-next v7 9/9] net: lan966x: Extend switchdev with fdb support Horatiu Vultur
2021-12-17 18:12   ` Vladimir Oltean
2021-12-18 13:00     ` Horatiu Vultur

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=20211218125543.anb7fapwpywwsryx@soft-dev3-1.localhost \
    --to=horatiu.vultur@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@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;
as well as URLs for NNTP newsgroup(s).