diff options
Diffstat (limited to 'drivers/net/igbvf/netdev.c')
| -rw-r--r-- | drivers/net/igbvf/netdev.c | 118 |
1 files changed, 29 insertions, 89 deletions
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c index c539f7c9c3e0..1c77fb3bf4ae 100644 --- a/drivers/net/igbvf/netdev.c +++ b/drivers/net/igbvf/netdev.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /******************************************************************************* | 1 | /******************************************************************************* |
| 2 | 2 | ||
| 3 | Intel(R) 82576 Virtual Function Linux driver | 3 | Intel(R) 82576 Virtual Function Linux driver |
| 4 | Copyright(c) 2009 Intel Corporation. | 4 | Copyright(c) 2009 - 2010 Intel Corporation. |
| 5 | 5 | ||
| 6 | This program is free software; you can redistribute it and/or modify it | 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, | 7 | under the terms and conditions of the GNU General Public License, |
| @@ -41,17 +41,17 @@ | |||
| 41 | #include <linux/mii.h> | 41 | #include <linux/mii.h> |
| 42 | #include <linux/ethtool.h> | 42 | #include <linux/ethtool.h> |
| 43 | #include <linux/if_vlan.h> | 43 | #include <linux/if_vlan.h> |
| 44 | #include <linux/pm_qos_params.h> | 44 | #include <linux/prefetch.h> |
| 45 | 45 | ||
| 46 | #include "igbvf.h" | 46 | #include "igbvf.h" |
| 47 | 47 | ||
| 48 | #define DRV_VERSION "1.0.0-k0" | 48 | #define DRV_VERSION "1.0.8-k0" |
| 49 | char igbvf_driver_name[] = "igbvf"; | 49 | char igbvf_driver_name[] = "igbvf"; |
| 50 | const char igbvf_driver_version[] = DRV_VERSION; | 50 | const char igbvf_driver_version[] = DRV_VERSION; |
| 51 | static struct pm_qos_request_list igbvf_driver_pm_qos_req; | ||
| 52 | static const char igbvf_driver_string[] = | 51 | static const char igbvf_driver_string[] = |
| 53 | "Intel(R) Virtual Function Network Driver"; | 52 | "Intel(R) Virtual Function Network Driver"; |
| 54 | static const char igbvf_copyright[] = "Copyright (c) 2009 Intel Corporation."; | 53 | static const char igbvf_copyright[] = |
| 54 | "Copyright (c) 2009 - 2010 Intel Corporation."; | ||
| 55 | 55 | ||
| 56 | static int igbvf_poll(struct napi_struct *napi, int budget); | 56 | static int igbvf_poll(struct napi_struct *napi, int budget); |
| 57 | static void igbvf_reset(struct igbvf_adapter *); | 57 | static void igbvf_reset(struct igbvf_adapter *); |
| @@ -65,8 +65,16 @@ static struct igbvf_info igbvf_vf_info = { | |||
| 65 | .init_ops = e1000_init_function_pointers_vf, | 65 | .init_ops = e1000_init_function_pointers_vf, |
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | static struct igbvf_info igbvf_i350_vf_info = { | ||
| 69 | .mac = e1000_vfadapt_i350, | ||
| 70 | .flags = 0, | ||
| 71 | .pba = 10, | ||
| 72 | .init_ops = e1000_init_function_pointers_vf, | ||
| 73 | }; | ||
| 74 | |||
| 68 | static const struct igbvf_info *igbvf_info_tbl[] = { | 75 | static const struct igbvf_info *igbvf_info_tbl[] = { |
| 69 | [board_vf] = &igbvf_vf_info, | 76 | [board_vf] = &igbvf_vf_info, |
| 77 | [board_i350_vf] = &igbvf_i350_vf_info, | ||
| 70 | }; | 78 | }; |
| 71 | 79 | ||
| 72 | /** | 80 | /** |
| @@ -103,7 +111,7 @@ static void igbvf_receive_skb(struct igbvf_adapter *adapter, | |||
| 103 | static inline void igbvf_rx_checksum_adv(struct igbvf_adapter *adapter, | 111 | static inline void igbvf_rx_checksum_adv(struct igbvf_adapter *adapter, |
| 104 | u32 status_err, struct sk_buff *skb) | 112 | u32 status_err, struct sk_buff *skb) |
| 105 | { | 113 | { |
| 106 | skb->ip_summed = CHECKSUM_NONE; | 114 | skb_checksum_none_assert(skb); |
| 107 | 115 | ||
| 108 | /* Ignore Checksum bit is set or checksum is disabled through ethtool */ | 116 | /* Ignore Checksum bit is set or checksum is disabled through ethtool */ |
| 109 | if ((status_err & E1000_RXD_STAT_IXSM) || | 117 | if ((status_err & E1000_RXD_STAT_IXSM) || |
| @@ -389,35 +397,6 @@ static void igbvf_put_txbuf(struct igbvf_adapter *adapter, | |||
| 389 | buffer_info->time_stamp = 0; | 397 | buffer_info->time_stamp = 0; |
| 390 | } | 398 | } |
| 391 | 399 | ||
| 392 | static void igbvf_print_tx_hang(struct igbvf_adapter *adapter) | ||
| 393 | { | ||
| 394 | struct igbvf_ring *tx_ring = adapter->tx_ring; | ||
| 395 | unsigned int i = tx_ring->next_to_clean; | ||
| 396 | unsigned int eop = tx_ring->buffer_info[i].next_to_watch; | ||
| 397 | union e1000_adv_tx_desc *eop_desc = IGBVF_TX_DESC_ADV(*tx_ring, eop); | ||
| 398 | |||
| 399 | /* detected Tx unit hang */ | ||
| 400 | dev_err(&adapter->pdev->dev, | ||
| 401 | "Detected Tx Unit Hang:\n" | ||
| 402 | " TDH <%x>\n" | ||
| 403 | " TDT <%x>\n" | ||
| 404 | " next_to_use <%x>\n" | ||
| 405 | " next_to_clean <%x>\n" | ||
| 406 | "buffer_info[next_to_clean]:\n" | ||
| 407 | " time_stamp <%lx>\n" | ||
| 408 | " next_to_watch <%x>\n" | ||
| 409 | " jiffies <%lx>\n" | ||
| 410 | " next_to_watch.status <%x>\n", | ||
| 411 | readl(adapter->hw.hw_addr + tx_ring->head), | ||
| 412 | readl(adapter->hw.hw_addr + tx_ring->tail), | ||
| 413 | tx_ring->next_to_use, | ||
| 414 | tx_ring->next_to_clean, | ||
| 415 | tx_ring->buffer_info[eop].time_stamp, | ||
| 416 | eop, | ||
| 417 | jiffies, | ||
| 418 | eop_desc->wb.status); | ||
| 419 | } | ||
| 420 | |||
| 421 | /** | 400 | /** |
| 422 | * igbvf_setup_tx_resources - allocate Tx resources (Descriptors) | 401 | * igbvf_setup_tx_resources - allocate Tx resources (Descriptors) |
| 423 | * @adapter: board private structure | 402 | * @adapter: board private structure |
| @@ -431,10 +410,9 @@ int igbvf_setup_tx_resources(struct igbvf_adapter *adapter, | |||
| 431 | int size; | 410 | int size; |
| 432 | 411 | ||
| 433 | size = sizeof(struct igbvf_buffer) * tx_ring->count; | 412 | size = sizeof(struct igbvf_buffer) * tx_ring->count; |
| 434 | tx_ring->buffer_info = vmalloc(size); | 413 | tx_ring->buffer_info = vzalloc(size); |
| 435 | if (!tx_ring->buffer_info) | 414 | if (!tx_ring->buffer_info) |
| 436 | goto err; | 415 | goto err; |
| 437 | memset(tx_ring->buffer_info, 0, size); | ||
| 438 | 416 | ||
| 439 | /* round up to nearest 4K */ | 417 | /* round up to nearest 4K */ |
| 440 | tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc); | 418 | tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc); |
| @@ -471,10 +449,9 @@ int igbvf_setup_rx_resources(struct igbvf_adapter *adapter, | |||
| 471 | int size, desc_len; | 449 | int size, desc_len; |
| 472 | 450 | ||
| 473 | size = sizeof(struct igbvf_buffer) * rx_ring->count; | 451 | size = sizeof(struct igbvf_buffer) * rx_ring->count; |
| 474 | rx_ring->buffer_info = vmalloc(size); | 452 | rx_ring->buffer_info = vzalloc(size); |
| 475 | if (!rx_ring->buffer_info) | 453 | if (!rx_ring->buffer_info) |
| 476 | goto err; | 454 | goto err; |
| 477 | memset(rx_ring->buffer_info, 0, size); | ||
| 478 | 455 | ||
| 479 | desc_len = sizeof(union e1000_adv_rx_desc); | 456 | desc_len = sizeof(union e1000_adv_rx_desc); |
| 480 | 457 | ||
| @@ -766,7 +743,6 @@ static void igbvf_set_itr(struct igbvf_adapter *adapter) | |||
| 766 | static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring) | 743 | static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring) |
| 767 | { | 744 | { |
| 768 | struct igbvf_adapter *adapter = tx_ring->adapter; | 745 | struct igbvf_adapter *adapter = tx_ring->adapter; |
| 769 | struct e1000_hw *hw = &adapter->hw; | ||
| 770 | struct net_device *netdev = adapter->netdev; | 746 | struct net_device *netdev = adapter->netdev; |
| 771 | struct igbvf_buffer *buffer_info; | 747 | struct igbvf_buffer *buffer_info; |
| 772 | struct sk_buff *skb; | 748 | struct sk_buff *skb; |
| @@ -827,25 +803,9 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring) | |||
| 827 | } | 803 | } |
| 828 | } | 804 | } |
| 829 | 805 | ||
| 830 | if (adapter->detect_tx_hung) { | ||
| 831 | /* Detect a transmit hang in hardware, this serializes the | ||
| 832 | * check with the clearing of time_stamp and movement of i */ | ||
| 833 | adapter->detect_tx_hung = false; | ||
| 834 | if (tx_ring->buffer_info[i].time_stamp && | ||
| 835 | time_after(jiffies, tx_ring->buffer_info[i].time_stamp + | ||
| 836 | (adapter->tx_timeout_factor * HZ)) && | ||
| 837 | !(er32(STATUS) & E1000_STATUS_TXOFF)) { | ||
| 838 | |||
| 839 | tx_desc = IGBVF_TX_DESC_ADV(*tx_ring, i); | ||
| 840 | /* detected Tx unit hang */ | ||
| 841 | igbvf_print_tx_hang(adapter); | ||
| 842 | |||
| 843 | netif_stop_queue(netdev); | ||
| 844 | } | ||
| 845 | } | ||
| 846 | adapter->net_stats.tx_bytes += total_bytes; | 806 | adapter->net_stats.tx_bytes += total_bytes; |
| 847 | adapter->net_stats.tx_packets += total_packets; | 807 | adapter->net_stats.tx_packets += total_packets; |
| 848 | return (count < tx_ring->count); | 808 | return count < tx_ring->count; |
| 849 | } | 809 | } |
| 850 | 810 | ||
| 851 | static irqreturn_t igbvf_msix_other(int irq, void *data) | 811 | static irqreturn_t igbvf_msix_other(int irq, void *data) |
| @@ -1256,7 +1216,7 @@ static void igbvf_restore_vlan(struct igbvf_adapter *adapter) | |||
| 1256 | if (!adapter->vlgrp) | 1216 | if (!adapter->vlgrp) |
| 1257 | return; | 1217 | return; |
| 1258 | 1218 | ||
| 1259 | for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) { | 1219 | for (vid = 0; vid < VLAN_N_VID; vid++) { |
| 1260 | if (!vlan_group_get_device(adapter->vlgrp, vid)) | 1220 | if (!vlan_group_get_device(adapter->vlgrp, vid)) |
| 1261 | continue; | 1221 | continue; |
| 1262 | igbvf_vlan_rx_add_vid(adapter->netdev, vid); | 1222 | igbvf_vlan_rx_add_vid(adapter->netdev, vid); |
| @@ -1853,26 +1813,11 @@ static void igbvf_watchdog_task(struct work_struct *work) | |||
| 1853 | 1813 | ||
| 1854 | if (link) { | 1814 | if (link) { |
| 1855 | if (!netif_carrier_ok(netdev)) { | 1815 | if (!netif_carrier_ok(netdev)) { |
| 1856 | bool txb2b = 1; | ||
| 1857 | |||
| 1858 | mac->ops.get_link_up_info(&adapter->hw, | 1816 | mac->ops.get_link_up_info(&adapter->hw, |
| 1859 | &adapter->link_speed, | 1817 | &adapter->link_speed, |
| 1860 | &adapter->link_duplex); | 1818 | &adapter->link_duplex); |
| 1861 | igbvf_print_link_info(adapter); | 1819 | igbvf_print_link_info(adapter); |
| 1862 | 1820 | ||
| 1863 | /* adjust timeout factor according to speed/duplex */ | ||
| 1864 | adapter->tx_timeout_factor = 1; | ||
| 1865 | switch (adapter->link_speed) { | ||
| 1866 | case SPEED_10: | ||
| 1867 | txb2b = 0; | ||
| 1868 | adapter->tx_timeout_factor = 16; | ||
| 1869 | break; | ||
| 1870 | case SPEED_100: | ||
| 1871 | txb2b = 0; | ||
| 1872 | /* maybe add some timeout factor ? */ | ||
| 1873 | break; | ||
| 1874 | } | ||
| 1875 | |||
| 1876 | netif_carrier_on(netdev); | 1821 | netif_carrier_on(netdev); |
| 1877 | netif_wake_queue(netdev); | 1822 | netif_wake_queue(netdev); |
| 1878 | } | 1823 | } |
| @@ -1906,9 +1851,6 @@ static void igbvf_watchdog_task(struct work_struct *work) | |||
| 1906 | /* Cause software interrupt to ensure Rx ring is cleaned */ | 1851 | /* Cause software interrupt to ensure Rx ring is cleaned */ |
| 1907 | ew32(EICS, adapter->rx_ring->eims_value); | 1852 | ew32(EICS, adapter->rx_ring->eims_value); |
| 1908 | 1853 | ||
| 1909 | /* Force detection of hung controller every watchdog period */ | ||
| 1910 | adapter->detect_tx_hung = 1; | ||
| 1911 | |||
| 1912 | /* Reset the timer */ | 1854 | /* Reset the timer */ |
| 1913 | if (!test_bit(__IGBVF_DOWN, &adapter->state)) | 1855 | if (!test_bit(__IGBVF_DOWN, &adapter->state)) |
| 1914 | mod_timer(&adapter->watchdog_timer, | 1856 | mod_timer(&adapter->watchdog_timer, |
| @@ -2286,7 +2228,7 @@ static netdev_tx_t igbvf_xmit_frame_ring_adv(struct sk_buff *skb, | |||
| 2286 | 2228 | ||
| 2287 | /* | 2229 | /* |
| 2288 | * count reflects descriptors mapped, if 0 then mapping error | 2230 | * count reflects descriptors mapped, if 0 then mapping error |
| 2289 | * has occured and we need to rewind the descriptor queue | 2231 | * has occurred and we need to rewind the descriptor queue |
| 2290 | */ | 2232 | */ |
| 2291 | count = igbvf_tx_map_adv(adapter, tx_ring, skb, first); | 2233 | count = igbvf_tx_map_adv(adapter, tx_ring, skb, first); |
| 2292 | 2234 | ||
| @@ -2698,8 +2640,7 @@ static int __devinit igbvf_probe(struct pci_dev *pdev, | |||
| 2698 | hw->device_id = pdev->device; | 2640 | hw->device_id = pdev->device; |
| 2699 | hw->subsystem_vendor_id = pdev->subsystem_vendor; | 2641 | hw->subsystem_vendor_id = pdev->subsystem_vendor; |
| 2700 | hw->subsystem_device_id = pdev->subsystem_device; | 2642 | hw->subsystem_device_id = pdev->subsystem_device; |
| 2701 | 2643 | hw->revision_id = pdev->revision; | |
| 2702 | pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id); | ||
| 2703 | 2644 | ||
| 2704 | err = -EIO; | 2645 | err = -EIO; |
| 2705 | adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, 0), | 2646 | adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, 0), |
| @@ -2785,15 +2726,15 @@ static int __devinit igbvf_probe(struct pci_dev *pdev, | |||
| 2785 | /* reset the hardware with the new settings */ | 2726 | /* reset the hardware with the new settings */ |
| 2786 | igbvf_reset(adapter); | 2727 | igbvf_reset(adapter); |
| 2787 | 2728 | ||
| 2788 | /* tell the stack to leave us alone until igbvf_open() is called */ | ||
| 2789 | netif_carrier_off(netdev); | ||
| 2790 | netif_stop_queue(netdev); | ||
| 2791 | |||
| 2792 | strcpy(netdev->name, "eth%d"); | 2729 | strcpy(netdev->name, "eth%d"); |
| 2793 | err = register_netdev(netdev); | 2730 | err = register_netdev(netdev); |
| 2794 | if (err) | 2731 | if (err) |
| 2795 | goto err_hw_init; | 2732 | goto err_hw_init; |
| 2796 | 2733 | ||
| 2734 | /* tell the stack to leave us alone until igbvf_open() is called */ | ||
| 2735 | netif_carrier_off(netdev); | ||
| 2736 | netif_stop_queue(netdev); | ||
| 2737 | |||
| 2797 | igbvf_print_device_info(adapter); | 2738 | igbvf_print_device_info(adapter); |
| 2798 | 2739 | ||
| 2799 | igbvf_initialize_last_counter_stats(adapter); | 2740 | igbvf_initialize_last_counter_stats(adapter); |
| @@ -2832,13 +2773,14 @@ static void __devexit igbvf_remove(struct pci_dev *pdev) | |||
| 2832 | struct e1000_hw *hw = &adapter->hw; | 2773 | struct e1000_hw *hw = &adapter->hw; |
| 2833 | 2774 | ||
| 2834 | /* | 2775 | /* |
| 2835 | * flush_scheduled work may reschedule our watchdog task, so | 2776 | * The watchdog timer may be rescheduled, so explicitly |
| 2836 | * explicitly disable watchdog tasks from being rescheduled | 2777 | * disable it from being rescheduled. |
| 2837 | */ | 2778 | */ |
| 2838 | set_bit(__IGBVF_DOWN, &adapter->state); | 2779 | set_bit(__IGBVF_DOWN, &adapter->state); |
| 2839 | del_timer_sync(&adapter->watchdog_timer); | 2780 | del_timer_sync(&adapter->watchdog_timer); |
| 2840 | 2781 | ||
| 2841 | flush_scheduled_work(); | 2782 | cancel_work_sync(&adapter->reset_task); |
| 2783 | cancel_work_sync(&adapter->watchdog_task); | ||
| 2842 | 2784 | ||
| 2843 | unregister_netdev(netdev); | 2785 | unregister_netdev(netdev); |
| 2844 | 2786 | ||
| @@ -2871,6 +2813,7 @@ static struct pci_error_handlers igbvf_err_handler = { | |||
| 2871 | 2813 | ||
| 2872 | static DEFINE_PCI_DEVICE_TABLE(igbvf_pci_tbl) = { | 2814 | static DEFINE_PCI_DEVICE_TABLE(igbvf_pci_tbl) = { |
| 2873 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_VF), board_vf }, | 2815 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_VF), board_vf }, |
| 2816 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_VF), board_i350_vf }, | ||
| 2874 | { } /* terminate list */ | 2817 | { } /* terminate list */ |
| 2875 | }; | 2818 | }; |
| 2876 | MODULE_DEVICE_TABLE(pci, igbvf_pci_tbl); | 2819 | MODULE_DEVICE_TABLE(pci, igbvf_pci_tbl); |
| @@ -2904,8 +2847,6 @@ static int __init igbvf_init_module(void) | |||
| 2904 | printk(KERN_INFO "%s\n", igbvf_copyright); | 2847 | printk(KERN_INFO "%s\n", igbvf_copyright); |
| 2905 | 2848 | ||
| 2906 | ret = pci_register_driver(&igbvf_driver); | 2849 | ret = pci_register_driver(&igbvf_driver); |
| 2907 | pm_qos_add_request(&igbvf_driver_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, | ||
| 2908 | PM_QOS_DEFAULT_VALUE); | ||
| 2909 | 2850 | ||
| 2910 | return ret; | 2851 | return ret; |
| 2911 | } | 2852 | } |
| @@ -2920,7 +2861,6 @@ module_init(igbvf_init_module); | |||
| 2920 | static void __exit igbvf_exit_module(void) | 2861 | static void __exit igbvf_exit_module(void) |
| 2921 | { | 2862 | { |
| 2922 | pci_unregister_driver(&igbvf_driver); | 2863 | pci_unregister_driver(&igbvf_driver); |
| 2923 | pm_qos_remove_request(&igbvf_driver_pm_qos_req); | ||
| 2924 | } | 2864 | } |
| 2925 | module_exit(igbvf_exit_module); | 2865 | module_exit(igbvf_exit_module); |
| 2926 | 2866 | ||
