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

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

Pull networking fixes from David Miller:
"A moderately sized pile of fixes, some specifically for merge window
introduced regressions although others are for longer standing items
and have been queued up for -stable.

I'm kind of tired of all the RDS protocol bugs over the years, to be
honest, it's way out of proportion to the number of people who
actually use it.

1) Fix missing range initialization in netfilter IPSET, from Jozsef
Kadlecsik.

2) ieee80211_local->tim_lock needs to use BH disabling, from Johannes
Berg.

3) Fix DMA syncing in SFC driver, from Ben Hutchings.

4) Fix regression in BOND device MAC address setting, from Jiri
Pirko.

5) Missing usb_free_urb in ISDN Hisax driver, from Marina Makienko.

6) Fix UDP checksumming in bnx2x driver for 57710 and 57711 chips,
fix from Dmitry Kravkov.

7) Missing cfgspace_lock initialization in BCMA driver.

8) Validate parameter size for SCTP assoc stats getsockopt(), from
Guenter Roeck.

9) Fix SCTP association hangs, from Lee A Roberts.

10) Fix jumbo frame handling in r8169, from Francois Romieu.

11) Fix phy_device memory leak, from Petr Malat.

12) Omit trailing FCS from frames received in BGMAC driver, from Hauke
Mehrtens.

13) Missing socket refcount release in L2TP, from Guillaume Nault.

14) sctp_endpoint_init should respect passed in gfp_t, rather than use
GFP_KERNEL unconditionally. From Dan Carpenter.

15) Add AISX AX88179 USB driver, from Freddy Xin.

16) Remove MAINTAINERS entries for drivers deleted during the merge
window, from Cesar Eduardo Barros.

17) RDS protocol can try to allocate huge amounts of memory, check
that the user's request length makes sense, from Cong Wang.

18) SCTP should use the provided KMALLOC_MAX_SIZE instead of it's own,
bogus, definition. From Cong Wang.

19) Fix deadlocks in FEC driver by moving TX reclaim into NAPI poll,
from Frank Li. Also, fix a build error introduced in the merge
window.

20) Fix bogus purging of default routes in ipv6, from Lorenzo Colitti.

21) Don't double count RTT measurements when we leave the TCP receive
fast path, from Neal Cardwell."

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (61 commits)
tcp: fix double-counted receiver RTT when leaving receiver fast path
CAIF: fix sparse warning for caif_usb
rds: simplify a warning message
net: fec: fix build error in no MXC platform
net: ipv6: Don't purge default router if accept_ra=2
net: fec: put tx to napi poll function to fix dead lock
sctp: use KMALLOC_MAX_SIZE instead of its own MAX_KMALLOC_SIZE
rds: limit the size allocated by rds_message_alloc()
MAINTAINERS: remove eexpress
MAINTAINERS: remove drivers/net/wan/cycx*
MAINTAINERS: remove 3c505
caif_dev: fix sparse warnings for caif_flow_cb
ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver
sctp: use the passed in gfp flags instead GFP_KERNEL
ipv[4|6]: correct dropwatch false positive in local_deliver_finish
l2tp: Restore socket refcount when sendmsg succeeds
net/phy: micrel: Disable asymmetric pause for KSZ9021
bgmac: omit the fcs
phy: Fix phy_device_free memory leak
bnx2x: Fix KR2 work-around condition
...

