2150a4a341447cebc6a80dce759fbb5f48aec63e
[openwrt/staging/xback.git] /
1 From 17ed1911f9c8d4f9af8e13b2c95103ee06dadc0f Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Tue, 3 Dec 2024 15:30:47 +0000
4 Subject: [PATCH 01/13] net: phylink: pass phylink and pcs into
5 phylink_pcs_neg_mode()
6
7 Move the call to phylink_pcs_neg_mode() in phylink_major_config() after
8 we have selected the appropriate PCS to allow the PCS to be passed in.
9
10 Add struct phylink and struct phylink_pcs pointers to
11 phylink_pcs_neg_mode() and pass in the appropriate structures. Set
12 pl->pcs_neg_mode before returning, and remove the return value.
13
14 This will allow the capabilities of the PCS and any PHY to be used when
15 deciding which pcs_neg_mode should be used.
16
17 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
18 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
19 Link: https://patch.msgid.link/E1tIUrP-006ITh-6u@rmk-PC.armlinux.org.uk
20 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
21 ---
22 drivers/net/phy/phylink.c | 26 +++++++++++++-------------
23 1 file changed, 13 insertions(+), 13 deletions(-)
24
25 --- a/drivers/net/phy/phylink.c
26 +++ b/drivers/net/phy/phylink.c
27 @@ -1118,7 +1118,8 @@ static void phylink_pcs_an_restart(struc
28
29 /**
30 * phylink_pcs_neg_mode() - helper to determine PCS inband mode
31 - * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
32 + * @pl: a pointer to a &struct phylink returned from phylink_create()
33 + * @pcs: a pointer to &struct phylink_pcs
34 * @interface: interface mode to be used
35 * @advertising: adertisement ethtool link mode mask
36 *
37 @@ -1135,11 +1136,13 @@ static void phylink_pcs_an_restart(struc
38 * Note: this is for cases where the PCS itself is involved in negotiation
39 * (e.g. Clause 37, SGMII and similar) not Clause 73.
40 */
41 -static unsigned int phylink_pcs_neg_mode(unsigned int mode,
42 - phy_interface_t interface,
43 - const unsigned long *advertising)
44 +static void phylink_pcs_neg_mode(struct phylink *pl, struct phylink_pcs *pcs,
45 + phy_interface_t interface,
46 + const unsigned long *advertising)
47 {
48 - unsigned int neg_mode;
49 + unsigned int neg_mode, mode;
50 +
51 + mode = pl->cur_link_an_mode;
52
53 switch (interface) {
54 case PHY_INTERFACE_MODE_SGMII:
55 @@ -1179,7 +1182,7 @@ static unsigned int phylink_pcs_neg_mode
56 break;
57 }
58
59 - return neg_mode;
60 + pl->pcs_neg_mode = neg_mode;
61 }
62
63 static void phylink_major_config(struct phylink *pl, bool restart,
64 @@ -1193,10 +1196,6 @@ static void phylink_major_config(struct
65
66 phylink_dbg(pl, "major config %s\n", phy_modes(state->interface));
67
68 - pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode,
69 - state->interface,
70 - state->advertising);
71 -
72 if (pl->using_mac_select_pcs) {
73 pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface);
74 if (IS_ERR(pcs)) {
75 @@ -1209,6 +1208,8 @@ static void phylink_major_config(struct
76 pcs_changed = pcs && pl->pcs != pcs;
77 }
78
79 + phylink_pcs_neg_mode(pl, pcs, state->interface, state->advertising);
80 +
81 phylink_pcs_poll_stop(pl);
82
83 if (pl->mac_ops->mac_prepare) {
84 @@ -1299,9 +1300,8 @@ static int phylink_change_inband_advert(
85 pl->link_config.pause);
86
87 /* Recompute the PCS neg mode */
88 - pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode,
89 - pl->link_config.interface,
90 - pl->link_config.advertising);
91 + phylink_pcs_neg_mode(pl, pl->pcs, pl->link_config.interface,
92 + pl->link_config.advertising);
93
94 neg_mode = pl->cur_link_an_mode;
95 if (pl->pcs->neg_mode)