5 #include <linux/spinlock.h>
6 #include <linux/workqueue.h>
16 MLO_PAUSE_RX = BIT(0),
17 MLO_PAUSE_TX = BIT(1),
18 MLO_PAUSE_TXRX_MASK = MLO_PAUSE_TX | MLO_PAUSE_RX,
19 MLO_PAUSE_AN = BIT(2),
21 MLO_AN_PHY = 0, /* Conventional PHY */
22 MLO_AN_FIXED, /* Fixed-link mode */
23 MLO_AN_INBAND, /* In-band protocol */
25 /* PCS "negotiation" mode.
26 * PHYLINK_PCS_NEG_NONE - protocol has no inband capability
27 * PHYLINK_PCS_NEG_OUTBAND - some out of band or fixed link setting
28 * PHYLINK_PCS_NEG_INBAND_DISABLED - inband mode disabled, e.g.
29 * 1000base-X with autoneg off
30 * PHYLINK_PCS_NEG_INBAND_ENABLED - inband mode enabled
31 * Additionally, this can be tested using bitmasks:
32 * PHYLINK_PCS_NEG_INBAND - inband mode selected
33 * PHYLINK_PCS_NEG_ENABLED - negotiation mode enabled
35 PHYLINK_PCS_NEG_NONE = 0,
36 PHYLINK_PCS_NEG_ENABLED = BIT(4),
37 PHYLINK_PCS_NEG_OUTBAND = BIT(5),
38 PHYLINK_PCS_NEG_INBAND = BIT(6),
39 PHYLINK_PCS_NEG_INBAND_DISABLED = PHYLINK_PCS_NEG_INBAND,
40 PHYLINK_PCS_NEG_INBAND_ENABLED = PHYLINK_PCS_NEG_INBAND |
41 PHYLINK_PCS_NEG_ENABLED,
43 /* MAC_SYM_PAUSE and MAC_ASYM_PAUSE are used when configuring our
44 * autonegotiation advertisement. They correspond to the PAUSE and
45 * ASM_DIR bits defined by 802.3, respectively.
47 * The following table lists the values of tx_pause and rx_pause which
48 * might be requested in mac_link_up. The exact values depend on either
49 * the results of autonegotation (if MLO_PAUSE_AN is set) or user
50 * configuration (if MLO_PAUSE_AN is not set).
52 * MAC_SYM_PAUSE MAC_ASYM_PAUSE MLO_PAUSE_AN tx_pause/rx_pause
53 * ============= ============== ============ ==================
56 * 0 1 0 0/0, 0/1, 1/0, 1/1
60 * 1 1 0 0/0, 0/1, 1/0, 1/1
63 * If you set MAC_ASYM_PAUSE, the user may request any combination of
64 * tx_pause and rx_pause. You do not have to support these
67 * However, you should support combinations of tx_pause and rx_pause
68 * which might be the result of autonegotation. For example, don't set
69 * MAC_SYM_PAUSE unless your device can support tx_pause and rx_pause
72 MAC_SYM_PAUSE = BIT(0),
73 MAC_ASYM_PAUSE = BIT(1),
76 MAC_10 = MAC_10HD | MAC_10FD,
79 MAC_100 = MAC_100HD | MAC_100FD,
82 MAC_1000 = MAC_1000HD | MAC_1000FD,
85 MAC_10000FD = BIT(10),
86 MAC_20000FD = BIT(11),
87 MAC_25000FD = BIT(12),
88 MAC_40000FD = BIT(13),
89 MAC_50000FD = BIT(14),
90 MAC_56000FD = BIT(15),
91 MAC_100000FD = BIT(16),
92 MAC_200000FD = BIT(17),
93 MAC_400000FD = BIT(18),
96 static inline bool phylink_autoneg_inband(unsigned int mode)
98 return mode == MLO_AN_INBAND;
102 * phylink_pcs_neg_mode() - helper to determine PCS inband mode
103 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
104 * @interface: interface mode to be used
105 * @advertising: adertisement ethtool link mode mask
107 * Determines the negotiation mode to be used by the PCS, and returns
110 * - %PHYLINK_PCS_NEG_NONE: interface mode does not support inband
111 * - %PHYLINK_PCS_NEG_OUTBAND: an out of band mode (e.g. reading the PHY)
113 * - %PHYLINK_PCS_NEG_INBAND_DISABLED: inband mode selected but autoneg
115 * - %PHYLINK_PCS_NEG_INBAND_ENABLED: inband mode selected and autoneg enabled
117 * Note: this is for cases where the PCS itself is involved in negotiation
118 * (e.g. Clause 37, SGMII and similar) not Clause 73.
120 static inline unsigned int phylink_pcs_neg_mode(unsigned int mode,
121 phy_interface_t interface,
122 const unsigned long *advertising)
124 unsigned int neg_mode;
127 case PHY_INTERFACE_MODE_SGMII:
128 case PHY_INTERFACE_MODE_QSGMII:
129 case PHY_INTERFACE_MODE_QUSGMII:
130 case PHY_INTERFACE_MODE_USXGMII:
131 /* These protocols are designed for use with a PHY which
132 * communicates its negotiation result back to the MAC via
133 * inband communication. Note: there exist PHYs that run
134 * with SGMII but do not send the inband data.
136 if (!phylink_autoneg_inband(mode))
137 neg_mode = PHYLINK_PCS_NEG_OUTBAND;
139 neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
142 case PHY_INTERFACE_MODE_1000BASEX:
143 case PHY_INTERFACE_MODE_2500BASEX:
144 /* 1000base-X is designed for use media-side for Fibre
145 * connections, and thus the Autoneg bit needs to be
146 * taken into account. We also do this for 2500base-X
147 * as well, but drivers may not support this, so may
148 * need to override this.
150 if (!phylink_autoneg_inband(mode))
151 neg_mode = PHYLINK_PCS_NEG_OUTBAND;
152 else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
154 neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
156 neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED;
160 neg_mode = PHYLINK_PCS_NEG_NONE;
168 * struct phylink_link_state - link state structure
169 * @advertising: ethtool bitmask containing advertised link modes
170 * @lp_advertising: ethtool bitmask containing link partner advertised link
172 * @interface: link &typedef phy_interface_t mode
173 * @speed: link speed, one of the SPEED_* constants.
174 * @duplex: link duplex mode, one of DUPLEX_* constants.
175 * @pause: link pause state, described by MLO_PAUSE_* constants.
176 * @rate_matching: rate matching being performed, one of the RATE_MATCH_*
177 * constants. If rate matching is taking place, then the speed/duplex of
178 * the medium link mode (@speed and @duplex) and the speed/duplex of the phy
179 * interface mode (@interface) are different.
180 * @link: true if the link is up.
181 * @an_complete: true if autonegotiation has completed.
183 struct phylink_link_state {
184 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
185 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising);
186 phy_interface_t interface;
192 unsigned int an_complete:1;
195 enum phylink_op_type {
201 * struct phylink_config - PHYLINK configuration structure
202 * @dev: a pointer to a struct device associated with the MAC
203 * @type: operation type of PHYLINK instance
204 * @poll_fixed_state: if true, starts link_poll,
205 * if MAC link is at %MLO_AN_FIXED mode.
206 * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM.
207 * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND
208 * @get_fixed_state: callback to execute to determine the fixed link state,
209 * if MAC link is at %MLO_AN_FIXED mode.
210 * @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx
211 * are supported by the MAC/PCS.
212 * @mac_capabilities: MAC pause/speed/duplex capabilities.
214 struct phylink_config {
216 enum phylink_op_type type;
217 bool poll_fixed_state;
220 void (*get_fixed_state)(struct phylink_config *config,
221 struct phylink_link_state *state);
222 DECLARE_PHY_INTERFACE_MASK(supported_interfaces);
223 unsigned long mac_capabilities;
227 * struct phylink_mac_ops - MAC operations structure.
228 * @validate: Validate and update the link configuration.
229 * @mac_select_pcs: Select a PCS for the interface mode.
230 * @mac_prepare: prepare for a major reconfiguration of the interface.
231 * @mac_config: configure the MAC for the selected mode and state.
232 * @mac_finish: finish a major reconfiguration of the interface.
233 * @mac_link_down: take the link down.
234 * @mac_link_up: allow the link to come up.
236 * The individual methods are described more fully below.
238 struct phylink_mac_ops {
239 void (*validate)(struct phylink_config *config,
240 unsigned long *supported,
241 struct phylink_link_state *state);
242 struct phylink_pcs *(*mac_select_pcs)(struct phylink_config *config,
243 phy_interface_t interface);
244 int (*mac_prepare)(struct phylink_config *config, unsigned int mode,
245 phy_interface_t iface);
246 void (*mac_config)(struct phylink_config *config, unsigned int mode,
247 const struct phylink_link_state *state);
248 int (*mac_finish)(struct phylink_config *config, unsigned int mode,
249 phy_interface_t iface);
250 void (*mac_link_down)(struct phylink_config *config, unsigned int mode,
251 phy_interface_t interface);
252 void (*mac_link_up)(struct phylink_config *config,
253 struct phy_device *phy, unsigned int mode,
254 phy_interface_t interface, int speed, int duplex,
255 bool tx_pause, bool rx_pause);
258 #if 0 /* For kernel-doc purposes only. */
260 * validate - Validate and update the link configuration
261 * @config: a pointer to a &struct phylink_config.
262 * @supported: ethtool bitmask for supported link modes.
263 * @state: a pointer to a &struct phylink_link_state.
265 * Clear bits in the @supported and @state->advertising masks that
266 * are not supportable by the MAC.
268 * Note that the PHY may be able to transform from one connection
269 * technology to another, so, eg, don't clear 1000BaseX just
270 * because the MAC is unable to BaseX mode. This is more about
271 * clearing unsupported speeds and duplex settings. The port modes
272 * should not be cleared; phylink_set_port_modes() will help with this.
274 * When @config->supported_interfaces has been set, phylink will iterate
275 * over the supported interfaces to determine the full capability of the
276 * MAC. The validation function must not print errors if @state->interface
277 * is set to an unexpected value.
279 * When @config->supported_interfaces is empty, phylink will call this
280 * function with @state->interface set to %PHY_INTERFACE_MODE_NA, and
281 * expects the MAC driver to return all supported link modes.
283 * If the @state->interface mode is not supported, then the @supported
284 * mask must be cleared.
286 * This member is optional; if not set, the generic validator will be
287 * used making use of @config->mac_capabilities and
288 * @config->supported_interfaces to determine which link modes are
291 void validate(struct phylink_config *config, unsigned long *supported,
292 struct phylink_link_state *state);
294 * mac_select_pcs: Select a PCS for the interface mode.
295 * @config: a pointer to a &struct phylink_config.
296 * @interface: PHY interface mode for PCS
298 * Return the &struct phylink_pcs for the specified interface mode, or
299 * NULL if none is required, or an error pointer on error.
301 * This must not modify any state. It is used to query which PCS should
302 * be used. Phylink will use this during validation to ensure that the
303 * configuration is valid, and when setting a configuration to internally
304 * set the PCS that will be used.
306 struct phylink_pcs *mac_select_pcs(struct phylink_config *config,
307 phy_interface_t interface);
310 * mac_prepare() - prepare to change the PHY interface mode
311 * @config: a pointer to a &struct phylink_config.
312 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
313 * @iface: interface mode to switch to
315 * phylink will call this method at the beginning of a full initialisation
316 * of the link, which includes changing the interface mode or at initial
317 * startup time. It may be called for the current mode. The MAC driver
318 * should perform whatever actions are required, e.g. disabling the
321 * This will be the first call in the sequence:
325 * - possible pcs_an_restart()
328 * Returns zero on success, or negative errno on failure which will be
329 * reported to the kernel log.
331 int mac_prepare(struct phylink_config *config, unsigned int mode,
332 phy_interface_t iface);
335 * mac_config() - configure the MAC for the selected mode and state
336 * @config: a pointer to a &struct phylink_config.
337 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
338 * @state: a pointer to a &struct phylink_link_state.
340 * Note - not all members of @state are valid. In particular,
341 * @state->lp_advertising, @state->link, @state->an_complete are never
342 * guaranteed to be correct, and so any mac_config() implementation must
343 * never reference these fields.
345 * This will only be called to reconfigure the MAC for a "major" change in
346 * e.g. interface mode. It will not be called for changes in speed, duplex
347 * or pause modes or to change the in-band advertisement.
349 * In all negotiation modes, as defined by @mode, @state->pause indicates the
350 * pause settings which should be applied as follows. If %MLO_PAUSE_AN is not
351 * set, %MLO_PAUSE_TX and %MLO_PAUSE_RX indicate whether the MAC should send
352 * pause frames and/or act on received pause frames respectively. Otherwise,
353 * the results of in-band negotiation/status from the MAC PCS should be used
354 * to control the MAC pause mode settings.
356 * The action performed depends on the currently selected mode:
358 * %MLO_AN_FIXED, %MLO_AN_PHY:
359 * Configure for non-inband negotiation mode, where the link settings
360 * are completely communicated via mac_link_up(). The physical link
361 * protocol from the MAC is specified by @state->interface.
363 * @state->advertising may be used, but is not required.
365 * Older drivers (prior to the mac_link_up() change) may use @state->speed,
366 * @state->duplex and @state->pause to configure the MAC, but this is
367 * deprecated; such drivers should be converted to use mac_link_up().
369 * Other members of @state must be ignored.
371 * Valid state members: interface, advertising.
372 * Deprecated state members: speed, duplex, pause.
375 * place the link in an inband negotiation mode (such as 802.3z
376 * 1000base-X or Cisco SGMII mode depending on the @state->interface
377 * mode). In both cases, link state management (whether the link
378 * is up or not) is performed by the MAC, and reported via the
379 * pcs_get_state() callback. Changes in link state must be made
380 * by calling phylink_mac_change().
382 * Interface mode specific details are mentioned below.
384 * If in 802.3z mode, the link speed is fixed, dependent on the
385 * @state->interface. Duplex and pause modes are negotiated via
386 * the in-band configuration word. Advertised pause modes are set
387 * according to the @state->an_enabled and @state->advertising
388 * flags. Beware of MACs which only support full duplex at gigabit
391 * If in Cisco SGMII mode, the link speed and duplex mode are passed
392 * in the serial bitstream 16-bit configuration word, and the MAC
393 * should be configured to read these bits and acknowledge the
394 * configuration word. Nothing is advertised by the MAC. The MAC is
395 * responsible for reading the configuration word and configuring
396 * itself accordingly.
398 * Valid state members: interface, an_enabled, pause, advertising.
400 * Implementations are expected to update the MAC to reflect the
401 * requested settings - i.o.w., if nothing has changed between two
402 * calls, no action is expected. If only flow control settings have
403 * changed, flow control should be updated *without* taking the link
404 * down. This "update" behaviour is critical to avoid bouncing the
407 void mac_config(struct phylink_config *config, unsigned int mode,
408 const struct phylink_link_state *state);
411 * mac_finish() - finish a to change the PHY interface mode
412 * @config: a pointer to a &struct phylink_config.
413 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
414 * @iface: interface mode to switch to
416 * phylink will call this if it called mac_prepare() to allow the MAC to
417 * complete any necessary steps after the MAC and PCS have been configured
418 * for the @mode and @iface. E.g. a MAC driver may wish to re-enable the
419 * Serdes PHY here if it was previously disabled by mac_prepare().
421 * Returns zero on success, or negative errno on failure which will be
422 * reported to the kernel log.
424 int mac_finish(struct phylink_config *config, unsigned int mode,
425 phy_interface_t iface);
428 * mac_link_down() - take the link down
429 * @config: a pointer to a &struct phylink_config.
430 * @mode: link autonegotiation mode
431 * @interface: link &typedef phy_interface_t mode
433 * If @mode is not an in-band negotiation mode (as defined by
434 * phylink_autoneg_inband()), force the link down and disable any
435 * Energy Efficient Ethernet MAC configuration. Interface type
436 * selection must be done in mac_config().
438 void mac_link_down(struct phylink_config *config, unsigned int mode,
439 phy_interface_t interface);
442 * mac_link_up() - allow the link to come up
443 * @config: a pointer to a &struct phylink_config.
444 * @phy: any attached phy
445 * @mode: link autonegotiation mode
446 * @interface: link &typedef phy_interface_t mode
448 * @duplex: link duplex
449 * @tx_pause: link transmit pause enablement status
450 * @rx_pause: link receive pause enablement status
452 * Configure the MAC for an established link.
454 * @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link
455 * settings, and should be used to configure the MAC block appropriately
456 * where these settings are not automatically conveyed from the PCS block,
457 * or if in-band negotiation (as defined by phylink_autoneg_inband(@mode))
460 * Note that when 802.3z in-band negotiation is in use, it is possible
461 * that the user wishes to override the pause settings, and this should
462 * be allowed when considering the implementation of this method.
464 * If in-band negotiation mode is disabled, allow the link to come up. If
465 * @phy is non-%NULL, configure Energy Efficient Ethernet by calling
466 * phy_init_eee() and perform appropriate MAC configuration for EEE.
467 * Interface type selection must be done in mac_config().
469 void mac_link_up(struct phylink_config *config, struct phy_device *phy,
470 unsigned int mode, phy_interface_t interface,
471 int speed, int duplex, bool tx_pause, bool rx_pause);
474 struct phylink_pcs_ops;
477 * struct phylink_pcs - PHYLINK PCS instance
478 * @ops: a pointer to the &struct phylink_pcs_ops structure
479 * @phylink: pointer to &struct phylink_config
480 * @neg_mode: provide PCS neg mode via "mode" argument
481 * @poll: poll the PCS for link changes
483 * This structure is designed to be embedded within the PCS private data,
484 * and will be passed between phylink and the PCS.
486 * The @phylink member is private to phylink and must not be touched by
490 const struct phylink_pcs_ops *ops;
491 struct phylink *phylink;
497 * struct phylink_pcs_ops - MAC PCS operations structure.
498 * @pcs_validate: validate the link configuration.
499 * @pcs_enable: enable the PCS.
500 * @pcs_disable: disable the PCS.
501 * @pcs_pre_config: pre-mac_config method (for errata)
502 * @pcs_post_config: post-mac_config method (for arrata)
503 * @pcs_get_state: read the current MAC PCS link state from the hardware.
504 * @pcs_config: configure the MAC PCS for the selected mode and state.
505 * @pcs_an_restart: restart 802.3z BaseX autonegotiation.
506 * @pcs_link_up: program the PCS for the resolved link configuration
509 struct phylink_pcs_ops {
510 int (*pcs_validate)(struct phylink_pcs *pcs, unsigned long *supported,
511 const struct phylink_link_state *state);
512 int (*pcs_enable)(struct phylink_pcs *pcs);
513 void (*pcs_disable)(struct phylink_pcs *pcs);
514 void (*pcs_pre_config)(struct phylink_pcs *pcs,
515 phy_interface_t interface);
516 int (*pcs_post_config)(struct phylink_pcs *pcs,
517 phy_interface_t interface);
518 void (*pcs_get_state)(struct phylink_pcs *pcs,
519 struct phylink_link_state *state);
520 int (*pcs_config)(struct phylink_pcs *pcs, unsigned int neg_mode,
521 phy_interface_t interface,
522 const unsigned long *advertising,
523 bool permit_pause_to_mac);
524 void (*pcs_an_restart)(struct phylink_pcs *pcs);
525 void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int neg_mode,
526 phy_interface_t interface, int speed, int duplex);
529 #if 0 /* For kernel-doc purposes only. */
531 * pcs_validate() - validate the link configuration.
532 * @pcs: a pointer to a &struct phylink_pcs.
533 * @supported: ethtool bitmask for supported link modes.
534 * @state: a const pointer to a &struct phylink_link_state.
536 * Validate the interface mode, and advertising's autoneg bit, removing any
537 * media ethtool link modes that would not be supportable from the supported
538 * mask. Phylink will propagate the changes to the advertising mask. See the
539 * &struct phylink_mac_ops validate() method.
541 * Returns -EINVAL if the interface mode/autoneg mode is not supported.
542 * Returns non-zero positive if the link state can be supported.
544 int pcs_validate(struct phylink_pcs *pcs, unsigned long *supported,
545 const struct phylink_link_state *state);
548 * pcs_enable() - enable the PCS.
549 * @pcs: a pointer to a &struct phylink_pcs.
551 int pcs_enable(struct phylink_pcs *pcs);
554 * pcs_disable() - disable the PCS.
555 * @pcs: a pointer to a &struct phylink_pcs.
557 void pcs_disable(struct phylink_pcs *pcs);
560 * pcs_get_state() - Read the current inband link state from the hardware
561 * @pcs: a pointer to a &struct phylink_pcs.
562 * @state: a pointer to a &struct phylink_link_state.
564 * Read the current inband link state from the MAC PCS, reporting the
565 * current speed in @state->speed, duplex mode in @state->duplex, pause
566 * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
567 * negotiation completion state in @state->an_complete, and link up state
568 * in @state->link. If possible, @state->lp_advertising should also be
571 * When present, this overrides pcs_get_state() in &struct
574 void pcs_get_state(struct phylink_pcs *pcs,
575 struct phylink_link_state *state);
578 * pcs_config() - Configure the PCS mode and advertisement
579 * @pcs: a pointer to a &struct phylink_pcs.
580 * @neg_mode: link negotiation mode (see below)
581 * @interface: interface mode to be used
582 * @advertising: adertisement ethtool link mode mask
583 * @permit_pause_to_mac: permit forwarding pause resolution to MAC
585 * Configure the PCS for the operating mode, the interface mode, and set
586 * the advertisement mask. @permit_pause_to_mac indicates whether the
587 * hardware may forward the pause mode resolution to the MAC.
589 * When operating in %MLO_AN_INBAND, inband should always be enabled,
590 * otherwise inband should be disabled.
592 * For SGMII, there is no advertisement from the MAC side, the PCS should
593 * be programmed to acknowledge the inband word from the PHY.
595 * For 1000BASE-X, the advertisement should be programmed into the PCS.
597 * For most 10GBASE-R, there is no advertisement.
599 * The %neg_mode argument should be tested via the phylink_mode_*() family of
600 * functions, or for PCS that set pcs->neg_mode true, should be tested
601 * against the %PHYLINK_PCS_NEG_* definitions.
603 int pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
604 phy_interface_t interface, const unsigned long *advertising,
605 bool permit_pause_to_mac);
608 * pcs_an_restart() - restart 802.3z BaseX autonegotiation
609 * @pcs: a pointer to a &struct phylink_pcs.
611 * When PCS ops are present, this overrides mac_an_restart() in &struct
614 void pcs_an_restart(struct phylink_pcs *pcs);
617 * pcs_link_up() - program the PCS for the resolved link configuration
618 * @pcs: a pointer to a &struct phylink_pcs.
619 * @neg_mode: link negotiation mode (see below)
620 * @interface: link &typedef phy_interface_t mode
622 * @duplex: link duplex
624 * This call will be made just before mac_link_up() to inform the PCS of
625 * the resolved link parameters. For example, a PCS operating in SGMII
626 * mode without in-band AN needs to be manually configured for the link
627 * and duplex setting. Otherwise, this should be a no-op.
629 * The %mode argument should be tested via the phylink_mode_*() family of
630 * functions, or for PCS that set pcs->neg_mode true, should be tested
631 * against the %PHYLINK_PCS_NEG_* definitions.
633 void pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
634 phy_interface_t interface, int speed, int duplex);
637 void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps);
638 unsigned long phylink_get_capabilities(phy_interface_t interface,
639 unsigned long mac_capabilities,
641 void phylink_validate_mask_caps(unsigned long *supported,
642 struct phylink_link_state *state,
644 void phylink_generic_validate(struct phylink_config *config,
645 unsigned long *supported,
646 struct phylink_link_state *state);
648 struct phylink *phylink_create(struct phylink_config *,
649 const struct fwnode_handle *,
651 const struct phylink_mac_ops *);
652 void phylink_destroy(struct phylink *);
653 bool phylink_expects_phy(struct phylink *pl);
655 int phylink_connect_phy(struct phylink *, struct phy_device *);
656 int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
657 int phylink_fwnode_phy_connect(struct phylink *pl,
658 const struct fwnode_handle *fwnode,
660 void phylink_disconnect_phy(struct phylink *);
662 void phylink_mac_change(struct phylink *, bool up);
663 void phylink_pcs_change(struct phylink_pcs *, bool up);
665 void phylink_start(struct phylink *);
666 void phylink_stop(struct phylink *);
668 void phylink_suspend(struct phylink *pl, bool mac_wol);
669 void phylink_resume(struct phylink *pl);
671 void phylink_ethtool_get_wol(struct phylink *, struct ethtool_wolinfo *);
672 int phylink_ethtool_set_wol(struct phylink *, struct ethtool_wolinfo *);
674 int phylink_ethtool_ksettings_get(struct phylink *,
675 struct ethtool_link_ksettings *);
676 int phylink_ethtool_ksettings_set(struct phylink *,
677 const struct ethtool_link_ksettings *);
678 int phylink_ethtool_nway_reset(struct phylink *);
679 void phylink_ethtool_get_pauseparam(struct phylink *,
680 struct ethtool_pauseparam *);
681 int phylink_ethtool_set_pauseparam(struct phylink *,
682 struct ethtool_pauseparam *);
683 int phylink_get_eee_err(struct phylink *);
684 int phylink_init_eee(struct phylink *, bool);
685 int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
686 int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
687 int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
688 int phylink_speed_down(struct phylink *pl, bool sync);
689 int phylink_speed_up(struct phylink *pl);
691 #define phylink_zero(bm) \
692 bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS)
693 #define __phylink_do_bit(op, bm, mode) \
694 op(ETHTOOL_LINK_MODE_ ## mode ## _BIT, bm)
696 #define phylink_set(bm, mode) __phylink_do_bit(__set_bit, bm, mode)
697 #define phylink_clear(bm, mode) __phylink_do_bit(__clear_bit, bm, mode)
698 #define phylink_test(bm, mode) __phylink_do_bit(test_bit, bm, mode)
700 void phylink_set_port_modes(unsigned long *bits);
703 * phylink_get_link_timer_ns - return the PCS link timer value
704 * @interface: link &typedef phy_interface_t mode
706 * Return the PCS link timer setting in nanoseconds for the PHY @interface
707 * mode, or -EINVAL if not appropriate.
709 static inline int phylink_get_link_timer_ns(phy_interface_t interface)
712 case PHY_INTERFACE_MODE_SGMII:
713 case PHY_INTERFACE_MODE_QSGMII:
714 case PHY_INTERFACE_MODE_USXGMII:
717 case PHY_INTERFACE_MODE_1000BASEX:
718 case PHY_INTERFACE_MODE_2500BASEX:
726 void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
728 void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,
729 struct phylink_link_state *state);
730 int phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface,
731 const unsigned long *advertising);
732 int phylink_mii_c22_pcs_config(struct mdio_device *pcs,
733 phy_interface_t interface,
734 const unsigned long *advertising,
735 unsigned int neg_mode);
736 void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs);
738 void phylink_resolve_c73(struct phylink_link_state *state);
740 void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs,
741 struct phylink_link_state *state);
743 void phylink_decode_usxgmii_word(struct phylink_link_state *state,