Home | History | Annotate | Line # | Download | only in ixgbe
ixgbe_x540.c revision 1.16.8.3
      1  1.16.8.3   martin /* $NetBSD: ixgbe_x540.c,v 1.16.8.3 2022/01/30 15:58:29 martin Exp $ */
      2  1.16.8.2   martin 
      3       1.1  msaitoh /******************************************************************************
      4      1.12  msaitoh   SPDX-License-Identifier: BSD-3-Clause
      5       1.1  msaitoh 
      6  1.16.8.3   martin   Copyright (c) 2001-2020, Intel Corporation
      7       1.1  msaitoh   All rights reserved.
      8      1.10  msaitoh 
      9      1.10  msaitoh   Redistribution and use in source and binary forms, with or without
     10       1.1  msaitoh   modification, are permitted provided that the following conditions are met:
     11      1.10  msaitoh 
     12      1.10  msaitoh    1. Redistributions of source code must retain the above copyright notice,
     13       1.1  msaitoh       this list of conditions and the following disclaimer.
     14      1.10  msaitoh 
     15      1.10  msaitoh    2. Redistributions in binary form must reproduce the above copyright
     16      1.10  msaitoh       notice, this list of conditions and the following disclaimer in the
     17       1.1  msaitoh       documentation and/or other materials provided with the distribution.
     18      1.10  msaitoh 
     19      1.10  msaitoh    3. Neither the name of the Intel Corporation nor the names of its
     20      1.10  msaitoh       contributors may be used to endorse or promote products derived from
     21       1.1  msaitoh       this software without specific prior written permission.
     22      1.10  msaitoh 
     23       1.1  msaitoh   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     24      1.10  msaitoh   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25      1.10  msaitoh   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26      1.10  msaitoh   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     27      1.10  msaitoh   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28      1.10  msaitoh   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29      1.10  msaitoh   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30      1.10  msaitoh   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31      1.10  msaitoh   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32       1.1  msaitoh   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33       1.1  msaitoh   POSSIBILITY OF SUCH DAMAGE.
     34       1.1  msaitoh 
     35       1.1  msaitoh ******************************************************************************/
     36      1.15  msaitoh /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x540.c 331224 2018-03-19 20:55:05Z erj $*/
     37       1.1  msaitoh 
     38  1.16.8.2   martin #include <sys/cdefs.h>
     39  1.16.8.3   martin __KERNEL_RCSID(0, "$NetBSD: ixgbe_x540.c,v 1.16.8.3 2022/01/30 15:58:29 martin Exp $");
     40  1.16.8.2   martin 
     41       1.1  msaitoh #include "ixgbe_x540.h"
     42       1.1  msaitoh #include "ixgbe_type.h"
     43       1.1  msaitoh #include "ixgbe_api.h"
     44       1.1  msaitoh #include "ixgbe_common.h"
     45       1.1  msaitoh #include "ixgbe_phy.h"
     46       1.1  msaitoh 
     47       1.5  msaitoh #define IXGBE_X540_MAX_TX_QUEUES	128
     48       1.5  msaitoh #define IXGBE_X540_MAX_RX_QUEUES	128
     49       1.5  msaitoh #define IXGBE_X540_RAR_ENTRIES		128
     50       1.5  msaitoh #define IXGBE_X540_MC_TBL_SIZE		128
     51       1.5  msaitoh #define IXGBE_X540_VFT_TBL_SIZE		128
     52       1.5  msaitoh #define IXGBE_X540_RX_PB_SIZE		384
     53       1.5  msaitoh 
     54       1.1  msaitoh static s32 ixgbe_poll_flash_update_done_X540(struct ixgbe_hw *hw);
     55       1.1  msaitoh static s32 ixgbe_get_swfw_sync_semaphore(struct ixgbe_hw *hw);
     56       1.1  msaitoh static void ixgbe_release_swfw_sync_semaphore(struct ixgbe_hw *hw);
     57       1.1  msaitoh 
     58       1.1  msaitoh /**
     59  1.16.8.3   martin  * ixgbe_init_ops_X540 - Inits func ptrs and MAC type
     60  1.16.8.3   martin  * @hw: pointer to hardware structure
     61       1.1  msaitoh  *
     62  1.16.8.3   martin  * Initialize the function pointers and assign the MAC type for X540.
     63  1.16.8.3   martin  * Does not touch the hardware.
     64       1.1  msaitoh  **/
     65       1.1  msaitoh s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw)
     66       1.1  msaitoh {
     67       1.1  msaitoh 	struct ixgbe_mac_info *mac = &hw->mac;
     68       1.1  msaitoh 	struct ixgbe_phy_info *phy = &hw->phy;
     69       1.1  msaitoh 	struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
     70       1.1  msaitoh 	s32 ret_val;
     71       1.1  msaitoh 
     72       1.1  msaitoh 	DEBUGFUNC("ixgbe_init_ops_X540");
     73       1.1  msaitoh 
     74       1.1  msaitoh 	ret_val = ixgbe_init_phy_ops_generic(hw);
     75       1.1  msaitoh 	ret_val = ixgbe_init_ops_generic(hw);
     76       1.1  msaitoh 
     77       1.1  msaitoh 
     78       1.1  msaitoh 	/* EEPROM */
     79       1.5  msaitoh 	eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
     80       1.5  msaitoh 	eeprom->ops.read = ixgbe_read_eerd_X540;
     81       1.5  msaitoh 	eeprom->ops.read_buffer = ixgbe_read_eerd_buffer_X540;
     82       1.5  msaitoh 	eeprom->ops.write = ixgbe_write_eewr_X540;
     83       1.5  msaitoh 	eeprom->ops.write_buffer = ixgbe_write_eewr_buffer_X540;
     84       1.5  msaitoh 	eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X540;
     85       1.5  msaitoh 	eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X540;
     86       1.5  msaitoh 	eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X540;
     87       1.1  msaitoh 
     88       1.1  msaitoh 	/* PHY */
     89       1.5  msaitoh 	phy->ops.init = ixgbe_init_phy_ops_generic;
     90       1.1  msaitoh 	phy->ops.reset = NULL;
     91       1.9  msaitoh 	phy->ops.set_phy_power = ixgbe_set_copper_phy_power;
     92       1.1  msaitoh 
     93       1.1  msaitoh 	/* MAC */
     94       1.5  msaitoh 	mac->ops.reset_hw = ixgbe_reset_hw_X540;
     95       1.5  msaitoh 	mac->ops.enable_relaxed_ordering = ixgbe_enable_relaxed_ordering_gen2;
     96       1.5  msaitoh 	mac->ops.get_media_type = ixgbe_get_media_type_X540;
     97       1.1  msaitoh 	mac->ops.get_supported_physical_layer =
     98       1.5  msaitoh 				    ixgbe_get_supported_physical_layer_X540;
     99       1.1  msaitoh 	mac->ops.read_analog_reg8 = NULL;
    100       1.1  msaitoh 	mac->ops.write_analog_reg8 = NULL;
    101       1.5  msaitoh 	mac->ops.start_hw = ixgbe_start_hw_X540;
    102       1.5  msaitoh 	mac->ops.get_san_mac_addr = ixgbe_get_san_mac_addr_generic;
    103       1.5  msaitoh 	mac->ops.set_san_mac_addr = ixgbe_set_san_mac_addr_generic;
    104       1.5  msaitoh 	mac->ops.get_device_caps = ixgbe_get_device_caps_generic;
    105       1.5  msaitoh 	mac->ops.get_wwn_prefix = ixgbe_get_wwn_prefix_generic;
    106       1.5  msaitoh 	mac->ops.get_fcoe_boot_status = ixgbe_get_fcoe_boot_status_generic;
    107       1.5  msaitoh 	mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X540;
    108       1.5  msaitoh 	mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X540;
    109      1.10  msaitoh 	mac->ops.init_swfw_sync = ixgbe_init_swfw_sync_X540;
    110       1.5  msaitoh 	mac->ops.disable_sec_rx_path = ixgbe_disable_sec_rx_path_generic;
    111       1.5  msaitoh 	mac->ops.enable_sec_rx_path = ixgbe_enable_sec_rx_path_generic;
    112       1.1  msaitoh 
    113       1.1  msaitoh 	/* RAR, Multicast, VLAN */
    114       1.5  msaitoh 	mac->ops.set_vmdq = ixgbe_set_vmdq_generic;
    115       1.5  msaitoh 	mac->ops.set_vmdq_san_mac = ixgbe_set_vmdq_san_mac_generic;
    116       1.5  msaitoh 	mac->ops.clear_vmdq = ixgbe_clear_vmdq_generic;
    117       1.5  msaitoh 	mac->ops.insert_mac_addr = ixgbe_insert_mac_addr_generic;
    118       1.1  msaitoh 	mac->rar_highwater = 1;
    119       1.5  msaitoh 	mac->ops.set_vfta = ixgbe_set_vfta_generic;
    120       1.5  msaitoh 	mac->ops.set_vlvf = ixgbe_set_vlvf_generic;
    121       1.5  msaitoh 	mac->ops.clear_vfta = ixgbe_clear_vfta_generic;
    122       1.5  msaitoh 	mac->ops.init_uta_tables = ixgbe_init_uta_tables_generic;
    123       1.5  msaitoh 	mac->ops.set_mac_anti_spoofing = ixgbe_set_mac_anti_spoofing;
    124       1.5  msaitoh 	mac->ops.set_vlan_anti_spoofing = ixgbe_set_vlan_anti_spoofing;
    125       1.1  msaitoh 
    126       1.1  msaitoh 	/* Link */
    127       1.1  msaitoh 	mac->ops.get_link_capabilities =
    128       1.5  msaitoh 				ixgbe_get_copper_link_capabilities_generic;
    129       1.5  msaitoh 	mac->ops.setup_link = ixgbe_setup_mac_link_X540;
    130       1.5  msaitoh 	mac->ops.setup_rxpba = ixgbe_set_rxpba_generic;
    131       1.5  msaitoh 	mac->ops.check_link = ixgbe_check_mac_link_generic;
    132      1.10  msaitoh 	mac->ops.bypass_rw = ixgbe_bypass_rw_generic;
    133      1.10  msaitoh 	mac->ops.bypass_valid_rd = ixgbe_bypass_valid_rd_generic;
    134      1.10  msaitoh 	mac->ops.bypass_set = ixgbe_bypass_set_generic;
    135      1.10  msaitoh 	mac->ops.bypass_rd_eep = ixgbe_bypass_rd_eep_generic;
    136       1.1  msaitoh 
    137       1.3  msaitoh 
    138       1.5  msaitoh 	mac->mcft_size		= IXGBE_X540_MC_TBL_SIZE;
    139       1.5  msaitoh 	mac->vft_size		= IXGBE_X540_VFT_TBL_SIZE;
    140       1.5  msaitoh 	mac->num_rar_entries	= IXGBE_X540_RAR_ENTRIES;
    141       1.5  msaitoh 	mac->rx_pb_size		= IXGBE_X540_RX_PB_SIZE;
    142       1.5  msaitoh 	mac->max_rx_queues	= IXGBE_X540_MAX_RX_QUEUES;
    143       1.5  msaitoh 	mac->max_tx_queues	= IXGBE_X540_MAX_TX_QUEUES;
    144       1.1  msaitoh 	mac->max_msix_vectors	= ixgbe_get_pcie_msix_count_generic(hw);
    145       1.1  msaitoh 
    146       1.1  msaitoh 	/*
    147       1.1  msaitoh 	 * FWSM register
    148       1.1  msaitoh 	 * ARC supported; valid only if manageability features are
    149       1.1  msaitoh 	 * enabled.
    150       1.1  msaitoh 	 */
    151       1.7  msaitoh 	mac->arc_subsystem_valid = !!(IXGBE_READ_REG(hw, IXGBE_FWSM_BY_MAC(hw))
    152       1.7  msaitoh 				     & IXGBE_FWSM_MODE_MASK);
    153       1.1  msaitoh 
    154       1.1  msaitoh 	hw->mbx.ops.init_params = ixgbe_init_mbx_params_pf;
    155       1.1  msaitoh 
    156       1.1  msaitoh 	/* LEDs */
    157       1.1  msaitoh 	mac->ops.blink_led_start = ixgbe_blink_led_start_X540;
    158       1.1  msaitoh 	mac->ops.blink_led_stop = ixgbe_blink_led_stop_X540;
    159       1.1  msaitoh 
    160       1.1  msaitoh 	/* Manageability interface */
    161       1.5  msaitoh 	mac->ops.set_fw_drv_ver = ixgbe_set_fw_drv_ver_generic;
    162       1.1  msaitoh 
    163       1.5  msaitoh 	mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
    164       1.4  msaitoh 
    165       1.1  msaitoh 	return ret_val;
    166       1.1  msaitoh }
    167       1.1  msaitoh 
    168       1.1  msaitoh /**
    169  1.16.8.3   martin  * ixgbe_get_link_capabilities_X540 - Determines link capabilities
    170  1.16.8.3   martin  * @hw: pointer to hardware structure
    171  1.16.8.3   martin  * @speed: pointer to link speed
    172  1.16.8.3   martin  * @autoneg: TRUE when autoneg or autotry is enabled
    173       1.1  msaitoh  *
    174  1.16.8.3   martin  * Determines the link capabilities by reading the AUTOC register.
    175       1.1  msaitoh  **/
    176       1.1  msaitoh s32 ixgbe_get_link_capabilities_X540(struct ixgbe_hw *hw,
    177       1.1  msaitoh 				     ixgbe_link_speed *speed,
    178       1.1  msaitoh 				     bool *autoneg)
    179       1.1  msaitoh {
    180       1.1  msaitoh 	ixgbe_get_copper_link_capabilities_generic(hw, speed, autoneg);
    181       1.1  msaitoh 
    182       1.1  msaitoh 	return IXGBE_SUCCESS;
    183       1.1  msaitoh }
    184       1.1  msaitoh 
    185       1.1  msaitoh /**
    186  1.16.8.3   martin  * ixgbe_get_media_type_X540 - Get media type
    187  1.16.8.3   martin  * @hw: pointer to hardware structure
    188       1.1  msaitoh  *
    189  1.16.8.3   martin  * Returns the media type (fiber, copper, backplane)
    190       1.1  msaitoh  **/
    191       1.1  msaitoh enum ixgbe_media_type ixgbe_get_media_type_X540(struct ixgbe_hw *hw)
    192       1.1  msaitoh {
    193       1.1  msaitoh 	UNREFERENCED_1PARAMETER(hw);
    194       1.1  msaitoh 	return ixgbe_media_type_copper;
    195       1.1  msaitoh }
    196       1.1  msaitoh 
    197       1.1  msaitoh /**
    198  1.16.8.3   martin  * ixgbe_setup_mac_link_X540 - Sets the auto advertised capabilities
    199  1.16.8.3   martin  * @hw: pointer to hardware structure
    200  1.16.8.3   martin  * @speed: new link speed
    201  1.16.8.3   martin  * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
    202       1.1  msaitoh  **/
    203       1.1  msaitoh s32 ixgbe_setup_mac_link_X540(struct ixgbe_hw *hw,
    204       1.3  msaitoh 			      ixgbe_link_speed speed,
    205       1.1  msaitoh 			      bool autoneg_wait_to_complete)
    206       1.1  msaitoh {
    207       1.1  msaitoh 	DEBUGFUNC("ixgbe_setup_mac_link_X540");
    208       1.3  msaitoh 	return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
    209       1.1  msaitoh }
    210       1.1  msaitoh 
    211       1.1  msaitoh /**
    212  1.16.8.3   martin  * ixgbe_reset_hw_X540 - Perform hardware reset
    213  1.16.8.3   martin  * @hw: pointer to hardware structure
    214       1.1  msaitoh  *
    215  1.16.8.3   martin  * Resets the hardware by resetting the transmit and receive units, masks
    216  1.16.8.3   martin  * and clears all interrupts, and perform a reset.
    217       1.1  msaitoh  **/
    218       1.1  msaitoh s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw)
    219       1.1  msaitoh {
    220       1.1  msaitoh 	s32 status;
    221       1.1  msaitoh 	u32 ctrl, i;
    222      1.10  msaitoh 	u32 swfw_mask = hw->phy.phy_semaphore_mask;
    223       1.1  msaitoh 
    224       1.1  msaitoh 	DEBUGFUNC("ixgbe_reset_hw_X540");
    225       1.1  msaitoh 
    226       1.1  msaitoh 	/* Call adapter stop to disable tx/rx and clear interrupts */
    227       1.1  msaitoh 	status = hw->mac.ops.stop_adapter(hw);
    228       1.1  msaitoh 	if (status != IXGBE_SUCCESS)
    229       1.1  msaitoh 		goto reset_hw_out;
    230       1.1  msaitoh 
    231       1.1  msaitoh 	/* flush pending Tx transactions */
    232       1.1  msaitoh 	ixgbe_clear_tx_pending(hw);
    233       1.1  msaitoh 
    234       1.1  msaitoh mac_reset_top:
    235      1.10  msaitoh 	status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
    236      1.10  msaitoh 	if (status != IXGBE_SUCCESS) {
    237      1.10  msaitoh 		ERROR_REPORT2(IXGBE_ERROR_CAUTION,
    238      1.10  msaitoh 			"semaphore failed with %d", status);
    239      1.10  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    240      1.10  msaitoh 	}
    241       1.1  msaitoh 	ctrl = IXGBE_CTRL_RST;
    242       1.1  msaitoh 	ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
    243       1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
    244       1.1  msaitoh 	IXGBE_WRITE_FLUSH(hw);
    245      1.10  msaitoh 	hw->mac.ops.release_swfw_sync(hw, swfw_mask);
    246       1.1  msaitoh 
    247       1.1  msaitoh 	/* Poll for reset bit to self-clear indicating reset is complete */
    248       1.1  msaitoh 	for (i = 0; i < 10; i++) {
    249       1.1  msaitoh 		usec_delay(1);
    250       1.1  msaitoh 		ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
    251       1.1  msaitoh 		if (!(ctrl & IXGBE_CTRL_RST_MASK))
    252       1.1  msaitoh 			break;
    253       1.1  msaitoh 	}
    254       1.1  msaitoh 
    255       1.1  msaitoh 	if (ctrl & IXGBE_CTRL_RST_MASK) {
    256       1.1  msaitoh 		status = IXGBE_ERR_RESET_FAILED;
    257       1.4  msaitoh 		ERROR_REPORT1(IXGBE_ERROR_POLLING,
    258       1.4  msaitoh 			     "Reset polling failed to complete.\n");
    259       1.1  msaitoh 	}
    260       1.1  msaitoh 	msec_delay(100);
    261       1.1  msaitoh 
    262       1.1  msaitoh 	/*
    263       1.1  msaitoh 	 * Double resets are required for recovery from certain error
    264       1.1  msaitoh 	 * conditions.  Between resets, it is necessary to stall to allow time
    265       1.1  msaitoh 	 * for any pending HW events to complete.
    266       1.1  msaitoh 	 */
    267       1.1  msaitoh 	if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
    268       1.1  msaitoh 		hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
    269       1.1  msaitoh 		goto mac_reset_top;
    270       1.1  msaitoh 	}
    271       1.1  msaitoh 
    272       1.1  msaitoh 	/* Set the Rx packet buffer size. */
    273       1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0), 384 << IXGBE_RXPBSIZE_SHIFT);
    274       1.1  msaitoh 
    275       1.1  msaitoh 	/* Store the permanent mac address */
    276       1.1  msaitoh 	hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
    277       1.1  msaitoh 
    278       1.1  msaitoh 	/*
    279       1.1  msaitoh 	 * Store MAC address from RAR0, clear receive address registers, and
    280       1.1  msaitoh 	 * clear the multicast table.  Also reset num_rar_entries to 128,
    281       1.1  msaitoh 	 * since we modify this value when programming the SAN MAC address.
    282       1.1  msaitoh 	 */
    283       1.1  msaitoh 	hw->mac.num_rar_entries = 128;
    284       1.1  msaitoh 	hw->mac.ops.init_rx_addrs(hw);
    285       1.1  msaitoh 
    286       1.1  msaitoh 	/* Store the permanent SAN mac address */
    287       1.1  msaitoh 	hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
    288       1.1  msaitoh 
    289       1.1  msaitoh 	/* Add the SAN MAC address to the RAR only if it's a valid address */
    290       1.1  msaitoh 	if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
    291      1.10  msaitoh 		/* Save the SAN MAC RAR index */
    292      1.10  msaitoh 		hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
    293      1.10  msaitoh 
    294      1.10  msaitoh 		hw->mac.ops.set_rar(hw, hw->mac.san_mac_rar_index,
    295       1.1  msaitoh 				    hw->mac.san_addr, 0, IXGBE_RAH_AV);
    296       1.1  msaitoh 
    297      1.10  msaitoh 		/* clear VMDq pool/queue selection for this RAR */
    298      1.10  msaitoh 		hw->mac.ops.clear_vmdq(hw, hw->mac.san_mac_rar_index,
    299      1.10  msaitoh 				       IXGBE_CLEAR_VMDQ_ALL);
    300       1.2  msaitoh 
    301       1.1  msaitoh 		/* Reserve the last RAR for the SAN MAC address */
    302       1.1  msaitoh 		hw->mac.num_rar_entries--;
    303       1.1  msaitoh 	}
    304       1.1  msaitoh 
    305       1.1  msaitoh 	/* Store the alternative WWNN/WWPN prefix */
    306       1.1  msaitoh 	hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
    307       1.1  msaitoh 				   &hw->mac.wwpn_prefix);
    308       1.1  msaitoh 
    309       1.1  msaitoh reset_hw_out:
    310       1.1  msaitoh 	return status;
    311       1.1  msaitoh }
    312       1.1  msaitoh 
    313       1.1  msaitoh /**
    314  1.16.8.3   martin  * ixgbe_start_hw_X540 - Prepare hardware for Tx/Rx
    315  1.16.8.3   martin  * @hw: pointer to hardware structure
    316       1.1  msaitoh  *
    317  1.16.8.3   martin  * Starts the hardware using the generic start_hw function
    318  1.16.8.3   martin  * and the generation start_hw function.
    319  1.16.8.3   martin  * Then performs revision-specific operations, if any.
    320       1.1  msaitoh  **/
    321       1.1  msaitoh s32 ixgbe_start_hw_X540(struct ixgbe_hw *hw)
    322       1.1  msaitoh {
    323       1.1  msaitoh 	s32 ret_val = IXGBE_SUCCESS;
    324       1.1  msaitoh 
    325       1.1  msaitoh 	DEBUGFUNC("ixgbe_start_hw_X540");
    326       1.1  msaitoh 
    327       1.1  msaitoh 	ret_val = ixgbe_start_hw_generic(hw);
    328       1.1  msaitoh 	if (ret_val != IXGBE_SUCCESS)
    329       1.1  msaitoh 		goto out;
    330       1.1  msaitoh 
    331  1.16.8.3   martin 	ixgbe_start_hw_gen2(hw);
    332       1.1  msaitoh 
    333       1.1  msaitoh out:
    334       1.1  msaitoh 	return ret_val;
    335       1.1  msaitoh }
    336       1.1  msaitoh 
    337       1.1  msaitoh /**
    338  1.16.8.3   martin  * ixgbe_get_supported_physical_layer_X540 - Returns physical layer type
    339  1.16.8.3   martin  * @hw: pointer to hardware structure
    340       1.1  msaitoh  *
    341  1.16.8.3   martin  * Determines physical layer capabilities of the current configuration.
    342       1.1  msaitoh  **/
    343      1.10  msaitoh u64 ixgbe_get_supported_physical_layer_X540(struct ixgbe_hw *hw)
    344       1.1  msaitoh {
    345      1.10  msaitoh 	u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
    346       1.1  msaitoh 	u16 ext_ability = 0;
    347       1.1  msaitoh 
    348       1.1  msaitoh 	DEBUGFUNC("ixgbe_get_supported_physical_layer_X540");
    349       1.1  msaitoh 
    350       1.1  msaitoh 	hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
    351       1.1  msaitoh 	IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
    352       1.1  msaitoh 	if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
    353       1.1  msaitoh 		physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
    354       1.1  msaitoh 	if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
    355       1.1  msaitoh 		physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
    356       1.1  msaitoh 	if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY)
    357       1.1  msaitoh 		physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
    358       1.1  msaitoh 
    359      1.11  msaitoh 	if (hw->mac.type == ixgbe_mac_X550) {
    360      1.11  msaitoh 		physical_layer |= IXGBE_PHYSICAL_LAYER_2500BASE_T
    361      1.11  msaitoh 		    | IXGBE_PHYSICAL_LAYER_5GBASE_T;
    362      1.11  msaitoh 	}
    363      1.11  msaitoh 
    364       1.1  msaitoh 	return physical_layer;
    365       1.1  msaitoh }
    366       1.1  msaitoh 
    367       1.1  msaitoh /**
    368  1.16.8.3   martin  * ixgbe_init_eeprom_params_X540 - Initialize EEPROM params
    369  1.16.8.3   martin  * @hw: pointer to hardware structure
    370       1.1  msaitoh  *
    371  1.16.8.3   martin  * Initializes the EEPROM parameters ixgbe_eeprom_info within the
    372  1.16.8.3   martin  * ixgbe_hw struct in order to set up EEPROM access.
    373       1.1  msaitoh  **/
    374       1.1  msaitoh s32 ixgbe_init_eeprom_params_X540(struct ixgbe_hw *hw)
    375       1.1  msaitoh {
    376       1.1  msaitoh 	struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
    377       1.1  msaitoh 	u32 eec;
    378       1.1  msaitoh 	u16 eeprom_size;
    379       1.1  msaitoh 
    380       1.1  msaitoh 	DEBUGFUNC("ixgbe_init_eeprom_params_X540");
    381       1.1  msaitoh 
    382       1.1  msaitoh 	if (eeprom->type == ixgbe_eeprom_uninitialized) {
    383       1.1  msaitoh 		eeprom->semaphore_delay = 10;
    384       1.1  msaitoh 		eeprom->type = ixgbe_flash;
    385       1.1  msaitoh 
    386       1.7  msaitoh 		eec = IXGBE_READ_REG(hw, IXGBE_EEC_BY_MAC(hw));
    387       1.1  msaitoh 		eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
    388       1.1  msaitoh 				    IXGBE_EEC_SIZE_SHIFT);
    389       1.1  msaitoh 		eeprom->word_size = 1 << (eeprom_size +
    390       1.1  msaitoh 					  IXGBE_EEPROM_WORD_SIZE_SHIFT);
    391       1.1  msaitoh 
    392       1.1  msaitoh 		DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
    393       1.1  msaitoh 			  eeprom->type, eeprom->word_size);
    394       1.1  msaitoh 	}
    395       1.1  msaitoh 
    396       1.1  msaitoh 	return IXGBE_SUCCESS;
    397       1.1  msaitoh }
    398       1.1  msaitoh 
    399       1.1  msaitoh /**
    400  1.16.8.3   martin  * ixgbe_read_eerd_X540- Read EEPROM word using EERD
    401  1.16.8.3   martin  * @hw: pointer to hardware structure
    402  1.16.8.3   martin  * @offset: offset of  word in the EEPROM to read
    403  1.16.8.3   martin  * @data: word read from the EEPROM
    404       1.1  msaitoh  *
    405  1.16.8.3   martin  * Reads a 16 bit word from the EEPROM using the EERD register.
    406       1.1  msaitoh  **/
    407       1.1  msaitoh s32 ixgbe_read_eerd_X540(struct ixgbe_hw *hw, u16 offset, u16 *data)
    408       1.1  msaitoh {
    409       1.1  msaitoh 	s32 status = IXGBE_SUCCESS;
    410       1.1  msaitoh 
    411       1.1  msaitoh 	DEBUGFUNC("ixgbe_read_eerd_X540");
    412       1.1  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
    413       1.4  msaitoh 	    IXGBE_SUCCESS) {
    414       1.1  msaitoh 		status = ixgbe_read_eerd_generic(hw, offset, data);
    415       1.4  msaitoh 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    416       1.4  msaitoh 	} else {
    417       1.1  msaitoh 		status = IXGBE_ERR_SWFW_SYNC;
    418       1.4  msaitoh 	}
    419       1.1  msaitoh 
    420       1.1  msaitoh 	return status;
    421       1.1  msaitoh }
    422       1.1  msaitoh 
    423       1.1  msaitoh /**
    424  1.16.8.3   martin  * ixgbe_read_eerd_buffer_X540- Read EEPROM word(s) using EERD
    425  1.16.8.3   martin  * @hw: pointer to hardware structure
    426  1.16.8.3   martin  * @offset: offset of  word in the EEPROM to read
    427  1.16.8.3   martin  * @words: number of words
    428  1.16.8.3   martin  * @data: word(s) read from the EEPROM
    429       1.1  msaitoh  *
    430  1.16.8.3   martin  * Reads a 16 bit word(s) from the EEPROM using the EERD register.
    431       1.1  msaitoh  **/
    432       1.1  msaitoh s32 ixgbe_read_eerd_buffer_X540(struct ixgbe_hw *hw,
    433       1.1  msaitoh 				u16 offset, u16 words, u16 *data)
    434       1.1  msaitoh {
    435       1.1  msaitoh 	s32 status = IXGBE_SUCCESS;
    436       1.1  msaitoh 
    437       1.1  msaitoh 	DEBUGFUNC("ixgbe_read_eerd_buffer_X540");
    438       1.1  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
    439       1.4  msaitoh 	    IXGBE_SUCCESS) {
    440       1.1  msaitoh 		status = ixgbe_read_eerd_buffer_generic(hw, offset,
    441       1.1  msaitoh 							words, data);
    442       1.4  msaitoh 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    443       1.4  msaitoh 	} else {
    444       1.1  msaitoh 		status = IXGBE_ERR_SWFW_SYNC;
    445       1.4  msaitoh 	}
    446       1.1  msaitoh 
    447       1.1  msaitoh 	return status;
    448       1.1  msaitoh }
    449       1.1  msaitoh 
    450       1.1  msaitoh /**
    451  1.16.8.3   martin  * ixgbe_write_eewr_X540 - Write EEPROM word using EEWR
    452  1.16.8.3   martin  * @hw: pointer to hardware structure
    453  1.16.8.3   martin  * @offset: offset of  word in the EEPROM to write
    454  1.16.8.3   martin  * @data: word write to the EEPROM
    455       1.1  msaitoh  *
    456  1.16.8.3   martin  * Write a 16 bit word to the EEPROM using the EEWR register.
    457       1.1  msaitoh  **/
    458       1.1  msaitoh s32 ixgbe_write_eewr_X540(struct ixgbe_hw *hw, u16 offset, u16 data)
    459       1.1  msaitoh {
    460       1.1  msaitoh 	s32 status = IXGBE_SUCCESS;
    461       1.1  msaitoh 
    462       1.1  msaitoh 	DEBUGFUNC("ixgbe_write_eewr_X540");
    463       1.1  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
    464       1.4  msaitoh 	    IXGBE_SUCCESS) {
    465       1.1  msaitoh 		status = ixgbe_write_eewr_generic(hw, offset, data);
    466       1.4  msaitoh 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    467       1.4  msaitoh 	} else {
    468       1.1  msaitoh 		status = IXGBE_ERR_SWFW_SYNC;
    469       1.4  msaitoh 	}
    470       1.1  msaitoh 
    471       1.1  msaitoh 	return status;
    472       1.1  msaitoh }
    473       1.1  msaitoh 
    474       1.1  msaitoh /**
    475  1.16.8.3   martin  * ixgbe_write_eewr_buffer_X540 - Write EEPROM word(s) using EEWR
    476  1.16.8.3   martin  * @hw: pointer to hardware structure
    477  1.16.8.3   martin  * @offset: offset of  word in the EEPROM to write
    478  1.16.8.3   martin  * @words: number of words
    479  1.16.8.3   martin  * @data: word(s) write to the EEPROM
    480       1.1  msaitoh  *
    481  1.16.8.3   martin  * Write a 16 bit word(s) to the EEPROM using the EEWR register.
    482       1.1  msaitoh  **/
    483       1.1  msaitoh s32 ixgbe_write_eewr_buffer_X540(struct ixgbe_hw *hw,
    484       1.1  msaitoh 				 u16 offset, u16 words, u16 *data)
    485       1.1  msaitoh {
    486       1.1  msaitoh 	s32 status = IXGBE_SUCCESS;
    487       1.1  msaitoh 
    488       1.1  msaitoh 	DEBUGFUNC("ixgbe_write_eewr_buffer_X540");
    489       1.1  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
    490       1.4  msaitoh 	    IXGBE_SUCCESS) {
    491       1.1  msaitoh 		status = ixgbe_write_eewr_buffer_generic(hw, offset,
    492       1.1  msaitoh 							 words, data);
    493       1.4  msaitoh 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    494       1.4  msaitoh 	} else {
    495       1.1  msaitoh 		status = IXGBE_ERR_SWFW_SYNC;
    496       1.4  msaitoh 	}
    497       1.1  msaitoh 
    498       1.1  msaitoh 	return status;
    499       1.1  msaitoh }
    500       1.1  msaitoh 
    501       1.1  msaitoh /**
    502  1.16.8.3   martin  * ixgbe_calc_eeprom_checksum_X540 - Calculates and returns the checksum
    503       1.1  msaitoh  *
    504  1.16.8.3   martin  * This function does not use synchronization for EERD and EEWR. It can
    505  1.16.8.3   martin  * be used internally by function which utilize ixgbe_acquire_swfw_sync_X540.
    506       1.1  msaitoh  *
    507  1.16.8.3   martin  * @hw: pointer to hardware structure
    508       1.5  msaitoh  *
    509  1.16.8.3   martin  * Returns a negative error code on error, or the 16-bit checksum
    510       1.1  msaitoh  **/
    511       1.5  msaitoh s32 ixgbe_calc_eeprom_checksum_X540(struct ixgbe_hw *hw)
    512       1.1  msaitoh {
    513       1.5  msaitoh 	u16 i, j;
    514       1.1  msaitoh 	u16 checksum = 0;
    515       1.1  msaitoh 	u16 length = 0;
    516       1.1  msaitoh 	u16 pointer = 0;
    517       1.1  msaitoh 	u16 word = 0;
    518       1.5  msaitoh 	u16 ptr_start = IXGBE_PCIE_ANALOG_PTR;
    519       1.1  msaitoh 
    520       1.5  msaitoh 	/* Do not use hw->eeprom.ops.read because we do not want to take
    521       1.1  msaitoh 	 * the synchronization semaphores here. Instead use
    522       1.1  msaitoh 	 * ixgbe_read_eerd_generic
    523       1.1  msaitoh 	 */
    524       1.1  msaitoh 
    525       1.1  msaitoh 	DEBUGFUNC("ixgbe_calc_eeprom_checksum_X540");
    526       1.1  msaitoh 
    527      1.10  msaitoh 	/* Include 0x0 up to IXGBE_EEPROM_CHECKSUM; do not include the
    528      1.10  msaitoh 	 * checksum itself
    529      1.10  msaitoh 	 */
    530      1.10  msaitoh 	for (i = 0; i < IXGBE_EEPROM_CHECKSUM; i++) {
    531       1.5  msaitoh 		if (ixgbe_read_eerd_generic(hw, i, &word)) {
    532       1.1  msaitoh 			DEBUGOUT("EEPROM read failed\n");
    533       1.5  msaitoh 			return IXGBE_ERR_EEPROM;
    534       1.1  msaitoh 		}
    535      1.10  msaitoh 		checksum += word;
    536       1.1  msaitoh 	}
    537       1.1  msaitoh 
    538       1.5  msaitoh 	/* Include all data from pointers 0x3, 0x6-0xE.  This excludes the
    539       1.1  msaitoh 	 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
    540       1.1  msaitoh 	 */
    541       1.5  msaitoh 	for (i = ptr_start; i < IXGBE_FW_PTR; i++) {
    542       1.1  msaitoh 		if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
    543       1.1  msaitoh 			continue;
    544       1.1  msaitoh 
    545       1.5  msaitoh 		if (ixgbe_read_eerd_generic(hw, i, &pointer)) {
    546       1.1  msaitoh 			DEBUGOUT("EEPROM read failed\n");
    547       1.5  msaitoh 			return IXGBE_ERR_EEPROM;
    548       1.1  msaitoh 		}
    549       1.1  msaitoh 
    550       1.1  msaitoh 		/* Skip pointer section if the pointer is invalid. */
    551       1.1  msaitoh 		if (pointer == 0xFFFF || pointer == 0 ||
    552       1.1  msaitoh 		    pointer >= hw->eeprom.word_size)
    553       1.1  msaitoh 			continue;
    554       1.1  msaitoh 
    555       1.5  msaitoh 		if (ixgbe_read_eerd_generic(hw, pointer, &length)) {
    556       1.1  msaitoh 			DEBUGOUT("EEPROM read failed\n");
    557       1.5  msaitoh 			return IXGBE_ERR_EEPROM;
    558       1.1  msaitoh 		}
    559       1.1  msaitoh 
    560       1.1  msaitoh 		/* Skip pointer section if length is invalid. */
    561       1.1  msaitoh 		if (length == 0xFFFF || length == 0 ||
    562       1.1  msaitoh 		    (pointer + length) >= hw->eeprom.word_size)
    563       1.1  msaitoh 			continue;
    564       1.1  msaitoh 
    565       1.5  msaitoh 		for (j = pointer + 1; j <= pointer + length; j++) {
    566       1.5  msaitoh 			if (ixgbe_read_eerd_generic(hw, j, &word)) {
    567       1.1  msaitoh 				DEBUGOUT("EEPROM read failed\n");
    568       1.5  msaitoh 				return IXGBE_ERR_EEPROM;
    569       1.1  msaitoh 			}
    570       1.1  msaitoh 			checksum += word;
    571       1.1  msaitoh 		}
    572       1.1  msaitoh 	}
    573       1.1  msaitoh 
    574       1.1  msaitoh 	checksum = (u16)IXGBE_EEPROM_SUM - checksum;
    575       1.1  msaitoh 
    576       1.5  msaitoh 	return (s32)checksum;
    577       1.1  msaitoh }
    578       1.1  msaitoh 
    579       1.1  msaitoh /**
    580  1.16.8.3   martin  * ixgbe_validate_eeprom_checksum_X540 - Validate EEPROM checksum
    581  1.16.8.3   martin  * @hw: pointer to hardware structure
    582  1.16.8.3   martin  * @checksum_val: calculated checksum
    583       1.1  msaitoh  *
    584  1.16.8.3   martin  * Performs checksum calculation and validates the EEPROM checksum.  If the
    585  1.16.8.3   martin  * caller does not need checksum_val, the value can be NULL.
    586       1.1  msaitoh  **/
    587       1.1  msaitoh s32 ixgbe_validate_eeprom_checksum_X540(struct ixgbe_hw *hw,
    588       1.1  msaitoh 					u16 *checksum_val)
    589       1.1  msaitoh {
    590       1.1  msaitoh 	s32 status;
    591       1.1  msaitoh 	u16 checksum;
    592       1.1  msaitoh 	u16 read_checksum = 0;
    593       1.1  msaitoh 
    594       1.1  msaitoh 	DEBUGFUNC("ixgbe_validate_eeprom_checksum_X540");
    595       1.1  msaitoh 
    596       1.5  msaitoh 	/* Read the first word from the EEPROM. If this times out or fails, do
    597       1.1  msaitoh 	 * not continue or we could be in for a very long wait while every
    598       1.1  msaitoh 	 * EEPROM read fails
    599       1.1  msaitoh 	 */
    600       1.1  msaitoh 	status = hw->eeprom.ops.read(hw, 0, &checksum);
    601       1.5  msaitoh 	if (status) {
    602       1.1  msaitoh 		DEBUGOUT("EEPROM read failed\n");
    603       1.5  msaitoh 		return status;
    604       1.1  msaitoh 	}
    605       1.1  msaitoh 
    606       1.5  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM))
    607       1.5  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    608       1.5  msaitoh 
    609       1.5  msaitoh 	status = hw->eeprom.ops.calc_checksum(hw);
    610       1.5  msaitoh 	if (status < 0)
    611       1.5  msaitoh 		goto out;
    612       1.1  msaitoh 
    613       1.5  msaitoh 	checksum = (u16)(status & 0xffff);
    614       1.1  msaitoh 
    615       1.5  msaitoh 	/* Do not use hw->eeprom.ops.read because we do not want to take
    616       1.5  msaitoh 	 * the synchronization semaphores twice here.
    617       1.5  msaitoh 	 */
    618       1.5  msaitoh 	status = ixgbe_read_eerd_generic(hw, IXGBE_EEPROM_CHECKSUM,
    619       1.5  msaitoh 					 &read_checksum);
    620       1.5  msaitoh 	if (status)
    621       1.5  msaitoh 		goto out;
    622       1.1  msaitoh 
    623       1.5  msaitoh 	/* Verify read checksum from EEPROM is the same as
    624       1.5  msaitoh 	 * calculated checksum
    625       1.5  msaitoh 	 */
    626       1.5  msaitoh 	if (read_checksum != checksum) {
    627       1.5  msaitoh 		ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
    628       1.5  msaitoh 			     "Invalid EEPROM checksum");
    629       1.5  msaitoh 		status = IXGBE_ERR_EEPROM_CHECKSUM;
    630       1.1  msaitoh 	}
    631       1.1  msaitoh 
    632       1.5  msaitoh 	/* If the user cares, return the calculated checksum */
    633       1.5  msaitoh 	if (checksum_val)
    634       1.5  msaitoh 		*checksum_val = checksum;
    635       1.5  msaitoh 
    636       1.1  msaitoh out:
    637       1.5  msaitoh 	hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    638       1.5  msaitoh 
    639       1.1  msaitoh 	return status;
    640       1.1  msaitoh }
    641       1.1  msaitoh 
    642       1.1  msaitoh /**
    643       1.1  msaitoh  * ixgbe_update_eeprom_checksum_X540 - Updates the EEPROM checksum and flash
    644       1.1  msaitoh  * @hw: pointer to hardware structure
    645       1.1  msaitoh  *
    646       1.1  msaitoh  * After writing EEPROM to shadow RAM using EEWR register, software calculates
    647       1.1  msaitoh  * checksum and updates the EEPROM and instructs the hardware to update
    648       1.1  msaitoh  * the flash.
    649       1.1  msaitoh  **/
    650       1.1  msaitoh s32 ixgbe_update_eeprom_checksum_X540(struct ixgbe_hw *hw)
    651       1.1  msaitoh {
    652       1.1  msaitoh 	s32 status;
    653       1.1  msaitoh 	u16 checksum;
    654       1.1  msaitoh 
    655       1.1  msaitoh 	DEBUGFUNC("ixgbe_update_eeprom_checksum_X540");
    656       1.1  msaitoh 
    657       1.5  msaitoh 	/* Read the first word from the EEPROM. If this times out or fails, do
    658       1.1  msaitoh 	 * not continue or we could be in for a very long wait while every
    659       1.1  msaitoh 	 * EEPROM read fails
    660       1.1  msaitoh 	 */
    661       1.1  msaitoh 	status = hw->eeprom.ops.read(hw, 0, &checksum);
    662       1.5  msaitoh 	if (status) {
    663       1.5  msaitoh 		DEBUGOUT("EEPROM read failed\n");
    664       1.5  msaitoh 		return status;
    665       1.5  msaitoh 	}
    666       1.5  msaitoh 
    667       1.5  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM))
    668       1.5  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    669       1.5  msaitoh 
    670       1.5  msaitoh 	status = hw->eeprom.ops.calc_checksum(hw);
    671       1.5  msaitoh 	if (status < 0)
    672       1.5  msaitoh 		goto out;
    673       1.1  msaitoh 
    674       1.5  msaitoh 	checksum = (u16)(status & 0xffff);
    675       1.1  msaitoh 
    676       1.5  msaitoh 	/* Do not use hw->eeprom.ops.write because we do not want to
    677       1.5  msaitoh 	 * take the synchronization semaphores twice here.
    678       1.5  msaitoh 	 */
    679       1.5  msaitoh 	status = ixgbe_write_eewr_generic(hw, IXGBE_EEPROM_CHECKSUM, checksum);
    680       1.5  msaitoh 	if (status)
    681       1.5  msaitoh 		goto out;
    682       1.1  msaitoh 
    683       1.5  msaitoh 	status = ixgbe_update_flash_X540(hw);
    684       1.1  msaitoh 
    685       1.5  msaitoh out:
    686       1.5  msaitoh 	hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    687       1.1  msaitoh 
    688       1.1  msaitoh 	return status;
    689       1.1  msaitoh }
    690       1.1  msaitoh 
    691       1.1  msaitoh /**
    692  1.16.8.3   martin  * ixgbe_update_flash_X540 - Instruct HW to copy EEPROM to Flash device
    693  1.16.8.3   martin  * @hw: pointer to hardware structure
    694       1.1  msaitoh  *
    695  1.16.8.3   martin  * Set FLUP (bit 23) of the EEC register to instruct Hardware to copy
    696  1.16.8.3   martin  * EEPROM from shadow RAM to the flash device.
    697       1.1  msaitoh  **/
    698       1.4  msaitoh s32 ixgbe_update_flash_X540(struct ixgbe_hw *hw)
    699       1.1  msaitoh {
    700       1.1  msaitoh 	u32 flup;
    701       1.5  msaitoh 	s32 status;
    702       1.1  msaitoh 
    703       1.1  msaitoh 	DEBUGFUNC("ixgbe_update_flash_X540");
    704       1.1  msaitoh 
    705       1.1  msaitoh 	status = ixgbe_poll_flash_update_done_X540(hw);
    706       1.1  msaitoh 	if (status == IXGBE_ERR_EEPROM) {
    707       1.1  msaitoh 		DEBUGOUT("Flash update time out\n");
    708       1.1  msaitoh 		goto out;
    709       1.1  msaitoh 	}
    710       1.1  msaitoh 
    711       1.7  msaitoh 	flup = IXGBE_READ_REG(hw, IXGBE_EEC_BY_MAC(hw)) | IXGBE_EEC_FLUP;
    712       1.7  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_EEC_BY_MAC(hw), flup);
    713       1.1  msaitoh 
    714       1.1  msaitoh 	status = ixgbe_poll_flash_update_done_X540(hw);
    715       1.1  msaitoh 	if (status == IXGBE_SUCCESS)
    716       1.1  msaitoh 		DEBUGOUT("Flash update complete\n");
    717       1.1  msaitoh 	else
    718       1.1  msaitoh 		DEBUGOUT("Flash update time out\n");
    719       1.1  msaitoh 
    720       1.4  msaitoh 	if (hw->mac.type == ixgbe_mac_X540 && hw->revision_id == 0) {
    721       1.7  msaitoh 		flup = IXGBE_READ_REG(hw, IXGBE_EEC_BY_MAC(hw));
    722       1.1  msaitoh 
    723       1.1  msaitoh 		if (flup & IXGBE_EEC_SEC1VAL) {
    724       1.1  msaitoh 			flup |= IXGBE_EEC_FLUP;
    725       1.7  msaitoh 			IXGBE_WRITE_REG(hw, IXGBE_EEC_BY_MAC(hw), flup);
    726       1.1  msaitoh 		}
    727       1.1  msaitoh 
    728       1.1  msaitoh 		status = ixgbe_poll_flash_update_done_X540(hw);
    729       1.1  msaitoh 		if (status == IXGBE_SUCCESS)
    730       1.1  msaitoh 			DEBUGOUT("Flash update complete\n");
    731       1.1  msaitoh 		else
    732       1.1  msaitoh 			DEBUGOUT("Flash update time out\n");
    733       1.1  msaitoh 	}
    734       1.1  msaitoh out:
    735       1.1  msaitoh 	return status;
    736       1.1  msaitoh }
    737       1.1  msaitoh 
    738       1.1  msaitoh /**
    739  1.16.8.3   martin  * ixgbe_poll_flash_update_done_X540 - Poll flash update status
    740  1.16.8.3   martin  * @hw: pointer to hardware structure
    741       1.1  msaitoh  *
    742  1.16.8.3   martin  * Polls the FLUDONE (bit 26) of the EEC Register to determine when the
    743  1.16.8.3   martin  * flash update is done.
    744       1.1  msaitoh  **/
    745       1.1  msaitoh static s32 ixgbe_poll_flash_update_done_X540(struct ixgbe_hw *hw)
    746       1.1  msaitoh {
    747       1.1  msaitoh 	u32 i;
    748       1.1  msaitoh 	u32 reg;
    749       1.1  msaitoh 	s32 status = IXGBE_ERR_EEPROM;
    750       1.1  msaitoh 
    751       1.1  msaitoh 	DEBUGFUNC("ixgbe_poll_flash_update_done_X540");
    752       1.1  msaitoh 
    753       1.1  msaitoh 	for (i = 0; i < IXGBE_FLUDONE_ATTEMPTS; i++) {
    754       1.7  msaitoh 		reg = IXGBE_READ_REG(hw, IXGBE_EEC_BY_MAC(hw));
    755       1.1  msaitoh 		if (reg & IXGBE_EEC_FLUDONE) {
    756       1.1  msaitoh 			status = IXGBE_SUCCESS;
    757       1.1  msaitoh 			break;
    758       1.1  msaitoh 		}
    759       1.5  msaitoh 		msec_delay(5);
    760       1.1  msaitoh 	}
    761       1.4  msaitoh 
    762       1.4  msaitoh 	if (i == IXGBE_FLUDONE_ATTEMPTS)
    763       1.4  msaitoh 		ERROR_REPORT1(IXGBE_ERROR_POLLING,
    764       1.4  msaitoh 			     "Flash update status polling timed out");
    765       1.4  msaitoh 
    766       1.1  msaitoh 	return status;
    767       1.1  msaitoh }
    768       1.1  msaitoh 
    769       1.1  msaitoh /**
    770  1.16.8.3   martin  * ixgbe_acquire_swfw_sync_X540 - Acquire SWFW semaphore
    771  1.16.8.3   martin  * @hw: pointer to hardware structure
    772  1.16.8.3   martin  * @mask: Mask to specify which semaphore to acquire
    773       1.1  msaitoh  *
    774  1.16.8.3   martin  * Acquires the SWFW semaphore thought the SW_FW_SYNC register for
    775  1.16.8.3   martin  * the specified function (CSR, PHY0, PHY1, NVM, Flash)
    776       1.1  msaitoh  **/
    777       1.5  msaitoh s32 ixgbe_acquire_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask)
    778       1.1  msaitoh {
    779       1.5  msaitoh 	u32 swmask = mask & IXGBE_GSSR_NVM_PHY_MASK;
    780       1.5  msaitoh 	u32 fwmask = swmask << 5;
    781       1.5  msaitoh 	u32 swi2c_mask = mask & IXGBE_GSSR_I2C_MASK;
    782       1.5  msaitoh 	u32 timeout = 200;
    783       1.5  msaitoh 	u32 hwmask = 0;
    784       1.1  msaitoh 	u32 swfw_sync;
    785       1.1  msaitoh 	u32 i;
    786       1.1  msaitoh 
    787       1.1  msaitoh 	DEBUGFUNC("ixgbe_acquire_swfw_sync_X540");
    788       1.1  msaitoh 
    789       1.5  msaitoh 	if (swmask & IXGBE_GSSR_EEP_SM)
    790       1.5  msaitoh 		hwmask |= IXGBE_GSSR_FLASH_SM;
    791       1.1  msaitoh 
    792       1.1  msaitoh 	/* SW only mask doesn't have FW bit pair */
    793       1.5  msaitoh 	if (mask & IXGBE_GSSR_SW_MNG_SM)
    794       1.5  msaitoh 		swmask |= IXGBE_GSSR_SW_MNG_SM;
    795       1.1  msaitoh 
    796       1.5  msaitoh 	swmask |= swi2c_mask;
    797       1.5  msaitoh 	fwmask |= swi2c_mask << 2;
    798      1.16  msaitoh 	if (hw->mac.type >= ixgbe_mac_X550)
    799      1.13  msaitoh 		timeout = 1000;
    800      1.13  msaitoh 
    801       1.1  msaitoh 	for (i = 0; i < timeout; i++) {
    802       1.5  msaitoh 		/* SW NVM semaphore bit is used for access to all
    803       1.1  msaitoh 		 * SW_FW_SYNC bits (not just NVM)
    804       1.1  msaitoh 		 */
    805      1.10  msaitoh 		if (ixgbe_get_swfw_sync_semaphore(hw)) {
    806      1.10  msaitoh 			DEBUGOUT("Failed to get NVM access and register semaphore, returning IXGBE_ERR_SWFW_SYNC\n");
    807       1.5  msaitoh 			return IXGBE_ERR_SWFW_SYNC;
    808      1.10  msaitoh 		}
    809       1.1  msaitoh 
    810       1.7  msaitoh 		swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    811       1.1  msaitoh 		if (!(swfw_sync & (fwmask | swmask | hwmask))) {
    812       1.1  msaitoh 			swfw_sync |= swmask;
    813       1.7  msaitoh 			IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw),
    814       1.7  msaitoh 					swfw_sync);
    815       1.1  msaitoh 			ixgbe_release_swfw_sync_semaphore(hw);
    816       1.5  msaitoh 			return IXGBE_SUCCESS;
    817       1.1  msaitoh 		}
    818       1.5  msaitoh 		/* Firmware currently using resource (fwmask), hardware
    819       1.5  msaitoh 		 * currently using resource (hwmask), or other software
    820       1.5  msaitoh 		 * thread currently using resource (swmask)
    821       1.5  msaitoh 		 */
    822       1.5  msaitoh 		ixgbe_release_swfw_sync_semaphore(hw);
    823       1.5  msaitoh 		msec_delay(5);
    824       1.1  msaitoh 	}
    825       1.1  msaitoh 
    826       1.1  msaitoh 	/* If the resource is not released by the FW/HW the SW can assume that
    827       1.4  msaitoh 	 * the FW/HW malfunctions. In that case the SW should set the SW bit(s)
    828       1.1  msaitoh 	 * of the requested resource(s) while ignoring the corresponding FW/HW
    829       1.1  msaitoh 	 * bits in the SW_FW_SYNC register.
    830       1.1  msaitoh 	 */
    831      1.10  msaitoh 	if (ixgbe_get_swfw_sync_semaphore(hw)) {
    832  1.16.8.1   martin 		DEBUGOUT("Failed to get NVM semaphore and register semaphore while forcefully ignoring FW semaphore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n");
    833       1.5  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    834      1.10  msaitoh 	}
    835       1.7  msaitoh 	swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    836       1.1  msaitoh 	if (swfw_sync & (fwmask | hwmask)) {
    837       1.1  msaitoh 		swfw_sync |= swmask;
    838       1.7  msaitoh 		IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw), swfw_sync);
    839       1.1  msaitoh 		ixgbe_release_swfw_sync_semaphore(hw);
    840       1.1  msaitoh 		msec_delay(5);
    841       1.5  msaitoh 		return IXGBE_SUCCESS;
    842       1.1  msaitoh 	}
    843       1.4  msaitoh 	/* If the resource is not released by other SW the SW can assume that
    844       1.4  msaitoh 	 * the other SW malfunctions. In that case the SW should clear all SW
    845       1.4  msaitoh 	 * flags that it does not own and then repeat the whole process once
    846       1.4  msaitoh 	 * again.
    847       1.4  msaitoh 	 */
    848       1.5  msaitoh 	if (swfw_sync & swmask) {
    849       1.5  msaitoh 		u32 rmask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_PHY0_SM |
    850      1.10  msaitoh 			    IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_MAC_CSR_SM |
    851      1.10  msaitoh 			    IXGBE_GSSR_SW_MNG_SM;
    852       1.5  msaitoh 
    853       1.5  msaitoh 		if (swi2c_mask)
    854       1.5  msaitoh 			rmask |= IXGBE_GSSR_I2C_MASK;
    855       1.5  msaitoh 		ixgbe_release_swfw_sync_X540(hw, rmask);
    856       1.5  msaitoh 		ixgbe_release_swfw_sync_semaphore(hw);
    857      1.10  msaitoh 		DEBUGOUT("Resource not released by other SW, returning IXGBE_ERR_SWFW_SYNC\n");
    858       1.5  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    859       1.4  msaitoh 	}
    860       1.5  msaitoh 	ixgbe_release_swfw_sync_semaphore(hw);
    861      1.10  msaitoh 	DEBUGOUT("Returning error IXGBE_ERR_SWFW_SYNC\n");
    862       1.1  msaitoh 
    863       1.5  msaitoh 	return IXGBE_ERR_SWFW_SYNC;
    864       1.1  msaitoh }
    865       1.1  msaitoh 
    866       1.1  msaitoh /**
    867  1.16.8.3   martin  * ixgbe_release_swfw_sync_X540 - Release SWFW semaphore
    868  1.16.8.3   martin  * @hw: pointer to hardware structure
    869  1.16.8.3   martin  * @mask: Mask to specify which semaphore to release
    870       1.1  msaitoh  *
    871  1.16.8.3   martin  * Releases the SWFW semaphore through the SW_FW_SYNC register
    872  1.16.8.3   martin  * for the specified function (CSR, PHY0, PHY1, EVM, Flash)
    873       1.1  msaitoh  **/
    874       1.5  msaitoh void ixgbe_release_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask)
    875       1.1  msaitoh {
    876       1.5  msaitoh 	u32 swmask = mask & (IXGBE_GSSR_NVM_PHY_MASK | IXGBE_GSSR_SW_MNG_SM);
    877       1.1  msaitoh 	u32 swfw_sync;
    878       1.1  msaitoh 
    879       1.1  msaitoh 	DEBUGFUNC("ixgbe_release_swfw_sync_X540");
    880       1.1  msaitoh 
    881       1.5  msaitoh 	if (mask & IXGBE_GSSR_I2C_MASK)
    882       1.5  msaitoh 		swmask |= mask & IXGBE_GSSR_I2C_MASK;
    883       1.1  msaitoh 	ixgbe_get_swfw_sync_semaphore(hw);
    884       1.1  msaitoh 
    885       1.7  msaitoh 	swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    886       1.1  msaitoh 	swfw_sync &= ~swmask;
    887       1.7  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw), swfw_sync);
    888       1.1  msaitoh 
    889       1.1  msaitoh 	ixgbe_release_swfw_sync_semaphore(hw);
    890      1.10  msaitoh 	msec_delay(2);
    891       1.1  msaitoh }
    892       1.1  msaitoh 
    893       1.1  msaitoh /**
    894  1.16.8.3   martin  * ixgbe_get_swfw_sync_semaphore - Get hardware semaphore
    895  1.16.8.3   martin  * @hw: pointer to hardware structure
    896       1.1  msaitoh  *
    897  1.16.8.3   martin  * Sets the hardware semaphores so SW/FW can gain control of shared resources
    898       1.1  msaitoh  **/
    899       1.1  msaitoh static s32 ixgbe_get_swfw_sync_semaphore(struct ixgbe_hw *hw)
    900       1.1  msaitoh {
    901       1.1  msaitoh 	s32 status = IXGBE_ERR_EEPROM;
    902       1.1  msaitoh 	u32 timeout = 2000;
    903       1.1  msaitoh 	u32 i;
    904       1.1  msaitoh 	u32 swsm;
    905       1.1  msaitoh 
    906       1.1  msaitoh 	DEBUGFUNC("ixgbe_get_swfw_sync_semaphore");
    907       1.1  msaitoh 
    908       1.1  msaitoh 	/* Get SMBI software semaphore between device drivers first */
    909       1.1  msaitoh 	for (i = 0; i < timeout; i++) {
    910       1.1  msaitoh 		/*
    911       1.1  msaitoh 		 * If the SMBI bit is 0 when we read it, then the bit will be
    912       1.1  msaitoh 		 * set and we have the semaphore
    913       1.1  msaitoh 		 */
    914       1.7  msaitoh 		swsm = IXGBE_READ_REG(hw, IXGBE_SWSM_BY_MAC(hw));
    915       1.1  msaitoh 		if (!(swsm & IXGBE_SWSM_SMBI)) {
    916       1.1  msaitoh 			status = IXGBE_SUCCESS;
    917       1.1  msaitoh 			break;
    918       1.1  msaitoh 		}
    919       1.1  msaitoh 		usec_delay(50);
    920       1.1  msaitoh 	}
    921       1.1  msaitoh 
    922       1.1  msaitoh 	/* Now get the semaphore between SW/FW through the REGSMP bit */
    923       1.1  msaitoh 	if (status == IXGBE_SUCCESS) {
    924       1.1  msaitoh 		for (i = 0; i < timeout; i++) {
    925       1.7  msaitoh 			swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    926       1.1  msaitoh 			if (!(swsm & IXGBE_SWFW_REGSMP))
    927       1.1  msaitoh 				break;
    928       1.1  msaitoh 
    929       1.1  msaitoh 			usec_delay(50);
    930       1.1  msaitoh 		}
    931       1.1  msaitoh 
    932       1.1  msaitoh 		/*
    933       1.1  msaitoh 		 * Release semaphores and return error if SW NVM semaphore
    934       1.1  msaitoh 		 * was not granted because we don't have access to the EEPROM
    935       1.1  msaitoh 		 */
    936       1.1  msaitoh 		if (i >= timeout) {
    937       1.4  msaitoh 			ERROR_REPORT1(IXGBE_ERROR_POLLING,
    938       1.4  msaitoh 				"REGSMP Software NVM semaphore not granted.\n");
    939       1.1  msaitoh 			ixgbe_release_swfw_sync_semaphore(hw);
    940       1.1  msaitoh 			status = IXGBE_ERR_EEPROM;
    941       1.1  msaitoh 		}
    942       1.1  msaitoh 	} else {
    943       1.4  msaitoh 		ERROR_REPORT1(IXGBE_ERROR_POLLING,
    944       1.4  msaitoh 			     "Software semaphore SMBI between device drivers "
    945       1.4  msaitoh 			     "not granted.\n");
    946       1.1  msaitoh 	}
    947       1.1  msaitoh 
    948       1.1  msaitoh 	return status;
    949       1.1  msaitoh }
    950       1.1  msaitoh 
    951       1.1  msaitoh /**
    952  1.16.8.3   martin  * ixgbe_release_swfw_sync_semaphore - Release hardware semaphore
    953  1.16.8.3   martin  * @hw: pointer to hardware structure
    954       1.1  msaitoh  *
    955  1.16.8.3   martin  * This function clears hardware semaphore bits.
    956       1.1  msaitoh  **/
    957       1.1  msaitoh static void ixgbe_release_swfw_sync_semaphore(struct ixgbe_hw *hw)
    958       1.1  msaitoh {
    959       1.1  msaitoh 	u32 swsm;
    960       1.1  msaitoh 
    961       1.1  msaitoh 	DEBUGFUNC("ixgbe_release_swfw_sync_semaphore");
    962       1.1  msaitoh 
    963       1.1  msaitoh 	/* Release both semaphores by writing 0 to the bits REGSMP and SMBI */
    964       1.1  msaitoh 
    965       1.7  msaitoh 	swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    966       1.6  msaitoh 	swsm &= ~IXGBE_SWFW_REGSMP;
    967       1.7  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw), swsm);
    968       1.6  msaitoh 
    969       1.7  msaitoh 	swsm = IXGBE_READ_REG(hw, IXGBE_SWSM_BY_MAC(hw));
    970       1.1  msaitoh 	swsm &= ~IXGBE_SWSM_SMBI;
    971       1.7  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_SWSM_BY_MAC(hw), swsm);
    972       1.1  msaitoh 
    973       1.1  msaitoh 	IXGBE_WRITE_FLUSH(hw);
    974       1.1  msaitoh }
    975       1.1  msaitoh 
    976       1.1  msaitoh /**
    977  1.16.8.3   martin  * ixgbe_init_swfw_sync_X540 - Release hardware semaphore
    978  1.16.8.3   martin  * @hw: pointer to hardware structure
    979      1.10  msaitoh  *
    980  1.16.8.3   martin  * This function reset hardware semaphore bits for a semaphore that may
    981  1.16.8.3   martin  * have be left locked due to a catastrophic failure.
    982      1.10  msaitoh  **/
    983      1.10  msaitoh void ixgbe_init_swfw_sync_X540(struct ixgbe_hw *hw)
    984      1.10  msaitoh {
    985      1.10  msaitoh 	u32 rmask;
    986      1.10  msaitoh 
    987      1.10  msaitoh 	/* First try to grab the semaphore but we don't need to bother
    988      1.10  msaitoh 	 * looking to see whether we got the lock or not since we do
    989      1.10  msaitoh 	 * the same thing regardless of whether we got the lock or not.
    990      1.10  msaitoh 	 * We got the lock - we release it.
    991      1.10  msaitoh 	 * We timeout trying to get the lock - we force its release.
    992      1.10  msaitoh 	 */
    993      1.10  msaitoh 	ixgbe_get_swfw_sync_semaphore(hw);
    994      1.10  msaitoh 	ixgbe_release_swfw_sync_semaphore(hw);
    995      1.10  msaitoh 
    996      1.10  msaitoh 	/* Acquire and release all software resources. */
    997      1.10  msaitoh 	rmask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_PHY0_SM |
    998      1.10  msaitoh 		IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_MAC_CSR_SM |
    999      1.10  msaitoh 		IXGBE_GSSR_SW_MNG_SM;
   1000      1.10  msaitoh 
   1001      1.10  msaitoh 	rmask |= IXGBE_GSSR_I2C_MASK;
   1002      1.10  msaitoh 	ixgbe_acquire_swfw_sync_X540(hw, rmask);
   1003      1.10  msaitoh 	ixgbe_release_swfw_sync_X540(hw, rmask);
   1004      1.10  msaitoh }
   1005      1.10  msaitoh 
   1006      1.10  msaitoh /**
   1007       1.1  msaitoh  * ixgbe_blink_led_start_X540 - Blink LED based on index.
   1008       1.1  msaitoh  * @hw: pointer to hardware structure
   1009       1.1  msaitoh  * @index: led number to blink
   1010       1.1  msaitoh  *
   1011       1.1  msaitoh  * Devices that implement the version 2 interface:
   1012  1.16.8.3   martin  *  X540
   1013       1.1  msaitoh  **/
   1014       1.1  msaitoh s32 ixgbe_blink_led_start_X540(struct ixgbe_hw *hw, u32 index)
   1015       1.1  msaitoh {
   1016       1.1  msaitoh 	u32 macc_reg;
   1017       1.1  msaitoh 	u32 ledctl_reg;
   1018       1.1  msaitoh 	ixgbe_link_speed speed;
   1019       1.1  msaitoh 	bool link_up;
   1020       1.1  msaitoh 
   1021       1.1  msaitoh 	DEBUGFUNC("ixgbe_blink_led_start_X540");
   1022       1.1  msaitoh 
   1023      1.10  msaitoh 	if (index > 3)
   1024      1.10  msaitoh 		return IXGBE_ERR_PARAM;
   1025      1.10  msaitoh 
   1026       1.1  msaitoh 	/*
   1027       1.1  msaitoh 	 * Link should be up in order for the blink bit in the LED control
   1028       1.1  msaitoh 	 * register to work. Force link and speed in the MAC if link is down.
   1029       1.1  msaitoh 	 * This will be reversed when we stop the blinking.
   1030       1.1  msaitoh 	 */
   1031       1.1  msaitoh 	hw->mac.ops.check_link(hw, &speed, &link_up, FALSE);
   1032       1.1  msaitoh 	if (link_up == FALSE) {
   1033       1.1  msaitoh 		macc_reg = IXGBE_READ_REG(hw, IXGBE_MACC);
   1034       1.1  msaitoh 		macc_reg |= IXGBE_MACC_FLU | IXGBE_MACC_FSV_10G | IXGBE_MACC_FS;
   1035       1.1  msaitoh 		IXGBE_WRITE_REG(hw, IXGBE_MACC, macc_reg);
   1036       1.1  msaitoh 	}
   1037       1.1  msaitoh 	/* Set the LED to LINK_UP + BLINK. */
   1038       1.1  msaitoh 	ledctl_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
   1039       1.1  msaitoh 	ledctl_reg &= ~IXGBE_LED_MODE_MASK(index);
   1040       1.1  msaitoh 	ledctl_reg |= IXGBE_LED_BLINK(index);
   1041       1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, ledctl_reg);
   1042       1.1  msaitoh 	IXGBE_WRITE_FLUSH(hw);
   1043       1.1  msaitoh 
   1044       1.1  msaitoh 	return IXGBE_SUCCESS;
   1045       1.1  msaitoh }
   1046       1.1  msaitoh 
   1047       1.1  msaitoh /**
   1048       1.1  msaitoh  * ixgbe_blink_led_stop_X540 - Stop blinking LED based on index.
   1049       1.1  msaitoh  * @hw: pointer to hardware structure
   1050       1.1  msaitoh  * @index: led number to stop blinking
   1051       1.1  msaitoh  *
   1052       1.1  msaitoh  * Devices that implement the version 2 interface:
   1053  1.16.8.3   martin  *  X540
   1054       1.1  msaitoh  **/
   1055       1.1  msaitoh s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw *hw, u32 index)
   1056       1.1  msaitoh {
   1057       1.1  msaitoh 	u32 macc_reg;
   1058       1.1  msaitoh 	u32 ledctl_reg;
   1059       1.1  msaitoh 
   1060      1.10  msaitoh 	if (index > 3)
   1061      1.10  msaitoh 		return IXGBE_ERR_PARAM;
   1062      1.10  msaitoh 
   1063       1.1  msaitoh 	DEBUGFUNC("ixgbe_blink_led_stop_X540");
   1064       1.1  msaitoh 
   1065       1.1  msaitoh 	/* Restore the LED to its default value. */
   1066       1.1  msaitoh 	ledctl_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
   1067       1.1  msaitoh 	ledctl_reg &= ~IXGBE_LED_MODE_MASK(index);
   1068       1.1  msaitoh 	ledctl_reg |= IXGBE_LED_LINK_ACTIVE << IXGBE_LED_MODE_SHIFT(index);
   1069       1.1  msaitoh 	ledctl_reg &= ~IXGBE_LED_BLINK(index);
   1070       1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, ledctl_reg);
   1071       1.1  msaitoh 
   1072       1.1  msaitoh 	/* Unforce link and speed in the MAC. */
   1073       1.1  msaitoh 	macc_reg = IXGBE_READ_REG(hw, IXGBE_MACC);
   1074       1.1  msaitoh 	macc_reg &= ~(IXGBE_MACC_FLU | IXGBE_MACC_FSV_10G | IXGBE_MACC_FS);
   1075       1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_MACC, macc_reg);
   1076       1.1  msaitoh 	IXGBE_WRITE_FLUSH(hw);
   1077       1.1  msaitoh 
   1078       1.1  msaitoh 	return IXGBE_SUCCESS;
   1079       1.1  msaitoh }
   1080