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