diff options
Diffstat (limited to 'drivers/net/ethernet/intel/igb/e1000_mac.c')
| -rw-r--r-- | drivers/net/ethernet/intel/igb/e1000_mac.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.c b/drivers/net/ethernet/intel/igb/e1000_mac.c index 819c145ac762..101e6e4da97f 100644 --- a/drivers/net/ethernet/intel/igb/e1000_mac.c +++ b/drivers/net/ethernet/intel/igb/e1000_mac.c | |||
| @@ -839,6 +839,7 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw) | |||
| 839 | { | 839 | { |
| 840 | struct e1000_mac_info *mac = &hw->mac; | 840 | struct e1000_mac_info *mac = &hw->mac; |
| 841 | s32 ret_val = 0; | 841 | s32 ret_val = 0; |
| 842 | u32 pcs_status_reg, pcs_adv_reg, pcs_lp_ability_reg, pcs_ctrl_reg; | ||
| 842 | u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; | 843 | u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; |
| 843 | u16 speed, duplex; | 844 | u16 speed, duplex; |
| 844 | 845 | ||
| @@ -1040,6 +1041,129 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw) | |||
| 1040 | goto out; | 1041 | goto out; |
| 1041 | } | 1042 | } |
| 1042 | } | 1043 | } |
| 1044 | /* Check for the case where we have SerDes media and auto-neg is | ||
| 1045 | * enabled. In this case, we need to check and see if Auto-Neg | ||
| 1046 | * has completed, and if so, how the PHY and link partner has | ||
| 1047 | * flow control configured. | ||
| 1048 | */ | ||
| 1049 | if ((hw->phy.media_type == e1000_media_type_internal_serdes) | ||
| 1050 | && mac->autoneg) { | ||
| 1051 | /* Read the PCS_LSTS and check to see if AutoNeg | ||
| 1052 | * has completed. | ||
| 1053 | */ | ||
| 1054 | pcs_status_reg = rd32(E1000_PCS_LSTAT); | ||
| 1055 | |||
| 1056 | if (!(pcs_status_reg & E1000_PCS_LSTS_AN_COMPLETE)) { | ||
| 1057 | hw_dbg("PCS Auto Neg has not completed.\n"); | ||
| 1058 | return ret_val; | ||
| 1059 | } | ||
| 1060 | |||
| 1061 | /* The AutoNeg process has completed, so we now need to | ||
| 1062 | * read both the Auto Negotiation Advertisement | ||
| 1063 | * Register (PCS_ANADV) and the Auto_Negotiation Base | ||
| 1064 | * Page Ability Register (PCS_LPAB) to determine how | ||
| 1065 | * flow control was negotiated. | ||
| 1066 | */ | ||
| 1067 | pcs_adv_reg = rd32(E1000_PCS_ANADV); | ||
| 1068 | pcs_lp_ability_reg = rd32(E1000_PCS_LPAB); | ||
| 1069 | |||
| 1070 | /* Two bits in the Auto Negotiation Advertisement Register | ||
| 1071 | * (PCS_ANADV) and two bits in the Auto Negotiation Base | ||
| 1072 | * Page Ability Register (PCS_LPAB) determine flow control | ||
| 1073 | * for both the PHY and the link partner. The following | ||
| 1074 | * table, taken out of the IEEE 802.3ab/D6.0 dated March 25, | ||
| 1075 | * 1999, describes these PAUSE resolution bits and how flow | ||
| 1076 | * control is determined based upon these settings. | ||
| 1077 | * NOTE: DC = Don't Care | ||
| 1078 | * | ||
| 1079 | * LOCAL DEVICE | LINK PARTNER | ||
| 1080 | * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution | ||
| 1081 | *-------|---------|-------|---------|-------------------- | ||
| 1082 | * 0 | 0 | DC | DC | e1000_fc_none | ||
| 1083 | * 0 | 1 | 0 | DC | e1000_fc_none | ||
| 1084 | * 0 | 1 | 1 | 0 | e1000_fc_none | ||
| 1085 | * 0 | 1 | 1 | 1 | e1000_fc_tx_pause | ||
| 1086 | * 1 | 0 | 0 | DC | e1000_fc_none | ||
| 1087 | * 1 | DC | 1 | DC | e1000_fc_full | ||
| 1088 | * 1 | 1 | 0 | 0 | e1000_fc_none | ||
| 1089 | * 1 | 1 | 0 | 1 | e1000_fc_rx_pause | ||
| 1090 | * | ||
| 1091 | * Are both PAUSE bits set to 1? If so, this implies | ||
| 1092 | * Symmetric Flow Control is enabled at both ends. The | ||
| 1093 | * ASM_DIR bits are irrelevant per the spec. | ||
| 1094 | * | ||
| 1095 | * For Symmetric Flow Control: | ||
| 1096 | * | ||
| 1097 | * LOCAL DEVICE | LINK PARTNER | ||
| 1098 | * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result | ||
| 1099 | *-------|---------|-------|---------|-------------------- | ||
| 1100 | * 1 | DC | 1 | DC | e1000_fc_full | ||
| 1101 | * | ||
| 1102 | */ | ||
| 1103 | if ((pcs_adv_reg & E1000_TXCW_PAUSE) && | ||
| 1104 | (pcs_lp_ability_reg & E1000_TXCW_PAUSE)) { | ||
| 1105 | /* Now we need to check if the user selected Rx ONLY | ||
| 1106 | * of pause frames. In this case, we had to advertise | ||
| 1107 | * FULL flow control because we could not advertise Rx | ||
| 1108 | * ONLY. Hence, we must now check to see if we need to | ||
| 1109 | * turn OFF the TRANSMISSION of PAUSE frames. | ||
| 1110 | */ | ||
| 1111 | if (hw->fc.requested_mode == e1000_fc_full) { | ||
| 1112 | hw->fc.current_mode = e1000_fc_full; | ||
| 1113 | hw_dbg("Flow Control = FULL.\n"); | ||
| 1114 | } else { | ||
| 1115 | hw->fc.current_mode = e1000_fc_rx_pause; | ||
| 1116 | hw_dbg("Flow Control = Rx PAUSE frames only.\n"); | ||
| 1117 | } | ||
| 1118 | } | ||
| 1119 | /* For receiving PAUSE frames ONLY. | ||
| 1120 | * | ||
| 1121 | * LOCAL DEVICE | LINK PARTNER | ||
| 1122 | * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result | ||
| 1123 | *-------|---------|-------|---------|-------------------- | ||
| 1124 | * 0 | 1 | 1 | 1 | e1000_fc_tx_pause | ||
| 1125 | */ | ||
| 1126 | else if (!(pcs_adv_reg & E1000_TXCW_PAUSE) && | ||
| 1127 | (pcs_adv_reg & E1000_TXCW_ASM_DIR) && | ||
| 1128 | (pcs_lp_ability_reg & E1000_TXCW_PAUSE) && | ||
| 1129 | (pcs_lp_ability_reg & E1000_TXCW_ASM_DIR)) { | ||
| 1130 | hw->fc.current_mode = e1000_fc_tx_pause; | ||
| 1131 | hw_dbg("Flow Control = Tx PAUSE frames only.\n"); | ||
| 1132 | } | ||
| 1133 | /* For transmitting PAUSE frames ONLY. | ||
| 1134 | * | ||
| 1135 | * LOCAL DEVICE | LINK PARTNER | ||
| 1136 | * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result | ||
| 1137 | *-------|---------|-------|---------|-------------------- | ||
| 1138 | * 1 | 1 | 0 | 1 | e1000_fc_rx_pause | ||
| 1139 | */ | ||
| 1140 | else if ((pcs_adv_reg & E1000_TXCW_PAUSE) && | ||
| 1141 | (pcs_adv_reg & E1000_TXCW_ASM_DIR) && | ||
| 1142 | !(pcs_lp_ability_reg & E1000_TXCW_PAUSE) && | ||
| 1143 | (pcs_lp_ability_reg & E1000_TXCW_ASM_DIR)) { | ||
| 1144 | hw->fc.current_mode = e1000_fc_rx_pause; | ||
| 1145 | hw_dbg("Flow Control = Rx PAUSE frames only.\n"); | ||
| 1146 | } else { | ||
| 1147 | /* Per the IEEE spec, at this point flow control | ||
| 1148 | * should be disabled. | ||
| 1149 | */ | ||
| 1150 | hw->fc.current_mode = e1000_fc_none; | ||
| 1151 | hw_dbg("Flow Control = NONE.\n"); | ||
| 1152 | } | ||
| 1153 | |||
| 1154 | /* Now we call a subroutine to actually force the MAC | ||
| 1155 | * controller to use the correct flow control settings. | ||
| 1156 | */ | ||
| 1157 | pcs_ctrl_reg = rd32(E1000_PCS_LCTL); | ||
| 1158 | pcs_ctrl_reg |= E1000_PCS_LCTL_FORCE_FCTRL; | ||
| 1159 | wr32(E1000_PCS_LCTL, pcs_ctrl_reg); | ||
| 1160 | |||
| 1161 | ret_val = igb_force_mac_fc(hw); | ||
| 1162 | if (ret_val) { | ||
| 1163 | hw_dbg("Error forcing flow control settings\n"); | ||
| 1164 | return ret_val; | ||
| 1165 | } | ||
| 1166 | } | ||
| 1043 | 1167 | ||
| 1044 | out: | 1168 | out: |
| 1045 | return ret_val; | 1169 | return ret_val; |
| @@ -1391,6 +1515,10 @@ s32 igb_validate_mdi_setting(struct e1000_hw *hw) | |||
| 1391 | { | 1515 | { |
| 1392 | s32 ret_val = 0; | 1516 | s32 ret_val = 0; |
| 1393 | 1517 | ||
| 1518 | /* All MDI settings are supported on 82580 and newer. */ | ||
| 1519 | if (hw->mac.type >= e1000_82580) | ||
| 1520 | goto out; | ||
| 1521 | |||
| 1394 | if (!hw->mac.autoneg && (hw->phy.mdix == 0 || hw->phy.mdix == 3)) { | 1522 | if (!hw->mac.autoneg && (hw->phy.mdix == 0 || hw->phy.mdix == 3)) { |
| 1395 | hw_dbg("Invalid MDI setting detected\n"); | 1523 | hw_dbg("Invalid MDI setting detected\n"); |
| 1396 | hw->phy.mdix = 1; | 1524 | hw->phy.mdix = 1; |
