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 * @legacy_pre_march2020: driver has not been updated for March 2020 updates
205 * (See commit 7cceb599d15d ("net: phylink: avoid mac_config calls")
206 * @poll_fixed_state: if true, starts link_poll,
207 * if MAC link is at %MLO_AN_FIXED mode.
208 * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM.
209 * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND
210 * @get_fixed_state: callback to execute to determine the fixed link state,
211 * if MAC link is at %MLO_AN_FIXED mode.
212 * @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx
213 * are supported by the MAC/PCS.
214 * @mac_capabilities: MAC pause/speed/duplex capabilities.
216 struct phylink_config {
218 enum phylink_op_type type;
219 bool legacy_pre_march2020;
220 bool poll_fixed_state;
223 void (*get_fixed_state)(struct phylink_config *config,
224 struct phylink_link_state *state);
225 DECLARE_PHY_INTERFACE_MASK(supported_interfaces);
226 unsigned long mac_capabilities;
230 * struct phylink_mac_ops - MAC operations structure.
231 * @validate: Validate and update the link configuration.
232 * @mac_select_pcs: Select a PCS for the interface mode.
233 * @mac_pcs_get_state: Read the current link state from the hardware.
234 * @mac_prepare: prepare for a major reconfiguration of the interface.
235 * @mac_config: configure the MAC for the selected mode and state.
236 * @mac_finish: finish a major reconfiguration of the interface.
237 * @mac_link_down: take the link down.
238 * @mac_link_up: allow the link to come up.
240 * The individual methods are described more fully below.
242 struct phylink_mac_ops {
243 void (*validate)(struct phylink_config *config,
244 unsigned long *supported,
245 struct phylink_link_state *state);
246 struct phylink_pcs *(*mac_select_pcs)(struct phylink_config *config,
247 phy_interface_t interface);
248 void (*mac_pcs_get_state)(struct phylink_config *config,
249 struct phylink_link_state *state);
250 int (*mac_prepare)(struct phylink_config *config, unsigned int mode,
251 phy_interface_t iface);
252 void (*mac_config)(struct phylink_config *config, unsigned int mode,
253 const struct phylink_link_state *state);
254 int (*mac_finish)(struct phylink_config *config, unsigned int mode,
255 phy_interface_t iface);
256 void (*mac_link_down)(struct phylink_config *config, unsigned int mode,
257 phy_interface_t interface);
258 void (*mac_link_up)(struct phylink_config *config,
259 struct phy_device *phy, unsigned int mode,
260 phy_interface_t interface, int speed, int duplex,
261 bool tx_pause, bool rx_pause);
264 #if 0 /* For kernel-doc purposes only. */
266 * validate - Validate and update the link configuration
267 * @config: a pointer to a &struct phylink_config.
268 * @supported: ethtool bitmask for supported link modes.
269 * @state: a pointer to a &struct phylink_link_state.
271 * Clear bits in the @supported and @state->advertising masks that
272 * are not supportable by the MAC.
274 * Note that the PHY may be able to transform from one connection
275 * technology to another, so, eg, don't clear 1000BaseX just
276 * because the MAC is unable to BaseX mode. This is more about
277 * clearing unsupported speeds and duplex settings. The port modes
278 * should not be cleared; phylink_set_port_modes() will help with this.
280 * When @config->supported_interfaces has been set, phylink will iterate
281 * over the supported interfaces to determine the full capability of the
282 * MAC. The validation function must not print errors if @state->interface
283 * is set to an unexpected value.
285 * When @config->supported_interfaces is empty, phylink will call this
286 * function with @state->interface set to %PHY_INTERFACE_MODE_NA, and
287 * expects the MAC driver to return all supported link modes.
289 * If the @state->interface mode is not supported, then the @supported
290 * mask must be cleared.
292 * This member is optional; if not set, the generic validator will be
293 * used making use of @config->mac_capabilities and
294 * @config->supported_interfaces to determine which link modes are
297 void validate(struct phylink_config *config, unsigned long *supported,
298 struct phylink_link_state *state);
300 * mac_select_pcs: Select a PCS for the interface mode.
301 * @config: a pointer to a &struct phylink_config.
302 * @interface: PHY interface mode for PCS
304 * Return the &struct phylink_pcs for the specified interface mode, or
305 * NULL if none is required, or an error pointer on error.
307 * This must not modify any state. It is used to query which PCS should
308 * be used. Phylink will use this during validation to ensure that the
309 * configuration is valid, and when setting a configuration to internally
310 * set the PCS that will be used.
312 struct phylink_pcs *mac_select_pcs(struct phylink_config *config,
313 phy_interface_t interface);
316 * mac_pcs_get_state() - Read the current inband link state from the hardware
317 * @config: a pointer to a &struct phylink_config.
318 * @state: a pointer to a &struct phylink_link_state.
320 * Read the current inband link state from the MAC PCS, reporting the
321 * current speed in @state->speed, duplex mode in @state->duplex, pause
322 * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
323 * negotiation completion state in @state->an_complete, and link up state
324 * in @state->link. If possible, @state->lp_advertising should also be
327 * Note: This is a legacy method. This function will not be called unless
328 * legacy_pre_march2020 is set in &struct phylink_config and there is no
331 void mac_pcs_get_state(struct phylink_config *config,
332 struct phylink_link_state *state);
335 * mac_prepare() - prepare to change the PHY interface mode
336 * @config: a pointer to a &struct phylink_config.
337 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
338 * @iface: interface mode to switch to
340 * phylink will call this method at the beginning of a full initialisation
341 * of the link, which includes changing the interface mode or at initial
342 * startup time. It may be called for the current mode. The MAC driver
343 * should perform whatever actions are required, e.g. disabling the
346 * This will be the first call in the sequence:
350 * - possible pcs_an_restart()
353 * Returns zero on success, or negative errno on failure which will be
354 * reported to the kernel log.
356 int mac_prepare(struct phylink_config *config, unsigned int mode,
357 phy_interface_t iface);
360 * mac_config() - configure the MAC for the selected mode and state
361 * @config: a pointer to a &struct phylink_config.
362 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
363 * @state: a pointer to a &struct phylink_link_state.
365 * Note - not all members of @state are valid. In particular,
366 * @state->lp_advertising, @state->link, @state->an_complete are never
367 * guaranteed to be correct, and so any mac_config() implementation must
368 * never reference these fields.
370 * Note: For legacy March 2020 drivers (drivers with legacy_pre_march2020 set
371 * in their &phylnk_config and which don't have a PCS), this function will be
372 * called on each link up event, and to also change the in-band advert. For
373 * non-legacy drivers, it will only be called to reconfigure the MAC for a
374 * "major" change in e.g. interface mode. It will not be called for changes
375 * in speed, duplex or pause modes or to change the in-band advertisement.
376 * In any case, it is strongly preferred that speed, duplex and pause settings
377 * are handled in the mac_link_up() method and not in this method.
379 * (this requires a rewrite - please refer to mac_link_up() for situations
380 * where the PCS and MAC are not tightly integrated.)
382 * In all negotiation modes, as defined by @mode, @state->pause indicates the
383 * pause settings which should be applied as follows. If %MLO_PAUSE_AN is not
384 * set, %MLO_PAUSE_TX and %MLO_PAUSE_RX indicate whether the MAC should send
385 * pause frames and/or act on received pause frames respectively. Otherwise,
386 * the results of in-band negotiation/status from the MAC PCS should be used
387 * to control the MAC pause mode settings.
389 * The action performed depends on the currently selected mode:
391 * %MLO_AN_FIXED, %MLO_AN_PHY:
392 * Configure for non-inband negotiation mode, where the link settings
393 * are completely communicated via mac_link_up(). The physical link
394 * protocol from the MAC is specified by @state->interface.
396 * @state->advertising may be used, but is not required.
398 * Older drivers (prior to the mac_link_up() change) may use @state->speed,
399 * @state->duplex and @state->pause to configure the MAC, but this is
400 * deprecated; such drivers should be converted to use mac_link_up().
402 * Other members of @state must be ignored.
404 * Valid state members: interface, advertising.
405 * Deprecated state members: speed, duplex, pause.
408 * place the link in an inband negotiation mode (such as 802.3z
409 * 1000base-X or Cisco SGMII mode depending on the @state->interface
410 * mode). In both cases, link state management (whether the link
411 * is up or not) is performed by the MAC, and reported via the
412 * mac_pcs_get_state() callback. Changes in link state must be made
413 * by calling phylink_mac_change().
415 * Interface mode specific details are mentioned below.
417 * If in 802.3z mode, the link speed is fixed, dependent on the
418 * @state->interface. Duplex and pause modes are negotiated via
419 * the in-band configuration word. Advertised pause modes are set
420 * according to the @state->an_enabled and @state->advertising
421 * flags. Beware of MACs which only support full duplex at gigabit
424 * If in Cisco SGMII mode, the link speed and duplex mode are passed
425 * in the serial bitstream 16-bit configuration word, and the MAC
426 * should be configured to read these bits and acknowledge the
427 * configuration word. Nothing is advertised by the MAC. The MAC is
428 * responsible for reading the configuration word and configuring
429 * itself accordingly.
431 * Valid state members: interface, an_enabled, pause, advertising.
433 * Implementations are expected to update the MAC to reflect the
434 * requested settings - i.o.w., if nothing has changed between two
435 * calls, no action is expected. If only flow control settings have
436 * changed, flow control should be updated *without* taking the link
437 * down. This "update" behaviour is critical to avoid bouncing the
440 void mac_config(struct phylink_config *config, unsigned int mode,
441 const struct phylink_link_state *state);
444 * mac_finish() - finish a to change the PHY interface mode
445 * @config: a pointer to a &struct phylink_config.
446 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
447 * @iface: interface mode to switch to
449 * phylink will call this if it called mac_prepare() to allow the MAC to
450 * complete any necessary steps after the MAC and PCS have been configured
451 * for the @mode and @iface. E.g. a MAC driver may wish to re-enable the
452 * Serdes PHY here if it was previously disabled by mac_prepare().
454 * Returns zero on success, or negative errno on failure which will be
455 * reported to the kernel log.
457 int mac_finish(struct phylink_config *config, unsigned int mode,
458 phy_interface_t iface);
461 * mac_link_down() - take the link down
462 * @config: a pointer to a &struct phylink_config.
463 * @mode: link autonegotiation mode
464 * @interface: link &typedef phy_interface_t mode
466 * If @mode is not an in-band negotiation mode (as defined by
467 * phylink_autoneg_inband()), force the link down and disable any
468 * Energy Efficient Ethernet MAC configuration. Interface type
469 * selection must be done in mac_config().
471 void mac_link_down(struct phylink_config *config, unsigned int mode,
472 phy_interface_t interface);
475 * mac_link_up() - allow the link to come up
476 * @config: a pointer to a &struct phylink_config.
477 * @phy: any attached phy
478 * @mode: link autonegotiation mode
479 * @interface: link &typedef phy_interface_t mode
481 * @duplex: link duplex
482 * @tx_pause: link transmit pause enablement status
483 * @rx_pause: link receive pause enablement status
485 * Configure the MAC for an established link.
487 * @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link
488 * settings, and should be used to configure the MAC block appropriately
489 * where these settings are not automatically conveyed from the PCS block,
490 * or if in-band negotiation (as defined by phylink_autoneg_inband(@mode))
493 * Note that when 802.3z in-band negotiation is in use, it is possible
494 * that the user wishes to override the pause settings, and this should
495 * be allowed when considering the implementation of this method.
497 * If in-band negotiation mode is disabled, allow the link to come up. If
498 * @phy is non-%NULL, configure Energy Efficient Ethernet by calling
499 * phy_init_eee() and perform appropriate MAC configuration for EEE.
500 * Interface type selection must be done in mac_config().
502 void mac_link_up(struct phylink_config *config, struct phy_device *phy,
503 unsigned int mode, phy_interface_t interface,
504 int speed, int duplex, bool tx_pause, bool rx_pause);
507 struct phylink_pcs_ops;
510 * struct phylink_pcs - PHYLINK PCS instance
511 * @ops: a pointer to the &struct phylink_pcs_ops structure
512 * @phylink: pointer to &struct phylink_config
513 * @neg_mode: provide PCS neg mode via "mode" argument
514 * @poll: poll the PCS for link changes
516 * This structure is designed to be embedded within the PCS private data,
517 * and will be passed between phylink and the PCS.
519 * The @phylink member is private to phylink and must not be touched by
523 const struct phylink_pcs_ops *ops;
524 struct phylink *phylink;
530 * struct phylink_pcs_ops - MAC PCS operations structure.
531 * @pcs_validate: validate the link configuration.
532 * @pcs_enable: enable the PCS.
533 * @pcs_disable: disable the PCS.
534 * @pcs_pre_config: pre-mac_config method (for errata)
535 * @pcs_post_config: post-mac_config method (for arrata)
536 * @pcs_get_state: read the current MAC PCS link state from the hardware.
537 * @pcs_config: configure the MAC PCS for the selected mode and state.
538 * @pcs_an_restart: restart 802.3z BaseX autonegotiation.
539 * @pcs_link_up: program the PCS for the resolved link configuration
542 struct phylink_pcs_ops {
543 int (*pcs_validate)(struct phylink_pcs *pcs, unsigned long *supported,
544 const struct phylink_link_state *state);
545 int (*pcs_enable)(struct phylink_pcs *pcs);
546 void (*pcs_disable)(struct phylink_pcs *pcs);
547 void (*pcs_pre_config)(struct phylink_pcs *pcs,
548 phy_interface_t interface);
549 int (*pcs_post_config)(struct phylink_pcs *pcs,
550 phy_interface_t interface);
551 void (*pcs_get_state)(struct phylink_pcs *pcs,
552 struct phylink_link_state *state);
553 int (*pcs_config)(struct phylink_pcs *pcs, unsigned int neg_mode,
554 phy_interface_t interface,
555 const unsigned long *advertising,
556 bool permit_pause_to_mac);
557 void (*pcs_an_restart)(struct phylink_pcs *pcs);
558 void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int neg_mode,
559 phy_interface_t interface, int speed, int duplex);
562 #if 0 /* For kernel-doc purposes only. */
564 * pcs_validate() - validate the link configuration.
565 * @pcs: a pointer to a &struct phylink_pcs.
566 * @supported: ethtool bitmask for supported link modes.
567 * @state: a const pointer to a &struct phylink_link_state.
569 * Validate the interface mode, and advertising's autoneg bit, removing any
570 * media ethtool link modes that would not be supportable from the supported
571 * mask. Phylink will propagate the changes to the advertising mask. See the
572 * &struct phylink_mac_ops validate() method.
574 * Returns -EINVAL if the interface mode/autoneg mode is not supported.
575 * Returns non-zero positive if the link state can be supported.
577 int pcs_validate(struct phylink_pcs *pcs, unsigned long *supported,
578 const struct phylink_link_state *state);
581 * pcs_enable() - enable the PCS.
582 * @pcs: a pointer to a &struct phylink_pcs.
584 int pcs_enable(struct phylink_pcs *pcs);
587 * pcs_disable() - disable the PCS.
588 * @pcs: a pointer to a &struct phylink_pcs.
590 void pcs_disable(struct phylink_pcs *pcs);
593 * pcs_get_state() - Read the current inband link state from the hardware
594 * @pcs: a pointer to a &struct phylink_pcs.
595 * @state: a pointer to a &struct phylink_link_state.
597 * Read the current inband link state from the MAC PCS, reporting the
598 * current speed in @state->speed, duplex mode in @state->duplex, pause
599 * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
600 * negotiation completion state in @state->an_complete, and link up state
601 * in @state->link. If possible, @state->lp_advertising should also be
604 * When present, this overrides mac_pcs_get_state() in &struct
607 void pcs_get_state(struct phylink_pcs *pcs,
608 struct phylink_link_state *state);
611 * pcs_config() - Configure the PCS mode and advertisement
612 * @pcs: a pointer to a &struct phylink_pcs.
613 * @neg_mode: link negotiation mode (see below)
614 * @interface: interface mode to be used
615 * @advertising: adertisement ethtool link mode mask
616 * @permit_pause_to_mac: permit forwarding pause resolution to MAC
618 * Configure the PCS for the operating mode, the interface mode, and set
619 * the advertisement mask. @permit_pause_to_mac indicates whether the
620 * hardware may forward the pause mode resolution to the MAC.
622 * When operating in %MLO_AN_INBAND, inband should always be enabled,
623 * otherwise inband should be disabled.
625 * For SGMII, there is no advertisement from the MAC side, the PCS should
626 * be programmed to acknowledge the inband word from the PHY.
628 * For 1000BASE-X, the advertisement should be programmed into the PCS.
630 * For most 10GBASE-R, there is no advertisement.
632 * The %neg_mode argument should be tested via the phylink_mode_*() family of
633 * functions, or for PCS that set pcs->neg_mode true, should be tested
634 * against the %PHYLINK_PCS_NEG_* definitions.
636 int pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
637 phy_interface_t interface, const unsigned long *advertising,
638 bool permit_pause_to_mac);
641 * pcs_an_restart() - restart 802.3z BaseX autonegotiation
642 * @pcs: a pointer to a &struct phylink_pcs.
644 * When PCS ops are present, this overrides mac_an_restart() in &struct
647 void pcs_an_restart(struct phylink_pcs *pcs);
650 * pcs_link_up() - program the PCS for the resolved link configuration
651 * @pcs: a pointer to a &struct phylink_pcs.
652 * @neg_mode: link negotiation mode (see below)
653 * @interface: link &typedef phy_interface_t mode
655 * @duplex: link duplex
657 * This call will be made just before mac_link_up() to inform the PCS of
658 * the resolved link parameters. For example, a PCS operating in SGMII
659 * mode without in-band AN needs to be manually configured for the link
660 * and duplex setting. Otherwise, this should be a no-op.
662 * The %mode argument should be tested via the phylink_mode_*() family of
663 * functions, or for PCS that set pcs->neg_mode true, should be tested
664 * against the %PHYLINK_PCS_NEG_* definitions.
666 void pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
667 phy_interface_t interface, int speed, int duplex);
670 void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps);
671 unsigned long phylink_get_capabilities(phy_interface_t interface,
672 unsigned long mac_capabilities,
674 void phylink_validate_mask_caps(unsigned long *supported,
675 struct phylink_link_state *state,
677 void phylink_generic_validate(struct phylink_config *config,
678 unsigned long *supported,
679 struct phylink_link_state *state);
681 struct phylink *phylink_create(struct phylink_config *,
682 const struct fwnode_handle *,
684 const struct phylink_mac_ops *);
685 void phylink_destroy(struct phylink *);
686 bool phylink_expects_phy(struct phylink *pl);
688 int phylink_connect_phy(struct phylink *, struct phy_device *);
689 int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
690 int phylink_fwnode_phy_connect(struct phylink *pl,
691 const struct fwnode_handle *fwnode,
693 void phylink_disconnect_phy(struct phylink *);
695 void phylink_mac_change(struct phylink *, bool up);
696 void phylink_pcs_change(struct phylink_pcs *, bool up);
698 void phylink_start(struct phylink *);
699 void phylink_stop(struct phylink *);
701 void phylink_suspend(struct phylink *pl, bool mac_wol);
702 void phylink_resume(struct phylink *pl);
704 void phylink_ethtool_get_wol(struct phylink *, struct ethtool_wolinfo *);
705 int phylink_ethtool_set_wol(struct phylink *, struct ethtool_wolinfo *);
707 int phylink_ethtool_ksettings_get(struct phylink *,
708 struct ethtool_link_ksettings *);
709 int phylink_ethtool_ksettings_set(struct phylink *,
710 const struct ethtool_link_ksettings *);
711 int phylink_ethtool_nway_reset(struct phylink *);
712 void phylink_ethtool_get_pauseparam(struct phylink *,
713 struct ethtool_pauseparam *);
714 int phylink_ethtool_set_pauseparam(struct phylink *,
715 struct ethtool_pauseparam *);
716 int phylink_get_eee_err(struct phylink *);
717 int phylink_init_eee(struct phylink *, bool);
718 int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
719 int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
720 int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
721 int phylink_speed_down(struct phylink *pl, bool sync);
722 int phylink_speed_up(struct phylink *pl);
724 #define phylink_zero(bm) \
725 bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS)
726 #define __phylink_do_bit(op, bm, mode) \
727 op(ETHTOOL_LINK_MODE_ ## mode ## _BIT, bm)
729 #define phylink_set(bm, mode) __phylink_do_bit(__set_bit, bm, mode)
730 #define phylink_clear(bm, mode) __phylink_do_bit(__clear_bit, bm, mode)
731 #define phylink_test(bm, mode) __phylink_do_bit(test_bit, bm, mode)
733 void phylink_set_port_modes(unsigned long *bits);
736 * phylink_get_link_timer_ns - return the PCS link timer value
737 * @interface: link &typedef phy_interface_t mode
739 * Return the PCS link timer setting in nanoseconds for the PHY @interface
740 * mode, or -EINVAL if not appropriate.
742 static inline int phylink_get_link_timer_ns(phy_interface_t interface)
745 case PHY_INTERFACE_MODE_SGMII:
746 case PHY_INTERFACE_MODE_QSGMII:
747 case PHY_INTERFACE_MODE_USXGMII:
750 case PHY_INTERFACE_MODE_1000BASEX:
751 case PHY_INTERFACE_MODE_2500BASEX:
759 void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
761 void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,
762 struct phylink_link_state *state);
763 int phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface,
764 const unsigned long *advertising);
765 int phylink_mii_c22_pcs_config(struct mdio_device *pcs,
766 phy_interface_t interface,
767 const unsigned long *advertising,
768 unsigned int neg_mode);
769 void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs);
771 void phylink_resolve_c73(struct phylink_link_state *state);
773 void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs,
774 struct phylink_link_state *state);
776 void phylink_decode_usxgmii_word(struct phylink_link_state *state,