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