42715ef97f1245188ab5b13072c1daa0d7a859c1
[openwrt/staging/xback.git] /
1 From 5e5401d6612ef599ad45785b941eebda7effc90f Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Thu, 4 Jan 2024 09:47:36 +0000
4 Subject: [PATCH] net: phylink: move phylink_pcs_neg_mode() into phylink.c
5
6 Move phylink_pcs_neg_mode() from the header file into the .c file since
7 nothing should be using it.
8
9 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
10 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13 drivers/net/phy/phylink.c | 66 +++++++++++++++++++++++++++++++++++++++
14 include/linux/phylink.h | 66 ---------------------------------------
15 2 files changed, 66 insertions(+), 66 deletions(-)
16
17 --- a/drivers/net/phy/phylink.c
18 +++ b/drivers/net/phy/phylink.c
19 @@ -1116,6 +1116,72 @@ static void phylink_pcs_an_restart(struc
20 pl->pcs->ops->pcs_an_restart(pl->pcs);
21 }
22
23 +/**
24 + * phylink_pcs_neg_mode() - helper to determine PCS inband mode
25 + * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
26 + * @interface: interface mode to be used
27 + * @advertising: adertisement ethtool link mode mask
28 + *
29 + * Determines the negotiation mode to be used by the PCS, and returns
30 + * one of:
31 + *
32 + * - %PHYLINK_PCS_NEG_NONE: interface mode does not support inband
33 + * - %PHYLINK_PCS_NEG_OUTBAND: an out of band mode (e.g. reading the PHY)
34 + * will be used.
35 + * - %PHYLINK_PCS_NEG_INBAND_DISABLED: inband mode selected but autoneg
36 + * disabled
37 + * - %PHYLINK_PCS_NEG_INBAND_ENABLED: inband mode selected and autoneg enabled
38 + *
39 + * Note: this is for cases where the PCS itself is involved in negotiation
40 + * (e.g. Clause 37, SGMII and similar) not Clause 73.
41 + */
42 +static unsigned int phylink_pcs_neg_mode(unsigned int mode,
43 + phy_interface_t interface,
44 + const unsigned long *advertising)
45 +{
46 + unsigned int neg_mode;
47 +
48 + switch (interface) {
49 + case PHY_INTERFACE_MODE_SGMII:
50 + case PHY_INTERFACE_MODE_QSGMII:
51 + case PHY_INTERFACE_MODE_QUSGMII:
52 + case PHY_INTERFACE_MODE_USXGMII:
53 + /* These protocols are designed for use with a PHY which
54 + * communicates its negotiation result back to the MAC via
55 + * inband communication. Note: there exist PHYs that run
56 + * with SGMII but do not send the inband data.
57 + */
58 + if (!phylink_autoneg_inband(mode))
59 + neg_mode = PHYLINK_PCS_NEG_OUTBAND;
60 + else
61 + neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
62 + break;
63 +
64 + case PHY_INTERFACE_MODE_1000BASEX:
65 + case PHY_INTERFACE_MODE_2500BASEX:
66 + /* 1000base-X is designed for use media-side for Fibre
67 + * connections, and thus the Autoneg bit needs to be
68 + * taken into account. We also do this for 2500base-X
69 + * as well, but drivers may not support this, so may
70 + * need to override this.
71 + */
72 + if (!phylink_autoneg_inband(mode))
73 + neg_mode = PHYLINK_PCS_NEG_OUTBAND;
74 + else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
75 + advertising))
76 + neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
77 + else
78 + neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED;
79 + break;
80 +
81 + default:
82 + neg_mode = PHYLINK_PCS_NEG_NONE;
83 + break;
84 + }
85 +
86 + return neg_mode;
87 +}
88 +
89 static void phylink_major_config(struct phylink *pl, bool restart,
90 const struct phylink_link_state *state)
91 {
92 --- a/include/linux/phylink.h
93 +++ b/include/linux/phylink.h
94 @@ -99,72 +99,6 @@ static inline bool phylink_autoneg_inban
95 }
96
97 /**
98 - * phylink_pcs_neg_mode() - helper to determine PCS inband mode
99 - * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
100 - * @interface: interface mode to be used
101 - * @advertising: adertisement ethtool link mode mask
102 - *
103 - * Determines the negotiation mode to be used by the PCS, and returns
104 - * one of:
105 - *
106 - * - %PHYLINK_PCS_NEG_NONE: interface mode does not support inband
107 - * - %PHYLINK_PCS_NEG_OUTBAND: an out of band mode (e.g. reading the PHY)
108 - * will be used.
109 - * - %PHYLINK_PCS_NEG_INBAND_DISABLED: inband mode selected but autoneg
110 - * disabled
111 - * - %PHYLINK_PCS_NEG_INBAND_ENABLED: inband mode selected and autoneg enabled
112 - *
113 - * Note: this is for cases where the PCS itself is involved in negotiation
114 - * (e.g. Clause 37, SGMII and similar) not Clause 73.
115 - */
116 -static inline unsigned int phylink_pcs_neg_mode(unsigned int mode,
117 - phy_interface_t interface,
118 - const unsigned long *advertising)
119 -{
120 - unsigned int neg_mode;
121 -
122 - switch (interface) {
123 - case PHY_INTERFACE_MODE_SGMII:
124 - case PHY_INTERFACE_MODE_QSGMII:
125 - case PHY_INTERFACE_MODE_QUSGMII:
126 - case PHY_INTERFACE_MODE_USXGMII:
127 - /* These protocols are designed for use with a PHY which
128 - * communicates its negotiation result back to the MAC via
129 - * inband communication. Note: there exist PHYs that run
130 - * with SGMII but do not send the inband data.
131 - */
132 - if (!phylink_autoneg_inband(mode))
133 - neg_mode = PHYLINK_PCS_NEG_OUTBAND;
134 - else
135 - neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
136 - break;
137 -
138 - case PHY_INTERFACE_MODE_1000BASEX:
139 - case PHY_INTERFACE_MODE_2500BASEX:
140 - /* 1000base-X is designed for use media-side for Fibre
141 - * connections, and thus the Autoneg bit needs to be
142 - * taken into account. We also do this for 2500base-X
143 - * as well, but drivers may not support this, so may
144 - * need to override this.
145 - */
146 - if (!phylink_autoneg_inband(mode))
147 - neg_mode = PHYLINK_PCS_NEG_OUTBAND;
148 - else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
149 - advertising))
150 - neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
151 - else
152 - neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED;
153 - break;
154 -
155 - default:
156 - neg_mode = PHYLINK_PCS_NEG_NONE;
157 - break;
158 - }
159 -
160 - return neg_mode;
161 -}
162 -
163 -/**
164 * struct phylink_link_state - link state structure
165 * @advertising: ethtool bitmask containing advertised link modes
166 * @lp_advertising: ethtool bitmask containing link partner advertised link