diff options
author | Jacob Keller <jacob.e.keller@intel.com> | 2012-06-08 02:59:17 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2012-06-20 04:37:14 -0400 |
commit | db01896398ae6beba41fc14f1a90d55fd21e6738 (patch) | |
tree | 4d7dbf4c475f10f409d1f3ba3430e573dad70b05 /drivers | |
parent | a49fda3eaa4fe70fdd14681060a7c6c6246dc927 (diff) |
ixgbe: clean up ixgbe_get_settings ethtool function
This patch cleans up the method used for determining the link speed of
devices. The old method re-wrote some logic already existing in a mac.ops
function which should be used instead. The result is much simpler to
understand and removes a strange double-check of logic, as well as reducing
code redundancy.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 147 |
1 files changed, 62 insertions, 85 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 3178f1ec3711..bbc7da5cdb4d 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | |||
@@ -154,100 +154,60 @@ static int ixgbe_get_settings(struct net_device *netdev, | |||
154 | { | 154 | { |
155 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | 155 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
156 | struct ixgbe_hw *hw = &adapter->hw; | 156 | struct ixgbe_hw *hw = &adapter->hw; |
157 | ixgbe_link_speed supported_link; | ||
157 | u32 link_speed = 0; | 158 | u32 link_speed = 0; |
159 | bool autoneg; | ||
158 | bool link_up; | 160 | bool link_up; |
159 | 161 | ||
160 | ecmd->supported = SUPPORTED_10000baseT_Full; | 162 | hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg); |
161 | ecmd->autoneg = AUTONEG_ENABLE; | 163 | |
162 | ecmd->transceiver = XCVR_EXTERNAL; | 164 | /* set the supported link speeds */ |
163 | if ((hw->phy.media_type == ixgbe_media_type_copper) || | 165 | if (supported_link & IXGBE_LINK_SPEED_10GB_FULL) |
164 | (hw->phy.multispeed_fiber)) { | 166 | ecmd->supported |= SUPPORTED_10000baseT_Full; |
165 | ecmd->supported |= (SUPPORTED_1000baseT_Full | | 167 | if (supported_link & IXGBE_LINK_SPEED_1GB_FULL) |
166 | SUPPORTED_Autoneg); | 168 | ecmd->supported |= SUPPORTED_1000baseT_Full; |
167 | 169 | if (supported_link & IXGBE_LINK_SPEED_100_FULL) | |
168 | switch (hw->mac.type) { | 170 | ecmd->supported |= SUPPORTED_100baseT_Full; |
169 | case ixgbe_mac_X540: | 171 | |
170 | ecmd->supported |= SUPPORTED_100baseT_Full; | 172 | /* set the advertised speeds */ |
171 | break; | 173 | if (hw->phy.autoneg_advertised) { |
172 | default: | 174 | if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL) |
173 | break; | 175 | ecmd->advertising |= ADVERTISED_100baseT_Full; |
174 | } | 176 | if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) |
175 | 177 | ecmd->advertising |= ADVERTISED_10000baseT_Full; | |
176 | ecmd->advertising = ADVERTISED_Autoneg; | 178 | if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) |
177 | if (hw->phy.autoneg_advertised) { | 179 | ecmd->advertising |= ADVERTISED_1000baseT_Full; |
178 | if (hw->phy.autoneg_advertised & | ||
179 | IXGBE_LINK_SPEED_100_FULL) | ||
180 | ecmd->advertising |= ADVERTISED_100baseT_Full; | ||
181 | if (hw->phy.autoneg_advertised & | ||
182 | IXGBE_LINK_SPEED_10GB_FULL) | ||
183 | ecmd->advertising |= ADVERTISED_10000baseT_Full; | ||
184 | if (hw->phy.autoneg_advertised & | ||
185 | IXGBE_LINK_SPEED_1GB_FULL) | ||
186 | ecmd->advertising |= ADVERTISED_1000baseT_Full; | ||
187 | } else { | ||
188 | /* | ||
189 | * Default advertised modes in case | ||
190 | * phy.autoneg_advertised isn't set. | ||
191 | */ | ||
192 | ecmd->advertising |= (ADVERTISED_10000baseT_Full | | ||
193 | ADVERTISED_1000baseT_Full); | ||
194 | if (hw->mac.type == ixgbe_mac_X540) | ||
195 | ecmd->advertising |= ADVERTISED_100baseT_Full; | ||
196 | } | ||
197 | |||
198 | if (hw->phy.media_type == ixgbe_media_type_copper) { | ||
199 | ecmd->supported |= SUPPORTED_TP; | ||
200 | ecmd->advertising |= ADVERTISED_TP; | ||
201 | ecmd->port = PORT_TP; | ||
202 | } else { | ||
203 | ecmd->supported |= SUPPORTED_FIBRE; | ||
204 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
205 | ecmd->port = PORT_FIBRE; | ||
206 | } | ||
207 | } else if (hw->phy.media_type == ixgbe_media_type_backplane) { | ||
208 | /* Set as FIBRE until SERDES defined in kernel */ | ||
209 | if (hw->device_id == IXGBE_DEV_ID_82598_BX) { | ||
210 | ecmd->supported = (SUPPORTED_1000baseT_Full | | ||
211 | SUPPORTED_FIBRE); | ||
212 | ecmd->advertising = (ADVERTISED_1000baseT_Full | | ||
213 | ADVERTISED_FIBRE); | ||
214 | ecmd->port = PORT_FIBRE; | ||
215 | ecmd->autoneg = AUTONEG_DISABLE; | ||
216 | } else if ((hw->device_id == IXGBE_DEV_ID_82599_COMBO_BACKPLANE) || | ||
217 | (hw->device_id == IXGBE_DEV_ID_82599_KX4_MEZZ)) { | ||
218 | ecmd->supported |= (SUPPORTED_1000baseT_Full | | ||
219 | SUPPORTED_Autoneg | | ||
220 | SUPPORTED_FIBRE); | ||
221 | ecmd->advertising = (ADVERTISED_10000baseT_Full | | ||
222 | ADVERTISED_1000baseT_Full | | ||
223 | ADVERTISED_Autoneg | | ||
224 | ADVERTISED_FIBRE); | ||
225 | ecmd->port = PORT_FIBRE; | ||
226 | } else { | ||
227 | ecmd->supported |= (SUPPORTED_1000baseT_Full | | ||
228 | SUPPORTED_FIBRE); | ||
229 | ecmd->advertising = (ADVERTISED_10000baseT_Full | | ||
230 | ADVERTISED_1000baseT_Full | | ||
231 | ADVERTISED_FIBRE); | ||
232 | ecmd->port = PORT_FIBRE; | ||
233 | } | ||
234 | } else { | 180 | } else { |
235 | ecmd->supported |= SUPPORTED_FIBRE; | 181 | /* default modes in case phy.autoneg_advertised isn't set */ |
236 | ecmd->advertising = (ADVERTISED_10000baseT_Full | | 182 | if (supported_link & IXGBE_LINK_SPEED_10GB_FULL) |
237 | ADVERTISED_FIBRE); | 183 | ecmd->advertising |= ADVERTISED_10000baseT_Full; |
238 | ecmd->port = PORT_FIBRE; | 184 | if (supported_link & IXGBE_LINK_SPEED_1GB_FULL) |
239 | ecmd->autoneg = AUTONEG_DISABLE; | 185 | ecmd->advertising |= ADVERTISED_1000baseT_Full; |
186 | if (supported_link & IXGBE_LINK_SPEED_100_FULL) | ||
187 | ecmd->advertising |= ADVERTISED_100baseT_Full; | ||
240 | } | 188 | } |
241 | 189 | ||
242 | /* Get PHY type */ | 190 | if (autoneg) { |
191 | ecmd->supported |= SUPPORTED_Autoneg; | ||
192 | ecmd->advertising |= ADVERTISED_Autoneg; | ||
193 | ecmd->autoneg = AUTONEG_ENABLE; | ||
194 | } else | ||
195 | ecmd->autoneg = AUTONEG_DISABLE; | ||
196 | |||
197 | ecmd->transceiver = XCVR_EXTERNAL; | ||
198 | |||
199 | /* Determine the remaining settings based on the PHY type. */ | ||
243 | switch (adapter->hw.phy.type) { | 200 | switch (adapter->hw.phy.type) { |
244 | case ixgbe_phy_tn: | 201 | case ixgbe_phy_tn: |
245 | case ixgbe_phy_aq: | 202 | case ixgbe_phy_aq: |
246 | case ixgbe_phy_cu_unknown: | 203 | case ixgbe_phy_cu_unknown: |
247 | /* Copper 10G-BASET */ | 204 | ecmd->supported |= SUPPORTED_TP; |
205 | ecmd->advertising |= ADVERTISED_TP; | ||
248 | ecmd->port = PORT_TP; | 206 | ecmd->port = PORT_TP; |
249 | break; | 207 | break; |
250 | case ixgbe_phy_qt: | 208 | case ixgbe_phy_qt: |
209 | ecmd->supported |= SUPPORTED_FIBRE; | ||
210 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
251 | ecmd->port = PORT_FIBRE; | 211 | ecmd->port = PORT_FIBRE; |
252 | break; | 212 | break; |
253 | case ixgbe_phy_nl: | 213 | case ixgbe_phy_nl: |
@@ -257,42 +217,59 @@ static int ixgbe_get_settings(struct net_device *netdev, | |||
257 | case ixgbe_phy_sfp_avago: | 217 | case ixgbe_phy_sfp_avago: |
258 | case ixgbe_phy_sfp_intel: | 218 | case ixgbe_phy_sfp_intel: |
259 | case ixgbe_phy_sfp_unknown: | 219 | case ixgbe_phy_sfp_unknown: |
260 | switch (adapter->hw.phy.sfp_type) { | ||
261 | /* SFP+ devices, further checking needed */ | 220 | /* SFP+ devices, further checking needed */ |
221 | switch (adapter->hw.phy.sfp_type) { | ||
262 | case ixgbe_sfp_type_da_cu: | 222 | case ixgbe_sfp_type_da_cu: |
263 | case ixgbe_sfp_type_da_cu_core0: | 223 | case ixgbe_sfp_type_da_cu_core0: |
264 | case ixgbe_sfp_type_da_cu_core1: | 224 | case ixgbe_sfp_type_da_cu_core1: |
225 | ecmd->supported |= SUPPORTED_FIBRE; | ||
226 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
265 | ecmd->port = PORT_DA; | 227 | ecmd->port = PORT_DA; |
266 | break; | 228 | break; |
267 | case ixgbe_sfp_type_sr: | 229 | case ixgbe_sfp_type_sr: |
268 | case ixgbe_sfp_type_lr: | 230 | case ixgbe_sfp_type_lr: |
269 | case ixgbe_sfp_type_srlr_core0: | 231 | case ixgbe_sfp_type_srlr_core0: |
270 | case ixgbe_sfp_type_srlr_core1: | 232 | case ixgbe_sfp_type_srlr_core1: |
233 | ecmd->supported |= SUPPORTED_FIBRE; | ||
234 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
271 | ecmd->port = PORT_FIBRE; | 235 | ecmd->port = PORT_FIBRE; |
272 | break; | 236 | break; |
273 | case ixgbe_sfp_type_not_present: | 237 | case ixgbe_sfp_type_not_present: |
238 | ecmd->supported |= SUPPORTED_FIBRE; | ||
239 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
274 | ecmd->port = PORT_NONE; | 240 | ecmd->port = PORT_NONE; |
275 | break; | 241 | break; |
276 | case ixgbe_sfp_type_1g_cu_core0: | 242 | case ixgbe_sfp_type_1g_cu_core0: |
277 | case ixgbe_sfp_type_1g_cu_core1: | 243 | case ixgbe_sfp_type_1g_cu_core1: |
244 | ecmd->supported |= SUPPORTED_TP; | ||
245 | ecmd->advertising |= ADVERTISED_TP; | ||
278 | ecmd->port = PORT_TP; | 246 | ecmd->port = PORT_TP; |
279 | ecmd->supported = SUPPORTED_TP; | 247 | break; |
280 | ecmd->advertising = (ADVERTISED_1000baseT_Full | | 248 | case ixgbe_sfp_type_1g_sx_core0: |
281 | ADVERTISED_TP); | 249 | case ixgbe_sfp_type_1g_sx_core1: |
250 | ecmd->supported |= SUPPORTED_FIBRE; | ||
251 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
252 | ecmd->port = PORT_FIBRE; | ||
282 | break; | 253 | break; |
283 | case ixgbe_sfp_type_unknown: | 254 | case ixgbe_sfp_type_unknown: |
284 | default: | 255 | default: |
256 | ecmd->supported |= SUPPORTED_FIBRE; | ||
257 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
285 | ecmd->port = PORT_OTHER; | 258 | ecmd->port = PORT_OTHER; |
286 | break; | 259 | break; |
287 | } | 260 | } |
288 | break; | 261 | break; |
289 | case ixgbe_phy_xaui: | 262 | case ixgbe_phy_xaui: |
263 | ecmd->supported |= SUPPORTED_FIBRE; | ||
264 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
290 | ecmd->port = PORT_NONE; | 265 | ecmd->port = PORT_NONE; |
291 | break; | 266 | break; |
292 | case ixgbe_phy_unknown: | 267 | case ixgbe_phy_unknown: |
293 | case ixgbe_phy_generic: | 268 | case ixgbe_phy_generic: |
294 | case ixgbe_phy_sfp_unsupported: | 269 | case ixgbe_phy_sfp_unsupported: |
295 | default: | 270 | default: |
271 | ecmd->supported |= SUPPORTED_FIBRE; | ||
272 | ecmd->advertising |= ADVERTISED_FIBRE; | ||
296 | ecmd->port = PORT_OTHER; | 273 | ecmd->port = PORT_OTHER; |
297 | break; | 274 | break; |
298 | } | 275 | } |