Skip to contentSkip to conversation

net: stmmac: rebuild VLAN priority steering when filters change

PATCH Applied James Hilliard 3 participants 4 messages Nov 4 – Nov 10

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: stmmac: rebuild VLAN priority steering when filters change

The RX queue priority callbacks preserve previously assigned priorities. Passing zero from tc_del_vlan_flow() therefore leaves the deleted rule's priority mapped to its RX queue. Clearing the whole queue instead would also remove priorities belonging to other installed rules.

Save each VLAN rule's priority and rebuild the complete per-queue masks after insertion and deletion, starting from the platform assignments. Resolve overlapping platform masks with the same last-queue-wins ordering used during initialization.

Make the GMAC4 and XGMAC callbacks replace the target queue's mask while retaining their exclusion of its priorities from other queues. Program a priority's new destination before clearing its previous assignment.

Keep VLAN rules in programming order. Flower installs a replacement under a new cookie before deleting the old one, so the newer assignment must remain effective while both are present, including when an earlier array slot is reused. Removing a rejected replacement restores the older rule, and removing the last override restores the platform assignment.

VLAN and EtherType rules share the RFS array. Preserve an existing cookie's steering type and reuse its entry without incrementing the rule count, so replaying a rule cannot unlink an EtherType entry or leave a retyped VLAN entry on the list.

Validate the selected RX queue before indexing the masks:
tc_classid_to_hwtc() checks the number of traffic classes, which can exceed the number of RX queues. When rebuilding the masks, skip rules whose RX queue was removed by ethtool so they cannot suppress the platform assignment or an older rule targeting an active queue.

Found by code inspection while working on STMMAC reset/recovery fixes. Host-side tests exercising the driver's VLAN rule handlers and priority callbacks with mocked MMIO reproduce the stale mapping after deletion and pass with this fix. No hardware testing was performed.

Fixes b3da86d432b7 ("net: stmmac: fix rx queue priority assignment")

---
Changes in v2:
- Preserve RFS entry types on replay in both the VLAN and EtherType
handlers, keeping only VLAN entries on the priority list.
- Reuse installed EtherType entries without counting them again or
rejecting them against their own capacity limit.
- Skip removed RX queues when rebuilding masks, retaining active
platform assignments and older valid rules.
- Rebase onto net at 03897066069f.
- Link to v1: https://patch.msgid.link/[email protected]

---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c  |  2 +
 .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c    |  2 +
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  4 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c    | 97 ++++++++++++++++------
 4 files changed, 81 insertions(+), 24 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +2 -0
index 259e2ebed8c1..efbe2ec4c213 100644
@@ -126,6 +126,7 @@ static void dwmac4_rx_queue_priority(struct mac_device_info *hw,
 	 * clear them from others queues
 	 */
 	if (queue < 4) {
+		ctrl2 &= ~GMAC_RXQCTRL_PSRQX_MASK(queue);
 		ctrl2 |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) &
 						GMAC_RXQCTRL_PSRQX_MASK(queue);
 
@@ -134,6 +135,7 @@ static void dwmac4_rx_queue_priority(struct mac_device_info *hw,
 	} else {
 		queue -= 4;
 
+		ctrl3 &= ~GMAC_RXQCTRL_PSRQX_MASK(queue);
 		ctrl3 |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) &
 						GMAC_RXQCTRL_PSRQX_MASK(queue);
 
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +2 -0
index 1a88cbaed70c..7ad08651675e 100644
@@ -119,6 +119,7 @@ static void dwxgmac2_rx_queue_prio(struct mac_device_info *hw, u32 prio,
 	 * clear them from others queues
 	 */
 	if (queue < 4) {
+		ctrl2 &= ~XGMAC_PSRQ(queue);
 		ctrl2 |= (prio << XGMAC_PSRQ_SHIFT(queue)) &
 						XGMAC_PSRQ(queue);
 
@@ -127,6 +128,7 @@ static void dwxgmac2_rx_queue_prio(struct mac_device_info *hw, u32 prio,
 	} else {
 		queue -= 4;
 
+		ctrl3 &= ~XGMAC_PSRQ(queue);
 		ctrl3 |= (prio << XGMAC_PSRQ_SHIFT(queue)) &
 						XGMAC_PSRQ(queue);
 
drivers/net/ethernet/stmicro/stmmac/stmmac.h +4 -0
index b76acfe0d958..fcc395321816 100644
@@ -14,6 +14,7 @@
 #include <linux/clk.h>
 #include <linux/hrtimer.h>
 #include <linux/if_vlan.h>
+#include <linux/list.h>
 #include <linux/stmmac.h>
 #include <linux/phylink.h>
 #include <linux/pci.h>
@@ -210,6 +211,8 @@ enum stmmac_rfs_type {
 struct stmmac_rfs_entry {
 	unsigned long cookie;
 	u16 etype;
+	u8 vlan_prio;
+	struct list_head vlan_node;
 	int in_use;
 	int type;
 	int tc;
@@ -382,6 +385,7 @@ struct stmmac_priv {
 	unsigned int rfs_entries_cnt[STMMAC_RFS_T_MAX];
 	unsigned int rfs_entries_total;
 	struct stmmac_rfs_entry *rfs_entries;
+	struct list_head vlan_prio;
 
 	/* Pulse Per Second output */
 	struct stmmac_pps_cfg pps[STMMAC_PPS_MAX];
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +73 -24

170 lines not on this page · raw message

---
base-commit: 03897066069fd47caf2908183edf3b22b822ea73
change-id: 20261102-submit-stmmac-vlan-prio-v1-8e5f674f1201

Best regards,

Signature · 1 line
James Hilliard <[email protected]>
#1 lore raw
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.

The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.

#2 lore raw
Quoted 9 lines · On Wed, Nov 4, 2026 at 11:53 AM <[email protected]> wrote:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.

As the commit message states:
No hardware testing was performed.

Quoted 9 lines

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.

The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.

#3 lore raw
In reply to James Hilliard
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 04 Nov 2026 11:51:41 -0700 you wrote:

The RX queue priority callbacks preserve previously assigned priorities. Passing zero from tc_del_vlan_flow() therefore leaves the deleted rule's priority mapped to its RX queue. Clearing the whole queue instead would also remove priorities belonging to other installed rules.

Save each VLAN rule's priority and rebuild the complete per-queue masks after insertion and deletion, starting from the platform assignments. Resolve overlapping platform masks with the same last-queue-wins ordering used during initialization.

[...]

Here is the summary with links:
- [net,v2] net: stmmac: rebuild VLAN priority steering when filters change

    https://git.kernel.org/netdev/net-next/c/edf10f5c2513

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html