diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bnx2.c | 48 | ||||
-rw-r--r-- | drivers/net/e1000e/netdev.c | 3 | ||||
-rw-r--r-- | drivers/net/gianfar.c | 6 | ||||
-rw-r--r-- | drivers/net/pcmcia/smc91c92_cs.c | 31 | ||||
-rw-r--r-- | drivers/net/sb1250-mac.c | 67 | ||||
-rw-r--r-- | drivers/net/sfc/efx.c | 4 | ||||
-rw-r--r-- | drivers/net/sfc/falcon.c | 4 | ||||
-rw-r--r-- | drivers/net/sfc/falcon_boards.c | 13 | ||||
-rw-r--r-- | drivers/net/sfc/nic.h | 2 | ||||
-rw-r--r-- | drivers/net/sfc/siena.c | 13 | ||||
-rw-r--r-- | drivers/net/usb/Kconfig | 9 | ||||
-rw-r--r-- | drivers/net/usb/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/usb/cdc_ether.c | 1 | ||||
-rw-r--r-- | drivers/net/usb/ipheth.c | 15 | ||||
-rw-r--r-- | drivers/net/usb/kaweth.c | 1 | ||||
-rw-r--r-- | drivers/net/usb/sierra_net.c | 1004 | ||||
-rw-r--r-- | drivers/net/wireless/p54/p54pci.c | 2 |
17 files changed, 1132 insertions, 92 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 53326fed6c81..ab26bbc2a1d3 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -58,8 +58,8 @@ | |||
58 | #include "bnx2_fw.h" | 58 | #include "bnx2_fw.h" |
59 | 59 | ||
60 | #define DRV_MODULE_NAME "bnx2" | 60 | #define DRV_MODULE_NAME "bnx2" |
61 | #define DRV_MODULE_VERSION "2.0.8" | 61 | #define DRV_MODULE_VERSION "2.0.9" |
62 | #define DRV_MODULE_RELDATE "Feb 15, 2010" | 62 | #define DRV_MODULE_RELDATE "April 27, 2010" |
63 | #define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-5.0.0.j6.fw" | 63 | #define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-5.0.0.j6.fw" |
64 | #define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-5.0.0.j3.fw" | 64 | #define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-5.0.0.j3.fw" |
65 | #define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-5.0.0.j9.fw" | 65 | #define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-5.0.0.j9.fw" |
@@ -651,9 +651,10 @@ bnx2_napi_enable(struct bnx2 *bp) | |||
651 | } | 651 | } |
652 | 652 | ||
653 | static void | 653 | static void |
654 | bnx2_netif_stop(struct bnx2 *bp) | 654 | bnx2_netif_stop(struct bnx2 *bp, bool stop_cnic) |
655 | { | 655 | { |
656 | bnx2_cnic_stop(bp); | 656 | if (stop_cnic) |
657 | bnx2_cnic_stop(bp); | ||
657 | if (netif_running(bp->dev)) { | 658 | if (netif_running(bp->dev)) { |
658 | int i; | 659 | int i; |
659 | 660 | ||
@@ -671,14 +672,15 @@ bnx2_netif_stop(struct bnx2 *bp) | |||
671 | } | 672 | } |
672 | 673 | ||
673 | static void | 674 | static void |
674 | bnx2_netif_start(struct bnx2 *bp) | 675 | bnx2_netif_start(struct bnx2 *bp, bool start_cnic) |
675 | { | 676 | { |
676 | if (atomic_dec_and_test(&bp->intr_sem)) { | 677 | if (atomic_dec_and_test(&bp->intr_sem)) { |
677 | if (netif_running(bp->dev)) { | 678 | if (netif_running(bp->dev)) { |
678 | netif_tx_wake_all_queues(bp->dev); | 679 | netif_tx_wake_all_queues(bp->dev); |
679 | bnx2_napi_enable(bp); | 680 | bnx2_napi_enable(bp); |
680 | bnx2_enable_int(bp); | 681 | bnx2_enable_int(bp); |
681 | bnx2_cnic_start(bp); | 682 | if (start_cnic) |
683 | bnx2_cnic_start(bp); | ||
682 | } | 684 | } |
683 | } | 685 | } |
684 | } | 686 | } |
@@ -4758,8 +4760,12 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code) | |||
4758 | rc = bnx2_alloc_bad_rbuf(bp); | 4760 | rc = bnx2_alloc_bad_rbuf(bp); |
4759 | } | 4761 | } |
4760 | 4762 | ||
4761 | if (bp->flags & BNX2_FLAG_USING_MSIX) | 4763 | if (bp->flags & BNX2_FLAG_USING_MSIX) { |
4762 | bnx2_setup_msix_tbl(bp); | 4764 | bnx2_setup_msix_tbl(bp); |
4765 | /* Prevent MSIX table reads and write from timing out */ | ||
4766 | REG_WR(bp, BNX2_MISC_ECO_HW_CTL, | ||
4767 | BNX2_MISC_ECO_HW_CTL_LARGE_GRC_TMOUT_EN); | ||
4768 | } | ||
4763 | 4769 | ||
4764 | return rc; | 4770 | return rc; |
4765 | } | 4771 | } |
@@ -6272,12 +6278,12 @@ bnx2_reset_task(struct work_struct *work) | |||
6272 | return; | 6278 | return; |
6273 | } | 6279 | } |
6274 | 6280 | ||
6275 | bnx2_netif_stop(bp); | 6281 | bnx2_netif_stop(bp, true); |
6276 | 6282 | ||
6277 | bnx2_init_nic(bp, 1); | 6283 | bnx2_init_nic(bp, 1); |
6278 | 6284 | ||
6279 | atomic_set(&bp->intr_sem, 1); | 6285 | atomic_set(&bp->intr_sem, 1); |
6280 | bnx2_netif_start(bp); | 6286 | bnx2_netif_start(bp, true); |
6281 | rtnl_unlock(); | 6287 | rtnl_unlock(); |
6282 | } | 6288 | } |
6283 | 6289 | ||
@@ -6319,7 +6325,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp) | |||
6319 | struct bnx2 *bp = netdev_priv(dev); | 6325 | struct bnx2 *bp = netdev_priv(dev); |
6320 | 6326 | ||
6321 | if (netif_running(dev)) | 6327 | if (netif_running(dev)) |
6322 | bnx2_netif_stop(bp); | 6328 | bnx2_netif_stop(bp, false); |
6323 | 6329 | ||
6324 | bp->vlgrp = vlgrp; | 6330 | bp->vlgrp = vlgrp; |
6325 | 6331 | ||
@@ -6330,7 +6336,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp) | |||
6330 | if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) | 6336 | if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) |
6331 | bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); | 6337 | bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); |
6332 | 6338 | ||
6333 | bnx2_netif_start(bp); | 6339 | bnx2_netif_start(bp, false); |
6334 | } | 6340 | } |
6335 | #endif | 6341 | #endif |
6336 | 6342 | ||
@@ -7050,9 +7056,9 @@ bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal) | |||
7050 | bp->stats_ticks &= BNX2_HC_STATS_TICKS_HC_STAT_TICKS; | 7056 | bp->stats_ticks &= BNX2_HC_STATS_TICKS_HC_STAT_TICKS; |
7051 | 7057 | ||
7052 | if (netif_running(bp->dev)) { | 7058 | if (netif_running(bp->dev)) { |
7053 | bnx2_netif_stop(bp); | 7059 | bnx2_netif_stop(bp, true); |
7054 | bnx2_init_nic(bp, 0); | 7060 | bnx2_init_nic(bp, 0); |
7055 | bnx2_netif_start(bp); | 7061 | bnx2_netif_start(bp, true); |
7056 | } | 7062 | } |
7057 | 7063 | ||
7058 | return 0; | 7064 | return 0; |
@@ -7082,7 +7088,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx) | |||
7082 | /* Reset will erase chipset stats; save them */ | 7088 | /* Reset will erase chipset stats; save them */ |
7083 | bnx2_save_stats(bp); | 7089 | bnx2_save_stats(bp); |
7084 | 7090 | ||
7085 | bnx2_netif_stop(bp); | 7091 | bnx2_netif_stop(bp, true); |
7086 | bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); | 7092 | bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); |
7087 | bnx2_free_skbs(bp); | 7093 | bnx2_free_skbs(bp); |
7088 | bnx2_free_mem(bp); | 7094 | bnx2_free_mem(bp); |
@@ -7110,7 +7116,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx) | |||
7110 | bnx2_setup_cnic_irq_info(bp); | 7116 | bnx2_setup_cnic_irq_info(bp); |
7111 | mutex_unlock(&bp->cnic_lock); | 7117 | mutex_unlock(&bp->cnic_lock); |
7112 | #endif | 7118 | #endif |
7113 | bnx2_netif_start(bp); | 7119 | bnx2_netif_start(bp, true); |
7114 | } | 7120 | } |
7115 | return 0; | 7121 | return 0; |
7116 | } | 7122 | } |
@@ -7363,7 +7369,7 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) | |||
7363 | if (etest->flags & ETH_TEST_FL_OFFLINE) { | 7369 | if (etest->flags & ETH_TEST_FL_OFFLINE) { |
7364 | int i; | 7370 | int i; |
7365 | 7371 | ||
7366 | bnx2_netif_stop(bp); | 7372 | bnx2_netif_stop(bp, true); |
7367 | bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG); | 7373 | bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG); |
7368 | bnx2_free_skbs(bp); | 7374 | bnx2_free_skbs(bp); |
7369 | 7375 | ||
@@ -7382,7 +7388,7 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) | |||
7382 | bnx2_shutdown_chip(bp); | 7388 | bnx2_shutdown_chip(bp); |
7383 | else { | 7389 | else { |
7384 | bnx2_init_nic(bp, 1); | 7390 | bnx2_init_nic(bp, 1); |
7385 | bnx2_netif_start(bp); | 7391 | bnx2_netif_start(bp, true); |
7386 | } | 7392 | } |
7387 | 7393 | ||
7388 | /* wait for link up */ | 7394 | /* wait for link up */ |
@@ -8376,7 +8382,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state) | |||
8376 | return 0; | 8382 | return 0; |
8377 | 8383 | ||
8378 | flush_scheduled_work(); | 8384 | flush_scheduled_work(); |
8379 | bnx2_netif_stop(bp); | 8385 | bnx2_netif_stop(bp, true); |
8380 | netif_device_detach(dev); | 8386 | netif_device_detach(dev); |
8381 | del_timer_sync(&bp->timer); | 8387 | del_timer_sync(&bp->timer); |
8382 | bnx2_shutdown_chip(bp); | 8388 | bnx2_shutdown_chip(bp); |
@@ -8398,7 +8404,7 @@ bnx2_resume(struct pci_dev *pdev) | |||
8398 | bnx2_set_power_state(bp, PCI_D0); | 8404 | bnx2_set_power_state(bp, PCI_D0); |
8399 | netif_device_attach(dev); | 8405 | netif_device_attach(dev); |
8400 | bnx2_init_nic(bp, 1); | 8406 | bnx2_init_nic(bp, 1); |
8401 | bnx2_netif_start(bp); | 8407 | bnx2_netif_start(bp, true); |
8402 | return 0; | 8408 | return 0; |
8403 | } | 8409 | } |
8404 | 8410 | ||
@@ -8425,7 +8431,7 @@ static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev, | |||
8425 | } | 8431 | } |
8426 | 8432 | ||
8427 | if (netif_running(dev)) { | 8433 | if (netif_running(dev)) { |
8428 | bnx2_netif_stop(bp); | 8434 | bnx2_netif_stop(bp, true); |
8429 | del_timer_sync(&bp->timer); | 8435 | del_timer_sync(&bp->timer); |
8430 | bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET); | 8436 | bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET); |
8431 | } | 8437 | } |
@@ -8482,7 +8488,7 @@ static void bnx2_io_resume(struct pci_dev *pdev) | |||
8482 | 8488 | ||
8483 | rtnl_lock(); | 8489 | rtnl_lock(); |
8484 | if (netif_running(dev)) | 8490 | if (netif_running(dev)) |
8485 | bnx2_netif_start(bp); | 8491 | bnx2_netif_start(bp, true); |
8486 | 8492 | ||
8487 | netif_device_attach(dev); | 8493 | netif_device_attach(dev); |
8488 | rtnl_unlock(); | 8494 | rtnl_unlock(); |
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 904bd6bf3199..d13760dc27f8 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -5020,6 +5020,9 @@ static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) | |||
5020 | reg16 &= ~state; | 5020 | reg16 &= ~state; |
5021 | pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); | 5021 | pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); |
5022 | 5022 | ||
5023 | if (!pdev->bus->self) | ||
5024 | return; | ||
5025 | |||
5023 | pos = pci_pcie_cap(pdev->bus->self); | 5026 | pos = pci_pcie_cap(pdev->bus->self); |
5024 | pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, ®16); | 5027 | pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, ®16); |
5025 | reg16 &= ~state; | 5028 | reg16 &= ~state; |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 0cef967499d3..5267c27e3174 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -1567,9 +1567,9 @@ static void gfar_halt_nodisable(struct net_device *dev) | |||
1567 | tempval |= (DMACTRL_GRS | DMACTRL_GTS); | 1567 | tempval |= (DMACTRL_GRS | DMACTRL_GTS); |
1568 | gfar_write(®s->dmactrl, tempval); | 1568 | gfar_write(®s->dmactrl, tempval); |
1569 | 1569 | ||
1570 | while (!(gfar_read(®s->ievent) & | 1570 | spin_event_timeout(((gfar_read(®s->ievent) & |
1571 | (IEVENT_GRSC | IEVENT_GTSC))) | 1571 | (IEVENT_GRSC | IEVENT_GTSC)) == |
1572 | cpu_relax(); | 1572 | (IEVENT_GRSC | IEVENT_GTSC)), -1, 0); |
1573 | } | 1573 | } |
1574 | } | 1574 | } |
1575 | 1575 | ||
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 408f3d7b1545..949ac1a12537 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -1804,23 +1804,30 @@ static void media_check(u_long arg) | |||
1804 | SMC_SELECT_BANK(1); | 1804 | SMC_SELECT_BANK(1); |
1805 | media |= (inw(ioaddr + CONFIG) & CFG_AUI_SELECT) ? 2 : 1; | 1805 | media |= (inw(ioaddr + CONFIG) & CFG_AUI_SELECT) ? 2 : 1; |
1806 | 1806 | ||
1807 | SMC_SELECT_BANK(saved_bank); | ||
1808 | spin_unlock_irqrestore(&smc->lock, flags); | ||
1809 | |||
1807 | /* Check for pending interrupt with watchdog flag set: with | 1810 | /* Check for pending interrupt with watchdog flag set: with |
1808 | this, we can limp along even if the interrupt is blocked */ | 1811 | this, we can limp along even if the interrupt is blocked */ |
1809 | if (smc->watchdog++ && ((i>>8) & i)) { | 1812 | if (smc->watchdog++ && ((i>>8) & i)) { |
1810 | if (!smc->fast_poll) | 1813 | if (!smc->fast_poll) |
1811 | printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); | 1814 | printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); |
1815 | local_irq_save(flags); | ||
1812 | smc_interrupt(dev->irq, dev); | 1816 | smc_interrupt(dev->irq, dev); |
1817 | local_irq_restore(flags); | ||
1813 | smc->fast_poll = HZ; | 1818 | smc->fast_poll = HZ; |
1814 | } | 1819 | } |
1815 | if (smc->fast_poll) { | 1820 | if (smc->fast_poll) { |
1816 | smc->fast_poll--; | 1821 | smc->fast_poll--; |
1817 | smc->media.expires = jiffies + HZ/100; | 1822 | smc->media.expires = jiffies + HZ/100; |
1818 | add_timer(&smc->media); | 1823 | add_timer(&smc->media); |
1819 | SMC_SELECT_BANK(saved_bank); | ||
1820 | spin_unlock_irqrestore(&smc->lock, flags); | ||
1821 | return; | 1824 | return; |
1822 | } | 1825 | } |
1823 | 1826 | ||
1827 | spin_lock_irqsave(&smc->lock, flags); | ||
1828 | |||
1829 | saved_bank = inw(ioaddr + BANK_SELECT); | ||
1830 | |||
1824 | if (smc->cfg & CFG_MII_SELECT) { | 1831 | if (smc->cfg & CFG_MII_SELECT) { |
1825 | if (smc->mii_if.phy_id < 0) | 1832 | if (smc->mii_if.phy_id < 0) |
1826 | goto reschedule; | 1833 | goto reschedule; |
@@ -1978,15 +1985,16 @@ static int smc_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
1978 | unsigned int ioaddr = dev->base_addr; | 1985 | unsigned int ioaddr = dev->base_addr; |
1979 | u16 saved_bank = inw(ioaddr + BANK_SELECT); | 1986 | u16 saved_bank = inw(ioaddr + BANK_SELECT); |
1980 | int ret; | 1987 | int ret; |
1988 | unsigned long flags; | ||
1981 | 1989 | ||
1982 | spin_lock_irq(&smc->lock); | 1990 | spin_lock_irqsave(&smc->lock, flags); |
1983 | SMC_SELECT_BANK(3); | 1991 | SMC_SELECT_BANK(3); |
1984 | if (smc->cfg & CFG_MII_SELECT) | 1992 | if (smc->cfg & CFG_MII_SELECT) |
1985 | ret = mii_ethtool_gset(&smc->mii_if, ecmd); | 1993 | ret = mii_ethtool_gset(&smc->mii_if, ecmd); |
1986 | else | 1994 | else |
1987 | ret = smc_netdev_get_ecmd(dev, ecmd); | 1995 | ret = smc_netdev_get_ecmd(dev, ecmd); |
1988 | SMC_SELECT_BANK(saved_bank); | 1996 | SMC_SELECT_BANK(saved_bank); |
1989 | spin_unlock_irq(&smc->lock); | 1997 | spin_unlock_irqrestore(&smc->lock, flags); |
1990 | return ret; | 1998 | return ret; |
1991 | } | 1999 | } |
1992 | 2000 | ||
@@ -1996,15 +2004,16 @@ static int smc_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
1996 | unsigned int ioaddr = dev->base_addr; | 2004 | unsigned int ioaddr = dev->base_addr; |
1997 | u16 saved_bank = inw(ioaddr + BANK_SELECT); | 2005 | u16 saved_bank = inw(ioaddr + BANK_SELECT); |
1998 | int ret; | 2006 | int ret; |
2007 | unsigned long flags; | ||
1999 | 2008 | ||
2000 | spin_lock_irq(&smc->lock); | 2009 | spin_lock_irqsave(&smc->lock, flags); |
2001 | SMC_SELECT_BANK(3); | 2010 | SMC_SELECT_BANK(3); |
2002 | if (smc->cfg & CFG_MII_SELECT) | 2011 | if (smc->cfg & CFG_MII_SELECT) |
2003 | ret = mii_ethtool_sset(&smc->mii_if, ecmd); | 2012 | ret = mii_ethtool_sset(&smc->mii_if, ecmd); |
2004 | else | 2013 | else |
2005 | ret = smc_netdev_set_ecmd(dev, ecmd); | 2014 | ret = smc_netdev_set_ecmd(dev, ecmd); |
2006 | SMC_SELECT_BANK(saved_bank); | 2015 | SMC_SELECT_BANK(saved_bank); |
2007 | spin_unlock_irq(&smc->lock); | 2016 | spin_unlock_irqrestore(&smc->lock, flags); |
2008 | return ret; | 2017 | return ret; |
2009 | } | 2018 | } |
2010 | 2019 | ||
@@ -2014,12 +2023,13 @@ static u32 smc_get_link(struct net_device *dev) | |||
2014 | unsigned int ioaddr = dev->base_addr; | 2023 | unsigned int ioaddr = dev->base_addr; |
2015 | u16 saved_bank = inw(ioaddr + BANK_SELECT); | 2024 | u16 saved_bank = inw(ioaddr + BANK_SELECT); |
2016 | u32 ret; | 2025 | u32 ret; |
2026 | unsigned long flags; | ||
2017 | 2027 | ||
2018 | spin_lock_irq(&smc->lock); | 2028 | spin_lock_irqsave(&smc->lock, flags); |
2019 | SMC_SELECT_BANK(3); | 2029 | SMC_SELECT_BANK(3); |
2020 | ret = smc_link_ok(dev); | 2030 | ret = smc_link_ok(dev); |
2021 | SMC_SELECT_BANK(saved_bank); | 2031 | SMC_SELECT_BANK(saved_bank); |
2022 | spin_unlock_irq(&smc->lock); | 2032 | spin_unlock_irqrestore(&smc->lock, flags); |
2023 | return ret; | 2033 | return ret; |
2024 | } | 2034 | } |
2025 | 2035 | ||
@@ -2056,16 +2066,17 @@ static int smc_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) | |||
2056 | int rc = 0; | 2066 | int rc = 0; |
2057 | u16 saved_bank; | 2067 | u16 saved_bank; |
2058 | unsigned int ioaddr = dev->base_addr; | 2068 | unsigned int ioaddr = dev->base_addr; |
2069 | unsigned long flags; | ||
2059 | 2070 | ||
2060 | if (!netif_running(dev)) | 2071 | if (!netif_running(dev)) |
2061 | return -EINVAL; | 2072 | return -EINVAL; |
2062 | 2073 | ||
2063 | spin_lock_irq(&smc->lock); | 2074 | spin_lock_irqsave(&smc->lock, flags); |
2064 | saved_bank = inw(ioaddr + BANK_SELECT); | 2075 | saved_bank = inw(ioaddr + BANK_SELECT); |
2065 | SMC_SELECT_BANK(3); | 2076 | SMC_SELECT_BANK(3); |
2066 | rc = generic_mii_ioctl(&smc->mii_if, mii, cmd, NULL); | 2077 | rc = generic_mii_ioctl(&smc->mii_if, mii, cmd, NULL); |
2067 | SMC_SELECT_BANK(saved_bank); | 2078 | SMC_SELECT_BANK(saved_bank); |
2068 | spin_unlock_irq(&smc->lock); | 2079 | spin_unlock_irqrestore(&smc->lock, flags); |
2069 | return rc; | 2080 | return rc; |
2070 | } | 2081 | } |
2071 | 2082 | ||
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c index ba4770a6c2e4..fec3c29b2ea8 100644 --- a/drivers/net/sb1250-mac.c +++ b/drivers/net/sb1250-mac.c | |||
@@ -2256,17 +2256,36 @@ static int sbmac_init(struct platform_device *pldev, long long base) | |||
2256 | 2256 | ||
2257 | sc->mii_bus = mdiobus_alloc(); | 2257 | sc->mii_bus = mdiobus_alloc(); |
2258 | if (sc->mii_bus == NULL) { | 2258 | if (sc->mii_bus == NULL) { |
2259 | sbmac_uninitctx(sc); | 2259 | err = -ENOMEM; |
2260 | return -ENOMEM; | 2260 | goto uninit_ctx; |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | sc->mii_bus->name = sbmac_mdio_string; | ||
2264 | snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx); | ||
2265 | sc->mii_bus->priv = sc; | ||
2266 | sc->mii_bus->read = sbmac_mii_read; | ||
2267 | sc->mii_bus->write = sbmac_mii_write; | ||
2268 | sc->mii_bus->irq = sc->phy_irq; | ||
2269 | for (i = 0; i < PHY_MAX_ADDR; ++i) | ||
2270 | sc->mii_bus->irq[i] = SBMAC_PHY_INT; | ||
2271 | |||
2272 | sc->mii_bus->parent = &pldev->dev; | ||
2273 | /* | ||
2274 | * Probe PHY address | ||
2275 | */ | ||
2276 | err = mdiobus_register(sc->mii_bus); | ||
2277 | if (err) { | ||
2278 | printk(KERN_ERR "%s: unable to register MDIO bus\n", | ||
2279 | dev->name); | ||
2280 | goto free_mdio; | ||
2281 | } | ||
2282 | dev_set_drvdata(&pldev->dev, sc->mii_bus); | ||
2283 | |||
2263 | err = register_netdev(dev); | 2284 | err = register_netdev(dev); |
2264 | if (err) { | 2285 | if (err) { |
2265 | printk(KERN_ERR "%s.%d: unable to register netdev\n", | 2286 | printk(KERN_ERR "%s.%d: unable to register netdev\n", |
2266 | sbmac_string, idx); | 2287 | sbmac_string, idx); |
2267 | mdiobus_free(sc->mii_bus); | 2288 | goto unreg_mdio; |
2268 | sbmac_uninitctx(sc); | ||
2269 | return err; | ||
2270 | } | 2289 | } |
2271 | 2290 | ||
2272 | pr_info("%s.%d: registered as %s\n", sbmac_string, idx, dev->name); | 2291 | pr_info("%s.%d: registered as %s\n", sbmac_string, idx, dev->name); |
@@ -2282,19 +2301,15 @@ static int sbmac_init(struct platform_device *pldev, long long base) | |||
2282 | pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %pM\n", | 2301 | pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %pM\n", |
2283 | dev->name, base, eaddr); | 2302 | dev->name, base, eaddr); |
2284 | 2303 | ||
2285 | sc->mii_bus->name = sbmac_mdio_string; | ||
2286 | snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx); | ||
2287 | sc->mii_bus->priv = sc; | ||
2288 | sc->mii_bus->read = sbmac_mii_read; | ||
2289 | sc->mii_bus->write = sbmac_mii_write; | ||
2290 | sc->mii_bus->irq = sc->phy_irq; | ||
2291 | for (i = 0; i < PHY_MAX_ADDR; ++i) | ||
2292 | sc->mii_bus->irq[i] = SBMAC_PHY_INT; | ||
2293 | |||
2294 | sc->mii_bus->parent = &pldev->dev; | ||
2295 | dev_set_drvdata(&pldev->dev, sc->mii_bus); | ||
2296 | |||
2297 | return 0; | 2304 | return 0; |
2305 | unreg_mdio: | ||
2306 | mdiobus_unregister(sc->mii_bus); | ||
2307 | dev_set_drvdata(&pldev->dev, NULL); | ||
2308 | free_mdio: | ||
2309 | mdiobus_free(sc->mii_bus); | ||
2310 | uninit_ctx: | ||
2311 | sbmac_uninitctx(sc); | ||
2312 | return err; | ||
2298 | } | 2313 | } |
2299 | 2314 | ||
2300 | 2315 | ||
@@ -2320,16 +2335,6 @@ static int sbmac_open(struct net_device *dev) | |||
2320 | goto out_err; | 2335 | goto out_err; |
2321 | } | 2336 | } |
2322 | 2337 | ||
2323 | /* | ||
2324 | * Probe PHY address | ||
2325 | */ | ||
2326 | err = mdiobus_register(sc->mii_bus); | ||
2327 | if (err) { | ||
2328 | printk(KERN_ERR "%s: unable to register MDIO bus\n", | ||
2329 | dev->name); | ||
2330 | goto out_unirq; | ||
2331 | } | ||
2332 | |||
2333 | sc->sbm_speed = sbmac_speed_none; | 2338 | sc->sbm_speed = sbmac_speed_none; |
2334 | sc->sbm_duplex = sbmac_duplex_none; | 2339 | sc->sbm_duplex = sbmac_duplex_none; |
2335 | sc->sbm_fc = sbmac_fc_none; | 2340 | sc->sbm_fc = sbmac_fc_none; |
@@ -2360,11 +2365,7 @@ static int sbmac_open(struct net_device *dev) | |||
2360 | return 0; | 2365 | return 0; |
2361 | 2366 | ||
2362 | out_unregister: | 2367 | out_unregister: |
2363 | mdiobus_unregister(sc->mii_bus); | ||
2364 | |||
2365 | out_unirq: | ||
2366 | free_irq(dev->irq, dev); | 2368 | free_irq(dev->irq, dev); |
2367 | |||
2368 | out_err: | 2369 | out_err: |
2369 | return err; | 2370 | return err; |
2370 | } | 2371 | } |
@@ -2553,9 +2554,6 @@ static int sbmac_close(struct net_device *dev) | |||
2553 | 2554 | ||
2554 | phy_disconnect(sc->phy_dev); | 2555 | phy_disconnect(sc->phy_dev); |
2555 | sc->phy_dev = NULL; | 2556 | sc->phy_dev = NULL; |
2556 | |||
2557 | mdiobus_unregister(sc->mii_bus); | ||
2558 | |||
2559 | free_irq(dev->irq, dev); | 2557 | free_irq(dev->irq, dev); |
2560 | 2558 | ||
2561 | sbdma_emptyring(&(sc->sbm_txdma)); | 2559 | sbdma_emptyring(&(sc->sbm_txdma)); |
@@ -2662,6 +2660,7 @@ static int __exit sbmac_remove(struct platform_device *pldev) | |||
2662 | 2660 | ||
2663 | unregister_netdev(dev); | 2661 | unregister_netdev(dev); |
2664 | sbmac_uninitctx(sc); | 2662 | sbmac_uninitctx(sc); |
2663 | mdiobus_unregister(sc->mii_bus); | ||
2665 | mdiobus_free(sc->mii_bus); | 2664 | mdiobus_free(sc->mii_bus); |
2666 | iounmap(sc->sbm_base); | 2665 | iounmap(sc->sbm_base); |
2667 | free_netdev(dev); | 2666 | free_netdev(dev); |
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index bc75ef683c9f..156460527231 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -1870,6 +1870,7 @@ out: | |||
1870 | } | 1870 | } |
1871 | 1871 | ||
1872 | if (disabled) { | 1872 | if (disabled) { |
1873 | dev_close(efx->net_dev); | ||
1873 | EFX_ERR(efx, "has been disabled\n"); | 1874 | EFX_ERR(efx, "has been disabled\n"); |
1874 | efx->state = STATE_DISABLED; | 1875 | efx->state = STATE_DISABLED; |
1875 | } else { | 1876 | } else { |
@@ -1893,8 +1894,7 @@ static void efx_reset_work(struct work_struct *data) | |||
1893 | } | 1894 | } |
1894 | 1895 | ||
1895 | rtnl_lock(); | 1896 | rtnl_lock(); |
1896 | if (efx_reset(efx, efx->reset_pending)) | 1897 | (void)efx_reset(efx, efx->reset_pending); |
1897 | dev_close(efx->net_dev); | ||
1898 | rtnl_unlock(); | 1898 | rtnl_unlock(); |
1899 | } | 1899 | } |
1900 | 1900 | ||
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index f7df24dce38a..655b697b45b2 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -1326,7 +1326,9 @@ static int falcon_probe_nvconfig(struct efx_nic *efx) | |||
1326 | 1326 | ||
1327 | EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad); | 1327 | EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad); |
1328 | 1328 | ||
1329 | falcon_probe_board(efx, board_rev); | 1329 | rc = falcon_probe_board(efx, board_rev); |
1330 | if (rc) | ||
1331 | goto fail2; | ||
1330 | 1332 | ||
1331 | kfree(nvconfig); | 1333 | kfree(nvconfig); |
1332 | return 0; | 1334 | return 0; |
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c index 5712fddd72f2..c7a933a3292e 100644 --- a/drivers/net/sfc/falcon_boards.c +++ b/drivers/net/sfc/falcon_boards.c | |||
@@ -728,15 +728,7 @@ static const struct falcon_board_type board_types[] = { | |||
728 | }, | 728 | }, |
729 | }; | 729 | }; |
730 | 730 | ||
731 | static const struct falcon_board_type falcon_dummy_board = { | 731 | int falcon_probe_board(struct efx_nic *efx, u16 revision_info) |
732 | .init = efx_port_dummy_op_int, | ||
733 | .init_phy = efx_port_dummy_op_void, | ||
734 | .fini = efx_port_dummy_op_void, | ||
735 | .set_id_led = efx_port_dummy_op_set_id_led, | ||
736 | .monitor = efx_port_dummy_op_int, | ||
737 | }; | ||
738 | |||
739 | void falcon_probe_board(struct efx_nic *efx, u16 revision_info) | ||
740 | { | 732 | { |
741 | struct falcon_board *board = falcon_board(efx); | 733 | struct falcon_board *board = falcon_board(efx); |
742 | u8 type_id = FALCON_BOARD_TYPE(revision_info); | 734 | u8 type_id = FALCON_BOARD_TYPE(revision_info); |
@@ -754,8 +746,9 @@ void falcon_probe_board(struct efx_nic *efx, u16 revision_info) | |||
754 | (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) | 746 | (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) |
755 | ? board->type->ref_model : board->type->gen_type, | 747 | ? board->type->ref_model : board->type->gen_type, |
756 | 'A' + board->major, board->minor); | 748 | 'A' + board->major, board->minor); |
749 | return 0; | ||
757 | } else { | 750 | } else { |
758 | EFX_ERR(efx, "unknown board type %d\n", type_id); | 751 | EFX_ERR(efx, "unknown board type %d\n", type_id); |
759 | board->type = &falcon_dummy_board; | 752 | return -ENODEV; |
760 | } | 753 | } |
761 | } | 754 | } |
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h index 5825f37b51bd..bbc2c0c2f843 100644 --- a/drivers/net/sfc/nic.h +++ b/drivers/net/sfc/nic.h | |||
@@ -158,7 +158,7 @@ extern struct efx_nic_type siena_a0_nic_type; | |||
158 | ************************************************************************** | 158 | ************************************************************************** |
159 | */ | 159 | */ |
160 | 160 | ||
161 | extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info); | 161 | extern int falcon_probe_board(struct efx_nic *efx, u16 revision_info); |
162 | 162 | ||
163 | /* TX data path */ | 163 | /* TX data path */ |
164 | extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue); | 164 | extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue); |
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c index 7bf93faff3ab..727b4228e081 100644 --- a/drivers/net/sfc/siena.c +++ b/drivers/net/sfc/siena.c | |||
@@ -475,8 +475,17 @@ static int siena_try_update_nic_stats(struct efx_nic *efx) | |||
475 | 475 | ||
476 | static void siena_update_nic_stats(struct efx_nic *efx) | 476 | static void siena_update_nic_stats(struct efx_nic *efx) |
477 | { | 477 | { |
478 | while (siena_try_update_nic_stats(efx) == -EAGAIN) | 478 | int retry; |
479 | cpu_relax(); | 479 | |
480 | /* If we're unlucky enough to read statistics wduring the DMA, wait | ||
481 | * up to 10ms for it to finish (typically takes <500us) */ | ||
482 | for (retry = 0; retry < 100; ++retry) { | ||
483 | if (siena_try_update_nic_stats(efx) == 0) | ||
484 | return; | ||
485 | udelay(100); | ||
486 | } | ||
487 | |||
488 | /* Use the old values instead */ | ||
480 | } | 489 | } |
481 | 490 | ||
482 | static void siena_start_nic_stats(struct efx_nic *efx) | 491 | static void siena_start_nic_stats(struct efx_nic *efx) |
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index 63be4caec70e..d7b7018a1de1 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig | |||
@@ -397,4 +397,13 @@ config USB_IPHETH | |||
397 | 397 | ||
398 | For more information: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver | 398 | For more information: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver |
399 | 399 | ||
400 | config USB_SIERRA_NET | ||
401 | tristate "USB-to-WWAN Driver for Sierra Wireless modems" | ||
402 | depends on USB_USBNET | ||
403 | help | ||
404 | Choose this option if you have a Sierra Wireless USB-to-WWAN device. | ||
405 | |||
406 | To compile this driver as a module, choose M here: the | ||
407 | module will be called sierra_net. | ||
408 | |||
400 | endmenu | 409 | endmenu |
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile index edb09c0ddf8e..b13a279663ba 100644 --- a/drivers/net/usb/Makefile +++ b/drivers/net/usb/Makefile | |||
@@ -24,4 +24,5 @@ obj-$(CONFIG_USB_USBNET) += usbnet.o | |||
24 | obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o | 24 | obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o |
25 | obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o | 25 | obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o |
26 | obj-$(CONFIG_USB_IPHETH) += ipheth.o | 26 | obj-$(CONFIG_USB_IPHETH) += ipheth.o |
27 | obj-$(CONFIG_USB_SIERRA_NET) += sierra_net.o | ||
27 | 28 | ||
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 811b2dc423d1..b3fe0de40469 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
@@ -466,6 +466,7 @@ static const struct driver_info mbm_info = { | |||
466 | .bind = cdc_bind, | 466 | .bind = cdc_bind, |
467 | .unbind = usbnet_cdc_unbind, | 467 | .unbind = usbnet_cdc_unbind, |
468 | .status = cdc_status, | 468 | .status = cdc_status, |
469 | .manage_power = cdc_manage_power, | ||
469 | }; | 470 | }; |
470 | 471 | ||
471 | /*-------------------------------------------------------------------------*/ | 472 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index fd1033130a81..418825d26f90 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c | |||
@@ -122,25 +122,25 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone) | |||
122 | 122 | ||
123 | tx_urb = usb_alloc_urb(0, GFP_KERNEL); | 123 | tx_urb = usb_alloc_urb(0, GFP_KERNEL); |
124 | if (tx_urb == NULL) | 124 | if (tx_urb == NULL) |
125 | goto error; | 125 | goto error_nomem; |
126 | 126 | ||
127 | rx_urb = usb_alloc_urb(0, GFP_KERNEL); | 127 | rx_urb = usb_alloc_urb(0, GFP_KERNEL); |
128 | if (rx_urb == NULL) | 128 | if (rx_urb == NULL) |
129 | goto error; | 129 | goto free_tx_urb; |
130 | 130 | ||
131 | tx_buf = usb_buffer_alloc(iphone->udev, | 131 | tx_buf = usb_buffer_alloc(iphone->udev, |
132 | IPHETH_BUF_SIZE, | 132 | IPHETH_BUF_SIZE, |
133 | GFP_KERNEL, | 133 | GFP_KERNEL, |
134 | &tx_urb->transfer_dma); | 134 | &tx_urb->transfer_dma); |
135 | if (tx_buf == NULL) | 135 | if (tx_buf == NULL) |
136 | goto error; | 136 | goto free_rx_urb; |
137 | 137 | ||
138 | rx_buf = usb_buffer_alloc(iphone->udev, | 138 | rx_buf = usb_buffer_alloc(iphone->udev, |
139 | IPHETH_BUF_SIZE, | 139 | IPHETH_BUF_SIZE, |
140 | GFP_KERNEL, | 140 | GFP_KERNEL, |
141 | &rx_urb->transfer_dma); | 141 | &rx_urb->transfer_dma); |
142 | if (rx_buf == NULL) | 142 | if (rx_buf == NULL) |
143 | goto error; | 143 | goto free_tx_buf; |
144 | 144 | ||
145 | 145 | ||
146 | iphone->tx_urb = tx_urb; | 146 | iphone->tx_urb = tx_urb; |
@@ -149,13 +149,14 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone) | |||
149 | iphone->rx_buf = rx_buf; | 149 | iphone->rx_buf = rx_buf; |
150 | return 0; | 150 | return 0; |
151 | 151 | ||
152 | error: | 152 | free_tx_buf: |
153 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, rx_buf, | ||
154 | rx_urb->transfer_dma); | ||
155 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf, | 153 | usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf, |
156 | tx_urb->transfer_dma); | 154 | tx_urb->transfer_dma); |
155 | free_rx_urb: | ||
157 | usb_free_urb(rx_urb); | 156 | usb_free_urb(rx_urb); |
157 | free_tx_urb: | ||
158 | usb_free_urb(tx_urb); | 158 | usb_free_urb(tx_urb); |
159 | error_nomem: | ||
159 | return -ENOMEM; | 160 | return -ENOMEM; |
160 | } | 161 | } |
161 | 162 | ||
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 52671ea043a7..c4c334d9770f 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c | |||
@@ -145,6 +145,7 @@ static struct usb_device_id usb_klsi_table[] = { | |||
145 | { USB_DEVICE(0x0707, 0x0100) }, /* SMC 2202USB */ | 145 | { USB_DEVICE(0x0707, 0x0100) }, /* SMC 2202USB */ |
146 | { USB_DEVICE(0x07aa, 0x0001) }, /* Correga K.K. */ | 146 | { USB_DEVICE(0x07aa, 0x0001) }, /* Correga K.K. */ |
147 | { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */ | 147 | { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */ |
148 | { USB_DEVICE(0x07c9, 0xb010) }, /* Allied Telesyn AT-USB10 USB Ethernet Adapter */ | ||
148 | { USB_DEVICE(0x0846, 0x1001) }, /* NetGear EA-101 */ | 149 | { USB_DEVICE(0x0846, 0x1001) }, /* NetGear EA-101 */ |
149 | { USB_DEVICE(0x0846, 0x1002) }, /* NetGear EA-101 */ | 150 | { USB_DEVICE(0x0846, 0x1002) }, /* NetGear EA-101 */ |
150 | { USB_DEVICE(0x085a, 0x0008) }, /* PortGear Ethernet Adapter */ | 151 | { USB_DEVICE(0x085a, 0x0008) }, /* PortGear Ethernet Adapter */ |
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c new file mode 100644 index 000000000000..f1942d69a0d5 --- /dev/null +++ b/drivers/net/usb/sierra_net.c | |||
@@ -0,0 +1,1004 @@ | |||
1 | /* | ||
2 | * USB-to-WWAN Driver for Sierra Wireless modems | ||
3 | * | ||
4 | * Copyright (C) 2008, 2009, 2010 Paxton Smith, Matthew Safar, Rory Filer | ||
5 | * <linux@sierrawireless.com> | ||
6 | * | ||
7 | * Portions of this based on the cdc_ether driver by David Brownell (2003-2005) | ||
8 | * and Ole Andre Vadla Ravnas (ActiveSync) (2006). | ||
9 | * | ||
10 | * IMPORTANT DISCLAIMER: This driver is not commercially supported by | ||
11 | * Sierra Wireless. Use at your own risk. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | * GNU General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, write to the Free Software | ||
25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
26 | */ | ||
27 | |||
28 | #define DRIVER_VERSION "v.2.0" | ||
29 | #define DRIVER_AUTHOR "Paxton Smith, Matthew Safar, Rory Filer" | ||
30 | #define DRIVER_DESC "USB-to-WWAN Driver for Sierra Wireless modems" | ||
31 | static const char driver_name[] = "sierra_net"; | ||
32 | |||
33 | /* if defined debug messages enabled */ | ||
34 | /*#define DEBUG*/ | ||
35 | |||
36 | #include <linux/module.h> | ||
37 | #include <linux/etherdevice.h> | ||
38 | #include <linux/ethtool.h> | ||
39 | #include <linux/mii.h> | ||
40 | #include <linux/sched.h> | ||
41 | #include <linux/timer.h> | ||
42 | #include <linux/usb.h> | ||
43 | #include <linux/usb/cdc.h> | ||
44 | #include <net/ip.h> | ||
45 | #include <net/udp.h> | ||
46 | #include <asm/unaligned.h> | ||
47 | #include <linux/usb/usbnet.h> | ||
48 | |||
49 | #define SWI_USB_REQUEST_GET_FW_ATTR 0x06 | ||
50 | #define SWI_GET_FW_ATTR_MASK 0x08 | ||
51 | |||
52 | /* atomic counter partially included in MAC address to make sure 2 devices | ||
53 | * do not end up with the same MAC - concept breaks in case of > 255 ifaces | ||
54 | */ | ||
55 | static atomic_t iface_counter = ATOMIC_INIT(0); | ||
56 | |||
57 | /* | ||
58 | * SYNC Timer Delay definition used to set the expiry time | ||
59 | */ | ||
60 | #define SIERRA_NET_SYNCDELAY (2*HZ) | ||
61 | |||
62 | /* Max. MTU supported. The modem buffers are limited to 1500 */ | ||
63 | #define SIERRA_NET_MAX_SUPPORTED_MTU 1500 | ||
64 | |||
65 | /* The SIERRA_NET_USBCTL_BUF_LEN defines a buffer size allocated for control | ||
66 | * message reception ... and thus the max. received packet. | ||
67 | * (May be the cause for parse_hip returning -EINVAL) | ||
68 | */ | ||
69 | #define SIERRA_NET_USBCTL_BUF_LEN 1024 | ||
70 | |||
71 | /* list of interface numbers - used for constructing interface lists */ | ||
72 | struct sierra_net_iface_info { | ||
73 | const u32 infolen; /* number of interface numbers on list */ | ||
74 | const u8 *ifaceinfo; /* pointer to the array holding the numbers */ | ||
75 | }; | ||
76 | |||
77 | struct sierra_net_info_data { | ||
78 | u16 rx_urb_size; | ||
79 | struct sierra_net_iface_info whitelist; | ||
80 | }; | ||
81 | |||
82 | /* Private data structure */ | ||
83 | struct sierra_net_data { | ||
84 | |||
85 | u8 ethr_hdr_tmpl[ETH_HLEN]; /* ethernet header template for rx'd pkts */ | ||
86 | |||
87 | u16 link_up; /* air link up or down */ | ||
88 | u8 tx_hdr_template[4]; /* part of HIP hdr for tx'd packets */ | ||
89 | |||
90 | u8 sync_msg[4]; /* SYNC message */ | ||
91 | u8 shdwn_msg[4]; /* Shutdown message */ | ||
92 | |||
93 | /* Backpointer to the container */ | ||
94 | struct usbnet *usbnet; | ||
95 | |||
96 | u8 ifnum; /* interface number */ | ||
97 | |||
98 | /* Bit masks, must be a power of 2 */ | ||
99 | #define SIERRA_NET_EVENT_RESP_AVAIL 0x01 | ||
100 | #define SIERRA_NET_TIMER_EXPIRY 0x02 | ||
101 | unsigned long kevent_flags; | ||
102 | struct work_struct sierra_net_kevent; | ||
103 | struct timer_list sync_timer; /* For retrying SYNC sequence */ | ||
104 | }; | ||
105 | |||
106 | struct param { | ||
107 | int is_present; | ||
108 | union { | ||
109 | void *ptr; | ||
110 | u32 dword; | ||
111 | u16 word; | ||
112 | u8 byte; | ||
113 | }; | ||
114 | }; | ||
115 | |||
116 | /* HIP message type */ | ||
117 | #define SIERRA_NET_HIP_EXTENDEDID 0x7F | ||
118 | #define SIERRA_NET_HIP_HSYNC_ID 0x60 /* Modem -> host */ | ||
119 | #define SIERRA_NET_HIP_RESTART_ID 0x62 /* Modem -> host */ | ||
120 | #define SIERRA_NET_HIP_MSYNC_ID 0x20 /* Host -> modem */ | ||
121 | #define SIERRA_NET_HIP_SHUTD_ID 0x26 /* Host -> modem */ | ||
122 | |||
123 | #define SIERRA_NET_HIP_EXT_IP_IN_ID 0x0202 | ||
124 | #define SIERRA_NET_HIP_EXT_IP_OUT_ID 0x0002 | ||
125 | |||
126 | /* 3G UMTS Link Sense Indication definitions */ | ||
127 | #define SIERRA_NET_HIP_LSI_UMTSID 0x78 | ||
128 | |||
129 | /* Reverse Channel Grant Indication HIP message */ | ||
130 | #define SIERRA_NET_HIP_RCGI 0x64 | ||
131 | |||
132 | /* LSI Protocol types */ | ||
133 | #define SIERRA_NET_PROTOCOL_UMTS 0x01 | ||
134 | /* LSI Coverage */ | ||
135 | #define SIERRA_NET_COVERAGE_NONE 0x00 | ||
136 | #define SIERRA_NET_COVERAGE_NOPACKET 0x01 | ||
137 | |||
138 | /* LSI Session */ | ||
139 | #define SIERRA_NET_SESSION_IDLE 0x00 | ||
140 | /* LSI Link types */ | ||
141 | #define SIERRA_NET_AS_LINK_TYPE_IPv4 0x00 | ||
142 | |||
143 | struct lsi_umts { | ||
144 | u8 protocol; | ||
145 | u8 unused1; | ||
146 | __be16 length; | ||
147 | /* eventually use a union for the rest - assume umts for now */ | ||
148 | u8 coverage; | ||
149 | u8 unused2[41]; | ||
150 | u8 session_state; | ||
151 | u8 unused3[33]; | ||
152 | u8 link_type; | ||
153 | u8 pdp_addr_len; /* NW-supplied PDP address len */ | ||
154 | u8 pdp_addr[16]; /* NW-supplied PDP address (bigendian)) */ | ||
155 | u8 unused4[23]; | ||
156 | u8 dns1_addr_len; /* NW-supplied 1st DNS address len (bigendian) */ | ||
157 | u8 dns1_addr[16]; /* NW-supplied 1st DNS address */ | ||
158 | u8 dns2_addr_len; /* NW-supplied 2nd DNS address len */ | ||
159 | u8 dns2_addr[16]; /* NW-supplied 2nd DNS address (bigendian)*/ | ||
160 | u8 wins1_addr_len; /* NW-supplied 1st Wins address len */ | ||
161 | u8 wins1_addr[16]; /* NW-supplied 1st Wins address (bigendian)*/ | ||
162 | u8 wins2_addr_len; /* NW-supplied 2nd Wins address len */ | ||
163 | u8 wins2_addr[16]; /* NW-supplied 2nd Wins address (bigendian) */ | ||
164 | u8 unused5[4]; | ||
165 | u8 gw_addr_len; /* NW-supplied GW address len */ | ||
166 | u8 gw_addr[16]; /* NW-supplied GW address (bigendian) */ | ||
167 | u8 reserved[8]; | ||
168 | } __attribute__ ((packed)); | ||
169 | |||
170 | #define SIERRA_NET_LSI_COMMON_LEN 4 | ||
171 | #define SIERRA_NET_LSI_UMTS_LEN (sizeof(struct lsi_umts)) | ||
172 | #define SIERRA_NET_LSI_UMTS_STATUS_LEN \ | ||
173 | (SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN) | ||
174 | |||
175 | /* Forward definitions */ | ||
176 | static void sierra_sync_timer(unsigned long syncdata); | ||
177 | static int sierra_net_change_mtu(struct net_device *net, int new_mtu); | ||
178 | |||
179 | /* Our own net device operations structure */ | ||
180 | static const struct net_device_ops sierra_net_device_ops = { | ||
181 | .ndo_open = usbnet_open, | ||
182 | .ndo_stop = usbnet_stop, | ||
183 | .ndo_start_xmit = usbnet_start_xmit, | ||
184 | .ndo_tx_timeout = usbnet_tx_timeout, | ||
185 | .ndo_change_mtu = sierra_net_change_mtu, | ||
186 | .ndo_set_mac_address = eth_mac_addr, | ||
187 | .ndo_validate_addr = eth_validate_addr, | ||
188 | }; | ||
189 | |||
190 | /* get private data associated with passed in usbnet device */ | ||
191 | static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev) | ||
192 | { | ||
193 | return (struct sierra_net_data *)dev->data[0]; | ||
194 | } | ||
195 | |||
196 | /* set private data associated with passed in usbnet device */ | ||
197 | static inline void sierra_net_set_private(struct usbnet *dev, | ||
198 | struct sierra_net_data *priv) | ||
199 | { | ||
200 | dev->data[0] = (unsigned long)priv; | ||
201 | } | ||
202 | |||
203 | /* is packet IPv4 */ | ||
204 | static inline int is_ip(struct sk_buff *skb) | ||
205 | { | ||
206 | return (skb->protocol == cpu_to_be16(ETH_P_IP)); | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * check passed in packet and make sure that: | ||
211 | * - it is linear (no scatter/gather) | ||
212 | * - it is ethernet (mac_header properly set) | ||
213 | */ | ||
214 | static int check_ethip_packet(struct sk_buff *skb, struct usbnet *dev) | ||
215 | { | ||
216 | skb_reset_mac_header(skb); /* ethernet header */ | ||
217 | |||
218 | if (skb_is_nonlinear(skb)) { | ||
219 | netdev_err(dev->net, "Non linear buffer-dropping\n"); | ||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | if (!pskb_may_pull(skb, ETH_HLEN)) | ||
224 | return 0; | ||
225 | skb->protocol = eth_hdr(skb)->h_proto; | ||
226 | |||
227 | return 1; | ||
228 | } | ||
229 | |||
230 | static const u8 *save16bit(struct param *p, const u8 *datap) | ||
231 | { | ||
232 | p->is_present = 1; | ||
233 | p->word = get_unaligned_be16(datap); | ||
234 | return datap + sizeof(p->word); | ||
235 | } | ||
236 | |||
237 | static const u8 *save8bit(struct param *p, const u8 *datap) | ||
238 | { | ||
239 | p->is_present = 1; | ||
240 | p->byte = *datap; | ||
241 | return datap + sizeof(p->byte); | ||
242 | } | ||
243 | |||
244 | /*----------------------------------------------------------------------------* | ||
245 | * BEGIN HIP * | ||
246 | *----------------------------------------------------------------------------*/ | ||
247 | /* HIP header */ | ||
248 | #define SIERRA_NET_HIP_HDR_LEN 4 | ||
249 | /* Extended HIP header */ | ||
250 | #define SIERRA_NET_HIP_EXT_HDR_LEN 6 | ||
251 | |||
252 | struct hip_hdr { | ||
253 | int hdrlen; | ||
254 | struct param payload_len; | ||
255 | struct param msgid; | ||
256 | struct param msgspecific; | ||
257 | struct param extmsgid; | ||
258 | }; | ||
259 | |||
260 | static int parse_hip(const u8 *buf, const u32 buflen, struct hip_hdr *hh) | ||
261 | { | ||
262 | const u8 *curp = buf; | ||
263 | int padded; | ||
264 | |||
265 | if (buflen < SIERRA_NET_HIP_HDR_LEN) | ||
266 | return -EPROTO; | ||
267 | |||
268 | curp = save16bit(&hh->payload_len, curp); | ||
269 | curp = save8bit(&hh->msgid, curp); | ||
270 | curp = save8bit(&hh->msgspecific, curp); | ||
271 | |||
272 | padded = hh->msgid.byte & 0x80; | ||
273 | hh->msgid.byte &= 0x7F; /* 7 bits */ | ||
274 | |||
275 | hh->extmsgid.is_present = (hh->msgid.byte == SIERRA_NET_HIP_EXTENDEDID); | ||
276 | if (hh->extmsgid.is_present) { | ||
277 | if (buflen < SIERRA_NET_HIP_EXT_HDR_LEN) | ||
278 | return -EPROTO; | ||
279 | |||
280 | hh->payload_len.word &= 0x3FFF; /* 14 bits */ | ||
281 | |||
282 | curp = save16bit(&hh->extmsgid, curp); | ||
283 | hh->extmsgid.word &= 0x03FF; /* 10 bits */ | ||
284 | |||
285 | hh->hdrlen = SIERRA_NET_HIP_EXT_HDR_LEN; | ||
286 | } else { | ||
287 | hh->payload_len.word &= 0x07FF; /* 11 bits */ | ||
288 | hh->hdrlen = SIERRA_NET_HIP_HDR_LEN; | ||
289 | } | ||
290 | |||
291 | if (padded) { | ||
292 | hh->hdrlen++; | ||
293 | hh->payload_len.word--; | ||
294 | } | ||
295 | |||
296 | /* if real packet shorter than the claimed length */ | ||
297 | if (buflen < (hh->hdrlen + hh->payload_len.word)) | ||
298 | return -EINVAL; | ||
299 | |||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | static void build_hip(u8 *buf, const u16 payloadlen, | ||
304 | struct sierra_net_data *priv) | ||
305 | { | ||
306 | /* the following doesn't have the full functionality. We | ||
307 | * currently build only one kind of header, so it is faster this way | ||
308 | */ | ||
309 | put_unaligned_be16(payloadlen, buf); | ||
310 | memcpy(buf+2, priv->tx_hdr_template, sizeof(priv->tx_hdr_template)); | ||
311 | } | ||
312 | /*----------------------------------------------------------------------------* | ||
313 | * END HIP * | ||
314 | *----------------------------------------------------------------------------*/ | ||
315 | |||
316 | static int sierra_net_send_cmd(struct usbnet *dev, | ||
317 | u8 *cmd, int cmdlen, const char * cmd_name) | ||
318 | { | ||
319 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
320 | int status; | ||
321 | |||
322 | status = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), | ||
323 | USB_CDC_SEND_ENCAPSULATED_COMMAND, | ||
324 | USB_DIR_OUT|USB_TYPE_CLASS|USB_RECIP_INTERFACE, 0, | ||
325 | priv->ifnum, cmd, cmdlen, USB_CTRL_SET_TIMEOUT); | ||
326 | |||
327 | if (status != cmdlen && status != -ENODEV) | ||
328 | netdev_err(dev->net, "Submit %s failed %d\n", cmd_name, status); | ||
329 | |||
330 | return status; | ||
331 | } | ||
332 | |||
333 | static int sierra_net_send_sync(struct usbnet *dev) | ||
334 | { | ||
335 | int status; | ||
336 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
337 | |||
338 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
339 | |||
340 | status = sierra_net_send_cmd(dev, priv->sync_msg, | ||
341 | sizeof(priv->sync_msg), "SYNC"); | ||
342 | |||
343 | return status; | ||
344 | } | ||
345 | |||
346 | static void sierra_net_set_ctx_index(struct sierra_net_data *priv, u8 ctx_ix) | ||
347 | { | ||
348 | dev_dbg(&(priv->usbnet->udev->dev), "%s %d", __func__, ctx_ix); | ||
349 | priv->tx_hdr_template[0] = 0x3F; | ||
350 | priv->tx_hdr_template[1] = ctx_ix; | ||
351 | *((u16 *)&priv->tx_hdr_template[2]) = | ||
352 | cpu_to_be16(SIERRA_NET_HIP_EXT_IP_OUT_ID); | ||
353 | } | ||
354 | |||
355 | static inline int sierra_net_is_valid_addrlen(u8 len) | ||
356 | { | ||
357 | return (len == sizeof(struct in_addr)); | ||
358 | } | ||
359 | |||
360 | static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen) | ||
361 | { | ||
362 | struct lsi_umts *lsi = (struct lsi_umts *)data; | ||
363 | |||
364 | if (datalen < sizeof(struct lsi_umts)) { | ||
365 | netdev_err(dev->net, "%s: Data length %d, exp %Zu\n", | ||
366 | __func__, datalen, | ||
367 | sizeof(struct lsi_umts)); | ||
368 | return -1; | ||
369 | } | ||
370 | |||
371 | if (lsi->length != cpu_to_be16(SIERRA_NET_LSI_UMTS_STATUS_LEN)) { | ||
372 | netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n", | ||
373 | __func__, be16_to_cpu(lsi->length), | ||
374 | (u32)SIERRA_NET_LSI_UMTS_STATUS_LEN); | ||
375 | return -1; | ||
376 | } | ||
377 | |||
378 | /* Validate the protocol - only support UMTS for now */ | ||
379 | if (lsi->protocol != SIERRA_NET_PROTOCOL_UMTS) { | ||
380 | netdev_err(dev->net, "Protocol unsupported, 0x%02x\n", | ||
381 | lsi->protocol); | ||
382 | return -1; | ||
383 | } | ||
384 | |||
385 | /* Validate the link type */ | ||
386 | if (lsi->link_type != SIERRA_NET_AS_LINK_TYPE_IPv4) { | ||
387 | netdev_err(dev->net, "Link type unsupported: 0x%02x\n", | ||
388 | lsi->link_type); | ||
389 | return -1; | ||
390 | } | ||
391 | |||
392 | /* Validate the coverage */ | ||
393 | if (lsi->coverage == SIERRA_NET_COVERAGE_NONE | ||
394 | || lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) { | ||
395 | netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage); | ||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | /* Validate the session state */ | ||
400 | if (lsi->session_state == SIERRA_NET_SESSION_IDLE) { | ||
401 | netdev_err(dev->net, "Session idle, 0x%02x\n", | ||
402 | lsi->session_state); | ||
403 | return 0; | ||
404 | } | ||
405 | |||
406 | /* Set link_sense true */ | ||
407 | return 1; | ||
408 | } | ||
409 | |||
410 | static void sierra_net_handle_lsi(struct usbnet *dev, char *data, | ||
411 | struct hip_hdr *hh) | ||
412 | { | ||
413 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
414 | int link_up; | ||
415 | |||
416 | link_up = sierra_net_parse_lsi(dev, data + hh->hdrlen, | ||
417 | hh->payload_len.word); | ||
418 | if (link_up < 0) { | ||
419 | netdev_err(dev->net, "Invalid LSI\n"); | ||
420 | return; | ||
421 | } | ||
422 | if (link_up) { | ||
423 | sierra_net_set_ctx_index(priv, hh->msgspecific.byte); | ||
424 | priv->link_up = 1; | ||
425 | netif_carrier_on(dev->net); | ||
426 | } else { | ||
427 | priv->link_up = 0; | ||
428 | netif_carrier_off(dev->net); | ||
429 | } | ||
430 | } | ||
431 | |||
432 | static void sierra_net_dosync(struct usbnet *dev) | ||
433 | { | ||
434 | int status; | ||
435 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
436 | |||
437 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
438 | |||
439 | /* tell modem we are ready */ | ||
440 | status = sierra_net_send_sync(dev); | ||
441 | if (status < 0) | ||
442 | netdev_err(dev->net, | ||
443 | "Send SYNC failed, status %d\n", status); | ||
444 | status = sierra_net_send_sync(dev); | ||
445 | if (status < 0) | ||
446 | netdev_err(dev->net, | ||
447 | "Send SYNC failed, status %d\n", status); | ||
448 | |||
449 | /* Now, start a timer and make sure we get the Restart Indication */ | ||
450 | priv->sync_timer.function = sierra_sync_timer; | ||
451 | priv->sync_timer.data = (unsigned long) dev; | ||
452 | priv->sync_timer.expires = jiffies + SIERRA_NET_SYNCDELAY; | ||
453 | add_timer(&priv->sync_timer); | ||
454 | } | ||
455 | |||
456 | static void sierra_net_kevent(struct work_struct *work) | ||
457 | { | ||
458 | struct sierra_net_data *priv = | ||
459 | container_of(work, struct sierra_net_data, sierra_net_kevent); | ||
460 | struct usbnet *dev = priv->usbnet; | ||
461 | int len; | ||
462 | int err; | ||
463 | u8 *buf; | ||
464 | u8 ifnum; | ||
465 | |||
466 | if (test_bit(SIERRA_NET_EVENT_RESP_AVAIL, &priv->kevent_flags)) { | ||
467 | clear_bit(SIERRA_NET_EVENT_RESP_AVAIL, &priv->kevent_flags); | ||
468 | |||
469 | /* Query the modem for the LSI message */ | ||
470 | buf = kzalloc(SIERRA_NET_USBCTL_BUF_LEN, GFP_KERNEL); | ||
471 | if (!buf) { | ||
472 | netdev_err(dev->net, | ||
473 | "failed to allocate buf for LS msg\n"); | ||
474 | return; | ||
475 | } | ||
476 | ifnum = priv->ifnum; | ||
477 | len = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), | ||
478 | USB_CDC_GET_ENCAPSULATED_RESPONSE, | ||
479 | USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE, | ||
480 | 0, ifnum, buf, SIERRA_NET_USBCTL_BUF_LEN, | ||
481 | USB_CTRL_SET_TIMEOUT); | ||
482 | |||
483 | if (len < 0) { | ||
484 | netdev_err(dev->net, | ||
485 | "usb_control_msg failed, status %d\n", len); | ||
486 | } else { | ||
487 | struct hip_hdr hh; | ||
488 | |||
489 | dev_dbg(&dev->udev->dev, "%s: Received status message," | ||
490 | " %04x bytes", __func__, len); | ||
491 | |||
492 | err = parse_hip(buf, len, &hh); | ||
493 | if (err) { | ||
494 | netdev_err(dev->net, "%s: Bad packet," | ||
495 | " parse result %d\n", __func__, err); | ||
496 | kfree(buf); | ||
497 | return; | ||
498 | } | ||
499 | |||
500 | /* Validate packet length */ | ||
501 | if (len != hh.hdrlen + hh.payload_len.word) { | ||
502 | netdev_err(dev->net, "%s: Bad packet, received" | ||
503 | " %d, expected %d\n", __func__, len, | ||
504 | hh.hdrlen + hh.payload_len.word); | ||
505 | kfree(buf); | ||
506 | return; | ||
507 | } | ||
508 | |||
509 | /* Switch on received message types */ | ||
510 | switch (hh.msgid.byte) { | ||
511 | case SIERRA_NET_HIP_LSI_UMTSID: | ||
512 | dev_dbg(&dev->udev->dev, "LSI for ctx:%d", | ||
513 | hh.msgspecific.byte); | ||
514 | sierra_net_handle_lsi(dev, buf, &hh); | ||
515 | break; | ||
516 | case SIERRA_NET_HIP_RESTART_ID: | ||
517 | dev_dbg(&dev->udev->dev, "Restart reported: %d," | ||
518 | " stopping sync timer", | ||
519 | hh.msgspecific.byte); | ||
520 | /* Got sync resp - stop timer & clear mask */ | ||
521 | del_timer_sync(&priv->sync_timer); | ||
522 | clear_bit(SIERRA_NET_TIMER_EXPIRY, | ||
523 | &priv->kevent_flags); | ||
524 | break; | ||
525 | case SIERRA_NET_HIP_HSYNC_ID: | ||
526 | dev_dbg(&dev->udev->dev, "SYNC received"); | ||
527 | err = sierra_net_send_sync(dev); | ||
528 | if (err < 0) | ||
529 | netdev_err(dev->net, | ||
530 | "Send SYNC failed %d\n", err); | ||
531 | break; | ||
532 | case SIERRA_NET_HIP_EXTENDEDID: | ||
533 | netdev_err(dev->net, "Unrecognized HIP msg, " | ||
534 | "extmsgid 0x%04x\n", hh.extmsgid.word); | ||
535 | break; | ||
536 | case SIERRA_NET_HIP_RCGI: | ||
537 | /* Ignored */ | ||
538 | break; | ||
539 | default: | ||
540 | netdev_err(dev->net, "Unrecognized HIP msg, " | ||
541 | "msgid 0x%02x\n", hh.msgid.byte); | ||
542 | break; | ||
543 | } | ||
544 | } | ||
545 | kfree(buf); | ||
546 | } | ||
547 | /* The sync timer bit might be set */ | ||
548 | if (test_bit(SIERRA_NET_TIMER_EXPIRY, &priv->kevent_flags)) { | ||
549 | clear_bit(SIERRA_NET_TIMER_EXPIRY, &priv->kevent_flags); | ||
550 | dev_dbg(&dev->udev->dev, "Deferred sync timer expiry"); | ||
551 | sierra_net_dosync(priv->usbnet); | ||
552 | } | ||
553 | |||
554 | if (priv->kevent_flags) | ||
555 | dev_dbg(&dev->udev->dev, "sierra_net_kevent done, " | ||
556 | "kevent_flags = 0x%lx", priv->kevent_flags); | ||
557 | } | ||
558 | |||
559 | static void sierra_net_defer_kevent(struct usbnet *dev, int work) | ||
560 | { | ||
561 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
562 | |||
563 | set_bit(work, &priv->kevent_flags); | ||
564 | schedule_work(&priv->sierra_net_kevent); | ||
565 | } | ||
566 | |||
567 | /* | ||
568 | * Sync Retransmit Timer Handler. On expiry, kick the work queue | ||
569 | */ | ||
570 | void sierra_sync_timer(unsigned long syncdata) | ||
571 | { | ||
572 | struct usbnet *dev = (struct usbnet *)syncdata; | ||
573 | |||
574 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
575 | /* Kick the tasklet */ | ||
576 | sierra_net_defer_kevent(dev, SIERRA_NET_TIMER_EXPIRY); | ||
577 | } | ||
578 | |||
579 | static void sierra_net_status(struct usbnet *dev, struct urb *urb) | ||
580 | { | ||
581 | struct usb_cdc_notification *event; | ||
582 | |||
583 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
584 | |||
585 | if (urb->actual_length < sizeof *event) | ||
586 | return; | ||
587 | |||
588 | /* Add cases to handle other standard notifications. */ | ||
589 | event = urb->transfer_buffer; | ||
590 | switch (event->bNotificationType) { | ||
591 | case USB_CDC_NOTIFY_NETWORK_CONNECTION: | ||
592 | case USB_CDC_NOTIFY_SPEED_CHANGE: | ||
593 | /* USB 305 sends those */ | ||
594 | break; | ||
595 | case USB_CDC_NOTIFY_RESPONSE_AVAILABLE: | ||
596 | sierra_net_defer_kevent(dev, SIERRA_NET_EVENT_RESP_AVAIL); | ||
597 | break; | ||
598 | default: | ||
599 | netdev_err(dev->net, ": unexpected notification %02x!\n", | ||
600 | event->bNotificationType); | ||
601 | break; | ||
602 | } | ||
603 | } | ||
604 | |||
605 | static void sierra_net_get_drvinfo(struct net_device *net, | ||
606 | struct ethtool_drvinfo *info) | ||
607 | { | ||
608 | /* Inherit standard device info */ | ||
609 | usbnet_get_drvinfo(net, info); | ||
610 | strncpy(info->driver, driver_name, sizeof info->driver); | ||
611 | strncpy(info->version, DRIVER_VERSION, sizeof info->version); | ||
612 | } | ||
613 | |||
614 | static u32 sierra_net_get_link(struct net_device *net) | ||
615 | { | ||
616 | struct usbnet *dev = netdev_priv(net); | ||
617 | /* Report link is down whenever the interface is down */ | ||
618 | return sierra_net_get_private(dev)->link_up && netif_running(net); | ||
619 | } | ||
620 | |||
621 | static struct ethtool_ops sierra_net_ethtool_ops = { | ||
622 | .get_drvinfo = sierra_net_get_drvinfo, | ||
623 | .get_link = sierra_net_get_link, | ||
624 | .get_msglevel = usbnet_get_msglevel, | ||
625 | .set_msglevel = usbnet_set_msglevel, | ||
626 | .get_settings = usbnet_get_settings, | ||
627 | .set_settings = usbnet_set_settings, | ||
628 | .nway_reset = usbnet_nway_reset, | ||
629 | }; | ||
630 | |||
631 | /* MTU can not be more than 1500 bytes, enforce it. */ | ||
632 | static int sierra_net_change_mtu(struct net_device *net, int new_mtu) | ||
633 | { | ||
634 | if (new_mtu > SIERRA_NET_MAX_SUPPORTED_MTU) | ||
635 | return -EINVAL; | ||
636 | |||
637 | return usbnet_change_mtu(net, new_mtu); | ||
638 | } | ||
639 | |||
640 | static int is_whitelisted(const u8 ifnum, | ||
641 | const struct sierra_net_iface_info *whitelist) | ||
642 | { | ||
643 | if (whitelist) { | ||
644 | const u8 *list = whitelist->ifaceinfo; | ||
645 | int i; | ||
646 | |||
647 | for (i = 0; i < whitelist->infolen; i++) { | ||
648 | if (list[i] == ifnum) | ||
649 | return 1; | ||
650 | } | ||
651 | } | ||
652 | return 0; | ||
653 | } | ||
654 | |||
655 | static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap) | ||
656 | { | ||
657 | int result = 0; | ||
658 | u16 *attrdata; | ||
659 | |||
660 | attrdata = kmalloc(sizeof(*attrdata), GFP_KERNEL); | ||
661 | if (!attrdata) | ||
662 | return -ENOMEM; | ||
663 | |||
664 | result = usb_control_msg( | ||
665 | dev->udev, | ||
666 | usb_rcvctrlpipe(dev->udev, 0), | ||
667 | /* _u8 vendor specific request */ | ||
668 | SWI_USB_REQUEST_GET_FW_ATTR, | ||
669 | USB_DIR_IN | USB_TYPE_VENDOR, /* __u8 request type */ | ||
670 | 0x0000, /* __u16 value not used */ | ||
671 | 0x0000, /* __u16 index not used */ | ||
672 | attrdata, /* char *data */ | ||
673 | sizeof(*attrdata), /* __u16 size */ | ||
674 | USB_CTRL_SET_TIMEOUT); /* int timeout */ | ||
675 | |||
676 | if (result < 0) { | ||
677 | kfree(attrdata); | ||
678 | return -EIO; | ||
679 | } | ||
680 | |||
681 | *datap = *attrdata; | ||
682 | |||
683 | kfree(attrdata); | ||
684 | return result; | ||
685 | } | ||
686 | |||
687 | /* | ||
688 | * collects the bulk endpoints, the status endpoint. | ||
689 | */ | ||
690 | static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf) | ||
691 | { | ||
692 | u8 ifacenum; | ||
693 | u8 numendpoints; | ||
694 | u16 fwattr = 0; | ||
695 | int status; | ||
696 | struct ethhdr *eth; | ||
697 | struct sierra_net_data *priv; | ||
698 | static const u8 sync_tmplate[sizeof(priv->sync_msg)] = { | ||
699 | 0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00}; | ||
700 | static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = { | ||
701 | 0x00, 0x00, SIERRA_NET_HIP_SHUTD_ID, 0x00}; | ||
702 | |||
703 | struct sierra_net_info_data *data = | ||
704 | (struct sierra_net_info_data *)dev->driver_info->data; | ||
705 | |||
706 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
707 | |||
708 | ifacenum = intf->cur_altsetting->desc.bInterfaceNumber; | ||
709 | /* We only accept certain interfaces */ | ||
710 | if (!is_whitelisted(ifacenum, &data->whitelist)) { | ||
711 | dev_dbg(&dev->udev->dev, "Ignoring interface: %d", ifacenum); | ||
712 | return -ENODEV; | ||
713 | } | ||
714 | numendpoints = intf->cur_altsetting->desc.bNumEndpoints; | ||
715 | /* We have three endpoints, bulk in and out, and a status */ | ||
716 | if (numendpoints != 3) { | ||
717 | dev_err(&dev->udev->dev, "Expected 3 endpoints, found: %d", | ||
718 | numendpoints); | ||
719 | return -ENODEV; | ||
720 | } | ||
721 | /* Status endpoint set in usbnet_get_endpoints() */ | ||
722 | dev->status = NULL; | ||
723 | status = usbnet_get_endpoints(dev, intf); | ||
724 | if (status < 0) { | ||
725 | dev_err(&dev->udev->dev, "Error in usbnet_get_endpoints (%d)", | ||
726 | status); | ||
727 | return -ENODEV; | ||
728 | } | ||
729 | /* Initialize sierra private data */ | ||
730 | priv = kzalloc(sizeof *priv, GFP_KERNEL); | ||
731 | if (!priv) { | ||
732 | dev_err(&dev->udev->dev, "No memory"); | ||
733 | return -ENOMEM; | ||
734 | } | ||
735 | |||
736 | priv->usbnet = dev; | ||
737 | priv->ifnum = ifacenum; | ||
738 | dev->net->netdev_ops = &sierra_net_device_ops; | ||
739 | |||
740 | /* change MAC addr to include, ifacenum, and to be unique */ | ||
741 | dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter); | ||
742 | dev->net->dev_addr[ETH_ALEN-1] = ifacenum; | ||
743 | |||
744 | /* we will have to manufacture ethernet headers, prepare template */ | ||
745 | eth = (struct ethhdr *)priv->ethr_hdr_tmpl; | ||
746 | memcpy(ð->h_dest, dev->net->dev_addr, ETH_ALEN); | ||
747 | eth->h_proto = cpu_to_be16(ETH_P_IP); | ||
748 | |||
749 | /* prepare shutdown message template */ | ||
750 | memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg)); | ||
751 | /* set context index initially to 0 - prepares tx hdr template */ | ||
752 | sierra_net_set_ctx_index(priv, 0); | ||
753 | |||
754 | /* decrease the rx_urb_size and max_tx_size to 4k on USB 1.1 */ | ||
755 | dev->rx_urb_size = data->rx_urb_size; | ||
756 | if (dev->udev->speed != USB_SPEED_HIGH) | ||
757 | dev->rx_urb_size = min_t(size_t, 4096, data->rx_urb_size); | ||
758 | |||
759 | dev->net->hard_header_len += SIERRA_NET_HIP_EXT_HDR_LEN; | ||
760 | dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; | ||
761 | |||
762 | /* Set up the netdev */ | ||
763 | dev->net->flags |= IFF_NOARP; | ||
764 | dev->net->ethtool_ops = &sierra_net_ethtool_ops; | ||
765 | netif_carrier_off(dev->net); | ||
766 | |||
767 | sierra_net_set_private(dev, priv); | ||
768 | |||
769 | priv->kevent_flags = 0; | ||
770 | |||
771 | /* Use the shared workqueue */ | ||
772 | INIT_WORK(&priv->sierra_net_kevent, sierra_net_kevent); | ||
773 | |||
774 | /* Only need to do this once */ | ||
775 | init_timer(&priv->sync_timer); | ||
776 | |||
777 | /* verify fw attributes */ | ||
778 | status = sierra_net_get_fw_attr(dev, &fwattr); | ||
779 | dev_dbg(&dev->udev->dev, "Fw attr: %x\n", fwattr); | ||
780 | |||
781 | /* test whether firmware supports DHCP */ | ||
782 | if (!(status == sizeof(fwattr) && (fwattr & SWI_GET_FW_ATTR_MASK))) { | ||
783 | /* found incompatible firmware version */ | ||
784 | dev_err(&dev->udev->dev, "Incompatible driver and firmware" | ||
785 | " versions\n"); | ||
786 | kfree(priv); | ||
787 | return -ENODEV; | ||
788 | } | ||
789 | /* prepare sync message from template */ | ||
790 | memcpy(priv->sync_msg, sync_tmplate, sizeof(priv->sync_msg)); | ||
791 | |||
792 | /* initiate the sync sequence */ | ||
793 | sierra_net_dosync(dev); | ||
794 | |||
795 | return 0; | ||
796 | } | ||
797 | |||
798 | static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf) | ||
799 | { | ||
800 | int status; | ||
801 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
802 | |||
803 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
804 | |||
805 | /* Kill the timer then flush the work queue */ | ||
806 | del_timer_sync(&priv->sync_timer); | ||
807 | |||
808 | flush_scheduled_work(); | ||
809 | |||
810 | /* tell modem we are going away */ | ||
811 | status = sierra_net_send_cmd(dev, priv->shdwn_msg, | ||
812 | sizeof(priv->shdwn_msg), "Shutdown"); | ||
813 | if (status < 0) | ||
814 | netdev_err(dev->net, | ||
815 | "usb_control_msg failed, status %d\n", status); | ||
816 | |||
817 | sierra_net_set_private(dev, NULL); | ||
818 | |||
819 | kfree(priv); | ||
820 | } | ||
821 | |||
822 | static struct sk_buff *sierra_net_skb_clone(struct usbnet *dev, | ||
823 | struct sk_buff *skb, int len) | ||
824 | { | ||
825 | struct sk_buff *new_skb; | ||
826 | |||
827 | /* clone skb */ | ||
828 | new_skb = skb_clone(skb, GFP_ATOMIC); | ||
829 | |||
830 | /* remove len bytes from original */ | ||
831 | skb_pull(skb, len); | ||
832 | |||
833 | /* trim next packet to it's length */ | ||
834 | if (new_skb) { | ||
835 | skb_trim(new_skb, len); | ||
836 | } else { | ||
837 | if (netif_msg_rx_err(dev)) | ||
838 | netdev_err(dev->net, "failed to get skb\n"); | ||
839 | dev->net->stats.rx_dropped++; | ||
840 | } | ||
841 | |||
842 | return new_skb; | ||
843 | } | ||
844 | |||
845 | /* ---------------------------- Receive data path ----------------------*/ | ||
846 | static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | ||
847 | { | ||
848 | int err; | ||
849 | struct hip_hdr hh; | ||
850 | struct sk_buff *new_skb; | ||
851 | |||
852 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
853 | |||
854 | /* could contain multiple packets */ | ||
855 | while (likely(skb->len)) { | ||
856 | err = parse_hip(skb->data, skb->len, &hh); | ||
857 | if (err) { | ||
858 | if (netif_msg_rx_err(dev)) | ||
859 | netdev_err(dev->net, "Invalid HIP header %d\n", | ||
860 | err); | ||
861 | /* dev->net->stats.rx_errors incremented by caller */ | ||
862 | dev->net->stats.rx_length_errors++; | ||
863 | return 0; | ||
864 | } | ||
865 | |||
866 | /* Validate Extended HIP header */ | ||
867 | if (!hh.extmsgid.is_present | ||
868 | || hh.extmsgid.word != SIERRA_NET_HIP_EXT_IP_IN_ID) { | ||
869 | if (netif_msg_rx_err(dev)) | ||
870 | netdev_err(dev->net, "HIP/ETH: Invalid pkt\n"); | ||
871 | |||
872 | dev->net->stats.rx_frame_errors++; | ||
873 | /* dev->net->stats.rx_errors incremented by caller */; | ||
874 | return 0; | ||
875 | } | ||
876 | |||
877 | skb_pull(skb, hh.hdrlen); | ||
878 | |||
879 | /* We are going to accept this packet, prepare it */ | ||
880 | memcpy(skb->data, sierra_net_get_private(dev)->ethr_hdr_tmpl, | ||
881 | ETH_HLEN); | ||
882 | |||
883 | /* Last packet in batch handled by usbnet */ | ||
884 | if (hh.payload_len.word == skb->len) | ||
885 | return 1; | ||
886 | |||
887 | new_skb = sierra_net_skb_clone(dev, skb, hh.payload_len.word); | ||
888 | if (new_skb) | ||
889 | usbnet_skb_return(dev, new_skb); | ||
890 | |||
891 | } /* while */ | ||
892 | |||
893 | return 0; | ||
894 | } | ||
895 | |||
896 | /* ---------------------------- Transmit data path ----------------------*/ | ||
897 | struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | ||
898 | gfp_t flags) | ||
899 | { | ||
900 | struct sierra_net_data *priv = sierra_net_get_private(dev); | ||
901 | u16 len; | ||
902 | bool need_tail; | ||
903 | |||
904 | dev_dbg(&dev->udev->dev, "%s", __func__); | ||
905 | if (priv->link_up && check_ethip_packet(skb, dev) && is_ip(skb)) { | ||
906 | /* enough head room as is? */ | ||
907 | if (SIERRA_NET_HIP_EXT_HDR_LEN <= skb_headroom(skb)) { | ||
908 | /* Save the Eth/IP length and set up HIP hdr */ | ||
909 | len = skb->len; | ||
910 | skb_push(skb, SIERRA_NET_HIP_EXT_HDR_LEN); | ||
911 | /* Handle ZLP issue */ | ||
912 | need_tail = ((len + SIERRA_NET_HIP_EXT_HDR_LEN) | ||
913 | % dev->maxpacket == 0); | ||
914 | if (need_tail) { | ||
915 | if (unlikely(skb_tailroom(skb) == 0)) { | ||
916 | netdev_err(dev->net, "tx_fixup:" | ||
917 | "no room for packet\n"); | ||
918 | dev_kfree_skb_any(skb); | ||
919 | return NULL; | ||
920 | } else { | ||
921 | skb->data[skb->len] = 0; | ||
922 | __skb_put(skb, 1); | ||
923 | len = len + 1; | ||
924 | } | ||
925 | } | ||
926 | build_hip(skb->data, len, priv); | ||
927 | return skb; | ||
928 | } else { | ||
929 | /* | ||
930 | * compensate in the future if necessary | ||
931 | */ | ||
932 | netdev_err(dev->net, "tx_fixup: no room for HIP\n"); | ||
933 | } /* headroom */ | ||
934 | } | ||
935 | |||
936 | if (!priv->link_up) | ||
937 | dev->net->stats.tx_carrier_errors++; | ||
938 | |||
939 | /* tx_dropped incremented by usbnet */ | ||
940 | |||
941 | /* filter the packet out, release it */ | ||
942 | dev_kfree_skb_any(skb); | ||
943 | return NULL; | ||
944 | } | ||
945 | |||
946 | static const u8 sierra_net_ifnum_list[] = { 7, 10, 11 }; | ||
947 | static const struct sierra_net_info_data sierra_net_info_data_68A3 = { | ||
948 | .rx_urb_size = 8 * 1024, | ||
949 | .whitelist = { | ||
950 | .infolen = ARRAY_SIZE(sierra_net_ifnum_list), | ||
951 | .ifaceinfo = sierra_net_ifnum_list | ||
952 | } | ||
953 | }; | ||
954 | |||
955 | static const struct driver_info sierra_net_info_68A3 = { | ||
956 | .description = "Sierra Wireless USB-to-WWAN Modem", | ||
957 | .flags = FLAG_WWAN | FLAG_SEND_ZLP, | ||
958 | .bind = sierra_net_bind, | ||
959 | .unbind = sierra_net_unbind, | ||
960 | .status = sierra_net_status, | ||
961 | .rx_fixup = sierra_net_rx_fixup, | ||
962 | .tx_fixup = sierra_net_tx_fixup, | ||
963 | .data = (unsigned long)&sierra_net_info_data_68A3, | ||
964 | }; | ||
965 | |||
966 | static const struct usb_device_id products[] = { | ||
967 | {USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless USB-to-WWAN modem */ | ||
968 | .driver_info = (unsigned long) &sierra_net_info_68A3}, | ||
969 | |||
970 | {}, /* last item */ | ||
971 | }; | ||
972 | MODULE_DEVICE_TABLE(usb, products); | ||
973 | |||
974 | /* We are based on usbnet, so let it handle the USB driver specifics */ | ||
975 | static struct usb_driver sierra_net_driver = { | ||
976 | .name = "sierra_net", | ||
977 | .id_table = products, | ||
978 | .probe = usbnet_probe, | ||
979 | .disconnect = usbnet_disconnect, | ||
980 | .suspend = usbnet_suspend, | ||
981 | .resume = usbnet_resume, | ||
982 | .no_dynamic_id = 1, | ||
983 | }; | ||
984 | |||
985 | static int __init sierra_net_init(void) | ||
986 | { | ||
987 | BUILD_BUG_ON(FIELD_SIZEOF(struct usbnet, data) | ||
988 | < sizeof(struct cdc_state)); | ||
989 | |||
990 | return usb_register(&sierra_net_driver); | ||
991 | } | ||
992 | |||
993 | static void __exit sierra_net_exit(void) | ||
994 | { | ||
995 | usb_deregister(&sierra_net_driver); | ||
996 | } | ||
997 | |||
998 | module_exit(sierra_net_exit); | ||
999 | module_init(sierra_net_init); | ||
1000 | |||
1001 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
1002 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
1003 | MODULE_VERSION(DRIVER_VERSION); | ||
1004 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c index 679da7e7522e..ca42ccb23d76 100644 --- a/drivers/net/wireless/p54/p54pci.c +++ b/drivers/net/wireless/p54/p54pci.c | |||
@@ -246,7 +246,7 @@ static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index, | |||
246 | u32 idx, i; | 246 | u32 idx, i; |
247 | 247 | ||
248 | i = (*index) % ring_limit; | 248 | i = (*index) % ring_limit; |
249 | (*index) = idx = le32_to_cpu(ring_control->device_idx[1]); | 249 | (*index) = idx = le32_to_cpu(ring_control->device_idx[ring_index]); |
250 | idx %= ring_limit; | 250 | idx %= ring_limit; |
251 | 251 | ||
252 | while (i != idx) { | 252 | while (i != idx) { |