Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethernet: mediatek: ppe: assign per-port queues for offloaded traffic

Keeps traffic sent to the switch within link speed limits

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20221116080734.44013-7-nbd@nbd.name
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Felix Fietkau and committed by
Jakub Kicinski
8bd8dcc5 d169ecb5

+31 -3
+18
drivers/net/ethernet/mediatek/mtk_ppe.c
··· 399 399 return 0; 400 400 } 401 401 402 + int mtk_foe_entry_set_queue(struct mtk_eth *eth, struct mtk_foe_entry *entry, 403 + unsigned int queue) 404 + { 405 + u32 *ib2 = mtk_foe_entry_ib2(eth, entry); 406 + 407 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { 408 + *ib2 &= ~MTK_FOE_IB2_QID_V2; 409 + *ib2 |= FIELD_PREP(MTK_FOE_IB2_QID_V2, queue); 410 + *ib2 |= MTK_FOE_IB2_PSE_QOS_V2; 411 + } else { 412 + *ib2 &= ~MTK_FOE_IB2_QID; 413 + *ib2 |= FIELD_PREP(MTK_FOE_IB2_QID, queue); 414 + *ib2 |= MTK_FOE_IB2_PSE_QOS; 415 + } 416 + 417 + return 0; 418 + } 419 + 402 420 static bool 403 421 mtk_flow_entry_match(struct mtk_eth *eth, struct mtk_flow_entry *entry, 404 422 struct mtk_foe_entry *data)
+4
drivers/net/ethernet/mediatek/mtk_ppe.h
··· 68 68 #define MTK_FOE_IB2_DSCP GENMASK(31, 24) 69 69 70 70 /* CONFIG_MEDIATEK_NETSYS_V2 */ 71 + #define MTK_FOE_IB2_QID_V2 GENMASK(6, 0) 71 72 #define MTK_FOE_IB2_PORT_MG_V2 BIT(7) 73 + #define MTK_FOE_IB2_PSE_QOS_V2 BIT(8) 72 74 #define MTK_FOE_IB2_DEST_PORT_V2 GENMASK(12, 9) 73 75 #define MTK_FOE_IB2_MULTICAST_V2 BIT(13) 74 76 #define MTK_FOE_IB2_WDMA_WINFO_V2 BIT(19) ··· 352 350 int sid); 353 351 int mtk_foe_entry_set_wdma(struct mtk_eth *eth, struct mtk_foe_entry *entry, 354 352 int wdma_idx, int txq, int bss, int wcid); 353 + int mtk_foe_entry_set_queue(struct mtk_eth *eth, struct mtk_foe_entry *entry, 354 + unsigned int queue); 355 355 int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); 356 356 void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); 357 357 int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry);
+9 -3
drivers/net/ethernet/mediatek/mtk_ppe_offload.c
··· 188 188 int *wed_index) 189 189 { 190 190 struct mtk_wdma_info info = {}; 191 - int pse_port, dsa_port; 191 + int pse_port, dsa_port, queue; 192 192 193 193 if (mtk_flow_get_wdma_info(dev, dest_mac, &info) == 0) { 194 194 mtk_foe_entry_set_wdma(eth, foe, info.wdma_idx, info.queue, ··· 212 212 } 213 213 214 214 dsa_port = mtk_flow_get_dsa_port(&dev); 215 - if (dsa_port >= 0) 216 - mtk_foe_entry_set_dsa(eth, foe, dsa_port); 217 215 218 216 if (dev == eth->netdev[0]) 219 217 pse_port = 1; ··· 219 221 pse_port = 2; 220 222 else 221 223 return -EOPNOTSUPP; 224 + 225 + if (dsa_port >= 0) { 226 + mtk_foe_entry_set_dsa(eth, foe, dsa_port); 227 + queue = 3 + dsa_port; 228 + } else { 229 + queue = pse_port - 1; 230 + } 231 + mtk_foe_entry_set_queue(eth, foe, queue); 222 232 223 233 out: 224 234 mtk_foe_entry_set_pse_port(eth, foe, pse_port);