blob: 4fa8633fae3c8cbc5a271a86902844a9a7265558 [file] [log] [blame]
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001/*******************************************************************************
2
3 Intel 10 Gigabit PCI Express Linux driver
Shannon Nelson8c47eaa2010-01-13 01:49:34 +00004 Copyright(c) 1999 - 2010 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
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +000042s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
43 ixgbe_link_speed speed,
44 bool autoneg,
45 bool autoneg_wait_to_complete);
Don Skidmorecd7e1f02009-10-08 15:36:22 +000046static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
47 ixgbe_link_speed speed,
48 bool autoneg,
49 bool autoneg_wait_to_complete);
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +000050s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
51 bool autoneg_wait_to_complete);
52s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
53 ixgbe_link_speed speed,
54 bool autoneg,
55 bool autoneg_wait_to_complete);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000056static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw,
57 ixgbe_link_speed *speed,
58 bool *autoneg);
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;
68 if (hw->phy.multispeed_fiber) {
69 /* Set up dual speed SFP+ support */
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +000070 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000071 } else {
Don Skidmorecd7e1f02009-10-08 15:36:22 +000072 if ((mac->ops.get_media_type(hw) ==
73 ixgbe_media_type_backplane) &&
74 (hw->phy.smart_speed == ixgbe_smart_speed_auto ||
75 hw->phy.smart_speed == ixgbe_smart_speed_on))
76 mac->ops.setup_link = &ixgbe_setup_mac_link_smartspeed;
77 else
78 mac->ops.setup_link = &ixgbe_setup_mac_link_82599;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000079 }
80}
81
Don Skidmore7b25cdb2009-08-25 04:47:32 +000082static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000083{
84 s32 ret_val = 0;
85 u16 list_offset, data_offset, data_value;
86
87 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
88 ixgbe_init_mac_link_ops_82599(hw);
PJ Waskiewicz553b4492009-04-09 22:28:15 +000089
90 hw->phy.ops.reset = NULL;
91
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000092 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
93 &data_offset);
94
95 if (ret_val != 0)
96 goto setup_sfp_out;
97
Peter P Waskiewicz Jraa5aec82009-05-19 09:18:34 +000098 /* PHY config will finish before releasing the semaphore */
99 ret_val = ixgbe_acquire_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
100 if (ret_val != 0) {
101 ret_val = IXGBE_ERR_SWFW_SYNC;
102 goto setup_sfp_out;
103 }
104
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000105 hw->eeprom.ops.read(hw, ++data_offset, &data_value);
106 while (data_value != 0xffff) {
107 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, data_value);
108 IXGBE_WRITE_FLUSH(hw);
109 hw->eeprom.ops.read(hw, ++data_offset, &data_value);
110 }
Peter P Waskiewicz Jr1479ad42009-06-04 11:10:17 +0000111 /* Now restart DSP by setting Restart_AN */
112 IXGBE_WRITE_REG(hw, IXGBE_AUTOC,
113 (IXGBE_READ_REG(hw, IXGBE_AUTOC) | IXGBE_AUTOC_AN_RESTART));
Peter P Waskiewicz Jraa5aec82009-05-19 09:18:34 +0000114
115 /* Release the semaphore */
116 ixgbe_release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
117 /* Delay obtaining semaphore again to allow FW access */
118 msleep(hw->eeprom.semaphore_delay);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000119 }
120
121setup_sfp_out:
122 return ret_val;
123}
124
125/**
126 * ixgbe_get_pcie_msix_count_82599 - Gets MSI-X vector count
127 * @hw: pointer to hardware structure
128 *
129 * Read PCIe configuration space, and get the MSI-X vector count from
130 * the capabilities table.
131 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000132static u32 ixgbe_get_pcie_msix_count_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000133{
134 struct ixgbe_adapter *adapter = hw->back;
135 u16 msix_count;
136 pci_read_config_word(adapter->pdev, IXGBE_PCIE_MSIX_82599_CAPS,
137 &msix_count);
138 msix_count &= IXGBE_PCIE_MSIX_TBL_SZ_MASK;
139
140 /* MSI-X count is zero-based in HW, so increment to give proper value */
141 msix_count++;
142
143 return msix_count;
144}
145
146static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
147{
148 struct ixgbe_mac_info *mac = &hw->mac;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000149
150 ixgbe_init_mac_link_ops_82599(hw);
151
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000152 mac->mcft_size = IXGBE_82599_MC_TBL_SIZE;
153 mac->vft_size = IXGBE_82599_VFT_TBL_SIZE;
154 mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES;
155 mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES;
156 mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES;
157 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82599(hw);
158
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000159 return 0;
160}
161
162/**
163 * ixgbe_init_phy_ops_82599 - PHY/SFP specific init
164 * @hw: pointer to hardware structure
165 *
166 * Initialize any function pointers that were not able to be
167 * set during get_invariants because the PHY/SFP type was
168 * not known. Perform the SFP init if necessary.
169 *
170 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000171static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000172{
173 struct ixgbe_mac_info *mac = &hw->mac;
174 struct ixgbe_phy_info *phy = &hw->phy;
175 s32 ret_val = 0;
176
177 /* Identify the PHY or SFP module */
178 ret_val = phy->ops.identify(hw);
179
180 /* Setup function pointers based on detected SFP module and speeds */
181 ixgbe_init_mac_link_ops_82599(hw);
182
183 /* If copper media, overwrite with copper function pointers */
184 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
185 mac->ops.setup_link = &ixgbe_setup_copper_link_82599;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000186 mac->ops.get_link_capabilities =
187 &ixgbe_get_copper_link_capabilities_82599;
188 }
189
190 /* Set necessary function pointers based on phy type */
191 switch (hw->phy.type) {
192 case ixgbe_phy_tn:
193 phy->ops.check_link = &ixgbe_check_phy_link_tnx;
194 phy->ops.get_firmware_version =
195 &ixgbe_get_phy_firmware_version_tnx;
196 break;
197 default:
198 break;
199 }
200
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000201 return ret_val;
202}
203
204/**
205 * ixgbe_get_link_capabilities_82599 - Determines link capabilities
206 * @hw: pointer to hardware structure
207 * @speed: pointer to link speed
208 * @negotiation: true when autoneg or autotry is enabled
209 *
210 * Determines the link capabilities by reading the AUTOC register.
211 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000212static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
213 ixgbe_link_speed *speed,
214 bool *negotiation)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000215{
216 s32 status = 0;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000217 u32 autoc = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000218
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000219 /*
220 * Determine link capabilities based on the stored value of AUTOC,
221 * which represents EEPROM defaults. If AUTOC value has not been
222 * stored, use the current register value.
223 */
224 if (hw->mac.orig_link_settings_stored)
225 autoc = hw->mac.orig_autoc;
226 else
227 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
228
229 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000230 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
231 *speed = IXGBE_LINK_SPEED_1GB_FULL;
232 *negotiation = false;
233 break;
234
235 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
236 *speed = IXGBE_LINK_SPEED_10GB_FULL;
237 *negotiation = false;
238 break;
239
240 case IXGBE_AUTOC_LMS_1G_AN:
241 *speed = IXGBE_LINK_SPEED_1GB_FULL;
242 *negotiation = true;
243 break;
244
245 case IXGBE_AUTOC_LMS_10G_SERIAL:
246 *speed = IXGBE_LINK_SPEED_10GB_FULL;
247 *negotiation = false;
248 break;
249
250 case IXGBE_AUTOC_LMS_KX4_KX_KR:
251 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
252 *speed = IXGBE_LINK_SPEED_UNKNOWN;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000253 if (autoc & IXGBE_AUTOC_KR_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000254 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000255 if (autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000256 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000257 if (autoc & IXGBE_AUTOC_KX_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000258 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
259 *negotiation = true;
260 break;
261
262 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
263 *speed = IXGBE_LINK_SPEED_100_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000264 if (autoc & IXGBE_AUTOC_KR_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000265 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000266 if (autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000267 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000268 if (autoc & IXGBE_AUTOC_KX_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000269 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
270 *negotiation = true;
271 break;
272
273 case IXGBE_AUTOC_LMS_SGMII_1G_100M:
274 *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
275 *negotiation = false;
276 break;
277
278 default:
279 status = IXGBE_ERR_LINK_SETUP;
280 goto out;
281 break;
282 }
283
284 if (hw->phy.multispeed_fiber) {
285 *speed |= IXGBE_LINK_SPEED_10GB_FULL |
286 IXGBE_LINK_SPEED_1GB_FULL;
287 *negotiation = true;
288 }
289
290out:
291 return status;
292}
293
294/**
295 * ixgbe_get_copper_link_capabilities_82599 - Determines link capabilities
296 * @hw: pointer to hardware structure
297 * @speed: pointer to link speed
298 * @autoneg: boolean auto-negotiation value
299 *
300 * Determines the link capabilities by reading the AUTOC register.
301 **/
302static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw,
303 ixgbe_link_speed *speed,
304 bool *autoneg)
305{
306 s32 status = IXGBE_ERR_LINK_SETUP;
307 u16 speed_ability;
308
309 *speed = 0;
310 *autoneg = true;
311
Ben Hutchings6b73e102009-04-29 08:08:58 +0000312 status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000313 &speed_ability);
314
315 if (status == 0) {
Ben Hutchings6b73e102009-04-29 08:08:58 +0000316 if (speed_ability & MDIO_SPEED_10G)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000317 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
Ben Hutchings6b73e102009-04-29 08:08:58 +0000318 if (speed_ability & MDIO_PMA_SPEED_1000)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000319 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
320 }
321
322 return status;
323}
324
325/**
326 * ixgbe_get_media_type_82599 - Get media type
327 * @hw: pointer to hardware structure
328 *
329 * Returns the media type (fiber, copper, backplane)
330 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000331static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000332{
333 enum ixgbe_media_type media_type;
334
335 /* Detect if there is a copper PHY attached. */
336 if (hw->phy.type == ixgbe_phy_cu_unknown ||
337 hw->phy.type == ixgbe_phy_tn) {
338 media_type = ixgbe_media_type_copper;
339 goto out;
340 }
341
342 switch (hw->device_id) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000343 case IXGBE_DEV_ID_82599_KX4:
Don Skidmoredbfec662009-10-02 08:58:25 +0000344 case IXGBE_DEV_ID_82599_KX4_MEZZ:
Don Skidmore312eb932009-10-02 08:58:04 +0000345 case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
Don Skidmore74757d42009-12-08 07:22:23 +0000346 case IXGBE_DEV_ID_82599_KR:
Peter P Waskiewicz Jr1fcf03e2009-05-17 20:58:04 +0000347 case IXGBE_DEV_ID_82599_XAUI_LOM:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000348 /* Default device ID is mezzanine card KX/KX4 */
349 media_type = ixgbe_media_type_backplane;
350 break;
351 case IXGBE_DEV_ID_82599_SFP:
Don Skidmore38ad1c82009-10-08 15:35:58 +0000352 case IXGBE_DEV_ID_82599_SFP_EM:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000353 media_type = ixgbe_media_type_fiber;
354 break;
Peter P Waskiewicz Jr89111842009-09-14 07:47:49 +0000355 case IXGBE_DEV_ID_82599_CX4:
Peter P Waskiewicz Jr6b1be192009-09-14 07:48:10 +0000356 media_type = ixgbe_media_type_cx4;
Peter P Waskiewicz Jr89111842009-09-14 07:47:49 +0000357 break;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000358 default:
359 media_type = ixgbe_media_type_unknown;
360 break;
361 }
362out:
363 return media_type;
364}
365
366/**
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000367 * ixgbe_start_mac_link_82599 - Setup MAC link settings
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000368 * @hw: pointer to hardware structure
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000369 * @autoneg_wait_to_complete: true when waiting for completion is needed
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000370 *
371 * Configures link settings based on values in the ixgbe_hw struct.
372 * Restarts the link. Performs autonegotiation if needed.
373 **/
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000374s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
375 bool autoneg_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000376{
377 u32 autoc_reg;
378 u32 links_reg;
379 u32 i;
380 s32 status = 0;
381
382 /* Restart link */
383 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
384 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
385 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
386
387 /* Only poll for autoneg to complete if specified to do so */
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000388 if (autoneg_wait_to_complete) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000389 if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
390 IXGBE_AUTOC_LMS_KX4_KX_KR ||
391 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
392 IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
393 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
394 IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
395 links_reg = 0; /* Just in case Autoneg time = 0 */
396 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
397 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
398 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
399 break;
400 msleep(100);
401 }
402 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
403 status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
404 hw_dbg(hw, "Autoneg did not complete.\n");
405 }
406 }
407 }
408
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000409 /* Add delay to filter out noises during initial link setup */
410 msleep(50);
411
412 return status;
413}
414
415/**
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000416 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000417 * @hw: pointer to hardware structure
418 * @speed: new link speed
419 * @autoneg: true if autonegotiation enabled
420 * @autoneg_wait_to_complete: true when waiting for completion is needed
421 *
422 * Set the link speed in the AUTOC register and restarts link.
423 **/
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000424s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
425 ixgbe_link_speed speed,
426 bool autoneg,
427 bool autoneg_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000428{
429 s32 status = 0;
430 ixgbe_link_speed phy_link_speed;
431 ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
432 u32 speedcnt = 0;
433 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
434 bool link_up = false;
435 bool negotiation;
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000436 int i;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000437
438 /* Mask off requested but non-supported speeds */
439 hw->mac.ops.get_link_capabilities(hw, &phy_link_speed, &negotiation);
440 speed &= phy_link_speed;
441
442 /*
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000443 * When the driver changes the link speeds that it can support,
444 * it sets autotry_restart to true to indicate that we need to
445 * initiate a new autotry session with the link partner. To do
446 * so, we set the speed then disable and re-enable the tx laser, to
447 * alert the link partner that it also needs to restart autotry on its
448 * end. This is consistent with true clause 37 autoneg, which also
449 * involves a loss of signal.
450 */
451
452 /*
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000453 * Try each speed one by one, highest priority first. We do this in
454 * software because 10gb fiber doesn't support speed autonegotiation.
455 */
456 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
457 speedcnt++;
458 highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL;
459
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000460 /* If we already have link at this speed, just jump out */
461 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
462
463 if ((phy_link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
464 goto out;
465
466 /* Set the module link speed */
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000467 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
468 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
469
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000470 /* Allow module to change analog characteristics (1G->10G) */
471 msleep(40);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000472
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000473 status = ixgbe_setup_mac_link_82599(hw,
474 IXGBE_LINK_SPEED_10GB_FULL,
475 autoneg,
476 autoneg_wait_to_complete);
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000477 if (status != 0)
Mallikarjuna R Chilakalac3c74322009-09-01 13:50:14 +0000478 return status;
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000479
480 /* Flap the tx laser if it has not already been done */
481 if (hw->mac.autotry_restart) {
482 /* Disable tx laser; allow 100us to go dark per spec */
483 esdp_reg |= IXGBE_ESDP_SDP3;
484 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
485 udelay(100);
486
487 /* Enable tx laser; allow 2ms to light up per spec */
488 esdp_reg &= ~IXGBE_ESDP_SDP3;
489 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
490 msleep(2);
491
492 hw->mac.autotry_restart = false;
493 }
494
Don Skidmorecd7e1f02009-10-08 15:36:22 +0000495 /*
496 * Wait for the controller to acquire link. Per IEEE 802.3ap,
497 * Section 73.10.2, we may have to wait up to 500ms if KR is
498 * attempted. 82599 uses the same timing for 10g SFI.
499 */
500
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000501 for (i = 0; i < 5; i++) {
502 /* Wait for the link partner to also set speed */
503 msleep(100);
504
505 /* If we have link, just jump out */
506 hw->mac.ops.check_link(hw, &phy_link_speed,
507 &link_up, false);
508 if (link_up)
509 goto out;
510 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000511 }
512
513 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
514 speedcnt++;
515 if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN)
516 highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL;
517
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000518 /* If we already have link at this speed, just jump out */
519 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
520
521 if ((phy_link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
522 goto out;
523
524 /* Set the module link speed */
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000525 esdp_reg &= ~IXGBE_ESDP_SDP5;
526 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
527 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
528
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000529 /* Allow module to change analog characteristics (10G->1G) */
530 msleep(40);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000531
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000532 status = ixgbe_setup_mac_link_82599(hw,
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000533 IXGBE_LINK_SPEED_1GB_FULL,
534 autoneg,
535 autoneg_wait_to_complete);
536 if (status != 0)
Mallikarjuna R Chilakalac3c74322009-09-01 13:50:14 +0000537 return status;
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000538
539 /* Flap the tx laser if it has not already been done */
540 if (hw->mac.autotry_restart) {
541 /* Disable tx laser; allow 100us to go dark per spec */
542 esdp_reg |= IXGBE_ESDP_SDP3;
543 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
544 udelay(100);
545
546 /* Enable tx laser; allow 2ms to light up per spec */
547 esdp_reg &= ~IXGBE_ESDP_SDP3;
548 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
549 msleep(2);
550
551 hw->mac.autotry_restart = false;
552 }
553
554 /* Wait for the link partner to also set speed */
555 msleep(100);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000556
557 /* If we have link, just jump out */
558 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
559 if (link_up)
560 goto out;
561 }
562
563 /*
564 * We didn't get link. Configure back to the highest speed we tried,
565 * (if there was more than one). We call ourselves back with just the
566 * single highest speed that the user requested.
567 */
568 if (speedcnt > 1)
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000569 status = ixgbe_setup_mac_link_multispeed_fiber(hw,
570 highest_link_speed,
571 autoneg,
572 autoneg_wait_to_complete);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000573
574out:
Mallikarjuna R Chilakalac3c74322009-09-01 13:50:14 +0000575 /* Set autoneg_advertised value based on input link speed */
576 hw->phy.autoneg_advertised = 0;
577
578 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
579 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
580
581 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
582 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
583
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000584 return status;
585}
586
587/**
Don Skidmorecd7e1f02009-10-08 15:36:22 +0000588 * ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed
589 * @hw: pointer to hardware structure
590 * @speed: new link speed
591 * @autoneg: true if autonegotiation enabled
592 * @autoneg_wait_to_complete: true when waiting for completion is needed
593 *
594 * Implements the Intel SmartSpeed algorithm.
595 **/
596static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
597 ixgbe_link_speed speed, bool autoneg,
598 bool autoneg_wait_to_complete)
599{
600 s32 status = 0;
601 ixgbe_link_speed link_speed;
602 s32 i, j;
603 bool link_up = false;
604 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
605
606 hw_dbg(hw, "ixgbe_setup_mac_link_smartspeed.\n");
607
608 /* Set autoneg_advertised value based on input link speed */
609 hw->phy.autoneg_advertised = 0;
610
611 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
612 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
613
614 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
615 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
616
617 if (speed & IXGBE_LINK_SPEED_100_FULL)
618 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
619
620 /*
621 * Implement Intel SmartSpeed algorithm. SmartSpeed will reduce the
622 * autoneg advertisement if link is unable to be established at the
623 * highest negotiated rate. This can sometimes happen due to integrity
624 * issues with the physical media connection.
625 */
626
627 /* First, try to get link with full advertisement */
628 hw->phy.smart_speed_active = false;
629 for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) {
630 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
631 autoneg_wait_to_complete);
632 if (status)
633 goto out;
634
635 /*
636 * Wait for the controller to acquire link. Per IEEE 802.3ap,
637 * Section 73.10.2, we may have to wait up to 500ms if KR is
638 * attempted, or 200ms if KX/KX4/BX/BX4 is attempted, per
639 * Table 9 in the AN MAS.
640 */
641 for (i = 0; i < 5; i++) {
642 mdelay(100);
643
644 /* If we have link, just jump out */
645 hw->mac.ops.check_link(hw, &link_speed,
646 &link_up, false);
647 if (link_up)
648 goto out;
649 }
650 }
651
652 /*
653 * We didn't get link. If we advertised KR plus one of KX4/KX
654 * (or BX4/BX), then disable KR and try again.
655 */
656 if (((autoc_reg & IXGBE_AUTOC_KR_SUPP) == 0) ||
657 ((autoc_reg & IXGBE_AUTOC_KX4_KX_SUPP_MASK) == 0))
658 goto out;
659
660 /* Turn SmartSpeed on to disable KR support */
661 hw->phy.smart_speed_active = true;
662 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
663 autoneg_wait_to_complete);
664 if (status)
665 goto out;
666
667 /*
668 * Wait for the controller to acquire link. 600ms will allow for
669 * the AN link_fail_inhibit_timer as well for multiple cycles of
670 * parallel detect, both 10g and 1g. This allows for the maximum
671 * connect attempts as defined in the AN MAS table 73-7.
672 */
673 for (i = 0; i < 6; i++) {
674 mdelay(100);
675
676 /* If we have link, just jump out */
677 hw->mac.ops.check_link(hw, &link_speed,
678 &link_up, false);
679 if (link_up)
680 goto out;
681 }
682
683 /* We didn't get link. Turn SmartSpeed back off. */
684 hw->phy.smart_speed_active = false;
685 status = ixgbe_setup_mac_link_82599(hw, speed, autoneg,
686 autoneg_wait_to_complete);
687
688out:
689 return status;
690}
691
692/**
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000693 * ixgbe_check_mac_link_82599 - Determine link and speed status
694 * @hw: pointer to hardware structure
695 * @speed: pointer to link speed
696 * @link_up: true when link is up
697 * @link_up_wait_to_complete: bool used to wait for link up or not
698 *
699 * Reads the links register to determine if link is up and the current speed
700 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000701static s32 ixgbe_check_mac_link_82599(struct ixgbe_hw *hw,
702 ixgbe_link_speed *speed,
703 bool *link_up,
704 bool link_up_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000705{
706 u32 links_reg;
707 u32 i;
708
709 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
710 if (link_up_wait_to_complete) {
711 for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
712 if (links_reg & IXGBE_LINKS_UP) {
713 *link_up = true;
714 break;
715 } else {
716 *link_up = false;
717 }
718 msleep(100);
719 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
720 }
721 } else {
722 if (links_reg & IXGBE_LINKS_UP)
723 *link_up = true;
724 else
725 *link_up = false;
726 }
727
728 if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
729 IXGBE_LINKS_SPEED_10G_82599)
730 *speed = IXGBE_LINK_SPEED_10GB_FULL;
731 else if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
732 IXGBE_LINKS_SPEED_1G_82599)
733 *speed = IXGBE_LINK_SPEED_1GB_FULL;
734 else
735 *speed = IXGBE_LINK_SPEED_100_FULL;
736
Mallikarjuna R Chilakala620fa032009-06-04 11:11:13 +0000737 /* if link is down, zero out the current_mode */
738 if (*link_up == false) {
739 hw->fc.current_mode = ixgbe_fc_none;
740 hw->fc.fc_was_autonegged = false;
741 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000742
743 return 0;
744}
745
746/**
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000747 * ixgbe_setup_mac_link_82599 - Set MAC link speed
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000748 * @hw: pointer to hardware structure
749 * @speed: new link speed
750 * @autoneg: true if autonegotiation enabled
751 * @autoneg_wait_to_complete: true when waiting for completion is needed
752 *
753 * Set the link speed in the AUTOC register and restarts link.
754 **/
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000755s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
756 ixgbe_link_speed speed, bool autoneg,
757 bool autoneg_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000758{
759 s32 status = 0;
760 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
761 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000762 u32 start_autoc = autoc;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000763 u32 orig_autoc = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000764 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
765 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
766 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
767 u32 links_reg;
768 u32 i;
769 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
770
771 /* Check to see if speed passed in is supported. */
772 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg);
773 speed &= link_capabilities;
774
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000775 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
776 status = IXGBE_ERR_LINK_SETUP;
777 goto out;
778 }
779
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000780 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
781 if (hw->mac.orig_link_settings_stored)
782 orig_autoc = hw->mac.orig_autoc;
783 else
784 orig_autoc = autoc;
785
786
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000787 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
788 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
789 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000790 /* Set KX4/KX/KR support according to speed requested */
791 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
792 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000793 if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000794 autoc |= IXGBE_AUTOC_KX4_SUPP;
Don Skidmorecd7e1f02009-10-08 15:36:22 +0000795 if ((orig_autoc & IXGBE_AUTOC_KR_SUPP) &&
796 (hw->phy.smart_speed_active == false))
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000797 autoc |= IXGBE_AUTOC_KR_SUPP;
798 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
799 autoc |= IXGBE_AUTOC_KX_SUPP;
800 } else if ((pma_pmd_1g == IXGBE_AUTOC_1G_SFI) &&
801 (link_mode == IXGBE_AUTOC_LMS_1G_LINK_NO_AN ||
802 link_mode == IXGBE_AUTOC_LMS_1G_AN)) {
803 /* Switch from 1G SFI to 10G SFI if requested */
804 if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&
805 (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)) {
806 autoc &= ~IXGBE_AUTOC_LMS_MASK;
807 autoc |= IXGBE_AUTOC_LMS_10G_SERIAL;
808 }
809 } else if ((pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI) &&
810 (link_mode == IXGBE_AUTOC_LMS_10G_SERIAL)) {
811 /* Switch from 10G SFI to 1G SFI if requested */
812 if ((speed == IXGBE_LINK_SPEED_1GB_FULL) &&
813 (pma_pmd_1g == IXGBE_AUTOC_1G_SFI)) {
814 autoc &= ~IXGBE_AUTOC_LMS_MASK;
815 if (autoneg)
816 autoc |= IXGBE_AUTOC_LMS_1G_AN;
817 else
818 autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
819 }
820 }
821
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000822 if (autoc != start_autoc) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000823 /* Restart link */
824 autoc |= IXGBE_AUTOC_AN_RESTART;
825 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
826
827 /* Only poll for autoneg to complete if specified to do so */
828 if (autoneg_wait_to_complete) {
829 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
830 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
831 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
832 links_reg = 0; /*Just in case Autoneg time=0*/
833 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
834 links_reg =
835 IXGBE_READ_REG(hw, IXGBE_LINKS);
836 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
837 break;
838 msleep(100);
839 }
840 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
841 status =
842 IXGBE_ERR_AUTONEG_NOT_COMPLETE;
843 hw_dbg(hw, "Autoneg did not "
844 "complete.\n");
845 }
846 }
847 }
848
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000849 /* Add delay to filter out noises during initial link setup */
850 msleep(50);
851 }
852
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000853out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000854 return status;
855}
856
857/**
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000858 * ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000859 * @hw: pointer to hardware structure
860 * @speed: new link speed
861 * @autoneg: true if autonegotiation enabled
862 * @autoneg_wait_to_complete: true if waiting is needed to complete
863 *
864 * Restarts link on PHY and MAC based on settings passed in.
865 **/
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000866static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
867 ixgbe_link_speed speed,
868 bool autoneg,
869 bool autoneg_wait_to_complete)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000870{
871 s32 status;
872
873 /* Setup the PHY according to input speed */
874 status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
875 autoneg_wait_to_complete);
876 /* Set up MAC */
Mallikarjuna R Chilakala8620a102009-09-01 13:49:35 +0000877 ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000878
879 return status;
880}
881
882/**
883 * ixgbe_reset_hw_82599 - Perform hardware reset
884 * @hw: pointer to hardware structure
885 *
886 * Resets the hardware by resetting the transmit and receive units, masks
887 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
888 * reset.
889 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +0000890static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000891{
892 s32 status = 0;
Greg Rosec9205692010-01-22 22:46:22 +0000893 u32 ctrl;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000894 u32 i;
895 u32 autoc;
896 u32 autoc2;
897
898 /* Call adapter stop to disable tx/rx and clear interrupts */
899 hw->mac.ops.stop_adapter(hw);
900
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000901 /* PHY ops must be identified and initialized prior to reset */
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000902
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000903 /* Init PHY and function pointers, perform SFP setup */
904 status = hw->phy.ops.init(hw);
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000905
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000906 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
907 goto reset_hw_out;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000908
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000909 /* Setup SFP module if there is one present. */
910 if (hw->phy.sfp_setup_needed) {
911 status = hw->mac.ops.setup_sfp(hw);
912 hw->phy.sfp_setup_needed = false;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000913 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000914
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000915 /* Reset PHY */
916 if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL)
917 hw->phy.ops.reset(hw);
918
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000919 /*
920 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
921 * access and verify no pending requests before reset
922 */
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000923 status = ixgbe_disable_pcie_master(hw);
924 if (status != 0) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000925 status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
926 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
927 }
928
929 /*
930 * Issue global reset to the MAC. This needs to be a SW reset.
931 * If link reset is used, it might reset the MAC when mng is using it
932 */
933 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
934 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST));
935 IXGBE_WRITE_FLUSH(hw);
936
937 /* Poll for reset bit to self-clear indicating reset is complete */
938 for (i = 0; i < 10; i++) {
939 udelay(1);
940 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
941 if (!(ctrl & IXGBE_CTRL_RST))
942 break;
943 }
944 if (ctrl & IXGBE_CTRL_RST) {
945 status = IXGBE_ERR_RESET_FAILED;
946 hw_dbg(hw, "Reset polling failed to complete.\n");
947 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000948
949 msleep(50);
950
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000951 /*
952 * Store the original AUTOC/AUTOC2 values if they have not been
953 * stored off yet. Otherwise restore the stored original
954 * values since the reset operation sets back to defaults.
955 */
956 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
957 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
958 if (hw->mac.orig_link_settings_stored == false) {
959 hw->mac.orig_autoc = autoc;
960 hw->mac.orig_autoc2 = autoc2;
961 hw->mac.orig_link_settings_stored = true;
Jesse Brandeburg4df10462009-03-13 22:15:31 +0000962 } else {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000963 if (autoc != hw->mac.orig_autoc)
964 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (hw->mac.orig_autoc |
965 IXGBE_AUTOC_AN_RESTART));
966
967 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
968 (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
969 autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
970 autoc2 |= (hw->mac.orig_autoc2 &
971 IXGBE_AUTOC2_UPPER_MASK);
972 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
973 }
974 }
975
Waskiewicz Jr, Peter Paca6bee2009-05-17 12:32:48 +0000976 /*
977 * Store MAC address from RAR0, clear receive address registers, and
978 * clear the multicast table. Also reset num_rar_entries to 128,
979 * since we modify this value when programming the SAN MAC address.
980 */
981 hw->mac.num_rar_entries = 128;
982 hw->mac.ops.init_rx_addrs(hw);
983
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000984 /* Store the permanent mac address */
985 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
986
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +0000987 /* Store the permanent SAN mac address */
988 hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
989
Waskiewicz Jr, Peter Paca6bee2009-05-17 12:32:48 +0000990 /* Add the SAN MAC address to the RAR only if it's a valid address */
991 if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
992 hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
993 hw->mac.san_addr, 0, IXGBE_RAH_AV);
994
995 /* Reserve the last RAR for the SAN MAC address */
996 hw->mac.num_rar_entries--;
997 }
998
Yi Zou383ff342009-10-28 18:23:57 +0000999 /* Store the alternative WWNN/WWPN prefix */
1000 hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
1001 &hw->mac.wwpn_prefix);
1002
PJ Waskiewicz04f165e2009-04-09 22:27:57 +00001003reset_hw_out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001004 return status;
1005}
1006
1007/**
1008 * ixgbe_clear_vmdq_82599 - Disassociate a VMDq pool index from a rx address
1009 * @hw: pointer to hardware struct
1010 * @rar: receive address register index to disassociate
1011 * @vmdq: VMDq pool index to remove from the rar
1012 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001013static s32 ixgbe_clear_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001014{
1015 u32 mpsar_lo, mpsar_hi;
1016 u32 rar_entries = hw->mac.num_rar_entries;
1017
1018 if (rar < rar_entries) {
1019 mpsar_lo = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));
1020 mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
1021
1022 if (!mpsar_lo && !mpsar_hi)
1023 goto done;
1024
1025 if (vmdq == IXGBE_CLEAR_VMDQ_ALL) {
1026 if (mpsar_lo) {
1027 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), 0);
1028 mpsar_lo = 0;
1029 }
1030 if (mpsar_hi) {
1031 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), 0);
1032 mpsar_hi = 0;
1033 }
1034 } else if (vmdq < 32) {
1035 mpsar_lo &= ~(1 << vmdq);
1036 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), mpsar_lo);
1037 } else {
1038 mpsar_hi &= ~(1 << (vmdq - 32));
1039 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), mpsar_hi);
1040 }
1041
1042 /* was that the last pool using this rar? */
1043 if (mpsar_lo == 0 && mpsar_hi == 0 && rar != 0)
1044 hw->mac.ops.clear_rar(hw, rar);
1045 } else {
1046 hw_dbg(hw, "RAR index %d is out of range.\n", rar);
1047 }
1048
1049done:
1050 return 0;
1051}
1052
1053/**
1054 * ixgbe_set_vmdq_82599 - Associate a VMDq pool index with a rx address
1055 * @hw: pointer to hardware struct
1056 * @rar: receive address register index to associate with a VMDq index
1057 * @vmdq: VMDq pool index
1058 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001059static s32 ixgbe_set_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001060{
1061 u32 mpsar;
1062 u32 rar_entries = hw->mac.num_rar_entries;
1063
1064 if (rar < rar_entries) {
1065 if (vmdq < 32) {
1066 mpsar = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));
1067 mpsar |= 1 << vmdq;
1068 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), mpsar);
1069 } else {
1070 mpsar = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
1071 mpsar |= 1 << (vmdq - 32);
1072 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), mpsar);
1073 }
1074 } else {
1075 hw_dbg(hw, "RAR index %d is out of range.\n", rar);
1076 }
1077 return 0;
1078}
1079
1080/**
1081 * ixgbe_set_vfta_82599 - Set VLAN filter table
1082 * @hw: pointer to hardware structure
1083 * @vlan: VLAN id to write to VLAN filter
1084 * @vind: VMDq output index that maps queue to VLAN id in VFVFB
1085 * @vlan_on: boolean flag to turn on/off VLAN in VFVF
1086 *
1087 * Turn on/off specified VLAN in the VLAN filter table.
1088 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001089static s32 ixgbe_set_vfta_82599(struct ixgbe_hw *hw, u32 vlan, u32 vind,
1090 bool vlan_on)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001091{
1092 u32 regindex;
Greg Rose096a58f2010-01-09 02:26:26 +00001093 u32 vlvf_index;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001094 u32 bitindex;
1095 u32 bits;
1096 u32 first_empty_slot;
Greg Rose096a58f2010-01-09 02:26:26 +00001097 u32 vt_ctl;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001098
1099 if (vlan > 4095)
1100 return IXGBE_ERR_PARAM;
1101
1102 /*
1103 * this is a 2 part operation - first the VFTA, then the
1104 * VLVF and VLVFB if vind is set
1105 */
1106
1107 /* Part 1
1108 * The VFTA is a bitstring made up of 128 32-bit registers
1109 * that enable the particular VLAN id, much like the MTA:
1110 * bits[11-5]: which register
1111 * bits[4-0]: which bit in the register
1112 */
1113 regindex = (vlan >> 5) & 0x7F;
1114 bitindex = vlan & 0x1F;
1115 bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
1116 if (vlan_on)
1117 bits |= (1 << bitindex);
1118 else
1119 bits &= ~(1 << bitindex);
1120 IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
1121
1122
1123 /* Part 2
Greg Rose096a58f2010-01-09 02:26:26 +00001124 * If VT mode is set
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001125 * Either vlan_on
1126 * make sure the vlan is in VLVF
1127 * set the vind bit in the matching VLVFB
1128 * Or !vlan_on
1129 * clear the pool bit and possibly the vind
1130 */
Greg Rose096a58f2010-01-09 02:26:26 +00001131 vt_ctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
1132 if (!(vt_ctl & IXGBE_VT_CTL_VT_ENABLE))
1133 goto out;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001134
Greg Rose096a58f2010-01-09 02:26:26 +00001135 /* find the vlanid or the first empty slot */
1136 first_empty_slot = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001137
Greg Rose096a58f2010-01-09 02:26:26 +00001138 for (vlvf_index = 1; vlvf_index < IXGBE_VLVF_ENTRIES; vlvf_index++) {
1139 bits = IXGBE_READ_REG(hw, IXGBE_VLVF(vlvf_index));
1140 if (!bits && !first_empty_slot)
1141 first_empty_slot = vlvf_index;
1142 else if ((bits & 0x0FFF) == vlan)
1143 break;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001144 }
1145
Greg Rose096a58f2010-01-09 02:26:26 +00001146 if (vlvf_index >= IXGBE_VLVF_ENTRIES) {
1147 if (first_empty_slot)
1148 vlvf_index = first_empty_slot;
1149 else {
1150 hw_dbg(hw, "No space in VLVF.\n");
1151 goto out;
1152 }
1153 }
1154
1155 if (vlan_on) {
1156 /* set the pool bit */
1157 if (vind < 32) {
1158 bits = IXGBE_READ_REG(hw,
1159 IXGBE_VLVFB(vlvf_index * 2));
1160 bits |= (1 << vind);
1161 IXGBE_WRITE_REG(hw,
1162 IXGBE_VLVFB(vlvf_index * 2), bits);
1163 } else {
1164 bits = IXGBE_READ_REG(hw,
1165 IXGBE_VLVFB((vlvf_index * 2) + 1));
1166 bits |= (1 << (vind - 32));
1167 IXGBE_WRITE_REG(hw,
1168 IXGBE_VLVFB((vlvf_index * 2) + 1), bits);
1169 }
1170 } else {
1171 /* clear the pool bit */
1172 if (vind < 32) {
1173 bits = IXGBE_READ_REG(hw,
1174 IXGBE_VLVFB(vlvf_index * 2));
1175 bits &= ~(1 << vind);
1176 IXGBE_WRITE_REG(hw,
1177 IXGBE_VLVFB(vlvf_index * 2), bits);
1178 bits |= IXGBE_READ_REG(hw,
1179 IXGBE_VLVFB((vlvf_index * 2) + 1));
1180 } else {
1181 bits = IXGBE_READ_REG(hw,
1182 IXGBE_VLVFB((vlvf_index * 2) + 1));
1183 bits &= ~(1 << (vind - 32));
1184 IXGBE_WRITE_REG(hw,
1185 IXGBE_VLVFB((vlvf_index * 2) + 1), bits);
1186 bits |= IXGBE_READ_REG(hw,
1187 IXGBE_VLVFB(vlvf_index * 2));
1188 }
1189 }
1190
1191 if (bits) {
1192 IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index),
1193 (IXGBE_VLVF_VIEN | vlan));
1194 /* if bits is non-zero then some pools/VFs are still
1195 * using this VLAN ID. Force the VFTA entry to on */
1196 bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
1197 bits |= (1 << bitindex);
1198 IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
1199 }
1200 else
1201 IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index), 0);
1202
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001203out:
1204 return 0;
1205}
1206
1207/**
1208 * ixgbe_clear_vfta_82599 - Clear VLAN filter table
1209 * @hw: pointer to hardware structure
1210 *
1211 * Clears the VLAN filer table, and the VMDq index associated with the filter
1212 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001213static s32 ixgbe_clear_vfta_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001214{
1215 u32 offset;
1216
1217 for (offset = 0; offset < hw->mac.vft_size; offset++)
1218 IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);
1219
1220 for (offset = 0; offset < IXGBE_VLVF_ENTRIES; offset++) {
1221 IXGBE_WRITE_REG(hw, IXGBE_VLVF(offset), 0);
1222 IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2), 0);
1223 IXGBE_WRITE_REG(hw, IXGBE_VLVFB((offset * 2) + 1), 0);
1224 }
1225
1226 return 0;
1227}
1228
1229/**
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001230 * ixgbe_init_uta_tables_82599 - Initialize the Unicast Table Array
1231 * @hw: pointer to hardware structure
1232 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001233static s32 ixgbe_init_uta_tables_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001234{
1235 int i;
1236 hw_dbg(hw, " Clearing UTA\n");
1237
1238 for (i = 0; i < 128; i++)
1239 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
1240
1241 return 0;
1242}
1243
1244/**
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001245 * ixgbe_reinit_fdir_tables_82599 - Reinitialize Flow Director tables.
1246 * @hw: pointer to hardware structure
1247 **/
1248s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
1249{
1250 int i;
1251 u32 fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
1252 fdirctrl &= ~IXGBE_FDIRCTRL_INIT_DONE;
1253
1254 /*
1255 * Before starting reinitialization process,
1256 * FDIRCMD.CMD must be zero.
1257 */
1258 for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) {
1259 if (!(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
1260 IXGBE_FDIRCMD_CMD_MASK))
1261 break;
1262 udelay(10);
1263 }
1264 if (i >= IXGBE_FDIRCMD_CMD_POLL) {
1265 hw_dbg(hw ,"Flow Director previous command isn't complete, "
1266 "aborting table re-initialization. \n");
1267 return IXGBE_ERR_FDIR_REINIT_FAILED;
1268 }
1269
1270 IXGBE_WRITE_REG(hw, IXGBE_FDIRFREE, 0);
1271 IXGBE_WRITE_FLUSH(hw);
1272 /*
1273 * 82599 adapters flow director init flow cannot be restarted,
1274 * Workaround 82599 silicon errata by performing the following steps
1275 * before re-writing the FDIRCTRL control register with the same value.
1276 * - write 1 to bit 8 of FDIRCMD register &
1277 * - write 0 to bit 8 of FDIRCMD register
1278 */
1279 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
1280 (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) |
1281 IXGBE_FDIRCMD_CLEARHT));
1282 IXGBE_WRITE_FLUSH(hw);
1283 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
1284 (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
1285 ~IXGBE_FDIRCMD_CLEARHT));
1286 IXGBE_WRITE_FLUSH(hw);
1287 /*
1288 * Clear FDIR Hash register to clear any leftover hashes
1289 * waiting to be programmed.
1290 */
1291 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, 0x00);
1292 IXGBE_WRITE_FLUSH(hw);
1293
1294 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1295 IXGBE_WRITE_FLUSH(hw);
1296
1297 /* Poll init-done after we write FDIRCTRL register */
1298 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1299 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1300 IXGBE_FDIRCTRL_INIT_DONE)
1301 break;
1302 udelay(10);
1303 }
1304 if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
1305 hw_dbg(hw, "Flow Director Signature poll time exceeded!\n");
1306 return IXGBE_ERR_FDIR_REINIT_FAILED;
1307 }
1308
1309 /* Clear FDIR statistics registers (read to clear) */
1310 IXGBE_READ_REG(hw, IXGBE_FDIRUSTAT);
1311 IXGBE_READ_REG(hw, IXGBE_FDIRFSTAT);
1312 IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
1313 IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
1314 IXGBE_READ_REG(hw, IXGBE_FDIRLEN);
1315
1316 return 0;
1317}
1318
1319/**
1320 * ixgbe_init_fdir_signature_82599 - Initialize Flow Director signature filters
1321 * @hw: pointer to hardware structure
1322 * @pballoc: which mode to allocate filters with
1323 **/
1324s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 pballoc)
1325{
1326 u32 fdirctrl = 0;
1327 u32 pbsize;
1328 int i;
1329
1330 /*
1331 * Before enabling Flow Director, the Rx Packet Buffer size
1332 * must be reduced. The new value is the current size minus
1333 * flow director memory usage size.
1334 */
1335 pbsize = (1 << (IXGBE_FDIR_PBALLOC_SIZE_SHIFT + pballoc));
1336 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0),
1337 (IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0)) - pbsize));
1338
1339 /*
1340 * The defaults in the HW for RX PB 1-7 are not zero and so should be
1341 * intialized to zero for non DCB mode otherwise actual total RX PB
1342 * would be bigger than programmed and filter space would run into
1343 * the PB 0 region.
1344 */
1345 for (i = 1; i < 8; i++)
1346 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
1347
1348 /* Send interrupt when 64 filters are left */
1349 fdirctrl |= 4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT;
1350
1351 /* Set the maximum length per hash bucket to 0xA filters */
1352 fdirctrl |= 0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT;
1353
1354 switch (pballoc) {
1355 case IXGBE_FDIR_PBALLOC_64K:
1356 /* 8k - 1 signature filters */
1357 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_64K;
1358 break;
1359 case IXGBE_FDIR_PBALLOC_128K:
1360 /* 16k - 1 signature filters */
1361 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_128K;
1362 break;
1363 case IXGBE_FDIR_PBALLOC_256K:
1364 /* 32k - 1 signature filters */
1365 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_256K;
1366 break;
1367 default:
1368 /* bad value */
1369 return IXGBE_ERR_CONFIG;
1370 };
1371
1372 /* Move the flexible bytes to use the ethertype - shift 6 words */
1373 fdirctrl |= (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT);
1374
1375 fdirctrl |= IXGBE_FDIRCTRL_REPORT_STATUS;
1376
1377 /* Prime the keys for hashing */
1378 IXGBE_WRITE_REG(hw, IXGBE_FDIRHKEY,
1379 htonl(IXGBE_ATR_BUCKET_HASH_KEY));
1380 IXGBE_WRITE_REG(hw, IXGBE_FDIRSKEY,
1381 htonl(IXGBE_ATR_SIGNATURE_HASH_KEY));
1382
1383 /*
1384 * Poll init-done after we write the register. Estimated times:
1385 * 10G: PBALLOC = 11b, timing is 60us
1386 * 1G: PBALLOC = 11b, timing is 600us
1387 * 100M: PBALLOC = 11b, timing is 6ms
1388 *
1389 * Multiple these timings by 4 if under full Rx load
1390 *
1391 * So we'll poll for IXGBE_FDIR_INIT_DONE_POLL times, sleeping for
1392 * 1 msec per poll time. If we're at line rate and drop to 100M, then
1393 * this might not finish in our poll time, but we can live with that
1394 * for now.
1395 */
1396 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1397 IXGBE_WRITE_FLUSH(hw);
1398 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1399 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1400 IXGBE_FDIRCTRL_INIT_DONE)
1401 break;
1402 msleep(1);
1403 }
1404 if (i >= IXGBE_FDIR_INIT_DONE_POLL)
1405 hw_dbg(hw, "Flow Director Signature poll time exceeded!\n");
1406
1407 return 0;
1408}
1409
1410/**
1411 * ixgbe_init_fdir_perfect_82599 - Initialize Flow Director perfect filters
1412 * @hw: pointer to hardware structure
1413 * @pballoc: which mode to allocate filters with
1414 **/
1415s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 pballoc)
1416{
1417 u32 fdirctrl = 0;
1418 u32 pbsize;
1419 int i;
1420
1421 /*
1422 * Before enabling Flow Director, the Rx Packet Buffer size
1423 * must be reduced. The new value is the current size minus
1424 * flow director memory usage size.
1425 */
1426 pbsize = (1 << (IXGBE_FDIR_PBALLOC_SIZE_SHIFT + pballoc));
1427 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0),
1428 (IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0)) - pbsize));
1429
1430 /*
1431 * The defaults in the HW for RX PB 1-7 are not zero and so should be
1432 * intialized to zero for non DCB mode otherwise actual total RX PB
1433 * would be bigger than programmed and filter space would run into
1434 * the PB 0 region.
1435 */
1436 for (i = 1; i < 8; i++)
1437 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
1438
1439 /* Send interrupt when 64 filters are left */
1440 fdirctrl |= 4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT;
1441
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001442 /* Initialize the drop queue to Rx queue 127 */
1443 fdirctrl |= (127 << IXGBE_FDIRCTRL_DROP_Q_SHIFT);
1444
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001445 switch (pballoc) {
1446 case IXGBE_FDIR_PBALLOC_64K:
1447 /* 2k - 1 perfect filters */
1448 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_64K;
1449 break;
1450 case IXGBE_FDIR_PBALLOC_128K:
1451 /* 4k - 1 perfect filters */
1452 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_128K;
1453 break;
1454 case IXGBE_FDIR_PBALLOC_256K:
1455 /* 8k - 1 perfect filters */
1456 fdirctrl |= IXGBE_FDIRCTRL_PBALLOC_256K;
1457 break;
1458 default:
1459 /* bad value */
1460 return IXGBE_ERR_CONFIG;
1461 };
1462
1463 /* Turn perfect match filtering on */
1464 fdirctrl |= IXGBE_FDIRCTRL_PERFECT_MATCH;
1465 fdirctrl |= IXGBE_FDIRCTRL_REPORT_STATUS;
1466
1467 /* Move the flexible bytes to use the ethertype - shift 6 words */
1468 fdirctrl |= (0x6 << IXGBE_FDIRCTRL_FLEX_SHIFT);
1469
1470 /* Prime the keys for hashing */
1471 IXGBE_WRITE_REG(hw, IXGBE_FDIRHKEY,
1472 htonl(IXGBE_ATR_BUCKET_HASH_KEY));
1473 IXGBE_WRITE_REG(hw, IXGBE_FDIRSKEY,
1474 htonl(IXGBE_ATR_SIGNATURE_HASH_KEY));
1475
1476 /*
1477 * Poll init-done after we write the register. Estimated times:
1478 * 10G: PBALLOC = 11b, timing is 60us
1479 * 1G: PBALLOC = 11b, timing is 600us
1480 * 100M: PBALLOC = 11b, timing is 6ms
1481 *
1482 * Multiple these timings by 4 if under full Rx load
1483 *
1484 * So we'll poll for IXGBE_FDIR_INIT_DONE_POLL times, sleeping for
1485 * 1 msec per poll time. If we're at line rate and drop to 100M, then
1486 * this might not finish in our poll time, but we can live with that
1487 * for now.
1488 */
1489
1490 /* Set the maximum length per hash bucket to 0xA filters */
1491 fdirctrl |= (0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT);
1492
1493 IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
1494 IXGBE_WRITE_FLUSH(hw);
1495 for (i = 0; i < IXGBE_FDIR_INIT_DONE_POLL; i++) {
1496 if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) &
1497 IXGBE_FDIRCTRL_INIT_DONE)
1498 break;
1499 msleep(1);
1500 }
1501 if (i >= IXGBE_FDIR_INIT_DONE_POLL)
1502 hw_dbg(hw, "Flow Director Perfect poll time exceeded!\n");
1503
1504 return 0;
1505}
1506
1507
1508/**
1509 * ixgbe_atr_compute_hash_82599 - Compute the hashes for SW ATR
1510 * @stream: input bitstream to compute the hash on
1511 * @key: 32-bit hash key
1512 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001513static u16 ixgbe_atr_compute_hash_82599(struct ixgbe_atr_input *atr_input,
1514 u32 key)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001515{
1516 /*
1517 * The algorithm is as follows:
1518 * Hash[15:0] = Sum { S[n] x K[n+16] }, n = 0...350
1519 * where Sum {A[n]}, n = 0...n is bitwise XOR of A[0], A[1]...A[n]
1520 * and A[n] x B[n] is bitwise AND between same length strings
1521 *
1522 * K[n] is 16 bits, defined as:
1523 * for n modulo 32 >= 15, K[n] = K[n % 32 : (n % 32) - 15]
1524 * for n modulo 32 < 15, K[n] =
1525 * K[(n % 32:0) | (31:31 - (14 - (n % 32)))]
1526 *
1527 * S[n] is 16 bits, defined as:
1528 * for n >= 15, S[n] = S[n:n - 15]
1529 * for n < 15, S[n] = S[(n:0) | (350:350 - (14 - n))]
1530 *
1531 * To simplify for programming, the algorithm is implemented
1532 * in software this way:
1533 *
1534 * Key[31:0], Stream[335:0]
1535 *
1536 * tmp_key[11 * 32 - 1:0] = 11{Key[31:0] = key concatenated 11 times
1537 * int_key[350:0] = tmp_key[351:1]
1538 * int_stream[365:0] = Stream[14:0] | Stream[335:0] | Stream[335:321]
1539 *
1540 * hash[15:0] = 0;
1541 * for (i = 0; i < 351; i++) {
1542 * if (int_key[i])
1543 * hash ^= int_stream[(i + 15):i];
1544 * }
1545 */
1546
1547 union {
1548 u64 fill[6];
1549 u32 key[11];
1550 u8 key_stream[44];
1551 } tmp_key;
1552
1553 u8 *stream = (u8 *)atr_input;
1554 u8 int_key[44]; /* upper-most bit unused */
1555 u8 hash_str[46]; /* upper-most 2 bits unused */
1556 u16 hash_result = 0;
1557 int i, j, k, h;
1558
1559 /*
1560 * Initialize the fill member to prevent warnings
1561 * on some compilers
1562 */
1563 tmp_key.fill[0] = 0;
1564
1565 /* First load the temporary key stream */
1566 for (i = 0; i < 6; i++) {
1567 u64 fillkey = ((u64)key << 32) | key;
1568 tmp_key.fill[i] = fillkey;
1569 }
1570
1571 /*
1572 * Set the interim key for the hashing. Bit 352 is unused, so we must
1573 * shift and compensate when building the key.
1574 */
1575
1576 int_key[0] = tmp_key.key_stream[0] >> 1;
1577 for (i = 1, j = 0; i < 44; i++) {
1578 unsigned int this_key = tmp_key.key_stream[j] << 7;
1579 j++;
1580 int_key[i] = (u8)(this_key | (tmp_key.key_stream[j] >> 1));
1581 }
1582
1583 /*
1584 * Set the interim bit string for the hashing. Bits 368 and 367 are
1585 * unused, so shift and compensate when building the string.
1586 */
1587 hash_str[0] = (stream[40] & 0x7f) >> 1;
1588 for (i = 1, j = 40; i < 46; i++) {
1589 unsigned int this_str = stream[j] << 7;
1590 j++;
1591 if (j > 41)
1592 j = 0;
1593 hash_str[i] = (u8)(this_str | (stream[j] >> 1));
1594 }
1595
1596 /*
1597 * Now compute the hash. i is the index into hash_str, j is into our
1598 * key stream, k is counting the number of bits, and h interates within
1599 * each byte.
1600 */
1601 for (i = 45, j = 43, k = 0; k < 351 && i >= 2 && j >= 0; i--, j--) {
1602 for (h = 0; h < 8 && k < 351; h++, k++) {
1603 if (int_key[j] & (1 << h)) {
1604 /*
1605 * Key bit is set, XOR in the current 16-bit
1606 * string. Example of processing:
1607 * h = 0,
1608 * tmp = (hash_str[i - 2] & 0 << 16) |
1609 * (hash_str[i - 1] & 0xff << 8) |
1610 * (hash_str[i] & 0xff >> 0)
1611 * So tmp = hash_str[15 + k:k], since the
1612 * i + 2 clause rolls off the 16-bit value
1613 * h = 7,
1614 * tmp = (hash_str[i - 2] & 0x7f << 9) |
1615 * (hash_str[i - 1] & 0xff << 1) |
1616 * (hash_str[i] & 0x80 >> 7)
1617 */
1618 int tmp = (hash_str[i] >> h);
1619 tmp |= (hash_str[i - 1] << (8 - h));
1620 tmp |= (int)(hash_str[i - 2] & ((1 << h) - 1))
1621 << (16 - h);
1622 hash_result ^= (u16)tmp;
1623 }
1624 }
1625 }
1626
1627 return hash_result;
1628}
1629
1630/**
1631 * ixgbe_atr_set_vlan_id_82599 - Sets the VLAN id in the ATR input stream
1632 * @input: input stream to modify
1633 * @vlan: the VLAN id to load
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001634 * @vlan_mask: bitwise mask for the VLAN
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001635 **/
1636s32 ixgbe_atr_set_vlan_id_82599(struct ixgbe_atr_input *input, u16 vlan)
1637{
1638 input->byte_stream[IXGBE_ATR_VLAN_OFFSET + 1] = vlan >> 8;
1639 input->byte_stream[IXGBE_ATR_VLAN_OFFSET] = vlan & 0xff;
1640
1641 return 0;
1642}
1643
1644/**
1645 * ixgbe_atr_set_src_ipv4_82599 - Sets the source IPv4 address
1646 * @input: input stream to modify
1647 * @src_addr: the IP address to load
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001648 * @src_addr_mask: bitwise mask for the source IP address
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001649 **/
1650s32 ixgbe_atr_set_src_ipv4_82599(struct ixgbe_atr_input *input, u32 src_addr)
1651{
1652 input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 3] = src_addr >> 24;
1653 input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 2] =
1654 (src_addr >> 16) & 0xff;
1655 input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 1] =
1656 (src_addr >> 8) & 0xff;
1657 input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET] = src_addr & 0xff;
1658
1659 return 0;
1660}
1661
1662/**
1663 * ixgbe_atr_set_dst_ipv4_82599 - Sets the destination IPv4 address
1664 * @input: input stream to modify
1665 * @dst_addr: the IP address to load
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001666 * @dst_addr_mask: bitwise mask for the destination IP address
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001667 **/
1668s32 ixgbe_atr_set_dst_ipv4_82599(struct ixgbe_atr_input *input, u32 dst_addr)
1669{
1670 input->byte_stream[IXGBE_ATR_DST_IPV4_OFFSET + 3] = dst_addr >> 24;
1671 input->byte_stream[IXGBE_ATR_DST_IPV4_OFFSET + 2] =
1672 (dst_addr >> 16) & 0xff;
1673 input->byte_stream[IXGBE_ATR_DST_IPV4_OFFSET + 1] =
1674 (dst_addr >> 8) & 0xff;
1675 input->byte_stream[IXGBE_ATR_DST_IPV4_OFFSET] = dst_addr & 0xff;
1676
1677 return 0;
1678}
1679
1680/**
1681 * ixgbe_atr_set_src_ipv6_82599 - Sets the source IPv6 address
1682 * @input: input stream to modify
1683 * @src_addr_1: the first 4 bytes of the IP address to load
1684 * @src_addr_2: the second 4 bytes of the IP address to load
1685 * @src_addr_3: the third 4 bytes of the IP address to load
1686 * @src_addr_4: the fourth 4 bytes of the IP address to load
1687 **/
1688s32 ixgbe_atr_set_src_ipv6_82599(struct ixgbe_atr_input *input,
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001689 u32 src_addr_1, u32 src_addr_2,
1690 u32 src_addr_3, u32 src_addr_4)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001691{
1692 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET] = src_addr_4 & 0xff;
1693 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 1] =
1694 (src_addr_4 >> 8) & 0xff;
1695 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 2] =
1696 (src_addr_4 >> 16) & 0xff;
1697 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 3] = src_addr_4 >> 24;
1698
1699 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 4] = src_addr_3 & 0xff;
1700 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 5] =
1701 (src_addr_3 >> 8) & 0xff;
1702 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 6] =
1703 (src_addr_3 >> 16) & 0xff;
1704 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 7] = src_addr_3 >> 24;
1705
1706 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 8] = src_addr_2 & 0xff;
1707 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 9] =
1708 (src_addr_2 >> 8) & 0xff;
1709 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 10] =
1710 (src_addr_2 >> 16) & 0xff;
1711 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 11] = src_addr_2 >> 24;
1712
1713 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 12] = src_addr_1 & 0xff;
1714 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 13] =
1715 (src_addr_1 >> 8) & 0xff;
1716 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 14] =
1717 (src_addr_1 >> 16) & 0xff;
1718 input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 15] = src_addr_1 >> 24;
1719
1720 return 0;
1721}
1722
1723/**
1724 * ixgbe_atr_set_dst_ipv6_82599 - Sets the destination IPv6 address
1725 * @input: input stream to modify
1726 * @dst_addr_1: the first 4 bytes of the IP address to load
1727 * @dst_addr_2: the second 4 bytes of the IP address to load
1728 * @dst_addr_3: the third 4 bytes of the IP address to load
1729 * @dst_addr_4: the fourth 4 bytes of the IP address to load
1730 **/
1731s32 ixgbe_atr_set_dst_ipv6_82599(struct ixgbe_atr_input *input,
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001732 u32 dst_addr_1, u32 dst_addr_2,
1733 u32 dst_addr_3, u32 dst_addr_4)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001734{
1735 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET] = dst_addr_4 & 0xff;
1736 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 1] =
1737 (dst_addr_4 >> 8) & 0xff;
1738 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 2] =
1739 (dst_addr_4 >> 16) & 0xff;
1740 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 3] = dst_addr_4 >> 24;
1741
1742 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 4] = dst_addr_3 & 0xff;
1743 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 5] =
1744 (dst_addr_3 >> 8) & 0xff;
1745 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 6] =
1746 (dst_addr_3 >> 16) & 0xff;
1747 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 7] = dst_addr_3 >> 24;
1748
1749 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 8] = dst_addr_2 & 0xff;
1750 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 9] =
1751 (dst_addr_2 >> 8) & 0xff;
1752 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 10] =
1753 (dst_addr_2 >> 16) & 0xff;
1754 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 11] = dst_addr_2 >> 24;
1755
1756 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 12] = dst_addr_1 & 0xff;
1757 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 13] =
1758 (dst_addr_1 >> 8) & 0xff;
1759 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 14] =
1760 (dst_addr_1 >> 16) & 0xff;
1761 input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 15] = dst_addr_1 >> 24;
1762
1763 return 0;
1764}
1765
1766/**
1767 * ixgbe_atr_set_src_port_82599 - Sets the source port
1768 * @input: input stream to modify
1769 * @src_port: the source port to load
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001770 * @src_port_mask: bitwise mask for the source port
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001771 **/
1772s32 ixgbe_atr_set_src_port_82599(struct ixgbe_atr_input *input, u16 src_port)
1773{
1774 input->byte_stream[IXGBE_ATR_SRC_PORT_OFFSET + 1] = src_port >> 8;
1775 input->byte_stream[IXGBE_ATR_SRC_PORT_OFFSET] = src_port & 0xff;
1776
1777 return 0;
1778}
1779
1780/**
1781 * ixgbe_atr_set_dst_port_82599 - Sets the destination port
1782 * @input: input stream to modify
1783 * @dst_port: the destination port to load
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001784 * @dst_port_mask: bitwise mask for the destination port
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001785 **/
1786s32 ixgbe_atr_set_dst_port_82599(struct ixgbe_atr_input *input, u16 dst_port)
1787{
1788 input->byte_stream[IXGBE_ATR_DST_PORT_OFFSET + 1] = dst_port >> 8;
1789 input->byte_stream[IXGBE_ATR_DST_PORT_OFFSET] = dst_port & 0xff;
1790
1791 return 0;
1792}
1793
1794/**
1795 * ixgbe_atr_set_flex_byte_82599 - Sets the flexible bytes
1796 * @input: input stream to modify
1797 * @flex_bytes: the flexible bytes to load
1798 **/
1799s32 ixgbe_atr_set_flex_byte_82599(struct ixgbe_atr_input *input, u16 flex_byte)
1800{
1801 input->byte_stream[IXGBE_ATR_FLEX_BYTE_OFFSET + 1] = flex_byte >> 8;
1802 input->byte_stream[IXGBE_ATR_FLEX_BYTE_OFFSET] = flex_byte & 0xff;
1803
1804 return 0;
1805}
1806
1807/**
1808 * ixgbe_atr_set_vm_pool_82599 - Sets the Virtual Machine pool
1809 * @input: input stream to modify
1810 * @vm_pool: the Virtual Machine pool to load
1811 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001812s32 ixgbe_atr_set_vm_pool_82599(struct ixgbe_atr_input *input,
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001813 u8 vm_pool)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001814{
1815 input->byte_stream[IXGBE_ATR_VM_POOL_OFFSET] = vm_pool;
1816
1817 return 0;
1818}
1819
1820/**
1821 * ixgbe_atr_set_l4type_82599 - Sets the layer 4 packet type
1822 * @input: input stream to modify
1823 * @l4type: the layer 4 type value to load
1824 **/
1825s32 ixgbe_atr_set_l4type_82599(struct ixgbe_atr_input *input, u8 l4type)
1826{
1827 input->byte_stream[IXGBE_ATR_L4TYPE_OFFSET] = l4type;
1828
1829 return 0;
1830}
1831
1832/**
1833 * ixgbe_atr_get_vlan_id_82599 - Gets the VLAN id from the ATR input stream
1834 * @input: input stream to search
1835 * @vlan: the VLAN id to load
1836 **/
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00001837static s32 ixgbe_atr_get_vlan_id_82599(struct ixgbe_atr_input *input, u16 *vlan)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001838{
1839 *vlan = input->byte_stream[IXGBE_ATR_VLAN_OFFSET];
1840 *vlan |= input->byte_stream[IXGBE_ATR_VLAN_OFFSET + 1] << 8;
1841
1842 return 0;
1843}
1844
1845/**
1846 * ixgbe_atr_get_src_ipv4_82599 - Gets the source IPv4 address
1847 * @input: input stream to search
1848 * @src_addr: the IP address to load
1849 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001850static s32 ixgbe_atr_get_src_ipv4_82599(struct ixgbe_atr_input *input,
1851 u32 *src_addr)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001852{
1853 *src_addr = input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET];
1854 *src_addr |= input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 1] << 8;
1855 *src_addr |= input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 2] << 16;
1856 *src_addr |= input->byte_stream[IXGBE_ATR_SRC_IPV4_OFFSET + 3] << 24;
1857
1858 return 0;
1859}
1860
1861/**
1862 * ixgbe_atr_get_dst_ipv4_82599 - Gets the destination IPv4 address
1863 * @input: input stream to search
1864 * @dst_addr: the IP address to load
1865 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001866static s32 ixgbe_atr_get_dst_ipv4_82599(struct ixgbe_atr_input *input,
1867 u32 *dst_addr)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001868{
1869 *dst_addr = input->byte_stream[IXGBE_ATR_DST_IPV4_OFFSET];
1870 *dst_addr |= input->byte_stream[IXGBE_ATR_DST_IPV4_OFFSET + 1] << 8;
1871 *dst_addr |= input->byte_stream[IXGBE_ATR_DST_IPV4_OFFSET + 2] << 16;
1872 *dst_addr |= input->byte_stream[IXGBE_ATR_DST_IPV4_OFFSET + 3] << 24;
1873
1874 return 0;
1875}
1876
1877/**
1878 * ixgbe_atr_get_src_ipv6_82599 - Gets the source IPv6 address
1879 * @input: input stream to search
1880 * @src_addr_1: the first 4 bytes of the IP address to load
1881 * @src_addr_2: the second 4 bytes of the IP address to load
1882 * @src_addr_3: the third 4 bytes of the IP address to load
1883 * @src_addr_4: the fourth 4 bytes of the IP address to load
1884 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001885static s32 ixgbe_atr_get_src_ipv6_82599(struct ixgbe_atr_input *input,
1886 u32 *src_addr_1, u32 *src_addr_2,
1887 u32 *src_addr_3, u32 *src_addr_4)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001888{
1889 *src_addr_1 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 12];
1890 *src_addr_1 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 13] << 8;
1891 *src_addr_1 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 14] << 16;
1892 *src_addr_1 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 15] << 24;
1893
1894 *src_addr_2 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 8];
1895 *src_addr_2 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 9] << 8;
1896 *src_addr_2 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 10] << 16;
1897 *src_addr_2 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 11] << 24;
1898
1899 *src_addr_3 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 4];
1900 *src_addr_3 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 5] << 8;
1901 *src_addr_3 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 6] << 16;
1902 *src_addr_3 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 7] << 24;
1903
1904 *src_addr_4 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET];
1905 *src_addr_4 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 1] << 8;
1906 *src_addr_4 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 2] << 16;
1907 *src_addr_4 = input->byte_stream[IXGBE_ATR_SRC_IPV6_OFFSET + 3] << 24;
1908
1909 return 0;
1910}
1911
1912/**
1913 * ixgbe_atr_get_dst_ipv6_82599 - Gets the destination IPv6 address
1914 * @input: input stream to search
1915 * @dst_addr_1: the first 4 bytes of the IP address to load
1916 * @dst_addr_2: the second 4 bytes of the IP address to load
1917 * @dst_addr_3: the third 4 bytes of the IP address to load
1918 * @dst_addr_4: the fourth 4 bytes of the IP address to load
1919 **/
1920s32 ixgbe_atr_get_dst_ipv6_82599(struct ixgbe_atr_input *input,
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001921 u32 *dst_addr_1, u32 *dst_addr_2,
1922 u32 *dst_addr_3, u32 *dst_addr_4)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001923{
1924 *dst_addr_1 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 12];
1925 *dst_addr_1 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 13] << 8;
1926 *dst_addr_1 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 14] << 16;
1927 *dst_addr_1 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 15] << 24;
1928
1929 *dst_addr_2 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 8];
1930 *dst_addr_2 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 9] << 8;
1931 *dst_addr_2 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 10] << 16;
1932 *dst_addr_2 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 11] << 24;
1933
1934 *dst_addr_3 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 4];
1935 *dst_addr_3 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 5] << 8;
1936 *dst_addr_3 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 6] << 16;
1937 *dst_addr_3 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 7] << 24;
1938
1939 *dst_addr_4 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET];
1940 *dst_addr_4 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 1] << 8;
1941 *dst_addr_4 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 2] << 16;
1942 *dst_addr_4 = input->byte_stream[IXGBE_ATR_DST_IPV6_OFFSET + 3] << 24;
1943
1944 return 0;
1945}
1946
1947/**
1948 * ixgbe_atr_get_src_port_82599 - Gets the source port
1949 * @input: input stream to modify
1950 * @src_port: the source port to load
1951 *
1952 * Even though the input is given in big-endian, the FDIRPORT registers
1953 * expect the ports to be programmed in little-endian. Hence the need to swap
1954 * endianness when retrieving the data. This can be confusing since the
1955 * internal hash engine expects it to be big-endian.
1956 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001957static s32 ixgbe_atr_get_src_port_82599(struct ixgbe_atr_input *input,
1958 u16 *src_port)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001959{
1960 *src_port = input->byte_stream[IXGBE_ATR_SRC_PORT_OFFSET] << 8;
1961 *src_port |= input->byte_stream[IXGBE_ATR_SRC_PORT_OFFSET + 1];
1962
1963 return 0;
1964}
1965
1966/**
1967 * ixgbe_atr_get_dst_port_82599 - Gets the destination port
1968 * @input: input stream to modify
1969 * @dst_port: the destination port to load
1970 *
1971 * Even though the input is given in big-endian, the FDIRPORT registers
1972 * expect the ports to be programmed in little-endian. Hence the need to swap
1973 * endianness when retrieving the data. This can be confusing since the
1974 * internal hash engine expects it to be big-endian.
1975 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001976static s32 ixgbe_atr_get_dst_port_82599(struct ixgbe_atr_input *input,
1977 u16 *dst_port)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001978{
1979 *dst_port = input->byte_stream[IXGBE_ATR_DST_PORT_OFFSET] << 8;
1980 *dst_port |= input->byte_stream[IXGBE_ATR_DST_PORT_OFFSET + 1];
1981
1982 return 0;
1983}
1984
1985/**
1986 * ixgbe_atr_get_flex_byte_82599 - Gets the flexible bytes
1987 * @input: input stream to modify
1988 * @flex_bytes: the flexible bytes to load
1989 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00001990static s32 ixgbe_atr_get_flex_byte_82599(struct ixgbe_atr_input *input,
1991 u16 *flex_byte)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00001992{
1993 *flex_byte = input->byte_stream[IXGBE_ATR_FLEX_BYTE_OFFSET];
1994 *flex_byte |= input->byte_stream[IXGBE_ATR_FLEX_BYTE_OFFSET + 1] << 8;
1995
1996 return 0;
1997}
1998
1999/**
2000 * ixgbe_atr_get_vm_pool_82599 - Gets the Virtual Machine pool
2001 * @input: input stream to modify
2002 * @vm_pool: the Virtual Machine pool to load
2003 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002004s32 ixgbe_atr_get_vm_pool_82599(struct ixgbe_atr_input *input,
2005 u8 *vm_pool)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00002006{
2007 *vm_pool = input->byte_stream[IXGBE_ATR_VM_POOL_OFFSET];
2008
2009 return 0;
2010}
2011
2012/**
2013 * ixgbe_atr_get_l4type_82599 - Gets the layer 4 packet type
2014 * @input: input stream to modify
2015 * @l4type: the layer 4 type value to load
2016 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002017static s32 ixgbe_atr_get_l4type_82599(struct ixgbe_atr_input *input,
2018 u8 *l4type)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00002019{
2020 *l4type = input->byte_stream[IXGBE_ATR_L4TYPE_OFFSET];
2021
2022 return 0;
2023}
2024
2025/**
2026 * ixgbe_atr_add_signature_filter_82599 - Adds a signature hash filter
2027 * @hw: pointer to hardware structure
2028 * @stream: input bitstream
2029 * @queue: queue index to direct traffic to
2030 **/
2031s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
2032 struct ixgbe_atr_input *input,
2033 u8 queue)
2034{
2035 u64 fdirhashcmd;
2036 u64 fdircmd;
2037 u32 fdirhash;
2038 u16 bucket_hash, sig_hash;
2039 u8 l4type;
2040
2041 bucket_hash = ixgbe_atr_compute_hash_82599(input,
2042 IXGBE_ATR_BUCKET_HASH_KEY);
2043
2044 /* bucket_hash is only 15 bits */
2045 bucket_hash &= IXGBE_ATR_HASH_MASK;
2046
2047 sig_hash = ixgbe_atr_compute_hash_82599(input,
2048 IXGBE_ATR_SIGNATURE_HASH_KEY);
2049
2050 /* Get the l4type in order to program FDIRCMD properly */
2051 /* lowest 2 bits are FDIRCMD.L4TYPE, third lowest bit is FDIRCMD.IPV6 */
2052 ixgbe_atr_get_l4type_82599(input, &l4type);
2053
2054 /*
2055 * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits
2056 * is for FDIRCMD. Then do a 64-bit register write from FDIRHASH.
2057 */
2058 fdirhash = sig_hash << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT | bucket_hash;
2059
2060 fdircmd = (IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE |
2061 IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN);
2062
2063 switch (l4type & IXGBE_ATR_L4TYPE_MASK) {
2064 case IXGBE_ATR_L4TYPE_TCP:
2065 fdircmd |= IXGBE_FDIRCMD_L4TYPE_TCP;
2066 break;
2067 case IXGBE_ATR_L4TYPE_UDP:
2068 fdircmd |= IXGBE_FDIRCMD_L4TYPE_UDP;
2069 break;
2070 case IXGBE_ATR_L4TYPE_SCTP:
2071 fdircmd |= IXGBE_FDIRCMD_L4TYPE_SCTP;
2072 break;
2073 default:
2074 hw_dbg(hw, "Error on l4type input\n");
2075 return IXGBE_ERR_CONFIG;
2076 }
2077
2078 if (l4type & IXGBE_ATR_L4TYPE_IPV6_MASK)
2079 fdircmd |= IXGBE_FDIRCMD_IPV6;
2080
2081 fdircmd |= ((u64)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT);
2082 fdirhashcmd = ((fdircmd << 32) | fdirhash);
2083
2084 IXGBE_WRITE_REG64(hw, IXGBE_FDIRHASH, fdirhashcmd);
2085
2086 return 0;
2087}
2088
2089/**
2090 * ixgbe_fdir_add_perfect_filter_82599 - Adds a perfect filter
2091 * @hw: pointer to hardware structure
2092 * @input: input bitstream
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00002093 * @input_masks: bitwise masks for relevant fields
2094 * @soft_id: software index into the silicon hash tables for filter storage
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00002095 * @queue: queue index to direct traffic to
2096 *
2097 * Note that the caller to this function must lock before calling, since the
2098 * hardware writes must be protected from one another.
2099 **/
2100s32 ixgbe_fdir_add_perfect_filter_82599(struct ixgbe_hw *hw,
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00002101 struct ixgbe_atr_input *input,
2102 struct ixgbe_atr_input_masks *input_masks,
2103 u16 soft_id, u8 queue)
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00002104{
2105 u32 fdircmd = 0;
2106 u32 fdirhash;
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00002107 u32 src_ipv4 = 0, dst_ipv4 = 0;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00002108 u32 src_ipv6_1, src_ipv6_2, src_ipv6_3, src_ipv6_4;
2109 u16 src_port, dst_port, vlan_id, flex_bytes;
2110 u16 bucket_hash;
2111 u8 l4type;
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00002112 u8 fdirm = 0;
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00002113
2114 /* Get our input values */
2115 ixgbe_atr_get_l4type_82599(input, &l4type);
2116
2117 /*
2118 * Check l4type formatting, and bail out before we touch the hardware
2119 * if there's a configuration issue
2120 */
2121 switch (l4type & IXGBE_ATR_L4TYPE_MASK) {
2122 case IXGBE_ATR_L4TYPE_TCP:
2123 fdircmd |= IXGBE_FDIRCMD_L4TYPE_TCP;
2124 break;
2125 case IXGBE_ATR_L4TYPE_UDP:
2126 fdircmd |= IXGBE_FDIRCMD_L4TYPE_UDP;
2127 break;
2128 case IXGBE_ATR_L4TYPE_SCTP:
2129 fdircmd |= IXGBE_FDIRCMD_L4TYPE_SCTP;
2130 break;
2131 default:
2132 hw_dbg(hw, "Error on l4type input\n");
2133 return IXGBE_ERR_CONFIG;
2134 }
2135
2136 bucket_hash = ixgbe_atr_compute_hash_82599(input,
2137 IXGBE_ATR_BUCKET_HASH_KEY);
2138
2139 /* bucket_hash is only 15 bits */
2140 bucket_hash &= IXGBE_ATR_HASH_MASK;
2141
2142 ixgbe_atr_get_vlan_id_82599(input, &vlan_id);
2143 ixgbe_atr_get_src_port_82599(input, &src_port);
2144 ixgbe_atr_get_dst_port_82599(input, &dst_port);
2145 ixgbe_atr_get_flex_byte_82599(input, &flex_bytes);
2146
2147 fdirhash = soft_id << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT | bucket_hash;
2148
2149 /* Now figure out if we're IPv4 or IPv6 */
2150 if (l4type & IXGBE_ATR_L4TYPE_IPV6_MASK) {
2151 /* IPv6 */
2152 ixgbe_atr_get_src_ipv6_82599(input, &src_ipv6_1, &src_ipv6_2,
2153 &src_ipv6_3, &src_ipv6_4);
2154
2155 IXGBE_WRITE_REG(hw, IXGBE_FDIRSIPv6(0), src_ipv6_1);
2156 IXGBE_WRITE_REG(hw, IXGBE_FDIRSIPv6(1), src_ipv6_2);
2157 IXGBE_WRITE_REG(hw, IXGBE_FDIRSIPv6(2), src_ipv6_3);
2158 /* The last 4 bytes is the same register as IPv4 */
2159 IXGBE_WRITE_REG(hw, IXGBE_FDIRIPSA, src_ipv6_4);
2160
2161 fdircmd |= IXGBE_FDIRCMD_IPV6;
2162 fdircmd |= IXGBE_FDIRCMD_IPv6DMATCH;
2163 } else {
2164 /* IPv4 */
2165 ixgbe_atr_get_src_ipv4_82599(input, &src_ipv4);
2166 IXGBE_WRITE_REG(hw, IXGBE_FDIRIPSA, src_ipv4);
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00002167 }
2168
2169 ixgbe_atr_get_dst_ipv4_82599(input, &dst_ipv4);
2170 IXGBE_WRITE_REG(hw, IXGBE_FDIRIPDA, dst_ipv4);
2171
2172 IXGBE_WRITE_REG(hw, IXGBE_FDIRVLAN, (vlan_id |
2173 (flex_bytes << IXGBE_FDIRVLAN_FLEX_SHIFT)));
2174 IXGBE_WRITE_REG(hw, IXGBE_FDIRPORT, (src_port |
Peter Waskiewicz9a713e72010-02-10 16:07:54 +00002175 (dst_port << IXGBE_FDIRPORT_DESTINATION_SHIFT)));
2176
2177 /*
2178 * Program the relevant mask registers. If src/dst_port or src/dst_addr
2179 * are zero, then assume a full mask for that field. Also assume that
2180 * a VLAN of 0 is unspecified, so mask that out as well. L4type
2181 * cannot be masked out in this implementation.
2182 *
2183 * This also assumes IPv4 only. IPv6 masking isn't supported at this
2184 * point in time.
2185 */
2186 if (src_ipv4 == 0)
2187 IXGBE_WRITE_REG(hw, IXGBE_FDIRSIP4M, 0xffffffff);
2188 else
2189 IXGBE_WRITE_REG(hw, IXGBE_FDIRSIP4M, input_masks->src_ip_mask);
2190
2191 if (dst_ipv4 == 0)
2192 IXGBE_WRITE_REG(hw, IXGBE_FDIRDIP4M, 0xffffffff);
2193 else
2194 IXGBE_WRITE_REG(hw, IXGBE_FDIRDIP4M, input_masks->dst_ip_mask);
2195
2196 switch (l4type & IXGBE_ATR_L4TYPE_MASK) {
2197 case IXGBE_ATR_L4TYPE_TCP:
2198 if (src_port == 0)
2199 IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, 0xffff);
2200 else
2201 IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM,
2202 input_masks->src_port_mask);
2203
2204 if (dst_port == 0)
2205 IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM,
2206 (IXGBE_READ_REG(hw, IXGBE_FDIRTCPM) |
2207 (0xffff << 16)));
2208 else
2209 IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM,
2210 (IXGBE_READ_REG(hw, IXGBE_FDIRTCPM) |
2211 (input_masks->dst_port_mask << 16)));
2212 break;
2213 case IXGBE_ATR_L4TYPE_UDP:
2214 if (src_port == 0)
2215 IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, 0xffff);
2216 else
2217 IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM,
2218 input_masks->src_port_mask);
2219
2220 if (dst_port == 0)
2221 IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM,
2222 (IXGBE_READ_REG(hw, IXGBE_FDIRUDPM) |
2223 (0xffff << 16)));
2224 else
2225 IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM,
2226 (IXGBE_READ_REG(hw, IXGBE_FDIRUDPM) |
2227 (input_masks->src_port_mask << 16)));
2228 break;
2229 default:
2230 /* this already would have failed above */
2231 break;
2232 }
2233
2234 /* Program the last mask register, FDIRM */
2235 if (input_masks->vlan_id_mask || !vlan_id)
2236 /* Mask both VLAN and VLANP - bits 0 and 1 */
2237 fdirm |= 0x3;
2238
2239 if (input_masks->data_mask || !flex_bytes)
2240 /* Flex bytes need masking, so mask the whole thing - bit 4 */
2241 fdirm |= 0x10;
2242
2243 /* Now mask VM pool and destination IPv6 - bits 5 and 2 */
2244 fdirm |= 0x24;
2245
2246 IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
Peter P Waskiewicz Jrffff4772009-06-04 16:01:25 +00002247
2248 fdircmd |= IXGBE_FDIRCMD_CMD_ADD_FLOW;
2249 fdircmd |= IXGBE_FDIRCMD_FILTER_UPDATE;
2250 fdircmd |= IXGBE_FDIRCMD_LAST;
2251 fdircmd |= IXGBE_FDIRCMD_QUEUE_EN;
2252 fdircmd |= queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
2253
2254 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
2255 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd);
2256
2257 return 0;
2258}
2259/**
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002260 * ixgbe_read_analog_reg8_82599 - Reads 8 bit Omer analog register
2261 * @hw: pointer to hardware structure
2262 * @reg: analog register to read
2263 * @val: read value
2264 *
2265 * Performs read operation to Omer analog register specified.
2266 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002267static s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002268{
2269 u32 core_ctl;
2270
2271 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, IXGBE_CORECTL_WRITE_CMD |
2272 (reg << 8));
2273 IXGBE_WRITE_FLUSH(hw);
2274 udelay(10);
2275 core_ctl = IXGBE_READ_REG(hw, IXGBE_CORECTL);
2276 *val = (u8)core_ctl;
2277
2278 return 0;
2279}
2280
2281/**
2282 * ixgbe_write_analog_reg8_82599 - Writes 8 bit Omer analog register
2283 * @hw: pointer to hardware structure
2284 * @reg: atlas register to write
2285 * @val: value to write
2286 *
2287 * Performs write operation to Omer analog register specified.
2288 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002289static s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002290{
2291 u32 core_ctl;
2292
2293 core_ctl = (reg << 8) | val;
2294 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, core_ctl);
2295 IXGBE_WRITE_FLUSH(hw);
2296 udelay(10);
2297
2298 return 0;
2299}
2300
2301/**
2302 * ixgbe_start_hw_82599 - Prepare hardware for Tx/Rx
2303 * @hw: pointer to hardware structure
2304 *
2305 * Starts the hardware using the generic start_hw function.
2306 * Then performs device-specific:
2307 * Clears the rate limiter registers.
2308 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002309static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002310{
2311 u32 q_num;
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +00002312 s32 ret_val;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002313
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +00002314 ret_val = ixgbe_start_hw_generic(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002315
2316 /* Clear the rate limiters */
2317 for (q_num = 0; q_num < hw->mac.max_tx_queues; q_num++) {
2318 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, q_num);
2319 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, 0);
2320 }
2321 IXGBE_WRITE_FLUSH(hw);
2322
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +00002323 /* We need to run link autotry after the driver loads */
2324 hw->mac.autotry_restart = true;
2325
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +00002326 if (ret_val == 0)
2327 ret_val = ixgbe_verify_fw_version_82599(hw);
2328
2329 return ret_val;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002330}
2331
2332/**
2333 * ixgbe_identify_phy_82599 - Get physical layer module
2334 * @hw: pointer to hardware structure
2335 *
2336 * Determines the physical layer module found on the current adapter.
2337 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002338static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002339{
2340 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
2341 status = ixgbe_identify_phy_generic(hw);
2342 if (status != 0)
2343 status = ixgbe_identify_sfp_module_generic(hw);
2344 return status;
2345}
2346
2347/**
2348 * ixgbe_get_supported_physical_layer_82599 - Returns physical layer type
2349 * @hw: pointer to hardware structure
2350 *
2351 * Determines physical layer capabilities of the current configuration.
2352 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002353static u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002354{
2355 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002356 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2357 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
2358 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
2359 u32 pma_pmd_10g_parallel = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
2360 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
2361 u16 ext_ability = 0;
PJ Waskiewicz1339b9e2009-03-13 22:12:29 +00002362 u8 comp_codes_10g = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002363
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002364 hw->phy.ops.identify(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002365
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002366 if (hw->phy.type == ixgbe_phy_tn ||
2367 hw->phy.type == ixgbe_phy_cu_unknown) {
Ben Hutchings6b73e102009-04-29 08:08:58 +00002368 hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
2369 &ext_ability);
2370 if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002371 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
Ben Hutchings6b73e102009-04-29 08:08:58 +00002372 if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002373 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
Ben Hutchings6b73e102009-04-29 08:08:58 +00002374 if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002375 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
2376 goto out;
2377 }
2378
2379 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
2380 case IXGBE_AUTOC_LMS_1G_AN:
2381 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
2382 if (pma_pmd_1g == IXGBE_AUTOC_1G_KX_BX) {
2383 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
2384 IXGBE_PHYSICAL_LAYER_1000BASE_BX;
2385 goto out;
2386 } else
2387 /* SFI mode so read SFP module */
2388 goto sfp_check;
2389 break;
2390 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
2391 if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_CX4)
2392 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
2393 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_KX4)
2394 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
Peter P Waskiewicz Jr1fcf03e2009-05-17 20:58:04 +00002395 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_XAUI)
2396 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_XAUI;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002397 goto out;
2398 break;
2399 case IXGBE_AUTOC_LMS_10G_SERIAL:
2400 if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_KR) {
2401 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR;
2402 goto out;
2403 } else if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)
2404 goto sfp_check;
2405 break;
2406 case IXGBE_AUTOC_LMS_KX4_KX_KR:
2407 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
2408 if (autoc & IXGBE_AUTOC_KX_SUPP)
2409 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2410 if (autoc & IXGBE_AUTOC_KX4_SUPP)
2411 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
2412 if (autoc & IXGBE_AUTOC_KR_SUPP)
2413 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KR;
2414 goto out;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002415 break;
2416 default:
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002417 goto out;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002418 break;
2419 }
2420
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002421sfp_check:
2422 /* SFP check must be done last since DA modules are sometimes used to
2423 * test KR mode - we need to id KR mode correctly before SFP module.
2424 * Call identify_sfp because the pluggable module may have changed */
2425 hw->phy.ops.identify_sfp(hw);
2426 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
2427 goto out;
2428
2429 switch (hw->phy.type) {
2430 case ixgbe_phy_tw_tyco:
2431 case ixgbe_phy_tw_unknown:
2432 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
2433 break;
2434 case ixgbe_phy_sfp_avago:
2435 case ixgbe_phy_sfp_ftl:
2436 case ixgbe_phy_sfp_intel:
2437 case ixgbe_phy_sfp_unknown:
2438 hw->phy.ops.read_i2c_eeprom(hw,
2439 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
2440 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
2441 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
2442 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
2443 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
2444 break;
2445 default:
2446 break;
2447 }
2448
2449out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002450 return physical_layer;
2451}
2452
2453/**
2454 * ixgbe_enable_rx_dma_82599 - Enable the Rx DMA unit on 82599
2455 * @hw: pointer to hardware structure
2456 * @regval: register value to write to RXCTRL
2457 *
2458 * Enables the Rx DMA unit for 82599
2459 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002460static s32 ixgbe_enable_rx_dma_82599(struct ixgbe_hw *hw, u32 regval)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002461{
2462#define IXGBE_MAX_SECRX_POLL 30
2463 int i;
2464 int secrxreg;
2465
2466 /*
2467 * Workaround for 82599 silicon errata when enabling the Rx datapath.
2468 * If traffic is incoming before we enable the Rx unit, it could hang
2469 * the Rx DMA unit. Therefore, make sure the security engine is
2470 * completely disabled prior to enabling the Rx unit.
2471 */
2472 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
2473 secrxreg |= IXGBE_SECRXCTRL_RX_DIS;
2474 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg);
2475 for (i = 0; i < IXGBE_MAX_SECRX_POLL; i++) {
2476 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT);
2477 if (secrxreg & IXGBE_SECRXSTAT_SECRX_RDY)
2478 break;
2479 else
2480 udelay(10);
2481 }
2482
2483 /* For informational purposes only */
2484 if (i >= IXGBE_MAX_SECRX_POLL)
2485 hw_dbg(hw, "Rx unit being enabled before security "
2486 "path fully disabled. Continuing with init.\n");
2487
2488 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval);
2489 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
2490 secrxreg &= ~IXGBE_SECRXCTRL_RX_DIS;
2491 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg);
2492 IXGBE_WRITE_FLUSH(hw);
2493
2494 return 0;
2495}
2496
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002497/**
2498 * ixgbe_get_device_caps_82599 - Get additional device capabilities
2499 * @hw: pointer to hardware structure
2500 * @device_caps: the EEPROM word with the extra device capabilities
2501 *
2502 * This function will read the EEPROM location for the device capabilities,
2503 * and return the word through device_caps.
2504 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002505static s32 ixgbe_get_device_caps_82599(struct ixgbe_hw *hw, u16 *device_caps)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002506{
2507 hw->eeprom.ops.read(hw, IXGBE_DEVICE_CAPS, device_caps);
2508
2509 return 0;
2510}
2511
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +00002512/**
2513 * ixgbe_get_san_mac_addr_offset_82599 - SAN MAC address offset for 82599
2514 * @hw: pointer to hardware structure
2515 * @san_mac_offset: SAN MAC address offset
2516 *
2517 * This function will read the EEPROM location for the SAN MAC address
2518 * pointer, and returns the value at that location. This is used in both
2519 * get and set mac_addr routines.
2520 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002521static s32 ixgbe_get_san_mac_addr_offset_82599(struct ixgbe_hw *hw,
2522 u16 *san_mac_offset)
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +00002523{
2524 /*
2525 * First read the EEPROM pointer to see if the MAC addresses are
2526 * available.
2527 */
2528 hw->eeprom.ops.read(hw, IXGBE_SAN_MAC_ADDR_PTR, san_mac_offset);
2529
2530 return 0;
2531}
2532
2533/**
2534 * ixgbe_get_san_mac_addr_82599 - SAN MAC address retrieval for 82599
2535 * @hw: pointer to hardware structure
2536 * @san_mac_addr: SAN MAC address
2537 *
2538 * Reads the SAN MAC address from the EEPROM, if it's available. This is
2539 * per-port, so set_lan_id() must be called before reading the addresses.
2540 * set_lan_id() is called by identify_sfp(), but this cannot be relied
2541 * upon for non-SFP connections, so we must call it here.
2542 **/
Don Skidmore7b25cdb2009-08-25 04:47:32 +00002543static s32 ixgbe_get_san_mac_addr_82599(struct ixgbe_hw *hw, u8 *san_mac_addr)
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +00002544{
2545 u16 san_mac_data, san_mac_offset;
2546 u8 i;
2547
2548 /*
2549 * First read the EEPROM pointer to see if the MAC addresses are
2550 * available. If they're not, no point in calling set_lan_id() here.
2551 */
2552 ixgbe_get_san_mac_addr_offset_82599(hw, &san_mac_offset);
2553
2554 if ((san_mac_offset == 0) || (san_mac_offset == 0xFFFF)) {
2555 /*
2556 * No addresses available in this EEPROM. It's not an
2557 * error though, so just wipe the local address and return.
2558 */
2559 for (i = 0; i < 6; i++)
2560 san_mac_addr[i] = 0xFF;
2561
2562 goto san_mac_addr_out;
2563 }
2564
2565 /* make sure we know which port we need to program */
2566 hw->mac.ops.set_lan_id(hw);
2567 /* apply the port offset to the address offset */
2568 (hw->bus.func) ? (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT1_OFFSET) :
2569 (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT0_OFFSET);
2570 for (i = 0; i < 3; i++) {
2571 hw->eeprom.ops.read(hw, san_mac_offset, &san_mac_data);
2572 san_mac_addr[i * 2] = (u8)(san_mac_data);
2573 san_mac_addr[i * 2 + 1] = (u8)(san_mac_data >> 8);
2574 san_mac_offset++;
2575 }
2576
2577san_mac_addr_out:
2578 return 0;
2579}
2580
Peter P Waskiewicz Jr794caeb2009-06-04 16:02:24 +00002581/**
2582 * ixgbe_verify_fw_version_82599 - verify fw version for 82599
2583 * @hw: pointer to hardware structure
2584 *
2585 * Verifies that installed the firmware version is 0.6 or higher
2586 * for SFI devices. All 82599 SFI devices should have version 0.6 or higher.
2587 *
2588 * Returns IXGBE_ERR_EEPROM_VERSION if the FW is not present or
2589 * if the FW version is not supported.
2590 **/
2591static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw)
2592{
2593 s32 status = IXGBE_ERR_EEPROM_VERSION;
2594 u16 fw_offset, fw_ptp_cfg_offset;
2595 u16 fw_version = 0;
2596
2597 /* firmware check is only necessary for SFI devices */
2598 if (hw->phy.media_type != ixgbe_media_type_fiber) {
2599 status = 0;
2600 goto fw_version_out;
2601 }
2602
2603 /* get the offset to the Firmware Module block */
2604 hw->eeprom.ops.read(hw, IXGBE_FW_PTR, &fw_offset);
2605
2606 if ((fw_offset == 0) || (fw_offset == 0xFFFF))
2607 goto fw_version_out;
2608
2609 /* get the offset to the Pass Through Patch Configuration block */
2610 hw->eeprom.ops.read(hw, (fw_offset +
2611 IXGBE_FW_PASSTHROUGH_PATCH_CONFIG_PTR),
2612 &fw_ptp_cfg_offset);
2613
2614 if ((fw_ptp_cfg_offset == 0) || (fw_ptp_cfg_offset == 0xFFFF))
2615 goto fw_version_out;
2616
2617 /* get the firmware version */
2618 hw->eeprom.ops.read(hw, (fw_ptp_cfg_offset +
2619 IXGBE_FW_PATCH_VERSION_4),
2620 &fw_version);
2621
2622 if (fw_version > 0x5)
2623 status = 0;
2624
2625fw_version_out:
2626 return status;
2627}
2628
Yi Zou383ff342009-10-28 18:23:57 +00002629/**
2630 * ixgbe_get_wwn_prefix_82599 - Get alternative WWNN/WWPN prefix from
2631 * the EEPROM
2632 * @hw: pointer to hardware structure
2633 * @wwnn_prefix: the alternative WWNN prefix
2634 * @wwpn_prefix: the alternative WWPN prefix
2635 *
2636 * This function will read the EEPROM from the alternative SAN MAC address
2637 * block to check the support for the alternative WWNN/WWPN prefix support.
2638 **/
2639static s32 ixgbe_get_wwn_prefix_82599(struct ixgbe_hw *hw, u16 *wwnn_prefix,
2640 u16 *wwpn_prefix)
2641{
2642 u16 offset, caps;
2643 u16 alt_san_mac_blk_offset;
2644
2645 /* clear output first */
2646 *wwnn_prefix = 0xFFFF;
2647 *wwpn_prefix = 0xFFFF;
2648
2649 /* check if alternative SAN MAC is supported */
2650 hw->eeprom.ops.read(hw, IXGBE_ALT_SAN_MAC_ADDR_BLK_PTR,
2651 &alt_san_mac_blk_offset);
2652
2653 if ((alt_san_mac_blk_offset == 0) ||
2654 (alt_san_mac_blk_offset == 0xFFFF))
2655 goto wwn_prefix_out;
2656
2657 /* check capability in alternative san mac address block */
2658 offset = alt_san_mac_blk_offset + IXGBE_ALT_SAN_MAC_ADDR_CAPS_OFFSET;
2659 hw->eeprom.ops.read(hw, offset, &caps);
2660 if (!(caps & IXGBE_ALT_SAN_MAC_ADDR_CAPS_ALTWWN))
2661 goto wwn_prefix_out;
2662
2663 /* get the corresponding prefix for WWNN/WWPN */
2664 offset = alt_san_mac_blk_offset + IXGBE_ALT_SAN_MAC_ADDR_WWNN_OFFSET;
2665 hw->eeprom.ops.read(hw, offset, wwnn_prefix);
2666
2667 offset = alt_san_mac_blk_offset + IXGBE_ALT_SAN_MAC_ADDR_WWPN_OFFSET;
2668 hw->eeprom.ops.read(hw, offset, wwpn_prefix);
2669
2670wwn_prefix_out:
2671 return 0;
2672}
2673
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002674static struct ixgbe_mac_operations mac_ops_82599 = {
2675 .init_hw = &ixgbe_init_hw_generic,
2676 .reset_hw = &ixgbe_reset_hw_82599,
2677 .start_hw = &ixgbe_start_hw_82599,
2678 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
2679 .get_media_type = &ixgbe_get_media_type_82599,
2680 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82599,
2681 .enable_rx_dma = &ixgbe_enable_rx_dma_82599,
2682 .get_mac_addr = &ixgbe_get_mac_addr_generic,
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +00002683 .get_san_mac_addr = &ixgbe_get_san_mac_addr_82599,
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00002684 .get_device_caps = &ixgbe_get_device_caps_82599,
Yi Zou383ff342009-10-28 18:23:57 +00002685 .get_wwn_prefix = &ixgbe_get_wwn_prefix_82599,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002686 .stop_adapter = &ixgbe_stop_adapter_generic,
2687 .get_bus_info = &ixgbe_get_bus_info_generic,
2688 .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie,
2689 .read_analog_reg8 = &ixgbe_read_analog_reg8_82599,
2690 .write_analog_reg8 = &ixgbe_write_analog_reg8_82599,
2691 .setup_link = &ixgbe_setup_mac_link_82599,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002692 .check_link = &ixgbe_check_mac_link_82599,
2693 .get_link_capabilities = &ixgbe_get_link_capabilities_82599,
2694 .led_on = &ixgbe_led_on_generic,
2695 .led_off = &ixgbe_led_off_generic,
PJ Waskiewicz87c12012009-04-08 13:20:31 +00002696 .blink_led_start = &ixgbe_blink_led_start_generic,
2697 .blink_led_stop = &ixgbe_blink_led_stop_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002698 .set_rar = &ixgbe_set_rar_generic,
2699 .clear_rar = &ixgbe_clear_rar_generic,
2700 .set_vmdq = &ixgbe_set_vmdq_82599,
2701 .clear_vmdq = &ixgbe_clear_vmdq_82599,
2702 .init_rx_addrs = &ixgbe_init_rx_addrs_generic,
2703 .update_uc_addr_list = &ixgbe_update_uc_addr_list_generic,
2704 .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,
2705 .enable_mc = &ixgbe_enable_mc_generic,
2706 .disable_mc = &ixgbe_disable_mc_generic,
2707 .clear_vfta = &ixgbe_clear_vfta_82599,
2708 .set_vfta = &ixgbe_set_vfta_82599,
Mallikarjuna R Chilakala620fa032009-06-04 11:11:13 +00002709 .fc_enable = &ixgbe_fc_enable_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002710 .init_uta_tables = &ixgbe_init_uta_tables_82599,
2711 .setup_sfp = &ixgbe_setup_sfp_modules_82599,
2712};
2713
2714static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
2715 .init_params = &ixgbe_init_eeprom_params_generic,
2716 .read = &ixgbe_read_eeprom_generic,
2717 .write = &ixgbe_write_eeprom_generic,
2718 .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
2719 .update_checksum = &ixgbe_update_eeprom_checksum_generic,
2720};
2721
2722static struct ixgbe_phy_operations phy_ops_82599 = {
2723 .identify = &ixgbe_identify_phy_82599,
2724 .identify_sfp = &ixgbe_identify_sfp_module_generic,
PJ Waskiewicz04f165e2009-04-09 22:27:57 +00002725 .init = &ixgbe_init_phy_ops_82599,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002726 .reset = &ixgbe_reset_phy_generic,
2727 .read_reg = &ixgbe_read_phy_reg_generic,
2728 .write_reg = &ixgbe_write_phy_reg_generic,
2729 .setup_link = &ixgbe_setup_phy_link_generic,
2730 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
2731 .read_i2c_byte = &ixgbe_read_i2c_byte_generic,
2732 .write_i2c_byte = &ixgbe_write_i2c_byte_generic,
2733 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic,
2734 .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic,
2735};
2736
2737struct ixgbe_info ixgbe_82599_info = {
2738 .mac = ixgbe_mac_82599EB,
2739 .get_invariants = &ixgbe_get_invariants_82599,
2740 .mac_ops = &mac_ops_82599,
2741 .eeprom_ops = &eeprom_ops_82599,
2742 .phy_ops = &phy_ops_82599,
Greg Rose096a58f2010-01-09 02:26:26 +00002743 .mbx_ops = &mbx_ops_82599,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00002744};