netdev at kapio-technology.com
2023-Feb-02 17:00 UTC
[Bridge] [PATCH net-next 5/5] net: dsa: mv88e6xxx: implementation of dynamic ATU entries
On 2023-01-31 19:56, Simon Horman wrote:>> --- a/drivers/net/dsa/mv88e6xxx/chip.c >> +++ b/drivers/net/dsa/mv88e6xxx/chip.c >> @@ -42,6 +42,7 @@ >> #include "ptp.h" >> #include "serdes.h" >> #include "smi.h" >> +#include "switchdev.h" >> >> static void assert_reg_lock(struct mv88e6xxx_chip *chip) >> { >> @@ -2726,18 +2727,25 @@ static int mv88e6xxx_port_fdb_add(struct >> dsa_switch *ds, int port, >> const unsigned char *addr, u16 vid, >> u16 fdb_flags, struct dsa_db db) >> { >> + bool is_dynamic = !!(fdb_flags & DSA_FDB_FLAG_DYNAMIC); >> struct mv88e6xxx_chip *chip = ds->priv; >> + u8 state; >> int err; >> >> - /* Ignore entries with flags set */ >> - if (fdb_flags) >> - return 0; >> + state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC; >> + if (is_dynamic) >> + state = MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_7_NEWEST; > > What if flags other than DSA_FDB_FLAG_DYNAMIC are set (in future)?They will have to be caught and handled here if there is support for it, e.g. something like... else if (someflag) dosomething(); For now only one flag will actually be set and they are mutually exclusive, as they will not make sense together with the potential flags I know, but that can change at some time of course.> >> + else >> + if (fdb_flags) > > nit: else if (fdb_flags) > >> + return 0; >> > > ...
Simon Horman
2023-Feb-03 08:20 UTC
[Bridge] [PATCH net-next 5/5] net: dsa: mv88e6xxx: implementation of dynamic ATU entries
On Thu, Feb 02, 2023 at 06:00:00PM +0100, netdev at kapio-technology.com wrote:> On 2023-01-31 19:56, Simon Horman wrote: > > > --- a/drivers/net/dsa/mv88e6xxx/chip.c > > > +++ b/drivers/net/dsa/mv88e6xxx/chip.c > > > @@ -42,6 +42,7 @@ > > > #include "ptp.h" > > > #include "serdes.h" > > > #include "smi.h" > > > +#include "switchdev.h" > > > > > > static void assert_reg_lock(struct mv88e6xxx_chip *chip) > > > { > > > @@ -2726,18 +2727,25 @@ static int mv88e6xxx_port_fdb_add(struct > > > dsa_switch *ds, int port, > > > const unsigned char *addr, u16 vid, > > > u16 fdb_flags, struct dsa_db db) > > > { > > > + bool is_dynamic = !!(fdb_flags & DSA_FDB_FLAG_DYNAMIC); > > > struct mv88e6xxx_chip *chip = ds->priv; > > > + u8 state; > > > int err; > > > > > > - /* Ignore entries with flags set */ > > > - if (fdb_flags) > > > - return 0; > > > + state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC; > > > + if (is_dynamic) > > > + state = MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_7_NEWEST; > > > > What if flags other than DSA_FDB_FLAG_DYNAMIC are set (in future)? > > They will have to be caught and handled here if there is support for it, > e.g. something like... > > else if (someflag) > dosomething(); > > For now only one flag will actually be set and they are mutually exclusive, > as they will not make sense together with the potential flags I know, but > that can change at some time of course.Yes, I see that is workable. I do feel that checking for other flags would be a bit more robust. But as you say, there are none. So whichever approach you prefer is fine by me.> > > > > + else > > > + if (fdb_flags) > > > > nit: else if (fdb_flags) > > > > > + return 0; > > > > > > > ...
Vladimir Oltean
2023-Feb-03 20:44 UTC
[Bridge] [PATCH net-next 5/5] net: dsa: mv88e6xxx: implementation of dynamic ATU entries
On Fri, Feb 03, 2023 at 09:20:22AM +0100, Simon Horman wrote:> > else if (someflag) > > dosomething(); > > > > For now only one flag will actually be set and they are mutually exclusive, > > as they will not make sense together with the potential flags I know, but > > that can change at some time of course. > > Yes, I see that is workable. I do feel that checking for other flags would > be a bit more robust. But as you say, there are none. So whichever > approach you prefer is fine by me.The model we have for unsupported bits in the SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS and SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS handlers is essentially this: if (flags & ~(supported_flag_mask)) return -EOPNOTSUPP; if (flags & supported_flag_1) ... if (flags & supported_flag_2) ... I suppose applying this model here would address Simon's extensibility concern.