aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-05-14 09:29:52 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-05-14 09:29:52 -0400
commit23e117fa44429cc054cb27d5621d64e4ced91e52 (patch)
treea4b9d0902b9c6f009b2c297515221c1b9bed3af8 /drivers/net
parent668eb65f092902eb7dd526af73d4a7f025a94612 (diff)
parenta93d2f1744206827ccf416e2cdc5018aa503314e (diff)
Merge branch 'sched/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip into trace/tip/tracing/core-4
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/8139too.c2
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/bnx2.c48
-rw-r--r--drivers/net/can/usb/ems_usb.c8
-rw-r--r--drivers/net/cxgb3/ael1002.c2
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c2
-rw-r--r--drivers/net/e100.c10
-rw-r--r--drivers/net/e1000e/82571.c20
-rw-r--r--drivers/net/e1000e/e1000.h5
-rw-r--r--drivers/net/e1000e/netdev.c70
-rw-r--r--drivers/net/fsl_pq_mdio.c20
-rw-r--r--drivers/net/gianfar.c12
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c62
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c22
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h2
-rw-r--r--drivers/net/ks8851.c12
-rw-r--r--drivers/net/pcmcia/3c574_cs.c7
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c31
-rw-r--r--drivers/net/r8169.c32
-rw-r--r--drivers/net/sfc/efx.c4
-rw-r--r--drivers/net/sfc/falcon.c4
-rw-r--r--drivers/net/sfc/falcon_boards.c13
-rw-r--r--drivers/net/sfc/nic.h2
-rw-r--r--drivers/net/sfc/siena.c13
-rw-r--r--drivers/net/tg3.c1
-rw-r--r--drivers/net/usb/Kconfig22
-rw-r--r--drivers/net/usb/Makefile2
-rw-r--r--drivers/net/usb/cdc_ether.c1
-rw-r--r--drivers/net/usb/ipheth.c569
-rw-r--r--drivers/net/usb/kaweth.c1
-rw-r--r--drivers/net/usb/sierra_net.c1001
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c31
38 files changed, 1875 insertions, 170 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index a03d291de854..f0d23de32967 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -1944,7 +1944,7 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1944 netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n", 1944 netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n",
1945 __func__, rx_status, rx_size, cur_rx); 1945 __func__, rx_status, rx_size, cur_rx);
1946#if RTL8139_DEBUG > 2 1946#if RTL8139_DEBUG > 2
1947 print_dump_hex(KERN_DEBUG, "Frame contents: ", 1947 print_hex_dump(KERN_DEBUG, "Frame contents: ",
1948 DUMP_PREFIX_OFFSET, 16, 1, 1948 DUMP_PREFIX_OFFSET, 16, 1,
1949 &rx_ring[ring_offset], 70, true); 1949 &rx_ring[ring_offset], 70, true);
1950#endif 1950#endif
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index a583b50d9de8..12b280afdd51 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -273,6 +273,7 @@ obj-$(CONFIG_USB_RTL8150) += usb/
273obj-$(CONFIG_USB_HSO) += usb/ 273obj-$(CONFIG_USB_HSO) += usb/
274obj-$(CONFIG_USB_USBNET) += usb/ 274obj-$(CONFIG_USB_USBNET) += usb/
275obj-$(CONFIG_USB_ZD1201) += usb/ 275obj-$(CONFIG_USB_ZD1201) += usb/
276obj-$(CONFIG_USB_IPHETH) += usb/
276 277
277obj-y += wireless/ 278obj-y += wireless/
278obj-$(CONFIG_NET_TULIP) += tulip/ 279obj-$(CONFIG_NET_TULIP) += tulip/
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index a257babd1bb4..ac90a3828f69 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
653static void 653static void
654bnx2_netif_stop(struct bnx2 *bp) 654bnx2_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
673static void 674static void
674bnx2_netif_start(struct bnx2 *bp) 675bnx2_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}
@@ -4759,8 +4761,12 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
4759 rc = bnx2_alloc_bad_rbuf(bp); 4761 rc = bnx2_alloc_bad_rbuf(bp);
4760 } 4762 }
4761 4763
4762 if (bp->flags & BNX2_FLAG_USING_MSIX) 4764 if (bp->flags & BNX2_FLAG_USING_MSIX) {
4763 bnx2_setup_msix_tbl(bp); 4765 bnx2_setup_msix_tbl(bp);
4766 /* Prevent MSIX table reads and write from timing out */
4767 REG_WR(bp, BNX2_MISC_ECO_HW_CTL,
4768 BNX2_MISC_ECO_HW_CTL_LARGE_GRC_TMOUT_EN);
4769 }
4764 4770
4765 return rc; 4771 return rc;
4766} 4772}
@@ -6273,12 +6279,12 @@ bnx2_reset_task(struct work_struct *work)
6273 return; 6279 return;
6274 } 6280 }
6275 6281
6276 bnx2_netif_stop(bp); 6282 bnx2_netif_stop(bp, true);
6277 6283
6278 bnx2_init_nic(bp, 1); 6284 bnx2_init_nic(bp, 1);
6279 6285
6280 atomic_set(&bp->intr_sem, 1); 6286 atomic_set(&bp->intr_sem, 1);
6281 bnx2_netif_start(bp); 6287 bnx2_netif_start(bp, true);
6282 rtnl_unlock(); 6288 rtnl_unlock();
6283} 6289}
6284 6290
@@ -6320,7 +6326,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
6320 struct bnx2 *bp = netdev_priv(dev); 6326 struct bnx2 *bp = netdev_priv(dev);
6321 6327
6322 if (netif_running(dev)) 6328 if (netif_running(dev))
6323 bnx2_netif_stop(bp); 6329 bnx2_netif_stop(bp, false);
6324 6330
6325 bp->vlgrp = vlgrp; 6331 bp->vlgrp = vlgrp;
6326 6332
@@ -6331,7 +6337,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
6331 if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) 6337 if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)
6332 bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); 6338 bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1);
6333 6339
6334 bnx2_netif_start(bp); 6340 bnx2_netif_start(bp, false);
6335} 6341}
6336#endif 6342#endif
6337 6343
@@ -7051,9 +7057,9 @@ bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
7051 bp->stats_ticks &= BNX2_HC_STATS_TICKS_HC_STAT_TICKS; 7057 bp->stats_ticks &= BNX2_HC_STATS_TICKS_HC_STAT_TICKS;
7052 7058
7053 if (netif_running(bp->dev)) { 7059 if (netif_running(bp->dev)) {
7054 bnx2_netif_stop(bp); 7060 bnx2_netif_stop(bp, true);
7055 bnx2_init_nic(bp, 0); 7061 bnx2_init_nic(bp, 0);
7056 bnx2_netif_start(bp); 7062 bnx2_netif_start(bp, true);
7057 } 7063 }
7058 7064
7059 return 0; 7065 return 0;
@@ -7083,7 +7089,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx)
7083 /* Reset will erase chipset stats; save them */ 7089 /* Reset will erase chipset stats; save them */
7084 bnx2_save_stats(bp); 7090 bnx2_save_stats(bp);
7085 7091
7086 bnx2_netif_stop(bp); 7092 bnx2_netif_stop(bp, true);
7087 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); 7093 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
7088 bnx2_free_skbs(bp); 7094 bnx2_free_skbs(bp);
7089 bnx2_free_mem(bp); 7095 bnx2_free_mem(bp);
@@ -7111,7 +7117,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx)
7111 bnx2_setup_cnic_irq_info(bp); 7117 bnx2_setup_cnic_irq_info(bp);
7112 mutex_unlock(&bp->cnic_lock); 7118 mutex_unlock(&bp->cnic_lock);
7113#endif 7119#endif
7114 bnx2_netif_start(bp); 7120 bnx2_netif_start(bp, true);
7115 } 7121 }
7116 return 0; 7122 return 0;
7117} 7123}
@@ -7364,7 +7370,7 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
7364 if (etest->flags & ETH_TEST_FL_OFFLINE) { 7370 if (etest->flags & ETH_TEST_FL_OFFLINE) {
7365 int i; 7371 int i;
7366 7372
7367 bnx2_netif_stop(bp); 7373 bnx2_netif_stop(bp, true);
7368 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG); 7374 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG);
7369 bnx2_free_skbs(bp); 7375 bnx2_free_skbs(bp);
7370 7376
@@ -7383,7 +7389,7 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
7383 bnx2_shutdown_chip(bp); 7389 bnx2_shutdown_chip(bp);
7384 else { 7390 else {
7385 bnx2_init_nic(bp, 1); 7391 bnx2_init_nic(bp, 1);
7386 bnx2_netif_start(bp); 7392 bnx2_netif_start(bp, true);
7387 } 7393 }
7388 7394
7389 /* wait for link up */ 7395 /* wait for link up */
@@ -8377,7 +8383,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
8377 return 0; 8383 return 0;
8378 8384
8379 flush_scheduled_work(); 8385 flush_scheduled_work();
8380 bnx2_netif_stop(bp); 8386 bnx2_netif_stop(bp, true);
8381 netif_device_detach(dev); 8387 netif_device_detach(dev);
8382 del_timer_sync(&bp->timer); 8388 del_timer_sync(&bp->timer);
8383 bnx2_shutdown_chip(bp); 8389 bnx2_shutdown_chip(bp);
@@ -8399,7 +8405,7 @@ bnx2_resume(struct pci_dev *pdev)
8399 bnx2_set_power_state(bp, PCI_D0); 8405 bnx2_set_power_state(bp, PCI_D0);
8400 netif_device_attach(dev); 8406 netif_device_attach(dev);
8401 bnx2_init_nic(bp, 1); 8407 bnx2_init_nic(bp, 1);
8402 bnx2_netif_start(bp); 8408 bnx2_netif_start(bp, true);
8403 return 0; 8409 return 0;
8404} 8410}
8405 8411
@@ -8426,7 +8432,7 @@ static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
8426 } 8432 }
8427 8433
8428 if (netif_running(dev)) { 8434 if (netif_running(dev)) {
8429 bnx2_netif_stop(bp); 8435 bnx2_netif_stop(bp, true);
8430 del_timer_sync(&bp->timer); 8436 del_timer_sync(&bp->timer);
8431 bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET); 8437 bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
8432 } 8438 }
@@ -8483,7 +8489,7 @@ static void bnx2_io_resume(struct pci_dev *pdev)
8483 8489
8484 rtnl_lock(); 8490 rtnl_lock();
8485 if (netif_running(dev)) 8491 if (netif_running(dev))
8486 bnx2_netif_start(bp); 8492 bnx2_netif_start(bp, true);
8487 8493
8488 netif_device_attach(dev); 8494 netif_device_attach(dev);
8489 rtnl_unlock(); 8495 rtnl_unlock();
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 33451092b8e8..d800b598ae3d 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -1006,7 +1006,7 @@ static int ems_usb_probe(struct usb_interface *intf,
1006 1006
1007 netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS); 1007 netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS);
1008 if (!netdev) { 1008 if (!netdev) {
1009 dev_err(netdev->dev.parent, "Couldn't alloc candev\n"); 1009 dev_err(&intf->dev, "ems_usb: Couldn't alloc candev\n");
1010 return -ENOMEM; 1010 return -ENOMEM;
1011 } 1011 }
1012 1012
@@ -1036,20 +1036,20 @@ static int ems_usb_probe(struct usb_interface *intf,
1036 1036
1037 dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); 1037 dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
1038 if (!dev->intr_urb) { 1038 if (!dev->intr_urb) {
1039 dev_err(netdev->dev.parent, "Couldn't alloc intr URB\n"); 1039 dev_err(&intf->dev, "Couldn't alloc intr URB\n");
1040 goto cleanup_candev; 1040 goto cleanup_candev;
1041 } 1041 }
1042 1042
1043 dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL); 1043 dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL);
1044 if (!dev->intr_in_buffer) { 1044 if (!dev->intr_in_buffer) {
1045 dev_err(netdev->dev.parent, "Couldn't alloc Intr buffer\n"); 1045 dev_err(&intf->dev, "Couldn't alloc Intr buffer\n");
1046 goto cleanup_intr_urb; 1046 goto cleanup_intr_urb;
1047 } 1047 }
1048 1048
1049 dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE + 1049 dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE +
1050 sizeof(struct ems_cpc_msg), GFP_KERNEL); 1050 sizeof(struct ems_cpc_msg), GFP_KERNEL);
1051 if (!dev->tx_msg_buffer) { 1051 if (!dev->tx_msg_buffer) {
1052 dev_err(netdev->dev.parent, "Couldn't alloc Tx buffer\n"); 1052 dev_err(&intf->dev, "Couldn't alloc Tx buffer\n");
1053 goto cleanup_intr_in_buffer; 1053 goto cleanup_intr_in_buffer;
1054 } 1054 }
1055 1055
diff --git a/drivers/net/cxgb3/ael1002.c b/drivers/net/cxgb3/ael1002.c
index 5248f9e0b2f4..35cd36729155 100644
--- a/drivers/net/cxgb3/ael1002.c
+++ b/drivers/net/cxgb3/ael1002.c
@@ -934,7 +934,7 @@ static struct cphy_ops xaui_direct_ops = {
934int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, 934int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter,
935 int phy_addr, const struct mdio_ops *mdio_ops) 935 int phy_addr, const struct mdio_ops *mdio_ops)
936{ 936{
937 cphy_init(phy, adapter, MDIO_PRTAD_NONE, &xaui_direct_ops, mdio_ops, 937 cphy_init(phy, adapter, phy_addr, &xaui_direct_ops, mdio_ops,
938 SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, 938 SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP,
939 "10GBASE-CX4"); 939 "10GBASE-CX4");
940 return 0; 940 return 0;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index aced6c5e635c..e3f1b8566495 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -439,7 +439,7 @@ static void free_irq_resources(struct adapter *adapter)
439static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt, 439static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt,
440 unsigned long n) 440 unsigned long n)
441{ 441{
442 int attempts = 5; 442 int attempts = 10;
443 443
444 while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) { 444 while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) {
445 if (!--attempts) 445 if (!--attempts)
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index b997e578e58f..791080303db1 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -166,6 +166,7 @@
166#include <linux/ethtool.h> 166#include <linux/ethtool.h>
167#include <linux/string.h> 167#include <linux/string.h>
168#include <linux/firmware.h> 168#include <linux/firmware.h>
169#include <linux/rtnetlink.h>
169#include <asm/unaligned.h> 170#include <asm/unaligned.h>
170 171
171 172
@@ -2265,8 +2266,13 @@ static void e100_tx_timeout_task(struct work_struct *work)
2265 2266
2266 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", 2267 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
2267 ioread8(&nic->csr->scb.status)); 2268 ioread8(&nic->csr->scb.status));
2268 e100_down(netdev_priv(netdev)); 2269
2269 e100_up(netdev_priv(netdev)); 2270 rtnl_lock();
2271 if (netif_running(netdev)) {
2272 e100_down(netdev_priv(netdev));
2273 e100_up(netdev_priv(netdev));
2274 }
2275 rtnl_unlock();
2270} 2276}
2271 2277
2272static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) 2278static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 712ccc66ba25..90155552ea09 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -336,7 +336,6 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
336 struct e1000_hw *hw = &adapter->hw; 336 struct e1000_hw *hw = &adapter->hw;
337 static int global_quad_port_a; /* global port a indication */ 337 static int global_quad_port_a; /* global port a indication */
338 struct pci_dev *pdev = adapter->pdev; 338 struct pci_dev *pdev = adapter->pdev;
339 u16 eeprom_data = 0;
340 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; 339 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
341 s32 rc; 340 s32 rc;
342 341
@@ -387,16 +386,15 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
387 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) 386 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
388 adapter->flags &= ~FLAG_HAS_WOL; 387 adapter->flags &= ~FLAG_HAS_WOL;
389 break; 388 break;
390
391 case e1000_82573: 389 case e1000_82573:
390 case e1000_82574:
391 case e1000_82583:
392 /* Disable ASPM L0s due to hardware errata */
393 e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S);
394
392 if (pdev->device == E1000_DEV_ID_82573L) { 395 if (pdev->device == E1000_DEV_ID_82573L) {
393 if (e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1, 396 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
394 &eeprom_data) < 0) 397 adapter->max_hw_frame_size = DEFAULT_JUMBO;
395 break;
396 if (!(eeprom_data & NVM_WORD1A_ASPM_MASK)) {
397 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
398 adapter->max_hw_frame_size = DEFAULT_JUMBO;
399 }
400 } 398 }
401 break; 399 break;
402 default: 400 default:
@@ -1792,6 +1790,7 @@ struct e1000_info e1000_82571_info = {
1792 | FLAG_RESET_OVERWRITES_LAA /* errata */ 1790 | FLAG_RESET_OVERWRITES_LAA /* errata */
1793 | FLAG_TARC_SPEED_MODE_BIT /* errata */ 1791 | FLAG_TARC_SPEED_MODE_BIT /* errata */
1794 | FLAG_APME_CHECK_PORT_B, 1792 | FLAG_APME_CHECK_PORT_B,
1793 .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */
1795 .pba = 38, 1794 .pba = 38,
1796 .max_hw_frame_size = DEFAULT_JUMBO, 1795 .max_hw_frame_size = DEFAULT_JUMBO,
1797 .get_variants = e1000_get_variants_82571, 1796 .get_variants = e1000_get_variants_82571,
@@ -1809,6 +1808,7 @@ struct e1000_info e1000_82572_info = {
1809 | FLAG_RX_CSUM_ENABLED 1808 | FLAG_RX_CSUM_ENABLED
1810 | FLAG_HAS_CTRLEXT_ON_LOAD 1809 | FLAG_HAS_CTRLEXT_ON_LOAD
1811 | FLAG_TARC_SPEED_MODE_BIT, /* errata */ 1810 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
1811 .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */
1812 .pba = 38, 1812 .pba = 38,
1813 .max_hw_frame_size = DEFAULT_JUMBO, 1813 .max_hw_frame_size = DEFAULT_JUMBO,
1814 .get_variants = e1000_get_variants_82571, 1814 .get_variants = e1000_get_variants_82571,
@@ -1820,13 +1820,11 @@ struct e1000_info e1000_82572_info = {
1820struct e1000_info e1000_82573_info = { 1820struct e1000_info e1000_82573_info = {
1821 .mac = e1000_82573, 1821 .mac = e1000_82573,
1822 .flags = FLAG_HAS_HW_VLAN_FILTER 1822 .flags = FLAG_HAS_HW_VLAN_FILTER
1823 | FLAG_HAS_JUMBO_FRAMES
1824 | FLAG_HAS_WOL 1823 | FLAG_HAS_WOL
1825 | FLAG_APME_IN_CTRL3 1824 | FLAG_APME_IN_CTRL3
1826 | FLAG_RX_CSUM_ENABLED 1825 | FLAG_RX_CSUM_ENABLED
1827 | FLAG_HAS_SMART_POWER_DOWN 1826 | FLAG_HAS_SMART_POWER_DOWN
1828 | FLAG_HAS_AMT 1827 | FLAG_HAS_AMT
1829 | FLAG_HAS_ERT
1830 | FLAG_HAS_SWSM_ON_LOAD, 1828 | FLAG_HAS_SWSM_ON_LOAD,
1831 .pba = 20, 1829 .pba = 20,
1832 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, 1830 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 118bdf483593..ee32b9b27a9f 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -37,6 +37,7 @@
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/netdevice.h> 38#include <linux/netdevice.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/pci-aspm.h>
40 41
41#include "hw.h" 42#include "hw.h"
42 43
@@ -374,7 +375,7 @@ struct e1000_adapter {
374struct e1000_info { 375struct e1000_info {
375 enum e1000_mac_type mac; 376 enum e1000_mac_type mac;
376 unsigned int flags; 377 unsigned int flags;
377 unsigned int flags2; 378 unsigned int flags2;
378 u32 pba; 379 u32 pba;
379 u32 max_hw_frame_size; 380 u32 max_hw_frame_size;
380 s32 (*get_variants)(struct e1000_adapter *); 381 s32 (*get_variants)(struct e1000_adapter *);
@@ -421,6 +422,7 @@ struct e1000_info {
421#define FLAG2_CRC_STRIPPING (1 << 0) 422#define FLAG2_CRC_STRIPPING (1 << 0)
422#define FLAG2_HAS_PHY_WAKEUP (1 << 1) 423#define FLAG2_HAS_PHY_WAKEUP (1 << 1)
423#define FLAG2_IS_DISCARDING (1 << 2) 424#define FLAG2_IS_DISCARDING (1 << 2)
425#define FLAG2_DISABLE_ASPM_L1 (1 << 3)
424 426
425#define E1000_RX_DESC_PS(R, i) \ 427#define E1000_RX_DESC_PS(R, i) \
426 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) 428 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
@@ -461,6 +463,7 @@ extern void e1000e_update_stats(struct e1000_adapter *adapter);
461extern bool e1000e_has_link(struct e1000_adapter *adapter); 463extern bool e1000e_has_link(struct e1000_adapter *adapter);
462extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); 464extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
463extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); 465extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
466extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
464 467
465extern unsigned int copybreak; 468extern unsigned int copybreak;
466 469
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 73d43c53015a..fb8fc7d1b50d 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4283,6 +4283,14 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
4283 return -EINVAL; 4283 return -EINVAL;
4284 } 4284 }
4285 4285
4286 /* 82573 Errata 17 */
4287 if (((adapter->hw.mac.type == e1000_82573) ||
4288 (adapter->hw.mac.type == e1000_82574)) &&
4289 (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN)) {
4290 adapter->flags2 |= FLAG2_DISABLE_ASPM_L1;
4291 e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L1);
4292 }
4293
4286 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 4294 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4287 msleep(1); 4295 msleep(1);
4288 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */ 4296 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
@@ -4605,29 +4613,39 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
4605 } 4613 }
4606} 4614}
4607 4615
4608static void e1000e_disable_l1aspm(struct pci_dev *pdev) 4616#ifdef CONFIG_PCIEASPM
4617static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4618{
4619 pci_disable_link_state(pdev, state);
4620}
4621#else
4622static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4609{ 4623{
4610 int pos; 4624 int pos;
4611 u16 val; 4625 u16 reg16;
4612 4626
4613 /* 4627 /*
4614 * 82573 workaround - disable L1 ASPM on mobile chipsets 4628 * Both device and parent should have the same ASPM setting.
4615 * 4629 * Disable ASPM in downstream component first and then upstream.
4616 * L1 ASPM on various mobile (ich7) chipsets do not behave properly
4617 * resulting in lost data or garbage information on the pci-e link
4618 * level. This could result in (false) bad EEPROM checksum errors,
4619 * long ping times (up to 2s) or even a system freeze/hang.
4620 *
4621 * Unfortunately this feature saves about 1W power consumption when
4622 * active.
4623 */ 4630 */
4624 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); 4631 pos = pci_pcie_cap(pdev);
4625 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val); 4632 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
4626 if (val & 0x2) { 4633 reg16 &= ~state;
4627 dev_warn(&pdev->dev, "Disabling L1 ASPM\n"); 4634 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
4628 val &= ~0x2; 4635
4629 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, val); 4636 pos = pci_pcie_cap(pdev->bus->self);
4630 } 4637 pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, &reg16);
4638 reg16 &= ~state;
4639 pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
4640}
4641#endif
4642void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4643{
4644 dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
4645 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
4646 (state & PCIE_LINK_STATE_L1) ? "L1" : "");
4647
4648 __e1000e_disable_aspm(pdev, state);
4631} 4649}
4632 4650
4633#ifdef CONFIG_PM 4651#ifdef CONFIG_PM
@@ -4653,7 +4671,8 @@ static int e1000_resume(struct pci_dev *pdev)
4653 pci_set_power_state(pdev, PCI_D0); 4671 pci_set_power_state(pdev, PCI_D0);
4654 pci_restore_state(pdev); 4672 pci_restore_state(pdev);
4655 pci_save_state(pdev); 4673 pci_save_state(pdev);
4656 e1000e_disable_l1aspm(pdev); 4674 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
4675 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
4657 4676
4658 err = pci_enable_device_mem(pdev); 4677 err = pci_enable_device_mem(pdev);
4659 if (err) { 4678 if (err) {
@@ -4795,7 +4814,8 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4795 int err; 4814 int err;
4796 pci_ers_result_t result; 4815 pci_ers_result_t result;
4797 4816
4798 e1000e_disable_l1aspm(pdev); 4817 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
4818 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
4799 err = pci_enable_device_mem(pdev); 4819 err = pci_enable_device_mem(pdev);
4800 if (err) { 4820 if (err) {
4801 dev_err(&pdev->dev, 4821 dev_err(&pdev->dev,
@@ -4889,13 +4909,6 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
4889 dev_warn(&adapter->pdev->dev, 4909 dev_warn(&adapter->pdev->dev,
4890 "Warning: detected DSPD enabled in EEPROM\n"); 4910 "Warning: detected DSPD enabled in EEPROM\n");
4891 } 4911 }
4892
4893 ret_val = e1000_read_nvm(hw, NVM_INIT_3GIO_3, 1, &buf);
4894 if (!ret_val && (le16_to_cpu(buf) & (3 << 2))) {
4895 /* ASPM enable */
4896 dev_warn(&adapter->pdev->dev,
4897 "Warning: detected ASPM enabled in EEPROM\n");
4898 }
4899} 4912}
4900 4913
4901static const struct net_device_ops e1000e_netdev_ops = { 4914static const struct net_device_ops e1000e_netdev_ops = {
@@ -4944,7 +4957,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4944 u16 eeprom_data = 0; 4957 u16 eeprom_data = 0;
4945 u16 eeprom_apme_mask = E1000_EEPROM_APME; 4958 u16 eeprom_apme_mask = E1000_EEPROM_APME;
4946 4959
4947 e1000e_disable_l1aspm(pdev); 4960 if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
4961 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
4948 4962
4949 err = pci_enable_device_mem(pdev); 4963 err = pci_enable_device_mem(pdev);
4950 if (err) 4964 if (err)
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index d5160edf2fcf..3acac5f930c8 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -205,8 +205,6 @@ static int fsl_pq_mdio_find_free(struct mii_bus *new_bus)
205static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) 205static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np)
206{ 206{
207 struct gfar __iomem *enet_regs; 207 struct gfar __iomem *enet_regs;
208 u32 __iomem *ioremap_tbipa;
209 u64 addr, size;
210 208
211 /* 209 /*
212 * This is mildly evil, but so is our hardware for doing this. 210 * This is mildly evil, but so is our hardware for doing this.
@@ -220,9 +218,7 @@ static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct devi
220 return &enet_regs->tbipa; 218 return &enet_regs->tbipa;
221 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || 219 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") ||
222 of_device_is_compatible(np, "fsl,etsec2-tbi")) { 220 of_device_is_compatible(np, "fsl,etsec2-tbi")) {
223 addr = of_translate_address(np, of_get_address(np, 1, &size, NULL)); 221 return of_iomap(np, 1);
224 ioremap_tbipa = ioremap(addr, size);
225 return ioremap_tbipa;
226 } else 222 } else
227 return NULL; 223 return NULL;
228} 224}
@@ -279,6 +275,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
279 u32 __iomem *tbipa; 275 u32 __iomem *tbipa;
280 struct mii_bus *new_bus; 276 struct mii_bus *new_bus;
281 int tbiaddr = -1; 277 int tbiaddr = -1;
278 const u32 *addrp;
282 u64 addr = 0, size = 0; 279 u64 addr = 0, size = 0;
283 int err = 0; 280 int err = 0;
284 281
@@ -297,8 +294,19 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
297 new_bus->priv = priv; 294 new_bus->priv = priv;
298 fsl_pq_mdio_bus_name(new_bus->id, np); 295 fsl_pq_mdio_bus_name(new_bus->id, np);
299 296
297 addrp = of_get_address(np, 0, &size, NULL);
298 if (!addrp) {
299 err = -EINVAL;
300 goto err_free_bus;
301 }
302
300 /* Set the PHY base address */ 303 /* Set the PHY base address */
301 addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); 304 addr = of_translate_address(np, addrp);
305 if (addr == OF_BAD_ADDR) {
306 err = -EINVAL;
307 goto err_free_bus;
308 }
309
302 map = ioremap(addr, size); 310 map = ioremap(addr, size);
303 if (!map) { 311 if (!map) {
304 err = -ENOMEM; 312 err = -ENOMEM;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 080d1cea5b26..4e97ca182997 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -549,12 +549,8 @@ static int gfar_parse_group(struct device_node *np,
549 struct gfar_private *priv, const char *model) 549 struct gfar_private *priv, const char *model)
550{ 550{
551 u32 *queue_mask; 551 u32 *queue_mask;
552 u64 addr, size;
553
554 addr = of_translate_address(np,
555 of_get_address(np, 0, &size, NULL));
556 priv->gfargrp[priv->num_grps].regs = ioremap(addr, size);
557 552
553 priv->gfargrp[priv->num_grps].regs = of_iomap(np, 0);
558 if (!priv->gfargrp[priv->num_grps].regs) 554 if (!priv->gfargrp[priv->num_grps].regs)
559 return -ENOMEM; 555 return -ENOMEM;
560 556
@@ -1515,9 +1511,9 @@ static void gfar_halt_nodisable(struct net_device *dev)
1515 tempval |= (DMACTRL_GRS | DMACTRL_GTS); 1511 tempval |= (DMACTRL_GRS | DMACTRL_GTS);
1516 gfar_write(&regs->dmactrl, tempval); 1512 gfar_write(&regs->dmactrl, tempval);
1517 1513
1518 while (!(gfar_read(&regs->ievent) & 1514 spin_event_timeout(((gfar_read(&regs->ievent) &
1519 (IEVENT_GRSC | IEVENT_GTSC))) 1515 (IEVENT_GRSC | IEVENT_GTSC)) ==
1520 cpu_relax(); 1516 (IEVENT_GRSC | IEVENT_GTSC)), -1, 0);
1521 } 1517 }
1522} 1518}
1523 1519
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index b405a00817c6..12fc0e7ba2ca 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -39,6 +39,8 @@
39#define IXGBE_82599_MC_TBL_SIZE 128 39#define IXGBE_82599_MC_TBL_SIZE 128
40#define IXGBE_82599_VFT_TBL_SIZE 128 40#define IXGBE_82599_VFT_TBL_SIZE 128
41 41
42void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
43void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
42void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw); 44void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
43s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, 45s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
44 ixgbe_link_speed speed, 46 ixgbe_link_speed speed,
@@ -69,8 +71,14 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
69 if (hw->phy.multispeed_fiber) { 71 if (hw->phy.multispeed_fiber) {
70 /* Set up dual speed SFP+ support */ 72 /* Set up dual speed SFP+ support */
71 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber; 73 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber;
74 mac->ops.disable_tx_laser =
75 &ixgbe_disable_tx_laser_multispeed_fiber;
76 mac->ops.enable_tx_laser =
77 &ixgbe_enable_tx_laser_multispeed_fiber;
72 mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber; 78 mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
73 } else { 79 } else {
80 mac->ops.disable_tx_laser = NULL;
81 mac->ops.enable_tx_laser = NULL;
74 mac->ops.flap_tx_laser = NULL; 82 mac->ops.flap_tx_laser = NULL;
75 if ((mac->ops.get_media_type(hw) == 83 if ((mac->ops.get_media_type(hw) ==
76 ixgbe_media_type_backplane) && 84 ixgbe_media_type_backplane) &&
@@ -415,6 +423,44 @@ s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
415 return status; 423 return status;
416} 424}
417 425
426 /**
427 * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
428 * @hw: pointer to hardware structure
429 *
430 * The base drivers may require better control over SFP+ module
431 * PHY states. This includes selectively shutting down the Tx
432 * laser on the PHY, effectively halting physical link.
433 **/
434void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
435{
436 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
437
438 /* Disable tx laser; allow 100us to go dark per spec */
439 esdp_reg |= IXGBE_ESDP_SDP3;
440 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
441 IXGBE_WRITE_FLUSH(hw);
442 udelay(100);
443}
444
445/**
446 * ixgbe_enable_tx_laser_multispeed_fiber - Enable Tx laser
447 * @hw: pointer to hardware structure
448 *
449 * The base drivers may require better control over SFP+ module
450 * PHY states. This includes selectively turning on the Tx
451 * laser on the PHY, effectively starting physical link.
452 **/
453void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
454{
455 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
456
457 /* Enable tx laser; allow 100ms to light up */
458 esdp_reg &= ~IXGBE_ESDP_SDP3;
459 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
460 IXGBE_WRITE_FLUSH(hw);
461 msleep(100);
462}
463
418/** 464/**
419 * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser 465 * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser
420 * @hw: pointer to hardware structure 466 * @hw: pointer to hardware structure
@@ -429,23 +475,11 @@ s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
429 **/ 475 **/
430void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) 476void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
431{ 477{
432 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
433
434 hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n"); 478 hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n");
435 479
436 if (hw->mac.autotry_restart) { 480 if (hw->mac.autotry_restart) {
437 /* Disable tx laser; allow 100us to go dark per spec */ 481 ixgbe_disable_tx_laser_multispeed_fiber(hw);
438 esdp_reg |= IXGBE_ESDP_SDP3; 482 ixgbe_enable_tx_laser_multispeed_fiber(hw);
439 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
440 IXGBE_WRITE_FLUSH(hw);
441 udelay(100);
442
443 /* Enable tx laser; allow 100ms to light up */
444 esdp_reg &= ~IXGBE_ESDP_SDP3;
445 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
446 IXGBE_WRITE_FLUSH(hw);
447 msleep(100);
448
449 hw->mac.autotry_restart = false; 483 hw->mac.autotry_restart = false;
450 } 484 }
451} 485}
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 8f677cb86290..6c00ee493a3b 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2982,6 +2982,10 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
2982 else 2982 else
2983 ixgbe_configure_msi_and_legacy(adapter); 2983 ixgbe_configure_msi_and_legacy(adapter);
2984 2984
2985 /* enable the optics */
2986 if (hw->phy.multispeed_fiber)
2987 hw->mac.ops.enable_tx_laser(hw);
2988
2985 clear_bit(__IXGBE_DOWN, &adapter->state); 2989 clear_bit(__IXGBE_DOWN, &adapter->state);
2986 ixgbe_napi_enable_all(adapter); 2990 ixgbe_napi_enable_all(adapter);
2987 2991
@@ -3243,6 +3247,10 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
3243 /* signal that we are down to the interrupt handler */ 3247 /* signal that we are down to the interrupt handler */
3244 set_bit(__IXGBE_DOWN, &adapter->state); 3248 set_bit(__IXGBE_DOWN, &adapter->state);
3245 3249
3250 /* power down the optics */
3251 if (hw->phy.multispeed_fiber)
3252 hw->mac.ops.disable_tx_laser(hw);
3253
3246 /* disable receive for all VFs and wait one second */ 3254 /* disable receive for all VFs and wait one second */
3247 if (adapter->num_vfs) { 3255 if (adapter->num_vfs) {
3248 /* ping all the active vfs to let them know we are going down */ 3256 /* ping all the active vfs to let them know we are going down */
@@ -6253,6 +6261,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6253 goto err_eeprom; 6261 goto err_eeprom;
6254 } 6262 }
6255 6263
6264 /* power down the optics */
6265 if (hw->phy.multispeed_fiber)
6266 hw->mac.ops.disable_tx_laser(hw);
6267
6256 init_timer(&adapter->watchdog_timer); 6268 init_timer(&adapter->watchdog_timer);
6257 adapter->watchdog_timer.function = &ixgbe_watchdog; 6269 adapter->watchdog_timer.function = &ixgbe_watchdog;
6258 adapter->watchdog_timer.data = (unsigned long)adapter; 6270 adapter->watchdog_timer.data = (unsigned long)adapter;
@@ -6400,16 +6412,6 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
6400 del_timer_sync(&adapter->sfp_timer); 6412 del_timer_sync(&adapter->sfp_timer);
6401 cancel_work_sync(&adapter->watchdog_task); 6413 cancel_work_sync(&adapter->watchdog_task);
6402 cancel_work_sync(&adapter->sfp_task); 6414 cancel_work_sync(&adapter->sfp_task);
6403 if (adapter->hw.phy.multispeed_fiber) {
6404 struct ixgbe_hw *hw = &adapter->hw;
6405 /*
6406 * Restart clause 37 autoneg, disable and re-enable
6407 * the tx laser, to clear & alert the link partner
6408 * that it needs to restart autotry
6409 */
6410 hw->mac.autotry_restart = true;
6411 hw->mac.ops.flap_tx_laser(hw);
6412 }
6413 cancel_work_sync(&adapter->multispeed_fiber_task); 6415 cancel_work_sync(&adapter->multispeed_fiber_task);
6414 cancel_work_sync(&adapter->sfp_config_module_task); 6416 cancel_work_sync(&adapter->sfp_config_module_task);
6415 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || 6417 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE ||
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 4ec6dc1a5b75..534affcc38ca 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -2398,6 +2398,8 @@ struct ixgbe_mac_operations {
2398 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); 2398 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32);
2399 2399
2400 /* Link */ 2400 /* Link */
2401 void (*disable_tx_laser)(struct ixgbe_hw *);
2402 void (*enable_tx_laser)(struct ixgbe_hw *);
2401 void (*flap_tx_laser)(struct ixgbe_hw *); 2403 void (*flap_tx_laser)(struct ixgbe_hw *);
2402 s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool); 2404 s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
2403 s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool); 2405 s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index 13cc1ca261d9..9e9f9b349766 100644
--- a/drivers/net/ks8851.c
+++ b/drivers/net/ks8851.c
@@ -722,12 +722,14 @@ static void ks8851_tx_work(struct work_struct *work)
722 txb = skb_dequeue(&ks->txq); 722 txb = skb_dequeue(&ks->txq);
723 last = skb_queue_empty(&ks->txq); 723 last = skb_queue_empty(&ks->txq);
724 724
725 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); 725 if (txb != NULL) {
726 ks8851_wrpkt(ks, txb, last); 726 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
727 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); 727 ks8851_wrpkt(ks, txb, last);
728 ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE); 728 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
729 ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE);
729 730
730 ks8851_done_tx(ks, txb); 731 ks8851_done_tx(ks, txb);
732 }
731 } 733 }
732 734
733 mutex_unlock(&ks->lock); 735 mutex_unlock(&ks->lock);
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 3d1d3a7b7ed3..757f87bb1db3 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -781,8 +781,13 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
781 inw(ioaddr + EL3_STATUS)); 781 inw(ioaddr + EL3_STATUS));
782 782
783 spin_lock_irqsave(&lp->window_lock, flags); 783 spin_lock_irqsave(&lp->window_lock, flags);
784
785 dev->stats.tx_bytes += skb->len;
786
787 /* Put out the doubleword header... */
784 outw(skb->len, ioaddr + TX_FIFO); 788 outw(skb->len, ioaddr + TX_FIFO);
785 outw(0, ioaddr + TX_FIFO); 789 outw(0, ioaddr + TX_FIFO);
790 /* ... and the packet rounded to a doubleword. */
786 outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2); 791 outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2);
787 792
788 dev->trans_start = jiffies; 793 dev->trans_start = jiffies;
@@ -1021,8 +1026,6 @@ static void update_stats(struct net_device *dev)
1021 /* BadSSD */ inb(ioaddr + 12); 1026 /* BadSSD */ inb(ioaddr + 12);
1022 up = inb(ioaddr + 13); 1027 up = inb(ioaddr + 13);
1023 1028
1024 dev->stats.tx_bytes += tx + ((up & 0xf0) << 12);
1025
1026 EL3WINDOW(1); 1029 EL3WINDOW(1);
1027} 1030}
1028 1031
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index fd9d6e34fda4..ccc553782a0d 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/r8169.c b/drivers/net/r8169.c
index dbb1f5a1824c..4748c21eb72e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -2759,6 +2759,7 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
2759{ 2759{
2760 iounmap(ioaddr); 2760 iounmap(ioaddr);
2761 pci_release_regions(pdev); 2761 pci_release_regions(pdev);
2762 pci_clear_mwi(pdev);
2762 pci_disable_device(pdev); 2763 pci_disable_device(pdev);
2763 free_netdev(dev); 2764 free_netdev(dev);
2764} 2765}
@@ -2825,8 +2826,13 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
2825 spin_lock_irq(&tp->lock); 2826 spin_lock_irq(&tp->lock);
2826 2827
2827 RTL_W8(Cfg9346, Cfg9346_Unlock); 2828 RTL_W8(Cfg9346, Cfg9346_Unlock);
2829
2828 RTL_W32(MAC4, high); 2830 RTL_W32(MAC4, high);
2831 RTL_R32(MAC4);
2832
2829 RTL_W32(MAC0, low); 2833 RTL_W32(MAC0, low);
2834 RTL_R32(MAC0);
2835
2830 RTL_W8(Cfg9346, Cfg9346_Lock); 2836 RTL_W8(Cfg9346, Cfg9346_Lock);
2831 2837
2832 spin_unlock_irq(&tp->lock); 2838 spin_unlock_irq(&tp->lock);
@@ -3014,9 +3020,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3014 goto err_out_free_dev_1; 3020 goto err_out_free_dev_1;
3015 } 3021 }
3016 3022
3017 rc = pci_set_mwi(pdev); 3023 if (pci_set_mwi(pdev) < 0)
3018 if (rc < 0) 3024 netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n");
3019 goto err_out_disable_2;
3020 3025
3021 /* make sure PCI base addr 1 is MMIO */ 3026 /* make sure PCI base addr 1 is MMIO */
3022 if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { 3027 if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) {
@@ -3024,7 +3029,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3024 "region #%d not an MMIO resource, aborting\n", 3029 "region #%d not an MMIO resource, aborting\n",
3025 region); 3030 region);
3026 rc = -ENODEV; 3031 rc = -ENODEV;
3027 goto err_out_mwi_3; 3032 goto err_out_mwi_2;
3028 } 3033 }
3029 3034
3030 /* check for weird/broken PCI region reporting */ 3035 /* check for weird/broken PCI region reporting */
@@ -3032,13 +3037,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3032 netif_err(tp, probe, dev, 3037 netif_err(tp, probe, dev,
3033 "Invalid PCI region size(s), aborting\n"); 3038 "Invalid PCI region size(s), aborting\n");
3034 rc = -ENODEV; 3039 rc = -ENODEV;
3035 goto err_out_mwi_3; 3040 goto err_out_mwi_2;
3036 } 3041 }
3037 3042
3038 rc = pci_request_regions(pdev, MODULENAME); 3043 rc = pci_request_regions(pdev, MODULENAME);
3039 if (rc < 0) { 3044 if (rc < 0) {
3040 netif_err(tp, probe, dev, "could not request regions\n"); 3045 netif_err(tp, probe, dev, "could not request regions\n");
3041 goto err_out_mwi_3; 3046 goto err_out_mwi_2;
3042 } 3047 }
3043 3048
3044 tp->cp_cmd = PCIMulRW | RxChkSum; 3049 tp->cp_cmd = PCIMulRW | RxChkSum;
@@ -3051,7 +3056,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3051 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 3056 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
3052 if (rc < 0) { 3057 if (rc < 0) {
3053 netif_err(tp, probe, dev, "DMA configuration failed\n"); 3058 netif_err(tp, probe, dev, "DMA configuration failed\n");
3054 goto err_out_free_res_4; 3059 goto err_out_free_res_3;
3055 } 3060 }
3056 } 3061 }
3057 3062
@@ -3060,7 +3065,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3060 if (!ioaddr) { 3065 if (!ioaddr) {
3061 netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); 3066 netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n");
3062 rc = -EIO; 3067 rc = -EIO;
3063 goto err_out_free_res_4; 3068 goto err_out_free_res_3;
3064 } 3069 }
3065 3070
3066 tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); 3071 tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
@@ -3102,7 +3107,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3102 if (i == ARRAY_SIZE(rtl_chip_info)) { 3107 if (i == ARRAY_SIZE(rtl_chip_info)) {
3103 dev_err(&pdev->dev, 3108 dev_err(&pdev->dev,
3104 "driver bug, MAC version not found in rtl_chip_info\n"); 3109 "driver bug, MAC version not found in rtl_chip_info\n");
3105 goto err_out_msi_5; 3110 goto err_out_msi_4;
3106 } 3111 }
3107 tp->chipset = i; 3112 tp->chipset = i;
3108 3113
@@ -3167,7 +3172,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3167 3172
3168 rc = register_netdev(dev); 3173 rc = register_netdev(dev);
3169 if (rc < 0) 3174 if (rc < 0)
3170 goto err_out_msi_5; 3175 goto err_out_msi_4;
3171 3176
3172 pci_set_drvdata(pdev, dev); 3177 pci_set_drvdata(pdev, dev);
3173 3178
@@ -3190,14 +3195,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3190out: 3195out:
3191 return rc; 3196 return rc;
3192 3197
3193err_out_msi_5: 3198err_out_msi_4:
3194 rtl_disable_msi(pdev, tp); 3199 rtl_disable_msi(pdev, tp);
3195 iounmap(ioaddr); 3200 iounmap(ioaddr);
3196err_out_free_res_4: 3201err_out_free_res_3:
3197 pci_release_regions(pdev); 3202 pci_release_regions(pdev);
3198err_out_mwi_3: 3203err_out_mwi_2:
3199 pci_clear_mwi(pdev); 3204 pci_clear_mwi(pdev);
3200err_out_disable_2:
3201 pci_disable_device(pdev); 3205 pci_disable_device(pdev);
3202err_out_free_dev_1: 3206err_out_free_dev_1:
3203 free_netdev(dev); 3207 free_netdev(dev);
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 6486657c47b8..649a264d6a81 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1861,6 +1861,7 @@ out:
1861 } 1861 }
1862 1862
1863 if (disabled) { 1863 if (disabled) {
1864 dev_close(efx->net_dev);
1864 EFX_ERR(efx, "has been disabled\n"); 1865 EFX_ERR(efx, "has been disabled\n");
1865 efx->state = STATE_DISABLED; 1866 efx->state = STATE_DISABLED;
1866 } else { 1867 } else {
@@ -1884,8 +1885,7 @@ static void efx_reset_work(struct work_struct *data)
1884 } 1885 }
1885 1886
1886 rtnl_lock(); 1887 rtnl_lock();
1887 if (efx_reset(efx, efx->reset_pending)) 1888 (void)efx_reset(efx, efx->reset_pending);
1888 dev_close(efx->net_dev);
1889 rtnl_unlock(); 1889 rtnl_unlock();
1890} 1890}
1891 1891
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index d294d66fd600..08278e7302b3 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1320,7 +1320,9 @@ static int falcon_probe_nvconfig(struct efx_nic *efx)
1320 1320
1321 EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad); 1321 EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad);
1322 1322
1323 falcon_probe_board(efx, board_rev); 1323 rc = falcon_probe_board(efx, board_rev);
1324 if (rc)
1325 goto fail2;
1324 1326
1325 kfree(nvconfig); 1327 kfree(nvconfig);
1326 return 0; 1328 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
731static const struct falcon_board_type falcon_dummy_board = { 731int 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
739void 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 9351c0331a47..3166bafdfbef 100644
--- a/drivers/net/sfc/nic.h
+++ b/drivers/net/sfc/nic.h
@@ -156,7 +156,7 @@ extern struct efx_nic_type siena_a0_nic_type;
156 ************************************************************************** 156 **************************************************************************
157 */ 157 */
158 158
159extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info); 159extern int falcon_probe_board(struct efx_nic *efx, u16 revision_info);
160 160
161/* TX data path */ 161/* TX data path */
162extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue); 162extern 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 38dcc42c4f79..e0c46f59d1f8 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -456,8 +456,17 @@ static int siena_try_update_nic_stats(struct efx_nic *efx)
456 456
457static void siena_update_nic_stats(struct efx_nic *efx) 457static void siena_update_nic_stats(struct efx_nic *efx)
458{ 458{
459 while (siena_try_update_nic_stats(efx) == -EAGAIN) 459 int retry;
460 cpu_relax(); 460
461 /* If we're unlucky enough to read statistics wduring the DMA, wait
462 * up to 10ms for it to finish (typically takes <500us) */
463 for (retry = 0; retry < 100; ++retry) {
464 if (siena_try_update_nic_stats(efx) == 0)
465 return;
466 udelay(100);
467 }
468
469 /* Use the old values instead */
461} 470}
462 471
463static void siena_start_nic_stats(struct efx_nic *efx) 472static void siena_start_nic_stats(struct efx_nic *efx)
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 22cf1c446de3..ecc41cffb470 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -8633,6 +8633,7 @@ static int tg3_test_msi(struct tg3 *tp)
8633 pci_disable_msi(tp->pdev); 8633 pci_disable_msi(tp->pdev);
8634 8634
8635 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; 8635 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
8636 tp->napi[0].irq_vec = tp->pdev->irq;
8636 8637
8637 err = tg3_request_irq(tp, 0); 8638 err = tg3_request_irq(tp, 0);
8638 if (err) 8639 if (err)
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index ba56ce4382d9..5d58abc224f4 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -385,4 +385,26 @@ config USB_CDC_PHONET
385 cellular modem, as found on most Nokia handsets with the 385 cellular modem, as found on most Nokia handsets with the
386 "PC suite" USB profile. 386 "PC suite" USB profile.
387 387
388config USB_IPHETH
389 tristate "Apple iPhone USB Ethernet driver"
390 default n
391 ---help---
392 Module used to share Internet connection (tethering) from your
393 iPhone (Original, 3G and 3GS) to your system.
394 Note that you need userspace libraries and programs that are needed
395 to pair your device with your system and that understand the iPhone
396 protocol.
397
398 For more information: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver
399
400config USB_SIERRA_NET
401 tristate "USB-to-WWAN Driver for Sierra Wireless modems"
402 depends on USB_USBNET
403 default y
404 help
405 Choose this option if you have a Sierra Wireless USB-to-WWAN device.
406
407 To compile this driver as a module, choose M here: the
408 module will be called sierra_net.
409
388endmenu 410endmenu
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 82ea62955b56..b13a279663ba 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -23,4 +23,6 @@ obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o
23obj-$(CONFIG_USB_USBNET) += usbnet.o 23obj-$(CONFIG_USB_USBNET) += usbnet.o
24obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o 24obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o
25obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o 25obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o
26obj-$(CONFIG_USB_IPHETH) += ipheth.o
27obj-$(CONFIG_USB_SIERRA_NET) += sierra_net.o
26 28
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index c8cdb7f30adc..3547cf13d219 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -431,6 +431,7 @@ static const struct driver_info mbm_info = {
431 .bind = cdc_bind, 431 .bind = cdc_bind,
432 .unbind = usbnet_cdc_unbind, 432 .unbind = usbnet_cdc_unbind,
433 .status = cdc_status, 433 .status = cdc_status,
434 .manage_power = cdc_manage_power,
434}; 435};
435 436
436/*-------------------------------------------------------------------------*/ 437/*-------------------------------------------------------------------------*/
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
new file mode 100644
index 000000000000..418825d26f90
--- /dev/null
+++ b/drivers/net/usb/ipheth.c
@@ -0,0 +1,569 @@
1/*
2 * ipheth.c - Apple iPhone USB Ethernet driver
3 *
4 * Copyright (c) 2009 Diego Giagio <diego@giagio.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of GIAGIO.COM nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * Alternatively, provided that this notice is retained in full, this
20 * software may be distributed under the terms of the GNU General
21 * Public License ("GPL") version 2, in which case the provisions of the
22 * GPL apply INSTEAD OF those given above.
23 *
24 * The provided data structures and external interfaces from this code
25 * are not restricted to be used by modules with a GPL compatible license.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
38 * DAMAGE.
39 *
40 *
41 * Attention: iPhone device must be paired, otherwise it won't respond to our
42 * driver. For more info: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver
43 *
44 */
45
46#include <linux/kernel.h>
47#include <linux/errno.h>
48#include <linux/init.h>
49#include <linux/slab.h>
50#include <linux/module.h>
51#include <linux/netdevice.h>
52#include <linux/etherdevice.h>
53#include <linux/ethtool.h>
54#include <linux/usb.h>
55#include <linux/workqueue.h>
56
57#define USB_VENDOR_APPLE 0x05ac
58#define USB_PRODUCT_IPHONE 0x1290
59#define USB_PRODUCT_IPHONE_3G 0x1292
60#define USB_PRODUCT_IPHONE_3GS 0x1294
61
62#define IPHETH_USBINTF_CLASS 255
63#define IPHETH_USBINTF_SUBCLASS 253
64#define IPHETH_USBINTF_PROTO 1
65
66#define IPHETH_BUF_SIZE 1516
67#define IPHETH_TX_TIMEOUT (5 * HZ)
68
69#define IPHETH_INTFNUM 2
70#define IPHETH_ALT_INTFNUM 1
71
72#define IPHETH_CTRL_ENDP 0x00
73#define IPHETH_CTRL_BUF_SIZE 0x40
74#define IPHETH_CTRL_TIMEOUT (5 * HZ)
75
76#define IPHETH_CMD_GET_MACADDR 0x00
77#define IPHETH_CMD_CARRIER_CHECK 0x45
78
79#define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ)
80#define IPHETH_CARRIER_ON 0x04
81
82static struct usb_device_id ipheth_table[] = {
83 { USB_DEVICE_AND_INTERFACE_INFO(
84 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE,
85 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
86 IPHETH_USBINTF_PROTO) },
87 { USB_DEVICE_AND_INTERFACE_INFO(
88 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G,
89 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
90 IPHETH_USBINTF_PROTO) },
91 { USB_DEVICE_AND_INTERFACE_INFO(
92 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS,
93 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
94 IPHETH_USBINTF_PROTO) },
95 { }
96};
97MODULE_DEVICE_TABLE(usb, ipheth_table);
98
99struct ipheth_device {
100 struct usb_device *udev;
101 struct usb_interface *intf;
102 struct net_device *net;
103 struct sk_buff *tx_skb;
104 struct urb *tx_urb;
105 struct urb *rx_urb;
106 unsigned char *tx_buf;
107 unsigned char *rx_buf;
108 unsigned char *ctrl_buf;
109 u8 bulk_in;
110 u8 bulk_out;
111 struct delayed_work carrier_work;
112};
113
114static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags);
115
116static int ipheth_alloc_urbs(struct ipheth_device *iphone)
117{
118 struct urb *tx_urb = NULL;
119 struct urb *rx_urb = NULL;
120 u8 *tx_buf = NULL;
121 u8 *rx_buf = NULL;
122
123 tx_urb = usb_alloc_urb(0, GFP_KERNEL);
124 if (tx_urb == NULL)
125 goto error_nomem;
126
127 rx_urb = usb_alloc_urb(0, GFP_KERNEL);
128 if (rx_urb == NULL)
129 goto free_tx_urb;
130
131 tx_buf = usb_buffer_alloc(iphone->udev,
132 IPHETH_BUF_SIZE,
133 GFP_KERNEL,
134 &tx_urb->transfer_dma);
135 if (tx_buf == NULL)
136 goto free_rx_urb;
137
138 rx_buf = usb_buffer_alloc(iphone->udev,
139 IPHETH_BUF_SIZE,
140 GFP_KERNEL,
141 &rx_urb->transfer_dma);
142 if (rx_buf == NULL)
143 goto free_tx_buf;
144
145
146 iphone->tx_urb = tx_urb;
147 iphone->rx_urb = rx_urb;
148 iphone->tx_buf = tx_buf;
149 iphone->rx_buf = rx_buf;
150 return 0;
151
152free_tx_buf:
153 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf,
154 tx_urb->transfer_dma);
155free_rx_urb:
156 usb_free_urb(rx_urb);
157free_tx_urb:
158 usb_free_urb(tx_urb);
159error_nomem:
160 return -ENOMEM;
161}
162
163static void ipheth_free_urbs(struct ipheth_device *iphone)
164{
165 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->rx_buf,
166 iphone->rx_urb->transfer_dma);
167 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->tx_buf,
168 iphone->tx_urb->transfer_dma);
169 usb_free_urb(iphone->rx_urb);
170 usb_free_urb(iphone->tx_urb);
171}
172
173static void ipheth_kill_urbs(struct ipheth_device *dev)
174{
175 usb_kill_urb(dev->tx_urb);
176 usb_kill_urb(dev->rx_urb);
177}
178
179static void ipheth_rcvbulk_callback(struct urb *urb)
180{
181 struct ipheth_device *dev;
182 struct sk_buff *skb;
183 int status;
184 char *buf;
185 int len;
186
187 dev = urb->context;
188 if (dev == NULL)
189 return;
190
191 status = urb->status;
192 switch (status) {
193 case -ENOENT:
194 case -ECONNRESET:
195 case -ESHUTDOWN:
196 return;
197 case 0:
198 break;
199 default:
200 err("%s: urb status: %d", __func__, urb->status);
201 return;
202 }
203
204 len = urb->actual_length;
205 buf = urb->transfer_buffer;
206
207 skb = dev_alloc_skb(NET_IP_ALIGN + len);
208 if (!skb) {
209 err("%s: dev_alloc_skb: -ENOMEM", __func__);
210 dev->net->stats.rx_dropped++;
211 return;
212 }
213
214 skb_reserve(skb, NET_IP_ALIGN);
215 memcpy(skb_put(skb, len), buf + NET_IP_ALIGN, len - NET_IP_ALIGN);
216 skb->dev = dev->net;
217 skb->protocol = eth_type_trans(skb, dev->net);
218
219 dev->net->stats.rx_packets++;
220 dev->net->stats.rx_bytes += len;
221
222 netif_rx(skb);
223 ipheth_rx_submit(dev, GFP_ATOMIC);
224}
225
226static void ipheth_sndbulk_callback(struct urb *urb)
227{
228 struct ipheth_device *dev;
229
230 dev = urb->context;
231 if (dev == NULL)
232 return;
233
234 if (urb->status != 0 &&
235 urb->status != -ENOENT &&
236 urb->status != -ECONNRESET &&
237 urb->status != -ESHUTDOWN)
238 err("%s: urb status: %d", __func__, urb->status);
239
240 dev_kfree_skb_irq(dev->tx_skb);
241 netif_wake_queue(dev->net);
242}
243
244static int ipheth_carrier_set(struct ipheth_device *dev)
245{
246 struct usb_device *udev = dev->udev;
247 int retval;
248
249 retval = usb_control_msg(udev,
250 usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
251 IPHETH_CMD_CARRIER_CHECK, /* request */
252 0xc0, /* request type */
253 0x00, /* value */
254 0x02, /* index */
255 dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE,
256 IPHETH_CTRL_TIMEOUT);
257 if (retval < 0) {
258 err("%s: usb_control_msg: %d", __func__, retval);
259 return retval;
260 }
261
262 if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON)
263 netif_carrier_on(dev->net);
264 else
265 netif_carrier_off(dev->net);
266
267 return 0;
268}
269
270static void ipheth_carrier_check_work(struct work_struct *work)
271{
272 struct ipheth_device *dev = container_of(work, struct ipheth_device,
273 carrier_work.work);
274
275 ipheth_carrier_set(dev);
276 schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT);
277}
278
279static int ipheth_get_macaddr(struct ipheth_device *dev)
280{
281 struct usb_device *udev = dev->udev;
282 struct net_device *net = dev->net;
283 int retval;
284
285 retval = usb_control_msg(udev,
286 usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
287 IPHETH_CMD_GET_MACADDR, /* request */
288 0xc0, /* request type */
289 0x00, /* value */
290 0x02, /* index */
291 dev->ctrl_buf,
292 IPHETH_CTRL_BUF_SIZE,
293 IPHETH_CTRL_TIMEOUT);
294 if (retval < 0) {
295 err("%s: usb_control_msg: %d", __func__, retval);
296 } else if (retval < ETH_ALEN) {
297 err("%s: usb_control_msg: short packet: %d bytes",
298 __func__, retval);
299 retval = -EINVAL;
300 } else {
301 memcpy(net->dev_addr, dev->ctrl_buf, ETH_ALEN);
302 retval = 0;
303 }
304
305 return retval;
306}
307
308static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags)
309{
310 struct usb_device *udev = dev->udev;
311 int retval;
312
313 usb_fill_bulk_urb(dev->rx_urb, udev,
314 usb_rcvbulkpipe(udev, dev->bulk_in),
315 dev->rx_buf, IPHETH_BUF_SIZE,
316 ipheth_rcvbulk_callback,
317 dev);
318 dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
319
320 retval = usb_submit_urb(dev->rx_urb, mem_flags);
321 if (retval)
322 err("%s: usb_submit_urb: %d", __func__, retval);
323 return retval;
324}
325
326static int ipheth_open(struct net_device *net)
327{
328 struct ipheth_device *dev = netdev_priv(net);
329 struct usb_device *udev = dev->udev;
330 int retval = 0;
331
332 usb_set_interface(udev, IPHETH_INTFNUM, IPHETH_ALT_INTFNUM);
333
334 retval = ipheth_carrier_set(dev);
335 if (retval)
336 return retval;
337
338 retval = ipheth_rx_submit(dev, GFP_KERNEL);
339 if (retval)
340 return retval;
341
342 schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT);
343 netif_start_queue(net);
344 return retval;
345}
346
347static int ipheth_close(struct net_device *net)
348{
349 struct ipheth_device *dev = netdev_priv(net);
350
351 cancel_delayed_work_sync(&dev->carrier_work);
352 netif_stop_queue(net);
353 return 0;
354}
355
356static int ipheth_tx(struct sk_buff *skb, struct net_device *net)
357{
358 struct ipheth_device *dev = netdev_priv(net);
359 struct usb_device *udev = dev->udev;
360 int retval;
361
362 /* Paranoid */
363 if (skb->len > IPHETH_BUF_SIZE) {
364 WARN(1, "%s: skb too large: %d bytes", __func__, skb->len);
365 dev->net->stats.tx_dropped++;
366 dev_kfree_skb_irq(skb);
367 return NETDEV_TX_OK;
368 }
369
370 memcpy(dev->tx_buf, skb->data, skb->len);
371 if (skb->len < IPHETH_BUF_SIZE)
372 memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len);
373
374 usb_fill_bulk_urb(dev->tx_urb, udev,
375 usb_sndbulkpipe(udev, dev->bulk_out),
376 dev->tx_buf, IPHETH_BUF_SIZE,
377 ipheth_sndbulk_callback,
378 dev);
379 dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
380
381 retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC);
382 if (retval) {
383 err("%s: usb_submit_urb: %d", __func__, retval);
384 dev->net->stats.tx_errors++;
385 dev_kfree_skb_irq(skb);
386 } else {
387 dev->tx_skb = skb;
388
389 dev->net->stats.tx_packets++;
390 dev->net->stats.tx_bytes += skb->len;
391 netif_stop_queue(net);
392 }
393
394 return NETDEV_TX_OK;
395}
396
397static void ipheth_tx_timeout(struct net_device *net)
398{
399 struct ipheth_device *dev = netdev_priv(net);
400
401 err("%s: TX timeout", __func__);
402 dev->net->stats.tx_errors++;
403 usb_unlink_urb(dev->tx_urb);
404}
405
406static struct net_device_stats *ipheth_stats(struct net_device *net)
407{
408 struct ipheth_device *dev = netdev_priv(net);
409 return &dev->net->stats;
410}
411
412static u32 ipheth_ethtool_op_get_link(struct net_device *net)
413{
414 struct ipheth_device *dev = netdev_priv(net);
415 return netif_carrier_ok(dev->net);
416}
417
418static struct ethtool_ops ops = {
419 .get_link = ipheth_ethtool_op_get_link
420};
421
422static const struct net_device_ops ipheth_netdev_ops = {
423 .ndo_open = &ipheth_open,
424 .ndo_stop = &ipheth_close,
425 .ndo_start_xmit = &ipheth_tx,
426 .ndo_tx_timeout = &ipheth_tx_timeout,
427 .ndo_get_stats = &ipheth_stats,
428};
429
430static struct device_type ipheth_type = {
431 .name = "wwan",
432};
433
434static int ipheth_probe(struct usb_interface *intf,
435 const struct usb_device_id *id)
436{
437 struct usb_device *udev = interface_to_usbdev(intf);
438 struct usb_host_interface *hintf;
439 struct usb_endpoint_descriptor *endp;
440 struct ipheth_device *dev;
441 struct net_device *netdev;
442 int i;
443 int retval;
444
445 netdev = alloc_etherdev(sizeof(struct ipheth_device));
446 if (!netdev)
447 return -ENOMEM;
448
449 netdev->netdev_ops = &ipheth_netdev_ops;
450 netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;
451 strcpy(netdev->name, "wwan%d");
452
453 dev = netdev_priv(netdev);
454 dev->udev = udev;
455 dev->net = netdev;
456 dev->intf = intf;
457
458 /* Set up endpoints */
459 hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM);
460 if (hintf == NULL) {
461 retval = -ENODEV;
462 err("Unable to find alternate settings interface");
463 goto err_endpoints;
464 }
465
466 for (i = 0; i < hintf->desc.bNumEndpoints; i++) {
467 endp = &hintf->endpoint[i].desc;
468 if (usb_endpoint_is_bulk_in(endp))
469 dev->bulk_in = endp->bEndpointAddress;
470 else if (usb_endpoint_is_bulk_out(endp))
471 dev->bulk_out = endp->bEndpointAddress;
472 }
473 if (!(dev->bulk_in && dev->bulk_out)) {
474 retval = -ENODEV;
475 err("Unable to find endpoints");
476 goto err_endpoints;
477 }
478
479 dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);
480 if (dev->ctrl_buf == NULL) {
481 retval = -ENOMEM;
482 goto err_alloc_ctrl_buf;
483 }
484
485 retval = ipheth_get_macaddr(dev);
486 if (retval)
487 goto err_get_macaddr;
488
489 INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work);
490
491 retval = ipheth_alloc_urbs(dev);
492 if (retval) {
493 err("error allocating urbs: %d", retval);
494 goto err_alloc_urbs;
495 }
496
497 usb_set_intfdata(intf, dev);
498
499 SET_NETDEV_DEV(netdev, &intf->dev);
500 SET_ETHTOOL_OPS(netdev, &ops);
501 SET_NETDEV_DEVTYPE(netdev, &ipheth_type);
502
503 retval = register_netdev(netdev);
504 if (retval) {
505 err("error registering netdev: %d", retval);
506 retval = -EIO;
507 goto err_register_netdev;
508 }
509
510 dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n");
511 return 0;
512
513err_register_netdev:
514 ipheth_free_urbs(dev);
515err_alloc_urbs:
516err_get_macaddr:
517err_alloc_ctrl_buf:
518 kfree(dev->ctrl_buf);
519err_endpoints:
520 free_netdev(netdev);
521 return retval;
522}
523
524static void ipheth_disconnect(struct usb_interface *intf)
525{
526 struct ipheth_device *dev;
527
528 dev = usb_get_intfdata(intf);
529 if (dev != NULL) {
530 unregister_netdev(dev->net);
531 ipheth_kill_urbs(dev);
532 ipheth_free_urbs(dev);
533 kfree(dev->ctrl_buf);
534 free_netdev(dev->net);
535 }
536 usb_set_intfdata(intf, NULL);
537 dev_info(&intf->dev, "Apple iPhone USB Ethernet now disconnected\n");
538}
539
540static struct usb_driver ipheth_driver = {
541 .name = "ipheth",
542 .probe = ipheth_probe,
543 .disconnect = ipheth_disconnect,
544 .id_table = ipheth_table,
545};
546
547static int __init ipheth_init(void)
548{
549 int retval;
550
551 retval = usb_register(&ipheth_driver);
552 if (retval) {
553 err("usb_register failed: %d", retval);
554 return retval;
555 }
556 return 0;
557}
558
559static void __exit ipheth_exit(void)
560{
561 usb_deregister(&ipheth_driver);
562}
563
564module_init(ipheth_init);
565module_exit(ipheth_exit);
566
567MODULE_AUTHOR("Diego Giagio <diego@giagio.com>");
568MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver");
569MODULE_LICENSE("Dual BSD/GPL");
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..a44f9e0ea098
--- /dev/null
+++ b/drivers/net/usb/sierra_net.c
@@ -0,0 +1,1001 @@
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"
31static 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 */
55static 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 */
72struct 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
77struct sierra_net_info_data {
78 u16 rx_urb_size;
79 struct sierra_net_iface_info whitelist;
80};
81
82/* Private data structure */
83struct 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
106struct 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
143struct 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 */
176static void sierra_sync_timer(unsigned long syncdata);
177static int sierra_net_change_mtu(struct net_device *net, int new_mtu);
178
179/* Our own net device operations structure */
180static 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 */
191static 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 */
197static 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 */
204static 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 */
214static 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
230static 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
237static 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
252struct hip_hdr {
253 int hdrlen;
254 struct param payload_len;
255 struct param msgid;
256 struct param msgspecific;
257 struct param extmsgid;
258};
259
260static 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
303static 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
316static 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
333static 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
346static 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
355static inline int sierra_net_is_valid_addrlen(u8 len)
356{
357 return (len == sizeof(struct in_addr));
358}
359
360static 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
410static 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
432static 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
456static 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
559static 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 */
570void 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
579static 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
605static 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
614static 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
621static 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. */
632static 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
640static 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
655static 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 */
690static 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(&eth->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 return 0;
793}
794
795static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf)
796{
797 int status;
798 struct sierra_net_data *priv = sierra_net_get_private(dev);
799
800 dev_dbg(&dev->udev->dev, "%s", __func__);
801
802 /* Kill the timer then flush the work queue */
803 del_timer_sync(&priv->sync_timer);
804
805 flush_scheduled_work();
806
807 /* tell modem we are going away */
808 status = sierra_net_send_cmd(dev, priv->shdwn_msg,
809 sizeof(priv->shdwn_msg), "Shutdown");
810 if (status < 0)
811 netdev_err(dev->net,
812 "usb_control_msg failed, status %d\n", status);
813
814 sierra_net_set_private(dev, NULL);
815
816 kfree(priv);
817}
818
819static struct sk_buff *sierra_net_skb_clone(struct usbnet *dev,
820 struct sk_buff *skb, int len)
821{
822 struct sk_buff *new_skb;
823
824 /* clone skb */
825 new_skb = skb_clone(skb, GFP_ATOMIC);
826
827 /* remove len bytes from original */
828 skb_pull(skb, len);
829
830 /* trim next packet to it's length */
831 if (new_skb) {
832 skb_trim(new_skb, len);
833 } else {
834 if (netif_msg_rx_err(dev))
835 netdev_err(dev->net, "failed to get skb\n");
836 dev->net->stats.rx_dropped++;
837 }
838
839 return new_skb;
840}
841
842/* ---------------------------- Receive data path ----------------------*/
843static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
844{
845 int err;
846 struct hip_hdr hh;
847 struct sk_buff *new_skb;
848
849 dev_dbg(&dev->udev->dev, "%s", __func__);
850
851 /* could contain multiple packets */
852 while (likely(skb->len)) {
853 err = parse_hip(skb->data, skb->len, &hh);
854 if (err) {
855 if (netif_msg_rx_err(dev))
856 netdev_err(dev->net, "Invalid HIP header %d\n",
857 err);
858 /* dev->net->stats.rx_errors incremented by caller */
859 dev->net->stats.rx_length_errors++;
860 return 0;
861 }
862
863 /* Validate Extended HIP header */
864 if (!hh.extmsgid.is_present
865 || hh.extmsgid.word != SIERRA_NET_HIP_EXT_IP_IN_ID) {
866 if (netif_msg_rx_err(dev))
867 netdev_err(dev->net, "HIP/ETH: Invalid pkt\n");
868
869 dev->net->stats.rx_frame_errors++;
870 /* dev->net->stats.rx_errors incremented by caller */;
871 return 0;
872 }
873
874 skb_pull(skb, hh.hdrlen);
875
876 /* We are going to accept this packet, prepare it */
877 memcpy(skb->data, sierra_net_get_private(dev)->ethr_hdr_tmpl,
878 ETH_HLEN);
879
880 /* Last packet in batch handled by usbnet */
881 if (hh.payload_len.word == skb->len)
882 return 1;
883
884 new_skb = sierra_net_skb_clone(dev, skb, hh.payload_len.word);
885 if (new_skb)
886 usbnet_skb_return(dev, new_skb);
887
888 } /* while */
889
890 return 0;
891}
892
893/* ---------------------------- Transmit data path ----------------------*/
894struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
895 gfp_t flags)
896{
897 struct sierra_net_data *priv = sierra_net_get_private(dev);
898 u16 len;
899 bool need_tail;
900
901 dev_dbg(&dev->udev->dev, "%s", __func__);
902 if (priv->link_up && check_ethip_packet(skb, dev) && is_ip(skb)) {
903 /* enough head room as is? */
904 if (SIERRA_NET_HIP_EXT_HDR_LEN <= skb_headroom(skb)) {
905 /* Save the Eth/IP length and set up HIP hdr */
906 len = skb->len;
907 skb_push(skb, SIERRA_NET_HIP_EXT_HDR_LEN);
908 /* Handle ZLP issue */
909 need_tail = ((len + SIERRA_NET_HIP_EXT_HDR_LEN)
910 % dev->maxpacket == 0);
911 if (need_tail) {
912 if (unlikely(skb_tailroom(skb) == 0)) {
913 netdev_err(dev->net, "tx_fixup:"
914 "no room for packet\n");
915 dev_kfree_skb_any(skb);
916 return NULL;
917 } else {
918 skb->data[skb->len] = 0;
919 __skb_put(skb, 1);
920 len = len + 1;
921 }
922 }
923 build_hip(skb->data, len, priv);
924 return skb;
925 } else {
926 /*
927 * compensate in the future if necessary
928 */
929 netdev_err(dev->net, "tx_fixup: no room for HIP\n");
930 } /* headroom */
931 }
932
933 if (!priv->link_up)
934 dev->net->stats.tx_carrier_errors++;
935
936 /* tx_dropped incremented by usbnet */
937
938 /* filter the packet out, release it */
939 dev_kfree_skb_any(skb);
940 return NULL;
941}
942
943static const u8 sierra_net_ifnum_list[] = { 7, 10, 11 };
944static const struct sierra_net_info_data sierra_net_info_data_68A3 = {
945 .rx_urb_size = 8 * 1024,
946 .whitelist = {
947 .infolen = ARRAY_SIZE(sierra_net_ifnum_list),
948 .ifaceinfo = sierra_net_ifnum_list
949 }
950};
951
952static const struct driver_info sierra_net_info_68A3 = {
953 .description = "Sierra Wireless USB-to-WWAN Modem",
954 .flags = FLAG_WWAN | FLAG_SEND_ZLP,
955 .bind = sierra_net_bind,
956 .unbind = sierra_net_unbind,
957 .status = sierra_net_status,
958 .rx_fixup = sierra_net_rx_fixup,
959 .tx_fixup = sierra_net_tx_fixup,
960 .data = (unsigned long)&sierra_net_info_data_68A3,
961};
962
963static const struct usb_device_id products[] = {
964 {USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless USB-to-WWAN modem */
965 .driver_info = (unsigned long) &sierra_net_info_68A3},
966
967 {}, /* last item */
968};
969MODULE_DEVICE_TABLE(usb, products);
970
971/* We are based on usbnet, so let it handle the USB driver specifics */
972static struct usb_driver sierra_net_driver = {
973 .name = "sierra_net",
974 .id_table = products,
975 .probe = usbnet_probe,
976 .disconnect = usbnet_disconnect,
977 .suspend = usbnet_suspend,
978 .resume = usbnet_resume,
979 .no_dynamic_id = 1,
980};
981
982static int __init sierra_net_init(void)
983{
984 BUILD_BUG_ON(FIELD_SIZEOF(struct usbnet, data)
985 < sizeof(struct cdc_state));
986
987 return usb_register(&sierra_net_driver);
988}
989
990static void __exit sierra_net_exit(void)
991{
992 usb_deregister(&sierra_net_driver);
993}
994
995module_exit(sierra_net_exit);
996module_init(sierra_net_init);
997
998MODULE_AUTHOR(DRIVER_AUTHOR);
999MODULE_DESCRIPTION(DRIVER_DESC);
1000MODULE_VERSION(DRIVER_VERSION);
1001MODULE_LICENSE("GPL");
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index c4844adff92a..92b3e64fc14d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -259,7 +259,7 @@ static struct iwl_lib_ops iwl6000_lib = {
259 EEPROM_5000_REG_BAND_3_CHANNELS, 259 EEPROM_5000_REG_BAND_3_CHANNELS,
260 EEPROM_5000_REG_BAND_4_CHANNELS, 260 EEPROM_5000_REG_BAND_4_CHANNELS,
261 EEPROM_5000_REG_BAND_5_CHANNELS, 261 EEPROM_5000_REG_BAND_5_CHANNELS,
262 EEPROM_5000_REG_BAND_24_HT40_CHANNELS, 262 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
263 EEPROM_5000_REG_BAND_52_HT40_CHANNELS 263 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
264 }, 264 },
265 .verify_signature = iwlcore_eeprom_verify_signature, 265 .verify_signature = iwlcore_eeprom_verify_signature,
@@ -323,7 +323,7 @@ static struct iwl_lib_ops iwl6050_lib = {
323 EEPROM_5000_REG_BAND_3_CHANNELS, 323 EEPROM_5000_REG_BAND_3_CHANNELS,
324 EEPROM_5000_REG_BAND_4_CHANNELS, 324 EEPROM_5000_REG_BAND_4_CHANNELS,
325 EEPROM_5000_REG_BAND_5_CHANNELS, 325 EEPROM_5000_REG_BAND_5_CHANNELS,
326 EEPROM_5000_REG_BAND_24_HT40_CHANNELS, 326 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
327 EEPROM_5000_REG_BAND_52_HT40_CHANNELS 327 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
328 }, 328 },
329 .verify_signature = iwlcore_eeprom_verify_signature, 329 .verify_signature = iwlcore_eeprom_verify_signature,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 8b8e3e1cbb44..bdff56583e11 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3331,6 +3331,7 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
3331 3331
3332 cancel_delayed_work_sync(&priv->init_alive_start); 3332 cancel_delayed_work_sync(&priv->init_alive_start);
3333 cancel_delayed_work(&priv->scan_check); 3333 cancel_delayed_work(&priv->scan_check);
3334 cancel_work_sync(&priv->start_internal_scan);
3334 cancel_delayed_work(&priv->alive_start); 3335 cancel_delayed_work(&priv->alive_start);
3335 cancel_work_sync(&priv->beacon_update); 3336 cancel_work_sync(&priv->beacon_update);
3336 del_timer_sync(&priv->statistics_periodic); 3337 del_timer_sync(&priv->statistics_periodic);
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 3352f7086632..049b652bcb5e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -3358,7 +3358,6 @@ static void iwl_force_rf_reset(struct iwl_priv *priv)
3358 */ 3358 */
3359 IWL_DEBUG_INFO(priv, "perform radio reset.\n"); 3359 IWL_DEBUG_INFO(priv, "perform radio reset.\n");
3360 iwl_internal_short_hw_scan(priv); 3360 iwl_internal_short_hw_scan(priv);
3361 return;
3362} 3361}
3363 3362
3364 3363
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 732590f5fe30..36940a9ec6b9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -506,7 +506,7 @@ void iwl_init_scan_params(struct iwl_priv *priv);
506int iwl_scan_cancel(struct iwl_priv *priv); 506int iwl_scan_cancel(struct iwl_priv *priv);
507int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 507int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
508int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); 508int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req);
509int iwl_internal_short_hw_scan(struct iwl_priv *priv); 509void iwl_internal_short_hw_scan(struct iwl_priv *priv);
510int iwl_force_reset(struct iwl_priv *priv, int mode); 510int iwl_force_reset(struct iwl_priv *priv, int mode);
511u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, 511u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
512 const u8 *ie, int ie_len, int left); 512 const u8 *ie, int ie_len, int left);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 6054c5fba0c1..ef1720a852e9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1296,6 +1296,7 @@ struct iwl_priv {
1296 struct work_struct tt_work; 1296 struct work_struct tt_work;
1297 struct work_struct ct_enter; 1297 struct work_struct ct_enter;
1298 struct work_struct ct_exit; 1298 struct work_struct ct_exit;
1299 struct work_struct start_internal_scan;
1299 1300
1300 struct tasklet_struct irq_tasklet; 1301 struct tasklet_struct irq_tasklet;
1301 1302
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 4e1ba824dc50..8171c701e4e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -203,6 +203,10 @@ struct iwl_eeprom_enhanced_txpwr {
203#define EEPROM_5000_REG_BAND_52_HT40_CHANNELS ((0x92)\ 203#define EEPROM_5000_REG_BAND_52_HT40_CHANNELS ((0x92)\
204 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */ 204 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */
205 205
206/* 6000 regulatory - indirect access */
207#define EEPROM_6000_REG_BAND_24_HT40_CHANNELS ((0x80)\
208 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 14 bytes */
209
206/* 6000 and up regulatory tx power - indirect access */ 210/* 6000 and up regulatory tx power - indirect access */
207/* max. elements per section */ 211/* max. elements per section */
208#define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8) 212#define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8)
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 9ab0e412bf10..12e455a4b90e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -470,6 +470,8 @@ EXPORT_SYMBOL(iwl_init_scan_params);
470 470
471static int iwl_scan_initiate(struct iwl_priv *priv) 471static int iwl_scan_initiate(struct iwl_priv *priv)
472{ 472{
473 WARN_ON(!mutex_is_locked(&priv->mutex));
474
473 IWL_DEBUG_INFO(priv, "Starting scan...\n"); 475 IWL_DEBUG_INFO(priv, "Starting scan...\n");
474 set_bit(STATUS_SCANNING, &priv->status); 476 set_bit(STATUS_SCANNING, &priv->status);
475 priv->is_internal_short_scan = false; 477 priv->is_internal_short_scan = false;
@@ -547,24 +549,31 @@ EXPORT_SYMBOL(iwl_mac_hw_scan);
547 * internal short scan, this function should only been called while associated. 549 * internal short scan, this function should only been called while associated.
548 * It will reset and tune the radio to prevent possible RF related problem 550 * It will reset and tune the radio to prevent possible RF related problem
549 */ 551 */
550int iwl_internal_short_hw_scan(struct iwl_priv *priv) 552void iwl_internal_short_hw_scan(struct iwl_priv *priv)
551{ 553{
552 int ret = 0; 554 queue_work(priv->workqueue, &priv->start_internal_scan);
555}
556
557static void iwl_bg_start_internal_scan(struct work_struct *work)
558{
559 struct iwl_priv *priv =
560 container_of(work, struct iwl_priv, start_internal_scan);
561
562 mutex_lock(&priv->mutex);
553 563
554 if (!iwl_is_ready_rf(priv)) { 564 if (!iwl_is_ready_rf(priv)) {
555 ret = -EIO;
556 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n"); 565 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n");
557 goto out; 566 goto unlock;
558 } 567 }
568
559 if (test_bit(STATUS_SCANNING, &priv->status)) { 569 if (test_bit(STATUS_SCANNING, &priv->status)) {
560 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 570 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
561 ret = -EAGAIN; 571 goto unlock;
562 goto out;
563 } 572 }
573
564 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 574 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
565 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n"); 575 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
566 ret = -EAGAIN; 576 goto unlock;
567 goto out;
568 } 577 }
569 578
570 priv->scan_bands = 0; 579 priv->scan_bands = 0;
@@ -577,9 +586,8 @@ int iwl_internal_short_hw_scan(struct iwl_priv *priv)
577 set_bit(STATUS_SCANNING, &priv->status); 586 set_bit(STATUS_SCANNING, &priv->status);
578 priv->is_internal_short_scan = true; 587 priv->is_internal_short_scan = true;
579 queue_work(priv->workqueue, &priv->request_scan); 588 queue_work(priv->workqueue, &priv->request_scan);
580 589 unlock:
581out: 590 mutex_unlock(&priv->mutex);
582 return ret;
583} 591}
584EXPORT_SYMBOL(iwl_internal_short_hw_scan); 592EXPORT_SYMBOL(iwl_internal_short_hw_scan);
585 593
@@ -965,6 +973,7 @@ void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
965 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 973 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
966 INIT_WORK(&priv->request_scan, iwl_bg_request_scan); 974 INIT_WORK(&priv->request_scan, iwl_bg_request_scan);
967 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 975 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
976 INIT_WORK(&priv->start_internal_scan, iwl_bg_start_internal_scan);
968 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); 977 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
969} 978}
970EXPORT_SYMBOL(iwl_setup_scan_deferred_work); 979EXPORT_SYMBOL(iwl_setup_scan_deferred_work);