lantiq: Tune the XWAY subtarget cflags
[openwrt/staging/yousong.git] / package / system / ep80579-drivers / patches / 001-igbe_update.patch
1 --- a/Embedded/src/GbE/gcu.h
2 +++ b/Embedded/src/GbE/gcu.h
3 @@ -2,7 +2,7 @@
4
5 GPL LICENSE SUMMARY
6
7 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
8 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of version 2 of the GNU General Public License as
12 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
13 Contact Information:
14 Intel Corporation
15
16 - version: Embedded.L.1.0.34
17 + version: Embedded.Release.Patch.L.1.0.7-5
18
19 Contact Information:
20
21 --- a/Embedded/src/GbE/gcu_if.c
22 +++ b/Embedded/src/GbE/gcu_if.c
23 @@ -2,7 +2,7 @@
24
25 GPL LICENSE SUMMARY
26
27 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
28 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
29
30 This program is free software; you can redistribute it and/or modify
31 it under the terms of version 2 of the GNU General Public License as
32 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
33 Contact Information:
34 Intel Corporation
35
36 - version: Embedded.L.1.0.34
37 + version: Embedded.Release.Patch.L.1.0.7-5
38
39 Contact Information:
40
41 @@ -330,10 +330,17 @@ gcu_write_verify(uint32_t phy_num, uint3
42 */
43 void gcu_iegbe_resume(struct pci_dev *pdev)
44 {
45 +#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
46 + ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
47 + struct net_device *netdev = pci_get_drvdata(pdev);
48 + struct gcu_adapter *adapter = netdev_priv(netdev);
49 +#endif
50 +
51 GCU_DBG("%s\n", __func__);
52
53 pci_restore_state(pdev);
54 - pci_enable_device(pdev);
55 + if(!pci_enable_device(pdev))
56 + GCU_DBG("pci_enable_device failed!\n",);
57
58 return;
59 }
60 @@ -348,6 +355,12 @@ EXPORT_SYMBOL(gcu_iegbe_resume);
61 */
62 int gcu_iegbe_suspend(struct pci_dev *pdev, uint32_t state)
63 {
64 +#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
65 + ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
66 + struct net_device *netdev = pci_get_drvdata(pdev);
67 + struct gcu_adapter *adapter = netdev_priv(netdev);
68 +#endif
69 +
70 GCU_DBG("%s\n", __func__);
71
72 pci_save_state(pdev);
73 --- a/Embedded/src/GbE/gcu_if.h
74 +++ b/Embedded/src/GbE/gcu_if.h
75 @@ -2,7 +2,7 @@
76
77 GPL LICENSE SUMMARY
78
79 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
80 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
81
82 This program is free software; you can redistribute it and/or modify
83 it under the terms of version 2 of the GNU General Public License as
84 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
85 Contact Information:
86 Intel Corporation
87
88 - version: Embedded.L.1.0.34
89 + version: Embedded.Release.Patch.L.1.0.7-5
90
91 Contact Information:
92
93 --- a/Embedded/src/GbE/gcu_main.c
94 +++ b/Embedded/src/GbE/gcu_main.c
95 @@ -2,7 +2,7 @@
96
97 GPL LICENSE SUMMARY
98
99 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
100 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
101
102 This program is free software; you can redistribute it and/or modify
103 it under the terms of version 2 of the GNU General Public License as
104 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
105 Contact Information:
106 Intel Corporation
107
108 - version: Embedded.L.1.0.34
109 + version: Embedded.Release.Patch.L.1.0.7-5
110
111 Contact Information:
112
113 @@ -94,6 +94,7 @@ static struct pci_driver gcu_driver = {
114
115 static struct gcu_adapter *global_adapter = 0;
116 static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
117 +static unsigned long g_intflags = 0;
118
119 MODULE_AUTHOR("Intel(R) Corporation");
120 MODULE_DESCRIPTION("Global Configuration Unit Driver");
121 @@ -124,7 +125,7 @@ gcu_init_module(void)
122
123 printk(KERN_INFO "%s\n", gcu_copyright);
124
125 - ret = pci_module_init(&gcu_driver);
126 + ret = pci_register_driver(&gcu_driver);
127 if(ret >= 0) {
128 register_reboot_notifier(&gcu_notifier_reboot);
129 }
130 @@ -199,8 +200,6 @@ gcu_probe(struct pci_dev *pdev,
131 return -ENOMEM;
132 }
133
134 - SET_MODULE_OWNER(adapter);
135 -
136 pci_set_drvdata(pdev, adapter);
137
138 adapter->pdev = pdev;
139 @@ -238,7 +237,6 @@ gcu_probe(struct pci_dev *pdev,
140 return 0;
141 }
142
143 -
144 /**
145 * gcu_probe_err - gcu_probe error handler
146 * @err: gcu_err_type
147 @@ -295,7 +293,7 @@ gcu_notify_reboot(struct notifier_block
148 case SYS_DOWN:
149 case SYS_HALT:
150 case SYS_POWER_OFF:
151 - while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
152 + while((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
153 if(pci_dev_driver(pdev) == &gcu_driver){
154 gcu_suspend(pdev, 0x3);
155 }
156 @@ -318,6 +316,11 @@ static int
157 gcu_suspend(struct pci_dev *pdev, uint32_t state)
158 {
159 /*struct gcu_adapter *adapter = pci_get_drvdata(pdev); */
160 +#if ( ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6) ) && \
161 + ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) ) )
162 + struct net_device *netdev = pci_get_drvdata(pdev);
163 + struct gcu_adapter *adapter = netdev_priv(netdev);
164 +#endif
165
166 GCU_DBG("%s\n", __func__);
167
168 @@ -338,7 +341,6 @@ gcu_suspend(struct pci_dev *pdev, uint32
169 return state;
170 }
171
172 -
173 /**
174 * alloc_gcu_adapter
175 *
176 @@ -412,7 +414,7 @@ gcu_get_adapter(void)
177 return NULL;
178 }
179
180 - spin_lock(&global_adapter_spinlock);
181 + spin_lock_irqsave(&global_adapter_spinlock, g_intflags);
182
183 return global_adapter;
184 }
185 @@ -437,7 +439,7 @@ gcu_release_adapter(const struct gcu_ada
186 *adapter = 0;
187 }
188
189 - spin_unlock(&global_adapter_spinlock);
190 + spin_unlock_irqrestore(&global_adapter_spinlock, g_intflags);
191
192 return;
193 }
194 --- a/Embedded/src/GbE/gcu_reg.h
195 +++ b/Embedded/src/GbE/gcu_reg.h
196 @@ -2,7 +2,7 @@
197
198 GPL LICENSE SUMMARY
199
200 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
201 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
202
203 This program is free software; you can redistribute it and/or modify
204 it under the terms of version 2 of the GNU General Public License as
205 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
206 Contact Information:
207 Intel Corporation
208
209 - version: Embedded.L.1.0.34
210 + version: Embedded.Release.Patch.L.1.0.7-5
211
212 Contact Information:
213
214 --- a/Embedded/src/GbE/iegbe.7
215 +++ b/Embedded/src/GbE/iegbe.7
216 @@ -1,7 +1,7 @@
217
218 .\" GPL LICENSE SUMMARY
219 .\"
220 -.\" Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
221 +.\" Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
222 .\"
223 .\" This program is free software; you can redistribute it and/or modify
224 .\" it under the terms of version 2 of the GNU General Public License as
225 @@ -21,7 +21,7 @@
226 .\" Contact Information:
227 .\" Intel Corporation
228 .\"
229 -.\" version: Embedded.L.1.0.34
230 +.\" version: Embedded.Release.Patch.L.1.0.7-5
231
232 .\" LICENSE
233 .\"
234 --- a/Embedded/src/GbE/iegbe_ethtool.c
235 +++ b/Embedded/src/GbE/iegbe_ethtool.c
236 @@ -2,7 +2,7 @@
237
238 GPL LICENSE SUMMARY
239
240 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
241 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
242
243 This program is free software; you can redistribute it and/or modify
244 it under the terms of version 2 of the GNU General Public License as
245 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
246 Contact Information:
247 Intel Corporation
248
249 - version: Embedded.L.1.0.34
250 + version: Embedded.Release.Patch.L.1.0.7-5
251
252 Contact Information:
253
254 @@ -132,22 +132,6 @@ static const struct iegbe_stats iegbe_gs
255 { "cpp_master", E1000_STAT(icr_cpp_master) },
256 { "stat", E1000_STAT(icr_stat) },
257 #endif
258 -#ifdef IEGBE_GBE_WORKAROUND
259 - { "txqec", E1000_STAT(stats.txqec) },
260 - { "tx_next_to_clean", E1000_STAT(stats.tx_next_to_clean) },
261 - { "tx_next_to_use", E1000_STAT(stats.tx_next_to_use) },
262 - { "num_tx_queues", E1000_STAT(stats.num_tx_queues) },
263 -
264 - { "num_rx_buf_alloc", E1000_STAT(stats.num_rx_buf_alloc) },
265 - { "rx_next_to_clean", E1000_STAT(stats.rx_next_to_clean) },
266 - { "rx_next_to_use", E1000_STAT(stats.rx_next_to_use) },
267 - { "cc_gt_num_rx", E1000_STAT(stats.cc_gt_num_rx) },
268 - { "tx_hnet", E1000_STAT(stats.tx_hnet) },
269 - { "tx_hnentu", E1000_STAT(stats.tx_hnentu) },
270 - { "RUC", E1000_STAT(stats.ruc) },
271 - { "RFC", E1000_STAT(stats.rfc) },
272 -
273 -#endif
274 };
275 #define E1000_STATS_LEN \
276 sizeof(iegbe_gstrings_stats) / sizeof(struct iegbe_stats)
277 @@ -158,7 +142,7 @@ static const char iegbe_gstrings_test[][
278 "Interrupt test (offline)", "Loopback test (offline)",
279 "Link test (on/offline)"
280 };
281 -#define E1000_TEST_LEN (sizeof(iegbe_gstrings_test) / (ETH_GSTRING_LEN))
282 +#define E1000_TEST_LEN (sizeof(iegbe_gstrings_test) / ETH_GSTRING_LEN)
283 #endif /* ETHTOOL_TEST */
284
285 #define E1000_REGS_LEN 0x20
286 @@ -176,9 +160,7 @@ iegbe_get_settings(struct net_device *ne
287 SUPPORTED_10baseT_Full |
288 SUPPORTED_100baseT_Half |
289 SUPPORTED_100baseT_Full |
290 -#ifndef IEGBE_10_100_ONLY
291 SUPPORTED_1000baseT_Full|
292 -#endif
293 SUPPORTED_Autoneg |
294 SUPPORTED_TP);
295
296 @@ -259,21 +241,13 @@ iegbe_set_settings(struct net_device *ne
297 ADVERTISED_10baseT_Full |
298 ADVERTISED_100baseT_Half |
299 ADVERTISED_100baseT_Full |
300 -#ifndef IEGBE_10_100_ONLY
301 ADVERTISED_1000baseT_Full|
302 -#endif
303 -
304 ADVERTISED_Autoneg |
305 ADVERTISED_TP;
306 ecmd->advertising = hw->autoneg_advertised;
307 }
308 - } else {
309 - uint16_t duplex;
310 -
311 - // ethtool uses DUPLEX_FULL/DUPLEX_HALF
312 - // the driver needs FULL_DUPLEX/HALF_DUPLEX
313 - duplex = (ecmd->duplex == DUPLEX_FULL) ? FULL_DUPLEX : HALF_DUPLEX;
314 - if(iegbe_set_spd_dplx(adapter, ecmd->speed + duplex))
315 + } else
316 + if(iegbe_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)){
317 return -EINVAL;
318 }
319 /* reset the link */
320 @@ -728,8 +702,8 @@ iegbe_set_ringparam(struct net_device *n
321 struct iegbe_rx_ring *rxdr, *rx_old, *rx_new;
322 int i, err, tx_ring_size, rx_ring_size;
323
324 - tx_ring_size = sizeof(struct iegbe_tx_ring) * adapter->num_queues;
325 - rx_ring_size = sizeof(struct iegbe_rx_ring) * adapter->num_queues;
326 + tx_ring_size = sizeof(struct iegbe_tx_ring) * adapter->num_tx_queues;
327 + rx_ring_size = sizeof(struct iegbe_rx_ring) * adapter->num_rx_queues;
328
329 if (netif_running(adapter->netdev)){
330 iegbe_down(adapter);
331 @@ -768,10 +742,10 @@ iegbe_set_ringparam(struct net_device *n
332 E1000_MAX_TXD : E1000_MAX_82544_TXD));
333 E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
334
335 - for (i = 0; i < adapter->num_queues; i++) {
336 - txdr[i].count = txdr->count;
337 - rxdr[i].count = rxdr->count;
338 - }
339 + for (i = 0; i < adapter->num_tx_queues; i++)
340 + txdr[i].count = txdr->count;
341 + for (i = 0; i < adapter->num_rx_queues; i++)
342 + rxdr[i].count = rxdr->count;
343
344 if(netif_running(adapter->netdev)) {
345 /* Try to get new resources before deleting old */
346 @@ -950,8 +924,7 @@ iegbe_eeprom_test(struct iegbe_adapter *
347
348 static irqreturn_t
349 iegbe_test_intr(int irq,
350 - void *data,
351 - struct pt_regs *regs)
352 + void *data)
353 {
354 struct net_device *netdev = (struct net_device *) data;
355 struct iegbe_adapter *adapter = netdev_priv(netdev);
356 @@ -973,7 +946,7 @@ iegbe_intr_test(struct iegbe_adapter *ad
357 /* Hook up test interrupt handler just for this test */
358 if(!request_irq(irq, &iegbe_test_intr, 0, netdev->name, netdev)) {
359 shared_int = FALSE;
360 - } else if(request_irq(irq, &iegbe_test_intr, SA_SHIRQ,
361 + } else if(request_irq(irq, &iegbe_test_intr, IRQF_SHARED,
362 netdev->name, netdev)){
363 *data = 1;
364 return -1;
365 @@ -1393,7 +1366,7 @@ iegbe_set_phy_loopback(struct iegbe_adap
366 * attempt this 10 times.
367 */
368 while(iegbe_nonintegrated_phy_loopback(adapter) &&
369 - count++ < 0xa) { };
370 + count++ < 0xa);
371 if(count < 0xb) {
372 return 0;
373 }
374 --- a/Embedded/src/GbE/iegbe.h
375 +++ b/Embedded/src/GbE/iegbe.h
376 @@ -1,7 +1,7 @@
377 /*******************************************************************************
378 GPL LICENSE SUMMARY
379
380 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
381 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
382
383 This program is free software; you can redistribute it and/or modify
384 it under the terms of version 2 of the GNU General Public License as
385 @@ -21,7 +21,7 @@ GPL LICENSE SUMMARY
386 Contact Information:
387 Intel Corporation
388
389 - version: Embedded.L.1.0.34
390 + version: Embedded.Release.Patch.L.1.0.7-5
391
392 Contact Information:
393
394 @@ -127,9 +127,12 @@ struct iegbe_adapter;
395 #define E1000_MIN_RXD 80
396 #define E1000_MAX_82544_RXD 4096
397
398 +#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
399 /* Supported Rx Buffer Sizes */
400 #define E1000_RXBUFFER_128 128 /* Used for packet split */
401 #define E1000_RXBUFFER_256 256 /* Used for packet split */
402 +#define E1000_RXBUFFER_512 512
403 +#define E1000_RXBUFFER_1024 1024
404 #define E1000_RXBUFFER_2048 2048
405 #define E1000_RXBUFFER_4096 4096
406 #define E1000_RXBUFFER_8192 8192
407 @@ -164,11 +167,9 @@ struct iegbe_adapter;
408 #define E1000_MASTER_SLAVE iegbe_ms_hw_default
409 #endif
410
411 -#ifdef NETIF_F_HW_VLAN_TX
412 -#define E1000_MNG_VLAN_NONE -1
413 -#endif
414 +#define E1000_MNG_VLAN_NONE (-1)
415 /* Number of packet split data buffers (not including the header buffer) */
416 -#define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
417 +#define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
418
419 /* only works for sizes that are powers of 2 */
420 #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
421 @@ -206,6 +207,7 @@ struct iegbe_tx_ring {
422 spinlock_t tx_lock;
423 uint16_t tdh;
424 uint16_t tdt;
425 + boolean_t last_tx_tso;
426 uint64_t pkt;
427 };
428
429 @@ -228,6 +230,9 @@ struct iegbe_rx_ring {
430 struct iegbe_ps_page *ps_page;
431 struct iegbe_ps_page_dma *ps_page_dma;
432
433 + /* cpu for rx queue */
434 + int cpu;
435 +
436 uint16_t rdh;
437 uint16_t rdt;
438 uint64_t pkt;
439 @@ -252,10 +257,8 @@ struct iegbe_adapter {
440 struct timer_list tx_fifo_stall_timer;
441 struct timer_list watchdog_timer;
442 struct timer_list phy_info_timer;
443 -#ifdef NETIF_F_HW_VLAN_TX
444 struct vlan_group *vlgrp;
445 uint16_t mng_vlan_id;
446 -#endif
447 uint32_t bd_number;
448 uint32_t rx_buffer_len;
449 uint32_t part_num;
450 @@ -265,8 +268,18 @@ struct iegbe_adapter {
451 uint16_t link_speed;
452 uint16_t link_duplex;
453 spinlock_t stats_lock;
454 - atomic_t irq_sem;
455 - struct work_struct tx_timeout_task;
456 + spinlock_t tx_queue_lock;
457 + unsigned int total_tx_bytes;
458 + unsigned int total_tx_packets;
459 + unsigned int total_rx_bytes;
460 + unsigned int total_rx_packets;
461 + /* Interrupt Throttle Rate */
462 + uint32_t itr;
463 + uint32_t itr_setting;
464 + uint16_t tx_itr;
465 + uint16_t rx_itr;
466 +
467 + struct work_struct reset_task;
468 uint8_t fc_autoneg;
469
470 #ifdef ETHTOOL_PHYS_ID
471 @@ -276,9 +289,8 @@ struct iegbe_adapter {
472
473 /* TX */
474 struct iegbe_tx_ring *tx_ring; /* One per active queue */
475 -#ifdef CONFIG_E1000_MQ
476 - struct iegbe_tx_ring **cpu_tx_ring; /* per-cpu */
477 -#endif
478 + unsigned int restart_queue;
479 + unsigned long tx_queue_len;
480 uint32_t txd_cmd;
481 uint32_t tx_int_delay;
482 uint32_t tx_abs_int_delay;
483 @@ -286,46 +298,33 @@ struct iegbe_adapter {
484 uint64_t gotcl_old;
485 uint64_t tpt_old;
486 uint64_t colc_old;
487 + uint32_t tx_timeout_count;
488 uint32_t tx_fifo_head;
489 uint32_t tx_head_addr;
490 uint32_t tx_fifo_size;
491 + uint8_t tx_timeout_factor;
492 atomic_t tx_fifo_stall;
493 boolean_t pcix_82544;
494 boolean_t detect_tx_hung;
495
496 /* RX */
497 -#ifdef CONFIG_E1000_NAPI
498 - boolean_t (*clean_rx) (struct iegbe_adapter *adapter,
499 + bool (*clean_rx)(struct iegbe_adapter *adapter,
500 struct iegbe_rx_ring *rx_ring,
501 int *work_done, int work_to_do);
502 -#else
503 - boolean_t (*clean_rx) (struct iegbe_adapter *adapter,
504 - struct iegbe_rx_ring *rx_ring);
505 -#endif
506 -
507 -#ifdef IEGBE_GBE_WORKAROUND
508 void (*alloc_rx_buf) (struct iegbe_adapter *adapter,
509 - struct iegbe_rx_ring *rx_ring,
510 - int cleaned_count);
511 -#else
512 - void (*alloc_rx_buf) (struct iegbe_adapter *adapter,
513 - struct iegbe_rx_ring *rx_ring);
514 -#endif
515 -
516 + struct iegbe_rx_ring *rx_ring,
517 + int cleaned_count);
518 struct iegbe_rx_ring *rx_ring; /* One per active queue */
519 -#ifdef CONFIG_E1000_NAPI
520 + struct napi_struct napi;
521 struct net_device *polling_netdev; /* One per active queue */
522 -#endif
523 -#ifdef CONFIG_E1000_MQ
524 - struct net_device **cpu_netdev; /* per-cpu */
525 - struct call_async_data_struct rx_sched_call_data;
526 - int cpu_for_queue[4];
527 -#endif
528 - int num_queues;
529 +
530 + int num_tx_queues;
531 + int num_rx_queues;
532
533 uint64_t hw_csum_err;
534 uint64_t hw_csum_good;
535 uint64_t rx_hdr_split;
536 + uint32_t alloc_rx_buff_failed;
537 uint32_t rx_int_delay;
538 uint32_t rx_abs_int_delay;
539 boolean_t rx_csum;
540 @@ -334,8 +333,6 @@ struct iegbe_adapter {
541 uint64_t gorcl_old;
542 uint16_t rx_ps_bsize0;
543
544 - /* Interrupt Throttle Rate */
545 - uint32_t itr;
546
547 /* OS defined structs */
548 struct net_device *netdev;
549 @@ -378,7 +375,21 @@ struct iegbe_adapter {
550 #ifdef CONFIG_PCI_MSI
551 boolean_t have_msi;
552 #endif
553 -#define IEGBE_INTD_DISABLE 0x0400
554 + /* to not mess up cache alignment, always add to the bottom */
555 + boolean_t tso_force;
556 + boolean_t smart_power_down; /* phy smart power down */
557 + boolean_t quad_port_a;
558 + unsigned long flags;
559 + uint32_t eeprom_wol;
560 + int bars;
561 + int need_ioport;
562 };
563 +
564 +enum iegbe_state_t {
565 + __E1000_TESTING,
566 + __E1000_RESETTING,
567 + __E1000_DOWN
568 +};
569 +#define IEGBE_INTD_DISABLE 0x0400
570 #endif /* _IEGBE_H_ */
571
572 --- a/Embedded/src/GbE/iegbe_hw.c
573 +++ b/Embedded/src/GbE/iegbe_hw.c
574 @@ -2,7 +2,7 @@
575
576 GPL LICENSE SUMMARY
577
578 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
579 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
580
581 This program is free software; you can redistribute it and/or modify
582 it under the terms of version 2 of the GNU General Public License as
583 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
584 Contact Information:
585 Intel Corporation
586
587 - version: Embedded.L.1.0.34
588 + version: Embedded.Release.Patch.L.1.0.7-5
589
590 Contact Information:
591
592 @@ -2115,7 +2115,7 @@ iegbe_config_mac_to_phy(struct iegbe_hw
593
594 ret_val = iegbe_oem_set_trans_gasket(hw);
595 if(ret_val){
596 - return ret_val;
597 + return ret_val;
598 }
599 ret_val = iegbe_oem_phy_is_full_duplex(
600 hw, (int *) &is_FullDuplex);
601 @@ -2164,7 +2164,7 @@ iegbe_config_mac_to_phy(struct iegbe_hw
602 }
603 /* Write the configured values back to the Device Control Reg. */
604 E1000_WRITE_REG(hw, CTRL, ctrl);
605 - return E1000_SUCCESS;
606 + return ret_val;
607 }
608
609 /*****************************************************************************
610 @@ -2684,7 +2684,7 @@ iegbe_check_for_link(struct iegbe_hw *hw
611
612 if(hw->autoneg_failed == 0) {
613 hw->autoneg_failed = 1;
614 - return 0;
615 + return E1000_SUCCESS;
616 }
617 DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\r\n");
618
619 @@ -5875,7 +5875,7 @@ iegbe_get_cable_length(struct iegbe_hw *
620 max_agc = cur_agc;
621 }
622 }
623 -
624 +
625 /* This is to fix a Klockwork defect, that the array index might
626 * be out of bounds. 113 is table size */
627 if (cur_agc < 0x71){
628 --- a/Embedded/src/GbE/iegbe_hw.h
629 +++ b/Embedded/src/GbE/iegbe_hw.h
630 @@ -2,7 +2,7 @@
631
632 GPL LICENSE SUMMARY
633
634 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
635 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
636
637 This program is free software; you can redistribute it and/or modify
638 it under the terms of version 2 of the GNU General Public License as
639 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
640 Contact Information:
641 Intel Corporation
642
643 - version: Embedded.L.1.0.34
644 + version: Embedded.Release.Patch.L.1.0.7-5
645
646 Contact Information:
647
648 @@ -299,7 +299,7 @@ void iegbe_set_media_type(struct iegbe_h
649 /* Link Configuration */
650 int32_t iegbe_setup_link(struct iegbe_hw *hw);
651 int32_t iegbe_phy_setup_autoneg(struct iegbe_hw *hw);
652 -void iegbe_config_collision_dist(struct iegbe_hw *hw);
653 +void iegbe_config_collision_dist(struct iegbe_hw *hw);
654 int32_t iegbe_config_fc_after_link_up(struct iegbe_hw *hw);
655 int32_t iegbe_check_for_link(struct iegbe_hw *hw);
656 int32_t iegbe_get_speed_and_duplex(struct iegbe_hw *hw, uint16_t * speed, uint16_t * duplex);
657 @@ -588,14 +588,6 @@ uint8_t iegbe_arc_subsystem_valid(struct
658 * o LSC = Link Status Change
659 */
660
661 -#ifdef IEGBE_GBE_WORKAROUND
662 -#define IMS_ENABLE_MASK ( \
663 - E1000_IMS_RXT0 | \
664 - E1000_IMS_TXQE | \
665 - E1000_IMS_RXDMT0 | \
666 - E1000_IMS_RXSEQ | \
667 - E1000_IMS_LSC)
668 -#else
669 #define IMS_ENABLE_MASK ( \
670 E1000_IMS_RXT0 | \
671 E1000_IMS_TXDW | \
672 @@ -606,8 +598,7 @@ uint8_t iegbe_arc_subsystem_valid(struct
673 E1000_ICR_PB | \
674 E1000_ICR_CPP_TARGET | \
675 E1000_ICR_CPP_MASTER | \
676 - E1000_IMS_LSC)
677 -#endif
678 + E1000_ICR_LSC)
679
680 /* Number of high/low register pairs in the RAR. The RAR (Receive Address
681 * Registers) holds the directed and multicast addresses that we monitor. We
682 @@ -923,10 +914,15 @@ struct iegbe_ffvt_entry {
683 #define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */
684 #define E1000_IMS 0x000D0 /* Interrupt Mask Set - RW */
685 #define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */
686 -// Register conflict, does not exist for ICP_xxxx hardware
687 -// #define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
688 #define E1000_CTRL_AUX 0x000E0 /* Aux Control -RW */
689 +#define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
690 #define E1000_RCTL 0x00100 /* RX Control - RW */
691 +#define E1000_RDTR1 0x02820 /* RX Delay Timer (1) - RW */
692 +#define E1000_RDBAL1 0x02900 /* RX Descriptor Base Address Low (1) - RW */
693 +#define E1000_RDBAH1 0x02904 /* RX Descriptor Base Address High (1) - RW */
694 +#define E1000_RDLEN1 0x02908 /* RX Descriptor Length (1) - RW */
695 +#define E1000_RDH1 0x02910 /* RX Descriptor Head (1) - RW */
696 +#define E1000_RDT1 0x02918 /* RX Descriptor Tail (1) - RW */
697 #define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */
698 #define E1000_TXCW 0x00178 /* TX Configuration Word - RW */
699 #define E1000_RXCW 0x00180 /* RX Configuration Word - RO */
700 @@ -1282,8 +1278,6 @@ struct iegbe_ffvt_entry {
701 #define E1000_82542_FFMT E1000_FFMT
702 #define E1000_82542_FFVT E1000_FFVT
703 #define E1000_82542_HOST_IF E1000_HOST_IF
704 -// Register conflict with ICP_xxxx hardware, no IAM
705 -// #define E1000_82542_IAM E1000_IAM
706 #define E1000_82542_EEMNGCTL E1000_EEMNGCTL
707 #define E1000_82542_PSRCTL E1000_PSRCTL
708 #define E1000_82542_RAID E1000_RAID
709 @@ -1329,6 +1323,7 @@ struct iegbe_hw_stats {
710 uint64_t algnerrc;
711 uint64_t symerrs;
712 uint64_t rxerrc;
713 + uint64_t txerrc;
714 uint64_t mpc;
715 uint64_t scc;
716 uint64_t ecol;
717 @@ -1363,6 +1358,7 @@ struct iegbe_hw_stats {
718 uint64_t ruc;
719 uint64_t rfc;
720 uint64_t roc;
721 + uint64_t rlerrc;
722 uint64_t rjc;
723 uint64_t mgprc;
724 uint64_t mgpdc;
725 @@ -1392,19 +1388,6 @@ struct iegbe_hw_stats {
726 uint64_t ictxqmtc;
727 uint64_t icrxdmtc;
728 uint64_t icrxoc;
729 -#ifdef IEGBE_GBE_WORKAROUND
730 - u64 txqec;
731 - u64 tx_next_to_clean;
732 - u64 tx_next_to_use;
733 - u64 cc_gt_num_rx;
734 - u64 tx_hnet;
735 - u64 tx_hnentu;
736 - u64 num_tx_queues;
737 -
738 - u64 num_rx_buf_alloc;
739 - u64 rx_next_to_clean;
740 - u64 rx_next_to_use;
741 -#endif
742 };
743
744 /* Structure containing variables used by the shared code (iegbe_hw.c) */
745 @@ -1484,6 +1467,7 @@ struct iegbe_hw {
746 boolean_t ifs_params_forced;
747 boolean_t in_ifs_mode;
748 boolean_t mng_reg_access_disabled;
749 + boolean_t rx_needs_kicking;
750 boolean_t icp_xxxx_is_link_up;
751 };
752
753 @@ -2358,17 +2342,23 @@ struct iegbe_host_command_info {
754 #define E1000_EXTCNF_SIZE_EXT_PHY_LENGTH 0x000000FF
755 #define E1000_EXTCNF_SIZE_EXT_DOCK_LENGTH 0x0000FF00
756 #define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH 0x00FF0000
757 +#define E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE 0x00000001
758 +#define E1000_EXTCNF_CTRL_SWFLAG 0x00000020
759
760 /* PBA constants */
761 +#define E1000_PBA_8K 0x0008 /* 8KB, default Rx allocation */
762 #define E1000_PBA_12K 0x000C /* 12KB, default Rx allocation */
763 #define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */
764 +#define E1000_PBA_20K 0x0014
765 #define E1000_PBA_22K 0x0016
766 #define E1000_PBA_24K 0x0018
767 #define E1000_PBA_30K 0x001E
768 #define E1000_PBA_32K 0x0020
769 +#define E1000_PBA_34K 0x0022
770 #define E1000_PBA_38K 0x0026
771 #define E1000_PBA_40K 0x0028
772 #define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */
773 +#define E1000_PBS_16K E1000_PBA_16K
774
775 /* Flow Control Constants */
776 #define FLOW_CONTROL_ADDRESS_LOW 0x00C28001
777 @@ -2899,7 +2889,7 @@ struct iegbe_host_command_info {
778 #define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
779 #define M88E1011_I_REV_4 0x04
780 #define M88E1111_I_PHY_ID 0x01410CC2
781 -#define M88E1141_E_PHY_ID 0x01410CD4
782 +#define M88E1141_E_PHY_ID 0x01410CD0
783 #define L1LXT971A_PHY_ID 0x001378E0
784
785 /* Miscellaneous PHY bit definitions. */
786 --- a/Embedded/src/GbE/iegbe_main.c
787 +++ b/Embedded/src/GbE/iegbe_main.c
788 @@ -2,7 +2,7 @@
789
790 GPL LICENSE SUMMARY
791
792 - Copyright(c) 2007,2008 Intel Corporation. All rights reserved.
793 + Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved.
794
795 This program is free software; you can redistribute it and/or modify
796 it under the terms of version 2 of the GNU General Public License as
797 @@ -22,7 +22,7 @@ GPL LICENSE SUMMARY
798 Contact Information:
799 Intel Corporation
800
801 - version: Embedded.L.1.0.34
802 + version: Embedded.Release.Patch.L.1.0.7-5
803
804 Contact Information:
805
806 @@ -42,103 +42,15 @@ GPL LICENSE SUMMARY
807
808 #include "iegbe.h"
809 #include "gcu_if.h"
810 -
811 -/* Change Log
812 - * 6.0.58 4/20/05
813 - * o iegbe_set_spd_dplx tests for compatible speed/duplex specification
814 - * for fiber adapters
815 - * 6.0.57 4/19/05
816 - * o Added code to fix register test failure for devices >= 82571
817 - *
818 - * 6.0.52 3/15/05
819 - * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
820 - * calls, one from mii_ioctl and other from within update_stats while
821 - * processing MIIREG ioctl.
822 - *
823 - * 6.1.2 4/13/05
824 - * o Fixed ethtool diagnostics
825 - * o Enabled flow control to take default eeprom settings
826 - * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
827 - * calls, one from mii_ioctl and other from within update_stats while processing
828 - * MIIREG ioctl.
829 - * 6.0.55 3/23/05
830 - * o Support for MODULE_VERSION
831 - * o Fix APM setting for 82544 based adapters
832 - * 6.0.54 3/26/05
833 - * o Added a timer to expire packets that were deferred for cleanup
834 - * 6.0.52 3/15/05
835 - * o Added stats_lock around iegbe_read_phy_reg commands to avoid concurrent
836 - * calls, one from mii_ioctl and other from within update_stats while
837 - * processing MIIREG ioctl.
838 - * 6.0.47 3/2/05
839 - * o Added enhanced functionality to the loopback diags to wrap the
840 - * descriptor rings
841 - * o Added manageability vlan filtering workaround.
842 - *
843 - * 6.0.44+ 2/15/05
844 - * o Added code to handle raw packet based DHCP packets
845 - * o Added code to fix the errata 10 buffer overflow issue
846 - * o Sync up with WR01-05
847 - * o applied Anton's patch to resolve tx hang in hardware
848 - * o iegbe timeouts with early writeback patch
849 - * o Removed Queensport IDs
850 - * o fixed driver panic if MAC receives a bad large packets when packet
851 - * split is enabled
852 - * o Applied Andrew Mortons patch - iegbe stops working after resume
853 - * 5.2.29 12/24/03
854 - * o Bug fix: Endianess issue causing ethtool diags to fail on ppc.
855 - * o Bug fix: Use pdev->irq instead of netdev->irq for MSI support.
856 - * o Report driver message on user override of InterruptThrottleRate module
857 - * parameter.
858 - * o Bug fix: Change I/O address storage from uint32_t to unsigned long.
859 - * o Feature: Added ethtool RINGPARAM support.
860 - * o Feature: Added netpoll support.
861 - * o Bug fix: Race between Tx queue and Tx clean fixed with a spin lock.
862 - * o Bug fix: Allow 1000/Full setting for autoneg param for fiber connections.
863 - * Jon D Mason [jonmason@us.ibm.com].
864 - *
865 - * 5.2.22 10/15/03
866 - * o Bug fix: SERDES devices might be connected to a back-plane switch that
867 - * doesn't support auto-neg, so add the capability to force 1000/Full.
868 - * Also, since forcing 1000/Full, sample RxSynchronize bit to detect link
869 - * state.
870 - * o Bug fix: Flow control settings for hi/lo watermark didn't consider
871 - * changes in the RX FIFO size, which could occur with Jumbo Frames or with
872 - * the reduced FIFO in 82547.
873 - * o Bug fix: Better propagation of error codes.
874 - * [Janice Girouard (janiceg -a-t- us.ibm.com)]
875 - * o Bug fix: hang under heavy Tx stress when running out of Tx descriptors;
876 - * wasn't clearing context descriptor when backing out of send because of
877 - * no-resource condition.
878 - * o Bug fix: check netif_running in dev->poll so we don't have to hang in
879 - * dev->close until all polls are finished. [Rober Olsson
880 - * (robert.olsson@data.slu.se)].
881 - * o Revert TxDescriptor ring size back to 256 since change to 1024 wasn't
882 - * accepted into the kernel.
883 - *
884 - * 5.2.16 8/8/03
885 - */
886 -
887 -#ifdef IEGBE_GBE_WORKAROUND
888 -#define IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS 1
889 -#endif
890 +#include <linux/ipv6.h>
891 +#include <net/ip6_checksum.h>
892
893 char iegbe_driver_name[] = "iegbe";
894 char iegbe_driver_string[] = "Gigabit Ethernet Controller Driver";
895 -#ifndef CONFIG_E1000_NAPI
896 -#define DRIVERNAPI
897 -#else
898 -#define DRIVERNAPI "-NAPI"
899 -#endif
900 -#define DRV_VERSION "0.8.0"DRIVERNAPI
901 +#define DRV_VERSION "1.0.0-K28-NAPI"
902 char iegbe_driver_version[] = DRV_VERSION;
903 -char iegbe_copyright[] = "Copyright (c) 1999-2007 Intel Corporation.";
904 +char iegbe_copyright[] = "Copyright (c) 1999-2009 Intel Corporation.";
905
906 -#define E1000_FIFO_HDR 0x10
907 -#define E1000_82547_PAD_LEN 0x3E0
908 -#define MINIMUM_DHCP_PACKET_SIZE 282
909 -#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
910 -#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
911
912 /* iegbe_pci_tbl - PCI Device ID Table
913 *
914 @@ -148,95 +60,48 @@ char iegbe_copyright[] = "Copyright (c)
915 * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
916 */
917 static struct pci_device_id iegbe_pci_tbl[] = {
918 -/* INTEL_E1000_ETHERNET_DEVICE(0x1000), */
919 -/* INTEL_E1000_ETHERNET_DEVICE(0x1001), */
920 -/* INTEL_E1000_ETHERNET_DEVICE(0x1004), */
921 -/* INTEL_E1000_ETHERNET_DEVICE(0x1008), */
922 -/* INTEL_E1000_ETHERNET_DEVICE(0x1009), */
923 -/* INTEL_E1000_ETHERNET_DEVICE(0x100C), */
924 -/* INTEL_E1000_ETHERNET_DEVICE(0x100D), */
925 -/* INTEL_E1000_ETHERNET_DEVICE(0x100E), */
926 -/* INTEL_E1000_ETHERNET_DEVICE(0x100F), */
927 -/* INTEL_E1000_ETHERNET_DEVICE(0x1010), */
928 -/* INTEL_E1000_ETHERNET_DEVICE(0x1011), */
929 -/* INTEL_E1000_ETHERNET_DEVICE(0x1012), */
930 -/* INTEL_E1000_ETHERNET_DEVICE(0x1013), */
931 -/* INTEL_E1000_ETHERNET_DEVICE(0x1014), */
932 -/* INTEL_E1000_ETHERNET_DEVICE(0x1015), */
933 -/* INTEL_E1000_ETHERNET_DEVICE(0x1016), */
934 -/* INTEL_E1000_ETHERNET_DEVICE(0x1017), */
935 -/* INTEL_E1000_ETHERNET_DEVICE(0x1018), */
936 -/* INTEL_E1000_ETHERNET_DEVICE(0x1019), */
937 -/* INTEL_E1000_ETHERNET_DEVICE(0x101A), */
938 -/* INTEL_E1000_ETHERNET_DEVICE(0x101D), */
939 -/* INTEL_E1000_ETHERNET_DEVICE(0x101E), */
940 -/* INTEL_E1000_ETHERNET_DEVICE(0x1026), */
941 -/* INTEL_E1000_ETHERNET_DEVICE(0x1027), */
942 -/* INTEL_E1000_ETHERNET_DEVICE(0x1028), */
943 -/* INTEL_E1000_ETHERNET_DEVICE(0x105E), */
944 -/* INTEL_E1000_ETHERNET_DEVICE(0x105F), */
945 -/* INTEL_E1000_ETHERNET_DEVICE(0x1060), */
946 -/* INTEL_E1000_ETHERNET_DEVICE(0x1075), */
947 -/* INTEL_E1000_ETHERNET_DEVICE(0x1076), */
948 -/* INTEL_E1000_ETHERNET_DEVICE(0x1077), */
949 -/* INTEL_E1000_ETHERNET_DEVICE(0x1078), */
950 -/* INTEL_E1000_ETHERNET_DEVICE(0x1079), */
951 -/* INTEL_E1000_ETHERNET_DEVICE(0x107A), */
952 -/* INTEL_E1000_ETHERNET_DEVICE(0x107B), */
953 -/* INTEL_E1000_ETHERNET_DEVICE(0x107C), */
954 -/* INTEL_E1000_ETHERNET_DEVICE(0x107D), */
955 -/* INTEL_E1000_ETHERNET_DEVICE(0x107E), */
956 -/* INTEL_E1000_ETHERNET_DEVICE(0x107F), */
957 -/* INTEL_E1000_ETHERNET_DEVICE(0x108A), */
958 -/* INTEL_E1000_ETHERNET_DEVICE(0x108B), */
959 -/* INTEL_E1000_ETHERNET_DEVICE(0x108C), */
960 -/* INTEL_E1000_ETHERNET_DEVICE(0x109A), */
961 - INTEL_E1000_ETHERNET_DEVICE(0x5040),
962 - INTEL_E1000_ETHERNET_DEVICE(0x5041),
963 - INTEL_E1000_ETHERNET_DEVICE(0x5042),
964 - INTEL_E1000_ETHERNET_DEVICE(0x5043),
965 - INTEL_E1000_ETHERNET_DEVICE(0x5044),
966 - INTEL_E1000_ETHERNET_DEVICE(0x5045),
967 - INTEL_E1000_ETHERNET_DEVICE(0x5046),
968 - INTEL_E1000_ETHERNET_DEVICE(0x5047),
969 - INTEL_E1000_ETHERNET_DEVICE(0x5048),
970 - INTEL_E1000_ETHERNET_DEVICE(0x5049),
971 - INTEL_E1000_ETHERNET_DEVICE(0x504A),
972 - INTEL_E1000_ETHERNET_DEVICE(0x504B),
973 - /* required last entry */
974 + INTEL_E1000_ETHERNET_DEVICE(0x5040),
975 + INTEL_E1000_ETHERNET_DEVICE(0x5041),
976 + INTEL_E1000_ETHERNET_DEVICE(0x5042),
977 + INTEL_E1000_ETHERNET_DEVICE(0x5043),
978 + INTEL_E1000_ETHERNET_DEVICE(0x5044),
979 + INTEL_E1000_ETHERNET_DEVICE(0x5045),
980 + INTEL_E1000_ETHERNET_DEVICE(0x5046),
981 + INTEL_E1000_ETHERNET_DEVICE(0x5047),
982 + INTEL_E1000_ETHERNET_DEVICE(0x5048),
983 + INTEL_E1000_ETHERNET_DEVICE(0x5049),
984 + INTEL_E1000_ETHERNET_DEVICE(0x504A),
985 + INTEL_E1000_ETHERNET_DEVICE(0x504B),
986 + /* required last entry */
987 {0,}
988 };
989
990 MODULE_DEVICE_TABLE(pci, iegbe_pci_tbl);
991
992 -DEFINE_SPINLOCK(print_lock);
993
994 int iegbe_up(struct iegbe_adapter *adapter);
995 void iegbe_down(struct iegbe_adapter *adapter);
996 +void iegbe_reinit_locked(struct iegbe_adapter *adapter);
997 void iegbe_reset(struct iegbe_adapter *adapter);
998 int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, uint16_t spddplx);
999 int iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter);
1000 int iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter);
1001 void iegbe_free_all_tx_resources(struct iegbe_adapter *adapter);
1002 void iegbe_free_all_rx_resources(struct iegbe_adapter *adapter);
1003 -int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
1004 +static int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
1005 struct iegbe_tx_ring *txdr);
1006 -int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
1007 +static int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
1008 struct iegbe_rx_ring *rxdr);
1009 -void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
1010 +static void iegbe_free_tx_resources(struct iegbe_adapter *adapter,
1011 struct iegbe_tx_ring *tx_ring);
1012 -void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
1013 +static void iegbe_free_rx_resources(struct iegbe_adapter *adapter,
1014 struct iegbe_rx_ring *rx_ring);
1015 void iegbe_update_stats(struct iegbe_adapter *adapter);
1016 -
1017 static int iegbe_init_module(void);
1018 static void iegbe_exit_module(void);
1019 static int iegbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
1020 static void __devexit iegbe_remove(struct pci_dev *pdev);
1021 static int iegbe_alloc_queues(struct iegbe_adapter *adapter);
1022 -#ifdef CONFIG_E1000_MQ
1023 -static void iegbe_setup_queue_mapping(struct iegbe_adapter *adapter);
1024 -#endif
1025 static int iegbe_sw_init(struct iegbe_adapter *adapter);
1026 static int iegbe_open(struct net_device *netdev);
1027 static int iegbe_close(struct net_device *netdev);
1028 @@ -249,7 +114,8 @@ static void iegbe_clean_tx_ring(struct i
1029 struct iegbe_tx_ring *tx_ring);
1030 static void iegbe_clean_rx_ring(struct iegbe_adapter *adapter,
1031 struct iegbe_rx_ring *rx_ring);
1032 -static void iegbe_set_multi(struct net_device *netdev);
1033 +
1034 +static void iegbe_set_rx_mode(struct net_device *netdev);
1035 static void iegbe_update_phy_info(unsigned long data);
1036 static void iegbe_watchdog(unsigned long data);
1037 static void iegbe_82547_tx_fifo_stall(unsigned long data);
1038 @@ -257,66 +123,46 @@ static int iegbe_xmit_frame(struct sk_bu
1039 static struct net_device_stats * iegbe_get_stats(struct net_device *netdev);
1040 static int iegbe_change_mtu(struct net_device *netdev, int new_mtu);
1041 static int iegbe_set_mac(struct net_device *netdev, void *p);
1042 -static irqreturn_t iegbe_intr(int irq, void *data, struct pt_regs *regs);
1043 +static irqreturn_t iegbe_intr(int irq, void *data);
1044
1045 -void iegbe_tasklet(unsigned long);
1046 +static irqreturn_t iegbe_intr_msi(int irq, void *data);
1047
1048 -#ifndef IEGBE_GBE_WORKAROUND
1049 -static boolean_t iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
1050 +static bool iegbe_clean_tx_irq(struct iegbe_adapter *adapter,
1051 struct iegbe_tx_ring *tx_ring);
1052 -#endif
1053 -
1054 -#ifdef CONFIG_E1000_NAPI
1055 -static int iegbe_clean(struct net_device *poll_dev, int *budget);
1056 -static boolean_t iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
1057 +static int iegbe_clean(struct napi_struct *napi, int budget);
1058 +static bool iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
1059 struct iegbe_rx_ring *rx_ring,
1060 int *work_done, int work_to_do);
1061 -static boolean_t iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
1062 +static bool iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
1063 struct iegbe_rx_ring *rx_ring,
1064 int *work_done, int work_to_do);
1065 -#else
1066 -static boolean_t iegbe_clean_rx_irq(struct iegbe_adapter *adapter,
1067 - struct iegbe_rx_ring *rx_ring);
1068 -static boolean_t iegbe_clean_rx_irq_ps(struct iegbe_adapter *adapter,
1069 - struct iegbe_rx_ring *rx_ring);
1070 -#endif
1071
1072 -#ifdef IEGBE_GBE_WORKAROUND
1073 +
1074 static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
1075 struct iegbe_rx_ring *rx_ring,
1076 int cleaned_count);
1077 static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
1078 struct iegbe_rx_ring *rx_ring,
1079 int cleaned_count);
1080 -#else
1081 -static void iegbe_alloc_rx_buffers(struct iegbe_adapter *adapter,
1082 - struct iegbe_rx_ring *rx_ring);
1083 -static void iegbe_alloc_rx_buffers_ps(struct iegbe_adapter *adapter,
1084 - struct iegbe_rx_ring *rx_ring);
1085 -#endif
1086 +
1087
1088 static int iegbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
1089 -#ifdef SIOCGMIIPHY
1090 static int iegbe_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
1091 - int cmd);
1092 -#endif
1093 + int cmd);
1094 void set_ethtool_ops(struct net_device *netdev);
1095 extern int ethtool_ioctl(struct ifreq *ifr);
1096 static void iegbe_enter_82542_rst(struct iegbe_adapter *adapter);
1097 static void iegbe_leave_82542_rst(struct iegbe_adapter *adapter);
1098 static void iegbe_tx_timeout(struct net_device *dev);
1099 -static void iegbe_tx_timeout_task(struct net_device *dev);
1100 +static void iegbe_reset_task(struct work_struct *work);
1101 static void iegbe_smartspeed(struct iegbe_adapter *adapter);
1102 static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
1103 - struct sk_buff *skb);
1104 + struct sk_buff *skb);
1105
1106 -#ifdef NETIF_F_HW_VLAN_TX
1107 -static void iegbe_vlan_rx_register(struct net_device *netdev,
1108 - struct vlan_group *grp);
1109 +static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
1110 static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
1111 static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
1112 static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
1113 -#endif
1114
1115 static int iegbe_notify_reboot(struct notifier_block *,
1116 unsigned long event,
1117 @@ -331,15 +177,17 @@ static int iegbe_resume(struct pci_dev *
1118 static void iegbe_netpoll (struct net_device *netdev);
1119 #endif
1120
1121 -#ifdef CONFIG_E1000_MQ
1122 -/* for multiple Rx queues */
1123 +#define COPYBREAK_DEFAULT 256
1124 +static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
1125 +module_param(copybreak, uint, 0644);
1126 +MODULE_PARM_DESC(copybreak,
1127 + "Maximum size of packet that is copied to a new buffer on receive");
1128 void iegbe_rx_schedule(void *data);
1129 -#endif
1130
1131 struct notifier_block iegbe_notifier_reboot = {
1132 - .notifier_call = iegbe_notify_reboot,
1133 - .next = NULL,
1134 - .priority = 0
1135 + .notifier_call = iegbe_notify_reboot,
1136 + .next = NULL,
1137 + .priority = 0
1138 };
1139
1140 /* Exported from other modules */
1141 @@ -347,14 +195,14 @@ struct notifier_block iegbe_notifier_reb
1142 extern void iegbe_check_options(struct iegbe_adapter *adapter);
1143
1144 static struct pci_driver iegbe_driver = {
1145 - .name = iegbe_driver_name,
1146 - .id_table = iegbe_pci_tbl,
1147 - .probe = iegbe_probe,
1148 - .remove = __devexit_p(iegbe_remove),
1149 - /* Power Managment Hooks */
1150 + .name = iegbe_driver_name,
1151 + .id_table = iegbe_pci_tbl,
1152 + .probe = iegbe_probe,
1153 + .remove = __devexit_p(iegbe_remove),
1154 + /* Power Managment Hooks */
1155 #ifdef CONFIG_PM
1156 - .suspend = iegbe_suspend,
1157 - .resume = iegbe_resume
1158 + .suspend = iegbe_suspend,
1159 + .resume = iegbe_resume
1160 #endif
1161 };
1162
1163 @@ -364,46 +212,17 @@ MODULE_LICENSE("GPL");
1164 MODULE_VERSION(DRV_VERSION);
1165
1166 static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
1167 -module_param(debug, int, 0);
1168 +module_param(debug, int, 0x0);
1169 MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
1170
1171 -static uint8_t gcu_suspend = 0;
1172 -static uint8_t gcu_resume = 0;
1173 +static uint8_t gcu_suspend = 0x0;
1174 +static uint8_t gcu_resume = 0x0;
1175 struct pci_dev *gcu = NULL;
1176
1177 -unsigned long tasklet_data;
1178 -DECLARE_TASKLET(iegbe_reset_tasklet, iegbe_tasklet, (unsigned long) &tasklet_data);
1179
1180 /**
1181 * iegbe_iegbe_tasklet -*
1182 **/
1183 -void iegbe_tasklet(unsigned long data)
1184 -{
1185 - char* err_msg = "TEST";
1186 - uint32_t *icr = (uint32_t*) data;
1187 - uint32_t gbe = *icr & 0x000000FF;
1188 - if( *icr & E1000_ICR_RX_DESC_FIFO_PAR) { /* 21 */
1189 - err_msg = "DMA Transmit Descriptor 2-bit ECC Error!";
1190 - }
1191 - if( *icr & E1000_ICR_TX_DESC_FIFO_PAR) { /* 20 */
1192 - err_msg = "DMA Receive Descriptor 2-bit ECC Error!";
1193 - }
1194 - if( *icr & E1000_ICR_PB) { /* 23 */
1195 - err_msg = "DMA Packet Buffer 2-bit ECC Error!";
1196 - }
1197 - if( *icr & E1000_ICR_CPP_TARGET) { /* 27 */
1198 - err_msg = "Statistic Register ECC Error!";
1199 - }
1200 - if( *icr & E1000_ICR_CPP_MASTER) {
1201 - err_msg = "CPP Error!";
1202 - }
1203 - spin_lock(&print_lock);
1204 - printk("IEGBE%d: System Reset due to: %s\n", gbe, err_msg);
1205 - dump_stack();
1206 - spin_unlock(&print_lock);
1207 - panic(err_msg);
1208 - return;
1209 -}
1210 /**
1211 * iegbe_init_module - Driver Registration Routine
1212 *
1213 @@ -411,21 +230,24 @@ void iegbe_tasklet(unsigned long data)
1214 * loaded. All it does is register with the PCI subsystem.
1215 **/
1216
1217 -static int __init
1218 -iegbe_init_module(void)
1219 +static int __init iegbe_init_module(void)
1220 {
1221 - int ret;
1222 + int ret;
1223
1224 printk(KERN_INFO "%s - version %s\n",
1225 - iegbe_driver_string, iegbe_driver_version);
1226 + iegbe_driver_string, iegbe_driver_version);
1227
1228 - printk(KERN_INFO "%s\n", iegbe_copyright);
1229 + printk(KERN_INFO "%s\n", iegbe_copyright);
1230
1231 - ret = pci_module_init(&iegbe_driver);
1232 - if(ret >= 0) {
1233 - register_reboot_notifier(&iegbe_notifier_reboot);
1234 - }
1235 - return ret;
1236 + ret = pci_register_driver(&iegbe_driver);
1237 + if (copybreak != COPYBREAK_DEFAULT) {
1238 + if (copybreak == 0)
1239 + printk(KERN_INFO "iegbe: copybreak disabled\n");
1240 + else
1241 + printk(KERN_INFO "iegbe: copybreak enabled for "
1242 + "packets <= %u bytes\n", copybreak);
1243 + }
1244 + return ret;
1245 }
1246
1247 module_init(iegbe_init_module);
1248 @@ -437,29 +259,51 @@ module_init(iegbe_init_module);
1249 * from memory.
1250 **/
1251
1252 -static void __exit
1253 -iegbe_exit_module(void)
1254 +static void __exit iegbe_exit_module(void)
1255 {
1256 -
1257 - unregister_reboot_notifier(&iegbe_notifier_reboot);
1258 - pci_unregister_driver(&iegbe_driver);
1259 + pci_unregister_driver(&iegbe_driver);
1260 }
1261
1262 module_exit(iegbe_exit_module);
1263
1264 +static int iegbe_request_irq(struct iegbe_adapter *adapter)
1265 +{
1266 + struct net_device *netdev = adapter->netdev;
1267 + irq_handler_t handler = iegbe_intr;
1268 + int irq_flags = IRQF_SHARED;
1269 + int err;
1270 + adapter->have_msi = !pci_enable_msi(adapter->pdev);
1271 + if (adapter->have_msi) {
1272 + handler = iegbe_intr_msi;
1273 + irq_flags = 0;
1274 + }
1275 + err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
1276 + netdev);
1277 + if (err) {
1278 + if (adapter->have_msi)
1279 + pci_disable_msi(adapter->pdev);
1280 + DPRINTK(PROBE, ERR,
1281 + "Unable to allocate interrupt Error: %d\n", err);
1282 + }
1283 + return err;
1284 +}
1285 +static void iegbe_free_irq(struct iegbe_adapter *adapter)
1286 +{
1287 + struct net_device *netdev = adapter->netdev;
1288 + free_irq(adapter->pdev->irq, netdev);
1289 + if (adapter->have_msi)
1290 + pci_disable_msi(adapter->pdev);
1291 +}
1292 /**
1293 * iegbe_irq_disable - Mask off interrupt generation on the NIC
1294 * @adapter: board private structure
1295 **/
1296
1297 -static inline void
1298 -iegbe_irq_disable(struct iegbe_adapter *adapter)
1299 +static void iegbe_irq_disable(struct iegbe_adapter *adapter)
1300 {
1301 -
1302 - atomic_inc(&adapter->irq_sem);
1303 - E1000_WRITE_REG(&adapter->hw, IMC, ~0);
1304 - E1000_WRITE_FLUSH(&adapter->hw);
1305 - synchronize_irq(adapter->pdev->irq);
1306 + E1000_WRITE_REG(&adapter->hw, IMC, ~0);
1307 + E1000_WRITE_FLUSH(&adapter->hw);
1308 + synchronize_irq(adapter->pdev->irq);
1309 }
1310
1311 /**
1312 @@ -470,244 +314,414 @@ iegbe_irq_disable(struct iegbe_adapter *
1313 static inline void
1314 iegbe_irq_enable(struct iegbe_adapter *adapter)
1315 {
1316 -
1317 - if(likely(atomic_dec_and_test(&adapter->irq_sem))) {
1318 - E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
1319 - E1000_WRITE_FLUSH(&adapter->hw);
1320 - }
1321 + E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
1322 + E1000_WRITE_FLUSH(&adapter->hw);
1323 }
1324 -#ifdef NETIF_F_HW_VLAN_TX
1325 -void
1326 -iegbe_update_mng_vlan(struct iegbe_adapter *adapter)
1327 -{
1328 - struct net_device *netdev = adapter->netdev;
1329 - uint16_t vid = adapter->hw.mng_cookie.vlan_id;
1330 - uint16_t old_vid = adapter->mng_vlan_id;
1331
1332 - if(adapter->vlgrp) {
1333 - if(!adapter->vlgrp->vlan_devices[vid]) {
1334 - if(adapter->hw.mng_cookie.status &
1335 - E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
1336 - iegbe_vlan_rx_add_vid(netdev, vid);
1337 - adapter->mng_vlan_id = vid;
1338 - } else {
1339 - adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
1340 - }
1341 - if((old_vid != (uint16_t)E1000_MNG_VLAN_NONE) &&
1342 - (vid != old_vid) &&
1343 - !adapter->vlgrp->vlan_devices[old_vid]) {
1344 - iegbe_vlan_rx_kill_vid(netdev, old_vid);
1345 - }
1346 - }
1347 -}
1348 +static void iegbe_update_mng_vlan(struct iegbe_adapter *adapter)
1349 +{
1350 + struct iegbe_hw *hw = &adapter->hw;
1351 + struct net_device *netdev = adapter->netdev;
1352 + u16 vid = hw->mng_cookie.vlan_id;
1353 + u16 old_vid = adapter->mng_vlan_id;
1354 + if (adapter->vlgrp) {
1355 + if (!vlan_group_get_device(adapter->vlgrp, vid)) {
1356 + if (hw->mng_cookie.status &
1357 + E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
1358 + iegbe_vlan_rx_add_vid(netdev, vid);
1359 + adapter->mng_vlan_id = vid;
1360 + } else
1361 + adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
1362 +
1363 + if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
1364 + (vid != old_vid) &&
1365 + !vlan_group_get_device(adapter->vlgrp, old_vid))
1366 + iegbe_vlan_rx_kill_vid(netdev, old_vid);
1367 + } else
1368 + adapter->mng_vlan_id = vid;
1369 + }
1370 }
1371 -#endif
1372
1373 -int
1374 -iegbe_up(struct iegbe_adapter *adapter)
1375 +/**
1376 + * iegbe_configure - configure the hardware for RX and TX
1377 + * @adapter = private board structure
1378 + **/
1379 +static void iegbe_configure(struct iegbe_adapter *adapter)
1380 {
1381 struct net_device *netdev = adapter->netdev;
1382 - int i, err;
1383 - uint16_t pci_cmd;
1384 -
1385 - /* hardware has been reset, we need to reload some things */
1386 -
1387 - /* Reset the PHY if it was previously powered down */
1388 - if(adapter->hw.media_type == iegbe_media_type_copper
1389 - || (adapter->hw.media_type == iegbe_media_type_oem
1390 - && iegbe_oem_phy_is_copper(&adapter->hw))) {
1391 - uint16_t mii_reg;
1392 - iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
1393 - if(mii_reg & MII_CR_POWER_DOWN){
1394 - iegbe_phy_reset(&adapter->hw);
1395 - }
1396 - }
1397 + int i;
1398
1399 - iegbe_set_multi(netdev);
1400 + iegbe_set_rx_mode(netdev);
1401
1402 -#ifdef NETIF_F_HW_VLAN_TX
1403 iegbe_restore_vlan(adapter);
1404 -#endif
1405
1406 iegbe_configure_tx(adapter);
1407 iegbe_setup_rctl(adapter);
1408 iegbe_configure_rx(adapter);
1409 + /* call E1000_DESC_UNUSED which always leaves
1410 + * at least 1 descriptor unused to make sure
1411 + * next_to_use != next_to_clean */
1412 + for (i = 0; i < adapter->num_rx_queues; i++) {
1413 + struct iegbe_rx_ring *ring = &adapter->rx_ring[i];
1414 + adapter->alloc_rx_buf(adapter, ring,
1415 + E1000_DESC_UNUSED(ring));
1416 + }
1417
1418 -#ifdef IEGBE_GBE_WORKAROUND
1419 - for (i = 0; i < adapter->num_queues; i++)
1420 - adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i],
1421 - IEGBE_GBE_WORKAROUND_NUM_RX_DESCRIPTORS + 1);
1422 -#else
1423 - for (i = 0; i < adapter->num_queues; i++)
1424 - adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i]);
1425 -#endif
1426 + adapter->tx_queue_len = netdev->tx_queue_len;
1427 +}
1428
1429 -#ifdef CONFIG_PCI_MSI
1430 - if(adapter->hw.mac_type > iegbe_82547_rev_2
1431 - || adapter->hw.mac_type == iegbe_icp_xxxx) {
1432 - adapter->have_msi = TRUE;
1433 - if((err = pci_enable_msi(adapter->pdev))) {
1434 - DPRINTK(PROBE, ERR,
1435 - "Unable to allocate MSI interrupt Error: %d\n", err);
1436 - adapter->have_msi = FALSE;
1437 - }
1438 - }
1439 - pci_read_config_word(adapter->pdev, PCI_COMMAND, &pci_cmd);
1440 - pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd | IEGBE_INTD_DISABLE);
1441 +int iegbe_up(struct iegbe_adapter *adapter)
1442 +{
1443 + /* hardware has been reset, we need to reload some things */
1444 + iegbe_configure(adapter);
1445
1446 -#endif
1447 - if((err = request_irq(adapter->pdev->irq, &iegbe_intr,
1448 - SA_SHIRQ | SA_SAMPLE_RANDOM,
1449 - netdev->name, netdev))) {
1450 - DPRINTK(PROBE, ERR,
1451 - "Unable to allocate interrupt Error: %d\n", err);
1452 - return err;
1453 - }
1454 + clear_bit(__E1000_DOWN, &adapter->flags);
1455
1456 - mod_timer(&adapter->watchdog_timer, jiffies);
1457 + napi_enable(&adapter->napi);
1458
1459 -#ifdef CONFIG_E1000_NAPI
1460 - netif_poll_enable(netdev);
1461 -#endif
1462 iegbe_irq_enable(adapter);
1463
1464 + adapter->hw.get_link_status = 0x1;
1465 return 0;
1466 }
1467
1468 -void
1469 -iegbe_down(struct iegbe_adapter *adapter)
1470 -{
1471 - struct net_device *netdev = adapter->netdev;
1472 -
1473 - iegbe_irq_disable(adapter);
1474 -#ifdef CONFIG_E1000_MQ
1475 - while (atomic_read(&adapter->rx_sched_call_data.count) != 0) { };
1476 -#endif
1477 - free_irq(adapter->pdev->irq, netdev);
1478 -#ifdef CONFIG_PCI_MSI
1479 - if((adapter->hw.mac_type > iegbe_82547_rev_2
1480 - || adapter->hw.mac_type == iegbe_icp_xxxx)
1481 - && adapter->have_msi == TRUE) {
1482 - pci_disable_msi(adapter->pdev);
1483 - }
1484 -#endif
1485 - del_timer_sync(&adapter->tx_fifo_stall_timer);
1486 - del_timer_sync(&adapter->watchdog_timer);
1487 - del_timer_sync(&adapter->phy_info_timer);
1488 +/**
1489 + * iegbe_power_up_phy - restore link in case the phy was powered down
1490 + * @adapter: address of board private structure
1491 + *
1492 + * The phy may be powered down to save power and turn off link when the
1493 + * driver is unloaded and wake on lan is not enabled (among others)
1494 + * *** this routine MUST be followed by a call to iegbe_reset ***
1495 + *
1496 + **/
1497
1498 -#ifdef CONFIG_E1000_NAPI
1499 - netif_poll_disable(netdev);
1500 -#endif
1501 - adapter->link_speed = 0;
1502 - adapter->link_duplex = 0;
1503 - netif_carrier_off(netdev);
1504 - netif_stop_queue(netdev);
1505 +void iegbe_power_up_phy(struct iegbe_adapter *adapter)
1506 +{
1507 + struct iegbe_hw *hw = &adapter->hw;
1508 + u16 mii_reg = 0;
1509
1510 - iegbe_reset(adapter);
1511 - iegbe_clean_all_tx_rings(adapter);
1512 - iegbe_clean_all_rx_rings(adapter);
1513 + /* Just clear the power down bit to wake the phy back up */
1514 + if (hw->media_type == iegbe_media_type_copper) {
1515 + /* according to the manual, the phy will retain its
1516 + * settings across a power-down/up cycle */
1517 + iegbe_read_phy_reg(hw, PHY_CTRL, &mii_reg);
1518 + mii_reg &= ~MII_CR_POWER_DOWN;
1519 + iegbe_write_phy_reg(hw, PHY_CTRL, mii_reg);
1520 + }
1521 +}
1522
1523 - /* If WoL is not enabled and management mode is not IAMT
1524 - * or if WoL is not enabled and OEM PHY is copper based,
1525 - * power down the PHY so no link is implied when interface is down */
1526 - if(!adapter->wol
1527 - && ((adapter->hw.mac_type >= iegbe_82540
1528 - && adapter->hw.media_type == iegbe_media_type_copper
1529 - && !iegbe_check_mng_mode(&adapter->hw)
1530 - && !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN))
1531 - || (adapter->hw.media_type == iegbe_media_type_oem
1532 - && iegbe_oem_phy_is_copper(&adapter->hw)))){
1533 +static void iegbe_power_down_phy(struct iegbe_adapter *adapter)
1534 +{
1535 + struct iegbe_hw *hw = &adapter->hw;
1536
1537 - uint16_t mii_reg;
1538 - iegbe_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
1539 + /* Power down the PHY so no link is implied when interface is down *
1540 + * The PHY cannot be powered down if any of the following is true *
1541 + * (a) WoL is enabled
1542 + * (b) AMT is active
1543 + * (c) SoL/IDER session is active */
1544 + if (!adapter->wol && hw->mac_type >= iegbe_82540 &&
1545 + hw->media_type == iegbe_media_type_copper) {
1546 + u16 mii_reg = 0;
1547 +
1548 + switch (hw->mac_type) {
1549 + case iegbe_82540:
1550 + case iegbe_82545:
1551 + case iegbe_82545_rev_3:
1552 + case iegbe_82546:
1553 + case iegbe_82546_rev_3:
1554 + case iegbe_82541:
1555 + case iegbe_82541_rev_2:
1556 + case iegbe_82547:
1557 + case iegbe_82547_rev_2:
1558 + if (E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN)
1559 + goto out;
1560 + break;
1561 + case iegbe_82571:
1562 + case iegbe_82572:
1563 + case iegbe_82573:
1564 + if (iegbe_check_mng_mode(hw) ||
1565 + iegbe_check_phy_reset_block(hw))
1566 + goto out;
1567 + break;
1568 + default:
1569 + goto out;
1570 + }
1571 + iegbe_read_phy_reg(hw, PHY_CTRL, &mii_reg);
1572 mii_reg |= MII_CR_POWER_DOWN;
1573 - iegbe_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
1574 + iegbe_write_phy_reg(hw, PHY_CTRL, mii_reg);
1575 mdelay(1);
1576 }
1577 +out:
1578 + return;
1579 }
1580
1581 -void
1582 -iegbe_reset(struct iegbe_adapter *adapter)
1583 +void iegbe_down(struct iegbe_adapter *adapter)
1584 {
1585 - struct net_device *netdev = adapter->netdev;
1586 - uint32_t pba, manc;
1587 - uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
1588 - uint16_t fc_low_water_mark = E1000_FC_LOW_DIFF;
1589 + struct net_device *netdev = adapter->netdev;
1590
1591 + /* signal that we're down so the interrupt handler does not
1592 + * reschedule our watchdog timer */
1593 + set_bit(__E1000_DOWN, &adapter->flags);
1594
1595 - /* Repartition Pba for greater than 9k mtu
1596 - * To take effect CTRL.RST is required.
1597 - */
1598 + napi_disable(&adapter->napi);
1599
1600 - switch (adapter->hw.mac_type) {
1601 - case iegbe_82547:
1602 - case iegbe_82547_rev_2:
1603 - pba = E1000_PBA_30K;
1604 - break;
1605 - case iegbe_82571:
1606 - case iegbe_82572:
1607 - pba = E1000_PBA_38K;
1608 - break;
1609 - case iegbe_82573:
1610 - pba = E1000_PBA_12K;
1611 + iegbe_irq_disable(adapter);
1612 +
1613 + del_timer_sync(&adapter->tx_fifo_stall_timer);
1614 + del_timer_sync(&adapter->watchdog_timer);
1615 + del_timer_sync(&adapter->phy_info_timer);
1616 +
1617 + netdev->tx_queue_len = adapter->tx_queue_len;
1618 + adapter->link_speed = 0;
1619 + adapter->link_duplex = 0;
1620 + netif_carrier_off(netdev);
1621 + netif_stop_queue(netdev);
1622 +
1623 + iegbe_reset(adapter);
1624 + iegbe_clean_all_tx_rings(adapter);
1625 + iegbe_clean_all_rx_rings(adapter);
1626 +}
1627 +void iegbe_reinit_locked(struct iegbe_adapter *adapter)
1628 +{
1629 + WARN_ON(in_interrupt());
1630 + while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
1631 + msleep(1);
1632 + iegbe_down(adapter);
1633 + iegbe_up(adapter);
1634 + clear_bit(__E1000_RESETTING, &adapter->flags);
1635 +}
1636 +
1637 +void iegbe_reset(struct iegbe_adapter *adapter)
1638 +{
1639 + struct iegbe_hw *hw = &adapter->hw;
1640 + u32 pba = 0, tx_space, min_tx_space, min_rx_space;
1641 + u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
1642 + bool legacy_pba_adjust = false;
1643 +
1644 + /* Repartition Pba for greater than 9k mtu
1645 + * To take effect CTRL.RST is required.
1646 + */
1647 +
1648 + switch (hw->mac_type) {
1649 + case iegbe_82542_rev2_0:
1650 + case iegbe_82542_rev2_1:
1651 + case iegbe_82543:
1652 + case iegbe_82544:
1653 + case iegbe_82540:
1654 + case iegbe_82541:
1655 + case iegbe_82541_rev_2:
1656 + case iegbe_icp_xxxx:
1657 + legacy_pba_adjust = true;
1658 + pba = E1000_PBA_48K;
1659 break;
1660 - default:
1661 + case iegbe_82545:
1662 + case iegbe_82545_rev_3:
1663 + case iegbe_82546:
1664 + case iegbe_82546_rev_3:
1665 pba = E1000_PBA_48K;
1666 break;
1667 - }
1668 + case iegbe_82547:
1669 + case iegbe_82573:
1670 + case iegbe_82547_rev_2:
1671 + legacy_pba_adjust = true;
1672 + pba = E1000_PBA_30K;
1673 + break;
1674 + case iegbe_82571:
1675 + case iegbe_82572:
1676 + case iegbe_undefined:
1677 + case iegbe_num_macs:
1678 + break;
1679 + }
1680 +
1681 + if (legacy_pba_adjust) {
1682 + if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
1683 + pba -= 8; /* allocate more FIFO for Tx */
1684 + /* send an XOFF when there is enough space in the
1685 + * Rx FIFO to hold one extra full size Rx packet
1686 + */
1687
1688 - if((adapter->hw.mac_type != iegbe_82573) &&
1689 - (adapter->rx_buffer_len > E1000_RXBUFFER_8192)) {
1690 - pba -= 0x8; /* allocate more FIFO for Tx */
1691 - /* send an XOFF when there is enough space in the
1692 - * Rx FIFO to hold one extra full size Rx packet
1693 - */
1694 - fc_high_water_mark = netdev->mtu + ENET_HEADER_SIZE +
1695 - ETHERNET_FCS_SIZE + 0x1;
1696 - fc_low_water_mark = fc_high_water_mark + 0x8;
1697 - }
1698
1699 + if (hw->mac_type == iegbe_82547) {
1700 + adapter->tx_fifo_head = 0;
1701 + adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
1702 + adapter->tx_fifo_size =
1703 + (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
1704 + atomic_set(&adapter->tx_fifo_stall, 0);
1705 + }
1706 + } else if (hw->max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
1707 + E1000_WRITE_REG(&adapter->hw, PBA, pba);
1708 +
1709 + /* To maintain wire speed transmits, the Tx FIFO should be
1710 + * large enough to accomodate two full transmit packets,
1711 + * rounded up to the next 1KB and expressed in KB. Likewise,
1712 + * the Rx FIFO should be large enough to accomodate at least
1713 + * one full receive packet and is similarly rounded up and
1714 + * expressed in KB. */
1715 + pba = E1000_READ_REG(&adapter->hw, PBA);
1716 + /* upper 16 bits has Tx packet buffer allocation size in KB */
1717 + tx_space = pba >> 16;
1718 + /* lower 16 bits has Rx packet buffer allocation size in KB */
1719 + pba &= 0xffff;
1720 + /* don't include ethernet FCS because hardware appends/strips */
1721 + min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE +
1722 + VLAN_TAG_SIZE;
1723 + min_tx_space = min_rx_space;
1724 + min_tx_space *= 2;
1725 + min_tx_space = ALIGN(min_tx_space, 1024);
1726 + min_tx_space >>= 10;
1727 + min_rx_space = ALIGN(min_rx_space, 1024);
1728 + min_rx_space >>= 10;
1729 +
1730 + /* If current Tx allocation is less than the min Tx FIFO size,
1731 + * and the min Tx FIFO size is less than the current Rx FIFO
1732 + * allocation, take space away from current Rx allocation */
1733 + if (tx_space < min_tx_space &&
1734 + ((min_tx_space - tx_space) < pba)) {
1735 + pba = pba - (min_tx_space - tx_space);
1736 +
1737 + /* PCI/PCIx hardware has PBA alignment constraints */
1738 + switch (hw->mac_type) {
1739 + case iegbe_82545 ... iegbe_82546_rev_3:
1740 + pba &= ~(E1000_PBA_8K - 1);
1741 + break;
1742 + default:
1743 + break;
1744 + }
1745
1746 - if(adapter->hw.mac_type == iegbe_82547) {
1747 - adapter->tx_fifo_head = 0;
1748 - adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
1749 - adapter->tx_fifo_size =
1750 - (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
1751 - atomic_set(&adapter->tx_fifo_stall, 0);
1752 + /* if short on rx space, rx wins and must trump tx
1753 + * adjustment or use Early Receive if available */
1754 + if (pba < min_rx_space) {
1755 + switch (hw->mac_type) {
1756 + case iegbe_82573:
1757 + /* ERT enabled in iegbe_configure_rx */
1758 + break;
1759 + default:
1760 + pba = min_rx_space;
1761 + break;
1762 + }
1763 + }
1764 + }
1765 }
1766
1767 E1000_WRITE_REG(&adapter->hw, PBA, pba);
1768
1769 /* flow control settings */
1770 - adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) -
1771 - fc_high_water_mark;
1772 - adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) -
1773 - fc_low_water_mark;
1774 - adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
1775 - adapter->hw.fc_send_xon = 1;
1776 - adapter->hw.fc = adapter->hw.original_fc;
1777 + /* Set the FC high water mark to 90% of the FIFO size.
1778 + * Required to clear last 3 LSB */
1779 + fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8;
1780 + /* We can't use 90% on small FIFOs because the remainder
1781 + * would be less than 1 full frame. In this case, we size
1782 + * it to allow at least a full frame above the high water
1783 + * mark. */
1784 + if (pba < E1000_PBA_16K)
1785 + fc_high_water_mark = (pba * 1024) - 1600;
1786 +
1787 + hw->fc_high_water = fc_high_water_mark;
1788 + hw->fc_low_water = fc_high_water_mark - 8;
1789 + hw->fc_pause_time = E1000_FC_PAUSE_TIME;
1790 + hw->fc_send_xon = 1;
1791 + hw->fc = hw->original_fc;
1792
1793 /* Allow time for pending master requests to run */
1794 - iegbe_reset_hw(&adapter->hw);
1795 - if(adapter->hw.mac_type >= iegbe_82544){
1796 + iegbe_reset_hw(hw);
1797 + if (hw->mac_type >= iegbe_82544)
1798 E1000_WRITE_REG(&adapter->hw, WUC, 0);
1799 - }
1800 - if(iegbe_init_hw(&adapter->hw)) {
1801 +
1802 + if (iegbe_init_hw(hw))
1803 DPRINTK(PROBE, ERR, "Hardware Error\n");
1804 - }
1805 -#ifdef NETIF_F_HW_VLAN_TX
1806 iegbe_update_mng_vlan(adapter);
1807 -#endif
1808 +
1809 + /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
1810 + if (hw->mac_type >= iegbe_82544 &&
1811 + hw->mac_type <= iegbe_82547_rev_2 &&
1812 + hw->autoneg == 1 &&
1813 + hw->autoneg_advertised == ADVERTISE_1000_FULL) {
1814 + u32 ctrl = E1000_READ_REG(&adapter->hw, CTRL);
1815 + /* clear phy power management bit if we are in gig only mode,
1816 + * which if enabled will attempt negotiation to 100Mb, which
1817 + * can cause a loss of link at power off or driver unload */
1818 + ctrl &= ~E1000_CTRL_SWDPIN3;
1819 + E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
1820 + }
1821 +
1822 /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
1823 E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
1824
1825 - iegbe_reset_adaptive(&adapter->hw);
1826 - iegbe_phy_get_info(&adapter->hw, &adapter->phy_info);
1827 - if(adapter->en_mng_pt) {
1828 - manc = E1000_READ_REG(&adapter->hw, MANC);
1829 - manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
1830 - E1000_WRITE_REG(&adapter->hw, MANC, manc);
1831 + iegbe_reset_adaptive(hw);
1832 + iegbe_phy_get_info(hw, &adapter->phy_info);
1833 +
1834 + if (!adapter->smart_power_down &&
1835 + (hw->mac_type == iegbe_82571 ||
1836 + hw->mac_type == iegbe_82572)) {
1837 + u16 phy_data = 0;
1838 + /* speed up time to link by disabling smart power down, ignore
1839 + * the return value of this function because there is nothing
1840 + * different we would do if it failed */
1841 + iegbe_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
1842 + &phy_data);
1843 + phy_data &= ~IGP02E1000_PM_SPD;
1844 + iegbe_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
1845 + phy_data);
1846 + }
1847 +
1848 +}
1849 +
1850 +/**
1851 + * Dump the eeprom for users having checksum issues
1852 + **/
1853 +static void iegbe_dump_eeprom(struct iegbe_adapter *adapter)
1854 +{
1855 + struct net_device *netdev = adapter->netdev;
1856 + struct ethtool_eeprom eeprom;
1857 + const struct ethtool_ops *ops = netdev->ethtool_ops;
1858 + u8 *data;
1859 + int i;
1860 + u16 csum_old, csum_new = 0;
1861 +
1862 + eeprom.len = ops->get_eeprom_len(netdev);
1863 + eeprom.offset = 0;
1864 +
1865 + data = kmalloc(eeprom.len, GFP_KERNEL);
1866 + if (!data) {
1867 + printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
1868 + " data\n");
1869 + return;
1870 }
1871 +
1872 + ops->get_eeprom(netdev, &eeprom, data);
1873 +
1874 + csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
1875 + (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
1876 + for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
1877 + csum_new += data[i] + (data[i + 1] << 8);
1878 + csum_new = EEPROM_SUM - csum_new;
1879 +
1880 + printk(KERN_ERR "/*********************/\n");
1881 + printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
1882 + printk(KERN_ERR "Calculated : 0x%04x\n", csum_new);
1883 +
1884 + printk(KERN_ERR "Offset Values\n");
1885 + printk(KERN_ERR "======== ======\n");
1886 + print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
1887 +
1888 + printk(KERN_ERR "Include this output when contacting your support "
1889 + "provider.\n");
1890 + printk(KERN_ERR "This is not a software error! Something bad "
1891 + "happened to your hardware or\n");
1892 + printk(KERN_ERR "EEPROM image. Ignoring this "
1893 + "problem could result in further problems,\n");
1894 + printk(KERN_ERR "possibly loss of data, corruption or system hangs!\n");
1895 + printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
1896 + "which is invalid\n");
1897 + printk(KERN_ERR "and requires you to set the proper MAC "
1898 + "address manually before continuing\n");
1899 + printk(KERN_ERR "to enable this network device.\n");
1900 + printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
1901 + "to your hardware vendor\n");
1902 + printk(KERN_ERR "or Intel Customer Support.\n");
1903 + printk(KERN_ERR "/*********************/\n");
1904 +
1905 + kfree(data);
1906 }
1907
1908 /**
1909 @@ -721,184 +735,166 @@ iegbe_reset(struct iegbe_adapter *adapte
1910 * The OS initialization, configuring of the adapter private structure,
1911 * and a hardware reset occur.
1912 **/
1913 -
1914 -static int __devinit
1915 -iegbe_probe(struct pci_dev *pdev,
1916 +static int __devinit iegbe_probe(struct pci_dev *pdev,
1917 const struct pci_device_id *ent)
1918 {
1919 - struct net_device *netdev;
1920 - struct iegbe_adapter *adapter;
1921 - unsigned long mmio_start, mmio_len;
1922 - uint32_t ctrl_ext;
1923 - uint32_t swsm;
1924 + struct net_device *netdev;
1925 + struct iegbe_adapter *adapter;
1926 + struct iegbe_hw *hw;
1927
1928 static int cards_found = 0;
1929 + int i, err, pci_using_dac;
1930 + u16 eeprom_data = 0;
1931 + u16 eeprom_apme_mask = E1000_EEPROM_APME;
1932 + int bars;
1933 + DECLARE_MAC_BUF(mac);
1934
1935 - int i, err, pci_using_dac;
1936 - uint16_t eeprom_data = 0;
1937 - uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
1938 + bars = pci_select_bars(pdev, IORESOURCE_MEM);
1939 + err = pci_enable_device(pdev);
1940
1941 + if (err)
1942 + return err;
1943
1944 - if((err = pci_enable_device(pdev))) {
1945 - return err;
1946 - }
1947 - if(!(err = pci_set_dma_mask(pdev, PCI_DMA_64BIT))) {
1948 + if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
1949 + !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
1950 pci_using_dac = 1;
1951 - } else {
1952 - if((err = pci_set_dma_mask(pdev, PCI_DMA_32BIT))) {
1953 - E1000_ERR("No usable DMA configuration, aborting\n");
1954 - return err;
1955 - }
1956 + } else {
1957 + err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
1958 + if (err) {
1959 + err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
1960 + if (err) {
1961 + E1000_ERR("No usable DMA configuration, "
1962 + "aborting\n");
1963 + goto err_dma;
1964 + }
1965 + }
1966 pci_using_dac = 0;
1967 - }
1968 -
1969 - if((err = pci_request_regions(pdev, iegbe_driver_name))) {
1970 - return err;
1971 }
1972 - pci_set_master(pdev);
1973
1974 - netdev = alloc_etherdev(sizeof(struct iegbe_adapter));
1975 - if(!netdev) {
1976 - err = -ENOMEM;
1977 - goto err_alloc_etherdev;
1978 - }
1979 + err = pci_request_selected_regions(pdev, bars, iegbe_driver_name);
1980 + if (err)
1981 + goto err_pci_reg;
1982 +
1983 + pci_set_master(pdev);
1984 +
1985 + err = -ENOMEM;
1986 + netdev = alloc_etherdev(sizeof(struct iegbe_adapter));
1987 + if (!netdev)
1988 + goto err_alloc_etherdev;
1989
1990 - SET_MODULE_OWNER(netdev);
1991 SET_NETDEV_DEV(netdev, &pdev->dev);
1992
1993 - pci_set_drvdata(pdev, netdev);
1994 - adapter = netdev_priv(netdev);
1995 - adapter->netdev = netdev;
1996 - adapter->pdev = pdev;
1997 - adapter->hw.back = adapter;
1998 - adapter->msg_enable = (0x1 << debug) - 0x1;
1999 -
2000 - mmio_start = pci_resource_start(pdev, BAR_0);
2001 - mmio_len = pci_resource_len(pdev, BAR_0);
2002 -
2003 - adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
2004 - if(!adapter->hw.hw_addr) {
2005 - err = -EIO;
2006 - goto err_ioremap;
2007 - }
2008 -
2009 - for(i = BAR_1; i <= BAR_5; i++) {
2010 - if(pci_resource_len(pdev, i) == 0) {
2011 - continue;
2012 - }
2013 - if(pci_resource_flags(pdev, i) & IORESOURCE_IO) {
2014 - adapter->hw.io_base = pci_resource_start(pdev, i);
2015 - break;
2016 - }
2017 - }
2018 -
2019 - netdev->open = &iegbe_open;
2020 - netdev->stop = &iegbe_close;
2021 - netdev->hard_start_xmit = &iegbe_xmit_frame;
2022 - netdev->get_stats = &iegbe_get_stats;
2023 - netdev->set_multicast_list = &iegbe_set_multi;
2024 + pci_set_drvdata(pdev, netdev);
2025 + adapter = netdev_priv(netdev);
2026 + adapter->netdev = netdev;
2027 + adapter->pdev = pdev;
2028 + adapter->msg_enable = (1 << debug) - 1;
2029 + adapter->bars = bars;
2030 +
2031 + hw = &adapter->hw;
2032 + hw->back = adapter;
2033 +
2034 + err = -EIO;
2035 + hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
2036 + pci_resource_len(pdev, BAR_0));
2037 + if (!hw->hw_addr)
2038 + goto err_ioremap;
2039 +
2040 + netdev->open = &iegbe_open;
2041 + netdev->stop = &iegbe_close;
2042 + netdev->hard_start_xmit = &iegbe_xmit_frame;
2043 + netdev->get_stats = &iegbe_get_stats;
2044 + netdev->set_rx_mode = &iegbe_set_rx_mode;
2045 netdev->set_mac_address = &iegbe_set_mac;
2046 - netdev->change_mtu = &iegbe_change_mtu;
2047 - netdev->do_ioctl = &iegbe_ioctl;
2048 + netdev->change_mtu = &iegbe_change_mtu;
2049 + netdev->do_ioctl = &iegbe_ioctl;
2050 set_ethtool_ops(netdev);
2051 -#ifdef HAVE_TX_TIMEOUT
2052 - netdev->tx_timeout = &iegbe_tx_timeout;
2053 - netdev->watchdog_timeo = 0x5 * HZ;
2054 -#endif
2055 -#ifdef CONFIG_E1000_NAPI
2056 - netdev->poll = &iegbe_clean;
2057 - netdev->weight = 0x40;
2058 -#endif
2059 -#ifdef NETIF_F_HW_VLAN_TX
2060 - netdev->vlan_rx_register = iegbe_vlan_rx_register;
2061 - netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
2062 - netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
2063 -#endif
2064 + netdev->tx_timeout = &iegbe_tx_timeout;
2065 + netdev->watchdog_timeo = 5 * HZ;
2066 + netif_napi_add(netdev, &adapter->napi, iegbe_clean, 64);
2067 + netdev->vlan_rx_register = iegbe_vlan_rx_register;
2068 + netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
2069 + netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
2070 #ifdef CONFIG_NET_POLL_CONTROLLER
2071 - netdev->poll_controller = iegbe_netpoll;
2072 + netdev->poll_controller = iegbe_netpoll;
2073 #endif
2074 - strcpy(netdev->name, pci_name(pdev));
2075 + strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
2076
2077 - netdev->mem_start = mmio_start;
2078 - netdev->mem_end = mmio_start + mmio_len;
2079 - netdev->base_addr = adapter->hw.io_base;
2080
2081 - adapter->bd_number = cards_found;
2082 + adapter->bd_number = cards_found;
2083
2084 - /* setup the private structure */
2085 + /* setup the private structure */
2086
2087 - if((err = iegbe_sw_init(adapter))) {
2088 - goto err_sw_init;
2089 - }
2090 - if((err = iegbe_check_phy_reset_block(&adapter->hw))) {
2091 - DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
2092 - }
2093 -#ifdef MAX_SKB_FRAGS
2094 - if(adapter->hw.mac_type >= iegbe_82543) {
2095 -#ifdef NETIF_F_HW_VLAN_TX
2096 - netdev->features = NETIF_F_SG |
2097 - NETIF_F_HW_CSUM |
2098 - NETIF_F_HW_VLAN_TX |
2099 - NETIF_F_HW_VLAN_RX |
2100 - NETIF_F_HW_VLAN_FILTER;
2101 -#else
2102 - netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM;
2103 -#endif
2104 - }
2105 + err = iegbe_sw_init(adapter);
2106 + if (err)
2107 + goto err_sw_init;
2108 + err = -EIO;
2109 + if (iegbe_check_phy_reset_block(hw))
2110 + DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
2111
2112 -#ifdef NETIF_F_TSO
2113 - if((adapter->hw.mac_type >= iegbe_82544) &&
2114 - (adapter->hw.mac_type != iegbe_82547)) {
2115 - netdev->features |= NETIF_F_TSO;
2116 - }
2117 -#ifdef NETIF_F_TSO_IPV6
2118 - if(adapter->hw.mac_type > iegbe_82547_rev_2) {
2119 - netdev->features |= NETIF_F_TSO_IPV6;
2120 - }
2121 -#endif
2122 -#endif
2123 - if(pci_using_dac) {
2124 - netdev->features |= NETIF_F_HIGHDMA;
2125 + if (hw->mac_type >= iegbe_82543) {
2126 + netdev->features = NETIF_F_SG |
2127 + NETIF_F_HW_CSUM |
2128 + NETIF_F_HW_VLAN_TX |
2129 + NETIF_F_HW_VLAN_RX |
2130 + NETIF_F_HW_VLAN_FILTER;
2131 }
2132 -#endif
2133 -#ifdef NETIF_F_LLTX
2134 - netdev->features |= NETIF_F_LLTX;
2135 -#endif
2136
2137 - adapter->en_mng_pt = iegbe_enable_mng_pass_thru(&adapter->hw);
2138 + if ((hw->mac_type >= iegbe_82544) &&
2139 + (hw->mac_type != iegbe_82547))
2140 + netdev->features |= NETIF_F_TSO;
2141
2142 - /* before reading the EEPROM, reset the controller to
2143 - * put the device in a known good starting state */
2144 + if (hw->mac_type > iegbe_82547_rev_2)
2145 + netdev->features |= NETIF_F_TSO6;
2146 + if (pci_using_dac)
2147 + netdev->features |= NETIF_F_HIGHDMA;
2148 +
2149 + netdev->features |= NETIF_F_LLTX;
2150
2151 - iegbe_reset_hw(&adapter->hw);
2152 + adapter->en_mng_pt = iegbe_enable_mng_pass_thru(hw);
2153
2154 - /* make sure the EEPROM is good */
2155 - if(iegbe_validate_eeprom_checksum(&adapter->hw) < 0) {
2156 - DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
2157 - err = -EIO;
2158 + /* initialize eeprom parameters */
2159 +
2160 + if (iegbe_init_eeprom_params(hw)) {
2161 + E1000_ERR("EEPROM initialization failed\n");
2162 goto err_eeprom;
2163 }
2164
2165 - /* copy the MAC address out of the EEPROM */
2166 + /* before reading the EEPROM, reset the controller to
2167 + * put the device in a known good starting state */
2168
2169 - if(iegbe_read_mac_addr(&adapter->hw)) {
2170 - DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
2171 - }
2172 - memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
2173 + iegbe_reset_hw(hw);
2174
2175 - if(!is_valid_ether_addr(netdev->dev_addr)) {
2176 - DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
2177 - err = -EIO;
2178 - goto err_eeprom;
2179 - }
2180 + /* make sure the EEPROM is good */
2181 + if (iegbe_validate_eeprom_checksum(hw) < 0) {
2182 + DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
2183 + iegbe_dump_eeprom(adapter);
2184 + /*
2185 + * set MAC address to all zeroes to invalidate and temporary
2186 + * disable this device for the user. This blocks regular
2187 + * traffic while still permitting ethtool ioctls from reaching
2188 + * the hardware as well as allowing the user to run the
2189 + * interface after manually setting a hw addr using
2190 + * `ip set address`
2191 + */
2192 + memset(hw->mac_addr, 0, netdev->addr_len);
2193 + } else {
2194 + /* copy the MAC address out of the EEPROM */
2195 + if (iegbe_read_mac_addr(hw))
2196 + DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
2197 + }
2198 + /* don't block initalization here due to bad MAC address */
2199 + memcpy(netdev->dev_addr, hw->mac_addr, netdev->addr_len);
2200 + memcpy(netdev->perm_addr, hw->mac_addr, netdev->addr_len);
2201
2202 - iegbe_read_part_num(&adapter->hw, &(adapter->part_num));
2203 + if (!is_valid_ether_addr(netdev->perm_addr))
2204 + DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
2205
2206 - iegbe_get_bus_info(&adapter->hw);
2207 + iegbe_get_bus_info(hw);
2208
2209 init_timer(&adapter->tx_fifo_stall_timer);
2210 adapter->tx_fifo_stall_timer.function = &iegbe_82547_tx_fifo_stall;
2211 - adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
2212 + adapter->tx_fifo_stall_timer.data = (unsigned long)adapter;
2213
2214 init_timer(&adapter->watchdog_timer);
2215 adapter->watchdog_timer.function = &iegbe_watchdog;
2216 @@ -906,75 +902,50 @@ iegbe_probe(struct pci_dev *pdev,
2217
2218 init_timer(&adapter->phy_info_timer);
2219 adapter->phy_info_timer.function = &iegbe_update_phy_info;
2220 - adapter->phy_info_timer.data = (unsigned long) adapter;
2221 -
2222 - INIT_WORK(&adapter->tx_timeout_task,
2223 - (void (*)(void *))iegbe_tx_timeout_task, netdev);
2224 + adapter->phy_info_timer.data = (unsigned long)adapter;
2225
2226 - /* we're going to reset, so assume we have no link for now */
2227 -
2228 - netif_carrier_off(netdev);
2229 - netif_stop_queue(netdev);
2230 + INIT_WORK(&adapter->reset_task, iegbe_reset_task);
2231
2232 - iegbe_check_options(adapter);
2233 + iegbe_check_options(adapter);
2234
2235 - /* Initial Wake on LAN setting
2236 - * If APM wake is enabled in the EEPROM,
2237 - * enable the ACPI Magic Packet filter
2238 - */
2239 + /* Initial Wake on LAN setting
2240 + * If APM wake is enabled in the EEPROM,
2241 + * enable the ACPI Magic Packet filter
2242 + */
2243
2244 - switch(adapter->hw.mac_type) {
2245 - case iegbe_82542_rev2_0:
2246 - case iegbe_82542_rev2_1:
2247 - case iegbe_82543:
2248 - break;
2249 - case iegbe_82544:
2250 - iegbe_read_eeprom(&adapter->hw,
2251 - EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
2252 - eeprom_apme_mask = E1000_EEPROM_82544_APM;
2253 - break;
2254 + switch(adapter->hw.mac_type) {
2255 + case iegbe_82542_rev2_0:
2256 + case iegbe_82542_rev2_1:
2257 + case iegbe_82543:
2258 + break;
2259 + case iegbe_82544:
2260 + iegbe_read_eeprom(&adapter->hw,
2261 + EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
2262 + eeprom_apme_mask = E1000_EEPROM_82544_APM;
2263 + break;
2264 case iegbe_icp_xxxx:
2265 - iegbe_read_eeprom(&adapter->hw,
2266 - EEPROM_INIT_CONTROL3_ICP_xxxx(adapter->bd_number),
2267 - 1, &eeprom_data);
2268 - eeprom_apme_mask = EEPROM_CTRL3_APME_ICP_xxxx;
2269 - break;
2270 - case iegbe_82546:
2271 - case iegbe_82546_rev_3:
2272 - if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
2273 - && (adapter->hw.media_type == iegbe_media_type_copper)) {
2274 - iegbe_read_eeprom(&adapter->hw,
2275 - EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
2276 - break;
2277 - }
2278 - /* Fall Through */
2279 - default:
2280 - iegbe_read_eeprom(&adapter->hw,
2281 - EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
2282 - break;
2283 - }
2284 + iegbe_read_eeprom(&adapter->hw,
2285 + EEPROM_INIT_CONTROL3_ICP_xxxx(adapter->bd_number),
2286 + 1, &eeprom_data);
2287 + eeprom_apme_mask = EEPROM_CTRL3_APME_ICP_xxxx;
2288 + break;
2289 + case iegbe_82546:
2290 + case iegbe_82546_rev_3:
2291 + if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
2292 + && (adapter->hw.media_type == iegbe_media_type_copper)) {
2293 + iegbe_read_eeprom(&adapter->hw,
2294 + EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
2295 + break;
2296 + }
2297 + /* Fall Through */
2298 + default:
2299 + iegbe_read_eeprom(&adapter->hw,
2300 + EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
2301 + break;
2302 + }
2303 if(eeprom_data & eeprom_apme_mask) {
2304 - adapter->wol |= E1000_WUFC_MAG;
2305 + adapter->wol |= E1000_WUFC_MAG;
2306 }
2307 - /* reset the hardware with the new settings */
2308 - iegbe_reset(adapter);
2309 -
2310 - /* Let firmware know the driver has taken over */
2311 - switch(adapter->hw.mac_type) {
2312 - case iegbe_82571:
2313 - case iegbe_82572:
2314 - ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
2315 - E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
2316 - ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
2317 - break;
2318 - case iegbe_82573:
2319 - swsm = E1000_READ_REG(&adapter->hw, SWSM);
2320 - E1000_WRITE_REG(&adapter->hw, SWSM,
2321 - swsm | E1000_SWSM_DRV_LOAD);
2322 - break;
2323 - default:
2324 - break;
2325 - }
2326
2327 /* The ICP_xxxx device has multiple, duplicate interrupt
2328 * registers, so disable all but the first one
2329 @@ -987,24 +958,40 @@ iegbe_probe(struct pci_dev *pdev,
2330 E1000_WRITE_REG(&adapter->hw, IMC2, ~0UL);
2331 }
2332
2333 - strcpy(netdev->name, "eth%d");
2334 - if((err = register_netdev(netdev))) {
2335 - goto err_register;
2336 - }
2337 + iegbe_reset(adapter);
2338 + netif_carrier_off(netdev);
2339 + netif_stop_queue(netdev);
2340 + strcpy(netdev->name, "eth%d");
2341 + err = register_netdev(netdev);
2342 + if (err)
2343 + goto err_register;
2344 +
2345 DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
2346
2347 - cards_found++;
2348 - return 0;
2349 + cards_found++;
2350 + return 0;
2351
2352 err_register:
2353 -err_sw_init:
2354 err_eeprom:
2355 - iounmap(adapter->hw.hw_addr);
2356 + if (!iegbe_check_phy_reset_block(hw))
2357 + iegbe_phy_hw_reset(hw);
2358 + if (hw->flash_address)
2359 + iounmap(hw->flash_address);
2360 + for (i = 0; i < adapter->num_rx_queues; i++)
2361 + dev_put(&adapter->polling_netdev[i]);
2362 + kfree(adapter->tx_ring);
2363 + kfree(adapter->rx_ring);
2364 + kfree(adapter->polling_netdev);
2365 +err_sw_init:
2366 + iounmap(hw->hw_addr);
2367 err_ioremap:
2368 - free_netdev(netdev);
2369 + free_netdev(netdev);
2370 err_alloc_etherdev:
2371 - pci_release_regions(pdev);
2372 - return err;
2373 + pci_release_selected_regions(pdev, bars);
2374 +err_pci_reg:
2375 +err_dma:
2376 + pci_disable_device(pdev);
2377 + return err;
2378 }
2379
2380 /**
2381 @@ -1020,64 +1007,36 @@ err_alloc_etherdev:
2382 static void __devexit
2383 iegbe_remove(struct pci_dev *pdev)
2384 {
2385 - struct net_device *netdev = pci_get_drvdata(pdev);
2386 - struct iegbe_adapter *adapter = netdev_priv(netdev);
2387 - uint32_t ctrl_ext;
2388 - uint32_t manc, swsm;
2389 -#ifdef CONFIG_E1000_NAPI
2390 - int i;
2391 -#endif
2392 -
2393 - if(adapter->hw.mac_type >= iegbe_82540
2394 - && adapter->hw.mac_type != iegbe_icp_xxxx
2395 - && adapter->hw.media_type == iegbe_media_type_copper) {
2396 - manc = E1000_READ_REG(&adapter->hw, MANC);
2397 - if(manc & E1000_MANC_SMBUS_EN) {
2398 - manc |= E1000_MANC_ARP_EN;
2399 - E1000_WRITE_REG(&adapter->hw, MANC, manc);
2400 - }
2401 - }
2402 -
2403 - switch(adapter->hw.mac_type) {
2404 - case iegbe_82571:
2405 - case iegbe_82572:
2406 - ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
2407 - E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
2408 - ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
2409 - break;
2410 - case iegbe_82573:
2411 - swsm = E1000_READ_REG(&adapter->hw, SWSM);
2412 - E1000_WRITE_REG(&adapter->hw, SWSM,
2413 - swsm & ~E1000_SWSM_DRV_LOAD);
2414 - break;
2415 -
2416 - default:
2417 - break;
2418 - }
2419 + struct net_device *netdev = pci_get_drvdata(pdev);
2420 + struct iegbe_adapter *adapter = netdev_priv(netdev);
2421 + uint32_t manc;
2422 + int i;
2423 +
2424 + if(adapter->hw.mac_type >= iegbe_82540
2425 + && adapter->hw.mac_type != iegbe_icp_xxxx
2426 + && adapter->hw.media_type == iegbe_media_type_copper) {
2427 + manc = E1000_READ_REG(&adapter->hw, MANC);
2428 + if(manc & E1000_MANC_SMBUS_EN) {
2429 + manc |= E1000_MANC_ARP_EN;
2430 + E1000_WRITE_REG(&adapter->hw, MANC, manc);
2431 + }
2432 + }
2433
2434 - unregister_netdev(netdev);
2435 -#ifdef CONFIG_E1000_NAPI
2436 - for (i = 0; i < adapter->num_queues; i++)
2437 + unregister_netdev(netdev);
2438 + for (i = 0x0; i < adapter->num_rx_queues; i++)
2439 dev_put(&adapter->polling_netdev[i]);
2440 -#endif
2441
2442 if(!iegbe_check_phy_reset_block(&adapter->hw)) {
2443 - iegbe_phy_hw_reset(&adapter->hw);
2444 + iegbe_phy_hw_reset(&adapter->hw);
2445 }
2446 - kfree(adapter->tx_ring);
2447 - kfree(adapter->rx_ring);
2448 -#ifdef CONFIG_E1000_NAPI
2449 - kfree(adapter->polling_netdev);
2450 -#endif
2451 + kfree(adapter->tx_ring);
2452 + kfree(adapter->rx_ring);
2453 + kfree(adapter->polling_netdev);
2454
2455 - iounmap(adapter->hw.hw_addr);
2456 - pci_release_regions(pdev);
2457 + iounmap(adapter->hw.hw_addr);
2458 + pci_release_regions(pdev);
2459
2460 -#ifdef CONFIG_E1000_MQ
2461 - free_percpu(adapter->cpu_netdev);
2462 - free_percpu(adapter->cpu_tx_ring);
2463 -#endif
2464 - free_netdev(netdev);
2465 + free_netdev(netdev);
2466 }
2467
2468 /**
2469 @@ -1092,118 +1051,78 @@ iegbe_remove(struct pci_dev *pdev)
2470 static int __devinit
2471 iegbe_sw_init(struct iegbe_adapter *adapter)
2472 {
2473 - struct iegbe_hw *hw = &adapter->hw;
2474 - struct net_device *netdev = adapter->netdev;
2475 - struct pci_dev *pdev = adapter->pdev;
2476 -#ifdef CONFIG_E1000_NAPI
2477 - int i;
2478 -#endif
2479 + struct iegbe_hw *hw = &adapter->hw;
2480 + struct net_device *netdev = adapter->netdev;
2481 + struct pci_dev *pdev = adapter->pdev;
2482 + int i;
2483
2484 - /* PCI config space info */
2485 + /* PCI config space info */
2486
2487 - hw->vendor_id = pdev->vendor;
2488 - hw->device_id = pdev->device;
2489 - hw->subsystem_vendor_id = pdev->subsystem_vendor;
2490 - hw->subsystem_id = pdev->subsystem_device;
2491 + hw->vendor_id = pdev->vendor;
2492 + hw->device_id = pdev->device;
2493 + hw->subsystem_vendor_id = pdev->subsystem_vendor;
2494 + hw->subsystem_id = pdev->subsystem_device;
2495
2496 - pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
2497 + pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
2498
2499 - pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
2500 + pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
2501
2502 - adapter->rx_buffer_len = E1000_RXBUFFER_2048;
2503 - adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
2504 - hw->max_frame_size = netdev->mtu +
2505 - ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
2506 - hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
2507 + adapter->rx_buffer_len = E1000_RXBUFFER_2048;
2508 + adapter->rx_ps_bsize0 = E1000_RXBUFFER_256;
2509 + hw->max_frame_size = netdev->mtu +
2510 + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
2511 + hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
2512
2513 - /* identify the MAC */
2514 + /* identify the MAC */
2515
2516 - if(iegbe_set_mac_type(hw)) {
2517 + if (iegbe_set_mac_type(hw)) {
2518 DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
2519 return -EIO;
2520 }
2521
2522 - /* initialize eeprom parameters */
2523 -
2524 - if(iegbe_init_eeprom_params(hw)) {
2525 - E1000_ERR("EEPROM initialization failed\n");
2526 - return -EIO;
2527 - }
2528 -
2529 - switch(hw->mac_type) {
2530 - default:
2531 - break;
2532 - case iegbe_82541:
2533 - case iegbe_82547:
2534 - case iegbe_82541_rev_2:
2535 - case iegbe_82547_rev_2:
2536 - hw->phy_init_script = 0x1;
2537 - break;
2538 - }
2539 -
2540 - iegbe_set_media_type(hw);
2541 + iegbe_set_media_type(hw);
2542
2543 - hw->wait_autoneg_complete = FALSE;
2544 - hw->tbi_compatibility_en = TRUE;
2545 - hw->adaptive_ifs = TRUE;
2546 + hw->wait_autoneg_complete = FALSE;
2547 + hw->tbi_compatibility_en = TRUE;
2548 + hw->adaptive_ifs = TRUE;
2549
2550 - /* Copper options */
2551 + /* Copper options */
2552
2553 - if(hw->media_type == iegbe_media_type_copper
2554 + if(hw->media_type == iegbe_media_type_copper
2555 || (hw->media_type == iegbe_media_type_oem
2556 && iegbe_oem_phy_is_copper(&adapter->hw))) {
2557 - hw->mdix = AUTO_ALL_MODES;
2558 - hw->disable_polarity_correction = FALSE;
2559 - hw->master_slave = E1000_MASTER_SLAVE;
2560 - }
2561 + hw->mdix = AUTO_ALL_MODES;
2562 + hw->disable_polarity_correction = FALSE;
2563 + hw->master_slave = E1000_MASTER_SLAVE;
2564 + }
2565
2566 -#ifdef CONFIG_E1000_MQ
2567 - /* Number of supported queues */
2568 - switch (hw->mac_type) {
2569 - case iegbe_82571:
2570 - case iegbe_82572:
2571 - adapter->num_queues = 0x2;
2572 - break;
2573 - default:
2574 - adapter->num_queues = 0x1;
2575 - break;
2576 - }
2577 - adapter->num_queues = min(adapter->num_queues, num_online_cpus());
2578 -#else
2579 - adapter->num_queues = 0x1;
2580 -#endif
2581 + adapter->num_tx_queues = 0x1;
2582 + adapter->num_rx_queues = 0x1;
2583
2584 if (iegbe_alloc_queues(adapter)) {
2585 DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
2586 return -ENOMEM;
2587 }
2588
2589 -#ifdef CONFIG_E1000_NAPI
2590 - for (i = 0; i < adapter->num_queues; i++) {
2591 + for (i = 0; i < adapter->num_rx_queues; i++) {
2592 adapter->polling_netdev[i].priv = adapter;
2593 - adapter->polling_netdev[i].poll = &iegbe_clean;
2594 - adapter->polling_netdev[i].weight = 0x40;
2595 dev_hold(&adapter->polling_netdev[i]);
2596 set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
2597 }
2598 -#endif
2599 -
2600 -#ifdef CONFIG_E1000_MQ
2601 - iegbe_setup_queue_mapping(adapter);
2602 -#endif
2603 + spin_lock_init(&adapter->tx_queue_lock);
2604
2605 /*
2606 - * for ICP_XXXX style controllers, it is necessary to keep
2607 - * track of the last known state of the link to determine if
2608 - * the link experienced a change in state when iegbe_watchdog
2609 - * fires
2610 - */
2611 - adapter->hw.icp_xxxx_is_link_up = FALSE;
2612 + * for ICP_XXXX style controllers, it is necessary to keep
2613 + * track of the last known state of the link to determine if
2614 + * the link experienced a change in state when iegbe_watchdog
2615 + * fires
2616 + */
2617 + adapter->hw.icp_xxxx_is_link_up = FALSE;
2618
2619 - atomic_set(&adapter->irq_sem, 1);
2620 - spin_lock_init(&adapter->stats_lock);
2621 + spin_lock_init(&adapter->stats_lock);
2622
2623 - return 0;
2624 + set_bit(__E1000_DOWN, &adapter->flags);
2625 + return 0x0;
2626 }
2627
2628 /**
2629 @@ -1218,71 +1137,31 @@ iegbe_sw_init(struct iegbe_adapter *adap
2630 static int __devinit
2631 iegbe_alloc_queues(struct iegbe_adapter *adapter)
2632 {
2633 - int size;
2634
2635 - size = sizeof(struct iegbe_tx_ring) * adapter->num_queues;
2636 - adapter->tx_ring = kmalloc(size, GFP_KERNEL);
2637 - if (!adapter->tx_ring){
2638 +
2639 + adapter->tx_ring = kcalloc(adapter->num_tx_queues,
2640 + sizeof(struct iegbe_tx_ring), GFP_KERNEL);
2641 + if (!adapter->tx_ring)
2642 return -ENOMEM;
2643 - }
2644 - memset(adapter->tx_ring, 0, size);
2645
2646 - size = sizeof(struct iegbe_rx_ring) * adapter->num_queues;
2647 - adapter->rx_ring = kmalloc(size, GFP_KERNEL);
2648 + adapter->rx_ring = kcalloc(adapter->num_rx_queues,
2649 + sizeof(struct iegbe_rx_ring), GFP_KERNEL);
2650 if (!adapter->rx_ring) {
2651 kfree(adapter->tx_ring);
2652 return -ENOMEM;
2653 }
2654 - memset(adapter->rx_ring, 0, size);
2655
2656 -#ifdef CONFIG_E1000_NAPI
2657 - size = sizeof(struct net_device) * adapter->num_queues;
2658 - adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
2659 + adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
2660 + sizeof(struct net_device),
2661 + GFP_KERNEL);
2662 if (!adapter->polling_netdev) {
2663 kfree(adapter->tx_ring);
2664 kfree(adapter->rx_ring);
2665 return -ENOMEM;
2666 }
2667 - memset(adapter->polling_netdev, 0, size);
2668 -#endif
2669 -
2670 - return E1000_SUCCESS;
2671 -}
2672
2673 -#ifdef CONFIG_E1000_MQ
2674 -static void __devinit
2675 -iegbe_setup_queue_mapping(struct iegbe_adapter *adapter)
2676 -{
2677 - int i, cpu;
2678 -
2679 - adapter->rx_sched_call_data.func = iegbe_rx_schedule;
2680 - adapter->rx_sched_call_data.info = adapter->netdev;
2681 - cpus_clear(adapter->rx_sched_call_data.cpumask);
2682 -
2683 - adapter->cpu_netdev = alloc_percpu(struct net_device *);
2684 - adapter->cpu_tx_ring = alloc_percpu(struct iegbe_tx_ring *);
2685 -
2686 - lock_cpu_hotplug();
2687 - i = 0;
2688 - for_each_online_cpu(cpu) {
2689 - *per_cpu_ptr(adapter->cpu_tx_ring, cpu) =
2690 - &adapter->tx_ring[i % adapter->num_queues];
2691 - /* This is incomplete because we'd like to assign separate
2692 - * physical cpus to these netdev polling structures and
2693 - * avoid saturating a subset of cpus.
2694 - */
2695 - if (i < adapter->num_queues) {
2696 - *per_cpu_ptr(adapter->cpu_netdev, cpu) =
2697 - &adapter->polling_netdev[i];
2698 - adapter->cpu_for_queue[i] = cpu;
2699 - } else {
2700 - *per_cpu_ptr(adapter->cpu_netdev, cpu) = NULL;
2701 - }
2702 - i++;
2703 - }
2704 - unlock_cpu_hotplug();
2705 + return E1000_SUCCESS;
2706 }
2707 -#endif
2708
2709 /**
2710 * iegbe_open - Called when a network interface is made active
2711 @@ -1300,40 +1179,62 @@ iegbe_setup_queue_mapping(struct iegbe_a
2712 static int
2713 iegbe_open(struct net_device *netdev)
2714 {
2715 - struct iegbe_adapter *adapter = netdev_priv(netdev);
2716 - int err;
2717 + struct iegbe_adapter *adapter = netdev_priv(netdev);
2718 + struct iegbe_hw *hw = &adapter->hw;
2719 + int err;
2720 +
2721
2722 + /* allocate receive descriptors */
2723 + if (test_bit(__E1000_TESTING, &adapter->flags))
2724 + return -EBUSY;
2725
2726 - /* allocate receive descriptors */
2727 + /* allocate transmit descriptors */
2728 + err = iegbe_setup_all_tx_resources(adapter);
2729 + if (err)
2730 + goto err_setup_tx;
2731
2732 - if ((err = iegbe_setup_all_rx_resources(adapter))) {
2733 + err = iegbe_setup_all_rx_resources(adapter);
2734 + if (err)
2735 goto err_setup_rx;
2736 - }
2737 - /* allocate transmit descriptors */
2738 - if ((err = iegbe_setup_all_tx_resources(adapter))) {
2739 - goto err_setup_tx;
2740 - }
2741 - if ((err = iegbe_up(adapter))) {
2742 - goto err_up;
2743 - }
2744 -#ifdef NETIF_F_HW_VLAN_TX
2745 - adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
2746 - if ((adapter->hw.mng_cookie.status &
2747 - E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
2748 - iegbe_update_mng_vlan(adapter);
2749 - }
2750 -#endif
2751
2752 - return E1000_SUCCESS;
2753 + iegbe_power_up_phy(adapter);
2754 + adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
2755 + if ((hw->mng_cookie.status &
2756 + E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
2757 + iegbe_update_mng_vlan(adapter);
2758 + }
2759 +
2760 + /* before we allocate an interrupt, we must be ready to handle it.
2761 + * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
2762 + * as soon as we call pci_request_irq, so we have to setup our
2763 + * clean_rx handler before we do so. */
2764 + iegbe_configure(adapter);
2765 + err = iegbe_request_irq(adapter);
2766 + if (err)
2767 + goto err_req_irq;
2768
2769 -err_up:
2770 - iegbe_free_all_tx_resources(adapter);
2771 -err_setup_tx:
2772 - iegbe_free_all_rx_resources(adapter);
2773 + /* From here on the code is the same as iegbe_up() */
2774 + clear_bit(__E1000_DOWN, &adapter->flags);
2775 +
2776 + napi_enable(&adapter->napi);
2777 +
2778 + iegbe_irq_enable(adapter);
2779 +
2780 + netif_start_queue(netdev);
2781 +
2782 + /* fire a link status change interrupt to start the watchdog */
2783 +
2784 + return E1000_SUCCESS;
2785 +
2786 +err_req_irq:
2787 + iegbe_power_down_phy(adapter);
2788 + iegbe_free_all_rx_resources(adapter);
2789 err_setup_rx:
2790 - iegbe_reset(adapter);
2791 + iegbe_free_all_tx_resources(adapter);
2792 +err_setup_tx:
2793 + iegbe_reset(adapter);
2794
2795 - return err;
2796 + return err;
2797 }
2798
2799 /**
2800 @@ -1348,22 +1249,25 @@ err_setup_rx:
2801 * hardware, and all transmit and receive resources are freed.
2802 **/
2803
2804 -static int
2805 -iegbe_close(struct net_device *netdev)
2806 +static int iegbe_close(struct net_device *netdev)
2807 {
2808 - struct iegbe_adapter *adapter = netdev_priv(netdev);
2809 -
2810 - iegbe_down(adapter);
2811 -
2812 - iegbe_free_all_tx_resources(adapter);
2813 - iegbe_free_all_rx_resources(adapter);
2814 + struct iegbe_adapter *adapter = netdev_priv(netdev);
2815 + struct iegbe_hw *hw = &adapter->hw;
2816
2817 -#ifdef NETIF_F_HW_VLAN_TX
2818 - if((adapter->hw.mng_cookie.status &
2819 - E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
2820 + WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
2821 + iegbe_down(adapter);
2822 + iegbe_power_down_phy(adapter);
2823 + iegbe_free_irq(adapter);
2824 +
2825 + iegbe_free_all_tx_resources(adapter);
2826 + iegbe_free_all_rx_resources(adapter);
2827 +
2828 + if ((hw->mng_cookie.status &
2829 + E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
2830 + !(adapter->vlgrp &&
2831 + vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
2832 iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
2833 }
2834 -#endif
2835 return 0;
2836 }
2837
2838 @@ -1375,19 +1279,19 @@ iegbe_close(struct net_device *netdev)
2839 **/
2840 static inline boolean_t
2841 iegbe_check_64k_bound(struct iegbe_adapter *adapter,
2842 - void *start, unsigned long len)
2843 + void *start, unsigned long len)
2844 {
2845 - unsigned long begin = (unsigned long) start;
2846 - unsigned long end = begin + len;
2847 + unsigned long begin = (unsigned long) start;
2848 + unsigned long end = begin + len;
2849
2850 - /* First rev 82545 and 82546 need to not allow any memory
2851 - * write location to cross 64k boundary due to errata 23 */
2852 - if(adapter->hw.mac_type == iegbe_82545 ||
2853 - adapter->hw.mac_type == iegbe_82546) {
2854 - return ((begin ^ (end - 1)) >> 0x10) != 0 ? FALSE : TRUE;
2855 - }
2856 + /* First rev 82545 and 82546 need to not allow any memory
2857 + * write location to cross 64k boundary due to errata 23 */
2858 + if(adapter->hw.mac_type == iegbe_82545 ||
2859 + adapter->hw.mac_type == iegbe_82546) {
2860 + return ((begin ^ (end - 1)) >> 0x10) != 0x0 ? FALSE : TRUE;
2861 + }
2862
2863 - return TRUE;
2864 + return TRUE;
2865 }
2866
2867 /**
2868 @@ -1398,102 +1302,98 @@ iegbe_check_64k_bound(struct iegbe_adapt
2869 * Return 0 on success, negative on failure
2870 **/
2871
2872 -int
2873 -iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
2874 +static int iegbe_setup_tx_resources(struct iegbe_adapter *adapter,
2875 struct iegbe_tx_ring *txdr)
2876 {
2877 - struct pci_dev *pdev = adapter->pdev;
2878 - int size;
2879 + struct pci_dev *pdev = adapter->pdev;
2880 + int size;
2881
2882 - size = sizeof(struct iegbe_buffer) * txdr->count;
2883 - txdr->buffer_info = vmalloc(size);
2884 - if (!txdr->buffer_info) {
2885 - DPRINTK(PROBE, ERR,
2886 - "Unable to allocate memory for the transmit descriptor ring\n");
2887 - return -ENOMEM;
2888 - }
2889 + size = sizeof(struct iegbe_buffer) * txdr->count;
2890 + txdr->buffer_info = vmalloc(size);
2891 + if (!txdr->buffer_info) {
2892 + DPRINTK(PROBE, ERR,
2893 + "Unable to allocate memory for the transmit descriptor ring\n");
2894 + return -ENOMEM;
2895 + }
2896 memset(txdr->buffer_info, 0, size);
2897 - memset(&txdr->previous_buffer_info, 0, sizeof(struct iegbe_buffer));
2898
2899 - /* round up to nearest 4K */
2900 + /* round up to nearest 4K */
2901
2902 - txdr->size = txdr->count * sizeof(struct iegbe_tx_desc);
2903 - E1000_ROUNDUP(txdr->size, 0x1000);
2904 + txdr->size = txdr->count * sizeof(struct iegbe_tx_desc);
2905 + txdr->size = ALIGN(txdr->size, 4096);
2906
2907 - txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
2908 - if (!txdr->desc) {
2909 + txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
2910 + if (!txdr->desc) {
2911 setup_tx_desc_die:
2912 - vfree(txdr->buffer_info);
2913 - DPRINTK(PROBE, ERR,
2914 - "Unable to allocate memory for the transmit descriptor ring\n");
2915 - return -ENOMEM;
2916 - }
2917 -
2918 - /* Fix for errata 23, can't cross 64kB boundary */
2919 - if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
2920 - void *olddesc = txdr->desc;
2921 - dma_addr_t olddma = txdr->dma;
2922 - DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
2923 - "at %p\n", txdr->size, txdr->desc);
2924 - /* Try again, without freeing the previous */
2925 - txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
2926 - /* Failed allocation, critical failure */
2927 - if (!txdr->desc) {
2928 - pci_free_consistent(pdev, txdr->size, olddesc, olddma);
2929 - goto setup_tx_desc_die;
2930 - }
2931 + vfree(txdr->buffer_info);
2932 + DPRINTK(PROBE, ERR,
2933 + "Unable to allocate memory for the transmit descriptor ring\n");
2934 + return -ENOMEM;
2935 + }
2936 +
2937 + /* Fix for errata 23, can't cross 64kB boundary */
2938 + if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
2939 + void *olddesc = txdr->desc;
2940 + dma_addr_t olddma = txdr->dma;
2941 + DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
2942 + "at %p\n", txdr->size, txdr->desc);
2943 + /* Try again, without freeing the previous */
2944 + txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
2945 + /* Failed allocation, critical failure */
2946 + if (!txdr->desc) {
2947 + pci_free_consistent(pdev, txdr->size, olddesc, olddma);
2948 + goto setup_tx_desc_die;
2949 + }
2950
2951 - if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
2952 - /* give up */
2953 - pci_free_consistent(pdev, txdr->size, txdr->desc,
2954 - txdr->dma);
2955 - pci_free_consistent(pdev, txdr->size, olddesc, olddma);
2956 - DPRINTK(PROBE, ERR,
2957 - "Unable to allocate aligned memory "
2958 - "for the transmit descriptor ring\n");
2959 - vfree(txdr->buffer_info);
2960 - return -ENOMEM;
2961 - } else {
2962 - /* Free old allocation, new allocation was successful */
2963 - pci_free_consistent(pdev, txdr->size, olddesc, olddma);
2964 - }
2965 - }
2966 + if (!iegbe_check_64k_bound(adapter, txdr->desc, txdr->size)) {
2967 + /* give up */
2968 + pci_free_consistent(pdev, txdr->size, txdr->desc,
2969 + txdr->dma);
2970 + pci_free_consistent(pdev, txdr->size, olddesc, olddma);
2971 + DPRINTK(PROBE, ERR,
2972 + "Unable to allocate aligned memory "
2973 + "for the transmit descriptor ring\n");
2974 + vfree(txdr->buffer_info);
2975 + return -ENOMEM;
2976 + } else {
2977 + /* Free old allocation, new allocation was successful */
2978 + pci_free_consistent(pdev, txdr->size, olddesc, olddma);
2979 + }
2980 + }
2981 memset(txdr->desc, 0, txdr->size);
2982
2983 txdr->next_to_use = 0;
2984 txdr->next_to_clean = 0;
2985 - spin_lock_init(&txdr->tx_lock);
2986 + spin_lock_init(&txdr->tx_lock);
2987
2988 return 0;
2989 }
2990
2991 /**
2992 * iegbe_setup_all_tx_resources - wrapper to allocate Tx resources
2993 - * (Descriptors) for all queues
2994 + * (Descriptors) for all queues
2995 * @adapter: board private structure
2996 *
2997 - * If this function returns with an error, then it's possible one or
2998 - * more of the rings is populated (while the rest are not). It is the
2999 - * callers duty to clean those orphaned rings.
3000 - *
3001 * Return 0 on success, negative on failure
3002 **/
3003
3004 -int
3005 -iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter)
3006 +int iegbe_setup_all_tx_resources(struct iegbe_adapter *adapter)
3007 {
3008 int i, err = 0;
3009
3010 - for (i = 0; i < adapter->num_queues; i++) {
3011 + for (i = 0; i < adapter->num_tx_queues; i++) {
3012 err = iegbe_setup_tx_resources(adapter, &adapter->tx_ring[i]);
3013 if (err) {
3014 DPRINTK(PROBE, ERR,
3015 "Allocation for Tx Queue %u failed\n", i);
3016 + for (i-- ; i >= 0; i--)
3017 + iegbe_free_tx_resources(adapter,
3018 + &adapter->tx_ring[i]);
3019 break;
3020 }
3021 }
3022
3023 - return err;
3024 + return err;
3025 }
3026
3027 /**
3028 @@ -1512,113 +1412,108 @@ iegbe_configure_tx(struct iegbe_adapter
3029
3030 /* Setup the HW Tx Head and Tail descriptor pointers */
3031
3032 - switch (adapter->num_queues) {
3033 + switch (adapter->num_tx_queues) {
3034 case 0x2:
3035 tdba = adapter->tx_ring[0x1].dma;
3036 tdlen = adapter->tx_ring[0x1].count *
3037 - sizeof(struct iegbe_tx_desc);
3038 - E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
3039 + sizeof(struct iegbe_tx_desc);
3040 + E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
3041 E1000_WRITE_REG(hw, TDBAH1, (tdba >> 0x20));
3042 - E1000_WRITE_REG(hw, TDLEN1, tdlen);
3043 - E1000_WRITE_REG(hw, TDH1, 0);
3044 - E1000_WRITE_REG(hw, TDT1, 0);
3045 + E1000_WRITE_REG(hw, TDLEN1, tdlen);
3046 + E1000_WRITE_REG(hw, TDH1, 0x0);
3047 + E1000_WRITE_REG(hw, TDT1, 0x0);
3048 adapter->tx_ring[0x1].tdh = E1000_TDH1;
3049 adapter->tx_ring[0x1].tdt = E1000_TDT1;
3050 - /* Fall Through */
3051 + /* Fall Through */
3052 case 0x1:
3053 - default:
3054 - tdba = adapter->tx_ring[0].dma;
3055 - tdlen = adapter->tx_ring[0].count *
3056 - sizeof(struct iegbe_tx_desc);
3057 - E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
3058 + default:
3059 + tdba = adapter->tx_ring[0x0].dma;
3060 + tdlen = adapter->tx_ring[0x0].count *
3061 + sizeof(struct iegbe_tx_desc);
3062 + E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
3063 E1000_WRITE_REG(hw, TDBAH, (tdba >> 0x20));
3064 - E1000_WRITE_REG(hw, TDLEN, tdlen);
3065 - E1000_WRITE_REG(hw, TDH, 0);
3066 - E1000_WRITE_REG(hw, TDT, 0);
3067 - adapter->tx_ring[0].tdh = E1000_TDH;
3068 - adapter->tx_ring[0].tdt = E1000_TDT;
3069 - break;
3070 - }
3071 -
3072 - /* Set the default values for the Tx Inter Packet Gap timer */
3073 -
3074 - switch (hw->mac_type) {
3075 - case iegbe_82542_rev2_0:
3076 - case iegbe_82542_rev2_1:
3077 - tipg = DEFAULT_82542_TIPG_IPGT;
3078 - tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
3079 - tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
3080 - break;
3081 - default:
3082 - switch(hw->media_type) {
3083 - case iegbe_media_type_fiber:
3084 - case iegbe_media_type_internal_serdes:
3085 - tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
3086 - break;
3087 - case iegbe_media_type_copper:
3088 - tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
3089 - break;
3090 - case iegbe_media_type_oem:
3091 - default:
3092 + E1000_WRITE_REG(hw, TDLEN, tdlen);
3093 + E1000_WRITE_REG(hw, TDH, 0x0);
3094 + E1000_WRITE_REG(hw, TDT, 0x0);
3095 + adapter->tx_ring[0x0].tdh = E1000_TDH;
3096 + adapter->tx_ring[0x0].tdt = E1000_TDT;
3097 + break;
3098 + }
3099 +
3100 + /* Set the default values for the Tx Inter Packet Gap timer */
3101 +
3102 + switch (hw->mac_type) {
3103 + case iegbe_82542_rev2_0:
3104 + case iegbe_82542_rev2_1:
3105 + tipg = DEFAULT_82542_TIPG_IPGT;
3106 + tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
3107 + tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
3108 + break;
3109 + default:
3110 + switch(hw->media_type) {
3111 + case iegbe_media_type_fiber:
3112 + case iegbe_media_type_internal_serdes:
3113 + tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
3114 + break;
3115 + case iegbe_media_type_copper:
3116 + tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
3117 + break;
3118 + case iegbe_media_type_oem:
3119 + default:
3120 tipg = (0xFFFFFFFFUL >> (sizeof(tipg)*0x8 -
3121 E1000_TIPG_IPGR1_SHIFT))
3122 - & iegbe_oem_get_tipg(&adapter->hw);
3123 - break;
3124 - }
3125 - tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
3126 - tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
3127 - }
3128 - E1000_WRITE_REG(hw, TIPG, tipg);
3129 + & iegbe_oem_get_tipg(&adapter->hw);
3130 + break;
3131 + }
3132 + tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
3133 + tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
3134 + }
3135 + E1000_WRITE_REG(hw, TIPG, tipg);
3136
3137 - /* Set the Tx Interrupt Delay register */
3138 + /* Set the Tx Interrupt Delay register */
3139
3140 - E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
3141 + E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
3142 if (hw->mac_type >= iegbe_82540) {
3143 - E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
3144 + E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
3145 }
3146 - /* Program the Transmit Control Register */
3147 + /* Program the Transmit Control Register */
3148
3149 - tctl = E1000_READ_REG(hw, TCTL);
3150 + tctl = E1000_READ_REG(hw, TCTL);
3151
3152 - tctl &= ~E1000_TCTL_CT;
3153 - tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
3154 - (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
3155 + tctl &= ~E1000_TCTL_CT;
3156 + tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
3157 + (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
3158
3159 - E1000_WRITE_REG(hw, TCTL, tctl);
3160 + E1000_WRITE_REG(hw, TCTL, tctl);
3161
3162 - if (hw->mac_type == iegbe_82571 || hw->mac_type == iegbe_82572) {
3163 - tarc = E1000_READ_REG(hw, TARC0);
3164 + if (hw->mac_type == iegbe_82571 || hw->mac_type == iegbe_82572) {
3165 + tarc = E1000_READ_REG(hw, TARC0);
3166 tarc |= ((0x1 << 0x19) | (0x1 << 0x15));
3167 - E1000_WRITE_REG(hw, TARC0, tarc);
3168 - tarc = E1000_READ_REG(hw, TARC1);
3169 + E1000_WRITE_REG(hw, TARC0, tarc);
3170 + tarc = E1000_READ_REG(hw, TARC1);
3171 tarc |= (0x1 << 0x19);
3172 if (tctl & E1000_TCTL_MULR) {
3173 tarc &= ~(0x1 << 0x1c);
3174 } else {
3175 tarc |= (0x1 << 0x1c);
3176 }
3177 - E1000_WRITE_REG(hw, TARC1, tarc);
3178 - }
3179 + E1000_WRITE_REG(hw, TARC1, tarc);
3180 + }
3181
3182 - iegbe_config_collision_dist(hw);
3183 + iegbe_config_collision_dist(hw);
3184
3185 - /* Setup Transmit Descriptor Settings for eop descriptor */
3186 - adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
3187 - E1000_TXD_CMD_IFCS;
3188 + /* Setup Transmit Descriptor Settings for eop descriptor */
3189 + adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
3190 + E1000_TXD_CMD_IFCS;
3191
3192 if (hw->mac_type < iegbe_82543) {
3193 - adapter->txd_cmd |= E1000_TXD_CMD_RPS;
3194 + adapter->txd_cmd |= E1000_TXD_CMD_RPS;
3195 } else {
3196 -#ifdef IEGBE_GBE_WORKAROUND
3197 - /* Disable the RS bit in the Tx descriptor */
3198 - adapter->txd_cmd &= ~E1000_TXD_CMD_RS;
3199 -#else
3200 - adapter->txd_cmd |= E1000_TXD_CMD_RS;
3201 -#endif
3202 + adapter->txd_cmd |= E1000_TXD_CMD_RS;
3203 }
3204 - /* Cache if we're 82544 running in PCI-X because we'll
3205 - * need this to apply a workaround later in the send path. */
3206 - if (hw->mac_type == iegbe_82544 &&
3207 + /* Cache if we're 82544 running in PCI-X because we'll
3208 + * need this to apply a workaround later in the send path. */
3209 + if (hw->mac_type == iegbe_82544 &&
3210 hw->bus_type == iegbe_bus_type_pcix) {
3211 adapter->pcix_82544 = 0x1;
3212 }
3213 @@ -1632,96 +1527,95 @@ iegbe_configure_tx(struct iegbe_adapter
3214 * Returns 0 on success, negative on failure
3215 **/
3216
3217 -int
3218 -iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
3219 +static int iegbe_setup_rx_resources(struct iegbe_adapter *adapter,
3220 struct iegbe_rx_ring *rxdr)
3221 {
3222 - struct pci_dev *pdev = adapter->pdev;
3223 - int size, desc_len;
3224 -
3225 - size = sizeof(struct iegbe_buffer) * rxdr->count;
3226 - rxdr->buffer_info = vmalloc(size);
3227 - if (!rxdr->buffer_info) {
3228 - DPRINTK(PROBE, ERR,
3229 - "Unable to allocate memory for the receive descriptor ring\n");
3230 - return -ENOMEM;
3231 - }
3232 - memset(rxdr->buffer_info, 0, size);
3233 -
3234 - size = sizeof(struct iegbe_ps_page) * rxdr->count;
3235 - rxdr->ps_page = kmalloc(size, GFP_KERNEL);
3236 - if (!rxdr->ps_page) {
3237 - vfree(rxdr->buffer_info);
3238 - DPRINTK(PROBE, ERR,
3239 - "Unable to allocate memory for the receive descriptor ring\n");
3240 - return -ENOMEM;
3241 - }
3242 - memset(rxdr->ps_page, 0, size);
3243 -
3244 - size = sizeof(struct iegbe_ps_page_dma) * rxdr->count;
3245 - rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
3246 - if (!rxdr->ps_page_dma) {
3247 - vfree(rxdr->buffer_info);
3248 - kfree(rxdr->ps_page);
3249 - DPRINTK(PROBE, ERR,
3250 - "Unable to allocate memory for the receive descriptor ring\n");
3251 - return -ENOMEM;
3252 - }
3253 - memset(rxdr->ps_page_dma, 0, size);
3254 + struct iegbe_hw *hw = &adapter->hw;
3255 + struct pci_dev *pdev = adapter->pdev;
3256 + int size, desc_len;
3257
3258 - if (adapter->hw.mac_type <= iegbe_82547_rev_2) {
3259 - desc_len = sizeof(struct iegbe_rx_desc);
3260 - } else {
3261 - desc_len = sizeof(union iegbe_rx_desc_packet_split);
3262 + size = sizeof(struct iegbe_buffer) * rxdr->count;
3263 + rxdr->buffer_info = vmalloc(size);
3264 + if (!rxdr->buffer_info) {
3265 + DPRINTK(PROBE, ERR,
3266 + "Unable to allocate memory for the receive descriptor ring\n");
3267 + return -ENOMEM;
3268 }
3269 - /* Round up to nearest 4K */
3270 -
3271 - rxdr->size = rxdr->count * desc_len;
3272 - E1000_ROUNDUP(rxdr->size, 0x1000);
3273 -
3274 - rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
3275 + memset(rxdr->buffer_info, 0, size);
3276
3277 - if (!rxdr->desc) {
3278 - DPRINTK(PROBE, ERR,
3279 - "Unable to allocate memory for the receive descriptor ring\n");
3280 + rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct iegbe_ps_page),
3281 + GFP_KERNEL);
3282 + if (!rxdr->ps_page) {
3283 + vfree(rxdr->buffer_info);
3284 + DPRINTK(PROBE, ERR,
3285 + "Unable to allocate memory for the receive descriptor ring\n");
3286 + return -ENOMEM;
3287 + }
3288 +
3289 + rxdr->ps_page_dma = kcalloc(rxdr->count,
3290 + sizeof(struct iegbe_ps_page_dma),
3291 + GFP_KERNEL);
3292 + if (!rxdr->ps_page_dma) {
3293 + vfree(rxdr->buffer_info);
3294 + kfree(rxdr->ps_page);
3295 + DPRINTK(PROBE, ERR,
3296 + "Unable to allocate memory for the receive descriptor ring\n");
3297 + return -ENOMEM;
3298 + }
3299 +
3300 + if (hw->mac_type <= iegbe_82547_rev_2)
3301 + desc_len = sizeof(struct iegbe_rx_desc);
3302 + else
3303 + desc_len = sizeof(union iegbe_rx_desc_packet_split);
3304 +
3305 + /* Round up to nearest 4K */
3306 +
3307 + rxdr->size = rxdr->count * desc_len;
3308 + rxdr->size = ALIGN(rxdr->size, 4096);
3309 +
3310 + rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
3311 +
3312 + if (!rxdr->desc) {
3313 + DPRINTK(PROBE, ERR,
3314 + "Unable to allocate memory for the receive descriptor ring\n");
3315 setup_rx_desc_die:
3316 - vfree(rxdr->buffer_info);
3317 - kfree(rxdr->ps_page);
3318 - kfree(rxdr->ps_page_dma);
3319 - return -ENOMEM;
3320 - }
3321 -
3322 - /* Fix for errata 23, can't cross 64kB boundary */
3323 - if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
3324 - void *olddesc = rxdr->desc;
3325 - dma_addr_t olddma = rxdr->dma;
3326 - DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
3327 - "at %p\n", rxdr->size, rxdr->desc);
3328 - /* Try again, without freeing the previous */
3329 - rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
3330 - /* Failed allocation, critical failure */
3331 - if (!rxdr->desc) {
3332 - pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
3333 - DPRINTK(PROBE, ERR,
3334 - "Unable to allocate memory "
3335 - "for the receive descriptor ring\n");
3336 - goto setup_rx_desc_die;
3337 - }
3338 + vfree(rxdr->buffer_info);
3339 + kfree(rxdr->ps_page);
3340 + kfree(rxdr->ps_page_dma);
3341 + return -ENOMEM;
3342 + }
3343 +
3344 + /* Fix for errata 23, can't cross 64kB boundary */
3345 + if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
3346 + void *olddesc = rxdr->desc;
3347 + dma_addr_t olddma = rxdr->dma;
3348 + DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
3349 + "at %p\n", rxdr->size, rxdr->desc);
3350 + /* Try again, without freeing the previous */
3351 + rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
3352 + /* Failed allocation, critical failure */
3353 + if (!rxdr->desc) {
3354 + pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
3355 + DPRINTK(PROBE, ERR,
3356 + "Unable to allocate memory "
3357 + "for the receive descriptor ring\n");
3358 + goto setup_rx_desc_die;
3359 + }
3360
3361 - if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
3362 - /* give up */
3363 - pci_free_consistent(pdev, rxdr->size, rxdr->desc,
3364 - rxdr->dma);
3365 - pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
3366 - DPRINTK(PROBE, ERR,
3367 - "Unable to allocate aligned memory "
3368 - "for the receive descriptor ring\n");
3369 - goto setup_rx_desc_die;
3370 - } else {
3371 - /* Free old allocation, new allocation was successful */
3372 - pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
3373 - }
3374 - }
3375 + if (!iegbe_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
3376 + /* give up */
3377 + pci_free_consistent(pdev, rxdr->size, rxdr->desc,
3378 + rxdr->dma);
3379 + pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
3380 + DPRINTK(PROBE, ERR,
3381 + "Unable to allocate aligned memory "
3382 + "for the receive descriptor ring\n");
3383 + goto setup_rx_desc_die;
3384 + } else {
3385 + /* Free old allocation, new allocation was successful */
3386 + pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
3387 + }
3388 + }
3389 memset(rxdr->desc, 0, rxdr->size);
3390
3391 rxdr->next_to_clean = 0;
3392 @@ -1732,7 +1626,7 @@ setup_rx_desc_die:
3393
3394 /**
3395 * iegbe_setup_all_rx_resources - wrapper to allocate Rx resources
3396 - * (Descriptors) for all queues
3397 + * (Descriptors) for all queues
3398 * @adapter: board private structure
3399 *
3400 * If this function returns with an error, then it's possible one or
3401 @@ -1742,21 +1636,23 @@ setup_rx_desc_die:
3402 * Return 0 on success, negative on failure
3403 **/
3404
3405 -int
3406 -iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter)
3407 +int iegbe_setup_all_rx_resources(struct iegbe_adapter *adapter)
3408 {
3409 int i, err = 0;
3410
3411 - for (i = 0; i < adapter->num_queues; i++) {
3412 + for (i = 0; i < adapter->num_rx_queues; i++) {
3413 err = iegbe_setup_rx_resources(adapter, &adapter->rx_ring[i]);
3414 if (err) {
3415 DPRINTK(PROBE, ERR,
3416 "Allocation for Rx Queue %u failed\n", i);
3417 + for (i-- ; i >= 0; i--)
3418 + iegbe_free_rx_resources(adapter,
3419 + &adapter->rx_ring[i]);
3420 break;
3421 }
3422 }
3423
3424 - return err;
3425 + return err;
3426 }
3427
3428 /**
3429 @@ -1765,105 +1661,104 @@ iegbe_setup_all_rx_resources(struct iegb
3430 **/
3431 #define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
3432 (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
3433 -static void
3434 -iegbe_setup_rctl(struct iegbe_adapter *adapter)
3435 +static void iegbe_setup_rctl(struct iegbe_adapter *adapter)
3436 {
3437 - uint32_t rctl, rfctl;
3438 - uint32_t psrctl = 0;
3439 -#ifdef CONFIG_E1000_PACKET_SPLIT
3440 - uint32_t pages = 0;
3441 -#endif
3442 -
3443 - rctl = E1000_READ_REG(&adapter->hw, RCTL);
3444 -
3445 - rctl &= ~(0x3 << E1000_RCTL_MO_SHIFT);
3446 -
3447 - rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
3448 - E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
3449 - (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
3450 -
3451 - if(adapter->hw.tbi_compatibility_on == 0x1) {
3452 - rctl |= E1000_RCTL_SBP;
3453 - } else {
3454 - rctl &= ~E1000_RCTL_SBP;
3455 - }
3456 - if(adapter->netdev->mtu <= ETH_DATA_LEN) {
3457 - rctl &= ~E1000_RCTL_LPE;
3458 - } else {
3459 - rctl |= E1000_RCTL_LPE;
3460 - }
3461 - /* Setup buffer sizes */
3462 - if(adapter->hw.mac_type >= iegbe_82571) {
3463 - /* We can now specify buffers in 1K increments.
3464 - * BSIZE and BSEX are ignored in this case. */
3465 - rctl |= adapter->rx_buffer_len << 0x11;
3466 - } else {
3467 - rctl &= ~E1000_RCTL_SZ_4096;
3468 - rctl |= E1000_RCTL_BSEX;
3469 - switch (adapter->rx_buffer_len) {
3470 - case E1000_RXBUFFER_2048:
3471 - default:
3472 - rctl |= E1000_RCTL_SZ_2048;
3473 + struct iegbe_hw *hw = &adapter->hw;
3474 + u32 rctl, rfctl;
3475 + u32 psrctl = 0;
3476 +#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT