705-13-v6.0-net-dsa-mt7530-get-cpu-port-via-dp-cpu_dp-instead-of.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. From ad2606f6fafae3a7d41c4f2af5554c8f6adecbc7 Mon Sep 17 00:00:00 2001
  2. From: Frank Wunderlich <[email protected]>
  3. Date: Fri, 10 Jun 2022 19:05:39 +0200
  4. Subject: [PATCH 13/13] net: dsa: mt7530: get cpu-port via dp->cpu_dp instead
  5. of constant
  6. Replace last occurences of hardcoded cpu-port by cpu_dp member of
  7. dsa_port struct.
  8. Now the constant can be dropped.
  9. Suggested-by: Vladimir Oltean <[email protected]>
  10. Signed-off-by: Frank Wunderlich <[email protected]>
  11. Reviewed-by: Vladimir Oltean <[email protected]>
  12. Reviewed-by: Florian Fainelli <[email protected]>
  13. Signed-off-by: Jakub Kicinski <[email protected]>
  14. ---
  15. drivers/net/dsa/mt7530.c | 27 ++++++++++++++++++++-------
  16. drivers/net/dsa/mt7530.h | 1 -
  17. 2 files changed, 20 insertions(+), 8 deletions(-)
  18. --- a/drivers/net/dsa/mt7530.c
  19. +++ b/drivers/net/dsa/mt7530.c
  20. @@ -1093,6 +1093,7 @@ static int
  21. mt7530_port_enable(struct dsa_switch *ds, int port,
  22. struct phy_device *phy)
  23. {
  24. + struct dsa_port *dp = dsa_to_port(ds, port);
  25. struct mt7530_priv *priv = ds->priv;
  26. mutex_lock(&priv->reg_mutex);
  27. @@ -1101,7 +1102,11 @@ mt7530_port_enable(struct dsa_switch *ds
  28. * restore the port matrix if the port is the member of a certain
  29. * bridge.
  30. */
  31. - priv->ports[port].pm |= PCR_MATRIX(BIT(MT7530_CPU_PORT));
  32. + if (dsa_port_is_user(dp)) {
  33. + struct dsa_port *cpu_dp = dp->cpu_dp;
  34. +
  35. + priv->ports[port].pm |= PCR_MATRIX(BIT(cpu_dp->index));
  36. + }
  37. priv->ports[port].enable = true;
  38. mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
  39. priv->ports[port].pm);
  40. @@ -1249,7 +1254,8 @@ mt7530_port_bridge_join(struct dsa_switc
  41. struct net_device *bridge)
  42. {
  43. struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
  44. - u32 port_bitmap = BIT(MT7530_CPU_PORT);
  45. + struct dsa_port *cpu_dp = dp->cpu_dp;
  46. + u32 port_bitmap = BIT(cpu_dp->index);
  47. struct mt7530_priv *priv = ds->priv;
  48. mutex_lock(&priv->reg_mutex);
  49. @@ -1326,9 +1332,12 @@ mt7530_port_set_vlan_unaware(struct dsa_
  50. * the CPU port get out of VLAN filtering mode.
  51. */
  52. if (all_user_ports_removed) {
  53. - mt7530_write(priv, MT7530_PCR_P(MT7530_CPU_PORT),
  54. + struct dsa_port *dp = dsa_to_port(ds, port);
  55. + struct dsa_port *cpu_dp = dp->cpu_dp;
  56. +
  57. + mt7530_write(priv, MT7530_PCR_P(cpu_dp->index),
  58. PCR_MATRIX(dsa_user_ports(priv->ds)));
  59. - mt7530_write(priv, MT7530_PVC_P(MT7530_CPU_PORT), PORT_SPEC_TAG
  60. + mt7530_write(priv, MT7530_PVC_P(cpu_dp->index), PORT_SPEC_TAG
  61. | PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
  62. }
  63. }
  64. @@ -1378,6 +1387,7 @@ mt7530_port_bridge_leave(struct dsa_swit
  65. struct net_device *bridge)
  66. {
  67. struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
  68. + struct dsa_port *cpu_dp = dp->cpu_dp;
  69. struct mt7530_priv *priv = ds->priv;
  70. mutex_lock(&priv->reg_mutex);
  71. @@ -1406,8 +1416,8 @@ mt7530_port_bridge_leave(struct dsa_swit
  72. */
  73. if (priv->ports[port].enable)
  74. mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
  75. - PCR_MATRIX(BIT(MT7530_CPU_PORT)));
  76. - priv->ports[port].pm = PCR_MATRIX(BIT(MT7530_CPU_PORT));
  77. + PCR_MATRIX(BIT(cpu_dp->index)));
  78. + priv->ports[port].pm = PCR_MATRIX(BIT(cpu_dp->index));
  79. /* When a port is removed from the bridge, the port would be set up
  80. * back to the default as is at initial boot which is a VLAN-unaware
  81. @@ -1570,6 +1580,9 @@ static int
  82. mt7530_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
  83. struct netlink_ext_ack *extack)
  84. {
  85. + struct dsa_port *dp = dsa_to_port(ds, port);
  86. + struct dsa_port *cpu_dp = dp->cpu_dp;
  87. +
  88. if (vlan_filtering) {
  89. /* The port is being kept as VLAN-unaware port when bridge is
  90. * set up with vlan_filtering not being set, Otherwise, the
  91. @@ -1577,7 +1590,7 @@ mt7530_port_vlan_filtering(struct dsa_sw
  92. * for becoming a VLAN-aware port.
  93. */
  94. mt7530_port_set_vlan_aware(ds, port);
  95. - mt7530_port_set_vlan_aware(ds, MT7530_CPU_PORT);
  96. + mt7530_port_set_vlan_aware(ds, cpu_dp->index);
  97. } else {
  98. mt7530_port_set_vlan_unaware(ds, port);
  99. }
  100. --- a/drivers/net/dsa/mt7530.h
  101. +++ b/drivers/net/dsa/mt7530.h
  102. @@ -8,7 +8,6 @@
  103. #define MT7530_NUM_PORTS 7
  104. #define MT7530_NUM_PHYS 5
  105. -#define MT7530_CPU_PORT 6
  106. #define MT7530_NUM_FDB_RECORDS 2048
  107. #define MT7530_ALL_MEMBERS 0xff