blob: 4d83e59165930ce3d6021018f634eab790d53b42 [file] [log] [blame]
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001/*******************************************************************************
2
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2009 Intel Corporation.
5
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"
34
35#define IXGBE_82599_MAX_TX_QUEUES 128
36#define IXGBE_82599_MAX_RX_QUEUES 128
37#define IXGBE_82599_RAR_ENTRIES 128
38#define IXGBE_82599_MC_TBL_SIZE 128
39#define IXGBE_82599_VFT_TBL_SIZE 128
40
41s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
42 ixgbe_link_speed *speed,
43 bool *autoneg);
44enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw);
45s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw);
46s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw,
47 ixgbe_link_speed speed, bool autoneg,
48 bool autoneg_wait_to_complete);
49s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw);
50s32 ixgbe_check_mac_link_82599(struct ixgbe_hw *hw,
51 ixgbe_link_speed *speed,
52 bool *link_up, bool link_up_wait_to_complete);
53s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
54 ixgbe_link_speed speed,
55 bool autoneg,
56 bool autoneg_wait_to_complete);
57static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw,
58 ixgbe_link_speed *speed,
59 bool *autoneg);
60static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw);
61static s32 ixgbe_setup_copper_link_speed_82599(struct ixgbe_hw *hw,
62 ixgbe_link_speed speed,
63 bool autoneg,
64 bool autoneg_wait_to_complete);
65s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw);
66s32 ixgbe_set_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
67s32 ixgbe_clear_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
68s32 ixgbe_set_vfta_82599(struct ixgbe_hw *hw, u32 vlan,
69 u32 vind, bool vlan_on);
70s32 ixgbe_clear_vfta_82599(struct ixgbe_hw *hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +000071s32 ixgbe_init_uta_tables_82599(struct ixgbe_hw *hw);
72s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val);
73s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val);
74s32 ixgbe_start_hw_rev_0_82599(struct ixgbe_hw *hw);
75s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw);
76s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw);
77u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw);
78
79void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
80{
81 struct ixgbe_mac_info *mac = &hw->mac;
82 if (hw->phy.multispeed_fiber) {
83 /* Set up dual speed SFP+ support */
84 mac->ops.setup_link =
85 &ixgbe_setup_mac_link_multispeed_fiber;
86 mac->ops.setup_link_speed =
87 &ixgbe_setup_mac_link_speed_multispeed_fiber;
88 } else {
89 mac->ops.setup_link =
90 &ixgbe_setup_mac_link_82599;
91 mac->ops.setup_link_speed =
92 &ixgbe_setup_mac_link_speed_82599;
93 }
94}
95
96s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
97{
98 s32 ret_val = 0;
99 u16 list_offset, data_offset, data_value;
100
101 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
102 ixgbe_init_mac_link_ops_82599(hw);
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000103
104 hw->phy.ops.reset = NULL;
105
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000106 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
107 &data_offset);
108
109 if (ret_val != 0)
110 goto setup_sfp_out;
111
Peter P Waskiewicz Jraa5aec82009-05-19 09:18:34 +0000112 /* PHY config will finish before releasing the semaphore */
113 ret_val = ixgbe_acquire_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
114 if (ret_val != 0) {
115 ret_val = IXGBE_ERR_SWFW_SYNC;
116 goto setup_sfp_out;
117 }
118
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000119 hw->eeprom.ops.read(hw, ++data_offset, &data_value);
120 while (data_value != 0xffff) {
121 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, data_value);
122 IXGBE_WRITE_FLUSH(hw);
123 hw->eeprom.ops.read(hw, ++data_offset, &data_value);
124 }
Peter P Waskiewicz Jr1479ad42009-06-04 11:10:17 +0000125 /* Now restart DSP by setting Restart_AN */
126 IXGBE_WRITE_REG(hw, IXGBE_AUTOC,
127 (IXGBE_READ_REG(hw, IXGBE_AUTOC) | IXGBE_AUTOC_AN_RESTART));
Peter P Waskiewicz Jraa5aec82009-05-19 09:18:34 +0000128
129 /* Release the semaphore */
130 ixgbe_release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
131 /* Delay obtaining semaphore again to allow FW access */
132 msleep(hw->eeprom.semaphore_delay);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000133 }
134
135setup_sfp_out:
136 return ret_val;
137}
138
139/**
140 * ixgbe_get_pcie_msix_count_82599 - Gets MSI-X vector count
141 * @hw: pointer to hardware structure
142 *
143 * Read PCIe configuration space, and get the MSI-X vector count from
144 * the capabilities table.
145 **/
146u32 ixgbe_get_pcie_msix_count_82599(struct ixgbe_hw *hw)
147{
148 struct ixgbe_adapter *adapter = hw->back;
149 u16 msix_count;
150 pci_read_config_word(adapter->pdev, IXGBE_PCIE_MSIX_82599_CAPS,
151 &msix_count);
152 msix_count &= IXGBE_PCIE_MSIX_TBL_SZ_MASK;
153
154 /* MSI-X count is zero-based in HW, so increment to give proper value */
155 msix_count++;
156
157 return msix_count;
158}
159
160static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
161{
162 struct ixgbe_mac_info *mac = &hw->mac;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000163
164 ixgbe_init_mac_link_ops_82599(hw);
165
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000166 mac->mcft_size = IXGBE_82599_MC_TBL_SIZE;
167 mac->vft_size = IXGBE_82599_VFT_TBL_SIZE;
168 mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES;
169 mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES;
170 mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES;
171 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82599(hw);
172
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000173 return 0;
174}
175
176/**
177 * ixgbe_init_phy_ops_82599 - PHY/SFP specific init
178 * @hw: pointer to hardware structure
179 *
180 * Initialize any function pointers that were not able to be
181 * set during get_invariants because the PHY/SFP type was
182 * not known. Perform the SFP init if necessary.
183 *
184 **/
185s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
186{
187 struct ixgbe_mac_info *mac = &hw->mac;
188 struct ixgbe_phy_info *phy = &hw->phy;
189 s32 ret_val = 0;
190
191 /* Identify the PHY or SFP module */
192 ret_val = phy->ops.identify(hw);
193
194 /* Setup function pointers based on detected SFP module and speeds */
195 ixgbe_init_mac_link_ops_82599(hw);
196
197 /* If copper media, overwrite with copper function pointers */
198 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
199 mac->ops.setup_link = &ixgbe_setup_copper_link_82599;
200 mac->ops.setup_link_speed =
201 &ixgbe_setup_copper_link_speed_82599;
202 mac->ops.get_link_capabilities =
203 &ixgbe_get_copper_link_capabilities_82599;
204 }
205
206 /* Set necessary function pointers based on phy type */
207 switch (hw->phy.type) {
208 case ixgbe_phy_tn:
209 phy->ops.check_link = &ixgbe_check_phy_link_tnx;
210 phy->ops.get_firmware_version =
211 &ixgbe_get_phy_firmware_version_tnx;
212 break;
213 default:
214 break;
215 }
216
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000217 return ret_val;
218}
219
220/**
221 * ixgbe_get_link_capabilities_82599 - Determines link capabilities
222 * @hw: pointer to hardware structure
223 * @speed: pointer to link speed
224 * @negotiation: true when autoneg or autotry is enabled
225 *
226 * Determines the link capabilities by reading the AUTOC register.
227 **/
228s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
229 ixgbe_link_speed *speed,
230 bool *negotiation)
231{
232 s32 status = 0;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000233 u32 autoc = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000234
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000235 /*
236 * Determine link capabilities based on the stored value of AUTOC,
237 * which represents EEPROM defaults. If AUTOC value has not been
238 * stored, use the current register value.
239 */
240 if (hw->mac.orig_link_settings_stored)
241 autoc = hw->mac.orig_autoc;
242 else
243 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
244
245 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000246 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
247 *speed = IXGBE_LINK_SPEED_1GB_FULL;
248 *negotiation = false;
249 break;
250
251 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
252 *speed = IXGBE_LINK_SPEED_10GB_FULL;
253 *negotiation = false;
254 break;
255
256 case IXGBE_AUTOC_LMS_1G_AN:
257 *speed = IXGBE_LINK_SPEED_1GB_FULL;
258 *negotiation = true;
259 break;
260
261 case IXGBE_AUTOC_LMS_10G_SERIAL:
262 *speed = IXGBE_LINK_SPEED_10GB_FULL;
263 *negotiation = false;
264 break;
265
266 case IXGBE_AUTOC_LMS_KX4_KX_KR:
267 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
268 *speed = IXGBE_LINK_SPEED_UNKNOWN;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000269 if (autoc & IXGBE_AUTOC_KR_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000270 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000271 if (autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000272 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000273 if (autoc & IXGBE_AUTOC_KX_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000274 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
275 *negotiation = true;
276 break;
277
278 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
279 *speed = IXGBE_LINK_SPEED_100_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000280 if (autoc & IXGBE_AUTOC_KR_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000281 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000282 if (autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000283 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000284 if (autoc & IXGBE_AUTOC_KX_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000285 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
286 *negotiation = true;
287 break;
288
289 case IXGBE_AUTOC_LMS_SGMII_1G_100M:
290 *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
291 *negotiation = false;
292 break;
293
294 default:
295 status = IXGBE_ERR_LINK_SETUP;
296 goto out;
297 break;
298 }
299
300 if (hw->phy.multispeed_fiber) {
301 *speed |= IXGBE_LINK_SPEED_10GB_FULL |
302 IXGBE_LINK_SPEED_1GB_FULL;
303 *negotiation = true;
304 }
305
306out:
307 return status;
308}
309
310/**
311 * ixgbe_get_copper_link_capabilities_82599 - Determines link capabilities
312 * @hw: pointer to hardware structure
313 * @speed: pointer to link speed
314 * @autoneg: boolean auto-negotiation value
315 *
316 * Determines the link capabilities by reading the AUTOC register.
317 **/
318static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw,
319 ixgbe_link_speed *speed,
320 bool *autoneg)
321{
322 s32 status = IXGBE_ERR_LINK_SETUP;
323 u16 speed_ability;
324
325 *speed = 0;
326 *autoneg = true;
327
Ben Hutchings6b73e102009-04-29 08:08:58 +0000328 status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000329 &speed_ability);
330
331 if (status == 0) {
Ben Hutchings6b73e102009-04-29 08:08:58 +0000332 if (speed_ability & MDIO_SPEED_10G)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000333 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
Ben Hutchings6b73e102009-04-29 08:08:58 +0000334 if (speed_ability & MDIO_PMA_SPEED_1000)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000335 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
336 }
337
338 return status;
339}
340
341/**
342 * ixgbe_get_media_type_82599 - Get media type
343 * @hw: pointer to hardware structure
344 *
345 * Returns the media type (fiber, copper, backplane)
346 **/
347enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
348{
349 enum ixgbe_media_type media_type;
350
351 /* Detect if there is a copper PHY attached. */
352 if (hw->phy.type == ixgbe_phy_cu_unknown ||
353 hw->phy.type == ixgbe_phy_tn) {
354 media_type = ixgbe_media_type_copper;
355 goto out;
356 }
357
358 switch (hw->device_id) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000359 case IXGBE_DEV_ID_82599_KX4:
Peter P Waskiewicz Jr1fcf03e2009-05-17 20:58:04 +0000360 case IXGBE_DEV_ID_82599_XAUI_LOM:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000361 /* Default device ID is mezzanine card KX/KX4 */
362 media_type = ixgbe_media_type_backplane;
363 break;
364 case IXGBE_DEV_ID_82599_SFP:
365 media_type = ixgbe_media_type_fiber;
366 break;
367 default:
368 media_type = ixgbe_media_type_unknown;
369 break;
370 }
371out:
372 return media_type;
373}
374
375/**
376 * ixgbe_setup_mac_link_82599 - Setup MAC link settings
377 * @hw: pointer to hardware structure
378 *
379 * Configures link settings based on values in the ixgbe_hw struct.
380 * Restarts the link. Performs autonegotiation if needed.
381 **/
382s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw)
383{
384 u32 autoc_reg;
385 u32 links_reg;
386 u32 i;
387 s32 status = 0;
388
389 /* Restart link */
390 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
391 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
392 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
393
394 /* Only poll for autoneg to complete if specified to do so */
395 if (hw->phy.autoneg_wait_to_complete) {
396 if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
397 IXGBE_AUTOC_LMS_KX4_KX_KR ||
398 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
399 IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
400 (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
401 IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
402 links_reg = 0; /* Just in case Autoneg time = 0 */
403 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
404 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
405 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
406 break;
407 msleep(100);
408 }
409 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
410 status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
411 hw_dbg(hw, "Autoneg did not complete.\n");
412 }
413 }
414 }
415
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000416 /* Add delay to filter out noises during initial link setup */
417 msleep(50);
418
419 return status;
420}
421
422/**
423 * ixgbe_setup_mac_link_multispeed_fiber - Setup MAC link settings
424 * @hw: pointer to hardware structure
425 *
426 * Configures link settings based on values in the ixgbe_hw struct.
427 * Restarts the link for multi-speed fiber at 1G speed, if link
428 * fails at 10G.
429 * Performs autonegotiation if needed.
430 **/
431s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw)
432{
433 s32 status = 0;
434 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_82599_AUTONEG;
Jesse Brandeburg4df10462009-03-13 22:15:31 +0000435 status = ixgbe_setup_mac_link_speed_multispeed_fiber(hw, link_speed,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000436 true, true);
437 return status;
438}
439
440/**
441 * ixgbe_setup_mac_link_speed_multispeed_fiber - Set MAC link speed
442 * @hw: pointer to hardware structure
443 * @speed: new link speed
444 * @autoneg: true if autonegotiation enabled
445 * @autoneg_wait_to_complete: true when waiting for completion is needed
446 *
447 * Set the link speed in the AUTOC register and restarts link.
448 **/
449s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw,
450 ixgbe_link_speed speed,
451 bool autoneg,
452 bool autoneg_wait_to_complete)
453{
454 s32 status = 0;
455 ixgbe_link_speed phy_link_speed;
456 ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
457 u32 speedcnt = 0;
458 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
459 bool link_up = false;
460 bool negotiation;
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000461 int i;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000462
463 /* Mask off requested but non-supported speeds */
464 hw->mac.ops.get_link_capabilities(hw, &phy_link_speed, &negotiation);
465 speed &= phy_link_speed;
466
467 /*
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000468 * When the driver changes the link speeds that it can support,
469 * it sets autotry_restart to true to indicate that we need to
470 * initiate a new autotry session with the link partner. To do
471 * so, we set the speed then disable and re-enable the tx laser, to
472 * alert the link partner that it also needs to restart autotry on its
473 * end. This is consistent with true clause 37 autoneg, which also
474 * involves a loss of signal.
475 */
476
477 /*
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000478 * Try each speed one by one, highest priority first. We do this in
479 * software because 10gb fiber doesn't support speed autonegotiation.
480 */
481 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
482 speedcnt++;
483 highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL;
484
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000485 /* If we already have link at this speed, just jump out */
486 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
487
488 if ((phy_link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
489 goto out;
490
491 /* Set the module link speed */
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000492 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
493 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
494
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000495 /* Allow module to change analog characteristics (1G->10G) */
496 msleep(40);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000497
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000498 status = ixgbe_setup_mac_link_speed_82599(hw,
499 IXGBE_LINK_SPEED_10GB_FULL,
500 autoneg,
501 autoneg_wait_to_complete);
502 if (status != 0)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000503 goto out;
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000504
505 /* Flap the tx laser if it has not already been done */
506 if (hw->mac.autotry_restart) {
507 /* Disable tx laser; allow 100us to go dark per spec */
508 esdp_reg |= IXGBE_ESDP_SDP3;
509 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
510 udelay(100);
511
512 /* Enable tx laser; allow 2ms to light up per spec */
513 esdp_reg &= ~IXGBE_ESDP_SDP3;
514 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
515 msleep(2);
516
517 hw->mac.autotry_restart = false;
518 }
519
520 /* The controller may take up to 500ms at 10g to acquire link */
521 for (i = 0; i < 5; i++) {
522 /* Wait for the link partner to also set speed */
523 msleep(100);
524
525 /* If we have link, just jump out */
526 hw->mac.ops.check_link(hw, &phy_link_speed,
527 &link_up, false);
528 if (link_up)
529 goto out;
530 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000531 }
532
533 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
534 speedcnt++;
535 if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN)
536 highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL;
537
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000538 /* If we already have link at this speed, just jump out */
539 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
540
541 if ((phy_link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
542 goto out;
543
544 /* Set the module link speed */
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000545 esdp_reg &= ~IXGBE_ESDP_SDP5;
546 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
547 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
548
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000549 /* Allow module to change analog characteristics (10G->1G) */
550 msleep(40);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000551
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000552 status = ixgbe_setup_mac_link_speed_82599(hw,
553 IXGBE_LINK_SPEED_1GB_FULL,
554 autoneg,
555 autoneg_wait_to_complete);
556 if (status != 0)
557 goto out;
558
559 /* Flap the tx laser if it has not already been done */
560 if (hw->mac.autotry_restart) {
561 /* Disable tx laser; allow 100us to go dark per spec */
562 esdp_reg |= IXGBE_ESDP_SDP3;
563 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
564 udelay(100);
565
566 /* Enable tx laser; allow 2ms to light up per spec */
567 esdp_reg &= ~IXGBE_ESDP_SDP3;
568 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
569 msleep(2);
570
571 hw->mac.autotry_restart = false;
572 }
573
574 /* Wait for the link partner to also set speed */
575 msleep(100);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000576
577 /* If we have link, just jump out */
578 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
579 if (link_up)
580 goto out;
581 }
582
583 /*
584 * We didn't get link. Configure back to the highest speed we tried,
585 * (if there was more than one). We call ourselves back with just the
586 * single highest speed that the user requested.
587 */
588 if (speedcnt > 1)
589 status = ixgbe_setup_mac_link_speed_multispeed_fiber(hw,
590 highest_link_speed,
591 autoneg,
592 autoneg_wait_to_complete);
593
594out:
595 return status;
596}
597
598/**
599 * ixgbe_check_mac_link_82599 - Determine link and speed status
600 * @hw: pointer to hardware structure
601 * @speed: pointer to link speed
602 * @link_up: true when link is up
603 * @link_up_wait_to_complete: bool used to wait for link up or not
604 *
605 * Reads the links register to determine if link is up and the current speed
606 **/
607s32 ixgbe_check_mac_link_82599(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
608 bool *link_up, bool link_up_wait_to_complete)
609{
610 u32 links_reg;
611 u32 i;
612
613 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
614 if (link_up_wait_to_complete) {
615 for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
616 if (links_reg & IXGBE_LINKS_UP) {
617 *link_up = true;
618 break;
619 } else {
620 *link_up = false;
621 }
622 msleep(100);
623 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
624 }
625 } else {
626 if (links_reg & IXGBE_LINKS_UP)
627 *link_up = true;
628 else
629 *link_up = false;
630 }
631
632 if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
633 IXGBE_LINKS_SPEED_10G_82599)
634 *speed = IXGBE_LINK_SPEED_10GB_FULL;
635 else if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
636 IXGBE_LINKS_SPEED_1G_82599)
637 *speed = IXGBE_LINK_SPEED_1GB_FULL;
638 else
639 *speed = IXGBE_LINK_SPEED_100_FULL;
640
Mallikarjuna R Chilakala620fa032009-06-04 11:11:13 +0000641 /* if link is down, zero out the current_mode */
642 if (*link_up == false) {
643 hw->fc.current_mode = ixgbe_fc_none;
644 hw->fc.fc_was_autonegged = false;
645 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000646
647 return 0;
648}
649
650/**
651 * ixgbe_setup_mac_link_speed_82599 - Set MAC link speed
652 * @hw: pointer to hardware structure
653 * @speed: new link speed
654 * @autoneg: true if autonegotiation enabled
655 * @autoneg_wait_to_complete: true when waiting for completion is needed
656 *
657 * Set the link speed in the AUTOC register and restarts link.
658 **/
659s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
660 ixgbe_link_speed speed, bool autoneg,
661 bool autoneg_wait_to_complete)
662{
663 s32 status = 0;
664 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
665 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000666 u32 start_autoc = autoc;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000667 u32 orig_autoc = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000668 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
669 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
670 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
671 u32 links_reg;
672 u32 i;
673 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
674
675 /* Check to see if speed passed in is supported. */
676 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg);
677 speed &= link_capabilities;
678
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000679 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
680 status = IXGBE_ERR_LINK_SETUP;
681 goto out;
682 }
683
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000684 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
685 if (hw->mac.orig_link_settings_stored)
686 orig_autoc = hw->mac.orig_autoc;
687 else
688 orig_autoc = autoc;
689
690
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000691 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
692 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
693 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000694 /* Set KX4/KX/KR support according to speed requested */
695 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
696 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000697 if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000698 autoc |= IXGBE_AUTOC_KX4_SUPP;
PJ Waskiewicz1eb99d52009-04-09 22:28:33 +0000699 if (orig_autoc & IXGBE_AUTOC_KR_SUPP)
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000700 autoc |= IXGBE_AUTOC_KR_SUPP;
701 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
702 autoc |= IXGBE_AUTOC_KX_SUPP;
703 } else if ((pma_pmd_1g == IXGBE_AUTOC_1G_SFI) &&
704 (link_mode == IXGBE_AUTOC_LMS_1G_LINK_NO_AN ||
705 link_mode == IXGBE_AUTOC_LMS_1G_AN)) {
706 /* Switch from 1G SFI to 10G SFI if requested */
707 if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&
708 (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)) {
709 autoc &= ~IXGBE_AUTOC_LMS_MASK;
710 autoc |= IXGBE_AUTOC_LMS_10G_SERIAL;
711 }
712 } else if ((pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI) &&
713 (link_mode == IXGBE_AUTOC_LMS_10G_SERIAL)) {
714 /* Switch from 10G SFI to 1G SFI if requested */
715 if ((speed == IXGBE_LINK_SPEED_1GB_FULL) &&
716 (pma_pmd_1g == IXGBE_AUTOC_1G_SFI)) {
717 autoc &= ~IXGBE_AUTOC_LMS_MASK;
718 if (autoneg)
719 autoc |= IXGBE_AUTOC_LMS_1G_AN;
720 else
721 autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
722 }
723 }
724
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000725 if (autoc != start_autoc) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000726 /* Restart link */
727 autoc |= IXGBE_AUTOC_AN_RESTART;
728 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
729
730 /* Only poll for autoneg to complete if specified to do so */
731 if (autoneg_wait_to_complete) {
732 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
733 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
734 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
735 links_reg = 0; /*Just in case Autoneg time=0*/
736 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
737 links_reg =
738 IXGBE_READ_REG(hw, IXGBE_LINKS);
739 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
740 break;
741 msleep(100);
742 }
743 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
744 status =
745 IXGBE_ERR_AUTONEG_NOT_COMPLETE;
746 hw_dbg(hw, "Autoneg did not "
747 "complete.\n");
748 }
749 }
750 }
751
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000752 /* Add delay to filter out noises during initial link setup */
753 msleep(50);
754 }
755
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +0000756out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000757 return status;
758}
759
760/**
761 * ixgbe_setup_copper_link_82599 - Setup copper link settings
762 * @hw: pointer to hardware structure
763 *
764 * Restarts the link on PHY and then MAC. Performs autonegotiation if needed.
765 **/
766static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw)
767{
768 s32 status;
769
770 /* Restart autonegotiation on PHY */
771 status = hw->phy.ops.setup_link(hw);
772
773 /* Set up MAC */
774 ixgbe_setup_mac_link_82599(hw);
775
776 return status;
777}
778
779/**
780 * ixgbe_setup_copper_link_speed_82599 - Set the PHY autoneg advertised field
781 * @hw: pointer to hardware structure
782 * @speed: new link speed
783 * @autoneg: true if autonegotiation enabled
784 * @autoneg_wait_to_complete: true if waiting is needed to complete
785 *
786 * Restarts link on PHY and MAC based on settings passed in.
787 **/
788static s32 ixgbe_setup_copper_link_speed_82599(struct ixgbe_hw *hw,
789 ixgbe_link_speed speed,
790 bool autoneg,
791 bool autoneg_wait_to_complete)
792{
793 s32 status;
794
795 /* Setup the PHY according to input speed */
796 status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
797 autoneg_wait_to_complete);
798 /* Set up MAC */
799 ixgbe_setup_mac_link_82599(hw);
800
801 return status;
802}
803
804/**
805 * ixgbe_reset_hw_82599 - Perform hardware reset
806 * @hw: pointer to hardware structure
807 *
808 * Resets the hardware by resetting the transmit and receive units, masks
809 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
810 * reset.
811 **/
812s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
813{
814 s32 status = 0;
815 u32 ctrl, ctrl_ext;
816 u32 i;
817 u32 autoc;
818 u32 autoc2;
819
820 /* Call adapter stop to disable tx/rx and clear interrupts */
821 hw->mac.ops.stop_adapter(hw);
822
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000823 /* PHY ops must be identified and initialized prior to reset */
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000824
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000825 /* Init PHY and function pointers, perform SFP setup */
826 status = hw->phy.ops.init(hw);
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000827
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000828 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
829 goto reset_hw_out;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000830
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000831 /* Setup SFP module if there is one present. */
832 if (hw->phy.sfp_setup_needed) {
833 status = hw->mac.ops.setup_sfp(hw);
834 hw->phy.sfp_setup_needed = false;
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000835 }
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000836
PJ Waskiewicz553b4492009-04-09 22:28:15 +0000837 /* Reset PHY */
838 if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL)
839 hw->phy.ops.reset(hw);
840
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000841 /*
842 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
843 * access and verify no pending requests before reset
844 */
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000845 status = ixgbe_disable_pcie_master(hw);
846 if (status != 0) {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000847 status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
848 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
849 }
850
851 /*
852 * Issue global reset to the MAC. This needs to be a SW reset.
853 * If link reset is used, it might reset the MAC when mng is using it
854 */
855 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
856 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST));
857 IXGBE_WRITE_FLUSH(hw);
858
859 /* Poll for reset bit to self-clear indicating reset is complete */
860 for (i = 0; i < 10; i++) {
861 udelay(1);
862 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
863 if (!(ctrl & IXGBE_CTRL_RST))
864 break;
865 }
866 if (ctrl & IXGBE_CTRL_RST) {
867 status = IXGBE_ERR_RESET_FAILED;
868 hw_dbg(hw, "Reset polling failed to complete.\n");
869 }
870 /* Clear PF Reset Done bit so PF/VF Mail Ops can work */
871 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
872 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
873 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
874
875 msleep(50);
876
877
878
879 /*
880 * Store the original AUTOC/AUTOC2 values if they have not been
881 * stored off yet. Otherwise restore the stored original
882 * values since the reset operation sets back to defaults.
883 */
884 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
885 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
886 if (hw->mac.orig_link_settings_stored == false) {
887 hw->mac.orig_autoc = autoc;
888 hw->mac.orig_autoc2 = autoc2;
889 hw->mac.orig_link_settings_stored = true;
Jesse Brandeburg4df10462009-03-13 22:15:31 +0000890 } else {
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000891 if (autoc != hw->mac.orig_autoc)
892 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (hw->mac.orig_autoc |
893 IXGBE_AUTOC_AN_RESTART));
894
895 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
896 (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
897 autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
898 autoc2 |= (hw->mac.orig_autoc2 &
899 IXGBE_AUTOC2_UPPER_MASK);
900 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
901 }
902 }
903
Waskiewicz Jr, Peter Paca6bee2009-05-17 12:32:48 +0000904 /*
905 * Store MAC address from RAR0, clear receive address registers, and
906 * clear the multicast table. Also reset num_rar_entries to 128,
907 * since we modify this value when programming the SAN MAC address.
908 */
909 hw->mac.num_rar_entries = 128;
910 hw->mac.ops.init_rx_addrs(hw);
911
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000912 /* Store the permanent mac address */
913 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
914
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +0000915 /* Store the permanent SAN mac address */
916 hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
917
Waskiewicz Jr, Peter Paca6bee2009-05-17 12:32:48 +0000918 /* Add the SAN MAC address to the RAR only if it's a valid address */
919 if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
920 hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
921 hw->mac.san_addr, 0, IXGBE_RAH_AV);
922
923 /* Reserve the last RAR for the SAN MAC address */
924 hw->mac.num_rar_entries--;
925 }
926
PJ Waskiewicz04f165e2009-04-09 22:27:57 +0000927reset_hw_out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +0000928 return status;
929}
930
931/**
932 * ixgbe_clear_vmdq_82599 - Disassociate a VMDq pool index from a rx address
933 * @hw: pointer to hardware struct
934 * @rar: receive address register index to disassociate
935 * @vmdq: VMDq pool index to remove from the rar
936 **/
937s32 ixgbe_clear_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
938{
939 u32 mpsar_lo, mpsar_hi;
940 u32 rar_entries = hw->mac.num_rar_entries;
941
942 if (rar < rar_entries) {
943 mpsar_lo = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));
944 mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
945
946 if (!mpsar_lo && !mpsar_hi)
947 goto done;
948
949 if (vmdq == IXGBE_CLEAR_VMDQ_ALL) {
950 if (mpsar_lo) {
951 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), 0);
952 mpsar_lo = 0;
953 }
954 if (mpsar_hi) {
955 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), 0);
956 mpsar_hi = 0;
957 }
958 } else if (vmdq < 32) {
959 mpsar_lo &= ~(1 << vmdq);
960 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), mpsar_lo);
961 } else {
962 mpsar_hi &= ~(1 << (vmdq - 32));
963 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), mpsar_hi);
964 }
965
966 /* was that the last pool using this rar? */
967 if (mpsar_lo == 0 && mpsar_hi == 0 && rar != 0)
968 hw->mac.ops.clear_rar(hw, rar);
969 } else {
970 hw_dbg(hw, "RAR index %d is out of range.\n", rar);
971 }
972
973done:
974 return 0;
975}
976
977/**
978 * ixgbe_set_vmdq_82599 - Associate a VMDq pool index with a rx address
979 * @hw: pointer to hardware struct
980 * @rar: receive address register index to associate with a VMDq index
981 * @vmdq: VMDq pool index
982 **/
983s32 ixgbe_set_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
984{
985 u32 mpsar;
986 u32 rar_entries = hw->mac.num_rar_entries;
987
988 if (rar < rar_entries) {
989 if (vmdq < 32) {
990 mpsar = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));
991 mpsar |= 1 << vmdq;
992 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), mpsar);
993 } else {
994 mpsar = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
995 mpsar |= 1 << (vmdq - 32);
996 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), mpsar);
997 }
998 } else {
999 hw_dbg(hw, "RAR index %d is out of range.\n", rar);
1000 }
1001 return 0;
1002}
1003
1004/**
1005 * ixgbe_set_vfta_82599 - Set VLAN filter table
1006 * @hw: pointer to hardware structure
1007 * @vlan: VLAN id to write to VLAN filter
1008 * @vind: VMDq output index that maps queue to VLAN id in VFVFB
1009 * @vlan_on: boolean flag to turn on/off VLAN in VFVF
1010 *
1011 * Turn on/off specified VLAN in the VLAN filter table.
1012 **/
1013s32 ixgbe_set_vfta_82599(struct ixgbe_hw *hw, u32 vlan, u32 vind,
1014 bool vlan_on)
1015{
1016 u32 regindex;
1017 u32 bitindex;
1018 u32 bits;
1019 u32 first_empty_slot;
1020
1021 if (vlan > 4095)
1022 return IXGBE_ERR_PARAM;
1023
1024 /*
1025 * this is a 2 part operation - first the VFTA, then the
1026 * VLVF and VLVFB if vind is set
1027 */
1028
1029 /* Part 1
1030 * The VFTA is a bitstring made up of 128 32-bit registers
1031 * that enable the particular VLAN id, much like the MTA:
1032 * bits[11-5]: which register
1033 * bits[4-0]: which bit in the register
1034 */
1035 regindex = (vlan >> 5) & 0x7F;
1036 bitindex = vlan & 0x1F;
1037 bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
1038 if (vlan_on)
1039 bits |= (1 << bitindex);
1040 else
1041 bits &= ~(1 << bitindex);
1042 IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
1043
1044
1045 /* Part 2
1046 * If the vind is set
1047 * Either vlan_on
1048 * make sure the vlan is in VLVF
1049 * set the vind bit in the matching VLVFB
1050 * Or !vlan_on
1051 * clear the pool bit and possibly the vind
1052 */
1053 if (vind) {
1054 /* find the vlanid or the first empty slot */
1055 first_empty_slot = 0;
1056
1057 for (regindex = 1; regindex < IXGBE_VLVF_ENTRIES; regindex++) {
1058 bits = IXGBE_READ_REG(hw, IXGBE_VLVF(regindex));
1059 if (!bits && !first_empty_slot)
1060 first_empty_slot = regindex;
1061 else if ((bits & 0x0FFF) == vlan)
1062 break;
1063 }
1064
1065 if (regindex >= IXGBE_VLVF_ENTRIES) {
1066 if (first_empty_slot)
1067 regindex = first_empty_slot;
1068 else {
1069 hw_dbg(hw, "No space in VLVF.\n");
1070 goto out;
1071 }
1072 }
1073
1074 if (vlan_on) {
1075 /* set the pool bit */
1076 if (vind < 32) {
1077 bits = IXGBE_READ_REG(hw,
1078 IXGBE_VLVFB(regindex * 2));
1079 bits |= (1 << vind);
1080 IXGBE_WRITE_REG(hw,
1081 IXGBE_VLVFB(regindex * 2), bits);
1082 } else {
1083 bits = IXGBE_READ_REG(hw,
1084 IXGBE_VLVFB((regindex * 2) + 1));
1085 bits |= (1 << vind);
1086 IXGBE_WRITE_REG(hw,
1087 IXGBE_VLVFB((regindex * 2) + 1), bits);
1088 }
1089 } else {
1090 /* clear the pool bit */
1091 if (vind < 32) {
1092 bits = IXGBE_READ_REG(hw,
1093 IXGBE_VLVFB(regindex * 2));
1094 bits &= ~(1 << vind);
1095 IXGBE_WRITE_REG(hw,
1096 IXGBE_VLVFB(regindex * 2), bits);
1097 bits |= IXGBE_READ_REG(hw,
1098 IXGBE_VLVFB((regindex * 2) + 1));
1099 } else {
1100 bits = IXGBE_READ_REG(hw,
1101 IXGBE_VLVFB((regindex * 2) + 1));
1102 bits &= ~(1 << vind);
1103 IXGBE_WRITE_REG(hw,
1104 IXGBE_VLVFB((regindex * 2) + 1), bits);
1105 bits |= IXGBE_READ_REG(hw,
1106 IXGBE_VLVFB(regindex * 2));
1107 }
1108 }
1109
1110 if (bits)
1111 IXGBE_WRITE_REG(hw, IXGBE_VLVF(regindex),
1112 (IXGBE_VLVF_VIEN | vlan));
1113 else
1114 IXGBE_WRITE_REG(hw, IXGBE_VLVF(regindex), 0);
1115 }
1116
1117out:
1118 return 0;
1119}
1120
1121/**
1122 * ixgbe_clear_vfta_82599 - Clear VLAN filter table
1123 * @hw: pointer to hardware structure
1124 *
1125 * Clears the VLAN filer table, and the VMDq index associated with the filter
1126 **/
1127s32 ixgbe_clear_vfta_82599(struct ixgbe_hw *hw)
1128{
1129 u32 offset;
1130
1131 for (offset = 0; offset < hw->mac.vft_size; offset++)
1132 IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);
1133
1134 for (offset = 0; offset < IXGBE_VLVF_ENTRIES; offset++) {
1135 IXGBE_WRITE_REG(hw, IXGBE_VLVF(offset), 0);
1136 IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2), 0);
1137 IXGBE_WRITE_REG(hw, IXGBE_VLVFB((offset * 2) + 1), 0);
1138 }
1139
1140 return 0;
1141}
1142
1143/**
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001144 * ixgbe_init_uta_tables_82599 - Initialize the Unicast Table Array
1145 * @hw: pointer to hardware structure
1146 **/
1147s32 ixgbe_init_uta_tables_82599(struct ixgbe_hw *hw)
1148{
1149 int i;
1150 hw_dbg(hw, " Clearing UTA\n");
1151
1152 for (i = 0; i < 128; i++)
1153 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
1154
1155 return 0;
1156}
1157
1158/**
1159 * ixgbe_read_analog_reg8_82599 - Reads 8 bit Omer analog register
1160 * @hw: pointer to hardware structure
1161 * @reg: analog register to read
1162 * @val: read value
1163 *
1164 * Performs read operation to Omer analog register specified.
1165 **/
1166s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val)
1167{
1168 u32 core_ctl;
1169
1170 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, IXGBE_CORECTL_WRITE_CMD |
1171 (reg << 8));
1172 IXGBE_WRITE_FLUSH(hw);
1173 udelay(10);
1174 core_ctl = IXGBE_READ_REG(hw, IXGBE_CORECTL);
1175 *val = (u8)core_ctl;
1176
1177 return 0;
1178}
1179
1180/**
1181 * ixgbe_write_analog_reg8_82599 - Writes 8 bit Omer analog register
1182 * @hw: pointer to hardware structure
1183 * @reg: atlas register to write
1184 * @val: value to write
1185 *
1186 * Performs write operation to Omer analog register specified.
1187 **/
1188s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val)
1189{
1190 u32 core_ctl;
1191
1192 core_ctl = (reg << 8) | val;
1193 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, core_ctl);
1194 IXGBE_WRITE_FLUSH(hw);
1195 udelay(10);
1196
1197 return 0;
1198}
1199
1200/**
1201 * ixgbe_start_hw_82599 - Prepare hardware for Tx/Rx
1202 * @hw: pointer to hardware structure
1203 *
1204 * Starts the hardware using the generic start_hw function.
1205 * Then performs device-specific:
1206 * Clears the rate limiter registers.
1207 **/
1208s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
1209{
1210 u32 q_num;
1211
1212 ixgbe_start_hw_generic(hw);
1213
1214 /* Clear the rate limiters */
1215 for (q_num = 0; q_num < hw->mac.max_tx_queues; q_num++) {
1216 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, q_num);
1217 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, 0);
1218 }
1219 IXGBE_WRITE_FLUSH(hw);
1220
Peter P Waskiewicz Jr50ac58b2009-06-04 11:10:53 +00001221 /* We need to run link autotry after the driver loads */
1222 hw->mac.autotry_restart = true;
1223
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001224 return 0;
1225}
1226
1227/**
1228 * ixgbe_identify_phy_82599 - Get physical layer module
1229 * @hw: pointer to hardware structure
1230 *
1231 * Determines the physical layer module found on the current adapter.
1232 **/
1233s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
1234{
1235 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1236 status = ixgbe_identify_phy_generic(hw);
1237 if (status != 0)
1238 status = ixgbe_identify_sfp_module_generic(hw);
1239 return status;
1240}
1241
1242/**
1243 * ixgbe_get_supported_physical_layer_82599 - Returns physical layer type
1244 * @hw: pointer to hardware structure
1245 *
1246 * Determines physical layer capabilities of the current configuration.
1247 **/
1248u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw)
1249{
1250 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001251 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1252 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1253 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
1254 u32 pma_pmd_10g_parallel = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
1255 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
1256 u16 ext_ability = 0;
PJ Waskiewicz1339b9e2009-03-13 22:12:29 +00001257 u8 comp_codes_10g = 0;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001258
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001259 hw->phy.ops.identify(hw);
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001260
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001261 if (hw->phy.type == ixgbe_phy_tn ||
1262 hw->phy.type == ixgbe_phy_cu_unknown) {
Ben Hutchings6b73e102009-04-29 08:08:58 +00001263 hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
1264 &ext_ability);
1265 if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001266 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
Ben Hutchings6b73e102009-04-29 08:08:58 +00001267 if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001268 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
Ben Hutchings6b73e102009-04-29 08:08:58 +00001269 if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001270 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
1271 goto out;
1272 }
1273
1274 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
1275 case IXGBE_AUTOC_LMS_1G_AN:
1276 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
1277 if (pma_pmd_1g == IXGBE_AUTOC_1G_KX_BX) {
1278 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
1279 IXGBE_PHYSICAL_LAYER_1000BASE_BX;
1280 goto out;
1281 } else
1282 /* SFI mode so read SFP module */
1283 goto sfp_check;
1284 break;
1285 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
1286 if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_CX4)
1287 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
1288 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_KX4)
1289 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
Peter P Waskiewicz Jr1fcf03e2009-05-17 20:58:04 +00001290 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_XAUI)
1291 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_XAUI;
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001292 goto out;
1293 break;
1294 case IXGBE_AUTOC_LMS_10G_SERIAL:
1295 if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_KR) {
1296 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR;
1297 goto out;
1298 } else if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)
1299 goto sfp_check;
1300 break;
1301 case IXGBE_AUTOC_LMS_KX4_KX_KR:
1302 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
1303 if (autoc & IXGBE_AUTOC_KX_SUPP)
1304 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
1305 if (autoc & IXGBE_AUTOC_KX4_SUPP)
1306 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
1307 if (autoc & IXGBE_AUTOC_KR_SUPP)
1308 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KR;
1309 goto out;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001310 break;
1311 default:
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001312 goto out;
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001313 break;
1314 }
1315
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001316sfp_check:
1317 /* SFP check must be done last since DA modules are sometimes used to
1318 * test KR mode - we need to id KR mode correctly before SFP module.
1319 * Call identify_sfp because the pluggable module may have changed */
1320 hw->phy.ops.identify_sfp(hw);
1321 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1322 goto out;
1323
1324 switch (hw->phy.type) {
1325 case ixgbe_phy_tw_tyco:
1326 case ixgbe_phy_tw_unknown:
1327 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1328 break;
1329 case ixgbe_phy_sfp_avago:
1330 case ixgbe_phy_sfp_ftl:
1331 case ixgbe_phy_sfp_intel:
1332 case ixgbe_phy_sfp_unknown:
1333 hw->phy.ops.read_i2c_eeprom(hw,
1334 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1335 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1336 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1337 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1338 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1339 break;
1340 default:
1341 break;
1342 }
1343
1344out:
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001345 return physical_layer;
1346}
1347
1348/**
1349 * ixgbe_enable_rx_dma_82599 - Enable the Rx DMA unit on 82599
1350 * @hw: pointer to hardware structure
1351 * @regval: register value to write to RXCTRL
1352 *
1353 * Enables the Rx DMA unit for 82599
1354 **/
1355s32 ixgbe_enable_rx_dma_82599(struct ixgbe_hw *hw, u32 regval)
1356{
1357#define IXGBE_MAX_SECRX_POLL 30
1358 int i;
1359 int secrxreg;
1360
1361 /*
1362 * Workaround for 82599 silicon errata when enabling the Rx datapath.
1363 * If traffic is incoming before we enable the Rx unit, it could hang
1364 * the Rx DMA unit. Therefore, make sure the security engine is
1365 * completely disabled prior to enabling the Rx unit.
1366 */
1367 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
1368 secrxreg |= IXGBE_SECRXCTRL_RX_DIS;
1369 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg);
1370 for (i = 0; i < IXGBE_MAX_SECRX_POLL; i++) {
1371 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT);
1372 if (secrxreg & IXGBE_SECRXSTAT_SECRX_RDY)
1373 break;
1374 else
1375 udelay(10);
1376 }
1377
1378 /* For informational purposes only */
1379 if (i >= IXGBE_MAX_SECRX_POLL)
1380 hw_dbg(hw, "Rx unit being enabled before security "
1381 "path fully disabled. Continuing with init.\n");
1382
1383 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval);
1384 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
1385 secrxreg &= ~IXGBE_SECRXCTRL_RX_DIS;
1386 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg);
1387 IXGBE_WRITE_FLUSH(hw);
1388
1389 return 0;
1390}
1391
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001392/**
1393 * ixgbe_get_device_caps_82599 - Get additional device capabilities
1394 * @hw: pointer to hardware structure
1395 * @device_caps: the EEPROM word with the extra device capabilities
1396 *
1397 * This function will read the EEPROM location for the device capabilities,
1398 * and return the word through device_caps.
1399 **/
1400s32 ixgbe_get_device_caps_82599(struct ixgbe_hw *hw, u16 *device_caps)
1401{
1402 hw->eeprom.ops.read(hw, IXGBE_DEVICE_CAPS, device_caps);
1403
1404 return 0;
1405}
1406
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +00001407/**
1408 * ixgbe_get_san_mac_addr_offset_82599 - SAN MAC address offset for 82599
1409 * @hw: pointer to hardware structure
1410 * @san_mac_offset: SAN MAC address offset
1411 *
1412 * This function will read the EEPROM location for the SAN MAC address
1413 * pointer, and returns the value at that location. This is used in both
1414 * get and set mac_addr routines.
1415 **/
1416s32 ixgbe_get_san_mac_addr_offset_82599(struct ixgbe_hw *hw,
1417 u16 *san_mac_offset)
1418{
1419 /*
1420 * First read the EEPROM pointer to see if the MAC addresses are
1421 * available.
1422 */
1423 hw->eeprom.ops.read(hw, IXGBE_SAN_MAC_ADDR_PTR, san_mac_offset);
1424
1425 return 0;
1426}
1427
1428/**
1429 * ixgbe_get_san_mac_addr_82599 - SAN MAC address retrieval for 82599
1430 * @hw: pointer to hardware structure
1431 * @san_mac_addr: SAN MAC address
1432 *
1433 * Reads the SAN MAC address from the EEPROM, if it's available. This is
1434 * per-port, so set_lan_id() must be called before reading the addresses.
1435 * set_lan_id() is called by identify_sfp(), but this cannot be relied
1436 * upon for non-SFP connections, so we must call it here.
1437 **/
1438s32 ixgbe_get_san_mac_addr_82599(struct ixgbe_hw *hw, u8 *san_mac_addr)
1439{
1440 u16 san_mac_data, san_mac_offset;
1441 u8 i;
1442
1443 /*
1444 * First read the EEPROM pointer to see if the MAC addresses are
1445 * available. If they're not, no point in calling set_lan_id() here.
1446 */
1447 ixgbe_get_san_mac_addr_offset_82599(hw, &san_mac_offset);
1448
1449 if ((san_mac_offset == 0) || (san_mac_offset == 0xFFFF)) {
1450 /*
1451 * No addresses available in this EEPROM. It's not an
1452 * error though, so just wipe the local address and return.
1453 */
1454 for (i = 0; i < 6; i++)
1455 san_mac_addr[i] = 0xFF;
1456
1457 goto san_mac_addr_out;
1458 }
1459
1460 /* make sure we know which port we need to program */
1461 hw->mac.ops.set_lan_id(hw);
1462 /* apply the port offset to the address offset */
1463 (hw->bus.func) ? (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT1_OFFSET) :
1464 (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT0_OFFSET);
1465 for (i = 0; i < 3; i++) {
1466 hw->eeprom.ops.read(hw, san_mac_offset, &san_mac_data);
1467 san_mac_addr[i * 2] = (u8)(san_mac_data);
1468 san_mac_addr[i * 2 + 1] = (u8)(san_mac_data >> 8);
1469 san_mac_offset++;
1470 }
1471
1472san_mac_addr_out:
1473 return 0;
1474}
1475
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001476static struct ixgbe_mac_operations mac_ops_82599 = {
1477 .init_hw = &ixgbe_init_hw_generic,
1478 .reset_hw = &ixgbe_reset_hw_82599,
1479 .start_hw = &ixgbe_start_hw_82599,
1480 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
1481 .get_media_type = &ixgbe_get_media_type_82599,
1482 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82599,
1483 .enable_rx_dma = &ixgbe_enable_rx_dma_82599,
1484 .get_mac_addr = &ixgbe_get_mac_addr_generic,
PJ Waskiewicz0365e6e2009-05-17 12:32:25 +00001485 .get_san_mac_addr = &ixgbe_get_san_mac_addr_82599,
Peter P Waskiewicz Jr04193052009-04-09 22:28:50 +00001486 .get_device_caps = &ixgbe_get_device_caps_82599,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001487 .stop_adapter = &ixgbe_stop_adapter_generic,
1488 .get_bus_info = &ixgbe_get_bus_info_generic,
1489 .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie,
1490 .read_analog_reg8 = &ixgbe_read_analog_reg8_82599,
1491 .write_analog_reg8 = &ixgbe_write_analog_reg8_82599,
1492 .setup_link = &ixgbe_setup_mac_link_82599,
1493 .setup_link_speed = &ixgbe_setup_mac_link_speed_82599,
1494 .check_link = &ixgbe_check_mac_link_82599,
1495 .get_link_capabilities = &ixgbe_get_link_capabilities_82599,
1496 .led_on = &ixgbe_led_on_generic,
1497 .led_off = &ixgbe_led_off_generic,
PJ Waskiewicz87c12012009-04-08 13:20:31 +00001498 .blink_led_start = &ixgbe_blink_led_start_generic,
1499 .blink_led_stop = &ixgbe_blink_led_stop_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001500 .set_rar = &ixgbe_set_rar_generic,
1501 .clear_rar = &ixgbe_clear_rar_generic,
1502 .set_vmdq = &ixgbe_set_vmdq_82599,
1503 .clear_vmdq = &ixgbe_clear_vmdq_82599,
1504 .init_rx_addrs = &ixgbe_init_rx_addrs_generic,
1505 .update_uc_addr_list = &ixgbe_update_uc_addr_list_generic,
1506 .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,
1507 .enable_mc = &ixgbe_enable_mc_generic,
1508 .disable_mc = &ixgbe_disable_mc_generic,
1509 .clear_vfta = &ixgbe_clear_vfta_82599,
1510 .set_vfta = &ixgbe_set_vfta_82599,
Mallikarjuna R Chilakala620fa032009-06-04 11:11:13 +00001511 .fc_enable = &ixgbe_fc_enable_generic,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001512 .init_uta_tables = &ixgbe_init_uta_tables_82599,
1513 .setup_sfp = &ixgbe_setup_sfp_modules_82599,
1514};
1515
1516static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
1517 .init_params = &ixgbe_init_eeprom_params_generic,
1518 .read = &ixgbe_read_eeprom_generic,
1519 .write = &ixgbe_write_eeprom_generic,
1520 .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
1521 .update_checksum = &ixgbe_update_eeprom_checksum_generic,
1522};
1523
1524static struct ixgbe_phy_operations phy_ops_82599 = {
1525 .identify = &ixgbe_identify_phy_82599,
1526 .identify_sfp = &ixgbe_identify_sfp_module_generic,
PJ Waskiewicz04f165e2009-04-09 22:27:57 +00001527 .init = &ixgbe_init_phy_ops_82599,
PJ Waskiewicz11afc1b2009-02-27 15:44:30 +00001528 .reset = &ixgbe_reset_phy_generic,
1529 .read_reg = &ixgbe_read_phy_reg_generic,
1530 .write_reg = &ixgbe_write_phy_reg_generic,
1531 .setup_link = &ixgbe_setup_phy_link_generic,
1532 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
1533 .read_i2c_byte = &ixgbe_read_i2c_byte_generic,
1534 .write_i2c_byte = &ixgbe_write_i2c_byte_generic,
1535 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic,
1536 .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic,
1537};
1538
1539struct ixgbe_info ixgbe_82599_info = {
1540 .mac = ixgbe_mac_82599EB,
1541 .get_invariants = &ixgbe_get_invariants_82599,
1542 .mac_ops = &mac_ops_82599,
1543 .eeprom_ops = &eeprom_ops_82599,
1544 .phy_ops = &phy_ops_82599,
1545};