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);
66 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
67 mac->ops.setup_link = &ixgbe_setup_copper_link_82598;
68 mac->ops.setup_link_speed =
69 &ixgbe_setup_copper_link_speed_82598;
70 mac->ops.get_link_capabilities =
71 &ixgbe_get_copper_link_capabilities_82598;
74 mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
75 mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
76 mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
77 mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
78 mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
84 * ixgbe_get_link_capabilities_82598 - Determines link capabilities
85 * @hw: pointer to hardware structure
86 * @speed: pointer to link speed
87 * @autoneg: boolean auto-negotiation value
89 * Determines the link capabilities by reading the AUTOC register.
91 static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
92 ixgbe_link_speed *speed,
98 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
100 if (hw->mac.link_settings_loaded) {
101 autoc_reg &= ~IXGBE_AUTOC_LMS_ATTACH_TYPE;
102 autoc_reg &= ~IXGBE_AUTOC_LMS_MASK;
103 autoc_reg |= hw->mac.link_attach_type;
104 autoc_reg |= hw->mac.link_mode_select;
107 switch (autoc_reg & IXGBE_AUTOC_LMS_MASK) {
108 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
109 *speed = IXGBE_LINK_SPEED_1GB_FULL;
113 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
114 *speed = IXGBE_LINK_SPEED_10GB_FULL;
118 case IXGBE_AUTOC_LMS_1G_AN:
119 *speed = IXGBE_LINK_SPEED_1GB_FULL;
123 case IXGBE_AUTOC_LMS_KX4_AN:
124 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
125 *speed = IXGBE_LINK_SPEED_UNKNOWN;
126 if (autoc_reg & IXGBE_AUTOC_KX4_SUPP)
127 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
128 if (autoc_reg & IXGBE_AUTOC_KX_SUPP)
129 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
134 status = IXGBE_ERR_LINK_SETUP;
142 * ixgbe_get_copper_link_capabilities_82598 - Determines link capabilities
143 * @hw: pointer to hardware structure
144 * @speed: pointer to link speed
145 * @autoneg: boolean auto-negotiation value
147 * Determines the link capabilities by reading the AUTOC register.
149 s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
150 ixgbe_link_speed *speed,
153 s32 status = IXGBE_ERR_LINK_SETUP;
159 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
160 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
164 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
165 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
166 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
167 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
174 * ixgbe_get_media_type_82598 - Determines media type
175 * @hw: pointer to hardware structure
177 * Returns the media type (fiber, copper, backplane)
179 static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
181 enum ixgbe_media_type media_type;
183 /* Media type for I82598 is based on device ID */
184 switch (hw->device_id) {
185 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
186 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
187 case IXGBE_DEV_ID_82598EB_CX4:
188 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
189 case IXGBE_DEV_ID_82598EB_XF_LR:
190 media_type = ixgbe_media_type_fiber;
193 media_type = ixgbe_media_type_unknown;
201 * ixgbe_setup_fc_82598 - Configure flow control settings
202 * @hw: pointer to hardware structure
203 * @packetbuf_num: packet buffer number (0-7)
205 * Configures the flow control settings based on SW configuration. This
206 * function is used for 802.3x flow control configuration only.
208 s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
213 if (packetbuf_num < 0 || packetbuf_num > 7) {
214 hw_dbg(hw, "Invalid packet buffer number [%d], expected range is"
215 " 0-7\n", packetbuf_num);
218 frctl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);
219 frctl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);
221 rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS);
222 rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X);
225 * 10 gig parts do not have a word in the EEPROM to determine the
226 * default flow control setting, so we explicitly set it to full.
228 if (hw->fc.type == ixgbe_fc_default)
229 hw->fc.type = ixgbe_fc_full;
232 * We want to save off the original Flow Control configuration just in
233 * case we get disconnected and then reconnected into a different hub
234 * or switch with different Flow Control capabilities.
236 hw->fc.original_type = hw->fc.type;
239 * The possible values of the "flow_control" parameter are:
240 * 0: Flow control is completely disabled
241 * 1: Rx flow control is enabled (we can receive pause frames but not
242 * send pause frames).
243 * 2: Tx flow control is enabled (we can send pause frames but we do not
244 * support receiving pause frames)
245 * 3: Both Rx and Tx flow control (symmetric) are enabled.
248 switch (hw->fc.type) {
251 case ixgbe_fc_rx_pause:
253 * Rx Flow control is enabled,
254 * and Tx Flow control is disabled.
256 frctl_reg |= IXGBE_FCTRL_RFCE;
258 case ixgbe_fc_tx_pause:
260 * Tx Flow control is enabled, and Rx Flow control is disabled,
261 * by a software over-ride.
263 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
267 * Flow control (both Rx and Tx) is enabled by a software
270 frctl_reg |= IXGBE_FCTRL_RFCE;
271 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
274 /* We should never get here. The value should be 0-3. */
275 hw_dbg(hw, "Flow control param set incorrectly\n");
279 /* Enable 802.3x based flow control settings. */
280 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, frctl_reg);
281 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
284 * Check for invalid software configuration, zeros are completely
285 * invalid for all parameters used past this point, and if we enable
286 * flow control with zero water marks, we blast flow control packets.
288 if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
289 hw_dbg(hw, "Flow control structure initialized incorrectly\n");
290 return IXGBE_ERR_INVALID_LINK_SETTINGS;
294 * We need to set up the Receive Threshold high and low water
295 * marks as well as (optionally) enabling the transmission of
298 if (hw->fc.type & ixgbe_fc_tx_pause) {
299 if (hw->fc.send_xon) {
300 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),
301 (hw->fc.low_water | IXGBE_FCRTL_XONE));
303 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),
306 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num),
307 (hw->fc.high_water)|IXGBE_FCRTH_FCEN);
310 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(0), hw->fc.pause_time);
311 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1));
317 * ixgbe_setup_mac_link_82598 - Configures MAC link settings
318 * @hw: pointer to hardware structure
320 * Configures link settings based on values in the ixgbe_hw struct.
321 * Restarts the link. Performs autonegotiation if needed.
323 static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)
330 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
332 if (hw->mac.link_settings_loaded) {
333 autoc_reg &= ~IXGBE_AUTOC_LMS_ATTACH_TYPE;
334 autoc_reg &= ~IXGBE_AUTOC_LMS_MASK;
335 autoc_reg |= hw->mac.link_attach_type;
336 autoc_reg |= hw->mac.link_mode_select;
338 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
339 IXGBE_WRITE_FLUSH(hw);
344 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
345 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
347 /* Only poll for autoneg to complete if specified to do so */
348 if (hw->phy.autoneg_wait_to_complete) {
349 if (hw->mac.link_mode_select == IXGBE_AUTOC_LMS_KX4_AN ||
350 hw->mac.link_mode_select == IXGBE_AUTOC_LMS_KX4_AN_1G_AN) {
351 links_reg = 0; /* Just in case Autoneg time = 0 */
352 for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
353 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
354 if (links_reg & IXGBE_LINKS_KX_AN_COMP)
358 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
359 status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
360 hw_dbg(hw, "Autonegotiation did not complete.\n");
366 * We want to save off the original Flow Control configuration just in
367 * case we get disconnected and then reconnected into a different hub
368 * or switch with different Flow Control capabilities.
370 hw->fc.original_type = hw->fc.type;
371 ixgbe_setup_fc_82598(hw, 0);
373 /* Add delay to filter out noises during initial link setup */
380 * ixgbe_check_mac_link_82598 - Get link/speed status
381 * @hw: pointer to hardware structure
382 * @speed: pointer to link speed
383 * @link_up: true is link is up, false otherwise
384 * @link_up_wait_to_complete: bool used to wait for link up or not
386 * Reads the links register to determine if link is up and the current speed
388 static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
389 ixgbe_link_speed *speed, bool *link_up,
390 bool link_up_wait_to_complete)
395 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
396 if (link_up_wait_to_complete) {
397 for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
398 if (links_reg & IXGBE_LINKS_UP) {
405 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
408 if (links_reg & IXGBE_LINKS_UP)
414 if (links_reg & IXGBE_LINKS_SPEED)
415 *speed = IXGBE_LINK_SPEED_10GB_FULL;
417 *speed = IXGBE_LINK_SPEED_1GB_FULL;
424 * ixgbe_setup_mac_link_speed_82598 - Set MAC link speed
425 * @hw: pointer to hardware structure
426 * @speed: new link speed
427 * @autoneg: true if auto-negotiation enabled
428 * @autoneg_wait_to_complete: true if waiting is needed to complete
430 * Set the link speed in the AUTOC register and restarts link.
432 static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw,
433 ixgbe_link_speed speed, bool autoneg,
434 bool autoneg_wait_to_complete)
438 /* If speed is 10G, then check for CX4 or XAUI. */
439 if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&
440 (!(hw->mac.link_attach_type & IXGBE_AUTOC_10G_KX4))) {
441 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_10G_LINK_NO_AN;
442 } else if ((speed == IXGBE_LINK_SPEED_1GB_FULL) && (!autoneg)) {
443 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_1G_LINK_NO_AN;
444 } else if (autoneg) {
445 /* BX mode - Autonegotiate 1G */
446 if (!(hw->mac.link_attach_type & IXGBE_AUTOC_1G_PMA_PMD))
447 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_1G_AN;
448 else /* KX/KX4 mode */
449 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN_1G_AN;
451 status = IXGBE_ERR_LINK_SETUP;
455 hw->phy.autoneg_wait_to_complete = autoneg_wait_to_complete;
457 hw->mac.link_settings_loaded = true;
459 * Setup and restart the link based on the new values in
460 * ixgbe_hw This will write the AUTOC register based on the new
463 ixgbe_setup_mac_link_82598(hw);
471 * ixgbe_setup_copper_link_82598 - Setup copper link settings
472 * @hw: pointer to hardware structure
474 * Configures link settings based on values in the ixgbe_hw struct.
475 * Restarts the link. Performs autonegotiation if needed. Restart
476 * phy and wait for autonegotiate to finish. Then synchronize the
479 static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw)
483 /* Restart autonegotiation on PHY */
484 status = hw->phy.ops.setup_link(hw);
486 /* Set MAC to KX/KX4 autoneg, which defaults to Parallel detection */
487 hw->mac.link_attach_type = (IXGBE_AUTOC_10G_KX4 | IXGBE_AUTOC_1G_KX);
488 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN;
491 ixgbe_setup_mac_link_82598(hw);
497 * ixgbe_setup_copper_link_speed_82598 - Set the PHY autoneg advertised field
498 * @hw: pointer to hardware structure
499 * @speed: new link speed
500 * @autoneg: true if autonegotiation enabled
501 * @autoneg_wait_to_complete: true if waiting is needed to complete
503 * Sets the link speed in the AUTOC register in the MAC and restarts link.
505 static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,
506 ixgbe_link_speed speed,
508 bool autoneg_wait_to_complete)
512 /* Setup the PHY according to input speed */
513 status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
514 autoneg_wait_to_complete);
516 /* Set MAC to KX/KX4 autoneg, which defaults to Parallel detection */
517 hw->mac.link_attach_type = (IXGBE_AUTOC_10G_KX4 | IXGBE_AUTOC_1G_KX);
518 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN;
521 ixgbe_setup_mac_link_82598(hw);
527 * ixgbe_reset_hw_82598 - Performs hardware reset
528 * @hw: pointer to hardware structure
530 * Resets the hardware by resetting the transmit and receive units, masks and
531 * clears all interrupts, performing a PHY reset, and performing a link (MAC)
534 static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
543 /* Call adapter stop to disable tx/rx and clear interrupts */
544 hw->mac.ops.stop_adapter(hw);
547 * Power up the Atlas Tx lanes if they are currently powered down.
548 * Atlas Tx lanes are powered down for MAC loopback tests, but
549 * they are not automatically restored on reset.
551 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val);
552 if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) {
553 /* Enable Tx Atlas so packets can be transmitted again */
554 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
556 analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN;
557 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,
560 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
562 analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL;
563 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,
566 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
568 analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL;
569 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,
572 hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
574 analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL;
575 hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,
580 if (hw->phy.reset_disable == false)
581 hw->phy.ops.reset(hw);
584 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
585 * access and verify no pending requests before reset
587 if (ixgbe_disable_pcie_master(hw) != 0) {
588 status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
589 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
593 * Issue global reset to the MAC. This needs to be a SW reset.
594 * If link reset is used, it might reset the MAC when mng is using it
596 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
597 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST));
598 IXGBE_WRITE_FLUSH(hw);
600 /* Poll for reset bit to self-clear indicating reset is complete */
601 for (i = 0; i < 10; i++) {
603 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
604 if (!(ctrl & IXGBE_CTRL_RST))
607 if (ctrl & IXGBE_CTRL_RST) {
608 status = IXGBE_ERR_RESET_FAILED;
609 hw_dbg(hw, "Reset polling failed to complete.\n");
614 gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR);
615 gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6));
616 IXGBE_WRITE_REG(hw, IXGBE_GHECCR, gheccr);
619 * AUTOC register which stores link settings gets cleared
620 * and reloaded from EEPROM after reset. We need to restore
621 * our stored value from init in case SW changed the attach
622 * type or speed. If this is the first time and link settings
623 * have not been stored, store default settings from AUTOC.
625 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
626 if (hw->mac.link_settings_loaded) {
627 autoc &= ~(IXGBE_AUTOC_LMS_ATTACH_TYPE);
628 autoc &= ~(IXGBE_AUTOC_LMS_MASK);
629 autoc |= hw->mac.link_attach_type;
630 autoc |= hw->mac.link_mode_select;
631 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
633 hw->mac.link_attach_type =
634 (autoc & IXGBE_AUTOC_LMS_ATTACH_TYPE);
635 hw->mac.link_mode_select = (autoc & IXGBE_AUTOC_LMS_MASK);
636 hw->mac.link_settings_loaded = true;
639 /* Store the permanent mac address */
640 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
646 * ixgbe_set_vmdq_82598 - Associate a VMDq set index with a rx address
647 * @hw: pointer to hardware struct
648 * @rar: receive address register index to associate with a VMDq index
649 * @vmdq: VMDq set index
651 s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
655 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
656 rar_high &= ~IXGBE_RAH_VIND_MASK;
657 rar_high |= ((vmdq << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK);
658 IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
663 * ixgbe_clear_vmdq_82598 - Disassociate a VMDq set index from an rx address
664 * @hw: pointer to hardware struct
665 * @rar: receive address register index to associate with a VMDq index
666 * @vmdq: VMDq clear index (not used in 82598, but elsewhere)
668 static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
671 u32 rar_entries = hw->mac.num_rar_entries;
673 if (rar < rar_entries) {
674 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
675 if (rar_high & IXGBE_RAH_VIND_MASK) {
676 rar_high &= ~IXGBE_RAH_VIND_MASK;
677 IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
680 hw_dbg(hw, "RAR index %d is out of range.\n", rar);
687 * ixgbe_set_vfta_82598 - Set VLAN filter table
688 * @hw: pointer to hardware structure
689 * @vlan: VLAN id to write to VLAN filter
690 * @vind: VMDq output index that maps queue to VLAN id in VFTA
691 * @vlan_on: boolean flag to turn on/off VLAN in VFTA
693 * Turn on/off specified VLAN in the VLAN filter table.
695 s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
704 return IXGBE_ERR_PARAM;
706 /* Determine 32-bit word position in array */
707 regindex = (vlan >> 5) & 0x7F; /* upper seven bits */
709 /* Determine the location of the (VMD) queue index */
710 vftabyte = ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */
711 bitindex = (vlan & 0x7) << 2; /* lower 3 bits indicate nibble */
713 /* Set the nibble for VMD queue index */
714 bits = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex));
715 bits &= (~(0x0F << bitindex));
716 bits |= (vind << bitindex);
717 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex), bits);
719 /* Determine the location of the bit for this VLAN id */
720 bitindex = vlan & 0x1F; /* lower five bits */
722 bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
724 /* Turn on this VLAN id */
725 bits |= (1 << bitindex);
727 /* Turn off this VLAN id */
728 bits &= ~(1 << bitindex);
729 IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);
735 * ixgbe_clear_vfta_82598 - Clear VLAN filter table
736 * @hw: pointer to hardware structure
738 * Clears the VLAN filer table, and the VMDq index associated with the filter
740 static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw)
745 for (offset = 0; offset < hw->mac.vft_size; offset++)
746 IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);
748 for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)
749 for (offset = 0; offset < hw->mac.vft_size; offset++)
750 IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset),
757 * ixgbe_blink_led_start_82598 - Blink LED based on index.
758 * @hw: pointer to hardware structure
759 * @index: led number to blink
761 static s32 ixgbe_blink_led_start_82598(struct ixgbe_hw *hw, u32 index)
763 ixgbe_link_speed speed = 0;
765 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
766 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
769 * Link must be up to auto-blink the LEDs on the 82598EB MAC;
770 * force it if link is down.
772 hw->mac.ops.check_link(hw, &speed, &link_up, false);
775 autoc_reg |= IXGBE_AUTOC_FLU;
776 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
780 led_reg &= ~IXGBE_LED_MODE_MASK(index);
781 led_reg |= IXGBE_LED_BLINK(index);
782 IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);
783 IXGBE_WRITE_FLUSH(hw);
789 * ixgbe_blink_led_stop_82598 - Stop blinking LED based on index.
790 * @hw: pointer to hardware structure
791 * @index: led number to stop blinking
793 static s32 ixgbe_blink_led_stop_82598(struct ixgbe_hw *hw, u32 index)
795 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
796 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
798 autoc_reg &= ~IXGBE_AUTOC_FLU;
799 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
800 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
802 led_reg &= ~IXGBE_LED_MODE_MASK(index);
803 led_reg &= ~IXGBE_LED_BLINK(index);
804 led_reg |= IXGBE_LED_LINK_ACTIVE << IXGBE_LED_MODE_SHIFT(index);
805 IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);
806 IXGBE_WRITE_FLUSH(hw);
812 * ixgbe_read_analog_reg8_82598 - Reads 8 bit Atlas analog register
813 * @hw: pointer to hardware structure
814 * @reg: analog register to read
817 * Performs read operation to Atlas analog register specified.
819 s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)
823 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL,
824 IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));
825 IXGBE_WRITE_FLUSH(hw);
827 atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL);
828 *val = (u8)atlas_ctl;
834 * ixgbe_write_analog_reg8_82598 - Writes 8 bit Atlas analog register
835 * @hw: pointer to hardware structure
836 * @reg: atlas register to write
837 * @val: value to write
839 * Performs write operation to Atlas analog register specified.
841 s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)
845 atlas_ctl = (reg << 8) | val;
846 IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);
847 IXGBE_WRITE_FLUSH(hw);
854 * ixgbe_get_supported_physical_layer_82598 - Returns physical layer type
855 * @hw: pointer to hardware structure
857 * Determines physical layer capabilities of the current configuration.
859 s32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
861 s32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
863 switch (hw->device_id) {
864 case IXGBE_DEV_ID_82598EB_CX4:
865 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
866 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
868 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
869 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
870 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
872 case IXGBE_DEV_ID_82598EB_XF_LR:
873 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
877 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
881 return physical_layer;
884 static struct ixgbe_mac_operations mac_ops_82598 = {
885 .init_hw = &ixgbe_init_hw_generic,
886 .reset_hw = &ixgbe_reset_hw_82598,
887 .start_hw = &ixgbe_start_hw_generic,
888 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
889 .get_media_type = &ixgbe_get_media_type_82598,
890 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82598,
891 .get_mac_addr = &ixgbe_get_mac_addr_generic,
892 .stop_adapter = &ixgbe_stop_adapter_generic,
893 .read_analog_reg8 = &ixgbe_read_analog_reg8_82598,
894 .write_analog_reg8 = &ixgbe_write_analog_reg8_82598,
895 .setup_link = &ixgbe_setup_mac_link_82598,
896 .setup_link_speed = &ixgbe_setup_mac_link_speed_82598,
897 .check_link = &ixgbe_check_mac_link_82598,
898 .get_link_capabilities = &ixgbe_get_link_capabilities_82598,
899 .led_on = &ixgbe_led_on_generic,
900 .led_off = &ixgbe_led_off_generic,
901 .blink_led_start = &ixgbe_blink_led_start_82598,
902 .blink_led_stop = &ixgbe_blink_led_stop_82598,
903 .set_rar = &ixgbe_set_rar_generic,
904 .clear_rar = &ixgbe_clear_rar_generic,
905 .set_vmdq = &ixgbe_set_vmdq_82598,
906 .clear_vmdq = &ixgbe_clear_vmdq_82598,
907 .init_rx_addrs = &ixgbe_init_rx_addrs_generic,
908 .update_uc_addr_list = &ixgbe_update_uc_addr_list_generic,
909 .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,
910 .enable_mc = &ixgbe_enable_mc_generic,
911 .disable_mc = &ixgbe_disable_mc_generic,
912 .clear_vfta = &ixgbe_clear_vfta_82598,
913 .set_vfta = &ixgbe_set_vfta_82598,
914 .setup_fc = &ixgbe_setup_fc_82598,
917 static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
918 .init_params = &ixgbe_init_eeprom_params_generic,
919 .read = &ixgbe_read_eeprom_generic,
920 .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
921 .update_checksum = &ixgbe_update_eeprom_checksum_generic,
924 static struct ixgbe_phy_operations phy_ops_82598 = {
925 .identify = &ixgbe_identify_phy_generic,
926 /* .identify_sfp = &ixgbe_identify_sfp_module_generic, */
927 .reset = &ixgbe_reset_phy_generic,
928 .read_reg = &ixgbe_read_phy_reg_generic,
929 .write_reg = &ixgbe_write_phy_reg_generic,
930 .setup_link = &ixgbe_setup_phy_link_generic,
931 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
934 struct ixgbe_info ixgbe_82598_info = {
935 .mac = ixgbe_mac_82598EB,
936 .get_invariants = &ixgbe_get_invariants_82598,
937 .mac_ops = &mac_ops_82598,
938 .eeprom_ops = &eeprom_ops_82598,
939 .phy_ops = &phy_ops_82598,