| .. | .. |
|---|
| 24 | 24 | |
|---|
| 25 | 25 | #include "igbvf.h" |
|---|
| 26 | 26 | |
|---|
| 27 | | -#define DRV_VERSION "2.4.0-k" |
|---|
| 28 | 27 | char igbvf_driver_name[] = "igbvf"; |
|---|
| 29 | | -const char igbvf_driver_version[] = DRV_VERSION; |
|---|
| 30 | 28 | static const char igbvf_driver_string[] = |
|---|
| 31 | 29 | "Intel(R) Gigabit Virtual Function Network Driver"; |
|---|
| 32 | 30 | static const char igbvf_copyright[] = |
|---|
| .. | .. |
|---|
| 63 | 61 | |
|---|
| 64 | 62 | /** |
|---|
| 65 | 63 | * igbvf_desc_unused - calculate if we have unused descriptors |
|---|
| 66 | | - * @rx_ring: address of receive ring structure |
|---|
| 64 | + * @ring: address of receive ring structure |
|---|
| 67 | 65 | **/ |
|---|
| 68 | 66 | static int igbvf_desc_unused(struct igbvf_ring *ring) |
|---|
| 69 | 67 | { |
|---|
| .. | .. |
|---|
| 76 | 74 | /** |
|---|
| 77 | 75 | * igbvf_receive_skb - helper function to handle Rx indications |
|---|
| 78 | 76 | * @adapter: board private structure |
|---|
| 77 | + * @netdev: pointer to netdev struct |
|---|
| 78 | + * @skb: skb to indicate to stack |
|---|
| 79 | 79 | * @status: descriptor status field as written by hardware |
|---|
| 80 | 80 | * @vlan: descriptor vlan field as written by hardware (no le/be conversion) |
|---|
| 81 | 81 | * @skb: pointer to sk_buff to be indicated to stack |
|---|
| .. | .. |
|---|
| 83 | 83 | static void igbvf_receive_skb(struct igbvf_adapter *adapter, |
|---|
| 84 | 84 | struct net_device *netdev, |
|---|
| 85 | 85 | struct sk_buff *skb, |
|---|
| 86 | | - u32 status, u16 vlan) |
|---|
| 86 | + u32 status, __le16 vlan) |
|---|
| 87 | 87 | { |
|---|
| 88 | 88 | u16 vid; |
|---|
| 89 | 89 | |
|---|
| 90 | 90 | if (status & E1000_RXD_STAT_VP) { |
|---|
| 91 | 91 | if ((adapter->flags & IGBVF_FLAG_RX_LB_VLAN_BSWAP) && |
|---|
| 92 | 92 | (status & E1000_RXDEXT_STATERR_LB)) |
|---|
| 93 | | - vid = be16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK; |
|---|
| 93 | + vid = be16_to_cpu((__force __be16)vlan) & E1000_RXD_SPC_VLAN_MASK; |
|---|
| 94 | 94 | else |
|---|
| 95 | 95 | vid = le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK; |
|---|
| 96 | 96 | if (test_bit(vid, adapter->active_vlans)) |
|---|
| .. | .. |
|---|
| 235 | 235 | /** |
|---|
| 236 | 236 | * igbvf_clean_rx_irq - Send received data up the network stack; legacy |
|---|
| 237 | 237 | * @adapter: board private structure |
|---|
| 238 | + * @work_done: output parameter used to indicate completed work |
|---|
| 239 | + * @work_to_do: input parameter setting limit of work |
|---|
| 238 | 240 | * |
|---|
| 239 | 241 | * the return value indicates whether actual cleaning was done, there |
|---|
| 240 | 242 | * is no guarantee that everything was cleaned |
|---|
| .. | .. |
|---|
| 408 | 410 | /** |
|---|
| 409 | 411 | * igbvf_setup_tx_resources - allocate Tx resources (Descriptors) |
|---|
| 410 | 412 | * @adapter: board private structure |
|---|
| 413 | + * @tx_ring: ring being initialized |
|---|
| 411 | 414 | * |
|---|
| 412 | 415 | * Return 0 on success, negative on failure |
|---|
| 413 | 416 | **/ |
|---|
| .. | .. |
|---|
| 446 | 449 | /** |
|---|
| 447 | 450 | * igbvf_setup_rx_resources - allocate Rx resources (Descriptors) |
|---|
| 448 | 451 | * @adapter: board private structure |
|---|
| 452 | + * @rx_ring: ring being initialized |
|---|
| 449 | 453 | * |
|---|
| 450 | 454 | * Returns 0 on success, negative on failure |
|---|
| 451 | 455 | **/ |
|---|
| .. | .. |
|---|
| 542 | 546 | |
|---|
| 543 | 547 | /** |
|---|
| 544 | 548 | * igbvf_clean_rx_ring - Free Rx Buffers per Queue |
|---|
| 545 | | - * @adapter: board private structure |
|---|
| 549 | + * @rx_ring: ring structure pointer to free buffers from |
|---|
| 546 | 550 | **/ |
|---|
| 547 | 551 | static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring) |
|---|
| 548 | 552 | { |
|---|
| .. | .. |
|---|
| 762 | 766 | |
|---|
| 763 | 767 | /** |
|---|
| 764 | 768 | * igbvf_clean_tx_irq - Reclaim resources after transmit completes |
|---|
| 765 | | - * @adapter: board private structure |
|---|
| 769 | + * @tx_ring: ring structure to clean descriptors from |
|---|
| 766 | 770 | * |
|---|
| 767 | 771 | * returns true if ring is completely cleaned |
|---|
| 768 | 772 | **/ |
|---|
| .. | .. |
|---|
| 1070 | 1074 | igbvf_intr_msix_rx, 0, adapter->rx_ring->name, |
|---|
| 1071 | 1075 | netdev); |
|---|
| 1072 | 1076 | if (err) |
|---|
| 1073 | | - goto out; |
|---|
| 1077 | + goto free_irq_tx; |
|---|
| 1074 | 1078 | |
|---|
| 1075 | 1079 | adapter->rx_ring->itr_register = E1000_EITR(vector); |
|---|
| 1076 | 1080 | adapter->rx_ring->itr_val = adapter->current_itr; |
|---|
| .. | .. |
|---|
| 1079 | 1083 | err = request_irq(adapter->msix_entries[vector].vector, |
|---|
| 1080 | 1084 | igbvf_msix_other, 0, netdev->name, netdev); |
|---|
| 1081 | 1085 | if (err) |
|---|
| 1082 | | - goto out; |
|---|
| 1086 | + goto free_irq_rx; |
|---|
| 1083 | 1087 | |
|---|
| 1084 | 1088 | igbvf_configure_msix(adapter); |
|---|
| 1085 | 1089 | return 0; |
|---|
| 1090 | +free_irq_rx: |
|---|
| 1091 | + free_irq(adapter->msix_entries[--vector].vector, netdev); |
|---|
| 1092 | +free_irq_tx: |
|---|
| 1093 | + free_irq(adapter->msix_entries[--vector].vector, netdev); |
|---|
| 1086 | 1094 | out: |
|---|
| 1087 | 1095 | return err; |
|---|
| 1088 | 1096 | } |
|---|
| .. | .. |
|---|
| 1186 | 1194 | |
|---|
| 1187 | 1195 | igbvf_clean_rx_irq(adapter, &work_done, budget); |
|---|
| 1188 | 1196 | |
|---|
| 1189 | | - /* If not enough Rx work done, exit the polling mode */ |
|---|
| 1190 | | - if (work_done < budget) { |
|---|
| 1191 | | - napi_complete_done(napi, work_done); |
|---|
| 1197 | + if (work_done == budget) |
|---|
| 1198 | + return budget; |
|---|
| 1192 | 1199 | |
|---|
| 1200 | + /* Exit the polling mode, but don't re-enable interrupts if stack might |
|---|
| 1201 | + * poll us due to busy-polling |
|---|
| 1202 | + */ |
|---|
| 1203 | + if (likely(napi_complete_done(napi, work_done))) { |
|---|
| 1193 | 1204 | if (adapter->requested_itr & 3) |
|---|
| 1194 | 1205 | igbvf_set_itr(adapter); |
|---|
| 1195 | 1206 | |
|---|
| .. | .. |
|---|
| 1890 | 1901 | |
|---|
| 1891 | 1902 | /** |
|---|
| 1892 | 1903 | * igbvf_watchdog - Timer Call-back |
|---|
| 1893 | | - * @data: pointer to adapter cast into an unsigned long |
|---|
| 1904 | + * @t: timer list pointer containing private struct |
|---|
| 1894 | 1905 | **/ |
|---|
| 1895 | 1906 | static void igbvf_watchdog(struct timer_list *t) |
|---|
| 1896 | 1907 | { |
|---|
| .. | .. |
|---|
| 2090 | 2101 | switch (skb->csum_offset) { |
|---|
| 2091 | 2102 | case offsetof(struct tcphdr, check): |
|---|
| 2092 | 2103 | type_tucmd = E1000_ADVTXD_TUCMD_L4T_TCP; |
|---|
| 2093 | | - /* fall through */ |
|---|
| 2104 | + fallthrough; |
|---|
| 2094 | 2105 | case offsetof(struct udphdr, check): |
|---|
| 2095 | 2106 | break; |
|---|
| 2096 | 2107 | case offsetof(struct sctphdr, checksum): |
|---|
| .. | .. |
|---|
| 2102 | 2113 | type_tucmd = E1000_ADVTXD_TUCMD_L4T_SCTP; |
|---|
| 2103 | 2114 | break; |
|---|
| 2104 | 2115 | } |
|---|
| 2105 | | - /* fall through */ |
|---|
| 2116 | + fallthrough; |
|---|
| 2106 | 2117 | default: |
|---|
| 2107 | 2118 | skb_checksum_help(skb); |
|---|
| 2108 | 2119 | goto csum_failed; |
|---|
| .. | .. |
|---|
| 2171 | 2182 | goto dma_error; |
|---|
| 2172 | 2183 | |
|---|
| 2173 | 2184 | for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) { |
|---|
| 2174 | | - const struct skb_frag_struct *frag; |
|---|
| 2185 | + const skb_frag_t *frag; |
|---|
| 2175 | 2186 | |
|---|
| 2176 | 2187 | count++; |
|---|
| 2177 | 2188 | i++; |
|---|
| .. | .. |
|---|
| 2276 | 2287 | tx_ring->buffer_info[first].next_to_watch = tx_desc; |
|---|
| 2277 | 2288 | tx_ring->next_to_use = i; |
|---|
| 2278 | 2289 | writel(i, adapter->hw.hw_addr + tx_ring->tail); |
|---|
| 2279 | | - /* we need this if more than one processor can write to our tail |
|---|
| 2280 | | - * at a time, it synchronizes IO on IA64/Altix systems |
|---|
| 2281 | | - */ |
|---|
| 2282 | | - mmiowb(); |
|---|
| 2283 | 2290 | } |
|---|
| 2284 | 2291 | |
|---|
| 2285 | 2292 | static netdev_tx_t igbvf_xmit_frame_ring_adv(struct sk_buff *skb, |
|---|
| .. | .. |
|---|
| 2375 | 2382 | /** |
|---|
| 2376 | 2383 | * igbvf_tx_timeout - Respond to a Tx Hang |
|---|
| 2377 | 2384 | * @netdev: network interface device structure |
|---|
| 2385 | + * @txqueue: queue timing out (unused) |
|---|
| 2378 | 2386 | **/ |
|---|
| 2379 | | -static void igbvf_tx_timeout(struct net_device *netdev) |
|---|
| 2387 | +static void igbvf_tx_timeout(struct net_device *netdev, unsigned int __always_unused txqueue) |
|---|
| 2380 | 2388 | { |
|---|
| 2381 | 2389 | struct igbvf_adapter *adapter = netdev_priv(netdev); |
|---|
| 2382 | 2390 | |
|---|
| .. | .. |
|---|
| 2438 | 2446 | adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + |
|---|
| 2439 | 2447 | ETH_FCS_LEN; |
|---|
| 2440 | 2448 | |
|---|
| 2441 | | - dev_info(&adapter->pdev->dev, "changing MTU from %d to %d\n", |
|---|
| 2442 | | - netdev->mtu, new_mtu); |
|---|
| 2449 | + netdev_dbg(netdev, "changing MTU from %d to %d\n", |
|---|
| 2450 | + netdev->mtu, new_mtu); |
|---|
| 2443 | 2451 | netdev->mtu = new_mtu; |
|---|
| 2444 | 2452 | |
|---|
| 2445 | 2453 | if (netif_running(netdev)) |
|---|
| .. | .. |
|---|
| 2460 | 2468 | } |
|---|
| 2461 | 2469 | } |
|---|
| 2462 | 2470 | |
|---|
| 2463 | | -static int igbvf_suspend(struct pci_dev *pdev, pm_message_t state) |
|---|
| 2471 | +static int igbvf_suspend(struct device *dev_d) |
|---|
| 2464 | 2472 | { |
|---|
| 2465 | | - struct net_device *netdev = pci_get_drvdata(pdev); |
|---|
| 2473 | + struct net_device *netdev = dev_get_drvdata(dev_d); |
|---|
| 2466 | 2474 | struct igbvf_adapter *adapter = netdev_priv(netdev); |
|---|
| 2467 | | -#ifdef CONFIG_PM |
|---|
| 2468 | | - int retval = 0; |
|---|
| 2469 | | -#endif |
|---|
| 2470 | 2475 | |
|---|
| 2471 | 2476 | netif_device_detach(netdev); |
|---|
| 2472 | 2477 | |
|---|
| .. | .. |
|---|
| 2476 | 2481 | igbvf_free_irq(adapter); |
|---|
| 2477 | 2482 | } |
|---|
| 2478 | 2483 | |
|---|
| 2479 | | -#ifdef CONFIG_PM |
|---|
| 2480 | | - retval = pci_save_state(pdev); |
|---|
| 2481 | | - if (retval) |
|---|
| 2482 | | - return retval; |
|---|
| 2483 | | -#endif |
|---|
| 2484 | | - |
|---|
| 2485 | | - pci_disable_device(pdev); |
|---|
| 2486 | | - |
|---|
| 2487 | 2484 | return 0; |
|---|
| 2488 | 2485 | } |
|---|
| 2489 | 2486 | |
|---|
| 2490 | | -#ifdef CONFIG_PM |
|---|
| 2491 | | -static int igbvf_resume(struct pci_dev *pdev) |
|---|
| 2487 | +static int __maybe_unused igbvf_resume(struct device *dev_d) |
|---|
| 2492 | 2488 | { |
|---|
| 2489 | + struct pci_dev *pdev = to_pci_dev(dev_d); |
|---|
| 2493 | 2490 | struct net_device *netdev = pci_get_drvdata(pdev); |
|---|
| 2494 | 2491 | struct igbvf_adapter *adapter = netdev_priv(netdev); |
|---|
| 2495 | 2492 | u32 err; |
|---|
| 2496 | | - |
|---|
| 2497 | | - pci_restore_state(pdev); |
|---|
| 2498 | | - err = pci_enable_device_mem(pdev); |
|---|
| 2499 | | - if (err) { |
|---|
| 2500 | | - dev_err(&pdev->dev, "Cannot enable PCI device from suspend\n"); |
|---|
| 2501 | | - return err; |
|---|
| 2502 | | - } |
|---|
| 2503 | 2493 | |
|---|
| 2504 | 2494 | pci_set_master(pdev); |
|---|
| 2505 | 2495 | |
|---|
| .. | .. |
|---|
| 2518 | 2508 | |
|---|
| 2519 | 2509 | return 0; |
|---|
| 2520 | 2510 | } |
|---|
| 2521 | | -#endif |
|---|
| 2522 | 2511 | |
|---|
| 2523 | 2512 | static void igbvf_shutdown(struct pci_dev *pdev) |
|---|
| 2524 | 2513 | { |
|---|
| 2525 | | - igbvf_suspend(pdev, PMSG_SUSPEND); |
|---|
| 2514 | + igbvf_suspend(&pdev->dev); |
|---|
| 2526 | 2515 | } |
|---|
| 2527 | 2516 | |
|---|
| 2528 | 2517 | #ifdef CONFIG_NET_POLL_CONTROLLER |
|---|
| .. | .. |
|---|
| 2964 | 2953 | }; |
|---|
| 2965 | 2954 | MODULE_DEVICE_TABLE(pci, igbvf_pci_tbl); |
|---|
| 2966 | 2955 | |
|---|
| 2956 | +static SIMPLE_DEV_PM_OPS(igbvf_pm_ops, igbvf_suspend, igbvf_resume); |
|---|
| 2957 | + |
|---|
| 2967 | 2958 | /* PCI Device API Driver */ |
|---|
| 2968 | 2959 | static struct pci_driver igbvf_driver = { |
|---|
| 2969 | 2960 | .name = igbvf_driver_name, |
|---|
| 2970 | 2961 | .id_table = igbvf_pci_tbl, |
|---|
| 2971 | 2962 | .probe = igbvf_probe, |
|---|
| 2972 | 2963 | .remove = igbvf_remove, |
|---|
| 2973 | | -#ifdef CONFIG_PM |
|---|
| 2974 | | - /* Power Management Hooks */ |
|---|
| 2975 | | - .suspend = igbvf_suspend, |
|---|
| 2976 | | - .resume = igbvf_resume, |
|---|
| 2977 | | -#endif |
|---|
| 2964 | + .driver.pm = &igbvf_pm_ops, |
|---|
| 2978 | 2965 | .shutdown = igbvf_shutdown, |
|---|
| 2979 | 2966 | .err_handler = &igbvf_err_handler |
|---|
| 2980 | 2967 | }; |
|---|
| .. | .. |
|---|
| 2989 | 2976 | { |
|---|
| 2990 | 2977 | int ret; |
|---|
| 2991 | 2978 | |
|---|
| 2992 | | - pr_info("%s - version %s\n", igbvf_driver_string, igbvf_driver_version); |
|---|
| 2979 | + pr_info("%s\n", igbvf_driver_string); |
|---|
| 2993 | 2980 | pr_info("%s\n", igbvf_copyright); |
|---|
| 2994 | 2981 | |
|---|
| 2995 | 2982 | ret = pci_register_driver(&igbvf_driver); |
|---|
| .. | .. |
|---|
| 3012 | 2999 | |
|---|
| 3013 | 3000 | MODULE_AUTHOR("Intel Corporation, <e1000-devel@lists.sourceforge.net>"); |
|---|
| 3014 | 3001 | MODULE_DESCRIPTION("Intel(R) Gigabit Virtual Function Network Driver"); |
|---|
| 3015 | | -MODULE_LICENSE("GPL"); |
|---|
| 3016 | | -MODULE_VERSION(DRV_VERSION); |
|---|
| 3002 | +MODULE_LICENSE("GPL v2"); |
|---|
| 3017 | 3003 | |
|---|
| 3018 | 3004 | /* netdev.c */ |
|---|