Print this page
Import some changes from FreeBSD (details later, this is quick-n-dirty for now).

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ixgbe/ixgbe_82599.c
          +++ new/usr/src/uts/common/io/ixgbe/ixgbe_82599.c
   1    1  /******************************************************************************
   2    2  
   3      -  Copyright (c) 2001-2012, Intel Corporation 
        3 +  Copyright (c) 2001-2013, Intel Corporation 
   4    4    All rights reserved.
   5    5    
   6    6    Redistribution and use in source and binary forms, with or without 
   7    7    modification, are permitted provided that the following conditions are met:
   8    8    
   9    9     1. Redistributions of source code must retain the above copyright notice, 
  10   10        this list of conditions and the following disclaimer.
  11   11    
  12   12     2. Redistributions in binary form must reproduce the above copyright 
  13   13        notice, this list of conditions and the following disclaimer in the 
↓ open down ↓ 19 lines elided ↑ open up ↑
  33   33  /*$FreeBSD: src/sys/dev/ixgbe/ixgbe_82599.c,v 1.8 2012/07/05 20:51:44 jfv Exp $*/
  34   34  
  35   35  #include "ixgbe_type.h"
  36   36  #include "ixgbe_82599.h"
  37   37  #include "ixgbe_api.h"
  38   38  #include "ixgbe_common.h"
  39   39  #include "ixgbe_phy.h"
  40   40  
  41   41  static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
  42   42                                           ixgbe_link_speed speed,
  43      -                                         bool autoneg,
  44   43                                           bool autoneg_wait_to_complete);
  45   44  static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw);
  46   45  static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
  47   46                                     u16 offset, u16 *data);
  48   47  static s32 ixgbe_read_eeprom_buffer_82599(struct ixgbe_hw *hw, u16 offset,
  49   48                                            u16 words, u16 *data);
  50   49  
       50 +static bool ixgbe_mng_enabled(struct ixgbe_hw *hw)
       51 +{
       52 +        u32 fwsm, manc, factps;
       53 +
       54 +        fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
       55 +        if ((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT)
       56 +                return FALSE;
       57 +
       58 +        manc = IXGBE_READ_REG(hw, IXGBE_MANC);
       59 +        if (!(manc & IXGBE_MANC_RCV_TCO_EN))
       60 +                return FALSE;
       61 +
       62 +        factps = IXGBE_READ_REG(hw, IXGBE_FACTPS);
       63 +        if (factps & IXGBE_FACTPS_MNGCG)
       64 +                return FALSE;
       65 +
       66 +        return TRUE;
       67 +}
       68 +
  51   69  void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
  52   70  {
  53   71          struct ixgbe_mac_info *mac = &hw->mac;
  54   72  
  55   73          DEBUGFUNC("ixgbe_init_mac_link_ops_82599");
  56   74  
  57      -        /* enable the laser control functions for SFP+ fiber */
  58      -        if (mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) {
       75 +        /*
       76 +         * enable the laser control functions for SFP+ fiber
       77 +         * and MNG not enabled
       78 +         */
       79 +        if ((mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) &&
       80 +            !(ixgbe_mng_enabled(hw))) {
  59   81                  mac->ops.disable_tx_laser =
  60   82                                         &ixgbe_disable_tx_laser_multispeed_fiber;
  61   83                  mac->ops.enable_tx_laser =
  62   84                                          &ixgbe_enable_tx_laser_multispeed_fiber;
  63   85                  mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
  64   86  
  65   87          } else {
  66   88                  mac->ops.disable_tx_laser = NULL;
  67   89                  mac->ops.enable_tx_laser = NULL;
  68   90                  mac->ops.flap_tx_laser = NULL;
↓ open down ↓ 59 lines elided ↑ open up ↑
 128  150          default:
 129  151                  break;
 130  152          }
 131  153  init_phy_ops_out:
 132  154          return ret_val;
 133  155  }
 134  156  
 135  157  s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
 136  158  {
 137  159          s32 ret_val = IXGBE_SUCCESS;
 138      -        u32 reg_anlp1 = 0;
 139      -        u32 i = 0;
 140  160          u16 list_offset, data_offset, data_value;
      161 +        bool got_lock = FALSE;
 141  162  
 142  163          DEBUGFUNC("ixgbe_setup_sfp_modules_82599");
 143  164  
 144  165          if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
 145  166                  ixgbe_init_mac_link_ops_82599(hw);
 146  167  
 147  168                  hw->phy.ops.reset = NULL;
 148  169  
 149  170                  ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
 150  171                                                                &data_offset);
↓ open down ↓ 13 lines elided ↑ open up ↑
 164  185                          IXGBE_WRITE_REG(hw, IXGBE_CORECTL, data_value);
 165  186                          IXGBE_WRITE_FLUSH(hw);
 166  187                          hw->eeprom.ops.read(hw, ++data_offset, &data_value);
 167  188                  }
 168  189  
 169  190                  /* Release the semaphore */
 170  191                  hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
 171  192                  /* Delay obtaining semaphore again to allow FW access */
 172  193                  msec_delay(hw->eeprom.semaphore_delay);
 173  194  
 174      -                /* Now restart DSP by setting Restart_AN and clearing LMS */
 175      -                IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((IXGBE_READ_REG(hw,
 176      -                                IXGBE_AUTOC) & ~IXGBE_AUTOC_LMS_MASK) |
 177      -                                IXGBE_AUTOC_AN_RESTART));
      195 +                /* Need SW/FW semaphore around AUTOC writes if LESM on,
      196 +                 * likewise reset_pipeline requires lock as it also writes
      197 +                 * AUTOC.
      198 +                 */
      199 +                if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
      200 +                        ret_val = hw->mac.ops.acquire_swfw_sync(hw,
      201 +                                                        IXGBE_GSSR_MAC_CSR_SM);
      202 +                        if (ret_val != IXGBE_SUCCESS) {
      203 +                                ret_val = IXGBE_ERR_SWFW_SYNC;
      204 +                                goto setup_sfp_out;
      205 +                        }
 178  206  
 179      -                /* Wait for AN to leave state 0 */
 180      -                for (i = 0; i < 10; i++) {
 181      -                        msec_delay(4);
 182      -                        reg_anlp1 = IXGBE_READ_REG(hw, IXGBE_ANLP1);
 183      -                        if (reg_anlp1 & IXGBE_ANLP1_AN_STATE_MASK)
 184      -                                break;
      207 +                        got_lock = TRUE;
 185  208                  }
 186      -                if (!(reg_anlp1 & IXGBE_ANLP1_AN_STATE_MASK)) {
      209 +
      210 +                /* Restart DSP and set SFI mode */
      211 +                IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((hw->mac.orig_autoc) |
      212 +                                IXGBE_AUTOC_LMS_10G_SERIAL));
      213 +                hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
      214 +                ret_val = ixgbe_reset_pipeline_82599(hw);
      215 +
      216 +                if (got_lock) {
      217 +                        hw->mac.ops.release_swfw_sync(hw,
      218 +                                                      IXGBE_GSSR_MAC_CSR_SM);
      219 +                        got_lock = FALSE;
      220 +                }
      221 +
      222 +                if (ret_val) {
 187  223                          DEBUGOUT("sfp module setup not complete\n");
 188  224                          ret_val = IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
 189  225                          goto setup_sfp_out;
 190  226                  }
 191  227  
 192      -                /* Restart DSP by setting Restart_AN and return to SFI mode */
 193      -                IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (IXGBE_READ_REG(hw,
 194      -                                IXGBE_AUTOC) | IXGBE_AUTOC_LMS_10G_SERIAL |
 195      -                                IXGBE_AUTOC_AN_RESTART));
 196  228          }
 197  229  
 198  230  setup_sfp_out:
 199  231          return ret_val;
 200  232  }
 201  233  
 202  234  /**
 203  235   *  ixgbe_init_ops_82599 - Inits func ptrs and MAC type
 204  236   *  @hw: pointer to hardware structure
 205  237   *
↓ open down ↓ 3 lines elided ↑ open up ↑
 209  241  
 210  242  s32 ixgbe_init_ops_82599(struct ixgbe_hw *hw)
 211  243  {
 212  244          struct ixgbe_mac_info *mac = &hw->mac;
 213  245          struct ixgbe_phy_info *phy = &hw->phy;
 214  246          struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
 215  247          s32 ret_val;
 216  248  
 217  249          DEBUGFUNC("ixgbe_init_ops_82599");
 218  250  
 219      -        ret_val = ixgbe_init_phy_ops_generic(hw);
      251 +        (void) ixgbe_init_phy_ops_generic(hw);
 220  252          ret_val = ixgbe_init_ops_generic(hw);
 221  253  
 222  254          /* PHY */
 223  255          phy->ops.identify = &ixgbe_identify_phy_82599;
 224  256          phy->ops.init = &ixgbe_init_phy_ops_82599;
 225  257  
 226  258          /* MAC */
 227  259          mac->ops.reset_hw = &ixgbe_reset_hw_82599;
 228  260          mac->ops.enable_relaxed_ordering = &ixgbe_enable_relaxed_ordering_gen2;
 229  261          mac->ops.get_media_type = &ixgbe_get_media_type_82599;
