Commit | Line | Data |
---|---|---|
9525ae83 RK |
1 | #ifndef NETDEV_PCS_H |
2 | #define NETDEV_PCS_H | |
3 | ||
4 | #include <linux/phy.h> | |
5 | #include <linux/spinlock.h> | |
6 | #include <linux/workqueue.h> | |
7 | ||
8 | struct device_node; | |
9 | struct ethtool_cmd; | |
8fa7b9b6 | 10 | struct fwnode_handle; |
9525ae83 RK |
11 | struct net_device; |
12 | ||
13 | enum { | |
14 | MLO_PAUSE_NONE, | |
4e5aeb41 RK |
15 | MLO_PAUSE_RX = BIT(0), |
16 | MLO_PAUSE_TX = BIT(1), | |
9525ae83 | 17 | MLO_PAUSE_TXRX_MASK = MLO_PAUSE_TX | MLO_PAUSE_RX, |
4e5aeb41 | 18 | MLO_PAUSE_AN = BIT(2), |
9525ae83 RK |
19 | |
20 | MLO_AN_PHY = 0, /* Conventional PHY */ | |
21 | MLO_AN_FIXED, /* Fixed-link mode */ | |
86a362c4 | 22 | MLO_AN_INBAND, /* In-band protocol */ |
9525ae83 RK |
23 | }; |
24 | ||
25 | static inline bool phylink_autoneg_inband(unsigned int mode) | |
26 | { | |
86a362c4 | 27 | return mode == MLO_AN_INBAND; |
9525ae83 RK |
28 | } |
29 | ||
8796c892 RK |
30 | /** |
31 | * struct phylink_link_state - link state structure | |
32 | * @advertising: ethtool bitmask containing advertised link modes | |
33 | * @lp_advertising: ethtool bitmask containing link partner advertised link | |
34 | * modes | |
35 | * @interface: link &typedef phy_interface_t mode | |
36 | * @speed: link speed, one of the SPEED_* constants. | |
37 | * @duplex: link duplex mode, one of DUPLEX_* constants. | |
38 | * @pause: link pause state, described by MLO_PAUSE_* constants. | |
39 | * @link: true if the link is up. | |
40 | * @an_enabled: true if autonegotiation is enabled/desired. | |
41 | * @an_complete: true if autonegotiation has completed. | |
42 | */ | |
9525ae83 RK |
43 | struct phylink_link_state { |
44 | __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); | |
45 | __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); | |
8796c892 | 46 | phy_interface_t interface; |
9525ae83 RK |
47 | int speed; |
48 | int duplex; | |
49 | int pause; | |
50 | unsigned int link:1; | |
51 | unsigned int an_enabled:1; | |
52 | unsigned int an_complete:1; | |
53 | }; | |
54 | ||
44cc27e4 IC |
55 | enum phylink_op_type { |
56 | PHYLINK_NETDEV = 0, | |
43de6195 | 57 | PHYLINK_DEV, |
44cc27e4 IC |
58 | }; |
59 | ||
60 | /** | |
61 | * struct phylink_config - PHYLINK configuration structure | |
62 | * @dev: a pointer to a struct device associated with the MAC | |
63 | * @type: operation type of PHYLINK instance | |
1511ed0a | 64 | * @pcs_poll: MAC PCS cannot provide link change interrupt |
5d682f5e MCC |
65 | * @poll_fixed_state: if true, starts link_poll, |
66 | * if MAC link is at %MLO_AN_FIXED mode. | |
ab393850 | 67 | * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND |
5d682f5e MCC |
68 | * @get_fixed_state: callback to execute to determine the fixed link state, |
69 | * if MAC link is at %MLO_AN_FIXED mode. | |
44cc27e4 IC |
70 | */ |
71 | struct phylink_config { | |
72 | struct device *dev; | |
73 | enum phylink_op_type type; | |
1511ed0a | 74 | bool pcs_poll; |
5c05c1db | 75 | bool poll_fixed_state; |
ab393850 | 76 | bool ovr_an_inband; |
5c05c1db RK |
77 | void (*get_fixed_state)(struct phylink_config *config, |
78 | struct phylink_link_state *state); | |
38c310eb | 79 | DECLARE_PHY_INTERFACE_MASK(supported_interfaces); |
44cc27e4 IC |
80 | }; |
81 | ||
8796c892 RK |
82 | /** |
83 | * struct phylink_mac_ops - MAC operations structure. | |
84 | * @validate: Validate and update the link configuration. | |
d46b7e4f | 85 | * @mac_pcs_get_state: Read the current link state from the hardware. |
b7ad14c2 | 86 | * @mac_prepare: prepare for a major reconfiguration of the interface. |
8796c892 | 87 | * @mac_config: configure the MAC for the selected mode and state. |
b7ad14c2 | 88 | * @mac_finish: finish a major reconfiguration of the interface. |
8796c892 RK |
89 | * @mac_an_restart: restart 802.3z BaseX autonegotiation. |
90 | * @mac_link_down: take the link down. | |
91 | * @mac_link_up: allow the link to come up. | |
92 | * | |
93 | * The individual methods are described more fully below. | |
94 | */ | |
9525ae83 | 95 | struct phylink_mac_ops { |
44cc27e4 IC |
96 | void (*validate)(struct phylink_config *config, |
97 | unsigned long *supported, | |
9525ae83 | 98 | struct phylink_link_state *state); |
d46b7e4f RK |
99 | void (*mac_pcs_get_state)(struct phylink_config *config, |
100 | struct phylink_link_state *state); | |
b7ad14c2 RK |
101 | int (*mac_prepare)(struct phylink_config *config, unsigned int mode, |
102 | phy_interface_t iface); | |
44cc27e4 | 103 | void (*mac_config)(struct phylink_config *config, unsigned int mode, |
9525ae83 | 104 | const struct phylink_link_state *state); |
b7ad14c2 RK |
105 | int (*mac_finish)(struct phylink_config *config, unsigned int mode, |
106 | phy_interface_t iface); | |
44cc27e4 IC |
107 | void (*mac_an_restart)(struct phylink_config *config); |
108 | void (*mac_link_down)(struct phylink_config *config, unsigned int mode, | |
c6ab3008 | 109 | phy_interface_t interface); |
91a208f2 RK |
110 | void (*mac_link_up)(struct phylink_config *config, |
111 | struct phy_device *phy, unsigned int mode, | |
112 | phy_interface_t interface, int speed, int duplex, | |
113 | bool tx_pause, bool rx_pause); | |
9525ae83 RK |
114 | }; |
115 | ||
8796c892 RK |
116 | #if 0 /* For kernel-doc purposes only. */ |
117 | /** | |
118 | * validate - Validate and update the link configuration | |
44cc27e4 | 119 | * @config: a pointer to a &struct phylink_config. |
8796c892 RK |
120 | * @supported: ethtool bitmask for supported link modes. |
121 | * @state: a pointer to a &struct phylink_link_state. | |
122 | * | |
123 | * Clear bits in the @supported and @state->advertising masks that | |
124 | * are not supportable by the MAC. | |
125 | * | |
126 | * Note that the PHY may be able to transform from one connection | |
127 | * technology to another, so, eg, don't clear 1000BaseX just | |
128 | * because the MAC is unable to BaseX mode. This is more about | |
32e454ef RK |
129 | * clearing unsupported speeds and duplex settings. The port modes |
130 | * should not be cleared; phylink_set_port_modes() will help with this. | |
8796c892 RK |
131 | * |
132 | * If the @state->interface mode is %PHY_INTERFACE_MODE_1000BASEX | |
133 | * or %PHY_INTERFACE_MODE_2500BASEX, select the appropriate mode | |
134 | * based on @state->advertising and/or @state->speed and update | |
32e454ef RK |
135 | * @state->interface accordingly. See phylink_helper_basex_speed(). |
136 | * | |
137 | * When @state->interface is %PHY_INTERFACE_MODE_NA, phylink expects the | |
138 | * MAC driver to return all supported link modes. | |
139 | * | |
140 | * If the @state->interface mode is not supported, then the @supported | |
141 | * mask must be cleared. | |
8796c892 | 142 | */ |
44cc27e4 | 143 | void validate(struct phylink_config *config, unsigned long *supported, |
8796c892 RK |
144 | struct phylink_link_state *state); |
145 | ||
146 | /** | |
d46b7e4f | 147 | * mac_pcs_get_state() - Read the current inband link state from the hardware |
44cc27e4 | 148 | * @config: a pointer to a &struct phylink_config. |
8796c892 RK |
149 | * @state: a pointer to a &struct phylink_link_state. |
150 | * | |
d46b7e4f RK |
151 | * Read the current inband link state from the MAC PCS, reporting the |
152 | * current speed in @state->speed, duplex mode in @state->duplex, pause | |
153 | * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits, | |
154 | * negotiation completion state in @state->an_complete, and link up state | |
155 | * in @state->link. If possible, @state->lp_advertising should also be | |
156 | * populated. | |
8796c892 | 157 | */ |
d46b7e4f RK |
158 | void mac_pcs_get_state(struct phylink_config *config, |
159 | struct phylink_link_state *state); | |
8796c892 | 160 | |
b7ad14c2 RK |
161 | /** |
162 | * mac_prepare() - prepare to change the PHY interface mode | |
163 | * @config: a pointer to a &struct phylink_config. | |
164 | * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. | |
165 | * @iface: interface mode to switch to | |
166 | * | |
167 | * phylink will call this method at the beginning of a full initialisation | |
168 | * of the link, which includes changing the interface mode or at initial | |
169 | * startup time. It may be called for the current mode. The MAC driver | |
170 | * should perform whatever actions are required, e.g. disabling the | |
171 | * Serdes PHY. | |
172 | * | |
173 | * This will be the first call in the sequence: | |
174 | * - mac_prepare() | |
175 | * - mac_config() | |
176 | * - pcs_config() | |
177 | * - possible pcs_an_restart() | |
178 | * - mac_finish() | |
179 | * | |
180 | * Returns zero on success, or negative errno on failure which will be | |
181 | * reported to the kernel log. | |
182 | */ | |
183 | int mac_prepare(struct phylink_config *config, unsigned int mode, | |
184 | phy_interface_t iface); | |
185 | ||
8796c892 RK |
186 | /** |
187 | * mac_config() - configure the MAC for the selected mode and state | |
44cc27e4 | 188 | * @config: a pointer to a &struct phylink_config. |
8796c892 RK |
189 | * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. |
190 | * @state: a pointer to a &struct phylink_link_state. | |
191 | * | |
4add7009 RKAL |
192 | * Note - not all members of @state are valid. In particular, |
193 | * @state->lp_advertising, @state->link, @state->an_complete are never | |
194 | * guaranteed to be correct, and so any mac_config() implementation must | |
195 | * never reference these fields. | |
196 | * | |
91a208f2 RK |
197 | * (this requires a rewrite - please refer to mac_link_up() for situations |
198 | * where the PCS and MAC are not tightly integrated.) | |
199 | * | |
b70486f9 RK |
200 | * In all negotiation modes, as defined by @mode, @state->pause indicates the |
201 | * pause settings which should be applied as follows. If %MLO_PAUSE_AN is not | |
202 | * set, %MLO_PAUSE_TX and %MLO_PAUSE_RX indicate whether the MAC should send | |
203 | * pause frames and/or act on received pause frames respectively. Otherwise, | |
204 | * the results of in-band negotiation/status from the MAC PCS should be used | |
205 | * to control the MAC pause mode settings. | |
206 | * | |
8796c892 RK |
207 | * The action performed depends on the currently selected mode: |
208 | * | |
209 | * %MLO_AN_FIXED, %MLO_AN_PHY: | |
91a208f2 RK |
210 | * Configure for non-inband negotiation mode, where the link settings |
211 | * are completely communicated via mac_link_up(). The physical link | |
212 | * protocol from the MAC is specified by @state->interface. | |
213 | * | |
214 | * @state->advertising may be used, but is not required. | |
215 | * | |
216 | * Older drivers (prior to the mac_link_up() change) may use @state->speed, | |
217 | * @state->duplex and @state->pause to configure the MAC, but this is | |
218 | * deprecated; such drivers should be converted to use mac_link_up(). | |
4add7009 | 219 | * |
91a208f2 RK |
220 | * Other members of @state must be ignored. |
221 | * | |
222 | * Valid state members: interface, advertising. | |
223 | * Deprecated state members: speed, duplex, pause. | |
8796c892 RK |
224 | * |
225 | * %MLO_AN_INBAND: | |
226 | * place the link in an inband negotiation mode (such as 802.3z | |
227 | * 1000base-X or Cisco SGMII mode depending on the @state->interface | |
228 | * mode). In both cases, link state management (whether the link | |
229 | * is up or not) is performed by the MAC, and reported via the | |
d46b7e4f | 230 | * mac_pcs_get_state() callback. Changes in link state must be made |
8796c892 RK |
231 | * by calling phylink_mac_change(). |
232 | * | |
b70486f9 RK |
233 | * Interface mode specific details are mentioned below. |
234 | * | |
8796c892 | 235 | * If in 802.3z mode, the link speed is fixed, dependent on the |
b70486f9 RK |
236 | * @state->interface. Duplex and pause modes are negotiated via |
237 | * the in-band configuration word. Advertised pause modes are set | |
238 | * according to the @state->an_enabled and @state->advertising | |
239 | * flags. Beware of MACs which only support full duplex at gigabit | |
240 | * and higher speeds. | |
8796c892 RK |
241 | * |
242 | * If in Cisco SGMII mode, the link speed and duplex mode are passed | |
243 | * in the serial bitstream 16-bit configuration word, and the MAC | |
244 | * should be configured to read these bits and acknowledge the | |
245 | * configuration word. Nothing is advertised by the MAC. The MAC is | |
246 | * responsible for reading the configuration word and configuring | |
247 | * itself accordingly. | |
0e29ae03 | 248 | * |
4add7009 RKAL |
249 | * Valid state members: interface, an_enabled, pause, advertising. |
250 | * | |
0e29ae03 RK |
251 | * Implementations are expected to update the MAC to reflect the |
252 | * requested settings - i.o.w., if nothing has changed between two | |
253 | * calls, no action is expected. If only flow control settings have | |
254 | * changed, flow control should be updated *without* taking the link | |
255 | * down. This "update" behaviour is critical to avoid bouncing the | |
256 | * link up status. | |
8796c892 | 257 | */ |
44cc27e4 | 258 | void mac_config(struct phylink_config *config, unsigned int mode, |
8796c892 RK |
259 | const struct phylink_link_state *state); |
260 | ||
b7ad14c2 RK |
261 | /** |
262 | * mac_finish() - finish a to change the PHY interface mode | |
263 | * @config: a pointer to a &struct phylink_config. | |
264 | * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. | |
265 | * @iface: interface mode to switch to | |
266 | * | |
267 | * phylink will call this if it called mac_prepare() to allow the MAC to | |
268 | * complete any necessary steps after the MAC and PCS have been configured | |
269 | * for the @mode and @iface. E.g. a MAC driver may wish to re-enable the | |
270 | * Serdes PHY here if it was previously disabled by mac_prepare(). | |
271 | * | |
272 | * Returns zero on success, or negative errno on failure which will be | |
273 | * reported to the kernel log. | |
274 | */ | |
275 | int mac_finish(struct phylink_config *config, unsigned int mode, | |
276 | phy_interface_t iface); | |
277 | ||
8796c892 RK |
278 | /** |
279 | * mac_an_restart() - restart 802.3z BaseX autonegotiation | |
44cc27e4 | 280 | * @config: a pointer to a &struct phylink_config. |
8796c892 | 281 | */ |
44cc27e4 | 282 | void mac_an_restart(struct phylink_config *config); |
8796c892 RK |
283 | |
284 | /** | |
285 | * mac_link_down() - take the link down | |
44cc27e4 | 286 | * @config: a pointer to a &struct phylink_config. |
8796c892 | 287 | * @mode: link autonegotiation mode |
c6ab3008 | 288 | * @interface: link &typedef phy_interface_t mode |
8796c892 RK |
289 | * |
290 | * If @mode is not an in-band negotiation mode (as defined by | |
291 | * phylink_autoneg_inband()), force the link down and disable any | |
c6ab3008 FF |
292 | * Energy Efficient Ethernet MAC configuration. Interface type |
293 | * selection must be done in mac_config(). | |
8796c892 | 294 | */ |
44cc27e4 | 295 | void mac_link_down(struct phylink_config *config, unsigned int mode, |
c6ab3008 | 296 | phy_interface_t interface); |
8796c892 RK |
297 | |
298 | /** | |
299 | * mac_link_up() - allow the link to come up | |
44cc27e4 | 300 | * @config: a pointer to a &struct phylink_config. |
91a208f2 | 301 | * @phy: any attached phy |
8796c892 | 302 | * @mode: link autonegotiation mode |
c6ab3008 | 303 | * @interface: link &typedef phy_interface_t mode |
91a208f2 RK |
304 | * @speed: link speed |
305 | * @duplex: link duplex | |
306 | * @tx_pause: link transmit pause enablement status | |
307 | * @rx_pause: link receive pause enablement status | |
8796c892 | 308 | * |
91a208f2 RK |
309 | * Configure the MAC for an established link. |
310 | * | |
311 | * @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link | |
312 | * settings, and should be used to configure the MAC block appropriately | |
313 | * where these settings are not automatically conveyed from the PCS block, | |
314 | * or if in-band negotiation (as defined by phylink_autoneg_inband(@mode)) | |
315 | * is disabled. | |
316 | * | |
317 | * Note that when 802.3z in-band negotiation is in use, it is possible | |
318 | * that the user wishes to override the pause settings, and this should | |
319 | * be allowed when considering the implementation of this method. | |
320 | * | |
321 | * If in-band negotiation mode is disabled, allow the link to come up. If | |
322 | * @phy is non-%NULL, configure Energy Efficient Ethernet by calling | |
8796c892 | 323 | * phy_init_eee() and perform appropriate MAC configuration for EEE. |
c6ab3008 | 324 | * Interface type selection must be done in mac_config(). |
8796c892 | 325 | */ |
91a208f2 RK |
326 | void mac_link_up(struct phylink_config *config, struct phy_device *phy, |
327 | unsigned int mode, phy_interface_t interface, | |
328 | int speed, int duplex, bool tx_pause, bool rx_pause); | |
8796c892 RK |
329 | #endif |
330 | ||
7137e18f RK |
331 | struct phylink_pcs_ops; |
332 | ||
333 | /** | |
334 | * struct phylink_pcs - PHYLINK PCS instance | |
335 | * @ops: a pointer to the &struct phylink_pcs_ops structure | |
336 | * @poll: poll the PCS for link changes | |
337 | * | |
338 | * This structure is designed to be embedded within the PCS private data, | |
339 | * and will be passed between phylink and the PCS. | |
340 | */ | |
341 | struct phylink_pcs { | |
342 | const struct phylink_pcs_ops *ops; | |
343 | bool poll; | |
344 | }; | |
345 | ||
4c0d6d3a RK |
346 | /** |
347 | * struct phylink_pcs_ops - MAC PCS operations structure. | |
348 | * @pcs_get_state: read the current MAC PCS link state from the hardware. | |
349 | * @pcs_config: configure the MAC PCS for the selected mode and state. | |
350 | * @pcs_an_restart: restart 802.3z BaseX autonegotiation. | |
351 | * @pcs_link_up: program the PCS for the resolved link configuration | |
352 | * (where necessary). | |
353 | */ | |
354 | struct phylink_pcs_ops { | |
7137e18f | 355 | void (*pcs_get_state)(struct phylink_pcs *pcs, |
4c0d6d3a | 356 | struct phylink_link_state *state); |
7137e18f | 357 | int (*pcs_config)(struct phylink_pcs *pcs, unsigned int mode, |
4c0d6d3a | 358 | phy_interface_t interface, |
1571e700 RK |
359 | const unsigned long *advertising, |
360 | bool permit_pause_to_mac); | |
7137e18f RK |
361 | void (*pcs_an_restart)(struct phylink_pcs *pcs); |
362 | void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int mode, | |
4c0d6d3a RK |
363 | phy_interface_t interface, int speed, int duplex); |
364 | }; | |
365 | ||
366 | #if 0 /* For kernel-doc purposes only. */ | |
367 | /** | |
368 | * pcs_get_state() - Read the current inband link state from the hardware | |
7137e18f | 369 | * @pcs: a pointer to a &struct phylink_pcs. |
4c0d6d3a RK |
370 | * @state: a pointer to a &struct phylink_link_state. |
371 | * | |
372 | * Read the current inband link state from the MAC PCS, reporting the | |
373 | * current speed in @state->speed, duplex mode in @state->duplex, pause | |
374 | * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits, | |
375 | * negotiation completion state in @state->an_complete, and link up state | |
376 | * in @state->link. If possible, @state->lp_advertising should also be | |
377 | * populated. | |
378 | * | |
379 | * When present, this overrides mac_pcs_get_state() in &struct | |
380 | * phylink_mac_ops. | |
381 | */ | |
7137e18f | 382 | void pcs_get_state(struct phylink_pcs *pcs, |
4c0d6d3a RK |
383 | struct phylink_link_state *state); |
384 | ||
385 | /** | |
386 | * pcs_config() - Configure the PCS mode and advertisement | |
7137e18f | 387 | * @pcs: a pointer to a &struct phylink_pcs. |
4c0d6d3a RK |
388 | * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. |
389 | * @interface: interface mode to be used | |
390 | * @advertising: adertisement ethtool link mode mask | |
1571e700 | 391 | * @permit_pause_to_mac: permit forwarding pause resolution to MAC |
4c0d6d3a RK |
392 | * |
393 | * Configure the PCS for the operating mode, the interface mode, and set | |
1571e700 RK |
394 | * the advertisement mask. @permit_pause_to_mac indicates whether the |
395 | * hardware may forward the pause mode resolution to the MAC. | |
4c0d6d3a RK |
396 | * |
397 | * When operating in %MLO_AN_INBAND, inband should always be enabled, | |
398 | * otherwise inband should be disabled. | |
399 | * | |
400 | * For SGMII, there is no advertisement from the MAC side, the PCS should | |
401 | * be programmed to acknowledge the inband word from the PHY. | |
402 | * | |
403 | * For 1000BASE-X, the advertisement should be programmed into the PCS. | |
404 | * | |
405 | * For most 10GBASE-R, there is no advertisement. | |
406 | */ | |
7137e18f | 407 | int pcs_config(struct phylink_pcs *pcs, unsigned int mode, |
0b76e642 RD |
408 | phy_interface_t interface, const unsigned long *advertising, |
409 | bool permit_pause_to_mac); | |
4c0d6d3a RK |
410 | |
411 | /** | |
412 | * pcs_an_restart() - restart 802.3z BaseX autonegotiation | |
7137e18f | 413 | * @pcs: a pointer to a &struct phylink_pcs. |
4c0d6d3a RK |
414 | * |
415 | * When PCS ops are present, this overrides mac_an_restart() in &struct | |
416 | * phylink_mac_ops. | |
417 | */ | |
7137e18f | 418 | void pcs_an_restart(struct phylink_pcs *pcs); |
4c0d6d3a RK |
419 | |
420 | /** | |
421 | * pcs_link_up() - program the PCS for the resolved link configuration | |
7137e18f | 422 | * @pcs: a pointer to a &struct phylink_pcs. |
4c0d6d3a RK |
423 | * @mode: link autonegotiation mode |
424 | * @interface: link &typedef phy_interface_t mode | |
425 | * @speed: link speed | |
426 | * @duplex: link duplex | |
427 | * | |
428 | * This call will be made just before mac_link_up() to inform the PCS of | |
429 | * the resolved link parameters. For example, a PCS operating in SGMII | |
430 | * mode without in-band AN needs to be manually configured for the link | |
431 | * and duplex setting. Otherwise, this should be a no-op. | |
432 | */ | |
7137e18f RK |
433 | void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, |
434 | phy_interface_t interface, int speed, int duplex); | |
4c0d6d3a RK |
435 | #endif |
436 | ||
44cc27e4 IC |
437 | struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, |
438 | phy_interface_t iface, | |
e7765d63 | 439 | const struct phylink_mac_ops *mac_ops); |
7137e18f | 440 | void phylink_set_pcs(struct phylink *, struct phylink_pcs *pcs); |
9525ae83 RK |
441 | void phylink_destroy(struct phylink *); |
442 | ||
443 | int phylink_connect_phy(struct phylink *, struct phy_device *); | |
0a62964c | 444 | int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); |
25396f68 CJ |
445 | int phylink_fwnode_phy_connect(struct phylink *pl, |
446 | struct fwnode_handle *fwnode, | |
447 | u32 flags); | |
9525ae83 RK |
448 | void phylink_disconnect_phy(struct phylink *); |
449 | ||
450 | void phylink_mac_change(struct phylink *, bool up); | |
451 | ||
452 | void phylink_start(struct phylink *); | |
453 | void phylink_stop(struct phylink *); | |
454 | ||
f9749365 RKO |
455 | void phylink_suspend(struct phylink *pl, bool mac_wol); |
456 | void phylink_resume(struct phylink *pl); | |
457 | ||
9525ae83 RK |
458 | void phylink_ethtool_get_wol(struct phylink *, struct ethtool_wolinfo *); |
459 | int phylink_ethtool_set_wol(struct phylink *, struct ethtool_wolinfo *); | |
460 | ||
461 | int phylink_ethtool_ksettings_get(struct phylink *, | |
462 | struct ethtool_link_ksettings *); | |
463 | int phylink_ethtool_ksettings_set(struct phylink *, | |
464 | const struct ethtool_link_ksettings *); | |
465 | int phylink_ethtool_nway_reset(struct phylink *); | |
466 | void phylink_ethtool_get_pauseparam(struct phylink *, | |
467 | struct ethtool_pauseparam *); | |
468 | int phylink_ethtool_set_pauseparam(struct phylink *, | |
469 | struct ethtool_pauseparam *); | |
9525ae83 | 470 | int phylink_get_eee_err(struct phylink *); |
86e58135 | 471 | int phylink_init_eee(struct phylink *, bool); |
9525ae83 RK |
472 | int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *); |
473 | int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *); | |
474 | int phylink_mii_ioctl(struct phylink *, struct ifreq *, int); | |
c6d5d843 RK |
475 | int phylink_speed_down(struct phylink *pl, bool sync); |
476 | int phylink_speed_up(struct phylink *pl); | |
9525ae83 RK |
477 | |
478 | #define phylink_zero(bm) \ | |
479 | bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS) | |
480 | #define __phylink_do_bit(op, bm, mode) \ | |
481 | op(ETHTOOL_LINK_MODE_ ## mode ## _BIT, bm) | |
482 | ||
483 | #define phylink_set(bm, mode) __phylink_do_bit(__set_bit, bm, mode) | |
484 | #define phylink_clear(bm, mode) __phylink_do_bit(__clear_bit, bm, mode) | |
485 | #define phylink_test(bm, mode) __phylink_do_bit(test_bit, bm, mode) | |
486 | ||
487 | void phylink_set_port_modes(unsigned long *bits); | |
a2c27a61 | 488 | void phylink_set_10g_modes(unsigned long *mask); |
624c0f02 | 489 | void phylink_helper_basex_speed(struct phylink_link_state *state); |
9525ae83 | 490 | |
74db1c18 RK |
491 | void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs, |
492 | struct phylink_link_state *state); | |
493 | int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs, | |
0bd27406 RK |
494 | phy_interface_t interface, |
495 | const unsigned long *advertising); | |
93eaceb0 RK |
496 | int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode, |
497 | phy_interface_t interface, | |
498 | const unsigned long *advertising); | |
74db1c18 RK |
499 | void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs); |
500 | ||
b8679ef8 RK |
501 | void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs, |
502 | struct phylink_link_state *state); | |
afd62209 IC |
503 | |
504 | void phylink_decode_usxgmii_word(struct phylink_link_state *state, | |
505 | uint16_t lpa); | |
9525ae83 | 506 | #endif |