aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/isdn/README.gigaset116
-rw-r--r--MAINTAINERS7
-rw-r--r--drivers/atm/he.c4
-rw-r--r--drivers/atm/iphase.c2
-rw-r--r--drivers/isdn/gigaset/common.c2
-rw-r--r--drivers/net/Kconfig1
-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/benet/be_main.c4
-rw-r--r--drivers/net/bonding/bond_3ad.c171
-rw-r--r--drivers/net/bonding/bond_alb.c38
-rw-r--r--drivers/net/bonding/bond_ipv6.c12
-rw-r--r--drivers/net/bonding/bond_main.c607
-rw-r--r--drivers/net/bonding/bond_sysfs.c327
-rw-r--r--drivers/net/can/Kconfig11
-rw-r--r--drivers/net/can/Makefile1
-rw-r--r--drivers/net/can/at91_can.c2
-rw-r--r--drivers/net/can/bfin_can.c783
-rw-r--r--drivers/net/can/mcp251x.c13
-rw-r--r--drivers/net/can/mscan/mscan.c3
-rw-r--r--drivers/net/can/sja1000/sja1000.c18
-rw-r--r--drivers/net/can/ti_hecc.c2
-rw-r--r--drivers/net/can/usb/ems_usb.c2
-rw-r--r--drivers/net/cnic.c11
-rw-r--r--drivers/net/cpmac.c2
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c1
-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/igb/igb_main.c22
-rw-r--r--drivers/net/igbvf/igbvf.h1
-rw-r--r--drivers/net/igbvf/netdev.c8
-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/mlx4/sense.c2
-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/pcmcia/3c574_cs.c4
-rw-r--r--drivers/net/pcmcia/3c589_cs.c4
-rw-r--r--drivers/net/sfc/selftest.c2
-rw-r--r--drivers/net/sky2.c16
-rw-r--r--drivers/net/smc91x.c8
-rw-r--r--drivers/net/usb/kaweth.c4
-rw-r--r--drivers/net/usb/rtl8150.c2
-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/xmit.c2
-rw-r--r--drivers/net/wireless/b43/main.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.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/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/can/dev.h9
-rw-r--r--include/linux/gigaset_dev.h22
-rw-r--r--include/linux/if_ether.h2
-rw-r--r--include/linux/rtnetlink.h6
-rw-r--r--include/net/compat.h2
-rw-r--r--include/net/dst.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/tcp.h26
-rw-r--r--net/atm/br2684.c11
-rw-r--r--net/atm/lec.c10
-rw-r--r--net/compat.c11
-rw-r--r--net/core/dev.c21
-rw-r--r--net/core/rtnetlink.c6
-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/syncookies.c27
-rw-r--r--net/ipv4/tcp.c5
-rw-r--r--net/ipv4/tcp_input.c59
-rw-r--r--net/ipv4/tcp_ipv4.c23
-rw-r--r--net/ipv4/tcp_minisocks.c10
-rw-r--r--net/ipv4/tcp_output.c18
-rw-r--r--net/ipv4/tcp_timer.c29
-rw-r--r--net/ipv4/udp.c7
-rw-r--r--net/ipv6/inet6_hashtables.c8
-rw-r--r--net/ipv6/syncookies.c28
-rw-r--r--net/ipv6/tcp_ipv6.c7
-rw-r--r--net/key/af_key.c1
-rw-r--r--net/mac80211/cfg.c3
-rw-r--r--net/mac80211/ieee80211_i.h1
-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.c10
-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
109 files changed, 2280 insertions, 1431 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/MAINTAINERS b/MAINTAINERS
index 520a3b3fd82c..256139e0c231 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5426,10 +5426,9 @@ S: Supported
5426F: drivers/block/ub.c 5426F: drivers/block/ub.c
5427 5427
5428USB CDC ETHERNET DRIVER 5428USB CDC ETHERNET DRIVER
5429M: Greg Kroah-Hartman <greg@kroah.com> 5429M: Oliver Neukum <oliver@neukum.name>
5430L: linux-usb@vger.kernel.org 5430L: linux-usb@vger.kernel.org
5431S: Maintained 5431S: Maintained
5432W: http://www.kroah.com/linux-usb/
5433F: drivers/net/usb/cdc_*.c 5432F: drivers/net/usb/cdc_*.c
5434F: include/linux/usb/cdc.h 5433F: include/linux/usb/cdc.h
5435 5434
@@ -5960,9 +5959,9 @@ F: sound/soc/codecs/wm8350.c
5960F: sound/soc/codecs/wm8400.c 5959F: sound/soc/codecs/wm8400.c
5961 5960
5962X.25 NETWORK LAYER 5961X.25 NETWORK LAYER
5963M: Henner Eisen <eis@baty.hanse.de> 5962M: Andrew Hendry <andrew.hendry@gmail.com>
5964L: linux-x25@vger.kernel.org 5963L: linux-x25@vger.kernel.org
5965S: Maintained 5964S: Odd Fixes
5966F: Documentation/networking/x25* 5965F: Documentation/networking/x25*
5967F: include/net/x25* 5966F: include/net/x25*
5968F: net/x25/ 5967F: net/x25/
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/atm/iphase.c b/drivers/atm/iphase.c
index f734b345ac71..25a4c86f839b 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -557,7 +557,7 @@ static int ia_cbr_setup (IADEV *dev, struct atm_vcc *vcc) {
557 memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC)); 557 memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC));
558 } /* while */ 558 } /* while */
559 // Move this VCI number into this location of the CBR Sched table. 559 // Move this VCI number into this location of the CBR Sched table.
560 memcpy((caddr_t)TstSchedTbl, (caddr_t)&vcIndex,sizeof(TstSchedTbl)); 560 memcpy((caddr_t)TstSchedTbl, (caddr_t)&vcIndex, sizeof(*TstSchedTbl));
561 dev->CbrRemEntries--; 561 dev->CbrRemEntries--;
562 toBeAssigned--; 562 toBeAssigned--;
563 } /* while */ 563 } /* while */
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..a5be9ac6405c 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2696,6 +2696,7 @@ config NETXEN_NIC
2696config NIU 2696config NIU
2697 tristate "Sun Neptune 10Gbit Ethernet support" 2697 tristate "Sun Neptune 10Gbit Ethernet support"
2698 depends on PCI 2698 depends on PCI
2699 select CRC32
2699 help 2700 help
2700 This enables support for cards based upon Sun's 2701 This enables support for cards based upon Sun's
2701 Neptune chipset. 2702 Neptune chipset.
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 6eb9241cee0a..2f4be59b9c0b 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/benet/be_main.c b/drivers/net/benet/be_main.c
index 24c7d9900baa..3a1f7902c16d 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -759,7 +759,7 @@ static void be_rx_compl_process(struct be_adapter *adapter,
759 759
760 /* vlanf could be wrongly set in some cards. 760 /* vlanf could be wrongly set in some cards.
761 * ignore if vtm is not set */ 761 * ignore if vtm is not set */
762 if ((adapter->cap == 0x400) && !vtm) 762 if ((adapter->cap & 0x400) && !vtm)
763 vlanf = 0; 763 vlanf = 0;
764 764
765 skb = netdev_alloc_skb_ip_align(adapter->netdev, BE_HDR_LEN); 765 skb = netdev_alloc_skb_ip_align(adapter->netdev, BE_HDR_LEN);
@@ -816,7 +816,7 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter,
816 816
817 /* vlanf could be wrongly set in some cards. 817 /* vlanf could be wrongly set in some cards.
818 * ignore if vtm is not set */ 818 * ignore if vtm is not set */
819 if ((adapter->cap == 0x400) && !vtm) 819 if ((adapter->cap & 0x400) && !vtm)
820 vlanf = 0; 820 vlanf = 0;
821 821
822 skb = napi_get_frags(&eq_obj->napi); 822 skb = napi_get_frags(&eq_obj->napi);
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index d69e6838f21e..0fb7a4964e75 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -20,6 +20,8 @@
20 * 20 *
21 */ 21 */
22 22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
23#include <linux/skbuff.h> 25#include <linux/skbuff.h>
24#include <linux/if_ether.h> 26#include <linux/if_ether.h>
25#include <linux/netdevice.h> 27#include <linux/netdevice.h>
@@ -352,7 +354,8 @@ static u16 __get_link_speed(struct port *port)
352 } 354 }
353 } 355 }
354 356
355 pr_debug("Port %d Received link speed %d update from adapter\n", port->actor_port_number, speed); 357 pr_debug("Port %d Received link speed %d update from adapter\n",
358 port->actor_port_number, speed);
356 return speed; 359 return speed;
357} 360}
358 361
@@ -378,12 +381,14 @@ static u8 __get_duplex(struct port *port)
378 switch (slave->duplex) { 381 switch (slave->duplex) {
379 case DUPLEX_FULL: 382 case DUPLEX_FULL:
380 retval=0x1; 383 retval=0x1;
381 pr_debug("Port %d Received status full duplex update from adapter\n", port->actor_port_number); 384 pr_debug("Port %d Received status full duplex update from adapter\n",
385 port->actor_port_number);
382 break; 386 break;
383 case DUPLEX_HALF: 387 case DUPLEX_HALF:
384 default: 388 default:
385 retval=0x0; 389 retval=0x0;
386 pr_debug("Port %d Received status NOT full duplex update from adapter\n", port->actor_port_number); 390 pr_debug("Port %d Received status NOT full duplex update from adapter\n",
391 port->actor_port_number);
387 break; 392 break;
388 } 393 }
389 } 394 }
@@ -980,7 +985,9 @@ static void ad_mux_machine(struct port *port)
980 985
981 // check if the state machine was changed 986 // check if the state machine was changed
982 if (port->sm_mux_state != last_state) { 987 if (port->sm_mux_state != last_state) {
983 pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_mux_state); 988 pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n",
989 port->actor_port_number, last_state,
990 port->sm_mux_state);
984 switch (port->sm_mux_state) { 991 switch (port->sm_mux_state) {
985 case AD_MUX_DETACHED: 992 case AD_MUX_DETACHED:
986 __detach_bond_from_agg(port); 993 __detach_bond_from_agg(port);
@@ -1079,7 +1086,9 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1079 1086
1080 // check if the State machine was changed or new lacpdu arrived 1087 // check if the State machine was changed or new lacpdu arrived
1081 if ((port->sm_rx_state != last_state) || (lacpdu)) { 1088 if ((port->sm_rx_state != last_state) || (lacpdu)) {
1082 pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_rx_state); 1089 pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n",
1090 port->actor_port_number, last_state,
1091 port->sm_rx_state);
1083 switch (port->sm_rx_state) { 1092 switch (port->sm_rx_state) {
1084 case AD_RX_INITIALIZE: 1093 case AD_RX_INITIALIZE:
1085 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) { 1094 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) {
@@ -1126,9 +1135,8 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1126 // detect loopback situation 1135 // detect loopback situation
1127 if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { 1136 if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
1128 // INFO_RECEIVED_LOOPBACK_FRAMES 1137 // INFO_RECEIVED_LOOPBACK_FRAMES
1129 pr_err(DRV_NAME ": %s: An illegal loopback occurred on " 1138 pr_err("%s: An illegal loopback occurred on adapter (%s).\n"
1130 "adapter (%s). Check the configuration to verify that all " 1139 "Check the configuration to verify that all adapters are connected to 802.3ad compliant switch ports\n",
1131 "Adapters are connected to 802.3ad compliant switch ports\n",
1132 port->slave->dev->master->name, port->slave->dev->name); 1140 port->slave->dev->master->name, port->slave->dev->name);
1133 __release_rx_machine_lock(port); 1141 __release_rx_machine_lock(port);
1134 return; 1142 return;
@@ -1166,7 +1174,8 @@ static void ad_tx_machine(struct port *port)
1166 __update_lacpdu_from_port(port); 1174 __update_lacpdu_from_port(port);
1167 1175
1168 if (ad_lacpdu_send(port) >= 0) { 1176 if (ad_lacpdu_send(port) >= 0) {
1169 pr_debug("Sent LACPDU on port %d\n", port->actor_port_number); 1177 pr_debug("Sent LACPDU on port %d\n",
1178 port->actor_port_number);
1170 1179
1171 /* mark ntt as false, so it will not be sent again until 1180 /* mark ntt as false, so it will not be sent again until
1172 demanded */ 1181 demanded */
@@ -1241,7 +1250,9 @@ static void ad_periodic_machine(struct port *port)
1241 1250
1242 // check if the state machine was changed 1251 // check if the state machine was changed
1243 if (port->sm_periodic_state != last_state) { 1252 if (port->sm_periodic_state != last_state) {
1244 pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_periodic_state); 1253 pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n",
1254 port->actor_port_number, last_state,
1255 port->sm_periodic_state);
1245 switch (port->sm_periodic_state) { 1256 switch (port->sm_periodic_state) {
1246 case AD_NO_PERIODIC: 1257 case AD_NO_PERIODIC:
1247 port->sm_periodic_timer_counter = 0; // zero timer 1258 port->sm_periodic_timer_counter = 0; // zero timer
@@ -1298,7 +1309,9 @@ static void ad_port_selection_logic(struct port *port)
1298 port->next_port_in_aggregator=NULL; 1309 port->next_port_in_aggregator=NULL;
1299 port->actor_port_aggregator_identifier=0; 1310 port->actor_port_aggregator_identifier=0;
1300 1311
1301 pr_debug("Port %d left LAG %d\n", port->actor_port_number, temp_aggregator->aggregator_identifier); 1312 pr_debug("Port %d left LAG %d\n",
1313 port->actor_port_number,
1314 temp_aggregator->aggregator_identifier);
1302 // if the aggregator is empty, clear its parameters, and set it ready to be attached 1315 // if the aggregator is empty, clear its parameters, and set it ready to be attached
1303 if (!temp_aggregator->lag_ports) { 1316 if (!temp_aggregator->lag_ports) {
1304 ad_clear_agg(temp_aggregator); 1317 ad_clear_agg(temp_aggregator);
@@ -1307,9 +1320,7 @@ static void ad_port_selection_logic(struct port *port)
1307 } 1320 }
1308 } 1321 }
1309 if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list 1322 if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
1310 pr_warning(DRV_NAME ": %s: Warning: Port %d (on %s) " 1323 pr_warning("%s: Warning: Port %d (on %s) was related to aggregator %d but was not on its port list\n",
1311 "was related to aggregator %d but was not "
1312 "on its port list\n",
1313 port->slave->dev->master->name, 1324 port->slave->dev->master->name,
1314 port->actor_port_number, 1325 port->actor_port_number,
1315 port->slave->dev->name, 1326 port->slave->dev->name,
@@ -1343,7 +1354,9 @@ static void ad_port_selection_logic(struct port *port)
1343 port->next_port_in_aggregator=aggregator->lag_ports; 1354 port->next_port_in_aggregator=aggregator->lag_ports;
1344 port->aggregator->num_of_ports++; 1355 port->aggregator->num_of_ports++;
1345 aggregator->lag_ports=port; 1356 aggregator->lag_ports=port;
1346 pr_debug("Port %d joined LAG %d(existing LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1357 pr_debug("Port %d joined LAG %d(existing LAG)\n",
1358 port->actor_port_number,
1359 port->aggregator->aggregator_identifier);
1347 1360
1348 // mark this port as selected 1361 // mark this port as selected
1349 port->sm_vars |= AD_PORT_SELECTED; 1362 port->sm_vars |= AD_PORT_SELECTED;
@@ -1380,10 +1393,11 @@ static void ad_port_selection_logic(struct port *port)
1380 // mark this port as selected 1393 // mark this port as selected
1381 port->sm_vars |= AD_PORT_SELECTED; 1394 port->sm_vars |= AD_PORT_SELECTED;
1382 1395
1383 pr_debug("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1396 pr_debug("Port %d joined LAG %d(new LAG)\n",
1397 port->actor_port_number,
1398 port->aggregator->aggregator_identifier);
1384 } else { 1399 } else {
1385 pr_err(DRV_NAME ": %s: Port %d (on %s) did not find " 1400 pr_err("%s: Port %d (on %s) did not find a suitable aggregator\n",
1386 "a suitable aggregator\n",
1387 port->slave->dev->master->name, 1401 port->slave->dev->master->name,
1388 port->actor_port_number, port->slave->dev->name); 1402 port->actor_port_number, port->slave->dev->name);
1389 } 1403 }
@@ -1460,8 +1474,7 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
1460 break; 1474 break;
1461 1475
1462 default: 1476 default:
1463 pr_warning(DRV_NAME 1477 pr_warning("%s: Impossible agg select mode %d\n",
1464 ": %s: Impossible agg select mode %d\n",
1465 curr->slave->dev->master->name, 1478 curr->slave->dev->master->name,
1466 __get_agg_selection_mode(curr->lag_ports)); 1479 __get_agg_selection_mode(curr->lag_ports));
1467 break; 1480 break;
@@ -1546,40 +1559,38 @@ static void ad_agg_selection_logic(struct aggregator *agg)
1546 // if there is new best aggregator, activate it 1559 // if there is new best aggregator, activate it
1547 if (best) { 1560 if (best) {
1548 pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", 1561 pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1549 best->aggregator_identifier, best->num_of_ports, 1562 best->aggregator_identifier, best->num_of_ports,
1550 best->actor_oper_aggregator_key, 1563 best->actor_oper_aggregator_key,
1551 best->partner_oper_aggregator_key, 1564 best->partner_oper_aggregator_key,
1552 best->is_individual, best->is_active); 1565 best->is_individual, best->is_active);
1553 pr_debug("best ports %p slave %p %s\n", 1566 pr_debug("best ports %p slave %p %s\n",
1554 best->lag_ports, best->slave, 1567 best->lag_ports, best->slave,
1555 best->slave ? best->slave->dev->name : "NULL"); 1568 best->slave ? best->slave->dev->name : "NULL");
1556 1569
1557 for (agg = __get_first_agg(best->lag_ports); agg; 1570 for (agg = __get_first_agg(best->lag_ports); agg;
1558 agg = __get_next_agg(agg)) { 1571 agg = __get_next_agg(agg)) {
1559 1572
1560 pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", 1573 pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1561 agg->aggregator_identifier, agg->num_of_ports, 1574 agg->aggregator_identifier, agg->num_of_ports,
1562 agg->actor_oper_aggregator_key, 1575 agg->actor_oper_aggregator_key,
1563 agg->partner_oper_aggregator_key, 1576 agg->partner_oper_aggregator_key,
1564 agg->is_individual, agg->is_active); 1577 agg->is_individual, agg->is_active);
1565 } 1578 }
1566 1579
1567 // check if any partner replys 1580 // check if any partner replys
1568 if (best->is_individual) { 1581 if (best->is_individual) {
1569 pr_warning(DRV_NAME ": %s: Warning: No 802.3ad" 1582 pr_warning("%s: Warning: No 802.3ad response from the link partner for any adapters in the bond\n",
1570 " response from the link partner for any" 1583 best->slave->dev->master->name);
1571 " adapters in the bond\n",
1572 best->slave->dev->master->name);
1573 } 1584 }
1574 1585
1575 best->is_active = 1; 1586 best->is_active = 1;
1576 pr_debug("LAG %d chosen as the active LAG\n", 1587 pr_debug("LAG %d chosen as the active LAG\n",
1577 best->aggregator_identifier); 1588 best->aggregator_identifier);
1578 pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", 1589 pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1579 best->aggregator_identifier, best->num_of_ports, 1590 best->aggregator_identifier, best->num_of_ports,
1580 best->actor_oper_aggregator_key, 1591 best->actor_oper_aggregator_key,
1581 best->partner_oper_aggregator_key, 1592 best->partner_oper_aggregator_key,
1582 best->is_individual, best->is_active); 1593 best->is_individual, best->is_active);
1583 1594
1584 // disable the ports that were related to the former active_aggregator 1595 // disable the ports that were related to the former active_aggregator
1585 if (active) { 1596 if (active) {
@@ -1633,7 +1644,8 @@ static void ad_clear_agg(struct aggregator *aggregator)
1633 aggregator->lag_ports = NULL; 1644 aggregator->lag_ports = NULL;
1634 aggregator->is_active = 0; 1645 aggregator->is_active = 0;
1635 aggregator->num_of_ports = 0; 1646 aggregator->num_of_ports = 0;
1636 pr_debug("LAG %d was cleared\n", aggregator->aggregator_identifier); 1647 pr_debug("LAG %d was cleared\n",
1648 aggregator->aggregator_identifier);
1637 } 1649 }
1638} 1650}
1639 1651
@@ -1728,7 +1740,9 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
1728static void ad_enable_collecting_distributing(struct port *port) 1740static void ad_enable_collecting_distributing(struct port *port)
1729{ 1741{
1730 if (port->aggregator->is_active) { 1742 if (port->aggregator->is_active) {
1731 pr_debug("Enabling port %d(LAG %d)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1743 pr_debug("Enabling port %d(LAG %d)\n",
1744 port->actor_port_number,
1745 port->aggregator->aggregator_identifier);
1732 __enable_port(port); 1746 __enable_port(port);
1733 } 1747 }
1734} 1748}
@@ -1741,7 +1755,9 @@ static void ad_enable_collecting_distributing(struct port *port)
1741static void ad_disable_collecting_distributing(struct port *port) 1755static void ad_disable_collecting_distributing(struct port *port)
1742{ 1756{
1743 if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) { 1757 if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) {
1744 pr_debug("Disabling port %d(LAG %d)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1758 pr_debug("Disabling port %d(LAG %d)\n",
1759 port->actor_port_number,
1760 port->aggregator->aggregator_identifier);
1745 __disable_port(port); 1761 __disable_port(port);
1746 } 1762 }
1747} 1763}
@@ -1779,7 +1795,8 @@ static void ad_marker_info_send(struct port *port)
1779 1795
1780 // send the marker information 1796 // send the marker information
1781 if (ad_marker_send(port, &marker) >= 0) { 1797 if (ad_marker_send(port, &marker) >= 0) {
1782 pr_debug("Sent Marker Information on port %d\n", port->actor_port_number); 1798 pr_debug("Sent Marker Information on port %d\n",
1799 port->actor_port_number);
1783 } 1800 }
1784} 1801}
1785#endif 1802#endif
@@ -1803,7 +1820,8 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
1803 // send the marker response 1820 // send the marker response
1804 1821
1805 if (ad_marker_send(port, &marker) >= 0) { 1822 if (ad_marker_send(port, &marker) >= 0) {
1806 pr_debug("Sent Marker Response on port %d\n", port->actor_port_number); 1823 pr_debug("Sent Marker Response on port %d\n",
1824 port->actor_port_number);
1807 } 1825 }
1808} 1826}
1809 1827
@@ -1889,8 +1907,7 @@ int bond_3ad_bind_slave(struct slave *slave)
1889 struct aggregator *aggregator; 1907 struct aggregator *aggregator;
1890 1908
1891 if (bond == NULL) { 1909 if (bond == NULL) {
1892 pr_err(DRV_NAME ": %s: The slave %s is not attached to " 1910 pr_err("%s: The slave %s is not attached to its bond\n",
1893 "its bond\n",
1894 slave->dev->master->name, slave->dev->name); 1911 slave->dev->master->name, slave->dev->name);
1895 return -1; 1912 return -1;
1896 } 1913 }
@@ -1966,13 +1983,13 @@ void bond_3ad_unbind_slave(struct slave *slave)
1966 1983
1967 // if slave is null, the whole port is not initialized 1984 // if slave is null, the whole port is not initialized
1968 if (!port->slave) { 1985 if (!port->slave) {
1969 pr_warning(DRV_NAME ": Warning: %s: Trying to " 1986 pr_warning("Warning: %s: Trying to unbind an uninitialized port on %s\n",
1970 "unbind an uninitialized port on %s\n",
1971 slave->dev->master->name, slave->dev->name); 1987 slave->dev->master->name, slave->dev->name);
1972 return; 1988 return;
1973 } 1989 }
1974 1990
1975 pr_debug("Unbinding Link Aggregation Group %d\n", aggregator->aggregator_identifier); 1991 pr_debug("Unbinding Link Aggregation Group %d\n",
1992 aggregator->aggregator_identifier);
1976 1993
1977 /* Tell the partner that this port is not suitable for aggregation */ 1994 /* Tell the partner that this port is not suitable for aggregation */
1978 port->actor_oper_port_state &= ~AD_STATE_AGGREGATION; 1995 port->actor_oper_port_state &= ~AD_STATE_AGGREGATION;
@@ -1996,10 +2013,12 @@ void bond_3ad_unbind_slave(struct slave *slave)
1996 // if new aggregator found, copy the aggregator's parameters 2013 // if new aggregator found, copy the aggregator's parameters
1997 // and connect the related lag_ports to the new aggregator 2014 // and connect the related lag_ports to the new aggregator
1998 if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) { 2015 if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) {
1999 pr_debug("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier); 2016 pr_debug("Some port(s) related to LAG %d - replaceing with LAG %d\n",
2017 aggregator->aggregator_identifier,
2018 new_aggregator->aggregator_identifier);
2000 2019
2001 if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) { 2020 if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
2002 pr_info(DRV_NAME ": %s: Removing an active aggregator\n", 2021 pr_info("%s: Removing an active aggregator\n",
2003 aggregator->slave->dev->master->name); 2022 aggregator->slave->dev->master->name);
2004 // select new active aggregator 2023 // select new active aggregator
2005 select_new_active_agg = 1; 2024 select_new_active_agg = 1;
@@ -2030,8 +2049,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
2030 ad_agg_selection_logic(__get_first_agg(port)); 2049 ad_agg_selection_logic(__get_first_agg(port));
2031 } 2050 }
2032 } else { 2051 } else {
2033 pr_warning(DRV_NAME ": %s: Warning: unbinding aggregator, " 2052 pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n",
2034 "and could not find a new aggregator for its ports\n",
2035 slave->dev->master->name); 2053 slave->dev->master->name);
2036 } 2054 }
2037 } else { // in case that the only port related to this aggregator is the one we want to remove 2055 } else { // in case that the only port related to this aggregator is the one we want to remove
@@ -2039,7 +2057,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
2039 // clear the aggregator 2057 // clear the aggregator
2040 ad_clear_agg(aggregator); 2058 ad_clear_agg(aggregator);
2041 if (select_new_active_agg) { 2059 if (select_new_active_agg) {
2042 pr_info(DRV_NAME ": %s: Removing an active aggregator\n", 2060 pr_info("%s: Removing an active aggregator\n",
2043 slave->dev->master->name); 2061 slave->dev->master->name);
2044 // select new active aggregator 2062 // select new active aggregator
2045 ad_agg_selection_logic(__get_first_agg(port)); 2063 ad_agg_selection_logic(__get_first_agg(port));
@@ -2066,7 +2084,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
2066 // clear the aggregator 2084 // clear the aggregator
2067 ad_clear_agg(temp_aggregator); 2085 ad_clear_agg(temp_aggregator);
2068 if (select_new_active_agg) { 2086 if (select_new_active_agg) {
2069 pr_info(DRV_NAME ": %s: Removing an active aggregator\n", 2087 pr_info("%s: Removing an active aggregator\n",
2070 slave->dev->master->name); 2088 slave->dev->master->name);
2071 // select new active aggregator 2089 // select new active aggregator
2072 ad_agg_selection_logic(__get_first_agg(port)); 2090 ad_agg_selection_logic(__get_first_agg(port));
@@ -2115,8 +2133,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
2115 // select the active aggregator for the bond 2133 // select the active aggregator for the bond
2116 if ((port = __get_first_port(bond))) { 2134 if ((port = __get_first_port(bond))) {
2117 if (!port->slave) { 2135 if (!port->slave) {
2118 pr_warning(DRV_NAME ": %s: Warning: bond's first port is " 2136 pr_warning("%s: Warning: bond's first port is uninitialized\n",
2119 "uninitialized\n", bond->dev->name); 2137 bond->dev->name);
2120 goto re_arm; 2138 goto re_arm;
2121 } 2139 }
2122 2140
@@ -2129,8 +2147,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
2129 // for each port run the state machines 2147 // for each port run the state machines
2130 for (port = __get_first_port(bond); port; port = __get_next_port(port)) { 2148 for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
2131 if (!port->slave) { 2149 if (!port->slave) {
2132 pr_warning(DRV_NAME ": %s: Warning: Found an uninitialized " 2150 pr_warning("%s: Warning: Found an uninitialized port\n",
2133 "port\n", bond->dev->name); 2151 bond->dev->name);
2134 goto re_arm; 2152 goto re_arm;
2135 } 2153 }
2136 2154
@@ -2171,15 +2189,15 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
2171 port = &(SLAVE_AD_INFO(slave).port); 2189 port = &(SLAVE_AD_INFO(slave).port);
2172 2190
2173 if (!port->slave) { 2191 if (!port->slave) {
2174 pr_warning(DRV_NAME ": %s: Warning: port of slave %s " 2192 pr_warning("%s: Warning: port of slave %s is uninitialized\n",
2175 "is uninitialized\n",
2176 slave->dev->name, slave->dev->master->name); 2193 slave->dev->name, slave->dev->master->name);
2177 return; 2194 return;
2178 } 2195 }
2179 2196
2180 switch (lacpdu->subtype) { 2197 switch (lacpdu->subtype) {
2181 case AD_TYPE_LACPDU: 2198 case AD_TYPE_LACPDU:
2182 pr_debug("Received LACPDU on port %d\n", port->actor_port_number); 2199 pr_debug("Received LACPDU on port %d\n",
2200 port->actor_port_number);
2183 ad_rx_machine(lacpdu, port); 2201 ad_rx_machine(lacpdu, port);
2184 break; 2202 break;
2185 2203
@@ -2188,17 +2206,20 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
2188 2206
2189 switch (((struct bond_marker *)lacpdu)->tlv_type) { 2207 switch (((struct bond_marker *)lacpdu)->tlv_type) {
2190 case AD_MARKER_INFORMATION_SUBTYPE: 2208 case AD_MARKER_INFORMATION_SUBTYPE:
2191 pr_debug("Received Marker Information on port %d\n", port->actor_port_number); 2209 pr_debug("Received Marker Information on port %d\n",
2210 port->actor_port_number);
2192 ad_marker_info_received((struct bond_marker *)lacpdu, port); 2211 ad_marker_info_received((struct bond_marker *)lacpdu, port);
2193 break; 2212 break;
2194 2213
2195 case AD_MARKER_RESPONSE_SUBTYPE: 2214 case AD_MARKER_RESPONSE_SUBTYPE:
2196 pr_debug("Received Marker Response on port %d\n", port->actor_port_number); 2215 pr_debug("Received Marker Response on port %d\n",
2216 port->actor_port_number);
2197 ad_marker_response_received((struct bond_marker *)lacpdu, port); 2217 ad_marker_response_received((struct bond_marker *)lacpdu, port);
2198 break; 2218 break;
2199 2219
2200 default: 2220 default:
2201 pr_debug("Received an unknown Marker subtype on slot %d\n", port->actor_port_number); 2221 pr_debug("Received an unknown Marker subtype on slot %d\n",
2222 port->actor_port_number);
2202 } 2223 }
2203 } 2224 }
2204 } 2225 }
@@ -2218,8 +2239,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
2218 2239
2219 // if slave is null, the whole port is not initialized 2240 // if slave is null, the whole port is not initialized
2220 if (!port->slave) { 2241 if (!port->slave) {
2221 pr_warning(DRV_NAME ": Warning: %s: speed " 2242 pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
2222 "changed for uninitialized port on %s\n",
2223 slave->dev->master->name, slave->dev->name); 2243 slave->dev->master->name, slave->dev->name);
2224 return; 2244 return;
2225 } 2245 }
@@ -2246,8 +2266,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
2246 2266
2247 // if slave is null, the whole port is not initialized 2267 // if slave is null, the whole port is not initialized
2248 if (!port->slave) { 2268 if (!port->slave) {
2249 pr_warning(DRV_NAME ": %s: Warning: duplex changed " 2269 pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
2250 "for uninitialized port on %s\n",
2251 slave->dev->master->name, slave->dev->name); 2270 slave->dev->master->name, slave->dev->name);
2252 return; 2271 return;
2253 } 2272 }
@@ -2275,8 +2294,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
2275 2294
2276 // if slave is null, the whole port is not initialized 2295 // if slave is null, the whole port is not initialized
2277 if (!port->slave) { 2296 if (!port->slave) {
2278 pr_warning(DRV_NAME ": Warning: %s: link status changed for " 2297 pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
2279 "uninitialized port on %s\n",
2280 slave->dev->master->name, slave->dev->name); 2298 slave->dev->master->name, slave->dev->name);
2281 return; 2299 return;
2282 } 2300 }
@@ -2381,8 +2399,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2381 } 2399 }
2382 2400
2383 if (bond_3ad_get_active_agg_info(bond, &ad_info)) { 2401 if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
2384 pr_debug(DRV_NAME ": %s: Error: " 2402 pr_debug("%s: Error: bond_3ad_get_active_agg_info failed\n",
2385 "bond_3ad_get_active_agg_info failed\n", dev->name); 2403 dev->name);
2386 goto out; 2404 goto out;
2387 } 2405 }
2388 2406
@@ -2391,8 +2409,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2391 2409
2392 if (slaves_in_agg == 0) { 2410 if (slaves_in_agg == 0) {
2393 /*the aggregator is empty*/ 2411 /*the aggregator is empty*/
2394 pr_debug(DRV_NAME ": %s: Error: active aggregator is empty\n", 2412 pr_debug("%s: Error: active aggregator is empty\n", dev->name);
2395 dev->name);
2396 goto out; 2413 goto out;
2397 } 2414 }
2398 2415
@@ -2410,8 +2427,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2410 } 2427 }
2411 2428
2412 if (slave_agg_no >= 0) { 2429 if (slave_agg_no >= 0) {
2413 pr_err(DRV_NAME ": %s: Error: Couldn't find a slave to tx on " 2430 pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n",
2414 "for aggregator ID %d\n", dev->name, agg_id); 2431 dev->name, agg_id);
2415 goto out; 2432 goto out;
2416 } 2433 }
2417 2434
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 00ab51ef3129..40fdc41446cc 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -20,6 +20,8 @@
20 * 20 *
21 */ 21 */
22 22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
23#include <linux/skbuff.h> 25#include <linux/skbuff.h>
24#include <linux/netdevice.h> 26#include <linux/netdevice.h>
25#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
@@ -201,8 +203,7 @@ static int tlb_initialize(struct bonding *bond)
201 203
202 new_hashtbl = kzalloc(size, GFP_KERNEL); 204 new_hashtbl = kzalloc(size, GFP_KERNEL);
203 if (!new_hashtbl) { 205 if (!new_hashtbl) {
204 pr_err(DRV_NAME 206 pr_err("%s: Error: Failed to allocate TLB hash table\n",
205 ": %s: Error: Failed to allocate TLB hash table\n",
206 bond->dev->name); 207 bond->dev->name);
207 return -1; 208 return -1;
208 } 209 }
@@ -514,8 +515,7 @@ static void rlb_update_client(struct rlb_client_info *client_info)
514 client_info->slave->dev->dev_addr, 515 client_info->slave->dev->dev_addr,
515 client_info->mac_dst); 516 client_info->mac_dst);
516 if (!skb) { 517 if (!skb) {
517 pr_err(DRV_NAME 518 pr_err("%s: Error: failed to create an ARP packet\n",
518 ": %s: Error: failed to create an ARP packet\n",
519 client_info->slave->dev->master->name); 519 client_info->slave->dev->master->name);
520 continue; 520 continue;
521 } 521 }
@@ -525,8 +525,7 @@ static void rlb_update_client(struct rlb_client_info *client_info)
525 if (client_info->tag) { 525 if (client_info->tag) {
526 skb = vlan_put_tag(skb, client_info->vlan_id); 526 skb = vlan_put_tag(skb, client_info->vlan_id);
527 if (!skb) { 527 if (!skb) {
528 pr_err(DRV_NAME 528 pr_err("%s: Error: failed to insert VLAN tag\n",
529 ": %s: Error: failed to insert VLAN tag\n",
530 client_info->slave->dev->master->name); 529 client_info->slave->dev->master->name);
531 continue; 530 continue;
532 } 531 }
@@ -609,9 +608,7 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, __be32 src_ip)
609 client_info = &(bond_info->rx_hashtbl[hash_index]); 608 client_info = &(bond_info->rx_hashtbl[hash_index]);
610 609
611 if (!client_info->slave) { 610 if (!client_info->slave) {
612 pr_err(DRV_NAME 611 pr_err("%s: Error: found a client with no channel in the client's hash table\n",
613 ": %s: Error: found a client with no channel in "
614 "the client's hash table\n",
615 bond->dev->name); 612 bond->dev->name);
616 continue; 613 continue;
617 } 614 }
@@ -806,8 +803,7 @@ static int rlb_initialize(struct bonding *bond)
806 803
807 new_hashtbl = kmalloc(size, GFP_KERNEL); 804 new_hashtbl = kmalloc(size, GFP_KERNEL);
808 if (!new_hashtbl) { 805 if (!new_hashtbl) {
809 pr_err(DRV_NAME 806 pr_err("%s: Error: Failed to allocate RLB hash table\n",
810 ": %s: Error: Failed to allocate RLB hash table\n",
811 bond->dev->name); 807 bond->dev->name);
812 return -1; 808 return -1;
813 } 809 }
@@ -928,8 +924,7 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
928 924
929 skb = vlan_put_tag(skb, vlan->vlan_id); 925 skb = vlan_put_tag(skb, vlan->vlan_id);
930 if (!skb) { 926 if (!skb) {
931 pr_err(DRV_NAME 927 pr_err("%s: Error: failed to insert VLAN tag\n",
932 ": %s: Error: failed to insert VLAN tag\n",
933 bond->dev->name); 928 bond->dev->name);
934 continue; 929 continue;
935 } 930 }
@@ -958,11 +953,8 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
958 memcpy(s_addr.sa_data, addr, dev->addr_len); 953 memcpy(s_addr.sa_data, addr, dev->addr_len);
959 s_addr.sa_family = dev->type; 954 s_addr.sa_family = dev->type;
960 if (dev_set_mac_address(dev, &s_addr)) { 955 if (dev_set_mac_address(dev, &s_addr)) {
961 pr_err(DRV_NAME 956 pr_err("%s: Error: dev_set_mac_address of dev %s failed!\n"
962 ": %s: Error: dev_set_mac_address of dev %s failed! ALB " 957 "ALB mode requires that the base driver support setting the hw address also when the network device's interface is open\n",
963 "mode requires that the base driver support setting "
964 "the hw address also when the network device's "
965 "interface is open\n",
966 dev->master->name, dev->name); 958 dev->master->name, dev->name);
967 return -EOPNOTSUPP; 959 return -EOPNOTSUPP;
968 } 960 }
@@ -1169,18 +1161,12 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
1169 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, 1161 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr,
1170 bond->alb_info.rlb_enabled); 1162 bond->alb_info.rlb_enabled);
1171 1163
1172 pr_warning(DRV_NAME 1164 pr_warning("%s: Warning: the hw address of slave %s is in use by the bond; giving it the hw address of %s\n",
1173 ": %s: Warning: the hw address of slave %s is "
1174 "in use by the bond; giving it the hw address "
1175 "of %s\n",
1176 bond->dev->name, slave->dev->name, 1165 bond->dev->name, slave->dev->name,
1177 free_mac_slave->dev->name); 1166 free_mac_slave->dev->name);
1178 1167
1179 } else if (has_bond_addr) { 1168 } else if (has_bond_addr) {
1180 pr_err(DRV_NAME 1169 pr_err("%s: Error: the hw address of slave %s is in use by the bond; couldn't find a slave with a free hw address to give it (this should not have happened)\n",
1181 ": %s: Error: the hw address of slave %s is in use by the "
1182 "bond; couldn't find a slave with a free hw address to "
1183 "give it (this should not have happened)\n",
1184 bond->dev->name, slave->dev->name); 1170 bond->dev->name, slave->dev->name);
1185 return -EFAULT; 1171 return -EFAULT;
1186 } 1172 }
diff --git a/drivers/net/bonding/bond_ipv6.c b/drivers/net/bonding/bond_ipv6.c
index b72e1dc8cf8f..6dd64cf3cb76 100644
--- a/drivers/net/bonding/bond_ipv6.c
+++ b/drivers/net/bonding/bond_ipv6.c
@@ -20,6 +20,8 @@
20 * 20 *
21 */ 21 */
22 22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
23#include <linux/types.h> 25#include <linux/types.h>
24#include <linux/if_vlan.h> 26#include <linux/if_vlan.h>
25#include <net/ipv6.h> 27#include <net/ipv6.h>
@@ -74,20 +76,20 @@ static void bond_na_send(struct net_device *slave_dev,
74 addrconf_addr_solict_mult(daddr, &mcaddr); 76 addrconf_addr_solict_mult(daddr, &mcaddr);
75 77
76 pr_debug("ipv6 na on slave %s: dest %pI6, src %pI6\n", 78 pr_debug("ipv6 na on slave %s: dest %pI6, src %pI6\n",
77 slave_dev->name, &mcaddr, daddr); 79 slave_dev->name, &mcaddr, daddr);
78 80
79 skb = ndisc_build_skb(slave_dev, &mcaddr, daddr, &icmp6h, daddr, 81 skb = ndisc_build_skb(slave_dev, &mcaddr, daddr, &icmp6h, daddr,
80 ND_OPT_TARGET_LL_ADDR); 82 ND_OPT_TARGET_LL_ADDR);
81 83
82 if (!skb) { 84 if (!skb) {
83 pr_err(DRV_NAME ": NA packet allocation failed\n"); 85 pr_err("NA packet allocation failed\n");
84 return; 86 return;
85 } 87 }
86 88
87 if (vlan_id) { 89 if (vlan_id) {
88 skb = vlan_put_tag(skb, vlan_id); 90 skb = vlan_put_tag(skb, vlan_id);
89 if (!skb) { 91 if (!skb) {
90 pr_err(DRV_NAME ": failed to insert VLAN tag\n"); 92 pr_err("failed to insert VLAN tag\n");
91 return; 93 return;
92 } 94 }
93 } 95 }
@@ -109,8 +111,8 @@ void bond_send_unsolicited_na(struct bonding *bond)
109 struct inet6_dev *idev; 111 struct inet6_dev *idev;
110 int is_router; 112 int is_router;
111 113
112 pr_debug("bond_send_unsol_na: bond %s slave %s\n", bond->dev->name, 114 pr_debug("%s: bond %s slave %s\n", bond->dev->name,
113 slave ? slave->dev->name : "NULL"); 115 __func__, slave ? slave->dev->name : "NULL");
114 116
115 if (!slave || !bond->send_unsol_na || 117 if (!slave || !bond->send_unsol_na ||
116 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) 118 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index af9b9c4eb496..3f0071cfe56b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -31,6 +31,8 @@
31 * 31 *
32 */ 32 */
33 33
34#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
35
34#include <linux/kernel.h> 36#include <linux/kernel.h>
35#include <linux/module.h> 37#include <linux/module.h>
36#include <linux/types.h> 38#include <linux/types.h>
@@ -260,7 +262,7 @@ static int bond_add_vlan(struct bonding *bond, unsigned short vlan_id)
260 struct vlan_entry *vlan; 262 struct vlan_entry *vlan;
261 263
262 pr_debug("bond: %s, vlan id %d\n", 264 pr_debug("bond: %s, vlan id %d\n",
263 (bond ? bond->dev->name : "None"), vlan_id); 265 (bond ? bond->dev->name : "None"), vlan_id);
264 266
265 vlan = kzalloc(sizeof(struct vlan_entry), GFP_KERNEL); 267 vlan = kzalloc(sizeof(struct vlan_entry), GFP_KERNEL);
266 if (!vlan) 268 if (!vlan)
@@ -303,8 +305,8 @@ static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id)
303 if (bond_is_lb(bond)) 305 if (bond_is_lb(bond))
304 bond_alb_clear_vlan(bond, vlan_id); 306 bond_alb_clear_vlan(bond, vlan_id);
305 307
306 pr_debug("removed VLAN ID %d from bond %s\n", vlan_id, 308 pr_debug("removed VLAN ID %d from bond %s\n",
307 bond->dev->name); 309 vlan_id, bond->dev->name);
308 310
309 kfree(vlan); 311 kfree(vlan);
310 312
@@ -323,8 +325,8 @@ static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id)
323 } 325 }
324 } 326 }
325 327
326 pr_debug("couldn't find VLAN ID %d in bond %s\n", vlan_id, 328 pr_debug("couldn't find VLAN ID %d in bond %s\n",
327 bond->dev->name); 329 vlan_id, bond->dev->name);
328 330
329out: 331out:
330 write_unlock_bh(&bond->lock); 332 write_unlock_bh(&bond->lock);
@@ -348,7 +350,7 @@ static int bond_has_challenged_slaves(struct bonding *bond)
348 bond_for_each_slave(bond, slave, i) { 350 bond_for_each_slave(bond, slave, i) {
349 if (slave->dev->features & NETIF_F_VLAN_CHALLENGED) { 351 if (slave->dev->features & NETIF_F_VLAN_CHALLENGED) {
350 pr_debug("found VLAN challenged slave - %s\n", 352 pr_debug("found VLAN challenged slave - %s\n",
351 slave->dev->name); 353 slave->dev->name);
352 return 1; 354 return 1;
353 } 355 }
354 } 356 }
@@ -499,8 +501,7 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
499 501
500 res = bond_add_vlan(bond, vid); 502 res = bond_add_vlan(bond, vid);
501 if (res) { 503 if (res) {
502 pr_err(DRV_NAME 504 pr_err("%s: Error: Failed to add vlan id %d\n",
503 ": %s: Error: Failed to add vlan id %d\n",
504 bond_dev->name, vid); 505 bond_dev->name, vid);
505 } 506 }
506} 507}
@@ -534,8 +535,7 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
534 535
535 res = bond_del_vlan(bond, vid); 536 res = bond_del_vlan(bond, vid);
536 if (res) { 537 if (res) {
537 pr_err(DRV_NAME 538 pr_err("%s: Error: Failed to remove vlan id %d\n",
538 ": %s: Error: Failed to remove vlan id %d\n",
539 bond_dev->name, vid); 539 bond_dev->name, vid);
540 } 540 }
541} 541}
@@ -1053,8 +1053,7 @@ static void bond_do_fail_over_mac(struct bonding *bond,
1053 1053
1054 rv = dev_set_mac_address(new_active->dev, &saddr); 1054 rv = dev_set_mac_address(new_active->dev, &saddr);
1055 if (rv) { 1055 if (rv) {
1056 pr_err(DRV_NAME 1056 pr_err("%s: Error %d setting MAC of slave %s\n",
1057 ": %s: Error %d setting MAC of slave %s\n",
1058 bond->dev->name, -rv, new_active->dev->name); 1057 bond->dev->name, -rv, new_active->dev->name);
1059 goto out; 1058 goto out;
1060 } 1059 }
@@ -1067,16 +1066,14 @@ static void bond_do_fail_over_mac(struct bonding *bond,
1067 1066
1068 rv = dev_set_mac_address(old_active->dev, &saddr); 1067 rv = dev_set_mac_address(old_active->dev, &saddr);
1069 if (rv) 1068 if (rv)
1070 pr_err(DRV_NAME 1069 pr_err("%s: Error %d setting MAC of slave %s\n",
1071 ": %s: Error %d setting MAC of slave %s\n",
1072 bond->dev->name, -rv, new_active->dev->name); 1070 bond->dev->name, -rv, new_active->dev->name);
1073out: 1071out:
1074 read_lock(&bond->lock); 1072 read_lock(&bond->lock);
1075 write_lock_bh(&bond->curr_slave_lock); 1073 write_lock_bh(&bond->curr_slave_lock);
1076 break; 1074 break;
1077 default: 1075 default:
1078 pr_err(DRV_NAME 1076 pr_err("%s: bond_do_fail_over_mac impossible: bad policy %d\n",
1079 ": %s: bond_do_fail_over_mac impossible: bad policy %d\n",
1080 bond->dev->name, bond->params.fail_over_mac); 1077 bond->dev->name, bond->params.fail_over_mac);
1081 break; 1078 break;
1082 } 1079 }
@@ -1178,11 +1175,9 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1178 1175
1179 if (new_active->link == BOND_LINK_BACK) { 1176 if (new_active->link == BOND_LINK_BACK) {
1180 if (USES_PRIMARY(bond->params.mode)) { 1177 if (USES_PRIMARY(bond->params.mode)) {
1181 pr_info(DRV_NAME 1178 pr_info("%s: making interface %s the new active one %d ms earlier.\n",
1182 ": %s: making interface %s the new " 1179 bond->dev->name, new_active->dev->name,
1183 "active one %d ms earlier.\n", 1180 (bond->params.updelay - new_active->delay) * bond->params.miimon);
1184 bond->dev->name, new_active->dev->name,
1185 (bond->params.updelay - new_active->delay) * bond->params.miimon);
1186 } 1181 }
1187 1182
1188 new_active->delay = 0; 1183 new_active->delay = 0;
@@ -1195,10 +1190,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1195 bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP); 1190 bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP);
1196 } else { 1191 } else {
1197 if (USES_PRIMARY(bond->params.mode)) { 1192 if (USES_PRIMARY(bond->params.mode)) {
1198 pr_info(DRV_NAME 1193 pr_info("%s: making interface %s the new active one.\n",
1199 ": %s: making interface %s the new " 1194 bond->dev->name, new_active->dev->name);
1200 "active one.\n",
1201 bond->dev->name, new_active->dev->name);
1202 } 1195 }
1203 } 1196 }
1204 } 1197 }
@@ -1268,13 +1261,11 @@ void bond_select_active_slave(struct bonding *bond)
1268 return; 1261 return;
1269 1262
1270 if (netif_carrier_ok(bond->dev)) { 1263 if (netif_carrier_ok(bond->dev)) {
1271 pr_info(DRV_NAME 1264 pr_info("%s: first active interface up!\n",
1272 ": %s: first active interface up!\n", 1265 bond->dev->name);
1273 bond->dev->name);
1274 } else { 1266 } else {
1275 pr_info(DRV_NAME ": %s: " 1267 pr_info("%s: now running without any active interface !\n",
1276 "now running without any active interface !\n", 1268 bond->dev->name);
1277 bond->dev->name);
1278 } 1269 }
1279 } 1270 }
1280} 1271}
@@ -1423,16 +1414,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1423 1414
1424 if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL && 1415 if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL &&
1425 slave_ops->ndo_do_ioctl == NULL) { 1416 slave_ops->ndo_do_ioctl == NULL) {
1426 pr_warning(DRV_NAME 1417 pr_warning("%s: Warning: no link monitoring support for %s\n",
1427 ": %s: Warning: no link monitoring support for %s\n", 1418 bond_dev->name, slave_dev->name);
1428 bond_dev->name, slave_dev->name);
1429 } 1419 }
1430 1420
1431 /* bond must be initialized by bond_open() before enslaving */ 1421 /* bond must be initialized by bond_open() before enslaving */
1432 if (!(bond_dev->flags & IFF_UP)) { 1422 if (!(bond_dev->flags & IFF_UP)) {
1433 pr_warning(DRV_NAME 1423 pr_warning("%s: master_dev is not up in bond_enslave\n",
1434 " %s: master_dev is not up in bond_enslave\n", 1424 bond_dev->name);
1435 bond_dev->name);
1436 } 1425 }
1437 1426
1438 /* already enslaved */ 1427 /* already enslaved */
@@ -1446,19 +1435,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1446 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { 1435 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
1447 pr_debug("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name); 1436 pr_debug("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name);
1448 if (!list_empty(&bond->vlan_list)) { 1437 if (!list_empty(&bond->vlan_list)) {
1449 pr_err(DRV_NAME 1438 pr_err("%s: Error: cannot enslave VLAN challenged slave %s on VLAN enabled bond %s\n",
1450 ": %s: Error: cannot enslave VLAN " 1439 bond_dev->name, slave_dev->name, bond_dev->name);
1451 "challenged slave %s on VLAN enabled "
1452 "bond %s\n", bond_dev->name, slave_dev->name,
1453 bond_dev->name);
1454 return -EPERM; 1440 return -EPERM;
1455 } else { 1441 } else {
1456 pr_warning(DRV_NAME 1442 pr_warning("%s: Warning: enslaved VLAN challenged slave %s. Adding VLANs will be blocked as long as %s is part of bond %s\n",
1457 ": %s: Warning: enslaved VLAN challenged " 1443 bond_dev->name, slave_dev->name,
1458 "slave %s. Adding VLANs will be blocked as " 1444 slave_dev->name, bond_dev->name);
1459 "long as %s is part of bond %s\n",
1460 bond_dev->name, slave_dev->name, slave_dev->name,
1461 bond_dev->name);
1462 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 1445 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
1463 } 1446 }
1464 } else { 1447 } else {
@@ -1478,8 +1461,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1478 * enslaving it; the old ifenslave will not. 1461 * enslaving it; the old ifenslave will not.
1479 */ 1462 */
1480 if ((slave_dev->flags & IFF_UP)) { 1463 if ((slave_dev->flags & IFF_UP)) {
1481 pr_err(DRV_NAME ": %s is up. " 1464 pr_err("%s is up. This may be due to an out of date ifenslave.\n",
1482 "This may be due to an out of date ifenslave.\n",
1483 slave_dev->name); 1465 slave_dev->name);
1484 res = -EPERM; 1466 res = -EPERM;
1485 goto err_undo_flags; 1467 goto err_undo_flags;
@@ -1495,7 +1477,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1495 if (bond->slave_cnt == 0) { 1477 if (bond->slave_cnt == 0) {
1496 if (bond_dev->type != slave_dev->type) { 1478 if (bond_dev->type != slave_dev->type) {
1497 pr_debug("%s: change device type from %d to %d\n", 1479 pr_debug("%s: change device type from %d to %d\n",
1498 bond_dev->name, bond_dev->type, slave_dev->type); 1480 bond_dev->name,
1481 bond_dev->type, slave_dev->type);
1499 1482
1500 netdev_bonding_change(bond_dev, NETDEV_BONDING_OLDTYPE); 1483 netdev_bonding_change(bond_dev, NETDEV_BONDING_OLDTYPE);
1501 1484
@@ -1507,28 +1490,21 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1507 netdev_bonding_change(bond_dev, NETDEV_BONDING_NEWTYPE); 1490 netdev_bonding_change(bond_dev, NETDEV_BONDING_NEWTYPE);
1508 } 1491 }
1509 } else if (bond_dev->type != slave_dev->type) { 1492 } else if (bond_dev->type != slave_dev->type) {
1510 pr_err(DRV_NAME ": %s ether type (%d) is different " 1493 pr_err("%s ether type (%d) is different from other slaves (%d), can not enslave it.\n",
1511 "from other slaves (%d), can not enslave it.\n", 1494 slave_dev->name,
1512 slave_dev->name, 1495 slave_dev->type, bond_dev->type);
1513 slave_dev->type, bond_dev->type); 1496 res = -EINVAL;
1514 res = -EINVAL; 1497 goto err_undo_flags;
1515 goto err_undo_flags;
1516 } 1498 }
1517 1499
1518 if (slave_ops->ndo_set_mac_address == NULL) { 1500 if (slave_ops->ndo_set_mac_address == NULL) {
1519 if (bond->slave_cnt == 0) { 1501 if (bond->slave_cnt == 0) {
1520 pr_warning(DRV_NAME 1502 pr_warning("%s: Warning: The first slave device specified does not support setting the MAC address. Setting fail_over_mac to active.",
1521 ": %s: Warning: The first slave device " 1503 bond_dev->name);
1522 "specified does not support setting the MAC "
1523 "address. Setting fail_over_mac to active.",
1524 bond_dev->name);
1525 bond->params.fail_over_mac = BOND_FOM_ACTIVE; 1504 bond->params.fail_over_mac = BOND_FOM_ACTIVE;
1526 } else if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) { 1505 } else if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) {
1527 pr_err(DRV_NAME 1506 pr_err("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active.\n",
1528 ": %s: Error: The slave device specified " 1507 bond_dev->name);
1529 "does not support setting the MAC address, "
1530 "but fail_over_mac is not set to active.\n"
1531 , bond_dev->name);
1532 res = -EOPNOTSUPP; 1508 res = -EOPNOTSUPP;
1533 goto err_undo_flags; 1509 goto err_undo_flags;
1534 } 1510 }
@@ -1655,22 +1631,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1655 * supported); thus, we don't need to change 1631 * supported); thus, we don't need to change
1656 * the messages for netif_carrier. 1632 * the messages for netif_carrier.
1657 */ 1633 */
1658 pr_warning(DRV_NAME 1634 pr_warning("%s: Warning: MII and ETHTOOL support not available for interface %s, and arp_interval/arp_ip_target module parameters not specified, thus bonding will not detect link failures! see bonding.txt for details.\n",
1659 ": %s: Warning: MII and ETHTOOL support not "
1660 "available for interface %s, and "
1661 "arp_interval/arp_ip_target module parameters "
1662 "not specified, thus bonding will not detect "
1663 "link failures! see bonding.txt for details.\n",
1664 bond_dev->name, slave_dev->name); 1635 bond_dev->name, slave_dev->name);
1665 } else if (link_reporting == -1) { 1636 } else if (link_reporting == -1) {
1666 /* unable get link status using mii/ethtool */ 1637 /* unable get link status using mii/ethtool */
1667 pr_warning(DRV_NAME 1638 pr_warning("%s: Warning: can't get link status from interface %s; the network driver associated with this interface does not support MII or ETHTOOL link status reporting, thus miimon has no effect on this interface.\n",
1668 ": %s: Warning: can't get link status from " 1639 bond_dev->name, slave_dev->name);
1669 "interface %s; the network driver associated "
1670 "with this interface does not support MII or "
1671 "ETHTOOL link status reporting, thus miimon "
1672 "has no effect on this interface.\n",
1673 bond_dev->name, slave_dev->name);
1674 } 1640 }
1675 } 1641 }
1676 1642
@@ -1678,34 +1644,27 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1678 if (!bond->params.miimon || 1644 if (!bond->params.miimon ||
1679 (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS)) { 1645 (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS)) {
1680 if (bond->params.updelay) { 1646 if (bond->params.updelay) {
1681 pr_debug("Initial state of slave_dev is " 1647 pr_debug("Initial state of slave_dev is BOND_LINK_BACK\n");
1682 "BOND_LINK_BACK\n");
1683 new_slave->link = BOND_LINK_BACK; 1648 new_slave->link = BOND_LINK_BACK;
1684 new_slave->delay = bond->params.updelay; 1649 new_slave->delay = bond->params.updelay;
1685 } else { 1650 } else {
1686 pr_debug("Initial state of slave_dev is " 1651 pr_debug("Initial state of slave_dev is BOND_LINK_UP\n");
1687 "BOND_LINK_UP\n");
1688 new_slave->link = BOND_LINK_UP; 1652 new_slave->link = BOND_LINK_UP;
1689 } 1653 }
1690 new_slave->jiffies = jiffies; 1654 new_slave->jiffies = jiffies;
1691 } else { 1655 } else {
1692 pr_debug("Initial state of slave_dev is " 1656 pr_debug("Initial state of slave_dev is BOND_LINK_DOWN\n");
1693 "BOND_LINK_DOWN\n");
1694 new_slave->link = BOND_LINK_DOWN; 1657 new_slave->link = BOND_LINK_DOWN;
1695 } 1658 }
1696 1659
1697 if (bond_update_speed_duplex(new_slave) && 1660 if (bond_update_speed_duplex(new_slave) &&
1698 (new_slave->link != BOND_LINK_DOWN)) { 1661 (new_slave->link != BOND_LINK_DOWN)) {
1699 pr_warning(DRV_NAME 1662 pr_warning("%s: Warning: failed to get speed and duplex from %s, assumed to be 100Mb/sec and Full.\n",
1700 ": %s: Warning: failed to get speed and duplex from %s, " 1663 bond_dev->name, new_slave->dev->name);
1701 "assumed to be 100Mb/sec and Full.\n",
1702 bond_dev->name, new_slave->dev->name);
1703 1664
1704 if (bond->params.mode == BOND_MODE_8023AD) { 1665 if (bond->params.mode == BOND_MODE_8023AD) {
1705 pr_warning(DRV_NAME 1666 pr_warning("%s: Warning: Operation of 802.3ad mode requires ETHTOOL support in base driver for proper aggregator selection.\n",
1706 ": %s: Warning: Operation of 802.3ad mode requires ETHTOOL " 1667 bond_dev->name);
1707 "support in base driver for proper aggregator "
1708 "selection.\n", bond_dev->name);
1709 } 1668 }
1710 } 1669 }
1711 1670
@@ -1777,11 +1736,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1777 if (res) 1736 if (res)
1778 goto err_close; 1737 goto err_close;
1779 1738
1780 pr_info(DRV_NAME 1739 pr_info("%s: enslaving %s as a%s interface with a%s link.\n",
1781 ": %s: enslaving %s as a%s interface with a%s link.\n", 1740 bond_dev->name, slave_dev->name,
1782 bond_dev->name, slave_dev->name, 1741 new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup",
1783 new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup", 1742 new_slave->link != BOND_LINK_DOWN ? "n up" : " down");
1784 new_slave->link != BOND_LINK_DOWN ? "n up" : " down");
1785 1743
1786 /* enslave is successful */ 1744 /* enslave is successful */
1787 return 0; 1745 return 0;
@@ -1833,8 +1791,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1833 /* slave is not a slave or master is not master of this slave */ 1791 /* slave is not a slave or master is not master of this slave */
1834 if (!(slave_dev->flags & IFF_SLAVE) || 1792 if (!(slave_dev->flags & IFF_SLAVE) ||
1835 (slave_dev->master != bond_dev)) { 1793 (slave_dev->master != bond_dev)) {
1836 pr_err(DRV_NAME 1794 pr_err("%s: Error: cannot release %s.\n",
1837 ": %s: Error: cannot release %s.\n",
1838 bond_dev->name, slave_dev->name); 1795 bond_dev->name, slave_dev->name);
1839 return -EINVAL; 1796 return -EINVAL;
1840 } 1797 }
@@ -1844,9 +1801,8 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1844 slave = bond_get_slave_by_dev(bond, slave_dev); 1801 slave = bond_get_slave_by_dev(bond, slave_dev);
1845 if (!slave) { 1802 if (!slave) {
1846 /* not a slave of this bond */ 1803 /* not a slave of this bond */
1847 pr_info(DRV_NAME 1804 pr_info("%s: %s not enslaved\n",
1848 ": %s: %s not enslaved\n", 1805 bond_dev->name, slave_dev->name);
1849 bond_dev->name, slave_dev->name);
1850 write_unlock_bh(&bond->lock); 1806 write_unlock_bh(&bond->lock);
1851 return -EINVAL; 1807 return -EINVAL;
1852 } 1808 }
@@ -1854,14 +1810,10 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1854 if (!bond->params.fail_over_mac) { 1810 if (!bond->params.fail_over_mac) {
1855 if (!compare_ether_addr(bond_dev->dev_addr, slave->perm_hwaddr) && 1811 if (!compare_ether_addr(bond_dev->dev_addr, slave->perm_hwaddr) &&
1856 bond->slave_cnt > 1) 1812 bond->slave_cnt > 1)
1857 pr_warning(DRV_NAME 1813 pr_warning("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s. Set the HWaddr of %s to a different address to avoid conflicts.\n",
1858 ": %s: Warning: the permanent HWaddr of %s - " 1814 bond_dev->name, slave_dev->name,
1859 "%pM - is still in use by %s. " 1815 slave->perm_hwaddr,
1860 "Set the HWaddr of %s to a different address " 1816 bond_dev->name, slave_dev->name);
1861 "to avoid conflicts.\n",
1862 bond_dev->name, slave_dev->name,
1863 slave->perm_hwaddr,
1864 bond_dev->name, slave_dev->name);
1865 } 1817 }
1866 1818
1867 /* Inform AD package of unbinding of slave. */ 1819 /* Inform AD package of unbinding of slave. */
@@ -1872,12 +1824,10 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1872 bond_3ad_unbind_slave(slave); 1824 bond_3ad_unbind_slave(slave);
1873 } 1825 }
1874 1826
1875 pr_info(DRV_NAME 1827 pr_info("%s: releasing %s interface %s\n",
1876 ": %s: releasing %s interface %s\n", 1828 bond_dev->name,
1877 bond_dev->name, 1829 (slave->state == BOND_STATE_ACTIVE) ? "active" : "backup",
1878 (slave->state == BOND_STATE_ACTIVE) 1830 slave_dev->name);
1879 ? "active" : "backup",
1880 slave_dev->name);
1881 1831
1882 oldcurrent = bond->curr_active_slave; 1832 oldcurrent = bond->curr_active_slave;
1883 1833
@@ -1934,21 +1884,15 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1934 if (list_empty(&bond->vlan_list)) { 1884 if (list_empty(&bond->vlan_list)) {
1935 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 1885 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
1936 } else { 1886 } else {
1937 pr_warning(DRV_NAME 1887 pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n",
1938 ": %s: Warning: clearing HW address of %s while it " 1888 bond_dev->name, bond_dev->name);
1939 "still has VLANs.\n", 1889 pr_warning("%s: When re-adding slaves, make sure the bond's HW address matches its VLANs'.\n",
1940 bond_dev->name, bond_dev->name); 1890 bond_dev->name);
1941 pr_warning(DRV_NAME
1942 ": %s: When re-adding slaves, make sure the bond's "
1943 "HW address matches its VLANs'.\n",
1944 bond_dev->name);
1945 } 1891 }
1946 } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) && 1892 } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) &&
1947 !bond_has_challenged_slaves(bond)) { 1893 !bond_has_challenged_slaves(bond)) {
1948 pr_info(DRV_NAME 1894 pr_info("%s: last VLAN challenged slave %s left bond %s. VLAN blocking is removed\n",
1949 ": %s: last VLAN challenged slave %s " 1895 bond_dev->name, slave_dev->name, bond_dev->name);
1950 "left bond %s. VLAN blocking is removed\n",
1951 bond_dev->name, slave_dev->name, bond_dev->name);
1952 bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED; 1896 bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED;
1953 } 1897 }
1954 1898
@@ -2011,8 +1955,8 @@ int bond_release_and_destroy(struct net_device *bond_dev,
2011 1955
2012 ret = bond_release(bond_dev, slave_dev); 1956 ret = bond_release(bond_dev, slave_dev);
2013 if ((ret == 0) && (bond->slave_cnt == 0)) { 1957 if ((ret == 0) && (bond->slave_cnt == 0)) {
2014 pr_info(DRV_NAME ": %s: destroying bond %s.\n", 1958 pr_info("%s: destroying bond %s.\n",
2015 bond_dev->name, bond_dev->name); 1959 bond_dev->name, bond_dev->name);
2016 unregister_netdevice(bond_dev); 1960 unregister_netdevice(bond_dev);
2017 } 1961 }
2018 return ret; 1962 return ret;
@@ -2116,19 +2060,13 @@ static int bond_release_all(struct net_device *bond_dev)
2116 if (list_empty(&bond->vlan_list)) 2060 if (list_empty(&bond->vlan_list))
2117 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 2061 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
2118 else { 2062 else {
2119 pr_warning(DRV_NAME 2063 pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n",
2120 ": %s: Warning: clearing HW address of %s while it " 2064 bond_dev->name, bond_dev->name);
2121 "still has VLANs.\n", 2065 pr_warning("%s: When re-adding slaves, make sure the bond's HW address matches its VLANs'.\n",
2122 bond_dev->name, bond_dev->name); 2066 bond_dev->name);
2123 pr_warning(DRV_NAME
2124 ": %s: When re-adding slaves, make sure the bond's "
2125 "HW address matches its VLANs'.\n",
2126 bond_dev->name);
2127 } 2067 }
2128 2068
2129 pr_info(DRV_NAME 2069 pr_info("%s: released all slaves\n", bond_dev->name);
2130 ": %s: released all slaves\n",
2131 bond_dev->name);
2132 2070
2133out: 2071out:
2134 write_unlock_bh(&bond->lock); 2072 write_unlock_bh(&bond->lock);
@@ -2254,16 +2192,14 @@ static int bond_miimon_inspect(struct bonding *bond)
2254 slave->link = BOND_LINK_FAIL; 2192 slave->link = BOND_LINK_FAIL;
2255 slave->delay = bond->params.downdelay; 2193 slave->delay = bond->params.downdelay;
2256 if (slave->delay) { 2194 if (slave->delay) {
2257 pr_info(DRV_NAME 2195 pr_info("%s: link status down for %sinterface %s, disabling it in %d ms.\n",
2258 ": %s: link status down for %s" 2196 bond->dev->name,
2259 "interface %s, disabling it in %d ms.\n", 2197 (bond->params.mode ==
2260 bond->dev->name, 2198 BOND_MODE_ACTIVEBACKUP) ?
2261 (bond->params.mode == 2199 ((slave->state == BOND_STATE_ACTIVE) ?
2262 BOND_MODE_ACTIVEBACKUP) ? 2200 "active " : "backup ") : "",
2263 ((slave->state == BOND_STATE_ACTIVE) ? 2201 slave->dev->name,
2264 "active " : "backup ") : "", 2202 bond->params.downdelay * bond->params.miimon);
2265 slave->dev->name,
2266 bond->params.downdelay * bond->params.miimon);
2267 } 2203 }
2268 /*FALLTHRU*/ 2204 /*FALLTHRU*/
2269 case BOND_LINK_FAIL: 2205 case BOND_LINK_FAIL:
@@ -2273,13 +2209,11 @@ static int bond_miimon_inspect(struct bonding *bond)
2273 */ 2209 */
2274 slave->link = BOND_LINK_UP; 2210 slave->link = BOND_LINK_UP;
2275 slave->jiffies = jiffies; 2211 slave->jiffies = jiffies;
2276 pr_info(DRV_NAME 2212 pr_info("%s: link status up again after %d ms for interface %s.\n",
2277 ": %s: link status up again after %d " 2213 bond->dev->name,
2278 "ms for interface %s.\n", 2214 (bond->params.downdelay - slave->delay) *
2279 bond->dev->name, 2215 bond->params.miimon,
2280 (bond->params.downdelay - slave->delay) * 2216 slave->dev->name);
2281 bond->params.miimon,
2282 slave->dev->name);
2283 continue; 2217 continue;
2284 } 2218 }
2285 2219
@@ -2300,25 +2234,21 @@ static int bond_miimon_inspect(struct bonding *bond)
2300 slave->delay = bond->params.updelay; 2234 slave->delay = bond->params.updelay;
2301 2235
2302 if (slave->delay) { 2236 if (slave->delay) {
2303 pr_info(DRV_NAME 2237 pr_info("%s: link status up for interface %s, enabling it in %d ms.\n",
2304 ": %s: link status up for " 2238 bond->dev->name, slave->dev->name,
2305 "interface %s, enabling it in %d ms.\n", 2239 ignore_updelay ? 0 :
2306 bond->dev->name, slave->dev->name, 2240 bond->params.updelay *
2307 ignore_updelay ? 0 : 2241 bond->params.miimon);
2308 bond->params.updelay *
2309 bond->params.miimon);
2310 } 2242 }
2311 /*FALLTHRU*/ 2243 /*FALLTHRU*/
2312 case BOND_LINK_BACK: 2244 case BOND_LINK_BACK:
2313 if (!link_state) { 2245 if (!link_state) {
2314 slave->link = BOND_LINK_DOWN; 2246 slave->link = BOND_LINK_DOWN;
2315 pr_info(DRV_NAME 2247 pr_info("%s: link status down again after %d ms for interface %s.\n",
2316 ": %s: link status down again after %d " 2248 bond->dev->name,
2317 "ms for interface %s.\n", 2249 (bond->params.updelay - slave->delay) *
2318 bond->dev->name, 2250 bond->params.miimon,
2319 (bond->params.updelay - slave->delay) * 2251 slave->dev->name);
2320 bond->params.miimon,
2321 slave->dev->name);
2322 2252
2323 continue; 2253 continue;
2324 } 2254 }
@@ -2366,10 +2296,8 @@ static void bond_miimon_commit(struct bonding *bond)
2366 slave->state = BOND_STATE_BACKUP; 2296 slave->state = BOND_STATE_BACKUP;
2367 } 2297 }
2368 2298
2369 pr_info(DRV_NAME 2299 pr_info("%s: link status definitely up for interface %s.\n",
2370 ": %s: link status definitely " 2300 bond->dev->name, slave->dev->name);
2371 "up for interface %s.\n",
2372 bond->dev->name, slave->dev->name);
2373 2301
2374 /* notify ad that the link status has changed */ 2302 /* notify ad that the link status has changed */
2375 if (bond->params.mode == BOND_MODE_8023AD) 2303 if (bond->params.mode == BOND_MODE_8023AD)
@@ -2395,10 +2323,8 @@ static void bond_miimon_commit(struct bonding *bond)
2395 bond->params.mode == BOND_MODE_8023AD) 2323 bond->params.mode == BOND_MODE_8023AD)
2396 bond_set_slave_inactive_flags(slave); 2324 bond_set_slave_inactive_flags(slave);
2397 2325
2398 pr_info(DRV_NAME 2326 pr_info("%s: link status definitely down for interface %s, disabling it\n",
2399 ": %s: link status definitely down for " 2327 bond->dev->name, slave->dev->name);
2400 "interface %s, disabling it\n",
2401 bond->dev->name, slave->dev->name);
2402 2328
2403 if (bond->params.mode == BOND_MODE_8023AD) 2329 if (bond->params.mode == BOND_MODE_8023AD)
2404 bond_3ad_handle_link_change(slave, 2330 bond_3ad_handle_link_change(slave,
@@ -2414,8 +2340,7 @@ static void bond_miimon_commit(struct bonding *bond)
2414 continue; 2340 continue;
2415 2341
2416 default: 2342 default:
2417 pr_err(DRV_NAME 2343 pr_err("%s: invalid new link %d on slave %s\n",
2418 ": %s: invalid new link %d on slave %s\n",
2419 bond->dev->name, slave->new_link, 2344 bond->dev->name, slave->new_link,
2420 slave->dev->name); 2345 slave->dev->name);
2421 slave->new_link = BOND_LINK_NOCHANGE; 2346 slave->new_link = BOND_LINK_NOCHANGE;
@@ -2534,19 +2459,19 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_
2534 struct sk_buff *skb; 2459 struct sk_buff *skb;
2535 2460
2536 pr_debug("arp %d on slave %s: dst %x src %x vid %d\n", arp_op, 2461 pr_debug("arp %d on slave %s: dst %x src %x vid %d\n", arp_op,
2537 slave_dev->name, dest_ip, src_ip, vlan_id); 2462 slave_dev->name, dest_ip, src_ip, vlan_id);
2538 2463
2539 skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip, 2464 skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip,
2540 NULL, slave_dev->dev_addr, NULL); 2465 NULL, slave_dev->dev_addr, NULL);
2541 2466
2542 if (!skb) { 2467 if (!skb) {
2543 pr_err(DRV_NAME ": ARP packet allocation failed\n"); 2468 pr_err("ARP packet allocation failed\n");
2544 return; 2469 return;
2545 } 2470 }
2546 if (vlan_id) { 2471 if (vlan_id) {
2547 skb = vlan_put_tag(skb, vlan_id); 2472 skb = vlan_put_tag(skb, vlan_id);
2548 if (!skb) { 2473 if (!skb) {
2549 pr_err(DRV_NAME ": failed to insert VLAN tag\n"); 2474 pr_err("failed to insert VLAN tag\n");
2550 return; 2475 return;
2551 } 2476 }
2552 } 2477 }
@@ -2586,9 +2511,8 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2586 rv = ip_route_output_key(dev_net(bond->dev), &rt, &fl); 2511 rv = ip_route_output_key(dev_net(bond->dev), &rt, &fl);
2587 if (rv) { 2512 if (rv) {
2588 if (net_ratelimit()) { 2513 if (net_ratelimit()) {
2589 pr_warning(DRV_NAME 2514 pr_warning("%s: no route to arp_ip_target %pI4\n",
2590 ": %s: no route to arp_ip_target %pI4\n", 2515 bond->dev->name, &fl.fl4_dst);
2591 bond->dev->name, &fl.fl4_dst);
2592 } 2516 }
2593 continue; 2517 continue;
2594 } 2518 }
@@ -2623,10 +2547,9 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2623 } 2547 }
2624 2548
2625 if (net_ratelimit()) { 2549 if (net_ratelimit()) {
2626 pr_warning(DRV_NAME 2550 pr_warning("%s: no path to arp_ip_target %pI4 via rt.dev %s\n",
2627 ": %s: no path to arp_ip_target %pI4 via rt.dev %s\n", 2551 bond->dev->name, &fl.fl4_dst,
2628 bond->dev->name, &fl.fl4_dst, 2552 rt->u.dst.dev ? rt->u.dst.dev->name : "NULL");
2629 rt->u.dst.dev ? rt->u.dst.dev->name : "NULL");
2630 } 2553 }
2631 ip_rt_put(rt); 2554 ip_rt_put(rt);
2632 } 2555 }
@@ -2644,8 +2567,8 @@ static void bond_send_gratuitous_arp(struct bonding *bond)
2644 struct vlan_entry *vlan; 2567 struct vlan_entry *vlan;
2645 struct net_device *vlan_dev; 2568 struct net_device *vlan_dev;
2646 2569
2647 pr_debug("bond_send_grat_arp: bond %s slave %s\n", bond->dev->name, 2570 pr_debug("bond_send_grat_arp: bond %s slave %s\n",
2648 slave ? slave->dev->name : "NULL"); 2571 bond->dev->name, slave ? slave->dev->name : "NULL");
2649 2572
2650 if (!slave || !bond->send_grat_arp || 2573 if (!slave || !bond->send_grat_arp ||
2651 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) 2574 test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))
@@ -2674,7 +2597,8 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32
2674 2597
2675 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) { 2598 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
2676 pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip) %d\n", 2599 pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip) %d\n",
2677 &sip, &tip, i, &targets[i], bond_has_this_ip(bond, tip)); 2600 &sip, &tip, i, &targets[i],
2601 bond_has_this_ip(bond, tip));
2678 if (sip == targets[i]) { 2602 if (sip == targets[i]) {
2679 if (bond_has_this_ip(bond, tip)) 2603 if (bond_has_this_ip(bond, tip))
2680 slave->last_arp_rx = jiffies; 2604 slave->last_arp_rx = jiffies;
@@ -2698,8 +2622,8 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
2698 read_lock(&bond->lock); 2622 read_lock(&bond->lock);
2699 2623
2700 pr_debug("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n", 2624 pr_debug("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n",
2701 bond->dev->name, skb->dev ? skb->dev->name : "NULL", 2625 bond->dev->name, skb->dev ? skb->dev->name : "NULL",
2702 orig_dev ? orig_dev->name : "NULL"); 2626 orig_dev ? orig_dev->name : "NULL");
2703 2627
2704 slave = bond_get_slave_by_dev(bond, orig_dev); 2628 slave = bond_get_slave_by_dev(bond, orig_dev);
2705 if (!slave || !slave_do_arp_validate(bond, slave)) 2629 if (!slave || !slave_do_arp_validate(bond, slave))
@@ -2724,9 +2648,9 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
2724 memcpy(&tip, arp_ptr, 4); 2648 memcpy(&tip, arp_ptr, 4);
2725 2649
2726 pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n", 2650 pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n",
2727 bond->dev->name, slave->dev->name, slave->state, 2651 bond->dev->name, slave->dev->name, slave->state,
2728 bond->params.arp_validate, slave_do_arp_validate(bond, slave), 2652 bond->params.arp_validate, slave_do_arp_validate(bond, slave),
2729 &sip, &tip); 2653 &sip, &tip);
2730 2654
2731 /* 2655 /*
2732 * Backup slaves won't see the ARP reply, but do come through 2656 * Backup slaves won't see the ARP reply, but do come through
@@ -2800,17 +2724,14 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2800 * is closed. 2724 * is closed.
2801 */ 2725 */
2802 if (!oldcurrent) { 2726 if (!oldcurrent) {
2803 pr_info(DRV_NAME 2727 pr_info("%s: link status definitely up for interface %s, ",
2804 ": %s: link status definitely " 2728 bond->dev->name,
2805 "up for interface %s, ", 2729 slave->dev->name);
2806 bond->dev->name,
2807 slave->dev->name);
2808 do_failover = 1; 2730 do_failover = 1;
2809 } else { 2731 } else {
2810 pr_info(DRV_NAME 2732 pr_info("%s: interface %s is now up\n",
2811 ": %s: interface %s is now up\n", 2733 bond->dev->name,
2812 bond->dev->name, 2734 slave->dev->name);
2813 slave->dev->name);
2814 } 2735 }
2815 } 2736 }
2816 } else { 2737 } else {
@@ -2829,10 +2750,9 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2829 if (slave->link_failure_count < UINT_MAX) 2750 if (slave->link_failure_count < UINT_MAX)
2830 slave->link_failure_count++; 2751 slave->link_failure_count++;
2831 2752
2832 pr_info(DRV_NAME 2753 pr_info("%s: interface %s is now down.\n",
2833 ": %s: interface %s is now down.\n", 2754 bond->dev->name,
2834 bond->dev->name, 2755 slave->dev->name);
2835 slave->dev->name);
2836 2756
2837 if (slave == oldcurrent) 2757 if (slave == oldcurrent)
2838 do_failover = 1; 2758 do_failover = 1;
@@ -2965,9 +2885,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
2965 slave->link = BOND_LINK_UP; 2885 slave->link = BOND_LINK_UP;
2966 bond->current_arp_slave = NULL; 2886 bond->current_arp_slave = NULL;
2967 2887
2968 pr_info(DRV_NAME 2888 pr_info("%s: link status definitely up for interface %s.\n",
2969 ": %s: link status definitely "
2970 "up for interface %s.\n",
2971 bond->dev->name, slave->dev->name); 2889 bond->dev->name, slave->dev->name);
2972 2890
2973 if (!bond->curr_active_slave || 2891 if (!bond->curr_active_slave ||
@@ -2985,9 +2903,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
2985 slave->link = BOND_LINK_DOWN; 2903 slave->link = BOND_LINK_DOWN;
2986 bond_set_slave_inactive_flags(slave); 2904 bond_set_slave_inactive_flags(slave);
2987 2905
2988 pr_info(DRV_NAME 2906 pr_info("%s: link status definitely down for interface %s, disabling it\n",
2989 ": %s: link status definitely down for "
2990 "interface %s, disabling it\n",
2991 bond->dev->name, slave->dev->name); 2907 bond->dev->name, slave->dev->name);
2992 2908
2993 if (slave == bond->curr_active_slave) { 2909 if (slave == bond->curr_active_slave) {
@@ -2998,8 +2914,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
2998 continue; 2914 continue;
2999 2915
3000 default: 2916 default:
3001 pr_err(DRV_NAME 2917 pr_err("%s: impossible: new_link %d on slave %s\n",
3002 ": %s: impossible: new_link %d on slave %s\n",
3003 bond->dev->name, slave->new_link, 2918 bond->dev->name, slave->new_link,
3004 slave->dev->name); 2919 slave->dev->name);
3005 continue; 2920 continue;
@@ -3028,9 +2943,9 @@ static void bond_ab_arp_probe(struct bonding *bond)
3028 read_lock(&bond->curr_slave_lock); 2943 read_lock(&bond->curr_slave_lock);
3029 2944
3030 if (bond->current_arp_slave && bond->curr_active_slave) 2945 if (bond->current_arp_slave && bond->curr_active_slave)
3031 pr_info(DRV_NAME "PROBE: c_arp %s && cas %s BAD\n", 2946 pr_info("PROBE: c_arp %s && cas %s BAD\n",
3032 bond->current_arp_slave->dev->name, 2947 bond->current_arp_slave->dev->name,
3033 bond->curr_active_slave->dev->name); 2948 bond->curr_active_slave->dev->name);
3034 2949
3035 if (bond->curr_active_slave) { 2950 if (bond->curr_active_slave) {
3036 bond_arp_send_all(bond, bond->curr_active_slave); 2951 bond_arp_send_all(bond, bond->curr_active_slave);
@@ -3078,9 +2993,8 @@ static void bond_ab_arp_probe(struct bonding *bond)
3078 2993
3079 bond_set_slave_inactive_flags(slave); 2994 bond_set_slave_inactive_flags(slave);
3080 2995
3081 pr_info(DRV_NAME 2996 pr_info("%s: backup interface %s is now down.\n",
3082 ": %s: backup interface %s is now down.\n", 2997 bond->dev->name, slave->dev->name);
3083 bond->dev->name, slave->dev->name);
3084 } 2998 }
3085 } 2999 }
3086} 3000}
@@ -3360,9 +3274,8 @@ static void bond_create_proc_entry(struct bonding *bond)
3360 S_IRUGO, bn->proc_dir, 3274 S_IRUGO, bn->proc_dir,
3361 &bond_info_fops, bond); 3275 &bond_info_fops, bond);
3362 if (bond->proc_entry == NULL) 3276 if (bond->proc_entry == NULL)
3363 pr_warning(DRV_NAME 3277 pr_warning("Warning: Cannot create /proc/net/%s/%s\n",
3364 ": Warning: Cannot create /proc/net/%s/%s\n", 3278 DRV_NAME, bond_dev->name);
3365 DRV_NAME, bond_dev->name);
3366 else 3279 else
3367 memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ); 3280 memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ);
3368 } 3281 }
@@ -3388,9 +3301,8 @@ static void bond_create_proc_dir(struct bond_net *bn)
3388 if (!bn->proc_dir) { 3301 if (!bn->proc_dir) {
3389 bn->proc_dir = proc_mkdir(DRV_NAME, bn->net->proc_net); 3302 bn->proc_dir = proc_mkdir(DRV_NAME, bn->net->proc_net);
3390 if (!bn->proc_dir) 3303 if (!bn->proc_dir)
3391 pr_warning(DRV_NAME 3304 pr_warning("Warning: cannot create /proc/net/%s\n",
3392 ": Warning: cannot create /proc/net/%s\n", 3305 DRV_NAME);
3393 DRV_NAME);
3394 } 3306 }
3395} 3307}
3396 3308
@@ -3539,8 +3451,8 @@ static int bond_netdev_event(struct notifier_block *this,
3539 struct net_device *event_dev = (struct net_device *)ptr; 3451 struct net_device *event_dev = (struct net_device *)ptr;
3540 3452
3541 pr_debug("event_dev: %s, event: %lx\n", 3453 pr_debug("event_dev: %s, event: %lx\n",
3542 (event_dev ? event_dev->name : "None"), 3454 event_dev ? event_dev->name : "None",
3543 event); 3455 event);
3544 3456
3545 if (!(event_dev->priv_flags & IFF_BONDING)) 3457 if (!(event_dev->priv_flags & IFF_BONDING))
3546 return NOTIFY_DONE; 3458 return NOTIFY_DONE;
@@ -3875,8 +3787,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3875 struct mii_ioctl_data *mii = NULL; 3787 struct mii_ioctl_data *mii = NULL;
3876 int res = 0; 3788 int res = 0;
3877 3789
3878 pr_debug("bond_ioctl: master=%s, cmd=%d\n", 3790 pr_debug("bond_ioctl: master=%s, cmd=%d\n", bond_dev->name, cmd);
3879 bond_dev->name, cmd);
3880 3791
3881 switch (cmd) { 3792 switch (cmd) {
3882 case SIOCGMIIPHY: 3793 case SIOCGMIIPHY:
@@ -3945,12 +3856,12 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3945 3856
3946 slave_dev = dev_get_by_name(dev_net(bond_dev), ifr->ifr_slave); 3857 slave_dev = dev_get_by_name(dev_net(bond_dev), ifr->ifr_slave);
3947 3858
3948 pr_debug("slave_dev=%p: \n", slave_dev); 3859 pr_debug("slave_dev=%p:\n", slave_dev);
3949 3860
3950 if (!slave_dev) 3861 if (!slave_dev)
3951 res = -ENODEV; 3862 res = -ENODEV;
3952 else { 3863 else {
3953 pr_debug("slave_dev->name=%s: \n", slave_dev->name); 3864 pr_debug("slave_dev->name=%s:\n", slave_dev->name);
3954 switch (cmd) { 3865 switch (cmd) {
3955 case BOND_ENSLAVE_OLD: 3866 case BOND_ENSLAVE_OLD:
3956 case SIOCBONDENSLAVE: 3867 case SIOCBONDENSLAVE:
@@ -4059,7 +3970,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
4059 int i; 3970 int i;
4060 3971
4061 pr_debug("bond=%p, name=%s, new_mtu=%d\n", bond, 3972 pr_debug("bond=%p, name=%s, new_mtu=%d\n", bond,
4062 (bond_dev ? bond_dev->name : "None"), new_mtu); 3973 (bond_dev ? bond_dev->name : "None"), new_mtu);
4063 3974
4064 /* Can't hold bond->lock with bh disabled here since 3975 /* Can't hold bond->lock with bh disabled here since
4065 * some base drivers panic. On the other hand we can't 3976 * some base drivers panic. On the other hand we can't
@@ -4077,8 +3988,10 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
4077 */ 3988 */
4078 3989
4079 bond_for_each_slave(bond, slave, i) { 3990 bond_for_each_slave(bond, slave, i) {
4080 pr_debug("s %p s->p %p c_m %p\n", slave, 3991 pr_debug("s %p s->p %p c_m %p\n",
4081 slave->prev, slave->dev->netdev_ops->ndo_change_mtu); 3992 slave,
3993 slave->prev,
3994 slave->dev->netdev_ops->ndo_change_mtu);
4082 3995
4083 res = dev_set_mtu(slave->dev, new_mtu); 3996 res = dev_set_mtu(slave->dev, new_mtu);
4084 3997
@@ -4108,8 +4021,8 @@ unwind:
4108 4021
4109 tmp_res = dev_set_mtu(slave->dev, bond_dev->mtu); 4022 tmp_res = dev_set_mtu(slave->dev, bond_dev->mtu);
4110 if (tmp_res) { 4023 if (tmp_res) {
4111 pr_debug("unwind err %d dev %s\n", tmp_res, 4024 pr_debug("unwind err %d dev %s\n",
4112 slave->dev->name); 4025 tmp_res, slave->dev->name);
4113 } 4026 }
4114 } 4027 }
4115 4028
@@ -4135,7 +4048,8 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
4135 return bond_alb_set_mac_address(bond_dev, addr); 4048 return bond_alb_set_mac_address(bond_dev, addr);
4136 4049
4137 4050
4138 pr_debug("bond=%p, name=%s\n", bond, (bond_dev ? bond_dev->name : "None")); 4051 pr_debug("bond=%p, name=%s\n",
4052 bond, bond_dev ? bond_dev->name : "None");
4139 4053
4140 /* 4054 /*
4141 * If fail_over_mac is set to active, do nothing and return 4055 * If fail_over_mac is set to active, do nothing and return
@@ -4200,8 +4114,8 @@ unwind:
4200 4114
4201 tmp_res = dev_set_mac_address(slave->dev, &tmp_sa); 4115 tmp_res = dev_set_mac_address(slave->dev, &tmp_sa);
4202 if (tmp_res) { 4116 if (tmp_res) {
4203 pr_debug("unwind err %d dev %s\n", tmp_res, 4117 pr_debug("unwind err %d dev %s\n",
4204 slave->dev->name); 4118 tmp_res, slave->dev->name);
4205 } 4119 }
4206 } 4120 }
4207 4121
@@ -4357,9 +4271,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
4357 if (tx_dev) { 4271 if (tx_dev) {
4358 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); 4272 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
4359 if (!skb2) { 4273 if (!skb2) {
4360 pr_err(DRV_NAME 4274 pr_err("%s: Error: bond_xmit_broadcast(): skb_clone() failed\n",
4361 ": %s: Error: bond_xmit_broadcast(): "
4362 "skb_clone() failed\n",
4363 bond_dev->name); 4275 bond_dev->name);
4364 continue; 4276 continue;
4365 } 4277 }
@@ -4425,8 +4337,8 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
4425 return bond_alb_xmit(skb, dev); 4337 return bond_alb_xmit(skb, dev);
4426 default: 4338 default:
4427 /* Should never happen, mode already checked */ 4339 /* Should never happen, mode already checked */
4428 pr_err(DRV_NAME ": %s: Error: Unknown bonding mode %d\n", 4340 pr_err("%s: Error: Unknown bonding mode %d\n",
4429 dev->name, bond->params.mode); 4341 dev->name, bond->params.mode);
4430 WARN_ON_ONCE(1); 4342 WARN_ON_ONCE(1);
4431 dev_kfree_skb(skb); 4343 dev_kfree_skb(skb);
4432 return NETDEV_TX_OK; 4344 return NETDEV_TX_OK;
@@ -4462,10 +4374,8 @@ void bond_set_mode_ops(struct bonding *bond, int mode)
4462 break; 4374 break;
4463 default: 4375 default:
4464 /* Should never happen, mode already checked */ 4376 /* Should never happen, mode already checked */
4465 pr_err(DRV_NAME 4377 pr_err("%s: Error: Unknown bonding mode %d\n",
4466 ": %s: Error: Unknown bonding mode %d\n", 4378 bond_dev->name, mode);
4467 bond_dev->name,
4468 mode);
4469 break; 4379 break;
4470 } 4380 }
4471} 4381}
@@ -4650,8 +4560,7 @@ static int bond_check_params(struct bond_params *params)
4650 if (mode) { 4560 if (mode) {
4651 bond_mode = bond_parse_parm(mode, bond_mode_tbl); 4561 bond_mode = bond_parse_parm(mode, bond_mode_tbl);
4652 if (bond_mode == -1) { 4562 if (bond_mode == -1) {
4653 pr_err(DRV_NAME 4563 pr_err("Error: Invalid bonding mode \"%s\"\n",
4654 ": Error: Invalid bonding mode \"%s\"\n",
4655 mode == NULL ? "NULL" : mode); 4564 mode == NULL ? "NULL" : mode);
4656 return -EINVAL; 4565 return -EINVAL;
4657 } 4566 }
@@ -4660,16 +4569,13 @@ static int bond_check_params(struct bond_params *params)
4660 if (xmit_hash_policy) { 4569 if (xmit_hash_policy) {
4661 if ((bond_mode != BOND_MODE_XOR) && 4570 if ((bond_mode != BOND_MODE_XOR) &&
4662 (bond_mode != BOND_MODE_8023AD)) { 4571 (bond_mode != BOND_MODE_8023AD)) {
4663 pr_info(DRV_NAME 4572 pr_info("xmit_hash_policy param is irrelevant in mode %s\n",
4664 ": xmit_hash_policy param is irrelevant in"
4665 " mode %s\n",
4666 bond_mode_name(bond_mode)); 4573 bond_mode_name(bond_mode));
4667 } else { 4574 } else {
4668 xmit_hashtype = bond_parse_parm(xmit_hash_policy, 4575 xmit_hashtype = bond_parse_parm(xmit_hash_policy,
4669 xmit_hashtype_tbl); 4576 xmit_hashtype_tbl);
4670 if (xmit_hashtype == -1) { 4577 if (xmit_hashtype == -1) {
4671 pr_err(DRV_NAME 4578 pr_err("Error: Invalid xmit_hash_policy \"%s\"\n",
4672 ": Error: Invalid xmit_hash_policy \"%s\"\n",
4673 xmit_hash_policy == NULL ? "NULL" : 4579 xmit_hash_policy == NULL ? "NULL" :
4674 xmit_hash_policy); 4580 xmit_hash_policy);
4675 return -EINVAL; 4581 return -EINVAL;
@@ -4679,14 +4585,12 @@ static int bond_check_params(struct bond_params *params)
4679 4585
4680 if (lacp_rate) { 4586 if (lacp_rate) {
4681 if (bond_mode != BOND_MODE_8023AD) { 4587 if (bond_mode != BOND_MODE_8023AD) {
4682 pr_info(DRV_NAME 4588 pr_info("lacp_rate param is irrelevant in mode %s\n",
4683 ": lacp_rate param is irrelevant in mode %s\n", 4589 bond_mode_name(bond_mode));
4684 bond_mode_name(bond_mode));
4685 } else { 4590 } else {
4686 lacp_fast = bond_parse_parm(lacp_rate, bond_lacp_tbl); 4591 lacp_fast = bond_parse_parm(lacp_rate, bond_lacp_tbl);
4687 if (lacp_fast == -1) { 4592 if (lacp_fast == -1) {
4688 pr_err(DRV_NAME 4593 pr_err("Error: Invalid lacp rate \"%s\"\n",
4689 ": Error: Invalid lacp rate \"%s\"\n",
4690 lacp_rate == NULL ? "NULL" : lacp_rate); 4594 lacp_rate == NULL ? "NULL" : lacp_rate);
4691 return -EINVAL; 4595 return -EINVAL;
4692 } 4596 }
@@ -4696,82 +4600,64 @@ static int bond_check_params(struct bond_params *params)
4696 if (ad_select) { 4600 if (ad_select) {
4697 params->ad_select = bond_parse_parm(ad_select, ad_select_tbl); 4601 params->ad_select = bond_parse_parm(ad_select, ad_select_tbl);
4698 if (params->ad_select == -1) { 4602 if (params->ad_select == -1) {
4699 pr_err(DRV_NAME 4603 pr_err("Error: Invalid ad_select \"%s\"\n",
4700 ": Error: Invalid ad_select \"%s\"\n",
4701 ad_select == NULL ? "NULL" : ad_select); 4604 ad_select == NULL ? "NULL" : ad_select);
4702 return -EINVAL; 4605 return -EINVAL;
4703 } 4606 }
4704 4607
4705 if (bond_mode != BOND_MODE_8023AD) { 4608 if (bond_mode != BOND_MODE_8023AD) {
4706 pr_warning(DRV_NAME 4609 pr_warning("ad_select param only affects 802.3ad mode\n");
4707 ": ad_select param only affects 802.3ad mode\n");
4708 } 4610 }
4709 } else { 4611 } else {
4710 params->ad_select = BOND_AD_STABLE; 4612 params->ad_select = BOND_AD_STABLE;
4711 } 4613 }
4712 4614
4713 if (max_bonds < 0) { 4615 if (max_bonds < 0) {
4714 pr_warning(DRV_NAME 4616 pr_warning("Warning: max_bonds (%d) not in range %d-%d, so it was reset to BOND_DEFAULT_MAX_BONDS (%d)\n",
4715 ": Warning: max_bonds (%d) not in range %d-%d, so it " 4617 max_bonds, 0, INT_MAX, BOND_DEFAULT_MAX_BONDS);
4716 "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n",
4717 max_bonds, 0, INT_MAX, BOND_DEFAULT_MAX_BONDS);
4718 max_bonds = BOND_DEFAULT_MAX_BONDS; 4618 max_bonds = BOND_DEFAULT_MAX_BONDS;
4719 } 4619 }
4720 4620
4721 if (miimon < 0) { 4621 if (miimon < 0) {
4722 pr_warning(DRV_NAME 4622 pr_warning("Warning: miimon module parameter (%d), not in range 0-%d, so it was reset to %d\n",
4723 ": Warning: miimon module parameter (%d), " 4623 miimon, INT_MAX, BOND_LINK_MON_INTERV);
4724 "not in range 0-%d, so it was reset to %d\n",
4725 miimon, INT_MAX, BOND_LINK_MON_INTERV);
4726 miimon = BOND_LINK_MON_INTERV; 4624 miimon = BOND_LINK_MON_INTERV;
4727 } 4625 }
4728 4626
4729 if (updelay < 0) { 4627 if (updelay < 0) {
4730 pr_warning(DRV_NAME 4628 pr_warning("Warning: updelay module parameter (%d), not in range 0-%d, so it was reset to 0\n",
4731 ": Warning: updelay module parameter (%d), " 4629 updelay, INT_MAX);
4732 "not in range 0-%d, so it was reset to 0\n",
4733 updelay, INT_MAX);
4734 updelay = 0; 4630 updelay = 0;
4735 } 4631 }
4736 4632
4737 if (downdelay < 0) { 4633 if (downdelay < 0) {
4738 pr_warning(DRV_NAME 4634 pr_warning("Warning: downdelay module parameter (%d), not in range 0-%d, so it was reset to 0\n",
4739 ": Warning: downdelay module parameter (%d), " 4635 downdelay, INT_MAX);
4740 "not in range 0-%d, so it was reset to 0\n",
4741 downdelay, INT_MAX);
4742 downdelay = 0; 4636 downdelay = 0;
4743 } 4637 }
4744 4638
4745 if ((use_carrier != 0) && (use_carrier != 1)) { 4639 if ((use_carrier != 0) && (use_carrier != 1)) {
4746 pr_warning(DRV_NAME 4640 pr_warning("Warning: use_carrier module parameter (%d), not of valid value (0/1), so it was set to 1\n",
4747 ": Warning: use_carrier module parameter (%d), " 4641 use_carrier);
4748 "not of valid value (0/1), so it was set to 1\n",
4749 use_carrier);
4750 use_carrier = 1; 4642 use_carrier = 1;
4751 } 4643 }
4752 4644
4753 if (num_grat_arp < 0 || num_grat_arp > 255) { 4645 if (num_grat_arp < 0 || num_grat_arp > 255) {
4754 pr_warning(DRV_NAME 4646 pr_warning("Warning: num_grat_arp (%d) not in range 0-255 so it was reset to 1 \n",
4755 ": Warning: num_grat_arp (%d) not in range 0-255 so it " 4647 num_grat_arp);
4756 "was reset to 1 \n", num_grat_arp);
4757 num_grat_arp = 1; 4648 num_grat_arp = 1;
4758 } 4649 }
4759 4650
4760 if (num_unsol_na < 0 || num_unsol_na > 255) { 4651 if (num_unsol_na < 0 || num_unsol_na > 255) {
4761 pr_warning(DRV_NAME 4652 pr_warning("Warning: num_unsol_na (%d) not in range 0-255 so it was reset to 1 \n",
4762 ": Warning: num_unsol_na (%d) not in range 0-255 so it " 4653 num_unsol_na);
4763 "was reset to 1 \n", num_unsol_na);
4764 num_unsol_na = 1; 4654 num_unsol_na = 1;
4765 } 4655 }
4766 4656
4767 /* reset values for 802.3ad */ 4657 /* reset values for 802.3ad */
4768 if (bond_mode == BOND_MODE_8023AD) { 4658 if (bond_mode == BOND_MODE_8023AD) {
4769 if (!miimon) { 4659 if (!miimon) {
4770 pr_warning(DRV_NAME 4660 pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n");
4771 ": Warning: miimon must be specified, "
4772 "otherwise bonding will not detect link "
4773 "failure, speed and duplex which are "
4774 "essential for 802.3ad operation\n");
4775 pr_warning("Forcing miimon to 100msec\n"); 4661 pr_warning("Forcing miimon to 100msec\n");
4776 miimon = 100; 4662 miimon = 100;
4777 } 4663 }
@@ -4781,24 +4667,15 @@ static int bond_check_params(struct bond_params *params)
4781 if ((bond_mode == BOND_MODE_TLB) || 4667 if ((bond_mode == BOND_MODE_TLB) ||
4782 (bond_mode == BOND_MODE_ALB)) { 4668 (bond_mode == BOND_MODE_ALB)) {
4783 if (!miimon) { 4669 if (!miimon) {
4784 pr_warning(DRV_NAME 4670 pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure and link speed which are essential for TLB/ALB load balancing\n");
4785 ": Warning: miimon must be specified, "
4786 "otherwise bonding will not detect link "
4787 "failure and link speed which are essential "
4788 "for TLB/ALB load balancing\n");
4789 pr_warning("Forcing miimon to 100msec\n"); 4671 pr_warning("Forcing miimon to 100msec\n");
4790 miimon = 100; 4672 miimon = 100;
4791 } 4673 }
4792 } 4674 }
4793 4675
4794 if (bond_mode == BOND_MODE_ALB) { 4676 if (bond_mode == BOND_MODE_ALB) {
4795 pr_notice(DRV_NAME 4677 pr_notice("In ALB mode you might experience client disconnections upon reconnection of a link if the bonding module updelay parameter (%d msec) is incompatible with the forwarding delay time of the switch\n",
4796 ": In ALB mode you might experience client " 4678 updelay);
4797 "disconnections upon reconnection of a link if the "
4798 "bonding module updelay parameter (%d msec) is "
4799 "incompatible with the forwarding delay time of the "
4800 "switch\n",
4801 updelay);
4802 } 4679 }
4803 4680
4804 if (!miimon) { 4681 if (!miimon) {
@@ -4806,49 +4683,37 @@ static int bond_check_params(struct bond_params *params)
4806 /* just warn the user the up/down delay will have 4683 /* just warn the user the up/down delay will have
4807 * no effect since miimon is zero... 4684 * no effect since miimon is zero...
4808 */ 4685 */
4809 pr_warning(DRV_NAME 4686 pr_warning("Warning: miimon module parameter not set and updelay (%d) or downdelay (%d) module parameter is set; updelay and downdelay have no effect unless miimon is set\n",
4810 ": Warning: miimon module parameter not set " 4687 updelay, downdelay);
4811 "and updelay (%d) or downdelay (%d) module "
4812 "parameter is set; updelay and downdelay have "
4813 "no effect unless miimon is set\n",
4814 updelay, downdelay);
4815 } 4688 }
4816 } else { 4689 } else {
4817 /* don't allow arp monitoring */ 4690 /* don't allow arp monitoring */
4818 if (arp_interval) { 4691 if (arp_interval) {
4819 pr_warning(DRV_NAME 4692 pr_warning("Warning: miimon (%d) and arp_interval (%d) can't be used simultaneously, disabling ARP monitoring\n",
4820 ": Warning: miimon (%d) and arp_interval (%d) " 4693 miimon, arp_interval);
4821 "can't be used simultaneously, disabling ARP "
4822 "monitoring\n",
4823 miimon, arp_interval);
4824 arp_interval = 0; 4694 arp_interval = 0;
4825 } 4695 }
4826 4696
4827 if ((updelay % miimon) != 0) { 4697 if ((updelay % miimon) != 0) {
4828 pr_warning(DRV_NAME 4698 pr_warning("Warning: updelay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
4829 ": Warning: updelay (%d) is not a multiple " 4699 updelay, miimon,
4830 "of miimon (%d), updelay rounded to %d ms\n", 4700 (updelay / miimon) * miimon);
4831 updelay, miimon, (updelay / miimon) * miimon);
4832 } 4701 }
4833 4702
4834 updelay /= miimon; 4703 updelay /= miimon;
4835 4704
4836 if ((downdelay % miimon) != 0) { 4705 if ((downdelay % miimon) != 0) {
4837 pr_warning(DRV_NAME 4706 pr_warning("Warning: downdelay (%d) is not a multiple of miimon (%d), downdelay rounded to %d ms\n",
4838 ": Warning: downdelay (%d) is not a multiple " 4707 downdelay, miimon,
4839 "of miimon (%d), downdelay rounded to %d ms\n", 4708 (downdelay / miimon) * miimon);
4840 downdelay, miimon,
4841 (downdelay / miimon) * miimon);
4842 } 4709 }
4843 4710
4844 downdelay /= miimon; 4711 downdelay /= miimon;
4845 } 4712 }
4846 4713
4847 if (arp_interval < 0) { 4714 if (arp_interval < 0) {
4848 pr_warning(DRV_NAME 4715 pr_warning("Warning: arp_interval module parameter (%d) , not in range 0-%d, so it was reset to %d\n",
4849 ": Warning: arp_interval module parameter (%d) " 4716 arp_interval, INT_MAX, BOND_LINK_ARP_INTERV);
4850 ", not in range 0-%d, so it was reset to %d\n",
4851 arp_interval, INT_MAX, BOND_LINK_ARP_INTERV);
4852 arp_interval = BOND_LINK_ARP_INTERV; 4717 arp_interval = BOND_LINK_ARP_INTERV;
4853 } 4718 }
4854 4719
@@ -4858,10 +4723,8 @@ static int bond_check_params(struct bond_params *params)
4858 /* not complete check, but should be good enough to 4723 /* not complete check, but should be good enough to
4859 catch mistakes */ 4724 catch mistakes */
4860 if (!isdigit(arp_ip_target[arp_ip_count][0])) { 4725 if (!isdigit(arp_ip_target[arp_ip_count][0])) {
4861 pr_warning(DRV_NAME 4726 pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n",
4862 ": Warning: bad arp_ip_target module parameter " 4727 arp_ip_target[arp_ip_count]);
4863 "(%s), ARP monitoring will not be performed\n",
4864 arp_ip_target[arp_ip_count]);
4865 arp_interval = 0; 4728 arp_interval = 0;
4866 } else { 4729 } else {
4867 __be32 ip = in_aton(arp_ip_target[arp_ip_count]); 4730 __be32 ip = in_aton(arp_ip_target[arp_ip_count]);
@@ -4871,31 +4734,25 @@ static int bond_check_params(struct bond_params *params)
4871 4734
4872 if (arp_interval && !arp_ip_count) { 4735 if (arp_interval && !arp_ip_count) {
4873 /* don't allow arping if no arp_ip_target given... */ 4736 /* don't allow arping if no arp_ip_target given... */
4874 pr_warning(DRV_NAME 4737 pr_warning("Warning: arp_interval module parameter (%d) specified without providing an arp_ip_target parameter, arp_interval was reset to 0\n",
4875 ": Warning: arp_interval module parameter (%d) " 4738 arp_interval);
4876 "specified without providing an arp_ip_target "
4877 "parameter, arp_interval was reset to 0\n",
4878 arp_interval);
4879 arp_interval = 0; 4739 arp_interval = 0;
4880 } 4740 }
4881 4741
4882 if (arp_validate) { 4742 if (arp_validate) {
4883 if (bond_mode != BOND_MODE_ACTIVEBACKUP) { 4743 if (bond_mode != BOND_MODE_ACTIVEBACKUP) {
4884 pr_err(DRV_NAME 4744 pr_err("arp_validate only supported in active-backup mode\n");
4885 ": arp_validate only supported in active-backup mode\n");
4886 return -EINVAL; 4745 return -EINVAL;
4887 } 4746 }
4888 if (!arp_interval) { 4747 if (!arp_interval) {
4889 pr_err(DRV_NAME 4748 pr_err("arp_validate requires arp_interval\n");
4890 ": arp_validate requires arp_interval\n");
4891 return -EINVAL; 4749 return -EINVAL;
4892 } 4750 }
4893 4751
4894 arp_validate_value = bond_parse_parm(arp_validate, 4752 arp_validate_value = bond_parse_parm(arp_validate,
4895 arp_validate_tbl); 4753 arp_validate_tbl);
4896 if (arp_validate_value == -1) { 4754 if (arp_validate_value == -1) {
4897 pr_err(DRV_NAME 4755 pr_err("Error: invalid arp_validate \"%s\"\n",
4898 ": Error: invalid arp_validate \"%s\"\n",
4899 arp_validate == NULL ? "NULL" : arp_validate); 4756 arp_validate == NULL ? "NULL" : arp_validate);
4900 return -EINVAL; 4757 return -EINVAL;
4901 } 4758 }
@@ -4903,17 +4760,14 @@ static int bond_check_params(struct bond_params *params)
4903 arp_validate_value = 0; 4760 arp_validate_value = 0;
4904 4761
4905 if (miimon) { 4762 if (miimon) {
4906 pr_info(DRV_NAME 4763 pr_info("MII link monitoring set to %d ms\n", miimon);
4907 ": MII link monitoring set to %d ms\n",
4908 miimon);
4909 } else if (arp_interval) { 4764 } else if (arp_interval) {
4910 int i; 4765 int i;
4911 4766
4912 pr_info(DRV_NAME ": ARP monitoring set to %d ms," 4767 pr_info("ARP monitoring set to %d ms, validate %s, with %d target(s):",
4913 " validate %s, with %d target(s):", 4768 arp_interval,
4914 arp_interval, 4769 arp_validate_tbl[arp_validate_value].modename,
4915 arp_validate_tbl[arp_validate_value].modename, 4770 arp_ip_count);
4916 arp_ip_count);
4917 4771
4918 for (i = 0; i < arp_ip_count; i++) 4772 for (i = 0; i < arp_ip_count; i++)
4919 pr_info(" %s", arp_ip_target[i]); 4773 pr_info(" %s", arp_ip_target[i]);
@@ -4924,21 +4778,15 @@ static int bond_check_params(struct bond_params *params)
4924 /* miimon and arp_interval not set, we need one so things 4778 /* miimon and arp_interval not set, we need one so things
4925 * work as expected, see bonding.txt for details 4779 * work as expected, see bonding.txt for details
4926 */ 4780 */
4927 pr_warning(DRV_NAME 4781 pr_warning("Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details.\n");
4928 ": Warning: either miimon or arp_interval and "
4929 "arp_ip_target module parameters must be specified, "
4930 "otherwise bonding will not detect link failures! see "
4931 "bonding.txt for details.\n");
4932 } 4782 }
4933 4783
4934 if (primary && !USES_PRIMARY(bond_mode)) { 4784 if (primary && !USES_PRIMARY(bond_mode)) {
4935 /* currently, using a primary only makes sense 4785 /* currently, using a primary only makes sense
4936 * in active backup, TLB or ALB modes 4786 * in active backup, TLB or ALB modes
4937 */ 4787 */
4938 pr_warning(DRV_NAME 4788 pr_warning("Warning: %s primary device specified but has no effect in %s mode\n",
4939 ": Warning: %s primary device specified but has no " 4789 primary, bond_mode_name(bond_mode));
4940 "effect in %s mode\n",
4941 primary, bond_mode_name(bond_mode));
4942 primary = NULL; 4790 primary = NULL;
4943 } 4791 }
4944 4792
@@ -4946,8 +4794,7 @@ static int bond_check_params(struct bond_params *params)
4946 primary_reselect_value = bond_parse_parm(primary_reselect, 4794 primary_reselect_value = bond_parse_parm(primary_reselect,
4947 pri_reselect_tbl); 4795 pri_reselect_tbl);
4948 if (primary_reselect_value == -1) { 4796 if (primary_reselect_value == -1) {
4949 pr_err(DRV_NAME 4797 pr_err("Error: Invalid primary_reselect \"%s\"\n",
4950 ": Error: Invalid primary_reselect \"%s\"\n",
4951 primary_reselect == 4798 primary_reselect ==
4952 NULL ? "NULL" : primary_reselect); 4799 NULL ? "NULL" : primary_reselect);
4953 return -EINVAL; 4800 return -EINVAL;
@@ -4960,16 +4807,13 @@ static int bond_check_params(struct bond_params *params)
4960 fail_over_mac_value = bond_parse_parm(fail_over_mac, 4807 fail_over_mac_value = bond_parse_parm(fail_over_mac,
4961 fail_over_mac_tbl); 4808 fail_over_mac_tbl);
4962 if (fail_over_mac_value == -1) { 4809 if (fail_over_mac_value == -1) {
4963 pr_err(DRV_NAME 4810 pr_err("Error: invalid fail_over_mac \"%s\"\n",
4964 ": Error: invalid fail_over_mac \"%s\"\n",
4965 arp_validate == NULL ? "NULL" : arp_validate); 4811 arp_validate == NULL ? "NULL" : arp_validate);
4966 return -EINVAL; 4812 return -EINVAL;
4967 } 4813 }
4968 4814
4969 if (bond_mode != BOND_MODE_ACTIVEBACKUP) 4815 if (bond_mode != BOND_MODE_ACTIVEBACKUP)
4970 pr_warning(DRV_NAME 4816 pr_warning("Warning: fail_over_mac only affects active-backup mode.\n");
4971 ": Warning: fail_over_mac only affects "
4972 "active-backup mode.\n");
4973 } else { 4817 } else {
4974 fail_over_mac_value = BOND_FOM_NONE; 4818 fail_over_mac_value = BOND_FOM_NONE;
4975 } 4819 }
@@ -5076,8 +4920,7 @@ int bond_create(struct net *net, const char *name)
5076 bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "", 4920 bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "",
5077 bond_setup); 4921 bond_setup);
5078 if (!bond_dev) { 4922 if (!bond_dev) {
5079 pr_err(DRV_NAME ": %s: eek! can't alloc netdev!\n", 4923 pr_err("%s: eek! can't alloc netdev!\n", name);
5080 name);
5081 res = -ENOMEM; 4924 res = -ENOMEM;
5082 goto out; 4925 goto out;
5083 } 4926 }
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 4e00b4f83641..5acd557cea9b 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -19,6 +19,9 @@
19 * file called LICENSE. 19 * file called LICENSE.
20 * 20 *
21 */ 21 */
22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
22#include <linux/kernel.h> 25#include <linux/kernel.h>
23#include <linux/module.h> 26#include <linux/module.h>
24#include <linux/device.h> 27#include <linux/device.h>
@@ -109,11 +112,10 @@ static ssize_t bonding_store_bonds(struct class *cls,
109 goto err_no_cmd; 112 goto err_no_cmd;
110 113
111 if (command[0] == '+') { 114 if (command[0] == '+') {
112 pr_info(DRV_NAME 115 pr_info("%s is being created...\n", ifname);
113 ": %s is being created...\n", ifname);
114 rv = bond_create(net, ifname); 116 rv = bond_create(net, ifname);
115 if (rv) { 117 if (rv) {
116 pr_info(DRV_NAME ": Bond creation failed.\n"); 118 pr_info("Bond creation failed.\n");
117 res = rv; 119 res = rv;
118 } 120 }
119 } else if (command[0] == '-') { 121 } else if (command[0] == '-') {
@@ -122,12 +124,10 @@ static ssize_t bonding_store_bonds(struct class *cls,
122 rtnl_lock(); 124 rtnl_lock();
123 bond_dev = bond_get_by_name(net, ifname); 125 bond_dev = bond_get_by_name(net, ifname);
124 if (bond_dev) { 126 if (bond_dev) {
125 pr_info(DRV_NAME ": %s is being deleted...\n", 127 pr_info("%s is being deleted...\n", ifname);
126 ifname);
127 unregister_netdevice(bond_dev); 128 unregister_netdevice(bond_dev);
128 } else { 129 } else {
129 pr_err(DRV_NAME ": unable to delete non-existent %s\n", 130 pr_err("unable to delete non-existent %s\n", ifname);
130 ifname);
131 res = -ENODEV; 131 res = -ENODEV;
132 } 132 }
133 rtnl_unlock(); 133 rtnl_unlock();
@@ -140,8 +140,7 @@ static ssize_t bonding_store_bonds(struct class *cls,
140 return res; 140 return res;
141 141
142err_no_cmd: 142err_no_cmd:
143 pr_err(DRV_NAME ": no command found in bonding_masters." 143 pr_err("no command found in bonding_masters. Use +ifname or -ifname.\n");
144 " Use +ifname or -ifname.\n");
145 return -EPERM; 144 return -EPERM;
146} 145}
147 146
@@ -225,8 +224,8 @@ static ssize_t bonding_store_slaves(struct device *d,
225 224
226 /* Quick sanity check -- is the bond interface up? */ 225 /* Quick sanity check -- is the bond interface up? */
227 if (!(bond->dev->flags & IFF_UP)) { 226 if (!(bond->dev->flags & IFF_UP)) {
228 pr_warning(DRV_NAME ": %s: doing slave updates when " 227 pr_warning("%s: doing slave updates when interface is down.\n",
229 "interface is down.\n", bond->dev->name); 228 bond->dev->name);
230 } 229 }
231 230
232 /* Note: We can't hold bond->lock here, as bond_create grabs it. */ 231 /* Note: We can't hold bond->lock here, as bond_create grabs it. */
@@ -247,17 +246,14 @@ static ssize_t bonding_store_slaves(struct device *d,
247 246
248 dev = __dev_get_by_name(dev_net(bond->dev), ifname); 247 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
249 if (!dev) { 248 if (!dev) {
250 pr_info(DRV_NAME 249 pr_info("%s: Interface %s does not exist!\n",
251 ": %s: Interface %s does not exist!\n", 250 bond->dev->name, ifname);
252 bond->dev->name, ifname);
253 ret = -ENODEV; 251 ret = -ENODEV;
254 goto out; 252 goto out;
255 } 253 }
256 254
257 if (dev->flags & IFF_UP) { 255 if (dev->flags & IFF_UP) {
258 pr_err(DRV_NAME 256 pr_err("%s: Error: Unable to enslave %s because it is already up.\n",
259 ": %s: Error: Unable to enslave %s "
260 "because it is already up.\n",
261 bond->dev->name, dev->name); 257 bond->dev->name, dev->name);
262 ret = -EPERM; 258 ret = -EPERM;
263 goto out; 259 goto out;
@@ -266,8 +262,7 @@ static ssize_t bonding_store_slaves(struct device *d,
266 read_lock(&bond->lock); 262 read_lock(&bond->lock);
267 bond_for_each_slave(bond, slave, i) 263 bond_for_each_slave(bond, slave, i)
268 if (slave->dev == dev) { 264 if (slave->dev == dev) {
269 pr_err(DRV_NAME 265 pr_err("%s: Interface %s is already enslaved!\n",
270 ": %s: Interface %s is already enslaved!\n",
271 bond->dev->name, ifname); 266 bond->dev->name, ifname);
272 ret = -EPERM; 267 ret = -EPERM;
273 read_unlock(&bond->lock); 268 read_unlock(&bond->lock);
@@ -275,8 +270,7 @@ static ssize_t bonding_store_slaves(struct device *d,
275 } 270 }
276 read_unlock(&bond->lock); 271 read_unlock(&bond->lock);
277 272
278 pr_info(DRV_NAME ": %s: Adding slave %s.\n", 273 pr_info("%s: Adding slave %s.\n", bond->dev->name, ifname);
279 bond->dev->name, ifname);
280 274
281 /* If this is the first slave, then we need to set 275 /* If this is the first slave, then we need to set
282 the master's hardware address to be the same as the 276 the master's hardware address to be the same as the
@@ -313,7 +307,7 @@ static ssize_t bonding_store_slaves(struct device *d,
313 break; 307 break;
314 } 308 }
315 if (dev) { 309 if (dev) {
316 pr_info(DRV_NAME ": %s: Removing slave %s\n", 310 pr_info("%s: Removing slave %s\n",
317 bond->dev->name, dev->name); 311 bond->dev->name, dev->name);
318 res = bond_release(bond->dev, dev); 312 res = bond_release(bond->dev, dev);
319 if (res) { 313 if (res) {
@@ -323,16 +317,16 @@ static ssize_t bonding_store_slaves(struct device *d,
323 /* set the slave MTU to the default */ 317 /* set the slave MTU to the default */
324 dev_set_mtu(dev, original_mtu); 318 dev_set_mtu(dev, original_mtu);
325 } else { 319 } else {
326 pr_err(DRV_NAME ": unable to remove non-existent" 320 pr_err("unable to remove non-existent slave %s for bond %s.\n",
327 " slave %s for bond %s.\n", 321 ifname, bond->dev->name);
328 ifname, bond->dev->name);
329 ret = -ENODEV; 322 ret = -ENODEV;
330 } 323 }
331 goto out; 324 goto out;
332 } 325 }
333 326
334err_no_cmd: 327err_no_cmd:
335 pr_err(DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); 328 pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n",
329 bond->dev->name);
336 ret = -EPERM; 330 ret = -EPERM;
337 331
338out: 332out:
@@ -365,18 +359,16 @@ static ssize_t bonding_store_mode(struct device *d,
365 struct bonding *bond = to_bond(d); 359 struct bonding *bond = to_bond(d);
366 360
367 if (bond->dev->flags & IFF_UP) { 361 if (bond->dev->flags & IFF_UP) {
368 pr_err(DRV_NAME ": unable to update mode of %s" 362 pr_err("unable to update mode of %s because interface is up.\n",
369 " because interface is up.\n", bond->dev->name); 363 bond->dev->name);
370 ret = -EPERM; 364 ret = -EPERM;
371 goto out; 365 goto out;
372 } 366 }
373 367
374 new_value = bond_parse_parm(buf, bond_mode_tbl); 368 new_value = bond_parse_parm(buf, bond_mode_tbl);
375 if (new_value < 0) { 369 if (new_value < 0) {
376 pr_err(DRV_NAME 370 pr_err("%s: Ignoring invalid mode value %.*s.\n",
377 ": %s: Ignoring invalid mode value %.*s.\n", 371 bond->dev->name, (int)strlen(buf) - 1, buf);
378 bond->dev->name,
379 (int)strlen(buf) - 1, buf);
380 ret = -EINVAL; 372 ret = -EINVAL;
381 goto out; 373 goto out;
382 } else { 374 } else {
@@ -388,8 +380,8 @@ static ssize_t bonding_store_mode(struct device *d,
388 380
389 bond->params.mode = new_value; 381 bond->params.mode = new_value;
390 bond_set_mode_ops(bond, bond->params.mode); 382 bond_set_mode_ops(bond, bond->params.mode);
391 pr_info(DRV_NAME ": %s: setting mode to %s (%d).\n", 383 pr_info("%s: setting mode to %s (%d).\n",
392 bond->dev->name, bond_mode_tbl[new_value].modename, 384 bond->dev->name, bond_mode_tbl[new_value].modename,
393 new_value); 385 new_value);
394 } 386 }
395out: 387out:
@@ -421,8 +413,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
421 struct bonding *bond = to_bond(d); 413 struct bonding *bond = to_bond(d);
422 414
423 if (bond->dev->flags & IFF_UP) { 415 if (bond->dev->flags & IFF_UP) {
424 pr_err(DRV_NAME 416 pr_err("%s: Interface is up. Unable to update xmit policy.\n",
425 "%s: Interface is up. Unable to update xmit policy.\n",
426 bond->dev->name); 417 bond->dev->name);
427 ret = -EPERM; 418 ret = -EPERM;
428 goto out; 419 goto out;
@@ -430,8 +421,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
430 421
431 new_value = bond_parse_parm(buf, xmit_hashtype_tbl); 422 new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
432 if (new_value < 0) { 423 if (new_value < 0) {
433 pr_err(DRV_NAME 424 pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
434 ": %s: Ignoring invalid xmit hash policy value %.*s.\n",
435 bond->dev->name, 425 bond->dev->name,
436 (int)strlen(buf) - 1, buf); 426 (int)strlen(buf) - 1, buf);
437 ret = -EINVAL; 427 ret = -EINVAL;
@@ -439,7 +429,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
439 } else { 429 } else {
440 bond->params.xmit_policy = new_value; 430 bond->params.xmit_policy = new_value;
441 bond_set_mode_ops(bond, bond->params.mode); 431 bond_set_mode_ops(bond, bond->params.mode);
442 pr_info(DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", 432 pr_info("%s: setting xmit hash policy to %s (%d).\n",
443 bond->dev->name, 433 bond->dev->name,
444 xmit_hashtype_tbl[new_value].modename, new_value); 434 xmit_hashtype_tbl[new_value].modename, new_value);
445 } 435 }
@@ -472,20 +462,18 @@ static ssize_t bonding_store_arp_validate(struct device *d,
472 462
473 new_value = bond_parse_parm(buf, arp_validate_tbl); 463 new_value = bond_parse_parm(buf, arp_validate_tbl);
474 if (new_value < 0) { 464 if (new_value < 0) {
475 pr_err(DRV_NAME 465 pr_err("%s: Ignoring invalid arp_validate value %s\n",
476 ": %s: Ignoring invalid arp_validate value %s\n",
477 bond->dev->name, buf); 466 bond->dev->name, buf);
478 return -EINVAL; 467 return -EINVAL;
479 } 468 }
480 if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { 469 if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
481 pr_err(DRV_NAME 470 pr_err("%s: arp_validate only supported in active-backup mode.\n",
482 ": %s: arp_validate only supported in active-backup mode.\n",
483 bond->dev->name); 471 bond->dev->name);
484 return -EINVAL; 472 return -EINVAL;
485 } 473 }
486 pr_info(DRV_NAME ": %s: setting arp_validate to %s (%d).\n", 474 pr_info("%s: setting arp_validate to %s (%d).\n",
487 bond->dev->name, arp_validate_tbl[new_value].modename, 475 bond->dev->name, arp_validate_tbl[new_value].modename,
488 new_value); 476 new_value);
489 477
490 if (!bond->params.arp_validate && new_value) 478 if (!bond->params.arp_validate && new_value)
491 bond_register_arp(bond); 479 bond_register_arp(bond);
@@ -523,24 +511,22 @@ static ssize_t bonding_store_fail_over_mac(struct device *d,
523 struct bonding *bond = to_bond(d); 511 struct bonding *bond = to_bond(d);
524 512
525 if (bond->slave_cnt != 0) { 513 if (bond->slave_cnt != 0) {
526 pr_err(DRV_NAME 514 pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
527 ": %s: Can't alter fail_over_mac with slaves in bond.\n",
528 bond->dev->name); 515 bond->dev->name);
529 return -EPERM; 516 return -EPERM;
530 } 517 }
531 518
532 new_value = bond_parse_parm(buf, fail_over_mac_tbl); 519 new_value = bond_parse_parm(buf, fail_over_mac_tbl);
533 if (new_value < 0) { 520 if (new_value < 0) {
534 pr_err(DRV_NAME 521 pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
535 ": %s: Ignoring invalid fail_over_mac value %s.\n",
536 bond->dev->name, buf); 522 bond->dev->name, buf);
537 return -EINVAL; 523 return -EINVAL;
538 } 524 }
539 525
540 bond->params.fail_over_mac = new_value; 526 bond->params.fail_over_mac = new_value;
541 pr_info(DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n", 527 pr_info("%s: Setting fail_over_mac to %s (%d).\n",
542 bond->dev->name, fail_over_mac_tbl[new_value].modename, 528 bond->dev->name, fail_over_mac_tbl[new_value].modename,
543 new_value); 529 new_value);
544 530
545 return count; 531 return count;
546} 532}
@@ -571,31 +557,26 @@ static ssize_t bonding_store_arp_interval(struct device *d,
571 struct bonding *bond = to_bond(d); 557 struct bonding *bond = to_bond(d);
572 558
573 if (sscanf(buf, "%d", &new_value) != 1) { 559 if (sscanf(buf, "%d", &new_value) != 1) {
574 pr_err(DRV_NAME 560 pr_err("%s: no arp_interval value specified.\n",
575 ": %s: no arp_interval value specified.\n",
576 bond->dev->name); 561 bond->dev->name);
577 ret = -EINVAL; 562 ret = -EINVAL;
578 goto out; 563 goto out;
579 } 564 }
580 if (new_value < 0) { 565 if (new_value < 0) {
581 pr_err(DRV_NAME 566 pr_err("%s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
582 ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
583 bond->dev->name, new_value, INT_MAX); 567 bond->dev->name, new_value, INT_MAX);
584 ret = -EINVAL; 568 ret = -EINVAL;
585 goto out; 569 goto out;
586 } 570 }
587 571
588 pr_info(DRV_NAME 572 pr_info("%s: Setting ARP monitoring interval to %d.\n",
589 ": %s: Setting ARP monitoring interval to %d.\n", 573 bond->dev->name, new_value);
590 bond->dev->name, new_value);
591 bond->params.arp_interval = new_value; 574 bond->params.arp_interval = new_value;
592 if (bond->params.arp_interval) 575 if (bond->params.arp_interval)
593 bond->dev->priv_flags |= IFF_MASTER_ARPMON; 576 bond->dev->priv_flags |= IFF_MASTER_ARPMON;
594 if (bond->params.miimon) { 577 if (bond->params.miimon) {
595 pr_info(DRV_NAME 578 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
596 ": %s: ARP monitoring cannot be used with MII monitoring. " 579 bond->dev->name, bond->dev->name);
597 "%s Disabling MII monitoring.\n",
598 bond->dev->name, bond->dev->name);
599 bond->params.miimon = 0; 580 bond->params.miimon = 0;
600 if (delayed_work_pending(&bond->mii_work)) { 581 if (delayed_work_pending(&bond->mii_work)) {
601 cancel_delayed_work(&bond->mii_work); 582 cancel_delayed_work(&bond->mii_work);
@@ -603,10 +584,8 @@ static ssize_t bonding_store_arp_interval(struct device *d,
603 } 584 }
604 } 585 }
605 if (!bond->params.arp_targets[0]) { 586 if (!bond->params.arp_targets[0]) {
606 pr_info(DRV_NAME 587 pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n",
607 ": %s: ARP monitoring has been set up, " 588 bond->dev->name);
608 "but no ARP targets have been specified.\n",
609 bond->dev->name);
610 } 589 }
611 if (bond->dev->flags & IFF_UP) { 590 if (bond->dev->flags & IFF_UP) {
612 /* If the interface is up, we may need to fire off 591 /* If the interface is up, we may need to fire off
@@ -666,8 +645,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
666 /* look for adds */ 645 /* look for adds */
667 if (buf[0] == '+') { 646 if (buf[0] == '+') {
668 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { 647 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
669 pr_err(DRV_NAME 648 pr_err("%s: invalid ARP target %pI4 specified for addition\n",
670 ": %s: invalid ARP target %pI4 specified for addition\n",
671 bond->dev->name, &newtarget); 649 bond->dev->name, &newtarget);
672 ret = -EINVAL; 650 ret = -EINVAL;
673 goto out; 651 goto out;
@@ -675,23 +653,20 @@ static ssize_t bonding_store_arp_targets(struct device *d,
675 /* look for an empty slot to put the target in, and check for dupes */ 653 /* look for an empty slot to put the target in, and check for dupes */
676 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { 654 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) {
677 if (targets[i] == newtarget) { /* duplicate */ 655 if (targets[i] == newtarget) { /* duplicate */
678 pr_err(DRV_NAME 656 pr_err("%s: ARP target %pI4 is already present\n",
679 ": %s: ARP target %pI4 is already present\n",
680 bond->dev->name, &newtarget); 657 bond->dev->name, &newtarget);
681 ret = -EINVAL; 658 ret = -EINVAL;
682 goto out; 659 goto out;
683 } 660 }
684 if (targets[i] == 0) { 661 if (targets[i] == 0) {
685 pr_info(DRV_NAME 662 pr_info("%s: adding ARP target %pI4.\n",
686 ": %s: adding ARP target %pI4.\n", 663 bond->dev->name, &newtarget);
687 bond->dev->name, &newtarget);
688 done = 1; 664 done = 1;
689 targets[i] = newtarget; 665 targets[i] = newtarget;
690 } 666 }
691 } 667 }
692 if (!done) { 668 if (!done) {
693 pr_err(DRV_NAME 669 pr_err("%s: ARP target table is full!\n",
694 ": %s: ARP target table is full!\n",
695 bond->dev->name); 670 bond->dev->name);
696 ret = -EINVAL; 671 ret = -EINVAL;
697 goto out; 672 goto out;
@@ -699,8 +674,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
699 674
700 } else if (buf[0] == '-') { 675 } else if (buf[0] == '-') {
701 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { 676 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
702 pr_err(DRV_NAME 677 pr_err("%s: invalid ARP target %pI4 specified for removal\n",
703 ": %s: invalid ARP target %pI4 specified for removal\n",
704 bond->dev->name, &newtarget); 678 bond->dev->name, &newtarget);
705 ret = -EINVAL; 679 ret = -EINVAL;
706 goto out; 680 goto out;
@@ -709,9 +683,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
709 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) { 683 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) {
710 if (targets[i] == newtarget) { 684 if (targets[i] == newtarget) {
711 int j; 685 int j;
712 pr_info(DRV_NAME 686 pr_info("%s: removing ARP target %pI4.\n",
713 ": %s: removing ARP target %pI4.\n", 687 bond->dev->name, &newtarget);
714 bond->dev->name, &newtarget);
715 for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++) 688 for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++)
716 targets[j] = targets[j+1]; 689 targets[j] = targets[j+1];
717 690
@@ -720,16 +693,14 @@ static ssize_t bonding_store_arp_targets(struct device *d,
720 } 693 }
721 } 694 }
722 if (!done) { 695 if (!done) {
723 pr_info(DRV_NAME 696 pr_info("%s: unable to remove nonexistent ARP target %pI4.\n",
724 ": %s: unable to remove nonexistent ARP target %pI4.\n", 697 bond->dev->name, &newtarget);
725 bond->dev->name, &newtarget);
726 ret = -EINVAL; 698 ret = -EINVAL;
727 goto out; 699 goto out;
728 } 700 }
729 } else { 701 } else {
730 pr_err(DRV_NAME ": no command found in arp_ip_targets file" 702 pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n",
731 " for bond %s. Use +<addr> or -<addr>.\n", 703 bond->dev->name);
732 bond->dev->name);
733 ret = -EPERM; 704 ret = -EPERM;
734 goto out; 705 goto out;
735 } 706 }
@@ -761,41 +732,34 @@ static ssize_t bonding_store_downdelay(struct device *d,
761 struct bonding *bond = to_bond(d); 732 struct bonding *bond = to_bond(d);
762 733
763 if (!(bond->params.miimon)) { 734 if (!(bond->params.miimon)) {
764 pr_err(DRV_NAME 735 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
765 ": %s: Unable to set down delay as MII monitoring is disabled\n",
766 bond->dev->name); 736 bond->dev->name);
767 ret = -EPERM; 737 ret = -EPERM;
768 goto out; 738 goto out;
769 } 739 }
770 740
771 if (sscanf(buf, "%d", &new_value) != 1) { 741 if (sscanf(buf, "%d", &new_value) != 1) {
772 pr_err(DRV_NAME 742 pr_err("%s: no down delay value specified.\n", bond->dev->name);
773 ": %s: no down delay value specified.\n",
774 bond->dev->name);
775 ret = -EINVAL; 743 ret = -EINVAL;
776 goto out; 744 goto out;
777 } 745 }
778 if (new_value < 0) { 746 if (new_value < 0) {
779 pr_err(DRV_NAME 747 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
780 ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
781 bond->dev->name, new_value, 1, INT_MAX); 748 bond->dev->name, new_value, 1, INT_MAX);
782 ret = -EINVAL; 749 ret = -EINVAL;
783 goto out; 750 goto out;
784 } else { 751 } else {
785 if ((new_value % bond->params.miimon) != 0) { 752 if ((new_value % bond->params.miimon) != 0) {
786 pr_warning(DRV_NAME 753 pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
787 ": %s: Warning: down delay (%d) is not a "
788 "multiple of miimon (%d), delay rounded "
789 "to %d ms\n",
790 bond->dev->name, new_value, 754 bond->dev->name, new_value,
791 bond->params.miimon, 755 bond->params.miimon,
792 (new_value / bond->params.miimon) * 756 (new_value / bond->params.miimon) *
793 bond->params.miimon); 757 bond->params.miimon);
794 } 758 }
795 bond->params.downdelay = new_value / bond->params.miimon; 759 bond->params.downdelay = new_value / bond->params.miimon;
796 pr_info(DRV_NAME ": %s: Setting down delay to %d.\n", 760 pr_info("%s: Setting down delay to %d.\n",
797 bond->dev->name, 761 bond->dev->name,
798 bond->params.downdelay * bond->params.miimon); 762 bond->params.downdelay * bond->params.miimon);
799 763
800 } 764 }
801 765
@@ -823,41 +787,35 @@ static ssize_t bonding_store_updelay(struct device *d,
823 struct bonding *bond = to_bond(d); 787 struct bonding *bond = to_bond(d);
824 788
825 if (!(bond->params.miimon)) { 789 if (!(bond->params.miimon)) {
826 pr_err(DRV_NAME 790 pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
827 ": %s: Unable to set up delay as MII monitoring is disabled\n",
828 bond->dev->name); 791 bond->dev->name);
829 ret = -EPERM; 792 ret = -EPERM;
830 goto out; 793 goto out;
831 } 794 }
832 795
833 if (sscanf(buf, "%d", &new_value) != 1) { 796 if (sscanf(buf, "%d", &new_value) != 1) {
834 pr_err(DRV_NAME 797 pr_err("%s: no up delay value specified.\n",
835 ": %s: no up delay value specified.\n",
836 bond->dev->name); 798 bond->dev->name);
837 ret = -EINVAL; 799 ret = -EINVAL;
838 goto out; 800 goto out;
839 } 801 }
840 if (new_value < 0) { 802 if (new_value < 0) {
841 pr_err(DRV_NAME 803 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
842 ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
843 bond->dev->name, new_value, 1, INT_MAX); 804 bond->dev->name, new_value, 1, INT_MAX);
844 ret = -EINVAL; 805 ret = -EINVAL;
845 goto out; 806 goto out;
846 } else { 807 } else {
847 if ((new_value % bond->params.miimon) != 0) { 808 if ((new_value % bond->params.miimon) != 0) {
848 pr_warning(DRV_NAME 809 pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
849 ": %s: Warning: up delay (%d) is not a "
850 "multiple of miimon (%d), updelay rounded "
851 "to %d ms\n",
852 bond->dev->name, new_value, 810 bond->dev->name, new_value,
853 bond->params.miimon, 811 bond->params.miimon,
854 (new_value / bond->params.miimon) * 812 (new_value / bond->params.miimon) *
855 bond->params.miimon); 813 bond->params.miimon);
856 } 814 }
857 bond->params.updelay = new_value / bond->params.miimon; 815 bond->params.updelay = new_value / bond->params.miimon;
858 pr_info(DRV_NAME ": %s: Setting up delay to %d.\n", 816 pr_info("%s: Setting up delay to %d.\n",
859 bond->dev->name, bond->params.updelay * bond->params.miimon); 817 bond->dev->name,
860 818 bond->params.updelay * bond->params.miimon);
861 } 819 }
862 820
863out: 821out:
@@ -889,16 +847,14 @@ static ssize_t bonding_store_lacp(struct device *d,
889 struct bonding *bond = to_bond(d); 847 struct bonding *bond = to_bond(d);
890 848
891 if (bond->dev->flags & IFF_UP) { 849 if (bond->dev->flags & IFF_UP) {
892 pr_err(DRV_NAME 850 pr_err("%s: Unable to update LACP rate because interface is up.\n",
893 ": %s: Unable to update LACP rate because interface is up.\n",
894 bond->dev->name); 851 bond->dev->name);
895 ret = -EPERM; 852 ret = -EPERM;
896 goto out; 853 goto out;
897 } 854 }
898 855
899 if (bond->params.mode != BOND_MODE_8023AD) { 856 if (bond->params.mode != BOND_MODE_8023AD) {
900 pr_err(DRV_NAME 857 pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
901 ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
902 bond->dev->name); 858 bond->dev->name);
903 ret = -EPERM; 859 ret = -EPERM;
904 goto out; 860 goto out;
@@ -908,12 +864,11 @@ static ssize_t bonding_store_lacp(struct device *d,
908 864
909 if ((new_value == 1) || (new_value == 0)) { 865 if ((new_value == 1) || (new_value == 0)) {
910 bond->params.lacp_fast = new_value; 866 bond->params.lacp_fast = new_value;
911 pr_info(DRV_NAME ": %s: Setting LACP rate to %s (%d).\n", 867 pr_info("%s: Setting LACP rate to %s (%d).\n",
912 bond->dev->name, bond_lacp_tbl[new_value].modename, 868 bond->dev->name, bond_lacp_tbl[new_value].modename,
913 new_value); 869 new_value);
914 } else { 870 } else {
915 pr_err(DRV_NAME 871 pr_err("%s: Ignoring invalid LACP rate value %.*s.\n",
916 ": %s: Ignoring invalid LACP rate value %.*s.\n",
917 bond->dev->name, (int)strlen(buf) - 1, buf); 872 bond->dev->name, (int)strlen(buf) - 1, buf);
918 ret = -EINVAL; 873 ret = -EINVAL;
919 } 874 }
@@ -943,9 +898,8 @@ static ssize_t bonding_store_ad_select(struct device *d,
943 struct bonding *bond = to_bond(d); 898 struct bonding *bond = to_bond(d);
944 899
945 if (bond->dev->flags & IFF_UP) { 900 if (bond->dev->flags & IFF_UP) {
946 pr_err(DRV_NAME 901 pr_err("%s: Unable to update ad_select because interface is up.\n",
947 ": %s: Unable to update ad_select because interface " 902 bond->dev->name);
948 "is up.\n", bond->dev->name);
949 ret = -EPERM; 903 ret = -EPERM;
950 goto out; 904 goto out;
951 } 905 }
@@ -954,13 +908,11 @@ static ssize_t bonding_store_ad_select(struct device *d,
954 908
955 if (new_value != -1) { 909 if (new_value != -1) {
956 bond->params.ad_select = new_value; 910 bond->params.ad_select = new_value;
957 pr_info(DRV_NAME 911 pr_info("%s: Setting ad_select to %s (%d).\n",
958 ": %s: Setting ad_select to %s (%d).\n", 912 bond->dev->name, ad_select_tbl[new_value].modename,
959 bond->dev->name, ad_select_tbl[new_value].modename, 913 new_value);
960 new_value);
961 } else { 914 } else {
962 pr_err(DRV_NAME 915 pr_err("%s: Ignoring invalid ad_select value %.*s.\n",
963 ": %s: Ignoring invalid ad_select value %.*s.\n",
964 bond->dev->name, (int)strlen(buf) - 1, buf); 916 bond->dev->name, (int)strlen(buf) - 1, buf);
965 ret = -EINVAL; 917 ret = -EINVAL;
966 } 918 }
@@ -990,15 +942,13 @@ static ssize_t bonding_store_n_grat_arp(struct device *d,
990 struct bonding *bond = to_bond(d); 942 struct bonding *bond = to_bond(d);
991 943
992 if (sscanf(buf, "%d", &new_value) != 1) { 944 if (sscanf(buf, "%d", &new_value) != 1) {
993 pr_err(DRV_NAME 945 pr_err("%s: no num_grat_arp value specified.\n",
994 ": %s: no num_grat_arp value specified.\n",
995 bond->dev->name); 946 bond->dev->name);
996 ret = -EINVAL; 947 ret = -EINVAL;
997 goto out; 948 goto out;
998 } 949 }
999 if (new_value < 0 || new_value > 255) { 950 if (new_value < 0 || new_value > 255) {
1000 pr_err(DRV_NAME 951 pr_err("%s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
1001 ": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
1002 bond->dev->name, new_value); 952 bond->dev->name, new_value);
1003 ret = -EINVAL; 953 ret = -EINVAL;
1004 goto out; 954 goto out;
@@ -1031,16 +981,14 @@ static ssize_t bonding_store_n_unsol_na(struct device *d,
1031 struct bonding *bond = to_bond(d); 981 struct bonding *bond = to_bond(d);
1032 982
1033 if (sscanf(buf, "%d", &new_value) != 1) { 983 if (sscanf(buf, "%d", &new_value) != 1) {
1034 pr_err(DRV_NAME 984 pr_err("%s: no num_unsol_na value specified.\n",
1035 ": %s: no num_unsol_na value specified.\n",
1036 bond->dev->name); 985 bond->dev->name);
1037 ret = -EINVAL; 986 ret = -EINVAL;
1038 goto out; 987 goto out;
1039 } 988 }
1040 989
1041 if (new_value < 0 || new_value > 255) { 990 if (new_value < 0 || new_value > 255) {
1042 pr_err(DRV_NAME 991 pr_err("%s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
1043 ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
1044 bond->dev->name, new_value); 992 bond->dev->name, new_value);
1045 ret = -EINVAL; 993 ret = -EINVAL;
1046 goto out; 994 goto out;
@@ -1075,40 +1023,31 @@ static ssize_t bonding_store_miimon(struct device *d,
1075 struct bonding *bond = to_bond(d); 1023 struct bonding *bond = to_bond(d);
1076 1024
1077 if (sscanf(buf, "%d", &new_value) != 1) { 1025 if (sscanf(buf, "%d", &new_value) != 1) {
1078 pr_err(DRV_NAME 1026 pr_err("%s: no miimon value specified.\n",
1079 ": %s: no miimon value specified.\n",
1080 bond->dev->name); 1027 bond->dev->name);
1081 ret = -EINVAL; 1028 ret = -EINVAL;
1082 goto out; 1029 goto out;
1083 } 1030 }
1084 if (new_value < 0) { 1031 if (new_value < 0) {
1085 pr_err(DRV_NAME 1032 pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n",
1086 ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n",
1087 bond->dev->name, new_value, 1, INT_MAX); 1033 bond->dev->name, new_value, 1, INT_MAX);
1088 ret = -EINVAL; 1034 ret = -EINVAL;
1089 goto out; 1035 goto out;
1090 } else { 1036 } else {
1091 pr_info(DRV_NAME 1037 pr_info("%s: Setting MII monitoring interval to %d.\n",
1092 ": %s: Setting MII monitoring interval to %d.\n", 1038 bond->dev->name, new_value);
1093 bond->dev->name, new_value);
1094 bond->params.miimon = new_value; 1039 bond->params.miimon = new_value;
1095 if (bond->params.updelay) 1040 if (bond->params.updelay)
1096 pr_info(DRV_NAME 1041 pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n",
1097 ": %s: Note: Updating updelay (to %d) " 1042 bond->dev->name,
1098 "since it is a multiple of the miimon value.\n", 1043 bond->params.updelay * bond->params.miimon);
1099 bond->dev->name,
1100 bond->params.updelay * bond->params.miimon);
1101 if (bond->params.downdelay) 1044 if (bond->params.downdelay)
1102 pr_info(DRV_NAME 1045 pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n",
1103 ": %s: Note: Updating downdelay (to %d) " 1046 bond->dev->name,
1104 "since it is a multiple of the miimon value.\n", 1047 bond->params.downdelay * bond->params.miimon);
1105 bond->dev->name,
1106 bond->params.downdelay * bond->params.miimon);
1107 if (bond->params.arp_interval) { 1048 if (bond->params.arp_interval) {
1108 pr_info(DRV_NAME 1049 pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
1109 ": %s: MII monitoring cannot be used with " 1050 bond->dev->name);
1110 "ARP monitoring. Disabling ARP monitoring...\n",
1111 bond->dev->name);
1112 bond->params.arp_interval = 0; 1051 bond->params.arp_interval = 0;
1113 bond->dev->priv_flags &= ~IFF_MASTER_ARPMON; 1052 bond->dev->priv_flags &= ~IFF_MASTER_ARPMON;
1114 if (bond->params.arp_validate) { 1053 if (bond->params.arp_validate) {
@@ -1176,17 +1115,15 @@ static ssize_t bonding_store_primary(struct device *d,
1176 write_lock_bh(&bond->curr_slave_lock); 1115 write_lock_bh(&bond->curr_slave_lock);
1177 1116
1178 if (!USES_PRIMARY(bond->params.mode)) { 1117 if (!USES_PRIMARY(bond->params.mode)) {
1179 pr_info(DRV_NAME 1118 pr_info("%s: Unable to set primary slave; %s is in mode %d\n",
1180 ": %s: Unable to set primary slave; %s is in mode %d\n", 1119 bond->dev->name, bond->dev->name, bond->params.mode);
1181 bond->dev->name, bond->dev->name, bond->params.mode);
1182 } else { 1120 } else {
1183 bond_for_each_slave(bond, slave, i) { 1121 bond_for_each_slave(bond, slave, i) {
1184 if (strnicmp 1122 if (strnicmp
1185 (slave->dev->name, buf, 1123 (slave->dev->name, buf,
1186 strlen(slave->dev->name)) == 0) { 1124 strlen(slave->dev->name)) == 0) {
1187 pr_info(DRV_NAME 1125 pr_info("%s: Setting %s as primary slave.\n",
1188 ": %s: Setting %s as primary slave.\n", 1126 bond->dev->name, slave->dev->name);
1189 bond->dev->name, slave->dev->name);
1190 bond->primary_slave = slave; 1127 bond->primary_slave = slave;
1191 strcpy(bond->params.primary, slave->dev->name); 1128 strcpy(bond->params.primary, slave->dev->name);
1192 bond_select_active_slave(bond); 1129 bond_select_active_slave(bond);
@@ -1197,15 +1134,13 @@ static ssize_t bonding_store_primary(struct device *d,
1197 /* if we got here, then we didn't match the name of any slave */ 1134 /* if we got here, then we didn't match the name of any slave */
1198 1135
1199 if (strlen(buf) == 0 || buf[0] == '\n') { 1136 if (strlen(buf) == 0 || buf[0] == '\n') {
1200 pr_info(DRV_NAME 1137 pr_info("%s: Setting primary slave to None.\n",
1201 ": %s: Setting primary slave to None.\n", 1138 bond->dev->name);
1202 bond->dev->name);
1203 bond->primary_slave = NULL; 1139 bond->primary_slave = NULL;
1204 bond_select_active_slave(bond); 1140 bond_select_active_slave(bond);
1205 } else { 1141 } else {
1206 pr_info(DRV_NAME 1142 pr_info("%s: Unable to set %.*s as primary slave as it is not a slave.\n",
1207 ": %s: Unable to set %.*s as primary slave as it is not a slave.\n", 1143 bond->dev->name, (int)strlen(buf) - 1, buf);
1208 bond->dev->name, (int)strlen(buf) - 1, buf);
1209 } 1144 }
1210 } 1145 }
1211out: 1146out:
@@ -1244,8 +1179,7 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
1244 1179
1245 new_value = bond_parse_parm(buf, pri_reselect_tbl); 1180 new_value = bond_parse_parm(buf, pri_reselect_tbl);
1246 if (new_value < 0) { 1181 if (new_value < 0) {
1247 pr_err(DRV_NAME 1182 pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
1248 ": %s: Ignoring invalid primary_reselect value %.*s.\n",
1249 bond->dev->name, 1183 bond->dev->name,
1250 (int) strlen(buf) - 1, buf); 1184 (int) strlen(buf) - 1, buf);
1251 ret = -EINVAL; 1185 ret = -EINVAL;
@@ -1253,7 +1187,7 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
1253 } 1187 }
1254 1188
1255 bond->params.primary_reselect = new_value; 1189 bond->params.primary_reselect = new_value;
1256 pr_info(DRV_NAME ": %s: setting primary_reselect to %s (%d).\n", 1190 pr_info("%s: setting primary_reselect to %s (%d).\n",
1257 bond->dev->name, pri_reselect_tbl[new_value].modename, 1191 bond->dev->name, pri_reselect_tbl[new_value].modename,
1258 new_value); 1192 new_value);
1259 1193
@@ -1291,20 +1225,18 @@ static ssize_t bonding_store_carrier(struct device *d,
1291 1225
1292 1226
1293 if (sscanf(buf, "%d", &new_value) != 1) { 1227 if (sscanf(buf, "%d", &new_value) != 1) {
1294 pr_err(DRV_NAME 1228 pr_err("%s: no use_carrier value specified.\n",
1295 ": %s: no use_carrier value specified.\n",
1296 bond->dev->name); 1229 bond->dev->name);
1297 ret = -EINVAL; 1230 ret = -EINVAL;
1298 goto out; 1231 goto out;
1299 } 1232 }
1300 if ((new_value == 0) || (new_value == 1)) { 1233 if ((new_value == 0) || (new_value == 1)) {
1301 bond->params.use_carrier = new_value; 1234 bond->params.use_carrier = new_value;
1302 pr_info(DRV_NAME ": %s: Setting use_carrier to %d.\n", 1235 pr_info("%s: Setting use_carrier to %d.\n",
1303 bond->dev->name, new_value); 1236 bond->dev->name, new_value);
1304 } else { 1237 } else {
1305 pr_info(DRV_NAME 1238 pr_info("%s: Ignoring invalid use_carrier value %d.\n",
1306 ": %s: Ignoring invalid use_carrier value %d.\n", 1239 bond->dev->name, new_value);
1307 bond->dev->name, new_value);
1308 } 1240 }
1309out: 1241out:
1310 return count; 1242 return count;
@@ -1349,8 +1281,7 @@ static ssize_t bonding_store_active_slave(struct device *d,
1349 write_lock_bh(&bond->curr_slave_lock); 1281 write_lock_bh(&bond->curr_slave_lock);
1350 1282
1351 if (!USES_PRIMARY(bond->params.mode)) 1283 if (!USES_PRIMARY(bond->params.mode))
1352 pr_info(DRV_NAME ": %s: Unable to change active slave;" 1284 pr_info("%s: Unable to change active slave; %s is in mode %d\n",
1353 " %s is in mode %d\n",
1354 bond->dev->name, bond->dev->name, bond->params.mode); 1285 bond->dev->name, bond->dev->name, bond->params.mode);
1355 else { 1286 else {
1356 bond_for_each_slave(bond, slave, i) { 1287 bond_for_each_slave(bond, slave, i) {
@@ -1361,9 +1292,9 @@ static ssize_t bonding_store_active_slave(struct device *d,
1361 new_active = slave; 1292 new_active = slave;
1362 if (new_active == old_active) { 1293 if (new_active == old_active) {
1363 /* do nothing */ 1294 /* do nothing */
1364 pr_info(DRV_NAME 1295 pr_info("%s: %s is already the current active slave.\n",
1365 ": %s: %s is already the current active slave.\n", 1296 bond->dev->name,
1366 bond->dev->name, slave->dev->name); 1297 slave->dev->name);
1367 goto out; 1298 goto out;
1368 } 1299 }
1369 else { 1300 else {
@@ -1371,16 +1302,15 @@ static ssize_t bonding_store_active_slave(struct device *d,
1371 (old_active) && 1302 (old_active) &&
1372 (new_active->link == BOND_LINK_UP) && 1303 (new_active->link == BOND_LINK_UP) &&
1373 IS_UP(new_active->dev)) { 1304 IS_UP(new_active->dev)) {
1374 pr_info(DRV_NAME 1305 pr_info("%s: Setting %s as active slave.\n",
1375 ": %s: Setting %s as active slave.\n", 1306 bond->dev->name,
1376 bond->dev->name, slave->dev->name); 1307 slave->dev->name);
1377 bond_change_active_slave(bond, new_active); 1308 bond_change_active_slave(bond, new_active);
1378 } 1309 }
1379 else { 1310 else {
1380 pr_info(DRV_NAME 1311 pr_info("%s: Could not set %s as active slave; either %s is down or the link is down.\n",
1381 ": %s: Could not set %s as active slave; " 1312 bond->dev->name,
1382 "either %s is down or the link is down.\n", 1313 slave->dev->name,
1383 bond->dev->name, slave->dev->name,
1384 slave->dev->name); 1314 slave->dev->name);
1385 } 1315 }
1386 goto out; 1316 goto out;
@@ -1391,14 +1321,12 @@ static ssize_t bonding_store_active_slave(struct device *d,
1391 /* if we got here, then we didn't match the name of any slave */ 1321 /* if we got here, then we didn't match the name of any slave */
1392 1322
1393 if (strlen(buf) == 0 || buf[0] == '\n') { 1323 if (strlen(buf) == 0 || buf[0] == '\n') {
1394 pr_info(DRV_NAME 1324 pr_info("%s: Setting active slave to None.\n",
1395 ": %s: Setting active slave to None.\n",
1396 bond->dev->name); 1325 bond->dev->name);
1397 bond->primary_slave = NULL; 1326 bond->primary_slave = NULL;
1398 bond_select_active_slave(bond); 1327 bond_select_active_slave(bond);
1399 } else { 1328 } else {
1400 pr_info(DRV_NAME ": %s: Unable to set %.*s" 1329 pr_info("%s: Unable to set %.*s as active slave as it is not a slave.\n",
1401 " as active slave as it is not a slave.\n",
1402 bond->dev->name, (int)strlen(buf) - 1, buf); 1330 bond->dev->name, (int)strlen(buf) - 1, buf);
1403 } 1331 }
1404 } 1332 }
@@ -1600,8 +1528,7 @@ int bond_create_sysfs(void)
1600 /* Is someone being kinky and naming a device bonding_master? */ 1528 /* Is someone being kinky and naming a device bonding_master? */
1601 if (__dev_get_by_name(&init_net, 1529 if (__dev_get_by_name(&init_net,
1602 class_attr_bonding_masters.attr.name)) 1530 class_attr_bonding_masters.attr.name))
1603 pr_err("network device named %s already " 1531 pr_err("network device named %s already exists in sysfs",
1604 "exists in sysfs",
1605 class_attr_bonding_masters.attr.name); 1532 class_attr_bonding_masters.attr.name);
1606 ret = 0; 1533 ret = 0;
1607 } 1534 }
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index bb803fa1e6a7..05b751719bd5 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -50,10 +50,19 @@ config CAN_TI_HECC
50 50
51config CAN_MCP251X 51config CAN_MCP251X
52 tristate "Microchip MCP251x SPI CAN controllers" 52 tristate "Microchip MCP251x SPI CAN controllers"
53 depends on CAN_DEV && SPI 53 depends on CAN_DEV && SPI && HAS_DMA
54 ---help--- 54 ---help---
55 Driver for the Microchip MCP251x SPI CAN controllers. 55 Driver for the Microchip MCP251x SPI CAN controllers.
56 56
57config CAN_BFIN
58 depends on CAN_DEV && (BF534 || BF536 || BF537 || BF538 || BF539 || BF54x)
59 tristate "Analog Devices Blackfin on-chip CAN"
60 ---help---
61 Driver for the Analog Devices Blackfin on-chip CAN controllers
62
63 To compile this driver as a module, choose M here: the
64 module will be called bfin_can.
65
57source "drivers/net/can/mscan/Kconfig" 66source "drivers/net/can/mscan/Kconfig"
58 67
59source "drivers/net/can/sja1000/Kconfig" 68source "drivers/net/can/sja1000/Kconfig"
diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile
index 56899fef1c6a..7a702f28d01c 100644
--- a/drivers/net/can/Makefile
+++ b/drivers/net/can/Makefile
@@ -14,5 +14,6 @@ obj-$(CONFIG_CAN_MSCAN) += mscan/
14obj-$(CONFIG_CAN_AT91) += at91_can.o 14obj-$(CONFIG_CAN_AT91) += at91_can.o
15obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o 15obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o
16obj-$(CONFIG_CAN_MCP251X) += mcp251x.o 16obj-$(CONFIG_CAN_MCP251X) += mcp251x.o
17obj-$(CONFIG_CAN_BFIN) += bfin_can.o
17 18
18ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG 19ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index cbe3fce53e3b..d0ec17878ffc 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -474,7 +474,7 @@ static void at91_read_mb(struct net_device *dev, unsigned int mb,
474 reg_msr = at91_read(priv, AT91_MSR(mb)); 474 reg_msr = at91_read(priv, AT91_MSR(mb));
475 if (reg_msr & AT91_MSR_MRTR) 475 if (reg_msr & AT91_MSR_MRTR)
476 cf->can_id |= CAN_RTR_FLAG; 476 cf->can_id |= CAN_RTR_FLAG;
477 cf->can_dlc = min_t(__u8, (reg_msr >> 16) & 0xf, 8); 477 cf->can_dlc = get_can_dlc((reg_msr >> 16) & 0xf);
478 478
479 *(u32 *)(cf->data + 0) = at91_read(priv, AT91_MDL(mb)); 479 *(u32 *)(cf->data + 0) = at91_read(priv, AT91_MDL(mb));
480 *(u32 *)(cf->data + 4) = at91_read(priv, AT91_MDH(mb)); 480 *(u32 *)(cf->data + 4) = at91_read(priv, AT91_MDH(mb));
diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
new file mode 100644
index 000000000000..0ec1524523cc
--- /dev/null
+++ b/drivers/net/can/bfin_can.c
@@ -0,0 +1,783 @@
1/*
2 * Blackfin On-Chip CAN Driver
3 *
4 * Copyright 2004-2009 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 */
10
11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/bitops.h>
15#include <linux/interrupt.h>
16#include <linux/errno.h>
17#include <linux/netdevice.h>
18#include <linux/skbuff.h>
19#include <linux/platform_device.h>
20
21#include <linux/can.h>
22#include <linux/can/dev.h>
23#include <linux/can/error.h>
24
25#include <asm/portmux.h>
26
27#define DRV_NAME "bfin_can"
28#define BFIN_CAN_TIMEOUT 100
29
30/*
31 * transmit and receive channels
32 */
33#define TRANSMIT_CHL 24
34#define RECEIVE_STD_CHL 0
35#define RECEIVE_EXT_CHL 4
36#define RECEIVE_RTR_CHL 8
37#define RECEIVE_EXT_RTR_CHL 12
38#define MAX_CHL_NUMBER 32
39
40/*
41 * bfin can registers layout
42 */
43struct bfin_can_mask_regs {
44 u16 aml;
45 u16 dummy1;
46 u16 amh;
47 u16 dummy2;
48};
49
50struct bfin_can_channel_regs {
51 u16 data[8];
52 u16 dlc;
53 u16 dummy1;
54 u16 tsv;
55 u16 dummy2;
56 u16 id0;
57 u16 dummy3;
58 u16 id1;
59 u16 dummy4;
60};
61
62struct bfin_can_regs {
63 /*
64 * global control and status registers
65 */
66 u16 mc1; /* offset 0 */
67 u16 dummy1;
68 u16 md1; /* offset 4 */
69 u16 rsv1[13];
70 u16 mbtif1; /* offset 0x20 */
71 u16 dummy2;
72 u16 mbrif1; /* offset 0x24 */
73 u16 dummy3;
74 u16 mbim1; /* offset 0x28 */
75 u16 rsv2[11];
76 u16 mc2; /* offset 0x40 */
77 u16 dummy4;
78 u16 md2; /* offset 0x44 */
79 u16 dummy5;
80 u16 trs2; /* offset 0x48 */
81 u16 rsv3[11];
82 u16 mbtif2; /* offset 0x60 */
83 u16 dummy6;
84 u16 mbrif2; /* offset 0x64 */
85 u16 dummy7;
86 u16 mbim2; /* offset 0x68 */
87 u16 rsv4[11];
88 u16 clk; /* offset 0x80 */
89 u16 dummy8;
90 u16 timing; /* offset 0x84 */
91 u16 rsv5[3];
92 u16 status; /* offset 0x8c */
93 u16 dummy9;
94 u16 cec; /* offset 0x90 */
95 u16 dummy10;
96 u16 gis; /* offset 0x94 */
97 u16 dummy11;
98 u16 gim; /* offset 0x98 */
99 u16 rsv6[3];
100 u16 ctrl; /* offset 0xa0 */
101 u16 dummy12;
102 u16 intr; /* offset 0xa4 */
103 u16 rsv7[7];
104 u16 esr; /* offset 0xb4 */
105 u16 rsv8[37];
106
107 /*
108 * channel(mailbox) mask and message registers
109 */
110 struct bfin_can_mask_regs msk[MAX_CHL_NUMBER]; /* offset 0x100 */
111 struct bfin_can_channel_regs chl[MAX_CHL_NUMBER]; /* offset 0x200 */
112};
113
114/*
115 * bfin can private data
116 */
117struct bfin_can_priv {
118 struct can_priv can; /* must be the first member */
119 struct net_device *dev;
120 void __iomem *membase;
121 int rx_irq;
122 int tx_irq;
123 int err_irq;
124 unsigned short *pin_list;
125};
126
127/*
128 * bfin can timing parameters
129 */
130static struct can_bittiming_const bfin_can_bittiming_const = {
131 .name = DRV_NAME,
132 .tseg1_min = 1,
133 .tseg1_max = 16,
134 .tseg2_min = 1,
135 .tseg2_max = 8,
136 .sjw_max = 4,
137 /*
138 * Although the BRP field can be set to any value, it is recommended
139 * that the value be greater than or equal to 4, as restrictions
140 * apply to the bit timing configuration when BRP is less than 4.
141 */
142 .brp_min = 4,
143 .brp_max = 1024,
144 .brp_inc = 1,
145};
146
147static int bfin_can_set_bittiming(struct net_device *dev)
148{
149 struct bfin_can_priv *priv = netdev_priv(dev);
150 struct bfin_can_regs __iomem *reg = priv->membase;
151 struct can_bittiming *bt = &priv->can.bittiming;
152 u16 clk, timing;
153
154 clk = bt->brp - 1;
155 timing = ((bt->sjw - 1) << 8) | (bt->prop_seg + bt->phase_seg1 - 1) |
156 ((bt->phase_seg2 - 1) << 4);
157
158 /*
159 * If the SAM bit is set, the input signal is oversampled three times
160 * at the SCLK rate.
161 */
162 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
163 timing |= SAM;
164
165 bfin_write16(&reg->clk, clk);
166 bfin_write16(&reg->timing, timing);
167
168 dev_info(dev->dev.parent, "setting CLOCK=0x%04x TIMING=0x%04x\n",
169 clk, timing);
170
171 return 0;
172}
173
174static void bfin_can_set_reset_mode(struct net_device *dev)
175{
176 struct bfin_can_priv *priv = netdev_priv(dev);
177 struct bfin_can_regs __iomem *reg = priv->membase;
178 int timeout = BFIN_CAN_TIMEOUT;
179 int i;
180
181 /* disable interrupts */
182 bfin_write16(&reg->mbim1, 0);
183 bfin_write16(&reg->mbim2, 0);
184 bfin_write16(&reg->gim, 0);
185
186 /* reset can and enter configuration mode */
187 bfin_write16(&reg->ctrl, SRS | CCR);
188 SSYNC();
189 bfin_write16(&reg->ctrl, CCR);
190 SSYNC();
191 while (!(bfin_read16(&reg->ctrl) & CCA)) {
192 udelay(10);
193 if (--timeout == 0) {
194 dev_err(dev->dev.parent,
195 "fail to enter configuration mode\n");
196 BUG();
197 }
198 }
199
200 /*
201 * All mailbox configurations are marked as inactive
202 * by writing to CAN Mailbox Configuration Registers 1 and 2
203 * For all bits: 0 - Mailbox disabled, 1 - Mailbox enabled
204 */
205 bfin_write16(&reg->mc1, 0);
206 bfin_write16(&reg->mc2, 0);
207
208 /* Set Mailbox Direction */
209 bfin_write16(&reg->md1, 0xFFFF); /* mailbox 1-16 are RX */
210 bfin_write16(&reg->md2, 0); /* mailbox 17-32 are TX */
211
212 /* RECEIVE_STD_CHL */
213 for (i = 0; i < 2; i++) {
214 bfin_write16(&reg->chl[RECEIVE_STD_CHL + i].id0, 0);
215 bfin_write16(&reg->chl[RECEIVE_STD_CHL + i].id1, AME);
216 bfin_write16(&reg->chl[RECEIVE_STD_CHL + i].dlc, 0);
217 bfin_write16(&reg->msk[RECEIVE_STD_CHL + i].amh, 0x1FFF);
218 bfin_write16(&reg->msk[RECEIVE_STD_CHL + i].aml, 0xFFFF);
219 }
220
221 /* RECEIVE_EXT_CHL */
222 for (i = 0; i < 2; i++) {
223 bfin_write16(&reg->chl[RECEIVE_EXT_CHL + i].id0, 0);
224 bfin_write16(&reg->chl[RECEIVE_EXT_CHL + i].id1, AME | IDE);
225 bfin_write16(&reg->chl[RECEIVE_EXT_CHL + i].dlc, 0);
226 bfin_write16(&reg->msk[RECEIVE_EXT_CHL + i].amh, 0x1FFF);
227 bfin_write16(&reg->msk[RECEIVE_EXT_CHL + i].aml, 0xFFFF);
228 }
229
230 bfin_write16(&reg->mc2, BIT(TRANSMIT_CHL - 16));
231 bfin_write16(&reg->mc1, BIT(RECEIVE_STD_CHL) + BIT(RECEIVE_EXT_CHL));
232 SSYNC();
233
234 priv->can.state = CAN_STATE_STOPPED;
235}
236
237static void bfin_can_set_normal_mode(struct net_device *dev)
238{
239 struct bfin_can_priv *priv = netdev_priv(dev);
240 struct bfin_can_regs __iomem *reg = priv->membase;
241 int timeout = BFIN_CAN_TIMEOUT;
242
243 /*
244 * leave configuration mode
245 */
246 bfin_write16(&reg->ctrl, bfin_read16(&reg->ctrl) & ~CCR);
247
248 while (bfin_read16(&reg->status) & CCA) {
249 udelay(10);
250 if (--timeout == 0) {
251 dev_err(dev->dev.parent,
252 "fail to leave configuration mode\n");
253 BUG();
254 }
255 }
256
257 /*
258 * clear _All_ tx and rx interrupts
259 */
260 bfin_write16(&reg->mbtif1, 0xFFFF);
261 bfin_write16(&reg->mbtif2, 0xFFFF);
262 bfin_write16(&reg->mbrif1, 0xFFFF);
263 bfin_write16(&reg->mbrif2, 0xFFFF);
264
265 /*
266 * clear global interrupt status register
267 */
268 bfin_write16(&reg->gis, 0x7FF); /* overwrites with '1' */
269
270 /*
271 * Initialize Interrupts
272 * - set bits in the mailbox interrupt mask register
273 * - global interrupt mask
274 */
275 bfin_write16(&reg->mbim1, BIT(RECEIVE_STD_CHL) + BIT(RECEIVE_EXT_CHL));
276 bfin_write16(&reg->mbim2, BIT(TRANSMIT_CHL - 16));
277
278 bfin_write16(&reg->gim, EPIM | BOIM | RMLIM);
279 SSYNC();
280}
281
282static void bfin_can_start(struct net_device *dev)
283{
284 struct bfin_can_priv *priv = netdev_priv(dev);
285
286 /* enter reset mode */
287 if (priv->can.state != CAN_STATE_STOPPED)
288 bfin_can_set_reset_mode(dev);
289
290 /* leave reset mode */
291 bfin_can_set_normal_mode(dev);
292}
293
294static int bfin_can_set_mode(struct net_device *dev, enum can_mode mode)
295{
296 switch (mode) {
297 case CAN_MODE_START:
298 bfin_can_start(dev);
299 if (netif_queue_stopped(dev))
300 netif_wake_queue(dev);
301 break;
302
303 default:
304 return -EOPNOTSUPP;
305 }
306
307 return 0;
308}
309
310static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev)
311{
312 struct bfin_can_priv *priv = netdev_priv(dev);
313 struct bfin_can_regs __iomem *reg = priv->membase;
314 struct can_frame *cf = (struct can_frame *)skb->data;
315 u8 dlc = cf->can_dlc;
316 canid_t id = cf->can_id;
317 u8 *data = cf->data;
318 u16 val;
319 int i;
320
321 netif_stop_queue(dev);
322
323 /* fill id */
324 if (id & CAN_EFF_FLAG) {
325 bfin_write16(&reg->chl[TRANSMIT_CHL].id0, id);
326 if (id & CAN_RTR_FLAG)
327 writew(((id & 0x1FFF0000) >> 16) | IDE | AME | RTR,
328 &reg->chl[TRANSMIT_CHL].id1);
329 else
330 writew(((id & 0x1FFF0000) >> 16) | IDE | AME,
331 &reg->chl[TRANSMIT_CHL].id1);
332
333 } else {
334 if (id & CAN_RTR_FLAG)
335 writew((id << 2) | AME | RTR,
336 &reg->chl[TRANSMIT_CHL].id1);
337 else
338 bfin_write16(&reg->chl[TRANSMIT_CHL].id1,
339 (id << 2) | AME);
340 }
341
342 /* fill payload */
343 for (i = 0; i < 8; i += 2) {
344 val = ((7 - i) < dlc ? (data[7 - i]) : 0) +
345 ((6 - i) < dlc ? (data[6 - i] << 8) : 0);
346 bfin_write16(&reg->chl[TRANSMIT_CHL].data[i], val);
347 }
348
349 /* fill data length code */
350 bfin_write16(&reg->chl[TRANSMIT_CHL].dlc, dlc);
351
352 dev->trans_start = jiffies;
353
354 can_put_echo_skb(skb, dev, 0);
355
356 /* set transmit request */
357 bfin_write16(&reg->trs2, BIT(TRANSMIT_CHL - 16));
358
359 return 0;
360}
361
362static void bfin_can_rx(struct net_device *dev, u16 isrc)
363{
364 struct bfin_can_priv *priv = netdev_priv(dev);
365 struct net_device_stats *stats = &dev->stats;
366 struct bfin_can_regs __iomem *reg = priv->membase;
367 struct can_frame *cf;
368 struct sk_buff *skb;
369 int obj;
370 int i;
371 u16 val;
372
373 skb = alloc_can_skb(dev, &cf);
374 if (skb == NULL)
375 return;
376
377 /* get id */
378 if (isrc & BIT(RECEIVE_EXT_CHL)) {
379 /* extended frame format (EFF) */
380 cf->can_id = ((bfin_read16(&reg->chl[RECEIVE_EXT_CHL].id1)
381 & 0x1FFF) << 16)
382 + bfin_read16(&reg->chl[RECEIVE_EXT_CHL].id0);
383 cf->can_id |= CAN_EFF_FLAG;
384 obj = RECEIVE_EXT_CHL;
385 } else {
386 /* standard frame format (SFF) */
387 cf->can_id = (bfin_read16(&reg->chl[RECEIVE_STD_CHL].id1)
388 & 0x1ffc) >> 2;
389 obj = RECEIVE_STD_CHL;
390 }
391 if (bfin_read16(&reg->chl[obj].id1) & RTR)
392 cf->can_id |= CAN_RTR_FLAG;
393
394 /* get data length code */
395 cf->can_dlc = get_can_dlc(bfin_read16(&reg->chl[obj].dlc) & 0xF);
396
397 /* get payload */
398 for (i = 0; i < 8; i += 2) {
399 val = bfin_read16(&reg->chl[obj].data[i]);
400 cf->data[7 - i] = (7 - i) < cf->can_dlc ? val : 0;
401 cf->data[6 - i] = (6 - i) < cf->can_dlc ? (val >> 8) : 0;
402 }
403
404 netif_rx(skb);
405
406 stats->rx_packets++;
407 stats->rx_bytes += cf->can_dlc;
408}
409
410static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status)
411{
412 struct bfin_can_priv *priv = netdev_priv(dev);
413 struct bfin_can_regs __iomem *reg = priv->membase;
414 struct net_device_stats *stats = &dev->stats;
415 struct can_frame *cf;
416 struct sk_buff *skb;
417 enum can_state state = priv->can.state;
418
419 skb = alloc_can_err_skb(dev, &cf);
420 if (skb == NULL)
421 return -ENOMEM;
422
423 if (isrc & RMLIS) {
424 /* data overrun interrupt */
425 dev_dbg(dev->dev.parent, "data overrun interrupt\n");
426 cf->can_id |= CAN_ERR_CRTL;
427 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
428 stats->rx_over_errors++;
429 stats->rx_errors++;
430 }
431
432 if (isrc & BOIS) {
433 dev_dbg(dev->dev.parent, "bus-off mode interrupt\n");
434 state = CAN_STATE_BUS_OFF;
435 cf->can_id |= CAN_ERR_BUSOFF;
436 can_bus_off(dev);
437 }
438
439 if (isrc & EPIS) {
440 /* error passive interrupt */
441 dev_dbg(dev->dev.parent, "error passive interrupt\n");
442 state = CAN_STATE_ERROR_PASSIVE;
443 }
444
445 if ((isrc & EWTIS) || (isrc & EWRIS)) {
446 dev_dbg(dev->dev.parent,
447 "Error Warning Transmit/Receive Interrupt\n");
448 state = CAN_STATE_ERROR_WARNING;
449 }
450
451 if (state != priv->can.state && (state == CAN_STATE_ERROR_WARNING ||
452 state == CAN_STATE_ERROR_PASSIVE)) {
453 u16 cec = bfin_read16(&reg->cec);
454 u8 rxerr = cec;
455 u8 txerr = cec >> 8;
456
457 cf->can_id |= CAN_ERR_CRTL;
458 if (state == CAN_STATE_ERROR_WARNING) {
459 priv->can.can_stats.error_warning++;
460 cf->data[1] = (txerr > rxerr) ?
461 CAN_ERR_CRTL_TX_WARNING :
462 CAN_ERR_CRTL_RX_WARNING;
463 } else {
464 priv->can.can_stats.error_passive++;
465 cf->data[1] = (txerr > rxerr) ?
466 CAN_ERR_CRTL_TX_PASSIVE :
467 CAN_ERR_CRTL_RX_PASSIVE;
468 }
469 }
470
471 if (status) {
472 priv->can.can_stats.bus_error++;
473
474 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
475
476 if (status & BEF)
477 cf->data[2] |= CAN_ERR_PROT_BIT;
478 else if (status & FER)
479 cf->data[2] |= CAN_ERR_PROT_FORM;
480 else if (status & SER)
481 cf->data[2] |= CAN_ERR_PROT_STUFF;
482 else
483 cf->data[2] |= CAN_ERR_PROT_UNSPEC;
484 }
485
486 priv->can.state = state;
487
488 netif_rx(skb);
489
490 stats->rx_packets++;
491 stats->rx_bytes += cf->can_dlc;
492
493 return 0;
494}
495
496irqreturn_t bfin_can_interrupt(int irq, void *dev_id)
497{
498 struct net_device *dev = dev_id;
499 struct bfin_can_priv *priv = netdev_priv(dev);
500 struct bfin_can_regs __iomem *reg = priv->membase;
501 struct net_device_stats *stats = &dev->stats;
502 u16 status, isrc;
503
504 if ((irq == priv->tx_irq) && bfin_read16(&reg->mbtif2)) {
505 /* transmission complete interrupt */
506 bfin_write16(&reg->mbtif2, 0xFFFF);
507 stats->tx_packets++;
508 stats->tx_bytes += bfin_read16(&reg->chl[TRANSMIT_CHL].dlc);
509 can_get_echo_skb(dev, 0);
510 netif_wake_queue(dev);
511 } else if ((irq == priv->rx_irq) && bfin_read16(&reg->mbrif1)) {
512 /* receive interrupt */
513 isrc = bfin_read16(&reg->mbrif1);
514 bfin_write16(&reg->mbrif1, 0xFFFF);
515 bfin_can_rx(dev, isrc);
516 } else if ((irq == priv->err_irq) && bfin_read16(&reg->gis)) {
517 /* error interrupt */
518 isrc = bfin_read16(&reg->gis);
519 status = bfin_read16(&reg->esr);
520 bfin_write16(&reg->gis, 0x7FF);
521 bfin_can_err(dev, isrc, status);
522 } else {
523 return IRQ_NONE;
524 }
525
526 return IRQ_HANDLED;
527}
528
529static int bfin_can_open(struct net_device *dev)
530{
531 struct bfin_can_priv *priv = netdev_priv(dev);
532 int err;
533
534 /* set chip into reset mode */
535 bfin_can_set_reset_mode(dev);
536
537 /* common open */
538 err = open_candev(dev);
539 if (err)
540 goto exit_open;
541
542 /* register interrupt handler */
543 err = request_irq(priv->rx_irq, &bfin_can_interrupt, 0,
544 "bfin-can-rx", dev);
545 if (err)
546 goto exit_rx_irq;
547 err = request_irq(priv->tx_irq, &bfin_can_interrupt, 0,
548 "bfin-can-tx", dev);
549 if (err)
550 goto exit_tx_irq;
551 err = request_irq(priv->err_irq, &bfin_can_interrupt, 0,
552 "bfin-can-err", dev);
553 if (err)
554 goto exit_err_irq;
555
556 bfin_can_start(dev);
557
558 netif_start_queue(dev);
559
560 return 0;
561
562exit_err_irq:
563 free_irq(priv->tx_irq, dev);
564exit_tx_irq:
565 free_irq(priv->rx_irq, dev);
566exit_rx_irq:
567 close_candev(dev);
568exit_open:
569 return err;
570}
571
572static int bfin_can_close(struct net_device *dev)
573{
574 struct bfin_can_priv *priv = netdev_priv(dev);
575
576 netif_stop_queue(dev);
577 bfin_can_set_reset_mode(dev);
578
579 close_candev(dev);
580
581 free_irq(priv->rx_irq, dev);
582 free_irq(priv->tx_irq, dev);
583 free_irq(priv->err_irq, dev);
584
585 return 0;
586}
587
588struct net_device *alloc_bfin_candev(void)
589{
590 struct net_device *dev;
591 struct bfin_can_priv *priv;
592
593 dev = alloc_candev(sizeof(*priv));
594 if (!dev)
595 return NULL;
596
597 priv = netdev_priv(dev);
598
599 priv->dev = dev;
600 priv->can.bittiming_const = &bfin_can_bittiming_const;
601 priv->can.do_set_bittiming = bfin_can_set_bittiming;
602 priv->can.do_set_mode = bfin_can_set_mode;
603
604 return dev;
605}
606
607static const struct net_device_ops bfin_can_netdev_ops = {
608 .ndo_open = bfin_can_open,
609 .ndo_stop = bfin_can_close,
610 .ndo_start_xmit = bfin_can_start_xmit,
611};
612
613static int __devinit bfin_can_probe(struct platform_device *pdev)
614{
615 int err;
616 struct net_device *dev;
617 struct bfin_can_priv *priv;
618 struct resource *res_mem, *rx_irq, *tx_irq, *err_irq;
619 unsigned short *pdata;
620
621 pdata = pdev->dev.platform_data;
622 if (!pdata) {
623 dev_err(&pdev->dev, "No platform data provided!\n");
624 err = -EINVAL;
625 goto exit;
626 }
627
628 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
629 rx_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
630 tx_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
631 err_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 2);
632 if (!res_mem || !rx_irq || !tx_irq || !err_irq) {
633 err = -EINVAL;
634 goto exit;
635 }
636
637 if (!request_mem_region(res_mem->start, resource_size(res_mem),
638 dev_name(&pdev->dev))) {
639 err = -EBUSY;
640 goto exit;
641 }
642
643 /* request peripheral pins */
644 err = peripheral_request_list(pdata, dev_name(&pdev->dev));
645 if (err)
646 goto exit_mem_release;
647
648 dev = alloc_bfin_candev();
649 if (!dev) {
650 err = -ENOMEM;
651 goto exit_peri_pin_free;
652 }
653
654 priv = netdev_priv(dev);
655 priv->membase = (void __iomem *)res_mem->start;
656 priv->rx_irq = rx_irq->start;
657 priv->tx_irq = tx_irq->start;
658 priv->err_irq = err_irq->start;
659 priv->pin_list = pdata;
660 priv->can.clock.freq = get_sclk();
661
662 dev_set_drvdata(&pdev->dev, dev);
663 SET_NETDEV_DEV(dev, &pdev->dev);
664
665 dev->flags |= IFF_ECHO; /* we support local echo */
666 dev->netdev_ops = &bfin_can_netdev_ops;
667
668 bfin_can_set_reset_mode(dev);
669
670 err = register_candev(dev);
671 if (err) {
672 dev_err(&pdev->dev, "registering failed (err=%d)\n", err);
673 goto exit_candev_free;
674 }
675
676 dev_info(&pdev->dev,
677 "%s device registered"
678 "(&reg_base=%p, rx_irq=%d, tx_irq=%d, err_irq=%d, sclk=%d)\n",
679 DRV_NAME, (void *)priv->membase, priv->rx_irq,
680 priv->tx_irq, priv->err_irq, priv->can.clock.freq);
681 return 0;
682
683exit_candev_free:
684 free_candev(dev);
685exit_peri_pin_free:
686 peripheral_free_list(pdata);
687exit_mem_release:
688 release_mem_region(res_mem->start, resource_size(res_mem));
689exit:
690 return err;
691}
692
693static int __devexit bfin_can_remove(struct platform_device *pdev)
694{
695 struct net_device *dev = dev_get_drvdata(&pdev->dev);
696 struct bfin_can_priv *priv = netdev_priv(dev);
697 struct resource *res;
698
699 bfin_can_set_reset_mode(dev);
700
701 unregister_candev(dev);
702
703 dev_set_drvdata(&pdev->dev, NULL);
704
705 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
706 release_mem_region(res->start, resource_size(res));
707
708 peripheral_free_list(priv->pin_list);
709
710 free_candev(dev);
711 return 0;
712}
713
714#ifdef CONFIG_PM
715static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg)
716{
717 struct net_device *dev = dev_get_drvdata(&pdev->dev);
718 struct bfin_can_priv *priv = netdev_priv(dev);
719 struct bfin_can_regs __iomem *reg = priv->membase;
720 int timeout = BFIN_CAN_TIMEOUT;
721
722 if (netif_running(dev)) {
723 /* enter sleep mode */
724 bfin_write16(&reg->ctrl, bfin_read16(&reg->ctrl) | SMR);
725 SSYNC();
726 while (!(bfin_read16(&reg->intr) & SMACK)) {
727 udelay(10);
728 if (--timeout == 0) {
729 dev_err(dev->dev.parent,
730 "fail to enter sleep mode\n");
731 BUG();
732 }
733 }
734 }
735
736 return 0;
737}
738
739static int bfin_can_resume(struct platform_device *pdev)
740{
741 struct net_device *dev = dev_get_drvdata(&pdev->dev);
742 struct bfin_can_priv *priv = netdev_priv(dev);
743 struct bfin_can_regs __iomem *reg = priv->membase;
744
745 if (netif_running(dev)) {
746 /* leave sleep mode */
747 bfin_write16(&reg->intr, 0);
748 SSYNC();
749 }
750
751 return 0;
752}
753#else
754#define bfin_can_suspend NULL
755#define bfin_can_resume NULL
756#endif /* CONFIG_PM */
757
758static struct platform_driver bfin_can_driver = {
759 .probe = bfin_can_probe,
760 .remove = __devexit_p(bfin_can_remove),
761 .suspend = bfin_can_suspend,
762 .resume = bfin_can_resume,
763 .driver = {
764 .name = DRV_NAME,
765 .owner = THIS_MODULE,
766 },
767};
768
769static int __init bfin_can_init(void)
770{
771 return platform_driver_register(&bfin_can_driver);
772}
773module_init(bfin_can_init);
774
775static void __exit bfin_can_exit(void)
776{
777 platform_driver_unregister(&bfin_can_driver);
778}
779module_exit(bfin_can_exit);
780
781MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
782MODULE_LICENSE("GPL");
783MODULE_DESCRIPTION("Blackfin on-chip CAN netdevice driver");
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 78b1b69b2921..9c5a1537939c 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -403,9 +403,8 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
403 403
404 for (i = 1; i < RXBDAT_OFF; i++) 404 for (i = 1; i < RXBDAT_OFF; i++)
405 buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i); 405 buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
406 len = buf[RXBDLC_OFF] & RXBDLC_LEN_MASK; 406
407 if (len > 8) 407 len = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
408 len = 8;
409 for (; i < (RXBDAT_OFF + len); i++) 408 for (; i < (RXBDAT_OFF + len); i++)
410 buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i); 409 buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
411 } else { 410 } else {
@@ -455,13 +454,7 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
455 (buf[RXBSIDL_OFF] >> RXBSIDL_SHIFT); 454 (buf[RXBSIDL_OFF] >> RXBSIDL_SHIFT);
456 } 455 }
457 /* Data length */ 456 /* Data length */
458 frame->can_dlc = buf[RXBDLC_OFF] & RXBDLC_LEN_MASK; 457 frame->can_dlc = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
459 if (frame->can_dlc > 8) {
460 dev_warn(&spi->dev, "invalid frame recevied\n");
461 priv->net->stats.rx_errors++;
462 dev_kfree_skb(skb);
463 return;
464 }
465 memcpy(frame->data, buf + RXBDAT_OFF, frame->can_dlc); 458 memcpy(frame->data, buf + RXBDAT_OFF, frame->can_dlc);
466 459
467 priv->net->stats.rx_packets++; 460 priv->net->stats.rx_packets++;
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index bb06dfb58f25..07346f880ca6 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -297,7 +297,8 @@ static void mscan_get_rx_frame(struct net_device *dev, struct can_frame *frame)
297 frame->can_id |= can_id >> 1; 297 frame->can_id |= can_id >> 1;
298 if (can_id & 1) 298 if (can_id & 1)
299 frame->can_id |= CAN_RTR_FLAG; 299 frame->can_id |= CAN_RTR_FLAG;
300 frame->can_dlc = in_8(&regs->rx.dlr) & 0xf; 300
301 frame->can_dlc = get_can_dlc(in_8(&regs->rx.dlr) & 0xf);
301 302
302 if (!(frame->can_id & CAN_RTR_FLAG)) { 303 if (!(frame->can_id & CAN_RTR_FLAG)) {
303 void __iomem *data = &regs->rx.dsr1_0; 304 void __iomem *data = &regs->rx.dsr1_0;
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index b4ba88a31075..542a4f7255b4 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -293,15 +293,14 @@ static void sja1000_rx(struct net_device *dev)
293 uint8_t fi; 293 uint8_t fi;
294 uint8_t dreg; 294 uint8_t dreg;
295 canid_t id; 295 canid_t id;
296 uint8_t dlc;
297 int i; 296 int i;
298 297
298 /* create zero'ed CAN frame buffer */
299 skb = alloc_can_skb(dev, &cf); 299 skb = alloc_can_skb(dev, &cf);
300 if (skb == NULL) 300 if (skb == NULL)
301 return; 301 return;
302 302
303 fi = priv->read_reg(priv, REG_FI); 303 fi = priv->read_reg(priv, REG_FI);
304 dlc = fi & 0x0F;
305 304
306 if (fi & FI_FF) { 305 if (fi & FI_FF) {
307 /* extended frame format (EFF) */ 306 /* extended frame format (EFF) */
@@ -318,16 +317,15 @@ static void sja1000_rx(struct net_device *dev)
318 | (priv->read_reg(priv, REG_ID2) >> 5); 317 | (priv->read_reg(priv, REG_ID2) >> 5);
319 } 318 }
320 319
321 if (fi & FI_RTR) 320 if (fi & FI_RTR) {
322 id |= CAN_RTR_FLAG; 321 id |= CAN_RTR_FLAG;
322 } else {
323 cf->can_dlc = get_can_dlc(fi & 0x0F);
324 for (i = 0; i < cf->can_dlc; i++)
325 cf->data[i] = priv->read_reg(priv, dreg++);
326 }
323 327
324 cf->can_id = id; 328 cf->can_id = id;
325 cf->can_dlc = dlc;
326 for (i = 0; i < dlc; i++)
327 cf->data[i] = priv->read_reg(priv, dreg++);
328
329 while (i < 8)
330 cf->data[i++] = 0;
331 329
332 /* release receive buffer */ 330 /* release receive buffer */
333 priv->write_reg(priv, REG_CMR, CMD_RRB); 331 priv->write_reg(priv, REG_CMR, CMD_RRB);
@@ -335,7 +333,7 @@ static void sja1000_rx(struct net_device *dev)
335 netif_rx(skb); 333 netif_rx(skb);
336 334
337 stats->rx_packets++; 335 stats->rx_packets++;
338 stats->rx_bytes += dlc; 336 stats->rx_bytes += cf->can_dlc;
339} 337}
340 338
341static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) 339static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 07e8016b17ec..5c993c2da528 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -552,7 +552,7 @@ static int ti_hecc_rx_pkt(struct ti_hecc_priv *priv, int mbxno)
552 data = hecc_read_mbx(priv, mbxno, HECC_CANMCF); 552 data = hecc_read_mbx(priv, mbxno, HECC_CANMCF);
553 if (data & HECC_CANMCF_RTR) 553 if (data & HECC_CANMCF_RTR)
554 cf->can_id |= CAN_RTR_FLAG; 554 cf->can_id |= CAN_RTR_FLAG;
555 cf->can_dlc = data & 0xF; 555 cf->can_dlc = get_can_dlc(data & 0xF);
556 data = hecc_read_mbx(priv, mbxno, HECC_CANMDL); 556 data = hecc_read_mbx(priv, mbxno, HECC_CANMDL);
557 *(u32 *)(cf->data) = cpu_to_be32(data); 557 *(u32 *)(cf->data) = cpu_to_be32(data);
558 if (cf->can_dlc > 4) { 558 if (cf->can_dlc > 4) {
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 591eb0eb1c2b..efbb05c71bf4 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -316,7 +316,7 @@ static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
316 return; 316 return;
317 317
318 cf->can_id = le32_to_cpu(msg->msg.can_msg.id); 318 cf->can_id = le32_to_cpu(msg->msg.can_msg.id);
319 cf->can_dlc = min_t(u8, msg->msg.can_msg.length, 8); 319 cf->can_dlc = get_can_dlc(msg->msg.can_msg.length & 0xF);
320 320
321 if (msg->type == CPC_MSG_TYPE_EXT_CAN_FRAME || 321 if (msg->type == CPC_MSG_TYPE_EXT_CAN_FRAME ||
322 msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME) 322 msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index d4c6e7fcff53..4332b3a2fafb 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -1104,6 +1104,8 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev)
1104 cp->bnx2x_status_blk = cp->status_blk; 1104 cp->bnx2x_status_blk = cp->status_blk;
1105 cp->bnx2x_def_status_blk = cp->ethdev->irq_arr[1].status_blk; 1105 cp->bnx2x_def_status_blk = cp->ethdev->irq_arr[1].status_blk;
1106 1106
1107 memset(cp->bnx2x_status_blk, 0, sizeof(struct host_status_block));
1108
1107 cp->l2_rx_ring_size = 15; 1109 cp->l2_rx_ring_size = 15;
1108 1110
1109 ret = cnic_alloc_l2_rings(dev, 4); 1111 ret = cnic_alloc_l2_rings(dev, 4);
@@ -4183,6 +4185,12 @@ static void cnic_shutdown_rings(struct cnic_dev *dev)
4183 cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_HALT, 4185 cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_HALT,
4184 BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE, &l5_data); 4186 BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE, &l5_data);
4185 msleep(10); 4187 msleep(10);
4188
4189 memset(&l5_data, 0, sizeof(l5_data));
4190 cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CFC_DEL,
4191 BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE |
4192 (1 << SPE_HDR_COMMON_RAMROD_SHIFT), &l5_data);
4193 msleep(10);
4186 } 4194 }
4187} 4195}
4188 4196
@@ -4289,6 +4297,9 @@ static void cnic_stop_bnx2x_hw(struct cnic_dev *dev)
4289 offsetof(struct cstorm_status_block_c, 4297 offsetof(struct cstorm_status_block_c,
4290 index_values[HC_INDEX_C_ISCSI_EQ_CONS]), 4298 index_values[HC_INDEX_C_ISCSI_EQ_CONS]),
4291 0); 4299 0);
4300 CNIC_WR(dev, BAR_CSTRORM_INTMEM +
4301 CSTORM_ISCSI_EQ_CONS_OFFSET(cp->func, 0), 0);
4302 CNIC_WR16(dev, cp->kcq_io_addr, 0);
4292 cnic_free_resc(dev); 4303 cnic_free_resc(dev);
4293} 4304}
4294 4305
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 678222389407..8d0be26f94e3 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -1163,7 +1163,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1163 priv->dev = dev; 1163 priv->dev = dev;
1164 priv->ring_size = 64; 1164 priv->ring_size = 64;
1165 priv->msg_enable = netif_msg_init(debug_level, 0xff); 1165 priv->msg_enable = netif_msg_init(debug_level, 0xff);
1166 memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); 1166 memcpy(dev->dev_addr, pdata->dev_addr, sizeof(pdata->dev_addr));
1167 1167
1168 snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); 1168 snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
1169 1169
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index cef3f882e2b6..89bec9c3c141 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -2860,6 +2860,7 @@ static int t3_reenable_adapter(struct adapter *adapter)
2860 } 2860 }
2861 pci_set_master(adapter->pdev); 2861 pci_set_master(adapter->pdev);
2862 pci_restore_state(adapter->pdev); 2862 pci_restore_state(adapter->pdev);
2863 pci_save_state(adapter->pdev);
2863 2864
2864 /* Free sge resources */ 2865 /* Free sge resources */
2865 t3_free_sge_resources(adapter); 2866 t3_free_sge_resources(adapter);
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/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 16349ba68736..78963a0e128d 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -4608,8 +4608,14 @@ static void igb_rcv_msg_from_vf(struct igb_adapter *adapter, u32 vf)
4608 4608
4609 retval = igb_read_mbx(hw, msgbuf, E1000_VFMAILBOX_SIZE, vf); 4609 retval = igb_read_mbx(hw, msgbuf, E1000_VFMAILBOX_SIZE, vf);
4610 4610
4611 if (retval) 4611 if (retval) {
4612 /* if receive failed revoke VF CTS stats and restart init */
4612 dev_err(&pdev->dev, "Error receiving message from VF\n"); 4613 dev_err(&pdev->dev, "Error receiving message from VF\n");
4614 vf_data->flags &= ~IGB_VF_FLAG_CTS;
4615 if (!time_after(jiffies, vf_data->last_nack + (2 * HZ)))
4616 return;
4617 goto out;
4618 }
4613 4619
4614 /* this is a message we already processed, do nothing */ 4620 /* this is a message we already processed, do nothing */
4615 if (msgbuf[0] & (E1000_VT_MSGTYPE_ACK | E1000_VT_MSGTYPE_NACK)) 4621 if (msgbuf[0] & (E1000_VT_MSGTYPE_ACK | E1000_VT_MSGTYPE_NACK))
@@ -4626,12 +4632,10 @@ static void igb_rcv_msg_from_vf(struct igb_adapter *adapter, u32 vf)
4626 } 4632 }
4627 4633
4628 if (!(vf_data->flags & IGB_VF_FLAG_CTS)) { 4634 if (!(vf_data->flags & IGB_VF_FLAG_CTS)) {
4629 msgbuf[0] = E1000_VT_MSGTYPE_NACK; 4635 if (!time_after(jiffies, vf_data->last_nack + (2 * HZ)))
4630 if (time_after(jiffies, vf_data->last_nack + (2 * HZ))) { 4636 return;
4631 igb_write_mbx(hw, msgbuf, 1, vf); 4637 retval = -1;
4632 vf_data->last_nack = jiffies; 4638 goto out;
4633 }
4634 return;
4635 } 4639 }
4636 4640
4637 switch ((msgbuf[0] & 0xFFFF)) { 4641 switch ((msgbuf[0] & 0xFFFF)) {
@@ -4656,14 +4660,14 @@ static void igb_rcv_msg_from_vf(struct igb_adapter *adapter, u32 vf)
4656 break; 4660 break;
4657 } 4661 }
4658 4662
4663 msgbuf[0] |= E1000_VT_MSGTYPE_CTS;
4664out:
4659 /* notify the VF of the results of what it sent us */ 4665 /* notify the VF of the results of what it sent us */
4660 if (retval) 4666 if (retval)
4661 msgbuf[0] |= E1000_VT_MSGTYPE_NACK; 4667 msgbuf[0] |= E1000_VT_MSGTYPE_NACK;
4662 else 4668 else
4663 msgbuf[0] |= E1000_VT_MSGTYPE_ACK; 4669 msgbuf[0] |= E1000_VT_MSGTYPE_ACK;
4664 4670
4665 msgbuf[0] |= E1000_VT_MSGTYPE_CTS;
4666
4667 igb_write_mbx(hw, msgbuf, 1, vf); 4671 igb_write_mbx(hw, msgbuf, 1, vf);
4668} 4672}
4669 4673
diff --git a/drivers/net/igbvf/igbvf.h b/drivers/net/igbvf/igbvf.h
index 3d1ee7a8478e..a1774b29d222 100644
--- a/drivers/net/igbvf/igbvf.h
+++ b/drivers/net/igbvf/igbvf.h
@@ -276,6 +276,7 @@ struct igbvf_adapter {
276 unsigned long led_status; 276 unsigned long led_status;
277 277
278 unsigned int flags; 278 unsigned int flags;
279 unsigned long last_reset;
279}; 280};
280 281
281struct igbvf_info { 282struct igbvf_info {
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c
index a127620dc653..e9dd95f136aa 100644
--- a/drivers/net/igbvf/netdev.c
+++ b/drivers/net/igbvf/netdev.c
@@ -1469,6 +1469,8 @@ static void igbvf_reset(struct igbvf_adapter *adapter)
1469 memcpy(netdev->perm_addr, adapter->hw.mac.addr, 1469 memcpy(netdev->perm_addr, adapter->hw.mac.addr,
1470 netdev->addr_len); 1470 netdev->addr_len);
1471 } 1471 }
1472
1473 adapter->last_reset = jiffies;
1472} 1474}
1473 1475
1474int igbvf_up(struct igbvf_adapter *adapter) 1476int igbvf_up(struct igbvf_adapter *adapter)
@@ -1812,11 +1814,15 @@ static bool igbvf_has_link(struct igbvf_adapter *adapter)
1812 s32 ret_val = E1000_SUCCESS; 1814 s32 ret_val = E1000_SUCCESS;
1813 bool link_active; 1815 bool link_active;
1814 1816
1817 /* If interface is down, stay link down */
1818 if (test_bit(__IGBVF_DOWN, &adapter->state))
1819 return false;
1820
1815 ret_val = hw->mac.ops.check_for_link(hw); 1821 ret_val = hw->mac.ops.check_for_link(hw);
1816 link_active = !hw->mac.get_link_status; 1822 link_active = !hw->mac.get_link_status;
1817 1823
1818 /* if check for link returns error we will need to reset */ 1824 /* if check for link returns error we will need to reset */
1819 if (ret_val) 1825 if (ret_val && time_after(jiffies, adapter->last_reset + (10 * HZ)))
1820 schedule_work(&adapter->reset_task); 1826 schedule_work(&adapter->reset_task);
1821 1827
1822 return link_active; 1828 return link_active;
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/mlx4/sense.c b/drivers/net/mlx4/sense.c
index f36ae691cab3..015fbe785c13 100644
--- a/drivers/net/mlx4/sense.c
+++ b/drivers/net/mlx4/sense.c
@@ -53,7 +53,7 @@ static int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
53 53
54 if (out_param > 2) { 54 if (out_param > 2) {
55 mlx4_err(dev, "Sense returned illegal value: 0x%llx\n", out_param); 55 mlx4_err(dev, "Sense returned illegal value: 0x%llx\n", out_param);
56 return EINVAL; 56 return -EINVAL;
57 } 57 }
58 58
59 *type = out_param; 59 *type = out_param;
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/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 17a27225cc98..98938ea9e0bd 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -912,7 +912,11 @@ static void media_check(unsigned long arg)
912 if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) == 0xff)) { 912 if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) == 0xff)) {
913 if (!lp->fast_poll) 913 if (!lp->fast_poll)
914 printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); 914 printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
915
916 local_irq_save(flags);
915 el3_interrupt(dev->irq, dev); 917 el3_interrupt(dev->irq, dev);
918 local_irq_restore(flags);
919
916 lp->fast_poll = HZ; 920 lp->fast_poll = HZ;
917 } 921 }
918 if (lp->fast_poll) { 922 if (lp->fast_poll) {
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 6f8d7e2e5922..322e11df0097 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -711,7 +711,11 @@ static void media_check(unsigned long arg)
711 (inb(ioaddr + EL3_TIMER) == 0xff)) { 711 (inb(ioaddr + EL3_TIMER) == 0xff)) {
712 if (!lp->fast_poll) 712 if (!lp->fast_poll)
713 printk(KERN_WARNING "%s: interrupt(s) dropped!\n", dev->name); 713 printk(KERN_WARNING "%s: interrupt(s) dropped!\n", dev->name);
714
715 local_irq_save(flags);
714 el3_interrupt(dev->irq, dev); 716 el3_interrupt(dev->irq, dev);
717 local_irq_restore(flags);
718
715 lp->fast_poll = HZ; 719 lp->fast_poll = HZ;
716 } 720 }
717 if (lp->fast_poll) { 721 if (lp->fast_poll) {
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index 14949bb303a0..af3933579790 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -47,7 +47,7 @@ static const unsigned char payload_source[ETH_ALEN] = {
47 0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b, 47 0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b,
48}; 48};
49 49
50static const char *payload_msg = 50static const char payload_msg[] =
51 "Hello world! This is an Efx loopback test in progress!"; 51 "Hello world! This is an Efx loopback test in progress!";
52 52
53/** 53/**
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 044e6817986f..1c01b96c9611 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -644,7 +644,6 @@ static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
644{ 644{
645 u32 reg1; 645 u32 reg1;
646 646
647 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
648 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1); 647 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
649 reg1 &= ~phy_power[port]; 648 reg1 &= ~phy_power[port];
650 649
@@ -652,7 +651,6 @@ static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
652 reg1 |= coma_mode[port]; 651 reg1 |= coma_mode[port];
653 652
654 sky2_pci_write32(hw, PCI_DEV_REG1, reg1); 653 sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
655 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
656 sky2_pci_read32(hw, PCI_DEV_REG1); 654 sky2_pci_read32(hw, PCI_DEV_REG1);
657 655
658 if (hw->chip_id == CHIP_ID_YUKON_FE) 656 if (hw->chip_id == CHIP_ID_YUKON_FE)
@@ -709,11 +707,9 @@ static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
709 gm_phy_write(hw, port, PHY_MARV_CTRL, PHY_CT_PDOWN); 707 gm_phy_write(hw, port, PHY_MARV_CTRL, PHY_CT_PDOWN);
710 } 708 }
711 709
712 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
713 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1); 710 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
714 reg1 |= phy_power[port]; /* set PHY to PowerDown/COMA Mode */ 711 reg1 |= phy_power[port]; /* set PHY to PowerDown/COMA Mode */
715 sky2_pci_write32(hw, PCI_DEV_REG1, reg1); 712 sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
716 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
717} 713}
718 714
719/* Force a renegotiation */ 715/* Force a renegotiation */
@@ -2643,7 +2639,6 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2643 if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) { 2639 if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
2644 u16 pci_err; 2640 u16 pci_err;
2645 2641
2646 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2647 pci_err = sky2_pci_read16(hw, PCI_STATUS); 2642 pci_err = sky2_pci_read16(hw, PCI_STATUS);
2648 if (net_ratelimit()) 2643 if (net_ratelimit())
2649 dev_err(&pdev->dev, "PCI hardware error (0x%x)\n", 2644 dev_err(&pdev->dev, "PCI hardware error (0x%x)\n",
@@ -2651,14 +2646,12 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2651 2646
2652 sky2_pci_write16(hw, PCI_STATUS, 2647 sky2_pci_write16(hw, PCI_STATUS,
2653 pci_err | PCI_STATUS_ERROR_BITS); 2648 pci_err | PCI_STATUS_ERROR_BITS);
2654 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2655 } 2649 }
2656 2650
2657 if (status & Y2_IS_PCI_EXP) { 2651 if (status & Y2_IS_PCI_EXP) {
2658 /* PCI-Express uncorrectable Error occurred */ 2652 /* PCI-Express uncorrectable Error occurred */
2659 u32 err; 2653 u32 err;
2660 2654
2661 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2662 err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS); 2655 err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
2663 sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS, 2656 sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
2664 0xfffffffful); 2657 0xfffffffful);
@@ -2666,7 +2659,6 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2666 dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err); 2659 dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err);
2667 2660
2668 sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS); 2661 sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
2669 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2670 } 2662 }
2671 2663
2672 if (status & Y2_HWE_L1_MASK) 2664 if (status & Y2_HWE_L1_MASK)
@@ -2968,8 +2960,13 @@ static int __devinit sky2_init(struct sky2_hw *hw)
2968 break; 2960 break;
2969 2961
2970 case CHIP_ID_YUKON_UL_2: 2962 case CHIP_ID_YUKON_UL_2:
2963 hw->flags = SKY2_HW_GIGABIT
2964 | SKY2_HW_ADV_POWER_CTL;
2965 break;
2966
2971 case CHIP_ID_YUKON_OPT: 2967 case CHIP_ID_YUKON_OPT:
2972 hw->flags = SKY2_HW_GIGABIT 2968 hw->flags = SKY2_HW_GIGABIT
2969 | SKY2_HW_NEW_LE
2973 | SKY2_HW_ADV_POWER_CTL; 2970 | SKY2_HW_ADV_POWER_CTL;
2974 break; 2971 break;
2975 2972
@@ -3040,7 +3037,6 @@ static void sky2_reset(struct sky2_hw *hw)
3040 } 3037 }
3041 3038
3042 sky2_power_on(hw); 3039 sky2_power_on(hw);
3043 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
3044 3040
3045 for (i = 0; i < hw->ports; i++) { 3041 for (i = 0; i < hw->ports; i++) {
3046 sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET); 3042 sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET);
@@ -4521,7 +4517,7 @@ static const char *sky2_name(u8 chipid, char *buf, int sz)
4521 "Optima", /* 0xbc */ 4517 "Optima", /* 0xbc */
4522 }; 4518 };
4523 4519
4524 if (chipid >= CHIP_ID_YUKON_XL && chipid < CHIP_ID_YUKON_OPT) 4520 if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_OPT)
4525 strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz); 4521 strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz);
4526 else 4522 else
4527 snprintf(buf, sz, "(chip %#x)", chipid); 4523 snprintf(buf, sz, "(chip %#x)", chipid);
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index ae4983a5127d..ea4fae79d6ec 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -534,9 +534,9 @@ static inline void smc_rcv(struct net_device *dev)
534#define smc_special_lock(lock, flags) spin_lock_irqsave(lock, flags) 534#define smc_special_lock(lock, flags) spin_lock_irqsave(lock, flags)
535#define smc_special_unlock(lock, flags) spin_unlock_irqrestore(lock, flags) 535#define smc_special_unlock(lock, flags) spin_unlock_irqrestore(lock, flags)
536#else 536#else
537#define smc_special_trylock(lock, flags) (1) 537#define smc_special_trylock(lock, flags) (flags == flags)
538#define smc_special_lock(lock, flags) do { } while (0) 538#define smc_special_lock(lock, flags) do { flags = 0; } while (0)
539#define smc_special_unlock(lock, flags) do { } while (0) 539#define smc_special_unlock(lock, flags) do { flags = 0; } while (0)
540#endif 540#endif
541 541
542/* 542/*
@@ -2387,7 +2387,7 @@ static int smc_drv_resume(struct device *dev)
2387 2387
2388 if (ndev) { 2388 if (ndev) {
2389 struct smc_local *lp = netdev_priv(ndev); 2389 struct smc_local *lp = netdev_priv(ndev);
2390 smc_enable_device(dev); 2390 smc_enable_device(pdev);
2391 if (netif_running(ndev)) { 2391 if (netif_running(ndev)) {
2392 smc_reset(ndev); 2392 smc_reset(ndev);
2393 smc_enable(ndev); 2393 smc_enable(ndev);
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 3b80e8d2d621..f1d64ef67efa 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -716,7 +716,7 @@ static int kaweth_open(struct net_device *net)
716 return 0; 716 return 0;
717 717
718err_out: 718err_out:
719 usb_autopm_enable(kaweth->intf); 719 usb_autopm_put_interface(kaweth->intf);
720 return -EIO; 720 return -EIO;
721} 721}
722 722
@@ -753,7 +753,7 @@ static int kaweth_close(struct net_device *net)
753 753
754 kaweth->status &= ~KAWETH_STATUS_CLOSING; 754 kaweth->status &= ~KAWETH_STATUS_CLOSING;
755 755
756 usb_autopm_enable(kaweth->intf); 756 usb_autopm_put_interface(kaweth->intf);
757 757
758 return 0; 758 return 0;
759} 759}
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index b091e20ca167..f14d225404da 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -324,7 +324,7 @@ static int rtl8150_set_mac_address(struct net_device *netdev, void *p)
324 dbg("%02X:", netdev->dev_addr[i]); 324 dbg("%02X:", netdev->dev_addr[i]);
325 dbg("%02X\n", netdev->dev_addr[i]); 325 dbg("%02X\n", netdev->dev_addr[i]);
326 /* Set the IDR registers. */ 326 /* Set the IDR registers. */
327 set_registers(dev, IDR, sizeof(netdev->dev_addr), netdev->dev_addr); 327 set_registers(dev, IDR, netdev->addr_len, netdev->dev_addr);
328#ifdef EEPROM_WRITE 328#ifdef EEPROM_WRITE
329 { 329 {
330 u8 cr; 330 u8 cr;
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 81ea52c4faff..5d1c8677f180 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/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 564c6cb1c2b4..2a11cc57ceea 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2078,7 +2078,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
2078 &txq->axq_q, lastbf->list.prev); 2078 &txq->axq_q, lastbf->list.prev);
2079 2079
2080 txq->axq_depth--; 2080 txq->axq_depth--;
2081 txok = (ds->ds_txstat.ts_status == 0); 2081 txok = !(ds->ds_txstat.ts_status & ATH9K_TXERR_FILT);
2082 txq->axq_tx_inprogress = false; 2082 txq->axq_tx_inprogress = false;
2083 spin_unlock_bh(&txq->axq_lock); 2083 spin_unlock_bh(&txq->axq_lock);
2084 2084
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 71e5c996bd09..4c41cfe44f26 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-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 58b132f9cf28..00da5e152d46 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -1353,7 +1353,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 == 1353 if (priv->stations[sta_id].tid[tid].agg.state ==
1354 IWL_EMPTYING_HW_QUEUE_ADDBA) { 1354 IWL_EMPTYING_HW_QUEUE_ADDBA) {
1355 IWL_DEBUG_HT(priv, "AGG stop before setup done\n"); 1355 IWL_DEBUG_HT(priv, "AGG stop before setup done\n");
1356 ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, ra, tid); 1356 ieee80211_stop_tx_ba_cb_irqsafe(priv->vif, ra, tid);
1357 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; 1357 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
1358 return 0; 1358 return 0;
1359 } 1359 }
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 84200da900b6..fb157eb889ca 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/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 ff4be7bf5d36..2f50a256efa5 100644
--- a/drivers/net/wireless/wl12xx/wl1251_main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -629,10 +629,6 @@ static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed)
629 goto out_sleep; 629 goto out_sleep;
630 } 630 }
631 631
632 ret = wl1251_build_null_data(wl);
633 if (ret < 0)
634 goto out_sleep;
635
636 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) { 632 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) {
637 wl1251_debug(DEBUG_PSM, "psm enabled"); 633 wl1251_debug(DEBUG_PSM, "psm enabled");
638 634
@@ -1110,6 +1106,21 @@ static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
1110 if (ret < 0) 1106 if (ret < 0)
1111 goto out; 1107 goto out;
1112 1108
1109 if (changed & BSS_CHANGED_BSSID) {
1110 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1111
1112 ret = wl1251_build_null_data(wl);
1113 if (ret < 0)
1114 goto out;
1115
1116 if (wl->bss_type != BSS_TYPE_IBSS) {
1117 ret = wl1251_join(wl, wl->bss_type, wl->channel,
1118 wl->beacon_int, wl->dtim_period);
1119 if (ret < 0)
1120 goto out_sleep;
1121 }
1122 }
1123
1113 if (changed & BSS_CHANGED_ASSOC) { 1124 if (changed & BSS_CHANGED_ASSOC) {
1114 if (bss_conf->assoc) { 1125 if (bss_conf->assoc) {
1115 wl->beacon_int = bss_conf->beacon_int; 1126 wl->beacon_int = bss_conf->beacon_int;
@@ -1169,23 +1180,6 @@ static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
1169 } 1180 }
1170 } 1181 }
1171 1182
1172 if (changed & BSS_CHANGED_BSSID) {
1173 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1174
1175 ret = wl1251_build_null_data(wl);
1176 if (ret < 0)
1177 goto out;
1178
1179 if (wl->bss_type != BSS_TYPE_IBSS) {
1180 ret = wl1251_join(wl, wl->bss_type, wl->channel,
1181 wl->beacon_int, wl->dtim_period);
1182 if (ret < 0)
1183 goto out_sleep;
1184 wl1251_warning("Set ctsprotect failed %d", ret);
1185 goto out_sleep;
1186 }
1187 }
1188
1189 if (changed & BSS_CHANGED_BEACON) { 1183 if (changed & BSS_CHANGED_BEACON) {
1190 beacon = ieee80211_beacon_get(hw, vif); 1184 beacon = ieee80211_beacon_get(hw, vif);
1191 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data, 1185 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data,
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 1ed2a5cc03f5..3db7767d2a17 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -51,6 +51,15 @@ struct can_priv {
51 struct sk_buff **echo_skb; 51 struct sk_buff **echo_skb;
52}; 52};
53 53
54/*
55 * get_can_dlc(value) - helper macro to cast a given data length code (dlc)
56 * to __u8 and ensure the dlc value to be max. 8 bytes.
57 *
58 * To be used in the CAN netdriver receive path to ensure conformance with
59 * ISO 11898-1 Chapter 8.4.2.3 (DLC field)
60 */
61#define get_can_dlc(i) (min_t(__u8, (i), 8))
62
54struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); 63struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
55void free_candev(struct net_device *dev); 64void free_candev(struct net_device *dev);
56 65
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/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/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 14fc906ed602..05330fc5b436 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -368,11 +368,9 @@ enum {
368#define RTAX_MAX (__RTAX_MAX - 1) 368#define RTAX_MAX (__RTAX_MAX - 1)
369 369
370#define RTAX_FEATURE_ECN 0x00000001 370#define RTAX_FEATURE_ECN 0x00000001
371#define RTAX_FEATURE_NO_SACK 0x00000002 371#define RTAX_FEATURE_SACK 0x00000002
372#define RTAX_FEATURE_NO_TSTAMP 0x00000004 372#define RTAX_FEATURE_TIMESTAMP 0x00000004
373#define RTAX_FEATURE_ALLFRAG 0x00000008 373#define RTAX_FEATURE_ALLFRAG 0x00000008
374#define RTAX_FEATURE_NO_WSCALE 0x00000010
375#define RTAX_FEATURE_NO_DSACK 0x00000020
376 374
377struct rta_session { 375struct rta_session {
378 __u8 proto; 376 __u8 proto;
diff --git a/include/net/compat.h b/include/net/compat.h
index 3c7d4e38fa1d..28d5428ec6a2 100644
--- a/include/net/compat.h
+++ b/include/net/compat.h
@@ -46,7 +46,7 @@ extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr __user *,unsi
46extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned); 46extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned);
47extern asmlinkage long compat_sys_recvmmsg(int, struct compat_mmsghdr __user *, 47extern asmlinkage long compat_sys_recvmmsg(int, struct compat_mmsghdr __user *,
48 unsigned, unsigned, 48 unsigned, unsigned,
49 struct timespec __user *); 49 struct compat_timespec __user *);
50extern asmlinkage long compat_sys_getsockopt(int, int, int, char __user *, int __user *); 50extern asmlinkage long compat_sys_getsockopt(int, int, int, char __user *, int __user *);
51extern int put_cmsg_compat(struct msghdr*, int, int, int, void *); 51extern int put_cmsg_compat(struct msghdr*, int, int, int, void *);
52 52
diff --git a/include/net/dst.h b/include/net/dst.h
index 387cb3cfde7e..39c4a5963e12 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -113,7 +113,7 @@ dst_metric(const struct dst_entry *dst, int metric)
113static inline u32 113static inline u32
114dst_feature(const struct dst_entry *dst, u32 feature) 114dst_feature(const struct dst_entry *dst, u32 feature)
115{ 115{
116 return (dst ? dst_metric(dst, RTAX_FEATURES) & feature : 0); 116 return dst_metric(dst, RTAX_FEATURES) & feature;
117} 117}
118 118
119static inline u32 dst_mtu(const struct dst_entry *dst) 119static inline u32 dst_mtu(const struct dst_entry *dst)
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/tcp.h b/include/net/tcp.h
index 5740b85bc5a0..34f5cc24d903 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -408,8 +408,7 @@ extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk,
408extern void tcp_parse_options(struct sk_buff *skb, 408extern void tcp_parse_options(struct sk_buff *skb,
409 struct tcp_options_received *opt_rx, 409 struct tcp_options_received *opt_rx,
410 u8 **hvpp, 410 u8 **hvpp,
411 int estab, 411 int estab);
412 struct dst_entry *dst);
413 412
414extern u8 *tcp_parse_md5sig_option(struct tcphdr *th); 413extern u8 *tcp_parse_md5sig_option(struct tcphdr *th);
415 414
@@ -1261,29 +1260,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) \ 1260#define tcp_for_write_queue_from_safe(skb, tmp, sk) \
1262 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) 1261 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp)
1263 1262
1264/* This function calculates a "timeout" which is equivalent to the timeout of a
1265 * TCP connection after "boundary" unsuccessful, 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
1287static inline struct sk_buff *tcp_send_head(struct sock *sk) 1263static inline struct sk_buff *tcp_send_head(struct sock *sk)
1288{ 1264{
1289 return sk->sk_send_head; 1265 return sk->sk_send_head;
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/compat.c b/net/compat.c
index e1a56ade803b..a1fb1b079a82 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -754,26 +754,21 @@ asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
754 754
755asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, 755asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
756 unsigned vlen, unsigned int flags, 756 unsigned vlen, unsigned int flags,
757 struct timespec __user *timeout) 757 struct compat_timespec __user *timeout)
758{ 758{
759 int datagrams; 759 int datagrams;
760 struct timespec ktspec; 760 struct timespec ktspec;
761 struct compat_timespec __user *utspec;
762 761
763 if (timeout == NULL) 762 if (timeout == NULL)
764 return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, 763 return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
765 flags | MSG_CMSG_COMPAT, NULL); 764 flags | MSG_CMSG_COMPAT, NULL);
766 765
767 utspec = (struct compat_timespec __user *)timeout; 766 if (get_compat_timespec(&ktspec, timeout))
768 if (get_user(ktspec.tv_sec, &utspec->tv_sec) ||
769 get_user(ktspec.tv_nsec, &utspec->tv_nsec))
770 return -EFAULT; 767 return -EFAULT;
771 768
772 datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, 769 datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
773 flags | MSG_CMSG_COMPAT, &ktspec); 770 flags | MSG_CMSG_COMPAT, &ktspec);
774 if (datagrams > 0 && 771 if (datagrams > 0 && put_compat_timespec(&ktspec, timeout))
775 (put_user(ktspec.tv_sec, &utspec->tv_sec) ||
776 put_user(ktspec.tv_nsec, &utspec->tv_nsec)))
777 datagrams = -EFAULT; 772 datagrams = -EFAULT;
778 773
779 return datagrams; 774 return datagrams;
diff --git a/net/core/dev.c b/net/core/dev.c
index c36a17aafcf3..be9924f60ec3 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4771,21 +4771,23 @@ static void net_set_todo(struct net_device *dev)
4771 4771
4772static void rollback_registered_many(struct list_head *head) 4772static void rollback_registered_many(struct list_head *head)
4773{ 4773{
4774 struct net_device *dev; 4774 struct net_device *dev, *tmp;
4775 4775
4776 BUG_ON(dev_boot_phase); 4776 BUG_ON(dev_boot_phase);
4777 ASSERT_RTNL(); 4777 ASSERT_RTNL();
4778 4778
4779 list_for_each_entry(dev, head, unreg_list) { 4779 list_for_each_entry_safe(dev, tmp, head, unreg_list) {
4780 /* Some devices call without registering 4780 /* Some devices call without registering
4781 * for initialization unwind. 4781 * for initialization unwind. Remove those
4782 * devices and proceed with the remaining.
4782 */ 4783 */
4783 if (dev->reg_state == NETREG_UNINITIALIZED) { 4784 if (dev->reg_state == NETREG_UNINITIALIZED) {
4784 pr_debug("unregister_netdevice: device %s/%p never " 4785 pr_debug("unregister_netdevice: device %s/%p never "
4785 "was registered\n", dev->name, dev); 4786 "was registered\n", dev->name, dev);
4786 4787
4787 WARN_ON(1); 4788 WARN_ON(1);
4788 return; 4789 list_del(&dev->unreg_list);
4790 continue;
4789 } 4791 }
4790 4792
4791 BUG_ON(dev->reg_state != NETREG_REGISTERED); 4793 BUG_ON(dev->reg_state != NETREG_REGISTERED);
@@ -5033,6 +5035,11 @@ int register_netdevice(struct net_device *dev)
5033 rollback_registered(dev); 5035 rollback_registered(dev);
5034 dev->reg_state = NETREG_UNREGISTERED; 5036 dev->reg_state = NETREG_UNREGISTERED;
5035 } 5037 }
5038 /*
5039 * Prevent userspace races by waiting until the network
5040 * device is fully setup before sending notifications.
5041 */
5042 rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
5036 5043
5037out: 5044out:
5038 return ret; 5045 return ret;
@@ -5595,6 +5602,12 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
5595 /* Notify protocols, that a new device appeared. */ 5602 /* Notify protocols, that a new device appeared. */
5596 call_netdevice_notifiers(NETDEV_REGISTER, dev); 5603 call_netdevice_notifiers(NETDEV_REGISTER, dev);
5597 5604
5605 /*
5606 * Prevent userspace races by waiting until the network
5607 * device is fully setup before sending notifications.
5608 */
5609 rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
5610
5598 synchronize_net(); 5611 synchronize_net();
5599 err = 0; 5612 err = 0;
5600out: 5613out:
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 33148a568199..794bcb897ff0 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1364,15 +1364,15 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
1364 case NETDEV_UNREGISTER: 1364 case NETDEV_UNREGISTER:
1365 rtmsg_ifinfo(RTM_DELLINK, dev, ~0U); 1365 rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
1366 break; 1366 break;
1367 case NETDEV_REGISTER:
1368 rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
1369 break;
1370 case NETDEV_UP: 1367 case NETDEV_UP:
1371 case NETDEV_DOWN: 1368 case NETDEV_DOWN:
1372 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING); 1369 rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING);
1373 break; 1370 break;
1371 case NETDEV_POST_INIT:
1372 case NETDEV_REGISTER:
1374 case NETDEV_CHANGE: 1373 case NETDEV_CHANGE:
1375 case NETDEV_GOING_DOWN: 1374 case NETDEV_GOING_DOWN:
1375 case NETDEV_UNREGISTER_BATCH:
1376 break; 1376 break;
1377 default: 1377 default:
1378 rtmsg_ifinfo(RTM_NEWLINK, dev, 0); 1378 rtmsg_ifinfo(RTM_NEWLINK, dev, 0);
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/syncookies.c b/net/ipv4/syncookies.c
index 26399ad2a289..66fd80ef2473 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -277,6 +277,13 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
277 277
278 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV); 278 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV);
279 279
280 /* check for timestamp cookie support */
281 memset(&tcp_opt, 0, sizeof(tcp_opt));
282 tcp_parse_options(skb, &tcp_opt, &hash_location, 0);
283
284 if (tcp_opt.saw_tstamp)
285 cookie_check_timestamp(&tcp_opt);
286
280 ret = NULL; 287 ret = NULL;
281 req = inet_reqsk_alloc(&tcp_request_sock_ops); /* for safety */ 288 req = inet_reqsk_alloc(&tcp_request_sock_ops); /* for safety */
282 if (!req) 289 if (!req)
@@ -292,6 +299,12 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
292 ireq->loc_addr = ip_hdr(skb)->daddr; 299 ireq->loc_addr = ip_hdr(skb)->daddr;
293 ireq->rmt_addr = ip_hdr(skb)->saddr; 300 ireq->rmt_addr = ip_hdr(skb)->saddr;
294 ireq->ecn_ok = 0; 301 ireq->ecn_ok = 0;
302 ireq->snd_wscale = tcp_opt.snd_wscale;
303 ireq->rcv_wscale = tcp_opt.rcv_wscale;
304 ireq->sack_ok = tcp_opt.sack_ok;
305 ireq->wscale_ok = tcp_opt.wscale_ok;
306 ireq->tstamp_ok = tcp_opt.saw_tstamp;
307 req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
295 308
296 /* We throwed the options of the initial SYN away, so we hope 309 /* We throwed the options of the initial SYN away, so we hope
297 * the ACK carries the same options again (see RFC1122 4.2.3.8) 310 * the ACK carries the same options again (see RFC1122 4.2.3.8)
@@ -340,20 +353,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
340 } 353 }
341 } 354 }
342 355
343 /* check for timestamp cookie support */
344 memset(&tcp_opt, 0, sizeof(tcp_opt));
345 tcp_parse_options(skb, &tcp_opt, &hash_location, 0, &rt->u.dst);
346
347 if (tcp_opt.saw_tstamp)
348 cookie_check_timestamp(&tcp_opt);
349
350 ireq->snd_wscale = tcp_opt.snd_wscale;
351 ireq->rcv_wscale = tcp_opt.rcv_wscale;
352 ireq->sack_ok = tcp_opt.sack_ok;
353 ireq->wscale_ok = tcp_opt.wscale_ok;
354 ireq->tstamp_ok = tcp_opt.saw_tstamp;
355 req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
356
357 /* Try to redo what tcp_v4_send_synack did. */ 356 /* Try to redo what tcp_v4_send_synack did. */
358 req->window_clamp = tp->window_clamp ? :dst_metric(&rt->u.dst, RTAX_WINDOW); 357 req->window_clamp = tp->window_clamp ? :dst_metric(&rt->u.dst, RTAX_WINDOW);
359 358
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..28e029632493 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)
@@ -3698,7 +3727,7 @@ old_ack:
3698 * the fast version below fails. 3727 * the fast version below fails.
3699 */ 3728 */
3700void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, 3729void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
3701 u8 **hvpp, int estab, struct dst_entry *dst) 3730 u8 **hvpp, int estab)
3702{ 3731{
3703 unsigned char *ptr; 3732 unsigned char *ptr;
3704 struct tcphdr *th = tcp_hdr(skb); 3733 struct tcphdr *th = tcp_hdr(skb);
@@ -3737,8 +3766,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
3737 break; 3766 break;
3738 case TCPOPT_WINDOW: 3767 case TCPOPT_WINDOW:
3739 if (opsize == TCPOLEN_WINDOW && th->syn && 3768 if (opsize == TCPOLEN_WINDOW && th->syn &&
3740 !estab && sysctl_tcp_window_scaling && 3769 !estab && sysctl_tcp_window_scaling) {
3741 !dst_feature(dst, RTAX_FEATURE_NO_WSCALE)) {
3742 __u8 snd_wscale = *(__u8 *)ptr; 3770 __u8 snd_wscale = *(__u8 *)ptr;
3743 opt_rx->wscale_ok = 1; 3771 opt_rx->wscale_ok = 1;
3744 if (snd_wscale > 14) { 3772 if (snd_wscale > 14) {
@@ -3754,8 +3782,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
3754 case TCPOPT_TIMESTAMP: 3782 case TCPOPT_TIMESTAMP:
3755 if ((opsize == TCPOLEN_TIMESTAMP) && 3783 if ((opsize == TCPOLEN_TIMESTAMP) &&
3756 ((estab && opt_rx->tstamp_ok) || 3784 ((estab && opt_rx->tstamp_ok) ||
3757 (!estab && sysctl_tcp_timestamps && 3785 (!estab && sysctl_tcp_timestamps))) {
3758 !dst_feature(dst, RTAX_FEATURE_NO_TSTAMP)))) {
3759 opt_rx->saw_tstamp = 1; 3786 opt_rx->saw_tstamp = 1;
3760 opt_rx->rcv_tsval = get_unaligned_be32(ptr); 3787 opt_rx->rcv_tsval = get_unaligned_be32(ptr);
3761 opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4); 3788 opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4);
@@ -3763,8 +3790,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
3763 break; 3790 break;
3764 case TCPOPT_SACK_PERM: 3791 case TCPOPT_SACK_PERM:
3765 if (opsize == TCPOLEN_SACK_PERM && th->syn && 3792 if (opsize == TCPOLEN_SACK_PERM && th->syn &&
3766 !estab && sysctl_tcp_sack && 3793 !estab && sysctl_tcp_sack) {
3767 !dst_feature(dst, RTAX_FEATURE_NO_SACK)) {
3768 opt_rx->sack_ok = 1; 3794 opt_rx->sack_ok = 1;
3769 tcp_sack_reset(opt_rx); 3795 tcp_sack_reset(opt_rx);
3770 } 3796 }
@@ -3849,7 +3875,7 @@ static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th,
3849 if (tcp_parse_aligned_timestamp(tp, th)) 3875 if (tcp_parse_aligned_timestamp(tp, th))
3850 return 1; 3876 return 1;
3851 } 3877 }
3852 tcp_parse_options(skb, &tp->rx_opt, hvpp, 1, NULL); 3878 tcp_parse_options(skb, &tp->rx_opt, hvpp, 1);
3853 return 1; 3879 return 1;
3854} 3880}
3855 3881
@@ -4104,10 +4130,8 @@ static inline int tcp_sack_extend(struct tcp_sack_block *sp, u32 seq,
4104static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq) 4130static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq)
4105{ 4131{
4106 struct tcp_sock *tp = tcp_sk(sk); 4132 struct tcp_sock *tp = tcp_sk(sk);
4107 struct dst_entry *dst = __sk_dst_get(sk);
4108 4133
4109 if (tcp_is_sack(tp) && sysctl_tcp_dsack && 4134 if (tcp_is_sack(tp) && sysctl_tcp_dsack) {
4110 !dst_feature(dst, RTAX_FEATURE_NO_DSACK)) {
4111 int mib_idx; 4135 int mib_idx;
4112 4136
4113 if (before(seq, tp->rcv_nxt)) 4137 if (before(seq, tp->rcv_nxt))
@@ -4136,15 +4160,13 @@ static void tcp_dsack_extend(struct sock *sk, u32 seq, u32 end_seq)
4136static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb) 4160static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb)
4137{ 4161{
4138 struct tcp_sock *tp = tcp_sk(sk); 4162 struct tcp_sock *tp = tcp_sk(sk);
4139 struct dst_entry *dst = __sk_dst_get(sk);
4140 4163
4141 if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && 4164 if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
4142 before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { 4165 before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
4143 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_DELAYEDACKLOST); 4166 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_DELAYEDACKLOST);
4144 tcp_enter_quickack_mode(sk); 4167 tcp_enter_quickack_mode(sk);
4145 4168
4146 if (tcp_is_sack(tp) && sysctl_tcp_dsack && 4169 if (tcp_is_sack(tp) && sysctl_tcp_dsack) {
4147 !dst_feature(dst, RTAX_FEATURE_NO_DSACK)) {
4148 u32 end_seq = TCP_SKB_CB(skb)->end_seq; 4170 u32 end_seq = TCP_SKB_CB(skb)->end_seq;
4149 4171
4150 if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) 4172 if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt))
@@ -5399,11 +5421,10 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
5399 u8 *hash_location; 5421 u8 *hash_location;
5400 struct inet_connection_sock *icsk = inet_csk(sk); 5422 struct inet_connection_sock *icsk = inet_csk(sk);
5401 struct tcp_sock *tp = tcp_sk(sk); 5423 struct tcp_sock *tp = tcp_sk(sk);
5402 struct dst_entry *dst = __sk_dst_get(sk);
5403 struct tcp_cookie_values *cvp = tp->cookie_values; 5424 struct tcp_cookie_values *cvp = tp->cookie_values;
5404 int saved_clamp = tp->rx_opt.mss_clamp; 5425 int saved_clamp = tp->rx_opt.mss_clamp;
5405 5426
5406 tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0, dst); 5427 tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0);
5407 5428
5408 if (th->ack) { 5429 if (th->ack) {
5409 /* rfc793: 5430 /* rfc793:
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 29002ab26e0d..65b8ebfd078a 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1262,20 +1262,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1262 tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops; 1262 tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops;
1263#endif 1263#endif
1264 1264
1265 ireq = inet_rsk(req);
1266 ireq->loc_addr = daddr;
1267 ireq->rmt_addr = saddr;
1268 ireq->no_srccheck = inet_sk(sk)->transparent;
1269 ireq->opt = tcp_v4_save_options(sk, skb);
1270
1271 dst = inet_csk_route_req(sk, req);
1272 if(!dst)
1273 goto drop_and_free;
1274
1275 tcp_clear_options(&tmp_opt); 1265 tcp_clear_options(&tmp_opt);
1276 tmp_opt.mss_clamp = TCP_MSS_DEFAULT; 1266 tmp_opt.mss_clamp = TCP_MSS_DEFAULT;
1277 tmp_opt.user_mss = tp->rx_opt.user_mss; 1267 tmp_opt.user_mss = tp->rx_opt.user_mss;
1278 tcp_parse_options(skb, &tmp_opt, &hash_location, 0, dst); 1268 tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
1279 1269
1280 if (tmp_opt.cookie_plus > 0 && 1270 if (tmp_opt.cookie_plus > 0 &&
1281 tmp_opt.saw_tstamp && 1271 tmp_opt.saw_tstamp &&
@@ -1319,8 +1309,14 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1319 tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; 1309 tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
1320 tcp_openreq_init(req, &tmp_opt, skb); 1310 tcp_openreq_init(req, &tmp_opt, skb);
1321 1311
1312 ireq = inet_rsk(req);
1313 ireq->loc_addr = daddr;
1314 ireq->rmt_addr = saddr;
1315 ireq->no_srccheck = inet_sk(sk)->transparent;
1316 ireq->opt = tcp_v4_save_options(sk, skb);
1317
1322 if (security_inet_conn_request(sk, skb, req)) 1318 if (security_inet_conn_request(sk, skb, req))
1323 goto drop_and_release; 1319 goto drop_and_free;
1324 1320
1325 if (!want_cookie) 1321 if (!want_cookie)
1326 TCP_ECN_create_request(req, tcp_hdr(skb)); 1322 TCP_ECN_create_request(req, tcp_hdr(skb));
@@ -1345,6 +1341,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1345 */ 1341 */
1346 if (tmp_opt.saw_tstamp && 1342 if (tmp_opt.saw_tstamp &&
1347 tcp_death_row.sysctl_tw_recycle && 1343 tcp_death_row.sysctl_tw_recycle &&
1344 (dst = inet_csk_route_req(sk, req)) != NULL &&
1348 (peer = rt_get_peer((struct rtable *)dst)) != NULL && 1345 (peer = rt_get_peer((struct rtable *)dst)) != NULL &&
1349 peer->v4daddr == saddr) { 1346 peer->v4daddr == saddr) {
1350 if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL && 1347 if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL &&
@@ -1464,7 +1461,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1464 } 1461 }
1465#endif 1462#endif
1466 1463
1467 __inet_hash_nolisten(newsk); 1464 __inet_hash_nolisten(newsk, NULL);
1468 __inet_inherit_port(sk, newsk); 1465 __inet_inherit_port(sk, newsk);
1469 1466
1470 return newsk; 1467 return newsk;
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 87accec8d097..f206ee5dda80 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -95,9 +95,9 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
95 struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); 95 struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw);
96 int paws_reject = 0; 96 int paws_reject = 0;
97 97
98 tmp_opt.saw_tstamp = 0;
98 if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) { 99 if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) {
99 tmp_opt.tstamp_ok = 1; 100 tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
100 tcp_parse_options(skb, &tmp_opt, &hash_location, 1, NULL);
101 101
102 if (tmp_opt.saw_tstamp) { 102 if (tmp_opt.saw_tstamp) {
103 tmp_opt.ts_recent = tcptw->tw_ts_recent; 103 tmp_opt.ts_recent = tcptw->tw_ts_recent;
@@ -526,9 +526,9 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
526 __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); 526 __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK);
527 int paws_reject = 0; 527 int paws_reject = 0;
528 528
529 if ((th->doff > (sizeof(*th) >> 2)) && (req->ts_recent)) { 529 tmp_opt.saw_tstamp = 0;
530 tmp_opt.tstamp_ok = 1; 530 if (th->doff > (sizeof(struct tcphdr)>>2)) {
531 tcp_parse_options(skb, &tmp_opt, &hash_location, 1, NULL); 531 tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
532 532
533 if (tmp_opt.saw_tstamp) { 533 if (tmp_opt.saw_tstamp) {
534 tmp_opt.ts_recent = req->ts_recent; 534 tmp_opt.ts_recent = req->ts_recent;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 93316a96d820..383ce237640f 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -553,7 +553,6 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
553 struct tcp_md5sig_key **md5) { 553 struct tcp_md5sig_key **md5) {
554 struct tcp_sock *tp = tcp_sk(sk); 554 struct tcp_sock *tp = tcp_sk(sk);
555 struct tcp_cookie_values *cvp = tp->cookie_values; 555 struct tcp_cookie_values *cvp = tp->cookie_values;
556 struct dst_entry *dst = __sk_dst_get(sk);
557 unsigned remaining = MAX_TCP_OPTION_SPACE; 556 unsigned remaining = MAX_TCP_OPTION_SPACE;
558 u8 cookie_size = (!tp->rx_opt.cookie_out_never && cvp != NULL) ? 557 u8 cookie_size = (!tp->rx_opt.cookie_out_never && cvp != NULL) ?
559 tcp_cookie_size_check(cvp->cookie_desired) : 558 tcp_cookie_size_check(cvp->cookie_desired) :
@@ -581,22 +580,18 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
581 opts->mss = tcp_advertise_mss(sk); 580 opts->mss = tcp_advertise_mss(sk);
582 remaining -= TCPOLEN_MSS_ALIGNED; 581 remaining -= TCPOLEN_MSS_ALIGNED;
583 582
584 if (likely(sysctl_tcp_timestamps && 583 if (likely(sysctl_tcp_timestamps && *md5 == NULL)) {
585 !dst_feature(dst, RTAX_FEATURE_NO_TSTAMP) &&
586 *md5 == NULL)) {
587 opts->options |= OPTION_TS; 584 opts->options |= OPTION_TS;
588 opts->tsval = TCP_SKB_CB(skb)->when; 585 opts->tsval = TCP_SKB_CB(skb)->when;
589 opts->tsecr = tp->rx_opt.ts_recent; 586 opts->tsecr = tp->rx_opt.ts_recent;
590 remaining -= TCPOLEN_TSTAMP_ALIGNED; 587 remaining -= TCPOLEN_TSTAMP_ALIGNED;
591 } 588 }
592 if (likely(sysctl_tcp_window_scaling && 589 if (likely(sysctl_tcp_window_scaling)) {
593 !dst_feature(dst, RTAX_FEATURE_NO_WSCALE))) {
594 opts->ws = tp->rx_opt.rcv_wscale; 590 opts->ws = tp->rx_opt.rcv_wscale;
595 opts->options |= OPTION_WSCALE; 591 opts->options |= OPTION_WSCALE;
596 remaining -= TCPOLEN_WSCALE_ALIGNED; 592 remaining -= TCPOLEN_WSCALE_ALIGNED;
597 } 593 }
598 if (likely(sysctl_tcp_sack && 594 if (likely(sysctl_tcp_sack)) {
599 !dst_feature(dst, RTAX_FEATURE_NO_SACK))) {
600 opts->options |= OPTION_SACK_ADVERTISE; 595 opts->options |= OPTION_SACK_ADVERTISE;
601 if (unlikely(!(OPTION_TS & opts->options))) 596 if (unlikely(!(OPTION_TS & opts->options)))
602 remaining -= TCPOLEN_SACKPERM_ALIGNED; 597 remaining -= TCPOLEN_SACKPERM_ALIGNED;
@@ -2527,9 +2522,7 @@ static void tcp_connect_init(struct sock *sk)
2527 * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. 2522 * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT.
2528 */ 2523 */
2529 tp->tcp_header_len = sizeof(struct tcphdr) + 2524 tp->tcp_header_len = sizeof(struct tcphdr) +
2530 (sysctl_tcp_timestamps && 2525 (sysctl_tcp_timestamps ? TCPOLEN_TSTAMP_ALIGNED : 0);
2531 (!dst_feature(dst, RTAX_FEATURE_NO_TSTAMP) ?
2532 TCPOLEN_TSTAMP_ALIGNED : 0));
2533 2526
2534#ifdef CONFIG_TCP_MD5SIG 2527#ifdef CONFIG_TCP_MD5SIG
2535 if (tp->af_specific->md5_lookup(sk, sk) != NULL) 2528 if (tp->af_specific->md5_lookup(sk, sk) != NULL)
@@ -2555,8 +2548,7 @@ static void tcp_connect_init(struct sock *sk)
2555 tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), 2548 tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0),
2556 &tp->rcv_wnd, 2549 &tp->rcv_wnd,
2557 &tp->window_clamp, 2550 &tp->window_clamp,
2558 (sysctl_tcp_window_scaling && 2551 sysctl_tcp_window_scaling,
2559 !dst_feature(dst, RTAX_FEATURE_NO_WSCALE)),
2560 &rcv_wscale); 2552 &rcv_wscale);
2561 2553
2562 tp->rx_opt.rcv_wscale = rcv_wscale; 2554 tp->rx_opt.rcv_wscale = rcv_wscale;
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/ipv4/udp.c b/net/ipv4/udp.c
index 1f9534846ca9..f0126fdd7e04 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -216,9 +216,8 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
216 * force rand to be an odd multiple of UDP_HTABLE_SIZE 216 * force rand to be an odd multiple of UDP_HTABLE_SIZE
217 */ 217 */
218 rand = (rand | 1) * (udptable->mask + 1); 218 rand = (rand | 1) * (udptable->mask + 1);
219 for (last = first + udptable->mask + 1; 219 last = first + udptable->mask + 1;
220 first != last; 220 do {
221 first++) {
222 hslot = udp_hashslot(udptable, net, first); 221 hslot = udp_hashslot(udptable, net, first);
223 bitmap_zero(bitmap, PORTS_PER_CHAIN); 222 bitmap_zero(bitmap, PORTS_PER_CHAIN);
224 spin_lock_bh(&hslot->lock); 223 spin_lock_bh(&hslot->lock);
@@ -238,7 +237,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
238 snum += rand; 237 snum += rand;
239 } while (snum != first); 238 } while (snum != first);
240 spin_unlock_bh(&hslot->lock); 239 spin_unlock_bh(&hslot->lock);
241 } 240 } while (++first != last);
242 goto fail; 241 goto fail;
243 } else { 242 } else {
244 hslot = udp_hashslot(udptable, net, snum); 243 hslot = udp_hashslot(udptable, net, snum);
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/syncookies.c b/net/ipv6/syncookies.c
index 5b9af508b8f2..7208a06576c6 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -185,6 +185,13 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
185 185
186 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV); 186 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV);
187 187
188 /* check for timestamp cookie support */
189 memset(&tcp_opt, 0, sizeof(tcp_opt));
190 tcp_parse_options(skb, &tcp_opt, &hash_location, 0);
191
192 if (tcp_opt.saw_tstamp)
193 cookie_check_timestamp(&tcp_opt);
194
188 ret = NULL; 195 ret = NULL;
189 req = inet6_reqsk_alloc(&tcp6_request_sock_ops); 196 req = inet6_reqsk_alloc(&tcp6_request_sock_ops);
190 if (!req) 197 if (!req)
@@ -218,6 +225,12 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
218 req->expires = 0UL; 225 req->expires = 0UL;
219 req->retrans = 0; 226 req->retrans = 0;
220 ireq->ecn_ok = 0; 227 ireq->ecn_ok = 0;
228 ireq->snd_wscale = tcp_opt.snd_wscale;
229 ireq->rcv_wscale = tcp_opt.rcv_wscale;
230 ireq->sack_ok = tcp_opt.sack_ok;
231 ireq->wscale_ok = tcp_opt.wscale_ok;
232 ireq->tstamp_ok = tcp_opt.saw_tstamp;
233 req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
221 treq->rcv_isn = ntohl(th->seq) - 1; 234 treq->rcv_isn = ntohl(th->seq) - 1;
222 treq->snt_isn = cookie; 235 treq->snt_isn = cookie;
223 236
@@ -253,21 +266,6 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
253 goto out_free; 266 goto out_free;
254 } 267 }
255 268
256 /* check for timestamp cookie support */
257 memset(&tcp_opt, 0, sizeof(tcp_opt));
258 tcp_parse_options(skb, &tcp_opt, &hash_location, 0, dst);
259
260 if (tcp_opt.saw_tstamp)
261 cookie_check_timestamp(&tcp_opt);
262
263 req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
264
265 ireq->snd_wscale = tcp_opt.snd_wscale;
266 ireq->rcv_wscale = tcp_opt.rcv_wscale;
267 ireq->sack_ok = tcp_opt.sack_ok;
268 ireq->wscale_ok = tcp_opt.wscale_ok;
269 ireq->tstamp_ok = tcp_opt.saw_tstamp;
270
271 req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); 269 req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW);
272 tcp_select_initial_window(tcp_full_space(sk), req->mss, 270 tcp_select_initial_window(tcp_full_space(sk), req->mss,
273 &req->rcv_wnd, &req->window_clamp, 271 &req->rcv_wnd, &req->window_clamp,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index aadd7cef73b3..febfd595a40d 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}
@@ -1169,7 +1169,6 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1169 struct inet6_request_sock *treq; 1169 struct inet6_request_sock *treq;
1170 struct ipv6_pinfo *np = inet6_sk(sk); 1170 struct ipv6_pinfo *np = inet6_sk(sk);
1171 struct tcp_sock *tp = tcp_sk(sk); 1171 struct tcp_sock *tp = tcp_sk(sk);
1172 struct dst_entry *dst = __sk_dst_get(sk);
1173 __u32 isn = TCP_SKB_CB(skb)->when; 1172 __u32 isn = TCP_SKB_CB(skb)->when;
1174#ifdef CONFIG_SYN_COOKIES 1173#ifdef CONFIG_SYN_COOKIES
1175 int want_cookie = 0; 1174 int want_cookie = 0;
@@ -1208,7 +1207,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1208 tcp_clear_options(&tmp_opt); 1207 tcp_clear_options(&tmp_opt);
1209 tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr); 1208 tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);
1210 tmp_opt.user_mss = tp->rx_opt.user_mss; 1209 tmp_opt.user_mss = tp->rx_opt.user_mss;
1211 tcp_parse_options(skb, &tmp_opt, &hash_location, 0, dst); 1210 tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
1212 1211
1213 if (tmp_opt.cookie_plus > 0 && 1212 if (tmp_opt.cookie_plus > 0 &&
1214 tmp_opt.saw_tstamp && 1213 tmp_opt.saw_tstamp &&
@@ -1496,7 +1495,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1496 } 1495 }
1497#endif 1496#endif
1498 1497
1499 __inet6_hash(newsk); 1498 __inet6_hash(newsk, NULL);
1500 __inet_inherit_port(sk, newsk); 1499 __inet_inherit_port(sk, newsk);
1501 1500
1502 return newsk; 1501 return newsk;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 84209fbbeb17..76fa6fef6473 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1193,6 +1193,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
1193 x->aalg->alg_key_len = key->sadb_key_bits; 1193 x->aalg->alg_key_len = key->sadb_key_bits;
1194 memcpy(x->aalg->alg_key, key+1, keysize); 1194 memcpy(x->aalg->alg_key, key+1, keysize);
1195 } 1195 }
1196 x->aalg->alg_trunc_len = a->uinfo.auth.icv_truncbits;
1196 x->props.aalgo = sa->sadb_sa_auth; 1197 x->props.aalgo = sa->sadb_sa_auth;
1197 /* x->algo.flags = sa->sadb_sa_flags; */ 1198 /* x->algo.flags = sa->sadb_sa_flags; */
1198 } 1199 }
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 93ee1fd5c08d..6dc3579c0ac5 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/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 419f186cfcf0..91dc8636d644 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -746,6 +746,7 @@ struct ieee80211_local {
746 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ 746 unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
747 747
748 bool pspolling; 748 bool pspolling;
749 bool scan_ps_enabled;
749 /* 750 /*
750 * PS can only be enabled when we have exactly one managed 751 * PS can only be enabled when we have exactly one managed
751 * interface (and monitors) in PS, this then points there. 752 * interface (and monitors) in PS, this then points there.
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index c0fe46493f71..6a4331429598 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 833b2f3670c5..d28acb6b1f81 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->dev->dev_addr, hdr->addr4, ETH_ALEN) && 942 !memcmp(sdata->dev->dev_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 6dc7b5ad9a41..d8d50fb5e823 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1083,8 +1083,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1083 1083
1084 ieee80211_set_wmm_default(sdata); 1084 ieee80211_set_wmm_default(sdata);
1085 1085
1086 ieee80211_recalc_idle(local);
1087
1088 /* channel(_type) changes are handled by ieee80211_hw_config */ 1086 /* channel(_type) changes are handled by ieee80211_hw_config */
1089 local->oper_channel_type = NL80211_CHAN_NO_HT; 1087 local->oper_channel_type = NL80211_CHAN_NO_HT;
1090 1088
@@ -1370,6 +1368,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
1370 1368
1371 if (!wk) { 1369 if (!wk) {
1372 ieee80211_set_disassoc(sdata, true); 1370 ieee80211_set_disassoc(sdata, true);
1371 ieee80211_recalc_idle(sdata->local);
1373 } else { 1372 } else {
1374 list_del(&wk->list); 1373 list_del(&wk->list);
1375 kfree(wk); 1374 kfree(wk);
@@ -1403,6 +1402,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
1403 sdata->dev->name, mgmt->sa, reason_code); 1402 sdata->dev->name, mgmt->sa, reason_code);
1404 1403
1405 ieee80211_set_disassoc(sdata, false); 1404 ieee80211_set_disassoc(sdata, false);
1405 ieee80211_recalc_idle(sdata->local);
1406 return RX_MGMT_CFG80211_DISASSOC; 1406 return RX_MGMT_CFG80211_DISASSOC;
1407} 1407}
1408 1408
@@ -2117,6 +2117,7 @@ static void ieee80211_sta_work(struct work_struct *work)
2117 " after %dms, disconnecting.\n", 2117 " after %dms, disconnecting.\n",
2118 bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); 2118 bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ);
2119 ieee80211_set_disassoc(sdata, true); 2119 ieee80211_set_disassoc(sdata, true);
2120 ieee80211_recalc_idle(local);
2120 mutex_unlock(&ifmgd->mtx); 2121 mutex_unlock(&ifmgd->mtx);
2121 /* 2122 /*
2122 * must be outside lock due to cfg80211, 2123 * must be outside lock due to cfg80211,
@@ -2560,6 +2561,8 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
2560 IEEE80211_STYPE_DEAUTH, req->reason_code, 2561 IEEE80211_STYPE_DEAUTH, req->reason_code,
2561 cookie); 2562 cookie);
2562 2563
2564 ieee80211_recalc_idle(sdata->local);
2565
2563 return 0; 2566 return 0;
2564} 2567}
2565 2568
@@ -2592,5 +2595,8 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
2592 ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, 2595 ieee80211_send_deauth_disassoc(sdata, req->bss->bssid,
2593 IEEE80211_STYPE_DISASSOC, req->reason_code, 2596 IEEE80211_STYPE_DISASSOC, req->reason_code,
2594 cookie); 2597 cookie);
2598
2599 ieee80211_recalc_idle(sdata->local);
2600
2595 return 0; 2601 return 0;
2596} 2602}
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index f237df408378..9f2807aeaf52 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1712,7 +1712,6 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1712 mpp_path_add(proxied_addr, mpp_addr, sdata); 1712 mpp_path_add(proxied_addr, mpp_addr, sdata);
1713 } else { 1713 } else {
1714 spin_lock_bh(&mppath->state_lock); 1714 spin_lock_bh(&mppath->state_lock);
1715 mppath->exp_time = jiffies;
1716 if (compare_ether_addr(mppath->mpp, mpp_addr) != 0) 1715 if (compare_ether_addr(mppath->mpp, mpp_addr) != 0)
1717 memcpy(mppath->mpp, mpp_addr, ETH_ALEN); 1716 memcpy(mppath->mpp, mpp_addr, ETH_ALEN);
1718 spin_unlock_bh(&mppath->state_lock); 1717 spin_unlock_bh(&mppath->state_lock);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 4cf387c944bf..f1a4c7160300 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 d09f78bb2442..78a6e924c7e1 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 c01470e7de15..baa898add287 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -141,62 +141,35 @@ static const struct ieee80211_regdomain us_regdom = {
141 .reg_rules = { 141 .reg_rules = {
142 /* IEEE 802.11b/g, channels 1..11 */ 142 /* IEEE 802.11b/g, channels 1..11 */
143 REG_RULE(2412-10, 2462+10, 40, 6, 27, 0), 143 REG_RULE(2412-10, 2462+10, 40, 6, 27, 0),
144 /* IEEE 802.11a, channel 36 */ 144 /* IEEE 802.11a, channel 36..48 */
145 REG_RULE(5180-10, 5180+10, 40, 6, 23, 0), 145 REG_RULE(5180-10, 5240+10, 40, 6, 17, 0),
146 /* IEEE 802.11a, channel 40 */
147 REG_RULE(5200-10, 5200+10, 40, 6, 23, 0),
148 /* IEEE 802.11a, channel 44 */
149 REG_RULE(5220-10, 5220+10, 40, 6, 23, 0),
150 /* IEEE 802.11a, channels 48..64 */ 146 /* IEEE 802.11a, channels 48..64 */
151 REG_RULE(5240-10, 5320+10, 40, 6, 23, 0), 147 REG_RULE(5260-10, 5320+10, 40, 6, 20, NL80211_RRF_DFS),
148 /* IEEE 802.11a, channels 100..124 */
149 REG_RULE(5500-10, 5590+10, 40, 6, 20, NL80211_RRF_DFS),
150 /* IEEE 802.11a, channels 132..144 */
151 REG_RULE(5660-10, 5700+10, 40, 6, 20, NL80211_RRF_DFS),
152 /* IEEE 802.11a, channels 149..165, outdoor */ 152 /* IEEE 802.11a, channels 149..165, outdoor */
153 REG_RULE(5745-10, 5825+10, 40, 6, 30, 0), 153 REG_RULE(5745-10, 5825+10, 40, 6, 30, 0),
154 } 154 }
155}; 155};
156 156
157static const struct ieee80211_regdomain jp_regdom = { 157static const struct ieee80211_regdomain jp_regdom = {
158 .n_reg_rules = 3, 158 .n_reg_rules = 6,
159 .alpha2 = "JP", 159 .alpha2 = "JP",
160 .reg_rules = { 160 .reg_rules = {
161 /* IEEE 802.11b/g, channels 1..14 */ 161 /* IEEE 802.11b/g, channels 1..11 */
162 REG_RULE(2412-10, 2484+10, 40, 6, 20, 0), 162 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
163 /* IEEE 802.11a, channels 34..48 */ 163 /* IEEE 802.11b/g, channels 12..13 */
164 REG_RULE(5170-10, 5240+10, 40, 6, 20, 164 REG_RULE(2467-10, 2472+10, 20, 6, 20, 0),
165 NL80211_RRF_PASSIVE_SCAN), 165 /* IEEE 802.11b/g, channel 14 */
166 REG_RULE(2484-10, 2484+10, 20, 6, 20, NL80211_RRF_NO_OFDM),
167 /* IEEE 802.11a, channels 36..48 */
168 REG_RULE(5180-10, 5240+10, 40, 6, 20, 0),
166 /* IEEE 802.11a, channels 52..64 */ 169 /* IEEE 802.11a, channels 52..64 */
167 REG_RULE(5260-10, 5320+10, 40, 6, 20, 170 REG_RULE(5260-10, 5320+10, 40, 6, 20, NL80211_RRF_DFS),
168 NL80211_RRF_NO_IBSS | 171 /* IEEE 802.11a, channels 100..144 */
169 NL80211_RRF_DFS), 172 REG_RULE(5500-10, 5700+10, 40, 6, 23, NL80211_RRF_DFS),
170 }
171};
172
173static const struct ieee80211_regdomain eu_regdom = {
174 .n_reg_rules = 6,
175 /*
176 * This alpha2 is bogus, we leave it here just for stupid
177 * backward compatibility
178 */
179 .alpha2 = "EU",
180 .reg_rules = {
181 /* IEEE 802.11b/g, channels 1..13 */
182 REG_RULE(2412-10, 2472+10, 40, 6, 20, 0),
183 /* IEEE 802.11a, channel 36 */
184 REG_RULE(5180-10, 5180+10, 40, 6, 23,
185 NL80211_RRF_PASSIVE_SCAN),
186 /* IEEE 802.11a, channel 40 */
187 REG_RULE(5200-10, 5200+10, 40, 6, 23,
188 NL80211_RRF_PASSIVE_SCAN),
189 /* IEEE 802.11a, channel 44 */
190 REG_RULE(5220-10, 5220+10, 40, 6, 23,
191 NL80211_RRF_PASSIVE_SCAN),
192 /* IEEE 802.11a, channels 48..64 */
193 REG_RULE(5240-10, 5320+10, 40, 6, 20,
194 NL80211_RRF_NO_IBSS |
195 NL80211_RRF_DFS),
196 /* IEEE 802.11a, channels 100..140 */
197 REG_RULE(5500-10, 5700+10, 40, 6, 30,
198 NL80211_RRF_NO_IBSS |
199 NL80211_RRF_DFS),
200 } 173 }
201}; 174};
202 175
@@ -206,15 +179,17 @@ static const struct ieee80211_regdomain *static_regdom(char *alpha2)
206 return &us_regdom; 179 return &us_regdom;
207 if (alpha2[0] == 'J' && alpha2[1] == 'P') 180 if (alpha2[0] == 'J' && alpha2[1] == 'P')
208 return &jp_regdom; 181 return &jp_regdom;
182 /* Use world roaming rules for "EU", since it was a pseudo
183 domain anyway... */
209 if (alpha2[0] == 'E' && alpha2[1] == 'U') 184 if (alpha2[0] == 'E' && alpha2[1] == 'U')
210 return &eu_regdom; 185 return &world_regdom;
211 /* Default, as per the old rules */ 186 /* Default, world roaming rules */
212 return &us_regdom; 187 return &world_regdom;
213} 188}
214 189
215static bool is_old_static_regdom(const struct ieee80211_regdomain *rd) 190static bool is_old_static_regdom(const struct ieee80211_regdomain *rd)
216{ 191{
217 if (rd == &us_regdom || rd == &jp_regdom || rd == &eu_regdom) 192 if (rd == &us_regdom || rd == &jp_regdom || rd == &world_regdom)
218 return true; 193 return true;
219 return false; 194 return false;
220} 195}
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 584eb4826e02..54face3d4424 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.