aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/netdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000e/netdev.c')
-rw-r--r--drivers/net/e1000e/netdev.c932
1 files changed, 593 insertions, 339 deletions
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index e561d15c3eb1..3310c3d477d7 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 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, 7 under the terms and conditions of the GNU General Public License,
@@ -49,15 +49,18 @@
49#include <linux/pm_qos_params.h> 49#include <linux/pm_qos_params.h>
50#include <linux/pm_runtime.h> 50#include <linux/pm_runtime.h>
51#include <linux/aer.h> 51#include <linux/aer.h>
52#include <linux/prefetch.h>
52 53
53#include "e1000.h" 54#include "e1000.h"
54 55
55#define DRV_EXTRAVERSION "-k2" 56#define DRV_EXTRAVERSION "-k2"
56 57
57#define DRV_VERSION "1.2.7" DRV_EXTRAVERSION 58#define DRV_VERSION "1.3.10" DRV_EXTRAVERSION
58char e1000e_driver_name[] = "e1000e"; 59char e1000e_driver_name[] = "e1000e";
59const char e1000e_driver_version[] = DRV_VERSION; 60const char e1000e_driver_version[] = DRV_VERSION;
60 61
62static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
63
61static const struct e1000_info *e1000_info_tbl[] = { 64static const struct e1000_info *e1000_info_tbl[] = {
62 [board_82571] = &e1000_82571_info, 65 [board_82571] = &e1000_82571_info,
63 [board_82572] = &e1000_82572_info, 66 [board_82572] = &e1000_82572_info,
@@ -77,17 +80,17 @@ struct e1000_reg_info {
77 char *name; 80 char *name;
78}; 81};
79 82
80#define E1000_RDFH 0x02410 /* Rx Data FIFO Head - RW */ 83#define E1000_RDFH 0x02410 /* Rx Data FIFO Head - RW */
81#define E1000_RDFT 0x02418 /* Rx Data FIFO Tail - RW */ 84#define E1000_RDFT 0x02418 /* Rx Data FIFO Tail - RW */
82#define E1000_RDFHS 0x02420 /* Rx Data FIFO Head Saved - RW */ 85#define E1000_RDFHS 0x02420 /* Rx Data FIFO Head Saved - RW */
83#define E1000_RDFTS 0x02428 /* Rx Data FIFO Tail Saved - RW */ 86#define E1000_RDFTS 0x02428 /* Rx Data FIFO Tail Saved - RW */
84#define E1000_RDFPC 0x02430 /* Rx Data FIFO Packet Count - RW */ 87#define E1000_RDFPC 0x02430 /* Rx Data FIFO Packet Count - RW */
85 88
86#define E1000_TDFH 0x03410 /* Tx Data FIFO Head - RW */ 89#define E1000_TDFH 0x03410 /* Tx Data FIFO Head - RW */
87#define E1000_TDFT 0x03418 /* Tx Data FIFO Tail - RW */ 90#define E1000_TDFT 0x03418 /* Tx Data FIFO Tail - RW */
88#define E1000_TDFHS 0x03420 /* Tx Data FIFO Head Saved - RW */ 91#define E1000_TDFHS 0x03420 /* Tx Data FIFO Head Saved - RW */
89#define E1000_TDFTS 0x03428 /* Tx Data FIFO Tail Saved - RW */ 92#define E1000_TDFTS 0x03428 /* Tx Data FIFO Tail Saved - RW */
90#define E1000_TDFPC 0x03430 /* Tx Data FIFO Packet Count - RW */ 93#define E1000_TDFPC 0x03430 /* Tx Data FIFO Packet Count - RW */
91 94
92static const struct e1000_reg_info e1000_reg_info_tbl[] = { 95static const struct e1000_reg_info e1000_reg_info_tbl[] = {
93 96
@@ -99,7 +102,7 @@ static const struct e1000_reg_info e1000_reg_info_tbl[] = {
99 /* Interrupt Registers */ 102 /* Interrupt Registers */
100 {E1000_ICR, "ICR"}, 103 {E1000_ICR, "ICR"},
101 104
102 /* RX Registers */ 105 /* Rx Registers */
103 {E1000_RCTL, "RCTL"}, 106 {E1000_RCTL, "RCTL"},
104 {E1000_RDLEN, "RDLEN"}, 107 {E1000_RDLEN, "RDLEN"},
105 {E1000_RDH, "RDH"}, 108 {E1000_RDH, "RDH"},
@@ -115,7 +118,7 @@ static const struct e1000_reg_info e1000_reg_info_tbl[] = {
115 {E1000_RDFTS, "RDFTS"}, 118 {E1000_RDFTS, "RDFTS"},
116 {E1000_RDFPC, "RDFPC"}, 119 {E1000_RDFPC, "RDFPC"},
117 120
118 /* TX Registers */ 121 /* Tx Registers */
119 {E1000_TCTL, "TCTL"}, 122 {E1000_TCTL, "TCTL"},
120 {E1000_TDBAL, "TDBAL"}, 123 {E1000_TDBAL, "TDBAL"},
121 {E1000_TDBAH, "TDBAH"}, 124 {E1000_TDBAH, "TDBAH"},
@@ -160,7 +163,7 @@ static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
160 break; 163 break;
161 default: 164 default:
162 printk(KERN_INFO "%-15s %08x\n", 165 printk(KERN_INFO "%-15s %08x\n",
163 reginfo->name, __er32(hw, reginfo->ofs)); 166 reginfo->name, __er32(hw, reginfo->ofs));
164 return; 167 return;
165 } 168 }
166 169
@@ -171,9 +174,8 @@ static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
171 printk(KERN_CONT "\n"); 174 printk(KERN_CONT "\n");
172} 175}
173 176
174
175/* 177/*
176 * e1000e_dump - Print registers, tx-ring and rx-ring 178 * e1000e_dump - Print registers, Tx-ring and Rx-ring
177 */ 179 */
178static void e1000e_dump(struct e1000_adapter *adapter) 180static void e1000e_dump(struct e1000_adapter *adapter)
179{ 181{
@@ -182,12 +184,20 @@ static void e1000e_dump(struct e1000_adapter *adapter)
182 struct e1000_reg_info *reginfo; 184 struct e1000_reg_info *reginfo;
183 struct e1000_ring *tx_ring = adapter->tx_ring; 185 struct e1000_ring *tx_ring = adapter->tx_ring;
184 struct e1000_tx_desc *tx_desc; 186 struct e1000_tx_desc *tx_desc;
185 struct my_u0 { u64 a; u64 b; } *u0; 187 struct my_u0 {
188 u64 a;
189 u64 b;
190 } *u0;
186 struct e1000_buffer *buffer_info; 191 struct e1000_buffer *buffer_info;
187 struct e1000_ring *rx_ring = adapter->rx_ring; 192 struct e1000_ring *rx_ring = adapter->rx_ring;
188 union e1000_rx_desc_packet_split *rx_desc_ps; 193 union e1000_rx_desc_packet_split *rx_desc_ps;
189 struct e1000_rx_desc *rx_desc; 194 struct e1000_rx_desc *rx_desc;
190 struct my_u1 { u64 a; u64 b; u64 c; u64 d; } *u1; 195 struct my_u1 {
196 u64 a;
197 u64 b;
198 u64 c;
199 u64 d;
200 } *u1;
191 u32 staterr; 201 u32 staterr;
192 int i = 0; 202 int i = 0;
193 203
@@ -198,12 +208,10 @@ static void e1000e_dump(struct e1000_adapter *adapter)
198 if (netdev) { 208 if (netdev) {
199 dev_info(&adapter->pdev->dev, "Net device Info\n"); 209 dev_info(&adapter->pdev->dev, "Net device Info\n");
200 printk(KERN_INFO "Device Name state " 210 printk(KERN_INFO "Device Name state "
201 "trans_start last_rx\n"); 211 "trans_start last_rx\n");
202 printk(KERN_INFO "%-15s %016lX %016lX %016lX\n", 212 printk(KERN_INFO "%-15s %016lX %016lX %016lX\n",
203 netdev->name, 213 netdev->name, netdev->state, netdev->trans_start,
204 netdev->state, 214 netdev->last_rx);
205 netdev->trans_start,
206 netdev->last_rx);
207 } 215 }
208 216
209 /* Print Registers */ 217 /* Print Registers */
@@ -214,26 +222,26 @@ static void e1000e_dump(struct e1000_adapter *adapter)
214 e1000_regdump(hw, reginfo); 222 e1000_regdump(hw, reginfo);
215 } 223 }
216 224
217 /* Print TX Ring Summary */ 225 /* Print Tx Ring Summary */
218 if (!netdev || !netif_running(netdev)) 226 if (!netdev || !netif_running(netdev))
219 goto exit; 227 goto exit;
220 228
221 dev_info(&adapter->pdev->dev, "TX Rings Summary\n"); 229 dev_info(&adapter->pdev->dev, "Tx Ring Summary\n");
222 printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma ]" 230 printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma ]"
223 " leng ntw timestamp\n"); 231 " leng ntw timestamp\n");
224 buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean]; 232 buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean];
225 printk(KERN_INFO " %5d %5X %5X %016llX %04X %3X %016llX\n", 233 printk(KERN_INFO " %5d %5X %5X %016llX %04X %3X %016llX\n",
226 0, tx_ring->next_to_use, tx_ring->next_to_clean, 234 0, tx_ring->next_to_use, tx_ring->next_to_clean,
227 (unsigned long long)buffer_info->dma, 235 (unsigned long long)buffer_info->dma,
228 buffer_info->length, 236 buffer_info->length,
229 buffer_info->next_to_watch, 237 buffer_info->next_to_watch,
230 (unsigned long long)buffer_info->time_stamp); 238 (unsigned long long)buffer_info->time_stamp);
231 239
232 /* Print TX Rings */ 240 /* Print Tx Ring */
233 if (!netif_msg_tx_done(adapter)) 241 if (!netif_msg_tx_done(adapter))
234 goto rx_ring_summary; 242 goto rx_ring_summary;
235 243
236 dev_info(&adapter->pdev->dev, "TX Rings Dump\n"); 244 dev_info(&adapter->pdev->dev, "Tx Ring Dump\n");
237 245
238 /* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended) 246 /* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended)
239 * 247 *
@@ -263,22 +271,22 @@ static void e1000e_dump(struct e1000_adapter *adapter)
263 * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 271 * 63 48 47 40 39 36 35 32 31 24 23 20 19 0
264 */ 272 */
265 printk(KERN_INFO "Tl[desc] [address 63:0 ] [SpeCssSCmCsLen]" 273 printk(KERN_INFO "Tl[desc] [address 63:0 ] [SpeCssSCmCsLen]"
266 " [bi->dma ] leng ntw timestamp bi->skb " 274 " [bi->dma ] leng ntw timestamp bi->skb "
267 "<-- Legacy format\n"); 275 "<-- Legacy format\n");
268 printk(KERN_INFO "Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen]" 276 printk(KERN_INFO "Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen]"
269 " [bi->dma ] leng ntw timestamp bi->skb " 277 " [bi->dma ] leng ntw timestamp bi->skb "
270 "<-- Ext Context format\n"); 278 "<-- Ext Context format\n");
271 printk(KERN_INFO "Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen]" 279 printk(KERN_INFO "Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen]"
272 " [bi->dma ] leng ntw timestamp bi->skb " 280 " [bi->dma ] leng ntw timestamp bi->skb "
273 "<-- Ext Data format\n"); 281 "<-- Ext Data format\n");
274 for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { 282 for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
275 tx_desc = E1000_TX_DESC(*tx_ring, i); 283 tx_desc = E1000_TX_DESC(*tx_ring, i);
276 buffer_info = &tx_ring->buffer_info[i]; 284 buffer_info = &tx_ring->buffer_info[i];
277 u0 = (struct my_u0 *)tx_desc; 285 u0 = (struct my_u0 *)tx_desc;
278 printk(KERN_INFO "T%c[0x%03X] %016llX %016llX %016llX " 286 printk(KERN_INFO "T%c[0x%03X] %016llX %016llX %016llX "
279 "%04X %3X %016llX %p", 287 "%04X %3X %016llX %p",
280 (!(le64_to_cpu(u0->b) & (1<<29)) ? 'l' : 288 (!(le64_to_cpu(u0->b) & (1 << 29)) ? 'l' :
281 ((le64_to_cpu(u0->b) & (1<<20)) ? 'd' : 'c')), i, 289 ((le64_to_cpu(u0->b) & (1 << 20)) ? 'd' : 'c')), i,
282 (unsigned long long)le64_to_cpu(u0->a), 290 (unsigned long long)le64_to_cpu(u0->a),
283 (unsigned long long)le64_to_cpu(u0->b), 291 (unsigned long long)le64_to_cpu(u0->b),
284 (unsigned long long)buffer_info->dma, 292 (unsigned long long)buffer_info->dma,
@@ -296,22 +304,22 @@ static void e1000e_dump(struct e1000_adapter *adapter)
296 304
297 if (netif_msg_pktdata(adapter) && buffer_info->dma != 0) 305 if (netif_msg_pktdata(adapter) && buffer_info->dma != 0)
298 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 306 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
299 16, 1, phys_to_virt(buffer_info->dma), 307 16, 1, phys_to_virt(buffer_info->dma),
300 buffer_info->length, true); 308 buffer_info->length, true);
301 } 309 }
302 310
303 /* Print RX Rings Summary */ 311 /* Print Rx Ring Summary */
304rx_ring_summary: 312rx_ring_summary:
305 dev_info(&adapter->pdev->dev, "RX Rings Summary\n"); 313 dev_info(&adapter->pdev->dev, "Rx Ring Summary\n");
306 printk(KERN_INFO "Queue [NTU] [NTC]\n"); 314 printk(KERN_INFO "Queue [NTU] [NTC]\n");
307 printk(KERN_INFO " %5d %5X %5X\n", 0, 315 printk(KERN_INFO " %5d %5X %5X\n", 0,
308 rx_ring->next_to_use, rx_ring->next_to_clean); 316 rx_ring->next_to_use, rx_ring->next_to_clean);
309 317
310 /* Print RX Rings */ 318 /* Print Rx Ring */
311 if (!netif_msg_rx_status(adapter)) 319 if (!netif_msg_rx_status(adapter))
312 goto exit; 320 goto exit;
313 321
314 dev_info(&adapter->pdev->dev, "RX Rings Dump\n"); 322 dev_info(&adapter->pdev->dev, "Rx Ring Dump\n");
315 switch (adapter->rx_ps_pages) { 323 switch (adapter->rx_ps_pages) {
316 case 1: 324 case 1:
317 case 2: 325 case 2:
@@ -329,7 +337,7 @@ rx_ring_summary:
329 * +-----------------------------------------------------+ 337 * +-----------------------------------------------------+
330 */ 338 */
331 printk(KERN_INFO "R [desc] [buffer 0 63:0 ] " 339 printk(KERN_INFO "R [desc] [buffer 0 63:0 ] "
332 "[buffer 1 63:0 ] " 340 "[buffer 1 63:0 ] "
333 "[buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma ] " 341 "[buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma ] "
334 "[bi->skb] <-- Ext Pkt Split format\n"); 342 "[bi->skb] <-- Ext Pkt Split format\n");
335 /* [Extended] Receive Descriptor (Write-Back) Format 343 /* [Extended] Receive Descriptor (Write-Back) Format
@@ -344,7 +352,7 @@ rx_ring_summary:
344 * 63 48 47 32 31 20 19 0 352 * 63 48 47 32 31 20 19 0
345 */ 353 */
346 printk(KERN_INFO "RWB[desc] [ck ipid mrqhsh] " 354 printk(KERN_INFO "RWB[desc] [ck ipid mrqhsh] "
347 "[vl l0 ee es] " 355 "[vl l0 ee es] "
348 "[ l3 l2 l1 hs] [reserved ] ---------------- " 356 "[ l3 l2 l1 hs] [reserved ] ---------------- "
349 "[bi->skb] <-- Ext Rx Write-Back format\n"); 357 "[bi->skb] <-- Ext Rx Write-Back format\n");
350 for (i = 0; i < rx_ring->count; i++) { 358 for (i = 0; i < rx_ring->count; i++) {
@@ -352,26 +360,26 @@ rx_ring_summary:
352 rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i); 360 rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i);
353 u1 = (struct my_u1 *)rx_desc_ps; 361 u1 = (struct my_u1 *)rx_desc_ps;
354 staterr = 362 staterr =
355 le32_to_cpu(rx_desc_ps->wb.middle.status_error); 363 le32_to_cpu(rx_desc_ps->wb.middle.status_error);
356 if (staterr & E1000_RXD_STAT_DD) { 364 if (staterr & E1000_RXD_STAT_DD) {
357 /* Descriptor Done */ 365 /* Descriptor Done */
358 printk(KERN_INFO "RWB[0x%03X] %016llX " 366 printk(KERN_INFO "RWB[0x%03X] %016llX "
359 "%016llX %016llX %016llX " 367 "%016llX %016llX %016llX "
360 "---------------- %p", i, 368 "---------------- %p", i,
361 (unsigned long long)le64_to_cpu(u1->a), 369 (unsigned long long)le64_to_cpu(u1->a),
362 (unsigned long long)le64_to_cpu(u1->b), 370 (unsigned long long)le64_to_cpu(u1->b),
363 (unsigned long long)le64_to_cpu(u1->c), 371 (unsigned long long)le64_to_cpu(u1->c),
364 (unsigned long long)le64_to_cpu(u1->d), 372 (unsigned long long)le64_to_cpu(u1->d),
365 buffer_info->skb); 373 buffer_info->skb);
366 } else { 374 } else {
367 printk(KERN_INFO "R [0x%03X] %016llX " 375 printk(KERN_INFO "R [0x%03X] %016llX "
368 "%016llX %016llX %016llX %016llX %p", i, 376 "%016llX %016llX %016llX %016llX %p", i,
369 (unsigned long long)le64_to_cpu(u1->a), 377 (unsigned long long)le64_to_cpu(u1->a),
370 (unsigned long long)le64_to_cpu(u1->b), 378 (unsigned long long)le64_to_cpu(u1->b),
371 (unsigned long long)le64_to_cpu(u1->c), 379 (unsigned long long)le64_to_cpu(u1->c),
372 (unsigned long long)le64_to_cpu(u1->d), 380 (unsigned long long)le64_to_cpu(u1->d),
373 (unsigned long long)buffer_info->dma, 381 (unsigned long long)buffer_info->dma,
374 buffer_info->skb); 382 buffer_info->skb);
375 383
376 if (netif_msg_pktdata(adapter)) 384 if (netif_msg_pktdata(adapter))
377 print_hex_dump(KERN_INFO, "", 385 print_hex_dump(KERN_INFO, "",
@@ -400,18 +408,18 @@ rx_ring_summary:
400 * 63 48 47 40 39 32 31 16 15 0 408 * 63 48 47 40 39 32 31 16 15 0
401 */ 409 */
402 printk(KERN_INFO "Rl[desc] [address 63:0 ] " 410 printk(KERN_INFO "Rl[desc] [address 63:0 ] "
403 "[vl er S cks ln] [bi->dma ] [bi->skb] " 411 "[vl er S cks ln] [bi->dma ] [bi->skb] "
404 "<-- Legacy format\n"); 412 "<-- Legacy format\n");
405 for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) { 413 for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) {
406 rx_desc = E1000_RX_DESC(*rx_ring, i); 414 rx_desc = E1000_RX_DESC(*rx_ring, i);
407 buffer_info = &rx_ring->buffer_info[i]; 415 buffer_info = &rx_ring->buffer_info[i];
408 u0 = (struct my_u0 *)rx_desc; 416 u0 = (struct my_u0 *)rx_desc;
409 printk(KERN_INFO "Rl[0x%03X] %016llX %016llX " 417 printk(KERN_INFO "Rl[0x%03X] %016llX %016llX "
410 "%016llX %p", i, 418 "%016llX %p", i,
411 (unsigned long long)le64_to_cpu(u0->a), 419 (unsigned long long)le64_to_cpu(u0->a),
412 (unsigned long long)le64_to_cpu(u0->b), 420 (unsigned long long)le64_to_cpu(u0->b),
413 (unsigned long long)buffer_info->dma, 421 (unsigned long long)buffer_info->dma,
414 buffer_info->skb); 422 buffer_info->skb);
415 if (i == rx_ring->next_to_use) 423 if (i == rx_ring->next_to_use)
416 printk(KERN_CONT " NTU\n"); 424 printk(KERN_CONT " NTU\n");
417 else if (i == rx_ring->next_to_clean) 425 else if (i == rx_ring->next_to_clean)
@@ -421,9 +429,10 @@ rx_ring_summary:
421 429
422 if (netif_msg_pktdata(adapter)) 430 if (netif_msg_pktdata(adapter))
423 print_hex_dump(KERN_INFO, "", 431 print_hex_dump(KERN_INFO, "",
424 DUMP_PREFIX_ADDRESS, 432 DUMP_PREFIX_ADDRESS,
425 16, 1, phys_to_virt(buffer_info->dma), 433 16, 1,
426 adapter->rx_buffer_len, true); 434 phys_to_virt(buffer_info->dma),
435 adapter->rx_buffer_len, true);
427 } 436 }
428 } 437 }
429 438
@@ -450,21 +459,20 @@ static int e1000_desc_unused(struct e1000_ring *ring)
450 * @skb: pointer to sk_buff to be indicated to stack 459 * @skb: pointer to sk_buff to be indicated to stack
451 **/ 460 **/
452static void e1000_receive_skb(struct e1000_adapter *adapter, 461static void e1000_receive_skb(struct e1000_adapter *adapter,
453 struct net_device *netdev, 462 struct net_device *netdev, struct sk_buff *skb,
454 struct sk_buff *skb,
455 u8 status, __le16 vlan) 463 u8 status, __le16 vlan)
456{ 464{
465 u16 tag = le16_to_cpu(vlan);
457 skb->protocol = eth_type_trans(skb, netdev); 466 skb->protocol = eth_type_trans(skb, netdev);
458 467
459 if (adapter->vlgrp && (status & E1000_RXD_STAT_VP)) 468 if (status & E1000_RXD_STAT_VP)
460 vlan_gro_receive(&adapter->napi, adapter->vlgrp, 469 __vlan_hwaccel_put_tag(skb, tag);
461 le16_to_cpu(vlan), skb); 470
462 else 471 napi_gro_receive(&adapter->napi, skb);
463 napi_gro_receive(&adapter->napi, skb);
464} 472}
465 473
466/** 474/**
467 * e1000_rx_checksum - Receive Checksum Offload for 82543 475 * e1000_rx_checksum - Receive Checksum Offload
468 * @adapter: board private structure 476 * @adapter: board private structure
469 * @status_err: receive descriptor status and error fields 477 * @status_err: receive descriptor status and error fields
470 * @csum: receive descriptor csum field 478 * @csum: receive descriptor csum field
@@ -475,7 +483,8 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
475{ 483{
476 u16 status = (u16)status_err; 484 u16 status = (u16)status_err;
477 u8 errors = (u8)(status_err >> 24); 485 u8 errors = (u8)(status_err >> 24);
478 skb->ip_summed = CHECKSUM_NONE; 486
487 skb_checksum_none_assert(skb);
479 488
480 /* Ignore Checksum bit is set */ 489 /* Ignore Checksum bit is set */
481 if (status & E1000_RXD_STAT_IXSM) 490 if (status & E1000_RXD_STAT_IXSM)
@@ -547,7 +556,7 @@ map_skb:
547 adapter->rx_buffer_len, 556 adapter->rx_buffer_len,
548 DMA_FROM_DEVICE); 557 DMA_FROM_DEVICE);
549 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { 558 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
550 dev_err(&pdev->dev, "RX DMA map failed\n"); 559 dev_err(&pdev->dev, "Rx DMA map failed\n");
551 adapter->rx_dma_failed++; 560 adapter->rx_dma_failed++;
552 break; 561 break;
553 } 562 }
@@ -600,7 +609,8 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
600 ps_page = &buffer_info->ps_pages[j]; 609 ps_page = &buffer_info->ps_pages[j];
601 if (j >= adapter->rx_ps_pages) { 610 if (j >= adapter->rx_ps_pages) {
602 /* all unused desc entries get hw null ptr */ 611 /* all unused desc entries get hw null ptr */
603 rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0); 612 rx_desc->read.buffer_addr[j + 1] =
613 ~cpu_to_le64(0);
604 continue; 614 continue;
605 } 615 }
606 if (!ps_page->page) { 616 if (!ps_page->page) {
@@ -616,7 +626,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
616 if (dma_mapping_error(&pdev->dev, 626 if (dma_mapping_error(&pdev->dev,
617 ps_page->dma)) { 627 ps_page->dma)) {
618 dev_err(&adapter->pdev->dev, 628 dev_err(&adapter->pdev->dev,
619 "RX DMA page map failed\n"); 629 "Rx DMA page map failed\n");
620 adapter->rx_dma_failed++; 630 adapter->rx_dma_failed++;
621 goto no_buffers; 631 goto no_buffers;
622 } 632 }
@@ -626,8 +636,8 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
626 * didn't change because each write-back 636 * didn't change because each write-back
627 * erases this info. 637 * erases this info.
628 */ 638 */
629 rx_desc->read.buffer_addr[j+1] = 639 rx_desc->read.buffer_addr[j + 1] =
630 cpu_to_le64(ps_page->dma); 640 cpu_to_le64(ps_page->dma);
631 } 641 }
632 642
633 skb = netdev_alloc_skb_ip_align(netdev, 643 skb = netdev_alloc_skb_ip_align(netdev,
@@ -643,7 +653,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
643 adapter->rx_ps_bsize0, 653 adapter->rx_ps_bsize0,
644 DMA_FROM_DEVICE); 654 DMA_FROM_DEVICE);
645 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { 655 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
646 dev_err(&pdev->dev, "RX DMA map failed\n"); 656 dev_err(&pdev->dev, "Rx DMA map failed\n");
647 adapter->rx_dma_failed++; 657 adapter->rx_dma_failed++;
648 /* cleanup skb */ 658 /* cleanup skb */
649 dev_kfree_skb_any(skb); 659 dev_kfree_skb_any(skb);
@@ -661,7 +671,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
661 * such as IA-64). 671 * such as IA-64).
662 */ 672 */
663 wmb(); 673 wmb();
664 writel(i<<1, adapter->hw.hw_addr + rx_ring->tail); 674 writel(i << 1, adapter->hw.hw_addr + rx_ring->tail);
665 } 675 }
666 676
667 i++; 677 i++;
@@ -893,8 +903,6 @@ next_desc:
893 903
894 adapter->total_rx_bytes += total_rx_bytes; 904 adapter->total_rx_bytes += total_rx_bytes;
895 adapter->total_rx_packets += total_rx_packets; 905 adapter->total_rx_packets += total_rx_packets;
896 netdev->stats.rx_bytes += total_rx_bytes;
897 netdev->stats.rx_packets += total_rx_packets;
898 return cleaned; 906 return cleaned;
899} 907}
900 908
@@ -930,6 +938,9 @@ static void e1000_print_hw_hang(struct work_struct *work)
930 u16 phy_status, phy_1000t_status, phy_ext_status; 938 u16 phy_status, phy_1000t_status, phy_ext_status;
931 u16 pci_status; 939 u16 pci_status;
932 940
941 if (test_bit(__E1000_DOWN, &adapter->state))
942 return;
943
933 e1e_rphy(hw, PHY_STATUS, &phy_status); 944 e1e_rphy(hw, PHY_STATUS, &phy_status);
934 e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status); 945 e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status);
935 e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status); 946 e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status);
@@ -1050,9 +1061,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
1050 } 1061 }
1051 adapter->total_tx_bytes += total_tx_bytes; 1062 adapter->total_tx_bytes += total_tx_bytes;
1052 adapter->total_tx_packets += total_tx_packets; 1063 adapter->total_tx_packets += total_tx_packets;
1053 netdev->stats.tx_bytes += total_tx_bytes; 1064 return count < tx_ring->count;
1054 netdev->stats.tx_packets += total_tx_packets;
1055 return (count < tx_ring->count);
1056} 1065}
1057 1066
1058/** 1067/**
@@ -1105,11 +1114,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
1105 cleaned = 1; 1114 cleaned = 1;
1106 cleaned_count++; 1115 cleaned_count++;
1107 dma_unmap_single(&pdev->dev, buffer_info->dma, 1116 dma_unmap_single(&pdev->dev, buffer_info->dma,
1108 adapter->rx_ps_bsize0, 1117 adapter->rx_ps_bsize0, DMA_FROM_DEVICE);
1109 DMA_FROM_DEVICE);
1110 buffer_info->dma = 0; 1118 buffer_info->dma = 0;
1111 1119
1112 /* see !EOP comment in other rx routine */ 1120 /* see !EOP comment in other Rx routine */
1113 if (!(staterr & E1000_RXD_STAT_EOP)) 1121 if (!(staterr & E1000_RXD_STAT_EOP))
1114 adapter->flags2 |= FLAG2_IS_DISCARDING; 1122 adapter->flags2 |= FLAG2_IS_DISCARDING;
1115 1123
@@ -1239,8 +1247,6 @@ next_desc:
1239 1247
1240 adapter->total_rx_bytes += total_rx_bytes; 1248 adapter->total_rx_bytes += total_rx_bytes;
1241 adapter->total_rx_packets += total_rx_packets; 1249 adapter->total_rx_packets += total_rx_packets;
1242 netdev->stats.rx_bytes += total_rx_bytes;
1243 netdev->stats.rx_packets += total_rx_packets;
1244 return cleaned; 1250 return cleaned;
1245} 1251}
1246 1252
@@ -1319,12 +1325,12 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
1319 /* an error means any chain goes out the window 1325 /* an error means any chain goes out the window
1320 * too */ 1326 * too */
1321 if (rx_ring->rx_skb_top) 1327 if (rx_ring->rx_skb_top)
1322 dev_kfree_skb(rx_ring->rx_skb_top); 1328 dev_kfree_skb_irq(rx_ring->rx_skb_top);
1323 rx_ring->rx_skb_top = NULL; 1329 rx_ring->rx_skb_top = NULL;
1324 goto next_desc; 1330 goto next_desc;
1325 } 1331 }
1326 1332
1327#define rxtop rx_ring->rx_skb_top 1333#define rxtop (rx_ring->rx_skb_top)
1328 if (!(status & E1000_RXD_STAT_EOP)) { 1334 if (!(status & E1000_RXD_STAT_EOP)) {
1329 /* this descriptor is only the beginning (or middle) */ 1335 /* this descriptor is only the beginning (or middle) */
1330 if (!rxtop) { 1336 if (!rxtop) {
@@ -1392,7 +1398,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
1392 /* eth type trans needs skb->data to point to something */ 1398 /* eth type trans needs skb->data to point to something */
1393 if (!pskb_may_pull(skb, ETH_HLEN)) { 1399 if (!pskb_may_pull(skb, ETH_HLEN)) {
1394 e_err("pskb_may_pull failed.\n"); 1400 e_err("pskb_may_pull failed.\n");
1395 dev_kfree_skb(skb); 1401 dev_kfree_skb_irq(skb);
1396 goto next_desc; 1402 goto next_desc;
1397 } 1403 }
1398 1404
@@ -1420,8 +1426,6 @@ next_desc:
1420 1426
1421 adapter->total_rx_bytes += total_rx_bytes; 1427 adapter->total_rx_bytes += total_rx_bytes;
1422 adapter->total_rx_packets += total_rx_packets; 1428 adapter->total_rx_packets += total_rx_packets;
1423 netdev->stats.rx_bytes += total_rx_bytes;
1424 netdev->stats.rx_packets += total_rx_packets;
1425 return cleaned; 1429 return cleaned;
1426} 1430}
1427 1431
@@ -1500,6 +1504,9 @@ static void e1000e_downshift_workaround(struct work_struct *work)
1500 struct e1000_adapter *adapter = container_of(work, 1504 struct e1000_adapter *adapter = container_of(work,
1501 struct e1000_adapter, downshift_task); 1505 struct e1000_adapter, downshift_task);
1502 1506
1507 if (test_bit(__E1000_DOWN, &adapter->state))
1508 return;
1509
1503 e1000e_gig_downshift_workaround_ich8lan(&adapter->hw); 1510 e1000e_gig_downshift_workaround_ich8lan(&adapter->hw);
1504} 1511}
1505 1512
@@ -1805,9 +1812,8 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
1805 err = pci_enable_msix(adapter->pdev, 1812 err = pci_enable_msix(adapter->pdev,
1806 adapter->msix_entries, 1813 adapter->msix_entries,
1807 adapter->num_vectors); 1814 adapter->num_vectors);
1808 if (err == 0) { 1815 if (err == 0)
1809 return; 1816 return;
1810 }
1811 } 1817 }
1812 /* MSI-X failed, so fall through and try MSI */ 1818 /* MSI-X failed, so fall through and try MSI */
1813 e_err("Failed to initialize MSI-X interrupts. " 1819 e_err("Failed to initialize MSI-X interrupts. "
@@ -1846,7 +1852,9 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
1846 int err = 0, vector = 0; 1852 int err = 0, vector = 0;
1847 1853
1848 if (strlen(netdev->name) < (IFNAMSIZ - 5)) 1854 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1849 sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name); 1855 snprintf(adapter->rx_ring->name,
1856 sizeof(adapter->rx_ring->name) - 1,
1857 "%s-rx-0", netdev->name);
1850 else 1858 else
1851 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ); 1859 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
1852 err = request_irq(adapter->msix_entries[vector].vector, 1860 err = request_irq(adapter->msix_entries[vector].vector,
@@ -1859,7 +1867,9 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
1859 vector++; 1867 vector++;
1860 1868
1861 if (strlen(netdev->name) < (IFNAMSIZ - 5)) 1869 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1862 sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name); 1870 snprintf(adapter->tx_ring->name,
1871 sizeof(adapter->tx_ring->name) - 1,
1872 "%s-tx-0", netdev->name);
1863 else 1873 else
1864 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ); 1874 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
1865 err = request_irq(adapter->msix_entries[vector].vector, 1875 err = request_irq(adapter->msix_entries[vector].vector,
@@ -1980,15 +1990,15 @@ static void e1000_irq_enable(struct e1000_adapter *adapter)
1980} 1990}
1981 1991
1982/** 1992/**
1983 * e1000_get_hw_control - get control of the h/w from f/w 1993 * e1000e_get_hw_control - get control of the h/w from f/w
1984 * @adapter: address of board private structure 1994 * @adapter: address of board private structure
1985 * 1995 *
1986 * e1000_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit. 1996 * e1000e_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit.
1987 * For ASF and Pass Through versions of f/w this means that 1997 * For ASF and Pass Through versions of f/w this means that
1988 * the driver is loaded. For AMT version (only with 82573) 1998 * the driver is loaded. For AMT version (only with 82573)
1989 * of the f/w this means that the network i/f is open. 1999 * of the f/w this means that the network i/f is open.
1990 **/ 2000 **/
1991static void e1000_get_hw_control(struct e1000_adapter *adapter) 2001void e1000e_get_hw_control(struct e1000_adapter *adapter)
1992{ 2002{
1993 struct e1000_hw *hw = &adapter->hw; 2003 struct e1000_hw *hw = &adapter->hw;
1994 u32 ctrl_ext; 2004 u32 ctrl_ext;
@@ -2005,16 +2015,16 @@ static void e1000_get_hw_control(struct e1000_adapter *adapter)
2005} 2015}
2006 2016
2007/** 2017/**
2008 * e1000_release_hw_control - release control of the h/w to f/w 2018 * e1000e_release_hw_control - release control of the h/w to f/w
2009 * @adapter: address of board private structure 2019 * @adapter: address of board private structure
2010 * 2020 *
2011 * e1000_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit. 2021 * e1000e_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit.
2012 * For ASF and Pass Through versions of f/w this means that the 2022 * For ASF and Pass Through versions of f/w this means that the
2013 * driver is no longer loaded. For AMT version (only with 82573) i 2023 * driver is no longer loaded. For AMT version (only with 82573) i
2014 * of the f/w this means that the network i/f is closed. 2024 * of the f/w this means that the network i/f is closed.
2015 * 2025 *
2016 **/ 2026 **/
2017static void e1000_release_hw_control(struct e1000_adapter *adapter) 2027void e1000e_release_hw_control(struct e1000_adapter *adapter)
2018{ 2028{
2019 struct e1000_hw *hw = &adapter->hw; 2029 struct e1000_hw *hw = &adapter->hw;
2020 u32 ctrl_ext; 2030 u32 ctrl_ext;
@@ -2058,10 +2068,9 @@ int e1000e_setup_tx_resources(struct e1000_adapter *adapter)
2058 int err = -ENOMEM, size; 2068 int err = -ENOMEM, size;
2059 2069
2060 size = sizeof(struct e1000_buffer) * tx_ring->count; 2070 size = sizeof(struct e1000_buffer) * tx_ring->count;
2061 tx_ring->buffer_info = vmalloc(size); 2071 tx_ring->buffer_info = vzalloc(size);
2062 if (!tx_ring->buffer_info) 2072 if (!tx_ring->buffer_info)
2063 goto err; 2073 goto err;
2064 memset(tx_ring->buffer_info, 0, size);
2065 2074
2066 /* round up to nearest 4K */ 2075 /* round up to nearest 4K */
2067 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc); 2076 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
@@ -2094,10 +2103,9 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter)
2094 int i, size, desc_len, err = -ENOMEM; 2103 int i, size, desc_len, err = -ENOMEM;
2095 2104
2096 size = sizeof(struct e1000_buffer) * rx_ring->count; 2105 size = sizeof(struct e1000_buffer) * rx_ring->count;
2097 rx_ring->buffer_info = vmalloc(size); 2106 rx_ring->buffer_info = vzalloc(size);
2098 if (!rx_ring->buffer_info) 2107 if (!rx_ring->buffer_info)
2099 goto err; 2108 goto err;
2100 memset(rx_ring->buffer_info, 0, size);
2101 2109
2102 for (i = 0; i < rx_ring->count; i++) { 2110 for (i = 0; i < rx_ring->count; i++) {
2103 buffer_info = &rx_ring->buffer_info[i]; 2111 buffer_info = &rx_ring->buffer_info[i];
@@ -2131,7 +2139,7 @@ err_pages:
2131 } 2139 }
2132err: 2140err:
2133 vfree(rx_ring->buffer_info); 2141 vfree(rx_ring->buffer_info);
2134 e_err("Unable to allocate memory for the transmit descriptor ring\n"); 2142 e_err("Unable to allocate memory for the receive descriptor ring\n");
2135 return err; 2143 return err;
2136} 2144}
2137 2145
@@ -2199,9 +2207,8 @@ void e1000e_free_rx_resources(struct e1000_adapter *adapter)
2199 2207
2200 e1000_clean_rx_ring(adapter); 2208 e1000_clean_rx_ring(adapter);
2201 2209
2202 for (i = 0; i < rx_ring->count; i++) { 2210 for (i = 0; i < rx_ring->count; i++)
2203 kfree(rx_ring->buffer_info[i].ps_pages); 2211 kfree(rx_ring->buffer_info[i].ps_pages);
2204 }
2205 2212
2206 vfree(rx_ring->buffer_info); 2213 vfree(rx_ring->buffer_info);
2207 rx_ring->buffer_info = NULL; 2214 rx_ring->buffer_info = NULL;
@@ -2241,20 +2248,18 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
2241 /* handle TSO and jumbo frames */ 2248 /* handle TSO and jumbo frames */
2242 if (bytes/packets > 8000) 2249 if (bytes/packets > 8000)
2243 retval = bulk_latency; 2250 retval = bulk_latency;
2244 else if ((packets < 5) && (bytes > 512)) { 2251 else if ((packets < 5) && (bytes > 512))
2245 retval = low_latency; 2252 retval = low_latency;
2246 }
2247 break; 2253 break;
2248 case low_latency: /* 50 usec aka 20000 ints/s */ 2254 case low_latency: /* 50 usec aka 20000 ints/s */
2249 if (bytes > 10000) { 2255 if (bytes > 10000) {
2250 /* this if handles the TSO accounting */ 2256 /* this if handles the TSO accounting */
2251 if (bytes/packets > 8000) { 2257 if (bytes/packets > 8000)
2252 retval = bulk_latency; 2258 retval = bulk_latency;
2253 } else if ((packets < 10) || ((bytes/packets) > 1200)) { 2259 else if ((packets < 10) || ((bytes/packets) > 1200))
2254 retval = bulk_latency; 2260 retval = bulk_latency;
2255 } else if ((packets > 35)) { 2261 else if ((packets > 35))
2256 retval = lowest_latency; 2262 retval = lowest_latency;
2257 }
2258 } else if (bytes/packets > 2000) { 2263 } else if (bytes/packets > 2000) {
2259 retval = bulk_latency; 2264 retval = bulk_latency;
2260 } else if (packets <= 2 && bytes < 512) { 2265 } else if (packets <= 2 && bytes < 512) {
@@ -2263,9 +2268,8 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
2263 break; 2268 break;
2264 case bulk_latency: /* 250 usec aka 4000 ints/s */ 2269 case bulk_latency: /* 250 usec aka 4000 ints/s */
2265 if (bytes > 25000) { 2270 if (bytes > 25000) {
2266 if (packets > 35) { 2271 if (packets > 35)
2267 retval = low_latency; 2272 retval = low_latency;
2268 }
2269 } else if (bytes < 6000) { 2273 } else if (bytes < 6000) {
2270 retval = low_latency; 2274 retval = low_latency;
2271 } 2275 }
@@ -2289,6 +2293,11 @@ static void e1000_set_itr(struct e1000_adapter *adapter)
2289 goto set_itr_now; 2293 goto set_itr_now;
2290 } 2294 }
2291 2295
2296 if (adapter->flags2 & FLAG2_DISABLE_AIM) {
2297 new_itr = 0;
2298 goto set_itr_now;
2299 }
2300
2292 adapter->tx_itr = e1000_update_itr(adapter, 2301 adapter->tx_itr = e1000_update_itr(adapter,
2293 adapter->tx_itr, 2302 adapter->tx_itr,
2294 adapter->total_tx_packets, 2303 adapter->total_tx_packets,
@@ -2337,7 +2346,10 @@ set_itr_now:
2337 if (adapter->msix_entries) 2346 if (adapter->msix_entries)
2338 adapter->rx_ring->set_itr = 1; 2347 adapter->rx_ring->set_itr = 1;
2339 else 2348 else
2340 ew32(ITR, 1000000000 / (new_itr * 256)); 2349 if (new_itr)
2350 ew32(ITR, 1000000000 / (new_itr * 256));
2351 else
2352 ew32(ITR, 0);
2341 } 2353 }
2342} 2354}
2343 2355
@@ -2424,6 +2436,8 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
2424 vfta |= (1 << (vid & 0x1F)); 2436 vfta |= (1 << (vid & 0x1F));
2425 hw->mac.ops.write_vfta(hw, index, vfta); 2437 hw->mac.ops.write_vfta(hw, index, vfta);
2426 } 2438 }
2439
2440 set_bit(vid, adapter->active_vlans);
2427} 2441}
2428 2442
2429static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) 2443static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
@@ -2432,18 +2446,11 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
2432 struct e1000_hw *hw = &adapter->hw; 2446 struct e1000_hw *hw = &adapter->hw;
2433 u32 vfta, index; 2447 u32 vfta, index;
2434 2448
2435 if (!test_bit(__E1000_DOWN, &adapter->state))
2436 e1000_irq_disable(adapter);
2437 vlan_group_set_device(adapter->vlgrp, vid, NULL);
2438
2439 if (!test_bit(__E1000_DOWN, &adapter->state))
2440 e1000_irq_enable(adapter);
2441
2442 if ((adapter->hw.mng_cookie.status & 2449 if ((adapter->hw.mng_cookie.status &
2443 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) && 2450 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
2444 (vid == adapter->mng_vlan_id)) { 2451 (vid == adapter->mng_vlan_id)) {
2445 /* release control to f/w */ 2452 /* release control to f/w */
2446 e1000_release_hw_control(adapter); 2453 e1000e_release_hw_control(adapter);
2447 return; 2454 return;
2448 } 2455 }
2449 2456
@@ -2454,93 +2461,105 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
2454 vfta &= ~(1 << (vid & 0x1F)); 2461 vfta &= ~(1 << (vid & 0x1F));
2455 hw->mac.ops.write_vfta(hw, index, vfta); 2462 hw->mac.ops.write_vfta(hw, index, vfta);
2456 } 2463 }
2464
2465 clear_bit(vid, adapter->active_vlans);
2457} 2466}
2458 2467
2459static void e1000_update_mng_vlan(struct e1000_adapter *adapter) 2468/**
2469 * e1000e_vlan_filter_disable - helper to disable hw VLAN filtering
2470 * @adapter: board private structure to initialize
2471 **/
2472static void e1000e_vlan_filter_disable(struct e1000_adapter *adapter)
2460{ 2473{
2461 struct net_device *netdev = adapter->netdev; 2474 struct net_device *netdev = adapter->netdev;
2462 u16 vid = adapter->hw.mng_cookie.vlan_id; 2475 struct e1000_hw *hw = &adapter->hw;
2463 u16 old_vid = adapter->mng_vlan_id; 2476 u32 rctl;
2464
2465 if (!adapter->vlgrp)
2466 return;
2467 2477
2468 if (!vlan_group_get_device(adapter->vlgrp, vid)) { 2478 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
2469 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 2479 /* disable VLAN receive filtering */
2470 if (adapter->hw.mng_cookie.status & 2480 rctl = er32(RCTL);
2471 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) { 2481 rctl &= ~(E1000_RCTL_VFE | E1000_RCTL_CFIEN);
2472 e1000_vlan_rx_add_vid(netdev, vid); 2482 ew32(RCTL, rctl);
2473 adapter->mng_vlan_id = vid; 2483
2484 if (adapter->mng_vlan_id != (u16)E1000_MNG_VLAN_NONE) {
2485 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
2486 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
2474 } 2487 }
2475
2476 if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
2477 (vid != old_vid) &&
2478 !vlan_group_get_device(adapter->vlgrp, old_vid))
2479 e1000_vlan_rx_kill_vid(netdev, old_vid);
2480 } else {
2481 adapter->mng_vlan_id = vid;
2482 } 2488 }
2483} 2489}
2484 2490
2491/**
2492 * e1000e_vlan_filter_enable - helper to enable HW VLAN filtering
2493 * @adapter: board private structure to initialize
2494 **/
2495static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
2496{
2497 struct e1000_hw *hw = &adapter->hw;
2498 u32 rctl;
2499
2500 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
2501 /* enable VLAN receive filtering */
2502 rctl = er32(RCTL);
2503 rctl |= E1000_RCTL_VFE;
2504 rctl &= ~E1000_RCTL_CFIEN;
2505 ew32(RCTL, rctl);
2506 }
2507}
2485 2508
2486static void e1000_vlan_rx_register(struct net_device *netdev, 2509/**
2487 struct vlan_group *grp) 2510 * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
2511 * @adapter: board private structure to initialize
2512 **/
2513static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
2488{ 2514{
2489 struct e1000_adapter *adapter = netdev_priv(netdev);
2490 struct e1000_hw *hw = &adapter->hw; 2515 struct e1000_hw *hw = &adapter->hw;
2491 u32 ctrl, rctl; 2516 u32 ctrl;
2492 2517
2493 if (!test_bit(__E1000_DOWN, &adapter->state)) 2518 /* disable VLAN tag insert/strip */
2494 e1000_irq_disable(adapter); 2519 ctrl = er32(CTRL);
2495 adapter->vlgrp = grp; 2520 ctrl &= ~E1000_CTRL_VME;
2521 ew32(CTRL, ctrl);
2522}
2496 2523
2497 if (grp) { 2524/**
2498 /* enable VLAN tag insert/strip */ 2525 * e1000e_vlan_strip_enable - helper to enable HW VLAN stripping
2499 ctrl = er32(CTRL); 2526 * @adapter: board private structure to initialize
2500 ctrl |= E1000_CTRL_VME; 2527 **/
2501 ew32(CTRL, ctrl); 2528static void e1000e_vlan_strip_enable(struct e1000_adapter *adapter)
2529{
2530 struct e1000_hw *hw = &adapter->hw;
2531 u32 ctrl;
2502 2532
2503 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) { 2533 /* enable VLAN tag insert/strip */
2504 /* enable VLAN receive filtering */ 2534 ctrl = er32(CTRL);
2505 rctl = er32(RCTL); 2535 ctrl |= E1000_CTRL_VME;
2506 rctl &= ~E1000_RCTL_CFIEN; 2536 ew32(CTRL, ctrl);
2507 ew32(RCTL, rctl); 2537}
2508 e1000_update_mng_vlan(adapter);
2509 }
2510 } else {
2511 /* disable VLAN tag insert/strip */
2512 ctrl = er32(CTRL);
2513 ctrl &= ~E1000_CTRL_VME;
2514 ew32(CTRL, ctrl);
2515 2538
2516 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) { 2539static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
2517 if (adapter->mng_vlan_id != 2540{
2518 (u16)E1000_MNG_VLAN_NONE) { 2541 struct net_device *netdev = adapter->netdev;
2519 e1000_vlan_rx_kill_vid(netdev, 2542 u16 vid = adapter->hw.mng_cookie.vlan_id;
2520 adapter->mng_vlan_id); 2543 u16 old_vid = adapter->mng_vlan_id;
2521 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 2544
2522 } 2545 if (adapter->hw.mng_cookie.status &
2523 } 2546 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
2547 e1000_vlan_rx_add_vid(netdev, vid);
2548 adapter->mng_vlan_id = vid;
2524 } 2549 }
2525 2550
2526 if (!test_bit(__E1000_DOWN, &adapter->state)) 2551 if ((old_vid != (u16)E1000_MNG_VLAN_NONE) && (vid != old_vid))
2527 e1000_irq_enable(adapter); 2552 e1000_vlan_rx_kill_vid(netdev, old_vid);
2528} 2553}
2529 2554
2530static void e1000_restore_vlan(struct e1000_adapter *adapter) 2555static void e1000_restore_vlan(struct e1000_adapter *adapter)
2531{ 2556{
2532 u16 vid; 2557 u16 vid;
2533 2558
2534 e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp); 2559 e1000_vlan_rx_add_vid(adapter->netdev, 0);
2535 2560
2536 if (!adapter->vlgrp) 2561 for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
2537 return;
2538
2539 for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
2540 if (!vlan_group_get_device(adapter->vlgrp, vid))
2541 continue;
2542 e1000_vlan_rx_add_vid(adapter->netdev, vid); 2562 e1000_vlan_rx_add_vid(adapter->netdev, vid);
2543 }
2544} 2563}
2545 2564
2546static void e1000_init_manageability_pt(struct e1000_adapter *adapter) 2565static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
@@ -2608,7 +2627,7 @@ static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
2608} 2627}
2609 2628
2610/** 2629/**
2611 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset 2630 * e1000_configure_tx - Configure Transmit Unit after Reset
2612 * @adapter: board private structure 2631 * @adapter: board private structure
2613 * 2632 *
2614 * Configure the Tx unit of the MAC after a reset. 2633 * Configure the Tx unit of the MAC after a reset.
@@ -2649,6 +2668,26 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2649 /* Tx irq moderation */ 2668 /* Tx irq moderation */
2650 ew32(TADV, adapter->tx_abs_int_delay); 2669 ew32(TADV, adapter->tx_abs_int_delay);
2651 2670
2671 if (adapter->flags2 & FLAG2_DMA_BURST) {
2672 u32 txdctl = er32(TXDCTL(0));
2673 txdctl &= ~(E1000_TXDCTL_PTHRESH | E1000_TXDCTL_HTHRESH |
2674 E1000_TXDCTL_WTHRESH);
2675 /*
2676 * set up some performance related parameters to encourage the
2677 * hardware to use the bus more efficiently in bursts, depends
2678 * on the tx_int_delay to be enabled,
2679 * wthresh = 5 ==> burst write a cacheline (64 bytes) at a time
2680 * hthresh = 1 ==> prefetch when one or more available
2681 * pthresh = 0x1f ==> prefetch if internal cache 31 or less
2682 * BEWARE: this seems to work but should be considered first if
2683 * there are Tx hangs or other Tx related bugs
2684 */
2685 txdctl |= E1000_TXDCTL_DMA_BURST_ENABLE;
2686 ew32(TXDCTL(0), txdctl);
2687 /* erratum work around: set txdctl the same for both queues */
2688 ew32(TXDCTL(1), txdctl);
2689 }
2690
2652 /* Program the Transmit Control Register */ 2691 /* Program the Transmit Control Register */
2653 tctl = er32(TCTL); 2692 tctl = er32(TCTL);
2654 tctl &= ~E1000_TCTL_CT; 2693 tctl &= ~E1000_TCTL_CT;
@@ -2701,7 +2740,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2701{ 2740{
2702 struct e1000_hw *hw = &adapter->hw; 2741 struct e1000_hw *hw = &adapter->hw;
2703 u32 rctl, rfctl; 2742 u32 rctl, rfctl;
2704 u32 psrctl = 0;
2705 u32 pages = 0; 2743 u32 pages = 0;
2706 2744
2707 /* Workaround Si errata on 82579 - configure jumbo frame flow */ 2745 /* Workaround Si errata on 82579 - configure jumbo frame flow */
@@ -2712,6 +2750,9 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2712 ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true); 2750 ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true);
2713 else 2751 else
2714 ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false); 2752 ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false);
2753
2754 if (ret_val)
2755 e_dbg("failed to enable jumbo frame workaround mode\n");
2715 } 2756 }
2716 2757
2717 /* Program MC offset vector base */ 2758 /* Program MC offset vector base */
@@ -2797,6 +2838,8 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2797 adapter->rx_ps_pages = 0; 2838 adapter->rx_ps_pages = 0;
2798 2839
2799 if (adapter->rx_ps_pages) { 2840 if (adapter->rx_ps_pages) {
2841 u32 psrctl = 0;
2842
2800 /* Configure extra packet-split registers */ 2843 /* Configure extra packet-split registers */
2801 rfctl = er32(RFCTL); 2844 rfctl = er32(RFCTL);
2802 rfctl |= E1000_RFCTL_EXTEN; 2845 rfctl |= E1000_RFCTL_EXTEN;
@@ -2852,7 +2895,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2852 if (adapter->rx_ps_pages) { 2895 if (adapter->rx_ps_pages) {
2853 /* this is a 32 byte descriptor */ 2896 /* this is a 32 byte descriptor */
2854 rdlen = rx_ring->count * 2897 rdlen = rx_ring->count *
2855 sizeof(union e1000_rx_desc_packet_split); 2898 sizeof(union e1000_rx_desc_packet_split);
2856 adapter->clean_rx = e1000_clean_rx_irq_ps; 2899 adapter->clean_rx = e1000_clean_rx_irq_ps;
2857 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; 2900 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
2858 } else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) { 2901 } else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
@@ -2869,14 +2912,37 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2869 rctl = er32(RCTL); 2912 rctl = er32(RCTL);
2870 ew32(RCTL, rctl & ~E1000_RCTL_EN); 2913 ew32(RCTL, rctl & ~E1000_RCTL_EN);
2871 e1e_flush(); 2914 e1e_flush();
2872 msleep(10); 2915 usleep_range(10000, 20000);
2916
2917 if (adapter->flags2 & FLAG2_DMA_BURST) {
2918 /*
2919 * set the writeback threshold (only takes effect if the RDTR
2920 * is set). set GRAN=1 and write back up to 0x4 worth, and
2921 * enable prefetching of 0x20 Rx descriptors
2922 * granularity = 01
2923 * wthresh = 04,
2924 * hthresh = 04,
2925 * pthresh = 0x20
2926 */
2927 ew32(RXDCTL(0), E1000_RXDCTL_DMA_BURST_ENABLE);
2928 ew32(RXDCTL(1), E1000_RXDCTL_DMA_BURST_ENABLE);
2929
2930 /*
2931 * override the delay timers for enabling bursting, only if
2932 * the value was not set by the user via module options
2933 */
2934 if (adapter->rx_int_delay == DEFAULT_RDTR)
2935 adapter->rx_int_delay = BURST_RDTR;
2936 if (adapter->rx_abs_int_delay == DEFAULT_RADV)
2937 adapter->rx_abs_int_delay = BURST_RADV;
2938 }
2873 2939
2874 /* set the Receive Delay Timer Register */ 2940 /* set the Receive Delay Timer Register */
2875 ew32(RDTR, adapter->rx_int_delay); 2941 ew32(RDTR, adapter->rx_int_delay);
2876 2942
2877 /* irq moderation */ 2943 /* irq moderation */
2878 ew32(RADV, adapter->rx_abs_int_delay); 2944 ew32(RADV, adapter->rx_abs_int_delay);
2879 if (adapter->itr_setting != 0) 2945 if ((adapter->itr_setting != 0) && (adapter->itr != 0))
2880 ew32(ITR, 1000000000 / (adapter->itr * 256)); 2946 ew32(ITR, 1000000000 / (adapter->itr * 256));
2881 2947
2882 ctrl_ext = er32(CTRL_EXT); 2948 ctrl_ext = er32(CTRL_EXT);
@@ -2921,22 +2987,22 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2921 * packet size is equal or larger than the specified value (in 8 byte 2987 * packet size is equal or larger than the specified value (in 8 byte
2922 * units), e.g. using jumbo frames when setting to E1000_ERT_2048 2988 * units), e.g. using jumbo frames when setting to E1000_ERT_2048
2923 */ 2989 */
2924 if (adapter->flags & FLAG_HAS_ERT) { 2990 if ((adapter->flags & FLAG_HAS_ERT) ||
2991 (adapter->hw.mac.type == e1000_pch2lan)) {
2925 if (adapter->netdev->mtu > ETH_DATA_LEN) { 2992 if (adapter->netdev->mtu > ETH_DATA_LEN) {
2926 u32 rxdctl = er32(RXDCTL(0)); 2993 u32 rxdctl = er32(RXDCTL(0));
2927 ew32(RXDCTL(0), rxdctl | 0x3); 2994 ew32(RXDCTL(0), rxdctl | 0x3);
2928 ew32(ERT, E1000_ERT_2048 | (1 << 13)); 2995 if (adapter->flags & FLAG_HAS_ERT)
2996 ew32(ERT, E1000_ERT_2048 | (1 << 13));
2929 /* 2997 /*
2930 * With jumbo frames and early-receive enabled, 2998 * With jumbo frames and early-receive enabled,
2931 * excessive C-state transition latencies result in 2999 * excessive C-state transition latencies result in
2932 * dropped transactions. 3000 * dropped transactions.
2933 */ 3001 */
2934 pm_qos_update_request( 3002 pm_qos_update_request(&adapter->netdev->pm_qos_req, 55);
2935 &adapter->netdev->pm_qos_req, 55);
2936 } else { 3003 } else {
2937 pm_qos_update_request( 3004 pm_qos_update_request(&adapter->netdev->pm_qos_req,
2938 &adapter->netdev->pm_qos_req, 3005 PM_QOS_DEFAULT_VALUE);
2939 PM_QOS_DEFAULT_VALUE);
2940 } 3006 }
2941 } 3007 }
2942 3008
@@ -2975,7 +3041,6 @@ static void e1000_set_multi(struct net_device *netdev)
2975 struct netdev_hw_addr *ha; 3041 struct netdev_hw_addr *ha;
2976 u8 *mta_list; 3042 u8 *mta_list;
2977 u32 rctl; 3043 u32 rctl;
2978 int i;
2979 3044
2980 /* Check for Promiscuous and All Multicast modes */ 3045 /* Check for Promiscuous and All Multicast modes */
2981 3046
@@ -2984,6 +3049,8 @@ static void e1000_set_multi(struct net_device *netdev)
2984 if (netdev->flags & IFF_PROMISC) { 3049 if (netdev->flags & IFF_PROMISC) {
2985 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); 3050 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
2986 rctl &= ~E1000_RCTL_VFE; 3051 rctl &= ~E1000_RCTL_VFE;
3052 /* Do not hardware filter VLANs in promisc mode */
3053 e1000e_vlan_filter_disable(adapter);
2987 } else { 3054 } else {
2988 if (netdev->flags & IFF_ALLMULTI) { 3055 if (netdev->flags & IFF_ALLMULTI) {
2989 rctl |= E1000_RCTL_MPE; 3056 rctl |= E1000_RCTL_MPE;
@@ -2991,19 +3058,19 @@ static void e1000_set_multi(struct net_device *netdev)
2991 } else { 3058 } else {
2992 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE); 3059 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
2993 } 3060 }
2994 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) 3061 e1000e_vlan_filter_enable(adapter);
2995 rctl |= E1000_RCTL_VFE;
2996 } 3062 }
2997 3063
2998 ew32(RCTL, rctl); 3064 ew32(RCTL, rctl);
2999 3065
3000 if (!netdev_mc_empty(netdev)) { 3066 if (!netdev_mc_empty(netdev)) {
3067 int i = 0;
3068
3001 mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); 3069 mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
3002 if (!mta_list) 3070 if (!mta_list)
3003 return; 3071 return;
3004 3072
3005 /* prepare a packed array of only addresses. */ 3073 /* prepare a packed array of only addresses. */
3006 i = 0;
3007 netdev_for_each_mc_addr(ha, netdev) 3074 netdev_for_each_mc_addr(ha, netdev)
3008 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN); 3075 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
3009 3076
@@ -3016,6 +3083,11 @@ static void e1000_set_multi(struct net_device *netdev)
3016 */ 3083 */
3017 e1000_update_mc_addr_list(hw, NULL, 0); 3084 e1000_update_mc_addr_list(hw, NULL, 0);
3018 } 3085 }
3086
3087 if (netdev->features & NETIF_F_HW_VLAN_RX)
3088 e1000e_vlan_strip_enable(adapter);
3089 else
3090 e1000e_vlan_strip_disable(adapter);
3019} 3091}
3020 3092
3021/** 3093/**
@@ -3102,7 +3174,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
3102 /* lower 16 bits has Rx packet buffer allocation size in KB */ 3174 /* lower 16 bits has Rx packet buffer allocation size in KB */
3103 pba &= 0xffff; 3175 pba &= 0xffff;
3104 /* 3176 /*
3105 * the Tx fifo also stores 16 bytes of information about the tx 3177 * the Tx fifo also stores 16 bytes of information about the Tx
3106 * but don't include ethernet FCS because hardware appends it 3178 * but don't include ethernet FCS because hardware appends it
3107 */ 3179 */
3108 min_tx_space = (adapter->max_frame_size + 3180 min_tx_space = (adapter->max_frame_size +
@@ -3125,7 +3197,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
3125 pba -= min_tx_space - tx_space; 3197 pba -= min_tx_space - tx_space;
3126 3198
3127 /* 3199 /*
3128 * if short on Rx space, Rx wins and must trump tx 3200 * if short on Rx space, Rx wins and must trump Tx
3129 * adjustment or use Early Receive if available 3201 * adjustment or use Early Receive if available
3130 */ 3202 */
3131 if ((pba < min_rx_space) && 3203 if ((pba < min_rx_space) &&
@@ -3137,7 +3209,6 @@ void e1000e_reset(struct e1000_adapter *adapter)
3137 ew32(PBA, pba); 3209 ew32(PBA, pba);
3138 } 3210 }
3139 3211
3140
3141 /* 3212 /*
3142 * flow control settings 3213 * flow control settings
3143 * 3214 *
@@ -3188,9 +3259,35 @@ void e1000e_reset(struct e1000_adapter *adapter)
3188 fc->low_water = 0x05048; 3259 fc->low_water = 0x05048;
3189 fc->pause_time = 0x0650; 3260 fc->pause_time = 0x0650;
3190 fc->refresh_time = 0x0400; 3261 fc->refresh_time = 0x0400;
3262 if (adapter->netdev->mtu > ETH_DATA_LEN) {
3263 pba = 14;
3264 ew32(PBA, pba);
3265 }
3191 break; 3266 break;
3192 } 3267 }
3193 3268
3269 /*
3270 * Disable Adaptive Interrupt Moderation if 2 full packets cannot
3271 * fit in receive buffer and early-receive not supported.
3272 */
3273 if (adapter->itr_setting & 0x3) {
3274 if (((adapter->max_frame_size * 2) > (pba << 10)) &&
3275 !(adapter->flags & FLAG_HAS_ERT)) {
3276 if (!(adapter->flags2 & FLAG2_DISABLE_AIM)) {
3277 dev_info(&adapter->pdev->dev,
3278 "Interrupt Throttle Rate turned off\n");
3279 adapter->flags2 |= FLAG2_DISABLE_AIM;
3280 ew32(ITR, 0);
3281 }
3282 } else if (adapter->flags2 & FLAG2_DISABLE_AIM) {
3283 dev_info(&adapter->pdev->dev,
3284 "Interrupt Throttle Rate turned on\n");
3285 adapter->flags2 &= ~FLAG2_DISABLE_AIM;
3286 adapter->itr = 20000;
3287 ew32(ITR, 1000000000 / (adapter->itr * 256));
3288 }
3289 }
3290
3194 /* Allow time for pending master requests to run */ 3291 /* Allow time for pending master requests to run */
3195 mac->ops.reset_hw(hw); 3292 mac->ops.reset_hw(hw);
3196 3293
@@ -3199,7 +3296,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
3199 * that the network interface is in control 3296 * that the network interface is in control
3200 */ 3297 */
3201 if (adapter->flags & FLAG_HAS_AMT) 3298 if (adapter->flags & FLAG_HAS_AMT)
3202 e1000_get_hw_control(adapter); 3299 e1000e_get_hw_control(adapter);
3203 3300
3204 ew32(WUC, 0); 3301 ew32(WUC, 0);
3205 3302
@@ -3212,6 +3309,13 @@ void e1000e_reset(struct e1000_adapter *adapter)
3212 ew32(VET, ETH_P_8021Q); 3309 ew32(VET, ETH_P_8021Q);
3213 3310
3214 e1000e_reset_adaptive(hw); 3311 e1000e_reset_adaptive(hw);
3312
3313 if (!netif_running(adapter->netdev) &&
3314 !test_bit(__E1000_TESTING, &adapter->state)) {
3315 e1000_power_down_phy(adapter);
3316 return;
3317 }
3318
3215 e1000_get_phy_info(hw); 3319 e1000_get_phy_info(hw);
3216 3320
3217 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) && 3321 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) &&
@@ -3253,6 +3357,23 @@ int e1000e_up(struct e1000_adapter *adapter)
3253 return 0; 3357 return 0;
3254} 3358}
3255 3359
3360static void e1000e_flush_descriptors(struct e1000_adapter *adapter)
3361{
3362 struct e1000_hw *hw = &adapter->hw;
3363
3364 if (!(adapter->flags2 & FLAG2_DMA_BURST))
3365 return;
3366
3367 /* flush pending descriptor writebacks to memory */
3368 ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
3369 ew32(RDTR, adapter->rx_int_delay | E1000_RDTR_FPD);
3370
3371 /* execute the writes immediately */
3372 e1e_flush();
3373}
3374
3375static void e1000e_update_stats(struct e1000_adapter *adapter);
3376
3256void e1000e_down(struct e1000_adapter *adapter) 3377void e1000e_down(struct e1000_adapter *adapter)
3257{ 3378{
3258 struct net_device *netdev = adapter->netdev; 3379 struct net_device *netdev = adapter->netdev;
@@ -3278,7 +3399,7 @@ void e1000e_down(struct e1000_adapter *adapter)
3278 ew32(TCTL, tctl); 3399 ew32(TCTL, tctl);
3279 /* flush both disables and wait for them to finish */ 3400 /* flush both disables and wait for them to finish */
3280 e1e_flush(); 3401 e1e_flush();
3281 msleep(10); 3402 usleep_range(10000, 20000);
3282 3403
3283 napi_disable(&adapter->napi); 3404 napi_disable(&adapter->napi);
3284 e1000_irq_disable(adapter); 3405 e1000_irq_disable(adapter);
@@ -3287,11 +3408,19 @@ void e1000e_down(struct e1000_adapter *adapter)
3287 del_timer_sync(&adapter->phy_info_timer); 3408 del_timer_sync(&adapter->phy_info_timer);
3288 3409
3289 netif_carrier_off(netdev); 3410 netif_carrier_off(netdev);
3411
3412 spin_lock(&adapter->stats64_lock);
3413 e1000e_update_stats(adapter);
3414 spin_unlock(&adapter->stats64_lock);
3415
3290 adapter->link_speed = 0; 3416 adapter->link_speed = 0;
3291 adapter->link_duplex = 0; 3417 adapter->link_duplex = 0;
3292 3418
3293 if (!pci_channel_offline(adapter->pdev)) 3419 if (!pci_channel_offline(adapter->pdev))
3294 e1000e_reset(adapter); 3420 e1000e_reset(adapter);
3421
3422 e1000e_flush_descriptors(adapter);
3423
3295 e1000_clean_tx_ring(adapter); 3424 e1000_clean_tx_ring(adapter);
3296 e1000_clean_rx_ring(adapter); 3425 e1000_clean_rx_ring(adapter);
3297 3426
@@ -3305,7 +3434,7 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter)
3305{ 3434{
3306 might_sleep(); 3435 might_sleep();
3307 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 3436 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
3308 msleep(1); 3437 usleep_range(1000, 2000);
3309 e1000e_down(adapter); 3438 e1000e_down(adapter);
3310 e1000e_up(adapter); 3439 e1000e_up(adapter);
3311 clear_bit(__E1000_RESETTING, &adapter->state); 3440 clear_bit(__E1000_RESETTING, &adapter->state);
@@ -3328,6 +3457,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
3328 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; 3457 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
3329 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; 3458 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
3330 3459
3460 spin_lock_init(&adapter->stats64_lock);
3461
3331 e1000e_set_interrupt_capability(adapter); 3462 e1000e_set_interrupt_capability(adapter);
3332 3463
3333 if (e1000_alloc_queues(adapter)) 3464 if (e1000_alloc_queues(adapter))
@@ -3411,22 +3542,16 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
3411 3542
3412 if (adapter->flags & FLAG_MSI_TEST_FAILED) { 3543 if (adapter->flags & FLAG_MSI_TEST_FAILED) {
3413 adapter->int_mode = E1000E_INT_MODE_LEGACY; 3544 adapter->int_mode = E1000E_INT_MODE_LEGACY;
3414 err = -EIO; 3545 e_info("MSI interrupt test failed, using legacy interrupt.\n");
3415 e_info("MSI interrupt test failed!\n"); 3546 } else
3416 } 3547 e_dbg("MSI interrupt test succeeded!\n");
3417 3548
3418 free_irq(adapter->pdev->irq, netdev); 3549 free_irq(adapter->pdev->irq, netdev);
3419 pci_disable_msi(adapter->pdev); 3550 pci_disable_msi(adapter->pdev);
3420 3551
3421 if (err == -EIO)
3422 goto msi_test_failed;
3423
3424 /* okay so the test worked, restore settings */
3425 e_dbg("MSI interrupt test succeeded!\n");
3426msi_test_failed: 3552msi_test_failed:
3427 e1000e_set_interrupt_capability(adapter); 3553 e1000e_set_interrupt_capability(adapter);
3428 e1000_request_irq(adapter); 3554 return e1000_request_irq(adapter);
3429 return err;
3430} 3555}
3431 3556
3432/** 3557/**
@@ -3458,21 +3583,6 @@ static int e1000_test_msi(struct e1000_adapter *adapter)
3458 pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd); 3583 pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd);
3459 } 3584 }
3460 3585
3461 /* success ! */
3462 if (!err)
3463 return 0;
3464
3465 /* EIO means MSI test failed */
3466 if (err != -EIO)
3467 return err;
3468
3469 /* back to INTx mode */
3470 e_warn("MSI interrupt test failed, using legacy interrupt.\n");
3471
3472 e1000_free_irq(adapter);
3473
3474 err = e1000_request_irq(adapter);
3475
3476 return err; 3586 return err;
3477} 3587}
3478 3588
@@ -3518,7 +3628,7 @@ static int e1000_open(struct net_device *netdev)
3518 * interface is now open and reset the part to a known state. 3628 * interface is now open and reset the part to a known state.
3519 */ 3629 */
3520 if (adapter->flags & FLAG_HAS_AMT) { 3630 if (adapter->flags & FLAG_HAS_AMT) {
3521 e1000_get_hw_control(adapter); 3631 e1000e_get_hw_control(adapter);
3522 e1000e_reset(adapter); 3632 e1000e_reset(adapter);
3523 } 3633 }
3524 3634
@@ -3530,7 +3640,8 @@ static int e1000_open(struct net_device *netdev)
3530 e1000_update_mng_vlan(adapter); 3640 e1000_update_mng_vlan(adapter);
3531 3641
3532 /* DMA latency requirement to workaround early-receive/jumbo issue */ 3642 /* DMA latency requirement to workaround early-receive/jumbo issue */
3533 if (adapter->flags & FLAG_HAS_ERT) 3643 if ((adapter->flags & FLAG_HAS_ERT) ||
3644 (adapter->hw.mac.type == e1000_pch2lan))
3534 pm_qos_add_request(&adapter->netdev->pm_qos_req, 3645 pm_qos_add_request(&adapter->netdev->pm_qos_req,
3535 PM_QOS_CPU_DMA_LATENCY, 3646 PM_QOS_CPU_DMA_LATENCY,
3536 PM_QOS_DEFAULT_VALUE); 3647 PM_QOS_DEFAULT_VALUE);
@@ -3581,7 +3692,7 @@ static int e1000_open(struct net_device *netdev)
3581 return 0; 3692 return 0;
3582 3693
3583err_req_irq: 3694err_req_irq:
3584 e1000_release_hw_control(adapter); 3695 e1000e_release_hw_control(adapter);
3585 e1000_power_down_phy(adapter); 3696 e1000_power_down_phy(adapter);
3586 e1000e_free_rx_resources(adapter); 3697 e1000e_free_rx_resources(adapter);
3587err_setup_rx: 3698err_setup_rx:
@@ -3626,20 +3737,20 @@ static int e1000_close(struct net_device *netdev)
3626 * kill manageability vlan ID if supported, but not if a vlan with 3737 * kill manageability vlan ID if supported, but not if a vlan with
3627 * the same ID is registered on the host OS (let 8021q kill it) 3738 * the same ID is registered on the host OS (let 8021q kill it)
3628 */ 3739 */
3629 if ((adapter->hw.mng_cookie.status & 3740 if (adapter->hw.mng_cookie.status &
3630 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) && 3741 E1000_MNG_DHCP_COOKIE_STATUS_VLAN)
3631 !(adapter->vlgrp &&
3632 vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id)))
3633 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); 3742 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
3634 3743
3635 /* 3744 /*
3636 * If AMT is enabled, let the firmware know that the network 3745 * If AMT is enabled, let the firmware know that the network
3637 * interface is now closed 3746 * interface is now closed
3638 */ 3747 */
3639 if (adapter->flags & FLAG_HAS_AMT) 3748 if ((adapter->flags & FLAG_HAS_AMT) &&
3640 e1000_release_hw_control(adapter); 3749 !test_bit(__E1000_TESTING, &adapter->state))
3750 e1000e_release_hw_control(adapter);
3641 3751
3642 if (adapter->flags & FLAG_HAS_ERT) 3752 if ((adapter->flags & FLAG_HAS_ERT) ||
3753 (adapter->hw.mac.type == e1000_pch2lan))
3643 pm_qos_remove_request(&adapter->netdev->pm_qos_req); 3754 pm_qos_remove_request(&adapter->netdev->pm_qos_req);
3644 3755
3645 pm_runtime_put_sync(&pdev->dev); 3756 pm_runtime_put_sync(&pdev->dev);
@@ -3698,6 +3809,10 @@ static void e1000e_update_phy_task(struct work_struct *work)
3698{ 3809{
3699 struct e1000_adapter *adapter = container_of(work, 3810 struct e1000_adapter *adapter = container_of(work,
3700 struct e1000_adapter, update_phy_task); 3811 struct e1000_adapter, update_phy_task);
3812
3813 if (test_bit(__E1000_DOWN, &adapter->state))
3814 return;
3815
3701 e1000_get_phy_info(&adapter->hw); 3816 e1000_get_phy_info(&adapter->hw);
3702} 3817}
3703 3818
@@ -3708,6 +3823,10 @@ static void e1000e_update_phy_task(struct work_struct *work)
3708static void e1000_update_phy_info(unsigned long data) 3823static void e1000_update_phy_info(unsigned long data)
3709{ 3824{
3710 struct e1000_adapter *adapter = (struct e1000_adapter *) data; 3825 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
3826
3827 if (test_bit(__E1000_DOWN, &adapter->state))
3828 return;
3829
3711 schedule_work(&adapter->update_phy_task); 3830 schedule_work(&adapter->update_phy_task);
3712} 3831}
3713 3832
@@ -3819,7 +3938,7 @@ release:
3819 * e1000e_update_stats - Update the board statistics counters 3938 * e1000e_update_stats - Update the board statistics counters
3820 * @adapter: board private structure 3939 * @adapter: board private structure
3821 **/ 3940 **/
3822void e1000e_update_stats(struct e1000_adapter *adapter) 3941static void e1000e_update_stats(struct e1000_adapter *adapter)
3823{ 3942{
3824 struct net_device *netdev = adapter->netdev; 3943 struct net_device *netdev = adapter->netdev;
3825 struct e1000_hw *hw = &adapter->hw; 3944 struct e1000_hw *hw = &adapter->hw;
@@ -3931,10 +4050,11 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
3931{ 4050{
3932 struct e1000_hw *hw = &adapter->hw; 4051 struct e1000_hw *hw = &adapter->hw;
3933 struct e1000_phy_regs *phy = &adapter->phy_regs; 4052 struct e1000_phy_regs *phy = &adapter->phy_regs;
3934 int ret_val;
3935 4053
3936 if ((er32(STATUS) & E1000_STATUS_LU) && 4054 if ((er32(STATUS) & E1000_STATUS_LU) &&
3937 (adapter->hw.phy.media_type == e1000_media_type_copper)) { 4055 (adapter->hw.phy.media_type == e1000_media_type_copper)) {
4056 int ret_val;
4057
3938 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr); 4058 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
3939 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr); 4059 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
3940 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise); 4060 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
@@ -3975,11 +4095,11 @@ static void e1000_print_link_info(struct e1000_adapter *adapter)
3975 adapter->netdev->name, 4095 adapter->netdev->name,
3976 adapter->link_speed, 4096 adapter->link_speed,
3977 (adapter->link_duplex == FULL_DUPLEX) ? 4097 (adapter->link_duplex == FULL_DUPLEX) ?
3978 "Full Duplex" : "Half Duplex", 4098 "Full Duplex" : "Half Duplex",
3979 ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ? 4099 ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ?
3980 "RX/TX" : 4100 "Rx/Tx" :
3981 ((ctrl & E1000_CTRL_RFCE) ? "RX" : 4101 ((ctrl & E1000_CTRL_RFCE) ? "Rx" :
3982 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" ))); 4102 ((ctrl & E1000_CTRL_TFCE) ? "Tx" : "None")));
3983} 4103}
3984 4104
3985static bool e1000e_has_link(struct e1000_adapter *adapter) 4105static bool e1000e_has_link(struct e1000_adapter *adapter)
@@ -4037,6 +4157,25 @@ static void e1000e_enable_receives(struct e1000_adapter *adapter)
4037 } 4157 }
4038} 4158}
4039 4159
4160static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter)
4161{
4162 struct e1000_hw *hw = &adapter->hw;
4163
4164 /*
4165 * With 82574 controllers, PHY needs to be checked periodically
4166 * for hung state and reset, if two calls return true
4167 */
4168 if (e1000_check_phy_82574(hw))
4169 adapter->phy_hang_count++;
4170 else
4171 adapter->phy_hang_count = 0;
4172
4173 if (adapter->phy_hang_count > 1) {
4174 adapter->phy_hang_count = 0;
4175 schedule_work(&adapter->reset_task);
4176 }
4177}
4178
4040/** 4179/**
4041 * e1000_watchdog - Timer Call-back 4180 * e1000_watchdog - Timer Call-back
4042 * @data: pointer to adapter cast into an unsigned long 4181 * @data: pointer to adapter cast into an unsigned long
@@ -4061,7 +4200,9 @@ static void e1000_watchdog_task(struct work_struct *work)
4061 struct e1000_ring *tx_ring = adapter->tx_ring; 4200 struct e1000_ring *tx_ring = adapter->tx_ring;
4062 struct e1000_hw *hw = &adapter->hw; 4201 struct e1000_hw *hw = &adapter->hw;
4063 u32 link, tctl; 4202 u32 link, tctl;
4064 int tx_pending = 0; 4203
4204 if (test_bit(__E1000_DOWN, &adapter->state))
4205 return;
4065 4206
4066 link = e1000e_has_link(adapter); 4207 link = e1000e_has_link(adapter);
4067 if ((netif_carrier_ok(netdev)) && link) { 4208 if ((netif_carrier_ok(netdev)) && link) {
@@ -4199,6 +4340,7 @@ static void e1000_watchdog_task(struct work_struct *work)
4199 } 4340 }
4200 4341
4201link_up: 4342link_up:
4343 spin_lock(&adapter->stats64_lock);
4202 e1000e_update_stats(adapter); 4344 e1000e_update_stats(adapter);
4203 4345
4204 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; 4346 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
@@ -4210,24 +4352,21 @@ link_up:
4210 adapter->gorc_old = adapter->stats.gorc; 4352 adapter->gorc_old = adapter->stats.gorc;
4211 adapter->gotc = adapter->stats.gotc - adapter->gotc_old; 4353 adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
4212 adapter->gotc_old = adapter->stats.gotc; 4354 adapter->gotc_old = adapter->stats.gotc;
4355 spin_unlock(&adapter->stats64_lock);
4213 4356
4214 e1000e_update_adaptive(&adapter->hw); 4357 e1000e_update_adaptive(&adapter->hw);
4215 4358
4216 if (!netif_carrier_ok(netdev)) { 4359 if (!netif_carrier_ok(netdev) &&
4217 tx_pending = (e1000_desc_unused(tx_ring) + 1 < 4360 (e1000_desc_unused(tx_ring) + 1 < tx_ring->count)) {
4218 tx_ring->count); 4361 /*
4219 if (tx_pending) { 4362 * We've lost link, so the controller stops DMA,
4220 /* 4363 * but we've got queued Tx work that's never going
4221 * We've lost link, so the controller stops DMA, 4364 * to get done, so reset controller to flush Tx.
4222 * but we've got queued Tx work that's never going 4365 * (Do the reset outside of interrupt context).
4223 * to get done, so reset controller to flush Tx. 4366 */
4224 * (Do the reset outside of interrupt context). 4367 schedule_work(&adapter->reset_task);
4225 */ 4368 /* return immediately since reset is imminent */
4226 adapter->tx_timeout_count++; 4369 return;
4227 schedule_work(&adapter->reset_task);
4228 /* return immediately since reset is imminent */
4229 return;
4230 }
4231 } 4370 }
4232 4371
4233 /* Simple mode for Interrupt Throttle Rate (ITR) */ 4372 /* Simple mode for Interrupt Throttle Rate (ITR) */
@@ -4252,6 +4391,9 @@ link_up:
4252 else 4391 else
4253 ew32(ICS, E1000_ICS_RXDMT0); 4392 ew32(ICS, E1000_ICS_RXDMT0);
4254 4393
4394 /* flush pending descriptors to memory before detecting Tx hang */
4395 e1000e_flush_descriptors(adapter);
4396
4255 /* Force detection of hung controller every watchdog period */ 4397 /* Force detection of hung controller every watchdog period */
4256 adapter->detect_tx_hung = 1; 4398 adapter->detect_tx_hung = 1;
4257 4399
@@ -4262,6 +4404,9 @@ link_up:
4262 if (e1000e_get_laa_state_82571(hw)) 4404 if (e1000e_get_laa_state_82571(hw))
4263 e1000e_rar_set(hw, adapter->hw.mac.addr, 0); 4405 e1000e_rar_set(hw, adapter->hw.mac.addr, 0);
4264 4406
4407 if (adapter->flags2 & FLAG2_CHECK_PHY_HANG)
4408 e1000e_check_82574_phy_workaround(adapter);
4409
4265 /* Reset the timer */ 4410 /* Reset the timer */
4266 if (!test_bit(__E1000_DOWN, &adapter->state)) 4411 if (!test_bit(__E1000_DOWN, &adapter->state))
4267 mod_timer(&adapter->watchdog_timer, 4412 mod_timer(&adapter->watchdog_timer,
@@ -4285,13 +4430,13 @@ static int e1000_tso(struct e1000_adapter *adapter,
4285 u32 cmd_length = 0; 4430 u32 cmd_length = 0;
4286 u16 ipcse = 0, tucse, mss; 4431 u16 ipcse = 0, tucse, mss;
4287 u8 ipcss, ipcso, tucss, tucso, hdr_len; 4432 u8 ipcss, ipcso, tucss, tucso, hdr_len;
4288 int err;
4289 4433
4290 if (!skb_is_gso(skb)) 4434 if (!skb_is_gso(skb))
4291 return 0; 4435 return 0;
4292 4436
4293 if (skb_header_cloned(skb)) { 4437 if (skb_header_cloned(skb)) {
4294 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 4438 int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
4439
4295 if (err) 4440 if (err)
4296 return err; 4441 return err;
4297 } 4442 }
@@ -4382,7 +4527,7 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
4382 break; 4527 break;
4383 } 4528 }
4384 4529
4385 css = skb_transport_offset(skb); 4530 css = skb_checksum_start_offset(skb);
4386 4531
4387 i = tx_ring->next_to_use; 4532 i = tx_ring->next_to_use;
4388 buffer_info = &tx_ring->buffer_info[i]; 4533 buffer_info = &tx_ring->buffer_info[i];
@@ -4433,7 +4578,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
4433 buffer_info->next_to_watch = i; 4578 buffer_info->next_to_watch = i;
4434 buffer_info->dma = dma_map_single(&pdev->dev, 4579 buffer_info->dma = dma_map_single(&pdev->dev,
4435 skb->data + offset, 4580 skb->data + offset,
4436 size, DMA_TO_DEVICE); 4581 size, DMA_TO_DEVICE);
4437 buffer_info->mapped_as_page = false; 4582 buffer_info->mapped_as_page = false;
4438 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) 4583 if (dma_mapping_error(&pdev->dev, buffer_info->dma))
4439 goto dma_error; 4584 goto dma_error;
@@ -4480,7 +4625,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
4480 } 4625 }
4481 } 4626 }
4482 4627
4483 segs = skb_shinfo(skb)->gso_segs ?: 1; 4628 segs = skb_shinfo(skb)->gso_segs ? : 1;
4484 /* multiply data chunks by size of headers */ 4629 /* multiply data chunks by size of headers */
4485 bytecount = ((segs - 1) * skb_headlen(skb)) + skb->len; 4630 bytecount = ((segs - 1) * skb_headlen(skb)) + skb->len;
4486 4631
@@ -4492,17 +4637,17 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
4492 return count; 4637 return count;
4493 4638
4494dma_error: 4639dma_error:
4495 dev_err(&pdev->dev, "TX DMA map failed\n"); 4640 dev_err(&pdev->dev, "Tx DMA map failed\n");
4496 buffer_info->dma = 0; 4641 buffer_info->dma = 0;
4497 if (count) 4642 if (count)
4498 count--; 4643 count--;
4499 4644
4500 while (count--) { 4645 while (count--) {
4501 if (i==0) 4646 if (i == 0)
4502 i += tx_ring->count; 4647 i += tx_ring->count;
4503 i--; 4648 i--;
4504 buffer_info = &tx_ring->buffer_info[i]; 4649 buffer_info = &tx_ring->buffer_info[i];
4505 e1000_put_txbuf(adapter, buffer_info);; 4650 e1000_put_txbuf(adapter, buffer_info);
4506 } 4651 }
4507 4652
4508 return 0; 4653 return 0;
@@ -4538,7 +4683,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
4538 4683
4539 i = tx_ring->next_to_use; 4684 i = tx_ring->next_to_use;
4540 4685
4541 while (count--) { 4686 do {
4542 buffer_info = &tx_ring->buffer_info[i]; 4687 buffer_info = &tx_ring->buffer_info[i];
4543 tx_desc = E1000_TX_DESC(*tx_ring, i); 4688 tx_desc = E1000_TX_DESC(*tx_ring, i);
4544 tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); 4689 tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
@@ -4549,7 +4694,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
4549 i++; 4694 i++;
4550 if (i == tx_ring->count) 4695 if (i == tx_ring->count)
4551 i = 0; 4696 i = 0;
4552 } 4697 } while (--count > 0);
4553 4698
4554 tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd); 4699 tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
4555 4700
@@ -4729,7 +4874,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
4729 if (e1000_maybe_stop_tx(netdev, count + 2)) 4874 if (e1000_maybe_stop_tx(netdev, count + 2))
4730 return NETDEV_TX_BUSY; 4875 return NETDEV_TX_BUSY;
4731 4876
4732 if (adapter->vlgrp && vlan_tx_tag_present(skb)) { 4877 if (vlan_tx_tag_present(skb)) {
4733 tx_flags |= E1000_TX_FLAGS_VLAN; 4878 tx_flags |= E1000_TX_FLAGS_VLAN;
4734 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT); 4879 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
4735 } 4880 }
@@ -4755,7 +4900,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
4755 if (skb->protocol == htons(ETH_P_IP)) 4900 if (skb->protocol == htons(ETH_P_IP))
4756 tx_flags |= E1000_TX_FLAGS_IPV4; 4901 tx_flags |= E1000_TX_FLAGS_IPV4;
4757 4902
4758 /* if count is 0 then mapping error has occured */ 4903 /* if count is 0 then mapping error has occurred */
4759 count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss); 4904 count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss);
4760 if (count) { 4905 if (count) {
4761 e1000_tx_queue(adapter, tx_flags, count); 4906 e1000_tx_queue(adapter, tx_flags, count);
@@ -4789,22 +4934,68 @@ static void e1000_reset_task(struct work_struct *work)
4789 struct e1000_adapter *adapter; 4934 struct e1000_adapter *adapter;
4790 adapter = container_of(work, struct e1000_adapter, reset_task); 4935 adapter = container_of(work, struct e1000_adapter, reset_task);
4791 4936
4792 e1000e_dump(adapter); 4937 /* don't run the task if already down */
4793 e_err("Reset adapter\n"); 4938 if (test_bit(__E1000_DOWN, &adapter->state))
4939 return;
4940
4941 if (!((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
4942 (adapter->flags & FLAG_RX_RESTART_NOW))) {
4943 e1000e_dump(adapter);
4944 e_err("Reset adapter\n");
4945 }
4794 e1000e_reinit_locked(adapter); 4946 e1000e_reinit_locked(adapter);
4795} 4947}
4796 4948
4797/** 4949/**
4798 * e1000_get_stats - Get System Network Statistics 4950 * e1000_get_stats64 - Get System Network Statistics
4799 * @netdev: network interface device structure 4951 * @netdev: network interface device structure
4952 * @stats: rtnl_link_stats64 pointer
4800 * 4953 *
4801 * Returns the address of the device statistics structure. 4954 * Returns the address of the device statistics structure.
4802 * The statistics are actually updated from the timer callback.
4803 **/ 4955 **/
4804static struct net_device_stats *e1000_get_stats(struct net_device *netdev) 4956struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
4957 struct rtnl_link_stats64 *stats)
4805{ 4958{
4806 /* only return the current stats */ 4959 struct e1000_adapter *adapter = netdev_priv(netdev);
4807 return &netdev->stats; 4960
4961 memset(stats, 0, sizeof(struct rtnl_link_stats64));
4962 spin_lock(&adapter->stats64_lock);
4963 e1000e_update_stats(adapter);
4964 /* Fill out the OS statistics structure */
4965 stats->rx_bytes = adapter->stats.gorc;
4966 stats->rx_packets = adapter->stats.gprc;
4967 stats->tx_bytes = adapter->stats.gotc;
4968 stats->tx_packets = adapter->stats.gptc;
4969 stats->multicast = adapter->stats.mprc;
4970 stats->collisions = adapter->stats.colc;
4971
4972 /* Rx Errors */
4973
4974 /*
4975 * RLEC on some newer hardware can be incorrect so build
4976 * our own version based on RUC and ROC
4977 */
4978 stats->rx_errors = adapter->stats.rxerrc +
4979 adapter->stats.crcerrs + adapter->stats.algnerrc +
4980 adapter->stats.ruc + adapter->stats.roc +
4981 adapter->stats.cexterr;
4982 stats->rx_length_errors = adapter->stats.ruc +
4983 adapter->stats.roc;
4984 stats->rx_crc_errors = adapter->stats.crcerrs;
4985 stats->rx_frame_errors = adapter->stats.algnerrc;
4986 stats->rx_missed_errors = adapter->stats.mpc;
4987
4988 /* Tx Errors */
4989 stats->tx_errors = adapter->stats.ecol +
4990 adapter->stats.latecol;
4991 stats->tx_aborted_errors = adapter->stats.ecol;
4992 stats->tx_window_errors = adapter->stats.latecol;
4993 stats->tx_carrier_errors = adapter->stats.tncrs;
4994
4995 /* Tx Dropped needs to be maintained elsewhere */
4996
4997 spin_unlock(&adapter->stats64_lock);
4998 return stats;
4808} 4999}
4809 5000
4810/** 5001/**
@@ -4851,7 +5042,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
4851 } 5042 }
4852 5043
4853 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 5044 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4854 msleep(1); 5045 usleep_range(1000, 2000);
4855 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */ 5046 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
4856 adapter->max_frame_size = max_frame; 5047 adapter->max_frame_size = max_frame;
4857 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu); 5048 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
@@ -5120,7 +5311,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
5120 * Release control of h/w to f/w. If f/w is AMT enabled, this 5311 * Release control of h/w to f/w. If f/w is AMT enabled, this
5121 * would have already happened in close and is redundant. 5312 * would have already happened in close and is redundant.
5122 */ 5313 */
5123 e1000_release_hw_control(adapter); 5314 e1000e_release_hw_control(adapter);
5124 5315
5125 pci_disable_device(pdev); 5316 pci_disable_device(pdev);
5126 5317
@@ -5170,7 +5361,7 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
5170#ifdef CONFIG_PCIEASPM 5361#ifdef CONFIG_PCIEASPM
5171static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) 5362static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
5172{ 5363{
5173 pci_disable_link_state(pdev, state); 5364 pci_disable_link_state_locked(pdev, state);
5174} 5365}
5175#else 5366#else
5176static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) 5367static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
@@ -5196,7 +5387,7 @@ static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
5196 pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16); 5387 pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
5197} 5388}
5198#endif 5389#endif
5199void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) 5390static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
5200{ 5391{
5201 dev_info(&pdev->dev, "Disabling ASPM %s %s\n", 5392 dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
5202 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "", 5393 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
@@ -5205,7 +5396,7 @@ void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
5205 __e1000e_disable_aspm(pdev, state); 5396 __e1000e_disable_aspm(pdev, state);
5206} 5397}
5207 5398
5208#ifdef CONFIG_PM_OPS 5399#ifdef CONFIG_PM
5209static bool e1000e_pm_ready(struct e1000_adapter *adapter) 5400static bool e1000e_pm_ready(struct e1000_adapter *adapter)
5210{ 5401{
5211 return !!adapter->tx_ring->buffer_info; 5402 return !!adapter->tx_ring->buffer_info;
@@ -5216,13 +5407,19 @@ static int __e1000_resume(struct pci_dev *pdev)
5216 struct net_device *netdev = pci_get_drvdata(pdev); 5407 struct net_device *netdev = pci_get_drvdata(pdev);
5217 struct e1000_adapter *adapter = netdev_priv(netdev); 5408 struct e1000_adapter *adapter = netdev_priv(netdev);
5218 struct e1000_hw *hw = &adapter->hw; 5409 struct e1000_hw *hw = &adapter->hw;
5410 u16 aspm_disable_flag = 0;
5219 u32 err; 5411 u32 err;
5220 5412
5413 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
5414 aspm_disable_flag = PCIE_LINK_STATE_L0S;
5415 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
5416 aspm_disable_flag |= PCIE_LINK_STATE_L1;
5417 if (aspm_disable_flag)
5418 e1000e_disable_aspm(pdev, aspm_disable_flag);
5419
5221 pci_set_power_state(pdev, PCI_D0); 5420 pci_set_power_state(pdev, PCI_D0);
5222 pci_restore_state(pdev); 5421 pci_restore_state(pdev);
5223 pci_save_state(pdev); 5422 pci_save_state(pdev);
5224 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
5225 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
5226 5423
5227 e1000e_set_interrupt_capability(adapter); 5424 e1000e_set_interrupt_capability(adapter);
5228 if (netif_running(netdev)) { 5425 if (netif_running(netdev)) {
@@ -5277,7 +5474,7 @@ static int __e1000_resume(struct pci_dev *pdev)
5277 * under the control of the driver. 5474 * under the control of the driver.
5278 */ 5475 */
5279 if (!(adapter->flags & FLAG_HAS_AMT)) 5476 if (!(adapter->flags & FLAG_HAS_AMT))
5280 e1000_get_hw_control(adapter); 5477 e1000e_get_hw_control(adapter);
5281 5478
5282 return 0; 5479 return 0;
5283} 5480}
@@ -5356,7 +5553,7 @@ static int e1000_runtime_resume(struct device *dev)
5356 return __e1000_resume(pdev); 5553 return __e1000_resume(pdev);
5357} 5554}
5358#endif /* CONFIG_PM_RUNTIME */ 5555#endif /* CONFIG_PM_RUNTIME */
5359#endif /* CONFIG_PM_OPS */ 5556#endif /* CONFIG_PM */
5360 5557
5361static void e1000_shutdown(struct pci_dev *pdev) 5558static void e1000_shutdown(struct pci_dev *pdev)
5362{ 5559{
@@ -5369,6 +5566,37 @@ static void e1000_shutdown(struct pci_dev *pdev)
5369} 5566}
5370 5567
5371#ifdef CONFIG_NET_POLL_CONTROLLER 5568#ifdef CONFIG_NET_POLL_CONTROLLER
5569
5570static irqreturn_t e1000_intr_msix(int irq, void *data)
5571{
5572 struct net_device *netdev = data;
5573 struct e1000_adapter *adapter = netdev_priv(netdev);
5574
5575 if (adapter->msix_entries) {
5576 int vector, msix_irq;
5577
5578 vector = 0;
5579 msix_irq = adapter->msix_entries[vector].vector;
5580 disable_irq(msix_irq);
5581 e1000_intr_msix_rx(msix_irq, netdev);
5582 enable_irq(msix_irq);
5583
5584 vector++;
5585 msix_irq = adapter->msix_entries[vector].vector;
5586 disable_irq(msix_irq);
5587 e1000_intr_msix_tx(msix_irq, netdev);
5588 enable_irq(msix_irq);
5589
5590 vector++;
5591 msix_irq = adapter->msix_entries[vector].vector;
5592 disable_irq(msix_irq);
5593 e1000_msix_other(msix_irq, netdev);
5594 enable_irq(msix_irq);
5595 }
5596
5597 return IRQ_HANDLED;
5598}
5599
5372/* 5600/*
5373 * Polling 'interrupt' - used by things like netconsole to send skbs 5601 * Polling 'interrupt' - used by things like netconsole to send skbs
5374 * without having to re-enable interrupts. It's not called while 5602 * without having to re-enable interrupts. It's not called while
@@ -5378,10 +5606,21 @@ static void e1000_netpoll(struct net_device *netdev)
5378{ 5606{
5379 struct e1000_adapter *adapter = netdev_priv(netdev); 5607 struct e1000_adapter *adapter = netdev_priv(netdev);
5380 5608
5381 disable_irq(adapter->pdev->irq); 5609 switch (adapter->int_mode) {
5382 e1000_intr(adapter->pdev->irq, netdev); 5610 case E1000E_INT_MODE_MSIX:
5383 5611 e1000_intr_msix(adapter->pdev->irq, netdev);
5384 enable_irq(adapter->pdev->irq); 5612 break;
5613 case E1000E_INT_MODE_MSI:
5614 disable_irq(adapter->pdev->irq);
5615 e1000_intr_msi(adapter->pdev->irq, netdev);
5616 enable_irq(adapter->pdev->irq);
5617 break;
5618 default: /* E1000E_INT_MODE_LEGACY */
5619 disable_irq(adapter->pdev->irq);
5620 e1000_intr(adapter->pdev->irq, netdev);
5621 enable_irq(adapter->pdev->irq);
5622 break;
5623 }
5385} 5624}
5386#endif 5625#endif
5387 5626
@@ -5424,11 +5663,17 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
5424 struct net_device *netdev = pci_get_drvdata(pdev); 5663 struct net_device *netdev = pci_get_drvdata(pdev);
5425 struct e1000_adapter *adapter = netdev_priv(netdev); 5664 struct e1000_adapter *adapter = netdev_priv(netdev);
5426 struct e1000_hw *hw = &adapter->hw; 5665 struct e1000_hw *hw = &adapter->hw;
5666 u16 aspm_disable_flag = 0;
5427 int err; 5667 int err;
5428 pci_ers_result_t result; 5668 pci_ers_result_t result;
5429 5669
5670 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
5671 aspm_disable_flag = PCIE_LINK_STATE_L0S;
5430 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1) 5672 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
5431 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1); 5673 aspm_disable_flag |= PCIE_LINK_STATE_L1;
5674 if (aspm_disable_flag)
5675 e1000e_disable_aspm(pdev, aspm_disable_flag);
5676
5432 err = pci_enable_device_mem(pdev); 5677 err = pci_enable_device_mem(pdev);
5433 if (err) { 5678 if (err) {
5434 dev_err(&pdev->dev, 5679 dev_err(&pdev->dev,
@@ -5483,7 +5728,7 @@ static void e1000_io_resume(struct pci_dev *pdev)
5483 * under the control of the driver. 5728 * under the control of the driver.
5484 */ 5729 */
5485 if (!(adapter->flags & FLAG_HAS_AMT)) 5730 if (!(adapter->flags & FLAG_HAS_AMT))
5486 e1000_get_hw_control(adapter); 5731 e1000e_get_hw_control(adapter);
5487 5732
5488} 5733}
5489 5734
@@ -5491,10 +5736,11 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
5491{ 5736{
5492 struct e1000_hw *hw = &adapter->hw; 5737 struct e1000_hw *hw = &adapter->hw;
5493 struct net_device *netdev = adapter->netdev; 5738 struct net_device *netdev = adapter->netdev;
5494 u32 pba_num; 5739 u32 ret_val;
5740 u8 pba_str[E1000_PBANUM_LENGTH];
5495 5741
5496 /* print bus type/speed/width info */ 5742 /* print bus type/speed/width info */
5497 e_info("(PCI Express:2.5GB/s:%s) %pM\n", 5743 e_info("(PCI Express:2.5GT/s:%s) %pM\n",
5498 /* bus width */ 5744 /* bus width */
5499 ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" : 5745 ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
5500 "Width x1"), 5746 "Width x1"),
@@ -5502,9 +5748,12 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
5502 netdev->dev_addr); 5748 netdev->dev_addr);
5503 e_info("Intel(R) PRO/%s Network Connection\n", 5749 e_info("Intel(R) PRO/%s Network Connection\n",
5504 (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000"); 5750 (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000");
5505 e1000e_read_pba_num(hw, &pba_num); 5751 ret_val = e1000_read_pba_string_generic(hw, pba_str,
5506 e_info("MAC: %d, PHY: %d, PBA No: %06x-%03x\n", 5752 E1000_PBANUM_LENGTH);
5507 hw->mac.type, hw->phy.type, (pba_num >> 8), (pba_num & 0xff)); 5753 if (ret_val)
5754 strncpy((char *)pba_str, "Unknown", sizeof(pba_str) - 1);
5755 e_info("MAC: %d, PHY: %d, PBA No: %s\n",
5756 hw->mac.type, hw->phy.type, pba_str);
5508} 5757}
5509 5758
5510static void e1000_eeprom_checks(struct e1000_adapter *adapter) 5759static void e1000_eeprom_checks(struct e1000_adapter *adapter)
@@ -5528,7 +5777,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
5528 .ndo_open = e1000_open, 5777 .ndo_open = e1000_open,
5529 .ndo_stop = e1000_close, 5778 .ndo_stop = e1000_close,
5530 .ndo_start_xmit = e1000_xmit_frame, 5779 .ndo_start_xmit = e1000_xmit_frame,
5531 .ndo_get_stats = e1000_get_stats, 5780 .ndo_get_stats64 = e1000e_get_stats64,
5532 .ndo_set_multicast_list = e1000_set_multi, 5781 .ndo_set_multicast_list = e1000_set_multi,
5533 .ndo_set_mac_address = e1000_set_mac, 5782 .ndo_set_mac_address = e1000_set_mac,
5534 .ndo_change_mtu = e1000_change_mtu, 5783 .ndo_change_mtu = e1000_change_mtu,
@@ -5536,7 +5785,6 @@ static const struct net_device_ops e1000e_netdev_ops = {
5536 .ndo_tx_timeout = e1000_tx_timeout, 5785 .ndo_tx_timeout = e1000_tx_timeout,
5537 .ndo_validate_addr = eth_validate_addr, 5786 .ndo_validate_addr = eth_validate_addr,
5538 5787
5539 .ndo_vlan_rx_register = e1000_vlan_rx_register,
5540 .ndo_vlan_rx_add_vid = e1000_vlan_rx_add_vid, 5788 .ndo_vlan_rx_add_vid = e1000_vlan_rx_add_vid,
5541 .ndo_vlan_rx_kill_vid = e1000_vlan_rx_kill_vid, 5789 .ndo_vlan_rx_kill_vid = e1000_vlan_rx_kill_vid,
5542#ifdef CONFIG_NET_POLL_CONTROLLER 5790#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -5566,12 +5814,17 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5566 resource_size_t flash_start, flash_len; 5814 resource_size_t flash_start, flash_len;
5567 5815
5568 static int cards_found; 5816 static int cards_found;
5817 u16 aspm_disable_flag = 0;
5569 int i, err, pci_using_dac; 5818 int i, err, pci_using_dac;
5570 u16 eeprom_data = 0; 5819 u16 eeprom_data = 0;
5571 u16 eeprom_apme_mask = E1000_EEPROM_APME; 5820 u16 eeprom_apme_mask = E1000_EEPROM_APME;
5572 5821
5822 if (ei->flags2 & FLAG2_DISABLE_ASPM_L0S)
5823 aspm_disable_flag = PCIE_LINK_STATE_L0S;
5573 if (ei->flags2 & FLAG2_DISABLE_ASPM_L1) 5824 if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
5574 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1); 5825 aspm_disable_flag |= PCIE_LINK_STATE_L1;
5826 if (aspm_disable_flag)
5827 e1000e_disable_aspm(pdev, aspm_disable_flag);
5575 5828
5576 err = pci_enable_device_mem(pdev); 5829 err = pci_enable_device_mem(pdev);
5577 if (err) 5830 if (err)
@@ -5712,8 +5965,10 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5712 netdev->vlan_features |= NETIF_F_HW_CSUM; 5965 netdev->vlan_features |= NETIF_F_HW_CSUM;
5713 netdev->vlan_features |= NETIF_F_SG; 5966 netdev->vlan_features |= NETIF_F_SG;
5714 5967
5715 if (pci_using_dac) 5968 if (pci_using_dac) {
5716 netdev->features |= NETIF_F_HIGHDMA; 5969 netdev->features |= NETIF_F_HIGHDMA;
5970 netdev->vlan_features |= NETIF_F_HIGHDMA;
5971 }
5717 5972
5718 if (e1000e_enable_mng_pass_thru(&adapter->hw)) 5973 if (e1000e_enable_mng_pass_thru(&adapter->hw))
5719 adapter->flags |= FLAG_MNG_PT_ENABLED; 5974 adapter->flags |= FLAG_MNG_PT_ENABLED;
@@ -5754,11 +6009,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5754 } 6009 }
5755 6010
5756 init_timer(&adapter->watchdog_timer); 6011 init_timer(&adapter->watchdog_timer);
5757 adapter->watchdog_timer.function = &e1000_watchdog; 6012 adapter->watchdog_timer.function = e1000_watchdog;
5758 adapter->watchdog_timer.data = (unsigned long) adapter; 6013 adapter->watchdog_timer.data = (unsigned long) adapter;
5759 6014
5760 init_timer(&adapter->phy_info_timer); 6015 init_timer(&adapter->phy_info_timer);
5761 adapter->phy_info_timer.function = &e1000_update_phy_info; 6016 adapter->phy_info_timer.function = e1000_update_phy_info;
5762 adapter->phy_info_timer.data = (unsigned long) adapter; 6017 adapter->phy_info_timer.data = (unsigned long) adapter;
5763 6018
5764 INIT_WORK(&adapter->reset_task, e1000_reset_task); 6019 INIT_WORK(&adapter->reset_task, e1000_reset_task);
@@ -5786,7 +6041,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5786 /* APME bit in EEPROM is mapped to WUC.APME */ 6041 /* APME bit in EEPROM is mapped to WUC.APME */
5787 eeprom_data = er32(WUC); 6042 eeprom_data = er32(WUC);
5788 eeprom_apme_mask = E1000_WUC_APME; 6043 eeprom_apme_mask = E1000_WUC_APME;
5789 if (eeprom_data & E1000_WUC_PHY_WAKE) 6044 if ((hw->mac.type > e1000_ich10lan) &&
6045 (eeprom_data & E1000_WUC_PHY_WAKE))
5790 adapter->flags2 |= FLAG2_HAS_PHY_WAKEUP; 6046 adapter->flags2 |= FLAG2_HAS_PHY_WAKEUP;
5791 } else if (adapter->flags & FLAG_APME_IN_CTRL3) { 6047 } else if (adapter->flags & FLAG_APME_IN_CTRL3) {
5792 if (adapter->flags & FLAG_APME_CHECK_PORT_B && 6048 if (adapter->flags & FLAG_APME_CHECK_PORT_B &&
@@ -5826,9 +6082,9 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5826 * under the control of the driver. 6082 * under the control of the driver.
5827 */ 6083 */
5828 if (!(adapter->flags & FLAG_HAS_AMT)) 6084 if (!(adapter->flags & FLAG_HAS_AMT))
5829 e1000_get_hw_control(adapter); 6085 e1000e_get_hw_control(adapter);
5830 6086
5831 strcpy(netdev->name, "eth%d"); 6087 strncpy(netdev->name, "eth%d", sizeof(netdev->name) - 1);
5832 err = register_netdev(netdev); 6088 err = register_netdev(netdev);
5833 if (err) 6089 if (err)
5834 goto err_register; 6090 goto err_register;
@@ -5845,12 +6101,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5845 6101
5846err_register: 6102err_register:
5847 if (!(adapter->flags & FLAG_HAS_AMT)) 6103 if (!(adapter->flags & FLAG_HAS_AMT))
5848 e1000_release_hw_control(adapter); 6104 e1000e_release_hw_control(adapter);
5849err_eeprom: 6105err_eeprom:
5850 if (!e1000_check_reset_block(&adapter->hw)) 6106 if (!e1000_check_reset_block(&adapter->hw))
5851 e1000_phy_hw_reset(&adapter->hw); 6107 e1000_phy_hw_reset(&adapter->hw);
5852err_hw_init: 6108err_hw_init:
5853
5854 kfree(adapter->tx_ring); 6109 kfree(adapter->tx_ring);
5855 kfree(adapter->rx_ring); 6110 kfree(adapter->rx_ring);
5856err_sw_init: 6111err_sw_init:
@@ -5886,8 +6141,8 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5886 bool down = test_bit(__E1000_DOWN, &adapter->state); 6141 bool down = test_bit(__E1000_DOWN, &adapter->state);
5887 6142
5888 /* 6143 /*
5889 * flush_scheduled work may reschedule our watchdog task, so 6144 * The timers may be rescheduled, so explicitly disable them
5890 * explicitly disable watchdog tasks from being rescheduled 6145 * from being rescheduled.
5891 */ 6146 */
5892 if (!down) 6147 if (!down)
5893 set_bit(__E1000_DOWN, &adapter->state); 6148 set_bit(__E1000_DOWN, &adapter->state);
@@ -5899,7 +6154,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5899 cancel_work_sync(&adapter->downshift_task); 6154 cancel_work_sync(&adapter->downshift_task);
5900 cancel_work_sync(&adapter->update_phy_task); 6155 cancel_work_sync(&adapter->update_phy_task);
5901 cancel_work_sync(&adapter->print_hang_task); 6156 cancel_work_sync(&adapter->print_hang_task);
5902 flush_scheduled_work();
5903 6157
5904 if (!(netdev->flags & IFF_UP)) 6158 if (!(netdev->flags & IFF_UP))
5905 e1000_power_down_phy(adapter); 6159 e1000_power_down_phy(adapter);
@@ -5916,7 +6170,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5916 * Release control of h/w to f/w. If f/w is AMT enabled, this 6170 * Release control of h/w to f/w. If f/w is AMT enabled, this
5917 * would have already happened in close and is redundant. 6171 * would have already happened in close and is redundant.
5918 */ 6172 */
5919 e1000_release_hw_control(adapter); 6173 e1000e_release_hw_control(adapter);
5920 6174
5921 e1000e_reset_interrupt_capability(adapter); 6175 e1000e_reset_interrupt_capability(adapter);
5922 kfree(adapter->tx_ring); 6176 kfree(adapter->tx_ring);
@@ -6015,7 +6269,7 @@ static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
6015}; 6269};
6016MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); 6270MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
6017 6271
6018#ifdef CONFIG_PM_OPS 6272#ifdef CONFIG_PM
6019static const struct dev_pm_ops e1000_pm_ops = { 6273static const struct dev_pm_ops e1000_pm_ops = {
6020 SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume) 6274 SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume)
6021 SET_RUNTIME_PM_OPS(e1000_runtime_suspend, 6275 SET_RUNTIME_PM_OPS(e1000_runtime_suspend,
@@ -6029,7 +6283,7 @@ static struct pci_driver e1000_driver = {
6029 .id_table = e1000_pci_tbl, 6283 .id_table = e1000_pci_tbl,
6030 .probe = e1000_probe, 6284 .probe = e1000_probe,
6031 .remove = __devexit_p(e1000_remove), 6285 .remove = __devexit_p(e1000_remove),
6032#ifdef CONFIG_PM_OPS 6286#ifdef CONFIG_PM
6033 .driver.pm = &e1000_pm_ops, 6287 .driver.pm = &e1000_pm_ops,
6034#endif 6288#endif
6035 .shutdown = e1000_shutdown, 6289 .shutdown = e1000_shutdown,
@@ -6047,7 +6301,7 @@ static int __init e1000_init_module(void)
6047 int ret; 6301 int ret;
6048 pr_info("Intel(R) PRO/1000 Network Driver - %s\n", 6302 pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
6049 e1000e_driver_version); 6303 e1000e_driver_version);
6050 pr_info("Copyright (c) 1999 - 2010 Intel Corporation.\n"); 6304 pr_info("Copyright(c) 1999 - 2011 Intel Corporation.\n");
6051 ret = pci_register_driver(&e1000_driver); 6305 ret = pci_register_driver(&e1000_driver);
6052 6306
6053 return ret; 6307 return ret;