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 S. Miller:

This has the fix for the wireless issues I ran into the other week as
well as:

1) Fix CAN c_can driver transmit handling resulting in BUG check
triggers, from AnilKumar Ch.

2) Fix packet drop monitor sleeping in atomic context, from Eric
Dumazet.

3) Fix mv643xx_eth driver build regression, from Andrew Lunn.

4) Inetpeer freeing needs an RCU grace period in order to avoid races
during tree invalidation. From Eric Dumazet.

5) Fix endianness bugs in xt_HMARK netfilter module, from Hans
Schillstrom.

6) Add proper module refcounting to l2tp_eth to avoid crash on module
unload, from Eric Dumazet.

7) Fix truncation of neighbour entry dumps due to logic errors in
neigh_dump_info() and friends, from Eric Dumazet.

8) The conversion of fib6_age() to dst_neigh_lookup() accidently
reversed the logic of a flags test, fix from Thomas Graf.

9) Fix checksum configuration in newer sky2 chips, from Stephen
Hemminger.

10) Revert BQL support in NIU driver, doesn't work.

11) l2tp_ip_sendmsg() illegally uses a route without a proper reference.
From Eric Dumazet.

12) be2net driver references an SKB after it's potentially been freed,
also from Eric Dumazet.

13) Fix RCU stalls in dummy net driver init. Also from Eric Dumazet.

14) lpc_eth has several bugs in it's transmit engine leading to packet
leaks and improper queue wakes, from Eric Dumazet.

15) Apply short DMA workaround to more tg3 chips, from Matt Carlson.

16) Add tilegx network driver.

17) Bonding queue mapping for a packet can get corrupted, fix from Eric
Dumazet.

18) Fix bug in netpoll_send_udp() SKB management that can leave garbage
in the payload in certain situations. From Eric Dumazet.

19) bnx2x driver interprets chip RX checksum offload incorrectly in
encapsulation situations. Fix from Eric Dumazet.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (75 commits)
bnx2x: fix checksum validation
netpoll: fix netpoll_send_udp() bugs
bonding: Fix corrupted queue_mapping
bonding:record primary when modify it via sysfs
tilegx network driver: initial support
tg3: Apply short DMA frag workaround to 5906
net: stmmac: Fix clock en-/disable calls
lpc_eth: fix tx completion
lpc_eth: add missing ndo_change_mtu()
dummy: fix rcu_sched self-detected stalls
net: Reorder initialization in ip_route_output to fix gcc warning
virtio-net: fix a race on 32bit arches
r8169: avoid NAPI scheduling delay.
net: Make linux/tcp.h C++ friendly (trivial)
netdev: fix drivers/net/phy/ kernel-doc warnings
net/core: fix kernel-doc warnings
be2net: fix a race in be_xmit()
l2tp: fix a race in l2tp_ip_sendmsg()
mac80211: add back channel change flag
NFC: Fix possible NULL ptr deref when getting the name of a socket
...

