Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller:

1) Workaround hw bug when acquiring PCI bos ownership of iwlwifi
devices, from Emmanuel Grumbach.

2) Falling back to vmalloc in conntrack should not emit a warning, from
Pablo Neira Ayuso.

3) Fix NULL deref when rtlwifi driver is used as an AP, from Luis
Felipe Dominguez Vega.

4) Rocker doesn't free netdev on device removal, from Ido Schimmel.

5) UDP multicast early sock demux has route handling races, from Eric
Dumazet.

6) Fix L4 checksum handling in openvswitch, from Glenn Griffin.

7) Fix use-after-free in skb_set_peeked, from Herbert Xu.

8) Don't advertize NETIF_F_FRAGLIST in virtio_net driver, this can lead
to fraglists longer than the driver can support. From Jason Wang.

9) Fix mlx5 on non-4k-pagesize systems, from Carol L Soto.

10) Fix interrupt storm in bna driver, from Ivan Vecera.

11) Don't propagate -EBUSY from netlink_insert(), from Daniel Borkmann.

12) Fix inet request sock leak, from Eric Dumazet.

13) Fix TX interrupt masking and marking in TX descriptors of fs_enet
driver, from LEROY Christophe.

14) Get rid of rule optimizer in gianfar driver, it's buggy and unlikely
to get fixed any time soon. From Jakub Kicinski

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (61 commits)
cosa: missing error code on failure in probe()
gianfar: remove faulty filer optimizer
gianfar: correct list membership accounting
gianfar: correct filer table writing
bonding: Gratuitous ARP gets dropped when first slave added
net: dsa: Do not override PHY interface if already configured
net: fs_enet: mask interrupts for TX partial frames.
net: fs_enet: explicitly remove I flag on TX partial frames
inet: fix possible request socket leak
inet: fix races with reqsk timers
mkiss: Fix error handling in mkiss_open()
bnx2x: Free NVRAM lock at end of each page
bnx2x: Prevent null pointer dereference on SKB release
cxgb4: missing curly braces in t4_setup_debugfs()
net-timestamp: Update skb_complete_tx_timestamp comment
ipv6: don't reject link-local nexthop on other interface
netlink: make sure -EBUSY won't escape from netlink_insert
bna: fix interrupts storm caused by erroneous packets
net: mvpp2: replace TX coalescing interrupts with hrtimer
net: mvpp2: enable proper per-CPU TX buffers unmapping
...

