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