1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2008 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_82598_MAX_TX_QUEUES 32
36 #define IXGBE_82598_MAX_RX_QUEUES 64
37 #define IXGBE_82598_RAR_ENTRIES 16
38 #define IXGBE_82598_MC_TBL_SIZE 128
39 #define IXGBE_82598_VFT_TBL_SIZE 128
41 static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
42 ixgbe_link_speed *speed,
44 static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw);
45 static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,
46 ixgbe_link_speed speed,
48 bool autoneg_wait_to_complete);
52 static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
54 struct ixgbe_mac_info *mac = &hw->mac;
55 struct ixgbe_phy_info *phy = &hw->phy;
57 /* Call PHY identify routine to get the phy type */
58 ixgbe_identify_phy_generic(hw);
63 phy->ops.check_link = &ixgbe_check_phy_link_tnx;
64 phy->ops.get_firmware_version =
65 &ixgbe_get_phy_firmware_version_tnx;
71 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
72 mac->ops.setup_link = &ixgbe_setup_copper_link_82598;
73 mac->ops.setup_link_speed =
74 &ixgbe_setup_copper_link_speed_82598;
75 mac->ops.get_link_capabilities =
76 &ixgbe_get_copper_link_capabilities_82598;
79 mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
80 mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
81 mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
82 mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
83 mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
89 * ixgbe_get_link_capabilities_82598 - Determines link capabilities
90 * @hw: pointer to hardware structure
91 * @speed: pointer to link speed
92 * @autoneg: boolean auto-negotiation value
94 * Determines the link capabilities by reading the AUTOC register.
96 static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
97 ixgbe_link_speed *speed,
103 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
105 if (hw->mac.link_settings_loaded) {
106 autoc_reg &= ~IXGBE_AUTOC_LMS_ATTACH_TYPE;
107 autoc_reg &= ~IXGBE_AUTOC_LMS_MASK;
108 autoc_reg |= hw->mac.link_attach_type;
109 autoc_reg |= hw->mac.link_mode_select;
112 switch (autoc_reg & IXGBE_AUTOC_LMS_MASK) {
113 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
114 *speed = IXGBE_LINK_SPEED_1GB_FULL;
118 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
119 *speed = IXGBE_LINK_SPEED_10GB_FULL;
123 case IXGBE_AUTOC_LMS_1G_AN:
124 *speed = IXGBE_LINK_SPEED_1GB_FULL;
128 case IXGBE_AUTOC_LMS_KX4_AN:
129 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
130 *speed = IXGBE_LINK_SPEED_UNKNOWN;
131 if (autoc_reg & IXGBE_AUTOC_KX4_SUPP)
132 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
133 if (autoc_reg & IXGBE_AUTOC_KX_SUPP)
134 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
139 status = IXGBE_ERR_LINK_SETUP;
147 * ixgbe_get_copper_link_capabilities_82598 - Determines link capabilities
148 * @hw: pointer to hardware structure
149 * @speed: pointer to link speed
150 * @autoneg: boolean auto-negotiation value
152 * Determines the link capabilities by reading the AUTOC register.
154 s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
155 ixgbe_link_speed *speed,
158 s32 status = IXGBE_ERR_LINK_SETUP;
164 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
165 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
169 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
170 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
171 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
172 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
179 * ixgbe_get_media_type_82598 - Determines media type
180 * @hw: pointer to hardware structure
182 * Returns the media type (fiber, copper, backplane)
184 static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
186 enum ixgbe_media_type media_type;
188 /* Media type for I82598 is based on device ID */
189 switch (hw->device_id) {
190 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
191 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
192 case IXGBE_DEV_ID_82598EB_CX4:
193 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
194 case IXGBE_DEV_ID_82598EB_XF_LR:
195 media_type = ixgbe_media_type_fiber;
197 case IXGBE_DEV_ID_82598AT:
198 media_type = ixgbe_media_type_copper;
201 media_type = ixgbe_media_type_unknown;
209 * ixgbe_setup_fc_82598 - Configure flow control settings
210 * @hw: pointer to hardware structure
211 * @packetbuf_num: packet buffer number (0-7)
213 * Configures the flow control settings based on SW configuration. This
214 * function is used for 802.3x flow control configuration only.
216 s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
221 if (packetbuf_num < 0 || packetbuf_num > 7) {
222 hw_dbg(hw, "Invalid packet buffer number [%d], expected range is"
223 " 0-7\n", packetbuf_num);
226 frctl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);
227 frctl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);
229 rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS);
230 rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X);
233 * 10 gig parts do not have a word in the EEPROM to determine the
234 * default flow control setting, so we explicitly set it to full.
236 if (hw->fc.type == ixgbe_fc_default)
237 hw->fc.type = ixgbe_fc_full;
240 * We want to save off the original Flow Control configuration just in
241 * case we get disconnected and then reconnected into a different hub
242 * or switch with different Flow Control capabilities.
244 hw->fc.original_type = hw->fc.type;
247 * The possible values of the "flow_control" parameter are:
248 * 0: Flow control is completely disabled
249 * 1: Rx flow control is enabled (we can receive pause frames but not
250 * send pause frames).
251 * 2: Tx flow control is enabled (we can send pause frames but we do not
252 * support receiving pause frames)
253 * 3: Both Rx and Tx flow control (symmetric) are enabled.
256 switch (hw->fc.type) {
259 case ixgbe_fc_rx_pause:
261 * Rx Flow control is enabled,
262 * and Tx Flow control is disabled.
264 frctl_reg |= IXGBE_FCTRL_RFCE;
266 case ixgbe_fc_tx_pause:
268 * Tx Flow control is enabled, and Rx Flow control is disabled,
269 * by a software over-ride.
271 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
275 * Flow control (both Rx and Tx) is enabled by a software
278 frctl_reg |= IXGBE_FCTRL_RFCE;
279 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
282 /* We should never get here. The value should be 0-3. */
283 hw_dbg(hw, "Flow control param set incorrectly\n");
287 /* Enable 802.3x based flow control settings. */
288 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, frctl_reg);
289 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
292 * Check for invalid software configuration, zeros are completely
293 * invalid for all parameters used past this point, and if we enable
294 * flow control with zero water marks, we blast flow control packets.
296 if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
297 hw_dbg(hw, "Flow control structure initialized incorrectly\n");
298 return IXGBE_ERR_INVALID_LINK_SETTINGS;
302 * We need to set up the Receive Threshold high and low water
303 * marks as well as (optionally) enabling the transmission of
306 if (hw->fc.type & ixgbe_fc_tx_pause) {
307 if (hw->fc.send_xon) {
308 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),
309 (hw->fc.low_water | IXGBE_FCRTL_XONE));
311 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),
314 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num),
315 (hw->fc.high_water)|IXGBE_FCRTH_FCEN);
318 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(0), hw->fc.pause_time);
319 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1));
325 * ixgbe_setup_mac_link_82598 - Configures MAC link settings
326 * @hw: pointer to hardware structure
328 * Configures link settings based on values in the ixgbe_hw struct.
329 * Restarts the link. Performs autonegotiation if needed.
331 static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)
338 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
340 if (hw->mac.link_settings_loaded) {
341 autoc_reg &= ~IXGBE_AUTOC_LMS_ATTACH_TYPE;
342 autoc_reg &= ~IXGBE_AUTOC_LMS_MASK;
343 autoc_reg |= hw->mac.link_attach_type;
344 autoc_reg |= hw->mac.link_mode_select;
346 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
347 IXGBE_WRITE_FLUSH(hw);
352 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
353 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
355 /* Only poll for autoneg to complete if specified to do so */
356 if (hw->phy.autoneg_wait_to_complete) {
357 if (hw->mac.link_mode_select == IXGBE_AUTOC_LMS_KX4_AN ||
358 hw->mac.link_mode_select == IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {
359 links_reg = 0; /* Just in case Autoneg time = 0 */
360 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
361 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
362 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
366 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
367 status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
368 hw_dbg(hw, "Autonegotiation did not complete.\n");
374 * We want to save off the original Flow Control configuration just in
375 * case we get disconnected and then reconnected into a different hub
376 * or switch with different Flow Control capabilities.
378 hw->fc.original_type = hw->fc.type;
379 ixgbe_setup_fc_82598(hw, 0);
381 /* Add delay to filter out noises during initial link setup */
388 * ixgbe_check_mac_link_82598 - Get link/speed status
389 * @hw: pointer to hardware structure
390 * @speed: pointer to link speed
391 * @link_up: true is link is up, false otherwise
392 * @link_up_wait_to_complete: bool used to wait for link up or not
394 * Reads the links register to determine if link is up and the current speed
396 static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
397 ixgbe_link_speed *speed, bool *link_up,
398 bool link_up_wait_to_complete)
403 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
404 if (link_up_wait_to_complete) {
405 for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
406 if (links_reg & IXGBE_LINKS_UP) {
413 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
416 if (links_reg & IXGBE_LINKS_UP)
422 if (links_reg & IXGBE_LINKS_SPEED)
423 *speed = IXGBE_LINK_SPEED_10GB_FULL;
425 *speed = IXGBE_LINK_SPEED_1GB_FULL;
432 * ixgbe_setup_mac_link_speed_82598 - Set MAC link speed
433 * @hw: pointer to hardware structure
434 * @speed: new link speed
435 * @autoneg: true if auto-negotiation enabled
436 * @autoneg_wait_to_complete: true if waiting is needed to complete
438 * Set the link speed in the AUTOC register and restarts link.
440 static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw,
441 ixgbe_link_speed speed, bool autoneg,
442 bool autoneg_wait_to_complete)
446 /* If speed is 10G, then check for CX4 or XAUI. */
447 if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&
448 (!(hw->mac.link_attach_type & IXGBE_AUTOC_10G_KX4))) {
449 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_10G_LINK_NO_AN;
450 } else if ((speed == IXGBE_LINK_SPEED_1GB_FULL) && (!autoneg)) {
451 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
452 } else if (autoneg) {
453 /* BX mode - Autonegotiate 1G */
454 if (!(hw->mac.link_attach_type & IXGBE_AUTOC_1G_PMA_PMD))
455 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_1G_AN;
456 else /* KX/KX4 mode */
457 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN_1G_AN;
459 status = IXGBE_ERR_LINK_SETUP;
463 hw->phy.autoneg_wait_to_complete = autoneg_wait_to_complete;
465 hw->mac.link_settings_loaded = true;
467 * Setup and restart the link based on the new values in
468 * ixgbe_hw This will write the AUTOC register based on the new
471 ixgbe_setup_mac_link_82598(hw);
479 * ixgbe_setup_copper_link_82598 - Setup copper link settings
480 * @hw: pointer to hardware structure
482 * Configures link settings based on values in the ixgbe_hw struct.
483 * Restarts the link. Performs autonegotiation if needed. Restart
484 * phy and wait for autonegotiate to finish. Then synchronize the
487 static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw)
491 /* Restart autonegotiation on PHY */
492 status = hw->phy.ops.setup_link(hw);
494 /* Set MAC to KX/KX4 autoneg, which defaults to Parallel detection */
495 hw->mac.link_attach_type = (IXGBE_AUTOC_10G_KX4 | IXGBE_AUTOC_1G_KX);
496 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN;
499 ixgbe_setup_mac_link_82598(hw);
505 * ixgbe_setup_copper_link_speed_82598 - Set the PHY autoneg advertised field
506 * @hw: pointer to hardware structure
507 * @speed: new link speed
508 * @autoneg: true if autonegotiation enabled
509 * @autoneg_wait_to_complete: true if waiting is needed to complete
511 * Sets the link speed in the AUTOC register in the MAC and restarts link.
513 static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,
514 ixgbe_link_speed speed,
516 bool autoneg_wait_to_complete)
520 /* Setup the PHY according to input speed */
521 status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
522 autoneg_wait_to_complete);
524 /* Set MAC to KX/KX4 autoneg, which defaults to Parallel detection */
525 hw->mac.link_attach_type = (IXGBE_AUTOC_10G_KX4 | IXGBE_AUTOC_1G_KX);
526 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN;
529 ixgbe_setup_mac_link_82598(hw);
535 * ixgbe_reset_hw_82598 - Performs hardware reset
536 * @hw: pointer to hardware structure
538 * Resets the hardware by resetting the transmit and receive units, masks and
539 * clears all interrupts, performing a PHY reset, and performing a link (MAC)
542 static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
551 /* Call adapter stop to disable tx/rx and clear interrupts */
552 hw->mac.ops.stop_adapter(hw);
555 * Power up the Atlas Tx lanes if they are currently powered down.
556 * Atlas Tx lanes are powered down for MAC loopback tests, but
557 * they are not automatically restored on reset.
559 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val);
560 if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) {
561 /* Enable Tx Atlas so packets can be transmitted again */
562 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
564 analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN;
565 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
568 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
570 analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL;
571 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
574 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
576 analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL;
577 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
580 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
582 analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL;
583 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
588 if (hw->phy.reset_disable == false)
589 hw->phy.ops.reset(hw);
592 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
593 * access and verify no pending requests before reset
595 if (ixgbe_disable_pcie_master(hw) != 0) {
596 status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
597 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
601 * Issue global reset to the MAC. This needs to be a SW reset.
602 * If link reset is used, it might reset the MAC when mng is using it
604 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
605 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST));
606 IXGBE_WRITE_FLUSH(hw);
608 /* Poll for reset bit to self-clear indicating reset is complete */
609 for (i = 0; i < 10; i++) {
611 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
612 if (!(ctrl & IXGBE_CTRL_RST))
615 if (ctrl & IXGBE_CTRL_RST) {
616 status = IXGBE_ERR_RESET_FAILED;
617 hw_dbg(hw, "Reset polling failed to complete.\n");
622 gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR);
623 gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6));
624 IXGBE_WRITE_REG(hw, IXGBE_GHECCR, gheccr);
627 * AUTOC register which stores link settings gets cleared
628 * and reloaded from EEPROM after reset. We need to restore
629 * our stored value from init in case SW changed the attach
630 * type or speed. If this is the first time and link settings
631 * have not been stored, store default settings from AUTOC.
633 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
634 if (hw->mac.link_settings_loaded) {
635 autoc &= ~(IXGBE_AUTOC_LMS_ATTACH_TYPE);
636 autoc &= ~(IXGBE_AUTOC_LMS_MASK);
637 autoc |= hw->mac.link_attach_type;
638 autoc |= hw->mac.link_mode_select;
639 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
641 hw->mac.link_attach_type =
642 (autoc & IXGBE_AUTOC_LMS_ATTACH_TYPE);
643 hw->mac.link_mode_select = (autoc & IXGBE_AUTOC_LMS_MASK);
644 hw->mac.link_settings_loaded = true;
647 /* Store the permanent mac address */
648 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
654 * ixgbe_set_vmdq_82598 - Associate a VMDq set index with a rx address
655 * @hw: pointer to hardware struct
656 * @rar: receive address register index to associate with a VMDq index
657 * @vmdq: VMDq set index
659 s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
663 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
664 rar_high &= ~IXGBE_RAH_VIND_MASK;
665 rar_high |= ((vmdq << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK);
666 IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
671 * ixgbe_clear_vmdq_82598 - Disassociate a VMDq set index from an rx address
672 * @hw: pointer to hardware struct
673 * @rar: receive address register index to associate with a VMDq index
674 * @vmdq: VMDq clear index (not used in 82598, but elsewhere)
676 static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
679 u32 rar_entries = hw->mac.num_rar_entries;
681 if (rar < rar_entries) {
682 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
683 if (rar_high & IXGBE_RAH_VIND_MASK) {
684 rar_high &= ~IXGBE_RAH_VIND_MASK;
685 IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
688 hw_dbg(hw, "RAR index %d is out of range.\n", rar);
695 * ixgbe_set_vfta_82598 - Set VLAN filter table
696 * @hw: pointer to hardware structure
697 * @vlan: VLAN id to write to VLAN filter
698 * @vind: VMDq output index that maps queue to VLAN id in VFTA
699 * @vlan_on: boolean flag to turn on/off VLAN in VFTA
701 * Turn on/off specified VLAN in the VLAN filter table.
703 s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
712 return IXGBE_ERR_PARAM;
714 /* Determine 32-bit word position in array */
715 regindex = (vlan >> 5) & 0x7F; /* upper seven bits */
717 /* Determine the location of the (VMD) queue index */
718 vftabyte = ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */
719 bitindex = (vlan & 0x7) << 2; /* lower 3 bits indicate nibble */
721 /* Set the nibble for VMD queue index */
722 bits = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex));
723 bits &= (~(0x0F << bitindex));
724 bits |= (vind << bitindex);
725 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex), bits);
727 /* Determine the location of the bit for this VLAN id */
728 bitindex = vlan & 0x1F; /* lower five bits */
730 bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
732 /* Turn on this VLAN id */
733 bits |= (1 << bitindex);
735 /* Turn off this VLAN id */
736 bits &= ~(1 << bitindex);
737 IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
743 * ixgbe_clear_vfta_82598 - Clear VLAN filter table
744 * @hw: pointer to hardware structure
746 * Clears the VLAN filer table, and the VMDq index associated with the filter
748 static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw)
753 for (offset = 0; offset < hw->mac.vft_size; offset++)
754 IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);
756 for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)
757 for (offset = 0; offset < hw->mac.vft_size; offset++)
758 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset),
765 * ixgbe_blink_led_start_82598 - Blink LED based on index.
766 * @hw: pointer to hardware structure
767 * @index: led number to blink
769 static s32 ixgbe_blink_led_start_82598(struct ixgbe_hw *hw, u32 index)
771 ixgbe_link_speed speed = 0;
773 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
774 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
777 * Link must be up to auto-blink the LEDs on the 82598EB MAC;
778 * force it if link is down.
780 hw->mac.ops.check_link(hw, &speed, &link_up, false);
783 autoc_reg |= IXGBE_AUTOC_FLU;
784 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
788 led_reg &= ~IXGBE_LED_MODE_MASK(index);
789 led_reg |= IXGBE_LED_BLINK(index);
790 IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);
791 IXGBE_WRITE_FLUSH(hw);
797 * ixgbe_blink_led_stop_82598 - Stop blinking LED based on index.
798 * @hw: pointer to hardware structure
799 * @index: led number to stop blinking
801 static s32 ixgbe_blink_led_stop_82598(struct ixgbe_hw *hw, u32 index)
803 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
804 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
806 autoc_reg &= ~IXGBE_AUTOC_FLU;
807 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
808 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
810 led_reg &= ~IXGBE_LED_MODE_MASK(index);
811 led_reg &= ~IXGBE_LED_BLINK(index);
812 led_reg |= IXGBE_LED_LINK_ACTIVE << IXGBE_LED_MODE_SHIFT(index);
813 IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);
814 IXGBE_WRITE_FLUSH(hw);
820 * ixgbe_read_analog_reg8_82598 - Reads 8 bit Atlas analog register
821 * @hw: pointer to hardware structure
822 * @reg: analog register to read
825 * Performs read operation to Atlas analog register specified.
827 s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)
831 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL,
832 IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));
833 IXGBE_WRITE_FLUSH(hw);
835 atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL);
836 *val = (u8)atlas_ctl;
842 * ixgbe_write_analog_reg8_82598 - Writes 8 bit Atlas analog register
843 * @hw: pointer to hardware structure
844 * @reg: atlas register to write
845 * @val: value to write
847 * Performs write operation to Atlas analog register specified.
849 s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)
853 atlas_ctl = (reg << 8) | val;
854 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);
855 IXGBE_WRITE_FLUSH(hw);
862 * ixgbe_get_supported_physical_layer_82598 - Returns physical layer type
863 * @hw: pointer to hardware structure
865 * Determines physical layer capabilities of the current configuration.
867 s32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
869 s32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
871 switch (hw->device_id) {
872 case IXGBE_DEV_ID_82598EB_CX4:
873 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
874 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
876 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
877 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
878 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
880 case IXGBE_DEV_ID_82598EB_XF_LR:
881 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
883 case IXGBE_DEV_ID_82598AT:
884 physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_T |
885 IXGBE_PHYSICAL_LAYER_1000BASE_T);
889 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
893 return physical_layer;
896 static struct ixgbe_mac_operations mac_ops_82598 = {
897 .init_hw = &ixgbe_init_hw_generic,
898 .reset_hw = &ixgbe_reset_hw_82598,
899 .start_hw = &ixgbe_start_hw_generic,
900 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
901 .get_media_type = &ixgbe_get_media_type_82598,
902 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82598,
903 .get_mac_addr = &ixgbe_get_mac_addr_generic,
904 .stop_adapter = &ixgbe_stop_adapter_generic,
905 .read_analog_reg8 = &ixgbe_read_analog_reg8_82598,
906 .write_analog_reg8 = &ixgbe_write_analog_reg8_82598,
907 .setup_link = &ixgbe_setup_mac_link_82598,
908 .setup_link_speed = &ixgbe_setup_mac_link_speed_82598,
909 .check_link = &ixgbe_check_mac_link_82598,
910 .get_link_capabilities = &ixgbe_get_link_capabilities_82598,
911 .led_on = &ixgbe_led_on_generic,
912 .led_off = &ixgbe_led_off_generic,
913 .blink_led_start = &ixgbe_blink_led_start_82598,
914 .blink_led_stop = &ixgbe_blink_led_stop_82598,
915 .set_rar = &ixgbe_set_rar_generic,
916 .clear_rar = &ixgbe_clear_rar_generic,
917 .set_vmdq = &ixgbe_set_vmdq_82598,
918 .clear_vmdq = &ixgbe_clear_vmdq_82598,
919 .init_rx_addrs = &ixgbe_init_rx_addrs_generic,
920 .update_uc_addr_list = &ixgbe_update_uc_addr_list_generic,
921 .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,
922 .enable_mc = &ixgbe_enable_mc_generic,
923 .disable_mc = &ixgbe_disable_mc_generic,
924 .clear_vfta = &ixgbe_clear_vfta_82598,
925 .set_vfta = &ixgbe_set_vfta_82598,
926 .setup_fc = &ixgbe_setup_fc_82598,
929 static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
930 .init_params = &ixgbe_init_eeprom_params_generic,
931 .read = &ixgbe_read_eeprom_generic,
932 .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
933 .update_checksum = &ixgbe_update_eeprom_checksum_generic,
936 static struct ixgbe_phy_operations phy_ops_82598 = {
937 .identify = &ixgbe_identify_phy_generic,
938 /* .identify_sfp = &ixgbe_identify_sfp_module_generic, */
939 .reset = &ixgbe_reset_phy_generic,
940 .read_reg = &ixgbe_read_phy_reg_generic,
941 .write_reg = &ixgbe_write_phy_reg_generic,
942 .setup_link = &ixgbe_setup_phy_link_generic,
943 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
946 struct ixgbe_info ixgbe_82598_info = {
947 .mac = ixgbe_mac_82598EB,
948 .get_invariants = &ixgbe_get_invariants_82598,
949 .mac_ops = &mac_ops_82598,
950 .eeprom_ops = &eeprom_ops_82598,
951 .phy_ops = &phy_ops_82598,