diff options
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r-- | drivers/net/e1000/e1000_main.c | 1147 |
1 files changed, 891 insertions, 256 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index 82549a6fcfb3..325495b8b60c 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************************* | 1 | /******************************************************************************* |
2 | 2 | ||
3 | 3 | ||
4 | Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. | 4 | Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify it | 6 | This program is free software; you can redistribute it and/or modify it |
7 | under the terms of the GNU General Public License as published by the Free | 7 | under the terms of the GNU General Public License as published by the Free |
@@ -29,33 +29,9 @@ | |||
29 | #include "e1000.h" | 29 | #include "e1000.h" |
30 | 30 | ||
31 | /* Change Log | 31 | /* Change Log |
32 | * 5.3.12 6/7/04 | 32 | * 6.0.44+ 2/15/05 |
33 | * - kcompat NETIF_MSG for older kernels (2.4.9) <sean.p.mcdermott@intel.com> | 33 | * o applied Anton's patch to resolve tx hang in hardware |
34 | * - if_mii support and associated kcompat for older kernels | 34 | * o Applied Andrew Mortons patch - e1000 stops working after resume |
35 | * - More errlogging support from Jon Mason <jonmason@us.ibm.com> | ||
36 | * - Fix TSO issues on PPC64 machines -- Jon Mason <jonmason@us.ibm.com> | ||
37 | * | ||
38 | * 5.7.1 12/16/04 | ||
39 | * - Resurrect 82547EI/GI related fix in e1000_intr to avoid deadlocks. This | ||
40 | * fix was removed as it caused system instability. The suspected cause of | ||
41 | * this is the called to e1000_irq_disable in e1000_intr. Inlined the | ||
42 | * required piece of e1000_irq_disable into e1000_intr - Anton Blanchard | ||
43 | * 5.7.0 12/10/04 | ||
44 | * - include fix to the condition that determines when to quit NAPI - Robert Olsson | ||
45 | * - use netif_poll_{disable/enable} to synchronize between NAPI and i/f up/down | ||
46 | * 5.6.5 11/01/04 | ||
47 | * - Enabling NETIF_F_SG without checksum offload is illegal - | ||
48 | John Mason <jdmason@us.ibm.com> | ||
49 | * 5.6.3 10/26/04 | ||
50 | * - Remove redundant initialization - Jamal Hadi | ||
51 | * - Reset buffer_info->dma in tx resource cleanup logic | ||
52 | * 5.6.2 10/12/04 | ||
53 | * - Avoid filling tx_ring completely - shemminger@osdl.org | ||
54 | * - Replace schedule_timeout() with msleep()/msleep_interruptible() - | ||
55 | * nacc@us.ibm.com | ||
56 | * - Sparse cleanup - shemminger@osdl.org | ||
57 | * - Fix tx resource cleanup logic | ||
58 | * - LLTX support - ak@suse.de and hadi@cyberus.ca | ||
59 | */ | 35 | */ |
60 | 36 | ||
61 | char e1000_driver_name[] = "e1000"; | 37 | char e1000_driver_name[] = "e1000"; |
@@ -65,7 +41,7 @@ char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; | |||
65 | #else | 41 | #else |
66 | #define DRIVERNAPI "-NAPI" | 42 | #define DRIVERNAPI "-NAPI" |
67 | #endif | 43 | #endif |
68 | #define DRV_VERSION "5.7.6-k2"DRIVERNAPI | 44 | #define DRV_VERSION "6.0.54-k2"DRIVERNAPI |
69 | char e1000_driver_version[] = DRV_VERSION; | 45 | char e1000_driver_version[] = DRV_VERSION; |
70 | char e1000_copyright[] = "Copyright (c) 1999-2004 Intel Corporation."; | 46 | char e1000_copyright[] = "Copyright (c) 1999-2004 Intel Corporation."; |
71 | 47 | ||
@@ -96,6 +72,7 @@ static struct pci_device_id e1000_pci_tbl[] = { | |||
96 | INTEL_E1000_ETHERNET_DEVICE(0x1017), | 72 | INTEL_E1000_ETHERNET_DEVICE(0x1017), |
97 | INTEL_E1000_ETHERNET_DEVICE(0x1018), | 73 | INTEL_E1000_ETHERNET_DEVICE(0x1018), |
98 | INTEL_E1000_ETHERNET_DEVICE(0x1019), | 74 | INTEL_E1000_ETHERNET_DEVICE(0x1019), |
75 | INTEL_E1000_ETHERNET_DEVICE(0x101A), | ||
99 | INTEL_E1000_ETHERNET_DEVICE(0x101D), | 76 | INTEL_E1000_ETHERNET_DEVICE(0x101D), |
100 | INTEL_E1000_ETHERNET_DEVICE(0x101E), | 77 | INTEL_E1000_ETHERNET_DEVICE(0x101E), |
101 | INTEL_E1000_ETHERNET_DEVICE(0x1026), | 78 | INTEL_E1000_ETHERNET_DEVICE(0x1026), |
@@ -110,6 +87,9 @@ static struct pci_device_id e1000_pci_tbl[] = { | |||
110 | INTEL_E1000_ETHERNET_DEVICE(0x107B), | 87 | INTEL_E1000_ETHERNET_DEVICE(0x107B), |
111 | INTEL_E1000_ETHERNET_DEVICE(0x107C), | 88 | INTEL_E1000_ETHERNET_DEVICE(0x107C), |
112 | INTEL_E1000_ETHERNET_DEVICE(0x108A), | 89 | INTEL_E1000_ETHERNET_DEVICE(0x108A), |
90 | INTEL_E1000_ETHERNET_DEVICE(0x108B), | ||
91 | INTEL_E1000_ETHERNET_DEVICE(0x108C), | ||
92 | INTEL_E1000_ETHERNET_DEVICE(0x1099), | ||
113 | /* required last entry */ | 93 | /* required last entry */ |
114 | {0,} | 94 | {0,} |
115 | }; | 95 | }; |
@@ -155,10 +135,14 @@ static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter); | |||
155 | static int e1000_clean(struct net_device *netdev, int *budget); | 135 | static int e1000_clean(struct net_device *netdev, int *budget); |
156 | static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter, | 136 | static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter, |
157 | int *work_done, int work_to_do); | 137 | int *work_done, int work_to_do); |
138 | static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | ||
139 | int *work_done, int work_to_do); | ||
158 | #else | 140 | #else |
159 | static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter); | 141 | static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter); |
142 | static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter); | ||
160 | #endif | 143 | #endif |
161 | static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter); | 144 | static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter); |
145 | static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter); | ||
162 | static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); | 146 | static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); |
163 | static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, | 147 | static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, |
164 | int cmd); | 148 | int cmd); |
@@ -286,7 +270,29 @@ e1000_irq_enable(struct e1000_adapter *adapter) | |||
286 | E1000_WRITE_FLUSH(&adapter->hw); | 270 | E1000_WRITE_FLUSH(&adapter->hw); |
287 | } | 271 | } |
288 | } | 272 | } |
289 | 273 | void | |
274 | e1000_update_mng_vlan(struct e1000_adapter *adapter) | ||
275 | { | ||
276 | struct net_device *netdev = adapter->netdev; | ||
277 | uint16_t vid = adapter->hw.mng_cookie.vlan_id; | ||
278 | uint16_t old_vid = adapter->mng_vlan_id; | ||
279 | if(adapter->vlgrp) { | ||
280 | if(!adapter->vlgrp->vlan_devices[vid]) { | ||
281 | if(adapter->hw.mng_cookie.status & | ||
282 | E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) { | ||
283 | e1000_vlan_rx_add_vid(netdev, vid); | ||
284 | adapter->mng_vlan_id = vid; | ||
285 | } else | ||
286 | adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; | ||
287 | |||
288 | if((old_vid != (uint16_t)E1000_MNG_VLAN_NONE) && | ||
289 | (vid != old_vid) && | ||
290 | !adapter->vlgrp->vlan_devices[old_vid]) | ||
291 | e1000_vlan_rx_kill_vid(netdev, old_vid); | ||
292 | } | ||
293 | } | ||
294 | } | ||
295 | |||
290 | int | 296 | int |
291 | e1000_up(struct e1000_adapter *adapter) | 297 | e1000_up(struct e1000_adapter *adapter) |
292 | { | 298 | { |
@@ -310,19 +316,33 @@ e1000_up(struct e1000_adapter *adapter) | |||
310 | e1000_configure_tx(adapter); | 316 | e1000_configure_tx(adapter); |
311 | e1000_setup_rctl(adapter); | 317 | e1000_setup_rctl(adapter); |
312 | e1000_configure_rx(adapter); | 318 | e1000_configure_rx(adapter); |
313 | e1000_alloc_rx_buffers(adapter); | 319 | adapter->alloc_rx_buf(adapter); |
314 | 320 | ||
321 | #ifdef CONFIG_PCI_MSI | ||
322 | if(adapter->hw.mac_type > e1000_82547_rev_2) { | ||
323 | adapter->have_msi = TRUE; | ||
324 | if((err = pci_enable_msi(adapter->pdev))) { | ||
325 | DPRINTK(PROBE, ERR, | ||
326 | "Unable to allocate MSI interrupt Error: %d\n", err); | ||
327 | adapter->have_msi = FALSE; | ||
328 | } | ||
329 | } | ||
330 | #endif | ||
315 | if((err = request_irq(adapter->pdev->irq, &e1000_intr, | 331 | if((err = request_irq(adapter->pdev->irq, &e1000_intr, |
316 | SA_SHIRQ | SA_SAMPLE_RANDOM, | 332 | SA_SHIRQ | SA_SAMPLE_RANDOM, |
317 | netdev->name, netdev))) | 333 | netdev->name, netdev))) { |
334 | DPRINTK(PROBE, ERR, | ||
335 | "Unable to allocate interrupt Error: %d\n", err); | ||
318 | return err; | 336 | return err; |
337 | } | ||
319 | 338 | ||
320 | mod_timer(&adapter->watchdog_timer, jiffies); | 339 | mod_timer(&adapter->watchdog_timer, jiffies); |
321 | e1000_irq_enable(adapter); | ||
322 | 340 | ||
323 | #ifdef CONFIG_E1000_NAPI | 341 | #ifdef CONFIG_E1000_NAPI |
324 | netif_poll_enable(netdev); | 342 | netif_poll_enable(netdev); |
325 | #endif | 343 | #endif |
344 | e1000_irq_enable(adapter); | ||
345 | |||
326 | return 0; | 346 | return 0; |
327 | } | 347 | } |
328 | 348 | ||
@@ -333,6 +353,11 @@ e1000_down(struct e1000_adapter *adapter) | |||
333 | 353 | ||
334 | e1000_irq_disable(adapter); | 354 | e1000_irq_disable(adapter); |
335 | free_irq(adapter->pdev->irq, netdev); | 355 | free_irq(adapter->pdev->irq, netdev); |
356 | #ifdef CONFIG_PCI_MSI | ||
357 | if(adapter->hw.mac_type > e1000_82547_rev_2 && | ||
358 | adapter->have_msi == TRUE) | ||
359 | pci_disable_msi(adapter->pdev); | ||
360 | #endif | ||
336 | del_timer_sync(&adapter->tx_fifo_stall_timer); | 361 | del_timer_sync(&adapter->tx_fifo_stall_timer); |
337 | del_timer_sync(&adapter->watchdog_timer); | 362 | del_timer_sync(&adapter->watchdog_timer); |
338 | del_timer_sync(&adapter->phy_info_timer); | 363 | del_timer_sync(&adapter->phy_info_timer); |
@@ -350,62 +375,93 @@ e1000_down(struct e1000_adapter *adapter) | |||
350 | e1000_clean_rx_ring(adapter); | 375 | e1000_clean_rx_ring(adapter); |
351 | 376 | ||
352 | /* If WoL is not enabled | 377 | /* If WoL is not enabled |
378 | * and management mode is not IAMT | ||
353 | * Power down the PHY so no link is implied when interface is down */ | 379 | * Power down the PHY so no link is implied when interface is down */ |
354 | if(!adapter->wol && adapter->hw.media_type == e1000_media_type_copper) { | 380 | if(!adapter->wol && adapter->hw.mac_type >= e1000_82540 && |
381 | adapter->hw.media_type == e1000_media_type_copper && | ||
382 | !e1000_check_mng_mode(&adapter->hw) && | ||
383 | !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN)) { | ||
355 | uint16_t mii_reg; | 384 | uint16_t mii_reg; |
356 | e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); | 385 | e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); |
357 | mii_reg |= MII_CR_POWER_DOWN; | 386 | mii_reg |= MII_CR_POWER_DOWN; |
358 | e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); | 387 | e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); |
388 | mdelay(1); | ||
359 | } | 389 | } |
360 | } | 390 | } |
361 | 391 | ||
362 | void | 392 | void |
363 | e1000_reset(struct e1000_adapter *adapter) | 393 | e1000_reset(struct e1000_adapter *adapter) |
364 | { | 394 | { |
365 | uint32_t pba; | 395 | struct net_device *netdev = adapter->netdev; |
396 | uint32_t pba, manc; | ||
397 | uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF; | ||
398 | uint16_t fc_low_water_mark = E1000_FC_LOW_DIFF; | ||
366 | 399 | ||
367 | /* Repartition Pba for greater than 9k mtu | 400 | /* Repartition Pba for greater than 9k mtu |
368 | * To take effect CTRL.RST is required. | 401 | * To take effect CTRL.RST is required. |
369 | */ | 402 | */ |
370 | 403 | ||
371 | if(adapter->hw.mac_type < e1000_82547) { | 404 | switch (adapter->hw.mac_type) { |
372 | if(adapter->rx_buffer_len > E1000_RXBUFFER_8192) | 405 | case e1000_82547: |
373 | pba = E1000_PBA_40K; | 406 | case e1000_82547_rev_2: |
374 | else | 407 | pba = E1000_PBA_30K; |
375 | pba = E1000_PBA_48K; | 408 | break; |
376 | } else { | 409 | case e1000_82573: |
377 | if(adapter->rx_buffer_len > E1000_RXBUFFER_8192) | 410 | pba = E1000_PBA_12K; |
378 | pba = E1000_PBA_22K; | 411 | break; |
379 | else | 412 | default: |
380 | pba = E1000_PBA_30K; | 413 | pba = E1000_PBA_48K; |
414 | break; | ||
415 | } | ||
416 | |||
417 | if((adapter->hw.mac_type != e1000_82573) && | ||
418 | (adapter->rx_buffer_len > E1000_RXBUFFER_8192)) { | ||
419 | pba -= 8; /* allocate more FIFO for Tx */ | ||
420 | /* send an XOFF when there is enough space in the | ||
421 | * Rx FIFO to hold one extra full size Rx packet | ||
422 | */ | ||
423 | fc_high_water_mark = netdev->mtu + ENET_HEADER_SIZE + | ||
424 | ETHERNET_FCS_SIZE + 1; | ||
425 | fc_low_water_mark = fc_high_water_mark + 8; | ||
426 | } | ||
427 | |||
428 | |||
429 | if(adapter->hw.mac_type == e1000_82547) { | ||
381 | adapter->tx_fifo_head = 0; | 430 | adapter->tx_fifo_head = 0; |
382 | adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT; | 431 | adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT; |
383 | adapter->tx_fifo_size = | 432 | adapter->tx_fifo_size = |
384 | (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT; | 433 | (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT; |
385 | atomic_set(&adapter->tx_fifo_stall, 0); | 434 | atomic_set(&adapter->tx_fifo_stall, 0); |
386 | } | 435 | } |
436 | |||
387 | E1000_WRITE_REG(&adapter->hw, PBA, pba); | 437 | E1000_WRITE_REG(&adapter->hw, PBA, pba); |
388 | 438 | ||
389 | /* flow control settings */ | 439 | /* flow control settings */ |
390 | adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) - | 440 | adapter->hw.fc_high_water = (pba << E1000_PBA_BYTES_SHIFT) - |
391 | E1000_FC_HIGH_DIFF; | 441 | fc_high_water_mark; |
392 | adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) - | 442 | adapter->hw.fc_low_water = (pba << E1000_PBA_BYTES_SHIFT) - |
393 | E1000_FC_LOW_DIFF; | 443 | fc_low_water_mark; |
394 | adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME; | 444 | adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME; |
395 | adapter->hw.fc_send_xon = 1; | 445 | adapter->hw.fc_send_xon = 1; |
396 | adapter->hw.fc = adapter->hw.original_fc; | 446 | adapter->hw.fc = adapter->hw.original_fc; |
397 | 447 | ||
448 | /* Allow time for pending master requests to run */ | ||
398 | e1000_reset_hw(&adapter->hw); | 449 | e1000_reset_hw(&adapter->hw); |
399 | if(adapter->hw.mac_type >= e1000_82544) | 450 | if(adapter->hw.mac_type >= e1000_82544) |
400 | E1000_WRITE_REG(&adapter->hw, WUC, 0); | 451 | E1000_WRITE_REG(&adapter->hw, WUC, 0); |
401 | if(e1000_init_hw(&adapter->hw)) | 452 | if(e1000_init_hw(&adapter->hw)) |
402 | DPRINTK(PROBE, ERR, "Hardware Error\n"); | 453 | DPRINTK(PROBE, ERR, "Hardware Error\n"); |
403 | 454 | e1000_update_mng_vlan(adapter); | |
404 | /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */ | 455 | /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */ |
405 | E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE); | 456 | E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE); |
406 | 457 | ||
407 | e1000_reset_adaptive(&adapter->hw); | 458 | e1000_reset_adaptive(&adapter->hw); |
408 | e1000_phy_get_info(&adapter->hw, &adapter->phy_info); | 459 | e1000_phy_get_info(&adapter->hw, &adapter->phy_info); |
460 | if (adapter->en_mng_pt) { | ||
461 | manc = E1000_READ_REG(&adapter->hw, MANC); | ||
462 | manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST); | ||
463 | E1000_WRITE_REG(&adapter->hw, MANC, manc); | ||
464 | } | ||
409 | } | 465 | } |
410 | 466 | ||
411 | /** | 467 | /** |
@@ -426,15 +482,13 @@ e1000_probe(struct pci_dev *pdev, | |||
426 | { | 482 | { |
427 | struct net_device *netdev; | 483 | struct net_device *netdev; |
428 | struct e1000_adapter *adapter; | 484 | struct e1000_adapter *adapter; |
485 | unsigned long mmio_start, mmio_len; | ||
486 | uint32_t swsm; | ||
487 | |||
429 | static int cards_found = 0; | 488 | static int cards_found = 0; |
430 | unsigned long mmio_start; | 489 | int i, err, pci_using_dac; |
431 | int mmio_len; | ||
432 | int pci_using_dac; | ||
433 | int i; | ||
434 | int err; | ||
435 | uint16_t eeprom_data; | 490 | uint16_t eeprom_data; |
436 | uint16_t eeprom_apme_mask = E1000_EEPROM_APME; | 491 | uint16_t eeprom_apme_mask = E1000_EEPROM_APME; |
437 | |||
438 | if((err = pci_enable_device(pdev))) | 492 | if((err = pci_enable_device(pdev))) |
439 | return err; | 493 | return err; |
440 | 494 | ||
@@ -521,6 +575,9 @@ e1000_probe(struct pci_dev *pdev, | |||
521 | if((err = e1000_sw_init(adapter))) | 575 | if((err = e1000_sw_init(adapter))) |
522 | goto err_sw_init; | 576 | goto err_sw_init; |
523 | 577 | ||
578 | if((err = e1000_check_phy_reset_block(&adapter->hw))) | ||
579 | DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n"); | ||
580 | |||
524 | if(adapter->hw.mac_type >= e1000_82543) { | 581 | if(adapter->hw.mac_type >= e1000_82543) { |
525 | netdev->features = NETIF_F_SG | | 582 | netdev->features = NETIF_F_SG | |
526 | NETIF_F_HW_CSUM | | 583 | NETIF_F_HW_CSUM | |
@@ -533,6 +590,11 @@ e1000_probe(struct pci_dev *pdev, | |||
533 | if((adapter->hw.mac_type >= e1000_82544) && | 590 | if((adapter->hw.mac_type >= e1000_82544) && |
534 | (adapter->hw.mac_type != e1000_82547)) | 591 | (adapter->hw.mac_type != e1000_82547)) |
535 | netdev->features |= NETIF_F_TSO; | 592 | netdev->features |= NETIF_F_TSO; |
593 | |||
594 | #ifdef NETIF_F_TSO_IPV6 | ||
595 | if(adapter->hw.mac_type > e1000_82547_rev_2) | ||
596 | netdev->features |= NETIF_F_TSO_IPV6; | ||
597 | #endif | ||
536 | #endif | 598 | #endif |
537 | if(pci_using_dac) | 599 | if(pci_using_dac) |
538 | netdev->features |= NETIF_F_HIGHDMA; | 600 | netdev->features |= NETIF_F_HIGHDMA; |
@@ -540,6 +602,8 @@ e1000_probe(struct pci_dev *pdev, | |||
540 | /* hard_start_xmit is safe against parallel locking */ | 602 | /* hard_start_xmit is safe against parallel locking */ |
541 | netdev->features |= NETIF_F_LLTX; | 603 | netdev->features |= NETIF_F_LLTX; |
542 | 604 | ||
605 | adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw); | ||
606 | |||
543 | /* before reading the EEPROM, reset the controller to | 607 | /* before reading the EEPROM, reset the controller to |
544 | * put the device in a known good starting state */ | 608 | * put the device in a known good starting state */ |
545 | 609 | ||
@@ -555,7 +619,7 @@ e1000_probe(struct pci_dev *pdev, | |||
555 | 619 | ||
556 | /* copy the MAC address out of the EEPROM */ | 620 | /* copy the MAC address out of the EEPROM */ |
557 | 621 | ||
558 | if (e1000_read_mac_addr(&adapter->hw)) | 622 | if(e1000_read_mac_addr(&adapter->hw)) |
559 | DPRINTK(PROBE, ERR, "EEPROM Read Error\n"); | 623 | DPRINTK(PROBE, ERR, "EEPROM Read Error\n"); |
560 | memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len); | 624 | memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len); |
561 | 625 | ||
@@ -629,6 +693,17 @@ e1000_probe(struct pci_dev *pdev, | |||
629 | /* reset the hardware with the new settings */ | 693 | /* reset the hardware with the new settings */ |
630 | e1000_reset(adapter); | 694 | e1000_reset(adapter); |
631 | 695 | ||
696 | /* Let firmware know the driver has taken over */ | ||
697 | switch(adapter->hw.mac_type) { | ||
698 | case e1000_82573: | ||
699 | swsm = E1000_READ_REG(&adapter->hw, SWSM); | ||
700 | E1000_WRITE_REG(&adapter->hw, SWSM, | ||
701 | swsm | E1000_SWSM_DRV_LOAD); | ||
702 | break; | ||
703 | default: | ||
704 | break; | ||
705 | } | ||
706 | |||
632 | strcpy(netdev->name, "eth%d"); | 707 | strcpy(netdev->name, "eth%d"); |
633 | if((err = register_netdev(netdev))) | 708 | if((err = register_netdev(netdev))) |
634 | goto err_register; | 709 | goto err_register; |
@@ -664,7 +739,7 @@ e1000_remove(struct pci_dev *pdev) | |||
664 | { | 739 | { |
665 | struct net_device *netdev = pci_get_drvdata(pdev); | 740 | struct net_device *netdev = pci_get_drvdata(pdev); |
666 | struct e1000_adapter *adapter = netdev->priv; | 741 | struct e1000_adapter *adapter = netdev->priv; |
667 | uint32_t manc; | 742 | uint32_t manc, swsm; |
668 | 743 | ||
669 | flush_scheduled_work(); | 744 | flush_scheduled_work(); |
670 | 745 | ||
@@ -677,9 +752,21 @@ e1000_remove(struct pci_dev *pdev) | |||
677 | } | 752 | } |
678 | } | 753 | } |
679 | 754 | ||
755 | switch(adapter->hw.mac_type) { | ||
756 | case e1000_82573: | ||
757 | swsm = E1000_READ_REG(&adapter->hw, SWSM); | ||
758 | E1000_WRITE_REG(&adapter->hw, SWSM, | ||
759 | swsm & ~E1000_SWSM_DRV_LOAD); | ||
760 | break; | ||
761 | |||
762 | default: | ||
763 | break; | ||
764 | } | ||
765 | |||
680 | unregister_netdev(netdev); | 766 | unregister_netdev(netdev); |
681 | 767 | ||
682 | e1000_phy_hw_reset(&adapter->hw); | 768 | if(!e1000_check_phy_reset_block(&adapter->hw)) |
769 | e1000_phy_hw_reset(&adapter->hw); | ||
683 | 770 | ||
684 | iounmap(adapter->hw.hw_addr); | 771 | iounmap(adapter->hw.hw_addr); |
685 | pci_release_regions(pdev); | 772 | pci_release_regions(pdev); |
@@ -717,6 +804,7 @@ e1000_sw_init(struct e1000_adapter *adapter) | |||
717 | pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word); | 804 | pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word); |
718 | 805 | ||
719 | adapter->rx_buffer_len = E1000_RXBUFFER_2048; | 806 | adapter->rx_buffer_len = E1000_RXBUFFER_2048; |
807 | adapter->rx_ps_bsize0 = E1000_RXBUFFER_256; | ||
720 | hw->max_frame_size = netdev->mtu + | 808 | hw->max_frame_size = netdev->mtu + |
721 | ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; | 809 | ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; |
722 | hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE; | 810 | hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE; |
@@ -730,7 +818,10 @@ e1000_sw_init(struct e1000_adapter *adapter) | |||
730 | 818 | ||
731 | /* initialize eeprom parameters */ | 819 | /* initialize eeprom parameters */ |
732 | 820 | ||
733 | e1000_init_eeprom_params(hw); | 821 | if(e1000_init_eeprom_params(hw)) { |
822 | E1000_ERR("EEPROM initialization failed\n"); | ||
823 | return -EIO; | ||
824 | } | ||
734 | 825 | ||
735 | switch(hw->mac_type) { | 826 | switch(hw->mac_type) { |
736 | default: | 827 | default: |
@@ -795,6 +886,11 @@ e1000_open(struct net_device *netdev) | |||
795 | 886 | ||
796 | if((err = e1000_up(adapter))) | 887 | if((err = e1000_up(adapter))) |
797 | goto err_up; | 888 | goto err_up; |
889 | adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; | ||
890 | if((adapter->hw.mng_cookie.status & | ||
891 | E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) { | ||
892 | e1000_update_mng_vlan(adapter); | ||
893 | } | ||
798 | 894 | ||
799 | return E1000_SUCCESS; | 895 | return E1000_SUCCESS; |
800 | 896 | ||
@@ -830,14 +926,18 @@ e1000_close(struct net_device *netdev) | |||
830 | e1000_free_tx_resources(adapter); | 926 | e1000_free_tx_resources(adapter); |
831 | e1000_free_rx_resources(adapter); | 927 | e1000_free_rx_resources(adapter); |
832 | 928 | ||
929 | if((adapter->hw.mng_cookie.status & | ||
930 | E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) { | ||
931 | e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); | ||
932 | } | ||
833 | return 0; | 933 | return 0; |
834 | } | 934 | } |
835 | 935 | ||
836 | /** | 936 | /** |
837 | * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary | 937 | * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary |
838 | * @adapter: address of board private structure | 938 | * @adapter: address of board private structure |
839 | * @begin: address of beginning of memory | 939 | * @start: address of beginning of memory |
840 | * @end: address of end of memory | 940 | * @len: length of memory |
841 | **/ | 941 | **/ |
842 | static inline boolean_t | 942 | static inline boolean_t |
843 | e1000_check_64k_bound(struct e1000_adapter *adapter, | 943 | e1000_check_64k_bound(struct e1000_adapter *adapter, |
@@ -846,12 +946,10 @@ e1000_check_64k_bound(struct e1000_adapter *adapter, | |||
846 | unsigned long begin = (unsigned long) start; | 946 | unsigned long begin = (unsigned long) start; |
847 | unsigned long end = begin + len; | 947 | unsigned long end = begin + len; |
848 | 948 | ||
849 | /* first rev 82545 and 82546 need to not allow any memory | 949 | /* First rev 82545 and 82546 need to not allow any memory |
850 | * write location to cross a 64k boundary due to errata 23 */ | 950 | * write location to cross 64k boundary due to errata 23 */ |
851 | if (adapter->hw.mac_type == e1000_82545 || | 951 | if (adapter->hw.mac_type == e1000_82545 || |
852 | adapter->hw.mac_type == e1000_82546 ) { | 952 | adapter->hw.mac_type == e1000_82546) { |
853 | |||
854 | /* check buffer doesn't cross 64kB */ | ||
855 | return ((begin ^ (end - 1)) >> 16) != 0 ? FALSE : TRUE; | 953 | return ((begin ^ (end - 1)) >> 16) != 0 ? FALSE : TRUE; |
856 | } | 954 | } |
857 | 955 | ||
@@ -875,8 +973,8 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter) | |||
875 | size = sizeof(struct e1000_buffer) * txdr->count; | 973 | size = sizeof(struct e1000_buffer) * txdr->count; |
876 | txdr->buffer_info = vmalloc(size); | 974 | txdr->buffer_info = vmalloc(size); |
877 | if(!txdr->buffer_info) { | 975 | if(!txdr->buffer_info) { |
878 | DPRINTK(PROBE, ERR, | 976 | DPRINTK(PROBE, ERR, |
879 | "Unable to Allocate Memory for the Transmit descriptor ring\n"); | 977 | "Unable to allocate memory for the transmit descriptor ring\n"); |
880 | return -ENOMEM; | 978 | return -ENOMEM; |
881 | } | 979 | } |
882 | memset(txdr->buffer_info, 0, size); | 980 | memset(txdr->buffer_info, 0, size); |
@@ -889,38 +987,38 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter) | |||
889 | txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); | 987 | txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); |
890 | if(!txdr->desc) { | 988 | if(!txdr->desc) { |
891 | setup_tx_desc_die: | 989 | setup_tx_desc_die: |
892 | DPRINTK(PROBE, ERR, | ||
893 | "Unable to Allocate Memory for the Transmit descriptor ring\n"); | ||
894 | vfree(txdr->buffer_info); | 990 | vfree(txdr->buffer_info); |
991 | DPRINTK(PROBE, ERR, | ||
992 | "Unable to allocate memory for the transmit descriptor ring\n"); | ||
895 | return -ENOMEM; | 993 | return -ENOMEM; |
896 | } | 994 | } |
897 | 995 | ||
898 | /* fix for errata 23, cant cross 64kB boundary */ | 996 | /* Fix for errata 23, can't cross 64kB boundary */ |
899 | if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { | 997 | if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { |
900 | void *olddesc = txdr->desc; | 998 | void *olddesc = txdr->desc; |
901 | dma_addr_t olddma = txdr->dma; | 999 | dma_addr_t olddma = txdr->dma; |
902 | DPRINTK(TX_ERR,ERR,"txdr align check failed: %u bytes at %p\n", | 1000 | DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes " |
903 | txdr->size, txdr->desc); | 1001 | "at %p\n", txdr->size, txdr->desc); |
904 | /* try again, without freeing the previous */ | 1002 | /* Try again, without freeing the previous */ |
905 | txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); | 1003 | txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); |
906 | /* failed allocation, critial failure */ | ||
907 | if(!txdr->desc) { | 1004 | if(!txdr->desc) { |
1005 | /* Failed allocation, critical failure */ | ||
908 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); | 1006 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); |
909 | goto setup_tx_desc_die; | 1007 | goto setup_tx_desc_die; |
910 | } | 1008 | } |
911 | 1009 | ||
912 | if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { | 1010 | if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { |
913 | /* give up */ | 1011 | /* give up */ |
914 | pci_free_consistent(pdev, txdr->size, | 1012 | pci_free_consistent(pdev, txdr->size, txdr->desc, |
915 | txdr->desc, txdr->dma); | 1013 | txdr->dma); |
916 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); | 1014 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); |
917 | DPRINTK(PROBE, ERR, | 1015 | DPRINTK(PROBE, ERR, |
918 | "Unable to Allocate aligned Memory for the Transmit" | 1016 | "Unable to allocate aligned memory " |
919 | " descriptor ring\n"); | 1017 | "for the transmit descriptor ring\n"); |
920 | vfree(txdr->buffer_info); | 1018 | vfree(txdr->buffer_info); |
921 | return -ENOMEM; | 1019 | return -ENOMEM; |
922 | } else { | 1020 | } else { |
923 | /* free old, move on with the new one since its okay */ | 1021 | /* Free old allocation, new allocation was successful */ |
924 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); | 1022 | pci_free_consistent(pdev, txdr->size, olddesc, olddma); |
925 | } | 1023 | } |
926 | } | 1024 | } |
@@ -1022,59 +1120,88 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter) | |||
1022 | { | 1120 | { |
1023 | struct e1000_desc_ring *rxdr = &adapter->rx_ring; | 1121 | struct e1000_desc_ring *rxdr = &adapter->rx_ring; |
1024 | struct pci_dev *pdev = adapter->pdev; | 1122 | struct pci_dev *pdev = adapter->pdev; |
1025 | int size; | 1123 | int size, desc_len; |
1026 | 1124 | ||
1027 | size = sizeof(struct e1000_buffer) * rxdr->count; | 1125 | size = sizeof(struct e1000_buffer) * rxdr->count; |
1028 | rxdr->buffer_info = vmalloc(size); | 1126 | rxdr->buffer_info = vmalloc(size); |
1029 | if(!rxdr->buffer_info) { | 1127 | if(!rxdr->buffer_info) { |
1030 | DPRINTK(PROBE, ERR, | 1128 | DPRINTK(PROBE, ERR, |
1031 | "Unable to Allocate Memory for the Recieve descriptor ring\n"); | 1129 | "Unable to allocate memory for the receive descriptor ring\n"); |
1032 | return -ENOMEM; | 1130 | return -ENOMEM; |
1033 | } | 1131 | } |
1034 | memset(rxdr->buffer_info, 0, size); | 1132 | memset(rxdr->buffer_info, 0, size); |
1035 | 1133 | ||
1134 | size = sizeof(struct e1000_ps_page) * rxdr->count; | ||
1135 | rxdr->ps_page = kmalloc(size, GFP_KERNEL); | ||
1136 | if(!rxdr->ps_page) { | ||
1137 | vfree(rxdr->buffer_info); | ||
1138 | DPRINTK(PROBE, ERR, | ||
1139 | "Unable to allocate memory for the receive descriptor ring\n"); | ||
1140 | return -ENOMEM; | ||
1141 | } | ||
1142 | memset(rxdr->ps_page, 0, size); | ||
1143 | |||
1144 | size = sizeof(struct e1000_ps_page_dma) * rxdr->count; | ||
1145 | rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL); | ||
1146 | if(!rxdr->ps_page_dma) { | ||
1147 | vfree(rxdr->buffer_info); | ||
1148 | kfree(rxdr->ps_page); | ||
1149 | DPRINTK(PROBE, ERR, | ||
1150 | "Unable to allocate memory for the receive descriptor ring\n"); | ||
1151 | return -ENOMEM; | ||
1152 | } | ||
1153 | memset(rxdr->ps_page_dma, 0, size); | ||
1154 | |||
1155 | if(adapter->hw.mac_type <= e1000_82547_rev_2) | ||
1156 | desc_len = sizeof(struct e1000_rx_desc); | ||
1157 | else | ||
1158 | desc_len = sizeof(union e1000_rx_desc_packet_split); | ||
1159 | |||
1036 | /* Round up to nearest 4K */ | 1160 | /* Round up to nearest 4K */ |
1037 | 1161 | ||
1038 | rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc); | 1162 | rxdr->size = rxdr->count * desc_len; |
1039 | E1000_ROUNDUP(rxdr->size, 4096); | 1163 | E1000_ROUNDUP(rxdr->size, 4096); |
1040 | 1164 | ||
1041 | rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); | 1165 | rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); |
1042 | 1166 | ||
1043 | if(!rxdr->desc) { | 1167 | if(!rxdr->desc) { |
1044 | setup_rx_desc_die: | 1168 | setup_rx_desc_die: |
1045 | DPRINTK(PROBE, ERR, | ||
1046 | "Unble to Allocate Memory for the Recieve descriptor ring\n"); | ||
1047 | vfree(rxdr->buffer_info); | 1169 | vfree(rxdr->buffer_info); |
1170 | kfree(rxdr->ps_page); | ||
1171 | kfree(rxdr->ps_page_dma); | ||
1172 | DPRINTK(PROBE, ERR, | ||
1173 | "Unable to allocate memory for the receive descriptor ring\n"); | ||
1048 | return -ENOMEM; | 1174 | return -ENOMEM; |
1049 | } | 1175 | } |
1050 | 1176 | ||
1051 | /* fix for errata 23, cant cross 64kB boundary */ | 1177 | /* Fix for errata 23, can't cross 64kB boundary */ |
1052 | if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { | 1178 | if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { |
1053 | void *olddesc = rxdr->desc; | 1179 | void *olddesc = rxdr->desc; |
1054 | dma_addr_t olddma = rxdr->dma; | 1180 | dma_addr_t olddma = rxdr->dma; |
1055 | DPRINTK(RX_ERR,ERR, | 1181 | DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes " |
1056 | "rxdr align check failed: %u bytes at %p\n", | 1182 | "at %p\n", rxdr->size, rxdr->desc); |
1057 | rxdr->size, rxdr->desc); | 1183 | /* Try again, without freeing the previous */ |
1058 | /* try again, without freeing the previous */ | ||
1059 | rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); | 1184 | rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); |
1060 | /* failed allocation, critial failure */ | ||
1061 | if(!rxdr->desc) { | 1185 | if(!rxdr->desc) { |
1186 | /* Failed allocation, critical failure */ | ||
1062 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); | 1187 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); |
1063 | goto setup_rx_desc_die; | 1188 | goto setup_rx_desc_die; |
1064 | } | 1189 | } |
1065 | 1190 | ||
1066 | if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { | 1191 | if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { |
1067 | /* give up */ | 1192 | /* give up */ |
1068 | pci_free_consistent(pdev, rxdr->size, | 1193 | pci_free_consistent(pdev, rxdr->size, rxdr->desc, |
1069 | rxdr->desc, rxdr->dma); | 1194 | rxdr->dma); |
1070 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); | 1195 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); |
1071 | DPRINTK(PROBE, ERR, | 1196 | DPRINTK(PROBE, ERR, |
1072 | "Unable to Allocate aligned Memory for the" | 1197 | "Unable to allocate aligned memory " |
1073 | " Receive descriptor ring\n"); | 1198 | "for the receive descriptor ring\n"); |
1074 | vfree(rxdr->buffer_info); | 1199 | vfree(rxdr->buffer_info); |
1200 | kfree(rxdr->ps_page); | ||
1201 | kfree(rxdr->ps_page_dma); | ||
1075 | return -ENOMEM; | 1202 | return -ENOMEM; |
1076 | } else { | 1203 | } else { |
1077 | /* free old, move on with the new one since its okay */ | 1204 | /* Free old allocation, new allocation was successful */ |
1078 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); | 1205 | pci_free_consistent(pdev, rxdr->size, olddesc, olddma); |
1079 | } | 1206 | } |
1080 | } | 1207 | } |
@@ -1087,14 +1214,15 @@ setup_rx_desc_die: | |||
1087 | } | 1214 | } |
1088 | 1215 | ||
1089 | /** | 1216 | /** |
1090 | * e1000_setup_rctl - configure the receive control register | 1217 | * e1000_setup_rctl - configure the receive control registers |
1091 | * @adapter: Board private structure | 1218 | * @adapter: Board private structure |
1092 | **/ | 1219 | **/ |
1093 | 1220 | ||
1094 | static void | 1221 | static void |
1095 | e1000_setup_rctl(struct e1000_adapter *adapter) | 1222 | e1000_setup_rctl(struct e1000_adapter *adapter) |
1096 | { | 1223 | { |
1097 | uint32_t rctl; | 1224 | uint32_t rctl, rfctl; |
1225 | uint32_t psrctl = 0; | ||
1098 | 1226 | ||
1099 | rctl = E1000_READ_REG(&adapter->hw, RCTL); | 1227 | rctl = E1000_READ_REG(&adapter->hw, RCTL); |
1100 | 1228 | ||
@@ -1109,24 +1237,69 @@ e1000_setup_rctl(struct e1000_adapter *adapter) | |||
1109 | else | 1237 | else |
1110 | rctl &= ~E1000_RCTL_SBP; | 1238 | rctl &= ~E1000_RCTL_SBP; |
1111 | 1239 | ||
1240 | if (adapter->netdev->mtu <= ETH_DATA_LEN) | ||
1241 | rctl &= ~E1000_RCTL_LPE; | ||
1242 | else | ||
1243 | rctl |= E1000_RCTL_LPE; | ||
1244 | |||
1112 | /* Setup buffer sizes */ | 1245 | /* Setup buffer sizes */ |
1113 | rctl &= ~(E1000_RCTL_SZ_4096); | 1246 | if(adapter->hw.mac_type == e1000_82573) { |
1114 | rctl |= (E1000_RCTL_BSEX | E1000_RCTL_LPE); | 1247 | /* We can now specify buffers in 1K increments. |
1115 | switch (adapter->rx_buffer_len) { | 1248 | * BSIZE and BSEX are ignored in this case. */ |
1116 | case E1000_RXBUFFER_2048: | 1249 | rctl |= adapter->rx_buffer_len << 0x11; |
1117 | default: | 1250 | } else { |
1118 | rctl |= E1000_RCTL_SZ_2048; | 1251 | rctl &= ~E1000_RCTL_SZ_4096; |
1119 | rctl &= ~(E1000_RCTL_BSEX | E1000_RCTL_LPE); | 1252 | rctl |= E1000_RCTL_BSEX; |
1120 | break; | 1253 | switch (adapter->rx_buffer_len) { |
1121 | case E1000_RXBUFFER_4096: | 1254 | case E1000_RXBUFFER_2048: |
1122 | rctl |= E1000_RCTL_SZ_4096; | 1255 | default: |
1123 | break; | 1256 | rctl |= E1000_RCTL_SZ_2048; |
1124 | case E1000_RXBUFFER_8192: | 1257 | rctl &= ~E1000_RCTL_BSEX; |
1125 | rctl |= E1000_RCTL_SZ_8192; | 1258 | break; |
1126 | break; | 1259 | case E1000_RXBUFFER_4096: |
1127 | case E1000_RXBUFFER_16384: | 1260 | rctl |= E1000_RCTL_SZ_4096; |
1128 | rctl |= E1000_RCTL_SZ_16384; | 1261 | break; |
1129 | break; | 1262 | case E1000_RXBUFFER_8192: |
1263 | rctl |= E1000_RCTL_SZ_8192; | ||
1264 | break; | ||
1265 | case E1000_RXBUFFER_16384: | ||
1266 | rctl |= E1000_RCTL_SZ_16384; | ||
1267 | break; | ||
1268 | } | ||
1269 | } | ||
1270 | |||
1271 | #ifdef CONFIG_E1000_PACKET_SPLIT | ||
1272 | /* 82571 and greater support packet-split where the protocol | ||
1273 | * header is placed in skb->data and the packet data is | ||
1274 | * placed in pages hanging off of skb_shinfo(skb)->nr_frags. | ||
1275 | * In the case of a non-split, skb->data is linearly filled, | ||
1276 | * followed by the page buffers. Therefore, skb->data is | ||
1277 | * sized to hold the largest protocol header. | ||
1278 | */ | ||
1279 | adapter->rx_ps = (adapter->hw.mac_type > e1000_82547_rev_2) | ||
1280 | && (adapter->netdev->mtu | ||
1281 | < ((3 * PAGE_SIZE) + adapter->rx_ps_bsize0)); | ||
1282 | #endif | ||
1283 | if(adapter->rx_ps) { | ||
1284 | /* Configure extra packet-split registers */ | ||
1285 | rfctl = E1000_READ_REG(&adapter->hw, RFCTL); | ||
1286 | rfctl |= E1000_RFCTL_EXTEN; | ||
1287 | /* disable IPv6 packet split support */ | ||
1288 | rfctl |= E1000_RFCTL_IPV6_DIS; | ||
1289 | E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl); | ||
1290 | |||
1291 | rctl |= E1000_RCTL_DTYP_PS | E1000_RCTL_SECRC; | ||
1292 | |||
1293 | psrctl |= adapter->rx_ps_bsize0 >> | ||
1294 | E1000_PSRCTL_BSIZE0_SHIFT; | ||
1295 | psrctl |= PAGE_SIZE >> | ||
1296 | E1000_PSRCTL_BSIZE1_SHIFT; | ||
1297 | psrctl |= PAGE_SIZE << | ||
1298 | E1000_PSRCTL_BSIZE2_SHIFT; | ||
1299 | psrctl |= PAGE_SIZE << | ||
1300 | E1000_PSRCTL_BSIZE3_SHIFT; | ||
1301 | |||
1302 | E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl); | ||
1130 | } | 1303 | } |
1131 | 1304 | ||
1132 | E1000_WRITE_REG(&adapter->hw, RCTL, rctl); | 1305 | E1000_WRITE_REG(&adapter->hw, RCTL, rctl); |
@@ -1143,9 +1316,18 @@ static void | |||
1143 | e1000_configure_rx(struct e1000_adapter *adapter) | 1316 | e1000_configure_rx(struct e1000_adapter *adapter) |
1144 | { | 1317 | { |
1145 | uint64_t rdba = adapter->rx_ring.dma; | 1318 | uint64_t rdba = adapter->rx_ring.dma; |
1146 | uint32_t rdlen = adapter->rx_ring.count * sizeof(struct e1000_rx_desc); | 1319 | uint32_t rdlen, rctl, rxcsum; |
1147 | uint32_t rctl; | 1320 | |
1148 | uint32_t rxcsum; | 1321 | if(adapter->rx_ps) { |
1322 | rdlen = adapter->rx_ring.count * | ||
1323 | sizeof(union e1000_rx_desc_packet_split); | ||
1324 | adapter->clean_rx = e1000_clean_rx_irq_ps; | ||
1325 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; | ||
1326 | } else { | ||
1327 | rdlen = adapter->rx_ring.count * sizeof(struct e1000_rx_desc); | ||
1328 | adapter->clean_rx = e1000_clean_rx_irq; | ||
1329 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers; | ||
1330 | } | ||
1149 | 1331 | ||
1150 | /* disable receives while setting up the descriptors */ | 1332 | /* disable receives while setting up the descriptors */ |
1151 | rctl = E1000_READ_REG(&adapter->hw, RCTL); | 1333 | rctl = E1000_READ_REG(&adapter->hw, RCTL); |
@@ -1172,13 +1354,27 @@ e1000_configure_rx(struct e1000_adapter *adapter) | |||
1172 | E1000_WRITE_REG(&adapter->hw, RDT, 0); | 1354 | E1000_WRITE_REG(&adapter->hw, RDT, 0); |
1173 | 1355 | ||
1174 | /* Enable 82543 Receive Checksum Offload for TCP and UDP */ | 1356 | /* Enable 82543 Receive Checksum Offload for TCP and UDP */ |
1175 | if((adapter->hw.mac_type >= e1000_82543) && | 1357 | if(adapter->hw.mac_type >= e1000_82543) { |
1176 | (adapter->rx_csum == TRUE)) { | ||
1177 | rxcsum = E1000_READ_REG(&adapter->hw, RXCSUM); | 1358 | rxcsum = E1000_READ_REG(&adapter->hw, RXCSUM); |
1178 | rxcsum |= E1000_RXCSUM_TUOFL; | 1359 | if(adapter->rx_csum == TRUE) { |
1360 | rxcsum |= E1000_RXCSUM_TUOFL; | ||
1361 | |||
1362 | /* Enable 82573 IPv4 payload checksum for UDP fragments | ||
1363 | * Must be used in conjunction with packet-split. */ | ||
1364 | if((adapter->hw.mac_type > e1000_82547_rev_2) && | ||
1365 | (adapter->rx_ps)) { | ||
1366 | rxcsum |= E1000_RXCSUM_IPPCSE; | ||
1367 | } | ||
1368 | } else { | ||
1369 | rxcsum &= ~E1000_RXCSUM_TUOFL; | ||
1370 | /* don't need to clear IPPCSE as it defaults to 0 */ | ||
1371 | } | ||
1179 | E1000_WRITE_REG(&adapter->hw, RXCSUM, rxcsum); | 1372 | E1000_WRITE_REG(&adapter->hw, RXCSUM, rxcsum); |
1180 | } | 1373 | } |
1181 | 1374 | ||
1375 | if (adapter->hw.mac_type == e1000_82573) | ||
1376 | E1000_WRITE_REG(&adapter->hw, ERT, 0x0100); | ||
1377 | |||
1182 | /* Enable Receives */ | 1378 | /* Enable Receives */ |
1183 | E1000_WRITE_REG(&adapter->hw, RCTL, rctl); | 1379 | E1000_WRITE_REG(&adapter->hw, RCTL, rctl); |
1184 | } | 1380 | } |
@@ -1210,13 +1406,11 @@ static inline void | |||
1210 | e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter, | 1406 | e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter, |
1211 | struct e1000_buffer *buffer_info) | 1407 | struct e1000_buffer *buffer_info) |
1212 | { | 1408 | { |
1213 | struct pci_dev *pdev = adapter->pdev; | ||
1214 | |||
1215 | if(buffer_info->dma) { | 1409 | if(buffer_info->dma) { |
1216 | pci_unmap_page(pdev, | 1410 | pci_unmap_page(adapter->pdev, |
1217 | buffer_info->dma, | 1411 | buffer_info->dma, |
1218 | buffer_info->length, | 1412 | buffer_info->length, |
1219 | PCI_DMA_TODEVICE); | 1413 | PCI_DMA_TODEVICE); |
1220 | buffer_info->dma = 0; | 1414 | buffer_info->dma = 0; |
1221 | } | 1415 | } |
1222 | if(buffer_info->skb) { | 1416 | if(buffer_info->skb) { |
@@ -1241,7 +1435,7 @@ e1000_clean_tx_ring(struct e1000_adapter *adapter) | |||
1241 | /* Free all the Tx ring sk_buffs */ | 1435 | /* Free all the Tx ring sk_buffs */ |
1242 | 1436 | ||
1243 | if (likely(adapter->previous_buffer_info.skb != NULL)) { | 1437 | if (likely(adapter->previous_buffer_info.skb != NULL)) { |
1244 | e1000_unmap_and_free_tx_resource(adapter, | 1438 | e1000_unmap_and_free_tx_resource(adapter, |
1245 | &adapter->previous_buffer_info); | 1439 | &adapter->previous_buffer_info); |
1246 | } | 1440 | } |
1247 | 1441 | ||
@@ -1281,6 +1475,10 @@ e1000_free_rx_resources(struct e1000_adapter *adapter) | |||
1281 | 1475 | ||
1282 | vfree(rx_ring->buffer_info); | 1476 | vfree(rx_ring->buffer_info); |
1283 | rx_ring->buffer_info = NULL; | 1477 | rx_ring->buffer_info = NULL; |
1478 | kfree(rx_ring->ps_page); | ||
1479 | rx_ring->ps_page = NULL; | ||
1480 | kfree(rx_ring->ps_page_dma); | ||
1481 | rx_ring->ps_page_dma = NULL; | ||
1284 | 1482 | ||
1285 | pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma); | 1483 | pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma); |
1286 | 1484 | ||
@@ -1297,16 +1495,19 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1297 | { | 1495 | { |
1298 | struct e1000_desc_ring *rx_ring = &adapter->rx_ring; | 1496 | struct e1000_desc_ring *rx_ring = &adapter->rx_ring; |
1299 | struct e1000_buffer *buffer_info; | 1497 | struct e1000_buffer *buffer_info; |
1498 | struct e1000_ps_page *ps_page; | ||
1499 | struct e1000_ps_page_dma *ps_page_dma; | ||
1300 | struct pci_dev *pdev = adapter->pdev; | 1500 | struct pci_dev *pdev = adapter->pdev; |
1301 | unsigned long size; | 1501 | unsigned long size; |
1302 | unsigned int i; | 1502 | unsigned int i, j; |
1303 | 1503 | ||
1304 | /* Free all the Rx ring sk_buffs */ | 1504 | /* Free all the Rx ring sk_buffs */ |
1305 | 1505 | ||
1306 | for(i = 0; i < rx_ring->count; i++) { | 1506 | for(i = 0; i < rx_ring->count; i++) { |
1307 | buffer_info = &rx_ring->buffer_info[i]; | 1507 | buffer_info = &rx_ring->buffer_info[i]; |
1308 | if(buffer_info->skb) { | 1508 | if(buffer_info->skb) { |
1309 | 1509 | ps_page = &rx_ring->ps_page[i]; | |
1510 | ps_page_dma = &rx_ring->ps_page_dma[i]; | ||
1310 | pci_unmap_single(pdev, | 1511 | pci_unmap_single(pdev, |
1311 | buffer_info->dma, | 1512 | buffer_info->dma, |
1312 | buffer_info->length, | 1513 | buffer_info->length, |
@@ -1314,11 +1515,25 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter) | |||
1314 | 1515 | ||
1315 | dev_kfree_skb(buffer_info->skb); | 1516 | dev_kfree_skb(buffer_info->skb); |
1316 | buffer_info->skb = NULL; | 1517 | buffer_info->skb = NULL; |
1518 | |||
1519 | for(j = 0; j < PS_PAGE_BUFFERS; j++) { | ||
1520 | if(!ps_page->ps_page[j]) break; | ||
1521 | pci_unmap_single(pdev, | ||
1522 | ps_page_dma->ps_page_dma[j], | ||
1523 | PAGE_SIZE, PCI_DMA_FROMDEVICE); | ||
1524 | ps_page_dma->ps_page_dma[j] = 0; | ||
1525 | put_page(ps_page->ps_page[j]); | ||
1526 | ps_page->ps_page[j] = NULL; | ||
1527 | } | ||
1317 | } | 1528 | } |
1318 | } | 1529 | } |
1319 | 1530 | ||
1320 | size = sizeof(struct e1000_buffer) * rx_ring->count; | 1531 | size = sizeof(struct e1000_buffer) * rx_ring->count; |
1321 | memset(rx_ring->buffer_info, 0, size); | 1532 | memset(rx_ring->buffer_info, 0, size); |
1533 | size = sizeof(struct e1000_ps_page) * rx_ring->count; | ||
1534 | memset(rx_ring->ps_page, 0, size); | ||
1535 | size = sizeof(struct e1000_ps_page_dma) * rx_ring->count; | ||
1536 | memset(rx_ring->ps_page_dma, 0, size); | ||
1322 | 1537 | ||
1323 | /* Zero out the descriptor ring */ | 1538 | /* Zero out the descriptor ring */ |
1324 | 1539 | ||
@@ -1422,15 +1637,15 @@ e1000_set_multi(struct net_device *netdev) | |||
1422 | struct e1000_adapter *adapter = netdev->priv; | 1637 | struct e1000_adapter *adapter = netdev->priv; |
1423 | struct e1000_hw *hw = &adapter->hw; | 1638 | struct e1000_hw *hw = &adapter->hw; |
1424 | struct dev_mc_list *mc_ptr; | 1639 | struct dev_mc_list *mc_ptr; |
1640 | unsigned long flags; | ||
1425 | uint32_t rctl; | 1641 | uint32_t rctl; |
1426 | uint32_t hash_value; | 1642 | uint32_t hash_value; |
1427 | int i; | 1643 | int i; |
1428 | unsigned long flags; | ||
1429 | |||
1430 | /* Check for Promiscuous and All Multicast modes */ | ||
1431 | 1644 | ||
1432 | spin_lock_irqsave(&adapter->tx_lock, flags); | 1645 | spin_lock_irqsave(&adapter->tx_lock, flags); |
1433 | 1646 | ||
1647 | /* Check for Promiscuous and All Multicast modes */ | ||
1648 | |||
1434 | rctl = E1000_READ_REG(hw, RCTL); | 1649 | rctl = E1000_READ_REG(hw, RCTL); |
1435 | 1650 | ||
1436 | if(netdev->flags & IFF_PROMISC) { | 1651 | if(netdev->flags & IFF_PROMISC) { |
@@ -1556,6 +1771,11 @@ e1000_watchdog_task(struct e1000_adapter *adapter) | |||
1556 | uint32_t link; | 1771 | uint32_t link; |
1557 | 1772 | ||
1558 | e1000_check_for_link(&adapter->hw); | 1773 | e1000_check_for_link(&adapter->hw); |
1774 | if (adapter->hw.mac_type == e1000_82573) { | ||
1775 | e1000_enable_tx_pkt_filtering(&adapter->hw); | ||
1776 | if(adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id) | ||
1777 | e1000_update_mng_vlan(adapter); | ||
1778 | } | ||
1559 | 1779 | ||
1560 | if((adapter->hw.media_type == e1000_media_type_internal_serdes) && | 1780 | if((adapter->hw.media_type == e1000_media_type_internal_serdes) && |
1561 | !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) | 1781 | !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) |
@@ -1632,7 +1852,7 @@ e1000_watchdog_task(struct e1000_adapter *adapter) | |||
1632 | /* Cause software interrupt to ensure rx ring is cleaned */ | 1852 | /* Cause software interrupt to ensure rx ring is cleaned */ |
1633 | E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0); | 1853 | E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0); |
1634 | 1854 | ||
1635 | /* Force detection of hung controller every watchdog period*/ | 1855 | /* Force detection of hung controller every watchdog period */ |
1636 | adapter->detect_tx_hung = TRUE; | 1856 | adapter->detect_tx_hung = TRUE; |
1637 | 1857 | ||
1638 | /* Reset the timer */ | 1858 | /* Reset the timer */ |
@@ -1642,6 +1862,7 @@ e1000_watchdog_task(struct e1000_adapter *adapter) | |||
1642 | #define E1000_TX_FLAGS_CSUM 0x00000001 | 1862 | #define E1000_TX_FLAGS_CSUM 0x00000001 |
1643 | #define E1000_TX_FLAGS_VLAN 0x00000002 | 1863 | #define E1000_TX_FLAGS_VLAN 0x00000002 |
1644 | #define E1000_TX_FLAGS_TSO 0x00000004 | 1864 | #define E1000_TX_FLAGS_TSO 0x00000004 |
1865 | #define E1000_TX_FLAGS_IPV4 0x00000008 | ||
1645 | #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 | 1866 | #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 |
1646 | #define E1000_TX_FLAGS_VLAN_SHIFT 16 | 1867 | #define E1000_TX_FLAGS_VLAN_SHIFT 16 |
1647 | 1868 | ||
@@ -1652,7 +1873,7 @@ e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb) | |||
1652 | struct e1000_context_desc *context_desc; | 1873 | struct e1000_context_desc *context_desc; |
1653 | unsigned int i; | 1874 | unsigned int i; |
1654 | uint32_t cmd_length = 0; | 1875 | uint32_t cmd_length = 0; |
1655 | uint16_t ipcse, tucse, mss; | 1876 | uint16_t ipcse = 0, tucse, mss; |
1656 | uint8_t ipcss, ipcso, tucss, tucso, hdr_len; | 1877 | uint8_t ipcss, ipcso, tucss, tucso, hdr_len; |
1657 | int err; | 1878 | int err; |
1658 | 1879 | ||
@@ -1665,23 +1886,37 @@ e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb) | |||
1665 | 1886 | ||
1666 | hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); | 1887 | hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); |
1667 | mss = skb_shinfo(skb)->tso_size; | 1888 | mss = skb_shinfo(skb)->tso_size; |
1668 | skb->nh.iph->tot_len = 0; | 1889 | if(skb->protocol == ntohs(ETH_P_IP)) { |
1669 | skb->nh.iph->check = 0; | 1890 | skb->nh.iph->tot_len = 0; |
1670 | skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr, | 1891 | skb->nh.iph->check = 0; |
1671 | skb->nh.iph->daddr, | 1892 | skb->h.th->check = |
1672 | 0, | 1893 | ~csum_tcpudp_magic(skb->nh.iph->saddr, |
1673 | IPPROTO_TCP, | 1894 | skb->nh.iph->daddr, |
1674 | 0); | 1895 | 0, |
1896 | IPPROTO_TCP, | ||
1897 | 0); | ||
1898 | cmd_length = E1000_TXD_CMD_IP; | ||
1899 | ipcse = skb->h.raw - skb->data - 1; | ||
1900 | #ifdef NETIF_F_TSO_IPV6 | ||
1901 | } else if(skb->protocol == ntohs(ETH_P_IPV6)) { | ||
1902 | skb->nh.ipv6h->payload_len = 0; | ||
1903 | skb->h.th->check = | ||
1904 | ~csum_ipv6_magic(&skb->nh.ipv6h->saddr, | ||
1905 | &skb->nh.ipv6h->daddr, | ||
1906 | 0, | ||
1907 | IPPROTO_TCP, | ||
1908 | 0); | ||
1909 | ipcse = 0; | ||
1910 | #endif | ||
1911 | } | ||
1675 | ipcss = skb->nh.raw - skb->data; | 1912 | ipcss = skb->nh.raw - skb->data; |
1676 | ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data; | 1913 | ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data; |
1677 | ipcse = skb->h.raw - skb->data - 1; | ||
1678 | tucss = skb->h.raw - skb->data; | 1914 | tucss = skb->h.raw - skb->data; |
1679 | tucso = (void *)&(skb->h.th->check) - (void *)skb->data; | 1915 | tucso = (void *)&(skb->h.th->check) - (void *)skb->data; |
1680 | tucse = 0; | 1916 | tucse = 0; |
1681 | 1917 | ||
1682 | cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE | | 1918 | cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE | |
1683 | E1000_TXD_CMD_IP | E1000_TXD_CMD_TCP | | 1919 | E1000_TXD_CMD_TCP | (skb->len - (hdr_len))); |
1684 | (skb->len - (hdr_len))); | ||
1685 | 1920 | ||
1686 | i = adapter->tx_ring.next_to_use; | 1921 | i = adapter->tx_ring.next_to_use; |
1687 | context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i); | 1922 | context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i); |
@@ -1760,6 +1995,15 @@ e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb, | |||
1760 | if(unlikely(mss && !nr_frags && size == len && size > 8)) | 1995 | if(unlikely(mss && !nr_frags && size == len && size > 8)) |
1761 | size -= 4; | 1996 | size -= 4; |
1762 | #endif | 1997 | #endif |
1998 | /* work-around for errata 10 and it applies | ||
1999 | * to all controllers in PCI-X mode | ||
2000 | * The fix is to make sure that the first descriptor of a | ||
2001 | * packet is smaller than 2048 - 16 - 16 (or 2016) bytes | ||
2002 | */ | ||
2003 | if(unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) && | ||
2004 | (size > 2015) && count == 0)) | ||
2005 | size = 2015; | ||
2006 | |||
1763 | /* Workaround for potential 82544 hang in PCI-X. Avoid | 2007 | /* Workaround for potential 82544 hang in PCI-X. Avoid |
1764 | * terminating buffers within evenly-aligned dwords. */ | 2008 | * terminating buffers within evenly-aligned dwords. */ |
1765 | if(unlikely(adapter->pcix_82544 && | 2009 | if(unlikely(adapter->pcix_82544 && |
@@ -1840,7 +2084,10 @@ e1000_tx_queue(struct e1000_adapter *adapter, int count, int tx_flags) | |||
1840 | if(likely(tx_flags & E1000_TX_FLAGS_TSO)) { | 2084 | if(likely(tx_flags & E1000_TX_FLAGS_TSO)) { |
1841 | txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D | | 2085 | txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D | |
1842 | E1000_TXD_CMD_TSE; | 2086 | E1000_TXD_CMD_TSE; |
1843 | txd_upper |= (E1000_TXD_POPTS_IXSM | E1000_TXD_POPTS_TXSM) << 8; | 2087 | txd_upper |= E1000_TXD_POPTS_TXSM << 8; |
2088 | |||
2089 | if(likely(tx_flags & E1000_TX_FLAGS_IPV4)) | ||
2090 | txd_upper |= E1000_TXD_POPTS_IXSM << 8; | ||
1844 | } | 2091 | } |
1845 | 2092 | ||
1846 | if(likely(tx_flags & E1000_TX_FLAGS_CSUM)) { | 2093 | if(likely(tx_flags & E1000_TX_FLAGS_CSUM)) { |
@@ -1915,6 +2162,53 @@ no_fifo_stall_required: | |||
1915 | return 0; | 2162 | return 0; |
1916 | } | 2163 | } |
1917 | 2164 | ||
2165 | #define MINIMUM_DHCP_PACKET_SIZE 282 | ||
2166 | static inline int | ||
2167 | e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb) | ||
2168 | { | ||
2169 | struct e1000_hw *hw = &adapter->hw; | ||
2170 | uint16_t length, offset; | ||
2171 | if(vlan_tx_tag_present(skb)) { | ||
2172 | if(!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) && | ||
2173 | ( adapter->hw.mng_cookie.status & | ||
2174 | E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) ) | ||
2175 | return 0; | ||
2176 | } | ||
2177 | if(htons(ETH_P_IP) == skb->protocol) { | ||
2178 | const struct iphdr *ip = skb->nh.iph; | ||
2179 | if(IPPROTO_UDP == ip->protocol) { | ||
2180 | struct udphdr *udp = (struct udphdr *)(skb->h.uh); | ||
2181 | if(ntohs(udp->dest) == 67) { | ||
2182 | offset = (uint8_t *)udp + 8 - skb->data; | ||
2183 | length = skb->len - offset; | ||
2184 | |||
2185 | return e1000_mng_write_dhcp_info(hw, | ||
2186 | (uint8_t *)udp + 8, length); | ||
2187 | } | ||
2188 | } | ||
2189 | } else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) { | ||
2190 | struct ethhdr *eth = (struct ethhdr *) skb->data; | ||
2191 | if((htons(ETH_P_IP) == eth->h_proto)) { | ||
2192 | const struct iphdr *ip = | ||
2193 | (struct iphdr *)((uint8_t *)skb->data+14); | ||
2194 | if(IPPROTO_UDP == ip->protocol) { | ||
2195 | struct udphdr *udp = | ||
2196 | (struct udphdr *)((uint8_t *)ip + | ||
2197 | (ip->ihl << 2)); | ||
2198 | if(ntohs(udp->dest) == 67) { | ||
2199 | offset = (uint8_t *)udp + 8 - skb->data; | ||
2200 | length = skb->len - offset; | ||
2201 | |||
2202 | return e1000_mng_write_dhcp_info(hw, | ||
2203 | (uint8_t *)udp + 8, | ||
2204 | length); | ||
2205 | } | ||
2206 | } | ||
2207 | } | ||
2208 | } | ||
2209 | return 0; | ||
2210 | } | ||
2211 | |||
1918 | #define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 ) | 2212 | #define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 ) |
1919 | static int | 2213 | static int |
1920 | e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | 2214 | e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) |
@@ -1939,7 +2233,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1939 | 2233 | ||
1940 | #ifdef NETIF_F_TSO | 2234 | #ifdef NETIF_F_TSO |
1941 | mss = skb_shinfo(skb)->tso_size; | 2235 | mss = skb_shinfo(skb)->tso_size; |
1942 | /* The controller does a simple calculation to | 2236 | /* The controller does a simple calculation to |
1943 | * make sure there is enough room in the FIFO before | 2237 | * make sure there is enough room in the FIFO before |
1944 | * initiating the DMA for each buffer. The calc is: | 2238 | * initiating the DMA for each buffer. The calc is: |
1945 | * 4 = ceil(buffer len/mss). To make sure we don't | 2239 | * 4 = ceil(buffer len/mss). To make sure we don't |
@@ -1952,7 +2246,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1952 | 2246 | ||
1953 | if((mss) || (skb->ip_summed == CHECKSUM_HW)) | 2247 | if((mss) || (skb->ip_summed == CHECKSUM_HW)) |
1954 | count++; | 2248 | count++; |
1955 | count++; /* for sentinel desc */ | 2249 | count++; |
1956 | #else | 2250 | #else |
1957 | if(skb->ip_summed == CHECKSUM_HW) | 2251 | if(skb->ip_summed == CHECKSUM_HW) |
1958 | count++; | 2252 | count++; |
@@ -1962,6 +2256,13 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1962 | if(adapter->pcix_82544) | 2256 | if(adapter->pcix_82544) |
1963 | count++; | 2257 | count++; |
1964 | 2258 | ||
2259 | /* work-around for errata 10 and it applies to all controllers | ||
2260 | * in PCI-X mode, so add one more descriptor to the count | ||
2261 | */ | ||
2262 | if(unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) && | ||
2263 | (len > 2015))) | ||
2264 | count++; | ||
2265 | |||
1965 | nr_frags = skb_shinfo(skb)->nr_frags; | 2266 | nr_frags = skb_shinfo(skb)->nr_frags; |
1966 | for(f = 0; f < nr_frags; f++) | 2267 | for(f = 0; f < nr_frags; f++) |
1967 | count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size, | 2268 | count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size, |
@@ -1975,6 +2276,9 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1975 | local_irq_restore(flags); | 2276 | local_irq_restore(flags); |
1976 | return NETDEV_TX_LOCKED; | 2277 | return NETDEV_TX_LOCKED; |
1977 | } | 2278 | } |
2279 | if(adapter->hw.tx_pkt_filtering && (adapter->hw.mac_type == e1000_82573) ) | ||
2280 | e1000_transfer_dhcp_info(adapter, skb); | ||
2281 | |||
1978 | 2282 | ||
1979 | /* need: count + 2 desc gap to keep tail from touching | 2283 | /* need: count + 2 desc gap to keep tail from touching |
1980 | * head, otherwise try next time */ | 2284 | * head, otherwise try next time */ |
@@ -2011,6 +2315,12 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
2011 | else if(likely(e1000_tx_csum(adapter, skb))) | 2315 | else if(likely(e1000_tx_csum(adapter, skb))) |
2012 | tx_flags |= E1000_TX_FLAGS_CSUM; | 2316 | tx_flags |= E1000_TX_FLAGS_CSUM; |
2013 | 2317 | ||
2318 | /* Old method was to assume IPv4 packet by default if TSO was enabled. | ||
2319 | * 82573 hardware supports TSO capabilities for IPv6 as well... | ||
2320 | * no longer assume, we must. */ | ||
2321 | if(likely(skb->protocol == ntohs(ETH_P_IP))) | ||
2322 | tx_flags |= E1000_TX_FLAGS_IPV4; | ||
2323 | |||
2014 | e1000_tx_queue(adapter, | 2324 | e1000_tx_queue(adapter, |
2015 | e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss), | 2325 | e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss), |
2016 | tx_flags); | 2326 | tx_flags); |
@@ -2077,7 +2387,6 @@ static int | |||
2077 | e1000_change_mtu(struct net_device *netdev, int new_mtu) | 2387 | e1000_change_mtu(struct net_device *netdev, int new_mtu) |
2078 | { | 2388 | { |
2079 | struct e1000_adapter *adapter = netdev->priv; | 2389 | struct e1000_adapter *adapter = netdev->priv; |
2080 | int old_mtu = adapter->rx_buffer_len; | ||
2081 | int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; | 2390 | int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; |
2082 | 2391 | ||
2083 | if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || | 2392 | if((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || |
@@ -2086,29 +2395,45 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
2086 | return -EINVAL; | 2395 | return -EINVAL; |
2087 | } | 2396 | } |
2088 | 2397 | ||
2089 | if(max_frame <= MAXIMUM_ETHERNET_FRAME_SIZE) { | 2398 | #define MAX_STD_JUMBO_FRAME_SIZE 9216 |
2090 | adapter->rx_buffer_len = E1000_RXBUFFER_2048; | 2399 | /* might want this to be bigger enum check... */ |
2091 | 2400 | if (adapter->hw.mac_type == e1000_82573 && | |
2092 | } else if(adapter->hw.mac_type < e1000_82543) { | 2401 | max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { |
2093 | DPRINTK(PROBE, ERR, "Jumbo Frames not supported on 82542\n"); | 2402 | DPRINTK(PROBE, ERR, "Jumbo Frames not supported " |
2403 | "on 82573\n"); | ||
2094 | return -EINVAL; | 2404 | return -EINVAL; |
2405 | } | ||
2095 | 2406 | ||
2096 | } else if(max_frame <= E1000_RXBUFFER_4096) { | 2407 | if(adapter->hw.mac_type > e1000_82547_rev_2) { |
2097 | adapter->rx_buffer_len = E1000_RXBUFFER_4096; | 2408 | adapter->rx_buffer_len = max_frame; |
2098 | 2409 | E1000_ROUNDUP(adapter->rx_buffer_len, 1024); | |
2099 | } else if(max_frame <= E1000_RXBUFFER_8192) { | ||
2100 | adapter->rx_buffer_len = E1000_RXBUFFER_8192; | ||
2101 | |||
2102 | } else { | 2410 | } else { |
2103 | adapter->rx_buffer_len = E1000_RXBUFFER_16384; | 2411 | if(unlikely((adapter->hw.mac_type < e1000_82543) && |
2412 | (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) { | ||
2413 | DPRINTK(PROBE, ERR, "Jumbo Frames not supported " | ||
2414 | "on 82542\n"); | ||
2415 | return -EINVAL; | ||
2416 | |||
2417 | } else { | ||
2418 | if(max_frame <= E1000_RXBUFFER_2048) { | ||
2419 | adapter->rx_buffer_len = E1000_RXBUFFER_2048; | ||
2420 | } else if(max_frame <= E1000_RXBUFFER_4096) { | ||
2421 | adapter->rx_buffer_len = E1000_RXBUFFER_4096; | ||
2422 | } else if(max_frame <= E1000_RXBUFFER_8192) { | ||
2423 | adapter->rx_buffer_len = E1000_RXBUFFER_8192; | ||
2424 | } else if(max_frame <= E1000_RXBUFFER_16384) { | ||
2425 | adapter->rx_buffer_len = E1000_RXBUFFER_16384; | ||
2426 | } | ||
2427 | } | ||
2104 | } | 2428 | } |
2105 | 2429 | ||
2106 | if(old_mtu != adapter->rx_buffer_len && netif_running(netdev)) { | 2430 | netdev->mtu = new_mtu; |
2431 | |||
2432 | if(netif_running(netdev)) { | ||
2107 | e1000_down(adapter); | 2433 | e1000_down(adapter); |
2108 | e1000_up(adapter); | 2434 | e1000_up(adapter); |
2109 | } | 2435 | } |
2110 | 2436 | ||
2111 | netdev->mtu = new_mtu; | ||
2112 | adapter->hw.max_frame_size = max_frame; | 2437 | adapter->hw.max_frame_size = max_frame; |
2113 | 2438 | ||
2114 | return 0; | 2439 | return 0; |
@@ -2199,6 +2524,17 @@ e1000_update_stats(struct e1000_adapter *adapter) | |||
2199 | adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC); | 2524 | adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC); |
2200 | adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC); | 2525 | adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC); |
2201 | } | 2526 | } |
2527 | if(hw->mac_type > e1000_82547_rev_2) { | ||
2528 | adapter->stats.iac += E1000_READ_REG(hw, IAC); | ||
2529 | adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC); | ||
2530 | adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC); | ||
2531 | adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC); | ||
2532 | adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC); | ||
2533 | adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC); | ||
2534 | adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC); | ||
2535 | adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC); | ||
2536 | adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC); | ||
2537 | } | ||
2202 | 2538 | ||
2203 | /* Fill out the OS statistics structure */ | 2539 | /* Fill out the OS statistics structure */ |
2204 | 2540 | ||
@@ -2213,9 +2549,9 @@ e1000_update_stats(struct e1000_adapter *adapter) | |||
2213 | 2549 | ||
2214 | adapter->net_stats.rx_errors = adapter->stats.rxerrc + | 2550 | adapter->net_stats.rx_errors = adapter->stats.rxerrc + |
2215 | adapter->stats.crcerrs + adapter->stats.algnerrc + | 2551 | adapter->stats.crcerrs + adapter->stats.algnerrc + |
2216 | adapter->stats.rlec + adapter->stats.rnbc + | 2552 | adapter->stats.rlec + adapter->stats.mpc + |
2217 | adapter->stats.mpc + adapter->stats.cexterr; | 2553 | adapter->stats.cexterr; |
2218 | adapter->net_stats.rx_dropped = adapter->stats.rnbc; | 2554 | adapter->net_stats.rx_dropped = adapter->stats.mpc; |
2219 | adapter->net_stats.rx_length_errors = adapter->stats.rlec; | 2555 | adapter->net_stats.rx_length_errors = adapter->stats.rlec; |
2220 | adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs; | 2556 | adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs; |
2221 | adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc; | 2557 | adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc; |
@@ -2300,11 +2636,11 @@ e1000_intr(int irq, void *data, struct pt_regs *regs) | |||
2300 | */ | 2636 | */ |
2301 | if(hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2){ | 2637 | if(hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2){ |
2302 | atomic_inc(&adapter->irq_sem); | 2638 | atomic_inc(&adapter->irq_sem); |
2303 | E1000_WRITE_REG(&adapter->hw, IMC, ~0); | 2639 | E1000_WRITE_REG(hw, IMC, ~0); |
2304 | } | 2640 | } |
2305 | 2641 | ||
2306 | for(i = 0; i < E1000_MAX_INTR; i++) | 2642 | for(i = 0; i < E1000_MAX_INTR; i++) |
2307 | if(unlikely(!e1000_clean_rx_irq(adapter) & | 2643 | if(unlikely(!adapter->clean_rx(adapter) & |
2308 | !e1000_clean_tx_irq(adapter))) | 2644 | !e1000_clean_tx_irq(adapter))) |
2309 | break; | 2645 | break; |
2310 | 2646 | ||
@@ -2328,16 +2664,15 @@ e1000_clean(struct net_device *netdev, int *budget) | |||
2328 | int work_to_do = min(*budget, netdev->quota); | 2664 | int work_to_do = min(*budget, netdev->quota); |
2329 | int tx_cleaned; | 2665 | int tx_cleaned; |
2330 | int work_done = 0; | 2666 | int work_done = 0; |
2331 | 2667 | ||
2332 | tx_cleaned = e1000_clean_tx_irq(adapter); | 2668 | tx_cleaned = e1000_clean_tx_irq(adapter); |
2333 | e1000_clean_rx_irq(adapter, &work_done, work_to_do); | 2669 | adapter->clean_rx(adapter, &work_done, work_to_do); |
2334 | 2670 | ||
2335 | *budget -= work_done; | 2671 | *budget -= work_done; |
2336 | netdev->quota -= work_done; | 2672 | netdev->quota -= work_done; |
2337 | 2673 | ||
2338 | /* if no Tx and not enough Rx work done, exit the polling mode */ | 2674 | /* If no Tx and no Rx work done, exit the polling mode */ |
2339 | if((!tx_cleaned && (work_done < work_to_do)) || | 2675 | if ((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) { |
2340 | !netif_running(netdev)) { | ||
2341 | netif_rx_complete(netdev); | 2676 | netif_rx_complete(netdev); |
2342 | e1000_irq_enable(adapter); | 2677 | e1000_irq_enable(adapter); |
2343 | return 0; | 2678 | return 0; |
@@ -2367,11 +2702,10 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter) | |||
2367 | eop_desc = E1000_TX_DESC(*tx_ring, eop); | 2702 | eop_desc = E1000_TX_DESC(*tx_ring, eop); |
2368 | 2703 | ||
2369 | while(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) { | 2704 | while(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) { |
2370 | /* pre-mature writeback of Tx descriptors */ | 2705 | /* Premature writeback of Tx descriptors clear (free buffers |
2371 | /* clear (free buffers and unmap pci_mapping) */ | 2706 | * and unmap pci_mapping) previous_buffer_info */ |
2372 | /* previous_buffer_info */ | ||
2373 | if (likely(adapter->previous_buffer_info.skb != NULL)) { | 2707 | if (likely(adapter->previous_buffer_info.skb != NULL)) { |
2374 | e1000_unmap_and_free_tx_resource(adapter, | 2708 | e1000_unmap_and_free_tx_resource(adapter, |
2375 | &adapter->previous_buffer_info); | 2709 | &adapter->previous_buffer_info); |
2376 | } | 2710 | } |
2377 | 2711 | ||
@@ -2380,26 +2714,30 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter) | |||
2380 | buffer_info = &tx_ring->buffer_info[i]; | 2714 | buffer_info = &tx_ring->buffer_info[i]; |
2381 | cleaned = (i == eop); | 2715 | cleaned = (i == eop); |
2382 | 2716 | ||
2383 | /* pre-mature writeback of Tx descriptors */ | 2717 | #ifdef NETIF_F_TSO |
2384 | /* save the cleaning of the this for the */ | 2718 | if (!(netdev->features & NETIF_F_TSO)) { |
2385 | /* next iteration */ | 2719 | #endif |
2386 | if (cleaned) { | 2720 | e1000_unmap_and_free_tx_resource(adapter, |
2387 | memcpy(&adapter->previous_buffer_info, | 2721 | buffer_info); |
2388 | buffer_info, | 2722 | #ifdef NETIF_F_TSO |
2389 | sizeof(struct e1000_buffer)); | ||
2390 | memset(buffer_info, | ||
2391 | 0, | ||
2392 | sizeof(struct e1000_buffer)); | ||
2393 | } else { | 2723 | } else { |
2394 | e1000_unmap_and_free_tx_resource(adapter, | 2724 | if (cleaned) { |
2395 | buffer_info); | 2725 | memcpy(&adapter->previous_buffer_info, |
2726 | buffer_info, | ||
2727 | sizeof(struct e1000_buffer)); | ||
2728 | memset(buffer_info, 0, | ||
2729 | sizeof(struct e1000_buffer)); | ||
2730 | } else { | ||
2731 | e1000_unmap_and_free_tx_resource( | ||
2732 | adapter, buffer_info); | ||
2733 | } | ||
2396 | } | 2734 | } |
2735 | #endif | ||
2397 | 2736 | ||
2398 | tx_desc->buffer_addr = 0; | 2737 | tx_desc->buffer_addr = 0; |
2399 | tx_desc->lower.data = 0; | 2738 | tx_desc->lower.data = 0; |
2400 | tx_desc->upper.data = 0; | 2739 | tx_desc->upper.data = 0; |
2401 | 2740 | ||
2402 | cleaned = (i == eop); | ||
2403 | if(unlikely(++i == tx_ring->count)) i = 0; | 2741 | if(unlikely(++i == tx_ring->count)) i = 0; |
2404 | } | 2742 | } |
2405 | 2743 | ||
@@ -2416,57 +2754,107 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter) | |||
2416 | netif_wake_queue(netdev); | 2754 | netif_wake_queue(netdev); |
2417 | 2755 | ||
2418 | spin_unlock(&adapter->tx_lock); | 2756 | spin_unlock(&adapter->tx_lock); |
2419 | |||
2420 | if(adapter->detect_tx_hung) { | 2757 | if(adapter->detect_tx_hung) { |
2421 | /* detect a transmit hang in hardware, this serializes the | 2758 | |
2759 | /* Detect a transmit hang in hardware, this serializes the | ||
2422 | * check with the clearing of time_stamp and movement of i */ | 2760 | * check with the clearing of time_stamp and movement of i */ |
2423 | adapter->detect_tx_hung = FALSE; | 2761 | adapter->detect_tx_hung = FALSE; |
2424 | if(tx_ring->buffer_info[i].dma && | 2762 | if (tx_ring->buffer_info[i].dma && |
2425 | time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ) && | 2763 | time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ) |
2426 | !(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_TXOFF)) | 2764 | && !(E1000_READ_REG(&adapter->hw, STATUS) & |
2765 | E1000_STATUS_TXOFF)) { | ||
2766 | |||
2767 | /* detected Tx unit hang */ | ||
2768 | i = tx_ring->next_to_clean; | ||
2769 | eop = tx_ring->buffer_info[i].next_to_watch; | ||
2770 | eop_desc = E1000_TX_DESC(*tx_ring, eop); | ||
2771 | DPRINTK(TX_ERR, ERR, "Detected Tx Unit Hang\n" | ||
2772 | " TDH <%x>\n" | ||
2773 | " TDT <%x>\n" | ||
2774 | " next_to_use <%x>\n" | ||
2775 | " next_to_clean <%x>\n" | ||
2776 | "buffer_info[next_to_clean]\n" | ||
2777 | " dma <%llx>\n" | ||
2778 | " time_stamp <%lx>\n" | ||
2779 | " next_to_watch <%x>\n" | ||
2780 | " jiffies <%lx>\n" | ||
2781 | " next_to_watch.status <%x>\n", | ||
2782 | E1000_READ_REG(&adapter->hw, TDH), | ||
2783 | E1000_READ_REG(&adapter->hw, TDT), | ||
2784 | tx_ring->next_to_use, | ||
2785 | i, | ||
2786 | tx_ring->buffer_info[i].dma, | ||
2787 | tx_ring->buffer_info[i].time_stamp, | ||
2788 | eop, | ||
2789 | jiffies, | ||
2790 | eop_desc->upper.fields.status); | ||
2427 | netif_stop_queue(netdev); | 2791 | netif_stop_queue(netdev); |
2792 | } | ||
2428 | } | 2793 | } |
2794 | #ifdef NETIF_F_TSO | ||
2795 | |||
2796 | if( unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && | ||
2797 | time_after(jiffies, adapter->previous_buffer_info.time_stamp + HZ))) | ||
2798 | e1000_unmap_and_free_tx_resource( | ||
2799 | adapter, &adapter->previous_buffer_info); | ||
2429 | 2800 | ||
2801 | #endif | ||
2430 | return cleaned; | 2802 | return cleaned; |
2431 | } | 2803 | } |
2432 | 2804 | ||
2433 | /** | 2805 | /** |
2434 | * e1000_rx_checksum - Receive Checksum Offload for 82543 | 2806 | * e1000_rx_checksum - Receive Checksum Offload for 82543 |
2435 | * @adapter: board private structure | 2807 | * @adapter: board private structure |
2436 | * @rx_desc: receive descriptor | 2808 | * @status_err: receive descriptor status and error fields |
2437 | * @sk_buff: socket buffer with received data | 2809 | * @csum: receive descriptor csum field |
2810 | * @sk_buff: socket buffer with received data | ||
2438 | **/ | 2811 | **/ |
2439 | 2812 | ||
2440 | static inline void | 2813 | static inline void |
2441 | e1000_rx_checksum(struct e1000_adapter *adapter, | 2814 | e1000_rx_checksum(struct e1000_adapter *adapter, |
2442 | struct e1000_rx_desc *rx_desc, | 2815 | uint32_t status_err, uint32_t csum, |
2443 | struct sk_buff *skb) | 2816 | struct sk_buff *skb) |
2444 | { | 2817 | { |
2818 | uint16_t status = (uint16_t)status_err; | ||
2819 | uint8_t errors = (uint8_t)(status_err >> 24); | ||
2820 | skb->ip_summed = CHECKSUM_NONE; | ||
2821 | |||
2445 | /* 82543 or newer only */ | 2822 | /* 82543 or newer only */ |
2446 | if(unlikely((adapter->hw.mac_type < e1000_82543) || | 2823 | if(unlikely(adapter->hw.mac_type < e1000_82543)) return; |
2447 | /* Ignore Checksum bit is set */ | 2824 | /* Ignore Checksum bit is set */ |
2448 | (rx_desc->status & E1000_RXD_STAT_IXSM) || | 2825 | if(unlikely(status & E1000_RXD_STAT_IXSM)) return; |
2449 | /* TCP Checksum has not been calculated */ | 2826 | /* TCP/UDP checksum error bit is set */ |
2450 | (!(rx_desc->status & E1000_RXD_STAT_TCPCS)))) { | 2827 | if(unlikely(errors & E1000_RXD_ERR_TCPE)) { |
2451 | skb->ip_summed = CHECKSUM_NONE; | ||
2452 | return; | ||
2453 | } | ||
2454 | |||
2455 | /* At this point we know the hardware did the TCP checksum */ | ||
2456 | /* now look at the TCP checksum error bit */ | ||
2457 | if(rx_desc->errors & E1000_RXD_ERR_TCPE) { | ||
2458 | /* let the stack verify checksum errors */ | 2828 | /* let the stack verify checksum errors */ |
2459 | skb->ip_summed = CHECKSUM_NONE; | ||
2460 | adapter->hw_csum_err++; | 2829 | adapter->hw_csum_err++; |
2830 | return; | ||
2831 | } | ||
2832 | /* TCP/UDP Checksum has not been calculated */ | ||
2833 | if(adapter->hw.mac_type <= e1000_82547_rev_2) { | ||
2834 | if(!(status & E1000_RXD_STAT_TCPCS)) | ||
2835 | return; | ||
2461 | } else { | 2836 | } else { |
2837 | if(!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS))) | ||
2838 | return; | ||
2839 | } | ||
2840 | /* It must be a TCP or UDP packet with a valid checksum */ | ||
2841 | if (likely(status & E1000_RXD_STAT_TCPCS)) { | ||
2462 | /* TCP checksum is good */ | 2842 | /* TCP checksum is good */ |
2463 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 2843 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
2464 | adapter->hw_csum_good++; | 2844 | } else if (adapter->hw.mac_type > e1000_82547_rev_2) { |
2845 | /* IP fragment with UDP payload */ | ||
2846 | /* Hardware complements the payload checksum, so we undo it | ||
2847 | * and then put the value in host order for further stack use. | ||
2848 | */ | ||
2849 | csum = ntohl(csum ^ 0xFFFF); | ||
2850 | skb->csum = csum; | ||
2851 | skb->ip_summed = CHECKSUM_HW; | ||
2465 | } | 2852 | } |
2853 | adapter->hw_csum_good++; | ||
2466 | } | 2854 | } |
2467 | 2855 | ||
2468 | /** | 2856 | /** |
2469 | * e1000_clean_rx_irq - Send received data up the network stack | 2857 | * e1000_clean_rx_irq - Send received data up the network stack; legacy |
2470 | * @adapter: board private structure | 2858 | * @adapter: board private structure |
2471 | **/ | 2859 | **/ |
2472 | 2860 | ||
@@ -2513,7 +2901,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter) | |||
2513 | if(unlikely(!(rx_desc->status & E1000_RXD_STAT_EOP))) { | 2901 | if(unlikely(!(rx_desc->status & E1000_RXD_STAT_EOP))) { |
2514 | /* All receives must fit into a single buffer */ | 2902 | /* All receives must fit into a single buffer */ |
2515 | E1000_DBG("%s: Receive packet consumed multiple" | 2903 | E1000_DBG("%s: Receive packet consumed multiple" |
2516 | " buffers\n", netdev->name); | 2904 | " buffers\n", netdev->name); |
2517 | dev_kfree_skb_irq(skb); | 2905 | dev_kfree_skb_irq(skb); |
2518 | goto next_desc; | 2906 | goto next_desc; |
2519 | } | 2907 | } |
@@ -2539,15 +2927,17 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter) | |||
2539 | skb_put(skb, length - ETHERNET_FCS_SIZE); | 2927 | skb_put(skb, length - ETHERNET_FCS_SIZE); |
2540 | 2928 | ||
2541 | /* Receive Checksum Offload */ | 2929 | /* Receive Checksum Offload */ |
2542 | e1000_rx_checksum(adapter, rx_desc, skb); | 2930 | e1000_rx_checksum(adapter, |
2543 | 2931 | (uint32_t)(rx_desc->status) | | |
2932 | ((uint32_t)(rx_desc->errors) << 24), | ||
2933 | rx_desc->csum, skb); | ||
2544 | skb->protocol = eth_type_trans(skb, netdev); | 2934 | skb->protocol = eth_type_trans(skb, netdev); |
2545 | #ifdef CONFIG_E1000_NAPI | 2935 | #ifdef CONFIG_E1000_NAPI |
2546 | if(unlikely(adapter->vlgrp && | 2936 | if(unlikely(adapter->vlgrp && |
2547 | (rx_desc->status & E1000_RXD_STAT_VP))) { | 2937 | (rx_desc->status & E1000_RXD_STAT_VP))) { |
2548 | vlan_hwaccel_receive_skb(skb, adapter->vlgrp, | 2938 | vlan_hwaccel_receive_skb(skb, adapter->vlgrp, |
2549 | le16_to_cpu(rx_desc->special) & | 2939 | le16_to_cpu(rx_desc->special) & |
2550 | E1000_RXD_SPC_VLAN_MASK); | 2940 | E1000_RXD_SPC_VLAN_MASK); |
2551 | } else { | 2941 | } else { |
2552 | netif_receive_skb(skb); | 2942 | netif_receive_skb(skb); |
2553 | } | 2943 | } |
@@ -2570,16 +2960,142 @@ next_desc: | |||
2570 | 2960 | ||
2571 | rx_desc = E1000_RX_DESC(*rx_ring, i); | 2961 | rx_desc = E1000_RX_DESC(*rx_ring, i); |
2572 | } | 2962 | } |
2573 | |||
2574 | rx_ring->next_to_clean = i; | 2963 | rx_ring->next_to_clean = i; |
2964 | adapter->alloc_rx_buf(adapter); | ||
2965 | |||
2966 | return cleaned; | ||
2967 | } | ||
2968 | |||
2969 | /** | ||
2970 | * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split | ||
2971 | * @adapter: board private structure | ||
2972 | **/ | ||
2973 | |||
2974 | static boolean_t | ||
2975 | #ifdef CONFIG_E1000_NAPI | ||
2976 | e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, int *work_done, | ||
2977 | int work_to_do) | ||
2978 | #else | ||
2979 | e1000_clean_rx_irq_ps(struct e1000_adapter *adapter) | ||
2980 | #endif | ||
2981 | { | ||
2982 | struct e1000_desc_ring *rx_ring = &adapter->rx_ring; | ||
2983 | union e1000_rx_desc_packet_split *rx_desc; | ||
2984 | struct net_device *netdev = adapter->netdev; | ||
2985 | struct pci_dev *pdev = adapter->pdev; | ||
2986 | struct e1000_buffer *buffer_info; | ||
2987 | struct e1000_ps_page *ps_page; | ||
2988 | struct e1000_ps_page_dma *ps_page_dma; | ||
2989 | struct sk_buff *skb; | ||
2990 | unsigned int i, j; | ||
2991 | uint32_t length, staterr; | ||
2992 | boolean_t cleaned = FALSE; | ||
2993 | |||
2994 | i = rx_ring->next_to_clean; | ||
2995 | rx_desc = E1000_RX_DESC_PS(*rx_ring, i); | ||
2996 | staterr = rx_desc->wb.middle.status_error; | ||
2997 | |||
2998 | while(staterr & E1000_RXD_STAT_DD) { | ||
2999 | buffer_info = &rx_ring->buffer_info[i]; | ||
3000 | ps_page = &rx_ring->ps_page[i]; | ||
3001 | ps_page_dma = &rx_ring->ps_page_dma[i]; | ||
3002 | #ifdef CONFIG_E1000_NAPI | ||
3003 | if(unlikely(*work_done >= work_to_do)) | ||
3004 | break; | ||
3005 | (*work_done)++; | ||
3006 | #endif | ||
3007 | cleaned = TRUE; | ||
3008 | pci_unmap_single(pdev, buffer_info->dma, | ||
3009 | buffer_info->length, | ||
3010 | PCI_DMA_FROMDEVICE); | ||
3011 | |||
3012 | skb = buffer_info->skb; | ||
3013 | |||
3014 | if(unlikely(!(staterr & E1000_RXD_STAT_EOP))) { | ||
3015 | E1000_DBG("%s: Packet Split buffers didn't pick up" | ||
3016 | " the full packet\n", netdev->name); | ||
3017 | dev_kfree_skb_irq(skb); | ||
3018 | goto next_desc; | ||
3019 | } | ||
3020 | |||
3021 | if(unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) { | ||
3022 | dev_kfree_skb_irq(skb); | ||
3023 | goto next_desc; | ||
3024 | } | ||
3025 | |||
3026 | length = le16_to_cpu(rx_desc->wb.middle.length0); | ||
3027 | |||
3028 | if(unlikely(!length)) { | ||
3029 | E1000_DBG("%s: Last part of the packet spanning" | ||
3030 | " multiple descriptors\n", netdev->name); | ||
3031 | dev_kfree_skb_irq(skb); | ||
3032 | goto next_desc; | ||
3033 | } | ||
3034 | |||
3035 | /* Good Receive */ | ||
3036 | skb_put(skb, length); | ||
3037 | |||
3038 | for(j = 0; j < PS_PAGE_BUFFERS; j++) { | ||
3039 | if(!(length = le16_to_cpu(rx_desc->wb.upper.length[j]))) | ||
3040 | break; | ||
3041 | |||
3042 | pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j], | ||
3043 | PAGE_SIZE, PCI_DMA_FROMDEVICE); | ||
3044 | ps_page_dma->ps_page_dma[j] = 0; | ||
3045 | skb_shinfo(skb)->frags[j].page = | ||
3046 | ps_page->ps_page[j]; | ||
3047 | ps_page->ps_page[j] = NULL; | ||
3048 | skb_shinfo(skb)->frags[j].page_offset = 0; | ||
3049 | skb_shinfo(skb)->frags[j].size = length; | ||
3050 | skb_shinfo(skb)->nr_frags++; | ||
3051 | skb->len += length; | ||
3052 | skb->data_len += length; | ||
3053 | } | ||
2575 | 3054 | ||
2576 | e1000_alloc_rx_buffers(adapter); | 3055 | e1000_rx_checksum(adapter, staterr, |
3056 | rx_desc->wb.lower.hi_dword.csum_ip.csum, skb); | ||
3057 | skb->protocol = eth_type_trans(skb, netdev); | ||
3058 | |||
3059 | #ifdef HAVE_RX_ZERO_COPY | ||
3060 | if(likely(rx_desc->wb.upper.header_status & | ||
3061 | E1000_RXDPS_HDRSTAT_HDRSP)) | ||
3062 | skb_shinfo(skb)->zero_copy = TRUE; | ||
3063 | #endif | ||
3064 | #ifdef CONFIG_E1000_NAPI | ||
3065 | if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) { | ||
3066 | vlan_hwaccel_receive_skb(skb, adapter->vlgrp, | ||
3067 | le16_to_cpu(rx_desc->wb.middle.vlan & | ||
3068 | E1000_RXD_SPC_VLAN_MASK)); | ||
3069 | } else { | ||
3070 | netif_receive_skb(skb); | ||
3071 | } | ||
3072 | #else /* CONFIG_E1000_NAPI */ | ||
3073 | if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) { | ||
3074 | vlan_hwaccel_rx(skb, adapter->vlgrp, | ||
3075 | le16_to_cpu(rx_desc->wb.middle.vlan & | ||
3076 | E1000_RXD_SPC_VLAN_MASK)); | ||
3077 | } else { | ||
3078 | netif_rx(skb); | ||
3079 | } | ||
3080 | #endif /* CONFIG_E1000_NAPI */ | ||
3081 | netdev->last_rx = jiffies; | ||
3082 | |||
3083 | next_desc: | ||
3084 | rx_desc->wb.middle.status_error &= ~0xFF; | ||
3085 | buffer_info->skb = NULL; | ||
3086 | if(unlikely(++i == rx_ring->count)) i = 0; | ||
3087 | |||
3088 | rx_desc = E1000_RX_DESC_PS(*rx_ring, i); | ||
3089 | staterr = rx_desc->wb.middle.status_error; | ||
3090 | } | ||
3091 | rx_ring->next_to_clean = i; | ||
3092 | adapter->alloc_rx_buf(adapter); | ||
2577 | 3093 | ||
2578 | return cleaned; | 3094 | return cleaned; |
2579 | } | 3095 | } |
2580 | 3096 | ||
2581 | /** | 3097 | /** |
2582 | * e1000_alloc_rx_buffers - Replace used receive buffers | 3098 | * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended |
2583 | * @adapter: address of board private structure | 3099 | * @adapter: address of board private structure |
2584 | **/ | 3100 | **/ |
2585 | 3101 | ||
@@ -2592,43 +3108,43 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter) | |||
2592 | struct e1000_rx_desc *rx_desc; | 3108 | struct e1000_rx_desc *rx_desc; |
2593 | struct e1000_buffer *buffer_info; | 3109 | struct e1000_buffer *buffer_info; |
2594 | struct sk_buff *skb; | 3110 | struct sk_buff *skb; |
2595 | unsigned int i, bufsz; | 3111 | unsigned int i; |
3112 | unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN; | ||
2596 | 3113 | ||
2597 | i = rx_ring->next_to_use; | 3114 | i = rx_ring->next_to_use; |
2598 | buffer_info = &rx_ring->buffer_info[i]; | 3115 | buffer_info = &rx_ring->buffer_info[i]; |
2599 | 3116 | ||
2600 | while(!buffer_info->skb) { | 3117 | while(!buffer_info->skb) { |
2601 | bufsz = adapter->rx_buffer_len + NET_IP_ALIGN; | ||
2602 | |||
2603 | skb = dev_alloc_skb(bufsz); | 3118 | skb = dev_alloc_skb(bufsz); |
3119 | |||
2604 | if(unlikely(!skb)) { | 3120 | if(unlikely(!skb)) { |
2605 | /* Better luck next round */ | 3121 | /* Better luck next round */ |
2606 | break; | 3122 | break; |
2607 | } | 3123 | } |
2608 | 3124 | ||
2609 | /* fix for errata 23, cant cross 64kB boundary */ | 3125 | /* Fix for errata 23, can't cross 64kB boundary */ |
2610 | if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) { | 3126 | if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) { |
2611 | struct sk_buff *oldskb = skb; | 3127 | struct sk_buff *oldskb = skb; |
2612 | DPRINTK(RX_ERR,ERR, | 3128 | DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes " |
2613 | "skb align check failed: %u bytes at %p\n", | 3129 | "at %p\n", bufsz, skb->data); |
2614 | bufsz, skb->data); | 3130 | /* Try again, without freeing the previous */ |
2615 | /* try again, without freeing the previous */ | ||
2616 | skb = dev_alloc_skb(bufsz); | 3131 | skb = dev_alloc_skb(bufsz); |
3132 | /* Failed allocation, critical failure */ | ||
2617 | if (!skb) { | 3133 | if (!skb) { |
2618 | dev_kfree_skb(oldskb); | 3134 | dev_kfree_skb(oldskb); |
2619 | break; | 3135 | break; |
2620 | } | 3136 | } |
3137 | |||
2621 | if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) { | 3138 | if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) { |
2622 | /* give up */ | 3139 | /* give up */ |
2623 | dev_kfree_skb(skb); | 3140 | dev_kfree_skb(skb); |
2624 | dev_kfree_skb(oldskb); | 3141 | dev_kfree_skb(oldskb); |
2625 | break; /* while !buffer_info->skb */ | 3142 | break; /* while !buffer_info->skb */ |
2626 | } else { | 3143 | } else { |
2627 | /* move on with the new one */ | 3144 | /* Use new allocation */ |
2628 | dev_kfree_skb(oldskb); | 3145 | dev_kfree_skb(oldskb); |
2629 | } | 3146 | } |
2630 | } | 3147 | } |
2631 | |||
2632 | /* Make buffer alignment 2 beyond a 16 byte boundary | 3148 | /* Make buffer alignment 2 beyond a 16 byte boundary |
2633 | * this will result in a 16 byte aligned IP header after | 3149 | * this will result in a 16 byte aligned IP header after |
2634 | * the 14 byte MAC header is removed | 3150 | * the 14 byte MAC header is removed |
@@ -2644,25 +3160,23 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter) | |||
2644 | adapter->rx_buffer_len, | 3160 | adapter->rx_buffer_len, |
2645 | PCI_DMA_FROMDEVICE); | 3161 | PCI_DMA_FROMDEVICE); |
2646 | 3162 | ||
2647 | /* fix for errata 23, cant cross 64kB boundary */ | 3163 | /* Fix for errata 23, can't cross 64kB boundary */ |
2648 | if(!e1000_check_64k_bound(adapter, | 3164 | if (!e1000_check_64k_bound(adapter, |
2649 | (void *)(unsigned long)buffer_info->dma, | 3165 | (void *)(unsigned long)buffer_info->dma, |
2650 | adapter->rx_buffer_len)) { | 3166 | adapter->rx_buffer_len)) { |
2651 | DPRINTK(RX_ERR,ERR, | 3167 | DPRINTK(RX_ERR, ERR, |
2652 | "dma align check failed: %u bytes at %ld\n", | 3168 | "dma align check failed: %u bytes at %p\n", |
2653 | adapter->rx_buffer_len, (unsigned long)buffer_info->dma); | 3169 | adapter->rx_buffer_len, |
2654 | 3170 | (void *)(unsigned long)buffer_info->dma); | |
2655 | dev_kfree_skb(skb); | 3171 | dev_kfree_skb(skb); |
2656 | buffer_info->skb = NULL; | 3172 | buffer_info->skb = NULL; |
2657 | 3173 | ||
2658 | pci_unmap_single(pdev, | 3174 | pci_unmap_single(pdev, buffer_info->dma, |
2659 | buffer_info->dma, | ||
2660 | adapter->rx_buffer_len, | 3175 | adapter->rx_buffer_len, |
2661 | PCI_DMA_FROMDEVICE); | 3176 | PCI_DMA_FROMDEVICE); |
2662 | 3177 | ||
2663 | break; /* while !buffer_info->skb */ | 3178 | break; /* while !buffer_info->skb */ |
2664 | } | 3179 | } |
2665 | |||
2666 | rx_desc = E1000_RX_DESC(*rx_ring, i); | 3180 | rx_desc = E1000_RX_DESC(*rx_ring, i); |
2667 | rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); | 3181 | rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); |
2668 | 3182 | ||
@@ -2672,7 +3186,6 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter) | |||
2672 | * applicable for weak-ordered memory model archs, | 3186 | * applicable for weak-ordered memory model archs, |
2673 | * such as IA-64). */ | 3187 | * such as IA-64). */ |
2674 | wmb(); | 3188 | wmb(); |
2675 | |||
2676 | E1000_WRITE_REG(&adapter->hw, RDT, i); | 3189 | E1000_WRITE_REG(&adapter->hw, RDT, i); |
2677 | } | 3190 | } |
2678 | 3191 | ||
@@ -2684,6 +3197,95 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter) | |||
2684 | } | 3197 | } |
2685 | 3198 | ||
2686 | /** | 3199 | /** |
3200 | * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split | ||
3201 | * @adapter: address of board private structure | ||
3202 | **/ | ||
3203 | |||
3204 | static void | ||
3205 | e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter) | ||
3206 | { | ||
3207 | struct e1000_desc_ring *rx_ring = &adapter->rx_ring; | ||
3208 | struct net_device *netdev = adapter->netdev; | ||
3209 | struct pci_dev *pdev = adapter->pdev; | ||
3210 | union e1000_rx_desc_packet_split *rx_desc; | ||
3211 | struct e1000_buffer *buffer_info; | ||
3212 | struct e1000_ps_page *ps_page; | ||
3213 | struct e1000_ps_page_dma *ps_page_dma; | ||
3214 | struct sk_buff *skb; | ||
3215 | unsigned int i, j; | ||
3216 | |||
3217 | i = rx_ring->next_to_use; | ||
3218 | buffer_info = &rx_ring->buffer_info[i]; | ||
3219 | ps_page = &rx_ring->ps_page[i]; | ||
3220 | ps_page_dma = &rx_ring->ps_page_dma[i]; | ||
3221 | |||
3222 | while(!buffer_info->skb) { | ||
3223 | rx_desc = E1000_RX_DESC_PS(*rx_ring, i); | ||
3224 | |||
3225 | for(j = 0; j < PS_PAGE_BUFFERS; j++) { | ||
3226 | if(unlikely(!ps_page->ps_page[j])) { | ||
3227 | ps_page->ps_page[j] = | ||
3228 | alloc_page(GFP_ATOMIC); | ||
3229 | if(unlikely(!ps_page->ps_page[j])) | ||
3230 | goto no_buffers; | ||
3231 | ps_page_dma->ps_page_dma[j] = | ||
3232 | pci_map_page(pdev, | ||
3233 | ps_page->ps_page[j], | ||
3234 | 0, PAGE_SIZE, | ||
3235 | PCI_DMA_FROMDEVICE); | ||
3236 | } | ||
3237 | /* Refresh the desc even if buffer_addrs didn't | ||
3238 | * change because each write-back erases this info. | ||
3239 | */ | ||
3240 | rx_desc->read.buffer_addr[j+1] = | ||
3241 | cpu_to_le64(ps_page_dma->ps_page_dma[j]); | ||
3242 | } | ||
3243 | |||
3244 | skb = dev_alloc_skb(adapter->rx_ps_bsize0 + NET_IP_ALIGN); | ||
3245 | |||
3246 | if(unlikely(!skb)) | ||
3247 | break; | ||
3248 | |||
3249 | /* Make buffer alignment 2 beyond a 16 byte boundary | ||
3250 | * this will result in a 16 byte aligned IP header after | ||
3251 | * the 14 byte MAC header is removed | ||
3252 | */ | ||
3253 | skb_reserve(skb, NET_IP_ALIGN); | ||
3254 | |||
3255 | skb->dev = netdev; | ||
3256 | |||
3257 | buffer_info->skb = skb; | ||
3258 | buffer_info->length = adapter->rx_ps_bsize0; | ||
3259 | buffer_info->dma = pci_map_single(pdev, skb->data, | ||
3260 | adapter->rx_ps_bsize0, | ||
3261 | PCI_DMA_FROMDEVICE); | ||
3262 | |||
3263 | rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma); | ||
3264 | |||
3265 | if(unlikely((i & ~(E1000_RX_BUFFER_WRITE - 1)) == i)) { | ||
3266 | /* Force memory writes to complete before letting h/w | ||
3267 | * know there are new descriptors to fetch. (Only | ||
3268 | * applicable for weak-ordered memory model archs, | ||
3269 | * such as IA-64). */ | ||
3270 | wmb(); | ||
3271 | /* Hardware increments by 16 bytes, but packet split | ||
3272 | * descriptors are 32 bytes...so we increment tail | ||
3273 | * twice as much. | ||
3274 | */ | ||
3275 | E1000_WRITE_REG(&adapter->hw, RDT, i<<1); | ||
3276 | } | ||
3277 | |||
3278 | if(unlikely(++i == rx_ring->count)) i = 0; | ||
3279 | buffer_info = &rx_ring->buffer_info[i]; | ||
3280 | ps_page = &rx_ring->ps_page[i]; | ||
3281 | ps_page_dma = &rx_ring->ps_page_dma[i]; | ||
3282 | } | ||
3283 | |||
3284 | no_buffers: | ||
3285 | rx_ring->next_to_use = i; | ||
3286 | } | ||
3287 | |||
3288 | /** | ||
2687 | * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers. | 3289 | * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers. |
2688 | * @adapter: | 3290 | * @adapter: |
2689 | **/ | 3291 | **/ |
@@ -2856,9 +3458,10 @@ void | |||
2856 | e1000_pci_set_mwi(struct e1000_hw *hw) | 3458 | e1000_pci_set_mwi(struct e1000_hw *hw) |
2857 | { | 3459 | { |
2858 | struct e1000_adapter *adapter = hw->back; | 3460 | struct e1000_adapter *adapter = hw->back; |
3461 | int ret_val = pci_set_mwi(adapter->pdev); | ||
2859 | 3462 | ||
2860 | int ret; | 3463 | if(ret_val) |
2861 | ret = pci_set_mwi(adapter->pdev); | 3464 | DPRINTK(PROBE, ERR, "Error in setting MWI\n"); |
2862 | } | 3465 | } |
2863 | 3466 | ||
2864 | void | 3467 | void |
@@ -2917,6 +3520,7 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) | |||
2917 | rctl |= E1000_RCTL_VFE; | 3520 | rctl |= E1000_RCTL_VFE; |
2918 | rctl &= ~E1000_RCTL_CFIEN; | 3521 | rctl &= ~E1000_RCTL_CFIEN; |
2919 | E1000_WRITE_REG(&adapter->hw, RCTL, rctl); | 3522 | E1000_WRITE_REG(&adapter->hw, RCTL, rctl); |
3523 | e1000_update_mng_vlan(adapter); | ||
2920 | } else { | 3524 | } else { |
2921 | /* disable VLAN tag insert/strip */ | 3525 | /* disable VLAN tag insert/strip */ |
2922 | ctrl = E1000_READ_REG(&adapter->hw, CTRL); | 3526 | ctrl = E1000_READ_REG(&adapter->hw, CTRL); |
@@ -2927,6 +3531,10 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) | |||
2927 | rctl = E1000_READ_REG(&adapter->hw, RCTL); | 3531 | rctl = E1000_READ_REG(&adapter->hw, RCTL); |
2928 | rctl &= ~E1000_RCTL_VFE; | 3532 | rctl &= ~E1000_RCTL_VFE; |
2929 | E1000_WRITE_REG(&adapter->hw, RCTL, rctl); | 3533 | E1000_WRITE_REG(&adapter->hw, RCTL, rctl); |
3534 | if(adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) { | ||
3535 | e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); | ||
3536 | adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; | ||
3537 | } | ||
2930 | } | 3538 | } |
2931 | 3539 | ||
2932 | e1000_irq_enable(adapter); | 3540 | e1000_irq_enable(adapter); |
@@ -2937,7 +3545,10 @@ e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid) | |||
2937 | { | 3545 | { |
2938 | struct e1000_adapter *adapter = netdev->priv; | 3546 | struct e1000_adapter *adapter = netdev->priv; |
2939 | uint32_t vfta, index; | 3547 | uint32_t vfta, index; |
2940 | 3548 | if((adapter->hw.mng_cookie.status & | |
3549 | E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && | ||
3550 | (vid == adapter->mng_vlan_id)) | ||
3551 | return; | ||
2941 | /* add VID to filter table */ | 3552 | /* add VID to filter table */ |
2942 | index = (vid >> 5) & 0x7F; | 3553 | index = (vid >> 5) & 0x7F; |
2943 | vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index); | 3554 | vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index); |
@@ -2958,6 +3569,10 @@ e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid) | |||
2958 | 3569 | ||
2959 | e1000_irq_enable(adapter); | 3570 | e1000_irq_enable(adapter); |
2960 | 3571 | ||
3572 | if((adapter->hw.mng_cookie.status & | ||
3573 | E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && | ||
3574 | (vid == adapter->mng_vlan_id)) | ||
3575 | return; | ||
2961 | /* remove VID from filter table */ | 3576 | /* remove VID from filter table */ |
2962 | index = (vid >> 5) & 0x7F; | 3577 | index = (vid >> 5) & 0x7F; |
2963 | vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index); | 3578 | vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index); |
@@ -3004,8 +3619,7 @@ e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx) | |||
3004 | break; | 3619 | break; |
3005 | case SPEED_1000 + DUPLEX_HALF: /* not supported */ | 3620 | case SPEED_1000 + DUPLEX_HALF: /* not supported */ |
3006 | default: | 3621 | default: |
3007 | DPRINTK(PROBE, ERR, | 3622 | DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n"); |
3008 | "Unsupported Speed/Duplexity configuration\n"); | ||
3009 | return -EINVAL; | 3623 | return -EINVAL; |
3010 | } | 3624 | } |
3011 | return 0; | 3625 | return 0; |
@@ -3033,7 +3647,7 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state) | |||
3033 | { | 3647 | { |
3034 | struct net_device *netdev = pci_get_drvdata(pdev); | 3648 | struct net_device *netdev = pci_get_drvdata(pdev); |
3035 | struct e1000_adapter *adapter = netdev->priv; | 3649 | struct e1000_adapter *adapter = netdev->priv; |
3036 | uint32_t ctrl, ctrl_ext, rctl, manc, status; | 3650 | uint32_t ctrl, ctrl_ext, rctl, manc, status, swsm; |
3037 | uint32_t wufc = adapter->wol; | 3651 | uint32_t wufc = adapter->wol; |
3038 | 3652 | ||
3039 | netif_device_detach(netdev); | 3653 | netif_device_detach(netdev); |
@@ -3075,6 +3689,9 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state) | |||
3075 | E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext); | 3689 | E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext); |
3076 | } | 3690 | } |
3077 | 3691 | ||
3692 | /* Allow time for pending master requests to run */ | ||
3693 | e1000_disable_pciex_master(&adapter->hw); | ||
3694 | |||
3078 | E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN); | 3695 | E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN); |
3079 | E1000_WRITE_REG(&adapter->hw, WUFC, wufc); | 3696 | E1000_WRITE_REG(&adapter->hw, WUFC, wufc); |
3080 | pci_enable_wake(pdev, 3, 1); | 3697 | pci_enable_wake(pdev, 3, 1); |
@@ -3099,6 +3716,16 @@ e1000_suspend(struct pci_dev *pdev, uint32_t state) | |||
3099 | } | 3716 | } |
3100 | } | 3717 | } |
3101 | 3718 | ||
3719 | switch(adapter->hw.mac_type) { | ||
3720 | case e1000_82573: | ||
3721 | swsm = E1000_READ_REG(&adapter->hw, SWSM); | ||
3722 | E1000_WRITE_REG(&adapter->hw, SWSM, | ||
3723 | swsm & ~E1000_SWSM_DRV_LOAD); | ||
3724 | break; | ||
3725 | default: | ||
3726 | break; | ||
3727 | } | ||
3728 | |||
3102 | pci_disable_device(pdev); | 3729 | pci_disable_device(pdev); |
3103 | 3730 | ||
3104 | state = (state > 0) ? 3 : 0; | 3731 | state = (state > 0) ? 3 : 0; |
@@ -3113,13 +3740,12 @@ e1000_resume(struct pci_dev *pdev) | |||
3113 | { | 3740 | { |
3114 | struct net_device *netdev = pci_get_drvdata(pdev); | 3741 | struct net_device *netdev = pci_get_drvdata(pdev); |
3115 | struct e1000_adapter *adapter = netdev->priv; | 3742 | struct e1000_adapter *adapter = netdev->priv; |
3116 | uint32_t manc, ret; | 3743 | uint32_t manc, ret, swsm; |
3117 | 3744 | ||
3118 | pci_set_power_state(pdev, 0); | 3745 | pci_set_power_state(pdev, 0); |
3119 | pci_restore_state(pdev); | 3746 | pci_restore_state(pdev); |
3120 | ret = pci_enable_device(pdev); | 3747 | ret = pci_enable_device(pdev); |
3121 | if (pdev->is_busmaster) | 3748 | pci_set_master(pdev); |
3122 | pci_set_master(pdev); | ||
3123 | 3749 | ||
3124 | pci_enable_wake(pdev, 3, 0); | 3750 | pci_enable_wake(pdev, 3, 0); |
3125 | pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */ | 3751 | pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */ |
@@ -3139,10 +3765,19 @@ e1000_resume(struct pci_dev *pdev) | |||
3139 | E1000_WRITE_REG(&adapter->hw, MANC, manc); | 3765 | E1000_WRITE_REG(&adapter->hw, MANC, manc); |
3140 | } | 3766 | } |
3141 | 3767 | ||
3768 | switch(adapter->hw.mac_type) { | ||
3769 | case e1000_82573: | ||
3770 | swsm = E1000_READ_REG(&adapter->hw, SWSM); | ||
3771 | E1000_WRITE_REG(&adapter->hw, SWSM, | ||
3772 | swsm | E1000_SWSM_DRV_LOAD); | ||
3773 | break; | ||
3774 | default: | ||
3775 | break; | ||
3776 | } | ||
3777 | |||
3142 | return 0; | 3778 | return 0; |
3143 | } | 3779 | } |
3144 | #endif | 3780 | #endif |
3145 | |||
3146 | #ifdef CONFIG_NET_POLL_CONTROLLER | 3781 | #ifdef CONFIG_NET_POLL_CONTROLLER |
3147 | /* | 3782 | /* |
3148 | * Polling 'interrupt' - used by things like netconsole to send skbs | 3783 | * Polling 'interrupt' - used by things like netconsole to send skbs |
@@ -3150,7 +3785,7 @@ e1000_resume(struct pci_dev *pdev) | |||
3150 | * the interrupt routine is executing. | 3785 | * the interrupt routine is executing. |
3151 | */ | 3786 | */ |
3152 | static void | 3787 | static void |
3153 | e1000_netpoll (struct net_device *netdev) | 3788 | e1000_netpoll(struct net_device *netdev) |
3154 | { | 3789 | { |
3155 | struct e1000_adapter *adapter = netdev->priv; | 3790 | struct e1000_adapter *adapter = netdev->priv; |
3156 | disable_irq(adapter->pdev->irq); | 3791 | disable_irq(adapter->pdev->irq); |