Deleted Added
full compact
ixgbe_82599.c (240155) ixgbe_82599.c (247822)
1/******************************************************************************
2
1/******************************************************************************
2
3 Copyright (c) 2001-2012, Intel Corporation
3 Copyright (c) 2001-2013, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11

--- 13 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11

--- 13 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
33/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_82599.c 240155 2012-09-06 02:07:58Z kevlo $*/
33/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_82599.c 247822 2013-03-04 23:07:40Z jfv $*/
34
35#include "ixgbe_type.h"
36#include "ixgbe_82599.h"
37#include "ixgbe_api.h"
38#include "ixgbe_common.h"
39#include "ixgbe_phy.h"
40
41static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
42 ixgbe_link_speed speed,
34
35#include "ixgbe_type.h"
36#include "ixgbe_82599.h"
37#include "ixgbe_api.h"
38#include "ixgbe_common.h"
39#include "ixgbe_phy.h"
40
41static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
42 ixgbe_link_speed speed,
43 bool autoneg,
44 bool autoneg_wait_to_complete);
45static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw);
46static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
47 u16 offset, u16 *data);
48static s32 ixgbe_read_eeprom_buffer_82599(struct ixgbe_hw *hw, u16 offset,
49 u16 words, u16 *data);
50
43 bool autoneg_wait_to_complete);
44static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw);
45static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
46 u16 offset, u16 *data);
47static s32 ixgbe_read_eeprom_buffer_82599(struct ixgbe_hw *hw, u16 offset,
48 u16 words, u16 *data);
49
50static bool ixgbe_mng_enabled(struct ixgbe_hw *hw)
51{
52 u32 fwsm, manc, factps;
53
54 fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
55 if ((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT)
56 return FALSE;
57
58 manc = IXGBE_READ_REG(hw, IXGBE_MANC);
59 if (!(manc & IXGBE_MANC_RCV_TCO_EN))
60 return FALSE;
61
62 factps = IXGBE_READ_REG(hw, IXGBE_FACTPS);
63 if (factps & IXGBE_FACTPS_MNGCG)
64 return FALSE;
65
66 return TRUE;
67}
68
51void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
52{
53 struct ixgbe_mac_info *mac = &hw->mac;
54
55 DEBUGFUNC("ixgbe_init_mac_link_ops_82599");
56
69void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
70{
71 struct ixgbe_mac_info *mac = &hw->mac;
72
73 DEBUGFUNC("ixgbe_init_mac_link_ops_82599");
74
57 /* enable the laser control functions for SFP+ fiber */
58 if (mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) {
75 /*
76 * enable the laser control functions for SFP+ fiber
77 * and MNG not enabled
78 */
79 if ((mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) &&
80 !(ixgbe_mng_enabled(hw))) {
59 mac->ops.disable_tx_laser =
60 &ixgbe_disable_tx_laser_multispeed_fiber;
61 mac->ops.enable_tx_laser =
62 &ixgbe_enable_tx_laser_multispeed_fiber;
63 mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
64
65 } else {
66 mac->ops.disable_tx_laser = NULL;

--- 63 unchanged lines hidden (view full) ---

130 }
131init_phy_ops_out:
132 return ret_val;
133}
134
135s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
136{
137 s32 ret_val = IXGBE_SUCCESS;
81 mac->ops.disable_tx_laser =
82 &ixgbe_disable_tx_laser_multispeed_fiber;
83 mac->ops.enable_tx_laser =
84 &ixgbe_enable_tx_laser_multispeed_fiber;
85 mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
86
87 } else {
88 mac->ops.disable_tx_laser = NULL;

--- 63 unchanged lines hidden (view full) ---

152 }
153init_phy_ops_out:
154 return ret_val;
155}
156
157s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
158{
159 s32 ret_val = IXGBE_SUCCESS;
138 u32 reg_anlp1 = 0;
139 u32 i = 0;
140 u16 list_offset, data_offset, data_value;
160 u16 list_offset, data_offset, data_value;
161 bool got_lock = FALSE;
141
142 DEBUGFUNC("ixgbe_setup_sfp_modules_82599");
143
144 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
145 ixgbe_init_mac_link_ops_82599(hw);
146
147 hw->phy.ops.reset = NULL;
148

--- 17 unchanged lines hidden (view full) ---

166 hw->eeprom.ops.read(hw, ++data_offset, &data_value);
167 }
168
169 /* Release the semaphore */
170 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
171 /* Delay obtaining semaphore again to allow FW access */
172 msec_delay(hw->eeprom.semaphore_delay);
173
162
163 DEBUGFUNC("ixgbe_setup_sfp_modules_82599");
164
165 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
166 ixgbe_init_mac_link_ops_82599(hw);
167
168 hw->phy.ops.reset = NULL;
169

--- 17 unchanged lines hidden (view full) ---

187 hw->eeprom.ops.read(hw, ++data_offset, &data_value);
188 }
189
190 /* Release the semaphore */
191 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
192 /* Delay obtaining semaphore again to allow FW access */
193 msec_delay(hw->eeprom.semaphore_delay);
194
174 /* Now restart DSP by setting Restart_AN and clearing LMS */
175 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((IXGBE_READ_REG(hw,
176 IXGBE_AUTOC) & ~IXGBE_AUTOC_LMS_MASK) |
177 IXGBE_AUTOC_AN_RESTART));
195 /* Need SW/FW semaphore around AUTOC writes if LESM on,
196 * likewise reset_pipeline requires lock as it also writes
197 * AUTOC.
198 */
199 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
200 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
201 IXGBE_GSSR_MAC_CSR_SM);
202 if (ret_val != IXGBE_SUCCESS) {
203 ret_val = IXGBE_ERR_SWFW_SYNC;
204 goto setup_sfp_out;
205 }
178
206
179 /* Wait for AN to leave state 0 */
180 for (i = 0; i < 10; i++) {
181 msec_delay(4);
182 reg_anlp1 = IXGBE_READ_REG(hw, IXGBE_ANLP1);
183 if (reg_anlp1 & IXGBE_ANLP1_AN_STATE_MASK)
184 break;
207 got_lock = TRUE;
185 }
208 }
186 if (!(reg_anlp1 & IXGBE_ANLP1_AN_STATE_MASK)) {
209
210 /* Restart DSP and set SFI mode */
211 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((hw->mac.orig_autoc) |
212 IXGBE_AUTOC_LMS_10G_SERIAL));
213 hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
214 ret_val = ixgbe_reset_pipeline_82599(hw);
215
216 if (got_lock) {
217 hw->mac.ops.release_swfw_sync(hw,
218 IXGBE_GSSR_MAC_CSR_SM);
219 got_lock = FALSE;
220 }
221
222 if (ret_val) {
187 DEBUGOUT("sfp module setup not complete\n");
188 ret_val = IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
189 goto setup_sfp_out;
190 }
191
223 DEBUGOUT("sfp module setup not complete\n");
224 ret_val = IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
225 goto setup_sfp_out;
226 }
227
192 /* Restart DSP by setting Restart_AN and return to SFI mode */
193 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (IXGBE_READ_REG(hw,
194 IXGBE_AUTOC) | IXGBE_AUTOC_LMS_10G_SERIAL |
195 IXGBE_AUTOC_AN_RESTART));
196 }
197
198setup_sfp_out:
199 return ret_val;
200}
201
202/**
203 * ixgbe_init_ops_82599 - Inits func ptrs and MAC type

--- 7 unchanged lines hidden (view full) ---

211{
212 struct ixgbe_mac_info *mac = &hw->mac;
213 struct ixgbe_phy_info *phy = &hw->phy;
214 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
215 s32 ret_val;
216
217 DEBUGFUNC("ixgbe_init_ops_82599");
218
228 }
229
230setup_sfp_out:
231 return ret_val;
232}
233
234/**
235 * ixgbe_init_ops_82599 - Inits func ptrs and MAC type

--- 7 unchanged lines hidden (view full) ---

243{
244 struct ixgbe_mac_info *mac = &hw->mac;
245 struct ixgbe_phy_info *phy = &hw->phy;
246 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
247 s32 ret_val;
248
249 DEBUGFUNC("ixgbe_init_ops_82599");
250
219 ret_val = ixgbe_init_phy_ops_generic(hw);
251 ixgbe_init_phy_ops_generic(hw);
220 ret_val = ixgbe_init_ops_generic(hw);
221
222 /* PHY */
223 phy->ops.identify = &ixgbe_identify_phy_82599;
224 phy->ops.init = &ixgbe_init_phy_ops_82599;
225
226 /* MAC */
227 mac->ops.reset_hw = &ixgbe_reset_hw_82599;

