Re: [PATCH net-next v2 3/3] net: lan966x: Extend switchdev with mdb support

From: Horatiu Vultur
Date: Tue Jan 04 2022 - 08:34:47 EST


The 01/04/2022 11:12, Vladimir Oltean wrote:
>
> On Tue, Jan 04, 2022 at 11:18:49AM +0100, Horatiu Vultur wrote:
> > +static int lan966x_mdb_ip_del(struct lan966x_port *port,
> > + const struct switchdev_obj_port_mdb *mdb,
> > + enum macaccess_entry_type type)
> > +{
> > + bool cpu_port = netif_is_bridge_master(mdb->obj.orig_dev);
> > + struct lan966x *lan966x = port->lan966x;
> > + struct lan966x_mdb_entry *mdb_entry;
> > + unsigned char mac[ETH_ALEN];
> > +
> > + mdb_entry = lan966x_mdb_entry_get(lan966x, mdb->addr, mdb->vid);
> > + if (!mdb_entry)
> > + return -ENOENT;
> > +
> > + lan966x_mdb_encode_mac(mac, mdb_entry, type);
> > + lan966x_mac_forget(lan966x, mac, mdb_entry->vid, type);
> > +
> > + if (cpu_port)
> > + mdb_entry->cpu_copy--;
>
> Can you code this in such a way that you don't forget and then re-learn
> the entry if you only do a cpu_copy-- which doesn't reach zero?

I think it is possible to do this. I will do that.

>
> > + else
> > + mdb_entry->ports &= ~BIT(port->chip_port);
> > +
> > + if (!mdb_entry->ports && !mdb_entry->cpu_copy) {
> > + list_del(&mdb_entry->list);
> > + kfree(mdb_entry);
> > + return 0;
> > + }
> > +
> > + lan966x_mdb_encode_mac(mac, mdb_entry, type);
> > + return lan966x_mac_ip_learn(lan966x, mdb_entry->cpu_copy,
> > + mac, mdb_entry->vid, type);
> > +}

--
/Horatiu