↓ open down ↓ 52 lines elided ↑ open up ↑
 282  314          mac->ops.set_fw_drv_ver = &ixgbe_set_fw_drv_ver_generic;
 283  315  
 284  316  
 285  317          return ret_val;
 286  318  }
 287  319  
 288  320  /**
 289  321   *  ixgbe_get_link_capabilities_82599 - Determines link capabilities
 290  322   *  @hw: pointer to hardware structure
 291  323   *  @speed: pointer to link speed
 292      - *  @negotiation: TRUE when autoneg or autotry is enabled
      324 + *  @autoneg: TRUE when autoneg or autotry is enabled
 293  325   *
 294  326   *  Determines the link capabilities by reading the AUTOC register.
 295  327   **/
 296  328  s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
 297  329                                        ixgbe_link_speed *speed,
 298      -                                      bool *negotiation)
      330 +                                      bool *autoneg)
 299  331  {
 300  332          s32 status = IXGBE_SUCCESS;
 301  333          u32 autoc = 0;
 302  334  
 303  335          DEBUGFUNC("ixgbe_get_link_capabilities_82599");
 304  336  
 305  337  
 306  338          /* Check if 1G SFP module. */
 307  339          if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
 308  340              hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
 309  341              hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
 310  342              hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
 311  343                  *speed = IXGBE_LINK_SPEED_1GB_FULL;
 312      -                *negotiation = TRUE;
      344 +                *autoneg = TRUE;
 313  345                  goto out;
 314  346          }
 315  347  
 316  348          /*
 317  349           * Determine link capabilities based on the stored value of AUTOC,
 318  350           * which represents EEPROM defaults.  If AUTOC value has not
 319  351           * been stored, use the current register values.
 320  352           */
 321  353          if (hw->mac.orig_link_settings_stored)
 322  354                  autoc = hw->mac.orig_autoc;
 323  355          else
 324  356                  autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
 325  357  
 326  358          switch (autoc & IXGBE_AUTOC_LMS_MASK) {
 327  359          case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
 328  360                  *speed = IXGBE_LINK_SPEED_1GB_FULL;
 329      -                *negotiation = FALSE;
      361 +                *autoneg = FALSE;
 330  362                  break;
 331  363  
 332  364          case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
 333  365                  *speed = IXGBE_LINK_SPEED_10GB_FULL;
 334      -                *negotiation = FALSE;
      366 +                *autoneg = FALSE;
 335  367                  break;
 336  368  
 337  369          case IXGBE_AUTOC_LMS_1G_AN:
 338  370                  *speed = IXGBE_LINK_SPEED_1GB_FULL;
 339      -                *negotiation = TRUE;
      371 +                *autoneg = TRUE;
 340  372                  break;
 341  373  
 342  374          case IXGBE_AUTOC_LMS_10G_SERIAL:
 343  375                  *speed = IXGBE_LINK_SPEED_10GB_FULL;
 344      -                *negotiation = FALSE;
      376 +                *autoneg = FALSE;
 345  377                  break;
 346  378  
 347  379          case IXGBE_AUTOC_LMS_KX4_KX_KR:
 348  380          case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
 349  381                  *speed = IXGBE_LINK_SPEED_UNKNOWN;
 350  382                  if (autoc & IXGBE_AUTOC_KR_SUPP)
 351  383                          *speed |= IXGBE_LINK_SPEED_10GB_FULL;
 352  384                  if (autoc & IXGBE_AUTOC_KX4_SUPP)
 353  385                          *speed |= IXGBE_LINK_SPEED_10GB_FULL;
 354  386                  if (autoc & IXGBE_AUTOC_KX_SUPP)
 355  387                          *speed |= IXGBE_LINK_SPEED_1GB_FULL;
 356      -                *negotiation = TRUE;
      388 +                *autoneg = TRUE;
 357  389                  break;
 358  390  
 359  391          case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
 360  392                  *speed = IXGBE_LINK_SPEED_100_FULL;
 361  393                  if (autoc & IXGBE_AUTOC_KR_SUPP)
 362  394                          *speed |= IXGBE_LINK_SPEED_10GB_FULL;
 363  395                  if (autoc & IXGBE_AUTOC_KX4_SUPP)
 364  396                          *speed |= IXGBE_LINK_SPEED_10GB_FULL;
 365  397                  if (autoc & IXGBE_AUTOC_KX_SUPP)
 366  398                          *speed |= IXGBE_LINK_SPEED_1GB_FULL;
 367      -                *negotiation = TRUE;
      399 +                *autoneg = TRUE;
 368  400                  break;
 369  401  
 370  402          case IXGBE_AUTOC_LMS_SGMII_1G_100M:
 371  403                  *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
 372      -                *negotiation = FALSE;
      404 +                *autoneg = FALSE;
 373  405                  break;
 374  406  
 375  407          default:
 376  408                  status = IXGBE_ERR_LINK_SETUP;
 377  409                  goto out;
 378  410          }
 379  411  
 380  412          if (hw->phy.multispeed_fiber) {
 381  413                  *speed |= IXGBE_LINK_SPEED_10GB_FULL |
 382  414                            IXGBE_LINK_SPEED_1GB_FULL;
 383      -                *negotiation = TRUE;
      415 +                *autoneg = TRUE;
 384  416          }
 385  417  
 386  418  out:
 387  419          return status;
 388  420  }
 389  421  
 390  422  /**
 391  423   *  ixgbe_get_media_type_82599 - Get media type
 392  424   *  @hw: pointer to hardware structure
 393  425   *
↓ open down ↓ 22 lines elided ↑ open up ↑
 416  448          case IXGBE_DEV_ID_82599_KR:
 417  449          case IXGBE_DEV_ID_82599_BACKPLANE_FCOE:
 418  450          case IXGBE_DEV_ID_82599_XAUI_LOM:
 419  451                  /* Default device ID is mezzanine card KX/KX4 */
 420  452                  media_type = ixgbe_media_type_backplane;
 421  453                  break;
 422  454          case IXGBE_DEV_ID_82599_SFP:
 423  455          case IXGBE_DEV_ID_82599_SFP_FCOE:
 424  456          case IXGBE_DEV_ID_82599_SFP_EM:
 425  457          case IXGBE_DEV_ID_82599_SFP_SF2:
      458 +        case IXGBE_DEV_ID_82599_SFP_SF_QP:
 426  459          case IXGBE_DEV_ID_82599EN_SFP:
 427  460                  media_type = ixgbe_media_type_fiber;
 428  461                  break;
 429  462          case IXGBE_DEV_ID_82599_CX4:
 430  463                  media_type = ixgbe_media_type_cx4;
 431  464                  break;
 432  465          case IXGBE_DEV_ID_82599_T3_LOM:
 433  466                  media_type = ixgbe_media_type_copper;
 434  467                  break;
      468 +        case IXGBE_DEV_ID_82599_BYPASS:
      469 +                media_type = ixgbe_media_type_fiber_fixed;
      470 +                hw->phy.multispeed_fiber = TRUE;
      471 +                break;
 435  472          default:
 436  473                  media_type = ixgbe_media_type_unknown;
 437  474                  break;
 438  475          }
 439  476  out:
 440  477          return media_type;
 441  478  }
 442  479  
 443  480  /**
 444  481   *  ixgbe_start_mac_link_82599 - Setup MAC link settings
↓ open down ↓ 3 lines elided ↑ open up ↑
 448  485   *  Configures link settings based on values in the ixgbe_hw struct.
 449  486   *  Restarts the link.  Performs autonegotiation if needed.
 450  487   **/
 451  488  s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
 452  489                                 bool autoneg_wait_to_complete)
 453  490  {
 454  491          u32 autoc_reg;
 455  492          u32 links_reg;
 456  493          u32 i;
 457  494          s32 status = IXGBE_SUCCESS;
      495 +        bool got_lock = FALSE;
 458  496  
 459  497          DEBUGFUNC("ixgbe_start_mac_link_82599");
 460  498  
 461  499  
      500 +        /*  reset_pipeline requires us to hold this lock as it writes to
      501 +         *  AUTOC.
      502 +         */
      503 +        if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
      504 +                status = hw->mac.ops.acquire_swfw_sync(hw,
      505 +                                                       IXGBE_GSSR_MAC_CSR_SM);
      506 +                if (status != IXGBE_SUCCESS)
      507 +                        goto out;
      508 +
      509 +                got_lock = TRUE;
      510 +        }
      511 +
 462  512          /* Restart link */
 463      -        autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
 464      -        autoc_reg |= IXGBE_AUTOC_AN_RESTART;
 465      -        IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
      513 +        (void) ixgbe_reset_pipeline_82599(hw);
 466  514  
      515 +        if (got_lock)
      516 +                hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
      517 +
 467  518          /* Only poll for autoneg to complete if specified to do so */
 468  519          if (autoneg_wait_to_complete) {
      520 +                autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
 469  521                  if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
 470  522                       IXGBE_AUTOC_LMS_KX4_KX_KR ||
 471  523                      (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
 472  524                       IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
 473  525                      (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
 474  526                       IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
 475  527                          links_reg = 0; /* Just in case Autoneg time = 0 */
 476  528                          for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
 477  529                                  links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
 478  530                                  if (links_reg & IXGBE_LINKS_KX_AN_COMP)
↓ open down ↓ 3 lines elided ↑ open up ↑
 482  534                          if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
 483  535                                  status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
 484  536                                  DEBUGOUT("Autoneg did not complete.\n");
 485  537                          }
 486  538                  }
 487  539          }
 488  540  
 489  541          /* Add delay to filter out noises during initial link setup */
 490  542          msec_delay(50);
 491  543  
      544 +out:
 492  545          return status;
 493  546  }
 494  547  
 495  548  /**
 496  549   *  ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
 497  550   *  @hw: pointer to hardware structure
 498  551   *
 499  552   *  The base drivers may require better control over SFP+ module
 500  553   *  PHY states.  This includes selectively shutting down the Tx
 501  554   *  laser on the PHY, effectively halting physical link.
↓ open down ↓ 45 lines elided ↑ open up ↑
 547  600          DEBUGFUNC("ixgbe_flap_tx_laser_multispeed_fiber");
 548  601  
 549  602          if (hw->mac.autotry_restart) {
 550  603                  ixgbe_disable_tx_laser_multispeed_fiber(hw);
 551  604                  ixgbe_enable_tx_laser_multispeed_fiber(hw);
 552  605                  hw->mac.autotry_restart = FALSE;
 553  606          }
 554  607  }
 555  608  
 556  609  /**
      610 + *  ixgbe_set_fiber_fixed_speed - Set module link speed for fixed fiber
      611 + *  @hw: pointer to hardware structure
      612 + *  @speed: link speed to set
      613 + *
      614 + *  We set the module speed differently for fixed fiber.  For other
      615 + *  multi-speed devices we don't have an error value so here if we
      616 + *  detect an error we just log it and exit.
      617 + */
      618 +static void ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw,
      619 +                                        ixgbe_link_speed speed)
      620 +{
      621 +        s32 status;
      622 +        u8 rs, eeprom_data;
      623 +
      624 +        switch (speed) {
      625 +        case IXGBE_LINK_SPEED_10GB_FULL:
      626 +                /* one bit mask same as setting on */
      627 +                rs = IXGBE_SFF_SOFT_RS_SELECT_10G;
      628 +                break;
      629 +        case IXGBE_LINK_SPEED_1GB_FULL:
      630 +                rs = IXGBE_SFF_SOFT_RS_SELECT_1G;
      631 +                break;
      632 +        default:
      633 +                DEBUGOUT("Invalid fixed module speed\n");
      634 +                return;
      635 +        }
      636 +
      637 +        /* Set RS0 */
      638 +        status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
      639 +                                           IXGBE_I2C_EEPROM_DEV_ADDR2,
      640 +                                           &eeprom_data);
      641 +        if (status) {
      642 +                DEBUGOUT("Failed to read Rx Rate Select RS0\n");
      643 +                goto out;
      644 +        }
      645 +
      646 +        eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
      647 +
      648 +        status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
      649 +                                            IXGBE_I2C_EEPROM_DEV_ADDR2,
      650 +                                            eeprom_data);
      651 +        if (status) {
      652 +                DEBUGOUT("Failed to write Rx Rate Select RS0\n");
      653 +                goto out;
      654 +        }
      655 +
      656 +        /* Set RS1 */
      657 +        status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
      658 +                                           IXGBE_I2C_EEPROM_DEV_ADDR2,
      659 +                                           &eeprom_data);
      660 +        if (status) {
      661 +                DEBUGOUT("Failed to read Rx Rate Select RS1\n");
      662 +                goto out;
      663 +        }
      664 +
      665 +        eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
      666 +
      667 +        status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
      668 +                                            IXGBE_I2C_EEPROM_DEV_ADDR2,
      669 +                                            eeprom_data);
      670 +        if (status) {
      671 +                DEBUGOUT("Failed to write Rx Rate Select RS1\n");
      672 +                goto out;
      673 +        }
      674 +out:
      675 +        return;
      676 +}
      677 +
      678 +/**
 557  679   *  ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
 558  680   *  @hw: pointer to hardware structure
 559  681   *  @speed: new link speed
 560      - *  @autoneg: TRUE if autonegotiation enabled
 561  682   *  @autoneg_wait_to_complete: TRUE when waiting for completion is needed
 562  683   *
 563  684   *  Set the link speed in the AUTOC register and restarts link.
 564  685   **/
 565  686  s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
 566      -                                     ixgbe_link_speed speed, bool autoneg,
      687 +                                     ixgbe_link_speed speed,
 567  688                                       bool autoneg_wait_to_complete)
 568  689  {
 569  690          s32 status = IXGBE_SUCCESS;
 570  691          ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 571  692          ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 572  693          u32 speedcnt = 0;
 573  694          u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
 574  695          u32 i = 0;
 575      -        bool link_up = FALSE;
 576      -        bool negotiation;
      696 +        bool autoneg, link_up = FALSE;
 577  697  
 578  698          DEBUGFUNC("ixgbe_setup_mac_link_multispeed_fiber");
 579  699  
 580  700          /* Mask off requested but non-supported speeds */
 581      -        status = ixgbe_get_link_capabilities(hw, &link_speed, &negotiation);
      701 +        status = ixgbe_get_link_capabilities(hw, &link_speed, &autoneg);
 582  702          if (status != IXGBE_SUCCESS)
 583  703                  return status;
 584  704  
 585  705          speed &= link_speed;
 586  706  
 587  707          /*
 588  708           * Try each speed one by one, highest priority first.  We do this in
 589  709           * software because 10gb fiber doesn't support speed autonegotiation.
 590  710           */
 591  711          if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
↓ open down ↓ 2 lines elided ↑ open up ↑
 594  714  
 595  715                  /* If we already have link at this speed, just jump out */
 596  716                  status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
 597  717                  if (status != IXGBE_SUCCESS)
 598  718                          return status;
 599  719  
 600  720                  if ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
 601  721                          goto out;
 602  722  
 603  723                  /* Set the module link speed */
 604      -                esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
 605      -                IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
 606      -                IXGBE_WRITE_FLUSH(hw);
      724 +                if (hw->phy.media_type == ixgbe_media_type_fiber_fixed) {
      725 +                        ixgbe_set_fiber_fixed_speed(hw,
      726 +                                                    IXGBE_LINK_SPEED_10GB_FULL);
      727 +                } else {
      728 +                        esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
      729 +                        IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
      730 +                        IXGBE_WRITE_FLUSH(hw);
      731 +                }
 607  732  
 608  733                  /* Allow module to change analog characteristics (1G->10G) */
 609  734                  msec_delay(40);
 610  735  
 611  736                  status = ixgbe_setup_mac_link_82599(hw,
 612  737                                                      IXGBE_LINK_SPEED_10GB_FULL,
 613      -                                                    autoneg,
 614  738                                                      autoneg_wait_to_complete);
 615  739                  if (status != IXGBE_SUCCESS)
 616  740                          return status;
 617  741  
 618  742                  /* Flap the tx laser if it has not already been done */
 619  743                  ixgbe_flap_tx_laser(hw);
 620  744  
 621  745                  /*
 622  746                   * Wait for the controller to acquire link.  Per IEEE 802.3ap,
 623  747                   * Section 73.10.2, we may have to wait up to 500ms if KR is
↓ open down ↓ 21 lines elided ↑ open up ↑
 645  769  
 646  770                  /* If we already have link at this speed, just jump out */
 647  771                  status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
 648  772                  if (status != IXGBE_SUCCESS)
 649  773                          return status;
 650  774  
 651  775                  if ((link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
 652  776                          goto out;
 653  777  
 654  778                  /* Set the module link speed */
 655      -                esdp_reg &= ~IXGBE_ESDP_SDP5;
 656      -                esdp_reg |= IXGBE_ESDP_SDP5_DIR;
 657      -                IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
 658      -                IXGBE_WRITE_FLUSH(hw);
      779 +                if (hw->phy.media_type == ixgbe_media_type_fiber_fixed) {
      780 +                        ixgbe_set_fiber_fixed_speed(hw,
      781 +                                                    IXGBE_LINK_SPEED_1GB_FULL);
      782 +                } else {
      783 +                        esdp_reg &= ~IXGBE_ESDP_SDP5;
      784 +                        esdp_reg |= IXGBE_ESDP_SDP5_DIR;
      785 +                        IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
      786 +                        IXGBE_WRITE_FLUSH(hw);
      787 +                }
 659  788  
 660  789                  /* Allow module to change analog characteristics (10G->1G) */
 661  790                  msec_delay(40);
 662  791  
 663  792                  status = ixgbe_setup_mac_link_82599(hw,
 664  793                                                      IXGBE_LINK_SPEED_1GB_FULL,
 665      -                                                    autoneg,
 666  794                                                      autoneg_wait_to_complete);
 667  795                  if (status != IXGBE_SUCCESS)
 668  796                          return status;
 669  797  
 670  798                  /* Flap the tx laser if it has not already been done */
 671  799                  ixgbe_flap_tx_laser(hw);
 672  800  
 673  801                  /* Wait for the link partner to also set speed */
 674  802                  msec_delay(100);
 675  803  
↓ open down ↓ 6 lines elided ↑ open up ↑
 682  810                          goto out;
 683  811          }
 684  812  
 685  813          /*
 686  814           * We didn't get link.  Configure back to the highest speed we tried,
 687  815           * (if there was more than one).  We call ourselves back with just the
 688  816           * single highest speed that the user requested.
 689  817           */
 690  818          if (speedcnt > 1)
 691  819                  status = ixgbe_setup_mac_link_multispeed_fiber(hw,
 692      -                        highest_link_speed, autoneg, autoneg_wait_to_complete);
      820 +                        highest_link_speed, autoneg_wait_to_complete);
 693  821  
 694  822  out:
 695  823          /* Set autoneg_advertised value based on input link speed */
 696  824          hw->phy.autoneg_advertised = 0;
 697  825  
 698  826          if (speed & IXGBE_LINK_SPEED_10GB_FULL)
 699  827                  hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
 700  828  
 701  829          if (speed & IXGBE_LINK_SPEED_1GB_FULL)
 702  830                  hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
 703  831  
 704  832          return status;
 705  833  }
 706  834  
 707  835  /**
 708  836   *  ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed
 709  837   *  @hw: pointer to hardware structure
 710  838   *  @speed: new link speed
 711      - *  @autoneg: TRUE if autonegotiation enabled
 712  839   *  @autoneg_wait_to_complete: TRUE when waiting for completion is needed
 713  840   *
 714  841   *  Implements the Intel SmartSpeed algorithm.
 715  842   **/
 716  843  s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
 717      -                                    ixgbe_link_speed speed, bool autoneg,
      844 +                                    ixgbe_link_speed speed,
 718  845                                      bool autoneg_wait_to_complete)
 719  846  {
 720  847          s32 status = IXGBE_SUCCESS;
 721  848          ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 722  849          s32 i, j;
 723  850          bool link_up = FALSE;
 724  851          u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
 725  852  
 726  853          DEBUGFUNC("ixgbe_setup_mac_link_smartspeed");
 727  854  
↓ open down ↓ 12 lines elided ↑ open up ↑
 740  867          /*
 741  868           * Implement Intel SmartSpeed algorithm.  SmartSpeed will reduce the
 742  869           * autoneg advertisement if link is unable to be established at the
 743  870           * highest negotiated rate.  This can sometimes happen due to integrity
 744  871           * issues with the physical media connection.
 745  872           */
 746  873  
 747  874          /* First, try to get link with full advertisement */
 748  875          hw->phy.smart_speed_active = FALSE;
 749  876          for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) {
 750      -                status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
      877 +                status = ixgbe_setup_mac_link_82599(hw, speed,
 751  878                                                      autoneg_wait_to_complete);
 752  879                  if (status != IXGBE_SUCCESS)
 753  880                          goto out;
 754  881  
 755  882                  /*
 756  883                   * Wait for the controller to acquire link.  Per IEEE 802.3ap,
 757  884                   * Section 73.10.2, we may have to wait up to 500ms if KR is
 758  885                   * attempted, or 200ms if KX/KX4/BX/BX4 is attempted, per
 759  886                   * Table 9 in the AN MAS.
 760  887                   */
↓ open down ↓ 14 lines elided ↑ open up ↑
 775  902          /*
 776  903           * We didn't get link.  If we advertised KR plus one of KX4/KX
 777  904           * (or BX4/BX), then disable KR and try again.
 778  905           */
 779  906          if (((autoc_reg & IXGBE_AUTOC_KR_SUPP) == 0) ||
 780  907              ((autoc_reg & IXGBE_AUTOC_KX4_KX_SUPP_MASK) == 0))
 781  908                  goto out;
 782  909  
 783  910          /* Turn SmartSpeed on to disable KR support */
 784  911          hw->phy.smart_speed_active = TRUE;
 785      -        status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
      912 +        status = ixgbe_setup_mac_link_82599(hw, speed,
 786  913                                              autoneg_wait_to_complete);
 787  914          if (status != IXGBE_SUCCESS)
 788  915                  goto out;
 789  916  
 790  917          /*
 791  918           * Wait for the controller to acquire link.  600ms will allow for
 792  919           * the AN link_fail_inhibit_timer as well for multiple cycles of
 793  920           * parallel detect, both 10g and 1g. This allows for the maximum
 794  921           * connect attempts as defined in the AN MAS table 73-7.
 795  922           */
↓ open down ↓ 4 lines elided ↑ open up ↑
 800  927                  status = ixgbe_check_link(hw, &link_speed, &link_up, FALSE);
 801  928                  if (status != IXGBE_SUCCESS)
 802  929                          goto out;
 803  930  
 804  931                  if (link_up)
 805  932                          goto out;
 806  933          }
 807  934  
 808  935          /* We didn't get link.  Turn SmartSpeed back off. */
 809  936          hw->phy.smart_speed_active = FALSE;
 810      -        status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
      937 +        status = ixgbe_setup_mac_link_82599(hw, speed,
 811  938                                              autoneg_wait_to_complete);
 812  939  
 813  940  out:
 814  941          if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL))
 815  942                  DEBUGOUT("Smartspeed has downgraded the link speed "
 816  943                  "from the maximum advertised\n");
 817  944          return status;
 818  945  }
 819  946  
 820  947  /**
 821  948   *  ixgbe_setup_mac_link_82599 - Set MAC link speed
 822  949   *  @hw: pointer to hardware structure
 823  950   *  @speed: new link speed
 824      - *  @autoneg: TRUE if autonegotiation enabled
 825  951   *  @autoneg_wait_to_complete: TRUE when waiting for completion is needed
 826  952   *
 827  953   *  Set the link speed in the AUTOC register and restarts link.
 828  954   **/
 829  955  s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
 830      -                               ixgbe_link_speed speed, bool autoneg,
      956 +                               ixgbe_link_speed speed,
 831  957                                 bool autoneg_wait_to_complete)
 832  958  {
      959 +        bool autoneg = FALSE;
 833  960          s32 status = IXGBE_SUCCESS;
 834      -        u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
      961 +        u32 autoc, pma_pmd_1g, link_mode, start_autoc;
 835  962          u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
 836      -        u32 start_autoc = autoc;
 837  963          u32 orig_autoc = 0;
 838      -        u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
 839      -        u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
 840  964          u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
 841  965          u32 links_reg;
 842  966          u32 i;
 843  967          ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
      968 +        bool got_lock = FALSE;
 844  969  
 845  970          DEBUGFUNC("ixgbe_setup_mac_link_82599");
 846  971  
 847  972          /* Check to see if speed passed in is supported. */
 848  973          status = ixgbe_get_link_capabilities(hw, &link_capabilities, &autoneg);
 849      -        if (status != IXGBE_SUCCESS)
      974 +        if (status)
 850  975                  goto out;
 851  976  
 852  977          speed &= link_capabilities;
 853  978  
 854  979          if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
 855  980                  status = IXGBE_ERR_LINK_SETUP;
 856  981                  goto out;
 857  982          }
 858  983  
 859  984          /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
 860  985          if (hw->mac.orig_link_settings_stored)
 861      -                orig_autoc = hw->mac.orig_autoc;
      986 +                autoc = hw->mac.orig_autoc;
 862  987          else
 863      -                orig_autoc = autoc;
      988 +                autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
 864  989  
      990 +        orig_autoc = autoc;
      991 +        start_autoc = hw->mac.cached_autoc;
      992 +        link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
      993 +        pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
      994 +
 865  995          if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
 866  996              link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
 867  997              link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
 868  998                  /* Set KX4/KX/KR support according to speed requested */
 869  999                  autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
 870 1000                  if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
 871 1001                          if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
 872 1002                                  autoc |= IXGBE_AUTOC_KX4_SUPP;
 873 1003                          if ((orig_autoc & IXGBE_AUTOC_KR_SUPP) &&
 874 1004                              (hw->phy.smart_speed_active == FALSE))
