On Mon, Jul 20, 2026 at 09:43:03AM +0800, [email protected] wrote:
> From: Wei Fang <[email protected]>
>
> The PSIPMMR (Port Station Interface Promiscuous MAC Mode Register) in
> ENETC v4 has the same bit layout as the PSIPMR register in ENETC v1: bit
> n controls unicast promiscuous mode for SI n, and bit (n + 16) controls
> multicast promiscuous mode for SI n. The only difference between the two
> hardware generations is the register address offset.
>
> Since the register functionality is identical, the MAC promiscuous mode
> setting code can be shared between ENETC v1 and v4 drivers.
>
> Rename ENETC_PSIPMR to ENETC_PSIPMMR in enetc_hw.h to match the actual
> register name used in the reference manual, and extract two new common
> helper functions, enetc_set_si_uc_promisc() and
> enetc_set_si_mc_promisc(), into enetc_pf_common.c. These helpers select
> the correct register offset based on the hardware revision via
> is_enetc_rev1().
>
> Remove the v4-specific enetc4_pf_set_si_mac_promisc() function from
> enetc4_pf.c and the duplicate PSIPMMR_SI_MAC_UP/MP macro definitions
> from enetc4_hw.h, as they are now superseded by the shared code.
>
> Signed-off-by: Wei Fang <[email protected]>
> ---
> .../net/ethernet/freescale/enetc/enetc4_hw.h | 2 -
> .../net/ethernet/freescale/enetc/enetc4_pf.c | 21 +--------
> .../ethernet/freescale/enetc/enetc_ethtool.c | 2 +-
> .../net/ethernet/freescale/enetc/enetc_hw.h | 7 +--
> .../net/ethernet/freescale/enetc/enetc_pf.c | 11 ++---
> .../freescale/enetc/enetc_pf_common.c | 44 +++++++++++++++++++
> .../freescale/enetc/enetc_pf_common.h | 2 +
> 7 files changed, 56 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h
> b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h
> index f18437556a0e..6a8f2ed56017 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc4_hw.h
> +++ b/drivers/net/ethernet/freescale/enetc/enetc4_hw.h
> @@ -69,8 +69,6 @@
>
> /* Port Station interface promiscuous MAC mode register */
> #define ENETC4_PSIPMMR 0x200
> -#define PSIPMMR_SI_MAC_UP(a) BIT(a) /* a = SI index */
> -#define PSIPMMR_SI_MAC_MP(a) BIT((a) + 16)
[...]
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h
> b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
> index bf99b65d7598..66bfda60da9c 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
> @@ -180,9 +180,10 @@ enum enetc_bdr_type {TX, RX};
> #define ENETC_PMR_PSPEED_1000M BIT(9)
> #define ENETC_PMR_PSPEED_2500M BIT(10)
> #define ENETC_PSR 0x0004 /* RO */
> -#define ENETC_PSIPMR 0x0018
> -#define ENETC_PSIPMR_SET_UP(n) BIT(n) /* n = SI index */
> -#define ENETC_PSIPMR_SET_MP(n) BIT((n) + 16)
> +#define ENETC_PSIPMMR 0x0018
> +#define PSIPMMR_SI_MAC_UP(n) BIT(n) /* n = SI index */
> +#define PSIPMMR_SI_MAC_MP(n) BIT((n) + 16)
I probably would have fixed the leading spaces when copying/pasting the macro,
but that seems like a nit.
I read the rest of the code a few times and it looks right to me.
Reviewed-by: Joe Damato <[email protected]>