--- 56 unchanged lines hidden (view full) ---

284
285 return ret_val;
286}
287
288/**
289 * ixgbe_get_link_capabilities_82599 - Determines link capabilities
290 * @hw: pointer to hardware structure
291 * @speed: pointer to link speed
252 ret_val = ixgbe_init_ops_generic(hw);
253
254 /* PHY */
255 phy->ops.identify = &ixgbe_identify_phy_82599;
256 phy->ops.init = &ixgbe_init_phy_ops_82599;
257
258 /* MAC */
259 mac->ops.reset_hw = &ixgbe_reset_hw_82599;

--- 56 unchanged lines hidden (view full) ---

316
317 return ret_val;
318}
319
320/**
321 * ixgbe_get_link_capabilities_82599 - Determines link capabilities
322 * @hw: pointer to hardware structure
323 * @speed: pointer to link speed
292 * @negotiation: TRUE when autoneg or autotry is enabled
324 * @autoneg: TRUE when autoneg or autotry is enabled
293 *
294 * Determines the link capabilities by reading the AUTOC register.
295 **/
296s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
297 ixgbe_link_speed *speed,
325 *
326 * Determines the link capabilities by reading the AUTOC register.
327 **/
328s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
329 ixgbe_link_speed *speed,
298 bool *negotiation)
330 bool *autoneg)
299{
300 s32 status = IXGBE_SUCCESS;
301 u32 autoc = 0;
302
303 DEBUGFUNC("ixgbe_get_link_capabilities_82599");
304
305
306 /* Check if 1G SFP module. */
307 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
308 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
309 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
310 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
311 *speed = IXGBE_LINK_SPEED_1GB_FULL;
331{
332 s32 status = IXGBE_SUCCESS;
333 u32 autoc = 0;
334
335 DEBUGFUNC("ixgbe_get_link_capabilities_82599");
336
337
338 /* Check if 1G SFP module. */
339 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
340 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
341 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
342 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
343 *speed = IXGBE_LINK_SPEED_1GB_FULL;
312 *negotiation = TRUE;
344 *autoneg = TRUE;
313 goto out;
314 }
315
316 /*
317 * Determine link capabilities based on the stored value of AUTOC,
318 * which represents EEPROM defaults. If AUTOC value has not
319 * been stored, use the current register values.
320 */
321 if (hw->mac.orig_link_settings_stored)
322 autoc = hw->mac.orig_autoc;
323 else
324 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
325
326 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
327 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
328 *speed = IXGBE_LINK_SPEED_1GB_FULL;
345 goto out;
346 }
347
348 /*
349 * Determine link capabilities based on the stored value of AUTOC,
350 * which represents EEPROM defaults. If AUTOC value has not
351 * been stored, use the current register values.
352 */
353 if (hw->mac.orig_link_settings_stored)
354 autoc = hw->mac.orig_autoc;
355 else
356 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
357
358 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
359 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
360 *speed = IXGBE_LINK_SPEED_1GB_FULL;
329 *negotiation = FALSE;
361 *autoneg = FALSE;
330 break;
331
332 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
333 *speed = IXGBE_LINK_SPEED_10GB_FULL;
362 break;
363
364 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
365 *speed = IXGBE_LINK_SPEED_10GB_FULL;
334 *negotiation = FALSE;
366 *autoneg = FALSE;
335 break;
336
337 case IXGBE_AUTOC_LMS_1G_AN:
338 *speed = IXGBE_LINK_SPEED_1GB_FULL;
367 break;
368
369 case IXGBE_AUTOC_LMS_1G_AN:
370 *speed = IXGBE_LINK_SPEED_1GB_FULL;
339 *negotiation = TRUE;
371 *autoneg = TRUE;
340 break;
341
342 case IXGBE_AUTOC_LMS_10G_SERIAL:
343 *speed = IXGBE_LINK_SPEED_10GB_FULL;
372 break;
373
374 case IXGBE_AUTOC_LMS_10G_SERIAL:
375 *speed = IXGBE_LINK_SPEED_10GB_FULL;
344 *negotiation = FALSE;
376 *autoneg = FALSE;
345 break;
346
347 case IXGBE_AUTOC_LMS_KX4_KX_KR:
348 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
349 *speed = IXGBE_LINK_SPEED_UNKNOWN;
350 if (autoc & IXGBE_AUTOC_KR_SUPP)
351 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
352 if (autoc & IXGBE_AUTOC_KX4_SUPP)
353 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
354 if (autoc & IXGBE_AUTOC_KX_SUPP)
355 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
377 break;
378
379 case IXGBE_AUTOC_LMS_KX4_KX_KR:
380 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
381 *speed = IXGBE_LINK_SPEED_UNKNOWN;
382 if (autoc & IXGBE_AUTOC_KR_SUPP)
383 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
384 if (autoc & IXGBE_AUTOC_KX4_SUPP)
385 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
386 if (autoc & IXGBE_AUTOC_KX_SUPP)
387 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
356 *negotiation = TRUE;
388 *autoneg = TRUE;
357 break;
358
359 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
360 *speed = IXGBE_LINK_SPEED_100_FULL;
361 if (autoc & IXGBE_AUTOC_KR_SUPP)
362 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
363 if (autoc & IXGBE_AUTOC_KX4_SUPP)
364 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
365 if (autoc & IXGBE_AUTOC_KX_SUPP)
366 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
389 break;
390
391 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
392 *speed = IXGBE_LINK_SPEED_100_FULL;
393 if (autoc & IXGBE_AUTOC_KR_SUPP)
394 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
395 if (autoc & IXGBE_AUTOC_KX4_SUPP)
396 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
397 if (autoc & IXGBE_AUTOC_KX_SUPP)
398 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
367 *negotiation = TRUE;
399 *autoneg = TRUE;
368 break;
369
370 case IXGBE_AUTOC_LMS_SGMII_1G_100M:
371 *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
400 break;
401
402 case IXGBE_AUTOC_LMS_SGMII_1G_100M:
403 *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
372 *negotiation = FALSE;
404 *autoneg = FALSE;
373 break;
374
375 default:
376 status = IXGBE_ERR_LINK_SETUP;
377 goto out;
378 break;
379 }
380
381 if (hw->phy.multispeed_fiber) {
382 *speed |= IXGBE_LINK_SPEED_10GB_FULL |
383 IXGBE_LINK_SPEED_1GB_FULL;
405 break;
406
407 default:
408 status = IXGBE_ERR_LINK_SETUP;
409 goto out;
410 break;
411 }
412
413 if (hw->phy.multispeed_fiber) {
414 *speed |= IXGBE_LINK_SPEED_10GB_FULL |
415 IXGBE_LINK_SPEED_1GB_FULL;
384 *negotiation = TRUE;
416 *autoneg = TRUE;
385 }
386
387out:
388 return status;
389}
390
391/**
392 * ixgbe_get_media_type_82599 - Get media type

--- 26 unchanged lines hidden (view full) ---

419 case IXGBE_DEV_ID_82599_XAUI_LOM:
420 /* Default device ID is mezzanine card KX/KX4 */
421 media_type = ixgbe_media_type_backplane;
422 break;
423 case IXGBE_DEV_ID_82599_SFP:
424 case IXGBE_DEV_ID_82599_SFP_FCOE:
425 case IXGBE_DEV_ID_82599_SFP_EM:
426 case IXGBE_DEV_ID_82599_SFP_SF2:
417 }
418
419out:
420 return status;
421}
422
423/**
424 * ixgbe_get_media_type_82599 - Get media type

--- 26 unchanged lines hidden (view full) ---

451 case IXGBE_DEV_ID_82599_XAUI_LOM:
452 /* Default device ID is mezzanine card KX/KX4 */
453 media_type = ixgbe_media_type_backplane;
454 break;
455 case IXGBE_DEV_ID_82599_SFP:
456 case IXGBE_DEV_ID_82599_SFP_FCOE:
457 case IXGBE_DEV_ID_82599_SFP_EM:
458 case IXGBE_DEV_ID_82599_SFP_SF2:
459 case IXGBE_DEV_ID_82599_SFP_SF_QP:
427 case IXGBE_DEV_ID_82599EN_SFP:
428 media_type = ixgbe_media_type_fiber;
429 break;
430 case IXGBE_DEV_ID_82599_CX4:
431 media_type = ixgbe_media_type_cx4;
432 break;
433 case IXGBE_DEV_ID_82599_T3_LOM:
434 media_type = ixgbe_media_type_copper;
435 break;
460 case IXGBE_DEV_ID_82599EN_SFP:
461 media_type = ixgbe_media_type_fiber;
462 break;
463 case IXGBE_DEV_ID_82599_CX4:
464 media_type = ixgbe_media_type_cx4;
465 break;
466 case IXGBE_DEV_ID_82599_T3_LOM:
467 media_type = ixgbe_media_type_copper;
468 break;
469 case IXGBE_DEV_ID_82599_BYPASS:
470 media_type = ixgbe_media_type_fiber_fixed;
471 hw->phy.multispeed_fiber = TRUE;
472 break;
436 default:
437 media_type = ixgbe_media_type_unknown;
438 break;
439 }
440out:
441 return media_type;
442}
443