↓ open down ↓ 17 lines elided ↑ open up ↑
 892 1022                      (pma_pmd_1g == IXGBE_AUTOC_1G_SFI)) {
 893 1023                          autoc &= ~IXGBE_AUTOC_LMS_MASK;
 894 1024                          if (autoneg)
 895 1025                                  autoc |= IXGBE_AUTOC_LMS_1G_AN;
 896 1026                          else
 897 1027                                  autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
 898 1028                  }
 899 1029          }
 900 1030  
 901 1031          if (autoc != start_autoc) {
     1032 +                /* Need SW/FW semaphore around AUTOC writes if LESM is on,
     1033 +                 * likewise reset_pipeline requires us to hold this lock as
     1034 +                 * it also writes to AUTOC.
     1035 +                 */
     1036 +                if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
     1037 +                        status = hw->mac.ops.acquire_swfw_sync(hw,
     1038 +                                                        IXGBE_GSSR_MAC_CSR_SM);
     1039 +                        if (status != IXGBE_SUCCESS) {
     1040 +                                status = IXGBE_ERR_SWFW_SYNC;
     1041 +                                goto out;
     1042 +                        }
     1043 +
     1044 +                        got_lock = TRUE;
     1045 +                }
     1046 +
 902 1047                  /* Restart link */
 903      -                autoc |= IXGBE_AUTOC_AN_RESTART;
 904 1048                  IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
     1049 +                hw->mac.cached_autoc = autoc;
     1050 +                (void) ixgbe_reset_pipeline_82599(hw);
 905 1051  
     1052 +                if (got_lock) {
     1053 +                        hw->mac.ops.release_swfw_sync(hw,
     1054 +                                                      IXGBE_GSSR_MAC_CSR_SM);
     1055 +                        got_lock = FALSE;
     1056 +                }
     1057 +
 906 1058                  /* Only poll for autoneg to complete if specified to do so */
 907 1059                  if (autoneg_wait_to_complete) {
 908 1060                          if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
 909 1061                              link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
 910 1062                              link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
 911 1063                                  links_reg = 0; /*Just in case Autoneg time=0*/
 912 1064                                  for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
 913 1065                                          links_reg =
 914 1066                                                 IXGBE_READ_REG(hw, IXGBE_LINKS);
 915 1067                                          if (links_reg & IXGBE_LINKS_KX_AN_COMP)
↓ open down ↓ 13 lines elided ↑ open up ↑
 929 1081          }
 930 1082  
 931 1083  out:
 932 1084          return status;
 933 1085  }
 934 1086  
 935 1087  /**
 936 1088   *  ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field
 937 1089   *  @hw: pointer to hardware structure
 938 1090   *  @speed: new link speed
 939      - *  @autoneg: TRUE if autonegotiation enabled
 940 1091   *  @autoneg_wait_to_complete: TRUE if waiting is needed to complete
 941 1092   *
 942 1093   *  Restarts link on PHY and MAC based on settings passed in.
 943 1094   **/
 944 1095  static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
 945 1096                                           ixgbe_link_speed speed,
 946      -                                         bool autoneg,
 947 1097                                           bool autoneg_wait_to_complete)
 948 1098  {
 949 1099          s32 status;
 950 1100  
 951 1101          DEBUGFUNC("ixgbe_setup_copper_link_82599");
 952 1102  
 953 1103          /* Setup the PHY according to input speed */
 954      -        status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
     1104 +        status = hw->phy.ops.setup_link_speed(hw, speed,
 955 1105                                                autoneg_wait_to_complete);
 956      -        if (status == IXGBE_SUCCESS) {
 957      -                /* Set up MAC */
 958      -                status =
 959      -                    ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete);
 960      -        }
     1106 +        /* Set up MAC */
     1107 +        (void) ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete);
 961 1108  
 962 1109          return status;
 963 1110  }
 964 1111  
 965 1112  /**
 966 1113   *  ixgbe_reset_hw_82599 - Perform hardware reset
 967 1114   *  @hw: pointer to hardware structure
 968 1115   *
 969 1116   *  Resets the hardware by resetting the transmit and receive units, masks
 970 1117   *  and clears all interrupts, perform a PHY reset, and perform a link (MAC)
↓ open down ↓ 80 lines elided ↑ open up ↑
1051 1198                  goto mac_reset_top;
1052 1199          }
1053 1200  
1054 1201          /*
1055 1202           * Store the original AUTOC/AUTOC2 values if they have not been
1056 1203           * stored off yet.  Otherwise restore the stored original
1057 1204           * values since the reset operation sets back to defaults.
1058 1205           */
1059 1206          autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1060 1207          autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
     1208 +
     1209 +        /* Enable link if disabled in NVM */
     1210 +        if (autoc2 & IXGBE_AUTOC2_LINK_DISABLE_MASK) {
     1211 +                autoc2 &= ~IXGBE_AUTOC2_LINK_DISABLE_MASK;
     1212 +                IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
     1213 +                IXGBE_WRITE_FLUSH(hw);
     1214 +        }
     1215 +
