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_82598.c
          +++ new/usr/src/uts/common/io/ixgbe/ixgbe_82598.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 ↓ 28 lines elided ↑ open up ↑
  42   42                                               ixgbe_link_speed *speed,
  43   43                                               bool *autoneg);
  44   44  static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw);
  45   45  static s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw,
  46   46                                        bool autoneg_wait_to_complete);
  47   47  static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
  48   48                                        ixgbe_link_speed *speed, bool *link_up,
  49   49                                        bool link_up_wait_to_complete);
  50   50  static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
  51   51                                        ixgbe_link_speed speed,
  52      -                                      bool autoneg,
  53   52                                        bool autoneg_wait_to_complete);
  54   53  static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
  55   54                                           ixgbe_link_speed speed,
  56      -                                         bool autoneg,
  57   55                                           bool autoneg_wait_to_complete);
  58   56  static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw);
  59   57  static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
  60   58  static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw);
  61   59  static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb,
  62   60                                    u32 headroom, int strategy);
  63      -
       61 +static s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset,
       62 +                                        u8 *sff8472_data);
  64   63  /**
  65   64   *  ixgbe_set_pcie_completion_timeout - set pci-e completion timeout
  66   65   *  @hw: pointer to the HW structure
  67   66   *
  68   67   *  The defaults for 82598 should be in the range of 50us to 50ms,
  69   68   *  however the hardware default for these parts is 500us to 1ms which is less
  70   69   *  than the 10ms recommended by the pci-e spec.  To address this we need to
  71   70   *  increase the value to either 10ms to 250ms for capability version 1 config,
  72   71   *  or 16ms to 55ms for version 2.
  73   72   **/
↓ open down ↓ 74 lines elided ↑ open up ↑
 148  147          mac->mcft_size          = 128;
 149  148          mac->vft_size           = 128;
 150  149          mac->num_rar_entries    = 16;
 151  150          mac->rx_pb_size         = 512;
 152  151          mac->max_tx_queues      = 32;
 153  152          mac->max_rx_queues      = 64;
 154  153          mac->max_msix_vectors   = ixgbe_get_pcie_msix_count_generic(hw);
 155  154  
 156  155          /* SFP+ Module */
 157  156          phy->ops.read_i2c_eeprom = &ixgbe_read_i2c_eeprom_82598;
      157 +        phy->ops.read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_82598;
 158  158  
 159  159          /* Link */
 160  160          mac->ops.check_link = &ixgbe_check_mac_link_82598;
 161  161          mac->ops.setup_link = &ixgbe_setup_mac_link_82598;
 162  162          mac->ops.flap_tx_laser = NULL;
 163  163          mac->ops.get_link_capabilities = &ixgbe_get_link_capabilities_82598;
 164  164          mac->ops.setup_rxpba = &ixgbe_set_rxpba_82598;
 165  165  
 166  166          /* Manageability interface */
 167  167          mac->ops.set_fw_drv_ver = NULL;
↓ open down ↓ 542 lines elided ↑ open up ↑
 710  710  /**
 711  711   *  ixgbe_setup_mac_link_82598 - Set MAC link speed
 712  712   *  @hw: pointer to hardware structure
 713  713   *  @speed: new link speed
 714  714   *  @autoneg: TRUE if autonegotiation enabled
 715  715   *  @autoneg_wait_to_complete: TRUE when waiting for completion is needed
 716  716   *
 717  717   *  Set the link speed in the AUTOC register and restarts link.
 718  718   **/
 719  719  static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
 720      -                                      ixgbe_link_speed speed, bool autoneg,
      720 +                                      ixgbe_link_speed speed,
 721  721                                        bool autoneg_wait_to_complete)
 722  722  {
      723 +        bool autoneg = FALSE;
 723  724          s32 status;
 724  725          ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
 725  726          u32 curr_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
 726  727          u32 autoc = curr_autoc;
 727  728          u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
 728  729  
 729  730          DEBUGFUNC("ixgbe_setup_mac_link_82598");
 730  731  
 731  732          /* Check to see if speed passed in is supported. */
 732  733          status = ixgbe_get_link_capabilities(hw, &link_capabilities, &autoneg);
↓ open down ↓ 27 lines elided ↑ open up ↑
 760  761          }
 761  762  
 762  763          return status;
 763  764  }
 764  765  
 765  766  
 766  767  /**
 767  768   *  ixgbe_setup_copper_link_82598 - Set the PHY autoneg advertised field
 768  769   *  @hw: pointer to hardware structure
 769  770   *  @speed: new link speed
 770      - *  @autoneg: TRUE if autonegotiation enabled
 771  771   *  @autoneg_wait_to_complete: TRUE if waiting is needed to complete
 772  772   *
 773  773   *  Sets the link speed in the AUTOC register in the MAC and restarts link.
 774  774   **/
 775  775  static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
 776  776                                           ixgbe_link_speed speed,
 777      -                                         bool autoneg,
 778  777                                           bool autoneg_wait_to_complete)
 779  778  {
 780  779          s32 status;
 781  780  
 782  781          DEBUGFUNC("ixgbe_setup_copper_link_82598");
 783  782  
 784  783          /* Setup the PHY according to input speed */
 785      -        status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
      784 +        status = hw->phy.ops.setup_link_speed(hw, speed,
 786  785                                                autoneg_wait_to_complete);
 787  786          if (status == IXGBE_SUCCESS) {
 788  787                  /* Set up MAC */
 789  788                  status =
 790  789                      ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
 791  790          }
 792  791  
 793  792          return status;
 794  793  }
 795  794  