--- 7 unchanged lines hidden (view full) ---

451 **/
452s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
453 bool autoneg_wait_to_complete)
454{
455 u32 autoc_reg;
456 u32 links_reg;
457 u32 i;
458 s32 status = IXGBE_SUCCESS;
473 default:
474 media_type = ixgbe_media_type_unknown;
475 break;
476 }
477out:
478 return media_type;
479}
480

--- 7 unchanged lines hidden (view full) ---

488 **/
489s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
490 bool autoneg_wait_to_complete)
491{
492 u32 autoc_reg;
493 u32 links_reg;
494 u32 i;
495 s32 status = IXGBE_SUCCESS;
496 bool got_lock = FALSE;
459
460 DEBUGFUNC("ixgbe_start_mac_link_82599");
461
462
497
498 DEBUGFUNC("ixgbe_start_mac_link_82599");
499
500
501 /* reset_pipeline requires us to hold this lock as it writes to
502 * AUTOC.
503 */
504 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
505 status = hw->mac.ops.acquire_swfw_sync(hw,
506 IXGBE_GSSR_MAC_CSR_SM);
507 if (status != IXGBE_SUCCESS)
508 goto out;
509
510 got_lock = TRUE;
511 }
512
463 /* Restart link */
513 /* Restart link */
464 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
465 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
466 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
514 ixgbe_reset_pipeline_82599(hw);
467
515
516 if (got_lock)
517 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
518
468 /* Only poll for autoneg to complete if specified to do so */
469 if (autoneg_wait_to_complete) {
519 /* Only poll for autoneg to complete if specified to do so */
520 if (autoneg_wait_to_complete) {
521 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
470 if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
471 IXGBE_AUTOC_LMS_KX4_KX_KR ||
472 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
473 IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
474 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
475 IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
476 links_reg = 0; /* Just in case Autoneg time = 0 */
477 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {

--- 7 unchanged lines hidden (view full) ---

485 DEBUGOUT("Autoneg did not complete.\n");
486 }
487 }
488 }
489
490 /* Add delay to filter out noises during initial link setup */
491 msec_delay(50);
492
522 if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
523 IXGBE_AUTOC_LMS_KX4_KX_KR ||
524 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
525 IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
526 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
527 IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
528 links_reg = 0; /* Just in case Autoneg time = 0 */
529 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {

--- 7 unchanged lines hidden (view full) ---

537 DEBUGOUT("Autoneg did not complete.\n");
538 }
539 }
540 }
541
542 /* Add delay to filter out noises during initial link setup */
543 msec_delay(50);
544
545out:
493 return status;
494}
495
496/**
497 * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
498 * @hw: pointer to hardware structure
499 *
500 * The base drivers may require better control over SFP+ module

--- 49 unchanged lines hidden (view full) ---

550 if (hw->mac.autotry_restart) {
551 ixgbe_disable_tx_laser_multispeed_fiber(hw);
552 ixgbe_enable_tx_laser_multispeed_fiber(hw);
553 hw->mac.autotry_restart = FALSE;
554 }
555}
556
557/**
546 return status;
547}
548
549/**
550 * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
551 * @hw: pointer to hardware structure
552 *
553 * The base drivers may require better control over SFP+ module

--- 49 unchanged lines hidden (view full) ---

603 if (hw->mac.autotry_restart) {
604 ixgbe_disable_tx_laser_multispeed_fiber(hw);
605 ixgbe_enable_tx_laser_multispeed_fiber(hw);
606 hw->mac.autotry_restart = FALSE;
607 }
608}
609
610/**
611 * ixgbe_set_fiber_fixed_speed - Set module link speed for fixed fiber
612 * @hw: pointer to hardware structure
613 * @speed: link speed to set
614 *
615 * We set the module speed differently for fixed fiber. For other
616 * multi-speed devices we don't have an error value so here if we
617 * detect an error we just log it and exit.
618 */
619static void ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw,
620 ixgbe_link_speed speed)
621{
622 s32 status;
623 u8 rs, eeprom_data;
624
625 switch (speed) {
626 case IXGBE_LINK_SPEED_10GB_FULL:
627 /* one bit mask same as setting on */
628 rs = IXGBE_SFF_SOFT_RS_SELECT_10G;
629 break;
630 case IXGBE_LINK_SPEED_1GB_FULL:
631 rs = IXGBE_SFF_SOFT_RS_SELECT_1G;
632 break;
633 default:
634 DEBUGOUT("Invalid fixed module speed\n");
635 return;
636 }
637
638 /* Set RS0 */
639 status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
640 IXGBE_I2C_EEPROM_DEV_ADDR2,
641 &eeprom_data);
642 if (status) {
643 DEBUGOUT("Failed to read Rx Rate Select RS0\n");
644 goto out;
645 }
646
647 eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
648
649 status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
650 IXGBE_I2C_EEPROM_DEV_ADDR2,
651 eeprom_data);
652 if (status) {
653 DEBUGOUT("Failed to write Rx Rate Select RS0\n");
654 goto out;
655 }
656
657 /* Set RS1 */
658 status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
659 IXGBE_I2C_EEPROM_DEV_ADDR2,
660 &eeprom_data);
661 if (status) {
662 DEBUGOUT("Failed to read Rx Rate Select RS1\n");
663 goto out;
664 }
665
666 eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
667
668 status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
669 IXGBE_I2C_EEPROM_DEV_ADDR2,
670 eeprom_data);
671 if (status) {
672 DEBUGOUT("Failed to write Rx Rate Select RS1\n");
673 goto out;
674 }
675out:
676 return;
677}
678
679/**
558 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
559 * @hw: pointer to hardware structure
560 * @speed: new link speed
680 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
681 * @hw: pointer to hardware structure
682 * @speed: new link speed
561 * @autoneg: TRUE if autonegotiation enabled
562 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
563 *
564 * Set the link speed in the AUTOC register and restarts link.
565 **/
566s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
683 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
684 *
685 * Set the link speed in the AUTOC register and restarts link.
686 **/
687s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
567 ixgbe_link_speed speed, bool autoneg,
688 ixgbe_link_speed speed,
568 bool autoneg_wait_to_complete)
569{
570 s32 status = IXGBE_SUCCESS;
571 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
572 ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
573 u32 speedcnt = 0;
574 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
575 u32 i = 0;
689 bool autoneg_wait_to_complete)
690{
691 s32 status = IXGBE_SUCCESS;
692 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
693 ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
694 u32 speedcnt = 0;
695 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
696 u32 i = 0;
576 bool link_up = FALSE;
577 bool negotiation;
697 bool autoneg, link_up = FALSE;
578
579 DEBUGFUNC("ixgbe_setup_mac_link_multispeed_fiber");
580
581 /* Mask off requested but non-supported speeds */
698
699 DEBUGFUNC("ixgbe_setup_mac_link_multispeed_fiber");
700
701 /* Mask off requested but non-supported speeds */
582 status = ixgbe_get_link_capabilities(hw, &link_speed, &negotiation);
702 status = ixgbe_get_link_capabilities(hw, &link_speed, &autoneg);
583 if (status != IXGBE_SUCCESS)
584 return status;
585
586 speed &= link_speed;
587
588 /*
589 * Try each speed one by one, highest priority first. We do this in
590 * software because 10gb fiber doesn't support speed autonegotiation.

--- 6 unchanged lines hidden (view full) ---

597 status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
598 if (status != IXGBE_SUCCESS)
599 return status;
600
601 if ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
602 goto out;
603
604 /* Set the module link speed */
703 if (status != IXGBE_SUCCESS)
704 return status;
705
706 speed &= link_speed;
707
708 /*
709 * Try each speed one by one, highest priority first. We do this in
710 * software because 10gb fiber doesn't support speed autonegotiation.

--- 6 unchanged lines hidden (view full) ---

717 status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
718 if (status != IXGBE_SUCCESS)
719 return status;
720
721 if ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
722 goto out;
723
724 /* Set the module link speed */
605 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
606 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
607 IXGBE_WRITE_FLUSH(hw);
725 if (hw->phy.media_type == ixgbe_media_type_fiber_fixed) {
726 ixgbe_set_fiber_fixed_speed(hw,
727 IXGBE_LINK_SPEED_10GB_FULL);
728 } else {
729 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
730 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
731 IXGBE_WRITE_FLUSH(hw);
732 }
608
609 /* Allow module to change analog characteristics (1G->10G) */
610 msec_delay(40);
611
612 status = ixgbe_setup_mac_link_82599(hw,
613 IXGBE_LINK_SPEED_10GB_FULL,
733
734 /* Allow module to change analog characteristics (1G->10G) */
735 msec_delay(40);
736
737 status = ixgbe_setup_mac_link_82599(hw,
738 IXGBE_LINK_SPEED_10GB_FULL,
614 autoneg,
615 autoneg_wait_to_complete);
616 if (status != IXGBE_SUCCESS)
617 return status;
618
619 /* Flap the tx laser if it has not already been done */
620 ixgbe_flap_tx_laser(hw);
621
622 /*

--- 25 unchanged lines hidden (view full) ---

648 status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
649 if (status != IXGBE_SUCCESS)
650 return status;
651
652 if ((link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
653 goto out;
654
655 /* Set the module link speed */
739 autoneg_wait_to_complete);
740 if (status != IXGBE_SUCCESS)
741 return status;
742
743 /* Flap the tx laser if it has not already been done */
744 ixgbe_flap_tx_laser(hw);
745
746 /*

--- 25 unchanged lines hidden (view full) ---

772 status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
773 if (status != IXGBE_SUCCESS)
774 return status;
775
776 if ((link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
777 goto out;
778
779 /* Set the module link speed */
656 esdp_reg &= ~IXGBE_ESDP_SDP5;
657 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
658 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
659 IXGBE_WRITE_FLUSH(hw);
780 if (hw->phy.media_type == ixgbe_media_type_fiber_fixed) {
781 ixgbe_set_fiber_fixed_speed(hw,
782 IXGBE_LINK_SPEED_1GB_FULL);
783 } else {
784 esdp_reg &= ~IXGBE_ESDP_SDP5;
785 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
786 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
787 IXGBE_WRITE_FLUSH(hw);
788 }
660
661 /* Allow module to change analog characteristics (10G->1G) */
662 msec_delay(40);
663
664 status = ixgbe_setup_mac_link_82599(hw,
665 IXGBE_LINK_SPEED_1GB_FULL,
789
790 /* Allow module to change analog characteristics (10G->1G) */
791 msec_delay(40);
792
793 status = ixgbe_setup_mac_link_82599(hw,
794 IXGBE_LINK_SPEED_1GB_FULL,
666 autoneg,
667 autoneg_wait_to_complete);
668 if (status != IXGBE_SUCCESS)
669 return status;
670
671 /* Flap the tx laser if it has not already been done */
672 ixgbe_flap_tx_laser(hw);
673
674 /* Wait for the link partner to also set speed */

--- 10 unchanged lines hidden (view full) ---

685
686 /*
687 * We didn't get link. Configure back to the highest speed we tried,
688 * (if there was more than one). We call ourselves back with just the
689 * single highest speed that the user requested.
690 */
691 if (speedcnt > 1)
692 status = ixgbe_setup_mac_link_multispeed_fiber(hw,
795 autoneg_wait_to_complete);
796 if (status != IXGBE_SUCCESS)
797 return status;
798
799 /* Flap the tx laser if it has not already been done */
800 ixgbe_flap_tx_laser(hw);
801
802 /* Wait for the link partner to also set speed */

--- 10 unchanged lines hidden (view full) ---

813
814 /*
815 * We didn't get link. Configure back to the highest speed we tried,
816 * (if there was more than one). We call ourselves back with just the
817 * single highest speed that the user requested.
818 */
819 if (speedcnt > 1)
820 status = ixgbe_setup_mac_link_multispeed_fiber(hw,
693 highest_link_speed, autoneg, autoneg_wait_to_complete);
821 highest_link_speed, autoneg_wait_to_complete);
694
695out:
696 /* Set autoneg_advertised value based on input link speed */
697 hw->phy.autoneg_advertised = 0;
698
699 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
700 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
701
702 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
703 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
704
705 return status;
706}
707
708/**
709 * ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed
710 * @hw: pointer to hardware structure
711 * @speed: new link speed
822
823out:
824 /* Set autoneg_advertised value based on input link speed */
825 hw->phy.autoneg_advertised = 0;
826
827 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
828 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
829
830 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
831 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
832
833 return status;
834}
835
836/**
837 * ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed
838 * @hw: pointer to hardware structure
839 * @speed: new link speed
712 * @autoneg: TRUE if autonegotiation enabled
713 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
714 *
715 * Implements the Intel SmartSpeed algorithm.
716 **/
717s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
840 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
841 *
842 * Implements the Intel SmartSpeed algorithm.
843 **/
844s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
718 ixgbe_link_speed speed, bool autoneg,
845 ixgbe_link_speed speed,
719 bool autoneg_wait_to_complete)
720{
721 s32 status = IXGBE_SUCCESS;
722 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
723 s32 i, j;
724 bool link_up = FALSE;
725 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
726

--- 16 unchanged lines hidden (view full) ---

743 * autoneg advertisement if link is unable to be established at the
744 * highest negotiated rate. This can sometimes happen due to integrity
745 * issues with the physical media connection.
746 */
747
748 /* First, try to get link with full advertisement */
749 hw->phy.smart_speed_active = FALSE;
750 for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) {
846 bool autoneg_wait_to_complete)
847{
848 s32 status = IXGBE_SUCCESS;
849 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
850 s32 i, j;
851 bool link_up = FALSE;
852 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
853

--- 16 unchanged lines hidden (view full) ---

870 * autoneg advertisement if link is unable to be established at the
871 * highest negotiated rate. This can sometimes happen due to integrity
872 * issues with the physical media connection.
873 */
874
875 /* First, try to get link with full advertisement */
876 hw->phy.smart_speed_active = FALSE;
877 for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) {
751 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
878 status = ixgbe_setup_mac_link_82599(hw, speed,
752 autoneg_wait_to_complete);
753 if (status != IXGBE_SUCCESS)
754 goto out;
755
756 /*
757 * Wait for the controller to acquire link. Per IEEE 802.3ap,
758 * Section 73.10.2, we may have to wait up to 500ms if KR is
759 * attempted, or 200ms if KX/KX4/BX/BX4 is attempted, per

--- 18 unchanged lines hidden (view full) ---

778 * (or BX4/BX), then disable KR and try again.
779 */
780 if (((autoc_reg & IXGBE_AUTOC_KR_SUPP) == 0) ||
781 ((autoc_reg & IXGBE_AUTOC_KX4_KX_SUPP_MASK) == 0))
782 goto out;
783
784 /* Turn SmartSpeed on to disable KR support */
785 hw->phy.smart_speed_active = TRUE;
879 autoneg_wait_to_complete);
880 if (status != IXGBE_SUCCESS)
881 goto out;
882
883 /*
884 * Wait for the controller to acquire link. Per IEEE 802.3ap,
885 * Section 73.10.2, we may have to wait up to 500ms if KR is
886 * attempted, or 200ms if KX/KX4/BX/BX4 is attempted, per

--- 18 unchanged lines hidden (view full) ---

905 * (or BX4/BX), then disable KR and try again.
906 */
907 if (((autoc_reg & IXGBE_AUTOC_KR_SUPP) == 0) ||
908 ((autoc_reg & IXGBE_AUTOC_KX4_KX_SUPP_MASK) == 0))
909 goto out;
910
911 /* Turn SmartSpeed on to disable KR support */
912 hw->phy.smart_speed_active = TRUE;
786 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
913 status = ixgbe_setup_mac_link_82599(hw, speed,
787 autoneg_wait_to_complete);
788 if (status != IXGBE_SUCCESS)
789 goto out;
790
791 /*
792 * Wait for the controller to acquire link. 600ms will allow for
793 * the AN link_fail_inhibit_timer as well for multiple cycles of
794 * parallel detect, both 10g and 1g. This allows for the maximum

--- 8 unchanged lines hidden (view full) ---

803 goto out;
804
805 if (link_up)
806 goto out;
807 }
808
809 /* We didn't get link. Turn SmartSpeed back off. */
810 hw->phy.smart_speed_active = FALSE;
914 autoneg_wait_to_complete);
915 if (status != IXGBE_SUCCESS)
916 goto out;
917
918 /*
919 * Wait for the controller to acquire link. 600ms will allow for
920 * the AN link_fail_inhibit_timer as well for multiple cycles of
921 * parallel detect, both 10g and 1g. This allows for the maximum

--- 8 unchanged lines hidden (view full) ---

930 goto out;
931
932 if (link_up)
933 goto out;
934 }
935
936 /* We didn't get link. Turn SmartSpeed back off. */
937 hw->phy.smart_speed_active = FALSE;
811 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
938 status = ixgbe_setup_mac_link_82599(hw, speed,
812 autoneg_wait_to_complete);
813
814out:
815 if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL))
816 DEBUGOUT("Smartspeed has downgraded the link speed "
817 "from the maximum advertised\n");
818 return status;
819}
820
821/**
822 * ixgbe_setup_mac_link_82599 - Set MAC link speed
823 * @hw: pointer to hardware structure
824 * @speed: new link speed
939 autoneg_wait_to_complete);
940
941out:
942 if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL))
943 DEBUGOUT("Smartspeed has downgraded the link speed "
944 "from the maximum advertised\n");
945 return status;
946}
947
948/**
949 * ixgbe_setup_mac_link_82599 - Set MAC link speed
950 * @hw: pointer to hardware structure
951 * @speed: new link speed
825 * @autoneg: TRUE if autonegotiation enabled
826 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
827 *
828 * Set the link speed in the AUTOC register and restarts link.
829 **/
830s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
952 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
953 *
954 * Set the link speed in the AUTOC register and restarts link.
955 **/
956s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
831 ixgbe_link_speed speed, bool autoneg,
957 ixgbe_link_speed speed,
832 bool autoneg_wait_to_complete)
833{
958 bool autoneg_wait_to_complete)
959{
960 bool autoneg = FALSE;
834 s32 status = IXGBE_SUCCESS;
961 s32 status = IXGBE_SUCCESS;
835 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
962 u32 autoc, pma_pmd_1g, link_mode, start_autoc;
836 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
963 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
837 u32 start_autoc = autoc;
838 u32 orig_autoc = 0;
964 u32 orig_autoc = 0;
839 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
840 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
841 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
842 u32 links_reg;
843 u32 i;
844 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
965 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
966 u32 links_reg;
967 u32 i;
968 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
969 bool got_lock = FALSE;
845
846 DEBUGFUNC("ixgbe_setup_mac_link_82599");
847
848 /* Check to see if speed passed in is supported. */
849 status = ixgbe_get_link_capabilities(hw, &link_capabilities, &autoneg);
970
971 DEBUGFUNC("ixgbe_setup_mac_link_82599");
972
973 /* Check to see if speed passed in is supported. */
974 status = ixgbe_get_link_capabilities(hw, &link_capabilities, &autoneg);
850 if (status != IXGBE_SUCCESS)
975 if (status)
851 goto out;
852
853 speed &= link_capabilities;
854
855 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
856 status = IXGBE_ERR_LINK_SETUP;
857 goto out;
858 }
859
860 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
861 if (hw->mac.orig_link_settings_stored)
976 goto out;
977
978 speed &= link_capabilities;
979
980 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
981 status = IXGBE_ERR_LINK_SETUP;
982 goto out;
983 }
984
985 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
986 if (hw->mac.orig_link_settings_stored)
862 orig_autoc = hw->mac.orig_autoc;
987 autoc = hw->mac.orig_autoc;
863 else
988 else
864 orig_autoc = autoc;
989 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
865
990
991 orig_autoc = autoc;
992 start_autoc = hw->mac.cached_autoc;
993 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
994 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
995
866 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
867 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
868 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
869 /* Set KX4/KX/KR support according to speed requested */
870 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
871 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
872 if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
873 autoc |= IXGBE_AUTOC_KX4_SUPP;

