bb36302f24e3dfd7fa789d88ccb80fb9b6c33ae5
[openwrt/staging/linusw.git] /
1 From ad2606f6fafae3a7d41c4f2af5554c8f6adecbc7 Mon Sep 17 00:00:00 2001
2 From: Frank Wunderlich <frank-w@public-files.de>
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
7 Replace last occurences of hardcoded cpu-port by cpu_dp member of
8 dsa_port struct.
9
10 Now the constant can be dropped.
11
12 Suggested-by: Vladimir Oltean <olteanv@gmail.com>
13 Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
14 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
15 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
16 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
17 ---
18 drivers/net/dsa/mt7530.c | 27 ++++++++++++++++++++-------
19 drivers/net/dsa/mt7530.h | 1 -
20 2 files changed, 20 insertions(+), 8 deletions(-)
21
22 --- a/drivers/net/dsa/mt7530.c
23 +++ b/drivers/net/dsa/mt7530.c
24 @@ -1254,6 +1254,7 @@ static int
25 mt7530_port_enable(struct dsa_switch *ds, int port,
26 struct phy_device *phy)
27 {
28 + struct dsa_port *dp = dsa_to_port(ds, port);
29 struct mt7530_priv *priv = ds->priv;
30
31 mutex_lock(&priv->reg_mutex);
32 @@ -1262,7 +1263,11 @@ mt7530_port_enable(struct dsa_switch *ds
33 * restore the port matrix if the port is the member of a certain
34 * bridge.
35 */
36 - priv->ports[port].pm |= PCR_MATRIX(BIT(MT7530_CPU_PORT));
37 + if (dsa_port_is_user(dp)) {
38 + struct dsa_port *cpu_dp = dp->cpu_dp;
39 +
40 + priv->ports[port].pm |= PCR_MATRIX(BIT(cpu_dp->index));
41 + }
42 priv->ports[port].enable = true;
43 mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
44 priv->ports[port].pm);
45 @@ -1410,7 +1415,8 @@ mt7530_port_bridge_join(struct dsa_switc
46 struct net_device *bridge)
47 {
48 struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
49 - u32 port_bitmap = BIT(MT7530_CPU_PORT);
50 + struct dsa_port *cpu_dp = dp->cpu_dp;
51 + u32 port_bitmap = BIT(cpu_dp->index);
52 struct mt7530_priv *priv = ds->priv;
53
54 mutex_lock(&priv->reg_mutex);
55 @@ -1487,9 +1493,12 @@ mt7530_port_set_vlan_unaware(struct dsa_
56 * the CPU port get out of VLAN filtering mode.
57 */
58 if (all_user_ports_removed) {
59 - mt7530_write(priv, MT7530_PCR_P(MT7530_CPU_PORT),
60 + struct dsa_port *dp = dsa_to_port(ds, port);
61 + struct dsa_port *cpu_dp = dp->cpu_dp;
62 +
63 + mt7530_write(priv, MT7530_PCR_P(cpu_dp->index),
64 PCR_MATRIX(dsa_user_ports(priv->ds)));
65 - mt7530_write(priv, MT7530_PVC_P(MT7530_CPU_PORT), PORT_SPEC_TAG
66 + mt7530_write(priv, MT7530_PVC_P(cpu_dp->index), PORT_SPEC_TAG
67 | PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
68 }
69 }
70 @@ -1539,6 +1548,7 @@ mt7530_port_bridge_leave(struct dsa_swit
71 struct net_device *bridge)
72 {
73 struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
74 + struct dsa_port *cpu_dp = dp->cpu_dp;
75 struct mt7530_priv *priv = ds->priv;
76
77 mutex_lock(&priv->reg_mutex);
78 @@ -1567,8 +1577,8 @@ mt7530_port_bridge_leave(struct dsa_swit
79 */
80 if (priv->ports[port].enable)
81 mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
82 - PCR_MATRIX(BIT(MT7530_CPU_PORT)));
83 - priv->ports[port].pm = PCR_MATRIX(BIT(MT7530_CPU_PORT));
84 + PCR_MATRIX(BIT(cpu_dp->index)));
85 + priv->ports[port].pm = PCR_MATRIX(BIT(cpu_dp->index));
86
87 /* When a port is removed from the bridge, the port would be set up
88 * back to the default as is at initial boot which is a VLAN-unaware
89 @@ -1731,6 +1741,9 @@ static int
90 mt7530_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
91 struct netlink_ext_ack *extack)
92 {
93 + struct dsa_port *dp = dsa_to_port(ds, port);
94 + struct dsa_port *cpu_dp = dp->cpu_dp;
95 +
96 if (vlan_filtering) {
97 /* The port is being kept as VLAN-unaware port when bridge is
98 * set up with vlan_filtering not being set, Otherwise, the
99 @@ -1738,7 +1751,7 @@ mt7530_port_vlan_filtering(struct dsa_sw
100 * for becoming a VLAN-aware port.
101 */
102 mt7530_port_set_vlan_aware(ds, port);
103 - mt7530_port_set_vlan_aware(ds, MT7530_CPU_PORT);
104 + mt7530_port_set_vlan_aware(ds, cpu_dp->index);
105 } else {
106 mt7530_port_set_vlan_unaware(ds, port);
107 }
108 --- a/drivers/net/dsa/mt7530.h
109 +++ b/drivers/net/dsa/mt7530.h
110 @@ -8,7 +8,6 @@
111
112 #define MT7530_NUM_PORTS 7
113 #define MT7530_NUM_PHYS 5
114 -#define MT7530_CPU_PORT 6
115 #define MT7530_NUM_FDB_RECORDS 2048
116 #define MT7530_ALL_MEMBERS 0xff
117