generic: 6.1, 6.6: mt7530: import accepted patches
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 765-v6.10-net-dsa-introduce-dsa_phylink_to_port.patch
1 From f13b2b33c7674fa0988dfaa9adb95d7d912b489f Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Wed, 10 Apr 2024 20:42:38 +0100
4 Subject: [PATCH 1/2] net: dsa: introduce dsa_phylink_to_port()
5
6 We convert from a phylink_config struct to a dsa_port struct in many
7 places, let's provide a helper for this.
8
9 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
10 Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
11 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
12 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
13 Link: https://lore.kernel.org/r/E1rudqA-006K9B-85@rmk-PC.armlinux.org.uk
14 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 ---
16 include/net/dsa.h | 6 ++++++
17 net/dsa/port.c | 12 ++++++------
18 2 files changed, 12 insertions(+), 6 deletions(-)
19
20 --- a/include/net/dsa.h
21 +++ b/include/net/dsa.h
22 @@ -337,6 +337,12 @@ struct dsa_port {
23 struct list_head vlans;
24 };
25
26 +static inline struct dsa_port *
27 +dsa_phylink_to_port(struct phylink_config *config)
28 +{
29 + return container_of(config, struct dsa_port, pl_config);
30 +}
31 +
32 /* TODO: ideally DSA ports would have a single dp->link_dp member,
33 * and no dst->rtable nor this struct dsa_link would be needed,
34 * but this would require some more complex tree walking,
35 --- a/net/dsa/port.c
36 +++ b/net/dsa/port.c
37 @@ -1552,7 +1552,7 @@ static void dsa_port_phylink_validate(st
38 unsigned long *supported,
39 struct phylink_link_state *state)
40 {
41 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
42 + struct dsa_port *dp = dsa_phylink_to_port(config);
43 struct dsa_switch *ds = dp->ds;
44
45 if (!ds->ops->phylink_validate) {
46 @@ -1567,7 +1567,7 @@ static void dsa_port_phylink_validate(st
47 static void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config,
48 struct phylink_link_state *state)
49 {
50 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
51 + struct dsa_port *dp = dsa_phylink_to_port(config);
52 struct dsa_switch *ds = dp->ds;
53 int err;
54
55 @@ -1589,7 +1589,7 @@ static struct phylink_pcs *
56 dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
57 phy_interface_t interface)
58 {
59 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
60 + struct dsa_port *dp = dsa_phylink_to_port(config);
61 struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
62 struct dsa_switch *ds = dp->ds;
63
64 @@ -1603,7 +1603,7 @@ static void dsa_port_phylink_mac_config(
65 unsigned int mode,
66 const struct phylink_link_state *state)
67 {
68 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
69 + struct dsa_port *dp = dsa_phylink_to_port(config);
70 struct dsa_switch *ds = dp->ds;
71
72 if (!ds->ops->phylink_mac_config)
73 @@ -1614,7 +1614,7 @@ static void dsa_port_phylink_mac_config(
74
75 static void dsa_port_phylink_mac_an_restart(struct phylink_config *config)
76 {
77 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
78 + struct dsa_port *dp = dsa_phylink_to_port(config);
79 struct dsa_switch *ds = dp->ds;
80
81 if (!ds->ops->phylink_mac_an_restart)
82 @@ -1627,7 +1627,7 @@ static void dsa_port_phylink_mac_link_do
83 unsigned int mode,
84 phy_interface_t interface)
85 {
86 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
87 + struct dsa_port *dp = dsa_phylink_to_port(config);
88 struct phy_device *phydev = NULL;
89 struct dsa_switch *ds = dp->ds;
90
91 @@ -1650,7 +1650,7 @@ static void dsa_port_phylink_mac_link_up
92 int speed, int duplex,
93 bool tx_pause, bool rx_pause)
94 {
95 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
96 + struct dsa_port *dp = dsa_phylink_to_port(config);
97 struct dsa_switch *ds = dp->ds;
98
99 if (!ds->ops->phylink_mac_link_up) {