at v6.4 26 kB view raw
1#ifndef NETDEV_PCS_H 2#define NETDEV_PCS_H 3 4#include <linux/phy.h> 5#include <linux/spinlock.h> 6#include <linux/workqueue.h> 7 8struct device_node; 9struct ethtool_cmd; 10struct fwnode_handle; 11struct net_device; 12 13enum { 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 77static 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_complete: true if autonegotiation has completed. 97 */ 98struct phylink_link_state { 99 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); 100 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); 101 phy_interface_t interface; 102 int speed; 103 int duplex; 104 int pause; 105 int rate_matching; 106 unsigned int link:1; 107 unsigned int an_complete:1; 108}; 109 110enum phylink_op_type { 111 PHYLINK_NETDEV = 0, 112 PHYLINK_DEV, 113}; 114 115/** 116 * struct phylink_config - PHYLINK configuration structure 117 * @dev: a pointer to a struct device associated with the MAC 118 * @type: operation type of PHYLINK instance 119 * @legacy_pre_march2020: driver has not been updated for March 2020 updates 120 * (See commit 7cceb599d15d ("net: phylink: avoid mac_config calls") 121 * @poll_fixed_state: if true, starts link_poll, 122 * if MAC link is at %MLO_AN_FIXED mode. 123 * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM. 124 * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND 125 * @get_fixed_state: callback to execute to determine the fixed link state, 126 * if MAC link is at %MLO_AN_FIXED mode. 127 * @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx 128 * are supported by the MAC/PCS. 129 * @mac_capabilities: MAC pause/speed/duplex capabilities. 130 */ 131struct phylink_config { 132 struct device *dev; 133 enum phylink_op_type type; 134 bool legacy_pre_march2020; 135 bool poll_fixed_state; 136 bool mac_managed_pm; 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 */ 158struct 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 * This member is optional; if not set, the generic validator will be 210 * used making use of @config->mac_capabilities and 211 * @config->supported_interfaces to determine which link modes are 212 * supported. 213 */ 214void validate(struct phylink_config *config, unsigned long *supported, 215 struct phylink_link_state *state); 216/** 217 * mac_select_pcs: Select a PCS for the interface mode. 218 * @config: a pointer to a &struct phylink_config. 219 * @interface: PHY interface mode for PCS 220 * 221 * Return the &struct phylink_pcs for the specified interface mode, or 222 * NULL if none is required, or an error pointer on error. 223 * 224 * This must not modify any state. It is used to query which PCS should 225 * be used. Phylink will use this during validation to ensure that the 226 * configuration is valid, and when setting a configuration to internally 227 * set the PCS that will be used. 228 */ 229struct phylink_pcs *mac_select_pcs(struct phylink_config *config, 230 phy_interface_t interface); 231 232/** 233 * mac_pcs_get_state() - Read the current inband link state from the hardware 234 * @config: a pointer to a &struct phylink_config. 235 * @state: a pointer to a &struct phylink_link_state. 236 * 237 * Read the current inband link state from the MAC PCS, reporting the 238 * current speed in @state->speed, duplex mode in @state->duplex, pause 239 * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits, 240 * negotiation completion state in @state->an_complete, and link up state 241 * in @state->link. If possible, @state->lp_advertising should also be 242 * populated. 243 * 244 * Note: This is a legacy method. This function will not be called unless 245 * legacy_pre_march2020 is set in &struct phylink_config and there is no 246 * PCS attached. 247 */ 248void mac_pcs_get_state(struct phylink_config *config, 249 struct phylink_link_state *state); 250 251/** 252 * mac_prepare() - prepare to change the PHY interface mode 253 * @config: a pointer to a &struct phylink_config. 254 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. 255 * @iface: interface mode to switch to 256 * 257 * phylink will call this method at the beginning of a full initialisation 258 * of the link, which includes changing the interface mode or at initial 259 * startup time. It may be called for the current mode. The MAC driver 260 * should perform whatever actions are required, e.g. disabling the 261 * Serdes PHY. 262 * 263 * This will be the first call in the sequence: 264 * - mac_prepare() 265 * - mac_config() 266 * - pcs_config() 267 * - possible pcs_an_restart() 268 * - mac_finish() 269 * 270 * Returns zero on success, or negative errno on failure which will be 271 * reported to the kernel log. 272 */ 273int mac_prepare(struct phylink_config *config, unsigned int mode, 274 phy_interface_t iface); 275 276/** 277 * mac_config() - configure the MAC for the selected mode and state 278 * @config: a pointer to a &struct phylink_config. 279 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. 280 * @state: a pointer to a &struct phylink_link_state. 281 * 282 * Note - not all members of @state are valid. In particular, 283 * @state->lp_advertising, @state->link, @state->an_complete are never 284 * guaranteed to be correct, and so any mac_config() implementation must 285 * never reference these fields. 286 * 287 * Note: For legacy March 2020 drivers (drivers with legacy_pre_march2020 set 288 * in their &phylnk_config and which don't have a PCS), this function will be 289 * called on each link up event, and to also change the in-band advert. For 290 * non-legacy drivers, it will only be called to reconfigure the MAC for a 291 * "major" change in e.g. interface mode. It will not be called for changes 292 * in speed, duplex or pause modes or to change the in-band advertisement. 293 * In any case, it is strongly preferred that speed, duplex and pause settings 294 * are handled in the mac_link_up() method and not in this method. 295 * 296 * (this requires a rewrite - please refer to mac_link_up() for situations 297 * where the PCS and MAC are not tightly integrated.) 298 * 299 * In all negotiation modes, as defined by @mode, @state->pause indicates the 300 * pause settings which should be applied as follows. If %MLO_PAUSE_AN is not 301 * set, %MLO_PAUSE_TX and %MLO_PAUSE_RX indicate whether the MAC should send 302 * pause frames and/or act on received pause frames respectively. Otherwise, 303 * the results of in-band negotiation/status from the MAC PCS should be used 304 * to control the MAC pause mode settings. 305 * 306 * The action performed depends on the currently selected mode: 307 * 308 * %MLO_AN_FIXED, %MLO_AN_PHY: 309 * Configure for non-inband negotiation mode, where the link settings 310 * are completely communicated via mac_link_up(). The physical link 311 * protocol from the MAC is specified by @state->interface. 312 * 313 * @state->advertising may be used, but is not required. 314 * 315 * Older drivers (prior to the mac_link_up() change) may use @state->speed, 316 * @state->duplex and @state->pause to configure the MAC, but this is 317 * deprecated; such drivers should be converted to use mac_link_up(). 318 * 319 * Other members of @state must be ignored. 320 * 321 * Valid state members: interface, advertising. 322 * Deprecated state members: speed, duplex, pause. 323 * 324 * %MLO_AN_INBAND: 325 * place the link in an inband negotiation mode (such as 802.3z 326 * 1000base-X or Cisco SGMII mode depending on the @state->interface 327 * mode). In both cases, link state management (whether the link 328 * is up or not) is performed by the MAC, and reported via the 329 * mac_pcs_get_state() callback. Changes in link state must be made 330 * by calling phylink_mac_change(). 331 * 332 * Interface mode specific details are mentioned below. 333 * 334 * If in 802.3z mode, the link speed is fixed, dependent on the 335 * @state->interface. Duplex and pause modes are negotiated via 336 * the in-band configuration word. Advertised pause modes are set 337 * according to the @state->an_enabled and @state->advertising 338 * flags. Beware of MACs which only support full duplex at gigabit 339 * and higher speeds. 340 * 341 * If in Cisco SGMII mode, the link speed and duplex mode are passed 342 * in the serial bitstream 16-bit configuration word, and the MAC 343 * should be configured to read these bits and acknowledge the 344 * configuration word. Nothing is advertised by the MAC. The MAC is 345 * responsible for reading the configuration word and configuring 346 * itself accordingly. 347 * 348 * Valid state members: interface, an_enabled, pause, advertising. 349 * 350 * Implementations are expected to update the MAC to reflect the 351 * requested settings - i.o.w., if nothing has changed between two 352 * calls, no action is expected. If only flow control settings have 353 * changed, flow control should be updated *without* taking the link 354 * down. This "update" behaviour is critical to avoid bouncing the 355 * link up status. 356 */ 357void mac_config(struct phylink_config *config, unsigned int mode, 358 const struct phylink_link_state *state); 359 360/** 361 * mac_finish() - finish a to change the PHY interface mode 362 * @config: a pointer to a &struct phylink_config. 363 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. 364 * @iface: interface mode to switch to 365 * 366 * phylink will call this if it called mac_prepare() to allow the MAC to 367 * complete any necessary steps after the MAC and PCS have been configured 368 * for the @mode and @iface. E.g. a MAC driver may wish to re-enable the 369 * Serdes PHY here if it was previously disabled by mac_prepare(). 370 * 371 * Returns zero on success, or negative errno on failure which will be 372 * reported to the kernel log. 373 */ 374int mac_finish(struct phylink_config *config, unsigned int mode, 375 phy_interface_t iface); 376 377/** 378 * mac_an_restart() - restart 802.3z BaseX autonegotiation 379 * @config: a pointer to a &struct phylink_config. 380 * 381 * Note: This is a legacy method. This function will not be called unless 382 * legacy_pre_march2020 is set in &struct phylink_config and there is no 383 * PCS attached. 384 */ 385void mac_an_restart(struct phylink_config *config); 386 387/** 388 * mac_link_down() - take the link down 389 * @config: a pointer to a &struct phylink_config. 390 * @mode: link autonegotiation mode 391 * @interface: link &typedef phy_interface_t mode 392 * 393 * If @mode is not an in-band negotiation mode (as defined by 394 * phylink_autoneg_inband()), force the link down and disable any 395 * Energy Efficient Ethernet MAC configuration. Interface type 396 * selection must be done in mac_config(). 397 */ 398void mac_link_down(struct phylink_config *config, unsigned int mode, 399 phy_interface_t interface); 400 401/** 402 * mac_link_up() - allow the link to come up 403 * @config: a pointer to a &struct phylink_config. 404 * @phy: any attached phy 405 * @mode: link autonegotiation mode 406 * @interface: link &typedef phy_interface_t mode 407 * @speed: link speed 408 * @duplex: link duplex 409 * @tx_pause: link transmit pause enablement status 410 * @rx_pause: link receive pause enablement status 411 * 412 * Configure the MAC for an established link. 413 * 414 * @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link 415 * settings, and should be used to configure the MAC block appropriately 416 * where these settings are not automatically conveyed from the PCS block, 417 * or if in-band negotiation (as defined by phylink_autoneg_inband(@mode)) 418 * is disabled. 419 * 420 * Note that when 802.3z in-band negotiation is in use, it is possible 421 * that the user wishes to override the pause settings, and this should 422 * be allowed when considering the implementation of this method. 423 * 424 * If in-band negotiation mode is disabled, allow the link to come up. If 425 * @phy is non-%NULL, configure Energy Efficient Ethernet by calling 426 * phy_init_eee() and perform appropriate MAC configuration for EEE. 427 * Interface type selection must be done in mac_config(). 428 */ 429void mac_link_up(struct phylink_config *config, struct phy_device *phy, 430 unsigned int mode, phy_interface_t interface, 431 int speed, int duplex, bool tx_pause, bool rx_pause); 432#endif 433 434struct phylink_pcs_ops; 435 436/** 437 * struct phylink_pcs - PHYLINK PCS instance 438 * @ops: a pointer to the &struct phylink_pcs_ops structure 439 * @poll: poll the PCS for link changes 440 * 441 * This structure is designed to be embedded within the PCS private data, 442 * and will be passed between phylink and the PCS. 443 */ 444struct phylink_pcs { 445 const struct phylink_pcs_ops *ops; 446 bool poll; 447}; 448 449/** 450 * struct phylink_pcs_ops - MAC PCS operations structure. 451 * @pcs_validate: validate the link configuration. 452 * @pcs_get_state: read the current MAC PCS link state from the hardware. 453 * @pcs_config: configure the MAC PCS for the selected mode and state. 454 * @pcs_an_restart: restart 802.3z BaseX autonegotiation. 455 * @pcs_link_up: program the PCS for the resolved link configuration 456 * (where necessary). 457 */ 458struct phylink_pcs_ops { 459 int (*pcs_validate)(struct phylink_pcs *pcs, unsigned long *supported, 460 const struct phylink_link_state *state); 461 void (*pcs_get_state)(struct phylink_pcs *pcs, 462 struct phylink_link_state *state); 463 int (*pcs_config)(struct phylink_pcs *pcs, unsigned int mode, 464 phy_interface_t interface, 465 const unsigned long *advertising, 466 bool permit_pause_to_mac); 467 void (*pcs_an_restart)(struct phylink_pcs *pcs); 468 void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int mode, 469 phy_interface_t interface, int speed, int duplex); 470}; 471 472#if 0 /* For kernel-doc purposes only. */ 473/** 474 * pcs_validate() - validate the link configuration. 475 * @pcs: a pointer to a &struct phylink_pcs. 476 * @supported: ethtool bitmask for supported link modes. 477 * @state: a const pointer to a &struct phylink_link_state. 478 * 479 * Validate the interface mode, and advertising's autoneg bit, removing any 480 * media ethtool link modes that would not be supportable from the supported 481 * mask. Phylink will propagate the changes to the advertising mask. See the 482 * &struct phylink_mac_ops validate() method. 483 * 484 * Returns -EINVAL if the interface mode/autoneg mode is not supported. 485 * Returns non-zero positive if the link state can be supported. 486 */ 487int pcs_validate(struct phylink_pcs *pcs, unsigned long *supported, 488 const struct phylink_link_state *state); 489 490/** 491 * pcs_get_state() - Read the current inband link state from the hardware 492 * @pcs: a pointer to a &struct phylink_pcs. 493 * @state: a pointer to a &struct phylink_link_state. 494 * 495 * Read the current inband link state from the MAC PCS, reporting the 496 * current speed in @state->speed, duplex mode in @state->duplex, pause 497 * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits, 498 * negotiation completion state in @state->an_complete, and link up state 499 * in @state->link. If possible, @state->lp_advertising should also be 500 * populated. 501 * 502 * When present, this overrides mac_pcs_get_state() in &struct 503 * phylink_mac_ops. 504 */ 505void pcs_get_state(struct phylink_pcs *pcs, 506 struct phylink_link_state *state); 507 508/** 509 * pcs_config() - Configure the PCS mode and advertisement 510 * @pcs: a pointer to a &struct phylink_pcs. 511 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. 512 * @interface: interface mode to be used 513 * @advertising: adertisement ethtool link mode mask 514 * @permit_pause_to_mac: permit forwarding pause resolution to MAC 515 * 516 * Configure the PCS for the operating mode, the interface mode, and set 517 * the advertisement mask. @permit_pause_to_mac indicates whether the 518 * hardware may forward the pause mode resolution to the MAC. 519 * 520 * When operating in %MLO_AN_INBAND, inband should always be enabled, 521 * otherwise inband should be disabled. 522 * 523 * For SGMII, there is no advertisement from the MAC side, the PCS should 524 * be programmed to acknowledge the inband word from the PHY. 525 * 526 * For 1000BASE-X, the advertisement should be programmed into the PCS. 527 * 528 * For most 10GBASE-R, there is no advertisement. 529 */ 530int pcs_config(struct phylink_pcs *pcs, unsigned int mode, 531 phy_interface_t interface, const unsigned long *advertising, 532 bool permit_pause_to_mac); 533 534/** 535 * pcs_an_restart() - restart 802.3z BaseX autonegotiation 536 * @pcs: a pointer to a &struct phylink_pcs. 537 * 538 * When PCS ops are present, this overrides mac_an_restart() in &struct 539 * phylink_mac_ops. 540 */ 541void pcs_an_restart(struct phylink_pcs *pcs); 542 543/** 544 * pcs_link_up() - program the PCS for the resolved link configuration 545 * @pcs: a pointer to a &struct phylink_pcs. 546 * @mode: link autonegotiation mode 547 * @interface: link &typedef phy_interface_t mode 548 * @speed: link speed 549 * @duplex: link duplex 550 * 551 * This call will be made just before mac_link_up() to inform the PCS of 552 * the resolved link parameters. For example, a PCS operating in SGMII 553 * mode without in-band AN needs to be manually configured for the link 554 * and duplex setting. Otherwise, this should be a no-op. 555 */ 556void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, 557 phy_interface_t interface, int speed, int duplex); 558#endif 559 560void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); 561unsigned long phylink_get_capabilities(phy_interface_t interface, 562 unsigned long mac_capabilities, 563 int rate_matching); 564void phylink_validate_mask_caps(unsigned long *supported, 565 struct phylink_link_state *state, 566 unsigned long caps); 567void phylink_generic_validate(struct phylink_config *config, 568 unsigned long *supported, 569 struct phylink_link_state *state); 570 571struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, 572 phy_interface_t iface, 573 const struct phylink_mac_ops *mac_ops); 574void phylink_destroy(struct phylink *); 575bool phylink_expects_phy(struct phylink *pl); 576 577int phylink_connect_phy(struct phylink *, struct phy_device *); 578int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); 579int phylink_fwnode_phy_connect(struct phylink *pl, 580 struct fwnode_handle *fwnode, 581 u32 flags); 582void phylink_disconnect_phy(struct phylink *); 583 584void phylink_mac_change(struct phylink *, bool up); 585 586void phylink_start(struct phylink *); 587void phylink_stop(struct phylink *); 588 589void phylink_suspend(struct phylink *pl, bool mac_wol); 590void phylink_resume(struct phylink *pl); 591 592void phylink_ethtool_get_wol(struct phylink *, struct ethtool_wolinfo *); 593int phylink_ethtool_set_wol(struct phylink *, struct ethtool_wolinfo *); 594 595int phylink_ethtool_ksettings_get(struct phylink *, 596 struct ethtool_link_ksettings *); 597int phylink_ethtool_ksettings_set(struct phylink *, 598 const struct ethtool_link_ksettings *); 599int phylink_ethtool_nway_reset(struct phylink *); 600void phylink_ethtool_get_pauseparam(struct phylink *, 601 struct ethtool_pauseparam *); 602int phylink_ethtool_set_pauseparam(struct phylink *, 603 struct ethtool_pauseparam *); 604int phylink_get_eee_err(struct phylink *); 605int phylink_init_eee(struct phylink *, bool); 606int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *); 607int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *); 608int phylink_mii_ioctl(struct phylink *, struct ifreq *, int); 609int phylink_speed_down(struct phylink *pl, bool sync); 610int phylink_speed_up(struct phylink *pl); 611 612#define phylink_zero(bm) \ 613 bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS) 614#define __phylink_do_bit(op, bm, mode) \ 615 op(ETHTOOL_LINK_MODE_ ## mode ## _BIT, bm) 616 617#define phylink_set(bm, mode) __phylink_do_bit(__set_bit, bm, mode) 618#define phylink_clear(bm, mode) __phylink_do_bit(__clear_bit, bm, mode) 619#define phylink_test(bm, mode) __phylink_do_bit(test_bit, bm, mode) 620 621void phylink_set_port_modes(unsigned long *bits); 622 623/** 624 * phylink_get_link_timer_ns - return the PCS link timer value 625 * @interface: link &typedef phy_interface_t mode 626 * 627 * Return the PCS link timer setting in nanoseconds for the PHY @interface 628 * mode, or -EINVAL if not appropriate. 629 */ 630static inline int phylink_get_link_timer_ns(phy_interface_t interface) 631{ 632 switch (interface) { 633 case PHY_INTERFACE_MODE_SGMII: 634 case PHY_INTERFACE_MODE_QSGMII: 635 case PHY_INTERFACE_MODE_USXGMII: 636 return 1600000; 637 638 case PHY_INTERFACE_MODE_1000BASEX: 639 case PHY_INTERFACE_MODE_2500BASEX: 640 return 10000000; 641 642 default: 643 return -EINVAL; 644 } 645} 646 647void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state, 648 u16 bmsr, u16 lpa); 649void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs, 650 struct phylink_link_state *state); 651int phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface, 652 const unsigned long *advertising); 653int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode, 654 phy_interface_t interface, 655 const unsigned long *advertising); 656void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs); 657 658void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs, 659 struct phylink_link_state *state); 660 661void phylink_decode_usxgmii_word(struct phylink_link_state *state, 662 uint16_t lpa); 663#endif