1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2009 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
28 #include <linux/pci.h>
29 #include <linux/delay.h>
30 #include <linux/sched.h>
33 #include "ixgbe_phy.h"
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
41 s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
42 ixgbe_link_speed *speed,
44 enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw);
45 s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw);
46 s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw,
47 ixgbe_link_speed speed, bool autoneg,
48 bool autoneg_wait_to_complete);
49 s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw);
50 s32 ixgbe_check_mac_link_82599(struct ixgbe_hw *hw,
51 ixgbe_link_speed *speed,
52 bool *link_up, bool link_up_wait_to_complete);
53 s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
54 ixgbe_link_speed speed,
56 bool autoneg_wait_to_complete);
57 static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw,
58 ixgbe_link_speed *speed,
60 static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw);
61 static s32 ixgbe_setup_copper_link_speed_82599(struct ixgbe_hw *hw,
62 ixgbe_link_speed speed,
64 bool autoneg_wait_to_complete);
65 s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw);
66 s32 ixgbe_set_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
67 s32 ixgbe_clear_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
68 s32 ixgbe_set_vfta_82599(struct ixgbe_hw *hw, u32 vlan,
69 u32 vind, bool vlan_on);
70 s32 ixgbe_clear_vfta_82599(struct ixgbe_hw *hw);
71 s32 ixgbe_init_uta_tables_82599(struct ixgbe_hw *hw);
72 s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val);
73 s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val);
74 s32 ixgbe_start_hw_rev_0_82599(struct ixgbe_hw *hw);
75 s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw);
76 s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw);
77 u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw);
79 void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
81 struct ixgbe_mac_info *mac = &hw->mac;
82 if (hw->phy.multispeed_fiber) {
83 /* Set up dual speed SFP+ support */
85 &ixgbe_setup_mac_link_multispeed_fiber;
86 mac->ops.setup_link_speed =
87 &ixgbe_setup_mac_link_speed_multispeed_fiber;
90 &ixgbe_setup_mac_link_82599;
91 mac->ops.setup_link_speed =
92 &ixgbe_setup_mac_link_speed_82599;
96 s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
99 u16 list_offset, data_offset, data_value;
101 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
102 ixgbe_init_mac_link_ops_82599(hw);
104 hw->phy.ops.reset = NULL;
106 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
112 /* PHY config will finish before releasing the semaphore */
113 ret_val = ixgbe_acquire_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
115 ret_val = IXGBE_ERR_SWFW_SYNC;
119 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);
125 /* 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));
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);
140 * ixgbe_get_pcie_msix_count_82599 - Gets MSI-X vector count
141 * @hw: pointer to hardware structure
143 * Read PCIe configuration space, and get the MSI-X vector count from
144 * the capabilities table.
146 u32 ixgbe_get_pcie_msix_count_82599(struct ixgbe_hw *hw)
148 struct ixgbe_adapter *adapter = hw->back;
150 pci_read_config_word(adapter->pdev, IXGBE_PCIE_MSIX_82599_CAPS,
152 msix_count &= IXGBE_PCIE_MSIX_TBL_SZ_MASK;
154 /* MSI-X count is zero-based in HW, so increment to give proper value */
160 static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
162 struct ixgbe_mac_info *mac = &hw->mac;
164 ixgbe_init_mac_link_ops_82599(hw);
166 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);
177 * ixgbe_init_phy_ops_82599 - PHY/SFP specific init
178 * @hw: pointer to hardware structure
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.
185 s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
187 struct ixgbe_mac_info *mac = &hw->mac;
188 struct ixgbe_phy_info *phy = &hw->phy;
191 /* Identify the PHY or SFP module */
192 ret_val = phy->ops.identify(hw);
194 /* Setup function pointers based on detected SFP module and speeds */
195 ixgbe_init_mac_link_ops_82599(hw);
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;
206 /* Set necessary function pointers based on phy type */
207 switch (hw->phy.type) {
209 phy->ops.check_link = &ixgbe_check_phy_link_tnx;
210 phy->ops.get_firmware_version =
211 &ixgbe_get_phy_firmware_version_tnx;
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
226 * Determines the link capabilities by reading the AUTOC register.
228 s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
229 ixgbe_link_speed *speed,
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.
240 if (hw->mac.orig_link_settings_stored)
241 autoc = hw->mac.orig_autoc;
243 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
245 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
246 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
247 *speed = IXGBE_LINK_SPEED_1GB_FULL;
248 *negotiation = false;
251 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
252 *speed = IXGBE_LINK_SPEED_10GB_FULL;
253 *negotiation = false;
256 case IXGBE_AUTOC_LMS_1G_AN:
257 *speed = IXGBE_LINK_SPEED_1GB_FULL;
261 case IXGBE_AUTOC_LMS_10G_SERIAL:
262 *speed = IXGBE_LINK_SPEED_10GB_FULL;
263 *negotiation = false;
266 case IXGBE_AUTOC_LMS_KX4_KX_KR:
267 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
268 *speed = IXGBE_LINK_SPEED_UNKNOWN;
269 if (autoc & IXGBE_AUTOC_KR_SUPP)
270 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
271 if (autoc & IXGBE_AUTOC_KX4_SUPP)
272 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
273 if (autoc & IXGBE_AUTOC_KX_SUPP)
274 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
278 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
279 *speed = IXGBE_LINK_SPEED_100_FULL;
280 if (autoc & IXGBE_AUTOC_KR_SUPP)
281 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
282 if (autoc & IXGBE_AUTOC_KX4_SUPP)
283 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
284 if (autoc & IXGBE_AUTOC_KX_SUPP)
285 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
289 case IXGBE_AUTOC_LMS_SGMII_1G_100M:
290 *speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
291 *negotiation = false;
295 status = IXGBE_ERR_LINK_SETUP;
300 if (hw->phy.multispeed_fiber) {
301 *speed |= IXGBE_LINK_SPEED_10GB_FULL |
302 IXGBE_LINK_SPEED_1GB_FULL;
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
316 * Determines the link capabilities by reading the AUTOC register.
318 static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw,
319 ixgbe_link_speed *speed,
322 s32 status = IXGBE_ERR_LINK_SETUP;
328 status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
332 if (speed_ability & MDIO_SPEED_10G)
333 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
334 if (speed_ability & MDIO_PMA_SPEED_1000)
335 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
342 * ixgbe_get_media_type_82599 - Get media type
343 * @hw: pointer to hardware structure
345 * Returns the media type (fiber, copper, backplane)
347 enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
349 enum ixgbe_media_type media_type;
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;
358 switch (hw->device_id) {
359 case IXGBE_DEV_ID_82599_KX4:
360 case IXGBE_DEV_ID_82599_XAUI_LOM:
361 /* Default device ID is mezzanine card KX/KX4 */
362 media_type = ixgbe_media_type_backplane;
364 case IXGBE_DEV_ID_82599_SFP:
365 media_type = ixgbe_media_type_fiber;
368 media_type = ixgbe_media_type_unknown;
376 * ixgbe_setup_mac_link_82599 - Setup MAC link settings
377 * @hw: pointer to hardware structure
379 * Configures link settings based on values in the ixgbe_hw struct.
380 * Restarts the link. Performs autonegotiation if needed.
382 s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw)
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);
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)
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");
416 /* Add delay to filter out noises during initial link setup */
423 * ixgbe_setup_mac_link_multispeed_fiber - Setup MAC link settings
424 * @hw: pointer to hardware structure
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
429 * Performs autonegotiation if needed.
431 s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw)
434 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_82599_AUTONEG;
435 status = ixgbe_setup_mac_link_speed_multispeed_fiber(hw, link_speed,
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
447 * Set the link speed in the AUTOC register and restarts link.
449 s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw,
450 ixgbe_link_speed speed,
452 bool autoneg_wait_to_complete)
455 ixgbe_link_speed phy_link_speed;
456 ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN;
458 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
459 bool link_up = false;
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;
467 /* Set autoneg_advertised value based on input link speed */
468 hw->phy.autoneg_advertised = 0;
470 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
471 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
473 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
474 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
477 * When the driver changes the link speeds that it can support,
478 * it sets autotry_restart to true to indicate that we need to
479 * initiate a new autotry session with the link partner. To do
480 * so, we set the speed then disable and re-enable the tx laser, to
481 * alert the link partner that it also needs to restart autotry on its
482 * end. This is consistent with true clause 37 autoneg, which also
483 * involves a loss of signal.
487 * Try each speed one by one, highest priority first. We do this in
488 * software because 10gb fiber doesn't support speed autonegotiation.
490 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
492 highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL;
494 /* If we already have link at this speed, just jump out */
495 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
497 if ((phy_link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
500 /* Set the module link speed */
501 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
502 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
504 /* Allow module to change analog characteristics (1G->10G) */
507 status = ixgbe_setup_mac_link_speed_82599(hw,
508 IXGBE_LINK_SPEED_10GB_FULL,
510 autoneg_wait_to_complete);
514 /* Flap the tx laser if it has not already been done */
515 if (hw->mac.autotry_restart) {
516 /* Disable tx laser; allow 100us to go dark per spec */
517 esdp_reg |= IXGBE_ESDP_SDP3;
518 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
521 /* Enable tx laser; allow 2ms to light up per spec */
522 esdp_reg &= ~IXGBE_ESDP_SDP3;
523 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
526 hw->mac.autotry_restart = false;
529 /* The controller may take up to 500ms at 10g to acquire link */
530 for (i = 0; i < 5; i++) {
531 /* Wait for the link partner to also set speed */
534 /* If we have link, just jump out */
535 hw->mac.ops.check_link(hw, &phy_link_speed,
542 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
544 if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN)
545 highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL;
547 /* If we already have link at this speed, just jump out */
548 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
550 if ((phy_link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
553 /* Set the module link speed */
554 esdp_reg &= ~IXGBE_ESDP_SDP5;
555 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
556 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
558 /* Allow module to change analog characteristics (10G->1G) */
561 status = ixgbe_setup_mac_link_speed_82599(hw,
562 IXGBE_LINK_SPEED_1GB_FULL,
564 autoneg_wait_to_complete);
568 /* Flap the tx laser if it has not already been done */
569 if (hw->mac.autotry_restart) {
570 /* Disable tx laser; allow 100us to go dark per spec */
571 esdp_reg |= IXGBE_ESDP_SDP3;
572 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
575 /* Enable tx laser; allow 2ms to light up per spec */
576 esdp_reg &= ~IXGBE_ESDP_SDP3;
577 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
580 hw->mac.autotry_restart = false;
583 /* Wait for the link partner to also set speed */
586 /* If we have link, just jump out */
587 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
593 * We didn't get link. Configure back to the highest speed we tried,
594 * (if there was more than one). We call ourselves back with just the
595 * single highest speed that the user requested.
598 status = ixgbe_setup_mac_link_speed_multispeed_fiber(hw,
601 autoneg_wait_to_complete);
608 * ixgbe_check_mac_link_82599 - Determine link and speed status
609 * @hw: pointer to hardware structure
610 * @speed: pointer to link speed
611 * @link_up: true when link is up
612 * @link_up_wait_to_complete: bool used to wait for link up or not
614 * Reads the links register to determine if link is up and the current speed
616 s32 ixgbe_check_mac_link_82599(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
617 bool *link_up, bool link_up_wait_to_complete)
622 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
623 if (link_up_wait_to_complete) {
624 for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
625 if (links_reg & IXGBE_LINKS_UP) {
632 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
635 if (links_reg & IXGBE_LINKS_UP)
641 if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
642 IXGBE_LINKS_SPEED_10G_82599)
643 *speed = IXGBE_LINK_SPEED_10GB_FULL;
644 else if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
645 IXGBE_LINKS_SPEED_1G_82599)
646 *speed = IXGBE_LINK_SPEED_1GB_FULL;
648 *speed = IXGBE_LINK_SPEED_100_FULL;
650 /* if link is down, zero out the current_mode */
651 if (*link_up == false) {
652 hw->fc.current_mode = ixgbe_fc_none;
653 hw->fc.fc_was_autonegged = false;
660 * ixgbe_setup_mac_link_speed_82599 - Set MAC link speed
661 * @hw: pointer to hardware structure
662 * @speed: new link speed
663 * @autoneg: true if autonegotiation enabled
664 * @autoneg_wait_to_complete: true when waiting for completion is needed
666 * Set the link speed in the AUTOC register and restarts link.
668 s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
669 ixgbe_link_speed speed, bool autoneg,
670 bool autoneg_wait_to_complete)
673 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
674 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
675 u32 start_autoc = autoc;
677 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
678 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
679 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
682 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
684 /* Check to see if speed passed in is supported. */
685 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg);
686 speed &= link_capabilities;
688 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
689 status = IXGBE_ERR_LINK_SETUP;
693 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
694 if (hw->mac.orig_link_settings_stored)
695 orig_autoc = hw->mac.orig_autoc;
700 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
701 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
702 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
703 /* Set KX4/KX/KR support according to speed requested */
704 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
705 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
706 if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
707 autoc |= IXGBE_AUTOC_KX4_SUPP;
708 if (orig_autoc & IXGBE_AUTOC_KR_SUPP)
709 autoc |= IXGBE_AUTOC_KR_SUPP;
710 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
711 autoc |= IXGBE_AUTOC_KX_SUPP;
712 } else if ((pma_pmd_1g == IXGBE_AUTOC_1G_SFI) &&
713 (link_mode == IXGBE_AUTOC_LMS_1G_LINK_NO_AN ||
714 link_mode == IXGBE_AUTOC_LMS_1G_AN)) {
715 /* Switch from 1G SFI to 10G SFI if requested */
716 if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&
717 (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)) {
718 autoc &= ~IXGBE_AUTOC_LMS_MASK;
719 autoc |= IXGBE_AUTOC_LMS_10G_SERIAL;
721 } else if ((pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI) &&
722 (link_mode == IXGBE_AUTOC_LMS_10G_SERIAL)) {
723 /* Switch from 10G SFI to 1G SFI if requested */
724 if ((speed == IXGBE_LINK_SPEED_1GB_FULL) &&
725 (pma_pmd_1g == IXGBE_AUTOC_1G_SFI)) {
726 autoc &= ~IXGBE_AUTOC_LMS_MASK;
728 autoc |= IXGBE_AUTOC_LMS_1G_AN;
730 autoc |= IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
734 if (autoc != start_autoc) {
736 autoc |= IXGBE_AUTOC_AN_RESTART;
737 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
739 /* Only poll for autoneg to complete if specified to do so */
740 if (autoneg_wait_to_complete) {
741 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
742 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
743 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
744 links_reg = 0; /*Just in case Autoneg time=0*/
745 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
747 IXGBE_READ_REG(hw, IXGBE_LINKS);
748 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
752 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
754 IXGBE_ERR_AUTONEG_NOT_COMPLETE;
755 hw_dbg(hw, "Autoneg did not "
761 /* Add delay to filter out noises during initial link setup */
770 * ixgbe_setup_copper_link_82599 - Setup copper link settings
771 * @hw: pointer to hardware structure
773 * Restarts the link on PHY and then MAC. Performs autonegotiation if needed.
775 static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw)
779 /* Restart autonegotiation on PHY */
780 status = hw->phy.ops.setup_link(hw);
783 ixgbe_setup_mac_link_82599(hw);
789 * ixgbe_setup_copper_link_speed_82599 - Set the PHY autoneg advertised field
790 * @hw: pointer to hardware structure
791 * @speed: new link speed
792 * @autoneg: true if autonegotiation enabled
793 * @autoneg_wait_to_complete: true if waiting is needed to complete
795 * Restarts link on PHY and MAC based on settings passed in.
797 static s32 ixgbe_setup_copper_link_speed_82599(struct ixgbe_hw *hw,
798 ixgbe_link_speed speed,
800 bool autoneg_wait_to_complete)
804 /* Setup the PHY according to input speed */
805 status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
806 autoneg_wait_to_complete);
808 ixgbe_setup_mac_link_82599(hw);
814 * ixgbe_reset_hw_82599 - Perform hardware reset
815 * @hw: pointer to hardware structure
817 * Resets the hardware by resetting the transmit and receive units, masks
818 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
821 s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
829 /* Call adapter stop to disable tx/rx and clear interrupts */
830 hw->mac.ops.stop_adapter(hw);
832 /* PHY ops must be identified and initialized prior to reset */
834 /* Init PHY and function pointers, perform SFP setup */
835 status = hw->phy.ops.init(hw);
837 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
840 /* Setup SFP module if there is one present. */
841 if (hw->phy.sfp_setup_needed) {
842 status = hw->mac.ops.setup_sfp(hw);
843 hw->phy.sfp_setup_needed = false;
847 if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL)
848 hw->phy.ops.reset(hw);
851 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
852 * access and verify no pending requests before reset
854 status = ixgbe_disable_pcie_master(hw);
856 status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
857 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
861 * Issue global reset to the MAC. This needs to be a SW reset.
862 * If link reset is used, it might reset the MAC when mng is using it
864 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
865 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST));
866 IXGBE_WRITE_FLUSH(hw);
868 /* Poll for reset bit to self-clear indicating reset is complete */
869 for (i = 0; i < 10; i++) {
871 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
872 if (!(ctrl & IXGBE_CTRL_RST))
875 if (ctrl & IXGBE_CTRL_RST) {
876 status = IXGBE_ERR_RESET_FAILED;
877 hw_dbg(hw, "Reset polling failed to complete.\n");
879 /* Clear PF Reset Done bit so PF/VF Mail Ops can work */
880 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
881 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
882 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
889 * Store the original AUTOC/AUTOC2 values if they have not been
890 * stored off yet. Otherwise restore the stored original
891 * values since the reset operation sets back to defaults.
893 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
894 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
895 if (hw->mac.orig_link_settings_stored == false) {
896 hw->mac.orig_autoc = autoc;
897 hw->mac.orig_autoc2 = autoc2;
898 hw->mac.orig_link_settings_stored = true;
900 if (autoc != hw->mac.orig_autoc)
901 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (hw->mac.orig_autoc |
902 IXGBE_AUTOC_AN_RESTART));
904 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
905 (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
906 autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
907 autoc2 |= (hw->mac.orig_autoc2 &
908 IXGBE_AUTOC2_UPPER_MASK);
909 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
914 * Store MAC address from RAR0, clear receive address registers, and
915 * clear the multicast table. Also reset num_rar_entries to 128,
916 * since we modify this value when programming the SAN MAC address.
918 hw->mac.num_rar_entries = 128;
919 hw->mac.ops.init_rx_addrs(hw);
921 /* Store the permanent mac address */
922 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
924 /* Store the permanent SAN mac address */
925 hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
927 /* Add the SAN MAC address to the RAR only if it's a valid address */
928 if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
929 hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
930 hw->mac.san_addr, 0, IXGBE_RAH_AV);
932 /* Reserve the last RAR for the SAN MAC address */
933 hw->mac.num_rar_entries--;
941 * ixgbe_clear_vmdq_82599 - Disassociate a VMDq pool index from a rx address
942 * @hw: pointer to hardware struct
943 * @rar: receive address register index to disassociate
944 * @vmdq: VMDq pool index to remove from the rar
946 s32 ixgbe_clear_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
948 u32 mpsar_lo, mpsar_hi;
949 u32 rar_entries = hw->mac.num_rar_entries;
951 if (rar < rar_entries) {
952 mpsar_lo = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));
953 mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
955 if (!mpsar_lo && !mpsar_hi)
958 if (vmdq == IXGBE_CLEAR_VMDQ_ALL) {
960 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), 0);
964 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), 0);
967 } else if (vmdq < 32) {
968 mpsar_lo &= ~(1 << vmdq);
969 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), mpsar_lo);
971 mpsar_hi &= ~(1 << (vmdq - 32));
972 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), mpsar_hi);
975 /* was that the last pool using this rar? */
976 if (mpsar_lo == 0 && mpsar_hi == 0 && rar != 0)
977 hw->mac.ops.clear_rar(hw, rar);
979 hw_dbg(hw, "RAR index %d is out of range.\n", rar);
987 * ixgbe_set_vmdq_82599 - Associate a VMDq pool index with a rx address
988 * @hw: pointer to hardware struct
989 * @rar: receive address register index to associate with a VMDq index
990 * @vmdq: VMDq pool index
992 s32 ixgbe_set_vmdq_82599(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
995 u32 rar_entries = hw->mac.num_rar_entries;
997 if (rar < rar_entries) {
999 mpsar = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));
1001 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(rar), mpsar);
1003 mpsar = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
1004 mpsar |= 1 << (vmdq - 32);
1005 IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(rar), mpsar);
1008 hw_dbg(hw, "RAR index %d is out of range.\n", rar);
1014 * ixgbe_set_vfta_82599 - Set VLAN filter table
1015 * @hw: pointer to hardware structure
1016 * @vlan: VLAN id to write to VLAN filter
1017 * @vind: VMDq output index that maps queue to VLAN id in VFVFB
1018 * @vlan_on: boolean flag to turn on/off VLAN in VFVF
1020 * Turn on/off specified VLAN in the VLAN filter table.
1022 s32 ixgbe_set_vfta_82599(struct ixgbe_hw *hw, u32 vlan, u32 vind,
1028 u32 first_empty_slot;
1031 return IXGBE_ERR_PARAM;
1034 * this is a 2 part operation - first the VFTA, then the
1035 * VLVF and VLVFB if vind is set
1039 * The VFTA is a bitstring made up of 128 32-bit registers
1040 * that enable the particular VLAN id, much like the MTA:
1041 * bits[11-5]: which register
1042 * bits[4-0]: which bit in the register
1044 regindex = (vlan >> 5) & 0x7F;
1045 bitindex = vlan & 0x1F;
1046 bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
1048 bits |= (1 << bitindex);
1050 bits &= ~(1 << bitindex);
1051 IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
1055 * If the vind is set
1057 * make sure the vlan is in VLVF
1058 * set the vind bit in the matching VLVFB
1060 * clear the pool bit and possibly the vind
1063 /* find the vlanid or the first empty slot */
1064 first_empty_slot = 0;
1066 for (regindex = 1; regindex < IXGBE_VLVF_ENTRIES; regindex++) {
1067 bits = IXGBE_READ_REG(hw, IXGBE_VLVF(regindex));
1068 if (!bits && !first_empty_slot)
1069 first_empty_slot = regindex;
1070 else if ((bits & 0x0FFF) == vlan)
1074 if (regindex >= IXGBE_VLVF_ENTRIES) {
1075 if (first_empty_slot)
1076 regindex = first_empty_slot;
1078 hw_dbg(hw, "No space in VLVF.\n");
1084 /* set the pool bit */
1086 bits = IXGBE_READ_REG(hw,
1087 IXGBE_VLVFB(regindex * 2));
1088 bits |= (1 << vind);
1090 IXGBE_VLVFB(regindex * 2), bits);
1092 bits = IXGBE_READ_REG(hw,
1093 IXGBE_VLVFB((regindex * 2) + 1));
1094 bits |= (1 << vind);
1096 IXGBE_VLVFB((regindex * 2) + 1), bits);
1099 /* clear the pool bit */
1101 bits = IXGBE_READ_REG(hw,
1102 IXGBE_VLVFB(regindex * 2));
1103 bits &= ~(1 << vind);
1105 IXGBE_VLVFB(regindex * 2), bits);
1106 bits |= IXGBE_READ_REG(hw,
1107 IXGBE_VLVFB((regindex * 2) + 1));
1109 bits = IXGBE_READ_REG(hw,
1110 IXGBE_VLVFB((regindex * 2) + 1));
1111 bits &= ~(1 << vind);
1113 IXGBE_VLVFB((regindex * 2) + 1), bits);
1114 bits |= IXGBE_READ_REG(hw,
1115 IXGBE_VLVFB(regindex * 2));
1120 IXGBE_WRITE_REG(hw, IXGBE_VLVF(regindex),
1121 (IXGBE_VLVF_VIEN | vlan));
1123 IXGBE_WRITE_REG(hw, IXGBE_VLVF(regindex), 0);
1131 * ixgbe_clear_vfta_82599 - Clear VLAN filter table
1132 * @hw: pointer to hardware structure
1134 * Clears the VLAN filer table, and the VMDq index associated with the filter
1136 s32 ixgbe_clear_vfta_82599(struct ixgbe_hw *hw)
1140 for (offset = 0; offset < hw->mac.vft_size; offset++)
1141 IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);
1143 for (offset = 0; offset < IXGBE_VLVF_ENTRIES; offset++) {
1144 IXGBE_WRITE_REG(hw, IXGBE_VLVF(offset), 0);
1145 IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2), 0);
1146 IXGBE_WRITE_REG(hw, IXGBE_VLVFB((offset * 2) + 1), 0);
1153 * ixgbe_init_uta_tables_82599 - Initialize the Unicast Table Array
1154 * @hw: pointer to hardware structure
1156 s32 ixgbe_init_uta_tables_82599(struct ixgbe_hw *hw)
1159 hw_dbg(hw, " Clearing UTA\n");
1161 for (i = 0; i < 128; i++)
1162 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
1168 * ixgbe_read_analog_reg8_82599 - Reads 8 bit Omer analog register
1169 * @hw: pointer to hardware structure
1170 * @reg: analog register to read
1173 * Performs read operation to Omer analog register specified.
1175 s32 ixgbe_read_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 *val)
1179 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, IXGBE_CORECTL_WRITE_CMD |
1181 IXGBE_WRITE_FLUSH(hw);
1183 core_ctl = IXGBE_READ_REG(hw, IXGBE_CORECTL);
1184 *val = (u8)core_ctl;
1190 * ixgbe_write_analog_reg8_82599 - Writes 8 bit Omer analog register
1191 * @hw: pointer to hardware structure
1192 * @reg: atlas register to write
1193 * @val: value to write
1195 * Performs write operation to Omer analog register specified.
1197 s32 ixgbe_write_analog_reg8_82599(struct ixgbe_hw *hw, u32 reg, u8 val)
1201 core_ctl = (reg << 8) | val;
1202 IXGBE_WRITE_REG(hw, IXGBE_CORECTL, core_ctl);
1203 IXGBE_WRITE_FLUSH(hw);
1210 * ixgbe_start_hw_82599 - Prepare hardware for Tx/Rx
1211 * @hw: pointer to hardware structure
1213 * Starts the hardware using the generic start_hw function.
1214 * Then performs device-specific:
1215 * Clears the rate limiter registers.
1217 s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
1221 ixgbe_start_hw_generic(hw);
1223 /* Clear the rate limiters */
1224 for (q_num = 0; q_num < hw->mac.max_tx_queues; q_num++) {
1225 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, q_num);
1226 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, 0);
1228 IXGBE_WRITE_FLUSH(hw);
1230 /* We need to run link autotry after the driver loads */
1231 hw->mac.autotry_restart = true;
1237 * ixgbe_identify_phy_82599 - Get physical layer module
1238 * @hw: pointer to hardware structure
1240 * Determines the physical layer module found on the current adapter.
1242 s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
1244 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1245 status = ixgbe_identify_phy_generic(hw);
1247 status = ixgbe_identify_sfp_module_generic(hw);
1252 * ixgbe_get_supported_physical_layer_82599 - Returns physical layer type
1253 * @hw: pointer to hardware structure
1255 * Determines physical layer capabilities of the current configuration.
1257 u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw)
1259 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1260 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1261 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1262 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
1263 u32 pma_pmd_10g_parallel = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
1264 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
1265 u16 ext_ability = 0;
1266 u8 comp_codes_10g = 0;
1268 hw->phy.ops.identify(hw);
1270 if (hw->phy.type == ixgbe_phy_tn ||
1271 hw->phy.type == ixgbe_phy_cu_unknown) {
1272 hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
1274 if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
1275 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
1276 if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
1277 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
1278 if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
1279 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
1283 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
1284 case IXGBE_AUTOC_LMS_1G_AN:
1285 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
1286 if (pma_pmd_1g == IXGBE_AUTOC_1G_KX_BX) {
1287 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
1288 IXGBE_PHYSICAL_LAYER_1000BASE_BX;
1291 /* SFI mode so read SFP module */
1294 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
1295 if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_CX4)
1296 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
1297 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_KX4)
1298 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
1299 else if (pma_pmd_10g_parallel == IXGBE_AUTOC_10G_XAUI)
1300 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_XAUI;
1303 case IXGBE_AUTOC_LMS_10G_SERIAL:
1304 if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_KR) {
1305 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR;
1307 } else if (pma_pmd_10g_serial == IXGBE_AUTOC2_10G_SFI)
1310 case IXGBE_AUTOC_LMS_KX4_KX_KR:
1311 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
1312 if (autoc & IXGBE_AUTOC_KX_SUPP)
1313 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
1314 if (autoc & IXGBE_AUTOC_KX4_SUPP)
1315 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
1316 if (autoc & IXGBE_AUTOC_KR_SUPP)
1317 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KR;
1326 /* SFP check must be done last since DA modules are sometimes used to
1327 * test KR mode - we need to id KR mode correctly before SFP module.
1328 * Call identify_sfp because the pluggable module may have changed */
1329 hw->phy.ops.identify_sfp(hw);
1330 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1333 switch (hw->phy.type) {
1334 case ixgbe_phy_tw_tyco:
1335 case ixgbe_phy_tw_unknown:
1336 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1338 case ixgbe_phy_sfp_avago:
1339 case ixgbe_phy_sfp_ftl:
1340 case ixgbe_phy_sfp_intel:
1341 case ixgbe_phy_sfp_unknown:
1342 hw->phy.ops.read_i2c_eeprom(hw,
1343 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1344 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1345 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1346 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1347 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1354 return physical_layer;
1358 * ixgbe_enable_rx_dma_82599 - Enable the Rx DMA unit on 82599
1359 * @hw: pointer to hardware structure
1360 * @regval: register value to write to RXCTRL
1362 * Enables the Rx DMA unit for 82599
1364 s32 ixgbe_enable_rx_dma_82599(struct ixgbe_hw *hw, u32 regval)
1366 #define IXGBE_MAX_SECRX_POLL 30
1371 * Workaround for 82599 silicon errata when enabling the Rx datapath.
1372 * If traffic is incoming before we enable the Rx unit, it could hang
1373 * the Rx DMA unit. Therefore, make sure the security engine is
1374 * completely disabled prior to enabling the Rx unit.
1376 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
1377 secrxreg |= IXGBE_SECRXCTRL_RX_DIS;
1378 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg);
1379 for (i = 0; i < IXGBE_MAX_SECRX_POLL; i++) {
1380 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT);
1381 if (secrxreg & IXGBE_SECRXSTAT_SECRX_RDY)
1387 /* For informational purposes only */
1388 if (i >= IXGBE_MAX_SECRX_POLL)
1389 hw_dbg(hw, "Rx unit being enabled before security "
1390 "path fully disabled. Continuing with init.\n");
1392 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval);
1393 secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
1394 secrxreg &= ~IXGBE_SECRXCTRL_RX_DIS;
1395 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg);
1396 IXGBE_WRITE_FLUSH(hw);
1402 * ixgbe_get_device_caps_82599 - Get additional device capabilities
1403 * @hw: pointer to hardware structure
1404 * @device_caps: the EEPROM word with the extra device capabilities
1406 * This function will read the EEPROM location for the device capabilities,
1407 * and return the word through device_caps.
1409 s32 ixgbe_get_device_caps_82599(struct ixgbe_hw *hw, u16 *device_caps)
1411 hw->eeprom.ops.read(hw, IXGBE_DEVICE_CAPS, device_caps);
1417 * ixgbe_get_san_mac_addr_offset_82599 - SAN MAC address offset for 82599
1418 * @hw: pointer to hardware structure
1419 * @san_mac_offset: SAN MAC address offset
1421 * This function will read the EEPROM location for the SAN MAC address
1422 * pointer, and returns the value at that location. This is used in both
1423 * get and set mac_addr routines.
1425 s32 ixgbe_get_san_mac_addr_offset_82599(struct ixgbe_hw *hw,
1426 u16 *san_mac_offset)
1429 * First read the EEPROM pointer to see if the MAC addresses are
1432 hw->eeprom.ops.read(hw, IXGBE_SAN_MAC_ADDR_PTR, san_mac_offset);
1438 * ixgbe_get_san_mac_addr_82599 - SAN MAC address retrieval for 82599
1439 * @hw: pointer to hardware structure
1440 * @san_mac_addr: SAN MAC address
1442 * Reads the SAN MAC address from the EEPROM, if it's available. This is
1443 * per-port, so set_lan_id() must be called before reading the addresses.
1444 * set_lan_id() is called by identify_sfp(), but this cannot be relied
1445 * upon for non-SFP connections, so we must call it here.
1447 s32 ixgbe_get_san_mac_addr_82599(struct ixgbe_hw *hw, u8 *san_mac_addr)
1449 u16 san_mac_data, san_mac_offset;
1453 * First read the EEPROM pointer to see if the MAC addresses are
1454 * available. If they're not, no point in calling set_lan_id() here.
1456 ixgbe_get_san_mac_addr_offset_82599(hw, &san_mac_offset);
1458 if ((san_mac_offset == 0) || (san_mac_offset == 0xFFFF)) {
1460 * No addresses available in this EEPROM. It's not an
1461 * error though, so just wipe the local address and return.
1463 for (i = 0; i < 6; i++)
1464 san_mac_addr[i] = 0xFF;
1466 goto san_mac_addr_out;
1469 /* make sure we know which port we need to program */
1470 hw->mac.ops.set_lan_id(hw);
1471 /* apply the port offset to the address offset */
1472 (hw->bus.func) ? (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT1_OFFSET) :
1473 (san_mac_offset += IXGBE_SAN_MAC_ADDR_PORT0_OFFSET);
1474 for (i = 0; i < 3; i++) {
1475 hw->eeprom.ops.read(hw, san_mac_offset, &san_mac_data);
1476 san_mac_addr[i * 2] = (u8)(san_mac_data);
1477 san_mac_addr[i * 2 + 1] = (u8)(san_mac_data >> 8);
1485 static struct ixgbe_mac_operations mac_ops_82599 = {
1486 .init_hw = &ixgbe_init_hw_generic,
1487 .reset_hw = &ixgbe_reset_hw_82599,
1488 .start_hw = &ixgbe_start_hw_82599,
1489 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
1490 .get_media_type = &ixgbe_get_media_type_82599,
1491 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82599,
1492 .enable_rx_dma = &ixgbe_enable_rx_dma_82599,
1493 .get_mac_addr = &ixgbe_get_mac_addr_generic,
1494 .get_san_mac_addr = &ixgbe_get_san_mac_addr_82599,
1495 .get_device_caps = &ixgbe_get_device_caps_82599,
1496 .stop_adapter = &ixgbe_stop_adapter_generic,
1497 .get_bus_info = &ixgbe_get_bus_info_generic,
1498 .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie,
1499 .read_analog_reg8 = &ixgbe_read_analog_reg8_82599,
1500 .write_analog_reg8 = &ixgbe_write_analog_reg8_82599,
1501 .setup_link = &ixgbe_setup_mac_link_82599,
1502 .setup_link_speed = &ixgbe_setup_mac_link_speed_82599,
1503 .check_link = &ixgbe_check_mac_link_82599,
1504 .get_link_capabilities = &ixgbe_get_link_capabilities_82599,
1505 .led_on = &ixgbe_led_on_generic,
1506 .led_off = &ixgbe_led_off_generic,
1507 .blink_led_start = &ixgbe_blink_led_start_generic,
1508 .blink_led_stop = &ixgbe_blink_led_stop_generic,
1509 .set_rar = &ixgbe_set_rar_generic,
1510 .clear_rar = &ixgbe_clear_rar_generic,
1511 .set_vmdq = &ixgbe_set_vmdq_82599,
1512 .clear_vmdq = &ixgbe_clear_vmdq_82599,
1513 .init_rx_addrs = &ixgbe_init_rx_addrs_generic,
1514 .update_uc_addr_list = &ixgbe_update_uc_addr_list_generic,
1515 .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,
1516 .enable_mc = &ixgbe_enable_mc_generic,
1517 .disable_mc = &ixgbe_disable_mc_generic,
1518 .clear_vfta = &ixgbe_clear_vfta_82599,
1519 .set_vfta = &ixgbe_set_vfta_82599,
1520 .fc_enable = &ixgbe_fc_enable_generic,
1521 .init_uta_tables = &ixgbe_init_uta_tables_82599,
1522 .setup_sfp = &ixgbe_setup_sfp_modules_82599,
1525 static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
1526 .init_params = &ixgbe_init_eeprom_params_generic,
1527 .read = &ixgbe_read_eeprom_generic,
1528 .write = &ixgbe_write_eeprom_generic,
1529 .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
1530 .update_checksum = &ixgbe_update_eeprom_checksum_generic,
1533 static struct ixgbe_phy_operations phy_ops_82599 = {
1534 .identify = &ixgbe_identify_phy_82599,
1535 .identify_sfp = &ixgbe_identify_sfp_module_generic,
1536 .init = &ixgbe_init_phy_ops_82599,
1537 .reset = &ixgbe_reset_phy_generic,
1538 .read_reg = &ixgbe_read_phy_reg_generic,
1539 .write_reg = &ixgbe_write_phy_reg_generic,
1540 .setup_link = &ixgbe_setup_phy_link_generic,
1541 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
1542 .read_i2c_byte = &ixgbe_read_i2c_byte_generic,
1543 .write_i2c_byte = &ixgbe_write_i2c_byte_generic,
1544 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic,
1545 .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic,
1548 struct ixgbe_info ixgbe_82599_info = {
1549 .mac = ixgbe_mac_82599EB,
1550 .get_invariants = &ixgbe_get_invariants_82599,
1551 .mac_ops = &mac_ops_82599,
1552 .eeprom_ops = &eeprom_ops_82599,
1553 .phy_ops = &phy_ops_82599,