Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver |
Catherine Sullivan | eaab59e | 2016-01-13 16:51:44 -0800 | [diff] [blame] | 4 | * Copyright(c) 2013 - 2016 Intel Corporation. |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [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 | * |
Jesse Brandeburg | b831607 | 2014-04-05 07:46:11 +0000 | [diff] [blame] | 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 18 | * The full GNU General Public License is included in this distribution in |
| 19 | * the file called "COPYING". |
| 20 | * |
| 21 | * Contact Information: |
| 22 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 24 | * |
| 25 | ******************************************************************************/ |
| 26 | |
| 27 | #include "i40evf.h" |
| 28 | #include "i40e_prototype.h" |
| 29 | static int i40evf_setup_all_tx_resources(struct i40evf_adapter *adapter); |
| 30 | static int i40evf_setup_all_rx_resources(struct i40evf_adapter *adapter); |
| 31 | static int i40evf_close(struct net_device *netdev); |
| 32 | |
| 33 | char i40evf_driver_name[] = "i40evf"; |
| 34 | static const char i40evf_driver_string[] = |
Catherine Sullivan | eaab59e | 2016-01-13 16:51:44 -0800 | [diff] [blame] | 35 | "Intel(R) 40-10 Gigabit Virtual Function Network Driver"; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 36 | |
Mitch Williams | 69ebe955 | 2015-11-19 11:34:24 -0800 | [diff] [blame] | 37 | #define DRV_KERN "-k" |
| 38 | |
| 39 | #define DRV_VERSION_MAJOR 1 |
Bimmy Pujari | 0706195 | 2016-05-16 10:26:45 -0700 | [diff] [blame] | 40 | #define DRV_VERSION_MINOR 6 |
Bimmy Pujari | cf465fe | 2016-09-27 11:28:54 -0700 | [diff] [blame] | 41 | #define DRV_VERSION_BUILD 21 |
Mitch Williams | 69ebe955 | 2015-11-19 11:34:24 -0800 | [diff] [blame] | 42 | #define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ |
| 43 | __stringify(DRV_VERSION_MINOR) "." \ |
| 44 | __stringify(DRV_VERSION_BUILD) \ |
| 45 | DRV_KERN |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 46 | const char i40evf_driver_version[] = DRV_VERSION; |
| 47 | static const char i40evf_copyright[] = |
Catherine Sullivan | bf41846 | 2015-07-10 19:36:10 -0400 | [diff] [blame] | 48 | "Copyright (c) 2013 - 2015 Intel Corporation."; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 49 | |
| 50 | /* i40evf_pci_tbl - PCI Device ID Table |
| 51 | * |
| 52 | * Wildcard entries (PCI_ANY_ID) should come last |
| 53 | * Last entry must be all 0s |
| 54 | * |
| 55 | * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, |
| 56 | * Class, Class Mask, private data (not used) } |
| 57 | */ |
Benoit Taine | 9baa3c3 | 2014-08-08 15:56:03 +0200 | [diff] [blame] | 58 | static const struct pci_device_id i40evf_pci_tbl[] = { |
Shannon Nelson | ab60085 | 2014-01-17 15:36:39 -0800 | [diff] [blame] | 59 | {PCI_VDEVICE(INTEL, I40E_DEV_ID_VF), 0}, |
Joshua Hay | 9287141 | 2016-06-20 09:10:37 -0700 | [diff] [blame] | 60 | {PCI_VDEVICE(INTEL, I40E_DEV_ID_VF_HV), 0}, |
Anjali Singhai Jain | 87e6c1d | 2015-06-05 12:20:25 -0400 | [diff] [blame] | 61 | {PCI_VDEVICE(INTEL, I40E_DEV_ID_X722_VF), 0}, |
Joshua Hay | 9287141 | 2016-06-20 09:10:37 -0700 | [diff] [blame] | 62 | {PCI_VDEVICE(INTEL, I40E_DEV_ID_X722_VF_HV), 0}, |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 63 | /* required last entry */ |
| 64 | {0, } |
| 65 | }; |
| 66 | |
| 67 | MODULE_DEVICE_TABLE(pci, i40evf_pci_tbl); |
| 68 | |
| 69 | MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); |
| 70 | MODULE_DESCRIPTION("Intel(R) XL710 X710 Virtual Function Network Driver"); |
| 71 | MODULE_LICENSE("GPL"); |
| 72 | MODULE_VERSION(DRV_VERSION); |
| 73 | |
Jesse Brandeburg | 2803b16 | 2015-12-22 14:25:08 -0800 | [diff] [blame] | 74 | static struct workqueue_struct *i40evf_wq; |
| 75 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 76 | /** |
| 77 | * i40evf_allocate_dma_mem_d - OS specific memory alloc for shared code |
| 78 | * @hw: pointer to the HW structure |
| 79 | * @mem: ptr to mem struct to fill out |
| 80 | * @size: size of memory requested |
| 81 | * @alignment: what to align the allocation to |
| 82 | **/ |
| 83 | i40e_status i40evf_allocate_dma_mem_d(struct i40e_hw *hw, |
| 84 | struct i40e_dma_mem *mem, |
| 85 | u64 size, u32 alignment) |
| 86 | { |
| 87 | struct i40evf_adapter *adapter = (struct i40evf_adapter *)hw->back; |
| 88 | |
| 89 | if (!mem) |
| 90 | return I40E_ERR_PARAM; |
| 91 | |
| 92 | mem->size = ALIGN(size, alignment); |
| 93 | mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, |
| 94 | (dma_addr_t *)&mem->pa, GFP_KERNEL); |
| 95 | if (mem->va) |
| 96 | return 0; |
| 97 | else |
| 98 | return I40E_ERR_NO_MEMORY; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * i40evf_free_dma_mem_d - OS specific memory free for shared code |
| 103 | * @hw: pointer to the HW structure |
| 104 | * @mem: ptr to mem struct to free |
| 105 | **/ |
| 106 | i40e_status i40evf_free_dma_mem_d(struct i40e_hw *hw, struct i40e_dma_mem *mem) |
| 107 | { |
| 108 | struct i40evf_adapter *adapter = (struct i40evf_adapter *)hw->back; |
| 109 | |
| 110 | if (!mem || !mem->va) |
| 111 | return I40E_ERR_PARAM; |
| 112 | dma_free_coherent(&adapter->pdev->dev, mem->size, |
| 113 | mem->va, (dma_addr_t)mem->pa); |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * i40evf_allocate_virt_mem_d - OS specific memory alloc for shared code |
| 119 | * @hw: pointer to the HW structure |
| 120 | * @mem: ptr to mem struct to fill out |
| 121 | * @size: size of memory requested |
| 122 | **/ |
| 123 | i40e_status i40evf_allocate_virt_mem_d(struct i40e_hw *hw, |
| 124 | struct i40e_virt_mem *mem, u32 size) |
| 125 | { |
| 126 | if (!mem) |
| 127 | return I40E_ERR_PARAM; |
| 128 | |
| 129 | mem->size = size; |
| 130 | mem->va = kzalloc(size, GFP_KERNEL); |
| 131 | |
| 132 | if (mem->va) |
| 133 | return 0; |
| 134 | else |
| 135 | return I40E_ERR_NO_MEMORY; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * i40evf_free_virt_mem_d - OS specific memory free for shared code |
| 140 | * @hw: pointer to the HW structure |
| 141 | * @mem: ptr to mem struct to free |
| 142 | **/ |
| 143 | i40e_status i40evf_free_virt_mem_d(struct i40e_hw *hw, |
| 144 | struct i40e_virt_mem *mem) |
| 145 | { |
| 146 | if (!mem) |
| 147 | return I40E_ERR_PARAM; |
| 148 | |
| 149 | /* it's ok to kfree a NULL pointer */ |
| 150 | kfree(mem->va); |
| 151 | |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * i40evf_debug_d - OS dependent version of debug printing |
| 157 | * @hw: pointer to the HW structure |
| 158 | * @mask: debug level mask |
| 159 | * @fmt_str: printf-type format description |
| 160 | **/ |
| 161 | void i40evf_debug_d(void *hw, u32 mask, char *fmt_str, ...) |
| 162 | { |
| 163 | char buf[512]; |
| 164 | va_list argptr; |
| 165 | |
| 166 | if (!(mask & ((struct i40e_hw *)hw)->debug_mask)) |
| 167 | return; |
| 168 | |
| 169 | va_start(argptr, fmt_str); |
| 170 | vsnprintf(buf, sizeof(buf), fmt_str, argptr); |
| 171 | va_end(argptr); |
| 172 | |
| 173 | /* the debug string is already formatted with a newline */ |
| 174 | pr_info("%s", buf); |
| 175 | } |
| 176 | |
| 177 | /** |
Mitch Williams | 00e5ec4 | 2016-01-15 14:33:10 -0800 | [diff] [blame] | 178 | * i40evf_schedule_reset - Set the flags and schedule a reset event |
| 179 | * @adapter: board private structure |
| 180 | **/ |
| 181 | void i40evf_schedule_reset(struct i40evf_adapter *adapter) |
| 182 | { |
| 183 | if (!(adapter->flags & |
| 184 | (I40EVF_FLAG_RESET_PENDING | I40EVF_FLAG_RESET_NEEDED))) { |
| 185 | adapter->flags |= I40EVF_FLAG_RESET_NEEDED; |
| 186 | schedule_work(&adapter->reset_task); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /** |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 191 | * i40evf_tx_timeout - Respond to a Tx Hang |
| 192 | * @netdev: network interface device structure |
| 193 | **/ |
| 194 | static void i40evf_tx_timeout(struct net_device *netdev) |
| 195 | { |
| 196 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 197 | |
| 198 | adapter->tx_timeout_count++; |
Mitch Williams | 00e5ec4 | 2016-01-15 14:33:10 -0800 | [diff] [blame] | 199 | i40evf_schedule_reset(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | /** |
| 203 | * i40evf_misc_irq_disable - Mask off interrupt generation on the NIC |
| 204 | * @adapter: board private structure |
| 205 | **/ |
| 206 | static void i40evf_misc_irq_disable(struct i40evf_adapter *adapter) |
| 207 | { |
| 208 | struct i40e_hw *hw = &adapter->hw; |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 209 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 210 | wr32(hw, I40E_VFINT_DYN_CTL01, 0); |
| 211 | |
| 212 | /* read flush */ |
| 213 | rd32(hw, I40E_VFGEN_RSTAT); |
| 214 | |
| 215 | synchronize_irq(adapter->msix_entries[0].vector); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * i40evf_misc_irq_enable - Enable default interrupt generation settings |
| 220 | * @adapter: board private structure |
| 221 | **/ |
| 222 | static void i40evf_misc_irq_enable(struct i40evf_adapter *adapter) |
| 223 | { |
| 224 | struct i40e_hw *hw = &adapter->hw; |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 225 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 226 | wr32(hw, I40E_VFINT_DYN_CTL01, I40E_VFINT_DYN_CTL01_INTENA_MASK | |
| 227 | I40E_VFINT_DYN_CTL01_ITR_INDX_MASK); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 228 | wr32(hw, I40E_VFINT_ICR0_ENA1, I40E_VFINT_ICR0_ENA1_ADMINQ_MASK); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 229 | |
| 230 | /* read flush */ |
| 231 | rd32(hw, I40E_VFGEN_RSTAT); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * i40evf_irq_disable - Mask off interrupt generation on the NIC |
| 236 | * @adapter: board private structure |
| 237 | **/ |
| 238 | static void i40evf_irq_disable(struct i40evf_adapter *adapter) |
| 239 | { |
| 240 | int i; |
| 241 | struct i40e_hw *hw = &adapter->hw; |
| 242 | |
Mitch Williams | dbb01c8 | 2014-02-20 19:29:07 -0800 | [diff] [blame] | 243 | if (!adapter->msix_entries) |
| 244 | return; |
| 245 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 246 | for (i = 1; i < adapter->num_msix_vectors; i++) { |
| 247 | wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), 0); |
| 248 | synchronize_irq(adapter->msix_entries[i].vector); |
| 249 | } |
| 250 | /* read flush */ |
| 251 | rd32(hw, I40E_VFGEN_RSTAT); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | /** |
| 255 | * i40evf_irq_enable_queues - Enable interrupt for specified queues |
| 256 | * @adapter: board private structure |
| 257 | * @mask: bitmap of queues to enable |
| 258 | **/ |
| 259 | void i40evf_irq_enable_queues(struct i40evf_adapter *adapter, u32 mask) |
| 260 | { |
| 261 | struct i40e_hw *hw = &adapter->hw; |
| 262 | int i; |
| 263 | |
| 264 | for (i = 1; i < adapter->num_msix_vectors; i++) { |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 265 | if (mask & BIT(i - 1)) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 266 | wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), |
| 267 | I40E_VFINT_DYN_CTLN1_INTENA_MASK | |
Jesse Brandeburg | 97bf75f | 2015-02-27 09:18:32 +0000 | [diff] [blame] | 268 | I40E_VFINT_DYN_CTLN1_ITR_INDX_MASK | |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 269 | I40E_VFINT_DYN_CTLN1_CLEARPBA_MASK); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * i40evf_fire_sw_int - Generate SW interrupt for specified vectors |
| 276 | * @adapter: board private structure |
| 277 | * @mask: bitmap of vectors to trigger |
| 278 | **/ |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 279 | static void i40evf_fire_sw_int(struct i40evf_adapter *adapter, u32 mask) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 280 | { |
| 281 | struct i40e_hw *hw = &adapter->hw; |
| 282 | int i; |
Mitch Williams | d82acb3 | 2015-11-06 15:26:06 -0800 | [diff] [blame] | 283 | u32 dyn_ctl; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 284 | |
Mitch Williams | 164ec1b | 2014-06-04 08:45:19 +0000 | [diff] [blame] | 285 | if (mask & 1) { |
| 286 | dyn_ctl = rd32(hw, I40E_VFINT_DYN_CTL01); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 287 | dyn_ctl |= I40E_VFINT_DYN_CTLN1_SWINT_TRIG_MASK | |
Jesse Brandeburg | 97bf75f | 2015-02-27 09:18:32 +0000 | [diff] [blame] | 288 | I40E_VFINT_DYN_CTLN1_ITR_INDX_MASK | |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 289 | I40E_VFINT_DYN_CTLN1_CLEARPBA_MASK; |
Mitch Williams | 164ec1b | 2014-06-04 08:45:19 +0000 | [diff] [blame] | 290 | wr32(hw, I40E_VFINT_DYN_CTL01, dyn_ctl); |
| 291 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 292 | for (i = 1; i < adapter->num_msix_vectors; i++) { |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 293 | if (mask & BIT(i)) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 294 | dyn_ctl = rd32(hw, I40E_VFINT_DYN_CTLN1(i - 1)); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 295 | dyn_ctl |= I40E_VFINT_DYN_CTLN1_SWINT_TRIG_MASK | |
Jesse Brandeburg | 97bf75f | 2015-02-27 09:18:32 +0000 | [diff] [blame] | 296 | I40E_VFINT_DYN_CTLN1_ITR_INDX_MASK | |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 297 | I40E_VFINT_DYN_CTLN1_CLEARPBA_MASK; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 298 | wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), dyn_ctl); |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * i40evf_irq_enable - Enable default interrupt generation settings |
| 305 | * @adapter: board private structure |
Jean Sacren | 69c1d70 | 2015-10-13 01:06:27 -0600 | [diff] [blame] | 306 | * @flush: boolean value whether to run rd32() |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 307 | **/ |
| 308 | void i40evf_irq_enable(struct i40evf_adapter *adapter, bool flush) |
| 309 | { |
| 310 | struct i40e_hw *hw = &adapter->hw; |
| 311 | |
Mitch Williams | 164ec1b | 2014-06-04 08:45:19 +0000 | [diff] [blame] | 312 | i40evf_misc_irq_enable(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 313 | i40evf_irq_enable_queues(adapter, ~0); |
| 314 | |
| 315 | if (flush) |
| 316 | rd32(hw, I40E_VFGEN_RSTAT); |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * i40evf_msix_aq - Interrupt handler for vector 0 |
| 321 | * @irq: interrupt number |
| 322 | * @data: pointer to netdev |
| 323 | **/ |
| 324 | static irqreturn_t i40evf_msix_aq(int irq, void *data) |
| 325 | { |
| 326 | struct net_device *netdev = data; |
| 327 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 328 | struct i40e_hw *hw = &adapter->hw; |
| 329 | u32 val; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 330 | |
Jesse Brandeburg | cfbe4db | 2015-10-04 01:09:49 -0700 | [diff] [blame] | 331 | /* handle non-queue interrupts, these reads clear the registers */ |
| 332 | val = rd32(hw, I40E_VFINT_ICR01); |
| 333 | val = rd32(hw, I40E_VFINT_ICR0_ENA1); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 334 | |
Jean Sacren | ed17f7e | 2015-10-13 01:06:30 -0600 | [diff] [blame] | 335 | val = rd32(hw, I40E_VFINT_DYN_CTL01) | |
| 336 | I40E_VFINT_DYN_CTL01_CLEARPBA_MASK; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 337 | wr32(hw, I40E_VFINT_DYN_CTL01, val); |
| 338 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 339 | /* schedule work on the private workqueue */ |
| 340 | schedule_work(&adapter->adminq_task); |
| 341 | |
| 342 | return IRQ_HANDLED; |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * i40evf_msix_clean_rings - MSIX mode Interrupt Handler |
| 347 | * @irq: interrupt number |
| 348 | * @data: pointer to a q_vector |
| 349 | **/ |
| 350 | static irqreturn_t i40evf_msix_clean_rings(int irq, void *data) |
| 351 | { |
| 352 | struct i40e_q_vector *q_vector = data; |
| 353 | |
| 354 | if (!q_vector->tx.ring && !q_vector->rx.ring) |
| 355 | return IRQ_HANDLED; |
| 356 | |
Alexander Duyck | 5d3465a | 2015-09-29 15:19:50 -0700 | [diff] [blame] | 357 | napi_schedule_irqoff(&q_vector->napi); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 358 | |
| 359 | return IRQ_HANDLED; |
| 360 | } |
| 361 | |
| 362 | /** |
| 363 | * i40evf_map_vector_to_rxq - associate irqs with rx queues |
| 364 | * @adapter: board private structure |
| 365 | * @v_idx: interrupt number |
| 366 | * @r_idx: queue number |
| 367 | **/ |
| 368 | static void |
| 369 | i40evf_map_vector_to_rxq(struct i40evf_adapter *adapter, int v_idx, int r_idx) |
| 370 | { |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 371 | struct i40e_q_vector *q_vector = &adapter->q_vectors[v_idx]; |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 372 | struct i40e_ring *rx_ring = &adapter->rx_rings[r_idx]; |
Mitch Williams | f19a973 | 2016-09-12 14:18:38 -0700 | [diff] [blame] | 373 | struct i40e_hw *hw = &adapter->hw; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 374 | |
| 375 | rx_ring->q_vector = q_vector; |
| 376 | rx_ring->next = q_vector->rx.ring; |
| 377 | rx_ring->vsi = &adapter->vsi; |
| 378 | q_vector->rx.ring = rx_ring; |
| 379 | q_vector->rx.count++; |
| 380 | q_vector->rx.latency_range = I40E_LOW_LATENCY; |
Jacob Keller | 65e87c0 | 2016-09-12 14:18:44 -0700 | [diff] [blame] | 381 | q_vector->rx.itr = ITR_TO_REG(rx_ring->rx_itr_setting); |
Mitch Williams | f19a973 | 2016-09-12 14:18:38 -0700 | [diff] [blame] | 382 | q_vector->ring_mask |= BIT(r_idx); |
Jesse Brandeburg | ee2319c | 2015-09-28 14:16:54 -0400 | [diff] [blame] | 383 | q_vector->itr_countdown = ITR_COUNTDOWN_START; |
Mitch Williams | f19a973 | 2016-09-12 14:18:38 -0700 | [diff] [blame] | 384 | wr32(hw, I40E_VFINT_ITRN1(I40E_RX_ITR, v_idx - 1), q_vector->rx.itr); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /** |
| 388 | * i40evf_map_vector_to_txq - associate irqs with tx queues |
| 389 | * @adapter: board private structure |
| 390 | * @v_idx: interrupt number |
| 391 | * @t_idx: queue number |
| 392 | **/ |
| 393 | static void |
| 394 | i40evf_map_vector_to_txq(struct i40evf_adapter *adapter, int v_idx, int t_idx) |
| 395 | { |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 396 | struct i40e_q_vector *q_vector = &adapter->q_vectors[v_idx]; |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 397 | struct i40e_ring *tx_ring = &adapter->tx_rings[t_idx]; |
Mitch Williams | f19a973 | 2016-09-12 14:18:38 -0700 | [diff] [blame] | 398 | struct i40e_hw *hw = &adapter->hw; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 399 | |
| 400 | tx_ring->q_vector = q_vector; |
| 401 | tx_ring->next = q_vector->tx.ring; |
| 402 | tx_ring->vsi = &adapter->vsi; |
| 403 | q_vector->tx.ring = tx_ring; |
| 404 | q_vector->tx.count++; |
| 405 | q_vector->tx.latency_range = I40E_LOW_LATENCY; |
Jacob Keller | 65e87c0 | 2016-09-12 14:18:44 -0700 | [diff] [blame] | 406 | q_vector->tx.itr = ITR_TO_REG(tx_ring->tx_itr_setting); |
Jesse Brandeburg | ee2319c | 2015-09-28 14:16:54 -0400 | [diff] [blame] | 407 | q_vector->itr_countdown = ITR_COUNTDOWN_START; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 408 | q_vector->num_ringpairs++; |
Mitch Williams | f19a973 | 2016-09-12 14:18:38 -0700 | [diff] [blame] | 409 | wr32(hw, I40E_VFINT_ITRN1(I40E_TX_ITR, v_idx - 1), q_vector->tx.itr); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | /** |
| 413 | * i40evf_map_rings_to_vectors - Maps descriptor rings to vectors |
| 414 | * @adapter: board private structure to initialize |
| 415 | * |
| 416 | * This function maps descriptor rings to the queue-specific vectors |
| 417 | * we were allotted through the MSI-X enabling code. Ideally, we'd have |
| 418 | * one vector per ring/queue, but on a constrained vector budget, we |
| 419 | * group the rings as "efficiently" as possible. You would add new |
| 420 | * mapping configurations in here. |
| 421 | **/ |
| 422 | static int i40evf_map_rings_to_vectors(struct i40evf_adapter *adapter) |
| 423 | { |
| 424 | int q_vectors; |
| 425 | int v_start = 0; |
| 426 | int rxr_idx = 0, txr_idx = 0; |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 427 | int rxr_remaining = adapter->num_active_queues; |
| 428 | int txr_remaining = adapter->num_active_queues; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 429 | int i, j; |
| 430 | int rqpv, tqpv; |
| 431 | int err = 0; |
| 432 | |
| 433 | q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
| 434 | |
| 435 | /* The ideal configuration... |
| 436 | * We have enough vectors to map one per queue. |
| 437 | */ |
Mitch Williams | 973371d | 2015-04-27 14:57:09 -0400 | [diff] [blame] | 438 | if (q_vectors >= (rxr_remaining * 2)) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 439 | for (; rxr_idx < rxr_remaining; v_start++, rxr_idx++) |
| 440 | i40evf_map_vector_to_rxq(adapter, v_start, rxr_idx); |
| 441 | |
| 442 | for (; txr_idx < txr_remaining; v_start++, txr_idx++) |
| 443 | i40evf_map_vector_to_txq(adapter, v_start, txr_idx); |
| 444 | goto out; |
| 445 | } |
| 446 | |
| 447 | /* If we don't have enough vectors for a 1-to-1 |
| 448 | * mapping, we'll have to group them so there are |
| 449 | * multiple queues per vector. |
| 450 | * Re-adjusting *qpv takes care of the remainder. |
| 451 | */ |
| 452 | for (i = v_start; i < q_vectors; i++) { |
| 453 | rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors - i); |
| 454 | for (j = 0; j < rqpv; j++) { |
| 455 | i40evf_map_vector_to_rxq(adapter, i, rxr_idx); |
| 456 | rxr_idx++; |
| 457 | rxr_remaining--; |
| 458 | } |
| 459 | } |
| 460 | for (i = v_start; i < q_vectors; i++) { |
| 461 | tqpv = DIV_ROUND_UP(txr_remaining, q_vectors - i); |
| 462 | for (j = 0; j < tqpv; j++) { |
| 463 | i40evf_map_vector_to_txq(adapter, i, txr_idx); |
| 464 | txr_idx++; |
| 465 | txr_remaining--; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | out: |
| 470 | adapter->aq_required |= I40EVF_FLAG_AQ_MAP_VECTORS; |
| 471 | |
| 472 | return err; |
| 473 | } |
| 474 | |
Alexander Duyck | 7709b4c | 2015-09-24 09:04:38 -0700 | [diff] [blame] | 475 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 476 | /** |
| 477 | * i40evf_netpoll - A Polling 'interrupt' handler |
| 478 | * @netdev: network interface device structure |
| 479 | * |
| 480 | * This is used by netconsole to send skbs without having to re-enable |
| 481 | * interrupts. It's not called while the normal interrupt routine is executing. |
| 482 | **/ |
| 483 | static void i40evf_netpoll(struct net_device *netdev) |
| 484 | { |
| 485 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 486 | int q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
| 487 | int i; |
| 488 | |
| 489 | /* if interface is down do nothing */ |
| 490 | if (test_bit(__I40E_DOWN, &adapter->vsi.state)) |
| 491 | return; |
| 492 | |
| 493 | for (i = 0; i < q_vectors; i++) |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 494 | i40evf_msix_clean_rings(0, &adapter->q_vectors[i]); |
Alexander Duyck | 7709b4c | 2015-09-24 09:04:38 -0700 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | #endif |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 498 | /** |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 499 | * i40evf_irq_affinity_notify - Callback for affinity changes |
| 500 | * @notify: context as to what irq was changed |
| 501 | * @mask: the new affinity mask |
| 502 | * |
| 503 | * This is a callback function used by the irq_set_affinity_notifier function |
| 504 | * so that we may register to receive changes to the irq affinity masks. |
| 505 | **/ |
| 506 | static void i40evf_irq_affinity_notify(struct irq_affinity_notify *notify, |
| 507 | const cpumask_t *mask) |
| 508 | { |
| 509 | struct i40e_q_vector *q_vector = |
| 510 | container_of(notify, struct i40e_q_vector, affinity_notify); |
| 511 | |
| 512 | q_vector->affinity_mask = *mask; |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * i40evf_irq_affinity_release - Callback for affinity notifier release |
| 517 | * @ref: internal core kernel usage |
| 518 | * |
| 519 | * This is a callback function used by the irq_set_affinity_notifier function |
| 520 | * to inform the current notification subscriber that they will no longer |
| 521 | * receive notifications. |
| 522 | **/ |
| 523 | static void i40evf_irq_affinity_release(struct kref *ref) {} |
| 524 | |
| 525 | /** |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 526 | * i40evf_request_traffic_irqs - Initialize MSI-X interrupts |
| 527 | * @adapter: board private structure |
| 528 | * |
| 529 | * Allocates MSI-X vectors for tx and rx handling, and requests |
| 530 | * interrupts from the kernel. |
| 531 | **/ |
| 532 | static int |
| 533 | i40evf_request_traffic_irqs(struct i40evf_adapter *adapter, char *basename) |
| 534 | { |
| 535 | int vector, err, q_vectors; |
| 536 | int rx_int_idx = 0, tx_int_idx = 0; |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 537 | int irq_num; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 538 | |
| 539 | i40evf_irq_disable(adapter); |
| 540 | /* Decrement for Other and TCP Timer vectors */ |
| 541 | q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
| 542 | |
| 543 | for (vector = 0; vector < q_vectors; vector++) { |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 544 | struct i40e_q_vector *q_vector = &adapter->q_vectors[vector]; |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 545 | irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 546 | |
| 547 | if (q_vector->tx.ring && q_vector->rx.ring) { |
| 548 | snprintf(q_vector->name, sizeof(q_vector->name) - 1, |
| 549 | "i40evf-%s-%s-%d", basename, |
| 550 | "TxRx", rx_int_idx++); |
| 551 | tx_int_idx++; |
| 552 | } else if (q_vector->rx.ring) { |
| 553 | snprintf(q_vector->name, sizeof(q_vector->name) - 1, |
| 554 | "i40evf-%s-%s-%d", basename, |
| 555 | "rx", rx_int_idx++); |
| 556 | } else if (q_vector->tx.ring) { |
| 557 | snprintf(q_vector->name, sizeof(q_vector->name) - 1, |
| 558 | "i40evf-%s-%s-%d", basename, |
| 559 | "tx", tx_int_idx++); |
| 560 | } else { |
| 561 | /* skip this unused q_vector */ |
| 562 | continue; |
| 563 | } |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 564 | err = request_irq(irq_num, |
| 565 | i40evf_msix_clean_rings, |
| 566 | 0, |
| 567 | q_vector->name, |
| 568 | q_vector); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 569 | if (err) { |
| 570 | dev_info(&adapter->pdev->dev, |
Shannon Nelson | fb43201f | 2015-08-26 15:14:17 -0400 | [diff] [blame] | 571 | "Request_irq failed, error: %d\n", err); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 572 | goto free_queue_irqs; |
| 573 | } |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 574 | /* register for affinity change notifications */ |
| 575 | q_vector->affinity_notify.notify = i40evf_irq_affinity_notify; |
| 576 | q_vector->affinity_notify.release = |
| 577 | i40evf_irq_affinity_release; |
| 578 | irq_set_affinity_notifier(irq_num, &q_vector->affinity_notify); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 579 | /* assign the mask for this irq */ |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 580 | irq_set_affinity_hint(irq_num, &q_vector->affinity_mask); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | return 0; |
| 584 | |
| 585 | free_queue_irqs: |
| 586 | while (vector) { |
| 587 | vector--; |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 588 | irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; |
| 589 | irq_set_affinity_notifier(irq_num, NULL); |
| 590 | irq_set_affinity_hint(irq_num, NULL); |
| 591 | free_irq(irq_num, &adapter->q_vectors[vector]); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 592 | } |
| 593 | return err; |
| 594 | } |
| 595 | |
| 596 | /** |
| 597 | * i40evf_request_misc_irq - Initialize MSI-X interrupts |
| 598 | * @adapter: board private structure |
| 599 | * |
| 600 | * Allocates MSI-X vector 0 and requests interrupts from the kernel. This |
| 601 | * vector is only for the admin queue, and stays active even when the netdev |
| 602 | * is closed. |
| 603 | **/ |
| 604 | static int i40evf_request_misc_irq(struct i40evf_adapter *adapter) |
| 605 | { |
| 606 | struct net_device *netdev = adapter->netdev; |
| 607 | int err; |
| 608 | |
Jesse Brandeburg | b39c1e2 | 2014-08-01 13:27:08 -0700 | [diff] [blame] | 609 | snprintf(adapter->misc_vector_name, |
Carolyn Wyborny | 9a21a00 | 2015-02-06 08:52:20 +0000 | [diff] [blame] | 610 | sizeof(adapter->misc_vector_name) - 1, "i40evf-%s:mbx", |
| 611 | dev_name(&adapter->pdev->dev)); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 612 | err = request_irq(adapter->msix_entries[0].vector, |
Mitch Williams | e1dfee8 | 2014-02-13 03:48:51 -0800 | [diff] [blame] | 613 | &i40evf_msix_aq, 0, |
| 614 | adapter->misc_vector_name, netdev); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 615 | if (err) { |
| 616 | dev_err(&adapter->pdev->dev, |
Catherine Sullivan | 77fa28b | 2014-02-20 19:29:17 -0800 | [diff] [blame] | 617 | "request_irq for %s failed: %d\n", |
| 618 | adapter->misc_vector_name, err); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 619 | free_irq(adapter->msix_entries[0].vector, netdev); |
| 620 | } |
| 621 | return err; |
| 622 | } |
| 623 | |
| 624 | /** |
| 625 | * i40evf_free_traffic_irqs - Free MSI-X interrupts |
| 626 | * @adapter: board private structure |
| 627 | * |
| 628 | * Frees all MSI-X vectors other than 0. |
| 629 | **/ |
| 630 | static void i40evf_free_traffic_irqs(struct i40evf_adapter *adapter) |
| 631 | { |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 632 | int vector, irq_num, q_vectors; |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 633 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 634 | q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
| 635 | |
Alan Brady | 96db776 | 2016-09-14 16:24:38 -0700 | [diff] [blame] | 636 | for (vector = 0; vector < q_vectors; vector++) { |
| 637 | irq_num = adapter->msix_entries[vector + NONQ_VECS].vector; |
| 638 | irq_set_affinity_notifier(irq_num, NULL); |
| 639 | irq_set_affinity_hint(irq_num, NULL); |
| 640 | free_irq(irq_num, &adapter->q_vectors[vector]); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 641 | } |
| 642 | } |
| 643 | |
| 644 | /** |
| 645 | * i40evf_free_misc_irq - Free MSI-X miscellaneous vector |
| 646 | * @adapter: board private structure |
| 647 | * |
| 648 | * Frees MSI-X vector 0. |
| 649 | **/ |
| 650 | static void i40evf_free_misc_irq(struct i40evf_adapter *adapter) |
| 651 | { |
| 652 | struct net_device *netdev = adapter->netdev; |
| 653 | |
| 654 | free_irq(adapter->msix_entries[0].vector, netdev); |
| 655 | } |
| 656 | |
| 657 | /** |
| 658 | * i40evf_configure_tx - Configure Transmit Unit after Reset |
| 659 | * @adapter: board private structure |
| 660 | * |
| 661 | * Configure the Tx unit of the MAC after a reset. |
| 662 | **/ |
| 663 | static void i40evf_configure_tx(struct i40evf_adapter *adapter) |
| 664 | { |
| 665 | struct i40e_hw *hw = &adapter->hw; |
| 666 | int i; |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 667 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 668 | for (i = 0; i < adapter->num_active_queues; i++) |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 669 | adapter->tx_rings[i].tail = hw->hw_addr + I40E_QTX_TAIL1(i); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | /** |
| 673 | * i40evf_configure_rx - Configure Receive Unit after Reset |
| 674 | * @adapter: board private structure |
| 675 | * |
| 676 | * Configure the Rx unit of the MAC after a reset. |
| 677 | **/ |
| 678 | static void i40evf_configure_rx(struct i40evf_adapter *adapter) |
| 679 | { |
| 680 | struct i40e_hw *hw = &adapter->hw; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 681 | int i; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 682 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 683 | for (i = 0; i < adapter->num_active_queues; i++) { |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 684 | adapter->rx_rings[i].tail = hw->hw_addr + I40E_QRX_TAIL1(i); |
Jesse Brandeburg | 19b85e6 | 2016-04-18 11:33:45 -0700 | [diff] [blame] | 685 | adapter->rx_rings[i].rx_buf_len = I40EVF_RXBUFFER_2048; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 686 | } |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * i40evf_find_vlan - Search filter list for specific vlan filter |
| 691 | * @adapter: board private structure |
| 692 | * @vlan: vlan tag |
| 693 | * |
| 694 | * Returns ptr to the filter object or NULL |
| 695 | **/ |
| 696 | static struct |
| 697 | i40evf_vlan_filter *i40evf_find_vlan(struct i40evf_adapter *adapter, u16 vlan) |
| 698 | { |
| 699 | struct i40evf_vlan_filter *f; |
| 700 | |
| 701 | list_for_each_entry(f, &adapter->vlan_filter_list, list) { |
| 702 | if (vlan == f->vlan) |
| 703 | return f; |
| 704 | } |
| 705 | return NULL; |
| 706 | } |
| 707 | |
| 708 | /** |
| 709 | * i40evf_add_vlan - Add a vlan filter to the list |
| 710 | * @adapter: board private structure |
| 711 | * @vlan: VLAN tag |
| 712 | * |
| 713 | * Returns ptr to the filter object or NULL when no memory available. |
| 714 | **/ |
| 715 | static struct |
| 716 | i40evf_vlan_filter *i40evf_add_vlan(struct i40evf_adapter *adapter, u16 vlan) |
| 717 | { |
Mitch Williams | 13acb54 | 2015-03-31 00:45:05 -0700 | [diff] [blame] | 718 | struct i40evf_vlan_filter *f = NULL; |
| 719 | int count = 50; |
| 720 | |
| 721 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, |
| 722 | &adapter->crit_section)) { |
| 723 | udelay(1); |
| 724 | if (--count == 0) |
| 725 | goto out; |
| 726 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 727 | |
| 728 | f = i40evf_find_vlan(adapter, vlan); |
Mitch Williams | 348d499 | 2014-11-11 20:02:52 +0000 | [diff] [blame] | 729 | if (!f) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 730 | f = kzalloc(sizeof(*f), GFP_ATOMIC); |
Mitch Williams | 348d499 | 2014-11-11 20:02:52 +0000 | [diff] [blame] | 731 | if (!f) |
Mitch Williams | 13acb54 | 2015-03-31 00:45:05 -0700 | [diff] [blame] | 732 | goto clearout; |
Mitch Williams | 249c8b8 | 2014-05-10 04:49:04 +0000 | [diff] [blame] | 733 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 734 | f->vlan = vlan; |
| 735 | |
| 736 | INIT_LIST_HEAD(&f->list); |
| 737 | list_add(&f->list, &adapter->vlan_filter_list); |
| 738 | f->add = true; |
| 739 | adapter->aq_required |= I40EVF_FLAG_AQ_ADD_VLAN_FILTER; |
| 740 | } |
| 741 | |
Mitch Williams | 13acb54 | 2015-03-31 00:45:05 -0700 | [diff] [blame] | 742 | clearout: |
| 743 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
| 744 | out: |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 745 | return f; |
| 746 | } |
| 747 | |
| 748 | /** |
| 749 | * i40evf_del_vlan - Remove a vlan filter from the list |
| 750 | * @adapter: board private structure |
| 751 | * @vlan: VLAN tag |
| 752 | **/ |
| 753 | static void i40evf_del_vlan(struct i40evf_adapter *adapter, u16 vlan) |
| 754 | { |
| 755 | struct i40evf_vlan_filter *f; |
Mitch Williams | 13acb54 | 2015-03-31 00:45:05 -0700 | [diff] [blame] | 756 | int count = 50; |
| 757 | |
| 758 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, |
| 759 | &adapter->crit_section)) { |
| 760 | udelay(1); |
| 761 | if (--count == 0) |
| 762 | return; |
| 763 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 764 | |
| 765 | f = i40evf_find_vlan(adapter, vlan); |
| 766 | if (f) { |
| 767 | f->remove = true; |
| 768 | adapter->aq_required |= I40EVF_FLAG_AQ_DEL_VLAN_FILTER; |
| 769 | } |
Mitch Williams | 13acb54 | 2015-03-31 00:45:05 -0700 | [diff] [blame] | 770 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | /** |
| 774 | * i40evf_vlan_rx_add_vid - Add a VLAN filter to a device |
| 775 | * @netdev: network device struct |
| 776 | * @vid: VLAN tag |
| 777 | **/ |
| 778 | static int i40evf_vlan_rx_add_vid(struct net_device *netdev, |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 779 | __always_unused __be16 proto, u16 vid) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 780 | { |
| 781 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 782 | |
Mitch Williams | 8ed995f | 2015-08-28 17:55:57 -0400 | [diff] [blame] | 783 | if (!VLAN_ALLOWED(adapter)) |
| 784 | return -EIO; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 785 | if (i40evf_add_vlan(adapter, vid) == NULL) |
| 786 | return -ENOMEM; |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 790 | /** |
| 791 | * i40evf_vlan_rx_kill_vid - Remove a VLAN filter from a device |
| 792 | * @netdev: network device struct |
| 793 | * @vid: VLAN tag |
| 794 | **/ |
| 795 | static int i40evf_vlan_rx_kill_vid(struct net_device *netdev, |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 796 | __always_unused __be16 proto, u16 vid) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 797 | { |
| 798 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 799 | |
Mitch Williams | 8ed995f | 2015-08-28 17:55:57 -0400 | [diff] [blame] | 800 | if (VLAN_ALLOWED(adapter)) { |
| 801 | i40evf_del_vlan(adapter, vid); |
| 802 | return 0; |
| 803 | } |
| 804 | return -EIO; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | /** |
| 808 | * i40evf_find_filter - Search filter list for specific mac filter |
| 809 | * @adapter: board private structure |
| 810 | * @macaddr: the MAC address |
| 811 | * |
| 812 | * Returns ptr to the filter object or NULL |
| 813 | **/ |
| 814 | static struct |
| 815 | i40evf_mac_filter *i40evf_find_filter(struct i40evf_adapter *adapter, |
| 816 | u8 *macaddr) |
| 817 | { |
| 818 | struct i40evf_mac_filter *f; |
| 819 | |
| 820 | if (!macaddr) |
| 821 | return NULL; |
| 822 | |
| 823 | list_for_each_entry(f, &adapter->mac_filter_list, list) { |
| 824 | if (ether_addr_equal(macaddr, f->macaddr)) |
| 825 | return f; |
| 826 | } |
| 827 | return NULL; |
| 828 | } |
| 829 | |
| 830 | /** |
| 831 | * i40e_add_filter - Add a mac filter to the filter list |
| 832 | * @adapter: board private structure |
| 833 | * @macaddr: the MAC address |
| 834 | * |
| 835 | * Returns ptr to the filter object or NULL when no memory available. |
| 836 | **/ |
| 837 | static struct |
| 838 | i40evf_mac_filter *i40evf_add_filter(struct i40evf_adapter *adapter, |
| 839 | u8 *macaddr) |
| 840 | { |
| 841 | struct i40evf_mac_filter *f; |
Mitch Williams | 54e16f6 | 2015-01-29 07:17:20 +0000 | [diff] [blame] | 842 | int count = 50; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 843 | |
| 844 | if (!macaddr) |
| 845 | return NULL; |
| 846 | |
| 847 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, |
Mitch Williams | 54e16f6 | 2015-01-29 07:17:20 +0000 | [diff] [blame] | 848 | &adapter->crit_section)) { |
Mitch Williams | b65476c | 2014-07-09 07:46:14 +0000 | [diff] [blame] | 849 | udelay(1); |
Mitch Williams | 54e16f6 | 2015-01-29 07:17:20 +0000 | [diff] [blame] | 850 | if (--count == 0) |
| 851 | return NULL; |
| 852 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 853 | |
| 854 | f = i40evf_find_filter(adapter, macaddr); |
Mitch Williams | 348d499 | 2014-11-11 20:02:52 +0000 | [diff] [blame] | 855 | if (!f) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 856 | f = kzalloc(sizeof(*f), GFP_ATOMIC); |
Mitch Williams | 348d499 | 2014-11-11 20:02:52 +0000 | [diff] [blame] | 857 | if (!f) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 858 | clear_bit(__I40EVF_IN_CRITICAL_TASK, |
| 859 | &adapter->crit_section); |
| 860 | return NULL; |
| 861 | } |
| 862 | |
Greg Rose | 9a17390 | 2014-05-22 06:32:02 +0000 | [diff] [blame] | 863 | ether_addr_copy(f->macaddr, macaddr); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 864 | |
Mitch Williams | 63590b6 | 2016-05-16 10:26:42 -0700 | [diff] [blame] | 865 | list_add_tail(&f->list, &adapter->mac_filter_list); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 866 | f->add = true; |
| 867 | adapter->aq_required |= I40EVF_FLAG_AQ_ADD_MAC_FILTER; |
| 868 | } |
| 869 | |
| 870 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
| 871 | return f; |
| 872 | } |
| 873 | |
| 874 | /** |
| 875 | * i40evf_set_mac - NDO callback to set port mac address |
| 876 | * @netdev: network interface device structure |
| 877 | * @p: pointer to an address structure |
| 878 | * |
| 879 | * Returns 0 on success, negative on failure |
| 880 | **/ |
| 881 | static int i40evf_set_mac(struct net_device *netdev, void *p) |
| 882 | { |
| 883 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 884 | struct i40e_hw *hw = &adapter->hw; |
| 885 | struct i40evf_mac_filter *f; |
| 886 | struct sockaddr *addr = p; |
| 887 | |
| 888 | if (!is_valid_ether_addr(addr->sa_data)) |
| 889 | return -EADDRNOTAVAIL; |
| 890 | |
| 891 | if (ether_addr_equal(netdev->dev_addr, addr->sa_data)) |
| 892 | return 0; |
| 893 | |
Mitch Williams | 14e52ee | 2015-08-31 19:54:44 -0400 | [diff] [blame] | 894 | if (adapter->flags & I40EVF_FLAG_ADDR_SET_BY_PF) |
| 895 | return -EPERM; |
| 896 | |
| 897 | f = i40evf_find_filter(adapter, hw->mac.addr); |
| 898 | if (f) { |
| 899 | f->remove = true; |
| 900 | adapter->aq_required |= I40EVF_FLAG_AQ_DEL_MAC_FILTER; |
| 901 | } |
| 902 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 903 | f = i40evf_add_filter(adapter, addr->sa_data); |
| 904 | if (f) { |
Greg Rose | 9a17390 | 2014-05-22 06:32:02 +0000 | [diff] [blame] | 905 | ether_addr_copy(hw->mac.addr, addr->sa_data); |
| 906 | ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 907 | } |
| 908 | |
| 909 | return (f == NULL) ? -ENOMEM : 0; |
| 910 | } |
| 911 | |
| 912 | /** |
| 913 | * i40evf_set_rx_mode - NDO callback to set the netdev filters |
| 914 | * @netdev: network interface device structure |
| 915 | **/ |
| 916 | static void i40evf_set_rx_mode(struct net_device *netdev) |
| 917 | { |
| 918 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 919 | struct i40evf_mac_filter *f, *ftmp; |
| 920 | struct netdev_hw_addr *uca; |
| 921 | struct netdev_hw_addr *mca; |
Shannon Nelson | 2f41f33 | 2015-08-26 15:14:20 -0400 | [diff] [blame] | 922 | struct netdev_hw_addr *ha; |
Mitch Williams | 54e16f6 | 2015-01-29 07:17:20 +0000 | [diff] [blame] | 923 | int count = 50; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 924 | |
| 925 | /* add addr if not already in the filter list */ |
| 926 | netdev_for_each_uc_addr(uca, netdev) { |
| 927 | i40evf_add_filter(adapter, uca->addr); |
| 928 | } |
| 929 | netdev_for_each_mc_addr(mca, netdev) { |
| 930 | i40evf_add_filter(adapter, mca->addr); |
| 931 | } |
| 932 | |
| 933 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, |
Mitch Williams | 54e16f6 | 2015-01-29 07:17:20 +0000 | [diff] [blame] | 934 | &adapter->crit_section)) { |
Mitch Williams | b65476c | 2014-07-09 07:46:14 +0000 | [diff] [blame] | 935 | udelay(1); |
Mitch Williams | 54e16f6 | 2015-01-29 07:17:20 +0000 | [diff] [blame] | 936 | if (--count == 0) { |
| 937 | dev_err(&adapter->pdev->dev, |
| 938 | "Failed to get lock in %s\n", __func__); |
| 939 | return; |
| 940 | } |
| 941 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 942 | /* remove filter if not in netdev list */ |
| 943 | list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { |
Shannon Nelson | 2f41f33 | 2015-08-26 15:14:20 -0400 | [diff] [blame] | 944 | netdev_for_each_mc_addr(mca, netdev) |
| 945 | if (ether_addr_equal(mca->addr, f->macaddr)) |
| 946 | goto bottom_of_search_loop; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 947 | |
Shannon Nelson | 2f41f33 | 2015-08-26 15:14:20 -0400 | [diff] [blame] | 948 | netdev_for_each_uc_addr(uca, netdev) |
| 949 | if (ether_addr_equal(uca->addr, f->macaddr)) |
| 950 | goto bottom_of_search_loop; |
| 951 | |
| 952 | for_each_dev_addr(netdev, ha) |
| 953 | if (ether_addr_equal(ha->addr, f->macaddr)) |
| 954 | goto bottom_of_search_loop; |
| 955 | |
| 956 | if (ether_addr_equal(f->macaddr, adapter->hw.mac.addr)) |
| 957 | goto bottom_of_search_loop; |
| 958 | |
| 959 | /* f->macaddr wasn't found in uc, mc, or ha list so delete it */ |
| 960 | f->remove = true; |
| 961 | adapter->aq_required |= I40EVF_FLAG_AQ_DEL_MAC_FILTER; |
| 962 | |
| 963 | bottom_of_search_loop: |
| 964 | continue; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 965 | } |
Anjali Singhai Jain | 47d3483 | 2016-04-12 08:30:52 -0700 | [diff] [blame] | 966 | |
| 967 | if (netdev->flags & IFF_PROMISC && |
| 968 | !(adapter->flags & I40EVF_FLAG_PROMISC_ON)) |
| 969 | adapter->aq_required |= I40EVF_FLAG_AQ_REQUEST_PROMISC; |
| 970 | else if (!(netdev->flags & IFF_PROMISC) && |
| 971 | adapter->flags & I40EVF_FLAG_PROMISC_ON) |
| 972 | adapter->aq_required |= I40EVF_FLAG_AQ_RELEASE_PROMISC; |
| 973 | |
Anjali Singhai Jain | f42a5c7 | 2016-05-03 15:13:10 -0700 | [diff] [blame] | 974 | if (netdev->flags & IFF_ALLMULTI && |
| 975 | !(adapter->flags & I40EVF_FLAG_ALLMULTI_ON)) |
| 976 | adapter->aq_required |= I40EVF_FLAG_AQ_REQUEST_ALLMULTI; |
| 977 | else if (!(netdev->flags & IFF_ALLMULTI) && |
| 978 | adapter->flags & I40EVF_FLAG_ALLMULTI_ON) |
| 979 | adapter->aq_required |= I40EVF_FLAG_AQ_RELEASE_ALLMULTI; |
| 980 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 981 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
| 982 | } |
| 983 | |
| 984 | /** |
| 985 | * i40evf_napi_enable_all - enable NAPI on all queue vectors |
| 986 | * @adapter: board private structure |
| 987 | **/ |
| 988 | static void i40evf_napi_enable_all(struct i40evf_adapter *adapter) |
| 989 | { |
| 990 | int q_idx; |
| 991 | struct i40e_q_vector *q_vector; |
| 992 | int q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
| 993 | |
| 994 | for (q_idx = 0; q_idx < q_vectors; q_idx++) { |
| 995 | struct napi_struct *napi; |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 996 | |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 997 | q_vector = &adapter->q_vectors[q_idx]; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 998 | napi = &q_vector->napi; |
| 999 | napi_enable(napi); |
| 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | /** |
| 1004 | * i40evf_napi_disable_all - disable NAPI on all queue vectors |
| 1005 | * @adapter: board private structure |
| 1006 | **/ |
| 1007 | static void i40evf_napi_disable_all(struct i40evf_adapter *adapter) |
| 1008 | { |
| 1009 | int q_idx; |
| 1010 | struct i40e_q_vector *q_vector; |
| 1011 | int q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
| 1012 | |
| 1013 | for (q_idx = 0; q_idx < q_vectors; q_idx++) { |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 1014 | q_vector = &adapter->q_vectors[q_idx]; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1015 | napi_disable(&q_vector->napi); |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | /** |
| 1020 | * i40evf_configure - set up transmit and receive data structures |
| 1021 | * @adapter: board private structure |
| 1022 | **/ |
| 1023 | static void i40evf_configure(struct i40evf_adapter *adapter) |
| 1024 | { |
| 1025 | struct net_device *netdev = adapter->netdev; |
| 1026 | int i; |
| 1027 | |
| 1028 | i40evf_set_rx_mode(netdev); |
| 1029 | |
| 1030 | i40evf_configure_tx(adapter); |
| 1031 | i40evf_configure_rx(adapter); |
| 1032 | adapter->aq_required |= I40EVF_FLAG_AQ_CONFIGURE_QUEUES; |
| 1033 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 1034 | for (i = 0; i < adapter->num_active_queues; i++) { |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1035 | struct i40e_ring *ring = &adapter->rx_rings[i]; |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 1036 | |
Mitch Williams | b163098 | 2016-04-18 11:33:48 -0700 | [diff] [blame] | 1037 | i40evf_alloc_rx_buffers(ring, I40E_DESC_UNUSED(ring)); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1038 | } |
| 1039 | } |
| 1040 | |
| 1041 | /** |
| 1042 | * i40evf_up_complete - Finish the last steps of bringing up a connection |
| 1043 | * @adapter: board private structure |
| 1044 | **/ |
Bimmy Pujari | cb130a0 | 2016-09-06 18:05:03 -0700 | [diff] [blame] | 1045 | static void i40evf_up_complete(struct i40evf_adapter *adapter) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1046 | { |
| 1047 | adapter->state = __I40EVF_RUNNING; |
| 1048 | clear_bit(__I40E_DOWN, &adapter->vsi.state); |
| 1049 | |
| 1050 | i40evf_napi_enable_all(adapter); |
| 1051 | |
| 1052 | adapter->aq_required |= I40EVF_FLAG_AQ_ENABLE_QUEUES; |
| 1053 | mod_timer_pending(&adapter->watchdog_timer, jiffies + 1); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | /** |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1057 | * i40e_down - Shutdown the connection processing |
| 1058 | * @adapter: board private structure |
| 1059 | **/ |
| 1060 | void i40evf_down(struct i40evf_adapter *adapter) |
| 1061 | { |
| 1062 | struct net_device *netdev = adapter->netdev; |
| 1063 | struct i40evf_mac_filter *f; |
| 1064 | |
Mitch Williams | 209dc4d | 2015-12-09 15:50:27 -0800 | [diff] [blame] | 1065 | if (adapter->state <= __I40EVF_DOWN_PENDING) |
Mitch Williams | ddf0b3a | 2014-05-22 06:31:46 +0000 | [diff] [blame] | 1066 | return; |
| 1067 | |
Mitch A Williams | 53d0b3a | 2014-12-09 08:53:04 +0000 | [diff] [blame] | 1068 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, |
| 1069 | &adapter->crit_section)) |
| 1070 | usleep_range(500, 1000); |
| 1071 | |
Mitch Williams | 63e18c2 | 2015-03-27 00:12:10 -0700 | [diff] [blame] | 1072 | netif_carrier_off(netdev); |
| 1073 | netif_tx_disable(netdev); |
Sridhar Samudrala | 3f341ac | 2016-09-01 22:27:27 +0200 | [diff] [blame] | 1074 | adapter->link_up = false; |
Mitch Williams | 748c434 | 2015-01-29 07:17:18 +0000 | [diff] [blame] | 1075 | i40evf_napi_disable_all(adapter); |
Mitch Williams | 63e18c2 | 2015-03-27 00:12:10 -0700 | [diff] [blame] | 1076 | i40evf_irq_disable(adapter); |
Mitch A Williams | 53d0b3a | 2014-12-09 08:53:04 +0000 | [diff] [blame] | 1077 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1078 | /* remove all MAC filters */ |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1079 | list_for_each_entry(f, &adapter->mac_filter_list, list) { |
| 1080 | f->remove = true; |
| 1081 | } |
Mitch Williams | ed1f5b5 | 2014-02-20 19:29:06 -0800 | [diff] [blame] | 1082 | /* remove all VLAN filters */ |
| 1083 | list_for_each_entry(f, &adapter->vlan_filter_list, list) { |
| 1084 | f->remove = true; |
| 1085 | } |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1086 | if (!(adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) && |
| 1087 | adapter->state != __I40EVF_RESETTING) { |
Mitch A Williams | 53d0b3a | 2014-12-09 08:53:04 +0000 | [diff] [blame] | 1088 | /* cancel any current operation */ |
| 1089 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; |
Mitch A Williams | 53d0b3a | 2014-12-09 08:53:04 +0000 | [diff] [blame] | 1090 | /* Schedule operations to close down the HW. Don't wait |
| 1091 | * here for this to complete. The watchdog is still running |
| 1092 | * and it will take care of this. |
| 1093 | */ |
| 1094 | adapter->aq_required = I40EVF_FLAG_AQ_DEL_MAC_FILTER; |
Mitch Williams | ed1f5b5 | 2014-02-20 19:29:06 -0800 | [diff] [blame] | 1095 | adapter->aq_required |= I40EVF_FLAG_AQ_DEL_VLAN_FILTER; |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1096 | adapter->aq_required |= I40EVF_FLAG_AQ_DISABLE_QUEUES; |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1097 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1098 | |
Mitch A Williams | 53d0b3a | 2014-12-09 08:53:04 +0000 | [diff] [blame] | 1099 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | /** |
| 1103 | * i40evf_acquire_msix_vectors - Setup the MSIX capability |
| 1104 | * @adapter: board private structure |
| 1105 | * @vectors: number of vectors to request |
| 1106 | * |
| 1107 | * Work with the OS to set up the MSIX vectors needed. |
| 1108 | * |
| 1109 | * Returns 0 on success, negative on failure |
| 1110 | **/ |
| 1111 | static int |
| 1112 | i40evf_acquire_msix_vectors(struct i40evf_adapter *adapter, int vectors) |
| 1113 | { |
| 1114 | int err, vector_threshold; |
| 1115 | |
| 1116 | /* We'll want at least 3 (vector_threshold): |
| 1117 | * 0) Other (Admin Queue and link, mostly) |
| 1118 | * 1) TxQ[0] Cleanup |
| 1119 | * 2) RxQ[0] Cleanup |
| 1120 | */ |
| 1121 | vector_threshold = MIN_MSIX_COUNT; |
| 1122 | |
| 1123 | /* The more we get, the more we will assign to Tx/Rx Cleanup |
| 1124 | * for the separate queues...where Rx Cleanup >= Tx Cleanup. |
| 1125 | * Right now, we simply care about how many we'll get; we'll |
| 1126 | * set them up later while requesting irq's. |
| 1127 | */ |
Alexander Gordeev | fc2f2f5 | 2014-04-28 17:53:16 +0000 | [diff] [blame] | 1128 | err = pci_enable_msix_range(adapter->pdev, adapter->msix_entries, |
| 1129 | vector_threshold, vectors); |
| 1130 | if (err < 0) { |
Mitch Williams | 80e7289 | 2014-05-10 04:49:06 +0000 | [diff] [blame] | 1131 | dev_err(&adapter->pdev->dev, "Unable to allocate MSI-X interrupts\n"); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1132 | kfree(adapter->msix_entries); |
| 1133 | adapter->msix_entries = NULL; |
Alexander Gordeev | fc2f2f5 | 2014-04-28 17:53:16 +0000 | [diff] [blame] | 1134 | return err; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1135 | } |
Alexander Gordeev | fc2f2f5 | 2014-04-28 17:53:16 +0000 | [diff] [blame] | 1136 | |
| 1137 | /* Adjust for only the vectors we'll use, which is minimum |
| 1138 | * of max_msix_q_vectors + NONQ_VECS, or the number of |
| 1139 | * vectors we were allocated. |
| 1140 | */ |
| 1141 | adapter->num_msix_vectors = err; |
| 1142 | return 0; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | /** |
| 1146 | * i40evf_free_queues - Free memory for all rings |
| 1147 | * @adapter: board private structure to initialize |
| 1148 | * |
| 1149 | * Free all of the memory associated with queue pairs. |
| 1150 | **/ |
| 1151 | static void i40evf_free_queues(struct i40evf_adapter *adapter) |
| 1152 | { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1153 | if (!adapter->vsi_res) |
| 1154 | return; |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1155 | kfree(adapter->tx_rings); |
Mitch Williams | 1031154 | 2015-12-09 15:50:30 -0800 | [diff] [blame] | 1156 | adapter->tx_rings = NULL; |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1157 | kfree(adapter->rx_rings); |
Mitch Williams | 1031154 | 2015-12-09 15:50:30 -0800 | [diff] [blame] | 1158 | adapter->rx_rings = NULL; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | /** |
| 1162 | * i40evf_alloc_queues - Allocate memory for all rings |
| 1163 | * @adapter: board private structure to initialize |
| 1164 | * |
| 1165 | * We allocate one ring per queue at run-time since we don't know the |
| 1166 | * number of queues at compile-time. The polling_netdev array is |
| 1167 | * intended for Multiqueue, but should work fine with a single queue. |
| 1168 | **/ |
| 1169 | static int i40evf_alloc_queues(struct i40evf_adapter *adapter) |
| 1170 | { |
| 1171 | int i; |
| 1172 | |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1173 | adapter->tx_rings = kcalloc(adapter->num_active_queues, |
| 1174 | sizeof(struct i40e_ring), GFP_KERNEL); |
| 1175 | if (!adapter->tx_rings) |
| 1176 | goto err_out; |
| 1177 | adapter->rx_rings = kcalloc(adapter->num_active_queues, |
| 1178 | sizeof(struct i40e_ring), GFP_KERNEL); |
| 1179 | if (!adapter->rx_rings) |
| 1180 | goto err_out; |
| 1181 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 1182 | for (i = 0; i < adapter->num_active_queues; i++) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1183 | struct i40e_ring *tx_ring; |
| 1184 | struct i40e_ring *rx_ring; |
| 1185 | |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1186 | tx_ring = &adapter->tx_rings[i]; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1187 | |
| 1188 | tx_ring->queue_index = i; |
| 1189 | tx_ring->netdev = adapter->netdev; |
| 1190 | tx_ring->dev = &adapter->pdev->dev; |
Mitch Williams | d732a18 | 2014-04-24 06:41:37 +0000 | [diff] [blame] | 1191 | tx_ring->count = adapter->tx_desc_count; |
Jacob Keller | 65e87c0 | 2016-09-12 14:18:44 -0700 | [diff] [blame] | 1192 | tx_ring->tx_itr_setting = (I40E_ITR_DYNAMIC | I40E_ITR_TX_DEF); |
Anjali Singhai Jain | 1f01227 | 2015-09-03 17:18:53 -0400 | [diff] [blame] | 1193 | if (adapter->flags & I40E_FLAG_WB_ON_ITR_CAPABLE) |
| 1194 | tx_ring->flags |= I40E_TXR_FLAGS_WB_ON_ITR; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1195 | |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1196 | rx_ring = &adapter->rx_rings[i]; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1197 | rx_ring->queue_index = i; |
| 1198 | rx_ring->netdev = adapter->netdev; |
| 1199 | rx_ring->dev = &adapter->pdev->dev; |
Mitch Williams | d732a18 | 2014-04-24 06:41:37 +0000 | [diff] [blame] | 1200 | rx_ring->count = adapter->rx_desc_count; |
Jacob Keller | 65e87c0 | 2016-09-12 14:18:44 -0700 | [diff] [blame] | 1201 | rx_ring->rx_itr_setting = (I40E_ITR_DYNAMIC | I40E_ITR_RX_DEF); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | return 0; |
| 1205 | |
| 1206 | err_out: |
| 1207 | i40evf_free_queues(adapter); |
| 1208 | return -ENOMEM; |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * i40evf_set_interrupt_capability - set MSI-X or FAIL if not supported |
| 1213 | * @adapter: board private structure to initialize |
| 1214 | * |
| 1215 | * Attempt to configure the interrupts using the best available |
| 1216 | * capabilities of the hardware and the kernel. |
| 1217 | **/ |
| 1218 | static int i40evf_set_interrupt_capability(struct i40evf_adapter *adapter) |
| 1219 | { |
| 1220 | int vector, v_budget; |
| 1221 | int pairs = 0; |
| 1222 | int err = 0; |
| 1223 | |
| 1224 | if (!adapter->vsi_res) { |
| 1225 | err = -EIO; |
| 1226 | goto out; |
| 1227 | } |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 1228 | pairs = adapter->num_active_queues; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1229 | |
| 1230 | /* It's easy to be greedy for MSI-X vectors, but it really |
| 1231 | * doesn't do us much good if we have a lot more vectors |
| 1232 | * than CPU's. So let's be conservative and only ask for |
| 1233 | * (roughly) twice the number of vectors as there are CPU's. |
| 1234 | */ |
Mitch Williams | 30a500e | 2014-02-11 08:27:52 +0000 | [diff] [blame] | 1235 | v_budget = min_t(int, pairs, (int)(num_online_cpus() * 2)) + NONQ_VECS; |
| 1236 | v_budget = min_t(int, v_budget, (int)adapter->vf_res->max_vectors); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1237 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1238 | adapter->msix_entries = kcalloc(v_budget, |
| 1239 | sizeof(struct msix_entry), GFP_KERNEL); |
| 1240 | if (!adapter->msix_entries) { |
| 1241 | err = -ENOMEM; |
| 1242 | goto out; |
| 1243 | } |
| 1244 | |
| 1245 | for (vector = 0; vector < v_budget; vector++) |
| 1246 | adapter->msix_entries[vector].entry = vector; |
| 1247 | |
Mitch Williams | 313ed2d | 2015-08-27 11:42:31 -0400 | [diff] [blame] | 1248 | err = i40evf_acquire_msix_vectors(adapter, v_budget); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1249 | |
| 1250 | out: |
Mitch Williams | e6c4cf6 | 2015-11-06 15:26:00 -0800 | [diff] [blame] | 1251 | netif_set_real_num_rx_queues(adapter->netdev, pairs); |
| 1252 | netif_set_real_num_tx_queues(adapter->netdev, pairs); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1253 | return err; |
| 1254 | } |
| 1255 | |
| 1256 | /** |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1257 | * i40e_config_rss_aq - Configure RSS keys and lut by using AQ commands |
| 1258 | * @adapter: board private structure |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1259 | * |
| 1260 | * Return 0 on success, negative on failure |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1261 | **/ |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1262 | static int i40evf_config_rss_aq(struct i40evf_adapter *adapter) |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1263 | { |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1264 | struct i40e_aqc_get_set_rss_key_data *rss_key = |
| 1265 | (struct i40e_aqc_get_set_rss_key_data *)adapter->rss_key; |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1266 | struct i40e_hw *hw = &adapter->hw; |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1267 | int ret = 0; |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1268 | |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1269 | if (adapter->current_op != I40E_VIRTCHNL_OP_UNKNOWN) { |
| 1270 | /* bail because we already have a command pending */ |
Masanari Iida | e3d132d | 2015-10-16 21:14:29 +0900 | [diff] [blame] | 1271 | dev_err(&adapter->pdev->dev, "Cannot configure RSS, command %d pending\n", |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1272 | adapter->current_op); |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1273 | return -EBUSY; |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1274 | } |
| 1275 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1276 | ret = i40evf_aq_set_rss_key(hw, adapter->vsi.id, rss_key); |
| 1277 | if (ret) { |
| 1278 | dev_err(&adapter->pdev->dev, "Cannot set RSS key, err %s aq_err %s\n", |
| 1279 | i40evf_stat_str(hw, ret), |
| 1280 | i40evf_aq_str(hw, hw->aq.asq_last_status)); |
| 1281 | return ret; |
| 1282 | |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1283 | } |
| 1284 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1285 | ret = i40evf_aq_set_rss_lut(hw, adapter->vsi.id, false, |
| 1286 | adapter->rss_lut, adapter->rss_lut_size); |
| 1287 | if (ret) { |
| 1288 | dev_err(&adapter->pdev->dev, "Cannot set RSS lut, err %s aq_err %s\n", |
| 1289 | i40evf_stat_str(hw, ret), |
| 1290 | i40evf_aq_str(hw, hw->aq.asq_last_status)); |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1291 | } |
| 1292 | |
| 1293 | return ret; |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1294 | |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | /** |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1298 | * i40evf_config_rss_reg - Configure RSS keys and lut by writing registers |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1299 | * @adapter: board private structure |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1300 | * |
| 1301 | * Returns 0 on success, negative on failure |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1302 | **/ |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1303 | static int i40evf_config_rss_reg(struct i40evf_adapter *adapter) |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1304 | { |
| 1305 | struct i40e_hw *hw = &adapter->hw; |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1306 | u32 *dw; |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1307 | u16 i; |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1308 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1309 | dw = (u32 *)adapter->rss_key; |
| 1310 | for (i = 0; i <= adapter->rss_key_size / 4; i++) |
| 1311 | wr32(hw, I40E_VFQF_HKEY(i), dw[i]); |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1312 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1313 | dw = (u32 *)adapter->rss_lut; |
| 1314 | for (i = 0; i <= adapter->rss_lut_size / 4; i++) |
| 1315 | wr32(hw, I40E_VFQF_HLUT(i), dw[i]); |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1316 | |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1317 | i40e_flush(hw); |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1318 | |
| 1319 | return 0; |
| 1320 | } |
| 1321 | |
| 1322 | /** |
| 1323 | * i40evf_config_rss - Configure RSS keys and lut |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1324 | * @adapter: board private structure |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1325 | * |
| 1326 | * Returns 0 on success, negative on failure |
| 1327 | **/ |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1328 | int i40evf_config_rss(struct i40evf_adapter *adapter) |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1329 | { |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1330 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1331 | if (RSS_PF(adapter)) { |
| 1332 | adapter->aq_required |= I40EVF_FLAG_AQ_SET_RSS_LUT | |
| 1333 | I40EVF_FLAG_AQ_SET_RSS_KEY; |
| 1334 | return 0; |
| 1335 | } else if (RSS_AQ(adapter)) { |
| 1336 | return i40evf_config_rss_aq(adapter); |
| 1337 | } else { |
| 1338 | return i40evf_config_rss_reg(adapter); |
| 1339 | } |
Helin Zhang | 90b02b4 | 2015-10-26 19:44:33 -0400 | [diff] [blame] | 1340 | } |
| 1341 | |
| 1342 | /** |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1343 | * i40evf_fill_rss_lut - Fill the lut with default values |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1344 | * @adapter: board private structure |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1345 | **/ |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1346 | static void i40evf_fill_rss_lut(struct i40evf_adapter *adapter) |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1347 | { |
| 1348 | u16 i; |
| 1349 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1350 | for (i = 0; i < adapter->rss_lut_size; i++) |
| 1351 | adapter->rss_lut[i] = i % adapter->num_active_queues; |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1352 | } |
| 1353 | |
| 1354 | /** |
Helin Zhang | 96a8198 | 2015-10-26 19:44:31 -0400 | [diff] [blame] | 1355 | * i40evf_init_rss - Prepare for RSS |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1356 | * @adapter: board private structure |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1357 | * |
| 1358 | * Return 0 on success, negative on failure |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1359 | **/ |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1360 | static int i40evf_init_rss(struct i40evf_adapter *adapter) |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1361 | { |
| 1362 | struct i40e_hw *hw = &adapter->hw; |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1363 | int ret; |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1364 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1365 | if (!RSS_PF(adapter)) { |
| 1366 | /* Enable PCTYPES for RSS, TCP/UDP with IPv4/IPv6 */ |
| 1367 | if (adapter->vf_res->vf_offload_flags & |
| 1368 | I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2) |
| 1369 | adapter->hena = I40E_DEFAULT_RSS_HENA_EXPANDED; |
| 1370 | else |
| 1371 | adapter->hena = I40E_DEFAULT_RSS_HENA; |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1372 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1373 | wr32(hw, I40E_VFQF_HENA(0), (u32)adapter->hena); |
| 1374 | wr32(hw, I40E_VFQF_HENA(1), (u32)(adapter->hena >> 32)); |
| 1375 | } |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 1376 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1377 | i40evf_fill_rss_lut(adapter); |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 1378 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1379 | netdev_rss_key_fill((void *)adapter->rss_key, adapter->rss_key_size); |
| 1380 | ret = i40evf_config_rss(adapter); |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 1381 | |
| 1382 | return ret; |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1383 | } |
| 1384 | |
| 1385 | /** |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1386 | * i40evf_alloc_q_vectors - Allocate memory for interrupt vectors |
| 1387 | * @adapter: board private structure to initialize |
| 1388 | * |
| 1389 | * We allocate one q_vector per queue interrupt. If allocation fails we |
| 1390 | * return -ENOMEM. |
| 1391 | **/ |
| 1392 | static int i40evf_alloc_q_vectors(struct i40evf_adapter *adapter) |
| 1393 | { |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 1394 | int q_idx = 0, num_q_vectors; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1395 | struct i40e_q_vector *q_vector; |
| 1396 | |
| 1397 | num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1398 | adapter->q_vectors = kcalloc(num_q_vectors, sizeof(*q_vector), |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 1399 | GFP_KERNEL); |
| 1400 | if (!adapter->q_vectors) |
Alan Cox | 311f23e | 2016-03-01 16:02:15 -0800 | [diff] [blame] | 1401 | return -ENOMEM; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1402 | |
| 1403 | for (q_idx = 0; q_idx < num_q_vectors; q_idx++) { |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 1404 | q_vector = &adapter->q_vectors[q_idx]; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1405 | q_vector->adapter = adapter; |
| 1406 | q_vector->vsi = &adapter->vsi; |
| 1407 | q_vector->v_idx = q_idx; |
| 1408 | netif_napi_add(adapter->netdev, &q_vector->napi, |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 1409 | i40evf_napi_poll, NAPI_POLL_WEIGHT); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1410 | } |
| 1411 | |
| 1412 | return 0; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1413 | } |
| 1414 | |
| 1415 | /** |
| 1416 | * i40evf_free_q_vectors - Free memory allocated for interrupt vectors |
| 1417 | * @adapter: board private structure to initialize |
| 1418 | * |
| 1419 | * This function frees the memory allocated to the q_vectors. In addition if |
| 1420 | * NAPI is enabled it will delete any references to the NAPI struct prior |
| 1421 | * to freeing the q_vector. |
| 1422 | **/ |
| 1423 | static void i40evf_free_q_vectors(struct i40evf_adapter *adapter) |
| 1424 | { |
| 1425 | int q_idx, num_q_vectors; |
| 1426 | int napi_vectors; |
| 1427 | |
| 1428 | num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 1429 | napi_vectors = adapter->num_active_queues; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1430 | |
| 1431 | for (q_idx = 0; q_idx < num_q_vectors; q_idx++) { |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 1432 | struct i40e_q_vector *q_vector = &adapter->q_vectors[q_idx]; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1433 | if (q_idx < napi_vectors) |
| 1434 | netif_napi_del(&q_vector->napi); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1435 | } |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 1436 | kfree(adapter->q_vectors); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1437 | } |
| 1438 | |
| 1439 | /** |
| 1440 | * i40evf_reset_interrupt_capability - Reset MSIX setup |
| 1441 | * @adapter: board private structure |
| 1442 | * |
| 1443 | **/ |
| 1444 | void i40evf_reset_interrupt_capability(struct i40evf_adapter *adapter) |
| 1445 | { |
| 1446 | pci_disable_msix(adapter->pdev); |
| 1447 | kfree(adapter->msix_entries); |
| 1448 | adapter->msix_entries = NULL; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1449 | } |
| 1450 | |
| 1451 | /** |
| 1452 | * i40evf_init_interrupt_scheme - Determine if MSIX is supported and init |
| 1453 | * @adapter: board private structure to initialize |
| 1454 | * |
| 1455 | **/ |
| 1456 | int i40evf_init_interrupt_scheme(struct i40evf_adapter *adapter) |
| 1457 | { |
| 1458 | int err; |
| 1459 | |
Jacob Keller | 62fe2a8 | 2016-07-27 12:02:33 -0700 | [diff] [blame] | 1460 | rtnl_lock(); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1461 | err = i40evf_set_interrupt_capability(adapter); |
Jacob Keller | 62fe2a8 | 2016-07-27 12:02:33 -0700 | [diff] [blame] | 1462 | rtnl_unlock(); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1463 | if (err) { |
| 1464 | dev_err(&adapter->pdev->dev, |
| 1465 | "Unable to setup interrupt capabilities\n"); |
| 1466 | goto err_set_interrupt; |
| 1467 | } |
| 1468 | |
| 1469 | err = i40evf_alloc_q_vectors(adapter); |
| 1470 | if (err) { |
| 1471 | dev_err(&adapter->pdev->dev, |
| 1472 | "Unable to allocate memory for queue vectors\n"); |
| 1473 | goto err_alloc_q_vectors; |
| 1474 | } |
| 1475 | |
| 1476 | err = i40evf_alloc_queues(adapter); |
| 1477 | if (err) { |
| 1478 | dev_err(&adapter->pdev->dev, |
| 1479 | "Unable to allocate memory for queues\n"); |
| 1480 | goto err_alloc_queues; |
| 1481 | } |
| 1482 | |
| 1483 | dev_info(&adapter->pdev->dev, "Multiqueue %s: Queue pair count = %u", |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 1484 | (adapter->num_active_queues > 1) ? "Enabled" : "Disabled", |
| 1485 | adapter->num_active_queues); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1486 | |
| 1487 | return 0; |
| 1488 | err_alloc_queues: |
| 1489 | i40evf_free_q_vectors(adapter); |
| 1490 | err_alloc_q_vectors: |
| 1491 | i40evf_reset_interrupt_capability(adapter); |
| 1492 | err_set_interrupt: |
| 1493 | return err; |
| 1494 | } |
| 1495 | |
| 1496 | /** |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1497 | * i40evf_free_rss - Free memory used by RSS structs |
| 1498 | * @adapter: board private structure |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 1499 | **/ |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1500 | static void i40evf_free_rss(struct i40evf_adapter *adapter) |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 1501 | { |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1502 | kfree(adapter->rss_key); |
| 1503 | adapter->rss_key = NULL; |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 1504 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1505 | kfree(adapter->rss_lut); |
| 1506 | adapter->rss_lut = NULL; |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 1507 | } |
| 1508 | |
| 1509 | /** |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1510 | * i40evf_watchdog_timer - Periodic call-back timer |
| 1511 | * @data: pointer to adapter disguised as unsigned long |
| 1512 | **/ |
| 1513 | static void i40evf_watchdog_timer(unsigned long data) |
| 1514 | { |
| 1515 | struct i40evf_adapter *adapter = (struct i40evf_adapter *)data; |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 1516 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1517 | schedule_work(&adapter->watchdog_task); |
| 1518 | /* timer will be rescheduled in watchdog task */ |
| 1519 | } |
| 1520 | |
| 1521 | /** |
| 1522 | * i40evf_watchdog_task - Periodic call-back task |
| 1523 | * @work: pointer to work_struct |
| 1524 | **/ |
| 1525 | static void i40evf_watchdog_task(struct work_struct *work) |
| 1526 | { |
| 1527 | struct i40evf_adapter *adapter = container_of(work, |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 1528 | struct i40evf_adapter, |
| 1529 | watchdog_task); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1530 | struct i40e_hw *hw = &adapter->hw; |
Mitch Williams | ee5c1e9 | 2015-08-28 17:55:53 -0400 | [diff] [blame] | 1531 | u32 reg_val; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1532 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1533 | if (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section)) |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1534 | goto restart_watchdog; |
| 1535 | |
| 1536 | if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) { |
Mitch Williams | ee5c1e9 | 2015-08-28 17:55:53 -0400 | [diff] [blame] | 1537 | reg_val = rd32(hw, I40E_VFGEN_RSTAT) & |
| 1538 | I40E_VFGEN_RSTAT_VFR_STATE_MASK; |
| 1539 | if ((reg_val == I40E_VFR_VFACTIVE) || |
| 1540 | (reg_val == I40E_VFR_COMPLETED)) { |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1541 | /* A chance for redemption! */ |
| 1542 | dev_err(&adapter->pdev->dev, "Hardware came out of reset. Attempting reinit.\n"); |
| 1543 | adapter->state = __I40EVF_STARTUP; |
| 1544 | adapter->flags &= ~I40EVF_FLAG_PF_COMMS_FAILED; |
| 1545 | schedule_delayed_work(&adapter->init_task, 10); |
| 1546 | clear_bit(__I40EVF_IN_CRITICAL_TASK, |
| 1547 | &adapter->crit_section); |
| 1548 | /* Don't reschedule the watchdog, since we've restarted |
| 1549 | * the init task. When init_task contacts the PF and |
| 1550 | * gets everything set up again, it'll restart the |
| 1551 | * watchdog for us. Down, boy. Sit. Stay. Woof. |
| 1552 | */ |
| 1553 | return; |
| 1554 | } |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1555 | adapter->aq_required = 0; |
| 1556 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; |
| 1557 | goto watchdog_done; |
| 1558 | } |
| 1559 | |
| 1560 | if ((adapter->state < __I40EVF_DOWN) || |
| 1561 | (adapter->flags & I40EVF_FLAG_RESET_PENDING)) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1562 | goto watchdog_done; |
| 1563 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1564 | /* check for reset */ |
Mitch Williams | ee5c1e9 | 2015-08-28 17:55:53 -0400 | [diff] [blame] | 1565 | reg_val = rd32(hw, I40E_VF_ARQLEN1) & I40E_VF_ARQLEN1_ARQENABLE_MASK; |
| 1566 | if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING) && !reg_val) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1567 | adapter->state = __I40EVF_RESETTING; |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1568 | adapter->flags |= I40EVF_FLAG_RESET_PENDING; |
Mitch Williams | 249c8b8 | 2014-05-10 04:49:04 +0000 | [diff] [blame] | 1569 | dev_err(&adapter->pdev->dev, "Hardware reset detected\n"); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1570 | schedule_work(&adapter->reset_task); |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1571 | adapter->aq_required = 0; |
| 1572 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1573 | goto watchdog_done; |
| 1574 | } |
| 1575 | |
| 1576 | /* Process admin queue tasks. After init, everything gets done |
| 1577 | * here so we don't race on the admin queue. |
| 1578 | */ |
Mitch Williams | ed63696 | 2015-04-07 19:45:32 -0400 | [diff] [blame] | 1579 | if (adapter->current_op) { |
Mitch A Williams | 0758e7cb | 2014-12-09 08:53:08 +0000 | [diff] [blame] | 1580 | if (!i40evf_asq_done(hw)) { |
| 1581 | dev_dbg(&adapter->pdev->dev, "Admin queue timeout\n"); |
| 1582 | i40evf_send_api_ver(adapter); |
| 1583 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1584 | goto watchdog_done; |
Mitch A Williams | 0758e7cb | 2014-12-09 08:53:08 +0000 | [diff] [blame] | 1585 | } |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 1586 | if (adapter->aq_required & I40EVF_FLAG_AQ_GET_CONFIG) { |
| 1587 | i40evf_send_vf_config_msg(adapter); |
| 1588 | goto watchdog_done; |
| 1589 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1590 | |
Mitch Williams | e284fc8 | 2015-03-27 00:12:09 -0700 | [diff] [blame] | 1591 | if (adapter->aq_required & I40EVF_FLAG_AQ_DISABLE_QUEUES) { |
| 1592 | i40evf_disable_queues(adapter); |
| 1593 | goto watchdog_done; |
| 1594 | } |
| 1595 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1596 | if (adapter->aq_required & I40EVF_FLAG_AQ_MAP_VECTORS) { |
| 1597 | i40evf_map_queues(adapter); |
| 1598 | goto watchdog_done; |
| 1599 | } |
| 1600 | |
| 1601 | if (adapter->aq_required & I40EVF_FLAG_AQ_ADD_MAC_FILTER) { |
| 1602 | i40evf_add_ether_addrs(adapter); |
| 1603 | goto watchdog_done; |
| 1604 | } |
| 1605 | |
| 1606 | if (adapter->aq_required & I40EVF_FLAG_AQ_ADD_VLAN_FILTER) { |
| 1607 | i40evf_add_vlans(adapter); |
| 1608 | goto watchdog_done; |
| 1609 | } |
| 1610 | |
| 1611 | if (adapter->aq_required & I40EVF_FLAG_AQ_DEL_MAC_FILTER) { |
| 1612 | i40evf_del_ether_addrs(adapter); |
| 1613 | goto watchdog_done; |
| 1614 | } |
| 1615 | |
| 1616 | if (adapter->aq_required & I40EVF_FLAG_AQ_DEL_VLAN_FILTER) { |
| 1617 | i40evf_del_vlans(adapter); |
| 1618 | goto watchdog_done; |
| 1619 | } |
| 1620 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1621 | if (adapter->aq_required & I40EVF_FLAG_AQ_CONFIGURE_QUEUES) { |
| 1622 | i40evf_configure_queues(adapter); |
| 1623 | goto watchdog_done; |
| 1624 | } |
| 1625 | |
| 1626 | if (adapter->aq_required & I40EVF_FLAG_AQ_ENABLE_QUEUES) { |
| 1627 | i40evf_enable_queues(adapter); |
| 1628 | goto watchdog_done; |
| 1629 | } |
| 1630 | |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1631 | if (adapter->aq_required & I40EVF_FLAG_AQ_CONFIGURE_RSS) { |
| 1632 | /* This message goes straight to the firmware, not the |
| 1633 | * PF, so we don't have to set current_op as we will |
| 1634 | * not get a response through the ARQ. |
| 1635 | */ |
Helin Zhang | 96a8198 | 2015-10-26 19:44:31 -0400 | [diff] [blame] | 1636 | i40evf_init_rss(adapter); |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1637 | adapter->aq_required &= ~I40EVF_FLAG_AQ_CONFIGURE_RSS; |
| 1638 | goto watchdog_done; |
| 1639 | } |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 1640 | if (adapter->aq_required & I40EVF_FLAG_AQ_GET_HENA) { |
| 1641 | i40evf_get_hena(adapter); |
| 1642 | goto watchdog_done; |
| 1643 | } |
| 1644 | if (adapter->aq_required & I40EVF_FLAG_AQ_SET_HENA) { |
| 1645 | i40evf_set_hena(adapter); |
| 1646 | goto watchdog_done; |
| 1647 | } |
| 1648 | if (adapter->aq_required & I40EVF_FLAG_AQ_SET_RSS_KEY) { |
| 1649 | i40evf_set_rss_key(adapter); |
| 1650 | goto watchdog_done; |
| 1651 | } |
| 1652 | if (adapter->aq_required & I40EVF_FLAG_AQ_SET_RSS_LUT) { |
| 1653 | i40evf_set_rss_lut(adapter); |
| 1654 | goto watchdog_done; |
| 1655 | } |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 1656 | |
Anjali Singhai Jain | 47d3483 | 2016-04-12 08:30:52 -0700 | [diff] [blame] | 1657 | if (adapter->aq_required & I40EVF_FLAG_AQ_REQUEST_PROMISC) { |
| 1658 | i40evf_set_promiscuous(adapter, I40E_FLAG_VF_UNICAST_PROMISC | |
| 1659 | I40E_FLAG_VF_MULTICAST_PROMISC); |
| 1660 | goto watchdog_done; |
| 1661 | } |
| 1662 | |
Anjali Singhai Jain | f42a5c7 | 2016-05-03 15:13:10 -0700 | [diff] [blame] | 1663 | if (adapter->aq_required & I40EVF_FLAG_AQ_REQUEST_ALLMULTI) { |
| 1664 | i40evf_set_promiscuous(adapter, I40E_FLAG_VF_MULTICAST_PROMISC); |
| 1665 | goto watchdog_done; |
| 1666 | } |
| 1667 | |
| 1668 | if ((adapter->aq_required & I40EVF_FLAG_AQ_RELEASE_PROMISC) && |
| 1669 | (adapter->aq_required & I40EVF_FLAG_AQ_RELEASE_ALLMULTI)) { |
Anjali Singhai Jain | 47d3483 | 2016-04-12 08:30:52 -0700 | [diff] [blame] | 1670 | i40evf_set_promiscuous(adapter, 0); |
| 1671 | goto watchdog_done; |
| 1672 | } |
| 1673 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1674 | if (adapter->state == __I40EVF_RUNNING) |
| 1675 | i40evf_request_stats(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1676 | watchdog_done: |
Mitch A Williams | 4870e17 | 2014-12-09 08:53:06 +0000 | [diff] [blame] | 1677 | if (adapter->state == __I40EVF_RUNNING) { |
| 1678 | i40evf_irq_enable_queues(adapter, ~0); |
| 1679 | i40evf_fire_sw_int(adapter, 0xFF); |
| 1680 | } else { |
| 1681 | i40evf_fire_sw_int(adapter, 0x1); |
| 1682 | } |
| 1683 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1684 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
| 1685 | restart_watchdog: |
Ashish Shah | d3e2edb | 2014-08-01 13:27:12 -0700 | [diff] [blame] | 1686 | if (adapter->state == __I40EVF_REMOVE) |
| 1687 | return; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1688 | if (adapter->aq_required) |
| 1689 | mod_timer(&adapter->watchdog_timer, |
| 1690 | jiffies + msecs_to_jiffies(20)); |
| 1691 | else |
| 1692 | mod_timer(&adapter->watchdog_timer, jiffies + (HZ * 2)); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1693 | schedule_work(&adapter->adminq_task); |
| 1694 | } |
| 1695 | |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1696 | #define I40EVF_RESET_WAIT_MS 10 |
| 1697 | #define I40EVF_RESET_WAIT_COUNT 500 |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1698 | /** |
| 1699 | * i40evf_reset_task - Call-back task to handle hardware reset |
| 1700 | * @work: pointer to work_struct |
| 1701 | * |
| 1702 | * During reset we need to shut down and reinitialize the admin queue |
| 1703 | * before we can use it to communicate with the PF again. We also clear |
| 1704 | * and reinit the rings because that context is lost as well. |
| 1705 | **/ |
| 1706 | static void i40evf_reset_task(struct work_struct *work) |
| 1707 | { |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1708 | struct i40evf_adapter *adapter = container_of(work, |
| 1709 | struct i40evf_adapter, |
| 1710 | reset_task); |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1711 | struct net_device *netdev = adapter->netdev; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1712 | struct i40e_hw *hw = &adapter->hw; |
Mitch Williams | 40d0136 | 2015-10-01 14:37:37 -0400 | [diff] [blame] | 1713 | struct i40evf_vlan_filter *vlf; |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1714 | struct i40evf_mac_filter *f; |
Mitch Williams | ee5c1e9 | 2015-08-28 17:55:53 -0400 | [diff] [blame] | 1715 | u32 reg_val; |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1716 | int i = 0, err; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1717 | |
| 1718 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, |
| 1719 | &adapter->crit_section)) |
Neerav Parikh | f98a200 | 2014-09-13 07:40:44 +0000 | [diff] [blame] | 1720 | usleep_range(500, 1000); |
Mitch Williams | 3526d80 | 2014-03-06 08:59:56 +0000 | [diff] [blame] | 1721 | |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1722 | i40evf_misc_irq_disable(adapter); |
Mitch Williams | 3526d80 | 2014-03-06 08:59:56 +0000 | [diff] [blame] | 1723 | if (adapter->flags & I40EVF_FLAG_RESET_NEEDED) { |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1724 | adapter->flags &= ~I40EVF_FLAG_RESET_NEEDED; |
| 1725 | /* Restart the AQ here. If we have been reset but didn't |
| 1726 | * detect it, or if the PF had to reinit, our AQ will be hosed. |
| 1727 | */ |
| 1728 | i40evf_shutdown_adminq(hw); |
| 1729 | i40evf_init_adminq(hw); |
Mitch Williams | 3526d80 | 2014-03-06 08:59:56 +0000 | [diff] [blame] | 1730 | i40evf_request_reset(adapter); |
| 1731 | } |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1732 | adapter->flags |= I40EVF_FLAG_RESET_PENDING; |
Mitch Williams | 3526d80 | 2014-03-06 08:59:56 +0000 | [diff] [blame] | 1733 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1734 | /* poll until we see the reset actually happen */ |
| 1735 | for (i = 0; i < I40EVF_RESET_WAIT_COUNT; i++) { |
Mitch Williams | ee5c1e9 | 2015-08-28 17:55:53 -0400 | [diff] [blame] | 1736 | reg_val = rd32(hw, I40E_VF_ARQLEN1) & |
| 1737 | I40E_VF_ARQLEN1_ARQENABLE_MASK; |
| 1738 | if (!reg_val) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1739 | break; |
Mitch Williams | ee5c1e9 | 2015-08-28 17:55:53 -0400 | [diff] [blame] | 1740 | usleep_range(5000, 10000); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1741 | } |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1742 | if (i == I40EVF_RESET_WAIT_COUNT) { |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1743 | dev_info(&adapter->pdev->dev, "Never saw reset\n"); |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1744 | goto continue_reset; /* act like the reset happened */ |
| 1745 | } |
| 1746 | |
| 1747 | /* wait until the reset is complete and the PF is responding to us */ |
| 1748 | for (i = 0; i < I40EVF_RESET_WAIT_COUNT; i++) { |
Jacob Keller | 7d3f04a | 2016-10-05 09:30:45 -0700 | [diff] [blame] | 1749 | /* sleep first to make sure a minimum wait time is met */ |
| 1750 | msleep(I40EVF_RESET_WAIT_MS); |
| 1751 | |
Mitch Williams | ee5c1e9 | 2015-08-28 17:55:53 -0400 | [diff] [blame] | 1752 | reg_val = rd32(hw, I40E_VFGEN_RSTAT) & |
| 1753 | I40E_VFGEN_RSTAT_VFR_STATE_MASK; |
| 1754 | if (reg_val == I40E_VFR_VFACTIVE) |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1755 | break; |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1756 | } |
Jacob Keller | 7d3f04a | 2016-10-05 09:30:45 -0700 | [diff] [blame] | 1757 | |
Mitch Williams | 509a447 | 2015-12-23 12:05:52 -0800 | [diff] [blame] | 1758 | pci_set_master(adapter->pdev); |
Jacob Keller | 7d3f04a | 2016-10-05 09:30:45 -0700 | [diff] [blame] | 1759 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1760 | if (i == I40EVF_RESET_WAIT_COUNT) { |
Shannon Nelson | 874d1a1 | 2015-09-03 17:18:57 -0400 | [diff] [blame] | 1761 | struct i40evf_mac_filter *ftmp; |
Mitch Williams | 6ba36a2 | 2014-08-01 13:27:14 -0700 | [diff] [blame] | 1762 | struct i40evf_vlan_filter *fv, *fvtmp; |
| 1763 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1764 | /* reset never finished */ |
Mitch Williams | 80e7289 | 2014-05-10 04:49:06 +0000 | [diff] [blame] | 1765 | dev_err(&adapter->pdev->dev, "Reset never finished (%x)\n", |
Mitch Williams | ee5c1e9 | 2015-08-28 17:55:53 -0400 | [diff] [blame] | 1766 | reg_val); |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1767 | adapter->flags |= I40EVF_FLAG_PF_COMMS_FAILED; |
| 1768 | |
Mitch Williams | 169f407 | 2014-04-01 07:11:50 +0000 | [diff] [blame] | 1769 | if (netif_running(adapter->netdev)) { |
| 1770 | set_bit(__I40E_DOWN, &adapter->vsi.state); |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1771 | netif_carrier_off(netdev); |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1772 | netif_tx_disable(netdev); |
Sridhar Samudrala | 3f341ac | 2016-09-01 22:27:27 +0200 | [diff] [blame] | 1773 | adapter->link_up = false; |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1774 | i40evf_napi_disable_all(adapter); |
| 1775 | i40evf_irq_disable(adapter); |
Mitch Williams | 169f407 | 2014-04-01 07:11:50 +0000 | [diff] [blame] | 1776 | i40evf_free_traffic_irqs(adapter); |
| 1777 | i40evf_free_all_tx_resources(adapter); |
| 1778 | i40evf_free_all_rx_resources(adapter); |
| 1779 | } |
Mitch Williams | 6ba36a2 | 2014-08-01 13:27:14 -0700 | [diff] [blame] | 1780 | |
| 1781 | /* Delete all of the filters, both MAC and VLAN. */ |
| 1782 | list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, |
| 1783 | list) { |
| 1784 | list_del(&f->list); |
| 1785 | kfree(f); |
| 1786 | } |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1787 | |
Mitch Williams | 6ba36a2 | 2014-08-01 13:27:14 -0700 | [diff] [blame] | 1788 | list_for_each_entry_safe(fv, fvtmp, &adapter->vlan_filter_list, |
| 1789 | list) { |
| 1790 | list_del(&fv->list); |
| 1791 | kfree(fv); |
| 1792 | } |
| 1793 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1794 | i40evf_free_misc_irq(adapter); |
| 1795 | i40evf_reset_interrupt_capability(adapter); |
| 1796 | i40evf_free_queues(adapter); |
Mitch Williams | d31944d | 2014-08-01 13:27:13 -0700 | [diff] [blame] | 1797 | i40evf_free_q_vectors(adapter); |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1798 | kfree(adapter->vf_res); |
| 1799 | i40evf_shutdown_adminq(hw); |
| 1800 | adapter->netdev->flags &= ~IFF_UP; |
| 1801 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1802 | adapter->flags &= ~I40EVF_FLAG_RESET_PENDING; |
Mitch Williams | 9b9344f | 2016-01-15 14:33:19 -0800 | [diff] [blame] | 1803 | adapter->state = __I40EVF_DOWN; |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1804 | dev_info(&adapter->pdev->dev, "Reset task did not complete, VF disabled\n"); |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1805 | return; /* Do not attempt to reinit. It's dead, Jim. */ |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1806 | } |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1807 | |
| 1808 | continue_reset: |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1809 | if (netif_running(adapter->netdev)) { |
| 1810 | netif_carrier_off(netdev); |
| 1811 | netif_tx_stop_all_queues(netdev); |
Sridhar Samudrala | 3f341ac | 2016-09-01 22:27:27 +0200 | [diff] [blame] | 1812 | adapter->link_up = false; |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1813 | i40evf_napi_disable_all(adapter); |
| 1814 | } |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1815 | i40evf_irq_disable(adapter); |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1816 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1817 | adapter->state = __I40EVF_RESETTING; |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1818 | adapter->flags &= ~I40EVF_FLAG_RESET_PENDING; |
| 1819 | |
| 1820 | /* free the Tx/Rx rings and descriptors, might be better to just |
| 1821 | * re-use them sometime in the future |
| 1822 | */ |
| 1823 | i40evf_free_all_rx_resources(adapter); |
| 1824 | i40evf_free_all_tx_resources(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1825 | |
| 1826 | /* kill and reinit the admin queue */ |
Lihong Yang | 903e683 | 2016-09-06 18:05:05 -0700 | [diff] [blame] | 1827 | i40evf_shutdown_adminq(hw); |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1828 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1829 | err = i40evf_init_adminq(hw); |
| 1830 | if (err) |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1831 | dev_info(&adapter->pdev->dev, "Failed to init adminq: %d\n", |
| 1832 | err); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1833 | |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 1834 | adapter->aq_required = I40EVF_FLAG_AQ_GET_CONFIG; |
| 1835 | adapter->aq_required |= I40EVF_FLAG_AQ_MAP_VECTORS; |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1836 | |
| 1837 | /* re-add all MAC filters */ |
| 1838 | list_for_each_entry(f, &adapter->mac_filter_list, list) { |
| 1839 | f->add = true; |
| 1840 | } |
| 1841 | /* re-add all VLAN filters */ |
Mitch Williams | 40d0136 | 2015-10-01 14:37:37 -0400 | [diff] [blame] | 1842 | list_for_each_entry(vlf, &adapter->vlan_filter_list, list) { |
| 1843 | vlf->add = true; |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1844 | } |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 1845 | adapter->aq_required |= I40EVF_FLAG_AQ_ADD_MAC_FILTER; |
Mitch Williams | ac833bb | 2015-01-29 07:17:19 +0000 | [diff] [blame] | 1846 | adapter->aq_required |= I40EVF_FLAG_AQ_ADD_VLAN_FILTER; |
Avinash Dayanand | bf3a178 | 2016-08-17 16:04:08 -0700 | [diff] [blame] | 1847 | /* Open RDMA Client again */ |
| 1848 | adapter->aq_required |= I40EVF_FLAG_SERVICE_CLIENT_REQUESTED; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1849 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1850 | i40evf_misc_irq_enable(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1851 | |
| 1852 | mod_timer(&adapter->watchdog_timer, jiffies + 2); |
| 1853 | |
| 1854 | if (netif_running(adapter->netdev)) { |
| 1855 | /* allocate transmit descriptors */ |
| 1856 | err = i40evf_setup_all_tx_resources(adapter); |
| 1857 | if (err) |
| 1858 | goto reset_err; |
| 1859 | |
| 1860 | /* allocate receive descriptors */ |
| 1861 | err = i40evf_setup_all_rx_resources(adapter); |
| 1862 | if (err) |
| 1863 | goto reset_err; |
| 1864 | |
| 1865 | i40evf_configure(adapter); |
| 1866 | |
Bimmy Pujari | cb130a0 | 2016-09-06 18:05:03 -0700 | [diff] [blame] | 1867 | i40evf_up_complete(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1868 | |
| 1869 | i40evf_irq_enable(adapter, true); |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1870 | } else { |
| 1871 | adapter->state = __I40EVF_DOWN; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1872 | } |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1873 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1874 | return; |
| 1875 | reset_err: |
Mitch Williams | 80e7289 | 2014-05-10 04:49:06 +0000 | [diff] [blame] | 1876 | dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n"); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1877 | i40evf_close(adapter->netdev); |
| 1878 | } |
| 1879 | |
| 1880 | /** |
| 1881 | * i40evf_adminq_task - worker thread to clean the admin queue |
| 1882 | * @work: pointer to work_struct containing our data |
| 1883 | **/ |
| 1884 | static void i40evf_adminq_task(struct work_struct *work) |
| 1885 | { |
| 1886 | struct i40evf_adapter *adapter = |
| 1887 | container_of(work, struct i40evf_adapter, adminq_task); |
| 1888 | struct i40e_hw *hw = &adapter->hw; |
| 1889 | struct i40e_arq_event_info event; |
| 1890 | struct i40e_virtchnl_msg *v_msg; |
| 1891 | i40e_status ret; |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1892 | u32 val, oldval; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1893 | u16 pending; |
| 1894 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1895 | if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) |
Mitch A Williams | 7235448 | 2014-12-09 08:53:07 +0000 | [diff] [blame] | 1896 | goto out; |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 1897 | |
Mitch Williams | 1001dc3 | 2014-11-11 20:02:19 +0000 | [diff] [blame] | 1898 | event.buf_len = I40EVF_MAX_AQ_BUF_SIZE; |
| 1899 | event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL); |
Mitch Williams | 249c8b8 | 2014-05-10 04:49:04 +0000 | [diff] [blame] | 1900 | if (!event.msg_buf) |
Mitch A Williams | 7235448 | 2014-12-09 08:53:07 +0000 | [diff] [blame] | 1901 | goto out; |
Mitch Williams | 249c8b8 | 2014-05-10 04:49:04 +0000 | [diff] [blame] | 1902 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1903 | v_msg = (struct i40e_virtchnl_msg *)&event.desc; |
| 1904 | do { |
| 1905 | ret = i40evf_clean_arq_element(hw, &event, &pending); |
Mitch Williams | 8b011eb | 2015-01-09 11:18:17 +0000 | [diff] [blame] | 1906 | if (ret || !v_msg->v_opcode) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1907 | break; /* No event to process or error cleaning ARQ */ |
| 1908 | |
| 1909 | i40evf_virtchnl_completion(adapter, v_msg->v_opcode, |
| 1910 | v_msg->v_retval, event.msg_buf, |
Mitch Williams | 1001dc3 | 2014-11-11 20:02:19 +0000 | [diff] [blame] | 1911 | event.msg_len); |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 1912 | if (pending != 0) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1913 | memset(event.msg_buf, 0, I40EVF_MAX_AQ_BUF_SIZE); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1914 | } while (pending); |
| 1915 | |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1916 | if ((adapter->flags & |
| 1917 | (I40EVF_FLAG_RESET_PENDING | I40EVF_FLAG_RESET_NEEDED)) || |
| 1918 | adapter->state == __I40EVF_RESETTING) |
| 1919 | goto freedom; |
| 1920 | |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1921 | /* check for error indications */ |
| 1922 | val = rd32(hw, hw->aq.arq.len); |
Mitch Williams | 19b73d8 | 2016-03-10 14:59:49 -0800 | [diff] [blame] | 1923 | if (val == 0xdeadbeef) /* indicates device in reset */ |
| 1924 | goto freedom; |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1925 | oldval = val; |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1926 | if (val & I40E_VF_ARQLEN1_ARQVFE_MASK) { |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1927 | dev_info(&adapter->pdev->dev, "ARQ VF Error detected\n"); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1928 | val &= ~I40E_VF_ARQLEN1_ARQVFE_MASK; |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1929 | } |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1930 | if (val & I40E_VF_ARQLEN1_ARQOVFL_MASK) { |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1931 | dev_info(&adapter->pdev->dev, "ARQ Overflow Error detected\n"); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1932 | val &= ~I40E_VF_ARQLEN1_ARQOVFL_MASK; |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1933 | } |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1934 | if (val & I40E_VF_ARQLEN1_ARQCRIT_MASK) { |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1935 | dev_info(&adapter->pdev->dev, "ARQ Critical Error detected\n"); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1936 | val &= ~I40E_VF_ARQLEN1_ARQCRIT_MASK; |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1937 | } |
| 1938 | if (oldval != val) |
| 1939 | wr32(hw, hw->aq.arq.len, val); |
| 1940 | |
| 1941 | val = rd32(hw, hw->aq.asq.len); |
| 1942 | oldval = val; |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1943 | if (val & I40E_VF_ATQLEN1_ATQVFE_MASK) { |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1944 | dev_info(&adapter->pdev->dev, "ASQ VF Error detected\n"); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1945 | val &= ~I40E_VF_ATQLEN1_ATQVFE_MASK; |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1946 | } |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1947 | if (val & I40E_VF_ATQLEN1_ATQOVFL_MASK) { |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1948 | dev_info(&adapter->pdev->dev, "ASQ Overflow Error detected\n"); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1949 | val &= ~I40E_VF_ATQLEN1_ATQOVFL_MASK; |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1950 | } |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1951 | if (val & I40E_VF_ATQLEN1_ATQCRIT_MASK) { |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1952 | dev_info(&adapter->pdev->dev, "ASQ Critical Error detected\n"); |
Anjali Singhai Jain | b1f3366 | 2015-07-10 19:36:05 -0400 | [diff] [blame] | 1953 | val &= ~I40E_VF_ATQLEN1_ATQCRIT_MASK; |
Mitch Williams | 912257e | 2014-05-22 06:32:07 +0000 | [diff] [blame] | 1954 | } |
| 1955 | if (oldval != val) |
| 1956 | wr32(hw, hw->aq.asq.len, val); |
| 1957 | |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 1958 | freedom: |
Mitch A Williams | 7235448 | 2014-12-09 08:53:07 +0000 | [diff] [blame] | 1959 | kfree(event.msg_buf); |
| 1960 | out: |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1961 | /* re-enable Admin queue interrupt cause */ |
| 1962 | i40evf_misc_irq_enable(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1963 | } |
| 1964 | |
| 1965 | /** |
| 1966 | * i40evf_free_all_tx_resources - Free Tx Resources for All Queues |
| 1967 | * @adapter: board private structure |
| 1968 | * |
| 1969 | * Free all transmit software resources |
| 1970 | **/ |
Mitch Williams | e284fc8 | 2015-03-27 00:12:09 -0700 | [diff] [blame] | 1971 | void i40evf_free_all_tx_resources(struct i40evf_adapter *adapter) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1972 | { |
| 1973 | int i; |
| 1974 | |
Mitch Williams | fdb47ae | 2015-11-19 11:34:18 -0800 | [diff] [blame] | 1975 | if (!adapter->tx_rings) |
| 1976 | return; |
| 1977 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 1978 | for (i = 0; i < adapter->num_active_queues; i++) |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1979 | if (adapter->tx_rings[i].desc) |
| 1980 | i40evf_free_tx_resources(&adapter->tx_rings[i]); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 1981 | } |
| 1982 | |
| 1983 | /** |
| 1984 | * i40evf_setup_all_tx_resources - allocate all queues Tx resources |
| 1985 | * @adapter: board private structure |
| 1986 | * |
| 1987 | * If this function returns with an error, then it's possible one or |
| 1988 | * more of the rings is populated (while the rest are not). It is the |
| 1989 | * callers duty to clean those orphaned rings. |
| 1990 | * |
| 1991 | * Return 0 on success, negative on failure |
| 1992 | **/ |
| 1993 | static int i40evf_setup_all_tx_resources(struct i40evf_adapter *adapter) |
| 1994 | { |
| 1995 | int i, err = 0; |
| 1996 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 1997 | for (i = 0; i < adapter->num_active_queues; i++) { |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 1998 | adapter->tx_rings[i].count = adapter->tx_desc_count; |
| 1999 | err = i40evf_setup_tx_descriptors(&adapter->tx_rings[i]); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2000 | if (!err) |
| 2001 | continue; |
| 2002 | dev_err(&adapter->pdev->dev, |
Shannon Nelson | fb43201f | 2015-08-26 15:14:17 -0400 | [diff] [blame] | 2003 | "Allocation for Tx Queue %u failed\n", i); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2004 | break; |
| 2005 | } |
| 2006 | |
| 2007 | return err; |
| 2008 | } |
| 2009 | |
| 2010 | /** |
| 2011 | * i40evf_setup_all_rx_resources - allocate all queues Rx resources |
| 2012 | * @adapter: board private structure |
| 2013 | * |
| 2014 | * If this function returns with an error, then it's possible one or |
| 2015 | * more of the rings is populated (while the rest are not). It is the |
| 2016 | * callers duty to clean those orphaned rings. |
| 2017 | * |
| 2018 | * Return 0 on success, negative on failure |
| 2019 | **/ |
| 2020 | static int i40evf_setup_all_rx_resources(struct i40evf_adapter *adapter) |
| 2021 | { |
| 2022 | int i, err = 0; |
| 2023 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 2024 | for (i = 0; i < adapter->num_active_queues; i++) { |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 2025 | adapter->rx_rings[i].count = adapter->rx_desc_count; |
| 2026 | err = i40evf_setup_rx_descriptors(&adapter->rx_rings[i]); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2027 | if (!err) |
| 2028 | continue; |
| 2029 | dev_err(&adapter->pdev->dev, |
Shannon Nelson | fb43201f | 2015-08-26 15:14:17 -0400 | [diff] [blame] | 2030 | "Allocation for Rx Queue %u failed\n", i); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2031 | break; |
| 2032 | } |
| 2033 | return err; |
| 2034 | } |
| 2035 | |
| 2036 | /** |
| 2037 | * i40evf_free_all_rx_resources - Free Rx Resources for All Queues |
| 2038 | * @adapter: board private structure |
| 2039 | * |
| 2040 | * Free all receive software resources |
| 2041 | **/ |
Mitch Williams | e284fc8 | 2015-03-27 00:12:09 -0700 | [diff] [blame] | 2042 | void i40evf_free_all_rx_resources(struct i40evf_adapter *adapter) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2043 | { |
| 2044 | int i; |
| 2045 | |
Mitch Williams | fdb47ae | 2015-11-19 11:34:18 -0800 | [diff] [blame] | 2046 | if (!adapter->rx_rings) |
| 2047 | return; |
| 2048 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 2049 | for (i = 0; i < adapter->num_active_queues; i++) |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame] | 2050 | if (adapter->rx_rings[i].desc) |
| 2051 | i40evf_free_rx_resources(&adapter->rx_rings[i]); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2052 | } |
| 2053 | |
| 2054 | /** |
| 2055 | * i40evf_open - Called when a network interface is made active |
| 2056 | * @netdev: network interface device structure |
| 2057 | * |
| 2058 | * Returns 0 on success, negative value on failure |
| 2059 | * |
| 2060 | * The open entry point is called when a network interface is made |
| 2061 | * active by the system (IFF_UP). At this point all resources needed |
| 2062 | * for transmit and receive operations are allocated, the interrupt |
| 2063 | * handler is registered with the OS, the watchdog timer is started, |
| 2064 | * and the stack is notified that the interface is ready. |
| 2065 | **/ |
| 2066 | static int i40evf_open(struct net_device *netdev) |
| 2067 | { |
| 2068 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 2069 | int err; |
| 2070 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 2071 | if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) { |
| 2072 | dev_err(&adapter->pdev->dev, "Unable to open device due to PF driver failure.\n"); |
| 2073 | return -EIO; |
| 2074 | } |
Mitch Williams | 209dc4d | 2015-12-09 15:50:27 -0800 | [diff] [blame] | 2075 | |
| 2076 | if (adapter->state != __I40EVF_DOWN) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2077 | return -EBUSY; |
| 2078 | |
| 2079 | /* allocate transmit descriptors */ |
| 2080 | err = i40evf_setup_all_tx_resources(adapter); |
| 2081 | if (err) |
| 2082 | goto err_setup_tx; |
| 2083 | |
| 2084 | /* allocate receive descriptors */ |
| 2085 | err = i40evf_setup_all_rx_resources(adapter); |
| 2086 | if (err) |
| 2087 | goto err_setup_rx; |
| 2088 | |
| 2089 | /* clear any pending interrupts, may auto mask */ |
| 2090 | err = i40evf_request_traffic_irqs(adapter, netdev->name); |
| 2091 | if (err) |
| 2092 | goto err_req_irq; |
| 2093 | |
Mitch Williams | 44151cd | 2015-04-27 14:57:17 -0400 | [diff] [blame] | 2094 | i40evf_add_filter(adapter, adapter->hw.mac.addr); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2095 | i40evf_configure(adapter); |
| 2096 | |
Bimmy Pujari | cb130a0 | 2016-09-06 18:05:03 -0700 | [diff] [blame] | 2097 | i40evf_up_complete(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2098 | |
| 2099 | i40evf_irq_enable(adapter, true); |
| 2100 | |
| 2101 | return 0; |
| 2102 | |
| 2103 | err_req_irq: |
| 2104 | i40evf_down(adapter); |
| 2105 | i40evf_free_traffic_irqs(adapter); |
| 2106 | err_setup_rx: |
| 2107 | i40evf_free_all_rx_resources(adapter); |
| 2108 | err_setup_tx: |
| 2109 | i40evf_free_all_tx_resources(adapter); |
| 2110 | |
| 2111 | return err; |
| 2112 | } |
| 2113 | |
| 2114 | /** |
| 2115 | * i40evf_close - Disables a network interface |
| 2116 | * @netdev: network interface device structure |
| 2117 | * |
| 2118 | * Returns 0, this is not allowed to fail |
| 2119 | * |
| 2120 | * The close entry point is called when an interface is de-activated |
| 2121 | * by the OS. The hardware is still under the drivers control, but |
| 2122 | * needs to be disabled. All IRQs except vector 0 (reserved for admin queue) |
| 2123 | * are freed, along with all transmit and receive resources. |
| 2124 | **/ |
| 2125 | static int i40evf_close(struct net_device *netdev) |
| 2126 | { |
| 2127 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 2128 | |
Mitch Williams | 209dc4d | 2015-12-09 15:50:27 -0800 | [diff] [blame] | 2129 | if (adapter->state <= __I40EVF_DOWN_PENDING) |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 2130 | return 0; |
| 2131 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 2132 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2133 | set_bit(__I40E_DOWN, &adapter->vsi.state); |
| 2134 | |
| 2135 | i40evf_down(adapter); |
Mitch Williams | 209dc4d | 2015-12-09 15:50:27 -0800 | [diff] [blame] | 2136 | adapter->state = __I40EVF_DOWN_PENDING; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2137 | i40evf_free_traffic_irqs(adapter); |
| 2138 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2139 | return 0; |
| 2140 | } |
| 2141 | |
| 2142 | /** |
| 2143 | * i40evf_get_stats - Get System Network Statistics |
| 2144 | * @netdev: network interface device structure |
| 2145 | * |
| 2146 | * Returns the address of the device statistics structure. |
| 2147 | * The statistics are actually updated from the timer callback. |
| 2148 | **/ |
| 2149 | static struct net_device_stats *i40evf_get_stats(struct net_device *netdev) |
| 2150 | { |
| 2151 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 2152 | |
| 2153 | /* only return the current stats */ |
| 2154 | return &adapter->net_stats; |
| 2155 | } |
| 2156 | |
| 2157 | /** |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2158 | * i40evf_change_mtu - Change the Maximum Transfer Unit |
| 2159 | * @netdev: network interface device structure |
| 2160 | * @new_mtu: new value for maximum frame size |
| 2161 | * |
| 2162 | * Returns 0 on success, negative on failure |
| 2163 | **/ |
| 2164 | static int i40evf_change_mtu(struct net_device *netdev, int new_mtu) |
| 2165 | { |
| 2166 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2167 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2168 | netdev->mtu = new_mtu; |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 2169 | adapter->flags |= I40EVF_FLAG_RESET_NEEDED; |
| 2170 | schedule_work(&adapter->reset_task); |
| 2171 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2172 | return 0; |
| 2173 | } |
| 2174 | |
Mitch Williams | c4445ae | 2016-03-18 12:18:07 -0700 | [diff] [blame] | 2175 | #define I40EVF_VLAN_FEATURES (NETIF_F_HW_VLAN_CTAG_TX |\ |
| 2176 | NETIF_F_HW_VLAN_CTAG_RX |\ |
| 2177 | NETIF_F_HW_VLAN_CTAG_FILTER) |
| 2178 | |
| 2179 | /** |
| 2180 | * i40evf_fix_features - fix up the netdev feature bits |
| 2181 | * @netdev: our net device |
| 2182 | * @features: desired feature bits |
| 2183 | * |
| 2184 | * Returns fixed-up features bits |
| 2185 | **/ |
| 2186 | static netdev_features_t i40evf_fix_features(struct net_device *netdev, |
| 2187 | netdev_features_t features) |
| 2188 | { |
| 2189 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 2190 | |
| 2191 | features &= ~I40EVF_VLAN_FEATURES; |
| 2192 | if (adapter->vf_res->vf_offload_flags & I40E_VIRTCHNL_VF_OFFLOAD_VLAN) |
| 2193 | features |= I40EVF_VLAN_FEATURES; |
| 2194 | return features; |
| 2195 | } |
| 2196 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2197 | static const struct net_device_ops i40evf_netdev_ops = { |
| 2198 | .ndo_open = i40evf_open, |
| 2199 | .ndo_stop = i40evf_close, |
| 2200 | .ndo_start_xmit = i40evf_xmit_frame, |
| 2201 | .ndo_get_stats = i40evf_get_stats, |
| 2202 | .ndo_set_rx_mode = i40evf_set_rx_mode, |
| 2203 | .ndo_validate_addr = eth_validate_addr, |
| 2204 | .ndo_set_mac_address = i40evf_set_mac, |
| 2205 | .ndo_change_mtu = i40evf_change_mtu, |
| 2206 | .ndo_tx_timeout = i40evf_tx_timeout, |
| 2207 | .ndo_vlan_rx_add_vid = i40evf_vlan_rx_add_vid, |
| 2208 | .ndo_vlan_rx_kill_vid = i40evf_vlan_rx_kill_vid, |
Mitch Williams | c4445ae | 2016-03-18 12:18:07 -0700 | [diff] [blame] | 2209 | .ndo_fix_features = i40evf_fix_features, |
Alexander Duyck | 7709b4c | 2015-09-24 09:04:38 -0700 | [diff] [blame] | 2210 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 2211 | .ndo_poll_controller = i40evf_netpoll, |
| 2212 | #endif |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2213 | }; |
| 2214 | |
| 2215 | /** |
| 2216 | * i40evf_check_reset_complete - check that VF reset is complete |
| 2217 | * @hw: pointer to hw struct |
| 2218 | * |
| 2219 | * Returns 0 if device is ready to use, or -EBUSY if it's in reset. |
| 2220 | **/ |
| 2221 | static int i40evf_check_reset_complete(struct i40e_hw *hw) |
| 2222 | { |
| 2223 | u32 rstat; |
| 2224 | int i; |
| 2225 | |
| 2226 | for (i = 0; i < 100; i++) { |
Ashish Shah | fd35886 | 2014-08-01 13:27:11 -0700 | [diff] [blame] | 2227 | rstat = rd32(hw, I40E_VFGEN_RSTAT) & |
| 2228 | I40E_VFGEN_RSTAT_VFR_STATE_MASK; |
| 2229 | if ((rstat == I40E_VFR_VFACTIVE) || |
| 2230 | (rstat == I40E_VFR_COMPLETED)) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2231 | return 0; |
Neerav Parikh | f98a200 | 2014-09-13 07:40:44 +0000 | [diff] [blame] | 2232 | usleep_range(10, 20); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2233 | } |
| 2234 | return -EBUSY; |
| 2235 | } |
| 2236 | |
| 2237 | /** |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2238 | * i40evf_process_config - Process the config information we got from the PF |
| 2239 | * @adapter: board private structure |
| 2240 | * |
| 2241 | * Verify that we have a valid config struct, and set up our netdev features |
| 2242 | * and our VSI struct. |
| 2243 | **/ |
| 2244 | int i40evf_process_config(struct i40evf_adapter *adapter) |
| 2245 | { |
Mitch Williams | ba6cc7f | 2016-04-01 13:34:31 -0700 | [diff] [blame] | 2246 | struct i40e_virtchnl_vf_resource *vfres = adapter->vf_res; |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2247 | struct net_device *netdev = adapter->netdev; |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 2248 | struct i40e_vsi *vsi = &adapter->vsi; |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2249 | int i; |
| 2250 | |
| 2251 | /* got VF config message back from PF, now we can parse it */ |
Mitch Williams | ba6cc7f | 2016-04-01 13:34:31 -0700 | [diff] [blame] | 2252 | for (i = 0; i < vfres->num_vsis; i++) { |
| 2253 | if (vfres->vsi_res[i].vsi_type == I40E_VSI_SRIOV) |
| 2254 | adapter->vsi_res = &vfres->vsi_res[i]; |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2255 | } |
| 2256 | if (!adapter->vsi_res) { |
| 2257 | dev_err(&adapter->pdev->dev, "No LAN VSI found\n"); |
| 2258 | return -ENODEV; |
| 2259 | } |
| 2260 | |
Alexander Duyck | b0fe330 | 2016-04-02 00:05:14 -0700 | [diff] [blame] | 2261 | netdev->hw_enc_features |= NETIF_F_SG | |
| 2262 | NETIF_F_IP_CSUM | |
| 2263 | NETIF_F_IPV6_CSUM | |
| 2264 | NETIF_F_HIGHDMA | |
| 2265 | NETIF_F_SOFT_FEATURES | |
| 2266 | NETIF_F_TSO | |
| 2267 | NETIF_F_TSO_ECN | |
| 2268 | NETIF_F_TSO6 | |
| 2269 | NETIF_F_GSO_GRE | |
Alexander Duyck | 1c7b4a2 | 2016-04-14 17:19:25 -0400 | [diff] [blame] | 2270 | NETIF_F_GSO_GRE_CSUM | |
Tom Herbert | 7e13318 | 2016-05-18 09:06:10 -0700 | [diff] [blame] | 2271 | NETIF_F_GSO_IPXIP4 | |
Alexander Duyck | bf2d1df | 2016-05-18 10:44:53 -0700 | [diff] [blame] | 2272 | NETIF_F_GSO_IPXIP6 | |
Alexander Duyck | b0fe330 | 2016-04-02 00:05:14 -0700 | [diff] [blame] | 2273 | NETIF_F_GSO_UDP_TUNNEL | |
| 2274 | NETIF_F_GSO_UDP_TUNNEL_CSUM | |
Alexander Duyck | 1c7b4a2 | 2016-04-14 17:19:25 -0400 | [diff] [blame] | 2275 | NETIF_F_GSO_PARTIAL | |
Alexander Duyck | b0fe330 | 2016-04-02 00:05:14 -0700 | [diff] [blame] | 2276 | NETIF_F_SCTP_CRC | |
| 2277 | NETIF_F_RXHASH | |
| 2278 | NETIF_F_RXCSUM | |
| 2279 | 0; |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2280 | |
Alexander Duyck | b0fe330 | 2016-04-02 00:05:14 -0700 | [diff] [blame] | 2281 | if (!(adapter->flags & I40EVF_FLAG_OUTER_UDP_CSUM_CAPABLE)) |
Alexander Duyck | 1c7b4a2 | 2016-04-14 17:19:25 -0400 | [diff] [blame] | 2282 | netdev->gso_partial_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM; |
| 2283 | |
| 2284 | netdev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM; |
Alexander Duyck | f608e6a | 2016-01-24 21:17:57 -0800 | [diff] [blame] | 2285 | |
Alexander Duyck | b0fe330 | 2016-04-02 00:05:14 -0700 | [diff] [blame] | 2286 | /* record features VLANs can make use of */ |
Alexander Duyck | 1c7b4a2 | 2016-04-14 17:19:25 -0400 | [diff] [blame] | 2287 | netdev->vlan_features |= netdev->hw_enc_features | |
| 2288 | NETIF_F_TSO_MANGLEID; |
Alexander Duyck | f608e6a | 2016-01-24 21:17:57 -0800 | [diff] [blame] | 2289 | |
Alexander Duyck | b0fe330 | 2016-04-02 00:05:14 -0700 | [diff] [blame] | 2290 | /* Write features and hw_features separately to avoid polluting |
| 2291 | * with, or dropping, features that are set when we registgered. |
| 2292 | */ |
| 2293 | netdev->hw_features |= netdev->hw_enc_features; |
Mitch Williams | ba6cc7f | 2016-04-01 13:34:31 -0700 | [diff] [blame] | 2294 | |
Alexander Duyck | b0fe330 | 2016-04-02 00:05:14 -0700 | [diff] [blame] | 2295 | netdev->features |= netdev->hw_enc_features | I40EVF_VLAN_FEATURES; |
Alexander Duyck | 1c7b4a2 | 2016-04-14 17:19:25 -0400 | [diff] [blame] | 2296 | netdev->hw_enc_features |= NETIF_F_TSO_MANGLEID; |
Alexander Duyck | b0fe330 | 2016-04-02 00:05:14 -0700 | [diff] [blame] | 2297 | |
| 2298 | /* disable VLAN features if not supported */ |
| 2299 | if (!(vfres->vf_offload_flags & I40E_VIRTCHNL_VF_OFFLOAD_VLAN)) |
| 2300 | netdev->features ^= I40EVF_VLAN_FEATURES; |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2301 | |
| 2302 | adapter->vsi.id = adapter->vsi_res->vsi_id; |
| 2303 | |
| 2304 | adapter->vsi.back = adapter; |
| 2305 | adapter->vsi.base_vector = 1; |
| 2306 | adapter->vsi.work_limit = I40E_DEFAULT_IRQ_WORK; |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 2307 | vsi->netdev = adapter->netdev; |
| 2308 | vsi->qs_handle = adapter->vsi_res->qset_handle; |
| 2309 | if (vfres->vf_offload_flags & I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF) { |
| 2310 | adapter->rss_key_size = vfres->rss_key_size; |
| 2311 | adapter->rss_lut_size = vfres->rss_lut_size; |
| 2312 | } else { |
| 2313 | adapter->rss_key_size = I40EVF_HKEY_ARRAY_SIZE; |
| 2314 | adapter->rss_lut_size = I40EVF_HLUT_ARRAY_SIZE; |
| 2315 | } |
| 2316 | |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2317 | return 0; |
| 2318 | } |
| 2319 | |
| 2320 | /** |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2321 | * i40evf_init_task - worker thread to perform delayed initialization |
| 2322 | * @work: pointer to work_struct containing our data |
| 2323 | * |
| 2324 | * This task completes the work that was begun in probe. Due to the nature |
| 2325 | * of VF-PF communications, we may need to wait tens of milliseconds to get |
Joe Perches | dbedd44 | 2015-03-06 20:49:12 -0800 | [diff] [blame] | 2326 | * responses back from the PF. Rather than busy-wait in probe and bog down the |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2327 | * whole system, we'll do it in a task so we can sleep. |
| 2328 | * This task only runs during driver init. Once we've established |
| 2329 | * communications with the PF driver and set up our netdev, the watchdog |
| 2330 | * takes over. |
| 2331 | **/ |
| 2332 | static void i40evf_init_task(struct work_struct *work) |
| 2333 | { |
| 2334 | struct i40evf_adapter *adapter = container_of(work, |
| 2335 | struct i40evf_adapter, |
| 2336 | init_task.work); |
| 2337 | struct net_device *netdev = adapter->netdev; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2338 | struct i40e_hw *hw = &adapter->hw; |
| 2339 | struct pci_dev *pdev = adapter->pdev; |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2340 | int err, bufsz; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2341 | |
| 2342 | switch (adapter->state) { |
| 2343 | case __I40EVF_STARTUP: |
| 2344 | /* driver loaded, probe complete */ |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 2345 | adapter->flags &= ~I40EVF_FLAG_PF_COMMS_FAILED; |
| 2346 | adapter->flags &= ~I40EVF_FLAG_RESET_PENDING; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2347 | err = i40e_set_mac_type(hw); |
| 2348 | if (err) { |
Mitch Williams | c2a137c | 2014-02-20 19:29:09 -0800 | [diff] [blame] | 2349 | dev_err(&pdev->dev, "Failed to set MAC type (%d)\n", |
| 2350 | err); |
Mitch Williams | 2619ef4 | 2015-04-07 19:45:30 -0400 | [diff] [blame] | 2351 | goto err; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2352 | } |
| 2353 | err = i40evf_check_reset_complete(hw); |
| 2354 | if (err) { |
Mitch Williams | 0d9c7ea | 2014-04-23 04:50:00 +0000 | [diff] [blame] | 2355 | dev_info(&pdev->dev, "Device is still in reset (%d), retrying\n", |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 2356 | err); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2357 | goto err; |
| 2358 | } |
| 2359 | hw->aq.num_arq_entries = I40EVF_AQ_LEN; |
| 2360 | hw->aq.num_asq_entries = I40EVF_AQ_LEN; |
| 2361 | hw->aq.arq_buf_size = I40EVF_MAX_AQ_BUF_SIZE; |
| 2362 | hw->aq.asq_buf_size = I40EVF_MAX_AQ_BUF_SIZE; |
| 2363 | |
| 2364 | err = i40evf_init_adminq(hw); |
| 2365 | if (err) { |
Mitch Williams | c2a137c | 2014-02-20 19:29:09 -0800 | [diff] [blame] | 2366 | dev_err(&pdev->dev, "Failed to init Admin Queue (%d)\n", |
| 2367 | err); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2368 | goto err; |
| 2369 | } |
| 2370 | err = i40evf_send_api_ver(adapter); |
| 2371 | if (err) { |
Mitch Williams | 10bdd67 | 2014-03-06 08:59:53 +0000 | [diff] [blame] | 2372 | dev_err(&pdev->dev, "Unable to send to PF (%d)\n", err); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2373 | i40evf_shutdown_adminq(hw); |
| 2374 | goto err; |
| 2375 | } |
| 2376 | adapter->state = __I40EVF_INIT_VERSION_CHECK; |
| 2377 | goto restart; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2378 | case __I40EVF_INIT_VERSION_CHECK: |
Mitch Williams | 10bdd67 | 2014-03-06 08:59:53 +0000 | [diff] [blame] | 2379 | if (!i40evf_asq_done(hw)) { |
Mitch Williams | 80e7289 | 2014-05-10 04:49:06 +0000 | [diff] [blame] | 2380 | dev_err(&pdev->dev, "Admin queue command never completed\n"); |
Mitch Williams | 906a693 | 2014-11-13 03:06:12 +0000 | [diff] [blame] | 2381 | i40evf_shutdown_adminq(hw); |
| 2382 | adapter->state = __I40EVF_STARTUP; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2383 | goto err; |
Mitch Williams | 10bdd67 | 2014-03-06 08:59:53 +0000 | [diff] [blame] | 2384 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2385 | |
| 2386 | /* aq msg sent, awaiting reply */ |
| 2387 | err = i40evf_verify_api_ver(adapter); |
| 2388 | if (err) { |
Mitch A Williams | d4f82fd | 2014-12-09 08:53:03 +0000 | [diff] [blame] | 2389 | if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK) |
Mitch Williams | 56f9920 | 2014-06-04 04:22:41 +0000 | [diff] [blame] | 2390 | err = i40evf_send_api_ver(adapter); |
Mitch Williams | ee1693e | 2015-06-04 16:23:59 -0400 | [diff] [blame] | 2391 | else |
| 2392 | dev_err(&pdev->dev, "Unsupported PF API version %d.%d, expected %d.%d\n", |
| 2393 | adapter->pf_version.major, |
| 2394 | adapter->pf_version.minor, |
| 2395 | I40E_VIRTCHNL_VERSION_MAJOR, |
| 2396 | I40E_VIRTCHNL_VERSION_MINOR); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2397 | goto err; |
| 2398 | } |
| 2399 | err = i40evf_send_vf_config_msg(adapter); |
| 2400 | if (err) { |
Mitch Williams | 3f2ab17 | 2014-06-04 04:22:40 +0000 | [diff] [blame] | 2401 | dev_err(&pdev->dev, "Unable to send config request (%d)\n", |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2402 | err); |
| 2403 | goto err; |
| 2404 | } |
| 2405 | adapter->state = __I40EVF_INIT_GET_RESOURCES; |
| 2406 | goto restart; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2407 | case __I40EVF_INIT_GET_RESOURCES: |
| 2408 | /* aq msg sent, awaiting reply */ |
| 2409 | if (!adapter->vf_res) { |
| 2410 | bufsz = sizeof(struct i40e_virtchnl_vf_resource) + |
| 2411 | (I40E_MAX_VF_VSI * |
| 2412 | sizeof(struct i40e_virtchnl_vsi_resource)); |
| 2413 | adapter->vf_res = kzalloc(bufsz, GFP_KERNEL); |
Mitch Williams | c2a137c | 2014-02-20 19:29:09 -0800 | [diff] [blame] | 2414 | if (!adapter->vf_res) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2415 | goto err; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2416 | } |
| 2417 | err = i40evf_get_vf_config(adapter); |
Mitch Williams | 906a693 | 2014-11-13 03:06:12 +0000 | [diff] [blame] | 2418 | if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK) { |
Mitch Williams | 906a693 | 2014-11-13 03:06:12 +0000 | [diff] [blame] | 2419 | err = i40evf_send_vf_config_msg(adapter); |
| 2420 | goto err; |
Mitch Williams | e743072 | 2015-10-26 19:44:38 -0400 | [diff] [blame] | 2421 | } else if (err == I40E_ERR_PARAM) { |
| 2422 | /* We only get ERR_PARAM if the device is in a very bad |
| 2423 | * state or if we've been disabled for previous bad |
| 2424 | * behavior. Either way, we're done now. |
| 2425 | */ |
| 2426 | i40evf_shutdown_adminq(hw); |
| 2427 | dev_err(&pdev->dev, "Unable to get VF config due to PF error condition, not retrying\n"); |
| 2428 | return; |
Mitch Williams | 906a693 | 2014-11-13 03:06:12 +0000 | [diff] [blame] | 2429 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2430 | if (err) { |
Mitch Williams | c2a137c | 2014-02-20 19:29:09 -0800 | [diff] [blame] | 2431 | dev_err(&pdev->dev, "Unable to get VF config (%d)\n", |
| 2432 | err); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2433 | goto err_alloc; |
| 2434 | } |
| 2435 | adapter->state = __I40EVF_INIT_SW; |
| 2436 | break; |
| 2437 | default: |
| 2438 | goto err_alloc; |
| 2439 | } |
Alexander Duyck | f608e6a | 2016-01-24 21:17:57 -0800 | [diff] [blame] | 2440 | |
| 2441 | if (hw->mac.type == I40E_MAC_X722_VF) |
| 2442 | adapter->flags |= I40EVF_FLAG_OUTER_UDP_CSUM_CAPABLE; |
| 2443 | |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2444 | if (i40evf_process_config(adapter)) |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2445 | goto err_alloc; |
Mitch Williams | e6d038d | 2015-06-04 16:23:58 -0400 | [diff] [blame] | 2446 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2447 | |
| 2448 | adapter->flags |= I40EVF_FLAG_RX_CSUM_ENABLED; |
| 2449 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2450 | netdev->netdev_ops = &i40evf_netdev_ops; |
| 2451 | i40evf_set_ethtool_ops(netdev); |
| 2452 | netdev->watchdog_timeo = 5 * HZ; |
Greg Rose | 3415e8c | 2014-01-30 12:40:27 +0000 | [diff] [blame] | 2453 | |
Jarod Wilson | 91c527a | 2016-10-17 15:54:05 -0400 | [diff] [blame] | 2454 | /* MTU range: 68 - 9710 */ |
| 2455 | netdev->min_mtu = ETH_MIN_MTU; |
| 2456 | netdev->max_mtu = I40E_MAX_RXBUFFER - (ETH_HLEN + ETH_FCS_LEN); |
| 2457 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2458 | if (!is_valid_ether_addr(adapter->hw.mac.addr)) { |
Mitch Williams | b34f90e | 2014-05-10 04:49:07 +0000 | [diff] [blame] | 2459 | dev_info(&pdev->dev, "Invalid MAC address %pM, using random\n", |
Mitch Williams | c2a137c | 2014-02-20 19:29:09 -0800 | [diff] [blame] | 2460 | adapter->hw.mac.addr); |
Mitch Williams | 14e52ee | 2015-08-31 19:54:44 -0400 | [diff] [blame] | 2461 | eth_hw_addr_random(netdev); |
| 2462 | ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); |
| 2463 | } else { |
| 2464 | adapter->flags |= I40EVF_FLAG_ADDR_SET_BY_PF; |
| 2465 | ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr); |
| 2466 | ether_addr_copy(netdev->perm_addr, adapter->hw.mac.addr); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2467 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2468 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2469 | init_timer(&adapter->watchdog_timer); |
| 2470 | adapter->watchdog_timer.function = &i40evf_watchdog_timer; |
| 2471 | adapter->watchdog_timer.data = (unsigned long)adapter; |
| 2472 | mod_timer(&adapter->watchdog_timer, jiffies + 1); |
| 2473 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 2474 | adapter->num_active_queues = min_t(int, |
| 2475 | adapter->vsi_res->num_queue_pairs, |
| 2476 | (int)(num_online_cpus())); |
Mitch Williams | d732a18 | 2014-04-24 06:41:37 +0000 | [diff] [blame] | 2477 | adapter->tx_desc_count = I40EVF_DEFAULT_TXD; |
| 2478 | adapter->rx_desc_count = I40EVF_DEFAULT_RXD; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2479 | err = i40evf_init_interrupt_scheme(adapter); |
| 2480 | if (err) |
| 2481 | goto err_sw_init; |
| 2482 | i40evf_map_rings_to_vectors(adapter); |
Anjali Singhai Jain | 1f01227 | 2015-09-03 17:18:53 -0400 | [diff] [blame] | 2483 | if (adapter->vf_res->vf_offload_flags & |
Anjali Singhai Jain | f6d83d1 | 2015-12-22 14:25:07 -0800 | [diff] [blame] | 2484 | I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) |
| 2485 | adapter->flags |= I40EVF_FLAG_WB_ON_ITR_CAPABLE; |
| 2486 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2487 | err = i40evf_request_misc_irq(adapter); |
| 2488 | if (err) |
| 2489 | goto err_sw_init; |
| 2490 | |
| 2491 | netif_carrier_off(netdev); |
Sridhar Samudrala | 3f341ac | 2016-09-01 22:27:27 +0200 | [diff] [blame] | 2492 | adapter->link_up = false; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2493 | |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 2494 | if (!adapter->netdev_registered) { |
| 2495 | err = register_netdev(netdev); |
| 2496 | if (err) |
| 2497 | goto err_register; |
| 2498 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2499 | |
| 2500 | adapter->netdev_registered = true; |
| 2501 | |
| 2502 | netif_tx_stop_all_queues(netdev); |
| 2503 | |
Mitch Williams | b34f90e | 2014-05-10 04:49:07 +0000 | [diff] [blame] | 2504 | dev_info(&pdev->dev, "MAC address: %pM\n", adapter->hw.mac.addr); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2505 | if (netdev->features & NETIF_F_GRO) |
| 2506 | dev_info(&pdev->dev, "GRO is enabled\n"); |
| 2507 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2508 | adapter->state = __I40EVF_DOWN; |
| 2509 | set_bit(__I40E_DOWN, &adapter->vsi.state); |
| 2510 | i40evf_misc_irq_enable(adapter); |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 2511 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 2512 | adapter->rss_key = kzalloc(adapter->rss_key_size, GFP_KERNEL); |
| 2513 | adapter->rss_lut = kzalloc(adapter->rss_lut_size, GFP_KERNEL); |
| 2514 | if (!adapter->rss_key || !adapter->rss_lut) |
| 2515 | goto err_mem; |
| 2516 | |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 2517 | if (RSS_AQ(adapter)) { |
| 2518 | adapter->aq_required |= I40EVF_FLAG_AQ_CONFIGURE_RSS; |
| 2519 | mod_timer_pending(&adapter->watchdog_timer, jiffies + 1); |
| 2520 | } else { |
Helin Zhang | 96a8198 | 2015-10-26 19:44:31 -0400 | [diff] [blame] | 2521 | i40evf_init_rss(adapter); |
Anjali Singhai Jain | e25d00b8 | 2015-06-23 19:00:04 -0400 | [diff] [blame] | 2522 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2523 | return; |
| 2524 | restart: |
Mitch Williams | 3f7e5c3 | 2015-09-28 14:12:42 -0400 | [diff] [blame] | 2525 | schedule_delayed_work(&adapter->init_task, msecs_to_jiffies(30)); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2526 | return; |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 2527 | err_mem: |
| 2528 | i40evf_free_rss(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2529 | err_register: |
| 2530 | i40evf_free_misc_irq(adapter); |
| 2531 | err_sw_init: |
| 2532 | i40evf_reset_interrupt_capability(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2533 | err_alloc: |
| 2534 | kfree(adapter->vf_res); |
| 2535 | adapter->vf_res = NULL; |
| 2536 | err: |
| 2537 | /* Things went into the weeds, so try again later */ |
| 2538 | if (++adapter->aq_wait_count > I40EVF_AQ_MAX_ERR) { |
Mitch Williams | b9029e9 | 2015-09-28 14:16:50 -0400 | [diff] [blame] | 2539 | dev_err(&pdev->dev, "Failed to communicate with PF; waiting before retry\n"); |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 2540 | adapter->flags |= I40EVF_FLAG_PF_COMMS_FAILED; |
Mitch Williams | b9029e9 | 2015-09-28 14:16:50 -0400 | [diff] [blame] | 2541 | i40evf_shutdown_adminq(hw); |
| 2542 | adapter->state = __I40EVF_STARTUP; |
| 2543 | schedule_delayed_work(&adapter->init_task, HZ * 5); |
| 2544 | return; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2545 | } |
Mitch Williams | 3f7e5c3 | 2015-09-28 14:12:42 -0400 | [diff] [blame] | 2546 | schedule_delayed_work(&adapter->init_task, HZ); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2547 | } |
| 2548 | |
| 2549 | /** |
| 2550 | * i40evf_shutdown - Shutdown the device in preparation for a reboot |
| 2551 | * @pdev: pci device structure |
| 2552 | **/ |
| 2553 | static void i40evf_shutdown(struct pci_dev *pdev) |
| 2554 | { |
| 2555 | struct net_device *netdev = pci_get_drvdata(pdev); |
Mitch Williams | 00293fd | 2015-01-09 11:18:18 +0000 | [diff] [blame] | 2556 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2557 | |
| 2558 | netif_device_detach(netdev); |
| 2559 | |
| 2560 | if (netif_running(netdev)) |
| 2561 | i40evf_close(netdev); |
| 2562 | |
Mitch Williams | 00293fd | 2015-01-09 11:18:18 +0000 | [diff] [blame] | 2563 | /* Prevent the watchdog from running. */ |
| 2564 | adapter->state = __I40EVF_REMOVE; |
| 2565 | adapter->aq_required = 0; |
Mitch Williams | 00293fd | 2015-01-09 11:18:18 +0000 | [diff] [blame] | 2566 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2567 | #ifdef CONFIG_PM |
| 2568 | pci_save_state(pdev); |
| 2569 | |
| 2570 | #endif |
| 2571 | pci_disable_device(pdev); |
| 2572 | } |
| 2573 | |
| 2574 | /** |
| 2575 | * i40evf_probe - Device Initialization Routine |
| 2576 | * @pdev: PCI device information struct |
| 2577 | * @ent: entry in i40evf_pci_tbl |
| 2578 | * |
| 2579 | * Returns 0 on success, negative on failure |
| 2580 | * |
| 2581 | * i40evf_probe initializes an adapter identified by a pci_dev structure. |
| 2582 | * The OS initialization, configuring of the adapter private structure, |
| 2583 | * and a hardware reset occur. |
| 2584 | **/ |
| 2585 | static int i40evf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
| 2586 | { |
| 2587 | struct net_device *netdev; |
| 2588 | struct i40evf_adapter *adapter = NULL; |
| 2589 | struct i40e_hw *hw = NULL; |
Mitch Williams | dbbd811 | 2014-02-20 19:29:08 -0800 | [diff] [blame] | 2590 | int err; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2591 | |
| 2592 | err = pci_enable_device(pdev); |
| 2593 | if (err) |
| 2594 | return err; |
| 2595 | |
Mitch Williams | 6494294 | 2014-02-11 08:26:33 +0000 | [diff] [blame] | 2596 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); |
Mitch Williams | 6494294 | 2014-02-11 08:26:33 +0000 | [diff] [blame] | 2597 | if (err) { |
Jean Sacren | e3e3bfd | 2014-03-25 04:30:27 +0000 | [diff] [blame] | 2598 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); |
| 2599 | if (err) { |
| 2600 | dev_err(&pdev->dev, |
| 2601 | "DMA configuration failed: 0x%x\n", err); |
| 2602 | goto err_dma; |
| 2603 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2604 | } |
| 2605 | |
| 2606 | err = pci_request_regions(pdev, i40evf_driver_name); |
| 2607 | if (err) { |
| 2608 | dev_err(&pdev->dev, |
| 2609 | "pci_request_regions failed 0x%x\n", err); |
| 2610 | goto err_pci_reg; |
| 2611 | } |
| 2612 | |
| 2613 | pci_enable_pcie_error_reporting(pdev); |
| 2614 | |
| 2615 | pci_set_master(pdev); |
| 2616 | |
Mitch Williams | 1255b7a | 2015-11-06 15:25:59 -0800 | [diff] [blame] | 2617 | netdev = alloc_etherdev_mq(sizeof(struct i40evf_adapter), MAX_QUEUES); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2618 | if (!netdev) { |
| 2619 | err = -ENOMEM; |
| 2620 | goto err_alloc_etherdev; |
| 2621 | } |
| 2622 | |
| 2623 | SET_NETDEV_DEV(netdev, &pdev->dev); |
| 2624 | |
| 2625 | pci_set_drvdata(pdev, netdev); |
| 2626 | adapter = netdev_priv(netdev); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2627 | |
| 2628 | adapter->netdev = netdev; |
| 2629 | adapter->pdev = pdev; |
| 2630 | |
| 2631 | hw = &adapter->hw; |
| 2632 | hw->back = adapter; |
| 2633 | |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2634 | adapter->msg_enable = BIT(DEFAULT_DEBUG_LEVEL_SHIFT) - 1; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2635 | adapter->state = __I40EVF_STARTUP; |
| 2636 | |
| 2637 | /* Call save state here because it relies on the adapter struct. */ |
| 2638 | pci_save_state(pdev); |
| 2639 | |
| 2640 | hw->hw_addr = ioremap(pci_resource_start(pdev, 0), |
| 2641 | pci_resource_len(pdev, 0)); |
| 2642 | if (!hw->hw_addr) { |
| 2643 | err = -EIO; |
| 2644 | goto err_ioremap; |
| 2645 | } |
| 2646 | hw->vendor_id = pdev->vendor; |
| 2647 | hw->device_id = pdev->device; |
| 2648 | pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id); |
| 2649 | hw->subsystem_vendor_id = pdev->subsystem_vendor; |
| 2650 | hw->subsystem_device_id = pdev->subsystem_device; |
| 2651 | hw->bus.device = PCI_SLOT(pdev->devfn); |
| 2652 | hw->bus.func = PCI_FUNC(pdev->devfn); |
| 2653 | |
Jesse Brandeburg | 8ddb332 | 2015-11-18 15:47:06 -0800 | [diff] [blame] | 2654 | /* set up the locks for the AQ, do this only once in probe |
| 2655 | * and destroy them only once in remove |
| 2656 | */ |
| 2657 | mutex_init(&hw->aq.asq_mutex); |
| 2658 | mutex_init(&hw->aq.arq_mutex); |
| 2659 | |
Serey Kong | 8bb1a54 | 2014-08-01 13:27:15 -0700 | [diff] [blame] | 2660 | INIT_LIST_HEAD(&adapter->mac_filter_list); |
| 2661 | INIT_LIST_HEAD(&adapter->vlan_filter_list); |
| 2662 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2663 | INIT_WORK(&adapter->reset_task, i40evf_reset_task); |
| 2664 | INIT_WORK(&adapter->adminq_task, i40evf_adminq_task); |
| 2665 | INIT_WORK(&adapter->watchdog_task, i40evf_watchdog_task); |
| 2666 | INIT_DELAYED_WORK(&adapter->init_task, i40evf_init_task); |
Mitch Williams | 9b32b0b | 2015-08-13 15:11:32 -0700 | [diff] [blame] | 2667 | schedule_delayed_work(&adapter->init_task, |
| 2668 | msecs_to_jiffies(5 * (pdev->devfn & 0x07))); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2669 | |
| 2670 | return 0; |
| 2671 | |
| 2672 | err_ioremap: |
| 2673 | free_netdev(netdev); |
| 2674 | err_alloc_etherdev: |
| 2675 | pci_release_regions(pdev); |
| 2676 | err_pci_reg: |
| 2677 | err_dma: |
| 2678 | pci_disable_device(pdev); |
| 2679 | return err; |
| 2680 | } |
| 2681 | |
| 2682 | #ifdef CONFIG_PM |
| 2683 | /** |
| 2684 | * i40evf_suspend - Power management suspend routine |
| 2685 | * @pdev: PCI device information struct |
| 2686 | * @state: unused |
| 2687 | * |
| 2688 | * Called when the system (VM) is entering sleep/suspend. |
| 2689 | **/ |
| 2690 | static int i40evf_suspend(struct pci_dev *pdev, pm_message_t state) |
| 2691 | { |
| 2692 | struct net_device *netdev = pci_get_drvdata(pdev); |
| 2693 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 2694 | int retval = 0; |
| 2695 | |
| 2696 | netif_device_detach(netdev); |
| 2697 | |
| 2698 | if (netif_running(netdev)) { |
| 2699 | rtnl_lock(); |
| 2700 | i40evf_down(adapter); |
| 2701 | rtnl_unlock(); |
| 2702 | } |
| 2703 | i40evf_free_misc_irq(adapter); |
| 2704 | i40evf_reset_interrupt_capability(adapter); |
| 2705 | |
| 2706 | retval = pci_save_state(pdev); |
| 2707 | if (retval) |
| 2708 | return retval; |
| 2709 | |
| 2710 | pci_disable_device(pdev); |
| 2711 | |
| 2712 | return 0; |
| 2713 | } |
| 2714 | |
| 2715 | /** |
Joe Perches | dbedd44 | 2015-03-06 20:49:12 -0800 | [diff] [blame] | 2716 | * i40evf_resume - Power management resume routine |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2717 | * @pdev: PCI device information struct |
| 2718 | * |
| 2719 | * Called when the system (VM) is resumed from sleep/suspend. |
| 2720 | **/ |
| 2721 | static int i40evf_resume(struct pci_dev *pdev) |
| 2722 | { |
| 2723 | struct i40evf_adapter *adapter = pci_get_drvdata(pdev); |
| 2724 | struct net_device *netdev = adapter->netdev; |
| 2725 | u32 err; |
| 2726 | |
| 2727 | pci_set_power_state(pdev, PCI_D0); |
| 2728 | pci_restore_state(pdev); |
| 2729 | /* pci_restore_state clears dev->state_saved so call |
| 2730 | * pci_save_state to restore it. |
| 2731 | */ |
| 2732 | pci_save_state(pdev); |
| 2733 | |
| 2734 | err = pci_enable_device_mem(pdev); |
| 2735 | if (err) { |
| 2736 | dev_err(&pdev->dev, "Cannot enable PCI device from suspend.\n"); |
| 2737 | return err; |
| 2738 | } |
| 2739 | pci_set_master(pdev); |
| 2740 | |
| 2741 | rtnl_lock(); |
| 2742 | err = i40evf_set_interrupt_capability(adapter); |
| 2743 | if (err) { |
Vasily Averin | f2a1c36 | 2015-07-07 18:53:38 +0300 | [diff] [blame] | 2744 | rtnl_unlock(); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2745 | dev_err(&pdev->dev, "Cannot enable MSI-X interrupts.\n"); |
| 2746 | return err; |
| 2747 | } |
| 2748 | err = i40evf_request_misc_irq(adapter); |
| 2749 | rtnl_unlock(); |
| 2750 | if (err) { |
| 2751 | dev_err(&pdev->dev, "Cannot get interrupt vector.\n"); |
| 2752 | return err; |
| 2753 | } |
| 2754 | |
| 2755 | schedule_work(&adapter->reset_task); |
| 2756 | |
| 2757 | netif_device_attach(netdev); |
| 2758 | |
| 2759 | return err; |
| 2760 | } |
| 2761 | |
| 2762 | #endif /* CONFIG_PM */ |
| 2763 | /** |
| 2764 | * i40evf_remove - Device Removal Routine |
| 2765 | * @pdev: PCI device information struct |
| 2766 | * |
| 2767 | * i40evf_remove is called by the PCI subsystem to alert the driver |
| 2768 | * that it should release a PCI device. The could be caused by a |
| 2769 | * Hot-Plug event, or because the driver is going to be removed from |
| 2770 | * memory. |
| 2771 | **/ |
| 2772 | static void i40evf_remove(struct pci_dev *pdev) |
| 2773 | { |
| 2774 | struct net_device *netdev = pci_get_drvdata(pdev); |
| 2775 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
Mitch Williams | 6ba36a2 | 2014-08-01 13:27:14 -0700 | [diff] [blame] | 2776 | struct i40evf_mac_filter *f, *ftmp; |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2777 | struct i40e_hw *hw = &adapter->hw; |
| 2778 | |
| 2779 | cancel_delayed_work_sync(&adapter->init_task); |
Mitch Williams | ef8693e | 2014-02-13 03:48:53 -0800 | [diff] [blame] | 2780 | cancel_work_sync(&adapter->reset_task); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2781 | |
| 2782 | if (adapter->netdev_registered) { |
| 2783 | unregister_netdev(netdev); |
| 2784 | adapter->netdev_registered = false; |
| 2785 | } |
Mitch A Williams | 53d0b3a | 2014-12-09 08:53:04 +0000 | [diff] [blame] | 2786 | |
Mitch Williams | f4a7188 | 2015-01-09 11:18:16 +0000 | [diff] [blame] | 2787 | /* Shut down all the garbage mashers on the detention level */ |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2788 | adapter->state = __I40EVF_REMOVE; |
Mitch Williams | f4a7188 | 2015-01-09 11:18:16 +0000 | [diff] [blame] | 2789 | adapter->aq_required = 0; |
Mitch Williams | f4a7188 | 2015-01-09 11:18:16 +0000 | [diff] [blame] | 2790 | i40evf_request_reset(adapter); |
Mitch Williams | 22ead37 | 2016-03-18 12:18:10 -0700 | [diff] [blame] | 2791 | msleep(50); |
Mitch Williams | f4a7188 | 2015-01-09 11:18:16 +0000 | [diff] [blame] | 2792 | /* If the FW isn't responding, kick it once, but only once. */ |
| 2793 | if (!i40evf_asq_done(hw)) { |
| 2794 | i40evf_request_reset(adapter); |
Mitch Williams | 22ead37 | 2016-03-18 12:18:10 -0700 | [diff] [blame] | 2795 | msleep(50); |
Mitch Williams | f4a7188 | 2015-01-09 11:18:16 +0000 | [diff] [blame] | 2796 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2797 | |
Mitch Williams | dbb01c8 | 2014-02-20 19:29:07 -0800 | [diff] [blame] | 2798 | if (adapter->msix_entries) { |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2799 | i40evf_misc_irq_disable(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2800 | i40evf_free_misc_irq(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2801 | i40evf_reset_interrupt_capability(adapter); |
Mitch Williams | d31944d | 2014-08-01 13:27:13 -0700 | [diff] [blame] | 2802 | i40evf_free_q_vectors(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2803 | } |
| 2804 | |
Mitch Williams | e5d17c3 | 2014-06-04 04:22:38 +0000 | [diff] [blame] | 2805 | if (adapter->watchdog_timer.function) |
| 2806 | del_timer_sync(&adapter->watchdog_timer); |
| 2807 | |
Mitch Williams | dbb01c8 | 2014-02-20 19:29:07 -0800 | [diff] [blame] | 2808 | flush_scheduled_work(); |
| 2809 | |
Mitch Williams | 43a3d9b | 2016-04-12 08:30:44 -0700 | [diff] [blame] | 2810 | i40evf_free_rss(adapter); |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 2811 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2812 | if (hw->aq.asq.count) |
| 2813 | i40evf_shutdown_adminq(hw); |
| 2814 | |
Jesse Brandeburg | 8ddb332 | 2015-11-18 15:47:06 -0800 | [diff] [blame] | 2815 | /* destroy the locks only once, here */ |
| 2816 | mutex_destroy(&hw->aq.arq_mutex); |
| 2817 | mutex_destroy(&hw->aq.asq_mutex); |
| 2818 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2819 | iounmap(hw->hw_addr); |
| 2820 | pci_release_regions(pdev); |
Mitch Williams | e284fc8 | 2015-03-27 00:12:09 -0700 | [diff] [blame] | 2821 | i40evf_free_all_tx_resources(adapter); |
| 2822 | i40evf_free_all_rx_resources(adapter); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2823 | i40evf_free_queues(adapter); |
| 2824 | kfree(adapter->vf_res); |
Mitch Williams | 6ba36a2 | 2014-08-01 13:27:14 -0700 | [diff] [blame] | 2825 | /* If we got removed before an up/down sequence, we've got a filter |
| 2826 | * hanging out there that we need to get rid of. |
| 2827 | */ |
| 2828 | list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { |
| 2829 | list_del(&f->list); |
| 2830 | kfree(f); |
| 2831 | } |
Mitch A Williams | 37dfdf3 | 2014-12-09 08:53:05 +0000 | [diff] [blame] | 2832 | list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { |
| 2833 | list_del(&f->list); |
| 2834 | kfree(f); |
| 2835 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2836 | |
| 2837 | free_netdev(netdev); |
| 2838 | |
| 2839 | pci_disable_pcie_error_reporting(pdev); |
| 2840 | |
| 2841 | pci_disable_device(pdev); |
| 2842 | } |
| 2843 | |
| 2844 | static struct pci_driver i40evf_driver = { |
| 2845 | .name = i40evf_driver_name, |
| 2846 | .id_table = i40evf_pci_tbl, |
| 2847 | .probe = i40evf_probe, |
| 2848 | .remove = i40evf_remove, |
| 2849 | #ifdef CONFIG_PM |
| 2850 | .suspend = i40evf_suspend, |
| 2851 | .resume = i40evf_resume, |
| 2852 | #endif |
| 2853 | .shutdown = i40evf_shutdown, |
| 2854 | }; |
| 2855 | |
| 2856 | /** |
| 2857 | * i40e_init_module - Driver Registration Routine |
| 2858 | * |
| 2859 | * i40e_init_module is the first routine called when the driver is |
| 2860 | * loaded. All it does is register with the PCI subsystem. |
| 2861 | **/ |
| 2862 | static int __init i40evf_init_module(void) |
| 2863 | { |
| 2864 | int ret; |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 2865 | |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2866 | pr_info("i40evf: %s - version %s\n", i40evf_driver_string, |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 2867 | i40evf_driver_version); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2868 | |
| 2869 | pr_info("%s\n", i40evf_copyright); |
| 2870 | |
Jacob Keller | 6992a6c | 2016-08-04 11:37:01 -0700 | [diff] [blame] | 2871 | i40evf_wq = alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1, |
| 2872 | i40evf_driver_name); |
Jesse Brandeburg | 2803b16 | 2015-12-22 14:25:08 -0800 | [diff] [blame] | 2873 | if (!i40evf_wq) { |
| 2874 | pr_err("%s: Failed to create workqueue\n", i40evf_driver_name); |
| 2875 | return -ENOMEM; |
| 2876 | } |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2877 | ret = pci_register_driver(&i40evf_driver); |
| 2878 | return ret; |
| 2879 | } |
| 2880 | |
| 2881 | module_init(i40evf_init_module); |
| 2882 | |
| 2883 | /** |
| 2884 | * i40e_exit_module - Driver Exit Cleanup Routine |
| 2885 | * |
| 2886 | * i40e_exit_module is called just before the driver is removed |
| 2887 | * from memory. |
| 2888 | **/ |
| 2889 | static void __exit i40evf_exit_module(void) |
| 2890 | { |
| 2891 | pci_unregister_driver(&i40evf_driver); |
Jesse Brandeburg | 2803b16 | 2015-12-22 14:25:08 -0800 | [diff] [blame] | 2892 | destroy_workqueue(i40evf_wq); |
Greg Rose | 5eae00c | 2013-12-21 06:12:45 +0000 | [diff] [blame] | 2893 | } |
| 2894 | |
| 2895 | module_exit(i40evf_exit_module); |
| 2896 | |
| 2897 | /* i40evf_main.c */ |