701-net-0256-net-mscc-ocelot-create-a-helper-for-changing-the-por.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From e870793b277eeaf3c455971d9610f039fd9ab160 Mon Sep 17 00:00:00 2001
  2. From: Vladimir Oltean <[email protected]>
  3. Date: Thu, 14 Nov 2019 17:03:23 +0200
  4. Subject: [PATCH] net: mscc: ocelot: create a helper for changing the port MTU
  5. Since in an NPI/DSA setup, not all ports will have the same MTU, we need
  6. to make sure the watermarks for pause frames and/or tail dropping logic
  7. that existed in the driver is still coherent for the new MTU values.
  8. We need to do this because the NPI (aka external CPU) port needs an
  9. increased MTU for the DSA tag. This will be done in a future patch.
  10. Signed-off-by: Vladimir Oltean <[email protected]>
  11. Reviewed-by: Andrew Lunn <[email protected]>
  12. Reviewed-by: Florian Fainelli <[email protected]>
  13. Signed-off-by: David S. Miller <[email protected]>
  14. ---
  15. drivers/net/ethernet/mscc/ocelot.c | 40 ++++++++++++++++++++++----------------
  16. 1 file changed, 23 insertions(+), 17 deletions(-)
  17. --- a/drivers/net/ethernet/mscc/ocelot.c
  18. +++ b/drivers/net/ethernet/mscc/ocelot.c
  19. @@ -2099,11 +2099,32 @@ static int ocelot_init_timestamp(struct
  20. return 0;
  21. }
  22. -static void ocelot_init_port(struct ocelot *ocelot, int port)
  23. +static void ocelot_port_set_mtu(struct ocelot *ocelot, int port, size_t mtu)
  24. {
  25. struct ocelot_port *ocelot_port = ocelot->ports[port];
  26. int atop_wm;
  27. + ocelot_port_writel(ocelot_port, mtu, DEV_MAC_MAXLEN_CFG);
  28. +
  29. + /* Set Pause WM hysteresis
  30. + * 152 = 6 * mtu / OCELOT_BUFFER_CELL_SZ
  31. + * 101 = 4 * mtu / OCELOT_BUFFER_CELL_SZ
  32. + */
  33. + ocelot_write_rix(ocelot, SYS_PAUSE_CFG_PAUSE_ENA |
  34. + SYS_PAUSE_CFG_PAUSE_STOP(101) |
  35. + SYS_PAUSE_CFG_PAUSE_START(152), SYS_PAUSE_CFG, port);
  36. +
  37. + /* Tail dropping watermark */
  38. + atop_wm = (ocelot->shared_queue_sz - 9 * mtu) / OCELOT_BUFFER_CELL_SZ;
  39. + ocelot_write_rix(ocelot, ocelot_wm_enc(9 * mtu),
  40. + SYS_ATOP, port);
  41. + ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
  42. +}
  43. +
  44. +static void ocelot_init_port(struct ocelot *ocelot, int port)
  45. +{
  46. + struct ocelot_port *ocelot_port = ocelot->ports[port];
  47. +
  48. INIT_LIST_HEAD(&ocelot_port->skbs);
  49. /* Basic L2 initialization */
  50. @@ -2124,8 +2145,7 @@ static void ocelot_init_port(struct ocel
  51. DEV_MAC_HDX_CFG);
  52. /* Set Max Length and maximum tags allowed */
  53. - ocelot_port_writel(ocelot_port, VLAN_ETH_FRAME_LEN,
  54. - DEV_MAC_MAXLEN_CFG);
  55. + ocelot_port_set_mtu(ocelot, port, VLAN_ETH_FRAME_LEN);
  56. ocelot_port_writel(ocelot_port, DEV_MAC_TAGS_CFG_TAG_ID(ETH_P_8021AD) |
  57. DEV_MAC_TAGS_CFG_VLAN_AWR_ENA |
  58. DEV_MAC_TAGS_CFG_VLAN_LEN_AWR_ENA,
  59. @@ -2135,20 +2155,6 @@ static void ocelot_init_port(struct ocel
  60. ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_HIGH_CFG);
  61. ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_LOW_CFG);
  62. - /* Set Pause WM hysteresis
  63. - * 152 = 6 * VLAN_ETH_FRAME_LEN / OCELOT_BUFFER_CELL_SZ
  64. - * 101 = 4 * VLAN_ETH_FRAME_LEN / OCELOT_BUFFER_CELL_SZ
  65. - */
  66. - ocelot_write_rix(ocelot, SYS_PAUSE_CFG_PAUSE_ENA |
  67. - SYS_PAUSE_CFG_PAUSE_STOP(101) |
  68. - SYS_PAUSE_CFG_PAUSE_START(152), SYS_PAUSE_CFG, port);
  69. -
  70. - /* Tail dropping watermark */
  71. - atop_wm = (ocelot->shared_queue_sz - 9 * VLAN_ETH_FRAME_LEN) / OCELOT_BUFFER_CELL_SZ;
  72. - ocelot_write_rix(ocelot, ocelot_wm_enc(9 * VLAN_ETH_FRAME_LEN),
  73. - SYS_ATOP, port);
  74. - ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
  75. -
  76. /* Drop frames with multicast source address */
  77. ocelot_rmw_gix(ocelot, ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
  78. ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,