1061 1216          if (hw->mac.orig_link_settings_stored == FALSE) {
1062 1217                  hw->mac.orig_autoc = autoc;
1063 1218                  hw->mac.orig_autoc2 = autoc2;
     1219 +                hw->mac.cached_autoc = autoc;
1064 1220                  hw->mac.orig_link_settings_stored = TRUE;
1065 1221          } else {
1066      -                if (autoc != hw->mac.orig_autoc)
1067      -                        IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (hw->mac.orig_autoc |
1068      -                                        IXGBE_AUTOC_AN_RESTART));
     1222 +                if (autoc != hw->mac.orig_autoc) {
     1223 +                        /* Need SW/FW semaphore around AUTOC writes if LESM is
     1224 +                         * on, likewise reset_pipeline requires us to hold
     1225 +                         * this lock as it also writes to AUTOC.
     1226 +                         */
     1227 +                        bool got_lock = FALSE;
     1228 +                        if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
     1229 +                                status = hw->mac.ops.acquire_swfw_sync(hw,
     1230 +                                                        IXGBE_GSSR_MAC_CSR_SM);
     1231 +                                if (status != IXGBE_SUCCESS) {
     1232 +                                        status = IXGBE_ERR_SWFW_SYNC;
     1233 +                                        goto reset_hw_out;
     1234 +                                }
1069 1235  
     1236 +                                got_lock = TRUE;
     1237 +                        }
     1238 +
     1239 +                        IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
     1240 +                        hw->mac.cached_autoc = hw->mac.orig_autoc;
     1241 +                        (void) ixgbe_reset_pipeline_82599(hw);
     1242 +
     1243 +                        if (got_lock)
     1244 +                                hw->mac.ops.release_swfw_sync(hw,
     1245 +                                                      IXGBE_GSSR_MAC_CSR_SM);
     1246 +                }
     1247 +