--- 21 unchanged lines hidden (view full) ---

895 if (autoneg)
896 autoc |= IXGBE_AUTOC_LMS_1G_AN;
897 else
898 autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
899 }
900 }
901
902 if (autoc != start_autoc) {
996 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
997 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
998 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
999 /* Set KX4/KX/KR support according to speed requested */
1000 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
1001 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
1002 if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
1003 autoc |= IXGBE_AUTOC_KX4_SUPP;

--- 21 unchanged lines hidden (view full) ---

1025 if (autoneg)
1026 autoc |= IXGBE_AUTOC_LMS_1G_AN;
1027 else
1028 autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
1029 }
1030 }
1031
1032 if (autoc != start_autoc) {
1033 /* Need SW/FW semaphore around AUTOC writes if LESM is on,
1034 * likewise reset_pipeline requires us to hold this lock as
1035 * it also writes to AUTOC.
1036 */
1037 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
1038 status = hw->mac.ops.acquire_swfw_sync(hw,
1039 IXGBE_GSSR_MAC_CSR_SM);
1040 if (status != IXGBE_SUCCESS) {
1041 status = IXGBE_ERR_SWFW_SYNC;
1042 goto out;
1043 }
1044
1045 got_lock = TRUE;
1046 }
1047
903 /* Restart link */
1048 /* Restart link */
904 autoc |= IXGBE_AUTOC_AN_RESTART;
905 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
1049 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
1050 hw->mac.cached_autoc = autoc;
1051 ixgbe_reset_pipeline_82599(hw);
906
1052
1053 if (got_lock) {
1054 hw->mac.ops.release_swfw_sync(hw,
1055 IXGBE_GSSR_MAC_CSR_SM);
1056 got_lock = FALSE;
1057 }
1058
907 /* Only poll for autoneg to complete if specified to do so */
908 if (autoneg_wait_to_complete) {
909 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
910 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
911 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
912 links_reg = 0; /*Just in case Autoneg time=0*/
913 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
914 links_reg =

--- 17 unchanged lines hidden (view full) ---

932out:
933 return status;
934}
935
936/**
937 * ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field
938 * @hw: pointer to hardware structure
939 * @speed: new link speed
1059 /* Only poll for autoneg to complete if specified to do so */
1060 if (autoneg_wait_to_complete) {
1061 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
1062 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
1063 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
1064 links_reg = 0; /*Just in case Autoneg time=0*/
1065 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
1066 links_reg =

--- 17 unchanged lines hidden (view full) ---

1084out:
1085 return status;
1086}
1087
1088/**
1089 * ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field
1090 * @hw: pointer to hardware structure
1091 * @speed: new link speed
940 * @autoneg: TRUE if autonegotiation enabled
941 * @autoneg_wait_to_complete: TRUE if waiting is needed to complete
942 *
943 * Restarts link on PHY and MAC based on settings passed in.
944 **/
945static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
946 ixgbe_link_speed speed,
1092 * @autoneg_wait_to_complete: TRUE if waiting is needed to complete
1093 *
1094 * Restarts link on PHY and MAC based on settings passed in.
1095 **/
1096static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
1097 ixgbe_link_speed speed,
947 bool autoneg,
948 bool autoneg_wait_to_complete)
949{
950 s32 status;
951
952 DEBUGFUNC("ixgbe_setup_copper_link_82599");
953
954 /* Setup the PHY according to input speed */
1098 bool autoneg_wait_to_complete)
1099{
1100 s32 status;
1101
1102 DEBUGFUNC("ixgbe_setup_copper_link_82599");
1103
1104 /* Setup the PHY according to input speed */
955 status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
1105 status = hw->phy.ops.setup_link_speed(hw, speed,
956 autoneg_wait_to_complete);
957 /* Set up MAC */
958 ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete);
959
960 return status;
961}
962
963/**

--- 87 unchanged lines hidden (view full) ---

1051
1052 /*
1053 * Store the original AUTOC/AUTOC2 values if they have not been
1054 * stored off yet. Otherwise restore the stored original
1055 * values since the reset operation sets back to defaults.
1056 */
1057 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1058 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1106 autoneg_wait_to_complete);
1107 /* Set up MAC */
1108 ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete);
1109
1110 return status;
1111}
1112
1113/**

--- 87 unchanged lines hidden (view full) ---

1201
1202 /*
1203 * Store the original AUTOC/AUTOC2 values if they have not been
1204 * stored off yet. Otherwise restore the stored original
1205 * values since the reset operation sets back to defaults.
1206 */
1207 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1208 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1209
1210 /* Enable link if disabled in NVM */
1211 if (autoc2 & IXGBE_AUTOC2_LINK_DISABLE_MASK) {
1212 autoc2 &= ~IXGBE_AUTOC2_LINK_DISABLE_MASK;
1213 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
1214 IXGBE_WRITE_FLUSH(hw);
1215 }
1216
1059 if (hw->mac.orig_link_settings_stored == FALSE) {
1060 hw->mac.orig_autoc = autoc;
1061 hw->mac.orig_autoc2 = autoc2;
1217 if (hw->mac.orig_link_settings_stored == FALSE) {
1218 hw->mac.orig_autoc = autoc;
1219 hw->mac.orig_autoc2 = autoc2;
1220 hw->mac.cached_autoc = autoc;
1062 hw->mac.orig_link_settings_stored = TRUE;
1063 } else {
1221 hw->mac.orig_link_settings_stored = TRUE;
1222 } else {
1064 if (autoc != hw->mac.orig_autoc)
1065 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (hw->mac.orig_autoc |
1066 IXGBE_AUTOC_AN_RESTART));
1223 if (autoc != hw->mac.orig_autoc) {
1224 /* Need SW/FW semaphore around AUTOC writes if LESM is
1225 * on, likewise reset_pipeline requires us to hold
1226 * this lock as it also writes to AUTOC.
1227 */
1228 bool got_lock = FALSE;
1229 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
1230 status = hw->mac.ops.acquire_swfw_sync(hw,
1231 IXGBE_GSSR_MAC_CSR_SM);
1232 if (status != IXGBE_SUCCESS) {
1233 status = IXGBE_ERR_SWFW_SYNC;
1234 goto reset_hw_out;
1235 }
1067
1236
1237 got_lock = TRUE;
1238 }
1239
1240 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
1241 hw->mac.cached_autoc = hw->mac.orig_autoc;
1242 ixgbe_reset_pipeline_82599(hw);
1243
1244 if (got_lock)
1245 hw->mac.ops.release_swfw_sync(hw,
1246 IXGBE_GSSR_MAC_CSR_SM);
1247 }
1248
1068 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
1069 (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
1070 autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
1071 autoc2 |= (hw->mac.orig_autoc2 &
1072 IXGBE_AUTOC2_UPPER_MASK);
1073 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
1074 }
1075 }

