1 /******************************************************************************
3 Copyright (c) 2001-2013, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
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.
32 ******************************************************************************/
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"
41 static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
42 ixgbe_link_speed speed,
43 bool autoneg_wait_to_complete);
44 static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw);
45 static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
46 u16 offset, u16 *data);
47 static s32 ixgbe_read_eeprom_buffer_82599(struct ixgbe_hw *hw, u16 offset,
48 u16 words, u16 *data);
50 static bool ixgbe_mng_enabled(struct ixgbe_hw *hw)
52 u32 fwsm, manc, factps;
54 fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
55 if ((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT)
58 manc = IXGBE_READ_REG(hw, IXGBE_MANC);
59 if (!(manc & IXGBE_MANC_RCV_TCO_EN))
62 factps = IXGBE_READ_REG(hw, IXGBE_FACTPS);
63 if (factps & IXGBE_FACTPS_MNGCG)
69 void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
71 struct ixgbe_mac_info *mac = &hw->mac;
73 DEBUGFUNC("ixgbe_init_mac_link_ops_82599");
76 * enable the laser control functions for SFP+ fiber
79 if ((mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) &&
80 !hw->mng_fw_enabled) {
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;
88 mac->ops.disable_tx_laser = NULL;
89 mac->ops.enable_tx_laser = NULL;
90 mac->ops.flap_tx_laser = NULL;
93 if (hw->phy.multispeed_fiber) {
94 /* Set up dual speed SFP+ support */
95 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber;
97 if ((ixgbe_get_media_type(hw) == ixgbe_media_type_backplane) &&
98 (hw->phy.smart_speed == ixgbe_smart_speed_auto ||
99 hw->phy.smart_speed == ixgbe_smart_speed_on) &&
100 !ixgbe_verify_lesm_fw_enabled_82599(hw)) {
101 mac->ops.setup_link = &ixgbe_setup_mac_link_smartspeed;
103 mac->ops.setup_link = &ixgbe_setup_mac_link_82599;
109 * ixgbe_init_phy_ops_82599 - PHY/SFP specific init
110 * @hw: pointer to hardware structure
112 * Initialize any function pointers that were not able to be
113 * set during init_shared_code because the PHY/SFP type was
114 * not known. Perform the SFP init if necessary.
117 s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
119 struct ixgbe_mac_info *mac = &hw->mac;
120 struct ixgbe_phy_info *phy = &hw->phy;
121 s32 ret_val = IXGBE_SUCCESS;
123 DEBUGFUNC("ixgbe_init_phy_ops_82599");
125 /* Identify the PHY or SFP module */
126 ret_val = phy->ops.identify(hw);
127 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
128 goto init_phy_ops_out;
130 /* Setup function pointers based on detected SFP module and speeds */
131 ixgbe_init_mac_link_ops_82599(hw);
132 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown)
133 hw->phy.ops.reset = NULL;
135 /* If copper media, overwrite with copper function pointers */
136 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
137 mac->ops.setup_link = &ixgbe_setup_copper_link_82599;
138 mac->ops.get_link_capabilities =
139 &ixgbe_get_copper_link_capabilities_generic;
142 /* Set necessary function pointers based on phy type */
143 switch (hw->phy.type) {
145 phy->ops.setup_link = &ixgbe_setup_phy_link_tnx;
146 phy->ops.check_link = &ixgbe_check_phy_link_tnx;
147 phy->ops.get_firmware_version =
148 &ixgbe_get_phy_firmware_version_tnx;
157 s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
159 s32 ret_val = IXGBE_SUCCESS;
160 u16 list_offset, data_offset, data_value;
161 bool got_lock = FALSE;
163 DEBUGFUNC("ixgbe_setup_sfp_modules_82599");
165 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
166 ixgbe_init_mac_link_ops_82599(hw);
168 hw->phy.ops.reset = NULL;
170 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
172 if (ret_val != IXGBE_SUCCESS)
175 /* PHY config will finish before releasing the semaphore */
176 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
177 IXGBE_GSSR_MAC_CSR_SM);
178 if (ret_val != IXGBE_SUCCESS) {
179 ret_val = IXGBE_ERR_SWFW_SYNC;
183 if (hw->eeprom.ops.read(hw, ++data_offset, &data_value))
185 while (data_value != 0xffff) {
186 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, data_value);
187 IXGBE_WRITE_FLUSH(hw);
188 if (hw->eeprom.ops.read(hw, ++data_offset, &data_value))
192 /* Release the semaphore */
193 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
194 /* Delay obtaining semaphore again to allow FW access */
195 msec_delay(hw->eeprom.semaphore_delay);
197 /* Need SW/FW semaphore around AUTOC writes if LESM on,
198 * likewise reset_pipeline requires lock as it also writes
201 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
202 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
203 IXGBE_GSSR_MAC_CSR_SM);
204 if (ret_val != IXGBE_SUCCESS) {
205 ret_val = IXGBE_ERR_SWFW_SYNC;
212 /* Restart DSP and set SFI mode */
213 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((hw->mac.orig_autoc) |
214 IXGBE_AUTOC_LMS_10G_SERIAL));
215 hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
216 ret_val = ixgbe_reset_pipeline_82599(hw);
219 hw->mac.ops.release_swfw_sync(hw,
220 IXGBE_GSSR_MAC_CSR_SM);
225 DEBUGOUT("sfp module setup not complete\n");
226 ret_val = IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
236 /* Release the semaphore */
237 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
238 /* Delay obtaining semaphore again to allow FW access */
239 msec_delay(hw->eeprom.semaphore_delay);
240 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
241 "eeprom read at offset %d failed", data_offset);
242 return IXGBE_ERR_PHY;
246 * ixgbe_init_ops_82599 - Inits func ptrs and MAC type
247 * @hw: pointer to hardware structure
249 * Initialize the function pointers and assign the MAC type for 82599.
250 * Does not touch the hardware.
253 s32 ixgbe_init_ops_82599(struct ixgbe_hw *hw)
255 struct ixgbe_mac_info *mac = &hw->mac;
256 struct ixgbe_phy_info *phy = &hw->phy;
257 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
260 DEBUGFUNC("ixgbe_init_ops_82599");
262 ixgbe_init_phy_ops_generic(hw);
263 ret_val = ixgbe_init_ops_generic(hw);
266 phy->ops.identify = &ixgbe_identify_phy_82599;
267 phy->ops.init = &ixgbe_init_phy_ops_82599;
270 mac->ops.reset_hw = &ixgbe_reset_hw_82599;
271 mac->ops.enable_relaxed_ordering = &ixgbe_enable_relaxed_ordering_gen2;
272 mac->ops.get_media_type = &ixgbe_get_media_type_82599;
273 mac->ops.get_supported_physical_layer =
274 &ixgbe_get_supported_physical_layer_82599;
275 mac->ops.disable_sec_rx_path = &ixgbe_disable_sec_rx_path_generic;
276 mac->ops.enable_sec_rx_path = &ixgbe_enable_sec_rx_path_generic;
277 mac->ops.enable_rx_dma = &ixgbe_enable_rx_dma_82599;
278 mac->ops.read_analog_reg8 = &ixgbe_read_analog_reg8_82599;
279 mac->ops.write_analog_reg8 = &ixgbe_write_analog_reg8_82599;
280 mac->ops.start_hw = &ixgbe_start_hw_82599;
281 mac->ops.get_san_mac_addr = &ixgbe_get_san_mac_addr_generic;
282 mac->ops.set_san_mac_addr = &ixgbe_set_san_mac_addr_generic;
283 mac->ops.get_device_caps = &ixgbe_get_device_caps_generic;
284 mac->ops.get_wwn_prefix = &ixgbe_get_wwn_prefix_generic;
285 mac->ops.get_fcoe_boot_status = &ixgbe_get_fcoe_boot_status_generic;
287 /* RAR, Multicast, VLAN */
288 mac->ops.set_vmdq = &ixgbe_set_vmdq_generic;
289 mac->ops.set_vmdq_san_mac = &ixgbe_set_vmdq_san_mac_generic;
290 mac->ops.clear_vmdq = &ixgbe_clear_vmdq_generic;
291 mac->ops.insert_mac_addr = &ixgbe_insert_mac_addr_generic;
292 mac->rar_highwater = 1;
293 mac->ops.set_vfta = &ixgbe_set_vfta_generic;
294 mac->ops.set_vlvf = &ixgbe_set_vlvf_generic;
295 mac->ops.clear_vfta = &ixgbe_clear_vfta_generic;
296 mac->ops.init_uta_tables = &ixgbe_init_uta_tables_generic;
297 mac->ops.setup_sfp = &ixgbe_setup_sfp_modules_82599;
298 mac->ops.set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing;
299 mac->ops.set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing;
302 mac->ops.get_link_capabilities = &ixgbe_get_link_capabilities_82599;
303 mac->ops.check_link = &ixgbe_check_mac_link_generic;
304 mac->ops.setup_rxpba = &ixgbe_set_rxpba_generic;
305 ixgbe_init_mac_link_ops_82599(hw);
307 mac->mcft_size = 128;
309 mac->num_rar_entries = 128;
310 mac->rx_pb_size = 512;
311 mac->max_tx_queues = 128;
312 mac->max_rx_queues = 128;
313 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw);
315 mac->arc_subsystem_valid = (IXGBE_READ_REG(hw, IXGBE_FWSM) &
316 IXGBE_FWSM_MODE_MASK) ? TRUE : FALSE;
318 hw->mbx.ops.init_params = ixgbe_init_mbx_params_pf;
321 eeprom->ops.read = &ixgbe_read_eeprom_82599;
322 eeprom->ops.read_buffer = &ixgbe_read_eeprom_buffer_82599;
324 /* Manageability interface */
325 mac->ops.set_fw_drv_ver = &ixgbe_set_fw_drv_ver_generic;
328 mac->ops.get_rtrup2tc = &ixgbe_dcb_get_rtrup2tc_generic;
330 /* Cache if MNG FW is up */
331 hw->mng_fw_enabled = ixgbe_mng_enabled(hw);
337 * ixgbe_get_link_capabilities_82599 - Determines link capabilities
338 * @hw: pointer to hardware structure
339 * @speed: pointer to link speed
340 * @autoneg: TRUE when autoneg or autotry is enabled
342 * Determines the link capabilities by reading the AUTOC register.
344 s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
345 ixgbe_link_speed *speed,
348 s32 status = IXGBE_SUCCESS;
351 DEBUGFUNC("ixgbe_get_link_capabilities_82599");
354 /* Check if 1G SFP module. */
355 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
356 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
357 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
358 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
359 *speed = IXGBE_LINK_SPEED_1GB_FULL;
365 * Determine link capabilities based on the stored value of AUTOC,
366 * which represents EEPROM defaults. If AUTOC value has not
367 * been stored, use the current register values.
369 if (hw->mac.orig_link_settings_stored)
370 autoc = hw->mac.orig_autoc;
372 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
374 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
375 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
376 *speed = IXGBE_LINK_SPEED_1GB_FULL;
380 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
381 *speed = IXGBE_LINK_SPEED_10GB_FULL;
385 case IXGBE_AUTOC_LMS_1G_AN:
386 *speed = IXGBE_LINK_SPEED_1GB_FULL;
390 case IXGBE_AUTOC_LMS_10G_SERIAL:
391 *speed = IXGBE_LINK_SPEED_10GB_FULL;
395 case IXGBE_AUTOC_LMS_KX4_KX_KR:
396 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
397 *speed = IXGBE_LINK_SPEED_UNKNOWN;
398 if (autoc & IXGBE_AUTOC_KR_SUPP)
399 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
400 if (autoc & IXGBE_AUTOC_KX4_SUPP)
401 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
402 if (autoc & IXGBE_AUTOC_KX_SUPP)
403 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
407 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
408 *speed = IXGBE_LINK_SPEED_100_FULL;
409 if (autoc & IXGBE_AUTOC_KR_SUPP)
410 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
411 if (autoc & IXGBE_AUTOC_KX4_SUPP)
412 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
413 if (autoc & IXGBE_AUTOC_KX_SUPP)
414 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
418 case IXGBE_AUTOC_LMS_SGMII_1G_100M:
419 *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
424 status = IXGBE_ERR_LINK_SETUP;
429 if (hw->phy.multispeed_fiber) {
430 *speed |= IXGBE_LINK_SPEED_10GB_FULL |
431 IXGBE_LINK_SPEED_1GB_FULL;
440 * ixgbe_get_media_type_82599 - Get media type
441 * @hw: pointer to hardware structure
443 * Returns the media type (fiber, copper, backplane)
445 enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
447 enum ixgbe_media_type media_type;
449 DEBUGFUNC("ixgbe_get_media_type_82599");
451 /* Detect if there is a copper PHY attached. */
452 switch (hw->phy.type) {
453 case ixgbe_phy_cu_unknown:
455 media_type = ixgbe_media_type_copper;
461 switch (hw->device_id) {
462 case IXGBE_DEV_ID_82599_KX4:
463 case IXGBE_DEV_ID_82599_KX4_MEZZ:
464 case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
465 case IXGBE_DEV_ID_82599_KR:
466 case IXGBE_DEV_ID_82599_BACKPLANE_FCOE:
467 case IXGBE_DEV_ID_82599_XAUI_LOM:
468 /* Default device ID is mezzanine card KX/KX4 */
469 media_type = ixgbe_media_type_backplane;
471 case IXGBE_DEV_ID_82599_SFP:
472 case IXGBE_DEV_ID_82599_SFP_FCOE:
473 case IXGBE_DEV_ID_82599_SFP_EM:
474 case IXGBE_DEV_ID_82599_SFP_SF2:
475 case IXGBE_DEV_ID_82599_SFP_SF_QP:
476 case IXGBE_DEV_ID_82599EN_SFP:
477 media_type = ixgbe_media_type_fiber;
479 case IXGBE_DEV_ID_82599_CX4:
480 media_type = ixgbe_media_type_cx4;
482 case IXGBE_DEV_ID_82599_T3_LOM:
483 media_type = ixgbe_media_type_copper;
485 case IXGBE_DEV_ID_82599_BYPASS:
486 media_type = ixgbe_media_type_fiber_fixed;
487 hw->phy.multispeed_fiber = TRUE;
490 media_type = ixgbe_media_type_unknown;
498 * ixgbe_stop_mac_link_on_d3_82599 - Disables link on D3
499 * @hw: pointer to hardware structure
501 * Disables link during D3 power down sequence.
504 void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw)
509 DEBUGFUNC("ixgbe_stop_mac_link_on_d3_82599");
510 ixgbe_read_eeprom(hw, IXGBE_EEPROM_CTRL_2, &ee_ctrl_2);
512 if (!hw->mng_fw_enabled && !hw->wol_enabled &&
513 ee_ctrl_2 & IXGBE_EEPROM_CCD_BIT) {
514 autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
515 autoc2_reg |= IXGBE_AUTOC2_LINK_DISABLE_ON_D3_MASK;
516 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg);
521 * ixgbe_start_mac_link_82599 - Setup MAC link settings
522 * @hw: pointer to hardware structure
523 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
525 * Configures link settings based on values in the ixgbe_hw struct.
526 * Restarts the link. Performs autonegotiation if needed.
528 s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
529 bool autoneg_wait_to_complete)
534 s32 status = IXGBE_SUCCESS;
535 bool got_lock = FALSE;
537 DEBUGFUNC("ixgbe_start_mac_link_82599");
540 /* reset_pipeline requires us to hold this lock as it writes to
543 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
544 status = hw->mac.ops.acquire_swfw_sync(hw,
545 IXGBE_GSSR_MAC_CSR_SM);
546 if (status != IXGBE_SUCCESS)
553 ixgbe_reset_pipeline_82599(hw);
556 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
558 /* Only poll for autoneg to complete if specified to do so */
559 if (autoneg_wait_to_complete) {
560 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
561 if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
562 IXGBE_AUTOC_LMS_KX4_KX_KR ||
563 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
564 IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
565 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
566 IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
567 links_reg = 0; /* Just in case Autoneg time = 0 */
568 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
569 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
570 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
574 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
575 status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
576 DEBUGOUT("Autoneg did not complete.\n");
581 /* Add delay to filter out noises during initial link setup */
589 * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
590 * @hw: pointer to hardware structure
592 * The base drivers may require better control over SFP+ module
593 * PHY states. This includes selectively shutting down the Tx
594 * laser on the PHY, effectively halting physical link.
596 void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
598 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
600 /* Disable tx laser; allow 100us to go dark per spec */
601 esdp_reg |= IXGBE_ESDP_SDP3;
602 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
603 IXGBE_WRITE_FLUSH(hw);
608 * ixgbe_enable_tx_laser_multispeed_fiber - Enable Tx laser
609 * @hw: pointer to hardware structure
611 * The base drivers may require better control over SFP+ module
612 * PHY states. This includes selectively turning on the Tx
613 * laser on the PHY, effectively starting physical link.
615 void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
617 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
619 /* Enable tx laser; allow 100ms to light up */
620 esdp_reg &= ~IXGBE_ESDP_SDP3;
621 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
622 IXGBE_WRITE_FLUSH(hw);
627 * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser
628 * @hw: pointer to hardware structure
630 * When the driver changes the link speeds that it can support,
631 * it sets autotry_restart to TRUE to indicate that we need to
632 * initiate a new autotry session with the link partner. To do
633 * so, we set the speed then disable and re-enable the tx laser, to
634 * alert the link partner that it also needs to restart autotry on its
635 * end. This is consistent with TRUE clause 37 autoneg, which also
636 * involves a loss of signal.
638 void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
640 DEBUGFUNC("ixgbe_flap_tx_laser_multispeed_fiber");
642 if (hw->mac.autotry_restart) {
643 ixgbe_disable_tx_laser_multispeed_fiber(hw);
644 ixgbe_enable_tx_laser_multispeed_fiber(hw);
645 hw->mac.autotry_restart = FALSE;
650 * ixgbe_set_fiber_fixed_speed - Set module link speed for fixed fiber
651 * @hw: pointer to hardware structure
652 * @speed: link speed to set
654 * We set the module speed differently for fixed fiber. For other
655 * multi-speed devices we don't have an error value so here if we
656 * detect an error we just log it and exit.
658 static void ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw,
659 ixgbe_link_speed speed)
665 case IXGBE_LINK_SPEED_10GB_FULL:
666 /* one bit mask same as setting on */
667 rs = IXGBE_SFF_SOFT_RS_SELECT_10G;
669 case IXGBE_LINK_SPEED_1GB_FULL:
670 rs = IXGBE_SFF_SOFT_RS_SELECT_1G;
673 DEBUGOUT("Invalid fixed module speed\n");
678 status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
679 IXGBE_I2C_EEPROM_DEV_ADDR2,
682 DEBUGOUT("Failed to read Rx Rate Select RS0\n");
686 eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
688 status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
689 IXGBE_I2C_EEPROM_DEV_ADDR2,
692 DEBUGOUT("Failed to write Rx Rate Select RS0\n");
697 status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
698 IXGBE_I2C_EEPROM_DEV_ADDR2,
701 DEBUGOUT("Failed to read Rx Rate Select RS1\n");
705 eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
707 status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
708 IXGBE_I2C_EEPROM_DEV_ADDR2,
711 DEBUGOUT("Failed to write Rx Rate Select RS1\n");
719 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
720 * @hw: pointer to hardware structure
721 * @speed: new link speed
722 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
724 * Set the link speed in the AUTOC register and restarts link.
726 s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
727 ixgbe_link_speed speed,
728 bool autoneg_wait_to_complete)
730 s32 status = IXGBE_SUCCESS;
731 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
732 ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
734 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
736 bool autoneg, link_up = FALSE;
738 DEBUGFUNC("ixgbe_setup_mac_link_multispeed_fiber");
740 /* Mask off requested but non-supported speeds */
741 status = ixgbe_get_link_capabilities(hw, &link_speed, &autoneg);
742 if (status != IXGBE_SUCCESS)
748 * Try each speed one by one, highest priority first. We do this in
749 * software because 10gb fiber doesn't support speed autonegotiation.
751 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
753 highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL;
755 /* If we already have link at this speed, just jump out */
756 status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
757 if (status != IXGBE_SUCCESS)
760 if ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
763 /* Set the module link speed */
764 if (hw->phy.media_type == ixgbe_media_type_fiber_fixed) {
765 ixgbe_set_fiber_fixed_speed(hw,
766 IXGBE_LINK_SPEED_10GB_FULL);
768 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
769 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
770 IXGBE_WRITE_FLUSH(hw);
773 /* Allow module to change analog characteristics (1G->10G) */
776 status = ixgbe_setup_mac_link_82599(hw,
777 IXGBE_LINK_SPEED_10GB_FULL,
778 autoneg_wait_to_complete);
779 if (status != IXGBE_SUCCESS)
782 /* Flap the tx laser if it has not already been done */
783 ixgbe_flap_tx_laser(hw);
786 * Wait for the controller to acquire link. Per IEEE 802.3ap,
787 * Section 73.10.2, we may have to wait up to 500ms if KR is
788 * attempted. 82599 uses the same timing for 10g SFI.
790 for (i = 0; i < 5; i++) {
791 /* Wait for the link partner to also set speed */
794 /* If we have link, just jump out */
795 status = ixgbe_check_link(hw, &link_speed,
797 if (status != IXGBE_SUCCESS)
805 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
807 if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN)
808 highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL;
810 /* If we already have link at this speed, just jump out */
811 status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
812 if (status != IXGBE_SUCCESS)
815 if ((link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
818 /* Set the module link speed */
819 if (hw->phy.media_type == ixgbe_media_type_fiber_fixed) {
820 ixgbe_set_fiber_fixed_speed(hw,
821 IXGBE_LINK_SPEED_1GB_FULL);
823 esdp_reg &= ~IXGBE_ESDP_SDP5;
824 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
825 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
826 IXGBE_WRITE_FLUSH(hw);
829 /* Allow module to change analog characteristics (10G->1G) */
832 status = ixgbe_setup_mac_link_82599(hw,
833 IXGBE_LINK_SPEED_1GB_FULL,
834 autoneg_wait_to_complete);
835 if (status != IXGBE_SUCCESS)
838 /* Flap the tx laser if it has not already been done */
839 ixgbe_flap_tx_laser(hw);
841 /* Wait for the link partner to also set speed */
844 /* If we have link, just jump out */
845 status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
846 if (status != IXGBE_SUCCESS)
854 * We didn't get link. Configure back to the highest speed we tried,
855 * (if there was more than one). We call ourselves back with just the
856 * single highest speed that the user requested.
859 status = ixgbe_setup_mac_link_multispeed_fiber(hw,
860 highest_link_speed, autoneg_wait_to_complete);
863 /* Set autoneg_advertised value based on input link speed */
864 hw->phy.autoneg_advertised = 0;
866 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
867 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
869 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
870 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
876 * ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed
877 * @hw: pointer to hardware structure
878 * @speed: new link speed
879 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
881 * Implements the Intel SmartSpeed algorithm.
883 s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
884 ixgbe_link_speed speed,
885 bool autoneg_wait_to_complete)
887 s32 status = IXGBE_SUCCESS;
888 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
890 bool link_up = FALSE;
891 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
893 DEBUGFUNC("ixgbe_setup_mac_link_smartspeed");
895 /* Set autoneg_advertised value based on input link speed */
896 hw->phy.autoneg_advertised = 0;
898 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
899 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
901 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
902 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
904 if (speed & IXGBE_LINK_SPEED_100_FULL)
905 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
908 * Implement Intel SmartSpeed algorithm. SmartSpeed will reduce the
909 * autoneg advertisement if link is unable to be established at the
910 * highest negotiated rate. This can sometimes happen due to integrity
911 * issues with the physical media connection.
914 /* First, try to get link with full advertisement */
915 hw->phy.smart_speed_active = FALSE;
916 for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) {
917 status = ixgbe_setup_mac_link_82599(hw, speed,
918 autoneg_wait_to_complete);
919 if (status != IXGBE_SUCCESS)
923 * Wait for the controller to acquire link. Per IEEE 802.3ap,
924 * Section 73.10.2, we may have to wait up to 500ms if KR is
925 * attempted, or 200ms if KX/KX4/BX/BX4 is attempted, per
926 * Table 9 in the AN MAS.
928 for (i = 0; i < 5; i++) {
931 /* If we have link, just jump out */
932 status = ixgbe_check_link(hw, &link_speed, &link_up,
934 if (status != IXGBE_SUCCESS)
943 * We didn't get link. If we advertised KR plus one of KX4/KX
944 * (or BX4/BX), then disable KR and try again.
946 if (((autoc_reg & IXGBE_AUTOC_KR_SUPP) == 0) ||
947 ((autoc_reg & IXGBE_AUTOC_KX4_KX_SUPP_MASK) == 0))
950 /* Turn SmartSpeed on to disable KR support */
951 hw->phy.smart_speed_active = TRUE;
952 status = ixgbe_setup_mac_link_82599(hw, speed,
953 autoneg_wait_to_complete);
954 if (status != IXGBE_SUCCESS)
958 * Wait for the controller to acquire link. 600ms will allow for
959 * the AN link_fail_inhibit_timer as well for multiple cycles of
960 * parallel detect, both 10g and 1g. This allows for the maximum
961 * connect attempts as defined in the AN MAS table 73-7.
963 for (i = 0; i < 6; i++) {
966 /* If we have link, just jump out */
967 status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
968 if (status != IXGBE_SUCCESS)
975 /* We didn't get link. Turn SmartSpeed back off. */
976 hw->phy.smart_speed_active = FALSE;
977 status = ixgbe_setup_mac_link_82599(hw, speed,
978 autoneg_wait_to_complete);
981 if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL))
982 DEBUGOUT("Smartspeed has downgraded the link speed "
983 "from the maximum advertised\n");
988 * ixgbe_setup_mac_link_82599 - Set MAC link speed
989 * @hw: pointer to hardware structure
990 * @speed: new link speed
991 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
993 * Set the link speed in the AUTOC register and restarts link.
995 s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
996 ixgbe_link_speed speed,
997 bool autoneg_wait_to_complete)
999 bool autoneg = FALSE;
1000 s32 status = IXGBE_SUCCESS;
1001 u32 autoc, pma_pmd_1g, link_mode, start_autoc;
1002 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1004 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
1007 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
1008 bool got_lock = FALSE;
1010 DEBUGFUNC("ixgbe_setup_mac_link_82599");
1012 /* Check to see if speed passed in is supported. */
1013 status = ixgbe_get_link_capabilities(hw, &link_capabilities, &autoneg);
1017 speed &= link_capabilities;
1019 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
1020 status = IXGBE_ERR_LINK_SETUP;
1024 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
1025 if (hw->mac.orig_link_settings_stored)
1026 autoc = hw->mac.orig_autoc;
1028 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1031 start_autoc = hw->mac.cached_autoc;
1032 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
1033 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
1035 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
1036 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
1037 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
1038 /* Set KX4/KX/KR support according to speed requested */
1039 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
1040 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
1041 if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
1042 autoc |= IXGBE_AUTOC_KX4_SUPP;
1043 if ((orig_autoc & IXGBE_AUTOC_KR_SUPP) &&
1044 (hw->phy.smart_speed_active == FALSE))
1045 autoc |= IXGBE_AUTOC_KR_SUPP;
1047 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
1048 autoc |= IXGBE_AUTOC_KX_SUPP;
1049 } else if ((pma_pmd_1g == IXGBE_AUTOC_1G_SFI) &&
1050 (link_mode == IXGBE_AUTOC_LMS_1G_LINK_NO_AN ||
1051 link_mode == IXGBE_AUTOC_LMS_1G_AN)) {
1052 /* Switch from 1G SFI to 10G SFI if requested */
1053 if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&
1054 (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)) {
1055 autoc &= ~IXGBE_AUTOC_LMS_MASK;
1056 autoc |= IXGBE_AUTOC_LMS_10G_SERIAL;
1058 } else if ((pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI) &&
1059 (link_mode == IXGBE_AUTOC_LMS_10G_SERIAL)) {
1060 /* Switch from 10G SFI to 1G SFI if requested */
1061 if ((speed == IXGBE_LINK_SPEED_1GB_FULL) &&
1062 (pma_pmd_1g == IXGBE_AUTOC_1G_SFI)) {
1063 autoc &= ~IXGBE_AUTOC_LMS_MASK;
1065 autoc |= IXGBE_AUTOC_LMS_1G_AN;
1067 autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
1071 if (autoc != start_autoc) {
1072 /* Need SW/FW semaphore around AUTOC writes if LESM is on,
1073 * likewise reset_pipeline requires us to hold this lock as
1074 * it also writes to AUTOC.
1076 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
1077 status = hw->mac.ops.acquire_swfw_sync(hw,
1078 IXGBE_GSSR_MAC_CSR_SM);
1079 if (status != IXGBE_SUCCESS) {
1080 status = IXGBE_ERR_SWFW_SYNC;
1088 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
1089 hw->mac.cached_autoc = autoc;
1090 ixgbe_reset_pipeline_82599(hw);
1093 hw->mac.ops.release_swfw_sync(hw,
1094 IXGBE_GSSR_MAC_CSR_SM);
1098 /* Only poll for autoneg to complete if specified to do so */
1099 if (autoneg_wait_to_complete) {
1100 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
1101 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
1102 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
1103 links_reg = 0; /*Just in case Autoneg time=0*/
1104 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
1106 IXGBE_READ_REG(hw, IXGBE_LINKS);
1107 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
1111 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
1113 IXGBE_ERR_AUTONEG_NOT_COMPLETE;
1114 DEBUGOUT("Autoneg did not complete.\n");
1119 /* Add delay to filter out noises during initial link setup */
1128 * ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field
1129 * @hw: pointer to hardware structure
1130 * @speed: new link speed
1131 * @autoneg_wait_to_complete: TRUE if waiting is needed to complete
1133 * Restarts link on PHY and MAC based on settings passed in.
1135 static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
1136 ixgbe_link_speed speed,
1137 bool autoneg_wait_to_complete)
1141 DEBUGFUNC("ixgbe_setup_copper_link_82599");
1143 /* Setup the PHY according to input speed */
1144 status = hw->phy.ops.setup_link_speed(hw, speed,
1145 autoneg_wait_to_complete);
1147 ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete);
1153 * ixgbe_reset_hw_82599 - Perform hardware reset
1154 * @hw: pointer to hardware structure
1156 * Resets the hardware by resetting the transmit and receive units, masks
1157 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
1160 s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
1162 ixgbe_link_speed link_speed;
1164 u32 ctrl, i, autoc2;
1166 bool link_up = FALSE;
1168 DEBUGFUNC("ixgbe_reset_hw_82599");
1170 /* Call adapter stop to disable tx/rx and clear interrupts */
1171 status = hw->mac.ops.stop_adapter(hw);
1172 if (status != IXGBE_SUCCESS)
1175 /* flush pending Tx transactions */
1176 ixgbe_clear_tx_pending(hw);
1178 /* PHY ops must be identified and initialized prior to reset */
1180 /* Identify PHY and related function pointers */
1181 status = hw->phy.ops.init(hw);
1183 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1186 /* Setup SFP module if there is one present. */
1187 if (hw->phy.sfp_setup_needed) {
1188 status = hw->mac.ops.setup_sfp(hw);
1189 hw->phy.sfp_setup_needed = FALSE;
1192 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1196 if (hw->phy.reset_disable == FALSE && hw->phy.ops.reset != NULL)
1197 hw->phy.ops.reset(hw);
1199 /* remember AUTOC from before we reset */
1200 if (hw->mac.cached_autoc)
1201 curr_lms = hw->mac.cached_autoc & IXGBE_AUTOC_LMS_MASK;
1203 curr_lms = IXGBE_READ_REG(hw, IXGBE_AUTOC) &
1204 IXGBE_AUTOC_LMS_MASK;
1208 * Issue global reset to the MAC. Needs to be SW reset if link is up.
1209 * If link reset is used when link is up, it might reset the PHY when
1210 * mng is using it. If link is down or the flag to force full link
1211 * reset is set, then perform link reset.
1213 ctrl = IXGBE_CTRL_LNK_RST;
1214 if (!hw->force_full_reset) {
1215 hw->mac.ops.check_link(hw, &link_speed, &link_up, FALSE);
1217 ctrl = IXGBE_CTRL_RST;
1220 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
1221 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
1222 IXGBE_WRITE_FLUSH(hw);
1224 /* Poll for reset bit to self-clear indicating reset is complete */
1225 for (i = 0; i < 10; i++) {
1227 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
1228 if (!(ctrl & IXGBE_CTRL_RST_MASK))
1232 if (ctrl & IXGBE_CTRL_RST_MASK) {
1233 status = IXGBE_ERR_RESET_FAILED;
1234 DEBUGOUT("Reset polling failed to complete.\n");
1240 * Double resets are required for recovery from certain error
1241 * conditions. Between resets, it is necessary to stall to allow time
1242 * for any pending HW events to complete.
1244 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
1245 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
1250 * Store the original AUTOC/AUTOC2 values if they have not been
1251 * stored off yet. Otherwise restore the stored original
1252 * values since the reset operation sets back to defaults.
1254 hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1255 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1257 /* Enable link if disabled in NVM */
1258 if (autoc2 & IXGBE_AUTOC2_LINK_DISABLE_MASK) {
1259 autoc2 &= ~IXGBE_AUTOC2_LINK_DISABLE_MASK;
1260 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
1261 IXGBE_WRITE_FLUSH(hw);
1264 if (hw->mac.orig_link_settings_stored == FALSE) {
1265 hw->mac.orig_autoc = hw->mac.cached_autoc;
1266 hw->mac.orig_autoc2 = autoc2;
1267 hw->mac.orig_link_settings_stored = TRUE;
1270 /* If MNG FW is running on a multi-speed device that
1271 * doesn't autoneg with out driver support we need to
1272 * leave LMS in the state it was before we MAC reset.
1273 * Likewise if we support WoL we don't want change the
1276 if ((hw->phy.multispeed_fiber && hw->mng_fw_enabled) ||
1278 hw->mac.orig_autoc =
1279 (hw->mac.orig_autoc & ~IXGBE_AUTOC_LMS_MASK) |
1282 if (hw->mac.cached_autoc != hw->mac.orig_autoc) {
1283 /* Need SW/FW semaphore around AUTOC writes if LESM is
1284 * on, likewise reset_pipeline requires us to hold
1285 * this lock as it also writes to AUTOC.
1287 bool got_lock = FALSE;
1288 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
1289 status = hw->mac.ops.acquire_swfw_sync(hw,
1290 IXGBE_GSSR_MAC_CSR_SM);
1291 if (status != IXGBE_SUCCESS) {
1292 status = IXGBE_ERR_SWFW_SYNC;
1299 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
1300 hw->mac.cached_autoc = hw->mac.orig_autoc;
1301 ixgbe_reset_pipeline_82599(hw);
1304 hw->mac.ops.release_swfw_sync(hw,
1305 IXGBE_GSSR_MAC_CSR_SM);
1308 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
1309 (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
1310 autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
1311 autoc2 |= (hw->mac.orig_autoc2 &
1312 IXGBE_AUTOC2_UPPER_MASK);
1313 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
1317 /* Store the permanent mac address */
1318 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
1321 * Store MAC address from RAR0, clear receive address registers, and
1322 * clear the multicast table. Also reset num_rar_entries to 128,
1323 * since we modify this value when programming the SAN MAC address.
1325 hw->mac.num_rar_entries = 128;
1326 hw->mac.ops.init_rx_addrs(hw);
1328 /* Store the permanent SAN mac address */
1329 hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
1331 /* Add the SAN MAC address to the RAR only if it's a valid address */
1332 if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
1333 hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
1334 hw->mac.san_addr, 0, IXGBE_RAH_AV);
1336 /* Save the SAN MAC RAR index */
1337 hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
1339 /* Reserve the last RAR for the SAN MAC address */
1340 hw->mac.num_rar_entries--;
1343 /* Store the alternative WWNN/WWPN prefix */
1344 hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
1345 &hw->mac.wwpn_prefix);
1352 * ixgbe_reinit_fdir_tables_82599 - Reinitialize Flow Director tables.
1353 * @hw: pointer to hardware structure
1355 s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
1358 u32 fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
1359 fdirctrl &= ~IXGBE_FDIRCTRL_INIT_DONE;
1361 DEBUGFUNC("ixgbe_reinit_fdir_tables_82599");
1364 * Before starting reinitialization process,
1365 * FDIRCMD.CMD must be zero.
1367 for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) {
1368 if (!(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
1369 IXGBE_FDIRCMD_CMD_MASK))
1373 if (i >= IXGBE_FDIRCMD_CMD_POLL) {
1374 DEBUGOUT("Flow Director previous command isn't complete, "
1375 "aborting table re-initialization.\n");
1376 return IXGBE_ERR_FDIR_REINIT_FAILED;
1379 IXGBE_WRITE_REG(hw, IXGBE_FDIRFREE, 0);
1380 IXGBE_WRITE_FLUSH(hw);
1382 * 82599 adapters flow director init flow cannot be restarted,
1383 * Workaround 82599 silicon errata by performing the following steps
1384 * before re-writing the FDIRCTRL control register with the same value.
1385 * - write 1 to bit 8 of FDIRCMD register &
1386 * - write 0 to bit 8 of FDIRCMD register
1388 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
1389 (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) |
1390 IXGBE_FDIRCMD_CLEARHT));
1391 IXGBE_WRITE_FLUSH(hw);
1392 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
1393 (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
1394 ~IXGBE_FDIRCMD_CLEARHT));
1395 IXGBE_WRITE_FLUSH(hw);
1397 * Clear FDIR Hash register to clear any leftover hashes
1398 * waiting to be programmed.
1400 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, 0x00);
1401 IXGBE_WRITE_FLUSH(hw);
1403 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1404 IXGBE_WRITE_FLUSH(hw);
1406 /* Poll init-done after we write FDIRCTRL register */
1407 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1408 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1409 IXGBE_FDIRCTRL_INIT_DONE)
1413 if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
1414 DEBUGOUT("Flow Director Signature poll time exceeded!\n");
1415 return IXGBE_ERR_FDIR_REINIT_FAILED;
1418 /* Clear FDIR statistics registers (read to clear) */
1419 IXGBE_READ_REG(hw, IXGBE_FDIRUSTAT);
1420 IXGBE_READ_REG(hw, IXGBE_FDIRFSTAT);
1421 IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
1422 IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
1423 IXGBE_READ_REG(hw, IXGBE_FDIRLEN);
1425 return IXGBE_SUCCESS;
1429 * ixgbe_fdir_enable_82599 - Initialize Flow Director control registers
1430 * @hw: pointer to hardware structure
1431 * @fdirctrl: value to write to flow director control register
1433 static void ixgbe_fdir_enable_82599(struct ixgbe_hw *hw, u32 fdirctrl)
1437 DEBUGFUNC("ixgbe_fdir_enable_82599");
1439 /* Prime the keys for hashing */
1440 IXGBE_WRITE_REG(hw, IXGBE_FDIRHKEY, IXGBE_ATR_BUCKET_HASH_KEY);
1441 IXGBE_WRITE_REG(hw, IXGBE_FDIRSKEY, IXGBE_ATR_SIGNATURE_HASH_KEY);
1444 * Poll init-done after we write the register. Estimated times:
1445 * 10G: PBALLOC = 11b, timing is 60us
1446 * 1G: PBALLOC = 11b, timing is 600us
1447 * 100M: PBALLOC = 11b, timing is 6ms
1449 * Multiple these timings by 4 if under full Rx load
1451 * So we'll poll for IXGBE_FDIR_INIT_DONE_POLL times, sleeping for
1452 * 1 msec per poll time. If we're at line rate and drop to 100M, then
1453 * this might not finish in our poll time, but we can live with that
1456 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1457 IXGBE_WRITE_FLUSH(hw);
1458 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1459 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1460 IXGBE_FDIRCTRL_INIT_DONE)
1465 if (i >= IXGBE_FDIR_INIT_DONE_POLL)
1466 DEBUGOUT("Flow Director poll time exceeded!\n");
1470 * ixgbe_init_fdir_signature_82599 - Initialize Flow Director signature filters
1471 * @hw: pointer to hardware structure
1472 * @fdirctrl: value to write to flow director control register, initially
1473 * contains just the value of the Rx packet buffer allocation
1475 s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl)
1477 DEBUGFUNC("ixgbe_init_fdir_signature_82599");
1480 * Continue setup of fdirctrl register bits:
1481 * Move the flexible bytes to use the ethertype - shift 6 words
1482 * Set the maximum length per hash bucket to 0xA filters
1483 * Send interrupt when 64 filters are left
1485 fdirctrl |= (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT) |
1486 (0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT) |
1487 (4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT);
1489 /* write hashes and fdirctrl register, poll for completion */
1490 ixgbe_fdir_enable_82599(hw, fdirctrl);
1492 return IXGBE_SUCCESS;
1496 * ixgbe_init_fdir_perfect_82599 - Initialize Flow Director perfect filters
1497 * @hw: pointer to hardware structure
1498 * @fdirctrl: value to write to flow director control register, initially
1499 * contains just the value of the Rx packet buffer allocation
1501 s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl)
1503 DEBUGFUNC("ixgbe_init_fdir_perfect_82599");
1506 * Continue setup of fdirctrl register bits:
1507 * Turn perfect match filtering on
1508 * Report hash in RSS field of Rx wb descriptor
1509 * Initialize the drop queue
1510 * Move the flexible bytes to use the ethertype - shift 6 words
1511 * Set the maximum length per hash bucket to 0xA filters
1512 * Send interrupt when 64 (0x4 * 16) filters are left
1514 fdirctrl |= IXGBE_FDIRCTRL_PERFECT_MATCH |
1515 IXGBE_FDIRCTRL_REPORT_STATUS |
1516 (IXGBE_FDIR_DROP_QUEUE << IXGBE_FDIRCTRL_DROP_Q_SHIFT) |
1517 (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT) |
1518 (0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT) |
1519 (4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT);
1521 /* write hashes and fdirctrl register, poll for completion */
1522 ixgbe_fdir_enable_82599(hw, fdirctrl);
1524 return IXGBE_SUCCESS;
1528 * These defines allow us to quickly generate all of the necessary instructions
1529 * in the function below by simply calling out IXGBE_COMPUTE_SIG_HASH_ITERATION
1530 * for values 0 through 15
1532 #define IXGBE_ATR_COMMON_HASH_KEY \
1533 (IXGBE_ATR_BUCKET_HASH_KEY & IXGBE_ATR_SIGNATURE_HASH_KEY)
1534 #define IXGBE_COMPUTE_SIG_HASH_ITERATION(_n) \
1537 if (IXGBE_ATR_COMMON_HASH_KEY & (0x01 << n)) \
1538 common_hash ^= lo_hash_dword >> n; \
1539 else if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << n)) \
1540 bucket_hash ^= lo_hash_dword >> n; \
1541 else if (IXGBE_ATR_SIGNATURE_HASH_KEY & (0x01 << n)) \
1542 sig_hash ^= lo_hash_dword << (16 - n); \
1543 if (IXGBE_ATR_COMMON_HASH_KEY & (0x01 << (n + 16))) \
1544 common_hash ^= hi_hash_dword >> n; \
1545 else if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << (n + 16))) \
1546 bucket_hash ^= hi_hash_dword >> n; \
1547 else if (IXGBE_ATR_SIGNATURE_HASH_KEY & (0x01 << (n + 16))) \
1548 sig_hash ^= hi_hash_dword << (16 - n); \
1552 * ixgbe_atr_compute_sig_hash_82599 - Compute the signature hash
1553 * @stream: input bitstream to compute the hash on
1555 * This function is almost identical to the function above but contains
1556 * several optomizations such as unwinding all of the loops, letting the
1557 * compiler work out all of the conditional ifs since the keys are static
1558 * defines, and computing two keys at once since the hashed dword stream
1559 * will be the same for both keys.
1561 u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input,
1562 union ixgbe_atr_hash_dword common)
1564 u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan;
1565 u32 sig_hash = 0, bucket_hash = 0, common_hash = 0;
1567 /* record the flow_vm_vlan bits as they are a key part to the hash */
1568 flow_vm_vlan = IXGBE_NTOHL(input.dword);
1570 /* generate common hash dword */
1571 hi_hash_dword = IXGBE_NTOHL(common.dword);
1573 /* low dword is word swapped version of common */
1574 lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16);
1576 /* apply flow ID/VM pool/VLAN ID bits to hash words */
1577 hi_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan >> 16);
1579 /* Process bits 0 and 16 */
1580 IXGBE_COMPUTE_SIG_HASH_ITERATION(0);
1583 * apply flow ID/VM pool/VLAN ID bits to lo hash dword, we had to
1584 * delay this because bit 0 of the stream should not be processed
1585 * so we do not add the vlan until after bit 0 was processed
1587 lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16);
1589 /* Process remaining 30 bit of the key */
1590 IXGBE_COMPUTE_SIG_HASH_ITERATION(1);
1591 IXGBE_COMPUTE_SIG_HASH_ITERATION(2);
1592 IXGBE_COMPUTE_SIG_HASH_ITERATION(3);
1593 IXGBE_COMPUTE_SIG_HASH_ITERATION(4);
1594 IXGBE_COMPUTE_SIG_HASH_ITERATION(5);
1595 IXGBE_COMPUTE_SIG_HASH_ITERATION(6);
1596 IXGBE_COMPUTE_SIG_HASH_ITERATION(7);
1597 IXGBE_COMPUTE_SIG_HASH_ITERATION(8);
1598 IXGBE_COMPUTE_SIG_HASH_ITERATION(9);
1599 IXGBE_COMPUTE_SIG_HASH_ITERATION(10);
1600 IXGBE_COMPUTE_SIG_HASH_ITERATION(11);
1601 IXGBE_COMPUTE_SIG_HASH_ITERATION(12);
1602 IXGBE_COMPUTE_SIG_HASH_ITERATION(13);
1603 IXGBE_COMPUTE_SIG_HASH_ITERATION(14);
1604 IXGBE_COMPUTE_SIG_HASH_ITERATION(15);
1606 /* combine common_hash result with signature and bucket hashes */
1607 bucket_hash ^= common_hash;
1608 bucket_hash &= IXGBE_ATR_HASH_MASK;
1610 sig_hash ^= common_hash << 16;
1611 sig_hash &= IXGBE_ATR_HASH_MASK << 16;
1613 /* return completed signature hash */
1614 return sig_hash ^ bucket_hash;
1618 * ixgbe_atr_add_signature_filter_82599 - Adds a signature hash filter
1619 * @hw: pointer to hardware structure
1620 * @input: unique input dword
1621 * @common: compressed common input dword
1622 * @queue: queue index to direct traffic to
1624 s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
1625 union ixgbe_atr_hash_dword input,
1626 union ixgbe_atr_hash_dword common,
1632 DEBUGFUNC("ixgbe_fdir_add_signature_filter_82599");
1635 * Get the flow_type in order to program FDIRCMD properly
1636 * lowest 2 bits are FDIRCMD.L4TYPE, third lowest bit is FDIRCMD.IPV6
1638 switch (input.formatted.flow_type) {
1639 case IXGBE_ATR_FLOW_TYPE_TCPV4:
1640 case IXGBE_ATR_FLOW_TYPE_UDPV4:
1641 case IXGBE_ATR_FLOW_TYPE_SCTPV4:
1642 case IXGBE_ATR_FLOW_TYPE_TCPV6:
1643 case IXGBE_ATR_FLOW_TYPE_UDPV6:
1644 case IXGBE_ATR_FLOW_TYPE_SCTPV6:
1647 DEBUGOUT(" Error on flow type input\n");
1648 return IXGBE_ERR_CONFIG;
1651 /* configure FDIRCMD register */
1652 fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE |
1653 IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
1654 fdircmd |= input.formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
1655 fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
1658 * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits
1659 * is for FDIRCMD. Then do a 64-bit register write from FDIRHASH.
1661 fdirhashcmd = (u64)fdircmd << 32;
1662 fdirhashcmd |= ixgbe_atr_compute_sig_hash_82599(input, common);
1663 IXGBE_WRITE_REG64(hw, IXGBE_FDIRHASH, fdirhashcmd);
1665 DEBUGOUT2("Tx Queue=%x hash=%x\n", queue, (u32)fdirhashcmd);
1667 return IXGBE_SUCCESS;
1670 #define IXGBE_COMPUTE_BKT_HASH_ITERATION(_n) \
1673 if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << n)) \
1674 bucket_hash ^= lo_hash_dword >> n; \
1675 if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << (n + 16))) \
1676 bucket_hash ^= hi_hash_dword >> n; \
1680 * ixgbe_atr_compute_perfect_hash_82599 - Compute the perfect filter hash
1681 * @atr_input: input bitstream to compute the hash on
1682 * @input_mask: mask for the input bitstream
1684 * This function serves two main purposes. First it applys the input_mask
1685 * to the atr_input resulting in a cleaned up atr_input data stream.
1686 * Secondly it computes the hash and stores it in the bkt_hash field at
1687 * the end of the input byte stream. This way it will be available for
1688 * future use without needing to recompute the hash.
1690 void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
1691 union ixgbe_atr_input *input_mask)
1694 u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan;
1695 u32 bucket_hash = 0;
1697 /* Apply masks to input data */
1698 input->dword_stream[0] &= input_mask->dword_stream[0];
1699 input->dword_stream[1] &= input_mask->dword_stream[1];
1700 input->dword_stream[2] &= input_mask->dword_stream[2];
1701 input->dword_stream[3] &= input_mask->dword_stream[3];
1702 input->dword_stream[4] &= input_mask->dword_stream[4];
1703 input->dword_stream[5] &= input_mask->dword_stream[5];
1704 input->dword_stream[6] &= input_mask->dword_stream[6];
1705 input->dword_stream[7] &= input_mask->dword_stream[7];
1706 input->dword_stream[8] &= input_mask->dword_stream[8];
1707 input->dword_stream[9] &= input_mask->dword_stream[9];
1708 input->dword_stream[10] &= input_mask->dword_stream[10];
1710 /* record the flow_vm_vlan bits as they are a key part to the hash */
1711 flow_vm_vlan = IXGBE_NTOHL(input->dword_stream[0]);
1713 /* generate common hash dword */
1714 hi_hash_dword = IXGBE_NTOHL(input->dword_stream[1] ^
1715 input->dword_stream[2] ^
1716 input->dword_stream[3] ^
1717 input->dword_stream[4] ^
1718 input->dword_stream[5] ^
1719 input->dword_stream[6] ^
1720 input->dword_stream[7] ^
1721 input->dword_stream[8] ^
1722 input->dword_stream[9] ^
1723 input->dword_stream[10]);
1725 /* low dword is word swapped version of common */
1726 lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16);
1728 /* apply flow ID/VM pool/VLAN ID bits to hash words */
1729 hi_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan >> 16);
1731 /* Process bits 0 and 16 */
1732 IXGBE_COMPUTE_BKT_HASH_ITERATION(0);
1735 * apply flow ID/VM pool/VLAN ID bits to lo hash dword, we had to
1736 * delay this because bit 0 of the stream should not be processed
1737 * so we do not add the vlan until after bit 0 was processed
1739 lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16);
1741 /* Process remaining 30 bit of the key */
1742 IXGBE_COMPUTE_BKT_HASH_ITERATION(1);
1743 IXGBE_COMPUTE_BKT_HASH_ITERATION(2);
1744 IXGBE_COMPUTE_BKT_HASH_ITERATION(3);
1745 IXGBE_COMPUTE_BKT_HASH_ITERATION(4);
1746 IXGBE_COMPUTE_BKT_HASH_ITERATION(5);
1747 IXGBE_COMPUTE_BKT_HASH_ITERATION(6);
1748 IXGBE_COMPUTE_BKT_HASH_ITERATION(7);
1749 IXGBE_COMPUTE_BKT_HASH_ITERATION(8);
1750 IXGBE_COMPUTE_BKT_HASH_ITERATION(9);
1751 IXGBE_COMPUTE_BKT_HASH_ITERATION(10);
1752 IXGBE_COMPUTE_BKT_HASH_ITERATION(11);
1753 IXGBE_COMPUTE_BKT_HASH_ITERATION(12);
1754 IXGBE_COMPUTE_BKT_HASH_ITERATION(13);
1755 IXGBE_COMPUTE_BKT_HASH_ITERATION(14);
1756 IXGBE_COMPUTE_BKT_HASH_ITERATION(15);
1759 * Limit hash to 13 bits since max bucket count is 8K.
1760 * Store result at the end of the input stream.
1762 input->formatted.bkt_hash = bucket_hash & 0x1FFF;
1766 * ixgbe_get_fdirtcpm_82599 - generate a tcp port from atr_input_masks
1767 * @input_mask: mask to be bit swapped
1769 * The source and destination port masks for flow director are bit swapped
1770 * in that bit 15 effects bit 0, 14 effects 1, 13, 2 etc. In order to
1771 * generate a correctly swapped value we need to bit swap the mask and that
1772 * is what is accomplished by this function.
1774 static u32 ixgbe_get_fdirtcpm_82599(union ixgbe_atr_input *input_mask)
1776 u32 mask = IXGBE_NTOHS(input_mask->formatted.dst_port);
1777 mask <<= IXGBE_FDIRTCPM_DPORTM_SHIFT;
1778 mask |= IXGBE_NTOHS(input_mask->formatted.src_port);
1779 mask = ((mask & 0x55555555) << 1) | ((mask & 0xAAAAAAAA) >> 1);
1780 mask = ((mask & 0x33333333) << 2) | ((mask & 0xCCCCCCCC) >> 2);
1781 mask = ((mask & 0x0F0F0F0F) << 4) | ((mask & 0xF0F0F0F0) >> 4);
1782 return ((mask & 0x00FF00FF) << 8) | ((mask & 0xFF00FF00) >> 8);
1786 * These two macros are meant to address the fact that we have registers
1787 * that are either all or in part big-endian. As a result on big-endian
1788 * systems we will end up byte swapping the value to little-endian before
1789 * it is byte swapped again and written to the hardware in the original
1790 * big-endian format.
1792 #define IXGBE_STORE_AS_BE32(_value) \
1793 (((u32)(_value) >> 24) | (((u32)(_value) & 0x00FF0000) >> 8) | \
1794 (((u32)(_value) & 0x0000FF00) << 8) | ((u32)(_value) << 24))
1796 #define IXGBE_WRITE_REG_BE32(a, reg, value) \
1797 IXGBE_WRITE_REG((a), (reg), IXGBE_STORE_AS_BE32(IXGBE_NTOHL(value)))
1799 #define IXGBE_STORE_AS_BE16(_value) \
1800 IXGBE_NTOHS(((u16)(_value) >> 8) | ((u16)(_value) << 8))
1802 s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
1803 union ixgbe_atr_input *input_mask)
1805 /* mask IPv6 since it is currently not supported */
1806 u32 fdirm = IXGBE_FDIRM_DIPv6;
1809 DEBUGFUNC("ixgbe_fdir_set_atr_input_mask_82599");
1812 * Program the relevant mask registers. If src/dst_port or src/dst_addr
1813 * are zero, then assume a full mask for that field. Also assume that
1814 * a VLAN of 0 is unspecified, so mask that out as well. L4type
1815 * cannot be masked out in this implementation.
1817 * This also assumes IPv4 only. IPv6 masking isn't supported at this
1821 /* verify bucket hash is cleared on hash generation */
1822 if (input_mask->formatted.bkt_hash)
1823 DEBUGOUT(" bucket hash should always be 0 in mask\n");
1825 /* Program FDIRM and verify partial masks */
1826 switch (input_mask->formatted.vm_pool & 0x7F) {
1828 fdirm |= IXGBE_FDIRM_POOL;
1832 DEBUGOUT(" Error on vm pool mask\n");
1833 return IXGBE_ERR_CONFIG;
1836 switch (input_mask->formatted.flow_type & IXGBE_ATR_L4TYPE_MASK) {
1838 fdirm |= IXGBE_FDIRM_L4P;
1839 if (input_mask->formatted.dst_port ||
1840 input_mask->formatted.src_port) {
1841 DEBUGOUT(" Error on src/dst port mask\n");
1842 return IXGBE_ERR_CONFIG;
1844 case IXGBE_ATR_L4TYPE_MASK:
1847 DEBUGOUT(" Error on flow type mask\n");
1848 return IXGBE_ERR_CONFIG;
1851 switch (IXGBE_NTOHS(input_mask->formatted.vlan_id) & 0xEFFF) {
1853 /* mask VLAN ID, fall through to mask VLAN priority */
1854 fdirm |= IXGBE_FDIRM_VLANID;
1856 /* mask VLAN priority */
1857 fdirm |= IXGBE_FDIRM_VLANP;
1860 /* mask VLAN ID only, fall through */
1861 fdirm |= IXGBE_FDIRM_VLANID;
1863 /* no VLAN fields masked */
1866 DEBUGOUT(" Error on VLAN mask\n");
1867 return IXGBE_ERR_CONFIG;
1870 switch (input_mask->formatted.flex_bytes & 0xFFFF) {
1872 /* Mask Flex Bytes, fall through */
1873 fdirm |= IXGBE_FDIRM_FLEX;
1877 DEBUGOUT(" Error on flexible byte mask\n");
1878 return IXGBE_ERR_CONFIG;
1881 /* Now mask VM pool and destination IPv6 - bits 5 and 2 */
1882 IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
1884 /* store the TCP/UDP port masks, bit reversed from port layout */
1885 fdirtcpm = ixgbe_get_fdirtcpm_82599(input_mask);
1887 /* write both the same so that UDP and TCP use the same mask */
1888 IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, ~fdirtcpm);
1889 IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, ~fdirtcpm);
1891 /* store source and destination IP masks (big-enian) */
1892 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIP4M,
1893 ~input_mask->formatted.src_ip[0]);
1894 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRDIP4M,
1895 ~input_mask->formatted.dst_ip[0]);
1897 return IXGBE_SUCCESS;
1900 s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
1901 union ixgbe_atr_input *input,
1902 u16 soft_id, u8 queue)
1904 u32 fdirport, fdirvlan, fdirhash, fdircmd;
1906 DEBUGFUNC("ixgbe_fdir_write_perfect_filter_82599");
1908 /* currently IPv6 is not supported, must be programmed with 0 */
1909 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(0),
1910 input->formatted.src_ip[0]);
1911 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(1),
1912 input->formatted.src_ip[1]);
1913 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(2),
1914 input->formatted.src_ip[2]);
1916 /* record the source address (big-endian) */
1917 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPSA, input->formatted.src_ip[0]);
1919 /* record the first 32 bits of the destination address (big-endian) */
1920 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPDA, input->formatted.dst_ip[0]);
1922 /* record source and destination port (little-endian)*/
1923 fdirport = IXGBE_NTOHS(input->formatted.dst_port);
1924 fdirport <<= IXGBE_FDIRPORT_DESTINATION_SHIFT;
1925 fdirport |= IXGBE_NTOHS(input->formatted.src_port);
1926 IXGBE_WRITE_REG(hw, IXGBE_FDIRPORT, fdirport);
1928 /* record vlan (little-endian) and flex_bytes(big-endian) */
1929 fdirvlan = IXGBE_STORE_AS_BE16(input->formatted.flex_bytes);
1930 fdirvlan <<= IXGBE_FDIRVLAN_FLEX_SHIFT;
1931 fdirvlan |= IXGBE_NTOHS(input->formatted.vlan_id);
1932 IXGBE_WRITE_REG(hw, IXGBE_FDIRVLAN, fdirvlan);
1934 /* configure FDIRHASH register */
1935 fdirhash = input->formatted.bkt_hash;
1936 fdirhash |= soft_id << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT;
1937 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
1940 * flush all previous writes to make certain registers are
1941 * programmed prior to issuing the command
1943 IXGBE_WRITE_FLUSH(hw);
1945 /* configure FDIRCMD register */
1946 fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE |
1947 IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
1948 if (queue == IXGBE_FDIR_DROP_QUEUE)
1949 fdircmd |= IXGBE_FDIRCMD_DROP;
1950 fdircmd |= input->formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
1951 fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
1952 fdircmd |= (u32)input->formatted.vm_pool << IXGBE_FDIRCMD_VT_POOL_SHIFT;
1954 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd);
1956 return IXGBE_SUCCESS;
1959 s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
1960 union ixgbe_atr_input *input,
1966 s32 err = IXGBE_SUCCESS;
1968 /* configure FDIRHASH register */
1969 fdirhash = input->formatted.bkt_hash;
1970 fdirhash |= soft_id << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT;
1971 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
1973 /* flush hash to HW */
1974 IXGBE_WRITE_FLUSH(hw);
1976 /* Query if filter is present */
1977 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, IXGBE_FDIRCMD_CMD_QUERY_REM_FILT);
1979 for (retry_count = 10; retry_count; retry_count--) {
1980 /* allow 10us for query to process */
1982 /* verify query completed successfully */
1983 fdircmd = IXGBE_READ_REG(hw, IXGBE_FDIRCMD);
1984 if (!(fdircmd & IXGBE_FDIRCMD_CMD_MASK))
1989 err = IXGBE_ERR_FDIR_REINIT_FAILED;
1991 /* if filter exists in hardware then remove it */
1992 if (fdircmd & IXGBE_FDIRCMD_FILTER_VALID) {
1993 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
1994 IXGBE_WRITE_FLUSH(hw);
1995 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
1996 IXGBE_FDIRCMD_CMD_REMOVE_FLOW);
2003 * ixgbe_fdir_add_perfect_filter_82599 - Adds a perfect filter
2004 * @hw: pointer to hardware structure
2005 * @input: input bitstream
2006 * @input_mask: mask for the input bitstream
2007 * @soft_id: software index for the filters
2008 * @queue: queue index to direct traffic to
2010 * Note that the caller to this function must lock before calling, since the
2011 * hardware writes must be protected from one another.
2013 s32 ixgbe_fdir_add_perfect_filter_82599(struct ixgbe_hw *hw,
2014 union ixgbe_atr_input *input,
2015 union ixgbe_atr_input *input_mask,
2016 u16 soft_id, u8 queue)
2018 s32 err = IXGBE_ERR_CONFIG;
2020 DEBUGFUNC("ixgbe_fdir_add_perfect_filter_82599");
2023 * Check flow_type formatting, and bail out before we touch the hardware
2024 * if there's a configuration issue
2026 switch (input->formatted.flow_type) {
2027 case IXGBE_ATR_FLOW_TYPE_IPV4:
2028 input_mask->formatted.flow_type = IXGBE_ATR_L4TYPE_IPV6_MASK;
2029 if (input->formatted.dst_port || input->formatted.src_port) {
2030 DEBUGOUT(" Error on src/dst port\n");
2031 return IXGBE_ERR_CONFIG;
2034 case IXGBE_ATR_FLOW_TYPE_SCTPV4:
2035 if (input->formatted.dst_port || input->formatted.src_port) {
2036 DEBUGOUT(" Error on src/dst port\n");
2037 return IXGBE_ERR_CONFIG;
2039 case IXGBE_ATR_FLOW_TYPE_TCPV4:
2040 case IXGBE_ATR_FLOW_TYPE_UDPV4:
2041 input_mask->formatted.flow_type = IXGBE_ATR_L4TYPE_IPV6_MASK |
2042 IXGBE_ATR_L4TYPE_MASK;
2045 DEBUGOUT(" Error on flow type input\n");
2049 /* program input mask into the HW */
2050 err = ixgbe_fdir_set_input_mask_82599(hw, input_mask);
2054 /* apply mask and compute/store hash */
2055 ixgbe_atr_compute_perfect_hash_82599(input, input_mask);
2057 /* program filters to filter memory */
2058 return ixgbe_fdir_write_perfect_filter_82599(hw, input,
2063 * ixgbe_read_analog_reg8_82599 - Reads 8 bit Omer analog register
2064 * @hw: pointer to hardware structure
2065 * @reg: analog register to read
2068 * Performs read operation to Omer analog register specified.
2070 s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val)
2074 DEBUGFUNC("ixgbe_read_analog_reg8_82599");
2076 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, IXGBE_CORECTL_WRITE_CMD |
2078 IXGBE_WRITE_FLUSH(hw);
2080 core_ctl = IXGBE_READ_REG(hw, IXGBE_CORECTL);
2081 *val = (u8)core_ctl;
2083 return IXGBE_SUCCESS;
2087 * ixgbe_write_analog_reg8_82599 - Writes 8 bit Omer analog register
2088 * @hw: pointer to hardware structure
2089 * @reg: atlas register to write
2090 * @val: value to write
2092 * Performs write operation to Omer analog register specified.
2094 s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val)
2098 DEBUGFUNC("ixgbe_write_analog_reg8_82599");
2100 core_ctl = (reg << 8) | val;
2101 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, core_ctl);
2102 IXGBE_WRITE_FLUSH(hw);
2105 return IXGBE_SUCCESS;
2109 * ixgbe_start_hw_82599 - Prepare hardware for Tx/Rx
2110 * @hw: pointer to hardware structure
2112 * Starts the hardware using the generic start_hw function
2113 * and the generation start_hw function.
2114 * Then performs revision-specific operations, if any.
2116 s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
2118 s32 ret_val = IXGBE_SUCCESS;
2120 DEBUGFUNC("ixgbe_start_hw_82599");
2122 ret_val = ixgbe_start_hw_generic(hw);
2123 if (ret_val != IXGBE_SUCCESS)
2126 ret_val = ixgbe_start_hw_gen2(hw);
2127 if (ret_val != IXGBE_SUCCESS)
2130 /* We need to run link autotry after the driver loads */
2131 hw->mac.autotry_restart = TRUE;
2133 if (ret_val == IXGBE_SUCCESS)
2134 ret_val = ixgbe_verify_fw_version_82599(hw);
2140 * ixgbe_identify_phy_82599 - Get physical layer module
2141 * @hw: pointer to hardware structure
2143 * Determines the physical layer module found on the current adapter.
2144 * If PHY already detected, maintains current PHY type in hw struct,
2145 * otherwise executes the PHY detection routine.
2147 s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
2149 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
2151 DEBUGFUNC("ixgbe_identify_phy_82599");
2153 /* Detect PHY if not unknown - returns success if already detected. */
2154 status = ixgbe_identify_phy_generic(hw);
2155 if (status != IXGBE_SUCCESS) {
2156 /* 82599 10GBASE-T requires an external PHY */
2157 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)
2160 status = ixgbe_identify_module_generic(hw);
2163 /* Set PHY type none if no PHY detected */
2164 if (hw->phy.type == ixgbe_phy_unknown) {
2165 hw->phy.type = ixgbe_phy_none;
2166 status = IXGBE_SUCCESS;
2169 /* Return error if SFP module has been detected but is not supported */
2170 if (hw->phy.type == ixgbe_phy_sfp_unsupported)
2171 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
2178 * ixgbe_get_supported_physical_layer_82599 - Returns physical layer type
2179 * @hw: pointer to hardware structure
2181 * Determines physical layer capabilities of the current configuration.
2183 u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw)
2185 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
2186 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2187 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
2188 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
2189 u32 pma_pmd_10g_parallel = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
2190 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
2191 u16 ext_ability = 0;
2192 u8 comp_codes_10g = 0;
2193 u8 comp_codes_1g = 0;
2195 DEBUGFUNC("ixgbe_get_support_physical_layer_82599");
2197 hw->phy.ops.identify(hw);
2199 switch (hw->phy.type) {
2201 case ixgbe_phy_cu_unknown:
2202 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
2203 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
2204 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
2205 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
2206 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
2207 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
2208 if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY)
2209 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
2215 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
2216 case IXGBE_AUTOC_LMS_1G_AN:
2217 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
2218 if (pma_pmd_1g == IXGBE_AUTOC_1G_KX_BX) {
2219 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
2220 IXGBE_PHYSICAL_LAYER_1000BASE_BX;
2223 /* SFI mode so read SFP module */
2226 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
2227 if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_CX4)
2228 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
2229 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_KX4)
2230 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
2231 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_XAUI)
2232 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_XAUI;
2235 case IXGBE_AUTOC_LMS_10G_SERIAL:
2236 if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_KR) {
2237 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR;
2239 } else if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)
2242 case IXGBE_AUTOC_LMS_KX4_KX_KR:
2243 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
2244 if (autoc & IXGBE_AUTOC_KX_SUPP)
2245 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2246 if (autoc & IXGBE_AUTOC_KX4_SUPP)
2247 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
2248 if (autoc & IXGBE_AUTOC_KR_SUPP)
2249 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KR;
2258 /* SFP check must be done last since DA modules are sometimes used to
2259 * test KR mode - we need to id KR mode correctly before SFP module.
2260 * Call identify_sfp because the pluggable module may have changed */
2261 hw->phy.ops.identify_sfp(hw);
2262 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
2265 switch (hw->phy.type) {
2266 case ixgbe_phy_sfp_passive_tyco:
2267 case ixgbe_phy_sfp_passive_unknown:
2268 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
2270 case ixgbe_phy_sfp_ftl_active:
2271 case ixgbe_phy_sfp_active_unknown:
2272 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
2274 case ixgbe_phy_sfp_avago:
2275 case ixgbe_phy_sfp_ftl:
2276 case ixgbe_phy_sfp_intel:
2277 case ixgbe_phy_sfp_unknown:
2278 hw->phy.ops.read_i2c_eeprom(hw,
2279 IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
2280 hw->phy.ops.read_i2c_eeprom(hw,
2281 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
2282 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
2283 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
2284 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
2285 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
2286 else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
2287 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
2288 else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE)
2289 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_SX;
2296 return physical_layer;
2300 * ixgbe_enable_rx_dma_82599 - Enable the Rx DMA unit on 82599
2301 * @hw: pointer to hardware structure
2302 * @regval: register value to write to RXCTRL
2304 * Enables the Rx DMA unit for 82599
2306 s32 ixgbe_enable_rx_dma_82599(struct ixgbe_hw *hw, u32 regval)
2309 DEBUGFUNC("ixgbe_enable_rx_dma_82599");
2312 * Workaround for 82599 silicon errata when enabling the Rx datapath.
2313 * If traffic is incoming before we enable the Rx unit, it could hang
2314 * the Rx DMA unit. Therefore, make sure the security engine is
2315 * completely disabled prior to enabling the Rx unit.
2318 hw->mac.ops.disable_sec_rx_path(hw);
2320 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval);
2322 hw->mac.ops.enable_sec_rx_path(hw);
2324 return IXGBE_SUCCESS;
2328 * ixgbe_verify_fw_version_82599 - verify fw version for 82599
2329 * @hw: pointer to hardware structure
2331 * Verifies that installed the firmware version is 0.6 or higher
2332 * for SFI devices. All 82599 SFI devices should have version 0.6 or higher.
2334 * Returns IXGBE_ERR_EEPROM_VERSION if the FW is not present or
2335 * if the FW version is not supported.
2337 static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
2339 s32 status = IXGBE_ERR_EEPROM_VERSION;
2340 u16 fw_offset, fw_ptp_cfg_offset;
2343 DEBUGFUNC("ixgbe_verify_fw_version_82599");
2345 /* firmware check is only necessary for SFI devices */
2346 if (hw->phy.media_type != ixgbe_media_type_fiber) {
2347 status = IXGBE_SUCCESS;
2348 goto fw_version_out;
2351 /* get the offset to the Firmware Module block */
2352 if (hw->eeprom.ops.read(hw, IXGBE_FW_PTR, &fw_offset)) {
2353 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2354 "eeprom read at offset %d failed", IXGBE_FW_PTR);
2355 return IXGBE_ERR_EEPROM_VERSION;
2358 if ((fw_offset == 0) || (fw_offset == 0xFFFF))
2359 goto fw_version_out;
2361 /* get the offset to the Pass Through Patch Configuration block */
2362 if (hw->eeprom.ops.read(hw, (fw_offset +
2363 IXGBE_FW_PASSTHROUGH_PATCH_CONFIG_PTR),
2364 &fw_ptp_cfg_offset)) {
2365 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2366 "eeprom read at offset %d failed",
2368 IXGBE_FW_PASSTHROUGH_PATCH_CONFIG_PTR);
2369 return IXGBE_ERR_EEPROM_VERSION;
2372 if ((fw_ptp_cfg_offset == 0) || (fw_ptp_cfg_offset == 0xFFFF))
2373 goto fw_version_out;
2375 /* get the firmware version */
2376 if (hw->eeprom.ops.read(hw, (fw_ptp_cfg_offset +
2377 IXGBE_FW_PATCH_VERSION_4), &fw_version)) {
2378 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2379 "eeprom read at offset %d failed",
2380 fw_ptp_cfg_offset + IXGBE_FW_PATCH_VERSION_4);
2381 return IXGBE_ERR_EEPROM_VERSION;
2384 if (fw_version > 0x5)
2385 status = IXGBE_SUCCESS;
2392 * ixgbe_verify_lesm_fw_enabled_82599 - Checks LESM FW module state.
2393 * @hw: pointer to hardware structure
2395 * Returns TRUE if the LESM FW module is present and enabled. Otherwise
2396 * returns FALSE. Smart Speed must be disabled if LESM FW module is enabled.
2398 bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw)
2400 bool lesm_enabled = FALSE;
2401 u16 fw_offset, fw_lesm_param_offset, fw_lesm_state;
2404 DEBUGFUNC("ixgbe_verify_lesm_fw_enabled_82599");
2406 /* get the offset to the Firmware Module block */
2407 status = hw->eeprom.ops.read(hw, IXGBE_FW_PTR, &fw_offset);
2409 if ((status != IXGBE_SUCCESS) ||
2410 (fw_offset == 0) || (fw_offset == 0xFFFF))
2413 /* get the offset to the LESM Parameters block */
2414 status = hw->eeprom.ops.read(hw, (fw_offset +
2415 IXGBE_FW_LESM_PARAMETERS_PTR),
2416 &fw_lesm_param_offset);
2418 if ((status != IXGBE_SUCCESS) ||
2419 (fw_lesm_param_offset == 0) || (fw_lesm_param_offset == 0xFFFF))
2422 /* get the lesm state word */
2423 status = hw->eeprom.ops.read(hw, (fw_lesm_param_offset +
2424 IXGBE_FW_LESM_STATE_1),
2427 if ((status == IXGBE_SUCCESS) &&
2428 (fw_lesm_state & IXGBE_FW_LESM_STATE_ENABLED))
2429 lesm_enabled = TRUE;
2432 return lesm_enabled;
2436 * ixgbe_read_eeprom_buffer_82599 - Read EEPROM word(s) using
2437 * fastest available method
2439 * @hw: pointer to hardware structure
2440 * @offset: offset of word in EEPROM to read
2441 * @words: number of words
2442 * @data: word(s) read from the EEPROM
2444 * Retrieves 16 bit word(s) read from EEPROM
2446 static s32 ixgbe_read_eeprom_buffer_82599(struct ixgbe_hw *hw, u16 offset,
2447 u16 words, u16 *data)
2449 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
2450 s32 ret_val = IXGBE_ERR_CONFIG;
2452 DEBUGFUNC("ixgbe_read_eeprom_buffer_82599");
2455 * If EEPROM is detected and can be addressed using 14 bits,
2456 * use EERD otherwise use bit bang
2458 if ((eeprom->type == ixgbe_eeprom_spi) &&
2459 (offset + (words - 1) <= IXGBE_EERD_MAX_ADDR))
2460 ret_val = ixgbe_read_eerd_buffer_generic(hw, offset, words,
2463 ret_val = ixgbe_read_eeprom_buffer_bit_bang_generic(hw, offset,
2471 * ixgbe_read_eeprom_82599 - Read EEPROM word using
2472 * fastest available method
2474 * @hw: pointer to hardware structure
2475 * @offset: offset of word in the EEPROM to read
2476 * @data: word read from the EEPROM
2478 * Reads a 16 bit word from the EEPROM
2480 static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
2481 u16 offset, u16 *data)
2483 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
2484 s32 ret_val = IXGBE_ERR_CONFIG;
2486 DEBUGFUNC("ixgbe_read_eeprom_82599");
2489 * If EEPROM is detected and can be addressed using 14 bits,
2490 * use EERD otherwise use bit bang
2492 if ((eeprom->type == ixgbe_eeprom_spi) &&
2493 (offset <= IXGBE_EERD_MAX_ADDR))
2494 ret_val = ixgbe_read_eerd_generic(hw, offset, data);
2496 ret_val = ixgbe_read_eeprom_bit_bang_generic(hw, offset, data);
2502 * ixgbe_reset_pipeline_82599 - perform pipeline reset
2504 * @hw: pointer to hardware structure
2506 * Reset pipeline by asserting Restart_AN together with LMS change to ensure
2507 * full pipeline reset
2509 s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)
2513 u32 i, autoc_reg, autoc2_reg;
2515 /* Enable link if disabled in NVM */
2516 autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
2517 if (autoc2_reg & IXGBE_AUTOC2_LINK_DISABLE_MASK) {
2518 autoc2_reg &= ~IXGBE_AUTOC2_LINK_DISABLE_MASK;
2519 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg);
2520 IXGBE_WRITE_FLUSH(hw);
2523 autoc_reg = hw->mac.cached_autoc;
2524 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
2525 /* Write AUTOC register with toggled LMS[2] bit and Restart_AN */
2526 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg ^ IXGBE_AUTOC_LMS_1G_AN);
2527 /* Wait for AN to leave state 0 */
2528 for (i = 0; i < 10; i++) {
2530 anlp1_reg = IXGBE_READ_REG(hw, IXGBE_ANLP1);
2531 if (anlp1_reg & IXGBE_ANLP1_AN_STATE_MASK)
2535 if (!(anlp1_reg & IXGBE_ANLP1_AN_STATE_MASK)) {
2536 DEBUGOUT("auto negotiation not completed\n");
2537 ret_val = IXGBE_ERR_RESET_FAILED;
2538 goto reset_pipeline_out;
2541 ret_val = IXGBE_SUCCESS;
2544 /* Write AUTOC register with original LMS field and Restart_AN */
2545 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
2546 IXGBE_WRITE_FLUSH(hw);