On Thu, May 19, 2022 at 05:31:03PM +0200, Clément Léger wrote: > +static int a5psw_port_fdb_dump(struct dsa_switch *ds, int port, > + dsa_fdb_dump_cb_t *cb, void *data) > +{ > + struct a5psw *a5psw = ds->priv; > + union lk_data lk_data; > + int i = 0, ret; > + u32 reg; > + > + for (i = 0; i < A5PSW_TABLE_ENTRIES; i++) { > + reg = A5PSW_LK_ADDR_CTRL_READ | A5PSW_LK_ADDR_CTRL_WAIT | i; > + mutex_lock(&a5psw->lk_lock); It might be more efficient to lock the lookup table only once, outside the for loop, rather than 8192 times (plus the fact that when you run plain "bridge fdb show", this gets repeated for each switch user port, which is a nuisance of its own). > + > + ret = a5psw_lk_execute_ctrl(a5psw, ®); > + if (ret) { > + mutex_unlock(&a5psw->lk_lock); > + return ret; > + } > + > + lk_data.hi = a5psw_reg_readl(a5psw, A5PSW_LK_DATA_HI); > + /* If entry is not valid or does not contain the port, skip */ > + if (!lk_data.entry.valid || > + !(lk_data.entry.port_mask & BIT(port))) { > + mutex_unlock(&a5psw->lk_lock); > + continue; > + } > + > + lk_data.lo = a5psw_reg_readl(a5psw, A5PSW_LK_DATA_LO); > + mutex_unlock(&a5psw->lk_lock); > + > + ret = cb(lk_data.entry.mac, 0, lk_data.entry.is_static, data); > + if (ret) > + return ret; > + } > + > + return 0; > +}