Subject: Re: [PATCH net-next v3 1/2] net: stmmac: Refactor VLAN implementation

From: Simon Horman <[email-masked]>
Date: Fri, 11 Apr 2025 17:27:08 +0100

On Thu, Apr 10, 2025 at 04:19:12PM +0800, Furong Xu wrote:
> On Tue,  8 Apr 2025 16:13:53 +0800, Boon Khai Ng <[email-masked]> wrote:
> 
> > Refactor VLAN implementation by moving common code for DWMAC4 and
> > DWXGMAC IPs into a separate VLAN module. VLAN implementation for
> > DWMAC4 and DWXGMAC differs only for CSR base address, the descriptor
> > for the VLAN ID and VLAN VALID bit field.
> > 
> > Signed-off-by: Boon Khai Ng <[email-masked]>
> > Reviewed-by: Matthew Gerlach <[email-masked]>
> > ---
> >  drivers/net/ethernet/stmicro/stmmac/Makefile  |   2 +-
> >  drivers/net/ethernet/stmicro/stmmac/common.h  |   1 +
> >  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  |  40 ---
> >  .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 295 +-----------------
> >  .../net/ethernet/stmicro/stmmac/dwxgmac2.h    |  13 -
> >  .../ethernet/stmicro/stmmac/dwxgmac2_core.c   |  87 ------
> >  drivers/net/ethernet/stmicro/stmmac/hwif.c    |   8 +
> >  drivers/net/ethernet/stmicro/stmmac/hwif.h    |  61 ++--
> >  .../net/ethernet/stmicro/stmmac/stmmac_vlan.c | 294 +++++++++++++++++
> >  .../net/ethernet/stmicro/stmmac/stmmac_vlan.h |  63 ++++
> >  10 files changed, 401 insertions(+), 463 deletions(-)
> >  create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
> >  create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.h
> > 
> [...]
> > +static void vlan_update_hash(struct mac_device_info *hw, u32 hash,
> > +			     __le16 perfect_match, bool is_double)
> > +{
> > +	void __iomem *ioaddr = hw->pcsr;
> > +	u32 value;
> > +
> > +	writel(hash, ioaddr + VLAN_HASH_TABLE);
> > +
> > +	value = readl(ioaddr + VLAN_TAG);
> > +
> > +	if (hash) {
> > +		value |= VLAN_VTHM | VLAN_ETV;
> > +		if (is_double) {
> > +			value |= VLAN_EDVLP;
> > +			value |= VLAN_ESVL;
> > +			value |= VLAN_DOVLTC;
> 
> I can confirm that 802.1ad (QinQ) has been broken on stmmac for years,
> and it will be so nice if this refactoring includes some fixes for QinQ

FWIIW, please be sure that fixes are separate patches from refactoring.