1070 1248                  if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
1071 1249                      (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
1072 1250                          autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
1073 1251                          autoc2 |= (hw->mac.orig_autoc2 &
1074 1252                                     IXGBE_AUTOC2_UPPER_MASK);
1075 1253                          IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
1076 1254                  }
1077 1255          }
1078 1256  
1079 1257          /* Store the permanent mac address */
↓ open down ↓ 83 lines elided ↑ open up ↑
1163 1341          IXGBE_WRITE_FLUSH(hw);
1164 1342  
1165 1343          IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1166 1344          IXGBE_WRITE_FLUSH(hw);
1167 1345  
1168 1346          /* Poll init-done after we write FDIRCTRL register */
1169 1347          for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1170 1348                  if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1171 1349                                     IXGBE_FDIRCTRL_INIT_DONE)
1172 1350                          break;
1173      -                usec_delay(10);
     1351 +                msec_delay(1);
1174 1352          }
1175 1353          if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
1176 1354                  DEBUGOUT("Flow Director Signature poll time exceeded!\n");
1177 1355                  return IXGBE_ERR_FDIR_REINIT_FAILED;
1178 1356          }
1179 1357  
1180 1358          /* Clear FDIR statistics registers (read to clear) */
1181 1359          (void) IXGBE_READ_REG(hw, IXGBE_FDIRUSTAT);
1182 1360          (void) IXGBE_READ_REG(hw, IXGBE_FDIRFSTAT);
1183 1361          (void) IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
↓ open down ↓ 914 lines elided ↑ open up ↑
2098 2276  /**
2099 2277   *  ixgbe_verify_fw_version_82599 - verify fw version for 82599
2100 2278   *  @hw: pointer to hardware structure
2101 2279   *
2102 2280   *  Verifies that installed the firmware version is 0.6 or higher
2103 2281   *  for SFI devices. All 82599 SFI devices should have version 0.6 or higher.
2104 2282   *
2105 2283   *  Returns IXGBE_ERR_EEPROM_VERSION if the FW is not present or
2106 2284   *  if the FW version is not supported.
2107 2285   **/
2108      -static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
     2286 +s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
