aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Skidmore <donald.c.skidmore@intel.com>2014-02-27 23:32:41 -0500
committerDavid S. Miller <davem@davemloft.net>2014-02-28 12:40:56 -0500
commit429d6a3be9b656f9400356f026328f3a2e900887 (patch)
tree074535acb391a3918afa797528df1d725f4bd286
parent1f86c983bebbb226b69f986bdc7b8b4299a2004c (diff)
ixgbe: collect all 82599 AUTOC code in one function
When reading or writing to the AUTOC register on 82599 devices we need to preform various operations that aren't needed for other MAC types. This patch will collect all of that code into one place to minimize MAC checks in common code paths. While doing this I also clean up some cases where we weren't holding the SW/FW semaphore during a read/modify/write of AUTOC. Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Signed-off-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c171
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c118
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.h5
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h3
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c2
7 files changed, 161 insertions, 141 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 0186ea2969fe..cca13a5438e2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -884,7 +884,6 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
884 u16 soft_id); 884 u16 soft_id);
885void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input, 885void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
886 union ixgbe_atr_input *mask); 886 union ixgbe_atr_input *mask);
887bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);
888void ixgbe_set_rx_mode(struct net_device *netdev); 887void ixgbe_set_rx_mode(struct net_device *netdev);
889#ifdef CONFIG_IXGBE_DCB 888#ifdef CONFIG_IXGBE_DCB
890void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter); 889void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
index a26f3fee4f35..10e563cb847a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
@@ -1316,6 +1316,8 @@ static struct ixgbe_mac_operations mac_ops_82598 = {
1316 .get_thermal_sensor_data = NULL, 1316 .get_thermal_sensor_data = NULL,
1317 .init_thermal_sensor_thresh = NULL, 1317 .init_thermal_sensor_thresh = NULL,
1318 .mng_fw_enabled = NULL, 1318 .mng_fw_enabled = NULL,
1319 .prot_autoc_read = &prot_autoc_read_generic,
1320 .prot_autoc_write = &prot_autoc_write_generic,
1319}; 1321};
1320 1322
1321static struct ixgbe_eeprom_operations eeprom_ops_82598 = { 1323static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
index edda6814108c..1c31d2d62f75 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
@@ -63,6 +63,8 @@ static s32 ixgbe_read_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
63 u8 dev_addr, u8 *data); 63 u8 dev_addr, u8 *data);
64static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset, 64static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
65 u8 dev_addr, u8 data); 65 u8 dev_addr, u8 data);
66static s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);
67static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);
66 68
67static bool ixgbe_mng_enabled(struct ixgbe_hw *hw) 69static bool ixgbe_mng_enabled(struct ixgbe_hw *hw)
68{ 70{
@@ -122,7 +124,6 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
122{ 124{
123 s32 ret_val = 0; 125 s32 ret_val = 0;
124 u16 list_offset, data_offset, data_value; 126 u16 list_offset, data_offset, data_value;
125 bool got_lock = false;
126 127
127 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) { 128 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
128 ixgbe_init_mac_link_ops_82599(hw); 129 ixgbe_init_mac_link_ops_82599(hw);
@@ -160,30 +161,10 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
160 usleep_range(hw->eeprom.semaphore_delay * 1000, 161 usleep_range(hw->eeprom.semaphore_delay * 1000,
161 hw->eeprom.semaphore_delay * 2000); 162 hw->eeprom.semaphore_delay * 2000);
162 163
163 /* Need SW/FW semaphore around AUTOC writes if LESM on,
164 * likewise reset_pipeline requires lock as it also writes
165 * AUTOC.
166 */
167 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
168 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
169 IXGBE_GSSR_MAC_CSR_SM);
170 if (ret_val)
171 goto setup_sfp_out;
172
173 got_lock = true;
174 }
175
176 /* Restart DSP and set SFI mode */ 164 /* Restart DSP and set SFI mode */
177 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((hw->mac.orig_autoc) | 165 ret_val = hw->mac.ops.prot_autoc_write(hw,
178 IXGBE_AUTOC_LMS_10G_SERIAL)); 166 hw->mac.orig_autoc | IXGBE_AUTOC_LMS_10G_SERIAL,
179 hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 167 false);
180 ret_val = ixgbe_reset_pipeline_82599(hw);
181
182 if (got_lock) {
183 hw->mac.ops.release_swfw_sync(hw,
184 IXGBE_GSSR_MAC_CSR_SM);
185 got_lock = false;
186 }
187 168
188 if (ret_val) { 169 if (ret_val) {
189 hw_dbg(hw, " sfp module setup not complete\n"); 170 hw_dbg(hw, " sfp module setup not complete\n");
@@ -207,6 +188,74 @@ setup_sfp_err:
207 return IXGBE_ERR_SFP_SETUP_NOT_COMPLETE; 188 return IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
208} 189}
209 190
191/**
192 * prot_autoc_read_82599 - Hides MAC differences needed for AUTOC read
193 * @hw: pointer to hardware structure
194 * @locked: Return the if we locked for this read.
195 * @reg_val: Value we read from AUTOC
196 *
197 * For this part (82599) we need to wrap read-modify-writes with a possible
198 * FW/SW lock. It is assumed this lock will be freed with the next
199 * prot_autoc_write_82599(). Note, that locked can only be true in cases
200 * where this function doesn't return an error.
201 **/
202static s32 prot_autoc_read_82599(struct ixgbe_hw *hw, bool *locked,
203 u32 *reg_val)
204{
205 s32 ret_val;
206
207 *locked = false;
208 /* If LESM is on then we need to hold the SW/FW semaphore. */
209 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
210 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
211 IXGBE_GSSR_MAC_CSR_SM);
212 if (!ret_val)
213 return IXGBE_ERR_SWFW_SYNC;
214
215 *locked = true;
216 }
217
218 *reg_val = IXGBE_READ_REG(hw, IXGBE_AUTOC);
219 return 0;
220}
221
222/**
223 * prot_autoc_write_82599 - Hides MAC differences needed for AUTOC write
224 * @hw: pointer to hardware structure
225 * @reg_val: value to write to AUTOC
226 * @locked: bool to indicate whether the SW/FW lock was already taken by
227 * previous proc_autoc_read_82599.
228 *
229 * This part (82599) may need to hold a the SW/FW lock around all writes to
230 * AUTOC. Likewise after a write we need to do a pipeline reset.
231 **/
232static s32 prot_autoc_write_82599(struct ixgbe_hw *hw, u32 autoc, bool locked)
233{
234 s32 ret_val = 0;
235
236 /* We only need to get the lock if:
237 * - We didn't do it already (in the read part of a read-modify-write)
238 * - LESM is enabled.
239 */
240 if (!locked && ixgbe_verify_lesm_fw_enabled_82599(hw)) {
241 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
242 IXGBE_GSSR_MAC_CSR_SM);
243 if (!ret_val)
244 return IXGBE_ERR_SWFW_SYNC;
245 }
246
247 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
248 ret_val = ixgbe_reset_pipeline_82599(hw);
249
250 /* Free the SW/FW semaphore as we either grabbed it here or
251 * already had it when this function was called.
252 */
253 if (locked)
254 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
255
256 return ret_val;
257}
258
210static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw) 259static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
211{ 260{
212 struct ixgbe_mac_info *mac = &hw->mac; 261 struct ixgbe_mac_info *mac = &hw->mac;
@@ -966,7 +1015,6 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
966 u32 links_reg; 1015 u32 links_reg;
967 u32 i; 1016 u32 i;
968 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN; 1017 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
969 bool got_lock = false;
970 bool autoneg = false; 1018 bool autoneg = false;
971 1019
972 /* Check to see if speed passed in is supported. */ 1020 /* Check to see if speed passed in is supported. */
@@ -989,7 +1037,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
989 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 1037 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
990 1038
991 orig_autoc = autoc; 1039 orig_autoc = autoc;
992 start_autoc = hw->mac.cached_autoc; 1040 start_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
993 link_mode = autoc & IXGBE_AUTOC_LMS_MASK; 1041 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
994 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK; 1042 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
995 1043
@@ -1030,27 +1078,10 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
1030 } 1078 }
1031 1079
1032 if (autoc != start_autoc) { 1080 if (autoc != start_autoc) {
1033 /* Need SW/FW semaphore around AUTOC writes if LESM is on,
1034 * likewise reset_pipeline requires us to hold this lock as
1035 * it also writes to AUTOC.
1036 */
1037 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
1038 status = hw->mac.ops.acquire_swfw_sync(hw,
1039 IXGBE_GSSR_MAC_CSR_SM);
1040 if (status != 0)
1041 goto out;
1042
1043 got_lock = true;
1044 }
1045
1046 /* Restart link */ 1081 /* Restart link */
1047 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc); 1082 status = hw->mac.ops.prot_autoc_write(hw, autoc, false);
1048 hw->mac.cached_autoc = autoc; 1083 if (!status)
1049 ixgbe_reset_pipeline_82599(hw); 1084 goto out;
1050
1051 if (got_lock)
1052 hw->mac.ops.release_swfw_sync(hw,
1053 IXGBE_GSSR_MAC_CSR_SM);
1054 1085
1055 /* Only poll for autoneg to complete if specified to do so */ 1086 /* Only poll for autoneg to complete if specified to do so */
1056 if (autoneg_wait_to_complete) { 1087 if (autoneg_wait_to_complete) {
@@ -1117,7 +1148,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
1117{ 1148{
1118 ixgbe_link_speed link_speed; 1149 ixgbe_link_speed link_speed;
1119 s32 status; 1150 s32 status;
1120 u32 ctrl, i, autoc2; 1151 u32 ctrl, i, autoc, autoc2;
1121 u32 curr_lms; 1152 u32 curr_lms;
1122 bool link_up = false; 1153 bool link_up = false;
1123 1154
@@ -1151,11 +1182,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
1151 hw->phy.ops.reset(hw); 1182 hw->phy.ops.reset(hw);
1152 1183
1153 /* remember AUTOC from before we reset */ 1184 /* remember AUTOC from before we reset */
1154 if (hw->mac.cached_autoc) 1185 curr_lms = IXGBE_READ_REG(hw, IXGBE_AUTOC) & IXGBE_AUTOC_LMS_MASK;
1155 curr_lms = hw->mac.cached_autoc & IXGBE_AUTOC_LMS_MASK;
1156 else
1157 curr_lms = IXGBE_READ_REG(hw, IXGBE_AUTOC) &
1158 IXGBE_AUTOC_LMS_MASK;
1159 1186
1160mac_reset_top: 1187mac_reset_top:
1161 /* 1188 /*
@@ -1205,7 +1232,7 @@ mac_reset_top:
1205 * stored off yet. Otherwise restore the stored original 1232 * stored off yet. Otherwise restore the stored original
1206 * values since the reset operation sets back to defaults. 1233 * values since the reset operation sets back to defaults.
1207 */ 1234 */
1208 hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 1235 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1209 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2); 1236 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1210 1237
1211 /* Enable link if disabled in NVM */ 1238 /* Enable link if disabled in NVM */
@@ -1216,7 +1243,7 @@ mac_reset_top:
1216 } 1243 }
1217 1244
1218 if (hw->mac.orig_link_settings_stored == false) { 1245 if (hw->mac.orig_link_settings_stored == false) {
1219 hw->mac.orig_autoc = hw->mac.cached_autoc; 1246 hw->mac.orig_autoc = autoc;
1220 hw->mac.orig_autoc2 = autoc2; 1247 hw->mac.orig_autoc2 = autoc2;
1221 hw->mac.orig_link_settings_stored = true; 1248 hw->mac.orig_link_settings_stored = true;
1222 } else { 1249 } else {
@@ -1233,28 +1260,12 @@ mac_reset_top:
1233 (hw->mac.orig_autoc & ~IXGBE_AUTOC_LMS_MASK) | 1260 (hw->mac.orig_autoc & ~IXGBE_AUTOC_LMS_MASK) |
1234 curr_lms; 1261 curr_lms;
1235 1262
1236 if (hw->mac.cached_autoc != hw->mac.orig_autoc) { 1263 if (autoc != hw->mac.orig_autoc) {
1237 /* Need SW/FW semaphore around AUTOC writes if LESM is 1264 status = hw->mac.ops.prot_autoc_write(hw,
1238 * on, likewise reset_pipeline requires us to hold 1265 hw->mac.orig_autoc,
1239 * this lock as it also writes to AUTOC. 1266 false);
1240 */ 1267 if (!status)
1241 bool got_lock = false; 1268 goto reset_hw_out;
1242 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
1243 status = hw->mac.ops.acquire_swfw_sync(hw,
1244 IXGBE_GSSR_MAC_CSR_SM);
1245 if (status)
1246 goto reset_hw_out;
1247
1248 got_lock = true;
1249 }
1250
1251 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
1252 hw->mac.cached_autoc = hw->mac.orig_autoc;
1253 ixgbe_reset_pipeline_82599(hw);
1254
1255 if (got_lock)
1256 hw->mac.ops.release_swfw_sync(hw,
1257 IXGBE_GSSR_MAC_CSR_SM);
1258 } 1269 }
1259 1270
1260 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) != 1271 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
@@ -2260,7 +2271,7 @@ fw_version_err:
2260 * Returns true if the LESM FW module is present and enabled. Otherwise 2271 * Returns true if the LESM FW module is present and enabled. Otherwise
2261 * returns false. Smart Speed must be disabled if LESM FW module is enabled. 2272 * returns false. Smart Speed must be disabled if LESM FW module is enabled.
2262 **/ 2273 **/
2263bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw) 2274static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw)
2264{ 2275{
2265 bool lesm_enabled = false; 2276 bool lesm_enabled = false;
2266 u16 fw_offset, fw_lesm_param_offset, fw_lesm_state; 2277 u16 fw_offset, fw_lesm_param_offset, fw_lesm_state;
@@ -2366,7 +2377,7 @@ static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
2366 * full pipeline reset. Note - We must hold the SW/FW semaphore before writing 2377 * full pipeline reset. Note - We must hold the SW/FW semaphore before writing
2367 * to AUTOC, so this function assumes the semaphore is held. 2378 * to AUTOC, so this function assumes the semaphore is held.
2368 **/ 2379 **/
2369s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw) 2380static s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)
2370{ 2381{
2371 s32 ret_val; 2382 s32 ret_val;
2372 u32 anlp1_reg = 0; 2383 u32 anlp1_reg = 0;
@@ -2380,7 +2391,7 @@ s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)
2380 IXGBE_WRITE_FLUSH(hw); 2391 IXGBE_WRITE_FLUSH(hw);
2381 } 2392 }
2382 2393
2383 autoc_reg = hw->mac.cached_autoc; 2394 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2384 autoc_reg |= IXGBE_AUTOC_AN_RESTART; 2395 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
2385 2396
2386 /* Write AUTOC register with toggled LMS[2] bit and Restart_AN */ 2397 /* Write AUTOC register with toggled LMS[2] bit and Restart_AN */
@@ -2566,6 +2577,8 @@ static struct ixgbe_mac_operations mac_ops_82599 = {
2566 .get_thermal_sensor_data = &ixgbe_get_thermal_sensor_data_generic, 2577 .get_thermal_sensor_data = &ixgbe_get_thermal_sensor_data_generic,
2567 .init_thermal_sensor_thresh = &ixgbe_init_thermal_sensor_thresh_generic, 2578 .init_thermal_sensor_thresh = &ixgbe_init_thermal_sensor_thresh_generic,
2568 .mng_fw_enabled = &ixgbe_mng_enabled, 2579 .mng_fw_enabled = &ixgbe_mng_enabled,
2580 .prot_autoc_read = &prot_autoc_read_82599,
2581 .prot_autoc_write = &prot_autoc_write_82599,
2569}; 2582};
2570 2583
2571static struct ixgbe_eeprom_operations eeprom_ops_82599 = { 2584static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index 2e84ee8a1071..263143f53b21 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -114,7 +114,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
114 s32 ret_val = 0; 114 s32 ret_val = 0;
115 u32 reg = 0, reg_bp = 0; 115 u32 reg = 0, reg_bp = 0;
116 u16 reg_cu = 0; 116 u16 reg_cu = 0;
117 bool got_lock = false; 117 bool locked = false;
118 118
119 /* 119 /*
120 * Validate the requested mode. Strict IEEE mode does not allow 120 * Validate the requested mode. Strict IEEE mode does not allow
@@ -139,11 +139,17 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
139 * we link at 10G, the 1G advertisement is harmless and vice versa. 139 * we link at 10G, the 1G advertisement is harmless and vice versa.
140 */ 140 */
141 switch (hw->phy.media_type) { 141 switch (hw->phy.media_type) {
142 case ixgbe_media_type_backplane:
143 /* some MAC's need RMW protection on AUTOC */
144 ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &reg_bp);
145 if (!ret_val)
146 goto out;
147
148 /* only backplane uses autoc so fall though */
142 case ixgbe_media_type_fiber_fixed: 149 case ixgbe_media_type_fiber_fixed:
143 case ixgbe_media_type_fiber: 150 case ixgbe_media_type_fiber:
144 case ixgbe_media_type_backplane:
145 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA); 151 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
146 reg_bp = IXGBE_READ_REG(hw, IXGBE_AUTOC); 152
147 break; 153 break;
148 case ixgbe_media_type_copper: 154 case ixgbe_media_type_copper:
149 hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE, 155 hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE,
@@ -240,27 +246,12 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
240 * LESM is on, likewise reset_pipeline requries the lock as 246 * LESM is on, likewise reset_pipeline requries the lock as
241 * it also writes AUTOC. 247 * it also writes AUTOC.
242 */ 248 */
243 if ((hw->mac.type == ixgbe_mac_82599EB) && 249 ret_val = hw->mac.ops.prot_autoc_write(hw, reg_bp, locked);
244 ixgbe_verify_lesm_fw_enabled_82599(hw)) { 250 if (ret_val)
245 ret_val = hw->mac.ops.acquire_swfw_sync(hw, 251 goto out;
246 IXGBE_GSSR_MAC_CSR_SM);
247 if (ret_val)
248 goto out;
249
250 got_lock = true;
251 }
252
253 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_bp);
254
255 if (hw->mac.type == ixgbe_mac_82599EB)
256 ixgbe_reset_pipeline_82599(hw);
257
258 if (got_lock)
259 hw->mac.ops.release_swfw_sync(hw,
260 IXGBE_GSSR_MAC_CSR_SM);
261 252
262 } else if ((hw->phy.media_type == ixgbe_media_type_copper) && 253 } else if ((hw->phy.media_type == ixgbe_media_type_copper) &&
263 ixgbe_device_supports_autoneg_fc(hw)) { 254 ixgbe_device_supports_autoneg_fc(hw)) {
264 hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE, 255 hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE,
265 MDIO_MMD_AN, reg_cu); 256 MDIO_MMD_AN, reg_cu);
266 } 257 }
@@ -2614,6 +2605,35 @@ void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask)
2614} 2605}
2615 2606
2616/** 2607/**
2608 * prot_autoc_read_generic - Hides MAC differences needed for AUTOC read
2609 * @hw: pointer to hardware structure
2610 * @reg_val: Value we read from AUTOC
2611 * @locked: bool to indicate whether the SW/FW lock should be taken. Never
2612 * true in this the generic case.
2613 *
2614 * The default case requires no protection so just to the register read.
2615 **/
2616s32 prot_autoc_read_generic(struct ixgbe_hw *hw, bool *locked, u32 *reg_val)
2617{
2618 *locked = false;
2619 *reg_val = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2620 return 0;
2621}
2622
2623/**
2624 * prot_autoc_write_generic - Hides MAC differences needed for AUTOC write
2625 * @hw: pointer to hardware structure
2626 * @reg_val: value to write to AUTOC
2627 * @locked: bool to indicate whether the SW/FW lock was already taken by
2628 * previous read.
2629 **/
2630s32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 reg_val, bool locked)
2631{
2632 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_val);
2633 return 0;
2634}
2635
2636/**
2617 * ixgbe_disable_rx_buff_generic - Stops the receive data path 2637 * ixgbe_disable_rx_buff_generic - Stops the receive data path
2618 * @hw: pointer to hardware structure 2638 * @hw: pointer to hardware structure
2619 * 2639 *
@@ -2691,6 +2711,7 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)
2691 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); 2711 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2692 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); 2712 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
2693 s32 ret_val = 0; 2713 s32 ret_val = 0;
2714 bool locked = false;
2694 2715
2695 /* 2716 /*
2696 * Link must be up to auto-blink the LEDs; 2717 * Link must be up to auto-blink the LEDs;
@@ -2699,28 +2720,19 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)
2699 hw->mac.ops.check_link(hw, &speed, &link_up, false); 2720 hw->mac.ops.check_link(hw, &speed, &link_up, false);
2700 2721
2701 if (!link_up) { 2722 if (!link_up) {
2702 /* Need the SW/FW semaphore around AUTOC writes if 82599 and 2723 ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg);
2703 * LESM is on. 2724 if (!ret_val)
2704 */ 2725 goto out;
2705 bool got_lock = false;
2706
2707 if ((hw->mac.type == ixgbe_mac_82599EB) &&
2708 ixgbe_verify_lesm_fw_enabled_82599(hw)) {
2709 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
2710 IXGBE_GSSR_MAC_CSR_SM);
2711 if (ret_val)
2712 goto out;
2713 2726
2714 got_lock = true;
2715 }
2716 autoc_reg |= IXGBE_AUTOC_AN_RESTART; 2727 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
2717 autoc_reg |= IXGBE_AUTOC_FLU; 2728 autoc_reg |= IXGBE_AUTOC_FLU;
2718 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); 2729
2730 ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked);
2731 if (!ret_val)
2732 goto out;
2733
2719 IXGBE_WRITE_FLUSH(hw); 2734 IXGBE_WRITE_FLUSH(hw);
2720 2735
2721 if (got_lock)
2722 hw->mac.ops.release_swfw_sync(hw,
2723 IXGBE_GSSR_MAC_CSR_SM);
2724 usleep_range(10000, 20000); 2736 usleep_range(10000, 20000);
2725 } 2737 }
2726 2738
@@ -2740,33 +2752,21 @@ out:
2740 **/ 2752 **/
2741s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index) 2753s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index)
2742{ 2754{
2743 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); 2755 u32 autoc_reg = 0;
2744 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); 2756 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
2745 s32 ret_val = 0; 2757 s32 ret_val = 0;
2746 bool got_lock = false; 2758 bool locked = false;
2747 2759
2748 /* Need the SW/FW semaphore around AUTOC writes if 82599 and 2760 ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg);
2749 * LESM is on. 2761 if (!ret_val)
2750 */ 2762 goto out;
2751 if ((hw->mac.type == ixgbe_mac_82599EB) &&
2752 ixgbe_verify_lesm_fw_enabled_82599(hw)) {
2753 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
2754 IXGBE_GSSR_MAC_CSR_SM);
2755 if (ret_val)
2756 goto out;
2757
2758 got_lock = true;
2759 }
2760 2763
2761 autoc_reg &= ~IXGBE_AUTOC_FLU; 2764 autoc_reg &= ~IXGBE_AUTOC_FLU;
2762 autoc_reg |= IXGBE_AUTOC_AN_RESTART; 2765 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
2763 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
2764 2766
2765 if (hw->mac.type == ixgbe_mac_82599EB) 2767 ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked);
2766 ixgbe_reset_pipeline_82599(hw); 2768 if (!ret_val)
2767 2769 goto out;
2768 if (got_lock)
2769 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
2770 2770
2771 led_reg &= ~IXGBE_LED_MODE_MASK(index); 2771 led_reg &= ~IXGBE_LED_MODE_MASK(index);
2772 led_reg &= ~IXGBE_LED_BLINK(index); 2772 led_reg &= ~IXGBE_LED_BLINK(index);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index f2e3919750ec..a042db2997f7 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -98,6 +98,10 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw,
98 bool *link_up, bool link_up_wait_to_complete); 98 bool *link_up, bool link_up_wait_to_complete);
99s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix, 99s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix,
100 u16 *wwpn_prefix); 100 u16 *wwpn_prefix);
101
102s32 prot_autoc_read_generic(struct ixgbe_hw *hw, bool *, u32 *reg_val);
103s32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 reg_val, bool locked);
104
101s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index); 105s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index);
102s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index); 106s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index);
103void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf); 107void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf);
@@ -109,7 +113,6 @@ void ixgbe_clear_tx_pending(struct ixgbe_hw *hw);
109 113
110void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, 114void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb,
111 u32 headroom, int strategy); 115 u32 headroom, int strategy);
112s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);
113 116
114#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8 117#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8
115#define IXGBE_EMC_INTERNAL_DATA 0x00 118#define IXGBE_EMC_INTERNAL_DATA 0x00
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 245819d7ec15..692341f4e503 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -2870,6 +2870,8 @@ struct ixgbe_mac_operations {
2870 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); 2870 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32);
2871 s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u16); 2871 s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u16);
2872 void (*release_swfw_sync)(struct ixgbe_hw *, u16); 2872 void (*release_swfw_sync)(struct ixgbe_hw *, u16);
2873 s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *);
2874 s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool);
2873 2875
2874 /* Link */ 2876 /* Link */
2875 void (*disable_tx_laser)(struct ixgbe_hw *); 2877 void (*disable_tx_laser)(struct ixgbe_hw *);
@@ -2969,7 +2971,6 @@ struct ixgbe_mac_info {
2969 u32 max_tx_queues; 2971 u32 max_tx_queues;
2970 u32 max_rx_queues; 2972 u32 max_rx_queues;
2971 u32 orig_autoc; 2973 u32 orig_autoc;
2972 u32 cached_autoc;
2973 u32 orig_autoc2; 2974 u32 orig_autoc2;
2974 bool orig_link_settings_stored; 2975 bool orig_link_settings_stored;
2975 bool autotry_restart; 2976 bool autotry_restart;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
index 24b80a6cfca4..c870f37f15d3 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
@@ -855,6 +855,8 @@ static struct ixgbe_mac_operations mac_ops_X540 = {
855 .get_thermal_sensor_data = NULL, 855 .get_thermal_sensor_data = NULL,
856 .init_thermal_sensor_thresh = NULL, 856 .init_thermal_sensor_thresh = NULL,
857 .mng_fw_enabled = NULL, 857 .mng_fw_enabled = NULL,
858 .prot_autoc_read = &prot_autoc_read_generic,
859 .prot_autoc_write = &prot_autoc_write_generic,
858}; 860};
859 861
860static struct ixgbe_eeprom_operations eeprom_ops_X540 = { 862static struct ixgbe_eeprom_operations eeprom_ops_X540 = {