.. | .. |
---|
12 | 12 | |
---|
13 | 13 | enum { |
---|
14 | 14 | MLO_PAUSE_NONE, |
---|
15 | | - MLO_PAUSE_ASYM = BIT(0), |
---|
16 | | - MLO_PAUSE_SYM = BIT(1), |
---|
17 | | - MLO_PAUSE_RX = BIT(2), |
---|
18 | | - MLO_PAUSE_TX = BIT(3), |
---|
| 15 | + MLO_PAUSE_RX = BIT(0), |
---|
| 16 | + MLO_PAUSE_TX = BIT(1), |
---|
19 | 17 | MLO_PAUSE_TXRX_MASK = MLO_PAUSE_TX | MLO_PAUSE_RX, |
---|
20 | | - MLO_PAUSE_AN = BIT(4), |
---|
| 18 | + MLO_PAUSE_AN = BIT(2), |
---|
21 | 19 | |
---|
22 | 20 | MLO_AN_PHY = 0, /* Conventional PHY */ |
---|
23 | 21 | MLO_AN_FIXED, /* Fixed-link mode */ |
---|
.. | .. |
---|
54 | 52 | unsigned int an_complete:1; |
---|
55 | 53 | }; |
---|
56 | 54 | |
---|
| 55 | +enum phylink_op_type { |
---|
| 56 | + PHYLINK_NETDEV = 0, |
---|
| 57 | + PHYLINK_DEV, |
---|
| 58 | +}; |
---|
| 59 | + |
---|
| 60 | +/** |
---|
| 61 | + * struct phylink_config - PHYLINK configuration structure |
---|
| 62 | + * @dev: a pointer to a struct device associated with the MAC |
---|
| 63 | + * @type: operation type of PHYLINK instance |
---|
| 64 | + * @pcs_poll: MAC PCS cannot provide link change interrupt |
---|
| 65 | + * @poll_fixed_state: if true, starts link_poll, |
---|
| 66 | + * if MAC link is at %MLO_AN_FIXED mode. |
---|
| 67 | + * @get_fixed_state: callback to execute to determine the fixed link state, |
---|
| 68 | + * if MAC link is at %MLO_AN_FIXED mode. |
---|
| 69 | + */ |
---|
| 70 | +struct phylink_config { |
---|
| 71 | + struct device *dev; |
---|
| 72 | + enum phylink_op_type type; |
---|
| 73 | + bool pcs_poll; |
---|
| 74 | + bool poll_fixed_state; |
---|
| 75 | + void (*get_fixed_state)(struct phylink_config *config, |
---|
| 76 | + struct phylink_link_state *state); |
---|
| 77 | +}; |
---|
| 78 | + |
---|
57 | 79 | /** |
---|
58 | 80 | * struct phylink_mac_ops - MAC operations structure. |
---|
59 | 81 | * @validate: Validate and update the link configuration. |
---|
60 | | - * @mac_link_state: Read the current link state from the hardware. |
---|
| 82 | + * @mac_pcs_get_state: Read the current link state from the hardware. |
---|
| 83 | + * @mac_prepare: prepare for a major reconfiguration of the interface. |
---|
61 | 84 | * @mac_config: configure the MAC for the selected mode and state. |
---|
| 85 | + * @mac_finish: finish a major reconfiguration of the interface. |
---|
62 | 86 | * @mac_an_restart: restart 802.3z BaseX autonegotiation. |
---|
63 | 87 | * @mac_link_down: take the link down. |
---|
64 | 88 | * @mac_link_up: allow the link to come up. |
---|
.. | .. |
---|
66 | 90 | * The individual methods are described more fully below. |
---|
67 | 91 | */ |
---|
68 | 92 | struct phylink_mac_ops { |
---|
69 | | - void (*validate)(struct net_device *ndev, unsigned long *supported, |
---|
| 93 | + void (*validate)(struct phylink_config *config, |
---|
| 94 | + unsigned long *supported, |
---|
70 | 95 | struct phylink_link_state *state); |
---|
71 | | - int (*mac_link_state)(struct net_device *ndev, |
---|
72 | | - struct phylink_link_state *state); |
---|
73 | | - void (*mac_config)(struct net_device *ndev, unsigned int mode, |
---|
| 96 | + void (*mac_pcs_get_state)(struct phylink_config *config, |
---|
| 97 | + struct phylink_link_state *state); |
---|
| 98 | + int (*mac_prepare)(struct phylink_config *config, unsigned int mode, |
---|
| 99 | + phy_interface_t iface); |
---|
| 100 | + void (*mac_config)(struct phylink_config *config, unsigned int mode, |
---|
74 | 101 | const struct phylink_link_state *state); |
---|
75 | | - void (*mac_an_restart)(struct net_device *ndev); |
---|
76 | | - void (*mac_link_down)(struct net_device *ndev, unsigned int mode, |
---|
| 102 | + int (*mac_finish)(struct phylink_config *config, unsigned int mode, |
---|
| 103 | + phy_interface_t iface); |
---|
| 104 | + void (*mac_an_restart)(struct phylink_config *config); |
---|
| 105 | + void (*mac_link_down)(struct phylink_config *config, unsigned int mode, |
---|
77 | 106 | phy_interface_t interface); |
---|
78 | | - void (*mac_link_up)(struct net_device *ndev, unsigned int mode, |
---|
79 | | - phy_interface_t interface, |
---|
80 | | - struct phy_device *phy); |
---|
| 107 | + void (*mac_link_up)(struct phylink_config *config, |
---|
| 108 | + struct phy_device *phy, unsigned int mode, |
---|
| 109 | + phy_interface_t interface, int speed, int duplex, |
---|
| 110 | + bool tx_pause, bool rx_pause); |
---|
81 | 111 | }; |
---|
82 | 112 | |
---|
83 | 113 | #if 0 /* For kernel-doc purposes only. */ |
---|
84 | 114 | /** |
---|
85 | 115 | * validate - Validate and update the link configuration |
---|
86 | | - * @ndev: a pointer to a &struct net_device for the MAC. |
---|
| 116 | + * @config: a pointer to a &struct phylink_config. |
---|
87 | 117 | * @supported: ethtool bitmask for supported link modes. |
---|
88 | 118 | * @state: a pointer to a &struct phylink_link_state. |
---|
89 | 119 | * |
---|
.. | .. |
---|
93 | 123 | * Note that the PHY may be able to transform from one connection |
---|
94 | 124 | * technology to another, so, eg, don't clear 1000BaseX just |
---|
95 | 125 | * because the MAC is unable to BaseX mode. This is more about |
---|
96 | | - * clearing unsupported speeds and duplex settings. |
---|
| 126 | + * clearing unsupported speeds and duplex settings. The port modes |
---|
| 127 | + * should not be cleared; phylink_set_port_modes() will help with this. |
---|
97 | 128 | * |
---|
98 | 129 | * If the @state->interface mode is %PHY_INTERFACE_MODE_1000BASEX |
---|
99 | 130 | * or %PHY_INTERFACE_MODE_2500BASEX, select the appropriate mode |
---|
100 | 131 | * based on @state->advertising and/or @state->speed and update |
---|
101 | | - * @state->interface accordingly. |
---|
| 132 | + * @state->interface accordingly. See phylink_helper_basex_speed(). |
---|
| 133 | + * |
---|
| 134 | + * When @state->interface is %PHY_INTERFACE_MODE_NA, phylink expects the |
---|
| 135 | + * MAC driver to return all supported link modes. |
---|
| 136 | + * |
---|
| 137 | + * If the @state->interface mode is not supported, then the @supported |
---|
| 138 | + * mask must be cleared. |
---|
102 | 139 | */ |
---|
103 | | -void validate(struct net_device *ndev, unsigned long *supported, |
---|
| 140 | +void validate(struct phylink_config *config, unsigned long *supported, |
---|
104 | 141 | struct phylink_link_state *state); |
---|
105 | 142 | |
---|
106 | 143 | /** |
---|
107 | | - * mac_link_state() - Read the current link state from the hardware |
---|
108 | | - * @ndev: a pointer to a &struct net_device for the MAC. |
---|
| 144 | + * mac_pcs_get_state() - Read the current inband link state from the hardware |
---|
| 145 | + * @config: a pointer to a &struct phylink_config. |
---|
109 | 146 | * @state: a pointer to a &struct phylink_link_state. |
---|
110 | 147 | * |
---|
111 | | - * Read the current link state from the MAC, reporting the current |
---|
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. |
---|
| 148 | + * Read the current inband link state from the MAC PCS, reporting the |
---|
| 149 | + * current speed in @state->speed, duplex mode in @state->duplex, pause |
---|
| 150 | + * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits, |
---|
| 151 | + * negotiation completion state in @state->an_complete, and link up state |
---|
| 152 | + * in @state->link. If possible, @state->lp_advertising should also be |
---|
| 153 | + * populated. |
---|
116 | 154 | */ |
---|
117 | | -int mac_link_state(struct net_device *ndev, |
---|
118 | | - struct phylink_link_state *state); |
---|
| 155 | +void mac_pcs_get_state(struct phylink_config *config, |
---|
| 156 | + struct phylink_link_state *state); |
---|
| 157 | + |
---|
| 158 | +/** |
---|
| 159 | + * mac_prepare() - prepare to change the PHY interface mode |
---|
| 160 | + * @config: a pointer to a &struct phylink_config. |
---|
| 161 | + * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. |
---|
| 162 | + * @iface: interface mode to switch to |
---|
| 163 | + * |
---|
| 164 | + * phylink will call this method at the beginning of a full initialisation |
---|
| 165 | + * of the link, which includes changing the interface mode or at initial |
---|
| 166 | + * startup time. It may be called for the current mode. The MAC driver |
---|
| 167 | + * should perform whatever actions are required, e.g. disabling the |
---|
| 168 | + * Serdes PHY. |
---|
| 169 | + * |
---|
| 170 | + * This will be the first call in the sequence: |
---|
| 171 | + * - mac_prepare() |
---|
| 172 | + * - mac_config() |
---|
| 173 | + * - pcs_config() |
---|
| 174 | + * - possible pcs_an_restart() |
---|
| 175 | + * - mac_finish() |
---|
| 176 | + * |
---|
| 177 | + * Returns zero on success, or negative errno on failure which will be |
---|
| 178 | + * reported to the kernel log. |
---|
| 179 | + */ |
---|
| 180 | +int mac_prepare(struct phylink_config *config, unsigned int mode, |
---|
| 181 | + phy_interface_t iface); |
---|
119 | 182 | |
---|
120 | 183 | /** |
---|
121 | 184 | * mac_config() - configure the MAC for the selected mode and state |
---|
122 | | - * @ndev: a pointer to a &struct net_device for the MAC. |
---|
| 185 | + * @config: a pointer to a &struct phylink_config. |
---|
123 | 186 | * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. |
---|
124 | 187 | * @state: a pointer to a &struct phylink_link_state. |
---|
| 188 | + * |
---|
| 189 | + * Note - not all members of @state are valid. In particular, |
---|
| 190 | + * @state->lp_advertising, @state->link, @state->an_complete are never |
---|
| 191 | + * guaranteed to be correct, and so any mac_config() implementation must |
---|
| 192 | + * never reference these fields. |
---|
| 193 | + * |
---|
| 194 | + * (this requires a rewrite - please refer to mac_link_up() for situations |
---|
| 195 | + * where the PCS and MAC are not tightly integrated.) |
---|
| 196 | + * |
---|
| 197 | + * In all negotiation modes, as defined by @mode, @state->pause indicates the |
---|
| 198 | + * pause settings which should be applied as follows. If %MLO_PAUSE_AN is not |
---|
| 199 | + * set, %MLO_PAUSE_TX and %MLO_PAUSE_RX indicate whether the MAC should send |
---|
| 200 | + * pause frames and/or act on received pause frames respectively. Otherwise, |
---|
| 201 | + * the results of in-band negotiation/status from the MAC PCS should be used |
---|
| 202 | + * to control the MAC pause mode settings. |
---|
125 | 203 | * |
---|
126 | 204 | * The action performed depends on the currently selected mode: |
---|
127 | 205 | * |
---|
128 | 206 | * %MLO_AN_FIXED, %MLO_AN_PHY: |
---|
129 | | - * Configure the specified @state->speed, @state->duplex and |
---|
130 | | - * @state->pause (%MLO_PAUSE_TX / %MLO_PAUSE_RX) mode. |
---|
| 207 | + * Configure for non-inband negotiation mode, where the link settings |
---|
| 208 | + * are completely communicated via mac_link_up(). The physical link |
---|
| 209 | + * protocol from the MAC is specified by @state->interface. |
---|
| 210 | + * |
---|
| 211 | + * @state->advertising may be used, but is not required. |
---|
| 212 | + * |
---|
| 213 | + * Older drivers (prior to the mac_link_up() change) may use @state->speed, |
---|
| 214 | + * @state->duplex and @state->pause to configure the MAC, but this is |
---|
| 215 | + * deprecated; such drivers should be converted to use mac_link_up(). |
---|
| 216 | + * |
---|
| 217 | + * Other members of @state must be ignored. |
---|
| 218 | + * |
---|
| 219 | + * Valid state members: interface, advertising. |
---|
| 220 | + * Deprecated state members: speed, duplex, pause. |
---|
131 | 221 | * |
---|
132 | 222 | * %MLO_AN_INBAND: |
---|
133 | 223 | * place the link in an inband negotiation mode (such as 802.3z |
---|
134 | 224 | * 1000base-X or Cisco SGMII mode depending on the @state->interface |
---|
135 | 225 | * mode). In both cases, link state management (whether the link |
---|
136 | 226 | * is up or not) is performed by the MAC, and reported via the |
---|
137 | | - * mac_link_state() callback. Changes in link state must be made |
---|
| 227 | + * mac_pcs_get_state() callback. Changes in link state must be made |
---|
138 | 228 | * by calling phylink_mac_change(). |
---|
139 | 229 | * |
---|
| 230 | + * Interface mode specific details are mentioned below. |
---|
| 231 | + * |
---|
140 | 232 | * If in 802.3z mode, the link speed is fixed, dependent on the |
---|
141 | | - * @state->interface. Duplex is negotiated, and pause is advertised |
---|
142 | | - * according to @state->an_enabled, @state->pause and |
---|
143 | | - * @state->advertising flags. Beware of MACs which only support full |
---|
144 | | - * duplex at gigabit and higher speeds. |
---|
| 233 | + * @state->interface. Duplex and pause modes are negotiated via |
---|
| 234 | + * the in-band configuration word. Advertised pause modes are set |
---|
| 235 | + * according to the @state->an_enabled and @state->advertising |
---|
| 236 | + * flags. Beware of MACs which only support full duplex at gigabit |
---|
| 237 | + * and higher speeds. |
---|
145 | 238 | * |
---|
146 | 239 | * If in Cisco SGMII mode, the link speed and duplex mode are passed |
---|
147 | 240 | * in the serial bitstream 16-bit configuration word, and the MAC |
---|
.. | .. |
---|
149 | 242 | * configuration word. Nothing is advertised by the MAC. The MAC is |
---|
150 | 243 | * responsible for reading the configuration word and configuring |
---|
151 | 244 | * itself accordingly. |
---|
| 245 | + * |
---|
| 246 | + * Valid state members: interface, an_enabled, pause, advertising. |
---|
| 247 | + * |
---|
| 248 | + * Implementations are expected to update the MAC to reflect the |
---|
| 249 | + * requested settings - i.o.w., if nothing has changed between two |
---|
| 250 | + * calls, no action is expected. If only flow control settings have |
---|
| 251 | + * changed, flow control should be updated *without* taking the link |
---|
| 252 | + * down. This "update" behaviour is critical to avoid bouncing the |
---|
| 253 | + * link up status. |
---|
152 | 254 | */ |
---|
153 | | -void mac_config(struct net_device *ndev, unsigned int mode, |
---|
| 255 | +void mac_config(struct phylink_config *config, unsigned int mode, |
---|
154 | 256 | const struct phylink_link_state *state); |
---|
155 | 257 | |
---|
156 | 258 | /** |
---|
157 | | - * mac_an_restart() - restart 802.3z BaseX autonegotiation |
---|
158 | | - * @ndev: a pointer to a &struct net_device for the MAC. |
---|
| 259 | + * mac_finish() - finish a to change the PHY interface mode |
---|
| 260 | + * @config: a pointer to a &struct phylink_config. |
---|
| 261 | + * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. |
---|
| 262 | + * @iface: interface mode to switch to |
---|
| 263 | + * |
---|
| 264 | + * phylink will call this if it called mac_prepare() to allow the MAC to |
---|
| 265 | + * complete any necessary steps after the MAC and PCS have been configured |
---|
| 266 | + * for the @mode and @iface. E.g. a MAC driver may wish to re-enable the |
---|
| 267 | + * Serdes PHY here if it was previously disabled by mac_prepare(). |
---|
| 268 | + * |
---|
| 269 | + * Returns zero on success, or negative errno on failure which will be |
---|
| 270 | + * reported to the kernel log. |
---|
159 | 271 | */ |
---|
160 | | -void mac_an_restart(struct net_device *ndev); |
---|
| 272 | +int mac_finish(struct phylink_config *config, unsigned int mode, |
---|
| 273 | + phy_interface_t iface); |
---|
| 274 | + |
---|
| 275 | +/** |
---|
| 276 | + * mac_an_restart() - restart 802.3z BaseX autonegotiation |
---|
| 277 | + * @config: a pointer to a &struct phylink_config. |
---|
| 278 | + */ |
---|
| 279 | +void mac_an_restart(struct phylink_config *config); |
---|
161 | 280 | |
---|
162 | 281 | /** |
---|
163 | 282 | * mac_link_down() - take the link down |
---|
164 | | - * @ndev: a pointer to a &struct net_device for the MAC. |
---|
| 283 | + * @config: a pointer to a &struct phylink_config. |
---|
165 | 284 | * @mode: link autonegotiation mode |
---|
166 | 285 | * @interface: link &typedef phy_interface_t mode |
---|
167 | 286 | * |
---|
.. | .. |
---|
170 | 289 | * Energy Efficient Ethernet MAC configuration. Interface type |
---|
171 | 290 | * selection must be done in mac_config(). |
---|
172 | 291 | */ |
---|
173 | | -void mac_link_down(struct net_device *ndev, unsigned int mode, |
---|
| 292 | +void mac_link_down(struct phylink_config *config, unsigned int mode, |
---|
174 | 293 | phy_interface_t interface); |
---|
175 | 294 | |
---|
176 | 295 | /** |
---|
177 | 296 | * mac_link_up() - allow the link to come up |
---|
178 | | - * @ndev: a pointer to a &struct net_device for the MAC. |
---|
| 297 | + * @config: a pointer to a &struct phylink_config. |
---|
| 298 | + * @phy: any attached phy |
---|
179 | 299 | * @mode: link autonegotiation mode |
---|
180 | 300 | * @interface: link &typedef phy_interface_t mode |
---|
181 | | - * @phy: any attached phy |
---|
| 301 | + * @speed: link speed |
---|
| 302 | + * @duplex: link duplex |
---|
| 303 | + * @tx_pause: link transmit pause enablement status |
---|
| 304 | + * @rx_pause: link receive pause enablement status |
---|
182 | 305 | * |
---|
183 | | - * If @mode is not an in-band negotiation mode (as defined by |
---|
184 | | - * phylink_autoneg_inband()), allow the link to come up. If @phy |
---|
185 | | - * is non-%NULL, configure Energy Efficient Ethernet by calling |
---|
| 306 | + * Configure the MAC for an established link. |
---|
| 307 | + * |
---|
| 308 | + * @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link |
---|
| 309 | + * settings, and should be used to configure the MAC block appropriately |
---|
| 310 | + * where these settings are not automatically conveyed from the PCS block, |
---|
| 311 | + * or if in-band negotiation (as defined by phylink_autoneg_inband(@mode)) |
---|
| 312 | + * is disabled. |
---|
| 313 | + * |
---|
| 314 | + * Note that when 802.3z in-band negotiation is in use, it is possible |
---|
| 315 | + * that the user wishes to override the pause settings, and this should |
---|
| 316 | + * be allowed when considering the implementation of this method. |
---|
| 317 | + * |
---|
| 318 | + * If in-band negotiation mode is disabled, allow the link to come up. If |
---|
| 319 | + * @phy is non-%NULL, configure Energy Efficient Ethernet by calling |
---|
186 | 320 | * phy_init_eee() and perform appropriate MAC configuration for EEE. |
---|
187 | 321 | * Interface type selection must be done in mac_config(). |
---|
188 | 322 | */ |
---|
189 | | -void mac_link_up(struct net_device *ndev, unsigned int mode, |
---|
190 | | - phy_interface_t interface, |
---|
191 | | - struct phy_device *phy); |
---|
| 323 | +void mac_link_up(struct phylink_config *config, struct phy_device *phy, |
---|
| 324 | + unsigned int mode, phy_interface_t interface, |
---|
| 325 | + int speed, int duplex, bool tx_pause, bool rx_pause); |
---|
192 | 326 | #endif |
---|
193 | 327 | |
---|
194 | | -struct phylink *phylink_create(struct net_device *, struct fwnode_handle *, |
---|
195 | | - phy_interface_t iface, const struct phylink_mac_ops *ops); |
---|
| 328 | +struct phylink_pcs_ops; |
---|
| 329 | + |
---|
| 330 | +/** |
---|
| 331 | + * struct phylink_pcs - PHYLINK PCS instance |
---|
| 332 | + * @ops: a pointer to the &struct phylink_pcs_ops structure |
---|
| 333 | + * @poll: poll the PCS for link changes |
---|
| 334 | + * |
---|
| 335 | + * This structure is designed to be embedded within the PCS private data, |
---|
| 336 | + * and will be passed between phylink and the PCS. |
---|
| 337 | + */ |
---|
| 338 | +struct phylink_pcs { |
---|
| 339 | + const struct phylink_pcs_ops *ops; |
---|
| 340 | + bool poll; |
---|
| 341 | +}; |
---|
| 342 | + |
---|
| 343 | +/** |
---|
| 344 | + * struct phylink_pcs_ops - MAC PCS operations structure. |
---|
| 345 | + * @pcs_get_state: read the current MAC PCS link state from the hardware. |
---|
| 346 | + * @pcs_config: configure the MAC PCS for the selected mode and state. |
---|
| 347 | + * @pcs_an_restart: restart 802.3z BaseX autonegotiation. |
---|
| 348 | + * @pcs_link_up: program the PCS for the resolved link configuration |
---|
| 349 | + * (where necessary). |
---|
| 350 | + */ |
---|
| 351 | +struct phylink_pcs_ops { |
---|
| 352 | + void (*pcs_get_state)(struct phylink_pcs *pcs, |
---|
| 353 | + struct phylink_link_state *state); |
---|
| 354 | + int (*pcs_config)(struct phylink_pcs *pcs, unsigned int mode, |
---|
| 355 | + phy_interface_t interface, |
---|
| 356 | + const unsigned long *advertising, |
---|
| 357 | + bool permit_pause_to_mac); |
---|
| 358 | + void (*pcs_an_restart)(struct phylink_pcs *pcs); |
---|
| 359 | + void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int mode, |
---|
| 360 | + phy_interface_t interface, int speed, int duplex); |
---|
| 361 | +}; |
---|
| 362 | + |
---|
| 363 | +#if 0 /* For kernel-doc purposes only. */ |
---|
| 364 | +/** |
---|
| 365 | + * pcs_get_state() - Read the current inband link state from the hardware |
---|
| 366 | + * @pcs: a pointer to a &struct phylink_pcs. |
---|
| 367 | + * @state: a pointer to a &struct phylink_link_state. |
---|
| 368 | + * |
---|
| 369 | + * Read the current inband link state from the MAC PCS, reporting the |
---|
| 370 | + * current speed in @state->speed, duplex mode in @state->duplex, pause |
---|
| 371 | + * mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits, |
---|
| 372 | + * negotiation completion state in @state->an_complete, and link up state |
---|
| 373 | + * in @state->link. If possible, @state->lp_advertising should also be |
---|
| 374 | + * populated. |
---|
| 375 | + * |
---|
| 376 | + * When present, this overrides mac_pcs_get_state() in &struct |
---|
| 377 | + * phylink_mac_ops. |
---|
| 378 | + */ |
---|
| 379 | +void pcs_get_state(struct phylink_pcs *pcs, |
---|
| 380 | + struct phylink_link_state *state); |
---|
| 381 | + |
---|
| 382 | +/** |
---|
| 383 | + * pcs_config() - Configure the PCS mode and advertisement |
---|
| 384 | + * @pcs: a pointer to a &struct phylink_pcs. |
---|
| 385 | + * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. |
---|
| 386 | + * @interface: interface mode to be used |
---|
| 387 | + * @advertising: adertisement ethtool link mode mask |
---|
| 388 | + * @permit_pause_to_mac: permit forwarding pause resolution to MAC |
---|
| 389 | + * |
---|
| 390 | + * Configure the PCS for the operating mode, the interface mode, and set |
---|
| 391 | + * the advertisement mask. @permit_pause_to_mac indicates whether the |
---|
| 392 | + * hardware may forward the pause mode resolution to the MAC. |
---|
| 393 | + * |
---|
| 394 | + * When operating in %MLO_AN_INBAND, inband should always be enabled, |
---|
| 395 | + * otherwise inband should be disabled. |
---|
| 396 | + * |
---|
| 397 | + * For SGMII, there is no advertisement from the MAC side, the PCS should |
---|
| 398 | + * be programmed to acknowledge the inband word from the PHY. |
---|
| 399 | + * |
---|
| 400 | + * For 1000BASE-X, the advertisement should be programmed into the PCS. |
---|
| 401 | + * |
---|
| 402 | + * For most 10GBASE-R, there is no advertisement. |
---|
| 403 | + */ |
---|
| 404 | +int pcs_config(struct phylink_pcs *pcs, unsigned int mode, |
---|
| 405 | + phy_interface_t interface, const unsigned long *advertising, |
---|
| 406 | + bool permit_pause_to_mac); |
---|
| 407 | + |
---|
| 408 | +/** |
---|
| 409 | + * pcs_an_restart() - restart 802.3z BaseX autonegotiation |
---|
| 410 | + * @pcs: a pointer to a &struct phylink_pcs. |
---|
| 411 | + * |
---|
| 412 | + * When PCS ops are present, this overrides mac_an_restart() in &struct |
---|
| 413 | + * phylink_mac_ops. |
---|
| 414 | + */ |
---|
| 415 | +void pcs_an_restart(struct phylink_pcs *pcs); |
---|
| 416 | + |
---|
| 417 | +/** |
---|
| 418 | + * pcs_link_up() - program the PCS for the resolved link configuration |
---|
| 419 | + * @pcs: a pointer to a &struct phylink_pcs. |
---|
| 420 | + * @mode: link autonegotiation mode |
---|
| 421 | + * @interface: link &typedef phy_interface_t mode |
---|
| 422 | + * @speed: link speed |
---|
| 423 | + * @duplex: link duplex |
---|
| 424 | + * |
---|
| 425 | + * This call will be made just before mac_link_up() to inform the PCS of |
---|
| 426 | + * the resolved link parameters. For example, a PCS operating in SGMII |
---|
| 427 | + * mode without in-band AN needs to be manually configured for the link |
---|
| 428 | + * and duplex setting. Otherwise, this should be a no-op. |
---|
| 429 | + */ |
---|
| 430 | +void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, |
---|
| 431 | + phy_interface_t interface, int speed, int duplex); |
---|
| 432 | +#endif |
---|
| 433 | + |
---|
| 434 | +struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, |
---|
| 435 | + phy_interface_t iface, |
---|
| 436 | + const struct phylink_mac_ops *mac_ops); |
---|
| 437 | +void phylink_set_pcs(struct phylink *, struct phylink_pcs *pcs); |
---|
196 | 438 | void phylink_destroy(struct phylink *); |
---|
197 | 439 | |
---|
198 | 440 | int phylink_connect_phy(struct phylink *, struct phy_device *); |
---|
199 | 441 | int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); |
---|
200 | 442 | void phylink_disconnect_phy(struct phylink *); |
---|
201 | | -int phylink_fixed_state_cb(struct phylink *, |
---|
202 | | - void (*cb)(struct net_device *dev, |
---|
203 | | - struct phylink_link_state *)); |
---|
204 | 443 | |
---|
205 | 444 | void phylink_mac_change(struct phylink *, bool up); |
---|
206 | 445 | |
---|
.. | .. |
---|
220 | 459 | int phylink_ethtool_set_pauseparam(struct phylink *, |
---|
221 | 460 | struct ethtool_pauseparam *); |
---|
222 | 461 | int phylink_get_eee_err(struct phylink *); |
---|
| 462 | +int phylink_init_eee(struct phylink *, bool); |
---|
223 | 463 | int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *); |
---|
224 | 464 | int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *); |
---|
225 | 465 | int phylink_mii_ioctl(struct phylink *, struct ifreq *, int); |
---|
| 466 | +int phylink_speed_down(struct phylink *pl, bool sync); |
---|
| 467 | +int phylink_speed_up(struct phylink *pl); |
---|
226 | 468 | |
---|
227 | 469 | #define phylink_zero(bm) \ |
---|
228 | 470 | bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS) |
---|
.. | .. |
---|
236 | 478 | void phylink_set_port_modes(unsigned long *bits); |
---|
237 | 479 | void phylink_helper_basex_speed(struct phylink_link_state *state); |
---|
238 | 480 | |
---|
| 481 | +void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs, |
---|
| 482 | + struct phylink_link_state *state); |
---|
| 483 | +int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs, |
---|
| 484 | + phy_interface_t interface, |
---|
| 485 | + const unsigned long *advertising); |
---|
| 486 | +int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode, |
---|
| 487 | + phy_interface_t interface, |
---|
| 488 | + const unsigned long *advertising); |
---|
| 489 | +void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs); |
---|
| 490 | + |
---|
| 491 | +void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs, |
---|
| 492 | + struct phylink_link_state *state); |
---|
| 493 | + |
---|
| 494 | +void phylink_decode_usxgmii_word(struct phylink_link_state *state, |
---|
| 495 | + uint16_t lpa); |
---|
239 | 496 | #endif |
---|