blob: 5ef968a10d42c4816177246a8675f3ee28a71f4c [file] [log] [blame]
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001/*******************************************************************************
2
3 Intel 10 Gigabit PCI Express Linux driver
Don Skidmorea52055e2011-02-23 09:58:39 +00004 Copyright(c) 1999 - 2011 Intel Corporation.
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00005
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25
26*******************************************************************************/
27
28#include <linux/pci.h>
29#include <linux/delay.h>
30#include <linux/sched.h>
31
32#include "ixgbe.h"
33#include "ixgbe_phy.h"
Greg Rose096a58f2010-01-09 02:26:26 +000034#include "ixgbe_mbx.h"
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000035
36#define IXGBE_82599_MAX_TX_QUEUES 128
37#define IXGBE_82599_MAX_RX_QUEUES 128
38#define IXGBE_82599_RAR_ENTRIES 128
39#define IXGBE_82599_MC_TBL_SIZE 128
40#define IXGBE_82599_VFT_TBL_SIZE 128
41
Emil Tantilov5d5b7c32010-10-12 22:20:59 +000042static void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
43static void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
44static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
45static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
46 ixgbe_link_speed speed,
47 bool autoneg,
48 bool autoneg_wait_to_complete);
Don Skidmorecd7e1f02009-10-08 15:36:22 +000049static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
50 ixgbe_link_speed speed,
51 bool autoneg,
52 bool autoneg_wait_to_complete);
Emil Tantilov5d5b7c32010-10-12 22:20:59 +000053static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
54 bool autoneg_wait_to_complete);
55static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +000056 ixgbe_link_speed speed,
57 bool autoneg,
58 bool autoneg_wait_to_complete);
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +000059static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
60 ixgbe_link_speed speed,
61 bool autoneg,
62 bool autoneg_wait_to_complete);
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +000063static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000064
Don Skidmore7b25cdb2009-08-25 04:47:32 +000065static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000066{
67 struct ixgbe_mac_info *mac = &hw->mac;
Don Skidmorec6ecf392010-12-03 03:31:51 +000068
69 /* enable the laser control functions for SFP+ fiber */
70 if (mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) {
Peter Waskiewicz61fac742010-04-27 00:38:15 +000071 mac->ops.disable_tx_laser =
72 &ixgbe_disable_tx_laser_multispeed_fiber;
73 mac->ops.enable_tx_laser =
74 &ixgbe_enable_tx_laser_multispeed_fiber;
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +000075 mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000076 } else {
Peter Waskiewicz61fac742010-04-27 00:38:15 +000077 mac->ops.disable_tx_laser = NULL;
78 mac->ops.enable_tx_laser = NULL;
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +000079 mac->ops.flap_tx_laser = NULL;
Don Skidmorec6ecf392010-12-03 03:31:51 +000080 }
81
82 if (hw->phy.multispeed_fiber) {
83 /* Set up dual speed SFP+ support */
84 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber;
85 } else {
Don Skidmorecd7e1f02009-10-08 15:36:22 +000086 if ((mac->ops.get_media_type(hw) ==
87 ixgbe_media_type_backplane) &&
88 (hw->phy.smart_speed == ixgbe_smart_speed_auto ||
89 hw->phy.smart_speed == ixgbe_smart_speed_on))
90 mac->ops.setup_link = &ixgbe_setup_mac_link_smartspeed;
91 else
92 mac->ops.setup_link = &ixgbe_setup_mac_link_82599;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000093 }
94}
95
Don Skidmore7b25cdb2009-08-25 04:47:32 +000096static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000097{
98 s32 ret_val = 0;
Don Skidmorea7f5a5f2010-12-03 13:23:30 +000099 u32 reg_anlp1 = 0;
100 u32 i = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000101 u16 list_offset, data_offset, data_value;
102
103 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
104 ixgbe_init_mac_link_ops_82599(hw);
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000105
106 hw->phy.ops.reset = NULL;
107
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000108 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
109 &data_offset);
110
111 if (ret_val != 0)
112 goto setup_sfp_out;
113
Peter P Waskiewicz Jraa5aec82009-05-19 09:18:34 +0000114 /* PHY config will finish before releasing the semaphore */
Don Skidmore5e655102011-02-25 01:58:04 +0000115 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
116 IXGBE_GSSR_MAC_CSR_SM);
Peter P Waskiewicz Jraa5aec82009-05-19 09:18:34 +0000117 if (ret_val != 0) {
118 ret_val = IXGBE_ERR_SWFW_SYNC;
119 goto setup_sfp_out;
120 }
121
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000122 hw->eeprom.ops.read(hw, ++data_offset, &data_value);
123 while (data_value != 0xffff) {
124 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, data_value);
125 IXGBE_WRITE_FLUSH(hw);
126 hw->eeprom.ops.read(hw, ++data_offset, &data_value);
127 }
Peter P Waskiewicz Jraa5aec82009-05-19 09:18:34 +0000128
129 /* Release the semaphore */
130 ixgbe_release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
131 /* Delay obtaining semaphore again to allow FW access */
132 msleep(hw->eeprom.semaphore_delay);
Don Skidmorea7f5a5f2010-12-03 13:23:30 +0000133
134 /* Now restart DSP by setting Restart_AN and clearing LMS */
135 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((IXGBE_READ_REG(hw,
136 IXGBE_AUTOC) & ~IXGBE_AUTOC_LMS_MASK) |
137 IXGBE_AUTOC_AN_RESTART));
138
139 /* Wait for AN to leave state 0 */
140 for (i = 0; i < 10; i++) {
141 msleep(4);
142 reg_anlp1 = IXGBE_READ_REG(hw, IXGBE_ANLP1);
143 if (reg_anlp1 & IXGBE_ANLP1_AN_STATE_MASK)
144 break;
145 }
146 if (!(reg_anlp1 & IXGBE_ANLP1_AN_STATE_MASK)) {
147 hw_dbg(hw, "sfp module setup not complete\n");
148 ret_val = IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
149 goto setup_sfp_out;
150 }
151
152 /* Restart DSP by setting Restart_AN and return to SFI mode */
153 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (IXGBE_READ_REG(hw,
154 IXGBE_AUTOC) | IXGBE_AUTOC_LMS_10G_SERIAL |
155 IXGBE_AUTOC_AN_RESTART));
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000156 }
157
158setup_sfp_out:
159 return ret_val;
160}
161
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000162static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
163{
164 struct ixgbe_mac_info *mac = &hw->mac;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000165
166 ixgbe_init_mac_link_ops_82599(hw);
167
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000168 mac->mcft_size = IXGBE_82599_MC_TBL_SIZE;
169 mac->vft_size = IXGBE_82599_VFT_TBL_SIZE;
170 mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES;
171 mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES;
172 mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES;
Mallikarjuna R Chilakala21ce8492010-05-13 17:33:41 +0000173 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000174
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000175 return 0;
176}
177
178/**
179 * ixgbe_init_phy_ops_82599 - PHY/SFP specific init
180 * @hw: pointer to hardware structure
181 *
182 * Initialize any function pointers that were not able to be
183 * set during get_invariants because the PHY/SFP type was
184 * not known. Perform the SFP init if necessary.
185 *
186 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000187static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000188{
189 struct ixgbe_mac_info *mac = &hw->mac;
190 struct ixgbe_phy_info *phy = &hw->phy;
191 s32 ret_val = 0;
192
193 /* Identify the PHY or SFP module */
194 ret_val = phy->ops.identify(hw);
195
196 /* Setup function pointers based on detected SFP module and speeds */
197 ixgbe_init_mac_link_ops_82599(hw);
198
199 /* If copper media, overwrite with copper function pointers */
200 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
201 mac->ops.setup_link = &ixgbe_setup_copper_link_82599;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000202 mac->ops.get_link_capabilities =
Don Skidmorea391f1d2010-11-16 19:27:15 -0800203 &ixgbe_get_copper_link_capabilities_generic;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000204 }
205
206 /* Set necessary function pointers based on phy type */
207 switch (hw->phy.type) {
208 case ixgbe_phy_tn:
209 phy->ops.check_link = &ixgbe_check_phy_link_tnx;
210 phy->ops.get_firmware_version =
211 &ixgbe_get_phy_firmware_version_tnx;
212 break;
Don Skidmorefe15e8e2010-11-16 19:27:16 -0800213 case ixgbe_phy_aq:
214 phy->ops.get_firmware_version =
215 &ixgbe_get_phy_firmware_version_generic;
216 break;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000217 default:
218 break;
219 }
220
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000221 return ret_val;
222}
223
224/**
225 * ixgbe_get_link_capabilities_82599 - Determines link capabilities
226 * @hw: pointer to hardware structure
227 * @speed: pointer to link speed
228 * @negotiation: true when autoneg or autotry is enabled
229 *
230 * Determines the link capabilities by reading the AUTOC register.
231 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000232static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
233 ixgbe_link_speed *speed,
234 bool *negotiation)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000235{
236 s32 status = 0;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000237 u32 autoc = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000238
Don Skidmorecb836a92010-06-29 18:30:59 +0000239 /* Determine 1G link capabilities off of SFP+ type */
240 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
241 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1) {
242 *speed = IXGBE_LINK_SPEED_1GB_FULL;
243 *negotiation = true;
244 goto out;
245 }
246
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000247 /*
248 * Determine link capabilities based on the stored value of AUTOC,
249 * which represents EEPROM defaults. If AUTOC value has not been
250 * stored, use the current register value.
251 */
252 if (hw->mac.orig_link_settings_stored)
253 autoc = hw->mac.orig_autoc;
254 else
255 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
256
257 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000258 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
259 *speed = IXGBE_LINK_SPEED_1GB_FULL;
260 *negotiation = false;
261 break;
262
263 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
264 *speed = IXGBE_LINK_SPEED_10GB_FULL;
265 *negotiation = false;
266 break;
267
268 case IXGBE_AUTOC_LMS_1G_AN:
269 *speed = IXGBE_LINK_SPEED_1GB_FULL;
270 *negotiation = true;
271 break;
272
273 case IXGBE_AUTOC_LMS_10G_SERIAL:
274 *speed = IXGBE_LINK_SPEED_10GB_FULL;
275 *negotiation = false;
276 break;
277
278 case IXGBE_AUTOC_LMS_KX4_KX_KR:
279 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
280 *speed = IXGBE_LINK_SPEED_UNKNOWN;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000281 if (autoc & IXGBE_AUTOC_KR_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000282 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000283 if (autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000284 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000285 if (autoc & IXGBE_AUTOC_KX_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000286 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
287 *negotiation = true;
288 break;
289
290 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
291 *speed = IXGBE_LINK_SPEED_100_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000292 if (autoc & IXGBE_AUTOC_KR_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000293 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000294 if (autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000295 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000296 if (autoc & IXGBE_AUTOC_KX_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000297 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
298 *negotiation = true;
299 break;
300
301 case IXGBE_AUTOC_LMS_SGMII_1G_100M:
302 *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
303 *negotiation = false;
304 break;
305
306 default:
307 status = IXGBE_ERR_LINK_SETUP;
308 goto out;
309 break;
310 }
311
312 if (hw->phy.multispeed_fiber) {
313 *speed |= IXGBE_LINK_SPEED_10GB_FULL |
314 IXGBE_LINK_SPEED_1GB_FULL;
315 *negotiation = true;
316 }
317
318out:
319 return status;
320}
321
322/**
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000323 * ixgbe_get_media_type_82599 - Get media type
324 * @hw: pointer to hardware structure
325 *
326 * Returns the media type (fiber, copper, backplane)
327 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000328static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000329{
330 enum ixgbe_media_type media_type;
331
332 /* Detect if there is a copper PHY attached. */
Emil Tantilov21cc5b42011-02-12 10:52:07 +0000333 switch (hw->phy.type) {
334 case ixgbe_phy_cu_unknown:
335 case ixgbe_phy_tn:
336 case ixgbe_phy_aq:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000337 media_type = ixgbe_media_type_copper;
338 goto out;
Emil Tantilov21cc5b42011-02-12 10:52:07 +0000339 default:
340 break;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000341 }
342
343 switch (hw->device_id) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000344 case IXGBE_DEV_ID_82599_KX4:
Don Skidmoredbfec662009-10-02 08:58:25 +0000345 case IXGBE_DEV_ID_82599_KX4_MEZZ:
Don Skidmore312eb932009-10-02 08:58:04 +0000346 case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
Don Skidmore74757d42009-12-08 07:22:23 +0000347 case IXGBE_DEV_ID_82599_KR:
Don Skidmoredbffcb22010-12-03 03:32:34 +0000348 case IXGBE_DEV_ID_82599_BACKPLANE_FCOE:
Peter P Waskiewicz Jr1fcf03e2009-05-17 20:58:04 +0000349 case IXGBE_DEV_ID_82599_XAUI_LOM:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000350 /* Default device ID is mezzanine card KX/KX4 */
351 media_type = ixgbe_media_type_backplane;
352 break;
353 case IXGBE_DEV_ID_82599_SFP:
Don Skidmoredbffcb22010-12-03 03:32:34 +0000354 case IXGBE_DEV_ID_82599_SFP_FCOE:
Don Skidmore38ad1c82009-10-08 15:35:58 +0000355 case IXGBE_DEV_ID_82599_SFP_EM:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000356 media_type = ixgbe_media_type_fiber;
357 break;
Peter P Waskiewicz Jr89111842009-09-14 07:47:49 +0000358 case IXGBE_DEV_ID_82599_CX4:
Peter P Waskiewicz Jr6b1be192009-09-14 07:48:10 +0000359 media_type = ixgbe_media_type_cx4;
Peter P Waskiewicz Jr89111842009-09-14 07:47:49 +0000360 break;
Emil Tantilov21cc5b42011-02-12 10:52:07 +0000361 case IXGBE_DEV_ID_82599_T3_LOM:
362 media_type = ixgbe_media_type_copper;
363 break;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000364 default:
365 media_type = ixgbe_media_type_unknown;
366 break;
367 }
368out:
369 return media_type;
370}
371
372/**
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000373 * ixgbe_start_mac_link_82599 - Setup MAC link settings
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000374 * @hw: pointer to hardware structure
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000375 * @autoneg_wait_to_complete: true when waiting for completion is needed
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000376 *
377 * Configures link settings based on values in the ixgbe_hw struct.
378 * Restarts the link. Performs autonegotiation if needed.
379 **/
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000380static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000381 bool autoneg_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000382{
383 u32 autoc_reg;
384 u32 links_reg;
385 u32 i;
386 s32 status = 0;
387
388 /* Restart link */
389 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
390 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
391 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
392
393 /* Only poll for autoneg to complete if specified to do so */
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000394 if (autoneg_wait_to_complete) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000395 if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
396 IXGBE_AUTOC_LMS_KX4_KX_KR ||
397 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
398 IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
399 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
400 IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
401 links_reg = 0; /* Just in case Autoneg time = 0 */
402 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
403 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
404 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
405 break;
406 msleep(100);
407 }
408 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
409 status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
410 hw_dbg(hw, "Autoneg did not complete.\n");
411 }
412 }
413 }
414
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000415 /* Add delay to filter out noises during initial link setup */
416 msleep(50);
417
418 return status;
419}
420
Emil Tantilov8c7bea32011-02-19 08:43:44 +0000421/**
422 * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
423 * @hw: pointer to hardware structure
424 *
425 * The base drivers may require better control over SFP+ module
426 * PHY states. This includes selectively shutting down the Tx
427 * laser on the PHY, effectively halting physical link.
428 **/
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000429static void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
Peter Waskiewicz61fac742010-04-27 00:38:15 +0000430{
431 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
432
433 /* Disable tx laser; allow 100us to go dark per spec */
434 esdp_reg |= IXGBE_ESDP_SDP3;
435 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
436 IXGBE_WRITE_FLUSH(hw);
437 udelay(100);
438}
439
440/**
441 * ixgbe_enable_tx_laser_multispeed_fiber - Enable Tx laser
442 * @hw: pointer to hardware structure
443 *
444 * The base drivers may require better control over SFP+ module
445 * PHY states. This includes selectively turning on the Tx
446 * laser on the PHY, effectively starting physical link.
447 **/
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000448static void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
Peter Waskiewicz61fac742010-04-27 00:38:15 +0000449{
450 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
451
452 /* Enable tx laser; allow 100ms to light up */
453 esdp_reg &= ~IXGBE_ESDP_SDP3;
454 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
455 IXGBE_WRITE_FLUSH(hw);
456 msleep(100);
457}
458
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000459/**
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +0000460 * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser
461 * @hw: pointer to hardware structure
462 *
463 * When the driver changes the link speeds that it can support,
464 * it sets autotry_restart to true to indicate that we need to
465 * initiate a new autotry session with the link partner. To do
466 * so, we set the speed then disable and re-enable the tx laser, to
467 * alert the link partner that it also needs to restart autotry on its
468 * end. This is consistent with true clause 37 autoneg, which also
469 * involves a loss of signal.
470 **/
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000471static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +0000472{
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +0000473 hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n");
474
475 if (hw->mac.autotry_restart) {
Peter Waskiewicz61fac742010-04-27 00:38:15 +0000476 ixgbe_disable_tx_laser_multispeed_fiber(hw);
477 ixgbe_enable_tx_laser_multispeed_fiber(hw);
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +0000478 hw->mac.autotry_restart = false;
479 }
480}
481
482/**
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000483 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000484 * @hw: pointer to hardware structure
485 * @speed: new link speed
486 * @autoneg: true if autonegotiation enabled
487 * @autoneg_wait_to_complete: true when waiting for completion is needed
488 *
489 * Set the link speed in the AUTOC register and restarts link.
490 **/
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000491s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
492 ixgbe_link_speed speed,
493 bool autoneg,
494 bool autoneg_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000495{
496 s32 status = 0;
497 ixgbe_link_speed phy_link_speed;
498 ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
499 u32 speedcnt = 0;
500 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
501 bool link_up = false;
502 bool negotiation;
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000503 int i;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000504
505 /* Mask off requested but non-supported speeds */
506 hw->mac.ops.get_link_capabilities(hw, &phy_link_speed, &negotiation);
507 speed &= phy_link_speed;
508
509 /*
510 * Try each speed one by one, highest priority first. We do this in
511 * software because 10gb fiber doesn't support speed autonegotiation.
512 */
513 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
514 speedcnt++;
515 highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL;
516
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000517 /* If we already have link at this speed, just jump out */
518 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
519
520 if ((phy_link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
521 goto out;
522
523 /* Set the module link speed */
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000524 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
525 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +0000526 IXGBE_WRITE_FLUSH(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000527
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000528 /* Allow module to change analog characteristics (1G->10G) */
529 msleep(40);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000530
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000531 status = ixgbe_setup_mac_link_82599(hw,
532 IXGBE_LINK_SPEED_10GB_FULL,
533 autoneg,
534 autoneg_wait_to_complete);
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000535 if (status != 0)
Mallikarjuna R Chilakalac3c74322009-09-01 13:50:14 +0000536 return status;
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000537
538 /* Flap the tx laser if it has not already been done */
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +0000539 hw->mac.ops.flap_tx_laser(hw);
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000540
Don Skidmorecd7e1f02009-10-08 15:36:22 +0000541 /*
542 * Wait for the controller to acquire link. Per IEEE 802.3ap,
543 * Section 73.10.2, we may have to wait up to 500ms if KR is
544 * attempted. 82599 uses the same timing for 10g SFI.
545 */
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000546 for (i = 0; i < 5; i++) {
547 /* Wait for the link partner to also set speed */
548 msleep(100);
549
550 /* If we have link, just jump out */
551 hw->mac.ops.check_link(hw, &phy_link_speed,
552 &link_up, false);
553 if (link_up)
554 goto out;
555 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000556 }
557
558 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
559 speedcnt++;
560 if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN)
561 highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL;
562
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000563 /* If we already have link at this speed, just jump out */
564 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
565
566 if ((phy_link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
567 goto out;
568
569 /* Set the module link speed */
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000570 esdp_reg &= ~IXGBE_ESDP_SDP5;
571 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
572 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +0000573 IXGBE_WRITE_FLUSH(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000574
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000575 /* Allow module to change analog characteristics (10G->1G) */
576 msleep(40);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000577
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000578 status = ixgbe_setup_mac_link_82599(hw,
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000579 IXGBE_LINK_SPEED_1GB_FULL,
580 autoneg,
581 autoneg_wait_to_complete);
582 if (status != 0)
Mallikarjuna R Chilakalac3c74322009-09-01 13:50:14 +0000583 return status;
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000584
585 /* Flap the tx laser if it has not already been done */
Mallikarjuna R Chilakala1097cd12010-03-18 14:34:52 +0000586 hw->mac.ops.flap_tx_laser(hw);
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000587
588 /* Wait for the link partner to also set speed */
589 msleep(100);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000590
591 /* If we have link, just jump out */
592 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
593 if (link_up)
594 goto out;
595 }
596
597 /*
598 * We didn't get link. Configure back to the highest speed we tried,
599 * (if there was more than one). We call ourselves back with just the
600 * single highest speed that the user requested.
601 */
602 if (speedcnt > 1)
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000603 status = ixgbe_setup_mac_link_multispeed_fiber(hw,
604 highest_link_speed,
605 autoneg,
606 autoneg_wait_to_complete);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000607
608out:
Mallikarjuna R Chilakalac3c74322009-09-01 13:50:14 +0000609 /* Set autoneg_advertised value based on input link speed */
610 hw->phy.autoneg_advertised = 0;
611
612 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
613 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
614
615 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
616 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
617
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000618 return status;
619}
620
621/**
Don Skidmorecd7e1f02009-10-08 15:36:22 +0000622 * ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed
623 * @hw: pointer to hardware structure
624 * @speed: new link speed
625 * @autoneg: true if autonegotiation enabled
626 * @autoneg_wait_to_complete: true when waiting for completion is needed
627 *
628 * Implements the Intel SmartSpeed algorithm.
629 **/
630static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
631 ixgbe_link_speed speed, bool autoneg,
632 bool autoneg_wait_to_complete)
633{
634 s32 status = 0;
635 ixgbe_link_speed link_speed;
636 s32 i, j;
637 bool link_up = false;
638 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
Anjali Singhaic4ee6a52010-04-27 11:31:25 +0000639 struct ixgbe_adapter *adapter = hw->back;
Don Skidmorecd7e1f02009-10-08 15:36:22 +0000640
641 hw_dbg(hw, "ixgbe_setup_mac_link_smartspeed.\n");
642
643 /* Set autoneg_advertised value based on input link speed */
644 hw->phy.autoneg_advertised = 0;
645
646 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
647 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
648
649 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
650 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
651
652 if (speed & IXGBE_LINK_SPEED_100_FULL)
653 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
654
655 /*
656 * Implement Intel SmartSpeed algorithm. SmartSpeed will reduce the
657 * autoneg advertisement if link is unable to be established at the
658 * highest negotiated rate. This can sometimes happen due to integrity
659 * issues with the physical media connection.
660 */
661
662 /* First, try to get link with full advertisement */
663 hw->phy.smart_speed_active = false;
664 for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) {
665 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
666 autoneg_wait_to_complete);
667 if (status)
668 goto out;
669
670 /*
671 * Wait for the controller to acquire link. Per IEEE 802.3ap,
672 * Section 73.10.2, we may have to wait up to 500ms if KR is
673 * attempted, or 200ms if KX/KX4/BX/BX4 is attempted, per
674 * Table 9 in the AN MAS.
675 */
676 for (i = 0; i < 5; i++) {
677 mdelay(100);
678
679 /* If we have link, just jump out */
680 hw->mac.ops.check_link(hw, &link_speed,
681 &link_up, false);
682 if (link_up)
683 goto out;
684 }
685 }
686
687 /*
688 * We didn't get link. If we advertised KR plus one of KX4/KX
689 * (or BX4/BX), then disable KR and try again.
690 */
691 if (((autoc_reg & IXGBE_AUTOC_KR_SUPP) == 0) ||
692 ((autoc_reg & IXGBE_AUTOC_KX4_KX_SUPP_MASK) == 0))
693 goto out;
694
695 /* Turn SmartSpeed on to disable KR support */
696 hw->phy.smart_speed_active = true;
697 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
698 autoneg_wait_to_complete);
699 if (status)
700 goto out;
701
702 /*
703 * Wait for the controller to acquire link. 600ms will allow for
704 * the AN link_fail_inhibit_timer as well for multiple cycles of
705 * parallel detect, both 10g and 1g. This allows for the maximum
706 * connect attempts as defined in the AN MAS table 73-7.
707 */
708 for (i = 0; i < 6; i++) {
709 mdelay(100);
710
711 /* If we have link, just jump out */
712 hw->mac.ops.check_link(hw, &link_speed,
713 &link_up, false);
714 if (link_up)
715 goto out;
716 }
717
718 /* We didn't get link. Turn SmartSpeed back off. */
719 hw->phy.smart_speed_active = false;
720 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
721 autoneg_wait_to_complete);
722
723out:
Anjali Singhaic4ee6a52010-04-27 11:31:25 +0000724 if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL))
Emil Tantilov396e7992010-07-01 20:05:12 +0000725 e_info(hw, "Smartspeed has downgraded the link speed from "
Emil Tantilov849c4542010-06-03 16:53:41 +0000726 "the maximum advertised\n");
Don Skidmorecd7e1f02009-10-08 15:36:22 +0000727 return status;
728}
729
730/**
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000731 * ixgbe_setup_mac_link_82599 - Set MAC link speed
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000732 * @hw: pointer to hardware structure
733 * @speed: new link speed
734 * @autoneg: true if autonegotiation enabled
735 * @autoneg_wait_to_complete: true when waiting for completion is needed
736 *
737 * Set the link speed in the AUTOC register and restarts link.
738 **/
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000739static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000740 ixgbe_link_speed speed, bool autoneg,
741 bool autoneg_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000742{
743 s32 status = 0;
744 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
745 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000746 u32 start_autoc = autoc;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000747 u32 orig_autoc = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000748 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
749 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
750 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
751 u32 links_reg;
752 u32 i;
753 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
754
755 /* Check to see if speed passed in is supported. */
756 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg);
757 speed &= link_capabilities;
758
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000759 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
760 status = IXGBE_ERR_LINK_SETUP;
761 goto out;
762 }
763
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000764 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
765 if (hw->mac.orig_link_settings_stored)
766 orig_autoc = hw->mac.orig_autoc;
767 else
768 orig_autoc = autoc;
769
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000770 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
771 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
772 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000773 /* Set KX4/KX/KR support according to speed requested */
774 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
775 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000776 if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000777 autoc |= IXGBE_AUTOC_KX4_SUPP;
Don Skidmorecd7e1f02009-10-08 15:36:22 +0000778 if ((orig_autoc & IXGBE_AUTOC_KR_SUPP) &&
779 (hw->phy.smart_speed_active == false))
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000780 autoc |= IXGBE_AUTOC_KR_SUPP;
781 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
782 autoc |= IXGBE_AUTOC_KX_SUPP;
783 } else if ((pma_pmd_1g == IXGBE_AUTOC_1G_SFI) &&
784 (link_mode == IXGBE_AUTOC_LMS_1G_LINK_NO_AN ||
785 link_mode == IXGBE_AUTOC_LMS_1G_AN)) {
786 /* Switch from 1G SFI to 10G SFI if requested */
787 if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&
788 (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)) {
789 autoc &= ~IXGBE_AUTOC_LMS_MASK;
790 autoc |= IXGBE_AUTOC_LMS_10G_SERIAL;
791 }
792 } else if ((pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI) &&
793 (link_mode == IXGBE_AUTOC_LMS_10G_SERIAL)) {
794 /* Switch from 10G SFI to 1G SFI if requested */
795 if ((speed == IXGBE_LINK_SPEED_1GB_FULL) &&
796 (pma_pmd_1g == IXGBE_AUTOC_1G_SFI)) {
797 autoc &= ~IXGBE_AUTOC_LMS_MASK;
798 if (autoneg)
799 autoc |= IXGBE_AUTOC_LMS_1G_AN;
800 else
801 autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
802 }
803 }
804
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000805 if (autoc != start_autoc) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000806 /* Restart link */
807 autoc |= IXGBE_AUTOC_AN_RESTART;
808 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
809
810 /* Only poll for autoneg to complete if specified to do so */
811 if (autoneg_wait_to_complete) {
812 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
813 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
814 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
815 links_reg = 0; /*Just in case Autoneg time=0*/
816 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
817 links_reg =
818 IXGBE_READ_REG(hw, IXGBE_LINKS);
819 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
820 break;
821 msleep(100);
822 }
823 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
824 status =
825 IXGBE_ERR_AUTONEG_NOT_COMPLETE;
826 hw_dbg(hw, "Autoneg did not "
827 "complete.\n");
828 }
829 }
830 }
831
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000832 /* Add delay to filter out noises during initial link setup */
833 msleep(50);
834 }
835
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000836out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000837 return status;
838}
839
840/**
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000841 * ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000842 * @hw: pointer to hardware structure
843 * @speed: new link speed
844 * @autoneg: true if autonegotiation enabled
845 * @autoneg_wait_to_complete: true if waiting is needed to complete
846 *
847 * Restarts link on PHY and MAC based on settings passed in.
848 **/
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000849static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
850 ixgbe_link_speed speed,
851 bool autoneg,
852 bool autoneg_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000853{
854 s32 status;
855
856 /* Setup the PHY according to input speed */
857 status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
858 autoneg_wait_to_complete);
859 /* Set up MAC */
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000860 ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000861
862 return status;
863}
864
865/**
866 * ixgbe_reset_hw_82599 - Perform hardware reset
867 * @hw: pointer to hardware structure
868 *
869 * Resets the hardware by resetting the transmit and receive units, masks
870 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
871 * reset.
872 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000873static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000874{
875 s32 status = 0;
Greg Rosec9205692010-01-22 22:46:22 +0000876 u32 ctrl;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000877 u32 i;
878 u32 autoc;
879 u32 autoc2;
880
881 /* Call adapter stop to disable tx/rx and clear interrupts */
882 hw->mac.ops.stop_adapter(hw);
883
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000884 /* PHY ops must be identified and initialized prior to reset */
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000885
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000886 /* Init PHY and function pointers, perform SFP setup */
887 status = hw->phy.ops.init(hw);
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000888
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000889 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
890 goto reset_hw_out;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000891
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000892 /* Setup SFP module if there is one present. */
893 if (hw->phy.sfp_setup_needed) {
894 status = hw->mac.ops.setup_sfp(hw);
895 hw->phy.sfp_setup_needed = false;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000896 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000897
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000898 /* Reset PHY */
899 if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL)
900 hw->phy.ops.reset(hw);
901
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000902 /*
903 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
904 * access and verify no pending requests before reset
905 */
Emil Tantilova4297dc2011-02-14 08:45:13 +0000906 ixgbe_disable_pcie_master(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000907
Emil Tantilova4297dc2011-02-14 08:45:13 +0000908mac_reset_top:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000909 /*
910 * Issue global reset to the MAC. This needs to be a SW reset.
911 * If link reset is used, it might reset the MAC when mng is using it
912 */
913 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
914 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST));
915 IXGBE_WRITE_FLUSH(hw);
916
917 /* Poll for reset bit to self-clear indicating reset is complete */
918 for (i = 0; i < 10; i++) {
919 udelay(1);
920 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
921 if (!(ctrl & IXGBE_CTRL_RST))
922 break;
923 }
924 if (ctrl & IXGBE_CTRL_RST) {
925 status = IXGBE_ERR_RESET_FAILED;
926 hw_dbg(hw, "Reset polling failed to complete.\n");
927 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000928
Emil Tantilova4297dc2011-02-14 08:45:13 +0000929 /*
930 * Double resets are required for recovery from certain error
931 * conditions. Between resets, it is necessary to stall to allow time
932 * for any pending HW events to complete. We use 1usec since that is
933 * what is needed for ixgbe_disable_pcie_master(). The second reset
934 * then clears out any effects of those events.
935 */
936 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
937 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
938 udelay(1);
939 goto mac_reset_top;
940 }
941
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000942 msleep(50);
943
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000944 /*
945 * Store the original AUTOC/AUTOC2 values if they have not been
946 * stored off yet. Otherwise restore the stored original
947 * values since the reset operation sets back to defaults.
948 */
949 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
950 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
951 if (hw->mac.orig_link_settings_stored == false) {
952 hw->mac.orig_autoc = autoc;
953 hw->mac.orig_autoc2 = autoc2;
954 hw->mac.orig_link_settings_stored = true;
Jesse Brandeburg4df10462009-03-13 22:15:31 +0000955 } else {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000956 if (autoc != hw->mac.orig_autoc)
957 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (hw->mac.orig_autoc |
958 IXGBE_AUTOC_AN_RESTART));
959
960 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
961 (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
962 autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
963 autoc2 |= (hw->mac.orig_autoc2 &
964 IXGBE_AUTOC2_UPPER_MASK);
965 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
966 }
967 }
968
Emil Tantilov278675d2011-02-19 08:43:49 +0000969 /* Store the permanent mac address */
970 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
971
Waskiewicz Jr, Peter Paca6bee2009-05-17 12:32:48 +0000972 /*
973 * Store MAC address from RAR0, clear receive address registers, and
974 * clear the multicast table. Also reset num_rar_entries to 128,
975 * since we modify this value when programming the SAN MAC address.
976 */
977 hw->mac.num_rar_entries = 128;
978 hw->mac.ops.init_rx_addrs(hw);
979
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +0000980 /* Store the permanent SAN mac address */
981 hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
982
Waskiewicz Jr, Peter Paca6bee2009-05-17 12:32:48 +0000983 /* Add the SAN MAC address to the RAR only if it's a valid address */
984 if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
985 hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
986 hw->mac.san_addr, 0, IXGBE_RAH_AV);
987
988 /* Reserve the last RAR for the SAN MAC address */
989 hw->mac.num_rar_entries--;
990 }
991
Yi Zou383ff342009-10-28 18:23:57 +0000992 /* Store the alternative WWNN/WWPN prefix */
993 hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
994 &hw->mac.wwpn_prefix);
995
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000996reset_hw_out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000997 return status;
998}
999
1000/**
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001001 * ixgbe_reinit_fdir_tables_82599 - Reinitialize Flow Director tables.
1002 * @hw: pointer to hardware structure
1003 **/
1004s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
1005{
1006 int i;
1007 u32 fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
1008 fdirctrl &= ~IXGBE_FDIRCTRL_INIT_DONE;
1009
1010 /*
1011 * Before starting reinitialization process,
1012 * FDIRCMD.CMD must be zero.
1013 */
1014 for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) {
1015 if (!(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
1016 IXGBE_FDIRCMD_CMD_MASK))
1017 break;
1018 udelay(10);
1019 }
1020 if (i >= IXGBE_FDIRCMD_CMD_POLL) {
Alexander Duyck905e4a42011-01-06 14:29:57 +00001021 hw_dbg(hw, "Flow Director previous command isn't complete, "
Frans Popd6dbee82010-03-24 07:57:35 +00001022 "aborting table re-initialization.\n");
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001023 return IXGBE_ERR_FDIR_REINIT_FAILED;
1024 }
1025
1026 IXGBE_WRITE_REG(hw, IXGBE_FDIRFREE, 0);
1027 IXGBE_WRITE_FLUSH(hw);
1028 /*
1029 * 82599 adapters flow director init flow cannot be restarted,
1030 * Workaround 82599 silicon errata by performing the following steps
1031 * before re-writing the FDIRCTRL control register with the same value.
1032 * - write 1 to bit 8 of FDIRCMD register &
1033 * - write 0 to bit 8 of FDIRCMD register
1034 */
1035 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
1036 (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) |
1037 IXGBE_FDIRCMD_CLEARHT));
1038 IXGBE_WRITE_FLUSH(hw);
1039 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
1040 (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
1041 ~IXGBE_FDIRCMD_CLEARHT));
1042 IXGBE_WRITE_FLUSH(hw);
1043 /*
1044 * Clear FDIR Hash register to clear any leftover hashes
1045 * waiting to be programmed.
1046 */
1047 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, 0x00);
1048 IXGBE_WRITE_FLUSH(hw);
1049
1050 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1051 IXGBE_WRITE_FLUSH(hw);
1052
1053 /* Poll init-done after we write FDIRCTRL register */
1054 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1055 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1056 IXGBE_FDIRCTRL_INIT_DONE)
1057 break;
1058 udelay(10);
1059 }
1060 if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
1061 hw_dbg(hw, "Flow Director Signature poll time exceeded!\n");
1062 return IXGBE_ERR_FDIR_REINIT_FAILED;
1063 }
1064
1065 /* Clear FDIR statistics registers (read to clear) */
1066 IXGBE_READ_REG(hw, IXGBE_FDIRUSTAT);
1067 IXGBE_READ_REG(hw, IXGBE_FDIRFSTAT);
1068 IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
1069 IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
1070 IXGBE_READ_REG(hw, IXGBE_FDIRLEN);
1071
1072 return 0;
1073}
1074
1075/**
1076 * ixgbe_init_fdir_signature_82599 - Initialize Flow Director signature filters
1077 * @hw: pointer to hardware structure
1078 * @pballoc: which mode to allocate filters with
1079 **/
1080s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 pballoc)
1081{
1082 u32 fdirctrl = 0;
1083 u32 pbsize;
1084 int i;
1085
1086 /*
1087 * Before enabling Flow Director, the Rx Packet Buffer size
1088 * must be reduced. The new value is the current size minus
1089 * flow director memory usage size.
1090 */
1091 pbsize = (1 << (IXGBE_FDIR_PBALLOC_SIZE_SHIFT + pballoc));
1092 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0),
1093 (IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0)) - pbsize));
1094
1095 /*
1096 * The defaults in the HW for RX PB 1-7 are not zero and so should be
Uwe Kleine-Königb5950762010-11-01 15:38:34 -04001097 * initialized to zero for non DCB mode otherwise actual total RX PB
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001098 * would be bigger than programmed and filter space would run into
1099 * the PB 0 region.
1100 */
1101 for (i = 1; i < 8; i++)
1102 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
1103
1104 /* Send interrupt when 64 filters are left */
1105 fdirctrl |= 4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT;
1106
1107 /* Set the maximum length per hash bucket to 0xA filters */
1108 fdirctrl |= 0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT;
1109
1110 switch (pballoc) {
1111 case IXGBE_FDIR_PBALLOC_64K:
1112 /* 8k - 1 signature filters */
1113 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_64K;
1114 break;
1115 case IXGBE_FDIR_PBALLOC_128K:
1116 /* 16k - 1 signature filters */
1117 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_128K;
1118 break;
1119 case IXGBE_FDIR_PBALLOC_256K:
1120 /* 32k - 1 signature filters */
1121 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_256K;
1122 break;
1123 default:
1124 /* bad value */
1125 return IXGBE_ERR_CONFIG;
1126 };
1127
1128 /* Move the flexible bytes to use the ethertype - shift 6 words */
1129 fdirctrl |= (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT);
1130
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001131
1132 /* Prime the keys for hashing */
Alexander Duyck905e4a42011-01-06 14:29:57 +00001133 IXGBE_WRITE_REG(hw, IXGBE_FDIRHKEY, IXGBE_ATR_BUCKET_HASH_KEY);
1134 IXGBE_WRITE_REG(hw, IXGBE_FDIRSKEY, IXGBE_ATR_SIGNATURE_HASH_KEY);
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001135
1136 /*
1137 * Poll init-done after we write the register. Estimated times:
1138 * 10G: PBALLOC = 11b, timing is 60us
1139 * 1G: PBALLOC = 11b, timing is 600us
1140 * 100M: PBALLOC = 11b, timing is 6ms
1141 *
1142 * Multiple these timings by 4 if under full Rx load
1143 *
1144 * So we'll poll for IXGBE_FDIR_INIT_DONE_POLL times, sleeping for
1145 * 1 msec per poll time. If we're at line rate and drop to 100M, then
1146 * this might not finish in our poll time, but we can live with that
1147 * for now.
1148 */
1149 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1150 IXGBE_WRITE_FLUSH(hw);
1151 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1152 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1153 IXGBE_FDIRCTRL_INIT_DONE)
1154 break;
1155 msleep(1);
1156 }
1157 if (i >= IXGBE_FDIR_INIT_DONE_POLL)
1158 hw_dbg(hw, "Flow Director Signature poll time exceeded!\n");
1159
1160 return 0;
1161}
1162
1163/**
1164 * ixgbe_init_fdir_perfect_82599 - Initialize Flow Director perfect filters
1165 * @hw: pointer to hardware structure
1166 * @pballoc: which mode to allocate filters with
1167 **/
1168s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 pballoc)
1169{
1170 u32 fdirctrl = 0;
1171 u32 pbsize;
1172 int i;
1173
1174 /*
1175 * Before enabling Flow Director, the Rx Packet Buffer size
1176 * must be reduced. The new value is the current size minus
1177 * flow director memory usage size.
1178 */
1179 pbsize = (1 << (IXGBE_FDIR_PBALLOC_SIZE_SHIFT + pballoc));
1180 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0),
1181 (IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0)) - pbsize));
1182
1183 /*
1184 * The defaults in the HW for RX PB 1-7 are not zero and so should be
Uwe Kleine-Königb5950762010-11-01 15:38:34 -04001185 * initialized to zero for non DCB mode otherwise actual total RX PB
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001186 * would be bigger than programmed and filter space would run into
1187 * the PB 0 region.
1188 */
1189 for (i = 1; i < 8; i++)
1190 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
1191
1192 /* Send interrupt when 64 filters are left */
1193 fdirctrl |= 4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT;
1194
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001195 /* Initialize the drop queue to Rx queue 127 */
1196 fdirctrl |= (127 << IXGBE_FDIRCTRL_DROP_Q_SHIFT);
1197
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001198 switch (pballoc) {
1199 case IXGBE_FDIR_PBALLOC_64K:
1200 /* 2k - 1 perfect filters */
1201 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_64K;
1202 break;
1203 case IXGBE_FDIR_PBALLOC_128K:
1204 /* 4k - 1 perfect filters */
1205 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_128K;
1206 break;
1207 case IXGBE_FDIR_PBALLOC_256K:
1208 /* 8k - 1 perfect filters */
1209 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_256K;
1210 break;
1211 default:
1212 /* bad value */
1213 return IXGBE_ERR_CONFIG;
1214 };
1215
1216 /* Turn perfect match filtering on */
1217 fdirctrl |= IXGBE_FDIRCTRL_PERFECT_MATCH;
1218 fdirctrl |= IXGBE_FDIRCTRL_REPORT_STATUS;
1219
1220 /* Move the flexible bytes to use the ethertype - shift 6 words */
1221 fdirctrl |= (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT);
1222
1223 /* Prime the keys for hashing */
Alexander Duyck905e4a42011-01-06 14:29:57 +00001224 IXGBE_WRITE_REG(hw, IXGBE_FDIRHKEY, IXGBE_ATR_BUCKET_HASH_KEY);
1225 IXGBE_WRITE_REG(hw, IXGBE_FDIRSKEY, IXGBE_ATR_SIGNATURE_HASH_KEY);
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001226
1227 /*
1228 * Poll init-done after we write the register. Estimated times:
1229 * 10G: PBALLOC = 11b, timing is 60us
1230 * 1G: PBALLOC = 11b, timing is 600us
1231 * 100M: PBALLOC = 11b, timing is 6ms
1232 *
1233 * Multiple these timings by 4 if under full Rx load
1234 *
1235 * So we'll poll for IXGBE_FDIR_INIT_DONE_POLL times, sleeping for
1236 * 1 msec per poll time. If we're at line rate and drop to 100M, then
1237 * this might not finish in our poll time, but we can live with that
1238 * for now.
1239 */
1240
1241 /* Set the maximum length per hash bucket to 0xA filters */
1242 fdirctrl |= (0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT);
1243
1244 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1245 IXGBE_WRITE_FLUSH(hw);
1246 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1247 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1248 IXGBE_FDIRCTRL_INIT_DONE)
1249 break;
1250 msleep(1);
1251 }
1252 if (i >= IXGBE_FDIR_INIT_DONE_POLL)
1253 hw_dbg(hw, "Flow Director Perfect poll time exceeded!\n");
1254
1255 return 0;
1256}
1257
1258
1259/**
1260 * ixgbe_atr_compute_hash_82599 - Compute the hashes for SW ATR
1261 * @stream: input bitstream to compute the hash on
1262 * @key: 32-bit hash key
1263 **/
Alexander Duyck905e4a42011-01-06 14:29:57 +00001264static u32 ixgbe_atr_compute_hash_82599(union ixgbe_atr_input *atr_input,
1265 u32 key)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001266{
1267 /*
1268 * The algorithm is as follows:
1269 * Hash[15:0] = Sum { S[n] x K[n+16] }, n = 0...350
1270 * where Sum {A[n]}, n = 0...n is bitwise XOR of A[0], A[1]...A[n]
1271 * and A[n] x B[n] is bitwise AND between same length strings
1272 *
1273 * K[n] is 16 bits, defined as:
1274 * for n modulo 32 >= 15, K[n] = K[n % 32 : (n % 32) - 15]
1275 * for n modulo 32 < 15, K[n] =
1276 * K[(n % 32:0) | (31:31 - (14 - (n % 32)))]
1277 *
1278 * S[n] is 16 bits, defined as:
1279 * for n >= 15, S[n] = S[n:n - 15]
1280 * for n < 15, S[n] = S[(n:0) | (350:350 - (14 - n))]
1281 *
1282 * To simplify for programming, the algorithm is implemented
1283 * in software this way:
1284 *
Alexander Duyck905e4a42011-01-06 14:29:57 +00001285 * key[31:0], hi_hash_dword[31:0], lo_hash_dword[31:0], hash[15:0]
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001286 *
Alexander Duyck905e4a42011-01-06 14:29:57 +00001287 * for (i = 0; i < 352; i+=32)
1288 * hi_hash_dword[31:0] ^= Stream[(i+31):i];
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001289 *
Alexander Duyck905e4a42011-01-06 14:29:57 +00001290 * lo_hash_dword[15:0] ^= Stream[15:0];
1291 * lo_hash_dword[15:0] ^= hi_hash_dword[31:16];
1292 * lo_hash_dword[31:16] ^= hi_hash_dword[15:0];
1293 *
1294 * hi_hash_dword[31:0] ^= Stream[351:320];
1295 *
1296 * if(key[0])
1297 * hash[15:0] ^= Stream[15:0];
1298 *
1299 * for (i = 0; i < 16; i++) {
1300 * if (key[i])
1301 * hash[15:0] ^= lo_hash_dword[(i+15):i];
1302 * if (key[i + 16])
1303 * hash[15:0] ^= hi_hash_dword[(i+15):i];
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001304 * }
Alexander Duyck905e4a42011-01-06 14:29:57 +00001305 *
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001306 */
Alexander Duyck905e4a42011-01-06 14:29:57 +00001307 __be32 common_hash_dword = 0;
1308 u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan;
1309 u32 hash_result = 0;
1310 u8 i;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001311
Alexander Duyck905e4a42011-01-06 14:29:57 +00001312 /* record the flow_vm_vlan bits as they are a key part to the hash */
1313 flow_vm_vlan = ntohl(atr_input->dword_stream[0]);
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001314
Alexander Duyck905e4a42011-01-06 14:29:57 +00001315 /* generate common hash dword */
1316 for (i = 10; i; i -= 2)
1317 common_hash_dword ^= atr_input->dword_stream[i] ^
1318 atr_input->dword_stream[i - 1];
1319
1320 hi_hash_dword = ntohl(common_hash_dword);
1321
1322 /* low dword is word swapped version of common */
1323 lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16);
1324
1325 /* apply flow ID/VM pool/VLAN ID bits to hash words */
1326 hi_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan >> 16);
1327
1328 /* Process bits 0 and 16 */
1329 if (key & 0x0001) hash_result ^= lo_hash_dword;
1330 if (key & 0x00010000) hash_result ^= hi_hash_dword;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001331
1332 /*
Alexander Duyck905e4a42011-01-06 14:29:57 +00001333 * apply flow ID/VM pool/VLAN ID bits to lo hash dword, we had to
1334 * delay this because bit 0 of the stream should not be processed
1335 * so we do not add the vlan until after bit 0 was processed
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001336 */
Alexander Duyck905e4a42011-01-06 14:29:57 +00001337 lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16);
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001338
Alexander Duyck905e4a42011-01-06 14:29:57 +00001339
1340 /* process the remaining 30 bits in the key 2 bits at a time */
1341 for (i = 15; i; i-- ) {
1342 if (key & (0x0001 << i)) hash_result ^= lo_hash_dword >> i;
1343 if (key & (0x00010000 << i)) hash_result ^= hi_hash_dword >> i;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001344 }
1345
Alexander Duyck905e4a42011-01-06 14:29:57 +00001346 return hash_result & IXGBE_ATR_HASH_MASK;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001347}
1348
Alexander Duyck69830522011-01-06 14:29:58 +00001349/*
1350 * These defines allow us to quickly generate all of the necessary instructions
1351 * in the function below by simply calling out IXGBE_COMPUTE_SIG_HASH_ITERATION
1352 * for values 0 through 15
1353 */
1354#define IXGBE_ATR_COMMON_HASH_KEY \
1355 (IXGBE_ATR_BUCKET_HASH_KEY & IXGBE_ATR_SIGNATURE_HASH_KEY)
1356#define IXGBE_COMPUTE_SIG_HASH_ITERATION(_n) \
1357do { \
1358 u32 n = (_n); \
1359 if (IXGBE_ATR_COMMON_HASH_KEY & (0x01 << n)) \
1360 common_hash ^= lo_hash_dword >> n; \
1361 else if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << n)) \
1362 bucket_hash ^= lo_hash_dword >> n; \
1363 else if (IXGBE_ATR_SIGNATURE_HASH_KEY & (0x01 << n)) \
1364 sig_hash ^= lo_hash_dword << (16 - n); \
1365 if (IXGBE_ATR_COMMON_HASH_KEY & (0x01 << (n + 16))) \
1366 common_hash ^= hi_hash_dword >> n; \
1367 else if (IXGBE_ATR_BUCKET_HASH_KEY & (0x01 << (n + 16))) \
1368 bucket_hash ^= hi_hash_dword >> n; \
1369 else if (IXGBE_ATR_SIGNATURE_HASH_KEY & (0x01 << (n + 16))) \
1370 sig_hash ^= hi_hash_dword << (16 - n); \
1371} while (0);
1372
1373/**
1374 * ixgbe_atr_compute_sig_hash_82599 - Compute the signature hash
1375 * @stream: input bitstream to compute the hash on
1376 *
1377 * This function is almost identical to the function above but contains
1378 * several optomizations such as unwinding all of the loops, letting the
1379 * compiler work out all of the conditional ifs since the keys are static
1380 * defines, and computing two keys at once since the hashed dword stream
1381 * will be the same for both keys.
1382 **/
1383static u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input,
1384 union ixgbe_atr_hash_dword common)
1385{
1386 u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan;
1387 u32 sig_hash = 0, bucket_hash = 0, common_hash = 0;
1388
1389 /* record the flow_vm_vlan bits as they are a key part to the hash */
1390 flow_vm_vlan = ntohl(input.dword);
1391
1392 /* generate common hash dword */
1393 hi_hash_dword = ntohl(common.dword);
1394
1395 /* low dword is word swapped version of common */
1396 lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16);
1397
1398 /* apply flow ID/VM pool/VLAN ID bits to hash words */
1399 hi_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan >> 16);
1400
1401 /* Process bits 0 and 16 */
1402 IXGBE_COMPUTE_SIG_HASH_ITERATION(0);
1403
1404 /*
1405 * apply flow ID/VM pool/VLAN ID bits to lo hash dword, we had to
1406 * delay this because bit 0 of the stream should not be processed
1407 * so we do not add the vlan until after bit 0 was processed
1408 */
1409 lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16);
1410
1411 /* Process remaining 30 bit of the key */
1412 IXGBE_COMPUTE_SIG_HASH_ITERATION(1);
1413 IXGBE_COMPUTE_SIG_HASH_ITERATION(2);
1414 IXGBE_COMPUTE_SIG_HASH_ITERATION(3);
1415 IXGBE_COMPUTE_SIG_HASH_ITERATION(4);
1416 IXGBE_COMPUTE_SIG_HASH_ITERATION(5);
1417 IXGBE_COMPUTE_SIG_HASH_ITERATION(6);
1418 IXGBE_COMPUTE_SIG_HASH_ITERATION(7);
1419 IXGBE_COMPUTE_SIG_HASH_ITERATION(8);
1420 IXGBE_COMPUTE_SIG_HASH_ITERATION(9);
1421 IXGBE_COMPUTE_SIG_HASH_ITERATION(10);
1422 IXGBE_COMPUTE_SIG_HASH_ITERATION(11);
1423 IXGBE_COMPUTE_SIG_HASH_ITERATION(12);
1424 IXGBE_COMPUTE_SIG_HASH_ITERATION(13);
1425 IXGBE_COMPUTE_SIG_HASH_ITERATION(14);
1426 IXGBE_COMPUTE_SIG_HASH_ITERATION(15);
1427
1428 /* combine common_hash result with signature and bucket hashes */
1429 bucket_hash ^= common_hash;
1430 bucket_hash &= IXGBE_ATR_HASH_MASK;
1431
1432 sig_hash ^= common_hash << 16;
1433 sig_hash &= IXGBE_ATR_HASH_MASK << 16;
1434
1435 /* return completed signature hash */
1436 return sig_hash ^ bucket_hash;
1437}
1438
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001439/**
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001440 * ixgbe_atr_add_signature_filter_82599 - Adds a signature hash filter
1441 * @hw: pointer to hardware structure
Alexander Duyck69830522011-01-06 14:29:58 +00001442 * @input: unique input dword
1443 * @common: compressed common input dword
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001444 * @queue: queue index to direct traffic to
1445 **/
1446s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
Alexander Duyck69830522011-01-06 14:29:58 +00001447 union ixgbe_atr_hash_dword input,
1448 union ixgbe_atr_hash_dword common,
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001449 u8 queue)
1450{
1451 u64 fdirhashcmd;
Alexander Duyck905e4a42011-01-06 14:29:57 +00001452 u32 fdircmd;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001453
Alexander Duyck905e4a42011-01-06 14:29:57 +00001454 /*
1455 * Get the flow_type in order to program FDIRCMD properly
1456 * lowest 2 bits are FDIRCMD.L4TYPE, third lowest bit is FDIRCMD.IPV6
1457 */
Alexander Duyck69830522011-01-06 14:29:58 +00001458 switch (input.formatted.flow_type) {
Alexander Duyck905e4a42011-01-06 14:29:57 +00001459 case IXGBE_ATR_FLOW_TYPE_TCPV4:
1460 case IXGBE_ATR_FLOW_TYPE_UDPV4:
1461 case IXGBE_ATR_FLOW_TYPE_SCTPV4:
1462 case IXGBE_ATR_FLOW_TYPE_TCPV6:
1463 case IXGBE_ATR_FLOW_TYPE_UDPV6:
1464 case IXGBE_ATR_FLOW_TYPE_SCTPV6:
1465 break;
1466 default:
1467 hw_dbg(hw, " Error on flow type input\n");
1468 return IXGBE_ERR_CONFIG;
1469 }
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001470
Alexander Duyck905e4a42011-01-06 14:29:57 +00001471 /* configure FDIRCMD register */
1472 fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE |
1473 IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
Alexander Duyck69830522011-01-06 14:29:58 +00001474 fdircmd |= input.formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
Alexander Duyck905e4a42011-01-06 14:29:57 +00001475 fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001476
1477 /*
1478 * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits
1479 * is for FDIRCMD. Then do a 64-bit register write from FDIRHASH.
1480 */
Alexander Duyck905e4a42011-01-06 14:29:57 +00001481 fdirhashcmd = (u64)fdircmd << 32;
Alexander Duyck69830522011-01-06 14:29:58 +00001482 fdirhashcmd |= ixgbe_atr_compute_sig_hash_82599(input, common);
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001483
1484 IXGBE_WRITE_REG64(hw, IXGBE_FDIRHASH, fdirhashcmd);
1485
Alexander Duyck69830522011-01-06 14:29:58 +00001486 hw_dbg(hw, "Tx Queue=%x hash=%x\n", queue, (u32)fdirhashcmd);
1487
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001488 return 0;
1489}
1490
1491/**
Alexander Duyck45b9f502011-01-06 14:29:59 +00001492 * ixgbe_get_fdirtcpm_82599 - generate a tcp port from atr_input_masks
1493 * @input_mask: mask to be bit swapped
1494 *
1495 * The source and destination port masks for flow director are bit swapped
1496 * in that bit 15 effects bit 0, 14 effects 1, 13, 2 etc. In order to
1497 * generate a correctly swapped value we need to bit swap the mask and that
1498 * is what is accomplished by this function.
1499 **/
1500static u32 ixgbe_get_fdirtcpm_82599(struct ixgbe_atr_input_masks *input_masks)
1501{
1502 u32 mask = ntohs(input_masks->dst_port_mask);
1503 mask <<= IXGBE_FDIRTCPM_DPORTM_SHIFT;
1504 mask |= ntohs(input_masks->src_port_mask);
1505 mask = ((mask & 0x55555555) << 1) | ((mask & 0xAAAAAAAA) >> 1);
1506 mask = ((mask & 0x33333333) << 2) | ((mask & 0xCCCCCCCC) >> 2);
1507 mask = ((mask & 0x0F0F0F0F) << 4) | ((mask & 0xF0F0F0F0) >> 4);
1508 return ((mask & 0x00FF00FF) << 8) | ((mask & 0xFF00FF00) >> 8);
1509}
1510
1511/*
1512 * These two macros are meant to address the fact that we have registers
1513 * that are either all or in part big-endian. As a result on big-endian
1514 * systems we will end up byte swapping the value to little-endian before
1515 * it is byte swapped again and written to the hardware in the original
1516 * big-endian format.
1517 */
1518#define IXGBE_STORE_AS_BE32(_value) \
1519 (((u32)(_value) >> 24) | (((u32)(_value) & 0x00FF0000) >> 8) | \
1520 (((u32)(_value) & 0x0000FF00) << 8) | ((u32)(_value) << 24))
1521
1522#define IXGBE_WRITE_REG_BE32(a, reg, value) \
1523 IXGBE_WRITE_REG((a), (reg), IXGBE_STORE_AS_BE32(ntohl(value)))
1524
1525#define IXGBE_STORE_AS_BE16(_value) \
1526 (((u16)(_value) >> 8) | ((u16)(_value) << 8))
1527
1528/**
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001529 * ixgbe_fdir_add_perfect_filter_82599 - Adds a perfect filter
1530 * @hw: pointer to hardware structure
1531 * @input: input bitstream
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001532 * @input_masks: bitwise masks for relevant fields
1533 * @soft_id: software index into the silicon hash tables for filter storage
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001534 * @queue: queue index to direct traffic to
1535 *
1536 * Note that the caller to this function must lock before calling, since the
1537 * hardware writes must be protected from one another.
1538 **/
1539s32 ixgbe_fdir_add_perfect_filter_82599(struct ixgbe_hw *hw,
Alexander Duyck905e4a42011-01-06 14:29:57 +00001540 union ixgbe_atr_input *input,
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001541 struct ixgbe_atr_input_masks *input_masks,
1542 u16 soft_id, u8 queue)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001543{
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001544 u32 fdirhash;
Alexander Duyck45b9f502011-01-06 14:29:59 +00001545 u32 fdircmd;
1546 u32 fdirport, fdirtcpm;
1547 u32 fdirvlan;
1548 /* start with VLAN, flex bytes, VM pool, and IPv6 destination masked */
1549 u32 fdirm = IXGBE_FDIRM_VLANID | IXGBE_FDIRM_VLANP | IXGBE_FDIRM_FLEX |
1550 IXGBE_FDIRM_POOL | IXGBE_FDIRM_DIPv6;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001551
1552 /*
Alexander Duyck45b9f502011-01-06 14:29:59 +00001553 * Check flow_type formatting, and bail out before we touch the hardware
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001554 * if there's a configuration issue
1555 */
Alexander Duyck45b9f502011-01-06 14:29:59 +00001556 switch (input->formatted.flow_type) {
1557 case IXGBE_ATR_FLOW_TYPE_IPV4:
1558 /* use the L4 protocol mask for raw IPv4/IPv6 traffic */
1559 fdirm |= IXGBE_FDIRM_L4P;
1560 case IXGBE_ATR_FLOW_TYPE_SCTPV4:
1561 if (input_masks->dst_port_mask || input_masks->src_port_mask) {
1562 hw_dbg(hw, " Error on src/dst port mask\n");
1563 return IXGBE_ERR_CONFIG;
1564 }
1565 case IXGBE_ATR_FLOW_TYPE_TCPV4:
1566 case IXGBE_ATR_FLOW_TYPE_UDPV4:
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001567 break;
1568 default:
Alexander Duyck45b9f502011-01-06 14:29:59 +00001569 hw_dbg(hw, " Error on flow type input\n");
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001570 return IXGBE_ERR_CONFIG;
1571 }
1572
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001573 /*
Alexander Duyck45b9f502011-01-06 14:29:59 +00001574 * Program the relevant mask registers. If src/dst_port or src/dst_addr
1575 * are zero, then assume a full mask for that field. Also assume that
1576 * a VLAN of 0 is unspecified, so mask that out as well. L4type
1577 * cannot be masked out in this implementation.
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001578 *
1579 * This also assumes IPv4 only. IPv6 masking isn't supported at this
1580 * point in time.
1581 */
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001582
Alexander Duyck45b9f502011-01-06 14:29:59 +00001583 /* Program FDIRM */
1584 switch (ntohs(input_masks->vlan_id_mask) & 0xEFFF) {
1585 case 0xEFFF:
1586 /* Unmask VLAN ID - bit 0 and fall through to unmask prio */
1587 fdirm &= ~IXGBE_FDIRM_VLANID;
1588 case 0xE000:
1589 /* Unmask VLAN prio - bit 1 */
1590 fdirm &= ~IXGBE_FDIRM_VLANP;
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001591 break;
Alexander Duyck45b9f502011-01-06 14:29:59 +00001592 case 0x0FFF:
1593 /* Unmask VLAN ID - bit 0 */
1594 fdirm &= ~IXGBE_FDIRM_VLANID;
1595 break;
1596 case 0x0000:
1597 /* do nothing, vlans already masked */
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001598 break;
1599 default:
Alexander Duyck45b9f502011-01-06 14:29:59 +00001600 hw_dbg(hw, " Error on VLAN mask\n");
1601 return IXGBE_ERR_CONFIG;
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001602 }
1603
Alexander Duyck45b9f502011-01-06 14:29:59 +00001604 if (input_masks->flex_mask & 0xFFFF) {
1605 if ((input_masks->flex_mask & 0xFFFF) != 0xFFFF) {
1606 hw_dbg(hw, " Error on flexible byte mask\n");
1607 return IXGBE_ERR_CONFIG;
1608 }
1609 /* Unmask Flex Bytes - bit 4 */
1610 fdirm &= ~IXGBE_FDIRM_FLEX;
1611 }
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001612
1613 /* Now mask VM pool and destination IPv6 - bits 5 and 2 */
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001614 IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001615
Alexander Duyck45b9f502011-01-06 14:29:59 +00001616 /* store the TCP/UDP port masks, bit reversed from port layout */
1617 fdirtcpm = ixgbe_get_fdirtcpm_82599(input_masks);
1618
1619 /* write both the same so that UDP and TCP use the same mask */
1620 IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, ~fdirtcpm);
1621 IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, ~fdirtcpm);
1622
1623 /* store source and destination IP masks (big-enian) */
1624 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIP4M,
1625 ~input_masks->src_ip_mask[0]);
1626 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRDIP4M,
1627 ~input_masks->dst_ip_mask[0]);
1628
1629 /* Apply masks to input data */
1630 input->formatted.vlan_id &= input_masks->vlan_id_mask;
1631 input->formatted.flex_bytes &= input_masks->flex_mask;
1632 input->formatted.src_port &= input_masks->src_port_mask;
1633 input->formatted.dst_port &= input_masks->dst_port_mask;
1634 input->formatted.src_ip[0] &= input_masks->src_ip_mask[0];
1635 input->formatted.dst_ip[0] &= input_masks->dst_ip_mask[0];
1636
1637 /* record vlan (little-endian) and flex_bytes(big-endian) */
1638 fdirvlan =
1639 IXGBE_STORE_AS_BE16(ntohs(input->formatted.flex_bytes));
1640 fdirvlan <<= IXGBE_FDIRVLAN_FLEX_SHIFT;
1641 fdirvlan |= ntohs(input->formatted.vlan_id);
1642 IXGBE_WRITE_REG(hw, IXGBE_FDIRVLAN, fdirvlan);
1643
1644 /* record source and destination port (little-endian)*/
1645 fdirport = ntohs(input->formatted.dst_port);
1646 fdirport <<= IXGBE_FDIRPORT_DESTINATION_SHIFT;
1647 fdirport |= ntohs(input->formatted.src_port);
1648 IXGBE_WRITE_REG(hw, IXGBE_FDIRPORT, fdirport);
1649
1650 /* record the first 32 bits of the destination address (big-endian) */
1651 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPDA, input->formatted.dst_ip[0]);
1652
1653 /* record the source address (big-endian) */
1654 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPSA, input->formatted.src_ip[0]);
1655
1656 /* configure FDIRCMD register */
1657 fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE |
1658 IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
1659 fdircmd |= input->formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
1660 fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
1661
1662 /* we only want the bucket hash so drop the upper 16 bits */
1663 fdirhash = ixgbe_atr_compute_hash_82599(input,
1664 IXGBE_ATR_BUCKET_HASH_KEY);
1665 fdirhash |= soft_id << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001666
1667 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
1668 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd);
1669
1670 return 0;
1671}
Alexander Duyck45b9f502011-01-06 14:29:59 +00001672
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001673/**
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001674 * ixgbe_read_analog_reg8_82599 - Reads 8 bit Omer analog register
1675 * @hw: pointer to hardware structure
1676 * @reg: analog register to read
1677 * @val: read value
1678 *
1679 * Performs read operation to Omer analog register specified.
1680 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001681static s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001682{
1683 u32 core_ctl;
1684
1685 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, IXGBE_CORECTL_WRITE_CMD |
1686 (reg << 8));
1687 IXGBE_WRITE_FLUSH(hw);
1688 udelay(10);
1689 core_ctl = IXGBE_READ_REG(hw, IXGBE_CORECTL);
1690 *val = (u8)core_ctl;
1691
1692 return 0;
1693}
1694
1695/**
1696 * ixgbe_write_analog_reg8_82599 - Writes 8 bit Omer analog register
1697 * @hw: pointer to hardware structure
1698 * @reg: atlas register to write
1699 * @val: value to write
1700 *
1701 * Performs write operation to Omer analog register specified.
1702 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001703static s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001704{
1705 u32 core_ctl;
1706
1707 core_ctl = (reg << 8) | val;
1708 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, core_ctl);
1709 IXGBE_WRITE_FLUSH(hw);
1710 udelay(10);
1711
1712 return 0;
1713}
1714
1715/**
1716 * ixgbe_start_hw_82599 - Prepare hardware for Tx/Rx
1717 * @hw: pointer to hardware structure
1718 *
1719 * Starts the hardware using the generic start_hw function.
1720 * Then performs device-specific:
1721 * Clears the rate limiter registers.
1722 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001723static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001724{
1725 u32 q_num;
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +00001726 s32 ret_val;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001727
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +00001728 ret_val = ixgbe_start_hw_generic(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001729
1730 /* Clear the rate limiters */
1731 for (q_num = 0; q_num < hw->mac.max_tx_queues; q_num++) {
1732 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, q_num);
1733 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, 0);
1734 }
1735 IXGBE_WRITE_FLUSH(hw);
1736
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +00001737 /* We need to run link autotry after the driver loads */
1738 hw->mac.autotry_restart = true;
1739
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +00001740 if (ret_val == 0)
1741 ret_val = ixgbe_verify_fw_version_82599(hw);
1742
1743 return ret_val;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001744}
1745
1746/**
1747 * ixgbe_identify_phy_82599 - Get physical layer module
1748 * @hw: pointer to hardware structure
1749 *
1750 * Determines the physical layer module found on the current adapter.
Emil Tantilov21cc5b42011-02-12 10:52:07 +00001751 * If PHY already detected, maintains current PHY type in hw struct,
1752 * otherwise executes the PHY detection routine.
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001753 **/
Emil Tantilov21cc5b42011-02-12 10:52:07 +00001754s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001755{
1756 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
Emil Tantilov21cc5b42011-02-12 10:52:07 +00001757
1758 /* Detect PHY if not unknown - returns success if already detected. */
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001759 status = ixgbe_identify_phy_generic(hw);
Emil Tantilov21cc5b42011-02-12 10:52:07 +00001760 if (status != 0) {
1761 /* 82599 10GBASE-T requires an external PHY */
1762 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)
1763 goto out;
1764 else
1765 status = ixgbe_identify_sfp_module_generic(hw);
1766 }
1767
1768 /* Set PHY type none if no PHY detected */
1769 if (hw->phy.type == ixgbe_phy_unknown) {
1770 hw->phy.type = ixgbe_phy_none;
1771 status = 0;
1772 }
1773
1774 /* Return error if SFP module has been detected but is not supported */
1775 if (hw->phy.type == ixgbe_phy_sfp_unsupported)
1776 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1777
1778out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001779 return status;
1780}
1781
1782/**
1783 * ixgbe_get_supported_physical_layer_82599 - Returns physical layer type
1784 * @hw: pointer to hardware structure
1785 *
1786 * Determines physical layer capabilities of the current configuration.
1787 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001788static u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001789{
1790 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001791 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1792 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1793 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
1794 u32 pma_pmd_10g_parallel = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
1795 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
1796 u16 ext_ability = 0;
PJ Waskiewicz1339b9e2009-03-13 22:12:29 +00001797 u8 comp_codes_10g = 0;
Don Skidmorecb836a92010-06-29 18:30:59 +00001798 u8 comp_codes_1g = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001799
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001800 hw->phy.ops.identify(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001801
Emil Tantilov21cc5b42011-02-12 10:52:07 +00001802 switch (hw->phy.type) {
1803 case ixgbe_phy_tn:
1804 case ixgbe_phy_aq:
1805 case ixgbe_phy_cu_unknown:
Ben Hutchings6b73e102009-04-29 08:08:58 +00001806 hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
Emil Tantilov21cc5b42011-02-12 10:52:07 +00001807 &ext_ability);
Ben Hutchings6b73e102009-04-29 08:08:58 +00001808 if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001809 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
Ben Hutchings6b73e102009-04-29 08:08:58 +00001810 if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001811 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
Ben Hutchings6b73e102009-04-29 08:08:58 +00001812 if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001813 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
1814 goto out;
Emil Tantilov21cc5b42011-02-12 10:52:07 +00001815 default:
1816 break;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001817 }
1818
1819 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
1820 case IXGBE_AUTOC_LMS_1G_AN:
1821 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
1822 if (pma_pmd_1g == IXGBE_AUTOC_1G_KX_BX) {
1823 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
1824 IXGBE_PHYSICAL_LAYER_1000BASE_BX;
1825 goto out;
1826 } else
1827 /* SFI mode so read SFP module */
1828 goto sfp_check;
1829 break;
1830 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
1831 if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_CX4)
1832 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
1833 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_KX4)
1834 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
Peter P Waskiewicz Jr1fcf03e2009-05-17 20:58:04 +00001835 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_XAUI)
1836 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_XAUI;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001837 goto out;
1838 break;
1839 case IXGBE_AUTOC_LMS_10G_SERIAL:
1840 if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_KR) {
1841 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR;
1842 goto out;
1843 } else if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)
1844 goto sfp_check;
1845 break;
1846 case IXGBE_AUTOC_LMS_KX4_KX_KR:
1847 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
1848 if (autoc & IXGBE_AUTOC_KX_SUPP)
1849 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
1850 if (autoc & IXGBE_AUTOC_KX4_SUPP)
1851 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
1852 if (autoc & IXGBE_AUTOC_KR_SUPP)
1853 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KR;
1854 goto out;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001855 break;
1856 default:
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001857 goto out;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001858 break;
1859 }
1860
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001861sfp_check:
1862 /* SFP check must be done last since DA modules are sometimes used to
1863 * test KR mode - we need to id KR mode correctly before SFP module.
1864 * Call identify_sfp because the pluggable module may have changed */
1865 hw->phy.ops.identify_sfp(hw);
1866 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1867 goto out;
1868
1869 switch (hw->phy.type) {
Don Skidmoreea0a04d2010-05-18 16:00:13 +00001870 case ixgbe_phy_sfp_passive_tyco:
1871 case ixgbe_phy_sfp_passive_unknown:
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001872 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1873 break;
Don Skidmoreea0a04d2010-05-18 16:00:13 +00001874 case ixgbe_phy_sfp_ftl_active:
1875 case ixgbe_phy_sfp_active_unknown:
1876 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
1877 break;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001878 case ixgbe_phy_sfp_avago:
1879 case ixgbe_phy_sfp_ftl:
1880 case ixgbe_phy_sfp_intel:
1881 case ixgbe_phy_sfp_unknown:
1882 hw->phy.ops.read_i2c_eeprom(hw,
Don Skidmorecb836a92010-06-29 18:30:59 +00001883 IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
1884 hw->phy.ops.read_i2c_eeprom(hw,
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001885 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1886 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1887 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1888 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1889 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
Don Skidmorecb836a92010-06-29 18:30:59 +00001890 else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
1891 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001892 break;
1893 default:
1894 break;
1895 }
1896
1897out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001898 return physical_layer;
1899}
1900
1901/**
1902 * ixgbe_enable_rx_dma_82599 - Enable the Rx DMA unit on 82599
1903 * @hw: pointer to hardware structure
1904 * @regval: register value to write to RXCTRL
1905 *
1906 * Enables the Rx DMA unit for 82599
1907 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001908static s32 ixgbe_enable_rx_dma_82599(struct ixgbe_hw *hw, u32 regval)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001909{
1910#define IXGBE_MAX_SECRX_POLL 30
1911 int i;
1912 int secrxreg;
1913
1914 /*
1915 * Workaround for 82599 silicon errata when enabling the Rx datapath.
1916 * If traffic is incoming before we enable the Rx unit, it could hang
1917 * the Rx DMA unit. Therefore, make sure the security engine is
1918 * completely disabled prior to enabling the Rx unit.
1919 */
1920 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
1921 secrxreg |= IXGBE_SECRXCTRL_RX_DIS;
1922 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg);
1923 for (i = 0; i < IXGBE_MAX_SECRX_POLL; i++) {
1924 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT);
1925 if (secrxreg & IXGBE_SECRXSTAT_SECRX_RDY)
1926 break;
1927 else
Emil Tantilov8c7bea32011-02-19 08:43:44 +00001928 /* Use interrupt-safe sleep just in case */
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001929 udelay(10);
1930 }
1931
1932 /* For informational purposes only */
1933 if (i >= IXGBE_MAX_SECRX_POLL)
1934 hw_dbg(hw, "Rx unit being enabled before security "
1935 "path fully disabled. Continuing with init.\n");
1936
1937 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval);
1938 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
1939 secrxreg &= ~IXGBE_SECRXCTRL_RX_DIS;
1940 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg);
1941 IXGBE_WRITE_FLUSH(hw);
1942
1943 return 0;
1944}
1945
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001946/**
1947 * ixgbe_get_device_caps_82599 - Get additional device capabilities
1948 * @hw: pointer to hardware structure
1949 * @device_caps: the EEPROM word with the extra device capabilities
1950 *
1951 * This function will read the EEPROM location for the device capabilities,
1952 * and return the word through device_caps.
1953 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001954static s32 ixgbe_get_device_caps_82599(struct ixgbe_hw *hw, u16 *device_caps)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001955{
1956 hw->eeprom.ops.read(hw, IXGBE_DEVICE_CAPS, device_caps);
1957
1958 return 0;
1959}
1960
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +00001961/**
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +00001962 * ixgbe_verify_fw_version_82599 - verify fw version for 82599
1963 * @hw: pointer to hardware structure
1964 *
1965 * Verifies that installed the firmware version is 0.6 or higher
1966 * for SFI devices. All 82599 SFI devices should have version 0.6 or higher.
1967 *
1968 * Returns IXGBE_ERR_EEPROM_VERSION if the FW is not present or
1969 * if the FW version is not supported.
1970 **/
1971static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
1972{
1973 s32 status = IXGBE_ERR_EEPROM_VERSION;
1974 u16 fw_offset, fw_ptp_cfg_offset;
1975 u16 fw_version = 0;
1976
1977 /* firmware check is only necessary for SFI devices */
1978 if (hw->phy.media_type != ixgbe_media_type_fiber) {
1979 status = 0;
1980 goto fw_version_out;
1981 }
1982
1983 /* get the offset to the Firmware Module block */
1984 hw->eeprom.ops.read(hw, IXGBE_FW_PTR, &fw_offset);
1985
1986 if ((fw_offset == 0) || (fw_offset == 0xFFFF))
1987 goto fw_version_out;
1988
1989 /* get the offset to the Pass Through Patch Configuration block */
1990 hw->eeprom.ops.read(hw, (fw_offset +
1991 IXGBE_FW_PASSTHROUGH_PATCH_CONFIG_PTR),
1992 &fw_ptp_cfg_offset);
1993
1994 if ((fw_ptp_cfg_offset == 0) || (fw_ptp_cfg_offset == 0xFFFF))
1995 goto fw_version_out;
1996
1997 /* get the firmware version */
1998 hw->eeprom.ops.read(hw, (fw_ptp_cfg_offset +
1999 IXGBE_FW_PATCH_VERSION_4),
2000 &fw_version);
2001
2002 if (fw_version > 0x5)
2003 status = 0;
2004
2005fw_version_out:
2006 return status;
2007}
2008
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002009static struct ixgbe_mac_operations mac_ops_82599 = {
2010 .init_hw = &ixgbe_init_hw_generic,
2011 .reset_hw = &ixgbe_reset_hw_82599,
2012 .start_hw = &ixgbe_start_hw_82599,
2013 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
2014 .get_media_type = &ixgbe_get_media_type_82599,
2015 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82599,
2016 .enable_rx_dma = &ixgbe_enable_rx_dma_82599,
2017 .get_mac_addr = &ixgbe_get_mac_addr_generic,
Mallikarjuna R Chilakala21ce8492010-05-13 17:33:41 +00002018 .get_san_mac_addr = &ixgbe_get_san_mac_addr_generic,
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002019 .get_device_caps = &ixgbe_get_device_caps_82599,
Don Skidmorea391f1d2010-11-16 19:27:15 -08002020 .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002021 .stop_adapter = &ixgbe_stop_adapter_generic,
2022 .get_bus_info = &ixgbe_get_bus_info_generic,
2023 .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie,
2024 .read_analog_reg8 = &ixgbe_read_analog_reg8_82599,
2025 .write_analog_reg8 = &ixgbe_write_analog_reg8_82599,
2026 .setup_link = &ixgbe_setup_mac_link_82599,
Mallikarjuna R Chilakala21ce8492010-05-13 17:33:41 +00002027 .check_link = &ixgbe_check_mac_link_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002028 .get_link_capabilities = &ixgbe_get_link_capabilities_82599,
2029 .led_on = &ixgbe_led_on_generic,
2030 .led_off = &ixgbe_led_off_generic,
PJ Waskiewicz87c12012009-04-08 13:20:31 +00002031 .blink_led_start = &ixgbe_blink_led_start_generic,
2032 .blink_led_stop = &ixgbe_blink_led_stop_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002033 .set_rar = &ixgbe_set_rar_generic,
2034 .clear_rar = &ixgbe_clear_rar_generic,
Mallikarjuna R Chilakala21ce8492010-05-13 17:33:41 +00002035 .set_vmdq = &ixgbe_set_vmdq_generic,
2036 .clear_vmdq = &ixgbe_clear_vmdq_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002037 .init_rx_addrs = &ixgbe_init_rx_addrs_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002038 .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,
2039 .enable_mc = &ixgbe_enable_mc_generic,
2040 .disable_mc = &ixgbe_disable_mc_generic,
Mallikarjuna R Chilakala21ce8492010-05-13 17:33:41 +00002041 .clear_vfta = &ixgbe_clear_vfta_generic,
2042 .set_vfta = &ixgbe_set_vfta_generic,
2043 .fc_enable = &ixgbe_fc_enable_generic,
2044 .init_uta_tables = &ixgbe_init_uta_tables_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002045 .setup_sfp = &ixgbe_setup_sfp_modules_82599,
Greg Rosea985b6c32010-11-18 03:02:52 +00002046 .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing,
2047 .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing,
Don Skidmore5e655102011-02-25 01:58:04 +00002048 .acquire_swfw_sync = &ixgbe_acquire_swfw_sync,
2049 .release_swfw_sync = &ixgbe_release_swfw_sync,
2050
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002051};
2052
2053static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
2054 .init_params = &ixgbe_init_eeprom_params_generic,
Mallikarjuna R Chilakala21ce8492010-05-13 17:33:41 +00002055 .read = &ixgbe_read_eerd_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002056 .write = &ixgbe_write_eeprom_generic,
Don Skidmorea391f1d2010-11-16 19:27:15 -08002057 .calc_checksum = &ixgbe_calc_eeprom_checksum_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002058 .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
2059 .update_checksum = &ixgbe_update_eeprom_checksum_generic,
2060};
2061
2062static struct ixgbe_phy_operations phy_ops_82599 = {
2063 .identify = &ixgbe_identify_phy_82599,
2064 .identify_sfp = &ixgbe_identify_sfp_module_generic,
Mallikarjuna R Chilakala21ce8492010-05-13 17:33:41 +00002065 .init = &ixgbe_init_phy_ops_82599,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002066 .reset = &ixgbe_reset_phy_generic,
2067 .read_reg = &ixgbe_read_phy_reg_generic,
2068 .write_reg = &ixgbe_write_phy_reg_generic,
2069 .setup_link = &ixgbe_setup_phy_link_generic,
2070 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
2071 .read_i2c_byte = &ixgbe_read_i2c_byte_generic,
2072 .write_i2c_byte = &ixgbe_write_i2c_byte_generic,
2073 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic,
2074 .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic,
Mallikarjuna R Chilakala119fc602010-05-20 23:07:06 -07002075 .check_overtemp = &ixgbe_tn_check_overtemp,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002076};
2077
2078struct ixgbe_info ixgbe_82599_info = {
2079 .mac = ixgbe_mac_82599EB,
2080 .get_invariants = &ixgbe_get_invariants_82599,
2081 .mac_ops = &mac_ops_82599,
2082 .eeprom_ops = &eeprom_ops_82599,
2083 .phy_ops = &phy_ops_82599,
Don Skidmorea391f1d2010-11-16 19:27:15 -08002084 .mbx_ops = &mbx_ops_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002085};