730-06-v6.3-net-ethernet-mediatek-ppe-assign-per-port-queues-for.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From: Felix Fietkau <[email protected]>
  2. Date: Thu, 3 Nov 2022 17:49:44 +0100
  3. Subject: [PATCH] net: ethernet: mediatek: ppe: assign per-port queues
  4. for offloaded traffic
  5. Keeps traffic sent to the switch within link speed limits
  6. Signed-off-by: Felix Fietkau <[email protected]>
  7. ---
  8. --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
  9. +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
  10. @@ -405,6 +405,24 @@ static inline bool mtk_foe_entry_usable(
  11. FIELD_GET(MTK_FOE_IB1_STATE, entry->ib1) != MTK_FOE_STATE_BIND;
  12. }
  13. +int mtk_foe_entry_set_queue(struct mtk_eth *eth, struct mtk_foe_entry *entry,
  14. + unsigned int queue)
  15. +{
  16. + u32 *ib2 = mtk_foe_entry_ib2(eth, entry);
  17. +
  18. + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
  19. + *ib2 &= ~MTK_FOE_IB2_QID_V2;
  20. + *ib2 |= FIELD_PREP(MTK_FOE_IB2_QID_V2, queue);
  21. + *ib2 |= MTK_FOE_IB2_PSE_QOS_V2;
  22. + } else {
  23. + *ib2 &= ~MTK_FOE_IB2_QID;
  24. + *ib2 |= FIELD_PREP(MTK_FOE_IB2_QID, queue);
  25. + *ib2 |= MTK_FOE_IB2_PSE_QOS;
  26. + }
  27. +
  28. + return 0;
  29. +}
  30. +
  31. static bool
  32. mtk_flow_entry_match(struct mtk_eth *eth, struct mtk_flow_entry *entry,
  33. struct mtk_foe_entry *data)
  34. --- a/drivers/net/ethernet/mediatek/mtk_ppe.h
  35. +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
  36. @@ -68,7 +68,9 @@ enum {
  37. #define MTK_FOE_IB2_DSCP GENMASK(31, 24)
  38. /* CONFIG_MEDIATEK_NETSYS_V2 */
  39. +#define MTK_FOE_IB2_QID_V2 GENMASK(6, 0)
  40. #define MTK_FOE_IB2_PORT_MG_V2 BIT(7)
  41. +#define MTK_FOE_IB2_PSE_QOS_V2 BIT(8)
  42. #define MTK_FOE_IB2_DEST_PORT_V2 GENMASK(12, 9)
  43. #define MTK_FOE_IB2_MULTICAST_V2 BIT(13)
  44. #define MTK_FOE_IB2_WDMA_WINFO_V2 BIT(19)
  45. @@ -352,6 +354,8 @@ int mtk_foe_entry_set_pppoe(struct mtk_e
  46. int sid);
  47. int mtk_foe_entry_set_wdma(struct mtk_eth *eth, struct mtk_foe_entry *entry,
  48. int wdma_idx, int txq, int bss, int wcid);
  49. +int mtk_foe_entry_set_queue(struct mtk_eth *eth, struct mtk_foe_entry *entry,
  50. + unsigned int queue);
  51. int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry);
  52. void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry);
  53. int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry);
  54. --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
  55. +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
  56. @@ -188,7 +188,7 @@ mtk_flow_set_output_device(struct mtk_et
  57. int *wed_index)
  58. {
  59. struct mtk_wdma_info info = {};
  60. - int pse_port, dsa_port;
  61. + int pse_port, dsa_port, queue;
  62. if (mtk_flow_get_wdma_info(dev, dest_mac, &info) == 0) {
  63. mtk_foe_entry_set_wdma(eth, foe, info.wdma_idx, info.queue,
  64. @@ -212,8 +212,6 @@ mtk_flow_set_output_device(struct mtk_et
  65. }
  66. dsa_port = mtk_flow_get_dsa_port(&dev);
  67. - if (dsa_port >= 0)
  68. - mtk_foe_entry_set_dsa(eth, foe, dsa_port);
  69. if (dev == eth->netdev[0])
  70. pse_port = 1;
  71. @@ -222,6 +220,14 @@ mtk_flow_set_output_device(struct mtk_et
  72. else
  73. return -EOPNOTSUPP;
  74. + if (dsa_port >= 0) {
  75. + mtk_foe_entry_set_dsa(eth, foe, dsa_port);
  76. + queue = 3 + dsa_port;
  77. + } else {
  78. + queue = pse_port - 1;
  79. + }
  80. + mtk_foe_entry_set_queue(eth, foe, queue);
  81. +
  82. out:
  83. mtk_foe_entry_set_pse_port(eth, foe, pse_port);