+2550 -389
+25 -19
Documentation/networking/stmmac.txt
··· 10 10 (i.e. 7xxx/5xxx SoCs), SPEAr (arm), Loongson1B (mips) and XLINX XC2V3000 11 11 FF1152AMT0221 D1215994A VIRTEX FPGA board. 12 12 13 - DWC Ether MAC 10/100/1000 Universal version 3.60a (and older) and DWC Ether MAC 10/100 14 - Universal version 4.0 have been used for developing this driver. 13 + DWC Ether MAC 10/100/1000 Universal version 3.60a (and older) and DWC Ether 14 + MAC 10/100 Universal version 4.0 have been used for developing this driver. 15 15 16 16 This driver supports both the platform bus and PCI. 17 17 ··· 54 54 When one or more packets are received, an interrupt happens. The interrupts 55 55 are not queued so the driver has to scan all the descriptors in the ring during 56 56 the receive process. 57 - This is based on NAPI so the interrupt handler signals only if there is work to be 58 - done, and it exits. 57 + This is based on NAPI so the interrupt handler signals only if there is work 58 + to be done, and it exits. 59 59 Then the poll method will be scheduled at some future point. 60 60 The incoming packets are stored, by the DMA, in a list of pre-allocated socket 61 61 buffers in order to avoid the memcpy (Zero-copy). 62 62 63 63 4.3) Timer-Driver Interrupt 64 - Instead of having the device that asynchronously notifies the frame receptions, the 65 - driver configures a timer to generate an interrupt at regular intervals. 66 - Based on the granularity of the timer, the frames that are received by the device 67 - will experience different levels of latency. Some NICs have dedicated timer 68 - device to perform this task. STMMAC can use either the RTC device or the TMU 69 - channel 2 on STLinux platforms. 64 + Instead of having the device that asynchronously notifies the frame receptions, 65 + the driver configures a timer to generate an interrupt at regular intervals. 66 + Based on the granularity of the timer, the frames that are received by the 67 + device will experience different levels of latency. Some NICs have dedicated 68 + timer device to perform this task. STMMAC can use either the RTC device or the 69 + TMU channel 2 on STLinux platforms. 70 70 The timers frequency can be passed to the driver as parameter; when change it, 71 71 take care of both hardware capability and network stability/performance impact. 72 - Several performance tests on STM platforms showed this optimisation allows to spare 73 - the CPU while having the maximum throughput. 72 + Several performance tests on STM platforms showed this optimisation allows to 73 + spare the CPU while having the maximum throughput. 74 74 75 75 4.4) WOL 76 - Wake up on Lan feature through Magic and Unicast frames are supported for the GMAC 77 - core. 76 + Wake up on Lan feature through Magic and Unicast frames are supported for the 77 + GMAC core. 78 78 79 79 4.5) DMA descriptors 80 80 Driver handles both normal and enhanced descriptors. The latter has been only ··· 106 106 These are included in the include/linux/stmmac.h header file 107 107 and detailed below as well: 108 108 109 - struct plat_stmmacenet_data { 109 + struct plat_stmmacenet_data { 110 + char *phy_bus_name; 110 111 int bus_id; 111 112 int phy_addr; 112 113 int interface; ··· 125 124 void (*bus_setup)(void __iomem *ioaddr); 126 125 int (*init)(struct platform_device *pdev); 127 126 void (*exit)(struct platform_device *pdev); 127 + void *custom_cfg; 128 + void *custom_data; 128 129 void *bsp_priv; 129 130 }; 130 131 131 132 Where: 133 + o phy_bus_name: phy bus name to attach to the stmmac. 132 134 o bus_id: bus identifier. 133 135 o phy_addr: the physical address can be passed from the platform. 134 136 If it is set to -1 the driver will automatically 135 137 detect it at run-time by probing all the 32 addresses. 136 138 o interface: PHY device's interface. 137 139 o mdio_bus_data: specific platform fields for the MDIO bus. 138 - o pbl: the Programmable Burst Length is maximum number of beats to 140 + o dma_cfg: internal DMA parameters 141 + o pbl: the Programmable Burst Length is maximum number of beats to 139 142 be transferred in one DMA transaction. 140 143 GMAC also enables the 4xPBL by default. 144 + o fixed_burst/mixed_burst/burst_len 141 145 o clk_csr: fixed CSR Clock range selection. 142 146 o has_gmac: uses the GMAC core. 143 147 o enh_desc: if sets the MAC will use the enhanced descriptor structure. ··· 166 160 this is sometime necessary on some platforms (e.g. ST boxes) 167 161 where the HW needs to have set some PIO lines or system cfg 168 162 registers. 169 - o custom_cfg: this is a custom configuration that can be passed while 170 - initialising the resources. 163 + o custom_cfg/custom_data: this is a custom configuration that can be passed 164 + while initialising the resources. 165 + o bsp_priv: another private poiter. 171 166 172 167 For MDIO bus The we have: 173 168 ··· 186 179 o phy_mask: phy mask passed when register the MDIO bus within the driver. 187 180 o irqs: list of IRQs, one per PHY. 188 181 o probed_phy_irq: if irqs is NULL, use this for probed PHY. 189 - 190 182 191 183 For DMA engine we have the following internal fields that should be 192 184 tuned according to the HW capabilities.
+10 -2
MAINTAINERS
··· 1800 1800 CFG80211 and NL80211 1801 1801 M: Johannes Berg <johannes@sipsolutions.net> 1802 1802 L: linux-wireless@vger.kernel.org 1803 + W: http://wireless.kernel.org/ 1804 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 1805 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 1803 1806 S: Maintained 1804 1807 F: include/linux/nl80211.h 1805 1808 F: include/net/cfg80211.h ··· 4352 4349 M: Johannes Berg <johannes@sipsolutions.net> 4353 4350 L: linux-wireless@vger.kernel.org 4354 4351 W: http://linuxwireless.org/ 4355 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless.git 4352 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 4353 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 4356 4354 S: Maintained 4357 4355 F: Documentation/networking/mac80211-injection.txt 4358 4356 F: include/net/mac80211.h ··· 4364 4360 M: Mattias Nissler <mattias.nissler@gmx.de> 4365 4361 L: linux-wireless@vger.kernel.org 4366 4362 W: http://linuxwireless.org/en/developers/Documentation/mac80211/RateControl/PID 4367 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless.git 4363 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 4364 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 4368 4365 S: Maintained 4369 4366 F: net/mac80211/rc80211_pid* 4370 4367 ··· 5716 5711 RFKILL 5717 5712 M: Johannes Berg <johannes@sipsolutions.net> 5718 5713 L: linux-wireless@vger.kernel.org 5714 + W: http://wireless.kernel.org/ 5715 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 5716 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git 5719 5717 S: Maintained 5720 5718 F: Documentation/rfkill.txt 5721 5719 F: net/rfkill/
+3 -1
drivers/bcma/driver_chipcommon_pmu.c
··· 139 139 bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x7); 140 140 break; 141 141 case 0x4331: 142 - /* BCM4331 workaround is SPROM-related, we put it in sprom.c */ 142 + case 43431: 143 + /* Ext PA lines must be enabled for tx on BCM4331 */ 144 + bcma_chipco_bcm4331_ext_pa_lines_ctl(cc, true); 143 145 break; 144 146 case 43224: 145 147 if (bus->chipinfo.rev == 0) {
+4 -2
drivers/bcma/driver_pci.c
··· 232 232 int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core, 233 233 bool enable) 234 234 { 235 - struct pci_dev *pdev = pc->core->bus->host_pci; 235 + struct pci_dev *pdev; 236 236 u32 coremask, tmp; 237 237 int err = 0; 238 238 239 - if (core->bus->hosttype != BCMA_HOSTTYPE_PCI) { 239 + if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI) { 240 240 /* This bcma device is not on a PCI host-bus. So the IRQs are 241 241 * not routed through the PCI core. 242 242 * So we must not enable routing through the PCI core. */ 243 243 goto out; 244 244 } 245 + 246 + pdev = pc->core->bus->host_pci; 245 247 246 248 err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp); 247 249 if (err)
+2 -2
drivers/bcma/sprom.c
··· 579 579 if (!sprom) 580 580 return -ENOMEM; 581 581 582 - if (bus->chipinfo.id == 0x4331) 582 + if (bus->chipinfo.id == 0x4331 || bus->chipinfo.id == 43431) 583 583 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false); 584 584 585 585 pr_debug("SPROM offset 0x%x\n", offset); 586 586 bcma_sprom_read(bus, offset, sprom); 587 587 588 - if (bus->chipinfo.id == 0x4331) 588 + if (bus->chipinfo.id == 0x4331 || bus->chipinfo.id == 43431) 589 589 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true); 590 590 591 591 err = bcma_sprom_valid(sprom);
+5 -4
drivers/net/bonding/bond_main.c
··· 76 76 #include <net/route.h> 77 77 #include <net/net_namespace.h> 78 78 #include <net/netns/generic.h> 79 + #include <net/pkt_sched.h> 79 80 #include "bonding.h" 80 81 #include "bond_3ad.h" 81 82 #include "bond_alb.h" ··· 382 381 return next; 383 382 } 384 383 385 - #define bond_queue_mapping(skb) (*(u16 *)((skb)->cb)) 386 - 387 384 /** 388 385 * bond_dev_queue_xmit - Prepare skb for xmit. 389 386 * ··· 394 395 { 395 396 skb->dev = slave_dev; 396 397 397 - skb->queue_mapping = bond_queue_mapping(skb); 398 + BUILD_BUG_ON(sizeof(skb->queue_mapping) != 399 + sizeof(qdisc_skb_cb(skb)->bond_queue_mapping)); 400 + skb->queue_mapping = qdisc_skb_cb(skb)->bond_queue_mapping; 398 401 399 402 if (unlikely(netpoll_tx_running(slave_dev))) 400 403 bond_netpoll_send_skb(bond_get_slave_by_dev(bond, slave_dev), skb); ··· 4172 4171 /* 4173 4172 * Save the original txq to restore before passing to the driver 4174 4173 */ 4175 - bond_queue_mapping(skb) = skb->queue_mapping; 4174 + qdisc_skb_cb(skb)->bond_queue_mapping = skb->queue_mapping; 4176 4175 4177 4176 if (unlikely(txq >= dev->real_num_tx_queues)) { 4178 4177 do {
+6 -2
drivers/net/bonding/bond_sysfs.c
··· 1082 1082 } 1083 1083 } 1084 1084 1085 - pr_info("%s: Unable to set %.*s as primary slave.\n", 1086 - bond->dev->name, (int)strlen(buf) - 1, buf); 1085 + strncpy(bond->params.primary, ifname, IFNAMSIZ); 1086 + bond->params.primary[IFNAMSIZ - 1] = 0; 1087 + 1088 + pr_info("%s: Recording %s as primary, " 1089 + "but it has not been enslaved to %s yet.\n", 1090 + bond->dev->name, ifname, bond->dev->name); 1087 1091 out: 1088 1092 write_unlock_bh(&bond->curr_slave_lock); 1089 1093 read_unlock(&bond->lock);
+9 -7
drivers/net/can/c_can/c_can.c
··· 686 686 * 687 687 * We iterate from priv->tx_echo to priv->tx_next and check if the 688 688 * packet has been transmitted, echo it back to the CAN framework. 689 - * If we discover a not yet transmitted package, stop looking for more. 689 + * If we discover a not yet transmitted packet, stop looking for more. 690 690 */ 691 691 static void c_can_do_tx(struct net_device *dev) 692 692 { ··· 698 698 for (/* nix */; (priv->tx_next - priv->tx_echo) > 0; priv->tx_echo++) { 699 699 msg_obj_no = get_tx_echo_msg_obj(priv); 700 700 val = c_can_read_reg32(priv, &priv->regs->txrqst1); 701 - if (!(val & (1 << msg_obj_no))) { 701 + if (!(val & (1 << (msg_obj_no - 1)))) { 702 702 can_get_echo_skb(dev, 703 703 msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST); 704 704 stats->tx_bytes += priv->read_reg(priv, ··· 706 706 & IF_MCONT_DLC_MASK; 707 707 stats->tx_packets++; 708 708 c_can_inval_msg_object(dev, 0, msg_obj_no); 709 + } else { 710 + break; 709 711 } 710 712 } 711 713 ··· 952 950 struct net_device *dev = napi->dev; 953 951 struct c_can_priv *priv = netdev_priv(dev); 954 952 955 - irqstatus = priv->read_reg(priv, &priv->regs->interrupt); 953 + irqstatus = priv->irqstatus; 956 954 if (!irqstatus) 957 955 goto end; 958 956 ··· 1030 1028 1031 1029 static irqreturn_t c_can_isr(int irq, void *dev_id) 1032 1030 { 1033 - u16 irqstatus; 1034 1031 struct net_device *dev = (struct net_device *)dev_id; 1035 1032 struct c_can_priv *priv = netdev_priv(dev); 1036 1033 1037 - irqstatus = priv->read_reg(priv, &priv->regs->interrupt); 1038 - if (!irqstatus) 1034 + priv->irqstatus = priv->read_reg(priv, &priv->regs->interrupt); 1035 + if (!priv->irqstatus) 1039 1036 return IRQ_NONE; 1040 1037 1041 1038 /* disable all interrupts and schedule the NAPI */ ··· 1064 1063 goto exit_irq_fail; 1065 1064 } 1066 1065 1066 + napi_enable(&priv->napi); 1067 + 1067 1068 /* start the c_can controller */ 1068 1069 c_can_start(dev); 1069 1070 1070 - napi_enable(&priv->napi); 1071 1071 netif_start_queue(dev); 1072 1072 1073 1073 return 0;
+1
drivers/net/can/c_can/c_can.h
··· 76 76 unsigned int tx_next; 77 77 unsigned int tx_echo; 78 78 void *priv; /* for board-specific data */ 79 + u16 irqstatus; 79 80 }; 80 81 81 82 struct net_device *alloc_c_can_dev(void);
+1 -1
drivers/net/can/cc770/cc770_platform.c
··· 154 154 struct cc770_platform_data *pdata = pdev->dev.platform_data; 155 155 156 156 priv->can.clock.freq = pdata->osc_freq; 157 - if (priv->cpu_interface | CPUIF_DSC) 157 + if (priv->cpu_interface & CPUIF_DSC) 158 158 priv->can.clock.freq /= 2; 159 159 priv->clkout = pdata->cor; 160 160 priv->bus_config = pdata->bcr;
+3 -1
drivers/net/dummy.c
··· 187 187 rtnl_lock(); 188 188 err = __rtnl_link_register(&dummy_link_ops); 189 189 190 - for (i = 0; i < numdummies && !err; i++) 190 + for (i = 0; i < numdummies && !err; i++) { 191 191 err = dummy_init_one(); 192 + cond_resched(); 193 + } 192 194 if (err < 0) 193 195 __rtnl_link_unregister(&dummy_link_ops); 194 196 rtnl_unlock();
-15
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
··· 747 747 748 748 #define ETH_RX_ERROR_FALGS ETH_FAST_PATH_RX_CQE_PHY_DECODE_ERR_FLG 749 749 750 - #define BNX2X_IP_CSUM_ERR(cqe) \ 751 - (!((cqe)->fast_path_cqe.status_flags & \ 752 - ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG) && \ 753 - ((cqe)->fast_path_cqe.type_error_flags & \ 754 - ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG)) 755 - 756 - #define BNX2X_L4_CSUM_ERR(cqe) \ 757 - (!((cqe)->fast_path_cqe.status_flags & \ 758 - ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG) && \ 759 - ((cqe)->fast_path_cqe.type_error_flags & \ 760 - ETH_FAST_PATH_RX_CQE_L4_BAD_XSUM_FLG)) 761 - 762 - #define BNX2X_RX_CSUM_OK(cqe) \ 763 - (!(BNX2X_L4_CSUM_ERR(cqe) || BNX2X_IP_CSUM_ERR(cqe))) 764 - 765 750 #define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \ 766 751 (((le16_to_cpu(flags) & \ 767 752 PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \
+21 -6
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
··· 617 617 return 0; 618 618 } 619 619 620 + static void bnx2x_csum_validate(struct sk_buff *skb, union eth_rx_cqe *cqe, 621 + struct bnx2x_fastpath *fp) 622 + { 623 + /* Do nothing if no IP/L4 csum validation was done */ 624 + 625 + if (cqe->fast_path_cqe.status_flags & 626 + (ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG | 627 + ETH_FAST_PATH_RX_CQE_L4_XSUM_NO_VALIDATION_FLG)) 628 + return; 629 + 630 + /* If both IP/L4 validation were done, check if an error was found. */ 631 + 632 + if (cqe->fast_path_cqe.type_error_flags & 633 + (ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG | 634 + ETH_FAST_PATH_RX_CQE_L4_BAD_XSUM_FLG)) 635 + fp->eth_q_stats.hw_csum_err++; 636 + else 637 + skb->ip_summed = CHECKSUM_UNNECESSARY; 638 + } 620 639 621 640 int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) 622 641 { ··· 825 806 826 807 skb_checksum_none_assert(skb); 827 808 828 - if (bp->dev->features & NETIF_F_RXCSUM) { 809 + if (bp->dev->features & NETIF_F_RXCSUM) 810 + bnx2x_csum_validate(skb, cqe, fp); 829 811 830 - if (likely(BNX2X_RX_CSUM_OK(cqe))) 831 - skb->ip_summed = CHECKSUM_UNNECESSARY; 832 - else 833 - fp->eth_q_stats.hw_csum_err++; 834 - } 835 812 836 813 skb_record_rx_queue(skb, fp->rx_queue); 837 814
+2 -1
drivers/net/ethernet/broadcom/tg3.c
··· 14275 14275 } 14276 14276 } 14277 14277 14278 - if (tg3_flag(tp, 5755_PLUS)) 14278 + if (tg3_flag(tp, 5755_PLUS) || 14279 + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) 14279 14280 tg3_flag_set(tp, SHORT_DMA_BUG); 14280 14281 14281 14282 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719)
+3 -2
drivers/net/ethernet/emulex/benet/be_main.c
··· 736 736 737 737 copied = make_tx_wrbs(adapter, txq, skb, wrb_cnt, dummy_wrb); 738 738 if (copied) { 739 + int gso_segs = skb_shinfo(skb)->gso_segs; 740 + 739 741 /* record the sent skb in the sent_skb table */ 740 742 BUG_ON(txo->sent_skb_list[start]); 741 743 txo->sent_skb_list[start] = skb; ··· 755 753 756 754 be_txq_notify(adapter, txq->id, wrb_cnt); 757 755 758 - be_tx_stats_update(txo, wrb_cnt, copied, 759 - skb_shinfo(skb)->gso_segs, stopped); 756 + be_tx_stats_update(txo, wrb_cnt, copied, gso_segs, stopped); 760 757 } else { 761 758 txq->head = start; 762 759 dev_kfree_skb_any(skb);
+4 -2
drivers/net/ethernet/intel/e1000e/ethtool.c
··· 258 258 * When SoL/IDER sessions are active, autoneg/speed/duplex 259 259 * cannot be changed 260 260 */ 261 - if (hw->phy.ops.check_reset_block(hw)) { 261 + if (hw->phy.ops.check_reset_block && 262 + hw->phy.ops.check_reset_block(hw)) { 262 263 e_err("Cannot change link characteristics when SoL/IDER is active.\n"); 263 264 return -EINVAL; 264 265 } ··· 1616 1615 * PHY loopback cannot be performed if SoL/IDER 1617 1616 * sessions are active 1618 1617 */ 1619 - if (hw->phy.ops.check_reset_block(hw)) { 1618 + if (hw->phy.ops.check_reset_block && 1619 + hw->phy.ops.check_reset_block(hw)) { 1620 1620 e_err("Cannot do PHY loopback test when SoL/IDER is active.\n"); 1621 1621 *data = 0; 1622 1622 goto out;
+1 -1
drivers/net/ethernet/intel/e1000e/mac.c
··· 709 709 * In the case of the phy reset being blocked, we already have a link. 710 710 * We do not need to set it up again. 711 711 */ 712 - if (hw->phy.ops.check_reset_block(hw)) 712 + if (hw->phy.ops.check_reset_block && hw->phy.ops.check_reset_block(hw)) 713 713 return 0; 714 714 715 715 /*
+2 -2
drivers/net/ethernet/intel/e1000e/netdev.c
··· 6237 6237 adapter->hw.phy.ms_type = e1000_ms_hw_default; 6238 6238 } 6239 6239 6240 - if (hw->phy.ops.check_reset_block(hw)) 6240 + if (hw->phy.ops.check_reset_block && hw->phy.ops.check_reset_block(hw)) 6241 6241 e_info("PHY reset is blocked due to SOL/IDER session.\n"); 6242 6242 6243 6243 /* Set initial default active device features */ ··· 6404 6404 if (!(adapter->flags & FLAG_HAS_AMT)) 6405 6405 e1000e_release_hw_control(adapter); 6406 6406 err_eeprom: 6407 - if (!hw->phy.ops.check_reset_block(hw)) 6407 + if (hw->phy.ops.check_reset_block && !hw->phy.ops.check_reset_block(hw)) 6408 6408 e1000_phy_hw_reset(&adapter->hw); 6409 6409 err_hw_init: 6410 6410 kfree(adapter->tx_ring);
+5 -3
drivers/net/ethernet/intel/e1000e/phy.c
··· 2155 2155 s32 ret_val; 2156 2156 u32 ctrl; 2157 2157 2158 - ret_val = phy->ops.check_reset_block(hw); 2159 - if (ret_val) 2160 - return 0; 2158 + if (phy->ops.check_reset_block) { 2159 + ret_val = phy->ops.check_reset_block(hw); 2160 + if (ret_val) 2161 + return 0; 2162 + } 2161 2163 2162 2164 ret_val = phy->ops.acquire(hw); 2163 2165 if (ret_val)
+10 -12
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 1390 1390 union ixgbe_adv_rx_desc *rx_desc, 1391 1391 struct sk_buff *skb) 1392 1392 { 1393 + struct net_device *dev = rx_ring->netdev; 1394 + 1393 1395 ixgbe_update_rsc_stats(rx_ring, skb); 1394 1396 1395 1397 ixgbe_rx_hash(rx_ring, rx_desc, skb); ··· 1403 1401 ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, skb); 1404 1402 #endif 1405 1403 1406 - if (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { 1404 + if ((dev->features & NETIF_F_HW_VLAN_RX) && 1405 + ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { 1407 1406 u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); 1408 1407 __vlan_hwaccel_put_tag(skb, vid); 1409 1408 } 1410 1409 1411 1410 skb_record_rx_queue(skb, rx_ring->queue_index); 1412 1411 1413 - skb->protocol = eth_type_trans(skb, rx_ring->netdev); 1412 + skb->protocol = eth_type_trans(skb, dev); 1414 1413 } 1415 1414 1416 1415 static void ixgbe_rx_skb(struct ixgbe_q_vector *q_vector, ··· 3609 3606 3610 3607 if (hw->mac.type == ixgbe_mac_82598EB) 3611 3608 netif_set_gso_max_size(adapter->netdev, 32768); 3612 - 3613 - 3614 - /* Enable VLAN tag insert/strip */ 3615 - adapter->netdev->features |= NETIF_F_HW_VLAN_RX; 3616 3609 3617 3610 hw->mac.ops.set_vfta(&adapter->hw, 0, 0, true); 3618 3611 ··· 6700 6701 { 6701 6702 struct ixgbe_adapter *adapter = netdev_priv(netdev); 6702 6703 6703 - #ifdef CONFIG_DCB 6704 - if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) 6705 - features &= ~NETIF_F_HW_VLAN_RX; 6706 - #endif 6707 - 6708 6704 /* return error if RXHASH is being enabled when RSS is not supported */ 6709 6705 if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED)) 6710 6706 features &= ~NETIF_F_RXHASH; ··· 6711 6717 /* Turn off LRO if not RSC capable */ 6712 6718 if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) 6713 6719 features &= ~NETIF_F_LRO; 6714 - 6715 6720 6716 6721 return features; 6717 6722 } ··· 6758 6765 adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE; 6759 6766 need_reset = true; 6760 6767 } 6768 + 6769 + if (features & NETIF_F_HW_VLAN_RX) 6770 + ixgbe_vlan_strip_enable(adapter); 6771 + else 6772 + ixgbe_vlan_strip_disable(adapter); 6761 6773 6762 6774 if (changed & NETIF_F_RXALL) 6763 6775 need_reset = true;
+10 -5
drivers/net/ethernet/marvell/mv643xx_eth.c
··· 436 436 /* 437 437 * Hardware-specific parameters. 438 438 */ 439 + #if defined(CONFIG_HAVE_CLK) 439 440 struct clk *clk; 441 + #endif 440 442 unsigned int t_clk; 441 443 }; 442 444 ··· 2897 2895 mp->dev = dev; 2898 2896 2899 2897 /* 2900 - * Get the clk rate, if there is one, otherwise use the default. 2898 + * Start with a default rate, and if there is a clock, allow 2899 + * it to override the default. 2901 2900 */ 2901 + mp->t_clk = 133000000; 2902 + #if defined(CONFIG_HAVE_CLK) 2902 2903 mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0")); 2903 2904 if (!IS_ERR(mp->clk)) { 2904 2905 clk_prepare_enable(mp->clk); 2905 2906 mp->t_clk = clk_get_rate(mp->clk); 2906 - } else { 2907 - mp->t_clk = 133000000; 2908 - printk(KERN_WARNING "Unable to get clock"); 2909 2907 } 2910 - 2908 + #endif 2911 2909 set_params(mp, pd); 2912 2910 netif_set_real_num_tx_queues(dev, mp->txq_count); 2913 2911 netif_set_real_num_rx_queues(dev, mp->rxq_count); ··· 2997 2995 phy_detach(mp->phy); 2998 2996 cancel_work_sync(&mp->tx_timeout_task); 2999 2997 2998 + #if defined(CONFIG_HAVE_CLK) 3000 2999 if (!IS_ERR(mp->clk)) { 3001 3000 clk_disable_unprepare(mp->clk); 3002 3001 clk_put(mp->clk); 3003 3002 } 3003 + #endif 3004 + 3004 3005 free_netdev(mp->dev); 3005 3006 3006 3007 platform_set_drvdata(pdev, NULL);
+6 -4
drivers/net/ethernet/marvell/sky2.c
··· 4381 4381 struct sky2_port *sky2 = netdev_priv(dev); 4382 4382 netdev_features_t changed = dev->features ^ features; 4383 4383 4384 - if (changed & NETIF_F_RXCSUM) { 4385 - bool on = features & NETIF_F_RXCSUM; 4386 - sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), 4387 - on ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); 4384 + if ((changed & NETIF_F_RXCSUM) && 4385 + !(sky2->hw->flags & SKY2_HW_NEW_LE)) { 4386 + sky2_write32(sky2->hw, 4387 + Q_ADDR(rxqaddr[sky2->port], Q_CSR), 4388 + (features & NETIF_F_RXCSUM) 4389 + ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); 4388 4390 } 4389 4391 4390 4392 if (changed & NETIF_F_RXHASH)
+6 -5
drivers/net/ethernet/nxp/lpc_eth.c
··· 946 946 /* Update stats */ 947 947 ndev->stats.tx_packets++; 948 948 ndev->stats.tx_bytes += skb->len; 949 - 950 - /* Free buffer */ 951 - dev_kfree_skb_irq(skb); 952 949 } 950 + dev_kfree_skb_irq(skb); 953 951 954 952 txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); 955 953 } 956 954 957 - if (netif_queue_stopped(ndev)) 958 - netif_wake_queue(ndev); 955 + if (pldat->num_used_tx_buffs <= ENET_TX_DESC/2) { 956 + if (netif_queue_stopped(ndev)) 957 + netif_wake_queue(ndev); 958 + } 959 959 } 960 960 961 961 static int __lpc_handle_recv(struct net_device *ndev, int budget) ··· 1320 1320 .ndo_set_rx_mode = lpc_eth_set_multicast_list, 1321 1321 .ndo_do_ioctl = lpc_eth_ioctl, 1322 1322 .ndo_set_mac_address = lpc_set_mac_address, 1323 + .ndo_change_mtu = eth_change_mtu, 1323 1324 }; 1324 1325 1325 1326 static int lpc_eth_drv_probe(struct platform_device *pdev)
+1 -5
drivers/net/ethernet/realtek/r8169.c
··· 5889 5889 if (status & LinkChg) 5890 5890 __rtl8169_check_link_status(dev, tp, tp->mmio_addr, true); 5891 5891 5892 - napi_disable(&tp->napi); 5893 - rtl_irq_disable(tp); 5894 - 5895 - napi_enable(&tp->napi); 5896 - napi_schedule(&tp->napi); 5892 + rtl_irq_enable_all(tp); 5897 5893 } 5898 5894 5899 5895 static void rtl_task(struct work_struct *work)
+2 -2
drivers/net/ethernet/stmicro/stmmac/Kconfig
··· 13 13 if STMMAC_ETH 14 14 15 15 config STMMAC_PLATFORM 16 - tristate "STMMAC platform bus support" 16 + bool "STMMAC Platform bus support" 17 17 depends on STMMAC_ETH 18 18 default y 19 19 ---help--- ··· 26 26 If unsure, say N. 27 27 28 28 config STMMAC_PCI 29 - tristate "STMMAC support on PCI bus (EXPERIMENTAL)" 29 + bool "STMMAC PCI bus support (EXPERIMENTAL)" 30 30 depends on STMMAC_ETH && PCI && EXPERIMENTAL 31 31 ---help--- 32 32 This is to select the Synopsys DWMAC available on PCI devices,
+60 -3
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 26 26 #include <linux/clk.h> 27 27 #include <linux/stmmac.h> 28 28 #include <linux/phy.h> 29 + #include <linux/pci.h> 29 30 #include "common.h" 30 31 #ifdef CONFIG_STMMAC_TIMER 31 32 #include "stmmac_timer.h" ··· 96 95 extern void stmmac_set_ethtool_ops(struct net_device *netdev); 97 96 extern const struct stmmac_desc_ops enh_desc_ops; 98 97 extern const struct stmmac_desc_ops ndesc_ops; 99 - 100 98 int stmmac_freeze(struct net_device *ndev); 101 99 int stmmac_restore(struct net_device *ndev); 102 100 int stmmac_resume(struct net_device *ndev); ··· 109 109 static inline int stmmac_clk_enable(struct stmmac_priv *priv) 110 110 { 111 111 if (!IS_ERR(priv->stmmac_clk)) 112 - return clk_enable(priv->stmmac_clk); 112 + return clk_prepare_enable(priv->stmmac_clk); 113 113 114 114 return 0; 115 115 } ··· 119 119 if (IS_ERR(priv->stmmac_clk)) 120 120 return; 121 121 122 - clk_disable(priv->stmmac_clk); 122 + clk_disable_unprepare(priv->stmmac_clk); 123 123 } 124 124 static inline int stmmac_clk_get(struct stmmac_priv *priv) 125 125 { ··· 143 143 return 0; 144 144 } 145 145 #endif /* CONFIG_HAVE_CLK */ 146 + 147 + 148 + #ifdef CONFIG_STMMAC_PLATFORM 149 + extern struct platform_driver stmmac_pltfr_driver; 150 + static inline int stmmac_register_platform(void) 151 + { 152 + int err; 153 + 154 + err = platform_driver_register(&stmmac_pltfr_driver); 155 + if (err) 156 + pr_err("stmmac: failed to register the platform driver\n"); 157 + 158 + return err; 159 + } 160 + static inline void stmmac_unregister_platform(void) 161 + { 162 + platform_driver_register(&stmmac_pltfr_driver); 163 + } 164 + #else 165 + static inline int stmmac_register_platform(void) 166 + { 167 + pr_debug("stmmac: do not register the platf driver\n"); 168 + 169 + return -EINVAL; 170 + } 171 + static inline void stmmac_unregister_platform(void) 172 + { 173 + } 174 + #endif /* CONFIG_STMMAC_PLATFORM */ 175 + 176 + #ifdef CONFIG_STMMAC_PCI 177 + extern struct pci_driver stmmac_pci_driver; 178 + static inline int stmmac_register_pci(void) 179 + { 180 + int err; 181 + 182 + err = pci_register_driver(&stmmac_pci_driver); 183 + if (err) 184 + pr_err("stmmac: failed to register the PCI driver\n"); 185 + 186 + return err; 187 + } 188 + static inline void stmmac_unregister_pci(void) 189 + { 190 + pci_unregister_driver(&stmmac_pci_driver); 191 + } 192 + #else 193 + static inline int stmmac_register_pci(void) 194 + { 195 + pr_debug("stmmac: do not register the PCI driver\n"); 196 + 197 + return -EINVAL; 198 + } 199 + static inline void stmmac_unregister_pci(void) 200 + { 201 + } 202 + #endif /* CONFIG_STMMAC_PCI */
+33 -2
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 833 833 834 834 /** 835 835 * stmmac_selec_desc_mode 836 - * @dev : device pointer 837 - * Description: select the Enhanced/Alternate or Normal descriptors */ 836 + * @priv : private structure 837 + * Description: select the Enhanced/Alternate or Normal descriptors 838 + */ 838 839 static void stmmac_selec_desc_mode(struct stmmac_priv *priv) 839 840 { 840 841 if (priv->plat->enh_desc) { ··· 1862 1861 /** 1863 1862 * stmmac_dvr_probe 1864 1863 * @device: device pointer 1864 + * @plat_dat: platform data pointer 1865 + * @addr: iobase memory address 1865 1866 * Description: this is the main probe function used to 1866 1867 * call the alloc_etherdev, allocate the priv structure. 1867 1868 */ ··· 2092 2089 return stmmac_open(ndev); 2093 2090 } 2094 2091 #endif /* CONFIG_PM */ 2092 + 2093 + /* Driver can be configured w/ and w/ both PCI and Platf drivers 2094 + * depending on the configuration selected. 2095 + */ 2096 + static int __init stmmac_init(void) 2097 + { 2098 + int err_plt = 0; 2099 + int err_pci = 0; 2100 + 2101 + err_plt = stmmac_register_platform(); 2102 + err_pci = stmmac_register_pci(); 2103 + 2104 + if ((err_pci) && (err_plt)) { 2105 + pr_err("stmmac: driver registration failed\n"); 2106 + return -EINVAL; 2107 + } 2108 + 2109 + return 0; 2110 + } 2111 + 2112 + static void __exit stmmac_exit(void) 2113 + { 2114 + stmmac_unregister_platform(); 2115 + stmmac_unregister_pci(); 2116 + } 2117 + 2118 + module_init(stmmac_init); 2119 + module_exit(stmmac_exit); 2095 2120 2096 2121 #ifndef MODULE 2097 2122 static int __init stmmac_cmdline_opt(char *str)
+1 -28
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
··· 179 179 180 180 MODULE_DEVICE_TABLE(pci, stmmac_id_table); 181 181 182 - static struct pci_driver stmmac_driver = { 182 + struct pci_driver stmmac_pci_driver = { 183 183 .name = STMMAC_RESOURCE_NAME, 184 184 .id_table = stmmac_id_table, 185 185 .probe = stmmac_pci_probe, ··· 189 189 .resume = stmmac_pci_resume, 190 190 #endif 191 191 }; 192 - 193 - /** 194 - * stmmac_init_module - Entry point for the driver 195 - * Description: This function is the entry point for the driver. 196 - */ 197 - static int __init stmmac_init_module(void) 198 - { 199 - int ret; 200 - 201 - ret = pci_register_driver(&stmmac_driver); 202 - if (ret < 0) 203 - pr_err("%s: ERROR: driver registration failed\n", __func__); 204 - 205 - return ret; 206 - } 207 - 208 - /** 209 - * stmmac_cleanup_module - Cleanup routine for the driver 210 - * Description: This function is the cleanup routine for the driver. 211 - */ 212 - static void __exit stmmac_cleanup_module(void) 213 - { 214 - pci_unregister_driver(&stmmac_driver); 215 - } 216 - 217 - module_init(stmmac_init_module); 218 - module_exit(stmmac_cleanup_module); 219 192 220 193 MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PCI driver"); 221 194 MODULE_AUTHOR("Rayagond Kokatanur <rayagond.kokatanur@vayavyalabs.com>");
+1 -3
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 255 255 }; 256 256 MODULE_DEVICE_TABLE(of, stmmac_dt_ids); 257 257 258 - static struct platform_driver stmmac_driver = { 258 + struct platform_driver stmmac_pltfr_driver = { 259 259 .probe = stmmac_pltfr_probe, 260 260 .remove = stmmac_pltfr_remove, 261 261 .driver = { ··· 265 265 .of_match_table = of_match_ptr(stmmac_dt_ids), 266 266 }, 267 267 }; 268 - 269 - module_platform_driver(stmmac_driver); 270 268 271 269 MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PLATFORM driver"); 272 270 MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
+1 -11
drivers/net/ethernet/sun/niu.c
··· 3598 3598 static void niu_tx_work(struct niu *np, struct tx_ring_info *rp) 3599 3599 { 3600 3600 struct netdev_queue *txq; 3601 - unsigned int tx_bytes; 3602 3601 u16 pkt_cnt, tmp; 3603 3602 int cons, index; 3604 3603 u64 cs; ··· 3620 3621 netif_printk(np, tx_done, KERN_DEBUG, np->dev, 3621 3622 "%s() pkt_cnt[%u] cons[%d]\n", __func__, pkt_cnt, cons); 3622 3623 3623 - tx_bytes = 0; 3624 - tmp = pkt_cnt; 3625 - while (tmp--) { 3626 - tx_bytes += rp->tx_buffs[cons].skb->len; 3624 + while (pkt_cnt--) 3627 3625 cons = release_tx_packet(np, rp, cons); 3628 - } 3629 3626 3630 3627 rp->cons = cons; 3631 3628 smp_mb(); 3632 - 3633 - netdev_tx_completed_queue(txq, pkt_cnt, tx_bytes); 3634 3629 3635 3630 out: 3636 3631 if (unlikely(netif_tx_queue_stopped(txq) && ··· 4326 4333 struct tx_ring_info *rp = &np->tx_rings[i]; 4327 4334 4328 4335 niu_free_tx_ring_info(np, rp); 4329 - netdev_tx_reset_queue(netdev_get_tx_queue(np->dev, i)); 4330 4336 } 4331 4337 kfree(np->tx_rings); 4332 4338 np->tx_rings = NULL; ··· 6730 6738 6731 6739 prod = NEXT_TX(rp, prod); 6732 6740 } 6733 - 6734 - netdev_tx_sent_queue(txq, skb->len); 6735 6741 6736 6742 if (prod < rp->prod) 6737 6743 rp->wrap_bit ^= TX_RING_KICK_WRAP;
+2
drivers/net/ethernet/tile/Kconfig
··· 7 7 depends on TILE 8 8 default y 9 9 select CRC32 10 + select TILE_GXIO_MPIPE if TILEGX 11 + select HIGH_RES_TIMERS if TILEGX 10 12 ---help--- 11 13 This is a standard Linux network device driver for the 12 14 on-chip Tilera Gigabit Ethernet and XAUI interfaces.
+2 -2
drivers/net/ethernet/tile/Makefile
··· 4 4 5 5 obj-$(CONFIG_TILE_NET) += tile_net.o 6 6 ifdef CONFIG_TILEGX 7 - tile_net-objs := tilegx.o mpipe.o iorpc_mpipe.o dma_queue.o 7 + tile_net-y := tilegx.o 8 8 else 9 - tile_net-objs := tilepro.o 9 + tile_net-y := tilepro.o 10 10 endif
+1898
drivers/net/ethernet/tile/tilegx.c
··· 1 + /* 2 + * Copyright 2012 Tilera Corporation. All Rights Reserved. 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License 6 + * as published by the Free Software Foundation, version 2. 7 + * 8 + * This program is distributed in the hope that it will be useful, but 9 + * WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 11 + * NON INFRINGEMENT. See the GNU General Public License for 12 + * more details. 13 + */ 14 + 15 + #include <linux/module.h> 16 + #include <linux/init.h> 17 + #include <linux/moduleparam.h> 18 + #include <linux/sched.h> 19 + #include <linux/kernel.h> /* printk() */ 20 + #include <linux/slab.h> /* kmalloc() */ 21 + #include <linux/errno.h> /* error codes */ 22 + #include <linux/types.h> /* size_t */ 23 + #include <linux/interrupt.h> 24 + #include <linux/in.h> 25 + #include <linux/irq.h> 26 + #include <linux/netdevice.h> /* struct device, and other headers */ 27 + #include <linux/etherdevice.h> /* eth_type_trans */ 28 + #include <linux/skbuff.h> 29 + #include <linux/ioctl.h> 30 + #include <linux/cdev.h> 31 + #include <linux/hugetlb.h> 32 + #include <linux/in6.h> 33 + #include <linux/timer.h> 34 + #include <linux/hrtimer.h> 35 + #include <linux/ktime.h> 36 + #include <linux/io.h> 37 + #include <linux/ctype.h> 38 + #include <linux/ip.h> 39 + #include <linux/tcp.h> 40 + 41 + #include <asm/checksum.h> 42 + #include <asm/homecache.h> 43 + #include <gxio/mpipe.h> 44 + #include <arch/sim.h> 45 + 46 + /* Default transmit lockup timeout period, in jiffies. */ 47 + #define TILE_NET_TIMEOUT (5 * HZ) 48 + 49 + /* The maximum number of distinct channels (idesc.channel is 5 bits). */ 50 + #define TILE_NET_CHANNELS 32 51 + 52 + /* Maximum number of idescs to handle per "poll". */ 53 + #define TILE_NET_BATCH 128 54 + 55 + /* Maximum number of packets to handle per "poll". */ 56 + #define TILE_NET_WEIGHT 64 57 + 58 + /* Number of entries in each iqueue. */ 59 + #define IQUEUE_ENTRIES 512 60 + 61 + /* Number of entries in each equeue. */ 62 + #define EQUEUE_ENTRIES 2048 63 + 64 + /* Total header bytes per equeue slot. Must be big enough for 2 bytes 65 + * of NET_IP_ALIGN alignment, plus 14 bytes (?) of L2 header, plus up to 66 + * 60 bytes of actual TCP header. We round up to align to cache lines. 67 + */ 68 + #define HEADER_BYTES 128 69 + 70 + /* Maximum completions per cpu per device (must be a power of two). 71 + * ISSUE: What is the right number here? If this is too small, then 72 + * egress might block waiting for free space in a completions array. 73 + * ISSUE: At the least, allocate these only for initialized echannels. 74 + */ 75 + #define TILE_NET_MAX_COMPS 64 76 + 77 + #define MAX_FRAGS (MAX_SKB_FRAGS + 1) 78 + 79 + /* Size of completions data to allocate. 80 + * ISSUE: Probably more than needed since we don't use all the channels. 81 + */ 82 + #define COMPS_SIZE (TILE_NET_CHANNELS * sizeof(struct tile_net_comps)) 83 + 84 + /* Size of NotifRing data to allocate. */ 85 + #define NOTIF_RING_SIZE (IQUEUE_ENTRIES * sizeof(gxio_mpipe_idesc_t)) 86 + 87 + /* Timeout to wake the per-device TX timer after we stop the queue. 88 + * We don't want the timeout too short (adds overhead, and might end 89 + * up causing stop/wake/stop/wake cycles) or too long (affects performance). 90 + * For the 10 Gb NIC, 30 usec means roughly 30+ 1500-byte packets. 91 + */ 92 + #define TX_TIMER_DELAY_USEC 30 93 + 94 + /* Timeout to wake the per-cpu egress timer to free completions. */ 95 + #define EGRESS_TIMER_DELAY_USEC 1000 96 + 97 + MODULE_AUTHOR("Tilera Corporation"); 98 + MODULE_LICENSE("GPL"); 99 + 100 + /* A "packet fragment" (a chunk of memory). */ 101 + struct frag { 102 + void *buf; 103 + size_t length; 104 + }; 105 + 106 + /* A single completion. */ 107 + struct tile_net_comp { 108 + /* The "complete_count" when the completion will be complete. */ 109 + s64 when; 110 + /* The buffer to be freed when the completion is complete. */ 111 + struct sk_buff *skb; 112 + }; 113 + 114 + /* The completions for a given cpu and echannel. */ 115 + struct tile_net_comps { 116 + /* The completions. */ 117 + struct tile_net_comp comp_queue[TILE_NET_MAX_COMPS]; 118 + /* The number of completions used. */ 119 + unsigned long comp_next; 120 + /* The number of completions freed. */ 121 + unsigned long comp_last; 122 + }; 123 + 124 + /* The transmit wake timer for a given cpu and echannel. */ 125 + struct tile_net_tx_wake { 126 + struct hrtimer timer; 127 + struct net_device *dev; 128 + }; 129 + 130 + /* Info for a specific cpu. */ 131 + struct tile_net_info { 132 + /* The NAPI struct. */ 133 + struct napi_struct napi; 134 + /* Packet queue. */ 135 + gxio_mpipe_iqueue_t iqueue; 136 + /* Our cpu. */ 137 + int my_cpu; 138 + /* True if iqueue is valid. */ 139 + bool has_iqueue; 140 + /* NAPI flags. */ 141 + bool napi_added; 142 + bool napi_enabled; 143 + /* Number of small sk_buffs which must still be provided. */ 144 + unsigned int num_needed_small_buffers; 145 + /* Number of large sk_buffs which must still be provided. */ 146 + unsigned int num_needed_large_buffers; 147 + /* A timer for handling egress completions. */ 148 + struct hrtimer egress_timer; 149 + /* True if "egress_timer" is scheduled. */ 150 + bool egress_timer_scheduled; 151 + /* Comps for each egress channel. */ 152 + struct tile_net_comps *comps_for_echannel[TILE_NET_CHANNELS]; 153 + /* Transmit wake timer for each egress channel. */ 154 + struct tile_net_tx_wake tx_wake[TILE_NET_CHANNELS]; 155 + }; 156 + 157 + /* Info for egress on a particular egress channel. */ 158 + struct tile_net_egress { 159 + /* The "equeue". */ 160 + gxio_mpipe_equeue_t *equeue; 161 + /* The headers for TSO. */ 162 + unsigned char *headers; 163 + }; 164 + 165 + /* Info for a specific device. */ 166 + struct tile_net_priv { 167 + /* Our network device. */ 168 + struct net_device *dev; 169 + /* The primary link. */ 170 + gxio_mpipe_link_t link; 171 + /* The primary channel, if open, else -1. */ 172 + int channel; 173 + /* The "loopify" egress link, if needed. */ 174 + gxio_mpipe_link_t loopify_link; 175 + /* The "loopify" egress channel, if open, else -1. */ 176 + int loopify_channel; 177 + /* The egress channel (channel or loopify_channel). */ 178 + int echannel; 179 + /* Total stats. */ 180 + struct net_device_stats stats; 181 + }; 182 + 183 + /* Egress info, indexed by "priv->echannel" (lazily created as needed). */ 184 + static struct tile_net_egress egress_for_echannel[TILE_NET_CHANNELS]; 185 + 186 + /* Devices currently associated with each channel. 187 + * NOTE: The array entry can become NULL after ifconfig down, but 188 + * we do not free the underlying net_device structures, so it is 189 + * safe to use a pointer after reading it from this array. 190 + */ 191 + static struct net_device *tile_net_devs_for_channel[TILE_NET_CHANNELS]; 192 + 193 + /* A mutex for "tile_net_devs_for_channel". */ 194 + static DEFINE_MUTEX(tile_net_devs_for_channel_mutex); 195 + 196 + /* The per-cpu info. */ 197 + static DEFINE_PER_CPU(struct tile_net_info, per_cpu_info); 198 + 199 + /* The "context" for all devices. */ 200 + static gxio_mpipe_context_t context; 201 + 202 + /* Buffer sizes and mpipe enum codes for buffer stacks. 203 + * See arch/tile/include/gxio/mpipe.h for the set of possible values. 204 + */ 205 + #define BUFFER_SIZE_SMALL_ENUM GXIO_MPIPE_BUFFER_SIZE_128 206 + #define BUFFER_SIZE_SMALL 128 207 + #define BUFFER_SIZE_LARGE_ENUM GXIO_MPIPE_BUFFER_SIZE_1664 208 + #define BUFFER_SIZE_LARGE 1664 209 + 210 + /* The small/large "buffer stacks". */ 211 + static int small_buffer_stack = -1; 212 + static int large_buffer_stack = -1; 213 + 214 + /* Amount of memory allocated for each buffer stack. */ 215 + static size_t buffer_stack_size; 216 + 217 + /* The actual memory allocated for the buffer stacks. */ 218 + static void *small_buffer_stack_va; 219 + static void *large_buffer_stack_va; 220 + 221 + /* The buckets. */ 222 + static int first_bucket = -1; 223 + static int num_buckets = 1; 224 + 225 + /* The ingress irq. */ 226 + static int ingress_irq = -1; 227 + 228 + /* Text value of tile_net.cpus if passed as a module parameter. */ 229 + static char *network_cpus_string; 230 + 231 + /* The actual cpus in "network_cpus". */ 232 + static struct cpumask network_cpus_map; 233 + 234 + /* If "loopify=LINK" was specified, this is "LINK". */ 235 + static char *loopify_link_name; 236 + 237 + /* If "tile_net.custom" was specified, this is non-NULL. */ 238 + static char *custom_str; 239 + 240 + /* The "tile_net.cpus" argument specifies the cpus that are dedicated 241 + * to handle ingress packets. 242 + * 243 + * The parameter should be in the form "tile_net.cpus=m-n[,x-y]", where 244 + * m, n, x, y are integer numbers that represent the cpus that can be 245 + * neither a dedicated cpu nor a dataplane cpu. 246 + */ 247 + static bool network_cpus_init(void) 248 + { 249 + char buf[1024]; 250 + int rc; 251 + 252 + if (network_cpus_string == NULL) 253 + return false; 254 + 255 + rc = cpulist_parse_crop(network_cpus_string, &network_cpus_map); 256 + if (rc != 0) { 257 + pr_warn("tile_net.cpus=%s: malformed cpu list\n", 258 + network_cpus_string); 259 + return false; 260 + } 261 + 262 + /* Remove dedicated cpus. */ 263 + cpumask_and(&network_cpus_map, &network_cpus_map, cpu_possible_mask); 264 + 265 + if (cpumask_empty(&network_cpus_map)) { 266 + pr_warn("Ignoring empty tile_net.cpus='%s'.\n", 267 + network_cpus_string); 268 + return false; 269 + } 270 + 271 + cpulist_scnprintf(buf, sizeof(buf), &network_cpus_map); 272 + pr_info("Linux network CPUs: %s\n", buf); 273 + return true; 274 + } 275 + 276 + module_param_named(cpus, network_cpus_string, charp, 0444); 277 + MODULE_PARM_DESC(cpus, "cpulist of cores that handle network interrupts"); 278 + 279 + /* The "tile_net.loopify=LINK" argument causes the named device to 280 + * actually use "loop0" for ingress, and "loop1" for egress. This 281 + * allows an app to sit between the actual link and linux, passing 282 + * (some) packets along to linux, and forwarding (some) packets sent 283 + * out by linux. 284 + */ 285 + module_param_named(loopify, loopify_link_name, charp, 0444); 286 + MODULE_PARM_DESC(loopify, "name the device to use loop0/1 for ingress/egress"); 287 + 288 + /* The "tile_net.custom" argument causes us to ignore the "conventional" 289 + * classifier metadata, in particular, the "l2_offset". 290 + */ 291 + module_param_named(custom, custom_str, charp, 0444); 292 + MODULE_PARM_DESC(custom, "indicates a (heavily) customized classifier"); 293 + 294 + /* Atomically update a statistics field. 295 + * Note that on TILE-Gx, this operation is fire-and-forget on the 296 + * issuing core (single-cycle dispatch) and takes only a few cycles 297 + * longer than a regular store when the request reaches the home cache. 298 + * No expensive bus management overhead is required. 299 + */ 300 + static void tile_net_stats_add(unsigned long value, unsigned long *field) 301 + { 302 + BUILD_BUG_ON(sizeof(atomic_long_t) != sizeof(unsigned long)); 303 + atomic_long_add(value, (atomic_long_t *)field); 304 + } 305 + 306 + /* Allocate and push a buffer. */ 307 + static bool tile_net_provide_buffer(bool small) 308 + { 309 + int stack = small ? small_buffer_stack : large_buffer_stack; 310 + const unsigned long buffer_alignment = 128; 311 + struct sk_buff *skb; 312 + int len; 313 + 314 + len = sizeof(struct sk_buff **) + buffer_alignment; 315 + len += (small ? BUFFER_SIZE_SMALL : BUFFER_SIZE_LARGE); 316 + skb = dev_alloc_skb(len); 317 + if (skb == NULL) 318 + return false; 319 + 320 + /* Make room for a back-pointer to 'skb' and guarantee alignment. */ 321 + skb_reserve(skb, sizeof(struct sk_buff **)); 322 + skb_reserve(skb, -(long)skb->data & (buffer_alignment - 1)); 323 + 324 + /* Save a back-pointer to 'skb'. */ 325 + *(struct sk_buff **)(skb->data - sizeof(struct sk_buff **)) = skb; 326 + 327 + /* Make sure "skb" and the back-pointer have been flushed. */ 328 + wmb(); 329 + 330 + gxio_mpipe_push_buffer(&context, stack, 331 + (void *)va_to_tile_io_addr(skb->data)); 332 + 333 + return true; 334 + } 335 + 336 + /* Convert a raw mpipe buffer to its matching skb pointer. */ 337 + static struct sk_buff *mpipe_buf_to_skb(void *va) 338 + { 339 + /* Acquire the associated "skb". */ 340 + struct sk_buff **skb_ptr = va - sizeof(*skb_ptr); 341 + struct sk_buff *skb = *skb_ptr; 342 + 343 + /* Paranoia. */ 344 + if (skb->data != va) { 345 + /* Panic here since there's a reasonable chance 346 + * that corrupt buffers means generic memory 347 + * corruption, with unpredictable system effects. 348 + */ 349 + panic("Corrupt linux buffer! va=%p, skb=%p, skb->data=%p", 350 + va, skb, skb->data); 351 + } 352 + 353 + return skb; 354 + } 355 + 356 + static void tile_net_pop_all_buffers(int stack) 357 + { 358 + for (;;) { 359 + tile_io_addr_t addr = 360 + (tile_io_addr_t)gxio_mpipe_pop_buffer(&context, stack); 361 + if (addr == 0) 362 + break; 363 + dev_kfree_skb_irq(mpipe_buf_to_skb(tile_io_addr_to_va(addr))); 364 + } 365 + } 366 + 367 + /* Provide linux buffers to mPIPE. */ 368 + static void tile_net_provide_needed_buffers(void) 369 + { 370 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 371 + 372 + while (info->num_needed_small_buffers != 0) { 373 + if (!tile_net_provide_buffer(true)) 374 + goto oops; 375 + info->num_needed_small_buffers--; 376 + } 377 + 378 + while (info->num_needed_large_buffers != 0) { 379 + if (!tile_net_provide_buffer(false)) 380 + goto oops; 381 + info->num_needed_large_buffers--; 382 + } 383 + 384 + return; 385 + 386 + oops: 387 + /* Add a description to the page allocation failure dump. */ 388 + pr_notice("Tile %d still needs some buffers\n", info->my_cpu); 389 + } 390 + 391 + static inline bool filter_packet(struct net_device *dev, void *buf) 392 + { 393 + /* Filter packets received before we're up. */ 394 + if (dev == NULL || !(dev->flags & IFF_UP)) 395 + return true; 396 + 397 + /* Filter out packets that aren't for us. */ 398 + if (!(dev->flags & IFF_PROMISC) && 399 + !is_multicast_ether_addr(buf) && 400 + compare_ether_addr(dev->dev_addr, buf) != 0) 401 + return true; 402 + 403 + return false; 404 + } 405 + 406 + static void tile_net_receive_skb(struct net_device *dev, struct sk_buff *skb, 407 + gxio_mpipe_idesc_t *idesc, unsigned long len) 408 + { 409 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 410 + struct tile_net_priv *priv = netdev_priv(dev); 411 + 412 + /* Encode the actual packet length. */ 413 + skb_put(skb, len); 414 + 415 + skb->protocol = eth_type_trans(skb, dev); 416 + 417 + /* Acknowledge "good" hardware checksums. */ 418 + if (idesc->cs && idesc->csum_seed_val == 0xFFFF) 419 + skb->ip_summed = CHECKSUM_UNNECESSARY; 420 + 421 + netif_receive_skb(skb); 422 + 423 + /* Update stats. */ 424 + tile_net_stats_add(1, &priv->stats.rx_packets); 425 + tile_net_stats_add(len, &priv->stats.rx_bytes); 426 + 427 + /* Need a new buffer. */ 428 + if (idesc->size == BUFFER_SIZE_SMALL_ENUM) 429 + info->num_needed_small_buffers++; 430 + else 431 + info->num_needed_large_buffers++; 432 + } 433 + 434 + /* Handle a packet. Return true if "processed", false if "filtered". */ 435 + static bool tile_net_handle_packet(gxio_mpipe_idesc_t *idesc) 436 + { 437 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 438 + struct net_device *dev = tile_net_devs_for_channel[idesc->channel]; 439 + uint8_t l2_offset; 440 + void *va; 441 + void *buf; 442 + unsigned long len; 443 + bool filter; 444 + 445 + /* Drop packets for which no buffer was available. 446 + * NOTE: This happens under heavy load. 447 + */ 448 + if (idesc->be) { 449 + struct tile_net_priv *priv = netdev_priv(dev); 450 + tile_net_stats_add(1, &priv->stats.rx_dropped); 451 + gxio_mpipe_iqueue_consume(&info->iqueue, idesc); 452 + if (net_ratelimit()) 453 + pr_info("Dropping packet (insufficient buffers).\n"); 454 + return false; 455 + } 456 + 457 + /* Get the "l2_offset", if allowed. */ 458 + l2_offset = custom_str ? 0 : gxio_mpipe_idesc_get_l2_offset(idesc); 459 + 460 + /* Get the raw buffer VA (includes "headroom"). */ 461 + va = tile_io_addr_to_va((unsigned long)(long)idesc->va); 462 + 463 + /* Get the actual packet start/length. */ 464 + buf = va + l2_offset; 465 + len = idesc->l2_size - l2_offset; 466 + 467 + /* Point "va" at the raw buffer. */ 468 + va -= NET_IP_ALIGN; 469 + 470 + filter = filter_packet(dev, buf); 471 + if (filter) { 472 + gxio_mpipe_iqueue_drop(&info->iqueue, idesc); 473 + } else { 474 + struct sk_buff *skb = mpipe_buf_to_skb(va); 475 + 476 + /* Skip headroom, and any custom header. */ 477 + skb_reserve(skb, NET_IP_ALIGN + l2_offset); 478 + 479 + tile_net_receive_skb(dev, skb, idesc, len); 480 + } 481 + 482 + gxio_mpipe_iqueue_consume(&info->iqueue, idesc); 483 + return !filter; 484 + } 485 + 486 + /* Handle some packets for the current CPU. 487 + * 488 + * This function handles up to TILE_NET_BATCH idescs per call. 489 + * 490 + * ISSUE: Since we do not provide new buffers until this function is 491 + * complete, we must initially provide enough buffers for each network 492 + * cpu to fill its iqueue and also its batched idescs. 493 + * 494 + * ISSUE: The "rotting packet" race condition occurs if a packet 495 + * arrives after the queue appears to be empty, and before the 496 + * hypervisor interrupt is re-enabled. 497 + */ 498 + static int tile_net_poll(struct napi_struct *napi, int budget) 499 + { 500 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 501 + unsigned int work = 0; 502 + gxio_mpipe_idesc_t *idesc; 503 + int i, n; 504 + 505 + /* Process packets. */ 506 + while ((n = gxio_mpipe_iqueue_try_peek(&info->iqueue, &idesc)) > 0) { 507 + for (i = 0; i < n; i++) { 508 + if (i == TILE_NET_BATCH) 509 + goto done; 510 + if (tile_net_handle_packet(idesc + i)) { 511 + if (++work >= budget) 512 + goto done; 513 + } 514 + } 515 + } 516 + 517 + /* There are no packets left. */ 518 + napi_complete(&info->napi); 519 + 520 + /* Re-enable hypervisor interrupts. */ 521 + gxio_mpipe_enable_notif_ring_interrupt(&context, info->iqueue.ring); 522 + 523 + /* HACK: Avoid the "rotting packet" problem. */ 524 + if (gxio_mpipe_iqueue_try_peek(&info->iqueue, &idesc) > 0) 525 + napi_schedule(&info->napi); 526 + 527 + /* ISSUE: Handle completions? */ 528 + 529 + done: 530 + tile_net_provide_needed_buffers(); 531 + 532 + return work; 533 + } 534 + 535 + /* Handle an ingress interrupt on the current cpu. */ 536 + static irqreturn_t tile_net_handle_ingress_irq(int irq, void *unused) 537 + { 538 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 539 + napi_schedule(&info->napi); 540 + return IRQ_HANDLED; 541 + } 542 + 543 + /* Free some completions. This must be called with interrupts blocked. */ 544 + static int tile_net_free_comps(gxio_mpipe_equeue_t *equeue, 545 + struct tile_net_comps *comps, 546 + int limit, bool force_update) 547 + { 548 + int n = 0; 549 + while (comps->comp_last < comps->comp_next) { 550 + unsigned int cid = comps->comp_last % TILE_NET_MAX_COMPS; 551 + struct tile_net_comp *comp = &comps->comp_queue[cid]; 552 + if (!gxio_mpipe_equeue_is_complete(equeue, comp->when, 553 + force_update || n == 0)) 554 + break; 555 + dev_kfree_skb_irq(comp->skb); 556 + comps->comp_last++; 557 + if (++n == limit) 558 + break; 559 + } 560 + return n; 561 + } 562 + 563 + /* Add a completion. This must be called with interrupts blocked. 564 + * tile_net_equeue_try_reserve() will have ensured a free completion entry. 565 + */ 566 + static void add_comp(gxio_mpipe_equeue_t *equeue, 567 + struct tile_net_comps *comps, 568 + uint64_t when, struct sk_buff *skb) 569 + { 570 + int cid = comps->comp_next % TILE_NET_MAX_COMPS; 571 + comps->comp_queue[cid].when = when; 572 + comps->comp_queue[cid].skb = skb; 573 + comps->comp_next++; 574 + } 575 + 576 + static void tile_net_schedule_tx_wake_timer(struct net_device *dev) 577 + { 578 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 579 + struct tile_net_priv *priv = netdev_priv(dev); 580 + 581 + hrtimer_start(&info->tx_wake[priv->echannel].timer, 582 + ktime_set(0, TX_TIMER_DELAY_USEC * 1000UL), 583 + HRTIMER_MODE_REL_PINNED); 584 + } 585 + 586 + static enum hrtimer_restart tile_net_handle_tx_wake_timer(struct hrtimer *t) 587 + { 588 + struct tile_net_tx_wake *tx_wake = 589 + container_of(t, struct tile_net_tx_wake, timer); 590 + netif_wake_subqueue(tx_wake->dev, smp_processor_id()); 591 + return HRTIMER_NORESTART; 592 + } 593 + 594 + /* Make sure the egress timer is scheduled. */ 595 + static void tile_net_schedule_egress_timer(void) 596 + { 597 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 598 + 599 + if (!info->egress_timer_scheduled) { 600 + hrtimer_start(&info->egress_timer, 601 + ktime_set(0, EGRESS_TIMER_DELAY_USEC * 1000UL), 602 + HRTIMER_MODE_REL_PINNED); 603 + info->egress_timer_scheduled = true; 604 + } 605 + } 606 + 607 + /* The "function" for "info->egress_timer". 608 + * 609 + * This timer will reschedule itself as long as there are any pending 610 + * completions expected for this tile. 611 + */ 612 + static enum hrtimer_restart tile_net_handle_egress_timer(struct hrtimer *t) 613 + { 614 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 615 + unsigned long irqflags; 616 + bool pending = false; 617 + int i; 618 + 619 + local_irq_save(irqflags); 620 + 621 + /* The timer is no longer scheduled. */ 622 + info->egress_timer_scheduled = false; 623 + 624 + /* Free all possible comps for this tile. */ 625 + for (i = 0; i < TILE_NET_CHANNELS; i++) { 626 + struct tile_net_egress *egress = &egress_for_echannel[i]; 627 + struct tile_net_comps *comps = info->comps_for_echannel[i]; 628 + if (comps->comp_last >= comps->comp_next) 629 + continue; 630 + tile_net_free_comps(egress->equeue, comps, -1, true); 631 + pending = pending || (comps->comp_last < comps->comp_next); 632 + } 633 + 634 + /* Reschedule timer if needed. */ 635 + if (pending) 636 + tile_net_schedule_egress_timer(); 637 + 638 + local_irq_restore(irqflags); 639 + 640 + return HRTIMER_NORESTART; 641 + } 642 + 643 + /* Helper function for "tile_net_update()". 644 + * "dev" (i.e. arg) is the device being brought up or down, 645 + * or NULL if all devices are now down. 646 + */ 647 + static void tile_net_update_cpu(void *arg) 648 + { 649 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 650 + struct net_device *dev = arg; 651 + 652 + if (!info->has_iqueue) 653 + return; 654 + 655 + if (dev != NULL) { 656 + if (!info->napi_added) { 657 + netif_napi_add(dev, &info->napi, 658 + tile_net_poll, TILE_NET_WEIGHT); 659 + info->napi_added = true; 660 + } 661 + if (!info->napi_enabled) { 662 + napi_enable(&info->napi); 663 + info->napi_enabled = true; 664 + } 665 + enable_percpu_irq(ingress_irq, 0); 666 + } else { 667 + disable_percpu_irq(ingress_irq); 668 + if (info->napi_enabled) { 669 + napi_disable(&info->napi); 670 + info->napi_enabled = false; 671 + } 672 + /* FIXME: Drain the iqueue. */ 673 + } 674 + } 675 + 676 + /* Helper function for tile_net_open() and tile_net_stop(). 677 + * Always called under tile_net_devs_for_channel_mutex. 678 + */ 679 + static int tile_net_update(struct net_device *dev) 680 + { 681 + static gxio_mpipe_rules_t rules; /* too big to fit on the stack */ 682 + bool saw_channel = false; 683 + int channel; 684 + int rc; 685 + int cpu; 686 + 687 + gxio_mpipe_rules_init(&rules, &context); 688 + 689 + for (channel = 0; channel < TILE_NET_CHANNELS; channel++) { 690 + if (tile_net_devs_for_channel[channel] == NULL) 691 + continue; 692 + if (!saw_channel) { 693 + saw_channel = true; 694 + gxio_mpipe_rules_begin(&rules, first_bucket, 695 + num_buckets, NULL); 696 + gxio_mpipe_rules_set_headroom(&rules, NET_IP_ALIGN); 697 + } 698 + gxio_mpipe_rules_add_channel(&rules, channel); 699 + } 700 + 701 + /* NOTE: This can fail if there is no classifier. 702 + * ISSUE: Can anything else cause it to fail? 703 + */ 704 + rc = gxio_mpipe_rules_commit(&rules); 705 + if (rc != 0) { 706 + netdev_warn(dev, "gxio_mpipe_rules_commit failed: %d\n", rc); 707 + return -EIO; 708 + } 709 + 710 + /* Update all cpus, sequentially (to protect "netif_napi_add()"). */ 711 + for_each_online_cpu(cpu) 712 + smp_call_function_single(cpu, tile_net_update_cpu, 713 + (saw_channel ? dev : NULL), 1); 714 + 715 + /* HACK: Allow packets to flow in the simulator. */ 716 + if (saw_channel) 717 + sim_enable_mpipe_links(0, -1); 718 + 719 + return 0; 720 + } 721 + 722 + /* Allocate and initialize mpipe buffer stacks, and register them in 723 + * the mPIPE TLBs, for both small and large packet sizes. 724 + * This routine supports tile_net_init_mpipe(), below. 725 + */ 726 + static int init_buffer_stacks(struct net_device *dev, int num_buffers) 727 + { 728 + pte_t hash_pte = pte_set_home((pte_t) { 0 }, PAGE_HOME_HASH); 729 + int rc; 730 + 731 + /* Compute stack bytes; we round up to 64KB and then use 732 + * alloc_pages() so we get the required 64KB alignment as well. 733 + */ 734 + buffer_stack_size = 735 + ALIGN(gxio_mpipe_calc_buffer_stack_bytes(num_buffers), 736 + 64 * 1024); 737 + 738 + /* Allocate two buffer stack indices. */ 739 + rc = gxio_mpipe_alloc_buffer_stacks(&context, 2, 0, 0); 740 + if (rc < 0) { 741 + netdev_err(dev, "gxio_mpipe_alloc_buffer_stacks failed: %d\n", 742 + rc); 743 + return rc; 744 + } 745 + small_buffer_stack = rc; 746 + large_buffer_stack = rc + 1; 747 + 748 + /* Allocate the small memory stack. */ 749 + small_buffer_stack_va = 750 + alloc_pages_exact(buffer_stack_size, GFP_KERNEL); 751 + if (small_buffer_stack_va == NULL) { 752 + netdev_err(dev, 753 + "Could not alloc %zd bytes for buffer stacks\n", 754 + buffer_stack_size); 755 + return -ENOMEM; 756 + } 757 + rc = gxio_mpipe_init_buffer_stack(&context, small_buffer_stack, 758 + BUFFER_SIZE_SMALL_ENUM, 759 + small_buffer_stack_va, 760 + buffer_stack_size, 0); 761 + if (rc != 0) { 762 + netdev_err(dev, "gxio_mpipe_init_buffer_stack: %d\n", rc); 763 + return rc; 764 + } 765 + rc = gxio_mpipe_register_client_memory(&context, small_buffer_stack, 766 + hash_pte, 0); 767 + if (rc != 0) { 768 + netdev_err(dev, 769 + "gxio_mpipe_register_buffer_memory failed: %d\n", 770 + rc); 771 + return rc; 772 + } 773 + 774 + /* Allocate the large buffer stack. */ 775 + large_buffer_stack_va = 776 + alloc_pages_exact(buffer_stack_size, GFP_KERNEL); 777 + if (large_buffer_stack_va == NULL) { 778 + netdev_err(dev, 779 + "Could not alloc %zd bytes for buffer stacks\n", 780 + buffer_stack_size); 781 + return -ENOMEM; 782 + } 783 + rc = gxio_mpipe_init_buffer_stack(&context, large_buffer_stack, 784 + BUFFER_SIZE_LARGE_ENUM, 785 + large_buffer_stack_va, 786 + buffer_stack_size, 0); 787 + if (rc != 0) { 788 + netdev_err(dev, "gxio_mpipe_init_buffer_stack failed: %d\n", 789 + rc); 790 + return rc; 791 + } 792 + rc = gxio_mpipe_register_client_memory(&context, large_buffer_stack, 793 + hash_pte, 0); 794 + if (rc != 0) { 795 + netdev_err(dev, 796 + "gxio_mpipe_register_buffer_memory failed: %d\n", 797 + rc); 798 + return rc; 799 + } 800 + 801 + return 0; 802 + } 803 + 804 + /* Allocate per-cpu resources (memory for completions and idescs). 805 + * This routine supports tile_net_init_mpipe(), below. 806 + */ 807 + static int alloc_percpu_mpipe_resources(struct net_device *dev, 808 + int cpu, int ring) 809 + { 810 + struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 811 + int order, i, rc; 812 + struct page *page; 813 + void *addr; 814 + 815 + /* Allocate the "comps". */ 816 + order = get_order(COMPS_SIZE); 817 + page = homecache_alloc_pages(GFP_KERNEL, order, cpu); 818 + if (page == NULL) { 819 + netdev_err(dev, "Failed to alloc %zd bytes comps memory\n", 820 + COMPS_SIZE); 821 + return -ENOMEM; 822 + } 823 + addr = pfn_to_kaddr(page_to_pfn(page)); 824 + memset(addr, 0, COMPS_SIZE); 825 + for (i = 0; i < TILE_NET_CHANNELS; i++) 826 + info->comps_for_echannel[i] = 827 + addr + i * sizeof(struct tile_net_comps); 828 + 829 + /* If this is a network cpu, create an iqueue. */ 830 + if (cpu_isset(cpu, network_cpus_map)) { 831 + order = get_order(NOTIF_RING_SIZE); 832 + page = homecache_alloc_pages(GFP_KERNEL, order, cpu); 833 + if (page == NULL) { 834 + netdev_err(dev, 835 + "Failed to alloc %zd bytes iqueue memory\n", 836 + NOTIF_RING_SIZE); 837 + return -ENOMEM; 838 + } 839 + addr = pfn_to_kaddr(page_to_pfn(page)); 840 + rc = gxio_mpipe_iqueue_init(&info->iqueue, &context, ring++, 841 + addr, NOTIF_RING_SIZE, 0); 842 + if (rc < 0) { 843 + netdev_err(dev, 844 + "gxio_mpipe_iqueue_init failed: %d\n", rc); 845 + return rc; 846 + } 847 + info->has_iqueue = true; 848 + } 849 + 850 + return ring; 851 + } 852 + 853 + /* Initialize NotifGroup and buckets. 854 + * This routine supports tile_net_init_mpipe(), below. 855 + */ 856 + static int init_notif_group_and_buckets(struct net_device *dev, 857 + int ring, int network_cpus_count) 858 + { 859 + int group, rc; 860 + 861 + /* Allocate one NotifGroup. */ 862 + rc = gxio_mpipe_alloc_notif_groups(&context, 1, 0, 0); 863 + if (rc < 0) { 864 + netdev_err(dev, "gxio_mpipe_alloc_notif_groups failed: %d\n", 865 + rc); 866 + return rc; 867 + } 868 + group = rc; 869 + 870 + /* Initialize global num_buckets value. */ 871 + if (network_cpus_count > 4) 872 + num_buckets = 256; 873 + else if (network_cpus_count > 1) 874 + num_buckets = 16; 875 + 876 + /* Allocate some buckets, and set global first_bucket value. */ 877 + rc = gxio_mpipe_alloc_buckets(&context, num_buckets, 0, 0); 878 + if (rc < 0) { 879 + netdev_err(dev, "gxio_mpipe_alloc_buckets failed: %d\n", rc); 880 + return rc; 881 + } 882 + first_bucket = rc; 883 + 884 + /* Init group and buckets. */ 885 + rc = gxio_mpipe_init_notif_group_and_buckets( 886 + &context, group, ring, network_cpus_count, 887 + first_bucket, num_buckets, 888 + GXIO_MPIPE_BUCKET_STICKY_FLOW_LOCALITY); 889 + if (rc != 0) { 890 + netdev_err( 891 + dev, 892 + "gxio_mpipe_init_notif_group_and_buckets failed: %d\n", 893 + rc); 894 + return rc; 895 + } 896 + 897 + return 0; 898 + } 899 + 900 + /* Create an irq and register it, then activate the irq and request 901 + * interrupts on all cores. Note that "ingress_irq" being initialized 902 + * is how we know not to call tile_net_init_mpipe() again. 903 + * This routine supports tile_net_init_mpipe(), below. 904 + */ 905 + static int tile_net_setup_interrupts(struct net_device *dev) 906 + { 907 + int cpu, rc; 908 + 909 + rc = create_irq(); 910 + if (rc < 0) { 911 + netdev_err(dev, "create_irq failed: %d\n", rc); 912 + return rc; 913 + } 914 + ingress_irq = rc; 915 + tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU); 916 + rc = request_irq(ingress_irq, tile_net_handle_ingress_irq, 917 + 0, NULL, NULL); 918 + if (rc != 0) { 919 + netdev_err(dev, "request_irq failed: %d\n", rc); 920 + destroy_irq(ingress_irq); 921 + ingress_irq = -1; 922 + return rc; 923 + } 924 + 925 + for_each_online_cpu(cpu) { 926 + struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 927 + if (info->has_iqueue) { 928 + gxio_mpipe_request_notif_ring_interrupt( 929 + &context, cpu_x(cpu), cpu_y(cpu), 930 + 1, ingress_irq, info->iqueue.ring); 931 + } 932 + } 933 + 934 + return 0; 935 + } 936 + 937 + /* Undo any state set up partially by a failed call to tile_net_init_mpipe. */ 938 + static void tile_net_init_mpipe_fail(void) 939 + { 940 + int cpu; 941 + 942 + /* Do cleanups that require the mpipe context first. */ 943 + if (small_buffer_stack >= 0) 944 + tile_net_pop_all_buffers(small_buffer_stack); 945 + if (large_buffer_stack >= 0) 946 + tile_net_pop_all_buffers(large_buffer_stack); 947 + 948 + /* Destroy mpipe context so the hardware no longer owns any memory. */ 949 + gxio_mpipe_destroy(&context); 950 + 951 + for_each_online_cpu(cpu) { 952 + struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 953 + free_pages((unsigned long)(info->comps_for_echannel[0]), 954 + get_order(COMPS_SIZE)); 955 + info->comps_for_echannel[0] = NULL; 956 + free_pages((unsigned long)(info->iqueue.idescs), 957 + get_order(NOTIF_RING_SIZE)); 958 + info->iqueue.idescs = NULL; 959 + } 960 + 961 + if (small_buffer_stack_va) 962 + free_pages_exact(small_buffer_stack_va, buffer_stack_size); 963 + if (large_buffer_stack_va) 964 + free_pages_exact(large_buffer_stack_va, buffer_stack_size); 965 + 966 + small_buffer_stack_va = NULL; 967 + large_buffer_stack_va = NULL; 968 + large_buffer_stack = -1; 969 + small_buffer_stack = -1; 970 + first_bucket = -1; 971 + } 972 + 973 + /* The first time any tilegx network device is opened, we initialize 974 + * the global mpipe state. If this step fails, we fail to open the 975 + * device, but if it succeeds, we never need to do it again, and since 976 + * tile_net can't be unloaded, we never undo it. 977 + * 978 + * Note that some resources in this path (buffer stack indices, 979 + * bindings from init_buffer_stack, etc.) are hypervisor resources 980 + * that are freed implicitly by gxio_mpipe_destroy(). 981 + */ 982 + static int tile_net_init_mpipe(struct net_device *dev) 983 + { 984 + int i, num_buffers, rc; 985 + int cpu; 986 + int first_ring, ring; 987 + int network_cpus_count = cpus_weight(network_cpus_map); 988 + 989 + if (!hash_default) { 990 + netdev_err(dev, "Networking requires hash_default!\n"); 991 + return -EIO; 992 + } 993 + 994 + rc = gxio_mpipe_init(&context, 0); 995 + if (rc != 0) { 996 + netdev_err(dev, "gxio_mpipe_init failed: %d\n", rc); 997 + return -EIO; 998 + } 999 + 1000 + /* Set up the buffer stacks. */ 1001 + num_buffers = 1002 + network_cpus_count * (IQUEUE_ENTRIES + TILE_NET_BATCH); 1003 + rc = init_buffer_stacks(dev, num_buffers); 1004 + if (rc != 0) 1005 + goto fail; 1006 + 1007 + /* Provide initial buffers. */ 1008 + rc = -ENOMEM; 1009 + for (i = 0; i < num_buffers; i++) { 1010 + if (!tile_net_provide_buffer(true)) { 1011 + netdev_err(dev, "Cannot allocate initial sk_bufs!\n"); 1012 + goto fail; 1013 + } 1014 + } 1015 + for (i = 0; i < num_buffers; i++) { 1016 + if (!tile_net_provide_buffer(false)) { 1017 + netdev_err(dev, "Cannot allocate initial sk_bufs!\n"); 1018 + goto fail; 1019 + } 1020 + } 1021 + 1022 + /* Allocate one NotifRing for each network cpu. */ 1023 + rc = gxio_mpipe_alloc_notif_rings(&context, network_cpus_count, 0, 0); 1024 + if (rc < 0) { 1025 + netdev_err(dev, "gxio_mpipe_alloc_notif_rings failed %d\n", 1026 + rc); 1027 + goto fail; 1028 + } 1029 + 1030 + /* Init NotifRings per-cpu. */ 1031 + first_ring = rc; 1032 + ring = first_ring; 1033 + for_each_online_cpu(cpu) { 1034 + rc = alloc_percpu_mpipe_resources(dev, cpu, ring); 1035 + if (rc < 0) 1036 + goto fail; 1037 + ring = rc; 1038 + } 1039 + 1040 + /* Initialize NotifGroup and buckets. */ 1041 + rc = init_notif_group_and_buckets(dev, first_ring, network_cpus_count); 1042 + if (rc != 0) 1043 + goto fail; 1044 + 1045 + /* Create and enable interrupts. */ 1046 + rc = tile_net_setup_interrupts(dev); 1047 + if (rc != 0) 1048 + goto fail; 1049 + 1050 + return 0; 1051 + 1052 + fail: 1053 + tile_net_init_mpipe_fail(); 1054 + return rc; 1055 + } 1056 + 1057 + /* Create persistent egress info for a given egress channel. 1058 + * Note that this may be shared between, say, "gbe0" and "xgbe0". 1059 + * ISSUE: Defer header allocation until TSO is actually needed? 1060 + */ 1061 + static int tile_net_init_egress(struct net_device *dev, int echannel) 1062 + { 1063 + struct page *headers_page, *edescs_page, *equeue_page; 1064 + gxio_mpipe_edesc_t *edescs; 1065 + gxio_mpipe_equeue_t *equeue; 1066 + unsigned char *headers; 1067 + int headers_order, edescs_order, equeue_order; 1068 + size_t edescs_size; 1069 + int edma; 1070 + int rc = -ENOMEM; 1071 + 1072 + /* Only initialize once. */ 1073 + if (egress_for_echannel[echannel].equeue != NULL) 1074 + return 0; 1075 + 1076 + /* Allocate memory for the "headers". */ 1077 + headers_order = get_order(EQUEUE_ENTRIES * HEADER_BYTES); 1078 + headers_page = alloc_pages(GFP_KERNEL, headers_order); 1079 + if (headers_page == NULL) { 1080 + netdev_warn(dev, 1081 + "Could not alloc %zd bytes for TSO headers.\n", 1082 + PAGE_SIZE << headers_order); 1083 + goto fail; 1084 + } 1085 + headers = pfn_to_kaddr(page_to_pfn(headers_page)); 1086 + 1087 + /* Allocate memory for the "edescs". */ 1088 + edescs_size = EQUEUE_ENTRIES * sizeof(*edescs); 1089 + edescs_order = get_order(edescs_size); 1090 + edescs_page = alloc_pages(GFP_KERNEL, edescs_order); 1091 + if (edescs_page == NULL) { 1092 + netdev_warn(dev, 1093 + "Could not alloc %zd bytes for eDMA ring.\n", 1094 + edescs_size); 1095 + goto fail_headers; 1096 + } 1097 + edescs = pfn_to_kaddr(page_to_pfn(edescs_page)); 1098 + 1099 + /* Allocate memory for the "equeue". */ 1100 + equeue_order = get_order(sizeof(*equeue)); 1101 + equeue_page = alloc_pages(GFP_KERNEL, equeue_order); 1102 + if (equeue_page == NULL) { 1103 + netdev_warn(dev, 1104 + "Could not alloc %zd bytes for equeue info.\n", 1105 + PAGE_SIZE << equeue_order); 1106 + goto fail_edescs; 1107 + } 1108 + equeue = pfn_to_kaddr(page_to_pfn(equeue_page)); 1109 + 1110 + /* Allocate an edma ring. Note that in practice this can't 1111 + * fail, which is good, because we will leak an edma ring if so. 1112 + */ 1113 + rc = gxio_mpipe_alloc_edma_rings(&context, 1, 0, 0); 1114 + if (rc < 0) { 1115 + netdev_warn(dev, "gxio_mpipe_alloc_edma_rings failed: %d\n", 1116 + rc); 1117 + goto fail_equeue; 1118 + } 1119 + edma = rc; 1120 + 1121 + /* Initialize the equeue. */ 1122 + rc = gxio_mpipe_equeue_init(equeue, &context, edma, echannel, 1123 + edescs, edescs_size, 0); 1124 + if (rc != 0) { 1125 + netdev_err(dev, "gxio_mpipe_equeue_init failed: %d\n", rc); 1126 + goto fail_equeue; 1127 + } 1128 + 1129 + /* Done. */ 1130 + egress_for_echannel[echannel].equeue = equeue; 1131 + egress_for_echannel[echannel].headers = headers; 1132 + return 0; 1133 + 1134 + fail_equeue: 1135 + __free_pages(equeue_page, equeue_order); 1136 + 1137 + fail_edescs: 1138 + __free_pages(edescs_page, edescs_order); 1139 + 1140 + fail_headers: 1141 + __free_pages(headers_page, headers_order); 1142 + 1143 + fail: 1144 + return rc; 1145 + } 1146 + 1147 + /* Return channel number for a newly-opened link. */ 1148 + static int tile_net_link_open(struct net_device *dev, gxio_mpipe_link_t *link, 1149 + const char *link_name) 1150 + { 1151 + int rc = gxio_mpipe_link_open(link, &context, link_name, 0); 1152 + if (rc < 0) { 1153 + netdev_err(dev, "Failed to open '%s'\n", link_name); 1154 + return rc; 1155 + } 1156 + rc = gxio_mpipe_link_channel(link); 1157 + if (rc < 0 || rc >= TILE_NET_CHANNELS) { 1158 + netdev_err(dev, "gxio_mpipe_link_channel bad value: %d\n", rc); 1159 + gxio_mpipe_link_close(link); 1160 + return -EINVAL; 1161 + } 1162 + return rc; 1163 + } 1164 + 1165 + /* Help the kernel activate the given network interface. */ 1166 + static int tile_net_open(struct net_device *dev) 1167 + { 1168 + struct tile_net_priv *priv = netdev_priv(dev); 1169 + int cpu, rc; 1170 + 1171 + mutex_lock(&tile_net_devs_for_channel_mutex); 1172 + 1173 + /* Do one-time initialization the first time any device is opened. */ 1174 + if (ingress_irq < 0) { 1175 + rc = tile_net_init_mpipe(dev); 1176 + if (rc != 0) 1177 + goto fail; 1178 + } 1179 + 1180 + /* Determine if this is the "loopify" device. */ 1181 + if (unlikely((loopify_link_name != NULL) && 1182 + !strcmp(dev->name, loopify_link_name))) { 1183 + rc = tile_net_link_open(dev, &priv->link, "loop0"); 1184 + if (rc < 0) 1185 + goto fail; 1186 + priv->channel = rc; 1187 + rc = tile_net_link_open(dev, &priv->loopify_link, "loop1"); 1188 + if (rc < 0) 1189 + goto fail; 1190 + priv->loopify_channel = rc; 1191 + priv->echannel = rc; 1192 + } else { 1193 + rc = tile_net_link_open(dev, &priv->link, dev->name); 1194 + if (rc < 0) 1195 + goto fail; 1196 + priv->channel = rc; 1197 + priv->echannel = rc; 1198 + } 1199 + 1200 + /* Initialize egress info (if needed). Once ever, per echannel. */ 1201 + rc = tile_net_init_egress(dev, priv->echannel); 1202 + if (rc != 0) 1203 + goto fail; 1204 + 1205 + tile_net_devs_for_channel[priv->channel] = dev; 1206 + 1207 + rc = tile_net_update(dev); 1208 + if (rc != 0) 1209 + goto fail; 1210 + 1211 + mutex_unlock(&tile_net_devs_for_channel_mutex); 1212 + 1213 + /* Initialize the transmit wake timer for this device for each cpu. */ 1214 + for_each_online_cpu(cpu) { 1215 + struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 1216 + struct tile_net_tx_wake *tx_wake = 1217 + &info->tx_wake[priv->echannel]; 1218 + 1219 + hrtimer_init(&tx_wake->timer, CLOCK_MONOTONIC, 1220 + HRTIMER_MODE_REL); 1221 + tx_wake->timer.function = tile_net_handle_tx_wake_timer; 1222 + tx_wake->dev = dev; 1223 + } 1224 + 1225 + for_each_online_cpu(cpu) 1226 + netif_start_subqueue(dev, cpu); 1227 + netif_carrier_on(dev); 1228 + return 0; 1229 + 1230 + fail: 1231 + if (priv->loopify_channel >= 0) { 1232 + if (gxio_mpipe_link_close(&priv->loopify_link) != 0) 1233 + netdev_warn(dev, "Failed to close loopify link!\n"); 1234 + priv->loopify_channel = -1; 1235 + } 1236 + if (priv->channel >= 0) { 1237 + if (gxio_mpipe_link_close(&priv->link) != 0) 1238 + netdev_warn(dev, "Failed to close link!\n"); 1239 + priv->channel = -1; 1240 + } 1241 + priv->echannel = -1; 1242 + tile_net_devs_for_channel[priv->channel] = NULL; 1243 + mutex_unlock(&tile_net_devs_for_channel_mutex); 1244 + 1245 + /* Don't return raw gxio error codes to generic Linux. */ 1246 + return (rc > -512) ? rc : -EIO; 1247 + } 1248 + 1249 + /* Help the kernel deactivate the given network interface. */ 1250 + static int tile_net_stop(struct net_device *dev) 1251 + { 1252 + struct tile_net_priv *priv = netdev_priv(dev); 1253 + int cpu; 1254 + 1255 + for_each_online_cpu(cpu) { 1256 + struct tile_net_info *info = &per_cpu(per_cpu_info, cpu); 1257 + struct tile_net_tx_wake *tx_wake = 1258 + &info->tx_wake[priv->echannel]; 1259 + 1260 + hrtimer_cancel(&tx_wake->timer); 1261 + netif_stop_subqueue(dev, cpu); 1262 + } 1263 + 1264 + mutex_lock(&tile_net_devs_for_channel_mutex); 1265 + tile_net_devs_for_channel[priv->channel] = NULL; 1266 + (void)tile_net_update(dev); 1267 + if (priv->loopify_channel >= 0) { 1268 + if (gxio_mpipe_link_close(&priv->loopify_link) != 0) 1269 + netdev_warn(dev, "Failed to close loopify link!\n"); 1270 + priv->loopify_channel = -1; 1271 + } 1272 + if (priv->channel >= 0) { 1273 + if (gxio_mpipe_link_close(&priv->link) != 0) 1274 + netdev_warn(dev, "Failed to close link!\n"); 1275 + priv->channel = -1; 1276 + } 1277 + priv->echannel = -1; 1278 + mutex_unlock(&tile_net_devs_for_channel_mutex); 1279 + 1280 + return 0; 1281 + } 1282 + 1283 + /* Determine the VA for a fragment. */ 1284 + static inline void *tile_net_frag_buf(skb_frag_t *f) 1285 + { 1286 + unsigned long pfn = page_to_pfn(skb_frag_page(f)); 1287 + return pfn_to_kaddr(pfn) + f->page_offset; 1288 + } 1289 + 1290 + /* Acquire a completion entry and an egress slot, or if we can't, 1291 + * stop the queue and schedule the tx_wake timer. 1292 + */ 1293 + static s64 tile_net_equeue_try_reserve(struct net_device *dev, 1294 + struct tile_net_comps *comps, 1295 + gxio_mpipe_equeue_t *equeue, 1296 + int num_edescs) 1297 + { 1298 + /* Try to acquire a completion entry. */ 1299 + if (comps->comp_next - comps->comp_last < TILE_NET_MAX_COMPS - 1 || 1300 + tile_net_free_comps(equeue, comps, 32, false) != 0) { 1301 + 1302 + /* Try to acquire an egress slot. */ 1303 + s64 slot = gxio_mpipe_equeue_try_reserve(equeue, num_edescs); 1304 + if (slot >= 0) 1305 + return slot; 1306 + 1307 + /* Freeing some completions gives the equeue time to drain. */ 1308 + tile_net_free_comps(equeue, comps, TILE_NET_MAX_COMPS, false); 1309 + 1310 + slot = gxio_mpipe_equeue_try_reserve(equeue, num_edescs); 1311 + if (slot >= 0) 1312 + return slot; 1313 + } 1314 + 1315 + /* Still nothing; give up and stop the queue for a short while. */ 1316 + netif_stop_subqueue(dev, smp_processor_id()); 1317 + tile_net_schedule_tx_wake_timer(dev); 1318 + return -1; 1319 + } 1320 + 1321 + /* Determine how many edesc's are needed for TSO. 1322 + * 1323 + * Sometimes, if "sendfile()" requires copying, we will be called with 1324 + * "data" containing the header and payload, with "frags" being empty. 1325 + * Sometimes, for example when using NFS over TCP, a single segment can 1326 + * span 3 fragments. This requires special care. 1327 + */ 1328 + static int tso_count_edescs(struct sk_buff *skb) 1329 + { 1330 + struct skb_shared_info *sh = skb_shinfo(skb); 1331 + unsigned int data_len = skb->data_len; 1332 + unsigned int p_len = sh->gso_size; 1333 + long f_id = -1; /* id of the current fragment */ 1334 + long f_size = -1; /* size of the current fragment */ 1335 + long f_used = -1; /* bytes used from the current fragment */ 1336 + long n; /* size of the current piece of payload */ 1337 + int num_edescs = 0; 1338 + int segment; 1339 + 1340 + for (segment = 0; segment < sh->gso_segs; segment++) { 1341 + 1342 + unsigned int p_used = 0; 1343 + 1344 + /* One edesc for header and for each piece of the payload. */ 1345 + for (num_edescs++; p_used < p_len; num_edescs++) { 1346 + 1347 + /* Advance as needed. */ 1348 + while (f_used >= f_size) { 1349 + f_id++; 1350 + f_size = sh->frags[f_id].size; 1351 + f_used = 0; 1352 + } 1353 + 1354 + /* Use bytes from the current fragment. */ 1355 + n = p_len - p_used; 1356 + if (n > f_size - f_used) 1357 + n = f_size - f_used; 1358 + f_used += n; 1359 + p_used += n; 1360 + } 1361 + 1362 + /* The last segment may be less than gso_size. */ 1363 + data_len -= p_len; 1364 + if (data_len < p_len) 1365 + p_len = data_len; 1366 + } 1367 + 1368 + return num_edescs; 1369 + } 1370 + 1371 + /* Prepare modified copies of the skbuff headers. 1372 + * FIXME: add support for IPv6. 1373 + */ 1374 + static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers, 1375 + s64 slot) 1376 + { 1377 + struct skb_shared_info *sh = skb_shinfo(skb); 1378 + struct iphdr *ih; 1379 + struct tcphdr *th; 1380 + unsigned int data_len = skb->data_len; 1381 + unsigned char *data = skb->data; 1382 + unsigned int ih_off, th_off, sh_len, p_len; 1383 + unsigned int isum_seed, tsum_seed, id, seq; 1384 + long f_id = -1; /* id of the current fragment */ 1385 + long f_size = -1; /* size of the current fragment */ 1386 + long f_used = -1; /* bytes used from the current fragment */ 1387 + long n; /* size of the current piece of payload */ 1388 + int segment; 1389 + 1390 + /* Locate original headers and compute various lengths. */ 1391 + ih = ip_hdr(skb); 1392 + th = tcp_hdr(skb); 1393 + ih_off = skb_network_offset(skb); 1394 + th_off = skb_transport_offset(skb); 1395 + sh_len = th_off + tcp_hdrlen(skb); 1396 + p_len = sh->gso_size; 1397 + 1398 + /* Set up seed values for IP and TCP csum and initialize id and seq. */ 1399 + isum_seed = ((0xFFFF - ih->check) + 1400 + (0xFFFF - ih->tot_len) + 1401 + (0xFFFF - ih->id)); 1402 + tsum_seed = th->check + (0xFFFF ^ htons(skb->len)); 1403 + id = ntohs(ih->id); 1404 + seq = ntohl(th->seq); 1405 + 1406 + /* Prepare all the headers. */ 1407 + for (segment = 0; segment < sh->gso_segs; segment++) { 1408 + unsigned char *buf; 1409 + unsigned int p_used = 0; 1410 + 1411 + /* Copy to the header memory for this segment. */ 1412 + buf = headers + (slot % EQUEUE_ENTRIES) * HEADER_BYTES + 1413 + NET_IP_ALIGN; 1414 + memcpy(buf, data, sh_len); 1415 + 1416 + /* Update copied ip header. */ 1417 + ih = (struct iphdr *)(buf + ih_off); 1418 + ih->tot_len = htons(sh_len + p_len - ih_off); 1419 + ih->id = htons(id); 1420 + ih->check = csum_long(isum_seed + ih->tot_len + 1421 + ih->id) ^ 0xffff; 1422 + 1423 + /* Update copied tcp header. */ 1424 + th = (struct tcphdr *)(buf + th_off); 1425 + th->seq = htonl(seq); 1426 + th->check = csum_long(tsum_seed + htons(sh_len + p_len)); 1427 + if (segment != sh->gso_segs - 1) { 1428 + th->fin = 0; 1429 + th->psh = 0; 1430 + } 1431 + 1432 + /* Skip past the header. */ 1433 + slot++; 1434 + 1435 + /* Skip past the payload. */ 1436 + while (p_used < p_len) { 1437 + 1438 + /* Advance as needed. */ 1439 + while (f_used >= f_size) { 1440 + f_id++; 1441 + f_size = sh->frags[f_id].size; 1442 + f_used = 0; 1443 + } 1444 + 1445 + /* Use bytes from the current fragment. */ 1446 + n = p_len - p_used; 1447 + if (n > f_size - f_used) 1448 + n = f_size - f_used; 1449 + f_used += n; 1450 + p_used += n; 1451 + 1452 + slot++; 1453 + } 1454 + 1455 + id++; 1456 + seq += p_len; 1457 + 1458 + /* The last segment may be less than gso_size. */ 1459 + data_len -= p_len; 1460 + if (data_len < p_len) 1461 + p_len = data_len; 1462 + } 1463 + 1464 + /* Flush the headers so they are ready for hardware DMA. */ 1465 + wmb(); 1466 + } 1467 + 1468 + /* Pass all the data to mpipe for egress. */ 1469 + static void tso_egress(struct net_device *dev, gxio_mpipe_equeue_t *equeue, 1470 + struct sk_buff *skb, unsigned char *headers, s64 slot) 1471 + { 1472 + struct tile_net_priv *priv = netdev_priv(dev); 1473 + struct skb_shared_info *sh = skb_shinfo(skb); 1474 + unsigned int data_len = skb->data_len; 1475 + unsigned int p_len = sh->gso_size; 1476 + gxio_mpipe_edesc_t edesc_head = { { 0 } }; 1477 + gxio_mpipe_edesc_t edesc_body = { { 0 } }; 1478 + long f_id = -1; /* id of the current fragment */ 1479 + long f_size = -1; /* size of the current fragment */ 1480 + long f_used = -1; /* bytes used from the current fragment */ 1481 + long n; /* size of the current piece of payload */ 1482 + unsigned long tx_packets = 0, tx_bytes = 0; 1483 + unsigned int csum_start, sh_len; 1484 + int segment; 1485 + 1486 + /* Prepare to egress the headers: set up header edesc. */ 1487 + csum_start = skb_checksum_start_offset(skb); 1488 + sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 1489 + edesc_head.csum = 1; 1490 + edesc_head.csum_start = csum_start; 1491 + edesc_head.csum_dest = csum_start + skb->csum_offset; 1492 + edesc_head.xfer_size = sh_len; 1493 + 1494 + /* This is only used to specify the TLB. */ 1495 + edesc_head.stack_idx = large_buffer_stack; 1496 + edesc_body.stack_idx = large_buffer_stack; 1497 + 1498 + /* Egress all the edescs. */ 1499 + for (segment = 0; segment < sh->gso_segs; segment++) { 1500 + void *va; 1501 + unsigned char *buf; 1502 + unsigned int p_used = 0; 1503 + 1504 + /* Egress the header. */ 1505 + buf = headers + (slot % EQUEUE_ENTRIES) * HEADER_BYTES + 1506 + NET_IP_ALIGN; 1507 + edesc_head.va = va_to_tile_io_addr(buf); 1508 + gxio_mpipe_equeue_put_at(equeue, edesc_head, slot); 1509 + slot++; 1510 + 1511 + /* Egress the payload. */ 1512 + while (p_used < p_len) { 1513 + 1514 + /* Advance as needed. */ 1515 + while (f_used >= f_size) { 1516 + f_id++; 1517 + f_size = sh->frags[f_id].size; 1518 + f_used = 0; 1519 + } 1520 + 1521 + va = tile_net_frag_buf(&sh->frags[f_id]) + f_used; 1522 + 1523 + /* Use bytes from the current fragment. */ 1524 + n = p_len - p_used; 1525 + if (n > f_size - f_used) 1526 + n = f_size - f_used; 1527 + f_used += n; 1528 + p_used += n; 1529 + 1530 + /* Egress a piece of the payload. */ 1531 + edesc_body.va = va_to_tile_io_addr(va); 1532 + edesc_body.xfer_size = n; 1533 + edesc_body.bound = !(p_used < p_len); 1534 + gxio_mpipe_equeue_put_at(equeue, edesc_body, slot); 1535 + slot++; 1536 + } 1537 + 1538 + tx_packets++; 1539 + tx_bytes += sh_len + p_len; 1540 + 1541 + /* The last segment may be less than gso_size. */ 1542 + data_len -= p_len; 1543 + if (data_len < p_len) 1544 + p_len = data_len; 1545 + } 1546 + 1547 + /* Update stats. */ 1548 + tile_net_stats_add(tx_packets, &priv->stats.tx_packets); 1549 + tile_net_stats_add(tx_bytes, &priv->stats.tx_bytes); 1550 + } 1551 + 1552 + /* Do "TSO" handling for egress. 1553 + * 1554 + * Normally drivers set NETIF_F_TSO only to support hardware TSO; 1555 + * otherwise the stack uses scatter-gather to implement GSO in software. 1556 + * On our testing, enabling GSO support (via NETIF_F_SG) drops network 1557 + * performance down to around 7.5 Gbps on the 10G interfaces, although 1558 + * also dropping cpu utilization way down, to under 8%. But 1559 + * implementing "TSO" in the driver brings performance back up to line 1560 + * rate, while dropping cpu usage even further, to less than 4%. In 1561 + * practice, profiling of GSO shows that skb_segment() is what causes 1562 + * the performance overheads; we benefit in the driver from using 1563 + * preallocated memory to duplicate the TCP/IP headers. 1564 + */ 1565 + static int tile_net_tx_tso(struct sk_buff *skb, struct net_device *dev) 1566 + { 1567 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 1568 + struct tile_net_priv *priv = netdev_priv(dev); 1569 + int channel = priv->echannel; 1570 + struct tile_net_egress *egress = &egress_for_echannel[channel]; 1571 + struct tile_net_comps *comps = info->comps_for_echannel[channel]; 1572 + gxio_mpipe_equeue_t *equeue = egress->equeue; 1573 + unsigned long irqflags; 1574 + int num_edescs; 1575 + s64 slot; 1576 + 1577 + /* Determine how many mpipe edesc's are needed. */ 1578 + num_edescs = tso_count_edescs(skb); 1579 + 1580 + local_irq_save(irqflags); 1581 + 1582 + /* Try to acquire a completion entry and an egress slot. */ 1583 + slot = tile_net_equeue_try_reserve(dev, comps, equeue, num_edescs); 1584 + if (slot < 0) { 1585 + local_irq_restore(irqflags); 1586 + return NETDEV_TX_BUSY; 1587 + } 1588 + 1589 + /* Set up copies of header data properly. */ 1590 + tso_headers_prepare(skb, egress->headers, slot); 1591 + 1592 + /* Actually pass the data to the network hardware. */ 1593 + tso_egress(dev, equeue, skb, egress->headers, slot); 1594 + 1595 + /* Add a completion record. */ 1596 + add_comp(equeue, comps, slot + num_edescs - 1, skb); 1597 + 1598 + local_irq_restore(irqflags); 1599 + 1600 + /* Make sure the egress timer is scheduled. */ 1601 + tile_net_schedule_egress_timer(); 1602 + 1603 + return NETDEV_TX_OK; 1604 + } 1605 + 1606 + /* Analyze the body and frags for a transmit request. */ 1607 + static unsigned int tile_net_tx_frags(struct frag *frags, 1608 + struct sk_buff *skb, 1609 + void *b_data, unsigned int b_len) 1610 + { 1611 + unsigned int i, n = 0; 1612 + 1613 + struct skb_shared_info *sh = skb_shinfo(skb); 1614 + 1615 + if (b_len != 0) { 1616 + frags[n].buf = b_data; 1617 + frags[n++].length = b_len; 1618 + } 1619 + 1620 + for (i = 0; i < sh->nr_frags; i++) { 1621 + skb_frag_t *f = &sh->frags[i]; 1622 + frags[n].buf = tile_net_frag_buf(f); 1623 + frags[n++].length = skb_frag_size(f); 1624 + } 1625 + 1626 + return n; 1627 + } 1628 + 1629 + /* Help the kernel transmit a packet. */ 1630 + static int tile_net_tx(struct sk_buff *skb, struct net_device *dev) 1631 + { 1632 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 1633 + struct tile_net_priv *priv = netdev_priv(dev); 1634 + struct tile_net_egress *egress = &egress_for_echannel[priv->echannel]; 1635 + gxio_mpipe_equeue_t *equeue = egress->equeue; 1636 + struct tile_net_comps *comps = 1637 + info->comps_for_echannel[priv->echannel]; 1638 + unsigned int len = skb->len; 1639 + unsigned char *data = skb->data; 1640 + unsigned int num_edescs; 1641 + struct frag frags[MAX_FRAGS]; 1642 + gxio_mpipe_edesc_t edescs[MAX_FRAGS]; 1643 + unsigned long irqflags; 1644 + gxio_mpipe_edesc_t edesc = { { 0 } }; 1645 + unsigned int i; 1646 + s64 slot; 1647 + 1648 + if (skb_is_gso(skb)) 1649 + return tile_net_tx_tso(skb, dev); 1650 + 1651 + num_edescs = tile_net_tx_frags(frags, skb, data, skb_headlen(skb)); 1652 + 1653 + /* This is only used to specify the TLB. */ 1654 + edesc.stack_idx = large_buffer_stack; 1655 + 1656 + /* Prepare the edescs. */ 1657 + for (i = 0; i < num_edescs; i++) { 1658 + edesc.xfer_size = frags[i].length; 1659 + edesc.va = va_to_tile_io_addr(frags[i].buf); 1660 + edescs[i] = edesc; 1661 + } 1662 + 1663 + /* Mark the final edesc. */ 1664 + edescs[num_edescs - 1].bound = 1; 1665 + 1666 + /* Add checksum info to the initial edesc, if needed. */ 1667 + if (skb->ip_summed == CHECKSUM_PARTIAL) { 1668 + unsigned int csum_start = skb_checksum_start_offset(skb); 1669 + edescs[0].csum = 1; 1670 + edescs[0].csum_start = csum_start; 1671 + edescs[0].csum_dest = csum_start + skb->csum_offset; 1672 + } 1673 + 1674 + local_irq_save(irqflags); 1675 + 1676 + /* Try to acquire a completion entry and an egress slot. */ 1677 + slot = tile_net_equeue_try_reserve(dev, comps, equeue, num_edescs); 1678 + if (slot < 0) { 1679 + local_irq_restore(irqflags); 1680 + return NETDEV_TX_BUSY; 1681 + } 1682 + 1683 + for (i = 0; i < num_edescs; i++) 1684 + gxio_mpipe_equeue_put_at(equeue, edescs[i], slot++); 1685 + 1686 + /* Add a completion record. */ 1687 + add_comp(equeue, comps, slot - 1, skb); 1688 + 1689 + /* NOTE: Use ETH_ZLEN for short packets (e.g. 42 < 60). */ 1690 + tile_net_stats_add(1, &priv->stats.tx_packets); 1691 + tile_net_stats_add(max_t(unsigned int, len, ETH_ZLEN), 1692 + &priv->stats.tx_bytes); 1693 + 1694 + local_irq_restore(irqflags); 1695 + 1696 + /* Make sure the egress timer is scheduled. */ 1697 + tile_net_schedule_egress_timer(); 1698 + 1699 + return NETDEV_TX_OK; 1700 + } 1701 + 1702 + /* Return subqueue id on this core (one per core). */ 1703 + static u16 tile_net_select_queue(struct net_device *dev, struct sk_buff *skb) 1704 + { 1705 + return smp_processor_id(); 1706 + } 1707 + 1708 + /* Deal with a transmit timeout. */ 1709 + static void tile_net_tx_timeout(struct net_device *dev) 1710 + { 1711 + int cpu; 1712 + 1713 + for_each_online_cpu(cpu) 1714 + netif_wake_subqueue(dev, cpu); 1715 + } 1716 + 1717 + /* Ioctl commands. */ 1718 + static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1719 + { 1720 + return -EOPNOTSUPP; 1721 + } 1722 + 1723 + /* Get system network statistics for device. */ 1724 + static struct net_device_stats *tile_net_get_stats(struct net_device *dev) 1725 + { 1726 + struct tile_net_priv *priv = netdev_priv(dev); 1727 + return &priv->stats; 1728 + } 1729 + 1730 + /* Change the MTU. */ 1731 + static int tile_net_change_mtu(struct net_device *dev, int new_mtu) 1732 + { 1733 + if ((new_mtu < 68) || (new_mtu > 1500)) 1734 + return -EINVAL; 1735 + dev->mtu = new_mtu; 1736 + return 0; 1737 + } 1738 + 1739 + /* Change the Ethernet address of the NIC. 1740 + * 1741 + * The hypervisor driver does not support changing MAC address. However, 1742 + * the hardware does not do anything with the MAC address, so the address 1743 + * which gets used on outgoing packets, and which is accepted on incoming 1744 + * packets, is completely up to us. 1745 + * 1746 + * Returns 0 on success, negative on failure. 1747 + */ 1748 + static int tile_net_set_mac_address(struct net_device *dev, void *p) 1749 + { 1750 + struct sockaddr *addr = p; 1751 + 1752 + if (!is_valid_ether_addr(addr->sa_data)) 1753 + return -EINVAL; 1754 + memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 1755 + return 0; 1756 + } 1757 + 1758 + #ifdef CONFIG_NET_POLL_CONTROLLER 1759 + /* Polling 'interrupt' - used by things like netconsole to send skbs 1760 + * without having to re-enable interrupts. It's not called while 1761 + * the interrupt routine is executing. 1762 + */ 1763 + static void tile_net_netpoll(struct net_device *dev) 1764 + { 1765 + disable_percpu_irq(ingress_irq); 1766 + tile_net_handle_ingress_irq(ingress_irq, NULL); 1767 + enable_percpu_irq(ingress_irq, 0); 1768 + } 1769 + #endif 1770 + 1771 + static const struct net_device_ops tile_net_ops = { 1772 + .ndo_open = tile_net_open, 1773 + .ndo_stop = tile_net_stop, 1774 + .ndo_start_xmit = tile_net_tx, 1775 + .ndo_select_queue = tile_net_select_queue, 1776 + .ndo_do_ioctl = tile_net_ioctl, 1777 + .ndo_get_stats = tile_net_get_stats, 1778 + .ndo_change_mtu = tile_net_change_mtu, 1779 + .ndo_tx_timeout = tile_net_tx_timeout, 1780 + .ndo_set_mac_address = tile_net_set_mac_address, 1781 + #ifdef CONFIG_NET_POLL_CONTROLLER 1782 + .ndo_poll_controller = tile_net_netpoll, 1783 + #endif 1784 + }; 1785 + 1786 + /* The setup function. 1787 + * 1788 + * This uses ether_setup() to assign various fields in dev, including 1789 + * setting IFF_BROADCAST and IFF_MULTICAST, then sets some extra fields. 1790 + */ 1791 + static void tile_net_setup(struct net_device *dev) 1792 + { 1793 + ether_setup(dev); 1794 + dev->netdev_ops = &tile_net_ops; 1795 + dev->watchdog_timeo = TILE_NET_TIMEOUT; 1796 + dev->features |= NETIF_F_LLTX; 1797 + dev->features |= NETIF_F_HW_CSUM; 1798 + dev->features |= NETIF_F_SG; 1799 + dev->features |= NETIF_F_TSO; 1800 + dev->mtu = 1500; 1801 + } 1802 + 1803 + /* Allocate the device structure, register the device, and obtain the 1804 + * MAC address from the hypervisor. 1805 + */ 1806 + static void tile_net_dev_init(const char *name, const uint8_t *mac) 1807 + { 1808 + int ret; 1809 + int i; 1810 + int nz_addr = 0; 1811 + struct net_device *dev; 1812 + struct tile_net_priv *priv; 1813 + 1814 + /* HACK: Ignore "loop" links. */ 1815 + if (strncmp(name, "loop", 4) == 0) 1816 + return; 1817 + 1818 + /* Allocate the device structure. Normally, "name" is a 1819 + * template, instantiated by register_netdev(), but not for us. 1820 + */ 1821 + dev = alloc_netdev_mqs(sizeof(*priv), name, tile_net_setup, 1822 + NR_CPUS, 1); 1823 + if (!dev) { 1824 + pr_err("alloc_netdev_mqs(%s) failed\n", name); 1825 + return; 1826 + } 1827 + 1828 + /* Initialize "priv". */ 1829 + priv = netdev_priv(dev); 1830 + memset(priv, 0, sizeof(*priv)); 1831 + priv->dev = dev; 1832 + priv->channel = -1; 1833 + priv->loopify_channel = -1; 1834 + priv->echannel = -1; 1835 + 1836 + /* Get the MAC address and set it in the device struct; this must 1837 + * be done before the device is opened. If the MAC is all zeroes, 1838 + * we use a random address, since we're probably on the simulator. 1839 + */ 1840 + for (i = 0; i < 6; i++) 1841 + nz_addr |= mac[i]; 1842 + 1843 + if (nz_addr) { 1844 + memcpy(dev->dev_addr, mac, 6); 1845 + dev->addr_len = 6; 1846 + } else { 1847 + random_ether_addr(dev->dev_addr); 1848 + } 1849 + 1850 + /* Register the network device. */ 1851 + ret = register_netdev(dev); 1852 + if (ret) { 1853 + netdev_err(dev, "register_netdev failed %d\n", ret); 1854 + free_netdev(dev); 1855 + return; 1856 + } 1857 + } 1858 + 1859 + /* Per-cpu module initialization. */ 1860 + static void tile_net_init_module_percpu(void *unused) 1861 + { 1862 + struct tile_net_info *info = &__get_cpu_var(per_cpu_info); 1863 + int my_cpu = smp_processor_id(); 1864 + 1865 + info->has_iqueue = false; 1866 + 1867 + info->my_cpu = my_cpu; 1868 + 1869 + /* Initialize the egress timer. */ 1870 + hrtimer_init(&info->egress_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 1871 + info->egress_timer.function = tile_net_handle_egress_timer; 1872 + } 1873 + 1874 + /* Module initialization. */ 1875 + static int __init tile_net_init_module(void) 1876 + { 1877 + int i; 1878 + char name[GXIO_MPIPE_LINK_NAME_LEN]; 1879 + uint8_t mac[6]; 1880 + 1881 + pr_info("Tilera Network Driver\n"); 1882 + 1883 + mutex_init(&tile_net_devs_for_channel_mutex); 1884 + 1885 + /* Initialize each CPU. */ 1886 + on_each_cpu(tile_net_init_module_percpu, NULL, 1); 1887 + 1888 + /* Find out what devices we have, and initialize them. */ 1889 + for (i = 0; gxio_mpipe_link_enumerate_mac(i, name, mac) >= 0; i++) 1890 + tile_net_dev_init(name, mac); 1891 + 1892 + if (!network_cpus_init()) 1893 + network_cpus_map = *cpu_online_mask; 1894 + 1895 + return 0; 1896 + } 1897 + 1898 + module_init(tile_net_init_module);
+1
drivers/net/hyperv/hyperv_net.h
··· 478 478 u32 nvsp_version; 479 479 480 480 atomic_t num_outstanding_sends; 481 + wait_queue_head_t wait_drain; 481 482 bool start_remove; 482 483 bool destroy; 483 484 /*
+6 -6
drivers/net/hyperv/netvsc.c
··· 42 42 if (!net_device) 43 43 return NULL; 44 44 45 + init_waitqueue_head(&net_device->wait_drain); 45 46 net_device->start_remove = false; 46 47 net_device->destroy = false; 47 48 net_device->dev = device; ··· 388 387 spin_unlock_irqrestore(&device->channel->inbound_lock, flags); 389 388 390 389 /* Wait for all send completions */ 391 - while (atomic_read(&net_device->num_outstanding_sends)) { 392 - dev_info(&device->device, 393 - "waiting for %d requests to complete...\n", 394 - atomic_read(&net_device->num_outstanding_sends)); 395 - udelay(100); 396 - } 390 + wait_event(net_device->wait_drain, 391 + atomic_read(&net_device->num_outstanding_sends) == 0); 397 392 398 393 netvsc_disconnect_vsp(net_device); 399 394 ··· 482 485 483 486 num_outstanding_sends = 484 487 atomic_dec_return(&net_device->num_outstanding_sends); 488 + 489 + if (net_device->destroy && num_outstanding_sends == 0) 490 + wake_up(&net_device->wait_drain); 485 491 486 492 if (netif_queue_stopped(ndev) && !net_device->start_remove && 487 493 (hv_ringbuf_avail_percent(&device->channel->outbound)
+7
drivers/net/phy/icplus.c
··· 41 41 #define IP1001_APS_ON 11 /* IP1001 APS Mode bit */ 42 42 #define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */ 43 43 #define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */ 44 + #define IP101A_G_IRQ_PIN_USED (1<<15) /* INTR pin used */ 45 + #define IP101A_G_IRQ_DEFAULT IP101A_G_IRQ_PIN_USED 44 46 45 47 static int ip175c_config_init(struct phy_device *phydev) 46 48 { ··· 135 133 return c; 136 134 c |= IP1001_APS_ON; 137 135 c = phy_write(phydev, IP1001_SPEC_CTRL_STATUS_2, c); 136 + if (c < 0) 137 + return c; 138 + 139 + /* INTR pin used: speed/link/duplex will cause an interrupt */ 140 + c = phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, IP101A_G_IRQ_DEFAULT); 138 141 if (c < 0) 139 142 return c; 140 143
+1 -1
drivers/net/phy/mdio_bus.c
··· 96 96 } 97 97 /** 98 98 * of_mdio_find_bus - Given an mii_bus node, find the mii_bus. 99 - * @mdio_np: Pointer to the mii_bus. 99 + * @mdio_bus_np: Pointer to the mii_bus. 100 100 * 101 101 * Returns a pointer to the mii_bus, or NULL if none found. 102 102 *
+10 -4
drivers/net/usb/sierra_net.c
··· 946 946 } 947 947 948 948 static const u8 sierra_net_ifnum_list[] = { 7, 10, 11 }; 949 - static const struct sierra_net_info_data sierra_net_info_data_68A3 = { 949 + static const struct sierra_net_info_data sierra_net_info_data_direct_ip = { 950 950 .rx_urb_size = 8 * 1024, 951 951 .whitelist = { 952 952 .infolen = ARRAY_SIZE(sierra_net_ifnum_list), ··· 954 954 } 955 955 }; 956 956 957 - static const struct driver_info sierra_net_info_68A3 = { 957 + static const struct driver_info sierra_net_info_direct_ip = { 958 958 .description = "Sierra Wireless USB-to-WWAN Modem", 959 959 .flags = FLAG_WWAN | FLAG_SEND_ZLP, 960 960 .bind = sierra_net_bind, ··· 962 962 .status = sierra_net_status, 963 963 .rx_fixup = sierra_net_rx_fixup, 964 964 .tx_fixup = sierra_net_tx_fixup, 965 - .data = (unsigned long)&sierra_net_info_data_68A3, 965 + .data = (unsigned long)&sierra_net_info_data_direct_ip, 966 966 }; 967 967 968 968 static const struct usb_device_id products[] = { 969 969 {USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless USB-to-WWAN modem */ 970 - .driver_info = (unsigned long) &sierra_net_info_68A3}, 970 + .driver_info = (unsigned long) &sierra_net_info_direct_ip}, 971 + {USB_DEVICE(0x0F3D, 0x68A3), /* AT&T Direct IP modem */ 972 + .driver_info = (unsigned long) &sierra_net_info_direct_ip}, 973 + {USB_DEVICE(0x1199, 0x68AA), /* Sierra Wireless Direct IP LTE modem */ 974 + .driver_info = (unsigned long) &sierra_net_info_direct_ip}, 975 + {USB_DEVICE(0x0F3D, 0x68AA), /* AT&T Direct IP LTE modem */ 976 + .driver_info = (unsigned long) &sierra_net_info_direct_ip}, 971 977 972 978 {}, /* last item */ 973 979 };
+12 -7
drivers/net/virtio_net.c
··· 42 42 #define VIRTNET_DRIVER_VERSION "1.0.0" 43 43 44 44 struct virtnet_stats { 45 - struct u64_stats_sync syncp; 45 + struct u64_stats_sync tx_syncp; 46 + struct u64_stats_sync rx_syncp; 46 47 u64 tx_bytes; 47 48 u64 tx_packets; 48 49 ··· 301 300 302 301 hdr = skb_vnet_hdr(skb); 303 302 304 - u64_stats_update_begin(&stats->syncp); 303 + u64_stats_update_begin(&stats->rx_syncp); 305 304 stats->rx_bytes += skb->len; 306 305 stats->rx_packets++; 307 - u64_stats_update_end(&stats->syncp); 306 + u64_stats_update_end(&stats->rx_syncp); 308 307 309 308 if (hdr->hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { 310 309 pr_debug("Needs csum!\n"); ··· 566 565 while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) { 567 566 pr_debug("Sent skb %p\n", skb); 568 567 569 - u64_stats_update_begin(&stats->syncp); 568 + u64_stats_update_begin(&stats->tx_syncp); 570 569 stats->tx_bytes += skb->len; 571 570 stats->tx_packets++; 572 - u64_stats_update_end(&stats->syncp); 571 + u64_stats_update_end(&stats->tx_syncp); 573 572 574 573 tot_sgs += skb_vnet_hdr(skb)->num_sg; 575 574 dev_kfree_skb_any(skb); ··· 704 703 u64 tpackets, tbytes, rpackets, rbytes; 705 704 706 705 do { 707 - start = u64_stats_fetch_begin(&stats->syncp); 706 + start = u64_stats_fetch_begin(&stats->tx_syncp); 708 707 tpackets = stats->tx_packets; 709 708 tbytes = stats->tx_bytes; 709 + } while (u64_stats_fetch_retry(&stats->tx_syncp, start)); 710 + 711 + do { 712 + start = u64_stats_fetch_begin(&stats->rx_syncp); 710 713 rpackets = stats->rx_packets; 711 714 rbytes = stats->rx_bytes; 712 - } while (u64_stats_fetch_retry(&stats->syncp, start)); 715 + } while (u64_stats_fetch_retry(&stats->rx_syncp, start)); 713 716 714 717 tot->rx_packets += rpackets; 715 718 tot->tx_packets += tpackets;
+4
drivers/net/wireless/b43/b43.h
··· 877 877 * from the mac80211 subsystem. */ 878 878 u16 mac80211_initially_registered_queues; 879 879 880 + /* Set this if we call ieee80211_register_hw() and check if we call 881 + * ieee80211_unregister_hw(). */ 882 + bool hw_registred; 883 + 880 884 /* We can only have one operating interface (802.11 core) 881 885 * at a time. General information about this interface follows. 882 886 */
+12 -7
drivers/net/wireless/b43/main.c
··· 2437 2437 err = ieee80211_register_hw(wl->hw); 2438 2438 if (err) 2439 2439 goto err_one_core_detach; 2440 + wl->hw_registred = true; 2440 2441 b43_leds_register(wl->current_dev); 2441 2442 goto out; 2442 2443 ··· 5300 5299 5301 5300 hw->queues = modparam_qos ? B43_QOS_QUEUE_NUM : 1; 5302 5301 wl->mac80211_initially_registered_queues = hw->queues; 5302 + wl->hw_registred = false; 5303 5303 hw->max_rates = 2; 5304 5304 SET_IEEE80211_DEV(hw, dev->dev); 5305 5305 if (is_valid_ether_addr(sprom->et1mac)) ··· 5372 5370 * as the ieee80211 unreg will destroy the workqueue. */ 5373 5371 cancel_work_sync(&wldev->restart_work); 5374 5372 5375 - /* Restore the queues count before unregistering, because firmware detect 5376 - * might have modified it. Restoring is important, so the networking 5377 - * stack can properly free resources. */ 5378 - wl->hw->queues = wl->mac80211_initially_registered_queues; 5379 - b43_leds_stop(wldev); 5380 - ieee80211_unregister_hw(wl->hw); 5373 + B43_WARN_ON(!wl); 5374 + if (wl->current_dev == wldev && wl->hw_registred) { 5375 + /* Restore the queues count before unregistering, because firmware detect 5376 + * might have modified it. Restoring is important, so the networking 5377 + * stack can properly free resources. */ 5378 + wl->hw->queues = wl->mac80211_initially_registered_queues; 5379 + b43_leds_stop(wldev); 5380 + ieee80211_unregister_hw(wl->hw); 5381 + } 5381 5382 5382 5383 b43_one_core_detach(wldev->dev); 5383 5384 ··· 5451 5446 cancel_work_sync(&wldev->restart_work); 5452 5447 5453 5448 B43_WARN_ON(!wl); 5454 - if (wl->current_dev == wldev) { 5449 + if (wl->current_dev == wldev && wl->hw_registred) { 5455 5450 /* Restore the queues count before unregistering, because firmware detect 5456 5451 * might have modified it. Restoring is important, so the networking 5457 5452 * stack can properly free resources. */
+2 -2
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
··· 89 89 data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1; 90 90 brcmf_sdio_regwb(sdiodev, SDIO_CCCR_IENx, data, &ret); 91 91 92 - /* redirect, configure ane enable io for interrupt signal */ 92 + /* redirect, configure and enable io for interrupt signal */ 93 93 data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE; 94 - if (sdiodev->irq_flags | IRQF_TRIGGER_HIGH) 94 + if (sdiodev->irq_flags & IRQF_TRIGGER_HIGH) 95 95 data |= SDIO_SEPINT_ACT_HI; 96 96 brcmf_sdio_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, &ret); 97 97
+5 -15
drivers/net/wireless/ipw2x00/ipw2100.c
··· 1903 1903 netif_stop_queue(priv->net_dev); 1904 1904 } 1905 1905 1906 - /* Called by register_netdev() */ 1907 - static int ipw2100_net_init(struct net_device *dev) 1908 - { 1909 - struct ipw2100_priv *priv = libipw_priv(dev); 1910 - 1911 - return ipw2100_up(priv, 1); 1912 - } 1913 - 1914 1906 static int ipw2100_wdev_init(struct net_device *dev) 1915 1907 { 1916 1908 struct ipw2100_priv *priv = libipw_priv(dev); ··· 6079 6087 .ndo_stop = ipw2100_close, 6080 6088 .ndo_start_xmit = libipw_xmit, 6081 6089 .ndo_change_mtu = libipw_change_mtu, 6082 - .ndo_init = ipw2100_net_init, 6083 6090 .ndo_tx_timeout = ipw2100_tx_timeout, 6084 6091 .ndo_set_mac_address = ipw2100_set_address, 6085 6092 .ndo_validate_addr = eth_validate_addr, ··· 6320 6329 printk(KERN_INFO DRV_NAME 6321 6330 ": Detected Intel PRO/Wireless 2100 Network Connection\n"); 6322 6331 6332 + err = ipw2100_up(priv, 1); 6333 + if (err) 6334 + goto fail; 6335 + 6323 6336 err = ipw2100_wdev_init(dev); 6324 6337 if (err) 6325 6338 goto fail; ··· 6333 6338 * network device we would call ipw2100_up. This introduced a race 6334 6339 * condition with newer hotplug configurations (network was coming 6335 6340 * up and making calls before the device was initialized). 6336 - * 6337 - * If we called ipw2100_up before we registered the device, then the 6338 - * device name wasn't registered. So, we instead use the net_dev->init 6339 - * member to call a function that then just turns and calls ipw2100_up. 6340 - * net_dev->init is called after name allocation but before the 6341 - * notifier chain is called */ 6341 + */ 6342 6342 err = register_netdev(dev); 6343 6343 if (err) { 6344 6344 printk(KERN_WARNING DRV_NAME
+21 -2
drivers/net/wireless/iwlwifi/iwl-6000.c
··· 35 35 #define IWL6000_UCODE_API_MAX 6 36 36 #define IWL6050_UCODE_API_MAX 5 37 37 #define IWL6000G2_UCODE_API_MAX 6 38 + #define IWL6035_UCODE_API_MAX 6 38 39 39 40 /* Oldest version we won't warn about */ 40 41 #define IWL6000_UCODE_API_OK 4 41 42 #define IWL6000G2_UCODE_API_OK 5 42 43 #define IWL6050_UCODE_API_OK 5 43 44 #define IWL6000G2B_UCODE_API_OK 6 45 + #define IWL6035_UCODE_API_OK 6 44 46 45 47 /* Lowest firmware API version supported */ 46 48 #define IWL6000_UCODE_API_MIN 4 47 49 #define IWL6050_UCODE_API_MIN 4 48 - #define IWL6000G2_UCODE_API_MIN 4 50 + #define IWL6000G2_UCODE_API_MIN 5 51 + #define IWL6035_UCODE_API_MIN 6 49 52 50 53 /* EEPROM versions */ 51 54 #define EEPROM_6000_TX_POWER_VERSION (4) ··· 230 227 IWL_DEVICE_6030, 231 228 }; 232 229 230 + #define IWL_DEVICE_6035 \ 231 + .fw_name_pre = IWL6030_FW_PRE, \ 232 + .ucode_api_max = IWL6035_UCODE_API_MAX, \ 233 + .ucode_api_ok = IWL6035_UCODE_API_OK, \ 234 + .ucode_api_min = IWL6035_UCODE_API_MIN, \ 235 + .device_family = IWL_DEVICE_FAMILY_6030, \ 236 + .max_inst_size = IWL60_RTC_INST_SIZE, \ 237 + .max_data_size = IWL60_RTC_DATA_SIZE, \ 238 + .eeprom_ver = EEPROM_6030_EEPROM_VERSION, \ 239 + .eeprom_calib_ver = EEPROM_6030_TX_POWER_VERSION, \ 240 + .base_params = &iwl6000_g2_base_params, \ 241 + .bt_params = &iwl6000_bt_params, \ 242 + .need_temp_offset_calib = true, \ 243 + .led_mode = IWL_LED_RF_STATE, \ 244 + .adv_pm = true 245 + 233 246 const struct iwl_cfg iwl6035_2agn_cfg = { 234 247 .name = "Intel(R) Centrino(R) Advanced-N 6235 AGN", 235 - IWL_DEVICE_6030, 248 + IWL_DEVICE_6035, 236 249 .ht_params = &iwl6000_ht_params, 237 250 }; 238 251
+1 -1
drivers/net/wireless/iwlwifi/iwl-agn-sta.c
··· 1267 1267 key_flags |= STA_KEY_MULTICAST_MSK; 1268 1268 1269 1269 sta_cmd.key.key_flags = key_flags; 1270 - sta_cmd.key.key_offset = WEP_INVALID_OFFSET; 1270 + sta_cmd.key.key_offset = keyconf->hw_key_idx; 1271 1271 sta_cmd.sta.modify_mask = STA_MODIFY_KEY_MASK; 1272 1272 sta_cmd.mode = STA_CONTROL_MODIFY_MSK; 1273 1273
+7 -2
drivers/net/wireless/iwlwifi/iwl-drv.c
··· 861 861 862 862 /* We have our copies now, allow OS release its copies */ 863 863 release_firmware(ucode_raw); 864 - complete(&drv->request_firmware_complete); 865 864 866 865 drv->op_mode = iwl_dvm_ops.start(drv->trans, drv->cfg, &drv->fw); 867 866 868 867 if (!drv->op_mode) 869 - goto out_free_fw; 868 + goto out_unbind; 870 869 870 + /* 871 + * Complete the firmware request last so that 872 + * a driver unbind (stop) doesn't run while we 873 + * are doing the start() above. 874 + */ 875 + complete(&drv->request_firmware_complete); 871 876 return; 872 877 873 878 try_again:
+9 -9
drivers/net/wireless/iwlwifi/iwl-eeprom.c
··· 568 568 * iwl_get_max_txpower_avg - get the highest tx power from all chains. 569 569 * find the highest tx power from all chains for the channel 570 570 */ 571 - static s8 iwl_get_max_txpower_avg(const struct iwl_cfg *cfg, 571 + static s8 iwl_get_max_txpower_avg(struct iwl_priv *priv, 572 572 struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, 573 573 int element, s8 *max_txpower_in_half_dbm) 574 574 { 575 575 s8 max_txpower_avg = 0; /* (dBm) */ 576 576 577 577 /* Take the highest tx power from any valid chains */ 578 - if ((cfg->valid_tx_ant & ANT_A) && 578 + if ((priv->hw_params.valid_tx_ant & ANT_A) && 579 579 (enhanced_txpower[element].chain_a_max > max_txpower_avg)) 580 580 max_txpower_avg = enhanced_txpower[element].chain_a_max; 581 - if ((cfg->valid_tx_ant & ANT_B) && 581 + if ((priv->hw_params.valid_tx_ant & ANT_B) && 582 582 (enhanced_txpower[element].chain_b_max > max_txpower_avg)) 583 583 max_txpower_avg = enhanced_txpower[element].chain_b_max; 584 - if ((cfg->valid_tx_ant & ANT_C) && 584 + if ((priv->hw_params.valid_tx_ant & ANT_C) && 585 585 (enhanced_txpower[element].chain_c_max > max_txpower_avg)) 586 586 max_txpower_avg = enhanced_txpower[element].chain_c_max; 587 - if (((cfg->valid_tx_ant == ANT_AB) | 588 - (cfg->valid_tx_ant == ANT_BC) | 589 - (cfg->valid_tx_ant == ANT_AC)) && 587 + if (((priv->hw_params.valid_tx_ant == ANT_AB) | 588 + (priv->hw_params.valid_tx_ant == ANT_BC) | 589 + (priv->hw_params.valid_tx_ant == ANT_AC)) && 590 590 (enhanced_txpower[element].mimo2_max > max_txpower_avg)) 591 591 max_txpower_avg = enhanced_txpower[element].mimo2_max; 592 - if ((cfg->valid_tx_ant == ANT_ABC) && 592 + if ((priv->hw_params.valid_tx_ant == ANT_ABC) && 593 593 (enhanced_txpower[element].mimo3_max > max_txpower_avg)) 594 594 max_txpower_avg = enhanced_txpower[element].mimo3_max; 595 595 ··· 691 691 ((txp->delta_20_in_40 & 0xf0) >> 4), 692 692 (txp->delta_20_in_40 & 0x0f)); 693 693 694 - max_txp_avg = iwl_get_max_txpower_avg(priv->cfg, txp_array, idx, 694 + max_txp_avg = iwl_get_max_txpower_avg(priv, txp_array, idx, 695 695 &max_txp_avg_halfdbm); 696 696 697 697 /*
+3
drivers/net/wireless/iwlwifi/iwl-mac80211.c
··· 199 199 WIPHY_FLAG_DISABLE_BEACON_HINTS | 200 200 WIPHY_FLAG_IBSS_RSN; 201 201 202 + #ifdef CONFIG_PM_SLEEP 202 203 if (priv->fw->img[IWL_UCODE_WOWLAN].sec[0].len && 203 204 priv->trans->ops->wowlan_suspend && 204 205 device_can_wakeup(priv->trans->dev)) { ··· 218 217 hw->wiphy->wowlan.pattern_max_len = 219 218 IWLAGN_WOWLAN_MAX_PATTERN_LEN; 220 219 } 220 + #endif 221 221 222 222 if (iwlwifi_mod_params.power_save) 223 223 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; ··· 251 249 ret = ieee80211_register_hw(priv->hw); 252 250 if (ret) { 253 251 IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); 252 + iwl_leds_exit(priv); 254 253 return ret; 255 254 } 256 255 priv->mac80211_registered = 1;
+1
drivers/net/wireless/iwlwifi/iwl-prph.h
··· 224 224 #define SCD_TXFACT (SCD_BASE + 0x10) 225 225 #define SCD_ACTIVE (SCD_BASE + 0x14) 226 226 #define SCD_QUEUECHAIN_SEL (SCD_BASE + 0xe8) 227 + #define SCD_CHAINEXT_EN (SCD_BASE + 0x244) 227 228 #define SCD_AGGR_SEL (SCD_BASE + 0x248) 228 229 #define SCD_INTERRUPT_MASK (SCD_BASE + 0x108) 229 230
+5
drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
··· 1058 1058 iwl_write_prph(trans, SCD_DRAM_BASE_ADDR, 1059 1059 trans_pcie->scd_bc_tbls.dma >> 10); 1060 1060 1061 + /* The chain extension of the SCD doesn't work well. This feature is 1062 + * enabled by default by the HW, so we need to disable it manually. 1063 + */ 1064 + iwl_write_prph(trans, SCD_CHAINEXT_EN, 0); 1065 + 1061 1066 /* Enable DMA channel */ 1062 1067 for (chan = 0; chan < FH_TCSR_CHNL_NUM ; chan++) 1063 1068 iwl_write_direct32(trans, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
+22
drivers/net/wireless/mac80211_hwsim.c
··· 1555 1555 hdr = (struct ieee80211_hdr *) skb->data; 1556 1556 mac80211_hwsim_monitor_ack(data2->hw, hdr->addr2); 1557 1557 } 1558 + txi->flags |= IEEE80211_TX_STAT_ACK; 1558 1559 } 1559 1560 ieee80211_tx_status_irqsafe(data2->hw, skb); 1560 1561 return 0; ··· 1722 1721 "unregister family %i\n", ret); 1723 1722 } 1724 1723 1724 + static const struct ieee80211_iface_limit hwsim_if_limits[] = { 1725 + { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, 1726 + { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) | 1727 + BIT(NL80211_IFTYPE_P2P_CLIENT) | 1728 + #ifdef CONFIG_MAC80211_MESH 1729 + BIT(NL80211_IFTYPE_MESH_POINT) | 1730 + #endif 1731 + BIT(NL80211_IFTYPE_AP) | 1732 + BIT(NL80211_IFTYPE_P2P_GO) }, 1733 + }; 1734 + 1735 + static const struct ieee80211_iface_combination hwsim_if_comb = { 1736 + .limits = hwsim_if_limits, 1737 + .n_limits = ARRAY_SIZE(hwsim_if_limits), 1738 + .max_interfaces = 2048, 1739 + .num_different_channels = 1, 1740 + }; 1741 + 1725 1742 static int __init init_mac80211_hwsim(void) 1726 1743 { 1727 1744 int i, err = 0; ··· 1800 1781 data->addresses[1].addr[0] |= 0x40; 1801 1782 hw->wiphy->n_addresses = 2; 1802 1783 hw->wiphy->addresses = data->addresses; 1784 + 1785 + hw->wiphy->iface_combinations = &hwsim_if_comb; 1786 + hw->wiphy->n_iface_combinations = 1; 1803 1787 1804 1788 if (fake_hw_scan) { 1805 1789 hw->wiphy->max_scan_ssids = 255;
+13
drivers/net/wireless/mwifiex/cfg80211.c
··· 948 948 bss_cfg->ssid.ssid_len = params->ssid_len; 949 949 } 950 950 951 + switch (params->hidden_ssid) { 952 + case NL80211_HIDDEN_SSID_NOT_IN_USE: 953 + bss_cfg->bcast_ssid_ctl = 1; 954 + break; 955 + case NL80211_HIDDEN_SSID_ZERO_LEN: 956 + bss_cfg->bcast_ssid_ctl = 0; 957 + break; 958 + case NL80211_HIDDEN_SSID_ZERO_CONTENTS: 959 + /* firmware doesn't support this type of hidden SSID */ 960 + default: 961 + return -EINVAL; 962 + } 963 + 951 964 if (mwifiex_set_secure_params(priv, bss_cfg, params)) { 952 965 kfree(bss_cfg); 953 966 wiphy_err(wiphy, "Failed to parse secuirty parameters!\n");
+6
drivers/net/wireless/mwifiex/fw.h
··· 122 122 #define TLV_TYPE_CHANNELBANDLIST (PROPRIETARY_TLV_BASE_ID + 42) 123 123 #define TLV_TYPE_UAP_BEACON_PERIOD (PROPRIETARY_TLV_BASE_ID + 44) 124 124 #define TLV_TYPE_UAP_DTIM_PERIOD (PROPRIETARY_TLV_BASE_ID + 45) 125 + #define TLV_TYPE_UAP_BCAST_SSID (PROPRIETARY_TLV_BASE_ID + 48) 125 126 #define TLV_TYPE_UAP_RTS_THRESHOLD (PROPRIETARY_TLV_BASE_ID + 51) 126 127 #define TLV_TYPE_UAP_WPA_PASSPHRASE (PROPRIETARY_TLV_BASE_ID + 60) 127 128 #define TLV_TYPE_UAP_ENCRY_PROTOCOL (PROPRIETARY_TLV_BASE_ID + 64) ··· 1208 1207 struct host_cmd_tlv_ssid { 1209 1208 struct host_cmd_tlv tlv; 1210 1209 u8 ssid[0]; 1210 + } __packed; 1211 + 1212 + struct host_cmd_tlv_bcast_ssid { 1213 + struct host_cmd_tlv tlv; 1214 + u8 bcast_ctl; 1211 1215 } __packed; 1212 1216 1213 1217 struct host_cmd_tlv_beacon_period {
+10
drivers/net/wireless/mwifiex/uap_cmd.c
··· 132 132 struct host_cmd_tlv_dtim_period *dtim_period; 133 133 struct host_cmd_tlv_beacon_period *beacon_period; 134 134 struct host_cmd_tlv_ssid *ssid; 135 + struct host_cmd_tlv_bcast_ssid *bcast_ssid; 135 136 struct host_cmd_tlv_channel_band *chan_band; 136 137 struct host_cmd_tlv_frag_threshold *frag_threshold; 137 138 struct host_cmd_tlv_rts_threshold *rts_threshold; ··· 154 153 cmd_size += sizeof(struct host_cmd_tlv) + 155 154 bss_cfg->ssid.ssid_len; 156 155 tlv += sizeof(struct host_cmd_tlv) + bss_cfg->ssid.ssid_len; 156 + 157 + bcast_ssid = (struct host_cmd_tlv_bcast_ssid *)tlv; 158 + bcast_ssid->tlv.type = cpu_to_le16(TLV_TYPE_UAP_BCAST_SSID); 159 + bcast_ssid->tlv.len = 160 + cpu_to_le16(sizeof(bcast_ssid->bcast_ctl)); 161 + bcast_ssid->bcast_ctl = bss_cfg->bcast_ssid_ctl; 162 + cmd_size += sizeof(struct host_cmd_tlv_bcast_ssid); 163 + tlv += sizeof(struct host_cmd_tlv_bcast_ssid); 157 164 } 158 165 if (bss_cfg->channel && bss_cfg->channel <= MAX_CHANNEL_BAND_BG) { 159 166 chan_band = (struct host_cmd_tlv_channel_band *)tlv; ··· 425 416 if (!bss_cfg) 426 417 return -ENOMEM; 427 418 419 + mwifiex_set_sys_config_invalid_data(bss_cfg); 428 420 bss_cfg->band_cfg = BAND_CONFIG_MANUAL; 429 421 bss_cfg->channel = channel; 430 422
+1 -2
drivers/net/wireless/rt2x00/rt2x00.h
··· 396 396 * for hardware which doesn't support hardware 397 397 * sequence counting. 398 398 */ 399 - spinlock_t seqlock; 400 - u16 seqno; 399 + atomic_t seqno; 401 400 }; 402 401 403 402 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
-1
drivers/net/wireless/rt2x00/rt2x00mac.c
··· 277 277 else 278 278 rt2x00dev->intf_sta_count++; 279 279 280 - spin_lock_init(&intf->seqlock); 281 280 mutex_init(&intf->beacon_skb_mutex); 282 281 intf->beacon = entry; 283 282
+6 -7
drivers/net/wireless/rt2x00/rt2x00queue.c
··· 207 207 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 208 208 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 209 209 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); 210 + u16 seqno; 210 211 211 212 if (!(tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) 212 213 return; ··· 239 238 * sequence counting per-frame, since those will override the 240 239 * sequence counter given by mac80211. 241 240 */ 242 - spin_lock(&intf->seqlock); 243 - 244 241 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)) 245 - intf->seqno += 0x10; 242 + seqno = atomic_add_return(0x10, &intf->seqno); 243 + else 244 + seqno = atomic_read(&intf->seqno); 245 + 246 246 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); 247 - hdr->seq_ctrl |= cpu_to_le16(intf->seqno); 248 - 249 - spin_unlock(&intf->seqlock); 250 - 247 + hdr->seq_ctrl |= cpu_to_le16(seqno); 251 248 } 252 249 253 250 static void rt2x00queue_create_tx_descriptor_plcp(struct rt2x00_dev *rt2x00dev,
+1 -1
drivers/net/wireless/rtl818x/rtl8187/leds.c
··· 117 117 radio_on = true; 118 118 } else if (radio_on) { 119 119 radio_on = false; 120 - cancel_delayed_work_sync(&priv->led_on); 120 + cancel_delayed_work(&priv->led_on); 121 121 ieee80211_queue_delayed_work(hw, &priv->led_off, 0); 122 122 } 123 123 } else if (radio_on) {
+5
include/linux/netfilter/xt_HMARK.h
··· 27 27 __u16 src; 28 28 __u16 dst; 29 29 } p16; 30 + struct { 31 + __be16 src; 32 + __be16 dst; 33 + } b16; 30 34 __u32 v32; 35 + __be32 b32; 31 36 }; 32 37 33 38 struct xt_hmark_info {
+10 -10
include/linux/tcp.h
··· 69 69 #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) 70 70 71 71 enum { 72 - TCP_FLAG_CWR = __cpu_to_be32(0x00800000), 73 - TCP_FLAG_ECE = __cpu_to_be32(0x00400000), 74 - TCP_FLAG_URG = __cpu_to_be32(0x00200000), 75 - TCP_FLAG_ACK = __cpu_to_be32(0x00100000), 76 - TCP_FLAG_PSH = __cpu_to_be32(0x00080000), 77 - TCP_FLAG_RST = __cpu_to_be32(0x00040000), 78 - TCP_FLAG_SYN = __cpu_to_be32(0x00020000), 79 - TCP_FLAG_FIN = __cpu_to_be32(0x00010000), 80 - TCP_RESERVED_BITS = __cpu_to_be32(0x0F000000), 81 - TCP_DATA_OFFSET = __cpu_to_be32(0xF0000000) 72 + TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000), 73 + TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000), 74 + TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000), 75 + TCP_FLAG_ACK = __constant_cpu_to_be32(0x00100000), 76 + TCP_FLAG_PSH = __constant_cpu_to_be32(0x00080000), 77 + TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000), 78 + TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000), 79 + TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), 80 + TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000), 81 + TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) 82 82 }; 83 83 84 84 /*
+4 -1
include/net/inetpeer.h
··· 40 40 u32 pmtu_orig; 41 41 u32 pmtu_learned; 42 42 struct inetpeer_addr_base redirect_learned; 43 - struct list_head gc_list; 43 + union { 44 + struct list_head gc_list; 45 + struct rcu_head gc_rcu; 46 + }; 44 47 /* 45 48 * Once inet_peer is queued for deletion (refcnt == -1), following fields 46 49 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp
+1 -1
include/net/route.h
··· 130 130 { 131 131 struct flowi4 fl4 = { 132 132 .flowi4_oif = oif, 133 + .flowi4_tos = tos, 133 134 .daddr = daddr, 134 135 .saddr = saddr, 135 - .flowi4_tos = tos, 136 136 }; 137 137 return ip_route_output_key(net, &fl4); 138 138 }
+5 -2
include/net/sch_generic.h
··· 220 220 221 221 struct qdisc_skb_cb { 222 222 unsigned int pkt_len; 223 - unsigned char data[24]; 223 + u16 bond_queue_mapping; 224 + u16 _pad; 225 + unsigned char data[20]; 224 226 }; 225 227 226 228 static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) 227 229 { 228 230 struct qdisc_skb_cb *qcb; 229 - BUILD_BUG_ON(sizeof(skb->cb) < sizeof(unsigned int) + sz); 231 + 232 + BUILD_BUG_ON(sizeof(skb->cb) < offsetof(struct qdisc_skb_cb, data) + sz); 230 233 BUILD_BUG_ON(sizeof(qcb->data) < sz); 231 234 } 232 235
+1 -3
net/appletalk/ddp.c
··· 1208 1208 if (addr->sat_addr.s_node == ATADDR_BCAST && 1209 1209 !sock_flag(sk, SOCK_BROADCAST)) { 1210 1210 #if 1 1211 - printk(KERN_WARNING "%s is broken and did not set " 1212 - "SO_BROADCAST. It will break when 2.2 is " 1213 - "released.\n", 1211 + pr_warn("atalk_connect: %s is broken and did not set SO_BROADCAST.\n", 1214 1212 current->comm); 1215 1213 #else 1216 1214 return -EACCES;
+1 -1
net/bluetooth/af_bluetooth.c
··· 210 210 } 211 211 212 212 if (sk->sk_state == BT_CONNECTED || !newsock || 213 - test_bit(BT_DEFER_SETUP, &bt_sk(parent)->flags)) { 213 + test_bit(BT_SK_DEFER_SETUP, &bt_sk(parent)->flags)) { 214 214 bt_accept_unlink(sk); 215 215 if (newsock) 216 216 sock_graft(sk, newsock);
+33 -69
net/core/drop_monitor.c
··· 36 36 #define TRACE_ON 1 37 37 #define TRACE_OFF 0 38 38 39 - static void send_dm_alert(struct work_struct *unused); 40 - 41 - 42 39 /* 43 40 * Globals, our netlink socket pointer 44 41 * and the work handle that will send up ··· 45 48 static DEFINE_MUTEX(trace_state_mutex); 46 49 47 50 struct per_cpu_dm_data { 48 - struct work_struct dm_alert_work; 49 - struct sk_buff __rcu *skb; 50 - atomic_t dm_hit_count; 51 - struct timer_list send_timer; 52 - int cpu; 51 + spinlock_t lock; 52 + struct sk_buff *skb; 53 + struct work_struct dm_alert_work; 54 + struct timer_list send_timer; 53 55 }; 54 56 55 57 struct dm_hw_stat_delta { ··· 74 78 static unsigned long dm_hw_check_delta = 2*HZ; 75 79 static LIST_HEAD(hw_stats_list); 76 80 77 - static void reset_per_cpu_data(struct per_cpu_dm_data *data) 81 + static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data) 78 82 { 79 83 size_t al; 80 84 struct net_dm_alert_msg *msg; 81 85 struct nlattr *nla; 82 86 struct sk_buff *skb; 83 - struct sk_buff *oskb = rcu_dereference_protected(data->skb, 1); 87 + unsigned long flags; 84 88 85 89 al = sizeof(struct net_dm_alert_msg); 86 90 al += dm_hit_limit * sizeof(struct net_dm_drop_point); ··· 95 99 sizeof(struct net_dm_alert_msg)); 96 100 msg = nla_data(nla); 97 101 memset(msg, 0, al); 98 - } else 99 - schedule_work_on(data->cpu, &data->dm_alert_work); 100 - 101 - /* 102 - * Don't need to lock this, since we are guaranteed to only 103 - * run this on a single cpu at a time. 104 - * Note also that we only update data->skb if the old and new skb 105 - * pointers don't match. This ensures that we don't continually call 106 - * synchornize_rcu if we repeatedly fail to alloc a new netlink message. 107 - */ 108 - if (skb != oskb) { 109 - rcu_assign_pointer(data->skb, skb); 110 - 111 - synchronize_rcu(); 112 - 113 - atomic_set(&data->dm_hit_count, dm_hit_limit); 102 + } else { 103 + mod_timer(&data->send_timer, jiffies + HZ / 10); 114 104 } 115 105 106 + spin_lock_irqsave(&data->lock, flags); 107 + swap(data->skb, skb); 108 + spin_unlock_irqrestore(&data->lock, flags); 109 + 110 + return skb; 116 111 } 117 112 118 - static void send_dm_alert(struct work_struct *unused) 113 + static void send_dm_alert(struct work_struct *work) 119 114 { 120 115 struct sk_buff *skb; 121 - struct per_cpu_dm_data *data = &get_cpu_var(dm_cpu_data); 116 + struct per_cpu_dm_data *data; 122 117 123 - WARN_ON_ONCE(data->cpu != smp_processor_id()); 118 + data = container_of(work, struct per_cpu_dm_data, dm_alert_work); 124 119 125 - /* 126 - * Grab the skb we're about to send 127 - */ 128 - skb = rcu_dereference_protected(data->skb, 1); 120 + skb = reset_per_cpu_data(data); 129 121 130 - /* 131 - * Replace it with a new one 132 - */ 133 - reset_per_cpu_data(data); 134 - 135 - /* 136 - * Ship it! 137 - */ 138 122 if (skb) 139 123 genlmsg_multicast(skb, 0, NET_DM_GRP_ALERT, GFP_KERNEL); 140 - 141 - put_cpu_var(dm_cpu_data); 142 124 } 143 125 144 126 /* 145 127 * This is the timer function to delay the sending of an alert 146 128 * in the event that more drops will arrive during the 147 - * hysteresis period. Note that it operates under the timer interrupt 148 - * so we don't need to disable preemption here 129 + * hysteresis period. 149 130 */ 150 - static void sched_send_work(unsigned long unused) 131 + static void sched_send_work(unsigned long _data) 151 132 { 152 - struct per_cpu_dm_data *data = &get_cpu_var(dm_cpu_data); 133 + struct per_cpu_dm_data *data = (struct per_cpu_dm_data *)_data; 153 134 154 - schedule_work_on(smp_processor_id(), &data->dm_alert_work); 155 - 156 - put_cpu_var(dm_cpu_data); 135 + schedule_work(&data->dm_alert_work); 157 136 } 158 137 159 138 static void trace_drop_common(struct sk_buff *skb, void *location) ··· 138 167 struct nlattr *nla; 139 168 int i; 140 169 struct sk_buff *dskb; 141 - struct per_cpu_dm_data *data = &get_cpu_var(dm_cpu_data); 170 + struct per_cpu_dm_data *data; 171 + unsigned long flags; 142 172 143 - 144 - rcu_read_lock(); 145 - dskb = rcu_dereference(data->skb); 173 + local_irq_save(flags); 174 + data = &__get_cpu_var(dm_cpu_data); 175 + spin_lock(&data->lock); 176 + dskb = data->skb; 146 177 147 178 if (!dskb) 148 179 goto out; 149 - 150 - if (!atomic_add_unless(&data->dm_hit_count, -1, 0)) { 151 - /* 152 - * we're already at zero, discard this hit 153 - */ 154 - goto out; 155 - } 156 180 157 181 nlh = (struct nlmsghdr *)dskb->data; 158 182 nla = genlmsg_data(nlmsg_data(nlh)); ··· 155 189 for (i = 0; i < msg->entries; i++) { 156 190 if (!memcmp(&location, msg->points[i].pc, sizeof(void *))) { 157 191 msg->points[i].count++; 158 - atomic_inc(&data->dm_hit_count); 159 192 goto out; 160 193 } 161 194 } 162 - 195 + if (msg->entries == dm_hit_limit) 196 + goto out; 163 197 /* 164 198 * We need to create a new entry 165 199 */ ··· 171 205 172 206 if (!timer_pending(&data->send_timer)) { 173 207 data->send_timer.expires = jiffies + dm_delay * HZ; 174 - add_timer_on(&data->send_timer, smp_processor_id()); 208 + add_timer(&data->send_timer); 175 209 } 176 210 177 211 out: 178 - rcu_read_unlock(); 179 - put_cpu_var(dm_cpu_data); 180 - return; 212 + spin_unlock_irqrestore(&data->lock, flags); 181 213 } 182 214 183 215 static void trace_kfree_skb_hit(void *ignore, struct sk_buff *skb, void *location) ··· 382 418 383 419 for_each_possible_cpu(cpu) { 384 420 data = &per_cpu(dm_cpu_data, cpu); 385 - data->cpu = cpu; 386 421 INIT_WORK(&data->dm_alert_work, send_dm_alert); 387 422 init_timer(&data->send_timer); 388 - data->send_timer.data = cpu; 423 + data->send_timer.data = (unsigned long)data; 389 424 data->send_timer.function = sched_send_work; 425 + spin_lock_init(&data->lock); 390 426 reset_per_cpu_data(data); 391 427 } 392 428
+2 -2
net/core/filter.c
··· 616 616 /** 617 617 * sk_unattached_filter_create - create an unattached filter 618 618 * @fprog: the filter program 619 - * @sk: the socket to use 619 + * @pfp: the unattached filter that is created 620 620 * 621 - * Create a filter independent ofr any socket. We first run some 621 + * Create a filter independent of any socket. We first run some 622 622 * sanity checks on it to make sure it does not explode on us later. 623 623 * If an error occurs or there is insufficient memory for the filter 624 624 * a negative errno code is returned. On success the return is zero.
+6 -8
net/core/neighbour.c
··· 2219 2219 rcu_read_lock_bh(); 2220 2220 nht = rcu_dereference_bh(tbl->nht); 2221 2221 2222 - for (h = 0; h < (1 << nht->hash_shift); h++) { 2223 - if (h < s_h) 2224 - continue; 2222 + for (h = s_h; h < (1 << nht->hash_shift); h++) { 2225 2223 if (h > s_h) 2226 2224 s_idx = 0; 2227 2225 for (n = rcu_dereference_bh(nht->hash_buckets[h]), idx = 0; ··· 2258 2260 2259 2261 read_lock_bh(&tbl->lock); 2260 2262 2261 - for (h = 0; h <= PNEIGH_HASHMASK; h++) { 2262 - if (h < s_h) 2263 - continue; 2263 + for (h = s_h; h <= PNEIGH_HASHMASK; h++) { 2264 2264 if (h > s_h) 2265 2265 s_idx = 0; 2266 2266 for (n = tbl->phash_buckets[h], idx = 0; n; n = n->next) { ··· 2293 2297 struct neigh_table *tbl; 2294 2298 int t, family, s_t; 2295 2299 int proxy = 0; 2296 - int err = 0; 2300 + int err; 2297 2301 2298 2302 read_lock(&neigh_tbl_lock); 2299 2303 family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family; ··· 2307 2311 2308 2312 s_t = cb->args[0]; 2309 2313 2310 - for (tbl = neigh_tables, t = 0; tbl && (err >= 0); 2314 + for (tbl = neigh_tables, t = 0; tbl; 2311 2315 tbl = tbl->next, t++) { 2312 2316 if (t < s_t || (family && tbl->family != family)) 2313 2317 continue; ··· 2318 2322 err = pneigh_dump_table(tbl, skb, cb); 2319 2323 else 2320 2324 err = neigh_dump_table(tbl, skb, cb); 2325 + if (err < 0) 2326 + break; 2321 2327 } 2322 2328 read_unlock(&neigh_tbl_lock); 2323 2329
+6 -5
net/core/netpoll.c
··· 362 362 363 363 void netpoll_send_udp(struct netpoll *np, const char *msg, int len) 364 364 { 365 - int total_len, eth_len, ip_len, udp_len; 365 + int total_len, ip_len, udp_len; 366 366 struct sk_buff *skb; 367 367 struct udphdr *udph; 368 368 struct iphdr *iph; 369 369 struct ethhdr *eth; 370 370 371 371 udp_len = len + sizeof(*udph); 372 - ip_len = eth_len = udp_len + sizeof(*iph); 373 - total_len = eth_len + ETH_HLEN + NET_IP_ALIGN; 372 + ip_len = udp_len + sizeof(*iph); 373 + total_len = ip_len + LL_RESERVED_SPACE(np->dev); 374 374 375 - skb = find_skb(np, total_len, total_len - len); 375 + skb = find_skb(np, total_len + np->dev->needed_tailroom, 376 + total_len - len); 376 377 if (!skb) 377 378 return; 378 379 379 380 skb_copy_to_linear_data(skb, msg, len); 380 - skb->len += len; 381 + skb_put(skb, len); 381 382 382 383 skb_push(skb, sizeof(*udph)); 383 384 skb_reset_transport_header(skb);
+1 -1
net/core/skbuff.c
··· 3361 3361 * @to: prior buffer 3362 3362 * @from: buffer to add 3363 3363 * @fragstolen: pointer to boolean 3364 - * 3364 + * @delta_truesize: how much more was allocated than was requested 3365 3365 */ 3366 3366 bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, 3367 3367 bool *fragstolen, int *delta_truesize)
+12 -4
net/ipv4/inetpeer.c
··· 560 560 } 561 561 EXPORT_SYMBOL(inet_peer_xrlim_allow); 562 562 563 + static void inetpeer_inval_rcu(struct rcu_head *head) 564 + { 565 + struct inet_peer *p = container_of(head, struct inet_peer, gc_rcu); 566 + 567 + spin_lock_bh(&gc_lock); 568 + list_add_tail(&p->gc_list, &gc_list); 569 + spin_unlock_bh(&gc_lock); 570 + 571 + schedule_delayed_work(&gc_work, gc_delay); 572 + } 573 + 563 574 void inetpeer_invalidate_tree(int family) 564 575 { 565 576 struct inet_peer *old, *new, *prev; ··· 587 576 prev = cmpxchg(&base->root, old, new); 588 577 if (prev == old) { 589 578 base->total = 0; 590 - spin_lock(&gc_lock); 591 - list_add_tail(&prev->gc_list, &gc_list); 592 - spin_unlock(&gc_lock); 593 - schedule_delayed_work(&gc_work, gc_delay); 579 + call_rcu(&prev->gc_rcu, inetpeer_inval_rcu); 594 580 } 595 581 596 582 out:
+1
net/ipv4/ip_forward.c
··· 44 44 struct ip_options *opt = &(IPCB(skb)->opt); 45 45 46 46 IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS); 47 + IP_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len); 47 48 48 49 if (unlikely(opt->optlen)) 49 50 ip_forward_options(skb);
+1
net/ipv4/ipmr.c
··· 1574 1574 struct ip_options *opt = &(IPCB(skb)->opt); 1575 1575 1576 1576 IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS); 1577 + IP_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len); 1577 1578 1578 1579 if (unlikely(opt->optlen)) 1579 1580 ip_forward_options(skb);
+1 -1
net/ipv6/ip6_fib.c
··· 1561 1561 neigh_flags = neigh->flags; 1562 1562 neigh_release(neigh); 1563 1563 } 1564 - if (neigh_flags & NTF_ROUTER) { 1564 + if (!(neigh_flags & NTF_ROUTER)) { 1565 1565 RT6_TRACE("purging route %p via non-router but gateway\n", 1566 1566 rt); 1567 1567 return -1;
+1
net/ipv6/ip6_output.c
··· 526 526 hdr->hop_limit--; 527 527 528 528 IP6_INC_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS); 529 + IP6_ADD_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len); 529 530 return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, skb, skb->dev, dst->dev, 530 531 ip6_forward_finish); 531 532
+2
net/ipv6/ip6mr.c
··· 1886 1886 { 1887 1887 IP6_INC_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)), 1888 1888 IPSTATS_MIB_OUTFORWDATAGRAMS); 1889 + IP6_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)), 1890 + IPSTATS_MIB_OUTOCTETS, skb->len); 1889 1891 return dst_output(skb); 1890 1892 } 1891 1893
+2
net/l2tp/l2tp_eth.c
··· 162 162 if (dev) { 163 163 unregister_netdev(dev); 164 164 spriv->dev = NULL; 165 + module_put(THIS_MODULE); 165 166 } 166 167 } 167 168 } ··· 250 249 if (rc < 0) 251 250 goto out_del_dev; 252 251 252 + __module_get(THIS_MODULE); 253 253 /* Must be done after register_netdev() */ 254 254 strlcpy(session->ifname, dev->name, IFNAMSIZ); 255 255
+6 -3
net/l2tp/l2tp_ip.c
··· 464 464 sk->sk_bound_dev_if); 465 465 if (IS_ERR(rt)) 466 466 goto no_route; 467 - if (connected) 467 + if (connected) { 468 468 sk_setup_caps(sk, &rt->dst); 469 - else 470 - dst_release(&rt->dst); /* safe since we hold rcu_read_lock */ 469 + } else { 470 + skb_dst_set(skb, &rt->dst); 471 + goto xmit; 472 + } 471 473 } 472 474 473 475 /* We dont need to clone dst here, it is guaranteed to not disappear. ··· 477 475 */ 478 476 skb_dst_set_noref(skb, &rt->dst); 479 477 478 + xmit: 480 479 /* Queue the packet to IP for output */ 481 480 rc = ip_queue_xmit(skb, &inet->cork.fl); 482 481 rcu_read_unlock();
+6 -1
net/mac80211/agg-rx.c
··· 145 145 struct tid_ampdu_rx *tid_rx; 146 146 unsigned long timeout; 147 147 148 + rcu_read_lock(); 148 149 tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[*ptid]); 149 - if (!tid_rx) 150 + if (!tid_rx) { 151 + rcu_read_unlock(); 150 152 return; 153 + } 151 154 152 155 timeout = tid_rx->last_rx + TU_TO_JIFFIES(tid_rx->timeout); 153 156 if (time_is_after_jiffies(timeout)) { 154 157 mod_timer(&tid_rx->session_timer, timeout); 158 + rcu_read_unlock(); 155 159 return; 156 160 } 161 + rcu_read_unlock(); 157 162 158 163 #ifdef CONFIG_MAC80211_HT_DEBUG 159 164 printk(KERN_DEBUG "rx session timer expired on tid %d\n", (u16)*ptid);
+3 -3
net/mac80211/cfg.c
··· 533 533 sinfo.filled = 0; 534 534 sta_set_sinfo(sta, &sinfo); 535 535 536 - if (sinfo.filled | STATION_INFO_TX_BITRATE) 536 + if (sinfo.filled & STATION_INFO_TX_BITRATE) 537 537 data[i] = 100000 * 538 538 cfg80211_calculate_bitrate(&sinfo.txrate); 539 539 i++; 540 - if (sinfo.filled | STATION_INFO_RX_BITRATE) 540 + if (sinfo.filled & STATION_INFO_RX_BITRATE) 541 541 data[i] = 100000 * 542 542 cfg80211_calculate_bitrate(&sinfo.rxrate); 543 543 i++; 544 544 545 - if (sinfo.filled | STATION_INFO_SIGNAL_AVG) 545 + if (sinfo.filled & STATION_INFO_SIGNAL_AVG) 546 546 data[i] = (u8)sinfo.signal_avg; 547 547 i++; 548 548 } else {
+12
net/mac80211/iface.c
··· 637 637 ieee80211_configure_filter(local); 638 638 break; 639 639 default: 640 + mutex_lock(&local->mtx); 641 + if (local->hw_roc_dev == sdata->dev && 642 + local->hw_roc_channel) { 643 + /* ignore return value since this is racy */ 644 + drv_cancel_remain_on_channel(local); 645 + ieee80211_queue_work(&local->hw, &local->hw_roc_done); 646 + } 647 + mutex_unlock(&local->mtx); 648 + 649 + flush_work(&local->hw_roc_start); 650 + flush_work(&local->hw_roc_done); 651 + 640 652 flush_work(&sdata->work); 641 653 /* 642 654 * When we get here, the interface is marked down.
+28 -10
net/mac80211/mlme.c
··· 1220 1220 sdata->vif.bss_conf.qos = true; 1221 1221 } 1222 1222 1223 + static void __ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata) 1224 + { 1225 + lockdep_assert_held(&sdata->local->mtx); 1226 + 1227 + sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | 1228 + IEEE80211_STA_BEACON_POLL); 1229 + ieee80211_run_deferred_scan(sdata->local); 1230 + } 1231 + 1232 + static void ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata) 1233 + { 1234 + mutex_lock(&sdata->local->mtx); 1235 + __ieee80211_stop_poll(sdata); 1236 + mutex_unlock(&sdata->local->mtx); 1237 + } 1238 + 1223 1239 static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, 1224 1240 u16 capab, bool erp_valid, u8 erp) 1225 1241 { ··· 1301 1285 sdata->u.mgd.flags |= IEEE80211_STA_RESET_SIGNAL_AVE; 1302 1286 1303 1287 /* just to be sure */ 1304 - sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | 1305 - IEEE80211_STA_BEACON_POLL); 1288 + ieee80211_stop_poll(sdata); 1306 1289 1307 1290 ieee80211_led_assoc(local, 1); 1308 1291 ··· 1471 1456 return; 1472 1457 } 1473 1458 1474 - ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | 1475 - IEEE80211_STA_BEACON_POLL); 1459 + __ieee80211_stop_poll(sdata); 1476 1460 1477 1461 mutex_lock(&local->iflist_mtx); 1478 1462 ieee80211_recalc_ps(local, -1); ··· 1491 1477 round_jiffies_up(jiffies + 1492 1478 IEEE80211_CONNECTION_IDLE_TIME)); 1493 1479 out: 1494 - ieee80211_run_deferred_scan(local); 1495 1480 mutex_unlock(&local->mtx); 1496 1481 } 1497 1482 ··· 2421 2408 net_dbg_ratelimited("%s: cancelling probereq poll due to a received beacon\n", 2422 2409 sdata->name); 2423 2410 #endif 2411 + mutex_lock(&local->mtx); 2424 2412 ifmgd->flags &= ~IEEE80211_STA_BEACON_POLL; 2413 + ieee80211_run_deferred_scan(local); 2414 + mutex_unlock(&local->mtx); 2415 + 2425 2416 mutex_lock(&local->iflist_mtx); 2426 2417 ieee80211_recalc_ps(local, -1); 2427 2418 mutex_unlock(&local->iflist_mtx); ··· 2612 2595 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2613 2596 u8 frame_buf[DEAUTH_DISASSOC_LEN]; 2614 2597 2615 - ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | 2616 - IEEE80211_STA_BEACON_POLL); 2598 + ieee80211_stop_poll(sdata); 2617 2599 2618 2600 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, reason, 2619 2601 false, frame_buf); ··· 2890 2874 u32 flags; 2891 2875 2892 2876 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 2893 - sdata->u.mgd.flags &= ~(IEEE80211_STA_BEACON_POLL | 2894 - IEEE80211_STA_CONNECTION_POLL); 2877 + __ieee80211_stop_poll(sdata); 2895 2878 2896 2879 /* let's probe the connection once */ 2897 2880 flags = sdata->local->hw.flags; ··· 2959 2944 if (test_and_clear_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running)) 2960 2945 add_timer(&ifmgd->chswitch_timer); 2961 2946 ieee80211_sta_reset_beacon_monitor(sdata); 2947 + 2948 + mutex_lock(&sdata->local->mtx); 2962 2949 ieee80211_restart_sta_timer(sdata); 2950 + mutex_unlock(&sdata->local->mtx); 2963 2951 } 2964 2952 #endif 2965 2953 ··· 3124 3106 } 3125 3107 3126 3108 local->oper_channel = cbss->channel; 3127 - ieee80211_hw_config(local, 0); 3109 + ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 3128 3110 3129 3111 if (!have_sta) { 3130 3112 u32 rates = 0, basic_rates = 0;
+16
net/mac80211/offchannel.c
··· 234 234 return; 235 235 } 236 236 237 + /* was never transmitted */ 238 + if (local->hw_roc_skb) { 239 + u64 cookie; 240 + 241 + cookie = local->hw_roc_cookie ^ 2; 242 + 243 + cfg80211_mgmt_tx_status(local->hw_roc_dev, cookie, 244 + local->hw_roc_skb->data, 245 + local->hw_roc_skb->len, false, 246 + GFP_KERNEL); 247 + 248 + kfree_skb(local->hw_roc_skb); 249 + local->hw_roc_skb = NULL; 250 + local->hw_roc_skb_for_status = NULL; 251 + } 252 + 237 253 if (!local->hw_roc_for_tx) 238 254 cfg80211_remain_on_channel_expired(local->hw_roc_dev, 239 255 local->hw_roc_cookie,
+2 -2
net/mac80211/sta_info.c
··· 378 378 /* make the station visible */ 379 379 sta_info_hash_add(local, sta); 380 380 381 - list_add(&sta->list, &local->sta_list); 381 + list_add_rcu(&sta->list, &local->sta_list); 382 382 383 383 set_sta_flag(sta, WLAN_STA_INSERTED); 384 384 ··· 688 688 if (ret) 689 689 return ret; 690 690 691 - list_del(&sta->list); 691 + list_del_rcu(&sta->list); 692 692 693 693 mutex_lock(&local->key_mtx); 694 694 for (i = 0; i < NUM_DEFAULT_KEYS; i++)
+6 -3
net/mac80211/tx.c
··· 1737 1737 __le16 fc; 1738 1738 struct ieee80211_hdr hdr; 1739 1739 struct ieee80211s_hdr mesh_hdr __maybe_unused; 1740 - struct mesh_path __maybe_unused *mppath = NULL; 1740 + struct mesh_path __maybe_unused *mppath = NULL, *mpath = NULL; 1741 1741 const u8 *encaps_data; 1742 1742 int encaps_len, skip_header_bytes; 1743 1743 int nh_pos, h_pos; ··· 1803 1803 goto fail; 1804 1804 } 1805 1805 rcu_read_lock(); 1806 - if (!is_multicast_ether_addr(skb->data)) 1807 - mppath = mpp_path_lookup(skb->data, sdata); 1806 + if (!is_multicast_ether_addr(skb->data)) { 1807 + mpath = mesh_path_lookup(skb->data, sdata); 1808 + if (!mpath) 1809 + mppath = mpp_path_lookup(skb->data, sdata); 1810 + } 1808 1811 1809 1812 /* 1810 1813 * Use address extension if it is a packet from
+1 -1
net/mac80211/util.c
··· 1271 1271 enum ieee80211_sta_state state; 1272 1272 1273 1273 for (state = IEEE80211_STA_NOTEXIST; 1274 - state < sta->sta_state - 1; state++) 1274 + state < sta->sta_state; state++) 1275 1275 WARN_ON(drv_sta_state(local, sta->sdata, sta, 1276 1276 state, state + 1)); 1277 1277 }
+2 -3
net/netfilter/nf_conntrack_h323_main.c
··· 270 270 return 0; 271 271 272 272 /* RTP port is even */ 273 - port &= htons(~1); 274 - rtp_port = port; 275 - rtcp_port = htons(ntohs(port) + 1); 273 + rtp_port = port & ~htons(1); 274 + rtcp_port = port | htons(1); 276 275 277 276 /* Create expect for RTP */ 278 277 if ((rtp_exp = nf_ct_expect_alloc(ct)) == NULL)
+41 -31
net/netfilter/xt_HMARK.c
··· 32 32 MODULE_ALIAS("ip6t_HMARK"); 33 33 34 34 struct hmark_tuple { 35 - u32 src; 36 - u32 dst; 35 + __be32 src; 36 + __be32 dst; 37 37 union hmark_ports uports; 38 - uint8_t proto; 38 + u8 proto; 39 39 }; 40 40 41 - static inline u32 hmark_addr6_mask(const __u32 *addr32, const __u32 *mask) 41 + static inline __be32 hmark_addr6_mask(const __be32 *addr32, const __be32 *mask) 42 42 { 43 43 return (addr32[0] & mask[0]) ^ 44 44 (addr32[1] & mask[1]) ^ ··· 46 46 (addr32[3] & mask[3]); 47 47 } 48 48 49 - static inline u32 50 - hmark_addr_mask(int l3num, const __u32 *addr32, const __u32 *mask) 49 + static inline __be32 50 + hmark_addr_mask(int l3num, const __be32 *addr32, const __be32 *mask) 51 51 { 52 52 switch (l3num) { 53 53 case AF_INET: ··· 56 56 return hmark_addr6_mask(addr32, mask); 57 57 } 58 58 return 0; 59 + } 60 + 61 + static inline void hmark_swap_ports(union hmark_ports *uports, 62 + const struct xt_hmark_info *info) 63 + { 64 + union hmark_ports hp; 65 + u16 src, dst; 66 + 67 + hp.b32 = (uports->b32 & info->port_mask.b32) | info->port_set.b32; 68 + src = ntohs(hp.b16.src); 69 + dst = ntohs(hp.b16.dst); 70 + 71 + if (dst > src) 72 + uports->v32 = (dst << 16) | src; 73 + else 74 + uports->v32 = (src << 16) | dst; 59 75 } 60 76 61 77 static int ··· 90 74 otuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple; 91 75 rtuple = &ct->tuplehash[IP_CT_DIR_REPLY].tuple; 92 76 93 - t->src = hmark_addr_mask(otuple->src.l3num, otuple->src.u3.all, 94 - info->src_mask.all); 95 - t->dst = hmark_addr_mask(otuple->src.l3num, rtuple->src.u3.all, 96 - info->dst_mask.all); 77 + t->src = hmark_addr_mask(otuple->src.l3num, otuple->src.u3.ip6, 78 + info->src_mask.ip6); 79 + t->dst = hmark_addr_mask(otuple->src.l3num, rtuple->src.u3.ip6, 80 + info->dst_mask.ip6); 97 81 98 82 if (info->flags & XT_HMARK_FLAG(XT_HMARK_METHOD_L3)) 99 83 return 0; 100 84 101 85 t->proto = nf_ct_protonum(ct); 102 86 if (t->proto != IPPROTO_ICMP) { 103 - t->uports.p16.src = otuple->src.u.all; 104 - t->uports.p16.dst = rtuple->src.u.all; 105 - t->uports.v32 = (t->uports.v32 & info->port_mask.v32) | 106 - info->port_set.v32; 107 - if (t->uports.p16.dst < t->uports.p16.src) 108 - swap(t->uports.p16.dst, t->uports.p16.src); 87 + t->uports.b16.src = otuple->src.u.all; 88 + t->uports.b16.dst = rtuple->src.u.all; 89 + hmark_swap_ports(&t->uports, info); 109 90 } 110 91 111 92 return 0; ··· 111 98 #endif 112 99 } 113 100 101 + /* This hash function is endian independent, to ensure consistent hashing if 102 + * the cluster is composed of big and little endian systems. */ 114 103 static inline u32 115 104 hmark_hash(struct hmark_tuple *t, const struct xt_hmark_info *info) 116 105 { 117 106 u32 hash; 107 + u32 src = ntohl(t->src); 108 + u32 dst = ntohl(t->dst); 118 109 119 - if (t->dst < t->src) 120 - swap(t->src, t->dst); 110 + if (dst < src) 111 + swap(src, dst); 121 112 122 - hash = jhash_3words(t->src, t->dst, t->uports.v32, info->hashrnd); 113 + hash = jhash_3words(src, dst, t->uports.v32, info->hashrnd); 123 114 hash = hash ^ (t->proto & info->proto_mask); 124 115 125 116 return (((u64)hash * info->hmodulus) >> 32) + info->hoffset; ··· 143 126 if (skb_copy_bits(skb, nhoff, &t->uports, sizeof(t->uports)) < 0) 144 127 return; 145 128 146 - t->uports.v32 = (t->uports.v32 & info->port_mask.v32) | 147 - info->port_set.v32; 148 - 149 - if (t->uports.p16.dst < t->uports.p16.src) 150 - swap(t->uports.p16.dst, t->uports.p16.src); 129 + hmark_swap_ports(&t->uports, info); 151 130 } 152 131 153 132 #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) ··· 191 178 return -1; 192 179 } 193 180 noicmp: 194 - t->src = hmark_addr6_mask(ip6->saddr.s6_addr32, info->src_mask.all); 195 - t->dst = hmark_addr6_mask(ip6->daddr.s6_addr32, info->dst_mask.all); 181 + t->src = hmark_addr6_mask(ip6->saddr.s6_addr32, info->src_mask.ip6); 182 + t->dst = hmark_addr6_mask(ip6->daddr.s6_addr32, info->dst_mask.ip6); 196 183 197 184 if (info->flags & XT_HMARK_FLAG(XT_HMARK_METHOD_L3)) 198 185 return 0; ··· 268 255 } 269 256 } 270 257 271 - t->src = (__force u32) ip->saddr; 272 - t->dst = (__force u32) ip->daddr; 273 - 274 - t->src &= info->src_mask.ip; 275 - t->dst &= info->dst_mask.ip; 258 + t->src = ip->saddr & info->src_mask.ip; 259 + t->dst = ip->daddr & info->dst_mask.ip; 276 260 277 261 if (info->flags & XT_HMARK_FLAG(XT_HMARK_METHOD_L3)) 278 262 return 0;
+3
net/nfc/llcp/sock.c
··· 292 292 293 293 pr_debug("%p\n", sk); 294 294 295 + if (llcp_sock == NULL) 296 + return -EBADFD; 297 + 295 298 addr->sa_family = AF_NFC; 296 299 *len = sizeof(struct sockaddr_nfc_llcp); 297 300
+5 -1
net/wireless/ibss.c
··· 42 42 cfg80211_hold_bss(bss_from_pub(bss)); 43 43 wdev->current_bss = bss_from_pub(bss); 44 44 45 + wdev->sme_state = CFG80211_SME_CONNECTED; 45 46 cfg80211_upload_connect_keys(wdev); 46 47 47 48 nl80211_send_ibss_bssid(wiphy_to_dev(wdev->wiphy), dev, bssid, ··· 61 60 struct cfg80211_event *ev; 62 61 unsigned long flags; 63 62 64 - CFG80211_DEV_WARN_ON(!wdev->ssid_len); 63 + CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING); 65 64 66 65 ev = kzalloc(sizeof(*ev), gfp); 67 66 if (!ev) ··· 116 115 #ifdef CONFIG_CFG80211_WEXT 117 116 wdev->wext.ibss.channel = params->channel; 118 117 #endif 118 + wdev->sme_state = CFG80211_SME_CONNECTING; 119 119 err = rdev->ops->join_ibss(&rdev->wiphy, dev, params); 120 120 if (err) { 121 121 wdev->connect_keys = NULL; 122 + wdev->sme_state = CFG80211_SME_IDLE; 122 123 return err; 123 124 } 124 125 ··· 172 169 } 173 170 174 171 wdev->current_bss = NULL; 172 + wdev->sme_state = CFG80211_SME_IDLE; 175 173 wdev->ssid_len = 0; 176 174 #ifdef CONFIG_CFG80211_WEXT 177 175 if (!nowext)
+18 -1
net/wireless/util.c
··· 935 935 enum nl80211_iftype iftype) 936 936 { 937 937 struct wireless_dev *wdev_iter; 938 + u32 used_iftypes = BIT(iftype); 938 939 int num[NUM_NL80211_IFTYPES]; 939 940 int total = 1; 940 941 int i, j; ··· 962 961 963 962 num[wdev_iter->iftype]++; 964 963 total++; 964 + used_iftypes |= BIT(wdev_iter->iftype); 965 965 } 966 966 mutex_unlock(&rdev->devlist_mtx); 967 967 ··· 972 970 for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) { 973 971 const struct ieee80211_iface_combination *c; 974 972 struct ieee80211_iface_limit *limits; 973 + u32 all_iftypes = 0; 975 974 976 975 c = &rdev->wiphy.iface_combinations[i]; 977 976 ··· 987 984 if (rdev->wiphy.software_iftypes & BIT(iftype)) 988 985 continue; 989 986 for (j = 0; j < c->n_limits; j++) { 987 + all_iftypes |= limits[j].types; 990 988 if (!(limits[j].types & BIT(iftype))) 991 989 continue; 992 990 if (limits[j].max < num[iftype]) ··· 995 991 limits[j].max -= num[iftype]; 996 992 } 997 993 } 998 - /* yay, it fits */ 994 + 995 + /* 996 + * Finally check that all iftypes that we're currently 997 + * using are actually part of this combination. If they 998 + * aren't then we can't use this combination and have 999 + * to continue to the next. 1000 + */ 1001 + if ((all_iftypes & used_iftypes) != used_iftypes) 1002 + goto cont; 1003 + 1004 + /* 1005 + * This combination covered all interface types and 1006 + * supported the requested numbers, so we're good. 1007 + */ 999 1008 kfree(limits); 1000 1009 return 0; 1001 1010 cont: