ixgbe_82598.c revision 283620
14Srgrimes/****************************************************************************** 24Srgrimes 34Srgrimes Copyright (c) 2001-2015, Intel Corporation 44Srgrimes All rights reserved. 54Srgrimes 64Srgrimes Redistribution and use in source and binary forms, with or without 74Srgrimes modification, are permitted provided that the following conditions are met: 84Srgrimes 94Srgrimes 1. Redistributions of source code must retain the above copyright notice, 104Srgrimes this list of conditions and the following disclaimer. 114Srgrimes 124Srgrimes 2. Redistributions in binary form must reproduce the above copyright 134Srgrimes notice, this list of conditions and the following disclaimer in the 144Srgrimes documentation and/or other materials provided with the distribution. 154Srgrimes 164Srgrimes 3. Neither the name of the Intel Corporation nor the names of its 174Srgrimes contributors may be used to endorse or promote products derived from 184Srgrimes this software without specific prior written permission. 194Srgrimes 204Srgrimes THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 214Srgrimes AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224Srgrimes IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234Srgrimes ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 244Srgrimes LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 254Srgrimes CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 264Srgrimes SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 274Srgrimes INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 284Srgrimes CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 294Srgrimes ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 304Srgrimes POSSIBILITY OF SUCH DAMAGE. 314Srgrimes 324Srgrimes******************************************************************************/ 334Srgrimes/*$FreeBSD: stable/10/sys/dev/ixgbe/ixgbe_82598.c 283620 2015-05-27 17:44:11Z erj $*/ 344Srgrimes 354Srgrimes#include "ixgbe_type.h" 36556Srgrimes#include "ixgbe_82598.h" 3750477Speter#include "ixgbe_api.h" 3815392Sphk#include "ixgbe_common.h" 39757Sdg#include "ixgbe_phy.h" 40757Sdg 41757Sdg#define IXGBE_82598_MAX_TX_QUEUES 32 4215392Sphk#define IXGBE_82598_MAX_RX_QUEUES 64 4315392Sphk#define IXGBE_82598_RAR_ENTRIES 16 444Srgrimes#define IXGBE_82598_MC_TBL_SIZE 128 454Srgrimes#define IXGBE_82598_VFT_TBL_SIZE 128 4632358Seivind#define IXGBE_82598_RX_PB_SIZE 512 4790132Sbde 4837272Sjmgstatic s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw, 4914835Sbde ixgbe_link_speed *speed, 5014835Sbde bool *autoneg); 515908Sbdestatic enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw); 524Srgrimesstatic s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw, 5314835Sbde bool autoneg_wait_to_complete); 5414835Sbdestatic s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, 5514835Sbde ixgbe_link_speed *speed, bool *link_up, 5615543Sphk bool link_up_wait_to_complete); 5714835Sbdestatic s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw, 5814835Sbde ixgbe_link_speed speed, 5914835Sbde bool autoneg_wait_to_complete); 6014835Sbdestatic s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw, 614Srgrimes ixgbe_link_speed speed, 62757Sdg bool autoneg_wait_to_complete); 63757Sdgstatic s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw); 644Srgrimesstatic s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq); 654Srgrimesstatic s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw); 664Srgrimesstatic void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb, 674Srgrimes u32 headroom, int strategy); 684Srgrimesstatic s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset, 69200Sdg u8 *sff8472_data); 704Srgrimes/** 714Srgrimes * ixgbe_set_pcie_completion_timeout - set pci-e completion timeout 7282307Sjulian * @hw: pointer to the HW structure 7382307Sjulian * 7482307Sjulian * The defaults for 82598 should be in the range of 50us to 50ms, 7582308Speter * however the hardware default for these parts is 500us to 1ms which is less 7682394Speter * than the 10ms recommended by the pci-e spec. To address this we need to 7782307Sjulian * increase the value to either 10ms to 250ms for capability version 1 config, 784Srgrimes * or 16ms to 55ms for version 2. 7973011Sjake **/ 8073011Sjakevoid ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw) 8173011Sjake{ 8273011Sjake u32 gcr = IXGBE_READ_REG(hw, IXGBE_GCR); 83592Srgrimes u16 pcie_devctl2; 843861Sbde 854Srgrimes /* only take action if timeout value is defaulted to 0 */ 864Srgrimes if (gcr & IXGBE_GCR_CMPL_TMOUT_MASK) 8782307Sjulian goto out; 884Srgrimes 8973011Sjake /* 9073011Sjake * if capababilities version is type 1 we can write the 9173011Sjake * timeout of 10ms to 250ms through the GCR register 9273011Sjake */ 934Srgrimes if (!(gcr & IXGBE_GCR_CAP_VER2)) { 9470928Sjake gcr |= IXGBE_GCR_CMPL_TMOUT_10ms; 954Srgrimes goto out; 9670928Sjake } 9770928Sjake 9870928Sjake /* 9970928Sjake * for version 2 capabilities we need to write the config space 10073011Sjake * directly in order to set the completion timeout value for 10173011Sjake * 16ms to 55ms 10273011Sjake */ 10370928Sjake pcie_devctl2 = IXGBE_READ_PCIE_WORD(hw, IXGBE_PCI_DEVICE_CONTROL2); 10470928Sjake pcie_devctl2 |= IXGBE_PCI_DEVICE_CONTROL2_16ms; 10570928Sjake IXGBE_WRITE_PCIE_WORD(hw, IXGBE_PCI_DEVICE_CONTROL2, pcie_devctl2); 10682262Speterout: 10782262Speter /* disable completion timeout resend */ 10882262Speter gcr &= ~IXGBE_GCR_CMPL_TMOUT_RESEND; 10982262Speter IXGBE_WRITE_REG(hw, IXGBE_GCR, gcr); 11082262Speter} 11182262Speter 112556Srgrimes/** 113556Srgrimes * ixgbe_init_ops_82598 - Inits func ptrs and MAC type 114556Srgrimes * @hw: pointer to hardware structure 11599741Sobrien * 116134Sdg * Initialize the function pointers and assign the MAC type for 82598. 11725083Sjdp * Does not touch the hardware. 11899741Sobrien **/ 11925083Sjdps32 ixgbe_init_ops_82598(struct ixgbe_hw *hw) 1203842Sdg{ 12182957Speter struct ixgbe_mac_info *mac = &hw->mac; 12299741Sobrien struct ixgbe_phy_info *phy = &hw->phy; 1234Srgrimes s32 ret_val; 12499862Speter 12599741Sobrien DEBUGFUNC("ixgbe_init_ops_82598"); 12699741Sobrien 127757Sdg ret_val = ixgbe_init_phy_ops_generic(hw); 12826812Speter ret_val = ixgbe_init_ops_generic(hw); 12973011Sjake 13099741Sobrien /* PHY */ 13199741Sobrien phy->ops.init = ixgbe_init_phy_ops_82598; 13225164Speter 13373011Sjake /* MAC */ 13499741Sobrien mac->ops.start_hw = ixgbe_start_hw_82598; 13599741Sobrien mac->ops.enable_relaxed_ordering = ixgbe_enable_relaxed_ordering_82598; 13626812Speter mac->ops.reset_hw = ixgbe_reset_hw_82598; 13725164Speter mac->ops.get_media_type = ixgbe_get_media_type_82598; 13873011Sjake mac->ops.get_supported_physical_layer = 13999741Sobrien ixgbe_get_supported_physical_layer_82598; 1403861Sbde mac->ops.read_analog_reg8 = ixgbe_read_analog_reg8_82598; 14126812Speter mac->ops.write_analog_reg8 = ixgbe_write_analog_reg8_82598; 14273011Sjake mac->ops.set_lan_id = ixgbe_set_lan_id_multi_port_pcie_82598; 14326812Speter mac->ops.enable_rx_dma = ixgbe_enable_rx_dma_82598; 14499741Sobrien 1454Srgrimes /* RAR, Multicast, VLAN */ 14683366Sjulian mac->ops.set_vmdq = ixgbe_set_vmdq_82598; 14799741Sobrien mac->ops.clear_vmdq = ixgbe_clear_vmdq_82598; 14899741Sobrien mac->ops.set_vfta = ixgbe_set_vfta_82598; 14999741Sobrien mac->ops.set_vlvf = NULL; 15099741Sobrien mac->ops.clear_vfta = ixgbe_clear_vfta_82598; 151134Sdg 15299741Sobrien /* Flow Control */ 15337889Sjlemon mac->ops.fc_enable = ixgbe_fc_enable_82598; 15473011Sjake 15599741Sobrien mac->mcft_size = IXGBE_82598_MC_TBL_SIZE; 15699741Sobrien mac->vft_size = IXGBE_82598_VFT_TBL_SIZE; 15734840Sjlemon mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES; 15843434Skato mac->rx_pb_size = IXGBE_82598_RX_PB_SIZE; 15973011Sjake mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES; 16073011Sjake mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES; 16143434Skato mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw); 16243434Skato 16315428Sphk /* SFP+ Module */ 16415392Sphk phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_82598; 16515392Sphk phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_82598; 16615392Sphk 16715392Sphk /* Link */ 168556Srgrimes mac->ops.check_link = ixgbe_check_mac_link_82598; 169134Sdg mac->ops.setup_link = ixgbe_setup_mac_link_82598; 17015392Sphk mac->ops.flap_tx_laser = NULL; 17115392Sphk mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_82598; 17215392Sphk mac->ops.setup_rxpba = ixgbe_set_rxpba_82598; 17315392Sphk 17415543Sphk /* Manageability interface */ 17515392Sphk mac->ops.set_fw_drv_ver = NULL; 17615392Sphk 17715392Sphk mac->ops.get_rtrup2tc = NULL; 17815543Sphk 17915392Sphk return ret_val; 18015428Sphk} 18115428Sphk 18215428Sphk/** 18315392Sphk * ixgbe_init_phy_ops_82598 - PHY/SFP specific init 184134Sdg * @hw: pointer to hardware structure 18515392Sphk * 18615565Sphk * Initialize any function pointers that were not able to be 18715565Sphk * set during init_shared_code because the PHY/SFP type was 18815392Sphk * not known. Perform the SFP init if necessary. 18915565Sphk * 19015565Sphk **/ 191134Sdgs32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw) 19215565Sphk{ 193111299Sjake struct ixgbe_mac_info *mac = &hw->mac; 19419621Sdyson struct ixgbe_phy_info *phy = &hw->phy; 19519621Sdyson s32 ret_val = IXGBE_SUCCESS; 19619621Sdyson u16 list_offset, data_offset; 19715565Sphk 19815565Sphk DEBUGFUNC("ixgbe_init_phy_ops_82598"); 199111299Sjake 20015428Sphk /* Identify the PHY */ 20115392Sphk phy->ops.identify(hw); 20215565Sphk 20315565Sphk /* Overwrite the link function pointers if copper PHY */ 20415565Sphk if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) { 20515565Sphk mac->ops.setup_link = ixgbe_setup_copper_link_82598; 20615565Sphk mac->ops.get_link_capabilities = 20715565Sphk ixgbe_get_copper_link_capabilities_generic; 20815565Sphk } 20915565Sphk 21015565Sphk switch (hw->phy.type) { 21173011Sjake case ixgbe_phy_tn: 21215565Sphk phy->ops.setup_link = ixgbe_setup_phy_link_tnx; 21315392Sphk phy->ops.check_link = ixgbe_check_phy_link_tnx; 21415392Sphk phy->ops.get_firmware_version = 21515392Sphk ixgbe_get_phy_firmware_version_tnx; 21615392Sphk break; 21715392Sphk case ixgbe_phy_nl: 21815392Sphk phy->ops.reset = ixgbe_reset_phy_nl; 2191321Sdg 2204Srgrimes /* Call SFP+ identify routine to get the SFP+ module type */ 22124112Skato ret_val = phy->ops.identify_sfp(hw); 22224112Skato if (ret_val != IXGBE_SUCCESS) 22343434Skato goto out; 22473011Sjake else if (hw->phy.sfp_type == ixgbe_sfp_type_unknown) { 22543434Skato ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED; 22624112Skato goto out; 22724112Skato } 22824112Skato 22924112Skato /* Check to see if SFP+ module is supported */ 23015392Sphk ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, 23115392Sphk &list_offset, 23254128Skato &data_offset); 23315392Sphk if (ret_val != IXGBE_SUCCESS) { 23415428Sphk ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED; 2353384Srgrimes goto out; 2363384Srgrimes } 2373384Srgrimes break; 23815392Sphk default: 2395603Sbde break; 2402486Sdg } 24115428Sphk 24215428Sphkout: 24315428Sphk return ret_val; 24415428Sphk} 24515428Sphk 24615428Sphk/** 2474217Sphk * ixgbe_start_hw_82598 - Prepare hardware for Tx/Rx 2484217Sphk * @hw: pointer to hardware structure 2494217Sphk * 25015392Sphk * Starts the hardware using the generic start_hw function. 25115392Sphk * Disables relaxed ordering Then set pcie completion timeout 25215428Sphk * 25315428Sphk **/ 25415428Sphks32 ixgbe_start_hw_82598(struct ixgbe_hw *hw) 25515428Sphk{ 25615428Sphk u32 regval; 25715428Sphk u32 i; 25825083Sjdp s32 ret_val = IXGBE_SUCCESS; 25915392Sphk 26024112Skato DEBUGFUNC("ixgbe_start_hw_82598"); 26143447Skato 26273011Sjake ret_val = ixgbe_start_hw_generic(hw); 26324112Skato if (ret_val) 26443447Skato return ret_val; 26573011Sjake 26624112Skato /* Disable relaxed ordering */ 26724112Skato for (i = 0; ((i < hw->mac.max_tx_queues) && 26824112Skato (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { 26924112Skato regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i)); 27024112Skato regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN; 27124112Skato IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval); 27224112Skato } 27324112Skato 27424112Skato for (i = 0; ((i < hw->mac.max_rx_queues) && 27524112Skato (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { 27624112Skato regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i)); 27724112Skato regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN | 27824112Skato IXGBE_DCA_RXCTRL_HEAD_WRO_EN); 27924112Skato IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); 28073011Sjake } 28124112Skato 28258786Skato /* set the completion timeout for interface */ 28373011Sjake ixgbe_set_pcie_completion_timeout(hw); 28473011Sjake 28524112Skato return ret_val; 28624112Skato} 28715392Sphk 28815392Sphk/** 28915392Sphk * ixgbe_get_link_capabilities_82598 - Determines link capabilities 29015428Sphk * @hw: pointer to hardware structure 29117120Sbde * @speed: pointer to link speed 29215428Sphk * @autoneg: boolean auto-negotiation value 29317120Sbde * 29417120Sbde * Determines the link capabilities by reading the AUTOC register. 29515428Sphk **/ 29615428Sphkstatic s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw, 29715428Sphk ixgbe_link_speed *speed, 29815428Sphk bool *autoneg) 29915428Sphk{ 30015428Sphk s32 status = IXGBE_SUCCESS; 30115428Sphk u32 autoc = 0; 302109994Sjake 303109994Sjake DEBUGFUNC("ixgbe_get_link_capabilities_82598"); 30415428Sphk 30573011Sjake /* 30673011Sjake * Determine link capabilities based on the stored value of AUTOC, 30715392Sphk * which represents EEPROM defaults. If AUTOC value has not been 30815392Sphk * stored, use the current register value. 30915428Sphk */ 31015428Sphk if (hw->mac.orig_link_settings_stored) 31115428Sphk autoc = hw->mac.orig_autoc; 31215392Sphk else 31315392Sphk autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 31415392Sphk 31527993Sdyson switch (autoc & IXGBE_AUTOC_LMS_MASK) { 31627993Sdyson case IXGBE_AUTOC_LMS_1G_LINK_NO_AN: 31727993Sdyson *speed = IXGBE_LINK_SPEED_1GB_FULL; 31873011Sjake *autoneg = FALSE; 31927993Sdyson break; 32027993Sdyson 32127993Sdyson case IXGBE_AUTOC_LMS_10G_LINK_NO_AN: 32227993Sdyson *speed = IXGBE_LINK_SPEED_10GB_FULL; 32327993Sdyson *autoneg = FALSE; 32427993Sdyson break; 32515392Sphk 32673011Sjake case IXGBE_AUTOC_LMS_1G_AN: 32799741Sobrien *speed = IXGBE_LINK_SPEED_1GB_FULL; 32899741Sobrien *autoneg = TRUE; 32999741Sobrien break; 33099741Sobrien 33115392Sphk case IXGBE_AUTOC_LMS_KX4_AN: 33299741Sobrien case IXGBE_AUTOC_LMS_KX4_AN_1G_AN: 33315392Sphk *speed = IXGBE_LINK_SPEED_UNKNOWN; 33415392Sphk if (autoc & IXGBE_AUTOC_KX4_SUPP) 33515392Sphk *speed |= IXGBE_LINK_SPEED_10GB_FULL; 33615392Sphk if (autoc & IXGBE_AUTOC_KX_SUPP) 33715392Sphk *speed |= IXGBE_LINK_SPEED_1GB_FULL; 33899741Sobrien *autoneg = TRUE; 33983366Sjulian break; 34083366Sjulian 34165815Sbde default: 34299741Sobrien status = IXGBE_ERR_LINK_SETUP; 34365815Sbde break; 34473011Sjake } 34583366Sjulian 34615392Sphk return status; 34799741Sobrien} 34899741Sobrien 34915392Sphk/** 35065815Sbde * ixgbe_get_media_type_82598 - Determines media type 35165815Sbde * @hw: pointer to hardware structure 35265815Sbde * 35365815Sbde * Returns the media type (fiber, copper, backplane) 35465815Sbde **/ 35565815Sbdestatic enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw) 35665815Sbde{ 35799741Sobrien enum ixgbe_media_type media_type; 35865815Sbde 35999741Sobrien DEBUGFUNC("ixgbe_get_media_type_82598"); 36015392Sphk 36124691Speter /* Detect if there is a copper PHY attached. */ 36215392Sphk switch (hw->phy.type) { 36315392Sphk case ixgbe_phy_cu_unknown: 36415392Sphk case ixgbe_phy_tn: 365107521Sdeischen media_type = ixgbe_media_type_copper; 366107521Sdeischen goto out; 36715392Sphk default: 36852140Sluoqi break; 369107521Sdeischen } 37099741Sobrien 371107521Sdeischen /* Media type for I82598 is based on device ID */ 37252140Sluoqi switch (hw->device_id) { 37399741Sobrien case IXGBE_DEV_ID_82598: 37499741Sobrien case IXGBE_DEV_ID_82598_BX: 375107521Sdeischen /* Default device ID is mezzanine card KX/KX4 */ 376107521Sdeischen media_type = ixgbe_media_type_backplane; 377107521Sdeischen break; 37852140Sluoqi case IXGBE_DEV_ID_82598AF_DUAL_PORT: 379105950Speter case IXGBE_DEV_ID_82598AF_SINGLE_PORT: 380105950Speter case IXGBE_DEV_ID_82598_DA_DUAL_PORT: 381105950Speter case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM: 382107521Sdeischen case IXGBE_DEV_ID_82598EB_XF_LR: 383107521Sdeischen case IXGBE_DEV_ID_82598EB_SFP_LOM: 384105950Speter media_type = ixgbe_media_type_fiber; 385105950Speter break; 386107521Sdeischen case IXGBE_DEV_ID_82598EB_CX4: 387105950Speter case IXGBE_DEV_ID_82598_CX4_DUAL_PORT: 388107521Sdeischen media_type = ixgbe_media_type_cx4; 389105950Speter break; 390105950Speter case IXGBE_DEV_ID_82598AT: 391105950Speter case IXGBE_DEV_ID_82598AT2: 392107521Sdeischen media_type = ixgbe_media_type_copper; 393107521Sdeischen break; 394107521Sdeischen default: 395105950Speter media_type = ixgbe_media_type_unknown; 396105950Speter break; 39790132Sbde } 39825083Sjdpout: 39973011Sjake return media_type; 40099741Sobrien} 40199741Sobrien 40252140Sluoqi/** 40352140Sluoqi * ixgbe_fc_enable_82598 - Enable flow control 40452140Sluoqi * @hw: pointer to hardware structure 40599741Sobrien * 40652140Sluoqi * Enable flow control according to the current settings. 407105950Speter **/ 40899741Sobriens32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw) 40999741Sobrien{ 41052140Sluoqi s32 ret_val = IXGBE_SUCCESS; 41190132Sbde u32 fctrl_reg; 41252140Sluoqi u32 rmcs_reg; 41352140Sluoqi u32 reg; 41473011Sjake u32 fcrtl, fcrth; 41515392Sphk u32 link_speed = 0; 41615392Sphk int i; 417105950Speter bool link_up; 41873011Sjake 41973011Sjake DEBUGFUNC("ixgbe_fc_enable_82598"); 420105950Speter 421105950Speter /* Validate the water mark configuration */ 422105950Speter if (!hw->fc.pause_time) { 423105950Speter ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; 424105950Speter goto out; 42590132Sbde } 426105950Speter 42773011Sjake /* Low water mark of zero causes XOFF floods */ 42873011Sjake for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) { 42990132Sbde if ((hw->fc.current_mode & ixgbe_fc_tx_pause) && 43015428Sphk hw->fc.high_water[i]) { 43115392Sphk if (!hw->fc.low_water[i] || 43215392Sphk hw->fc.low_water[i] >= hw->fc.high_water[i]) { 43315392Sphk DEBUGOUT("Invalid water mark configuration\n"); 43415392Sphk ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; 43515392Sphk goto out; 43615392Sphk } 43715392Sphk } 43815392Sphk } 4393284Srgrimes 4403284Srgrimes /* 4413284Srgrimes * On 82598 having Rx FC on causes resets while doing 1G 4423284Srgrimes * so if it's on turn it off once we know link_speed. For 4433284Srgrimes * more details see 82598 Specification update. 4443284Srgrimes */ 4453284Srgrimes hw->mac.ops.check_link(hw, &link_speed, &link_up, FALSE); 4463284Srgrimes if (link_up && link_speed == IXGBE_LINK_SPEED_1GB_FULL) { 4473284Srgrimes switch (hw->fc.requested_mode) { 4483284Srgrimes case ixgbe_fc_full: 4493284Srgrimes hw->fc.requested_mode = ixgbe_fc_tx_pause; 4503284Srgrimes break; 4513284Srgrimes case ixgbe_fc_rx_pause: 4523284Srgrimes hw->fc.requested_mode = ixgbe_fc_none; 4533284Srgrimes break; 4543284Srgrimes default: 4553284Srgrimes /* no change */ 4563284Srgrimes break; 4573284Srgrimes } 4583284Srgrimes } 4593284Srgrimes 4603284Srgrimes /* Negotiate the fc mode to use */ 4613284Srgrimes ixgbe_fc_autoneg(hw); 4623384Srgrimes 4633384Srgrimes /* Disable any previous flow control settings */ 4644Srgrimes fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL); 4653284Srgrimes fctrl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE); 4663284Srgrimes 4673284Srgrimes rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS); 4683284Srgrimes rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X); 4693284Srgrimes 4703284Srgrimes /* 4713384Srgrimes * The possible values of fc.current_mode are: 47215392Sphk * 0: Flow control is completely disabled 4733284Srgrimes * 1: Rx flow control is enabled (we can receive pause frames, 4743284Srgrimes * but not send pause frames). 4753284Srgrimes * 2: Tx flow control is enabled (we can send pause frames but 4763284Srgrimes * we do not support receiving pause frames). 47715428Sphk * 3: Both Rx and Tx flow control (symmetric) are enabled. 47815428Sphk * other: Invalid. 4793284Srgrimes */ 4803384Srgrimes switch (hw->fc.current_mode) { 48115392Sphk case ixgbe_fc_none: 4823284Srgrimes /* 4833284Srgrimes * Flow control is disabled by software override or autoneg. 4843284Srgrimes * The code below will actually disable it in the HW. 4853284Srgrimes */ 4863284Srgrimes break; 4873284Srgrimes case ixgbe_fc_rx_pause: 4883284Srgrimes /* 4893284Srgrimes * Rx Flow control is enabled and Tx Flow control is 4903284Srgrimes * disabled by software override. Since there really 4913384Srgrimes * isn't a way to advertise that we are capable of RX 49215428Sphk * Pause ONLY, we will advertise that we support both 4933384Srgrimes * symmetric and asymmetric Rx PAUSE. Later, we will 4943284Srgrimes * disable the adapter's ability to send PAUSE frames. 49515392Sphk */ 4963384Srgrimes fctrl_reg |= IXGBE_FCTRL_RFCE; 4975908Sbde break; 4983384Srgrimes case ixgbe_fc_tx_pause: 4993384Srgrimes /* 5003384Srgrimes * Tx Flow control is enabled, and Rx Flow control is 5013384Srgrimes * disabled by software override. 50215428Sphk */ 50315428Sphk rmcs_reg |= IXGBE_RMCS_TFCE_802_3X; 50415428Sphk break; 50515428Sphk case ixgbe_fc_full: 5063384Srgrimes /* Flow control (both Rx and Tx) is enabled by SW override. */ 5073284Srgrimes fctrl_reg |= IXGBE_FCTRL_RFCE; 5083384Srgrimes rmcs_reg |= IXGBE_RMCS_TFCE_802_3X; 5093284Srgrimes break; 5103384Srgrimes default: 5113384Srgrimes DEBUGOUT("Flow control param set incorrectly\n"); 5125908Sbde ret_val = IXGBE_ERR_CONFIG; 5133384Srgrimes goto out; 5149344Sdg break; 5159344Sdg } 51673011Sjake 5179344Sdg /* Set 802.3x based flow control settings. */ 5189344Sdg fctrl_reg |= IXGBE_FCTRL_DPF; 5199344Sdg IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg); 5209344Sdg IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg); 5219344Sdg 5229344Sdg /* Set up and enable Rx high/low water mark thresholds, enable XON. */ 5233384Srgrimes for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) { 5243384Srgrimes if ((hw->fc.current_mode & ixgbe_fc_tx_pause) && 5253384Srgrimes hw->fc.high_water[i]) { 5263384Srgrimes fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE; 5279344Sdg fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN; 52815428Sphk IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl); 5295908Sbde IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), fcrth); 5305908Sbde } else { 5315908Sbde IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), 0); 5325908Sbde IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), 0); 5334600Sphk } 5345908Sbde 5355908Sbde } 5365908Sbde 5375908Sbde /* Configure pause time (2 TCs per register) */ 5385908Sbde reg = hw->fc.pause_time * 0x00010001; 5395908Sbde for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++) 54015428Sphk IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg); 5415908Sbde 5425908Sbde /* Configure flow control refresh threshold value */ 5434600Sphk IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2); 54473011Sjake 5455908Sbdeout: 5465908Sbde return ret_val; 5474600Sphk} 5485908Sbde 5494600Sphk/** 5504600Sphk * ixgbe_start_mac_link_82598 - Configures MAC link settings 5514600Sphk * @hw: pointer to hardware structure 5524600Sphk * 55338063Smsmith * Configures link settings based on values in the ixgbe_hw struct. 55425837Stegge * Restarts the link. Performs autonegotiation if needed. 5553384Srgrimes **/ 5563384Srgrimesstatic s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw, 5573384Srgrimes bool autoneg_wait_to_complete) 5585908Sbde{ 5593384Srgrimes u32 autoc_reg; 56015428Sphk u32 links_reg; 56173011Sjake u32 i; 5623384Srgrimes s32 status = IXGBE_SUCCESS; 5633384Srgrimes 5643384Srgrimes DEBUGFUNC("ixgbe_start_mac_link_82598"); 5653384Srgrimes 56673011Sjake /* Restart link */ 5673795Sphk autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); 5683406Sdg autoc_reg |= IXGBE_AUTOC_AN_RESTART; 56925837Stegge IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); 5703384Srgrimes 5713384Srgrimes /* Only poll for autoneg to complete if specified to do so */ 5723284Srgrimes if (autoneg_wait_to_complete) { 5733284Srgrimes if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) == 5743384Srgrimes IXGBE_AUTOC_LMS_KX4_AN || 5753384Srgrimes (autoc_reg & IXGBE_AUTOC_LMS_MASK) == 5763284Srgrimes IXGBE_AUTOC_LMS_KX4_AN_1G_AN) { 57715392Sphk links_reg = 0; /* Just in case Autoneg time = 0 */ 5783384Srgrimes for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) { 57973011Sjake links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); 5803384Srgrimes if (links_reg & IXGBE_LINKS_KX_AN_COMP) 58173011Sjake break; 5822783Ssos msec_delay(100); 58315392Sphk } 5843258Sdg if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) { 5851321Sdg status = IXGBE_ERR_AUTONEG_NOT_COMPLETE; 58615392Sphk DEBUGOUT("Autonegotiation did not complete.\n"); 58715392Sphk } 58815392Sphk } 58915392Sphk } 59015392Sphk 59115392Sphk /* Add delay to filter out noises during initial link setup */ 59215392Sphk msec_delay(50); 5931998Swollman 5941998Swollman return status; 5951998Swollman} 5961998Swollman 5971998Swollman/** 5981998Swollman * ixgbe_validate_link_ready - Function looks for phy link 5991998Swollman * @hw: pointer to hardware structure 6001998Swollman * 6011998Swollman * Function indicates success when phy link is available. If phy is not ready 6021998Swollman * within 5 seconds of MAC indicating link, the function returns error. 6031998Swollman **/ 6041998Swollmanstatic s32 ixgbe_validate_link_ready(struct ixgbe_hw *hw) 6051998Swollman{ 6061998Swollman u32 timeout; 6071998Swollman u16 an_reg; 60824112Skato 60924112Skato if (hw->device_id != IXGBE_DEV_ID_82598AT2) 61024112Skato return IXGBE_SUCCESS; 61124112Skato 61224112Skato for (timeout = 0; 61324112Skato timeout < IXGBE_VALIDATE_LINK_READY_TIMEOUT; timeout++) { 61424112Skato hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS, 61524112Skato IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &an_reg); 61624112Skato 61724112Skato if ((an_reg & IXGBE_MII_AUTONEG_COMPLETE) && 61824112Skato (an_reg & IXGBE_MII_AUTONEG_LINK_UP)) 61973011Sjake break; 62013081Sdg 6211998Swollman msec_delay(100); 62224112Skato } 62327424Skato 62473011Sjake if (timeout == IXGBE_VALIDATE_LINK_READY_TIMEOUT) { 62573011Sjake DEBUGOUT("Link was indicated but link is down\n"); 62673011Sjake return IXGBE_ERR_LINK_SETUP; 62773011Sjake } 62873011Sjake 62924112Skato return IXGBE_SUCCESS; 63024112Skato} 63124112Skato 6321998Swollman/** 6331998Swollman * ixgbe_check_mac_link_82598 - Get link/speed status 6341998Swollman * @hw: pointer to hardware structure 6351998Swollman * @speed: pointer to link speed 6361998Swollman * @link_up: TRUE is link is up, FALSE otherwise 6371998Swollman * @link_up_wait_to_complete: bool used to wait for link up or not 6381998Swollman * 6391998Swollman * Reads the links register to determine if link is up and the current speed 6401998Swollman **/ 6411998Swollmanstatic s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, 6421998Swollman ixgbe_link_speed *speed, bool *link_up, 6431998Swollman bool link_up_wait_to_complete) 6441998Swollman{ 6451998Swollman u32 links_reg; 64624112Skato u32 i; 64773011Sjake u16 link_reg, adapt_comp_reg; 6482495Spst 64924112Skato DEBUGFUNC("ixgbe_check_mac_link_82598"); 65024112Skato 65124112Skato /* 65224112Skato * SERDES PHY requires us to read link status from undocumented 65324112Skato * register 0xC79F. Bit 0 set indicates link is up/ready; clear 65424112Skato * indicates link down. OxC00C is read to check that the XAUI lanes 65524112Skato * are active. Bit 0 clear indicates active; set indicates inactive. 65624112Skato */ 65724112Skato if (hw->phy.type == ixgbe_phy_nl) { 65824112Skato hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg); 65924112Skato hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg); 66024112Skato hw->phy.ops.read_reg(hw, 0xC00C, IXGBE_TWINAX_DEV, 66124112Skato &adapt_comp_reg); 66224112Skato if (link_up_wait_to_complete) { 66324112Skato for (i = 0; i < IXGBE_LINK_UP_TIME; i++) { 66424112Skato if ((link_reg & 1) && 6652495Spst ((adapt_comp_reg & 1) == 0)) { 66624112Skato *link_up = TRUE; 66724112Skato break; 66824112Skato } else { 66924112Skato *link_up = FALSE; 67024112Skato } 67124112Skato msec_delay(100); 67224112Skato hw->phy.ops.read_reg(hw, 0xC79F, 67324112Skato IXGBE_TWINAX_DEV, 67473011Sjake &link_reg); 67573011Sjake hw->phy.ops.read_reg(hw, 0xC00C, 67673011Sjake IXGBE_TWINAX_DEV, 67713014Sdg &adapt_comp_reg); 6781998Swollman } 67924112Skato } else { 6801998Swollman if ((link_reg & 1) && ((adapt_comp_reg & 1) == 0)) 68169006Smarkm *link_up = TRUE; 68273011Sjake else 68373011Sjake *link_up = FALSE; 68473011Sjake } 68573011Sjake 68673011Sjake if (*link_up == FALSE) 6871998Swollman goto out; 6881998Swollman } 68969006Smarkm 69073011Sjake links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); 691109696Sjhb if (link_up_wait_to_complete) { 69273011Sjake for (i = 0; i < IXGBE_LINK_UP_TIME; i++) { 6936308Sphk if (links_reg & IXGBE_LINKS_UP) { 6941998Swollman *link_up = TRUE; 6951998Swollman break; 6961998Swollman } else { 6971998Swollman *link_up = FALSE; 6981998Swollman } 69973011Sjake msec_delay(100); 70013000Sdg links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); 70113000Sdg } 70213000Sdg } else { 70313000Sdg if (links_reg & IXGBE_LINKS_UP) 70413000Sdg *link_up = TRUE; 70573011Sjake else 70613000Sdg *link_up = FALSE; 707556Srgrimes } 70813000Sdg 70973011Sjake if (links_reg & IXGBE_LINKS_SPEED) 71013000Sdg *speed = IXGBE_LINK_SPEED_10GB_FULL; 71115392Sphk else 712556Srgrimes *speed = IXGBE_LINK_SPEED_1GB_FULL; 7134Srgrimes 71415392Sphk if ((hw->device_id == IXGBE_DEV_ID_82598AT2) && (*link_up == TRUE) && 715570Srgrimes (ixgbe_validate_link_ready(hw) != IXGBE_SUCCESS)) 71615428Sphk *link_up = FALSE; 71715392Sphk 718570Srgrimesout: 719570Srgrimes return IXGBE_SUCCESS; 72015392Sphk} 72115392Sphk 72215428Sphk/** 72315392Sphk * ixgbe_setup_mac_link_82598 - Set MAC link speed 7244Srgrimes * @hw: pointer to hardware structure 72561422Sbde * @speed: new link speed 72673011Sjake * @autoneg_wait_to_complete: TRUE when waiting for completion is needed 7275908Sbde * 72815428Sphk * Set the link speed in the AUTOC register and restarts link. 7295908Sbde **/ 7305908Sbdestatic s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw, 73173011Sjake ixgbe_link_speed speed, 73273011Sjake bool autoneg_wait_to_complete) 73315428Sphk{ 7345908Sbde bool autoneg = FALSE; 73540081Smsmith s32 status = IXGBE_SUCCESS; 73673011Sjake ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN; 73740081Smsmith u32 curr_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 73840081Smsmith u32 autoc = curr_autoc; 73940081Smsmith u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK; 74040081Smsmith 74140081Smsmith DEBUGFUNC("ixgbe_setup_mac_link_82598"); 74215565Sphk 74315565Sphk /* Check to see if speed passed in is supported. */ 74473011Sjake ixgbe_get_link_capabilities(hw, &link_capabilities, &autoneg); 74515428Sphk speed &= link_capabilities; 746608Srgrimes 74715392Sphk if (speed == IXGBE_LINK_SPEED_UNKNOWN) 74815392Sphk status = IXGBE_ERR_LINK_SETUP; 74973011Sjake 750757Sdg /* Set KX4/KX support according to speed requested */ 75115392Sphk else if (link_mode == IXGBE_AUTOC_LMS_KX4_AN || 752111363Sjake link_mode == IXGBE_AUTOC_LMS_KX4_AN_1G_AN) { 75373011Sjake autoc &= ~IXGBE_AUTOC_KX4_KX_SUPP_MASK; 7544Srgrimes if (speed & IXGBE_LINK_SPEED_10GB_FULL) 75515392Sphk autoc |= IXGBE_AUTOC_KX4_SUPP; 75683366Sjulian if (speed & IXGBE_LINK_SPEED_1GB_FULL) 75717120Sbde autoc |= IXGBE_AUTOC_KX_SUPP; 75815392Sphk if (autoc != curr_autoc) 75983366Sjulian IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc); 7604Srgrimes } 76183366Sjulian 76283366Sjulian if (status == IXGBE_SUCCESS) { 76383366Sjulian /* 76483366Sjulian * Setup and restart the link based on the new values in 76583366Sjulian * ixgbe_hw This will write the AUTOC register based on the new 76637889Sjlemon * stored values 76737889Sjlemon */ 76837889Sjlemon status = ixgbe_start_mac_link_82598(hw, 76937889Sjlemon autoneg_wait_to_complete); 77073011Sjake } 77134840Sjlemon 77273011Sjake return status; 77334840Sjlemon} 77426812Speter 77525164Speter 77625164Speter/** 77725164Speter * ixgbe_setup_copper_link_82598 - Set the PHY autoneg advertised field 77825164Speter * @hw: pointer to hardware structure 77973011Sjake * @speed: new link speed 78025164Speter * @autoneg_wait_to_complete: TRUE if waiting is needed to complete 78146129Sluoqi * 78225164Speter * Sets the link speed in the AUTOC register in the MAC and restarts link. 78346129Sluoqi **/ 78425164Speterstatic s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw, 78573011Sjake ixgbe_link_speed speed, 78626812Speter bool autoneg_wait_to_complete) 78725164Speter{ 78815392Sphk s32 status; 78915565Sphk 79019621Sdyson DEBUGFUNC("ixgbe_setup_copper_link_82598"); 79199862Speter 79215565Sphk /* Setup the PHY according to input speed */ 79315565Sphk status = hw->phy.ops.setup_link_speed(hw, speed, 79419621Sdyson autoneg_wait_to_complete); 795757Sdg /* Set up MAC */ 79615392Sphk ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete); 79773011Sjake 79815694Sphk return status; 79915694Sphk} 80019621Sdyson 80199862Speter/** 802757Sdg * ixgbe_reset_hw_82598 - Performs hardware reset 80315543Sphk * @hw: pointer to hardware structure 80419621Sdyson * 805757Sdg * Resets the hardware by resetting the transmit and receive units, masks and 80615428Sphk * clears all interrupts, performing a PHY reset, and performing a link (MAC) 80773011Sjake * reset. 808111363Sjake **/ 80919621Sdysonstatic s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw) 810757Sdg{ 81117120Sbde s32 status = IXGBE_SUCCESS; 81217120Sbde s32 phy_status = IXGBE_SUCCESS; 81383366Sjulian u32 ctrl; 81419621Sdyson u32 gheccr; 8154Srgrimes u32 i; 81683366Sjulian u32 autoc; 81783366Sjulian u8 analog_val; 81883366Sjulian 81983366Sjulian DEBUGFUNC("ixgbe_reset_hw_82598"); 82083366Sjulian 82115565Sphk /* Call adapter stop to disable tx/rx and clear interrupts */ 82215565Sphk status = hw->mac.ops.stop_adapter(hw); 82315565Sphk if (status != IXGBE_SUCCESS) 82422130Sdg goto reset_hw_out; 82515565Sphk 82634840Sjlemon /* 82737889Sjlemon * Power up the Atlas Tx lanes if they are currently powered down. 82834840Sjlemon * Atlas Tx lanes are powered down for MAC loopback tests, but 82934840Sjlemon * they are not automatically restored on reset. 83034840Sjlemon */ 83134840Sjlemon hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val); 83234840Sjlemon if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) { 83334840Sjlemon /* Enable Tx Atlas so packets can be transmitted again */ 83434840Sjlemon hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, 83573011Sjake &analog_val); 83634840Sjlemon analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN; 83734840Sjlemon hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, 83834840Sjlemon analog_val); 83934840Sjlemon 84034840Sjlemon hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G, 84173011Sjake &analog_val); 84234840Sjlemon analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL; 84326812Speter hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G, 84426812Speter analog_val); 84525164Speter 84625164Speter hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G, 84725164Speter &analog_val); 84825164Speter analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL; 84946129Sluoqi hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G, 85046129Sluoqi analog_val); 85125164Speter 85225164Speter hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN, 85325164Speter &analog_val); 85446129Sluoqi analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL; 85525164Speter hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN, 85625164Speter analog_val); 85725164Speter } 85846129Sluoqi 85925164Speter /* Reset PHY */ 86026812Speter if (hw->phy.reset_disable == FALSE) { 86146129Sluoqi /* PHY ops must be identified and initialized prior to reset */ 86225164Speter 86325164Speter /* Init PHY and function pointers, perform SFP setup */ 86473011Sjake phy_status = hw->phy.ops.init(hw); 86534840Sjlemon if (phy_status == IXGBE_ERR_SFP_NOT_SUPPORTED) 86634840Sjlemon goto reset_hw_out; 86734840Sjlemon if (phy_status == IXGBE_ERR_SFP_NOT_PRESENT) 86834840Sjlemon goto mac_reset_top; 86946129Sluoqi 87034840Sjlemon hw->phy.ops.reset(hw); 87146129Sluoqi } 87226812Speter 87325164Spetermac_reset_top: 87415392Sphk /* 87573011Sjake * Issue global reset to the MAC. This needs to be a SW reset. 87615565Sphk * If link reset is used, it might reset the MAC when mng is using it 87774283Speter */ 87873011Sjake ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL) | IXGBE_CTRL_RST; 8794Srgrimes IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl); 88015392Sphk IXGBE_WRITE_FLUSH(hw); 88173011Sjake 88215565Sphk /* Poll for reset bit to self-clear indicating reset is complete */ 88315565Sphk for (i = 0; i < 10; i++) { 88473011Sjake usec_delay(1); 8854Srgrimes ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); 88615392Sphk if (!(ctrl & IXGBE_CTRL_RST)) 88773011Sjake break; 88815565Sphk } 889111372Sjake if (ctrl & IXGBE_CTRL_RST) { 89073011Sjake status = IXGBE_ERR_RESET_FAILED; 8914Srgrimes DEBUGOUT("Reset polling failed to complete.\n"); 8924Srgrimes } 893 894 msec_delay(50); 895 896 /* 897 * Double resets are required for recovery from certain error 898 * conditions. Between resets, it is necessary to stall to allow time 899 * for any pending HW events to complete. 900 */ 901 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) { 902 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED; 903 goto mac_reset_top; 904 } 905 906 gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR); 907 gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6)); 908 IXGBE_WRITE_REG(hw, IXGBE_GHECCR, gheccr); 909 910 /* 911 * Store the original AUTOC value if it has not been 912 * stored off yet. Otherwise restore the stored original 913 * AUTOC value since the reset operation sets back to deaults. 914 */ 915 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 916 if (hw->mac.orig_link_settings_stored == FALSE) { 917 hw->mac.orig_autoc = autoc; 918 hw->mac.orig_link_settings_stored = TRUE; 919 } else if (autoc != hw->mac.orig_autoc) { 920 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc); 921 } 922 923 /* Store the permanent mac address */ 924 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr); 925 926 /* 927 * Store MAC address from RAR0, clear receive address registers, and 928 * clear the multicast table 929 */ 930 hw->mac.ops.init_rx_addrs(hw); 931 932reset_hw_out: 933 if (phy_status != IXGBE_SUCCESS) 934 status = phy_status; 935 936 return status; 937} 938 939/** 940 * ixgbe_set_vmdq_82598 - Associate a VMDq set index with a rx address 941 * @hw: pointer to hardware struct 942 * @rar: receive address register index to associate with a VMDq index 943 * @vmdq: VMDq set index 944 **/ 945s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq) 946{ 947 u32 rar_high; 948 u32 rar_entries = hw->mac.num_rar_entries; 949 950 DEBUGFUNC("ixgbe_set_vmdq_82598"); 951 952 /* Make sure we are using a valid rar index range */ 953 if (rar >= rar_entries) { 954 DEBUGOUT1("RAR index %d is out of range.\n", rar); 955 return IXGBE_ERR_INVALID_ARGUMENT; 956 } 957 958 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar)); 959 rar_high &= ~IXGBE_RAH_VIND_MASK; 960 rar_high |= ((vmdq << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK); 961 IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high); 962 return IXGBE_SUCCESS; 963} 964 965/** 966 * ixgbe_clear_vmdq_82598 - Disassociate a VMDq set index from an rx address 967 * @hw: pointer to hardware struct 968 * @rar: receive address register index to associate with a VMDq index 969 * @vmdq: VMDq clear index (not used in 82598, but elsewhere) 970 **/ 971static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq) 972{ 973 u32 rar_high; 974 u32 rar_entries = hw->mac.num_rar_entries; 975 976 UNREFERENCED_1PARAMETER(vmdq); 977 978 /* Make sure we are using a valid rar index range */ 979 if (rar >= rar_entries) { 980 DEBUGOUT1("RAR index %d is out of range.\n", rar); 981 return IXGBE_ERR_INVALID_ARGUMENT; 982 } 983 984 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar)); 985 if (rar_high & IXGBE_RAH_VIND_MASK) { 986 rar_high &= ~IXGBE_RAH_VIND_MASK; 987 IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high); 988 } 989 990 return IXGBE_SUCCESS; 991} 992 993/** 994 * ixgbe_set_vfta_82598 - Set VLAN filter table 995 * @hw: pointer to hardware structure 996 * @vlan: VLAN id to write to VLAN filter 997 * @vind: VMDq output index that maps queue to VLAN id in VFTA 998 * @vlan_on: boolean flag to turn on/off VLAN in VFTA 999 * 1000 * Turn on/off specified VLAN in the VLAN filter table. 1001 **/ 1002s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, 1003 bool vlan_on) 1004{ 1005 u32 regindex; 1006 u32 bitindex; 1007 u32 bits; 1008 u32 vftabyte; 1009 1010 DEBUGFUNC("ixgbe_set_vfta_82598"); 1011 1012 if (vlan > 4095) 1013 return IXGBE_ERR_PARAM; 1014 1015 /* Determine 32-bit word position in array */ 1016 regindex = (vlan >> 5) & 0x7F; /* upper seven bits */ 1017 1018 /* Determine the location of the (VMD) queue index */ 1019 vftabyte = ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */ 1020 bitindex = (vlan & 0x7) << 2; /* lower 3 bits indicate nibble */ 1021 1022 /* Set the nibble for VMD queue index */ 1023 bits = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex)); 1024 bits &= (~(0x0F << bitindex)); 1025 bits |= (vind << bitindex); 1026 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex), bits); 1027 1028 /* Determine the location of the bit for this VLAN id */ 1029 bitindex = vlan & 0x1F; /* lower five bits */ 1030 1031 bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex)); 1032 if (vlan_on) 1033 /* Turn on this VLAN id */ 1034 bits |= (1 << bitindex); 1035 else 1036 /* Turn off this VLAN id */ 1037 bits &= ~(1 << bitindex); 1038 IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits); 1039 1040 return IXGBE_SUCCESS; 1041} 1042 1043/** 1044 * ixgbe_clear_vfta_82598 - Clear VLAN filter table 1045 * @hw: pointer to hardware structure 1046 * 1047 * Clears the VLAN filer table, and the VMDq index associated with the filter 1048 **/ 1049static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw) 1050{ 1051 u32 offset; 1052 u32 vlanbyte; 1053 1054 DEBUGFUNC("ixgbe_clear_vfta_82598"); 1055 1056 for (offset = 0; offset < hw->mac.vft_size; offset++) 1057 IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0); 1058 1059 for (vlanbyte = 0; vlanbyte < 4; vlanbyte++) 1060 for (offset = 0; offset < hw->mac.vft_size; offset++) 1061 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset), 1062 0); 1063 1064 return IXGBE_SUCCESS; 1065} 1066 1067/** 1068 * ixgbe_read_analog_reg8_82598 - Reads 8 bit Atlas analog register 1069 * @hw: pointer to hardware structure 1070 * @reg: analog register to read 1071 * @val: read value 1072 * 1073 * Performs read operation to Atlas analog register specified. 1074 **/ 1075s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val) 1076{ 1077 u32 atlas_ctl; 1078 1079 DEBUGFUNC("ixgbe_read_analog_reg8_82598"); 1080 1081 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, 1082 IXGBE_ATLASCTL_WRITE_CMD | (reg << 8)); 1083 IXGBE_WRITE_FLUSH(hw); 1084 usec_delay(10); 1085 atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL); 1086 *val = (u8)atlas_ctl; 1087 1088 return IXGBE_SUCCESS; 1089} 1090 1091/** 1092 * ixgbe_write_analog_reg8_82598 - Writes 8 bit Atlas analog register 1093 * @hw: pointer to hardware structure 1094 * @reg: atlas register to write 1095 * @val: value to write 1096 * 1097 * Performs write operation to Atlas analog register specified. 1098 **/ 1099s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val) 1100{ 1101 u32 atlas_ctl; 1102 1103 DEBUGFUNC("ixgbe_write_analog_reg8_82598"); 1104 1105 atlas_ctl = (reg << 8) | val; 1106 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl); 1107 IXGBE_WRITE_FLUSH(hw); 1108 usec_delay(10); 1109 1110 return IXGBE_SUCCESS; 1111} 1112 1113/** 1114 * ixgbe_read_i2c_phy_82598 - Reads 8 bit word over I2C interface. 1115 * @hw: pointer to hardware structure 1116 * @dev_addr: address to read from 1117 * @byte_offset: byte offset to read from dev_addr 1118 * @eeprom_data: value read 1119 * 1120 * Performs 8 byte read operation to SFP module's EEPROM over I2C interface. 1121 **/ 1122static s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr, 1123 u8 byte_offset, u8 *eeprom_data) 1124{ 1125 s32 status = IXGBE_SUCCESS; 1126 u16 sfp_addr = 0; 1127 u16 sfp_data = 0; 1128 u16 sfp_stat = 0; 1129 u16 gssr; 1130 u32 i; 1131 1132 DEBUGFUNC("ixgbe_read_i2c_phy_82598"); 1133 1134 if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1) 1135 gssr = IXGBE_GSSR_PHY1_SM; 1136 else 1137 gssr = IXGBE_GSSR_PHY0_SM; 1138 1139 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) != IXGBE_SUCCESS) 1140 return IXGBE_ERR_SWFW_SYNC; 1141 1142 if (hw->phy.type == ixgbe_phy_nl) { 1143 /* 1144 * NetLogic phy SDA/SCL registers are at addresses 0xC30A to 1145 * 0xC30D. These registers are used to talk to the SFP+ 1146 * module's EEPROM through the SDA/SCL (I2C) interface. 1147 */ 1148 sfp_addr = (dev_addr << 8) + byte_offset; 1149 sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK); 1150 hw->phy.ops.write_reg_mdi(hw, 1151 IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR, 1152 IXGBE_MDIO_PMA_PMD_DEV_TYPE, 1153 sfp_addr); 1154 1155 /* Poll status */ 1156 for (i = 0; i < 100; i++) { 1157 hw->phy.ops.read_reg_mdi(hw, 1158 IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT, 1159 IXGBE_MDIO_PMA_PMD_DEV_TYPE, 1160 &sfp_stat); 1161 sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK; 1162 if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS) 1163 break; 1164 msec_delay(10); 1165 } 1166 1167 if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_PASS) { 1168 DEBUGOUT("EEPROM read did not pass.\n"); 1169 status = IXGBE_ERR_SFP_NOT_PRESENT; 1170 goto out; 1171 } 1172 1173 /* Read data */ 1174 hw->phy.ops.read_reg_mdi(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA, 1175 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &sfp_data); 1176 1177 *eeprom_data = (u8)(sfp_data >> 8); 1178 } else { 1179 status = IXGBE_ERR_PHY; 1180 } 1181 1182out: 1183 hw->mac.ops.release_swfw_sync(hw, gssr); 1184 return status; 1185} 1186 1187/** 1188 * ixgbe_read_i2c_eeprom_82598 - Reads 8 bit word over I2C interface. 1189 * @hw: pointer to hardware structure 1190 * @byte_offset: EEPROM byte offset to read 1191 * @eeprom_data: value read 1192 * 1193 * Performs 8 byte read operation to SFP module's EEPROM over I2C interface. 1194 **/ 1195s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset, 1196 u8 *eeprom_data) 1197{ 1198 return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR, 1199 byte_offset, eeprom_data); 1200} 1201 1202/** 1203 * ixgbe_read_i2c_sff8472_82598 - Reads 8 bit word over I2C interface. 1204 * @hw: pointer to hardware structure 1205 * @byte_offset: byte offset at address 0xA2 1206 * @eeprom_data: value read 1207 * 1208 * Performs 8 byte read operation to SFP module's SFF-8472 data over I2C 1209 **/ 1210static s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset, 1211 u8 *sff8472_data) 1212{ 1213 return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR2, 1214 byte_offset, sff8472_data); 1215} 1216 1217/** 1218 * ixgbe_get_supported_physical_layer_82598 - Returns physical layer type 1219 * @hw: pointer to hardware structure 1220 * 1221 * Determines physical layer capabilities of the current configuration. 1222 **/ 1223u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw) 1224{ 1225 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN; 1226 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 1227 u32 pma_pmd_10g = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK; 1228 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK; 1229 u16 ext_ability = 0; 1230 1231 DEBUGFUNC("ixgbe_get_supported_physical_layer_82598"); 1232 1233 hw->phy.ops.identify(hw); 1234 1235 /* Copper PHY must be checked before AUTOC LMS to determine correct 1236 * physical layer because 10GBase-T PHYs use LMS = KX4/KX */ 1237 switch (hw->phy.type) { 1238 case ixgbe_phy_tn: 1239 case ixgbe_phy_cu_unknown: 1240 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY, 1241 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability); 1242 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY) 1243 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T; 1244 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY) 1245 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T; 1246 if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY) 1247 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX; 1248 goto out; 1249 default: 1250 break; 1251 } 1252 1253 switch (autoc & IXGBE_AUTOC_LMS_MASK) { 1254 case IXGBE_AUTOC_LMS_1G_AN: 1255 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN: 1256 if (pma_pmd_1g == IXGBE_AUTOC_1G_KX) 1257 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX; 1258 else 1259 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_BX; 1260 break; 1261 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN: 1262 if (pma_pmd_10g == IXGBE_AUTOC_10G_CX4) 1263 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4; 1264 else if (pma_pmd_10g == IXGBE_AUTOC_10G_KX4) 1265 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4; 1266 else /* XAUI */ 1267 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN; 1268 break; 1269 case IXGBE_AUTOC_LMS_KX4_AN: 1270 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN: 1271 if (autoc & IXGBE_AUTOC_KX_SUPP) 1272 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX; 1273 if (autoc & IXGBE_AUTOC_KX4_SUPP) 1274 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4; 1275 break; 1276 default: 1277 break; 1278 } 1279 1280 if (hw->phy.type == ixgbe_phy_nl) { 1281 hw->phy.ops.identify_sfp(hw); 1282 1283 switch (hw->phy.sfp_type) { 1284 case ixgbe_sfp_type_da_cu: 1285 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU; 1286 break; 1287 case ixgbe_sfp_type_sr: 1288 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR; 1289 break; 1290 case ixgbe_sfp_type_lr: 1291 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR; 1292 break; 1293 default: 1294 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN; 1295 break; 1296 } 1297 } 1298 1299 switch (hw->device_id) { 1300 case IXGBE_DEV_ID_82598_DA_DUAL_PORT: 1301 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU; 1302 break; 1303 case IXGBE_DEV_ID_82598AF_DUAL_PORT: 1304 case IXGBE_DEV_ID_82598AF_SINGLE_PORT: 1305 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM: 1306 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR; 1307 break; 1308 case IXGBE_DEV_ID_82598EB_XF_LR: 1309 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR; 1310 break; 1311 default: 1312 break; 1313 } 1314 1315out: 1316 return physical_layer; 1317} 1318 1319/** 1320 * ixgbe_set_lan_id_multi_port_pcie_82598 - Set LAN id for PCIe multiple 1321 * port devices. 1322 * @hw: pointer to the HW structure 1323 * 1324 * Calls common function and corrects issue with some single port devices 1325 * that enable LAN1 but not LAN0. 1326 **/ 1327void ixgbe_set_lan_id_multi_port_pcie_82598(struct ixgbe_hw *hw) 1328{ 1329 struct ixgbe_bus_info *bus = &hw->bus; 1330 u16 pci_gen = 0; 1331 u16 pci_ctrl2 = 0; 1332 1333 DEBUGFUNC("ixgbe_set_lan_id_multi_port_pcie_82598"); 1334 1335 ixgbe_set_lan_id_multi_port_pcie(hw); 1336 1337 /* check if LAN0 is disabled */ 1338 hw->eeprom.ops.read(hw, IXGBE_PCIE_GENERAL_PTR, &pci_gen); 1339 if ((pci_gen != 0) && (pci_gen != 0xFFFF)) { 1340 1341 hw->eeprom.ops.read(hw, pci_gen + IXGBE_PCIE_CTRL2, &pci_ctrl2); 1342 1343 /* if LAN0 is completely disabled force function to 0 */ 1344 if ((pci_ctrl2 & IXGBE_PCIE_CTRL2_LAN_DISABLE) && 1345 !(pci_ctrl2 & IXGBE_PCIE_CTRL2_DISABLE_SELECT) && 1346 !(pci_ctrl2 & IXGBE_PCIE_CTRL2_DUMMY_ENABLE)) { 1347 1348 bus->func = 0; 1349 } 1350 } 1351} 1352 1353/** 1354 * ixgbe_enable_relaxed_ordering_82598 - enable relaxed ordering 1355 * @hw: pointer to hardware structure 1356 * 1357 **/ 1358void ixgbe_enable_relaxed_ordering_82598(struct ixgbe_hw *hw) 1359{ 1360 u32 regval; 1361 u32 i; 1362 1363 DEBUGFUNC("ixgbe_enable_relaxed_ordering_82598"); 1364 1365 /* Enable relaxed ordering */ 1366 for (i = 0; ((i < hw->mac.max_tx_queues) && 1367 (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { 1368 regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i)); 1369 regval |= IXGBE_DCA_TXCTRL_DESC_WRO_EN; 1370 IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval); 1371 } 1372 1373 for (i = 0; ((i < hw->mac.max_rx_queues) && 1374 (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { 1375 regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i)); 1376 regval |= IXGBE_DCA_RXCTRL_DATA_WRO_EN | 1377 IXGBE_DCA_RXCTRL_HEAD_WRO_EN; 1378 IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); 1379 } 1380 1381} 1382 1383/** 1384 * ixgbe_set_rxpba_82598 - Initialize RX packet buffer 1385 * @hw: pointer to hardware structure 1386 * @num_pb: number of packet buffers to allocate 1387 * @headroom: reserve n KB of headroom 1388 * @strategy: packet buffer allocation strategy 1389 **/ 1390static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb, 1391 u32 headroom, int strategy) 1392{ 1393 u32 rxpktsize = IXGBE_RXPBSIZE_64KB; 1394 u8 i = 0; 1395 UNREFERENCED_1PARAMETER(headroom); 1396 1397 if (!num_pb) 1398 return; 1399 1400 /* Setup Rx packet buffer sizes */ 1401 switch (strategy) { 1402 case PBA_STRATEGY_WEIGHTED: 1403 /* Setup the first four at 80KB */ 1404 rxpktsize = IXGBE_RXPBSIZE_80KB; 1405 for (; i < 4; i++) 1406 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize); 1407 /* Setup the last four at 48KB...don't re-init i */ 1408 rxpktsize = IXGBE_RXPBSIZE_48KB; 1409 /* Fall Through */ 1410 case PBA_STRATEGY_EQUAL: 1411 default: 1412 /* Divide the remaining Rx packet buffer evenly among the TCs */ 1413 for (; i < IXGBE_MAX_PACKET_BUFFERS; i++) 1414 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize); 1415 break; 1416 } 1417 1418 /* Setup Tx packet buffer sizes */ 1419 for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++) 1420 IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), IXGBE_TXPBSIZE_40KB); 1421} 1422 1423/** 1424 * ixgbe_enable_rx_dma_82598 - Enable the Rx DMA unit 1425 * @hw: pointer to hardware structure 1426 * @regval: register value to write to RXCTRL 1427 * 1428 * Enables the Rx DMA unit 1429 **/ 1430s32 ixgbe_enable_rx_dma_82598(struct ixgbe_hw *hw, u32 regval) 1431{ 1432 DEBUGFUNC("ixgbe_enable_rx_dma_82598"); 1433 1434 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval); 1435 1436 return IXGBE_SUCCESS; 1437} 1438