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 Jr | 3efac5a | 2009-02-01 01:19:20 -0800 | [diff] [blame] | 4 | Copyright(c) 1999 - 2009 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/types.h> |
| 29 | #include <linux/module.h> |
| 30 | #include <linux/pci.h> |
| 31 | #include <linux/netdevice.h> |
| 32 | #include <linux/vmalloc.h> |
| 33 | #include <linux/string.h> |
| 34 | #include <linux/in.h> |
| 35 | #include <linux/ip.h> |
| 36 | #include <linux/tcp.h> |
Lucy Liu | 6012786 | 2009-07-22 14:07:33 +0000 | [diff] [blame] | 37 | #include <linux/pkt_sched.h> |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 38 | #include <linux/ipv6.h> |
| 39 | #include <net/checksum.h> |
| 40 | #include <net/ip6_checksum.h> |
| 41 | #include <linux/ethtool.h> |
| 42 | #include <linux/if_vlan.h> |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 43 | #include <scsi/fc/fc_fcoe.h> |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 44 | |
| 45 | #include "ixgbe.h" |
| 46 | #include "ixgbe_common.h" |
| 47 | |
| 48 | char ixgbe_driver_name[] = "ixgbe"; |
Stephen Hemminger | 9c8eb72 | 2007-10-29 10:46:24 -0700 | [diff] [blame] | 49 | static const char ixgbe_driver_string[] = |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 50 | "Intel(R) 10 Gigabit PCI Express Network Driver"; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 51 | |
Peter P Waskiewicz Jr | bbf50e4 | 2009-07-16 15:51:11 +0000 | [diff] [blame] | 52 | #define DRV_VERSION "2.0.37-k2" |
Stephen Hemminger | 9c8eb72 | 2007-10-29 10:46:24 -0700 | [diff] [blame] | 53 | const char ixgbe_driver_version[] = DRV_VERSION; |
Peter P Waskiewicz Jr | 3efac5a | 2009-02-01 01:19:20 -0800 | [diff] [blame] | 54 | static char ixgbe_copyright[] = "Copyright (c) 1999-2009 Intel Corporation."; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 55 | |
| 56 | static const struct ixgbe_info *ixgbe_info_tbl[] = { |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 57 | [board_82598] = &ixgbe_82598_info, |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 58 | [board_82599] = &ixgbe_82599_info, |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | /* ixgbe_pci_tbl - PCI Device ID Table |
| 62 | * |
| 63 | * Wildcard entries (PCI_ANY_ID) should come last |
| 64 | * Last entry must be all 0s |
| 65 | * |
| 66 | * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, |
| 67 | * Class, Class Mask, private data (not used) } |
| 68 | */ |
| 69 | static struct pci_device_id ixgbe_pci_tbl[] = { |
Don Skidmore | 1e336d0 | 2009-01-26 20:57:51 -0800 | [diff] [blame] | 70 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598), |
| 71 | board_82598 }, |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 72 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_DUAL_PORT), |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 73 | board_82598 }, |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 74 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_SINGLE_PORT), |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 75 | board_82598 }, |
Jesse Brandeburg | 0befdb3 | 2008-10-31 00:46:40 -0700 | [diff] [blame] | 76 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AT), |
| 77 | board_82598 }, |
Peter P Waskiewicz Jr | 3845bec | 2009-07-16 15:50:52 +0000 | [diff] [blame] | 78 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AT2), |
| 79 | board_82598 }, |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 80 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598EB_CX4), |
Auke Kok | 3957d63 | 2007-10-31 15:22:10 -0700 | [diff] [blame] | 81 | board_82598 }, |
Jesse Brandeburg | 8d792cd | 2008-08-08 16:24:19 -0700 | [diff] [blame] | 82 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598_CX4_DUAL_PORT), |
| 83 | board_82598 }, |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 84 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598_DA_DUAL_PORT), |
| 85 | board_82598 }, |
| 86 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM), |
| 87 | board_82598 }, |
Jesse Brandeburg | b95f5fc | 2008-09-11 19:58:59 -0700 | [diff] [blame] | 88 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598EB_XF_LR), |
| 89 | board_82598 }, |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 90 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598EB_SFP_LOM), |
| 91 | board_82598 }, |
Don Skidmore | 2f21bdd | 2009-02-01 01:18:23 -0800 | [diff] [blame] | 92 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598_BX), |
| 93 | board_82598 }, |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 94 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_KX4), |
| 95 | board_82599 }, |
Peter P Waskiewicz Jr | 1fcf03e | 2009-05-17 20:58:04 +0000 | [diff] [blame] | 96 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_XAUI_LOM), |
| 97 | board_82599 }, |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 98 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP), |
| 99 | board_82599 }, |
Peter P Waskiewicz Jr | 8911184 | 2009-09-14 07:47:49 +0000 | [diff] [blame] | 100 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_CX4), |
| 101 | board_82599 }, |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 102 | |
| 103 | /* required last entry */ |
| 104 | {0, } |
| 105 | }; |
| 106 | MODULE_DEVICE_TABLE(pci, ixgbe_pci_tbl); |
| 107 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 108 | #ifdef CONFIG_IXGBE_DCA |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 109 | static int ixgbe_notify_dca(struct notifier_block *, unsigned long event, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 110 | void *p); |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 111 | static struct notifier_block dca_notifier = { |
| 112 | .notifier_call = ixgbe_notify_dca, |
| 113 | .next = NULL, |
| 114 | .priority = 0 |
| 115 | }; |
| 116 | #endif |
| 117 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 118 | MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); |
| 119 | MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver"); |
| 120 | MODULE_LICENSE("GPL"); |
| 121 | MODULE_VERSION(DRV_VERSION); |
| 122 | |
| 123 | #define DEFAULT_DEBUG_LEVEL_SHIFT 3 |
| 124 | |
Ayyappan Veeraiyan | 5eba369 | 2008-02-01 15:59:04 -0800 | [diff] [blame] | 125 | static void ixgbe_release_hw_control(struct ixgbe_adapter *adapter) |
| 126 | { |
| 127 | u32 ctrl_ext; |
| 128 | |
| 129 | /* Let firmware take over control of h/w */ |
| 130 | ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); |
| 131 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 132 | ctrl_ext & ~IXGBE_CTRL_EXT_DRV_LOAD); |
Ayyappan Veeraiyan | 5eba369 | 2008-02-01 15:59:04 -0800 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | static void ixgbe_get_hw_control(struct ixgbe_adapter *adapter) |
| 136 | { |
| 137 | u32 ctrl_ext; |
| 138 | |
| 139 | /* Let firmware know the driver has taken over */ |
| 140 | ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); |
| 141 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 142 | ctrl_ext | IXGBE_CTRL_EXT_DRV_LOAD); |
Ayyappan Veeraiyan | 5eba369 | 2008-02-01 15:59:04 -0800 | [diff] [blame] | 143 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 144 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 145 | /* |
| 146 | * ixgbe_set_ivar - set the IVAR registers, mapping interrupt causes to vectors |
| 147 | * @adapter: pointer to adapter struct |
| 148 | * @direction: 0 for Rx, 1 for Tx, -1 for other causes |
| 149 | * @queue: queue to map the corresponding interrupt to |
| 150 | * @msix_vector: the vector to map to the corresponding queue |
| 151 | * |
| 152 | */ |
| 153 | static void ixgbe_set_ivar(struct ixgbe_adapter *adapter, s8 direction, |
| 154 | u8 queue, u8 msix_vector) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 155 | { |
| 156 | u32 ivar, index; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 157 | struct ixgbe_hw *hw = &adapter->hw; |
| 158 | switch (hw->mac.type) { |
| 159 | case ixgbe_mac_82598EB: |
| 160 | msix_vector |= IXGBE_IVAR_ALLOC_VAL; |
| 161 | if (direction == -1) |
| 162 | direction = 0; |
| 163 | index = (((direction * 64) + queue) >> 2) & 0x1F; |
| 164 | ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index)); |
| 165 | ivar &= ~(0xFF << (8 * (queue & 0x3))); |
| 166 | ivar |= (msix_vector << (8 * (queue & 0x3))); |
| 167 | IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar); |
| 168 | break; |
| 169 | case ixgbe_mac_82599EB: |
| 170 | if (direction == -1) { |
| 171 | /* other causes */ |
| 172 | msix_vector |= IXGBE_IVAR_ALLOC_VAL; |
| 173 | index = ((queue & 1) * 8); |
| 174 | ivar = IXGBE_READ_REG(&adapter->hw, IXGBE_IVAR_MISC); |
| 175 | ivar &= ~(0xFF << index); |
| 176 | ivar |= (msix_vector << index); |
| 177 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_IVAR_MISC, ivar); |
| 178 | break; |
| 179 | } else { |
| 180 | /* tx or rx causes */ |
| 181 | msix_vector |= IXGBE_IVAR_ALLOC_VAL; |
| 182 | index = ((16 * (queue & 1)) + (8 * direction)); |
| 183 | ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1)); |
| 184 | ivar &= ~(0xFF << index); |
| 185 | ivar |= (msix_vector << index); |
| 186 | IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), ivar); |
| 187 | break; |
| 188 | } |
| 189 | default: |
| 190 | break; |
| 191 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 194 | static inline void ixgbe_irq_rearm_queues(struct ixgbe_adapter *adapter, |
| 195 | u64 qmask) |
| 196 | { |
| 197 | u32 mask; |
| 198 | |
| 199 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 200 | mask = (IXGBE_EIMS_RTX_QUEUE & qmask); |
| 201 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS, mask); |
| 202 | } else { |
| 203 | mask = (qmask & 0xFFFFFFFF); |
| 204 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0), mask); |
| 205 | mask = (qmask >> 32); |
| 206 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1), mask); |
| 207 | } |
| 208 | } |
| 209 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 210 | static void ixgbe_unmap_and_free_tx_resource(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 211 | struct ixgbe_tx_buffer |
| 212 | *tx_buffer_info) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 213 | { |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 214 | tx_buffer_info->dma = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 215 | if (tx_buffer_info->skb) { |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 216 | skb_dma_unmap(&adapter->pdev->dev, tx_buffer_info->skb, |
| 217 | DMA_TO_DEVICE); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 218 | dev_kfree_skb_any(tx_buffer_info->skb); |
| 219 | tx_buffer_info->skb = NULL; |
| 220 | } |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 221 | tx_buffer_info->time_stamp = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 222 | /* tx_buffer_info must be completely set up in the transmit path */ |
| 223 | } |
| 224 | |
| 225 | static inline bool ixgbe_check_tx_hang(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 226 | struct ixgbe_ring *tx_ring, |
| 227 | unsigned int eop) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 228 | { |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 229 | struct ixgbe_hw *hw = &adapter->hw; |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 230 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 231 | /* Detect a transmit hang in hardware, this serializes the |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 232 | * check with the clearing of time_stamp and movement of eop */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 233 | adapter->detect_tx_hung = false; |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 234 | if (tx_ring->tx_buffer_info[eop].time_stamp && |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 235 | time_after(jiffies, tx_ring->tx_buffer_info[eop].time_stamp + HZ) && |
| 236 | !(IXGBE_READ_REG(&adapter->hw, IXGBE_TFCS) & IXGBE_TFCS_TXOFF)) { |
| 237 | /* detected Tx unit hang */ |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 238 | union ixgbe_adv_tx_desc *tx_desc; |
| 239 | tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 240 | DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n" |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 241 | " Tx Queue <%d>\n" |
| 242 | " TDH, TDT <%x>, <%x>\n" |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 243 | " next_to_use <%x>\n" |
| 244 | " next_to_clean <%x>\n" |
| 245 | "tx_buffer_info[next_to_clean]\n" |
| 246 | " time_stamp <%lx>\n" |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 247 | " jiffies <%lx>\n", |
| 248 | tx_ring->queue_index, |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 249 | IXGBE_READ_REG(hw, tx_ring->head), |
| 250 | IXGBE_READ_REG(hw, tx_ring->tail), |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 251 | tx_ring->next_to_use, eop, |
| 252 | tx_ring->tx_buffer_info[eop].time_stamp, jiffies); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 253 | return true; |
| 254 | } |
| 255 | |
| 256 | return false; |
| 257 | } |
| 258 | |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 259 | #define IXGBE_MAX_TXD_PWR 14 |
| 260 | #define IXGBE_MAX_DATA_PER_TXD (1 << IXGBE_MAX_TXD_PWR) |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 261 | |
| 262 | /* Tx Descriptors needed, worst case */ |
| 263 | #define TXD_USE_COUNT(S) (((S) >> IXGBE_MAX_TXD_PWR) + \ |
| 264 | (((S) & (IXGBE_MAX_DATA_PER_TXD - 1)) ? 1 : 0)) |
| 265 | #define DESC_NEEDED (TXD_USE_COUNT(IXGBE_MAX_DATA_PER_TXD) /* skb->data */ + \ |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 266 | MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1) /* for context */ |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 267 | |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 268 | static void ixgbe_tx_timeout(struct net_device *netdev); |
| 269 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 270 | /** |
| 271 | * ixgbe_clean_tx_irq - Reclaim resources after transmit completes |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 272 | * @q_vector: structure containing interrupt and ring information |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 273 | * @tx_ring: tx ring to clean |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 274 | **/ |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 275 | static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 276 | struct ixgbe_ring *tx_ring) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 277 | { |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 278 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 279 | struct net_device *netdev = adapter->netdev; |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 280 | union ixgbe_adv_tx_desc *tx_desc, *eop_desc; |
| 281 | struct ixgbe_tx_buffer *tx_buffer_info; |
| 282 | unsigned int i, eop, count = 0; |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 283 | unsigned int total_bytes = 0, total_packets = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 284 | |
| 285 | i = tx_ring->next_to_clean; |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 286 | eop = tx_ring->tx_buffer_info[i].next_to_watch; |
| 287 | eop_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop); |
| 288 | |
| 289 | while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) && |
Jesse Brandeburg | 9a1a69ad | 2009-03-13 22:14:10 +0000 | [diff] [blame] | 290 | (count < tx_ring->work_limit)) { |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 291 | bool cleaned = false; |
| 292 | for ( ; !cleaned; count++) { |
| 293 | struct sk_buff *skb; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 294 | tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i); |
| 295 | tx_buffer_info = &tx_ring->tx_buffer_info[i]; |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 296 | cleaned = (i == eop); |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 297 | skb = tx_buffer_info->skb; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 298 | |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 299 | if (cleaned && skb) { |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 300 | unsigned int segs, bytecount; |
Yi Zou | 3d8fd38 | 2009-06-08 14:38:44 +0000 | [diff] [blame] | 301 | unsigned int hlen = skb_headlen(skb); |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 302 | |
| 303 | /* gso_segs is currently only valid for tcp */ |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 304 | segs = skb_shinfo(skb)->gso_segs ?: 1; |
Yi Zou | 3d8fd38 | 2009-06-08 14:38:44 +0000 | [diff] [blame] | 305 | #ifdef IXGBE_FCOE |
| 306 | /* adjust for FCoE Sequence Offload */ |
| 307 | if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) |
| 308 | && (skb->protocol == htons(ETH_P_FCOE)) && |
| 309 | skb_is_gso(skb)) { |
| 310 | hlen = skb_transport_offset(skb) + |
| 311 | sizeof(struct fc_frame_header) + |
| 312 | sizeof(struct fcoe_crc_eof); |
| 313 | segs = DIV_ROUND_UP(skb->len - hlen, |
| 314 | skb_shinfo(skb)->gso_size); |
| 315 | } |
| 316 | #endif /* IXGBE_FCOE */ |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 317 | /* multiply data chunks by size of headers */ |
Yi Zou | 3d8fd38 | 2009-06-08 14:38:44 +0000 | [diff] [blame] | 318 | bytecount = ((segs - 1) * hlen) + skb->len; |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 319 | total_packets += segs; |
| 320 | total_bytes += bytecount; |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 321 | } |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 322 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 323 | ixgbe_unmap_and_free_tx_resource(adapter, |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 324 | tx_buffer_info); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 325 | |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 326 | tx_desc->wb.status = 0; |
| 327 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 328 | i++; |
| 329 | if (i == tx_ring->count) |
| 330 | i = 0; |
| 331 | } |
| 332 | |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 333 | eop = tx_ring->tx_buffer_info[i].next_to_watch; |
| 334 | eop_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop); |
| 335 | } |
| 336 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 337 | tx_ring->next_to_clean = i; |
| 338 | |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 339 | #define TX_WAKE_THRESHOLD (DESC_NEEDED * 2) |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 340 | if (unlikely(count && netif_carrier_ok(netdev) && |
| 341 | (IXGBE_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD))) { |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 342 | /* Make sure that anybody stopping the queue after this |
| 343 | * sees the new next_to_clean. |
| 344 | */ |
| 345 | smp_mb(); |
Ayyappan Veeraiyan | 30eba97 | 2008-03-03 15:03:52 -0800 | [diff] [blame] | 346 | if (__netif_subqueue_stopped(netdev, tx_ring->queue_index) && |
| 347 | !test_bit(__IXGBE_DOWN, &adapter->state)) { |
| 348 | netif_wake_subqueue(netdev, tx_ring->queue_index); |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 349 | ++adapter->restart_queue; |
Ayyappan Veeraiyan | 30eba97 | 2008-03-03 15:03:52 -0800 | [diff] [blame] | 350 | } |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 351 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 352 | |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 353 | if (adapter->detect_tx_hung) { |
| 354 | if (ixgbe_check_tx_hang(adapter, tx_ring, i)) { |
| 355 | /* schedule immediate reset if we believe we hung */ |
| 356 | DPRINTK(PROBE, INFO, |
| 357 | "tx hang %d detected, resetting adapter\n", |
| 358 | adapter->tx_timeout_count + 1); |
| 359 | ixgbe_tx_timeout(adapter->netdev); |
| 360 | } |
| 361 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 362 | |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 363 | /* re-arm the interrupt */ |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 364 | if (count >= tx_ring->work_limit) |
| 365 | ixgbe_irq_rearm_queues(adapter, ((u64)1 << q_vector->v_idx)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 366 | |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 367 | tx_ring->total_bytes += total_bytes; |
| 368 | tx_ring->total_packets += total_packets; |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 369 | tx_ring->stats.packets += total_packets; |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 370 | tx_ring->stats.bytes += total_bytes; |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 371 | adapter->net_stats.tx_bytes += total_bytes; |
| 372 | adapter->net_stats.tx_packets += total_packets; |
Jesse Brandeburg | 9a1a69ad | 2009-03-13 22:14:10 +0000 | [diff] [blame] | 373 | return (count < tx_ring->work_limit); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 376 | #ifdef CONFIG_IXGBE_DCA |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 377 | static void ixgbe_update_rx_dca(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 378 | struct ixgbe_ring *rx_ring) |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 379 | { |
| 380 | u32 rxctrl; |
| 381 | int cpu = get_cpu(); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 382 | int q = rx_ring - adapter->rx_ring; |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 383 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 384 | if (rx_ring->cpu != cpu) { |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 385 | rxctrl = IXGBE_READ_REG(&adapter->hw, IXGBE_DCA_RXCTRL(q)); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 386 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 387 | rxctrl &= ~IXGBE_DCA_RXCTRL_CPUID_MASK; |
| 388 | rxctrl |= dca3_get_tag(&adapter->pdev->dev, cpu); |
| 389 | } else if (adapter->hw.mac.type == ixgbe_mac_82599EB) { |
| 390 | rxctrl &= ~IXGBE_DCA_RXCTRL_CPUID_MASK_82599; |
| 391 | rxctrl |= (dca3_get_tag(&adapter->pdev->dev, cpu) << |
| 392 | IXGBE_DCA_RXCTRL_CPUID_SHIFT_82599); |
| 393 | } |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 394 | rxctrl |= IXGBE_DCA_RXCTRL_DESC_DCA_EN; |
| 395 | rxctrl |= IXGBE_DCA_RXCTRL_HEAD_DCA_EN; |
Don Skidmore | 15005a3 | 2009-01-19 16:54:13 -0800 | [diff] [blame] | 396 | rxctrl &= ~(IXGBE_DCA_RXCTRL_DESC_RRO_EN); |
| 397 | rxctrl &= ~(IXGBE_DCA_RXCTRL_DESC_WRO_EN | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 398 | IXGBE_DCA_RXCTRL_DESC_HSRO_EN); |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 399 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_RXCTRL(q), rxctrl); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 400 | rx_ring->cpu = cpu; |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 401 | } |
| 402 | put_cpu(); |
| 403 | } |
| 404 | |
| 405 | static void ixgbe_update_tx_dca(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 406 | struct ixgbe_ring *tx_ring) |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 407 | { |
| 408 | u32 txctrl; |
| 409 | int cpu = get_cpu(); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 410 | int q = tx_ring - adapter->tx_ring; |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 411 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 412 | if (tx_ring->cpu != cpu) { |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 413 | txctrl = IXGBE_READ_REG(&adapter->hw, IXGBE_DCA_TXCTRL(q)); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 414 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 415 | txctrl &= ~IXGBE_DCA_TXCTRL_CPUID_MASK; |
| 416 | txctrl |= dca3_get_tag(&adapter->pdev->dev, cpu); |
| 417 | } else if (adapter->hw.mac.type == ixgbe_mac_82599EB) { |
| 418 | txctrl &= ~IXGBE_DCA_TXCTRL_CPUID_MASK_82599; |
| 419 | txctrl |= (dca3_get_tag(&adapter->pdev->dev, cpu) << |
| 420 | IXGBE_DCA_TXCTRL_CPUID_SHIFT_82599); |
| 421 | } |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 422 | txctrl |= IXGBE_DCA_TXCTRL_DESC_DCA_EN; |
| 423 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_TXCTRL(q), txctrl); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 424 | tx_ring->cpu = cpu; |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 425 | } |
| 426 | put_cpu(); |
| 427 | } |
| 428 | |
| 429 | static void ixgbe_setup_dca(struct ixgbe_adapter *adapter) |
| 430 | { |
| 431 | int i; |
| 432 | |
| 433 | if (!(adapter->flags & IXGBE_FLAG_DCA_ENABLED)) |
| 434 | return; |
| 435 | |
Alexander Duyck | e35ec12 | 2009-05-21 13:07:12 +0000 | [diff] [blame] | 436 | /* always use CB2 mode, difference is masked in the CB driver */ |
| 437 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, 2); |
| 438 | |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 439 | for (i = 0; i < adapter->num_tx_queues; i++) { |
| 440 | adapter->tx_ring[i].cpu = -1; |
| 441 | ixgbe_update_tx_dca(adapter, &adapter->tx_ring[i]); |
| 442 | } |
| 443 | for (i = 0; i < adapter->num_rx_queues; i++) { |
| 444 | adapter->rx_ring[i].cpu = -1; |
| 445 | ixgbe_update_rx_dca(adapter, &adapter->rx_ring[i]); |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | static int __ixgbe_notify_dca(struct device *dev, void *data) |
| 450 | { |
| 451 | struct net_device *netdev = dev_get_drvdata(dev); |
| 452 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 453 | unsigned long event = *(unsigned long *)data; |
| 454 | |
| 455 | switch (event) { |
| 456 | case DCA_PROVIDER_ADD: |
Jesse Brandeburg | 96b0e0f | 2008-08-26 04:27:21 -0700 | [diff] [blame] | 457 | /* if we're already enabled, don't do it again */ |
| 458 | if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) |
| 459 | break; |
Denis V. Lunev | 652f093 | 2008-03-27 14:39:17 +0300 | [diff] [blame] | 460 | if (dca_add_requester(dev) == 0) { |
Jesse Brandeburg | 96b0e0f | 2008-08-26 04:27:21 -0700 | [diff] [blame] | 461 | adapter->flags |= IXGBE_FLAG_DCA_ENABLED; |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 462 | ixgbe_setup_dca(adapter); |
| 463 | break; |
| 464 | } |
| 465 | /* Fall Through since DCA is disabled. */ |
| 466 | case DCA_PROVIDER_REMOVE: |
| 467 | if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) { |
| 468 | dca_remove_requester(dev); |
| 469 | adapter->flags &= ~IXGBE_FLAG_DCA_ENABLED; |
| 470 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, 1); |
| 471 | } |
| 472 | break; |
| 473 | } |
| 474 | |
Denis V. Lunev | 652f093 | 2008-03-27 14:39:17 +0300 | [diff] [blame] | 475 | return 0; |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 476 | } |
| 477 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 478 | #endif /* CONFIG_IXGBE_DCA */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 479 | /** |
| 480 | * ixgbe_receive_skb - Send a completed packet up the stack |
| 481 | * @adapter: board private structure |
| 482 | * @skb: packet to send up |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 483 | * @status: hardware indication of status of receive |
| 484 | * @rx_ring: rx descriptor ring (for a specific queue) to setup |
| 485 | * @rx_desc: rx descriptor |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 486 | **/ |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 487 | static void ixgbe_receive_skb(struct ixgbe_q_vector *q_vector, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 488 | struct sk_buff *skb, u8 status, |
Alexander Duyck | fdaff1c | 2009-05-06 10:43:47 +0000 | [diff] [blame] | 489 | struct ixgbe_ring *ring, |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 490 | union ixgbe_adv_rx_desc *rx_desc) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 491 | { |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 492 | struct ixgbe_adapter *adapter = q_vector->adapter; |
| 493 | struct napi_struct *napi = &q_vector->napi; |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 494 | bool is_vlan = (status & IXGBE_RXD_STAT_VP); |
| 495 | u16 tag = le16_to_cpu(rx_desc->wb.upper.vlan); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 496 | |
Alexander Duyck | fdaff1c | 2009-05-06 10:43:47 +0000 | [diff] [blame] | 497 | skb_record_rx_queue(skb, ring->queue_index); |
Alexander Duyck | 182ff8d | 2009-04-27 22:35:33 +0000 | [diff] [blame] | 498 | if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) { |
Lucy Liu | 8a62bab | 2009-08-13 14:09:38 +0000 | [diff] [blame] | 499 | if (adapter->vlgrp && is_vlan && (tag & VLAN_VID_MASK)) |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 500 | vlan_gro_receive(napi, adapter->vlgrp, tag, skb); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 501 | else |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 502 | napi_gro_receive(napi, skb); |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 503 | } else { |
Lucy Liu | 8a62bab | 2009-08-13 14:09:38 +0000 | [diff] [blame] | 504 | if (adapter->vlgrp && is_vlan && (tag & VLAN_VID_MASK)) |
Alexander Duyck | 182ff8d | 2009-04-27 22:35:33 +0000 | [diff] [blame] | 505 | vlan_hwaccel_rx(skb, adapter->vlgrp, tag); |
| 506 | else |
| 507 | netif_rx(skb); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | |
Ayyappan Veeraiyan | e59bd25 | 2008-02-01 15:59:09 -0800 | [diff] [blame] | 511 | /** |
| 512 | * ixgbe_rx_checksum - indicate in skb if hw indicated a good cksum |
| 513 | * @adapter: address of board private structure |
| 514 | * @status_err: hardware indication of status of receive |
| 515 | * @skb: skb currently being received and modified |
| 516 | **/ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 517 | static inline void ixgbe_rx_checksum(struct ixgbe_adapter *adapter, |
Don Skidmore | 8bae1b2 | 2009-07-23 18:00:39 +0000 | [diff] [blame] | 518 | union ixgbe_adv_rx_desc *rx_desc, |
| 519 | struct sk_buff *skb) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 520 | { |
Don Skidmore | 8bae1b2 | 2009-07-23 18:00:39 +0000 | [diff] [blame] | 521 | u32 status_err = le32_to_cpu(rx_desc->wb.upper.status_error); |
| 522 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 523 | skb->ip_summed = CHECKSUM_NONE; |
| 524 | |
Jesse Brandeburg | 712744b | 2008-08-26 04:26:56 -0700 | [diff] [blame] | 525 | /* Rx csum disabled */ |
| 526 | if (!(adapter->flags & IXGBE_FLAG_RX_CSUM_ENABLED)) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 527 | return; |
Ayyappan Veeraiyan | e59bd25 | 2008-02-01 15:59:09 -0800 | [diff] [blame] | 528 | |
| 529 | /* if IP and error */ |
| 530 | if ((status_err & IXGBE_RXD_STAT_IPCS) && |
| 531 | (status_err & IXGBE_RXDADV_ERR_IPE)) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 532 | adapter->hw_csum_rx_error++; |
| 533 | return; |
| 534 | } |
Ayyappan Veeraiyan | e59bd25 | 2008-02-01 15:59:09 -0800 | [diff] [blame] | 535 | |
| 536 | if (!(status_err & IXGBE_RXD_STAT_L4CS)) |
| 537 | return; |
| 538 | |
| 539 | if (status_err & IXGBE_RXDADV_ERR_TCPE) { |
Don Skidmore | 8bae1b2 | 2009-07-23 18:00:39 +0000 | [diff] [blame] | 540 | u16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; |
| 541 | |
| 542 | /* |
| 543 | * 82599 errata, UDP frames with a 0 checksum can be marked as |
| 544 | * checksum errors. |
| 545 | */ |
| 546 | if ((pkt_info & IXGBE_RXDADV_PKTTYPE_UDP) && |
| 547 | (adapter->hw.mac.type == ixgbe_mac_82599EB)) |
| 548 | return; |
| 549 | |
Ayyappan Veeraiyan | e59bd25 | 2008-02-01 15:59:09 -0800 | [diff] [blame] | 550 | adapter->hw_csum_rx_error++; |
| 551 | return; |
| 552 | } |
| 553 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 554 | /* It must be a TCP or UDP packet with a valid checksum */ |
Ayyappan Veeraiyan | e59bd25 | 2008-02-01 15:59:09 -0800 | [diff] [blame] | 555 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 556 | adapter->hw_csum_rx_good++; |
| 557 | } |
| 558 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 559 | static inline void ixgbe_release_rx_desc(struct ixgbe_hw *hw, |
| 560 | struct ixgbe_ring *rx_ring, u32 val) |
| 561 | { |
| 562 | /* |
| 563 | * Force memory writes to complete before letting h/w |
| 564 | * know there are new descriptors to fetch. (Only |
| 565 | * applicable for weak-ordered memory model archs, |
| 566 | * such as IA-64). |
| 567 | */ |
| 568 | wmb(); |
| 569 | IXGBE_WRITE_REG(hw, IXGBE_RDT(rx_ring->reg_idx), val); |
| 570 | } |
| 571 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 572 | /** |
| 573 | * ixgbe_alloc_rx_buffers - Replace used receive buffers; packet split |
| 574 | * @adapter: address of board private structure |
| 575 | **/ |
| 576 | static void ixgbe_alloc_rx_buffers(struct ixgbe_adapter *adapter, |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 577 | struct ixgbe_ring *rx_ring, |
| 578 | int cleaned_count) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 579 | { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 580 | struct pci_dev *pdev = adapter->pdev; |
| 581 | union ixgbe_adv_rx_desc *rx_desc; |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 582 | struct ixgbe_rx_buffer *bi; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 583 | unsigned int i; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 584 | |
| 585 | i = rx_ring->next_to_use; |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 586 | bi = &rx_ring->rx_buffer_info[i]; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 587 | |
| 588 | while (cleaned_count--) { |
| 589 | rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i); |
| 590 | |
Jesse Brandeburg | 762f4c5 | 2008-09-11 19:58:43 -0700 | [diff] [blame] | 591 | if (!bi->page_dma && |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 592 | (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED)) { |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 593 | if (!bi->page) { |
Jesse Brandeburg | 762f4c5 | 2008-09-11 19:58:43 -0700 | [diff] [blame] | 594 | bi->page = alloc_page(GFP_ATOMIC); |
| 595 | if (!bi->page) { |
| 596 | adapter->alloc_rx_page_failed++; |
| 597 | goto no_buffers; |
| 598 | } |
| 599 | bi->page_offset = 0; |
| 600 | } else { |
| 601 | /* use a half page if we're re-using */ |
| 602 | bi->page_offset ^= (PAGE_SIZE / 2); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 603 | } |
Jesse Brandeburg | 762f4c5 | 2008-09-11 19:58:43 -0700 | [diff] [blame] | 604 | |
| 605 | bi->page_dma = pci_map_page(pdev, bi->page, |
| 606 | bi->page_offset, |
| 607 | (PAGE_SIZE / 2), |
| 608 | PCI_DMA_FROMDEVICE); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 609 | } |
| 610 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 611 | if (!bi->skb) { |
Jesse Brandeburg | 5ecc361 | 2008-12-15 01:00:57 -0800 | [diff] [blame] | 612 | struct sk_buff *skb; |
Jesse Brandeburg | 4f57ca6 | 2009-06-30 11:44:56 +0000 | [diff] [blame] | 613 | skb = netdev_alloc_skb(adapter->netdev, |
| 614 | (rx_ring->rx_buf_len + |
| 615 | NET_IP_ALIGN)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 616 | |
| 617 | if (!skb) { |
| 618 | adapter->alloc_rx_buff_failed++; |
| 619 | goto no_buffers; |
| 620 | } |
| 621 | |
| 622 | /* |
| 623 | * Make buffer alignment 2 beyond a 16 byte boundary |
| 624 | * this will result in a 16 byte aligned IP header after |
| 625 | * the 14 byte MAC header is removed |
| 626 | */ |
| 627 | skb_reserve(skb, NET_IP_ALIGN); |
| 628 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 629 | bi->skb = skb; |
Jesse Brandeburg | 4f57ca6 | 2009-06-30 11:44:56 +0000 | [diff] [blame] | 630 | bi->dma = pci_map_single(pdev, skb->data, |
| 631 | rx_ring->rx_buf_len, |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 632 | PCI_DMA_FROMDEVICE); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 633 | } |
| 634 | /* Refresh the desc even if buffer_addrs didn't change because |
| 635 | * each write-back erases this info. */ |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 636 | if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) { |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 637 | rx_desc->read.pkt_addr = cpu_to_le64(bi->page_dma); |
| 638 | rx_desc->read.hdr_addr = cpu_to_le64(bi->dma); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 639 | } else { |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 640 | rx_desc->read.pkt_addr = cpu_to_le64(bi->dma); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | i++; |
| 644 | if (i == rx_ring->count) |
| 645 | i = 0; |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 646 | bi = &rx_ring->rx_buffer_info[i]; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 647 | } |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 648 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 649 | no_buffers: |
| 650 | if (rx_ring->next_to_use != i) { |
| 651 | rx_ring->next_to_use = i; |
| 652 | if (i-- == 0) |
| 653 | i = (rx_ring->count - 1); |
| 654 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 655 | ixgbe_release_rx_desc(&adapter->hw, rx_ring, i); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 656 | } |
| 657 | } |
| 658 | |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 659 | static inline u16 ixgbe_get_hdr_info(union ixgbe_adv_rx_desc *rx_desc) |
| 660 | { |
| 661 | return rx_desc->wb.lower.lo_dword.hs_rss.hdr_info; |
| 662 | } |
| 663 | |
| 664 | static inline u16 ixgbe_get_pkt_info(union ixgbe_adv_rx_desc *rx_desc) |
| 665 | { |
| 666 | return rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; |
| 667 | } |
| 668 | |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 669 | static inline u32 ixgbe_get_rsc_count(union ixgbe_adv_rx_desc *rx_desc) |
| 670 | { |
| 671 | return (le32_to_cpu(rx_desc->wb.lower.lo_dword.data) & |
| 672 | IXGBE_RXDADV_RSCCNT_MASK) >> |
| 673 | IXGBE_RXDADV_RSCCNT_SHIFT; |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * ixgbe_transform_rsc_queue - change rsc queue into a full packet |
| 678 | * @skb: pointer to the last skb in the rsc queue |
| 679 | * |
| 680 | * This function changes a queue full of hw rsc buffers into a completed |
| 681 | * packet. It uses the ->prev pointers to find the first packet and then |
| 682 | * turns it into the frag list owner. |
| 683 | **/ |
| 684 | static inline struct sk_buff *ixgbe_transform_rsc_queue(struct sk_buff *skb) |
| 685 | { |
| 686 | unsigned int frag_list_size = 0; |
| 687 | |
| 688 | while (skb->prev) { |
| 689 | struct sk_buff *prev = skb->prev; |
| 690 | frag_list_size += skb->len; |
| 691 | skb->prev = NULL; |
| 692 | skb = prev; |
| 693 | } |
| 694 | |
| 695 | skb_shinfo(skb)->frag_list = skb->next; |
| 696 | skb->next = NULL; |
| 697 | skb->len += frag_list_size; |
| 698 | skb->data_len += frag_list_size; |
| 699 | skb->truesize += frag_list_size; |
| 700 | return skb; |
| 701 | } |
| 702 | |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 703 | static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 704 | struct ixgbe_ring *rx_ring, |
| 705 | int *work_done, int work_to_do) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 706 | { |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 707 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 708 | struct pci_dev *pdev = adapter->pdev; |
| 709 | union ixgbe_adv_rx_desc *rx_desc, *next_rxd; |
| 710 | struct ixgbe_rx_buffer *rx_buffer_info, *next_buffer; |
| 711 | struct sk_buff *skb; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 712 | unsigned int i, rsc_count = 0; |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 713 | u32 len, staterr; |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 714 | u16 hdr_info; |
| 715 | bool cleaned = false; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 716 | int cleaned_count = 0; |
Ayyappan Veeraiyan | d2f4fbe | 2008-02-01 15:59:19 -0800 | [diff] [blame] | 717 | unsigned int total_rx_bytes = 0, total_rx_packets = 0; |
Yi Zou | 3d8fd38 | 2009-06-08 14:38:44 +0000 | [diff] [blame] | 718 | #ifdef IXGBE_FCOE |
| 719 | int ddp_bytes = 0; |
| 720 | #endif /* IXGBE_FCOE */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 721 | |
| 722 | i = rx_ring->next_to_clean; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 723 | rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i); |
| 724 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); |
| 725 | rx_buffer_info = &rx_ring->rx_buffer_info[i]; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 726 | |
| 727 | while (staterr & IXGBE_RXD_STAT_DD) { |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 728 | u32 upper_len = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 729 | if (*work_done >= work_to_do) |
| 730 | break; |
| 731 | (*work_done)++; |
| 732 | |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 733 | if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) { |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 734 | hdr_info = le16_to_cpu(ixgbe_get_hdr_info(rx_desc)); |
| 735 | len = (hdr_info & IXGBE_RXDADV_HDRBUFLEN_MASK) >> |
Jesse Brandeburg | 762f4c5 | 2008-09-11 19:58:43 -0700 | [diff] [blame] | 736 | IXGBE_RXDADV_HDRBUFLEN_SHIFT; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 737 | if (hdr_info & IXGBE_RXDADV_SPH) |
| 738 | adapter->rx_hdr_split++; |
| 739 | if (len > IXGBE_RX_HDR_SIZE) |
| 740 | len = IXGBE_RX_HDR_SIZE; |
| 741 | upper_len = le16_to_cpu(rx_desc->wb.upper.length); |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 742 | } else { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 743 | len = le16_to_cpu(rx_desc->wb.upper.length); |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 744 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 745 | |
| 746 | cleaned = true; |
| 747 | skb = rx_buffer_info->skb; |
| 748 | prefetch(skb->data - NET_IP_ALIGN); |
| 749 | rx_buffer_info->skb = NULL; |
| 750 | |
Alexander Duyck | 21fa4e6 | 2009-06-04 15:59:49 +0000 | [diff] [blame] | 751 | if (rx_buffer_info->dma) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 752 | pci_unmap_single(pdev, rx_buffer_info->dma, |
Jesse Brandeburg | 5ecc361 | 2008-12-15 01:00:57 -0800 | [diff] [blame] | 753 | rx_ring->rx_buf_len, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 754 | PCI_DMA_FROMDEVICE); |
Jesse Brandeburg | 4f57ca6 | 2009-06-30 11:44:56 +0000 | [diff] [blame] | 755 | rx_buffer_info->dma = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 756 | skb_put(skb, len); |
| 757 | } |
| 758 | |
| 759 | if (upper_len) { |
| 760 | pci_unmap_page(pdev, rx_buffer_info->page_dma, |
Jesse Brandeburg | 762f4c5 | 2008-09-11 19:58:43 -0700 | [diff] [blame] | 761 | PAGE_SIZE / 2, PCI_DMA_FROMDEVICE); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 762 | rx_buffer_info->page_dma = 0; |
| 763 | skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags, |
Jesse Brandeburg | 762f4c5 | 2008-09-11 19:58:43 -0700 | [diff] [blame] | 764 | rx_buffer_info->page, |
| 765 | rx_buffer_info->page_offset, |
| 766 | upper_len); |
| 767 | |
| 768 | if ((rx_ring->rx_buf_len > (PAGE_SIZE / 2)) || |
| 769 | (page_count(rx_buffer_info->page) != 1)) |
| 770 | rx_buffer_info->page = NULL; |
| 771 | else |
| 772 | get_page(rx_buffer_info->page); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 773 | |
| 774 | skb->len += upper_len; |
| 775 | skb->data_len += upper_len; |
| 776 | skb->truesize += upper_len; |
| 777 | } |
| 778 | |
| 779 | i++; |
| 780 | if (i == rx_ring->count) |
| 781 | i = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 782 | |
| 783 | next_rxd = IXGBE_RX_DESC_ADV(*rx_ring, i); |
| 784 | prefetch(next_rxd); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 785 | cleaned_count++; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 786 | |
Peter P Waskiewicz Jr | 0c19d6a | 2009-07-30 12:25:28 +0000 | [diff] [blame] | 787 | if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 788 | rsc_count = ixgbe_get_rsc_count(rx_desc); |
| 789 | |
| 790 | if (rsc_count) { |
| 791 | u32 nextp = (staterr & IXGBE_RXDADV_NEXTP_MASK) >> |
| 792 | IXGBE_RXDADV_NEXTP_SHIFT; |
| 793 | next_buffer = &rx_ring->rx_buffer_info[nextp]; |
| 794 | rx_ring->rsc_count += (rsc_count - 1); |
| 795 | } else { |
| 796 | next_buffer = &rx_ring->rx_buffer_info[i]; |
| 797 | } |
| 798 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 799 | if (staterr & IXGBE_RXD_STAT_EOP) { |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 800 | if (skb->prev) |
| 801 | skb = ixgbe_transform_rsc_queue(skb); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 802 | rx_ring->stats.packets++; |
| 803 | rx_ring->stats.bytes += skb->len; |
| 804 | } else { |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 805 | if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) { |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 806 | rx_buffer_info->skb = next_buffer->skb; |
| 807 | rx_buffer_info->dma = next_buffer->dma; |
| 808 | next_buffer->skb = skb; |
| 809 | next_buffer->dma = 0; |
| 810 | } else { |
| 811 | skb->next = next_buffer->skb; |
| 812 | skb->next->prev = skb; |
| 813 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 814 | adapter->non_eop_descs++; |
| 815 | goto next_desc; |
| 816 | } |
| 817 | |
| 818 | if (staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK) { |
| 819 | dev_kfree_skb_irq(skb); |
| 820 | goto next_desc; |
| 821 | } |
| 822 | |
Don Skidmore | 8bae1b2 | 2009-07-23 18:00:39 +0000 | [diff] [blame] | 823 | ixgbe_rx_checksum(adapter, rx_desc, skb); |
Ayyappan Veeraiyan | d2f4fbe | 2008-02-01 15:59:19 -0800 | [diff] [blame] | 824 | |
| 825 | /* probably a little skewed due to removing CRC */ |
| 826 | total_rx_bytes += skb->len; |
| 827 | total_rx_packets++; |
| 828 | |
Jesse Brandeburg | 74ce8dd | 2008-09-11 20:03:23 -0700 | [diff] [blame] | 829 | skb->protocol = eth_type_trans(skb, adapter->netdev); |
Yi Zou | 332d4a7 | 2009-05-13 13:11:53 +0000 | [diff] [blame] | 830 | #ifdef IXGBE_FCOE |
| 831 | /* if ddp, not passing to ULD unless for FCP_RSP or error */ |
Yi Zou | 3d8fd38 | 2009-06-08 14:38:44 +0000 | [diff] [blame] | 832 | if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) { |
| 833 | ddp_bytes = ixgbe_fcoe_ddp(adapter, rx_desc, skb); |
| 834 | if (!ddp_bytes) |
Yi Zou | 332d4a7 | 2009-05-13 13:11:53 +0000 | [diff] [blame] | 835 | goto next_desc; |
Yi Zou | 3d8fd38 | 2009-06-08 14:38:44 +0000 | [diff] [blame] | 836 | } |
Yi Zou | 332d4a7 | 2009-05-13 13:11:53 +0000 | [diff] [blame] | 837 | #endif /* IXGBE_FCOE */ |
Alexander Duyck | fdaff1c | 2009-05-06 10:43:47 +0000 | [diff] [blame] | 838 | ixgbe_receive_skb(q_vector, skb, staterr, rx_ring, rx_desc); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 839 | |
| 840 | next_desc: |
| 841 | rx_desc->wb.upper.status_error = 0; |
| 842 | |
| 843 | /* return some buffers to hardware, one at a time is too slow */ |
| 844 | if (cleaned_count >= IXGBE_RX_BUFFER_WRITE) { |
| 845 | ixgbe_alloc_rx_buffers(adapter, rx_ring, cleaned_count); |
| 846 | cleaned_count = 0; |
| 847 | } |
| 848 | |
| 849 | /* use prefetched values */ |
| 850 | rx_desc = next_rxd; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 851 | rx_buffer_info = &rx_ring->rx_buffer_info[i]; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 852 | |
| 853 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 854 | } |
| 855 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 856 | rx_ring->next_to_clean = i; |
| 857 | cleaned_count = IXGBE_DESC_UNUSED(rx_ring); |
| 858 | |
| 859 | if (cleaned_count) |
| 860 | ixgbe_alloc_rx_buffers(adapter, rx_ring, cleaned_count); |
| 861 | |
Yi Zou | 3d8fd38 | 2009-06-08 14:38:44 +0000 | [diff] [blame] | 862 | #ifdef IXGBE_FCOE |
| 863 | /* include DDPed FCoE data */ |
| 864 | if (ddp_bytes > 0) { |
| 865 | unsigned int mss; |
| 866 | |
| 867 | mss = adapter->netdev->mtu - sizeof(struct fcoe_hdr) - |
| 868 | sizeof(struct fc_frame_header) - |
| 869 | sizeof(struct fcoe_crc_eof); |
| 870 | if (mss > 512) |
| 871 | mss &= ~511; |
| 872 | total_rx_bytes += ddp_bytes; |
| 873 | total_rx_packets += DIV_ROUND_UP(ddp_bytes, mss); |
| 874 | } |
| 875 | #endif /* IXGBE_FCOE */ |
| 876 | |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 877 | rx_ring->total_packets += total_rx_packets; |
| 878 | rx_ring->total_bytes += total_rx_bytes; |
| 879 | adapter->net_stats.rx_bytes += total_rx_bytes; |
| 880 | adapter->net_stats.rx_packets += total_rx_packets; |
| 881 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 882 | return cleaned; |
| 883 | } |
| 884 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 885 | static int ixgbe_clean_rxonly(struct napi_struct *, int); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 886 | /** |
| 887 | * ixgbe_configure_msix - Configure MSI-X hardware |
| 888 | * @adapter: board private structure |
| 889 | * |
| 890 | * ixgbe_configure_msix sets up the hardware to properly generate MSI-X |
| 891 | * interrupts. |
| 892 | **/ |
| 893 | static void ixgbe_configure_msix(struct ixgbe_adapter *adapter) |
| 894 | { |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 895 | struct ixgbe_q_vector *q_vector; |
| 896 | int i, j, q_vectors, v_idx, r_idx; |
| 897 | u32 mask; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 898 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 899 | q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
| 900 | |
Jesse Brandeburg | 4df1046 | 2009-03-13 22:15:31 +0000 | [diff] [blame] | 901 | /* |
| 902 | * Populate the IVAR table and set the ITR values to the |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 903 | * corresponding register. |
| 904 | */ |
| 905 | for (v_idx = 0; v_idx < q_vectors; v_idx++) { |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 906 | q_vector = adapter->q_vector[v_idx]; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 907 | /* XXX for_each_bit(...) */ |
| 908 | r_idx = find_first_bit(q_vector->rxr_idx, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 909 | adapter->num_rx_queues); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 910 | |
| 911 | for (i = 0; i < q_vector->rxr_count; i++) { |
| 912 | j = adapter->rx_ring[r_idx].reg_idx; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 913 | ixgbe_set_ivar(adapter, 0, j, v_idx); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 914 | r_idx = find_next_bit(q_vector->rxr_idx, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 915 | adapter->num_rx_queues, |
| 916 | r_idx + 1); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 917 | } |
| 918 | r_idx = find_first_bit(q_vector->txr_idx, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 919 | adapter->num_tx_queues); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 920 | |
| 921 | for (i = 0; i < q_vector->txr_count; i++) { |
| 922 | j = adapter->tx_ring[r_idx].reg_idx; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 923 | ixgbe_set_ivar(adapter, 1, j, v_idx); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 924 | r_idx = find_next_bit(q_vector->txr_idx, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 925 | adapter->num_tx_queues, |
| 926 | r_idx + 1); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 927 | } |
| 928 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 929 | if (q_vector->txr_count && !q_vector->rxr_count) |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 930 | /* tx only */ |
| 931 | q_vector->eitr = adapter->tx_eitr_param; |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 932 | else if (q_vector->rxr_count) |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 933 | /* rx or mixed */ |
| 934 | q_vector->eitr = adapter->rx_eitr_param; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 935 | |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 936 | ixgbe_write_eitr(q_vector); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 937 | } |
| 938 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 939 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) |
| 940 | ixgbe_set_ivar(adapter, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX, |
| 941 | v_idx); |
| 942 | else if (adapter->hw.mac.type == ixgbe_mac_82599EB) |
| 943 | ixgbe_set_ivar(adapter, -1, 1, v_idx); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 944 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITR(v_idx), 1950); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 945 | |
Jesse Brandeburg | 41fb924 | 2008-09-11 19:55:58 -0700 | [diff] [blame] | 946 | /* set up to autoclear timer, and the vectors */ |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 947 | mask = IXGBE_EIMS_ENABLE_MASK; |
Jesse Brandeburg | 41fb924 | 2008-09-11 19:55:58 -0700 | [diff] [blame] | 948 | mask &= ~(IXGBE_EIMS_OTHER | IXGBE_EIMS_LSC); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 949 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIAC, mask); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 950 | } |
| 951 | |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 952 | enum latency_range { |
| 953 | lowest_latency = 0, |
| 954 | low_latency = 1, |
| 955 | bulk_latency = 2, |
| 956 | latency_invalid = 255 |
| 957 | }; |
| 958 | |
| 959 | /** |
| 960 | * ixgbe_update_itr - update the dynamic ITR value based on statistics |
| 961 | * @adapter: pointer to adapter |
| 962 | * @eitr: eitr setting (ints per sec) to give last timeslice |
| 963 | * @itr_setting: current throttle rate in ints/second |
| 964 | * @packets: the number of packets during this measurement interval |
| 965 | * @bytes: the number of bytes during this measurement interval |
| 966 | * |
| 967 | * Stores a new ITR value based on packets and byte |
| 968 | * counts during the last interrupt. The advantage of per interrupt |
| 969 | * computation is faster updates and more accurate ITR for the current |
| 970 | * traffic pattern. Constants in this function were computed |
| 971 | * based on theoretical maximum wire speed and thresholds were set based |
| 972 | * on testing data as well as attempting to minimize response time |
| 973 | * while increasing bulk throughput. |
| 974 | * this functionality is controlled by the InterruptThrottleRate module |
| 975 | * parameter (see ixgbe_param.c) |
| 976 | **/ |
| 977 | static u8 ixgbe_update_itr(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 978 | u32 eitr, u8 itr_setting, |
| 979 | int packets, int bytes) |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 980 | { |
| 981 | unsigned int retval = itr_setting; |
| 982 | u32 timepassed_us; |
| 983 | u64 bytes_perint; |
| 984 | |
| 985 | if (packets == 0) |
| 986 | goto update_itr_done; |
| 987 | |
| 988 | |
| 989 | /* simple throttlerate management |
| 990 | * 0-20MB/s lowest (100000 ints/s) |
| 991 | * 20-100MB/s low (20000 ints/s) |
| 992 | * 100-1249MB/s bulk (8000 ints/s) |
| 993 | */ |
| 994 | /* what was last interrupt timeslice? */ |
| 995 | timepassed_us = 1000000/eitr; |
| 996 | bytes_perint = bytes / timepassed_us; /* bytes/usec */ |
| 997 | |
| 998 | switch (itr_setting) { |
| 999 | case lowest_latency: |
| 1000 | if (bytes_perint > adapter->eitr_low) |
| 1001 | retval = low_latency; |
| 1002 | break; |
| 1003 | case low_latency: |
| 1004 | if (bytes_perint > adapter->eitr_high) |
| 1005 | retval = bulk_latency; |
| 1006 | else if (bytes_perint <= adapter->eitr_low) |
| 1007 | retval = lowest_latency; |
| 1008 | break; |
| 1009 | case bulk_latency: |
| 1010 | if (bytes_perint <= adapter->eitr_high) |
| 1011 | retval = low_latency; |
| 1012 | break; |
| 1013 | } |
| 1014 | |
| 1015 | update_itr_done: |
| 1016 | return retval; |
| 1017 | } |
| 1018 | |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 1019 | /** |
| 1020 | * ixgbe_write_eitr - write EITR register in hardware specific way |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1021 | * @q_vector: structure containing interrupt and ring information |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 1022 | * |
| 1023 | * This function is made to be called by ethtool and by the driver |
| 1024 | * when it needs to update EITR registers at runtime. Hardware |
| 1025 | * specific quirks/differences are taken care of here. |
| 1026 | */ |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1027 | void ixgbe_write_eitr(struct ixgbe_q_vector *q_vector) |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 1028 | { |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1029 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 1030 | struct ixgbe_hw *hw = &adapter->hw; |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1031 | int v_idx = q_vector->v_idx; |
| 1032 | u32 itr_reg = EITR_INTS_PER_SEC_TO_REG(q_vector->eitr); |
| 1033 | |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 1034 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 1035 | /* must write high and low 16 bits to reset counter */ |
| 1036 | itr_reg |= (itr_reg << 16); |
| 1037 | } else if (adapter->hw.mac.type == ixgbe_mac_82599EB) { |
| 1038 | /* |
| 1039 | * set the WDIS bit to not clear the timer bits and cause an |
| 1040 | * immediate assertion of the interrupt |
| 1041 | */ |
| 1042 | itr_reg |= IXGBE_EITR_CNT_WDIS; |
| 1043 | } |
| 1044 | IXGBE_WRITE_REG(hw, IXGBE_EITR(v_idx), itr_reg); |
| 1045 | } |
| 1046 | |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1047 | static void ixgbe_set_itr_msix(struct ixgbe_q_vector *q_vector) |
| 1048 | { |
| 1049 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1050 | u32 new_itr; |
| 1051 | u8 current_itr, ret_itr; |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1052 | int i, r_idx; |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1053 | struct ixgbe_ring *rx_ring, *tx_ring; |
| 1054 | |
| 1055 | r_idx = find_first_bit(q_vector->txr_idx, adapter->num_tx_queues); |
| 1056 | for (i = 0; i < q_vector->txr_count; i++) { |
| 1057 | tx_ring = &(adapter->tx_ring[r_idx]); |
| 1058 | ret_itr = ixgbe_update_itr(adapter, q_vector->eitr, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1059 | q_vector->tx_itr, |
| 1060 | tx_ring->total_packets, |
| 1061 | tx_ring->total_bytes); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1062 | /* if the result for this queue would decrease interrupt |
| 1063 | * rate for this vector then use that result */ |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1064 | q_vector->tx_itr = ((q_vector->tx_itr > ret_itr) ? |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1065 | q_vector->tx_itr - 1 : ret_itr); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1066 | r_idx = find_next_bit(q_vector->txr_idx, adapter->num_tx_queues, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1067 | r_idx + 1); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues); |
| 1071 | for (i = 0; i < q_vector->rxr_count; i++) { |
| 1072 | rx_ring = &(adapter->rx_ring[r_idx]); |
| 1073 | ret_itr = ixgbe_update_itr(adapter, q_vector->eitr, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1074 | q_vector->rx_itr, |
| 1075 | rx_ring->total_packets, |
| 1076 | rx_ring->total_bytes); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1077 | /* if the result for this queue would decrease interrupt |
| 1078 | * rate for this vector then use that result */ |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1079 | q_vector->rx_itr = ((q_vector->rx_itr > ret_itr) ? |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1080 | q_vector->rx_itr - 1 : ret_itr); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1081 | r_idx = find_next_bit(q_vector->rxr_idx, adapter->num_rx_queues, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1082 | r_idx + 1); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1083 | } |
| 1084 | |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1085 | current_itr = max(q_vector->rx_itr, q_vector->tx_itr); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1086 | |
| 1087 | switch (current_itr) { |
| 1088 | /* counts and packets in update_itr are dependent on these numbers */ |
| 1089 | case lowest_latency: |
| 1090 | new_itr = 100000; |
| 1091 | break; |
| 1092 | case low_latency: |
| 1093 | new_itr = 20000; /* aka hwitr = ~200 */ |
| 1094 | break; |
| 1095 | case bulk_latency: |
| 1096 | default: |
| 1097 | new_itr = 8000; |
| 1098 | break; |
| 1099 | } |
| 1100 | |
| 1101 | if (new_itr != q_vector->eitr) { |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1102 | /* do an exponential smoothing */ |
| 1103 | new_itr = ((q_vector->eitr * 90)/100) + ((new_itr * 10)/100); |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 1104 | |
| 1105 | /* save the algorithm value here, not the smoothed one */ |
| 1106 | q_vector->eitr = new_itr; |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1107 | |
| 1108 | ixgbe_write_eitr(q_vector); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | return; |
| 1112 | } |
| 1113 | |
Jesse Brandeburg | 0befdb3 | 2008-10-31 00:46:40 -0700 | [diff] [blame] | 1114 | static void ixgbe_check_fan_failure(struct ixgbe_adapter *adapter, u32 eicr) |
| 1115 | { |
| 1116 | struct ixgbe_hw *hw = &adapter->hw; |
| 1117 | |
| 1118 | if ((adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) && |
| 1119 | (eicr & IXGBE_EICR_GPI_SDP1)) { |
| 1120 | DPRINTK(PROBE, CRIT, "Fan has stopped, replace the adapter\n"); |
| 1121 | /* write to clear the interrupt */ |
| 1122 | IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1); |
| 1123 | } |
| 1124 | } |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 1125 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1126 | static void ixgbe_check_sfp_event(struct ixgbe_adapter *adapter, u32 eicr) |
| 1127 | { |
| 1128 | struct ixgbe_hw *hw = &adapter->hw; |
| 1129 | |
| 1130 | if (eicr & IXGBE_EICR_GPI_SDP1) { |
| 1131 | /* Clear the interrupt */ |
| 1132 | IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1); |
| 1133 | schedule_work(&adapter->multispeed_fiber_task); |
| 1134 | } else if (eicr & IXGBE_EICR_GPI_SDP2) { |
| 1135 | /* Clear the interrupt */ |
| 1136 | IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP2); |
| 1137 | schedule_work(&adapter->sfp_config_module_task); |
| 1138 | } else { |
| 1139 | /* Interrupt isn't for us... */ |
| 1140 | return; |
| 1141 | } |
| 1142 | } |
| 1143 | |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 1144 | static void ixgbe_check_lsc(struct ixgbe_adapter *adapter) |
| 1145 | { |
| 1146 | struct ixgbe_hw *hw = &adapter->hw; |
| 1147 | |
| 1148 | adapter->lsc_int++; |
| 1149 | adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; |
| 1150 | adapter->link_check_timeout = jiffies; |
| 1151 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) { |
| 1152 | IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_LSC); |
| 1153 | schedule_work(&adapter->watchdog_task); |
| 1154 | } |
| 1155 | } |
| 1156 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1157 | static irqreturn_t ixgbe_msix_lsc(int irq, void *data) |
| 1158 | { |
| 1159 | struct net_device *netdev = data; |
| 1160 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 1161 | struct ixgbe_hw *hw = &adapter->hw; |
Don Skidmore | 5403750 | 2009-02-21 15:42:56 -0800 | [diff] [blame] | 1162 | u32 eicr; |
| 1163 | |
| 1164 | /* |
| 1165 | * Workaround for Silicon errata. Use clear-by-write instead |
| 1166 | * of clear-by-read. Reading with EICS will return the |
| 1167 | * interrupt causes without clearing, which later be done |
| 1168 | * with the write to EICR. |
| 1169 | */ |
| 1170 | eicr = IXGBE_READ_REG(hw, IXGBE_EICS); |
| 1171 | IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1172 | |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 1173 | if (eicr & IXGBE_EICR_LSC) |
| 1174 | ixgbe_check_lsc(adapter); |
Ayyappan Veeraiyan | d4f8088 | 2008-02-01 15:58:41 -0800 | [diff] [blame] | 1175 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1176 | if (hw->mac.type == ixgbe_mac_82598EB) |
| 1177 | ixgbe_check_fan_failure(adapter, eicr); |
Jesse Brandeburg | 0befdb3 | 2008-10-31 00:46:40 -0700 | [diff] [blame] | 1178 | |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 1179 | if (hw->mac.type == ixgbe_mac_82599EB) { |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1180 | ixgbe_check_sfp_event(adapter, eicr); |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 1181 | |
| 1182 | /* Handle Flow Director Full threshold interrupt */ |
| 1183 | if (eicr & IXGBE_EICR_FLOW_DIR) { |
| 1184 | int i; |
| 1185 | IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_FLOW_DIR); |
| 1186 | /* Disable transmits before FDIR Re-initialization */ |
| 1187 | netif_tx_stop_all_queues(netdev); |
| 1188 | for (i = 0; i < adapter->num_tx_queues; i++) { |
| 1189 | struct ixgbe_ring *tx_ring = |
| 1190 | &adapter->tx_ring[i]; |
| 1191 | if (test_and_clear_bit(__IXGBE_FDIR_INIT_DONE, |
| 1192 | &tx_ring->reinit_state)) |
| 1193 | schedule_work(&adapter->fdir_reinit_task); |
| 1194 | } |
| 1195 | } |
| 1196 | } |
Ayyappan Veeraiyan | d4f8088 | 2008-02-01 15:58:41 -0800 | [diff] [blame] | 1197 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
| 1198 | IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1199 | |
| 1200 | return IRQ_HANDLED; |
| 1201 | } |
| 1202 | |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1203 | static inline void ixgbe_irq_enable_queues(struct ixgbe_adapter *adapter, |
| 1204 | u64 qmask) |
| 1205 | { |
| 1206 | u32 mask; |
| 1207 | |
| 1208 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 1209 | mask = (IXGBE_EIMS_RTX_QUEUE & qmask); |
| 1210 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask); |
| 1211 | } else { |
| 1212 | mask = (qmask & 0xFFFFFFFF); |
| 1213 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS_EX(0), mask); |
| 1214 | mask = (qmask >> 32); |
| 1215 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS_EX(1), mask); |
| 1216 | } |
| 1217 | /* skip the flush */ |
| 1218 | } |
| 1219 | |
| 1220 | static inline void ixgbe_irq_disable_queues(struct ixgbe_adapter *adapter, |
| 1221 | u64 qmask) |
| 1222 | { |
| 1223 | u32 mask; |
| 1224 | |
| 1225 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 1226 | mask = (IXGBE_EIMS_RTX_QUEUE & qmask); |
| 1227 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, mask); |
| 1228 | } else { |
| 1229 | mask = (qmask & 0xFFFFFFFF); |
| 1230 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(0), mask); |
| 1231 | mask = (qmask >> 32); |
| 1232 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(1), mask); |
| 1233 | } |
| 1234 | /* skip the flush */ |
| 1235 | } |
| 1236 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1237 | static irqreturn_t ixgbe_msix_clean_tx(int irq, void *data) |
| 1238 | { |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1239 | struct ixgbe_q_vector *q_vector = data; |
| 1240 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1241 | struct ixgbe_ring *tx_ring; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1242 | int i, r_idx; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1243 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1244 | if (!q_vector->txr_count) |
| 1245 | return IRQ_HANDLED; |
| 1246 | |
| 1247 | r_idx = find_first_bit(q_vector->txr_idx, adapter->num_tx_queues); |
| 1248 | for (i = 0; i < q_vector->txr_count; i++) { |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1249 | tx_ring = &(adapter->tx_ring[r_idx]); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1250 | tx_ring->total_bytes = 0; |
| 1251 | tx_ring->total_packets = 0; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1252 | r_idx = find_next_bit(q_vector->txr_idx, adapter->num_tx_queues, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1253 | r_idx + 1); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1254 | } |
| 1255 | |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1256 | /* disable interrupts on this vector only */ |
| 1257 | ixgbe_irq_disable_queues(adapter, ((u64)1 << q_vector->v_idx)); |
| 1258 | napi_schedule(&q_vector->napi); |
| 1259 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1260 | return IRQ_HANDLED; |
| 1261 | } |
| 1262 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1263 | /** |
| 1264 | * ixgbe_msix_clean_rx - single unshared vector rx clean (all queues) |
| 1265 | * @irq: unused |
| 1266 | * @data: pointer to our q_vector struct for this interrupt vector |
| 1267 | **/ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1268 | static irqreturn_t ixgbe_msix_clean_rx(int irq, void *data) |
| 1269 | { |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1270 | struct ixgbe_q_vector *q_vector = data; |
| 1271 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1272 | struct ixgbe_ring *rx_ring; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1273 | int r_idx; |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1274 | int i; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1275 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1276 | r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues); |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1277 | for (i = 0; i < q_vector->rxr_count; i++) { |
| 1278 | rx_ring = &(adapter->rx_ring[r_idx]); |
| 1279 | rx_ring->total_bytes = 0; |
| 1280 | rx_ring->total_packets = 0; |
| 1281 | r_idx = find_next_bit(q_vector->rxr_idx, adapter->num_rx_queues, |
| 1282 | r_idx + 1); |
| 1283 | } |
| 1284 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1285 | if (!q_vector->rxr_count) |
| 1286 | return IRQ_HANDLED; |
| 1287 | |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1288 | r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1289 | rx_ring = &(adapter->rx_ring[r_idx]); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1290 | /* disable interrupts on this vector only */ |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1291 | ixgbe_irq_disable_queues(adapter, ((u64)1 << q_vector->v_idx)); |
Ben Hutchings | 288379f | 2009-01-19 16:43:59 -0800 | [diff] [blame] | 1292 | napi_schedule(&q_vector->napi); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1293 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1294 | return IRQ_HANDLED; |
| 1295 | } |
| 1296 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1297 | static irqreturn_t ixgbe_msix_clean_many(int irq, void *data) |
| 1298 | { |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1299 | struct ixgbe_q_vector *q_vector = data; |
| 1300 | struct ixgbe_adapter *adapter = q_vector->adapter; |
| 1301 | struct ixgbe_ring *ring; |
| 1302 | int r_idx; |
| 1303 | int i; |
| 1304 | |
| 1305 | if (!q_vector->txr_count && !q_vector->rxr_count) |
| 1306 | return IRQ_HANDLED; |
| 1307 | |
| 1308 | r_idx = find_first_bit(q_vector->txr_idx, adapter->num_tx_queues); |
| 1309 | for (i = 0; i < q_vector->txr_count; i++) { |
| 1310 | ring = &(adapter->tx_ring[r_idx]); |
| 1311 | ring->total_bytes = 0; |
| 1312 | ring->total_packets = 0; |
| 1313 | r_idx = find_next_bit(q_vector->txr_idx, adapter->num_tx_queues, |
| 1314 | r_idx + 1); |
| 1315 | } |
| 1316 | |
| 1317 | r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues); |
| 1318 | for (i = 0; i < q_vector->rxr_count; i++) { |
| 1319 | ring = &(adapter->rx_ring[r_idx]); |
| 1320 | ring->total_bytes = 0; |
| 1321 | ring->total_packets = 0; |
| 1322 | r_idx = find_next_bit(q_vector->rxr_idx, adapter->num_rx_queues, |
| 1323 | r_idx + 1); |
| 1324 | } |
| 1325 | |
| 1326 | /* disable interrupts on this vector only */ |
| 1327 | ixgbe_irq_disable_queues(adapter, ((u64)1 << q_vector->v_idx)); |
| 1328 | napi_schedule(&q_vector->napi); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1329 | |
| 1330 | return IRQ_HANDLED; |
| 1331 | } |
| 1332 | |
| 1333 | /** |
| 1334 | * ixgbe_clean_rxonly - msix (aka one shot) rx clean routine |
| 1335 | * @napi: napi struct with our devices info in it |
| 1336 | * @budget: amount of work driver is allowed to do this pass, in packets |
| 1337 | * |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1338 | * This function is optimized for cleaning one queue only on a single |
| 1339 | * q_vector!!! |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1340 | **/ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1341 | static int ixgbe_clean_rxonly(struct napi_struct *napi, int budget) |
| 1342 | { |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1343 | struct ixgbe_q_vector *q_vector = |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1344 | container_of(napi, struct ixgbe_q_vector, napi); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1345 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1346 | struct ixgbe_ring *rx_ring = NULL; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1347 | int work_done = 0; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1348 | long r_idx; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1349 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1350 | r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1351 | rx_ring = &(adapter->rx_ring[r_idx]); |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 1352 | #ifdef CONFIG_IXGBE_DCA |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 1353 | if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1354 | ixgbe_update_rx_dca(adapter, rx_ring); |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 1355 | #endif |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1356 | |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 1357 | ixgbe_clean_rx_irq(q_vector, rx_ring, &work_done, budget); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1358 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1359 | /* If all Rx work done, exit the polling mode */ |
| 1360 | if (work_done < budget) { |
Ben Hutchings | 288379f | 2009-01-19 16:43:59 -0800 | [diff] [blame] | 1361 | napi_complete(napi); |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 1362 | if (adapter->rx_itr_setting & 1) |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1363 | ixgbe_set_itr_msix(q_vector); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1364 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1365 | ixgbe_irq_enable_queues(adapter, |
| 1366 | ((u64)1 << q_vector->v_idx)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | return work_done; |
| 1370 | } |
| 1371 | |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1372 | /** |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1373 | * ixgbe_clean_rxtx_many - msix (aka one shot) rx clean routine |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1374 | * @napi: napi struct with our devices info in it |
| 1375 | * @budget: amount of work driver is allowed to do this pass, in packets |
| 1376 | * |
| 1377 | * This function will clean more than one rx queue associated with a |
| 1378 | * q_vector. |
| 1379 | **/ |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1380 | static int ixgbe_clean_rxtx_many(struct napi_struct *napi, int budget) |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1381 | { |
| 1382 | struct ixgbe_q_vector *q_vector = |
| 1383 | container_of(napi, struct ixgbe_q_vector, napi); |
| 1384 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1385 | struct ixgbe_ring *ring = NULL; |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1386 | int work_done = 0, i; |
| 1387 | long r_idx; |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1388 | bool tx_clean_complete = true; |
| 1389 | |
| 1390 | r_idx = find_first_bit(q_vector->txr_idx, adapter->num_tx_queues); |
| 1391 | for (i = 0; i < q_vector->txr_count; i++) { |
| 1392 | ring = &(adapter->tx_ring[r_idx]); |
| 1393 | #ifdef CONFIG_IXGBE_DCA |
| 1394 | if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) |
| 1395 | ixgbe_update_tx_dca(adapter, ring); |
| 1396 | #endif |
| 1397 | tx_clean_complete &= ixgbe_clean_tx_irq(q_vector, ring); |
| 1398 | r_idx = find_next_bit(q_vector->txr_idx, adapter->num_tx_queues, |
| 1399 | r_idx + 1); |
| 1400 | } |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1401 | |
| 1402 | /* attempt to distribute budget to each queue fairly, but don't allow |
| 1403 | * the budget to go below 1 because we'll exit polling */ |
| 1404 | budget /= (q_vector->rxr_count ?: 1); |
| 1405 | budget = max(budget, 1); |
| 1406 | r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues); |
| 1407 | for (i = 0; i < q_vector->rxr_count; i++) { |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1408 | ring = &(adapter->rx_ring[r_idx]); |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 1409 | #ifdef CONFIG_IXGBE_DCA |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1410 | if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1411 | ixgbe_update_rx_dca(adapter, ring); |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1412 | #endif |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1413 | ixgbe_clean_rx_irq(q_vector, ring, &work_done, budget); |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1414 | r_idx = find_next_bit(q_vector->rxr_idx, adapter->num_rx_queues, |
| 1415 | r_idx + 1); |
| 1416 | } |
| 1417 | |
| 1418 | r_idx = find_first_bit(q_vector->rxr_idx, adapter->num_rx_queues); |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1419 | ring = &(adapter->rx_ring[r_idx]); |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1420 | /* If all Rx work done, exit the polling mode */ |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 1421 | if (work_done < budget) { |
Ben Hutchings | 288379f | 2009-01-19 16:43:59 -0800 | [diff] [blame] | 1422 | napi_complete(napi); |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 1423 | if (adapter->rx_itr_setting & 1) |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1424 | ixgbe_set_itr_msix(q_vector); |
| 1425 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1426 | ixgbe_irq_enable_queues(adapter, |
| 1427 | ((u64)1 << q_vector->v_idx)); |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 1428 | return 0; |
| 1429 | } |
| 1430 | |
| 1431 | return work_done; |
| 1432 | } |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1433 | |
| 1434 | /** |
| 1435 | * ixgbe_clean_txonly - msix (aka one shot) tx clean routine |
| 1436 | * @napi: napi struct with our devices info in it |
| 1437 | * @budget: amount of work driver is allowed to do this pass, in packets |
| 1438 | * |
| 1439 | * This function is optimized for cleaning one queue only on a single |
| 1440 | * q_vector!!! |
| 1441 | **/ |
| 1442 | static int ixgbe_clean_txonly(struct napi_struct *napi, int budget) |
| 1443 | { |
| 1444 | struct ixgbe_q_vector *q_vector = |
| 1445 | container_of(napi, struct ixgbe_q_vector, napi); |
| 1446 | struct ixgbe_adapter *adapter = q_vector->adapter; |
| 1447 | struct ixgbe_ring *tx_ring = NULL; |
| 1448 | int work_done = 0; |
| 1449 | long r_idx; |
| 1450 | |
| 1451 | r_idx = find_first_bit(q_vector->txr_idx, adapter->num_tx_queues); |
| 1452 | tx_ring = &(adapter->tx_ring[r_idx]); |
| 1453 | #ifdef CONFIG_IXGBE_DCA |
| 1454 | if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) |
| 1455 | ixgbe_update_tx_dca(adapter, tx_ring); |
| 1456 | #endif |
| 1457 | |
| 1458 | if (!ixgbe_clean_tx_irq(q_vector, tx_ring)) |
| 1459 | work_done = budget; |
| 1460 | |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 1461 | /* If all Tx work done, exit the polling mode */ |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1462 | if (work_done < budget) { |
| 1463 | napi_complete(napi); |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 1464 | if (adapter->tx_itr_setting & 1) |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 1465 | ixgbe_set_itr_msix(q_vector); |
| 1466 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
| 1467 | ixgbe_irq_enable_queues(adapter, ((u64)1 << q_vector->v_idx)); |
| 1468 | } |
| 1469 | |
| 1470 | return work_done; |
| 1471 | } |
| 1472 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1473 | static inline void map_vector_to_rxq(struct ixgbe_adapter *a, int v_idx, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1474 | int r_idx) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1475 | { |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1476 | struct ixgbe_q_vector *q_vector = a->q_vector[v_idx]; |
| 1477 | |
| 1478 | set_bit(r_idx, q_vector->rxr_idx); |
| 1479 | q_vector->rxr_count++; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1480 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1481 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1482 | static inline void map_vector_to_txq(struct ixgbe_adapter *a, int v_idx, |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1483 | int t_idx) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1484 | { |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1485 | struct ixgbe_q_vector *q_vector = a->q_vector[v_idx]; |
| 1486 | |
| 1487 | set_bit(t_idx, q_vector->txr_idx); |
| 1488 | q_vector->txr_count++; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1489 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1490 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1491 | /** |
| 1492 | * ixgbe_map_rings_to_vectors - Maps descriptor rings to vectors |
| 1493 | * @adapter: board private structure to initialize |
| 1494 | * @vectors: allotted vector count for descriptor rings |
| 1495 | * |
| 1496 | * This function maps descriptor rings to the queue-specific vectors |
| 1497 | * we were allotted through the MSI-X enabling code. Ideally, we'd have |
| 1498 | * one vector per ring/queue, but on a constrained vector budget, we |
| 1499 | * group the rings as "efficiently" as possible. You would add new |
| 1500 | * mapping configurations in here. |
| 1501 | **/ |
| 1502 | static int ixgbe_map_rings_to_vectors(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1503 | int vectors) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1504 | { |
| 1505 | int v_start = 0; |
| 1506 | int rxr_idx = 0, txr_idx = 0; |
| 1507 | int rxr_remaining = adapter->num_rx_queues; |
| 1508 | int txr_remaining = adapter->num_tx_queues; |
| 1509 | int i, j; |
| 1510 | int rqpv, tqpv; |
| 1511 | int err = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1512 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1513 | /* No mapping required if MSI-X is disabled. */ |
| 1514 | if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1515 | goto out; |
| 1516 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1517 | /* |
| 1518 | * The ideal configuration... |
| 1519 | * We have enough vectors to map one per queue. |
| 1520 | */ |
| 1521 | if (vectors == adapter->num_rx_queues + adapter->num_tx_queues) { |
| 1522 | for (; rxr_idx < rxr_remaining; v_start++, rxr_idx++) |
| 1523 | map_vector_to_rxq(adapter, v_start, rxr_idx); |
| 1524 | |
| 1525 | for (; txr_idx < txr_remaining; v_start++, txr_idx++) |
| 1526 | map_vector_to_txq(adapter, v_start, txr_idx); |
| 1527 | |
| 1528 | goto out; |
| 1529 | } |
| 1530 | |
| 1531 | /* |
| 1532 | * If we don't have enough vectors for a 1-to-1 |
| 1533 | * mapping, we'll have to group them so there are |
| 1534 | * multiple queues per vector. |
| 1535 | */ |
| 1536 | /* Re-adjusting *qpv takes care of the remainder. */ |
| 1537 | for (i = v_start; i < vectors; i++) { |
| 1538 | rqpv = DIV_ROUND_UP(rxr_remaining, vectors - i); |
| 1539 | for (j = 0; j < rqpv; j++) { |
| 1540 | map_vector_to_rxq(adapter, i, rxr_idx); |
| 1541 | rxr_idx++; |
| 1542 | rxr_remaining--; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1543 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1544 | } |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1545 | for (i = v_start; i < vectors; i++) { |
| 1546 | tqpv = DIV_ROUND_UP(txr_remaining, vectors - i); |
| 1547 | for (j = 0; j < tqpv; j++) { |
| 1548 | map_vector_to_txq(adapter, i, txr_idx); |
| 1549 | txr_idx++; |
| 1550 | txr_remaining--; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1551 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1552 | } |
| 1553 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1554 | out: |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1555 | return err; |
| 1556 | } |
| 1557 | |
| 1558 | /** |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1559 | * ixgbe_request_msix_irqs - Initialize MSI-X interrupts |
| 1560 | * @adapter: board private structure |
| 1561 | * |
| 1562 | * ixgbe_request_msix_irqs allocates MSI-X vectors and requests |
| 1563 | * interrupts from the kernel. |
| 1564 | **/ |
| 1565 | static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter) |
| 1566 | { |
| 1567 | struct net_device *netdev = adapter->netdev; |
| 1568 | irqreturn_t (*handler)(int, void *); |
| 1569 | int i, vector, q_vectors, err; |
Robert Olsson | cb13fc2 | 2008-11-25 16:43:52 -0800 | [diff] [blame] | 1570 | int ri=0, ti=0; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1571 | |
| 1572 | /* Decrement for Other and TCP Timer vectors */ |
| 1573 | q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
| 1574 | |
| 1575 | /* Map the Tx/Rx rings to the vectors we were allotted. */ |
| 1576 | err = ixgbe_map_rings_to_vectors(adapter, q_vectors); |
| 1577 | if (err) |
| 1578 | goto out; |
| 1579 | |
| 1580 | #define SET_HANDLER(_v) ((!(_v)->rxr_count) ? &ixgbe_msix_clean_tx : \ |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1581 | (!(_v)->txr_count) ? &ixgbe_msix_clean_rx : \ |
| 1582 | &ixgbe_msix_clean_many) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1583 | for (vector = 0; vector < q_vectors; vector++) { |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1584 | handler = SET_HANDLER(adapter->q_vector[vector]); |
Robert Olsson | cb13fc2 | 2008-11-25 16:43:52 -0800 | [diff] [blame] | 1585 | |
| 1586 | if(handler == &ixgbe_msix_clean_rx) { |
| 1587 | sprintf(adapter->name[vector], "%s-%s-%d", |
| 1588 | netdev->name, "rx", ri++); |
| 1589 | } |
| 1590 | else if(handler == &ixgbe_msix_clean_tx) { |
| 1591 | sprintf(adapter->name[vector], "%s-%s-%d", |
| 1592 | netdev->name, "tx", ti++); |
| 1593 | } |
| 1594 | else |
| 1595 | sprintf(adapter->name[vector], "%s-%s-%d", |
| 1596 | netdev->name, "TxRx", vector); |
| 1597 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1598 | err = request_irq(adapter->msix_entries[vector].vector, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1599 | handler, 0, adapter->name[vector], |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1600 | adapter->q_vector[vector]); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1601 | if (err) { |
| 1602 | DPRINTK(PROBE, ERR, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1603 | "request_irq failed for MSIX interrupt " |
| 1604 | "Error: %d\n", err); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1605 | goto free_queue_irqs; |
| 1606 | } |
| 1607 | } |
| 1608 | |
| 1609 | sprintf(adapter->name[vector], "%s:lsc", netdev->name); |
| 1610 | err = request_irq(adapter->msix_entries[vector].vector, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1611 | &ixgbe_msix_lsc, 0, adapter->name[vector], netdev); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1612 | if (err) { |
| 1613 | DPRINTK(PROBE, ERR, |
| 1614 | "request_irq for msix_lsc failed: %d\n", err); |
| 1615 | goto free_queue_irqs; |
| 1616 | } |
| 1617 | |
| 1618 | return 0; |
| 1619 | |
| 1620 | free_queue_irqs: |
| 1621 | for (i = vector - 1; i >= 0; i--) |
| 1622 | free_irq(adapter->msix_entries[--vector].vector, |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1623 | adapter->q_vector[i]); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1624 | adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; |
| 1625 | pci_disable_msix(adapter->pdev); |
| 1626 | kfree(adapter->msix_entries); |
| 1627 | adapter->msix_entries = NULL; |
| 1628 | out: |
| 1629 | return err; |
| 1630 | } |
| 1631 | |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1632 | static void ixgbe_set_itr(struct ixgbe_adapter *adapter) |
| 1633 | { |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1634 | struct ixgbe_q_vector *q_vector = adapter->q_vector[0]; |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1635 | u8 current_itr; |
| 1636 | u32 new_itr = q_vector->eitr; |
| 1637 | struct ixgbe_ring *rx_ring = &adapter->rx_ring[0]; |
| 1638 | struct ixgbe_ring *tx_ring = &adapter->tx_ring[0]; |
| 1639 | |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1640 | q_vector->tx_itr = ixgbe_update_itr(adapter, new_itr, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1641 | q_vector->tx_itr, |
| 1642 | tx_ring->total_packets, |
| 1643 | tx_ring->total_bytes); |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1644 | q_vector->rx_itr = ixgbe_update_itr(adapter, new_itr, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1645 | q_vector->rx_itr, |
| 1646 | rx_ring->total_packets, |
| 1647 | rx_ring->total_bytes); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1648 | |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 1649 | current_itr = max(q_vector->rx_itr, q_vector->tx_itr); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1650 | |
| 1651 | switch (current_itr) { |
| 1652 | /* counts and packets in update_itr are dependent on these numbers */ |
| 1653 | case lowest_latency: |
| 1654 | new_itr = 100000; |
| 1655 | break; |
| 1656 | case low_latency: |
| 1657 | new_itr = 20000; /* aka hwitr = ~200 */ |
| 1658 | break; |
| 1659 | case bulk_latency: |
| 1660 | new_itr = 8000; |
| 1661 | break; |
| 1662 | default: |
| 1663 | break; |
| 1664 | } |
| 1665 | |
| 1666 | if (new_itr != q_vector->eitr) { |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1667 | /* do an exponential smoothing */ |
| 1668 | new_itr = ((q_vector->eitr * 90)/100) + ((new_itr * 10)/100); |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 1669 | |
| 1670 | /* save the algorithm value here, not the smoothed one */ |
| 1671 | q_vector->eitr = new_itr; |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 1672 | |
| 1673 | ixgbe_write_eitr(q_vector); |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1674 | } |
| 1675 | |
| 1676 | return; |
| 1677 | } |
| 1678 | |
Alexey Dobriyan | 79aefa4 | 2008-11-19 14:17:02 -0800 | [diff] [blame] | 1679 | /** |
Alexey Dobriyan | 79aefa4 | 2008-11-19 14:17:02 -0800 | [diff] [blame] | 1680 | * ixgbe_irq_enable - Enable default interrupt generation settings |
| 1681 | * @adapter: board private structure |
| 1682 | **/ |
| 1683 | static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter) |
| 1684 | { |
| 1685 | u32 mask; |
Nelson, Shannon | 835462f | 2009-04-27 22:42:54 +0000 | [diff] [blame] | 1686 | |
| 1687 | mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE); |
David S. Miller | 6ab33d5 | 2008-11-20 16:44:00 -0800 | [diff] [blame] | 1688 | if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) |
| 1689 | mask |= IXGBE_EIMS_GPI_SDP1; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1690 | if (adapter->hw.mac.type == ixgbe_mac_82599EB) { |
Jesse Brandeburg | 2a41ff8 | 2009-03-13 22:14:30 +0000 | [diff] [blame] | 1691 | mask |= IXGBE_EIMS_ECC; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1692 | mask |= IXGBE_EIMS_GPI_SDP1; |
| 1693 | mask |= IXGBE_EIMS_GPI_SDP2; |
| 1694 | } |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 1695 | if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || |
| 1696 | adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) |
| 1697 | mask |= IXGBE_EIMS_FLOW_DIR; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1698 | |
Alexey Dobriyan | 79aefa4 | 2008-11-19 14:17:02 -0800 | [diff] [blame] | 1699 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask); |
Nelson, Shannon | 835462f | 2009-04-27 22:42:54 +0000 | [diff] [blame] | 1700 | ixgbe_irq_enable_queues(adapter, ~0); |
Alexey Dobriyan | 79aefa4 | 2008-11-19 14:17:02 -0800 | [diff] [blame] | 1701 | IXGBE_WRITE_FLUSH(&adapter->hw); |
| 1702 | } |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1703 | |
| 1704 | /** |
| 1705 | * ixgbe_intr - legacy mode Interrupt Handler |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1706 | * @irq: interrupt number |
| 1707 | * @data: pointer to a network interface device structure |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1708 | **/ |
| 1709 | static irqreturn_t ixgbe_intr(int irq, void *data) |
| 1710 | { |
| 1711 | struct net_device *netdev = data; |
| 1712 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 1713 | struct ixgbe_hw *hw = &adapter->hw; |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1714 | struct ixgbe_q_vector *q_vector = adapter->q_vector[0]; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1715 | u32 eicr; |
| 1716 | |
Don Skidmore | 5403750 | 2009-02-21 15:42:56 -0800 | [diff] [blame] | 1717 | /* |
| 1718 | * Workaround for silicon errata. Mask the interrupts |
| 1719 | * before the read of EICR. |
| 1720 | */ |
| 1721 | IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK); |
| 1722 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1723 | /* for NAPI, using EIAM to auto-mask tx/rx interrupt bits on read |
| 1724 | * therefore no explict interrupt disable is necessary */ |
| 1725 | eicr = IXGBE_READ_REG(hw, IXGBE_EICR); |
Jesse Brandeburg | f47cf66 | 2008-09-11 19:56:14 -0700 | [diff] [blame] | 1726 | if (!eicr) { |
| 1727 | /* shared interrupt alert! |
| 1728 | * make sure interrupts are enabled because the read will |
| 1729 | * have disabled interrupts due to EIAM */ |
| 1730 | ixgbe_irq_enable(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1731 | return IRQ_NONE; /* Not our interrupt */ |
Jesse Brandeburg | f47cf66 | 2008-09-11 19:56:14 -0700 | [diff] [blame] | 1732 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1733 | |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 1734 | if (eicr & IXGBE_EICR_LSC) |
| 1735 | ixgbe_check_lsc(adapter); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1736 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1737 | if (hw->mac.type == ixgbe_mac_82599EB) |
| 1738 | ixgbe_check_sfp_event(adapter, eicr); |
| 1739 | |
Jesse Brandeburg | 0befdb3 | 2008-10-31 00:46:40 -0700 | [diff] [blame] | 1740 | ixgbe_check_fan_failure(adapter, eicr); |
| 1741 | |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1742 | if (napi_schedule_prep(&(q_vector->napi))) { |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 1743 | adapter->tx_ring[0].total_packets = 0; |
| 1744 | adapter->tx_ring[0].total_bytes = 0; |
| 1745 | adapter->rx_ring[0].total_packets = 0; |
| 1746 | adapter->rx_ring[0].total_bytes = 0; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1747 | /* would disable interrupts here but EIAM disabled it */ |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1748 | __napi_schedule(&(q_vector->napi)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1749 | } |
| 1750 | |
| 1751 | return IRQ_HANDLED; |
| 1752 | } |
| 1753 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1754 | static inline void ixgbe_reset_q_vectors(struct ixgbe_adapter *adapter) |
| 1755 | { |
| 1756 | int i, q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
| 1757 | |
| 1758 | for (i = 0; i < q_vectors; i++) { |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1759 | struct ixgbe_q_vector *q_vector = adapter->q_vector[i]; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1760 | bitmap_zero(q_vector->rxr_idx, MAX_RX_QUEUES); |
| 1761 | bitmap_zero(q_vector->txr_idx, MAX_TX_QUEUES); |
| 1762 | q_vector->rxr_count = 0; |
| 1763 | q_vector->txr_count = 0; |
| 1764 | } |
| 1765 | } |
| 1766 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1767 | /** |
| 1768 | * ixgbe_request_irq - initialize interrupts |
| 1769 | * @adapter: board private structure |
| 1770 | * |
| 1771 | * Attempts to configure interrupts using the best available |
| 1772 | * capabilities of the hardware and kernel. |
| 1773 | **/ |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1774 | static int ixgbe_request_irq(struct ixgbe_adapter *adapter) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1775 | { |
| 1776 | struct net_device *netdev = adapter->netdev; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1777 | int err; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1778 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1779 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { |
| 1780 | err = ixgbe_request_msix_irqs(adapter); |
| 1781 | } else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) { |
| 1782 | err = request_irq(adapter->pdev->irq, &ixgbe_intr, 0, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1783 | netdev->name, netdev); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1784 | } else { |
| 1785 | err = request_irq(adapter->pdev->irq, &ixgbe_intr, IRQF_SHARED, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 1786 | netdev->name, netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1787 | } |
| 1788 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1789 | if (err) |
| 1790 | DPRINTK(PROBE, ERR, "request_irq failed, Error %d\n", err); |
| 1791 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1792 | return err; |
| 1793 | } |
| 1794 | |
| 1795 | static void ixgbe_free_irq(struct ixgbe_adapter *adapter) |
| 1796 | { |
| 1797 | struct net_device *netdev = adapter->netdev; |
| 1798 | |
| 1799 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1800 | int i, q_vectors; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1801 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1802 | q_vectors = adapter->num_msix_vectors; |
| 1803 | |
| 1804 | i = q_vectors - 1; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1805 | free_irq(adapter->msix_entries[i].vector, netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1806 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1807 | i--; |
| 1808 | for (; i >= 0; i--) { |
| 1809 | free_irq(adapter->msix_entries[i].vector, |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 1810 | adapter->q_vector[i]); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1811 | } |
| 1812 | |
| 1813 | ixgbe_reset_q_vectors(adapter); |
| 1814 | } else { |
| 1815 | free_irq(adapter->pdev->irq, netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1816 | } |
| 1817 | } |
| 1818 | |
| 1819 | /** |
Jesse Brandeburg | 22d5a71 | 2009-03-19 01:24:04 +0000 | [diff] [blame] | 1820 | * ixgbe_irq_disable - Mask off interrupt generation on the NIC |
| 1821 | * @adapter: board private structure |
| 1822 | **/ |
| 1823 | static inline void ixgbe_irq_disable(struct ixgbe_adapter *adapter) |
| 1824 | { |
Nelson, Shannon | 835462f | 2009-04-27 22:42:54 +0000 | [diff] [blame] | 1825 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 1826 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0); |
| 1827 | } else { |
| 1828 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, 0xFFFF0000); |
| 1829 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(0), ~0); |
Jesse Brandeburg | 22d5a71 | 2009-03-19 01:24:04 +0000 | [diff] [blame] | 1830 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(1), ~0); |
Jesse Brandeburg | 22d5a71 | 2009-03-19 01:24:04 +0000 | [diff] [blame] | 1831 | } |
| 1832 | IXGBE_WRITE_FLUSH(&adapter->hw); |
| 1833 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { |
| 1834 | int i; |
| 1835 | for (i = 0; i < adapter->num_msix_vectors; i++) |
| 1836 | synchronize_irq(adapter->msix_entries[i].vector); |
| 1837 | } else { |
| 1838 | synchronize_irq(adapter->pdev->irq); |
| 1839 | } |
| 1840 | } |
| 1841 | |
Jesse Brandeburg | 22d5a71 | 2009-03-19 01:24:04 +0000 | [diff] [blame] | 1842 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1843 | * ixgbe_configure_msi_and_legacy - Initialize PIN (INTA...) and MSI interrupts |
| 1844 | * |
| 1845 | **/ |
| 1846 | static void ixgbe_configure_msi_and_legacy(struct ixgbe_adapter *adapter) |
| 1847 | { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1848 | struct ixgbe_hw *hw = &adapter->hw; |
| 1849 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1850 | IXGBE_WRITE_REG(hw, IXGBE_EITR(0), |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 1851 | EITR_INTS_PER_SEC_TO_REG(adapter->rx_eitr_param)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1852 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1853 | ixgbe_set_ivar(adapter, 0, 0, 0); |
| 1854 | ixgbe_set_ivar(adapter, 1, 0, 0); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1855 | |
| 1856 | map_vector_to_rxq(adapter, 0, 0); |
| 1857 | map_vector_to_txq(adapter, 0, 0); |
| 1858 | |
| 1859 | DPRINTK(HW, INFO, "Legacy interrupt IVAR setup done\n"); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1860 | } |
| 1861 | |
| 1862 | /** |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1863 | * ixgbe_configure_tx - Configure 8259x Transmit Unit after Reset |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1864 | * @adapter: board private structure |
| 1865 | * |
| 1866 | * Configure the Tx unit of the MAC after a reset. |
| 1867 | **/ |
| 1868 | static void ixgbe_configure_tx(struct ixgbe_adapter *adapter) |
| 1869 | { |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 1870 | u64 tdba; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1871 | struct ixgbe_hw *hw = &adapter->hw; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1872 | u32 i, j, tdlen, txctrl; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1873 | |
| 1874 | /* Setup the HW Tx Head and Tail descriptor pointers */ |
| 1875 | for (i = 0; i < adapter->num_tx_queues; i++) { |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 1876 | struct ixgbe_ring *ring = &adapter->tx_ring[i]; |
| 1877 | j = ring->reg_idx; |
| 1878 | tdba = ring->dma; |
| 1879 | tdlen = ring->count * sizeof(union ixgbe_adv_tx_desc); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1880 | IXGBE_WRITE_REG(hw, IXGBE_TDBAL(j), |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1881 | (tdba & DMA_BIT_MASK(32))); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1882 | IXGBE_WRITE_REG(hw, IXGBE_TDBAH(j), (tdba >> 32)); |
| 1883 | IXGBE_WRITE_REG(hw, IXGBE_TDLEN(j), tdlen); |
| 1884 | IXGBE_WRITE_REG(hw, IXGBE_TDH(j), 0); |
| 1885 | IXGBE_WRITE_REG(hw, IXGBE_TDT(j), 0); |
| 1886 | adapter->tx_ring[i].head = IXGBE_TDH(j); |
| 1887 | adapter->tx_ring[i].tail = IXGBE_TDT(j); |
| 1888 | /* Disable Tx Head Writeback RO bit, since this hoses |
| 1889 | * bookkeeping if things aren't delivered in order. |
| 1890 | */ |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 1891 | txctrl = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(j)); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1892 | txctrl &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN; |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 1893 | IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(j), txctrl); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1894 | } |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1895 | if (hw->mac.type == ixgbe_mac_82599EB) { |
| 1896 | /* We enable 8 traffic classes, DCB only */ |
| 1897 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) |
| 1898 | IXGBE_WRITE_REG(hw, IXGBE_MTQC, (IXGBE_MTQC_RT_ENA | |
| 1899 | IXGBE_MTQC_8TC_8TQ)); |
| 1900 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1901 | } |
| 1902 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1903 | #define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2 |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1904 | |
Yi Zou | a6616b4 | 2009-08-06 13:05:23 +0000 | [diff] [blame] | 1905 | static void ixgbe_configure_srrctl(struct ixgbe_adapter *adapter, |
| 1906 | struct ixgbe_ring *rx_ring) |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1907 | { |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1908 | u32 srrctl; |
Yi Zou | a6616b4 | 2009-08-06 13:05:23 +0000 | [diff] [blame] | 1909 | int index; |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 1910 | struct ixgbe_ring_feature *feature = adapter->ring_feature; |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1911 | |
Yi Zou | a6616b4 | 2009-08-06 13:05:23 +0000 | [diff] [blame] | 1912 | index = rx_ring->reg_idx; |
| 1913 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 1914 | unsigned long mask; |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 1915 | mask = (unsigned long) feature[RING_F_RSS].mask; |
Alexander Duyck | 3be1adf | 2008-08-30 00:29:10 -0700 | [diff] [blame] | 1916 | index = index & mask; |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1917 | } |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1918 | srrctl = IXGBE_READ_REG(&adapter->hw, IXGBE_SRRCTL(index)); |
| 1919 | |
| 1920 | srrctl &= ~IXGBE_SRRCTL_BSIZEHDR_MASK; |
| 1921 | srrctl &= ~IXGBE_SRRCTL_BSIZEPKT_MASK; |
| 1922 | |
Alexander Duyck | afafd5b | 2009-05-07 10:38:56 +0000 | [diff] [blame] | 1923 | srrctl |= (IXGBE_RX_HDR_SIZE << IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) & |
| 1924 | IXGBE_SRRCTL_BSIZEHDR_MASK; |
| 1925 | |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 1926 | if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) { |
Alexander Duyck | afafd5b | 2009-05-07 10:38:56 +0000 | [diff] [blame] | 1927 | #if (PAGE_SIZE / 2) > IXGBE_MAX_RXBUFFER |
| 1928 | srrctl |= IXGBE_MAX_RXBUFFER >> IXGBE_SRRCTL_BSIZEPKT_SHIFT; |
| 1929 | #else |
| 1930 | srrctl |= (PAGE_SIZE / 2) >> IXGBE_SRRCTL_BSIZEPKT_SHIFT; |
| 1931 | #endif |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1932 | srrctl |= IXGBE_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS; |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1933 | } else { |
Alexander Duyck | afafd5b | 2009-05-07 10:38:56 +0000 | [diff] [blame] | 1934 | srrctl |= ALIGN(rx_ring->rx_buf_len, 1024) >> |
| 1935 | IXGBE_SRRCTL_BSIZEPKT_SHIFT; |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1936 | srrctl |= IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF; |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1937 | } |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 1938 | |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1939 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_SRRCTL(index), srrctl); |
| 1940 | } |
| 1941 | |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 1942 | static u32 ixgbe_setup_mrqc(struct ixgbe_adapter *adapter) |
| 1943 | { |
| 1944 | u32 mrqc = 0; |
| 1945 | int mask; |
| 1946 | |
| 1947 | if (!(adapter->hw.mac.type == ixgbe_mac_82599EB)) |
| 1948 | return mrqc; |
| 1949 | |
| 1950 | mask = adapter->flags & (IXGBE_FLAG_RSS_ENABLED |
| 1951 | #ifdef CONFIG_IXGBE_DCB |
| 1952 | | IXGBE_FLAG_DCB_ENABLED |
| 1953 | #endif |
| 1954 | ); |
| 1955 | |
| 1956 | switch (mask) { |
| 1957 | case (IXGBE_FLAG_RSS_ENABLED): |
| 1958 | mrqc = IXGBE_MRQC_RSSEN; |
| 1959 | break; |
| 1960 | #ifdef CONFIG_IXGBE_DCB |
| 1961 | case (IXGBE_FLAG_DCB_ENABLED): |
| 1962 | mrqc = IXGBE_MRQC_RT8TCEN; |
| 1963 | break; |
| 1964 | #endif /* CONFIG_IXGBE_DCB */ |
| 1965 | default: |
| 1966 | break; |
| 1967 | } |
| 1968 | |
| 1969 | return mrqc; |
| 1970 | } |
| 1971 | |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 1972 | /** |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 1973 | * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1974 | * @adapter: board private structure |
| 1975 | * |
| 1976 | * Configure the Rx unit of the MAC after a reset. |
| 1977 | **/ |
| 1978 | static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) |
| 1979 | { |
| 1980 | u64 rdba; |
| 1981 | struct ixgbe_hw *hw = &adapter->hw; |
Yi Zou | a6616b4 | 2009-08-06 13:05:23 +0000 | [diff] [blame] | 1982 | struct ixgbe_ring *rx_ring; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1983 | struct net_device *netdev = adapter->netdev; |
| 1984 | int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 1985 | int i, j; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1986 | u32 rdlen, rxctrl, rxcsum; |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 1987 | static const u32 seed[10] = { 0xE291D73D, 0x1805EC6C, 0x2A94B30D, |
| 1988 | 0xA54F2BEC, 0xEA49AF7C, 0xE214AD3D, 0xB855AABE, |
| 1989 | 0x6A3E67EA, 0x14364D17, 0x3BED200D}; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1990 | u32 fctrl, hlreg0; |
Jesse Brandeburg | 509ee93 | 2009-03-13 22:13:28 +0000 | [diff] [blame] | 1991 | u32 reta = 0, mrqc = 0; |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 1992 | u32 rdrxctl; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 1993 | u32 rscctrl; |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 1994 | int rx_buf_len; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1995 | |
| 1996 | /* Decide whether to use packet split mode or not */ |
Jesse Brandeburg | 762f4c5 | 2008-09-11 19:58:43 -0700 | [diff] [blame] | 1997 | adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 1998 | |
| 1999 | /* Set the RX buffer length according to the mode */ |
| 2000 | if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 2001 | rx_buf_len = IXGBE_RX_HDR_SIZE; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2002 | if (hw->mac.type == ixgbe_mac_82599EB) { |
| 2003 | /* PSRTYPE must be initialized in 82599 */ |
| 2004 | u32 psrtype = IXGBE_PSRTYPE_TCPHDR | |
| 2005 | IXGBE_PSRTYPE_UDPHDR | |
| 2006 | IXGBE_PSRTYPE_IPV4HDR | |
Yi Zou | dfa12f0 | 2009-05-07 10:39:35 +0000 | [diff] [blame] | 2007 | IXGBE_PSRTYPE_IPV6HDR | |
| 2008 | IXGBE_PSRTYPE_L2HDR; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2009 | IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(0), psrtype); |
| 2010 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2011 | } else { |
Peter P Waskiewicz Jr | 0c19d6a | 2009-07-30 12:25:28 +0000 | [diff] [blame] | 2012 | if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) && |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2013 | (netdev->mtu <= ETH_DATA_LEN)) |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 2014 | rx_buf_len = MAXIMUM_ETHERNET_VLAN_SIZE; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2015 | else |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 2016 | rx_buf_len = ALIGN(max_frame, 1024); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | fctrl = IXGBE_READ_REG(&adapter->hw, IXGBE_FCTRL); |
| 2020 | fctrl |= IXGBE_FCTRL_BAM; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2021 | fctrl |= IXGBE_FCTRL_DPF; /* discard pause frames when FC enabled */ |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2022 | fctrl |= IXGBE_FCTRL_PMCF; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2023 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCTRL, fctrl); |
| 2024 | |
| 2025 | hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0); |
| 2026 | if (adapter->netdev->mtu <= ETH_DATA_LEN) |
| 2027 | hlreg0 &= ~IXGBE_HLREG0_JUMBOEN; |
| 2028 | else |
| 2029 | hlreg0 |= IXGBE_HLREG0_JUMBOEN; |
Yi Zou | 63f39bd | 2009-05-17 12:34:35 +0000 | [diff] [blame] | 2030 | #ifdef IXGBE_FCOE |
Yi Zou | f34c5c8 | 2009-08-14 12:42:17 +0000 | [diff] [blame] | 2031 | if (netdev->features & NETIF_F_FCOE_MTU) |
Yi Zou | 63f39bd | 2009-05-17 12:34:35 +0000 | [diff] [blame] | 2032 | hlreg0 |= IXGBE_HLREG0_JUMBOEN; |
| 2033 | #endif |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2034 | IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); |
| 2035 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2036 | rdlen = adapter->rx_ring[0].count * sizeof(union ixgbe_adv_rx_desc); |
| 2037 | /* disable receives while setting up the descriptors */ |
| 2038 | rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL); |
| 2039 | IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl & ~IXGBE_RXCTRL_RXEN); |
| 2040 | |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 2041 | /* |
| 2042 | * Setup the HW Rx Head and Tail Descriptor Pointers and |
| 2043 | * the Base and Length of the Rx Descriptor Ring |
| 2044 | */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2045 | for (i = 0; i < adapter->num_rx_queues; i++) { |
Yi Zou | a6616b4 | 2009-08-06 13:05:23 +0000 | [diff] [blame] | 2046 | rx_ring = &adapter->rx_ring[i]; |
| 2047 | rdba = rx_ring->dma; |
| 2048 | j = rx_ring->reg_idx; |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 2049 | IXGBE_WRITE_REG(hw, IXGBE_RDBAL(j), (rdba & DMA_BIT_MASK(32))); |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 2050 | IXGBE_WRITE_REG(hw, IXGBE_RDBAH(j), (rdba >> 32)); |
| 2051 | IXGBE_WRITE_REG(hw, IXGBE_RDLEN(j), rdlen); |
| 2052 | IXGBE_WRITE_REG(hw, IXGBE_RDH(j), 0); |
| 2053 | IXGBE_WRITE_REG(hw, IXGBE_RDT(j), 0); |
Yi Zou | a6616b4 | 2009-08-06 13:05:23 +0000 | [diff] [blame] | 2054 | rx_ring->head = IXGBE_RDH(j); |
| 2055 | rx_ring->tail = IXGBE_RDT(j); |
| 2056 | rx_ring->rx_buf_len = rx_buf_len; |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 2057 | |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 2058 | if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) |
| 2059 | rx_ring->flags |= IXGBE_RING_RX_PS_ENABLED; |
Peter P Waskiewicz Jr | 1b3ff02 | 2009-09-14 07:47:27 +0000 | [diff] [blame] | 2060 | else |
| 2061 | rx_ring->flags &= ~IXGBE_RING_RX_PS_ENABLED; |
Jesse Brandeburg | cc41ac7 | 2008-08-26 04:27:27 -0700 | [diff] [blame] | 2062 | |
Yi Zou | 63f39bd | 2009-05-17 12:34:35 +0000 | [diff] [blame] | 2063 | #ifdef IXGBE_FCOE |
Yi Zou | f34c5c8 | 2009-08-14 12:42:17 +0000 | [diff] [blame] | 2064 | if (netdev->features & NETIF_F_FCOE_MTU) { |
Yi Zou | 63f39bd | 2009-05-17 12:34:35 +0000 | [diff] [blame] | 2065 | struct ixgbe_ring_feature *f; |
| 2066 | f = &adapter->ring_feature[RING_F_FCOE]; |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 2067 | if ((i >= f->mask) && (i < f->mask + f->indices)) { |
| 2068 | rx_ring->flags &= ~IXGBE_RING_RX_PS_ENABLED; |
| 2069 | if (rx_buf_len < IXGBE_FCOE_JUMBO_FRAME_SIZE) |
| 2070 | rx_ring->rx_buf_len = |
| 2071 | IXGBE_FCOE_JUMBO_FRAME_SIZE; |
| 2072 | } |
Yi Zou | 63f39bd | 2009-05-17 12:34:35 +0000 | [diff] [blame] | 2073 | } |
| 2074 | |
| 2075 | #endif /* IXGBE_FCOE */ |
Yi Zou | a6616b4 | 2009-08-06 13:05:23 +0000 | [diff] [blame] | 2076 | ixgbe_configure_srrctl(adapter, rx_ring); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2077 | } |
| 2078 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2079 | if (hw->mac.type == ixgbe_mac_82598EB) { |
| 2080 | /* |
| 2081 | * For VMDq support of different descriptor types or |
| 2082 | * buffer sizes through the use of multiple SRRCTL |
| 2083 | * registers, RDRXCTL.MVMEN must be set to 1 |
| 2084 | * |
| 2085 | * also, the manual doesn't mention it clearly but DCA hints |
| 2086 | * will only use queue 0's tags unless this bit is set. Side |
| 2087 | * effects of setting this bit are only that SRRCTL must be |
| 2088 | * fully programmed [0..15] |
| 2089 | */ |
Jesse Brandeburg | 2a41ff8 | 2009-03-13 22:14:30 +0000 | [diff] [blame] | 2090 | rdrxctl = IXGBE_READ_REG(hw, IXGBE_RDRXCTL); |
| 2091 | rdrxctl |= IXGBE_RDRXCTL_MVMEN; |
| 2092 | IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 2093 | } |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 2094 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2095 | /* Program MRQC for the distribution of queues */ |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 2096 | mrqc = ixgbe_setup_mrqc(adapter); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2097 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2098 | if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2099 | /* Fill out redirection table */ |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2100 | for (i = 0, j = 0; i < 128; i++, j++) { |
| 2101 | if (j == adapter->ring_feature[RING_F_RSS].indices) |
| 2102 | j = 0; |
| 2103 | /* reta = 4-byte sliding window of |
| 2104 | * 0x00..(indices-1)(indices-1)00..etc. */ |
| 2105 | reta = (reta << 8) | (j * 0x11); |
| 2106 | if ((i & 3) == 3) |
| 2107 | IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2108 | } |
| 2109 | |
| 2110 | /* Fill out hash function seeds */ |
| 2111 | for (i = 0; i < 10; i++) |
Jesse Brandeburg | 7c6e0a4 | 2008-08-26 04:27:16 -0700 | [diff] [blame] | 2112 | IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), seed[i]); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2113 | |
Jesse Brandeburg | 2a41ff8 | 2009-03-13 22:14:30 +0000 | [diff] [blame] | 2114 | if (hw->mac.type == ixgbe_mac_82598EB) |
| 2115 | mrqc |= IXGBE_MRQC_RSSEN; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2116 | /* Perform hash on these packet types */ |
Jesse Brandeburg | 2a41ff8 | 2009-03-13 22:14:30 +0000 | [diff] [blame] | 2117 | mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4 |
| 2118 | | IXGBE_MRQC_RSS_FIELD_IPV4_TCP |
| 2119 | | IXGBE_MRQC_RSS_FIELD_IPV4_UDP |
| 2120 | | IXGBE_MRQC_RSS_FIELD_IPV6 |
| 2121 | | IXGBE_MRQC_RSS_FIELD_IPV6_TCP |
| 2122 | | IXGBE_MRQC_RSS_FIELD_IPV6_UDP; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2123 | } |
Jesse Brandeburg | 2a41ff8 | 2009-03-13 22:14:30 +0000 | [diff] [blame] | 2124 | IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2125 | |
| 2126 | rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM); |
| 2127 | |
| 2128 | if (adapter->flags & IXGBE_FLAG_RSS_ENABLED || |
| 2129 | adapter->flags & IXGBE_FLAG_RX_CSUM_ENABLED) { |
| 2130 | /* Disable indicating checksum in descriptor, enables |
| 2131 | * RSS hash */ |
| 2132 | rxcsum |= IXGBE_RXCSUM_PCSD; |
| 2133 | } |
| 2134 | if (!(rxcsum & IXGBE_RXCSUM_PCSD)) { |
| 2135 | /* Enable IPv4 payload checksum for UDP fragments |
| 2136 | * if PCSD is not set */ |
| 2137 | rxcsum |= IXGBE_RXCSUM_IPPCSE; |
| 2138 | } |
| 2139 | |
| 2140 | IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, rxcsum); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2141 | |
| 2142 | if (hw->mac.type == ixgbe_mac_82599EB) { |
| 2143 | rdrxctl = IXGBE_READ_REG(hw, IXGBE_RDRXCTL); |
| 2144 | rdrxctl |= IXGBE_RDRXCTL_CRCSTRIP; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2145 | rdrxctl &= ~IXGBE_RDRXCTL_RSCFRSTSIZE; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2146 | IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl); |
| 2147 | } |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2148 | |
Peter P Waskiewicz Jr | 0c19d6a | 2009-07-30 12:25:28 +0000 | [diff] [blame] | 2149 | if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2150 | /* Enable 82599 HW-RSC */ |
| 2151 | for (i = 0; i < adapter->num_rx_queues; i++) { |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 2152 | rx_ring = &adapter->rx_ring[i]; |
| 2153 | j = rx_ring->reg_idx; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2154 | rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j)); |
| 2155 | rscctrl |= IXGBE_RSCCTL_RSCEN; |
| 2156 | /* |
Alexander Duyck | e76678d | 2009-05-17 20:57:47 +0000 | [diff] [blame] | 2157 | * we must limit the number of descriptors so that the |
| 2158 | * total size of max desc * buf_len is not greater |
| 2159 | * than 65535 |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2160 | */ |
Yi Zou | 6e455b89 | 2009-08-06 13:05:44 +0000 | [diff] [blame] | 2161 | if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) { |
Alexander Duyck | e76678d | 2009-05-17 20:57:47 +0000 | [diff] [blame] | 2162 | #if (MAX_SKB_FRAGS > 16) |
| 2163 | rscctrl |= IXGBE_RSCCTL_MAXDESC_16; |
| 2164 | #elif (MAX_SKB_FRAGS > 8) |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2165 | rscctrl |= IXGBE_RSCCTL_MAXDESC_8; |
Alexander Duyck | e76678d | 2009-05-17 20:57:47 +0000 | [diff] [blame] | 2166 | #elif (MAX_SKB_FRAGS > 4) |
| 2167 | rscctrl |= IXGBE_RSCCTL_MAXDESC_4; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2168 | #else |
Alexander Duyck | e76678d | 2009-05-17 20:57:47 +0000 | [diff] [blame] | 2169 | rscctrl |= IXGBE_RSCCTL_MAXDESC_1; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2170 | #endif |
Alexander Duyck | e76678d | 2009-05-17 20:57:47 +0000 | [diff] [blame] | 2171 | } else { |
| 2172 | if (rx_buf_len < IXGBE_RXBUFFER_4096) |
| 2173 | rscctrl |= IXGBE_RSCCTL_MAXDESC_16; |
| 2174 | else if (rx_buf_len < IXGBE_RXBUFFER_8192) |
| 2175 | rscctrl |= IXGBE_RSCCTL_MAXDESC_8; |
| 2176 | else |
| 2177 | rscctrl |= IXGBE_RSCCTL_MAXDESC_4; |
| 2178 | } |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2179 | IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(j), rscctrl); |
| 2180 | } |
| 2181 | /* Disable RSC for ACK packets */ |
| 2182 | IXGBE_WRITE_REG(hw, IXGBE_RSCDBU, |
| 2183 | (IXGBE_RSCDBU_RSCACKDIS | IXGBE_READ_REG(hw, IXGBE_RSCDBU))); |
| 2184 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2185 | } |
| 2186 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2187 | static void ixgbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid) |
| 2188 | { |
| 2189 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 2190 | struct ixgbe_hw *hw = &adapter->hw; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2191 | |
| 2192 | /* add VID to filter table */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 2193 | hw->mac.ops.set_vfta(&adapter->hw, vid, 0, true); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2194 | } |
| 2195 | |
| 2196 | static void ixgbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) |
| 2197 | { |
| 2198 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 2199 | struct ixgbe_hw *hw = &adapter->hw; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2200 | |
Ayyappan Veeraiyan | d4f8088 | 2008-02-01 15:58:41 -0800 | [diff] [blame] | 2201 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
| 2202 | ixgbe_irq_disable(adapter); |
| 2203 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2204 | vlan_group_set_device(adapter->vlgrp, vid, NULL); |
Ayyappan Veeraiyan | d4f8088 | 2008-02-01 15:58:41 -0800 | [diff] [blame] | 2205 | |
| 2206 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
| 2207 | ixgbe_irq_enable(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2208 | |
| 2209 | /* remove VID from filter table */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 2210 | hw->mac.ops.set_vfta(&adapter->hw, vid, 0, false); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2211 | } |
| 2212 | |
Don Skidmore | 068c89b | 2009-01-19 16:54:36 -0800 | [diff] [blame] | 2213 | static void ixgbe_vlan_rx_register(struct net_device *netdev, |
| 2214 | struct vlan_group *grp) |
| 2215 | { |
| 2216 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 2217 | u32 ctrl; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2218 | int i, j; |
Don Skidmore | 068c89b | 2009-01-19 16:54:36 -0800 | [diff] [blame] | 2219 | |
| 2220 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
| 2221 | ixgbe_irq_disable(adapter); |
| 2222 | adapter->vlgrp = grp; |
| 2223 | |
| 2224 | /* |
| 2225 | * For a DCB driver, always enable VLAN tag stripping so we can |
| 2226 | * still receive traffic from a DCB-enabled host even if we're |
| 2227 | * not in DCB mode. |
| 2228 | */ |
| 2229 | ctrl = IXGBE_READ_REG(&adapter->hw, IXGBE_VLNCTRL); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2230 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
| 2231 | ctrl |= IXGBE_VLNCTRL_VME | IXGBE_VLNCTRL_VFE; |
Don Skidmore | 068c89b | 2009-01-19 16:54:36 -0800 | [diff] [blame] | 2232 | ctrl &= ~IXGBE_VLNCTRL_CFIEN; |
| 2233 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_VLNCTRL, ctrl); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2234 | } else if (adapter->hw.mac.type == ixgbe_mac_82599EB) { |
| 2235 | ctrl |= IXGBE_VLNCTRL_VFE; |
| 2236 | /* enable VLAN tag insert/strip */ |
| 2237 | ctrl = IXGBE_READ_REG(&adapter->hw, IXGBE_VLNCTRL); |
| 2238 | ctrl &= ~IXGBE_VLNCTRL_CFIEN; |
| 2239 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_VLNCTRL, ctrl); |
| 2240 | for (i = 0; i < adapter->num_rx_queues; i++) { |
| 2241 | j = adapter->rx_ring[i].reg_idx; |
| 2242 | ctrl = IXGBE_READ_REG(&adapter->hw, IXGBE_RXDCTL(j)); |
| 2243 | ctrl |= IXGBE_RXDCTL_VME; |
| 2244 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_RXDCTL(j), ctrl); |
| 2245 | } |
Don Skidmore | 068c89b | 2009-01-19 16:54:36 -0800 | [diff] [blame] | 2246 | } |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2247 | ixgbe_vlan_rx_add_vid(netdev, 0); |
Don Skidmore | 068c89b | 2009-01-19 16:54:36 -0800 | [diff] [blame] | 2248 | |
| 2249 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
| 2250 | ixgbe_irq_enable(adapter); |
| 2251 | } |
| 2252 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2253 | static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter) |
| 2254 | { |
| 2255 | ixgbe_vlan_rx_register(adapter->netdev, adapter->vlgrp); |
| 2256 | |
| 2257 | if (adapter->vlgrp) { |
| 2258 | u16 vid; |
| 2259 | for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) { |
| 2260 | if (!vlan_group_get_device(adapter->vlgrp, vid)) |
| 2261 | continue; |
| 2262 | ixgbe_vlan_rx_add_vid(adapter->netdev, vid); |
| 2263 | } |
| 2264 | } |
| 2265 | } |
| 2266 | |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2267 | static u8 *ixgbe_addr_list_itr(struct ixgbe_hw *hw, u8 **mc_addr_ptr, u32 *vmdq) |
| 2268 | { |
| 2269 | struct dev_mc_list *mc_ptr; |
| 2270 | u8 *addr = *mc_addr_ptr; |
| 2271 | *vmdq = 0; |
| 2272 | |
| 2273 | mc_ptr = container_of(addr, struct dev_mc_list, dmi_addr[0]); |
| 2274 | if (mc_ptr->next) |
| 2275 | *mc_addr_ptr = mc_ptr->next->dmi_addr; |
| 2276 | else |
| 2277 | *mc_addr_ptr = NULL; |
| 2278 | |
| 2279 | return addr; |
| 2280 | } |
| 2281 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2282 | /** |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2283 | * ixgbe_set_rx_mode - Unicast, Multicast and Promiscuous mode set |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2284 | * @netdev: network interface device structure |
| 2285 | * |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2286 | * The set_rx_method entry point is called whenever the unicast/multicast |
| 2287 | * address list or the network interface flags are updated. This routine is |
| 2288 | * responsible for configuring the hardware for proper unicast, multicast and |
| 2289 | * promiscuous mode. |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2290 | **/ |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2291 | static void ixgbe_set_rx_mode(struct net_device *netdev) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2292 | { |
| 2293 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 2294 | struct ixgbe_hw *hw = &adapter->hw; |
Alexander Duyck | 3d01625 | 2008-08-26 18:30:04 -0700 | [diff] [blame] | 2295 | u32 fctrl, vlnctrl; |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2296 | u8 *addr_list = NULL; |
| 2297 | int addr_count = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2298 | |
| 2299 | /* Check for Promiscuous and All Multicast modes */ |
| 2300 | |
| 2301 | fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL); |
Alexander Duyck | 3d01625 | 2008-08-26 18:30:04 -0700 | [diff] [blame] | 2302 | vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2303 | |
| 2304 | if (netdev->flags & IFF_PROMISC) { |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2305 | hw->addr_ctrl.user_set_promisc = 1; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2306 | fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE); |
Alexander Duyck | 3d01625 | 2008-08-26 18:30:04 -0700 | [diff] [blame] | 2307 | vlnctrl &= ~IXGBE_VLNCTRL_VFE; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2308 | } else { |
Patrick McHardy | 746b9f0 | 2008-07-16 20:15:45 -0700 | [diff] [blame] | 2309 | if (netdev->flags & IFF_ALLMULTI) { |
| 2310 | fctrl |= IXGBE_FCTRL_MPE; |
| 2311 | fctrl &= ~IXGBE_FCTRL_UPE; |
| 2312 | } else { |
| 2313 | fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE); |
| 2314 | } |
Alexander Duyck | 3d01625 | 2008-08-26 18:30:04 -0700 | [diff] [blame] | 2315 | vlnctrl |= IXGBE_VLNCTRL_VFE; |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2316 | hw->addr_ctrl.user_set_promisc = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2317 | } |
| 2318 | |
| 2319 | IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl); |
Alexander Duyck | 3d01625 | 2008-08-26 18:30:04 -0700 | [diff] [blame] | 2320 | IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2321 | |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2322 | /* reprogram secondary unicast list */ |
Jiri Pirko | 31278e7 | 2009-06-17 01:12:19 +0000 | [diff] [blame] | 2323 | hw->mac.ops.update_uc_addr_list(hw, &netdev->uc.list); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2324 | |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2325 | /* reprogram multicast list */ |
| 2326 | addr_count = netdev->mc_count; |
| 2327 | if (addr_count) |
| 2328 | addr_list = netdev->mc_list->dmi_addr; |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 2329 | hw->mac.ops.update_mc_addr_list(hw, addr_list, addr_count, |
| 2330 | ixgbe_addr_list_itr); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2331 | } |
| 2332 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2333 | static void ixgbe_napi_enable_all(struct ixgbe_adapter *adapter) |
| 2334 | { |
| 2335 | int q_idx; |
| 2336 | struct ixgbe_q_vector *q_vector; |
| 2337 | int q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
| 2338 | |
| 2339 | /* legacy and MSI only use one vector */ |
| 2340 | if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) |
| 2341 | q_vectors = 1; |
| 2342 | |
| 2343 | for (q_idx = 0; q_idx < q_vectors; q_idx++) { |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 2344 | struct napi_struct *napi; |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 2345 | q_vector = adapter->q_vector[q_idx]; |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 2346 | napi = &q_vector->napi; |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 2347 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { |
| 2348 | if (!q_vector->rxr_count || !q_vector->txr_count) { |
| 2349 | if (q_vector->txr_count == 1) |
| 2350 | napi->poll = &ixgbe_clean_txonly; |
| 2351 | else if (q_vector->rxr_count == 1) |
| 2352 | napi->poll = &ixgbe_clean_rxonly; |
| 2353 | } |
| 2354 | } |
Jesse Brandeburg | f084827 | 2008-09-11 19:59:42 -0700 | [diff] [blame] | 2355 | |
| 2356 | napi_enable(napi); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2357 | } |
| 2358 | } |
| 2359 | |
| 2360 | static void ixgbe_napi_disable_all(struct ixgbe_adapter *adapter) |
| 2361 | { |
| 2362 | int q_idx; |
| 2363 | struct ixgbe_q_vector *q_vector; |
| 2364 | int q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
| 2365 | |
| 2366 | /* legacy and MSI only use one vector */ |
| 2367 | if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) |
| 2368 | q_vectors = 1; |
| 2369 | |
| 2370 | for (q_idx = 0; q_idx < q_vectors; q_idx++) { |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 2371 | q_vector = adapter->q_vector[q_idx]; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2372 | napi_disable(&q_vector->napi); |
| 2373 | } |
| 2374 | } |
| 2375 | |
Jeff Kirsher | 7a6b6f5 | 2008-11-25 01:02:08 -0800 | [diff] [blame] | 2376 | #ifdef CONFIG_IXGBE_DCB |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 2377 | /* |
| 2378 | * ixgbe_configure_dcb - Configure DCB hardware |
| 2379 | * @adapter: ixgbe adapter struct |
| 2380 | * |
| 2381 | * This is called by the driver on open to configure the DCB hardware. |
| 2382 | * This is also called by the gennetlink interface when reconfiguring |
| 2383 | * the DCB state. |
| 2384 | */ |
| 2385 | static void ixgbe_configure_dcb(struct ixgbe_adapter *adapter) |
| 2386 | { |
| 2387 | struct ixgbe_hw *hw = &adapter->hw; |
| 2388 | u32 txdctl, vlnctrl; |
| 2389 | int i, j; |
| 2390 | |
| 2391 | ixgbe_dcb_check_config(&adapter->dcb_cfg); |
| 2392 | ixgbe_dcb_calculate_tc_credits(&adapter->dcb_cfg, DCB_TX_CONFIG); |
| 2393 | ixgbe_dcb_calculate_tc_credits(&adapter->dcb_cfg, DCB_RX_CONFIG); |
| 2394 | |
| 2395 | /* reconfigure the hardware */ |
| 2396 | ixgbe_dcb_hw_config(&adapter->hw, &adapter->dcb_cfg); |
| 2397 | |
| 2398 | for (i = 0; i < adapter->num_tx_queues; i++) { |
| 2399 | j = adapter->tx_ring[i].reg_idx; |
| 2400 | txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(j)); |
| 2401 | /* PThresh workaround for Tx hang with DFP enabled. */ |
| 2402 | txdctl |= 32; |
| 2403 | IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(j), txdctl); |
| 2404 | } |
| 2405 | /* Enable VLAN tag insert/strip */ |
| 2406 | vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2407 | if (hw->mac.type == ixgbe_mac_82598EB) { |
| 2408 | vlnctrl |= IXGBE_VLNCTRL_VME | IXGBE_VLNCTRL_VFE; |
| 2409 | vlnctrl &= ~IXGBE_VLNCTRL_CFIEN; |
| 2410 | IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl); |
| 2411 | } else if (hw->mac.type == ixgbe_mac_82599EB) { |
| 2412 | vlnctrl |= IXGBE_VLNCTRL_VFE; |
| 2413 | vlnctrl &= ~IXGBE_VLNCTRL_CFIEN; |
| 2414 | IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl); |
| 2415 | for (i = 0; i < adapter->num_rx_queues; i++) { |
| 2416 | j = adapter->rx_ring[i].reg_idx; |
| 2417 | vlnctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(j)); |
| 2418 | vlnctrl |= IXGBE_RXDCTL_VME; |
| 2419 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(j), vlnctrl); |
| 2420 | } |
| 2421 | } |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 2422 | hw->mac.ops.set_vfta(&adapter->hw, 0, 0, true); |
| 2423 | } |
| 2424 | |
| 2425 | #endif |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2426 | static void ixgbe_configure(struct ixgbe_adapter *adapter) |
| 2427 | { |
| 2428 | struct net_device *netdev = adapter->netdev; |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 2429 | struct ixgbe_hw *hw = &adapter->hw; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2430 | int i; |
| 2431 | |
Christopher Leech | 2c5645c | 2008-08-26 04:27:02 -0700 | [diff] [blame] | 2432 | ixgbe_set_rx_mode(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2433 | |
| 2434 | ixgbe_restore_vlan(adapter); |
Jeff Kirsher | 7a6b6f5 | 2008-11-25 01:02:08 -0800 | [diff] [blame] | 2435 | #ifdef CONFIG_IXGBE_DCB |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 2436 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
| 2437 | netif_set_gso_max_size(netdev, 32768); |
| 2438 | ixgbe_configure_dcb(adapter); |
| 2439 | } else { |
| 2440 | netif_set_gso_max_size(netdev, 65536); |
| 2441 | } |
| 2442 | #else |
| 2443 | netif_set_gso_max_size(netdev, 65536); |
| 2444 | #endif |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2445 | |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 2446 | #ifdef IXGBE_FCOE |
| 2447 | if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) |
| 2448 | ixgbe_configure_fcoe(adapter); |
| 2449 | |
| 2450 | #endif /* IXGBE_FCOE */ |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 2451 | if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { |
| 2452 | for (i = 0; i < adapter->num_tx_queues; i++) |
| 2453 | adapter->tx_ring[i].atr_sample_rate = |
| 2454 | adapter->atr_sample_rate; |
| 2455 | ixgbe_init_fdir_signature_82599(hw, adapter->fdir_pballoc); |
| 2456 | } else if (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) { |
| 2457 | ixgbe_init_fdir_perfect_82599(hw, adapter->fdir_pballoc); |
| 2458 | } |
| 2459 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2460 | ixgbe_configure_tx(adapter); |
| 2461 | ixgbe_configure_rx(adapter); |
| 2462 | for (i = 0; i < adapter->num_rx_queues; i++) |
| 2463 | ixgbe_alloc_rx_buffers(adapter, &adapter->rx_ring[i], |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 2464 | (adapter->rx_ring[i].count - 1)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2465 | } |
| 2466 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2467 | static inline bool ixgbe_is_sfp(struct ixgbe_hw *hw) |
| 2468 | { |
| 2469 | switch (hw->phy.type) { |
| 2470 | case ixgbe_phy_sfp_avago: |
| 2471 | case ixgbe_phy_sfp_ftl: |
| 2472 | case ixgbe_phy_sfp_intel: |
| 2473 | case ixgbe_phy_sfp_unknown: |
| 2474 | case ixgbe_phy_tw_tyco: |
| 2475 | case ixgbe_phy_tw_unknown: |
| 2476 | return true; |
| 2477 | default: |
| 2478 | return false; |
| 2479 | } |
| 2480 | } |
| 2481 | |
Peter P Waskiewicz Jr | 0ecc061 | 2009-02-06 21:46:54 -0800 | [diff] [blame] | 2482 | /** |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2483 | * ixgbe_sfp_link_config - set up SFP+ link |
| 2484 | * @adapter: pointer to private adapter struct |
| 2485 | **/ |
| 2486 | static void ixgbe_sfp_link_config(struct ixgbe_adapter *adapter) |
| 2487 | { |
| 2488 | struct ixgbe_hw *hw = &adapter->hw; |
| 2489 | |
| 2490 | if (hw->phy.multispeed_fiber) { |
| 2491 | /* |
| 2492 | * In multispeed fiber setups, the device may not have |
| 2493 | * had a physical connection when the driver loaded. |
| 2494 | * If that's the case, the initial link configuration |
| 2495 | * couldn't get the MAC into 10G or 1G mode, so we'll |
| 2496 | * never have a link status change interrupt fire. |
| 2497 | * We need to try and force an autonegotiation |
| 2498 | * session, then bring up link. |
| 2499 | */ |
| 2500 | hw->mac.ops.setup_sfp(hw); |
| 2501 | if (!(adapter->flags & IXGBE_FLAG_IN_SFP_LINK_TASK)) |
| 2502 | schedule_work(&adapter->multispeed_fiber_task); |
| 2503 | } else { |
| 2504 | /* |
| 2505 | * Direct Attach Cu and non-multispeed fiber modules |
| 2506 | * still need to be configured properly prior to |
| 2507 | * attempting link. |
| 2508 | */ |
| 2509 | if (!(adapter->flags & IXGBE_FLAG_IN_SFP_MOD_TASK)) |
| 2510 | schedule_work(&adapter->sfp_config_module_task); |
| 2511 | } |
| 2512 | } |
| 2513 | |
| 2514 | /** |
| 2515 | * ixgbe_non_sfp_link_config - set up non-SFP+ link |
Peter P Waskiewicz Jr | 0ecc061 | 2009-02-06 21:46:54 -0800 | [diff] [blame] | 2516 | * @hw: pointer to private hardware struct |
| 2517 | * |
| 2518 | * Returns 0 on success, negative on failure |
| 2519 | **/ |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2520 | static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw) |
Peter P Waskiewicz Jr | 0ecc061 | 2009-02-06 21:46:54 -0800 | [diff] [blame] | 2521 | { |
| 2522 | u32 autoneg; |
Mallikarjuna R Chilakala | 8620a10 | 2009-09-01 13:49:35 +0000 | [diff] [blame] | 2523 | bool negotiation, link_up = false; |
Peter P Waskiewicz Jr | 0ecc061 | 2009-02-06 21:46:54 -0800 | [diff] [blame] | 2524 | u32 ret = IXGBE_ERR_LINK_SETUP; |
| 2525 | |
| 2526 | if (hw->mac.ops.check_link) |
| 2527 | ret = hw->mac.ops.check_link(hw, &autoneg, &link_up, false); |
| 2528 | |
| 2529 | if (ret) |
| 2530 | goto link_cfg_out; |
| 2531 | |
| 2532 | if (hw->mac.ops.get_link_capabilities) |
Mallikarjuna R Chilakala | 8620a10 | 2009-09-01 13:49:35 +0000 | [diff] [blame] | 2533 | ret = hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation); |
Peter P Waskiewicz Jr | 0ecc061 | 2009-02-06 21:46:54 -0800 | [diff] [blame] | 2534 | if (ret) |
| 2535 | goto link_cfg_out; |
| 2536 | |
Mallikarjuna R Chilakala | 8620a10 | 2009-09-01 13:49:35 +0000 | [diff] [blame] | 2537 | if (hw->mac.ops.setup_link) |
| 2538 | ret = hw->mac.ops.setup_link(hw, autoneg, negotiation, link_up); |
Peter P Waskiewicz Jr | 0ecc061 | 2009-02-06 21:46:54 -0800 | [diff] [blame] | 2539 | link_cfg_out: |
| 2540 | return ret; |
| 2541 | } |
| 2542 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2543 | #define IXGBE_MAX_RX_DESC_POLL 10 |
| 2544 | static inline void ixgbe_rx_desc_queue_enable(struct ixgbe_adapter *adapter, |
| 2545 | int rxr) |
| 2546 | { |
| 2547 | int j = adapter->rx_ring[rxr].reg_idx; |
| 2548 | int k; |
| 2549 | |
| 2550 | for (k = 0; k < IXGBE_MAX_RX_DESC_POLL; k++) { |
| 2551 | if (IXGBE_READ_REG(&adapter->hw, |
| 2552 | IXGBE_RXDCTL(j)) & IXGBE_RXDCTL_ENABLE) |
| 2553 | break; |
| 2554 | else |
| 2555 | msleep(1); |
| 2556 | } |
| 2557 | if (k >= IXGBE_MAX_RX_DESC_POLL) { |
| 2558 | DPRINTK(DRV, ERR, "RXDCTL.ENABLE on Rx queue %d " |
| 2559 | "not set within the polling period\n", rxr); |
| 2560 | } |
| 2561 | ixgbe_release_rx_desc(&adapter->hw, &adapter->rx_ring[rxr], |
| 2562 | (adapter->rx_ring[rxr].count - 1)); |
| 2563 | } |
| 2564 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2565 | static int ixgbe_up_complete(struct ixgbe_adapter *adapter) |
| 2566 | { |
| 2567 | struct net_device *netdev = adapter->netdev; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2568 | struct ixgbe_hw *hw = &adapter->hw; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2569 | int i, j = 0; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2570 | int num_rx_rings = adapter->num_rx_queues; |
Peter P Waskiewicz Jr | 0ecc061 | 2009-02-06 21:46:54 -0800 | [diff] [blame] | 2571 | int err; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2572 | int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2573 | u32 txdctl, rxdctl, mhadd; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2574 | u32 dmatxctl; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2575 | u32 gpie; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2576 | |
Ayyappan Veeraiyan | 5eba369 | 2008-02-01 15:59:04 -0800 | [diff] [blame] | 2577 | ixgbe_get_hw_control(adapter); |
| 2578 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2579 | if ((adapter->flags & IXGBE_FLAG_MSIX_ENABLED) || |
| 2580 | (adapter->flags & IXGBE_FLAG_MSI_ENABLED)) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2581 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { |
| 2582 | gpie = (IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_EIAME | |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 2583 | IXGBE_GPIE_PBA_SUPPORT | IXGBE_GPIE_OCD); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2584 | } else { |
| 2585 | /* MSI only */ |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2586 | gpie = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2587 | } |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2588 | /* XXX: to interrupt immediately for EICS writes, enable this */ |
| 2589 | /* gpie |= IXGBE_GPIE_EIMEN; */ |
| 2590 | IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie); |
| 2591 | } |
| 2592 | |
| 2593 | if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { |
| 2594 | /* legacy interrupts, use EIAM to auto-mask when reading EICR, |
| 2595 | * specifically only auto mask tx and rx interrupts */ |
| 2596 | IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2597 | } |
| 2598 | |
Jesse Brandeburg | 0befdb3 | 2008-10-31 00:46:40 -0700 | [diff] [blame] | 2599 | /* Enable fan failure interrupt if media type is copper */ |
| 2600 | if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) { |
| 2601 | gpie = IXGBE_READ_REG(hw, IXGBE_GPIE); |
| 2602 | gpie |= IXGBE_SDP1_GPIEN; |
| 2603 | IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie); |
| 2604 | } |
| 2605 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2606 | if (hw->mac.type == ixgbe_mac_82599EB) { |
| 2607 | gpie = IXGBE_READ_REG(hw, IXGBE_GPIE); |
| 2608 | gpie |= IXGBE_SDP1_GPIEN; |
| 2609 | gpie |= IXGBE_SDP2_GPIEN; |
| 2610 | IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie); |
| 2611 | } |
| 2612 | |
Yi Zou | 63f39bd | 2009-05-17 12:34:35 +0000 | [diff] [blame] | 2613 | #ifdef IXGBE_FCOE |
| 2614 | /* adjust max frame to be able to do baby jumbo for FCoE */ |
Yi Zou | f34c5c8 | 2009-08-14 12:42:17 +0000 | [diff] [blame] | 2615 | if ((netdev->features & NETIF_F_FCOE_MTU) && |
Yi Zou | 63f39bd | 2009-05-17 12:34:35 +0000 | [diff] [blame] | 2616 | (max_frame < IXGBE_FCOE_JUMBO_FRAME_SIZE)) |
| 2617 | max_frame = IXGBE_FCOE_JUMBO_FRAME_SIZE; |
| 2618 | |
| 2619 | #endif /* IXGBE_FCOE */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2620 | mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2621 | if (max_frame != (mhadd >> IXGBE_MHADD_MFS_SHIFT)) { |
| 2622 | mhadd &= ~IXGBE_MHADD_MFS_MASK; |
| 2623 | mhadd |= max_frame << IXGBE_MHADD_MFS_SHIFT; |
| 2624 | |
| 2625 | IXGBE_WRITE_REG(hw, IXGBE_MHADD, mhadd); |
| 2626 | } |
| 2627 | |
| 2628 | for (i = 0; i < adapter->num_tx_queues; i++) { |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2629 | j = adapter->tx_ring[i].reg_idx; |
| 2630 | txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(j)); |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 2631 | /* enable WTHRESH=8 descriptors, to encourage burst writeback */ |
| 2632 | txdctl |= (8 << 16); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2633 | IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(j), txdctl); |
| 2634 | } |
| 2635 | |
| 2636 | if (hw->mac.type == ixgbe_mac_82599EB) { |
| 2637 | /* DMATXCTL.EN must be set after all Tx queue config is done */ |
| 2638 | dmatxctl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL); |
| 2639 | dmatxctl |= IXGBE_DMATXCTL_TE; |
| 2640 | IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, dmatxctl); |
| 2641 | } |
| 2642 | for (i = 0; i < adapter->num_tx_queues; i++) { |
| 2643 | j = adapter->tx_ring[i].reg_idx; |
| 2644 | txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(j)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2645 | txdctl |= IXGBE_TXDCTL_ENABLE; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2646 | IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(j), txdctl); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2647 | } |
| 2648 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2649 | for (i = 0; i < num_rx_rings; i++) { |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2650 | j = adapter->rx_ring[i].reg_idx; |
| 2651 | rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(j)); |
| 2652 | /* enable PTHRESH=32 descriptors (half the internal cache) |
| 2653 | * and HTHRESH=0 descriptors (to minimize latency on fetch), |
| 2654 | * this also removes a pesky rx_no_buffer_count increment */ |
| 2655 | rxdctl |= 0x0020; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2656 | rxdctl |= IXGBE_RXDCTL_ENABLE; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2657 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(j), rxdctl); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2658 | if (hw->mac.type == ixgbe_mac_82599EB) |
| 2659 | ixgbe_rx_desc_queue_enable(adapter, i); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2660 | } |
| 2661 | /* enable all receives */ |
| 2662 | rxdctl = IXGBE_READ_REG(hw, IXGBE_RXCTRL); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2663 | if (hw->mac.type == ixgbe_mac_82598EB) |
| 2664 | rxdctl |= (IXGBE_RXCTRL_DMBYPS | IXGBE_RXCTRL_RXEN); |
| 2665 | else |
| 2666 | rxdctl |= IXGBE_RXCTRL_RXEN; |
| 2667 | hw->mac.ops.enable_rx_dma(hw, rxdctl); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2668 | |
| 2669 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) |
| 2670 | ixgbe_configure_msix(adapter); |
| 2671 | else |
| 2672 | ixgbe_configure_msi_and_legacy(adapter); |
| 2673 | |
| 2674 | clear_bit(__IXGBE_DOWN, &adapter->state); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2675 | ixgbe_napi_enable_all(adapter); |
| 2676 | |
| 2677 | /* clear any pending interrupts, may auto mask */ |
| 2678 | IXGBE_READ_REG(hw, IXGBE_EICR); |
| 2679 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2680 | ixgbe_irq_enable(adapter); |
| 2681 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2682 | /* |
Don Skidmore | bf069c9 | 2009-05-07 10:39:54 +0000 | [diff] [blame] | 2683 | * If this adapter has a fan, check to see if we had a failure |
| 2684 | * before we enabled the interrupt. |
| 2685 | */ |
| 2686 | if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) { |
| 2687 | u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP); |
| 2688 | if (esdp & IXGBE_ESDP_SDP1) |
| 2689 | DPRINTK(DRV, CRIT, |
| 2690 | "Fan has stopped, replace the adapter\n"); |
| 2691 | } |
| 2692 | |
| 2693 | /* |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2694 | * For hot-pluggable SFP+ devices, a new SFP+ module may have |
Don Skidmore | 19343de | 2009-07-02 12:50:31 +0000 | [diff] [blame] | 2695 | * arrived before interrupts were enabled but after probe. Such |
| 2696 | * devices wouldn't have their type identified yet. We need to |
| 2697 | * kick off the SFP+ module setup first, then try to bring up link. |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2698 | * If we're not hot-pluggable SFP+, we just need to configure link |
| 2699 | * and bring it up. |
| 2700 | */ |
Don Skidmore | 19343de | 2009-07-02 12:50:31 +0000 | [diff] [blame] | 2701 | if (hw->phy.type == ixgbe_phy_unknown) { |
| 2702 | err = hw->phy.ops.identify(hw); |
| 2703 | if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { |
Don Skidmore | 5da43c1 | 2009-07-02 12:50:52 +0000 | [diff] [blame] | 2704 | /* |
| 2705 | * Take the device down and schedule the sfp tasklet |
| 2706 | * which will unregister_netdev and log it. |
| 2707 | */ |
Don Skidmore | 19343de | 2009-07-02 12:50:31 +0000 | [diff] [blame] | 2708 | ixgbe_down(adapter); |
Don Skidmore | 5da43c1 | 2009-07-02 12:50:52 +0000 | [diff] [blame] | 2709 | schedule_work(&adapter->sfp_config_module_task); |
Don Skidmore | 19343de | 2009-07-02 12:50:31 +0000 | [diff] [blame] | 2710 | return err; |
| 2711 | } |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 2712 | } |
| 2713 | |
| 2714 | if (ixgbe_is_sfp(hw)) { |
| 2715 | ixgbe_sfp_link_config(adapter); |
| 2716 | } else { |
| 2717 | err = ixgbe_non_sfp_link_config(hw); |
| 2718 | if (err) |
| 2719 | DPRINTK(PROBE, ERR, "link_config FAILED %d\n", err); |
| 2720 | } |
Peter P Waskiewicz Jr | 0ecc061 | 2009-02-06 21:46:54 -0800 | [diff] [blame] | 2721 | |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 2722 | for (i = 0; i < adapter->num_tx_queues; i++) |
| 2723 | set_bit(__IXGBE_FDIR_INIT_DONE, |
| 2724 | &(adapter->tx_ring[i].reinit_state)); |
| 2725 | |
Peter P Waskiewicz Jr | 1da100b | 2009-01-19 16:55:03 -0800 | [diff] [blame] | 2726 | /* enable transmits */ |
| 2727 | netif_tx_start_all_queues(netdev); |
| 2728 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2729 | /* bring the link up in the watchdog, this could race with our first |
| 2730 | * link up interrupt but shouldn't be a problem */ |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 2731 | adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; |
| 2732 | adapter->link_check_timeout = jiffies; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2733 | mod_timer(&adapter->watchdog_timer, jiffies); |
| 2734 | return 0; |
| 2735 | } |
| 2736 | |
Ayyappan Veeraiyan | d4f8088 | 2008-02-01 15:58:41 -0800 | [diff] [blame] | 2737 | void ixgbe_reinit_locked(struct ixgbe_adapter *adapter) |
| 2738 | { |
| 2739 | WARN_ON(in_interrupt()); |
| 2740 | while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) |
| 2741 | msleep(1); |
| 2742 | ixgbe_down(adapter); |
| 2743 | ixgbe_up(adapter); |
| 2744 | clear_bit(__IXGBE_RESETTING, &adapter->state); |
| 2745 | } |
| 2746 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2747 | int ixgbe_up(struct ixgbe_adapter *adapter) |
| 2748 | { |
| 2749 | /* hardware has been reset, we need to reload some things */ |
| 2750 | ixgbe_configure(adapter); |
| 2751 | |
| 2752 | return ixgbe_up_complete(adapter); |
| 2753 | } |
| 2754 | |
| 2755 | void ixgbe_reset(struct ixgbe_adapter *adapter) |
| 2756 | { |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 2757 | struct ixgbe_hw *hw = &adapter->hw; |
Don Skidmore | 8ca783a | 2009-05-26 20:40:47 -0700 | [diff] [blame] | 2758 | int err; |
| 2759 | |
| 2760 | err = hw->mac.ops.init_hw(hw); |
Peter P Waskiewicz Jr | da4dd0f | 2009-06-04 11:10:35 +0000 | [diff] [blame] | 2761 | switch (err) { |
| 2762 | case 0: |
| 2763 | case IXGBE_ERR_SFP_NOT_PRESENT: |
| 2764 | break; |
| 2765 | case IXGBE_ERR_MASTER_REQUESTS_PENDING: |
| 2766 | dev_err(&adapter->pdev->dev, "master disable timed out\n"); |
| 2767 | break; |
Peter P Waskiewicz Jr | 794caeb | 2009-06-04 16:02:24 +0000 | [diff] [blame] | 2768 | case IXGBE_ERR_EEPROM_VERSION: |
| 2769 | /* We are running on a pre-production device, log a warning */ |
| 2770 | dev_warn(&adapter->pdev->dev, "This device is a pre-production " |
| 2771 | "adapter/LOM. Please be aware there may be issues " |
| 2772 | "associated with your hardware. If you are " |
| 2773 | "experiencing problems please contact your Intel or " |
| 2774 | "hardware representative who provided you with this " |
| 2775 | "hardware.\n"); |
| 2776 | break; |
Peter P Waskiewicz Jr | da4dd0f | 2009-06-04 11:10:35 +0000 | [diff] [blame] | 2777 | default: |
| 2778 | dev_err(&adapter->pdev->dev, "Hardware Error: %d\n", err); |
| 2779 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2780 | |
| 2781 | /* reprogram the RAR[0] in case user changed it. */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 2782 | hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2783 | } |
| 2784 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2785 | /** |
| 2786 | * ixgbe_clean_rx_ring - Free Rx Buffers per Queue |
| 2787 | * @adapter: board private structure |
| 2788 | * @rx_ring: ring to free buffers from |
| 2789 | **/ |
| 2790 | static void ixgbe_clean_rx_ring(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 2791 | struct ixgbe_ring *rx_ring) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2792 | { |
| 2793 | struct pci_dev *pdev = adapter->pdev; |
| 2794 | unsigned long size; |
| 2795 | unsigned int i; |
| 2796 | |
| 2797 | /* Free all the Rx ring sk_buffs */ |
| 2798 | |
| 2799 | for (i = 0; i < rx_ring->count; i++) { |
| 2800 | struct ixgbe_rx_buffer *rx_buffer_info; |
| 2801 | |
| 2802 | rx_buffer_info = &rx_ring->rx_buffer_info[i]; |
| 2803 | if (rx_buffer_info->dma) { |
| 2804 | pci_unmap_single(pdev, rx_buffer_info->dma, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 2805 | rx_ring->rx_buf_len, |
| 2806 | PCI_DMA_FROMDEVICE); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2807 | rx_buffer_info->dma = 0; |
| 2808 | } |
| 2809 | if (rx_buffer_info->skb) { |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2810 | struct sk_buff *skb = rx_buffer_info->skb; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2811 | rx_buffer_info->skb = NULL; |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 2812 | do { |
| 2813 | struct sk_buff *this = skb; |
| 2814 | skb = skb->prev; |
| 2815 | dev_kfree_skb(this); |
| 2816 | } while (skb); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2817 | } |
| 2818 | if (!rx_buffer_info->page) |
| 2819 | continue; |
Jesse Brandeburg | 4f57ca6 | 2009-06-30 11:44:56 +0000 | [diff] [blame] | 2820 | if (rx_buffer_info->page_dma) { |
| 2821 | pci_unmap_page(pdev, rx_buffer_info->page_dma, |
| 2822 | PAGE_SIZE / 2, PCI_DMA_FROMDEVICE); |
| 2823 | rx_buffer_info->page_dma = 0; |
| 2824 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2825 | put_page(rx_buffer_info->page); |
| 2826 | rx_buffer_info->page = NULL; |
Jesse Brandeburg | 762f4c5 | 2008-09-11 19:58:43 -0700 | [diff] [blame] | 2827 | rx_buffer_info->page_offset = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2828 | } |
| 2829 | |
| 2830 | size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; |
| 2831 | memset(rx_ring->rx_buffer_info, 0, size); |
| 2832 | |
| 2833 | /* Zero out the descriptor ring */ |
| 2834 | memset(rx_ring->desc, 0, rx_ring->size); |
| 2835 | |
| 2836 | rx_ring->next_to_clean = 0; |
| 2837 | rx_ring->next_to_use = 0; |
| 2838 | |
Jesse Brandeburg | 9891ca7 | 2009-03-13 22:14:50 +0000 | [diff] [blame] | 2839 | if (rx_ring->head) |
| 2840 | writel(0, adapter->hw.hw_addr + rx_ring->head); |
| 2841 | if (rx_ring->tail) |
| 2842 | writel(0, adapter->hw.hw_addr + rx_ring->tail); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2843 | } |
| 2844 | |
| 2845 | /** |
| 2846 | * ixgbe_clean_tx_ring - Free Tx Buffers |
| 2847 | * @adapter: board private structure |
| 2848 | * @tx_ring: ring to be cleaned |
| 2849 | **/ |
| 2850 | static void ixgbe_clean_tx_ring(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 2851 | struct ixgbe_ring *tx_ring) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2852 | { |
| 2853 | struct ixgbe_tx_buffer *tx_buffer_info; |
| 2854 | unsigned long size; |
| 2855 | unsigned int i; |
| 2856 | |
| 2857 | /* Free all the Tx ring sk_buffs */ |
| 2858 | |
| 2859 | for (i = 0; i < tx_ring->count; i++) { |
| 2860 | tx_buffer_info = &tx_ring->tx_buffer_info[i]; |
| 2861 | ixgbe_unmap_and_free_tx_resource(adapter, tx_buffer_info); |
| 2862 | } |
| 2863 | |
| 2864 | size = sizeof(struct ixgbe_tx_buffer) * tx_ring->count; |
| 2865 | memset(tx_ring->tx_buffer_info, 0, size); |
| 2866 | |
| 2867 | /* Zero out the descriptor ring */ |
| 2868 | memset(tx_ring->desc, 0, tx_ring->size); |
| 2869 | |
| 2870 | tx_ring->next_to_use = 0; |
| 2871 | tx_ring->next_to_clean = 0; |
| 2872 | |
Jesse Brandeburg | 9891ca7 | 2009-03-13 22:14:50 +0000 | [diff] [blame] | 2873 | if (tx_ring->head) |
| 2874 | writel(0, adapter->hw.hw_addr + tx_ring->head); |
| 2875 | if (tx_ring->tail) |
| 2876 | writel(0, adapter->hw.hw_addr + tx_ring->tail); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2877 | } |
| 2878 | |
| 2879 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2880 | * ixgbe_clean_all_rx_rings - Free Rx Buffers for all queues |
| 2881 | * @adapter: board private structure |
| 2882 | **/ |
| 2883 | static void ixgbe_clean_all_rx_rings(struct ixgbe_adapter *adapter) |
| 2884 | { |
| 2885 | int i; |
| 2886 | |
| 2887 | for (i = 0; i < adapter->num_rx_queues; i++) |
| 2888 | ixgbe_clean_rx_ring(adapter, &adapter->rx_ring[i]); |
| 2889 | } |
| 2890 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2891 | /** |
| 2892 | * ixgbe_clean_all_tx_rings - Free Tx Buffers for all queues |
| 2893 | * @adapter: board private structure |
| 2894 | **/ |
| 2895 | static void ixgbe_clean_all_tx_rings(struct ixgbe_adapter *adapter) |
| 2896 | { |
| 2897 | int i; |
| 2898 | |
| 2899 | for (i = 0; i < adapter->num_tx_queues; i++) |
| 2900 | ixgbe_clean_tx_ring(adapter, &adapter->tx_ring[i]); |
| 2901 | } |
| 2902 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2903 | void ixgbe_down(struct ixgbe_adapter *adapter) |
| 2904 | { |
| 2905 | struct net_device *netdev = adapter->netdev; |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 2906 | struct ixgbe_hw *hw = &adapter->hw; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2907 | u32 rxctrl; |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 2908 | u32 txdctl; |
| 2909 | int i, j; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2910 | |
| 2911 | /* signal that we are down to the interrupt handler */ |
| 2912 | set_bit(__IXGBE_DOWN, &adapter->state); |
| 2913 | |
| 2914 | /* disable receives */ |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 2915 | rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL); |
| 2916 | IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl & ~IXGBE_RXCTRL_RXEN); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2917 | |
| 2918 | netif_tx_disable(netdev); |
| 2919 | |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 2920 | IXGBE_WRITE_FLUSH(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2921 | msleep(10); |
| 2922 | |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 2923 | netif_tx_stop_all_queues(netdev); |
| 2924 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2925 | ixgbe_irq_disable(adapter); |
| 2926 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2927 | ixgbe_napi_disable_all(adapter); |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 2928 | |
Don Skidmore | 0a1f87c | 2009-09-18 09:45:43 +0000 | [diff] [blame] | 2929 | clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state); |
| 2930 | del_timer_sync(&adapter->sfp_timer); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2931 | del_timer_sync(&adapter->watchdog_timer); |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 2932 | cancel_work_sync(&adapter->watchdog_task); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2933 | |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 2934 | if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || |
| 2935 | adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) |
| 2936 | cancel_work_sync(&adapter->fdir_reinit_task); |
| 2937 | |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 2938 | /* disable transmits in the hardware now that interrupts are off */ |
| 2939 | for (i = 0; i < adapter->num_tx_queues; i++) { |
| 2940 | j = adapter->tx_ring[i].reg_idx; |
| 2941 | txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(j)); |
| 2942 | IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(j), |
| 2943 | (txdctl & ~IXGBE_TXDCTL_ENABLE)); |
| 2944 | } |
PJ Waskiewicz | 8851253 | 2009-03-13 22:15:10 +0000 | [diff] [blame] | 2945 | /* Disable the Tx DMA engine on 82599 */ |
| 2946 | if (hw->mac.type == ixgbe_mac_82599EB) |
| 2947 | IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, |
| 2948 | (IXGBE_READ_REG(hw, IXGBE_DMATXCTL) & |
| 2949 | ~IXGBE_DMATXCTL_TE)); |
Jesse Brandeburg | 7f82187 | 2008-09-11 20:00:16 -0700 | [diff] [blame] | 2950 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2951 | netif_carrier_off(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2952 | |
Paul Larson | 6f4a0e4 | 2008-06-24 17:00:56 -0700 | [diff] [blame] | 2953 | if (!pci_channel_offline(adapter->pdev)) |
| 2954 | ixgbe_reset(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2955 | ixgbe_clean_all_tx_rings(adapter); |
| 2956 | ixgbe_clean_all_rx_rings(adapter); |
| 2957 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 2958 | #ifdef CONFIG_IXGBE_DCA |
Jesse Brandeburg | 96b0e0f | 2008-08-26 04:27:21 -0700 | [diff] [blame] | 2959 | /* since we reset the hardware DCA settings were cleared */ |
Alexander Duyck | e35ec12 | 2009-05-21 13:07:12 +0000 | [diff] [blame] | 2960 | ixgbe_setup_dca(adapter); |
Jesse Brandeburg | 96b0e0f | 2008-08-26 04:27:21 -0700 | [diff] [blame] | 2961 | #endif |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2962 | } |
| 2963 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2964 | /** |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2965 | * ixgbe_poll - NAPI Rx polling callback |
| 2966 | * @napi: structure for representing this polling device |
| 2967 | * @budget: how many packets driver is allowed to clean |
| 2968 | * |
| 2969 | * This function is used for legacy and MSI, NAPI mode |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2970 | **/ |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2971 | static int ixgbe_poll(struct napi_struct *napi, int budget) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2972 | { |
Jesse Brandeburg | 9a1a69ad | 2009-03-13 22:14:10 +0000 | [diff] [blame] | 2973 | struct ixgbe_q_vector *q_vector = |
| 2974 | container_of(napi, struct ixgbe_q_vector, napi); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 2975 | struct ixgbe_adapter *adapter = q_vector->adapter; |
Jesse Brandeburg | 9a1a69ad | 2009-03-13 22:14:10 +0000 | [diff] [blame] | 2976 | int tx_clean_complete, work_done = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2977 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 2978 | #ifdef CONFIG_IXGBE_DCA |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 2979 | if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) { |
| 2980 | ixgbe_update_tx_dca(adapter, adapter->tx_ring); |
| 2981 | ixgbe_update_rx_dca(adapter, adapter->rx_ring); |
| 2982 | } |
| 2983 | #endif |
| 2984 | |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 2985 | tx_clean_complete = ixgbe_clean_tx_irq(q_vector, adapter->tx_ring); |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 2986 | ixgbe_clean_rx_irq(q_vector, adapter->rx_ring, &work_done, budget); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2987 | |
Jesse Brandeburg | 9a1a69ad | 2009-03-13 22:14:10 +0000 | [diff] [blame] | 2988 | if (!tx_clean_complete) |
David S. Miller | d2c7ddd | 2008-01-15 22:43:24 -0800 | [diff] [blame] | 2989 | work_done = budget; |
| 2990 | |
David S. Miller | 53e52c7 | 2008-01-07 21:06:12 -0800 | [diff] [blame] | 2991 | /* If budget not fully consumed, exit the polling mode */ |
| 2992 | if (work_done < budget) { |
Ben Hutchings | 288379f | 2009-01-19 16:43:59 -0800 | [diff] [blame] | 2993 | napi_complete(napi); |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 2994 | if (adapter->rx_itr_setting & 1) |
Ayyappan Veeraiyan | f494e8f | 2008-03-03 15:03:57 -0800 | [diff] [blame] | 2995 | ixgbe_set_itr(adapter); |
Ayyappan Veeraiyan | d4f8088 | 2008-02-01 15:58:41 -0800 | [diff] [blame] | 2996 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
Nelson, Shannon | 835462f | 2009-04-27 22:42:54 +0000 | [diff] [blame] | 2997 | ixgbe_irq_enable_queues(adapter, IXGBE_EIMS_RTX_QUEUE); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2998 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 2999 | return work_done; |
| 3000 | } |
| 3001 | |
| 3002 | /** |
| 3003 | * ixgbe_tx_timeout - Respond to a Tx Hang |
| 3004 | * @netdev: network interface device structure |
| 3005 | **/ |
| 3006 | static void ixgbe_tx_timeout(struct net_device *netdev) |
| 3007 | { |
| 3008 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 3009 | |
| 3010 | /* Do the reset outside of interrupt context */ |
| 3011 | schedule_work(&adapter->reset_task); |
| 3012 | } |
| 3013 | |
| 3014 | static void ixgbe_reset_task(struct work_struct *work) |
| 3015 | { |
| 3016 | struct ixgbe_adapter *adapter; |
| 3017 | adapter = container_of(work, struct ixgbe_adapter, reset_task); |
| 3018 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3019 | /* If we're already down or resetting, just bail */ |
| 3020 | if (test_bit(__IXGBE_DOWN, &adapter->state) || |
| 3021 | test_bit(__IXGBE_RESETTING, &adapter->state)) |
| 3022 | return; |
| 3023 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3024 | adapter->tx_timeout_count++; |
| 3025 | |
Ayyappan Veeraiyan | d4f8088 | 2008-02-01 15:58:41 -0800 | [diff] [blame] | 3026 | ixgbe_reinit_locked(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3027 | } |
| 3028 | |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3029 | #ifdef CONFIG_IXGBE_DCB |
| 3030 | static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter) |
Jesse Brandeburg | b980497 | 2008-09-11 20:00:29 -0700 | [diff] [blame] | 3031 | { |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3032 | bool ret = false; |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 3033 | struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_DCB]; |
Jesse Brandeburg | b980497 | 2008-09-11 20:00:29 -0700 | [diff] [blame] | 3034 | |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 3035 | if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED)) |
| 3036 | return ret; |
| 3037 | |
| 3038 | f->mask = 0x7 << 3; |
| 3039 | adapter->num_rx_queues = f->indices; |
| 3040 | adapter->num_tx_queues = f->indices; |
| 3041 | ret = true; |
Jesse Brandeburg | b980497 | 2008-09-11 20:00:29 -0700 | [diff] [blame] | 3042 | |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3043 | return ret; |
| 3044 | } |
| 3045 | #endif |
| 3046 | |
Jesse Brandeburg | 4df1046 | 2009-03-13 22:15:31 +0000 | [diff] [blame] | 3047 | /** |
| 3048 | * ixgbe_set_rss_queues: Allocate queues for RSS |
| 3049 | * @adapter: board private structure to initialize |
| 3050 | * |
| 3051 | * This is our "base" multiqueue mode. RSS (Receive Side Scaling) will try |
| 3052 | * to allocate one Rx queue per CPU, and if available, one Tx queue per CPU. |
| 3053 | * |
| 3054 | **/ |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3055 | static inline bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter) |
| 3056 | { |
| 3057 | bool ret = false; |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 3058 | struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_RSS]; |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3059 | |
| 3060 | if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { |
Jesse Brandeburg | 0cefafa | 2009-05-19 09:19:11 +0000 | [diff] [blame] | 3061 | f->mask = 0xF; |
| 3062 | adapter->num_rx_queues = f->indices; |
| 3063 | adapter->num_tx_queues = f->indices; |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3064 | ret = true; |
| 3065 | } else { |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3066 | ret = false; |
| 3067 | } |
| 3068 | |
| 3069 | return ret; |
| 3070 | } |
| 3071 | |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 3072 | /** |
| 3073 | * ixgbe_set_fdir_queues: Allocate queues for Flow Director |
| 3074 | * @adapter: board private structure to initialize |
| 3075 | * |
| 3076 | * Flow Director is an advanced Rx filter, attempting to get Rx flows back |
| 3077 | * to the original CPU that initiated the Tx session. This runs in addition |
| 3078 | * to RSS, so if a packet doesn't match an FDIR filter, we can still spread the |
| 3079 | * Rx load across CPUs using RSS. |
| 3080 | * |
| 3081 | **/ |
| 3082 | static bool inline ixgbe_set_fdir_queues(struct ixgbe_adapter *adapter) |
| 3083 | { |
| 3084 | bool ret = false; |
| 3085 | struct ixgbe_ring_feature *f_fdir = &adapter->ring_feature[RING_F_FDIR]; |
| 3086 | |
| 3087 | f_fdir->indices = min((int)num_online_cpus(), f_fdir->indices); |
| 3088 | f_fdir->mask = 0; |
| 3089 | |
| 3090 | /* Flow Director must have RSS enabled */ |
| 3091 | if (adapter->flags & IXGBE_FLAG_RSS_ENABLED && |
| 3092 | ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || |
| 3093 | (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)))) { |
| 3094 | adapter->num_tx_queues = f_fdir->indices; |
| 3095 | adapter->num_rx_queues = f_fdir->indices; |
| 3096 | ret = true; |
| 3097 | } else { |
| 3098 | adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; |
| 3099 | adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE; |
| 3100 | } |
| 3101 | return ret; |
| 3102 | } |
| 3103 | |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3104 | #ifdef IXGBE_FCOE |
| 3105 | /** |
| 3106 | * ixgbe_set_fcoe_queues: Allocate queues for Fiber Channel over Ethernet (FCoE) |
| 3107 | * @adapter: board private structure to initialize |
| 3108 | * |
| 3109 | * FCoE RX FCRETA can use up to 8 rx queues for up to 8 different exchanges. |
| 3110 | * The ring feature mask is not used as a mask for FCoE, as it can take any 8 |
| 3111 | * rx queues out of the max number of rx queues, instead, it is used as the |
| 3112 | * index of the first rx queue used by FCoE. |
| 3113 | * |
| 3114 | **/ |
| 3115 | static inline bool ixgbe_set_fcoe_queues(struct ixgbe_adapter *adapter) |
| 3116 | { |
| 3117 | bool ret = false; |
| 3118 | struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE]; |
| 3119 | |
| 3120 | f->indices = min((int)num_online_cpus(), f->indices); |
| 3121 | if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) { |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3122 | adapter->num_rx_queues = 1; |
| 3123 | adapter->num_tx_queues = 1; |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3124 | #ifdef CONFIG_IXGBE_DCB |
| 3125 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3126 | DPRINTK(PROBE, INFO, "FCoE enabled with DCB \n"); |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3127 | ixgbe_set_dcb_queues(adapter); |
| 3128 | } |
| 3129 | #endif |
| 3130 | if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3131 | DPRINTK(PROBE, INFO, "FCoE enabled with RSS \n"); |
Yi Zou | 8faa2a7 | 2009-07-09 02:29:50 +0000 | [diff] [blame] | 3132 | if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) || |
| 3133 | (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) |
| 3134 | ixgbe_set_fdir_queues(adapter); |
| 3135 | else |
| 3136 | ixgbe_set_rss_queues(adapter); |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3137 | } |
| 3138 | /* adding FCoE rx rings to the end */ |
| 3139 | f->mask = adapter->num_rx_queues; |
| 3140 | adapter->num_rx_queues += f->indices; |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3141 | adapter->num_tx_queues += f->indices; |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3142 | |
| 3143 | ret = true; |
| 3144 | } |
| 3145 | |
| 3146 | return ret; |
| 3147 | } |
| 3148 | |
| 3149 | #endif /* IXGBE_FCOE */ |
Jesse Brandeburg | 4df1046 | 2009-03-13 22:15:31 +0000 | [diff] [blame] | 3150 | /* |
| 3151 | * ixgbe_set_num_queues: Allocate queues for device, feature dependant |
| 3152 | * @adapter: board private structure to initialize |
| 3153 | * |
| 3154 | * This is the top level queue allocation routine. The order here is very |
| 3155 | * important, starting with the "most" number of features turned on at once, |
| 3156 | * and ending with the smallest set of features. This way large combinations |
| 3157 | * can be allocated if they're turned on, and smaller combinations are the |
| 3158 | * fallthrough conditions. |
| 3159 | * |
| 3160 | **/ |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3161 | static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter) |
| 3162 | { |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3163 | #ifdef IXGBE_FCOE |
| 3164 | if (ixgbe_set_fcoe_queues(adapter)) |
| 3165 | goto done; |
| 3166 | |
| 3167 | #endif /* IXGBE_FCOE */ |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3168 | #ifdef CONFIG_IXGBE_DCB |
| 3169 | if (ixgbe_set_dcb_queues(adapter)) |
Wu Fengguang | af22ab1 | 2009-04-14 21:54:07 -0700 | [diff] [blame] | 3170 | goto done; |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3171 | |
| 3172 | #endif |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 3173 | if (ixgbe_set_fdir_queues(adapter)) |
| 3174 | goto done; |
| 3175 | |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3176 | if (ixgbe_set_rss_queues(adapter)) |
Wu Fengguang | af22ab1 | 2009-04-14 21:54:07 -0700 | [diff] [blame] | 3177 | goto done; |
| 3178 | |
| 3179 | /* fallback to base case */ |
| 3180 | adapter->num_rx_queues = 1; |
| 3181 | adapter->num_tx_queues = 1; |
| 3182 | |
| 3183 | done: |
| 3184 | /* Notify the stack of the (possibly) reduced Tx Queue count. */ |
| 3185 | adapter->netdev->real_num_tx_queues = adapter->num_tx_queues; |
Jesse Brandeburg | b980497 | 2008-09-11 20:00:29 -0700 | [diff] [blame] | 3186 | } |
| 3187 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3188 | static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3189 | int vectors) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3190 | { |
| 3191 | int err, vector_threshold; |
| 3192 | |
| 3193 | /* We'll want at least 3 (vector_threshold): |
| 3194 | * 1) TxQ[0] Cleanup |
| 3195 | * 2) RxQ[0] Cleanup |
| 3196 | * 3) Other (Link Status Change, etc.) |
| 3197 | * 4) TCP Timer (optional) |
| 3198 | */ |
| 3199 | vector_threshold = MIN_MSIX_COUNT; |
| 3200 | |
| 3201 | /* The more we get, the more we will assign to Tx/Rx Cleanup |
| 3202 | * for the separate queues...where Rx Cleanup >= Tx Cleanup. |
| 3203 | * Right now, we simply care about how many we'll get; we'll |
| 3204 | * set them up later while requesting irq's. |
| 3205 | */ |
| 3206 | while (vectors >= vector_threshold) { |
| 3207 | err = pci_enable_msix(adapter->pdev, adapter->msix_entries, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3208 | vectors); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3209 | if (!err) /* Success in acquiring all requested vectors. */ |
| 3210 | break; |
| 3211 | else if (err < 0) |
| 3212 | vectors = 0; /* Nasty failure, quit now */ |
| 3213 | else /* err == number of vectors we should try again with */ |
| 3214 | vectors = err; |
| 3215 | } |
| 3216 | |
| 3217 | if (vectors < vector_threshold) { |
| 3218 | /* Can't allocate enough MSI-X interrupts? Oh well. |
| 3219 | * This just means we'll go with either a single MSI |
| 3220 | * vector or fall back to legacy interrupts. |
| 3221 | */ |
| 3222 | DPRINTK(HW, DEBUG, "Unable to allocate MSI-X interrupts\n"); |
| 3223 | adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; |
| 3224 | kfree(adapter->msix_entries); |
| 3225 | adapter->msix_entries = NULL; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3226 | } else { |
| 3227 | adapter->flags |= IXGBE_FLAG_MSIX_ENABLED; /* Woot! */ |
Peter P Waskiewicz Jr | eb7f139 | 2009-02-01 01:18:58 -0800 | [diff] [blame] | 3228 | /* |
| 3229 | * Adjust for only the vectors we'll use, which is minimum |
| 3230 | * of max_msix_q_vectors + NON_Q_VECTORS, or the number of |
| 3231 | * vectors we were allocated. |
| 3232 | */ |
| 3233 | adapter->num_msix_vectors = min(vectors, |
| 3234 | adapter->max_msix_q_vectors + NON_Q_VECTORS); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3235 | } |
| 3236 | } |
| 3237 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3238 | /** |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3239 | * ixgbe_cache_ring_rss - Descriptor ring to register mapping for RSS |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3240 | * @adapter: board private structure to initialize |
| 3241 | * |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3242 | * Cache the descriptor ring offsets for RSS to the assigned rings. |
| 3243 | * |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3244 | **/ |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3245 | static inline bool ixgbe_cache_ring_rss(struct ixgbe_adapter *adapter) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3246 | { |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3247 | int i; |
| 3248 | bool ret = false; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3249 | |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3250 | if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { |
| 3251 | for (i = 0; i < adapter->num_rx_queues; i++) |
| 3252 | adapter->rx_ring[i].reg_idx = i; |
| 3253 | for (i = 0; i < adapter->num_tx_queues; i++) |
| 3254 | adapter->tx_ring[i].reg_idx = i; |
| 3255 | ret = true; |
| 3256 | } else { |
| 3257 | ret = false; |
| 3258 | } |
| 3259 | |
| 3260 | return ret; |
| 3261 | } |
| 3262 | |
| 3263 | #ifdef CONFIG_IXGBE_DCB |
| 3264 | /** |
| 3265 | * ixgbe_cache_ring_dcb - Descriptor ring to register mapping for DCB |
| 3266 | * @adapter: board private structure to initialize |
| 3267 | * |
| 3268 | * Cache the descriptor ring offsets for DCB to the assigned rings. |
| 3269 | * |
| 3270 | **/ |
| 3271 | static inline bool ixgbe_cache_ring_dcb(struct ixgbe_adapter *adapter) |
| 3272 | { |
| 3273 | int i; |
| 3274 | bool ret = false; |
| 3275 | int dcb_i = adapter->ring_feature[RING_F_DCB].indices; |
| 3276 | |
| 3277 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
| 3278 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) { |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3279 | /* the number of queues is assumed to be symmetric */ |
| 3280 | for (i = 0; i < dcb_i; i++) { |
| 3281 | adapter->rx_ring[i].reg_idx = i << 3; |
| 3282 | adapter->tx_ring[i].reg_idx = i << 2; |
| 3283 | } |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3284 | ret = true; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 3285 | } else if (adapter->hw.mac.type == ixgbe_mac_82599EB) { |
PJ Waskiewicz | f92ef20 | 2009-04-16 15:00:20 +0000 | [diff] [blame] | 3286 | if (dcb_i == 8) { |
| 3287 | /* |
| 3288 | * Tx TC0 starts at: descriptor queue 0 |
| 3289 | * Tx TC1 starts at: descriptor queue 32 |
| 3290 | * Tx TC2 starts at: descriptor queue 64 |
| 3291 | * Tx TC3 starts at: descriptor queue 80 |
| 3292 | * Tx TC4 starts at: descriptor queue 96 |
| 3293 | * Tx TC5 starts at: descriptor queue 104 |
| 3294 | * Tx TC6 starts at: descriptor queue 112 |
| 3295 | * Tx TC7 starts at: descriptor queue 120 |
| 3296 | * |
| 3297 | * Rx TC0-TC7 are offset by 16 queues each |
| 3298 | */ |
| 3299 | for (i = 0; i < 3; i++) { |
| 3300 | adapter->tx_ring[i].reg_idx = i << 5; |
| 3301 | adapter->rx_ring[i].reg_idx = i << 4; |
| 3302 | } |
| 3303 | for ( ; i < 5; i++) { |
| 3304 | adapter->tx_ring[i].reg_idx = |
| 3305 | ((i + 2) << 4); |
| 3306 | adapter->rx_ring[i].reg_idx = i << 4; |
| 3307 | } |
| 3308 | for ( ; i < dcb_i; i++) { |
| 3309 | adapter->tx_ring[i].reg_idx = |
| 3310 | ((i + 8) << 3); |
| 3311 | adapter->rx_ring[i].reg_idx = i << 4; |
| 3312 | } |
| 3313 | |
| 3314 | ret = true; |
| 3315 | } else if (dcb_i == 4) { |
| 3316 | /* |
| 3317 | * Tx TC0 starts at: descriptor queue 0 |
| 3318 | * Tx TC1 starts at: descriptor queue 64 |
| 3319 | * Tx TC2 starts at: descriptor queue 96 |
| 3320 | * Tx TC3 starts at: descriptor queue 112 |
| 3321 | * |
| 3322 | * Rx TC0-TC3 are offset by 32 queues each |
| 3323 | */ |
| 3324 | adapter->tx_ring[0].reg_idx = 0; |
| 3325 | adapter->tx_ring[1].reg_idx = 64; |
| 3326 | adapter->tx_ring[2].reg_idx = 96; |
| 3327 | adapter->tx_ring[3].reg_idx = 112; |
| 3328 | for (i = 0 ; i < dcb_i; i++) |
| 3329 | adapter->rx_ring[i].reg_idx = i << 5; |
| 3330 | |
| 3331 | ret = true; |
| 3332 | } else { |
| 3333 | ret = false; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 3334 | } |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3335 | } else { |
| 3336 | ret = false; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3337 | } |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3338 | } else { |
| 3339 | ret = false; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3340 | } |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3341 | |
| 3342 | return ret; |
| 3343 | } |
| 3344 | #endif |
| 3345 | |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 3346 | /** |
| 3347 | * ixgbe_cache_ring_fdir - Descriptor ring to register mapping for Flow Director |
| 3348 | * @adapter: board private structure to initialize |
| 3349 | * |
| 3350 | * Cache the descriptor ring offsets for Flow Director to the assigned rings. |
| 3351 | * |
| 3352 | **/ |
| 3353 | static bool inline ixgbe_cache_ring_fdir(struct ixgbe_adapter *adapter) |
| 3354 | { |
| 3355 | int i; |
| 3356 | bool ret = false; |
| 3357 | |
| 3358 | if (adapter->flags & IXGBE_FLAG_RSS_ENABLED && |
| 3359 | ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) || |
| 3360 | (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))) { |
| 3361 | for (i = 0; i < adapter->num_rx_queues; i++) |
| 3362 | adapter->rx_ring[i].reg_idx = i; |
| 3363 | for (i = 0; i < adapter->num_tx_queues; i++) |
| 3364 | adapter->tx_ring[i].reg_idx = i; |
| 3365 | ret = true; |
| 3366 | } |
| 3367 | |
| 3368 | return ret; |
| 3369 | } |
| 3370 | |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3371 | #ifdef IXGBE_FCOE |
| 3372 | /** |
| 3373 | * ixgbe_cache_ring_fcoe - Descriptor ring to register mapping for the FCoE |
| 3374 | * @adapter: board private structure to initialize |
| 3375 | * |
| 3376 | * Cache the descriptor ring offsets for FCoE mode to the assigned rings. |
| 3377 | * |
| 3378 | */ |
| 3379 | static inline bool ixgbe_cache_ring_fcoe(struct ixgbe_adapter *adapter) |
| 3380 | { |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3381 | int i, fcoe_rx_i = 0, fcoe_tx_i = 0; |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3382 | bool ret = false; |
| 3383 | struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE]; |
| 3384 | |
| 3385 | if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) { |
| 3386 | #ifdef CONFIG_IXGBE_DCB |
| 3387 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3388 | struct ixgbe_fcoe *fcoe = &adapter->fcoe; |
| 3389 | |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3390 | ixgbe_cache_ring_dcb(adapter); |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3391 | /* find out queues in TC for FCoE */ |
| 3392 | fcoe_rx_i = adapter->rx_ring[fcoe->tc].reg_idx + 1; |
| 3393 | fcoe_tx_i = adapter->tx_ring[fcoe->tc].reg_idx + 1; |
| 3394 | /* |
| 3395 | * In 82599, the number of Tx queues for each traffic |
| 3396 | * class for both 8-TC and 4-TC modes are: |
| 3397 | * TCs : TC0 TC1 TC2 TC3 TC4 TC5 TC6 TC7 |
| 3398 | * 8 TCs: 32 32 16 16 8 8 8 8 |
| 3399 | * 4 TCs: 64 64 32 32 |
| 3400 | * We have max 8 queues for FCoE, where 8 the is |
| 3401 | * FCoE redirection table size. If TC for FCoE is |
| 3402 | * less than or equal to TC3, we have enough queues |
| 3403 | * to add max of 8 queues for FCoE, so we start FCoE |
| 3404 | * tx descriptor from the next one, i.e., reg_idx + 1. |
| 3405 | * If TC for FCoE is above TC3, implying 8 TC mode, |
| 3406 | * and we need 8 for FCoE, we have to take all queues |
| 3407 | * in that traffic class for FCoE. |
| 3408 | */ |
| 3409 | if ((f->indices == IXGBE_FCRETA_SIZE) && (fcoe->tc > 3)) |
| 3410 | fcoe_tx_i--; |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3411 | } |
| 3412 | #endif /* CONFIG_IXGBE_DCB */ |
| 3413 | if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { |
Yi Zou | 8faa2a7 | 2009-07-09 02:29:50 +0000 | [diff] [blame] | 3414 | if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) || |
| 3415 | (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) |
| 3416 | ixgbe_cache_ring_fdir(adapter); |
| 3417 | else |
| 3418 | ixgbe_cache_ring_rss(adapter); |
| 3419 | |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3420 | fcoe_rx_i = f->mask; |
| 3421 | fcoe_tx_i = f->mask; |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3422 | } |
Yi Zou | 8de8b2e | 2009-09-03 14:55:50 +0000 | [diff] [blame] | 3423 | for (i = 0; i < f->indices; i++, fcoe_rx_i++, fcoe_tx_i++) { |
| 3424 | adapter->rx_ring[f->mask + i].reg_idx = fcoe_rx_i; |
| 3425 | adapter->tx_ring[f->mask + i].reg_idx = fcoe_tx_i; |
| 3426 | } |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3427 | ret = true; |
| 3428 | } |
| 3429 | return ret; |
| 3430 | } |
| 3431 | |
| 3432 | #endif /* IXGBE_FCOE */ |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3433 | /** |
| 3434 | * ixgbe_cache_ring_register - Descriptor ring to register mapping |
| 3435 | * @adapter: board private structure to initialize |
| 3436 | * |
| 3437 | * Once we know the feature-set enabled for the device, we'll cache |
| 3438 | * the register offset the descriptor ring is assigned to. |
| 3439 | * |
| 3440 | * Note, the order the various feature calls is important. It must start with |
| 3441 | * the "most" features enabled at the same time, then trickle down to the |
| 3442 | * least amount of features turned on at once. |
| 3443 | **/ |
| 3444 | static void ixgbe_cache_ring_register(struct ixgbe_adapter *adapter) |
| 3445 | { |
| 3446 | /* start with default case */ |
| 3447 | adapter->rx_ring[0].reg_idx = 0; |
| 3448 | adapter->tx_ring[0].reg_idx = 0; |
| 3449 | |
Yi Zou | 0331a83 | 2009-05-17 12:33:52 +0000 | [diff] [blame] | 3450 | #ifdef IXGBE_FCOE |
| 3451 | if (ixgbe_cache_ring_fcoe(adapter)) |
| 3452 | return; |
| 3453 | |
| 3454 | #endif /* IXGBE_FCOE */ |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3455 | #ifdef CONFIG_IXGBE_DCB |
| 3456 | if (ixgbe_cache_ring_dcb(adapter)) |
| 3457 | return; |
| 3458 | |
| 3459 | #endif |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 3460 | if (ixgbe_cache_ring_fdir(adapter)) |
| 3461 | return; |
| 3462 | |
Peter P Waskiewicz Jr | bc97114 | 2009-02-05 23:53:59 -0800 | [diff] [blame] | 3463 | if (ixgbe_cache_ring_rss(adapter)) |
| 3464 | return; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3465 | } |
| 3466 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3467 | /** |
| 3468 | * ixgbe_alloc_queues - Allocate memory for all rings |
| 3469 | * @adapter: board private structure to initialize |
| 3470 | * |
| 3471 | * We allocate one ring per queue at run-time since we don't know the |
Jesse Brandeburg | 4df1046 | 2009-03-13 22:15:31 +0000 | [diff] [blame] | 3472 | * number of queues at compile-time. The polling_netdev array is |
| 3473 | * intended for Multiqueue, but should work fine with a single queue. |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3474 | **/ |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3475 | static int ixgbe_alloc_queues(struct ixgbe_adapter *adapter) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3476 | { |
| 3477 | int i; |
| 3478 | |
| 3479 | adapter->tx_ring = kcalloc(adapter->num_tx_queues, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3480 | sizeof(struct ixgbe_ring), GFP_KERNEL); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3481 | if (!adapter->tx_ring) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3482 | goto err_tx_ring_allocation; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3483 | |
| 3484 | adapter->rx_ring = kcalloc(adapter->num_rx_queues, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3485 | sizeof(struct ixgbe_ring), GFP_KERNEL); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3486 | if (!adapter->rx_ring) |
| 3487 | goto err_rx_ring_allocation; |
| 3488 | |
| 3489 | for (i = 0; i < adapter->num_tx_queues; i++) { |
Jesse Brandeburg | b980497 | 2008-09-11 20:00:29 -0700 | [diff] [blame] | 3490 | adapter->tx_ring[i].count = adapter->tx_ring_count; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3491 | adapter->tx_ring[i].queue_index = i; |
| 3492 | } |
Jesse Brandeburg | b980497 | 2008-09-11 20:00:29 -0700 | [diff] [blame] | 3493 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3494 | for (i = 0; i < adapter->num_rx_queues; i++) { |
Jesse Brandeburg | b980497 | 2008-09-11 20:00:29 -0700 | [diff] [blame] | 3495 | adapter->rx_ring[i].count = adapter->rx_ring_count; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3496 | adapter->rx_ring[i].queue_index = i; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3497 | } |
| 3498 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3499 | ixgbe_cache_ring_register(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3500 | |
| 3501 | return 0; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3502 | |
| 3503 | err_rx_ring_allocation: |
| 3504 | kfree(adapter->tx_ring); |
| 3505 | err_tx_ring_allocation: |
| 3506 | return -ENOMEM; |
| 3507 | } |
| 3508 | |
| 3509 | /** |
| 3510 | * ixgbe_set_interrupt_capability - set MSI-X or MSI if supported |
| 3511 | * @adapter: board private structure to initialize |
| 3512 | * |
| 3513 | * Attempt to configure the interrupts using the best available |
| 3514 | * capabilities of the hardware and the kernel. |
| 3515 | **/ |
Al Viro | feea6a5 | 2008-11-27 15:34:07 -0800 | [diff] [blame] | 3516 | static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3517 | { |
PJ Waskiewicz | 8be0e46 | 2009-03-31 21:34:05 +0000 | [diff] [blame] | 3518 | struct ixgbe_hw *hw = &adapter->hw; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3519 | int err = 0; |
| 3520 | int vector, v_budget; |
| 3521 | |
| 3522 | /* |
| 3523 | * It's easy to be greedy for MSI-X vectors, but it really |
| 3524 | * doesn't do us much good if we have a lot more vectors |
| 3525 | * than CPU's. So let's be conservative and only ask for |
| 3526 | * (roughly) twice the number of vectors as there are CPU's. |
| 3527 | */ |
| 3528 | v_budget = min(adapter->num_rx_queues + adapter->num_tx_queues, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3529 | (int)(num_online_cpus() * 2)) + NON_Q_VECTORS; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3530 | |
| 3531 | /* |
| 3532 | * At the same time, hardware can only support a maximum of |
PJ Waskiewicz | 8be0e46 | 2009-03-31 21:34:05 +0000 | [diff] [blame] | 3533 | * hw.mac->max_msix_vectors vectors. With features |
| 3534 | * such as RSS and VMDq, we can easily surpass the number of Rx and Tx |
| 3535 | * descriptor queues supported by our device. Thus, we cap it off in |
| 3536 | * those rare cases where the cpu count also exceeds our vector limit. |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3537 | */ |
PJ Waskiewicz | 8be0e46 | 2009-03-31 21:34:05 +0000 | [diff] [blame] | 3538 | v_budget = min(v_budget, (int)hw->mac.max_msix_vectors); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3539 | |
| 3540 | /* A failure in MSI-X entry allocation isn't fatal, but it does |
| 3541 | * mean we disable MSI-X capabilities of the adapter. */ |
| 3542 | adapter->msix_entries = kcalloc(v_budget, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3543 | sizeof(struct msix_entry), GFP_KERNEL); |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3544 | if (adapter->msix_entries) { |
| 3545 | for (vector = 0; vector < v_budget; vector++) |
| 3546 | adapter->msix_entries[vector].entry = vector; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3547 | |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3548 | ixgbe_acquire_msix_vectors(adapter, v_budget); |
| 3549 | |
| 3550 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) |
| 3551 | goto out; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3552 | } |
| 3553 | |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3554 | adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; |
| 3555 | adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED; |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 3556 | adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; |
| 3557 | adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE; |
| 3558 | adapter->atr_sample_rate = 0; |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3559 | ixgbe_set_num_queues(adapter); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3560 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3561 | err = pci_enable_msi(adapter->pdev); |
| 3562 | if (!err) { |
| 3563 | adapter->flags |= IXGBE_FLAG_MSI_ENABLED; |
| 3564 | } else { |
| 3565 | DPRINTK(HW, DEBUG, "Unable to allocate MSI interrupt, " |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3566 | "falling back to legacy. Error: %d\n", err); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3567 | /* reset err */ |
| 3568 | err = 0; |
| 3569 | } |
| 3570 | |
| 3571 | out: |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3572 | return err; |
| 3573 | } |
| 3574 | |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3575 | /** |
| 3576 | * ixgbe_alloc_q_vectors - Allocate memory for interrupt vectors |
| 3577 | * @adapter: board private structure to initialize |
| 3578 | * |
| 3579 | * We allocate one q_vector per queue interrupt. If allocation fails we |
| 3580 | * return -ENOMEM. |
| 3581 | **/ |
| 3582 | static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter) |
| 3583 | { |
| 3584 | int q_idx, num_q_vectors; |
| 3585 | struct ixgbe_q_vector *q_vector; |
| 3586 | int napi_vectors; |
| 3587 | int (*poll)(struct napi_struct *, int); |
| 3588 | |
| 3589 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { |
| 3590 | num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
| 3591 | napi_vectors = adapter->num_rx_queues; |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 3592 | poll = &ixgbe_clean_rxtx_many; |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3593 | } else { |
| 3594 | num_q_vectors = 1; |
| 3595 | napi_vectors = 1; |
| 3596 | poll = &ixgbe_poll; |
| 3597 | } |
| 3598 | |
| 3599 | for (q_idx = 0; q_idx < num_q_vectors; q_idx++) { |
| 3600 | q_vector = kzalloc(sizeof(struct ixgbe_q_vector), GFP_KERNEL); |
| 3601 | if (!q_vector) |
| 3602 | goto err_out; |
| 3603 | q_vector->adapter = adapter; |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 3604 | if (q_vector->txr_count && !q_vector->rxr_count) |
| 3605 | q_vector->eitr = adapter->tx_eitr_param; |
| 3606 | else |
| 3607 | q_vector->eitr = adapter->rx_eitr_param; |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 3608 | q_vector->v_idx = q_idx; |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 3609 | netif_napi_add(adapter->netdev, &q_vector->napi, (*poll), 64); |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3610 | adapter->q_vector[q_idx] = q_vector; |
| 3611 | } |
| 3612 | |
| 3613 | return 0; |
| 3614 | |
| 3615 | err_out: |
| 3616 | while (q_idx) { |
| 3617 | q_idx--; |
| 3618 | q_vector = adapter->q_vector[q_idx]; |
| 3619 | netif_napi_del(&q_vector->napi); |
| 3620 | kfree(q_vector); |
| 3621 | adapter->q_vector[q_idx] = NULL; |
| 3622 | } |
| 3623 | return -ENOMEM; |
| 3624 | } |
| 3625 | |
| 3626 | /** |
| 3627 | * ixgbe_free_q_vectors - Free memory allocated for interrupt vectors |
| 3628 | * @adapter: board private structure to initialize |
| 3629 | * |
| 3630 | * This function frees the memory allocated to the q_vectors. In addition if |
| 3631 | * NAPI is enabled it will delete any references to the NAPI struct prior |
| 3632 | * to freeing the q_vector. |
| 3633 | **/ |
| 3634 | static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter) |
| 3635 | { |
| 3636 | int q_idx, num_q_vectors; |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3637 | |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 3638 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3639 | num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 3640 | else |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3641 | num_q_vectors = 1; |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3642 | |
| 3643 | for (q_idx = 0; q_idx < num_q_vectors; q_idx++) { |
| 3644 | struct ixgbe_q_vector *q_vector = adapter->q_vector[q_idx]; |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3645 | adapter->q_vector[q_idx] = NULL; |
Alexander Duyck | 91281fd | 2009-06-04 16:00:27 +0000 | [diff] [blame] | 3646 | netif_napi_del(&q_vector->napi); |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3647 | kfree(q_vector); |
| 3648 | } |
| 3649 | } |
| 3650 | |
Don Skidmore | 7b25cdb | 2009-08-25 04:47:32 +0000 | [diff] [blame] | 3651 | static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3652 | { |
| 3653 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { |
| 3654 | adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; |
| 3655 | pci_disable_msix(adapter->pdev); |
| 3656 | kfree(adapter->msix_entries); |
| 3657 | adapter->msix_entries = NULL; |
| 3658 | } else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) { |
| 3659 | adapter->flags &= ~IXGBE_FLAG_MSI_ENABLED; |
| 3660 | pci_disable_msi(adapter->pdev); |
| 3661 | } |
| 3662 | return; |
| 3663 | } |
| 3664 | |
| 3665 | /** |
| 3666 | * ixgbe_init_interrupt_scheme - Determine proper interrupt scheme |
| 3667 | * @adapter: board private structure to initialize |
| 3668 | * |
| 3669 | * We determine which interrupt scheme to use based on... |
| 3670 | * - Kernel support (MSI, MSI-X) |
| 3671 | * - which can be user-defined (via MODULE_PARAM) |
| 3672 | * - Hardware queue count (num_*_queues) |
| 3673 | * - defined by miscellaneous hardware support/features (RSS, etc.) |
| 3674 | **/ |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3675 | int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter) |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3676 | { |
| 3677 | int err; |
| 3678 | |
| 3679 | /* Number of supported queues */ |
| 3680 | ixgbe_set_num_queues(adapter); |
| 3681 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3682 | err = ixgbe_set_interrupt_capability(adapter); |
| 3683 | if (err) { |
| 3684 | DPRINTK(PROBE, ERR, "Unable to setup interrupt capabilities\n"); |
| 3685 | goto err_set_interrupt; |
| 3686 | } |
| 3687 | |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3688 | err = ixgbe_alloc_q_vectors(adapter); |
| 3689 | if (err) { |
| 3690 | DPRINTK(PROBE, ERR, "Unable to allocate memory for queue " |
| 3691 | "vectors\n"); |
| 3692 | goto err_alloc_q_vectors; |
| 3693 | } |
| 3694 | |
| 3695 | err = ixgbe_alloc_queues(adapter); |
| 3696 | if (err) { |
| 3697 | DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n"); |
| 3698 | goto err_alloc_queues; |
| 3699 | } |
| 3700 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3701 | DPRINTK(DRV, INFO, "Multiqueue %s: Rx Queue count = %u, " |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3702 | "Tx Queue count = %u\n", |
| 3703 | (adapter->num_rx_queues > 1) ? "Enabled" : |
| 3704 | "Disabled", adapter->num_rx_queues, adapter->num_tx_queues); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3705 | |
| 3706 | set_bit(__IXGBE_DOWN, &adapter->state); |
| 3707 | |
| 3708 | return 0; |
| 3709 | |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3710 | err_alloc_queues: |
| 3711 | ixgbe_free_q_vectors(adapter); |
| 3712 | err_alloc_q_vectors: |
| 3713 | ixgbe_reset_interrupt_capability(adapter); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3714 | err_set_interrupt: |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3715 | return err; |
| 3716 | } |
| 3717 | |
| 3718 | /** |
| 3719 | * ixgbe_clear_interrupt_scheme - Clear the current interrupt scheme settings |
| 3720 | * @adapter: board private structure to clear interrupt scheme on |
| 3721 | * |
| 3722 | * We go through and clear interrupt specific resources and reset the structure |
| 3723 | * to pre-load conditions |
| 3724 | **/ |
| 3725 | void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter) |
| 3726 | { |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3727 | kfree(adapter->tx_ring); |
| 3728 | kfree(adapter->rx_ring); |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 3729 | adapter->tx_ring = NULL; |
| 3730 | adapter->rx_ring = NULL; |
| 3731 | |
| 3732 | ixgbe_free_q_vectors(adapter); |
| 3733 | ixgbe_reset_interrupt_capability(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3734 | } |
| 3735 | |
| 3736 | /** |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 3737 | * ixgbe_sfp_timer - worker thread to find a missing module |
| 3738 | * @data: pointer to our adapter struct |
| 3739 | **/ |
| 3740 | static void ixgbe_sfp_timer(unsigned long data) |
| 3741 | { |
| 3742 | struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)data; |
| 3743 | |
Jesse Brandeburg | 4df1046 | 2009-03-13 22:15:31 +0000 | [diff] [blame] | 3744 | /* |
| 3745 | * Do the sfp_timer outside of interrupt context due to the |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 3746 | * delays that sfp+ detection requires |
| 3747 | */ |
| 3748 | schedule_work(&adapter->sfp_task); |
| 3749 | } |
| 3750 | |
| 3751 | /** |
| 3752 | * ixgbe_sfp_task - worker thread to find a missing module |
| 3753 | * @work: pointer to work_struct containing our data |
| 3754 | **/ |
| 3755 | static void ixgbe_sfp_task(struct work_struct *work) |
| 3756 | { |
| 3757 | struct ixgbe_adapter *adapter = container_of(work, |
| 3758 | struct ixgbe_adapter, |
| 3759 | sfp_task); |
| 3760 | struct ixgbe_hw *hw = &adapter->hw; |
| 3761 | |
| 3762 | if ((hw->phy.type == ixgbe_phy_nl) && |
| 3763 | (hw->phy.sfp_type == ixgbe_sfp_type_not_present)) { |
| 3764 | s32 ret = hw->phy.ops.identify_sfp(hw); |
Don Skidmore | 63d6e1d | 2009-07-02 12:50:12 +0000 | [diff] [blame] | 3765 | if (ret == IXGBE_ERR_SFP_NOT_PRESENT) |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 3766 | goto reschedule; |
| 3767 | ret = hw->phy.ops.reset(hw); |
| 3768 | if (ret == IXGBE_ERR_SFP_NOT_SUPPORTED) { |
Don Skidmore | 88d2b81 | 2009-06-30 11:43:55 +0000 | [diff] [blame] | 3769 | dev_err(&adapter->pdev->dev, "failed to initialize " |
| 3770 | "because an unsupported SFP+ module type " |
| 3771 | "was detected.\n" |
| 3772 | "Reload the driver after installing a " |
| 3773 | "supported module.\n"); |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 3774 | unregister_netdev(adapter->netdev); |
| 3775 | } else { |
| 3776 | DPRINTK(PROBE, INFO, "detected SFP+: %d\n", |
| 3777 | hw->phy.sfp_type); |
| 3778 | } |
| 3779 | /* don't need this routine any more */ |
| 3780 | clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state); |
| 3781 | } |
| 3782 | return; |
| 3783 | reschedule: |
| 3784 | if (test_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state)) |
| 3785 | mod_timer(&adapter->sfp_timer, |
| 3786 | round_jiffies(jiffies + (2 * HZ))); |
| 3787 | } |
| 3788 | |
| 3789 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3790 | * ixgbe_sw_init - Initialize general software structures (struct ixgbe_adapter) |
| 3791 | * @adapter: board private structure to initialize |
| 3792 | * |
| 3793 | * ixgbe_sw_init initializes the Adapter private data structure. |
| 3794 | * Fields are initialized based on PCI device information and |
| 3795 | * OS network device settings (MTU size). |
| 3796 | **/ |
| 3797 | static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) |
| 3798 | { |
| 3799 | struct ixgbe_hw *hw = &adapter->hw; |
| 3800 | struct pci_dev *pdev = adapter->pdev; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3801 | unsigned int rss; |
Jeff Kirsher | 7a6b6f5 | 2008-11-25 01:02:08 -0800 | [diff] [blame] | 3802 | #ifdef CONFIG_IXGBE_DCB |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3803 | int j; |
| 3804 | struct tc_configuration *tc; |
| 3805 | #endif |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3806 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 3807 | /* PCI config space info */ |
| 3808 | |
| 3809 | hw->vendor_id = pdev->vendor; |
| 3810 | hw->device_id = pdev->device; |
| 3811 | hw->revision_id = pdev->revision; |
| 3812 | hw->subsystem_vendor_id = pdev->subsystem_vendor; |
| 3813 | hw->subsystem_device_id = pdev->subsystem_device; |
| 3814 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3815 | /* Set capability flags */ |
| 3816 | rss = min(IXGBE_MAX_RSS_INDICES, (int)num_online_cpus()); |
| 3817 | adapter->ring_feature[RING_F_RSS].indices = rss; |
| 3818 | adapter->flags |= IXGBE_FLAG_RSS_ENABLED; |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3819 | adapter->ring_feature[RING_F_DCB].indices = IXGBE_MAX_DCB_INDICES; |
Don Skidmore | bf069c9 | 2009-05-07 10:39:54 +0000 | [diff] [blame] | 3820 | if (hw->mac.type == ixgbe_mac_82598EB) { |
| 3821 | if (hw->device_id == IXGBE_DEV_ID_82598AT) |
| 3822 | adapter->flags |= IXGBE_FLAG_FAN_FAIL_CAPABLE; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 3823 | adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82598; |
Don Skidmore | bf069c9 | 2009-05-07 10:39:54 +0000 | [diff] [blame] | 3824 | } else if (hw->mac.type == ixgbe_mac_82599EB) { |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 3825 | adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82599; |
Peter P Waskiewicz Jr | 0c19d6a | 2009-07-30 12:25:28 +0000 | [diff] [blame] | 3826 | adapter->flags2 |= IXGBE_FLAG2_RSC_CAPABLE; |
| 3827 | adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 3828 | adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE; |
| 3829 | adapter->ring_feature[RING_F_FDIR].indices = |
| 3830 | IXGBE_MAX_FDIR_INDICES; |
| 3831 | adapter->atr_sample_rate = 20; |
| 3832 | adapter->fdir_pballoc = 0; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 3833 | #ifdef IXGBE_FCOE |
Yi Zou | 0d55158 | 2009-07-22 14:07:12 +0000 | [diff] [blame] | 3834 | adapter->flags |= IXGBE_FLAG_FCOE_CAPABLE; |
| 3835 | adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; |
| 3836 | adapter->ring_feature[RING_F_FCOE].indices = 0; |
Yi Zou | 6ee1652 | 2009-08-31 12:34:28 +0000 | [diff] [blame] | 3837 | /* Default traffic class to use for FCoE */ |
| 3838 | adapter->fcoe.tc = IXGBE_FCOE_DEFTC; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 3839 | #endif /* IXGBE_FCOE */ |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 3840 | } |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3841 | |
Jeff Kirsher | 7a6b6f5 | 2008-11-25 01:02:08 -0800 | [diff] [blame] | 3842 | #ifdef CONFIG_IXGBE_DCB |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3843 | /* Configure DCB traffic classes */ |
| 3844 | for (j = 0; j < MAX_TRAFFIC_CLASS; j++) { |
| 3845 | tc = &adapter->dcb_cfg.tc_config[j]; |
| 3846 | tc->path[DCB_TX_CONFIG].bwg_id = 0; |
| 3847 | tc->path[DCB_TX_CONFIG].bwg_percent = 12 + (j & 1); |
| 3848 | tc->path[DCB_RX_CONFIG].bwg_id = 0; |
| 3849 | tc->path[DCB_RX_CONFIG].bwg_percent = 12 + (j & 1); |
| 3850 | tc->dcb_pfc = pfc_disabled; |
| 3851 | } |
| 3852 | adapter->dcb_cfg.bw_percentage[DCB_TX_CONFIG][0] = 100; |
| 3853 | adapter->dcb_cfg.bw_percentage[DCB_RX_CONFIG][0] = 100; |
| 3854 | adapter->dcb_cfg.rx_pba_cfg = pba_equal; |
Peter P Waskiewicz Jr | 264857b | 2009-05-17 12:35:16 +0000 | [diff] [blame] | 3855 | adapter->dcb_cfg.pfc_mode_enable = false; |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 3856 | adapter->dcb_cfg.round_robin_enable = false; |
| 3857 | adapter->dcb_set_bitmap = 0x00; |
| 3858 | ixgbe_copy_dcb_cfg(&adapter->dcb_cfg, &adapter->temp_dcb_cfg, |
| 3859 | adapter->ring_feature[RING_F_DCB].indices); |
| 3860 | |
| 3861 | #endif |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3862 | |
| 3863 | /* default flow control settings */ |
Don Skidmore | cd7664f | 2009-03-31 21:33:44 +0000 | [diff] [blame] | 3864 | hw->fc.requested_mode = ixgbe_fc_full; |
Don Skidmore | 71fd570 | 2009-03-31 21:35:05 +0000 | [diff] [blame] | 3865 | hw->fc.current_mode = ixgbe_fc_full; /* init for ethtool output */ |
Peter P Waskiewicz Jr | 264857b | 2009-05-17 12:35:16 +0000 | [diff] [blame] | 3866 | #ifdef CONFIG_DCB |
| 3867 | adapter->last_lfc_mode = hw->fc.current_mode; |
| 3868 | #endif |
Jesse Brandeburg | 2b9ade9 | 2008-08-26 04:27:10 -0700 | [diff] [blame] | 3869 | hw->fc.high_water = IXGBE_DEFAULT_FCRTH; |
| 3870 | hw->fc.low_water = IXGBE_DEFAULT_FCRTL; |
| 3871 | hw->fc.pause_time = IXGBE_DEFAULT_FCPAUSE; |
| 3872 | hw->fc.send_xon = true; |
Don Skidmore | 71fd570 | 2009-03-31 21:35:05 +0000 | [diff] [blame] | 3873 | hw->fc.disable_fc_autoneg = false; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3874 | |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 3875 | /* enable itr by default in dynamic mode */ |
Nelson, Shannon | f7554a2 | 2009-09-18 09:46:06 +0000 | [diff] [blame^] | 3876 | adapter->rx_itr_setting = 1; |
| 3877 | adapter->rx_eitr_param = 20000; |
| 3878 | adapter->tx_itr_setting = 1; |
| 3879 | adapter->tx_eitr_param = 10000; |
Jesse Brandeburg | 30efa5a | 2008-09-11 19:58:14 -0700 | [diff] [blame] | 3880 | |
| 3881 | /* set defaults for eitr in MegaBytes */ |
| 3882 | adapter->eitr_low = 10; |
| 3883 | adapter->eitr_high = 20; |
| 3884 | |
| 3885 | /* set default ring sizes */ |
| 3886 | adapter->tx_ring_count = IXGBE_DEFAULT_TXD; |
| 3887 | adapter->rx_ring_count = IXGBE_DEFAULT_RXD; |
| 3888 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3889 | /* initialize eeprom parameters */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 3890 | if (ixgbe_init_eeprom_params_generic(hw)) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3891 | dev_err(&pdev->dev, "EEPROM initialization failed\n"); |
| 3892 | return -EIO; |
| 3893 | } |
| 3894 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3895 | /* enable rx csum by default */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3896 | adapter->flags |= IXGBE_FLAG_RX_CSUM_ENABLED; |
| 3897 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3898 | set_bit(__IXGBE_DOWN, &adapter->state); |
| 3899 | |
| 3900 | return 0; |
| 3901 | } |
| 3902 | |
| 3903 | /** |
| 3904 | * ixgbe_setup_tx_resources - allocate Tx resources (Descriptors) |
| 3905 | * @adapter: board private structure |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3906 | * @tx_ring: tx descriptor ring (for a specific queue) to setup |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3907 | * |
| 3908 | * Return 0 on success, negative on failure |
| 3909 | **/ |
| 3910 | int ixgbe_setup_tx_resources(struct ixgbe_adapter *adapter, |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 3911 | struct ixgbe_ring *tx_ring) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3912 | { |
| 3913 | struct pci_dev *pdev = adapter->pdev; |
| 3914 | int size; |
| 3915 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3916 | size = sizeof(struct ixgbe_tx_buffer) * tx_ring->count; |
| 3917 | tx_ring->tx_buffer_info = vmalloc(size); |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 3918 | if (!tx_ring->tx_buffer_info) |
| 3919 | goto err; |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3920 | memset(tx_ring->tx_buffer_info, 0, size); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3921 | |
| 3922 | /* round up to nearest 4K */ |
Peter P Waskiewicz Jr | 12207e4 | 2009-02-06 21:47:24 -0800 | [diff] [blame] | 3923 | tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3924 | tx_ring->size = ALIGN(tx_ring->size, 4096); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3925 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3926 | tx_ring->desc = pci_alloc_consistent(pdev, tx_ring->size, |
| 3927 | &tx_ring->dma); |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 3928 | if (!tx_ring->desc) |
| 3929 | goto err; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3930 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3931 | tx_ring->next_to_use = 0; |
| 3932 | tx_ring->next_to_clean = 0; |
| 3933 | tx_ring->work_limit = tx_ring->count; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3934 | return 0; |
Jesse Brandeburg | e01c31a | 2008-08-26 04:27:13 -0700 | [diff] [blame] | 3935 | |
| 3936 | err: |
| 3937 | vfree(tx_ring->tx_buffer_info); |
| 3938 | tx_ring->tx_buffer_info = NULL; |
| 3939 | DPRINTK(PROBE, ERR, "Unable to allocate memory for the transmit " |
| 3940 | "descriptor ring\n"); |
| 3941 | return -ENOMEM; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3942 | } |
| 3943 | |
| 3944 | /** |
Alexander Duyck | 6988867 | 2008-09-11 20:05:39 -0700 | [diff] [blame] | 3945 | * ixgbe_setup_all_tx_resources - allocate all queues Tx resources |
| 3946 | * @adapter: board private structure |
| 3947 | * |
| 3948 | * If this function returns with an error, then it's possible one or |
| 3949 | * more of the rings is populated (while the rest are not). It is the |
| 3950 | * callers duty to clean those orphaned rings. |
| 3951 | * |
| 3952 | * Return 0 on success, negative on failure |
| 3953 | **/ |
| 3954 | static int ixgbe_setup_all_tx_resources(struct ixgbe_adapter *adapter) |
| 3955 | { |
| 3956 | int i, err = 0; |
| 3957 | |
| 3958 | for (i = 0; i < adapter->num_tx_queues; i++) { |
| 3959 | err = ixgbe_setup_tx_resources(adapter, &adapter->tx_ring[i]); |
| 3960 | if (!err) |
| 3961 | continue; |
| 3962 | DPRINTK(PROBE, ERR, "Allocation for Tx Queue %u failed\n", i); |
| 3963 | break; |
| 3964 | } |
| 3965 | |
| 3966 | return err; |
| 3967 | } |
| 3968 | |
| 3969 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3970 | * ixgbe_setup_rx_resources - allocate Rx resources (Descriptors) |
| 3971 | * @adapter: board private structure |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3972 | * @rx_ring: rx descriptor ring (for a specific queue) to setup |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3973 | * |
| 3974 | * Returns 0 on success, negative on failure |
| 3975 | **/ |
| 3976 | int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3977 | struct ixgbe_ring *rx_ring) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3978 | { |
| 3979 | struct pci_dev *pdev = adapter->pdev; |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 3980 | int size; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3981 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3982 | size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; |
| 3983 | rx_ring->rx_buffer_info = vmalloc(size); |
| 3984 | if (!rx_ring->rx_buffer_info) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3985 | DPRINTK(PROBE, ERR, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3986 | "vmalloc allocation failed for the rx desc ring\n"); |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 3987 | goto alloc_failed; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3988 | } |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3989 | memset(rx_ring->rx_buffer_info, 0, size); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3990 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3991 | /* Round up to nearest 4K */ |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3992 | rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc); |
| 3993 | rx_ring->size = ALIGN(rx_ring->size, 4096); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3994 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3995 | rx_ring->desc = pci_alloc_consistent(pdev, rx_ring->size, &rx_ring->dma); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3996 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 3997 | if (!rx_ring->desc) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 3998 | DPRINTK(PROBE, ERR, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 3999 | "Memory allocation failed for the rx desc ring\n"); |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 4000 | vfree(rx_ring->rx_buffer_info); |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 4001 | goto alloc_failed; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4002 | } |
| 4003 | |
Jesse Brandeburg | 3a58107 | 2008-08-26 04:27:08 -0700 | [diff] [blame] | 4004 | rx_ring->next_to_clean = 0; |
| 4005 | rx_ring->next_to_use = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4006 | |
| 4007 | return 0; |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 4008 | |
| 4009 | alloc_failed: |
Mallikarjuna R Chilakala | 177db6f | 2008-06-18 15:32:19 -0700 | [diff] [blame] | 4010 | return -ENOMEM; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4011 | } |
| 4012 | |
| 4013 | /** |
Alexander Duyck | 6988867 | 2008-09-11 20:05:39 -0700 | [diff] [blame] | 4014 | * ixgbe_setup_all_rx_resources - allocate all queues Rx resources |
| 4015 | * @adapter: board private structure |
| 4016 | * |
| 4017 | * If this function returns with an error, then it's possible one or |
| 4018 | * more of the rings is populated (while the rest are not). It is the |
| 4019 | * callers duty to clean those orphaned rings. |
| 4020 | * |
| 4021 | * Return 0 on success, negative on failure |
| 4022 | **/ |
| 4023 | |
| 4024 | static int ixgbe_setup_all_rx_resources(struct ixgbe_adapter *adapter) |
| 4025 | { |
| 4026 | int i, err = 0; |
| 4027 | |
| 4028 | for (i = 0; i < adapter->num_rx_queues; i++) { |
| 4029 | err = ixgbe_setup_rx_resources(adapter, &adapter->rx_ring[i]); |
| 4030 | if (!err) |
| 4031 | continue; |
| 4032 | DPRINTK(PROBE, ERR, "Allocation for Rx Queue %u failed\n", i); |
| 4033 | break; |
| 4034 | } |
| 4035 | |
| 4036 | return err; |
| 4037 | } |
| 4038 | |
| 4039 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4040 | * ixgbe_free_tx_resources - Free Tx Resources per Queue |
| 4041 | * @adapter: board private structure |
| 4042 | * @tx_ring: Tx descriptor ring for a specific queue |
| 4043 | * |
| 4044 | * Free all transmit software resources |
| 4045 | **/ |
Jesse Brandeburg | c431f97 | 2008-09-11 19:59:16 -0700 | [diff] [blame] | 4046 | void ixgbe_free_tx_resources(struct ixgbe_adapter *adapter, |
| 4047 | struct ixgbe_ring *tx_ring) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4048 | { |
| 4049 | struct pci_dev *pdev = adapter->pdev; |
| 4050 | |
| 4051 | ixgbe_clean_tx_ring(adapter, tx_ring); |
| 4052 | |
| 4053 | vfree(tx_ring->tx_buffer_info); |
| 4054 | tx_ring->tx_buffer_info = NULL; |
| 4055 | |
| 4056 | pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma); |
| 4057 | |
| 4058 | tx_ring->desc = NULL; |
| 4059 | } |
| 4060 | |
| 4061 | /** |
| 4062 | * ixgbe_free_all_tx_resources - Free Tx Resources for All Queues |
| 4063 | * @adapter: board private structure |
| 4064 | * |
| 4065 | * Free all transmit software resources |
| 4066 | **/ |
| 4067 | static void ixgbe_free_all_tx_resources(struct ixgbe_adapter *adapter) |
| 4068 | { |
| 4069 | int i; |
| 4070 | |
| 4071 | for (i = 0; i < adapter->num_tx_queues; i++) |
Jesse Brandeburg | 9891ca7 | 2009-03-13 22:14:50 +0000 | [diff] [blame] | 4072 | if (adapter->tx_ring[i].desc) |
| 4073 | ixgbe_free_tx_resources(adapter, &adapter->tx_ring[i]); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4074 | } |
| 4075 | |
| 4076 | /** |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4077 | * ixgbe_free_rx_resources - Free Rx Resources |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4078 | * @adapter: board private structure |
| 4079 | * @rx_ring: ring to clean the resources from |
| 4080 | * |
| 4081 | * Free all receive software resources |
| 4082 | **/ |
Jesse Brandeburg | c431f97 | 2008-09-11 19:59:16 -0700 | [diff] [blame] | 4083 | void ixgbe_free_rx_resources(struct ixgbe_adapter *adapter, |
| 4084 | struct ixgbe_ring *rx_ring) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4085 | { |
| 4086 | struct pci_dev *pdev = adapter->pdev; |
| 4087 | |
| 4088 | ixgbe_clean_rx_ring(adapter, rx_ring); |
| 4089 | |
| 4090 | vfree(rx_ring->rx_buffer_info); |
| 4091 | rx_ring->rx_buffer_info = NULL; |
| 4092 | |
| 4093 | pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma); |
| 4094 | |
| 4095 | rx_ring->desc = NULL; |
| 4096 | } |
| 4097 | |
| 4098 | /** |
| 4099 | * ixgbe_free_all_rx_resources - Free Rx Resources for All Queues |
| 4100 | * @adapter: board private structure |
| 4101 | * |
| 4102 | * Free all receive software resources |
| 4103 | **/ |
| 4104 | static void ixgbe_free_all_rx_resources(struct ixgbe_adapter *adapter) |
| 4105 | { |
| 4106 | int i; |
| 4107 | |
| 4108 | for (i = 0; i < adapter->num_rx_queues; i++) |
Jesse Brandeburg | 9891ca7 | 2009-03-13 22:14:50 +0000 | [diff] [blame] | 4109 | if (adapter->rx_ring[i].desc) |
| 4110 | ixgbe_free_rx_resources(adapter, &adapter->rx_ring[i]); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4111 | } |
| 4112 | |
| 4113 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4114 | * ixgbe_change_mtu - Change the Maximum Transfer Unit |
| 4115 | * @netdev: network interface device structure |
| 4116 | * @new_mtu: new value for maximum frame size |
| 4117 | * |
| 4118 | * Returns 0 on success, negative on failure |
| 4119 | **/ |
| 4120 | static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu) |
| 4121 | { |
| 4122 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 4123 | int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; |
| 4124 | |
Jesse Brandeburg | 42c783c | 2008-09-11 19:56:28 -0700 | [diff] [blame] | 4125 | /* MTU < 68 is an error and causes problems on some kernels */ |
| 4126 | if ((new_mtu < 68) || (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE)) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4127 | return -EINVAL; |
| 4128 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 4129 | DPRINTK(PROBE, INFO, "changing MTU from %d to %d\n", |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4130 | netdev->mtu, new_mtu); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 4131 | /* must set new MTU before calling down or up */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4132 | netdev->mtu = new_mtu; |
| 4133 | |
Ayyappan Veeraiyan | d4f8088 | 2008-02-01 15:58:41 -0800 | [diff] [blame] | 4134 | if (netif_running(netdev)) |
| 4135 | ixgbe_reinit_locked(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4136 | |
| 4137 | return 0; |
| 4138 | } |
| 4139 | |
| 4140 | /** |
| 4141 | * ixgbe_open - Called when a network interface is made active |
| 4142 | * @netdev: network interface device structure |
| 4143 | * |
| 4144 | * Returns 0 on success, negative value on failure |
| 4145 | * |
| 4146 | * The open entry point is called when a network interface is made |
| 4147 | * active by the system (IFF_UP). At this point all resources needed |
| 4148 | * for transmit and receive operations are allocated, the interrupt |
| 4149 | * handler is registered with the OS, the watchdog timer is started, |
| 4150 | * and the stack is notified that the interface is ready. |
| 4151 | **/ |
| 4152 | static int ixgbe_open(struct net_device *netdev) |
| 4153 | { |
| 4154 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 4155 | int err; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4156 | |
Auke Kok | 4bebfaa | 2008-02-11 09:26:01 -0800 | [diff] [blame] | 4157 | /* disallow open during test */ |
| 4158 | if (test_bit(__IXGBE_TESTING, &adapter->state)) |
| 4159 | return -EBUSY; |
| 4160 | |
Jesse Brandeburg | 5438646 | 2009-04-17 20:44:27 +0000 | [diff] [blame] | 4161 | netif_carrier_off(netdev); |
| 4162 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4163 | /* allocate transmit descriptors */ |
| 4164 | err = ixgbe_setup_all_tx_resources(adapter); |
| 4165 | if (err) |
| 4166 | goto err_setup_tx; |
| 4167 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4168 | /* allocate receive descriptors */ |
| 4169 | err = ixgbe_setup_all_rx_resources(adapter); |
| 4170 | if (err) |
| 4171 | goto err_setup_rx; |
| 4172 | |
| 4173 | ixgbe_configure(adapter); |
| 4174 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 4175 | err = ixgbe_request_irq(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4176 | if (err) |
| 4177 | goto err_req_irq; |
| 4178 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4179 | err = ixgbe_up_complete(adapter); |
| 4180 | if (err) |
| 4181 | goto err_up; |
| 4182 | |
Jeff Kirsher | d55b53f | 2008-07-18 04:33:03 -0700 | [diff] [blame] | 4183 | netif_tx_start_all_queues(netdev); |
| 4184 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4185 | return 0; |
| 4186 | |
| 4187 | err_up: |
Ayyappan Veeraiyan | 5eba369 | 2008-02-01 15:59:04 -0800 | [diff] [blame] | 4188 | ixgbe_release_hw_control(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4189 | ixgbe_free_irq(adapter); |
| 4190 | err_req_irq: |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4191 | err_setup_rx: |
Mallikarjuna R Chilakala | a20a119 | 2009-03-31 21:34:44 +0000 | [diff] [blame] | 4192 | ixgbe_free_all_rx_resources(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4193 | err_setup_tx: |
Mallikarjuna R Chilakala | a20a119 | 2009-03-31 21:34:44 +0000 | [diff] [blame] | 4194 | ixgbe_free_all_tx_resources(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4195 | ixgbe_reset(adapter); |
| 4196 | |
| 4197 | return err; |
| 4198 | } |
| 4199 | |
| 4200 | /** |
| 4201 | * ixgbe_close - Disables a network interface |
| 4202 | * @netdev: network interface device structure |
| 4203 | * |
| 4204 | * Returns 0, this is not allowed to fail |
| 4205 | * |
| 4206 | * The close entry point is called when an interface is de-activated |
| 4207 | * by the OS. The hardware is still under the drivers control, but |
| 4208 | * needs to be disabled. A global MAC reset is issued to stop the |
| 4209 | * hardware, and all transmit and receive resources are freed. |
| 4210 | **/ |
| 4211 | static int ixgbe_close(struct net_device *netdev) |
| 4212 | { |
| 4213 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4214 | |
| 4215 | ixgbe_down(adapter); |
| 4216 | ixgbe_free_irq(adapter); |
| 4217 | |
| 4218 | ixgbe_free_all_tx_resources(adapter); |
| 4219 | ixgbe_free_all_rx_resources(adapter); |
| 4220 | |
Ayyappan Veeraiyan | 5eba369 | 2008-02-01 15:59:04 -0800 | [diff] [blame] | 4221 | ixgbe_release_hw_control(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4222 | |
| 4223 | return 0; |
| 4224 | } |
| 4225 | |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4226 | #ifdef CONFIG_PM |
| 4227 | static int ixgbe_resume(struct pci_dev *pdev) |
| 4228 | { |
| 4229 | struct net_device *netdev = pci_get_drvdata(pdev); |
| 4230 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 4231 | u32 err; |
| 4232 | |
| 4233 | pci_set_power_state(pdev, PCI_D0); |
| 4234 | pci_restore_state(pdev); |
gouji-new | 9ce7766 | 2009-05-06 10:44:45 +0000 | [diff] [blame] | 4235 | |
| 4236 | err = pci_enable_device_mem(pdev); |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4237 | if (err) { |
Alexander Duyck | 6988867 | 2008-09-11 20:05:39 -0700 | [diff] [blame] | 4238 | printk(KERN_ERR "ixgbe: Cannot enable PCI device from " |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4239 | "suspend\n"); |
| 4240 | return err; |
| 4241 | } |
| 4242 | pci_set_master(pdev); |
| 4243 | |
Don Skidmore | dd4d8ca | 2009-04-29 00:22:31 -0700 | [diff] [blame] | 4244 | pci_wake_from_d3(pdev, false); |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4245 | |
| 4246 | err = ixgbe_init_interrupt_scheme(adapter); |
| 4247 | if (err) { |
| 4248 | printk(KERN_ERR "ixgbe: Cannot initialize interrupts for " |
| 4249 | "device\n"); |
| 4250 | return err; |
| 4251 | } |
| 4252 | |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4253 | ixgbe_reset(adapter); |
| 4254 | |
Waskiewicz Jr, Peter P | 495dce1 | 2009-04-23 11:15:18 +0000 | [diff] [blame] | 4255 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); |
| 4256 | |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4257 | if (netif_running(netdev)) { |
| 4258 | err = ixgbe_open(adapter->netdev); |
| 4259 | if (err) |
| 4260 | return err; |
| 4261 | } |
| 4262 | |
| 4263 | netif_device_attach(netdev); |
| 4264 | |
| 4265 | return 0; |
| 4266 | } |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4267 | #endif /* CONFIG_PM */ |
Rafael J. Wysocki | 9d8d05a | 2009-04-15 17:44:01 +0000 | [diff] [blame] | 4268 | |
| 4269 | static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake) |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4270 | { |
| 4271 | struct net_device *netdev = pci_get_drvdata(pdev); |
| 4272 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4273 | struct ixgbe_hw *hw = &adapter->hw; |
| 4274 | u32 ctrl, fctrl; |
| 4275 | u32 wufc = adapter->wol; |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4276 | #ifdef CONFIG_PM |
| 4277 | int retval = 0; |
| 4278 | #endif |
| 4279 | |
| 4280 | netif_device_detach(netdev); |
| 4281 | |
| 4282 | if (netif_running(netdev)) { |
| 4283 | ixgbe_down(adapter); |
| 4284 | ixgbe_free_irq(adapter); |
| 4285 | ixgbe_free_all_tx_resources(adapter); |
| 4286 | ixgbe_free_all_rx_resources(adapter); |
| 4287 | } |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 4288 | ixgbe_clear_interrupt_scheme(adapter); |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4289 | |
| 4290 | #ifdef CONFIG_PM |
| 4291 | retval = pci_save_state(pdev); |
| 4292 | if (retval) |
| 4293 | return retval; |
Jesse Brandeburg | 4df1046 | 2009-03-13 22:15:31 +0000 | [diff] [blame] | 4294 | |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4295 | #endif |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4296 | if (wufc) { |
| 4297 | ixgbe_set_rx_mode(netdev); |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4298 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4299 | /* turn on all-multi mode if wake on multicast is enabled */ |
| 4300 | if (wufc & IXGBE_WUFC_MC) { |
| 4301 | fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL); |
| 4302 | fctrl |= IXGBE_FCTRL_MPE; |
| 4303 | IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl); |
| 4304 | } |
| 4305 | |
| 4306 | ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); |
| 4307 | ctrl |= IXGBE_CTRL_GIO_DIS; |
| 4308 | IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl); |
| 4309 | |
| 4310 | IXGBE_WRITE_REG(hw, IXGBE_WUFC, wufc); |
| 4311 | } else { |
| 4312 | IXGBE_WRITE_REG(hw, IXGBE_WUC, 0); |
| 4313 | IXGBE_WRITE_REG(hw, IXGBE_WUFC, 0); |
| 4314 | } |
| 4315 | |
Don Skidmore | dd4d8ca | 2009-04-29 00:22:31 -0700 | [diff] [blame] | 4316 | if (wufc && hw->mac.type == ixgbe_mac_82599EB) |
| 4317 | pci_wake_from_d3(pdev, true); |
| 4318 | else |
| 4319 | pci_wake_from_d3(pdev, false); |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4320 | |
Rafael J. Wysocki | 9d8d05a | 2009-04-15 17:44:01 +0000 | [diff] [blame] | 4321 | *enable_wake = !!wufc; |
| 4322 | |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4323 | ixgbe_release_hw_control(adapter); |
| 4324 | |
| 4325 | pci_disable_device(pdev); |
| 4326 | |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4327 | return 0; |
| 4328 | } |
| 4329 | |
Rafael J. Wysocki | 9d8d05a | 2009-04-15 17:44:01 +0000 | [diff] [blame] | 4330 | #ifdef CONFIG_PM |
| 4331 | static int ixgbe_suspend(struct pci_dev *pdev, pm_message_t state) |
| 4332 | { |
| 4333 | int retval; |
| 4334 | bool wake; |
| 4335 | |
| 4336 | retval = __ixgbe_shutdown(pdev, &wake); |
| 4337 | if (retval) |
| 4338 | return retval; |
| 4339 | |
| 4340 | if (wake) { |
| 4341 | pci_prepare_to_sleep(pdev); |
| 4342 | } else { |
| 4343 | pci_wake_from_d3(pdev, false); |
| 4344 | pci_set_power_state(pdev, PCI_D3hot); |
| 4345 | } |
| 4346 | |
| 4347 | return 0; |
| 4348 | } |
| 4349 | #endif /* CONFIG_PM */ |
| 4350 | |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4351 | static void ixgbe_shutdown(struct pci_dev *pdev) |
| 4352 | { |
Rafael J. Wysocki | 9d8d05a | 2009-04-15 17:44:01 +0000 | [diff] [blame] | 4353 | bool wake; |
| 4354 | |
| 4355 | __ixgbe_shutdown(pdev, &wake); |
| 4356 | |
| 4357 | if (system_state == SYSTEM_POWER_OFF) { |
| 4358 | pci_wake_from_d3(pdev, wake); |
| 4359 | pci_set_power_state(pdev, PCI_D3hot); |
| 4360 | } |
Alexander Duyck | b3c8b4b | 2008-09-11 20:04:56 -0700 | [diff] [blame] | 4361 | } |
| 4362 | |
| 4363 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4364 | * ixgbe_update_stats - Update the board statistics counters. |
| 4365 | * @adapter: board private structure |
| 4366 | **/ |
| 4367 | void ixgbe_update_stats(struct ixgbe_adapter *adapter) |
| 4368 | { |
| 4369 | struct ixgbe_hw *hw = &adapter->hw; |
Ayyappan Veeraiyan | 6f11eef | 2008-02-01 15:59:14 -0800 | [diff] [blame] | 4370 | u64 total_mpc = 0; |
| 4371 | u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4372 | |
PJ Waskiewicz | d51019a | 2009-03-13 22:12:48 +0000 | [diff] [blame] | 4373 | if (hw->mac.type == ixgbe_mac_82599EB) { |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 4374 | u64 rsc_count = 0; |
PJ Waskiewicz | d51019a | 2009-03-13 22:12:48 +0000 | [diff] [blame] | 4375 | for (i = 0; i < 16; i++) |
| 4376 | adapter->hw_rx_no_dma_resources += |
| 4377 | IXGBE_READ_REG(hw, IXGBE_QPRDC(i)); |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 4378 | for (i = 0; i < adapter->num_rx_queues; i++) |
| 4379 | rsc_count += adapter->rx_ring[i].rsc_count; |
| 4380 | adapter->rsc_count = rsc_count; |
PJ Waskiewicz | d51019a | 2009-03-13 22:12:48 +0000 | [diff] [blame] | 4381 | } |
| 4382 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4383 | adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS); |
Ayyappan Veeraiyan | 6f11eef | 2008-02-01 15:59:14 -0800 | [diff] [blame] | 4384 | for (i = 0; i < 8; i++) { |
| 4385 | /* for packet buffers not used, the register should read 0 */ |
| 4386 | mpc = IXGBE_READ_REG(hw, IXGBE_MPC(i)); |
| 4387 | missed_rx += mpc; |
| 4388 | adapter->stats.mpc[i] += mpc; |
| 4389 | total_mpc += adapter->stats.mpc[i]; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4390 | if (hw->mac.type == ixgbe_mac_82598EB) |
| 4391 | adapter->stats.rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i)); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 4392 | adapter->stats.qptc[i] += IXGBE_READ_REG(hw, IXGBE_QPTC(i)); |
| 4393 | adapter->stats.qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC(i)); |
| 4394 | adapter->stats.qprc[i] += IXGBE_READ_REG(hw, IXGBE_QPRC(i)); |
| 4395 | adapter->stats.qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC(i)); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4396 | if (hw->mac.type == ixgbe_mac_82599EB) { |
| 4397 | adapter->stats.pxonrxc[i] += IXGBE_READ_REG(hw, |
| 4398 | IXGBE_PXONRXCNT(i)); |
| 4399 | adapter->stats.pxoffrxc[i] += IXGBE_READ_REG(hw, |
| 4400 | IXGBE_PXOFFRXCNT(i)); |
| 4401 | adapter->stats.qprdc[i] += IXGBE_READ_REG(hw, IXGBE_QPRDC(i)); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4402 | } else { |
| 4403 | adapter->stats.pxonrxc[i] += IXGBE_READ_REG(hw, |
| 4404 | IXGBE_PXONRXC(i)); |
| 4405 | adapter->stats.pxoffrxc[i] += IXGBE_READ_REG(hw, |
| 4406 | IXGBE_PXOFFRXC(i)); |
| 4407 | } |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 4408 | adapter->stats.pxontxc[i] += IXGBE_READ_REG(hw, |
| 4409 | IXGBE_PXONTXC(i)); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 4410 | adapter->stats.pxofftxc[i] += IXGBE_READ_REG(hw, |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4411 | IXGBE_PXOFFTXC(i)); |
Ayyappan Veeraiyan | 6f11eef | 2008-02-01 15:59:14 -0800 | [diff] [blame] | 4412 | } |
| 4413 | adapter->stats.gprc += IXGBE_READ_REG(hw, IXGBE_GPRC); |
| 4414 | /* work around hardware counting issue */ |
| 4415 | adapter->stats.gprc -= missed_rx; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4416 | |
Ayyappan Veeraiyan | 6f11eef | 2008-02-01 15:59:14 -0800 | [diff] [blame] | 4417 | /* 82598 hardware only has a 32 bit counter in the high register */ |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4418 | if (hw->mac.type == ixgbe_mac_82599EB) { |
| 4419 | adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GORCL); |
| 4420 | IXGBE_READ_REG(hw, IXGBE_GORCH); /* to clear */ |
| 4421 | adapter->stats.gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL); |
| 4422 | IXGBE_READ_REG(hw, IXGBE_GOTCH); /* to clear */ |
| 4423 | adapter->stats.tor += IXGBE_READ_REG(hw, IXGBE_TORL); |
| 4424 | IXGBE_READ_REG(hw, IXGBE_TORH); /* to clear */ |
| 4425 | adapter->stats.lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT); |
| 4426 | adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT); |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 4427 | adapter->stats.fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH); |
| 4428 | adapter->stats.fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS); |
Yi Zou | 6d45522 | 2009-05-13 13:12:16 +0000 | [diff] [blame] | 4429 | #ifdef IXGBE_FCOE |
| 4430 | adapter->stats.fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC); |
| 4431 | adapter->stats.fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC); |
| 4432 | adapter->stats.fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC); |
| 4433 | adapter->stats.fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC); |
| 4434 | adapter->stats.fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC); |
| 4435 | adapter->stats.fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC); |
| 4436 | #endif /* IXGBE_FCOE */ |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4437 | } else { |
| 4438 | adapter->stats.lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC); |
| 4439 | adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC); |
| 4440 | adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GORCH); |
| 4441 | adapter->stats.gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH); |
| 4442 | adapter->stats.tor += IXGBE_READ_REG(hw, IXGBE_TORH); |
| 4443 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4444 | bprc = IXGBE_READ_REG(hw, IXGBE_BPRC); |
| 4445 | adapter->stats.bprc += bprc; |
| 4446 | adapter->stats.mprc += IXGBE_READ_REG(hw, IXGBE_MPRC); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4447 | if (hw->mac.type == ixgbe_mac_82598EB) |
| 4448 | adapter->stats.mprc -= bprc; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4449 | adapter->stats.roc += IXGBE_READ_REG(hw, IXGBE_ROC); |
| 4450 | adapter->stats.prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64); |
| 4451 | adapter->stats.prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127); |
| 4452 | adapter->stats.prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255); |
| 4453 | adapter->stats.prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511); |
| 4454 | adapter->stats.prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023); |
| 4455 | adapter->stats.prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4456 | adapter->stats.rlec += IXGBE_READ_REG(hw, IXGBE_RLEC); |
Ayyappan Veeraiyan | 6f11eef | 2008-02-01 15:59:14 -0800 | [diff] [blame] | 4457 | lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC); |
| 4458 | adapter->stats.lxontxc += lxon; |
| 4459 | lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC); |
| 4460 | adapter->stats.lxofftxc += lxoff; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4461 | adapter->stats.ruc += IXGBE_READ_REG(hw, IXGBE_RUC); |
| 4462 | adapter->stats.gptc += IXGBE_READ_REG(hw, IXGBE_GPTC); |
Ayyappan Veeraiyan | 6f11eef | 2008-02-01 15:59:14 -0800 | [diff] [blame] | 4463 | adapter->stats.mptc += IXGBE_READ_REG(hw, IXGBE_MPTC); |
| 4464 | /* |
| 4465 | * 82598 errata - tx of flow control packets is included in tx counters |
| 4466 | */ |
| 4467 | xon_off_tot = lxon + lxoff; |
| 4468 | adapter->stats.gptc -= xon_off_tot; |
| 4469 | adapter->stats.mptc -= xon_off_tot; |
| 4470 | adapter->stats.gotc -= (xon_off_tot * (ETH_ZLEN + ETH_FCS_LEN)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4471 | adapter->stats.ruc += IXGBE_READ_REG(hw, IXGBE_RUC); |
| 4472 | adapter->stats.rfc += IXGBE_READ_REG(hw, IXGBE_RFC); |
| 4473 | adapter->stats.rjc += IXGBE_READ_REG(hw, IXGBE_RJC); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4474 | adapter->stats.tpr += IXGBE_READ_REG(hw, IXGBE_TPR); |
| 4475 | adapter->stats.ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64); |
Ayyappan Veeraiyan | 6f11eef | 2008-02-01 15:59:14 -0800 | [diff] [blame] | 4476 | adapter->stats.ptc64 -= xon_off_tot; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4477 | adapter->stats.ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127); |
| 4478 | adapter->stats.ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255); |
| 4479 | adapter->stats.ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511); |
| 4480 | adapter->stats.ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023); |
| 4481 | adapter->stats.ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4482 | adapter->stats.bptc += IXGBE_READ_REG(hw, IXGBE_BPTC); |
| 4483 | |
| 4484 | /* Fill out the OS statistics structure */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4485 | adapter->net_stats.multicast = adapter->stats.mprc; |
| 4486 | |
| 4487 | /* Rx Errors */ |
| 4488 | adapter->net_stats.rx_errors = adapter->stats.crcerrs + |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4489 | adapter->stats.rlec; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4490 | adapter->net_stats.rx_dropped = 0; |
| 4491 | adapter->net_stats.rx_length_errors = adapter->stats.rlec; |
| 4492 | adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs; |
Ayyappan Veeraiyan | 6f11eef | 2008-02-01 15:59:14 -0800 | [diff] [blame] | 4493 | adapter->net_stats.rx_missed_errors = total_mpc; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4494 | } |
| 4495 | |
| 4496 | /** |
| 4497 | * ixgbe_watchdog - Timer Call-back |
| 4498 | * @data: pointer to adapter cast into an unsigned long |
| 4499 | **/ |
| 4500 | static void ixgbe_watchdog(unsigned long data) |
| 4501 | { |
| 4502 | struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)data; |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4503 | struct ixgbe_hw *hw = &adapter->hw; |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 4504 | u64 eics = 0; |
| 4505 | int i; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4506 | |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 4507 | /* |
| 4508 | * Do the watchdog outside of interrupt context due to the lovely |
| 4509 | * delays that some of the newer hardware requires |
| 4510 | */ |
Jesse Brandeburg | 22d5a71 | 2009-03-19 01:24:04 +0000 | [diff] [blame] | 4511 | |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 4512 | if (test_bit(__IXGBE_DOWN, &adapter->state)) |
| 4513 | goto watchdog_short_circuit; |
Jesse Brandeburg | 22d5a71 | 2009-03-19 01:24:04 +0000 | [diff] [blame] | 4514 | |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 4515 | if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { |
| 4516 | /* |
| 4517 | * for legacy and MSI interrupts don't set any bits |
| 4518 | * that are enabled for EIAM, because this operation |
| 4519 | * would set *both* EIMS and EICS for any bit in EIAM |
| 4520 | */ |
| 4521 | IXGBE_WRITE_REG(hw, IXGBE_EICS, |
| 4522 | (IXGBE_EICS_TCP_TIMER | IXGBE_EICS_OTHER)); |
| 4523 | goto watchdog_reschedule; |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4524 | } |
| 4525 | |
Alexander Duyck | fe49f04 | 2009-06-04 16:00:09 +0000 | [diff] [blame] | 4526 | /* get one bit for every active tx/rx interrupt vector */ |
| 4527 | for (i = 0; i < adapter->num_msix_vectors - NON_Q_VECTORS; i++) { |
| 4528 | struct ixgbe_q_vector *qv = adapter->q_vector[i]; |
| 4529 | if (qv->rxr_count || qv->txr_count) |
| 4530 | eics |= ((u64)1 << i); |
| 4531 | } |
| 4532 | |
| 4533 | /* Cause software interrupt to ensure rx rings are cleaned */ |
| 4534 | ixgbe_irq_rearm_queues(adapter, eics); |
| 4535 | |
| 4536 | watchdog_reschedule: |
| 4537 | /* Reset the timer */ |
| 4538 | mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ)); |
| 4539 | |
| 4540 | watchdog_short_circuit: |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4541 | schedule_work(&adapter->watchdog_task); |
| 4542 | } |
| 4543 | |
| 4544 | /** |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4545 | * ixgbe_multispeed_fiber_task - worker thread to configure multispeed fiber |
| 4546 | * @work: pointer to work_struct containing our data |
| 4547 | **/ |
| 4548 | static void ixgbe_multispeed_fiber_task(struct work_struct *work) |
| 4549 | { |
| 4550 | struct ixgbe_adapter *adapter = container_of(work, |
| 4551 | struct ixgbe_adapter, |
| 4552 | multispeed_fiber_task); |
| 4553 | struct ixgbe_hw *hw = &adapter->hw; |
| 4554 | u32 autoneg; |
Mallikarjuna R Chilakala | 8620a10 | 2009-09-01 13:49:35 +0000 | [diff] [blame] | 4555 | bool negotiation; |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4556 | |
| 4557 | adapter->flags |= IXGBE_FLAG_IN_SFP_LINK_TASK; |
Mallikarjuna R Chilakala | a1f2532 | 2009-06-30 11:44:36 +0000 | [diff] [blame] | 4558 | autoneg = hw->phy.autoneg_advertised; |
| 4559 | if ((!autoneg) && (hw->mac.ops.get_link_capabilities)) |
Mallikarjuna R Chilakala | 8620a10 | 2009-09-01 13:49:35 +0000 | [diff] [blame] | 4560 | hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation); |
| 4561 | if (hw->mac.ops.setup_link) |
| 4562 | hw->mac.ops.setup_link(hw, autoneg, negotiation, true); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4563 | adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; |
| 4564 | adapter->flags &= ~IXGBE_FLAG_IN_SFP_LINK_TASK; |
| 4565 | } |
| 4566 | |
| 4567 | /** |
| 4568 | * ixgbe_sfp_config_module_task - worker thread to configure a new SFP+ module |
| 4569 | * @work: pointer to work_struct containing our data |
| 4570 | **/ |
| 4571 | static void ixgbe_sfp_config_module_task(struct work_struct *work) |
| 4572 | { |
| 4573 | struct ixgbe_adapter *adapter = container_of(work, |
| 4574 | struct ixgbe_adapter, |
| 4575 | sfp_config_module_task); |
| 4576 | struct ixgbe_hw *hw = &adapter->hw; |
| 4577 | u32 err; |
| 4578 | |
| 4579 | adapter->flags |= IXGBE_FLAG_IN_SFP_MOD_TASK; |
Don Skidmore | 63d6e1d | 2009-07-02 12:50:12 +0000 | [diff] [blame] | 4580 | |
| 4581 | /* Time for electrical oscillations to settle down */ |
| 4582 | msleep(100); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4583 | err = hw->phy.ops.identify_sfp(hw); |
Don Skidmore | 63d6e1d | 2009-07-02 12:50:12 +0000 | [diff] [blame] | 4584 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4585 | if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { |
Don Skidmore | 88d2b81 | 2009-06-30 11:43:55 +0000 | [diff] [blame] | 4586 | dev_err(&adapter->pdev->dev, "failed to initialize because " |
| 4587 | "an unsupported SFP+ module type was detected.\n" |
| 4588 | "Reload the driver after installing a supported " |
| 4589 | "module.\n"); |
Don Skidmore | 63d6e1d | 2009-07-02 12:50:12 +0000 | [diff] [blame] | 4590 | unregister_netdev(adapter->netdev); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4591 | return; |
| 4592 | } |
| 4593 | hw->mac.ops.setup_sfp(hw); |
| 4594 | |
Tony Breeds | 8d1c3c0 | 2009-04-09 22:29:10 +0000 | [diff] [blame] | 4595 | if (!(adapter->flags & IXGBE_FLAG_IN_SFP_LINK_TASK)) |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4596 | /* This will also work for DA Twinax connections */ |
| 4597 | schedule_work(&adapter->multispeed_fiber_task); |
| 4598 | adapter->flags &= ~IXGBE_FLAG_IN_SFP_MOD_TASK; |
| 4599 | } |
| 4600 | |
| 4601 | /** |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 4602 | * ixgbe_fdir_reinit_task - worker thread to reinit FDIR filter table |
| 4603 | * @work: pointer to work_struct containing our data |
| 4604 | **/ |
| 4605 | static void ixgbe_fdir_reinit_task(struct work_struct *work) |
| 4606 | { |
| 4607 | struct ixgbe_adapter *adapter = container_of(work, |
| 4608 | struct ixgbe_adapter, |
| 4609 | fdir_reinit_task); |
| 4610 | struct ixgbe_hw *hw = &adapter->hw; |
| 4611 | int i; |
| 4612 | |
| 4613 | if (ixgbe_reinit_fdir_tables_82599(hw) == 0) { |
| 4614 | for (i = 0; i < adapter->num_tx_queues; i++) |
| 4615 | set_bit(__IXGBE_FDIR_INIT_DONE, |
| 4616 | &(adapter->tx_ring[i].reinit_state)); |
| 4617 | } else { |
| 4618 | DPRINTK(PROBE, ERR, "failed to finish FDIR re-initialization, " |
| 4619 | "ignored adding FDIR ATR filters \n"); |
| 4620 | } |
| 4621 | /* Done FDIR Re-initialization, enable transmits */ |
| 4622 | netif_tx_start_all_queues(adapter->netdev); |
| 4623 | } |
| 4624 | |
| 4625 | /** |
Alexander Duyck | 6988867 | 2008-09-11 20:05:39 -0700 | [diff] [blame] | 4626 | * ixgbe_watchdog_task - worker thread to bring link up |
| 4627 | * @work: pointer to work_struct containing our data |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4628 | **/ |
| 4629 | static void ixgbe_watchdog_task(struct work_struct *work) |
| 4630 | { |
| 4631 | struct ixgbe_adapter *adapter = container_of(work, |
| 4632 | struct ixgbe_adapter, |
| 4633 | watchdog_task); |
| 4634 | struct net_device *netdev = adapter->netdev; |
| 4635 | struct ixgbe_hw *hw = &adapter->hw; |
| 4636 | u32 link_speed = adapter->link_speed; |
| 4637 | bool link_up = adapter->link_up; |
Nelson, Shannon | bc59fcd | 2009-04-27 22:43:12 +0000 | [diff] [blame] | 4638 | int i; |
| 4639 | struct ixgbe_ring *tx_ring; |
| 4640 | int some_tx_pending = 0; |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4641 | |
| 4642 | adapter->flags |= IXGBE_FLAG_IN_WATCHDOG_TASK; |
| 4643 | |
| 4644 | if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) { |
| 4645 | hw->mac.ops.check_link(hw, &link_speed, &link_up, false); |
Peter P Waskiewicz Jr | 264857b | 2009-05-17 12:35:16 +0000 | [diff] [blame] | 4646 | if (link_up) { |
| 4647 | #ifdef CONFIG_DCB |
| 4648 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
| 4649 | for (i = 0; i < MAX_TRAFFIC_CLASS; i++) |
Mallikarjuna R Chilakala | 620fa03 | 2009-06-04 11:11:13 +0000 | [diff] [blame] | 4650 | hw->mac.ops.fc_enable(hw, i); |
Peter P Waskiewicz Jr | 264857b | 2009-05-17 12:35:16 +0000 | [diff] [blame] | 4651 | } else { |
Mallikarjuna R Chilakala | 620fa03 | 2009-06-04 11:11:13 +0000 | [diff] [blame] | 4652 | hw->mac.ops.fc_enable(hw, 0); |
Peter P Waskiewicz Jr | 264857b | 2009-05-17 12:35:16 +0000 | [diff] [blame] | 4653 | } |
| 4654 | #else |
Mallikarjuna R Chilakala | 620fa03 | 2009-06-04 11:11:13 +0000 | [diff] [blame] | 4655 | hw->mac.ops.fc_enable(hw, 0); |
Peter P Waskiewicz Jr | 264857b | 2009-05-17 12:35:16 +0000 | [diff] [blame] | 4656 | #endif |
| 4657 | } |
| 4658 | |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4659 | if (link_up || |
| 4660 | time_after(jiffies, (adapter->link_check_timeout + |
| 4661 | IXGBE_TRY_LINK_TIMEOUT))) { |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4662 | adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE; |
Peter P Waskiewicz Jr | 264857b | 2009-05-17 12:35:16 +0000 | [diff] [blame] | 4663 | IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMC_LSC); |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4664 | } |
| 4665 | adapter->link_up = link_up; |
| 4666 | adapter->link_speed = link_speed; |
| 4667 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4668 | |
| 4669 | if (link_up) { |
| 4670 | if (!netif_carrier_ok(netdev)) { |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4671 | bool flow_rx, flow_tx; |
| 4672 | |
| 4673 | if (hw->mac.type == ixgbe_mac_82599EB) { |
| 4674 | u32 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN); |
| 4675 | u32 fccfg = IXGBE_READ_REG(hw, IXGBE_FCCFG); |
Peter P Waskiewicz Jr | 078788b | 2009-07-16 15:50:32 +0000 | [diff] [blame] | 4676 | flow_rx = !!(mflcn & IXGBE_MFLCN_RFCE); |
| 4677 | flow_tx = !!(fccfg & IXGBE_FCCFG_TFCE_802_3X); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4678 | } else { |
| 4679 | u32 frctl = IXGBE_READ_REG(hw, IXGBE_FCTRL); |
| 4680 | u32 rmcs = IXGBE_READ_REG(hw, IXGBE_RMCS); |
Peter P Waskiewicz Jr | 078788b | 2009-07-16 15:50:32 +0000 | [diff] [blame] | 4681 | flow_rx = !!(frctl & IXGBE_FCTRL_RFCE); |
| 4682 | flow_tx = !!(rmcs & IXGBE_RMCS_TFCE_802_3X); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4683 | } |
| 4684 | |
Jeff Kirsher | a46e534 | 2008-11-27 00:22:21 -0800 | [diff] [blame] | 4685 | printk(KERN_INFO "ixgbe: %s NIC Link is Up %s, " |
| 4686 | "Flow Control: %s\n", |
| 4687 | netdev->name, |
| 4688 | (link_speed == IXGBE_LINK_SPEED_10GB_FULL ? |
| 4689 | "10 Gbps" : |
| 4690 | (link_speed == IXGBE_LINK_SPEED_1GB_FULL ? |
| 4691 | "1 Gbps" : "unknown speed")), |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 4692 | ((flow_rx && flow_tx) ? "RX/TX" : |
| 4693 | (flow_rx ? "RX" : |
| 4694 | (flow_tx ? "TX" : "None")))); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4695 | |
| 4696 | netif_carrier_on(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4697 | } else { |
| 4698 | /* Force detection of hung controller */ |
| 4699 | adapter->detect_tx_hung = true; |
| 4700 | } |
| 4701 | } else { |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4702 | adapter->link_up = false; |
| 4703 | adapter->link_speed = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4704 | if (netif_carrier_ok(netdev)) { |
Jeff Kirsher | a46e534 | 2008-11-27 00:22:21 -0800 | [diff] [blame] | 4705 | printk(KERN_INFO "ixgbe: %s NIC Link is Down\n", |
| 4706 | netdev->name); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4707 | netif_carrier_off(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4708 | } |
| 4709 | } |
| 4710 | |
Nelson, Shannon | bc59fcd | 2009-04-27 22:43:12 +0000 | [diff] [blame] | 4711 | if (!netif_carrier_ok(netdev)) { |
| 4712 | for (i = 0; i < adapter->num_tx_queues; i++) { |
| 4713 | tx_ring = &adapter->tx_ring[i]; |
| 4714 | if (tx_ring->next_to_use != tx_ring->next_to_clean) { |
| 4715 | some_tx_pending = 1; |
| 4716 | break; |
| 4717 | } |
| 4718 | } |
| 4719 | |
| 4720 | if (some_tx_pending) { |
| 4721 | /* We've lost link, so the controller stops DMA, |
| 4722 | * but we've got queued Tx work that's never going |
| 4723 | * to get done, so reset controller to flush Tx. |
| 4724 | * (Do the reset outside of interrupt context). |
| 4725 | */ |
| 4726 | schedule_work(&adapter->reset_task); |
| 4727 | } |
| 4728 | } |
| 4729 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4730 | ixgbe_update_stats(adapter); |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 4731 | adapter->flags &= ~IXGBE_FLAG_IN_WATCHDOG_TASK; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4732 | } |
| 4733 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4734 | static int ixgbe_tso(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4735 | struct ixgbe_ring *tx_ring, struct sk_buff *skb, |
| 4736 | u32 tx_flags, u8 *hdr_len) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4737 | { |
| 4738 | struct ixgbe_adv_tx_context_desc *context_desc; |
| 4739 | unsigned int i; |
| 4740 | int err; |
| 4741 | struct ixgbe_tx_buffer *tx_buffer_info; |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 4742 | u32 vlan_macip_lens = 0, type_tucmd_mlhl; |
| 4743 | u32 mss_l4len_idx, l4len; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4744 | |
| 4745 | if (skb_is_gso(skb)) { |
| 4746 | if (skb_header_cloned(skb)) { |
| 4747 | err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); |
| 4748 | if (err) |
| 4749 | return err; |
| 4750 | } |
| 4751 | l4len = tcp_hdrlen(skb); |
| 4752 | *hdr_len += l4len; |
| 4753 | |
Al Viro | 8327d00 | 2007-12-10 18:54:12 +0000 | [diff] [blame] | 4754 | if (skb->protocol == htons(ETH_P_IP)) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4755 | struct iphdr *iph = ip_hdr(skb); |
| 4756 | iph->tot_len = 0; |
| 4757 | iph->check = 0; |
| 4758 | tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4759 | iph->daddr, 0, |
| 4760 | IPPROTO_TCP, |
| 4761 | 0); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4762 | adapter->hw_tso_ctxt++; |
| 4763 | } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) { |
| 4764 | ipv6_hdr(skb)->payload_len = 0; |
| 4765 | tcp_hdr(skb)->check = |
| 4766 | ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4767 | &ipv6_hdr(skb)->daddr, |
| 4768 | 0, IPPROTO_TCP, 0); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4769 | adapter->hw_tso6_ctxt++; |
| 4770 | } |
| 4771 | |
| 4772 | i = tx_ring->next_to_use; |
| 4773 | |
| 4774 | tx_buffer_info = &tx_ring->tx_buffer_info[i]; |
| 4775 | context_desc = IXGBE_TX_CTXTDESC_ADV(*tx_ring, i); |
| 4776 | |
| 4777 | /* VLAN MACLEN IPLEN */ |
| 4778 | if (tx_flags & IXGBE_TX_FLAGS_VLAN) |
| 4779 | vlan_macip_lens |= |
| 4780 | (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK); |
| 4781 | vlan_macip_lens |= ((skb_network_offset(skb)) << |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4782 | IXGBE_ADVTXD_MACLEN_SHIFT); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4783 | *hdr_len += skb_network_offset(skb); |
| 4784 | vlan_macip_lens |= |
| 4785 | (skb_transport_header(skb) - skb_network_header(skb)); |
| 4786 | *hdr_len += |
| 4787 | (skb_transport_header(skb) - skb_network_header(skb)); |
| 4788 | context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); |
| 4789 | context_desc->seqnum_seed = 0; |
| 4790 | |
| 4791 | /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 4792 | type_tucmd_mlhl = (IXGBE_TXD_CMD_DEXT | |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4793 | IXGBE_ADVTXD_DTYP_CTXT); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4794 | |
Al Viro | 8327d00 | 2007-12-10 18:54:12 +0000 | [diff] [blame] | 4795 | if (skb->protocol == htons(ETH_P_IP)) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4796 | type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV4; |
| 4797 | type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_TCP; |
| 4798 | context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd_mlhl); |
| 4799 | |
| 4800 | /* MSS L4LEN IDX */ |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 4801 | mss_l4len_idx = |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4802 | (skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT); |
| 4803 | mss_l4len_idx |= (l4len << IXGBE_ADVTXD_L4LEN_SHIFT); |
PJ Waskiewicz | 4eeae6f | 2008-08-26 04:27:30 -0700 | [diff] [blame] | 4804 | /* use index 1 for TSO */ |
| 4805 | mss_l4len_idx |= (1 << IXGBE_ADVTXD_IDX_SHIFT); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4806 | context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); |
| 4807 | |
| 4808 | tx_buffer_info->time_stamp = jiffies; |
| 4809 | tx_buffer_info->next_to_watch = i; |
| 4810 | |
| 4811 | i++; |
| 4812 | if (i == tx_ring->count) |
| 4813 | i = 0; |
| 4814 | tx_ring->next_to_use = i; |
| 4815 | |
| 4816 | return true; |
| 4817 | } |
| 4818 | return false; |
| 4819 | } |
| 4820 | |
| 4821 | static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4822 | struct ixgbe_ring *tx_ring, |
| 4823 | struct sk_buff *skb, u32 tx_flags) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4824 | { |
| 4825 | struct ixgbe_adv_tx_context_desc *context_desc; |
| 4826 | unsigned int i; |
| 4827 | struct ixgbe_tx_buffer *tx_buffer_info; |
| 4828 | u32 vlan_macip_lens = 0, type_tucmd_mlhl = 0; |
| 4829 | |
| 4830 | if (skb->ip_summed == CHECKSUM_PARTIAL || |
| 4831 | (tx_flags & IXGBE_TX_FLAGS_VLAN)) { |
| 4832 | i = tx_ring->next_to_use; |
| 4833 | tx_buffer_info = &tx_ring->tx_buffer_info[i]; |
| 4834 | context_desc = IXGBE_TX_CTXTDESC_ADV(*tx_ring, i); |
| 4835 | |
| 4836 | if (tx_flags & IXGBE_TX_FLAGS_VLAN) |
| 4837 | vlan_macip_lens |= |
| 4838 | (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK); |
| 4839 | vlan_macip_lens |= (skb_network_offset(skb) << |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4840 | IXGBE_ADVTXD_MACLEN_SHIFT); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4841 | if (skb->ip_summed == CHECKSUM_PARTIAL) |
| 4842 | vlan_macip_lens |= (skb_transport_header(skb) - |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4843 | skb_network_header(skb)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4844 | |
| 4845 | context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); |
| 4846 | context_desc->seqnum_seed = 0; |
| 4847 | |
| 4848 | type_tucmd_mlhl |= (IXGBE_TXD_CMD_DEXT | |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4849 | IXGBE_ADVTXD_DTYP_CTXT); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4850 | |
| 4851 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
Auke Kok | 41825d7 | 2008-02-12 15:20:33 -0800 | [diff] [blame] | 4852 | switch (skb->protocol) { |
Harvey Harrison | 09640e6 | 2009-02-01 00:45:17 -0800 | [diff] [blame] | 4853 | case cpu_to_be16(ETH_P_IP): |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4854 | type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV4; |
Auke Kok | 41825d7 | 2008-02-12 15:20:33 -0800 | [diff] [blame] | 4855 | if (ip_hdr(skb)->protocol == IPPROTO_TCP) |
| 4856 | type_tucmd_mlhl |= |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4857 | IXGBE_ADVTXD_TUCMD_L4T_TCP; |
Jesse Brandeburg | 45a5ead | 2009-04-27 22:36:35 +0000 | [diff] [blame] | 4858 | else if (ip_hdr(skb)->protocol == IPPROTO_SCTP) |
| 4859 | type_tucmd_mlhl |= |
| 4860 | IXGBE_ADVTXD_TUCMD_L4T_SCTP; |
Auke Kok | 41825d7 | 2008-02-12 15:20:33 -0800 | [diff] [blame] | 4861 | break; |
Harvey Harrison | 09640e6 | 2009-02-01 00:45:17 -0800 | [diff] [blame] | 4862 | case cpu_to_be16(ETH_P_IPV6): |
Auke Kok | 41825d7 | 2008-02-12 15:20:33 -0800 | [diff] [blame] | 4863 | /* XXX what about other V6 headers?? */ |
| 4864 | if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) |
| 4865 | type_tucmd_mlhl |= |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4866 | IXGBE_ADVTXD_TUCMD_L4T_TCP; |
Jesse Brandeburg | 45a5ead | 2009-04-27 22:36:35 +0000 | [diff] [blame] | 4867 | else if (ipv6_hdr(skb)->nexthdr == IPPROTO_SCTP) |
| 4868 | type_tucmd_mlhl |= |
| 4869 | IXGBE_ADVTXD_TUCMD_L4T_SCTP; |
Auke Kok | 41825d7 | 2008-02-12 15:20:33 -0800 | [diff] [blame] | 4870 | break; |
Auke Kok | 41825d7 | 2008-02-12 15:20:33 -0800 | [diff] [blame] | 4871 | default: |
| 4872 | if (unlikely(net_ratelimit())) { |
| 4873 | DPRINTK(PROBE, WARNING, |
| 4874 | "partial checksum but proto=%x!\n", |
| 4875 | skb->protocol); |
| 4876 | } |
| 4877 | break; |
| 4878 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4879 | } |
| 4880 | |
| 4881 | context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd_mlhl); |
PJ Waskiewicz | 4eeae6f | 2008-08-26 04:27:30 -0700 | [diff] [blame] | 4882 | /* use index zero for tx checksum offload */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4883 | context_desc->mss_l4len_idx = 0; |
| 4884 | |
| 4885 | tx_buffer_info->time_stamp = jiffies; |
| 4886 | tx_buffer_info->next_to_watch = i; |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 4887 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4888 | adapter->hw_csum_tx_good++; |
| 4889 | i++; |
| 4890 | if (i == tx_ring->count) |
| 4891 | i = 0; |
| 4892 | tx_ring->next_to_use = i; |
| 4893 | |
| 4894 | return true; |
| 4895 | } |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 4896 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4897 | return false; |
| 4898 | } |
| 4899 | |
| 4900 | static int ixgbe_tx_map(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4901 | struct ixgbe_ring *tx_ring, |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 4902 | struct sk_buff *skb, u32 tx_flags, |
| 4903 | unsigned int first) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4904 | { |
| 4905 | struct ixgbe_tx_buffer *tx_buffer_info; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 4906 | unsigned int len; |
| 4907 | unsigned int total = skb->len; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4908 | unsigned int offset = 0, size, count = 0, i; |
| 4909 | unsigned int nr_frags = skb_shinfo(skb)->nr_frags; |
| 4910 | unsigned int f; |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 4911 | dma_addr_t *map; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4912 | |
| 4913 | i = tx_ring->next_to_use; |
| 4914 | |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 4915 | if (skb_dma_map(&adapter->pdev->dev, skb, DMA_TO_DEVICE)) { |
| 4916 | dev_err(&adapter->pdev->dev, "TX DMA map failed\n"); |
| 4917 | return 0; |
| 4918 | } |
| 4919 | |
| 4920 | map = skb_shinfo(skb)->dma_maps; |
| 4921 | |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 4922 | if (tx_flags & IXGBE_TX_FLAGS_FCOE) |
| 4923 | /* excluding fcoe_crc_eof for FCoE */ |
| 4924 | total -= sizeof(struct fcoe_crc_eof); |
| 4925 | |
| 4926 | len = min(skb_headlen(skb), total); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4927 | while (len) { |
| 4928 | tx_buffer_info = &tx_ring->tx_buffer_info[i]; |
| 4929 | size = min(len, (uint)IXGBE_MAX_DATA_PER_TXD); |
| 4930 | |
| 4931 | tx_buffer_info->length = size; |
Eric Dumazet | 042a53a | 2009-06-05 04:04:16 +0000 | [diff] [blame] | 4932 | tx_buffer_info->dma = skb_shinfo(skb)->dma_head + offset; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4933 | tx_buffer_info->time_stamp = jiffies; |
| 4934 | tx_buffer_info->next_to_watch = i; |
| 4935 | |
| 4936 | len -= size; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 4937 | total -= size; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4938 | offset += size; |
| 4939 | count++; |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 4940 | |
| 4941 | if (len) { |
| 4942 | i++; |
| 4943 | if (i == tx_ring->count) |
| 4944 | i = 0; |
| 4945 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4946 | } |
| 4947 | |
| 4948 | for (f = 0; f < nr_frags; f++) { |
| 4949 | struct skb_frag_struct *frag; |
| 4950 | |
| 4951 | frag = &skb_shinfo(skb)->frags[f]; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 4952 | len = min((unsigned int)frag->size, total); |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 4953 | offset = 0; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4954 | |
| 4955 | while (len) { |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 4956 | i++; |
| 4957 | if (i == tx_ring->count) |
| 4958 | i = 0; |
| 4959 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4960 | tx_buffer_info = &tx_ring->tx_buffer_info[i]; |
| 4961 | size = min(len, (uint)IXGBE_MAX_DATA_PER_TXD); |
| 4962 | |
| 4963 | tx_buffer_info->length = size; |
Eric Dumazet | 042a53a | 2009-06-05 04:04:16 +0000 | [diff] [blame] | 4964 | tx_buffer_info->dma = map[f] + offset; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4965 | tx_buffer_info->time_stamp = jiffies; |
| 4966 | tx_buffer_info->next_to_watch = i; |
| 4967 | |
| 4968 | len -= size; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 4969 | total -= size; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4970 | offset += size; |
| 4971 | count++; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4972 | } |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 4973 | if (total == 0) |
| 4974 | break; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4975 | } |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 4976 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4977 | tx_ring->tx_buffer_info[i].skb = skb; |
| 4978 | tx_ring->tx_buffer_info[first].next_to_watch = i; |
| 4979 | |
| 4980 | return count; |
| 4981 | } |
| 4982 | |
| 4983 | static void ixgbe_tx_queue(struct ixgbe_adapter *adapter, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 4984 | struct ixgbe_ring *tx_ring, |
| 4985 | int tx_flags, int count, u32 paylen, u8 hdr_len) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 4986 | { |
| 4987 | union ixgbe_adv_tx_desc *tx_desc = NULL; |
| 4988 | struct ixgbe_tx_buffer *tx_buffer_info; |
| 4989 | u32 olinfo_status = 0, cmd_type_len = 0; |
| 4990 | unsigned int i; |
| 4991 | u32 txd_cmd = IXGBE_TXD_CMD_EOP | IXGBE_TXD_CMD_RS | IXGBE_TXD_CMD_IFCS; |
| 4992 | |
| 4993 | cmd_type_len |= IXGBE_ADVTXD_DTYP_DATA; |
| 4994 | |
| 4995 | cmd_type_len |= IXGBE_ADVTXD_DCMD_IFCS | IXGBE_ADVTXD_DCMD_DEXT; |
| 4996 | |
| 4997 | if (tx_flags & IXGBE_TX_FLAGS_VLAN) |
| 4998 | cmd_type_len |= IXGBE_ADVTXD_DCMD_VLE; |
| 4999 | |
| 5000 | if (tx_flags & IXGBE_TX_FLAGS_TSO) { |
| 5001 | cmd_type_len |= IXGBE_ADVTXD_DCMD_TSE; |
| 5002 | |
| 5003 | olinfo_status |= IXGBE_TXD_POPTS_TXSM << |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5004 | IXGBE_ADVTXD_POPTS_SHIFT; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5005 | |
PJ Waskiewicz | 4eeae6f | 2008-08-26 04:27:30 -0700 | [diff] [blame] | 5006 | /* use index 1 context for tso */ |
| 5007 | olinfo_status |= (1 << IXGBE_ADVTXD_IDX_SHIFT); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5008 | if (tx_flags & IXGBE_TX_FLAGS_IPV4) |
| 5009 | olinfo_status |= IXGBE_TXD_POPTS_IXSM << |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5010 | IXGBE_ADVTXD_POPTS_SHIFT; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5011 | |
| 5012 | } else if (tx_flags & IXGBE_TX_FLAGS_CSUM) |
| 5013 | olinfo_status |= IXGBE_TXD_POPTS_TXSM << |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5014 | IXGBE_ADVTXD_POPTS_SHIFT; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5015 | |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5016 | if (tx_flags & IXGBE_TX_FLAGS_FCOE) { |
| 5017 | olinfo_status |= IXGBE_ADVTXD_CC; |
| 5018 | olinfo_status |= (1 << IXGBE_ADVTXD_IDX_SHIFT); |
| 5019 | if (tx_flags & IXGBE_TX_FLAGS_FSO) |
| 5020 | cmd_type_len |= IXGBE_ADVTXD_DCMD_TSE; |
| 5021 | } |
| 5022 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5023 | olinfo_status |= ((paylen - hdr_len) << IXGBE_ADVTXD_PAYLEN_SHIFT); |
| 5024 | |
| 5025 | i = tx_ring->next_to_use; |
| 5026 | while (count--) { |
| 5027 | tx_buffer_info = &tx_ring->tx_buffer_info[i]; |
| 5028 | tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i); |
| 5029 | tx_desc->read.buffer_addr = cpu_to_le64(tx_buffer_info->dma); |
| 5030 | tx_desc->read.cmd_type_len = |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5031 | cpu_to_le32(cmd_type_len | tx_buffer_info->length); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5032 | tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5033 | i++; |
| 5034 | if (i == tx_ring->count) |
| 5035 | i = 0; |
| 5036 | } |
| 5037 | |
| 5038 | tx_desc->read.cmd_type_len |= cpu_to_le32(txd_cmd); |
| 5039 | |
| 5040 | /* |
| 5041 | * Force memory writes to complete before letting h/w |
| 5042 | * know there are new descriptors to fetch. (Only |
| 5043 | * applicable for weak-ordered memory model archs, |
| 5044 | * such as IA-64). |
| 5045 | */ |
| 5046 | wmb(); |
| 5047 | |
| 5048 | tx_ring->next_to_use = i; |
| 5049 | writel(i, adapter->hw.hw_addr + tx_ring->tail); |
| 5050 | } |
| 5051 | |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 5052 | static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb, |
| 5053 | int queue, u32 tx_flags) |
| 5054 | { |
| 5055 | /* Right now, we support IPv4 only */ |
| 5056 | struct ixgbe_atr_input atr_input; |
| 5057 | struct tcphdr *th; |
| 5058 | struct udphdr *uh; |
| 5059 | struct iphdr *iph = ip_hdr(skb); |
| 5060 | struct ethhdr *eth = (struct ethhdr *)skb->data; |
| 5061 | u16 vlan_id, src_port, dst_port, flex_bytes; |
| 5062 | u32 src_ipv4_addr, dst_ipv4_addr; |
| 5063 | u8 l4type = 0; |
| 5064 | |
| 5065 | /* check if we're UDP or TCP */ |
| 5066 | if (iph->protocol == IPPROTO_TCP) { |
| 5067 | th = tcp_hdr(skb); |
| 5068 | src_port = th->source; |
| 5069 | dst_port = th->dest; |
| 5070 | l4type |= IXGBE_ATR_L4TYPE_TCP; |
| 5071 | /* l4type IPv4 type is 0, no need to assign */ |
| 5072 | } else if(iph->protocol == IPPROTO_UDP) { |
| 5073 | uh = udp_hdr(skb); |
| 5074 | src_port = uh->source; |
| 5075 | dst_port = uh->dest; |
| 5076 | l4type |= IXGBE_ATR_L4TYPE_UDP; |
| 5077 | /* l4type IPv4 type is 0, no need to assign */ |
| 5078 | } else { |
| 5079 | /* Unsupported L4 header, just bail here */ |
| 5080 | return; |
| 5081 | } |
| 5082 | |
| 5083 | memset(&atr_input, 0, sizeof(struct ixgbe_atr_input)); |
| 5084 | |
| 5085 | vlan_id = (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK) >> |
| 5086 | IXGBE_TX_FLAGS_VLAN_SHIFT; |
| 5087 | src_ipv4_addr = iph->saddr; |
| 5088 | dst_ipv4_addr = iph->daddr; |
| 5089 | flex_bytes = eth->h_proto; |
| 5090 | |
| 5091 | ixgbe_atr_set_vlan_id_82599(&atr_input, vlan_id); |
| 5092 | ixgbe_atr_set_src_port_82599(&atr_input, dst_port); |
| 5093 | ixgbe_atr_set_dst_port_82599(&atr_input, src_port); |
| 5094 | ixgbe_atr_set_flex_byte_82599(&atr_input, flex_bytes); |
| 5095 | ixgbe_atr_set_l4type_82599(&atr_input, l4type); |
| 5096 | /* src and dst are inverted, think how the receiver sees them */ |
| 5097 | ixgbe_atr_set_src_ipv4_82599(&atr_input, dst_ipv4_addr); |
| 5098 | ixgbe_atr_set_dst_ipv4_82599(&atr_input, src_ipv4_addr); |
| 5099 | |
| 5100 | /* This assumes the Rx queue and Tx queue are bound to the same CPU */ |
| 5101 | ixgbe_fdir_add_signature_filter_82599(&adapter->hw, &atr_input, queue); |
| 5102 | } |
| 5103 | |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 5104 | static int __ixgbe_maybe_stop_tx(struct net_device *netdev, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5105 | struct ixgbe_ring *tx_ring, int size) |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 5106 | { |
| 5107 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 5108 | |
Ayyappan Veeraiyan | 30eba97 | 2008-03-03 15:03:52 -0800 | [diff] [blame] | 5109 | netif_stop_subqueue(netdev, tx_ring->queue_index); |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 5110 | /* Herbert's original patch had: |
| 5111 | * smp_mb__after_netif_stop_queue(); |
| 5112 | * but since that doesn't exist yet, just open code it. */ |
| 5113 | smp_mb(); |
| 5114 | |
| 5115 | /* We need to check again in a case another CPU has just |
| 5116 | * made room available. */ |
| 5117 | if (likely(IXGBE_DESC_UNUSED(tx_ring) < size)) |
| 5118 | return -EBUSY; |
| 5119 | |
| 5120 | /* A reprieve! - use start_queue because it doesn't call schedule */ |
Jesse Brandeburg | af72166 | 2008-09-11 19:54:23 -0700 | [diff] [blame] | 5121 | netif_start_subqueue(netdev, tx_ring->queue_index); |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 5122 | ++adapter->restart_queue; |
| 5123 | return 0; |
| 5124 | } |
| 5125 | |
| 5126 | static int ixgbe_maybe_stop_tx(struct net_device *netdev, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5127 | struct ixgbe_ring *tx_ring, int size) |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 5128 | { |
| 5129 | if (likely(IXGBE_DESC_UNUSED(tx_ring) >= size)) |
| 5130 | return 0; |
| 5131 | return __ixgbe_maybe_stop_tx(netdev, tx_ring, size); |
| 5132 | } |
| 5133 | |
Stephen Hemminger | 09a3b1f | 2009-03-21 13:40:01 -0700 | [diff] [blame] | 5134 | static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb) |
| 5135 | { |
| 5136 | struct ixgbe_adapter *adapter = netdev_priv(dev); |
| 5137 | |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 5138 | if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) |
| 5139 | return smp_processor_id(); |
| 5140 | |
Stephen Hemminger | 09a3b1f | 2009-03-21 13:40:01 -0700 | [diff] [blame] | 5141 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) |
Lucy Liu | 36e89d7 | 2009-08-05 13:06:34 -0700 | [diff] [blame] | 5142 | return (skb->vlan_tci & IXGBE_TX_FLAGS_VLAN_PRIO_MASK) >> 13; |
Stephen Hemminger | 09a3b1f | 2009-03-21 13:40:01 -0700 | [diff] [blame] | 5143 | |
| 5144 | return skb_tx_hash(dev, skb); |
| 5145 | } |
| 5146 | |
Stephen Hemminger | 3b29a56 | 2009-08-31 19:50:55 +0000 | [diff] [blame] | 5147 | static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb, |
| 5148 | struct net_device *netdev) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5149 | { |
| 5150 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 5151 | struct ixgbe_ring *tx_ring; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5152 | unsigned int first; |
| 5153 | unsigned int tx_flags = 0; |
Ayyappan Veeraiyan | 30eba97 | 2008-03-03 15:03:52 -0800 | [diff] [blame] | 5154 | u8 hdr_len = 0; |
| 5155 | int r_idx = 0, tso; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5156 | int count = 0; |
| 5157 | unsigned int f; |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 5158 | |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 5159 | if (adapter->vlgrp && vlan_tx_tag_present(skb)) { |
| 5160 | tx_flags |= vlan_tx_tag_get(skb); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 5161 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
| 5162 | tx_flags &= ~IXGBE_TX_FLAGS_VLAN_PRIO_MASK; |
| 5163 | tx_flags |= (skb->queue_mapping << 13); |
| 5164 | } |
| 5165 | tx_flags <<= IXGBE_TX_FLAGS_VLAN_SHIFT; |
| 5166 | tx_flags |= IXGBE_TX_FLAGS_VLAN; |
| 5167 | } else if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
Lucy Liu | 6012786 | 2009-07-22 14:07:33 +0000 | [diff] [blame] | 5168 | if (skb->priority != TC_PRIO_CONTROL) { |
| 5169 | tx_flags |= (skb->queue_mapping << 13); |
| 5170 | tx_flags <<= IXGBE_TX_FLAGS_VLAN_SHIFT; |
| 5171 | tx_flags |= IXGBE_TX_FLAGS_VLAN; |
| 5172 | } else { |
| 5173 | skb->queue_mapping = |
| 5174 | adapter->ring_feature[RING_F_DCB].indices-1; |
| 5175 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5176 | } |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5177 | |
Lucy Liu | 6012786 | 2009-07-22 14:07:33 +0000 | [diff] [blame] | 5178 | r_idx = skb->queue_mapping; |
| 5179 | tx_ring = &adapter->tx_ring[r_idx]; |
| 5180 | |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5181 | if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) && |
Yi Zou | 09ad1cc | 2009-09-03 14:56:10 +0000 | [diff] [blame] | 5182 | (skb->protocol == htons(ETH_P_FCOE))) { |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5183 | tx_flags |= IXGBE_TX_FLAGS_FCOE; |
Yi Zou | 09ad1cc | 2009-09-03 14:56:10 +0000 | [diff] [blame] | 5184 | #ifdef IXGBE_FCOE |
| 5185 | r_idx = smp_processor_id(); |
| 5186 | r_idx &= (adapter->ring_feature[RING_F_FCOE].indices - 1); |
| 5187 | r_idx += adapter->ring_feature[RING_F_FCOE].mask; |
| 5188 | tx_ring = &adapter->tx_ring[r_idx]; |
| 5189 | #endif |
| 5190 | } |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5191 | /* four things can cause us to need a context descriptor */ |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 5192 | if (skb_is_gso(skb) || |
| 5193 | (skb->ip_summed == CHECKSUM_PARTIAL) || |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5194 | (tx_flags & IXGBE_TX_FLAGS_VLAN) || |
| 5195 | (tx_flags & IXGBE_TX_FLAGS_FCOE)) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5196 | count++; |
| 5197 | |
Jesse Brandeburg | 9f8cdf4 | 2008-09-11 20:03:35 -0700 | [diff] [blame] | 5198 | count += TXD_USE_COUNT(skb_headlen(skb)); |
| 5199 | for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5200 | count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size); |
| 5201 | |
Ayyappan Veeraiyan | e092be6 | 2008-02-01 15:58:49 -0800 | [diff] [blame] | 5202 | if (ixgbe_maybe_stop_tx(netdev, tx_ring, count)) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5203 | adapter->tx_busy++; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5204 | return NETDEV_TX_BUSY; |
| 5205 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5206 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5207 | first = tx_ring->next_to_use; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5208 | if (tx_flags & IXGBE_TX_FLAGS_FCOE) { |
| 5209 | #ifdef IXGBE_FCOE |
| 5210 | /* setup tx offload for FCoE */ |
| 5211 | tso = ixgbe_fso(adapter, tx_ring, skb, tx_flags, &hdr_len); |
| 5212 | if (tso < 0) { |
| 5213 | dev_kfree_skb_any(skb); |
| 5214 | return NETDEV_TX_OK; |
| 5215 | } |
| 5216 | if (tso) |
| 5217 | tx_flags |= IXGBE_TX_FLAGS_FSO; |
| 5218 | #endif /* IXGBE_FCOE */ |
| 5219 | } else { |
| 5220 | if (skb->protocol == htons(ETH_P_IP)) |
| 5221 | tx_flags |= IXGBE_TX_FLAGS_IPV4; |
| 5222 | tso = ixgbe_tso(adapter, tx_ring, skb, tx_flags, &hdr_len); |
| 5223 | if (tso < 0) { |
| 5224 | dev_kfree_skb_any(skb); |
| 5225 | return NETDEV_TX_OK; |
| 5226 | } |
| 5227 | |
| 5228 | if (tso) |
| 5229 | tx_flags |= IXGBE_TX_FLAGS_TSO; |
| 5230 | else if (ixgbe_tx_csum(adapter, tx_ring, skb, tx_flags) && |
| 5231 | (skb->ip_summed == CHECKSUM_PARTIAL)) |
| 5232 | tx_flags |= IXGBE_TX_FLAGS_CSUM; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5233 | } |
| 5234 | |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5235 | count = ixgbe_tx_map(adapter, tx_ring, skb, tx_flags, first); |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 5236 | if (count) { |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 5237 | /* add the ATR filter if ATR is on */ |
| 5238 | if (tx_ring->atr_sample_rate) { |
| 5239 | ++tx_ring->atr_count; |
| 5240 | if ((tx_ring->atr_count >= tx_ring->atr_sample_rate) && |
| 5241 | test_bit(__IXGBE_FDIR_INIT_DONE, |
| 5242 | &tx_ring->reinit_state)) { |
| 5243 | ixgbe_atr(adapter, skb, tx_ring->queue_index, |
| 5244 | tx_flags); |
| 5245 | tx_ring->atr_count = 0; |
| 5246 | } |
| 5247 | } |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 5248 | ixgbe_tx_queue(adapter, tx_ring, tx_flags, count, skb->len, |
| 5249 | hdr_len); |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 5250 | ixgbe_maybe_stop_tx(netdev, tx_ring, DESC_NEEDED); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5251 | |
Alexander Duyck | 44df32c | 2009-03-31 21:34:23 +0000 | [diff] [blame] | 5252 | } else { |
| 5253 | dev_kfree_skb_any(skb); |
| 5254 | tx_ring->tx_buffer_info[first].time_stamp = 0; |
| 5255 | tx_ring->next_to_use = first; |
| 5256 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5257 | |
| 5258 | return NETDEV_TX_OK; |
| 5259 | } |
| 5260 | |
| 5261 | /** |
| 5262 | * ixgbe_get_stats - Get System Network Statistics |
| 5263 | * @netdev: network interface device structure |
| 5264 | * |
| 5265 | * Returns the address of the device statistics structure. |
| 5266 | * The statistics are actually updated from the timer callback. |
| 5267 | **/ |
| 5268 | static struct net_device_stats *ixgbe_get_stats(struct net_device *netdev) |
| 5269 | { |
| 5270 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 5271 | |
| 5272 | /* only return the current stats */ |
| 5273 | return &adapter->net_stats; |
| 5274 | } |
| 5275 | |
| 5276 | /** |
| 5277 | * ixgbe_set_mac - Change the Ethernet Address of the NIC |
| 5278 | * @netdev: network interface device structure |
| 5279 | * @p: pointer to an address structure |
| 5280 | * |
| 5281 | * Returns 0 on success, negative on failure |
| 5282 | **/ |
| 5283 | static int ixgbe_set_mac(struct net_device *netdev, void *p) |
| 5284 | { |
| 5285 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5286 | struct ixgbe_hw *hw = &adapter->hw; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5287 | struct sockaddr *addr = p; |
| 5288 | |
| 5289 | if (!is_valid_ether_addr(addr->sa_data)) |
| 5290 | return -EADDRNOTAVAIL; |
| 5291 | |
| 5292 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5293 | memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5294 | |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5295 | hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5296 | |
| 5297 | return 0; |
| 5298 | } |
| 5299 | |
Ben Hutchings | 6b73e10 | 2009-04-29 08:08:58 +0000 | [diff] [blame] | 5300 | static int |
| 5301 | ixgbe_mdio_read(struct net_device *netdev, int prtad, int devad, u16 addr) |
| 5302 | { |
| 5303 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 5304 | struct ixgbe_hw *hw = &adapter->hw; |
| 5305 | u16 value; |
| 5306 | int rc; |
| 5307 | |
| 5308 | if (prtad != hw->phy.mdio.prtad) |
| 5309 | return -EINVAL; |
| 5310 | rc = hw->phy.ops.read_reg(hw, addr, devad, &value); |
| 5311 | if (!rc) |
| 5312 | rc = value; |
| 5313 | return rc; |
| 5314 | } |
| 5315 | |
| 5316 | static int ixgbe_mdio_write(struct net_device *netdev, int prtad, int devad, |
| 5317 | u16 addr, u16 value) |
| 5318 | { |
| 5319 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 5320 | struct ixgbe_hw *hw = &adapter->hw; |
| 5321 | |
| 5322 | if (prtad != hw->phy.mdio.prtad) |
| 5323 | return -EINVAL; |
| 5324 | return hw->phy.ops.write_reg(hw, addr, devad, value); |
| 5325 | } |
| 5326 | |
| 5327 | static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd) |
| 5328 | { |
| 5329 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 5330 | |
| 5331 | return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd); |
| 5332 | } |
| 5333 | |
PJ Waskiewicz | 0365e6e | 2009-05-17 12:32:25 +0000 | [diff] [blame] | 5334 | /** |
| 5335 | * ixgbe_add_sanmac_netdev - Add the SAN MAC address to the corresponding |
Jiri Pirko | 31278e7 | 2009-06-17 01:12:19 +0000 | [diff] [blame] | 5336 | * netdev->dev_addrs |
PJ Waskiewicz | 0365e6e | 2009-05-17 12:32:25 +0000 | [diff] [blame] | 5337 | * @netdev: network interface device structure |
| 5338 | * |
| 5339 | * Returns non-zero on failure |
| 5340 | **/ |
| 5341 | static int ixgbe_add_sanmac_netdev(struct net_device *dev) |
| 5342 | { |
| 5343 | int err = 0; |
| 5344 | struct ixgbe_adapter *adapter = netdev_priv(dev); |
| 5345 | struct ixgbe_mac_info *mac = &adapter->hw.mac; |
| 5346 | |
| 5347 | if (is_valid_ether_addr(mac->san_addr)) { |
| 5348 | rtnl_lock(); |
| 5349 | err = dev_addr_add(dev, mac->san_addr, NETDEV_HW_ADDR_T_SAN); |
| 5350 | rtnl_unlock(); |
| 5351 | } |
| 5352 | return err; |
| 5353 | } |
| 5354 | |
| 5355 | /** |
| 5356 | * ixgbe_del_sanmac_netdev - Removes the SAN MAC address to the corresponding |
Jiri Pirko | 31278e7 | 2009-06-17 01:12:19 +0000 | [diff] [blame] | 5357 | * netdev->dev_addrs |
PJ Waskiewicz | 0365e6e | 2009-05-17 12:32:25 +0000 | [diff] [blame] | 5358 | * @netdev: network interface device structure |
| 5359 | * |
| 5360 | * Returns non-zero on failure |
| 5361 | **/ |
| 5362 | static int ixgbe_del_sanmac_netdev(struct net_device *dev) |
| 5363 | { |
| 5364 | int err = 0; |
| 5365 | struct ixgbe_adapter *adapter = netdev_priv(dev); |
| 5366 | struct ixgbe_mac_info *mac = &adapter->hw.mac; |
| 5367 | |
| 5368 | if (is_valid_ether_addr(mac->san_addr)) { |
| 5369 | rtnl_lock(); |
| 5370 | err = dev_addr_del(dev, mac->san_addr, NETDEV_HW_ADDR_T_SAN); |
| 5371 | rtnl_unlock(); |
| 5372 | } |
| 5373 | return err; |
| 5374 | } |
| 5375 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5376 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 5377 | /* |
| 5378 | * Polling 'interrupt' - used by things like netconsole to send skbs |
| 5379 | * without having to re-enable interrupts. It's not called while |
| 5380 | * the interrupt routine is executing. |
| 5381 | */ |
| 5382 | static void ixgbe_netpoll(struct net_device *netdev) |
| 5383 | { |
| 5384 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Peter P Waskiewicz Jr | 8f9a716 | 2009-07-30 12:25:09 +0000 | [diff] [blame] | 5385 | int i; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5386 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5387 | adapter->flags |= IXGBE_FLAG_IN_NETPOLL; |
Peter P Waskiewicz Jr | 8f9a716 | 2009-07-30 12:25:09 +0000 | [diff] [blame] | 5388 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { |
| 5389 | int num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
| 5390 | for (i = 0; i < num_q_vectors; i++) { |
| 5391 | struct ixgbe_q_vector *q_vector = adapter->q_vector[i]; |
| 5392 | ixgbe_msix_clean_many(0, q_vector); |
| 5393 | } |
| 5394 | } else { |
| 5395 | ixgbe_intr(adapter->pdev->irq, netdev); |
| 5396 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5397 | adapter->flags &= ~IXGBE_FLAG_IN_NETPOLL; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5398 | } |
| 5399 | #endif |
| 5400 | |
Stephen Hemminger | 0edc352 | 2008-11-19 22:24:29 -0800 | [diff] [blame] | 5401 | static const struct net_device_ops ixgbe_netdev_ops = { |
| 5402 | .ndo_open = ixgbe_open, |
| 5403 | .ndo_stop = ixgbe_close, |
Stephen Hemminger | 0082982 | 2008-11-20 20:14:53 -0800 | [diff] [blame] | 5404 | .ndo_start_xmit = ixgbe_xmit_frame, |
Stephen Hemminger | 09a3b1f | 2009-03-21 13:40:01 -0700 | [diff] [blame] | 5405 | .ndo_select_queue = ixgbe_select_queue, |
Stephen Hemminger | 0edc352 | 2008-11-19 22:24:29 -0800 | [diff] [blame] | 5406 | .ndo_get_stats = ixgbe_get_stats, |
Chris Leech | e90d400 | 2009-03-10 16:00:24 +0000 | [diff] [blame] | 5407 | .ndo_set_rx_mode = ixgbe_set_rx_mode, |
Stephen Hemminger | 0edc352 | 2008-11-19 22:24:29 -0800 | [diff] [blame] | 5408 | .ndo_set_multicast_list = ixgbe_set_rx_mode, |
| 5409 | .ndo_validate_addr = eth_validate_addr, |
| 5410 | .ndo_set_mac_address = ixgbe_set_mac, |
| 5411 | .ndo_change_mtu = ixgbe_change_mtu, |
| 5412 | .ndo_tx_timeout = ixgbe_tx_timeout, |
| 5413 | .ndo_vlan_rx_register = ixgbe_vlan_rx_register, |
| 5414 | .ndo_vlan_rx_add_vid = ixgbe_vlan_rx_add_vid, |
| 5415 | .ndo_vlan_rx_kill_vid = ixgbe_vlan_rx_kill_vid, |
Ben Hutchings | 6b73e10 | 2009-04-29 08:08:58 +0000 | [diff] [blame] | 5416 | .ndo_do_ioctl = ixgbe_ioctl, |
Stephen Hemminger | 0edc352 | 2008-11-19 22:24:29 -0800 | [diff] [blame] | 5417 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 5418 | .ndo_poll_controller = ixgbe_netpoll, |
| 5419 | #endif |
Yi Zou | 332d4a7 | 2009-05-13 13:11:53 +0000 | [diff] [blame] | 5420 | #ifdef IXGBE_FCOE |
| 5421 | .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get, |
| 5422 | .ndo_fcoe_ddp_done = ixgbe_fcoe_ddp_put, |
Yi Zou | 8450ff8 | 2009-08-31 12:32:14 +0000 | [diff] [blame] | 5423 | .ndo_fcoe_enable = ixgbe_fcoe_enable, |
| 5424 | .ndo_fcoe_disable = ixgbe_fcoe_disable, |
Yi Zou | 332d4a7 | 2009-05-13 13:11:53 +0000 | [diff] [blame] | 5425 | #endif /* IXGBE_FCOE */ |
Stephen Hemminger | 0edc352 | 2008-11-19 22:24:29 -0800 | [diff] [blame] | 5426 | }; |
| 5427 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5428 | /** |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5429 | * ixgbe_probe - Device Initialization Routine |
| 5430 | * @pdev: PCI device information struct |
| 5431 | * @ent: entry in ixgbe_pci_tbl |
| 5432 | * |
| 5433 | * Returns 0 on success, negative on failure |
| 5434 | * |
| 5435 | * ixgbe_probe initializes an adapter identified by a pci_dev structure. |
| 5436 | * The OS initialization, configuring of the adapter private structure, |
| 5437 | * and a hardware reset occur. |
| 5438 | **/ |
| 5439 | static int __devinit ixgbe_probe(struct pci_dev *pdev, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5440 | const struct pci_device_id *ent) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5441 | { |
| 5442 | struct net_device *netdev; |
| 5443 | struct ixgbe_adapter *adapter = NULL; |
| 5444 | struct ixgbe_hw *hw; |
| 5445 | const struct ixgbe_info *ii = ixgbe_info_tbl[ent->driver_data]; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5446 | static int cards_found; |
| 5447 | int i, err, pci_using_dac; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5448 | #ifdef IXGBE_FCOE |
| 5449 | u16 device_caps; |
| 5450 | #endif |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5451 | u32 part_num, eec; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5452 | |
gouji-new | 9ce7766 | 2009-05-06 10:44:45 +0000 | [diff] [blame] | 5453 | err = pci_enable_device_mem(pdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5454 | if (err) |
| 5455 | return err; |
| 5456 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 5457 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && |
| 5458 | !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5459 | pci_using_dac = 1; |
| 5460 | } else { |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 5461 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5462 | if (err) { |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 5463 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5464 | if (err) { |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5465 | dev_err(&pdev->dev, "No usable DMA " |
| 5466 | "configuration, aborting\n"); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5467 | goto err_dma; |
| 5468 | } |
| 5469 | } |
| 5470 | pci_using_dac = 0; |
| 5471 | } |
| 5472 | |
gouji-new | 9ce7766 | 2009-05-06 10:44:45 +0000 | [diff] [blame] | 5473 | err = pci_request_selected_regions(pdev, pci_select_bars(pdev, |
| 5474 | IORESOURCE_MEM), ixgbe_driver_name); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5475 | if (err) { |
gouji-new | 9ce7766 | 2009-05-06 10:44:45 +0000 | [diff] [blame] | 5476 | dev_err(&pdev->dev, |
| 5477 | "pci_request_selected_regions failed 0x%x\n", err); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5478 | goto err_pci_reg; |
| 5479 | } |
| 5480 | |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5481 | err = pci_enable_pcie_error_reporting(pdev); |
| 5482 | if (err) { |
| 5483 | dev_err(&pdev->dev, "pci_enable_pcie_error_reporting failed " |
| 5484 | "0x%x\n", err); |
| 5485 | /* non-fatal, continue */ |
| 5486 | } |
| 5487 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5488 | pci_set_master(pdev); |
Wendy Xiong | fb3b27b | 2008-04-23 11:09:24 -0700 | [diff] [blame] | 5489 | pci_save_state(pdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5490 | |
Ayyappan Veeraiyan | 30eba97 | 2008-03-03 15:03:52 -0800 | [diff] [blame] | 5491 | netdev = alloc_etherdev_mq(sizeof(struct ixgbe_adapter), MAX_TX_QUEUES); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5492 | if (!netdev) { |
| 5493 | err = -ENOMEM; |
| 5494 | goto err_alloc_etherdev; |
| 5495 | } |
| 5496 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5497 | SET_NETDEV_DEV(netdev, &pdev->dev); |
| 5498 | |
| 5499 | pci_set_drvdata(pdev, netdev); |
| 5500 | adapter = netdev_priv(netdev); |
| 5501 | |
| 5502 | adapter->netdev = netdev; |
| 5503 | adapter->pdev = pdev; |
| 5504 | hw = &adapter->hw; |
| 5505 | hw->back = adapter; |
| 5506 | adapter->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1; |
| 5507 | |
Jeff Kirsher | 0585798 | 2008-09-11 19:57:00 -0700 | [diff] [blame] | 5508 | hw->hw_addr = ioremap(pci_resource_start(pdev, 0), |
| 5509 | pci_resource_len(pdev, 0)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5510 | if (!hw->hw_addr) { |
| 5511 | err = -EIO; |
| 5512 | goto err_ioremap; |
| 5513 | } |
| 5514 | |
| 5515 | for (i = 1; i <= 5; i++) { |
| 5516 | if (pci_resource_len(pdev, i) == 0) |
| 5517 | continue; |
| 5518 | } |
| 5519 | |
Stephen Hemminger | 0edc352 | 2008-11-19 22:24:29 -0800 | [diff] [blame] | 5520 | netdev->netdev_ops = &ixgbe_netdev_ops; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5521 | ixgbe_set_ethtool_ops(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5522 | netdev->watchdog_timeo = 5 * HZ; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5523 | strcpy(netdev->name, pci_name(pdev)); |
| 5524 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5525 | adapter->bd_number = cards_found; |
| 5526 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5527 | /* Setup hw api */ |
| 5528 | memcpy(&hw->mac.ops, ii->mac_ops, sizeof(hw->mac.ops)); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 5529 | hw->mac.type = ii->mac; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5530 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5531 | /* EEPROM */ |
| 5532 | memcpy(&hw->eeprom.ops, ii->eeprom_ops, sizeof(hw->eeprom.ops)); |
| 5533 | eec = IXGBE_READ_REG(hw, IXGBE_EEC); |
| 5534 | /* If EEPROM is valid (bit 8 = 1), use default otherwise use bit bang */ |
| 5535 | if (!(eec & (1 << 8))) |
| 5536 | hw->eeprom.ops.read = &ixgbe_read_eeprom_bit_bang_generic; |
| 5537 | |
| 5538 | /* PHY */ |
| 5539 | memcpy(&hw->phy.ops, ii->phy_ops, sizeof(hw->phy.ops)); |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 5540 | hw->phy.sfp_type = ixgbe_sfp_type_unknown; |
Ben Hutchings | 6b73e10 | 2009-04-29 08:08:58 +0000 | [diff] [blame] | 5541 | /* ixgbe_identify_phy_generic will set prtad and mmds properly */ |
| 5542 | hw->phy.mdio.prtad = MDIO_PRTAD_NONE; |
| 5543 | hw->phy.mdio.mmds = 0; |
| 5544 | hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; |
| 5545 | hw->phy.mdio.dev = netdev; |
| 5546 | hw->phy.mdio.mdio_read = ixgbe_mdio_read; |
| 5547 | hw->phy.mdio.mdio_write = ixgbe_mdio_write; |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 5548 | |
| 5549 | /* set up this timer and work struct before calling get_invariants |
| 5550 | * which might start the timer |
| 5551 | */ |
| 5552 | init_timer(&adapter->sfp_timer); |
| 5553 | adapter->sfp_timer.function = &ixgbe_sfp_timer; |
| 5554 | adapter->sfp_timer.data = (unsigned long) adapter; |
| 5555 | |
| 5556 | INIT_WORK(&adapter->sfp_task, ixgbe_sfp_task); |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5557 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5558 | /* multispeed fiber has its own tasklet, called from GPI SDP1 context */ |
| 5559 | INIT_WORK(&adapter->multispeed_fiber_task, ixgbe_multispeed_fiber_task); |
| 5560 | |
| 5561 | /* a new SFP+ module arrival, called from GPI SDP2 context */ |
| 5562 | INIT_WORK(&adapter->sfp_config_module_task, |
| 5563 | ixgbe_sfp_config_module_task); |
| 5564 | |
Don Skidmore | 8ca783a | 2009-05-26 20:40:47 -0700 | [diff] [blame] | 5565 | ii->get_invariants(hw); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5566 | |
| 5567 | /* setup the private structure */ |
| 5568 | err = ixgbe_sw_init(adapter); |
| 5569 | if (err) |
| 5570 | goto err_sw_init; |
| 5571 | |
Don Skidmore | bf069c9 | 2009-05-07 10:39:54 +0000 | [diff] [blame] | 5572 | /* |
| 5573 | * If there is a fan on this device and it has failed log the |
| 5574 | * failure. |
| 5575 | */ |
| 5576 | if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) { |
| 5577 | u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP); |
| 5578 | if (esdp & IXGBE_ESDP_SDP1) |
| 5579 | DPRINTK(PROBE, CRIT, |
| 5580 | "Fan has stopped, replace the adapter\n"); |
| 5581 | } |
| 5582 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5583 | /* reset_hw fills in the perm_addr as well */ |
| 5584 | err = hw->mac.ops.reset_hw(hw); |
Don Skidmore | 8ca783a | 2009-05-26 20:40:47 -0700 | [diff] [blame] | 5585 | if (err == IXGBE_ERR_SFP_NOT_PRESENT && |
| 5586 | hw->mac.type == ixgbe_mac_82598EB) { |
| 5587 | /* |
| 5588 | * Start a kernel thread to watch for a module to arrive. |
| 5589 | * Only do this for 82598, since 82599 will generate |
| 5590 | * interrupts on module arrival. |
| 5591 | */ |
| 5592 | set_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state); |
| 5593 | mod_timer(&adapter->sfp_timer, |
| 5594 | round_jiffies(jiffies + (2 * HZ))); |
| 5595 | err = 0; |
| 5596 | } else if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { |
Don Skidmore | 88d2b81 | 2009-06-30 11:43:55 +0000 | [diff] [blame] | 5597 | dev_err(&adapter->pdev->dev, "failed to initialize because " |
| 5598 | "an unsupported SFP+ module type was detected.\n" |
| 5599 | "Reload the driver after installing a supported " |
| 5600 | "module.\n"); |
PJ Waskiewicz | 04f165e | 2009-04-09 22:27:57 +0000 | [diff] [blame] | 5601 | goto err_sw_init; |
| 5602 | } else if (err) { |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5603 | dev_err(&adapter->pdev->dev, "HW Init failed: %d\n", err); |
| 5604 | goto err_sw_init; |
| 5605 | } |
| 5606 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5607 | netdev->features = NETIF_F_SG | |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5608 | NETIF_F_IP_CSUM | |
| 5609 | NETIF_F_HW_VLAN_TX | |
| 5610 | NETIF_F_HW_VLAN_RX | |
| 5611 | NETIF_F_HW_VLAN_FILTER; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5612 | |
Jesse Brandeburg | e9990a9 | 2008-08-26 04:27:24 -0700 | [diff] [blame] | 5613 | netdev->features |= NETIF_F_IPV6_CSUM; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5614 | netdev->features |= NETIF_F_TSO; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5615 | netdev->features |= NETIF_F_TSO6; |
Herbert Xu | 78b6f4c | 2009-01-18 21:49:45 -0800 | [diff] [blame] | 5616 | netdev->features |= NETIF_F_GRO; |
Jeff Kirsher | ad31c40 | 2008-06-05 04:05:30 -0700 | [diff] [blame] | 5617 | |
Jesse Brandeburg | 45a5ead | 2009-04-27 22:36:35 +0000 | [diff] [blame] | 5618 | if (adapter->hw.mac.type == ixgbe_mac_82599EB) |
| 5619 | netdev->features |= NETIF_F_SCTP_CSUM; |
| 5620 | |
Jeff Kirsher | ad31c40 | 2008-06-05 04:05:30 -0700 | [diff] [blame] | 5621 | netdev->vlan_features |= NETIF_F_TSO; |
| 5622 | netdev->vlan_features |= NETIF_F_TSO6; |
Jesse Brandeburg | 22f32b7a5 | 2008-08-26 04:27:18 -0700 | [diff] [blame] | 5623 | netdev->vlan_features |= NETIF_F_IP_CSUM; |
Alexander Duyck | cd1da50 | 2009-08-25 04:47:50 +0000 | [diff] [blame] | 5624 | netdev->vlan_features |= NETIF_F_IPV6_CSUM; |
Jeff Kirsher | ad31c40 | 2008-06-05 04:05:30 -0700 | [diff] [blame] | 5625 | netdev->vlan_features |= NETIF_F_SG; |
| 5626 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 5627 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) |
| 5628 | adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED; |
| 5629 | |
Jeff Kirsher | 7a6b6f5 | 2008-11-25 01:02:08 -0800 | [diff] [blame] | 5630 | #ifdef CONFIG_IXGBE_DCB |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 5631 | netdev->dcbnl_ops = &dcbnl_ops; |
| 5632 | #endif |
| 5633 | |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5634 | #ifdef IXGBE_FCOE |
Yi Zou | 0d55158 | 2009-07-22 14:07:12 +0000 | [diff] [blame] | 5635 | if (adapter->flags & IXGBE_FLAG_FCOE_CAPABLE) { |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5636 | if (hw->mac.ops.get_device_caps) { |
| 5637 | hw->mac.ops.get_device_caps(hw, &device_caps); |
Yi Zou | 0d55158 | 2009-07-22 14:07:12 +0000 | [diff] [blame] | 5638 | if (device_caps & IXGBE_DEVICE_CAPS_FCOE_OFFLOADS) |
| 5639 | adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE; |
Yi Zou | eacd73f | 2009-05-13 13:11:06 +0000 | [diff] [blame] | 5640 | } |
| 5641 | } |
| 5642 | #endif /* IXGBE_FCOE */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5643 | if (pci_using_dac) |
| 5644 | netdev->features |= NETIF_F_HIGHDMA; |
| 5645 | |
Peter P Waskiewicz Jr | 0c19d6a | 2009-07-30 12:25:28 +0000 | [diff] [blame] | 5646 | if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) |
Alexander Duyck | f8212f9 | 2009-04-27 22:42:37 +0000 | [diff] [blame] | 5647 | netdev->features |= NETIF_F_LRO; |
| 5648 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5649 | /* make sure the EEPROM is good */ |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5650 | if (hw->eeprom.ops.validate_checksum(hw, NULL) < 0) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5651 | dev_err(&pdev->dev, "The EEPROM Checksum Is Not Valid\n"); |
| 5652 | err = -EIO; |
| 5653 | goto err_eeprom; |
| 5654 | } |
| 5655 | |
| 5656 | memcpy(netdev->dev_addr, hw->mac.perm_addr, netdev->addr_len); |
| 5657 | memcpy(netdev->perm_addr, hw->mac.perm_addr, netdev->addr_len); |
| 5658 | |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5659 | if (ixgbe_validate_mac_addr(netdev->perm_addr)) { |
| 5660 | dev_err(&pdev->dev, "invalid MAC address\n"); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5661 | err = -EIO; |
| 5662 | goto err_eeprom; |
| 5663 | } |
| 5664 | |
| 5665 | init_timer(&adapter->watchdog_timer); |
| 5666 | adapter->watchdog_timer.function = &ixgbe_watchdog; |
| 5667 | adapter->watchdog_timer.data = (unsigned long)adapter; |
| 5668 | |
| 5669 | INIT_WORK(&adapter->reset_task, ixgbe_reset_task); |
Jesse Brandeburg | cf8280e | 2008-09-11 19:55:32 -0700 | [diff] [blame] | 5670 | INIT_WORK(&adapter->watchdog_task, ixgbe_watchdog_task); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5671 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 5672 | err = ixgbe_init_interrupt_scheme(adapter); |
| 5673 | if (err) |
| 5674 | goto err_sw_init; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5675 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5676 | switch (pdev->device) { |
| 5677 | case IXGBE_DEV_ID_82599_KX4: |
Waskiewicz Jr, Peter P | 495dce1 | 2009-04-23 11:15:18 +0000 | [diff] [blame] | 5678 | adapter->wol = (IXGBE_WUFC_MAG | IXGBE_WUFC_EX | |
| 5679 | IXGBE_WUFC_MC | IXGBE_WUFC_BC); |
Peter P Waskiewicz Jr | bdf0a55 | 2009-06-04 11:09:58 +0000 | [diff] [blame] | 5680 | /* Enable ACPI wakeup in GRC */ |
| 5681 | IXGBE_WRITE_REG(hw, IXGBE_GRC, |
| 5682 | (IXGBE_READ_REG(hw, IXGBE_GRC) & ~IXGBE_GRC_APME)); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5683 | break; |
| 5684 | default: |
| 5685 | adapter->wol = 0; |
| 5686 | break; |
| 5687 | } |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5688 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); |
| 5689 | |
PJ Waskiewicz | 04f165e | 2009-04-09 22:27:57 +0000 | [diff] [blame] | 5690 | /* pick up the PCI bus settings for reporting later */ |
| 5691 | hw->mac.ops.get_bus_info(hw); |
| 5692 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5693 | /* print bus type/speed/width info */ |
Johannes Berg | 7c510e4 | 2008-10-27 17:47:26 -0700 | [diff] [blame] | 5694 | dev_info(&pdev->dev, "(PCI Express:%s:%s) %pM\n", |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5695 | ((hw->bus.speed == ixgbe_bus_speed_5000) ? "5.0Gb/s": |
| 5696 | (hw->bus.speed == ixgbe_bus_speed_2500) ? "2.5Gb/s":"Unknown"), |
| 5697 | ((hw->bus.width == ixgbe_bus_width_pcie_x8) ? "Width x8" : |
| 5698 | (hw->bus.width == ixgbe_bus_width_pcie_x4) ? "Width x4" : |
| 5699 | (hw->bus.width == ixgbe_bus_width_pcie_x1) ? "Width x1" : |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5700 | "Unknown"), |
Johannes Berg | 7c510e4 | 2008-10-27 17:47:26 -0700 | [diff] [blame] | 5701 | netdev->dev_addr); |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5702 | ixgbe_read_pba_num_generic(hw, &part_num); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5703 | if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present) |
| 5704 | dev_info(&pdev->dev, "MAC: %d, PHY: %d, SFP+: %d, PBA No: %06x-%03x\n", |
| 5705 | hw->mac.type, hw->phy.type, hw->phy.sfp_type, |
| 5706 | (part_num >> 8), (part_num & 0xff)); |
| 5707 | else |
| 5708 | dev_info(&pdev->dev, "MAC: %d, PHY: %d, PBA No: %06x-%03x\n", |
| 5709 | hw->mac.type, hw->phy.type, |
| 5710 | (part_num >> 8), (part_num & 0xff)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5711 | |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5712 | if (hw->bus.width <= ixgbe_bus_width_pcie_x4) { |
Auke Kok | 0c254d8 | 2008-02-11 09:25:56 -0800 | [diff] [blame] | 5713 | dev_warn(&pdev->dev, "PCI-Express bandwidth available for " |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5714 | "this card is not sufficient for optimal " |
| 5715 | "performance.\n"); |
Auke Kok | 0c254d8 | 2008-02-11 09:25:56 -0800 | [diff] [blame] | 5716 | dev_warn(&pdev->dev, "For optimal performance a x8 " |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5717 | "PCI-Express slot is required.\n"); |
Auke Kok | 0c254d8 | 2008-02-11 09:25:56 -0800 | [diff] [blame] | 5718 | } |
| 5719 | |
Peter P Waskiewicz Jr | 34b0368 | 2009-02-05 23:54:42 -0800 | [diff] [blame] | 5720 | /* save off EEPROM version number */ |
| 5721 | hw->eeprom.ops.read(hw, 0x29, &adapter->eeprom_version); |
| 5722 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5723 | /* reset the hardware with the new settings */ |
Peter P Waskiewicz Jr | 794caeb | 2009-06-04 16:02:24 +0000 | [diff] [blame] | 5724 | err = hw->mac.ops.start_hw(hw); |
Jesse Brandeburg | c44ade9 | 2008-09-11 19:59:59 -0700 | [diff] [blame] | 5725 | |
Peter P Waskiewicz Jr | 794caeb | 2009-06-04 16:02:24 +0000 | [diff] [blame] | 5726 | if (err == IXGBE_ERR_EEPROM_VERSION) { |
| 5727 | /* We are running on a pre-production device, log a warning */ |
| 5728 | dev_warn(&pdev->dev, "This device is a pre-production " |
| 5729 | "adapter/LOM. Please be aware there may be issues " |
| 5730 | "associated with your hardware. If you are " |
| 5731 | "experiencing problems please contact your Intel or " |
| 5732 | "hardware representative who provided you with this " |
| 5733 | "hardware.\n"); |
| 5734 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5735 | strcpy(netdev->name, "eth%d"); |
| 5736 | err = register_netdev(netdev); |
| 5737 | if (err) |
| 5738 | goto err_register; |
| 5739 | |
Jesse Brandeburg | 5438646 | 2009-04-17 20:44:27 +0000 | [diff] [blame] | 5740 | /* carrier off reporting is important to ethtool even BEFORE open */ |
| 5741 | netif_carrier_off(netdev); |
| 5742 | |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 5743 | if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || |
| 5744 | adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) |
| 5745 | INIT_WORK(&adapter->fdir_reinit_task, ixgbe_fdir_reinit_task); |
| 5746 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 5747 | #ifdef CONFIG_IXGBE_DCA |
Denis V. Lunev | 652f093 | 2008-03-27 14:39:17 +0300 | [diff] [blame] | 5748 | if (dca_add_requester(&pdev->dev) == 0) { |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 5749 | adapter->flags |= IXGBE_FLAG_DCA_ENABLED; |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 5750 | ixgbe_setup_dca(adapter); |
| 5751 | } |
| 5752 | #endif |
PJ Waskiewicz | 0365e6e | 2009-05-17 12:32:25 +0000 | [diff] [blame] | 5753 | /* add san mac addr to netdev */ |
| 5754 | ixgbe_add_sanmac_netdev(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5755 | |
| 5756 | dev_info(&pdev->dev, "Intel(R) 10 Gigabit Network Connection\n"); |
| 5757 | cards_found++; |
| 5758 | return 0; |
| 5759 | |
| 5760 | err_register: |
Ayyappan Veeraiyan | 5eba369 | 2008-02-01 15:59:04 -0800 | [diff] [blame] | 5761 | ixgbe_release_hw_control(adapter); |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 5762 | ixgbe_clear_interrupt_scheme(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5763 | err_sw_init: |
| 5764 | err_eeprom: |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 5765 | clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state); |
| 5766 | del_timer_sync(&adapter->sfp_timer); |
| 5767 | cancel_work_sync(&adapter->sfp_task); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5768 | cancel_work_sync(&adapter->multispeed_fiber_task); |
| 5769 | cancel_work_sync(&adapter->sfp_config_module_task); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5770 | iounmap(hw->hw_addr); |
| 5771 | err_ioremap: |
| 5772 | free_netdev(netdev); |
| 5773 | err_alloc_etherdev: |
gouji-new | 9ce7766 | 2009-05-06 10:44:45 +0000 | [diff] [blame] | 5774 | pci_release_selected_regions(pdev, pci_select_bars(pdev, |
| 5775 | IORESOURCE_MEM)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5776 | err_pci_reg: |
| 5777 | err_dma: |
| 5778 | pci_disable_device(pdev); |
| 5779 | return err; |
| 5780 | } |
| 5781 | |
| 5782 | /** |
| 5783 | * ixgbe_remove - Device Removal Routine |
| 5784 | * @pdev: PCI device information struct |
| 5785 | * |
| 5786 | * ixgbe_remove is called by the PCI subsystem to alert the driver |
| 5787 | * that it should release a PCI device. The could be caused by a |
| 5788 | * Hot-Plug event, or because the driver is going to be removed from |
| 5789 | * memory. |
| 5790 | **/ |
| 5791 | static void __devexit ixgbe_remove(struct pci_dev *pdev) |
| 5792 | { |
| 5793 | struct net_device *netdev = pci_get_drvdata(pdev); |
| 5794 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5795 | int err; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5796 | |
| 5797 | set_bit(__IXGBE_DOWN, &adapter->state); |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 5798 | /* clear the module not found bit to make sure the worker won't |
| 5799 | * reschedule |
| 5800 | */ |
| 5801 | clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5802 | del_timer_sync(&adapter->watchdog_timer); |
| 5803 | |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 5804 | del_timer_sync(&adapter->sfp_timer); |
| 5805 | cancel_work_sync(&adapter->watchdog_task); |
| 5806 | cancel_work_sync(&adapter->sfp_task); |
PJ Waskiewicz | e8e2635 | 2009-02-27 15:45:05 +0000 | [diff] [blame] | 5807 | cancel_work_sync(&adapter->multispeed_fiber_task); |
| 5808 | cancel_work_sync(&adapter->sfp_config_module_task); |
Peter P Waskiewicz Jr | c4cf55e | 2009-06-04 16:01:43 +0000 | [diff] [blame] | 5809 | if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || |
| 5810 | adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) |
| 5811 | cancel_work_sync(&adapter->fdir_reinit_task); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5812 | flush_scheduled_work(); |
| 5813 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 5814 | #ifdef CONFIG_IXGBE_DCA |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 5815 | if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) { |
| 5816 | adapter->flags &= ~IXGBE_FLAG_DCA_ENABLED; |
| 5817 | dca_remove_requester(&pdev->dev); |
| 5818 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, 1); |
| 5819 | } |
| 5820 | |
| 5821 | #endif |
Yi Zou | 332d4a7 | 2009-05-13 13:11:53 +0000 | [diff] [blame] | 5822 | #ifdef IXGBE_FCOE |
| 5823 | if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) |
| 5824 | ixgbe_cleanup_fcoe(adapter); |
| 5825 | |
| 5826 | #endif /* IXGBE_FCOE */ |
PJ Waskiewicz | 0365e6e | 2009-05-17 12:32:25 +0000 | [diff] [blame] | 5827 | |
| 5828 | /* remove the added san mac */ |
| 5829 | ixgbe_del_sanmac_netdev(netdev); |
| 5830 | |
Donald Skidmore | c4900be | 2008-11-20 21:11:42 -0800 | [diff] [blame] | 5831 | if (netdev->reg_state == NETREG_REGISTERED) |
| 5832 | unregister_netdev(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5833 | |
Alexander Duyck | 7a921c9 | 2009-05-06 10:43:28 +0000 | [diff] [blame] | 5834 | ixgbe_clear_interrupt_scheme(adapter); |
Ayyappan Veeraiyan | 5eba369 | 2008-02-01 15:59:04 -0800 | [diff] [blame] | 5835 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 5836 | ixgbe_release_hw_control(adapter); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5837 | |
| 5838 | iounmap(adapter->hw.hw_addr); |
gouji-new | 9ce7766 | 2009-05-06 10:44:45 +0000 | [diff] [blame] | 5839 | pci_release_selected_regions(pdev, pci_select_bars(pdev, |
| 5840 | IORESOURCE_MEM)); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5841 | |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 5842 | DPRINTK(PROBE, INFO, "complete\n"); |
Ayyappan Veeraiyan | 021230d | 2008-03-03 15:03:45 -0800 | [diff] [blame] | 5843 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5844 | free_netdev(netdev); |
| 5845 | |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5846 | err = pci_disable_pcie_error_reporting(pdev); |
| 5847 | if (err) |
| 5848 | dev_err(&pdev->dev, |
| 5849 | "pci_disable_pcie_error_reporting failed 0x%x\n", err); |
| 5850 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5851 | pci_disable_device(pdev); |
| 5852 | } |
| 5853 | |
| 5854 | /** |
| 5855 | * ixgbe_io_error_detected - called when PCI error is detected |
| 5856 | * @pdev: Pointer to PCI device |
| 5857 | * @state: The current pci connection state |
| 5858 | * |
| 5859 | * This function is called after a PCI bus error affecting |
| 5860 | * this device has been detected. |
| 5861 | */ |
| 5862 | static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5863 | pci_channel_state_t state) |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5864 | { |
| 5865 | struct net_device *netdev = pci_get_drvdata(pdev); |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 5866 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5867 | |
| 5868 | netif_device_detach(netdev); |
| 5869 | |
Breno Leitao | 3044b8d | 2009-05-06 10:44:26 +0000 | [diff] [blame] | 5870 | if (state == pci_channel_io_perm_failure) |
| 5871 | return PCI_ERS_RESULT_DISCONNECT; |
| 5872 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5873 | if (netif_running(netdev)) |
| 5874 | ixgbe_down(adapter); |
| 5875 | pci_disable_device(pdev); |
| 5876 | |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5877 | /* Request a slot reset. */ |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5878 | return PCI_ERS_RESULT_NEED_RESET; |
| 5879 | } |
| 5880 | |
| 5881 | /** |
| 5882 | * ixgbe_io_slot_reset - called after the pci bus has been reset. |
| 5883 | * @pdev: Pointer to PCI device |
| 5884 | * |
| 5885 | * Restart the card from scratch, as if from a cold-boot. |
| 5886 | */ |
| 5887 | static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev) |
| 5888 | { |
| 5889 | struct net_device *netdev = pci_get_drvdata(pdev); |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 5890 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5891 | pci_ers_result_t result; |
| 5892 | int err; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5893 | |
gouji-new | 9ce7766 | 2009-05-06 10:44:45 +0000 | [diff] [blame] | 5894 | if (pci_enable_device_mem(pdev)) { |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5895 | DPRINTK(PROBE, ERR, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5896 | "Cannot re-enable PCI device after reset.\n"); |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5897 | result = PCI_ERS_RESULT_DISCONNECT; |
| 5898 | } else { |
| 5899 | pci_set_master(pdev); |
| 5900 | pci_restore_state(pdev); |
| 5901 | |
Don Skidmore | dd4d8ca | 2009-04-29 00:22:31 -0700 | [diff] [blame] | 5902 | pci_wake_from_d3(pdev, false); |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5903 | |
| 5904 | ixgbe_reset(adapter); |
PJ Waskiewicz | 8851253 | 2009-03-13 22:15:10 +0000 | [diff] [blame] | 5905 | IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5906 | result = PCI_ERS_RESULT_RECOVERED; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5907 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5908 | |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5909 | err = pci_cleanup_aer_uncorrect_error_status(pdev); |
| 5910 | if (err) { |
| 5911 | dev_err(&pdev->dev, |
| 5912 | "pci_cleanup_aer_uncorrect_error_status failed 0x%0x\n", err); |
| 5913 | /* non-fatal, continue */ |
| 5914 | } |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5915 | |
Peter P Waskiewicz Jr | 6fabd71 | 2008-12-10 01:13:08 -0800 | [diff] [blame] | 5916 | return result; |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5917 | } |
| 5918 | |
| 5919 | /** |
| 5920 | * ixgbe_io_resume - called when traffic can start flowing again. |
| 5921 | * @pdev: Pointer to PCI device |
| 5922 | * |
| 5923 | * This callback is called when the error recovery driver tells us that |
| 5924 | * its OK to resume normal operation. |
| 5925 | */ |
| 5926 | static void ixgbe_io_resume(struct pci_dev *pdev) |
| 5927 | { |
| 5928 | struct net_device *netdev = pci_get_drvdata(pdev); |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 5929 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5930 | |
| 5931 | if (netif_running(netdev)) { |
| 5932 | if (ixgbe_up(adapter)) { |
| 5933 | DPRINTK(PROBE, INFO, "ixgbe_up failed after reset\n"); |
| 5934 | return; |
| 5935 | } |
| 5936 | } |
| 5937 | |
| 5938 | netif_device_attach(netdev); |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5939 | } |
| 5940 | |
| 5941 | static struct pci_error_handlers ixgbe_err_handler = { |
| 5942 | .error_detected = ixgbe_io_error_detected, |
| 5943 | .slot_reset = ixgbe_io_slot_reset, |
| 5944 | .resume = ixgbe_io_resume, |
| 5945 | }; |
| 5946 | |
| 5947 | static struct pci_driver ixgbe_driver = { |
| 5948 | .name = ixgbe_driver_name, |
| 5949 | .id_table = ixgbe_pci_tbl, |
| 5950 | .probe = ixgbe_probe, |
| 5951 | .remove = __devexit_p(ixgbe_remove), |
| 5952 | #ifdef CONFIG_PM |
| 5953 | .suspend = ixgbe_suspend, |
| 5954 | .resume = ixgbe_resume, |
| 5955 | #endif |
| 5956 | .shutdown = ixgbe_shutdown, |
| 5957 | .err_handler = &ixgbe_err_handler |
| 5958 | }; |
| 5959 | |
| 5960 | /** |
| 5961 | * ixgbe_init_module - Driver Registration Routine |
| 5962 | * |
| 5963 | * ixgbe_init_module is the first routine called when the driver is |
| 5964 | * loaded. All it does is register with the PCI subsystem. |
| 5965 | **/ |
| 5966 | static int __init ixgbe_init_module(void) |
| 5967 | { |
| 5968 | int ret; |
| 5969 | printk(KERN_INFO "%s: %s - version %s\n", ixgbe_driver_name, |
| 5970 | ixgbe_driver_string, ixgbe_driver_version); |
| 5971 | |
| 5972 | printk(KERN_INFO "%s: %s\n", ixgbe_driver_name, ixgbe_copyright); |
| 5973 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 5974 | #ifdef CONFIG_IXGBE_DCA |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 5975 | dca_register_notify(&dca_notifier); |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 5976 | #endif |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 5977 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5978 | ret = pci_register_driver(&ixgbe_driver); |
| 5979 | return ret; |
| 5980 | } |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 5981 | |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5982 | module_init(ixgbe_init_module); |
| 5983 | |
| 5984 | /** |
| 5985 | * ixgbe_exit_module - Driver Exit Cleanup Routine |
| 5986 | * |
| 5987 | * ixgbe_exit_module is called just before the driver is removed |
| 5988 | * from memory. |
| 5989 | **/ |
| 5990 | static void __exit ixgbe_exit_module(void) |
| 5991 | { |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 5992 | #ifdef CONFIG_IXGBE_DCA |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 5993 | dca_unregister_notify(&dca_notifier); |
| 5994 | #endif |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 5995 | pci_unregister_driver(&ixgbe_driver); |
| 5996 | } |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 5997 | |
Jeff Garzik | 5dd2d33 | 2008-10-16 05:09:31 -0400 | [diff] [blame] | 5998 | #ifdef CONFIG_IXGBE_DCA |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 5999 | static int ixgbe_notify_dca(struct notifier_block *nb, unsigned long event, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 6000 | void *p) |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 6001 | { |
| 6002 | int ret_val; |
| 6003 | |
| 6004 | ret_val = driver_for_each_device(&ixgbe_driver.driver, NULL, &event, |
Peter P Waskiewicz | b461724 | 2008-09-11 20:04:46 -0700 | [diff] [blame] | 6005 | __ixgbe_notify_dca); |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 6006 | |
| 6007 | return ret_val ? NOTIFY_BAD : NOTIFY_DONE; |
| 6008 | } |
Jeb Cramer | bd0362d | 2008-03-03 15:04:02 -0800 | [diff] [blame] | 6009 | |
Alexander Duyck | b453368 | 2009-03-31 21:32:42 +0000 | [diff] [blame] | 6010 | #endif /* CONFIG_IXGBE_DCA */ |
| 6011 | #ifdef DEBUG |
| 6012 | /** |
| 6013 | * ixgbe_get_hw_dev_name - return device name string |
| 6014 | * used by hardware layer to print debugging information |
| 6015 | **/ |
| 6016 | char *ixgbe_get_hw_dev_name(struct ixgbe_hw *hw) |
| 6017 | { |
| 6018 | struct ixgbe_adapter *adapter = hw->back; |
| 6019 | return adapter->netdev->name; |
| 6020 | } |
| 6021 | |
| 6022 | #endif |
Auke Kok | 9a799d7 | 2007-09-15 14:07:45 -0700 | [diff] [blame] | 6023 | module_exit(ixgbe_exit_module); |
| 6024 | |
| 6025 | /* ixgbe_main.c */ |