--- 87 unchanged lines hidden (view full) ---

1163 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1164 IXGBE_WRITE_FLUSH(hw);
1165
1166 /* Poll init-done after we write FDIRCTRL register */
1167 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1168 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1169 IXGBE_FDIRCTRL_INIT_DONE)
1170 break;
1249 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
1250 (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
1251 autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
1252 autoc2 |= (hw->mac.orig_autoc2 &
1253 IXGBE_AUTOC2_UPPER_MASK);
1254 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
1255 }
1256 }

--- 87 unchanged lines hidden (view full) ---

1344 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1345 IXGBE_WRITE_FLUSH(hw);
1346
1347 /* Poll init-done after we write FDIRCTRL register */
1348 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1349 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1350 IXGBE_FDIRCTRL_INIT_DONE)
1351 break;
1171 usec_delay(10);
1352 msec_delay(1);
1172 }
1173 if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
1174 DEBUGOUT("Flow Director Signature poll time exceeded!\n");
1175 return IXGBE_ERR_FDIR_REINIT_FAILED;
1176 }
1177
1178 /* Clear FDIR statistics registers (read to clear) */
1179 IXGBE_READ_REG(hw, IXGBE_FDIRUSTAT);

--- 909 unchanged lines hidden (view full) ---

2089 * @hw: pointer to hardware structure
2090 *
2091 * Verifies that installed the firmware version is 0.6 or higher
2092 * for SFI devices. All 82599 SFI devices should have version 0.6 or higher.
2093 *
2094 * Returns IXGBE_ERR_EEPROM_VERSION if the FW is not present or
2095 * if the FW version is not supported.
2096 **/
1353 }
1354 if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
1355 DEBUGOUT("Flow Director Signature poll time exceeded!\n");
1356 return IXGBE_ERR_FDIR_REINIT_FAILED;
1357 }
1358
1359 /* Clear FDIR statistics registers (read to clear) */
1360 IXGBE_READ_REG(hw, IXGBE_FDIRUSTAT);

