net: enetc: move enetc_set_si_vlan_promisc() to enetc_pf_common.c

The PSIPVMR in ENETC v4 has the same bit layout and functionality as the
PSIPVMR register in ENETC v1: bit n (n <= 15) controls VLAN 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 VLAN promiscuous mode
setting code can be shared between ENETC v1 and v4 drivers.

Move enetc_set_si_vlan_promisc() from enetc_pf.c to enetc_pf_common.c
and export it so that it can be shared between the two drivers. Add a
revision check using is_enetc_rev1() to select the correct register
offset (ENETC_PSIPVMR for v1 and ENETC4_PSIPVMR for v4) while keeping
the same logic.

Remove the v4-specific enetc4_pf_set_si_vlan_promisc() from enetc4_pf.c
and replace its call site with the new common enetc_set_si_vlan_promisc()
to eliminate code duplication.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Joe Damato <joe@dama.to>
Link: https://patch.msgid.link/20260720014317.1059359-12-wei.fang@oss.nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Wei Fang
2026-07-20 09:43:13 +08:00
committed by Jakub Kicinski
parent f7c6dcd644
commit ba07e3bef1
4 changed files with 25 additions and 31 deletions

View File

@@ -295,18 +295,6 @@ static void enetc4_allocate_si_rings(struct enetc_pf *pf)
enetc4_default_rings_allocation(pf);
}
static void enetc4_pf_set_si_vlan_promisc(struct enetc_hw *hw, int si, bool en)
{
u32 val = enetc_port_rd(hw, ENETC4_PSIPVMR);
if (en)
val |= BIT(si);
else
val &= ~BIT(si);
enetc_port_wr(hw, ENETC4_PSIPVMR, val);
}
/* Allocate the number of MSI-X vectors for per SI. */
static void enetc4_set_si_msix_num(struct enetc_pf *pf)
{
@@ -352,7 +340,7 @@ static void enetc4_configure_port_si(struct enetc_pf *pf)
/* Enforce VLAN promiscuous mode for all SIs */
for (int i = 0; i < pf->caps.num_vsi + 1; i++)
enetc4_pf_set_si_vlan_promisc(hw, i, true);
enetc_set_si_vlan_promisc(pf->si, i, true);
/* Disable SI MAC multicast & unicast promiscuous */
enetc_port_wr(hw, ENETC4_PSIPMMR, 0);
@@ -518,12 +506,11 @@ static int enetc4_pf_set_features(struct net_device *ndev,
{
netdev_features_t changed = ndev->features ^ features;
struct enetc_ndev_priv *priv = netdev_priv(ndev);
struct enetc_hw *hw = &priv->si->hw;
if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
bool promisc_en = !(features & NETIF_F_HW_VLAN_CTAG_FILTER);
enetc4_pf_set_si_vlan_promisc(hw, 0, promisc_en);
enetc_set_si_vlan_promisc(priv->si, 0, promisc_en);
}
if (changed & NETIF_F_LOOPBACK)

View File

@@ -42,22 +42,6 @@ static void enetc_pf_destroy_pcs(struct phylink_pcs *pcs)
lynx_pcs_destroy(pcs);
}
static void enetc_set_si_vlan_promisc(struct enetc_si *si, int si_id,
bool promisc)
{
struct enetc_hw *hw = &si->hw;
u32 val;
val = enetc_port_rd(hw, ENETC_PSIPVMR);
if (promisc)
val |= PSIPVMR_SI_VLAN_P(si_id);
else
val &= ~PSIPVMR_SI_VLAN_P(si_id);
enetc_port_wr(hw, ENETC_PSIPVMR, val);
}
static void enetc_set_isol_vlan(struct enetc_hw *hw, int si, u16 vlan, u8 qos)
{
u32 val = 0;

View File

@@ -171,6 +171,28 @@ void enetc_set_si_mc_hash_filter(struct enetc_si *si, int si_id, u64 hash)
}
EXPORT_SYMBOL_GPL(enetc_set_si_mc_hash_filter);
void enetc_set_si_vlan_promisc(struct enetc_si *si, int si_id, bool promisc)
{
struct enetc_hw *hw = &si->hw;
int psipvmr_off;
u32 val;
if (is_enetc_rev1(si))
psipvmr_off = ENETC_PSIPVMR;
else
psipvmr_off = ENETC4_PSIPVMR;
val = enetc_port_rd(hw, psipvmr_off);
if (promisc)
val |= PSIPVMR_SI_VLAN_P(si_id);
else
val &= ~PSIPVMR_SI_VLAN_P(si_id);
enetc_port_wr(hw, psipvmr_off, val);
}
EXPORT_SYMBOL_GPL(enetc_set_si_vlan_promisc);
void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
const struct net_device_ops *ndev_ops)
{

View File

@@ -21,6 +21,7 @@ void enetc_set_si_uc_promisc(struct enetc_si *si, int si_id, bool promisc);
void enetc_set_si_mc_promisc(struct enetc_si *si, int si_id, bool promisc);
void enetc_set_si_uc_hash_filter(struct enetc_si *si, int si_id, u64 hash);
void enetc_set_si_mc_hash_filter(struct enetc_si *si, int si_id, u64 hash);
void enetc_set_si_vlan_promisc(struct enetc_si *si, int si_id, bool promisc);
static inline u16 enetc_get_ip_revision(struct enetc_hw *hw)
{