lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aa1e91a9df8548559f0e6cde19dc1e90619d8a1e.camel@microchip.com>
Date:   Tue, 29 Nov 2022 08:29:47 +0000
From:   <Arun.Ramadoss@...rochip.com>
To:     <olteanv@...il.com>, <UNGLinuxDriver@...rochip.com>,
        <vivien.didelot@...il.com>, <andrew@...n.ch>,
        <f.fainelli@...il.com>, <kuba@...nel.org>, <edumazet@...gle.com>,
        <pabeni@...hat.com>, <o.rempel@...gutronix.de>,
        <Woojung.Huh@...rochip.com>, <davem@...emloft.net>
CC:     <linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>,
        <kernel@...gutronix.de>
Subject: Re: [PATCH v1 10/26] net: dsa: microchip: ksz8: refactor
 ksz8_fdb_dump()

Hi Oleksij,

On Mon, 2022-11-28 at 12:59 +0100, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> After fixing different bugs we can refactor this function:
> - be paranoid - read only max possibly amount of entries supported by
>   the HW.
> - pass error values returned by regmap
> 
> Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
> ---
>  drivers/net/dsa/microchip/ksz8795.c     | 41 ++++++++++++++---------
> --
>  drivers/net/dsa/microchip/ksz8795_reg.h |  1 +
>  2 files changed, 24 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/dsa/microchip/ksz8795.c
> b/drivers/net/dsa/microchip/ksz8795.c
> index 736cf4e54333..308b46bb2ce5 100644
> --- a/drivers/net/dsa/microchip/ksz8795.c
> +++ b/drivers/net/dsa/microchip/ksz8795.c
> @@ -949,26 +949,31 @@ void ksz8_flush_dyn_mac_table(struct ksz_device
> *dev, int port)
>  int ksz8_fdb_dump(struct ksz_device *dev, int port,
>                   dsa_fdb_dump_cb_t *cb, void *data)
>  {
> -       int ret = 0;
> -       u16 i = 0;
> -       u16 entries = 0;
> -       u8 src_port;
> -       u8 mac[ETH_ALEN];
> +       u16 i, entries = 0;
> +       int ret;
> 
> -       do {
> -               ret = ksz8_r_dyn_mac_table(dev, i, mac, &src_port,
> -                                          &entries);
> -               if (!ret && port == src_port) {
> -                       ret = cb(mac, 0, false, data);
> -                       if (ret)
> -                               break;
> -               }
> -               i++;
> -       } while (i < entries);
> -       if (i >= entries)
> -               ret = 0;
> +       for (i = 0; i < KSZ8_DYN_MAC_ENTRIES; i++) {
> +               u8 mac[ETH_ALEN];
> +               u8 src_port;

Any specific reason for declaring variable within for loop instead of
outside.

> 
> -       return ret;
> +               ret = ksz8_r_dyn_mac_table(dev, i, mac, &src_port,
> &entries);
> +               if (ret == -ENXIO)
> +                       return 0;
> +               if (ret)
> +                       return ret;
> +
> +               if (i >= entries)
> +                       return 0;
> +
> +               if (port != src_port)
> +                       continue;
> +
> +               ret = cb(mac, 0, false, data);
> +               if (ret)
> +                       return ret;
> +       }
> +
> +       return 0;
>  }
> 
>  int ksz8_mdb_add(struct ksz_device *dev, int port,
> diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h
> b/drivers/net/dsa/microchip/ksz8795_reg.h
> index 7a57c6088f80..0bdceb534192 100644
> --- a/drivers/net/dsa/microchip/ksz8795_reg.h
> +++ b/drivers/net/dsa/microchip/ksz8795_reg.h
> @@ -811,5 +811,6 @@
>  #define TAIL_TAG_LOOKUP                        BIT(7)
> 
>  #define FID_ENTRIES                    128
> +#define KSZ8_DYN_MAC_ENTRIES           1024
> 
>  #endif
> --
> 2.30.2
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