--- 909 unchanged lines hidden (view full) ---

2270 * @hw: pointer to hardware structure
2271 *
2272 * Verifies that installed the firmware version is 0.6 or higher
2273 * for SFI devices. All 82599 SFI devices should have version 0.6 or higher.
2274 *
2275 * Returns IXGBE_ERR_EEPROM_VERSION if the FW is not present or
2276 * if the FW version is not supported.
2277 **/
2097static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
2278s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
2098{
2099 s32 status = IXGBE_ERR_EEPROM_VERSION;
2100 u16 fw_offset, fw_ptp_cfg_offset;
2101 u16 fw_version = 0;
2102
2103 DEBUGFUNC("ixgbe_verify_fw_version_82599");
2104
2105 /* firmware check is only necessary for SFI devices */

--- 132 unchanged lines hidden (view full) ---

2238 (offset <= IXGBE_EERD_MAX_ADDR))
2239 ret_val = ixgbe_read_eerd_generic(hw, offset, data);
2240 else
2241 ret_val = ixgbe_read_eeprom_bit_bang_generic(hw, offset, data);
2242
2243 return ret_val;
2244}
2245
2279{
2280 s32 status = IXGBE_ERR_EEPROM_VERSION;
2281 u16 fw_offset, fw_ptp_cfg_offset;
2282 u16 fw_version = 0;
2283
2284 DEBUGFUNC("ixgbe_verify_fw_version_82599");
2285
2286 /* firmware check is only necessary for SFI devices */

--- 132 unchanged lines hidden (view full) ---

2419 (offset <= IXGBE_EERD_MAX_ADDR))
2420 ret_val = ixgbe_read_eerd_generic(hw, offset, data);
2421 else
2422 ret_val = ixgbe_read_eeprom_bit_bang_generic(hw, offset, data);
2423
2424 return ret_val;
2425}
2426
2427/**
2428 * ixgbe_reset_pipeline_82599 - perform pipeline reset
2429 *
2430 * @hw: pointer to hardware structure
2431 *
2432 * Reset pipeline by asserting Restart_AN together with LMS change to ensure
2433 * full pipeline reset
2434 **/
2435s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)
2436{
2437 s32 ret_val;
2438 u32 anlp1_reg = 0;
2439 u32 i, autoc_reg, autoc2_reg;
2246
2440
2441 /* Enable link if disabled in NVM */
2442 autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
2443 if (autoc2_reg & IXGBE_AUTOC2_LINK_DISABLE_MASK) {
2444 autoc2_reg &= ~IXGBE_AUTOC2_LINK_DISABLE_MASK;
2445 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg);
2446 IXGBE_WRITE_FLUSH(hw);
2447 }
2448
2449 autoc_reg = hw->mac.cached_autoc;
2450 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
2451 /* Write AUTOC register with toggled LMS[2] bit and Restart_AN */
2452 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg ^ IXGBE_AUTOC_LMS_1G_AN);
2453 /* Wait for AN to leave state 0 */
2454 for (i = 0; i < 10; i++) {
2455 msec_delay(4);
2456 anlp1_reg = IXGBE_READ_REG(hw, IXGBE_ANLP1);
2457 if (anlp1_reg & IXGBE_ANLP1_AN_STATE_MASK)
2458 break;
2459 }
2460
2461 if (!(anlp1_reg & IXGBE_ANLP1_AN_STATE_MASK)) {
2462 DEBUGOUT("auto negotiation not completed\n");
2463 ret_val = IXGBE_ERR_RESET_FAILED;
2464 goto reset_pipeline_out;
2465 }
2466
2467 ret_val = IXGBE_SUCCESS;
2468
2469reset_pipeline_out:
2470 /* Write AUTOC register with original LMS field and Restart_AN */
2471 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
2472 IXGBE_WRITE_FLUSH(hw);
2473
2474 return ret_val;
2475}
2476
2477
2478