1 #ifndef NETDEV_PCS_H 1 #ifndef NETDEV_PCS_H 2 #define NETDEV_PCS_H 2 #define NETDEV_PCS_H 3 3 4 #include <linux/phy.h> 4 #include <linux/phy.h> 5 #include <linux/spinlock.h> 5 #include <linux/spinlock.h> 6 #include <linux/workqueue.h> 6 #include <linux/workqueue.h> 7 7 8 struct device_node; 8 struct device_node; 9 struct ethtool_cmd; 9 struct ethtool_cmd; 10 struct fwnode_handle; 10 struct fwnode_handle; 11 struct net_device; 11 struct net_device; 12 struct phylink; << 13 12 14 enum { 13 enum { 15 MLO_PAUSE_NONE, 14 MLO_PAUSE_NONE, 16 MLO_PAUSE_RX = BIT(0), !! 15 MLO_PAUSE_ASYM = BIT(0), 17 MLO_PAUSE_TX = BIT(1), !! 16 MLO_PAUSE_SYM = BIT(1), >> 17 MLO_PAUSE_RX = BIT(2), >> 18 MLO_PAUSE_TX = BIT(3), 18 MLO_PAUSE_TXRX_MASK = MLO_PAUSE_TX | M 19 MLO_PAUSE_TXRX_MASK = MLO_PAUSE_TX | MLO_PAUSE_RX, 19 MLO_PAUSE_AN = BIT(2), !! 20 MLO_PAUSE_AN = BIT(4), 20 21 21 MLO_AN_PHY = 0, /* Conventional PHY */ 22 MLO_AN_PHY = 0, /* Conventional PHY */ 22 MLO_AN_FIXED, /* Fixed-link mode */ 23 MLO_AN_FIXED, /* Fixed-link mode */ 23 MLO_AN_INBAND, /* In-band protocol */ 24 MLO_AN_INBAND, /* In-band protocol */ 24 << 25 /* PCS "negotiation" mode. << 26 * PHYLINK_PCS_NEG_NONE - protocol ha << 27 * PHYLINK_PCS_NEG_OUTBAND - some out << 28 * PHYLINK_PCS_NEG_INBAND_DISABLED - << 29 * << 30 * PHYLINK_PCS_NEG_INBAND_ENABLED - i << 31 * Additionally, this can be tested us << 32 * PHYLINK_PCS_NEG_INBAND - inband mo << 33 * PHYLINK_PCS_NEG_ENABLED - negotiat << 34 */ << 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 = PHYL << 40 PHYLINK_PCS_NEG_INBAND_ENABLED = PHYLI << 41 PHYLI << 42 << 43 /* MAC_SYM_PAUSE and MAC_ASYM_PAUSE ar << 44 * autonegotiation advertisement. They << 45 * ASM_DIR bits defined by 802.3, resp << 46 * << 47 * The following table lists the value << 48 * might be requested in mac_link_up. << 49 * the results of autonegotation (if M << 50 * configuration (if MLO_PAUSE_AN is n << 51 * << 52 * MAC_SYM_PAUSE MAC_ASYM_PAUSE MLO_PA << 53 * ============= ============== ====== << 54 * 0 0 << 55 * 0 0 << 56 * 0 1 << 57 * 0 1 << 58 * 1 0 << 59 * 1 0 << 60 * 1 1 << 61 * 1 1 << 62 * << 63 * If you set MAC_ASYM_PAUSE, the user << 64 * tx_pause and rx_pause. You do not h << 65 * combinations. << 66 * << 67 * However, you should support combina << 68 * which might be the result of autone << 69 * MAC_SYM_PAUSE unless your device ca << 70 * at the same time. << 71 */ << 72 MAC_SYM_PAUSE = BIT(0), << 73 MAC_ASYM_PAUSE = BIT(1), << 74 MAC_10HD = BIT(2), << 75 MAC_10FD = BIT(3), << 76 MAC_10 = MAC_10HD | MAC_10FD, << 77 MAC_100HD = BIT(4), << 78 MAC_100FD = BIT(5), << 79 MAC_100 = MAC_100HD | MAC_100F << 80 MAC_1000HD = BIT(6), << 81 MAC_1000FD = BIT(7), << 82 MAC_1000 = MAC_1000HD | MAC_100 << 83 MAC_2500FD = BIT(8), << 84 MAC_5000FD = BIT(9), << 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), << 94 }; 25 }; 95 26 96 static inline bool phylink_autoneg_inband(unsi 27 static inline bool phylink_autoneg_inband(unsigned int mode) 97 { 28 { 98 return mode == MLO_AN_INBAND; 29 return mode == MLO_AN_INBAND; 99 } 30 } 100 31 101 /** 32 /** 102 * struct phylink_link_state - link state stru 33 * struct phylink_link_state - link state structure 103 * @advertising: ethtool bitmask containing ad 34 * @advertising: ethtool bitmask containing advertised link modes 104 * @lp_advertising: ethtool bitmask containing 35 * @lp_advertising: ethtool bitmask containing link partner advertised link 105 * modes 36 * modes 106 * @interface: link &typedef phy_interface_t m 37 * @interface: link &typedef phy_interface_t mode 107 * @speed: link speed, one of the SPEED_* cons 38 * @speed: link speed, one of the SPEED_* constants. 108 * @duplex: link duplex mode, one of DUPLEX_* 39 * @duplex: link duplex mode, one of DUPLEX_* constants. 109 * @pause: link pause state, described by MLO_ 40 * @pause: link pause state, described by MLO_PAUSE_* constants. 110 * @rate_matching: rate matching being perform << 111 * constants. If rate matching is taking pla << 112 * the medium link mode (@speed and @duplex) << 113 * interface mode (@interface) are different << 114 * @link: true if the link is up. 41 * @link: true if the link is up. >> 42 * @an_enabled: true if autonegotiation is enabled/desired. 115 * @an_complete: true if autonegotiation has c 43 * @an_complete: true if autonegotiation has completed. 116 */ 44 */ 117 struct phylink_link_state { 45 struct phylink_link_state { 118 __ETHTOOL_DECLARE_LINK_MODE_MASK(adver 46 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); 119 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_ad 47 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); 120 phy_interface_t interface; 48 phy_interface_t interface; 121 int speed; 49 int speed; 122 int duplex; 50 int duplex; 123 int pause; 51 int pause; 124 int rate_matching; << 125 unsigned int link:1; 52 unsigned int link:1; >> 53 unsigned int an_enabled:1; 126 unsigned int an_complete:1; 54 unsigned int an_complete:1; 127 }; 55 }; 128 56 129 enum phylink_op_type { << 130 PHYLINK_NETDEV = 0, << 131 PHYLINK_DEV, << 132 }; << 133 << 134 /** << 135 * struct phylink_config - PHYLINK configurati << 136 * @dev: a pointer to a struct device associat << 137 * @type: operation type of PHYLINK instance << 138 * @poll_fixed_state: if true, starts link_pol << 139 * if MAC link is at %MLO_A << 140 * @mac_managed_pm: if true, indicate the MAC << 141 * @mac_requires_rxc: if true, the MAC always << 142 * The PHY driver should st << 143 * possible and avoid stopp << 144 * @default_an_inband: if true, defaults to ML << 145 * MLO_AN_PHY. A fixed-lin << 146 * @get_fixed_state: callback to execute to de << 147 * if MAC link is at %MLO_AN << 148 * @supported_interfaces: bitmap describing wh << 149 * are supported by the << 150 * @mac_capabilities: MAC pause/speed/duplex c << 151 */ << 152 struct phylink_config { << 153 struct device *dev; << 154 enum phylink_op_type type; << 155 bool poll_fixed_state; << 156 bool mac_managed_pm; << 157 bool mac_requires_rxc; << 158 bool default_an_inband; << 159 void (*get_fixed_state)(struct phylink << 160 struct phylink << 161 DECLARE_PHY_INTERFACE_MASK(supported_i << 162 unsigned long mac_capabilities; << 163 }; << 164 << 165 void phylink_limit_mac_speed(struct phylink_co << 166 << 167 /** 57 /** 168 * struct phylink_mac_ops - MAC operations str 58 * struct phylink_mac_ops - MAC operations structure. 169 * @mac_get_caps: Get MAC capabilities for int !! 59 * @validate: Validate and update the link configuration. 170 * @mac_select_pcs: Select a PCS for the inter !! 60 * @mac_link_state: Read the current link state from the hardware. 171 * @mac_prepare: prepare for a major reconfigu << 172 * @mac_config: configure the MAC for the sele 61 * @mac_config: configure the MAC for the selected mode and state. 173 * @mac_finish: finish a major reconfiguration !! 62 * @mac_an_restart: restart 802.3z BaseX autonegotiation. 174 * @mac_link_down: take the link down. 63 * @mac_link_down: take the link down. 175 * @mac_link_up: allow the link to come up. 64 * @mac_link_up: allow the link to come up. 176 * 65 * 177 * The individual methods are described more f 66 * The individual methods are described more fully below. 178 */ 67 */ 179 struct phylink_mac_ops { 68 struct phylink_mac_ops { 180 unsigned long (*mac_get_caps)(struct p !! 69 void (*validate)(struct net_device *ndev, unsigned long *supported, 181 phy_inte !! 70 struct phylink_link_state *state); 182 struct phylink_pcs *(*mac_select_pcs)( !! 71 int (*mac_link_state)(struct net_device *ndev, 183 !! 72 struct phylink_link_state *state); 184 int (*mac_prepare)(struct phylink_conf !! 73 void (*mac_config)(struct net_device *ndev, unsigned int mode, 185 phy_interface_t ifa << 186 void (*mac_config)(struct phylink_conf << 187 const struct phylin 74 const struct phylink_link_state *state); 188 int (*mac_finish)(struct phylink_confi !! 75 void (*mac_an_restart)(struct net_device *ndev); 189 phy_interface_t ifac !! 76 void (*mac_link_down)(struct net_device *ndev, unsigned int mode, 190 void (*mac_link_down)(struct phylink_c << 191 phy_interface_t 77 phy_interface_t interface); 192 void (*mac_link_up)(struct phylink_con !! 78 void (*mac_link_up)(struct net_device *ndev, unsigned int mode, 193 struct phy_device !! 79 phy_interface_t interface, 194 phy_interface_t in !! 80 struct phy_device *phy); 195 bool tx_pause, boo << 196 }; 81 }; 197 82 198 #if 0 /* For kernel-doc purposes only. */ 83 #if 0 /* For kernel-doc purposes only. */ 199 /** 84 /** 200 * mac_get_caps: Get MAC capabilities for inte !! 85 * validate - Validate and update the link configuration 201 * @config: a pointer to a &struct phylink_con !! 86 * @ndev: a pointer to a &struct net_device for the MAC. 202 * @interface: PHY interface mode. !! 87 * @supported: ethtool bitmask for supported link modes. 203 * !! 88 * @state: a pointer to a &struct phylink_link_state. 204 * Optional method. When not provided, config- !! 89 * 205 * When implemented, this returns the MAC capa !! 90 * Clear bits in the @supported and @state->advertising masks that 206 * interface mode where there is some special !! 91 * are not supportable by the MAC. 207 * driver (e.g. not supporting half-duplex in !! 92 * 208 */ !! 93 * Note that the PHY may be able to transform from one connection 209 unsigned long mac_get_caps(struct phylink_conf !! 94 * technology to another, so, eg, don't clear 1000BaseX just 210 phy_interface_t int !! 95 * because the MAC is unable to BaseX mode. This is more about 211 /** !! 96 * clearing unsupported speeds and duplex settings. 212 * mac_select_pcs: Select a PCS for the interf !! 97 * 213 * @config: a pointer to a &struct phylink_con !! 98 * If the @state->interface mode is %PHY_INTERFACE_MODE_1000BASEX 214 * @interface: PHY interface mode for PCS !! 99 * or %PHY_INTERFACE_MODE_2500BASEX, select the appropriate mode 215 * !! 100 * based on @state->advertising and/or @state->speed and update 216 * Return the &struct phylink_pcs for the spec !! 101 * @state->interface accordingly. 217 * NULL if none is required, or an error point << 218 * << 219 * This must not modify any state. It is used << 220 * be used. Phylink will use this during valid << 221 * configuration is valid, and when setting a << 222 * set the PCS that will be used. << 223 */ 102 */ 224 struct phylink_pcs *mac_select_pcs(struct phyl !! 103 void validate(struct net_device *ndev, unsigned long *supported, 225 phy_interfa !! 104 struct phylink_link_state *state); 226 105 227 /** 106 /** 228 * mac_prepare() - prepare to change the PHY i !! 107 * mac_link_state() - Read the current link state from the hardware 229 * @config: a pointer to a &struct phylink_con !! 108 * @ndev: a pointer to a &struct net_device for the MAC. 230 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, % !! 109 * @state: a pointer to a &struct phylink_link_state. 231 * @iface: interface mode to switch to << 232 * << 233 * phylink will call this method at the beginn << 234 * of the link, which includes changing the in << 235 * startup time. It may be called for the curr << 236 * should perform whatever actions are require << 237 * Serdes PHY. << 238 * << 239 * This will be the first call in the sequence << 240 * - mac_prepare() << 241 * - mac_config() << 242 * - pcs_config() << 243 * - possible pcs_an_restart() << 244 * - mac_finish() << 245 * 110 * 246 * Returns zero on success, or negative errno !! 111 * Read the current link state from the MAC, reporting the current 247 * reported to the kernel log. !! 112 * speed in @state->speed, duplex mode in @state->duplex, pause mode >> 113 * in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits, >> 114 * negotiation completion state in @state->an_complete, and link >> 115 * up state in @state->link. 248 */ 116 */ 249 int mac_prepare(struct phylink_config *config, !! 117 int mac_link_state(struct net_device *ndev, 250 phy_interface_t iface); !! 118 struct phylink_link_state *state); 251 119 252 /** 120 /** 253 * mac_config() - configure the MAC for the se 121 * mac_config() - configure the MAC for the selected mode and state 254 * @config: a pointer to a &struct phylink_con !! 122 * @ndev: a pointer to a &struct net_device for the MAC. 255 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, % 123 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. 256 * @state: a pointer to a &struct phylink_link 124 * @state: a pointer to a &struct phylink_link_state. 257 * 125 * 258 * Note - not all members of @state are valid. << 259 * @state->lp_advertising, @state->link, @stat << 260 * guaranteed to be correct, and so any mac_co << 261 * never reference these fields. << 262 * << 263 * This will only be called to reconfigure the << 264 * e.g. interface mode. It will not be called << 265 * or pause modes or to change the in-band adv << 266 * << 267 * In all negotiation modes, as defined by @mo << 268 * pause settings which should be applied as f << 269 * set, %MLO_PAUSE_TX and %MLO_PAUSE_RX indica << 270 * pause frames and/or act on received pause f << 271 * the results of in-band negotiation/status f << 272 * to control the MAC pause mode settings. << 273 * << 274 * The action performed depends on the current 126 * The action performed depends on the currently selected mode: 275 * 127 * 276 * %MLO_AN_FIXED, %MLO_AN_PHY: 128 * %MLO_AN_FIXED, %MLO_AN_PHY: 277 * Configure for non-inband negotiation mode !! 129 * Configure the specified @state->speed, @state->duplex and 278 * are completely communicated via mac_link_ !! 130 * @state->pause (%MLO_PAUSE_TX / %MLO_PAUSE_RX) mode. 279 * protocol from the MAC is specified by @st << 280 * << 281 * @state->advertising may be used, but is n << 282 * << 283 * Older drivers (prior to the mac_link_up() << 284 * @state->duplex and @state->pause to confi << 285 * deprecated; such drivers should be conver << 286 * << 287 * Other members of @state must be ignored. << 288 * << 289 * Valid state members: interface, advertisi << 290 * Deprecated state members: speed, duplex, << 291 * 131 * 292 * %MLO_AN_INBAND: 132 * %MLO_AN_INBAND: 293 * place the link in an inband negotiation m 133 * place the link in an inband negotiation mode (such as 802.3z 294 * 1000base-X or Cisco SGMII mode depending 134 * 1000base-X or Cisco SGMII mode depending on the @state->interface 295 * mode). In both cases, link state manageme 135 * mode). In both cases, link state management (whether the link 296 * is up or not) is performed by the MAC, an 136 * is up or not) is performed by the MAC, and reported via the 297 * pcs_get_state() callback. Changes in link !! 137 * mac_link_state() callback. Changes in link state must be made 298 * by calling phylink_mac_change(). 138 * by calling phylink_mac_change(). 299 * 139 * 300 * Interface mode specific details are menti << 301 * << 302 * If in 802.3z mode, the link speed is fixe 140 * If in 802.3z mode, the link speed is fixed, dependent on the 303 * @state->interface. Duplex and pause modes !! 141 * @state->interface. Duplex is negotiated, and pause is advertised 304 * the in-band configuration word. Advertise !! 142 * according to @state->an_enabled, @state->pause and 305 * according to the @state->an_enabled and @ !! 143 * @state->advertising flags. Beware of MACs which only support full 306 * flags. Beware of MACs which only support !! 144 * duplex at gigabit and higher speeds. 307 * and higher speeds. << 308 * 145 * 309 * If in Cisco SGMII mode, the link speed an 146 * If in Cisco SGMII mode, the link speed and duplex mode are passed 310 * in the serial bitstream 16-bit configurat 147 * in the serial bitstream 16-bit configuration word, and the MAC 311 * should be configured to read these bits a 148 * should be configured to read these bits and acknowledge the 312 * configuration word. Nothing is advertised 149 * configuration word. Nothing is advertised by the MAC. The MAC is 313 * responsible for reading the configuration 150 * responsible for reading the configuration word and configuring 314 * itself accordingly. 151 * itself accordingly. 315 * 152 * 316 * Valid state members: interface, an_enable << 317 * << 318 * Implementations are expected to update the 153 * Implementations are expected to update the MAC to reflect the 319 * requested settings - i.o.w., if nothing has 154 * requested settings - i.o.w., if nothing has changed between two 320 * calls, no action is expected. If only flow 155 * calls, no action is expected. If only flow control settings have 321 * changed, flow control should be updated *wi 156 * changed, flow control should be updated *without* taking the link 322 * down. This "update" behaviour is critical 157 * down. This "update" behaviour is critical to avoid bouncing the 323 * link up status. 158 * link up status. 324 */ 159 */ 325 void mac_config(struct phylink_config *config, !! 160 void mac_config(struct net_device *ndev, unsigned int mode, 326 const struct phylink_link_stat 161 const struct phylink_link_state *state); 327 162 328 /** 163 /** 329 * mac_finish() - finish a to change the PHY i !! 164 * mac_an_restart() - restart 802.3z BaseX autonegotiation 330 * @config: a pointer to a &struct phylink_con !! 165 * @ndev: a pointer to a &struct net_device for the MAC. 331 * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, % << 332 * @iface: interface mode to switch to << 333 * << 334 * phylink will call this if it called mac_pre << 335 * complete any necessary steps after the MAC << 336 * for the @mode and @iface. E.g. a MAC driver << 337 * Serdes PHY here if it was previously disabl << 338 * << 339 * Returns zero on success, or negative errno << 340 * reported to the kernel log. << 341 */ 166 */ 342 int mac_finish(struct phylink_config *config, !! 167 void mac_an_restart(struct net_device *ndev); 343 phy_interface_t iface); << 344 168 345 /** 169 /** 346 * mac_link_down() - take the link down 170 * mac_link_down() - take the link down 347 * @config: a pointer to a &struct phylink_con !! 171 * @ndev: a pointer to a &struct net_device for the MAC. 348 * @mode: link autonegotiation mode 172 * @mode: link autonegotiation mode 349 * @interface: link &typedef phy_interface_t m 173 * @interface: link &typedef phy_interface_t mode 350 * 174 * 351 * If @mode is not an in-band negotiation mode 175 * If @mode is not an in-band negotiation mode (as defined by 352 * phylink_autoneg_inband()), force the link d 176 * phylink_autoneg_inband()), force the link down and disable any 353 * Energy Efficient Ethernet MAC configuration 177 * Energy Efficient Ethernet MAC configuration. Interface type 354 * selection must be done in mac_config(). 178 * selection must be done in mac_config(). 355 */ 179 */ 356 void mac_link_down(struct phylink_config *conf !! 180 void mac_link_down(struct net_device *ndev, unsigned int mode, 357 phy_interface_t interface); 181 phy_interface_t interface); 358 182 359 /** 183 /** 360 * mac_link_up() - allow the link to come up 184 * mac_link_up() - allow the link to come up 361 * @config: a pointer to a &struct phylink_con !! 185 * @ndev: a pointer to a &struct net_device for the MAC. 362 * @phy: any attached phy << 363 * @mode: link autonegotiation mode 186 * @mode: link autonegotiation mode 364 * @interface: link &typedef phy_interface_t m 187 * @interface: link &typedef phy_interface_t mode 365 * @speed: link speed !! 188 * @phy: any attached phy 366 * @duplex: link duplex << 367 * @tx_pause: link transmit pause enablement s << 368 * @rx_pause: link receive pause enablement st << 369 * << 370 * Configure the MAC for an established link. << 371 * << 372 * @speed, @duplex, @tx_pause and @rx_pause in << 373 * settings, and should be used to configure t << 374 * where these settings are not automatically << 375 * or if in-band negotiation (as defined by ph << 376 * is disabled. << 377 * << 378 * Note that when 802.3z in-band negotiation i << 379 * that the user wishes to override the pause << 380 * be allowed when considering the implementat << 381 * 189 * 382 * If in-band negotiation mode is disabled, al !! 190 * If @mode is not an in-band negotiation mode (as defined by 383 * @phy is non-%NULL, configure Energy Efficie !! 191 * phylink_autoneg_inband()), allow the link to come up. If @phy >> 192 * is non-%NULL, configure Energy Efficient Ethernet by calling 384 * phy_init_eee() and perform appropriate MAC 193 * phy_init_eee() and perform appropriate MAC configuration for EEE. 385 * Interface type selection must be done in ma 194 * Interface type selection must be done in mac_config(). 386 */ 195 */ 387 void mac_link_up(struct phylink_config *config !! 196 void mac_link_up(struct net_device *ndev, unsigned int mode, 388 unsigned int mode, phy_interf !! 197 phy_interface_t interface, 389 int speed, int duplex, bool t !! 198 struct phy_device *phy); 390 #endif 199 #endif 391 200 392 struct phylink_pcs_ops; !! 201 struct phylink *phylink_create(struct net_device *, struct fwnode_handle *, 393 !! 202 phy_interface_t iface, const struct phylink_mac_ops *ops); 394 /** << 395 * struct phylink_pcs - PHYLINK PCS instance << 396 * @ops: a pointer to the &struct phylink_pcs_ << 397 * @phylink: pointer to &struct phylink_config << 398 * @neg_mode: provide PCS neg mode via "mode" << 399 * @poll: poll the PCS for link changes << 400 * @rxc_always_on: The MAC driver requires the << 401 * to always be on. Standalone << 402 * do not have access to a PHY << 403 * this instead of PHY_F_RXC_A << 404 * << 405 * This structure is designed to be embedded w << 406 * and will be passed between phylink and the << 407 * << 408 * The @phylink member is private to phylink a << 409 * the PCS driver. << 410 */ << 411 struct phylink_pcs { << 412 const struct phylink_pcs_ops *ops; << 413 struct phylink *phylink; << 414 bool neg_mode; << 415 bool poll; << 416 bool rxc_always_on; << 417 }; << 418 << 419 /** << 420 * struct phylink_pcs_ops - MAC PCS operations << 421 * @pcs_validate: validate the link configurat << 422 * @pcs_enable: enable the PCS. << 423 * @pcs_disable: disable the PCS. << 424 * @pcs_pre_config: pre-mac_config method (for << 425 * @pcs_post_config: post-mac_config method (f << 426 * @pcs_get_state: read the current MAC PCS li << 427 * @pcs_config: configure the MAC PCS for the << 428 * @pcs_an_restart: restart 802.3z BaseX auton << 429 * @pcs_link_up: program the PCS for the resol << 430 * (where necessary). << 431 * @pcs_pre_init: configure PCS components nec << 432 * initialization e.g. RX clock << 433 */ << 434 struct phylink_pcs_ops { << 435 int (*pcs_validate)(struct phylink_pcs << 436 const struct phyli << 437 int (*pcs_enable)(struct phylink_pcs * << 438 void (*pcs_disable)(struct phylink_pcs << 439 void (*pcs_pre_config)(struct phylink_ << 440 phy_interface_t << 441 int (*pcs_post_config)(struct phylink_ << 442 phy_interface_t << 443 void (*pcs_get_state)(struct phylink_p << 444 struct phylink_l << 445 int (*pcs_config)(struct phylink_pcs * << 446 phy_interface_t inte << 447 const unsigned long << 448 bool permit_pause_to << 449 void (*pcs_an_restart)(struct phylink_ << 450 void (*pcs_link_up)(struct phylink_pcs << 451 phy_interface_t in << 452 int (*pcs_pre_init)(struct phylink_pcs << 453 }; << 454 << 455 #if 0 /* For kernel-doc purposes only. */ << 456 /** << 457 * pcs_validate() - validate the link configur << 458 * @pcs: a pointer to a &struct phylink_pcs. << 459 * @supported: ethtool bitmask for supported l << 460 * @state: a const pointer to a &struct phylin << 461 * << 462 * Validate the interface mode, and advertisin << 463 * media ethtool link modes that would not be << 464 * mask. Phylink will propagate the changes to << 465 * &struct phylink_mac_ops validate() method. << 466 * << 467 * Returns -EINVAL if the interface mode/auton << 468 * Returns non-zero positive if the link state << 469 */ << 470 int pcs_validate(struct phylink_pcs *pcs, unsi << 471 const struct phylink_link_sta << 472 << 473 /** << 474 * pcs_enable() - enable the PCS. << 475 * @pcs: a pointer to a &struct phylink_pcs. << 476 */ << 477 int pcs_enable(struct phylink_pcs *pcs); << 478 << 479 /** << 480 * pcs_disable() - disable the PCS. << 481 * @pcs: a pointer to a &struct phylink_pcs. << 482 */ << 483 void pcs_disable(struct phylink_pcs *pcs); << 484 << 485 /** << 486 * pcs_get_state() - Read the current inband l << 487 * @pcs: a pointer to a &struct phylink_pcs. << 488 * @state: a pointer to a &struct phylink_link << 489 * << 490 * Read the current inband link state from the << 491 * current speed in @state->speed, duplex mode << 492 * mode in @state->pause using the %MLO_PAUSE_ << 493 * negotiation completion state in @state->an_ << 494 * in @state->link. If possible, @state->lp_ad << 495 * populated. << 496 */ << 497 void pcs_get_state(struct phylink_pcs *pcs, << 498 struct phylink_link_state * << 499 << 500 /** << 501 * pcs_config() - Configure the PCS mode and a << 502 * @pcs: a pointer to a &struct phylink_pcs. << 503 * @neg_mode: link negotiation mode (see below << 504 * @interface: interface mode to be used << 505 * @advertising: adertisement ethtool link mod << 506 * @permit_pause_to_mac: permit forwarding pau << 507 * << 508 * Configure the PCS for the operating mode, t << 509 * the advertisement mask. @permit_pause_to_ma << 510 * hardware may forward the pause mode resolut << 511 * << 512 * When operating in %MLO_AN_INBAND, inband sh << 513 * otherwise inband should be disabled. << 514 * << 515 * For SGMII, there is no advertisement from t << 516 * be programmed to acknowledge the inband wor << 517 * << 518 * For 1000BASE-X, the advertisement should be << 519 * << 520 * For most 10GBASE-R, there is no advertiseme << 521 * << 522 * The %neg_mode argument should be tested via << 523 * functions, or for PCS that set pcs->neg_mod << 524 * against the PHYLINK_PCS_NEG_* definitions. << 525 */ << 526 int pcs_config(struct phylink_pcs *pcs, unsign << 527 phy_interface_t interface, cons << 528 bool permit_pause_to_mac); << 529 << 530 /** << 531 * pcs_an_restart() - restart 802.3z BaseX aut << 532 * @pcs: a pointer to a &struct phylink_pcs. << 533 * << 534 * When PCS ops are present, this overrides ma << 535 * phylink_mac_ops. << 536 */ << 537 void pcs_an_restart(struct phylink_pcs *pcs); << 538 << 539 /** << 540 * pcs_link_up() - program the PCS for the res << 541 * @pcs: a pointer to a &struct phylink_pcs. << 542 * @neg_mode: link negotiation mode (see below << 543 * @interface: link &typedef phy_interface_t m << 544 * @speed: link speed << 545 * @duplex: link duplex << 546 * << 547 * This call will be made just before mac_link << 548 * the resolved link parameters. For example, << 549 * mode without in-band AN needs to be manuall << 550 * and duplex setting. Otherwise, this should << 551 * << 552 * The %mode argument should be tested via the << 553 * functions, or for PCS that set pcs->neg_mod << 554 * against the PHYLINK_PCS_NEG_* definitions. << 555 */ << 556 void pcs_link_up(struct phylink_pcs *pcs, unsi << 557 phy_interface_t interface, in << 558 << 559 /** << 560 * pcs_pre_init() - Configure PCS components n << 561 * @pcs: a pointer to a &struct phylink_pcs. << 562 * << 563 * This function can be called by MAC drivers << 564 * phylink_pcs_pre_init() wrapper, before thei << 565 * should not be called after the link is brou << 566 * at this point could break the link. << 567 * << 568 * Some MAC devices require specific hardware << 569 * their associated PCS device before they can << 570 * hardware. An example of this is the initial << 571 * which requires an active REF_CLK signal to << 572 * << 573 * By calling phylink_pcs_pre_init(), MAC driv << 574 * setup in a way that allows for successful h << 575 * << 576 * The specific configuration performed by pcs << 577 * model of PCS and the requirements of the MA << 578 * driver authors should consider whether thei << 579 * conjunction with a MAC device whose driver << 580 * driver authors should document their requir << 581 * pre-initialization. << 582 * << 583 */ << 584 int pcs_pre_init(struct phylink_pcs *pcs); << 585 << 586 #endif << 587 << 588 struct phylink *phylink_create(struct phylink_ << 589 const struct fw << 590 phy_interface_t << 591 const struct ph << 592 void phylink_destroy(struct phylink *); 203 void phylink_destroy(struct phylink *); 593 bool phylink_expects_phy(struct phylink *pl); << 594 204 595 int phylink_connect_phy(struct phylink *, stru 205 int phylink_connect_phy(struct phylink *, struct phy_device *); 596 int phylink_of_phy_connect(struct phylink *, s 206 int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); 597 int phylink_fwnode_phy_connect(struct phylink << 598 const struct fw << 599 u32 flags); << 600 void phylink_disconnect_phy(struct phylink *); 207 void phylink_disconnect_phy(struct phylink *); 601 int phylink_set_fixed_link(struct phylink *, !! 208 int phylink_fixed_state_cb(struct phylink *, 602 const struct phylin !! 209 void (*cb)(struct net_device *dev, >> 210 struct phylink_link_state *)); 603 211 604 void phylink_mac_change(struct phylink *, bool 212 void phylink_mac_change(struct phylink *, bool up); 605 void phylink_pcs_change(struct phylink_pcs *, << 606 << 607 int phylink_pcs_pre_init(struct phylink *pl, s << 608 213 609 void phylink_start(struct phylink *); 214 void phylink_start(struct phylink *); 610 void phylink_stop(struct phylink *); 215 void phylink_stop(struct phylink *); 611 216 612 void phylink_suspend(struct phylink *pl, bool << 613 void phylink_resume(struct phylink *pl); << 614 << 615 void phylink_ethtool_get_wol(struct phylink *, 217 void phylink_ethtool_get_wol(struct phylink *, struct ethtool_wolinfo *); 616 int phylink_ethtool_set_wol(struct phylink *, 218 int phylink_ethtool_set_wol(struct phylink *, struct ethtool_wolinfo *); 617 219 618 int phylink_ethtool_ksettings_get(struct phyli 220 int phylink_ethtool_ksettings_get(struct phylink *, 619 struct ethto 221 struct ethtool_link_ksettings *); 620 int phylink_ethtool_ksettings_set(struct phyli 222 int phylink_ethtool_ksettings_set(struct phylink *, 621 const struct 223 const struct ethtool_link_ksettings *); 622 int phylink_ethtool_nway_reset(struct phylink 224 int phylink_ethtool_nway_reset(struct phylink *); 623 void phylink_ethtool_get_pauseparam(struct phy 225 void phylink_ethtool_get_pauseparam(struct phylink *, 624 struct eth 226 struct ethtool_pauseparam *); 625 int phylink_ethtool_set_pauseparam(struct phyl 227 int phylink_ethtool_set_pauseparam(struct phylink *, 626 struct etht 228 struct ethtool_pauseparam *); 627 int phylink_get_eee_err(struct phylink *); 229 int phylink_get_eee_err(struct phylink *); 628 int phylink_init_eee(struct phylink *, bool); 230 int phylink_init_eee(struct phylink *, bool); 629 int phylink_ethtool_get_eee(struct phylink *li !! 231 int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *); 630 int phylink_ethtool_set_eee(struct phylink *li !! 232 int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *); 631 int phylink_mii_ioctl(struct phylink *, struct 233 int phylink_mii_ioctl(struct phylink *, struct ifreq *, int); 632 int phylink_speed_down(struct phylink *pl, boo << 633 int phylink_speed_up(struct phylink *pl); << 634 234 635 #define phylink_zero(bm) \ 235 #define phylink_zero(bm) \ 636 bitmap_zero(bm, __ETHTOOL_LINK_MODE_MA 236 bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS) 637 #define __phylink_do_bit(op, bm, mode) \ 237 #define __phylink_do_bit(op, bm, mode) \ 638 op(ETHTOOL_LINK_MODE_ ## mode ## _BIT, 238 op(ETHTOOL_LINK_MODE_ ## mode ## _BIT, bm) 639 239 640 #define phylink_set(bm, mode) __phylink_do_b 240 #define phylink_set(bm, mode) __phylink_do_bit(__set_bit, bm, mode) 641 #define phylink_clear(bm, mode) __phylink_do_b 241 #define phylink_clear(bm, mode) __phylink_do_bit(__clear_bit, bm, mode) 642 #define phylink_test(bm, mode) __phylink_do_b 242 #define phylink_test(bm, mode) __phylink_do_bit(test_bit, bm, mode) 643 243 644 void phylink_set_port_modes(unsigned long *bit 244 void phylink_set_port_modes(unsigned long *bits); >> 245 void phylink_helper_basex_speed(struct phylink_link_state *state); 645 246 646 /** << 647 * phylink_get_link_timer_ns - return the PCS << 648 * @interface: link &typedef phy_interface_t m << 649 * << 650 * Return the PCS link timer setting in nanose << 651 * mode, or -EINVAL if not appropriate. << 652 */ << 653 static inline int phylink_get_link_timer_ns(ph << 654 { << 655 switch (interface) { << 656 case PHY_INTERFACE_MODE_SGMII: << 657 case PHY_INTERFACE_MODE_QSGMII: << 658 case PHY_INTERFACE_MODE_USXGMII: << 659 case PHY_INTERFACE_MODE_10G_QXGMII: << 660 return 1600000; << 661 << 662 case PHY_INTERFACE_MODE_1000BASEX: << 663 case PHY_INTERFACE_MODE_2500BASEX: << 664 return 10000000; << 665 << 666 default: << 667 return -EINVAL; << 668 } << 669 } << 670 << 671 void phylink_mii_c22_pcs_decode_state(struct p << 672 u16 bmsr << 673 void phylink_mii_c22_pcs_get_state(struct mdio << 674 struct phyl << 675 int phylink_mii_c22_pcs_encode_advertisement(p << 676 c << 677 int phylink_mii_c22_pcs_config(struct mdio_dev << 678 phy_interface_t << 679 const unsigned << 680 unsigned int ne << 681 void phylink_mii_c22_pcs_an_restart(struct mdi << 682 << 683 void phylink_resolve_c73(struct phylink_link_s << 684 << 685 void phylink_mii_c45_pcs_get_state(struct mdio << 686 struct phyl << 687 << 688 void phylink_decode_usxgmii_word(struct phylin << 689 uint16_t lpa) << 690 #endif 247 #endif 691 248
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.