↓ open down ↓ 303 lines elided ↑ open up ↑
1099 1098  
1100 1099          atlas_ctl = (reg << 8) | val;
1101 1100          IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);
1102 1101          IXGBE_WRITE_FLUSH(hw);
1103 1102          usec_delay(10);
1104 1103  
1105 1104          return IXGBE_SUCCESS;
1106 1105  }
1107 1106  
1108 1107  /**
1109      - *  ixgbe_read_i2c_eeprom_82598 - Reads 8 bit word over I2C interface.
     1108 + *  ixgbe_read_i2c_phy_82598 - Reads 8 bit word over I2C interface.
1110 1109   *  @hw: pointer to hardware structure
1111      - *  @byte_offset: EEPROM byte offset to read
     1110 + *  @dev_addr: address to read from
     1111 + *  @byte_offset: byte offset to read from dev_addr
1112 1112   *  @eeprom_data: value read
1113 1113   *
1114 1114   *  Performs 8 byte read operation to SFP module's EEPROM over I2C interface.
1115 1115   **/
1116      -s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
1117      -                                u8 *eeprom_data)
     1116 +static s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr,
     1117 +                                    u8 byte_offset, u8 *eeprom_data)
1118 1118  {
1119 1119          s32 status = IXGBE_SUCCESS;
1120 1120          u16 sfp_addr = 0;
1121 1121          u16 sfp_data = 0;
1122 1122          u16 sfp_stat = 0;
1123 1123          u32 i;
1124 1124  
1125      -        DEBUGFUNC("ixgbe_read_i2c_eeprom_82598");
     1125 +        DEBUGFUNC("ixgbe_read_i2c_phy_82598");
1126 1126  
1127 1127          if (hw->phy.type == ixgbe_phy_nl) {
1128 1128                  /*
1129 1129                   * NetLogic phy SDA/SCL registers are at addresses 0xC30A to
1130 1130                   * 0xC30D. These registers are used to talk to the SFP+
1131 1131                   * module's EEPROM through the SDA/SCL (I2C) interface.
1132 1132                   */
1133      -                sfp_addr = (IXGBE_I2C_EEPROM_DEV_ADDR << 8) + byte_offset;
     1133 +                sfp_addr = (dev_addr << 8) + byte_offset;
1134 1134                  sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK);
1135 1135                  hw->phy.ops.write_reg(hw,
1136 1136                                        IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR,
1137 1137                                        IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1138 1138                                        sfp_addr);
1139 1139  
1140 1140                  /* Poll status */
1141 1141                  for (i = 0; i < 100; i++) {
1142 1142                          hw->phy.ops.read_reg(hw,
1143 1143                                               IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT,
↓ open down ↓ 11 lines elided ↑ open up ↑
1155 1155                          goto out;
1156 1156                  }
1157 1157  
1158 1158                  /* Read data */
1159 1159                  hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA,
1160 1160                                       IXGBE_MDIO_PMA_PMD_DEV_TYPE, &sfp_data);
1161 1161  
1162 1162                  *eeprom_data = (u8)(sfp_data >> 8);
1163 1163          } else {
1164 1164                  status = IXGBE_ERR_PHY;
1165      -                goto out;
1166 1165          }
1167 1166  
1168 1167  out:
1169 1168          return status;
1170 1169  }
1171 1170  
     1171 +/**
     1172 + *  ixgbe_read_i2c_eeprom_82598 - Reads 8 bit word over I2C interface.
     1173 + *  @hw: pointer to hardware structure
     1174 + *  @byte_offset: EEPROM byte offset to read
     1175 + *  @eeprom_data: value read
     1176 + *
     1177 + *  Performs 8 byte read operation to SFP module's EEPROM over I2C interface.
     1178 + **/
     1179 +s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
     1180 +                                u8 *eeprom_data)
     1181 +{
     1182 +        return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR,
     1183 +                                        byte_offset, eeprom_data);
     1184 +}
     1185 +
     1186 +/**
     1187 + *  ixgbe_read_i2c_sff8472_82598 - Reads 8 bit word over I2C interface.
     1188 + *  @hw: pointer to hardware structure
     1189 + *  @byte_offset: byte offset at address 0xA2
     1190 + *  @eeprom_data: value read
     1191 + *
     1192 + *  Performs 8 byte read operation to SFP module's SFF-8472 data over I2C
     1193 + **/
     1194 +static s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset,
     1195 +                                        u8 *sff8472_data)
     1196 +{
     1197 +        return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR2,
     1198 +                                        byte_offset, sff8472_data);
     1199 +}
     1200 +
1172 1201  /**
1173 1202   *  ixgbe_get_supported_physical_layer_82598 - Returns physical layer type
1174 1203   *  @hw: pointer to hardware structure
1175 1204   *
1176 1205   *  Determines physical layer capabilities of the current configuration.
1177 1206   **/
1178 1207  u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
1179 1208  {
1180 1209          u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1181 1210          u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
↓ open down ↓ 196 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX