aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/isdn/README.gigaset116
-rw-r--r--drivers/atm/he.c4
-rw-r--r--drivers/isdn/gigaset/common.c2
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/atl1c/atl1c.h17
-rw-r--r--drivers/net/atl1c/atl1c_main.c94
-rw-r--r--drivers/net/b44.c3
-rw-r--r--drivers/net/e1000e/defines.h2
-rw-r--r--drivers/net/e1000e/es2lan.c97
-rw-r--r--drivers/net/e1000e/hw.h7
-rw-r--r--drivers/net/e1000e/ich8lan.c8
-rw-r--r--drivers/net/e1000e/netdev.c2
-rw-r--r--drivers/net/fec_mpc52xx.c121
-rw-r--r--drivers/net/gianfar.c1
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c1
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c1
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c22
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h1
-rw-r--r--drivers/net/mv643xx_eth.c3
-rw-r--r--drivers/net/myri10ge/myri10ge.c4
-rw-r--r--drivers/net/netxen/netxen_nic_init.c14
-rw-r--r--drivers/net/netxen/netxen_nic_main.c49
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c3
-rw-r--r--drivers/net/wireless/ath/ath5k/led.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c42
-rw-r--r--drivers/net/wireless/b43/main.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000-hw.h14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c37
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c27
-rw-r--r--drivers/net/wireless/iwmc3200wifi/iwm.h2
-rw-r--r--drivers/net/wireless/iwmc3200wifi/netdev.c2
-rw-r--r--drivers/net/wireless/iwmc3200wifi/rx.c2
-rw-r--r--drivers/net/wireless/libertas/wext.c2
-rw-r--r--drivers/net/wireless/mwl8k.c327
-rw-r--r--drivers/net/wireless/orinoco/hermes_dld.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2800.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c17
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c5
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187.h6
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c12
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_leds.c68
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_leds.h2
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_rfkill.c4
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_main.c36
-rw-r--r--include/linux/gigaset_dev.h22
-rw-r--r--include/linux/ieee80211.h2
-rw-r--r--include/linux/if_ether.h2
-rw-r--r--include/net/inet6_hashtables.h2
-rw-r--r--include/net/inet_hashtables.h8
-rw-r--r--include/net/inet_timewait_sock.h3
-rw-r--r--include/net/mac80211.h6
-rw-r--r--include/net/tcp.h22
-rw-r--r--net/atm/br2684.c11
-rw-r--r--net/atm/lec.c10
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/dccp/ipv6.c4
-rw-r--r--net/ipv4/inet_hashtables.c24
-rw-r--r--net/ipv4/inet_timewait_sock.c61
-rw-r--r--net/ipv4/tcp.c5
-rw-r--r--net/ipv4/tcp_input.c35
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv4/tcp_timer.c29
-rw-r--r--net/ipv6/inet6_hashtables.c8
-rw-r--r--net/ipv6/tcp_ipv6.c4
-rw-r--r--net/mac80211/cfg.c3
-rw-r--r--net/mac80211/ht.c25
-rw-r--r--net/mac80211/ieee80211_i.h1
-rw-r--r--net/mac80211/main.c2
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/mac80211/mesh.h5
-rw-r--r--net/mac80211/mesh_hwmp.c2
-rw-r--r--net/mac80211/mlme.c18
-rw-r--r--net/mac80211/rx.c1
-rw-r--r--net/mac80211/scan.c20
-rw-r--r--net/mac80211/util.c2
-rw-r--r--net/rfkill/core.c4
-rw-r--r--net/wireless/reg.c75
-rw-r--r--net/wireless/wext-compat.c1
92 files changed, 1006 insertions, 686 deletions
diff --git a/Documentation/isdn/README.gigaset b/Documentation/isdn/README.gigaset
index 0fc9831d7ecb..794941fc9493 100644
--- a/Documentation/isdn/README.gigaset
+++ b/Documentation/isdn/README.gigaset
@@ -68,22 +68,38 @@ GigaSet 307x Device Driver
68 for troubleshooting or to pass module parameters. 68 for troubleshooting or to pass module parameters.
69 69
70 The module ser_gigaset provides a serial line discipline N_GIGASET_M101 70 The module ser_gigaset provides a serial line discipline N_GIGASET_M101
71 which drives the device through the regular serial line driver. It must 71 which uses the regular serial port driver to access the device, and must
72 be attached to the serial line to which the M101 is connected with the 72 therefore be attached to the serial device to which the M101 is connected.
73 ldattach(8) command (requires util-linux-ng release 2.14 or later), for 73 The ldattach(8) command (included in util-linux-ng release 2.14 or later)
74 example: 74 can be used for that purpose, for example:
75 ldattach GIGASET_M101 /dev/ttyS1 75 ldattach GIGASET_M101 /dev/ttyS1
76 This will open the device file, attach the line discipline to it, and 76 This will open the device file, attach the line discipline to it, and
77 then sleep in the background, keeping the device open so that the line 77 then sleep in the background, keeping the device open so that the line
78 discipline remains active. To deactivate it, kill the daemon, for example 78 discipline remains active. To deactivate it, kill the daemon, for example
79 with 79 with
80 killall ldattach 80 killall ldattach
81 before disconnecting the device. To have this happen automatically at 81 before disconnecting the device. To have this happen automatically at
82 system startup/shutdown on an LSB compatible system, create and activate 82 system startup/shutdown on an LSB compatible system, create and activate
83 an appropriate LSB startup script /etc/init.d/gigaset. (The init name 83 an appropriate LSB startup script /etc/init.d/gigaset. (The init name
84 'gigaset' is officially assigned to this project by LANANA.) 84 'gigaset' is officially assigned to this project by LANANA.)
85 Alternatively, just add the 'ldattach' command line to /etc/rc.local. 85 Alternatively, just add the 'ldattach' command line to /etc/rc.local.
86 86
87 The modules accept the following parameters:
88
89 Module Parameter Meaning
90
91 gigaset debug debug level (see section 3.2.)
92
93 startmode initial operation mode (see section 2.5.):
94 bas_gigaset ) 1=ISDN4linux/CAPI (default), 0=Unimodem
95 ser_gigaset )
96 usb_gigaset ) cidmode initial Call-ID mode setting (see section
97 2.5.): 1=on (default), 0=off
98
99 Depending on your distribution you may want to create a separate module
100 configuration file /etc/modprobe.d/gigaset for these, or add them to a
101 custom file like /etc/modprobe.conf.local.
102
872.2. Device nodes for user space programs 1032.2. Device nodes for user space programs
88 ------------------------------------ 104 ------------------------------------
89 The device can be accessed from user space (eg. by the user space tools 105 The device can be accessed from user space (eg. by the user space tools
@@ -93,11 +109,48 @@ GigaSet 307x Device Driver
93 - /dev/ttyGU0 for M105 (USB data boxes) 109 - /dev/ttyGU0 for M105 (USB data boxes)
94 - /dev/ttyGB0 for the base driver (direct USB connection) 110 - /dev/ttyGB0 for the base driver (direct USB connection)
95 111
96 You can also select a "default device" which is used by the frontends when 112 If you connect more than one device of a type, they will get consecutive
113 device nodes, eg. /dev/ttyGU1 for a second M105.
114
115 You can also set a "default device" for the user space tools to use when
97 no device node is given as parameter, by creating a symlink /dev/ttyG to 116 no device node is given as parameter, by creating a symlink /dev/ttyG to
98 one of them, eg.: 117 one of them, eg.:
99 118
100 ln -s /dev/ttyGB0 /dev/ttyG 119 ln -s /dev/ttyGB0 /dev/ttyG
120
121 The devices accept the following device specific ioctl calls
122 (defined in gigaset_dev.h):
123
124 ioctl(int fd, GIGASET_REDIR, int *cmd);
125 If cmd==1, the device is set to be controlled exclusively through the
126 character device node; access from the ISDN subsystem is blocked.
127 If cmd==0, the device is set to be used from the ISDN subsystem and does
128 not communicate through the character device node.
129
130 ioctl(int fd, GIGASET_CONFIG, int *cmd);
131 (ser_gigaset and usb_gigaset only)
132 If cmd==1, the device is set to adapter configuration mode where commands
133 are interpreted by the M10x DECT adapter itself instead of being
134 forwarded to the base station. In this mode, the device accepts the
135 commands described in Siemens document "AT-Kommando Alignment M10x Data"
136 for setting the operation mode, associating with a base station and
137 querying parameters like field strengh and signal quality.
138 Note that there is no ioctl command for leaving adapter configuration
139 mode and returning to regular operation. In order to leave adapter
140 configuration mode, write the command ATO to the device.
141
142 ioctl(int fd, GIGASET_BRKCHARS, unsigned char brkchars[6]);
143 (usb_gigaset only)
144 Set the break characters on an M105's internal serial adapter to the six
145 bytes stored in brkchars[]. Unused bytes should be set to zero.
146
147 ioctl(int fd, GIGASET_VERSION, unsigned version[4]);
148 Retrieve version information from the driver. version[0] must be set to
149 one of:
150 - GIGVER_DRIVER: retrieve driver version
151 - GIGVER_COMPAT: retrieve interface compatibility version
152 - GIGVER_FWBASE: retrieve the firmware version of the base
153 Upon return, version[] is filled with the requested version information.
101 154
1022.3. ISDN4linux 1552.3. ISDN4linux
103 ---------- 156 ----------
@@ -113,15 +166,24 @@ GigaSet 307x Device Driver
113 Connection State: 0, Response: -1 166 Connection State: 0, Response: -1
114 gigaset_process_response: resp_code -1 in ConState 0 ! 167 gigaset_process_response: resp_code -1 in ConState 0 !
115 Timeout occurred 168 Timeout occurred
116 you might need to use unimodem mode. (see section 2.5.) 169 you probably need to use unimodem mode. (see section 2.5.)
117 170
1182.4. CAPI 1712.4. CAPI
119 ---- 172 ----
120 If the driver is compiled with CAPI support (kernel configuration option 173 If the driver is compiled with CAPI support (kernel configuration option
121 GIGASET_CAPI, experimental) it can also be used with CAPI 2.0 kernel and 174 GIGASET_CAPI, experimental) it can also be used with CAPI 2.0 kernel and
122 user space applications. ISDN4Linux is supported in this configuration 175 user space applications. For user space access, the module capi.ko must
176 be loaded. The capiinit command (included in the capi4k-utils package)
177 does this for you.
178
179 The CAPI variant of the driver supports legacy ISDN4Linux applications
123 via the capidrv compatibility driver. The kernel module capidrv.ko must 180 via the capidrv compatibility driver. The kernel module capidrv.ko must
124 be loaded explicitly ("modprobe capidrv") if needed. 181 be loaded explicitly with the command
182 modprobe capidrv
183 if needed, and cannot be unloaded again without unloading the driver
184 first. (These are limitations of capidrv.)
185
186 The note about unimodem mode in the preceding section applies here, too.
125 187
1262.5. Unimodem mode 1882.5. Unimodem mode
127 ------------- 189 -------------
@@ -134,9 +196,14 @@ GigaSet 307x Device Driver
134 You can switch back using 196 You can switch back using
135 gigacontr --mode isdn 197 gigacontr --mode isdn
136 198
137 You can also load the driver using e.g. 199 You can also put the driver directly into Unimodem mode when it's loaded,
138 modprobe usb_gigaset startmode=0 200 by passing the module parameter startmode=0 to the hardware specific
139 to prevent the driver from starting in "isdn4linux mode". 201 module, e.g.
202 modprobe usb_gigaset startmode=0
203 or by adding a line like
204 options usb_gigaset startmode=0
205 to an appropriate module configuration file, like /etc/modprobe.d/gigaset
206 or /etc/modprobe.conf.local.
140 207
141 In this mode the device works like a modem connected to a serial port 208 In this mode the device works like a modem connected to a serial port
142 (the /dev/ttyGU0, ... mentioned above) which understands the commands 209 (the /dev/ttyGU0, ... mentioned above) which understands the commands
@@ -164,9 +231,8 @@ GigaSet 307x Device Driver
164 231
165 options ppp_async flag_time=0 232 options ppp_async flag_time=0
166 233
167 to /etc/modprobe.conf. If your distribution has some local module 234 to an appropriate module configuration file, like /etc/modprobe.d/gigaset
168 configuration file like /etc/modprobe.conf.local, 235 or /etc/modprobe.conf.local.
169 using that should be preferred.
170 236
1712.6. Call-ID (CID) mode 2372.6. Call-ID (CID) mode
172 ------------------ 238 ------------------
@@ -189,12 +255,13 @@ GigaSet 307x Device Driver
189 settings (CID mode). 255 settings (CID mode).
190 - If you have several DECT data devices (M10x) which you want to use 256 - If you have several DECT data devices (M10x) which you want to use
191 in turn, select Unimodem mode by passing the parameter "cidmode=0" to 257 in turn, select Unimodem mode by passing the parameter "cidmode=0" to
192 the driver ("modprobe usb_gigaset cidmode=0" or modprobe.conf). 258 the appropriate driver module (ser_gigaset or usb_gigaset).
193 259
194 If you want both of these at once, you are out of luck. 260 If you want both of these at once, you are out of luck.
195 261
196 You can also use /sys/class/tty/ttyGxy/cidmode for changing the CID mode 262 You can also use the tty class parameter "cidmode" of the device to
197 setting (ttyGxy is ttyGU0 or ttyGB0). 263 change its CID mode while the driver is loaded, eg.
264 echo 0 > /sys/class/tty/ttyGU0/cidmode
198 265
1992.7. Unregistered Wireless Devices (M101/M105) 2662.7. Unregistered Wireless Devices (M101/M105)
200 ----------------------------------------- 267 -----------------------------------------
@@ -208,7 +275,7 @@ GigaSet 307x Device Driver
208 driver. In that situation, a restricted set of functions is available 275 driver. In that situation, a restricted set of functions is available
209 which includes, in particular, those necessary for registering the device 276 which includes, in particular, those necessary for registering the device
210 to a base or for switching it between Fixed Part and Portable Part 277 to a base or for switching it between Fixed Part and Portable Part
211 modes. 278 modes. See the gigacontr(8) manpage for details.
212 279
2133. Troubleshooting 2803. Troubleshooting
214 --------------- 281 ---------------
@@ -222,9 +289,7 @@ GigaSet 307x Device Driver
222 289
223 options isdn dialtimeout=15 290 options isdn dialtimeout=15
224 291
225 to /etc/modprobe.conf. If your distribution has some local module 292 to /etc/modprobe.d/gigaset, /etc/modprobe.conf.local or a similar file.
226 configuration file like /etc/modprobe.conf.local,
227 using that should be preferred.
228 293
229 Problem: 294 Problem:
230 Your isdn script aborts with a message about isdnlog. 295 Your isdn script aborts with a message about isdnlog.
@@ -264,7 +329,8 @@ GigaSet 307x Device Driver
264 The initial value can be set using the debug parameter when loading the 329 The initial value can be set using the debug parameter when loading the
265 module "gigaset", e.g. by adding a line 330 module "gigaset", e.g. by adding a line
266 options gigaset debug=0 331 options gigaset debug=0
267 to /etc/modprobe.conf, ... 332 to your module configuration file, eg. /etc/modprobe.d/gigaset or
333 /etc/modprobe.conf.local.
268 334
269 Generated debugging information can be found 335 Generated debugging information can be found
270 - as output of the command 336 - as output of the command
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index e90665876c47..e8c6529dc366 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -2505,7 +2505,7 @@ he_close(struct atm_vcc *vcc)
2505 * TBRQ, the host issues the close command to the adapter. 2505 * TBRQ, the host issues the close command to the adapter.
2506 */ 2506 */
2507 2507
2508 while (((tx_inuse = atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) > 0) && 2508 while (((tx_inuse = atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) > 1) &&
2509 (retry < MAX_RETRY)) { 2509 (retry < MAX_RETRY)) {
2510 msleep(sleep); 2510 msleep(sleep);
2511 if (sleep < 250) 2511 if (sleep < 250)
@@ -2514,7 +2514,7 @@ he_close(struct atm_vcc *vcc)
2514 ++retry; 2514 ++retry;
2515 } 2515 }
2516 2516
2517 if (tx_inuse) 2517 if (tx_inuse > 1)
2518 hprintk("close tx cid 0x%x tx_inuse = %d\n", cid, tx_inuse); 2518 hprintk("close tx cid 0x%x tx_inuse = %d\n", cid, tx_inuse);
2519 2519
2520 /* 2.3.1.1 generic close operations with flush */ 2520 /* 2.3.1.1 generic close operations with flush */
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 82ed1cd14ff5..664b0c519c3e 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -29,7 +29,7 @@
29#endif 29#endif
30 30
31/* Module parameters */ 31/* Module parameters */
32int gigaset_debuglevel = DEBUG_DEFAULT; 32int gigaset_debuglevel;
33EXPORT_SYMBOL_GPL(gigaset_debuglevel); 33EXPORT_SYMBOL_GPL(gigaset_debuglevel);
34module_param_named(debug, gigaset_debuglevel, int, S_IRUGO|S_IWUSR); 34module_param_named(debug, gigaset_debuglevel, int, S_IRUGO|S_IWUSR);
35MODULE_PARM_DESC(debug, "debug level"); 35MODULE_PARM_DESC(debug, "debug level");
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 0bbd5ae49862..18ff622703be 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2344,6 +2344,7 @@ config GELIC_NET
2344 2344
2345config GELIC_WIRELESS 2345config GELIC_WIRELESS
2346 bool "PS3 Wireless support" 2346 bool "PS3 Wireless support"
2347 depends on WLAN
2347 depends on GELIC_NET 2348 depends on GELIC_NET
2348 select WIRELESS_EXT 2349 select WIRELESS_EXT
2349 help 2350 help
@@ -2356,6 +2357,7 @@ config GELIC_WIRELESS
2356config GELIC_WIRELESS_OLD_PSK_INTERFACE 2357config GELIC_WIRELESS_OLD_PSK_INTERFACE
2357 bool "PS3 Wireless private PSK interface (OBSOLETE)" 2358 bool "PS3 Wireless private PSK interface (OBSOLETE)"
2358 depends on GELIC_WIRELESS 2359 depends on GELIC_WIRELESS
2360 select WEXT_PRIV
2359 help 2361 help
2360 This option retains the obsolete private interface to pass 2362 This option retains the obsolete private interface to pass
2361 the PSK from user space programs to the driver. The PSK 2363 the PSK from user space programs to the driver. The PSK
diff --git a/drivers/net/atl1c/atl1c.h b/drivers/net/atl1c/atl1c.h
index a348a22551d9..efe5435bc3d3 100644
--- a/drivers/net/atl1c/atl1c.h
+++ b/drivers/net/atl1c/atl1c.h
@@ -479,6 +479,9 @@ struct atl1c_buffer {
479#define ATL1C_PCIMAP_PAGE 0x0008 479#define ATL1C_PCIMAP_PAGE 0x0008
480#define ATL1C_PCIMAP_TYPE_MASK 0x000C 480#define ATL1C_PCIMAP_TYPE_MASK 0x000C
481 481
482#define ATL1C_PCIMAP_TODEVICE 0x0010
483#define ATL1C_PCIMAP_FROMDEVICE 0x0020
484#define ATL1C_PCIMAP_DIRECTION_MASK 0x0030
482 dma_addr_t dma; 485 dma_addr_t dma;
483}; 486};
484 487
@@ -487,9 +490,11 @@ struct atl1c_buffer {
487 ((buff)->flags) |= (state); \ 490 ((buff)->flags) |= (state); \
488 } while (0) 491 } while (0)
489 492
490#define ATL1C_SET_PCIMAP_TYPE(buff, type) do { \ 493#define ATL1C_SET_PCIMAP_TYPE(buff, type, direction) do { \
491 ((buff)->flags) &= ~ATL1C_PCIMAP_TYPE_MASK; \ 494 ((buff)->flags) &= ~ATL1C_PCIMAP_TYPE_MASK; \
492 ((buff)->flags) |= (type); \ 495 ((buff)->flags) |= (type); \
496 ((buff)->flags) &= ~ATL1C_PCIMAP_DIRECTION_MASK; \
497 ((buff)->flags) |= (direction); \
493 } while (0) 498 } while (0)
494 499
495/* transimit packet descriptor (tpd) ring */ 500/* transimit packet descriptor (tpd) ring */
@@ -550,6 +555,9 @@ struct atl1c_adapter {
550#define __AT_TESTING 0x0001 555#define __AT_TESTING 0x0001
551#define __AT_RESETTING 0x0002 556#define __AT_RESETTING 0x0002
552#define __AT_DOWN 0x0003 557#define __AT_DOWN 0x0003
558 u8 work_event;
559#define ATL1C_WORK_EVENT_RESET 0x01
560#define ATL1C_WORK_EVENT_LINK_CHANGE 0x02
553 u32 msg_enable; 561 u32 msg_enable;
554 562
555 bool have_msi; 563 bool have_msi;
@@ -561,8 +569,7 @@ struct atl1c_adapter {
561 spinlock_t tx_lock; 569 spinlock_t tx_lock;
562 atomic_t irq_sem; 570 atomic_t irq_sem;
563 571
564 struct work_struct reset_task; 572 struct work_struct common_task;
565 struct work_struct link_chg_task;
566 struct timer_list watchdog_timer; 573 struct timer_list watchdog_timer;
567 struct timer_list phy_config_timer; 574 struct timer_list phy_config_timer;
568 575
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index 1e2f57d4c367..666261b5851e 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -198,27 +198,12 @@ static void atl1c_phy_config(unsigned long data)
198 198
199void atl1c_reinit_locked(struct atl1c_adapter *adapter) 199void atl1c_reinit_locked(struct atl1c_adapter *adapter)
200{ 200{
201
202 WARN_ON(in_interrupt()); 201 WARN_ON(in_interrupt());
203 atl1c_down(adapter); 202 atl1c_down(adapter);
204 atl1c_up(adapter); 203 atl1c_up(adapter);
205 clear_bit(__AT_RESETTING, &adapter->flags); 204 clear_bit(__AT_RESETTING, &adapter->flags);
206} 205}
207 206
208static void atl1c_reset_task(struct work_struct *work)
209{
210 struct atl1c_adapter *adapter;
211 struct net_device *netdev;
212
213 adapter = container_of(work, struct atl1c_adapter, reset_task);
214 netdev = adapter->netdev;
215
216 netif_device_detach(netdev);
217 atl1c_down(adapter);
218 atl1c_up(adapter);
219 netif_device_attach(netdev);
220}
221
222static void atl1c_check_link_status(struct atl1c_adapter *adapter) 207static void atl1c_check_link_status(struct atl1c_adapter *adapter)
223{ 208{
224 struct atl1c_hw *hw = &adapter->hw; 209 struct atl1c_hw *hw = &adapter->hw;
@@ -275,18 +260,6 @@ static void atl1c_check_link_status(struct atl1c_adapter *adapter)
275 } 260 }
276} 261}
277 262
278/*
279 * atl1c_link_chg_task - deal with link change event Out of interrupt context
280 * @netdev: network interface device structure
281 */
282static void atl1c_link_chg_task(struct work_struct *work)
283{
284 struct atl1c_adapter *adapter;
285
286 adapter = container_of(work, struct atl1c_adapter, link_chg_task);
287 atl1c_check_link_status(adapter);
288}
289
290static void atl1c_link_chg_event(struct atl1c_adapter *adapter) 263static void atl1c_link_chg_event(struct atl1c_adapter *adapter)
291{ 264{
292 struct net_device *netdev = adapter->netdev; 265 struct net_device *netdev = adapter->netdev;
@@ -311,20 +284,40 @@ static void atl1c_link_chg_event(struct atl1c_adapter *adapter)
311 adapter->link_speed = SPEED_0; 284 adapter->link_speed = SPEED_0;
312 } 285 }
313 } 286 }
314 schedule_work(&adapter->link_chg_task); 287
288 adapter->work_event |= ATL1C_WORK_EVENT_LINK_CHANGE;
289 schedule_work(&adapter->common_task);
315} 290}
316 291
317static void atl1c_del_timer(struct atl1c_adapter *adapter) 292static void atl1c_common_task(struct work_struct *work)
318{ 293{
319 del_timer_sync(&adapter->phy_config_timer); 294 struct atl1c_adapter *adapter;
295 struct net_device *netdev;
296
297 adapter = container_of(work, struct atl1c_adapter, common_task);
298 netdev = adapter->netdev;
299
300 if (adapter->work_event & ATL1C_WORK_EVENT_RESET) {
301 netif_device_detach(netdev);
302 atl1c_down(adapter);
303 atl1c_up(adapter);
304 netif_device_attach(netdev);
305 return;
306 }
307
308 if (adapter->work_event & ATL1C_WORK_EVENT_LINK_CHANGE)
309 atl1c_check_link_status(adapter);
310
311 return;
320} 312}
321 313
322static void atl1c_cancel_work(struct atl1c_adapter *adapter) 314
315static void atl1c_del_timer(struct atl1c_adapter *adapter)
323{ 316{
324 cancel_work_sync(&adapter->reset_task); 317 del_timer_sync(&adapter->phy_config_timer);
325 cancel_work_sync(&adapter->link_chg_task);
326} 318}
327 319
320
328/* 321/*
329 * atl1c_tx_timeout - Respond to a Tx Hang 322 * atl1c_tx_timeout - Respond to a Tx Hang
330 * @netdev: network interface device structure 323 * @netdev: network interface device structure
@@ -334,7 +327,8 @@ static void atl1c_tx_timeout(struct net_device *netdev)
334 struct atl1c_adapter *adapter = netdev_priv(netdev); 327 struct atl1c_adapter *adapter = netdev_priv(netdev);
335 328
336 /* Do the reset outside of interrupt context */ 329 /* Do the reset outside of interrupt context */
337 schedule_work(&adapter->reset_task); 330 adapter->work_event |= ATL1C_WORK_EVENT_RESET;
331 schedule_work(&adapter->common_task);
338} 332}
339 333
340/* 334/*
@@ -713,15 +707,21 @@ static int __devinit atl1c_sw_init(struct atl1c_adapter *adapter)
713static inline void atl1c_clean_buffer(struct pci_dev *pdev, 707static inline void atl1c_clean_buffer(struct pci_dev *pdev,
714 struct atl1c_buffer *buffer_info, int in_irq) 708 struct atl1c_buffer *buffer_info, int in_irq)
715{ 709{
710 u16 pci_driection;
716 if (buffer_info->flags & ATL1C_BUFFER_FREE) 711 if (buffer_info->flags & ATL1C_BUFFER_FREE)
717 return; 712 return;
718 if (buffer_info->dma) { 713 if (buffer_info->dma) {
714 if (buffer_info->flags & ATL1C_PCIMAP_FROMDEVICE)
715 pci_driection = PCI_DMA_FROMDEVICE;
716 else
717 pci_driection = PCI_DMA_TODEVICE;
718
719 if (buffer_info->flags & ATL1C_PCIMAP_SINGLE) 719 if (buffer_info->flags & ATL1C_PCIMAP_SINGLE)
720 pci_unmap_single(pdev, buffer_info->dma, 720 pci_unmap_single(pdev, buffer_info->dma,
721 buffer_info->length, PCI_DMA_TODEVICE); 721 buffer_info->length, pci_driection);
722 else if (buffer_info->flags & ATL1C_PCIMAP_PAGE) 722 else if (buffer_info->flags & ATL1C_PCIMAP_PAGE)
723 pci_unmap_page(pdev, buffer_info->dma, 723 pci_unmap_page(pdev, buffer_info->dma,
724 buffer_info->length, PCI_DMA_TODEVICE); 724 buffer_info->length, pci_driection);
725 } 725 }
726 if (buffer_info->skb) { 726 if (buffer_info->skb) {
727 if (in_irq) 727 if (in_irq)
@@ -1533,7 +1533,8 @@ static irqreturn_t atl1c_intr(int irq, void *data)
1533 /* reset MAC */ 1533 /* reset MAC */
1534 hw->intr_mask &= ~ISR_ERROR; 1534 hw->intr_mask &= ~ISR_ERROR;
1535 AT_WRITE_REG(hw, REG_IMR, hw->intr_mask); 1535 AT_WRITE_REG(hw, REG_IMR, hw->intr_mask);
1536 schedule_work(&adapter->reset_task); 1536 adapter->work_event |= ATL1C_WORK_EVENT_RESET;
1537 schedule_work(&adapter->common_task);
1537 break; 1538 break;
1538 } 1539 }
1539 1540
@@ -1606,7 +1607,8 @@ static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter, const int ringid
1606 buffer_info->dma = pci_map_single(pdev, vir_addr, 1607 buffer_info->dma = pci_map_single(pdev, vir_addr,
1607 buffer_info->length, 1608 buffer_info->length,
1608 PCI_DMA_FROMDEVICE); 1609 PCI_DMA_FROMDEVICE);
1609 ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE); 1610 ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE,
1611 ATL1C_PCIMAP_FROMDEVICE);
1610 rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma); 1612 rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
1611 rfd_next_to_use = next_next; 1613 rfd_next_to_use = next_next;
1612 if (++next_next == rfd_ring->count) 1614 if (++next_next == rfd_ring->count)
@@ -1967,7 +1969,8 @@ static void atl1c_tx_map(struct atl1c_adapter *adapter,
1967 buffer_info->dma = pci_map_single(adapter->pdev, 1969 buffer_info->dma = pci_map_single(adapter->pdev,
1968 skb->data, hdr_len, PCI_DMA_TODEVICE); 1970 skb->data, hdr_len, PCI_DMA_TODEVICE);
1969 ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); 1971 ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY);
1970 ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE); 1972 ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE,
1973 ATL1C_PCIMAP_TODEVICE);
1971 mapped_len += map_len; 1974 mapped_len += map_len;
1972 use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); 1975 use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma);
1973 use_tpd->buffer_len = cpu_to_le16(buffer_info->length); 1976 use_tpd->buffer_len = cpu_to_le16(buffer_info->length);
@@ -1988,7 +1991,8 @@ static void atl1c_tx_map(struct atl1c_adapter *adapter,
1988 pci_map_single(adapter->pdev, skb->data + mapped_len, 1991 pci_map_single(adapter->pdev, skb->data + mapped_len,
1989 buffer_info->length, PCI_DMA_TODEVICE); 1992 buffer_info->length, PCI_DMA_TODEVICE);
1990 ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); 1993 ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY);
1991 ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE); 1994 ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE,
1995 ATL1C_PCIMAP_TODEVICE);
1992 use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); 1996 use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma);
1993 use_tpd->buffer_len = cpu_to_le16(buffer_info->length); 1997 use_tpd->buffer_len = cpu_to_le16(buffer_info->length);
1994 } 1998 }
@@ -2009,7 +2013,8 @@ static void atl1c_tx_map(struct atl1c_adapter *adapter,
2009 buffer_info->length, 2013 buffer_info->length,
2010 PCI_DMA_TODEVICE); 2014 PCI_DMA_TODEVICE);
2011 ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); 2015 ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY);
2012 ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_PAGE); 2016 ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_PAGE,
2017 ATL1C_PCIMAP_TODEVICE);
2013 use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); 2018 use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma);
2014 use_tpd->buffer_len = cpu_to_le16(buffer_info->length); 2019 use_tpd->buffer_len = cpu_to_le16(buffer_info->length);
2015 } 2020 }
@@ -2198,8 +2203,7 @@ void atl1c_down(struct atl1c_adapter *adapter)
2198 struct net_device *netdev = adapter->netdev; 2203 struct net_device *netdev = adapter->netdev;
2199 2204
2200 atl1c_del_timer(adapter); 2205 atl1c_del_timer(adapter);
2201 atl1c_cancel_work(adapter); 2206 adapter->work_event = 0; /* clear all event */
2202
2203 /* signal that we're down so the interrupt handler does not 2207 /* signal that we're down so the interrupt handler does not
2204 * reschedule our watchdog timer */ 2208 * reschedule our watchdog timer */
2205 set_bit(__AT_DOWN, &adapter->flags); 2209 set_bit(__AT_DOWN, &adapter->flags);
@@ -2599,8 +2603,8 @@ static int __devinit atl1c_probe(struct pci_dev *pdev,
2599 adapter->hw.mac_addr[4], adapter->hw.mac_addr[5]); 2603 adapter->hw.mac_addr[4], adapter->hw.mac_addr[5]);
2600 2604
2601 atl1c_hw_set_mac_addr(&adapter->hw); 2605 atl1c_hw_set_mac_addr(&adapter->hw);
2602 INIT_WORK(&adapter->reset_task, atl1c_reset_task); 2606 INIT_WORK(&adapter->common_task, atl1c_common_task);
2603 INIT_WORK(&adapter->link_chg_task, atl1c_link_chg_task); 2607 adapter->work_event = 0;
2604 err = register_netdev(netdev); 2608 err = register_netdev(netdev);
2605 if (err) { 2609 if (err) {
2606 dev_err(&pdev->dev, "register netdevice failed\n"); 2610 dev_err(&pdev->dev, "register netdevice failed\n");
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 2a9132343b66..4869adb69586 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -1505,8 +1505,7 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset)
1505 for (k = 0; k< ethaddr_bytes; k++) { 1505 for (k = 0; k< ethaddr_bytes; k++) {
1506 ppattern[offset + magicsync + 1506 ppattern[offset + magicsync +
1507 (j * ETH_ALEN) + k] = macaddr[k]; 1507 (j * ETH_ALEN) + k] = macaddr[k];
1508 len++; 1508 set_bit(len++, (unsigned long *) pmask);
1509 set_bit(len, (unsigned long *) pmask);
1510 } 1509 }
1511 } 1510 }
1512 return len - 1; 1511 return len - 1;
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index 86d2809763c3..e02e38221ed4 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -74,7 +74,7 @@
74#define E1000_WUS_BC E1000_WUFC_BC 74#define E1000_WUS_BC E1000_WUFC_BC
75 75
76/* Extended Device Control */ 76/* Extended Device Control */
77#define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Definable Pin 7 */ 77#define E1000_CTRL_EXT_SDP3_DATA 0x00000080 /* Value of SW Definable Pin 3 */
78#define E1000_CTRL_EXT_EE_RST 0x00002000 /* Reinitialize from EEPROM */ 78#define E1000_CTRL_EXT_EE_RST 0x00002000 /* Reinitialize from EEPROM */
79#define E1000_CTRL_EXT_SPD_BYPS 0x00008000 /* Speed Select Bypass */ 79#define E1000_CTRL_EXT_SPD_BYPS 0x00008000 /* Speed Select Bypass */
80#define E1000_CTRL_EXT_RO_DIS 0x00020000 /* Relaxed Ordering disable */ 80#define E1000_CTRL_EXT_RO_DIS 0x00020000 /* Relaxed Ordering disable */
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index d2a104794609..3028f23da891 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -46,6 +46,9 @@
46#define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT 0x0000 46#define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT 0x0000
47#define E1000_KMRNCTRLSTA_OPMODE_E_IDLE 0x2000 47#define E1000_KMRNCTRLSTA_OPMODE_E_IDLE 0x2000
48 48
49#define E1000_KMRNCTRLSTA_OPMODE_MASK 0x000C
50#define E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO 0x0004
51
49#define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */ 52#define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */
50#define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN 0x00010000 53#define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN 0x00010000
51 54
@@ -462,28 +465,36 @@ static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
462 return ret_val; 465 return ret_val;
463 } 466 }
464 467
465 /* 468 if (hw->dev_spec.e80003es2lan.mdic_wa_enable == true) {
466 * The "ready" bit in the MDIC register may be incorrectly set 469 /*
467 * before the device has completed the "Page Select" MDI 470 * The "ready" bit in the MDIC register may be incorrectly set
468 * transaction. So we wait 200us after each MDI command... 471 * before the device has completed the "Page Select" MDI
469 */ 472 * transaction. So we wait 200us after each MDI command...
470 udelay(200); 473 */
474 udelay(200);
471 475
472 /* ...and verify the command was successful. */ 476 /* ...and verify the command was successful. */
473 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp); 477 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
474 478
475 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) { 479 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
476 ret_val = -E1000_ERR_PHY; 480 ret_val = -E1000_ERR_PHY;
477 e1000_release_phy_80003es2lan(hw); 481 e1000_release_phy_80003es2lan(hw);
478 return ret_val; 482 return ret_val;
479 } 483 }
480 484
481 udelay(200); 485 udelay(200);
482 486
483 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 487 ret_val = e1000e_read_phy_reg_mdic(hw,
484 data); 488 MAX_PHY_REG_ADDRESS & offset,
489 data);
490
491 udelay(200);
492 } else {
493 ret_val = e1000e_read_phy_reg_mdic(hw,
494 MAX_PHY_REG_ADDRESS & offset,
495 data);
496 }
485 497
486 udelay(200);
487 e1000_release_phy_80003es2lan(hw); 498 e1000_release_phy_80003es2lan(hw);
488 499
489 return ret_val; 500 return ret_val;
@@ -526,28 +537,35 @@ static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
526 return ret_val; 537 return ret_val;
527 } 538 }
528 539
540 if (hw->dev_spec.e80003es2lan.mdic_wa_enable == true) {
541 /*
542 * The "ready" bit in the MDIC register may be incorrectly set
543 * before the device has completed the "Page Select" MDI
544 * transaction. So we wait 200us after each MDI command...
545 */
546 udelay(200);
529 547
530 /* 548 /* ...and verify the command was successful. */
531 * The "ready" bit in the MDIC register may be incorrectly set 549 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
532 * before the device has completed the "Page Select" MDI
533 * transaction. So we wait 200us after each MDI command...
534 */
535 udelay(200);
536 550
537 /* ...and verify the command was successful. */ 551 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
538 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp); 552 e1000_release_phy_80003es2lan(hw);
553 return -E1000_ERR_PHY;
554 }
539 555
540 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) { 556 udelay(200);
541 e1000_release_phy_80003es2lan(hw);
542 return -E1000_ERR_PHY;
543 }
544 557
545 udelay(200); 558 ret_val = e1000e_write_phy_reg_mdic(hw,
559 MAX_PHY_REG_ADDRESS & offset,
560 data);
546 561
547 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, 562 udelay(200);
548 data); 563 } else {
564 ret_val = e1000e_write_phy_reg_mdic(hw,
565 MAX_PHY_REG_ADDRESS & offset,
566 data);
567 }
549 568
550 udelay(200);
551 e1000_release_phy_80003es2lan(hw); 569 e1000_release_phy_80003es2lan(hw);
552 570
553 return ret_val; 571 return ret_val;
@@ -866,6 +884,19 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
866 reg_data &= ~0x00100000; 884 reg_data &= ~0x00100000;
867 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data); 885 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
868 886
887 /* default to true to enable the MDIC W/A */
888 hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
889
890 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
891 E1000_KMRNCTRLSTA_OFFSET >>
892 E1000_KMRNCTRLSTA_OFFSET_SHIFT,
893 &i);
894 if (!ret_val) {
895 if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
896 E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
897 hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
898 }
899
869 /* 900 /*
870 * Clear all of the statistics registers (clear on read). It is 901 * Clear all of the statistics registers (clear on read). It is
871 * important that we do this after we have tried to establish link 902 * important that we do this after we have tried to establish link
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index a7d08dae79c4..2784cf44a6f3 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -302,6 +302,8 @@ enum e1e_registers {
302#define E1000_KMRNCTRLSTA_OFFSET_SHIFT 16 302#define E1000_KMRNCTRLSTA_OFFSET_SHIFT 16
303#define E1000_KMRNCTRLSTA_REN 0x00200000 303#define E1000_KMRNCTRLSTA_REN 0x00200000
304#define E1000_KMRNCTRLSTA_DIAG_OFFSET 0x3 /* Kumeran Diagnostic */ 304#define E1000_KMRNCTRLSTA_DIAG_OFFSET 0x3 /* Kumeran Diagnostic */
305#define E1000_KMRNCTRLSTA_TIMEOUTS 0x4 /* Kumeran Timeouts */
306#define E1000_KMRNCTRLSTA_INBAND_PARAM 0x9 /* Kumeran InBand Parameters */
305#define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */ 307#define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */
306#define E1000_KMRNCTRLSTA_K1_CONFIG 0x7 308#define E1000_KMRNCTRLSTA_K1_CONFIG 0x7
307#define E1000_KMRNCTRLSTA_K1_ENABLE 0x140E 309#define E1000_KMRNCTRLSTA_K1_ENABLE 0x140E
@@ -898,6 +900,10 @@ struct e1000_dev_spec_82571 {
898 u32 smb_counter; 900 u32 smb_counter;
899}; 901};
900 902
903struct e1000_dev_spec_80003es2lan {
904 bool mdic_wa_enable;
905};
906
901struct e1000_shadow_ram { 907struct e1000_shadow_ram {
902 u16 value; 908 u16 value;
903 bool modified; 909 bool modified;
@@ -926,6 +932,7 @@ struct e1000_hw {
926 932
927 union { 933 union {
928 struct e1000_dev_spec_82571 e82571; 934 struct e1000_dev_spec_82571 e82571;
935 struct e1000_dev_spec_80003es2lan e80003es2lan;
929 struct e1000_dev_spec_ich8lan ich8lan; 936 struct e1000_dev_spec_ich8lan ich8lan;
930 } dev_spec; 937 } dev_spec;
931}; 938};
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 7b33be98a2ca..9b09246af064 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -2755,14 +2755,16 @@ static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
2755 * and increase the max iterations when polling the phy; 2755 * and increase the max iterations when polling the phy;
2756 * this fixes erroneous timeouts at 10Mbps. 2756 * this fixes erroneous timeouts at 10Mbps.
2757 */ 2757 */
2758 ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF); 2758 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
2759 if (ret_val) 2759 if (ret_val)
2760 return ret_val; 2760 return ret_val;
2761 ret_val = e1000e_read_kmrn_reg(hw, GG82563_REG(0x34, 9), &reg_data); 2761 ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
2762 &reg_data);
2762 if (ret_val) 2763 if (ret_val)
2763 return ret_val; 2764 return ret_val;
2764 reg_data |= 0x3F; 2765 reg_data |= 0x3F;
2765 ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data); 2766 ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
2767 reg_data);
2766 if (ret_val) 2768 if (ret_val)
2767 return ret_val; 2769 return ret_val;
2768 2770
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index c3105c5087e0..762b697ce731 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4541,7 +4541,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
4541 e1000_media_type_internal_serdes) { 4541 e1000_media_type_internal_serdes) {
4542 /* keep the laser running in D3 */ 4542 /* keep the laser running in D3 */
4543 ctrl_ext = er32(CTRL_EXT); 4543 ctrl_ext = er32(CTRL_EXT);
4544 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA; 4544 ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA;
4545 ew32(CTRL_EXT, ctrl_ext); 4545 ew32(CTRL_EXT, ctrl_ext);
4546 } 4546 }
4547 4547
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 6407672b28e9..848e8407ea8f 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -85,11 +85,15 @@ MODULE_PARM_DESC(debug, "debugging messages level");
85 85
86static void mpc52xx_fec_tx_timeout(struct net_device *dev) 86static void mpc52xx_fec_tx_timeout(struct net_device *dev)
87{ 87{
88 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
89 unsigned long flags;
90
88 dev_warn(&dev->dev, "transmit timed out\n"); 91 dev_warn(&dev->dev, "transmit timed out\n");
89 92
93 spin_lock_irqsave(&priv->lock, flags);
90 mpc52xx_fec_reset(dev); 94 mpc52xx_fec_reset(dev);
91
92 dev->stats.tx_errors++; 95 dev->stats.tx_errors++;
96 spin_unlock_irqrestore(&priv->lock, flags);
93 97
94 netif_wake_queue(dev); 98 netif_wake_queue(dev);
95} 99}
@@ -135,28 +139,32 @@ static void mpc52xx_fec_free_rx_buffers(struct net_device *dev, struct bcom_task
135 } 139 }
136} 140}
137 141
142static void
143mpc52xx_fec_rx_submit(struct net_device *dev, struct sk_buff *rskb)
144{
145 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
146 struct bcom_fec_bd *bd;
147
148 bd = (struct bcom_fec_bd *) bcom_prepare_next_buffer(priv->rx_dmatsk);
149 bd->status = FEC_RX_BUFFER_SIZE;
150 bd->skb_pa = dma_map_single(dev->dev.parent, rskb->data,
151 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
152 bcom_submit_next_buffer(priv->rx_dmatsk, rskb);
153}
154
138static int mpc52xx_fec_alloc_rx_buffers(struct net_device *dev, struct bcom_task *rxtsk) 155static int mpc52xx_fec_alloc_rx_buffers(struct net_device *dev, struct bcom_task *rxtsk)
139{ 156{
140 while (!bcom_queue_full(rxtsk)) { 157 struct sk_buff *skb;
141 struct sk_buff *skb;
142 struct bcom_fec_bd *bd;
143 158
159 while (!bcom_queue_full(rxtsk)) {
144 skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); 160 skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE);
145 if (skb == NULL) 161 if (!skb)
146 return -EAGAIN; 162 return -EAGAIN;
147 163
148 /* zero out the initial receive buffers to aid debugging */ 164 /* zero out the initial receive buffers to aid debugging */
149 memset(skb->data, 0, FEC_RX_BUFFER_SIZE); 165 memset(skb->data, 0, FEC_RX_BUFFER_SIZE);
150 166 mpc52xx_fec_rx_submit(dev, skb);
151 bd = (struct bcom_fec_bd *)bcom_prepare_next_buffer(rxtsk);
152
153 bd->status = FEC_RX_BUFFER_SIZE;
154 bd->skb_pa = dma_map_single(dev->dev.parent, skb->data,
155 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
156
157 bcom_submit_next_buffer(rxtsk, skb);
158 } 167 }
159
160 return 0; 168 return 0;
161} 169}
162 170
@@ -328,13 +336,12 @@ static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
328 DMA_TO_DEVICE); 336 DMA_TO_DEVICE);
329 337
330 bcom_submit_next_buffer(priv->tx_dmatsk, skb); 338 bcom_submit_next_buffer(priv->tx_dmatsk, skb);
339 spin_unlock_irqrestore(&priv->lock, flags);
331 340
332 if (bcom_queue_full(priv->tx_dmatsk)) { 341 if (bcom_queue_full(priv->tx_dmatsk)) {
333 netif_stop_queue(dev); 342 netif_stop_queue(dev);
334 } 343 }
335 344
336 spin_unlock_irqrestore(&priv->lock, flags);
337
338 return NETDEV_TX_OK; 345 return NETDEV_TX_OK;
339} 346}
340 347
@@ -359,9 +366,9 @@ static irqreturn_t mpc52xx_fec_tx_interrupt(int irq, void *dev_id)
359{ 366{
360 struct net_device *dev = dev_id; 367 struct net_device *dev = dev_id;
361 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 368 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
369 unsigned long flags;
362 370
363 spin_lock(&priv->lock); 371 spin_lock_irqsave(&priv->lock, flags);
364
365 while (bcom_buffer_done(priv->tx_dmatsk)) { 372 while (bcom_buffer_done(priv->tx_dmatsk)) {
366 struct sk_buff *skb; 373 struct sk_buff *skb;
367 struct bcom_fec_bd *bd; 374 struct bcom_fec_bd *bd;
@@ -372,11 +379,10 @@ static irqreturn_t mpc52xx_fec_tx_interrupt(int irq, void *dev_id)
372 379
373 dev_kfree_skb_irq(skb); 380 dev_kfree_skb_irq(skb);
374 } 381 }
382 spin_unlock_irqrestore(&priv->lock, flags);
375 383
376 netif_wake_queue(dev); 384 netif_wake_queue(dev);
377 385
378 spin_unlock(&priv->lock);
379
380 return IRQ_HANDLED; 386 return IRQ_HANDLED;
381} 387}
382 388
@@ -384,67 +390,60 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
384{ 390{
385 struct net_device *dev = dev_id; 391 struct net_device *dev = dev_id;
386 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 392 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
393 struct sk_buff *rskb; /* received sk_buff */
394 struct sk_buff *skb; /* new sk_buff to enqueue in its place */
395 struct bcom_fec_bd *bd;
396 u32 status, physaddr;
397 int length;
398 unsigned long flags;
399
400 spin_lock_irqsave(&priv->lock, flags);
387 401
388 while (bcom_buffer_done(priv->rx_dmatsk)) { 402 while (bcom_buffer_done(priv->rx_dmatsk)) {
389 struct sk_buff *skb;
390 struct sk_buff *rskb;
391 struct bcom_fec_bd *bd;
392 u32 status;
393 403
394 rskb = bcom_retrieve_buffer(priv->rx_dmatsk, &status, 404 rskb = bcom_retrieve_buffer(priv->rx_dmatsk, &status,
395 (struct bcom_bd **)&bd); 405 (struct bcom_bd **)&bd);
396 dma_unmap_single(dev->dev.parent, bd->skb_pa, rskb->len, 406 physaddr = bd->skb_pa;
397 DMA_FROM_DEVICE);
398 407
399 /* Test for errors in received frame */ 408 /* Test for errors in received frame */
400 if (status & BCOM_FEC_RX_BD_ERRORS) { 409 if (status & BCOM_FEC_RX_BD_ERRORS) {
401 /* Drop packet and reuse the buffer */ 410 /* Drop packet and reuse the buffer */
402 bd = (struct bcom_fec_bd *) 411 mpc52xx_fec_rx_submit(dev, rskb);
403 bcom_prepare_next_buffer(priv->rx_dmatsk);
404
405 bd->status = FEC_RX_BUFFER_SIZE;
406 bd->skb_pa = dma_map_single(dev->dev.parent,
407 rskb->data,
408 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
409
410 bcom_submit_next_buffer(priv->rx_dmatsk, rskb);
411
412 dev->stats.rx_dropped++; 412 dev->stats.rx_dropped++;
413
414 continue; 413 continue;
415 } 414 }
416 415
417 /* skbs are allocated on open, so now we allocate a new one, 416 /* skbs are allocated on open, so now we allocate a new one,
418 * and remove the old (with the packet) */ 417 * and remove the old (with the packet) */
419 skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); 418 skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE);
420 if (skb) { 419 if (!skb) {
421 /* Process the received skb */
422 int length = status & BCOM_FEC_RX_BD_LEN_MASK;
423
424 skb_put(rskb, length - 4); /* length without CRC32 */
425
426 rskb->dev = dev;
427 rskb->protocol = eth_type_trans(rskb, dev);
428
429 netif_rx(rskb);
430 } else {
431 /* Can't get a new one : reuse the same & drop pkt */ 420 /* Can't get a new one : reuse the same & drop pkt */
432 dev_notice(&dev->dev, "Memory squeeze, dropping packet.\n"); 421 dev_notice(&dev->dev, "Low memory - dropped packet.\n");
422 mpc52xx_fec_rx_submit(dev, rskb);
433 dev->stats.rx_dropped++; 423 dev->stats.rx_dropped++;
434 424 continue;
435 skb = rskb;
436 } 425 }
437 426
438 bd = (struct bcom_fec_bd *) 427 /* Enqueue the new sk_buff back on the hardware */
439 bcom_prepare_next_buffer(priv->rx_dmatsk); 428 mpc52xx_fec_rx_submit(dev, skb);
440 429
441 bd->status = FEC_RX_BUFFER_SIZE; 430 /* Process the received skb - Drop the spin lock while
442 bd->skb_pa = dma_map_single(dev->dev.parent, skb->data, 431 * calling into the network stack */
443 FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); 432 spin_unlock_irqrestore(&priv->lock, flags);
444 433
445 bcom_submit_next_buffer(priv->rx_dmatsk, skb); 434 dma_unmap_single(dev->dev.parent, physaddr, rskb->len,
435 DMA_FROM_DEVICE);
436 length = status & BCOM_FEC_RX_BD_LEN_MASK;
437 skb_put(rskb, length - 4); /* length without CRC32 */
438 rskb->dev = dev;
439 rskb->protocol = eth_type_trans(rskb, dev);
440 netif_rx(rskb);
441
442 spin_lock_irqsave(&priv->lock, flags);
446 } 443 }
447 444
445 spin_unlock_irqrestore(&priv->lock, flags);
446
448 return IRQ_HANDLED; 447 return IRQ_HANDLED;
449} 448}
450 449
@@ -454,6 +453,7 @@ static irqreturn_t mpc52xx_fec_interrupt(int irq, void *dev_id)
454 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 453 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
455 struct mpc52xx_fec __iomem *fec = priv->fec; 454 struct mpc52xx_fec __iomem *fec = priv->fec;
456 u32 ievent; 455 u32 ievent;
456 unsigned long flags;
457 457
458 ievent = in_be32(&fec->ievent); 458 ievent = in_be32(&fec->ievent);
459 459
@@ -471,9 +471,10 @@ static irqreturn_t mpc52xx_fec_interrupt(int irq, void *dev_id)
471 if (net_ratelimit() && (ievent & FEC_IEVENT_XFIFO_ERROR)) 471 if (net_ratelimit() && (ievent & FEC_IEVENT_XFIFO_ERROR))
472 dev_warn(&dev->dev, "FEC_IEVENT_XFIFO_ERROR\n"); 472 dev_warn(&dev->dev, "FEC_IEVENT_XFIFO_ERROR\n");
473 473
474 spin_lock_irqsave(&priv->lock, flags);
474 mpc52xx_fec_reset(dev); 475 mpc52xx_fec_reset(dev);
476 spin_unlock_irqrestore(&priv->lock, flags);
475 477
476 netif_wake_queue(dev);
477 return IRQ_HANDLED; 478 return IRQ_HANDLED;
478 } 479 }
479 480
@@ -768,6 +769,8 @@ static void mpc52xx_fec_reset(struct net_device *dev)
768 bcom_enable(priv->tx_dmatsk); 769 bcom_enable(priv->tx_dmatsk);
769 770
770 mpc52xx_fec_start(dev); 771 mpc52xx_fec_start(dev);
772
773 netif_wake_queue(dev);
771} 774}
772 775
773 776
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 16def131c390..6850dc0a7b91 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -2644,6 +2644,7 @@ static void gfar_netpoll(struct net_device *dev)
2644 gfar_interrupt(priv->gfargrp[i].interruptTransmit, 2644 gfar_interrupt(priv->gfargrp[i].interruptTransmit,
2645 &priv->gfargrp[i]); 2645 &priv->gfargrp[i]);
2646 enable_irq(priv->gfargrp[i].interruptTransmit); 2646 enable_irq(priv->gfargrp[i].interruptTransmit);
2647 }
2647 } 2648 }
2648} 2649}
2649#endif 2650#endif
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index 72106898a5cb..538340527aa6 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -342,6 +342,7 @@ static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
342 case IXGBE_DEV_ID_82599_KX4: 342 case IXGBE_DEV_ID_82599_KX4:
343 case IXGBE_DEV_ID_82599_KX4_MEZZ: 343 case IXGBE_DEV_ID_82599_KX4_MEZZ:
344 case IXGBE_DEV_ID_82599_COMBO_BACKPLANE: 344 case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
345 case IXGBE_DEV_ID_82599_KR:
345 case IXGBE_DEV_ID_82599_XAUI_LOM: 346 case IXGBE_DEV_ID_82599_XAUI_LOM:
346 /* Default device ID is mezzanine card KX/KX4 */ 347 /* Default device ID is mezzanine card KX/KX4 */
347 media_type = ixgbe_media_type_backplane; 348 media_type = ixgbe_media_type_backplane;
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 06a9d18bbdbc..0bd49d3b9f65 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -990,6 +990,7 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
990 char *p = NULL; 990 char *p = NULL;
991 991
992 ixgbe_update_stats(adapter); 992 ixgbe_update_stats(adapter);
993 dev_get_stats(netdev);
993 for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) { 994 for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) {
994 switch (ixgbe_gstrings_stats[i].type) { 995 switch (ixgbe_gstrings_stats[i].type) {
995 case NETDEV_STATS: 996 case NETDEV_STATS:
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 247ed2a24769..35ea8c93fd80 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -96,6 +96,8 @@ static struct pci_device_id ixgbe_pci_tbl[] = {
96 board_82599 }, 96 board_82599 },
97 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_XAUI_LOM), 97 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_XAUI_LOM),
98 board_82599 }, 98 board_82599 },
99 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_KR),
100 board_82599 },
99 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP), 101 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP),
100 board_82599 }, 102 board_82599 },
101 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP_EM), 103 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP_EM),
@@ -435,8 +437,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,
435 tx_ring->total_packets += total_packets; 437 tx_ring->total_packets += total_packets;
436 tx_ring->stats.packets += total_packets; 438 tx_ring->stats.packets += total_packets;
437 tx_ring->stats.bytes += total_bytes; 439 tx_ring->stats.bytes += total_bytes;
438 netdev->stats.tx_bytes += total_bytes;
439 netdev->stats.tx_packets += total_packets;
440 return (count < tx_ring->work_limit); 440 return (count < tx_ring->work_limit);
441} 441}
442 442
@@ -5327,6 +5327,7 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
5327{ 5327{
5328 struct ixgbe_adapter *adapter = netdev_priv(netdev); 5328 struct ixgbe_adapter *adapter = netdev_priv(netdev);
5329 struct ixgbe_ring *tx_ring; 5329 struct ixgbe_ring *tx_ring;
5330 struct netdev_queue *txq;
5330 unsigned int first; 5331 unsigned int first;
5331 unsigned int tx_flags = 0; 5332 unsigned int tx_flags = 0;
5332 u8 hdr_len = 0; 5333 u8 hdr_len = 0;
@@ -5424,6 +5425,9 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
5424 tx_ring->atr_count = 0; 5425 tx_ring->atr_count = 0;
5425 } 5426 }
5426 } 5427 }
5428 txq = netdev_get_tx_queue(netdev, tx_ring->queue_index);
5429 txq->tx_bytes += skb->len;
5430 txq->tx_packets++;
5427 ixgbe_tx_queue(adapter, tx_ring, tx_flags, count, skb->len, 5431 ixgbe_tx_queue(adapter, tx_ring, tx_flags, count, skb->len,
5428 hdr_len); 5432 hdr_len);
5429 ixgbe_maybe_stop_tx(netdev, tx_ring, DESC_NEEDED); 5433 ixgbe_maybe_stop_tx(netdev, tx_ring, DESC_NEEDED);
@@ -5438,19 +5442,6 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
5438} 5442}
5439 5443
5440/** 5444/**
5441 * ixgbe_get_stats - Get System Network Statistics
5442 * @netdev: network interface device structure
5443 *
5444 * Returns the address of the device statistics structure.
5445 * The statistics are actually updated from the timer callback.
5446 **/
5447static struct net_device_stats *ixgbe_get_stats(struct net_device *netdev)
5448{
5449 /* only return the current stats */
5450 return &netdev->stats;
5451}
5452
5453/**
5454 * ixgbe_set_mac - Change the Ethernet Address of the NIC 5445 * ixgbe_set_mac - Change the Ethernet Address of the NIC
5455 * @netdev: network interface device structure 5446 * @netdev: network interface device structure
5456 * @p: pointer to an address structure 5447 * @p: pointer to an address structure
@@ -5580,7 +5571,6 @@ static const struct net_device_ops ixgbe_netdev_ops = {
5580 .ndo_stop = ixgbe_close, 5571 .ndo_stop = ixgbe_close,
5581 .ndo_start_xmit = ixgbe_xmit_frame, 5572 .ndo_start_xmit = ixgbe_xmit_frame,
5582 .ndo_select_queue = ixgbe_select_queue, 5573 .ndo_select_queue = ixgbe_select_queue,
5583 .ndo_get_stats = ixgbe_get_stats,
5584 .ndo_set_rx_mode = ixgbe_set_rx_mode, 5574 .ndo_set_rx_mode = ixgbe_set_rx_mode,
5585 .ndo_set_multicast_list = ixgbe_set_rx_mode, 5575 .ndo_set_multicast_list = ixgbe_set_rx_mode,
5586 .ndo_validate_addr = eth_validate_addr, 5576 .ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 21b6633da578..f3e8d52610b7 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -50,6 +50,7 @@
50#define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4 50#define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4
51#define IXGBE_DEV_ID_82599_KX4 0x10F7 51#define IXGBE_DEV_ID_82599_KX4 0x10F7
52#define IXGBE_DEV_ID_82599_KX4_MEZZ 0x1514 52#define IXGBE_DEV_ID_82599_KX4_MEZZ 0x1514
53#define IXGBE_DEV_ID_82599_KR 0x1517
53#define IXGBE_DEV_ID_82599_CX4 0x10F9 54#define IXGBE_DEV_ID_82599_CX4 0x10F9
54#define IXGBE_DEV_ID_82599_SFP 0x10FB 55#define IXGBE_DEV_ID_82599_SFP 0x10FB
55#define IXGBE_DEV_ID_82599_SFP_EM 0x1507 56#define IXGBE_DEV_ID_82599_SFP_EM 0x1507
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 796a493f95ab..1405a170bb43 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1827,6 +1827,9 @@ static int mv643xx_eth_set_mac_address(struct net_device *dev, void *addr)
1827{ 1827{
1828 struct sockaddr *sa = addr; 1828 struct sockaddr *sa = addr;
1829 1829
1830 if (!is_valid_ether_addr(sa->sa_data))
1831 return -EINVAL;
1832
1830 memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN); 1833 memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
1831 1834
1832 netif_addr_lock_bh(dev); 1835 netif_addr_lock_bh(dev);
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index d38921906bb7..3fcb1c356e0d 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -75,7 +75,7 @@
75#include "myri10ge_mcp.h" 75#include "myri10ge_mcp.h"
76#include "myri10ge_mcp_gen_header.h" 76#include "myri10ge_mcp_gen_header.h"
77 77
78#define MYRI10GE_VERSION_STR "1.5.1-1.451" 78#define MYRI10GE_VERSION_STR "1.5.1-1.453"
79 79
80MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); 80MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
81MODULE_AUTHOR("Maintainer: help@myri.com"); 81MODULE_AUTHOR("Maintainer: help@myri.com");
@@ -347,7 +347,7 @@ static int myri10ge_max_slices = 1;
347module_param(myri10ge_max_slices, int, S_IRUGO); 347module_param(myri10ge_max_slices, int, S_IRUGO);
348MODULE_PARM_DESC(myri10ge_max_slices, "Max tx/rx queues"); 348MODULE_PARM_DESC(myri10ge_max_slices, "Max tx/rx queues");
349 349
350static int myri10ge_rss_hash = MXGEFW_RSS_HASH_TYPE_SRC_PORT; 350static int myri10ge_rss_hash = MXGEFW_RSS_HASH_TYPE_SRC_DST_PORT;
351module_param(myri10ge_rss_hash, int, S_IRUGO); 351module_param(myri10ge_rss_hash, int, S_IRUGO);
352MODULE_PARM_DESC(myri10ge_rss_hash, "Type of RSS hashing to do"); 352MODULE_PARM_DESC(myri10ge_rss_hash, "Type of RSS hashing to do");
353 353
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 80a667460514..02f8d4b4db63 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -619,17 +619,20 @@ nx_set_product_offs(struct netxen_adapter *adapter)
619 uint32_t i; 619 uint32_t i;
620 __le32 entries; 620 __le32 entries;
621 621
622 int mn_present = (NX_IS_REVISION_P2(adapter->ahw.revision_id)) ?
623 1 : netxen_p3_has_mn(adapter);
624
622 ptab_descr = nx_get_table_desc(unirom, NX_UNI_DIR_SECT_PRODUCT_TBL); 625 ptab_descr = nx_get_table_desc(unirom, NX_UNI_DIR_SECT_PRODUCT_TBL);
623 if (ptab_descr == NULL) 626 if (ptab_descr == NULL)
624 return -1; 627 return -1;
625 628
626 entries = cpu_to_le32(ptab_descr->num_entries); 629 entries = cpu_to_le32(ptab_descr->num_entries);
627 630
631nomn:
628 for (i = 0; i < entries; i++) { 632 for (i = 0; i < entries; i++) {
629 633
630 __le32 flags, file_chiprev, offs; 634 __le32 flags, file_chiprev, offs;
631 u8 chiprev = adapter->ahw.revision_id; 635 u8 chiprev = adapter->ahw.revision_id;
632 int mn_present = netxen_p3_has_mn(adapter);
633 uint32_t flagbit; 636 uint32_t flagbit;
634 637
635 offs = cpu_to_le32(ptab_descr->findex) + 638 offs = cpu_to_le32(ptab_descr->findex) +
@@ -647,6 +650,11 @@ nx_set_product_offs(struct netxen_adapter *adapter)
647 } 650 }
648 } 651 }
649 652
653 if (mn_present && NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
654 mn_present = 0;
655 goto nomn;
656 }
657
650 return -1; 658 return -1;
651} 659}
652 660
@@ -1021,6 +1029,10 @@ netxen_p3_has_mn(struct netxen_adapter *adapter)
1021 u32 capability, flashed_ver; 1029 u32 capability, flashed_ver;
1022 capability = 0; 1030 capability = 0;
1023 1031
1032 /* NX2031 always had MN */
1033 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
1034 return 1;
1035
1024 netxen_rom_fast_read(adapter, 1036 netxen_rom_fast_read(adapter,
1025 NX_FW_VERSION_OFFSET, (int *)&flashed_ver); 1037 NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
1026 flashed_ver = NETXEN_DECODE_VERSION(flashed_ver); 1038 flashed_ver = NETXEN_DECODE_VERSION(flashed_ver);
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index e5d187fce51b..f4996846a234 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -946,8 +946,9 @@ netxen_nic_init_coalesce_defaults(struct netxen_adapter *adapter)
946 NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS; 946 NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS;
947} 947}
948 948
949/* with rtnl_lock */
949static int 950static int
950netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) 951__netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
951{ 952{
952 int err; 953 int err;
953 954
@@ -988,14 +989,32 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
988 return 0; 989 return 0;
989} 990}
990 991
992/* Usage: During resume and firmware recovery module.*/
993
994static inline int
995netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
996{
997 int err = 0;
998
999 rtnl_lock();
1000 if (netif_running(netdev))
1001 err = __netxen_nic_up(adapter, netdev);
1002 rtnl_unlock();
1003
1004 return err;
1005}
1006
1007/* with rtnl_lock */
991static void 1008static void
992netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) 1009__netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
993{ 1010{
994 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) 1011 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
995 return; 1012 return;
996 1013
997 clear_bit(__NX_DEV_UP, &adapter->state); 1014 if (!test_and_clear_bit(__NX_DEV_UP, &adapter->state))
1015 return;
998 1016
1017 smp_mb();
999 spin_lock(&adapter->tx_clean_lock); 1018 spin_lock(&adapter->tx_clean_lock);
1000 netif_carrier_off(netdev); 1019 netif_carrier_off(netdev);
1001 netif_tx_disable(netdev); 1020 netif_tx_disable(netdev);
@@ -1014,6 +1033,17 @@ netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
1014 spin_unlock(&adapter->tx_clean_lock); 1033 spin_unlock(&adapter->tx_clean_lock);
1015} 1034}
1016 1035
1036/* Usage: During suspend and firmware recovery module */
1037
1038static inline void
1039netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
1040{
1041 rtnl_lock();
1042 if (netif_running(netdev))
1043 __netxen_nic_down(adapter, netdev);
1044 rtnl_unlock();
1045
1046}
1017 1047
1018static int 1048static int
1019netxen_nic_attach(struct netxen_adapter *adapter) 1049netxen_nic_attach(struct netxen_adapter *adapter)
@@ -1122,14 +1152,14 @@ netxen_nic_reset_context(struct netxen_adapter *adapter)
1122 netif_device_detach(netdev); 1152 netif_device_detach(netdev);
1123 1153
1124 if (netif_running(netdev)) 1154 if (netif_running(netdev))
1125 netxen_nic_down(adapter, netdev); 1155 __netxen_nic_down(adapter, netdev);
1126 1156
1127 netxen_nic_detach(adapter); 1157 netxen_nic_detach(adapter);
1128 1158
1129 if (netif_running(netdev)) { 1159 if (netif_running(netdev)) {
1130 err = netxen_nic_attach(adapter); 1160 err = netxen_nic_attach(adapter);
1131 if (!err) 1161 if (!err)
1132 err = netxen_nic_up(adapter, netdev); 1162 err = __netxen_nic_up(adapter, netdev);
1133 1163
1134 if (err) 1164 if (err)
1135 goto done; 1165 goto done;
@@ -1499,7 +1529,7 @@ static int netxen_nic_open(struct net_device *netdev)
1499 if (err) 1529 if (err)
1500 return err; 1530 return err;
1501 1531
1502 err = netxen_nic_up(adapter, netdev); 1532 err = __netxen_nic_up(adapter, netdev);
1503 if (err) 1533 if (err)
1504 goto err_out; 1534 goto err_out;
1505 1535
@@ -1519,7 +1549,7 @@ static int netxen_nic_close(struct net_device *netdev)
1519{ 1549{
1520 struct netxen_adapter *adapter = netdev_priv(netdev); 1550 struct netxen_adapter *adapter = netdev_priv(netdev);
1521 1551
1522 netxen_nic_down(adapter, netdev); 1552 __netxen_nic_down(adapter, netdev);
1523 return 0; 1553 return 0;
1524} 1554}
1525 1555
@@ -2025,7 +2055,7 @@ static int netxen_nic_poll(struct napi_struct *napi, int budget)
2025 2055
2026 if ((work_done < budget) && tx_complete) { 2056 if ((work_done < budget) && tx_complete) {
2027 napi_complete(&sds_ring->napi); 2057 napi_complete(&sds_ring->napi);
2028 if (netif_running(adapter->netdev)) 2058 if (test_bit(__NX_DEV_UP, &adapter->state))
2029 netxen_nic_enable_int(sds_ring); 2059 netxen_nic_enable_int(sds_ring);
2030 } 2060 }
2031 2061
@@ -2210,8 +2240,7 @@ netxen_detach_work(struct work_struct *work)
2210 2240
2211 netif_device_detach(netdev); 2241 netif_device_detach(netdev);
2212 2242
2213 if (netif_running(netdev)) 2243 netxen_nic_down(adapter, netdev);
2214 netxen_nic_down(adapter, netdev);
2215 2244
2216 netxen_nic_detach(adapter); 2245 netxen_nic_detach(adapter);
2217 2246
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 644962adda97..791885262602 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -97,6 +97,7 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
97 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; 97 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
98 int ret; 98 int ret;
99 u16 val; 99 u16 val;
100 u32 cksum, offset;
100 101
101 /* 102 /*
102 * Read values from EEPROM and store them in the capability structure 103 * Read values from EEPROM and store them in the capability structure
@@ -111,7 +112,6 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
111 if (ah->ah_ee_version < AR5K_EEPROM_VERSION_3_0) 112 if (ah->ah_ee_version < AR5K_EEPROM_VERSION_3_0)
112 return 0; 113 return 0;
113 114
114#ifdef notyet
115 /* 115 /*
116 * Validate the checksum of the EEPROM date. There are some 116 * Validate the checksum of the EEPROM date. There are some
117 * devices with invalid EEPROMs. 117 * devices with invalid EEPROMs.
@@ -124,7 +124,6 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
124 ATH5K_ERR(ah->ah_sc, "Invalid EEPROM checksum 0x%04x\n", cksum); 124 ATH5K_ERR(ah->ah_sc, "Invalid EEPROM checksum 0x%04x\n", cksum);
125 return -EIO; 125 return -EIO;
126 } 126 }
127#endif
128 127
129 AR5K_EEPROM_READ_HDR(AR5K_EEPROM_ANT_GAIN(ah->ah_ee_version), 128 AR5K_EEPROM_READ_HDR(AR5K_EEPROM_ANT_GAIN(ah->ah_ee_version),
130 ee_ant_gain); 129 ee_ant_gain);
diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
index d495890355d9..60f547503d75 100644
--- a/drivers/net/wireless/ath/ath5k/led.c
+++ b/drivers/net/wireless/ath/ath5k/led.c
@@ -79,6 +79,8 @@ static const struct pci_device_id ath5k_led_devices[] = {
79 { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) }, 79 { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) },
80 /* IBM-specific AR5212 (all others) */ 80 /* IBM-specific AR5212 (all others) */
81 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5212_IBM), ATH_LED(0, 0) }, 81 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5212_IBM), ATH_LED(0, 0) },
82 /* Dell Vostro A860 (shahar@shahar-or.co.il) */
83 { ATH_SDEVICE(PCI_VENDOR_ID_QMI, 0x0112), ATH_LED(3, 0) },
82 { } 84 { }
83}; 85};
84 86
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index 71b84d91dcff..efc420cd42bf 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -186,7 +186,7 @@ bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
186 wait = wait_time; 186 wait = wait_time;
187 while (ath9k_hw_numtxpending(ah, q)) { 187 while (ath9k_hw_numtxpending(ah, q)) {
188 if ((--wait) == 0) { 188 if ((--wait) == 0) {
189 ath_print(common, ATH_DBG_QUEUE, 189 ath_print(common, ATH_DBG_FATAL,
190 "Failed to stop TX DMA in 100 " 190 "Failed to stop TX DMA in 100 "
191 "msec after killing last frame\n"); 191 "msec after killing last frame\n");
192 break; 192 break;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 6401b3521049..3f5b887d0fcd 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1963,6 +1963,9 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
1963 struct ieee80211_hw *hw = sc->hw; 1963 struct ieee80211_hw *hw = sc->hw;
1964 int r; 1964 int r;
1965 1965
1966 /* Stop ANI */
1967 del_timer_sync(&common->ani.timer);
1968
1966 ath9k_hw_set_interrupts(ah, 0); 1969 ath9k_hw_set_interrupts(ah, 0);
1967 ath_drain_all_txq(sc, retry_tx); 1970 ath_drain_all_txq(sc, retry_tx);
1968 ath_stoprecv(sc); 1971 ath_stoprecv(sc);
@@ -2004,6 +2007,9 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
2004 } 2007 }
2005 } 2008 }
2006 2009
2010 /* Start ANI */
2011 ath_start_ani(common);
2012
2007 return r; 2013 return r;
2008} 2014}
2009 2015
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 564c6cb1c2b4..1e813bbf474a 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1108,11 +1108,11 @@ void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
1108 if (npend) { 1108 if (npend) {
1109 int r; 1109 int r;
1110 1110
1111 ath_print(common, ATH_DBG_XMIT, 1111 ath_print(common, ATH_DBG_FATAL,
1112 "Unable to stop TxDMA. Reset HAL!\n"); 1112 "Unable to stop TxDMA. Reset HAL!\n");
1113 1113
1114 spin_lock_bh(&sc->sc_resetlock); 1114 spin_lock_bh(&sc->sc_resetlock);
1115 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, true); 1115 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, false);
1116 if (r) 1116 if (r)
1117 ath_print(common, ATH_DBG_FATAL, 1117 ath_print(common, ATH_DBG_FATAL,
1118 "Unable to reset hardware; reset status %d\n", 1118 "Unable to reset hardware; reset status %d\n",
@@ -1414,17 +1414,9 @@ static void assign_aggr_tid_seqno(struct sk_buff *skb,
1414 * For HT capable stations, we save tidno for later use. 1414 * For HT capable stations, we save tidno for later use.
1415 * We also override seqno set by upper layer with the one 1415 * We also override seqno set by upper layer with the one
1416 * in tx aggregation state. 1416 * in tx aggregation state.
1417 *
1418 * If fragmentation is on, the sequence number is
1419 * not overridden, since it has been
1420 * incremented by the fragmentation routine.
1421 *
1422 * FIXME: check if the fragmentation threshold exceeds
1423 * IEEE80211 max.
1424 */ 1417 */
1425 tid = ATH_AN_2_TID(an, bf->bf_tidno); 1418 tid = ATH_AN_2_TID(an, bf->bf_tidno);
1426 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << 1419 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT);
1427 IEEE80211_SEQ_SEQ_SHIFT);
1428 bf->bf_seqno = tid->seq_next; 1420 bf->bf_seqno = tid->seq_next;
1429 INCR(tid->seq_next, IEEE80211_SEQ_MAX); 1421 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
1430} 1422}
@@ -1636,7 +1628,8 @@ static int ath_tx_setup_buffer(struct ieee80211_hw *hw, struct ath_buf *bf,
1636 bf->bf_keyix = ATH9K_TXKEYIX_INVALID; 1628 bf->bf_keyix = ATH9K_TXKEYIX_INVALID;
1637 } 1629 }
1638 1630
1639 if (ieee80211_is_data_qos(fc) && (sc->sc_flags & SC_OP_TXAGGR)) 1631 if (ieee80211_is_data_qos(fc) && bf_isht(bf) &&
1632 (sc->sc_flags & SC_OP_TXAGGR))
1640 assign_aggr_tid_seqno(skb, bf); 1633 assign_aggr_tid_seqno(skb, bf);
1641 1634
1642 bf->bf_mpdu = skb; 1635 bf->bf_mpdu = skb;
@@ -1780,7 +1773,8 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
1780 struct ath_wiphy *aphy = hw->priv; 1773 struct ath_wiphy *aphy = hw->priv;
1781 struct ath_softc *sc = aphy->sc; 1774 struct ath_softc *sc = aphy->sc;
1782 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1775 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1783 int hdrlen, padsize; 1776 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1777 int padpos, padsize;
1784 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1778 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1785 struct ath_tx_control txctl; 1779 struct ath_tx_control txctl;
1786 1780
@@ -1792,7 +1786,6 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
1792 * BSSes. 1786 * BSSes.
1793 */ 1787 */
1794 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 1788 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
1795 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1796 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) 1789 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
1797 sc->tx.seq_no += 0x10; 1790 sc->tx.seq_no += 0x10;
1798 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); 1791 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
@@ -1800,9 +1793,9 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
1800 } 1793 }
1801 1794
1802 /* Add the padding after the header if this is not already done */ 1795 /* Add the padding after the header if this is not already done */
1803 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 1796 padpos = ath9k_cmn_padpos(hdr->frame_control);
1804 if (hdrlen & 3) { 1797 padsize = padpos & 3;
1805 padsize = hdrlen % 4; 1798 if (padsize && skb->len>padpos) {
1806 if (skb_headroom(skb) < padsize) { 1799 if (skb_headroom(skb) < padsize) {
1807 ath_print(common, ATH_DBG_XMIT, 1800 ath_print(common, ATH_DBG_XMIT,
1808 "TX CABQ padding failed\n"); 1801 "TX CABQ padding failed\n");
@@ -1810,7 +1803,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
1810 return; 1803 return;
1811 } 1804 }
1812 skb_push(skb, padsize); 1805 skb_push(skb, padsize);
1813 memmove(skb->data, skb->data + padsize, hdrlen); 1806 memmove(skb->data, skb->data + padsize, padpos);
1814 } 1807 }
1815 1808
1816 txctl.txq = sc->beacon.cabq; 1809 txctl.txq = sc->beacon.cabq;
@@ -1838,7 +1831,8 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
1838 struct ieee80211_hw *hw = sc->hw; 1831 struct ieee80211_hw *hw = sc->hw;
1839 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1832 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1840 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1833 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1841 int hdrlen, padsize; 1834 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
1835 int padpos, padsize;
1842 1836
1843 ath_print(common, ATH_DBG_XMIT, "TX complete: skb: %p\n", skb); 1837 ath_print(common, ATH_DBG_XMIT, "TX complete: skb: %p\n", skb);
1844 1838
@@ -1853,14 +1847,14 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
1853 tx_info->flags |= IEEE80211_TX_STAT_ACK; 1847 tx_info->flags |= IEEE80211_TX_STAT_ACK;
1854 } 1848 }
1855 1849
1856 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 1850 padpos = ath9k_cmn_padpos(hdr->frame_control);
1857 padsize = hdrlen & 3; 1851 padsize = padpos & 3;
1858 if (padsize && hdrlen >= 24) { 1852 if (padsize && skb->len>padpos+padsize) {
1859 /* 1853 /*
1860 * Remove MAC header padding before giving the frame back to 1854 * Remove MAC header padding before giving the frame back to
1861 * mac80211. 1855 * mac80211.
1862 */ 1856 */
1863 memmove(skb->data + padsize, skb->data, hdrlen); 1857 memmove(skb->data + padsize, skb->data, padpos);
1864 skb_pull(skb, padsize); 1858 skb_pull(skb, padsize);
1865 } 1859 }
1866 1860
@@ -2078,7 +2072,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
2078 &txq->axq_q, lastbf->list.prev); 2072 &txq->axq_q, lastbf->list.prev);
2079 2073
2080 txq->axq_depth--; 2074 txq->axq_depth--;
2081 txok = (ds->ds_txstat.ts_status == 0); 2075 txok = !(ds->ds_txstat.ts_status & ATH9K_TXERR_FILT);
2082 txq->axq_tx_inprogress = false; 2076 txq->axq_tx_inprogress = false;
2083 spin_unlock_bh(&txq->axq_lock); 2077 spin_unlock_bh(&txq->axq_lock);
2084 2078
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 077480c4916a..19b4eae47b59 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1784,7 +1784,10 @@ static void b43_do_interrupt_thread(struct b43_wldev *dev)
1784 dma_reason[0], dma_reason[1], 1784 dma_reason[0], dma_reason[1],
1785 dma_reason[2], dma_reason[3], 1785 dma_reason[2], dma_reason[3],
1786 dma_reason[4], dma_reason[5]); 1786 dma_reason[4], dma_reason[5]);
1787 b43_controller_restart(dev, "DMA error"); 1787 b43err(dev->wl, "This device does not support DMA "
1788 "on your system. Please use PIO instead.\n");
1789 b43err(dev->wl, "CONFIG_B43_FORCE_PIO must be set in "
1790 "your kernel configuration.\n");
1788 return; 1791 return;
1789 } 1792 }
1790 if (merged_dma_reason & B43_DMAIRQ_NONFATALMASK) { 1793 if (merged_dma_reason & B43_DMAIRQ_NONFATALMASK) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 3708b5c204e6..d1bab141508a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -1835,8 +1835,7 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
1835 rc = -EIO; 1835 rc = -EIO;
1836 } 1836 }
1837 1837
1838 priv->alloc_rxb_page--; 1838 iwl_free_pages(priv, cmd.reply_page);
1839 free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
1840 1839
1841 return rc; 1840 return rc;
1842} 1841}
@@ -2836,6 +2835,7 @@ static struct iwl_cfg iwl3945_bg_cfg = {
2836 .use_isr_legacy = true, 2835 .use_isr_legacy = true,
2837 .ht_greenfield_support = false, 2836 .ht_greenfield_support = false,
2838 .led_compensation = 64, 2837 .led_compensation = 64,
2838 .broken_powersave = true,
2839}; 2839};
2840 2840
2841static struct iwl_cfg iwl3945_abg_cfg = { 2841static struct iwl_cfg iwl3945_abg_cfg = {
@@ -2852,6 +2852,7 @@ static struct iwl_cfg iwl3945_abg_cfg = {
2852 .use_isr_legacy = true, 2852 .use_isr_legacy = true,
2853 .ht_greenfield_support = false, 2853 .ht_greenfield_support = false,
2854 .led_compensation = 64, 2854 .led_compensation = 64,
2855 .broken_powersave = true,
2855}; 2856};
2856 2857
2857struct pci_device_id iwl3945_hw_card_ids[] = { 2858struct pci_device_id iwl3945_hw_card_ids[] = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index a5e3384d56b3..78706ce8b7ae 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -1204,7 +1204,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1204 iwl4965_interpolate_chan(priv, channel, &ch_eeprom_info); 1204 iwl4965_interpolate_chan(priv, channel, &ch_eeprom_info);
1205 1205
1206 /* calculate tx gain adjustment based on power supply voltage */ 1206 /* calculate tx gain adjustment based on power supply voltage */
1207 voltage = priv->calib_info->voltage; 1207 voltage = le16_to_cpu(priv->calib_info->voltage);
1208 init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage); 1208 init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage);
1209 voltage_compensation = 1209 voltage_compensation =
1210 iwl4965_get_voltage_compensation(voltage, init_voltage); 1210 iwl4965_get_voltage_compensation(voltage, init_voltage);
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
index 4ef6804a455a..bc056e9ab85f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
@@ -92,11 +92,15 @@
92 92
93static inline s32 iwl_temp_calib_to_offset(struct iwl_priv *priv) 93static inline s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
94{ 94{
95 u16 *temp_calib = (u16 *)iwl_eeprom_query_addr(priv, 95 u16 temperature, voltage;
96 EEPROM_5000_TEMPERATURE); 96 __le16 *temp_calib =
97 /* offset = temperature - voltage / coef */ 97 (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_TEMPERATURE);
98 s32 offset = (s32)(temp_calib[0] - temp_calib[1] / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF); 98
99 return offset; 99 temperature = le16_to_cpu(temp_calib[0]);
100 voltage = le16_to_cpu(temp_calib[1]);
101
102 /* offset = temp - volt / coeff */
103 return (s32)(temperature - voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
100} 104}
101 105
102/* Fixed (non-configurable) rx data from phy */ 106/* Fixed (non-configurable) rx data from phy */
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index f2b1915530e7..ec6b27689fa8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -333,14 +333,15 @@ static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
333static int iwl5000_set_Xtal_calib(struct iwl_priv *priv) 333static int iwl5000_set_Xtal_calib(struct iwl_priv *priv)
334{ 334{
335 struct iwl_calib_xtal_freq_cmd cmd; 335 struct iwl_calib_xtal_freq_cmd cmd;
336 u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL); 336 __le16 *xtal_calib =
337 (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
337 338
338 cmd.hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD; 339 cmd.hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD;
339 cmd.hdr.first_group = 0; 340 cmd.hdr.first_group = 0;
340 cmd.hdr.groups_num = 1; 341 cmd.hdr.groups_num = 1;
341 cmd.hdr.data_valid = 1; 342 cmd.hdr.data_valid = 1;
342 cmd.cap_pin1 = (u8)xtal_calib[0]; 343 cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]);
343 cmd.cap_pin2 = (u8)xtal_calib[1]; 344 cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]);
344 return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL], 345 return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL],
345 (u8 *)&cmd, sizeof(cmd)); 346 (u8 *)&cmd, sizeof(cmd));
346} 347}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 904b5d8da860..771b03c1c7c5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1995,7 +1995,7 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
1995 } 1995 }
1996 1996
1997#ifdef CONFIG_IWLWIFI_DEBUG 1997#ifdef CONFIG_IWLWIFI_DEBUG
1998 if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS)) 1998 if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log)
1999 size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES) 1999 size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
2000 ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size; 2000 ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
2001#else 2001#else
@@ -3349,7 +3349,6 @@ static int iwl_init_drv(struct iwl_priv *priv)
3349 3349
3350 priv->ibss_beacon = NULL; 3350 priv->ibss_beacon = NULL;
3351 3351
3352 spin_lock_init(&priv->lock);
3353 spin_lock_init(&priv->sta_lock); 3352 spin_lock_init(&priv->sta_lock);
3354 spin_lock_init(&priv->hcmd_lock); 3353 spin_lock_init(&priv->hcmd_lock);
3355 3354
@@ -3538,10 +3537,11 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3538 (unsigned long long) pci_resource_len(pdev, 0)); 3537 (unsigned long long) pci_resource_len(pdev, 0));
3539 IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); 3538 IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base);
3540 3539
3541 /* this spin lock will be used in apm_ops.init and EEPROM access 3540 /* these spin locks will be used in apm_ops.init and EEPROM access
3542 * we should init now 3541 * we should init now
3543 */ 3542 */
3544 spin_lock_init(&priv->reg_lock); 3543 spin_lock_init(&priv->reg_lock);
3544 spin_lock_init(&priv->lock);
3545 iwl_hw_detect(priv); 3545 iwl_hw_detect(priv);
3546 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n", 3546 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n",
3547 priv->cfg->name, priv->hw_rev); 3547 priv->cfg->name, priv->hw_rev);
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index a7bfae01f19b..1ec8cb4d5eae 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -77,8 +77,7 @@
77 * The MAC (uCode processor, etc.) does not need to be powered up for accessing 77 * The MAC (uCode processor, etc.) does not need to be powered up for accessing
78 * the CSR registers. 78 * the CSR registers.
79 * 79 *
80 * NOTE: Newer devices using one-time-programmable (OTP) memory 80 * NOTE: Device does need to be awake in order to read this memory
81 * require device to be awake in order to read this memory
82 * via CSR_EEPROM and CSR_OTP registers 81 * via CSR_EEPROM and CSR_OTP registers
83 */ 82 */
84#define CSR_BASE (0x000) 83#define CSR_BASE (0x000)
@@ -111,9 +110,8 @@
111/* 110/*
112 * EEPROM and OTP (one-time-programmable) memory reads 111 * EEPROM and OTP (one-time-programmable) memory reads
113 * 112 *
114 * NOTE: For (newer) devices using OTP, device must be awake, initialized via 113 * NOTE: Device must be awake, initialized via apm_ops.init(),
115 * apm_ops.init() in order to read. Older devices (3945/4965/5000) 114 * in order to read.
116 * use EEPROM and do not require this.
117 */ 115 */
118#define CSR_EEPROM_REG (CSR_BASE+0x02c) 116#define CSR_EEPROM_REG (CSR_BASE+0x02c)
119#define CSR_EEPROM_GP (CSR_BASE+0x030) 117#define CSR_EEPROM_GP (CSR_BASE+0x030)
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 1e12e7340c90..42f9b17327c3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1195,7 +1195,7 @@ struct iwl_priv {
1195 u32 last_beacon_time; 1195 u32 last_beacon_time;
1196 u64 last_tsf; 1196 u64 last_tsf;
1197 1197
1198 /* eeprom */ 1198 /* eeprom -- this is in the card's little endian byte order */
1199 u8 *eeprom; 1199 u8 *eeprom;
1200 int nvm_device_type; 1200 int nvm_device_type;
1201 struct iwl_eeprom_calib_info *calib_info; 1201 struct iwl_eeprom_calib_info *calib_info;
@@ -1383,4 +1383,15 @@ static inline int is_channel_ibss(const struct iwl_channel_info *ch)
1383 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0; 1383 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
1384} 1384}
1385 1385
1386static inline void __iwl_free_pages(struct iwl_priv *priv, struct page *page)
1387{
1388 __free_pages(page, priv->hw_params.rx_page_order);
1389 priv->alloc_rxb_page--;
1390}
1391
1392static inline void iwl_free_pages(struct iwl_priv *priv, unsigned long page)
1393{
1394 free_pages(page, priv->hw_params.rx_page_order);
1395 priv->alloc_rxb_page--;
1396}
1386#endif /* __iwl_dev_h__ */ 1397#endif /* __iwl_dev_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 3946e5c03f81..4a30969689ff 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -370,7 +370,7 @@ static int iwl_init_otp_access(struct iwl_priv *priv)
370 return ret; 370 return ret;
371} 371}
372 372
373static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, u16 *eeprom_data) 373static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, __le16 *eeprom_data)
374{ 374{
375 int ret = 0; 375 int ret = 0;
376 u32 r; 376 u32 r;
@@ -404,7 +404,7 @@ static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, u16 *eeprom_data)
404 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); 404 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK);
405 IWL_ERR(priv, "Correctable OTP ECC error, continue read\n"); 405 IWL_ERR(priv, "Correctable OTP ECC error, continue read\n");
406 } 406 }
407 *eeprom_data = le16_to_cpu((__force __le16)(r >> 16)); 407 *eeprom_data = cpu_to_le16(r >> 16);
408 return 0; 408 return 0;
409} 409}
410 410
@@ -413,7 +413,8 @@ static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, u16 *eeprom_data)
413 */ 413 */
414static bool iwl_is_otp_empty(struct iwl_priv *priv) 414static bool iwl_is_otp_empty(struct iwl_priv *priv)
415{ 415{
416 u16 next_link_addr = 0, link_value; 416 u16 next_link_addr = 0;
417 __le16 link_value;
417 bool is_empty = false; 418 bool is_empty = false;
418 419
419 /* locate the beginning of OTP link list */ 420 /* locate the beginning of OTP link list */
@@ -443,7 +444,8 @@ static bool iwl_is_otp_empty(struct iwl_priv *priv)
443static int iwl_find_otp_image(struct iwl_priv *priv, 444static int iwl_find_otp_image(struct iwl_priv *priv,
444 u16 *validblockaddr) 445 u16 *validblockaddr)
445{ 446{
446 u16 next_link_addr = 0, link_value = 0, valid_addr; 447 u16 next_link_addr = 0, valid_addr;
448 __le16 link_value = 0;
447 int usedblocks = 0; 449 int usedblocks = 0;
448 450
449 /* set addressing mode to absolute to traverse the link list */ 451 /* set addressing mode to absolute to traverse the link list */
@@ -463,7 +465,7 @@ static int iwl_find_otp_image(struct iwl_priv *priv,
463 * check for more block on the link list 465 * check for more block on the link list
464 */ 466 */
465 valid_addr = next_link_addr; 467 valid_addr = next_link_addr;
466 next_link_addr = link_value * sizeof(u16); 468 next_link_addr = le16_to_cpu(link_value) * sizeof(u16);
467 IWL_DEBUG_INFO(priv, "OTP blocks %d addr 0x%x\n", 469 IWL_DEBUG_INFO(priv, "OTP blocks %d addr 0x%x\n",
468 usedblocks, next_link_addr); 470 usedblocks, next_link_addr);
469 if (iwl_read_otp_word(priv, next_link_addr, &link_value)) 471 if (iwl_read_otp_word(priv, next_link_addr, &link_value))
@@ -497,7 +499,7 @@ static int iwl_find_otp_image(struct iwl_priv *priv,
497 */ 499 */
498int iwl_eeprom_init(struct iwl_priv *priv) 500int iwl_eeprom_init(struct iwl_priv *priv)
499{ 501{
500 u16 *e; 502 __le16 *e;
501 u32 gp = iwl_read32(priv, CSR_EEPROM_GP); 503 u32 gp = iwl_read32(priv, CSR_EEPROM_GP);
502 int sz; 504 int sz;
503 int ret; 505 int ret;
@@ -516,12 +518,9 @@ int iwl_eeprom_init(struct iwl_priv *priv)
516 ret = -ENOMEM; 518 ret = -ENOMEM;
517 goto alloc_err; 519 goto alloc_err;
518 } 520 }
519 e = (u16 *)priv->eeprom; 521 e = (__le16 *)priv->eeprom;
520 522
521 if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) { 523 priv->cfg->ops->lib->apm_ops.init(priv);
522 /* OTP reads require powered-up chip */
523 priv->cfg->ops->lib->apm_ops.init(priv);
524 }
525 524
526 ret = priv->cfg->ops->lib->eeprom_ops.verify_signature(priv); 525 ret = priv->cfg->ops->lib->eeprom_ops.verify_signature(priv);
527 if (ret < 0) { 526 if (ret < 0) {
@@ -562,7 +561,7 @@ int iwl_eeprom_init(struct iwl_priv *priv)
562 } 561 }
563 for (addr = validblockaddr; addr < validblockaddr + sz; 562 for (addr = validblockaddr; addr < validblockaddr + sz;
564 addr += sizeof(u16)) { 563 addr += sizeof(u16)) {
565 u16 eeprom_data; 564 __le16 eeprom_data;
566 565
567 ret = iwl_read_otp_word(priv, addr, &eeprom_data); 566 ret = iwl_read_otp_word(priv, addr, &eeprom_data);
568 if (ret) 567 if (ret)
@@ -570,13 +569,6 @@ int iwl_eeprom_init(struct iwl_priv *priv)
570 e[cache_addr / 2] = eeprom_data; 569 e[cache_addr / 2] = eeprom_data;
571 cache_addr += sizeof(u16); 570 cache_addr += sizeof(u16);
572 } 571 }
573
574 /*
575 * Now that OTP reads are complete, reset chip to save
576 * power until we load uCode during "up".
577 */
578 priv->cfg->ops->lib->apm_ops.stop(priv);
579
580 } else { 572 } else {
581 /* eeprom is an array of 16bit values */ 573 /* eeprom is an array of 16bit values */
582 for (addr = 0; addr < sz; addr += sizeof(u16)) { 574 for (addr = 0; addr < sz; addr += sizeof(u16)) {
@@ -594,7 +586,7 @@ int iwl_eeprom_init(struct iwl_priv *priv)
594 goto done; 586 goto done;
595 } 587 }
596 r = _iwl_read_direct32(priv, CSR_EEPROM_REG); 588 r = _iwl_read_direct32(priv, CSR_EEPROM_REG);
597 e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16)); 589 e[addr / 2] = cpu_to_le16(r >> 16);
598 } 590 }
599 } 591 }
600 ret = 0; 592 ret = 0;
@@ -603,6 +595,8 @@ done:
603err: 595err:
604 if (ret) 596 if (ret)
605 iwl_eeprom_free(priv); 597 iwl_eeprom_free(priv);
598 /* Reset chip to save power until we load uCode during "up". */
599 priv->cfg->ops->lib->apm_ops.stop(priv);
606alloc_err: 600alloc_err:
607 return ret; 601 return ret;
608} 602}
@@ -755,7 +749,8 @@ static int iwl_mod_ht40_chan_info(struct iwl_priv *priv,
755 ch_info->ht40_eeprom = *eeprom_ch; 749 ch_info->ht40_eeprom = *eeprom_ch;
756 ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; 750 ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg;
757 ch_info->ht40_flags = eeprom_ch->flags; 751 ch_info->ht40_flags = eeprom_ch->flags;
758 ch_info->ht40_extension_channel &= ~clear_ht40_extension_channel; 752 if (eeprom_ch->flags & EEPROM_CHANNEL_VALID)
753 ch_info->ht40_extension_channel &= ~clear_ht40_extension_channel;
759 754
760 return 0; 755 return 0;
761} 756}
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 5cd2b66bbe45..0cd9c02ee044 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -137,7 +137,7 @@ struct iwl_eeprom_channel {
137 * 137 *
138 */ 138 */
139struct iwl_eeprom_enhanced_txpwr { 139struct iwl_eeprom_enhanced_txpwr {
140 u16 common; 140 __le16 common;
141 s8 chain_a_max; 141 s8 chain_a_max;
142 s8 chain_b_max; 142 s8 chain_b_max;
143 s8 chain_c_max; 143 s8 chain_c_max;
@@ -360,7 +360,7 @@ struct iwl_eeprom_calib_subband_info {
360struct iwl_eeprom_calib_info { 360struct iwl_eeprom_calib_info {
361 u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ 361 u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */
362 u8 saturation_power52; /* half-dBm */ 362 u8 saturation_power52; /* half-dBm */
363 s16 voltage; /* signed */ 363 __le16 voltage; /* signed */
364 struct iwl_eeprom_calib_subband_info 364 struct iwl_eeprom_calib_subband_info
365 band_info[EEPROM_TX_POWER_BANDS]; 365 band_info[EEPROM_TX_POWER_BANDS];
366} __attribute__ ((packed)); 366} __attribute__ ((packed));
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index a23165948202..30e9ea6d54ec 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -234,7 +234,7 @@ cancel:
234 } 234 }
235fail: 235fail:
236 if (cmd->reply_page) { 236 if (cmd->reply_page) {
237 free_pages(cmd->reply_page, priv->hw_params.rx_page_order); 237 iwl_free_pages(priv, cmd->reply_page);
238 cmd->reply_page = 0; 238 cmd->reply_page = 0;
239 } 239 }
240out: 240out:
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 6090bc15a6d5..f5c87e72660a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -345,10 +345,8 @@ void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
345 pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, 345 pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
346 PAGE_SIZE << priv->hw_params.rx_page_order, 346 PAGE_SIZE << priv->hw_params.rx_page_order,
347 PCI_DMA_FROMDEVICE); 347 PCI_DMA_FROMDEVICE);
348 __free_pages(rxq->pool[i].page, 348 __iwl_free_pages(priv, rxq->pool[i].page);
349 priv->hw_params.rx_page_order);
350 rxq->pool[i].page = NULL; 349 rxq->pool[i].page = NULL;
351 priv->alloc_rxb_page--;
352 } 350 }
353 } 351 }
354 352
@@ -416,9 +414,7 @@ void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
416 pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, 414 pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
417 PAGE_SIZE << priv->hw_params.rx_page_order, 415 PAGE_SIZE << priv->hw_params.rx_page_order,
418 PCI_DMA_FROMDEVICE); 416 PCI_DMA_FROMDEVICE);
419 priv->alloc_rxb_page--; 417 __iwl_free_pages(priv, rxq->pool[i].page);
420 __free_pages(rxq->pool[i].page,
421 priv->hw_params.rx_page_order);
422 rxq->pool[i].page = NULL; 418 rxq->pool[i].page = NULL;
423 } 419 }
424 list_add_tail(&rxq->pool[i].list, &rxq->rx_used); 420 list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index a2b2b8315ff9..fa1c89ba6459 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -144,8 +144,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
144 clear_bit(STATUS_SCAN_HW, &priv->status); 144 clear_bit(STATUS_SCAN_HW, &priv->status);
145 } 145 }
146 146
147 priv->alloc_rxb_page--; 147 iwl_free_pages(priv, cmd.reply_page);
148 free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
149 148
150 return ret; 149 return ret;
151} 150}
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index cd6a6901216e..cde09a890b73 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -164,9 +164,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
164 break; 164 break;
165 } 165 }
166 } 166 }
167 167 iwl_free_pages(priv, cmd.reply_page);
168 priv->alloc_rxb_page--;
169 free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
170 168
171 return ret; 169 return ret;
172} 170}
@@ -391,9 +389,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr,
391 break; 389 break;
392 } 390 }
393 } 391 }
394 392 iwl_free_pages(priv, cmd.reply_page);
395 priv->alloc_rxb_page--;
396 free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
397 393
398 return ret; 394 return ret;
399} 395}
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 58b132f9cf28..87ce2bd292c7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -407,13 +407,14 @@ void iwl_hw_txq_ctx_free(struct iwl_priv *priv)
407 int txq_id; 407 int txq_id;
408 408
409 /* Tx queues */ 409 /* Tx queues */
410 if (priv->txq) 410 if (priv->txq) {
411 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; 411 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num;
412 txq_id++) 412 txq_id++)
413 if (txq_id == IWL_CMD_QUEUE_NUM) 413 if (txq_id == IWL_CMD_QUEUE_NUM)
414 iwl_cmd_queue_free(priv); 414 iwl_cmd_queue_free(priv);
415 else 415 else
416 iwl_tx_queue_free(priv, txq_id); 416 iwl_tx_queue_free(priv, txq_id);
417 }
417 iwl_free_dma_ptr(priv, &priv->kw); 418 iwl_free_dma_ptr(priv, &priv->kw);
418 419
419 iwl_free_dma_ptr(priv, &priv->scd_bc_tbls); 420 iwl_free_dma_ptr(priv, &priv->scd_bc_tbls);
@@ -1353,7 +1354,7 @@ int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1353 if (priv->stations[sta_id].tid[tid].agg.state == 1354 if (priv->stations[sta_id].tid[tid].agg.state ==
1354 IWL_EMPTYING_HW_QUEUE_ADDBA) { 1355 IWL_EMPTYING_HW_QUEUE_ADDBA) {
1355 IWL_DEBUG_HT(priv, "AGG stop before setup done\n"); 1356 IWL_DEBUG_HT(priv, "AGG stop before setup done\n");
1356 ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, ra, tid); 1357 ieee80211_stop_tx_ba_cb_irqsafe(priv->vif, ra, tid);
1357 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; 1358 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
1358 return 0; 1359 return 0;
1359 } 1360 }
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index f7c7ff4264fb..6533122ed87a 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -548,6 +548,9 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
548 txq = &priv->txq[txq_id]; 548 txq = &priv->txq[txq_id];
549 q = &txq->q; 549 q = &txq->q;
550 550
551 if ((iwl_queue_space(q) < q->high_mark))
552 goto drop;
553
551 spin_lock_irqsave(&priv->lock, flags); 554 spin_lock_irqsave(&priv->lock, flags);
552 555
553 idx = get_cmd_index(q, q->write_ptr, 0); 556 idx = get_cmd_index(q, q->write_ptr, 0);
@@ -812,7 +815,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
812 break; 815 break;
813 } 816 }
814 817
815 free_pages(cmd.reply_page, priv->hw_params.rx_page_order); 818 iwl_free_pages(priv, cmd.reply_page);
816 819
817 return rc; 820 return rc;
818} 821}
@@ -1198,9 +1201,7 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
1198 pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, 1201 pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
1199 PAGE_SIZE << priv->hw_params.rx_page_order, 1202 PAGE_SIZE << priv->hw_params.rx_page_order,
1200 PCI_DMA_FROMDEVICE); 1203 PCI_DMA_FROMDEVICE);
1201 priv->alloc_rxb_page--; 1204 __iwl_free_pages(priv, rxq->pool[i].page);
1202 __free_pages(rxq->pool[i].page,
1203 priv->hw_params.rx_page_order);
1204 rxq->pool[i].page = NULL; 1205 rxq->pool[i].page = NULL;
1205 } 1206 }
1206 list_add_tail(&rxq->pool[i].list, &rxq->rx_used); 1207 list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
@@ -1247,10 +1248,8 @@ static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rx
1247 pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, 1248 pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
1248 PAGE_SIZE << priv->hw_params.rx_page_order, 1249 PAGE_SIZE << priv->hw_params.rx_page_order,
1249 PCI_DMA_FROMDEVICE); 1250 PCI_DMA_FROMDEVICE);
1250 __free_pages(rxq->pool[i].page, 1251 __iwl_free_pages(priv, rxq->pool[i].page);
1251 priv->hw_params.rx_page_order);
1252 rxq->pool[i].page = NULL; 1252 rxq->pool[i].page = NULL;
1253 priv->alloc_rxb_page--;
1254 } 1253 }
1255 } 1254 }
1256 1255
@@ -1716,7 +1715,7 @@ int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
1716 } 1715 }
1717 1716
1718#ifdef CONFIG_IWLWIFI_DEBUG 1717#ifdef CONFIG_IWLWIFI_DEBUG
1719 if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS)) 1718 if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log)
1720 size = (size > DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES) 1719 size = (size > DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES)
1721 ? DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES : size; 1720 ? DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES : size;
1722#else 1721#else
@@ -3908,7 +3907,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
3908 priv->retry_rate = 1; 3907 priv->retry_rate = 1;
3909 priv->ibss_beacon = NULL; 3908 priv->ibss_beacon = NULL;
3910 3909
3911 spin_lock_init(&priv->lock);
3912 spin_lock_init(&priv->sta_lock); 3910 spin_lock_init(&priv->sta_lock);
3913 spin_lock_init(&priv->hcmd_lock); 3911 spin_lock_init(&priv->hcmd_lock);
3914 3912
@@ -3977,9 +3975,11 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3977 /* Tell mac80211 our characteristics */ 3975 /* Tell mac80211 our characteristics */
3978 hw->flags = IEEE80211_HW_SIGNAL_DBM | 3976 hw->flags = IEEE80211_HW_SIGNAL_DBM |
3979 IEEE80211_HW_NOISE_DBM | 3977 IEEE80211_HW_NOISE_DBM |
3980 IEEE80211_HW_SPECTRUM_MGMT | 3978 IEEE80211_HW_SPECTRUM_MGMT;
3981 IEEE80211_HW_SUPPORTS_PS | 3979
3982 IEEE80211_HW_SUPPORTS_DYNAMIC_PS; 3980 if (!priv->cfg->broken_powersave)
3981 hw->flags |= IEEE80211_HW_SUPPORTS_PS |
3982 IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
3983 3983
3984 hw->wiphy->interface_modes = 3984 hw->wiphy->interface_modes =
3985 BIT(NL80211_IFTYPE_STATION) | 3985 BIT(NL80211_IFTYPE_STATION) |
@@ -4098,10 +4098,11 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4098 * PCI Tx retries from interfering with C3 CPU state */ 4098 * PCI Tx retries from interfering with C3 CPU state */
4099 pci_write_config_byte(pdev, 0x41, 0x00); 4099 pci_write_config_byte(pdev, 0x41, 0x00);
4100 4100
4101 /* this spin lock will be used in apm_ops.init and EEPROM access 4101 /* these spin locks will be used in apm_ops.init and EEPROM access
4102 * we should init now 4102 * we should init now
4103 */ 4103 */
4104 spin_lock_init(&priv->reg_lock); 4104 spin_lock_init(&priv->reg_lock);
4105 spin_lock_init(&priv->lock);
4105 4106
4106 /*********************** 4107 /***********************
4107 * 4. Read EEPROM 4108 * 4. Read EEPROM
diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h
index 5a26bb05a33a..79ffa3b98d73 100644
--- a/drivers/net/wireless/iwmc3200wifi/iwm.h
+++ b/drivers/net/wireless/iwmc3200wifi/iwm.h
@@ -349,7 +349,7 @@ int iwm_up(struct iwm_priv *iwm);
349int iwm_down(struct iwm_priv *iwm); 349int iwm_down(struct iwm_priv *iwm);
350 350
351/* TX API */ 351/* TX API */
352u16 iwm_tid_to_queue(u16 tid); 352int iwm_tid_to_queue(u16 tid);
353void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages); 353void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages);
354void iwm_tx_worker(struct work_struct *work); 354void iwm_tx_worker(struct work_struct *work);
355int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev); 355int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index e4f0f8705f65..c4c0d23c63ec 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -76,7 +76,7 @@ static int iwm_stop(struct net_device *ndev)
76 */ 76 */
77static const u16 iwm_1d_to_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 }; 77static const u16 iwm_1d_to_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
78 78
79u16 iwm_tid_to_queue(u16 tid) 79int iwm_tid_to_queue(u16 tid)
80{ 80{
81 if (tid > IWM_UMAC_TID_NR - 2) 81 if (tid > IWM_UMAC_TID_NR - 2)
82 return -EINVAL; 82 return -EINVAL;
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
index 0619d6a1103c..fd399e6b1930 100644
--- a/drivers/net/wireless/iwmc3200wifi/rx.c
+++ b/drivers/net/wireless/iwmc3200wifi/rx.c
@@ -1125,7 +1125,7 @@ static int iwm_ntf_stop_resume_tx(struct iwm_priv *iwm, u8 *buf,
1125 1125
1126 if (!stop) { 1126 if (!stop) {
1127 struct iwm_tx_queue *txq; 1127 struct iwm_tx_queue *txq;
1128 u16 queue = iwm_tid_to_queue(bit); 1128 int queue = iwm_tid_to_queue(bit);
1129 1129
1130 if (queue < 0) 1130 if (queue < 0)
1131 continue; 1131 continue;
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index f07ba0b6c5f1..71f88a08e090 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -2031,10 +2031,8 @@ static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
2031 if (priv->connect_status == LBS_CONNECTED) { 2031 if (priv->connect_status == LBS_CONNECTED) {
2032 memcpy(extra, priv->curbssparams.ssid, 2032 memcpy(extra, priv->curbssparams.ssid,
2033 priv->curbssparams.ssid_len); 2033 priv->curbssparams.ssid_len);
2034 extra[priv->curbssparams.ssid_len] = '\0';
2035 } else { 2034 } else {
2036 memset(extra, 0, 32); 2035 memset(extra, 0, 32);
2037 extra[priv->curbssparams.ssid_len] = '\0';
2038 } 2036 }
2039 /* 2037 /*
2040 * If none, we may want to get the one that was set 2038 * If none, we may want to get the one that was set
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 0cb5ecc822a8..59d49159cf2a 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -84,7 +84,8 @@ struct rxd_ops {
84 int rxd_size; 84 int rxd_size;
85 void (*rxd_init)(void *rxd, dma_addr_t next_dma_addr); 85 void (*rxd_init)(void *rxd, dma_addr_t next_dma_addr);
86 void (*rxd_refill)(void *rxd, dma_addr_t addr, int len); 86 void (*rxd_refill)(void *rxd, dma_addr_t addr, int len);
87 int (*rxd_process)(void *rxd, struct ieee80211_rx_status *status); 87 int (*rxd_process)(void *rxd, struct ieee80211_rx_status *status,
88 __le16 *qos);
88}; 89};
89 90
90struct mwl8k_device_info { 91struct mwl8k_device_info {
@@ -184,7 +185,7 @@ struct mwl8k_priv {
184 /* PHY parameters */ 185 /* PHY parameters */
185 struct ieee80211_supported_band band; 186 struct ieee80211_supported_band band;
186 struct ieee80211_channel channels[14]; 187 struct ieee80211_channel channels[14];
187 struct ieee80211_rate rates[13]; 188 struct ieee80211_rate rates[14];
188 189
189 bool radio_on; 190 bool radio_on;
190 bool radio_short_preamble; 191 bool radio_short_preamble;
@@ -220,15 +221,6 @@ struct mwl8k_vif {
220 u8 bssid[ETH_ALEN]; 221 u8 bssid[ETH_ALEN];
221 u8 mac_addr[ETH_ALEN]; 222 u8 mac_addr[ETH_ALEN];
222 223
223 /*
224 * Subset of supported legacy rates.
225 * Intersection of AP and STA supported rates.
226 */
227 struct ieee80211_rate legacy_rates[13];
228
229 /* number of supported legacy rates */
230 u8 legacy_nrates;
231
232 /* Index into station database.Returned by update_sta_db call */ 224 /* Index into station database.Returned by update_sta_db call */
233 u8 peer_id; 225 u8 peer_id;
234 226
@@ -266,6 +258,11 @@ static const struct ieee80211_rate mwl8k_rates[] = {
266 { .bitrate = 360, .hw_value = 72, }, 258 { .bitrate = 360, .hw_value = 72, },
267 { .bitrate = 480, .hw_value = 96, }, 259 { .bitrate = 480, .hw_value = 96, },
268 { .bitrate = 540, .hw_value = 108, }, 260 { .bitrate = 540, .hw_value = 108, },
261 { .bitrate = 720, .hw_value = 144, },
262};
263
264static const u8 mwl8k_rateids[12] = {
265 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108,
269}; 266};
270 267
271/* Set or get info from Firmware */ 268/* Set or get info from Firmware */
@@ -574,7 +571,7 @@ static int mwl8k_load_firmware(struct ieee80211_hw *hw)
574 "helper image\n", pci_name(priv->pdev)); 571 "helper image\n", pci_name(priv->pdev));
575 return rc; 572 return rc;
576 } 573 }
577 msleep(1); 574 msleep(5);
578 575
579 rc = mwl8k_feed_fw_image(priv, fw->data, fw->size); 576 rc = mwl8k_feed_fw_image(priv, fw->data, fw->size);
580 } else { 577 } else {
@@ -591,9 +588,8 @@ static int mwl8k_load_firmware(struct ieee80211_hw *hw)
591 iowrite32(MWL8K_MODE_AP, priv->regs + MWL8K_HIU_GEN_PTR); 588 iowrite32(MWL8K_MODE_AP, priv->regs + MWL8K_HIU_GEN_PTR);
592 else 589 else
593 iowrite32(MWL8K_MODE_STA, priv->regs + MWL8K_HIU_GEN_PTR); 590 iowrite32(MWL8K_MODE_STA, priv->regs + MWL8K_HIU_GEN_PTR);
594 msleep(1);
595 591
596 loops = 200000; 592 loops = 500000;
597 do { 593 do {
598 u32 ready_code; 594 u32 ready_code;
599 595
@@ -633,9 +629,6 @@ struct ewc_ht_info {
633/* Peer Entry flags - used to define the type of the peer node */ 629/* Peer Entry flags - used to define the type of the peer node */
634#define MWL8K_PEER_TYPE_ACCESSPOINT 2 630#define MWL8K_PEER_TYPE_ACCESSPOINT 2
635 631
636#define MWL8K_IEEE_LEGACY_DATA_RATES 13
637#define MWL8K_MCS_BITMAP_SIZE 16
638
639struct peer_capability_info { 632struct peer_capability_info {
640 /* Peer type - AP vs. STA. */ 633 /* Peer type - AP vs. STA. */
641 __u8 peer_type; 634 __u8 peer_type;
@@ -652,10 +645,10 @@ struct peer_capability_info {
652 struct ewc_ht_info ewc_info; 645 struct ewc_ht_info ewc_info;
653 646
654 /* Legacy rate table. Intersection of our rates and peer rates. */ 647 /* Legacy rate table. Intersection of our rates and peer rates. */
655 __u8 legacy_rates[MWL8K_IEEE_LEGACY_DATA_RATES]; 648 __u8 legacy_rates[12];
656 649
657 /* HT rate table. Intersection of our rates and peer rates. */ 650 /* HT rate table. Intersection of our rates and peer rates. */
658 __u8 ht_rates[MWL8K_MCS_BITMAP_SIZE]; 651 __u8 ht_rates[16];
659 __u8 pad[16]; 652 __u8 pad[16];
660 653
661 /* If set, interoperability mode, no proprietary extensions. */ 654 /* If set, interoperability mode, no proprietary extensions. */
@@ -706,55 +699,64 @@ static inline u16 mwl8k_qos_setbit_qlen(u16 qos, u8 len)
706struct mwl8k_dma_data { 699struct mwl8k_dma_data {
707 __le16 fwlen; 700 __le16 fwlen;
708 struct ieee80211_hdr wh; 701 struct ieee80211_hdr wh;
702 char data[0];
709} __attribute__((packed)); 703} __attribute__((packed));
710 704
711/* Routines to add/remove DMA header from skb. */ 705/* Routines to add/remove DMA header from skb. */
712static inline void mwl8k_remove_dma_header(struct sk_buff *skb) 706static inline void mwl8k_remove_dma_header(struct sk_buff *skb, __le16 qos)
713{ 707{
714 struct mwl8k_dma_data *tr = (struct mwl8k_dma_data *)skb->data; 708 struct mwl8k_dma_data *tr;
715 void *dst, *src = &tr->wh; 709 int hdrlen;
716 int hdrlen = ieee80211_hdrlen(tr->wh.frame_control);
717 u16 space = sizeof(struct mwl8k_dma_data) - hdrlen;
718 710
719 dst = (void *)tr + space; 711 tr = (struct mwl8k_dma_data *)skb->data;
720 if (dst != src) { 712 hdrlen = ieee80211_hdrlen(tr->wh.frame_control);
721 memmove(dst, src, hdrlen); 713
722 skb_pull(skb, space); 714 if (hdrlen != sizeof(tr->wh)) {
715 if (ieee80211_is_data_qos(tr->wh.frame_control)) {
716 memmove(tr->data - hdrlen, &tr->wh, hdrlen - 2);
717 *((__le16 *)(tr->data - 2)) = qos;
718 } else {
719 memmove(tr->data - hdrlen, &tr->wh, hdrlen);
720 }
723 } 721 }
722
723 if (hdrlen != sizeof(*tr))
724 skb_pull(skb, sizeof(*tr) - hdrlen);
724} 725}
725 726
726static inline void mwl8k_add_dma_header(struct sk_buff *skb) 727static inline void mwl8k_add_dma_header(struct sk_buff *skb)
727{ 728{
728 struct ieee80211_hdr *wh; 729 struct ieee80211_hdr *wh;
729 u32 hdrlen, pktlen; 730 int hdrlen;
730 struct mwl8k_dma_data *tr; 731 struct mwl8k_dma_data *tr;
731 732
733 /*
734 * Add a firmware DMA header; the firmware requires that we
735 * present a 2-byte payload length followed by a 4-address
736 * header (without QoS field), followed (optionally) by any
737 * WEP/ExtIV header (but only filled in for CCMP).
738 */
732 wh = (struct ieee80211_hdr *)skb->data; 739 wh = (struct ieee80211_hdr *)skb->data;
740
733 hdrlen = ieee80211_hdrlen(wh->frame_control); 741 hdrlen = ieee80211_hdrlen(wh->frame_control);
734 pktlen = skb->len; 742 if (hdrlen != sizeof(*tr))
743 skb_push(skb, sizeof(*tr) - hdrlen);
735 744
736 /* 745 if (ieee80211_is_data_qos(wh->frame_control))
737 * Copy up/down the 802.11 header; the firmware requires 746 hdrlen -= 2;
738 * we present a 2-byte payload length followed by a
739 * 4-address header (w/o QoS), followed (optionally) by
740 * any WEP/ExtIV header (but only filled in for CCMP).
741 */
742 if (hdrlen != sizeof(struct mwl8k_dma_data))
743 skb_push(skb, sizeof(struct mwl8k_dma_data) - hdrlen);
744 747
745 tr = (struct mwl8k_dma_data *)skb->data; 748 tr = (struct mwl8k_dma_data *)skb->data;
746 if (wh != &tr->wh) 749 if (wh != &tr->wh)
747 memmove(&tr->wh, wh, hdrlen); 750 memmove(&tr->wh, wh, hdrlen);
748 751 if (hdrlen != sizeof(tr->wh))
749 /* Clear addr4 */ 752 memset(((void *)&tr->wh) + hdrlen, 0, sizeof(tr->wh) - hdrlen);
750 memset(tr->wh.addr4, 0, ETH_ALEN);
751 753
752 /* 754 /*
753 * Firmware length is the length of the fully formed "802.11 755 * Firmware length is the length of the fully formed "802.11
754 * payload". That is, everything except for the 802.11 header. 756 * payload". That is, everything except for the 802.11 header.
755 * This includes all crypto material including the MIC. 757 * This includes all crypto material including the MIC.
756 */ 758 */
757 tr->fwlen = cpu_to_le16(pktlen - hdrlen); 759 tr->fwlen = cpu_to_le16(skb->len - sizeof(*tr));
758} 760}
759 761
760 762
@@ -779,6 +781,10 @@ struct mwl8k_rxd_8366 {
779 __u8 rx_ctrl; 781 __u8 rx_ctrl;
780} __attribute__((packed)); 782} __attribute__((packed));
781 783
784#define MWL8K_8366_RATE_INFO_MCS_FORMAT 0x80
785#define MWL8K_8366_RATE_INFO_40MHZ 0x40
786#define MWL8K_8366_RATE_INFO_RATEID(x) ((x) & 0x3f)
787
782#define MWL8K_8366_RX_CTRL_OWNED_BY_HOST 0x80 788#define MWL8K_8366_RX_CTRL_OWNED_BY_HOST 0x80
783 789
784static void mwl8k_rxd_8366_init(void *_rxd, dma_addr_t next_dma_addr) 790static void mwl8k_rxd_8366_init(void *_rxd, dma_addr_t next_dma_addr)
@@ -800,7 +806,8 @@ static void mwl8k_rxd_8366_refill(void *_rxd, dma_addr_t addr, int len)
800} 806}
801 807
802static int 808static int
803mwl8k_rxd_8366_process(void *_rxd, struct ieee80211_rx_status *status) 809mwl8k_rxd_8366_process(void *_rxd, struct ieee80211_rx_status *status,
810 __le16 *qos)
804{ 811{
805 struct mwl8k_rxd_8366 *rxd = _rxd; 812 struct mwl8k_rxd_8366 *rxd = _rxd;
806 813
@@ -813,9 +820,11 @@ mwl8k_rxd_8366_process(void *_rxd, struct ieee80211_rx_status *status)
813 status->signal = -rxd->rssi; 820 status->signal = -rxd->rssi;
814 status->noise = -rxd->noise_floor; 821 status->noise = -rxd->noise_floor;
815 822
816 if (rxd->rate & 0x80) { 823 if (rxd->rate & MWL8K_8366_RATE_INFO_MCS_FORMAT) {
817 status->flag |= RX_FLAG_HT; 824 status->flag |= RX_FLAG_HT;
818 status->rate_idx = rxd->rate & 0x7f; 825 if (rxd->rate & MWL8K_8366_RATE_INFO_40MHZ)
826 status->flag |= RX_FLAG_40MHZ;
827 status->rate_idx = MWL8K_8366_RATE_INFO_RATEID(rxd->rate);
819 } else { 828 } else {
820 int i; 829 int i;
821 830
@@ -830,6 +839,8 @@ mwl8k_rxd_8366_process(void *_rxd, struct ieee80211_rx_status *status)
830 status->band = IEEE80211_BAND_2GHZ; 839 status->band = IEEE80211_BAND_2GHZ;
831 status->freq = ieee80211_channel_to_frequency(rxd->channel); 840 status->freq = ieee80211_channel_to_frequency(rxd->channel);
832 841
842 *qos = rxd->qos_control;
843
833 return le16_to_cpu(rxd->pkt_len); 844 return le16_to_cpu(rxd->pkt_len);
834} 845}
835 846
@@ -888,7 +899,8 @@ static void mwl8k_rxd_8687_refill(void *_rxd, dma_addr_t addr, int len)
888} 899}
889 900
890static int 901static int
891mwl8k_rxd_8687_process(void *_rxd, struct ieee80211_rx_status *status) 902mwl8k_rxd_8687_process(void *_rxd, struct ieee80211_rx_status *status,
903 __le16 *qos)
892{ 904{
893 struct mwl8k_rxd_8687 *rxd = _rxd; 905 struct mwl8k_rxd_8687 *rxd = _rxd;
894 u16 rate_info; 906 u16 rate_info;
@@ -903,7 +915,6 @@ mwl8k_rxd_8687_process(void *_rxd, struct ieee80211_rx_status *status)
903 915
904 status->signal = -rxd->rssi; 916 status->signal = -rxd->rssi;
905 status->noise = -rxd->noise_level; 917 status->noise = -rxd->noise_level;
906 status->qual = rxd->link_quality;
907 status->antenna = MWL8K_8687_RATE_INFO_ANTSELECT(rate_info); 918 status->antenna = MWL8K_8687_RATE_INFO_ANTSELECT(rate_info);
908 status->rate_idx = MWL8K_8687_RATE_INFO_RATEID(rate_info); 919 status->rate_idx = MWL8K_8687_RATE_INFO_RATEID(rate_info);
909 920
@@ -919,6 +930,8 @@ mwl8k_rxd_8687_process(void *_rxd, struct ieee80211_rx_status *status)
919 status->band = IEEE80211_BAND_2GHZ; 930 status->band = IEEE80211_BAND_2GHZ;
920 status->freq = ieee80211_channel_to_frequency(rxd->channel); 931 status->freq = ieee80211_channel_to_frequency(rxd->channel);
921 932
933 *qos = rxd->qos_control;
934
922 return le16_to_cpu(rxd->pkt_len); 935 return le16_to_cpu(rxd->pkt_len);
923} 936}
924 937
@@ -1090,6 +1103,7 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
1090 void *rxd; 1103 void *rxd;
1091 int pkt_len; 1104 int pkt_len;
1092 struct ieee80211_rx_status status; 1105 struct ieee80211_rx_status status;
1106 __le16 qos;
1093 1107
1094 skb = rxq->buf[rxq->head].skb; 1108 skb = rxq->buf[rxq->head].skb;
1095 if (skb == NULL) 1109 if (skb == NULL)
@@ -1097,7 +1111,7 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
1097 1111
1098 rxd = rxq->rxd + (rxq->head * priv->rxd_ops->rxd_size); 1112 rxd = rxq->rxd + (rxq->head * priv->rxd_ops->rxd_size);
1099 1113
1100 pkt_len = priv->rxd_ops->rxd_process(rxd, &status); 1114 pkt_len = priv->rxd_ops->rxd_process(rxd, &status, &qos);
1101 if (pkt_len < 0) 1115 if (pkt_len < 0)
1102 break; 1116 break;
1103 1117
@@ -1115,7 +1129,7 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
1115 rxq->rxd_count--; 1129 rxq->rxd_count--;
1116 1130
1117 skb_put(skb, pkt_len); 1131 skb_put(skb, pkt_len);
1118 mwl8k_remove_dma_header(skb); 1132 mwl8k_remove_dma_header(skb, qos);
1119 1133
1120 /* 1134 /*
1121 * Check for a pending join operation. Save a 1135 * Check for a pending join operation. Save a
@@ -1221,99 +1235,106 @@ static inline void mwl8k_tx_start(struct mwl8k_priv *priv)
1221 ioread32(priv->regs + MWL8K_HIU_INT_CODE); 1235 ioread32(priv->regs + MWL8K_HIU_INT_CODE);
1222} 1236}
1223 1237
1224struct mwl8k_txq_info { 1238static void mwl8k_dump_tx_rings(struct ieee80211_hw *hw)
1225 u32 fw_owned;
1226 u32 drv_owned;
1227 u32 unused;
1228 u32 len;
1229 u32 head;
1230 u32 tail;
1231};
1232
1233static int mwl8k_scan_tx_ring(struct mwl8k_priv *priv,
1234 struct mwl8k_txq_info *txinfo)
1235{ 1239{
1236 int count, desc, status; 1240 struct mwl8k_priv *priv = hw->priv;
1237 struct mwl8k_tx_queue *txq; 1241 int i;
1238 struct mwl8k_tx_desc *tx_desc;
1239 int ndescs = 0;
1240 1242
1241 memset(txinfo, 0, MWL8K_TX_QUEUES * sizeof(struct mwl8k_txq_info)); 1243 for (i = 0; i < MWL8K_TX_QUEUES; i++) {
1244 struct mwl8k_tx_queue *txq = priv->txq + i;
1245 int fw_owned = 0;
1246 int drv_owned = 0;
1247 int unused = 0;
1248 int desc;
1242 1249
1243 for (count = 0; count < MWL8K_TX_QUEUES; count++) {
1244 txq = priv->txq + count;
1245 txinfo[count].len = txq->stats.len;
1246 txinfo[count].head = txq->head;
1247 txinfo[count].tail = txq->tail;
1248 for (desc = 0; desc < MWL8K_TX_DESCS; desc++) { 1250 for (desc = 0; desc < MWL8K_TX_DESCS; desc++) {
1249 tx_desc = txq->txd + desc; 1251 struct mwl8k_tx_desc *tx_desc = txq->txd + desc;
1250 status = le32_to_cpu(tx_desc->status); 1252 u32 status;
1251 1253
1254 status = le32_to_cpu(tx_desc->status);
1252 if (status & MWL8K_TXD_STATUS_FW_OWNED) 1255 if (status & MWL8K_TXD_STATUS_FW_OWNED)
1253 txinfo[count].fw_owned++; 1256 fw_owned++;
1254 else 1257 else
1255 txinfo[count].drv_owned++; 1258 drv_owned++;
1256 1259
1257 if (tx_desc->pkt_len == 0) 1260 if (tx_desc->pkt_len == 0)
1258 txinfo[count].unused++; 1261 unused++;
1259 } 1262 }
1260 }
1261 1263
1262 return ndescs; 1264 printk(KERN_ERR "%s: txq[%d] len=%d head=%d tail=%d "
1265 "fw_owned=%d drv_owned=%d unused=%d\n",
1266 wiphy_name(hw->wiphy), i,
1267 txq->stats.len, txq->head, txq->tail,
1268 fw_owned, drv_owned, unused);
1269 }
1263} 1270}
1264 1271
1265/* 1272/*
1266 * Must be called with priv->fw_mutex held and tx queues stopped. 1273 * Must be called with priv->fw_mutex held and tx queues stopped.
1267 */ 1274 */
1275#define MWL8K_TX_WAIT_TIMEOUT_MS 1000
1276
1268static int mwl8k_tx_wait_empty(struct ieee80211_hw *hw) 1277static int mwl8k_tx_wait_empty(struct ieee80211_hw *hw)
1269{ 1278{
1270 struct mwl8k_priv *priv = hw->priv; 1279 struct mwl8k_priv *priv = hw->priv;
1271 DECLARE_COMPLETION_ONSTACK(tx_wait); 1280 DECLARE_COMPLETION_ONSTACK(tx_wait);
1272 u32 count; 1281 int retry;
1273 unsigned long timeout; 1282 int rc;
1274 1283
1275 might_sleep(); 1284 might_sleep();
1276 1285
1286 /*
1287 * The TX queues are stopped at this point, so this test
1288 * doesn't need to take ->tx_lock.
1289 */
1290 if (!priv->pending_tx_pkts)
1291 return 0;
1292
1293 retry = 0;
1294 rc = 0;
1295
1277 spin_lock_bh(&priv->tx_lock); 1296 spin_lock_bh(&priv->tx_lock);
1278 count = priv->pending_tx_pkts; 1297 priv->tx_wait = &tx_wait;
1279 if (count) 1298 while (!rc) {
1280 priv->tx_wait = &tx_wait; 1299 int oldcount;
1281 spin_unlock_bh(&priv->tx_lock); 1300 unsigned long timeout;
1282 1301
1283 if (count) { 1302 oldcount = priv->pending_tx_pkts;
1284 struct mwl8k_txq_info txinfo[MWL8K_TX_QUEUES];
1285 int index;
1286 int newcount;
1287 1303
1304 spin_unlock_bh(&priv->tx_lock);
1288 timeout = wait_for_completion_timeout(&tx_wait, 1305 timeout = wait_for_completion_timeout(&tx_wait,
1289 msecs_to_jiffies(5000)); 1306 msecs_to_jiffies(MWL8K_TX_WAIT_TIMEOUT_MS));
1290 if (timeout)
1291 return 0;
1292
1293 spin_lock_bh(&priv->tx_lock); 1307 spin_lock_bh(&priv->tx_lock);
1294 priv->tx_wait = NULL;
1295 newcount = priv->pending_tx_pkts;
1296 mwl8k_scan_tx_ring(priv, txinfo);
1297 spin_unlock_bh(&priv->tx_lock);
1298 1308
1299 printk(KERN_ERR "%s(%u) TIMEDOUT:5000ms Pend:%u-->%u\n", 1309 if (timeout) {
1300 __func__, __LINE__, count, newcount); 1310 WARN_ON(priv->pending_tx_pkts);
1311 if (retry) {
1312 printk(KERN_NOTICE "%s: tx rings drained\n",
1313 wiphy_name(hw->wiphy));
1314 }
1315 break;
1316 }
1301 1317
1302 for (index = 0; index < MWL8K_TX_QUEUES; index++) 1318 if (priv->pending_tx_pkts < oldcount) {
1303 printk(KERN_ERR "TXQ:%u L:%u H:%u T:%u FW:%u " 1319 printk(KERN_NOTICE "%s: timeout waiting for tx "
1304 "DRV:%u U:%u\n", 1320 "rings to drain (%d -> %d pkts), retrying\n",
1305 index, 1321 wiphy_name(hw->wiphy), oldcount,
1306 txinfo[index].len, 1322 priv->pending_tx_pkts);
1307 txinfo[index].head, 1323 retry = 1;
1308 txinfo[index].tail, 1324 continue;
1309 txinfo[index].fw_owned, 1325 }
1310 txinfo[index].drv_owned,
1311 txinfo[index].unused);
1312 1326
1313 return -ETIMEDOUT; 1327 priv->tx_wait = NULL;
1328
1329 printk(KERN_ERR "%s: tx rings stuck for %d ms\n",
1330 wiphy_name(hw->wiphy), MWL8K_TX_WAIT_TIMEOUT_MS);
1331 mwl8k_dump_tx_rings(hw);
1332
1333 rc = -ETIMEDOUT;
1314 } 1334 }
1335 spin_unlock_bh(&priv->tx_lock);
1315 1336
1316 return 0; 1337 return rc;
1317} 1338}
1318 1339
1319#define MWL8K_TXD_SUCCESS(status) \ 1340#define MWL8K_TXD_SUCCESS(status) \
@@ -1361,7 +1382,7 @@ static void mwl8k_txq_reclaim(struct ieee80211_hw *hw, int index, int force)
1361 BUG_ON(skb == NULL); 1382 BUG_ON(skb == NULL);
1362 pci_unmap_single(priv->pdev, addr, size, PCI_DMA_TODEVICE); 1383 pci_unmap_single(priv->pdev, addr, size, PCI_DMA_TODEVICE);
1363 1384
1364 mwl8k_remove_dma_header(skb); 1385 mwl8k_remove_dma_header(skb, tx_desc->qos_control);
1365 1386
1366 /* Mark descriptor as unused */ 1387 /* Mark descriptor as unused */
1367 tx_desc->pkt_phys_addr = 0; 1388 tx_desc->pkt_phys_addr = 0;
@@ -1563,8 +1584,8 @@ static void mwl8k_fw_unlock(struct ieee80211_hw *hw)
1563 * Command processing. 1584 * Command processing.
1564 */ 1585 */
1565 1586
1566/* Timeout firmware commands after 2000ms */ 1587/* Timeout firmware commands after 10s */
1567#define MWL8K_CMD_TIMEOUT_MS 2000 1588#define MWL8K_CMD_TIMEOUT_MS 10000
1568 1589
1569static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd) 1590static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1570{ 1591{
@@ -1615,12 +1636,21 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1615 MWL8K_CMD_TIMEOUT_MS); 1636 MWL8K_CMD_TIMEOUT_MS);
1616 rc = -ETIMEDOUT; 1637 rc = -ETIMEDOUT;
1617 } else { 1638 } else {
1639 int ms;
1640
1641 ms = MWL8K_CMD_TIMEOUT_MS - jiffies_to_msecs(timeout);
1642
1618 rc = cmd->result ? -EINVAL : 0; 1643 rc = cmd->result ? -EINVAL : 0;
1619 if (rc) 1644 if (rc)
1620 printk(KERN_ERR "%s: Command %s error 0x%x\n", 1645 printk(KERN_ERR "%s: Command %s error 0x%x\n",
1621 wiphy_name(hw->wiphy), 1646 wiphy_name(hw->wiphy),
1622 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)), 1647 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)),
1623 le16_to_cpu(cmd->result)); 1648 le16_to_cpu(cmd->result));
1649 else if (ms > 2000)
1650 printk(KERN_NOTICE "%s: Command %s took %d ms\n",
1651 wiphy_name(hw->wiphy),
1652 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)),
1653 ms);
1624 } 1654 }
1625 1655
1626 return rc; 1656 return rc;
@@ -2439,8 +2469,6 @@ mwl8k_set_edca_params(struct ieee80211_hw *hw, __u8 qnum,
2439/* 2469/*
2440 * CMD_FINALIZE_JOIN. 2470 * CMD_FINALIZE_JOIN.
2441 */ 2471 */
2442
2443/* FJ beacon buffer size is compiled into the firmware. */
2444#define MWL8K_FJ_BEACON_MAXLEN 128 2472#define MWL8K_FJ_BEACON_MAXLEN 128
2445 2473
2446struct mwl8k_cmd_finalize_join { 2474struct mwl8k_cmd_finalize_join {
@@ -2450,17 +2478,13 @@ struct mwl8k_cmd_finalize_join {
2450} __attribute__((packed)); 2478} __attribute__((packed));
2451 2479
2452static int mwl8k_finalize_join(struct ieee80211_hw *hw, void *frame, 2480static int mwl8k_finalize_join(struct ieee80211_hw *hw, void *frame,
2453 __u16 framelen, __u16 dtim) 2481 int framelen, int dtim)
2454{ 2482{
2455 struct mwl8k_cmd_finalize_join *cmd; 2483 struct mwl8k_cmd_finalize_join *cmd;
2456 struct ieee80211_mgmt *payload = frame; 2484 struct ieee80211_mgmt *payload = frame;
2457 u16 hdrlen; 2485 int payload_len;
2458 u32 payload_len;
2459 int rc; 2486 int rc;
2460 2487
2461 if (frame == NULL)
2462 return -EINVAL;
2463
2464 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 2488 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2465 if (cmd == NULL) 2489 if (cmd == NULL)
2466 return -ENOMEM; 2490 return -ENOMEM;
@@ -2469,24 +2493,17 @@ static int mwl8k_finalize_join(struct ieee80211_hw *hw, void *frame,
2469 cmd->header.length = cpu_to_le16(sizeof(*cmd)); 2493 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2470 cmd->sleep_interval = cpu_to_le32(dtim ? dtim : 1); 2494 cmd->sleep_interval = cpu_to_le32(dtim ? dtim : 1);
2471 2495
2472 hdrlen = ieee80211_hdrlen(payload->frame_control); 2496 payload_len = framelen - ieee80211_hdrlen(payload->frame_control);
2473 2497 if (payload_len < 0)
2474 payload_len = framelen > hdrlen ? framelen - hdrlen : 0; 2498 payload_len = 0;
2475 2499 else if (payload_len > MWL8K_FJ_BEACON_MAXLEN)
2476 /* XXX TBD Might just have to abort and return an error */
2477 if (payload_len > MWL8K_FJ_BEACON_MAXLEN)
2478 printk(KERN_ERR "%s(): WARNING: Incomplete beacon "
2479 "sent to firmware. Sz=%u MAX=%u\n", __func__,
2480 payload_len, MWL8K_FJ_BEACON_MAXLEN);
2481
2482 if (payload_len > MWL8K_FJ_BEACON_MAXLEN)
2483 payload_len = MWL8K_FJ_BEACON_MAXLEN; 2500 payload_len = MWL8K_FJ_BEACON_MAXLEN;
2484 2501
2485 if (payload && payload_len) 2502 memcpy(cmd->beacon_data, &payload->u.beacon, payload_len);
2486 memcpy(cmd->beacon_data, &payload->u.beacon, payload_len);
2487 2503
2488 rc = mwl8k_post_cmd(hw, &cmd->header); 2504 rc = mwl8k_post_cmd(hw, &cmd->header);
2489 kfree(cmd); 2505 kfree(cmd);
2506
2490 return rc; 2507 return rc;
2491} 2508}
2492 2509
@@ -2515,9 +2532,7 @@ static int mwl8k_cmd_update_sta_db(struct ieee80211_hw *hw,
2515 struct ieee80211_bss_conf *info = &mv_vif->bss_info; 2532 struct ieee80211_bss_conf *info = &mv_vif->bss_info;
2516 struct mwl8k_cmd_update_sta_db *cmd; 2533 struct mwl8k_cmd_update_sta_db *cmd;
2517 struct peer_capability_info *peer_info; 2534 struct peer_capability_info *peer_info;
2518 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2519 int rc; 2535 int rc;
2520 __u8 count, *rates;
2521 2536
2522 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 2537 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2523 if (cmd == NULL) 2538 if (cmd == NULL)
@@ -2536,13 +2551,11 @@ static int mwl8k_cmd_update_sta_db(struct ieee80211_hw *hw,
2536 /* Build peer_info block */ 2551 /* Build peer_info block */
2537 peer_info->peer_type = MWL8K_PEER_TYPE_ACCESSPOINT; 2552 peer_info->peer_type = MWL8K_PEER_TYPE_ACCESSPOINT;
2538 peer_info->basic_caps = cpu_to_le16(info->assoc_capability); 2553 peer_info->basic_caps = cpu_to_le16(info->assoc_capability);
2554 memcpy(peer_info->legacy_rates, mwl8k_rateids,
2555 sizeof(mwl8k_rateids));
2539 peer_info->interop = 1; 2556 peer_info->interop = 1;
2540 peer_info->amsdu_enabled = 0; 2557 peer_info->amsdu_enabled = 0;
2541 2558
2542 rates = peer_info->legacy_rates;
2543 for (count = 0; count < mv_vif->legacy_nrates; count++)
2544 rates[count] = bitrates[count].hw_value;
2545
2546 rc = mwl8k_post_cmd(hw, &cmd->header); 2559 rc = mwl8k_post_cmd(hw, &cmd->header);
2547 if (rc == 0) 2560 if (rc == 0)
2548 mv_vif->peer_id = peer_info->station_id; 2561 mv_vif->peer_id = peer_info->station_id;
@@ -2565,8 +2578,6 @@ static int mwl8k_cmd_update_sta_db(struct ieee80211_hw *hw,
2565/* 2578/*
2566 * CMD_SET_AID. 2579 * CMD_SET_AID.
2567 */ 2580 */
2568#define MWL8K_RATE_INDEX_MAX_ARRAY 14
2569
2570#define MWL8K_FRAME_PROT_DISABLED 0x00 2581#define MWL8K_FRAME_PROT_DISABLED 0x00
2571#define MWL8K_FRAME_PROT_11G 0x07 2582#define MWL8K_FRAME_PROT_11G 0x07
2572#define MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY 0x02 2583#define MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY 0x02
@@ -2579,7 +2590,7 @@ struct mwl8k_cmd_update_set_aid {
2579 /* AP's MAC address (BSSID) */ 2590 /* AP's MAC address (BSSID) */
2580 __u8 bssid[ETH_ALEN]; 2591 __u8 bssid[ETH_ALEN];
2581 __le16 protection_mode; 2592 __le16 protection_mode;
2582 __u8 supp_rates[MWL8K_RATE_INDEX_MAX_ARRAY]; 2593 __u8 supp_rates[14];
2583} __attribute__((packed)); 2594} __attribute__((packed));
2584 2595
2585static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw, 2596static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
@@ -2588,8 +2599,6 @@ static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
2588 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif); 2599 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
2589 struct ieee80211_bss_conf *info = &mv_vif->bss_info; 2600 struct ieee80211_bss_conf *info = &mv_vif->bss_info;
2590 struct mwl8k_cmd_update_set_aid *cmd; 2601 struct mwl8k_cmd_update_set_aid *cmd;
2591 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2592 int count;
2593 u16 prot_mode; 2602 u16 prot_mode;
2594 int rc; 2603 int rc;
2595 2604
@@ -2621,8 +2630,7 @@ static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
2621 } 2630 }
2622 cmd->protection_mode = cpu_to_le16(prot_mode); 2631 cmd->protection_mode = cpu_to_le16(prot_mode);
2623 2632
2624 for (count = 0; count < mv_vif->legacy_nrates; count++) 2633 memcpy(cmd->supp_rates, mwl8k_rateids, sizeof(mwl8k_rateids));
2625 cmd->supp_rates[count] = bitrates[count].hw_value;
2626 2634
2627 rc = mwl8k_post_cmd(hw, &cmd->header); 2635 rc = mwl8k_post_cmd(hw, &cmd->header);
2628 kfree(cmd); 2636 kfree(cmd);
@@ -2635,20 +2643,17 @@ static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
2635 */ 2643 */
2636struct mwl8k_cmd_update_rateset { 2644struct mwl8k_cmd_update_rateset {
2637 struct mwl8k_cmd_pkt header; 2645 struct mwl8k_cmd_pkt header;
2638 __u8 legacy_rates[MWL8K_RATE_INDEX_MAX_ARRAY]; 2646 __u8 legacy_rates[14];
2639 2647
2640 /* Bitmap for supported MCS codes. */ 2648 /* Bitmap for supported MCS codes. */
2641 __u8 mcs_set[MWL8K_IEEE_LEGACY_DATA_RATES]; 2649 __u8 mcs_set[16];
2642 __u8 reserved[MWL8K_IEEE_LEGACY_DATA_RATES]; 2650 __u8 reserved[16];
2643} __attribute__((packed)); 2651} __attribute__((packed));
2644 2652
2645static int mwl8k_update_rateset(struct ieee80211_hw *hw, 2653static int mwl8k_update_rateset(struct ieee80211_hw *hw,
2646 struct ieee80211_vif *vif) 2654 struct ieee80211_vif *vif)
2647{ 2655{
2648 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
2649 struct mwl8k_cmd_update_rateset *cmd; 2656 struct mwl8k_cmd_update_rateset *cmd;
2650 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2651 int count;
2652 int rc; 2657 int rc;
2653 2658
2654 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 2659 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
@@ -2657,9 +2662,7 @@ static int mwl8k_update_rateset(struct ieee80211_hw *hw,
2657 2662
2658 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_RATE); 2663 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_RATE);
2659 cmd->header.length = cpu_to_le16(sizeof(*cmd)); 2664 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2660 2665 memcpy(cmd->legacy_rates, mwl8k_rateids, sizeof(mwl8k_rateids));
2661 for (count = 0; count < mv_vif->legacy_nrates; count++)
2662 cmd->legacy_rates[count] = bitrates[count].hw_value;
2663 2666
2664 rc = mwl8k_post_cmd(hw, &cmd->header); 2667 rc = mwl8k_post_cmd(hw, &cmd->header);
2665 kfree(cmd); 2668 kfree(cmd);
@@ -2932,11 +2935,6 @@ static int mwl8k_add_interface(struct ieee80211_hw *hw,
2932 /* Back pointer to parent config block */ 2935 /* Back pointer to parent config block */
2933 mwl8k_vif->priv = priv; 2936 mwl8k_vif->priv = priv;
2934 2937
2935 /* Setup initial PHY parameters */
2936 memcpy(mwl8k_vif->legacy_rates,
2937 priv->rates, sizeof(mwl8k_vif->legacy_rates));
2938 mwl8k_vif->legacy_nrates = ARRAY_SIZE(priv->rates);
2939
2940 /* Set Initial sequence number to zero */ 2938 /* Set Initial sequence number to zero */
2941 mwl8k_vif->seqno = 0; 2939 mwl8k_vif->seqno = 0;
2942 2940
@@ -3014,9 +3012,6 @@ static void mwl8k_bss_info_changed(struct ieee80211_hw *hw,
3014 struct mwl8k_vif *mwl8k_vif = MWL8K_VIF(vif); 3012 struct mwl8k_vif *mwl8k_vif = MWL8K_VIF(vif);
3015 int rc; 3013 int rc;
3016 3014
3017 if (changed & BSS_CHANGED_BSSID)
3018 memcpy(mwl8k_vif->bssid, info->bssid, ETH_ALEN);
3019
3020 if ((changed & BSS_CHANGED_ASSOC) == 0) 3015 if ((changed & BSS_CHANGED_ASSOC) == 0)
3021 return; 3016 return;
3022 3017
@@ -3030,6 +3025,8 @@ static void mwl8k_bss_info_changed(struct ieee80211_hw *hw,
3030 memcpy(&mwl8k_vif->bss_info, info, 3025 memcpy(&mwl8k_vif->bss_info, info,
3031 sizeof(struct ieee80211_bss_conf)); 3026 sizeof(struct ieee80211_bss_conf));
3032 3027
3028 memcpy(mwl8k_vif->bssid, info->bssid, ETH_ALEN);
3029
3033 /* Install rates */ 3030 /* Install rates */
3034 rc = mwl8k_update_rateset(hw, vif); 3031 rc = mwl8k_update_rateset(hw, vif);
3035 if (rc) 3032 if (rc)
@@ -3366,7 +3363,7 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
3366 if (rc) { 3363 if (rc) {
3367 printk(KERN_ERR "%s: Cannot obtain PCI resources\n", 3364 printk(KERN_ERR "%s: Cannot obtain PCI resources\n",
3368 MWL8K_NAME); 3365 MWL8K_NAME);
3369 return rc; 3366 goto err_disable_device;
3370 } 3367 }
3371 3368
3372 pci_set_master(pdev); 3369 pci_set_master(pdev);
@@ -3597,6 +3594,8 @@ err_iounmap:
3597 3594
3598err_free_reg: 3595err_free_reg:
3599 pci_release_regions(pdev); 3596 pci_release_regions(pdev);
3597
3598err_disable_device:
3600 pci_disable_device(pdev); 3599 pci_disable_device(pdev);
3601 3600
3602 return rc; 3601 return rc;
diff --git a/drivers/net/wireless/orinoco/hermes_dld.c b/drivers/net/wireless/orinoco/hermes_dld.c
index a3eefe109df4..6d5660defd87 100644
--- a/drivers/net/wireless/orinoco/hermes_dld.c
+++ b/drivers/net/wireless/orinoco/hermes_dld.c
@@ -427,7 +427,7 @@ int hermesi_program_init(hermes_t *hw, u32 offset)
427 if (err) 427 if (err)
428 return err; 428 return err;
429 429
430 pr_debug(KERN_DEBUG PFX "Enabling volatile, EP 0x%08x\n", offset); 430 pr_debug(PFX "Enabling volatile, EP 0x%08x\n", offset);
431 err = hermes_doicmd_wait(hw, 431 err = hermes_doicmd_wait(hw,
432 HERMES_PROGRAM_ENABLE_VOLATILE, 432 HERMES_PROGRAM_ENABLE_VOLATILE,
433 offset & 0xFFFFu, 433 offset & 0xFFFFu,
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index c5fe867665e6..1a7eae357fef 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -1323,7 +1323,7 @@
1323#define PAIRWISE_KEY_ENTRY(__idx) \ 1323#define PAIRWISE_KEY_ENTRY(__idx) \
1324 ( PAIRWISE_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) ) 1324 ( PAIRWISE_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) )
1325#define MAC_IVEIV_ENTRY(__idx) \ 1325#define MAC_IVEIV_ENTRY(__idx) \
1326 ( MAC_IVEIV_TABLE_BASE + ((__idx) & sizeof(struct mac_iveiv_entry)) ) 1326 ( MAC_IVEIV_TABLE_BASE + ((__idx) * sizeof(struct mac_iveiv_entry)) )
1327#define MAC_WCID_ATTR_ENTRY(__idx) \ 1327#define MAC_WCID_ATTR_ENTRY(__idx) \
1328 ( MAC_WCID_ATTRIBUTE_BASE + ((__idx) * sizeof(u32)) ) 1328 ( MAC_WCID_ATTRIBUTE_BASE + ((__idx) * sizeof(u32)) )
1329#define SHARED_KEY_ENTRY(__idx) \ 1329#define SHARED_KEY_ENTRY(__idx) \
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index eb1e1d00bec3..27bf887f1453 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -37,7 +37,7 @@
37#include <linux/module.h> 37#include <linux/module.h>
38 38
39#include "rt2x00.h" 39#include "rt2x00.h"
40#ifdef CONFIG_RT2800USB 40#if defined(CONFIG_RT2800USB) || defined(CONFIG_RT2800USB_MODULE)
41#include "rt2x00usb.h" 41#include "rt2x00usb.h"
42#endif 42#endif
43#include "rt2800lib.h" 43#include "rt2800lib.h"
@@ -1121,7 +1121,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
1121 1121
1122 if (rt2x00_intf_is_usb(rt2x00dev)) { 1122 if (rt2x00_intf_is_usb(rt2x00dev)) {
1123 rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000); 1123 rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000);
1124#ifdef CONFIG_RT2800USB 1124#if defined(CONFIG_RT2800USB) || defined(CONFIG_RT2800USB_MODULE)
1125 rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0, 1125 rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
1126 USB_MODE_RESET, REGISTER_TIMEOUT); 1126 USB_MODE_RESET, REGISTER_TIMEOUT);
1127#endif 1127#endif
@@ -2022,6 +2022,12 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2022 u16 eeprom; 2022 u16 eeprom;
2023 2023
2024 /* 2024 /*
2025 * Disable powersaving as default on PCI devices.
2026 */
2027 if (rt2x00_intf_is_pci(rt2x00dev))
2028 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
2029
2030 /*
2025 * Initialize all hw fields. 2031 * Initialize all hw fields.
2026 */ 2032 */
2027 rt2x00dev->hw->flags = 2033 rt2x00dev->hw->flags =
@@ -2074,8 +2080,7 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2074 IEEE80211_HT_CAP_SGI_20 | 2080 IEEE80211_HT_CAP_SGI_20 |
2075 IEEE80211_HT_CAP_SGI_40 | 2081 IEEE80211_HT_CAP_SGI_40 |
2076 IEEE80211_HT_CAP_TX_STBC | 2082 IEEE80211_HT_CAP_TX_STBC |
2077 IEEE80211_HT_CAP_RX_STBC | 2083 IEEE80211_HT_CAP_RX_STBC;
2078 IEEE80211_HT_CAP_PSMP_SUPPORT;
2079 spec->ht.ampdu_factor = 3; 2084 spec->ht.ampdu_factor = 3;
2080 spec->ht.ampdu_density = 4; 2085 spec->ht.ampdu_density = 4;
2081 spec->ht.mcs.tx_params = 2086 spec->ht.mcs.tx_params =
@@ -2140,8 +2145,8 @@ static void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,
2140 rt2800_register_multiread(rt2x00dev, offset, 2145 rt2800_register_multiread(rt2x00dev, offset,
2141 &iveiv_entry, sizeof(iveiv_entry)); 2146 &iveiv_entry, sizeof(iveiv_entry));
2142 2147
2143 memcpy(&iveiv_entry.iv[0], iv16, sizeof(iv16)); 2148 memcpy(iv16, &iveiv_entry.iv[0], sizeof(*iv16));
2144 memcpy(&iveiv_entry.iv[4], iv32, sizeof(iv32)); 2149 memcpy(iv32, &iveiv_entry.iv[4], sizeof(*iv32));
2145} 2150}
2146 2151
2147static int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value) 2152static int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 687e17dc2e9f..0ca589306d71 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -2539,6 +2539,11 @@ static int rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2539 unsigned int i; 2539 unsigned int i;
2540 2540
2541 /* 2541 /*
2542 * Disable powersaving as default.
2543 */
2544 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
2545
2546 /*
2542 * Initialize all hw fields. 2547 * Initialize all hw fields.
2543 */ 2548 */
2544 rt2x00dev->hw->flags = 2549 rt2x00dev->hw->flags =
diff --git a/drivers/net/wireless/rtl818x/rtl8187.h b/drivers/net/wireless/rtl818x/rtl8187.h
index abb4907cf296..6af0f3f71f3a 100644
--- a/drivers/net/wireless/rtl818x/rtl8187.h
+++ b/drivers/net/wireless/rtl818x/rtl8187.h
@@ -23,6 +23,7 @@
23#define RTL8187_EEPROM_TXPWR_CHAN_1 0x16 /* 3 channels */ 23#define RTL8187_EEPROM_TXPWR_CHAN_1 0x16 /* 3 channels */
24#define RTL8187_EEPROM_TXPWR_CHAN_6 0x1B /* 2 channels */ 24#define RTL8187_EEPROM_TXPWR_CHAN_6 0x1B /* 2 channels */
25#define RTL8187_EEPROM_TXPWR_CHAN_4 0x3D /* 2 channels */ 25#define RTL8187_EEPROM_TXPWR_CHAN_4 0x3D /* 2 channels */
26#define RTL8187_EEPROM_SELECT_GPIO 0x3B
26 27
27#define RTL8187_REQT_READ 0xC0 28#define RTL8187_REQT_READ 0xC0
28#define RTL8187_REQT_WRITE 0x40 29#define RTL8187_REQT_WRITE 0x40
@@ -31,6 +32,9 @@
31 32
32#define RTL8187_MAX_RX 0x9C4 33#define RTL8187_MAX_RX 0x9C4
33 34
35#define RFKILL_MASK_8187_89_97 0x2
36#define RFKILL_MASK_8198 0x4
37
34struct rtl8187_rx_info { 38struct rtl8187_rx_info {
35 struct urb *urb; 39 struct urb *urb;
36 struct ieee80211_hw *dev; 40 struct ieee80211_hw *dev;
@@ -104,6 +108,7 @@ struct rtl8187_priv {
104 struct delayed_work work; 108 struct delayed_work work;
105 struct ieee80211_hw *dev; 109 struct ieee80211_hw *dev;
106#ifdef CONFIG_RTL8187_LEDS 110#ifdef CONFIG_RTL8187_LEDS
111 struct rtl8187_led led_radio;
107 struct rtl8187_led led_tx; 112 struct rtl8187_led led_tx;
108 struct rtl8187_led led_rx; 113 struct rtl8187_led led_rx;
109 struct delayed_work led_on; 114 struct delayed_work led_on;
@@ -122,6 +127,7 @@ struct rtl8187_priv {
122 u8 noise; 127 u8 noise;
123 u8 slot_time; 128 u8 slot_time;
124 u8 aifsn[4]; 129 u8 aifsn[4];
130 u8 rfkill_mask;
125 struct { 131 struct {
126 __le64 buf; 132 __le64 buf;
127 struct sk_buff_head queue; 133 struct sk_buff_head queue;
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 76973b8c7099..bc5726dd5fe4 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -1322,6 +1322,7 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1322 struct ieee80211_channel *channel; 1322 struct ieee80211_channel *channel;
1323 const char *chip_name; 1323 const char *chip_name;
1324 u16 txpwr, reg; 1324 u16 txpwr, reg;
1325 u16 product_id = le16_to_cpu(udev->descriptor.idProduct);
1325 int err, i; 1326 int err, i;
1326 1327
1327 dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8187_ops); 1328 dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8187_ops);
@@ -1481,6 +1482,13 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1481 (*channel++).hw_value = txpwr & 0xFF; 1482 (*channel++).hw_value = txpwr & 0xFF;
1482 (*channel++).hw_value = txpwr >> 8; 1483 (*channel++).hw_value = txpwr >> 8;
1483 } 1484 }
1485 /* Handle the differing rfkill GPIO bit in different models */
1486 priv->rfkill_mask = RFKILL_MASK_8187_89_97;
1487 if (product_id == 0x8197 || product_id == 0x8198) {
1488 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_SELECT_GPIO, &reg);
1489 if (reg & 0xFF00)
1490 priv->rfkill_mask = RFKILL_MASK_8198;
1491 }
1484 1492
1485 /* 1493 /*
1486 * XXX: Once this driver supports anything that requires 1494 * XXX: Once this driver supports anything that requires
@@ -1509,9 +1517,9 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1509 mutex_init(&priv->conf_mutex); 1517 mutex_init(&priv->conf_mutex);
1510 skb_queue_head_init(&priv->b_tx_status.queue); 1518 skb_queue_head_init(&priv->b_tx_status.queue);
1511 1519
1512 printk(KERN_INFO "%s: hwaddr %pM, %s V%d + %s\n", 1520 printk(KERN_INFO "%s: hwaddr %pM, %s V%d + %s, rfkill mask %d\n",
1513 wiphy_name(dev->wiphy), dev->wiphy->perm_addr, 1521 wiphy_name(dev->wiphy), dev->wiphy->perm_addr,
1514 chip_name, priv->asic_rev, priv->rf->name); 1522 chip_name, priv->asic_rev, priv->rf->name, priv->rfkill_mask);
1515 1523
1516#ifdef CONFIG_RTL8187_LEDS 1524#ifdef CONFIG_RTL8187_LEDS
1517 eeprom_93cx6_read(&eeprom, 0x3F, &reg); 1525 eeprom_93cx6_read(&eeprom, 0x3F, &reg);
diff --git a/drivers/net/wireless/rtl818x/rtl8187_leds.c b/drivers/net/wireless/rtl818x/rtl8187_leds.c
index cf8a4a40fdf6..ded44c045eb2 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_leds.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_leds.c
@@ -105,19 +105,36 @@ static void rtl8187_led_brightness_set(struct led_classdev *led_dev,
105 struct rtl8187_led *led = container_of(led_dev, struct rtl8187_led, 105 struct rtl8187_led *led = container_of(led_dev, struct rtl8187_led,
106 led_dev); 106 led_dev);
107 struct ieee80211_hw *hw = led->dev; 107 struct ieee80211_hw *hw = led->dev;
108 struct rtl8187_priv *priv = hw->priv; 108 struct rtl8187_priv *priv;
109 static bool radio_on;
109 110
110 if (brightness == LED_OFF) { 111 if (!hw)
111 ieee80211_queue_delayed_work(hw, &priv->led_off, 0); 112 return;
112 /* The LED is off for 1/20 sec so that it just blinks. */ 113 priv = hw->priv;
113 ieee80211_queue_delayed_work(hw, &priv->led_on, HZ / 20); 114 if (led->is_radio) {
114 } else 115 if (brightness == LED_FULL) {
115 ieee80211_queue_delayed_work(hw, &priv->led_on, 0); 116 ieee80211_queue_delayed_work(hw, &priv->led_on, 0);
117 radio_on = true;
118 } else if (radio_on) {
119 radio_on = false;
120 cancel_delayed_work_sync(&priv->led_on);
121 ieee80211_queue_delayed_work(hw, &priv->led_off, 0);
122 }
123 } else if (radio_on) {
124 if (brightness == LED_OFF) {
125 ieee80211_queue_delayed_work(hw, &priv->led_off, 0);
126 /* The LED is off for 1/20 sec - it just blinks. */
127 ieee80211_queue_delayed_work(hw, &priv->led_on,
128 HZ / 20);
129 } else
130 ieee80211_queue_delayed_work(hw, &priv->led_on, 0);
131 }
116} 132}
117 133
118static int rtl8187_register_led(struct ieee80211_hw *dev, 134static int rtl8187_register_led(struct ieee80211_hw *dev,
119 struct rtl8187_led *led, const char *name, 135 struct rtl8187_led *led, const char *name,
120 const char *default_trigger, u8 ledpin) 136 const char *default_trigger, u8 ledpin,
137 bool is_radio)
121{ 138{
122 int err; 139 int err;
123 struct rtl8187_priv *priv = dev->priv; 140 struct rtl8187_priv *priv = dev->priv;
@@ -128,6 +145,7 @@ static int rtl8187_register_led(struct ieee80211_hw *dev,
128 return -EINVAL; 145 return -EINVAL;
129 led->dev = dev; 146 led->dev = dev;
130 led->ledpin = ledpin; 147 led->ledpin = ledpin;
148 led->is_radio = is_radio;
131 strncpy(led->name, name, sizeof(led->name)); 149 strncpy(led->name, name, sizeof(led->name));
132 150
133 led->led_dev.name = led->name; 151 led->led_dev.name = led->name;
@@ -145,7 +163,11 @@ static int rtl8187_register_led(struct ieee80211_hw *dev,
145 163
146static void rtl8187_unregister_led(struct rtl8187_led *led) 164static void rtl8187_unregister_led(struct rtl8187_led *led)
147{ 165{
166 struct ieee80211_hw *hw = led->dev;
167 struct rtl8187_priv *priv = hw->priv;
168
148 led_classdev_unregister(&led->led_dev); 169 led_classdev_unregister(&led->led_dev);
170 flush_delayed_work(&priv->led_off);
149 led->dev = NULL; 171 led->dev = NULL;
150} 172}
151 173
@@ -183,33 +205,37 @@ void rtl8187_leds_init(struct ieee80211_hw *dev, u16 custid)
183 INIT_DELAYED_WORK(&priv->led_off, led_turn_off); 205 INIT_DELAYED_WORK(&priv->led_off, led_turn_off);
184 206
185 snprintf(name, sizeof(name), 207 snprintf(name, sizeof(name),
208 "rtl8187-%s::radio", wiphy_name(dev->wiphy));
209 err = rtl8187_register_led(dev, &priv->led_radio, name,
210 ieee80211_get_radio_led_name(dev), ledpin, true);
211 if (err)
212 return;
213
214 snprintf(name, sizeof(name),
186 "rtl8187-%s::tx", wiphy_name(dev->wiphy)); 215 "rtl8187-%s::tx", wiphy_name(dev->wiphy));
187 err = rtl8187_register_led(dev, &priv->led_tx, name, 216 err = rtl8187_register_led(dev, &priv->led_tx, name,
188 ieee80211_get_tx_led_name(dev), ledpin); 217 ieee80211_get_tx_led_name(dev), ledpin, false);
189 if (err) 218 if (err)
190 goto error; 219 goto err_tx;
220
191 snprintf(name, sizeof(name), 221 snprintf(name, sizeof(name),
192 "rtl8187-%s::rx", wiphy_name(dev->wiphy)); 222 "rtl8187-%s::rx", wiphy_name(dev->wiphy));
193 err = rtl8187_register_led(dev, &priv->led_rx, name, 223 err = rtl8187_register_led(dev, &priv->led_rx, name,
194 ieee80211_get_rx_led_name(dev), ledpin); 224 ieee80211_get_rx_led_name(dev), ledpin, false);
195 if (!err) { 225 if (!err)
196 ieee80211_queue_delayed_work(dev, &priv->led_on, 0);
197 return; 226 return;
198 } 227
199 /* registration of RX LED failed - unregister TX */ 228 /* registration of RX LED failed - unregister */
200 rtl8187_unregister_led(&priv->led_tx); 229 rtl8187_unregister_led(&priv->led_tx);
201error: 230err_tx:
202 /* If registration of either failed, cancel delayed work */ 231 rtl8187_unregister_led(&priv->led_radio);
203 cancel_delayed_work_sync(&priv->led_off);
204 cancel_delayed_work_sync(&priv->led_on);
205} 232}
206 233
207void rtl8187_leds_exit(struct ieee80211_hw *dev) 234void rtl8187_leds_exit(struct ieee80211_hw *dev)
208{ 235{
209 struct rtl8187_priv *priv = dev->priv; 236 struct rtl8187_priv *priv = dev->priv;
210 237
211 /* turn the LED off before exiting */ 238 rtl8187_unregister_led(&priv->led_radio);
212 ieee80211_queue_delayed_work(dev, &priv->led_off, 0);
213 rtl8187_unregister_led(&priv->led_rx); 239 rtl8187_unregister_led(&priv->led_rx);
214 rtl8187_unregister_led(&priv->led_tx); 240 rtl8187_unregister_led(&priv->led_tx);
215 cancel_delayed_work_sync(&priv->led_off); 241 cancel_delayed_work_sync(&priv->led_off);
diff --git a/drivers/net/wireless/rtl818x/rtl8187_leds.h b/drivers/net/wireless/rtl818x/rtl8187_leds.h
index a0332027aead..efe8041bdda4 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_leds.h
+++ b/drivers/net/wireless/rtl818x/rtl8187_leds.h
@@ -47,6 +47,8 @@ struct rtl8187_led {
47 u8 ledpin; 47 u8 ledpin;
48 /* The unique name string for this LED device. */ 48 /* The unique name string for this LED device. */
49 char name[RTL8187_LED_MAX_NAME_LEN + 1]; 49 char name[RTL8187_LED_MAX_NAME_LEN + 1];
50 /* If the LED is radio or tx/rx */
51 bool is_radio;
50}; 52};
51 53
52void rtl8187_leds_init(struct ieee80211_hw *dev, u16 code); 54void rtl8187_leds_init(struct ieee80211_hw *dev, u16 code);
diff --git a/drivers/net/wireless/rtl818x/rtl8187_rfkill.c b/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
index cad8037ab2af..03555e1e0cab 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
@@ -25,10 +25,10 @@ static bool rtl8187_is_radio_enabled(struct rtl8187_priv *priv)
25 u8 gpio; 25 u8 gpio;
26 26
27 gpio = rtl818x_ioread8(priv, &priv->map->GPIO0); 27 gpio = rtl818x_ioread8(priv, &priv->map->GPIO0);
28 rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~0x02); 28 rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~priv->rfkill_mask);
29 gpio = rtl818x_ioread8(priv, &priv->map->GPIO1); 29 gpio = rtl818x_ioread8(priv, &priv->map->GPIO1);
30 30
31 return gpio & 0x02; 31 return gpio & priv->rfkill_mask;
32} 32}
33 33
34void rtl8187_rfkill_init(struct ieee80211_hw *hw) 34void rtl8187_rfkill_init(struct ieee80211_hw *hw)
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c
index 63511ca131b1..6aeffbe9e401 100644
--- a/drivers/net/wireless/wl12xx/wl1251_main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -630,10 +630,6 @@ static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed)
630 goto out_sleep; 630 goto out_sleep;
631 } 631 }
632 632
633 ret = wl1251_build_null_data(wl);
634 if (ret < 0)
635 goto out_sleep;
636
637 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) { 633 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) {
638 wl1251_debug(DEBUG_PSM, "psm enabled"); 634 wl1251_debug(DEBUG_PSM, "psm enabled");
639 635
@@ -1116,6 +1112,21 @@ static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
1116 if (ret < 0) 1112 if (ret < 0)
1117 goto out; 1113 goto out;
1118 1114
1115 if (changed & BSS_CHANGED_BSSID) {
1116 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1117
1118 ret = wl1251_build_null_data(wl);
1119 if (ret < 0)
1120 goto out;
1121
1122 if (wl->bss_type != BSS_TYPE_IBSS) {
1123 ret = wl1251_join(wl, wl->bss_type, wl->channel,
1124 wl->beacon_int, wl->dtim_period);
1125 if (ret < 0)
1126 goto out_sleep;
1127 }
1128 }
1129
1119 if (changed & BSS_CHANGED_ASSOC) { 1130 if (changed & BSS_CHANGED_ASSOC) {
1120 if (bss_conf->assoc) { 1131 if (bss_conf->assoc) {
1121 wl->beacon_int = bss_conf->beacon_int; 1132 wl->beacon_int = bss_conf->beacon_int;
@@ -1175,23 +1186,6 @@ static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
1175 } 1186 }
1176 } 1187 }
1177 1188
1178 if (changed & BSS_CHANGED_BSSID) {
1179 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1180
1181 ret = wl1251_build_null_data(wl);
1182 if (ret < 0)
1183 goto out;
1184
1185 if (wl->bss_type != BSS_TYPE_IBSS) {
1186 ret = wl1251_join(wl, wl->bss_type, wl->channel,
1187 wl->beacon_int, wl->dtim_period);
1188 if (ret < 0)
1189 goto out_sleep;
1190 wl1251_warning("Set ctsprotect failed %d", ret);
1191 goto out_sleep;
1192 }
1193 }
1194
1195 if (changed & BSS_CHANGED_BEACON) { 1189 if (changed & BSS_CHANGED_BEACON) {
1196 beacon = ieee80211_beacon_get(hw, vif); 1190 beacon = ieee80211_beacon_get(hw, vif);
1197 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data, 1191 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data,
diff --git a/include/linux/gigaset_dev.h b/include/linux/gigaset_dev.h
index 5dc4a316ca37..258ba82937e7 100644
--- a/include/linux/gigaset_dev.h
+++ b/include/linux/gigaset_dev.h
@@ -16,15 +16,23 @@
16 16
17#include <linux/ioctl.h> 17#include <linux/ioctl.h>
18 18
19/* The magic IOCTL value for this interface. */
19#define GIGASET_IOCTL 0x47 20#define GIGASET_IOCTL 0x47
20 21
21#define GIGVER_DRIVER 0 22/* enable/disable device control via character device (lock out ISDN subsys) */
22#define GIGVER_COMPAT 1 23#define GIGASET_REDIR _IOWR(GIGASET_IOCTL, 0, int)
23#define GIGVER_FWBASE 2
24 24
25#define GIGASET_REDIR _IOWR (GIGASET_IOCTL, 0, int) 25/* enable adapter configuration mode (M10x only) */
26#define GIGASET_CONFIG _IOWR (GIGASET_IOCTL, 1, int) 26#define GIGASET_CONFIG _IOWR(GIGASET_IOCTL, 1, int)
27#define GIGASET_BRKCHARS _IOW (GIGASET_IOCTL, 2, unsigned char[6]) //FIXME [6] okay? 27
28#define GIGASET_VERSION _IOWR (GIGASET_IOCTL, 3, unsigned[4]) 28/* set break characters (M105 only) */
29#define GIGASET_BRKCHARS _IOW(GIGASET_IOCTL, 2, unsigned char[6])
30
31/* get version information selected by arg[0] */
32#define GIGASET_VERSION _IOWR(GIGASET_IOCTL, 3, unsigned[4])
33/* values for GIGASET_VERSION arg[0] */
34#define GIGVER_DRIVER 0 /* get driver version */
35#define GIGVER_COMPAT 1 /* get interface compatibility version */
36#define GIGVER_FWBASE 2 /* get base station firmware version */
29 37
30#endif 38#endif
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 098bedcde9bb..d62edc7df3ae 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -840,7 +840,7 @@ struct ieee80211_ht_cap {
840#define IEEE80211_HT_CAP_DELAY_BA 0x0400 840#define IEEE80211_HT_CAP_DELAY_BA 0x0400
841#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 841#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
842#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 842#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
843#define IEEE80211_HT_CAP_PSMP_SUPPORT 0x2000 843#define IEEE80211_HT_CAP_RESERVED 0x2000
844#define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000 844#define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
845#define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000 845#define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
846 846
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 005e1525ab86..299b4121f914 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -137,8 +137,6 @@ extern struct ctl_table ether_table[];
137extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len); 137extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
138 138
139#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" 139#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
140#define MAC_BUF_SIZE 18
141#define DECLARE_MAC_BUF(var) char var[MAC_BUF_SIZE]
142 140
143#endif 141#endif
144 142
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index 92838d3a1ab7..e46674d5daea 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -53,7 +53,7 @@ static inline int inet6_sk_ehashfn(const struct sock *sk)
53 return inet6_ehashfn(net, laddr, lport, faddr, fport); 53 return inet6_ehashfn(net, laddr, lport, faddr, fport);
54} 54}
55 55
56extern void __inet6_hash(struct sock *sk); 56extern int __inet6_hash(struct sock *sk, struct inet_timewait_sock *twp);
57 57
58/* 58/*
59 * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so 59 * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 41cbddd25b70..74358d1b3f43 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -251,7 +251,7 @@ extern void inet_put_port(struct sock *sk);
251 251
252void inet_hashinfo_init(struct inet_hashinfo *h); 252void inet_hashinfo_init(struct inet_hashinfo *h);
253 253
254extern void __inet_hash_nolisten(struct sock *sk); 254extern int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw);
255extern void inet_hash(struct sock *sk); 255extern void inet_hash(struct sock *sk);
256extern void inet_unhash(struct sock *sk); 256extern void inet_unhash(struct sock *sk);
257 257
@@ -391,10 +391,12 @@ static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,
391} 391}
392 392
393extern int __inet_hash_connect(struct inet_timewait_death_row *death_row, 393extern int __inet_hash_connect(struct inet_timewait_death_row *death_row,
394 struct sock *sk, u32 port_offset, 394 struct sock *sk,
395 u32 port_offset,
395 int (*check_established)(struct inet_timewait_death_row *, 396 int (*check_established)(struct inet_timewait_death_row *,
396 struct sock *, __u16, struct inet_timewait_sock **), 397 struct sock *, __u16, struct inet_timewait_sock **),
397 void (*hash)(struct sock *sk)); 398 int (*hash)(struct sock *sk, struct inet_timewait_sock *twp));
399
398extern int inet_hash_connect(struct inet_timewait_death_row *death_row, 400extern int inet_hash_connect(struct inet_timewait_death_row *death_row,
399 struct sock *sk); 401 struct sock *sk);
400#endif /* _INET_HASHTABLES_H */ 402#endif /* _INET_HASHTABLES_H */
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index b801ade2295e..79f67eae8a7e 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -201,6 +201,9 @@ extern void inet_twsk_put(struct inet_timewait_sock *tw);
201 201
202extern int inet_twsk_unhash(struct inet_timewait_sock *tw); 202extern int inet_twsk_unhash(struct inet_timewait_sock *tw);
203 203
204extern int inet_twsk_bind_unhash(struct inet_timewait_sock *tw,
205 struct inet_hashinfo *hashinfo);
206
204extern struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, 207extern struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
205 const int state); 208 const int state);
206 209
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index e6b6bf81d5b9..494ac69ff477 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1798,6 +1798,12 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
1798 local_bh_enable(); 1798 local_bh_enable();
1799} 1799}
1800 1800
1801/*
1802 * The TX headroom reserved by mac80211 for its own tx_status functions.
1803 * This is enough for the radiotap header.
1804 */
1805#define IEEE80211_TX_STATUS_HEADROOM 13
1806
1801/** 1807/**
1802 * ieee80211_tx_status - transmit status callback 1808 * ieee80211_tx_status - transmit status callback
1803 * 1809 *
diff --git a/include/net/tcp.h b/include/net/tcp.h
index e2d2ca2509be..0248c181a92c 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1261,28 +1261,6 @@ static inline struct sk_buff *tcp_write_queue_prev(struct sock *sk, struct sk_bu
1261#define tcp_for_write_queue_from_safe(skb, tmp, sk) \ 1261#define tcp_for_write_queue_from_safe(skb, tmp, sk) \
1262 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) 1262 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp)
1263 1263
1264/* This function calculates a "timeout" which is equivalent to the timeout of a
1265 * TCP connection after "boundary" unsucessful, exponentially backed-off
1266 * retransmissions with an initial RTO of TCP_RTO_MIN.
1267 */
1268static inline bool retransmits_timed_out(const struct sock *sk,
1269 unsigned int boundary)
1270{
1271 unsigned int timeout, linear_backoff_thresh;
1272
1273 if (!inet_csk(sk)->icsk_retransmits)
1274 return false;
1275
1276 linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN);
1277
1278 if (boundary <= linear_backoff_thresh)
1279 timeout = ((2 << boundary) - 1) * TCP_RTO_MIN;
1280 else
1281 timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN +
1282 (boundary - linear_backoff_thresh) * TCP_RTO_MAX;
1283
1284 return (tcp_time_stamp - tcp_sk(sk)->retrans_stamp) >= timeout;
1285}
1286 1264
1287static inline struct sk_buff *tcp_send_head(struct sock *sk) 1265static inline struct sk_buff *tcp_send_head(struct sock *sk)
1288{ 1266{
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 26a646d4eb32..c9230c398697 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -554,6 +554,12 @@ static const struct net_device_ops br2684_netdev_ops = {
554 .ndo_validate_addr = eth_validate_addr, 554 .ndo_validate_addr = eth_validate_addr,
555}; 555};
556 556
557static const struct net_device_ops br2684_netdev_ops_routed = {
558 .ndo_start_xmit = br2684_start_xmit,
559 .ndo_set_mac_address = br2684_mac_addr,
560 .ndo_change_mtu = eth_change_mtu
561};
562
557static void br2684_setup(struct net_device *netdev) 563static void br2684_setup(struct net_device *netdev)
558{ 564{
559 struct br2684_dev *brdev = BRPRIV(netdev); 565 struct br2684_dev *brdev = BRPRIV(netdev);
@@ -569,11 +575,10 @@ static void br2684_setup(struct net_device *netdev)
569static void br2684_setup_routed(struct net_device *netdev) 575static void br2684_setup_routed(struct net_device *netdev)
570{ 576{
571 struct br2684_dev *brdev = BRPRIV(netdev); 577 struct br2684_dev *brdev = BRPRIV(netdev);
572 brdev->net_dev = netdev;
573 578
579 brdev->net_dev = netdev;
574 netdev->hard_header_len = 0; 580 netdev->hard_header_len = 0;
575 581 netdev->netdev_ops = &br2684_netdev_ops_routed;
576 netdev->netdev_ops = &br2684_netdev_ops;
577 netdev->addr_len = 0; 582 netdev->addr_len = 0;
578 netdev->mtu = 1500; 583 netdev->mtu = 1500;
579 netdev->type = ARPHRD_PPP; 584 netdev->type = ARPHRD_PPP;
diff --git a/net/atm/lec.c b/net/atm/lec.c
index b2d644560323..42749b7b917c 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -62,7 +62,6 @@ static int lec_open(struct net_device *dev);
62static netdev_tx_t lec_start_xmit(struct sk_buff *skb, 62static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
63 struct net_device *dev); 63 struct net_device *dev);
64static int lec_close(struct net_device *dev); 64static int lec_close(struct net_device *dev);
65static void lec_init(struct net_device *dev);
66static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, 65static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
67 const unsigned char *mac_addr); 66 const unsigned char *mac_addr);
68static int lec_arp_remove(struct lec_priv *priv, 67static int lec_arp_remove(struct lec_priv *priv,
@@ -670,13 +669,6 @@ static const struct net_device_ops lec_netdev_ops = {
670 .ndo_set_multicast_list = lec_set_multicast_list, 669 .ndo_set_multicast_list = lec_set_multicast_list,
671}; 670};
672 671
673
674static void lec_init(struct net_device *dev)
675{
676 dev->netdev_ops = &lec_netdev_ops;
677 printk("%s: Initialized!\n", dev->name);
678}
679
680static const unsigned char lec_ctrl_magic[] = { 672static const unsigned char lec_ctrl_magic[] = {
681 0xff, 673 0xff,
682 0x00, 674 0x00,
@@ -893,6 +885,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
893 dev_lec[i] = alloc_etherdev(size); 885 dev_lec[i] = alloc_etherdev(size);
894 if (!dev_lec[i]) 886 if (!dev_lec[i])
895 return -ENOMEM; 887 return -ENOMEM;
888 dev_lec[i]->netdev_ops = &lec_netdev_ops;
896 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); 889 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i);
897 if (register_netdev(dev_lec[i])) { 890 if (register_netdev(dev_lec[i])) {
898 free_netdev(dev_lec[i]); 891 free_netdev(dev_lec[i]);
@@ -901,7 +894,6 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
901 894
902 priv = netdev_priv(dev_lec[i]); 895 priv = netdev_priv(dev_lec[i]);
903 priv->is_trdev = is_trdev; 896 priv->is_trdev = is_trdev;
904 lec_init(dev_lec[i]);
905 } else { 897 } else {
906 priv = netdev_priv(dev_lec[i]); 898 priv = netdev_priv(dev_lec[i]);
907 if (priv->lecd) 899 if (priv->lecd)
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index efbcfdc12796..dad7bc4878e0 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -408,7 +408,7 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb,
408 408
409 dccp_sync_mss(newsk, dst_mtu(dst)); 409 dccp_sync_mss(newsk, dst_mtu(dst));
410 410
411 __inet_hash_nolisten(newsk); 411 __inet_hash_nolisten(newsk, NULL);
412 __inet_inherit_port(sk, newsk); 412 __inet_inherit_port(sk, newsk);
413 413
414 return newsk; 414 return newsk;
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 6574215a1f51..baf05cf43c28 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -46,7 +46,7 @@ static void dccp_v6_hash(struct sock *sk)
46 return; 46 return;
47 } 47 }
48 local_bh_disable(); 48 local_bh_disable();
49 __inet6_hash(sk); 49 __inet6_hash(sk, NULL);
50 local_bh_enable(); 50 local_bh_enable();
51 } 51 }
52} 52}
@@ -644,7 +644,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
644 newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; 644 newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;
645 newinet->inet_rcv_saddr = LOOPBACK4_IPV6; 645 newinet->inet_rcv_saddr = LOOPBACK4_IPV6;
646 646
647 __inet6_hash(newsk); 647 __inet6_hash(newsk, NULL);
648 __inet_inherit_port(sk, newsk); 648 __inet_inherit_port(sk, newsk);
649 649
650 return newsk; 650 return newsk;
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 21e5e32d8c60..2b79377b468d 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -351,12 +351,13 @@ static inline u32 inet_sk_port_offset(const struct sock *sk)
351 inet->inet_dport); 351 inet->inet_dport);
352} 352}
353 353
354void __inet_hash_nolisten(struct sock *sk) 354int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw)
355{ 355{
356 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; 356 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
357 struct hlist_nulls_head *list; 357 struct hlist_nulls_head *list;
358 spinlock_t *lock; 358 spinlock_t *lock;
359 struct inet_ehash_bucket *head; 359 struct inet_ehash_bucket *head;
360 int twrefcnt = 0;
360 361
361 WARN_ON(!sk_unhashed(sk)); 362 WARN_ON(!sk_unhashed(sk));
362 363
@@ -367,8 +368,13 @@ void __inet_hash_nolisten(struct sock *sk)
367 368
368 spin_lock(lock); 369 spin_lock(lock);
369 __sk_nulls_add_node_rcu(sk, list); 370 __sk_nulls_add_node_rcu(sk, list);
371 if (tw) {
372 WARN_ON(sk->sk_hash != tw->tw_hash);
373 twrefcnt = inet_twsk_unhash(tw);
374 }
370 spin_unlock(lock); 375 spin_unlock(lock);
371 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 376 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
377 return twrefcnt;
372} 378}
373EXPORT_SYMBOL_GPL(__inet_hash_nolisten); 379EXPORT_SYMBOL_GPL(__inet_hash_nolisten);
374 380
@@ -378,7 +384,7 @@ static void __inet_hash(struct sock *sk)
378 struct inet_listen_hashbucket *ilb; 384 struct inet_listen_hashbucket *ilb;
379 385
380 if (sk->sk_state != TCP_LISTEN) { 386 if (sk->sk_state != TCP_LISTEN) {
381 __inet_hash_nolisten(sk); 387 __inet_hash_nolisten(sk, NULL);
382 return; 388 return;
383 } 389 }
384 390
@@ -427,7 +433,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
427 struct sock *sk, u32 port_offset, 433 struct sock *sk, u32 port_offset,
428 int (*check_established)(struct inet_timewait_death_row *, 434 int (*check_established)(struct inet_timewait_death_row *,
429 struct sock *, __u16, struct inet_timewait_sock **), 435 struct sock *, __u16, struct inet_timewait_sock **),
430 void (*hash)(struct sock *sk)) 436 int (*hash)(struct sock *sk, struct inet_timewait_sock *twp))
431{ 437{
432 struct inet_hashinfo *hinfo = death_row->hashinfo; 438 struct inet_hashinfo *hinfo = death_row->hashinfo;
433 const unsigned short snum = inet_sk(sk)->inet_num; 439 const unsigned short snum = inet_sk(sk)->inet_num;
@@ -435,6 +441,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
435 struct inet_bind_bucket *tb; 441 struct inet_bind_bucket *tb;
436 int ret; 442 int ret;
437 struct net *net = sock_net(sk); 443 struct net *net = sock_net(sk);
444 int twrefcnt = 1;
438 445
439 if (!snum) { 446 if (!snum) {
440 int i, remaining, low, high, port; 447 int i, remaining, low, high, port;
@@ -493,13 +500,18 @@ ok:
493 inet_bind_hash(sk, tb, port); 500 inet_bind_hash(sk, tb, port);
494 if (sk_unhashed(sk)) { 501 if (sk_unhashed(sk)) {
495 inet_sk(sk)->inet_sport = htons(port); 502 inet_sk(sk)->inet_sport = htons(port);
496 hash(sk); 503 twrefcnt += hash(sk, tw);
497 } 504 }
505 if (tw)
506 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
498 spin_unlock(&head->lock); 507 spin_unlock(&head->lock);
499 508
500 if (tw) { 509 if (tw) {
501 inet_twsk_deschedule(tw, death_row); 510 inet_twsk_deschedule(tw, death_row);
502 inet_twsk_put(tw); 511 while (twrefcnt) {
512 twrefcnt--;
513 inet_twsk_put(tw);
514 }
503 } 515 }
504 516
505 ret = 0; 517 ret = 0;
@@ -510,7 +522,7 @@ ok:
510 tb = inet_csk(sk)->icsk_bind_hash; 522 tb = inet_csk(sk)->icsk_bind_hash;
511 spin_lock_bh(&head->lock); 523 spin_lock_bh(&head->lock);
512 if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { 524 if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) {
513 hash(sk); 525 hash(sk, NULL);
514 spin_unlock_bh(&head->lock); 526 spin_unlock_bh(&head->lock);
515 return 0; 527 return 0;
516 } else { 528 } else {
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 0fdf45e4c90c..cc94cc2d8b2d 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -15,9 +15,13 @@
15#include <net/ip.h> 15#include <net/ip.h>
16 16
17 17
18/* 18/**
19 * unhash a timewait socket from established hash 19 * inet_twsk_unhash - unhash a timewait socket from established hash
20 * lock must be hold by caller 20 * @tw: timewait socket
21 *
22 * unhash a timewait socket from established hash, if hashed.
23 * ehash lock must be held by caller.
24 * Returns 1 if caller should call inet_twsk_put() after lock release.
21 */ 25 */
22int inet_twsk_unhash(struct inet_timewait_sock *tw) 26int inet_twsk_unhash(struct inet_timewait_sock *tw)
23{ 27{
@@ -26,6 +30,37 @@ int inet_twsk_unhash(struct inet_timewait_sock *tw)
26 30
27 hlist_nulls_del_rcu(&tw->tw_node); 31 hlist_nulls_del_rcu(&tw->tw_node);
28 sk_nulls_node_init(&tw->tw_node); 32 sk_nulls_node_init(&tw->tw_node);
33 /*
34 * We cannot call inet_twsk_put() ourself under lock,
35 * caller must call it for us.
36 */
37 return 1;
38}
39
40/**
41 * inet_twsk_bind_unhash - unhash a timewait socket from bind hash
42 * @tw: timewait socket
43 * @hashinfo: hashinfo pointer
44 *
45 * unhash a timewait socket from bind hash, if hashed.
46 * bind hash lock must be held by caller.
47 * Returns 1 if caller should call inet_twsk_put() after lock release.
48 */
49int inet_twsk_bind_unhash(struct inet_timewait_sock *tw,
50 struct inet_hashinfo *hashinfo)
51{
52 struct inet_bind_bucket *tb = tw->tw_tb;
53
54 if (!tb)
55 return 0;
56
57 __hlist_del(&tw->tw_bind_node);
58 tw->tw_tb = NULL;
59 inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb);
60 /*
61 * We cannot call inet_twsk_put() ourself under lock,
62 * caller must call it for us.
63 */
29 return 1; 64 return 1;
30} 65}
31 66
@@ -34,7 +69,6 @@ static void __inet_twsk_kill(struct inet_timewait_sock *tw,
34 struct inet_hashinfo *hashinfo) 69 struct inet_hashinfo *hashinfo)
35{ 70{
36 struct inet_bind_hashbucket *bhead; 71 struct inet_bind_hashbucket *bhead;
37 struct inet_bind_bucket *tb;
38 int refcnt; 72 int refcnt;
39 /* Unlink from established hashes. */ 73 /* Unlink from established hashes. */
40 spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash); 74 spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash);
@@ -46,15 +80,11 @@ static void __inet_twsk_kill(struct inet_timewait_sock *tw,
46 /* Disassociate with bind bucket. */ 80 /* Disassociate with bind bucket. */
47 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num, 81 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num,
48 hashinfo->bhash_size)]; 82 hashinfo->bhash_size)];
83
49 spin_lock(&bhead->lock); 84 spin_lock(&bhead->lock);
50 tb = tw->tw_tb; 85 refcnt += inet_twsk_bind_unhash(tw, hashinfo);
51 if (tb) {
52 __hlist_del(&tw->tw_bind_node);
53 tw->tw_tb = NULL;
54 inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb);
55 refcnt++;
56 }
57 spin_unlock(&bhead->lock); 86 spin_unlock(&bhead->lock);
87
58#ifdef SOCK_REFCNT_DEBUG 88#ifdef SOCK_REFCNT_DEBUG
59 if (atomic_read(&tw->tw_refcnt) != 1) { 89 if (atomic_read(&tw->tw_refcnt) != 1) {
60 printk(KERN_DEBUG "%s timewait_sock %p refcnt=%d\n", 90 printk(KERN_DEBUG "%s timewait_sock %p refcnt=%d\n",
@@ -126,7 +156,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
126 156
127 /* 157 /*
128 * Notes : 158 * Notes :
129 * - We initially set tw_refcnt to 0 in inet_twsk_alloc() 159 * - We initially set tw_refcnt to 0 in inet_twsk_alloc()
130 * - We add one reference for the bhash link 160 * - We add one reference for the bhash link
131 * - We add one reference for the ehash link 161 * - We add one reference for the ehash link
132 * - We want this refcnt update done before allowing other 162 * - We want this refcnt update done before allowing other
@@ -136,7 +166,6 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
136 166
137 spin_unlock(lock); 167 spin_unlock(lock);
138} 168}
139
140EXPORT_SYMBOL_GPL(__inet_twsk_hashdance); 169EXPORT_SYMBOL_GPL(__inet_twsk_hashdance);
141 170
142struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int state) 171struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int state)
@@ -177,7 +206,6 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat
177 206
178 return tw; 207 return tw;
179} 208}
180
181EXPORT_SYMBOL_GPL(inet_twsk_alloc); 209EXPORT_SYMBOL_GPL(inet_twsk_alloc);
182 210
183/* Returns non-zero if quota exceeded. */ 211/* Returns non-zero if quota exceeded. */
@@ -256,7 +284,6 @@ void inet_twdr_hangman(unsigned long data)
256out: 284out:
257 spin_unlock(&twdr->death_lock); 285 spin_unlock(&twdr->death_lock);
258} 286}
259
260EXPORT_SYMBOL_GPL(inet_twdr_hangman); 287EXPORT_SYMBOL_GPL(inet_twdr_hangman);
261 288
262void inet_twdr_twkill_work(struct work_struct *work) 289void inet_twdr_twkill_work(struct work_struct *work)
@@ -287,7 +314,6 @@ void inet_twdr_twkill_work(struct work_struct *work)
287 spin_unlock_bh(&twdr->death_lock); 314 spin_unlock_bh(&twdr->death_lock);
288 } 315 }
289} 316}
290
291EXPORT_SYMBOL_GPL(inet_twdr_twkill_work); 317EXPORT_SYMBOL_GPL(inet_twdr_twkill_work);
292 318
293/* These are always called from BH context. See callers in 319/* These are always called from BH context. See callers in
@@ -307,7 +333,6 @@ void inet_twsk_deschedule(struct inet_timewait_sock *tw,
307 spin_unlock(&twdr->death_lock); 333 spin_unlock(&twdr->death_lock);
308 __inet_twsk_kill(tw, twdr->hashinfo); 334 __inet_twsk_kill(tw, twdr->hashinfo);
309} 335}
310
311EXPORT_SYMBOL(inet_twsk_deschedule); 336EXPORT_SYMBOL(inet_twsk_deschedule);
312 337
313void inet_twsk_schedule(struct inet_timewait_sock *tw, 338void inet_twsk_schedule(struct inet_timewait_sock *tw,
@@ -388,7 +413,6 @@ void inet_twsk_schedule(struct inet_timewait_sock *tw,
388 mod_timer(&twdr->tw_timer, jiffies + twdr->period); 413 mod_timer(&twdr->tw_timer, jiffies + twdr->period);
389 spin_unlock(&twdr->death_lock); 414 spin_unlock(&twdr->death_lock);
390} 415}
391
392EXPORT_SYMBOL_GPL(inet_twsk_schedule); 416EXPORT_SYMBOL_GPL(inet_twsk_schedule);
393 417
394void inet_twdr_twcal_tick(unsigned long data) 418void inet_twdr_twcal_tick(unsigned long data)
@@ -449,7 +473,6 @@ out:
449#endif 473#endif
450 spin_unlock(&twdr->death_lock); 474 spin_unlock(&twdr->death_lock);
451} 475}
452
453EXPORT_SYMBOL_GPL(inet_twdr_twcal_tick); 476EXPORT_SYMBOL_GPL(inet_twdr_twcal_tick);
454 477
455void inet_twsk_purge(struct inet_hashinfo *hashinfo, 478void inet_twsk_purge(struct inet_hashinfo *hashinfo,
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c8666b70cde0..b0a26bb25e2e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2540,11 +2540,6 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
2540 ctd.tcpct_cookie_desired = cvp->cookie_desired; 2540 ctd.tcpct_cookie_desired = cvp->cookie_desired;
2541 ctd.tcpct_s_data_desired = cvp->s_data_desired; 2541 ctd.tcpct_s_data_desired = cvp->s_data_desired;
2542 2542
2543 /* Cookie(s) saved, return as nonce */
2544 if (sizeof(ctd.tcpct_value) < cvp->cookie_pair_size) {
2545 /* impossible? */
2546 return -EINVAL;
2547 }
2548 memcpy(&ctd.tcpct_value[0], &cvp->cookie_pair[0], 2543 memcpy(&ctd.tcpct_value[0], &cvp->cookie_pair[0],
2549 cvp->cookie_pair_size); 2544 cvp->cookie_pair_size);
2550 ctd.tcpct_used = cvp->cookie_pair_size; 2545 ctd.tcpct_used = cvp->cookie_pair_size;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 57ae96a04220..12cab7d74dba 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2717,6 +2717,35 @@ static void tcp_try_undo_dsack(struct sock *sk)
2717 } 2717 }
2718} 2718}
2719 2719
2720/* We can clear retrans_stamp when there are no retransmissions in the
2721 * window. It would seem that it is trivially available for us in
2722 * tp->retrans_out, however, that kind of assumptions doesn't consider
2723 * what will happen if errors occur when sending retransmission for the
2724 * second time. ...It could the that such segment has only
2725 * TCPCB_EVER_RETRANS set at the present time. It seems that checking
2726 * the head skb is enough except for some reneging corner cases that
2727 * are not worth the effort.
2728 *
2729 * Main reason for all this complexity is the fact that connection dying
2730 * time now depends on the validity of the retrans_stamp, in particular,
2731 * that successive retransmissions of a segment must not advance
2732 * retrans_stamp under any conditions.
2733 */
2734static int tcp_any_retrans_done(struct sock *sk)
2735{
2736 struct tcp_sock *tp = tcp_sk(sk);
2737 struct sk_buff *skb;
2738
2739 if (tp->retrans_out)
2740 return 1;
2741
2742 skb = tcp_write_queue_head(sk);
2743 if (unlikely(skb && TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS))
2744 return 1;
2745
2746 return 0;
2747}
2748
2720/* Undo during fast recovery after partial ACK. */ 2749/* Undo during fast recovery after partial ACK. */
2721 2750
2722static int tcp_try_undo_partial(struct sock *sk, int acked) 2751static int tcp_try_undo_partial(struct sock *sk, int acked)
@@ -2729,7 +2758,7 @@ static int tcp_try_undo_partial(struct sock *sk, int acked)
2729 /* Plain luck! Hole if filled with delayed 2758 /* Plain luck! Hole if filled with delayed
2730 * packet, rather than with a retransmit. 2759 * packet, rather than with a retransmit.
2731 */ 2760 */
2732 if (tp->retrans_out == 0) 2761 if (!tcp_any_retrans_done(sk))
2733 tp->retrans_stamp = 0; 2762 tp->retrans_stamp = 0;
2734 2763
2735 tcp_update_reordering(sk, tcp_fackets_out(tp) + acked, 1); 2764 tcp_update_reordering(sk, tcp_fackets_out(tp) + acked, 1);
@@ -2788,7 +2817,7 @@ static void tcp_try_keep_open(struct sock *sk)
2788 struct tcp_sock *tp = tcp_sk(sk); 2817 struct tcp_sock *tp = tcp_sk(sk);
2789 int state = TCP_CA_Open; 2818 int state = TCP_CA_Open;
2790 2819
2791 if (tcp_left_out(tp) || tp->retrans_out || tp->undo_marker) 2820 if (tcp_left_out(tp) || tcp_any_retrans_done(sk) || tp->undo_marker)
2792 state = TCP_CA_Disorder; 2821 state = TCP_CA_Disorder;
2793 2822
2794 if (inet_csk(sk)->icsk_ca_state != state) { 2823 if (inet_csk(sk)->icsk_ca_state != state) {
@@ -2803,7 +2832,7 @@ static void tcp_try_to_open(struct sock *sk, int flag)
2803 2832
2804 tcp_verify_left_out(tp); 2833 tcp_verify_left_out(tp);
2805 2834
2806 if (!tp->frto_counter && tp->retrans_out == 0) 2835 if (!tp->frto_counter && !tcp_any_retrans_done(sk))
2807 tp->retrans_stamp = 0; 2836 tp->retrans_stamp = 0;
2808 2837
2809 if (flag & FLAG_ECE) 2838 if (flag & FLAG_ECE)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 29002ab26e0d..15e96030ce47 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1464,7 +1464,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1464 } 1464 }
1465#endif 1465#endif
1466 1466
1467 __inet_hash_nolisten(newsk); 1467 __inet_hash_nolisten(newsk, NULL);
1468 __inet_inherit_port(sk, newsk); 1468 __inet_inherit_port(sk, newsk);
1469 1469
1470 return newsk; 1470 return newsk;
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 8353a538cd4c..8816a20c2597 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -132,6 +132,35 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
132 } 132 }
133} 133}
134 134
135/* This function calculates a "timeout" which is equivalent to the timeout of a
136 * TCP connection after "boundary" unsucessful, exponentially backed-off
137 * retransmissions with an initial RTO of TCP_RTO_MIN.
138 */
139static bool retransmits_timed_out(struct sock *sk,
140 unsigned int boundary)
141{
142 unsigned int timeout, linear_backoff_thresh;
143 unsigned int start_ts;
144
145 if (!inet_csk(sk)->icsk_retransmits)
146 return false;
147
148 if (unlikely(!tcp_sk(sk)->retrans_stamp))
149 start_ts = TCP_SKB_CB(tcp_write_queue_head(sk))->when;
150 else
151 start_ts = tcp_sk(sk)->retrans_stamp;
152
153 linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN);
154
155 if (boundary <= linear_backoff_thresh)
156 timeout = ((2 << boundary) - 1) * TCP_RTO_MIN;
157 else
158 timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN +
159 (boundary - linear_backoff_thresh) * TCP_RTO_MAX;
160
161 return (tcp_time_stamp - start_ts) >= timeout;
162}
163
135/* A write timeout has occurred. Process the after effects. */ 164/* A write timeout has occurred. Process the after effects. */
136static int tcp_write_timeout(struct sock *sk) 165static int tcp_write_timeout(struct sock *sk)
137{ 166{
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index c813e294ec0c..633a6c266136 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -22,9 +22,10 @@
22#include <net/inet6_hashtables.h> 22#include <net/inet6_hashtables.h>
23#include <net/ip.h> 23#include <net/ip.h>
24 24
25void __inet6_hash(struct sock *sk) 25int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw)
26{ 26{
27 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; 27 struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
28 int twrefcnt = 0;
28 29
29 WARN_ON(!sk_unhashed(sk)); 30 WARN_ON(!sk_unhashed(sk));
30 31
@@ -45,10 +46,15 @@ void __inet6_hash(struct sock *sk)
45 lock = inet_ehash_lockp(hashinfo, hash); 46 lock = inet_ehash_lockp(hashinfo, hash);
46 spin_lock(lock); 47 spin_lock(lock);
47 __sk_nulls_add_node_rcu(sk, list); 48 __sk_nulls_add_node_rcu(sk, list);
49 if (tw) {
50 WARN_ON(sk->sk_hash != tw->tw_hash);
51 twrefcnt = inet_twsk_unhash(tw);
52 }
48 spin_unlock(lock); 53 spin_unlock(lock);
49 } 54 }
50 55
51 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 56 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
57 return twrefcnt;
52} 58}
53EXPORT_SYMBOL(__inet6_hash); 59EXPORT_SYMBOL(__inet6_hash);
54 60
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index aadd7cef73b3..ee9cf62458d4 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -96,7 +96,7 @@ static void tcp_v6_hash(struct sock *sk)
96 return; 96 return;
97 } 97 }
98 local_bh_disable(); 98 local_bh_disable();
99 __inet6_hash(sk); 99 __inet6_hash(sk, NULL);
100 local_bh_enable(); 100 local_bh_enable();
101 } 101 }
102} 102}
@@ -1496,7 +1496,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1496 } 1496 }
1497#endif 1497#endif
1498 1498
1499 __inet6_hash(newsk); 1499 __inet6_hash(newsk, NULL);
1500 __inet_inherit_port(sk, newsk); 1500 __inet_inherit_port(sk, newsk);
1501 1501
1502 return newsk; 1502 return newsk;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index f07c4abefe56..63843e3e576a 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -354,7 +354,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
354 sinfo->rx_packets = sta->rx_packets; 354 sinfo->rx_packets = sta->rx_packets;
355 sinfo->tx_packets = sta->tx_packets; 355 sinfo->tx_packets = sta->tx_packets;
356 356
357 if (sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) { 357 if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
358 (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
358 sinfo->filled |= STATION_INFO_SIGNAL; 359 sinfo->filled |= STATION_INFO_SIGNAL;
359 sinfo->signal = (s8)sta->last_signal; 360 sinfo->signal = (s8)sta->last_signal;
360 } 361 }
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index 63b8f86b7f16..bb677a73b7c9 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -34,9 +34,28 @@ void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband,
34 34
35 ht_cap->ht_supported = true; 35 ht_cap->ht_supported = true;
36 36
37 ht_cap->cap = le16_to_cpu(ht_cap_ie->cap_info) & sband->ht_cap.cap; 37 /*
38 ht_cap->cap &= ~IEEE80211_HT_CAP_SM_PS; 38 * The bits listed in this expression should be
39 ht_cap->cap |= sband->ht_cap.cap & IEEE80211_HT_CAP_SM_PS; 39 * the same for the peer and us, if the station
40 * advertises more then we can't use those thus
41 * we mask them out.
42 */
43 ht_cap->cap = le16_to_cpu(ht_cap_ie->cap_info) &
44 (sband->ht_cap.cap |
45 ~(IEEE80211_HT_CAP_LDPC_CODING |
46 IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
47 IEEE80211_HT_CAP_GRN_FLD |
48 IEEE80211_HT_CAP_SGI_20 |
49 IEEE80211_HT_CAP_SGI_40 |
50 IEEE80211_HT_CAP_DSSSCCK40));
51 /*
52 * The STBC bits are asymmetric -- if we don't have
53 * TX then mask out the peer's RX and vice versa.
54 */
55 if (!(sband->ht_cap.cap & IEEE80211_HT_CAP_TX_STBC))
56 ht_cap->cap &= ~IEEE80211_HT_CAP_RX_STBC;
57 if (!(sband->ht_cap.cap & IEEE80211_HT_CAP_RX_STBC))
58 ht_cap->cap &= ~IEEE80211_HT_CAP_TX_STBC;
40 59
41 ampdu_info = ht_cap_ie->ampdu_params_info; 60 ampdu_info = ht_cap_ie->ampdu_params_info;
42 ht_cap->ampdu_factor = 61 ht_cap->ampdu_factor =
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 6fb3f7181536..88b0ba6c7484 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -752,6 +752,7 @@ struct ieee80211_local {
752 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ 752 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
753 753
754 bool pspolling; 754 bool pspolling;
755 bool scan_ps_enabled;
755 /* 756 /*
756 * PS can only be enabled when we have exactly one managed 757 * PS can only be enabled when we have exactly one managed
757 * interface (and monitors) in PS, this then points there. 758 * interface (and monitors) in PS, this then points there.
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 25f52098b636..d4426748ab10 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -543,6 +543,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
543 * and we need some headroom for passing the frame to monitor 543 * and we need some headroom for passing the frame to monitor
544 * interfaces, but never both at the same time. 544 * interfaces, but never both at the same time.
545 */ 545 */
546 BUILD_BUG_ON(IEEE80211_TX_STATUS_HEADROOM !=
547 sizeof(struct ieee80211_tx_status_rtap_hdr));
546 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, 548 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
547 sizeof(struct ieee80211_tx_status_rtap_hdr)); 549 sizeof(struct ieee80211_tx_status_rtap_hdr));
548 550
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 63299b72a7b0..e0bd85e3d4b6 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -427,7 +427,7 @@ int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
427 char *addr5, char *addr6) 427 char *addr5, char *addr6)
428{ 428{
429 int aelen = 0; 429 int aelen = 0;
430 memset(meshhdr, 0, sizeof(meshhdr)); 430 memset(meshhdr, 0, sizeof(*meshhdr));
431 meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; 431 meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL;
432 put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum); 432 put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum);
433 sdata->u.mesh.mesh_seqnum++; 433 sdata->u.mesh.mesh_seqnum++;
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index 31e102541869..85562c59d7d6 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -188,8 +188,9 @@ struct mesh_rmc {
188 */ 188 */
189#define MESH_PREQ_MIN_INT 10 189#define MESH_PREQ_MIN_INT 10
190#define MESH_DIAM_TRAVERSAL_TIME 50 190#define MESH_DIAM_TRAVERSAL_TIME 50
191/* Paths will be refreshed if they are closer than PATH_REFRESH_TIME to their 191/* A path will be refreshed if it is used PATH_REFRESH_TIME milliseconds before
192 * expiration 192 * timing out. This way it will remain ACTIVE and no data frames will be
193 * unnecesarily held in the pending queue.
193 */ 194 */
194#define MESH_PATH_REFRESH_TIME 1000 195#define MESH_PATH_REFRESH_TIME 1000
195#define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME) 196#define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME)
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 664f5cc2b273..ce84237ebad3 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -937,7 +937,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
937 937
938 if (mpath->flags & MESH_PATH_ACTIVE) { 938 if (mpath->flags & MESH_PATH_ACTIVE) {
939 if (time_after(jiffies, 939 if (time_after(jiffies,
940 mpath->exp_time + 940 mpath->exp_time -
941 msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && 941 msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) &&
942 !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) && 942 !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) &&
943 !(mpath->flags & MESH_PATH_RESOLVING) && 943 !(mpath->flags & MESH_PATH_RESOLVING) &&
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 5174bfc5710d..2f9ed8b9c3f0 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -973,6 +973,14 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
973 sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | 973 sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL |
974 IEEE80211_STA_BEACON_POLL); 974 IEEE80211_STA_BEACON_POLL);
975 975
976 /*
977 * Always handle WMM once after association regardless
978 * of the first value the AP uses. Setting -1 here has
979 * that effect because the AP values is an unsigned
980 * 4-bit value.
981 */
982 sdata->u.mgd.wmm_last_param_set = -1;
983
976 ieee80211_led_assoc(local, 1); 984 ieee80211_led_assoc(local, 1);
977 985
978 sdata->vif.bss_conf.assoc = 1; 986 sdata->vif.bss_conf.assoc = 1;
@@ -1142,8 +1150,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1142 1150
1143 ieee80211_set_wmm_default(sdata); 1151 ieee80211_set_wmm_default(sdata);
1144 1152
1145 ieee80211_recalc_idle(local);
1146
1147 /* channel(_type) changes are handled by ieee80211_hw_config */ 1153 /* channel(_type) changes are handled by ieee80211_hw_config */
1148 local->oper_channel_type = NL80211_CHAN_NO_HT; 1154 local->oper_channel_type = NL80211_CHAN_NO_HT;
1149 1155
@@ -1429,6 +1435,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
1429 1435
1430 if (!wk) { 1436 if (!wk) {
1431 ieee80211_set_disassoc(sdata, true); 1437 ieee80211_set_disassoc(sdata, true);
1438 ieee80211_recalc_idle(sdata->local);
1432 } else { 1439 } else {
1433 list_del(&wk->list); 1440 list_del(&wk->list);
1434 kfree(wk); 1441 kfree(wk);
@@ -1462,6 +1469,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
1462 sdata->name, mgmt->sa, reason_code); 1469 sdata->name, mgmt->sa, reason_code);
1463 1470
1464 ieee80211_set_disassoc(sdata, false); 1471 ieee80211_set_disassoc(sdata, false);
1472 ieee80211_recalc_idle(sdata->local);
1465 return RX_MGMT_CFG80211_DISASSOC; 1473 return RX_MGMT_CFG80211_DISASSOC;
1466} 1474}
1467 1475
@@ -2164,6 +2172,7 @@ static void ieee80211_sta_work(struct work_struct *work)
2164 " after %dms, disconnecting.\n", 2172 " after %dms, disconnecting.\n",
2165 bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); 2173 bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ);
2166 ieee80211_set_disassoc(sdata, true); 2174 ieee80211_set_disassoc(sdata, true);
2175 ieee80211_recalc_idle(local);
2167 mutex_unlock(&ifmgd->mtx); 2176 mutex_unlock(&ifmgd->mtx);
2168 /* 2177 /*
2169 * must be outside lock due to cfg80211, 2178 * must be outside lock due to cfg80211,
@@ -2612,6 +2621,8 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
2612 IEEE80211_STYPE_DEAUTH, req->reason_code, 2621 IEEE80211_STYPE_DEAUTH, req->reason_code,
2613 cookie); 2622 cookie);
2614 2623
2624 ieee80211_recalc_idle(sdata->local);
2625
2615 return 0; 2626 return 0;
2616} 2627}
2617 2628
@@ -2644,5 +2655,8 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
2644 ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, 2655 ieee80211_send_deauth_disassoc(sdata, req->bss->bssid,
2645 IEEE80211_STYPE_DISASSOC, req->reason_code, 2656 IEEE80211_STYPE_DISASSOC, req->reason_code,
2646 cookie); 2657 cookie);
2658
2659 ieee80211_recalc_idle(sdata->local);
2660
2647 return 0; 2661 return 0;
2648} 2662}
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index a182e423109b..6cbf1a7b3157 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1631,7 +1631,6 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1631 mpp_path_add(proxied_addr, mpp_addr, sdata); 1631 mpp_path_add(proxied_addr, mpp_addr, sdata);
1632 } else { 1632 } else {
1633 spin_lock_bh(&mppath->state_lock); 1633 spin_lock_bh(&mppath->state_lock);
1634 mppath->exp_time = jiffies;
1635 if (compare_ether_addr(mppath->mpp, mpp_addr) != 0) 1634 if (compare_ether_addr(mppath->mpp, mpp_addr) != 0)
1636 memcpy(mppath->mpp, mpp_addr, ETH_ALEN); 1635 memcpy(mppath->mpp, mpp_addr, ETH_ALEN);
1637 spin_unlock_bh(&mppath->state_lock); 1636 spin_unlock_bh(&mppath->state_lock);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index d3381ba5f457..66da0ab1d8fa 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -227,7 +227,8 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
227static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata) 227static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata)
228{ 228{
229 struct ieee80211_local *local = sdata->local; 229 struct ieee80211_local *local = sdata->local;
230 bool ps = false; 230
231 local->scan_ps_enabled = false;
231 232
232 /* FIXME: what to do when local->pspolling is true? */ 233 /* FIXME: what to do when local->pspolling is true? */
233 234
@@ -235,12 +236,13 @@ static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata)
235 cancel_work_sync(&local->dynamic_ps_enable_work); 236 cancel_work_sync(&local->dynamic_ps_enable_work);
236 237
237 if (local->hw.conf.flags & IEEE80211_CONF_PS) { 238 if (local->hw.conf.flags & IEEE80211_CONF_PS) {
238 ps = true; 239 local->scan_ps_enabled = true;
239 local->hw.conf.flags &= ~IEEE80211_CONF_PS; 240 local->hw.conf.flags &= ~IEEE80211_CONF_PS;
240 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 241 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
241 } 242 }
242 243
243 if (!ps || !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) 244 if (!(local->scan_ps_enabled) ||
245 !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
244 /* 246 /*
245 * If power save was enabled, no need to send a nullfunc 247 * If power save was enabled, no need to send a nullfunc
246 * frame because AP knows that we are sleeping. But if the 248 * frame because AP knows that we are sleeping. But if the
@@ -261,7 +263,7 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata)
261 263
262 if (!local->ps_sdata) 264 if (!local->ps_sdata)
263 ieee80211_send_nullfunc(local, sdata, 0); 265 ieee80211_send_nullfunc(local, sdata, 0);
264 else { 266 else if (local->scan_ps_enabled) {
265 /* 267 /*
266 * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware 268 * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware
267 * will send a nullfunc frame with the powersave bit set 269 * will send a nullfunc frame with the powersave bit set
@@ -277,6 +279,16 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata)
277 */ 279 */
278 local->hw.conf.flags |= IEEE80211_CONF_PS; 280 local->hw.conf.flags |= IEEE80211_CONF_PS;
279 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); 281 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
282 } else if (local->hw.conf.dynamic_ps_timeout > 0) {
283 /*
284 * If IEEE80211_CONF_PS was not set and the dynamic_ps_timer
285 * had been running before leaving the operating channel,
286 * restart the timer now and send a nullfunc frame to inform
287 * the AP that we are awake.
288 */
289 ieee80211_send_nullfunc(local, sdata, 0);
290 mod_timer(&local->dynamic_ps_timer, jiffies +
291 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
280 } 292 }
281} 293}
282 294
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index acb6626ad0a4..b01972579c7c 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -579,7 +579,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
579 if (elen > left) 579 if (elen > left)
580 break; 580 break;
581 581
582 if (calc_crc && id < 64 && (filter & BIT(id))) 582 if (calc_crc && id < 64 && (filter & (1ULL << id)))
583 crc = crc32_be(crc, pos - 2, elen + 2); 583 crc = crc32_be(crc, pos - 2, elen + 2);
584 584
585 switch (id) { 585 switch (id) {
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 448e5a0fcc2e..c218e07e5caf 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -579,6 +579,8 @@ static ssize_t rfkill_name_show(struct device *dev,
579 579
580static const char *rfkill_get_type_str(enum rfkill_type type) 580static const char *rfkill_get_type_str(enum rfkill_type type)
581{ 581{
582 BUILD_BUG_ON(NUM_RFKILL_TYPES != RFKILL_TYPE_FM + 1);
583
582 switch (type) { 584 switch (type) {
583 case RFKILL_TYPE_WLAN: 585 case RFKILL_TYPE_WLAN:
584 return "wlan"; 586 return "wlan";
@@ -597,8 +599,6 @@ static const char *rfkill_get_type_str(enum rfkill_type type)
597 default: 599 default:
598 BUG(); 600 BUG();
599 } 601 }
600
601 BUILD_BUG_ON(NUM_RFKILL_TYPES != RFKILL_TYPE_FM + 1);
602} 602}
603 603
604static ssize_t rfkill_type_show(struct device *dev, 604static ssize_t rfkill_type_show(struct device *dev,
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 65f86264f7bb..dc13c3ffeca6 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -142,62 +142,35 @@ static const struct ieee80211_regdomain us_regdom = {
142 .reg_rules = { 142 .reg_rules = {
143 /* IEEE 802.11b/g, channels 1..11 */ 143 /* IEEE 802.11b/g, channels 1..11 */
144 REG_RULE(2412-10, 2462+10, 40, 6, 27, 0), 144 REG_RULE(2412-10, 2462+10, 40, 6, 27, 0),
145 /* IEEE 802.11a, channel 36 */ 145 /* IEEE 802.11a, channel 36..48 */
146 REG_RULE(5180-10, 5180+10, 40, 6, 23, 0), 146 REG_RULE(5180-10, 5240+10, 40, 6, 17, 0),
147 /* IEEE 802.11a, channel 40 */
148 REG_RULE(5200-10, 5200+10, 40, 6, 23, 0),
149 /* IEEE 802.11a, channel 44 */
150 REG_RULE(5220-10, 5220+10, 40, 6, 23, 0),
151 /* IEEE 802.11a, channels 48..64 */ 147 /* IEEE 802.11a, channels 48..64 */
152 REG_RULE(5240-10, 5320+10, 40, 6, 23, 0), 148 REG_RULE(5260-10, 5320+10, 40, 6, 20, NL80211_RRF_DFS),
149 /* IEEE 802.11a, channels 100..124 */
150 REG_RULE(5500-10, 5590+10, 40, 6, 20, NL80211_RRF_DFS),
151 /* IEEE 802.11a, channels 132..144 */
152 REG_RULE(5660-10, 5700+10, 40, 6, 20, NL80211_RRF_DFS),
153 /* IEEE 802.11a, channels 149..165, outdoor */ 153 /* IEEE 802.11a, channels 149..165, outdoor */
154 REG_RULE(5745-10, 5825+10, 40, 6, 30, 0), 154 REG_RULE(5745-10, 5825+10, 40, 6, 30, 0),
155 } 155 }
156}; 156};
157 157
158static const struct ieee80211_regdomain jp_regdom = { 158static const struct ieee80211_regdomain jp_regdom = {
159 .n_reg_rules = 3, 159 .n_reg_rules = 6,
160 .alpha2 = "JP", 160 .alpha2 = "JP",
161 .reg_rules = { 161 .reg_rules = {
162 /* IEEE 802.11b/g, channels 1..14 */ 162 /* IEEE 802.11b/g, channels 1..11 */
163 REG_RULE(2412-10, 2484+10, 40, 6, 20, 0), 163 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
164 /* IEEE 802.11a, channels 34..48 */ 164 /* IEEE 802.11b/g, channels 12..13 */
165 REG_RULE(5170-10, 5240+10, 40, 6, 20, 165 REG_RULE(2467-10, 2472+10, 20, 6, 20, 0),
166 NL80211_RRF_PASSIVE_SCAN), 166 /* IEEE 802.11b/g, channel 14 */
167 REG_RULE(2484-10, 2484+10, 20, 6, 20, NL80211_RRF_NO_OFDM),
168 /* IEEE 802.11a, channels 36..48 */
169 REG_RULE(5180-10, 5240+10, 40, 6, 20, 0),
167 /* IEEE 802.11a, channels 52..64 */ 170 /* IEEE 802.11a, channels 52..64 */
168 REG_RULE(5260-10, 5320+10, 40, 6, 20, 171 REG_RULE(5260-10, 5320+10, 40, 6, 20, NL80211_RRF_DFS),
169 NL80211_RRF_NO_IBSS | 172 /* IEEE 802.11a, channels 100..144 */
170 NL80211_RRF_DFS), 173 REG_RULE(5500-10, 5700+10, 40, 6, 23, NL80211_RRF_DFS),
171 }
172};
173
174static const struct ieee80211_regdomain eu_regdom = {
175 .n_reg_rules = 6,
176 /*
177 * This alpha2 is bogus, we leave it here just for stupid
178 * backward compatibility
179 */
180 .alpha2 = "EU",
181 .reg_rules = {
182 /* IEEE 802.11b/g, channels 1..13 */
183 REG_RULE(2412-10, 2472+10, 40, 6, 20, 0),
184 /* IEEE 802.11a, channel 36 */
185 REG_RULE(5180-10, 5180+10, 40, 6, 23,
186 NL80211_RRF_PASSIVE_SCAN),
187 /* IEEE 802.11a, channel 40 */
188 REG_RULE(5200-10, 5200+10, 40, 6, 23,
189 NL80211_RRF_PASSIVE_SCAN),
190 /* IEEE 802.11a, channel 44 */
191 REG_RULE(5220-10, 5220+10, 40, 6, 23,
192 NL80211_RRF_PASSIVE_SCAN),
193 /* IEEE 802.11a, channels 48..64 */
194 REG_RULE(5240-10, 5320+10, 40, 6, 20,
195 NL80211_RRF_NO_IBSS |
196 NL80211_RRF_DFS),
197 /* IEEE 802.11a, channels 100..140 */
198 REG_RULE(5500-10, 5700+10, 40, 6, 30,
199 NL80211_RRF_NO_IBSS |
200 NL80211_RRF_DFS),
201 } 174 }
202}; 175};
203 176
@@ -207,15 +180,17 @@ static const struct ieee80211_regdomain *static_regdom(char *alpha2)
207 return &us_regdom; 180 return &us_regdom;
208 if (alpha2[0] == 'J' && alpha2[1] == 'P') 181 if (alpha2[0] == 'J' && alpha2[1] == 'P')
209 return &jp_regdom; 182 return &jp_regdom;
183 /* Use world roaming rules for "EU", since it was a pseudo
184 domain anyway... */
210 if (alpha2[0] == 'E' && alpha2[1] == 'U') 185 if (alpha2[0] == 'E' && alpha2[1] == 'U')
211 return &eu_regdom; 186 return &world_regdom;
212 /* Default, as per the old rules */ 187 /* Default, world roaming rules */
213 return &us_regdom; 188 return &world_regdom;
214} 189}
215 190
216static bool is_old_static_regdom(const struct ieee80211_regdomain *rd) 191static bool is_old_static_regdom(const struct ieee80211_regdomain *rd)
217{ 192{
218 if (rd == &us_regdom || rd == &jp_regdom || rd == &eu_regdom) 193 if (rd == &us_regdom || rd == &jp_regdom || rd == &world_regdom)
219 return true; 194 return true;
220 return false; 195 return false;
221} 196}
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 2fa8de1140e9..4198243a3dff 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -479,6 +479,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
479 } 479 }
480 err = rdev->ops->del_key(&rdev->wiphy, dev, idx, addr); 480 err = rdev->ops->del_key(&rdev->wiphy, dev, idx, addr);
481 } 481 }
482 wdev->wext.connect.privacy = false;
482 /* 483 /*
483 * Applications using wireless extensions expect to be 484 * Applications using wireless extensions expect to be
484 * able to delete keys that don't exist, so allow that. 485 * able to delete keys that don't exist, so allow that.