28 #include <linux/pci.h>
30 #include <linux/sched.h>
35 #define IXGBE_82598_MAX_TX_QUEUES 32
36 #define IXGBE_82598_MAX_RX_QUEUES 64
37 #define IXGBE_82598_RAR_ENTRIES 16
38 #define IXGBE_82598_MC_TBL_SIZE 128
39 #define IXGBE_82598_VFT_TBL_SIZE 128
40 #define IXGBE_82598_RX_PB_SIZE 512
45 bool autoneg_wait_to_complete);
59 static void ixgbe_set_pcie_completion_timeout(
struct ixgbe_hw *
hw)
83 pci_read_config_word(adapter->
pdev,
86 pci_write_config_word(adapter->
pdev,
94 static s32 ixgbe_get_invariants_82598(
struct ixgbe_hw *hw)
120 static s32 ixgbe_init_phy_ops_82598(
struct ixgbe_hw *hw)
128 phy->
ops.identify(hw);
132 mac->
ops.setup_link = &ixgbe_setup_copper_link_82598;
133 mac->
ops.get_link_capabilities =
137 switch (hw->
phy.type) {
141 phy->
ops.get_firmware_version =
148 ret_val = phy->
ops.identify_sfp(hw);
181 static s32 ixgbe_start_hw_82598(
struct ixgbe_hw *hw)
190 for (i = 0; ((i < hw->
mac.max_tx_queues) &&
197 for (i = 0; ((i < hw->
mac.max_rx_queues) &&
209 ixgbe_set_pcie_completion_timeout(hw);
222 static s32 ixgbe_get_link_capabilities_82598(
struct ixgbe_hw *hw,
234 if (hw->
mac.orig_link_settings_stored)
235 autoc = hw->
mac.orig_autoc;
284 switch (hw->
phy.type) {
330 static s32 ixgbe_fc_enable_82598(
struct ixgbe_hw *hw)
346 if (!hw->
fc.low_water ||
347 !hw->
fc.high_water[0] ||
348 !hw->
fc.pause_time) {
349 hw_dbg(hw,
"Invalid water mark configuration\n");
359 hw->
mac.ops.check_link(hw, &link_speed, &link_up,
false);
361 switch (hw->
fc.requested_mode) {
394 switch (hw->
fc.current_mode) {
425 hw_dbg(hw,
"Flow control param set incorrectly\n");
441 hw->
fc.high_water[
i]) {
453 reg = hw->
fc.pause_time * 0x00010001;
454 for (i = 0; i < (MAX_TRAFFIC_CLASS / 2); i++)
471 static s32 ixgbe_start_mac_link_82598(
struct ixgbe_hw *hw,
472 bool autoneg_wait_to_complete)
485 if (autoneg_wait_to_complete) {
486 if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
488 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
499 hw_dbg(hw,
"Autonegotiation did not complete.\n");
517 static s32 ixgbe_validate_link_ready(
struct ixgbe_hw *hw)
536 if (timeout == IXGBE_VALIDATE_LINK_READY_TIMEOUT) {
537 hw_dbg(hw,
"Link was indicated but link is down\n");
553 static s32 ixgbe_check_mac_link_82598(
struct ixgbe_hw *hw,
555 bool link_up_wait_to_complete)
559 u16 link_reg, adapt_comp_reg;
572 if (link_up_wait_to_complete) {
574 if ((link_reg & 1) &&
575 ((adapt_comp_reg & 1) == 0)) {
582 hw->
phy.ops.read_reg(hw, 0xC79F,
585 hw->
phy.ops.read_reg(hw, 0xC00C,
590 if ((link_reg & 1) && ((adapt_comp_reg & 1) == 0))
601 if (link_up_wait_to_complete) {
625 (ixgbe_validate_link_ready(hw) != 0))
641 static s32 ixgbe_setup_mac_link_82598(
struct ixgbe_hw *hw,
643 bool autoneg_wait_to_complete)
648 u32 autoc = curr_autoc;
652 ixgbe_get_link_capabilities_82598(hw, &link_capabilities, &autoneg);
653 speed &= link_capabilities;
666 if (autoc != curr_autoc)
676 status = ixgbe_start_mac_link_82598(hw,
677 autoneg_wait_to_complete);
693 static s32 ixgbe_setup_copper_link_82598(
struct ixgbe_hw *hw,
696 bool autoneg_wait_to_complete)
701 status = hw->
phy.ops.setup_link_speed(hw, speed, autoneg,
702 autoneg_wait_to_complete);
704 ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
717 static s32 ixgbe_reset_hw_82598(
struct ixgbe_hw *hw)
728 status = hw->
mac.ops.stop_adapter(hw);
742 analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN;
766 if (hw->
phy.reset_disable ==
false) {
770 phy_status = hw->
phy.ops.init(hw);
776 hw->
phy.ops.reset(hw);
789 for (i = 0; i < 10; i++) {
797 hw_dbg(hw,
"Reset polling failed to complete.\n");
813 gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6));
822 if (hw->
mac.orig_link_settings_stored ==
false) {
823 hw->
mac.orig_autoc = autoc;
824 hw->
mac.orig_link_settings_stored =
true;
825 }
else if (autoc != hw->
mac.orig_autoc) {
830 hw->
mac.ops.get_mac_addr(hw, hw->
mac.perm_addr);
836 hw->
mac.ops.init_rx_addrs(hw);
854 u32 rar_entries = hw->
mac.num_rar_entries;
857 if (rar >= rar_entries) {
858 hw_dbg(hw,
"RAR index %d is out of range.\n", rar);
878 u32 rar_entries = hw->
mac.num_rar_entries;
882 if (rar >= rar_entries) {
883 hw_dbg(hw,
"RAR index %d is out of range.\n", rar);
889 rar_high &= ~IXGBE_RAH_VIND_MASK;
917 regindex = (vlan >> 5) & 0x7F;
920 vftabyte = ((vlan >> 3) & 0x03);
921 bitindex = (vlan & 0x7) << 2;
925 bits &= (~(0x0F << bitindex));
926 bits |= (vind << bitindex);
930 bitindex = vlan & 0x1F;
935 bits |= (1 << bitindex);
938 bits &= ~(1 << bitindex);
950 static s32 ixgbe_clear_vfta_82598(
struct ixgbe_hw *hw)
955 for (offset = 0; offset < hw->
mac.vft_size; offset++)
958 for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)
959 for (offset = 0; offset < hw->
mac.vft_size; offset++)
983 *val = (
u8)atlas_ctl;
996 static s32 ixgbe_write_analog_reg8_82598(
struct ixgbe_hw *hw,
u32 reg,
u8 val)
1000 atlas_ctl = (reg << 8) | val;
1033 hw->
phy.ops.write_reg(hw,
1039 for (i = 0; i < 100; i++) {
1040 hw->
phy.ops.read_reg(hw,
1051 hw_dbg(hw,
"EEPROM read did not pass.\n");
1060 *eeprom_data = (
u8)(sfp_data >> 8);
1076 static u32 ixgbe_get_supported_physical_layer_82598(
struct ixgbe_hw *hw)
1082 u16 ext_ability = 0;
1084 hw->
phy.ops.identify(hw);
1088 switch (hw->
phy.type) {
1104 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
1132 hw->
phy.ops.identify_sfp(hw);
1134 switch (hw->
phy.sfp_type) {
1167 return physical_layer;
1178 static void ixgbe_set_lan_id_multi_port_pcie_82598(
struct ixgbe_hw *hw)
1188 if ((pci_gen != 0) && (pci_gen != 0xFFFF)) {
1209 static void ixgbe_set_rxpba_82598(
struct ixgbe_hw *hw,
int num_pb,
u32 headroom,
1245 .reset_hw = &ixgbe_reset_hw_82598,
1246 .start_hw = &ixgbe_start_hw_82598,
1248 .get_media_type = &ixgbe_get_media_type_82598,
1249 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82598,
1254 .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie_82598,
1255 .read_analog_reg8 = &ixgbe_read_analog_reg8_82598,
1256 .write_analog_reg8 = &ixgbe_write_analog_reg8_82598,
1257 .setup_link = &ixgbe_setup_mac_link_82598,
1258 .set_rxpba = &ixgbe_set_rxpba_82598,
1259 .check_link = &ixgbe_check_mac_link_82598,
1260 .get_link_capabilities = &ixgbe_get_link_capabilities_82598,
1267 .set_vmdq = &ixgbe_set_vmdq_82598,
1268 .clear_vmdq = &ixgbe_clear_vmdq_82598,
1273 .clear_vfta = &ixgbe_clear_vfta_82598,
1274 .set_vfta = &ixgbe_set_vfta_82598,
1275 .fc_enable = &ixgbe_fc_enable_82598,
1276 .set_fw_drv_ver =
NULL,
1279 .get_thermal_sensor_data =
NULL,
1280 .init_thermal_sensor_thresh =
NULL,
1297 .init = &ixgbe_init_phy_ops_82598,
1303 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_82598,
1309 .get_invariants = &ixgbe_get_invariants_82598,
1310 .mac_ops = &mac_ops_82598,
1311 .eeprom_ops = &eeprom_ops_82598,
1312 .phy_ops = &phy_ops_82598,