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