aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/networking/bonding.txt59
-rw-r--r--MAINTAINERS1
-rw-r--r--drivers/net/acenic.c4
-rw-r--r--drivers/net/bonding/bond_3ad.c70
-rw-r--r--drivers/net/bonding/bond_main.c228
-rw-r--r--drivers/net/bonding/bond_sysfs.c56
-rw-r--r--drivers/net/bonding/bonding.h34
-rw-r--r--drivers/net/e1000/e1000_hw.h4
-rw-r--r--drivers/net/forcedeth.c8
-rw-r--r--drivers/net/gt64240eth.h402
-rw-r--r--drivers/net/phy/phy_device.c2
-rw-r--r--drivers/net/s2io.c10
-rw-r--r--drivers/net/skge.c357
-rw-r--r--drivers/net/skge.h37
-rw-r--r--drivers/net/smc91x.h18
-rw-r--r--drivers/net/tokenring/lanstreamer.c59
-rw-r--r--drivers/net/tokenring/lanstreamer.h12
-rw-r--r--drivers/net/typhoon.c4
-rw-r--r--drivers/net/wireless/airo.c19
-rw-r--r--drivers/net/wireless/atmel.c18
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h1
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c10
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_phy.c15
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_xmit.c5
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c10
-rw-r--r--drivers/net/wireless/ipw2100.c14
-rw-r--r--drivers/net/wireless/ipw2200.c16
-rw-r--r--drivers/net/wireless/orinoco.c10
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c16
-rw-r--r--drivers/net/wireless/ray_cs.c2
-rw-r--r--drivers/net/wireless/wl3501_cs.c6
-rw-r--r--drivers/net/wireless/zd1201.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c137
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h23
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c50
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h5
-rw-r--r--drivers/net/wireless/zd1211rw/zd_netdev.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c10
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.h2
-rw-r--r--include/linux/if.h2
-rw-r--r--include/linux/netdevice.h8
-rw-r--r--include/linux/wireless.h24
-rw-r--r--net/core/net-sysfs.c5
-rw-r--r--net/core/wireless.c67
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c8
46 files changed, 993 insertions, 861 deletions
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index afac780445cd..dc942eaf490f 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -192,6 +192,17 @@ or, for backwards compatibility, the option value. E.g.,
192arp_interval 192arp_interval
193 193
194 Specifies the ARP link monitoring frequency in milliseconds. 194 Specifies the ARP link monitoring frequency in milliseconds.
195
196 The ARP monitor works by periodically checking the slave
197 devices to determine whether they have sent or received
198 traffic recently (the precise criteria depends upon the
199 bonding mode, and the state of the slave). Regular traffic is
200 generated via ARP probes issued for the addresses specified by
201 the arp_ip_target option.
202
203 This behavior can be modified by the arp_validate option,
204 below.
205
195 If ARP monitoring is used in an etherchannel compatible mode 206 If ARP monitoring is used in an etherchannel compatible mode
196 (modes 0 and 2), the switch should be configured in a mode 207 (modes 0 and 2), the switch should be configured in a mode
197 that evenly distributes packets across all links. If the 208 that evenly distributes packets across all links. If the
@@ -213,6 +224,54 @@ arp_ip_target
213 maximum number of targets that can be specified is 16. The 224 maximum number of targets that can be specified is 16. The
214 default value is no IP addresses. 225 default value is no IP addresses.
215 226
227arp_validate
228
229 Specifies whether or not ARP probes and replies should be
230 validated in the active-backup mode. This causes the ARP
231 monitor to examine the incoming ARP requests and replies, and
232 only consider a slave to be up if it is receiving the
233 appropriate ARP traffic.
234
235 Possible values are:
236
237 none or 0
238
239 No validation is performed. This is the default.
240
241 active or 1
242
243 Validation is performed only for the active slave.
244
245 backup or 2
246
247 Validation is performed only for backup slaves.
248
249 all or 3
250
251 Validation is performed for all slaves.
252
253 For the active slave, the validation checks ARP replies to
254 confirm that they were generated by an arp_ip_target. Since
255 backup slaves do not typically receive these replies, the
256 validation performed for backup slaves is on the ARP request
257 sent out via the active slave. It is possible that some
258 switch or network configurations may result in situations
259 wherein the backup slaves do not receive the ARP requests; in
260 such a situation, validation of backup slaves must be
261 disabled.
262
263 This option is useful in network configurations in which
264 multiple bonding hosts are concurrently issuing ARPs to one or
265 more targets beyond a common switch. Should the link between
266 the switch and target fail (but not the switch itself), the
267 probe traffic generated by the multiple bonding instances will
268 fool the standard ARP monitor into considering the links as
269 still up. Use of the arp_validate option can resolve this, as
270 the ARP monitor will only consider ARP requests and replies
271 associated with its own instance of bonding.
272
273 This option was added in bonding version 3.1.0.
274
216downdelay 275downdelay
217 276
218 Specifies the time, in milliseconds, to wait before disabling 277 Specifies the time, in milliseconds, to wait before disabling
diff --git a/MAINTAINERS b/MAINTAINERS
index 767a43434ae8..63673e6513b7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2679,7 +2679,6 @@ M: josejx@gentoo.org
2679P: Daniel Drake 2679P: Daniel Drake
2680M: dsd@gentoo.org 2680M: dsd@gentoo.org
2681W: http://softmac.sipsolutions.net/ 2681W: http://softmac.sipsolutions.net/
2682L: softmac-dev@sipsolutions.net
2683L: netdev@vger.kernel.org 2682L: netdev@vger.kernel.org
2684S: Maintained 2683S: Maintained
2685 2684
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index a075246f6f43..71a4f60f7325 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -163,11 +163,7 @@ MODULE_DEVICE_TABLE(pci, acenic_pci_tbl);
163#define SET_NETDEV_DEV(net, pdev) do{} while(0) 163#define SET_NETDEV_DEV(net, pdev) do{} while(0)
164#endif 164#endif
165 165
166#if LINUX_VERSION_CODE >= 0x2051c
167#define ace_sync_irq(irq) synchronize_irq(irq) 166#define ace_sync_irq(irq) synchronize_irq(irq)
168#else
169#define ace_sync_irq(irq) synchronize_irq()
170#endif
171 167
172#ifndef offset_in_page 168#ifndef offset_in_page
173#define offset_in_page(ptr) ((unsigned long)(ptr) & ~PAGE_MASK) 169#define offset_in_page(ptr) ((unsigned long)(ptr) & ~PAGE_MASK)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 6a407070c2e8..3fb354d9c515 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -85,6 +85,7 @@
85#define AD_LINK_SPEED_BITMASK_10MBPS 0x2 85#define AD_LINK_SPEED_BITMASK_10MBPS 0x2
86#define AD_LINK_SPEED_BITMASK_100MBPS 0x4 86#define AD_LINK_SPEED_BITMASK_100MBPS 0x4
87#define AD_LINK_SPEED_BITMASK_1000MBPS 0x8 87#define AD_LINK_SPEED_BITMASK_1000MBPS 0x8
88#define AD_LINK_SPEED_BITMASK_10000MBPS 0x10
88//endalloun 89//endalloun
89 90
90// compare MAC addresses 91// compare MAC addresses
@@ -99,7 +100,7 @@ static u16 __get_link_speed(struct port *port);
99static u8 __get_duplex(struct port *port); 100static u8 __get_duplex(struct port *port);
100static inline void __initialize_port_locks(struct port *port); 101static inline void __initialize_port_locks(struct port *port);
101//conversions 102//conversions
102static void __ntohs_lacpdu(struct lacpdu *lacpdu); 103static void __htons_lacpdu(struct lacpdu *lacpdu);
103static u16 __ad_timer_to_ticks(u16 timer_type, u16 Par); 104static u16 __ad_timer_to_ticks(u16 timer_type, u16 Par);
104 105
105 106
@@ -330,7 +331,8 @@ static inline void __release_rx_machine_lock(struct port *port)
330 * 0, 331 * 0,
331 * %AD_LINK_SPEED_BITMASK_10MBPS, 332 * %AD_LINK_SPEED_BITMASK_10MBPS,
332 * %AD_LINK_SPEED_BITMASK_100MBPS, 333 * %AD_LINK_SPEED_BITMASK_100MBPS,
333 * %AD_LINK_SPEED_BITMASK_1000MBPS 334 * %AD_LINK_SPEED_BITMASK_1000MBPS,
335 * %AD_LINK_SPEED_BITMASK_10000MBPS
334 */ 336 */
335static u16 __get_link_speed(struct port *port) 337static u16 __get_link_speed(struct port *port)
336{ 338{
@@ -357,6 +359,10 @@ static u16 __get_link_speed(struct port *port)
357 speed = AD_LINK_SPEED_BITMASK_1000MBPS; 359 speed = AD_LINK_SPEED_BITMASK_1000MBPS;
358 break; 360 break;
359 361
362 case SPEED_10000:
363 speed = AD_LINK_SPEED_BITMASK_10000MBPS;
364 break;
365
360 default: 366 default:
361 speed = 0; // unknown speed value from ethtool. shouldn't happen 367 speed = 0; // unknown speed value from ethtool. shouldn't happen
362 break; 368 break;
@@ -414,23 +420,23 @@ static inline void __initialize_port_locks(struct port *port)
414 420
415//conversions 421//conversions
416/** 422/**
417 * __ntohs_lacpdu - convert the contents of a LACPDU to host byte order 423 * __htons_lacpdu - convert the contents of a LACPDU to network byte order
418 * @lacpdu: the speicifed lacpdu 424 * @lacpdu: the speicifed lacpdu
419 * 425 *
420 * For each multi-byte field in the lacpdu, convert its content 426 * For each multi-byte field in the lacpdu, convert its content
421 */ 427 */
422static void __ntohs_lacpdu(struct lacpdu *lacpdu) 428static void __htons_lacpdu(struct lacpdu *lacpdu)
423{ 429{
424 if (lacpdu) { 430 if (lacpdu) {
425 lacpdu->actor_system_priority = ntohs(lacpdu->actor_system_priority); 431 lacpdu->actor_system_priority = htons(lacpdu->actor_system_priority);
426 lacpdu->actor_key = ntohs(lacpdu->actor_key); 432 lacpdu->actor_key = htons(lacpdu->actor_key);
427 lacpdu->actor_port_priority = ntohs(lacpdu->actor_port_priority); 433 lacpdu->actor_port_priority = htons(lacpdu->actor_port_priority);
428 lacpdu->actor_port = ntohs(lacpdu->actor_port); 434 lacpdu->actor_port = htons(lacpdu->actor_port);
429 lacpdu->partner_system_priority = ntohs(lacpdu->partner_system_priority); 435 lacpdu->partner_system_priority = htons(lacpdu->partner_system_priority);
430 lacpdu->partner_key = ntohs(lacpdu->partner_key); 436 lacpdu->partner_key = htons(lacpdu->partner_key);
431 lacpdu->partner_port_priority = ntohs(lacpdu->partner_port_priority); 437 lacpdu->partner_port_priority = htons(lacpdu->partner_port_priority);
432 lacpdu->partner_port = ntohs(lacpdu->partner_port); 438 lacpdu->partner_port = htons(lacpdu->partner_port);
433 lacpdu->collector_max_delay = ntohs(lacpdu->collector_max_delay); 439 lacpdu->collector_max_delay = htons(lacpdu->collector_max_delay);
434 } 440 }
435} 441}
436 442
@@ -490,11 +496,11 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
490 // validate lacpdu and port 496 // validate lacpdu and port
491 if (lacpdu && port) { 497 if (lacpdu && port) {
492 // record the new parameter values for the partner operational 498 // record the new parameter values for the partner operational
493 port->partner_oper_port_number = lacpdu->actor_port; 499 port->partner_oper_port_number = ntohs(lacpdu->actor_port);
494 port->partner_oper_port_priority = lacpdu->actor_port_priority; 500 port->partner_oper_port_priority = ntohs(lacpdu->actor_port_priority);
495 port->partner_oper_system = lacpdu->actor_system; 501 port->partner_oper_system = lacpdu->actor_system;
496 port->partner_oper_system_priority = lacpdu->actor_system_priority; 502 port->partner_oper_system_priority = ntohs(lacpdu->actor_system_priority);
497 port->partner_oper_key = lacpdu->actor_key; 503 port->partner_oper_key = ntohs(lacpdu->actor_key);
498 // zero partener's lase states 504 // zero partener's lase states
499 port->partner_oper_port_state = 0; 505 port->partner_oper_port_state = 0;
500 port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_LACP_ACTIVITY); 506 port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_LACP_ACTIVITY);
@@ -561,11 +567,11 @@ static void __update_selected(struct lacpdu *lacpdu, struct port *port)
561 // validate lacpdu and port 567 // validate lacpdu and port
562 if (lacpdu && port) { 568 if (lacpdu && port) {
563 // check if any parameter is different 569 // check if any parameter is different
564 if ((lacpdu->actor_port != port->partner_oper_port_number) || 570 if ((ntohs(lacpdu->actor_port) != port->partner_oper_port_number) ||
565 (lacpdu->actor_port_priority != port->partner_oper_port_priority) || 571 (ntohs(lacpdu->actor_port_priority) != port->partner_oper_port_priority) ||
566 MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper_system)) || 572 MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper_system)) ||
567 (lacpdu->actor_system_priority != port->partner_oper_system_priority) || 573 (ntohs(lacpdu->actor_system_priority) != port->partner_oper_system_priority) ||
568 (lacpdu->actor_key != port->partner_oper_key) || 574 (ntohs(lacpdu->actor_key) != port->partner_oper_key) ||
569 ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION)) 575 ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION))
570 ) { 576 ) {
571 // update the state machine Selected variable 577 // update the state machine Selected variable
@@ -628,11 +634,11 @@ static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
628 // validate lacpdu and port 634 // validate lacpdu and port
629 if (lacpdu && port) { 635 if (lacpdu && port) {
630 // check if all parameters are alike 636 // check if all parameters are alike
631 if (((lacpdu->partner_port == port->actor_port_number) && 637 if (((ntohs(lacpdu->partner_port) == port->actor_port_number) &&
632 (lacpdu->partner_port_priority == port->actor_port_priority) && 638 (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) &&
633 !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) && 639 !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
634 (lacpdu->partner_system_priority == port->actor_system_priority) && 640 (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) &&
635 (lacpdu->partner_key == port->actor_oper_port_key) && 641 (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) &&
636 ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) || 642 ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
637 // or this is individual link(aggregation == FALSE) 643 // or this is individual link(aggregation == FALSE)
638 ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0) 644 ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
@@ -662,11 +668,11 @@ static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
662 // validate lacpdu and port 668 // validate lacpdu and port
663 if (lacpdu && port) { 669 if (lacpdu && port) {
664 // check if any parameter is different 670 // check if any parameter is different
665 if ((lacpdu->partner_port != port->actor_port_number) || 671 if ((ntohs(lacpdu->partner_port) != port->actor_port_number) ||
666 (lacpdu->partner_port_priority != port->actor_port_priority) || 672 (ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) ||
667 MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) || 673 MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) ||
668 (lacpdu->partner_system_priority != port->actor_system_priority) || 674 (ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) ||
669 (lacpdu->partner_key != port->actor_oper_port_key) || 675 (ntohs(lacpdu->partner_key) != port->actor_oper_port_key) ||
670 ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) || 676 ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) ||
671 ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)) || 677 ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)) ||
672 ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) || 678 ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) ||
@@ -775,6 +781,9 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
775 case AD_LINK_SPEED_BITMASK_1000MBPS: 781 case AD_LINK_SPEED_BITMASK_1000MBPS:
776 bandwidth = aggregator->num_of_ports * 1000; 782 bandwidth = aggregator->num_of_ports * 1000;
777 break; 783 break;
784 case AD_LINK_SPEED_BITMASK_10000MBPS:
785 bandwidth = aggregator->num_of_ports * 10000;
786 break;
778 default: 787 default:
779 bandwidth=0; // to silent the compilor .... 788 bandwidth=0; // to silent the compilor ....
780 } 789 }
@@ -847,7 +856,7 @@ static inline void __update_lacpdu_from_port(struct port *port)
847 */ 856 */
848 857
849 /* Convert all non u8 parameters to Big Endian for transmit */ 858 /* Convert all non u8 parameters to Big Endian for transmit */
850 __ntohs_lacpdu(lacpdu); 859 __htons_lacpdu(lacpdu);
851} 860}
852 861
853////////////////////////////////////////////////////////////////////////////////////// 862//////////////////////////////////////////////////////////////////////////////////////
@@ -2171,7 +2180,6 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
2171 2180
2172 switch (lacpdu->subtype) { 2181 switch (lacpdu->subtype) {
2173 case AD_TYPE_LACPDU: 2182 case AD_TYPE_LACPDU:
2174 __ntohs_lacpdu(lacpdu);
2175 dprintk("Received LACPDU on port %d\n", port->actor_port_number); 2183 dprintk("Received LACPDU on port %d\n", port->actor_port_number);
2176 ad_rx_machine(lacpdu, port); 2184 ad_rx_machine(lacpdu, port);
2177 break; 2185 break;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 850aae21a2fe..0fb5f653d3ce 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -96,6 +96,7 @@ static char *lacp_rate = NULL;
96static char *xmit_hash_policy = NULL; 96static char *xmit_hash_policy = NULL;
97static int arp_interval = BOND_LINK_ARP_INTERV; 97static int arp_interval = BOND_LINK_ARP_INTERV;
98static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; 98static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, };
99static char *arp_validate = NULL;
99struct bond_params bonding_defaults; 100struct bond_params bonding_defaults;
100 101
101module_param(max_bonds, int, 0); 102module_param(max_bonds, int, 0);
@@ -127,6 +128,8 @@ module_param(arp_interval, int, 0);
127MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); 128MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds");
128module_param_array(arp_ip_target, charp, NULL, 0); 129module_param_array(arp_ip_target, charp, NULL, 0);
129MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form"); 130MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form");
131module_param(arp_validate, charp, 0);
132MODULE_PARM_DESC(arp_validate, "validate src/dst of ARP probes: none (default), active, backup or all");
130 133
131/*----------------------------- Global variables ----------------------------*/ 134/*----------------------------- Global variables ----------------------------*/
132 135
@@ -170,6 +173,14 @@ struct bond_parm_tbl xmit_hashtype_tbl[] = {
170{ NULL, -1}, 173{ NULL, -1},
171}; 174};
172 175
176struct bond_parm_tbl arp_validate_tbl[] = {
177{ "none", BOND_ARP_VALIDATE_NONE},
178{ "active", BOND_ARP_VALIDATE_ACTIVE},
179{ "backup", BOND_ARP_VALIDATE_BACKUP},
180{ "all", BOND_ARP_VALIDATE_ALL},
181{ NULL, -1},
182};
183
173/*-------------------------- Forward declarations ---------------------------*/ 184/*-------------------------- Forward declarations ---------------------------*/
174 185
175static void bond_send_gratuitous_arp(struct bonding *bond); 186static void bond_send_gratuitous_arp(struct bonding *bond);
@@ -638,6 +649,7 @@ verify:
638 case SPEED_10: 649 case SPEED_10:
639 case SPEED_100: 650 case SPEED_100:
640 case SPEED_1000: 651 case SPEED_1000:
652 case SPEED_10000:
641 break; 653 break;
642 default: 654 default:
643 return -1; 655 return -1;
@@ -1210,10 +1222,14 @@ static int bond_compute_features(struct bonding *bond)
1210 unsigned long features = BOND_INTERSECT_FEATURES; 1222 unsigned long features = BOND_INTERSECT_FEATURES;
1211 struct slave *slave; 1223 struct slave *slave;
1212 struct net_device *bond_dev = bond->dev; 1224 struct net_device *bond_dev = bond->dev;
1225 unsigned short max_hard_header_len = ETH_HLEN;
1213 int i; 1226 int i;
1214 1227
1215 bond_for_each_slave(bond, slave, i) 1228 bond_for_each_slave(bond, slave, i) {
1216 features &= (slave->dev->features & BOND_INTERSECT_FEATURES); 1229 features &= (slave->dev->features & BOND_INTERSECT_FEATURES);
1230 if (slave->dev->hard_header_len > max_hard_header_len)
1231 max_hard_header_len = slave->dev->hard_header_len;
1232 }
1217 1233
1218 if ((features & NETIF_F_SG) && 1234 if ((features & NETIF_F_SG) &&
1219 !(features & NETIF_F_ALL_CSUM)) 1235 !(features & NETIF_F_ALL_CSUM))
@@ -1231,6 +1247,7 @@ static int bond_compute_features(struct bonding *bond)
1231 1247
1232 features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES); 1248 features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES);
1233 bond_dev->features = features; 1249 bond_dev->features = features;
1250 bond_dev->hard_header_len = max_hard_header_len;
1234 1251
1235 return 0; 1252 return 0;
1236} 1253}
@@ -1365,6 +1382,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1365 } 1382 }
1366 1383
1367 new_slave->dev = slave_dev; 1384 new_slave->dev = slave_dev;
1385 slave_dev->priv_flags |= IFF_BONDING;
1368 1386
1369 if ((bond->params.mode == BOND_MODE_TLB) || 1387 if ((bond->params.mode == BOND_MODE_TLB) ||
1370 (bond->params.mode == BOND_MODE_ALB)) { 1388 (bond->params.mode == BOND_MODE_ALB)) {
@@ -1417,6 +1435,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1417 1435
1418 bond_compute_features(bond); 1436 bond_compute_features(bond);
1419 1437
1438 new_slave->last_arp_rx = jiffies;
1439
1420 if (bond->params.miimon && !bond->params.use_carrier) { 1440 if (bond->params.miimon && !bond->params.use_carrier) {
1421 link_reporting = bond_check_dev_link(bond, slave_dev, 1); 1441 link_reporting = bond_check_dev_link(bond, slave_dev, 1);
1422 1442
@@ -1493,29 +1513,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1493 1513
1494 switch (bond->params.mode) { 1514 switch (bond->params.mode) {
1495 case BOND_MODE_ACTIVEBACKUP: 1515 case BOND_MODE_ACTIVEBACKUP:
1496 /* if we're in active-backup mode, we need one and 1516 bond_set_slave_inactive_flags(new_slave);
1497 * only one active interface. The backup interfaces 1517 bond_select_active_slave(bond);
1498 * will have their SLAVE_INACTIVE flag set because we
1499 * need them to be drop all packets. Thus, since we
1500 * guarantee that curr_active_slave always point to
1501 * the last usable interface, we just have to verify
1502 * this interface's flag.
1503 */
1504 if (((!bond->curr_active_slave) ||
1505 (bond->curr_active_slave->dev->priv_flags & IFF_SLAVE_INACTIVE)) &&
1506 (new_slave->link != BOND_LINK_DOWN)) {
1507 /* first slave or no active slave yet, and this link
1508 is OK, so make this interface the active one */
1509 bond_change_active_slave(bond, new_slave);
1510 printk(KERN_INFO DRV_NAME
1511 ": %s: first active interface up!\n",
1512 bond->dev->name);
1513 netif_carrier_on(bond->dev);
1514
1515 } else {
1516 dprintk("This is just a backup slave\n");
1517 bond_set_slave_inactive_flags(new_slave);
1518 }
1519 break; 1518 break;
1520 case BOND_MODE_8023AD: 1519 case BOND_MODE_8023AD:
1521 /* in 802.3ad mode, the internal mechanism 1520 /* in 802.3ad mode, the internal mechanism
@@ -1778,7 +1777,8 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1778 dev_set_mac_address(slave_dev, &addr); 1777 dev_set_mac_address(slave_dev, &addr);
1779 1778
1780 slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB | 1779 slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB |
1781 IFF_SLAVE_INACTIVE); 1780 IFF_SLAVE_INACTIVE | IFF_BONDING |
1781 IFF_SLAVE_NEEDARP);
1782 1782
1783 kfree(slave); 1783 kfree(slave);
1784 1784
@@ -2291,6 +2291,25 @@ static int bond_has_ip(struct bonding *bond)
2291 return 0; 2291 return 0;
2292} 2292}
2293 2293
2294static int bond_has_this_ip(struct bonding *bond, u32 ip)
2295{
2296 struct vlan_entry *vlan, *vlan_next;
2297
2298 if (ip == bond->master_ip)
2299 return 1;
2300
2301 if (list_empty(&bond->vlan_list))
2302 return 0;
2303
2304 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list,
2305 vlan_list) {
2306 if (ip == vlan->vlan_ip)
2307 return 1;
2308 }
2309
2310 return 0;
2311}
2312
2294/* 2313/*
2295 * We go to the (large) trouble of VLAN tagging ARP frames because 2314 * We go to the (large) trouble of VLAN tagging ARP frames because
2296 * switches in VLAN mode (especially if ports are configured as 2315 * switches in VLAN mode (especially if ports are configured as
@@ -2429,6 +2448,93 @@ static void bond_send_gratuitous_arp(struct bonding *bond)
2429 } 2448 }
2430} 2449}
2431 2450
2451static void bond_validate_arp(struct bonding *bond, struct slave *slave, u32 sip, u32 tip)
2452{
2453 int i;
2454 u32 *targets = bond->params.arp_targets;
2455
2456 targets = bond->params.arp_targets;
2457 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
2458 dprintk("bva: sip %u.%u.%u.%u tip %u.%u.%u.%u t[%d] "
2459 "%u.%u.%u.%u bhti(tip) %d\n",
2460 NIPQUAD(sip), NIPQUAD(tip), i, NIPQUAD(targets[i]),
2461 bond_has_this_ip(bond, tip));
2462 if (sip == targets[i]) {
2463 if (bond_has_this_ip(bond, tip))
2464 slave->last_arp_rx = jiffies;
2465 return;
2466 }
2467 }
2468}
2469
2470static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
2471{
2472 struct arphdr *arp;
2473 struct slave *slave;
2474 struct bonding *bond;
2475 unsigned char *arp_ptr;
2476 u32 sip, tip;
2477
2478 if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER))
2479 goto out;
2480
2481 bond = dev->priv;
2482 read_lock(&bond->lock);
2483
2484 dprintk("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n",
2485 bond->dev->name, skb->dev ? skb->dev->name : "NULL",
2486 orig_dev ? orig_dev->name : "NULL");
2487
2488 slave = bond_get_slave_by_dev(bond, orig_dev);
2489 if (!slave || !slave_do_arp_validate(bond, slave))
2490 goto out_unlock;
2491
2492 /* ARP header, plus 2 device addresses, plus 2 IP addresses. */
2493 if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
2494 (2 * dev->addr_len) +
2495 (2 * sizeof(u32)))))
2496 goto out_unlock;
2497
2498 arp = skb->nh.arph;
2499 if (arp->ar_hln != dev->addr_len ||
2500 skb->pkt_type == PACKET_OTHERHOST ||
2501 skb->pkt_type == PACKET_LOOPBACK ||
2502 arp->ar_hrd != htons(ARPHRD_ETHER) ||
2503 arp->ar_pro != htons(ETH_P_IP) ||
2504 arp->ar_pln != 4)
2505 goto out_unlock;
2506
2507 arp_ptr = (unsigned char *)(arp + 1);
2508 arp_ptr += dev->addr_len;
2509 memcpy(&sip, arp_ptr, 4);
2510 arp_ptr += 4 + dev->addr_len;
2511 memcpy(&tip, arp_ptr, 4);
2512
2513 dprintk("bond_arp_rcv: %s %s/%d av %d sv %d sip %u.%u.%u.%u"
2514 " tip %u.%u.%u.%u\n", bond->dev->name, slave->dev->name,
2515 slave->state, bond->params.arp_validate,
2516 slave_do_arp_validate(bond, slave), NIPQUAD(sip), NIPQUAD(tip));
2517
2518 /*
2519 * Backup slaves won't see the ARP reply, but do come through
2520 * here for each ARP probe (so we swap the sip/tip to validate
2521 * the probe). In a "redundant switch, common router" type of
2522 * configuration, the ARP probe will (hopefully) travel from
2523 * the active, through one switch, the router, then the other
2524 * switch before reaching the backup.
2525 */
2526 if (slave->state == BOND_STATE_ACTIVE)
2527 bond_validate_arp(bond, slave, sip, tip);
2528 else
2529 bond_validate_arp(bond, slave, tip, sip);
2530
2531out_unlock:
2532 read_unlock(&bond->lock);
2533out:
2534 dev_kfree_skb(skb);
2535 return NET_RX_SUCCESS;
2536}
2537
2432/* 2538/*
2433 * this function is called regularly to monitor each slave's link 2539 * this function is called regularly to monitor each slave's link
2434 * ensuring that traffic is being sent and received when arp monitoring 2540 * ensuring that traffic is being sent and received when arp monitoring
@@ -2593,7 +2699,8 @@ void bond_activebackup_arp_mon(struct net_device *bond_dev)
2593 */ 2699 */
2594 bond_for_each_slave(bond, slave, i) { 2700 bond_for_each_slave(bond, slave, i) {
2595 if (slave->link != BOND_LINK_UP) { 2701 if (slave->link != BOND_LINK_UP) {
2596 if ((jiffies - slave->dev->last_rx) <= delta_in_ticks) { 2702 if ((jiffies - slave_last_rx(bond, slave)) <=
2703 delta_in_ticks) {
2597 2704
2598 slave->link = BOND_LINK_UP; 2705 slave->link = BOND_LINK_UP;
2599 2706
@@ -2638,7 +2745,7 @@ void bond_activebackup_arp_mon(struct net_device *bond_dev)
2638 2745
2639 if ((slave != bond->curr_active_slave) && 2746 if ((slave != bond->curr_active_slave) &&
2640 (!bond->current_arp_slave) && 2747 (!bond->current_arp_slave) &&
2641 (((jiffies - slave->dev->last_rx) >= 3*delta_in_ticks) && 2748 (((jiffies - slave_last_rx(bond, slave)) >= 3*delta_in_ticks) &&
2642 bond_has_ip(bond))) { 2749 bond_has_ip(bond))) {
2643 /* a backup slave has gone down; three times 2750 /* a backup slave has gone down; three times
2644 * the delta allows the current slave to be 2751 * the delta allows the current slave to be
@@ -2685,7 +2792,7 @@ void bond_activebackup_arp_mon(struct net_device *bond_dev)
2685 * if it is up and needs to take over as the curr_active_slave 2792 * if it is up and needs to take over as the curr_active_slave
2686 */ 2793 */
2687 if ((((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) || 2794 if ((((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) ||
2688 (((jiffies - slave->dev->last_rx) >= (2*delta_in_ticks)) && 2795 (((jiffies - slave_last_rx(bond, slave)) >= (2*delta_in_ticks)) &&
2689 bond_has_ip(bond))) && 2796 bond_has_ip(bond))) &&
2690 ((jiffies - slave->jiffies) >= 2*delta_in_ticks)) { 2797 ((jiffies - slave->jiffies) >= 2*delta_in_ticks)) {
2691 2798
@@ -2950,7 +3057,7 @@ static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave
2950 seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name); 3057 seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name);
2951 seq_printf(seq, "MII Status: %s\n", 3058 seq_printf(seq, "MII Status: %s\n",
2952 (slave->link == BOND_LINK_UP) ? "up" : "down"); 3059 (slave->link == BOND_LINK_UP) ? "up" : "down");
2953 seq_printf(seq, "Link Failure Count: %d\n", 3060 seq_printf(seq, "Link Failure Count: %u\n",
2954 slave->link_failure_count); 3061 slave->link_failure_count);
2955 3062
2956 seq_printf(seq, 3063 seq_printf(seq,
@@ -3210,6 +3317,9 @@ static int bond_netdev_event(struct notifier_block *this, unsigned long event, v
3210 (event_dev ? event_dev->name : "None"), 3317 (event_dev ? event_dev->name : "None"),
3211 event); 3318 event);
3212 3319
3320 if (!(event_dev->priv_flags & IFF_BONDING))
3321 return NOTIFY_DONE;
3322
3213 if (event_dev->flags & IFF_MASTER) { 3323 if (event_dev->flags & IFF_MASTER) {
3214 dprintk("IFF_MASTER\n"); 3324 dprintk("IFF_MASTER\n");
3215 return bond_master_netdev_event(event, event_dev); 3325 return bond_master_netdev_event(event, event_dev);
@@ -3305,6 +3415,21 @@ static void bond_unregister_lacpdu(struct bonding *bond)
3305 dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type)); 3415 dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type));
3306} 3416}
3307 3417
3418void bond_register_arp(struct bonding *bond)
3419{
3420 struct packet_type *pt = &bond->arp_mon_pt;
3421
3422 pt->type = htons(ETH_P_ARP);
3423 pt->dev = NULL; /*bond->dev;XXX*/
3424 pt->func = bond_arp_rcv;
3425 dev_add_pack(pt);
3426}
3427
3428void bond_unregister_arp(struct bonding *bond)
3429{
3430 dev_remove_pack(&bond->arp_mon_pt);
3431}
3432
3308/*---------------------------- Hashing Policies -----------------------------*/ 3433/*---------------------------- Hashing Policies -----------------------------*/
3309 3434
3310/* 3435/*
@@ -3391,6 +3516,9 @@ static int bond_open(struct net_device *bond_dev)
3391 } else { 3516 } else {
3392 arp_timer->function = (void *)&bond_loadbalance_arp_mon; 3517 arp_timer->function = (void *)&bond_loadbalance_arp_mon;
3393 } 3518 }
3519 if (bond->params.arp_validate)
3520 bond_register_arp(bond);
3521
3394 add_timer(arp_timer); 3522 add_timer(arp_timer);
3395 } 3523 }
3396 3524
@@ -3418,9 +3546,11 @@ static int bond_close(struct net_device *bond_dev)
3418 bond_unregister_lacpdu(bond); 3546 bond_unregister_lacpdu(bond);
3419 } 3547 }
3420 3548
3549 if (bond->params.arp_validate)
3550 bond_unregister_arp(bond);
3551
3421 write_lock_bh(&bond->lock); 3552 write_lock_bh(&bond->lock);
3422 3553
3423 bond_mc_list_destroy(bond);
3424 3554
3425 /* signal timers not to re-arm */ 3555 /* signal timers not to re-arm */
3426 bond->kill_timers = 1; 3556 bond->kill_timers = 1;
@@ -3451,8 +3581,6 @@ static int bond_close(struct net_device *bond_dev)
3451 break; 3581 break;
3452 } 3582 }
3453 3583
3454 /* Release the bonded slaves */
3455 bond_release_all(bond_dev);
3456 3584
3457 if ((bond->params.mode == BOND_MODE_TLB) || 3585 if ((bond->params.mode == BOND_MODE_TLB) ||
3458 (bond->params.mode == BOND_MODE_ALB)) { 3586 (bond->params.mode == BOND_MODE_ALB)) {
@@ -4179,6 +4307,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4179 /* Initialize the device options */ 4307 /* Initialize the device options */
4180 bond_dev->tx_queue_len = 0; 4308 bond_dev->tx_queue_len = 0;
4181 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST; 4309 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
4310 bond_dev->priv_flags |= IFF_BONDING;
4182 4311
4183 /* At first, we block adding VLANs. That's the only way to 4312 /* At first, we block adding VLANs. That's the only way to
4184 * prevent problems that occur when adding VLANs over an 4313 * prevent problems that occur when adding VLANs over an
@@ -4237,6 +4366,9 @@ static void bond_free_all(void)
4237 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) { 4366 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) {
4238 struct net_device *bond_dev = bond->dev; 4367 struct net_device *bond_dev = bond->dev;
4239 4368
4369 bond_mc_list_destroy(bond);
4370 /* Release the bonded slaves */
4371 bond_release_all(bond_dev);
4240 unregister_netdevice(bond_dev); 4372 unregister_netdevice(bond_dev);
4241 bond_deinit(bond_dev); 4373 bond_deinit(bond_dev);
4242 } 4374 }
@@ -4270,6 +4402,8 @@ int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl)
4270 4402
4271static int bond_check_params(struct bond_params *params) 4403static int bond_check_params(struct bond_params *params)
4272{ 4404{
4405 int arp_validate_value;
4406
4273 /* 4407 /*
4274 * Convert string parameters. 4408 * Convert string parameters.
4275 */ 4409 */
@@ -4473,6 +4607,29 @@ static int bond_check_params(struct bond_params *params)
4473 arp_interval = 0; 4607 arp_interval = 0;
4474 } 4608 }
4475 4609
4610 if (arp_validate) {
4611 if (bond_mode != BOND_MODE_ACTIVEBACKUP) {
4612 printk(KERN_ERR DRV_NAME
4613 ": arp_validate only supported in active-backup mode\n");
4614 return -EINVAL;
4615 }
4616 if (!arp_interval) {
4617 printk(KERN_ERR DRV_NAME
4618 ": arp_validate requires arp_interval\n");
4619 return -EINVAL;
4620 }
4621
4622 arp_validate_value = bond_parse_parm(arp_validate,
4623 arp_validate_tbl);
4624 if (arp_validate_value == -1) {
4625 printk(KERN_ERR DRV_NAME
4626 ": Error: invalid arp_validate \"%s\"\n",
4627 arp_validate == NULL ? "NULL" : arp_validate);
4628 return -EINVAL;
4629 }
4630 } else
4631 arp_validate_value = 0;
4632
4476 if (miimon) { 4633 if (miimon) {
4477 printk(KERN_INFO DRV_NAME 4634 printk(KERN_INFO DRV_NAME
4478 ": MII link monitoring set to %d ms\n", 4635 ": MII link monitoring set to %d ms\n",
@@ -4481,8 +4638,10 @@ static int bond_check_params(struct bond_params *params)
4481 int i; 4638 int i;
4482 4639
4483 printk(KERN_INFO DRV_NAME 4640 printk(KERN_INFO DRV_NAME
4484 ": ARP monitoring set to %d ms with %d target(s):", 4641 ": ARP monitoring set to %d ms, validate %s, with %d target(s):",
4485 arp_interval, arp_ip_count); 4642 arp_interval,
4643 arp_validate_tbl[arp_validate_value].modename,
4644 arp_ip_count);
4486 4645
4487 for (i = 0; i < arp_ip_count; i++) 4646 for (i = 0; i < arp_ip_count; i++)
4488 printk (" %s", arp_ip_target[i]); 4647 printk (" %s", arp_ip_target[i]);
@@ -4516,6 +4675,7 @@ static int bond_check_params(struct bond_params *params)
4516 params->xmit_policy = xmit_hashtype; 4675 params->xmit_policy = xmit_hashtype;
4517 params->miimon = miimon; 4676 params->miimon = miimon;
4518 params->arp_interval = arp_interval; 4677 params->arp_interval = arp_interval;
4678 params->arp_validate = arp_validate_value;
4519 params->updelay = updelay; 4679 params->updelay = updelay;
4520 params->downdelay = downdelay; 4680 params->downdelay = downdelay;
4521 params->use_carrier = use_carrier; 4681 params->use_carrier = use_carrier;
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index cfe4dc3a93a3..ced9ed8f995a 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -51,6 +51,7 @@ extern struct bond_params bonding_defaults;
51extern struct bond_parm_tbl bond_mode_tbl[]; 51extern struct bond_parm_tbl bond_mode_tbl[];
52extern struct bond_parm_tbl bond_lacp_tbl[]; 52extern struct bond_parm_tbl bond_lacp_tbl[];
53extern struct bond_parm_tbl xmit_hashtype_tbl[]; 53extern struct bond_parm_tbl xmit_hashtype_tbl[];
54extern struct bond_parm_tbl arp_validate_tbl[];
54 55
55static int expected_refcount = -1; 56static int expected_refcount = -1;
56static struct class *netdev_class; 57static struct class *netdev_class;
@@ -503,6 +504,53 @@ out:
503static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); 504static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash);
504 505
505/* 506/*
507 * Show and set arp_validate.
508 */
509static ssize_t bonding_show_arp_validate(struct class_device *cd, char *buf)
510{
511 struct bonding *bond = to_bond(cd);
512
513 return sprintf(buf, "%s %d\n",
514 arp_validate_tbl[bond->params.arp_validate].modename,
515 bond->params.arp_validate) + 1;
516}
517
518static ssize_t bonding_store_arp_validate(struct class_device *cd, const char *buf, size_t count)
519{
520 int new_value;
521 struct bonding *bond = to_bond(cd);
522
523 new_value = bond_parse_parm((char *)buf, arp_validate_tbl);
524 if (new_value < 0) {
525 printk(KERN_ERR DRV_NAME
526 ": %s: Ignoring invalid arp_validate value %s\n",
527 bond->dev->name, buf);
528 return -EINVAL;
529 }
530 if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
531 printk(KERN_ERR DRV_NAME
532 ": %s: arp_validate only supported in active-backup mode.\n",
533 bond->dev->name);
534 return -EINVAL;
535 }
536 printk(KERN_INFO DRV_NAME ": %s: setting arp_validate to %s (%d).\n",
537 bond->dev->name, arp_validate_tbl[new_value].modename,
538 new_value);
539
540 if (!bond->params.arp_validate && new_value) {
541 bond_register_arp(bond);
542 } else if (bond->params.arp_validate && !new_value) {
543 bond_unregister_arp(bond);
544 }
545
546 bond->params.arp_validate = new_value;
547
548 return count;
549}
550
551static CLASS_DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate);
552
553/*
506 * Show and set the arp timer interval. There are two tricky bits 554 * Show and set the arp timer interval. There are two tricky bits
507 * here. First, if ARP monitoring is activated, then we must disable 555 * here. First, if ARP monitoring is activated, then we must disable
508 * MII monitoring. Second, if the ARP timer isn't running, we must 556 * MII monitoring. Second, if the ARP timer isn't running, we must
@@ -914,6 +962,11 @@ static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, si
914 "ARP monitoring. Disabling ARP monitoring...\n", 962 "ARP monitoring. Disabling ARP monitoring...\n",
915 bond->dev->name); 963 bond->dev->name);
916 bond->params.arp_interval = 0; 964 bond->params.arp_interval = 0;
965 if (bond->params.arp_validate) {
966 bond_unregister_arp(bond);
967 bond->params.arp_validate =
968 BOND_ARP_VALIDATE_NONE;
969 }
917 /* Kill ARP timer, else it brings bond's link down */ 970 /* Kill ARP timer, else it brings bond's link down */
918 if (bond->mii_timer.function) { 971 if (bond->mii_timer.function) {
919 printk(KERN_INFO DRV_NAME 972 printk(KERN_INFO DRV_NAME
@@ -1093,7 +1146,7 @@ static ssize_t bonding_store_active_slave(struct class_device *cd, const char *b
1093 strlen(slave->dev->name)) == 0) { 1146 strlen(slave->dev->name)) == 0) {
1094 old_active = bond->curr_active_slave; 1147 old_active = bond->curr_active_slave;
1095 new_active = slave; 1148 new_active = slave;
1096 if (new_active && (new_active == old_active)) { 1149 if (new_active == old_active) {
1097 /* do nothing */ 1150 /* do nothing */
1098 printk(KERN_INFO DRV_NAME 1151 printk(KERN_INFO DRV_NAME
1099 ": %s: %s is already the current active slave.\n", 1152 ": %s: %s is already the current active slave.\n",
@@ -1273,6 +1326,7 @@ static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, N
1273static struct attribute *per_bond_attrs[] = { 1326static struct attribute *per_bond_attrs[] = {
1274 &class_device_attr_slaves.attr, 1327 &class_device_attr_slaves.attr,
1275 &class_device_attr_mode.attr, 1328 &class_device_attr_mode.attr,
1329 &class_device_attr_arp_validate.attr,
1276 &class_device_attr_arp_interval.attr, 1330 &class_device_attr_arp_interval.attr,
1277 &class_device_attr_arp_ip_target.attr, 1331 &class_device_attr_arp_ip_target.attr,
1278 &class_device_attr_downdelay.attr, 1332 &class_device_attr_downdelay.attr,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 0bdfe2c71453..db16fee40a5f 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -22,8 +22,8 @@
22#include "bond_3ad.h" 22#include "bond_3ad.h"
23#include "bond_alb.h" 23#include "bond_alb.h"
24 24
25#define DRV_VERSION "3.0.3" 25#define DRV_VERSION "3.1.0-test"
26#define DRV_RELDATE "March 23, 2006" 26#define DRV_RELDATE "September 9, 2006"
27#define DRV_NAME "bonding" 27#define DRV_NAME "bonding"
28#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" 28#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
29 29
@@ -126,6 +126,7 @@ struct bond_params {
126 int xmit_policy; 126 int xmit_policy;
127 int miimon; 127 int miimon;
128 int arp_interval; 128 int arp_interval;
129 int arp_validate;
129 int use_carrier; 130 int use_carrier;
130 int updelay; 131 int updelay;
131 int downdelay; 132 int downdelay;
@@ -149,8 +150,9 @@ struct slave {
149 struct net_device *dev; /* first - useful for panic debug */ 150 struct net_device *dev; /* first - useful for panic debug */
150 struct slave *next; 151 struct slave *next;
151 struct slave *prev; 152 struct slave *prev;
152 s16 delay; 153 int delay;
153 u32 jiffies; 154 u32 jiffies;
155 u32 last_arp_rx;
154 s8 link; /* one of BOND_LINK_XXXX */ 156 s8 link; /* one of BOND_LINK_XXXX */
155 s8 state; /* one of BOND_STATE_XXXX */ 157 s8 state; /* one of BOND_STATE_XXXX */
156 u32 original_flags; 158 u32 original_flags;
@@ -198,6 +200,7 @@ struct bonding {
198 struct bond_params params; 200 struct bond_params params;
199 struct list_head vlan_list; 201 struct list_head vlan_list;
200 struct vlan_group *vlgrp; 202 struct vlan_group *vlgrp;
203 struct packet_type arp_mon_pt;
201}; 204};
202 205
203/** 206/**
@@ -228,6 +231,25 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
228 return (struct bonding *)slave->dev->master->priv; 231 return (struct bonding *)slave->dev->master->priv;
229} 232}
230 233
234#define BOND_ARP_VALIDATE_NONE 0
235#define BOND_ARP_VALIDATE_ACTIVE (1 << BOND_STATE_ACTIVE)
236#define BOND_ARP_VALIDATE_BACKUP (1 << BOND_STATE_BACKUP)
237#define BOND_ARP_VALIDATE_ALL (BOND_ARP_VALIDATE_ACTIVE | \
238 BOND_ARP_VALIDATE_BACKUP)
239
240extern inline int slave_do_arp_validate(struct bonding *bond, struct slave *slave)
241{
242 return bond->params.arp_validate & (1 << slave->state);
243}
244
245extern inline u32 slave_last_rx(struct bonding *bond, struct slave *slave)
246{
247 if (slave_do_arp_validate(bond, slave))
248 return slave->last_arp_rx;
249
250 return slave->dev->last_rx;
251}
252
231static inline void bond_set_slave_inactive_flags(struct slave *slave) 253static inline void bond_set_slave_inactive_flags(struct slave *slave)
232{ 254{
233 struct bonding *bond = slave->dev->master->priv; 255 struct bonding *bond = slave->dev->master->priv;
@@ -235,12 +257,14 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave)
235 bond->params.mode != BOND_MODE_ALB) 257 bond->params.mode != BOND_MODE_ALB)
236 slave->state = BOND_STATE_BACKUP; 258 slave->state = BOND_STATE_BACKUP;
237 slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; 259 slave->dev->priv_flags |= IFF_SLAVE_INACTIVE;
260 if (slave_do_arp_validate(bond, slave))
261 slave->dev->priv_flags |= IFF_SLAVE_NEEDARP;
238} 262}
239 263
240static inline void bond_set_slave_active_flags(struct slave *slave) 264static inline void bond_set_slave_active_flags(struct slave *slave)
241{ 265{
242 slave->state = BOND_STATE_ACTIVE; 266 slave->state = BOND_STATE_ACTIVE;
243 slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE; 267 slave->dev->priv_flags &= ~(IFF_SLAVE_INACTIVE | IFF_SLAVE_NEEDARP);
244} 268}
245 269
246static inline void bond_set_master_3ad_flags(struct bonding *bond) 270static inline void bond_set_master_3ad_flags(struct bonding *bond)
@@ -284,6 +308,8 @@ int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl);
284const char *bond_mode_name(int mode); 308const char *bond_mode_name(int mode);
285void bond_select_active_slave(struct bonding *bond); 309void bond_select_active_slave(struct bonding *bond);
286void bond_change_active_slave(struct bonding *bond, struct slave *new_active); 310void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
311void bond_register_arp(struct bonding *);
312void bond_unregister_arp(struct bonding *);
287 313
288#endif /* _LINUX_BONDING_H */ 314#endif /* _LINUX_BONDING_H */
289 315
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index a170e96251f6..4020acb55005 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -1367,8 +1367,8 @@ struct e1000_hw_stats {
1367 1367
1368/* Structure containing variables used by the shared code (e1000_hw.c) */ 1368/* Structure containing variables used by the shared code (e1000_hw.c) */
1369struct e1000_hw { 1369struct e1000_hw {
1370 uint8_t *hw_addr; 1370 uint8_t __iomem *hw_addr;
1371 uint8_t *flash_address; 1371 uint8_t __iomem *flash_address;
1372 e1000_mac_type mac_type; 1372 e1000_mac_type mac_type;
1373 e1000_phy_type phy_type; 1373 e1000_phy_type phy_type;
1374 uint32_t phy_init_script; 1374 uint32_t phy_init_script;
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 97db910fbc8c..eea1d66c530e 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -3789,6 +3789,12 @@ static int nv_loopback_test(struct net_device *dev)
3789 /* setup packet for tx */ 3789 /* setup packet for tx */
3790 pkt_len = ETH_DATA_LEN; 3790 pkt_len = ETH_DATA_LEN;
3791 tx_skb = dev_alloc_skb(pkt_len); 3791 tx_skb = dev_alloc_skb(pkt_len);
3792 if (!tx_skb) {
3793 printk(KERN_ERR "dev_alloc_skb() failed during loopback test"
3794 " of %s\n", dev->name);
3795 ret = 0;
3796 goto out;
3797 }
3792 pkt_data = skb_put(tx_skb, pkt_len); 3798 pkt_data = skb_put(tx_skb, pkt_len);
3793 for (i = 0; i < pkt_len; i++) 3799 for (i = 0; i < pkt_len; i++)
3794 pkt_data[i] = (u8)(i & 0xff); 3800 pkt_data[i] = (u8)(i & 0xff);
@@ -3853,7 +3859,7 @@ static int nv_loopback_test(struct net_device *dev)
3853 tx_skb->end-tx_skb->data, 3859 tx_skb->end-tx_skb->data,
3854 PCI_DMA_TODEVICE); 3860 PCI_DMA_TODEVICE);
3855 dev_kfree_skb_any(tx_skb); 3861 dev_kfree_skb_any(tx_skb);
3856 3862 out:
3857 /* stop engines */ 3863 /* stop engines */
3858 nv_stop_rx(dev); 3864 nv_stop_rx(dev);
3859 nv_stop_tx(dev); 3865 nv_stop_tx(dev);
diff --git a/drivers/net/gt64240eth.h b/drivers/net/gt64240eth.h
deleted file mode 100644
index 0d6f486e4579..000000000000
--- a/drivers/net/gt64240eth.h
+++ /dev/null
@@ -1,402 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2001 Patton Electronics Company
7 * Copyright (C) 2002 Momentum Computer
8 *
9 * Copyright 2000 MontaVista Software Inc.
10 * Author: MontaVista Software, Inc.
11 * stevel@mvista.com or support@mvista.com
12 *
13 * This program is free software; you can distribute it and/or modify it
14 * under the terms of the GNU General Public License (Version 2) as
15 * published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
25 *
26 * Ethernet driver definitions for the MIPS GT96100 Advanced
27 * Communication Controller.
28 *
29 * Modified for the Marvellous GT64240 Retarded Communication Controller.
30 */
31#ifndef _GT64240ETH_H
32#define _GT64240ETH_H
33
34#include <asm/gt64240.h>
35
36#define ETHERNET_PORTS_DIFFERENCE_OFFSETS 0x400
37
38/* Translate those weanie names from Galileo/VxWorks header files: */
39
40#define GT64240_MRR MAIN_ROUTING_REGISTER
41#define GT64240_CIU_ARBITER_CONFIG COMM_UNIT_ARBITER_CONFIGURATION_REGISTER
42#define GT64240_CIU_ARBITER_CONTROL COMM_UNIT_ARBITER_CONTROL
43#define GT64240_MAIN_LOW_CAUSE LOW_INTERRUPT_CAUSE_REGISTER
44#define GT64240_MAIN_HIGH_CAUSE HIGH_INTERRUPT_CAUSE_REGISTER
45#define GT64240_CPU_LOW_MASK CPU_INTERRUPT_MASK_REGISTER_LOW
46#define GT64240_CPU_HIGH_MASK CPU_INTERRUPT_MASK_REGISTER_HIGH
47#define GT64240_CPU_SELECT_CAUSE CPU_SELECT_CAUSE_REGISTER
48
49#define GT64240_ETH_PHY_ADDR_REG ETHERNET_PHY_ADDRESS_REGISTER
50#define GT64240_ETH_PORT_CONFIG ETHERNET0_PORT_CONFIGURATION_REGISTER
51#define GT64240_ETH_PORT_CONFIG_EXT ETHERNET0_PORT_CONFIGURATION_EXTEND_REGISTER
52#define GT64240_ETH_PORT_COMMAND ETHERNET0_PORT_COMMAND_REGISTER
53#define GT64240_ETH_PORT_STATUS ETHERNET0_PORT_STATUS_REGISTER
54#define GT64240_ETH_IO_SIZE ETHERNET_PORTS_DIFFERENCE_OFFSETS
55#define GT64240_ETH_SMI_REG ETHERNET_SMI_REGISTER
56#define GT64240_ETH_MIB_COUNT_BASE ETHERNET0_MIB_COUNTER_BASE
57#define GT64240_ETH_SDMA_CONFIG ETHERNET0_SDMA_CONFIGURATION_REGISTER
58#define GT64240_ETH_SDMA_COMM ETHERNET0_SDMA_COMMAND_REGISTER
59#define GT64240_ETH_INT_MASK ETHERNET0_INTERRUPT_MASK_REGISTER
60#define GT64240_ETH_INT_CAUSE ETHERNET0_INTERRUPT_CAUSE_REGISTER
61#define GT64240_ETH_CURR_TX_DESC_PTR0 ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER0
62#define GT64240_ETH_CURR_TX_DESC_PTR1 ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER1
63#define GT64240_ETH_1ST_RX_DESC_PTR0 ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER0
64#define GT64240_ETH_CURR_RX_DESC_PTR0 ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER0
65#define GT64240_ETH_HASH_TBL_PTR ETHERNET0_HASH_TABLE_POINTER_REGISTER
66
67/* Turn on NAPI by default */
68
69#define GT64240_NAPI 1
70
71/* Some 64240 settings that SHOULD eventually be setup in PROM monitor: */
72/* (Board-specific to the DSL3224 Rev A board ONLY!) */
73#define D3224_MPP_CTRL0_SETTING 0x66669900
74#define D3224_MPP_CTRL1_SETTING 0x00000000
75#define D3224_MPP_CTRL2_SETTING 0x00887700
76#define D3224_MPP_CTRL3_SETTING 0x00000044
77#define D3224_GPP_IO_CTRL_SETTING 0x0000e800
78#define D3224_GPP_LEVEL_CTRL_SETTING 0xf001f703
79#define D3224_GPP_VALUE_SETTING 0x00000000
80
81/* Keep the ring sizes a power of two for efficiency. */
82//-#define TX_RING_SIZE 16
83#define TX_RING_SIZE 64 /* TESTING !!! */
84#define RX_RING_SIZE 32
85#define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */
86
87#define RX_HASH_TABLE_SIZE 16384
88#define HASH_HOP_NUMBER 12
89
90#define NUM_INTERFACES 3
91
92#define GT64240ETH_TX_TIMEOUT HZ/4
93
94#define MIPS_GT64240_BASE 0xf4000000
95#define GT64240_ETH0_BASE (MIPS_GT64240_BASE + GT64240_ETH_PORT_CONFIG)
96#define GT64240_ETH1_BASE (GT64240_ETH0_BASE + GT64240_ETH_IO_SIZE)
97#define GT64240_ETH2_BASE (GT64240_ETH1_BASE + GT64240_ETH_IO_SIZE)
98
99#if defined(CONFIG_MIPS_DSL3224)
100#define GT64240_ETHER0_IRQ 4
101#define GT64240_ETHER1_IRQ 4
102#else
103#define GT64240_ETHER0_IRQ -1
104#define GT64240_ETHER1_IRQ -1
105#endif
106
107#define REV_GT64240 0x1
108#define REV_GT64240A 0x10
109
110#define GT64240ETH_READ(gp, offset) \
111 GT_READ((gp)->port_offset + (offset))
112
113#define GT64240ETH_WRITE(gp, offset, data) \
114 GT_WRITE((gp)->port_offset + (offset), (data))
115
116#define GT64240ETH_SETBIT(gp, offset, bits) \
117 GT64240ETH_WRITE((gp), (offset), \
118 GT64240ETH_READ((gp), (offset)) | (bits))
119
120#define GT64240ETH_CLRBIT(gp, offset, bits) \
121 GT64240ETH_WRITE((gp), (offset), \
122 GT64240ETH_READ((gp), (offset)) & ~(bits))
123
124#define GT64240_READ(ofs) GT_READ(ofs)
125#define GT64240_WRITE(ofs, data) GT_WRITE((ofs), (data))
126
127/* Bit definitions of the SMI Reg */
128enum {
129 smirDataMask = 0xffff,
130 smirPhyAdMask = 0x1f << 16,
131 smirPhyAdBit = 16,
132 smirRegAdMask = 0x1f << 21,
133 smirRegAdBit = 21,
134 smirOpCode = 1 << 26,
135 smirReadValid = 1 << 27,
136 smirBusy = 1 << 28
137};
138
139/* Bit definitions of the Port Config Reg */
140enum pcr_bits {
141 pcrPM = 1 << 0,
142 pcrRBM = 1 << 1,
143 pcrPBF = 1 << 2,
144 pcrEN = 1 << 7,
145 pcrLPBKMask = 0x3 << 8,
146 pcrLPBKBit = 1 << 8,
147 pcrFC = 1 << 10,
148 pcrHS = 1 << 12,
149 pcrHM = 1 << 13,
150 pcrHDM = 1 << 14,
151 pcrHD = 1 << 15,
152 pcrISLMask = 0x7 << 28,
153 pcrISLBit = 28,
154 pcrACCS = 1 << 31
155};
156
157/* Bit definitions of the Port Config Extend Reg */
158enum pcxr_bits {
159 pcxrIGMP = 1,
160 pcxrSPAN = 2,
161 pcxrPAR = 4,
162 pcxrPRIOtxMask = 0x7 << 3,
163 pcxrPRIOtxBit = 3,
164 pcxrPRIOrxMask = 0x3 << 6,
165 pcxrPRIOrxBit = 6,
166 pcxrPRIOrxOverride = 1 << 8,
167 pcxrDPLXen = 1 << 9,
168 pcxrFCTLen = 1 << 10,
169 pcxrFLP = 1 << 11,
170 pcxrFCTL = 1 << 12,
171 pcxrMFLMask = 0x3 << 14,
172 pcxrMFLBit = 14,
173 pcxrMIBclrMode = 1 << 16,
174 pcxrSpeed = 1 << 18,
175 pcxrSpeeden = 1 << 19,
176 pcxrRMIIen = 1 << 20,
177 pcxrDSCPen = 1 << 21
178};
179
180/* Bit definitions of the Port Command Reg */
181enum pcmr_bits {
182 pcmrFJ = 1 << 15
183};
184
185
186/* Bit definitions of the Port Status Reg */
187enum psr_bits {
188 psrSpeed = 1,
189 psrDuplex = 2,
190 psrFctl = 4,
191 psrLink = 8,
192 psrPause = 1 << 4,
193 psrTxLow = 1 << 5,
194 psrTxHigh = 1 << 6,
195 psrTxInProg = 1 << 7
196};
197
198/* Bit definitions of the SDMA Config Reg */
199enum sdcr_bits {
200 sdcrRCMask = 0xf << 2,
201 sdcrRCBit = 2,
202 sdcrBLMR = 1 << 6,
203 sdcrBLMT = 1 << 7,
204 sdcrPOVR = 1 << 8,
205 sdcrRIFB = 1 << 9,
206 sdcrBSZMask = 0x3 << 12,
207 sdcrBSZBit = 12
208};
209
210/* Bit definitions of the SDMA Command Reg */
211enum sdcmr_bits {
212 sdcmrERD = 1 << 7,
213 sdcmrAR = 1 << 15,
214 sdcmrSTDH = 1 << 16,
215 sdcmrSTDL = 1 << 17,
216 sdcmrTXDH = 1 << 23,
217 sdcmrTXDL = 1 << 24,
218 sdcmrAT = 1 << 31
219};
220
221/* Bit definitions of the Interrupt Cause Reg */
222enum icr_bits {
223 icrRxBuffer = 1,
224 icrTxBufferHigh = 1 << 2,
225 icrTxBufferLow = 1 << 3,
226 icrTxEndHigh = 1 << 6,
227 icrTxEndLow = 1 << 7,
228 icrRxError = 1 << 8,
229 icrTxErrorHigh = 1 << 10,
230 icrTxErrorLow = 1 << 11,
231 icrRxOVR = 1 << 12,
232 icrTxUdr = 1 << 13,
233 icrRxBufferQ0 = 1 << 16,
234 icrRxBufferQ1 = 1 << 17,
235 icrRxBufferQ2 = 1 << 18,
236 icrRxBufferQ3 = 1 << 19,
237 icrRxErrorQ0 = 1 << 20,
238 icrRxErrorQ1 = 1 << 21,
239 icrRxErrorQ2 = 1 << 22,
240 icrRxErrorQ3 = 1 << 23,
241 icrMIIPhySTC = 1 << 28,
242 icrSMIdone = 1 << 29,
243 icrEtherIntSum = 1 << 31
244};
245
246
247/* The Rx and Tx descriptor lists. */
248#ifdef __LITTLE_ENDIAN
249typedef struct {
250 u32 cmdstat;
251 u16 reserved; //-prk21aug01 u32 reserved:16;
252 u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16;
253 u32 buff_ptr;
254 u32 next;
255} gt64240_td_t;
256
257typedef struct {
258 u32 cmdstat;
259 u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16;
260 u16 buff_sz; //-prk21aug01 u32 buff_sz:16;
261 u32 buff_ptr;
262 u32 next;
263} gt64240_rd_t;
264#elif defined(__BIG_ENDIAN)
265typedef struct {
266 u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16;
267 u16 reserved; //-prk21aug01 u32 reserved:16;
268 u32 cmdstat;
269 u32 next;
270 u32 buff_ptr;
271} gt64240_td_t;
272
273typedef struct {
274 u16 buff_sz; //-prk21aug01 u32 buff_sz:16;
275 u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16;
276 u32 cmdstat;
277 u32 next;
278 u32 buff_ptr;
279} gt64240_rd_t;
280#else
281#error Either __BIG_ENDIAN or __LITTLE_ENDIAN must be defined!
282#endif
283
284
285/* Values for the Tx command-status descriptor entry. */
286enum td_cmdstat {
287 txOwn = 1 << 31,
288 txAutoMode = 1 << 30,
289 txEI = 1 << 23,
290 txGenCRC = 1 << 22,
291 txPad = 1 << 18,
292 txFirst = 1 << 17,
293 txLast = 1 << 16,
294 txErrorSummary = 1 << 15,
295 txReTxCntMask = 0x0f << 10,
296 txReTxCntBit = 10,
297 txCollision = 1 << 9,
298 txReTxLimit = 1 << 8,
299 txUnderrun = 1 << 6,
300 txLateCollision = 1 << 5
301};
302
303
304/* Values for the Rx command-status descriptor entry. */
305enum rd_cmdstat {
306 rxOwn = 1 << 31,
307 rxAutoMode = 1 << 30,
308 rxEI = 1 << 23,
309 rxFirst = 1 << 17,
310 rxLast = 1 << 16,
311 rxErrorSummary = 1 << 15,
312 rxIGMP = 1 << 14,
313 rxHashExpired = 1 << 13,
314 rxMissedFrame = 1 << 12,
315 rxFrameType = 1 << 11,
316 rxShortFrame = 1 << 8,
317 rxMaxFrameLen = 1 << 7,
318 rxOverrun = 1 << 6,
319 rxCollision = 1 << 4,
320 rxCRCError = 1
321};
322
323/* Bit fields of a Hash Table Entry */
324enum hash_table_entry {
325 hteValid = 1,
326 hteSkip = 2,
327 hteRD = 4
328};
329
330// The MIB counters
331typedef struct {
332 u32 byteReceived;
333 u32 byteSent;
334 u32 framesReceived;
335 u32 framesSent;
336 u32 totalByteReceived;
337 u32 totalFramesReceived;
338 u32 broadcastFramesReceived;
339 u32 multicastFramesReceived;
340 u32 cRCError;
341 u32 oversizeFrames;
342 u32 fragments;
343 u32 jabber;
344 u32 collision;
345 u32 lateCollision;
346 u32 frames64;
347 u32 frames65_127;
348 u32 frames128_255;
349 u32 frames256_511;
350 u32 frames512_1023;
351 u32 frames1024_MaxSize;
352 u32 macRxError;
353 u32 droppedFrames;
354 u32 outMulticastFrames;
355 u32 outBroadcastFrames;
356 u32 undersizeFrames;
357} mib_counters_t;
358
359
360struct gt64240_private {
361 gt64240_rd_t *rx_ring;
362 gt64240_td_t *tx_ring;
363 // The Rx and Tx rings must be 16-byte aligned
364 dma_addr_t rx_ring_dma;
365 dma_addr_t tx_ring_dma;
366 char *hash_table;
367 // The Hash Table must be 8-byte aligned
368 dma_addr_t hash_table_dma;
369 int hash_mode;
370
371 // The Rx buffers must be 8-byte aligned
372 char *rx_buff;
373 dma_addr_t rx_buff_dma;
374 // Tx buffers (tx_skbuff[i]->data) with less than 8 bytes
375 // of payload must be 8-byte aligned
376 struct sk_buff *tx_skbuff[TX_RING_SIZE];
377 int rx_next_out; /* The next free ring entry to receive */
378 int tx_next_in; /* The next free ring entry to send */
379 int tx_next_out; /* The last ring entry the ISR processed */
380 int tx_count; /* current # of pkts waiting to be sent in Tx ring */
381 int intr_work_done; /* number of Rx and Tx pkts processed in the isr */
382 int tx_full; /* Tx ring is full */
383
384 mib_counters_t mib;
385 struct net_device_stats stats;
386
387 int io_size;
388 int port_num; // 0 or 1
389 u32 port_offset;
390
391 int phy_addr; // PHY address
392 u32 last_psr; // last value of the port status register
393
394 int options; /* User-settable misc. driver options. */
395 int drv_flags;
396 spinlock_t lock; /* Serialise access to device */
397 struct mii_if_info mii_if;
398
399 u32 msg_enable;
400};
401
402#endif /* _GT64240ETH_H */
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 2d1ecfdc80db..ecd3da151e2d 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -522,7 +522,7 @@ EXPORT_SYMBOL(genphy_read_status);
522 522
523static int genphy_config_init(struct phy_device *phydev) 523static int genphy_config_init(struct phy_device *phydev)
524{ 524{
525 u32 val; 525 int val;
526 u32 features; 526 u32 features;
527 527
528 /* For now, I'll claim that the generic driver supports 528 /* For now, I'll claim that the generic driver supports
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index f5dbeb27b6f0..1bf23e41f580 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -2904,7 +2904,7 @@ static void s2io_mdio_write(u32 mmd_type, u64 addr, u16 value, struct net_device
2904{ 2904{
2905 u64 val64 = 0x0; 2905 u64 val64 = 0x0;
2906 nic_t *sp = dev->priv; 2906 nic_t *sp = dev->priv;
2907 XENA_dev_config_t *bar0 = (XENA_dev_config_t *)sp->bar0; 2907 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2908 2908
2909 //address transaction 2909 //address transaction
2910 val64 = val64 | MDIO_MMD_INDX_ADDR(addr) 2910 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
@@ -2953,7 +2953,7 @@ static u64 s2io_mdio_read(u32 mmd_type, u64 addr, struct net_device *dev)
2953 u64 val64 = 0x0; 2953 u64 val64 = 0x0;
2954 u64 rval64 = 0x0; 2954 u64 rval64 = 0x0;
2955 nic_t *sp = dev->priv; 2955 nic_t *sp = dev->priv;
2956 XENA_dev_config_t *bar0 = (XENA_dev_config_t *)sp->bar0; 2956 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2957 2957
2958 /* address transaction */ 2958 /* address transaction */
2959 val64 = val64 | MDIO_MMD_INDX_ADDR(addr) 2959 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
@@ -3276,7 +3276,7 @@ static void alarm_intr_handler(struct s2io_nic *nic)
3276 * SUCCESS on success and FAILURE on failure. 3276 * SUCCESS on success and FAILURE on failure.
3277 */ 3277 */
3278 3278
3279static int wait_for_cmd_complete(void *addr, u64 busy_bit) 3279static int wait_for_cmd_complete(void __iomem *addr, u64 busy_bit)
3280{ 3280{
3281 int ret = FAILURE, cnt = 0; 3281 int ret = FAILURE, cnt = 0;
3282 u64 val64; 3282 u64 val64;
@@ -4303,11 +4303,11 @@ static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4303 sp->stats.tx_errors = 4303 sp->stats.tx_errors =
4304 le32_to_cpu(mac_control->stats_info->tmac_any_err_frms); 4304 le32_to_cpu(mac_control->stats_info->tmac_any_err_frms);
4305 sp->stats.rx_errors = 4305 sp->stats.rx_errors =
4306 le32_to_cpu(mac_control->stats_info->rmac_drop_frms); 4306 le64_to_cpu(mac_control->stats_info->rmac_drop_frms);
4307 sp->stats.multicast = 4307 sp->stats.multicast =
4308 le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms); 4308 le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms);
4309 sp->stats.rx_length_errors = 4309 sp->stats.rx_length_errors =
4310 le32_to_cpu(mac_control->stats_info->rmac_long_frms); 4310 le64_to_cpu(mac_control->stats_info->rmac_long_frms);
4311 4311
4312 return (&sp->stats); 4312 return (&sp->stats);
4313} 4313}
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 9142d91355bc..705e9a8fa30f 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -58,6 +58,7 @@
58#define TX_WATCHDOG (5 * HZ) 58#define TX_WATCHDOG (5 * HZ)
59#define NAPI_WEIGHT 64 59#define NAPI_WEIGHT 64
60#define BLINK_MS 250 60#define BLINK_MS 250
61#define LINK_HZ (HZ/2)
61 62
62MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver"); 63MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver");
63MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>"); 64MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>");
@@ -605,7 +606,12 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
605 if (hw->chip_id == CHIP_ID_GENESIS) { 606 if (hw->chip_id == CHIP_ID_GENESIS) {
606 switch (mode) { 607 switch (mode) {
607 case LED_MODE_OFF: 608 case LED_MODE_OFF:
608 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF); 609 if (hw->phy_type == SK_PHY_BCOM)
610 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF);
611 else {
612 skge_write32(hw, SK_REG(port, TX_LED_VAL), 0);
613 skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_T_OFF);
614 }
609 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF); 615 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
610 skge_write32(hw, SK_REG(port, RX_LED_VAL), 0); 616 skge_write32(hw, SK_REG(port, RX_LED_VAL), 0);
611 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_T_OFF); 617 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_T_OFF);
@@ -625,8 +631,14 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
625 skge_write32(hw, SK_REG(port, RX_LED_VAL), 100); 631 skge_write32(hw, SK_REG(port, RX_LED_VAL), 100);
626 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START); 632 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START);
627 633
628 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON); 634 if (hw->phy_type == SK_PHY_BCOM)
629 break; 635 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON);
636 else {
637 skge_write8(hw, SK_REG(port, TX_LED_TST), LED_T_ON);
638 skge_write32(hw, SK_REG(port, TX_LED_VAL), 100);
639 skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_START);
640 }
641
630 } 642 }
631 } else { 643 } else {
632 switch (mode) { 644 switch (mode) {
@@ -879,6 +891,9 @@ static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val)
879 xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr); 891 xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr);
880 *val = xm_read16(hw, port, XM_PHY_DATA); 892 *val = xm_read16(hw, port, XM_PHY_DATA);
881 893
894 if (hw->phy_type == SK_PHY_XMAC)
895 goto ready;
896
882 for (i = 0; i < PHY_RETRIES; i++) { 897 for (i = 0; i < PHY_RETRIES; i++) {
883 if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY) 898 if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY)
884 goto ready; 899 goto ready;
@@ -965,7 +980,8 @@ static void genesis_reset(struct skge_hw *hw, int port)
965 xm_write16(hw, port, XM_RX_CMD, 0); /* reset RX CMD Reg */ 980 xm_write16(hw, port, XM_RX_CMD, 0); /* reset RX CMD Reg */
966 981
967 /* disable Broadcom PHY IRQ */ 982 /* disable Broadcom PHY IRQ */
968 xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff); 983 if (hw->phy_type == SK_PHY_BCOM)
984 xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff);
969 985
970 xm_outhash(hw, port, XM_HSM, zero); 986 xm_outhash(hw, port, XM_HSM, zero);
971} 987}
@@ -1000,60 +1016,64 @@ static void bcom_check_link(struct skge_hw *hw, int port)
1000 1016
1001 if (netif_carrier_ok(dev)) 1017 if (netif_carrier_ok(dev))
1002 skge_link_down(skge); 1018 skge_link_down(skge);
1003 } else { 1019 return;
1004 if (skge->autoneg == AUTONEG_ENABLE && 1020 }
1005 (status & PHY_ST_AN_OVER)) {
1006 u16 lpa = xm_phy_read(hw, port, PHY_BCOM_AUNE_LP);
1007 u16 aux = xm_phy_read(hw, port, PHY_BCOM_AUX_STAT);
1008
1009 if (lpa & PHY_B_AN_RF) {
1010 printk(KERN_NOTICE PFX "%s: remote fault\n",
1011 dev->name);
1012 return;
1013 }
1014 1021
1015 /* Check Duplex mismatch */ 1022 if (skge->autoneg == AUTONEG_ENABLE) {
1016 switch (aux & PHY_B_AS_AN_RES_MSK) { 1023 u16 lpa, aux;
1017 case PHY_B_RES_1000FD:
1018 skge->duplex = DUPLEX_FULL;
1019 break;
1020 case PHY_B_RES_1000HD:
1021 skge->duplex = DUPLEX_HALF;
1022 break;
1023 default:
1024 printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
1025 dev->name);
1026 return;
1027 }
1028 1024
1025 if (!(status & PHY_ST_AN_OVER))
1026 return;
1029 1027
1030 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 1028 lpa = xm_phy_read(hw, port, PHY_XMAC_AUNE_LP);
1031 switch (aux & PHY_B_AS_PAUSE_MSK) { 1029 if (lpa & PHY_B_AN_RF) {
1032 case PHY_B_AS_PAUSE_MSK: 1030 printk(KERN_NOTICE PFX "%s: remote fault\n",
1033 skge->flow_control = FLOW_MODE_SYMMETRIC; 1031 dev->name);
1034 break; 1032 return;
1035 case PHY_B_AS_PRR: 1033 }
1036 skge->flow_control = FLOW_MODE_REM_SEND;
1037 break;
1038 case PHY_B_AS_PRT:
1039 skge->flow_control = FLOW_MODE_LOC_SEND;
1040 break;
1041 default:
1042 skge->flow_control = FLOW_MODE_NONE;
1043 }
1044 1034
1045 skge->speed = SPEED_1000; 1035 aux = xm_phy_read(hw, port, PHY_BCOM_AUX_STAT);
1036
1037 /* Check Duplex mismatch */
1038 switch (aux & PHY_B_AS_AN_RES_MSK) {
1039 case PHY_B_RES_1000FD:
1040 skge->duplex = DUPLEX_FULL;
1041 break;
1042 case PHY_B_RES_1000HD:
1043 skge->duplex = DUPLEX_HALF;
1044 break;
1045 default:
1046 printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
1047 dev->name);
1048 return;
1046 } 1049 }
1047 1050
1048 if (!netif_carrier_ok(dev)) 1051
1049 genesis_link_up(skge); 1052 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1053 switch (aux & PHY_B_AS_PAUSE_MSK) {
1054 case PHY_B_AS_PAUSE_MSK:
1055 skge->flow_control = FLOW_MODE_SYMMETRIC;
1056 break;
1057 case PHY_B_AS_PRR:
1058 skge->flow_control = FLOW_MODE_REM_SEND;
1059 break;
1060 case PHY_B_AS_PRT:
1061 skge->flow_control = FLOW_MODE_LOC_SEND;
1062 break;
1063 default:
1064 skge->flow_control = FLOW_MODE_NONE;
1065 }
1066 skge->speed = SPEED_1000;
1050 } 1067 }
1068
1069 if (!netif_carrier_ok(dev))
1070 genesis_link_up(skge);
1051} 1071}
1052 1072
1053/* Broadcom 5400 only supports giagabit! SysKonnect did not put an additional 1073/* Broadcom 5400 only supports giagabit! SysKonnect did not put an additional
1054 * Phy on for 100 or 10Mbit operation 1074 * Phy on for 100 or 10Mbit operation
1055 */ 1075 */
1056static void bcom_phy_init(struct skge_port *skge, int jumbo) 1076static void bcom_phy_init(struct skge_port *skge)
1057{ 1077{
1058 struct skge_hw *hw = skge->hw; 1078 struct skge_hw *hw = skge->hw;
1059 int port = skge->port; 1079 int port = skge->port;
@@ -1144,7 +1164,7 @@ static void bcom_phy_init(struct skge_port *skge, int jumbo)
1144 phy_pause_map[skge->flow_control] | PHY_AN_CSMA); 1164 phy_pause_map[skge->flow_control] | PHY_AN_CSMA);
1145 1165
1146 /* Handle Jumbo frames */ 1166 /* Handle Jumbo frames */
1147 if (jumbo) { 1167 if (hw->dev[port]->mtu > ETH_DATA_LEN) {
1148 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL, 1168 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
1149 PHY_B_AC_TX_TST | PHY_B_AC_LONG_PACK); 1169 PHY_B_AC_TX_TST | PHY_B_AC_LONG_PACK);
1150 1170
@@ -1157,8 +1177,154 @@ static void bcom_phy_init(struct skge_port *skge, int jumbo)
1157 1177
1158 /* Use link status change interrupt */ 1178 /* Use link status change interrupt */
1159 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK); 1179 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
1180}
1160 1181
1161 bcom_check_link(hw, port); 1182static void xm_phy_init(struct skge_port *skge)
1183{
1184 struct skge_hw *hw = skge->hw;
1185 int port = skge->port;
1186 u16 ctrl = 0;
1187
1188 if (skge->autoneg == AUTONEG_ENABLE) {
1189 if (skge->advertising & ADVERTISED_1000baseT_Half)
1190 ctrl |= PHY_X_AN_HD;
1191 if (skge->advertising & ADVERTISED_1000baseT_Full)
1192 ctrl |= PHY_X_AN_FD;
1193
1194 switch(skge->flow_control) {
1195 case FLOW_MODE_NONE:
1196 ctrl |= PHY_X_P_NO_PAUSE;
1197 break;
1198 case FLOW_MODE_LOC_SEND:
1199 ctrl |= PHY_X_P_ASYM_MD;
1200 break;
1201 case FLOW_MODE_SYMMETRIC:
1202 ctrl |= PHY_X_P_BOTH_MD;
1203 break;
1204 }
1205
1206 xm_phy_write(hw, port, PHY_XMAC_AUNE_ADV, ctrl);
1207
1208 /* Restart Auto-negotiation */
1209 ctrl = PHY_CT_ANE | PHY_CT_RE_CFG;
1210 } else {
1211 /* Set DuplexMode in Config register */
1212 if (skge->duplex == DUPLEX_FULL)
1213 ctrl |= PHY_CT_DUP_MD;
1214 /*
1215 * Do NOT enable Auto-negotiation here. This would hold
1216 * the link down because no IDLEs are transmitted
1217 */
1218 }
1219
1220 xm_phy_write(hw, port, PHY_XMAC_CTRL, ctrl);
1221
1222 /* Poll PHY for status changes */
1223 schedule_delayed_work(&skge->link_thread, LINK_HZ);
1224}
1225
1226static void xm_check_link(struct net_device *dev)
1227{
1228 struct skge_port *skge = netdev_priv(dev);
1229 struct skge_hw *hw = skge->hw;
1230 int port = skge->port;
1231 u16 status;
1232
1233 /* read twice because of latch */
1234 (void) xm_phy_read(hw, port, PHY_XMAC_STAT);
1235 status = xm_phy_read(hw, port, PHY_XMAC_STAT);
1236
1237 if ((status & PHY_ST_LSYNC) == 0) {
1238 u16 cmd = xm_read16(hw, port, XM_MMU_CMD);
1239 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1240 xm_write16(hw, port, XM_MMU_CMD, cmd);
1241 /* dummy read to ensure writing */
1242 (void) xm_read16(hw, port, XM_MMU_CMD);
1243
1244 if (netif_carrier_ok(dev))
1245 skge_link_down(skge);
1246 return;
1247 }
1248
1249 if (skge->autoneg == AUTONEG_ENABLE) {
1250 u16 lpa, res;
1251
1252 if (!(status & PHY_ST_AN_OVER))
1253 return;
1254
1255 lpa = xm_phy_read(hw, port, PHY_XMAC_AUNE_LP);
1256 if (lpa & PHY_B_AN_RF) {
1257 printk(KERN_NOTICE PFX "%s: remote fault\n",
1258 dev->name);
1259 return;
1260 }
1261
1262 res = xm_phy_read(hw, port, PHY_XMAC_RES_ABI);
1263
1264 /* Check Duplex mismatch */
1265 switch (res & (PHY_X_RS_HD | PHY_X_RS_FD)) {
1266 case PHY_X_RS_FD:
1267 skge->duplex = DUPLEX_FULL;
1268 break;
1269 case PHY_X_RS_HD:
1270 skge->duplex = DUPLEX_HALF;
1271 break;
1272 default:
1273 printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
1274 dev->name);
1275 return;
1276 }
1277
1278 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1279 if (lpa & PHY_X_P_SYM_MD)
1280 skge->flow_control = FLOW_MODE_SYMMETRIC;
1281 else if ((lpa & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD)
1282 skge->flow_control = FLOW_MODE_REM_SEND;
1283 else if ((lpa & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD)
1284 skge->flow_control = FLOW_MODE_LOC_SEND;
1285 else
1286 skge->flow_control = FLOW_MODE_NONE;
1287
1288
1289 skge->speed = SPEED_1000;
1290 }
1291
1292 if (!netif_carrier_ok(dev))
1293 genesis_link_up(skge);
1294}
1295
1296/* Poll to check for link coming up.
1297 * Since internal PHY is wired to a level triggered pin, can't
1298 * get an interrupt when carrier is detected.
1299 */
1300static void xm_link_timer(void *arg)
1301{
1302 struct net_device *dev = arg;
1303 struct skge_port *skge = netdev_priv(arg);
1304 struct skge_hw *hw = skge->hw;
1305 int port = skge->port;
1306
1307 if (!netif_running(dev))
1308 return;
1309
1310 if (netif_carrier_ok(dev)) {
1311 xm_read16(hw, port, XM_ISRC);
1312 if (!(xm_read16(hw, port, XM_ISRC) & XM_IS_INP_ASS))
1313 goto nochange;
1314 } else {
1315 if (xm_read32(hw, port, XM_GP_PORT) & XM_GP_INP_ASS)
1316 goto nochange;
1317 xm_read16(hw, port, XM_ISRC);
1318 if (xm_read16(hw, port, XM_ISRC) & XM_IS_INP_ASS)
1319 goto nochange;
1320 }
1321
1322 mutex_lock(&hw->phy_mutex);
1323 xm_check_link(dev);
1324 mutex_unlock(&hw->phy_mutex);
1325
1326nochange:
1327 schedule_delayed_work(&skge->link_thread, LINK_HZ);
1162} 1328}
1163 1329
1164static void genesis_mac_init(struct skge_hw *hw, int port) 1330static void genesis_mac_init(struct skge_hw *hw, int port)
@@ -1189,20 +1355,29 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1189 * namely for the 1000baseTX cards that use the XMAC's 1355 * namely for the 1000baseTX cards that use the XMAC's
1190 * GMII mode. 1356 * GMII mode.
1191 */ 1357 */
1192 /* Take external Phy out of reset */ 1358 if (hw->phy_type != SK_PHY_XMAC) {
1193 r = skge_read32(hw, B2_GP_IO); 1359 /* Take external Phy out of reset */
1194 if (port == 0) 1360 r = skge_read32(hw, B2_GP_IO);
1195 r |= GP_DIR_0|GP_IO_0; 1361 if (port == 0)
1196 else 1362 r |= GP_DIR_0|GP_IO_0;
1197 r |= GP_DIR_2|GP_IO_2; 1363 else
1364 r |= GP_DIR_2|GP_IO_2;
1198 1365
1199 skge_write32(hw, B2_GP_IO, r); 1366 skge_write32(hw, B2_GP_IO, r);
1200 1367
1368 /* Enable GMII interface */
1369 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
1370 }
1201 1371
1202 /* Enable GMII interface */
1203 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
1204 1372
1205 bcom_phy_init(skge, jumbo); 1373 switch(hw->phy_type) {
1374 case SK_PHY_XMAC:
1375 xm_phy_init(skge);
1376 break;
1377 case SK_PHY_BCOM:
1378 bcom_phy_init(skge);
1379 bcom_check_link(hw, port);
1380 }
1206 1381
1207 /* Set Station Address */ 1382 /* Set Station Address */
1208 xm_outaddr(hw, port, XM_SA, dev->dev_addr); 1383 xm_outaddr(hw, port, XM_SA, dev->dev_addr);
@@ -1335,16 +1510,18 @@ static void genesis_stop(struct skge_port *skge)
1335 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST); 1510 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST);
1336 1511
1337 /* For external PHYs there must be special handling */ 1512 /* For external PHYs there must be special handling */
1338 reg = skge_read32(hw, B2_GP_IO); 1513 if (hw->phy_type != SK_PHY_XMAC) {
1339 if (port == 0) { 1514 reg = skge_read32(hw, B2_GP_IO);
1340 reg |= GP_DIR_0; 1515 if (port == 0) {
1341 reg &= ~GP_IO_0; 1516 reg |= GP_DIR_0;
1342 } else { 1517 reg &= ~GP_IO_0;
1343 reg |= GP_DIR_2; 1518 } else {
1344 reg &= ~GP_IO_2; 1519 reg |= GP_DIR_2;
1520 reg &= ~GP_IO_2;
1521 }
1522 skge_write32(hw, B2_GP_IO, reg);
1523 skge_read32(hw, B2_GP_IO);
1345 } 1524 }
1346 skge_write32(hw, B2_GP_IO, reg);
1347 skge_read32(hw, B2_GP_IO);
1348 1525
1349 xm_write16(hw, port, XM_MMU_CMD, 1526 xm_write16(hw, port, XM_MMU_CMD,
1350 xm_read16(hw, port, XM_MMU_CMD) 1527 xm_read16(hw, port, XM_MMU_CMD)
@@ -1406,7 +1583,7 @@ static void genesis_link_up(struct skge_port *skge)
1406 struct skge_hw *hw = skge->hw; 1583 struct skge_hw *hw = skge->hw;
1407 int port = skge->port; 1584 int port = skge->port;
1408 u16 cmd; 1585 u16 cmd;
1409 u32 mode, msk; 1586 u32 mode;
1410 1587
1411 cmd = xm_read16(hw, port, XM_MMU_CMD); 1588 cmd = xm_read16(hw, port, XM_MMU_CMD);
1412 1589
@@ -1454,27 +1631,24 @@ static void genesis_link_up(struct skge_port *skge)
1454 } 1631 }
1455 1632
1456 xm_write32(hw, port, XM_MODE, mode); 1633 xm_write32(hw, port, XM_MODE, mode);
1457 1634 xm_write16(hw, port, XM_IMSK, XM_DEF_MSK);
1458 msk = XM_DEF_MSK;
1459 /* disable GP0 interrupt bit for external Phy */
1460 msk |= XM_IS_INP_ASS;
1461
1462 xm_write16(hw, port, XM_IMSK, msk);
1463 xm_read16(hw, port, XM_ISRC); 1635 xm_read16(hw, port, XM_ISRC);
1464 1636
1465 /* get MMU Command Reg. */ 1637 /* get MMU Command Reg. */
1466 cmd = xm_read16(hw, port, XM_MMU_CMD); 1638 cmd = xm_read16(hw, port, XM_MMU_CMD);
1467 if (skge->duplex == DUPLEX_FULL) 1639 if (hw->phy_type != SK_PHY_XMAC && skge->duplex == DUPLEX_FULL)
1468 cmd |= XM_MMU_GMII_FD; 1640 cmd |= XM_MMU_GMII_FD;
1469 1641
1470 /* 1642 /*
1471 * Workaround BCOM Errata (#10523) for all BCom Phys 1643 * Workaround BCOM Errata (#10523) for all BCom Phys
1472 * Enable Power Management after link up 1644 * Enable Power Management after link up
1473 */ 1645 */
1474 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL, 1646 if (hw->phy_type == SK_PHY_BCOM) {
1475 xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL) 1647 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
1476 & ~PHY_B_AC_DIS_PM); 1648 xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL)
1477 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK); 1649 & ~PHY_B_AC_DIS_PM);
1650 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
1651 }
1478 1652
1479 /* enable Rx/Tx */ 1653 /* enable Rx/Tx */
1480 xm_write16(hw, port, XM_MMU_CMD, 1654 xm_write16(hw, port, XM_MMU_CMD,
@@ -2240,6 +2414,8 @@ static int skge_down(struct net_device *dev)
2240 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); 2414 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
2241 2415
2242 netif_stop_queue(dev); 2416 netif_stop_queue(dev);
2417 if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC)
2418 cancel_rearming_delayed_work(&skge->link_thread);
2243 2419
2244 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF); 2420 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
2245 if (hw->chip_id == CHIP_ID_GENESIS) 2421 if (hw->chip_id == CHIP_ID_GENESIS)
@@ -2862,7 +3038,7 @@ static void skge_extirq(void *arg)
2862 if (netif_running(dev)) { 3038 if (netif_running(dev)) {
2863 if (hw->chip_id != CHIP_ID_GENESIS) 3039 if (hw->chip_id != CHIP_ID_GENESIS)
2864 yukon_phy_intr(skge); 3040 yukon_phy_intr(skge);
2865 else 3041 else if (hw->phy_type == SK_PHY_BCOM)
2866 bcom_phy_intr(skge); 3042 bcom_phy_intr(skge);
2867 } 3043 }
2868 } 3044 }
@@ -3014,7 +3190,7 @@ static int skge_reset(struct skge_hw *hw)
3014{ 3190{
3015 u32 reg; 3191 u32 reg;
3016 u16 ctst, pci_status; 3192 u16 ctst, pci_status;
3017 u8 t8, mac_cfg, pmd_type, phy_type; 3193 u8 t8, mac_cfg, pmd_type;
3018 int i; 3194 int i;
3019 3195
3020 ctst = skge_read16(hw, B0_CTST); 3196 ctst = skge_read16(hw, B0_CTST);
@@ -3038,19 +3214,22 @@ static int skge_reset(struct skge_hw *hw)
3038 ctst & (CS_CLK_RUN_HOT|CS_CLK_RUN_RST|CS_CLK_RUN_ENA)); 3214 ctst & (CS_CLK_RUN_HOT|CS_CLK_RUN_RST|CS_CLK_RUN_ENA));
3039 3215
3040 hw->chip_id = skge_read8(hw, B2_CHIP_ID); 3216 hw->chip_id = skge_read8(hw, B2_CHIP_ID);
3041 phy_type = skge_read8(hw, B2_E_1) & 0xf; 3217 hw->phy_type = skge_read8(hw, B2_E_1) & 0xf;
3042 pmd_type = skge_read8(hw, B2_PMD_TYP); 3218 pmd_type = skge_read8(hw, B2_PMD_TYP);
3043 hw->copper = (pmd_type == 'T' || pmd_type == '1'); 3219 hw->copper = (pmd_type == 'T' || pmd_type == '1');
3044 3220
3045 switch (hw->chip_id) { 3221 switch (hw->chip_id) {
3046 case CHIP_ID_GENESIS: 3222 case CHIP_ID_GENESIS:
3047 switch (phy_type) { 3223 switch (hw->phy_type) {
3224 case SK_PHY_XMAC:
3225 hw->phy_addr = PHY_ADDR_XMAC;
3226 break;
3048 case SK_PHY_BCOM: 3227 case SK_PHY_BCOM:
3049 hw->phy_addr = PHY_ADDR_BCOM; 3228 hw->phy_addr = PHY_ADDR_BCOM;
3050 break; 3229 break;
3051 default: 3230 default:
3052 printk(KERN_ERR PFX "%s: unsupported phy type 0x%x\n", 3231 printk(KERN_ERR PFX "%s: unsupported phy type 0x%x\n",
3053 pci_name(hw->pdev), phy_type); 3232 pci_name(hw->pdev), hw->phy_type);
3054 return -EOPNOTSUPP; 3233 return -EOPNOTSUPP;
3055 } 3234 }
3056 break; 3235 break;
@@ -3058,7 +3237,7 @@ static int skge_reset(struct skge_hw *hw)
3058 case CHIP_ID_YUKON: 3237 case CHIP_ID_YUKON:
3059 case CHIP_ID_YUKON_LITE: 3238 case CHIP_ID_YUKON_LITE:
3060 case CHIP_ID_YUKON_LP: 3239 case CHIP_ID_YUKON_LP:
3061 if (phy_type < SK_PHY_MARV_COPPER && pmd_type != 'S') 3240 if (hw->phy_type < SK_PHY_MARV_COPPER && pmd_type != 'S')
3062 hw->copper = 1; 3241 hw->copper = 1;
3063 3242
3064 hw->phy_addr = PHY_ADDR_MARV; 3243 hw->phy_addr = PHY_ADDR_MARV;
@@ -3089,10 +3268,13 @@ static int skge_reset(struct skge_hw *hw)
3089 else 3268 else
3090 hw->ram_size = t8 * 4096; 3269 hw->ram_size = t8 * 4096;
3091 3270
3092 hw->intr_mask = IS_HW_ERR | IS_EXT_REG | IS_PORT_1; 3271 hw->intr_mask = IS_HW_ERR | IS_PORT_1;
3093 if (hw->ports > 1) 3272 if (hw->ports > 1)
3094 hw->intr_mask |= IS_PORT_2; 3273 hw->intr_mask |= IS_PORT_2;
3095 3274
3275 if (!(hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC))
3276 hw->intr_mask |= IS_EXT_REG;
3277
3096 if (hw->chip_id == CHIP_ID_GENESIS) 3278 if (hw->chip_id == CHIP_ID_GENESIS)
3097 genesis_init(hw); 3279 genesis_init(hw);
3098 else { 3280 else {
@@ -3226,6 +3408,9 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3226 3408
3227 skge->port = port; 3409 skge->port = port;
3228 3410
3411 /* Only used for Genesis XMAC */
3412 INIT_WORK(&skge->link_thread, xm_link_timer, dev);
3413
3229 if (hw->chip_id != CHIP_ID_GENESIS) { 3414 if (hw->chip_id != CHIP_ID_GENESIS) {
3230 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 3415 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
3231 skge->rx_csum = 1; 3416 skge->rx_csum = 1;
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 79e09271bcf9..d0b47d46cf9d 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -934,7 +934,7 @@ enum {
934 PHY_XMAC_AUNE_ADV = 0x04,/* 16 bit r/w Auto-Neg. Advertisement */ 934 PHY_XMAC_AUNE_ADV = 0x04,/* 16 bit r/w Auto-Neg. Advertisement */
935 PHY_XMAC_AUNE_LP = 0x05,/* 16 bit r/o Link Partner Abi Reg */ 935 PHY_XMAC_AUNE_LP = 0x05,/* 16 bit r/o Link Partner Abi Reg */
936 PHY_XMAC_AUNE_EXP = 0x06,/* 16 bit r/o Auto-Neg. Expansion Reg */ 936 PHY_XMAC_AUNE_EXP = 0x06,/* 16 bit r/o Auto-Neg. Expansion Reg */
937 PHY_XMAC_NEPG = 0x07,/* 16 bit r/w Next Page Register */ 937 PHY_XMAC_NEPG = 0x07,/* 16 bit r/w Next Page Register */
938 PHY_XMAC_NEPG_LP = 0x08,/* 16 bit r/o Next Page Link Partner */ 938 PHY_XMAC_NEPG_LP = 0x08,/* 16 bit r/o Next Page Link Partner */
939 939
940 PHY_XMAC_EXT_STAT = 0x0f,/* 16 bit r/o Ext Status Register */ 940 PHY_XMAC_EXT_STAT = 0x0f,/* 16 bit r/o Ext Status Register */
@@ -1097,13 +1097,36 @@ enum {
1097 1097
1098/* Pause Bits (PHY_X_AN_PAUSE and PHY_X_RS_PAUSE) encoding */ 1098/* Pause Bits (PHY_X_AN_PAUSE and PHY_X_RS_PAUSE) encoding */
1099enum { 1099enum {
1100 PHY_X_P_NO_PAUSE = 0<<7,/* Bit 8..7: no Pause Mode */ 1100 PHY_X_P_NO_PAUSE= 0<<7,/* Bit 8..7: no Pause Mode */
1101 PHY_X_P_SYM_MD = 1<<7, /* Bit 8..7: symmetric Pause Mode */ 1101 PHY_X_P_SYM_MD = 1<<7, /* Bit 8..7: symmetric Pause Mode */
1102 PHY_X_P_ASYM_MD = 2<<7,/* Bit 8..7: asymmetric Pause Mode */ 1102 PHY_X_P_ASYM_MD = 2<<7,/* Bit 8..7: asymmetric Pause Mode */
1103 PHY_X_P_BOTH_MD = 3<<7,/* Bit 8..7: both Pause Mode */ 1103 PHY_X_P_BOTH_MD = 3<<7,/* Bit 8..7: both Pause Mode */
1104}; 1104};
1105 1105
1106 1106
1107/***** PHY_XMAC_EXT_STAT 16 bit r/w Extended Status Register *****/
1108enum {
1109 PHY_X_EX_FD = 1<<15, /* Bit 15: Device Supports Full Duplex */
1110 PHY_X_EX_HD = 1<<14, /* Bit 14: Device Supports Half Duplex */
1111};
1112
1113/***** PHY_XMAC_RES_ABI 16 bit r/o PHY Resolved Ability *****/
1114enum {
1115 PHY_X_RS_PAUSE = 3<<7, /* Bit 8..7: selected Pause Mode */
1116 PHY_X_RS_HD = 1<<6, /* Bit 6: Half Duplex Mode selected */
1117 PHY_X_RS_FD = 1<<5, /* Bit 5: Full Duplex Mode selected */
1118 PHY_X_RS_ABLMIS = 1<<4, /* Bit 4: duplex or pause cap mismatch */
1119 PHY_X_RS_PAUMIS = 1<<3, /* Bit 3: pause capability mismatch */
1120};
1121
1122/* Remote Fault Bits (PHY_X_AN_RFB) encoding */
1123enum {
1124 X_RFB_OK = 0<<12,/* Bit 13..12 No errors, Link OK */
1125 X_RFB_LF = 1<<12,/* Bit 13..12 Link Failure */
1126 X_RFB_OFF = 2<<12,/* Bit 13..12 Offline */
1127 X_RFB_AN_ERR = 3<<12,/* Bit 13..12 Auto-Negotiation Error */
1128};
1129
1107/* Broadcom-Specific */ 1130/* Broadcom-Specific */
1108/***** PHY_BCOM_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/ 1131/***** PHY_BCOM_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/
1109enum { 1132enum {
@@ -2158,8 +2181,8 @@ enum {
2158 XM_IS_LNK_AE = 1<<14, /* Bit 14: Link Asynchronous Event */ 2181 XM_IS_LNK_AE = 1<<14, /* Bit 14: Link Asynchronous Event */
2159 XM_IS_TX_ABORT = 1<<13, /* Bit 13: Transmit Abort, late Col. etc */ 2182 XM_IS_TX_ABORT = 1<<13, /* Bit 13: Transmit Abort, late Col. etc */
2160 XM_IS_FRC_INT = 1<<12, /* Bit 12: Force INT bit set in GP */ 2183 XM_IS_FRC_INT = 1<<12, /* Bit 12: Force INT bit set in GP */
2161 XM_IS_INP_ASS = 1<<11, /* Bit 11: Input Asserted, GP bit 0 set */ 2184 XM_IS_INP_ASS = 1<<11, /* Bit 11: Input Asserted, GP bit 0 set */
2162 XM_IS_LIPA_RC = 1<<10, /* Bit 10: Link Partner requests config */ 2185 XM_IS_LIPA_RC = 1<<10, /* Bit 10: Link Partner requests config */
2163 XM_IS_RX_PAGE = 1<<9, /* Bit 9: Page Received */ 2186 XM_IS_RX_PAGE = 1<<9, /* Bit 9: Page Received */
2164 XM_IS_TX_PAGE = 1<<8, /* Bit 8: Next Page Loaded for Transmit */ 2187 XM_IS_TX_PAGE = 1<<8, /* Bit 8: Next Page Loaded for Transmit */
2165 XM_IS_AND = 1<<7, /* Bit 7: Auto-Negotiation Done */ 2188 XM_IS_AND = 1<<7, /* Bit 7: Auto-Negotiation Done */
@@ -2172,9 +2195,7 @@ enum {
2172 XM_IS_RX_COMP = 1<<0, /* Bit 0: Frame Rx Complete */ 2195 XM_IS_RX_COMP = 1<<0, /* Bit 0: Frame Rx Complete */
2173}; 2196};
2174 2197
2175#define XM_DEF_MSK (~(XM_IS_INP_ASS | XM_IS_LIPA_RC | XM_IS_RX_PAGE | \ 2198#define XM_DEF_MSK (~(XM_IS_RXC_OV | XM_IS_TXC_OV | XM_IS_RXF_OV | XM_IS_TXF_UR))
2176 XM_IS_AND | XM_IS_RXC_OV | XM_IS_TXC_OV | \
2177 XM_IS_RXF_OV | XM_IS_TXF_UR))
2178 2199
2179 2200
2180/* XM_HW_CFG 16 bit r/w Hardware Config Register */ 2201/* XM_HW_CFG 16 bit r/w Hardware Config Register */
@@ -2396,6 +2417,7 @@ struct skge_hw {
2396 u8 chip_rev; 2417 u8 chip_rev;
2397 u8 copper; 2418 u8 copper;
2398 u8 ports; 2419 u8 ports;
2420 u8 phy_type;
2399 2421
2400 u32 ram_size; 2422 u32 ram_size;
2401 u32 ram_offset; 2423 u32 ram_offset;
@@ -2422,6 +2444,7 @@ struct skge_port {
2422 2444
2423 struct net_device_stats net_stats; 2445 struct net_device_stats net_stats;
2424 2446
2447 struct work_struct link_thread;
2425 u8 rx_csum; 2448 u8 rx_csum;
2426 u8 blink_on; 2449 u8 blink_on;
2427 u8 flow_control; 2450 u8 flow_control;
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 7aa7fbac8224..c660e33f43a2 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -379,6 +379,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
379 379
380#define SMC_IRQ_FLAGS (0) 380#define SMC_IRQ_FLAGS (0)
381 381
382#elif defined(CONFIG_ARCH_VERSATILE)
383
384#define SMC_CAN_USE_8BIT 1
385#define SMC_CAN_USE_16BIT 1
386#define SMC_CAN_USE_32BIT 1
387#define SMC_NOWAIT 1
388
389#define SMC_inb(a, r) readb((a) + (r))
390#define SMC_inw(a, r) readw((a) + (r))
391#define SMC_inl(a, r) readl((a) + (r))
392#define SMC_outb(v, a, r) writeb(v, (a) + (r))
393#define SMC_outw(v, a, r) writew(v, (a) + (r))
394#define SMC_outl(v, a, r) writel(v, (a) + (r))
395#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
396#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
397
398#define SMC_IRQ_FLAGS (0)
399
382#else 400#else
383 401
384#define SMC_CAN_USE_8BIT 1 402#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 0d66700c6ced..bfc8c3eae9a1 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -1876,7 +1876,6 @@ static int sprintf_info(char *buffer, struct net_device *dev)
1876 datap[size+1]=io_word & 0xff; 1876 datap[size+1]=io_word & 0xff;
1877 } 1877 }
1878 1878
1879
1880 size = sprintf(buffer, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev->name); 1879 size = sprintf(buffer, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev->name);
1881 1880
1882 size += sprintf(buffer + size, 1881 size += sprintf(buffer + size,
@@ -1932,64 +1931,6 @@ static int sprintf_info(char *buffer, struct net_device *dev)
1932#endif 1931#endif
1933#endif 1932#endif
1934 1933
1935#if STREAMER_IOCTL && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1936static int streamer_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1937{
1938 int i;
1939 struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
1940 u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1941
1942 switch(cmd) {
1943 case IOCTL_SISR_MASK:
1944 writew(SISR_MI, streamer_mmio + SISR_MASK_SUM);
1945 break;
1946 case IOCTL_SPIN_LOCK_TEST:
1947 printk(KERN_INFO "spin_lock() called.\n");
1948 spin_lock(&streamer_priv->streamer_lock);
1949 spin_unlock(&streamer_priv->streamer_lock);
1950 printk(KERN_INFO "spin_unlock() finished.\n");
1951 break;
1952 case IOCTL_PRINT_BDAS:
1953 printk(KERN_INFO "bdas: RXBDA: %x RXLBDA: %x TX2FDA: %x TX2LFDA: %x\n",
1954 readw(streamer_mmio + RXBDA),
1955 readw(streamer_mmio + RXLBDA),
1956 readw(streamer_mmio + TX2FDA),
1957 readw(streamer_mmio + TX2LFDA));
1958 break;
1959 case IOCTL_PRINT_REGISTERS:
1960 printk(KERN_INFO "registers:\n");
1961 printk(KERN_INFO "SISR: %04x MISR: %04x LISR: %04x BCTL: %04x BMCTL: %04x\nmask %04x mask %04x\n",
1962 readw(streamer_mmio + SISR),
1963 readw(streamer_mmio + MISR_RUM),
1964 readw(streamer_mmio + LISR),
1965 readw(streamer_mmio + BCTL),
1966 readw(streamer_mmio + BMCTL_SUM),
1967 readw(streamer_mmio + SISR_MASK),
1968 readw(streamer_mmio + MISR_MASK));
1969 break;
1970 case IOCTL_PRINT_RX_BUFS:
1971 printk(KERN_INFO "Print rx bufs:\n");
1972 for(i=0; i<STREAMER_RX_RING_SIZE; i++)
1973 printk(KERN_INFO "rx_ring %d status: 0x%x\n", i,
1974 streamer_priv->streamer_rx_ring[i].status);
1975 break;
1976 case IOCTL_PRINT_TX_BUFS:
1977 printk(KERN_INFO "Print tx bufs:\n");
1978 for(i=0; i<STREAMER_TX_RING_SIZE; i++)
1979 printk(KERN_INFO "tx_ring %d status: 0x%x\n", i,
1980 streamer_priv->streamer_tx_ring[i].status);
1981 break;
1982 case IOCTL_RX_CMD:
1983 streamer_rx(dev);
1984 printk(KERN_INFO "Sent rx command.\n");
1985 break;
1986 default:
1987 printk(KERN_INFO "Bad ioctl!\n");
1988 }
1989 return 0;
1990}
1991#endif
1992
1993static struct pci_driver streamer_pci_driver = { 1934static struct pci_driver streamer_pci_driver = {
1994 .name = "lanstreamer", 1935 .name = "lanstreamer",
1995 .id_table = streamer_pci_tbl, 1936 .id_table = streamer_pci_tbl,
diff --git a/drivers/net/tokenring/lanstreamer.h b/drivers/net/tokenring/lanstreamer.h
index 5557d8e1e22d..e7bb3494afc7 100644
--- a/drivers/net/tokenring/lanstreamer.h
+++ b/drivers/net/tokenring/lanstreamer.h
@@ -62,18 +62,6 @@
62 62
63#include <linux/version.h> 63#include <linux/version.h>
64 64
65#if STREAMER_IOCTL && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
66#include <asm/ioctl.h>
67#define IOCTL_PRINT_RX_BUFS SIOCDEVPRIVATE
68#define IOCTL_PRINT_TX_BUFS SIOCDEVPRIVATE+1
69#define IOCTL_RX_CMD SIOCDEVPRIVATE+2
70#define IOCTL_TX_CMD SIOCDEVPRIVATE+3
71#define IOCTL_PRINT_REGISTERS SIOCDEVPRIVATE+4
72#define IOCTL_PRINT_BDAS SIOCDEVPRIVATE+5
73#define IOCTL_SPIN_LOCK_TEST SIOCDEVPRIVATE+6
74#define IOCTL_SISR_MASK SIOCDEVPRIVATE+7
75#endif
76
77/* MAX_INTR - the maximum number of times we can loop 65/* MAX_INTR - the maximum number of times we can loop
78 * inside the interrupt function before returning 66 * inside the interrupt function before returning
79 * control to the OS (maximum value is 256) 67 * control to the OS (maximum value is 256)
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 8f6f6fd8b87d..d5c32e9caa97 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -333,11 +333,7 @@ enum state_values {
333#define TYPHOON_RESET_TIMEOUT_NOSLEEP ((6 * 1000000) / TYPHOON_UDELAY) 333#define TYPHOON_RESET_TIMEOUT_NOSLEEP ((6 * 1000000) / TYPHOON_UDELAY)
334#define TYPHOON_WAIT_TIMEOUT ((1000000 / 2) / TYPHOON_UDELAY) 334#define TYPHOON_WAIT_TIMEOUT ((1000000 / 2) / TYPHOON_UDELAY)
335 335
336#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 28)
337#define typhoon_synchronize_irq(x) synchronize_irq()
338#else
339#define typhoon_synchronize_irq(x) synchronize_irq(x) 336#define typhoon_synchronize_irq(x) synchronize_irq(x)
340#endif
341 337
342#if defined(NETIF_F_TSO) 338#if defined(NETIF_F_TSO)
343#define skb_tso_size(x) (skb_shinfo(x)->gso_size) 339#define skb_tso_size(x) (skb_shinfo(x)->gso_size)
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index bff04cba3fed..ba737c6cebec 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -5868,7 +5868,7 @@ static int airo_set_essid(struct net_device *dev,
5868 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 5868 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
5869 5869
5870 /* Check the size of the string */ 5870 /* Check the size of the string */
5871 if(dwrq->length > IW_ESSID_MAX_SIZE+1) { 5871 if(dwrq->length > IW_ESSID_MAX_SIZE) {
5872 return -E2BIG ; 5872 return -E2BIG ;
5873 } 5873 }
5874 /* Check if index is valid */ 5874 /* Check if index is valid */
@@ -5880,7 +5880,7 @@ static int airo_set_essid(struct net_device *dev,
5880 memset(SSID_rid.ssids[index].ssid, 0, 5880 memset(SSID_rid.ssids[index].ssid, 0,
5881 sizeof(SSID_rid.ssids[index].ssid)); 5881 sizeof(SSID_rid.ssids[index].ssid));
5882 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length); 5882 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length);
5883 SSID_rid.ssids[index].len = dwrq->length - 1; 5883 SSID_rid.ssids[index].len = dwrq->length;
5884 } 5884 }
5885 SSID_rid.len = sizeof(SSID_rid); 5885 SSID_rid.len = sizeof(SSID_rid);
5886 /* Write it to the card */ 5886 /* Write it to the card */
@@ -5990,7 +5990,7 @@ static int airo_set_nick(struct net_device *dev,
5990 struct airo_info *local = dev->priv; 5990 struct airo_info *local = dev->priv;
5991 5991
5992 /* Check the size of the string */ 5992 /* Check the size of the string */
5993 if(dwrq->length > 16 + 1) { 5993 if(dwrq->length > 16) {
5994 return -E2BIG; 5994 return -E2BIG;
5995 } 5995 }
5996 readConfigRid(local, 1); 5996 readConfigRid(local, 1);
@@ -6015,7 +6015,7 @@ static int airo_get_nick(struct net_device *dev,
6015 readConfigRid(local, 1); 6015 readConfigRid(local, 1);
6016 strncpy(extra, local->config.nodeName, 16); 6016 strncpy(extra, local->config.nodeName, 16);
6017 extra[16] = '\0'; 6017 extra[16] = '\0';
6018 dwrq->length = strlen(extra) + 1; 6018 dwrq->length = strlen(extra);
6019 6019
6020 return 0; 6020 return 0;
6021} 6021}
@@ -6767,9 +6767,9 @@ static int airo_set_retry(struct net_device *dev,
6767 } 6767 }
6768 readConfigRid(local, 1); 6768 readConfigRid(local, 1);
6769 if(vwrq->flags & IW_RETRY_LIMIT) { 6769 if(vwrq->flags & IW_RETRY_LIMIT) {
6770 if(vwrq->flags & IW_RETRY_MAX) 6770 if(vwrq->flags & IW_RETRY_LONG)
6771 local->config.longRetryLimit = vwrq->value; 6771 local->config.longRetryLimit = vwrq->value;
6772 else if (vwrq->flags & IW_RETRY_MIN) 6772 else if (vwrq->flags & IW_RETRY_SHORT)
6773 local->config.shortRetryLimit = vwrq->value; 6773 local->config.shortRetryLimit = vwrq->value;
6774 else { 6774 else {
6775 /* No modifier : set both */ 6775 /* No modifier : set both */
@@ -6805,14 +6805,14 @@ static int airo_get_retry(struct net_device *dev,
6805 if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { 6805 if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
6806 vwrq->flags = IW_RETRY_LIFETIME; 6806 vwrq->flags = IW_RETRY_LIFETIME;
6807 vwrq->value = (int)local->config.txLifetime * 1024; 6807 vwrq->value = (int)local->config.txLifetime * 1024;
6808 } else if((vwrq->flags & IW_RETRY_MAX)) { 6808 } else if((vwrq->flags & IW_RETRY_LONG)) {
6809 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 6809 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
6810 vwrq->value = (int)local->config.longRetryLimit; 6810 vwrq->value = (int)local->config.longRetryLimit;
6811 } else { 6811 } else {
6812 vwrq->flags = IW_RETRY_LIMIT; 6812 vwrq->flags = IW_RETRY_LIMIT;
6813 vwrq->value = (int)local->config.shortRetryLimit; 6813 vwrq->value = (int)local->config.shortRetryLimit;
6814 if((int)local->config.shortRetryLimit != (int)local->config.longRetryLimit) 6814 if((int)local->config.shortRetryLimit != (int)local->config.longRetryLimit)
6815 vwrq->flags |= IW_RETRY_MIN; 6815 vwrq->flags |= IW_RETRY_SHORT;
6816 } 6816 }
6817 6817
6818 return 0; 6818 return 0;
@@ -6990,6 +6990,7 @@ static int airo_set_power(struct net_device *dev,
6990 local->config.rmode |= RXMODE_BC_MC_ADDR; 6990 local->config.rmode |= RXMODE_BC_MC_ADDR;
6991 set_bit (FLAG_COMMIT, &local->flags); 6991 set_bit (FLAG_COMMIT, &local->flags);
6992 case IW_POWER_ON: 6992 case IW_POWER_ON:
6993 /* This is broken, fixme ;-) */
6993 break; 6994 break;
6994 default: 6995 default:
6995 return -EINVAL; 6996 return -EINVAL;
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 995c7bea5897..0fc267d626dc 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1656,13 +1656,13 @@ static int atmel_set_essid(struct net_device *dev,
1656 priv->connect_to_any_BSS = 0; 1656 priv->connect_to_any_BSS = 0;
1657 1657
1658 /* Check the size of the string */ 1658 /* Check the size of the string */
1659 if (dwrq->length > MAX_SSID_LENGTH + 1) 1659 if (dwrq->length > MAX_SSID_LENGTH)
1660 return -E2BIG; 1660 return -E2BIG;
1661 if (index != 0) 1661 if (index != 0)
1662 return -EINVAL; 1662 return -EINVAL;
1663 1663
1664 memcpy(priv->new_SSID, extra, dwrq->length - 1); 1664 memcpy(priv->new_SSID, extra, dwrq->length);
1665 priv->new_SSID_size = dwrq->length - 1; 1665 priv->new_SSID_size = dwrq->length;
1666 } 1666 }
1667 1667
1668 return -EINPROGRESS; 1668 return -EINPROGRESS;
@@ -2120,9 +2120,9 @@ static int atmel_set_retry(struct net_device *dev,
2120 struct atmel_private *priv = netdev_priv(dev); 2120 struct atmel_private *priv = netdev_priv(dev);
2121 2121
2122 if (!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) { 2122 if (!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) {
2123 if (vwrq->flags & IW_RETRY_MAX) 2123 if (vwrq->flags & IW_RETRY_LONG)
2124 priv->long_retry = vwrq->value; 2124 priv->long_retry = vwrq->value;
2125 else if (vwrq->flags & IW_RETRY_MIN) 2125 else if (vwrq->flags & IW_RETRY_SHORT)
2126 priv->short_retry = vwrq->value; 2126 priv->short_retry = vwrq->value;
2127 else { 2127 else {
2128 /* No modifier : set both */ 2128 /* No modifier : set both */
@@ -2144,15 +2144,15 @@ static int atmel_get_retry(struct net_device *dev,
2144 2144
2145 vwrq->disabled = 0; /* Can't be disabled */ 2145 vwrq->disabled = 0; /* Can't be disabled */
2146 2146
2147 /* Note : by default, display the min retry number */ 2147 /* Note : by default, display the short retry number */
2148 if (vwrq->flags & IW_RETRY_MAX) { 2148 if (vwrq->flags & IW_RETRY_LONG) {
2149 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 2149 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
2150 vwrq->value = priv->long_retry; 2150 vwrq->value = priv->long_retry;
2151 } else { 2151 } else {
2152 vwrq->flags = IW_RETRY_LIMIT; 2152 vwrq->flags = IW_RETRY_LIMIT;
2153 vwrq->value = priv->short_retry; 2153 vwrq->value = priv->short_retry;
2154 if (priv->long_retry != priv->short_retry) 2154 if (priv->long_retry != priv->short_retry)
2155 vwrq->flags |= IW_RETRY_MIN; 2155 vwrq->flags |= IW_RETRY_SHORT;
2156 } 2156 }
2157 2157
2158 return 0; 2158 return 0;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index 6d4ea36bc564..d6a8bf09878e 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -666,7 +666,6 @@ struct bcm43xx_noise_calculation {
666}; 666};
667 667
668struct bcm43xx_stats { 668struct bcm43xx_stats {
669 u8 link_quality;
670 u8 noise; 669 u8 noise;
671 struct iw_statistics wstats; 670 struct iw_statistics wstats;
672 /* Store the last TX/RX times here for updating the leds. */ 671 /* Store the last TX/RX times here for updating the leds. */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index cb9a3ae8463a..eb65db7393ba 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -2405,9 +2405,10 @@ static int bcm43xx_chip_init(struct bcm43xx_private *bcm)
2405 BCM43xx_UCODE_TIME) & 0x1f); 2405 BCM43xx_UCODE_TIME) & 0x1f);
2406 2406
2407 if ( value16 > 0x128 ) { 2407 if ( value16 > 0x128 ) {
2408 dprintk(KERN_ERR PFX 2408 printk(KERN_ERR PFX
2409 "Firmware: no support for microcode rev > 0x128\n"); 2409 "Firmware: no support for microcode extracted "
2410 err = -1; 2410 "from version 4.x binary drivers.\n");
2411 err = -EOPNOTSUPP;
2411 goto err_release_fw; 2412 goto err_release_fw;
2412 } 2413 }
2413 2414
@@ -3169,8 +3170,7 @@ static void bcm43xx_periodic_work_handler(void *d)
3169 * be preemtible. 3170 * be preemtible.
3170 */ 3171 */
3171 mutex_lock(&bcm->mutex); 3172 mutex_lock(&bcm->mutex);
3172 netif_stop_queue(bcm->net_dev); 3173 netif_tx_disable(bcm->net_dev);
3173 synchronize_net();
3174 spin_lock_irqsave(&bcm->irq_lock, flags); 3174 spin_lock_irqsave(&bcm->irq_lock, flags);
3175 bcm43xx_mac_suspend(bcm); 3175 bcm43xx_mac_suspend(bcm);
3176 if (bcm43xx_using_pio(bcm)) 3176 if (bcm43xx_using_pio(bcm))
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
index eafd0f662686..52ce2a9334fb 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
@@ -361,7 +361,7 @@ static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
361 if (phy->rev <= 2) 361 if (phy->rev <= 2)
362 for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++) 362 for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++)
363 bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg1[i]); 363 bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg1[i]);
364 else if ((phy->rev == 7) && (bcm43xx_phy_read(bcm, 0x0449) & 0x0200)) 364 else if ((phy->rev >= 7) && (bcm43xx_phy_read(bcm, 0x0449) & 0x0200))
365 for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++) 365 for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++)
366 bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg3[i]); 366 bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg3[i]);
367 else 367 else
@@ -371,7 +371,7 @@ static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
371 if (phy->rev == 2) 371 if (phy->rev == 2)
372 for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++) 372 for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++)
373 bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr1[i]); 373 bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr1[i]);
374 else if ((phy->rev > 2) && (phy->rev <= 7)) 374 else if ((phy->rev > 2) && (phy->rev <= 8))
375 for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++) 375 for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++)
376 bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr2[i]); 376 bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr2[i]);
377 377
@@ -1197,7 +1197,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1197 1197
1198 if (phy->rev == 1) 1198 if (phy->rev == 1)
1199 bcm43xx_phy_initb5(bcm); 1199 bcm43xx_phy_initb5(bcm);
1200 else if (phy->rev >= 2 && phy->rev <= 7) 1200 else
1201 bcm43xx_phy_initb6(bcm); 1201 bcm43xx_phy_initb6(bcm);
1202 if (phy->rev >= 2 || phy->connected) 1202 if (phy->rev >= 2 || phy->connected)
1203 bcm43xx_phy_inita(bcm); 1203 bcm43xx_phy_inita(bcm);
@@ -1241,23 +1241,22 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1241 bcm43xx_phy_lo_g_measure(bcm); 1241 bcm43xx_phy_lo_g_measure(bcm);
1242 } else { 1242 } else {
1243 if (radio->version == 0x2050 && radio->revision == 8) { 1243 if (radio->version == 0x2050 && radio->revision == 8) {
1244 //FIXME 1244 bcm43xx_radio_write16(bcm, 0x0052,
1245 (radio->txctl1 << 4) | radio->txctl2);
1245 } else { 1246 } else {
1246 bcm43xx_radio_write16(bcm, 0x0052, 1247 bcm43xx_radio_write16(bcm, 0x0052,
1247 (bcm43xx_radio_read16(bcm, 0x0052) 1248 (bcm43xx_radio_read16(bcm, 0x0052)
1248 & 0xFFF0) | radio->txctl1); 1249 & 0xFFF0) | radio->txctl1);
1249 } 1250 }
1250 if (phy->rev >= 6) { 1251 if (phy->rev >= 6) {
1251 /*
1252 bcm43xx_phy_write(bcm, 0x0036, 1252 bcm43xx_phy_write(bcm, 0x0036,
1253 (bcm43xx_phy_read(bcm, 0x0036) 1253 (bcm43xx_phy_read(bcm, 0x0036)
1254 & 0xF000) | (FIXME << 12)); 1254 & 0xF000) | (radio->txctl2 << 12));
1255 */
1256 } 1255 }
1257 if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL) 1256 if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL)
1258 bcm43xx_phy_write(bcm, 0x002E, 0x8075); 1257 bcm43xx_phy_write(bcm, 0x002E, 0x8075);
1259 else 1258 else
1260 bcm43xx_phy_write(bcm, 0x003E, 0x807F); 1259 bcm43xx_phy_write(bcm, 0x002E, 0x807F);
1261 if (phy->rev < 2) 1260 if (phy->rev < 2)
1262 bcm43xx_phy_write(bcm, 0x002F, 0x0101); 1261 bcm43xx_phy_write(bcm, 0x002F, 0x0101);
1263 else 1262 else
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index 888077fc14c4..9b7b15cf6561 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -334,7 +334,7 @@ static int bcm43xx_wx_get_nick(struct net_device *net_dev,
334 size_t len; 334 size_t len;
335 335
336 mutex_lock(&bcm->mutex); 336 mutex_lock(&bcm->mutex);
337 len = strlen(bcm->nick) + 1; 337 len = strlen(bcm->nick);
338 memcpy(extra, bcm->nick, len); 338 memcpy(extra, bcm->nick, len);
339 data->data.length = (__u16)len; 339 data->data.length = (__u16)len;
340 data->data.flags = 1; 340 data->data.flags = 1;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
index c0efbfe605a5..0159e4e93201 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
@@ -496,15 +496,14 @@ int bcm43xx_rx(struct bcm43xx_private *bcm,
496 stats.signal = bcm43xx_rssi_postprocess(bcm, rxhdr->rssi, is_ofdm, 496 stats.signal = bcm43xx_rssi_postprocess(bcm, rxhdr->rssi, is_ofdm,
497 !!(rxflags1 & BCM43xx_RXHDR_FLAGS1_2053RSSIADJ), 497 !!(rxflags1 & BCM43xx_RXHDR_FLAGS1_2053RSSIADJ),
498 !!(rxflags3 & BCM43xx_RXHDR_FLAGS3_2050RSSIADJ)); 498 !!(rxflags3 & BCM43xx_RXHDR_FLAGS3_2050RSSIADJ));
499//TODO stats.noise = 499 stats.noise = bcm->stats.noise;
500 if (is_ofdm) 500 if (is_ofdm)
501 stats.rate = bcm43xx_plcp_get_bitrate_ofdm(plcp); 501 stats.rate = bcm43xx_plcp_get_bitrate_ofdm(plcp);
502 else 502 else
503 stats.rate = bcm43xx_plcp_get_bitrate_cck(plcp); 503 stats.rate = bcm43xx_plcp_get_bitrate_cck(plcp);
504 stats.received_channel = radio->channel; 504 stats.received_channel = radio->channel;
505//TODO stats.control =
506 stats.mask = IEEE80211_STATMASK_SIGNAL | 505 stats.mask = IEEE80211_STATMASK_SIGNAL |
507//TODO IEEE80211_STATMASK_NOISE | 506 IEEE80211_STATMASK_NOISE |
508 IEEE80211_STATMASK_RATE | 507 IEEE80211_STATMASK_RATE |
509 IEEE80211_STATMASK_RSSI; 508 IEEE80211_STATMASK_RSSI;
510 if (phy->type == BCM43xx_PHYTYPE_A) 509 if (phy->type == BCM43xx_PHYTYPE_A)
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 7a4978516eac..d061fb3443ff 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -1412,9 +1412,9 @@ static int prism2_ioctl_siwretry(struct net_device *dev,
1412 /* what could be done, if firmware would support this.. */ 1412 /* what could be done, if firmware would support this.. */
1413 1413
1414 if (rrq->flags & IW_RETRY_LIMIT) { 1414 if (rrq->flags & IW_RETRY_LIMIT) {
1415 if (rrq->flags & IW_RETRY_MAX) 1415 if (rrq->flags & IW_RETRY_LONG)
1416 HFA384X_RID_LONGRETRYLIMIT = rrq->value; 1416 HFA384X_RID_LONGRETRYLIMIT = rrq->value;
1417 else if (rrq->flags & IW_RETRY_MIN) 1417 else if (rrq->flags & IW_RETRY_SHORT)
1418 HFA384X_RID_SHORTRETRYLIMIT = rrq->value; 1418 HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
1419 else { 1419 else {
1420 HFA384X_RID_LONGRETRYLIMIT = rrq->value; 1420 HFA384X_RID_LONGRETRYLIMIT = rrq->value;
@@ -1468,14 +1468,14 @@ static int prism2_ioctl_giwretry(struct net_device *dev,
1468 rrq->value = le16_to_cpu(altretry); 1468 rrq->value = le16_to_cpu(altretry);
1469 else 1469 else
1470 rrq->value = local->manual_retry_count; 1470 rrq->value = local->manual_retry_count;
1471 } else if ((rrq->flags & IW_RETRY_MAX)) { 1471 } else if ((rrq->flags & IW_RETRY_LONG)) {
1472 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 1472 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1473 rrq->value = longretry; 1473 rrq->value = longretry;
1474 } else { 1474 } else {
1475 rrq->flags = IW_RETRY_LIMIT; 1475 rrq->flags = IW_RETRY_LIMIT;
1476 rrq->value = shortretry; 1476 rrq->value = shortretry;
1477 if (shortretry != longretry) 1477 if (shortretry != longretry)
1478 rrq->flags |= IW_RETRY_MIN; 1478 rrq->flags |= IW_RETRY_SHORT;
1479 } 1479 }
1480 } 1480 }
1481 return 0; 1481 return 0;
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index b4d81a04c895..6c5add701a6f 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -6958,7 +6958,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
6958 } 6958 }
6959 6959
6960 if (wrqu->essid.flags && wrqu->essid.length) { 6960 if (wrqu->essid.flags && wrqu->essid.length) {
6961 length = wrqu->essid.length - 1; 6961 length = wrqu->essid.length;
6962 essid = extra; 6962 essid = extra;
6963 } 6963 }
6964 6964
@@ -7051,7 +7051,7 @@ static int ipw2100_wx_get_nick(struct net_device *dev,
7051 7051
7052 struct ipw2100_priv *priv = ieee80211_priv(dev); 7052 struct ipw2100_priv *priv = ieee80211_priv(dev);
7053 7053
7054 wrqu->data.length = strlen(priv->nick) + 1; 7054 wrqu->data.length = strlen(priv->nick);
7055 memcpy(extra, priv->nick, wrqu->data.length); 7055 memcpy(extra, priv->nick, wrqu->data.length);
7056 wrqu->data.flags = 1; /* active */ 7056 wrqu->data.flags = 1; /* active */
7057 7057
@@ -7343,14 +7343,14 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7343 goto done; 7343 goto done;
7344 } 7344 }
7345 7345
7346 if (wrqu->retry.flags & IW_RETRY_MIN) { 7346 if (wrqu->retry.flags & IW_RETRY_SHORT) {
7347 err = ipw2100_set_short_retry(priv, wrqu->retry.value); 7347 err = ipw2100_set_short_retry(priv, wrqu->retry.value);
7348 IPW_DEBUG_WX("SET Short Retry Limit -> %d \n", 7348 IPW_DEBUG_WX("SET Short Retry Limit -> %d \n",
7349 wrqu->retry.value); 7349 wrqu->retry.value);
7350 goto done; 7350 goto done;
7351 } 7351 }
7352 7352
7353 if (wrqu->retry.flags & IW_RETRY_MAX) { 7353 if (wrqu->retry.flags & IW_RETRY_LONG) {
7354 err = ipw2100_set_long_retry(priv, wrqu->retry.value); 7354 err = ipw2100_set_long_retry(priv, wrqu->retry.value);
7355 IPW_DEBUG_WX("SET Long Retry Limit -> %d \n", 7355 IPW_DEBUG_WX("SET Long Retry Limit -> %d \n",
7356 wrqu->retry.value); 7356 wrqu->retry.value);
@@ -7383,14 +7383,14 @@ static int ipw2100_wx_get_retry(struct net_device *dev,
7383 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) 7383 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME)
7384 return -EINVAL; 7384 return -EINVAL;
7385 7385
7386 if (wrqu->retry.flags & IW_RETRY_MAX) { 7386 if (wrqu->retry.flags & IW_RETRY_LONG) {
7387 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 7387 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
7388 wrqu->retry.value = priv->long_retry_limit; 7388 wrqu->retry.value = priv->long_retry_limit;
7389 } else { 7389 } else {
7390 wrqu->retry.flags = 7390 wrqu->retry.flags =
7391 (priv->short_retry_limit != 7391 (priv->short_retry_limit !=
7392 priv->long_retry_limit) ? 7392 priv->long_retry_limit) ?
7393 IW_RETRY_LIMIT | IW_RETRY_MIN : IW_RETRY_LIMIT; 7393 IW_RETRY_LIMIT | IW_RETRY_SHORT : IW_RETRY_LIMIT;
7394 7394
7395 wrqu->retry.value = priv->short_retry_limit; 7395 wrqu->retry.value = priv->short_retry_limit;
7396 } 7396 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 7358664e0908..5685d7ba55bb 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -8875,8 +8875,6 @@ static int ipw_wx_set_essid(struct net_device *dev,
8875 } 8875 }
8876 8876
8877 length = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); 8877 length = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE);
8878 if (!extra[length - 1])
8879 length--;
8880 8878
8881 priv->config |= CFG_STATIC_ESSID; 8879 priv->config |= CFG_STATIC_ESSID;
8882 8880
@@ -8953,7 +8951,7 @@ static int ipw_wx_get_nick(struct net_device *dev,
8953 struct ipw_priv *priv = ieee80211_priv(dev); 8951 struct ipw_priv *priv = ieee80211_priv(dev);
8954 IPW_DEBUG_WX("Getting nick\n"); 8952 IPW_DEBUG_WX("Getting nick\n");
8955 mutex_lock(&priv->mutex); 8953 mutex_lock(&priv->mutex);
8956 wrqu->data.length = strlen(priv->nick) + 1; 8954 wrqu->data.length = strlen(priv->nick);
8957 memcpy(extra, priv->nick, wrqu->data.length); 8955 memcpy(extra, priv->nick, wrqu->data.length);
8958 wrqu->data.flags = 1; /* active */ 8956 wrqu->data.flags = 1; /* active */
8959 mutex_unlock(&priv->mutex); 8957 mutex_unlock(&priv->mutex);
@@ -9276,9 +9274,9 @@ static int ipw_wx_set_retry(struct net_device *dev,
9276 return -EINVAL; 9274 return -EINVAL;
9277 9275
9278 mutex_lock(&priv->mutex); 9276 mutex_lock(&priv->mutex);
9279 if (wrqu->retry.flags & IW_RETRY_MIN) 9277 if (wrqu->retry.flags & IW_RETRY_SHORT)
9280 priv->short_retry_limit = (u8) wrqu->retry.value; 9278 priv->short_retry_limit = (u8) wrqu->retry.value;
9281 else if (wrqu->retry.flags & IW_RETRY_MAX) 9279 else if (wrqu->retry.flags & IW_RETRY_LONG)
9282 priv->long_retry_limit = (u8) wrqu->retry.value; 9280 priv->long_retry_limit = (u8) wrqu->retry.value;
9283 else { 9281 else {
9284 priv->short_retry_limit = (u8) wrqu->retry.value; 9282 priv->short_retry_limit = (u8) wrqu->retry.value;
@@ -9307,11 +9305,11 @@ static int ipw_wx_get_retry(struct net_device *dev,
9307 return -EINVAL; 9305 return -EINVAL;
9308 } 9306 }
9309 9307
9310 if (wrqu->retry.flags & IW_RETRY_MAX) { 9308 if (wrqu->retry.flags & IW_RETRY_LONG) {
9311 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 9309 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
9312 wrqu->retry.value = priv->long_retry_limit; 9310 wrqu->retry.value = priv->long_retry_limit;
9313 } else if (wrqu->retry.flags & IW_RETRY_MIN) { 9311 } else if (wrqu->retry.flags & IW_RETRY_SHORT) {
9314 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN; 9312 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
9315 wrqu->retry.value = priv->short_retry_limit; 9313 wrqu->retry.value = priv->short_retry_limit;
9316 } else { 9314 } else {
9317 wrqu->retry.flags = IW_RETRY_LIMIT; 9315 wrqu->retry.flags = IW_RETRY_LIMIT;
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 1840b69e3cb5..9e19a963febc 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -3037,7 +3037,7 @@ static int orinoco_ioctl_getessid(struct net_device *dev,
3037 } 3037 }
3038 3038
3039 erq->flags = 1; 3039 erq->flags = 1;
3040 erq->length = strlen(essidbuf) + 1; 3040 erq->length = strlen(essidbuf);
3041 3041
3042 return 0; 3042 return 0;
3043} 3043}
@@ -3078,7 +3078,7 @@ static int orinoco_ioctl_getnick(struct net_device *dev,
3078 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE+1); 3078 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE+1);
3079 orinoco_unlock(priv, &flags); 3079 orinoco_unlock(priv, &flags);
3080 3080
3081 nrq->length = strlen(nickbuf)+1; 3081 nrq->length = strlen(nickbuf);
3082 3082
3083 return 0; 3083 return 0;
3084} 3084}
@@ -3575,14 +3575,14 @@ static int orinoco_ioctl_getretry(struct net_device *dev,
3575 rrq->value = lifetime * 1000; /* ??? */ 3575 rrq->value = lifetime * 1000; /* ??? */
3576 } else { 3576 } else {
3577 /* By default, display the min number */ 3577 /* By default, display the min number */
3578 if ((rrq->flags & IW_RETRY_MAX)) { 3578 if ((rrq->flags & IW_RETRY_LONG)) {
3579 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 3579 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3580 rrq->value = long_limit; 3580 rrq->value = long_limit;
3581 } else { 3581 } else {
3582 rrq->flags = IW_RETRY_LIMIT; 3582 rrq->flags = IW_RETRY_LIMIT;
3583 rrq->value = short_limit; 3583 rrq->value = short_limit;
3584 if(short_limit != long_limit) 3584 if(short_limit != long_limit)
3585 rrq->flags |= IW_RETRY_MIN; 3585 rrq->flags |= IW_RETRY_SHORT;
3586 } 3586 }
3587 } 3587 }
3588 3588
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index c09fbf733b3a..286325ca3293 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -742,9 +742,9 @@ prism54_set_essid(struct net_device *ndev, struct iw_request_info *info,
742 742
743 /* Check if we were asked for `any' */ 743 /* Check if we were asked for `any' */
744 if (dwrq->flags && dwrq->length) { 744 if (dwrq->flags && dwrq->length) {
745 if (dwrq->length > min(33, IW_ESSID_MAX_SIZE + 1)) 745 if (dwrq->length > 32)
746 return -E2BIG; 746 return -E2BIG;
747 essid.length = dwrq->length - 1; 747 essid.length = dwrq->length;
748 memcpy(essid.octets, extra, dwrq->length); 748 memcpy(essid.octets, extra, dwrq->length);
749 } else 749 } else
750 essid.length = 0; 750 essid.length = 0;
@@ -814,7 +814,7 @@ prism54_get_nick(struct net_device *ndev, struct iw_request_info *info,
814 dwrq->length = 0; 814 dwrq->length = 0;
815 815
816 down_read(&priv->mib_sem); 816 down_read(&priv->mib_sem);
817 dwrq->length = strlen(priv->nickname) + 1; 817 dwrq->length = strlen(priv->nickname);
818 memcpy(extra, priv->nickname, dwrq->length); 818 memcpy(extra, priv->nickname, dwrq->length);
819 up_read(&priv->mib_sem); 819 up_read(&priv->mib_sem);
820 820
@@ -992,9 +992,9 @@ prism54_set_retry(struct net_device *ndev, struct iw_request_info *info,
992 return -EINVAL; 992 return -EINVAL;
993 993
994 if (vwrq->flags & IW_RETRY_LIMIT) { 994 if (vwrq->flags & IW_RETRY_LIMIT) {
995 if (vwrq->flags & IW_RETRY_MIN) 995 if (vwrq->flags & IW_RETRY_SHORT)
996 slimit = vwrq->value; 996 slimit = vwrq->value;
997 else if (vwrq->flags & IW_RETRY_MAX) 997 else if (vwrq->flags & IW_RETRY_LONG)
998 llimit = vwrq->value; 998 llimit = vwrq->value;
999 else { 999 else {
1000 /* we are asked to set both */ 1000 /* we are asked to set both */
@@ -1035,18 +1035,18 @@ prism54_get_retry(struct net_device *ndev, struct iw_request_info *info,
1035 mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r); 1035 mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r);
1036 vwrq->value = r.u * 1024; 1036 vwrq->value = r.u * 1024;
1037 vwrq->flags = IW_RETRY_LIFETIME; 1037 vwrq->flags = IW_RETRY_LIFETIME;
1038 } else if ((vwrq->flags & IW_RETRY_MAX)) { 1038 } else if ((vwrq->flags & IW_RETRY_LONG)) {
1039 /* we are asked for the long retry limit */ 1039 /* we are asked for the long retry limit */
1040 rvalue |= 1040 rvalue |=
1041 mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r); 1041 mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r);
1042 vwrq->value = r.u; 1042 vwrq->value = r.u;
1043 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 1043 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1044 } else { 1044 } else {
1045 /* default. get the short retry limit */ 1045 /* default. get the short retry limit */
1046 rvalue |= 1046 rvalue |=
1047 mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r); 1047 mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r);
1048 vwrq->value = r.u; 1048 vwrq->value = r.u;
1049 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MIN; 1049 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
1050 } 1050 }
1051 1051
1052 return rvalue; 1052 return rvalue;
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 4574290f971f..e82548ea609a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -1173,7 +1173,7 @@ static int ray_set_essid(struct net_device *dev,
1173 return -EOPNOTSUPP; 1173 return -EOPNOTSUPP;
1174 } else { 1174 } else {
1175 /* Check the size of the string */ 1175 /* Check the size of the string */
1176 if(dwrq->length > IW_ESSID_MAX_SIZE + 1) { 1176 if(dwrq->length > IW_ESSID_MAX_SIZE) {
1177 return -E2BIG; 1177 return -E2BIG;
1178 } 1178 }
1179 1179
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index e0d294c12970..e3ae5f60d5be 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1802,15 +1802,15 @@ static int wl3501_get_retry(struct net_device *dev,
1802 &retry, sizeof(retry)); 1802 &retry, sizeof(retry));
1803 if (rc) 1803 if (rc)
1804 goto out; 1804 goto out;
1805 if (wrqu->retry.flags & IW_RETRY_MAX) { 1805 if (wrqu->retry.flags & IW_RETRY_LONG) {
1806 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 1806 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1807 goto set_value; 1807 goto set_value;
1808 } 1808 }
1809 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT, 1809 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT,
1810 &retry, sizeof(retry)); 1810 &retry, sizeof(retry));
1811 if (rc) 1811 if (rc)
1812 goto out; 1812 goto out;
1813 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN; 1813 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
1814set_value: 1814set_value:
1815 wrqu->retry.value = retry; 1815 wrqu->retry.value = retry;
1816 wrqu->retry.disabled = 0; 1816 wrqu->retry.disabled = 0;
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index c52e9bcf8d02..a44dda952c67 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -1218,7 +1218,7 @@ static int zd1201_set_essid(struct net_device *dev,
1218 return -EINVAL; 1218 return -EINVAL;
1219 if (data->length < 1) 1219 if (data->length < 1)
1220 data->length = 1; 1220 data->length = 1;
1221 zd->essidlen = data->length-1; 1221 zd->essidlen = data->length;
1222 memset(zd->essid, 0, IW_ESSID_MAX_SIZE+1); 1222 memset(zd->essid, 0, IW_ESSID_MAX_SIZE+1);
1223 memcpy(zd->essid, essid, data->length); 1223 memcpy(zd->essid, essid, data->length);
1224 return zd1201_join(zd, zd->essid, zd->essidlen); 1224 return zd1201_join(zd, zd->essid, zd->essidlen);
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 7c4e32cf0d47..aa661b2b76c7 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -249,7 +249,6 @@ int zd_ioread16(struct zd_chip *chip, zd_addr_t addr, u16 *value)
249{ 249{
250 int r; 250 int r;
251 251
252 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
253 mutex_lock(&chip->mutex); 252 mutex_lock(&chip->mutex);
254 r = zd_ioread16_locked(chip, value, addr); 253 r = zd_ioread16_locked(chip, value, addr);
255 mutex_unlock(&chip->mutex); 254 mutex_unlock(&chip->mutex);
@@ -260,7 +259,6 @@ int zd_ioread32(struct zd_chip *chip, zd_addr_t addr, u32 *value)
260{ 259{
261 int r; 260 int r;
262 261
263 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
264 mutex_lock(&chip->mutex); 262 mutex_lock(&chip->mutex);
265 r = zd_ioread32_locked(chip, value, addr); 263 r = zd_ioread32_locked(chip, value, addr);
266 mutex_unlock(&chip->mutex); 264 mutex_unlock(&chip->mutex);
@@ -271,7 +269,6 @@ int zd_iowrite16(struct zd_chip *chip, zd_addr_t addr, u16 value)
271{ 269{
272 int r; 270 int r;
273 271
274 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
275 mutex_lock(&chip->mutex); 272 mutex_lock(&chip->mutex);
276 r = zd_iowrite16_locked(chip, value, addr); 273 r = zd_iowrite16_locked(chip, value, addr);
277 mutex_unlock(&chip->mutex); 274 mutex_unlock(&chip->mutex);
@@ -282,7 +279,6 @@ int zd_iowrite32(struct zd_chip *chip, zd_addr_t addr, u32 value)
282{ 279{
283 int r; 280 int r;
284 281
285 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
286 mutex_lock(&chip->mutex); 282 mutex_lock(&chip->mutex);
287 r = zd_iowrite32_locked(chip, value, addr); 283 r = zd_iowrite32_locked(chip, value, addr);
288 mutex_unlock(&chip->mutex); 284 mutex_unlock(&chip->mutex);
@@ -294,7 +290,6 @@ int zd_ioread32v(struct zd_chip *chip, const zd_addr_t *addresses,
294{ 290{
295 int r; 291 int r;
296 292
297 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
298 mutex_lock(&chip->mutex); 293 mutex_lock(&chip->mutex);
299 r = zd_ioread32v_locked(chip, values, addresses, count); 294 r = zd_ioread32v_locked(chip, values, addresses, count);
300 mutex_unlock(&chip->mutex); 295 mutex_unlock(&chip->mutex);
@@ -306,7 +301,6 @@ int zd_iowrite32a(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
306{ 301{
307 int r; 302 int r;
308 303
309 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
310 mutex_lock(&chip->mutex); 304 mutex_lock(&chip->mutex);
311 r = zd_iowrite32a_locked(chip, ioreqs, count); 305 r = zd_iowrite32a_locked(chip, ioreqs, count);
312 mutex_unlock(&chip->mutex); 306 mutex_unlock(&chip->mutex);
@@ -331,13 +325,22 @@ static int read_pod(struct zd_chip *chip, u8 *rf_type)
331 chip->patch_cr157 = (value >> 13) & 0x1; 325 chip->patch_cr157 = (value >> 13) & 0x1;
332 chip->patch_6m_band_edge = (value >> 21) & 0x1; 326 chip->patch_6m_band_edge = (value >> 21) & 0x1;
333 chip->new_phy_layout = (value >> 31) & 0x1; 327 chip->new_phy_layout = (value >> 31) & 0x1;
328 chip->link_led = ((value >> 4) & 1) ? LED1 : LED2;
329 chip->supports_tx_led = 1;
330 if (value & (1 << 24)) { /* LED scenario */
331 if (value & (1 << 29))
332 chip->supports_tx_led = 0;
333 }
334 334
335 dev_dbg_f(zd_chip_dev(chip), 335 dev_dbg_f(zd_chip_dev(chip),
336 "RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d " 336 "RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d "
337 "patch 6M %d new PHY %d\n", 337 "patch 6M %d new PHY %d link LED%d tx led %d\n",
338 zd_rf_name(*rf_type), *rf_type, 338 zd_rf_name(*rf_type), *rf_type,
339 chip->pa_type, chip->patch_cck_gain, 339 chip->pa_type, chip->patch_cck_gain,
340 chip->patch_cr157, chip->patch_6m_band_edge, chip->new_phy_layout); 340 chip->patch_cr157, chip->patch_6m_band_edge,
341 chip->new_phy_layout,
342 chip->link_led == LED1 ? 1 : 2,
343 chip->supports_tx_led);
341 return 0; 344 return 0;
342error: 345error:
343 *rf_type = 0; 346 *rf_type = 0;
@@ -1181,7 +1184,7 @@ static int update_pwr_int(struct zd_chip *chip, u8 channel)
1181 u8 value = chip->pwr_int_values[channel - 1]; 1184 u8 value = chip->pwr_int_values[channel - 1];
1182 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_int %#04x\n", 1185 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_int %#04x\n",
1183 channel, value); 1186 channel, value);
1184 return zd_iowrite32_locked(chip, value, CR31); 1187 return zd_iowrite16_locked(chip, value, CR31);
1185} 1188}
1186 1189
1187static int update_pwr_cal(struct zd_chip *chip, u8 channel) 1190static int update_pwr_cal(struct zd_chip *chip, u8 channel)
@@ -1189,12 +1192,12 @@ static int update_pwr_cal(struct zd_chip *chip, u8 channel)
1189 u8 value = chip->pwr_cal_values[channel-1]; 1192 u8 value = chip->pwr_cal_values[channel-1];
1190 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_cal %#04x\n", 1193 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_cal %#04x\n",
1191 channel, value); 1194 channel, value);
1192 return zd_iowrite32_locked(chip, value, CR68); 1195 return zd_iowrite16_locked(chip, value, CR68);
1193} 1196}
1194 1197
1195static int update_ofdm_cal(struct zd_chip *chip, u8 channel) 1198static int update_ofdm_cal(struct zd_chip *chip, u8 channel)
1196{ 1199{
1197 struct zd_ioreq32 ioreqs[3]; 1200 struct zd_ioreq16 ioreqs[3];
1198 1201
1199 ioreqs[0].addr = CR67; 1202 ioreqs[0].addr = CR67;
1200 ioreqs[0].value = chip->ofdm_cal_values[OFDM_36M_INDEX][channel-1]; 1203 ioreqs[0].value = chip->ofdm_cal_values[OFDM_36M_INDEX][channel-1];
@@ -1206,7 +1209,7 @@ static int update_ofdm_cal(struct zd_chip *chip, u8 channel)
1206 dev_dbg_f(zd_chip_dev(chip), 1209 dev_dbg_f(zd_chip_dev(chip),
1207 "channel %d ofdm_cal 36M %#04x 48M %#04x 54M %#04x\n", 1210 "channel %d ofdm_cal 36M %#04x 48M %#04x 54M %#04x\n",
1208 channel, ioreqs[0].value, ioreqs[1].value, ioreqs[2].value); 1211 channel, ioreqs[0].value, ioreqs[1].value, ioreqs[2].value);
1209 return zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 1212 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1210} 1213}
1211 1214
1212static int update_channel_integration_and_calibration(struct zd_chip *chip, 1215static int update_channel_integration_and_calibration(struct zd_chip *chip,
@@ -1218,7 +1221,7 @@ static int update_channel_integration_and_calibration(struct zd_chip *chip,
1218 if (r) 1221 if (r)
1219 return r; 1222 return r;
1220 if (chip->is_zd1211b) { 1223 if (chip->is_zd1211b) {
1221 static const struct zd_ioreq32 ioreqs[] = { 1224 static const struct zd_ioreq16 ioreqs[] = {
1222 { CR69, 0x28 }, 1225 { CR69, 0x28 },
1223 {}, 1226 {},
1224 { CR69, 0x2a }, 1227 { CR69, 0x2a },
@@ -1230,7 +1233,7 @@ static int update_channel_integration_and_calibration(struct zd_chip *chip,
1230 r = update_pwr_cal(chip, channel); 1233 r = update_pwr_cal(chip, channel);
1231 if (r) 1234 if (r)
1232 return r; 1235 return r;
1233 r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 1236 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1234 if (r) 1237 if (r)
1235 return r; 1238 return r;
1236 } 1239 }
@@ -1252,7 +1255,7 @@ static int patch_cck_gain(struct zd_chip *chip)
1252 if (r) 1255 if (r)
1253 return r; 1256 return r;
1254 dev_dbg_f(zd_chip_dev(chip), "patching value %x\n", value & 0xff); 1257 dev_dbg_f(zd_chip_dev(chip), "patching value %x\n", value & 0xff);
1255 return zd_iowrite32_locked(chip, value & 0xff, CR47); 1258 return zd_iowrite16_locked(chip, value & 0xff, CR47);
1256} 1259}
1257 1260
1258int zd_chip_set_channel(struct zd_chip *chip, u8 channel) 1261int zd_chip_set_channel(struct zd_chip *chip, u8 channel)
@@ -1295,89 +1298,60 @@ u8 zd_chip_get_channel(struct zd_chip *chip)
1295 return channel; 1298 return channel;
1296} 1299}
1297 1300
1298static u16 led_mask(int led) 1301int zd_chip_control_leds(struct zd_chip *chip, enum led_status status)
1299{ 1302{
1300 switch (led) { 1303 static const zd_addr_t a[] = {
1301 case 1: 1304 FW_LINK_STATUS,
1302 return LED1; 1305 CR_LED,
1303 case 2: 1306 };
1304 return LED2;
1305 default:
1306 return 0;
1307 }
1308}
1309
1310static int read_led_reg(struct zd_chip *chip, u16 *status)
1311{
1312 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1313 return zd_ioread16_locked(chip, status, CR_LED);
1314}
1315
1316static int write_led_reg(struct zd_chip *chip, u16 status)
1317{
1318 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1319 return zd_iowrite16_locked(chip, status, CR_LED);
1320}
1321 1307
1322int zd_chip_led_status(struct zd_chip *chip, int led, enum led_status status) 1308 int r;
1323{ 1309 u16 v[ARRAY_SIZE(a)];
1324 int r, ret; 1310 struct zd_ioreq16 ioreqs[ARRAY_SIZE(a)] = {
1325 u16 mask = led_mask(led); 1311 [0] = { FW_LINK_STATUS },
1326 u16 reg; 1312 [1] = { CR_LED },
1313 };
1314 u16 other_led;
1327 1315
1328 if (!mask)
1329 return -EINVAL;
1330 mutex_lock(&chip->mutex); 1316 mutex_lock(&chip->mutex);
1331 r = read_led_reg(chip, &reg); 1317 r = zd_ioread16v_locked(chip, v, (const zd_addr_t *)a, ARRAY_SIZE(a));
1332 if (r) 1318 if (r)
1333 return r; 1319 goto out;
1320
1321 other_led = chip->link_led == LED1 ? LED2 : LED1;
1322
1334 switch (status) { 1323 switch (status) {
1335 case LED_STATUS:
1336 return (reg & mask) ? LED_ON : LED_OFF;
1337 case LED_OFF: 1324 case LED_OFF:
1338 reg &= ~mask; 1325 ioreqs[0].value = FW_LINK_OFF;
1339 ret = LED_OFF; 1326 ioreqs[1].value = v[1] & ~(LED1|LED2);
1340 break; 1327 break;
1341 case LED_FLIP: 1328 case LED_SCANNING:
1342 reg ^= mask; 1329 ioreqs[0].value = FW_LINK_OFF;
1343 ret = (reg&mask) ? LED_ON : LED_OFF; 1330 ioreqs[1].value = v[1] & ~other_led;
1331 if (get_seconds() % 3 == 0) {
1332 ioreqs[1].value &= ~chip->link_led;
1333 } else {
1334 ioreqs[1].value |= chip->link_led;
1335 }
1344 break; 1336 break;
1345 case LED_ON: 1337 case LED_ASSOCIATED:
1346 reg |= mask; 1338 ioreqs[0].value = FW_LINK_TX;
1347 ret = LED_ON; 1339 ioreqs[1].value = v[1] & ~other_led;
1340 ioreqs[1].value |= chip->link_led;
1348 break; 1341 break;
1349 default: 1342 default:
1350 return -EINVAL; 1343 r = -EINVAL;
1351 }
1352 r = write_led_reg(chip, reg);
1353 if (r) {
1354 ret = r;
1355 goto out; 1344 goto out;
1356 } 1345 }
1357out:
1358 mutex_unlock(&chip->mutex);
1359 return r;
1360}
1361
1362int zd_chip_led_flip(struct zd_chip *chip, int led,
1363 const unsigned int *phases_msecs, unsigned int count)
1364{
1365 int i, r;
1366 enum led_status status;
1367 1346
1368 r = zd_chip_led_status(chip, led, LED_STATUS); 1347 if (v[0] != ioreqs[0].value || v[1] != ioreqs[1].value) {
1369 if (r) 1348 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1370 return r; 1349 if (r)
1371 status = r;
1372 for (i = 0; i < count; i++) {
1373 r = zd_chip_led_status(chip, led, LED_FLIP);
1374 if (r < 0)
1375 goto out; 1350 goto out;
1376 msleep(phases_msecs[i]);
1377 } 1351 }
1378 1352 r = 0;
1379out: 1353out:
1380 zd_chip_led_status(chip, led, status); 1354 mutex_unlock(&chip->mutex);
1381 return r; 1355 return r;
1382} 1356}
1383 1357
@@ -1679,4 +1653,3 @@ int zd_rfwritev_cr_locked(struct zd_chip *chip,
1679 1653
1680 return 0; 1654 return 0;
1681} 1655}
1682
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index 4b1250859897..ae59597ce4e1 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -428,6 +428,7 @@
428/* masks for controlling LEDs */ 428/* masks for controlling LEDs */
429#define LED1 0x0100 429#define LED1 0x0100
430#define LED2 0x0200 430#define LED2 0x0200
431#define LED_SW 0x0400
431 432
432/* Seems to indicate that the configuration is over. 433/* Seems to indicate that the configuration is over.
433 */ 434 */
@@ -629,6 +630,10 @@
629#define FW_SOFT_RESET FW_REG(4) 630#define FW_SOFT_RESET FW_REG(4)
630#define FW_FLASH_CHK FW_REG(5) 631#define FW_FLASH_CHK FW_REG(5)
631 632
633#define FW_LINK_OFF 0x0
634#define FW_LINK_TX 0x1
635/* 0x2 - link led on? */
636
632enum { 637enum {
633 CR_BASE_OFFSET = 0x9000, 638 CR_BASE_OFFSET = 0x9000,
634 FW_START_OFFSET = 0xee00, 639 FW_START_OFFSET = 0xee00,
@@ -663,8 +668,11 @@ struct zd_chip {
663 u8 pwr_int_values[E2P_CHANNEL_COUNT]; 668 u8 pwr_int_values[E2P_CHANNEL_COUNT];
664 /* SetPointOFDM in the vendor driver */ 669 /* SetPointOFDM in the vendor driver */
665 u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT]; 670 u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT];
666 u8 pa_type:4, patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1, 671 u16 link_led;
667 new_phy_layout:1, is_zd1211b:1; 672 unsigned int pa_type:4,
673 patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
674 new_phy_layout:1,
675 is_zd1211b:1, supports_tx_led:1;
668}; 676};
669 677
670static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb) 678static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb)
@@ -812,15 +820,12 @@ int zd_chip_lock_phy_regs(struct zd_chip *chip);
812int zd_chip_unlock_phy_regs(struct zd_chip *chip); 820int zd_chip_unlock_phy_regs(struct zd_chip *chip);
813 821
814enum led_status { 822enum led_status {
815 LED_OFF = 0, 823 LED_OFF = 0,
816 LED_ON = 1, 824 LED_SCANNING = 1,
817 LED_FLIP = 2, 825 LED_ASSOCIATED = 2,
818 LED_STATUS = 3,
819}; 826};
820 827
821int zd_chip_led_status(struct zd_chip *chip, int led, enum led_status status); 828int zd_chip_control_leds(struct zd_chip *chip, enum led_status status);
822int zd_chip_led_flip(struct zd_chip *chip, int led,
823 const unsigned int *phases_msecs, unsigned int count);
824 829
825int zd_set_beacon_interval(struct zd_chip *chip, u32 interval); 830int zd_set_beacon_interval(struct zd_chip *chip, u32 interval);
826 831
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 1989f1c05fbe..2d12837052b0 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -33,6 +33,10 @@
33static void ieee_init(struct ieee80211_device *ieee); 33static void ieee_init(struct ieee80211_device *ieee);
34static void softmac_init(struct ieee80211softmac_device *sm); 34static void softmac_init(struct ieee80211softmac_device *sm);
35 35
36static void housekeeping_init(struct zd_mac *mac);
37static void housekeeping_enable(struct zd_mac *mac);
38static void housekeeping_disable(struct zd_mac *mac);
39
36int zd_mac_init(struct zd_mac *mac, 40int zd_mac_init(struct zd_mac *mac,
37 struct net_device *netdev, 41 struct net_device *netdev,
38 struct usb_interface *intf) 42 struct usb_interface *intf)
@@ -46,6 +50,7 @@ int zd_mac_init(struct zd_mac *mac,
46 ieee_init(ieee); 50 ieee_init(ieee);
47 softmac_init(ieee80211_priv(netdev)); 51 softmac_init(ieee80211_priv(netdev));
48 zd_chip_init(&mac->chip, netdev, intf); 52 zd_chip_init(&mac->chip, netdev, intf);
53 housekeeping_init(mac);
49 return 0; 54 return 0;
50} 55}
51 56
@@ -178,6 +183,7 @@ int zd_mac_open(struct net_device *netdev)
178 if (r < 0) 183 if (r < 0)
179 goto disable_rx; 184 goto disable_rx;
180 185
186 housekeeping_enable(mac);
181 ieee80211softmac_start(netdev); 187 ieee80211softmac_start(netdev);
182 return 0; 188 return 0;
183disable_rx: 189disable_rx:
@@ -204,6 +210,7 @@ int zd_mac_stop(struct net_device *netdev)
204 */ 210 */
205 211
206 zd_chip_disable_rx(chip); 212 zd_chip_disable_rx(chip);
213 housekeeping_disable(mac);
207 ieee80211softmac_stop(netdev); 214 ieee80211softmac_stop(netdev);
208 215
209 zd_chip_disable_hwint(chip); 216 zd_chip_disable_hwint(chip);
@@ -1080,3 +1087,46 @@ void zd_dump_rx_status(const struct rx_status *status)
1080 } 1087 }
1081} 1088}
1082#endif /* DEBUG */ 1089#endif /* DEBUG */
1090
1091#define LINK_LED_WORK_DELAY HZ
1092
1093static void link_led_handler(void *p)
1094{
1095 struct zd_mac *mac = p;
1096 struct zd_chip *chip = &mac->chip;
1097 struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev);
1098 int is_associated;
1099 int r;
1100
1101 spin_lock_irq(&mac->lock);
1102 is_associated = sm->associated != 0;
1103 spin_unlock_irq(&mac->lock);
1104
1105 r = zd_chip_control_leds(chip,
1106 is_associated ? LED_ASSOCIATED : LED_SCANNING);
1107 if (r)
1108 dev_err(zd_mac_dev(mac), "zd_chip_control_leds error %d\n", r);
1109
1110 queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work,
1111 LINK_LED_WORK_DELAY);
1112}
1113
1114static void housekeeping_init(struct zd_mac *mac)
1115{
1116 INIT_WORK(&mac->housekeeping.link_led_work, link_led_handler, mac);
1117}
1118
1119static void housekeeping_enable(struct zd_mac *mac)
1120{
1121 dev_dbg_f(zd_mac_dev(mac), "\n");
1122 queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work,
1123 0);
1124}
1125
1126static void housekeeping_disable(struct zd_mac *mac)
1127{
1128 dev_dbg_f(zd_mac_dev(mac), "\n");
1129 cancel_rearming_delayed_workqueue(zd_workqueue,
1130 &mac->housekeeping.link_led_work);
1131 zd_chip_control_leds(&mac->chip, LED_OFF);
1132}
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 29b51fd7d4e5..b8ea3de7924a 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -120,6 +120,10 @@ enum mac_flags {
120 MAC_FIXED_CHANNEL = 0x01, 120 MAC_FIXED_CHANNEL = 0x01,
121}; 121};
122 122
123struct housekeeping {
124 struct work_struct link_led_work;
125};
126
123#define ZD_MAC_STATS_BUFFER_SIZE 16 127#define ZD_MAC_STATS_BUFFER_SIZE 16
124 128
125struct zd_mac { 129struct zd_mac {
@@ -128,6 +132,7 @@ struct zd_mac {
128 struct net_device *netdev; 132 struct net_device *netdev;
129 /* Unlocked reading possible */ 133 /* Unlocked reading possible */
130 struct iw_statistics iw_stats; 134 struct iw_statistics iw_stats;
135 struct housekeeping housekeeping;
131 unsigned int stats_count; 136 unsigned int stats_count;
132 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 137 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE];
133 u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 138 u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE];
diff --git a/drivers/net/wireless/zd1211rw/zd_netdev.c b/drivers/net/wireless/zd1211rw/zd_netdev.c
index 440ef24b5fd1..af3a7b36d078 100644
--- a/drivers/net/wireless/zd1211rw/zd_netdev.c
+++ b/drivers/net/wireless/zd1211rw/zd_netdev.c
@@ -82,7 +82,7 @@ static int iw_get_nick(struct net_device *netdev,
82 union iwreq_data *req, char *extra) 82 union iwreq_data *req, char *extra)
83{ 83{
84 strcpy(extra, "zd1211"); 84 strcpy(extra, "zd1211");
85 req->data.length = strlen(extra) + 1; 85 req->data.length = strlen(extra);
86 req->data.flags = 1; 86 req->data.flags = 1;
87 return 0; 87 return 0;
88} 88}
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 31027e52b04b..5c265ad0485a 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/skbuff.h> 25#include <linux/skbuff.h>
26#include <linux/usb.h> 26#include <linux/usb.h>
27#include <linux/workqueue.h>
27#include <net/ieee80211.h> 28#include <net/ieee80211.h>
28 29
29#include "zd_def.h" 30#include "zd_def.h"
@@ -1112,12 +1113,20 @@ static struct usb_driver driver = {
1112 .disconnect = disconnect, 1113 .disconnect = disconnect,
1113}; 1114};
1114 1115
1116struct workqueue_struct *zd_workqueue;
1117
1115static int __init usb_init(void) 1118static int __init usb_init(void)
1116{ 1119{
1117 int r; 1120 int r;
1118 1121
1119 pr_debug("usb_init()\n"); 1122 pr_debug("usb_init()\n");
1120 1123
1124 zd_workqueue = create_singlethread_workqueue(driver.name);
1125 if (zd_workqueue == NULL) {
1126 printk(KERN_ERR "%s: couldn't create workqueue\n", driver.name);
1127 return -ENOMEM;
1128 }
1129
1121 r = usb_register(&driver); 1130 r = usb_register(&driver);
1122 if (r) { 1131 if (r) {
1123 printk(KERN_ERR "usb_register() failed. Error number %d\n", r); 1132 printk(KERN_ERR "usb_register() failed. Error number %d\n", r);
@@ -1132,6 +1141,7 @@ static void __exit usb_exit(void)
1132{ 1141{
1133 pr_debug("usb_exit()\n"); 1142 pr_debug("usb_exit()\n");
1134 usb_deregister(&driver); 1143 usb_deregister(&driver);
1144 destroy_workqueue(zd_workqueue);
1135} 1145}
1136 1146
1137module_init(usb_init); 1147module_init(usb_init);
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.h b/drivers/net/wireless/zd1211rw/zd_usb.h
index ded39de5f72d..e81a2d3cfffd 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.h
+++ b/drivers/net/wireless/zd1211rw/zd_usb.h
@@ -238,4 +238,6 @@ int zd_usb_iowrite16v(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs,
238 238
239int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits); 239int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits);
240 240
241extern struct workqueue_struct *zd_workqueue;
242
241#endif /* _ZD_USB_H */ 243#endif /* _ZD_USB_H */
diff --git a/include/linux/if.h b/include/linux/if.h
index cd080d765324..8018c2e22c0c 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -59,6 +59,8 @@
59#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ 59#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */
60#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */ 60#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */
61#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */ 61#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */
62#define IFF_BONDING 0x20 /* bonding master or slave */
63#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */
62 64
63#define IF_GET_IFACE 0x0001 /* for querying only */ 65#define IF_GET_IFACE 0x0001 /* for querying only */
64#define IF_GET_PROTO 0x0002 66#define IF_GET_PROTO 0x0002
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 43289127b458..13d6d4eb8b3a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -334,7 +334,6 @@ struct net_device
334 334
335 335
336 struct net_device_stats* (*get_stats)(struct net_device *dev); 336 struct net_device_stats* (*get_stats)(struct net_device *dev);
337 struct iw_statistics* (*get_wireless_stats)(struct net_device *dev);
338 337
339 /* List of functions to handle Wireless Extensions (instead of ioctl). 338 /* List of functions to handle Wireless Extensions (instead of ioctl).
340 * See <net/iw_handler.h> for details. Jean II */ 339 * See <net/iw_handler.h> for details. Jean II */
@@ -1016,7 +1015,8 @@ static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
1016} 1015}
1017 1016
1018/* On bonding slaves other than the currently active slave, suppress 1017/* On bonding slaves other than the currently active slave, suppress
1019 * duplicates except for 802.3ad ETH_P_SLOW and alb non-mcast/bcast. 1018 * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and
1019 * ARP on active-backup slaves with arp_validate enabled.
1020 */ 1020 */
1021static inline int skb_bond_should_drop(struct sk_buff *skb) 1021static inline int skb_bond_should_drop(struct sk_buff *skb)
1022{ 1022{
@@ -1025,6 +1025,10 @@ static inline int skb_bond_should_drop(struct sk_buff *skb)
1025 1025
1026 if (master && 1026 if (master &&
1027 (dev->priv_flags & IFF_SLAVE_INACTIVE)) { 1027 (dev->priv_flags & IFF_SLAVE_INACTIVE)) {
1028 if ((dev->priv_flags & IFF_SLAVE_NEEDARP) &&
1029 skb->protocol == __constant_htons(ETH_P_ARP))
1030 return 0;
1031
1028 if (master->priv_flags & IFF_MASTER_ALB) { 1032 if (master->priv_flags & IFF_MASTER_ALB) {
1029 if (skb->pkt_type != PACKET_BROADCAST && 1033 if (skb->pkt_type != PACKET_BROADCAST &&
1030 skb->pkt_type != PACKET_MULTICAST) 1034 skb->pkt_type != PACKET_MULTICAST)
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index 13588564b42b..a50a0130fd9e 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * This file define a set of standard wireless extensions 2 * This file define a set of standard wireless extensions
3 * 3 *
4 * Version : 20 17.2.06 4 * Version : 21 14.3.06
5 * 5 *
6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> 6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
7 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved. 7 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
@@ -69,9 +69,14 @@
69 69
70/***************************** INCLUDES *****************************/ 70/***************************** INCLUDES *****************************/
71 71
72/* This header is used in user-space, therefore need to be sanitised
73 * for that purpose. Those includes are usually not compatible with glibc.
74 * To know which includes to use in user-space, check iwlib.h. */
75#ifdef __KERNEL__
72#include <linux/types.h> /* for "caddr_t" et al */ 76#include <linux/types.h> /* for "caddr_t" et al */
73#include <linux/socket.h> /* for "struct sockaddr" et al */ 77#include <linux/socket.h> /* for "struct sockaddr" et al */
74#include <linux/if.h> /* for IFNAMSIZ and co... */ 78#include <linux/if.h> /* for IFNAMSIZ and co... */
79#endif /* __KERNEL__ */
75 80
76/***************************** VERSION *****************************/ 81/***************************** VERSION *****************************/
77/* 82/*
@@ -80,7 +85,7 @@
80 * (there is some stuff that will be added in the future...) 85 * (there is some stuff that will be added in the future...)
81 * I just plan to increment with each new version. 86 * I just plan to increment with each new version.
82 */ 87 */
83#define WIRELESS_EXT 20 88#define WIRELESS_EXT 21
84 89
85/* 90/*
86 * Changes : 91 * Changes :
@@ -208,6 +213,14 @@
208 * V19 to V20 213 * V19 to V20
209 * ---------- 214 * ----------
210 * - RtNetlink requests support (SET/GET) 215 * - RtNetlink requests support (SET/GET)
216 *
217 * V20 to V21
218 * ----------
219 * - Remove (struct net_device *)->get_wireless_stats()
220 * - Change length in ESSID and NICK to strlen() instead of strlen()+1
221 * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
222 * - Power/Retry relative values no longer * 100000
223 * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
211 */ 224 */
212 225
213/**************************** CONSTANTS ****************************/ 226/**************************** CONSTANTS ****************************/
@@ -448,6 +461,7 @@
448#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */ 461#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
449#define IW_QUAL_LEVEL_INVALID 0x20 462#define IW_QUAL_LEVEL_INVALID 0x20
450#define IW_QUAL_NOISE_INVALID 0x40 463#define IW_QUAL_NOISE_INVALID 0x40
464#define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
451#define IW_QUAL_ALL_INVALID 0x70 465#define IW_QUAL_ALL_INVALID 0x70
452 466
453/* Frequency flags */ 467/* Frequency flags */
@@ -500,10 +514,12 @@
500#define IW_RETRY_TYPE 0xF000 /* Type of parameter */ 514#define IW_RETRY_TYPE 0xF000 /* Type of parameter */
501#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/ 515#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
502#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */ 516#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
503#define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */ 517#define IW_RETRY_MODIFIER 0x00FF /* Modify a parameter */
504#define IW_RETRY_MIN 0x0001 /* Value is a minimum */ 518#define IW_RETRY_MIN 0x0001 /* Value is a minimum */
505#define IW_RETRY_MAX 0x0002 /* Value is a maximum */ 519#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
506#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */ 520#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
521#define IW_RETRY_SHORT 0x0010 /* Value is for short packets */
522#define IW_RETRY_LONG 0x0020 /* Value is for long packets */
507 523
508/* Scanning request flags */ 524/* Scanning request flags */
509#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */ 525#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
@@ -1017,7 +1033,7 @@ struct iw_range
1017 /* Note : this frequency list doesn't need to fit channel numbers, 1033 /* Note : this frequency list doesn't need to fit channel numbers,
1018 * because each entry contain its channel index */ 1034 * because each entry contain its channel index */
1019 1035
1020 __u32 enc_capa; /* IW_ENC_CAPA_* bit field */ 1036 __u32 enc_capa; /* IW_ENC_CAPA_* bit field */
1021}; 1037};
1022 1038
1023/* 1039/*
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 13472762b18b..f47f319bb7dc 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -344,8 +344,6 @@ static ssize_t wireless_show(struct class_device *cd, char *buf,
344 if(dev->wireless_handlers && 344 if(dev->wireless_handlers &&
345 dev->wireless_handlers->get_wireless_stats) 345 dev->wireless_handlers->get_wireless_stats)
346 iw = dev->wireless_handlers->get_wireless_stats(dev); 346 iw = dev->wireless_handlers->get_wireless_stats(dev);
347 else if (dev->get_wireless_stats)
348 iw = dev->get_wireless_stats(dev);
349 if (iw != NULL) 347 if (iw != NULL)
350 ret = (*format)(iw, buf); 348 ret = (*format)(iw, buf);
351 } 349 }
@@ -465,8 +463,7 @@ int netdev_register_sysfs(struct net_device *net)
465 *groups++ = &netstat_group; 463 *groups++ = &netstat_group;
466 464
467#ifdef WIRELESS_EXT 465#ifdef WIRELESS_EXT
468 if (net->get_wireless_stats 466 if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats)
469 || (net->wireless_handlers && net->wireless_handlers->get_wireless_stats))
470 *groups++ = &wireless_group; 467 *groups++ = &wireless_group;
471#endif 468#endif
472 469
diff --git a/net/core/wireless.c b/net/core/wireless.c
index 3168fca312f7..ffff0da46c6e 100644
--- a/net/core/wireless.c
+++ b/net/core/wireless.c
@@ -68,6 +68,14 @@
68 * 68 *
69 * v8 - 17.02.06 - Jean II 69 * v8 - 17.02.06 - Jean II
70 * o RtNetlink requests support (SET/GET) 70 * o RtNetlink requests support (SET/GET)
71 *
72 * v8b - 03.08.06 - Herbert Xu
73 * o Fix Wireless Event locking issues.
74 *
75 * v9 - 14.3.06 - Jean II
76 * o Change length in ESSID and NICK to strlen() instead of strlen()+1
77 * o Make standard_ioctl_num and standard_event_num unsigned
78 * o Remove (struct net_device *)->get_wireless_stats()
71 */ 79 */
72 80
73/***************************** INCLUDES *****************************/ 81/***************************** INCLUDES *****************************/
@@ -234,24 +242,24 @@ static const struct iw_ioctl_description standard_ioctl[] = {
234 [SIOCSIWESSID - SIOCIWFIRST] = { 242 [SIOCSIWESSID - SIOCIWFIRST] = {
235 .header_type = IW_HEADER_TYPE_POINT, 243 .header_type = IW_HEADER_TYPE_POINT,
236 .token_size = 1, 244 .token_size = 1,
237 .max_tokens = IW_ESSID_MAX_SIZE + 1, 245 .max_tokens = IW_ESSID_MAX_SIZE,
238 .flags = IW_DESCR_FLAG_EVENT, 246 .flags = IW_DESCR_FLAG_EVENT,
239 }, 247 },
240 [SIOCGIWESSID - SIOCIWFIRST] = { 248 [SIOCGIWESSID - SIOCIWFIRST] = {
241 .header_type = IW_HEADER_TYPE_POINT, 249 .header_type = IW_HEADER_TYPE_POINT,
242 .token_size = 1, 250 .token_size = 1,
243 .max_tokens = IW_ESSID_MAX_SIZE + 1, 251 .max_tokens = IW_ESSID_MAX_SIZE,
244 .flags = IW_DESCR_FLAG_DUMP, 252 .flags = IW_DESCR_FLAG_DUMP,
245 }, 253 },
246 [SIOCSIWNICKN - SIOCIWFIRST] = { 254 [SIOCSIWNICKN - SIOCIWFIRST] = {
247 .header_type = IW_HEADER_TYPE_POINT, 255 .header_type = IW_HEADER_TYPE_POINT,
248 .token_size = 1, 256 .token_size = 1,
249 .max_tokens = IW_ESSID_MAX_SIZE + 1, 257 .max_tokens = IW_ESSID_MAX_SIZE,
250 }, 258 },
251 [SIOCGIWNICKN - SIOCIWFIRST] = { 259 [SIOCGIWNICKN - SIOCIWFIRST] = {
252 .header_type = IW_HEADER_TYPE_POINT, 260 .header_type = IW_HEADER_TYPE_POINT,
253 .token_size = 1, 261 .token_size = 1,
254 .max_tokens = IW_ESSID_MAX_SIZE + 1, 262 .max_tokens = IW_ESSID_MAX_SIZE,
255 }, 263 },
256 [SIOCSIWRATE - SIOCIWFIRST] = { 264 [SIOCSIWRATE - SIOCIWFIRST] = {
257 .header_type = IW_HEADER_TYPE_PARAM, 265 .header_type = IW_HEADER_TYPE_PARAM,
@@ -338,8 +346,8 @@ static const struct iw_ioctl_description standard_ioctl[] = {
338 .max_tokens = sizeof(struct iw_pmksa), 346 .max_tokens = sizeof(struct iw_pmksa),
339 }, 347 },
340}; 348};
341static const int standard_ioctl_num = (sizeof(standard_ioctl) / 349static const unsigned standard_ioctl_num = (sizeof(standard_ioctl) /
342 sizeof(struct iw_ioctl_description)); 350 sizeof(struct iw_ioctl_description));
343 351
344/* 352/*
345 * Meta-data about all the additional standard Wireless Extension events 353 * Meta-data about all the additional standard Wireless Extension events
@@ -389,8 +397,8 @@ static const struct iw_ioctl_description standard_event[] = {
389 .max_tokens = sizeof(struct iw_pmkid_cand), 397 .max_tokens = sizeof(struct iw_pmkid_cand),
390 }, 398 },
391}; 399};
392static const int standard_event_num = (sizeof(standard_event) / 400static const unsigned standard_event_num = (sizeof(standard_event) /
393 sizeof(struct iw_ioctl_description)); 401 sizeof(struct iw_ioctl_description));
394 402
395/* Size (in bytes) of the various private data types */ 403/* Size (in bytes) of the various private data types */
396static const char iw_priv_type_size[] = { 404static const char iw_priv_type_size[] = {
@@ -465,17 +473,6 @@ static inline struct iw_statistics *get_wireless_stats(struct net_device *dev)
465 (dev->wireless_handlers->get_wireless_stats != NULL)) 473 (dev->wireless_handlers->get_wireless_stats != NULL))
466 return dev->wireless_handlers->get_wireless_stats(dev); 474 return dev->wireless_handlers->get_wireless_stats(dev);
467 475
468 /* Old location, field to be removed in next WE */
469 if(dev->get_wireless_stats) {
470 static int printed_message;
471
472 if (!printed_message++)
473 printk(KERN_DEBUG "%s (WE) : Driver using old /proc/net/wireless support, please fix driver !\n",
474 dev->name);
475
476 return dev->get_wireless_stats(dev);
477 }
478
479 /* Not found */ 476 /* Not found */
480 return (struct iw_statistics *) NULL; 477 return (struct iw_statistics *) NULL;
481} 478}
@@ -1843,8 +1840,33 @@ int wireless_rtnetlink_set(struct net_device * dev,
1843 */ 1840 */
1844 1841
1845#ifdef WE_EVENT_RTNETLINK 1842#ifdef WE_EVENT_RTNETLINK
1843/* ---------------------------------------------------------------- */
1844/*
1845 * Locking...
1846 * ----------
1847 *
1848 * Thanks to Herbert Xu <herbert@gondor.apana.org.au> for fixing
1849 * the locking issue in here and implementing this code !
1850 *
1851 * The issue : wireless_send_event() is often called in interrupt context,
1852 * while the Netlink layer can never be called in interrupt context.
1853 * The fully formed RtNetlink events are queued, and then a tasklet is run
1854 * to feed those to Netlink.
1855 * The skb_queue is interrupt safe, and its lock is not held while calling
1856 * Netlink, so there is no possibility of dealock.
1857 * Jean II
1858 */
1859
1846static struct sk_buff_head wireless_nlevent_queue; 1860static struct sk_buff_head wireless_nlevent_queue;
1847 1861
1862static int __init wireless_nlevent_init(void)
1863{
1864 skb_queue_head_init(&wireless_nlevent_queue);
1865 return 0;
1866}
1867
1868subsys_initcall(wireless_nlevent_init);
1869
1848static void wireless_nlevent_process(unsigned long data) 1870static void wireless_nlevent_process(unsigned long data)
1849{ 1871{
1850 struct sk_buff *skb; 1872 struct sk_buff *skb;
@@ -1921,13 +1943,6 @@ static inline void rtmsg_iwinfo(struct net_device * dev,
1921 tasklet_schedule(&wireless_nlevent_tasklet); 1943 tasklet_schedule(&wireless_nlevent_tasklet);
1922} 1944}
1923 1945
1924static int __init wireless_nlevent_init(void)
1925{
1926 skb_queue_head_init(&wireless_nlevent_queue);
1927 return 0;
1928}
1929
1930subsys_initcall(wireless_nlevent_init);
1931#endif /* WE_EVENT_RTNETLINK */ 1946#endif /* WE_EVENT_RTNETLINK */
1932 1947
1933/* ---------------------------------------------------------------- */ 1948/* ---------------------------------------------------------------- */
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index 75320b6842ab..2aa779d18f38 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -80,10 +80,10 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
80 * If it's our network, ignore the change, we're already doing it! 80 * If it's our network, ignore the change, we're already doing it!
81 */ 81 */
82 if((sm->associnfo.associating || sm->associated) && 82 if((sm->associnfo.associating || sm->associated) &&
83 (data->essid.flags && data->essid.length && extra)) { 83 (data->essid.flags && data->essid.length)) {
84 /* Get the associating network */ 84 /* Get the associating network */
85 n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid); 85 n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid);
86 if(n && n->essid.len == (data->essid.length - 1) && 86 if(n && n->essid.len == data->essid.length &&
87 !memcmp(n->essid.data, extra, n->essid.len)) { 87 !memcmp(n->essid.data, extra, n->essid.len)) {
88 dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n", 88 dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n",
89 MAC_ARG(sm->associnfo.bssid)); 89 MAC_ARG(sm->associnfo.bssid));
@@ -109,8 +109,8 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
109 sm->associnfo.static_essid = 0; 109 sm->associnfo.static_essid = 0;
110 sm->associnfo.assoc_wait = 0; 110 sm->associnfo.assoc_wait = 0;
111 111
112 if (data->essid.flags && data->essid.length && extra /*required?*/) { 112 if (data->essid.flags && data->essid.length) {
113 length = min(data->essid.length - 1, IW_ESSID_MAX_SIZE); 113 length = min((int)data->essid.length, IW_ESSID_MAX_SIZE);
114 if (length) { 114 if (length) {
115 memcpy(sm->associnfo.req_essid.data, extra, length); 115 memcpy(sm->associnfo.req_essid.data, extra, length);
116 sm->associnfo.static_essid = 1; 116 sm->associnfo.static_essid = 1;