Subject: Re: [PATCH net-next v4 1/3] net: dsa: felix: move USXGMII defines to common place

From: Russell King - ARM Linux admin <[email-masked]>
Date: Tue, 7 Jul 2020 10:18:31 +0100

On Tue, Jul 07, 2020 at 12:02:53AM +0200, Michael Walle wrote:
> The ENETC has the same PCS PHY and thus needs the same definitions. Move
> them into the common enetc_mdio.h header which has already the macros
> for the SGMII PCS.
> 
> Signed-off-by: Michael Walle <[email-masked]>
> ---
>  drivers/net/dsa/ocelot/felix_vsc9959.c | 21 ---------------------
>  include/linux/fsl/enetc_mdio.h         | 19 +++++++++++++++++++
>  2 files changed, 19 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index 19614537b1ba..53453c7015f6 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -16,29 +16,8 @@
>  #define VSC9959_VCAP_IS2_CNT		1024
>  #define VSC9959_VCAP_IS2_ENTRY_WIDTH	376
>  #define VSC9959_VCAP_PORT_CNT		6
> -
> -/* TODO: should find a better place for these */
> -#define USXGMII_BMCR_RESET		BIT(15)
> -#define USXGMII_BMCR_AN_EN		BIT(12)
> -#define USXGMII_BMCR_RST_AN		BIT(9)
> -#define USXGMII_BMSR_LNKS(status)	(((status) & GENMASK(2, 2)) >> 2)
> -#define USXGMII_BMSR_AN_CMPL(status)	(((status) & GENMASK(5, 5)) >> 5)
> -#define USXGMII_ADVERTISE_LNKS(x)	(((x) << 15) & BIT(15))
> -#define USXGMII_ADVERTISE_FDX		BIT(12)
> -#define USXGMII_ADVERTISE_SPEED(x)	(((x) << 9) & GENMASK(11, 9))
> -#define USXGMII_LPA_LNKS(lpa)		((lpa) >> 15)
> -#define USXGMII_LPA_DUPLEX(lpa)		(((lpa) & GENMASK(12, 12)) >> 12)
> -#define USXGMII_LPA_SPEED(lpa)		(((lpa) & GENMASK(11, 9)) >> 9)
> -
>  #define VSC9959_TAS_GCL_ENTRY_MAX	63
>  
> -enum usxgmii_speed {
> -	USXGMII_SPEED_10	= 0,
> -	USXGMII_SPEED_100	= 1,
> -	USXGMII_SPEED_1000	= 2,
> -	USXGMII_SPEED_2500	= 4,
> -};
> -
>  static const u32 vsc9959_ana_regmap[] = {
>  	REG(ANA_ADVLEARN,			0x0089a0),
>  	REG(ANA_VLANMASK,			0x0089a4),
> diff --git a/include/linux/fsl/enetc_mdio.h b/include/linux/fsl/enetc_mdio.h
> index 2d9203314865..611a7b0d5f10 100644
> --- a/include/linux/fsl/enetc_mdio.h
> +++ b/include/linux/fsl/enetc_mdio.h
> @@ -28,6 +28,25 @@ enum enetc_pcs_speed {
>  	ENETC_PCS_SPEED_2500	= 2,
>  };
>  
> +#define USXGMII_BMCR_RESET		BIT(15)
> +#define USXGMII_BMCR_AN_EN		BIT(12)
> +#define USXGMII_BMCR_RST_AN		BIT(9)

Aren't these just redefinitions of the standard BMCR definitions?

> +#define USXGMII_BMSR_LNKS(status)	(((status) & GENMASK(2, 2)) >> 2)
> +#define USXGMII_BMSR_AN_CMPL(status)	(((status) & GENMASK(5, 5)) >> 5)

Aren't these just redefinitions of the standard BMSR definitions just
differently?

Maybe convert the code to use the standard definitions found in
include/uapi/linux/mii.h and include/uapi/linux/mdio.h?

> +#define USXGMII_ADVERTISE_LNKS(x)	(((x) << 15) & BIT(15))
> +#define USXGMII_ADVERTISE_FDX		BIT(12)
> +#define USXGMII_ADVERTISE_SPEED(x)	(((x) << 9) & GENMASK(11, 9))
> +#define USXGMII_LPA_LNKS(lpa)		((lpa) >> 15)
> +#define USXGMII_LPA_DUPLEX(lpa)		(((lpa) & GENMASK(12, 12)) >> 12)
> +#define USXGMII_LPA_SPEED(lpa)		(((lpa) & GENMASK(11, 9)) >> 9)
> +
> +enum usxgmii_speed {
> +	USXGMII_SPEED_10	= 0,
> +	USXGMII_SPEED_100	= 1,
> +	USXGMII_SPEED_1000	= 2,
> +	USXGMII_SPEED_2500	= 4,
> +};
> +

I've asked in other patch sets for the USXGMII definitions to be moved
into some header that everyone can use - there is nothing enetc specific
about the USXGMII word definitions.  Please move them to a header file
so that everyone can use them.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!