Re: [PATCH net-next v1 4/7] net: dsa: microchip: ksz8_r_sta_mac_table(): Avoid using error code for empty entries

From: Vladimir Oltean
Date: Tue Apr 04 2023 - 07:58:19 EST


On Tue, Apr 04, 2023 at 12:18:39PM +0200, Oleksij Rempel wrote:
> Prepare for the next patch by ensuring that ksz8_r_sta_mac_table() does
> not use error codes for empty entries. This change will enable better
> handling of read/write errors in the upcoming patch.
>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
> ---

Reviewed-by: Vladimir Oltean <olteanv@xxxxxxxxx>

FWIW, it looks like for port_fdb_add(), you could skip the search in the
static MAC table, as long as you just keep a reference to the last
populated index, because the bridge won't allow, to my knowledge, adding
the same MAC address twice (this has changed when we stopped allowing
bridge bypass operations in commit b117e1e8a86d ("net: dsa: delete
dsa_legacy_fdb_add and dsa_legacy_fdb_del")), and so, having space would
mean that the last populated index is < dev->info->num_statics - 1.

This guarantee and optimization possibility is different from
port_mdb_add(), because there, you might be asked to modify an existing
entry, and so, you still need the search to find it. But still, you
could limit the search for the remaining 3 operations - port_fdb_del(),
port_mdb_add(), port_mdb_del() - just from 0 to that last populated
entry, not to dev->info->num_statics, which should still accelerate the
operations a bit.