2109 2287  {
2110 2288          s32 status = IXGBE_ERR_EEPROM_VERSION;
2111 2289          u16 fw_offset, fw_ptp_cfg_offset;
2112 2290          u16 fw_version = 0;
2113 2291  
2114 2292          DEBUGFUNC("ixgbe_verify_fw_version_82599");
2115 2293  
2116 2294          /* firmware check is only necessary for SFI devices */
2117 2295          if (hw->phy.media_type != ixgbe_media_type_fiber) {
2118 2296                  status = IXGBE_SUCCESS;
↓ open down ↓ 128 lines elided ↑ open up ↑
2247 2425           */
2248 2426          if ((eeprom->type == ixgbe_eeprom_spi) &&
2249 2427              (offset <= IXGBE_EERD_MAX_ADDR))
2250 2428                  ret_val = ixgbe_read_eerd_generic(hw, offset, data);
2251 2429          else
2252 2430                  ret_val = ixgbe_read_eeprom_bit_bang_generic(hw, offset, data);
2253 2431  
2254 2432          return ret_val;
2255 2433  }
2256 2434  
     2435 +/**
     2436 + * ixgbe_reset_pipeline_82599 - perform pipeline reset
     2437 + *
     2438 + *  @hw: pointer to hardware structure
     2439 + *
     2440 + * Reset pipeline by asserting Restart_AN together with LMS change to ensure
     2441 + * full pipeline reset
     2442 + **/
     2443 +s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)
     2444 +{
     2445 +        s32 ret_val;
     2446 +        u32 anlp1_reg = 0;
     2447 +        u32 i, autoc_reg, autoc2_reg;
2257 2448  
     2449 +        /* Enable link if disabled in NVM */
     2450 +        autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
     2451 +        if (autoc2_reg & IXGBE_AUTOC2_LINK_DISABLE_MASK) {
     2452 +                autoc2_reg &= ~IXGBE_AUTOC2_LINK_DISABLE_MASK;
     2453 +                IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg);
     2454 +                IXGBE_WRITE_FLUSH(hw);
     2455 +        }
     2456 +
     2457 +        autoc_reg = hw->mac.cached_autoc;
     2458 +        autoc_reg |= IXGBE_AUTOC_AN_RESTART;
     2459 +        /* Write AUTOC register with toggled LMS[2] bit and Restart_AN */
     2460 +        IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg ^ IXGBE_AUTOC_LMS_1G_AN);
     2461 +        /* Wait for AN to leave state 0 */
     2462 +        for (i = 0; i < 10; i++) {
     2463 +                msec_delay(4);
     2464 +                anlp1_reg = IXGBE_READ_REG(hw, IXGBE_ANLP1);
     2465 +                if (anlp1_reg & IXGBE_ANLP1_AN_STATE_MASK)
     2466 +                        break;
     2467 +        }
     2468 +
     2469 +        if (!(anlp1_reg & IXGBE_ANLP1_AN_STATE_MASK)) {
     2470 +                DEBUGOUT("auto negotiation not completed\n");
     2471 +                ret_val = IXGBE_ERR_RESET_FAILED;
     2472 +                goto reset_pipeline_out;
     2473 +        }
     2474 +
     2475 +        ret_val = IXGBE_SUCCESS;
     2476 +
     2477 +reset_pipeline_out:
     2478 +        /* Write AUTOC register with original LMS field and Restart_AN */
     2479 +        IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
     2480 +        IXGBE_WRITE_FLUSH(hw);
     2481 +
     2482 +        return ret_val;
     2483 +}
     2484 +
     2485 +
     2486 +
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX