From daa37761de13976153502332f2fa675bd3761cc4 Mon Sep 17 00:00:00 2001
From: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
Date: Thu, 23 Apr 2026 13:56:30 +0100
Subject: [PATCH 2/9] net: ethernet: mtk_ppe: set tport_idx on netsys_v3 for
 QoS

On MT7988 (netsys_v3) the PPE MAC info block carries a transport
port index field. When not set, ETH-to-ETH and WiFi-to-ETH hardware-
offloaded flows do not enter QDMA for scheduling, even with
IB2_PSE_QOS programmed on the entry -- the packet bypasses the
QDMA scheduler entirely, so any per-queue shaping installed
downstream has no effect.

Populate the netsys_v3 tport/tinfo fields in struct mtk_foe_mac_info
and set TPORT_IDX=1 from mtk_foe_entry_set_queue() on v3+.
No functional change on netsys_v1 or v2.

The hard-coded value 1 matches MediaTek's reference driver; the
datasheet may define additional transport modes, but none are in use
by in-tree consumers.

Signed-off-by: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
[Daniel Golle: hoist l2 declaration to function top per kernel C89 style]
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/ethernet/mediatek/mtk_ppe.c | 7 +++++++
 drivers/net/ethernet/mediatek/mtk_ppe.h | 4 ++++
 2 files changed, 11 insertions(+)

--- a/drivers/net/ethernet/mediatek/mtk_ppe.c
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
@@ -479,6 +479,7 @@ int mtk_foe_entry_set_queue(struct mtk_e
 			    unsigned int queue)
 {
 	u32 *ib2 = mtk_foe_entry_ib2(eth, entry);
+	struct mtk_foe_mac_info *l2;
 
 	if (mtk_is_netsys_v2_or_greater(eth)) {
 		*ib2 &= ~MTK_FOE_IB2_QID_V2;
@@ -490,6 +491,12 @@ int mtk_foe_entry_set_queue(struct mtk_e
 		*ib2 |= MTK_FOE_IB2_PSE_QOS;
 	}
 
+	if (mtk_is_netsys_v3_or_greater(eth)) {
+		l2 = mtk_foe_entry_l2(eth, entry);
+		l2->tport &= ~MTK_FOE_TPORT_IDX;
+		l2->tport |= FIELD_PREP(MTK_FOE_TPORT_IDX, 1);
+	}
+
 	return 0;
 }
 
--- a/drivers/net/ethernet/mediatek/mtk_ppe.h
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
@@ -96,6 +96,8 @@ enum {
 #define MTK_FOE_WINFO_AMSDU_HF		BIT(23)
 #define MTK_FOE_WINFO_AMSDU_EN		BIT(24)
 
+#define MTK_FOE_TPORT_IDX		GENMASK(3, 0)
+
 enum {
 	MTK_FOE_STATE_INVALID,
 	MTK_FOE_STATE_UNBIND,
@@ -124,6 +126,8 @@ struct mtk_foe_mac_info {
 	/* netsys_v3 */
 	u32 w3info;
 	u32 amsdu;
+	u16 tinfo;
+	u16 tport;
 };
 
 /* software-only entry type */
