Re: [PATCH net-next v6 04/10] net: dsa: microchip: ksz8795: add support for ksz88xx chips

From: Andrew Lunn
Date: Sat Apr 24 2021 - 11:51:57 EST


On Fri, Apr 23, 2021 at 10:02:12AM +0200, Oleksij Rempel wrote:
> We add support for the ksz8863 and ksz8873 chips which are
> using the same register patterns but other offsets as the
> ksz8795.
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
>
> ---
> v1 -> v4: - extracted this change from bigger previous patch
> v4 -> v5: - added clear of reset bit for ksz8863 reset code
> - using extra device flag IS_KSZ88x3 instead of is_ksz8795 function
> - using DSA_TAG_PROTO_KSZ9893 protocol for ksz88x3 instead
> v5 -> v6: - changed variable order to revers christmas tree
> - added back missed dropped handling in init_cnt for ksz8863
> - disable VLAN support for ksz8863. Currently it need more
> work.
> ---
> drivers/net/dsa/microchip/ksz8795.c | 321 ++++++++++++++++++++----
> drivers/net/dsa/microchip/ksz8795_reg.h | 40 ++-
> drivers/net/dsa/microchip/ksz_common.h | 1 +
> 3 files changed, 286 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
> index 8835217e2804..78181d29db12 100644
> --- a/drivers/net/dsa/microchip/ksz8795.c
> +++ b/drivers/net/dsa/microchip/ksz8795.c
> @@ -22,6 +22,9 @@
> #include "ksz8795_reg.h"
> #include "ksz8.h"
>
> +/* Used with variable features to indicate capabilities. */
> +#define IS_88X3 BIT(0)

How well is this going to scale? With only two devices, this is
O.K. But when you add a third, you are probably going to want to use a
switch statement, and that is not so easy with bits. I think an enum
makes this more future proof.

Andrew