610-v5.13-31-net-ethernet-mtk_eth_soc-fix-parsing-packets-in-GDM.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From: Felix Fietkau <[email protected]>
  2. Date: Wed, 24 Mar 2021 02:30:52 +0100
  3. Subject: [PATCH] net: ethernet: mtk_eth_soc: fix parsing packets in GDM
  4. When using DSA, set the special tag in GDM ingress control to allow the MAC
  5. to parse packets properly earlier. This affects rx DMA source port reporting.
  6. Signed-off-by: Felix Fietkau <[email protected]>
  7. Signed-off-by: Pablo Neira Ayuso <[email protected]>
  8. ---
  9. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  10. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  11. @@ -19,6 +19,7 @@
  12. #include <linux/interrupt.h>
  13. #include <linux/pinctrl/devinfo.h>
  14. #include <linux/phylink.h>
  15. +#include <net/dsa.h>
  16. #include "mtk_eth_soc.h"
  17. @@ -1264,13 +1265,12 @@ static int mtk_poll_rx(struct napi_struc
  18. break;
  19. /* find out which mac the packet come from. values start at 1 */
  20. - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
  21. + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628) ||
  22. + (trxd.rxd4 & RX_DMA_SPECIAL_TAG))
  23. mac = 0;
  24. - } else {
  25. - mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
  26. - RX_DMA_FPORT_MASK;
  27. - mac--;
  28. - }
  29. + else
  30. + mac = ((trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
  31. + RX_DMA_FPORT_MASK) - 1;
  32. if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
  33. !eth->netdev[mac]))
  34. @@ -2233,6 +2233,9 @@ static void mtk_gdm_config(struct mtk_et
  35. val |= config;
  36. + if (!i && eth->netdev[0] && netdev_uses_dsa(eth->netdev[0]))
  37. + val |= MTK_GDMA_SPECIAL_TAG;
  38. +
  39. mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i));
  40. }
  41. /* Reset and enable PSE */
  42. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
  43. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
  44. @@ -81,6 +81,7 @@
  45. /* GDM Exgress Control Register */
  46. #define MTK_GDMA_FWD_CFG(x) (0x500 + (x * 0x1000))
  47. +#define MTK_GDMA_SPECIAL_TAG BIT(24)
  48. #define MTK_GDMA_ICS_EN BIT(22)
  49. #define MTK_GDMA_TCS_EN BIT(21)
  50. #define MTK_GDMA_UCS_EN BIT(20)
  51. @@ -305,6 +306,7 @@
  52. #define RX_DMA_L4_VALID_PDMA BIT(30) /* when PDMA is used */
  53. #define RX_DMA_FPORT_SHIFT 19
  54. #define RX_DMA_FPORT_MASK 0x7
  55. +#define RX_DMA_SPECIAL_TAG BIT(22)
  56. /* PHY Indirect Access Control registers */
  57. #define MTK_PHY_IAC 0x10004