+2084 -335
-18
MAINTAINERS
··· 114 114 115 115 ----------------------------------- 116 116 117 - 3C505 NETWORK DRIVER 118 - M: Philip Blundell <philb@gnu.org> 119 - L: netdev@vger.kernel.org 120 - S: Maintained 121 - F: drivers/net/ethernet/i825xx/3c505* 122 - 123 117 3C59X NETWORK DRIVER 124 118 M: Steffen Klassert <klassert@mathematik.tu-chemnitz.de> 125 119 L: netdev@vger.kernel.org ··· 2355 2361 S: Maintained 2356 2362 F: drivers/video/cyber2000fb.* 2357 2363 2358 - CYCLADES 2X SYNC CARD DRIVER 2359 - M: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> 2360 - W: http://oops.ghostprotocols.net:81/blog 2361 - S: Maintained 2362 - F: drivers/net/wan/cycx* 2363 - 2364 2364 CYCLADES ASYNC MUX DRIVER 2365 2365 W: http://www.cyclades.com/ 2366 2366 S: Orphan ··· 3054 3066 T: git git://git.kernel.org/pub/scm/linux/kernel/git/kristoffer/linux-hpc.git 3055 3067 F: drivers/video/s1d13xxxfb.c 3056 3068 F: include/video/s1d13xxxfb.h 3057 - 3058 - ETHEREXPRESS-16 NETWORK DRIVER 3059 - M: Philip Blundell <philb@gnu.org> 3060 - L: netdev@vger.kernel.org 3061 - S: Maintained 3062 - F: drivers/net/ethernet/i825xx/eexpress.* 3063 3069 3064 3070 ETHERNET BRIDGE 3065 3071 M: Stephen Hemminger <stephen@networkplumber.org>
+2
drivers/bcma/driver_pci_host.c
··· 404 404 return; 405 405 } 406 406 407 + spin_lock_init(&pc_host->cfgspace_lock); 408 + 407 409 pc->host_controller = pc_host; 408 410 pc_host->pci_controller.io_resource = &pc_host->io_resource; 409 411 pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
+8
drivers/connector/cn_proc.c
··· 313 313 (task_active_pid_ns(current) != &init_pid_ns)) 314 314 return; 315 315 316 + /* Can only change if privileged. */ 317 + if (!capable(CAP_NET_ADMIN)) { 318 + err = EPERM; 319 + goto out; 320 + } 321 + 316 322 mc_op = (enum proc_cn_mcast_op *)msg->data; 317 323 switch (*mc_op) { 318 324 case PROC_CN_MCAST_LISTEN: ··· 331 325 err = EINVAL; 332 326 break; 333 327 } 328 + 329 + out: 334 330 cn_proc_ack(err, msg->seq, msg->ack); 335 331 } 336 332
+10 -2
drivers/isdn/hisax/st5481_usb.c
··· 294 294 // Allocate URBs and buffers for interrupt endpoint 295 295 urb = usb_alloc_urb(0, GFP_KERNEL); 296 296 if (!urb) { 297 - return -ENOMEM; 297 + goto err1; 298 298 } 299 299 intr->urb = urb; 300 300 301 301 buf = kmalloc(INT_PKT_SIZE, GFP_KERNEL); 302 302 if (!buf) { 303 - return -ENOMEM; 303 + goto err2; 304 304 } 305 305 306 306 endpoint = &altsetting->endpoint[EP_INT-1]; ··· 313 313 endpoint->desc.bInterval); 314 314 315 315 return 0; 316 + err2: 317 + usb_free_urb(intr->urb); 318 + intr->urb = NULL; 319 + err1: 320 + usb_free_urb(ctrl->urb); 321 + ctrl->urb = NULL; 322 + 323 + return -ENOMEM; 316 324 } 317 325 318 326 /*
+1 -1
drivers/net/bonding/bond_main.c
··· 1629 1629 1630 1630 /* If this is the first slave, then we need to set the master's hardware 1631 1631 * address to be the same as the slave's. */ 1632 - if (bond->dev_addr_from_first) 1632 + if (bond->slave_cnt == 0 && bond->dev_addr_from_first) 1633 1633 bond_set_dev_addr(bond->dev, slave_dev); 1634 1634 1635 1635 new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL);
+4
drivers/net/ethernet/broadcom/bgmac.c
··· 301 301 bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n", 302 302 ring->start); 303 303 } else { 304 + /* Omit CRC. */ 305 + len -= ETH_FCS_LEN; 306 + 304 307 new_skb = netdev_alloc_skb_ip_align(bgmac->net_dev, len); 305 308 if (new_skb) { 306 309 skb_put(new_skb, len); 307 310 skb_copy_from_linear_data_offset(skb, BGMAC_RX_FRAME_OFFSET, 308 311 new_skb->data, 309 312 len); 313 + skb_checksum_none_assert(skb); 310 314 new_skb->protocol = 311 315 eth_type_trans(new_skb, bgmac->net_dev); 312 316 netif_receive_skb(new_skb);
+1 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
··· 3142 3142 tsum = ~csum_fold(csum_add((__force __wsum) csum, 3143 3143 csum_partial(t_header, -fix, 0))); 3144 3144 3145 - return bswab16(csum); 3145 + return bswab16(tsum); 3146 3146 } 3147 3147 3148 3148 static inline u32 bnx2x_xmit_type(struct bnx2x *bp, struct sk_buff *skb)
+6
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
··· 281 281 cmd->lp_advertising |= ADVERTISED_2500baseX_Full; 282 282 if (status & LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE) 283 283 cmd->lp_advertising |= ADVERTISED_10000baseT_Full; 284 + if (status & LINK_STATUS_LINK_PARTNER_20GXFD_CAPABLE) 285 + cmd->lp_advertising |= ADVERTISED_20000baseKR2_Full; 284 286 } 285 287 286 288 cmd->maxtxpkt = 0; ··· 465 463 ADVERTISED_10000baseKR_Full)) 466 464 bp->link_params.speed_cap_mask[cfg_idx] |= 467 465 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G; 466 + 467 + if (cmd->advertising & ADVERTISED_20000baseKR2_Full) 468 + bp->link_params.speed_cap_mask[cfg_idx] |= 469 + PORT_HW_CFG_SPEED_CAPABILITY_D0_20G; 468 470 } 469 471 } else { /* forced speed */ 470 472 /* advertise the requested speed and duplex if supported */
+63 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
··· 10422 10422 MDIO_PMA_DEVAD, 10423 10423 MDIO_PMA_REG_8481_LED1_MASK, 10424 10424 0x0); 10425 + if (phy->type == 10426 + PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84834) { 10427 + /* Disable MI_INT interrupt before setting LED4 10428 + * source to constant off. 10429 + */ 10430 + if (REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + 10431 + params->port*4) & 10432 + NIG_MASK_MI_INT) { 10433 + params->link_flags |= 10434 + LINK_FLAGS_INT_DISABLED; 10435 + 10436 + bnx2x_bits_dis( 10437 + bp, 10438 + NIG_REG_MASK_INTERRUPT_PORT0 + 10439 + params->port*4, 10440 + NIG_MASK_MI_INT); 10441 + } 10442 + bnx2x_cl45_write(bp, phy, 10443 + MDIO_PMA_DEVAD, 10444 + MDIO_PMA_REG_8481_SIGNAL_MASK, 10445 + 0x0); 10446 + } 10425 10447 } 10426 10448 break; 10427 10449 case LED_MODE_ON: ··· 10490 10468 MDIO_PMA_DEVAD, 10491 10469 MDIO_PMA_REG_8481_LED1_MASK, 10492 10470 0x20); 10471 + if (phy->type == 10472 + PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84834) { 10473 + /* Disable MI_INT interrupt before setting LED4 10474 + * source to constant on. 10475 + */ 10476 + if (REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + 10477 + params->port*4) & 10478 + NIG_MASK_MI_INT) { 10479 + params->link_flags |= 10480 + LINK_FLAGS_INT_DISABLED; 10481 + 10482 + bnx2x_bits_dis( 10483 + bp, 10484 + NIG_REG_MASK_INTERRUPT_PORT0 + 10485 + params->port*4, 10486 + NIG_MASK_MI_INT); 10487 + } 10488 + bnx2x_cl45_write(bp, phy, 10489 + MDIO_PMA_DEVAD, 10490 + MDIO_PMA_REG_8481_SIGNAL_MASK, 10491 + 0x20); 10492 + } 10493 10493 } 10494 10494 break; 10495 10495 ··· 10576 10532 MDIO_PMA_DEVAD, 10577 10533 MDIO_PMA_REG_8481_LINK_SIGNAL, 10578 10534 val); 10535 + if (phy->type == 10536 + PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84834) { 10537 + /* Restore LED4 source to external link, 10538 + * and re-enable interrupts. 10539 + */ 10540 + bnx2x_cl45_write(bp, phy, 10541 + MDIO_PMA_DEVAD, 10542 + MDIO_PMA_REG_8481_SIGNAL_MASK, 10543 + 0x40); 10544 + if (params->link_flags & 10545 + LINK_FLAGS_INT_DISABLED) { 10546 + bnx2x_link_int_enable(params); 10547 + params->link_flags &= 10548 + ~LINK_FLAGS_INT_DISABLED; 10549 + } 10550 + } 10579 10551 } 10580 10552 break; 10581 10553 } ··· 11851 11791 phy->media_type = ETH_PHY_KR; 11852 11792 phy->flags |= FLAGS_WC_DUAL_MODE; 11853 11793 phy->supported &= (SUPPORTED_20000baseKR2_Full | 11794 + SUPPORTED_10000baseT_Full | 11795 + SUPPORTED_1000baseT_Full | 11854 11796 SUPPORTED_Autoneg | 11855 11797 SUPPORTED_FIBRE | 11856 11798 SUPPORTED_Pause | ··· 13499 13437 struct bnx2x_phy *phy = &params->phy[INT_PHY]; 13500 13438 bnx2x_set_aer_mmd(params, phy); 13501 13439 if ((phy->supported & SUPPORTED_20000baseKR2_Full) && 13502 - (phy->speed_cap_mask & SPEED_20000)) 13440 + (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_20G)) 13503 13441 bnx2x_check_kr2_wa(params, vars, phy); 13504 13442 bnx2x_check_over_curr(params, vars); 13505 13443 if (vars->rx_tx_asic_rst)
+2 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
··· 307 307 struct bnx2x *bp; 308 308 u16 req_fc_auto_adv; /* Should be set to TX / BOTH when 309 309 req_flow_ctrl is set to AUTO */ 310 - u16 rsrv1; 310 + u16 link_flags; 311 + #define LINK_FLAGS_INT_DISABLED (1<<0) 311 312 u32 lfa_base; 312 313 }; 313 314
+42 -45
drivers/net/ethernet/freescale/fec.c
··· 246 246 struct bufdesc *bdp; 247 247 void *bufaddr; 248 248 unsigned short status; 249 - unsigned long flags; 249 + unsigned int index; 250 250 251 251 if (!fep->link) { 252 252 /* Link is down or autonegotiation is in progress. */ 253 253 return NETDEV_TX_BUSY; 254 254 } 255 255 256 - spin_lock_irqsave(&fep->hw_lock, flags); 257 256 /* Fill in a Tx ring entry */ 258 257 bdp = fep->cur_tx; 259 258 ··· 263 264 * This should not happen, since ndev->tbusy should be set. 264 265 */ 265 266 printk("%s: tx queue full!.\n", ndev->name); 266 - spin_unlock_irqrestore(&fep->hw_lock, flags); 267 267 return NETDEV_TX_BUSY; 268 268 } 269 269 ··· 278 280 * 4-byte boundaries. Use bounce buffers to copy data 279 281 * and get it aligned. Ugh. 280 282 */ 283 + if (fep->bufdesc_ex) 284 + index = (struct bufdesc_ex *)bdp - 285 + (struct bufdesc_ex *)fep->tx_bd_base; 286 + else 287 + index = bdp - fep->tx_bd_base; 288 + 281 289 if (((unsigned long) bufaddr) & FEC_ALIGNMENT) { 282 - unsigned int index; 283 - if (fep->bufdesc_ex) 284 - index = (struct bufdesc_ex *)bdp - 285 - (struct bufdesc_ex *)fep->tx_bd_base; 286 - else 287 - index = bdp - fep->tx_bd_base; 288 290 memcpy(fep->tx_bounce[index], skb->data, skb->len); 289 291 bufaddr = fep->tx_bounce[index]; 290 292 } ··· 298 300 swap_buffer(bufaddr, skb->len); 299 301 300 302 /* Save skb pointer */ 301 - fep->tx_skbuff[fep->skb_cur] = skb; 302 - 303 - ndev->stats.tx_bytes += skb->len; 304 - fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK; 303 + fep->tx_skbuff[index] = skb; 305 304 306 305 /* Push the data cache so the CPM does not get stale memory 307 306 * data. ··· 326 331 ebdp->cbd_esc = BD_ENET_TX_INT; 327 332 } 328 333 } 329 - /* Trigger transmission start */ 330 - writel(0, fep->hwp + FEC_X_DES_ACTIVE); 331 - 332 334 /* If this was the last BD in the ring, start at the beginning again. */ 333 335 if (status & BD_ENET_TX_WRAP) 334 336 bdp = fep->tx_bd_base; 335 337 else 336 338 bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex); 337 339 338 - if (bdp == fep->dirty_tx) { 339 - fep->tx_full = 1; 340 - netif_stop_queue(ndev); 341 - } 342 - 343 340 fep->cur_tx = bdp; 344 341 345 - skb_tx_timestamp(skb); 342 + if (fep->cur_tx == fep->dirty_tx) 343 + netif_stop_queue(ndev); 346 344 347 - spin_unlock_irqrestore(&fep->hw_lock, flags); 345 + /* Trigger transmission start */ 346 + writel(0, fep->hwp + FEC_X_DES_ACTIVE); 347 + 348 + skb_tx_timestamp(skb); 348 349 349 350 return NETDEV_TX_OK; 350 351 } ··· 397 406 writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc) 398 407 * RX_RING_SIZE, fep->hwp + FEC_X_DES_START); 399 408 400 - fep->dirty_tx = fep->cur_tx = fep->tx_bd_base; 401 409 fep->cur_rx = fep->rx_bd_base; 402 410 403 - /* Reset SKB transmit buffers. */ 404 - fep->skb_cur = fep->skb_dirty = 0; 405 411 for (i = 0; i <= TX_RING_MOD_MASK; i++) { 406 412 if (fep->tx_skbuff[i]) { 407 413 dev_kfree_skb_any(fep->tx_skbuff[i]); ··· 561 573 struct bufdesc *bdp; 562 574 unsigned short status; 563 575 struct sk_buff *skb; 576 + int index = 0; 564 577 565 578 fep = netdev_priv(ndev); 566 - spin_lock(&fep->hw_lock); 567 579 bdp = fep->dirty_tx; 568 580 581 + /* get next bdp of dirty_tx */ 582 + if (bdp->cbd_sc & BD_ENET_TX_WRAP) 583 + bdp = fep->tx_bd_base; 584 + else 585 + bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex); 586 + 569 587 while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) { 570 - if (bdp == fep->cur_tx && fep->tx_full == 0) 588 + 589 + /* current queue is empty */ 590 + if (bdp == fep->cur_tx) 571 591 break; 592 + 593 + if (fep->bufdesc_ex) 594 + index = (struct bufdesc_ex *)bdp - 595 + (struct bufdesc_ex *)fep->tx_bd_base; 596 + else 597 + index = bdp - fep->tx_bd_base; 572 598 573 599 dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, 574 600 FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); 575 601 bdp->cbd_bufaddr = 0; 576 602 577 - skb = fep->tx_skbuff[fep->skb_dirty]; 603 + skb = fep->tx_skbuff[index]; 604 + 578 605 /* Check for errors. */ 579 606 if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | 580 607 BD_ENET_TX_RL | BD_ENET_TX_UN | ··· 634 631 635 632 /* Free the sk buffer associated with this last transmit */ 636 633 dev_kfree_skb_any(skb); 637 - fep->tx_skbuff[fep->skb_dirty] = NULL; 638 - fep->skb_dirty = (fep->skb_dirty + 1) & TX_RING_MOD_MASK; 634 + fep->tx_skbuff[index] = NULL; 635 + 636 + fep->dirty_tx = bdp; 639 637 640 638 /* Update pointer to next buffer descriptor to be transmitted */ 641 639 if (status & BD_ENET_TX_WRAP) ··· 646 642 647 643 /* Since we have freed up a buffer, the ring is no longer full 648 644 */ 649 - if (fep->tx_full) { 650 - fep->tx_full = 0; 645 + if (fep->dirty_tx != fep->cur_tx) { 651 646 if (netif_queue_stopped(ndev)) 652 647 netif_wake_queue(ndev); 653 648 } 654 649 } 655 - fep->dirty_tx = bdp; 656 - spin_unlock(&fep->hw_lock); 650 + return; 657 651 } 658 652 659 653 ··· 818 816 int_events = readl(fep->hwp + FEC_IEVENT); 819 817 writel(int_events, fep->hwp + FEC_IEVENT); 820 818 821 - if (int_events & FEC_ENET_RXF) { 819 + if (int_events & (FEC_ENET_RXF | FEC_ENET_TXF)) { 822 820 ret = IRQ_HANDLED; 823 821 824 822 /* Disable the RX interrupt */ ··· 827 825 fep->hwp + FEC_IMASK); 828 826 __napi_schedule(&fep->napi); 829 827 } 830 - } 831 - 832 - /* Transmit OK, or non-fatal error. Update the buffer 833 - * descriptors. FEC handles all errors, we just discover 834 - * them as part of the transmit process. 835 - */ 836 - if (int_events & FEC_ENET_TXF) { 837 - ret = IRQ_HANDLED; 838 - fec_enet_tx(ndev); 839 828 } 840 829 841 830 if (int_events & FEC_ENET_MII) { ··· 843 850 struct net_device *ndev = napi->dev; 844 851 int pkts = fec_enet_rx(ndev, budget); 845 852 struct fec_enet_private *fep = netdev_priv(ndev); 853 + 854 + fec_enet_tx(ndev); 846 855 847 856 if (pkts < budget) { 848 857 napi_complete(napi); ··· 1641 1646 1642 1647 /* ...and the same for transmit */ 1643 1648 bdp = fep->tx_bd_base; 1649 + fep->cur_tx = bdp; 1644 1650 for (i = 0; i < TX_RING_SIZE; i++) { 1645 1651 1646 1652 /* Initialize the BD for every fragment in the page. */ ··· 1653 1657 /* Set the last buffer to wrap */ 1654 1658 bdp = fec_enet_get_prevdesc(bdp, fep->bufdesc_ex); 1655 1659 bdp->cbd_sc |= BD_SC_WRAP; 1660 + fep->dirty_tx = bdp; 1656 1661 1657 1662 fec_restart(ndev, 0); 1658 1663
+7 -11
drivers/net/ethernet/freescale/fec.h
··· 97 97 unsigned short cbd_sc; /* Control and status info */ 98 98 unsigned long cbd_bufaddr; /* Buffer address */ 99 99 }; 100 + #else 101 + struct bufdesc { 102 + unsigned short cbd_sc; /* Control and status info */ 103 + unsigned short cbd_datlen; /* Data length */ 104 + unsigned long cbd_bufaddr; /* Buffer address */ 105 + }; 106 + #endif 100 107 101 108 struct bufdesc_ex { 102 109 struct bufdesc desc; ··· 113 106 unsigned long ts; 114 107 unsigned short res0[4]; 115 108 }; 116 - 117 - #else 118 - struct bufdesc { 119 - unsigned short cbd_sc; /* Control and status info */ 120 - unsigned short cbd_datlen; /* Data length */ 121 - unsigned long cbd_bufaddr; /* Buffer address */ 122 - }; 123 - #endif 124 109 125 110 /* 126 111 * The following definitions courtesy of commproc.h, which where ··· 213 214 unsigned char *tx_bounce[TX_RING_SIZE]; 214 215 struct sk_buff *tx_skbuff[TX_RING_SIZE]; 215 216 struct sk_buff *rx_skbuff[RX_RING_SIZE]; 216 - ushort skb_cur; 217 - ushort skb_dirty; 218 217 219 218 /* CPM dual port RAM relative addresses */ 220 219 dma_addr_t bd_dma; ··· 224 227 /* The ring entries to be free()ed */ 225 228 struct bufdesc *dirty_tx; 226 229 227 - uint tx_full; 228 230 /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */ 229 231 spinlock_t hw_lock; 230 232
+18 -9
drivers/net/ethernet/realtek/r8169.c
··· 4765 4765 4766 4766 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4767 4767 4768 - rtl_tx_performance_tweak(pdev, 4769 - (0x5 << MAX_READ_REQUEST_SHIFT) | PCI_EXP_DEVCTL_NOSNOOP_EN); 4768 + if (tp->dev->mtu <= ETH_DATA_LEN) { 4769 + rtl_tx_performance_tweak(pdev, (0x5 << MAX_READ_REQUEST_SHIFT) | 4770 + PCI_EXP_DEVCTL_NOSNOOP_EN); 4771 + } 4770 4772 } 4771 4773 4772 4774 static void rtl_hw_start_8168bef(struct rtl8169_private *tp) ··· 4791 4789 4792 4790 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); 4793 4791 4794 - rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4792 + if (tp->dev->mtu <= ETH_DATA_LEN) 4793 + rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4795 4794 4796 4795 rtl_disable_clock_request(pdev); 4797 4796 ··· 4825 4822 4826 4823 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); 4827 4824 4828 - rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4825 + if (tp->dev->mtu <= ETH_DATA_LEN) 4826 + rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4829 4827 4830 4828 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4831 4829 } ··· 4845 4841 4846 4842 RTL_W8(MaxTxPacketSize, TxPacketMax); 4847 4843 4848 - rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4844 + if (tp->dev->mtu <= ETH_DATA_LEN) 4845 + rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4849 4846 4850 4847 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4851 4848 } ··· 4906 4901 4907 4902 RTL_W8(MaxTxPacketSize, TxPacketMax); 4908 4903 4909 - rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4904 + if (tp->dev->mtu <= ETH_DATA_LEN) 4905 + rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4910 4906 4911 4907 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4912 4908 } ··· 4919 4913 4920 4914 rtl_csi_access_enable_1(tp); 4921 4915 4922 - rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4916 + if (tp->dev->mtu <= ETH_DATA_LEN) 4917 + rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4923 4918 4924 4919 RTL_W8(MaxTxPacketSize, TxPacketMax); 4925 4920 ··· 4979 4972 4980 4973 rtl_ephy_init(tp, e_info_8168e_1, ARRAY_SIZE(e_info_8168e_1)); 4981 4974 4982 - rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4975 + if (tp->dev->mtu <= ETH_DATA_LEN) 4976 + rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4983 4977 4984 4978 RTL_W8(MaxTxPacketSize, TxPacketMax); 4985 4979 ··· 5006 4998 5007 4999 rtl_ephy_init(tp, e_info_8168e_2, ARRAY_SIZE(e_info_8168e_2)); 5008 5000 5009 - rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 5001 + if (tp->dev->mtu <= ETH_DATA_LEN) 5002 + rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 5010 5003 5011 5004 rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); 5012 5005 rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
+12 -4
drivers/net/ethernet/sfc/efx.c
··· 779 779 tx_queue->txd.entries); 780 780 } 781 781 782 + efx_device_detach_sync(efx); 782 783 efx_stop_all(efx); 783 784 efx_stop_interrupts(efx, true); 784 785 ··· 833 832 834 833 efx_start_interrupts(efx, true); 835 834 efx_start_all(efx); 835 + netif_device_attach(efx->net_dev); 836 836 return rc; 837 837 838 838 rollback: ··· 1643 1641 /* Flush efx_mac_work(), refill_workqueue, monitor_work */ 1644 1642 efx_flush_all(efx); 1645 1643 1646 - /* Stop the kernel transmit interface late, so the watchdog 1647 - * timer isn't ticking over the flush */ 1644 + /* Stop the kernel transmit interface. This is only valid if 1645 + * the device is stopped or detached; otherwise the watchdog 1646 + * may fire immediately. 1647 + */ 1648 + WARN_ON(netif_running(efx->net_dev) && 1649 + netif_device_present(efx->net_dev)); 1648 1650 netif_tx_disable(efx->net_dev); 1649 1651 1650 1652 efx_stop_datapath(efx); ··· 1969 1963 if (new_mtu > EFX_MAX_MTU) 1970 1964 return -EINVAL; 1971 1965 1972 - efx_stop_all(efx); 1973 - 1974 1966 netif_dbg(efx, drv, efx->net_dev, "changing MTU to %d\n", new_mtu); 1967 + 1968 + efx_device_detach_sync(efx); 1969 + efx_stop_all(efx); 1975 1970 1976 1971 mutex_lock(&efx->mac_lock); 1977 1972 net_dev->mtu = new_mtu; ··· 1980 1973 mutex_unlock(&efx->mac_lock); 1981 1974 1982 1975 efx_start_all(efx); 1976 + netif_device_attach(efx->net_dev); 1983 1977 return 0; 1984 1978 } 1985 1979
+3 -1
drivers/net/ethernet/sfc/net_driver.h
··· 210 210 * Will be %NULL if the buffer slot is currently free. 211 211 * @page: The associated page buffer. Valif iff @flags & %EFX_RX_BUF_PAGE. 212 212 * Will be %NULL if the buffer slot is currently free. 213 + * @page_offset: Offset within page. Valid iff @flags & %EFX_RX_BUF_PAGE. 213 214 * @len: Buffer length, in bytes. 214 215 * @flags: Flags for buffer and packet state. 215 216 */ ··· 220 219 struct sk_buff *skb; 221 220 struct page *page; 222 221 } u; 223 - unsigned int len; 222 + u16 page_offset; 223 + u16 len; 224 224 u16 flags; 225 225 }; 226 226 #define EFX_RX_BUF_PAGE 0x0001
+15 -10
drivers/net/ethernet/sfc/rx.c
··· 90 90 static inline unsigned int efx_rx_buf_offset(struct efx_nic *efx, 91 91 struct efx_rx_buffer *buf) 92 92 { 93 - /* Offset is always within one page, so we don't need to consider 94 - * the page order. 95 - */ 96 - return ((unsigned int) buf->dma_addr & (PAGE_SIZE - 1)) + 97 - efx->type->rx_buffer_hash_size; 93 + return buf->page_offset + efx->type->rx_buffer_hash_size; 98 94 } 99 95 static inline unsigned int efx_rx_buf_size(struct efx_nic *efx) 100 96 { ··· 183 187 struct efx_nic *efx = rx_queue->efx; 184 188 struct efx_rx_buffer *rx_buf; 185 189 struct page *page; 190 + unsigned int page_offset; 186 191 struct efx_rx_page_state *state; 187 192 dma_addr_t dma_addr; 188 193 unsigned index, count; ··· 208 211 state->dma_addr = dma_addr; 209 212 210 213 dma_addr += sizeof(struct efx_rx_page_state); 214 + page_offset = sizeof(struct efx_rx_page_state); 211 215 212 216 split: 213 217 index = rx_queue->added_count & rx_queue->ptr_mask; 214 218 rx_buf = efx_rx_buffer(rx_queue, index); 215 219 rx_buf->dma_addr = dma_addr + EFX_PAGE_IP_ALIGN; 216 220 rx_buf->u.page = page; 221 + rx_buf->page_offset = page_offset; 217 222 rx_buf->len = efx->rx_buffer_len - EFX_PAGE_IP_ALIGN; 218 223 rx_buf->flags = EFX_RX_BUF_PAGE; 219 224 ++rx_queue->added_count; ··· 226 227 /* Use the second half of the page */ 227 228 get_page(page); 228 229 dma_addr += (PAGE_SIZE >> 1); 230 + page_offset += (PAGE_SIZE >> 1); 229 231 ++count; 230 232 goto split; 231 233 } ··· 236 236 } 237 237 238 238 static void efx_unmap_rx_buffer(struct efx_nic *efx, 239 - struct efx_rx_buffer *rx_buf) 239 + struct efx_rx_buffer *rx_buf, 240 + unsigned int used_len) 240 241 { 241 242 if ((rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.page) { 242 243 struct efx_rx_page_state *state; ··· 248 247 state->dma_addr, 249 248 efx_rx_buf_size(efx), 250 249 DMA_FROM_DEVICE); 250 + } else if (used_len) { 251 + dma_sync_single_for_cpu(&efx->pci_dev->dev, 252 + rx_buf->dma_addr, used_len, 253 + DMA_FROM_DEVICE); 251 254 } 252 255 } else if (!(rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.skb) { 253 256 dma_unmap_single(&efx->pci_dev->dev, rx_buf->dma_addr, ··· 274 269 static void efx_fini_rx_buffer(struct efx_rx_queue *rx_queue, 275 270 struct efx_rx_buffer *rx_buf) 276 271 { 277 - efx_unmap_rx_buffer(rx_queue->efx, rx_buf); 272 + efx_unmap_rx_buffer(rx_queue->efx, rx_buf, 0); 278 273 efx_free_rx_buffer(rx_queue->efx, rx_buf); 279 274 } 280 275 ··· 540 535 goto out; 541 536 } 542 537 543 - /* Release card resources - assumes all RX buffers consumed in-order 544 - * per RX queue 538 + /* Release and/or sync DMA mapping - assumes all RX buffers 539 + * consumed in-order per RX queue 545 540 */ 546 - efx_unmap_rx_buffer(efx, rx_buf); 541 + efx_unmap_rx_buffer(efx, rx_buf, len); 547 542 548 543 /* Prefetch nice and early so data will (hopefully) be in cache by 549 544 * the time we look at it.
+1 -1
drivers/net/ethernet/ti/cpsw.c
··· 731 731 732 732 writel(vlan, &priv->host_port_regs->port_vlan); 733 733 734 - for (i = 0; i < 2; i++) 734 + for (i = 0; i < priv->data.slaves; i++) 735 735 slave_write(priv->slaves + i, vlan, reg); 736 736 737 737 cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port,
+1 -2
drivers/net/phy/micrel.c
··· 257 257 .phy_id = PHY_ID_KSZ9021, 258 258 .phy_id_mask = 0x000ffffe, 259 259 .name = "Micrel KSZ9021 Gigabit PHY", 260 - .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause 261 - | SUPPORTED_Asym_Pause), 260 + .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause), 262 261 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 263 262 .config_init = kszphy_config_init, 264 263 .config_aneg = genphy_config_aneg,
+6 -4
drivers/net/phy/phy_device.c
··· 44 44 45 45 void phy_device_free(struct phy_device *phydev) 46 46 { 47 - kfree(phydev); 47 + put_device(&phydev->dev); 48 48 } 49 49 EXPORT_SYMBOL(phy_device_free); 50 50 51 51 static void phy_device_release(struct device *dev) 52 52 { 53 - phy_device_free(to_phy_device(dev)); 53 + kfree(to_phy_device(dev)); 54 54 } 55 55 56 56 static struct phy_driver genphy_driver; ··· 200 200 driver will get bored and give up as soon as it finds that 201 201 there's no driver _already_ loaded. */ 202 202 request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT, MDIO_ID_ARGS(phy_id)); 203 + 204 + device_initialize(&dev->dev); 203 205 204 206 return dev; 205 207 } ··· 365 363 /* Run all of the fixups for this PHY */ 366 364 phy_scan_fixups(phydev); 367 365 368 - err = device_register(&phydev->dev); 366 + err = device_add(&phydev->dev); 369 367 if (err) { 370 - pr_err("phy %d failed to register\n", phydev->addr); 368 + pr_err("PHY %d failed to add\n", phydev->addr); 371 369 goto out; 372 370 } 373 371
+18
drivers/net/usb/Kconfig
··· 156 156 This driver creates an interface named "ethX", where X depends on 157 157 what other networking devices you have in use. 158 158 159 + config USB_NET_AX88179_178A 160 + tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet" 161 + depends on USB_USBNET 162 + select CRC32 163 + select PHYLIB 164 + default y 165 + help 166 + This option adds support for ASIX AX88179 based USB 3.0/2.0 167 + to Gigabit Ethernet adapters. 168 + 169 + This driver should work with at least the following devices: 170 + * ASIX AX88179 171 + * ASIX AX88178A 172 + * Sitcomm LN-032 173 + 174 + This driver creates an interface named "ethX", where X depends on 175 + what other networking devices you have in use. 176 + 159 177 config USB_NET_CDCETHER 160 178 tristate "CDC Ethernet support (smart devices such as cable modems)" 161 179 depends on USB_USBNET
+1
drivers/net/usb/Makefile
··· 9 9 obj-$(CONFIG_USB_HSO) += hso.o 10 10 obj-$(CONFIG_USB_NET_AX8817X) += asix.o 11 11 asix-y := asix_devices.o asix_common.o ax88172a.o 12 + obj-$(CONFIG_USB_NET_AX88179_178A) += ax88179_178a.o 12 13 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o 13 14 obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o 14 15 obj-$(CONFIG_USB_NET_DM9601) += dm9601.o
+31
drivers/net/usb/asix_devices.c
··· 924 924 .tx_fixup = asix_tx_fixup, 925 925 }; 926 926 927 + /* 928 + * USBLINK 20F9 "USB 2.0 LAN" USB ethernet adapter, typically found in 929 + * no-name packaging. 930 + * USB device strings are: 931 + * 1: Manufacturer: USBLINK 932 + * 2: Product: HG20F9 USB2.0 933 + * 3: Serial: 000003 934 + * Appears to be compatible with Asix 88772B. 935 + */ 936 + static const struct driver_info hg20f9_info = { 937 + .description = "HG20F9 USB 2.0 Ethernet", 938 + .bind = ax88772_bind, 939 + .unbind = ax88772_unbind, 940 + .status = asix_status, 941 + .link_reset = ax88772_link_reset, 942 + .reset = ax88772_reset, 943 + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | 944 + FLAG_MULTI_PACKET, 945 + .rx_fixup = asix_rx_fixup_common, 946 + .tx_fixup = asix_tx_fixup, 947 + .data = FLAG_EEPROM_MAC, 948 + }; 949 + 927 950 extern const struct driver_info ax88172a_info; 928 951 929 952 static const struct usb_device_id products [] = { ··· 1086 1063 /* ASIX 88172a demo board */ 1087 1064 USB_DEVICE(0x0b95, 0x172a), 1088 1065 .driver_info = (unsigned long) &ax88172a_info, 1066 + }, { 1067 + /* 1068 + * USBLINK HG20F9 "USB 2.0 LAN" 1069 + * Appears to have gazumped Linksys's manufacturer ID but 1070 + * doesn't (yet) conflict with any known Linksys product. 1071 + */ 1072 + USB_DEVICE(0x066b, 0x20f9), 1073 + .driver_info = (unsigned long) &hg20f9_info, 1089 1074 }, 1090 1075 { }, // END 1091 1076 };
+1448
drivers/net/usb/ax88179_178a.c
··· 1 + /* 2 + * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices 3 + * 4 + * Copyright (C) 2011-2013 ASIX 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License 8 + * as published by the Free Software Foundation; either version 2 9 + * of the License, or (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, write to the Free Software 18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 + */ 20 + 21 + #include <linux/module.h> 22 + #include <linux/etherdevice.h> 23 + #include <linux/mii.h> 24 + #include <linux/usb.h> 25 + #include <linux/crc32.h> 26 + #include <linux/usb/usbnet.h> 27 + 28 + #define AX88179_PHY_ID 0x03 29 + #define AX_EEPROM_LEN 0x100 30 + #define AX88179_EEPROM_MAGIC 0x17900b95 31 + #define AX_MCAST_FLTSIZE 8 32 + #define AX_MAX_MCAST 64 33 + #define AX_INT_PPLS_LINK ((u32)BIT(16)) 34 + #define AX_RXHDR_L4_TYPE_MASK 0x1c 35 + #define AX_RXHDR_L4_TYPE_UDP 4 36 + #define AX_RXHDR_L4_TYPE_TCP 16 37 + #define AX_RXHDR_L3CSUM_ERR 2 38 + #define AX_RXHDR_L4CSUM_ERR 1 39 + #define AX_RXHDR_CRC_ERR ((u32)BIT(31)) 40 + #define AX_RXHDR_DROP_ERR ((u32)BIT(30)) 41 + #define AX_ACCESS_MAC 0x01 42 + #define AX_ACCESS_PHY 0x02 43 + #define AX_ACCESS_EEPROM 0x04 44 + #define AX_ACCESS_EFUS 0x05 45 + #define AX_PAUSE_WATERLVL_HIGH 0x54 46 + #define AX_PAUSE_WATERLVL_LOW 0x55 47 + 48 + #define PHYSICAL_LINK_STATUS 0x02 49 + #define AX_USB_SS 0x04 50 + #define AX_USB_HS 0x02 51 + 52 + #define GENERAL_STATUS 0x03 53 + /* Check AX88179 version. UA1:Bit2 = 0, UA2:Bit2 = 1 */ 54 + #define AX_SECLD 0x04 55 + 56 + #define AX_SROM_ADDR 0x07 57 + #define AX_SROM_CMD 0x0a 58 + #define EEP_RD 0x04 59 + #define EEP_BUSY 0x10 60 + 61 + #define AX_SROM_DATA_LOW 0x08 62 + #define AX_SROM_DATA_HIGH 0x09 63 + 64 + #define AX_RX_CTL 0x0b 65 + #define AX_RX_CTL_DROPCRCERR 0x0100 66 + #define AX_RX_CTL_IPE 0x0200 67 + #define AX_RX_CTL_START 0x0080 68 + #define AX_RX_CTL_AP 0x0020 69 + #define AX_RX_CTL_AM 0x0010 70 + #define AX_RX_CTL_AB 0x0008 71 + #define AX_RX_CTL_AMALL 0x0002 72 + #define AX_RX_CTL_PRO 0x0001 73 + #define AX_RX_CTL_STOP 0x0000 74 + 75 + #define AX_NODE_ID 0x10 76 + #define AX_MULFLTARY 0x16 77 + 78 + #define AX_MEDIUM_STATUS_MODE 0x22 79 + #define AX_MEDIUM_GIGAMODE 0x01 80 + #define AX_MEDIUM_FULL_DUPLEX 0x02 81 + #define AX_MEDIUM_ALWAYS_ONE 0x04 82 + #define AX_MEDIUM_EN_125MHZ 0x08 83 + #define AX_MEDIUM_RXFLOW_CTRLEN 0x10 84 + #define AX_MEDIUM_TXFLOW_CTRLEN 0x20 85 + #define AX_MEDIUM_RECEIVE_EN 0x100 86 + #define AX_MEDIUM_PS 0x200 87 + #define AX_MEDIUM_JUMBO_EN 0x8040 88 + 89 + #define AX_MONITOR_MOD 0x24 90 + #define AX_MONITOR_MODE_RWLC 0x02 91 + #define AX_MONITOR_MODE_RWMP 0x04 92 + #define AX_MONITOR_MODE_PMEPOL 0x20 93 + #define AX_MONITOR_MODE_PMETYPE 0x40 94 + 95 + #define AX_GPIO_CTRL 0x25 96 + #define AX_GPIO_CTRL_GPIO3EN 0x80 97 + #define AX_GPIO_CTRL_GPIO2EN 0x40 98 + #define AX_GPIO_CTRL_GPIO1EN 0x20 99 + 100 + #define AX_PHYPWR_RSTCTL 0x26 101 + #define AX_PHYPWR_RSTCTL_BZ 0x0010 102 + #define AX_PHYPWR_RSTCTL_IPRL 0x0020 103 + #define AX_PHYPWR_RSTCTL_AT 0x1000 104 + 105 + #define AX_RX_BULKIN_QCTRL 0x2e 106 + #define AX_CLK_SELECT 0x33 107 + #define AX_CLK_SELECT_BCS 0x01 108 + #define AX_CLK_SELECT_ACS 0x02 109 + #define AX_CLK_SELECT_ULR 0x08 110 + 111 + #define AX_RXCOE_CTL 0x34 112 + #define AX_RXCOE_IP 0x01 113 + #define AX_RXCOE_TCP 0x02 114 + #define AX_RXCOE_UDP 0x04 115 + #define AX_RXCOE_TCPV6 0x20 116 + #define AX_RXCOE_UDPV6 0x40 117 + 118 + #define AX_TXCOE_CTL 0x35 119 + #define AX_TXCOE_IP 0x01 120 + #define AX_TXCOE_TCP 0x02 121 + #define AX_TXCOE_UDP 0x04 122 + #define AX_TXCOE_TCPV6 0x20 123 + #define AX_TXCOE_UDPV6 0x40 124 + 125 + #define AX_LEDCTRL 0x73 126 + 127 + #define GMII_PHY_PHYSR 0x11 128 + #define GMII_PHY_PHYSR_SMASK 0xc000 129 + #define GMII_PHY_PHYSR_GIGA 0x8000 130 + #define GMII_PHY_PHYSR_100 0x4000 131 + #define GMII_PHY_PHYSR_FULL 0x2000 132 + #define GMII_PHY_PHYSR_LINK 0x400 133 + 134 + #define GMII_LED_ACT 0x1a 135 + #define GMII_LED_ACTIVE_MASK 0xff8f 136 + #define GMII_LED0_ACTIVE BIT(4) 137 + #define GMII_LED1_ACTIVE BIT(5) 138 + #define GMII_LED2_ACTIVE BIT(6) 139 + 140 + #define GMII_LED_LINK 0x1c 141 + #define GMII_LED_LINK_MASK 0xf888 142 + #define GMII_LED0_LINK_10 BIT(0) 143 + #define GMII_LED0_LINK_100 BIT(1) 144 + #define GMII_LED0_LINK_1000 BIT(2) 145 + #define GMII_LED1_LINK_10 BIT(4) 146 + #define GMII_LED1_LINK_100 BIT(5) 147 + #define GMII_LED1_LINK_1000 BIT(6) 148 + #define GMII_LED2_LINK_10 BIT(8) 149 + #define GMII_LED2_LINK_100 BIT(9) 150 + #define GMII_LED2_LINK_1000 BIT(10) 151 + #define LED0_ACTIVE BIT(0) 152 + #define LED0_LINK_10 BIT(1) 153 + #define LED0_LINK_100 BIT(2) 154 + #define LED0_LINK_1000 BIT(3) 155 + #define LED0_FD BIT(4) 156 + #define LED0_USB3_MASK 0x001f 157 + #define LED1_ACTIVE BIT(5) 158 + #define LED1_LINK_10 BIT(6) 159 + #define LED1_LINK_100 BIT(7) 160 + #define LED1_LINK_1000 BIT(8) 161 + #define LED1_FD BIT(9) 162 + #define LED1_USB3_MASK 0x03e0 163 + #define LED2_ACTIVE BIT(10) 164 + #define LED2_LINK_1000 BIT(13) 165 + #define LED2_LINK_100 BIT(12) 166 + #define LED2_LINK_10 BIT(11) 167 + #define LED2_FD BIT(14) 168 + #define LED_VALID BIT(15) 169 + #define LED2_USB3_MASK 0x7c00 170 + 171 + #define GMII_PHYPAGE 0x1e 172 + #define GMII_PHY_PAGE_SELECT 0x1f 173 + #define GMII_PHY_PGSEL_EXT 0x0007 174 + #define GMII_PHY_PGSEL_PAGE0 0x0000 175 + 176 + struct ax88179_data { 177 + u16 rxctl; 178 + u16 reserved; 179 + }; 180 + 181 + struct ax88179_int_data { 182 + __le32 intdata1; 183 + __le32 intdata2; 184 + }; 185 + 186 + static const struct { 187 + unsigned char ctrl, timer_l, timer_h, size, ifg; 188 + } AX88179_BULKIN_SIZE[] = { 189 + {7, 0x4f, 0, 0x12, 0xff}, 190 + {7, 0x20, 3, 0x16, 0xff}, 191 + {7, 0xae, 7, 0x18, 0xff}, 192 + {7, 0xcc, 0x4c, 0x18, 8}, 193 + }; 194 + 195 + static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 196 + u16 size, void *data, int in_pm) 197 + { 198 + int ret; 199 + int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); 200 + 201 + BUG_ON(!dev); 202 + 203 + if (!in_pm) 204 + fn = usbnet_read_cmd; 205 + else 206 + fn = usbnet_read_cmd_nopm; 207 + 208 + ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 209 + value, index, data, size); 210 + 211 + if (unlikely(ret < 0)) 212 + netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", 213 + index, ret); 214 + 215 + return ret; 216 + } 217 + 218 + static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 219 + u16 size, void *data, int in_pm) 220 + { 221 + int ret; 222 + int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); 223 + 224 + BUG_ON(!dev); 225 + 226 + if (!in_pm) 227 + fn = usbnet_write_cmd; 228 + else 229 + fn = usbnet_write_cmd_nopm; 230 + 231 + ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 232 + value, index, data, size); 233 + 234 + if (unlikely(ret < 0)) 235 + netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n", 236 + index, ret); 237 + 238 + return ret; 239 + } 240 + 241 + static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, 242 + u16 index, u16 size, void *data) 243 + { 244 + u16 buf; 245 + 246 + if (2 == size) { 247 + buf = *((u16 *)data); 248 + cpu_to_le16s(&buf); 249 + usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | 250 + USB_RECIP_DEVICE, value, index, &buf, 251 + size); 252 + } else { 253 + usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | 254 + USB_RECIP_DEVICE, value, index, data, 255 + size); 256 + } 257 + } 258 + 259 + static int ax88179_read_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, 260 + u16 index, u16 size, void *data) 261 + { 262 + int ret; 263 + 264 + if (2 == size) { 265 + u16 buf; 266 + ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 1); 267 + le16_to_cpus(&buf); 268 + *((u16 *)data) = buf; 269 + } else if (4 == size) { 270 + u32 buf; 271 + ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 1); 272 + le32_to_cpus(&buf); 273 + *((u32 *)data) = buf; 274 + } else { 275 + ret = __ax88179_read_cmd(dev, cmd, value, index, size, data, 1); 276 + } 277 + 278 + return ret; 279 + } 280 + 281 + static int ax88179_write_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, 282 + u16 index, u16 size, void *data) 283 + { 284 + int ret; 285 + 286 + if (2 == size) { 287 + u16 buf; 288 + buf = *((u16 *)data); 289 + cpu_to_le16s(&buf); 290 + ret = __ax88179_write_cmd(dev, cmd, value, index, 291 + size, &buf, 1); 292 + } else { 293 + ret = __ax88179_write_cmd(dev, cmd, value, index, 294 + size, data, 1); 295 + } 296 + 297 + return ret; 298 + } 299 + 300 + static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 301 + u16 size, void *data) 302 + { 303 + int ret; 304 + 305 + if (2 == size) { 306 + u16 buf; 307 + ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0); 308 + le16_to_cpus(&buf); 309 + *((u16 *)data) = buf; 310 + } else if (4 == size) { 311 + u32 buf; 312 + ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0); 313 + le32_to_cpus(&buf); 314 + *((u32 *)data) = buf; 315 + } else { 316 + ret = __ax88179_read_cmd(dev, cmd, value, index, size, data, 0); 317 + } 318 + 319 + return ret; 320 + } 321 + 322 + static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 323 + u16 size, void *data) 324 + { 325 + int ret; 326 + 327 + if (2 == size) { 328 + u16 buf; 329 + buf = *((u16 *)data); 330 + cpu_to_le16s(&buf); 331 + ret = __ax88179_write_cmd(dev, cmd, value, index, 332 + size, &buf, 0); 333 + } else { 334 + ret = __ax88179_write_cmd(dev, cmd, value, index, 335 + size, data, 0); 336 + } 337 + 338 + return ret; 339 + } 340 + 341 + static void ax88179_status(struct usbnet *dev, struct urb *urb) 342 + { 343 + struct ax88179_int_data *event; 344 + u32 link; 345 + 346 + if (urb->actual_length < 8) 347 + return; 348 + 349 + event = urb->transfer_buffer; 350 + le32_to_cpus((void *)&event->intdata1); 351 + 352 + link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16; 353 + 354 + if (netif_carrier_ok(dev->net) != link) { 355 + if (link) 356 + usbnet_defer_kevent(dev, EVENT_LINK_RESET); 357 + else 358 + netif_carrier_off(dev->net); 359 + 360 + netdev_info(dev->net, "ax88179 - Link status is: %d\n", link); 361 + } 362 + } 363 + 364 + static int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc) 365 + { 366 + struct usbnet *dev = netdev_priv(netdev); 367 + u16 res; 368 + 369 + ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); 370 + return res; 371 + } 372 + 373 + static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, 374 + int val) 375 + { 376 + struct usbnet *dev = netdev_priv(netdev); 377 + u16 res = (u16) val; 378 + 379 + ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); 380 + } 381 + 382 + static int ax88179_suspend(struct usb_interface *intf, pm_message_t message) 383 + { 384 + struct usbnet *dev = usb_get_intfdata(intf); 385 + u16 tmp16; 386 + u8 tmp8; 387 + 388 + usbnet_suspend(intf, message); 389 + 390 + /* Disable RX path */ 391 + ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 392 + 2, 2, &tmp16); 393 + tmp16 &= ~AX_MEDIUM_RECEIVE_EN; 394 + ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 395 + 2, 2, &tmp16); 396 + 397 + /* Force bulk-in zero length */ 398 + ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 399 + 2, 2, &tmp16); 400 + 401 + tmp16 |= AX_PHYPWR_RSTCTL_BZ | AX_PHYPWR_RSTCTL_IPRL; 402 + ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 403 + 2, 2, &tmp16); 404 + 405 + /* change clock */ 406 + tmp8 = 0; 407 + ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 408 + 409 + /* Configure RX control register => stop operation */ 410 + tmp16 = AX_RX_CTL_STOP; 411 + ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); 412 + 413 + return 0; 414 + } 415 + 416 + /* This function is used to enable the autodetach function. */ 417 + /* This function is determined by offset 0x43 of EEPROM */ 418 + static int ax88179_auto_detach(struct usbnet *dev, int in_pm) 419 + { 420 + u16 tmp16; 421 + u8 tmp8; 422 + int (*fnr)(struct usbnet *, u8, u16, u16, u16, void *); 423 + int (*fnw)(struct usbnet *, u8, u16, u16, u16, void *); 424 + 425 + if (!in_pm) { 426 + fnr = ax88179_read_cmd; 427 + fnw = ax88179_write_cmd; 428 + } else { 429 + fnr = ax88179_read_cmd_nopm; 430 + fnw = ax88179_write_cmd_nopm; 431 + } 432 + 433 + if (fnr(dev, AX_ACCESS_EEPROM, 0x43, 1, 2, &tmp16) < 0) 434 + return 0; 435 + 436 + if ((tmp16 == 0xFFFF) || (!(tmp16 & 0x0100))) 437 + return 0; 438 + 439 + /* Enable Auto Detach bit */ 440 + tmp8 = 0; 441 + fnr(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 442 + tmp8 |= AX_CLK_SELECT_ULR; 443 + fnw(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 444 + 445 + fnr(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); 446 + tmp16 |= AX_PHYPWR_RSTCTL_AT; 447 + fnw(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); 448 + 449 + return 0; 450 + } 451 + 452 + static int ax88179_resume(struct usb_interface *intf) 453 + { 454 + struct usbnet *dev = usb_get_intfdata(intf); 455 + u16 tmp16; 456 + u8 tmp8; 457 + 458 + netif_carrier_off(dev->net); 459 + 460 + /* Power up ethernet PHY */ 461 + tmp16 = 0; 462 + ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 463 + 2, 2, &tmp16); 464 + udelay(1000); 465 + 466 + tmp16 = AX_PHYPWR_RSTCTL_IPRL; 467 + ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 468 + 2, 2, &tmp16); 469 + msleep(200); 470 + 471 + /* Ethernet PHY Auto Detach*/ 472 + ax88179_auto_detach(dev, 1); 473 + 474 + /* Enable clock */ 475 + ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 476 + tmp8 |= AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; 477 + ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 478 + msleep(100); 479 + 480 + /* Configure RX control register => start operation */ 481 + tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | 482 + AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; 483 + ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); 484 + 485 + return usbnet_resume(intf); 486 + } 487 + 488 + static void 489 + ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) 490 + { 491 + struct usbnet *dev = netdev_priv(net); 492 + u8 opt; 493 + 494 + if (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 495 + 1, 1, &opt) < 0) { 496 + wolinfo->supported = 0; 497 + wolinfo->wolopts = 0; 498 + return; 499 + } 500 + 501 + wolinfo->supported = WAKE_PHY | WAKE_MAGIC; 502 + wolinfo->wolopts = 0; 503 + if (opt & AX_MONITOR_MODE_RWLC) 504 + wolinfo->wolopts |= WAKE_PHY; 505 + if (opt & AX_MONITOR_MODE_RWMP) 506 + wolinfo->wolopts |= WAKE_MAGIC; 507 + } 508 + 509 + static int 510 + ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) 511 + { 512 + struct usbnet *dev = netdev_priv(net); 513 + u8 opt = 0; 514 + 515 + if (wolinfo->wolopts & WAKE_PHY) 516 + opt |= AX_MONITOR_MODE_RWLC; 517 + if (wolinfo->wolopts & WAKE_MAGIC) 518 + opt |= AX_MONITOR_MODE_RWMP; 519 + 520 + if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 521 + 1, 1, &opt) < 0) 522 + return -EINVAL; 523 + 524 + return 0; 525 + } 526 + 527 + static int ax88179_get_eeprom_len(struct net_device *net) 528 + { 529 + return AX_EEPROM_LEN; 530 + } 531 + 532 + static int 533 + ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, 534 + u8 *data) 535 + { 536 + struct usbnet *dev = netdev_priv(net); 537 + u16 *eeprom_buff; 538 + int first_word, last_word; 539 + int i, ret; 540 + 541 + if (eeprom->len == 0) 542 + return -EINVAL; 543 + 544 + eeprom->magic = AX88179_EEPROM_MAGIC; 545 + 546 + first_word = eeprom->offset >> 1; 547 + last_word = (eeprom->offset + eeprom->len - 1) >> 1; 548 + eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), 549 + GFP_KERNEL); 550 + if (!eeprom_buff) 551 + return -ENOMEM; 552 + 553 + /* ax88179/178A returns 2 bytes from eeprom on read */ 554 + for (i = first_word; i <= last_word; i++) { 555 + ret = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2, 556 + &eeprom_buff[i - first_word], 557 + 0); 558 + if (ret < 0) { 559 + kfree(eeprom_buff); 560 + return -EIO; 561 + } 562 + } 563 + 564 + memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); 565 + kfree(eeprom_buff); 566 + return 0; 567 + } 568 + 569 + static int ax88179_get_settings(struct net_device *net, struct ethtool_cmd *cmd) 570 + { 571 + struct usbnet *dev = netdev_priv(net); 572 + return mii_ethtool_gset(&dev->mii, cmd); 573 + } 574 + 575 + static int ax88179_set_settings(struct net_device *net, struct ethtool_cmd *cmd) 576 + { 577 + struct usbnet *dev = netdev_priv(net); 578 + return mii_ethtool_sset(&dev->mii, cmd); 579 + } 580 + 581 + 582 + static int ax88179_ioctl(struct net_device *net, struct ifreq *rq, int cmd) 583 + { 584 + struct usbnet *dev = netdev_priv(net); 585 + return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); 586 + } 587 + 588 + static const struct ethtool_ops ax88179_ethtool_ops = { 589 + .get_link = ethtool_op_get_link, 590 + .get_msglevel = usbnet_get_msglevel, 591 + .set_msglevel = usbnet_set_msglevel, 592 + .get_wol = ax88179_get_wol, 593 + .set_wol = ax88179_set_wol, 594 + .get_eeprom_len = ax88179_get_eeprom_len, 595 + .get_eeprom = ax88179_get_eeprom, 596 + .get_settings = ax88179_get_settings, 597 + .set_settings = ax88179_set_settings, 598 + .nway_reset = usbnet_nway_reset, 599 + }; 600 + 601 + static void ax88179_set_multicast(struct net_device *net) 602 + { 603 + struct usbnet *dev = netdev_priv(net); 604 + struct ax88179_data *data = (struct ax88179_data *)dev->data; 605 + u8 *m_filter = ((u8 *)dev->data) + 12; 606 + 607 + data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE); 608 + 609 + if (net->flags & IFF_PROMISC) { 610 + data->rxctl |= AX_RX_CTL_PRO; 611 + } else if (net->flags & IFF_ALLMULTI || 612 + netdev_mc_count(net) > AX_MAX_MCAST) { 613 + data->rxctl |= AX_RX_CTL_AMALL; 614 + } else if (netdev_mc_empty(net)) { 615 + /* just broadcast and directed */ 616 + } else { 617 + /* We use the 20 byte dev->data for our 8 byte filter buffer 618 + * to avoid allocating memory that is tricky to free later 619 + */ 620 + u32 crc_bits; 621 + struct netdev_hw_addr *ha; 622 + 623 + memset(m_filter, 0, AX_MCAST_FLTSIZE); 624 + 625 + netdev_for_each_mc_addr(ha, net) { 626 + crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; 627 + *(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7)); 628 + } 629 + 630 + ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY, 631 + AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE, 632 + m_filter); 633 + 634 + data->rxctl |= AX_RX_CTL_AM; 635 + } 636 + 637 + ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, 638 + 2, 2, &data->rxctl); 639 + } 640 + 641 + static int 642 + ax88179_set_features(struct net_device *net, netdev_features_t features) 643 + { 644 + u8 tmp; 645 + struct usbnet *dev = netdev_priv(net); 646 + netdev_features_t changed = net->features ^ features; 647 + 648 + if (changed & NETIF_F_IP_CSUM) { 649 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); 650 + tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP; 651 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); 652 + } 653 + 654 + if (changed & NETIF_F_IPV6_CSUM) { 655 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); 656 + tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; 657 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); 658 + } 659 + 660 + if (changed & NETIF_F_RXCSUM) { 661 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); 662 + tmp ^= AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | 663 + AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; 664 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); 665 + } 666 + 667 + return 0; 668 + } 669 + 670 + static int ax88179_change_mtu(struct net_device *net, int new_mtu) 671 + { 672 + struct usbnet *dev = netdev_priv(net); 673 + u16 tmp16; 674 + 675 + if (new_mtu <= 0 || new_mtu > 4088) 676 + return -EINVAL; 677 + 678 + net->mtu = new_mtu; 679 + dev->hard_mtu = net->mtu + net->hard_header_len; 680 + 681 + if (net->mtu > 1500) { 682 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 683 + 2, 2, &tmp16); 684 + tmp16 |= AX_MEDIUM_JUMBO_EN; 685 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 686 + 2, 2, &tmp16); 687 + } else { 688 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 689 + 2, 2, &tmp16); 690 + tmp16 &= ~AX_MEDIUM_JUMBO_EN; 691 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 692 + 2, 2, &tmp16); 693 + } 694 + 695 + return 0; 696 + } 697 + 698 + static int ax88179_set_mac_addr(struct net_device *net, void *p) 699 + { 700 + struct usbnet *dev = netdev_priv(net); 701 + struct sockaddr *addr = p; 702 + 703 + if (netif_running(net)) 704 + return -EBUSY; 705 + if (!is_valid_ether_addr(addr->sa_data)) 706 + return -EADDRNOTAVAIL; 707 + 708 + memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); 709 + 710 + /* Set the MAC address */ 711 + return ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, 712 + ETH_ALEN, net->dev_addr); 713 + } 714 + 715 + static const struct net_device_ops ax88179_netdev_ops = { 716 + .ndo_open = usbnet_open, 717 + .ndo_stop = usbnet_stop, 718 + .ndo_start_xmit = usbnet_start_xmit, 719 + .ndo_tx_timeout = usbnet_tx_timeout, 720 + .ndo_change_mtu = ax88179_change_mtu, 721 + .ndo_set_mac_address = ax88179_set_mac_addr, 722 + .ndo_validate_addr = eth_validate_addr, 723 + .ndo_do_ioctl = ax88179_ioctl, 724 + .ndo_set_rx_mode = ax88179_set_multicast, 725 + .ndo_set_features = ax88179_set_features, 726 + }; 727 + 728 + static int ax88179_check_eeprom(struct usbnet *dev) 729 + { 730 + u8 i, buf, eeprom[20]; 731 + u16 csum, delay = HZ / 10; 732 + unsigned long jtimeout; 733 + 734 + /* Read EEPROM content */ 735 + for (i = 0; i < 6; i++) { 736 + buf = i; 737 + if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, 738 + 1, 1, &buf) < 0) 739 + return -EINVAL; 740 + 741 + buf = EEP_RD; 742 + if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, 743 + 1, 1, &buf) < 0) 744 + return -EINVAL; 745 + 746 + jtimeout = jiffies + delay; 747 + do { 748 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, 749 + 1, 1, &buf); 750 + 751 + if (time_after(jiffies, jtimeout)) 752 + return -EINVAL; 753 + 754 + } while (buf & EEP_BUSY); 755 + 756 + __ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, 757 + 2, 2, &eeprom[i * 2], 0); 758 + 759 + if ((i == 0) && (eeprom[0] == 0xFF)) 760 + return -EINVAL; 761 + } 762 + 763 + csum = eeprom[6] + eeprom[7] + eeprom[8] + eeprom[9]; 764 + csum = (csum >> 8) + (csum & 0xff); 765 + if ((csum + eeprom[10]) != 0xff) 766 + return -EINVAL; 767 + 768 + return 0; 769 + } 770 + 771 + static int ax88179_check_efuse(struct usbnet *dev, u16 *ledmode) 772 + { 773 + u8 i; 774 + u8 efuse[64]; 775 + u16 csum = 0; 776 + 777 + if (ax88179_read_cmd(dev, AX_ACCESS_EFUS, 0, 64, 64, efuse) < 0) 778 + return -EINVAL; 779 + 780 + if (*efuse == 0xFF) 781 + return -EINVAL; 782 + 783 + for (i = 0; i < 64; i++) 784 + csum = csum + efuse[i]; 785 + 786 + while (csum > 255) 787 + csum = (csum & 0x00FF) + ((csum >> 8) & 0x00FF); 788 + 789 + if (csum != 0xFF) 790 + return -EINVAL; 791 + 792 + *ledmode = (efuse[51] << 8) | efuse[52]; 793 + 794 + return 0; 795 + } 796 + 797 + static int ax88179_convert_old_led(struct usbnet *dev, u16 *ledvalue) 798 + { 799 + u16 led; 800 + 801 + /* Loaded the old eFuse LED Mode */ 802 + if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM, 0x3C, 1, 2, &led) < 0) 803 + return -EINVAL; 804 + 805 + led >>= 8; 806 + switch (led) { 807 + case 0xFF: 808 + led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | 809 + LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | 810 + LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; 811 + break; 812 + case 0xFE: 813 + led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | LED_VALID; 814 + break; 815 + case 0xFD: 816 + led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | 817 + LED2_LINK_10 | LED_VALID; 818 + break; 819 + case 0xFC: 820 + led = LED0_ACTIVE | LED1_ACTIVE | LED1_LINK_1000 | LED2_ACTIVE | 821 + LED2_LINK_100 | LED2_LINK_10 | LED_VALID; 822 + break; 823 + default: 824 + led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | 825 + LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | 826 + LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; 827 + break; 828 + } 829 + 830 + *ledvalue = led; 831 + 832 + return 0; 833 + } 834 + 835 + static int ax88179_led_setting(struct usbnet *dev) 836 + { 837 + u8 ledfd, value = 0; 838 + u16 tmp, ledact, ledlink, ledvalue = 0, delay = HZ / 10; 839 + unsigned long jtimeout; 840 + 841 + /* Check AX88179 version. UA1 or UA2*/ 842 + ax88179_read_cmd(dev, AX_ACCESS_MAC, GENERAL_STATUS, 1, 1, &value); 843 + 844 + if (!(value & AX_SECLD)) { /* UA1 */ 845 + value = AX_GPIO_CTRL_GPIO3EN | AX_GPIO_CTRL_GPIO2EN | 846 + AX_GPIO_CTRL_GPIO1EN; 847 + if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_GPIO_CTRL, 848 + 1, 1, &value) < 0) 849 + return -EINVAL; 850 + } 851 + 852 + /* Check EEPROM */ 853 + if (!ax88179_check_eeprom(dev)) { 854 + value = 0x42; 855 + if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, 856 + 1, 1, &value) < 0) 857 + return -EINVAL; 858 + 859 + value = EEP_RD; 860 + if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, 861 + 1, 1, &value) < 0) 862 + return -EINVAL; 863 + 864 + jtimeout = jiffies + delay; 865 + do { 866 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, 867 + 1, 1, &value); 868 + 869 + if (time_after(jiffies, jtimeout)) 870 + return -EINVAL; 871 + 872 + } while (value & EEP_BUSY); 873 + 874 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_HIGH, 875 + 1, 1, &value); 876 + ledvalue = (value << 8); 877 + 878 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, 879 + 1, 1, &value); 880 + ledvalue |= value; 881 + 882 + /* load internal ROM for defaule setting */ 883 + if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) 884 + ax88179_convert_old_led(dev, &ledvalue); 885 + 886 + } else if (!ax88179_check_efuse(dev, &ledvalue)) { 887 + if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) 888 + ax88179_convert_old_led(dev, &ledvalue); 889 + } else { 890 + ax88179_convert_old_led(dev, &ledvalue); 891 + } 892 + 893 + tmp = GMII_PHY_PGSEL_EXT; 894 + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 895 + GMII_PHY_PAGE_SELECT, 2, &tmp); 896 + 897 + tmp = 0x2c; 898 + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 899 + GMII_PHYPAGE, 2, &tmp); 900 + 901 + ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 902 + GMII_LED_ACT, 2, &ledact); 903 + 904 + ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 905 + GMII_LED_LINK, 2, &ledlink); 906 + 907 + ledact &= GMII_LED_ACTIVE_MASK; 908 + ledlink &= GMII_LED_LINK_MASK; 909 + 910 + if (ledvalue & LED0_ACTIVE) 911 + ledact |= GMII_LED0_ACTIVE; 912 + 913 + if (ledvalue & LED1_ACTIVE) 914 + ledact |= GMII_LED1_ACTIVE; 915 + 916 + if (ledvalue & LED2_ACTIVE) 917 + ledact |= GMII_LED2_ACTIVE; 918 + 919 + if (ledvalue & LED0_LINK_10) 920 + ledlink |= GMII_LED0_LINK_10; 921 + 922 + if (ledvalue & LED1_LINK_10) 923 + ledlink |= GMII_LED1_LINK_10; 924 + 925 + if (ledvalue & LED2_LINK_10) 926 + ledlink |= GMII_LED2_LINK_10; 927 + 928 + if (ledvalue & LED0_LINK_100) 929 + ledlink |= GMII_LED0_LINK_100; 930 + 931 + if (ledvalue & LED1_LINK_100) 932 + ledlink |= GMII_LED1_LINK_100; 933 + 934 + if (ledvalue & LED2_LINK_100) 935 + ledlink |= GMII_LED2_LINK_100; 936 + 937 + if (ledvalue & LED0_LINK_1000) 938 + ledlink |= GMII_LED0_LINK_1000; 939 + 940 + if (ledvalue & LED1_LINK_1000) 941 + ledlink |= GMII_LED1_LINK_1000; 942 + 943 + if (ledvalue & LED2_LINK_1000) 944 + ledlink |= GMII_LED2_LINK_1000; 945 + 946 + tmp = ledact; 947 + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 948 + GMII_LED_ACT, 2, &tmp); 949 + 950 + tmp = ledlink; 951 + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 952 + GMII_LED_LINK, 2, &tmp); 953 + 954 + tmp = GMII_PHY_PGSEL_PAGE0; 955 + ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 956 + GMII_PHY_PAGE_SELECT, 2, &tmp); 957 + 958 + /* LED full duplex setting */ 959 + ledfd = 0; 960 + if (ledvalue & LED0_FD) 961 + ledfd |= 0x01; 962 + else if ((ledvalue & LED0_USB3_MASK) == 0) 963 + ledfd |= 0x02; 964 + 965 + if (ledvalue & LED1_FD) 966 + ledfd |= 0x04; 967 + else if ((ledvalue & LED1_USB3_MASK) == 0) 968 + ledfd |= 0x08; 969 + 970 + if (ledvalue & LED2_FD) 971 + ledfd |= 0x10; 972 + else if ((ledvalue & LED2_USB3_MASK) == 0) 973 + ledfd |= 0x20; 974 + 975 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_LEDCTRL, 1, 1, &ledfd); 976 + 977 + return 0; 978 + } 979 + 980 + static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf) 981 + { 982 + u8 buf[5]; 983 + u16 *tmp16; 984 + u8 *tmp; 985 + struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; 986 + 987 + usbnet_get_endpoints(dev, intf); 988 + 989 + tmp16 = (u16 *)buf; 990 + tmp = (u8 *)buf; 991 + 992 + memset(ax179_data, 0, sizeof(*ax179_data)); 993 + 994 + /* Power up ethernet PHY */ 995 + *tmp16 = 0; 996 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); 997 + *tmp16 = AX_PHYPWR_RSTCTL_IPRL; 998 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); 999 + msleep(200); 1000 + 1001 + *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; 1002 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp); 1003 + msleep(100); 1004 + 1005 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, 1006 + ETH_ALEN, dev->net->dev_addr); 1007 + memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN); 1008 + 1009 + /* RX bulk configuration */ 1010 + memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); 1011 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); 1012 + 1013 + dev->rx_urb_size = 1024 * 20; 1014 + 1015 + *tmp = 0x34; 1016 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp); 1017 + 1018 + *tmp = 0x52; 1019 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, 1020 + 1, 1, tmp); 1021 + 1022 + dev->net->netdev_ops = &ax88179_netdev_ops; 1023 + dev->net->ethtool_ops = &ax88179_ethtool_ops; 1024 + dev->net->needed_headroom = 8; 1025 + 1026 + /* Initialize MII structure */ 1027 + dev->mii.dev = dev->net; 1028 + dev->mii.mdio_read = ax88179_mdio_read; 1029 + dev->mii.mdio_write = ax88179_mdio_write; 1030 + dev->mii.phy_id_mask = 0xff; 1031 + dev->mii.reg_num_mask = 0xff; 1032 + dev->mii.phy_id = 0x03; 1033 + dev->mii.supports_gmii = 1; 1034 + 1035 + dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 1036 + NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO; 1037 + 1038 + dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 1039 + NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO; 1040 + 1041 + /* Enable checksum offload */ 1042 + *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | 1043 + AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; 1044 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp); 1045 + 1046 + *tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP | 1047 + AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; 1048 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp); 1049 + 1050 + /* Configure RX control register => start operation */ 1051 + *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | 1052 + AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; 1053 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); 1054 + 1055 + *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | 1056 + AX_MONITOR_MODE_RWMP; 1057 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp); 1058 + 1059 + /* Configure default medium type => giga */ 1060 + *tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | 1061 + AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_ALWAYS_ONE | 1062 + AX_MEDIUM_FULL_DUPLEX | AX_MEDIUM_GIGAMODE; 1063 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1064 + 2, 2, tmp16); 1065 + 1066 + ax88179_led_setting(dev); 1067 + 1068 + /* Restart autoneg */ 1069 + mii_nway_restart(&dev->mii); 1070 + 1071 + netif_carrier_off(dev->net); 1072 + 1073 + return 0; 1074 + } 1075 + 1076 + static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf) 1077 + { 1078 + u16 tmp16; 1079 + 1080 + /* Configure RX control register => stop operation */ 1081 + tmp16 = AX_RX_CTL_STOP; 1082 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); 1083 + 1084 + tmp16 = 0; 1085 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp16); 1086 + 1087 + /* Power down ethernet PHY */ 1088 + tmp16 = 0; 1089 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); 1090 + } 1091 + 1092 + static void 1093 + ax88179_rx_checksum(struct sk_buff *skb, u32 *pkt_hdr) 1094 + { 1095 + skb->ip_summed = CHECKSUM_NONE; 1096 + 1097 + /* checksum error bit is set */ 1098 + if ((*pkt_hdr & AX_RXHDR_L3CSUM_ERR) || 1099 + (*pkt_hdr & AX_RXHDR_L4CSUM_ERR)) 1100 + return; 1101 + 1102 + /* It must be a TCP or UDP packet with a valid checksum */ 1103 + if (((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_TCP) || 1104 + ((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_UDP)) 1105 + skb->ip_summed = CHECKSUM_UNNECESSARY; 1106 + } 1107 + 1108 + static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 1109 + { 1110 + struct sk_buff *ax_skb; 1111 + int pkt_cnt; 1112 + u32 rx_hdr; 1113 + u16 hdr_off; 1114 + u32 *pkt_hdr; 1115 + 1116 + skb_trim(skb, skb->len - 4); 1117 + memcpy(&rx_hdr, skb_tail_pointer(skb), 4); 1118 + le32_to_cpus(&rx_hdr); 1119 + 1120 + pkt_cnt = (u16)rx_hdr; 1121 + hdr_off = (u16)(rx_hdr >> 16); 1122 + pkt_hdr = (u32 *)(skb->data + hdr_off); 1123 + 1124 + while (pkt_cnt--) { 1125 + u16 pkt_len; 1126 + 1127 + le32_to_cpus(pkt_hdr); 1128 + pkt_len = (*pkt_hdr >> 16) & 0x1fff; 1129 + 1130 + /* Check CRC or runt packet */ 1131 + if ((*pkt_hdr & AX_RXHDR_CRC_ERR) || 1132 + (*pkt_hdr & AX_RXHDR_DROP_ERR)) { 1133 + skb_pull(skb, (pkt_len + 7) & 0xFFF8); 1134 + pkt_hdr++; 1135 + continue; 1136 + } 1137 + 1138 + if (pkt_cnt == 0) { 1139 + /* Skip IP alignment psudo header */ 1140 + skb_pull(skb, 2); 1141 + skb->len = pkt_len; 1142 + skb_set_tail_pointer(skb, pkt_len); 1143 + skb->truesize = pkt_len + sizeof(struct sk_buff); 1144 + ax88179_rx_checksum(skb, pkt_hdr); 1145 + return 1; 1146 + } 1147 + 1148 + ax_skb = skb_clone(skb, GFP_ATOMIC); 1149 + if (ax_skb) { 1150 + ax_skb->len = pkt_len; 1151 + ax_skb->data = skb->data + 2; 1152 + skb_set_tail_pointer(ax_skb, pkt_len); 1153 + ax_skb->truesize = pkt_len + sizeof(struct sk_buff); 1154 + ax88179_rx_checksum(ax_skb, pkt_hdr); 1155 + usbnet_skb_return(dev, ax_skb); 1156 + } else { 1157 + return 0; 1158 + } 1159 + 1160 + skb_pull(skb, (pkt_len + 7) & 0xFFF8); 1161 + pkt_hdr++; 1162 + } 1163 + return 1; 1164 + } 1165 + 1166 + static struct sk_buff * 1167 + ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) 1168 + { 1169 + u32 tx_hdr1, tx_hdr2; 1170 + int frame_size = dev->maxpacket; 1171 + int mss = skb_shinfo(skb)->gso_size; 1172 + int headroom; 1173 + int tailroom; 1174 + 1175 + tx_hdr1 = skb->len; 1176 + tx_hdr2 = mss; 1177 + if (((skb->len + 8) % frame_size) == 0) 1178 + tx_hdr2 |= 0x80008000; /* Enable padding */ 1179 + 1180 + skb_linearize(skb); 1181 + headroom = skb_headroom(skb); 1182 + tailroom = skb_tailroom(skb); 1183 + 1184 + if (!skb_header_cloned(skb) && 1185 + !skb_cloned(skb) && 1186 + (headroom + tailroom) >= 8) { 1187 + if (headroom < 8) { 1188 + skb->data = memmove(skb->head + 8, skb->data, skb->len); 1189 + skb_set_tail_pointer(skb, skb->len); 1190 + } 1191 + } else { 1192 + struct sk_buff *skb2; 1193 + 1194 + skb2 = skb_copy_expand(skb, 8, 0, flags); 1195 + dev_kfree_skb_any(skb); 1196 + skb = skb2; 1197 + if (!skb) 1198 + return NULL; 1199 + } 1200 + 1201 + skb_push(skb, 4); 1202 + cpu_to_le32s(&tx_hdr2); 1203 + skb_copy_to_linear_data(skb, &tx_hdr2, 4); 1204 + 1205 + skb_push(skb, 4); 1206 + cpu_to_le32s(&tx_hdr1); 1207 + skb_copy_to_linear_data(skb, &tx_hdr1, 4); 1208 + 1209 + return skb; 1210 + } 1211 + 1212 + static int ax88179_link_reset(struct usbnet *dev) 1213 + { 1214 + struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; 1215 + u8 tmp[5], link_sts; 1216 + u16 mode, tmp16, delay = HZ / 10; 1217 + u32 tmp32 = 0x40000000; 1218 + unsigned long jtimeout; 1219 + 1220 + jtimeout = jiffies + delay; 1221 + while (tmp32 & 0x40000000) { 1222 + mode = 0; 1223 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &mode); 1224 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, 1225 + &ax179_data->rxctl); 1226 + 1227 + /*link up, check the usb device control TX FIFO full or empty*/ 1228 + ax88179_read_cmd(dev, 0x81, 0x8c, 0, 4, &tmp32); 1229 + 1230 + if (time_after(jiffies, jtimeout)) 1231 + return 0; 1232 + } 1233 + 1234 + mode = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | 1235 + AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_ALWAYS_ONE; 1236 + 1237 + ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, 1238 + 1, 1, &link_sts); 1239 + 1240 + ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1241 + GMII_PHY_PHYSR, 2, &tmp16); 1242 + 1243 + if (!(tmp16 & GMII_PHY_PHYSR_LINK)) { 1244 + return 0; 1245 + } else if (GMII_PHY_PHYSR_GIGA == (tmp16 & GMII_PHY_PHYSR_SMASK)) { 1246 + mode |= AX_MEDIUM_GIGAMODE | AX_MEDIUM_EN_125MHZ; 1247 + if (dev->net->mtu > 1500) 1248 + mode |= AX_MEDIUM_JUMBO_EN; 1249 + 1250 + if (link_sts & AX_USB_SS) 1251 + memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); 1252 + else if (link_sts & AX_USB_HS) 1253 + memcpy(tmp, &AX88179_BULKIN_SIZE[1], 5); 1254 + else 1255 + memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); 1256 + } else if (GMII_PHY_PHYSR_100 == (tmp16 & GMII_PHY_PHYSR_SMASK)) { 1257 + mode |= AX_MEDIUM_PS; 1258 + 1259 + if (link_sts & (AX_USB_SS | AX_USB_HS)) 1260 + memcpy(tmp, &AX88179_BULKIN_SIZE[2], 5); 1261 + else 1262 + memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); 1263 + } else { 1264 + memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); 1265 + } 1266 + 1267 + /* RX bulk configuration */ 1268 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); 1269 + 1270 + dev->rx_urb_size = (1024 * (tmp[3] + 2)); 1271 + 1272 + if (tmp16 & GMII_PHY_PHYSR_FULL) 1273 + mode |= AX_MEDIUM_FULL_DUPLEX; 1274 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1275 + 2, 2, &mode); 1276 + 1277 + netif_carrier_on(dev->net); 1278 + 1279 + return 0; 1280 + } 1281 + 1282 + static int ax88179_reset(struct usbnet *dev) 1283 + { 1284 + u8 buf[5]; 1285 + u16 *tmp16; 1286 + u8 *tmp; 1287 + 1288 + tmp16 = (u16 *)buf; 1289 + tmp = (u8 *)buf; 1290 + 1291 + /* Power up ethernet PHY */ 1292 + *tmp16 = 0; 1293 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); 1294 + 1295 + *tmp16 = AX_PHYPWR_RSTCTL_IPRL; 1296 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); 1297 + msleep(200); 1298 + 1299 + *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; 1300 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp); 1301 + msleep(100); 1302 + 1303 + /* Ethernet PHY Auto Detach*/ 1304 + ax88179_auto_detach(dev, 0); 1305 + 1306 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN, 1307 + dev->net->dev_addr); 1308 + memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN); 1309 + 1310 + /* RX bulk configuration */ 1311 + memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); 1312 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); 1313 + 1314 + dev->rx_urb_size = 1024 * 20; 1315 + 1316 + *tmp = 0x34; 1317 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp); 1318 + 1319 + *tmp = 0x52; 1320 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, 1321 + 1, 1, tmp); 1322 + 1323 + dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 1324 + NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO; 1325 + 1326 + dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 1327 + NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO; 1328 + 1329 + /* Enable checksum offload */ 1330 + *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | 1331 + AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; 1332 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp); 1333 + 1334 + *tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP | 1335 + AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; 1336 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp); 1337 + 1338 + /* Configure RX control register => start operation */ 1339 + *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | 1340 + AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; 1341 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); 1342 + 1343 + *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | 1344 + AX_MONITOR_MODE_RWMP; 1345 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp); 1346 + 1347 + /* Configure default medium type => giga */ 1348 + *tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | 1349 + AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_ALWAYS_ONE | 1350 + AX_MEDIUM_FULL_DUPLEX | AX_MEDIUM_GIGAMODE; 1351 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1352 + 2, 2, tmp16); 1353 + 1354 + ax88179_led_setting(dev); 1355 + 1356 + /* Restart autoneg */ 1357 + mii_nway_restart(&dev->mii); 1358 + 1359 + netif_carrier_off(dev->net); 1360 + 1361 + return 0; 1362 + } 1363 + 1364 + static int ax88179_stop(struct usbnet *dev) 1365 + { 1366 + u16 tmp16; 1367 + 1368 + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1369 + 2, 2, &tmp16); 1370 + tmp16 &= ~AX_MEDIUM_RECEIVE_EN; 1371 + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1372 + 2, 2, &tmp16); 1373 + 1374 + return 0; 1375 + } 1376 + 1377 + static const struct driver_info ax88179_info = { 1378 + .description = "ASIX AX88179 USB 3.0 Gigibit Ethernet", 1379 + .bind = ax88179_bind, 1380 + .unbind = ax88179_unbind, 1381 + .status = ax88179_status, 1382 + .link_reset = ax88179_link_reset, 1383 + .reset = ax88179_reset, 1384 + .stop = ax88179_stop, 1385 + .flags = FLAG_ETHER | FLAG_FRAMING_AX, 1386 + .rx_fixup = ax88179_rx_fixup, 1387 + .tx_fixup = ax88179_tx_fixup, 1388 + }; 1389 + 1390 + static const struct driver_info ax88178a_info = { 1391 + .description = "ASIX AX88178A USB 2.0 Gigibit Ethernet", 1392 + .bind = ax88179_bind, 1393 + .unbind = ax88179_unbind, 1394 + .status = ax88179_status, 1395 + .link_reset = ax88179_link_reset, 1396 + .reset = ax88179_reset, 1397 + .stop = ax88179_stop, 1398 + .flags = FLAG_ETHER | FLAG_FRAMING_AX, 1399 + .rx_fixup = ax88179_rx_fixup, 1400 + .tx_fixup = ax88179_tx_fixup, 1401 + }; 1402 + 1403 + static const struct driver_info sitecom_info = { 1404 + .description = "Sitecom USB 3.0 to Gigabit Adapter", 1405 + .bind = ax88179_bind, 1406 + .unbind = ax88179_unbind, 1407 + .status = ax88179_status, 1408 + .link_reset = ax88179_link_reset, 1409 + .reset = ax88179_reset, 1410 + .stop = ax88179_stop, 1411 + .flags = FLAG_ETHER | FLAG_FRAMING_AX, 1412 + .rx_fixup = ax88179_rx_fixup, 1413 + .tx_fixup = ax88179_tx_fixup, 1414 + }; 1415 + 1416 + static const struct usb_device_id products[] = { 1417 + { 1418 + /* ASIX AX88179 10/100/1000 */ 1419 + USB_DEVICE(0x0b95, 0x1790), 1420 + .driver_info = (unsigned long)&ax88179_info, 1421 + }, { 1422 + /* ASIX AX88178A 10/100/1000 */ 1423 + USB_DEVICE(0x0b95, 0x178a), 1424 + .driver_info = (unsigned long)&ax88178a_info, 1425 + }, { 1426 + /* Sitecom USB 3.0 to Gigabit Adapter */ 1427 + USB_DEVICE(0x0df6, 0x0072), 1428 + .driver_info = (unsigned long) &sitecom_info, 1429 + }, 1430 + { }, 1431 + }; 1432 + MODULE_DEVICE_TABLE(usb, products); 1433 + 1434 + static struct usb_driver ax88179_178a_driver = { 1435 + .name = "ax88179_178a", 1436 + .id_table = products, 1437 + .probe = usbnet_probe, 1438 + .suspend = ax88179_suspend, 1439 + .resume = ax88179_resume, 1440 + .disconnect = usbnet_disconnect, 1441 + .supports_autosuspend = 1, 1442 + .disable_hub_initiated_lpm = 1, 1443 + }; 1444 + 1445 + module_usb_driver(ax88179_178a_driver); 1446 + 1447 + MODULE_DESCRIPTION("ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices"); 1448 + MODULE_LICENSE("GPL");
+8
drivers/net/usb/cdc_ncm.c
··· 1213 1213 .driver_info = (unsigned long) &wwan_info, 1214 1214 }, 1215 1215 1216 + /* tag Huawei devices as wwan */ 1217 + { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 1218 + USB_CLASS_COMM, 1219 + USB_CDC_SUBCLASS_NCM, 1220 + USB_CDC_PROTO_NONE), 1221 + .driver_info = (unsigned long)&wwan_info, 1222 + }, 1223 + 1216 1224 /* Huawei NCM devices disguised as vendor specific */ 1217 1225 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16), 1218 1226 .driver_info = (unsigned long)&wwan_info,
+1 -1
drivers/net/wireless/ath/ath9k/common.h
··· 27 27 #define WME_MAX_BA WME_BA_BMP_SIZE 28 28 #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA) 29 29 30 - #define ATH_RSSI_DUMMY_MARKER 0x127 30 + #define ATH_RSSI_DUMMY_MARKER 127 31 31 #define ATH_RSSI_LPF_LEN 10 32 32 #define RSSI_LPF_THRESHOLD -20 33 33 #define ATH_RSSI_EP_MULTIPLIER (1<<7)
+1
drivers/net/wireless/ath/ath9k/htc.h
··· 22 22 #include <linux/firmware.h> 23 23 #include <linux/skbuff.h> 24 24 #include <linux/netdevice.h> 25 + #include <linux/etherdevice.h> 25 26 #include <linux/leds.h> 26 27 #include <linux/slab.h> 27 28 #include <net/mac80211.h>
+11 -7
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
··· 1067 1067 1068 1068 last_rssi = priv->rx.last_rssi; 1069 1069 1070 - if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) 1071 - rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi, 1072 - ATH_RSSI_EP_MULTIPLIER); 1070 + if (ieee80211_is_beacon(hdr->frame_control) && 1071 + !is_zero_ether_addr(common->curbssid) && 1072 + ether_addr_equal(hdr->addr3, common->curbssid)) { 1073 + s8 rssi = rxbuf->rxstatus.rs_rssi; 1073 1074 1074 - if (rxbuf->rxstatus.rs_rssi < 0) 1075 - rxbuf->rxstatus.rs_rssi = 0; 1075 + if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) 1076 + rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER); 1076 1077 1077 - if (ieee80211_is_beacon(fc)) 1078 - priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi; 1078 + if (rssi < 0) 1079 + rssi = 0; 1080 + 1081 + priv->ah->stats.avgbrssi = rssi; 1082 + } 1079 1083 1080 1084 rx_status->mactime = be64_to_cpu(rxbuf->rxstatus.rs_tstamp); 1081 1085 rx_status->band = hw->conf.channel->band;
+3 -1
drivers/net/wireless/ath/ath9k/hw.c
··· 1463 1463 reset_type = ATH9K_RESET_POWER_ON; 1464 1464 else 1465 1465 reset_type = ATH9K_RESET_COLD; 1466 - } 1466 + } else if (ah->chip_fullsleep || REG_READ(ah, AR_Q_TXE) || 1467 + (REG_READ(ah, AR_CR) & AR_CR_RXE)) 1468 + reset_type = ATH9K_RESET_COLD; 1467 1469 1468 1470 if (!ath9k_hw_set_reset_reg(ah, reset_type)) 1469 1471 return false;
+4 -6
drivers/net/wireless/iwlwifi/iwl-devtrace.h
··· 349 349 TRACE_EVENT(iwlwifi_dev_hcmd, 350 350 TP_PROTO(const struct device *dev, 351 351 struct iwl_host_cmd *cmd, u16 total_size, 352 - const void *hdr, size_t hdr_len), 353 - TP_ARGS(dev, cmd, total_size, hdr, hdr_len), 352 + struct iwl_cmd_header *hdr), 353 + TP_ARGS(dev, cmd, total_size, hdr), 354 354 TP_STRUCT__entry( 355 355 DEV_ENTRY 356 356 __dynamic_array(u8, hcmd, total_size) 357 357 __field(u32, flags) 358 358 ), 359 359 TP_fast_assign( 360 - int i, offset = hdr_len; 360 + int i, offset = sizeof(*hdr); 361 361 362 362 DEV_ASSIGN; 363 363 __entry->flags = cmd->flags; 364 - memcpy(__get_dynamic_array(hcmd), hdr, hdr_len); 364 + memcpy(__get_dynamic_array(hcmd), hdr, sizeof(*hdr)); 365 365 366 366 for (i = 0; i < IWL_MAX_CMD_TFDS; i++) { 367 367 if (!cmd->len[i]) 368 - continue; 369 - if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY)) 370 368 continue; 371 369 memcpy((u8 *)__get_dynamic_array(hcmd) + offset, 372 370 cmd->data[i], cmd->len[i]);
-16
drivers/net/wireless/iwlwifi/iwl-phy-db.c
··· 136 136 u8 data[]; 137 137 } __packed; 138 138 139 - #define IWL_PHY_DB_STATIC_PIC cpu_to_le32(0x21436587) 140 - static inline void iwl_phy_db_test_pic(__le32 pic) 141 - { 142 - WARN_ON(IWL_PHY_DB_STATIC_PIC != pic); 143 - } 144 - 145 139 struct iwl_phy_db *iwl_phy_db_init(struct iwl_trans *trans) 146 140 { 147 141 struct iwl_phy_db *phy_db = kzalloc(sizeof(struct iwl_phy_db), ··· 254 260 (size - CHANNEL_NUM_SIZE) / phy_db->channel_num; 255 261 } 256 262 257 - /* Test PIC */ 258 - if (type != IWL_PHY_DB_CFG) 259 - iwl_phy_db_test_pic(*(((__le32 *)phy_db_notif->data) + 260 - (size / sizeof(__le32)) - 1)); 261 - 262 263 IWL_DEBUG_INFO(phy_db->trans, 263 264 "%s(%d): [PHYDB]SET: Type %d , Size: %d\n", 264 265 __func__, __LINE__, type, size); ··· 360 371 *data = entry->data; 361 372 *size = entry->size; 362 373 } 363 - 364 - /* Test PIC */ 365 - if (type != IWL_PHY_DB_CFG) 366 - iwl_phy_db_test_pic(*(((__le32 *)*data) + 367 - (*size / sizeof(__le32)) - 1)); 368 374 369 375 IWL_DEBUG_INFO(phy_db->trans, 370 376 "%s(%d): [PHYDB] GET: Type %d , Size: %d\n",
+77 -27
drivers/net/wireless/iwlwifi/mvm/d3.c
··· 61 61 * 62 62 *****************************************************************************/ 63 63 64 + #include <linux/etherdevice.h> 64 65 #include <net/cfg80211.h> 65 66 #include <net/ipv6.h> 66 67 #include "iwl-modparams.h" ··· 193 192 sizeof(wkc), &wkc); 194 193 data->error = ret != 0; 195 194 195 + mvm->ptk_ivlen = key->iv_len; 196 + mvm->ptk_icvlen = key->icv_len; 197 + mvm->gtk_ivlen = key->iv_len; 198 + mvm->gtk_icvlen = key->icv_len; 199 + 196 200 /* don't upload key again */ 197 201 goto out_unlock; 198 202 } ··· 310 304 */ 311 305 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { 312 306 key->hw_key_idx = 0; 307 + mvm->ptk_ivlen = key->iv_len; 308 + mvm->ptk_icvlen = key->icv_len; 313 309 } else { 314 310 data->gtk_key_idx++; 315 311 key->hw_key_idx = data->gtk_key_idx; 312 + mvm->gtk_ivlen = key->iv_len; 313 + mvm->gtk_icvlen = key->icv_len; 316 314 } 317 315 318 316 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, true); ··· 659 649 /* We reprogram keys and shouldn't allocate new key indices */ 660 650 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); 661 651 652 + mvm->ptk_ivlen = 0; 653 + mvm->ptk_icvlen = 0; 654 + mvm->ptk_ivlen = 0; 655 + mvm->ptk_icvlen = 0; 656 + 662 657 /* 663 658 * The D3 firmware still hardcodes the AP station ID for the 664 659 * BSS we're associated with as 0. As a result, we have to move ··· 798 783 struct iwl_wowlan_status *status; 799 784 u32 reasons; 800 785 int ret, len; 801 - bool pkt8023 = false; 802 786 struct sk_buff *pkt = NULL; 803 787 804 788 iwl_trans_read_mem_bytes(mvm->trans, base, ··· 838 824 status = (void *)cmd.resp_pkt->data; 839 825 840 826 if (len - sizeof(struct iwl_cmd_header) != 841 - sizeof(*status) + le32_to_cpu(status->wake_packet_bufsize)) { 827 + sizeof(*status) + 828 + ALIGN(le32_to_cpu(status->wake_packet_bufsize), 4)) { 842 829 IWL_ERR(mvm, "Invalid WoWLAN status response!\n"); 843 830 goto out; 844 831 } ··· 851 836 goto report; 852 837 } 853 838 854 - if (reasons & IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET) { 839 + if (reasons & IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET) 855 840 wakeup.magic_pkt = true; 856 - pkt8023 = true; 857 - } 858 841 859 - if (reasons & IWL_WOWLAN_WAKEUP_BY_PATTERN) { 842 + if (reasons & IWL_WOWLAN_WAKEUP_BY_PATTERN) 860 843 wakeup.pattern_idx = 861 844 le16_to_cpu(status->pattern_number); 862 - pkt8023 = true; 863 - } 864 845 865 846 if (reasons & (IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON | 866 847 IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH)) 867 848 wakeup.disconnect = true; 868 849 869 - if (reasons & IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE) { 850 + if (reasons & IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE) 870 851 wakeup.gtk_rekey_failure = true; 871 - pkt8023 = true; 872 - } 873 852 874 - if (reasons & IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED) { 853 + if (reasons & IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED) 875 854 wakeup.rfkill_release = true; 876 - pkt8023 = true; 877 - } 878 855 879 - if (reasons & IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST) { 856 + if (reasons & IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST) 880 857 wakeup.eap_identity_req = true; 881 - pkt8023 = true; 882 - } 883 858 884 - if (reasons & IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE) { 859 + if (reasons & IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE) 885 860 wakeup.four_way_handshake = true; 886 - pkt8023 = true; 887 - } 888 861 889 862 if (status->wake_packet_bufsize) { 890 - u32 pktsize = le32_to_cpu(status->wake_packet_bufsize); 891 - u32 pktlen = le32_to_cpu(status->wake_packet_length); 863 + int pktsize = le32_to_cpu(status->wake_packet_bufsize); 864 + int pktlen = le32_to_cpu(status->wake_packet_length); 865 + const u8 *pktdata = status->wake_packet; 866 + struct ieee80211_hdr *hdr = (void *)pktdata; 867 + int truncated = pktlen - pktsize; 892 868 893 - if (pkt8023) { 869 + /* this would be a firmware bug */ 870 + if (WARN_ON_ONCE(truncated < 0)) 871 + truncated = 0; 872 + 873 + if (ieee80211_is_data(hdr->frame_control)) { 874 + int hdrlen = ieee80211_hdrlen(hdr->frame_control); 875 + int ivlen = 0, icvlen = 4; /* also FCS */ 876 + 894 877 pkt = alloc_skb(pktsize, GFP_KERNEL); 895 878 if (!pkt) 896 879 goto report; 897 - memcpy(skb_put(pkt, pktsize), status->wake_packet, 898 - pktsize); 880 + 881 + memcpy(skb_put(pkt, hdrlen), pktdata, hdrlen); 882 + pktdata += hdrlen; 883 + pktsize -= hdrlen; 884 + 885 + if (ieee80211_has_protected(hdr->frame_control)) { 886 + if (is_multicast_ether_addr(hdr->addr1)) { 887 + ivlen = mvm->gtk_ivlen; 888 + icvlen += mvm->gtk_icvlen; 889 + } else { 890 + ivlen = mvm->ptk_ivlen; 891 + icvlen += mvm->ptk_icvlen; 892 + } 893 + } 894 + 895 + /* if truncated, FCS/ICV is (partially) gone */ 896 + if (truncated >= icvlen) { 897 + icvlen = 0; 898 + truncated -= icvlen; 899 + } else { 900 + icvlen -= truncated; 901 + truncated = 0; 902 + } 903 + 904 + pktsize -= ivlen + icvlen; 905 + pktdata += ivlen; 906 + 907 + memcpy(skb_put(pkt, pktsize), pktdata, pktsize); 908 + 899 909 if (ieee80211_data_to_8023(pkt, vif->addr, vif->type)) 900 910 goto report; 901 911 wakeup.packet = pkt->data; 902 912 wakeup.packet_present_len = pkt->len; 903 - wakeup.packet_len = pkt->len - (pktlen - pktsize); 913 + wakeup.packet_len = pkt->len - truncated; 904 914 wakeup.packet_80211 = false; 905 915 } else { 916 + int fcslen = 4; 917 + 918 + if (truncated >= 4) { 919 + truncated -= 4; 920 + fcslen = 0; 921 + } else { 922 + fcslen -= truncated; 923 + truncated = 0; 924 + } 925 + pktsize -= fcslen; 906 926 wakeup.packet = status->wake_packet; 907 927 wakeup.packet_present_len = pktsize; 908 - wakeup.packet_len = pktlen; 928 + wakeup.packet_len = pktlen - truncated; 909 929 wakeup.packet_80211 = true; 910 930 } 911 931 }
+14 -5
drivers/net/wireless/iwlwifi/mvm/mac80211.c
··· 557 557 return ret; 558 558 } 559 559 560 - static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, 561 - struct ieee80211_vif *vif) 560 + static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, 561 + struct ieee80211_vif *vif) 562 562 { 563 - struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 564 - struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 565 563 u32 tfd_msk = 0, ac; 566 564 567 565 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) ··· 592 594 */ 593 595 flush_work(&mvm->sta_drained_wk); 594 596 } 597 + } 598 + 599 + static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, 600 + struct ieee80211_vif *vif) 601 + { 602 + struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 603 + struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 604 + 605 + iwl_mvm_prepare_mac_removal(mvm, vif); 595 606 596 607 mutex_lock(&mvm->mutex); 597 608 598 609 /* 599 610 * For AP/GO interface, the tear down of the resources allocated to the 600 - * interface should be handled as part of the bss_info_changed flow. 611 + * interface is be handled as part of the stop_ap flow. 601 612 */ 602 613 if (vif->type == NL80211_IFTYPE_AP) { 603 614 iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta); ··· 769 762 { 770 763 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 771 764 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 765 + 766 + iwl_mvm_prepare_mac_removal(mvm, vif); 772 767 773 768 mutex_lock(&mvm->mutex); 774 769
+4
drivers/net/wireless/iwlwifi/mvm/mvm.h
··· 327 327 struct led_classdev led; 328 328 329 329 struct ieee80211_vif *p2p_device_vif; 330 + 331 + #ifdef CONFIG_PM_SLEEP 332 + int gtk_ivlen, gtk_icvlen, ptk_ivlen, ptk_icvlen; 333 + #endif 330 334 }; 331 335 332 336 /* Extract MVM priv from op_mode and _hw */
+9
drivers/net/wireless/iwlwifi/pcie/internal.h
··· 182 182 #define TFD_TX_CMD_SLOTS 256 183 183 #define TFD_CMD_SLOTS 32 184 184 185 + /* 186 + * The FH will write back to the first TB only, so we need 187 + * to copy some data into the buffer regardless of whether 188 + * it should be mapped or not. This indicates how much to 189 + * copy, even for HCMDs it must be big enough to fit the 190 + * DRAM scratch from the TX cmd, at least 16 bytes. 191 + */ 192 + #define IWL_HCMD_MIN_COPY_SIZE 16 193 + 185 194 struct iwl_pcie_txq_entry { 186 195 struct iwl_device_cmd *cmd; 187 196 struct iwl_device_cmd *copy_cmd;
+58 -17
drivers/net/wireless/iwlwifi/pcie/tx.c
··· 1152 1152 void *dup_buf = NULL; 1153 1153 dma_addr_t phys_addr; 1154 1154 int idx; 1155 - u16 copy_size, cmd_size; 1155 + u16 copy_size, cmd_size, dma_size; 1156 1156 bool had_nocopy = false; 1157 1157 int i; 1158 1158 u32 cmd_pos; 1159 + const u8 *cmddata[IWL_MAX_CMD_TFDS]; 1160 + u16 cmdlen[IWL_MAX_CMD_TFDS]; 1159 1161 1160 1162 copy_size = sizeof(out_cmd->hdr); 1161 1163 cmd_size = sizeof(out_cmd->hdr); ··· 1166 1164 BUILD_BUG_ON(IWL_MAX_CMD_TFDS > IWL_NUM_OF_TBS - 1); 1167 1165 1168 1166 for (i = 0; i < IWL_MAX_CMD_TFDS; i++) { 1167 + cmddata[i] = cmd->data[i]; 1168 + cmdlen[i] = cmd->len[i]; 1169 + 1169 1170 if (!cmd->len[i]) 1170 1171 continue; 1172 + 1173 + /* need at least IWL_HCMD_MIN_COPY_SIZE copied */ 1174 + if (copy_size < IWL_HCMD_MIN_COPY_SIZE) { 1175 + int copy = IWL_HCMD_MIN_COPY_SIZE - copy_size; 1176 + 1177 + if (copy > cmdlen[i]) 1178 + copy = cmdlen[i]; 1179 + cmdlen[i] -= copy; 1180 + cmddata[i] += copy; 1181 + copy_size += copy; 1182 + } 1183 + 1171 1184 if (cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY) { 1172 1185 had_nocopy = true; 1173 1186 if (WARN_ON(cmd->dataflags[i] & IWL_HCMD_DFL_DUP)) { ··· 1202 1185 goto free_dup_buf; 1203 1186 } 1204 1187 1205 - dup_buf = kmemdup(cmd->data[i], cmd->len[i], 1188 + dup_buf = kmemdup(cmddata[i], cmdlen[i], 1206 1189 GFP_ATOMIC); 1207 1190 if (!dup_buf) 1208 1191 return -ENOMEM; ··· 1212 1195 idx = -EINVAL; 1213 1196 goto free_dup_buf; 1214 1197 } 1215 - copy_size += cmd->len[i]; 1198 + copy_size += cmdlen[i]; 1216 1199 } 1217 1200 cmd_size += cmd->len[i]; 1218 1201 } ··· 1259 1242 1260 1243 /* and copy the data that needs to be copied */ 1261 1244 cmd_pos = offsetof(struct iwl_device_cmd, payload); 1245 + copy_size = sizeof(out_cmd->hdr); 1262 1246 for (i = 0; i < IWL_MAX_CMD_TFDS; i++) { 1263 - if (!cmd->len[i]) 1247 + int copy = 0; 1248 + 1249 + if (!cmd->len) 1264 1250 continue; 1265 - if (cmd->dataflags[i] & (IWL_HCMD_DFL_NOCOPY | 1266 - IWL_HCMD_DFL_DUP)) 1267 - break; 1268 - memcpy((u8 *)out_cmd + cmd_pos, cmd->data[i], cmd->len[i]); 1269 - cmd_pos += cmd->len[i]; 1251 + 1252 + /* need at least IWL_HCMD_MIN_COPY_SIZE copied */ 1253 + if (copy_size < IWL_HCMD_MIN_COPY_SIZE) { 1254 + copy = IWL_HCMD_MIN_COPY_SIZE - copy_size; 1255 + 1256 + if (copy > cmd->len[i]) 1257 + copy = cmd->len[i]; 1258 + } 1259 + 1260 + /* copy everything if not nocopy/dup */ 1261 + if (!(cmd->dataflags[i] & (IWL_HCMD_DFL_NOCOPY | 1262 + IWL_HCMD_DFL_DUP))) 1263 + copy = cmd->len[i]; 1264 + 1265 + if (copy) { 1266 + memcpy((u8 *)out_cmd + cmd_pos, cmd->data[i], copy); 1267 + cmd_pos += copy; 1268 + copy_size += copy; 1269 + } 1270 1270 } 1271 1271 1272 1272 WARN_ON_ONCE(txq->entries[idx].copy_cmd); ··· 1309 1275 out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), 1310 1276 cmd_size, q->write_ptr, idx, trans_pcie->cmd_queue); 1311 1277 1312 - phys_addr = dma_map_single(trans->dev, &out_cmd->hdr, copy_size, 1278 + /* 1279 + * If the entire command is smaller than IWL_HCMD_MIN_COPY_SIZE, we must 1280 + * still map at least that many bytes for the hardware to write back to. 1281 + * We have enough space, so that's not a problem. 1282 + */ 1283 + dma_size = max_t(u16, copy_size, IWL_HCMD_MIN_COPY_SIZE); 1284 + 1285 + phys_addr = dma_map_single(trans->dev, &out_cmd->hdr, dma_size, 1313 1286 DMA_BIDIRECTIONAL); 1314 1287 if (unlikely(dma_mapping_error(trans->dev, phys_addr))) { 1315 1288 idx = -ENOMEM; ··· 1324 1283 } 1325 1284 1326 1285 dma_unmap_addr_set(out_meta, mapping, phys_addr); 1327 - dma_unmap_len_set(out_meta, len, copy_size); 1286 + dma_unmap_len_set(out_meta, len, dma_size); 1328 1287 1329 1288 iwl_pcie_txq_build_tfd(trans, txq, phys_addr, copy_size, 1); 1330 1289 1290 + /* map the remaining (adjusted) nocopy/dup fragments */ 1331 1291 for (i = 0; i < IWL_MAX_CMD_TFDS; i++) { 1332 - const void *data = cmd->data[i]; 1292 + const void *data = cmddata[i]; 1333 1293 1334 - if (!cmd->len[i]) 1294 + if (!cmdlen[i]) 1335 1295 continue; 1336 1296 if (!(cmd->dataflags[i] & (IWL_HCMD_DFL_NOCOPY | 1337 1297 IWL_HCMD_DFL_DUP))) ··· 1340 1298 if (cmd->dataflags[i] & IWL_HCMD_DFL_DUP) 1341 1299 data = dup_buf; 1342 1300 phys_addr = dma_map_single(trans->dev, (void *)data, 1343 - cmd->len[i], DMA_BIDIRECTIONAL); 1301 + cmdlen[i], DMA_BIDIRECTIONAL); 1344 1302 if (dma_mapping_error(trans->dev, phys_addr)) { 1345 1303 iwl_pcie_tfd_unmap(trans, out_meta, 1346 1304 &txq->tfds[q->write_ptr], ··· 1349 1307 goto out; 1350 1308 } 1351 1309 1352 - iwl_pcie_txq_build_tfd(trans, txq, phys_addr, cmd->len[i], 0); 1310 + iwl_pcie_txq_build_tfd(trans, txq, phys_addr, cmdlen[i], 0); 1353 1311 } 1354 1312 1355 1313 out_meta->flags = cmd->flags; ··· 1359 1317 1360 1318 txq->need_update = 1; 1361 1319 1362 - trace_iwlwifi_dev_hcmd(trans->dev, cmd, cmd_size, 1363 - &out_cmd->hdr, copy_size); 1320 + trace_iwlwifi_dev_hcmd(trans->dev, cmd, cmd_size, &out_cmd->hdr); 1364 1321 1365 1322 /* start timer if queue currently empty */ 1366 1323 if (q->read_ptr == q->write_ptr && trans_pcie->wd_timeout)
+5 -1
drivers/net/wireless/libertas/if_sdio.c
··· 825 825 826 826 sdio_release_host(func); 827 827 828 + /* Set fw_ready before queuing any commands so that 829 + * lbs_thread won't block from sending them to firmware. 830 + */ 831 + priv->fw_ready = 1; 832 + 828 833 /* 829 834 * FUNC_INIT is required for SD8688 WLAN/BT multiple functions 830 835 */ ··· 844 839 netdev_alert(priv->dev, "CMD_FUNC_INIT cmd failed\n"); 845 840 } 846 841 847 - priv->fw_ready = 1; 848 842 wake_up(&card->pwron_waitq); 849 843 850 844 if (!card->started) {
+1 -1
drivers/net/wireless/mwifiex/pcie.c
··· 302 302 i++; 303 303 usleep_range(10, 20); 304 304 /* 50ms max wait */ 305 - if (i == 50000) 305 + if (i == 5000) 306 306 break; 307 307 } 308 308
+6 -2
drivers/net/wireless/rt2x00/rt2x00dev.c
··· 1236 1236 */ 1237 1237 if_limit = &rt2x00dev->if_limits_ap; 1238 1238 if_limit->max = rt2x00dev->ops->max_ap_intf; 1239 - if_limit->types = BIT(NL80211_IFTYPE_AP) | 1240 - BIT(NL80211_IFTYPE_MESH_POINT); 1239 + if_limit->types = BIT(NL80211_IFTYPE_AP); 1240 + #ifdef CONFIG_MAC80211_MESH 1241 + if_limit->types |= BIT(NL80211_IFTYPE_MESH_POINT); 1242 + #endif 1241 1243 1242 1244 /* 1243 1245 * Build up AP interface combinations structure. ··· 1311 1309 rt2x00dev->hw->wiphy->interface_modes |= 1312 1310 BIT(NL80211_IFTYPE_ADHOC) | 1313 1311 BIT(NL80211_IFTYPE_AP) | 1312 + #ifdef CONFIG_MAC80211_MESH 1314 1313 BIT(NL80211_IFTYPE_MESH_POINT) | 1314 + #endif 1315 1315 BIT(NL80211_IFTYPE_WDS); 1316 1316 1317 1317 rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
+3 -1
include/linux/netfilter/ipset/ip_set_ahash.h
··· 854 854 retry: 855 855 ret = 0; 856 856 htable_bits++; 857 + pr_debug("attempt to resize set %s from %u to %u, t %p\n", 858 + set->name, orig->htable_bits, htable_bits, orig); 857 859 if (!htable_bits) { 858 860 /* In case we have plenty of memory :-) */ 859 861 pr_warning("Cannot increase the hashsize of set %s further\n", ··· 875 873 data = ahash_tdata(n, j); 876 874 m = hbucket(t, HKEY(data, h->initval, htable_bits)); 877 875 ret = type_pf_elem_tadd(m, data, AHASH_MAX(h), 0, 878 - type_pf_data_timeout(data)); 876 + ip_set_timeout_get(type_pf_data_timeout(data))); 879 877 if (ret < 0) { 880 878 read_unlock_bh(&set->lock); 881 879 ahash_destroy(t);
+4
include/net/tcp.h
··· 1045 1045 if (sysctl_tcp_low_latency || !tp->ucopy.task) 1046 1046 return false; 1047 1047 1048 + if (skb->len <= tcp_hdrlen(skb) && 1049 + skb_queue_len(&tp->ucopy.prequeue) == 0) 1050 + return false; 1051 + 1048 1052 __skb_queue_tail(&tp->ucopy.prequeue, skb); 1049 1053 tp->ucopy.memory += skb->truesize; 1050 1054 if (tp->ucopy.memory > sk->sk_rcvbuf) {
+1 -1
net/caif/caif_dev.c
··· 118 118 return NULL; 119 119 } 120 120 121 - void caif_flow_cb(struct sk_buff *skb) 121 + static void caif_flow_cb(struct sk_buff *skb) 122 122 { 123 123 struct caif_device_entry *caifd; 124 124 void (*dtor)(struct sk_buff *skb) = NULL;
+2 -2
net/caif/caif_usb.c
··· 81 81 layr->up->ctrlcmd(layr->up, ctrl, layr->id); 82 82 } 83 83 84 - struct cflayer *cfusbl_create(int phyid, u8 ethaddr[ETH_ALEN], 85 - u8 braddr[ETH_ALEN]) 84 + static struct cflayer *cfusbl_create(int phyid, u8 ethaddr[ETH_ALEN], 85 + u8 braddr[ETH_ALEN]) 86 86 { 87 87 struct cfusbl *this = kmalloc(sizeof(struct cfusbl), GFP_ATOMIC); 88 88
+4 -2
net/ipv4/ip_input.c
··· 228 228 icmp_send(skb, ICMP_DEST_UNREACH, 229 229 ICMP_PROT_UNREACH, 0); 230 230 } 231 - } else 231 + kfree_skb(skb); 232 + } else { 232 233 IP_INC_STATS_BH(net, IPSTATS_MIB_INDELIVERS); 233 - kfree_skb(skb); 234 + consume_skb(skb); 235 + } 234 236 } 235 237 } 236 238 out:
+3 -3
net/ipv4/tcp_input.c
··· 5485 5485 if (tcp_checksum_complete_user(sk, skb)) 5486 5486 goto csum_error; 5487 5487 5488 + if ((int)skb->truesize > sk->sk_forward_alloc) 5489 + goto step5; 5490 + 5488 5491 /* Predicted packet is in window by definition. 5489 5492 * seq == rcv_nxt and rcv_wup <= rcv_nxt. 5490 5493 * Hence, check seq<=rcv_wup reduces to: ··· 5498 5495 tcp_store_ts_recent(tp); 5499 5496 5500 5497 tcp_rcv_rtt_measure_ts(sk, skb); 5501 - 5502 - if ((int)skb->truesize > sk->sk_forward_alloc) 5503 - goto step5; 5504 5498 5505 5499 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITS); 5506 5500
+4 -2
net/ipv6/ip6_input.c
··· 241 241 icmpv6_send(skb, ICMPV6_PARAMPROB, 242 242 ICMPV6_UNK_NEXTHDR, nhoff); 243 243 } 244 - } else 244 + kfree_skb(skb); 245 + } else { 245 246 IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INDELIVERS); 246 - kfree_skb(skb); 247 + consume_skb(skb); 248 + } 247 249 } 248 250 rcu_read_unlock(); 249 251 return 0;
+2 -1
net/ipv6/route.c
··· 1915 1915 restart: 1916 1916 read_lock_bh(&table->tb6_lock); 1917 1917 for (rt = table->tb6_root.leaf; rt; rt = rt->dst.rt6_next) { 1918 - if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) { 1918 + if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF) && 1919 + (!rt->rt6i_idev || rt->rt6i_idev->cnf.accept_ra != 2)) { 1919 1920 dst_hold(&rt->dst); 1920 1921 read_unlock_bh(&table->tb6_lock); 1921 1922 ip6_del_rt(rt);
+5 -2
net/irda/iriap.c
··· 495 495 /* case CS_ISO_8859_9: */ 496 496 /* case CS_UNICODE: */ 497 497 default: 498 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n", 499 - __func__, ias_charset_types[charset]); 498 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n", 499 + __func__, charset, 500 + charset < ARRAY_SIZE(ias_charset_types) ? 501 + ias_charset_types[charset] : 502 + "(unknown)"); 500 503 501 504 /* Aborting, close connection! */ 502 505 iriap_disconnect_request(self);
+1
net/l2tp/l2tp_ppp.c
··· 355 355 l2tp_xmit_skb(session, skb, session->hdr_len); 356 356 357 357 sock_put(ps->tunnel_sock); 358 + sock_put(sk); 358 359 359 360 return error; 360 361
+9 -3
net/mac80211/cfg.c
··· 3285 3285 struct cfg80211_chan_def *chandef) 3286 3286 { 3287 3287 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 3288 + struct ieee80211_local *local = wiphy_priv(wiphy); 3288 3289 struct ieee80211_chanctx_conf *chanctx_conf; 3289 3290 int ret = -ENODATA; 3290 3291 3291 3292 rcu_read_lock(); 3292 - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); 3293 - if (chanctx_conf) { 3294 - *chandef = chanctx_conf->def; 3293 + if (local->use_chanctx) { 3294 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); 3295 + if (chanctx_conf) { 3296 + *chandef = chanctx_conf->def; 3297 + ret = 0; 3298 + } 3299 + } else if (local->open_count == local->monitors) { 3300 + *chandef = local->monitor_chandef; 3295 3301 ret = 0; 3296 3302 } 3297 3303 rcu_read_unlock();
+1 -1
net/mac80211/iface.c
··· 107 107 108 108 lockdep_assert_held(&local->mtx); 109 109 110 - active = !list_empty(&local->chanctx_list); 110 + active = !list_empty(&local->chanctx_list) || local->monitors; 111 111 112 112 if (!local->ops->remain_on_channel) { 113 113 list_for_each_entry(roc, &local->roc_list, list) {
+49 -28
net/mac80211/tx.c
··· 1231 1231 if (local->queue_stop_reasons[q] || 1232 1232 (!txpending && !skb_queue_empty(&local->pending[q]))) { 1233 1233 if (unlikely(info->flags & 1234 - IEEE80211_TX_INTFL_OFFCHAN_TX_OK && 1235 - local->queue_stop_reasons[q] & 1236 - ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL))) { 1234 + IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) { 1235 + if (local->queue_stop_reasons[q] & 1236 + ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL)) { 1237 + /* 1238 + * Drop off-channel frames if queues 1239 + * are stopped for any reason other 1240 + * than off-channel operation. Never 1241 + * queue them. 1242 + */ 1243 + spin_unlock_irqrestore( 1244 + &local->queue_stop_reason_lock, 1245 + flags); 1246 + ieee80211_purge_tx_queue(&local->hw, 1247 + skbs); 1248 + return true; 1249 + } 1250 + } else { 1251 + 1237 1252 /* 1238 - * Drop off-channel frames if queues are stopped 1239 - * for any reason other than off-channel 1240 - * operation. Never queue them. 1253 + * Since queue is stopped, queue up frames for 1254 + * later transmission from the tx-pending 1255 + * tasklet when the queue is woken again. 1241 1256 */ 1242 - spin_unlock_irqrestore( 1243 - &local->queue_stop_reason_lock, flags); 1244 - ieee80211_purge_tx_queue(&local->hw, skbs); 1245 - return true; 1257 + if (txpending) 1258 + skb_queue_splice_init(skbs, 1259 + &local->pending[q]); 1260 + else 1261 + skb_queue_splice_tail_init(skbs, 1262 + &local->pending[q]); 1263 + 1264 + spin_unlock_irqrestore(&local->queue_stop_reason_lock, 1265 + flags); 1266 + return false; 1246 1267 } 1247 - 1248 - /* 1249 - * Since queue is stopped, queue up frames for later 1250 - * transmission from the tx-pending tasklet when the 1251 - * queue is woken again. 1252 - */ 1253 - if (txpending) 1254 - skb_queue_splice_init(skbs, &local->pending[q]); 1255 - else 1256 - skb_queue_splice_tail_init(skbs, 1257 - &local->pending[q]); 1258 - 1259 - spin_unlock_irqrestore(&local->queue_stop_reason_lock, 1260 - flags); 1261 - return false; 1262 1268 } 1263 1269 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 1264 1270 ··· 1850 1844 } 1851 1845 1852 1846 if (!is_multicast_ether_addr(skb->data)) { 1847 + struct sta_info *next_hop; 1848 + bool mpp_lookup = true; 1849 + 1853 1850 mpath = mesh_path_lookup(sdata, skb->data); 1854 - if (!mpath) 1851 + if (mpath) { 1852 + mpp_lookup = false; 1853 + next_hop = rcu_dereference(mpath->next_hop); 1854 + if (!next_hop || 1855 + !(mpath->flags & (MESH_PATH_ACTIVE | 1856 + MESH_PATH_RESOLVING))) 1857 + mpp_lookup = true; 1858 + } 1859 + 1860 + if (mpp_lookup) 1855 1861 mppath = mpp_path_lookup(sdata, skb->data); 1862 + 1863 + if (mppath && mpath) 1864 + mesh_path_del(mpath->sdata, mpath->dst); 1856 1865 } 1857 1866 1858 1867 /* ··· 2371 2350 if (local->tim_in_locked_section) { 2372 2351 __ieee80211_beacon_add_tim(sdata, ps, skb); 2373 2352 } else { 2374 - spin_lock(&local->tim_lock); 2353 + spin_lock_bh(&local->tim_lock); 2375 2354 __ieee80211_beacon_add_tim(sdata, ps, skb); 2376 - spin_unlock(&local->tim_lock); 2355 + spin_unlock_bh(&local->tim_lock); 2377 2356 } 2378 2357 2379 2358 return 0;
+2 -1
net/netfilter/ipset/ip_set_core.c
··· 1470 1470 if (ret == -EAGAIN) 1471 1471 ret = 1; 1472 1472 1473 - return ret < 0 ? ret : ret > 0 ? 0 : -IPSET_ERR_EXIST; 1473 + return (ret < 0 && ret != -ENOTEMPTY) ? ret : 1474 + ret > 0 ? 0 : -IPSET_ERR_EXIST; 1474 1475 } 1475 1476 1476 1477 /* Get headed data of a set */
+4 -4
net/rds/message.c
··· 82 82 void rds_message_put(struct rds_message *rm) 83 83 { 84 84 rdsdebug("put rm %p ref %d\n", rm, atomic_read(&rm->m_refcount)); 85 - if (atomic_read(&rm->m_refcount) == 0) { 86 - printk(KERN_CRIT "danger refcount zero on %p\n", rm); 87 - WARN_ON(1); 88 - } 85 + WARN(!atomic_read(&rm->m_refcount), "danger refcount zero on %p\n", rm); 89 86 if (atomic_dec_and_test(&rm->m_refcount)) { 90 87 BUG_ON(!list_empty(&rm->m_sock_item)); 91 88 BUG_ON(!list_empty(&rm->m_conn_item)); ··· 193 196 struct rds_message *rds_message_alloc(unsigned int extra_len, gfp_t gfp) 194 197 { 195 198 struct rds_message *rm; 199 + 200 + if (extra_len > KMALLOC_MAX_SIZE - sizeof(struct rds_message)) 201 + return NULL; 196 202 197 203 rm = kzalloc(sizeof(struct rds_message) + extra_len, gfp); 198 204 if (!rm)
+1 -1
net/sctp/endpointola.c
··· 155 155 156 156 /* SCTP-AUTH extensions*/ 157 157 INIT_LIST_HEAD(&ep->endpoint_shared_keys); 158 - null_key = sctp_auth_shkey_create(0, GFP_KERNEL); 158 + null_key = sctp_auth_shkey_create(0, gfp); 159 159 if (!null_key) 160 160 goto nomem; 161 161
+3 -3
net/sctp/socket.c
··· 5653 5653 if (len < sizeof(sctp_assoc_t)) 5654 5654 return -EINVAL; 5655 5655 5656 + /* Allow the struct to grow and fill in as much as possible */ 5657 + len = min_t(size_t, len, sizeof(sas)); 5658 + 5656 5659 if (copy_from_user(&sas, optval, len)) 5657 5660 return -EFAULT; 5658 5661 ··· 5688 5685 5689 5686 /* Mark beginning of a new observation period */ 5690 5687 asoc->stats.max_obs_rto = asoc->rto_min; 5691 - 5692 - /* Allow the struct to grow and fill in as much as possible */ 5693 - len = min_t(size_t, len, sizeof(sas)); 5694 5688 5695 5689 if (put_user(len, optlen)) 5696 5690 return -EFAULT;
+3 -5
net/sctp/ssnmap.c
··· 41 41 #include <net/sctp/sctp.h> 42 42 #include <net/sctp/sm.h> 43 43 44 - #define MAX_KMALLOC_SIZE 131072 45 - 46 44 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in, 47 45 __u16 out); 48 46 ··· 63 65 int size; 64 66 65 67 size = sctp_ssnmap_size(in, out); 66 - if (size <= MAX_KMALLOC_SIZE) 68 + if (size <= KMALLOC_MAX_SIZE) 67 69 retval = kmalloc(size, gfp); 68 70 else 69 71 retval = (struct sctp_ssnmap *) ··· 80 82 return retval; 81 83 82 84 fail_map: 83 - if (size <= MAX_KMALLOC_SIZE) 85 + if (size <= KMALLOC_MAX_SIZE) 84 86 kfree(retval); 85 87 else 86 88 free_pages((unsigned long)retval, get_order(size)); ··· 122 124 int size; 123 125 124 126 size = sctp_ssnmap_size(map->in.len, map->out.len); 125 - if (size <= MAX_KMALLOC_SIZE) 127 + if (size <= KMALLOC_MAX_SIZE) 126 128 kfree(map); 127 129 else 128 130 free_pages((unsigned long)map, get_order(size));
+7 -6
net/sctp/tsnmap.c
··· 51 51 static void sctp_tsnmap_update(struct sctp_tsnmap *map); 52 52 static void sctp_tsnmap_find_gap_ack(unsigned long *map, __u16 off, 53 53 __u16 len, __u16 *start, __u16 *end); 54 - static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 gap); 54 + static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 size); 55 55 56 56 /* Initialize a block of memory as a tsnmap. */ 57 57 struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *map, __u16 len, ··· 124 124 125 125 gap = tsn - map->base_tsn; 126 126 127 - if (gap >= map->len && !sctp_tsnmap_grow(map, gap)) 127 + if (gap >= map->len && !sctp_tsnmap_grow(map, gap + 1)) 128 128 return -ENOMEM; 129 129 130 130 if (!sctp_tsnmap_has_gap(map) && gap == 0) { ··· 360 360 return ngaps; 361 361 } 362 362 363 - static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 gap) 363 + static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 size) 364 364 { 365 365 unsigned long *new; 366 366 unsigned long inc; 367 367 u16 len; 368 368 369 - if (gap >= SCTP_TSN_MAP_SIZE) 369 + if (size > SCTP_TSN_MAP_SIZE) 370 370 return 0; 371 371 372 - inc = ALIGN((gap - map->len),BITS_PER_LONG) + SCTP_TSN_MAP_INCREMENT; 372 + inc = ALIGN((size - map->len), BITS_PER_LONG) + SCTP_TSN_MAP_INCREMENT; 373 373 len = min_t(u16, map->len + inc, SCTP_TSN_MAP_SIZE); 374 374 375 375 new = kzalloc(len>>3, GFP_ATOMIC); 376 376 if (!new) 377 377 return 0; 378 378 379 - bitmap_copy(new, map->tsn_map, map->max_tsn_seen - map->base_tsn); 379 + bitmap_copy(new, map->tsn_map, 380 + map->max_tsn_seen - map->cumulative_tsn_ack_point); 380 381 kfree(map->tsn_map); 381 382 map->tsn_map = new; 382 383 map->len = len;
+71 -16
net/sctp/ulpqueue.c
··· 106 106 { 107 107 struct sk_buff_head temp; 108 108 struct sctp_ulpevent *event; 109 + int event_eor = 0; 109 110 110 111 /* Create an event from the incoming chunk. */ 111 112 event = sctp_ulpevent_make_rcvmsg(chunk->asoc, chunk, gfp); ··· 128 127 /* Send event to the ULP. 'event' is the sctp_ulpevent for 129 128 * very first SKB on the 'temp' list. 130 129 */ 131 - if (event) 130 + if (event) { 131 + event_eor = (event->msg_flags & MSG_EOR) ? 1 : 0; 132 132 sctp_ulpq_tail_event(ulpq, event); 133 + } 133 134 134 - return 0; 135 + return event_eor; 135 136 } 136 137 137 138 /* Add a new event for propagation to the ULP. */ ··· 543 540 ctsn = cevent->tsn; 544 541 545 542 switch (cevent->msg_flags & SCTP_DATA_FRAG_MASK) { 543 + case SCTP_DATA_FIRST_FRAG: 544 + if (!first_frag) 545 + return NULL; 546 + goto done; 546 547 case SCTP_DATA_MIDDLE_FRAG: 547 548 if (!first_frag) { 548 549 first_frag = pos; 549 550 next_tsn = ctsn + 1; 550 551 last_frag = pos; 551 - } else if (next_tsn == ctsn) 552 + } else if (next_tsn == ctsn) { 552 553 next_tsn++; 553 - else 554 + last_frag = pos; 555 + } else 554 556 goto done; 555 557 break; 556 558 case SCTP_DATA_LAST_FRAG: ··· 659 651 } else 660 652 goto done; 661 653 break; 654 + 655 + case SCTP_DATA_LAST_FRAG: 656 + if (!first_frag) 657 + return NULL; 658 + else 659 + goto done; 660 + break; 661 + 662 662 default: 663 663 return NULL; 664 664 } ··· 978 962 struct sk_buff_head *list, __u16 needed) 979 963 { 980 964 __u16 freed = 0; 981 - __u32 tsn; 982 - struct sk_buff *skb; 965 + __u32 tsn, last_tsn; 966 + struct sk_buff *skb, *flist, *last; 983 967 struct sctp_ulpevent *event; 984 968 struct sctp_tsnmap *tsnmap; 985 969 986 970 tsnmap = &ulpq->asoc->peer.tsn_map; 987 971 988 - while ((skb = __skb_dequeue_tail(list)) != NULL) { 989 - freed += skb_headlen(skb); 972 + while ((skb = skb_peek_tail(list)) != NULL) { 990 973 event = sctp_skb2event(skb); 991 974 tsn = event->tsn; 992 975 976 + /* Don't renege below the Cumulative TSN ACK Point. */ 977 + if (TSN_lte(tsn, sctp_tsnmap_get_ctsn(tsnmap))) 978 + break; 979 + 980 + /* Events in ordering queue may have multiple fragments 981 + * corresponding to additional TSNs. Sum the total 982 + * freed space; find the last TSN. 983 + */ 984 + freed += skb_headlen(skb); 985 + flist = skb_shinfo(skb)->frag_list; 986 + for (last = flist; flist; flist = flist->next) { 987 + last = flist; 988 + freed += skb_headlen(last); 989 + } 990 + if (last) 991 + last_tsn = sctp_skb2event(last)->tsn; 992 + else 993 + last_tsn = tsn; 994 + 995 + /* Unlink the event, then renege all applicable TSNs. */ 996 + __skb_unlink(skb, list); 993 997 sctp_ulpevent_free(event); 994 - sctp_tsnmap_renege(tsnmap, tsn); 998 + while (TSN_lte(tsn, last_tsn)) { 999 + sctp_tsnmap_renege(tsnmap, tsn); 1000 + tsn++; 1001 + } 995 1002 if (freed >= needed) 996 1003 return freed; 997 1004 } ··· 1041 1002 struct sctp_ulpevent *event; 1042 1003 struct sctp_association *asoc; 1043 1004 struct sctp_sock *sp; 1005 + __u32 ctsn; 1006 + struct sk_buff *skb; 1044 1007 1045 1008 asoc = ulpq->asoc; 1046 1009 sp = sctp_sk(asoc->base.sk); 1047 1010 1048 1011 /* If the association is already in Partial Delivery mode 1049 - * we have noting to do. 1012 + * we have nothing to do. 1050 1013 */ 1051 1014 if (ulpq->pd_mode) 1052 1015 return; 1016 + 1017 + /* Data must be at or below the Cumulative TSN ACK Point to 1018 + * start partial delivery. 1019 + */ 1020 + skb = skb_peek(&asoc->ulpq.reasm); 1021 + if (skb != NULL) { 1022 + ctsn = sctp_skb2event(skb)->tsn; 1023 + if (!TSN_lte(ctsn, sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map))) 1024 + return; 1025 + } 1053 1026 1054 1027 /* If the user enabled fragment interleave socket option, 1055 1028 * multiple associations can enter partial delivery. ··· 1105 1054 } 1106 1055 /* If able to free enough room, accept this chunk. */ 1107 1056 if (chunk && (freed >= needed)) { 1108 - __u32 tsn; 1109 - tsn = ntohl(chunk->subh.data_hdr->tsn); 1110 - sctp_tsnmap_mark(&asoc->peer.tsn_map, tsn, chunk->transport); 1111 - sctp_ulpq_tail_data(ulpq, chunk, gfp); 1112 - 1113 - sctp_ulpq_partial_delivery(ulpq, gfp); 1057 + int retval; 1058 + retval = sctp_ulpq_tail_data(ulpq, chunk, gfp); 1059 + /* 1060 + * Enter partial delivery if chunk has not been 1061 + * delivered; otherwise, drain the reassembly queue. 1062 + */ 1063 + if (retval <= 0) 1064 + sctp_ulpq_partial_delivery(ulpq, gfp); 1065 + else if (retval == 1) 1066 + sctp_ulpq_reasm_drain(ulpq); 1114 1067 } 1115 1068 1116 1069 sk_mem_reclaim(asoc->base.sk);
+3 -58
net/wireless/nl80211.c
··· 554 554 if ((chan->flags & IEEE80211_CHAN_NO_IBSS) && 555 555 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS)) 556 556 goto nla_put_failure; 557 - if (chan->flags & IEEE80211_CHAN_RADAR) { 558 - u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered); 559 - if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR)) 560 - goto nla_put_failure; 561 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE, 562 - chan->dfs_state)) 563 - goto nla_put_failure; 564 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time)) 565 - goto nla_put_failure; 566 - } 557 + if ((chan->flags & IEEE80211_CHAN_RADAR) && 558 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR)) 559 + goto nla_put_failure; 567 560 if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) && 568 561 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS)) 569 562 goto nla_put_failure; ··· 893 900 nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM, 894 901 c->max_interfaces)) 895 902 goto nla_put_failure; 896 - if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, 897 - c->radar_detect_widths)) 898 - goto nla_put_failure; 899 903 900 904 nla_nest_end(msg, nl_combi); 901 905 } ··· 903 913 nla_put_failure: 904 914 return -ENOBUFS; 905 915 } 906 - 907 - #ifdef CONFIG_PM 908 - static int nl80211_send_wowlan_tcp_caps(struct cfg80211_registered_device *rdev, 909 - struct sk_buff *msg) 910 - { 911 - const struct wiphy_wowlan_tcp_support *tcp = rdev->wiphy.wowlan.tcp; 912 - struct nlattr *nl_tcp; 913 - 914 - if (!tcp) 915 - return 0; 916 - 917 - nl_tcp = nla_nest_start(msg, NL80211_WOWLAN_TRIG_TCP_CONNECTION); 918 - if (!nl_tcp) 919 - return -ENOBUFS; 920 - 921 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD, 922 - tcp->data_payload_max)) 923 - return -ENOBUFS; 924 - 925 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD, 926 - tcp->data_payload_max)) 927 - return -ENOBUFS; 928 - 929 - if (tcp->seq && nla_put_flag(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ)) 930 - return -ENOBUFS; 931 - 932 - if (tcp->tok && nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN, 933 - sizeof(*tcp->tok), tcp->tok)) 934 - return -ENOBUFS; 935 - 936 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_DATA_INTERVAL, 937 - tcp->data_interval_max)) 938 - return -ENOBUFS; 939 - 940 - if (nla_put_u32(msg, NL80211_WOWLAN_TCP_WAKE_PAYLOAD, 941 - tcp->wake_payload_max)) 942 - return -ENOBUFS; 943 - 944 - nla_nest_end(msg, nl_tcp); 945 - return 0; 946 - } 947 - #endif 948 916 949 917 static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags, 950 918 struct cfg80211_registered_device *dev) ··· 1277 1329 sizeof(pat), &pat)) 1278 1330 goto nla_put_failure; 1279 1331 } 1280 - 1281 - if (nl80211_send_wowlan_tcp_caps(dev, msg)) 1282 - goto nla_put_failure; 1283 1332 1284 1333 nla_nest_end(msg, nl_wowlan); 1285 1334 }