aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-25 10:22:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-25 10:22:11 -0400
commit5c3cc2084dd9dc26b258f88abb629550090956e0 (patch)
tree78bad2d2f412e0700384268f065823879f8ef1da /drivers/net
parent851b147e4411df6a1e7e90e2a609773c277eefd2 (diff)
parentb8273570f802a7658827dcb077b0b517ba75a289 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (94 commits) genetlink: fix netns vs. netlink table locking (2) 3c59x: Get rid of "Trying to free already-free IRQ" tunnel: eliminate recursion field ems_pci: fix size of CAN controllers BAR mapping for CPC-PCI v2 net: fix htmldocs sunrpc, clnt.c Phonet: error on broadcast sending (unimplemented) Phonet: fix race for port number in concurrent bind() pktgen: better scheduler friendliness pktgen: T_TERMINATE flag is unused ipv4: check optlen for IP_MULTICAST_IF option ath9k: Initialize txgain and rxgain for newer AR9287 chipsets. iwlagn: fix panic in iwl{5000,4965}_rx_reply_tx ath9k: Fix RFKILL bugs drivers/net/wireless: Use usb_endpoint_dir_out cfg80211: don't overwrite privacy setting wl12xx: fix kconfig/link errors rt2x00: fix the definition of rt2x00crypto_rx_insert_iv iwlwifi: reduce noise when skb allocation fails iwlwifi: do not send sync command while holding spinlock mac80211: fix DTIM setting ...
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/3c59x.c12
-rw-r--r--drivers/net/8139cp.c2
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/atl1c/atl1c_main.c2
-rw-r--r--drivers/net/can/Kconfig13
-rw-r--r--drivers/net/can/Makefile3
-rw-r--r--drivers/net/can/sja1000/ems_pci.c16
-rw-r--r--drivers/net/can/usb/Makefile5
-rw-r--r--drivers/net/can/usb/ems_usb.c1155
-rw-r--r--drivers/net/cnic.c4
-rw-r--r--drivers/net/cpmac.c8
-rw-r--r--drivers/net/ehea/ehea_main.c1
-rw-r--r--drivers/net/igb/e1000_mac.c72
-rw-r--r--drivers/net/igb/e1000_mac.h1
-rw-r--r--drivers/net/ixgbe/ixgbe.h6
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c75
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c111
-rw-r--r--drivers/net/netxen/netxen_nic_main.c8
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c11
-rw-r--r--drivers/net/sky2.c4
-rw-r--r--drivers/net/sunvnet.c1
-rw-r--r--drivers/net/tun.c4
-rw-r--r--drivers/net/usb/kaweth.c18
-rw-r--r--drivers/net/usb/smsc95xx.c67
-rw-r--r--drivers/net/usb/usbnet.c2
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c23
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_def.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c202
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h4
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c16
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h3
-rw-r--r--drivers/net/wireless/b43/Kconfig21
-rw-r--r--drivers/net/wireless/b43/Makefile1
-rw-r--r--drivers/net/wireless/b43/b43.h23
-rw-r--r--drivers/net/wireless/b43/debugfs.c1
-rw-r--r--drivers/net/wireless/b43/debugfs.h1
-rw-r--r--drivers/net/wireless/b43/dma.c4
-rw-r--r--drivers/net/wireless/b43/leds.c266
-rw-r--r--drivers/net/wireless/b43/leds.h33
-rw-r--r--drivers/net/wireless/b43/main.c224
-rw-r--r--drivers/net/wireless/b43/phy_lp.c12
-rw-r--r--drivers/net/wireless/b43/pio.c2
-rw-r--r--drivers/net/wireless/b43/rfkill.c2
-rw-r--r--drivers/net/wireless/b43/sdio.c202
-rw-r--r--drivers/net/wireless/b43/sdio.h45
-rw-r--r--drivers/net/wireless/b43/xmit.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h2
-rw-r--r--drivers/net/wireless/wl12xx/Kconfig2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c2
-rw-r--r--drivers/net/xilinx_emaclite.c7
57 files changed, 2290 insertions, 456 deletions
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 7adff4d0960d..b9eeadf01b74 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -813,10 +813,10 @@ static int vortex_suspend(struct pci_dev *pdev, pm_message_t state)
813 if (netif_running(dev)) { 813 if (netif_running(dev)) {
814 netif_device_detach(dev); 814 netif_device_detach(dev);
815 vortex_down(dev, 1); 815 vortex_down(dev, 1);
816 disable_irq(dev->irq);
816 } 817 }
817 pci_save_state(pdev); 818 pci_save_state(pdev);
818 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); 819 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
819 free_irq(dev->irq, dev);
820 pci_disable_device(pdev); 820 pci_disable_device(pdev);
821 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 821 pci_set_power_state(pdev, pci_choose_state(pdev, state));
822 } 822 }
@@ -839,18 +839,12 @@ static int vortex_resume(struct pci_dev *pdev)
839 return err; 839 return err;
840 } 840 }
841 pci_set_master(pdev); 841 pci_set_master(pdev);
842 if (request_irq(dev->irq, vp->full_bus_master_rx ?
843 &boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev)) {
844 pr_warning("%s: Could not reserve IRQ %d\n", dev->name, dev->irq);
845 pci_disable_device(pdev);
846 return -EBUSY;
847 }
848 if (netif_running(dev)) { 842 if (netif_running(dev)) {
849 err = vortex_up(dev); 843 err = vortex_up(dev);
850 if (err) 844 if (err)
851 return err; 845 return err;
852 else 846 enable_irq(dev->irq);
853 netif_device_attach(dev); 847 netif_device_attach(dev);
854 } 848 }
855 } 849 }
856 return 0; 850 return 0;
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 462d9f59c53a..83a1922e68e0 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -87,7 +87,7 @@
87 87
88/* These identify the driver base version and may not be removed. */ 88/* These identify the driver base version and may not be removed. */
89static char version[] = 89static char version[] =
90KERN_INFO DRV_NAME ": 10/100 PCI Ethernet driver v" DRV_VERSION " (" DRV_RELDATE ")\n"; 90DRV_NAME ": 10/100 PCI Ethernet driver v" DRV_VERSION " (" DRV_RELDATE ")\n";
91 91
92MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>"); 92MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>");
93MODULE_DESCRIPTION("RealTek RTL-8139C+ series 10/100 PCI Ethernet driver"); 93MODULE_DESCRIPTION("RealTek RTL-8139C+ series 10/100 PCI Ethernet driver");
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ed5741b2e701..2bea67c134f0 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1875,7 +1875,7 @@ config 68360_ENET
1875 1875
1876config FEC 1876config FEC
1877 bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)" 1877 bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)"
1878 depends on M523x || M527x || M5272 || M528x || M520x || M532x || MACH_MX27 || ARCH_MX35 1878 depends on M523x || M527x || M5272 || M528x || M520x || M532x || MACH_MX27 || ARCH_MX35 || ARCH_MX25
1879 help 1879 help
1880 Say Y here if you want to use the built-in 10/100 Fast ethernet 1880 Say Y here if you want to use the built-in 10/100 Fast ethernet
1881 controller on some Motorola ColdFire and Freescale i.MX processors. 1881 controller on some Motorola ColdFire and Freescale i.MX processors.
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index be2c6cfe6e84..1372e9a99f5b 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -2296,7 +2296,7 @@ static int atl1c_suspend(struct pci_dev *pdev, pm_message_t state)
2296 u32 ctrl; 2296 u32 ctrl;
2297 u32 mac_ctrl_data; 2297 u32 mac_ctrl_data;
2298 u32 master_ctrl_data; 2298 u32 master_ctrl_data;
2299 u32 wol_ctrl_data; 2299 u32 wol_ctrl_data = 0;
2300 u16 mii_bmsr_data; 2300 u16 mii_bmsr_data;
2301 u16 save_autoneg_advertised; 2301 u16 save_autoneg_advertised;
2302 u16 mii_intr_status_data; 2302 u16 mii_intr_status_data;
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index 090074372462..df32c109b7ac 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -75,6 +75,13 @@ config CAN_EMS_PCI
75 CPC-PCIe and CPC-104P cards from EMS Dr. Thomas Wuensche 75 CPC-PCIe and CPC-104P cards from EMS Dr. Thomas Wuensche
76 (http://www.ems-wuensche.de). 76 (http://www.ems-wuensche.de).
77 77
78config CAN_EMS_USB
79 tristate "EMS CPC-USB/ARM7 CAN/USB interface"
80 depends on USB && CAN_DEV
81 ---help---
82 This driver is for the one channel CPC-USB/ARM7 CAN/USB interface
83 from from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de).
84
78config CAN_KVASER_PCI 85config CAN_KVASER_PCI
79 tristate "Kvaser PCIcanx and Kvaser PCIcan PCI Cards" 86 tristate "Kvaser PCIcanx and Kvaser PCIcan PCI Cards"
80 depends on PCI && CAN_SJA1000 87 depends on PCI && CAN_SJA1000
@@ -82,6 +89,12 @@ config CAN_KVASER_PCI
82 This driver is for the the PCIcanx and PCIcan cards (1, 2 or 89 This driver is for the the PCIcanx and PCIcan cards (1, 2 or
83 4 channel) from Kvaser (http://www.kvaser.com). 90 4 channel) from Kvaser (http://www.kvaser.com).
84 91
92config CAN_AT91
93 tristate "Atmel AT91 onchip CAN controller"
94 depends on CAN && CAN_DEV && ARCH_AT91SAM9263
95 ---help---
96 This is a driver for the SoC CAN controller in Atmel's AT91SAM9263.
97
85config CAN_DEBUG_DEVICES 98config CAN_DEBUG_DEVICES
86 bool "CAN devices debugging messages" 99 bool "CAN devices debugging messages"
87 depends on CAN 100 depends on CAN
diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile
index 523a941b358b..0dea62721f2f 100644
--- a/drivers/net/can/Makefile
+++ b/drivers/net/can/Makefile
@@ -7,6 +7,9 @@ obj-$(CONFIG_CAN_VCAN) += vcan.o
7obj-$(CONFIG_CAN_DEV) += can-dev.o 7obj-$(CONFIG_CAN_DEV) += can-dev.o
8can-dev-y := dev.o 8can-dev-y := dev.o
9 9
10obj-y += usb/
11
10obj-$(CONFIG_CAN_SJA1000) += sja1000/ 12obj-$(CONFIG_CAN_SJA1000) += sja1000/
13obj-$(CONFIG_CAN_AT91) += at91_can.o
11 14
12ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG 15ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 7d84b8ac9c1c..fd04789d3370 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -94,12 +94,14 @@ struct ems_pci_card {
94#define EMS_PCI_CDR (CDR_CBP | CDR_CLKOUT_MASK) 94#define EMS_PCI_CDR (CDR_CBP | CDR_CLKOUT_MASK)
95 95
96#define EMS_PCI_V1_BASE_BAR 1 96#define EMS_PCI_V1_BASE_BAR 1
97#define EMS_PCI_V1_MEM_SIZE 4096 97#define EMS_PCI_V1_CONF_SIZE 4096 /* size of PITA control area */
98#define EMS_PCI_V2_BASE_BAR 2 98#define EMS_PCI_V2_BASE_BAR 2
99#define EMS_PCI_V2_MEM_SIZE 128 99#define EMS_PCI_V2_CONF_SIZE 128 /* size of PLX control area */
100#define EMS_PCI_CAN_BASE_OFFSET 0x400 /* offset where the controllers starts */ 100#define EMS_PCI_CAN_BASE_OFFSET 0x400 /* offset where the controllers starts */
101#define EMS_PCI_CAN_CTRL_SIZE 0x200 /* memory size for each controller */ 101#define EMS_PCI_CAN_CTRL_SIZE 0x200 /* memory size for each controller */
102 102
103#define EMS_PCI_BASE_SIZE 4096 /* size of controller area */
104
103static struct pci_device_id ems_pci_tbl[] = { 105static struct pci_device_id ems_pci_tbl[] = {
104 /* CPC-PCI v1 */ 106 /* CPC-PCI v1 */
105 {PCI_VENDOR_ID_SIEMENS, 0x2104, PCI_ANY_ID, PCI_ANY_ID,}, 107 {PCI_VENDOR_ID_SIEMENS, 0x2104, PCI_ANY_ID, PCI_ANY_ID,},
@@ -224,7 +226,7 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev,
224 struct sja1000_priv *priv; 226 struct sja1000_priv *priv;
225 struct net_device *dev; 227 struct net_device *dev;
226 struct ems_pci_card *card; 228 struct ems_pci_card *card;
227 int max_chan, mem_size, base_bar; 229 int max_chan, conf_size, base_bar;
228 int err, i; 230 int err, i;
229 231
230 /* Enabling PCI device */ 232 /* Enabling PCI device */
@@ -251,22 +253,22 @@ static int __devinit ems_pci_add_card(struct pci_dev *pdev,
251 card->version = 2; /* CPC-PCI v2 */ 253 card->version = 2; /* CPC-PCI v2 */
252 max_chan = EMS_PCI_V2_MAX_CHAN; 254 max_chan = EMS_PCI_V2_MAX_CHAN;
253 base_bar = EMS_PCI_V2_BASE_BAR; 255 base_bar = EMS_PCI_V2_BASE_BAR;
254 mem_size = EMS_PCI_V2_MEM_SIZE; 256 conf_size = EMS_PCI_V2_CONF_SIZE;
255 } else { 257 } else {
256 card->version = 1; /* CPC-PCI v1 */ 258 card->version = 1; /* CPC-PCI v1 */
257 max_chan = EMS_PCI_V1_MAX_CHAN; 259 max_chan = EMS_PCI_V1_MAX_CHAN;
258 base_bar = EMS_PCI_V1_BASE_BAR; 260 base_bar = EMS_PCI_V1_BASE_BAR;
259 mem_size = EMS_PCI_V1_MEM_SIZE; 261 conf_size = EMS_PCI_V1_CONF_SIZE;
260 } 262 }
261 263
262 /* Remap configuration space and controller memory area */ 264 /* Remap configuration space and controller memory area */
263 card->conf_addr = pci_iomap(pdev, 0, mem_size); 265 card->conf_addr = pci_iomap(pdev, 0, conf_size);
264 if (card->conf_addr == NULL) { 266 if (card->conf_addr == NULL) {
265 err = -ENOMEM; 267 err = -ENOMEM;
266 goto failure_cleanup; 268 goto failure_cleanup;
267 } 269 }
268 270
269 card->base_addr = pci_iomap(pdev, base_bar, mem_size); 271 card->base_addr = pci_iomap(pdev, base_bar, EMS_PCI_BASE_SIZE);
270 if (card->base_addr == NULL) { 272 if (card->base_addr == NULL) {
271 err = -ENOMEM; 273 err = -ENOMEM;
272 goto failure_cleanup; 274 goto failure_cleanup;
diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
new file mode 100644
index 000000000000..c3f75ba701b1
--- /dev/null
+++ b/drivers/net/can/usb/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the Linux Controller Area Network USB drivers.
3#
4
5obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
new file mode 100644
index 000000000000..9012e0abc626
--- /dev/null
+++ b/drivers/net/can/usb/ems_usb.c
@@ -0,0 +1,1155 @@
1/*
2 * CAN driver for EMS Dr. Thomas Wuensche CPC-USB/ARM7
3 *
4 * Copyright (C) 2004-2009 EMS Dr. Thomas Wuensche
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19#include <linux/init.h>
20#include <linux/signal.h>
21#include <linux/slab.h>
22#include <linux/module.h>
23#include <linux/netdevice.h>
24#include <linux/usb.h>
25
26#include <linux/can.h>
27#include <linux/can/dev.h>
28#include <linux/can/error.h>
29
30MODULE_AUTHOR("Sebastian Haas <haas@ems-wuensche.com>");
31MODULE_DESCRIPTION("CAN driver for EMS Dr. Thomas Wuensche CAN/USB interfaces");
32MODULE_LICENSE("GPL v2");
33
34/* Control-Values for CPC_Control() Command Subject Selection */
35#define CONTR_CAN_MESSAGE 0x04
36#define CONTR_CAN_STATE 0x0C
37#define CONTR_BUS_ERROR 0x1C
38
39/* Control Command Actions */
40#define CONTR_CONT_OFF 0
41#define CONTR_CONT_ON 1
42#define CONTR_ONCE 2
43
44/* Messages from CPC to PC */
45#define CPC_MSG_TYPE_CAN_FRAME 1 /* CAN data frame */
46#define CPC_MSG_TYPE_RTR_FRAME 8 /* CAN remote frame */
47#define CPC_MSG_TYPE_CAN_PARAMS 12 /* Actual CAN parameters */
48#define CPC_MSG_TYPE_CAN_STATE 14 /* CAN state message */
49#define CPC_MSG_TYPE_EXT_CAN_FRAME 16 /* Extended CAN data frame */
50#define CPC_MSG_TYPE_EXT_RTR_FRAME 17 /* Extended remote frame */
51#define CPC_MSG_TYPE_CONTROL 19 /* change interface behavior */
52#define CPC_MSG_TYPE_CONFIRM 20 /* command processed confirmation */
53#define CPC_MSG_TYPE_OVERRUN 21 /* overrun events */
54#define CPC_MSG_TYPE_CAN_FRAME_ERROR 23 /* detected bus errors */
55#define CPC_MSG_TYPE_ERR_COUNTER 25 /* RX/TX error counter */
56
57/* Messages from the PC to the CPC interface */
58#define CPC_CMD_TYPE_CAN_FRAME 1 /* CAN data frame */
59#define CPC_CMD_TYPE_CONTROL 3 /* control of interface behavior */
60#define CPC_CMD_TYPE_CAN_PARAMS 6 /* set CAN parameters */
61#define CPC_CMD_TYPE_RTR_FRAME 13 /* CAN remote frame */
62#define CPC_CMD_TYPE_CAN_STATE 14 /* CAN state message */
63#define CPC_CMD_TYPE_EXT_CAN_FRAME 15 /* Extended CAN data frame */
64#define CPC_CMD_TYPE_EXT_RTR_FRAME 16 /* Extended CAN remote frame */
65#define CPC_CMD_TYPE_CAN_EXIT 200 /* exit the CAN */
66
67#define CPC_CMD_TYPE_INQ_ERR_COUNTER 25 /* request the CAN error counters */
68#define CPC_CMD_TYPE_CLEAR_MSG_QUEUE 8 /* clear CPC_MSG queue */
69#define CPC_CMD_TYPE_CLEAR_CMD_QUEUE 28 /* clear CPC_CMD queue */
70
71#define CPC_CC_TYPE_SJA1000 2 /* Philips basic CAN controller */
72
73#define CPC_CAN_ECODE_ERRFRAME 0x01 /* Ecode type */
74
75/* Overrun types */
76#define CPC_OVR_EVENT_CAN 0x01
77#define CPC_OVR_EVENT_CANSTATE 0x02
78#define CPC_OVR_EVENT_BUSERROR 0x04
79
80/*
81 * If the CAN controller lost a message we indicate it with the highest bit
82 * set in the count field.
83 */
84#define CPC_OVR_HW 0x80
85
86/* Size of the "struct ems_cpc_msg" without the union */
87#define CPC_MSG_HEADER_LEN 11
88#define CPC_CAN_MSG_MIN_SIZE 5
89
90/* Define these values to match your devices */
91#define USB_CPCUSB_VENDOR_ID 0x12D6
92
93#define USB_CPCUSB_ARM7_PRODUCT_ID 0x0444
94
95/* Mode register NXP LPC2119/SJA1000 CAN Controller */
96#define SJA1000_MOD_NORMAL 0x00
97#define SJA1000_MOD_RM 0x01
98
99/* ECC register NXP LPC2119/SJA1000 CAN Controller */
100#define SJA1000_ECC_SEG 0x1F
101#define SJA1000_ECC_DIR 0x20
102#define SJA1000_ECC_ERR 0x06
103#define SJA1000_ECC_BIT 0x00
104#define SJA1000_ECC_FORM 0x40
105#define SJA1000_ECC_STUFF 0x80
106#define SJA1000_ECC_MASK 0xc0
107
108/* Status register content */
109#define SJA1000_SR_BS 0x80
110#define SJA1000_SR_ES 0x40
111
112#define SJA1000_DEFAULT_OUTPUT_CONTROL 0xDA
113
114/*
115 * The device actually uses a 16MHz clock to generate the CAN clock
116 * but it expects SJA1000 bit settings based on 8MHz (is internally
117 * converted).
118 */
119#define EMS_USB_ARM7_CLOCK 8000000
120
121/*
122 * CAN-Message representation in a CPC_MSG. Message object type is
123 * CPC_MSG_TYPE_CAN_FRAME or CPC_MSG_TYPE_RTR_FRAME or
124 * CPC_MSG_TYPE_EXT_CAN_FRAME or CPC_MSG_TYPE_EXT_RTR_FRAME.
125 */
126struct cpc_can_msg {
127 u32 id;
128 u8 length;
129 u8 msg[8];
130};
131
132/* Representation of the CAN parameters for the SJA1000 controller */
133struct cpc_sja1000_params {
134 u8 mode;
135 u8 acc_code0;
136 u8 acc_code1;
137 u8 acc_code2;
138 u8 acc_code3;
139 u8 acc_mask0;
140 u8 acc_mask1;
141 u8 acc_mask2;
142 u8 acc_mask3;
143 u8 btr0;
144 u8 btr1;
145 u8 outp_contr;
146};
147
148/* CAN params message representation */
149struct cpc_can_params {
150 u8 cc_type;
151
152 /* Will support M16C CAN controller in the future */
153 union {
154 struct cpc_sja1000_params sja1000;
155 } cc_params;
156};
157
158/* Structure for confirmed message handling */
159struct cpc_confirm {
160 u8 error; /* error code */
161};
162
163/* Structure for overrun conditions */
164struct cpc_overrun {
165 u8 event;
166 u8 count;
167};
168
169/* SJA1000 CAN errors (compatible to NXP LPC2119) */
170struct cpc_sja1000_can_error {
171 u8 ecc;
172 u8 rxerr;
173 u8 txerr;
174};
175
176/* structure for CAN error conditions */
177struct cpc_can_error {
178 u8 ecode;
179
180 struct {
181 u8 cc_type;
182
183 /* Other controllers may also provide error code capture regs */
184 union {
185 struct cpc_sja1000_can_error sja1000;
186 } regs;
187 } cc;
188};
189
190/*
191 * Structure containing RX/TX error counter. This structure is used to request
192 * the values of the CAN controllers TX and RX error counter.
193 */
194struct cpc_can_err_counter {
195 u8 rx;
196 u8 tx;
197};
198
199/* Main message type used between library and application */
200struct __attribute__ ((packed)) ems_cpc_msg {
201 u8 type; /* type of message */
202 u8 length; /* length of data within union 'msg' */
203 u8 msgid; /* confirmation handle */
204 u32 ts_sec; /* timestamp in seconds */
205 u32 ts_nsec; /* timestamp in nano seconds */
206
207 union {
208 u8 generic[64];
209 struct cpc_can_msg can_msg;
210 struct cpc_can_params can_params;
211 struct cpc_confirm confirmation;
212 struct cpc_overrun overrun;
213 struct cpc_can_error error;
214 struct cpc_can_err_counter err_counter;
215 u8 can_state;
216 } msg;
217};
218
219/*
220 * Table of devices that work with this driver
221 * NOTE: This driver supports only CPC-USB/ARM7 (LPC2119) yet.
222 */
223static struct usb_device_id ems_usb_table[] = {
224 {USB_DEVICE(USB_CPCUSB_VENDOR_ID, USB_CPCUSB_ARM7_PRODUCT_ID)},
225 {} /* Terminating entry */
226};
227
228MODULE_DEVICE_TABLE(usb, ems_usb_table);
229
230#define RX_BUFFER_SIZE 64
231#define CPC_HEADER_SIZE 4
232#define INTR_IN_BUFFER_SIZE 4
233
234#define MAX_RX_URBS 10
235#define MAX_TX_URBS CAN_ECHO_SKB_MAX
236
237struct ems_usb;
238
239struct ems_tx_urb_context {
240 struct ems_usb *dev;
241
242 u32 echo_index;
243 u8 dlc;
244};
245
246struct ems_usb {
247 struct can_priv can; /* must be the first member */
248 int open_time;
249
250 struct sk_buff *echo_skb[MAX_TX_URBS];
251
252 struct usb_device *udev;
253 struct net_device *netdev;
254
255 atomic_t active_tx_urbs;
256 struct usb_anchor tx_submitted;
257 struct ems_tx_urb_context tx_contexts[MAX_TX_URBS];
258
259 struct usb_anchor rx_submitted;
260
261 struct urb *intr_urb;
262
263 u8 *tx_msg_buffer;
264
265 u8 *intr_in_buffer;
266 unsigned int free_slots; /* remember number of available slots */
267
268 struct ems_cpc_msg active_params; /* active controller parameters */
269};
270
271static void ems_usb_read_interrupt_callback(struct urb *urb)
272{
273 struct ems_usb *dev = urb->context;
274 struct net_device *netdev = dev->netdev;
275 int err;
276
277 if (!netif_device_present(netdev))
278 return;
279
280 switch (urb->status) {
281 case 0:
282 dev->free_slots = dev->intr_in_buffer[1];
283 break;
284
285 case -ECONNRESET: /* unlink */
286 case -ENOENT:
287 case -ESHUTDOWN:
288 return;
289
290 default:
291 dev_info(netdev->dev.parent, "Rx interrupt aborted %d\n",
292 urb->status);
293 break;
294 }
295
296 err = usb_submit_urb(urb, GFP_ATOMIC);
297
298 if (err == -ENODEV)
299 netif_device_detach(netdev);
300 else if (err)
301 dev_err(netdev->dev.parent,
302 "failed resubmitting intr urb: %d\n", err);
303
304 return;
305}
306
307static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
308{
309 struct can_frame *cf;
310 struct sk_buff *skb;
311 int i;
312 struct net_device_stats *stats = &dev->netdev->stats;
313
314 skb = netdev_alloc_skb(dev->netdev, sizeof(struct can_frame));
315 if (skb == NULL)
316 return;
317
318 skb->protocol = htons(ETH_P_CAN);
319
320 cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
321
322 cf->can_id = msg->msg.can_msg.id;
323 cf->can_dlc = min_t(u8, msg->msg.can_msg.length, 8);
324
325 if (msg->type == CPC_MSG_TYPE_EXT_CAN_FRAME
326 || msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME)
327 cf->can_id |= CAN_EFF_FLAG;
328
329 if (msg->type == CPC_MSG_TYPE_RTR_FRAME
330 || msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME) {
331 cf->can_id |= CAN_RTR_FLAG;
332 } else {
333 for (i = 0; i < cf->can_dlc; i++)
334 cf->data[i] = msg->msg.can_msg.msg[i];
335 }
336
337 netif_rx(skb);
338
339 stats->rx_packets++;
340 stats->rx_bytes += cf->can_dlc;
341}
342
343static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg)
344{
345 struct can_frame *cf;
346 struct sk_buff *skb;
347 struct net_device_stats *stats = &dev->netdev->stats;
348
349 skb = netdev_alloc_skb(dev->netdev, sizeof(struct can_frame));
350 if (skb == NULL)
351 return;
352
353 skb->protocol = htons(ETH_P_CAN);
354
355 cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
356 memset(cf, 0, sizeof(struct can_frame));
357
358 cf->can_id = CAN_ERR_FLAG;
359 cf->can_dlc = CAN_ERR_DLC;
360
361 if (msg->type == CPC_MSG_TYPE_CAN_STATE) {
362 u8 state = msg->msg.can_state;
363
364 if (state & SJA1000_SR_BS) {
365 dev->can.state = CAN_STATE_BUS_OFF;
366 cf->can_id |= CAN_ERR_BUSOFF;
367
368 can_bus_off(dev->netdev);
369 } else if (state & SJA1000_SR_ES) {
370 dev->can.state = CAN_STATE_ERROR_WARNING;
371 dev->can.can_stats.error_warning++;
372 } else {
373 dev->can.state = CAN_STATE_ERROR_ACTIVE;
374 dev->can.can_stats.error_passive++;
375 }
376 } else if (msg->type == CPC_MSG_TYPE_CAN_FRAME_ERROR) {
377 u8 ecc = msg->msg.error.cc.regs.sja1000.ecc;
378 u8 txerr = msg->msg.error.cc.regs.sja1000.txerr;
379 u8 rxerr = msg->msg.error.cc.regs.sja1000.rxerr;
380
381 /* bus error interrupt */
382 dev->can.can_stats.bus_error++;
383 stats->rx_errors++;
384
385 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
386
387 switch (ecc & SJA1000_ECC_MASK) {
388 case SJA1000_ECC_BIT:
389 cf->data[2] |= CAN_ERR_PROT_BIT;
390 break;
391 case SJA1000_ECC_FORM:
392 cf->data[2] |= CAN_ERR_PROT_FORM;
393 break;
394 case SJA1000_ECC_STUFF:
395 cf->data[2] |= CAN_ERR_PROT_STUFF;
396 break;
397 default:
398 cf->data[2] |= CAN_ERR_PROT_UNSPEC;
399 cf->data[3] = ecc & SJA1000_ECC_SEG;
400 break;
401 }
402
403 /* Error occured during transmission? */
404 if ((ecc & SJA1000_ECC_DIR) == 0)
405 cf->data[2] |= CAN_ERR_PROT_TX;
406
407 if (dev->can.state == CAN_STATE_ERROR_WARNING ||
408 dev->can.state == CAN_STATE_ERROR_PASSIVE) {
409 cf->data[1] = (txerr > rxerr) ?
410 CAN_ERR_CRTL_TX_PASSIVE : CAN_ERR_CRTL_RX_PASSIVE;
411 }
412 } else if (msg->type == CPC_MSG_TYPE_OVERRUN) {
413 cf->can_id |= CAN_ERR_CRTL;
414 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
415
416 stats->rx_over_errors++;
417 stats->rx_errors++;
418 }
419
420 netif_rx(skb);
421
422 stats->rx_packets++;
423 stats->rx_bytes += cf->can_dlc;
424}
425
426/*
427 * callback for bulk IN urb
428 */
429static void ems_usb_read_bulk_callback(struct urb *urb)
430{
431 struct ems_usb *dev = urb->context;
432 struct net_device *netdev;
433 int retval;
434
435 netdev = dev->netdev;
436
437 if (!netif_device_present(netdev))
438 return;
439
440 switch (urb->status) {
441 case 0: /* success */
442 break;
443
444 case -ENOENT:
445 return;
446
447 default:
448 dev_info(netdev->dev.parent, "Rx URB aborted (%d)\n",
449 urb->status);
450 goto resubmit_urb;
451 }
452
453 if (urb->actual_length > CPC_HEADER_SIZE) {
454 struct ems_cpc_msg *msg;
455 u8 *ibuf = urb->transfer_buffer;
456 u8 msg_count, again, start;
457
458 msg_count = ibuf[0] & ~0x80;
459 again = ibuf[0] & 0x80;
460
461 start = CPC_HEADER_SIZE;
462
463 while (msg_count) {
464 msg = (struct ems_cpc_msg *)&ibuf[start];
465
466 switch (msg->type) {
467 case CPC_MSG_TYPE_CAN_STATE:
468 /* Process CAN state changes */
469 ems_usb_rx_err(dev, msg);
470 break;
471
472 case CPC_MSG_TYPE_CAN_FRAME:
473 case CPC_MSG_TYPE_EXT_CAN_FRAME:
474 case CPC_MSG_TYPE_RTR_FRAME:
475 case CPC_MSG_TYPE_EXT_RTR_FRAME:
476 ems_usb_rx_can_msg(dev, msg);
477 break;
478
479 case CPC_MSG_TYPE_CAN_FRAME_ERROR:
480 /* Process errorframe */
481 ems_usb_rx_err(dev, msg);
482 break;
483
484 case CPC_MSG_TYPE_OVERRUN:
485 /* Message lost while receiving */
486 ems_usb_rx_err(dev, msg);
487 break;
488 }
489
490 start += CPC_MSG_HEADER_LEN + msg->length;
491 msg_count--;
492
493 if (start > urb->transfer_buffer_length) {
494 dev_err(netdev->dev.parent, "format error\n");
495 break;
496 }
497 }
498 }
499
500resubmit_urb:
501 usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2),
502 urb->transfer_buffer, RX_BUFFER_SIZE,
503 ems_usb_read_bulk_callback, dev);
504
505 retval = usb_submit_urb(urb, GFP_ATOMIC);
506
507 if (retval == -ENODEV)
508 netif_device_detach(netdev);
509 else if (retval)
510 dev_err(netdev->dev.parent,
511 "failed resubmitting read bulk urb: %d\n", retval);
512
513 return;
514}
515
516/*
517 * callback for bulk IN urb
518 */
519static void ems_usb_write_bulk_callback(struct urb *urb)
520{
521 struct ems_tx_urb_context *context = urb->context;
522 struct ems_usb *dev;
523 struct net_device *netdev;
524
525 BUG_ON(!context);
526
527 dev = context->dev;
528 netdev = dev->netdev;
529
530 /* free up our allocated buffer */
531 usb_buffer_free(urb->dev, urb->transfer_buffer_length,
532 urb->transfer_buffer, urb->transfer_dma);
533
534 atomic_dec(&dev->active_tx_urbs);
535
536 if (!netif_device_present(netdev))
537 return;
538
539 if (urb->status)
540 dev_info(netdev->dev.parent, "Tx URB aborted (%d)\n",
541 urb->status);
542
543 netdev->trans_start = jiffies;
544
545 /* transmission complete interrupt */
546 netdev->stats.tx_packets++;
547 netdev->stats.tx_bytes += context->dlc;
548
549 can_get_echo_skb(netdev, context->echo_index);
550
551 /* Release context */
552 context->echo_index = MAX_TX_URBS;
553
554 if (netif_queue_stopped(netdev))
555 netif_wake_queue(netdev);
556}
557
558/*
559 * Send the given CPC command synchronously
560 */
561static int ems_usb_command_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
562{
563 int actual_length;
564
565 /* Copy payload */
566 memcpy(&dev->tx_msg_buffer[CPC_HEADER_SIZE], msg,
567 msg->length + CPC_MSG_HEADER_LEN);
568
569 /* Clear header */
570 memset(&dev->tx_msg_buffer[0], 0, CPC_HEADER_SIZE);
571
572 return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2),
573 &dev->tx_msg_buffer[0],
574 msg->length + CPC_MSG_HEADER_LEN + CPC_HEADER_SIZE,
575 &actual_length, 1000);
576}
577
578/*
579 * Change CAN controllers' mode register
580 */
581static int ems_usb_write_mode(struct ems_usb *dev, u8 mode)
582{
583 dev->active_params.msg.can_params.cc_params.sja1000.mode = mode;
584
585 return ems_usb_command_msg(dev, &dev->active_params);
586}
587
588/*
589 * Send a CPC_Control command to change behaviour when interface receives a CAN
590 * message, bus error or CAN state changed notifications.
591 */
592static int ems_usb_control_cmd(struct ems_usb *dev, u8 val)
593{
594 struct ems_cpc_msg cmd;
595
596 cmd.type = CPC_CMD_TYPE_CONTROL;
597 cmd.length = CPC_MSG_HEADER_LEN + 1;
598
599 cmd.msgid = 0;
600
601 cmd.msg.generic[0] = val;
602
603 return ems_usb_command_msg(dev, &cmd);
604}
605
606/*
607 * Start interface
608 */
609static int ems_usb_start(struct ems_usb *dev)
610{
611 struct net_device *netdev = dev->netdev;
612 int err, i;
613
614 dev->intr_in_buffer[0] = 0;
615 dev->free_slots = 15; /* initial size */
616
617 for (i = 0; i < MAX_RX_URBS; i++) {
618 struct urb *urb = NULL;
619 u8 *buf = NULL;
620
621 /* create a URB, and a buffer for it */
622 urb = usb_alloc_urb(0, GFP_KERNEL);
623 if (!urb) {
624 dev_err(netdev->dev.parent,
625 "No memory left for URBs\n");
626 return -ENOMEM;
627 }
628
629 buf = usb_buffer_alloc(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL,
630 &urb->transfer_dma);
631 if (!buf) {
632 dev_err(netdev->dev.parent,
633 "No memory left for USB buffer\n");
634 usb_free_urb(urb);
635 return -ENOMEM;
636 }
637
638 usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2),
639 buf, RX_BUFFER_SIZE,
640 ems_usb_read_bulk_callback, dev);
641 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
642 usb_anchor_urb(urb, &dev->rx_submitted);
643
644 err = usb_submit_urb(urb, GFP_KERNEL);
645 if (err) {
646 if (err == -ENODEV)
647 netif_device_detach(dev->netdev);
648
649 usb_unanchor_urb(urb);
650 usb_buffer_free(dev->udev, RX_BUFFER_SIZE, buf,
651 urb->transfer_dma);
652 break;
653 }
654
655 /* Drop reference, USB core will take care of freeing it */
656 usb_free_urb(urb);
657 }
658
659 /* Did we submit any URBs */
660 if (i == 0) {
661 dev_warn(netdev->dev.parent, "couldn't setup read URBs\n");
662 return err;
663 }
664
665 /* Warn if we've couldn't transmit all the URBs */
666 if (i < MAX_RX_URBS)
667 dev_warn(netdev->dev.parent, "rx performance may be slow\n");
668
669 /* Setup and start interrupt URB */
670 usb_fill_int_urb(dev->intr_urb, dev->udev,
671 usb_rcvintpipe(dev->udev, 1),
672 dev->intr_in_buffer,
673 INTR_IN_BUFFER_SIZE,
674 ems_usb_read_interrupt_callback, dev, 1);
675
676 err = usb_submit_urb(dev->intr_urb, GFP_KERNEL);
677 if (err) {
678 if (err == -ENODEV)
679 netif_device_detach(dev->netdev);
680
681 dev_warn(netdev->dev.parent, "intr URB submit failed: %d\n",
682 err);
683
684 return err;
685 }
686
687 /* CPC-USB will transfer received message to host */
688 err = ems_usb_control_cmd(dev, CONTR_CAN_MESSAGE | CONTR_CONT_ON);
689 if (err)
690 goto failed;
691
692 /* CPC-USB will transfer CAN state changes to host */
693 err = ems_usb_control_cmd(dev, CONTR_CAN_STATE | CONTR_CONT_ON);
694 if (err)
695 goto failed;
696
697 /* CPC-USB will transfer bus errors to host */
698 err = ems_usb_control_cmd(dev, CONTR_BUS_ERROR | CONTR_CONT_ON);
699 if (err)
700 goto failed;
701
702 err = ems_usb_write_mode(dev, SJA1000_MOD_NORMAL);
703 if (err)
704 goto failed;
705
706 dev->can.state = CAN_STATE_ERROR_ACTIVE;
707
708 return 0;
709
710failed:
711 if (err == -ENODEV)
712 netif_device_detach(dev->netdev);
713
714 dev_warn(netdev->dev.parent, "couldn't submit control: %d\n", err);
715
716 return err;
717}
718
719static void unlink_all_urbs(struct ems_usb *dev)
720{
721 int i;
722
723 usb_unlink_urb(dev->intr_urb);
724
725 usb_kill_anchored_urbs(&dev->rx_submitted);
726
727 usb_kill_anchored_urbs(&dev->tx_submitted);
728 atomic_set(&dev->active_tx_urbs, 0);
729
730 for (i = 0; i < MAX_TX_URBS; i++)
731 dev->tx_contexts[i].echo_index = MAX_TX_URBS;
732}
733
734static int ems_usb_open(struct net_device *netdev)
735{
736 struct ems_usb *dev = netdev_priv(netdev);
737 int err;
738
739 err = ems_usb_write_mode(dev, SJA1000_MOD_RM);
740 if (err)
741 return err;
742
743 /* common open */
744 err = open_candev(netdev);
745 if (err)
746 return err;
747
748 /* finally start device */
749 err = ems_usb_start(dev);
750 if (err) {
751 if (err == -ENODEV)
752 netif_device_detach(dev->netdev);
753
754 dev_warn(netdev->dev.parent, "couldn't start device: %d\n",
755 err);
756
757 close_candev(netdev);
758
759 return err;
760 }
761
762 dev->open_time = jiffies;
763
764 netif_start_queue(netdev);
765
766 return 0;
767}
768
769static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *netdev)
770{
771 struct ems_usb *dev = netdev_priv(netdev);
772 struct ems_tx_urb_context *context = NULL;
773 struct net_device_stats *stats = &netdev->stats;
774 struct can_frame *cf = (struct can_frame *)skb->data;
775 struct ems_cpc_msg *msg;
776 struct urb *urb;
777 u8 *buf;
778 int i, err;
779 size_t size = CPC_HEADER_SIZE + CPC_MSG_HEADER_LEN
780 + sizeof(struct cpc_can_msg);
781
782 /* create a URB, and a buffer for it, and copy the data to the URB */
783 urb = usb_alloc_urb(0, GFP_ATOMIC);
784 if (!urb) {
785 dev_err(netdev->dev.parent, "No memory left for URBs\n");
786 goto nomem;
787 }
788
789 buf = usb_buffer_alloc(dev->udev, size, GFP_ATOMIC, &urb->transfer_dma);
790 if (!buf) {
791 dev_err(netdev->dev.parent, "No memory left for USB buffer\n");
792 usb_free_urb(urb);
793 goto nomem;
794 }
795
796 msg = (struct ems_cpc_msg *)&buf[CPC_HEADER_SIZE];
797
798 msg->msg.can_msg.id = cf->can_id & CAN_ERR_MASK;
799 msg->msg.can_msg.length = cf->can_dlc;
800
801 if (cf->can_id & CAN_RTR_FLAG) {
802 msg->type = cf->can_id & CAN_EFF_FLAG ?
803 CPC_CMD_TYPE_EXT_RTR_FRAME : CPC_CMD_TYPE_RTR_FRAME;
804
805 msg->length = CPC_CAN_MSG_MIN_SIZE;
806 } else {
807 msg->type = cf->can_id & CAN_EFF_FLAG ?
808 CPC_CMD_TYPE_EXT_CAN_FRAME : CPC_CMD_TYPE_CAN_FRAME;
809
810 for (i = 0; i < cf->can_dlc; i++)
811 msg->msg.can_msg.msg[i] = cf->data[i];
812
813 msg->length = CPC_CAN_MSG_MIN_SIZE + cf->can_dlc;
814 }
815
816 for (i = 0; i < MAX_TX_URBS; i++) {
817 if (dev->tx_contexts[i].echo_index == MAX_TX_URBS) {
818 context = &dev->tx_contexts[i];
819 break;
820 }
821 }
822
823 /*
824 * May never happen! When this happens we'd more URBs in flight as
825 * allowed (MAX_TX_URBS).
826 */
827 if (!context) {
828 usb_unanchor_urb(urb);
829 usb_buffer_free(dev->udev, size, buf, urb->transfer_dma);
830
831 dev_warn(netdev->dev.parent, "couldn't find free context\n");
832
833 return NETDEV_TX_BUSY;
834 }
835
836 context->dev = dev;
837 context->echo_index = i;
838 context->dlc = cf->can_dlc;
839
840 usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), buf,
841 size, ems_usb_write_bulk_callback, context);
842 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
843 usb_anchor_urb(urb, &dev->tx_submitted);
844
845 can_put_echo_skb(skb, netdev, context->echo_index);
846
847 atomic_inc(&dev->active_tx_urbs);
848
849 err = usb_submit_urb(urb, GFP_ATOMIC);
850 if (unlikely(err)) {
851 can_free_echo_skb(netdev, context->echo_index);
852
853 usb_unanchor_urb(urb);
854 usb_buffer_free(dev->udev, size, buf, urb->transfer_dma);
855 dev_kfree_skb(skb);
856
857 atomic_dec(&dev->active_tx_urbs);
858
859 if (err == -ENODEV) {
860 netif_device_detach(netdev);
861 } else {
862 dev_warn(netdev->dev.parent, "failed tx_urb %d\n", err);
863
864 stats->tx_dropped++;
865 }
866 } else {
867 netdev->trans_start = jiffies;
868
869 /* Slow down tx path */
870 if (atomic_read(&dev->active_tx_urbs) >= MAX_TX_URBS ||
871 dev->free_slots < 5) {
872 netif_stop_queue(netdev);
873 }
874 }
875
876 /*
877 * Release our reference to this URB, the USB core will eventually free
878 * it entirely.
879 */
880 usb_free_urb(urb);
881
882 return NETDEV_TX_OK;
883
884nomem:
885 if (skb)
886 dev_kfree_skb(skb);
887
888 stats->tx_dropped++;
889
890 return NETDEV_TX_OK;
891}
892
893static int ems_usb_close(struct net_device *netdev)
894{
895 struct ems_usb *dev = netdev_priv(netdev);
896
897 /* Stop polling */
898 unlink_all_urbs(dev);
899
900 netif_stop_queue(netdev);
901
902 /* Set CAN controller to reset mode */
903 if (ems_usb_write_mode(dev, SJA1000_MOD_RM))
904 dev_warn(netdev->dev.parent, "couldn't stop device");
905
906 close_candev(netdev);
907
908 dev->open_time = 0;
909
910 return 0;
911}
912
913static const struct net_device_ops ems_usb_netdev_ops = {
914 .ndo_open = ems_usb_open,
915 .ndo_stop = ems_usb_close,
916 .ndo_start_xmit = ems_usb_start_xmit,
917};
918
919static struct can_bittiming_const ems_usb_bittiming_const = {
920 .name = "ems_usb",
921 .tseg1_min = 1,
922 .tseg1_max = 16,
923 .tseg2_min = 1,
924 .tseg2_max = 8,
925 .sjw_max = 4,
926 .brp_min = 1,
927 .brp_max = 64,
928 .brp_inc = 1,
929};
930
931static int ems_usb_set_mode(struct net_device *netdev, enum can_mode mode)
932{
933 struct ems_usb *dev = netdev_priv(netdev);
934
935 if (!dev->open_time)
936 return -EINVAL;
937
938 switch (mode) {
939 case CAN_MODE_START:
940 if (ems_usb_write_mode(dev, SJA1000_MOD_NORMAL))
941 dev_warn(netdev->dev.parent, "couldn't start device");
942
943 if (netif_queue_stopped(netdev))
944 netif_wake_queue(netdev);
945 break;
946
947 default:
948 return -EOPNOTSUPP;
949 }
950
951 return 0;
952}
953
954static int ems_usb_set_bittiming(struct net_device *netdev)
955{
956 struct ems_usb *dev = netdev_priv(netdev);
957 struct can_bittiming *bt = &dev->can.bittiming;
958 u8 btr0, btr1;
959
960 btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6);
961 btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) |
962 (((bt->phase_seg2 - 1) & 0x7) << 4);
963 if (dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
964 btr1 |= 0x80;
965
966 dev_info(netdev->dev.parent, "setting BTR0=0x%02x BTR1=0x%02x\n",
967 btr0, btr1);
968
969 dev->active_params.msg.can_params.cc_params.sja1000.btr0 = btr0;
970 dev->active_params.msg.can_params.cc_params.sja1000.btr1 = btr1;
971
972 return ems_usb_command_msg(dev, &dev->active_params);
973}
974
975static void init_params_sja1000(struct ems_cpc_msg *msg)
976{
977 struct cpc_sja1000_params *sja1000 =
978 &msg->msg.can_params.cc_params.sja1000;
979
980 msg->type = CPC_CMD_TYPE_CAN_PARAMS;
981 msg->length = sizeof(struct cpc_can_params);
982 msg->msgid = 0;
983
984 msg->msg.can_params.cc_type = CPC_CC_TYPE_SJA1000;
985
986 /* Acceptance filter open */
987 sja1000->acc_code0 = 0x00;
988 sja1000->acc_code1 = 0x00;
989 sja1000->acc_code2 = 0x00;
990 sja1000->acc_code3 = 0x00;
991
992 /* Acceptance filter open */
993 sja1000->acc_mask0 = 0xFF;
994 sja1000->acc_mask1 = 0xFF;
995 sja1000->acc_mask2 = 0xFF;
996 sja1000->acc_mask3 = 0xFF;
997
998 sja1000->btr0 = 0;
999 sja1000->btr1 = 0;
1000
1001 sja1000->outp_contr = SJA1000_DEFAULT_OUTPUT_CONTROL;
1002 sja1000->mode = SJA1000_MOD_RM;
1003}
1004
1005/*
1006 * probe function for new CPC-USB devices
1007 */
1008static int ems_usb_probe(struct usb_interface *intf,
1009 const struct usb_device_id *id)
1010{
1011 struct net_device *netdev;
1012 struct ems_usb *dev;
1013 int i, err = -ENOMEM;
1014
1015 netdev = alloc_candev(sizeof(struct ems_usb));
1016 if (!netdev) {
1017 dev_err(netdev->dev.parent, "Couldn't alloc candev\n");
1018 return -ENOMEM;
1019 }
1020
1021 dev = netdev_priv(netdev);
1022
1023 dev->udev = interface_to_usbdev(intf);
1024 dev->netdev = netdev;
1025
1026 dev->can.state = CAN_STATE_STOPPED;
1027 dev->can.clock.freq = EMS_USB_ARM7_CLOCK;
1028 dev->can.bittiming_const = &ems_usb_bittiming_const;
1029 dev->can.do_set_bittiming = ems_usb_set_bittiming;
1030 dev->can.do_set_mode = ems_usb_set_mode;
1031
1032 netdev->flags |= IFF_ECHO; /* we support local echo */
1033
1034 netdev->netdev_ops = &ems_usb_netdev_ops;
1035
1036 netdev->flags |= IFF_ECHO; /* we support local echo */
1037
1038 init_usb_anchor(&dev->rx_submitted);
1039
1040 init_usb_anchor(&dev->tx_submitted);
1041 atomic_set(&dev->active_tx_urbs, 0);
1042
1043 for (i = 0; i < MAX_TX_URBS; i++)
1044 dev->tx_contexts[i].echo_index = MAX_TX_URBS;
1045
1046 dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
1047 if (!dev->intr_urb) {
1048 dev_err(netdev->dev.parent, "Couldn't alloc intr URB\n");
1049 goto cleanup_candev;
1050 }
1051
1052 dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL);
1053 if (!dev->intr_in_buffer) {
1054 dev_err(netdev->dev.parent, "Couldn't alloc Intr buffer\n");
1055 goto cleanup_intr_urb;
1056 }
1057
1058 dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE +
1059 sizeof(struct ems_cpc_msg), GFP_KERNEL);
1060 if (!dev->tx_msg_buffer) {
1061 dev_err(netdev->dev.parent, "Couldn't alloc Tx buffer\n");
1062 goto cleanup_intr_in_buffer;
1063 }
1064
1065 usb_set_intfdata(intf, dev);
1066
1067 SET_NETDEV_DEV(netdev, &intf->dev);
1068
1069 init_params_sja1000(&dev->active_params);
1070
1071 err = ems_usb_command_msg(dev, &dev->active_params);
1072 if (err) {
1073 dev_err(netdev->dev.parent,
1074 "couldn't initialize controller: %d\n", err);
1075 goto cleanup_tx_msg_buffer;
1076 }
1077
1078 err = register_candev(netdev);
1079 if (err) {
1080 dev_err(netdev->dev.parent,
1081 "couldn't register CAN device: %d\n", err);
1082 goto cleanup_tx_msg_buffer;
1083 }
1084
1085 return 0;
1086
1087cleanup_tx_msg_buffer:
1088 kfree(dev->tx_msg_buffer);
1089
1090cleanup_intr_in_buffer:
1091 kfree(dev->intr_in_buffer);
1092
1093cleanup_intr_urb:
1094 usb_free_urb(dev->intr_urb);
1095
1096cleanup_candev:
1097 free_candev(netdev);
1098
1099 return err;
1100}
1101
1102/*
1103 * called by the usb core when the device is removed from the system
1104 */
1105static void ems_usb_disconnect(struct usb_interface *intf)
1106{
1107 struct ems_usb *dev = usb_get_intfdata(intf);
1108
1109 usb_set_intfdata(intf, NULL);
1110
1111 if (dev) {
1112 unregister_netdev(dev->netdev);
1113 free_candev(dev->netdev);
1114
1115 unlink_all_urbs(dev);
1116
1117 usb_free_urb(dev->intr_urb);
1118
1119 kfree(dev->intr_in_buffer);
1120 }
1121}
1122
1123/* usb specific object needed to register this driver with the usb subsystem */
1124static struct usb_driver ems_usb_driver = {
1125 .name = "ems_usb",
1126 .probe = ems_usb_probe,
1127 .disconnect = ems_usb_disconnect,
1128 .id_table = ems_usb_table,
1129};
1130
1131static int __init ems_usb_init(void)
1132{
1133 int err;
1134
1135 printk(KERN_INFO "CPC-USB kernel driver loaded\n");
1136
1137 /* register this driver with the USB subsystem */
1138 err = usb_register(&ems_usb_driver);
1139
1140 if (err) {
1141 err("usb_register failed. Error number %d\n", err);
1142 return err;
1143 }
1144
1145 return 0;
1146}
1147
1148static void __exit ems_usb_exit(void)
1149{
1150 /* deregister this driver with the USB subsystem */
1151 usb_deregister(&ems_usb_driver);
1152}
1153
1154module_init(ems_usb_init);
1155module_exit(ems_usb_exit);
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index d45eacb76702..211c8e9182fc 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -85,8 +85,6 @@ static int cnic_uio_open(struct uio_info *uinfo, struct inode *inode)
85 85
86 cp->uio_dev = iminor(inode); 86 cp->uio_dev = iminor(inode);
87 87
88 cnic_shutdown_bnx2_rx_ring(dev);
89
90 cnic_init_bnx2_tx_ring(dev); 88 cnic_init_bnx2_tx_ring(dev);
91 cnic_init_bnx2_rx_ring(dev); 89 cnic_init_bnx2_rx_ring(dev);
92 90
@@ -98,6 +96,8 @@ static int cnic_uio_close(struct uio_info *uinfo, struct inode *inode)
98 struct cnic_dev *dev = uinfo->priv; 96 struct cnic_dev *dev = uinfo->priv;
99 struct cnic_local *cp = dev->cnic_priv; 97 struct cnic_local *cp = dev->cnic_priv;
100 98
99 cnic_shutdown_bnx2_rx_ring(dev);
100
101 cp->uio_dev = -1; 101 cp->uio_dev = -1;
102 return 0; 102 return 0;
103} 103}
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 3e3fab8afb1e..61f9da2b4943 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -1109,7 +1109,7 @@ static int external_switch;
1109static int __devinit cpmac_probe(struct platform_device *pdev) 1109static int __devinit cpmac_probe(struct platform_device *pdev)
1110{ 1110{
1111 int rc, phy_id; 1111 int rc, phy_id;
1112 char mdio_bus_id[BUS_ID_SIZE]; 1112 char mdio_bus_id[MII_BUS_ID_SIZE];
1113 struct resource *mem; 1113 struct resource *mem;
1114 struct cpmac_priv *priv; 1114 struct cpmac_priv *priv;
1115 struct net_device *dev; 1115 struct net_device *dev;
@@ -1118,7 +1118,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1118 pdata = pdev->dev.platform_data; 1118 pdata = pdev->dev.platform_data;
1119 1119
1120 if (external_switch || dumb_switch) { 1120 if (external_switch || dumb_switch) {
1121 strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */ 1121 strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */
1122 phy_id = pdev->id; 1122 phy_id = pdev->id;
1123 } else { 1123 } else {
1124 for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { 1124 for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
@@ -1126,7 +1126,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1126 continue; 1126 continue;
1127 if (!cpmac_mii->phy_map[phy_id]) 1127 if (!cpmac_mii->phy_map[phy_id])
1128 continue; 1128 continue;
1129 strncpy(mdio_bus_id, cpmac_mii->id, BUS_ID_SIZE); 1129 strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE);
1130 break; 1130 break;
1131 } 1131 }
1132 } 1132 }
@@ -1167,7 +1167,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1167 priv->msg_enable = netif_msg_init(debug_level, 0xff); 1167 priv->msg_enable = netif_msg_init(debug_level, 0xff);
1168 memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); 1168 memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
1169 1169
1170 snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); 1170 snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
1171 1171
1172 priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, 1172 priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0,
1173 PHY_INTERFACE_MODE_MII); 1173 PHY_INTERFACE_MODE_MII);
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 977c3d358279..41bd7aeafd82 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -3083,7 +3083,6 @@ static const struct net_device_ops ehea_netdev_ops = {
3083 .ndo_poll_controller = ehea_netpoll, 3083 .ndo_poll_controller = ehea_netpoll,
3084#endif 3084#endif
3085 .ndo_get_stats = ehea_get_stats, 3085 .ndo_get_stats = ehea_get_stats,
3086 .ndo_change_mtu = eth_change_mtu,
3087 .ndo_set_mac_address = ehea_set_mac_addr, 3086 .ndo_set_mac_address = ehea_set_mac_addr,
3088 .ndo_validate_addr = eth_validate_addr, 3087 .ndo_validate_addr = eth_validate_addr,
3089 .ndo_set_multicast_list = ehea_set_multicast_list, 3088 .ndo_set_multicast_list = ehea_set_multicast_list,
diff --git a/drivers/net/igb/e1000_mac.c b/drivers/net/igb/e1000_mac.c
index a0231cd079f1..7d76bb085e10 100644
--- a/drivers/net/igb/e1000_mac.c
+++ b/drivers/net/igb/e1000_mac.c
@@ -286,41 +286,6 @@ void igb_mta_set(struct e1000_hw *hw, u32 hash_value)
286} 286}
287 287
288/** 288/**
289 * igb_update_mc_addr_list - Update Multicast addresses
290 * @hw: pointer to the HW structure
291 * @mc_addr_list: array of multicast addresses to program
292 * @mc_addr_count: number of multicast addresses to program
293 *
294 * Updates entire Multicast Table Array.
295 * The caller must have a packed mc_addr_list of multicast addresses.
296 **/
297void igb_update_mc_addr_list(struct e1000_hw *hw,
298 u8 *mc_addr_list, u32 mc_addr_count)
299{
300 u32 hash_value, hash_bit, hash_reg;
301 int i;
302
303 /* clear mta_shadow */
304 memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow));
305
306 /* update mta_shadow from mc_addr_list */
307 for (i = 0; (u32) i < mc_addr_count; i++) {
308 hash_value = igb_hash_mc_addr(hw, mc_addr_list);
309
310 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
311 hash_bit = hash_value & 0x1F;
312
313 hw->mac.mta_shadow[hash_reg] |= (1 << hash_bit);
314 mc_addr_list += (ETH_ALEN);
315 }
316
317 /* replace the entire MTA table */
318 for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
319 array_wr32(E1000_MTA, i, hw->mac.mta_shadow[i]);
320 wrfl();
321}
322
323/**
324 * igb_hash_mc_addr - Generate a multicast hash value 289 * igb_hash_mc_addr - Generate a multicast hash value
325 * @hw: pointer to the HW structure 290 * @hw: pointer to the HW structure
326 * @mc_addr: pointer to a multicast address 291 * @mc_addr: pointer to a multicast address
@@ -329,7 +294,7 @@ void igb_update_mc_addr_list(struct e1000_hw *hw,
329 * the multicast filter table array address and new table value. See 294 * the multicast filter table array address and new table value. See
330 * igb_mta_set() 295 * igb_mta_set()
331 **/ 296 **/
332u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) 297static u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
333{ 298{
334 u32 hash_value, hash_mask; 299 u32 hash_value, hash_mask;
335 u8 bit_shift = 0; 300 u8 bit_shift = 0;
@@ -392,6 +357,41 @@ u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
392} 357}
393 358
394/** 359/**
360 * igb_update_mc_addr_list - Update Multicast addresses
361 * @hw: pointer to the HW structure
362 * @mc_addr_list: array of multicast addresses to program
363 * @mc_addr_count: number of multicast addresses to program
364 *
365 * Updates entire Multicast Table Array.
366 * The caller must have a packed mc_addr_list of multicast addresses.
367 **/
368void igb_update_mc_addr_list(struct e1000_hw *hw,
369 u8 *mc_addr_list, u32 mc_addr_count)
370{
371 u32 hash_value, hash_bit, hash_reg;
372 int i;
373
374 /* clear mta_shadow */
375 memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow));
376
377 /* update mta_shadow from mc_addr_list */
378 for (i = 0; (u32) i < mc_addr_count; i++) {
379 hash_value = igb_hash_mc_addr(hw, mc_addr_list);
380
381 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
382 hash_bit = hash_value & 0x1F;
383
384 hw->mac.mta_shadow[hash_reg] |= (1 << hash_bit);
385 mc_addr_list += (ETH_ALEN);
386 }
387
388 /* replace the entire MTA table */
389 for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
390 array_wr32(E1000_MTA, i, hw->mac.mta_shadow[i]);
391 wrfl();
392}
393
394/**
395 * igb_clear_hw_cntrs_base - Clear base hardware counters 395 * igb_clear_hw_cntrs_base - Clear base hardware counters
396 * @hw: pointer to the HW structure 396 * @hw: pointer to the HW structure
397 * 397 *
diff --git a/drivers/net/igb/e1000_mac.h b/drivers/net/igb/e1000_mac.h
index 7518af8cbbf5..bca17d882417 100644
--- a/drivers/net/igb/e1000_mac.h
+++ b/drivers/net/igb/e1000_mac.h
@@ -88,6 +88,5 @@ enum e1000_mng_mode {
88#define E1000_MNG_DHCP_COOKIE_STATUS_VLAN 0x2 88#define E1000_MNG_DHCP_COOKIE_STATUS_VLAN 0x2
89 89
90extern void e1000_init_function_pointers_82575(struct e1000_hw *hw); 90extern void e1000_init_function_pointers_82575(struct e1000_hw *hw);
91extern u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr);
92 91
93#endif 92#endif
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index dd688d45e9cd..385be6016667 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -267,7 +267,8 @@ struct ixgbe_adapter {
267 enum ixgbe_fc_mode last_lfc_mode; 267 enum ixgbe_fc_mode last_lfc_mode;
268 268
269 /* Interrupt Throttle Rate */ 269 /* Interrupt Throttle Rate */
270 u32 itr_setting; 270 u32 rx_itr_setting;
271 u32 tx_itr_setting;
271 u16 eitr_low; 272 u16 eitr_low;
272 u16 eitr_high; 273 u16 eitr_high;
273 274
@@ -351,7 +352,8 @@ struct ixgbe_adapter {
351 struct ixgbe_hw_stats stats; 352 struct ixgbe_hw_stats stats;
352 353
353 /* Interrupt Throttle Rate */ 354 /* Interrupt Throttle Rate */
354 u32 eitr_param; 355 u32 rx_eitr_param;
356 u32 tx_eitr_param;
355 357
356 unsigned long state; 358 unsigned long state;
357 u64 tx_busy; 359 u64 tx_busy;
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 026e94a99849..53b0a6680254 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -1929,7 +1929,7 @@ static int ixgbe_get_coalesce(struct net_device *netdev,
1929 ec->tx_max_coalesced_frames_irq = adapter->tx_ring[0].work_limit; 1929 ec->tx_max_coalesced_frames_irq = adapter->tx_ring[0].work_limit;
1930 1930
1931 /* only valid if in constant ITR mode */ 1931 /* only valid if in constant ITR mode */
1932 switch (adapter->itr_setting) { 1932 switch (adapter->rx_itr_setting) {
1933 case 0: 1933 case 0:
1934 /* throttling disabled */ 1934 /* throttling disabled */
1935 ec->rx_coalesce_usecs = 0; 1935 ec->rx_coalesce_usecs = 0;
@@ -1940,9 +1940,25 @@ static int ixgbe_get_coalesce(struct net_device *netdev,
1940 break; 1940 break;
1941 default: 1941 default:
1942 /* fixed interrupt rate mode */ 1942 /* fixed interrupt rate mode */
1943 ec->rx_coalesce_usecs = 1000000/adapter->eitr_param; 1943 ec->rx_coalesce_usecs = 1000000/adapter->rx_eitr_param;
1944 break; 1944 break;
1945 } 1945 }
1946
1947 /* only valid if in constant ITR mode */
1948 switch (adapter->tx_itr_setting) {
1949 case 0:
1950 /* throttling disabled */
1951 ec->tx_coalesce_usecs = 0;
1952 break;
1953 case 1:
1954 /* dynamic ITR mode */
1955 ec->tx_coalesce_usecs = 1;
1956 break;
1957 default:
1958 ec->tx_coalesce_usecs = 1000000/adapter->tx_eitr_param;
1959 break;
1960 }
1961
1946 return 0; 1962 return 0;
1947} 1963}
1948 1964
@@ -1953,6 +1969,14 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
1953 struct ixgbe_q_vector *q_vector; 1969 struct ixgbe_q_vector *q_vector;
1954 int i; 1970 int i;
1955 1971
1972 /*
1973 * don't accept tx specific changes if we've got mixed RxTx vectors
1974 * test and jump out here if needed before changing the rx numbers
1975 */
1976 if ((1000000/ec->tx_coalesce_usecs) != adapter->tx_eitr_param &&
1977 adapter->q_vector[0]->txr_count && adapter->q_vector[0]->rxr_count)
1978 return -EINVAL;
1979
1956 if (ec->tx_max_coalesced_frames_irq) 1980 if (ec->tx_max_coalesced_frames_irq)
1957 adapter->tx_ring[0].work_limit = ec->tx_max_coalesced_frames_irq; 1981 adapter->tx_ring[0].work_limit = ec->tx_max_coalesced_frames_irq;
1958 1982
@@ -1963,26 +1987,49 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
1963 return -EINVAL; 1987 return -EINVAL;
1964 1988
1965 /* store the value in ints/second */ 1989 /* store the value in ints/second */
1966 adapter->eitr_param = 1000000/ec->rx_coalesce_usecs; 1990 adapter->rx_eitr_param = 1000000/ec->rx_coalesce_usecs;
1967 1991
1968 /* static value of interrupt rate */ 1992 /* static value of interrupt rate */
1969 adapter->itr_setting = adapter->eitr_param; 1993 adapter->rx_itr_setting = adapter->rx_eitr_param;
1970 /* clear the lower bit as its used for dynamic state */ 1994 /* clear the lower bit as its used for dynamic state */
1971 adapter->itr_setting &= ~1; 1995 adapter->rx_itr_setting &= ~1;
1972 } else if (ec->rx_coalesce_usecs == 1) { 1996 } else if (ec->rx_coalesce_usecs == 1) {
1973 /* 1 means dynamic mode */ 1997 /* 1 means dynamic mode */
1974 adapter->eitr_param = 20000; 1998 adapter->rx_eitr_param = 20000;
1975 adapter->itr_setting = 1; 1999 adapter->rx_itr_setting = 1;
1976 } else { 2000 } else {
1977 /* 2001 /*
1978 * any other value means disable eitr, which is best 2002 * any other value means disable eitr, which is best
1979 * served by setting the interrupt rate very high 2003 * served by setting the interrupt rate very high
1980 */ 2004 */
1981 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) 2005 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
1982 adapter->eitr_param = IXGBE_MAX_RSC_INT_RATE; 2006 adapter->rx_eitr_param = IXGBE_MAX_RSC_INT_RATE;
1983 else 2007 else
1984 adapter->eitr_param = IXGBE_MAX_INT_RATE; 2008 adapter->rx_eitr_param = IXGBE_MAX_INT_RATE;
1985 adapter->itr_setting = 0; 2009 adapter->rx_itr_setting = 0;
2010 }
2011
2012 if (ec->tx_coalesce_usecs > 1) {
2013 /* check the limits */
2014 if ((1000000/ec->tx_coalesce_usecs > IXGBE_MAX_INT_RATE) ||
2015 (1000000/ec->tx_coalesce_usecs < IXGBE_MIN_INT_RATE))
2016 return -EINVAL;
2017
2018 /* store the value in ints/second */
2019 adapter->tx_eitr_param = 1000000/ec->tx_coalesce_usecs;
2020
2021 /* static value of interrupt rate */
2022 adapter->tx_itr_setting = adapter->tx_eitr_param;
2023
2024 /* clear the lower bit as its used for dynamic state */
2025 adapter->tx_itr_setting &= ~1;
2026 } else if (ec->tx_coalesce_usecs == 1) {
2027 /* 1 means dynamic mode */
2028 adapter->tx_eitr_param = 10000;
2029 adapter->tx_itr_setting = 1;
2030 } else {
2031 adapter->tx_eitr_param = IXGBE_MAX_INT_RATE;
2032 adapter->tx_itr_setting = 0;
1986 } 2033 }
1987 2034
1988 /* MSI/MSIx Interrupt Mode */ 2035 /* MSI/MSIx Interrupt Mode */
@@ -1992,17 +2039,17 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
1992 for (i = 0; i < num_vectors; i++) { 2039 for (i = 0; i < num_vectors; i++) {
1993 q_vector = adapter->q_vector[i]; 2040 q_vector = adapter->q_vector[i];
1994 if (q_vector->txr_count && !q_vector->rxr_count) 2041 if (q_vector->txr_count && !q_vector->rxr_count)
1995 /* tx vector gets half the rate */ 2042 /* tx only */
1996 q_vector->eitr = (adapter->eitr_param >> 1); 2043 q_vector->eitr = adapter->tx_eitr_param;
1997 else 2044 else
1998 /* rx only or mixed */ 2045 /* rx only or mixed */
1999 q_vector->eitr = adapter->eitr_param; 2046 q_vector->eitr = adapter->rx_eitr_param;
2000 ixgbe_write_eitr(q_vector); 2047 ixgbe_write_eitr(q_vector);
2001 } 2048 }
2002 /* Legacy Interrupt Mode */ 2049 /* Legacy Interrupt Mode */
2003 } else { 2050 } else {
2004 q_vector = adapter->q_vector[0]; 2051 q_vector = adapter->q_vector[0];
2005 q_vector->eitr = adapter->eitr_param; 2052 q_vector->eitr = adapter->rx_eitr_param;
2006 ixgbe_write_eitr(q_vector); 2053 ixgbe_write_eitr(q_vector);
2007 } 2054 }
2008 2055
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 59ad9590e700..c407bd9de0dd 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -926,12 +926,12 @@ static void ixgbe_configure_msix(struct ixgbe_adapter *adapter)
926 r_idx + 1); 926 r_idx + 1);
927 } 927 }
928 928
929 /* if this is a tx only vector halve the interrupt rate */
930 if (q_vector->txr_count && !q_vector->rxr_count) 929 if (q_vector->txr_count && !q_vector->rxr_count)
931 q_vector->eitr = (adapter->eitr_param >> 1); 930 /* tx only */
931 q_vector->eitr = adapter->tx_eitr_param;
932 else if (q_vector->rxr_count) 932 else if (q_vector->rxr_count)
933 /* rx only */ 933 /* rx or mixed */
934 q_vector->eitr = adapter->eitr_param; 934 q_vector->eitr = adapter->rx_eitr_param;
935 935
936 ixgbe_write_eitr(q_vector); 936 ixgbe_write_eitr(q_vector);
937 } 937 }
@@ -1359,7 +1359,7 @@ static int ixgbe_clean_rxonly(struct napi_struct *napi, int budget)
1359 /* If all Rx work done, exit the polling mode */ 1359 /* If all Rx work done, exit the polling mode */
1360 if (work_done < budget) { 1360 if (work_done < budget) {
1361 napi_complete(napi); 1361 napi_complete(napi);
1362 if (adapter->itr_setting & 1) 1362 if (adapter->rx_itr_setting & 1)
1363 ixgbe_set_itr_msix(q_vector); 1363 ixgbe_set_itr_msix(q_vector);
1364 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 1364 if (!test_bit(__IXGBE_DOWN, &adapter->state))
1365 ixgbe_irq_enable_queues(adapter, 1365 ixgbe_irq_enable_queues(adapter,
@@ -1420,7 +1420,7 @@ static int ixgbe_clean_rxtx_many(struct napi_struct *napi, int budget)
1420 /* If all Rx work done, exit the polling mode */ 1420 /* If all Rx work done, exit the polling mode */
1421 if (work_done < budget) { 1421 if (work_done < budget) {
1422 napi_complete(napi); 1422 napi_complete(napi);
1423 if (adapter->itr_setting & 1) 1423 if (adapter->rx_itr_setting & 1)
1424 ixgbe_set_itr_msix(q_vector); 1424 ixgbe_set_itr_msix(q_vector);
1425 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 1425 if (!test_bit(__IXGBE_DOWN, &adapter->state))
1426 ixgbe_irq_enable_queues(adapter, 1426 ixgbe_irq_enable_queues(adapter,
@@ -1458,10 +1458,10 @@ static int ixgbe_clean_txonly(struct napi_struct *napi, int budget)
1458 if (!ixgbe_clean_tx_irq(q_vector, tx_ring)) 1458 if (!ixgbe_clean_tx_irq(q_vector, tx_ring))
1459 work_done = budget; 1459 work_done = budget;
1460 1460
1461 /* If all Rx work done, exit the polling mode */ 1461 /* If all Tx work done, exit the polling mode */
1462 if (work_done < budget) { 1462 if (work_done < budget) {
1463 napi_complete(napi); 1463 napi_complete(napi);
1464 if (adapter->itr_setting & 1) 1464 if (adapter->tx_itr_setting & 1)
1465 ixgbe_set_itr_msix(q_vector); 1465 ixgbe_set_itr_msix(q_vector);
1466 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 1466 if (!test_bit(__IXGBE_DOWN, &adapter->state))
1467 ixgbe_irq_enable_queues(adapter, ((u64)1 << q_vector->v_idx)); 1467 ixgbe_irq_enable_queues(adapter, ((u64)1 << q_vector->v_idx));
@@ -1848,7 +1848,7 @@ static void ixgbe_configure_msi_and_legacy(struct ixgbe_adapter *adapter)
1848 struct ixgbe_hw *hw = &adapter->hw; 1848 struct ixgbe_hw *hw = &adapter->hw;
1849 1849
1850 IXGBE_WRITE_REG(hw, IXGBE_EITR(0), 1850 IXGBE_WRITE_REG(hw, IXGBE_EITR(0),
1851 EITR_INTS_PER_SEC_TO_REG(adapter->eitr_param)); 1851 EITR_INTS_PER_SEC_TO_REG(adapter->rx_eitr_param));
1852 1852
1853 ixgbe_set_ivar(adapter, 0, 0, 0); 1853 ixgbe_set_ivar(adapter, 0, 0, 0);
1854 ixgbe_set_ivar(adapter, 1, 0, 0); 1854 ixgbe_set_ivar(adapter, 1, 0, 0);
@@ -1970,6 +1970,50 @@ static u32 ixgbe_setup_mrqc(struct ixgbe_adapter *adapter)
1970} 1970}
1971 1971
1972/** 1972/**
1973 * ixgbe_configure_rscctl - enable RSC for the indicated ring
1974 * @adapter: address of board private structure
1975 * @index: index of ring to set
1976 * @rx_buf_len: rx buffer length
1977 **/
1978static void ixgbe_configure_rscctl(struct ixgbe_adapter *adapter, int index,
1979 int rx_buf_len)
1980{
1981 struct ixgbe_ring *rx_ring;
1982 struct ixgbe_hw *hw = &adapter->hw;
1983 int j;
1984 u32 rscctrl;
1985
1986 rx_ring = &adapter->rx_ring[index];
1987 j = rx_ring->reg_idx;
1988 rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j));
1989 rscctrl |= IXGBE_RSCCTL_RSCEN;
1990 /*
1991 * we must limit the number of descriptors so that the
1992 * total size of max desc * buf_len is not greater
1993 * than 65535
1994 */
1995 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) {
1996#if (MAX_SKB_FRAGS > 16)
1997 rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
1998#elif (MAX_SKB_FRAGS > 8)
1999 rscctrl |= IXGBE_RSCCTL_MAXDESC_8;
2000#elif (MAX_SKB_FRAGS > 4)
2001 rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
2002#else
2003 rscctrl |= IXGBE_RSCCTL_MAXDESC_1;
2004#endif
2005 } else {
2006 if (rx_buf_len < IXGBE_RXBUFFER_4096)
2007 rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
2008 else if (rx_buf_len < IXGBE_RXBUFFER_8192)
2009 rscctrl |= IXGBE_RSCCTL_MAXDESC_8;
2010 else
2011 rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
2012 }
2013 IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(j), rscctrl);
2014}
2015
2016/**
1973 * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset 2017 * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset
1974 * @adapter: board private structure 2018 * @adapter: board private structure
1975 * 2019 *
@@ -1990,7 +2034,6 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
1990 u32 fctrl, hlreg0; 2034 u32 fctrl, hlreg0;
1991 u32 reta = 0, mrqc = 0; 2035 u32 reta = 0, mrqc = 0;
1992 u32 rdrxctl; 2036 u32 rdrxctl;
1993 u32 rscctrl;
1994 int rx_buf_len; 2037 int rx_buf_len;
1995 2038
1996 /* Decide whether to use packet split mode or not */ 2039 /* Decide whether to use packet split mode or not */
@@ -2148,36 +2191,9 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2148 2191
2149 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { 2192 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
2150 /* Enable 82599 HW-RSC */ 2193 /* Enable 82599 HW-RSC */
2151 for (i = 0; i < adapter->num_rx_queues; i++) { 2194 for (i = 0; i < adapter->num_rx_queues; i++)
2152 rx_ring = &adapter->rx_ring[i]; 2195 ixgbe_configure_rscctl(adapter, i, rx_buf_len);
2153 j = rx_ring->reg_idx; 2196
2154 rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j));
2155 rscctrl |= IXGBE_RSCCTL_RSCEN;
2156 /*
2157 * we must limit the number of descriptors so that the
2158 * total size of max desc * buf_len is not greater
2159 * than 65535
2160 */
2161 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) {
2162#if (MAX_SKB_FRAGS > 16)
2163 rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
2164#elif (MAX_SKB_FRAGS > 8)
2165 rscctrl |= IXGBE_RSCCTL_MAXDESC_8;
2166#elif (MAX_SKB_FRAGS > 4)
2167 rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
2168#else
2169 rscctrl |= IXGBE_RSCCTL_MAXDESC_1;
2170#endif
2171 } else {
2172 if (rx_buf_len < IXGBE_RXBUFFER_4096)
2173 rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
2174 else if (rx_buf_len < IXGBE_RXBUFFER_8192)
2175 rscctrl |= IXGBE_RSCCTL_MAXDESC_8;
2176 else
2177 rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
2178 }
2179 IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(j), rscctrl);
2180 }
2181 /* Disable RSC for ACK packets */ 2197 /* Disable RSC for ACK packets */
2182 IXGBE_WRITE_REG(hw, IXGBE_RSCDBU, 2198 IXGBE_WRITE_REG(hw, IXGBE_RSCDBU,
2183 (IXGBE_RSCDBU_RSCACKDIS | IXGBE_READ_REG(hw, IXGBE_RSCDBU))); 2199 (IXGBE_RSCDBU_RSCACKDIS | IXGBE_READ_REG(hw, IXGBE_RSCDBU)));
@@ -2926,6 +2942,8 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
2926 2942
2927 ixgbe_napi_disable_all(adapter); 2943 ixgbe_napi_disable_all(adapter);
2928 2944
2945 clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state);
2946 del_timer_sync(&adapter->sfp_timer);
2929 del_timer_sync(&adapter->watchdog_timer); 2947 del_timer_sync(&adapter->watchdog_timer);
2930 cancel_work_sync(&adapter->watchdog_task); 2948 cancel_work_sync(&adapter->watchdog_task);
2931 2949
@@ -2989,7 +3007,7 @@ static int ixgbe_poll(struct napi_struct *napi, int budget)
2989 /* If budget not fully consumed, exit the polling mode */ 3007 /* If budget not fully consumed, exit the polling mode */
2990 if (work_done < budget) { 3008 if (work_done < budget) {
2991 napi_complete(napi); 3009 napi_complete(napi);
2992 if (adapter->itr_setting & 1) 3010 if (adapter->rx_itr_setting & 1)
2993 ixgbe_set_itr(adapter); 3011 ixgbe_set_itr(adapter);
2994 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 3012 if (!test_bit(__IXGBE_DOWN, &adapter->state))
2995 ixgbe_irq_enable_queues(adapter, IXGBE_EIMS_RTX_QUEUE); 3013 ixgbe_irq_enable_queues(adapter, IXGBE_EIMS_RTX_QUEUE);
@@ -3599,7 +3617,10 @@ static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter)
3599 if (!q_vector) 3617 if (!q_vector)
3600 goto err_out; 3618 goto err_out;
3601 q_vector->adapter = adapter; 3619 q_vector->adapter = adapter;
3602 q_vector->eitr = adapter->eitr_param; 3620 if (q_vector->txr_count && !q_vector->rxr_count)
3621 q_vector->eitr = adapter->tx_eitr_param;
3622 else
3623 q_vector->eitr = adapter->rx_eitr_param;
3603 q_vector->v_idx = q_idx; 3624 q_vector->v_idx = q_idx;
3604 netif_napi_add(adapter->netdev, &q_vector->napi, (*poll), 64); 3625 netif_napi_add(adapter->netdev, &q_vector->napi, (*poll), 64);
3605 adapter->q_vector[q_idx] = q_vector; 3626 adapter->q_vector[q_idx] = q_vector;
@@ -3868,8 +3889,10 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
3868 hw->fc.disable_fc_autoneg = false; 3889 hw->fc.disable_fc_autoneg = false;
3869 3890
3870 /* enable itr by default in dynamic mode */ 3891 /* enable itr by default in dynamic mode */
3871 adapter->itr_setting = 1; 3892 adapter->rx_itr_setting = 1;
3872 adapter->eitr_param = 20000; 3893 adapter->rx_eitr_param = 20000;
3894 adapter->tx_itr_setting = 1;
3895 adapter->tx_eitr_param = 10000;
3873 3896
3874 /* set defaults for eitr in MegaBytes */ 3897 /* set defaults for eitr in MegaBytes */
3875 adapter->eitr_low = 10; 3898 adapter->eitr_low = 10;
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index f7bdde111dfc..b5aa974827e5 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1469,6 +1469,7 @@ netxen_nic_resume(struct pci_dev *pdev)
1469 } 1469 }
1470 1470
1471 netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY); 1471 netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY);
1472 return 0;
1472 1473
1473err_out_detach: 1474err_out_detach:
1474 netxen_nic_detach(adapter); 1475 netxen_nic_detach(adapter);
@@ -1903,12 +1904,13 @@ static void netxen_tx_timeout_task(struct work_struct *work)
1903 1904
1904 netif_wake_queue(adapter->netdev); 1905 netif_wake_queue(adapter->netdev);
1905 1906
1906 goto done; 1907 clear_bit(__NX_RESETTING, &adapter->state);
1907 1908
1908 } else { 1909 } else {
1910 clear_bit(__NX_RESETTING, &adapter->state);
1909 if (!netxen_nic_reset_context(adapter)) { 1911 if (!netxen_nic_reset_context(adapter)) {
1910 adapter->netdev->trans_start = jiffies; 1912 adapter->netdev->trans_start = jiffies;
1911 goto done; 1913 return;
1912 } 1914 }
1913 1915
1914 /* context reset failed, fall through for fw reset */ 1916 /* context reset failed, fall through for fw reset */
@@ -1916,8 +1918,6 @@ static void netxen_tx_timeout_task(struct work_struct *work)
1916 1918
1917request_reset: 1919request_reset:
1918 adapter->need_fw_reset = 1; 1920 adapter->need_fw_reset = 1;
1919done:
1920 clear_bit(__NX_RESETTING, &adapter->state);
1921} 1921}
1922 1922
1923struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) 1923struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 97db1c732342..474876c879cb 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -340,12 +340,11 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
340 base = &virt[hw_info[i].offset & (req.Size-1)]; 340 base = &virt[hw_info[i].offset & (req.Size-1)];
341 if ((readb(base+0) == hw_info[i].a0) && 341 if ((readb(base+0) == hw_info[i].a0) &&
342 (readb(base+2) == hw_info[i].a1) && 342 (readb(base+2) == hw_info[i].a1) &&
343 (readb(base+4) == hw_info[i].a2)) 343 (readb(base+4) == hw_info[i].a2)) {
344 break; 344 for (j = 0; j < 6; j++)
345 } 345 dev->dev_addr[j] = readb(base + (j<<1));
346 if (i < NR_INFO) { 346 break;
347 for (j = 0; j < 6; j++) 347 }
348 dev->dev_addr[j] = readb(base + (j<<1));
349 } 348 }
350 349
351 iounmap(virt); 350 iounmap(virt);
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 15140f9f2e92..ef1165718dd7 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1497,7 +1497,6 @@ static int sky2_up(struct net_device *dev)
1497 if (ramsize > 0) { 1497 if (ramsize > 0) {
1498 u32 rxspace; 1498 u32 rxspace;
1499 1499
1500 hw->flags |= SKY2_HW_RAM_BUFFER;
1501 pr_debug(PFX "%s: ram buffer %dK\n", dev->name, ramsize); 1500 pr_debug(PFX "%s: ram buffer %dK\n", dev->name, ramsize);
1502 if (ramsize < 16) 1501 if (ramsize < 16)
1503 rxspace = ramsize / 2; 1502 rxspace = ramsize / 2;
@@ -2926,6 +2925,9 @@ static int __devinit sky2_init(struct sky2_hw *hw)
2926 ++hw->ports; 2925 ++hw->ports;
2927 } 2926 }
2928 2927
2928 if (sky2_read8(hw, B2_E_0))
2929 hw->flags |= SKY2_HW_RAM_BUFFER;
2930
2929 return 0; 2931 return 0;
2930} 2932}
2931 2933
diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c
index f1e5e4542c2a..bc74db0d12f3 100644
--- a/drivers/net/sunvnet.c
+++ b/drivers/net/sunvnet.c
@@ -1016,7 +1016,6 @@ static const struct net_device_ops vnet_ops = {
1016 .ndo_open = vnet_open, 1016 .ndo_open = vnet_open,
1017 .ndo_stop = vnet_close, 1017 .ndo_stop = vnet_close,
1018 .ndo_set_multicast_list = vnet_set_rx_mode, 1018 .ndo_set_multicast_list = vnet_set_rx_mode,
1019 .ndo_change_mtu = eth_change_mtu,
1020 .ndo_set_mac_address = vnet_set_mac_addr, 1019 .ndo_set_mac_address = vnet_set_mac_addr,
1021 .ndo_validate_addr = eth_validate_addr, 1020 .ndo_validate_addr = eth_validate_addr,
1022 .ndo_tx_timeout = vnet_tx_timeout, 1021 .ndo_tx_timeout = vnet_tx_timeout,
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d3ee1994b02f..4fdfa2ae5418 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -946,8 +946,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
946 char *name; 946 char *name;
947 unsigned long flags = 0; 947 unsigned long flags = 0;
948 948
949 err = -EINVAL;
950
951 if (!capable(CAP_NET_ADMIN)) 949 if (!capable(CAP_NET_ADMIN))
952 return -EPERM; 950 return -EPERM;
953 err = security_tun_dev_create(); 951 err = security_tun_dev_create();
@@ -964,7 +962,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
964 flags |= TUN_TAP_DEV; 962 flags |= TUN_TAP_DEV;
965 name = "tap%d"; 963 name = "tap%d";
966 } else 964 } else
967 goto failed; 965 return -EINVAL;
968 966
969 if (*ifr->ifr_name) 967 if (*ifr->ifr_name)
970 name = ifr->ifr_name; 968 name = ifr->ifr_name;
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index e2a39b9be96e..e391ef969c28 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -263,6 +263,7 @@ static int kaweth_control(struct kaweth_device *kaweth,
263 int timeout) 263 int timeout)
264{ 264{
265 struct usb_ctrlrequest *dr; 265 struct usb_ctrlrequest *dr;
266 int retval;
266 267
267 dbg("kaweth_control()"); 268 dbg("kaweth_control()");
268 269
@@ -278,18 +279,21 @@ static int kaweth_control(struct kaweth_device *kaweth,
278 return -ENOMEM; 279 return -ENOMEM;
279 } 280 }
280 281
281 dr->bRequestType= requesttype; 282 dr->bRequestType = requesttype;
282 dr->bRequest = request; 283 dr->bRequest = request;
283 dr->wValue = cpu_to_le16(value); 284 dr->wValue = cpu_to_le16(value);
284 dr->wIndex = cpu_to_le16(index); 285 dr->wIndex = cpu_to_le16(index);
285 dr->wLength = cpu_to_le16(size); 286 dr->wLength = cpu_to_le16(size);
286 287
287 return kaweth_internal_control_msg(kaweth->dev, 288 retval = kaweth_internal_control_msg(kaweth->dev,
288 pipe, 289 pipe,
289 dr, 290 dr,
290 data, 291 data,
291 size, 292 size,
292 timeout); 293 timeout);
294
295 kfree(dr);
296 return retval;
293} 297}
294 298
295/**************************************************************** 299/****************************************************************
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 938fb3530a7a..c6c922247d05 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1227,7 +1227,7 @@ static const struct driver_info smsc95xx_info = {
1227 .rx_fixup = smsc95xx_rx_fixup, 1227 .rx_fixup = smsc95xx_rx_fixup,
1228 .tx_fixup = smsc95xx_tx_fixup, 1228 .tx_fixup = smsc95xx_tx_fixup,
1229 .status = smsc95xx_status, 1229 .status = smsc95xx_status,
1230 .flags = FLAG_ETHER, 1230 .flags = FLAG_ETHER | FLAG_SEND_ZLP,
1231}; 1231};
1232 1232
1233static const struct usb_device_id products[] = { 1233static const struct usb_device_id products[] = {
@@ -1237,10 +1237,75 @@ static const struct usb_device_id products[] = {
1237 .driver_info = (unsigned long) &smsc95xx_info, 1237 .driver_info = (unsigned long) &smsc95xx_info,
1238 }, 1238 },
1239 { 1239 {
1240 /* SMSC9505 USB Ethernet Device */
1241 USB_DEVICE(0x0424, 0x9505),
1242 .driver_info = (unsigned long) &smsc95xx_info,
1243 },
1244 {
1245 /* SMSC9500A USB Ethernet Device */
1246 USB_DEVICE(0x0424, 0x9E00),
1247 .driver_info = (unsigned long) &smsc95xx_info,
1248 },
1249 {
1250 /* SMSC9505A USB Ethernet Device */
1251 USB_DEVICE(0x0424, 0x9E01),
1252 .driver_info = (unsigned long) &smsc95xx_info,
1253 },
1254 {
1240 /* SMSC9512/9514 USB Hub & Ethernet Device */ 1255 /* SMSC9512/9514 USB Hub & Ethernet Device */
1241 USB_DEVICE(0x0424, 0xec00), 1256 USB_DEVICE(0x0424, 0xec00),
1242 .driver_info = (unsigned long) &smsc95xx_info, 1257 .driver_info = (unsigned long) &smsc95xx_info,
1243 }, 1258 },
1259 {
1260 /* SMSC9500 USB Ethernet Device (SAL10) */
1261 USB_DEVICE(0x0424, 0x9900),
1262 .driver_info = (unsigned long) &smsc95xx_info,
1263 },
1264 {
1265 /* SMSC9505 USB Ethernet Device (SAL10) */
1266 USB_DEVICE(0x0424, 0x9901),
1267 .driver_info = (unsigned long) &smsc95xx_info,
1268 },
1269 {
1270 /* SMSC9500A USB Ethernet Device (SAL10) */
1271 USB_DEVICE(0x0424, 0x9902),
1272 .driver_info = (unsigned long) &smsc95xx_info,
1273 },
1274 {
1275 /* SMSC9505A USB Ethernet Device (SAL10) */
1276 USB_DEVICE(0x0424, 0x9903),
1277 .driver_info = (unsigned long) &smsc95xx_info,
1278 },
1279 {
1280 /* SMSC9512/9514 USB Hub & Ethernet Device (SAL10) */
1281 USB_DEVICE(0x0424, 0x9904),
1282 .driver_info = (unsigned long) &smsc95xx_info,
1283 },
1284 {
1285 /* SMSC9500A USB Ethernet Device (HAL) */
1286 USB_DEVICE(0x0424, 0x9905),
1287 .driver_info = (unsigned long) &smsc95xx_info,
1288 },
1289 {
1290 /* SMSC9505A USB Ethernet Device (HAL) */
1291 USB_DEVICE(0x0424, 0x9906),
1292 .driver_info = (unsigned long) &smsc95xx_info,
1293 },
1294 {
1295 /* SMSC9500 USB Ethernet Device (Alternate ID) */
1296 USB_DEVICE(0x0424, 0x9907),
1297 .driver_info = (unsigned long) &smsc95xx_info,
1298 },
1299 {
1300 /* SMSC9500A USB Ethernet Device (Alternate ID) */
1301 USB_DEVICE(0x0424, 0x9908),
1302 .driver_info = (unsigned long) &smsc95xx_info,
1303 },
1304 {
1305 /* SMSC9512/9514 USB Hub & Ethernet Device (Alternate ID) */
1306 USB_DEVICE(0x0424, 0x9909),
1307 .driver_info = (unsigned long) &smsc95xx_info,
1308 },
1244 { }, /* END */ 1309 { }, /* END */
1245}; 1310};
1246MODULE_DEVICE_TABLE(usb, products); 1311MODULE_DEVICE_TABLE(usb, products);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 24b36f795151..ca5ca5ae061d 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1049,7 +1049,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
1049 * NOTE: strictly conforming cdc-ether devices should expect 1049 * NOTE: strictly conforming cdc-ether devices should expect
1050 * the ZLP here, but ignore the one-byte packet. 1050 * the ZLP here, but ignore the one-byte packet.
1051 */ 1051 */
1052 if ((length % dev->maxpacket) == 0) { 1052 if (!(info->flags & FLAG_SEND_ZLP) && (length % dev->maxpacket) == 0) {
1053 urb->transfer_buffer_length++; 1053 urb->transfer_buffer_length++;
1054 if (skb_tailroom(skb)) { 1054 if (skb_tailroom(skb)) {
1055 skb->data[skb->len] = 0; 1055 skb->data[skb->len] = 0;
diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c
index e0138ac8bf50..e974e5829e1a 100644
--- a/drivers/net/wireless/ath/ar9170/usb.c
+++ b/drivers/net/wireless/ath/ar9170/usb.c
@@ -64,6 +64,8 @@ static struct usb_device_id ar9170_usb_ids[] = {
64 { USB_DEVICE(0x0cf3, 0x9170) }, 64 { USB_DEVICE(0x0cf3, 0x9170) },
65 /* Atheros TG121N */ 65 /* Atheros TG121N */
66 { USB_DEVICE(0x0cf3, 0x1001) }, 66 { USB_DEVICE(0x0cf3, 0x1001) },
67 /* TP-Link TL-WN821N v2 */
68 { USB_DEVICE(0x0cf3, 0x1002) },
67 /* Cace Airpcap NX */ 69 /* Cace Airpcap NX */
68 { USB_DEVICE(0xcace, 0x0300) }, 70 { USB_DEVICE(0xcace, 0x0300) },
69 /* D-Link DWA 160A */ 71 /* D-Link DWA 160A */
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 3234995e8881..0ad6d0b76e9e 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -609,14 +609,24 @@ void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
609 AR_PHY_CH1_EXT_CCA, 609 AR_PHY_CH1_EXT_CCA,
610 AR_PHY_CH2_EXT_CCA 610 AR_PHY_CH2_EXT_CCA
611 }; 611 };
612 u8 chainmask; 612 u8 chainmask, rx_chain_status;
613 613
614 rx_chain_status = REG_READ(ah, AR_PHY_RX_CHAINMASK);
614 if (AR_SREV_9285(ah)) 615 if (AR_SREV_9285(ah))
615 chainmask = 0x9; 616 chainmask = 0x9;
616 else if (AR_SREV_9280(ah) || AR_SREV_9287(ah)) 617 else if (AR_SREV_9280(ah) || AR_SREV_9287(ah)) {
617 chainmask = 0x1B; 618 if ((rx_chain_status & 0x2) || (rx_chain_status & 0x4))
618 else 619 chainmask = 0x1B;
619 chainmask = 0x3F; 620 else
621 chainmask = 0x09;
622 } else {
623 if (rx_chain_status & 0x4)
624 chainmask = 0x3F;
625 else if (rx_chain_status & 0x2)
626 chainmask = 0x1B;
627 else
628 chainmask = 0x09;
629 }
620 630
621 h = ah->nfCalHist; 631 h = ah->nfCalHist;
622 632
@@ -697,6 +707,8 @@ void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah)
697 noise_floor = AR_PHY_CCA_MAX_AR9280_GOOD_VALUE; 707 noise_floor = AR_PHY_CCA_MAX_AR9280_GOOD_VALUE;
698 else if (AR_SREV_9285(ah)) 708 else if (AR_SREV_9285(ah))
699 noise_floor = AR_PHY_CCA_MAX_AR9285_GOOD_VALUE; 709 noise_floor = AR_PHY_CCA_MAX_AR9285_GOOD_VALUE;
710 else if (AR_SREV_9287(ah))
711 noise_floor = AR_PHY_CCA_MAX_AR9287_GOOD_VALUE;
700 else 712 else
701 noise_floor = AR_PHY_CCA_MAX_AR5416_GOOD_VALUE; 713 noise_floor = AR_PHY_CCA_MAX_AR5416_GOOD_VALUE;
702 714
@@ -924,6 +936,7 @@ static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah, bool is_reset)
924 regVal |= (1 << (19 + i)); 936 regVal |= (1 << (19 + i));
925 REG_WRITE(ah, 0x7834, regVal); 937 REG_WRITE(ah, 0x7834, regVal);
926 udelay(1); 938 udelay(1);
939 regVal = REG_READ(ah, 0x7834);
927 regVal &= (~(0x1 << (19 + i))); 940 regVal &= (~(0x1 << (19 + i)));
928 reg_field = MS(REG_READ(ah, 0x7840), AR9285_AN_RXTXBB1_SPARE9); 941 reg_field = MS(REG_READ(ah, 0x7840), AR9285_AN_RXTXBB1_SPARE9);
929 regVal |= (reg_field << (19 + i)); 942 regVal |= (reg_field << (19 + i));
diff --git a/drivers/net/wireless/ath/ath9k/calib.h b/drivers/net/wireless/ath/ath9k/calib.h
index 019bcbba40ed..9028ab193e42 100644
--- a/drivers/net/wireless/ath/ath9k/calib.h
+++ b/drivers/net/wireless/ath/ath9k/calib.h
@@ -28,6 +28,7 @@ extern const struct ath9k_percal_data adc_init_dc_cal;
28#define AR_PHY_CCA_MAX_AR5416_GOOD_VALUE -85 28#define AR_PHY_CCA_MAX_AR5416_GOOD_VALUE -85
29#define AR_PHY_CCA_MAX_AR9280_GOOD_VALUE -112 29#define AR_PHY_CCA_MAX_AR9280_GOOD_VALUE -112
30#define AR_PHY_CCA_MAX_AR9285_GOOD_VALUE -118 30#define AR_PHY_CCA_MAX_AR9285_GOOD_VALUE -118
31#define AR_PHY_CCA_MAX_AR9287_GOOD_VALUE -118
31#define AR_PHY_CCA_MAX_HIGH_VALUE -62 32#define AR_PHY_CCA_MAX_HIGH_VALUE -62
32#define AR_PHY_CCA_MIN_BAD_VALUE -140 33#define AR_PHY_CCA_MIN_BAD_VALUE -140
33#define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT 3 34#define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT 3
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index ae7fb5dcb266..4071fc91da0a 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -509,6 +509,8 @@ static void ath9k_hw_def_set_board_values(struct ath_hw *ah,
509 REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE, 509 REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE,
510 eep->baseEepHeader.dacLpMode); 510 eep->baseEepHeader.dacLpMode);
511 511
512 udelay(100);
513
512 REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL, AR_PHY_FRAME_CTL_TX_CLIP, 514 REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL, AR_PHY_FRAME_CTL_TX_CLIP,
513 pModal->miscBits >> 2); 515 pModal->miscBits >> 2);
514 516
@@ -902,7 +904,7 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
902 u16 powerLimit) 904 u16 powerLimit)
903{ 905{
904#define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */ 906#define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */
905#define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10 /* 10*log10(3)*2 */ 907#define REDUCE_SCALED_POWER_BY_THREE_CHAIN 9 /* 10*log10(3)*2 */
906 908
907 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); 909 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
908 struct ar5416_eeprom_def *pEepData = &ah->eeprom.def; 910 struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index b6c6cca07812..ca7694caf364 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -842,7 +842,7 @@ static void ath9k_hw_init_mode_regs(struct ath_hw *ah)
842 842
843static void ath9k_hw_init_mode_gain_regs(struct ath_hw *ah) 843static void ath9k_hw_init_mode_gain_regs(struct ath_hw *ah)
844{ 844{
845 if (AR_SREV_9287_11(ah)) 845 if (AR_SREV_9287_11_OR_LATER(ah))
846 INIT_INI_ARRAY(&ah->iniModesRxGain, 846 INIT_INI_ARRAY(&ah->iniModesRxGain,
847 ar9287Modes_rx_gain_9287_1_1, 847 ar9287Modes_rx_gain_9287_1_1,
848 ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_1), 6); 848 ARRAY_SIZE(ar9287Modes_rx_gain_9287_1_1), 6);
@@ -853,7 +853,7 @@ static void ath9k_hw_init_mode_gain_regs(struct ath_hw *ah)
853 else if (AR_SREV_9280_20(ah)) 853 else if (AR_SREV_9280_20(ah))
854 ath9k_hw_init_rxgain_ini(ah); 854 ath9k_hw_init_rxgain_ini(ah);
855 855
856 if (AR_SREV_9287_11(ah)) { 856 if (AR_SREV_9287_11_OR_LATER(ah)) {
857 INIT_INI_ARRAY(&ah->iniModesTxGain, 857 INIT_INI_ARRAY(&ah->iniModesTxGain,
858 ar9287Modes_tx_gain_9287_1_1, 858 ar9287Modes_tx_gain_9287_1_1,
859 ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_1), 6); 859 ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_1), 6);
@@ -965,7 +965,7 @@ int ath9k_hw_init(struct ath_hw *ah)
965 ath9k_hw_init_mode_regs(ah); 965 ath9k_hw_init_mode_regs(ah);
966 966
967 if (ah->is_pciexpress) 967 if (ah->is_pciexpress)
968 ath9k_hw_configpcipowersave(ah, 0); 968 ath9k_hw_configpcipowersave(ah, 0, 0);
969 else 969 else
970 ath9k_hw_disablepcie(ah); 970 ath9k_hw_disablepcie(ah);
971 971
@@ -1273,6 +1273,15 @@ static void ath9k_hw_override_ini(struct ath_hw *ah,
1273 */ 1273 */
1274 REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); 1274 REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
1275 1275
1276 if (AR_SREV_9280_10_OR_LATER(ah)) {
1277 val = REG_READ(ah, AR_PCU_MISC_MODE2) &
1278 (~AR_PCU_MISC_MODE2_HWWAR1);
1279
1280 if (AR_SREV_9287_10_OR_LATER(ah))
1281 val = val & (~AR_PCU_MISC_MODE2_HWWAR2);
1282
1283 REG_WRITE(ah, AR_PCU_MISC_MODE2, val);
1284 }
1276 1285
1277 if (!AR_SREV_5416_20_OR_LATER(ah) || 1286 if (!AR_SREV_5416_20_OR_LATER(ah) ||
1278 AR_SREV_9280_10_OR_LATER(ah)) 1287 AR_SREV_9280_10_OR_LATER(ah))
@@ -1784,7 +1793,7 @@ static void ath9k_hw_set_regs(struct ath_hw *ah, struct ath9k_channel *chan,
1784static bool ath9k_hw_chip_reset(struct ath_hw *ah, 1793static bool ath9k_hw_chip_reset(struct ath_hw *ah,
1785 struct ath9k_channel *chan) 1794 struct ath9k_channel *chan)
1786{ 1795{
1787 if (OLC_FOR_AR9280_20_LATER) { 1796 if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) {
1788 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) 1797 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON))
1789 return false; 1798 return false;
1790 } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM)) 1799 } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))
@@ -2338,6 +2347,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
2338 struct ath9k_channel *curchan = ah->curchan; 2347 struct ath9k_channel *curchan = ah->curchan;
2339 u32 saveDefAntenna; 2348 u32 saveDefAntenna;
2340 u32 macStaId1; 2349 u32 macStaId1;
2350 u64 tsf = 0;
2341 int i, rx_chainmask, r; 2351 int i, rx_chainmask, r;
2342 2352
2343 ah->extprotspacing = sc->ht_extprotspacing; 2353 ah->extprotspacing = sc->ht_extprotspacing;
@@ -2347,7 +2357,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
2347 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) 2357 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
2348 return -EIO; 2358 return -EIO;
2349 2359
2350 if (curchan) 2360 if (curchan && !ah->chip_fullsleep)
2351 ath9k_hw_getnf(ah, curchan); 2361 ath9k_hw_getnf(ah, curchan);
2352 2362
2353 if (bChannelChange && 2363 if (bChannelChange &&
@@ -2356,8 +2366,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
2356 (chan->channel != ah->curchan->channel) && 2366 (chan->channel != ah->curchan->channel) &&
2357 ((chan->channelFlags & CHANNEL_ALL) == 2367 ((chan->channelFlags & CHANNEL_ALL) ==
2358 (ah->curchan->channelFlags & CHANNEL_ALL)) && 2368 (ah->curchan->channelFlags & CHANNEL_ALL)) &&
2359 (!AR_SREV_9280(ah) || (!IS_CHAN_A_5MHZ_SPACED(chan) && 2369 !(AR_SREV_9280(ah) || IS_CHAN_A_5MHZ_SPACED(chan) ||
2360 !IS_CHAN_A_5MHZ_SPACED(ah->curchan)))) { 2370 IS_CHAN_A_5MHZ_SPACED(ah->curchan))) {
2361 2371
2362 if (ath9k_hw_channel_change(ah, chan, sc->tx_chan_width)) { 2372 if (ath9k_hw_channel_change(ah, chan, sc->tx_chan_width)) {
2363 ath9k_hw_loadnf(ah, ah->curchan); 2373 ath9k_hw_loadnf(ah, ah->curchan);
@@ -2372,6 +2382,10 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
2372 2382
2373 macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B; 2383 macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B;
2374 2384
2385 /* For chips on which RTC reset is done, save TSF before it gets cleared */
2386 if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
2387 tsf = ath9k_hw_gettsf64(ah);
2388
2375 saveLedState = REG_READ(ah, AR_CFG_LED) & 2389 saveLedState = REG_READ(ah, AR_CFG_LED) &
2376 (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL | 2390 (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL |
2377 AR_CFG_LED_BLINK_THRESH_SEL | AR_CFG_LED_BLINK_SLOW); 2391 AR_CFG_LED_BLINK_THRESH_SEL | AR_CFG_LED_BLINK_SLOW);
@@ -2398,6 +2412,10 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
2398 udelay(50); 2412 udelay(50);
2399 } 2413 }
2400 2414
2415 /* Restore TSF */
2416 if (tsf && AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
2417 ath9k_hw_settsf64(ah, tsf);
2418
2401 if (AR_SREV_9280_10_OR_LATER(ah)) 2419 if (AR_SREV_9280_10_OR_LATER(ah))
2402 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE); 2420 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
2403 2421
@@ -3005,9 +3023,10 @@ void ath9k_ps_restore(struct ath_softc *sc)
3005 * Programming the SerDes must go through the same 288 bit serial shift 3023 * Programming the SerDes must go through the same 288 bit serial shift
3006 * register as the other analog registers. Hence the 9 writes. 3024 * register as the other analog registers. Hence the 9 writes.
3007 */ 3025 */
3008void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore) 3026void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off)
3009{ 3027{
3010 u8 i; 3028 u8 i;
3029 u32 val;
3011 3030
3012 if (ah->is_pciexpress != true) 3031 if (ah->is_pciexpress != true)
3013 return; 3032 return;
@@ -3017,84 +3036,113 @@ void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore)
3017 return; 3036 return;
3018 3037
3019 /* Nothing to do on restore for 11N */ 3038 /* Nothing to do on restore for 11N */
3020 if (restore) 3039 if (!restore) {
3021 return; 3040 if (AR_SREV_9280_20_OR_LATER(ah)) {
3041 /*
3042 * AR9280 2.0 or later chips use SerDes values from the
3043 * initvals.h initialized depending on chipset during
3044 * ath9k_hw_init()
3045 */
3046 for (i = 0; i < ah->iniPcieSerdes.ia_rows; i++) {
3047 REG_WRITE(ah, INI_RA(&ah->iniPcieSerdes, i, 0),
3048 INI_RA(&ah->iniPcieSerdes, i, 1));
3049 }
3050 } else if (AR_SREV_9280(ah) &&
3051 (ah->hw_version.macRev == AR_SREV_REVISION_9280_10)) {
3052 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00);
3053 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
3054
3055 /* RX shut off when elecidle is asserted */
3056 REG_WRITE(ah, AR_PCIE_SERDES, 0xa8000019);
3057 REG_WRITE(ah, AR_PCIE_SERDES, 0x13160820);
3058 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980560);
3059
3060 /* Shut off CLKREQ active in L1 */
3061 if (ah->config.pcie_clock_req)
3062 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffc);
3063 else
3064 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffd);
3022 3065
3023 if (AR_SREV_9280_20_OR_LATER(ah)) { 3066 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
3024 /* 3067 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
3025 * AR9280 2.0 or later chips use SerDes values from the 3068 REG_WRITE(ah, AR_PCIE_SERDES, 0x00043007);
3026 * initvals.h initialized depending on chipset during
3027 * ath9k_hw_init()
3028 */
3029 for (i = 0; i < ah->iniPcieSerdes.ia_rows; i++) {
3030 REG_WRITE(ah, INI_RA(&ah->iniPcieSerdes, i, 0),
3031 INI_RA(&ah->iniPcieSerdes, i, 1));
3032 }
3033 } else if (AR_SREV_9280(ah) &&
3034 (ah->hw_version.macRev == AR_SREV_REVISION_9280_10)) {
3035 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fd00);
3036 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
3037 3069
3038 /* RX shut off when elecidle is asserted */ 3070 /* Load the new settings */
3039 REG_WRITE(ah, AR_PCIE_SERDES, 0xa8000019); 3071 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
3040 REG_WRITE(ah, AR_PCIE_SERDES, 0x13160820);
3041 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980560);
3042 3072
3043 /* Shut off CLKREQ active in L1 */ 3073 } else {
3044 if (ah->config.pcie_clock_req) 3074 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
3045 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffc); 3075 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
3046 else
3047 REG_WRITE(ah, AR_PCIE_SERDES, 0x401deffd);
3048
3049 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
3050 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
3051 REG_WRITE(ah, AR_PCIE_SERDES, 0x00043007);
3052 3076
3053 /* Load the new settings */ 3077 /* RX shut off when elecidle is asserted */
3054 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); 3078 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039);
3079 REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824);
3080 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579);
3055 3081
3056 } else { 3082 /*
3057 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); 3083 * Ignore ah->ah_config.pcie_clock_req setting for
3058 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924); 3084 * pre-AR9280 11n
3085 */
3086 REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff);
3059 3087
3060 /* RX shut off when elecidle is asserted */ 3088 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
3061 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000039); 3089 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
3062 REG_WRITE(ah, AR_PCIE_SERDES, 0x53160824); 3090 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007);
3063 REG_WRITE(ah, AR_PCIE_SERDES, 0xe5980579);
3064 3091
3065 /* 3092 /* Load the new settings */
3066 * Ignore ah->ah_config.pcie_clock_req setting for 3093 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
3067 * pre-AR9280 11n 3094 }
3068 */
3069 REG_WRITE(ah, AR_PCIE_SERDES, 0x001defff);
3070 3095
3071 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40); 3096 udelay(1000);
3072 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
3073 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e3007);
3074 3097
3075 /* Load the new settings */ 3098 /* set bit 19 to allow forcing of pcie core into L1 state */
3076 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000); 3099 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
3077 }
3078 3100
3079 udelay(1000); 3101 /* Several PCIe massages to ensure proper behaviour */
3102 if (ah->config.pcie_waen) {
3103 val = ah->config.pcie_waen;
3104 if (!power_off)
3105 val &= (~AR_WA_D3_L1_DISABLE);
3106 } else {
3107 if (AR_SREV_9285(ah) || AR_SREV_9271(ah) ||
3108 AR_SREV_9287(ah)) {
3109 val = AR9285_WA_DEFAULT;
3110 if (!power_off)
3111 val &= (~AR_WA_D3_L1_DISABLE);
3112 } else if (AR_SREV_9280(ah)) {
3113 /*
3114 * On AR9280 chips bit 22 of 0x4004 needs to be
3115 * set otherwise card may disappear.
3116 */
3117 val = AR9280_WA_DEFAULT;
3118 if (!power_off)
3119 val &= (~AR_WA_D3_L1_DISABLE);
3120 } else
3121 val = AR_WA_DEFAULT;
3122 }
3080 3123
3081 /* set bit 19 to allow forcing of pcie core into L1 state */ 3124 REG_WRITE(ah, AR_WA, val);
3082 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); 3125 }
3083 3126
3084 /* Several PCIe massages to ensure proper behaviour */ 3127 if (power_off) {
3085 if (ah->config.pcie_waen) {
3086 REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
3087 } else {
3088 if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || AR_SREV_9287(ah))
3089 REG_WRITE(ah, AR_WA, AR9285_WA_DEFAULT);
3090 /* 3128 /*
3091 * On AR9280 chips bit 22 of 0x4004 needs to be set to 3129 * Set PCIe workaround bits
3092 * otherwise card may disappear. 3130 * bit 14 in WA register (disable L1) should only
3131 * be set when device enters D3 and be cleared
3132 * when device comes back to D0.
3093 */ 3133 */
3094 else if (AR_SREV_9280(ah)) 3134 if (ah->config.pcie_waen) {
3095 REG_WRITE(ah, AR_WA, AR9280_WA_DEFAULT); 3135 if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE)
3096 else 3136 REG_SET_BIT(ah, AR_WA, AR_WA_D3_L1_DISABLE);
3097 REG_WRITE(ah, AR_WA, AR_WA_DEFAULT); 3137 } else {
3138 if (((AR_SREV_9285(ah) || AR_SREV_9271(ah) ||
3139 AR_SREV_9287(ah)) &&
3140 (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) ||
3141 (AR_SREV_9280(ah) &&
3142 (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) {
3143 REG_SET_BIT(ah, AR_WA, AR_WA_D3_L1_DISABLE);
3144 }
3145 }
3098 } 3146 }
3099} 3147}
3100 3148
@@ -3652,15 +3700,7 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
3652 } 3700 }
3653#endif 3701#endif
3654 3702
3655 if ((ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI) || 3703 pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP;
3656 (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE) ||
3657 (ah->hw_version.macVersion == AR_SREV_VERSION_9160) ||
3658 (ah->hw_version.macVersion == AR_SREV_VERSION_9100) ||
3659 (ah->hw_version.macVersion == AR_SREV_VERSION_9280) ||
3660 (ah->hw_version.macVersion == AR_SREV_VERSION_9285))
3661 pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP;
3662 else
3663 pCap->hw_caps |= ATH9K_HW_CAP_AUTOSLEEP;
3664 3704
3665 if (AR_SREV_9280(ah) || AR_SREV_9285(ah)) 3705 if (AR_SREV_9280(ah) || AR_SREV_9285(ah))
3666 pCap->hw_caps &= ~ATH9K_HW_CAP_4KB_SPLITTRANS; 3706 pCap->hw_caps &= ~ATH9K_HW_CAP_4KB_SPLITTRANS;
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 9106a0b537dd..b89234571829 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -106,7 +106,7 @@
106#define AH_TSF_WRITE_TIMEOUT 100 /* (us) */ 106#define AH_TSF_WRITE_TIMEOUT 100 /* (us) */
107#define AH_TIME_QUANTUM 10 107#define AH_TIME_QUANTUM 10
108#define AR_KEYTABLE_SIZE 128 108#define AR_KEYTABLE_SIZE 128
109#define POWER_UP_TIME 200000 109#define POWER_UP_TIME 10000
110#define SPUR_RSSI_THRESH 40 110#define SPUR_RSSI_THRESH 40
111 111
112#define CAB_TIMEOUT_VAL 10 112#define CAB_TIMEOUT_VAL 10
@@ -650,7 +650,7 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
650 const struct ath9k_beacon_state *bs); 650 const struct ath9k_beacon_state *bs);
651bool ath9k_hw_setpower(struct ath_hw *ah, 651bool ath9k_hw_setpower(struct ath_hw *ah,
652 enum ath9k_power_mode mode); 652 enum ath9k_power_mode mode);
653void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore); 653void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off);
654 654
655/* Interrupt Handling */ 655/* Interrupt Handling */
656bool ath9k_hw_intrpend(struct ath_hw *ah); 656bool ath9k_hw_intrpend(struct ath_hw *ah);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 3dc7b5a13e64..52bed89063d4 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1131,7 +1131,7 @@ void ath_radio_enable(struct ath_softc *sc)
1131 int r; 1131 int r;
1132 1132
1133 ath9k_ps_wakeup(sc); 1133 ath9k_ps_wakeup(sc);
1134 ath9k_hw_configpcipowersave(ah, 0); 1134 ath9k_hw_configpcipowersave(ah, 0, 0);
1135 1135
1136 if (!ah->curchan) 1136 if (!ah->curchan)
1137 ah->curchan = ath_get_curchannel(sc, sc->hw); 1137 ah->curchan = ath_get_curchannel(sc, sc->hw);
@@ -1202,7 +1202,7 @@ void ath_radio_disable(struct ath_softc *sc)
1202 spin_unlock_bh(&sc->sc_resetlock); 1202 spin_unlock_bh(&sc->sc_resetlock);
1203 1203
1204 ath9k_hw_phy_disable(ah); 1204 ath9k_hw_phy_disable(ah);
1205 ath9k_hw_configpcipowersave(ah, 1); 1205 ath9k_hw_configpcipowersave(ah, 1, 1);
1206 ath9k_ps_restore(sc); 1206 ath9k_ps_restore(sc);
1207 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP); 1207 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
1208} 1208}
@@ -1226,11 +1226,6 @@ static void ath9k_rfkill_poll_state(struct ieee80211_hw *hw)
1226 bool blocked = !!ath_is_rfkill_set(sc); 1226 bool blocked = !!ath_is_rfkill_set(sc);
1227 1227
1228 wiphy_rfkill_set_hw_state(hw->wiphy, blocked); 1228 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
1229
1230 if (blocked)
1231 ath_radio_disable(sc);
1232 else
1233 ath_radio_enable(sc);
1234} 1229}
1235 1230
1236static void ath_start_rfkill_poll(struct ath_softc *sc) 1231static void ath_start_rfkill_poll(struct ath_softc *sc)
@@ -1260,6 +1255,7 @@ void ath_detach(struct ath_softc *sc)
1260 DPRINTF(sc, ATH_DBG_CONFIG, "Detach ATH hw\n"); 1255 DPRINTF(sc, ATH_DBG_CONFIG, "Detach ATH hw\n");
1261 1256
1262 ath_deinit_leds(sc); 1257 ath_deinit_leds(sc);
1258 wiphy_rfkill_stop_polling(sc->hw->wiphy);
1263 1259
1264 for (i = 0; i < sc->num_sec_wiphy; i++) { 1260 for (i = 0; i < sc->num_sec_wiphy; i++) {
1265 struct ath_wiphy *aphy = sc->sec_wiphy[i]; 1261 struct ath_wiphy *aphy = sc->sec_wiphy[i];
@@ -1942,7 +1938,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
1942 init_channel = ath_get_curchannel(sc, hw); 1938 init_channel = ath_get_curchannel(sc, hw);
1943 1939
1944 /* Reset SERDES registers */ 1940 /* Reset SERDES registers */
1945 ath9k_hw_configpcipowersave(sc->sc_ah, 0); 1941 ath9k_hw_configpcipowersave(sc->sc_ah, 0, 0);
1946 1942
1947 /* 1943 /*
1948 * The basic interface to setting the hardware in a good 1944 * The basic interface to setting the hardware in a good
@@ -2166,11 +2162,9 @@ static void ath9k_stop(struct ieee80211_hw *hw)
2166 } else 2162 } else
2167 sc->rx.rxlink = NULL; 2163 sc->rx.rxlink = NULL;
2168 2164
2169 wiphy_rfkill_stop_polling(sc->hw->wiphy);
2170
2171 /* disable HAL and put h/w to sleep */ 2165 /* disable HAL and put h/w to sleep */
2172 ath9k_hw_disable(sc->sc_ah); 2166 ath9k_hw_disable(sc->sc_ah);
2173 ath9k_hw_configpcipowersave(sc->sc_ah, 1); 2167 ath9k_hw_configpcipowersave(sc->sc_ah, 1, 1);
2174 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP); 2168 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
2175 2169
2176 sc->sc_flags |= SC_OP_INVALID; 2170 sc->sc_flags |= SC_OP_INVALID;
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index e5c29eb86e80..d83b77f821e9 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -676,8 +676,9 @@
676#define AR_RC_HOSTIF 0x00000100 676#define AR_RC_HOSTIF 0x00000100
677 677
678#define AR_WA 0x4004 678#define AR_WA 0x4004
679#define AR_WA_D3_L1_DISABLE (1 << 14)
679#define AR9285_WA_DEFAULT 0x004a05cb 680#define AR9285_WA_DEFAULT 0x004a05cb
680#define AR9280_WA_DEFAULT 0x0040073f 681#define AR9280_WA_DEFAULT 0x0040073b
681#define AR_WA_DEFAULT 0x0000073f 682#define AR_WA_DEFAULT 0x0000073f
682 683
683 684
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig
index 83e38134accb..54ea61c15d8b 100644
--- a/drivers/net/wireless/b43/Kconfig
+++ b/drivers/net/wireless/b43/Kconfig
@@ -61,11 +61,28 @@ config B43_PCMCIA
61 61
62 If unsure, say N. 62 If unsure, say N.
63 63
64config B43_SDIO
65 bool "Broadcom 43xx SDIO device support (EXPERIMENTAL)"
66 depends on B43 && SSB_SDIOHOST_POSSIBLE && EXPERIMENTAL
67 select SSB_SDIOHOST
68 ---help---
69 Broadcom 43xx device support for Soft-MAC SDIO devices.
70
71 With this config option you can drive Soft-MAC b43 cards with a
72 Secure Digital I/O interface.
73 This includes the WLAN daughter card found on the Nintendo Wii
74 video game console.
75 Note that this does not support Broadcom 43xx Full-MAC devices.
76
77 It's safe to select Y here, even if you don't have a B43 SDIO device.
78
79 If unsure, say N.
80
64# Data transfers to the device via PIO 81# Data transfers to the device via PIO
65# This is only needed on PCMCIA devices. All others can do DMA properly. 82# This is only needed on PCMCIA and SDIO devices. All others can do DMA properly.
66config B43_PIO 83config B43_PIO
67 bool 84 bool
68 depends on B43 && (B43_PCMCIA || B43_FORCE_PIO) 85 depends on B43 && (B43_SDIO || B43_PCMCIA || B43_FORCE_PIO)
69 select SSB_BLOCKIO 86 select SSB_BLOCKIO
70 default y 87 default y
71 88
diff --git a/drivers/net/wireless/b43/Makefile b/drivers/net/wireless/b43/Makefile
index da379f4b0c3a..84772a2542dc 100644
--- a/drivers/net/wireless/b43/Makefile
+++ b/drivers/net/wireless/b43/Makefile
@@ -16,6 +16,7 @@ b43-$(CONFIG_B43_PIO) += pio.o
16b43-y += rfkill.o 16b43-y += rfkill.o
17b43-$(CONFIG_B43_LEDS) += leds.o 17b43-$(CONFIG_B43_LEDS) += leds.o
18b43-$(CONFIG_B43_PCMCIA) += pcmcia.o 18b43-$(CONFIG_B43_PCMCIA) += pcmcia.o
19b43-$(CONFIG_B43_SDIO) += sdio.o
19b43-$(CONFIG_B43_DEBUG) += debugfs.o 20b43-$(CONFIG_B43_DEBUG) += debugfs.o
20 21
21obj-$(CONFIG_B43) += b43.o 22obj-$(CONFIG_B43) += b43.o
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 09cfe68537b6..fa1549a03c71 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -629,13 +629,6 @@ struct b43_wl {
629 * from the mac80211 subsystem. */ 629 * from the mac80211 subsystem. */
630 u16 mac80211_initially_registered_queues; 630 u16 mac80211_initially_registered_queues;
631 631
632 /* R/W lock for data transmission.
633 * Transmissions on 2+ queues can run concurrently, but somebody else
634 * might sync with TX by write_lock_irqsave()'ing. */
635 rwlock_t tx_lock;
636 /* Lock for LEDs access. */
637 spinlock_t leds_lock;
638
639 /* We can only have one operating interface (802.11 core) 632 /* We can only have one operating interface (802.11 core)
640 * at a time. General information about this interface follows. 633 * at a time. General information about this interface follows.
641 */ 634 */
@@ -686,6 +679,9 @@ struct b43_wl {
686 struct work_struct tx_work; 679 struct work_struct tx_work;
687 /* Queue of packets to be transmitted. */ 680 /* Queue of packets to be transmitted. */
688 struct sk_buff_head tx_queue; 681 struct sk_buff_head tx_queue;
682
683 /* The device LEDs. */
684 struct b43_leds leds;
689}; 685};
690 686
691/* The type of the firmware file. */ 687/* The type of the firmware file. */
@@ -768,13 +764,10 @@ struct b43_wldev {
768 /* The device initialization status. 764 /* The device initialization status.
769 * Use b43_status() to query. */ 765 * Use b43_status() to query. */
770 atomic_t __init_status; 766 atomic_t __init_status;
771 /* Saved init status for handling suspend. */
772 int suspend_init_status;
773 767
774 bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */ 768 bool bad_frames_preempt; /* Use "Bad Frames Preemption" (default off) */
775 bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */ 769 bool dfq_valid; /* Directed frame queue valid (IBSS PS mode, ATIM) */
776 bool radio_hw_enable; /* saved state of radio hardware enabled state */ 770 bool radio_hw_enable; /* saved state of radio hardware enabled state */
777 bool suspend_in_progress; /* TRUE, if we are in a suspend/resume cycle */
778 bool qos_enabled; /* TRUE, if QoS is used. */ 771 bool qos_enabled; /* TRUE, if QoS is used. */
779 bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */ 772 bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
780 773
@@ -794,12 +787,6 @@ struct b43_wldev {
794 /* Various statistics about the physical device. */ 787 /* Various statistics about the physical device. */
795 struct b43_stats stats; 788 struct b43_stats stats;
796 789
797 /* The device LEDs. */
798 struct b43_led led_tx;
799 struct b43_led led_rx;
800 struct b43_led led_assoc;
801 struct b43_led led_radio;
802
803 /* Reason code of the last interrupt. */ 790 /* Reason code of the last interrupt. */
804 u32 irq_reason; 791 u32 irq_reason;
805 u32 dma_reason[6]; 792 u32 dma_reason[6];
@@ -830,6 +817,10 @@ struct b43_wldev {
830 /* Debugging stuff follows. */ 817 /* Debugging stuff follows. */
831#ifdef CONFIG_B43_DEBUG 818#ifdef CONFIG_B43_DEBUG
832 struct b43_dfsentry *dfsentry; 819 struct b43_dfsentry *dfsentry;
820 unsigned int irq_count;
821 unsigned int irq_bit_count[32];
822 unsigned int tx_count;
823 unsigned int rx_count;
833#endif 824#endif
834}; 825};
835 826
diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index 8f64943e3f60..80b19a44a407 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -689,6 +689,7 @@ static void b43_add_dynamic_debug(struct b43_wldev *dev)
689 add_dyn_dbg("debug_lo", B43_DBG_LO, 0); 689 add_dyn_dbg("debug_lo", B43_DBG_LO, 0);
690 add_dyn_dbg("debug_firmware", B43_DBG_FIRMWARE, 0); 690 add_dyn_dbg("debug_firmware", B43_DBG_FIRMWARE, 0);
691 add_dyn_dbg("debug_keys", B43_DBG_KEYS, 0); 691 add_dyn_dbg("debug_keys", B43_DBG_KEYS, 0);
692 add_dyn_dbg("debug_verbose_stats", B43_DBG_VERBOSESTATS, 0);
692 693
693#undef add_dyn_dbg 694#undef add_dyn_dbg
694} 695}
diff --git a/drivers/net/wireless/b43/debugfs.h b/drivers/net/wireless/b43/debugfs.h
index e47b4b488b04..822aad8842f4 100644
--- a/drivers/net/wireless/b43/debugfs.h
+++ b/drivers/net/wireless/b43/debugfs.h
@@ -13,6 +13,7 @@ enum b43_dyndbg { /* Dynamic debugging features */
13 B43_DBG_LO, 13 B43_DBG_LO,
14 B43_DBG_FIRMWARE, 14 B43_DBG_FIRMWARE,
15 B43_DBG_KEYS, 15 B43_DBG_KEYS,
16 B43_DBG_VERBOSESTATS,
16 __B43_NR_DYNDBG, 17 __B43_NR_DYNDBG,
17}; 18};
18 19
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index a467ee260a19..8701034569fa 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -1428,9 +1428,9 @@ void b43_dma_handle_txstatus(struct b43_wldev *dev,
1428 ring->nr_failed_tx_packets++; 1428 ring->nr_failed_tx_packets++;
1429 ring->nr_total_packet_tries += status->frame_count; 1429 ring->nr_total_packet_tries += status->frame_count;
1430#endif /* DEBUG */ 1430#endif /* DEBUG */
1431 ieee80211_tx_status_irqsafe(dev->wl->hw, meta->skb); 1431 ieee80211_tx_status(dev->wl->hw, meta->skb);
1432 1432
1433 /* skb is freed by ieee80211_tx_status_irqsafe() */ 1433 /* skb is freed by ieee80211_tx_status() */
1434 meta->skb = NULL; 1434 meta->skb = NULL;
1435 } else { 1435 } else {
1436 /* No need to call free_descriptor_buffer here, as 1436 /* No need to call free_descriptor_buffer here, as
diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c
index c8b317094c31..fbe3d4f62ce2 100644
--- a/drivers/net/wireless/b43/leds.c
+++ b/drivers/net/wireless/b43/leds.c
@@ -34,57 +34,88 @@
34static void b43_led_turn_on(struct b43_wldev *dev, u8 led_index, 34static void b43_led_turn_on(struct b43_wldev *dev, u8 led_index,
35 bool activelow) 35 bool activelow)
36{ 36{
37 struct b43_wl *wl = dev->wl;
38 unsigned long flags;
39 u16 ctl; 37 u16 ctl;
40 38
41 spin_lock_irqsave(&wl->leds_lock, flags);
42 ctl = b43_read16(dev, B43_MMIO_GPIO_CONTROL); 39 ctl = b43_read16(dev, B43_MMIO_GPIO_CONTROL);
43 if (activelow) 40 if (activelow)
44 ctl &= ~(1 << led_index); 41 ctl &= ~(1 << led_index);
45 else 42 else
46 ctl |= (1 << led_index); 43 ctl |= (1 << led_index);
47 b43_write16(dev, B43_MMIO_GPIO_CONTROL, ctl); 44 b43_write16(dev, B43_MMIO_GPIO_CONTROL, ctl);
48 spin_unlock_irqrestore(&wl->leds_lock, flags);
49} 45}
50 46
51static void b43_led_turn_off(struct b43_wldev *dev, u8 led_index, 47static void b43_led_turn_off(struct b43_wldev *dev, u8 led_index,
52 bool activelow) 48 bool activelow)
53{ 49{
54 struct b43_wl *wl = dev->wl;
55 unsigned long flags;
56 u16 ctl; 50 u16 ctl;
57 51
58 spin_lock_irqsave(&wl->leds_lock, flags);
59 ctl = b43_read16(dev, B43_MMIO_GPIO_CONTROL); 52 ctl = b43_read16(dev, B43_MMIO_GPIO_CONTROL);
60 if (activelow) 53 if (activelow)
61 ctl |= (1 << led_index); 54 ctl |= (1 << led_index);
62 else 55 else
63 ctl &= ~(1 << led_index); 56 ctl &= ~(1 << led_index);
64 b43_write16(dev, B43_MMIO_GPIO_CONTROL, ctl); 57 b43_write16(dev, B43_MMIO_GPIO_CONTROL, ctl);
65 spin_unlock_irqrestore(&wl->leds_lock, flags);
66} 58}
67 59
68/* Callback from the LED subsystem. */ 60static void b43_led_update(struct b43_wldev *dev,
69static void b43_led_brightness_set(struct led_classdev *led_dev, 61 struct b43_led *led)
70 enum led_brightness brightness)
71{ 62{
72 struct b43_led *led = container_of(led_dev, struct b43_led, led_dev);
73 struct b43_wldev *dev = led->dev;
74 bool radio_enabled; 63 bool radio_enabled;
64 bool turn_on;
75 65
76 if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) 66 if (!led->wl)
77 return; 67 return;
78 68
79 /* Checking the radio-enabled status here is slightly racy,
80 * but we want to avoid the locking overhead and we don't care
81 * whether the LED has the wrong state for a second. */
82 radio_enabled = (dev->phy.radio_on && dev->radio_hw_enable); 69 radio_enabled = (dev->phy.radio_on && dev->radio_hw_enable);
83 70
84 if (brightness == LED_OFF || !radio_enabled) 71 /* The led->state read is racy, but we don't care. In case we raced
85 b43_led_turn_off(dev, led->index, led->activelow); 72 * with the brightness_set handler, we will be called again soon
73 * to fixup our state. */
74 if (radio_enabled)
75 turn_on = atomic_read(&led->state) != LED_OFF;
86 else 76 else
77 turn_on = 0;
78 if (turn_on == led->hw_state)
79 return;
80 led->hw_state = turn_on;
81
82 if (turn_on)
87 b43_led_turn_on(dev, led->index, led->activelow); 83 b43_led_turn_on(dev, led->index, led->activelow);
84 else
85 b43_led_turn_off(dev, led->index, led->activelow);
86}
87
88static void b43_leds_work(struct work_struct *work)
89{
90 struct b43_leds *leds = container_of(work, struct b43_leds, work);
91 struct b43_wl *wl = container_of(leds, struct b43_wl, leds);
92 struct b43_wldev *dev;
93
94 mutex_lock(&wl->mutex);
95 dev = wl->current_dev;
96 if (unlikely(!dev || b43_status(dev) < B43_STAT_STARTED))
97 goto out_unlock;
98
99 b43_led_update(dev, &wl->leds.led_tx);
100 b43_led_update(dev, &wl->leds.led_rx);
101 b43_led_update(dev, &wl->leds.led_radio);
102 b43_led_update(dev, &wl->leds.led_assoc);
103
104out_unlock:
105 mutex_unlock(&wl->mutex);
106}
107
108/* Callback from the LED subsystem. */
109static void b43_led_brightness_set(struct led_classdev *led_dev,
110 enum led_brightness brightness)
111{
112 struct b43_led *led = container_of(led_dev, struct b43_led, led_dev);
113 struct b43_wl *wl = led->wl;
114
115 if (likely(!wl->leds.stop)) {
116 atomic_set(&led->state, brightness);
117 ieee80211_queue_work(wl->hw, &wl->leds.work);
118 }
88} 119}
89 120
90static int b43_register_led(struct b43_wldev *dev, struct b43_led *led, 121static int b43_register_led(struct b43_wldev *dev, struct b43_led *led,
@@ -93,15 +124,15 @@ static int b43_register_led(struct b43_wldev *dev, struct b43_led *led,
93{ 124{
94 int err; 125 int err;
95 126
96 b43_led_turn_off(dev, led_index, activelow); 127 if (led->wl)
97 if (led->dev)
98 return -EEXIST; 128 return -EEXIST;
99 if (!default_trigger) 129 if (!default_trigger)
100 return -EINVAL; 130 return -EINVAL;
101 led->dev = dev; 131 led->wl = dev->wl;
102 led->index = led_index; 132 led->index = led_index;
103 led->activelow = activelow; 133 led->activelow = activelow;
104 strncpy(led->name, name, sizeof(led->name)); 134 strncpy(led->name, name, sizeof(led->name));
135 atomic_set(&led->state, 0);
105 136
106 led->led_dev.name = led->name; 137 led->led_dev.name = led->name;
107 led->led_dev.default_trigger = default_trigger; 138 led->led_dev.default_trigger = default_trigger;
@@ -110,19 +141,19 @@ static int b43_register_led(struct b43_wldev *dev, struct b43_led *led,
110 err = led_classdev_register(dev->dev->dev, &led->led_dev); 141 err = led_classdev_register(dev->dev->dev, &led->led_dev);
111 if (err) { 142 if (err) {
112 b43warn(dev->wl, "LEDs: Failed to register %s\n", name); 143 b43warn(dev->wl, "LEDs: Failed to register %s\n", name);
113 led->dev = NULL; 144 led->wl = NULL;
114 return err; 145 return err;
115 } 146 }
147
116 return 0; 148 return 0;
117} 149}
118 150
119static void b43_unregister_led(struct b43_led *led) 151static void b43_unregister_led(struct b43_led *led)
120{ 152{
121 if (!led->dev) 153 if (!led->wl)
122 return; 154 return;
123 led_classdev_unregister(&led->led_dev); 155 led_classdev_unregister(&led->led_dev);
124 b43_led_turn_off(led->dev, led->index, led->activelow); 156 led->wl = NULL;
125 led->dev = NULL;
126} 157}
127 158
128static void b43_map_led(struct b43_wldev *dev, 159static void b43_map_led(struct b43_wldev *dev,
@@ -137,24 +168,20 @@ static void b43_map_led(struct b43_wldev *dev,
137 * generic LED triggers. */ 168 * generic LED triggers. */
138 switch (behaviour) { 169 switch (behaviour) {
139 case B43_LED_INACTIVE: 170 case B43_LED_INACTIVE:
140 break;
141 case B43_LED_OFF: 171 case B43_LED_OFF:
142 b43_led_turn_off(dev, led_index, activelow);
143 break;
144 case B43_LED_ON: 172 case B43_LED_ON:
145 b43_led_turn_on(dev, led_index, activelow);
146 break; 173 break;
147 case B43_LED_ACTIVITY: 174 case B43_LED_ACTIVITY:
148 case B43_LED_TRANSFER: 175 case B43_LED_TRANSFER:
149 case B43_LED_APTRANSFER: 176 case B43_LED_APTRANSFER:
150 snprintf(name, sizeof(name), 177 snprintf(name, sizeof(name),
151 "b43-%s::tx", wiphy_name(hw->wiphy)); 178 "b43-%s::tx", wiphy_name(hw->wiphy));
152 b43_register_led(dev, &dev->led_tx, name, 179 b43_register_led(dev, &dev->wl->leds.led_tx, name,
153 ieee80211_get_tx_led_name(hw), 180 ieee80211_get_tx_led_name(hw),
154 led_index, activelow); 181 led_index, activelow);
155 snprintf(name, sizeof(name), 182 snprintf(name, sizeof(name),
156 "b43-%s::rx", wiphy_name(hw->wiphy)); 183 "b43-%s::rx", wiphy_name(hw->wiphy));
157 b43_register_led(dev, &dev->led_rx, name, 184 b43_register_led(dev, &dev->wl->leds.led_rx, name,
158 ieee80211_get_rx_led_name(hw), 185 ieee80211_get_rx_led_name(hw),
159 led_index, activelow); 186 led_index, activelow);
160 break; 187 break;
@@ -164,18 +191,15 @@ static void b43_map_led(struct b43_wldev *dev,
164 case B43_LED_MODE_BG: 191 case B43_LED_MODE_BG:
165 snprintf(name, sizeof(name), 192 snprintf(name, sizeof(name),
166 "b43-%s::radio", wiphy_name(hw->wiphy)); 193 "b43-%s::radio", wiphy_name(hw->wiphy));
167 b43_register_led(dev, &dev->led_radio, name, 194 b43_register_led(dev, &dev->wl->leds.led_radio, name,
168 ieee80211_get_radio_led_name(hw), 195 ieee80211_get_radio_led_name(hw),
169 led_index, activelow); 196 led_index, activelow);
170 /* Sync the RF-kill LED state with radio and switch states. */
171 if (dev->phy.radio_on && b43_is_hw_radio_enabled(dev))
172 b43_led_turn_on(dev, led_index, activelow);
173 break; 197 break;
174 case B43_LED_WEIRD: 198 case B43_LED_WEIRD:
175 case B43_LED_ASSOC: 199 case B43_LED_ASSOC:
176 snprintf(name, sizeof(name), 200 snprintf(name, sizeof(name),
177 "b43-%s::assoc", wiphy_name(hw->wiphy)); 201 "b43-%s::assoc", wiphy_name(hw->wiphy));
178 b43_register_led(dev, &dev->led_assoc, name, 202 b43_register_led(dev, &dev->wl->leds.led_assoc, name,
179 ieee80211_get_assoc_led_name(hw), 203 ieee80211_get_assoc_led_name(hw),
180 led_index, activelow); 204 led_index, activelow);
181 break; 205 break;
@@ -186,58 +210,150 @@ static void b43_map_led(struct b43_wldev *dev,
186 } 210 }
187} 211}
188 212
189void b43_leds_init(struct b43_wldev *dev) 213static void b43_led_get_sprominfo(struct b43_wldev *dev,
214 unsigned int led_index,
215 enum b43_led_behaviour *behaviour,
216 bool *activelow)
190{ 217{
191 struct ssb_bus *bus = dev->dev->bus; 218 struct ssb_bus *bus = dev->dev->bus;
192 u8 sprom[4]; 219 u8 sprom[4];
193 int i;
194 enum b43_led_behaviour behaviour;
195 bool activelow;
196 220
197 sprom[0] = bus->sprom.gpio0; 221 sprom[0] = bus->sprom.gpio0;
198 sprom[1] = bus->sprom.gpio1; 222 sprom[1] = bus->sprom.gpio1;
199 sprom[2] = bus->sprom.gpio2; 223 sprom[2] = bus->sprom.gpio2;
200 sprom[3] = bus->sprom.gpio3; 224 sprom[3] = bus->sprom.gpio3;
201 225
202 for (i = 0; i < 4; i++) { 226 if (sprom[led_index] == 0xFF) {
203 if (sprom[i] == 0xFF) { 227 /* There is no LED information in the SPROM
204 /* There is no LED information in the SPROM 228 * for this LED. Hardcode it here. */
205 * for this LED. Hardcode it here. */ 229 *activelow = 0;
206 activelow = 0; 230 switch (led_index) {
207 switch (i) { 231 case 0:
208 case 0: 232 *behaviour = B43_LED_ACTIVITY;
209 behaviour = B43_LED_ACTIVITY; 233 *activelow = 1;
210 activelow = 1; 234 if (bus->boardinfo.vendor == PCI_VENDOR_ID_COMPAQ)
211 if (bus->boardinfo.vendor == PCI_VENDOR_ID_COMPAQ) 235 *behaviour = B43_LED_RADIO_ALL;
212 behaviour = B43_LED_RADIO_ALL; 236 break;
213 break; 237 case 1:
214 case 1: 238 *behaviour = B43_LED_RADIO_B;
215 behaviour = B43_LED_RADIO_B; 239 if (bus->boardinfo.vendor == PCI_VENDOR_ID_ASUSTEK)
216 if (bus->boardinfo.vendor == PCI_VENDOR_ID_ASUSTEK) 240 *behaviour = B43_LED_ASSOC;
217 behaviour = B43_LED_ASSOC; 241 break;
218 break; 242 case 2:
219 case 2: 243 *behaviour = B43_LED_RADIO_A;
220 behaviour = B43_LED_RADIO_A; 244 break;
221 break; 245 case 3:
222 case 3: 246 *behaviour = B43_LED_OFF;
223 behaviour = B43_LED_OFF; 247 break;
224 break; 248 default:
225 default: 249 B43_WARN_ON(1);
226 B43_WARN_ON(1); 250 return;
227 return; 251 }
228 } 252 } else {
253 *behaviour = sprom[led_index] & B43_LED_BEHAVIOUR;
254 *activelow = !!(sprom[led_index] & B43_LED_ACTIVELOW);
255 }
256}
257
258void b43_leds_init(struct b43_wldev *dev)
259{
260 struct b43_led *led;
261 unsigned int i;
262 enum b43_led_behaviour behaviour;
263 bool activelow;
264
265 /* Sync the RF-kill LED state (if we have one) with radio and switch states. */
266 led = &dev->wl->leds.led_radio;
267 if (led->wl) {
268 if (dev->phy.radio_on && b43_is_hw_radio_enabled(dev)) {
269 b43_led_turn_on(dev, led->index, led->activelow);
270 led->hw_state = 1;
271 atomic_set(&led->state, 1);
229 } else { 272 } else {
230 behaviour = sprom[i] & B43_LED_BEHAVIOUR; 273 b43_led_turn_off(dev, led->index, led->activelow);
231 activelow = !!(sprom[i] & B43_LED_ACTIVELOW); 274 led->hw_state = 0;
275 atomic_set(&led->state, 0);
232 } 276 }
233 b43_map_led(dev, i, behaviour, activelow);
234 } 277 }
278
279 /* Initialize TX/RX/ASSOC leds */
280 led = &dev->wl->leds.led_tx;
281 if (led->wl) {
282 b43_led_turn_off(dev, led->index, led->activelow);
283 led->hw_state = 0;
284 atomic_set(&led->state, 0);
285 }
286 led = &dev->wl->leds.led_rx;
287 if (led->wl) {
288 b43_led_turn_off(dev, led->index, led->activelow);
289 led->hw_state = 0;
290 atomic_set(&led->state, 0);
291 }
292 led = &dev->wl->leds.led_assoc;
293 if (led->wl) {
294 b43_led_turn_off(dev, led->index, led->activelow);
295 led->hw_state = 0;
296 atomic_set(&led->state, 0);
297 }
298
299 /* Initialize other LED states. */
300 for (i = 0; i < B43_MAX_NR_LEDS; i++) {
301 b43_led_get_sprominfo(dev, i, &behaviour, &activelow);
302 switch (behaviour) {
303 case B43_LED_OFF:
304 b43_led_turn_off(dev, i, activelow);
305 break;
306 case B43_LED_ON:
307 b43_led_turn_on(dev, i, activelow);
308 break;
309 default:
310 /* Leave others as-is. */
311 break;
312 }
313 }
314
315 dev->wl->leds.stop = 0;
235} 316}
236 317
237void b43_leds_exit(struct b43_wldev *dev) 318void b43_leds_exit(struct b43_wldev *dev)
238{ 319{
239 b43_unregister_led(&dev->led_tx); 320 struct b43_leds *leds = &dev->wl->leds;
240 b43_unregister_led(&dev->led_rx); 321
241 b43_unregister_led(&dev->led_assoc); 322 b43_led_turn_off(dev, leds->led_tx.index, leds->led_tx.activelow);
242 b43_unregister_led(&dev->led_radio); 323 b43_led_turn_off(dev, leds->led_rx.index, leds->led_rx.activelow);
324 b43_led_turn_off(dev, leds->led_assoc.index, leds->led_assoc.activelow);
325 b43_led_turn_off(dev, leds->led_radio.index, leds->led_radio.activelow);
326}
327
328void b43_leds_stop(struct b43_wldev *dev)
329{
330 struct b43_leds *leds = &dev->wl->leds;
331
332 leds->stop = 1;
333 cancel_work_sync(&leds->work);
334}
335
336void b43_leds_register(struct b43_wldev *dev)
337{
338 unsigned int i;
339 enum b43_led_behaviour behaviour;
340 bool activelow;
341
342 INIT_WORK(&dev->wl->leds.work, b43_leds_work);
343
344 /* Register the LEDs to the LED subsystem. */
345 for (i = 0; i < B43_MAX_NR_LEDS; i++) {
346 b43_led_get_sprominfo(dev, i, &behaviour, &activelow);
347 b43_map_led(dev, i, behaviour, activelow);
348 }
349}
350
351void b43_leds_unregister(struct b43_wldev *dev)
352{
353 struct b43_leds *leds = &dev->wl->leds;
354
355 b43_unregister_led(&leds->led_tx);
356 b43_unregister_led(&leds->led_rx);
357 b43_unregister_led(&leds->led_assoc);
358 b43_unregister_led(&leds->led_radio);
243} 359}
diff --git a/drivers/net/wireless/b43/leds.h b/drivers/net/wireless/b43/leds.h
index b8b1dd521243..9592e4c5a5f5 100644
--- a/drivers/net/wireless/b43/leds.h
+++ b/drivers/net/wireless/b43/leds.h
@@ -7,12 +7,13 @@ struct b43_wldev;
7 7
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/leds.h> 9#include <linux/leds.h>
10#include <linux/workqueue.h>
10 11
11 12
12#define B43_LED_MAX_NAME_LEN 31 13#define B43_LED_MAX_NAME_LEN 31
13 14
14struct b43_led { 15struct b43_led {
15 struct b43_wldev *dev; 16 struct b43_wl *wl;
16 /* The LED class device */ 17 /* The LED class device */
17 struct led_classdev led_dev; 18 struct led_classdev led_dev;
18 /* The index number of the LED. */ 19 /* The index number of the LED. */
@@ -22,8 +23,24 @@ struct b43_led {
22 bool activelow; 23 bool activelow;
23 /* The unique name string for this LED device. */ 24 /* The unique name string for this LED device. */
24 char name[B43_LED_MAX_NAME_LEN + 1]; 25 char name[B43_LED_MAX_NAME_LEN + 1];
26 /* The current status of the LED. This is updated locklessly. */
27 atomic_t state;
28 /* The active state in hardware. */
29 bool hw_state;
25}; 30};
26 31
32struct b43_leds {
33 struct b43_led led_tx;
34 struct b43_led led_rx;
35 struct b43_led led_radio;
36 struct b43_led led_assoc;
37
38 bool stop;
39 struct work_struct work;
40};
41
42#define B43_MAX_NR_LEDS 4
43
27#define B43_LED_BEHAVIOUR 0x7F 44#define B43_LED_BEHAVIOUR 0x7F
28#define B43_LED_ACTIVELOW 0x80 45#define B43_LED_ACTIVELOW 0x80
29/* LED behaviour values */ 46/* LED behaviour values */
@@ -42,23 +59,35 @@ enum b43_led_behaviour {
42 B43_LED_INACTIVE, 59 B43_LED_INACTIVE,
43}; 60};
44 61
62void b43_leds_register(struct b43_wldev *dev);
63void b43_leds_unregister(struct b43_wldev *dev);
45void b43_leds_init(struct b43_wldev *dev); 64void b43_leds_init(struct b43_wldev *dev);
46void b43_leds_exit(struct b43_wldev *dev); 65void b43_leds_exit(struct b43_wldev *dev);
66void b43_leds_stop(struct b43_wldev *dev);
47 67
48 68
49#else /* CONFIG_B43_LEDS */ 69#else /* CONFIG_B43_LEDS */
50/* LED support disabled */ 70/* LED support disabled */
51 71
52struct b43_led { 72struct b43_leds {
53 /* empty */ 73 /* empty */
54}; 74};
55 75
76static inline void b43_leds_register(struct b43_wldev *dev)
77{
78}
79static inline void b43_leds_unregister(struct b43_wldev *dev)
80{
81}
56static inline void b43_leds_init(struct b43_wldev *dev) 82static inline void b43_leds_init(struct b43_wldev *dev)
57{ 83{
58} 84}
59static inline void b43_leds_exit(struct b43_wldev *dev) 85static inline void b43_leds_exit(struct b43_wldev *dev)
60{ 86{
61} 87}
88static inline void b43_leds_stop(struct b43_wldev *dev)
89{
90}
62#endif /* CONFIG_B43_LEDS */ 91#endif /* CONFIG_B43_LEDS */
63 92
64#endif /* B43_LEDS_H_ */ 93#endif /* B43_LEDS_H_ */
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index e789792a36bc..9b907a36bb8c 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -8,6 +8,9 @@
8 Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org> 8 Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
9 Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch> 9 Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
10 10
11 SDIO support
12 Copyright (c) 2009 Albert Herranz <albert_herranz@yahoo.es>
13
11 Some parts of the code in this file are derived from the ipw2200 14 Some parts of the code in this file are derived from the ipw2200
12 driver Copyright(c) 2003 - 2004 Intel Corporation. 15 driver Copyright(c) 2003 - 2004 Intel Corporation.
13 16
@@ -53,6 +56,8 @@
53#include "xmit.h" 56#include "xmit.h"
54#include "lo.h" 57#include "lo.h"
55#include "pcmcia.h" 58#include "pcmcia.h"
59#include "sdio.h"
60#include <linux/mmc/sdio_func.h>
56 61
57MODULE_DESCRIPTION("Broadcom B43 wireless driver"); 62MODULE_DESCRIPTION("Broadcom B43 wireless driver");
58MODULE_AUTHOR("Martin Langer"); 63MODULE_AUTHOR("Martin Langer");
@@ -1587,7 +1592,7 @@ static void b43_beacon_update_trigger_work(struct work_struct *work)
1587 mutex_lock(&wl->mutex); 1592 mutex_lock(&wl->mutex);
1588 dev = wl->current_dev; 1593 dev = wl->current_dev;
1589 if (likely(dev && (b43_status(dev) >= B43_STAT_INITIALIZED))) { 1594 if (likely(dev && (b43_status(dev) >= B43_STAT_INITIALIZED))) {
1590 if (0 /*FIXME dev->dev->bus->bustype == SSB_BUSTYPE_SDIO*/) { 1595 if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) {
1591 /* wl->mutex is enough. */ 1596 /* wl->mutex is enough. */
1592 b43_do_beacon_update_trigger_work(dev); 1597 b43_do_beacon_update_trigger_work(dev);
1593 mmiowb(); 1598 mmiowb();
@@ -1825,6 +1830,16 @@ static void b43_do_interrupt_thread(struct b43_wldev *dev)
1825 1830
1826 /* Re-enable interrupts on the device by restoring the current interrupt mask. */ 1831 /* Re-enable interrupts on the device by restoring the current interrupt mask. */
1827 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask); 1832 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, dev->irq_mask);
1833
1834#if B43_DEBUG
1835 if (b43_debug(dev, B43_DBG_VERBOSESTATS)) {
1836 dev->irq_count++;
1837 for (i = 0; i < ARRAY_SIZE(dev->irq_bit_count); i++) {
1838 if (reason & (1 << i))
1839 dev->irq_bit_count[i]++;
1840 }
1841 }
1842#endif
1828} 1843}
1829 1844
1830/* Interrupt thread handler. Handles device interrupts in thread context. */ 1845/* Interrupt thread handler. Handles device interrupts in thread context. */
@@ -1905,6 +1920,21 @@ static irqreturn_t b43_interrupt_handler(int irq, void *dev_id)
1905 return ret; 1920 return ret;
1906} 1921}
1907 1922
1923/* SDIO interrupt handler. This runs in process context. */
1924static void b43_sdio_interrupt_handler(struct b43_wldev *dev)
1925{
1926 struct b43_wl *wl = dev->wl;
1927 irqreturn_t ret;
1928
1929 mutex_lock(&wl->mutex);
1930
1931 ret = b43_do_interrupt(dev);
1932 if (ret == IRQ_WAKE_THREAD)
1933 b43_do_interrupt_thread(dev);
1934
1935 mutex_unlock(&wl->mutex);
1936}
1937
1908void b43_do_release_fw(struct b43_firmware_file *fw) 1938void b43_do_release_fw(struct b43_firmware_file *fw)
1909{ 1939{
1910 release_firmware(fw->data); 1940 release_firmware(fw->data);
@@ -2645,6 +2675,20 @@ static void b43_adjust_opmode(struct b43_wldev *dev)
2645 cfp_pretbtt = 50; 2675 cfp_pretbtt = 50;
2646 } 2676 }
2647 b43_write16(dev, 0x612, cfp_pretbtt); 2677 b43_write16(dev, 0x612, cfp_pretbtt);
2678
2679 /* FIXME: We don't currently implement the PMQ mechanism,
2680 * so always disable it. If we want to implement PMQ,
2681 * we need to enable it here (clear DISCPMQ) in AP mode.
2682 */
2683 if (0 /* ctl & B43_MACCTL_AP */) {
2684 b43_write32(dev, B43_MMIO_MACCTL,
2685 b43_read32(dev, B43_MMIO_MACCTL)
2686 & ~B43_MACCTL_DISCPMQ);
2687 } else {
2688 b43_write32(dev, B43_MMIO_MACCTL,
2689 b43_read32(dev, B43_MMIO_MACCTL)
2690 | B43_MACCTL_DISCPMQ);
2691 }
2648} 2692}
2649 2693
2650static void b43_rate_memory_write(struct b43_wldev *dev, u16 rate, int is_ofdm) 2694static void b43_rate_memory_write(struct b43_wldev *dev, u16 rate, int is_ofdm)
@@ -2873,6 +2917,27 @@ static void b43_periodic_every15sec(struct b43_wldev *dev)
2873 2917
2874 atomic_set(&phy->txerr_cnt, B43_PHY_TX_BADNESS_LIMIT); 2918 atomic_set(&phy->txerr_cnt, B43_PHY_TX_BADNESS_LIMIT);
2875 wmb(); 2919 wmb();
2920
2921#if B43_DEBUG
2922 if (b43_debug(dev, B43_DBG_VERBOSESTATS)) {
2923 unsigned int i;
2924
2925 b43dbg(dev->wl, "Stats: %7u IRQs/sec, %7u TX/sec, %7u RX/sec\n",
2926 dev->irq_count / 15,
2927 dev->tx_count / 15,
2928 dev->rx_count / 15);
2929 dev->irq_count = 0;
2930 dev->tx_count = 0;
2931 dev->rx_count = 0;
2932 for (i = 0; i < ARRAY_SIZE(dev->irq_bit_count); i++) {
2933 if (dev->irq_bit_count[i]) {
2934 b43dbg(dev->wl, "Stats: %7u IRQ-%02u/sec (0x%08X)\n",
2935 dev->irq_bit_count[i] / 15, i, (1 << i));
2936 dev->irq_bit_count[i] = 0;
2937 }
2938 }
2939 }
2940#endif
2876} 2941}
2877 2942
2878static void do_periodic_work(struct b43_wldev *dev) 2943static void do_periodic_work(struct b43_wldev *dev)
@@ -3002,14 +3067,18 @@ static void b43_security_init(struct b43_wldev *dev)
3002static int b43_rng_read(struct hwrng *rng, u32 *data) 3067static int b43_rng_read(struct hwrng *rng, u32 *data)
3003{ 3068{
3004 struct b43_wl *wl = (struct b43_wl *)rng->priv; 3069 struct b43_wl *wl = (struct b43_wl *)rng->priv;
3070 struct b43_wldev *dev;
3071 int count = -ENODEV;
3005 3072
3006 /* FIXME: We need to take wl->mutex here to make sure the device 3073 mutex_lock(&wl->mutex);
3007 * is not going away from under our ass. However it could deadlock 3074 dev = wl->current_dev;
3008 * with hwrng internal locking. */ 3075 if (likely(dev && b43_status(dev) >= B43_STAT_INITIALIZED)) {
3009 3076 *data = b43_read16(dev, B43_MMIO_RNG);
3010 *data = b43_read16(wl->current_dev, B43_MMIO_RNG); 3077 count = sizeof(u16);
3078 }
3079 mutex_unlock(&wl->mutex);
3011 3080
3012 return (sizeof(u16)); 3081 return count;
3013} 3082}
3014#endif /* CONFIG_B43_HWRNG */ 3083#endif /* CONFIG_B43_HWRNG */
3015 3084
@@ -3068,6 +3137,9 @@ static void b43_tx_work(struct work_struct *work)
3068 dev_kfree_skb(skb); /* Drop it */ 3137 dev_kfree_skb(skb); /* Drop it */
3069 } 3138 }
3070 3139
3140#if B43_DEBUG
3141 dev->tx_count++;
3142#endif
3071 mutex_unlock(&wl->mutex); 3143 mutex_unlock(&wl->mutex);
3072} 3144}
3073 3145
@@ -3820,7 +3892,7 @@ redo:
3820 3892
3821 /* Disable interrupts on the device. */ 3893 /* Disable interrupts on the device. */
3822 b43_set_status(dev, B43_STAT_INITIALIZED); 3894 b43_set_status(dev, B43_STAT_INITIALIZED);
3823 if (0 /*FIXME dev->dev->bus->bustype == SSB_BUSTYPE_SDIO*/) { 3895 if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) {
3824 /* wl->mutex is locked. That is enough. */ 3896 /* wl->mutex is locked. That is enough. */
3825 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, 0); 3897 b43_write32(dev, B43_MMIO_GEN_IRQ_MASK, 0);
3826 b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* Flush */ 3898 b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* Flush */
@@ -3830,10 +3902,15 @@ redo:
3830 b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* Flush */ 3902 b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* Flush */
3831 spin_unlock_irq(&wl->hardirq_lock); 3903 spin_unlock_irq(&wl->hardirq_lock);
3832 } 3904 }
3833 /* Synchronize the interrupt handlers. Unlock to avoid deadlocks. */ 3905 /* Synchronize and free the interrupt handlers. Unlock to avoid deadlocks. */
3834 orig_dev = dev; 3906 orig_dev = dev;
3835 mutex_unlock(&wl->mutex); 3907 mutex_unlock(&wl->mutex);
3836 synchronize_irq(dev->dev->irq); 3908 if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) {
3909 b43_sdio_free_irq(dev);
3910 } else {
3911 synchronize_irq(dev->dev->irq);
3912 free_irq(dev->dev->irq, dev);
3913 }
3837 mutex_lock(&wl->mutex); 3914 mutex_lock(&wl->mutex);
3838 dev = wl->current_dev; 3915 dev = wl->current_dev;
3839 if (!dev) 3916 if (!dev)
@@ -3850,7 +3927,7 @@ redo:
3850 dev_kfree_skb(skb_dequeue(&wl->tx_queue)); 3927 dev_kfree_skb(skb_dequeue(&wl->tx_queue));
3851 3928
3852 b43_mac_suspend(dev); 3929 b43_mac_suspend(dev);
3853 free_irq(dev->dev->irq, dev); 3930 b43_leds_exit(dev);
3854 b43dbg(wl, "Wireless interface stopped\n"); 3931 b43dbg(wl, "Wireless interface stopped\n");
3855 3932
3856 return dev; 3933 return dev;
@@ -3864,12 +3941,20 @@ static int b43_wireless_core_start(struct b43_wldev *dev)
3864 B43_WARN_ON(b43_status(dev) != B43_STAT_INITIALIZED); 3941 B43_WARN_ON(b43_status(dev) != B43_STAT_INITIALIZED);
3865 3942
3866 drain_txstatus_queue(dev); 3943 drain_txstatus_queue(dev);
3867 err = request_threaded_irq(dev->dev->irq, b43_interrupt_handler, 3944 if (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) {
3868 b43_interrupt_thread_handler, 3945 err = b43_sdio_request_irq(dev, b43_sdio_interrupt_handler);
3869 IRQF_SHARED, KBUILD_MODNAME, dev); 3946 if (err) {
3870 if (err) { 3947 b43err(dev->wl, "Cannot request SDIO IRQ\n");
3871 b43err(dev->wl, "Cannot request IRQ-%d\n", dev->dev->irq); 3948 goto out;
3872 goto out; 3949 }
3950 } else {
3951 err = request_threaded_irq(dev->dev->irq, b43_interrupt_handler,
3952 b43_interrupt_thread_handler,
3953 IRQF_SHARED, KBUILD_MODNAME, dev);
3954 if (err) {
3955 b43err(dev->wl, "Cannot request IRQ-%d\n", dev->dev->irq);
3956 goto out;
3957 }
3873 } 3958 }
3874 3959
3875 /* We are ready to run. */ 3960 /* We are ready to run. */
@@ -3882,8 +3967,10 @@ static int b43_wireless_core_start(struct b43_wldev *dev)
3882 /* Start maintainance work */ 3967 /* Start maintainance work */
3883 b43_periodic_tasks_setup(dev); 3968 b43_periodic_tasks_setup(dev);
3884 3969
3970 b43_leds_init(dev);
3971
3885 b43dbg(dev->wl, "Wireless interface started\n"); 3972 b43dbg(dev->wl, "Wireless interface started\n");
3886 out: 3973out:
3887 return err; 3974 return err;
3888} 3975}
3889 3976
@@ -4160,10 +4247,6 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
4160 macctl |= B43_MACCTL_PSM_JMP0; 4247 macctl |= B43_MACCTL_PSM_JMP0;
4161 b43_write32(dev, B43_MMIO_MACCTL, macctl); 4248 b43_write32(dev, B43_MMIO_MACCTL, macctl);
4162 4249
4163 if (!dev->suspend_in_progress) {
4164 b43_leds_exit(dev);
4165 b43_rng_exit(dev->wl);
4166 }
4167 b43_dma_free(dev); 4250 b43_dma_free(dev);
4168 b43_pio_free(dev); 4251 b43_pio_free(dev);
4169 b43_chip_exit(dev); 4252 b43_chip_exit(dev);
@@ -4180,7 +4263,6 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
4180/* Initialize a wireless core */ 4263/* Initialize a wireless core */
4181static int b43_wireless_core_init(struct b43_wldev *dev) 4264static int b43_wireless_core_init(struct b43_wldev *dev)
4182{ 4265{
4183 struct b43_wl *wl = dev->wl;
4184 struct ssb_bus *bus = dev->dev->bus; 4266 struct ssb_bus *bus = dev->dev->bus;
4185 struct ssb_sprom *sprom = &bus->sprom; 4267 struct ssb_sprom *sprom = &bus->sprom;
4186 struct b43_phy *phy = &dev->phy; 4268 struct b43_phy *phy = &dev->phy;
@@ -4264,7 +4346,9 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4264 /* Maximum Contention Window */ 4346 /* Maximum Contention Window */
4265 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MAXCONT, 0x3FF); 4347 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MAXCONT, 0x3FF);
4266 4348
4267 if ((dev->dev->bus->bustype == SSB_BUSTYPE_PCMCIA) || B43_FORCE_PIO) { 4349 if ((dev->dev->bus->bustype == SSB_BUSTYPE_PCMCIA) ||
4350 (dev->dev->bus->bustype == SSB_BUSTYPE_SDIO) ||
4351 B43_FORCE_PIO) {
4268 dev->__using_pio_transfers = 1; 4352 dev->__using_pio_transfers = 1;
4269 err = b43_pio_init(dev); 4353 err = b43_pio_init(dev);
4270 } else { 4354 } else {
@@ -4280,15 +4364,13 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4280 ssb_bus_powerup(bus, !(sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW)); 4364 ssb_bus_powerup(bus, !(sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW));
4281 b43_upload_card_macaddress(dev); 4365 b43_upload_card_macaddress(dev);
4282 b43_security_init(dev); 4366 b43_security_init(dev);
4283 if (!dev->suspend_in_progress) 4367
4284 b43_rng_init(wl); 4368 ieee80211_wake_queues(dev->wl->hw);
4285 4369
4286 ieee80211_wake_queues(dev->wl->hw); 4370 ieee80211_wake_queues(dev->wl->hw);
4287 4371
4288 b43_set_status(dev, B43_STAT_INITIALIZED); 4372 b43_set_status(dev, B43_STAT_INITIALIZED);
4289 4373
4290 if (!dev->suspend_in_progress)
4291 b43_leds_init(dev);
4292out: 4374out:
4293 return err; 4375 return err;
4294 4376
@@ -4837,7 +4919,6 @@ static int b43_wireless_init(struct ssb_device *dev)
4837 4919
4838 /* Initialize struct b43_wl */ 4920 /* Initialize struct b43_wl */
4839 wl->hw = hw; 4921 wl->hw = hw;
4840 spin_lock_init(&wl->leds_lock);
4841 mutex_init(&wl->mutex); 4922 mutex_init(&wl->mutex);
4842 spin_lock_init(&wl->hardirq_lock); 4923 spin_lock_init(&wl->hardirq_lock);
4843 INIT_LIST_HEAD(&wl->devlist); 4924 INIT_LIST_HEAD(&wl->devlist);
@@ -4878,6 +4959,8 @@ static int b43_probe(struct ssb_device *dev, const struct ssb_device_id *id)
4878 err = ieee80211_register_hw(wl->hw); 4959 err = ieee80211_register_hw(wl->hw);
4879 if (err) 4960 if (err)
4880 goto err_one_core_detach; 4961 goto err_one_core_detach;
4962 b43_leds_register(wl->current_dev);
4963 b43_rng_init(wl);
4881 } 4964 }
4882 4965
4883 out: 4966 out:
@@ -4906,12 +4989,15 @@ static void b43_remove(struct ssb_device *dev)
4906 * might have modified it. Restoring is important, so the networking 4989 * might have modified it. Restoring is important, so the networking
4907 * stack can properly free resources. */ 4990 * stack can properly free resources. */
4908 wl->hw->queues = wl->mac80211_initially_registered_queues; 4991 wl->hw->queues = wl->mac80211_initially_registered_queues;
4992 b43_leds_stop(wldev);
4909 ieee80211_unregister_hw(wl->hw); 4993 ieee80211_unregister_hw(wl->hw);
4910 } 4994 }
4911 4995
4912 b43_one_core_detach(dev); 4996 b43_one_core_detach(dev);
4913 4997
4914 if (list_empty(&wl->devlist)) { 4998 if (list_empty(&wl->devlist)) {
4999 b43_rng_exit(wl);
5000 b43_leds_unregister(wldev);
4915 /* Last core on the chip unregistered. 5001 /* Last core on the chip unregistered.
4916 * We can destroy common struct b43_wl. 5002 * We can destroy common struct b43_wl.
4917 */ 5003 */
@@ -4929,80 +5015,17 @@ void b43_controller_restart(struct b43_wldev *dev, const char *reason)
4929 ieee80211_queue_work(dev->wl->hw, &dev->restart_work); 5015 ieee80211_queue_work(dev->wl->hw, &dev->restart_work);
4930} 5016}
4931 5017
4932#ifdef CONFIG_PM
4933
4934static int b43_suspend(struct ssb_device *dev, pm_message_t state)
4935{
4936 struct b43_wldev *wldev = ssb_get_drvdata(dev);
4937 struct b43_wl *wl = wldev->wl;
4938
4939 b43dbg(wl, "Suspending...\n");
4940
4941 mutex_lock(&wl->mutex);
4942 wldev->suspend_in_progress = true;
4943 wldev->suspend_init_status = b43_status(wldev);
4944 if (wldev->suspend_init_status >= B43_STAT_STARTED)
4945 wldev = b43_wireless_core_stop(wldev);
4946 if (wldev && wldev->suspend_init_status >= B43_STAT_INITIALIZED)
4947 b43_wireless_core_exit(wldev);
4948 mutex_unlock(&wl->mutex);
4949
4950 b43dbg(wl, "Device suspended.\n");
4951
4952 return 0;
4953}
4954
4955static int b43_resume(struct ssb_device *dev)
4956{
4957 struct b43_wldev *wldev = ssb_get_drvdata(dev);
4958 struct b43_wl *wl = wldev->wl;
4959 int err = 0;
4960
4961 b43dbg(wl, "Resuming...\n");
4962
4963 mutex_lock(&wl->mutex);
4964 if (wldev->suspend_init_status >= B43_STAT_INITIALIZED) {
4965 err = b43_wireless_core_init(wldev);
4966 if (err) {
4967 b43err(wl, "Resume failed at core init\n");
4968 goto out;
4969 }
4970 }
4971 if (wldev->suspend_init_status >= B43_STAT_STARTED) {
4972 err = b43_wireless_core_start(wldev);
4973 if (err) {
4974 b43_leds_exit(wldev);
4975 b43_rng_exit(wldev->wl);
4976 b43_wireless_core_exit(wldev);
4977 b43err(wl, "Resume failed at core start\n");
4978 goto out;
4979 }
4980 }
4981 b43dbg(wl, "Device resumed.\n");
4982 out:
4983 wldev->suspend_in_progress = false;
4984 mutex_unlock(&wl->mutex);
4985 return err;
4986}
4987
4988#else /* CONFIG_PM */
4989# define b43_suspend NULL
4990# define b43_resume NULL
4991#endif /* CONFIG_PM */
4992
4993static struct ssb_driver b43_ssb_driver = { 5018static struct ssb_driver b43_ssb_driver = {
4994 .name = KBUILD_MODNAME, 5019 .name = KBUILD_MODNAME,
4995 .id_table = b43_ssb_tbl, 5020 .id_table = b43_ssb_tbl,
4996 .probe = b43_probe, 5021 .probe = b43_probe,
4997 .remove = b43_remove, 5022 .remove = b43_remove,
4998 .suspend = b43_suspend,
4999 .resume = b43_resume,
5000}; 5023};
5001 5024
5002static void b43_print_driverinfo(void) 5025static void b43_print_driverinfo(void)
5003{ 5026{
5004 const char *feat_pci = "", *feat_pcmcia = "", *feat_nphy = "", 5027 const char *feat_pci = "", *feat_pcmcia = "", *feat_nphy = "",
5005 *feat_leds = ""; 5028 *feat_leds = "", *feat_sdio = "";
5006 5029
5007#ifdef CONFIG_B43_PCI_AUTOSELECT 5030#ifdef CONFIG_B43_PCI_AUTOSELECT
5008 feat_pci = "P"; 5031 feat_pci = "P";
@@ -5016,11 +5039,14 @@ static void b43_print_driverinfo(void)
5016#ifdef CONFIG_B43_LEDS 5039#ifdef CONFIG_B43_LEDS
5017 feat_leds = "L"; 5040 feat_leds = "L";
5018#endif 5041#endif
5042#ifdef CONFIG_B43_SDIO
5043 feat_sdio = "S";
5044#endif
5019 printk(KERN_INFO "Broadcom 43xx driver loaded " 5045 printk(KERN_INFO "Broadcom 43xx driver loaded "
5020 "[ Features: %s%s%s%s, Firmware-ID: " 5046 "[ Features: %s%s%s%s%s, Firmware-ID: "
5021 B43_SUPPORTED_FIRMWARE_ID " ]\n", 5047 B43_SUPPORTED_FIRMWARE_ID " ]\n",
5022 feat_pci, feat_pcmcia, feat_nphy, 5048 feat_pci, feat_pcmcia, feat_nphy,
5023 feat_leds); 5049 feat_leds, feat_sdio);
5024} 5050}
5025 5051
5026static int __init b43_init(void) 5052static int __init b43_init(void)
@@ -5031,13 +5057,18 @@ static int __init b43_init(void)
5031 err = b43_pcmcia_init(); 5057 err = b43_pcmcia_init();
5032 if (err) 5058 if (err)
5033 goto err_dfs_exit; 5059 goto err_dfs_exit;
5034 err = ssb_driver_register(&b43_ssb_driver); 5060 err = b43_sdio_init();
5035 if (err) 5061 if (err)
5036 goto err_pcmcia_exit; 5062 goto err_pcmcia_exit;
5063 err = ssb_driver_register(&b43_ssb_driver);
5064 if (err)
5065 goto err_sdio_exit;
5037 b43_print_driverinfo(); 5066 b43_print_driverinfo();
5038 5067
5039 return err; 5068 return err;
5040 5069
5070err_sdio_exit:
5071 b43_sdio_exit();
5041err_pcmcia_exit: 5072err_pcmcia_exit:
5042 b43_pcmcia_exit(); 5073 b43_pcmcia_exit();
5043err_dfs_exit: 5074err_dfs_exit:
@@ -5048,6 +5079,7 @@ err_dfs_exit:
5048static void __exit b43_exit(void) 5079static void __exit b43_exit(void)
5049{ 5080{
5050 ssb_driver_unregister(&b43_ssb_driver); 5081 ssb_driver_unregister(&b43_ssb_driver);
5082 b43_sdio_exit();
5051 b43_pcmcia_exit(); 5083 b43_pcmcia_exit();
5052 b43_debugfs_exit(); 5084 b43_debugfs_exit();
5053} 5085}
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
index 3e02d969f683..1e318d815a5b 100644
--- a/drivers/net/wireless/b43/phy_lp.c
+++ b/drivers/net/wireless/b43/phy_lp.c
@@ -2228,6 +2228,16 @@ static enum b43_txpwr_result b43_lpphy_op_recalc_txpower(struct b43_wldev *dev,
2228 return B43_TXPWR_RES_DONE; 2228 return B43_TXPWR_RES_DONE;
2229} 2229}
2230 2230
2231void b43_lpphy_op_switch_analog(struct b43_wldev *dev, bool on)
2232{
2233 if (on) {
2234 b43_phy_mask(dev, B43_LPPHY_AFE_CTL_OVR, 0xfff8);
2235 } else {
2236 b43_phy_set(dev, B43_LPPHY_AFE_CTL_OVRVAL, 0x0007);
2237 b43_phy_set(dev, B43_LPPHY_AFE_CTL_OVR, 0x0007);
2238 }
2239}
2240
2231const struct b43_phy_operations b43_phyops_lp = { 2241const struct b43_phy_operations b43_phyops_lp = {
2232 .allocate = b43_lpphy_op_allocate, 2242 .allocate = b43_lpphy_op_allocate,
2233 .free = b43_lpphy_op_free, 2243 .free = b43_lpphy_op_free,
@@ -2239,7 +2249,7 @@ const struct b43_phy_operations b43_phyops_lp = {
2239 .radio_read = b43_lpphy_op_radio_read, 2249 .radio_read = b43_lpphy_op_radio_read,
2240 .radio_write = b43_lpphy_op_radio_write, 2250 .radio_write = b43_lpphy_op_radio_write,
2241 .software_rfkill = b43_lpphy_op_software_rfkill, 2251 .software_rfkill = b43_lpphy_op_software_rfkill,
2242 .switch_analog = b43_phyop_switch_analog_generic, 2252 .switch_analog = b43_lpphy_op_switch_analog,
2243 .switch_channel = b43_lpphy_op_switch_channel, 2253 .switch_channel = b43_lpphy_op_switch_channel,
2244 .get_default_chan = b43_lpphy_op_get_default_chan, 2254 .get_default_chan = b43_lpphy_op_get_default_chan,
2245 .set_rx_antenna = b43_lpphy_op_set_rx_antenna, 2255 .set_rx_antenna = b43_lpphy_op_set_rx_antenna,
diff --git a/drivers/net/wireless/b43/pio.c b/drivers/net/wireless/b43/pio.c
index 3498b68385e7..e96091b31499 100644
--- a/drivers/net/wireless/b43/pio.c
+++ b/drivers/net/wireless/b43/pio.c
@@ -574,7 +574,7 @@ void b43_pio_handle_txstatus(struct b43_wldev *dev,
574 q->buffer_used -= total_len; 574 q->buffer_used -= total_len;
575 q->free_packet_slots += 1; 575 q->free_packet_slots += 1;
576 576
577 ieee80211_tx_status_irqsafe(dev->wl->hw, pack->skb); 577 ieee80211_tx_status(dev->wl->hw, pack->skb);
578 pack->skb = NULL; 578 pack->skb = NULL;
579 list_add(&pack->list, &q->packets_list); 579 list_add(&pack->list, &q->packets_list);
580 580
diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c
index 31e55999893f..7a3218c5ba7d 100644
--- a/drivers/net/wireless/b43/rfkill.c
+++ b/drivers/net/wireless/b43/rfkill.c
@@ -28,7 +28,7 @@
28/* Returns TRUE, if the radio is enabled in hardware. */ 28/* Returns TRUE, if the radio is enabled in hardware. */
29bool b43_is_hw_radio_enabled(struct b43_wldev *dev) 29bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
30{ 30{
31 if (dev->phy.rev >= 3) { 31 if (dev->phy.rev >= 3 || dev->phy.type == B43_PHYTYPE_LP) {
32 if (!(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI) 32 if (!(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
33 & B43_MMIO_RADIO_HWENABLED_HI_MASK)) 33 & B43_MMIO_RADIO_HWENABLED_HI_MASK))
34 return 1; 34 return 1;
diff --git a/drivers/net/wireless/b43/sdio.c b/drivers/net/wireless/b43/sdio.c
new file mode 100644
index 000000000000..0d3ac64147a5
--- /dev/null
+++ b/drivers/net/wireless/b43/sdio.c
@@ -0,0 +1,202 @@
1/*
2 * Broadcom B43 wireless driver
3 *
4 * SDIO over Sonics Silicon Backplane bus glue for b43.
5 *
6 * Copyright (C) 2009 Albert Herranz
7 * Copyright (C) 2009 Michael Buesch <mb@bu3sch.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 */
14
15#include <linux/kernel.h>
16#include <linux/mmc/card.h>
17#include <linux/mmc/sdio_func.h>
18#include <linux/mmc/sdio_ids.h>
19#include <linux/ssb/ssb.h>
20
21#include "sdio.h"
22#include "b43.h"
23
24
25#define HNBU_CHIPID 0x01 /* vendor & device id */
26
27#define B43_SDIO_BLOCK_SIZE 64 /* rx fifo max size in bytes */
28
29
30static const struct b43_sdio_quirk {
31 u16 vendor;
32 u16 device;
33 unsigned int quirks;
34} b43_sdio_quirks[] = {
35 { 0x14E4, 0x4318, SSB_QUIRK_SDIO_READ_AFTER_WRITE32, },
36 { },
37};
38
39
40static unsigned int b43_sdio_get_quirks(u16 vendor, u16 device)
41{
42 const struct b43_sdio_quirk *q;
43
44 for (q = b43_sdio_quirks; q->quirks; q++) {
45 if (vendor == q->vendor && device == q->device)
46 return q->quirks;
47 }
48
49 return 0;
50}
51
52static void b43_sdio_interrupt_dispatcher(struct sdio_func *func)
53{
54 struct b43_sdio *sdio = sdio_get_drvdata(func);
55 struct b43_wldev *dev = sdio->irq_handler_opaque;
56
57 if (unlikely(b43_status(dev) < B43_STAT_STARTED))
58 return;
59
60 sdio_release_host(func);
61 sdio->irq_handler(dev);
62 sdio_claim_host(func);
63}
64
65int b43_sdio_request_irq(struct b43_wldev *dev,
66 void (*handler)(struct b43_wldev *dev))
67{
68 struct ssb_bus *bus = dev->dev->bus;
69 struct sdio_func *func = bus->host_sdio;
70 struct b43_sdio *sdio = sdio_get_drvdata(func);
71 int err;
72
73 sdio->irq_handler_opaque = dev;
74 sdio->irq_handler = handler;
75 sdio_claim_host(func);
76 err = sdio_claim_irq(func, b43_sdio_interrupt_dispatcher);
77 sdio_release_host(func);
78
79 return err;
80}
81
82void b43_sdio_free_irq(struct b43_wldev *dev)
83{
84 struct ssb_bus *bus = dev->dev->bus;
85 struct sdio_func *func = bus->host_sdio;
86 struct b43_sdio *sdio = sdio_get_drvdata(func);
87
88 sdio_claim_host(func);
89 sdio_release_irq(func);
90 sdio_release_host(func);
91 sdio->irq_handler_opaque = NULL;
92 sdio->irq_handler = NULL;
93}
94
95static int b43_sdio_probe(struct sdio_func *func,
96 const struct sdio_device_id *id)
97{
98 struct b43_sdio *sdio;
99 struct sdio_func_tuple *tuple;
100 u16 vendor = 0, device = 0;
101 int error;
102
103 /* Look for the card chip identifier. */
104 tuple = func->tuples;
105 while (tuple) {
106 switch (tuple->code) {
107 case 0x80:
108 switch (tuple->data[0]) {
109 case HNBU_CHIPID:
110 if (tuple->size != 5)
111 break;
112 vendor = tuple->data[1] | (tuple->data[2]<<8);
113 device = tuple->data[3] | (tuple->data[4]<<8);
114 dev_info(&func->dev, "Chip ID %04x:%04x\n",
115 vendor, device);
116 break;
117 default:
118 break;
119 }
120 break;
121 default:
122 break;
123 }
124 tuple = tuple->next;
125 }
126 if (!vendor || !device) {
127 error = -ENODEV;
128 goto out;
129 }
130
131 sdio_claim_host(func);
132 error = sdio_set_block_size(func, B43_SDIO_BLOCK_SIZE);
133 if (error) {
134 dev_err(&func->dev, "failed to set block size to %u bytes,"
135 " error %d\n", B43_SDIO_BLOCK_SIZE, error);
136 goto err_release_host;
137 }
138 error = sdio_enable_func(func);
139 if (error) {
140 dev_err(&func->dev, "failed to enable func, error %d\n", error);
141 goto err_release_host;
142 }
143 sdio_release_host(func);
144
145 sdio = kzalloc(sizeof(*sdio), GFP_KERNEL);
146 if (!sdio) {
147 error = -ENOMEM;
148 dev_err(&func->dev, "failed to allocate ssb bus\n");
149 goto err_disable_func;
150 }
151 error = ssb_bus_sdiobus_register(&sdio->ssb, func,
152 b43_sdio_get_quirks(vendor, device));
153 if (error) {
154 dev_err(&func->dev, "failed to register ssb sdio bus,"
155 " error %d\n", error);
156 goto err_free_ssb;
157 }
158 sdio_set_drvdata(func, sdio);
159
160 return 0;
161
162err_free_ssb:
163 kfree(sdio);
164err_disable_func:
165 sdio_disable_func(func);
166err_release_host:
167 sdio_release_host(func);
168out:
169 return error;
170}
171
172static void b43_sdio_remove(struct sdio_func *func)
173{
174 struct b43_sdio *sdio = sdio_get_drvdata(func);
175
176 ssb_bus_unregister(&sdio->ssb);
177 sdio_disable_func(func);
178 kfree(sdio);
179 sdio_set_drvdata(func, NULL);
180}
181
182static const struct sdio_device_id b43_sdio_ids[] = {
183 { SDIO_DEVICE(0x02d0, 0x044b) }, /* Nintendo Wii WLAN daughter card */
184 { },
185};
186
187static struct sdio_driver b43_sdio_driver = {
188 .name = "b43-sdio",
189 .id_table = b43_sdio_ids,
190 .probe = b43_sdio_probe,
191 .remove = b43_sdio_remove,
192};
193
194int b43_sdio_init(void)
195{
196 return sdio_register_driver(&b43_sdio_driver);
197}
198
199void b43_sdio_exit(void)
200{
201 sdio_unregister_driver(&b43_sdio_driver);
202}
diff --git a/drivers/net/wireless/b43/sdio.h b/drivers/net/wireless/b43/sdio.h
new file mode 100644
index 000000000000..fb633094403a
--- /dev/null
+++ b/drivers/net/wireless/b43/sdio.h
@@ -0,0 +1,45 @@
1#ifndef B43_SDIO_H_
2#define B43_SDIO_H_
3
4#include <linux/ssb/ssb.h>
5
6struct b43_wldev;
7
8
9#ifdef CONFIG_B43_SDIO
10
11struct b43_sdio {
12 struct ssb_bus ssb;
13 void *irq_handler_opaque;
14 void (*irq_handler)(struct b43_wldev *dev);
15};
16
17int b43_sdio_request_irq(struct b43_wldev *dev,
18 void (*handler)(struct b43_wldev *dev));
19void b43_sdio_free_irq(struct b43_wldev *dev);
20
21int b43_sdio_init(void);
22void b43_sdio_exit(void);
23
24
25#else /* CONFIG_B43_SDIO */
26
27
28int b43_sdio_request_irq(struct b43_wldev *dev,
29 void (*handler)(struct b43_wldev *dev))
30{
31 return -ENODEV;
32}
33void b43_sdio_free_irq(struct b43_wldev *dev)
34{
35}
36static inline int b43_sdio_init(void)
37{
38 return 0;
39}
40static inline void b43_sdio_exit(void)
41{
42}
43
44#endif /* CONFIG_B43_SDIO */
45#endif /* B43_SDIO_H_ */
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index 14f541248b5c..ac9f600995e4 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -690,8 +690,11 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
690 } 690 }
691 691
692 memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); 692 memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
693 ieee80211_rx_irqsafe(dev->wl->hw, skb); 693 ieee80211_rx(dev->wl->hw, skb);
694 694
695#if B43_DEBUG
696 dev->rx_count++;
697#endif
695 return; 698 return;
696drop: 699drop:
697 b43dbg(dev->wl, "RX: Packet dropped\n"); 700 b43dbg(dev->wl, "RX: Packet dropped\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index ca61d3796cef..3259b8841544 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2021,6 +2021,12 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2021 agg->frame_count, txq_id, idx); 2021 agg->frame_count, txq_id, idx);
2022 2022
2023 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx); 2023 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
2024 if (!hdr) {
2025 IWL_ERR(priv,
2026 "BUG_ON idx doesn't point to valid skb"
2027 " idx=%d, txq_id=%d\n", idx, txq_id);
2028 return -1;
2029 }
2024 2030
2025 sc = le16_to_cpu(hdr->seq_ctrl); 2031 sc = le16_to_cpu(hdr->seq_ctrl);
2026 if (idx != (SEQ_TO_SN(sc) & 0xff)) { 2032 if (idx != (SEQ_TO_SN(sc) & 0xff)) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 1d539e3b8db1..a6391c7fea53 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -1163,6 +1163,12 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1163 agg->frame_count, txq_id, idx); 1163 agg->frame_count, txq_id, idx);
1164 1164
1165 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx); 1165 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
1166 if (!hdr) {
1167 IWL_ERR(priv,
1168 "BUG_ON idx doesn't point to valid skb"
1169 " idx=%d, txq_id=%d\n", idx, txq_id);
1170 return -1;
1171 }
1166 1172
1167 sc = le16_to_cpu(hdr->seq_ctrl); 1173 sc = le16_to_cpu(hdr->seq_ctrl);
1168 if (idx != (SEQ_TO_SN(sc) & 0xff)) { 1174 if (idx != (SEQ_TO_SN(sc) & 0xff)) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index b90adcb73b06..8e1bb53c0aa3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -250,12 +250,20 @@ void iwl_rx_allocate(struct iwl_priv *priv, gfp_t priority)
250 } 250 }
251 spin_unlock_irqrestore(&rxq->lock, flags); 251 spin_unlock_irqrestore(&rxq->lock, flags);
252 252
253 if (rxq->free_count > RX_LOW_WATERMARK)
254 priority |= __GFP_NOWARN;
253 /* Alloc a new receive buffer */ 255 /* Alloc a new receive buffer */
254 skb = alloc_skb(priv->hw_params.rx_buf_size + 256, 256 skb = alloc_skb(priv->hw_params.rx_buf_size + 256,
255 priority); 257 priority);
256 258
257 if (!skb) { 259 if (!skb) {
258 IWL_CRIT(priv, "Can not allocate SKB buffers\n"); 260 if (net_ratelimit())
261 IWL_DEBUG_INFO(priv, "Failed to allocate SKB buffer.\n");
262 if ((rxq->free_count <= RX_LOW_WATERMARK) &&
263 net_ratelimit())
264 IWL_CRIT(priv, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n",
265 priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL",
266 rxq->free_count);
259 /* We don't reschedule replenish work here -- we will 267 /* We don't reschedule replenish work here -- we will
260 * call the restock method and if it still needs 268 * call the restock method and if it still needs
261 * more buffers it will schedule replenish */ 269 * more buffers it will schedule replenish */
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index a2b9ec82b965..c6633fec8216 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -520,7 +520,7 @@ int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
520 struct iwl_host_cmd cmd = { 520 struct iwl_host_cmd cmd = {
521 .id = REPLY_WEPKEY, 521 .id = REPLY_WEPKEY,
522 .data = wep_cmd, 522 .data = wep_cmd,
523 .flags = CMD_SYNC, 523 .flags = CMD_ASYNC,
524 }; 524 };
525 525
526 memset(wep_cmd, 0, cmd_size + 526 memset(wep_cmd, 0, cmd_size +
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 090966837f3c..4f2d43937283 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1146,11 +1146,18 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority)
1146 } 1146 }
1147 spin_unlock_irqrestore(&rxq->lock, flags); 1147 spin_unlock_irqrestore(&rxq->lock, flags);
1148 1148
1149 if (rxq->free_count > RX_LOW_WATERMARK)
1150 priority |= __GFP_NOWARN;
1149 /* Alloc a new receive buffer */ 1151 /* Alloc a new receive buffer */
1150 skb = alloc_skb(priv->hw_params.rx_buf_size, priority); 1152 skb = alloc_skb(priv->hw_params.rx_buf_size, priority);
1151 if (!skb) { 1153 if (!skb) {
1152 if (net_ratelimit()) 1154 if (net_ratelimit())
1153 IWL_CRIT(priv, ": Can not allocate SKB buffers\n"); 1155 IWL_DEBUG_INFO(priv, "Failed to allocate SKB buffer.\n");
1156 if ((rxq->free_count <= RX_LOW_WATERMARK) &&
1157 net_ratelimit())
1158 IWL_CRIT(priv, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n",
1159 priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL",
1160 rxq->free_count);
1154 /* We don't reschedule replenish work here -- we will 1161 /* We don't reschedule replenish work here -- we will
1155 * call the restock method and if it still needs 1162 * call the restock method and if it still needs
1156 * more buffers it will schedule replenish */ 1163 * more buffers it will schedule replenish */
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 5462cb5ad994..567f029a8cda 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -380,7 +380,7 @@ static inline void rt2x00crypto_tx_insert_iv(struct sk_buff *skb,
380{ 380{
381} 381}
382 382
383static inline void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, bool l2pad, 383static inline void rt2x00crypto_rx_insert_iv(struct sk_buff *skb,
384 unsigned int header_length, 384 unsigned int header_length,
385 struct rxdone_entry_desc *rxdesc) 385 struct rxdone_entry_desc *rxdesc)
386{ 386{
diff --git a/drivers/net/wireless/wl12xx/Kconfig b/drivers/net/wireless/wl12xx/Kconfig
index 7b14d5bc63d6..88060e117541 100644
--- a/drivers/net/wireless/wl12xx/Kconfig
+++ b/drivers/net/wireless/wl12xx/Kconfig
@@ -1,5 +1,5 @@
1menuconfig WL12XX 1menuconfig WL12XX
2 boolean "TI wl12xx driver support" 2 tristate "TI wl12xx driver support"
3 depends on MAC80211 && WLAN_80211 && EXPERIMENTAL 3 depends on MAC80211 && WLAN_80211 && EXPERIMENTAL
4 ---help--- 4 ---help---
5 This will enable TI wl12xx driver support. The drivers make 5 This will enable TI wl12xx driver support. The drivers make
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 38688847d568..23a6a6d4863b 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -1070,7 +1070,7 @@ static int eject_installer(struct usb_interface *intf)
1070 1070
1071 /* Find bulk out endpoint */ 1071 /* Find bulk out endpoint */
1072 endpoint = &iface_desc->endpoint[1].desc; 1072 endpoint = &iface_desc->endpoint[1].desc;
1073 if ((endpoint->bEndpointAddress & USB_TYPE_MASK) == USB_DIR_OUT && 1073 if (usb_endpoint_dir_out(endpoint) &&
1074 usb_endpoint_xfer_bulk(endpoint)) { 1074 usb_endpoint_xfer_bulk(endpoint)) {
1075 bulk_out_ep = endpoint->bEndpointAddress; 1075 bulk_out_ep = endpoint->bEndpointAddress;
1076 } else { 1076 } else {
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index dc22782633a5..83a044dbd1d7 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -134,18 +134,15 @@ static void xemaclite_enable_interrupts(struct net_local *drvdata)
134 } 134 }
135 135
136 /* Enable the Rx interrupts for the first buffer */ 136 /* Enable the Rx interrupts for the first buffer */
137 reg_data = in_be32(drvdata->base_addr + XEL_RSR_OFFSET);
138 out_be32(drvdata->base_addr + XEL_RSR_OFFSET, 137 out_be32(drvdata->base_addr + XEL_RSR_OFFSET,
139 reg_data | XEL_RSR_RECV_IE_MASK); 138 XEL_RSR_RECV_IE_MASK);
140 139
141 /* Enable the Rx interrupts for the second Buffer if 140 /* Enable the Rx interrupts for the second Buffer if
142 * configured in HW */ 141 * configured in HW */
143 if (drvdata->rx_ping_pong != 0) { 142 if (drvdata->rx_ping_pong != 0) {
144 reg_data = in_be32(drvdata->base_addr + XEL_BUFFER_OFFSET +
145 XEL_RSR_OFFSET);
146 out_be32(drvdata->base_addr + XEL_BUFFER_OFFSET + 143 out_be32(drvdata->base_addr + XEL_BUFFER_OFFSET +
147 XEL_RSR_OFFSET, 144 XEL_RSR_OFFSET,
148 reg_data | XEL_RSR_RECV_IE_MASK); 145 XEL_RSR_RECV_IE_MASK);
149 } 146 }
150 147
151 /* Enable the Global Interrupt Enable */ 148 /* Enable the Global Interrupt Enable */