[PATCH net v3 0/4] net: stmmac: Fix VLAN handling when interface is down

Ovidiu Panait posted 4 patches 1 month ago
drivers/net/ethernet/stmicro/stmmac/stmmac.h  |  1 +
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 53 ++++++++++++++--
.../net/ethernet/stmicro/stmmac/stmmac_vlan.c | 60 ++++++++++---------
3 files changed, 79 insertions(+), 35 deletions(-)
[PATCH net v3 0/4] net: stmmac: Fix VLAN handling when interface is down
Posted by Ovidiu Panait 1 month ago
VLAN register accesses on the MAC side require the PHY RX clock to be
active. When the network interface is down, the PHY is suspended and
the RX clock is unavailable, causing VLAN operations to fail with
timeouts.

The VLAN core automatically removes VID 0 after the interface goes down
and re-adds it when it comes back up, so these timeouts happen during
normal interface down/up:

    # ip link set end1 down
    renesas-gbeth 15c40000.ethernet end1: Timeout accessing MAC_VLAN_Tag_Filter
    renesas-gbeth 15c40000.ethernet end1: failed to kill vid 0081/0

Adding VLANs while the interface is down also fails:

    # ip link add link end1 name end1.10 type vlan id 10
    renesas-gbeth 15c40000.ethernet end1: Timeout accessing MAC_VLAN_Tag_Filter
    RTNETLINK answers: Device or resource busy

Patch 4 fixes this by adding checks in the VLAN paths for netif_running(),
and skipping register accesses if the interface is down. Only the software
state is updated in this case. When the interface is brought up, the VLAN
state is restored to hardware.

Patches 1-3 fix some issues in the existing VLAN implementation.

v3:
- Dropped the 'write_hw' approach and added checks for netif_running() directly
  in the VLAN paths, to avoid passing attributes around.

v2: https://lore.kernel.org/all/20260225142414.130144-1-ovidiu.panait.rb@renesas.com/
- Added a new commit that fixes VLAN restore on the resume and open paths.

v1: https://lore.kernel.org/all/20260223124102.120432-1-ovidiu.panait.rb@renesas.com/

Ovidiu Panait (4):
  net: stmmac: Fix error handling in VLAN add and delete paths
  net: stmmac: Improve double VLAN handling
  net: stmmac: Fix VLAN HW state restore
  net: stmmac: Defer VLAN HW configuration when interface is down

 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |  1 +
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 53 ++++++++++++++--
 .../net/ethernet/stmicro/stmmac/stmmac_vlan.c | 60 ++++++++++---------
 3 files changed, 79 insertions(+), 35 deletions(-)

-- 
2.51.0