Re: [PATCH v2 net-next 4/9] net: dsa: microchip: add DSA support for microchip lan937x

From: Andrew Lunn
Date: Thu Apr 22 2021 - 19:38:26 EST


> +static void lan937x_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
> + u64 *dropped, u64 *cnt)
> +{
> + addr = lan937x_mib_names[addr].index;
> + lan937x_r_mib_cnt(dev, port, addr, cnt);
> +}
> +
> +static void lan937x_port_init_cnt(struct ksz_device *dev, int port)
> +{
> + struct ksz_port_mib *mib = &dev->ports[port].mib;
> +
> + /* flush all enabled port MIB counters */
> + mutex_lock(&mib->cnt_mutex);
> + lan937x_pwrite32(dev, port, REG_PORT_MIB_CTRL_STAT__4,
> + MIB_COUNTER_FLUSH_FREEZE);
> + ksz_write8(dev, REG_SW_MAC_CTRL_6, SW_MIB_COUNTER_FLUSH);
> + lan937x_pwrite32(dev, port, REG_PORT_MIB_CTRL_STAT__4, 0);
> + mutex_unlock(&mib->cnt_mutex);
> +
> + mib->cnt_ptr = 0;
> + memset(mib->counters, 0, dev->mib_cnt * sizeof(u64));

This setting of cnt_ptr to zero and the memset() seem to be common to
all the drivers. Please add a cleanup patch which moves this into
ksz_init_mib_timer().

Andrew