+590 -633
+1
drivers/net/bonding/bond_main.c
··· 786 786 slave ? slave->dev->name : "NULL"); 787 787 788 788 if (!slave || !bond->send_peer_notif || 789 + !netif_carrier_ok(bond->dev) || 789 790 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) 790 791 return false; 791 792
+8 -9
drivers/net/ethernet/3com/3c59x.c
··· 1763 1763 vp->rx_ring[i].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE)); 1764 1764 } 1765 1765 if (i != RX_RING_SIZE) { 1766 - int j; 1767 1766 pr_emerg("%s: no memory for rx ring\n", dev->name); 1768 - for (j = 0; j < i; j++) { 1769 - if (vp->rx_skbuff[j]) { 1770 - dev_kfree_skb(vp->rx_skbuff[j]); 1771 - vp->rx_skbuff[j] = NULL; 1772 - } 1773 - } 1774 1767 retval = -ENOMEM; 1775 - goto err_free_irq; 1768 + goto err_free_skb; 1776 1769 } 1777 1770 /* Wrap the ring. */ 1778 1771 vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma); ··· 1775 1782 if (!retval) 1776 1783 goto out; 1777 1784 1778 - err_free_irq: 1785 + err_free_skb: 1786 + for (i = 0; i < RX_RING_SIZE; i++) { 1787 + if (vp->rx_skbuff[i]) { 1788 + dev_kfree_skb(vp->rx_skbuff[i]); 1789 + vp->rx_skbuff[i] = NULL; 1790 + } 1791 + } 1779 1792 free_irq(dev->irq, dev); 1780 1793 err: 1781 1794 if (vortex_debug > 1)
+1 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
··· 262 262 if (likely(skb)) { 263 263 (*pkts_compl)++; 264 264 (*bytes_compl) += skb->len; 265 + dev_kfree_skb_any(skb); 265 266 } 266 267 267 - dev_kfree_skb_any(skb); 268 268 tx_buf->first_bd = 0; 269 269 tx_buf->skb = NULL; 270 270
+16
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
··· 1718 1718 offset += sizeof(u32); 1719 1719 data_buf += sizeof(u32); 1720 1720 written_so_far += sizeof(u32); 1721 + 1722 + /* At end of each 4Kb page, release nvram lock to allow MFW 1723 + * chance to take it for its own use. 1724 + */ 1725 + if ((cmd_flags & MCPR_NVM_COMMAND_LAST) && 1726 + (written_so_far < buf_size)) { 1727 + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, 1728 + "Releasing NVM lock after offset 0x%x\n", 1729 + (u32)(offset - sizeof(u32))); 1730 + bnx2x_release_nvram_lock(bp); 1731 + usleep_range(1000, 2000); 1732 + rc = bnx2x_acquire_nvram_lock(bp); 1733 + if (rc) 1734 + return rc; 1735 + } 1736 + 1721 1737 cmd_flags = 0; 1722 1738 } 1723 1739
+1 -1
drivers/net/ethernet/brocade/bna/bnad.c
··· 676 676 if (!next_cmpl->valid) 677 677 break; 678 678 } 679 + packets++; 679 680 680 681 /* TODO: BNA_CQ_EF_LOCAL ? */ 681 682 if (unlikely(flags & (BNA_CQ_EF_MAC_ERROR | ··· 693 692 else 694 693 bnad_cq_setup_skb_frags(rcb, skb, sop_ci, nvecs, len); 695 694 696 - packets++; 697 695 rcb->rxq->rx_packets++; 698 696 rcb->rxq->rx_bytes += totlen; 699 697 ccb->bytes_per_intr += totlen;
-3
drivers/net/ethernet/cavium/Kconfig
··· 16 16 config THUNDER_NIC_PF 17 17 tristate "Thunder Physical function driver" 18 18 depends on 64BIT 19 - default ARCH_THUNDER 20 19 select THUNDER_NIC_BGX 21 20 ---help--- 22 21 This driver supports Thunder's NIC physical function. ··· 28 29 config THUNDER_NIC_VF 29 30 tristate "Thunder Virtual function driver" 30 31 depends on 64BIT 31 - default ARCH_THUNDER 32 32 ---help--- 33 33 This driver supports Thunder's NIC virtual function 34 34 35 35 config THUNDER_NIC_BGX 36 36 tristate "Thunder MAC interface driver (BGX)" 37 37 depends on 64BIT 38 - default ARCH_THUNDER 39 38 ---help--- 40 39 This driver supports programming and controlling of MAC 41 40 interface from NIC physical function driver.
+2 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
··· 2332 2332 EXT_MEM1_SIZE_G(size)); 2333 2333 } 2334 2334 } else { 2335 - if (i & EXT_MEM_ENABLE_F) 2335 + if (i & EXT_MEM_ENABLE_F) { 2336 2336 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A); 2337 2337 add_debugfs_mem(adap, "mc", MEM_MC, 2338 2338 EXT_MEM_SIZE_G(size)); 2339 + } 2339 2340 } 2340 2341 2341 2342 de = debugfs_create_file_size("flash", S_IRUSR, adap->debugfs_root, adap,
+5
drivers/net/ethernet/emulex/benet/be_cmds.h
··· 620 620 BE_IF_FLAGS_VLAN_PROMISCUOUS |\ 621 621 BE_IF_FLAGS_MCAST_PROMISCUOUS) 622 622 623 + #define BE_IF_EN_FLAGS (BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |\ 624 + BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_UNTAGGED) 625 + 626 + #define BE_IF_ALL_FILT_FLAGS (BE_IF_EN_FLAGS | BE_IF_FLAGS_ALL_PROMISCUOUS) 627 + 623 628 /* An RX interface is an object with one or more MAC addresses and 624 629 * filtering capabilities. */ 625 630 struct be_cmd_req_if_create {
+120 -67
drivers/net/ethernet/emulex/benet/be_main.c
··· 273 273 if (ether_addr_equal(addr->sa_data, netdev->dev_addr)) 274 274 return 0; 275 275 276 + /* if device is not running, copy MAC to netdev->dev_addr */ 277 + if (!netif_running(netdev)) 278 + goto done; 279 + 276 280 /* The PMAC_ADD cmd may fail if the VF doesn't have FILTMGMT 277 281 * privilege or if PF did not provision the new MAC address. 278 282 * On BE3, this cmd will always fail if the VF doesn't have the ··· 311 307 status = -EPERM; 312 308 goto err; 313 309 } 314 - 315 - memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 316 - dev_info(dev, "MAC address changed to %pM\n", mac); 310 + done: 311 + ether_addr_copy(netdev->dev_addr, addr->sa_data); 312 + dev_info(dev, "MAC address changed to %pM\n", addr->sa_data); 317 313 return 0; 318 314 err: 319 315 dev_warn(dev, "MAC address change to %pM failed\n", addr->sa_data); ··· 2451 2447 be_eq_notify(eqo->adapter, eqo->q.id, false, true, num, 0); 2452 2448 } 2453 2449 2450 + /* Free posted rx buffers that were not used */ 2451 + static void be_rxq_clean(struct be_rx_obj *rxo) 2452 + { 2453 + struct be_queue_info *rxq = &rxo->q; 2454 + struct be_rx_page_info *page_info; 2455 + 2456 + while (atomic_read(&rxq->used) > 0) { 2457 + page_info = get_rx_page_info(rxo); 2458 + put_page(page_info->page); 2459 + memset(page_info, 0, sizeof(*page_info)); 2460 + } 2461 + BUG_ON(atomic_read(&rxq->used)); 2462 + rxq->tail = 0; 2463 + rxq->head = 0; 2464 + } 2465 + 2454 2466 static void be_rx_cq_clean(struct be_rx_obj *rxo) 2455 2467 { 2456 - struct be_rx_page_info *page_info; 2457 - struct be_queue_info *rxq = &rxo->q; 2458 2468 struct be_queue_info *rx_cq = &rxo->cq; 2459 2469 struct be_rx_compl_info *rxcp; 2460 2470 struct be_adapter *adapter = rxo->adapter; ··· 2505 2487 2506 2488 /* After cleanup, leave the CQ in unarmed state */ 2507 2489 be_cq_notify(adapter, rx_cq->id, false, 0); 2508 - 2509 - /* Then free posted rx buffers that were not used */ 2510 - while (atomic_read(&rxq->used) > 0) { 2511 - page_info = get_rx_page_info(rxo); 2512 - put_page(page_info->page); 2513 - memset(page_info, 0, sizeof(*page_info)); 2514 - } 2515 - BUG_ON(atomic_read(&rxq->used)); 2516 - rxq->tail = 0; 2517 - rxq->head = 0; 2518 2490 } 2519 2491 2520 2492 static void be_tx_compl_clean(struct be_adapter *adapter) ··· 2584 2576 be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); 2585 2577 napi_hash_del(&eqo->napi); 2586 2578 netif_napi_del(&eqo->napi); 2579 + free_cpumask_var(eqo->affinity_mask); 2587 2580 } 2588 - free_cpumask_var(eqo->affinity_mask); 2589 2581 be_queue_free(adapter, &eqo->q); 2590 2582 } 2591 2583 } ··· 2602 2594 2603 2595 for_all_evt_queues(adapter, eqo, i) { 2604 2596 int numa_node = dev_to_node(&adapter->pdev->dev); 2605 - if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL)) 2606 - return -ENOMEM; 2607 - cpumask_set_cpu(cpumask_local_spread(i, numa_node), 2608 - eqo->affinity_mask); 2609 - netif_napi_add(adapter->netdev, &eqo->napi, be_poll, 2610 - BE_NAPI_WEIGHT); 2611 - napi_hash_add(&eqo->napi); 2597 + 2612 2598 aic = &adapter->aic_obj[i]; 2613 2599 eqo->adapter = adapter; 2614 2600 eqo->idx = i; ··· 2618 2616 rc = be_cmd_eq_create(adapter, eqo); 2619 2617 if (rc) 2620 2618 return rc; 2619 + 2620 + if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL)) 2621 + return -ENOMEM; 2622 + cpumask_set_cpu(cpumask_local_spread(i, numa_node), 2623 + eqo->affinity_mask); 2624 + netif_napi_add(adapter->netdev, &eqo->napi, be_poll, 2625 + BE_NAPI_WEIGHT); 2626 + napi_hash_add(&eqo->napi); 2621 2627 } 2622 2628 return 0; 2623 2629 } ··· 3364 3354 for_all_rx_queues(adapter, rxo, i) { 3365 3355 q = &rxo->q; 3366 3356 if (q->created) { 3357 + /* If RXQs are destroyed while in an "out of buffer" 3358 + * state, there is a possibility of an HW stall on 3359 + * Lancer. So, post 64 buffers to each queue to relieve 3360 + * the "out of buffer" condition. 3361 + * Make sure there's space in the RXQ before posting. 3362 + */ 3363 + if (lancer_chip(adapter)) { 3364 + be_rx_cq_clean(rxo); 3365 + if (atomic_read(&q->used) == 0) 3366 + be_post_rx_frags(rxo, GFP_KERNEL, 3367 + MAX_RX_POST); 3368 + } 3369 + 3367 3370 be_cmd_rxq_destroy(adapter, q); 3368 3371 be_rx_cq_clean(rxo); 3372 + be_rxq_clean(rxo); 3369 3373 } 3370 3374 be_queue_free(adapter, q); 3375 + } 3376 + } 3377 + 3378 + static void be_disable_if_filters(struct be_adapter *adapter) 3379 + { 3380 + be_cmd_pmac_del(adapter, adapter->if_handle, 3381 + adapter->pmac_id[0], 0); 3382 + 3383 + be_clear_uc_list(adapter); 3384 + 3385 + /* The IFACE flags are enabled in the open path and cleared 3386 + * in the close path. When a VF gets detached from the host and 3387 + * assigned to a VM the following happens: 3388 + * - VF's IFACE flags get cleared in the detach path 3389 + * - IFACE create is issued by the VF in the attach path 3390 + * Due to a bug in the BE3/Skyhawk-R FW 3391 + * (Lancer FW doesn't have the bug), the IFACE capability flags 3392 + * specified along with the IFACE create cmd issued by a VF are not 3393 + * honoured by FW. As a consequence, if a *new* driver 3394 + * (that enables/disables IFACE flags in open/close) 3395 + * is loaded in the host and an *old* driver is * used by a VM/VF, 3396 + * the IFACE gets created *without* the needed flags. 3397 + * To avoid this, disable RX-filter flags only for Lancer. 3398 + */ 3399 + if (lancer_chip(adapter)) { 3400 + be_cmd_rx_filter(adapter, BE_IF_ALL_FILT_FLAGS, OFF); 3401 + adapter->if_flags &= ~BE_IF_ALL_FILT_FLAGS; 3371 3402 } 3372 3403 } 3373 3404 ··· 3423 3372 */ 3424 3373 if (!(adapter->flags & BE_FLAGS_SETUP_DONE)) 3425 3374 return 0; 3375 + 3376 + be_disable_if_filters(adapter); 3426 3377 3427 3378 be_roce_dev_close(adapter); 3428 3379 ··· 3445 3392 be_tx_compl_clean(adapter); 3446 3393 3447 3394 be_rx_qs_destroy(adapter); 3448 - be_clear_uc_list(adapter); 3449 3395 3450 3396 for_all_evt_queues(adapter, eqo, i) { 3451 3397 if (msix_enabled(adapter)) ··· 3529 3477 return 0; 3530 3478 } 3531 3479 3480 + static int be_enable_if_filters(struct be_adapter *adapter) 3481 + { 3482 + int status; 3483 + 3484 + status = be_cmd_rx_filter(adapter, BE_IF_EN_FLAGS, ON); 3485 + if (status) 3486 + return status; 3487 + 3488 + /* For BE3 VFs, the PF programs the initial MAC address */ 3489 + if (!(BEx_chip(adapter) && be_virtfn(adapter))) { 3490 + status = be_cmd_pmac_add(adapter, adapter->netdev->dev_addr, 3491 + adapter->if_handle, 3492 + &adapter->pmac_id[0], 0); 3493 + if (status) 3494 + return status; 3495 + } 3496 + 3497 + if (adapter->vlans_added) 3498 + be_vid_config(adapter); 3499 + 3500 + be_set_rx_mode(adapter->netdev); 3501 + 3502 + return 0; 3503 + } 3504 + 3532 3505 static int be_open(struct net_device *netdev) 3533 3506 { 3534 3507 struct be_adapter *adapter = netdev_priv(netdev); ··· 3564 3487 int status, i; 3565 3488 3566 3489 status = be_rx_qs_create(adapter); 3490 + if (status) 3491 + goto err; 3492 + 3493 + status = be_enable_if_filters(adapter); 3567 3494 if (status) 3568 3495 goto err; 3569 3496 ··· 3767 3686 } 3768 3687 } 3769 3688 3770 - static void be_mac_clear(struct be_adapter *adapter) 3771 - { 3772 - if (adapter->pmac_id) { 3773 - be_cmd_pmac_del(adapter, adapter->if_handle, 3774 - adapter->pmac_id[0], 0); 3775 - kfree(adapter->pmac_id); 3776 - adapter->pmac_id = NULL; 3777 - } 3778 - } 3779 - 3780 3689 #ifdef CONFIG_BE2NET_VXLAN 3781 3690 static void be_disable_vxlan_offloads(struct be_adapter *adapter) 3782 3691 { ··· 3841 3770 #ifdef CONFIG_BE2NET_VXLAN 3842 3771 be_disable_vxlan_offloads(adapter); 3843 3772 #endif 3844 - /* delete the primary mac along with the uc-mac list */ 3845 - be_mac_clear(adapter); 3773 + kfree(adapter->pmac_id); 3774 + adapter->pmac_id = NULL; 3846 3775 3847 3776 be_cmd_if_destroy(adapter, adapter->if_handle, 0); 3848 3777 ··· 3853 3782 return 0; 3854 3783 } 3855 3784 3856 - static int be_if_create(struct be_adapter *adapter, u32 *if_handle, 3857 - u32 cap_flags, u32 vf) 3858 - { 3859 - u32 en_flags; 3860 - 3861 - en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 3862 - BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS | 3863 - BE_IF_FLAGS_RSS | BE_IF_FLAGS_DEFQ_RSS; 3864 - 3865 - en_flags &= cap_flags; 3866 - 3867 - return be_cmd_if_create(adapter, cap_flags, en_flags, if_handle, vf); 3868 - } 3869 - 3870 3785 static int be_vfs_if_create(struct be_adapter *adapter) 3871 3786 { 3872 3787 struct be_resources res = {0}; 3788 + u32 cap_flags, en_flags, vf; 3873 3789 struct be_vf_cfg *vf_cfg; 3874 - u32 cap_flags, vf; 3875 3790 int status; 3876 3791 3877 3792 /* If a FW profile exists, then cap_flags are updated */ ··· 3878 3821 } 3879 3822 } 3880 3823 3881 - status = be_if_create(adapter, &vf_cfg->if_handle, 3882 - cap_flags, vf + 1); 3824 + en_flags = cap_flags & (BE_IF_FLAGS_UNTAGGED | 3825 + BE_IF_FLAGS_BROADCAST | 3826 + BE_IF_FLAGS_MULTICAST | 3827 + BE_IF_FLAGS_PASS_L3L4_ERRORS); 3828 + status = be_cmd_if_create(adapter, cap_flags, en_flags, 3829 + &vf_cfg->if_handle, vf + 1); 3883 3830 if (status) 3884 3831 return status; 3885 3832 } ··· 4255 4194 4256 4195 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); 4257 4196 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); 4258 - } else { 4259 - /* Maybe the HW was reset; dev_addr must be re-programmed */ 4260 - memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN); 4261 4197 } 4262 4198 4263 - /* For BE3-R VFs, the PF programs the initial MAC address */ 4264 - if (!(BEx_chip(adapter) && be_virtfn(adapter))) 4265 - be_cmd_pmac_add(adapter, mac, adapter->if_handle, 4266 - &adapter->pmac_id[0], 0); 4267 4199 return 0; 4268 4200 } 4269 4201 ··· 4396 4342 static int be_setup(struct be_adapter *adapter) 4397 4343 { 4398 4344 struct device *dev = &adapter->pdev->dev; 4345 + u32 en_flags; 4399 4346 int status; 4400 4347 4401 4348 status = be_func_init(adapter); ··· 4419 4364 if (status) 4420 4365 goto err; 4421 4366 4422 - status = be_if_create(adapter, &adapter->if_handle, 4423 - be_if_cap_flags(adapter), 0); 4367 + /* will enable all the needed filter flags in be_open() */ 4368 + en_flags = BE_IF_FLAGS_RSS | BE_IF_FLAGS_DEFQ_RSS; 4369 + en_flags = en_flags & be_if_cap_flags(adapter); 4370 + status = be_cmd_if_create(adapter, be_if_cap_flags(adapter), en_flags, 4371 + &adapter->if_handle, 0); 4424 4372 if (status) 4425 4373 goto err; 4426 4374 ··· 4448 4390 adapter->fw_ver); 4449 4391 dev_err(dev, "Please upgrade firmware to version >= 4.0\n"); 4450 4392 } 4451 - 4452 - if (adapter->vlans_added) 4453 - be_vid_config(adapter); 4454 - 4455 - be_set_rx_mode(adapter->netdev); 4456 4393 4457 4394 status = be_cmd_set_flow_control(adapter, adapter->tx_fc, 4458 4395 adapter->rx_fc);
+1
drivers/net/ethernet/freescale/fec_main.c
··· 3433 3433 3434 3434 pm_runtime_set_autosuspend_delay(&pdev->dev, FEC_MDIO_PM_TIMEOUT); 3435 3435 pm_runtime_use_autosuspend(&pdev->dev); 3436 + pm_runtime_get_noresume(&pdev->dev); 3436 3437 pm_runtime_set_active(&pdev->dev); 3437 3438 pm_runtime_enable(&pdev->dev); 3438 3439
+2 -1
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
··· 586 586 frag = skb_shinfo(skb)->frags; 587 587 while (nr_frags) { 588 588 CBDC_SC(bdp, 589 - BD_ENET_TX_STATS | BD_ENET_TX_LAST | BD_ENET_TX_TC); 589 + BD_ENET_TX_STATS | BD_ENET_TX_INTR | BD_ENET_TX_LAST | 590 + BD_ENET_TX_TC); 590 591 CBDS_SC(bdp, BD_ENET_TX_READY); 591 592 592 593 if ((CBDR_SC(bdp) & BD_ENET_TX_WRAP) == 0)
+1 -1
drivers/net/ethernet/freescale/fs_enet/mac-fec.c
··· 110 110 } 111 111 112 112 #define FEC_NAPI_RX_EVENT_MSK (FEC_ENET_RXF | FEC_ENET_RXB) 113 - #define FEC_NAPI_TX_EVENT_MSK (FEC_ENET_TXF | FEC_ENET_TXB) 113 + #define FEC_NAPI_TX_EVENT_MSK (FEC_ENET_TXF) 114 114 #define FEC_RX_EVENT (FEC_ENET_RXF) 115 115 #define FEC_TX_EVENT (FEC_ENET_TXF) 116 116 #define FEC_ERR_EVENT_MSK (FEC_ENET_HBERR | FEC_ENET_BABR | \
+4 -341
drivers/net/ethernet/freescale/gianfar_ethtool.c
··· 900 900 return 0; 901 901 } 902 902 903 - static int gfar_comp_asc(const void *a, const void *b) 904 - { 905 - return memcmp(a, b, 4); 906 - } 907 - 908 - static int gfar_comp_desc(const void *a, const void *b) 909 - { 910 - return -memcmp(a, b, 4); 911 - } 912 - 913 - static void gfar_swap(void *a, void *b, int size) 914 - { 915 - u32 *_a = a; 916 - u32 *_b = b; 917 - 918 - swap(_a[0], _b[0]); 919 - swap(_a[1], _b[1]); 920 - swap(_a[2], _b[2]); 921 - swap(_a[3], _b[3]); 922 - } 923 - 924 903 /* Write a mask to filer cache */ 925 904 static void gfar_set_mask(u32 mask, struct filer_table *tab) 926 905 { ··· 1249 1270 return 0; 1250 1271 } 1251 1272 1252 - /* Copy size filer entries */ 1253 - static void gfar_copy_filer_entries(struct gfar_filer_entry dst[0], 1254 - struct gfar_filer_entry src[0], s32 size) 1255 - { 1256 - while (size > 0) { 1257 - size--; 1258 - dst[size].ctrl = src[size].ctrl; 1259 - dst[size].prop = src[size].prop; 1260 - } 1261 - } 1262 - 1263 - /* Delete the contents of the filer-table between start and end 1264 - * and collapse them 1265 - */ 1266 - static int gfar_trim_filer_entries(u32 begin, u32 end, struct filer_table *tab) 1267 - { 1268 - int length; 1269 - 1270 - if (end > MAX_FILER_CACHE_IDX || end < begin) 1271 - return -EINVAL; 1272 - 1273 - end++; 1274 - length = end - begin; 1275 - 1276 - /* Copy */ 1277 - while (end < tab->index) { 1278 - tab->fe[begin].ctrl = tab->fe[end].ctrl; 1279 - tab->fe[begin++].prop = tab->fe[end++].prop; 1280 - 1281 - } 1282 - /* Fill up with don't cares */ 1283 - while (begin < tab->index) { 1284 - tab->fe[begin].ctrl = 0x60; 1285 - tab->fe[begin].prop = 0xFFFFFFFF; 1286 - begin++; 1287 - } 1288 - 1289 - tab->index -= length; 1290 - return 0; 1291 - } 1292 - 1293 - /* Make space on the wanted location */ 1294 - static int gfar_expand_filer_entries(u32 begin, u32 length, 1295 - struct filer_table *tab) 1296 - { 1297 - if (length == 0 || length + tab->index > MAX_FILER_CACHE_IDX || 1298 - begin > MAX_FILER_CACHE_IDX) 1299 - return -EINVAL; 1300 - 1301 - gfar_copy_filer_entries(&(tab->fe[begin + length]), &(tab->fe[begin]), 1302 - tab->index - length + 1); 1303 - 1304 - tab->index += length; 1305 - return 0; 1306 - } 1307 - 1308 - static int gfar_get_next_cluster_start(int start, struct filer_table *tab) 1309 - { 1310 - for (; (start < tab->index) && (start < MAX_FILER_CACHE_IDX - 1); 1311 - start++) { 1312 - if ((tab->fe[start].ctrl & (RQFCR_AND | RQFCR_CLE)) == 1313 - (RQFCR_AND | RQFCR_CLE)) 1314 - return start; 1315 - } 1316 - return -1; 1317 - } 1318 - 1319 - static int gfar_get_next_cluster_end(int start, struct filer_table *tab) 1320 - { 1321 - for (; (start < tab->index) && (start < MAX_FILER_CACHE_IDX - 1); 1322 - start++) { 1323 - if ((tab->fe[start].ctrl & (RQFCR_AND | RQFCR_CLE)) == 1324 - (RQFCR_CLE)) 1325 - return start; 1326 - } 1327 - return -1; 1328 - } 1329 - 1330 - /* Uses hardwares clustering option to reduce 1331 - * the number of filer table entries 1332 - */ 1333 - static void gfar_cluster_filer(struct filer_table *tab) 1334 - { 1335 - s32 i = -1, j, iend, jend; 1336 - 1337 - while ((i = gfar_get_next_cluster_start(++i, tab)) != -1) { 1338 - j = i; 1339 - while ((j = gfar_get_next_cluster_start(++j, tab)) != -1) { 1340 - /* The cluster entries self and the previous one 1341 - * (a mask) must be identical! 1342 - */ 1343 - if (tab->fe[i].ctrl != tab->fe[j].ctrl) 1344 - break; 1345 - if (tab->fe[i].prop != tab->fe[j].prop) 1346 - break; 1347 - if (tab->fe[i - 1].ctrl != tab->fe[j - 1].ctrl) 1348 - break; 1349 - if (tab->fe[i - 1].prop != tab->fe[j - 1].prop) 1350 - break; 1351 - iend = gfar_get_next_cluster_end(i, tab); 1352 - jend = gfar_get_next_cluster_end(j, tab); 1353 - if (jend == -1 || iend == -1) 1354 - break; 1355 - 1356 - /* First we make some free space, where our cluster 1357 - * element should be. Then we copy it there and finally 1358 - * delete in from its old location. 1359 - */ 1360 - if (gfar_expand_filer_entries(iend, (jend - j), tab) == 1361 - -EINVAL) 1362 - break; 1363 - 1364 - gfar_copy_filer_entries(&(tab->fe[iend + 1]), 1365 - &(tab->fe[jend + 1]), jend - j); 1366 - 1367 - if (gfar_trim_filer_entries(jend - 1, 1368 - jend + (jend - j), 1369 - tab) == -EINVAL) 1370 - return; 1371 - 1372 - /* Mask out cluster bit */ 1373 - tab->fe[iend].ctrl &= ~(RQFCR_CLE); 1374 - } 1375 - } 1376 - } 1377 - 1378 - /* Swaps the masked bits of a1<>a2 and b1<>b2 */ 1379 - static void gfar_swap_bits(struct gfar_filer_entry *a1, 1380 - struct gfar_filer_entry *a2, 1381 - struct gfar_filer_entry *b1, 1382 - struct gfar_filer_entry *b2, u32 mask) 1383 - { 1384 - u32 temp[4]; 1385 - temp[0] = a1->ctrl & mask; 1386 - temp[1] = a2->ctrl & mask; 1387 - temp[2] = b1->ctrl & mask; 1388 - temp[3] = b2->ctrl & mask; 1389 - 1390 - a1->ctrl &= ~mask; 1391 - a2->ctrl &= ~mask; 1392 - b1->ctrl &= ~mask; 1393 - b2->ctrl &= ~mask; 1394 - 1395 - a1->ctrl |= temp[1]; 1396 - a2->ctrl |= temp[0]; 1397 - b1->ctrl |= temp[3]; 1398 - b2->ctrl |= temp[2]; 1399 - } 1400 - 1401 - /* Generate a list consisting of masks values with their start and 1402 - * end of validity and block as indicator for parts belonging 1403 - * together (glued by ANDs) in mask_table 1404 - */ 1405 - static u32 gfar_generate_mask_table(struct gfar_mask_entry *mask_table, 1406 - struct filer_table *tab) 1407 - { 1408 - u32 i, and_index = 0, block_index = 1; 1409 - 1410 - for (i = 0; i < tab->index; i++) { 1411 - 1412 - /* LSByte of control = 0 sets a mask */ 1413 - if (!(tab->fe[i].ctrl & 0xF)) { 1414 - mask_table[and_index].mask = tab->fe[i].prop; 1415 - mask_table[and_index].start = i; 1416 - mask_table[and_index].block = block_index; 1417 - if (and_index >= 1) 1418 - mask_table[and_index - 1].end = i - 1; 1419 - and_index++; 1420 - } 1421 - /* cluster starts and ends will be separated because they should 1422 - * hold their position 1423 - */ 1424 - if (tab->fe[i].ctrl & RQFCR_CLE) 1425 - block_index++; 1426 - /* A not set AND indicates the end of a depended block */ 1427 - if (!(tab->fe[i].ctrl & RQFCR_AND)) 1428 - block_index++; 1429 - } 1430 - 1431 - mask_table[and_index - 1].end = i - 1; 1432 - 1433 - return and_index; 1434 - } 1435 - 1436 - /* Sorts the entries of mask_table by the values of the masks. 1437 - * Important: The 0xFF80 flags of the first and last entry of a 1438 - * block must hold their position (which queue, CLusterEnable, ReJEct, 1439 - * AND) 1440 - */ 1441 - static void gfar_sort_mask_table(struct gfar_mask_entry *mask_table, 1442 - struct filer_table *temp_table, u32 and_index) 1443 - { 1444 - /* Pointer to compare function (_asc or _desc) */ 1445 - int (*gfar_comp)(const void *, const void *); 1446 - 1447 - u32 i, size = 0, start = 0, prev = 1; 1448 - u32 old_first, old_last, new_first, new_last; 1449 - 1450 - gfar_comp = &gfar_comp_desc; 1451 - 1452 - for (i = 0; i < and_index; i++) { 1453 - if (prev != mask_table[i].block) { 1454 - old_first = mask_table[start].start + 1; 1455 - old_last = mask_table[i - 1].end; 1456 - sort(mask_table + start, size, 1457 - sizeof(struct gfar_mask_entry), 1458 - gfar_comp, &gfar_swap); 1459 - 1460 - /* Toggle order for every block. This makes the 1461 - * thing more efficient! 1462 - */ 1463 - if (gfar_comp == gfar_comp_desc) 1464 - gfar_comp = &gfar_comp_asc; 1465 - else 1466 - gfar_comp = &gfar_comp_desc; 1467 - 1468 - new_first = mask_table[start].start + 1; 1469 - new_last = mask_table[i - 1].end; 1470 - 1471 - gfar_swap_bits(&temp_table->fe[new_first], 1472 - &temp_table->fe[old_first], 1473 - &temp_table->fe[new_last], 1474 - &temp_table->fe[old_last], 1475 - RQFCR_QUEUE | RQFCR_CLE | 1476 - RQFCR_RJE | RQFCR_AND); 1477 - 1478 - start = i; 1479 - size = 0; 1480 - } 1481 - size++; 1482 - prev = mask_table[i].block; 1483 - } 1484 - } 1485 - 1486 - /* Reduces the number of masks needed in the filer table to save entries 1487 - * This is done by sorting the masks of a depended block. A depended block is 1488 - * identified by gluing ANDs or CLE. The sorting order toggles after every 1489 - * block. Of course entries in scope of a mask must change their location with 1490 - * it. 1491 - */ 1492 - static int gfar_optimize_filer_masks(struct filer_table *tab) 1493 - { 1494 - struct filer_table *temp_table; 1495 - struct gfar_mask_entry *mask_table; 1496 - 1497 - u32 and_index = 0, previous_mask = 0, i = 0, j = 0, size = 0; 1498 - s32 ret = 0; 1499 - 1500 - /* We need a copy of the filer table because 1501 - * we want to change its order 1502 - */ 1503 - temp_table = kmemdup(tab, sizeof(*temp_table), GFP_KERNEL); 1504 - if (temp_table == NULL) 1505 - return -ENOMEM; 1506 - 1507 - mask_table = kcalloc(MAX_FILER_CACHE_IDX / 2 + 1, 1508 - sizeof(struct gfar_mask_entry), GFP_KERNEL); 1509 - 1510 - if (mask_table == NULL) { 1511 - ret = -ENOMEM; 1512 - goto end; 1513 - } 1514 - 1515 - and_index = gfar_generate_mask_table(mask_table, tab); 1516 - 1517 - gfar_sort_mask_table(mask_table, temp_table, and_index); 1518 - 1519 - /* Now we can copy the data from our duplicated filer table to 1520 - * the real one in the order the mask table says 1521 - */ 1522 - for (i = 0; i < and_index; i++) { 1523 - size = mask_table[i].end - mask_table[i].start + 1; 1524 - gfar_copy_filer_entries(&(tab->fe[j]), 1525 - &(temp_table->fe[mask_table[i].start]), size); 1526 - j += size; 1527 - } 1528 - 1529 - /* And finally we just have to check for duplicated masks and drop the 1530 - * second ones 1531 - */ 1532 - for (i = 0; i < tab->index && i < MAX_FILER_CACHE_IDX; i++) { 1533 - if (tab->fe[i].ctrl == 0x80) { 1534 - previous_mask = i++; 1535 - break; 1536 - } 1537 - } 1538 - for (; i < tab->index && i < MAX_FILER_CACHE_IDX; i++) { 1539 - if (tab->fe[i].ctrl == 0x80) { 1540 - if (tab->fe[i].prop == tab->fe[previous_mask].prop) { 1541 - /* Two identical ones found! 1542 - * So drop the second one! 1543 - */ 1544 - gfar_trim_filer_entries(i, i, tab); 1545 - } else 1546 - /* Not identical! */ 1547 - previous_mask = i; 1548 - } 1549 - } 1550 - 1551 - kfree(mask_table); 1552 - end: kfree(temp_table); 1553 - return ret; 1554 - } 1555 - 1556 1273 /* Write the bit-pattern from software's buffer to hardware registers */ 1557 1274 static int gfar_write_filer_table(struct gfar_private *priv, 1558 1275 struct filer_table *tab) ··· 1258 1583 return -EBUSY; 1259 1584 1260 1585 /* Fill regular entries */ 1261 - for (; i < MAX_FILER_IDX - 1 && (tab->fe[i].ctrl | tab->fe[i].prop); 1262 - i++) 1586 + for (; i < MAX_FILER_IDX && (tab->fe[i].ctrl | tab->fe[i].prop); i++) 1263 1587 gfar_write_filer(priv, i, tab->fe[i].ctrl, tab->fe[i].prop); 1264 1588 /* Fill the rest with fall-troughs */ 1265 - for (; i < MAX_FILER_IDX - 1; i++) 1589 + for (; i < MAX_FILER_IDX; i++) 1266 1590 gfar_write_filer(priv, i, 0x60, 0xFFFFFFFF); 1267 1591 /* Last entry must be default accept 1268 1592 * because that's what people expect ··· 1295 1621 { 1296 1622 struct ethtool_flow_spec_container *j; 1297 1623 struct filer_table *tab; 1298 - s32 i = 0; 1299 1624 s32 ret = 0; 1300 1625 1301 1626 /* So index is set to zero, too! */ ··· 1318 1645 goto end; 1319 1646 } 1320 1647 } 1321 - 1322 - i = tab->index; 1323 - 1324 - /* Optimizations to save entries */ 1325 - gfar_cluster_filer(tab); 1326 - gfar_optimize_filer_masks(tab); 1327 - 1328 - pr_debug("\tSummary:\n" 1329 - "\tData on hardware: %d\n" 1330 - "\tCompression rate: %d%%\n", 1331 - tab->index, 100 - (100 * tab->index) / i); 1332 1648 1333 1649 /* Write everything to hardware */ 1334 1650 ret = gfar_write_filer_table(priv, tab); ··· 1384 1722 } 1385 1723 1386 1724 process: 1725 + priv->rx_list.count++; 1387 1726 ret = gfar_process_filer_changes(priv); 1388 1727 if (ret) 1389 1728 goto clean_list; 1390 - priv->rx_list.count++; 1391 1729 return ret; 1392 1730 1393 1731 clean_list: 1732 + priv->rx_list.count--; 1394 1733 list_del(&temp->list); 1395 1734 clean_mem: 1396 1735 kfree(temp);
+167 -77
drivers/net/ethernet/marvell/mvpp2.c
··· 27 27 #include <linux/of_address.h> 28 28 #include <linux/phy.h> 29 29 #include <linux/clk.h> 30 + #include <linux/hrtimer.h> 31 + #include <linux/ktime.h> 30 32 #include <uapi/linux/ppp_defs.h> 31 33 #include <net/ip.h> 32 34 #include <net/ipv6.h> ··· 301 299 302 300 /* Coalescing */ 303 301 #define MVPP2_TXDONE_COAL_PKTS_THRESH 15 302 + #define MVPP2_TXDONE_HRTIMER_PERIOD_NS 1000000UL 304 303 #define MVPP2_RX_COAL_PKTS 32 305 304 #define MVPP2_RX_COAL_USEC 100 306 305 ··· 663 660 u64 tx_bytes; 664 661 }; 665 662 663 + /* Per-CPU port control */ 664 + struct mvpp2_port_pcpu { 665 + struct hrtimer tx_done_timer; 666 + bool timer_scheduled; 667 + /* Tasklet for egress finalization */ 668 + struct tasklet_struct tx_done_tasklet; 669 + }; 670 + 666 671 struct mvpp2_port { 667 672 u8 id; 668 673 ··· 689 678 690 679 u32 pending_cause_rx; 691 680 struct napi_struct napi; 681 + 682 + /* Per-CPU port control */ 683 + struct mvpp2_port_pcpu __percpu *pcpu; 692 684 693 685 /* Flags */ 694 686 unsigned long flags; ··· 789 775 790 776 /* Array of transmitted skb */ 791 777 struct sk_buff **tx_skb; 778 + 779 + /* Array of transmitted buffers' physical addresses */ 780 + dma_addr_t *tx_buffs; 792 781 793 782 /* Index of last TX DMA descriptor that was inserted */ 794 783 int txq_put_index; ··· 930 913 /* Occupied buffers indicator */ 931 914 atomic_t in_use; 932 915 int in_use_thresh; 933 - 934 - spinlock_t lock; 935 916 }; 936 917 937 918 struct mvpp2_buff_hdr { ··· 978 963 } 979 964 980 965 static void mvpp2_txq_inc_put(struct mvpp2_txq_pcpu *txq_pcpu, 981 - struct sk_buff *skb) 966 + struct sk_buff *skb, 967 + struct mvpp2_tx_desc *tx_desc) 982 968 { 983 969 txq_pcpu->tx_skb[txq_pcpu->txq_put_index] = skb; 970 + if (skb) 971 + txq_pcpu->tx_buffs[txq_pcpu->txq_put_index] = 972 + tx_desc->buf_phys_addr; 984 973 txq_pcpu->txq_put_index++; 985 974 if (txq_pcpu->txq_put_index == txq_pcpu->size) 986 975 txq_pcpu->txq_put_index = 0; ··· 3395 3376 bm_pool->pkt_size = 0; 3396 3377 bm_pool->buf_num = 0; 3397 3378 atomic_set(&bm_pool->in_use, 0); 3398 - spin_lock_init(&bm_pool->lock); 3399 3379 3400 3380 return 0; 3401 3381 } ··· 3665 3647 mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, 3666 3648 int pkt_size) 3667 3649 { 3668 - unsigned long flags = 0; 3669 3650 struct mvpp2_bm_pool *new_pool = &port->priv->bm_pools[pool]; 3670 3651 int num; 3671 3652 ··· 3672 3655 netdev_err(port->dev, "mixing pool types is forbidden\n"); 3673 3656 return NULL; 3674 3657 } 3675 - 3676 - spin_lock_irqsave(&new_pool->lock, flags); 3677 3658 3678 3659 if (new_pool->type == MVPP2_BM_FREE) 3679 3660 new_pool->type = type; ··· 3701 3686 if (num != pkts_num) { 3702 3687 WARN(1, "pool %d: %d of %d allocated\n", 3703 3688 new_pool->id, num, pkts_num); 3704 - /* We need to undo the bufs_add() allocations */ 3705 - spin_unlock_irqrestore(&new_pool->lock, flags); 3706 3689 return NULL; 3707 3690 } 3708 3691 } ··· 3708 3695 mvpp2_bm_pool_bufsize_set(port->priv, new_pool, 3709 3696 MVPP2_RX_BUF_SIZE(new_pool->pkt_size)); 3710 3697 3711 - spin_unlock_irqrestore(&new_pool->lock, flags); 3712 - 3713 3698 return new_pool; 3714 3699 } 3715 3700 3716 3701 /* Initialize pools for swf */ 3717 3702 static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) 3718 3703 { 3719 - unsigned long flags = 0; 3720 3704 int rxq; 3721 3705 3722 3706 if (!port->pool_long) { ··· 3724 3714 if (!port->pool_long) 3725 3715 return -ENOMEM; 3726 3716 3727 - spin_lock_irqsave(&port->pool_long->lock, flags); 3728 3717 port->pool_long->port_map |= (1 << port->id); 3729 - spin_unlock_irqrestore(&port->pool_long->lock, flags); 3730 3718 3731 3719 for (rxq = 0; rxq < rxq_number; rxq++) 3732 3720 mvpp2_rxq_long_pool_set(port, rxq, port->pool_long->id); ··· 3738 3730 if (!port->pool_short) 3739 3731 return -ENOMEM; 3740 3732 3741 - spin_lock_irqsave(&port->pool_short->lock, flags); 3742 3733 port->pool_short->port_map |= (1 << port->id); 3743 - spin_unlock_irqrestore(&port->pool_short->lock, flags); 3744 3734 3745 3735 for (rxq = 0; rxq < rxq_number; rxq++) 3746 3736 mvpp2_rxq_short_pool_set(port, rxq, ··· 3812 3806 3813 3807 mvpp2_write(port->priv, MVPP2_ISR_RX_TX_MASK_REG(port->id), 3814 3808 (MVPP2_CAUSE_MISC_SUM_MASK | 3815 - MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK | 3816 3809 MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK)); 3817 3810 } 3818 3811 ··· 4387 4382 rxq->time_coal = usec; 4388 4383 } 4389 4384 4390 - /* Set threshold for TX_DONE pkts coalescing */ 4391 - static void mvpp2_tx_done_pkts_coal_set(void *arg) 4392 - { 4393 - struct mvpp2_port *port = arg; 4394 - int queue; 4395 - u32 val; 4396 - 4397 - for (queue = 0; queue < txq_number; queue++) { 4398 - struct mvpp2_tx_queue *txq = port->txqs[queue]; 4399 - 4400 - val = (txq->done_pkts_coal << MVPP2_TRANSMITTED_THRESH_OFFSET) & 4401 - MVPP2_TRANSMITTED_THRESH_MASK; 4402 - mvpp2_write(port->priv, MVPP2_TXQ_NUM_REG, txq->id); 4403 - mvpp2_write(port->priv, MVPP2_TXQ_THRESH_REG, val); 4404 - } 4405 - } 4406 - 4407 4385 /* Free Tx queue skbuffs */ 4408 4386 static void mvpp2_txq_bufs_free(struct mvpp2_port *port, 4409 4387 struct mvpp2_tx_queue *txq, ··· 4395 4407 int i; 4396 4408 4397 4409 for (i = 0; i < num; i++) { 4398 - struct mvpp2_tx_desc *tx_desc = txq->descs + 4399 - txq_pcpu->txq_get_index; 4410 + dma_addr_t buf_phys_addr = 4411 + txq_pcpu->tx_buffs[txq_pcpu->txq_get_index]; 4400 4412 struct sk_buff *skb = txq_pcpu->tx_skb[txq_pcpu->txq_get_index]; 4401 4413 4402 4414 mvpp2_txq_inc_get(txq_pcpu); ··· 4404 4416 if (!skb) 4405 4417 continue; 4406 4418 4407 - dma_unmap_single(port->dev->dev.parent, tx_desc->buf_phys_addr, 4408 - tx_desc->data_size, DMA_TO_DEVICE); 4419 + dma_unmap_single(port->dev->dev.parent, buf_phys_addr, 4420 + skb_headlen(skb), DMA_TO_DEVICE); 4409 4421 dev_kfree_skb_any(skb); 4410 4422 } 4411 4423 } ··· 4421 4433 static inline struct mvpp2_tx_queue *mvpp2_get_tx_queue(struct mvpp2_port *port, 4422 4434 u32 cause) 4423 4435 { 4424 - int queue = fls(cause >> 16) - 1; 4436 + int queue = fls(cause) - 1; 4425 4437 4426 4438 return port->txqs[queue]; 4427 4439 } ··· 4446 4458 if (netif_tx_queue_stopped(nq)) 4447 4459 if (txq_pcpu->size - txq_pcpu->count >= MAX_SKB_FRAGS + 1) 4448 4460 netif_tx_wake_queue(nq); 4461 + } 4462 + 4463 + static unsigned int mvpp2_tx_done(struct mvpp2_port *port, u32 cause) 4464 + { 4465 + struct mvpp2_tx_queue *txq; 4466 + struct mvpp2_txq_pcpu *txq_pcpu; 4467 + unsigned int tx_todo = 0; 4468 + 4469 + while (cause) { 4470 + txq = mvpp2_get_tx_queue(port, cause); 4471 + if (!txq) 4472 + break; 4473 + 4474 + txq_pcpu = this_cpu_ptr(txq->pcpu); 4475 + 4476 + if (txq_pcpu->count) { 4477 + mvpp2_txq_done(port, txq, txq_pcpu); 4478 + tx_todo += txq_pcpu->count; 4479 + } 4480 + 4481 + cause &= ~(1 << txq->log_id); 4482 + } 4483 + return tx_todo; 4449 4484 } 4450 4485 4451 4486 /* Rx/Tx queue initialization/cleanup methods */ ··· 4660 4649 txq_pcpu->tx_skb = kmalloc(txq_pcpu->size * 4661 4650 sizeof(*txq_pcpu->tx_skb), 4662 4651 GFP_KERNEL); 4663 - if (!txq_pcpu->tx_skb) { 4664 - dma_free_coherent(port->dev->dev.parent, 4665 - txq->size * MVPP2_DESC_ALIGNED_SIZE, 4666 - txq->descs, txq->descs_phys); 4667 - return -ENOMEM; 4668 - } 4652 + if (!txq_pcpu->tx_skb) 4653 + goto error; 4654 + 4655 + txq_pcpu->tx_buffs = kmalloc(txq_pcpu->size * 4656 + sizeof(dma_addr_t), GFP_KERNEL); 4657 + if (!txq_pcpu->tx_buffs) 4658 + goto error; 4669 4659 4670 4660 txq_pcpu->count = 0; 4671 4661 txq_pcpu->reserved_num = 0; ··· 4675 4663 } 4676 4664 4677 4665 return 0; 4666 + 4667 + error: 4668 + for_each_present_cpu(cpu) { 4669 + txq_pcpu = per_cpu_ptr(txq->pcpu, cpu); 4670 + kfree(txq_pcpu->tx_skb); 4671 + kfree(txq_pcpu->tx_buffs); 4672 + } 4673 + 4674 + dma_free_coherent(port->dev->dev.parent, 4675 + txq->size * MVPP2_DESC_ALIGNED_SIZE, 4676 + txq->descs, txq->descs_phys); 4677 + 4678 + return -ENOMEM; 4678 4679 } 4679 4680 4680 4681 /* Free allocated TXQ resources */ ··· 4700 4675 for_each_present_cpu(cpu) { 4701 4676 txq_pcpu = per_cpu_ptr(txq->pcpu, cpu); 4702 4677 kfree(txq_pcpu->tx_skb); 4678 + kfree(txq_pcpu->tx_buffs); 4703 4679 } 4704 4680 4705 4681 if (txq->descs) ··· 4831 4805 goto err_cleanup; 4832 4806 } 4833 4807 4834 - on_each_cpu(mvpp2_tx_done_pkts_coal_set, port, 1); 4835 4808 on_each_cpu(mvpp2_txq_sent_counter_clear, port, 1); 4836 4809 return 0; 4837 4810 ··· 4910 4885 } 4911 4886 phy_print_status(phydev); 4912 4887 } 4888 + } 4889 + 4890 + static void mvpp2_timer_set(struct mvpp2_port_pcpu *port_pcpu) 4891 + { 4892 + ktime_t interval; 4893 + 4894 + if (!port_pcpu->timer_scheduled) { 4895 + port_pcpu->timer_scheduled = true; 4896 + interval = ktime_set(0, MVPP2_TXDONE_HRTIMER_PERIOD_NS); 4897 + hrtimer_start(&port_pcpu->tx_done_timer, interval, 4898 + HRTIMER_MODE_REL_PINNED); 4899 + } 4900 + } 4901 + 4902 + static void mvpp2_tx_proc_cb(unsigned long data) 4903 + { 4904 + struct net_device *dev = (struct net_device *)data; 4905 + struct mvpp2_port *port = netdev_priv(dev); 4906 + struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu); 4907 + unsigned int tx_todo, cause; 4908 + 4909 + if (!netif_running(dev)) 4910 + return; 4911 + port_pcpu->timer_scheduled = false; 4912 + 4913 + /* Process all the Tx queues */ 4914 + cause = (1 << txq_number) - 1; 4915 + tx_todo = mvpp2_tx_done(port, cause); 4916 + 4917 + /* Set the timer in case not all the packets were processed */ 4918 + if (tx_todo) 4919 + mvpp2_timer_set(port_pcpu); 4920 + } 4921 + 4922 + static enum hrtimer_restart mvpp2_hr_timer_cb(struct hrtimer *timer) 4923 + { 4924 + struct mvpp2_port_pcpu *port_pcpu = container_of(timer, 4925 + struct mvpp2_port_pcpu, 4926 + tx_done_timer); 4927 + 4928 + tasklet_schedule(&port_pcpu->tx_done_tasklet); 4929 + 4930 + return HRTIMER_NORESTART; 4913 4931 } 4914 4932 4915 4933 /* Main RX/TX processing routines */ ··· 5212 5144 if (i == (skb_shinfo(skb)->nr_frags - 1)) { 5213 5145 /* Last descriptor */ 5214 5146 tx_desc->command = MVPP2_TXD_L_DESC; 5215 - mvpp2_txq_inc_put(txq_pcpu, skb); 5147 + mvpp2_txq_inc_put(txq_pcpu, skb, tx_desc); 5216 5148 } else { 5217 5149 /* Descriptor in the middle: Not First, Not Last */ 5218 5150 tx_desc->command = 0; 5219 - mvpp2_txq_inc_put(txq_pcpu, NULL); 5151 + mvpp2_txq_inc_put(txq_pcpu, NULL, tx_desc); 5220 5152 } 5221 5153 } 5222 5154 ··· 5282 5214 /* First and Last descriptor */ 5283 5215 tx_cmd |= MVPP2_TXD_F_DESC | MVPP2_TXD_L_DESC; 5284 5216 tx_desc->command = tx_cmd; 5285 - mvpp2_txq_inc_put(txq_pcpu, skb); 5217 + mvpp2_txq_inc_put(txq_pcpu, skb, tx_desc); 5286 5218 } else { 5287 5219 /* First but not Last */ 5288 5220 tx_cmd |= MVPP2_TXD_F_DESC | MVPP2_TXD_PADDING_DISABLE; 5289 5221 tx_desc->command = tx_cmd; 5290 - mvpp2_txq_inc_put(txq_pcpu, NULL); 5222 + mvpp2_txq_inc_put(txq_pcpu, NULL, tx_desc); 5291 5223 5292 5224 /* Continue with other skb fragments */ 5293 5225 if (mvpp2_tx_frag_process(port, skb, aggr_txq, txq)) { ··· 5323 5255 dev_kfree_skb_any(skb); 5324 5256 } 5325 5257 5258 + /* Finalize TX processing */ 5259 + if (txq_pcpu->count >= txq->done_pkts_coal) 5260 + mvpp2_txq_done(port, txq, txq_pcpu); 5261 + 5262 + /* Set the timer in case not all frags were processed */ 5263 + if (txq_pcpu->count <= frags && txq_pcpu->count > 0) { 5264 + struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu); 5265 + 5266 + mvpp2_timer_set(port_pcpu); 5267 + } 5268 + 5326 5269 return NETDEV_TX_OK; 5327 5270 } 5328 5271 ··· 5347 5268 netdev_err(dev, "tx fifo underrun error\n"); 5348 5269 } 5349 5270 5350 - static void mvpp2_txq_done_percpu(void *arg) 5271 + static int mvpp2_poll(struct napi_struct *napi, int budget) 5351 5272 { 5352 - struct mvpp2_port *port = arg; 5353 - u32 cause_rx_tx, cause_tx, cause_misc; 5273 + u32 cause_rx_tx, cause_rx, cause_misc; 5274 + int rx_done = 0; 5275 + struct mvpp2_port *port = netdev_priv(napi->dev); 5354 5276 5355 5277 /* Rx/Tx cause register 5356 5278 * ··· 5365 5285 */ 5366 5286 cause_rx_tx = mvpp2_read(port->priv, 5367 5287 MVPP2_ISR_RX_TX_CAUSE_REG(port->id)); 5368 - cause_tx = cause_rx_tx & MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK; 5288 + cause_rx_tx &= ~MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK; 5369 5289 cause_misc = cause_rx_tx & MVPP2_CAUSE_MISC_SUM_MASK; 5370 5290 5371 5291 if (cause_misc) { ··· 5377 5297 cause_rx_tx & ~MVPP2_CAUSE_MISC_SUM_MASK); 5378 5298 } 5379 5299 5380 - /* Release TX descriptors */ 5381 - if (cause_tx) { 5382 - struct mvpp2_tx_queue *txq = mvpp2_get_tx_queue(port, cause_tx); 5383 - struct mvpp2_txq_pcpu *txq_pcpu = this_cpu_ptr(txq->pcpu); 5384 - 5385 - if (txq_pcpu->count) 5386 - mvpp2_txq_done(port, txq, txq_pcpu); 5387 - } 5388 - } 5389 - 5390 - static int mvpp2_poll(struct napi_struct *napi, int budget) 5391 - { 5392 - u32 cause_rx_tx, cause_rx; 5393 - int rx_done = 0; 5394 - struct mvpp2_port *port = netdev_priv(napi->dev); 5395 - 5396 - on_each_cpu(mvpp2_txq_done_percpu, port, 1); 5397 - 5398 - cause_rx_tx = mvpp2_read(port->priv, 5399 - MVPP2_ISR_RX_TX_CAUSE_REG(port->id)); 5400 5300 cause_rx = cause_rx_tx & MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK; 5401 5301 5402 5302 /* Process RX packets */ ··· 5621 5561 static int mvpp2_stop(struct net_device *dev) 5622 5562 { 5623 5563 struct mvpp2_port *port = netdev_priv(dev); 5564 + struct mvpp2_port_pcpu *port_pcpu; 5565 + int cpu; 5624 5566 5625 5567 mvpp2_stop_dev(port); 5626 5568 mvpp2_phy_disconnect(port); ··· 5631 5569 on_each_cpu(mvpp2_interrupts_mask, port, 1); 5632 5570 5633 5571 free_irq(port->irq, port); 5572 + for_each_present_cpu(cpu) { 5573 + port_pcpu = per_cpu_ptr(port->pcpu, cpu); 5574 + 5575 + hrtimer_cancel(&port_pcpu->tx_done_timer); 5576 + port_pcpu->timer_scheduled = false; 5577 + tasklet_kill(&port_pcpu->tx_done_tasklet); 5578 + } 5634 5579 mvpp2_cleanup_rxqs(port); 5635 5580 mvpp2_cleanup_txqs(port); 5636 5581 ··· 5853 5784 txq->done_pkts_coal = c->tx_max_coalesced_frames; 5854 5785 } 5855 5786 5856 - on_each_cpu(mvpp2_tx_done_pkts_coal_set, port, 1); 5857 5787 return 0; 5858 5788 } 5859 5789 ··· 6103 6035 { 6104 6036 struct device_node *phy_node; 6105 6037 struct mvpp2_port *port; 6038 + struct mvpp2_port_pcpu *port_pcpu; 6106 6039 struct net_device *dev; 6107 6040 struct resource *res; 6108 6041 const char *dt_mac_addr; ··· 6113 6044 int features; 6114 6045 int phy_mode; 6115 6046 int priv_common_regs_num = 2; 6116 - int err, i; 6047 + int err, i, cpu; 6117 6048 6118 6049 dev = alloc_etherdev_mqs(sizeof(struct mvpp2_port), txq_number, 6119 6050 rxq_number); ··· 6204 6135 } 6205 6136 mvpp2_port_power_up(port); 6206 6137 6138 + port->pcpu = alloc_percpu(struct mvpp2_port_pcpu); 6139 + if (!port->pcpu) { 6140 + err = -ENOMEM; 6141 + goto err_free_txq_pcpu; 6142 + } 6143 + 6144 + for_each_present_cpu(cpu) { 6145 + port_pcpu = per_cpu_ptr(port->pcpu, cpu); 6146 + 6147 + hrtimer_init(&port_pcpu->tx_done_timer, CLOCK_MONOTONIC, 6148 + HRTIMER_MODE_REL_PINNED); 6149 + port_pcpu->tx_done_timer.function = mvpp2_hr_timer_cb; 6150 + port_pcpu->timer_scheduled = false; 6151 + 6152 + tasklet_init(&port_pcpu->tx_done_tasklet, mvpp2_tx_proc_cb, 6153 + (unsigned long)dev); 6154 + } 6155 + 6207 6156 netif_napi_add(dev, &port->napi, mvpp2_poll, NAPI_POLL_WEIGHT); 6208 6157 features = NETIF_F_SG | NETIF_F_IP_CSUM; 6209 6158 dev->features = features | NETIF_F_RXCSUM; ··· 6231 6144 err = register_netdev(dev); 6232 6145 if (err < 0) { 6233 6146 dev_err(&pdev->dev, "failed to register netdev\n"); 6234 - goto err_free_txq_pcpu; 6147 + goto err_free_port_pcpu; 6235 6148 } 6236 6149 netdev_info(dev, "Using %s mac address %pM\n", mac_from, dev->dev_addr); 6237 6150 ··· 6240 6153 priv->port_list[id] = port; 6241 6154 return 0; 6242 6155 6156 + err_free_port_pcpu: 6157 + free_percpu(port->pcpu); 6243 6158 err_free_txq_pcpu: 6244 6159 for (i = 0; i < txq_number; i++) 6245 6160 free_percpu(port->txqs[i]->pcpu); ··· 6260 6171 int i; 6261 6172 6262 6173 unregister_netdev(port->dev); 6174 + free_percpu(port->pcpu); 6263 6175 free_percpu(port->stats); 6264 6176 for (i = 0; i < txq_number; i++) 6265 6177 free_percpu(port->txqs[i]->pcpu);
+2
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 391 391 /* disable cmdif checksum */ 392 392 MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0); 393 393 394 + MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12); 395 + 394 396 err = set_caps(dev, set_ctx, set_sz); 395 397 396 398 query_ex:
+3 -1
drivers/net/ethernet/realtek/r8169.c
··· 4875 4875 case RTL_GIGA_MAC_VER_46: 4876 4876 case RTL_GIGA_MAC_VER_47: 4877 4877 case RTL_GIGA_MAC_VER_48: 4878 + RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF); 4879 + break; 4878 4880 case RTL_GIGA_MAC_VER_49: 4879 4881 case RTL_GIGA_MAC_VER_50: 4880 4882 case RTL_GIGA_MAC_VER_51: 4881 - RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF); 4883 + RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); 4882 4884 break; 4883 4885 default: 4884 4886 RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST);
+1
drivers/net/ethernet/rocker/rocker.c
··· 4821 4821 rocker_port_ig_tbl(rocker_port, SWITCHDEV_TRANS_NONE, 4822 4822 ROCKER_OP_FLAG_REMOVE); 4823 4823 unregister_netdev(rocker_port->dev); 4824 + free_netdev(rocker_port->dev); 4824 4825 } 4825 4826 kfree(rocker->ports); 4826 4827 }
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
··· 42 42 #define NSS_COMMON_CLK_DIV_MASK 0x7f 43 43 44 44 #define NSS_COMMON_CLK_SRC_CTRL 0x14 45 - #define NSS_COMMON_CLK_SRC_CTRL_OFFSET(x) (1 << x) 45 + #define NSS_COMMON_CLK_SRC_CTRL_OFFSET(x) (x) 46 46 /* Mode is coded on 1 bit but is different depending on the MAC ID: 47 47 * MAC0: QSGMII=0 RGMII=1 48 48 * MAC1: QSGMII=0 SGMII=0 RGMII=1 ··· 291 291 292 292 /* Configure the clock src according to the mode */ 293 293 regmap_read(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, &val); 294 - val &= ~NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); 294 + val &= ~(1 << NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id)); 295 295 switch (gmac->phy_mode) { 296 296 case PHY_INTERFACE_MODE_RGMII: 297 297 val |= NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) <<
-1
drivers/net/ethernet/ti/netcp.h
··· 85 85 struct list_head rxhook_list_head; 86 86 unsigned int rx_queue_id; 87 87 void *rx_fdq[KNAV_DMA_FDQ_PER_CHAN]; 88 - u32 rx_buffer_sizes[KNAV_DMA_FDQ_PER_CHAN]; 89 88 struct napi_struct rx_napi; 90 89 struct napi_struct tx_napi; 91 90
+13 -22
drivers/net/ethernet/ti/netcp_core.c
··· 34 34 #define NETCP_SOP_OFFSET (NET_IP_ALIGN + NET_SKB_PAD) 35 35 #define NETCP_NAPI_WEIGHT 64 36 36 #define NETCP_TX_TIMEOUT (5 * HZ) 37 + #define NETCP_PACKET_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN) 37 38 #define NETCP_MIN_PACKET_SIZE ETH_ZLEN 38 39 #define NETCP_MAX_MCAST_ADDR 16 39 40 ··· 805 804 if (likely(fdq == 0)) { 806 805 unsigned int primary_buf_len; 807 806 /* Allocate a primary receive queue entry */ 808 - buf_len = netcp->rx_buffer_sizes[0] + NETCP_SOP_OFFSET; 807 + buf_len = NETCP_PACKET_SIZE + NETCP_SOP_OFFSET; 809 808 primary_buf_len = SKB_DATA_ALIGN(buf_len) + 810 809 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); 811 810 812 - if (primary_buf_len <= PAGE_SIZE) { 813 - bufptr = netdev_alloc_frag(primary_buf_len); 814 - pad[1] = primary_buf_len; 815 - } else { 816 - bufptr = kmalloc(primary_buf_len, GFP_ATOMIC | 817 - GFP_DMA32 | __GFP_COLD); 818 - pad[1] = 0; 819 - } 811 + bufptr = netdev_alloc_frag(primary_buf_len); 812 + pad[1] = primary_buf_len; 820 813 821 814 if (unlikely(!bufptr)) { 822 - dev_warn_ratelimited(netcp->ndev_dev, "Primary RX buffer alloc failed\n"); 815 + dev_warn_ratelimited(netcp->ndev_dev, 816 + "Primary RX buffer alloc failed\n"); 823 817 goto fail; 824 818 } 825 819 dma = dma_map_single(netcp->dev, bufptr, buf_len, 826 820 DMA_TO_DEVICE); 821 + if (unlikely(dma_mapping_error(netcp->dev, dma))) 822 + goto fail; 823 + 827 824 pad[0] = (u32)bufptr; 828 825 829 826 } else { 830 827 /* Allocate a secondary receive queue entry */ 831 - page = alloc_page(GFP_ATOMIC | GFP_DMA32 | __GFP_COLD); 828 + page = alloc_page(GFP_ATOMIC | GFP_DMA | __GFP_COLD); 832 829 if (unlikely(!page)) { 833 830 dev_warn_ratelimited(netcp->ndev_dev, "Secondary page alloc failed\n"); 834 831 goto fail; ··· 1009 1010 1010 1011 /* Map the linear buffer */ 1011 1012 dma_addr = dma_map_single(dev, skb->data, pkt_len, DMA_TO_DEVICE); 1012 - if (unlikely(!dma_addr)) { 1013 + if (unlikely(dma_mapping_error(dev, dma_addr))) { 1013 1014 dev_err(netcp->ndev_dev, "Failed to map skb buffer\n"); 1014 1015 return NULL; 1015 1016 } ··· 1545 1546 knav_queue_disable_notify(netcp->rx_queue); 1546 1547 1547 1548 /* open Rx FDQs */ 1548 - for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN && 1549 - netcp->rx_queue_depths[i] && netcp->rx_buffer_sizes[i]; ++i) { 1549 + for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN && netcp->rx_queue_depths[i]; 1550 + ++i) { 1550 1551 snprintf(name, sizeof(name), "rx-fdq-%s-%d", ndev->name, i); 1551 1552 netcp->rx_fdq[i] = knav_queue_open(name, KNAV_QUEUE_GP, 0); 1552 1553 if (IS_ERR_OR_NULL(netcp->rx_fdq[i])) { ··· 1938 1939 if (ret < 0) { 1939 1940 dev_err(dev, "missing \"rx-queue-depth\" parameter\n"); 1940 1941 netcp->rx_queue_depths[0] = 128; 1941 - } 1942 - 1943 - ret = of_property_read_u32_array(node_interface, "rx-buffer-size", 1944 - netcp->rx_buffer_sizes, 1945 - KNAV_DMA_FDQ_PER_CHAN); 1946 - if (ret) { 1947 - dev_err(dev, "missing \"rx-buffer-size\" parameter\n"); 1948 - netcp->rx_buffer_sizes[0] = 1536; 1949 1942 } 1950 1943 1951 1944 ret = of_property_read_u32_array(node_interface, "rx-pool", temp, 2);
+4 -3
drivers/net/hamradio/mkiss.c
··· 728 728 dev->type = ARPHRD_AX25; 729 729 730 730 /* Perform the low-level AX25 initialization. */ 731 - if ((err = ax_open(ax->dev))) { 731 + err = ax_open(ax->dev); 732 + if (err) 732 733 goto out_free_netdev; 733 - } 734 734 735 - if (register_netdev(dev)) 735 + err = register_netdev(dev); 736 + if (err) 736 737 goto out_free_buffers; 737 738 738 739 /* after register_netdev() - because else printk smashes the kernel */
+2 -2
drivers/net/virtio_net.c
··· 1756 1756 /* Do we support "hardware" checksums? */ 1757 1757 if (virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) { 1758 1758 /* This opens up the world of extra features. */ 1759 - dev->hw_features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; 1759 + dev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_SG; 1760 1760 if (csum) 1761 - dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; 1761 + dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG; 1762 1762 1763 1763 if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) { 1764 1764 dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
+2 -1
drivers/net/wan/cosa.c
··· 589 589 chan->netdev->base_addr = chan->cosa->datareg; 590 590 chan->netdev->irq = chan->cosa->irq; 591 591 chan->netdev->dma = chan->cosa->dma; 592 - if (register_hdlc_device(chan->netdev)) { 592 + err = register_hdlc_device(chan->netdev); 593 + if (err) { 593 594 netdev_warn(chan->netdev, 594 595 "register_hdlc_device() failed\n"); 595 596 free_netdev(chan->netdev);
+1 -1
drivers/net/wireless/b43/tables_nphy.c
··· 3728 3728 switch (phy->rev) { 3729 3729 case 6: 3730 3730 case 5: 3731 - if (sprom->fem.ghz5.extpa_gain == 3) 3731 + if (sprom->fem.ghz2.extpa_gain == 3) 3732 3732 return b43_ntab_tx_gain_epa_rev3_hi_pwr_2g; 3733 3733 /* fall through */ 3734 3734 case 4:
+1 -1
drivers/net/wireless/iwlwifi/mvm/scan.c
··· 1023 1023 cmd->scan_priority = 1024 1024 iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6); 1025 1025 1026 - if (iwl_mvm_scan_total_iterations(params) == 0) 1026 + if (iwl_mvm_scan_total_iterations(params) == 1) 1027 1027 cmd->ooc_priority = 1028 1028 iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6); 1029 1029 else
+19 -3
drivers/net/wireless/iwlwifi/pcie/trans.c
··· 478 478 if (trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) 479 479 iwl_set_bits_prph(trans, APMG_PCIDEV_STT_REG, 480 480 APMG_PCIDEV_STT_VAL_WAKE_ME); 481 - else if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) 481 + else if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) { 482 + iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, 483 + CSR_RESET_LINK_PWR_MGMT_DISABLED); 482 484 iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, 483 485 CSR_HW_IF_CONFIG_REG_PREPARE | 484 486 CSR_HW_IF_CONFIG_REG_ENABLE_PME); 487 + mdelay(1); 488 + iwl_clear_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, 489 + CSR_RESET_LINK_PWR_MGMT_DISABLED); 490 + } 485 491 mdelay(5); 486 492 } 487 493 ··· 581 575 if (ret >= 0) 582 576 return 0; 583 577 578 + iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, 579 + CSR_RESET_LINK_PWR_MGMT_DISABLED); 580 + msleep(1); 581 + 584 582 for (iter = 0; iter < 10; iter++) { 585 583 /* If HW is not ready, prepare the conditions to check again */ 586 584 iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, ··· 592 582 593 583 do { 594 584 ret = iwl_pcie_set_hw_ready(trans); 595 - if (ret >= 0) 596 - return 0; 585 + if (ret >= 0) { 586 + ret = 0; 587 + goto out; 588 + } 597 589 598 590 usleep_range(200, 1000); 599 591 t += 200; ··· 604 592 } 605 593 606 594 IWL_ERR(trans, "Couldn't prepare the card\n"); 595 + 596 + out: 597 + iwl_clear_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, 598 + CSR_RESET_LINK_PWR_MGMT_DISABLED); 607 599 608 600 return ret; 609 601 }
+13 -2
drivers/net/wireless/iwlwifi/pcie/tx.c
··· 1875 1875 1876 1876 /* start timer if queue currently empty */ 1877 1877 if (q->read_ptr == q->write_ptr) { 1878 - if (txq->wd_timeout) 1879 - mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout); 1878 + if (txq->wd_timeout) { 1879 + /* 1880 + * If the TXQ is active, then set the timer, if not, 1881 + * set the timer in remainder so that the timer will 1882 + * be armed with the right value when the station will 1883 + * wake up. 1884 + */ 1885 + if (!txq->frozen) 1886 + mod_timer(&txq->stuck_timer, 1887 + jiffies + txq->wd_timeout); 1888 + else 1889 + txq->frozen_expiry_remainder = txq->wd_timeout; 1890 + } 1880 1891 IWL_DEBUG_RPM(trans, "Q: %d first tx - take ref\n", q->id); 1881 1892 iwl_trans_pcie_ref(trans); 1882 1893 }
+7 -1
drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
··· 172 172 (struct rsi_91x_sdiodev *)adapter->rsi_dev; 173 173 u32 len; 174 174 u32 num_blocks; 175 + const u8 *fw; 175 176 const struct firmware *fw_entry = NULL; 176 177 u32 block_size = dev->tx_blk_size; 177 178 int status = 0; ··· 201 200 return status; 202 201 } 203 202 203 + /* Copy firmware into DMA-accessible memory */ 204 + fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL); 205 + if (!fw) 206 + return -ENOMEM; 204 207 len = fw_entry->size; 205 208 206 209 if (len % 4) ··· 215 210 rsi_dbg(INIT_ZONE, "%s: Instruction size:%d\n", __func__, len); 216 211 rsi_dbg(INIT_ZONE, "%s: num blocks: %d\n", __func__, num_blocks); 217 212 218 - status = rsi_copy_to_card(common, fw_entry->data, len, num_blocks); 213 + status = rsi_copy_to_card(common, fw, len, num_blocks); 214 + kfree(fw); 219 215 release_firmware(fw_entry); 220 216 return status; 221 217 }
+4
drivers/net/wireless/rsi/rsi_91x_usb_ops.c
··· 146 146 return status; 147 147 } 148 148 149 + /* Copy firmware into DMA-accessible memory */ 149 150 fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL); 151 + if (!fw) 152 + return -ENOMEM; 150 153 len = fw_entry->size; 151 154 152 155 if (len % 4) ··· 161 158 rsi_dbg(INIT_ZONE, "%s: num blocks: %d\n", __func__, num_blocks); 162 159 163 160 status = rsi_copy_to_card(common, fw, len, num_blocks); 161 + kfree(fw); 164 162 release_firmware(fw_entry); 165 163 return status; 166 164 }
+5 -2
drivers/net/wireless/rtlwifi/core.c
··· 1015 1015 { 1016 1016 struct rtl_priv *rtlpriv = rtl_priv(hw); 1017 1017 struct sk_buff *skb = ieee80211_beacon_get(hw, vif); 1018 + struct rtl_tcb_desc tcb_desc; 1018 1019 1019 - if (skb) 1020 - rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, NULL); 1020 + if (skb) { 1021 + memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); 1022 + rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc); 1023 + } 1021 1024 } 1022 1025 1023 1026 static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
+1
drivers/net/wireless/rtlwifi/rtl8723be/sw.c
··· 385 385 module_param_named(ips, rtl8723be_mod_params.inactiveps, bool, 0444); 386 386 module_param_named(swlps, rtl8723be_mod_params.swctrl_lps, bool, 0444); 387 387 module_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444); 388 + module_param_named(msi, rtl8723be_mod_params.msi_support, bool, 0444); 388 389 module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog, 389 390 bool, 0444); 390 391 MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
+6
drivers/net/xen-netback/interface.c
··· 61 61 void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue) 62 62 { 63 63 atomic_dec(&queue->inflight_packets); 64 + 65 + /* Wake the dealloc thread _after_ decrementing inflight_packets so 66 + * that if kthread_stop() has already been called, the dealloc thread 67 + * does not wait forever with nothing to wake it. 68 + */ 69 + wake_up(&queue->dealloc_wq); 64 70 } 65 71 66 72 int xenvif_schedulable(struct xenvif *vif)
+33 -29
drivers/net/xen-netback/netback.c
··· 810 810 static struct gnttab_map_grant_ref *xenvif_get_requests(struct xenvif_queue *queue, 811 811 struct sk_buff *skb, 812 812 struct xen_netif_tx_request *txp, 813 - struct gnttab_map_grant_ref *gop) 813 + struct gnttab_map_grant_ref *gop, 814 + unsigned int frag_overflow, 815 + struct sk_buff *nskb) 814 816 { 815 817 struct skb_shared_info *shinfo = skb_shinfo(skb); 816 818 skb_frag_t *frags = shinfo->frags; 817 819 u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx; 818 820 int start; 819 821 pending_ring_idx_t index; 820 - unsigned int nr_slots, frag_overflow = 0; 822 + unsigned int nr_slots; 821 823 822 - /* At this point shinfo->nr_frags is in fact the number of 823 - * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX. 824 - */ 825 - if (shinfo->nr_frags > MAX_SKB_FRAGS) { 826 - frag_overflow = shinfo->nr_frags - MAX_SKB_FRAGS; 827 - BUG_ON(frag_overflow > MAX_SKB_FRAGS); 828 - shinfo->nr_frags = MAX_SKB_FRAGS; 829 - } 830 824 nr_slots = shinfo->nr_frags; 831 825 832 826 /* Skip first skb fragment if it is on same page as header fragment. */ ··· 835 841 } 836 842 837 843 if (frag_overflow) { 838 - struct sk_buff *nskb = xenvif_alloc_skb(0); 839 - if (unlikely(nskb == NULL)) { 840 - if (net_ratelimit()) 841 - netdev_err(queue->vif->dev, 842 - "Can't allocate the frag_list skb.\n"); 843 - return NULL; 844 - } 845 844 846 845 shinfo = skb_shinfo(nskb); 847 846 frags = shinfo->frags; ··· 1162 1175 unsigned *copy_ops, 1163 1176 unsigned *map_ops) 1164 1177 { 1165 - struct gnttab_map_grant_ref *gop = queue->tx_map_ops, *request_gop; 1166 - struct sk_buff *skb; 1178 + struct gnttab_map_grant_ref *gop = queue->tx_map_ops; 1179 + struct sk_buff *skb, *nskb; 1167 1180 int ret; 1181 + unsigned int frag_overflow; 1168 1182 1169 1183 while (skb_queue_len(&queue->tx_queue) < budget) { 1170 1184 struct xen_netif_tx_request txreq; ··· 1253 1265 break; 1254 1266 } 1255 1267 1268 + skb_shinfo(skb)->nr_frags = ret; 1269 + if (data_len < txreq.size) 1270 + skb_shinfo(skb)->nr_frags++; 1271 + /* At this point shinfo->nr_frags is in fact the number of 1272 + * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX. 1273 + */ 1274 + frag_overflow = 0; 1275 + nskb = NULL; 1276 + if (skb_shinfo(skb)->nr_frags > MAX_SKB_FRAGS) { 1277 + frag_overflow = skb_shinfo(skb)->nr_frags - MAX_SKB_FRAGS; 1278 + BUG_ON(frag_overflow > MAX_SKB_FRAGS); 1279 + skb_shinfo(skb)->nr_frags = MAX_SKB_FRAGS; 1280 + nskb = xenvif_alloc_skb(0); 1281 + if (unlikely(nskb == NULL)) { 1282 + kfree_skb(skb); 1283 + xenvif_tx_err(queue, &txreq, idx); 1284 + if (net_ratelimit()) 1285 + netdev_err(queue->vif->dev, 1286 + "Can't allocate the frag_list skb.\n"); 1287 + break; 1288 + } 1289 + } 1290 + 1256 1291 if (extras[XEN_NETIF_EXTRA_TYPE_GSO - 1].type) { 1257 1292 struct xen_netif_extra_info *gso; 1258 1293 gso = &extras[XEN_NETIF_EXTRA_TYPE_GSO - 1]; ··· 1283 1272 if (xenvif_set_skb_gso(queue->vif, skb, gso)) { 1284 1273 /* Failure in xenvif_set_skb_gso is fatal. */ 1285 1274 kfree_skb(skb); 1275 + kfree_skb(nskb); 1286 1276 break; 1287 1277 } 1288 1278 } ··· 1306 1294 1307 1295 (*copy_ops)++; 1308 1296 1309 - skb_shinfo(skb)->nr_frags = ret; 1310 1297 if (data_len < txreq.size) { 1311 - skb_shinfo(skb)->nr_frags++; 1312 1298 frag_set_pending_idx(&skb_shinfo(skb)->frags[0], 1313 1299 pending_idx); 1314 1300 xenvif_tx_create_map_op(queue, pending_idx, &txreq, gop); ··· 1320 1310 1321 1311 queue->pending_cons++; 1322 1312 1323 - request_gop = xenvif_get_requests(queue, skb, txfrags, gop); 1324 - if (request_gop == NULL) { 1325 - kfree_skb(skb); 1326 - xenvif_tx_err(queue, &txreq, idx); 1327 - break; 1328 - } 1329 - gop = request_gop; 1313 + gop = xenvif_get_requests(queue, skb, txfrags, gop, 1314 + frag_overflow, nskb); 1330 1315 1331 1316 __skb_queue_tail(&queue->tx_queue, skb); 1332 1317 ··· 1541 1536 smp_wmb(); 1542 1537 queue->dealloc_prod++; 1543 1538 } while (ubuf); 1544 - wake_up(&queue->dealloc_wq); 1545 1539 spin_unlock_irqrestore(&queue->callback_lock, flags); 1546 1540 1547 1541 if (likely(zerocopy_success))
+3 -3
include/linux/skbuff.h
··· 2884 2884 * 2885 2885 * PHY drivers may accept clones of transmitted packets for 2886 2886 * timestamping via their phy_driver.txtstamp method. These drivers 2887 - * must call this function to return the skb back to the stack, with 2888 - * or without a timestamp. 2887 + * must call this function to return the skb back to the stack with a 2888 + * timestamp. 2889 2889 * 2890 2890 * @skb: clone of the the original outgoing packet 2891 - * @hwtstamps: hardware time stamps, may be NULL if not available 2891 + * @hwtstamps: hardware time stamps 2892 2892 * 2893 2893 */ 2894 2894 void skb_complete_tx_timestamp(struct sk_buff *skb,
+13 -5
net/batman-adv/distributed-arp-table.c
··· 1138 1138 * @bat_priv: the bat priv with all the soft interface information 1139 1139 * @skb: packet to check 1140 1140 * @hdr_size: size of the encapsulation header 1141 + * 1142 + * Returns true if the packet was snooped and consumed by DAT. False if the 1143 + * packet has to be delivered to the interface 1141 1144 */ 1142 1145 bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, 1143 1146 struct sk_buff *skb, int hdr_size) ··· 1148 1145 uint16_t type; 1149 1146 __be32 ip_src, ip_dst; 1150 1147 uint8_t *hw_src, *hw_dst; 1151 - bool ret = false; 1148 + bool dropped = false; 1152 1149 unsigned short vid; 1153 1150 1154 1151 if (!atomic_read(&bat_priv->distributed_arp_table)) ··· 1177 1174 /* if this REPLY is directed to a client of mine, let's deliver the 1178 1175 * packet to the interface 1179 1176 */ 1180 - ret = !batadv_is_my_client(bat_priv, hw_dst, vid); 1177 + dropped = !batadv_is_my_client(bat_priv, hw_dst, vid); 1178 + 1179 + /* if this REPLY is sent on behalf of a client of mine, let's drop the 1180 + * packet because the client will reply by itself 1181 + */ 1182 + dropped |= batadv_is_my_client(bat_priv, hw_src, vid); 1181 1183 out: 1182 - if (ret) 1184 + if (dropped) 1183 1185 kfree_skb(skb); 1184 - /* if ret == false -> packet has to be delivered to the interface */ 1185 - return ret; 1186 + /* if dropped == false -> deliver to the interface */ 1187 + return dropped; 1186 1188 } 1187 1189 1188 1190 /**
+2
net/batman-adv/gateway_client.c
··· 439 439 440 440 INIT_HLIST_NODE(&gw_node->list); 441 441 gw_node->orig_node = orig_node; 442 + gw_node->bandwidth_down = ntohl(gateway->bandwidth_down); 443 + gw_node->bandwidth_up = ntohl(gateway->bandwidth_up); 442 444 atomic_set(&gw_node->refcount, 1); 443 445 444 446 spin_lock_bh(&bat_priv->gw.list_lock);
+3
net/batman-adv/soft-interface.c
··· 479 479 */ 480 480 void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *vlan) 481 481 { 482 + if (!vlan) 483 + return; 484 + 482 485 if (atomic_dec_and_test(&vlan->refcount)) { 483 486 spin_lock_bh(&vlan->bat_priv->softif_vlan_list_lock); 484 487 hlist_del_rcu(&vlan->list);
+24 -5
net/batman-adv/translation-table.c
··· 594 594 595 595 /* increase the refcounter of the related vlan */ 596 596 vlan = batadv_softif_vlan_get(bat_priv, vid); 597 + if (WARN(!vlan, "adding TT local entry %pM to non-existent VLAN %d", 598 + addr, BATADV_PRINT_VID(vid))) 599 + goto out; 597 600 598 601 batadv_dbg(BATADV_DBG_TT, bat_priv, 599 602 "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n", ··· 1037 1034 struct batadv_tt_local_entry *tt_local_entry; 1038 1035 uint16_t flags, curr_flags = BATADV_NO_FLAGS; 1039 1036 struct batadv_softif_vlan *vlan; 1037 + void *tt_entry_exists; 1040 1038 1041 1039 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid); 1042 1040 if (!tt_local_entry) ··· 1065 1061 * immediately purge it 1066 1062 */ 1067 1063 batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL); 1068 - hlist_del_rcu(&tt_local_entry->common.hash_entry); 1064 + 1065 + tt_entry_exists = batadv_hash_remove(bat_priv->tt.local_hash, 1066 + batadv_compare_tt, 1067 + batadv_choose_tt, 1068 + &tt_local_entry->common); 1069 + if (!tt_entry_exists) 1070 + goto out; 1071 + 1072 + /* extra call to free the local tt entry */ 1069 1073 batadv_tt_local_entry_free_ref(tt_local_entry); 1070 1074 1071 1075 /* decrease the reference held for this vlan */ 1072 1076 vlan = batadv_softif_vlan_get(bat_priv, vid); 1077 + if (!vlan) 1078 + goto out; 1079 + 1073 1080 batadv_softif_vlan_free_ref(vlan); 1074 1081 batadv_softif_vlan_free_ref(vlan); 1075 1082 ··· 1181 1166 /* decrease the reference held for this vlan */ 1182 1167 vlan = batadv_softif_vlan_get(bat_priv, 1183 1168 tt_common_entry->vid); 1184 - batadv_softif_vlan_free_ref(vlan); 1185 - batadv_softif_vlan_free_ref(vlan); 1169 + if (vlan) { 1170 + batadv_softif_vlan_free_ref(vlan); 1171 + batadv_softif_vlan_free_ref(vlan); 1172 + } 1186 1173 1187 1174 batadv_tt_local_entry_free_ref(tt_local); 1188 1175 } ··· 3224 3207 3225 3208 /* decrease the reference held for this vlan */ 3226 3209 vlan = batadv_softif_vlan_get(bat_priv, tt_common->vid); 3227 - batadv_softif_vlan_free_ref(vlan); 3228 - batadv_softif_vlan_free_ref(vlan); 3210 + if (vlan) { 3211 + batadv_softif_vlan_free_ref(vlan); 3212 + batadv_softif_vlan_free_ref(vlan); 3213 + } 3229 3214 3230 3215 batadv_tt_local_entry_free_ref(tt_local); 3231 3216 }
+1 -1
net/bluetooth/mgmt.c
··· 7820 7820 /* Make sure we copy only the significant bytes based on the 7821 7821 * encryption key size, and set the rest of the value to zeroes. 7822 7822 */ 7823 - memcpy(ev.key.val, key->val, sizeof(key->enc_size)); 7823 + memcpy(ev.key.val, key->val, key->enc_size); 7824 7824 memset(ev.key.val + key->enc_size, 0, 7825 7825 sizeof(ev.key.val) - key->enc_size); 7826 7826
+4
net/bridge/br_netlink.c
··· 112 112 + nla_total_size(1) /* IFLA_BRPORT_FAST_LEAVE */ 113 113 + nla_total_size(1) /* IFLA_BRPORT_LEARNING */ 114 114 + nla_total_size(1) /* IFLA_BRPORT_UNICAST_FLOOD */ 115 + + nla_total_size(1) /* IFLA_BRPORT_PROXYARP */ 116 + + nla_total_size(1) /* IFLA_BRPORT_PROXYARP_WIFI */ 115 117 + 0; 116 118 } 117 119 ··· 508 506 [IFLA_BRPORT_FAST_LEAVE]= { .type = NLA_U8 }, 509 507 [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 }, 510 508 [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 }, 509 + [IFLA_BRPORT_PROXYARP] = { .type = NLA_U8 }, 510 + [IFLA_BRPORT_PROXYARP_WIFI] = { .type = NLA_U8 }, 511 511 }; 512 512 513 513 /* Change the state of the port and notify spanning tree */
+7 -6
net/core/datagram.c
··· 131 131 goto out; 132 132 } 133 133 134 - static int skb_set_peeked(struct sk_buff *skb) 134 + static struct sk_buff *skb_set_peeked(struct sk_buff *skb) 135 135 { 136 136 struct sk_buff *nskb; 137 137 138 138 if (skb->peeked) 139 - return 0; 139 + return skb; 140 140 141 141 /* We have to unshare an skb before modifying it. */ 142 142 if (!skb_shared(skb)) ··· 144 144 145 145 nskb = skb_clone(skb, GFP_ATOMIC); 146 146 if (!nskb) 147 - return -ENOMEM; 147 + return ERR_PTR(-ENOMEM); 148 148 149 149 skb->prev->next = nskb; 150 150 skb->next->prev = nskb; ··· 157 157 done: 158 158 skb->peeked = 1; 159 159 160 - return 0; 160 + return skb; 161 161 } 162 162 163 163 /** ··· 229 229 continue; 230 230 } 231 231 232 - error = skb_set_peeked(skb); 233 - if (error) 232 + skb = skb_set_peeked(skb); 233 + error = PTR_ERR(skb); 234 + if (IS_ERR(skb)) 234 235 goto unlock_err; 235 236 236 237 atomic_inc(&skb->users);
-3
net/core/pktgen.c
··· 3514 3514 3515 3515 set_freezable(); 3516 3516 3517 - __set_current_state(TASK_RUNNING); 3518 - 3519 3517 while (!kthread_should_stop()) { 3520 3518 pkt_dev = next_to_run(t); 3521 3519 ··· 3558 3560 3559 3561 try_to_freeze(); 3560 3562 } 3561 - set_current_state(TASK_INTERRUPTIBLE); 3562 3563 3563 3564 pr_debug("%s stopping all device\n", t->tsk->comm); 3564 3565 pktgen_stop(t);
+7 -1
net/core/request_sock.c
··· 103 103 spin_lock_bh(&queue->syn_wait_lock); 104 104 while ((req = lopt->syn_table[i]) != NULL) { 105 105 lopt->syn_table[i] = req->dl_next; 106 + /* Because of following del_timer_sync(), 107 + * we must release the spinlock here 108 + * or risk a dead lock. 109 + */ 110 + spin_unlock_bh(&queue->syn_wait_lock); 106 111 atomic_inc(&lopt->qlen_dec); 107 - if (del_timer(&req->rsk_timer)) 112 + if (del_timer_sync(&req->rsk_timer)) 108 113 reqsk_put(req); 109 114 reqsk_put(req); 115 + spin_lock_bh(&queue->syn_wait_lock); 110 116 } 111 117 spin_unlock_bh(&queue->syn_wait_lock); 112 118 }
+2 -1
net/dsa/slave.c
··· 756 756 return -ENODEV; 757 757 758 758 /* Use already configured phy mode */ 759 - p->phy_interface = p->phy->interface; 759 + if (p->phy_interface == PHY_INTERFACE_MODE_NA) 760 + p->phy_interface = p->phy->interface; 760 761 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, 761 762 p->phy_interface); 762 763
+1 -1
net/ipv4/inet_connection_sock.c
··· 593 593 } 594 594 595 595 spin_unlock(&queue->syn_wait_lock); 596 - if (del_timer(&req->rsk_timer)) 596 + if (del_timer_sync(&req->rsk_timer)) 597 597 reqsk_put(req); 598 598 return found; 599 599 }
+2 -1
net/ipv4/netfilter/ipt_SYNPROXY.c
··· 226 226 227 227 synproxy_build_options(nth, opts); 228 228 229 - synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); 229 + synproxy_send_tcp(skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, 230 + niph, nth, tcp_hdr_size); 230 231 } 231 232 232 233 static bool
+1 -1
net/ipv4/tcp_ipv4.c
··· 1348 1348 req = inet_csk_search_req(sk, th->source, iph->saddr, iph->daddr); 1349 1349 if (req) { 1350 1350 nsk = tcp_check_req(sk, skb, req, false); 1351 - if (!nsk) 1351 + if (!nsk || nsk == sk) 1352 1352 reqsk_put(req); 1353 1353 return nsk; 1354 1354 }
+10 -3
net/ipv4/udp.c
··· 1995 1995 1996 1996 skb->sk = sk; 1997 1997 skb->destructor = sock_efree; 1998 - dst = sk->sk_rx_dst; 1998 + dst = READ_ONCE(sk->sk_rx_dst); 1999 1999 2000 2000 if (dst) 2001 2001 dst = dst_check(dst, 0); 2002 - if (dst) 2003 - skb_dst_set_noref(skb, dst); 2002 + if (dst) { 2003 + /* DST_NOCACHE can not be used without taking a reference */ 2004 + if (dst->flags & DST_NOCACHE) { 2005 + if (likely(atomic_inc_not_zero(&dst->__refcnt))) 2006 + skb_dst_set(skb, dst); 2007 + } else { 2008 + skb_dst_set_noref(skb, dst); 2009 + } 2010 + } 2004 2011 } 2005 2012 2006 2013 int udp_rcv(struct sk_buff *skb)
+11 -8
net/ipv6/netfilter/ip6t_SYNPROXY.c
··· 37 37 } 38 38 39 39 static void 40 - synproxy_send_tcp(const struct sk_buff *skb, struct sk_buff *nskb, 40 + synproxy_send_tcp(const struct synproxy_net *snet, 41 + const struct sk_buff *skb, struct sk_buff *nskb, 41 42 struct nf_conntrack *nfct, enum ip_conntrack_info ctinfo, 42 43 struct ipv6hdr *niph, struct tcphdr *nth, 43 44 unsigned int tcp_hdr_size) 44 45 { 45 - struct net *net = nf_ct_net((struct nf_conn *)nfct); 46 + struct net *net = nf_ct_net(snet->tmpl); 46 47 struct dst_entry *dst; 47 48 struct flowi6 fl6; 48 49 ··· 84 83 } 85 84 86 85 static void 87 - synproxy_send_client_synack(const struct sk_buff *skb, const struct tcphdr *th, 86 + synproxy_send_client_synack(const struct synproxy_net *snet, 87 + const struct sk_buff *skb, const struct tcphdr *th, 88 88 const struct synproxy_options *opts) 89 89 { 90 90 struct sk_buff *nskb; ··· 121 119 122 120 synproxy_build_options(nth, opts); 123 121 124 - synproxy_send_tcp(skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, 122 + synproxy_send_tcp(snet, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, 125 123 niph, nth, tcp_hdr_size); 126 124 } 127 125 ··· 165 163 166 164 synproxy_build_options(nth, opts); 167 165 168 - synproxy_send_tcp(skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW, 166 + synproxy_send_tcp(snet, skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW, 169 167 niph, nth, tcp_hdr_size); 170 168 } 171 169 ··· 205 203 206 204 synproxy_build_options(nth, opts); 207 205 208 - synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); 206 + synproxy_send_tcp(snet, skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); 209 207 } 210 208 211 209 static void ··· 243 241 244 242 synproxy_build_options(nth, opts); 245 243 246 - synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); 244 + synproxy_send_tcp(snet, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, 245 + niph, nth, tcp_hdr_size); 247 246 } 248 247 249 248 static bool ··· 304 301 XT_SYNPROXY_OPT_SACK_PERM | 305 302 XT_SYNPROXY_OPT_ECN); 306 303 307 - synproxy_send_client_synack(skb, th, &opts); 304 + synproxy_send_client_synack(snet, skb, th, &opts); 308 305 return NF_DROP; 309 306 310 307 } else if (th->ack && !(th->fin || th->rst || th->syn)) {
+4 -2
net/ipv6/route.c
··· 1831 1831 int gwa_type; 1832 1832 1833 1833 gw_addr = &cfg->fc_gateway; 1834 + gwa_type = ipv6_addr_type(gw_addr); 1834 1835 1835 1836 /* if gw_addr is local we will fail to detect this in case 1836 1837 * address is still TENTATIVE (DAD in progress). rt6_lookup() ··· 1839 1838 * prefix route was assigned to, which might be non-loopback. 1840 1839 */ 1841 1840 err = -EINVAL; 1842 - if (ipv6_chk_addr_and_flags(net, gw_addr, NULL, 0, 0)) 1841 + if (ipv6_chk_addr_and_flags(net, gw_addr, 1842 + gwa_type & IPV6_ADDR_LINKLOCAL ? 1843 + dev : NULL, 0, 0)) 1843 1844 goto out; 1844 1845 1845 1846 rt->rt6i_gateway = *gw_addr; 1846 - gwa_type = ipv6_addr_type(gw_addr); 1847 1847 1848 1848 if (gwa_type != (IPV6_ADDR_LINKLOCAL|IPV6_ADDR_UNICAST)) { 1849 1849 struct rt6_info *grt;
+1 -1
net/ipv6/tcp_ipv6.c
··· 943 943 &ipv6_hdr(skb)->daddr, tcp_v6_iif(skb)); 944 944 if (req) { 945 945 nsk = tcp_check_req(sk, skb, req, false); 946 - if (!nsk) 946 + if (!nsk || nsk == sk) 947 947 reqsk_put(req); 948 948 return nsk; 949 949 }
+3 -5
net/netfilter/nf_conntrack_core.c
··· 292 292 { 293 293 struct nf_conn *tmpl; 294 294 295 - tmpl = kzalloc(sizeof(struct nf_conn), GFP_KERNEL); 295 + tmpl = kzalloc(sizeof(*tmpl), flags); 296 296 if (tmpl == NULL) 297 297 return NULL; 298 298 ··· 303 303 if (zone) { 304 304 struct nf_conntrack_zone *nf_ct_zone; 305 305 306 - nf_ct_zone = nf_ct_ext_add(tmpl, NF_CT_EXT_ZONE, GFP_ATOMIC); 306 + nf_ct_zone = nf_ct_ext_add(tmpl, NF_CT_EXT_ZONE, flags); 307 307 if (!nf_ct_zone) 308 308 goto out_free; 309 309 nf_ct_zone->id = zone; ··· 1544 1544 sz = nr_slots * sizeof(struct hlist_nulls_head); 1545 1545 hash = (void *)__get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 1546 1546 get_order(sz)); 1547 - if (!hash) { 1548 - printk(KERN_WARNING "nf_conntrack: falling back to vmalloc.\n"); 1547 + if (!hash) 1549 1548 hash = vzalloc(sz); 1550 - } 1551 1549 1552 1550 if (hash && nulls) 1553 1551 for (i = 0; i < nr_slots; i++)
+1 -3
net/netfilter/nf_synproxy_core.c
··· 353 353 int err = -ENOMEM; 354 354 355 355 ct = nf_ct_tmpl_alloc(net, 0, GFP_KERNEL); 356 - if (IS_ERR(ct)) { 357 - err = PTR_ERR(ct); 356 + if (!ct) 358 357 goto err1; 359 - } 360 358 361 359 if (!nfct_seqadj_ext_add(ct)) 362 360 goto err2;
+3 -2
net/netfilter/xt_CT.c
··· 202 202 goto err1; 203 203 204 204 ct = nf_ct_tmpl_alloc(par->net, info->zone, GFP_KERNEL); 205 - ret = PTR_ERR(ct); 206 - if (IS_ERR(ct)) 205 + if (!ct) { 206 + ret = -ENOMEM; 207 207 goto err2; 208 + } 208 209 209 210 ret = 0; 210 211 if ((info->ct_events || info->exp_events) &&
+5
net/netlink/af_netlink.c
··· 1096 1096 1097 1097 err = __netlink_insert(table, sk); 1098 1098 if (err) { 1099 + /* In case the hashtable backend returns with -EBUSY 1100 + * from here, it must not escape to the caller. 1101 + */ 1102 + if (unlikely(err == -EBUSY)) 1103 + err = -EOVERFLOW; 1099 1104 if (err == -EEXIST) 1100 1105 err = -EADDRINUSE; 1101 1106 nlk_sk(sk)->portid = 0;
+12 -4
net/openvswitch/actions.c
··· 273 273 return 0; 274 274 } 275 275 276 - static void set_ip_addr(struct sk_buff *skb, struct iphdr *nh, 277 - __be32 *addr, __be32 new_addr) 276 + static void update_ip_l4_checksum(struct sk_buff *skb, struct iphdr *nh, 277 + __be32 addr, __be32 new_addr) 278 278 { 279 279 int transport_len = skb->len - skb_transport_offset(skb); 280 + 281 + if (nh->frag_off & htons(IP_OFFSET)) 282 + return; 280 283 281 284 if (nh->protocol == IPPROTO_TCP) { 282 285 if (likely(transport_len >= sizeof(struct tcphdr))) 283 286 inet_proto_csum_replace4(&tcp_hdr(skb)->check, skb, 284 - *addr, new_addr, 1); 287 + addr, new_addr, 1); 285 288 } else if (nh->protocol == IPPROTO_UDP) { 286 289 if (likely(transport_len >= sizeof(struct udphdr))) { 287 290 struct udphdr *uh = udp_hdr(skb); 288 291 289 292 if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) { 290 293 inet_proto_csum_replace4(&uh->check, skb, 291 - *addr, new_addr, 1); 294 + addr, new_addr, 1); 292 295 if (!uh->check) 293 296 uh->check = CSUM_MANGLED_0; 294 297 } 295 298 } 296 299 } 300 + } 297 301 302 + static void set_ip_addr(struct sk_buff *skb, struct iphdr *nh, 303 + __be32 *addr, __be32 new_addr) 304 + { 305 + update_ip_l4_checksum(skb, nh, *addr, new_addr); 298 306 csum_replace4(&nh->check, *addr, new_addr); 299 307 skb_clear_hash(skb); 300 308 *addr = new_addr;
+1 -1
net/rds/info.c
··· 176 176 177 177 /* check for all kinds of wrapping and the like */ 178 178 start = (unsigned long)optval; 179 - if (len < 0 || len + PAGE_SIZE - 1 < len || start + len < start) { 179 + if (len < 0 || len > INT_MAX - PAGE_SIZE + 1 || start + len < start) { 180 180 ret = -EINVAL; 181 181 goto out; 182 182 }
+2
net/sched/act_mirred.c
··· 98 98 return ret; 99 99 ret = ACT_P_CREATED; 100 100 } else { 101 + if (bind) 102 + return 0; 101 103 if (!ovr) { 102 104 tcf_hash_release(a, bind); 103 105 return -EEXIST;
+19 -3
net/sched/sch_fq_codel.c
··· 288 288 289 289 static void fq_codel_reset(struct Qdisc *sch) 290 290 { 291 - struct sk_buff *skb; 291 + struct fq_codel_sched_data *q = qdisc_priv(sch); 292 + int i; 292 293 293 - while ((skb = fq_codel_dequeue(sch)) != NULL) 294 - kfree_skb(skb); 294 + INIT_LIST_HEAD(&q->new_flows); 295 + INIT_LIST_HEAD(&q->old_flows); 296 + for (i = 0; i < q->flows_cnt; i++) { 297 + struct fq_codel_flow *flow = q->flows + i; 298 + 299 + while (flow->head) { 300 + struct sk_buff *skb = dequeue_head(flow); 301 + 302 + qdisc_qstats_backlog_dec(sch, skb); 303 + kfree_skb(skb); 304 + } 305 + 306 + INIT_LIST_HEAD(&flow->flowchain); 307 + codel_vars_init(&flow->cvars); 308 + } 309 + memset(q->backlogs, 0, q->flows_cnt * sizeof(u32)); 310 + sch->q.qlen = 0; 295 311 } 296 312 297 313 static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = {