From nobody Tue Apr 7 14:06:12 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4059D392822; Wed, 25 Feb 2026 14:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772029492; cv=none; b=UY8un1aUfdYTaBlPnUvnvM7qeTRLFAa7dvmcmOWEDmpSKrZCEHWmD0W0YJcTusf6U4ZlMImbX1wx5WredXRQMF63auFRmZXVPxlRI52+1LoVBzW9vajOJTuIwWL/Q9pjlHVIHe6ycopbGxLwYxw4FCfdEpZf73q5VAeE61+Nm0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772029492; c=relaxed/simple; bh=90v2V3edTeUdWM0oAbEoX+Yh7zyuJt/oEpYWh3miwjQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OwPM/wwlb8jXwo7QORy4TR5qre9evxKWRP2W4ByWVZ3iPZXCocWmD8ZYUGJzTLlLqYLvhOK/Ls4yWDSdH3u5oow85BQJmTvSe3jgG5iG7AzOxTxWPA1xSZP2IbaHaqQBV8laA46nqUfuXPQcAYYmm1LKxaWmC0rmOq3iFbcM4ls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: L+IALaWDRBO0q4YalVUyWw== X-CSE-MsgGUID: cCWN2MKST6q+m7KfE0ELWQ== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 25 Feb 2026 23:24:49 +0900 Received: from vm01.adwin.renesas.com (unknown [10.226.92.192]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id D25B14017D8D; Wed, 25 Feb 2026 23:24:42 +0900 (JST) From: Ovidiu Panait To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux@armlinux.org.uk, rmk+kernel@armlinux.org.uk, maxime.chevallier@bootlin.com, boon.khai.ng@altera.com, rohan.g.thomas@altera.com, vladimir.oltean@nxp.com, hayashi.kunihiko@socionext.com, boon.leong.ong@intel.com, kim.tatt.chuah@intel.com Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 4/5] net: stmmac: Add write_hw parameter to VLAN filter operations Date: Wed, 25 Feb 2026 14:24:13 +0000 Message-ID: <20260225142414.130144-5-ovidiu.panait.rb@renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260225142414.130144-1-ovidiu.panait.rb@renesas.com> References: <20260225142414.130144-1-ovidiu.panait.rb@renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a write_hw parameter to the VLAN add/delete HW filter functions and to stmmac_vlan_update(). This flag controls whether the actual hardware register accesses are performed. When set to false, only the software state is updated. The next commit will use this to defer hardware writes when the interface is down. No functional change. Signed-off-by: Ovidiu Panait --- v2 changes: none. drivers/net/ethernet/stmicro/stmmac/hwif.h | 6 ++-- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 25 +++++++++----- .../net/ethernet/stmicro/stmmac/stmmac_vlan.c | 34 ++++++++++++------- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ether= net/stmicro/stmmac/hwif.h index 0db96a387259..d7598c76251f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -647,10 +647,12 @@ struct stmmac_vlan_ops { void (*set_hw_vlan_mode)(struct mac_device_info *hw); int (*add_hw_vlan_rx_fltr)(struct net_device *dev, struct mac_device_info *hw, - __be16 proto, u16 vid); + __be16 proto, u16 vid, + bool write_hw); int (*del_hw_vlan_rx_fltr)(struct net_device *dev, struct mac_device_info *hw, - __be16 proto, u16 vid); + __be16 proto, u16 vid, + bool write_hw); void (*restore_hw_vlan_rx_fltr)(struct net_device *dev, struct mac_device_info *hw); }; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index a02575f67057..19c86e3b42cc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6751,7 +6751,8 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le) return crc; } =20 -static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double) +static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double, + bool write_hw) { u32 crc, hash =3D 0; u16 pmatch =3D 0; @@ -6773,7 +6774,11 @@ static int stmmac_vlan_update(struct stmmac_priv *pr= iv, bool is_double) hash =3D 0; } =20 - return stmmac_update_vlan_hash(priv, priv->hw, hash, pmatch, is_double); + if (write_hw) + return stmmac_update_vlan_hash(priv, priv->hw, hash, pmatch, + is_double); + + return 0; } =20 /* FIXME: This may need RXC to be running, but it may be called with BH @@ -6795,17 +6800,18 @@ static int stmmac_vlan_rx_add_vid(struct net_device= *ndev, __be16 proto, u16 vid =20 set_bit(vid, priv->active_vlans); num_double_vlans =3D priv->num_double_vlans + is_double; - ret =3D stmmac_vlan_update(priv, num_double_vlans); + ret =3D stmmac_vlan_update(priv, num_double_vlans, true); if (ret) { clear_bit(vid, priv->active_vlans); goto err_pm_put; } =20 if (priv->hw->num_vlan) { - ret =3D stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); + ret =3D stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, + vid, true); if (ret) { clear_bit(vid, priv->active_vlans); - stmmac_vlan_update(priv, priv->num_double_vlans); + stmmac_vlan_update(priv, priv->num_double_vlans, true); goto err_pm_put; } } @@ -6837,17 +6843,18 @@ static int stmmac_vlan_rx_kill_vid(struct net_devic= e *ndev, __be16 proto, u16 vi =20 clear_bit(vid, priv->active_vlans); num_double_vlans =3D priv->num_double_vlans - is_double; - ret =3D stmmac_vlan_update(priv, num_double_vlans); + ret =3D stmmac_vlan_update(priv, num_double_vlans, true); if (ret) { set_bit(vid, priv->active_vlans); goto del_vlan_error; } =20 if (priv->hw->num_vlan) { - ret =3D stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); + ret =3D stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, + vid, true); if (ret) { set_bit(vid, priv->active_vlans); - stmmac_vlan_update(priv, priv->num_double_vlans); + stmmac_vlan_update(priv, priv->num_double_vlans, true); goto del_vlan_error; } } @@ -6870,7 +6877,7 @@ static int stmmac_vlan_restore(struct stmmac_priv *pr= iv) if (priv->hw->num_vlan) stmmac_restore_hw_vlan_rx_fltr(priv, priv->dev, priv->hw); =20 - ret =3D stmmac_vlan_update(priv, priv->num_double_vlans); + ret =3D stmmac_vlan_update(priv, priv->num_double_vlans, true); if (ret) netdev_err(priv->dev, "Failed to restore VLANs\n"); =20 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_vlan.c index fcc34867405e..f81015179d04 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c @@ -53,7 +53,8 @@ static int vlan_write_filter(struct net_device *dev, =20 static int vlan_add_hw_rx_fltr(struct net_device *dev, struct mac_device_info *hw, - __be16 proto, u16 vid) + __be16 proto, u16 vid, + bool write_hw) { int index =3D -1; u32 val =3D 0; @@ -76,7 +77,8 @@ static int vlan_add_hw_rx_fltr(struct net_device *dev, } =20 hw->vlan_filter[0] =3D vid; - vlan_write_single(dev, vid); + if (write_hw) + vlan_write_single(dev, vid); =20 return 0; } @@ -97,17 +99,21 @@ static int vlan_add_hw_rx_fltr(struct net_device *dev, return -EPERM; } =20 - ret =3D vlan_write_filter(dev, hw, index, val); + if (write_hw) { + ret =3D vlan_write_filter(dev, hw, index, val); + if (ret) + return ret; + } =20 - if (!ret) - hw->vlan_filter[index] =3D val; + hw->vlan_filter[index] =3D val; =20 - return ret; + return 0; } =20 static int vlan_del_hw_rx_fltr(struct net_device *dev, struct mac_device_info *hw, - __be16 proto, u16 vid) + __be16 proto, u16 vid, + bool write_hw) { int i, ret =3D 0; =20 @@ -115,7 +121,8 @@ static int vlan_del_hw_rx_fltr(struct net_device *dev, if (hw->num_vlan =3D=3D 1) { if ((hw->vlan_filter[0] & VLAN_TAG_VID) =3D=3D vid) { hw->vlan_filter[0] =3D 0; - vlan_write_single(dev, 0); + if (write_hw) + vlan_write_single(dev, 0); } return 0; } @@ -124,12 +131,13 @@ static int vlan_del_hw_rx_fltr(struct net_device *dev, for (i =3D 0; i < hw->num_vlan; i++) { if ((hw->vlan_filter[i] & VLAN_TAG_DATA_VEN) && ((hw->vlan_filter[i] & VLAN_TAG_DATA_VID) =3D=3D vid)) { - ret =3D vlan_write_filter(dev, hw, i, 0); + if (write_hw) { + ret =3D vlan_write_filter(dev, hw, i, 0); + if (ret) + return ret; + } =20 - if (!ret) - hw->vlan_filter[i] =3D 0; - else - return ret; + hw->vlan_filter[i] =3D 0; } } =20 --=20 2.51.0