Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel 10 Gigabit PCI Express Linux driver |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4 | Copyright(c) 1999 - 2008 Intel Corporation. |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, |
| 8 | version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License along with |
| 16 | this program; if not, write to the Free Software Foundation, Inc., |
| 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | |
| 19 | The full GNU General Public License is included in this distribution in |
| 20 | the file called "COPYING". |
| 21 | |
| 22 | Contact Information: |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 23 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 24 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 25 | |
| 26 | *******************************************************************************/ |
| 27 | |
| 28 | #include <linux/pci.h> |
| 29 | #include <linux/delay.h> |
| 30 | #include <linux/sched.h> |
| 31 | |
Stephen Hemminger | 9c8eb72 | 2007-10-29 10:46:24 -0700 | [diff] [blame] | 32 | #include "ixgbe.h" |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 33 | #include "ixgbe_phy.h" |
| 34 | |
| 35 | #define IXGBE_82598_MAX_TX_QUEUES 32 |
| 36 | #define IXGBE_82598_MAX_RX_QUEUES 64 |
| 37 | #define IXGBE_82598_RAR_ENTRIES 16 |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 38 | #define IXGBE_82598_MC_TBL_SIZE 128 |
| 39 | #define IXGBE_82598_VFT_TBL_SIZE 128 |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 40 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 41 | static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw, |
| 42 | ixgbe_link_speed *speed, |
| 43 | bool *autoneg); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 44 | static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw); |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 45 | static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, |
| 46 | ixgbe_link_speed speed, |
| 47 | bool autoneg, |
| 48 | bool autoneg_wait_to_complete); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 49 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 50 | /** |
| 51 | */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 52 | static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw) |
| 53 | { |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 54 | struct ixgbe_mac_info *mac = &hw->mac; |
| 55 | struct ixgbe_phy_info *phy = &hw->phy; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 56 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 57 | /* Call PHY identify routine to get the phy type */ |
| 58 | ixgbe_identify_phy_generic(hw); |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 59 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 60 | /* PHY Init */ |
| 61 | switch (phy->type) { |
Jesse Brandeburg | 0befdb3 | 2008-10-31 00:46:40 -0700 | [diff] [blame^] | 62 | case ixgbe_phy_tn: |
| 63 | phy->ops.check_link = &ixgbe_check_phy_link_tnx; |
| 64 | phy->ops.get_firmware_version = |
| 65 | &ixgbe_get_phy_firmware_version_tnx; |
| 66 | break; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 67 | default: |
| 68 | break; |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 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; |
| 77 | } |
| 78 | |
| 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; |
| 84 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | /** |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 89 | * ixgbe_get_link_capabilities_82598 - Determines link capabilities |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 90 | * @hw: pointer to hardware structure |
| 91 | * @speed: pointer to link speed |
| 92 | * @autoneg: boolean auto-negotiation value |
| 93 | * |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 94 | * Determines the link capabilities by reading the AUTOC register. |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 95 | **/ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 96 | static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 97 | ixgbe_link_speed *speed, |
| 98 | bool *autoneg) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 99 | { |
| 100 | s32 status = 0; |
| 101 | s32 autoc_reg; |
| 102 | |
| 103 | autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); |
| 104 | |
| 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; |
| 110 | } |
| 111 | |
| 112 | switch (autoc_reg & IXGBE_AUTOC_LMS_MASK) { |
| 113 | case IXGBE_AUTOC_LMS_1G_LINK_NO_AN: |
| 114 | *speed = IXGBE_LINK_SPEED_1GB_FULL; |
| 115 | *autoneg = false; |
| 116 | break; |
| 117 | |
| 118 | case IXGBE_AUTOC_LMS_10G_LINK_NO_AN: |
| 119 | *speed = IXGBE_LINK_SPEED_10GB_FULL; |
| 120 | *autoneg = false; |
| 121 | break; |
| 122 | |
| 123 | case IXGBE_AUTOC_LMS_1G_AN: |
| 124 | *speed = IXGBE_LINK_SPEED_1GB_FULL; |
| 125 | *autoneg = true; |
| 126 | break; |
| 127 | |
| 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; |
| 135 | *autoneg = true; |
| 136 | break; |
| 137 | |
| 138 | default: |
| 139 | status = IXGBE_ERR_LINK_SETUP; |
| 140 | break; |
| 141 | } |
| 142 | |
| 143 | return status; |
| 144 | } |
| 145 | |
| 146 | /** |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 147 | * ixgbe_get_copper_link_capabilities_82598 - Determines link capabilities |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 148 | * @hw: pointer to hardware structure |
| 149 | * @speed: pointer to link speed |
| 150 | * @autoneg: boolean auto-negotiation value |
| 151 | * |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 152 | * Determines the link capabilities by reading the AUTOC register. |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 153 | **/ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 154 | s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw, |
| 155 | ixgbe_link_speed *speed, |
| 156 | bool *autoneg) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 157 | { |
| 158 | s32 status = IXGBE_ERR_LINK_SETUP; |
| 159 | u16 speed_ability; |
| 160 | |
| 161 | *speed = 0; |
| 162 | *autoneg = true; |
| 163 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 164 | status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 165 | IXGBE_MDIO_PMA_PMD_DEV_TYPE, |
| 166 | &speed_ability); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 167 | |
| 168 | if (status == 0) { |
| 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; |
| 173 | } |
| 174 | |
| 175 | return status; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * ixgbe_get_media_type_82598 - Determines media type |
| 180 | * @hw: pointer to hardware structure |
| 181 | * |
| 182 | * Returns the media type (fiber, copper, backplane) |
| 183 | **/ |
| 184 | static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw) |
| 185 | { |
| 186 | enum ixgbe_media_type media_type; |
| 187 | |
| 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: |
Jesse Brandeburg | 8d792cd | 2008-08-08 16:24:19 -0700 | [diff] [blame] | 193 | case IXGBE_DEV_ID_82598_CX4_DUAL_PORT: |
Jesse Brandeburg | b95f5fc | 2008-09-11 19:58:59 -0700 | [diff] [blame] | 194 | case IXGBE_DEV_ID_82598EB_XF_LR: |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 195 | media_type = ixgbe_media_type_fiber; |
| 196 | break; |
Jesse Brandeburg | 0befdb3 | 2008-10-31 00:46:40 -0700 | [diff] [blame^] | 197 | case IXGBE_DEV_ID_82598AT: |
| 198 | media_type = ixgbe_media_type_copper; |
| 199 | break; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 200 | default: |
| 201 | media_type = ixgbe_media_type_unknown; |
| 202 | break; |
| 203 | } |
| 204 | |
| 205 | return media_type; |
| 206 | } |
| 207 | |
| 208 | /** |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 209 | * ixgbe_setup_fc_82598 - Configure flow control settings |
| 210 | * @hw: pointer to hardware structure |
| 211 | * @packetbuf_num: packet buffer number (0-7) |
| 212 | * |
| 213 | * Configures the flow control settings based on SW configuration. This |
| 214 | * function is used for 802.3x flow control configuration only. |
| 215 | **/ |
| 216 | s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num) |
| 217 | { |
| 218 | u32 frctl_reg; |
| 219 | u32 rmcs_reg; |
| 220 | |
| 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); |
| 224 | } |
| 225 | |
| 226 | frctl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL); |
| 227 | frctl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE); |
| 228 | |
| 229 | rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS); |
| 230 | rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X); |
| 231 | |
| 232 | /* |
| 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. |
| 235 | */ |
| 236 | if (hw->fc.type == ixgbe_fc_default) |
| 237 | hw->fc.type = ixgbe_fc_full; |
| 238 | |
| 239 | /* |
| 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. |
| 243 | */ |
| 244 | hw->fc.original_type = hw->fc.type; |
| 245 | |
| 246 | /* |
| 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. |
| 254 | * other: Invalid. |
| 255 | */ |
| 256 | switch (hw->fc.type) { |
| 257 | case ixgbe_fc_none: |
| 258 | break; |
| 259 | case ixgbe_fc_rx_pause: |
| 260 | /* |
| 261 | * Rx Flow control is enabled, |
| 262 | * and Tx Flow control is disabled. |
| 263 | */ |
| 264 | frctl_reg |= IXGBE_FCTRL_RFCE; |
| 265 | break; |
| 266 | case ixgbe_fc_tx_pause: |
| 267 | /* |
| 268 | * Tx Flow control is enabled, and Rx Flow control is disabled, |
| 269 | * by a software over-ride. |
| 270 | */ |
| 271 | rmcs_reg |= IXGBE_RMCS_TFCE_802_3X; |
| 272 | break; |
| 273 | case ixgbe_fc_full: |
| 274 | /* |
| 275 | * Flow control (both Rx and Tx) is enabled by a software |
| 276 | * over-ride. |
| 277 | */ |
| 278 | frctl_reg |= IXGBE_FCTRL_RFCE; |
| 279 | rmcs_reg |= IXGBE_RMCS_TFCE_802_3X; |
| 280 | break; |
| 281 | default: |
| 282 | /* We should never get here. The value should be 0-3. */ |
| 283 | hw_dbg(hw, "Flow control param set incorrectly\n"); |
| 284 | break; |
| 285 | } |
| 286 | |
| 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); |
| 290 | |
| 291 | /* |
| 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. |
| 295 | */ |
| 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; |
| 299 | } |
| 300 | |
| 301 | /* |
| 302 | * We need to set up the Receive Threshold high and low water |
| 303 | * marks as well as (optionally) enabling the transmission of |
| 304 | * XON frames. |
| 305 | */ |
| 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)); |
| 310 | } else { |
| 311 | IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num), |
| 312 | hw->fc.low_water); |
| 313 | } |
| 314 | IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num), |
| 315 | (hw->fc.high_water)|IXGBE_FCRTH_FCEN); |
| 316 | } |
| 317 | |
| 318 | IXGBE_WRITE_REG(hw, IXGBE_FCTTV(0), hw->fc.pause_time); |
| 319 | IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1)); |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 325 | * ixgbe_setup_mac_link_82598 - Configures MAC link settings |
| 326 | * @hw: pointer to hardware structure |
| 327 | * |
| 328 | * Configures link settings based on values in the ixgbe_hw struct. |
| 329 | * Restarts the link. Performs autonegotiation if needed. |
| 330 | **/ |
| 331 | static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw) |
| 332 | { |
| 333 | u32 autoc_reg; |
| 334 | u32 links_reg; |
| 335 | u32 i; |
| 336 | s32 status = 0; |
| 337 | |
| 338 | autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); |
| 339 | |
| 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; |
| 345 | |
| 346 | IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 347 | IXGBE_WRITE_FLUSH(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 348 | msleep(50); |
| 349 | } |
| 350 | |
| 351 | /* Restart link */ |
| 352 | autoc_reg |= IXGBE_AUTOC_AN_RESTART; |
| 353 | IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); |
| 354 | |
| 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) |
| 363 | break; |
| 364 | msleep(100); |
| 365 | } |
| 366 | if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) { |
| 367 | status = IXGBE_ERR_AUTONEG_NOT_COMPLETE; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 368 | hw_dbg(hw, "Autonegotiation did not complete.\n"); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 369 | } |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | /* |
| 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. |
| 377 | */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 378 | hw->fc.original_type = hw->fc.type; |
| 379 | ixgbe_setup_fc_82598(hw, 0); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 380 | |
| 381 | /* Add delay to filter out noises during initial link setup */ |
| 382 | msleep(50); |
| 383 | |
| 384 | return status; |
| 385 | } |
| 386 | |
| 387 | /** |
| 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 |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 392 | * @link_up_wait_to_complete: bool used to wait for link up or not |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 393 | * |
| 394 | * Reads the links register to determine if link is up and the current speed |
| 395 | **/ |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 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) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 399 | { |
| 400 | u32 links_reg; |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 401 | u32 i; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 402 | |
| 403 | links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 404 | if (link_up_wait_to_complete) { |
| 405 | for (i = 0; i < IXGBE_LINK_UP_TIME; i++) { |
| 406 | if (links_reg & IXGBE_LINKS_UP) { |
| 407 | *link_up = true; |
| 408 | break; |
| 409 | } else { |
| 410 | *link_up = false; |
| 411 | } |
| 412 | msleep(100); |
| 413 | links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); |
| 414 | } |
| 415 | } else { |
| 416 | if (links_reg & IXGBE_LINKS_UP) |
| 417 | *link_up = true; |
| 418 | else |
| 419 | *link_up = false; |
| 420 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 421 | |
| 422 | if (links_reg & IXGBE_LINKS_SPEED) |
| 423 | *speed = IXGBE_LINK_SPEED_10GB_FULL; |
| 424 | else |
| 425 | *speed = IXGBE_LINK_SPEED_1GB_FULL; |
| 426 | |
| 427 | return 0; |
| 428 | } |
| 429 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 430 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 431 | /** |
| 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 |
| 437 | * |
| 438 | * Set the link speed in the AUTOC register and restarts link. |
| 439 | **/ |
| 440 | static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 441 | ixgbe_link_speed speed, bool autoneg, |
| 442 | bool autoneg_wait_to_complete) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 443 | { |
| 444 | s32 status = 0; |
| 445 | |
| 446 | /* If speed is 10G, then check for CX4 or XAUI. */ |
| 447 | if ((speed == IXGBE_LINK_SPEED_10GB_FULL) && |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 448 | (!(hw->mac.link_attach_type & IXGBE_AUTOC_10G_KX4))) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 449 | hw->mac.link_mode_select = IXGBE_AUTOC_LMS_10G_LINK_NO_AN; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 450 | } else if ((speed == IXGBE_LINK_SPEED_1GB_FULL) && (!autoneg)) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 451 | hw->mac.link_mode_select = IXGBE_AUTOC_LMS_1G_LINK_NO_AN; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 452 | } else if (autoneg) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 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; |
| 458 | } else { |
| 459 | status = IXGBE_ERR_LINK_SETUP; |
| 460 | } |
| 461 | |
| 462 | if (status == 0) { |
| 463 | hw->phy.autoneg_wait_to_complete = autoneg_wait_to_complete; |
| 464 | |
| 465 | hw->mac.link_settings_loaded = true; |
| 466 | /* |
| 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 |
| 469 | * stored values |
| 470 | */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 471 | ixgbe_setup_mac_link_82598(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | return status; |
| 475 | } |
| 476 | |
| 477 | |
| 478 | /** |
| 479 | * ixgbe_setup_copper_link_82598 - Setup copper link settings |
| 480 | * @hw: pointer to hardware structure |
| 481 | * |
| 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 |
| 485 | * MAC and PHY. |
| 486 | **/ |
| 487 | static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw) |
| 488 | { |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 489 | s32 status; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 490 | |
| 491 | /* Restart autonegotiation on PHY */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 492 | status = hw->phy.ops.setup_link(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 493 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 494 | /* Set MAC to KX/KX4 autoneg, which defaults to Parallel detection */ |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 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; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 497 | |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 498 | /* Set up MAC */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 499 | ixgbe_setup_mac_link_82598(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 500 | |
| 501 | return status; |
| 502 | } |
| 503 | |
| 504 | /** |
| 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 |
| 510 | * |
| 511 | * Sets the link speed in the AUTOC register in the MAC and restarts link. |
| 512 | **/ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 513 | static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 514 | ixgbe_link_speed speed, |
| 515 | bool autoneg, |
| 516 | bool autoneg_wait_to_complete) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 517 | { |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 518 | s32 status; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 519 | |
| 520 | /* Setup the PHY according to input speed */ |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 521 | status = hw->phy.ops.setup_link_speed(hw, speed, autoneg, |
| 522 | autoneg_wait_to_complete); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 523 | |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 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; |
| 527 | |
| 528 | /* Set up MAC */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 529 | ixgbe_setup_mac_link_82598(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 530 | |
| 531 | return status; |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * ixgbe_reset_hw_82598 - Performs hardware reset |
| 536 | * @hw: pointer to hardware structure |
| 537 | * |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 538 | * Resets the hardware by resetting the transmit and receive units, masks and |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 539 | * clears all interrupts, performing a PHY reset, and performing a link (MAC) |
| 540 | * reset. |
| 541 | **/ |
| 542 | static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw) |
| 543 | { |
| 544 | s32 status = 0; |
| 545 | u32 ctrl; |
| 546 | u32 gheccr; |
| 547 | u32 i; |
| 548 | u32 autoc; |
| 549 | u8 analog_val; |
| 550 | |
| 551 | /* Call adapter stop to disable tx/rx and clear interrupts */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 552 | hw->mac.ops.stop_adapter(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 553 | |
| 554 | /* |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 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 |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 557 | * they are not automatically restored on reset. |
| 558 | */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 559 | hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 560 | if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) { |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 561 | /* Enable Tx Atlas so packets can be transmitted again */ |
| 562 | hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, |
| 563 | &analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 564 | analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 565 | hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, |
| 566 | analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 567 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 568 | hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G, |
| 569 | &analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 570 | analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 571 | hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G, |
| 572 | analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 573 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 574 | hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G, |
| 575 | &analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 576 | analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 577 | hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G, |
| 578 | analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 579 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 580 | hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN, |
| 581 | &analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 582 | analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 583 | hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN, |
| 584 | analog_val); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | /* Reset PHY */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 588 | if (hw->phy.reset_disable == false) |
| 589 | hw->phy.ops.reset(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 590 | |
| 591 | /* |
| 592 | * Prevent the PCI-E bus from from hanging by disabling PCI-E master |
| 593 | * access and verify no pending requests before reset |
| 594 | */ |
| 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"); |
| 598 | } |
| 599 | |
| 600 | /* |
| 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 |
| 603 | */ |
| 604 | ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); |
| 605 | IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST)); |
| 606 | IXGBE_WRITE_FLUSH(hw); |
| 607 | |
| 608 | /* Poll for reset bit to self-clear indicating reset is complete */ |
| 609 | for (i = 0; i < 10; i++) { |
| 610 | udelay(1); |
| 611 | ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); |
| 612 | if (!(ctrl & IXGBE_CTRL_RST)) |
| 613 | break; |
| 614 | } |
| 615 | if (ctrl & IXGBE_CTRL_RST) { |
| 616 | status = IXGBE_ERR_RESET_FAILED; |
| 617 | hw_dbg(hw, "Reset polling failed to complete.\n"); |
| 618 | } |
| 619 | |
| 620 | msleep(50); |
| 621 | |
| 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); |
| 625 | |
| 626 | /* |
| 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. |
| 632 | */ |
| 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); |
| 640 | } else { |
| 641 | hw->mac.link_attach_type = |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 642 | (autoc & IXGBE_AUTOC_LMS_ATTACH_TYPE); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 643 | hw->mac.link_mode_select = (autoc & IXGBE_AUTOC_LMS_MASK); |
| 644 | hw->mac.link_settings_loaded = true; |
| 645 | } |
| 646 | |
| 647 | /* Store the permanent mac address */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 648 | hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 649 | |
| 650 | return status; |
| 651 | } |
| 652 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 653 | /** |
| 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 |
| 658 | **/ |
| 659 | s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq) |
| 660 | { |
| 661 | u32 rar_high; |
| 662 | |
| 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); |
| 667 | return 0; |
| 668 | } |
| 669 | |
| 670 | /** |
| 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) |
| 675 | **/ |
| 676 | static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq) |
| 677 | { |
| 678 | u32 rar_high; |
| 679 | u32 rar_entries = hw->mac.num_rar_entries; |
| 680 | |
| 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); |
| 686 | } |
| 687 | } else { |
| 688 | hw_dbg(hw, "RAR index %d is out of range.\n", rar); |
| 689 | } |
| 690 | |
| 691 | return 0; |
| 692 | } |
| 693 | |
| 694 | /** |
| 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 |
| 700 | * |
| 701 | * Turn on/off specified VLAN in the VLAN filter table. |
| 702 | **/ |
| 703 | s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 704 | bool vlan_on) |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 705 | { |
| 706 | u32 regindex; |
| 707 | u32 bitindex; |
| 708 | u32 bits; |
| 709 | u32 vftabyte; |
| 710 | |
| 711 | if (vlan > 4095) |
| 712 | return IXGBE_ERR_PARAM; |
| 713 | |
| 714 | /* Determine 32-bit word position in array */ |
| 715 | regindex = (vlan >> 5) & 0x7F; /* upper seven bits */ |
| 716 | |
| 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 */ |
| 720 | |
| 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); |
| 726 | |
| 727 | /* Determine the location of the bit for this VLAN id */ |
| 728 | bitindex = vlan & 0x1F; /* lower five bits */ |
| 729 | |
| 730 | bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex)); |
| 731 | if (vlan_on) |
| 732 | /* Turn on this VLAN id */ |
| 733 | bits |= (1 << bitindex); |
| 734 | else |
| 735 | /* Turn off this VLAN id */ |
| 736 | bits &= ~(1 << bitindex); |
| 737 | IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits); |
| 738 | |
| 739 | return 0; |
| 740 | } |
| 741 | |
| 742 | /** |
| 743 | * ixgbe_clear_vfta_82598 - Clear VLAN filter table |
| 744 | * @hw: pointer to hardware structure |
| 745 | * |
| 746 | * Clears the VLAN filer table, and the VMDq index associated with the filter |
| 747 | **/ |
| 748 | static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw) |
| 749 | { |
| 750 | u32 offset; |
| 751 | u32 vlanbyte; |
| 752 | |
| 753 | for (offset = 0; offset < hw->mac.vft_size; offset++) |
| 754 | IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0); |
| 755 | |
| 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), |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 759 | 0); |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 760 | |
| 761 | return 0; |
| 762 | } |
| 763 | |
| 764 | /** |
| 765 | * ixgbe_blink_led_start_82598 - Blink LED based on index. |
| 766 | * @hw: pointer to hardware structure |
| 767 | * @index: led number to blink |
| 768 | **/ |
| 769 | static s32 ixgbe_blink_led_start_82598(struct ixgbe_hw *hw, u32 index) |
| 770 | { |
| 771 | ixgbe_link_speed speed = 0; |
| 772 | bool link_up = 0; |
| 773 | u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); |
| 774 | u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); |
| 775 | |
| 776 | /* |
| 777 | * Link must be up to auto-blink the LEDs on the 82598EB MAC; |
| 778 | * force it if link is down. |
| 779 | */ |
| 780 | hw->mac.ops.check_link(hw, &speed, &link_up, false); |
| 781 | |
| 782 | if (!link_up) { |
| 783 | autoc_reg |= IXGBE_AUTOC_FLU; |
| 784 | IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); |
| 785 | msleep(10); |
| 786 | } |
| 787 | |
| 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); |
| 792 | |
| 793 | return 0; |
| 794 | } |
| 795 | |
| 796 | /** |
| 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 |
| 800 | **/ |
| 801 | static s32 ixgbe_blink_led_stop_82598(struct ixgbe_hw *hw, u32 index) |
| 802 | { |
| 803 | u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); |
| 804 | u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); |
| 805 | |
| 806 | autoc_reg &= ~IXGBE_AUTOC_FLU; |
| 807 | autoc_reg |= IXGBE_AUTOC_AN_RESTART; |
| 808 | IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); |
| 809 | |
| 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); |
| 815 | |
| 816 | return 0; |
| 817 | } |
| 818 | |
| 819 | /** |
| 820 | * ixgbe_read_analog_reg8_82598 - Reads 8 bit Atlas analog register |
| 821 | * @hw: pointer to hardware structure |
| 822 | * @reg: analog register to read |
| 823 | * @val: read value |
| 824 | * |
| 825 | * Performs read operation to Atlas analog register specified. |
| 826 | **/ |
| 827 | s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val) |
| 828 | { |
| 829 | u32 atlas_ctl; |
| 830 | |
| 831 | IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, |
| 832 | IXGBE_ATLASCTL_WRITE_CMD | (reg << 8)); |
| 833 | IXGBE_WRITE_FLUSH(hw); |
| 834 | udelay(10); |
| 835 | atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL); |
| 836 | *val = (u8)atlas_ctl; |
| 837 | |
| 838 | return 0; |
| 839 | } |
| 840 | |
| 841 | /** |
| 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 |
| 846 | * |
| 847 | * Performs write operation to Atlas analog register specified. |
| 848 | **/ |
| 849 | s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val) |
| 850 | { |
| 851 | u32 atlas_ctl; |
| 852 | |
| 853 | atlas_ctl = (reg << 8) | val; |
| 854 | IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl); |
| 855 | IXGBE_WRITE_FLUSH(hw); |
| 856 | udelay(10); |
| 857 | |
| 858 | return 0; |
| 859 | } |
| 860 | |
| 861 | /** |
| 862 | * ixgbe_get_supported_physical_layer_82598 - Returns physical layer type |
| 863 | * @hw: pointer to hardware structure |
| 864 | * |
| 865 | * Determines physical layer capabilities of the current configuration. |
| 866 | **/ |
| 867 | s32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw) |
| 868 | { |
| 869 | s32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN; |
| 870 | |
| 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; |
| 875 | break; |
| 876 | case IXGBE_DEV_ID_82598AF_DUAL_PORT: |
| 877 | case IXGBE_DEV_ID_82598AF_SINGLE_PORT: |
| 878 | physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR; |
| 879 | break; |
| 880 | case IXGBE_DEV_ID_82598EB_XF_LR: |
| 881 | physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR; |
| 882 | break; |
Jesse Brandeburg | 0befdb3 | 2008-10-31 00:46:40 -0700 | [diff] [blame^] | 883 | case IXGBE_DEV_ID_82598AT: |
| 884 | physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_T | |
| 885 | IXGBE_PHYSICAL_LAYER_1000BASE_T); |
| 886 | break; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 887 | |
| 888 | default: |
| 889 | physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN; |
| 890 | break; |
| 891 | } |
| 892 | |
| 893 | return physical_layer; |
| 894 | } |
| 895 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 896 | static struct ixgbe_mac_operations mac_ops_82598 = { |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 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, |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 901 | .get_media_type = &ixgbe_get_media_type_82598, |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 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, |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 907 | .setup_link = &ixgbe_setup_mac_link_82598, |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 908 | .setup_link_speed = &ixgbe_setup_mac_link_speed_82598, |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 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, |
| 927 | }; |
| 928 | |
| 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, |
| 934 | }; |
| 935 | |
| 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, |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 944 | }; |
| 945 | |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 946 | struct ixgbe_info ixgbe_82598_info = { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 947 | .mac = ixgbe_mac_82598EB, |
| 948 | .get_invariants = &ixgbe_get_invariants_82598, |
| 949 | .mac_ops = &mac_ops_82598, |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 950 | .eeprom_ops = &eeprom_ops_82598, |
| 951 | .phy_ops = &phy_ops_82598, |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 952 | }; |
| 953 | |