On Fri, Jul 23, 2021 at 11:01:07PM +0530, Prasanna Vengateshan wrote: > +static int lan937x_port_fdb_add(struct dsa_switch *ds, int port, > + const unsigned char *addr, u16 vid) > +{ > + struct ksz_device *dev = ds->priv; > + u8 fid = lan937x_get_fid(vid); > + u32 alu_table[4]; > + int ret, i; > + u32 data; > + u8 val; > + > + mutex_lock(&dev->alu_mutex); > + > + /* Accessing two ALU tables through loop */ > + for (i = 0; i < ALU_STA_DYN_CNT; i++) { > + /* find any entry with mac & fid */ > + data = fid << ALU_FID_INDEX_S; > + data |= ((addr[0] << 8) | addr[1]); Maybe upper_32_bits(ether_addr_to_u64(addr)) and lower_32_bits(ether_addr_to_u64(addr)) would be slightly easier on the eye? > + if (alu_table[0] & ALU_V_STATIC_VALID) { > + /* read ALU entry */ > + ret = lan937x_read_table(dev, alu_table); > + if (ret < 0) { > + dev_err(dev->dev, "Failed to read ALU table\n"); > + break; > + } > + > + /* clear forwarding port */ > + alu_table[1] &= ~BIT(port); > + > + /* if there is no port to forward, clear table */ > + if ((alu_table[1] & ALU_V_PORT_MAP) == 0) { > + alu_table[0] = 0; > + alu_table[1] = 0; > + alu_table[2] = 0; > + alu_table[3] = 0; memset? > + } > + } else { > + alu_table[0] = 0; > + alu_table[1] = 0; > + alu_table[2] = 0; > + alu_table[3] = 0; > + } > + > + ret = lan937x_write_table(dev, alu_table); > + if (ret < 0) > + break;