Home | History | Annotate | Line # | Download | only in ixgbe
ixgbe_82598.c revision 1.1.12.1
      1  1.1.12.1  jdolecek /* $NetBSD: ixgbe_82598.c,v 1.1.12.1 2017/12/03 11:37:29 jdolecek Exp $ */
      2  1.1.12.1  jdolecek 
      3       1.1    dyoung /******************************************************************************
      4       1.1    dyoung 
      5  1.1.12.1  jdolecek   Copyright (c) 2001-2017, Intel Corporation
      6       1.1    dyoung   All rights reserved.
      7  1.1.12.1  jdolecek 
      8  1.1.12.1  jdolecek   Redistribution and use in source and binary forms, with or without
      9       1.1    dyoung   modification, are permitted provided that the following conditions are met:
     10  1.1.12.1  jdolecek 
     11  1.1.12.1  jdolecek    1. Redistributions of source code must retain the above copyright notice,
     12       1.1    dyoung       this list of conditions and the following disclaimer.
     13  1.1.12.1  jdolecek 
     14  1.1.12.1  jdolecek    2. Redistributions in binary form must reproduce the above copyright
     15  1.1.12.1  jdolecek       notice, this list of conditions and the following disclaimer in the
     16       1.1    dyoung       documentation and/or other materials provided with the distribution.
     17  1.1.12.1  jdolecek 
     18  1.1.12.1  jdolecek    3. Neither the name of the Intel Corporation nor the names of its
     19  1.1.12.1  jdolecek       contributors may be used to endorse or promote products derived from
     20       1.1    dyoung       this software without specific prior written permission.
     21  1.1.12.1  jdolecek 
     22       1.1    dyoung   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     23  1.1.12.1  jdolecek   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  1.1.12.1  jdolecek   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  1.1.12.1  jdolecek   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     26  1.1.12.1  jdolecek   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27  1.1.12.1  jdolecek   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28  1.1.12.1  jdolecek   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29  1.1.12.1  jdolecek   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30  1.1.12.1  jdolecek   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31       1.1    dyoung   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32       1.1    dyoung   POSSIBILITY OF SUCH DAMAGE.
     33       1.1    dyoung 
     34       1.1    dyoung ******************************************************************************/
     35  1.1.12.1  jdolecek /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_82598.c 320688 2017-07-05 17:27:03Z erj $*/
     36       1.1    dyoung 
     37       1.1    dyoung #include "ixgbe_type.h"
     38  1.1.12.1  jdolecek #include "ixgbe_82598.h"
     39       1.1    dyoung #include "ixgbe_api.h"
     40       1.1    dyoung #include "ixgbe_common.h"
     41       1.1    dyoung #include "ixgbe_phy.h"
     42       1.1    dyoung 
     43  1.1.12.1  jdolecek #define IXGBE_82598_MAX_TX_QUEUES 32
     44  1.1.12.1  jdolecek #define IXGBE_82598_MAX_RX_QUEUES 64
     45  1.1.12.1  jdolecek #define IXGBE_82598_RAR_ENTRIES   16
     46  1.1.12.1  jdolecek #define IXGBE_82598_MC_TBL_SIZE  128
     47  1.1.12.1  jdolecek #define IXGBE_82598_VFT_TBL_SIZE 128
     48  1.1.12.1  jdolecek #define IXGBE_82598_RX_PB_SIZE   512
     49  1.1.12.1  jdolecek 
     50       1.1    dyoung static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
     51  1.1.12.1  jdolecek 					     ixgbe_link_speed *speed,
     52  1.1.12.1  jdolecek 					     bool *autoneg);
     53       1.1    dyoung static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw);
     54       1.1    dyoung static s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw,
     55  1.1.12.1  jdolecek 				      bool autoneg_wait_to_complete);
     56       1.1    dyoung static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
     57  1.1.12.1  jdolecek 				      ixgbe_link_speed *speed, bool *link_up,
     58  1.1.12.1  jdolecek 				      bool link_up_wait_to_complete);
     59       1.1    dyoung static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
     60  1.1.12.1  jdolecek 				      ixgbe_link_speed speed,
     61  1.1.12.1  jdolecek 				      bool autoneg_wait_to_complete);
     62       1.1    dyoung static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
     63  1.1.12.1  jdolecek 					 ixgbe_link_speed speed,
     64  1.1.12.1  jdolecek 					 bool autoneg_wait_to_complete);
     65       1.1    dyoung static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw);
     66       1.1    dyoung static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
     67       1.1    dyoung static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw);
     68  1.1.12.1  jdolecek static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb,
     69  1.1.12.1  jdolecek 				  u32 headroom, int strategy);
     70  1.1.12.1  jdolecek static s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset,
     71  1.1.12.1  jdolecek 					u8 *sff8472_data);
     72       1.1    dyoung /**
     73       1.1    dyoung  *  ixgbe_set_pcie_completion_timeout - set pci-e completion timeout
     74       1.1    dyoung  *  @hw: pointer to the HW structure
     75       1.1    dyoung  *
     76       1.1    dyoung  *  The defaults for 82598 should be in the range of 50us to 50ms,
     77       1.1    dyoung  *  however the hardware default for these parts is 500us to 1ms which is less
     78       1.1    dyoung  *  than the 10ms recommended by the pci-e spec.  To address this we need to
     79       1.1    dyoung  *  increase the value to either 10ms to 250ms for capability version 1 config,
     80       1.1    dyoung  *  or 16ms to 55ms for version 2.
     81       1.1    dyoung  **/
     82       1.1    dyoung void ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw)
     83       1.1    dyoung {
     84       1.1    dyoung 	u32 gcr = IXGBE_READ_REG(hw, IXGBE_GCR);
     85       1.1    dyoung 	u16 pcie_devctl2;
     86       1.1    dyoung 
     87       1.1    dyoung 	/* only take action if timeout value is defaulted to 0 */
     88       1.1    dyoung 	if (gcr & IXGBE_GCR_CMPL_TMOUT_MASK)
     89       1.1    dyoung 		goto out;
     90       1.1    dyoung 
     91       1.1    dyoung 	/*
     92       1.1    dyoung 	 * if capababilities version is type 1 we can write the
     93       1.1    dyoung 	 * timeout of 10ms to 250ms through the GCR register
     94       1.1    dyoung 	 */
     95       1.1    dyoung 	if (!(gcr & IXGBE_GCR_CAP_VER2)) {
     96       1.1    dyoung 		gcr |= IXGBE_GCR_CMPL_TMOUT_10ms;
     97       1.1    dyoung 		goto out;
     98       1.1    dyoung 	}
     99       1.1    dyoung 
    100       1.1    dyoung 	/*
    101       1.1    dyoung 	 * for version 2 capabilities we need to write the config space
    102       1.1    dyoung 	 * directly in order to set the completion timeout value for
    103       1.1    dyoung 	 * 16ms to 55ms
    104       1.1    dyoung 	 */
    105       1.1    dyoung 	pcie_devctl2 = IXGBE_READ_PCIE_WORD(hw, IXGBE_PCI_DEVICE_CONTROL2);
    106       1.1    dyoung 	pcie_devctl2 |= IXGBE_PCI_DEVICE_CONTROL2_16ms;
    107       1.1    dyoung 	IXGBE_WRITE_PCIE_WORD(hw, IXGBE_PCI_DEVICE_CONTROL2, pcie_devctl2);
    108       1.1    dyoung out:
    109       1.1    dyoung 	/* disable completion timeout resend */
    110       1.1    dyoung 	gcr &= ~IXGBE_GCR_CMPL_TMOUT_RESEND;
    111       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_GCR, gcr);
    112       1.1    dyoung }
    113       1.1    dyoung 
    114       1.1    dyoung /**
    115       1.1    dyoung  *  ixgbe_init_ops_82598 - Inits func ptrs and MAC type
    116       1.1    dyoung  *  @hw: pointer to hardware structure
    117       1.1    dyoung  *
    118       1.1    dyoung  *  Initialize the function pointers and assign the MAC type for 82598.
    119       1.1    dyoung  *  Does not touch the hardware.
    120       1.1    dyoung  **/
    121       1.1    dyoung s32 ixgbe_init_ops_82598(struct ixgbe_hw *hw)
    122       1.1    dyoung {
    123       1.1    dyoung 	struct ixgbe_mac_info *mac = &hw->mac;
    124       1.1    dyoung 	struct ixgbe_phy_info *phy = &hw->phy;
    125       1.1    dyoung 	s32 ret_val;
    126       1.1    dyoung 
    127       1.1    dyoung 	DEBUGFUNC("ixgbe_init_ops_82598");
    128       1.1    dyoung 
    129       1.1    dyoung 	ret_val = ixgbe_init_phy_ops_generic(hw);
    130       1.1    dyoung 	ret_val = ixgbe_init_ops_generic(hw);
    131       1.1    dyoung 
    132       1.1    dyoung 	/* PHY */
    133  1.1.12.1  jdolecek 	phy->ops.init = ixgbe_init_phy_ops_82598;
    134       1.1    dyoung 
    135       1.1    dyoung 	/* MAC */
    136  1.1.12.1  jdolecek 	mac->ops.start_hw = ixgbe_start_hw_82598;
    137  1.1.12.1  jdolecek 	mac->ops.enable_relaxed_ordering = ixgbe_enable_relaxed_ordering_82598;
    138  1.1.12.1  jdolecek 	mac->ops.reset_hw = ixgbe_reset_hw_82598;
    139  1.1.12.1  jdolecek 	mac->ops.get_media_type = ixgbe_get_media_type_82598;
    140       1.1    dyoung 	mac->ops.get_supported_physical_layer =
    141  1.1.12.1  jdolecek 				ixgbe_get_supported_physical_layer_82598;
    142  1.1.12.1  jdolecek 	mac->ops.read_analog_reg8 = ixgbe_read_analog_reg8_82598;
    143  1.1.12.1  jdolecek 	mac->ops.write_analog_reg8 = ixgbe_write_analog_reg8_82598;
    144  1.1.12.1  jdolecek 	mac->ops.set_lan_id = ixgbe_set_lan_id_multi_port_pcie_82598;
    145  1.1.12.1  jdolecek 	mac->ops.enable_rx_dma = ixgbe_enable_rx_dma_82598;
    146       1.1    dyoung 
    147       1.1    dyoung 	/* RAR, Multicast, VLAN */
    148  1.1.12.1  jdolecek 	mac->ops.set_vmdq = ixgbe_set_vmdq_82598;
    149  1.1.12.1  jdolecek 	mac->ops.clear_vmdq = ixgbe_clear_vmdq_82598;
    150  1.1.12.1  jdolecek 	mac->ops.set_vfta = ixgbe_set_vfta_82598;
    151  1.1.12.1  jdolecek 	mac->ops.set_vlvf = NULL;
    152  1.1.12.1  jdolecek 	mac->ops.clear_vfta = ixgbe_clear_vfta_82598;
    153       1.1    dyoung 
    154       1.1    dyoung 	/* Flow Control */
    155  1.1.12.1  jdolecek 	mac->ops.fc_enable = ixgbe_fc_enable_82598;
    156       1.1    dyoung 
    157  1.1.12.1  jdolecek 	mac->mcft_size		= IXGBE_82598_MC_TBL_SIZE;
    158  1.1.12.1  jdolecek 	mac->vft_size		= IXGBE_82598_VFT_TBL_SIZE;
    159  1.1.12.1  jdolecek 	mac->num_rar_entries	= IXGBE_82598_RAR_ENTRIES;
    160  1.1.12.1  jdolecek 	mac->rx_pb_size		= IXGBE_82598_RX_PB_SIZE;
    161  1.1.12.1  jdolecek 	mac->max_rx_queues	= IXGBE_82598_MAX_RX_QUEUES;
    162  1.1.12.1  jdolecek 	mac->max_tx_queues	= IXGBE_82598_MAX_TX_QUEUES;
    163  1.1.12.1  jdolecek 	mac->max_msix_vectors	= ixgbe_get_pcie_msix_count_generic(hw);
    164       1.1    dyoung 
    165       1.1    dyoung 	/* SFP+ Module */
    166  1.1.12.1  jdolecek 	phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_82598;
    167  1.1.12.1  jdolecek 	phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_82598;
    168       1.1    dyoung 
    169       1.1    dyoung 	/* Link */
    170  1.1.12.1  jdolecek 	mac->ops.check_link = ixgbe_check_mac_link_82598;
    171  1.1.12.1  jdolecek 	mac->ops.setup_link = ixgbe_setup_mac_link_82598;
    172       1.1    dyoung 	mac->ops.flap_tx_laser = NULL;
    173  1.1.12.1  jdolecek 	mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_82598;
    174  1.1.12.1  jdolecek 	mac->ops.setup_rxpba = ixgbe_set_rxpba_82598;
    175  1.1.12.1  jdolecek 
    176  1.1.12.1  jdolecek 	/* Manageability interface */
    177  1.1.12.1  jdolecek 	mac->ops.set_fw_drv_ver = NULL;
    178  1.1.12.1  jdolecek 
    179  1.1.12.1  jdolecek 	mac->ops.get_rtrup2tc = NULL;
    180       1.1    dyoung 
    181       1.1    dyoung 	return ret_val;
    182       1.1    dyoung }
    183       1.1    dyoung 
    184       1.1    dyoung /**
    185       1.1    dyoung  *  ixgbe_init_phy_ops_82598 - PHY/SFP specific init
    186       1.1    dyoung  *  @hw: pointer to hardware structure
    187       1.1    dyoung  *
    188       1.1    dyoung  *  Initialize any function pointers that were not able to be
    189       1.1    dyoung  *  set during init_shared_code because the PHY/SFP type was
    190       1.1    dyoung  *  not known.  Perform the SFP init if necessary.
    191       1.1    dyoung  *
    192       1.1    dyoung  **/
    193       1.1    dyoung s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
    194       1.1    dyoung {
    195       1.1    dyoung 	struct ixgbe_mac_info *mac = &hw->mac;
    196       1.1    dyoung 	struct ixgbe_phy_info *phy = &hw->phy;
    197       1.1    dyoung 	s32 ret_val = IXGBE_SUCCESS;
    198       1.1    dyoung 	u16 list_offset, data_offset;
    199       1.1    dyoung 
    200       1.1    dyoung 	DEBUGFUNC("ixgbe_init_phy_ops_82598");
    201       1.1    dyoung 
    202       1.1    dyoung 	/* Identify the PHY */
    203       1.1    dyoung 	phy->ops.identify(hw);
    204       1.1    dyoung 
    205       1.1    dyoung 	/* Overwrite the link function pointers if copper PHY */
    206       1.1    dyoung 	if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
    207  1.1.12.1  jdolecek 		mac->ops.setup_link = ixgbe_setup_copper_link_82598;
    208       1.1    dyoung 		mac->ops.get_link_capabilities =
    209  1.1.12.1  jdolecek 				ixgbe_get_copper_link_capabilities_generic;
    210       1.1    dyoung 	}
    211       1.1    dyoung 
    212       1.1    dyoung 	switch (hw->phy.type) {
    213       1.1    dyoung 	case ixgbe_phy_tn:
    214  1.1.12.1  jdolecek 		phy->ops.setup_link = ixgbe_setup_phy_link_tnx;
    215  1.1.12.1  jdolecek 		phy->ops.check_link = ixgbe_check_phy_link_tnx;
    216       1.1    dyoung 		phy->ops.get_firmware_version =
    217  1.1.12.1  jdolecek 					ixgbe_get_phy_firmware_version_tnx;
    218       1.1    dyoung 		break;
    219       1.1    dyoung 	case ixgbe_phy_nl:
    220  1.1.12.1  jdolecek 		phy->ops.reset = ixgbe_reset_phy_nl;
    221       1.1    dyoung 
    222       1.1    dyoung 		/* Call SFP+ identify routine to get the SFP+ module type */
    223       1.1    dyoung 		ret_val = phy->ops.identify_sfp(hw);
    224       1.1    dyoung 		if (ret_val != IXGBE_SUCCESS)
    225       1.1    dyoung 			goto out;
    226       1.1    dyoung 		else if (hw->phy.sfp_type == ixgbe_sfp_type_unknown) {
    227       1.1    dyoung 			ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
    228       1.1    dyoung 			goto out;
    229       1.1    dyoung 		}
    230       1.1    dyoung 
    231       1.1    dyoung 		/* Check to see if SFP+ module is supported */
    232       1.1    dyoung 		ret_val = ixgbe_get_sfp_init_sequence_offsets(hw,
    233  1.1.12.1  jdolecek 							      &list_offset,
    234  1.1.12.1  jdolecek 							      &data_offset);
    235       1.1    dyoung 		if (ret_val != IXGBE_SUCCESS) {
    236       1.1    dyoung 			ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
    237       1.1    dyoung 			goto out;
    238       1.1    dyoung 		}
    239       1.1    dyoung 		break;
    240       1.1    dyoung 	default:
    241       1.1    dyoung 		break;
    242       1.1    dyoung 	}
    243       1.1    dyoung 
    244       1.1    dyoung out:
    245       1.1    dyoung 	return ret_val;
    246       1.1    dyoung }
    247       1.1    dyoung 
    248       1.1    dyoung /**
    249       1.1    dyoung  *  ixgbe_start_hw_82598 - Prepare hardware for Tx/Rx
    250       1.1    dyoung  *  @hw: pointer to hardware structure
    251       1.1    dyoung  *
    252       1.1    dyoung  *  Starts the hardware using the generic start_hw function.
    253       1.1    dyoung  *  Disables relaxed ordering Then set pcie completion timeout
    254       1.1    dyoung  *
    255       1.1    dyoung  **/
    256       1.1    dyoung s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
    257       1.1    dyoung {
    258       1.1    dyoung 	u32 regval;
    259       1.1    dyoung 	u32 i;
    260       1.1    dyoung 	s32 ret_val = IXGBE_SUCCESS;
    261       1.1    dyoung 
    262       1.1    dyoung 	DEBUGFUNC("ixgbe_start_hw_82598");
    263       1.1    dyoung 
    264       1.1    dyoung 	ret_val = ixgbe_start_hw_generic(hw);
    265  1.1.12.1  jdolecek 	if (ret_val)
    266  1.1.12.1  jdolecek 		return ret_val;
    267       1.1    dyoung 
    268       1.1    dyoung 	/* Disable relaxed ordering */
    269       1.1    dyoung 	for (i = 0; ((i < hw->mac.max_tx_queues) &&
    270       1.1    dyoung 	     (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
    271       1.1    dyoung 		regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i));
    272  1.1.12.1  jdolecek 		regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
    273       1.1    dyoung 		IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval);
    274       1.1    dyoung 	}
    275       1.1    dyoung 
    276       1.1    dyoung 	for (i = 0; ((i < hw->mac.max_rx_queues) &&
    277       1.1    dyoung 	     (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
    278       1.1    dyoung 		regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i));
    279  1.1.12.1  jdolecek 		regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN |
    280  1.1.12.1  jdolecek 			    IXGBE_DCA_RXCTRL_HEAD_WRO_EN);
    281       1.1    dyoung 		IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
    282       1.1    dyoung 	}
    283       1.1    dyoung 
    284       1.1    dyoung 	/* set the completion timeout for interface */
    285  1.1.12.1  jdolecek 	ixgbe_set_pcie_completion_timeout(hw);
    286       1.1    dyoung 
    287       1.1    dyoung 	return ret_val;
    288       1.1    dyoung }
    289       1.1    dyoung 
    290       1.1    dyoung /**
    291       1.1    dyoung  *  ixgbe_get_link_capabilities_82598 - Determines link capabilities
    292       1.1    dyoung  *  @hw: pointer to hardware structure
    293       1.1    dyoung  *  @speed: pointer to link speed
    294       1.1    dyoung  *  @autoneg: boolean auto-negotiation value
    295       1.1    dyoung  *
    296       1.1    dyoung  *  Determines the link capabilities by reading the AUTOC register.
    297       1.1    dyoung  **/
    298       1.1    dyoung static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
    299  1.1.12.1  jdolecek 					     ixgbe_link_speed *speed,
    300  1.1.12.1  jdolecek 					     bool *autoneg)
    301       1.1    dyoung {
    302       1.1    dyoung 	s32 status = IXGBE_SUCCESS;
    303       1.1    dyoung 	u32 autoc = 0;
    304       1.1    dyoung 
    305       1.1    dyoung 	DEBUGFUNC("ixgbe_get_link_capabilities_82598");
    306       1.1    dyoung 
    307       1.1    dyoung 	/*
    308       1.1    dyoung 	 * Determine link capabilities based on the stored value of AUTOC,
    309       1.1    dyoung 	 * which represents EEPROM defaults.  If AUTOC value has not been
    310       1.1    dyoung 	 * stored, use the current register value.
    311       1.1    dyoung 	 */
    312       1.1    dyoung 	if (hw->mac.orig_link_settings_stored)
    313       1.1    dyoung 		autoc = hw->mac.orig_autoc;
    314       1.1    dyoung 	else
    315       1.1    dyoung 		autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
    316       1.1    dyoung 
    317       1.1    dyoung 	switch (autoc & IXGBE_AUTOC_LMS_MASK) {
    318       1.1    dyoung 	case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
    319       1.1    dyoung 		*speed = IXGBE_LINK_SPEED_1GB_FULL;
    320       1.1    dyoung 		*autoneg = FALSE;
    321       1.1    dyoung 		break;
    322       1.1    dyoung 
    323       1.1    dyoung 	case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
    324       1.1    dyoung 		*speed = IXGBE_LINK_SPEED_10GB_FULL;
    325       1.1    dyoung 		*autoneg = FALSE;
    326       1.1    dyoung 		break;
    327       1.1    dyoung 
    328       1.1    dyoung 	case IXGBE_AUTOC_LMS_1G_AN:
    329       1.1    dyoung 		*speed = IXGBE_LINK_SPEED_1GB_FULL;
    330       1.1    dyoung 		*autoneg = TRUE;
    331       1.1    dyoung 		break;
    332       1.1    dyoung 
    333       1.1    dyoung 	case IXGBE_AUTOC_LMS_KX4_AN:
    334       1.1    dyoung 	case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
    335       1.1    dyoung 		*speed = IXGBE_LINK_SPEED_UNKNOWN;
    336       1.1    dyoung 		if (autoc & IXGBE_AUTOC_KX4_SUPP)
    337       1.1    dyoung 			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
    338       1.1    dyoung 		if (autoc & IXGBE_AUTOC_KX_SUPP)
    339       1.1    dyoung 			*speed |= IXGBE_LINK_SPEED_1GB_FULL;
    340       1.1    dyoung 		*autoneg = TRUE;
    341       1.1    dyoung 		break;
    342       1.1    dyoung 
    343       1.1    dyoung 	default:
    344       1.1    dyoung 		status = IXGBE_ERR_LINK_SETUP;
    345       1.1    dyoung 		break;
    346       1.1    dyoung 	}
    347       1.1    dyoung 
    348       1.1    dyoung 	return status;
    349       1.1    dyoung }
    350       1.1    dyoung 
    351       1.1    dyoung /**
    352       1.1    dyoung  *  ixgbe_get_media_type_82598 - Determines media type
    353       1.1    dyoung  *  @hw: pointer to hardware structure
    354       1.1    dyoung  *
    355       1.1    dyoung  *  Returns the media type (fiber, copper, backplane)
    356       1.1    dyoung  **/
    357       1.1    dyoung static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
    358       1.1    dyoung {
    359       1.1    dyoung 	enum ixgbe_media_type media_type;
    360       1.1    dyoung 
    361       1.1    dyoung 	DEBUGFUNC("ixgbe_get_media_type_82598");
    362       1.1    dyoung 
    363       1.1    dyoung 	/* Detect if there is a copper PHY attached. */
    364       1.1    dyoung 	switch (hw->phy.type) {
    365       1.1    dyoung 	case ixgbe_phy_cu_unknown:
    366       1.1    dyoung 	case ixgbe_phy_tn:
    367       1.1    dyoung 		media_type = ixgbe_media_type_copper;
    368       1.1    dyoung 		goto out;
    369       1.1    dyoung 	default:
    370       1.1    dyoung 		break;
    371       1.1    dyoung 	}
    372       1.1    dyoung 
    373       1.1    dyoung 	/* Media type for I82598 is based on device ID */
    374       1.1    dyoung 	switch (hw->device_id) {
    375       1.1    dyoung 	case IXGBE_DEV_ID_82598:
    376       1.1    dyoung 	case IXGBE_DEV_ID_82598_BX:
    377       1.1    dyoung 		/* Default device ID is mezzanine card KX/KX4 */
    378       1.1    dyoung 		media_type = ixgbe_media_type_backplane;
    379       1.1    dyoung 		break;
    380       1.1    dyoung 	case IXGBE_DEV_ID_82598AF_DUAL_PORT:
    381       1.1    dyoung 	case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
    382       1.1    dyoung 	case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
    383       1.1    dyoung 	case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
    384       1.1    dyoung 	case IXGBE_DEV_ID_82598EB_XF_LR:
    385       1.1    dyoung 	case IXGBE_DEV_ID_82598EB_SFP_LOM:
    386       1.1    dyoung 		media_type = ixgbe_media_type_fiber;
    387       1.1    dyoung 		break;
    388       1.1    dyoung 	case IXGBE_DEV_ID_82598EB_CX4:
    389       1.1    dyoung 	case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
    390       1.1    dyoung 		media_type = ixgbe_media_type_cx4;
    391       1.1    dyoung 		break;
    392       1.1    dyoung 	case IXGBE_DEV_ID_82598AT:
    393       1.1    dyoung 	case IXGBE_DEV_ID_82598AT2:
    394       1.1    dyoung 		media_type = ixgbe_media_type_copper;
    395       1.1    dyoung 		break;
    396       1.1    dyoung 	default:
    397       1.1    dyoung 		media_type = ixgbe_media_type_unknown;
    398       1.1    dyoung 		break;
    399       1.1    dyoung 	}
    400       1.1    dyoung out:
    401       1.1    dyoung 	return media_type;
    402       1.1    dyoung }
    403       1.1    dyoung 
    404       1.1    dyoung /**
    405       1.1    dyoung  *  ixgbe_fc_enable_82598 - Enable flow control
    406       1.1    dyoung  *  @hw: pointer to hardware structure
    407       1.1    dyoung  *
    408       1.1    dyoung  *  Enable flow control according to the current settings.
    409       1.1    dyoung  **/
    410  1.1.12.1  jdolecek s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
    411       1.1    dyoung {
    412       1.1    dyoung 	s32 ret_val = IXGBE_SUCCESS;
    413       1.1    dyoung 	u32 fctrl_reg;
    414       1.1    dyoung 	u32 rmcs_reg;
    415       1.1    dyoung 	u32 reg;
    416  1.1.12.1  jdolecek 	u32 fcrtl, fcrth;
    417       1.1    dyoung 	u32 link_speed = 0;
    418  1.1.12.1  jdolecek 	int i;
    419       1.1    dyoung 	bool link_up;
    420       1.1    dyoung 
    421       1.1    dyoung 	DEBUGFUNC("ixgbe_fc_enable_82598");
    422       1.1    dyoung 
    423  1.1.12.1  jdolecek 	/* Validate the water mark configuration */
    424  1.1.12.1  jdolecek 	if (!hw->fc.pause_time) {
    425  1.1.12.1  jdolecek 		ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
    426  1.1.12.1  jdolecek 		goto out;
    427  1.1.12.1  jdolecek 	}
    428  1.1.12.1  jdolecek 
    429  1.1.12.1  jdolecek 	/* Low water mark of zero causes XOFF floods */
    430  1.1.12.1  jdolecek 	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
    431  1.1.12.1  jdolecek 		if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
    432  1.1.12.1  jdolecek 		    hw->fc.high_water[i]) {
    433  1.1.12.1  jdolecek 			if (!hw->fc.low_water[i] ||
    434  1.1.12.1  jdolecek 			    hw->fc.low_water[i] >= hw->fc.high_water[i]) {
    435  1.1.12.1  jdolecek 				DEBUGOUT("Invalid water mark configuration\n");
    436  1.1.12.1  jdolecek 				ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
    437  1.1.12.1  jdolecek 				goto out;
    438  1.1.12.1  jdolecek 			}
    439  1.1.12.1  jdolecek 		}
    440  1.1.12.1  jdolecek 	}
    441  1.1.12.1  jdolecek 
    442       1.1    dyoung 	/*
    443       1.1    dyoung 	 * On 82598 having Rx FC on causes resets while doing 1G
    444       1.1    dyoung 	 * so if it's on turn it off once we know link_speed. For
    445       1.1    dyoung 	 * more details see 82598 Specification update.
    446       1.1    dyoung 	 */
    447       1.1    dyoung 	hw->mac.ops.check_link(hw, &link_speed, &link_up, FALSE);
    448       1.1    dyoung 	if (link_up && link_speed == IXGBE_LINK_SPEED_1GB_FULL) {
    449       1.1    dyoung 		switch (hw->fc.requested_mode) {
    450       1.1    dyoung 		case ixgbe_fc_full:
    451       1.1    dyoung 			hw->fc.requested_mode = ixgbe_fc_tx_pause;
    452       1.1    dyoung 			break;
    453       1.1    dyoung 		case ixgbe_fc_rx_pause:
    454       1.1    dyoung 			hw->fc.requested_mode = ixgbe_fc_none;
    455       1.1    dyoung 			break;
    456       1.1    dyoung 		default:
    457       1.1    dyoung 			/* no change */
    458       1.1    dyoung 			break;
    459       1.1    dyoung 		}
    460       1.1    dyoung 	}
    461       1.1    dyoung 
    462       1.1    dyoung 	/* Negotiate the fc mode to use */
    463  1.1.12.1  jdolecek 	ixgbe_fc_autoneg(hw);
    464       1.1    dyoung 
    465       1.1    dyoung 	/* Disable any previous flow control settings */
    466       1.1    dyoung 	fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);
    467       1.1    dyoung 	fctrl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);
    468       1.1    dyoung 
    469       1.1    dyoung 	rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS);
    470       1.1    dyoung 	rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X);
    471       1.1    dyoung 
    472       1.1    dyoung 	/*
    473       1.1    dyoung 	 * The possible values of fc.current_mode are:
    474       1.1    dyoung 	 * 0: Flow control is completely disabled
    475       1.1    dyoung 	 * 1: Rx flow control is enabled (we can receive pause frames,
    476       1.1    dyoung 	 *    but not send pause frames).
    477       1.1    dyoung 	 * 2: Tx flow control is enabled (we can send pause frames but
    478       1.1    dyoung 	 *     we do not support receiving pause frames).
    479       1.1    dyoung 	 * 3: Both Rx and Tx flow control (symmetric) are enabled.
    480       1.1    dyoung 	 * other: Invalid.
    481       1.1    dyoung 	 */
    482       1.1    dyoung 	switch (hw->fc.current_mode) {
    483       1.1    dyoung 	case ixgbe_fc_none:
    484       1.1    dyoung 		/*
    485       1.1    dyoung 		 * Flow control is disabled by software override or autoneg.
    486       1.1    dyoung 		 * The code below will actually disable it in the HW.
    487       1.1    dyoung 		 */
    488       1.1    dyoung 		break;
    489       1.1    dyoung 	case ixgbe_fc_rx_pause:
    490       1.1    dyoung 		/*
    491       1.1    dyoung 		 * Rx Flow control is enabled and Tx Flow control is
    492       1.1    dyoung 		 * disabled by software override. Since there really
    493       1.1    dyoung 		 * isn't a way to advertise that we are capable of RX
    494       1.1    dyoung 		 * Pause ONLY, we will advertise that we support both
    495       1.1    dyoung 		 * symmetric and asymmetric Rx PAUSE.  Later, we will
    496       1.1    dyoung 		 * disable the adapter's ability to send PAUSE frames.
    497       1.1    dyoung 		 */
    498       1.1    dyoung 		fctrl_reg |= IXGBE_FCTRL_RFCE;
    499       1.1    dyoung 		break;
    500       1.1    dyoung 	case ixgbe_fc_tx_pause:
    501       1.1    dyoung 		/*
    502       1.1    dyoung 		 * Tx Flow control is enabled, and Rx Flow control is
    503       1.1    dyoung 		 * disabled by software override.
    504       1.1    dyoung 		 */
    505       1.1    dyoung 		rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
    506       1.1    dyoung 		break;
    507       1.1    dyoung 	case ixgbe_fc_full:
    508       1.1    dyoung 		/* Flow control (both Rx and Tx) is enabled by SW override. */
    509       1.1    dyoung 		fctrl_reg |= IXGBE_FCTRL_RFCE;
    510       1.1    dyoung 		rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
    511       1.1    dyoung 		break;
    512       1.1    dyoung 	default:
    513       1.1    dyoung 		DEBUGOUT("Flow control param set incorrectly\n");
    514       1.1    dyoung 		ret_val = IXGBE_ERR_CONFIG;
    515       1.1    dyoung 		goto out;
    516       1.1    dyoung 		break;
    517       1.1    dyoung 	}
    518       1.1    dyoung 
    519       1.1    dyoung 	/* Set 802.3x based flow control settings. */
    520       1.1    dyoung 	fctrl_reg |= IXGBE_FCTRL_DPF;
    521       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg);
    522       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
    523       1.1    dyoung 
    524       1.1    dyoung 	/* Set up and enable Rx high/low water mark thresholds, enable XON. */
    525  1.1.12.1  jdolecek 	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
    526  1.1.12.1  jdolecek 		if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
    527  1.1.12.1  jdolecek 		    hw->fc.high_water[i]) {
    528  1.1.12.1  jdolecek 			fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;
    529  1.1.12.1  jdolecek 			fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;
    530  1.1.12.1  jdolecek 			IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl);
    531  1.1.12.1  jdolecek 			IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), fcrth);
    532  1.1.12.1  jdolecek 		} else {
    533  1.1.12.1  jdolecek 			IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), 0);
    534  1.1.12.1  jdolecek 			IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), 0);
    535  1.1.12.1  jdolecek 		}
    536       1.1    dyoung 
    537       1.1    dyoung 	}
    538       1.1    dyoung 
    539       1.1    dyoung 	/* Configure pause time (2 TCs per register) */
    540  1.1.12.1  jdolecek 	reg = hw->fc.pause_time * 0x00010001;
    541  1.1.12.1  jdolecek 	for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
    542  1.1.12.1  jdolecek 		IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
    543       1.1    dyoung 
    544  1.1.12.1  jdolecek 	/* Configure flow control refresh threshold value */
    545  1.1.12.1  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
    546       1.1    dyoung 
    547       1.1    dyoung out:
    548       1.1    dyoung 	return ret_val;
    549       1.1    dyoung }
    550       1.1    dyoung 
    551       1.1    dyoung /**
    552       1.1    dyoung  *  ixgbe_start_mac_link_82598 - Configures MAC link settings
    553       1.1    dyoung  *  @hw: pointer to hardware structure
    554       1.1    dyoung  *
    555       1.1    dyoung  *  Configures link settings based on values in the ixgbe_hw struct.
    556       1.1    dyoung  *  Restarts the link.  Performs autonegotiation if needed.
    557       1.1    dyoung  **/
    558       1.1    dyoung static s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw,
    559  1.1.12.1  jdolecek 				      bool autoneg_wait_to_complete)
    560       1.1    dyoung {
    561       1.1    dyoung 	u32 autoc_reg;
    562       1.1    dyoung 	u32 links_reg;
    563       1.1    dyoung 	u32 i;
    564       1.1    dyoung 	s32 status = IXGBE_SUCCESS;
    565       1.1    dyoung 
    566       1.1    dyoung 	DEBUGFUNC("ixgbe_start_mac_link_82598");
    567       1.1    dyoung 
    568       1.1    dyoung 	/* Restart link */
    569       1.1    dyoung 	autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
    570       1.1    dyoung 	autoc_reg |= IXGBE_AUTOC_AN_RESTART;
    571       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
    572       1.1    dyoung 
    573       1.1    dyoung 	/* Only poll for autoneg to complete if specified to do so */
    574       1.1    dyoung 	if (autoneg_wait_to_complete) {
    575       1.1    dyoung 		if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
    576       1.1    dyoung 		     IXGBE_AUTOC_LMS_KX4_AN ||
    577       1.1    dyoung 		    (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
    578       1.1    dyoung 		     IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {
    579       1.1    dyoung 			links_reg = 0; /* Just in case Autoneg time = 0 */
    580       1.1    dyoung 			for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
    581       1.1    dyoung 				links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
    582       1.1    dyoung 				if (links_reg & IXGBE_LINKS_KX_AN_COMP)
    583       1.1    dyoung 					break;
    584       1.1    dyoung 				msec_delay(100);
    585       1.1    dyoung 			}
    586       1.1    dyoung 			if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
    587       1.1    dyoung 				status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
    588       1.1    dyoung 				DEBUGOUT("Autonegotiation did not complete.\n");
    589       1.1    dyoung 			}
    590       1.1    dyoung 		}
    591       1.1    dyoung 	}
    592       1.1    dyoung 
    593       1.1    dyoung 	/* Add delay to filter out noises during initial link setup */
    594       1.1    dyoung 	msec_delay(50);
    595       1.1    dyoung 
    596       1.1    dyoung 	return status;
    597       1.1    dyoung }
    598       1.1    dyoung 
    599       1.1    dyoung /**
    600       1.1    dyoung  *  ixgbe_validate_link_ready - Function looks for phy link
    601       1.1    dyoung  *  @hw: pointer to hardware structure
    602       1.1    dyoung  *
    603       1.1    dyoung  *  Function indicates success when phy link is available. If phy is not ready
    604       1.1    dyoung  *  within 5 seconds of MAC indicating link, the function returns error.
    605       1.1    dyoung  **/
    606       1.1    dyoung static s32 ixgbe_validate_link_ready(struct ixgbe_hw *hw)
    607       1.1    dyoung {
    608       1.1    dyoung 	u32 timeout;
    609       1.1    dyoung 	u16 an_reg;
    610       1.1    dyoung 
    611       1.1    dyoung 	if (hw->device_id != IXGBE_DEV_ID_82598AT2)
    612       1.1    dyoung 		return IXGBE_SUCCESS;
    613       1.1    dyoung 
    614       1.1    dyoung 	for (timeout = 0;
    615       1.1    dyoung 	     timeout < IXGBE_VALIDATE_LINK_READY_TIMEOUT; timeout++) {
    616       1.1    dyoung 		hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
    617  1.1.12.1  jdolecek 				     IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &an_reg);
    618       1.1    dyoung 
    619       1.1    dyoung 		if ((an_reg & IXGBE_MII_AUTONEG_COMPLETE) &&
    620       1.1    dyoung 		    (an_reg & IXGBE_MII_AUTONEG_LINK_UP))
    621       1.1    dyoung 			break;
    622       1.1    dyoung 
    623       1.1    dyoung 		msec_delay(100);
    624       1.1    dyoung 	}
    625       1.1    dyoung 
    626       1.1    dyoung 	if (timeout == IXGBE_VALIDATE_LINK_READY_TIMEOUT) {
    627       1.1    dyoung 		DEBUGOUT("Link was indicated but link is down\n");
    628       1.1    dyoung 		return IXGBE_ERR_LINK_SETUP;
    629       1.1    dyoung 	}
    630       1.1    dyoung 
    631       1.1    dyoung 	return IXGBE_SUCCESS;
    632       1.1    dyoung }
    633       1.1    dyoung 
    634       1.1    dyoung /**
    635       1.1    dyoung  *  ixgbe_check_mac_link_82598 - Get link/speed status
    636       1.1    dyoung  *  @hw: pointer to hardware structure
    637       1.1    dyoung  *  @speed: pointer to link speed
    638       1.1    dyoung  *  @link_up: TRUE is link is up, FALSE otherwise
    639       1.1    dyoung  *  @link_up_wait_to_complete: bool used to wait for link up or not
    640       1.1    dyoung  *
    641       1.1    dyoung  *  Reads the links register to determine if link is up and the current speed
    642       1.1    dyoung  **/
    643       1.1    dyoung static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
    644  1.1.12.1  jdolecek 				      ixgbe_link_speed *speed, bool *link_up,
    645  1.1.12.1  jdolecek 				      bool link_up_wait_to_complete)
    646       1.1    dyoung {
    647       1.1    dyoung 	u32 links_reg;
    648       1.1    dyoung 	u32 i;
    649       1.1    dyoung 	u16 link_reg, adapt_comp_reg;
    650       1.1    dyoung 
    651       1.1    dyoung 	DEBUGFUNC("ixgbe_check_mac_link_82598");
    652       1.1    dyoung 
    653       1.1    dyoung 	/*
    654       1.1    dyoung 	 * SERDES PHY requires us to read link status from undocumented
    655       1.1    dyoung 	 * register 0xC79F.  Bit 0 set indicates link is up/ready; clear
    656       1.1    dyoung 	 * indicates link down.  OxC00C is read to check that the XAUI lanes
    657       1.1    dyoung 	 * are active.  Bit 0 clear indicates active; set indicates inactive.
    658       1.1    dyoung 	 */
    659       1.1    dyoung 	if (hw->phy.type == ixgbe_phy_nl) {
    660       1.1    dyoung 		hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg);
    661       1.1    dyoung 		hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg);
    662       1.1    dyoung 		hw->phy.ops.read_reg(hw, 0xC00C, IXGBE_TWINAX_DEV,
    663  1.1.12.1  jdolecek 				     &adapt_comp_reg);
    664       1.1    dyoung 		if (link_up_wait_to_complete) {
    665  1.1.12.1  jdolecek 			for (i = 0; i < hw->mac.max_link_up_time; i++) {
    666       1.1    dyoung 				if ((link_reg & 1) &&
    667       1.1    dyoung 				    ((adapt_comp_reg & 1) == 0)) {
    668       1.1    dyoung 					*link_up = TRUE;
    669       1.1    dyoung 					break;
    670       1.1    dyoung 				} else {
    671       1.1    dyoung 					*link_up = FALSE;
    672       1.1    dyoung 				}
    673       1.1    dyoung 				msec_delay(100);
    674       1.1    dyoung 				hw->phy.ops.read_reg(hw, 0xC79F,
    675  1.1.12.1  jdolecek 						     IXGBE_TWINAX_DEV,
    676  1.1.12.1  jdolecek 						     &link_reg);
    677       1.1    dyoung 				hw->phy.ops.read_reg(hw, 0xC00C,
    678  1.1.12.1  jdolecek 						     IXGBE_TWINAX_DEV,
    679  1.1.12.1  jdolecek 						     &adapt_comp_reg);
    680       1.1    dyoung 			}
    681       1.1    dyoung 		} else {
    682       1.1    dyoung 			if ((link_reg & 1) && ((adapt_comp_reg & 1) == 0))
    683       1.1    dyoung 				*link_up = TRUE;
    684       1.1    dyoung 			else
    685       1.1    dyoung 				*link_up = FALSE;
    686       1.1    dyoung 		}
    687       1.1    dyoung 
    688       1.1    dyoung 		if (*link_up == FALSE)
    689       1.1    dyoung 			goto out;
    690       1.1    dyoung 	}
    691       1.1    dyoung 
    692       1.1    dyoung 	links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
    693       1.1    dyoung 	if (link_up_wait_to_complete) {
    694  1.1.12.1  jdolecek 		for (i = 0; i < hw->mac.max_link_up_time; i++) {
    695       1.1    dyoung 			if (links_reg & IXGBE_LINKS_UP) {
    696       1.1    dyoung 				*link_up = TRUE;
    697       1.1    dyoung 				break;
    698       1.1    dyoung 			} else {
    699       1.1    dyoung 				*link_up = FALSE;
    700       1.1    dyoung 			}
    701       1.1    dyoung 			msec_delay(100);
    702       1.1    dyoung 			links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
    703       1.1    dyoung 		}
    704       1.1    dyoung 	} else {
    705       1.1    dyoung 		if (links_reg & IXGBE_LINKS_UP)
    706       1.1    dyoung 			*link_up = TRUE;
    707       1.1    dyoung 		else
    708       1.1    dyoung 			*link_up = FALSE;
    709       1.1    dyoung 	}
    710       1.1    dyoung 
    711       1.1    dyoung 	if (links_reg & IXGBE_LINKS_SPEED)
    712       1.1    dyoung 		*speed = IXGBE_LINK_SPEED_10GB_FULL;
    713       1.1    dyoung 	else
    714       1.1    dyoung 		*speed = IXGBE_LINK_SPEED_1GB_FULL;
    715       1.1    dyoung 
    716       1.1    dyoung 	if ((hw->device_id == IXGBE_DEV_ID_82598AT2) && (*link_up == TRUE) &&
    717       1.1    dyoung 	    (ixgbe_validate_link_ready(hw) != IXGBE_SUCCESS))
    718       1.1    dyoung 		*link_up = FALSE;
    719       1.1    dyoung 
    720       1.1    dyoung out:
    721       1.1    dyoung 	return IXGBE_SUCCESS;
    722       1.1    dyoung }
    723       1.1    dyoung 
    724       1.1    dyoung /**
    725       1.1    dyoung  *  ixgbe_setup_mac_link_82598 - Set MAC link speed
    726       1.1    dyoung  *  @hw: pointer to hardware structure
    727       1.1    dyoung  *  @speed: new link speed
    728       1.1    dyoung  *  @autoneg_wait_to_complete: TRUE when waiting for completion is needed
    729       1.1    dyoung  *
    730       1.1    dyoung  *  Set the link speed in the AUTOC register and restarts link.
    731       1.1    dyoung  **/
    732       1.1    dyoung static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
    733  1.1.12.1  jdolecek 				      ixgbe_link_speed speed,
    734  1.1.12.1  jdolecek 				      bool autoneg_wait_to_complete)
    735       1.1    dyoung {
    736  1.1.12.1  jdolecek 	bool autoneg = FALSE;
    737  1.1.12.1  jdolecek 	s32 status = IXGBE_SUCCESS;
    738       1.1    dyoung 	ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
    739  1.1.12.1  jdolecek 	u32 curr_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
    740  1.1.12.1  jdolecek 	u32 autoc = curr_autoc;
    741  1.1.12.1  jdolecek 	u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
    742       1.1    dyoung 
    743       1.1    dyoung 	DEBUGFUNC("ixgbe_setup_mac_link_82598");
    744       1.1    dyoung 
    745       1.1    dyoung 	/* Check to see if speed passed in is supported. */
    746       1.1    dyoung 	ixgbe_get_link_capabilities(hw, &link_capabilities, &autoneg);
    747       1.1    dyoung 	speed &= link_capabilities;
    748       1.1    dyoung 
    749       1.1    dyoung 	if (speed == IXGBE_LINK_SPEED_UNKNOWN)
    750       1.1    dyoung 		status = IXGBE_ERR_LINK_SETUP;
    751       1.1    dyoung 
    752       1.1    dyoung 	/* Set KX4/KX support according to speed requested */
    753       1.1    dyoung 	else if (link_mode == IXGBE_AUTOC_LMS_KX4_AN ||
    754  1.1.12.1  jdolecek 		 link_mode == IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {
    755       1.1    dyoung 		autoc &= ~IXGBE_AUTOC_KX4_KX_SUPP_MASK;
    756       1.1    dyoung 		if (speed & IXGBE_LINK_SPEED_10GB_FULL)
    757       1.1    dyoung 			autoc |= IXGBE_AUTOC_KX4_SUPP;
    758       1.1    dyoung 		if (speed & IXGBE_LINK_SPEED_1GB_FULL)
    759       1.1    dyoung 			autoc |= IXGBE_AUTOC_KX_SUPP;
    760       1.1    dyoung 		if (autoc != curr_autoc)
    761       1.1    dyoung 			IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
    762       1.1    dyoung 	}
    763       1.1    dyoung 
    764       1.1    dyoung 	if (status == IXGBE_SUCCESS) {
    765       1.1    dyoung 		/*
    766       1.1    dyoung 		 * Setup and restart the link based on the new values in
    767       1.1    dyoung 		 * ixgbe_hw This will write the AUTOC register based on the new
    768       1.1    dyoung 		 * stored values
    769       1.1    dyoung 		 */
    770       1.1    dyoung 		status = ixgbe_start_mac_link_82598(hw,
    771  1.1.12.1  jdolecek 						    autoneg_wait_to_complete);
    772       1.1    dyoung 	}
    773       1.1    dyoung 
    774       1.1    dyoung 	return status;
    775       1.1    dyoung }
    776       1.1    dyoung 
    777       1.1    dyoung 
    778       1.1    dyoung /**
    779       1.1    dyoung  *  ixgbe_setup_copper_link_82598 - Set the PHY autoneg advertised field
    780       1.1    dyoung  *  @hw: pointer to hardware structure
    781       1.1    dyoung  *  @speed: new link speed
    782       1.1    dyoung  *  @autoneg_wait_to_complete: TRUE if waiting is needed to complete
    783       1.1    dyoung  *
    784       1.1    dyoung  *  Sets the link speed in the AUTOC register in the MAC and restarts link.
    785       1.1    dyoung  **/
    786       1.1    dyoung static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
    787  1.1.12.1  jdolecek 					 ixgbe_link_speed speed,
    788  1.1.12.1  jdolecek 					 bool autoneg_wait_to_complete)
    789       1.1    dyoung {
    790       1.1    dyoung 	s32 status;
    791       1.1    dyoung 
    792       1.1    dyoung 	DEBUGFUNC("ixgbe_setup_copper_link_82598");
    793       1.1    dyoung 
    794       1.1    dyoung 	/* Setup the PHY according to input speed */
    795  1.1.12.1  jdolecek 	status = hw->phy.ops.setup_link_speed(hw, speed,
    796  1.1.12.1  jdolecek 					      autoneg_wait_to_complete);
    797       1.1    dyoung 	/* Set up MAC */
    798       1.1    dyoung 	ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
    799       1.1    dyoung 
    800       1.1    dyoung 	return status;
    801       1.1    dyoung }
    802       1.1    dyoung 
    803       1.1    dyoung /**
    804       1.1    dyoung  *  ixgbe_reset_hw_82598 - Performs hardware reset
    805       1.1    dyoung  *  @hw: pointer to hardware structure
    806       1.1    dyoung  *
    807       1.1    dyoung  *  Resets the hardware by resetting the transmit and receive units, masks and
    808       1.1    dyoung  *  clears all interrupts, performing a PHY reset, and performing a link (MAC)
    809       1.1    dyoung  *  reset.
    810       1.1    dyoung  **/
    811       1.1    dyoung static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
    812       1.1    dyoung {
    813       1.1    dyoung 	s32 status = IXGBE_SUCCESS;
    814       1.1    dyoung 	s32 phy_status = IXGBE_SUCCESS;
    815       1.1    dyoung 	u32 ctrl;
    816       1.1    dyoung 	u32 gheccr;
    817       1.1    dyoung 	u32 i;
    818       1.1    dyoung 	u32 autoc;
    819       1.1    dyoung 	u8  analog_val;
    820       1.1    dyoung 
    821       1.1    dyoung 	DEBUGFUNC("ixgbe_reset_hw_82598");
    822       1.1    dyoung 
    823       1.1    dyoung 	/* Call adapter stop to disable tx/rx and clear interrupts */
    824  1.1.12.1  jdolecek 	status = hw->mac.ops.stop_adapter(hw);
    825  1.1.12.1  jdolecek 	if (status != IXGBE_SUCCESS)
    826  1.1.12.1  jdolecek 		goto reset_hw_out;
    827       1.1    dyoung 
    828       1.1    dyoung 	/*
    829       1.1    dyoung 	 * Power up the Atlas Tx lanes if they are currently powered down.
    830       1.1    dyoung 	 * Atlas Tx lanes are powered down for MAC loopback tests, but
    831       1.1    dyoung 	 * they are not automatically restored on reset.
    832       1.1    dyoung 	 */
    833       1.1    dyoung 	hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val);
    834       1.1    dyoung 	if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) {
    835       1.1    dyoung 		/* Enable Tx Atlas so packets can be transmitted again */
    836       1.1    dyoung 		hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
    837  1.1.12.1  jdolecek 					     &analog_val);
    838       1.1    dyoung 		analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN;
    839       1.1    dyoung 		hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
    840  1.1.12.1  jdolecek 					      analog_val);
    841       1.1    dyoung 
    842       1.1    dyoung 		hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
    843  1.1.12.1  jdolecek 					     &analog_val);
    844       1.1    dyoung 		analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL;
    845       1.1    dyoung 		hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
    846  1.1.12.1  jdolecek 					      analog_val);
    847       1.1    dyoung 
    848       1.1    dyoung 		hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
    849  1.1.12.1  jdolecek 					     &analog_val);
    850       1.1    dyoung 		analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL;
    851       1.1    dyoung 		hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
    852  1.1.12.1  jdolecek 					      analog_val);
    853       1.1    dyoung 
    854       1.1    dyoung 		hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
    855  1.1.12.1  jdolecek 					     &analog_val);
    856       1.1    dyoung 		analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL;
    857       1.1    dyoung 		hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
    858  1.1.12.1  jdolecek 					      analog_val);
    859       1.1    dyoung 	}
    860       1.1    dyoung 
    861       1.1    dyoung 	/* Reset PHY */
    862       1.1    dyoung 	if (hw->phy.reset_disable == FALSE) {
    863       1.1    dyoung 		/* PHY ops must be identified and initialized prior to reset */
    864       1.1    dyoung 
    865       1.1    dyoung 		/* Init PHY and function pointers, perform SFP setup */
    866       1.1    dyoung 		phy_status = hw->phy.ops.init(hw);
    867       1.1    dyoung 		if (phy_status == IXGBE_ERR_SFP_NOT_SUPPORTED)
    868       1.1    dyoung 			goto reset_hw_out;
    869  1.1.12.1  jdolecek 		if (phy_status == IXGBE_ERR_SFP_NOT_PRESENT)
    870  1.1.12.1  jdolecek 			goto mac_reset_top;
    871       1.1    dyoung 
    872       1.1    dyoung 		hw->phy.ops.reset(hw);
    873       1.1    dyoung 	}
    874       1.1    dyoung 
    875       1.1    dyoung mac_reset_top:
    876       1.1    dyoung 	/*
    877       1.1    dyoung 	 * Issue global reset to the MAC.  This needs to be a SW reset.
    878       1.1    dyoung 	 * If link reset is used, it might reset the MAC when mng is using it
    879       1.1    dyoung 	 */
    880  1.1.12.1  jdolecek 	ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL) | IXGBE_CTRL_RST;
    881  1.1.12.1  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
    882       1.1    dyoung 	IXGBE_WRITE_FLUSH(hw);
    883       1.1    dyoung 
    884       1.1    dyoung 	/* Poll for reset bit to self-clear indicating reset is complete */
    885       1.1    dyoung 	for (i = 0; i < 10; i++) {
    886       1.1    dyoung 		usec_delay(1);
    887       1.1    dyoung 		ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
    888       1.1    dyoung 		if (!(ctrl & IXGBE_CTRL_RST))
    889       1.1    dyoung 			break;
    890       1.1    dyoung 	}
    891       1.1    dyoung 	if (ctrl & IXGBE_CTRL_RST) {
    892       1.1    dyoung 		status = IXGBE_ERR_RESET_FAILED;
    893       1.1    dyoung 		DEBUGOUT("Reset polling failed to complete.\n");
    894       1.1    dyoung 	}
    895       1.1    dyoung 
    896  1.1.12.1  jdolecek 	msec_delay(50);
    897  1.1.12.1  jdolecek 
    898       1.1    dyoung 	/*
    899       1.1    dyoung 	 * Double resets are required for recovery from certain error
    900       1.1    dyoung 	 * conditions.  Between resets, it is necessary to stall to allow time
    901  1.1.12.1  jdolecek 	 * for any pending HW events to complete.
    902       1.1    dyoung 	 */
    903       1.1    dyoung 	if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
    904       1.1    dyoung 		hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
    905       1.1    dyoung 		goto mac_reset_top;
    906       1.1    dyoung 	}
    907       1.1    dyoung 
    908       1.1    dyoung 	gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR);
    909       1.1    dyoung 	gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6));
    910       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_GHECCR, gheccr);
    911       1.1    dyoung 
    912       1.1    dyoung 	/*
    913       1.1    dyoung 	 * Store the original AUTOC value if it has not been
    914       1.1    dyoung 	 * stored off yet.  Otherwise restore the stored original
    915       1.1    dyoung 	 * AUTOC value since the reset operation sets back to deaults.
    916       1.1    dyoung 	 */
    917       1.1    dyoung 	autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
    918       1.1    dyoung 	if (hw->mac.orig_link_settings_stored == FALSE) {
    919       1.1    dyoung 		hw->mac.orig_autoc = autoc;
    920       1.1    dyoung 		hw->mac.orig_link_settings_stored = TRUE;
    921       1.1    dyoung 	} else if (autoc != hw->mac.orig_autoc) {
    922       1.1    dyoung 		IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
    923       1.1    dyoung 	}
    924       1.1    dyoung 
    925       1.1    dyoung 	/* Store the permanent mac address */
    926       1.1    dyoung 	hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
    927       1.1    dyoung 
    928       1.1    dyoung 	/*
    929       1.1    dyoung 	 * Store MAC address from RAR0, clear receive address registers, and
    930       1.1    dyoung 	 * clear the multicast table
    931       1.1    dyoung 	 */
    932       1.1    dyoung 	hw->mac.ops.init_rx_addrs(hw);
    933       1.1    dyoung 
    934       1.1    dyoung reset_hw_out:
    935       1.1    dyoung 	if (phy_status != IXGBE_SUCCESS)
    936       1.1    dyoung 		status = phy_status;
    937       1.1    dyoung 
    938       1.1    dyoung 	return status;
    939       1.1    dyoung }
    940       1.1    dyoung 
    941       1.1    dyoung /**
    942       1.1    dyoung  *  ixgbe_set_vmdq_82598 - Associate a VMDq set index with a rx address
    943       1.1    dyoung  *  @hw: pointer to hardware struct
    944       1.1    dyoung  *  @rar: receive address register index to associate with a VMDq index
    945       1.1    dyoung  *  @vmdq: VMDq set index
    946       1.1    dyoung  **/
    947       1.1    dyoung s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
    948       1.1    dyoung {
    949       1.1    dyoung 	u32 rar_high;
    950       1.1    dyoung 	u32 rar_entries = hw->mac.num_rar_entries;
    951       1.1    dyoung 
    952       1.1    dyoung 	DEBUGFUNC("ixgbe_set_vmdq_82598");
    953       1.1    dyoung 
    954       1.1    dyoung 	/* Make sure we are using a valid rar index range */
    955       1.1    dyoung 	if (rar >= rar_entries) {
    956       1.1    dyoung 		DEBUGOUT1("RAR index %d is out of range.\n", rar);
    957       1.1    dyoung 		return IXGBE_ERR_INVALID_ARGUMENT;
    958       1.1    dyoung 	}
    959       1.1    dyoung 
    960       1.1    dyoung 	rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
    961       1.1    dyoung 	rar_high &= ~IXGBE_RAH_VIND_MASK;
    962       1.1    dyoung 	rar_high |= ((vmdq << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK);
    963       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
    964       1.1    dyoung 	return IXGBE_SUCCESS;
    965       1.1    dyoung }
    966       1.1    dyoung 
    967       1.1    dyoung /**
    968       1.1    dyoung  *  ixgbe_clear_vmdq_82598 - Disassociate a VMDq set index from an rx address
    969       1.1    dyoung  *  @hw: pointer to hardware struct
    970       1.1    dyoung  *  @rar: receive address register index to associate with a VMDq index
    971       1.1    dyoung  *  @vmdq: VMDq clear index (not used in 82598, but elsewhere)
    972       1.1    dyoung  **/
    973       1.1    dyoung static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
    974       1.1    dyoung {
    975       1.1    dyoung 	u32 rar_high;
    976       1.1    dyoung 	u32 rar_entries = hw->mac.num_rar_entries;
    977       1.1    dyoung 
    978  1.1.12.1  jdolecek 	UNREFERENCED_1PARAMETER(vmdq);
    979       1.1    dyoung 
    980       1.1    dyoung 	/* Make sure we are using a valid rar index range */
    981       1.1    dyoung 	if (rar >= rar_entries) {
    982       1.1    dyoung 		DEBUGOUT1("RAR index %d is out of range.\n", rar);
    983       1.1    dyoung 		return IXGBE_ERR_INVALID_ARGUMENT;
    984       1.1    dyoung 	}
    985       1.1    dyoung 
    986       1.1    dyoung 	rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
    987       1.1    dyoung 	if (rar_high & IXGBE_RAH_VIND_MASK) {
    988       1.1    dyoung 		rar_high &= ~IXGBE_RAH_VIND_MASK;
    989       1.1    dyoung 		IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
    990       1.1    dyoung 	}
    991       1.1    dyoung 
    992       1.1    dyoung 	return IXGBE_SUCCESS;
    993       1.1    dyoung }
    994       1.1    dyoung 
    995       1.1    dyoung /**
    996       1.1    dyoung  *  ixgbe_set_vfta_82598 - Set VLAN filter table
    997       1.1    dyoung  *  @hw: pointer to hardware structure
    998       1.1    dyoung  *  @vlan: VLAN id to write to VLAN filter
    999       1.1    dyoung  *  @vind: VMDq output index that maps queue to VLAN id in VFTA
   1000       1.1    dyoung  *  @vlan_on: boolean flag to turn on/off VLAN in VFTA
   1001  1.1.12.1  jdolecek  *  @vlvf_bypass: boolean flag - unused
   1002       1.1    dyoung  *
   1003       1.1    dyoung  *  Turn on/off specified VLAN in the VLAN filter table.
   1004       1.1    dyoung  **/
   1005       1.1    dyoung s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
   1006  1.1.12.1  jdolecek 			 bool vlan_on, bool vlvf_bypass)
   1007       1.1    dyoung {
   1008       1.1    dyoung 	u32 regindex;
   1009       1.1    dyoung 	u32 bitindex;
   1010       1.1    dyoung 	u32 bits;
   1011       1.1    dyoung 	u32 vftabyte;
   1012       1.1    dyoung 
   1013  1.1.12.1  jdolecek 	UNREFERENCED_1PARAMETER(vlvf_bypass);
   1014  1.1.12.1  jdolecek 
   1015       1.1    dyoung 	DEBUGFUNC("ixgbe_set_vfta_82598");
   1016       1.1    dyoung 
   1017       1.1    dyoung 	if (vlan > 4095)
   1018       1.1    dyoung 		return IXGBE_ERR_PARAM;
   1019       1.1    dyoung 
   1020       1.1    dyoung 	/* Determine 32-bit word position in array */
   1021       1.1    dyoung 	regindex = (vlan >> 5) & 0x7F;   /* upper seven bits */
   1022       1.1    dyoung 
   1023       1.1    dyoung 	/* Determine the location of the (VMD) queue index */
   1024       1.1    dyoung 	vftabyte =  ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */
   1025       1.1    dyoung 	bitindex = (vlan & 0x7) << 2;    /* lower 3 bits indicate nibble */
   1026       1.1    dyoung 
   1027       1.1    dyoung 	/* Set the nibble for VMD queue index */
   1028       1.1    dyoung 	bits = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex));
   1029       1.1    dyoung 	bits &= (~(0x0F << bitindex));
   1030       1.1    dyoung 	bits |= (vind << bitindex);
   1031       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex), bits);
   1032       1.1    dyoung 
   1033       1.1    dyoung 	/* Determine the location of the bit for this VLAN id */
   1034       1.1    dyoung 	bitindex = vlan & 0x1F;   /* lower five bits */
   1035       1.1    dyoung 
   1036       1.1    dyoung 	bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
   1037       1.1    dyoung 	if (vlan_on)
   1038       1.1    dyoung 		/* Turn on this VLAN id */
   1039       1.1    dyoung 		bits |= (1 << bitindex);
   1040       1.1    dyoung 	else
   1041       1.1    dyoung 		/* Turn off this VLAN id */
   1042       1.1    dyoung 		bits &= ~(1 << bitindex);
   1043       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
   1044       1.1    dyoung 
   1045       1.1    dyoung 	return IXGBE_SUCCESS;
   1046       1.1    dyoung }
   1047       1.1    dyoung 
   1048       1.1    dyoung /**
   1049       1.1    dyoung  *  ixgbe_clear_vfta_82598 - Clear VLAN filter table
   1050       1.1    dyoung  *  @hw: pointer to hardware structure
   1051       1.1    dyoung  *
   1052       1.1    dyoung  *  Clears the VLAN filer table, and the VMDq index associated with the filter
   1053       1.1    dyoung  **/
   1054       1.1    dyoung static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw)
   1055       1.1    dyoung {
   1056       1.1    dyoung 	u32 offset;
   1057       1.1    dyoung 	u32 vlanbyte;
   1058       1.1    dyoung 
   1059       1.1    dyoung 	DEBUGFUNC("ixgbe_clear_vfta_82598");
   1060       1.1    dyoung 
   1061       1.1    dyoung 	for (offset = 0; offset < hw->mac.vft_size; offset++)
   1062       1.1    dyoung 		IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);
   1063       1.1    dyoung 
   1064       1.1    dyoung 	for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)
   1065       1.1    dyoung 		for (offset = 0; offset < hw->mac.vft_size; offset++)
   1066       1.1    dyoung 			IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset),
   1067  1.1.12.1  jdolecek 					0);
   1068       1.1    dyoung 
   1069       1.1    dyoung 	return IXGBE_SUCCESS;
   1070       1.1    dyoung }
   1071       1.1    dyoung 
   1072       1.1    dyoung /**
   1073       1.1    dyoung  *  ixgbe_read_analog_reg8_82598 - Reads 8 bit Atlas analog register
   1074       1.1    dyoung  *  @hw: pointer to hardware structure
   1075       1.1    dyoung  *  @reg: analog register to read
   1076       1.1    dyoung  *  @val: read value
   1077       1.1    dyoung  *
   1078       1.1    dyoung  *  Performs read operation to Atlas analog register specified.
   1079       1.1    dyoung  **/
   1080       1.1    dyoung s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)
   1081       1.1    dyoung {
   1082       1.1    dyoung 	u32  atlas_ctl;
   1083       1.1    dyoung 
   1084       1.1    dyoung 	DEBUGFUNC("ixgbe_read_analog_reg8_82598");
   1085       1.1    dyoung 
   1086       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL,
   1087  1.1.12.1  jdolecek 			IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));
   1088       1.1    dyoung 	IXGBE_WRITE_FLUSH(hw);
   1089       1.1    dyoung 	usec_delay(10);
   1090       1.1    dyoung 	atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL);
   1091       1.1    dyoung 	*val = (u8)atlas_ctl;
   1092       1.1    dyoung 
   1093       1.1    dyoung 	return IXGBE_SUCCESS;
   1094       1.1    dyoung }
   1095       1.1    dyoung 
   1096       1.1    dyoung /**
   1097       1.1    dyoung  *  ixgbe_write_analog_reg8_82598 - Writes 8 bit Atlas analog register
   1098       1.1    dyoung  *  @hw: pointer to hardware structure
   1099       1.1    dyoung  *  @reg: atlas register to write
   1100       1.1    dyoung  *  @val: value to write
   1101       1.1    dyoung  *
   1102       1.1    dyoung  *  Performs write operation to Atlas analog register specified.
   1103       1.1    dyoung  **/
   1104       1.1    dyoung s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)
   1105       1.1    dyoung {
   1106       1.1    dyoung 	u32  atlas_ctl;
   1107       1.1    dyoung 
   1108       1.1    dyoung 	DEBUGFUNC("ixgbe_write_analog_reg8_82598");
   1109       1.1    dyoung 
   1110       1.1    dyoung 	atlas_ctl = (reg << 8) | val;
   1111       1.1    dyoung 	IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);
   1112       1.1    dyoung 	IXGBE_WRITE_FLUSH(hw);
   1113       1.1    dyoung 	usec_delay(10);
   1114       1.1    dyoung 
   1115       1.1    dyoung 	return IXGBE_SUCCESS;
   1116       1.1    dyoung }
   1117       1.1    dyoung 
   1118       1.1    dyoung /**
   1119  1.1.12.1  jdolecek  *  ixgbe_read_i2c_phy_82598 - Reads 8 bit word over I2C interface.
   1120       1.1    dyoung  *  @hw: pointer to hardware structure
   1121  1.1.12.1  jdolecek  *  @dev_addr: address to read from
   1122  1.1.12.1  jdolecek  *  @byte_offset: byte offset to read from dev_addr
   1123       1.1    dyoung  *  @eeprom_data: value read
   1124       1.1    dyoung  *
   1125       1.1    dyoung  *  Performs 8 byte read operation to SFP module's EEPROM over I2C interface.
   1126       1.1    dyoung  **/
   1127  1.1.12.1  jdolecek static s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr,
   1128  1.1.12.1  jdolecek 				    u8 byte_offset, u8 *eeprom_data)
   1129       1.1    dyoung {
   1130       1.1    dyoung 	s32 status = IXGBE_SUCCESS;
   1131       1.1    dyoung 	u16 sfp_addr = 0;
   1132       1.1    dyoung 	u16 sfp_data = 0;
   1133       1.1    dyoung 	u16 sfp_stat = 0;
   1134  1.1.12.1  jdolecek 	u16 gssr;
   1135       1.1    dyoung 	u32 i;
   1136       1.1    dyoung 
   1137  1.1.12.1  jdolecek 	DEBUGFUNC("ixgbe_read_i2c_phy_82598");
   1138  1.1.12.1  jdolecek 
   1139  1.1.12.1  jdolecek 	if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
   1140  1.1.12.1  jdolecek 		gssr = IXGBE_GSSR_PHY1_SM;
   1141  1.1.12.1  jdolecek 	else
   1142  1.1.12.1  jdolecek 		gssr = IXGBE_GSSR_PHY0_SM;
   1143  1.1.12.1  jdolecek 
   1144  1.1.12.1  jdolecek 	if (hw->mac.ops.acquire_swfw_sync(hw, gssr) != IXGBE_SUCCESS)
   1145  1.1.12.1  jdolecek 		return IXGBE_ERR_SWFW_SYNC;
   1146       1.1    dyoung 
   1147       1.1    dyoung 	if (hw->phy.type == ixgbe_phy_nl) {
   1148       1.1    dyoung 		/*
   1149       1.1    dyoung 		 * NetLogic phy SDA/SCL registers are at addresses 0xC30A to
   1150       1.1    dyoung 		 * 0xC30D. These registers are used to talk to the SFP+
   1151       1.1    dyoung 		 * module's EEPROM through the SDA/SCL (I2C) interface.
   1152       1.1    dyoung 		 */
   1153  1.1.12.1  jdolecek 		sfp_addr = (dev_addr << 8) + byte_offset;
   1154       1.1    dyoung 		sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK);
   1155  1.1.12.1  jdolecek 		hw->phy.ops.write_reg_mdi(hw,
   1156  1.1.12.1  jdolecek 					  IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR,
   1157  1.1.12.1  jdolecek 					  IXGBE_MDIO_PMA_PMD_DEV_TYPE,
   1158  1.1.12.1  jdolecek 					  sfp_addr);
   1159       1.1    dyoung 
   1160       1.1    dyoung 		/* Poll status */
   1161       1.1    dyoung 		for (i = 0; i < 100; i++) {
   1162  1.1.12.1  jdolecek 			hw->phy.ops.read_reg_mdi(hw,
   1163  1.1.12.1  jdolecek 						IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT,
   1164  1.1.12.1  jdolecek 						IXGBE_MDIO_PMA_PMD_DEV_TYPE,
   1165  1.1.12.1  jdolecek 						&sfp_stat);
   1166       1.1    dyoung 			sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK;
   1167       1.1    dyoung 			if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS)
   1168       1.1    dyoung 				break;
   1169       1.1    dyoung 			msec_delay(10);
   1170       1.1    dyoung 		}
   1171       1.1    dyoung 
   1172       1.1    dyoung 		if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_PASS) {
   1173       1.1    dyoung 			DEBUGOUT("EEPROM read did not pass.\n");
   1174       1.1    dyoung 			status = IXGBE_ERR_SFP_NOT_PRESENT;
   1175       1.1    dyoung 			goto out;
   1176       1.1    dyoung 		}
   1177       1.1    dyoung 
   1178       1.1    dyoung 		/* Read data */
   1179  1.1.12.1  jdolecek 		hw->phy.ops.read_reg_mdi(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA,
   1180  1.1.12.1  jdolecek 					IXGBE_MDIO_PMA_PMD_DEV_TYPE, &sfp_data);
   1181       1.1    dyoung 
   1182       1.1    dyoung 		*eeprom_data = (u8)(sfp_data >> 8);
   1183       1.1    dyoung 	} else {
   1184       1.1    dyoung 		status = IXGBE_ERR_PHY;
   1185       1.1    dyoung 	}
   1186       1.1    dyoung 
   1187       1.1    dyoung out:
   1188  1.1.12.1  jdolecek 	hw->mac.ops.release_swfw_sync(hw, gssr);
   1189       1.1    dyoung 	return status;
   1190       1.1    dyoung }
   1191       1.1    dyoung 
   1192       1.1    dyoung /**
   1193  1.1.12.1  jdolecek  *  ixgbe_read_i2c_eeprom_82598 - Reads 8 bit word over I2C interface.
   1194  1.1.12.1  jdolecek  *  @hw: pointer to hardware structure
   1195  1.1.12.1  jdolecek  *  @byte_offset: EEPROM byte offset to read
   1196  1.1.12.1  jdolecek  *  @eeprom_data: value read
   1197  1.1.12.1  jdolecek  *
   1198  1.1.12.1  jdolecek  *  Performs 8 byte read operation to SFP module's EEPROM over I2C interface.
   1199  1.1.12.1  jdolecek  **/
   1200  1.1.12.1  jdolecek s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
   1201  1.1.12.1  jdolecek 				u8 *eeprom_data)
   1202  1.1.12.1  jdolecek {
   1203  1.1.12.1  jdolecek 	return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR,
   1204  1.1.12.1  jdolecek 					byte_offset, eeprom_data);
   1205  1.1.12.1  jdolecek }
   1206  1.1.12.1  jdolecek 
   1207  1.1.12.1  jdolecek /**
   1208  1.1.12.1  jdolecek  *  ixgbe_read_i2c_sff8472_82598 - Reads 8 bit word over I2C interface.
   1209  1.1.12.1  jdolecek  *  @hw: pointer to hardware structure
   1210  1.1.12.1  jdolecek  *  @byte_offset: byte offset at address 0xA2
   1211  1.1.12.1  jdolecek  *  @eeprom_data: value read
   1212  1.1.12.1  jdolecek  *
   1213  1.1.12.1  jdolecek  *  Performs 8 byte read operation to SFP module's SFF-8472 data over I2C
   1214  1.1.12.1  jdolecek  **/
   1215  1.1.12.1  jdolecek static s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset,
   1216  1.1.12.1  jdolecek 					u8 *sff8472_data)
   1217  1.1.12.1  jdolecek {
   1218  1.1.12.1  jdolecek 	return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR2,
   1219  1.1.12.1  jdolecek 					byte_offset, sff8472_data);
   1220  1.1.12.1  jdolecek }
   1221  1.1.12.1  jdolecek 
   1222  1.1.12.1  jdolecek /**
   1223       1.1    dyoung  *  ixgbe_get_supported_physical_layer_82598 - Returns physical layer type
   1224       1.1    dyoung  *  @hw: pointer to hardware structure
   1225       1.1    dyoung  *
   1226       1.1    dyoung  *  Determines physical layer capabilities of the current configuration.
   1227       1.1    dyoung  **/
   1228  1.1.12.1  jdolecek u64 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
   1229       1.1    dyoung {
   1230  1.1.12.1  jdolecek 	u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
   1231       1.1    dyoung 	u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
   1232       1.1    dyoung 	u32 pma_pmd_10g = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
   1233       1.1    dyoung 	u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
   1234       1.1    dyoung 	u16 ext_ability = 0;
   1235       1.1    dyoung 
   1236       1.1    dyoung 	DEBUGFUNC("ixgbe_get_supported_physical_layer_82598");
   1237       1.1    dyoung 
   1238       1.1    dyoung 	hw->phy.ops.identify(hw);
   1239       1.1    dyoung 
   1240       1.1    dyoung 	/* Copper PHY must be checked before AUTOC LMS to determine correct
   1241       1.1    dyoung 	 * physical layer because 10GBase-T PHYs use LMS = KX4/KX */
   1242       1.1    dyoung 	switch (hw->phy.type) {
   1243       1.1    dyoung 	case ixgbe_phy_tn:
   1244       1.1    dyoung 	case ixgbe_phy_cu_unknown:
   1245       1.1    dyoung 		hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
   1246       1.1    dyoung 		IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
   1247       1.1    dyoung 		if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
   1248       1.1    dyoung 			physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
   1249       1.1    dyoung 		if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
   1250       1.1    dyoung 			physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
   1251       1.1    dyoung 		if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY)
   1252       1.1    dyoung 			physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
   1253       1.1    dyoung 		goto out;
   1254       1.1    dyoung 	default:
   1255       1.1    dyoung 		break;
   1256       1.1    dyoung 	}
   1257       1.1    dyoung 
   1258       1.1    dyoung 	switch (autoc & IXGBE_AUTOC_LMS_MASK) {
   1259       1.1    dyoung 	case IXGBE_AUTOC_LMS_1G_AN:
   1260       1.1    dyoung 	case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
   1261       1.1    dyoung 		if (pma_pmd_1g == IXGBE_AUTOC_1G_KX)
   1262       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
   1263       1.1    dyoung 		else
   1264       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_BX;
   1265       1.1    dyoung 		break;
   1266       1.1    dyoung 	case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
   1267       1.1    dyoung 		if (pma_pmd_10g == IXGBE_AUTOC_10G_CX4)
   1268       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
   1269       1.1    dyoung 		else if (pma_pmd_10g == IXGBE_AUTOC_10G_KX4)
   1270       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
   1271       1.1    dyoung 		else /* XAUI */
   1272       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
   1273       1.1    dyoung 		break;
   1274       1.1    dyoung 	case IXGBE_AUTOC_LMS_KX4_AN:
   1275       1.1    dyoung 	case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
   1276       1.1    dyoung 		if (autoc & IXGBE_AUTOC_KX_SUPP)
   1277       1.1    dyoung 			physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
   1278       1.1    dyoung 		if (autoc & IXGBE_AUTOC_KX4_SUPP)
   1279       1.1    dyoung 			physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
   1280       1.1    dyoung 		break;
   1281       1.1    dyoung 	default:
   1282       1.1    dyoung 		break;
   1283       1.1    dyoung 	}
   1284       1.1    dyoung 
   1285       1.1    dyoung 	if (hw->phy.type == ixgbe_phy_nl) {
   1286       1.1    dyoung 		hw->phy.ops.identify_sfp(hw);
   1287       1.1    dyoung 
   1288       1.1    dyoung 		switch (hw->phy.sfp_type) {
   1289       1.1    dyoung 		case ixgbe_sfp_type_da_cu:
   1290       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
   1291       1.1    dyoung 			break;
   1292       1.1    dyoung 		case ixgbe_sfp_type_sr:
   1293       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
   1294       1.1    dyoung 			break;
   1295       1.1    dyoung 		case ixgbe_sfp_type_lr:
   1296       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
   1297       1.1    dyoung 			break;
   1298       1.1    dyoung 		default:
   1299       1.1    dyoung 			physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
   1300       1.1    dyoung 			break;
   1301       1.1    dyoung 		}
   1302       1.1    dyoung 	}
   1303       1.1    dyoung 
   1304       1.1    dyoung 	switch (hw->device_id) {
   1305       1.1    dyoung 	case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
   1306       1.1    dyoung 		physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
   1307       1.1    dyoung 		break;
   1308       1.1    dyoung 	case IXGBE_DEV_ID_82598AF_DUAL_PORT:
   1309       1.1    dyoung 	case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
   1310       1.1    dyoung 	case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
   1311       1.1    dyoung 		physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
   1312       1.1    dyoung 		break;
   1313       1.1    dyoung 	case IXGBE_DEV_ID_82598EB_XF_LR:
   1314       1.1    dyoung 		physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
   1315       1.1    dyoung 		break;
   1316       1.1    dyoung 	default:
   1317       1.1    dyoung 		break;
   1318       1.1    dyoung 	}
   1319       1.1    dyoung 
   1320       1.1    dyoung out:
   1321       1.1    dyoung 	return physical_layer;
   1322       1.1    dyoung }
   1323       1.1    dyoung 
   1324       1.1    dyoung /**
   1325       1.1    dyoung  *  ixgbe_set_lan_id_multi_port_pcie_82598 - Set LAN id for PCIe multiple
   1326       1.1    dyoung  *  port devices.
   1327       1.1    dyoung  *  @hw: pointer to the HW structure
   1328       1.1    dyoung  *
   1329       1.1    dyoung  *  Calls common function and corrects issue with some single port devices
   1330       1.1    dyoung  *  that enable LAN1 but not LAN0.
   1331       1.1    dyoung  **/
   1332       1.1    dyoung void ixgbe_set_lan_id_multi_port_pcie_82598(struct ixgbe_hw *hw)
   1333       1.1    dyoung {
   1334       1.1    dyoung 	struct ixgbe_bus_info *bus = &hw->bus;
   1335       1.1    dyoung 	u16 pci_gen = 0;
   1336       1.1    dyoung 	u16 pci_ctrl2 = 0;
   1337       1.1    dyoung 
   1338       1.1    dyoung 	DEBUGFUNC("ixgbe_set_lan_id_multi_port_pcie_82598");
   1339       1.1    dyoung 
   1340       1.1    dyoung 	ixgbe_set_lan_id_multi_port_pcie(hw);
   1341       1.1    dyoung 
   1342       1.1    dyoung 	/* check if LAN0 is disabled */
   1343       1.1    dyoung 	hw->eeprom.ops.read(hw, IXGBE_PCIE_GENERAL_PTR, &pci_gen);
   1344       1.1    dyoung 	if ((pci_gen != 0) && (pci_gen != 0xFFFF)) {
   1345       1.1    dyoung 
   1346       1.1    dyoung 		hw->eeprom.ops.read(hw, pci_gen + IXGBE_PCIE_CTRL2, &pci_ctrl2);
   1347       1.1    dyoung 
   1348       1.1    dyoung 		/* if LAN0 is completely disabled force function to 0 */
   1349       1.1    dyoung 		if ((pci_ctrl2 & IXGBE_PCIE_CTRL2_LAN_DISABLE) &&
   1350       1.1    dyoung 		    !(pci_ctrl2 & IXGBE_PCIE_CTRL2_DISABLE_SELECT) &&
   1351       1.1    dyoung 		    !(pci_ctrl2 & IXGBE_PCIE_CTRL2_DUMMY_ENABLE)) {
   1352       1.1    dyoung 
   1353       1.1    dyoung 			bus->func = 0;
   1354       1.1    dyoung 		}
   1355       1.1    dyoung 	}
   1356       1.1    dyoung }
   1357       1.1    dyoung 
   1358       1.1    dyoung /**
   1359       1.1    dyoung  *  ixgbe_enable_relaxed_ordering_82598 - enable relaxed ordering
   1360       1.1    dyoung  *  @hw: pointer to hardware structure
   1361       1.1    dyoung  *
   1362       1.1    dyoung  **/
   1363       1.1    dyoung void ixgbe_enable_relaxed_ordering_82598(struct ixgbe_hw *hw)
   1364       1.1    dyoung {
   1365       1.1    dyoung 	u32 regval;
   1366       1.1    dyoung 	u32 i;
   1367       1.1    dyoung 
   1368       1.1    dyoung 	DEBUGFUNC("ixgbe_enable_relaxed_ordering_82598");
   1369       1.1    dyoung 
   1370       1.1    dyoung 	/* Enable relaxed ordering */
   1371       1.1    dyoung 	for (i = 0; ((i < hw->mac.max_tx_queues) &&
   1372       1.1    dyoung 	     (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
   1373       1.1    dyoung 		regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i));
   1374  1.1.12.1  jdolecek 		regval |= IXGBE_DCA_TXCTRL_DESC_WRO_EN;
   1375       1.1    dyoung 		IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval);
   1376       1.1    dyoung 	}
   1377       1.1    dyoung 
   1378       1.1    dyoung 	for (i = 0; ((i < hw->mac.max_rx_queues) &&
   1379       1.1    dyoung 	     (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
   1380       1.1    dyoung 		regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i));
   1381  1.1.12.1  jdolecek 		regval |= IXGBE_DCA_RXCTRL_DATA_WRO_EN |
   1382  1.1.12.1  jdolecek 			  IXGBE_DCA_RXCTRL_HEAD_WRO_EN;
   1383       1.1    dyoung 		IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
   1384       1.1    dyoung 	}
   1385       1.1    dyoung 
   1386       1.1    dyoung }
   1387  1.1.12.1  jdolecek 
   1388  1.1.12.1  jdolecek /**
   1389  1.1.12.1  jdolecek  * ixgbe_set_rxpba_82598 - Initialize RX packet buffer
   1390  1.1.12.1  jdolecek  * @hw: pointer to hardware structure
   1391  1.1.12.1  jdolecek  * @num_pb: number of packet buffers to allocate
   1392  1.1.12.1  jdolecek  * @headroom: reserve n KB of headroom
   1393  1.1.12.1  jdolecek  * @strategy: packet buffer allocation strategy
   1394  1.1.12.1  jdolecek  **/
   1395  1.1.12.1  jdolecek static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb,
   1396  1.1.12.1  jdolecek 				  u32 headroom, int strategy)
   1397  1.1.12.1  jdolecek {
   1398  1.1.12.1  jdolecek 	u32 rxpktsize = IXGBE_RXPBSIZE_64KB;
   1399  1.1.12.1  jdolecek 	u8 i = 0;
   1400  1.1.12.1  jdolecek 	UNREFERENCED_1PARAMETER(headroom);
   1401  1.1.12.1  jdolecek 
   1402  1.1.12.1  jdolecek 	if (!num_pb)
   1403  1.1.12.1  jdolecek 		return;
   1404  1.1.12.1  jdolecek 
   1405  1.1.12.1  jdolecek 	/* Setup Rx packet buffer sizes */
   1406  1.1.12.1  jdolecek 	switch (strategy) {
   1407  1.1.12.1  jdolecek 	case PBA_STRATEGY_WEIGHTED:
   1408  1.1.12.1  jdolecek 		/* Setup the first four at 80KB */
   1409  1.1.12.1  jdolecek 		rxpktsize = IXGBE_RXPBSIZE_80KB;
   1410  1.1.12.1  jdolecek 		for (; i < 4; i++)
   1411  1.1.12.1  jdolecek 			IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize);
   1412  1.1.12.1  jdolecek 		/* Setup the last four at 48KB...don't re-init i */
   1413  1.1.12.1  jdolecek 		rxpktsize = IXGBE_RXPBSIZE_48KB;
   1414  1.1.12.1  jdolecek 		/* Fall Through */
   1415  1.1.12.1  jdolecek 	case PBA_STRATEGY_EQUAL:
   1416  1.1.12.1  jdolecek 	default:
   1417  1.1.12.1  jdolecek 		/* Divide the remaining Rx packet buffer evenly among the TCs */
   1418  1.1.12.1  jdolecek 		for (; i < IXGBE_MAX_PACKET_BUFFERS; i++)
   1419  1.1.12.1  jdolecek 			IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize);
   1420  1.1.12.1  jdolecek 		break;
   1421  1.1.12.1  jdolecek 	}
   1422  1.1.12.1  jdolecek 
   1423  1.1.12.1  jdolecek 	/* Setup Tx packet buffer sizes */
   1424  1.1.12.1  jdolecek 	for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++)
   1425  1.1.12.1  jdolecek 		IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), IXGBE_TXPBSIZE_40KB);
   1426  1.1.12.1  jdolecek }
   1427  1.1.12.1  jdolecek 
   1428  1.1.12.1  jdolecek /**
   1429  1.1.12.1  jdolecek  *  ixgbe_enable_rx_dma_82598 - Enable the Rx DMA unit
   1430  1.1.12.1  jdolecek  *  @hw: pointer to hardware structure
   1431  1.1.12.1  jdolecek  *  @regval: register value to write to RXCTRL
   1432  1.1.12.1  jdolecek  *
   1433  1.1.12.1  jdolecek  *  Enables the Rx DMA unit
   1434  1.1.12.1  jdolecek  **/
   1435  1.1.12.1  jdolecek s32 ixgbe_enable_rx_dma_82598(struct ixgbe_hw *hw, u32 regval)
   1436  1.1.12.1  jdolecek {
   1437  1.1.12.1  jdolecek 	DEBUGFUNC("ixgbe_enable_rx_dma_82598");
   1438  1.1.12.1  jdolecek 
   1439  1.1.12.1  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval);
   1440  1.1.12.1  jdolecek 
   1441  1.1.12.1  jdolecek 	return IXGBE_SUCCESS;
   1442  1.1.12.1  jdolecek }
   1443