lkml.org 
[lkml]   [2021]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 net-next 09/10] net: dsa: microchip: add support for fdb and mdb management
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;

\
 
 \ /
  Last update: 2021-07-31 17:19    [W:0.190 / U:0.700 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site