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_phy.c
          +++ new/usr/src/uts/common/io/ixgbe/ixgbe_phy.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 ↓ 26 lines elided ↑ open up ↑
  40   40  static void ixgbe_i2c_stop(struct ixgbe_hw *hw);
  41   41  static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data);
  42   42  static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data);
  43   43  static s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw);
  44   44  static s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data);
  45   45  static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data);
  46   46  static void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
  47   47  static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
  48   48  static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data);
  49   49  static bool ixgbe_get_i2c_data(u32 *i2cctl);
       50 +static s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
       51 +                                          u8 *sff8472_data);
  50   52  
  51   53  /**
  52   54   *  ixgbe_init_phy_ops_generic - Inits PHY function ptrs
  53   55   *  @hw: pointer to the hardware structure
  54   56   *
  55   57   *  Initialize the function pointers.
  56   58   **/
  57   59  s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
  58   60  {
  59   61          struct ixgbe_phy_info *phy = &hw->phy;
↓ open down ↓ 4 lines elided ↑ open up ↑
  64   66          phy->ops.identify = &ixgbe_identify_phy_generic;
  65   67          phy->ops.reset = &ixgbe_reset_phy_generic;
  66   68          phy->ops.read_reg = &ixgbe_read_phy_reg_generic;
  67   69          phy->ops.write_reg = &ixgbe_write_phy_reg_generic;
  68   70          phy->ops.setup_link = &ixgbe_setup_phy_link_generic;
  69   71          phy->ops.setup_link_speed = &ixgbe_setup_phy_link_speed_generic;
  70   72          phy->ops.check_link = NULL;
  71   73          phy->ops.get_firmware_version = ixgbe_get_phy_firmware_version_generic;
  72   74          phy->ops.read_i2c_byte = &ixgbe_read_i2c_byte_generic;
  73   75          phy->ops.write_i2c_byte = &ixgbe_write_i2c_byte_generic;
       76 +        phy->ops.read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_generic;
  74   77          phy->ops.read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic;
  75   78          phy->ops.write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic;
  76   79          phy->ops.i2c_bus_clear = &ixgbe_i2c_bus_clear;
  77   80          phy->ops.identify_sfp = &ixgbe_identify_module_generic;
  78   81          phy->sfp_type = ixgbe_sfp_type_unknown;
  79   82          phy->ops.check_overtemp = &ixgbe_tn_check_overtemp;
  80   83          return IXGBE_SUCCESS;
  81   84  }
  82   85  
  83   86  /**
↓ open down ↓ 475 lines elided ↑ open up ↑
 559  562                  DEBUGOUT("ixgbe_setup_phy_link_generic: time out");
 560  563          }
 561  564  
 562  565          return status;
 563  566  }
 564  567  
 565  568  /**
 566  569   *  ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
 567  570   *  @hw: pointer to hardware structure
 568  571   *  @speed: new link speed
 569      - *  @autoneg: TRUE if autonegotiation enabled
 570  572   **/
 571  573  s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
 572  574                                         ixgbe_link_speed speed,
 573      -                                       bool autoneg,
 574  575                                         bool autoneg_wait_to_complete)
 575  576  {
 576      -        UNREFERENCED_2PARAMETER(autoneg, autoneg_wait_to_complete);
      577 +        UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
 577  578  
 578  579          DEBUGFUNC("ixgbe_setup_phy_link_speed_generic");
 579  580  
 580  581          /*
 581  582           * Clear autoneg_advertised and set new values based on input link
 582  583           * speed.
 583  584           */
 584  585          hw->phy.autoneg_advertised = 0;
 585  586  
 586  587          if (speed & IXGBE_LINK_SPEED_10GB_FULL)
↓ open down ↓ 381 lines elided ↑ open up ↑
 968  969          if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
 969  970                  hw->phy.sfp_type = ixgbe_sfp_type_not_present;
 970  971                  status = IXGBE_ERR_SFP_NOT_PRESENT;
 971  972                  goto out;
 972  973          }
 973  974  
 974  975          status = hw->phy.ops.read_i2c_eeprom(hw,
 975  976                                               IXGBE_SFF_IDENTIFIER,
 976  977                                               &identifier);
 977  978  
 978      -        if (status == IXGBE_ERR_SWFW_SYNC ||
 979      -            status == IXGBE_ERR_I2C ||
 980      -            status == IXGBE_ERR_SFP_NOT_PRESENT)
      979 +        if (status != IXGBE_SUCCESS)
 981  980                  goto err_read_i2c_eeprom;
 982  981  
 983  982          /* LAN ID is needed for sfp_type determination */
 984  983          hw->mac.ops.set_lan_id(hw);
 985  984  
 986  985          if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
 987  986                  hw->phy.type = ixgbe_phy_sfp_unsupported;
 988  987                  status = IXGBE_ERR_SFP_NOT_SUPPORTED;
 989  988          } else {
 990  989                  status = hw->phy.ops.read_i2c_eeprom(hw,
 991  990                                                       IXGBE_SFF_1GBE_COMP_CODES,
 992  991                                                       &comp_codes_1g);
 993  992  
 994      -                if (status == IXGBE_ERR_SWFW_SYNC ||
 995      -                    status == IXGBE_ERR_I2C ||
 996      -                    status == IXGBE_ERR_SFP_NOT_PRESENT)
      993 +                if (status != IXGBE_SUCCESS)
 997  994                          goto err_read_i2c_eeprom;
 998  995  
 999  996                  status = hw->phy.ops.read_i2c_eeprom(hw,
1000  997                                                       IXGBE_SFF_10GBE_COMP_CODES,
1001  998                                                       &comp_codes_10g);
1002  999  
1003      -                if (status == IXGBE_ERR_SWFW_SYNC ||
1004      -                    status == IXGBE_ERR_I2C ||
1005      -                    status == IXGBE_ERR_SFP_NOT_PRESENT)
     1000 +                if (status != IXGBE_SUCCESS)
1006 1001                          goto err_read_i2c_eeprom;
1007 1002                  status = hw->phy.ops.read_i2c_eeprom(hw,
1008 1003                                                       IXGBE_SFF_CABLE_TECHNOLOGY,
1009 1004                                                       &cable_tech);
1010 1005  
1011      -                if (status == IXGBE_ERR_SWFW_SYNC ||
1012      -                    status == IXGBE_ERR_I2C ||
1013      -                    status == IXGBE_ERR_SFP_NOT_PRESENT)
     1006 +                if (status != IXGBE_SUCCESS)
1014 1007                          goto err_read_i2c_eeprom;
1015 1008  
1016 1009                   /* ID Module
1017 1010                    * =========
1018 1011                    * 0   SFP_DA_CU
1019 1012                    * 1   SFP_SR
1020 1013                    * 2   SFP_LR
1021 1014                    * 3   SFP_DA_CORE0 - 82599-specific
1022 1015                    * 4   SFP_DA_CORE1 - 82599-specific
1023 1016                    * 5   SFP_SR/LR_CORE0 - 82599-specific
↓ open down ↓ 77 lines elided ↑ open up ↑
1101 1094                     (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1102 1095                          hw->phy.multispeed_fiber = TRUE;
1103 1096  
1104 1097                  /* Determine PHY vendor */
1105 1098                  if (hw->phy.type != ixgbe_phy_nl) {
1106 1099                          hw->phy.id = identifier;
1107 1100                          status = hw->phy.ops.read_i2c_eeprom(hw,
1108 1101                                                      IXGBE_SFF_VENDOR_OUI_BYTE0,
1109 1102                                                      &oui_bytes[0]);
1110 1103  
1111      -                        if (status == IXGBE_ERR_SWFW_SYNC ||
1112      -                            status == IXGBE_ERR_I2C ||
1113      -                            status == IXGBE_ERR_SFP_NOT_PRESENT)
     1104 +                        if (status != IXGBE_SUCCESS)
1114 1105                                  goto err_read_i2c_eeprom;
1115 1106  
1116 1107                          status = hw->phy.ops.read_i2c_eeprom(hw,
1117 1108                                                      IXGBE_SFF_VENDOR_OUI_BYTE1,
1118 1109                                                      &oui_bytes[1]);
1119 1110  
1120      -                        if (status == IXGBE_ERR_SWFW_SYNC ||
1121      -                            status == IXGBE_ERR_I2C ||
1122      -                            status == IXGBE_ERR_SFP_NOT_PRESENT)
     1111 +                        if (status != IXGBE_SUCCESS)
1123 1112                                  goto err_read_i2c_eeprom;
1124 1113  
1125 1114                          status = hw->phy.ops.read_i2c_eeprom(hw,
1126 1115                                                      IXGBE_SFF_VENDOR_OUI_BYTE2,
1127 1116                                                      &oui_bytes[2]);
1128 1117  
1129      -                        if (status == IXGBE_ERR_SWFW_SYNC ||
1130      -                            status == IXGBE_ERR_I2C ||
1131      -                            status == IXGBE_ERR_SFP_NOT_PRESENT)
     1118 +                        if (status != IXGBE_SUCCESS)
1132 1119                                  goto err_read_i2c_eeprom;
1133 1120  
1134 1121                          vendor_oui =
1135 1122                            ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1136 1123                             (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1137 1124                             (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1138 1125  
1139 1126                          switch (vendor_oui) {
1140 1127                          case IXGBE_SFF_VENDOR_OUI_TYCO:
1141 1128                                  if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
↓ open down ↓ 191 lines elided ↑ open up ↑
1333 1320                                    u8 *eeprom_data)
1334 1321  {
1335 1322          DEBUGFUNC("ixgbe_read_i2c_eeprom_generic");
1336 1323  
1337 1324          return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1338 1325                                           IXGBE_I2C_EEPROM_DEV_ADDR,
1339 1326                                           eeprom_data);
1340 1327  }
1341 1328  
1342 1329  /**
     1330 + *  ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
     1331 + *  @hw: pointer to hardware structure
     1332 + *  @byte_offset: byte offset at address 0xA2
     1333 + *  @eeprom_data: value read
     1334 + *
     1335 + *  Performs byte read operation to SFP module's SFF-8472 data over I2C
     1336 + **/
     1337 +static s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
     1338 +                                          u8 *sff8472_data)
     1339 +{
     1340 +        return hw->phy.ops.read_i2c_byte(hw, byte_offset,
     1341 +                                         IXGBE_I2C_EEPROM_DEV_ADDR2,
     1342 +                                         sff8472_data);
     1343 +}
     1344 +
     1345 +/**
1343 1346   *  ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
1344 1347   *  @hw: pointer to hardware structure
1345 1348   *  @byte_offset: EEPROM byte offset to write
1346 1349   *  @eeprom_data: value to write
1347 1350   *
1348 1351   *  Performs byte write operation to SFP module's EEPROM over I2C interface.
1349 1352   **/
1350 1353  s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1351 1354                                     u8 eeprom_data)
1352 1355  {
↓ open down ↓ 72 lines elided ↑ open up ↑
1425 1428                          goto fail;
1426 1429  
1427 1430                  status = ixgbe_clock_out_i2c_bit(hw, nack);
1428 1431                  if (status != IXGBE_SUCCESS)
1429 1432                          goto fail;
1430 1433  
1431 1434                  ixgbe_i2c_stop(hw);
1432 1435                  break;
1433 1436  
1434 1437  fail:
     1438 +                ixgbe_i2c_bus_clear(hw);
1435 1439                  hw->mac.ops.release_swfw_sync(hw, swfw_mask);
1436 1440                  msec_delay(100);
1437      -                ixgbe_i2c_bus_clear(hw);
1438 1441                  retry++;
1439 1442                  if (retry < max_retry)
1440 1443                          DEBUGOUT("I2C byte read error - Retrying.\n");
1441 1444                  else
1442 1445                          DEBUGOUT("I2C byte read error.\n");
1443 1446  
1444 1447          } while (retry < max_retry);
1445 1448  
1446 1449          hw->mac.ops.release_swfw_sync(hw, swfw_mask);
1447 1450  
↓ open down ↓ 469 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX