aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/3c523.c9
-rw-r--r--drivers/net/3c59x.c3
-rw-r--r--drivers/net/apne.c7
-rw-r--r--drivers/net/arcnet/arc-rawmode.c2
-rw-r--r--drivers/net/arcnet/arcnet.c20
-rw-r--r--drivers/net/arcnet/rfc1051.c2
-rw-r--r--drivers/net/arcnet/rfc1201.c2
-rw-r--r--drivers/net/arm/etherh.c3
-rw-r--r--drivers/net/eth16i.c11
-rw-r--r--drivers/net/hamradio/baycom_epp.c2
-rw-r--r--drivers/net/hp100.c5
-rw-r--r--drivers/net/mv643xx_eth.c702
-rw-r--r--drivers/net/mv643xx_eth.h21
-rw-r--r--drivers/net/ne-h8300.c5
-rw-r--r--drivers/net/ne.c7
-rw-r--r--drivers/net/ne2.c7
-rw-r--r--drivers/net/ns83820.c5
-rw-r--r--drivers/net/oaknet.c3
-rw-r--r--drivers/net/pcmcia/3c589_cs.c3
-rw-r--r--drivers/net/ppp_async.c3
-rw-r--r--drivers/net/s2io.c22
-rw-r--r--drivers/net/s2io.h17
-rw-r--r--drivers/net/seeq8005.c5
-rw-r--r--drivers/net/shaper.c3
-rw-r--r--drivers/net/sk98lin/h/skaddr.h48
-rw-r--r--drivers/net/sk98lin/h/skcsum.h6
-rw-r--r--drivers/net/sk98lin/h/skgeinit.h56
-rw-r--r--drivers/net/sk98lin/h/skgepnmi.h4
-rw-r--r--drivers/net/sk98lin/h/skgesirq.h1
-rw-r--r--drivers/net/sk98lin/h/ski2c.h3
-rw-r--r--drivers/net/sk98lin/h/skvpd.h15
-rw-r--r--drivers/net/sk98lin/skaddr.c35
-rw-r--r--drivers/net/sk98lin/skgeinit.c148
-rw-r--r--drivers/net/sk98lin/skgemib.c7
-rw-r--r--drivers/net/sk98lin/skgepnmi.c153
-rw-r--r--drivers/net/sk98lin/skgesirq.c24
-rw-r--r--drivers/net/sk98lin/ski2c.c6
-rw-r--r--drivers/net/sk98lin/sklm80.c72
-rw-r--r--drivers/net/sk98lin/skrlmt.c1
-rw-r--r--drivers/net/sk98lin/skvpd.c108
-rw-r--r--drivers/net/sk98lin/skxmac2.c461
-rw-r--r--drivers/net/starfire.c36
-rw-r--r--drivers/net/sundance.c6
-rw-r--r--drivers/net/tokenring/lanstreamer.c3
-rw-r--r--drivers/net/tokenring/olympic.c9
-rw-r--r--drivers/net/tulip/de2104x.c18
-rw-r--r--drivers/net/tulip/pnic.c3
-rw-r--r--drivers/net/tulip/winbond-840.c2
-rw-r--r--drivers/net/tulip/xircom_cb.c6
-rw-r--r--drivers/net/wireless/Kconfig7
-rw-r--r--drivers/net/wireless/airo.c331
-rw-r--r--drivers/net/wireless/ipw2100.c48
-rw-r--r--drivers/net/wireless/ipw2100.h6
-rw-r--r--drivers/net/wireless/ipw2200.c876
-rw-r--r--drivers/net/wireless/ipw2200.h64
-rw-r--r--drivers/net/wireless/netwave_cs.c2
-rw-r--r--drivers/net/wireless/strip.c4
-rw-r--r--drivers/net/wireless/wavelan.p.h6
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h9
-rw-r--r--drivers/net/zorro8390.c7
60 files changed, 1363 insertions, 2097 deletions
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index 9e1fe2e0478c..b40885d41680 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -105,6 +105,7 @@
105#include <linux/mca-legacy.h> 105#include <linux/mca-legacy.h>
106#include <linux/ethtool.h> 106#include <linux/ethtool.h>
107#include <linux/bitops.h> 107#include <linux/bitops.h>
108#include <linux/jiffies.h>
108 109
109#include <asm/uaccess.h> 110#include <asm/uaccess.h>
110#include <asm/processor.h> 111#include <asm/processor.h>
@@ -658,7 +659,7 @@ static int init586(struct net_device *dev)
658 659
659 s = jiffies; /* warning: only active with interrupts on !! */ 660 s = jiffies; /* warning: only active with interrupts on !! */
660 while (!(cfg_cmd->cmd_status & STAT_COMPL)) { 661 while (!(cfg_cmd->cmd_status & STAT_COMPL)) {
661 if (jiffies - s > 30*HZ/100) 662 if (time_after(jiffies, s + 30*HZ/100))
662 break; 663 break;
663 } 664 }
664 665
@@ -684,7 +685,7 @@ static int init586(struct net_device *dev)
684 685
685 s = jiffies; 686 s = jiffies;
686 while (!(ias_cmd->cmd_status & STAT_COMPL)) { 687 while (!(ias_cmd->cmd_status & STAT_COMPL)) {
687 if (jiffies - s > 30*HZ/100) 688 if (time_after(jiffies, s + 30*HZ/100))
688 break; 689 break;
689 } 690 }
690 691
@@ -709,7 +710,7 @@ static int init586(struct net_device *dev)
709 710
710 s = jiffies; 711 s = jiffies;
711 while (!(tdr_cmd->cmd_status & STAT_COMPL)) { 712 while (!(tdr_cmd->cmd_status & STAT_COMPL)) {
712 if (jiffies - s > 30*HZ/100) { 713 if (time_after(jiffies, s + 30*HZ/100)) {
713 printk(KERN_WARNING "%s: %d Problems while running the TDR.\n", dev->name, __LINE__); 714 printk(KERN_WARNING "%s: %d Problems while running the TDR.\n", dev->name, __LINE__);
714 result = 1; 715 result = 1;
715 break; 716 break;
@@ -798,7 +799,7 @@ static int init586(struct net_device *dev)
798 elmc_id_attn586(); 799 elmc_id_attn586();
799 s = jiffies; 800 s = jiffies;
800 while (!(mc_cmd->cmd_status & STAT_COMPL)) { 801 while (!(mc_cmd->cmd_status & STAT_COMPL)) {
801 if (jiffies - s > 30*HZ/100) 802 if (time_after(jiffies, s + 30*HZ/100))
802 break; 803 break;
803 } 804 }
804 if (!(mc_cmd->cmd_status & STAT_COMPL)) { 805 if (!(mc_cmd->cmd_status & STAT_COMPL)) {
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 7f47124f118d..9e8897976a69 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -258,6 +258,7 @@ static int vortex_debug = 1;
258#include <linux/highmem.h> 258#include <linux/highmem.h>
259#include <linux/eisa.h> 259#include <linux/eisa.h>
260#include <linux/bitops.h> 260#include <linux/bitops.h>
261#include <linux/jiffies.h>
261#include <asm/irq.h> /* For NR_IRQS only. */ 262#include <asm/irq.h> /* For NR_IRQS only. */
262#include <asm/io.h> 263#include <asm/io.h>
263#include <asm/uaccess.h> 264#include <asm/uaccess.h>
@@ -2724,7 +2725,7 @@ boomerang_rx(struct net_device *dev)
2724 skb = dev_alloc_skb(PKT_BUF_SZ); 2725 skb = dev_alloc_skb(PKT_BUF_SZ);
2725 if (skb == NULL) { 2726 if (skb == NULL) {
2726 static unsigned long last_jif; 2727 static unsigned long last_jif;
2727 if ((jiffies - last_jif) > 10 * HZ) { 2728 if (time_after(jiffies, last_jif + 10 * HZ)) {
2728 printk(KERN_WARNING "%s: memory shortage\n", dev->name); 2729 printk(KERN_WARNING "%s: memory shortage\n", dev->name);
2729 last_jif = jiffies; 2730 last_jif = jiffies;
2730 } 2731 }
diff --git a/drivers/net/apne.c b/drivers/net/apne.c
index a94216b87184..b9820b86cdcc 100644
--- a/drivers/net/apne.c
+++ b/drivers/net/apne.c
@@ -36,6 +36,7 @@
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/netdevice.h> 37#include <linux/netdevice.h>
38#include <linux/etherdevice.h> 38#include <linux/etherdevice.h>
39#include <linux/jiffies.h>
39 40
40#include <asm/system.h> 41#include <asm/system.h>
41#include <asm/io.h> 42#include <asm/io.h>
@@ -216,7 +217,7 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
216 outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET); 217 outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
217 218
218 while ((inb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0) 219 while ((inb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0)
219 if (jiffies - reset_start_time > 2*HZ/100) { 220 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
220 printk(" not found (no reset ack).\n"); 221 printk(" not found (no reset ack).\n");
221 return -ENODEV; 222 return -ENODEV;
222 } 223 }
@@ -382,7 +383,7 @@ apne_reset_8390(struct net_device *dev)
382 383
383 /* This check _should_not_ be necessary, omit eventually. */ 384 /* This check _should_not_ be necessary, omit eventually. */
384 while ((inb(NE_BASE+NE_EN0_ISR) & ENISR_RESET) == 0) 385 while ((inb(NE_BASE+NE_EN0_ISR) & ENISR_RESET) == 0)
385 if (jiffies - reset_start_time > 2*HZ/100) { 386 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
386 printk("%s: ne_reset_8390() did not complete.\n", dev->name); 387 printk("%s: ne_reset_8390() did not complete.\n", dev->name);
387 break; 388 break;
388 } 389 }
@@ -530,7 +531,7 @@ apne_block_output(struct net_device *dev, int count,
530 dma_start = jiffies; 531 dma_start = jiffies;
531 532
532 while ((inb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0) 533 while ((inb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0)
533 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ 534 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
534 printk("%s: timeout waiting for Tx RDC.\n", dev->name); 535 printk("%s: timeout waiting for Tx RDC.\n", dev->name);
535 apne_reset_8390(dev); 536 apne_reset_8390(dev);
536 NS8390_init(dev,1); 537 NS8390_init(dev,1);
diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index e1ea29b0cd14..e7555d4e6ff1 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -42,7 +42,7 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
42static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length, 42static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
43 int bufnum); 43 int bufnum);
44 44
45struct ArcProto rawmode_proto = 45static struct ArcProto rawmode_proto =
46{ 46{
47 .suffix = 'r', 47 .suffix = 'r',
48 .mtu = XMTU, 48 .mtu = XMTU,
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 12ef52c193a3..64e2caf3083d 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -52,6 +52,7 @@
52#include <net/arp.h> 52#include <net/arp.h>
53#include <linux/init.h> 53#include <linux/init.h>
54#include <linux/arcdevice.h> 54#include <linux/arcdevice.h>
55#include <linux/jiffies.h>
55 56
56/* "do nothing" functions for protocol drivers */ 57/* "do nothing" functions for protocol drivers */
57static void null_rx(struct net_device *dev, int bufnum, 58static void null_rx(struct net_device *dev, int bufnum,
@@ -61,6 +62,7 @@ static int null_build_header(struct sk_buff *skb, struct net_device *dev,
61static int null_prepare_tx(struct net_device *dev, struct archdr *pkt, 62static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
62 int length, int bufnum); 63 int length, int bufnum);
63 64
65static void arcnet_rx(struct net_device *dev, int bufnum);
64 66
65/* 67/*
66 * one ArcProto per possible proto ID. None of the elements of 68 * one ArcProto per possible proto ID. None of the elements of
@@ -71,7 +73,7 @@ static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
71 struct ArcProto *arc_proto_map[256], *arc_proto_default, 73 struct ArcProto *arc_proto_map[256], *arc_proto_default,
72 *arc_bcast_proto, *arc_raw_proto; 74 *arc_bcast_proto, *arc_raw_proto;
73 75
74struct ArcProto arc_proto_null = 76static struct ArcProto arc_proto_null =
75{ 77{
76 .suffix = '?', 78 .suffix = '?',
77 .mtu = XMTU, 79 .mtu = XMTU,
@@ -90,7 +92,6 @@ EXPORT_SYMBOL(arc_proto_map);
90EXPORT_SYMBOL(arc_proto_default); 92EXPORT_SYMBOL(arc_proto_default);
91EXPORT_SYMBOL(arc_bcast_proto); 93EXPORT_SYMBOL(arc_bcast_proto);
92EXPORT_SYMBOL(arc_raw_proto); 94EXPORT_SYMBOL(arc_raw_proto);
93EXPORT_SYMBOL(arc_proto_null);
94EXPORT_SYMBOL(arcnet_unregister_proto); 95EXPORT_SYMBOL(arcnet_unregister_proto);
95EXPORT_SYMBOL(arcnet_debug); 96EXPORT_SYMBOL(arcnet_debug);
96EXPORT_SYMBOL(alloc_arcdev); 97EXPORT_SYMBOL(alloc_arcdev);
@@ -118,7 +119,7 @@ static int __init arcnet_init(void)
118 119
119 arcnet_debug = debug; 120 arcnet_debug = debug;
120 121
121 printk(VERSION); 122 printk("arcnet loaded.\n");
122 123
123#ifdef ALPHA_WARNING 124#ifdef ALPHA_WARNING
124 BUGLVL(D_EXTRA) { 125 BUGLVL(D_EXTRA) {
@@ -178,8 +179,8 @@ EXPORT_SYMBOL(arcnet_dump_skb);
178 * Dump the contents of an ARCnet buffer 179 * Dump the contents of an ARCnet buffer
179 */ 180 */
180#if (ARCNET_DEBUG_MAX & (D_RX | D_TX)) 181#if (ARCNET_DEBUG_MAX & (D_RX | D_TX))
181void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc, 182static void arcnet_dump_packet(struct net_device *dev, int bufnum,
182 int take_arcnet_lock) 183 char *desc, int take_arcnet_lock)
183{ 184{
184 struct arcnet_local *lp = dev->priv; 185 struct arcnet_local *lp = dev->priv;
185 int i, length; 186 int i, length;
@@ -208,7 +209,10 @@ void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc,
208 209
209} 210}
210 211
211EXPORT_SYMBOL(arcnet_dump_packet); 212#else
213
214#define arcnet_dump_packet(dev, bufnum, desc,take_arcnet_lock) do { } while (0)
215
212#endif 216#endif
213 217
214 218
@@ -733,7 +737,7 @@ static void arcnet_timeout(struct net_device *dev)
733 737
734 spin_unlock_irqrestore(&lp->lock, flags); 738 spin_unlock_irqrestore(&lp->lock, flags);
735 739
736 if (jiffies - lp->last_timeout > 10*HZ) { 740 if (time_after(jiffies, lp->last_timeout + 10*HZ)) {
737 BUGMSG(D_EXTRA, "tx timed out%s (status=%Xh, intmask=%Xh, dest=%02Xh)\n", 741 BUGMSG(D_EXTRA, "tx timed out%s (status=%Xh, intmask=%Xh, dest=%02Xh)\n",
738 msg, status, lp->intmask, lp->lasttrans_dest); 742 msg, status, lp->intmask, lp->lasttrans_dest);
739 lp->last_timeout = jiffies; 743 lp->last_timeout = jiffies;
@@ -996,7 +1000,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
996 * This is a generic packet receiver that calls arcnet??_rx depending on the 1000 * This is a generic packet receiver that calls arcnet??_rx depending on the
997 * protocol ID found. 1001 * protocol ID found.
998 */ 1002 */
999void arcnet_rx(struct net_device *dev, int bufnum) 1003static void arcnet_rx(struct net_device *dev, int bufnum)
1000{ 1004{
1001 struct arcnet_local *lp = dev->priv; 1005 struct arcnet_local *lp = dev->priv;
1002 struct archdr pkt; 1006 struct archdr pkt;
diff --git a/drivers/net/arcnet/rfc1051.c b/drivers/net/arcnet/rfc1051.c
index 6d7913704fb5..6d6c69f036ef 100644
--- a/drivers/net/arcnet/rfc1051.c
+++ b/drivers/net/arcnet/rfc1051.c
@@ -43,7 +43,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
43 int bufnum); 43 int bufnum);
44 44
45 45
46struct ArcProto rfc1051_proto = 46static struct ArcProto rfc1051_proto =
47{ 47{
48 .suffix = 's', 48 .suffix = 's',
49 .mtu = XMTU - RFC1051_HDR_SIZE, 49 .mtu = XMTU - RFC1051_HDR_SIZE,
diff --git a/drivers/net/arcnet/rfc1201.c b/drivers/net/arcnet/rfc1201.c
index 6b6ae4bf3d39..bee34226abfa 100644
--- a/drivers/net/arcnet/rfc1201.c
+++ b/drivers/net/arcnet/rfc1201.c
@@ -43,7 +43,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
43 int bufnum); 43 int bufnum);
44static int continue_tx(struct net_device *dev, int bufnum); 44static int continue_tx(struct net_device *dev, int bufnum);
45 45
46struct ArcProto rfc1201_proto = 46static struct ArcProto rfc1201_proto =
47{ 47{
48 .suffix = 'a', 48 .suffix = 'a',
49 .mtu = 1500, /* could be more, but some receivers can't handle it... */ 49 .mtu = 1500, /* could be more, but some receivers can't handle it... */
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 6a93b666eb72..d52deb8d2075 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -46,6 +46,7 @@
46#include <linux/device.h> 46#include <linux/device.h>
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/bitops.h> 48#include <linux/bitops.h>
49#include <linux/jiffies.h>
49 50
50#include <asm/system.h> 51#include <asm/system.h>
51#include <asm/ecard.h> 52#include <asm/ecard.h>
@@ -355,7 +356,7 @@ etherh_block_output (struct net_device *dev, int count, const unsigned char *buf
355 dma_start = jiffies; 356 dma_start = jiffies;
356 357
357 while ((readb (addr + EN0_ISR) & ENISR_RDC) == 0) 358 while ((readb (addr + EN0_ISR) & ENISR_RDC) == 0)
358 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ 359 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
359 printk(KERN_ERR "%s: timeout waiting for TX RDC\n", 360 printk(KERN_ERR "%s: timeout waiting for TX RDC\n",
360 dev->name); 361 dev->name);
361 etherh_reset (dev); 362 etherh_reset (dev);
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index f32a6b3acb2a..b67545be2caa 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -161,6 +161,7 @@ static char *version =
161#include <linux/etherdevice.h> 161#include <linux/etherdevice.h>
162#include <linux/skbuff.h> 162#include <linux/skbuff.h>
163#include <linux/bitops.h> 163#include <linux/bitops.h>
164#include <linux/jiffies.h>
164 165
165#include <asm/system.h> 166#include <asm/system.h>
166#include <asm/io.h> 167#include <asm/io.h>
@@ -754,7 +755,7 @@ static void eth16i_set_port(int ioaddr, int porttype)
754 755
755static int eth16i_send_probe_packet(int ioaddr, unsigned char *b, int l) 756static int eth16i_send_probe_packet(int ioaddr, unsigned char *b, int l)
756{ 757{
757 int starttime; 758 unsigned long starttime;
758 759
759 outb(0xff, ioaddr + TX_STATUS_REG); 760 outb(0xff, ioaddr + TX_STATUS_REG);
760 761
@@ -765,7 +766,7 @@ static int eth16i_send_probe_packet(int ioaddr, unsigned char *b, int l)
765 outb(TX_START | 1, ioaddr + TRANSMIT_START_REG); 766 outb(TX_START | 1, ioaddr + TRANSMIT_START_REG);
766 767
767 while( (inb(ioaddr + TX_STATUS_REG) & 0x80) == 0) { 768 while( (inb(ioaddr + TX_STATUS_REG) & 0x80) == 0) {
768 if( (jiffies - starttime) > TX_TIMEOUT) { 769 if( time_after(jiffies, starttime + TX_TIMEOUT)) {
769 return -1; 770 return -1;
770 } 771 }
771 } 772 }
@@ -775,18 +776,18 @@ static int eth16i_send_probe_packet(int ioaddr, unsigned char *b, int l)
775 776
776static int eth16i_receive_probe_packet(int ioaddr) 777static int eth16i_receive_probe_packet(int ioaddr)
777{ 778{
778 int starttime; 779 unsigned long starttime;
779 780
780 starttime = jiffies; 781 starttime = jiffies;
781 782
782 while((inb(ioaddr + TX_STATUS_REG) & 0x20) == 0) { 783 while((inb(ioaddr + TX_STATUS_REG) & 0x20) == 0) {
783 if( (jiffies - starttime) > TX_TIMEOUT) { 784 if( time_after(jiffies, starttime + TX_TIMEOUT)) {
784 785
785 if(eth16i_debug > 1) 786 if(eth16i_debug > 1)
786 printk(KERN_DEBUG "Timeout occurred waiting transmit packet received\n"); 787 printk(KERN_DEBUG "Timeout occurred waiting transmit packet received\n");
787 starttime = jiffies; 788 starttime = jiffies;
788 while((inb(ioaddr + RX_STATUS_REG) & 0x80) == 0) { 789 while((inb(ioaddr + RX_STATUS_REG) & 0x80) == 0) {
789 if( (jiffies - starttime) > TX_TIMEOUT) { 790 if( time_after(jiffies, starttime + TX_TIMEOUT)) {
790 if(eth16i_debug > 1) 791 if(eth16i_debug > 1)
791 printk(KERN_DEBUG "Timeout occurred waiting receive packet\n"); 792 printk(KERN_DEBUG "Timeout occurred waiting receive packet\n");
792 return -1; 793 return -1;
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index e4188d082f01..9220de9f4fe7 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -905,7 +905,7 @@ static int epp_open(struct net_device *dev)
905 /* autoprobe baud rate */ 905 /* autoprobe baud rate */
906 tstart = jiffies; 906 tstart = jiffies;
907 i = 0; 907 i = 0;
908 while ((signed)(jiffies-tstart-HZ/3) < 0) { 908 while (time_before(jiffies, tstart + HZ/3)) {
909 if (pp->ops->epp_read_addr(pp, &stat, 1, 0) != 1) 909 if (pp->ops->epp_read_addr(pp, &stat, 1, 0) != 1)
910 goto epptimeout; 910 goto epptimeout;
911 if ((stat & (EPP_NRAEF|EPP_NRHF)) == EPP_NRHF) { 911 if ((stat & (EPP_NRAEF|EPP_NRHF)) == EPP_NRHF) {
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index 7ba87b7ee612..247c8ca86033 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -115,6 +115,7 @@
115#include <linux/delay.h> 115#include <linux/delay.h>
116#include <linux/init.h> 116#include <linux/init.h>
117#include <linux/bitops.h> 117#include <linux/bitops.h>
118#include <linux/jiffies.h>
118 119
119#include <asm/io.h> 120#include <asm/io.h>
120 121
@@ -1499,7 +1500,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
1499 printk("hp100: %s: start_xmit_bm: No TX PDL available.\n", dev->name); 1500 printk("hp100: %s: start_xmit_bm: No TX PDL available.\n", dev->name);
1500#endif 1501#endif
1501 /* not waited long enough since last tx? */ 1502 /* not waited long enough since last tx? */
1502 if (jiffies - dev->trans_start < HZ) 1503 if (time_before(jiffies, dev->trans_start + HZ))
1503 return -EAGAIN; 1504 return -EAGAIN;
1504 1505
1505 if (hp100_check_lan(dev)) 1506 if (hp100_check_lan(dev))
@@ -1652,7 +1653,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev)
1652 printk("hp100: %s: start_xmit: tx free mem = 0x%x\n", dev->name, i); 1653 printk("hp100: %s: start_xmit: tx free mem = 0x%x\n", dev->name, i);
1653#endif 1654#endif
1654 /* not waited long enough since last failed tx try? */ 1655 /* not waited long enough since last failed tx try? */
1655 if (jiffies - dev->trans_start < HZ) { 1656 if (time_before(jiffies, dev->trans_start + HZ)) {
1656#ifdef HP100_DEBUG 1657#ifdef HP100_DEBUG
1657 printk("hp100: %s: trans_start timing problem\n", 1658 printk("hp100: %s: trans_start timing problem\n",
1658 dev->name); 1659 dev->name);
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index c0998ef938e0..6b4fff80ae5f 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -81,10 +81,15 @@
81#define PHY_WAIT_MICRO_SECONDS 10 81#define PHY_WAIT_MICRO_SECONDS 10
82 82
83/* Static function declarations */ 83/* Static function declarations */
84static int eth_port_link_is_up(unsigned int eth_port_num);
85static void eth_port_uc_addr_get(struct net_device *dev, 84static void eth_port_uc_addr_get(struct net_device *dev,
86 unsigned char *MacAddr); 85 unsigned char *MacAddr);
87static void eth_port_set_multicast_list(struct net_device *); 86static void eth_port_set_multicast_list(struct net_device *);
87static void mv643xx_eth_port_enable_tx(unsigned int port_num,
88 unsigned int channels);
89static void mv643xx_eth_port_enable_rx(unsigned int port_num,
90 unsigned int channels);
91static unsigned int mv643xx_eth_port_disable_tx(unsigned int port_num);
92static unsigned int mv643xx_eth_port_disable_rx(unsigned int port_num);
88static int mv643xx_eth_open(struct net_device *); 93static int mv643xx_eth_open(struct net_device *);
89static int mv643xx_eth_stop(struct net_device *); 94static int mv643xx_eth_stop(struct net_device *);
90static int mv643xx_eth_change_mtu(struct net_device *, int); 95static int mv643xx_eth_change_mtu(struct net_device *, int);
@@ -93,8 +98,12 @@ static void eth_port_init_mac_tables(unsigned int eth_port_num);
93#ifdef MV643XX_NAPI 98#ifdef MV643XX_NAPI
94static int mv643xx_poll(struct net_device *dev, int *budget); 99static int mv643xx_poll(struct net_device *dev, int *budget);
95#endif 100#endif
101static int ethernet_phy_get(unsigned int eth_port_num);
96static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr); 102static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
97static int ethernet_phy_detect(unsigned int eth_port_num); 103static int ethernet_phy_detect(unsigned int eth_port_num);
104static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location);
105static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val);
106static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
98static struct ethtool_ops mv643xx_ethtool_ops; 107static struct ethtool_ops mv643xx_ethtool_ops;
99 108
100static char mv643xx_driver_name[] = "mv643xx_eth"; 109static char mv643xx_driver_name[] = "mv643xx_eth";
@@ -171,11 +180,11 @@ static void mv643xx_eth_rx_task(void *data)
171 if (test_and_set_bit(0, &mp->rx_task_busy)) 180 if (test_and_set_bit(0, &mp->rx_task_busy))
172 panic("%s: Error in test_set_bit / clear_bit", dev->name); 181 panic("%s: Error in test_set_bit / clear_bit", dev->name);
173 182
174 while (mp->rx_ring_skbs < (mp->rx_ring_size - 5)) { 183 while (mp->rx_desc_count < (mp->rx_ring_size - 5)) {
175 skb = dev_alloc_skb(RX_SKB_SIZE + DMA_ALIGN); 184 skb = dev_alloc_skb(RX_SKB_SIZE + DMA_ALIGN);
176 if (!skb) 185 if (!skb)
177 break; 186 break;
178 mp->rx_ring_skbs++; 187 mp->rx_desc_count++;
179 unaligned = (u32)skb->data & (DMA_ALIGN - 1); 188 unaligned = (u32)skb->data & (DMA_ALIGN - 1);
180 if (unaligned) 189 if (unaligned)
181 skb_reserve(skb, DMA_ALIGN - unaligned); 190 skb_reserve(skb, DMA_ALIGN - unaligned);
@@ -196,7 +205,7 @@ static void mv643xx_eth_rx_task(void *data)
196 * If RX ring is empty of SKB, set a timer to try allocating 205 * If RX ring is empty of SKB, set a timer to try allocating
197 * again in a later time . 206 * again in a later time .
198 */ 207 */
199 if ((mp->rx_ring_skbs == 0) && (mp->rx_timer_flag == 0)) { 208 if ((mp->rx_desc_count == 0) && (mp->rx_timer_flag == 0)) {
200 printk(KERN_INFO "%s: Rx ring is empty\n", dev->name); 209 printk(KERN_INFO "%s: Rx ring is empty\n", dev->name);
201 /* After 100mSec */ 210 /* After 100mSec */
202 mp->timeout.expires = jiffies + (HZ / 10); 211 mp->timeout.expires = jiffies + (HZ / 10);
@@ -245,8 +254,7 @@ static void mv643xx_eth_update_mac_address(struct net_device *dev)
245 unsigned int port_num = mp->port_num; 254 unsigned int port_num = mp->port_num;
246 255
247 eth_port_init_mac_tables(port_num); 256 eth_port_init_mac_tables(port_num);
248 memcpy(mp->port_mac_addr, dev->dev_addr, 6); 257 eth_port_uc_addr_set(port_num, dev->dev_addr);
249 eth_port_uc_addr_set(port_num, mp->port_mac_addr);
250} 258}
251 259
252/* 260/*
@@ -260,13 +268,14 @@ static void mv643xx_eth_update_mac_address(struct net_device *dev)
260static void mv643xx_eth_set_rx_mode(struct net_device *dev) 268static void mv643xx_eth_set_rx_mode(struct net_device *dev)
261{ 269{
262 struct mv643xx_private *mp = netdev_priv(dev); 270 struct mv643xx_private *mp = netdev_priv(dev);
271 u32 config_reg;
263 272
273 config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num));
264 if (dev->flags & IFF_PROMISC) 274 if (dev->flags & IFF_PROMISC)
265 mp->port_config |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE; 275 config_reg |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
266 else 276 else
267 mp->port_config &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE; 277 config_reg &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
268 278 mv_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num), config_reg);
269 mv_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num), mp->port_config);
270 279
271 eth_port_set_multicast_list(dev); 280 eth_port_set_multicast_list(dev);
272} 281}
@@ -322,7 +331,7 @@ static void mv643xx_eth_tx_timeout_task(struct net_device *dev)
322 331
323 netif_device_detach(dev); 332 netif_device_detach(dev);
324 eth_port_reset(mp->port_num); 333 eth_port_reset(mp->port_num);
325 eth_port_start(mp); 334 eth_port_start(dev);
326 netif_device_attach(dev); 335 netif_device_attach(dev);
327} 336}
328 337
@@ -397,7 +406,7 @@ static int mv643xx_eth_receive_queue(struct net_device *dev)
397#else 406#else
398 while (eth_port_receive(mp, &pkt_info) == ETH_OK) { 407 while (eth_port_receive(mp, &pkt_info) == ETH_OK) {
399#endif 408#endif
400 mp->rx_ring_skbs--; 409 mp->rx_desc_count--;
401 received_packets++; 410 received_packets++;
402 411
403 /* Update statistics. Note byte count includes 4 byte CRC count */ 412 /* Update statistics. Note byte count includes 4 byte CRC count */
@@ -452,6 +461,56 @@ static int mv643xx_eth_receive_queue(struct net_device *dev)
452 return received_packets; 461 return received_packets;
453} 462}
454 463
464/* Set the mv643xx port configuration register for the speed/duplex mode. */
465static void mv643xx_eth_update_pscr(struct net_device *dev,
466 struct ethtool_cmd *ecmd)
467{
468 struct mv643xx_private *mp = netdev_priv(dev);
469 int port_num = mp->port_num;
470 u32 o_pscr, n_pscr;
471 unsigned int channels;
472
473 o_pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
474 n_pscr = o_pscr;
475
476 /* clear speed, duplex and rx buffer size fields */
477 n_pscr &= ~(MV643XX_ETH_SET_MII_SPEED_TO_100 |
478 MV643XX_ETH_SET_GMII_SPEED_TO_1000 |
479 MV643XX_ETH_SET_FULL_DUPLEX_MODE |
480 MV643XX_ETH_MAX_RX_PACKET_MASK);
481
482 if (ecmd->duplex == DUPLEX_FULL)
483 n_pscr |= MV643XX_ETH_SET_FULL_DUPLEX_MODE;
484
485 if (ecmd->speed == SPEED_1000)
486 n_pscr |= MV643XX_ETH_SET_GMII_SPEED_TO_1000 |
487 MV643XX_ETH_MAX_RX_PACKET_9700BYTE;
488 else {
489 if (ecmd->speed == SPEED_100)
490 n_pscr |= MV643XX_ETH_SET_MII_SPEED_TO_100;
491 n_pscr |= MV643XX_ETH_MAX_RX_PACKET_1522BYTE;
492 }
493
494 if (n_pscr != o_pscr) {
495 if ((o_pscr & MV643XX_ETH_SERIAL_PORT_ENABLE) == 0)
496 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
497 n_pscr);
498 else {
499 channels = mv643xx_eth_port_disable_tx(port_num);
500
501 o_pscr &= ~MV643XX_ETH_SERIAL_PORT_ENABLE;
502 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
503 o_pscr);
504 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
505 n_pscr);
506 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
507 n_pscr);
508 if (channels)
509 mv643xx_eth_port_enable_tx(port_num, channels);
510 }
511 }
512}
513
455/* 514/*
456 * mv643xx_eth_int_handler 515 * mv643xx_eth_int_handler
457 * 516 *
@@ -497,7 +556,7 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id,
497 /* UDP change : We may need this */ 556 /* UDP change : We may need this */
498 if ((eth_int_cause_ext & 0x0000ffff) && 557 if ((eth_int_cause_ext & 0x0000ffff) &&
499 (mv643xx_eth_free_tx_queue(dev, eth_int_cause_ext) == 0) && 558 (mv643xx_eth_free_tx_queue(dev, eth_int_cause_ext) == 0) &&
500 (mp->tx_ring_size > mp->tx_ring_skbs + MAX_DESCS_PER_SKB)) 559 (mp->tx_ring_size > mp->tx_desc_count + MAX_DESCS_PER_SKB))
501 netif_wake_queue(dev); 560 netif_wake_queue(dev);
502#ifdef MV643XX_NAPI 561#ifdef MV643XX_NAPI
503 } else { 562 } else {
@@ -534,15 +593,23 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id,
534 } 593 }
535 /* PHY status changed */ 594 /* PHY status changed */
536 if (eth_int_cause_ext & (BIT16 | BIT20)) { 595 if (eth_int_cause_ext & (BIT16 | BIT20)) {
537 if (eth_port_link_is_up(port_num)) { 596 struct ethtool_cmd cmd;
538 netif_carrier_on(dev); 597
539 netif_wake_queue(dev); 598 if (mii_link_ok(&mp->mii)) {
540 /* Start TX queue */ 599 mii_ethtool_gset(&mp->mii, &cmd);
541 mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG 600 mv643xx_eth_update_pscr(dev, &cmd);
542 (port_num), 1); 601 if (!netif_carrier_ok(dev)) {
543 } else { 602 netif_carrier_on(dev);
544 netif_carrier_off(dev); 603 if (mp->tx_ring_size > mp->tx_desc_count +
604 MAX_DESCS_PER_SKB) {
605 netif_wake_queue(dev);
606 /* Start TX queue */
607 mv643xx_eth_port_enable_tx(port_num, mp->port_tx_queue_command);
608 }
609 }
610 } else if (netif_carrier_ok(dev)) {
545 netif_stop_queue(dev); 611 netif_stop_queue(dev);
612 netif_carrier_off(dev);
546 } 613 }
547 } 614 }
548 615
@@ -671,8 +738,8 @@ static void ether_init_rx_desc_ring(struct mv643xx_private *mp)
671 738
672 mp->rx_desc_area_size = rx_desc_num * sizeof(struct eth_rx_desc); 739 mp->rx_desc_area_size = rx_desc_num * sizeof(struct eth_rx_desc);
673 740
674 /* Add the queue to the list of RX queues of this port */ 741 /* Enable queue 0 for this port */
675 mp->port_rx_queue_command |= 1; 742 mp->port_rx_queue_command = 1;
676} 743}
677 744
678/* 745/*
@@ -718,8 +785,36 @@ static void ether_init_tx_desc_ring(struct mv643xx_private *mp)
718 785
719 mp->tx_desc_area_size = tx_desc_num * sizeof(struct eth_tx_desc); 786 mp->tx_desc_area_size = tx_desc_num * sizeof(struct eth_tx_desc);
720 787
721 /* Add the queue to the list of Tx queues of this port */ 788 /* Enable queue 0 for this port */
722 mp->port_tx_queue_command |= 1; 789 mp->port_tx_queue_command = 1;
790}
791
792static int mv643xx_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
793{
794 struct mv643xx_private *mp = netdev_priv(dev);
795 int err;
796
797 spin_lock_irq(&mp->lock);
798 err = mii_ethtool_sset(&mp->mii, cmd);
799 spin_unlock_irq(&mp->lock);
800
801 return err;
802}
803
804static int mv643xx_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
805{
806 struct mv643xx_private *mp = netdev_priv(dev);
807 int err;
808
809 spin_lock_irq(&mp->lock);
810 err = mii_ethtool_gset(&mp->mii, cmd);
811 spin_unlock_irq(&mp->lock);
812
813 /* The PHY may support 1000baseT_Half, but the mv643xx does not */
814 cmd->supported &= ~SUPPORTED_1000baseT_Half;
815 cmd->advertising &= ~ADVERTISED_1000baseT_Half;
816
817 return err;
723} 818}
724 819
725/* 820/*
@@ -750,12 +845,6 @@ static int mv643xx_eth_open(struct net_device *dev)
750 return -EAGAIN; 845 return -EAGAIN;
751 } 846 }
752 847
753 /* Stop RX Queues */
754 mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), 0x0000ff00);
755
756 /* Set the MAC Address */
757 memcpy(mp->port_mac_addr, dev->dev_addr, 6);
758
759 eth_port_init(mp); 848 eth_port_init(mp);
760 849
761 INIT_WORK(&mp->rx_task, (void (*)(void *))mv643xx_eth_rx_task, dev); 850 INIT_WORK(&mp->rx_task, (void (*)(void *))mv643xx_eth_rx_task, dev);
@@ -784,7 +873,7 @@ static int mv643xx_eth_open(struct net_device *dev)
784 } 873 }
785 874
786 /* Allocate TX ring */ 875 /* Allocate TX ring */
787 mp->tx_ring_skbs = 0; 876 mp->tx_desc_count = 0;
788 size = mp->tx_ring_size * sizeof(struct eth_tx_desc); 877 size = mp->tx_ring_size * sizeof(struct eth_tx_desc);
789 mp->tx_desc_area_size = size; 878 mp->tx_desc_area_size = size;
790 879
@@ -809,7 +898,7 @@ static int mv643xx_eth_open(struct net_device *dev)
809 ether_init_tx_desc_ring(mp); 898 ether_init_tx_desc_ring(mp);
810 899
811 /* Allocate RX ring */ 900 /* Allocate RX ring */
812 mp->rx_ring_skbs = 0; 901 mp->rx_desc_count = 0;
813 size = mp->rx_ring_size * sizeof(struct eth_rx_desc); 902 size = mp->rx_ring_size * sizeof(struct eth_rx_desc);
814 mp->rx_desc_area_size = size; 903 mp->rx_desc_area_size = size;
815 904
@@ -841,7 +930,11 @@ static int mv643xx_eth_open(struct net_device *dev)
841 930
842 mv643xx_eth_rx_task(dev); /* Fill RX ring with skb's */ 931 mv643xx_eth_rx_task(dev); /* Fill RX ring with skb's */
843 932
844 eth_port_start(mp); 933 /* Clear any pending ethernet port interrupts */
934 mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
935 mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
936
937 eth_port_start(dev);
845 938
846 /* Interrupt Coalescing */ 939 /* Interrupt Coalescing */
847 940
@@ -853,16 +946,13 @@ static int mv643xx_eth_open(struct net_device *dev)
853 mp->tx_int_coal = 946 mp->tx_int_coal =
854 eth_port_set_tx_coal(port_num, 133000000, MV643XX_TX_COAL); 947 eth_port_set_tx_coal(port_num, 133000000, MV643XX_TX_COAL);
855 948
856 /* Clear any pending ethernet port interrupts */
857 mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
858 mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
859
860 /* Unmask phy and link status changes interrupts */ 949 /* Unmask phy and link status changes interrupts */
861 mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num), 950 mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
862 INT_UNMASK_ALL_EXT); 951 INT_UNMASK_ALL_EXT);
863 952
864 /* Unmask RX buffer and TX end interrupt */ 953 /* Unmask RX buffer and TX end interrupt */
865 mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), INT_UNMASK_ALL); 954 mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), INT_UNMASK_ALL);
955
866 return 0; 956 return 0;
867 957
868out_free_tx_skb: 958out_free_tx_skb:
@@ -883,20 +973,20 @@ static void mv643xx_eth_free_tx_rings(struct net_device *dev)
883 struct sk_buff *skb; 973 struct sk_buff *skb;
884 974
885 /* Stop Tx Queues */ 975 /* Stop Tx Queues */
886 mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 0x0000ff00); 976 mv643xx_eth_port_disable_tx(port_num);
887 977
888 /* Free outstanding skb's on TX rings */ 978 /* Free outstanding skb's on TX rings */
889 for (curr = 0; mp->tx_ring_skbs && curr < mp->tx_ring_size; curr++) { 979 for (curr = 0; mp->tx_desc_count && curr < mp->tx_ring_size; curr++) {
890 skb = mp->tx_skb[curr]; 980 skb = mp->tx_skb[curr];
891 if (skb) { 981 if (skb) {
892 mp->tx_ring_skbs -= skb_shinfo(skb)->nr_frags; 982 mp->tx_desc_count -= skb_shinfo(skb)->nr_frags;
893 dev_kfree_skb(skb); 983 dev_kfree_skb(skb);
894 mp->tx_ring_skbs--; 984 mp->tx_desc_count--;
895 } 985 }
896 } 986 }
897 if (mp->tx_ring_skbs) 987 if (mp->tx_desc_count)
898 printk("%s: Error on Tx descriptor free - could not free %d" 988 printk("%s: Error on Tx descriptor free - could not free %d"
899 " descriptors\n", dev->name, mp->tx_ring_skbs); 989 " descriptors\n", dev->name, mp->tx_desc_count);
900 990
901 /* Free TX ring */ 991 /* Free TX ring */
902 if (mp->tx_sram_size) 992 if (mp->tx_sram_size)
@@ -913,21 +1003,21 @@ static void mv643xx_eth_free_rx_rings(struct net_device *dev)
913 int curr; 1003 int curr;
914 1004
915 /* Stop RX Queues */ 1005 /* Stop RX Queues */
916 mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), 0x0000ff00); 1006 mv643xx_eth_port_disable_rx(port_num);
917 1007
918 /* Free preallocated skb's on RX rings */ 1008 /* Free preallocated skb's on RX rings */
919 for (curr = 0; mp->rx_ring_skbs && curr < mp->rx_ring_size; curr++) { 1009 for (curr = 0; mp->rx_desc_count && curr < mp->rx_ring_size; curr++) {
920 if (mp->rx_skb[curr]) { 1010 if (mp->rx_skb[curr]) {
921 dev_kfree_skb(mp->rx_skb[curr]); 1011 dev_kfree_skb(mp->rx_skb[curr]);
922 mp->rx_ring_skbs--; 1012 mp->rx_desc_count--;
923 } 1013 }
924 } 1014 }
925 1015
926 if (mp->rx_ring_skbs) 1016 if (mp->rx_desc_count)
927 printk(KERN_ERR 1017 printk(KERN_ERR
928 "%s: Error in freeing Rx Ring. %d skb's still" 1018 "%s: Error in freeing Rx Ring. %d skb's still"
929 " stuck in RX Ring - ignoring them\n", dev->name, 1019 " stuck in RX Ring - ignoring them\n", dev->name,
930 mp->rx_ring_skbs); 1020 mp->rx_desc_count);
931 /* Free RX ring */ 1021 /* Free RX ring */
932 if (mp->rx_sram_size) 1022 if (mp->rx_sram_size)
933 iounmap(mp->p_rx_desc_area); 1023 iounmap(mp->p_rx_desc_area);
@@ -997,7 +1087,8 @@ static void mv643xx_tx(struct net_device *dev)
997 } 1087 }
998 1088
999 if (netif_queue_stopped(dev) && 1089 if (netif_queue_stopped(dev) &&
1000 mp->tx_ring_size > mp->tx_ring_skbs + MAX_DESCS_PER_SKB) 1090 mp->tx_ring_size >
1091 mp->tx_desc_count + MAX_DESCS_PER_SKB)
1001 netif_wake_queue(dev); 1092 netif_wake_queue(dev);
1002} 1093}
1003 1094
@@ -1089,7 +1180,7 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
1089 } 1180 }
1090 1181
1091 /* This is a hard error, log it. */ 1182 /* This is a hard error, log it. */
1092 if ((mp->tx_ring_size - mp->tx_ring_skbs) <= 1183 if ((mp->tx_ring_size - mp->tx_desc_count) <=
1093 (skb_shinfo(skb)->nr_frags + 1)) { 1184 (skb_shinfo(skb)->nr_frags + 1)) {
1094 netif_stop_queue(dev); 1185 netif_stop_queue(dev);
1095 printk(KERN_ERR 1186 printk(KERN_ERR
@@ -1266,7 +1357,7 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
1266 /* Check if TX queue can handle another skb. If not, then 1357 /* Check if TX queue can handle another skb. If not, then
1267 * signal higher layers to stop requesting TX 1358 * signal higher layers to stop requesting TX
1268 */ 1359 */
1269 if (mp->tx_ring_size <= (mp->tx_ring_skbs + MAX_DESCS_PER_SKB)) 1360 if (mp->tx_ring_size <= (mp->tx_desc_count + MAX_DESCS_PER_SKB))
1270 /* 1361 /*
1271 * Stop getting skb's from upper layers. 1362 * Stop getting skb's from upper layers.
1272 * Getting skb's from upper layers will be enabled again after 1363 * Getting skb's from upper layers will be enabled again after
@@ -1316,6 +1407,35 @@ static void mv643xx_netpoll(struct net_device *netdev)
1316} 1407}
1317#endif 1408#endif
1318 1409
1410static void mv643xx_init_ethtool_cmd(struct net_device *dev, int phy_address,
1411 int speed, int duplex,
1412 struct ethtool_cmd *cmd)
1413{
1414 struct mv643xx_private *mp = netdev_priv(dev);
1415
1416 memset(cmd, 0, sizeof(*cmd));
1417
1418 cmd->port = PORT_MII;
1419 cmd->transceiver = XCVR_INTERNAL;
1420 cmd->phy_address = phy_address;
1421
1422 if (speed == 0) {
1423 cmd->autoneg = AUTONEG_ENABLE;
1424 /* mii lib checks, but doesn't use speed on AUTONEG_ENABLE */
1425 cmd->speed = SPEED_100;
1426 cmd->advertising = ADVERTISED_10baseT_Half |
1427 ADVERTISED_10baseT_Full |
1428 ADVERTISED_100baseT_Half |
1429 ADVERTISED_100baseT_Full;
1430 if (mp->mii.supports_gmii)
1431 cmd->advertising |= ADVERTISED_1000baseT_Full;
1432 } else {
1433 cmd->autoneg = AUTONEG_DISABLE;
1434 cmd->speed = speed;
1435 cmd->duplex = duplex;
1436 }
1437}
1438
1319/*/ 1439/*/
1320 * mv643xx_eth_probe 1440 * mv643xx_eth_probe
1321 * 1441 *
@@ -1336,6 +1456,9 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1336 u8 *p; 1456 u8 *p;
1337 struct resource *res; 1457 struct resource *res;
1338 int err; 1458 int err;
1459 struct ethtool_cmd cmd;
1460 int duplex = DUPLEX_HALF;
1461 int speed = 0; /* default to auto-negotiation */
1339 1462
1340 dev = alloc_etherdev(sizeof(struct mv643xx_private)); 1463 dev = alloc_etherdev(sizeof(struct mv643xx_private));
1341 if (!dev) 1464 if (!dev)
@@ -1373,6 +1496,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1373 dev->tx_queue_len = mp->tx_ring_size; 1496 dev->tx_queue_len = mp->tx_ring_size;
1374 dev->base_addr = 0; 1497 dev->base_addr = 0;
1375 dev->change_mtu = mv643xx_eth_change_mtu; 1498 dev->change_mtu = mv643xx_eth_change_mtu;
1499 dev->do_ioctl = mv643xx_eth_do_ioctl;
1376 SET_ETHTOOL_OPS(dev, &mv643xx_ethtool_ops); 1500 SET_ETHTOOL_OPS(dev, &mv643xx_ethtool_ops);
1377 1501
1378#ifdef MV643XX_CHECKSUM_OFFLOAD_TX 1502#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
@@ -1393,33 +1517,17 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1393 1517
1394 /* set default config values */ 1518 /* set default config values */
1395 eth_port_uc_addr_get(dev, dev->dev_addr); 1519 eth_port_uc_addr_get(dev, dev->dev_addr);
1396 mp->port_config = MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE;
1397 mp->port_config_extend = MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE;
1398 mp->port_sdma_config = MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE;
1399 mp->port_serial_control = MV643XX_ETH_PORT_SERIAL_CONTROL_DEFAULT_VALUE;
1400 mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE; 1520 mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE;
1401 mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE; 1521 mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE;
1402 1522
1403 pd = pdev->dev.platform_data; 1523 pd = pdev->dev.platform_data;
1404 if (pd) { 1524 if (pd) {
1405 if (pd->mac_addr != NULL) 1525 if (pd->mac_addr)
1406 memcpy(dev->dev_addr, pd->mac_addr, 6); 1526 memcpy(dev->dev_addr, pd->mac_addr, 6);
1407 1527
1408 if (pd->phy_addr || pd->force_phy_addr) 1528 if (pd->phy_addr || pd->force_phy_addr)
1409 ethernet_phy_set(port_num, pd->phy_addr); 1529 ethernet_phy_set(port_num, pd->phy_addr);
1410 1530
1411 if (pd->port_config || pd->force_port_config)
1412 mp->port_config = pd->port_config;
1413
1414 if (pd->port_config_extend || pd->force_port_config_extend)
1415 mp->port_config_extend = pd->port_config_extend;
1416
1417 if (pd->port_sdma_config || pd->force_port_sdma_config)
1418 mp->port_sdma_config = pd->port_sdma_config;
1419
1420 if (pd->port_serial_control || pd->force_port_serial_control)
1421 mp->port_serial_control = pd->port_serial_control;
1422
1423 if (pd->rx_queue_size) 1531 if (pd->rx_queue_size)
1424 mp->rx_ring_size = pd->rx_queue_size; 1532 mp->rx_ring_size = pd->rx_queue_size;
1425 1533
@@ -1435,16 +1543,33 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1435 mp->rx_sram_size = pd->rx_sram_size; 1543 mp->rx_sram_size = pd->rx_sram_size;
1436 mp->rx_sram_addr = pd->rx_sram_addr; 1544 mp->rx_sram_addr = pd->rx_sram_addr;
1437 } 1545 }
1546
1547 duplex = pd->duplex;
1548 speed = pd->speed;
1438 } 1549 }
1439 1550
1551 /* Hook up MII support for ethtool */
1552 mp->mii.dev = dev;
1553 mp->mii.mdio_read = mv643xx_mdio_read;
1554 mp->mii.mdio_write = mv643xx_mdio_write;
1555 mp->mii.phy_id = ethernet_phy_get(port_num);
1556 mp->mii.phy_id_mask = 0x3f;
1557 mp->mii.reg_num_mask = 0x1f;
1558
1440 err = ethernet_phy_detect(port_num); 1559 err = ethernet_phy_detect(port_num);
1441 if (err) { 1560 if (err) {
1442 pr_debug("MV643xx ethernet port %d: " 1561 pr_debug("MV643xx ethernet port %d: "
1443 "No PHY detected at addr %d\n", 1562 "No PHY detected at addr %d\n",
1444 port_num, ethernet_phy_get(port_num)); 1563 port_num, ethernet_phy_get(port_num));
1445 return err; 1564 goto out;
1446 } 1565 }
1447 1566
1567 ethernet_phy_reset(port_num);
1568 mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii);
1569 mv643xx_init_ethtool_cmd(dev, mp->mii.phy_id, speed, duplex, &cmd);
1570 mv643xx_eth_update_pscr(dev, &cmd);
1571 mv643xx_set_settings(dev, &cmd);
1572
1448 err = register_netdev(dev); 1573 err = register_netdev(dev);
1449 if (err) 1574 if (err)
1450 goto out; 1575 goto out;
@@ -1708,7 +1833,6 @@ MODULE_DESCRIPTION("Ethernet driver for Marvell MV643XX");
1708 * Prior to calling the initialization routine eth_port_init() the user 1833 * Prior to calling the initialization routine eth_port_init() the user
1709 * must set the following fields under mv643xx_private struct: 1834 * must set the following fields under mv643xx_private struct:
1710 * port_num User Ethernet port number. 1835 * port_num User Ethernet port number.
1711 * port_mac_addr[6] User defined port MAC address.
1712 * port_config User port configuration value. 1836 * port_config User port configuration value.
1713 * port_config_extend User port config extend value. 1837 * port_config_extend User port config extend value.
1714 * port_sdma_config User port SDMA config value. 1838 * port_sdma_config User port SDMA config value.
@@ -1725,20 +1849,12 @@ MODULE_DESCRIPTION("Ethernet driver for Marvell MV643XX");
1725 * return_info Tx/Rx user resource return information. 1849 * return_info Tx/Rx user resource return information.
1726 */ 1850 */
1727 1851
1728/* defines */
1729/* SDMA command macros */
1730#define ETH_ENABLE_TX_QUEUE(eth_port) \
1731 mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(eth_port), 1)
1732
1733/* locals */
1734
1735/* PHY routines */ 1852/* PHY routines */
1736static int ethernet_phy_get(unsigned int eth_port_num); 1853static int ethernet_phy_get(unsigned int eth_port_num);
1737static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr); 1854static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
1738 1855
1739/* Ethernet Port routines */ 1856/* Ethernet Port routines */
1740static int eth_port_uc_addr(unsigned int eth_port_num, unsigned char uc_nibble, 1857static void eth_port_set_filter_table_entry(int table, unsigned char entry);
1741 int option);
1742 1858
1743/* 1859/*
1744 * eth_port_init - Initialize the Ethernet port driver 1860 * eth_port_init - Initialize the Ethernet port driver
@@ -1766,17 +1882,12 @@ static int eth_port_uc_addr(unsigned int eth_port_num, unsigned char uc_nibble,
1766 */ 1882 */
1767static void eth_port_init(struct mv643xx_private *mp) 1883static void eth_port_init(struct mv643xx_private *mp)
1768{ 1884{
1769 mp->port_rx_queue_command = 0;
1770 mp->port_tx_queue_command = 0;
1771
1772 mp->rx_resource_err = 0; 1885 mp->rx_resource_err = 0;
1773 mp->tx_resource_err = 0; 1886 mp->tx_resource_err = 0;
1774 1887
1775 eth_port_reset(mp->port_num); 1888 eth_port_reset(mp->port_num);
1776 1889
1777 eth_port_init_mac_tables(mp->port_num); 1890 eth_port_init_mac_tables(mp->port_num);
1778
1779 ethernet_phy_reset(mp->port_num);
1780} 1891}
1781 1892
1782/* 1893/*
@@ -1798,7 +1909,7 @@ static void eth_port_init(struct mv643xx_private *mp)
1798 * and ether_init_rx_desc_ring for Rx queues). 1909 * and ether_init_rx_desc_ring for Rx queues).
1799 * 1910 *
1800 * INPUT: 1911 * INPUT:
1801 * struct mv643xx_private *mp Ethernet port control struct 1912 * dev - a pointer to the required interface
1802 * 1913 *
1803 * OUTPUT: 1914 * OUTPUT:
1804 * Ethernet port is ready to receive and transmit. 1915 * Ethernet port is ready to receive and transmit.
@@ -1806,10 +1917,13 @@ static void eth_port_init(struct mv643xx_private *mp)
1806 * RETURN: 1917 * RETURN:
1807 * None. 1918 * None.
1808 */ 1919 */
1809static void eth_port_start(struct mv643xx_private *mp) 1920static void eth_port_start(struct net_device *dev)
1810{ 1921{
1922 struct mv643xx_private *mp = netdev_priv(dev);
1811 unsigned int port_num = mp->port_num; 1923 unsigned int port_num = mp->port_num;
1812 int tx_curr_desc, rx_curr_desc; 1924 int tx_curr_desc, rx_curr_desc;
1925 u32 pscr;
1926 struct ethtool_cmd ethtool_cmd;
1813 1927
1814 /* Assignment of Tx CTRP of given queue */ 1928 /* Assignment of Tx CTRP of given queue */
1815 tx_curr_desc = mp->tx_curr_desc_q; 1929 tx_curr_desc = mp->tx_curr_desc_q;
@@ -1822,37 +1936,45 @@ static void eth_port_start(struct mv643xx_private *mp)
1822 (u32)((struct eth_rx_desc *)mp->rx_desc_dma + rx_curr_desc)); 1936 (u32)((struct eth_rx_desc *)mp->rx_desc_dma + rx_curr_desc));
1823 1937
1824 /* Add the assigned Ethernet address to the port's address table */ 1938 /* Add the assigned Ethernet address to the port's address table */
1825 eth_port_uc_addr_set(port_num, mp->port_mac_addr); 1939 eth_port_uc_addr_set(port_num, dev->dev_addr);
1826 1940
1827 /* Assign port configuration and command. */ 1941 /* Assign port configuration and command. */
1828 mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num), mp->port_config); 1942 mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num),
1943 MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE);
1829 1944
1830 mv_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num), 1945 mv_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num),
1831 mp->port_config_extend); 1946 MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE);
1832 1947
1948 pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
1833 1949
1834 /* Increase the Rx side buffer size if supporting GigE */ 1950 pscr &= ~(MV643XX_ETH_SERIAL_PORT_ENABLE | MV643XX_ETH_FORCE_LINK_PASS);
1835 if (mp->port_serial_control & MV643XX_ETH_SET_GMII_SPEED_TO_1000) 1951 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
1836 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), 1952
1837 (mp->port_serial_control & 0xfff1ffff) | (0x5 << 17)); 1953 pscr |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL |
1838 else 1954 MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII |
1839 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), 1955 MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX |
1840 mp->port_serial_control); 1956 MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL |
1957 MV643XX_ETH_SERIAL_PORT_CONTROL_RESERVED;
1841 1958
1842 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), 1959 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
1843 mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)) | 1960
1844 MV643XX_ETH_SERIAL_PORT_ENABLE); 1961 pscr |= MV643XX_ETH_SERIAL_PORT_ENABLE;
1962 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
1845 1963
1846 /* Assign port SDMA configuration */ 1964 /* Assign port SDMA configuration */
1847 mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num), 1965 mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num),
1848 mp->port_sdma_config); 1966 MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE);
1849 1967
1850 /* Enable port Rx. */ 1968 /* Enable port Rx. */
1851 mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), 1969 mv643xx_eth_port_enable_rx(port_num, mp->port_rx_queue_command);
1852 mp->port_rx_queue_command);
1853 1970
1854 /* Disable port bandwidth limits by clearing MTU register */ 1971 /* Disable port bandwidth limits by clearing MTU register */
1855 mv_write(MV643XX_ETH_MAXIMUM_TRANSMIT_UNIT(port_num), 0); 1972 mv_write(MV643XX_ETH_MAXIMUM_TRANSMIT_UNIT(port_num), 0);
1973
1974 /* save phy settings across reset */
1975 mv643xx_get_settings(dev, &ethtool_cmd);
1976 ethernet_phy_reset(mp->port_num);
1977 mv643xx_set_settings(dev, &ethtool_cmd);
1856} 1978}
1857 1979
1858/* 1980/*
@@ -1866,8 +1988,9 @@ static void eth_port_start(struct mv643xx_private *mp)
1866 * char * p_addr Address to be set 1988 * char * p_addr Address to be set
1867 * 1989 *
1868 * OUTPUT: 1990 * OUTPUT:
1869 * Set MAC address low and high registers. also calls eth_port_uc_addr() 1991 * Set MAC address low and high registers. also calls
1870 * To set the unicast table with the proper information. 1992 * eth_port_set_filter_table_entry() to set the unicast
1993 * table with the proper information.
1871 * 1994 *
1872 * RETURN: 1995 * RETURN:
1873 * N/A. 1996 * N/A.
@@ -1878,6 +2001,7 @@ static void eth_port_uc_addr_set(unsigned int eth_port_num,
1878{ 2001{
1879 unsigned int mac_h; 2002 unsigned int mac_h;
1880 unsigned int mac_l; 2003 unsigned int mac_l;
2004 int table;
1881 2005
1882 mac_l = (p_addr[4] << 8) | (p_addr[5]); 2006 mac_l = (p_addr[4] << 8) | (p_addr[5]);
1883 mac_h = (p_addr[0] << 24) | (p_addr[1] << 16) | (p_addr[2] << 8) | 2007 mac_h = (p_addr[0] << 24) | (p_addr[1] << 16) | (p_addr[2] << 8) |
@@ -1887,9 +2011,8 @@ static void eth_port_uc_addr_set(unsigned int eth_port_num,
1887 mv_write(MV643XX_ETH_MAC_ADDR_HIGH(eth_port_num), mac_h); 2011 mv_write(MV643XX_ETH_MAC_ADDR_HIGH(eth_port_num), mac_h);
1888 2012
1889 /* Accept frames of this address */ 2013 /* Accept frames of this address */
1890 eth_port_uc_addr(eth_port_num, p_addr[5], ACCEPT_MAC_ADDR); 2014 table = MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(eth_port_num);
1891 2015 eth_port_set_filter_table_entry(table, p_addr[5] & 0x0f);
1892 return;
1893} 2016}
1894 2017
1895/* 2018/*
@@ -1928,72 +2051,6 @@ static void eth_port_uc_addr_get(struct net_device *dev, unsigned char *p_addr)
1928} 2051}
1929 2052
1930/* 2053/*
1931 * eth_port_uc_addr - This function Set the port unicast address table
1932 *
1933 * DESCRIPTION:
1934 * This function locates the proper entry in the Unicast table for the
1935 * specified MAC nibble and sets its properties according to function
1936 * parameters.
1937 *
1938 * INPUT:
1939 * unsigned int eth_port_num Port number.
1940 * unsigned char uc_nibble Unicast MAC Address last nibble.
1941 * int option 0 = Add, 1 = remove address.
1942 *
1943 * OUTPUT:
1944 * This function add/removes MAC addresses from the port unicast address
1945 * table.
1946 *
1947 * RETURN:
1948 * true is output succeeded.
1949 * false if option parameter is invalid.
1950 *
1951 */
1952static int eth_port_uc_addr(unsigned int eth_port_num, unsigned char uc_nibble,
1953 int option)
1954{
1955 unsigned int unicast_reg;
1956 unsigned int tbl_offset;
1957 unsigned int reg_offset;
1958
1959 /* Locate the Unicast table entry */
1960 uc_nibble = (0xf & uc_nibble);
1961 tbl_offset = (uc_nibble / 4) * 4; /* Register offset from unicast table base */
1962 reg_offset = uc_nibble % 4; /* Entry offset within the above register */
1963
1964 switch (option) {
1965 case REJECT_MAC_ADDR:
1966 /* Clear accepts frame bit at given unicast DA table entry */
1967 unicast_reg = mv_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
1968 (eth_port_num) + tbl_offset));
1969
1970 unicast_reg &= (0x0E << (8 * reg_offset));
1971
1972 mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
1973 (eth_port_num) + tbl_offset), unicast_reg);
1974 break;
1975
1976 case ACCEPT_MAC_ADDR:
1977 /* Set accepts frame bit at unicast DA filter table entry */
1978 unicast_reg =
1979 mv_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
1980 (eth_port_num) + tbl_offset));
1981
1982 unicast_reg |= (0x01 << (8 * reg_offset));
1983
1984 mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
1985 (eth_port_num) + tbl_offset), unicast_reg);
1986
1987 break;
1988
1989 default:
1990 return 0;
1991 }
1992
1993 return 1;
1994}
1995
1996/*
1997 * The entries in each table are indexed by a hash of a packet's MAC 2054 * The entries in each table are indexed by a hash of a packet's MAC
1998 * address. One bit in each entry determines whether the packet is 2055 * address. One bit in each entry determines whether the packet is
1999 * accepted. There are 4 entries (each 8 bits wide) in each register 2056 * accepted. There are 4 entries (each 8 bits wide) in each register
@@ -2205,8 +2262,8 @@ static void eth_port_init_mac_tables(unsigned int eth_port_num)
2205 2262
2206 /* Clear DA filter unicast table (Ex_dFUT) */ 2263 /* Clear DA filter unicast table (Ex_dFUT) */
2207 for (table_index = 0; table_index <= 0xC; table_index += 4) 2264 for (table_index = 0; table_index <= 0xC; table_index += 4)
2208 mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE 2265 mv_write(MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
2209 (eth_port_num) + table_index), 0); 2266 (eth_port_num) + table_index, 0);
2210 2267
2211 for (table_index = 0; table_index <= 0xFC; table_index += 4) { 2268 for (table_index = 0; table_index <= 0xFC; table_index += 4) {
2212 /* Clear DA filter special multicast table (Ex_dFSMT) */ 2269 /* Clear DA filter special multicast table (Ex_dFSMT) */
@@ -2389,6 +2446,73 @@ static void ethernet_phy_reset(unsigned int eth_port_num)
2389 eth_port_read_smi_reg(eth_port_num, 0, &phy_reg_data); 2446 eth_port_read_smi_reg(eth_port_num, 0, &phy_reg_data);
2390 phy_reg_data |= 0x8000; /* Set bit 15 to reset the PHY */ 2447 phy_reg_data |= 0x8000; /* Set bit 15 to reset the PHY */
2391 eth_port_write_smi_reg(eth_port_num, 0, phy_reg_data); 2448 eth_port_write_smi_reg(eth_port_num, 0, phy_reg_data);
2449
2450 /* wait for PHY to come out of reset */
2451 do {
2452 udelay(1);
2453 eth_port_read_smi_reg(eth_port_num, 0, &phy_reg_data);
2454 } while (phy_reg_data & 0x8000);
2455}
2456
2457static void mv643xx_eth_port_enable_tx(unsigned int port_num,
2458 unsigned int channels)
2459{
2460 mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), channels);
2461}
2462
2463static void mv643xx_eth_port_enable_rx(unsigned int port_num,
2464 unsigned int channels)
2465{
2466 mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), channels);
2467}
2468
2469static unsigned int mv643xx_eth_port_disable_tx(unsigned int port_num)
2470{
2471 u32 channels;
2472
2473 /* Stop Tx port activity. Check port Tx activity. */
2474 channels = mv_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num))
2475 & 0xFF;
2476 if (channels) {
2477 /* Issue stop command for active channels only */
2478 mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num),
2479 (channels << 8));
2480
2481 /* Wait for all Tx activity to terminate. */
2482 /* Check port cause register that all Tx queues are stopped */
2483 while (mv_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num))
2484 & 0xFF)
2485 udelay(PHY_WAIT_MICRO_SECONDS);
2486
2487 /* Wait for Tx FIFO to empty */
2488 while (mv_read(MV643XX_ETH_PORT_STATUS_REG(port_num)) &
2489 ETH_PORT_TX_FIFO_EMPTY)
2490 udelay(PHY_WAIT_MICRO_SECONDS);
2491 }
2492
2493 return channels;
2494}
2495
2496static unsigned int mv643xx_eth_port_disable_rx(unsigned int port_num)
2497{
2498 u32 channels;
2499
2500 /* Stop Rx port activity. Check port Rx activity. */
2501 channels = mv_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num)
2502 & 0xFF);
2503 if (channels) {
2504 /* Issue stop command for active channels only */
2505 mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
2506 (channels << 8));
2507
2508 /* Wait for all Rx activity to terminate. */
2509 /* Check port cause register that all Rx queues are stopped */
2510 while (mv_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num))
2511 & 0xFF)
2512 udelay(PHY_WAIT_MICRO_SECONDS);
2513 }
2514
2515 return channels;
2392} 2516}
2393 2517
2394/* 2518/*
@@ -2413,70 +2537,21 @@ static void eth_port_reset(unsigned int port_num)
2413{ 2537{
2414 unsigned int reg_data; 2538 unsigned int reg_data;
2415 2539
2416 /* Stop Tx port activity. Check port Tx activity. */ 2540 mv643xx_eth_port_disable_tx(port_num);
2417 reg_data = mv_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num)); 2541 mv643xx_eth_port_disable_rx(port_num);
2418
2419 if (reg_data & 0xFF) {
2420 /* Issue stop command for active channels only */
2421 mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num),
2422 (reg_data << 8));
2423
2424 /* Wait for all Tx activity to terminate. */
2425 /* Check port cause register that all Tx queues are stopped */
2426 while (mv_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num))
2427 & 0xFF)
2428 udelay(10);
2429 }
2430
2431 /* Stop Rx port activity. Check port Rx activity. */
2432 reg_data = mv_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num));
2433
2434 if (reg_data & 0xFF) {
2435 /* Issue stop command for active channels only */
2436 mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
2437 (reg_data << 8));
2438
2439 /* Wait for all Rx activity to terminate. */
2440 /* Check port cause register that all Rx queues are stopped */
2441 while (mv_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num))
2442 & 0xFF)
2443 udelay(10);
2444 }
2445 2542
2446 /* Clear all MIB counters */ 2543 /* Clear all MIB counters */
2447 eth_clear_mib_counters(port_num); 2544 eth_clear_mib_counters(port_num);
2448 2545
2449 /* Reset the Enable bit in the Configuration Register */ 2546 /* Reset the Enable bit in the Configuration Register */
2450 reg_data = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)); 2547 reg_data = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
2451 reg_data &= ~MV643XX_ETH_SERIAL_PORT_ENABLE; 2548 reg_data &= ~(MV643XX_ETH_SERIAL_PORT_ENABLE |
2549 MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL |
2550 MV643XX_ETH_FORCE_LINK_PASS);
2452 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), reg_data); 2551 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), reg_data);
2453} 2552}
2454 2553
2455 2554
2456static int eth_port_autoneg_supported(unsigned int eth_port_num)
2457{
2458 unsigned int phy_reg_data0;
2459
2460 eth_port_read_smi_reg(eth_port_num, 0, &phy_reg_data0);
2461
2462 return phy_reg_data0 & 0x1000;
2463}
2464
2465static int eth_port_link_is_up(unsigned int eth_port_num)
2466{
2467 unsigned int phy_reg_data1;
2468
2469 eth_port_read_smi_reg(eth_port_num, 1, &phy_reg_data1);
2470
2471 if (eth_port_autoneg_supported(eth_port_num)) {
2472 if (phy_reg_data1 & 0x20) /* auto-neg complete */
2473 return 1;
2474 } else if (phy_reg_data1 & 0x4) /* link up */
2475 return 1;
2476
2477 return 0;
2478}
2479
2480/* 2555/*
2481 * eth_port_read_smi_reg - Read PHY registers 2556 * eth_port_read_smi_reg - Read PHY registers
2482 * 2557 *
@@ -2582,6 +2657,24 @@ out:
2582} 2657}
2583 2658
2584/* 2659/*
2660 * Wrappers for MII support library.
2661 */
2662static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location)
2663{
2664 int val;
2665 struct mv643xx_private *mp = netdev_priv(dev);
2666
2667 eth_port_read_smi_reg(mp->port_num, location, &val);
2668 return val;
2669}
2670
2671static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val)
2672{
2673 struct mv643xx_private *mp = netdev_priv(dev);
2674 eth_port_write_smi_reg(mp->port_num, location, val);
2675}
2676
2677/*
2585 * eth_port_send - Send an Ethernet packet 2678 * eth_port_send - Send an Ethernet packet
2586 * 2679 *
2587 * DESCRIPTION: 2680 * DESCRIPTION:
@@ -2635,8 +2728,8 @@ static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
2635 return ETH_ERROR; 2728 return ETH_ERROR;
2636 } 2729 }
2637 2730
2638 mp->tx_ring_skbs++; 2731 mp->tx_desc_count++;
2639 BUG_ON(mp->tx_ring_skbs > mp->tx_ring_size); 2732 BUG_ON(mp->tx_desc_count > mp->tx_ring_size);
2640 2733
2641 /* Get the Tx Desc ring indexes */ 2734 /* Get the Tx Desc ring indexes */
2642 tx_desc_curr = mp->tx_curr_desc_q; 2735 tx_desc_curr = mp->tx_curr_desc_q;
@@ -2670,7 +2763,7 @@ static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
2670 first_descriptor->cmd_sts = mp->tx_first_command; 2763 first_descriptor->cmd_sts = mp->tx_first_command;
2671 2764
2672 wmb(); 2765 wmb();
2673 ETH_ENABLE_TX_QUEUE(mp->port_num); 2766 mv643xx_eth_port_enable_tx(mp->port_num, mp->port_tx_queue_command);
2674 2767
2675 /* 2768 /*
2676 * Finish Tx packet. Update first desc in case of Tx resource 2769 * Finish Tx packet. Update first desc in case of Tx resource
@@ -2704,8 +2797,8 @@ static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
2704 if (mp->tx_resource_err) 2797 if (mp->tx_resource_err)
2705 return ETH_QUEUE_FULL; 2798 return ETH_QUEUE_FULL;
2706 2799
2707 mp->tx_ring_skbs++; 2800 mp->tx_desc_count++;
2708 BUG_ON(mp->tx_ring_skbs > mp->tx_ring_size); 2801 BUG_ON(mp->tx_desc_count > mp->tx_ring_size);
2709 2802
2710 /* Get the Tx Desc ring indexes */ 2803 /* Get the Tx Desc ring indexes */
2711 tx_desc_curr = mp->tx_curr_desc_q; 2804 tx_desc_curr = mp->tx_curr_desc_q;
@@ -2723,7 +2816,7 @@ static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
2723 ETH_BUFFER_OWNED_BY_DMA | ETH_TX_ENABLE_INTERRUPT; 2816 ETH_BUFFER_OWNED_BY_DMA | ETH_TX_ENABLE_INTERRUPT;
2724 2817
2725 wmb(); 2818 wmb();
2726 ETH_ENABLE_TX_QUEUE(mp->port_num); 2819 mv643xx_eth_port_enable_tx(mp->port_num, mp->port_tx_queue_command);
2727 2820
2728 /* Finish Tx packet. Update first desc in case of Tx resource error */ 2821 /* Finish Tx packet. Update first desc in case of Tx resource error */
2729 tx_desc_curr = (tx_desc_curr + 1) % mp->tx_ring_size; 2822 tx_desc_curr = (tx_desc_curr + 1) % mp->tx_ring_size;
@@ -2819,8 +2912,8 @@ static ETH_FUNC_RET_STATUS eth_tx_return_desc(struct mv643xx_private *mp,
2819 /* Any Tx return cancels the Tx resource error status */ 2912 /* Any Tx return cancels the Tx resource error status */
2820 mp->tx_resource_err = 0; 2913 mp->tx_resource_err = 0;
2821 2914
2822 BUG_ON(mp->tx_ring_skbs == 0); 2915 BUG_ON(mp->tx_desc_count == 0);
2823 mp->tx_ring_skbs--; 2916 mp->tx_desc_count--;
2824 2917
2825out: 2918out:
2826 spin_unlock_irqrestore(&mp->lock, flags); 2919 spin_unlock_irqrestore(&mp->lock, flags);
@@ -3017,111 +3110,6 @@ static const struct mv643xx_stats mv643xx_gstrings_stats[] = {
3017#define MV643XX_STATS_LEN \ 3110#define MV643XX_STATS_LEN \
3018 sizeof(mv643xx_gstrings_stats) / sizeof(struct mv643xx_stats) 3111 sizeof(mv643xx_gstrings_stats) / sizeof(struct mv643xx_stats)
3019 3112
3020static int
3021mv643xx_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
3022{
3023 struct mv643xx_private *mp = netdev->priv;
3024 int port_num = mp->port_num;
3025 int autoneg = eth_port_autoneg_supported(port_num);
3026 int mode_10_bit;
3027 int auto_duplex;
3028 int half_duplex = 0;
3029 int full_duplex = 0;
3030 int auto_speed;
3031 int speed_10 = 0;
3032 int speed_100 = 0;
3033 int speed_1000 = 0;
3034
3035 u32 pcs = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
3036 u32 psr = mv_read(MV643XX_ETH_PORT_STATUS_REG(port_num));
3037
3038 mode_10_bit = psr & MV643XX_ETH_PORT_STATUS_MODE_10_BIT;
3039
3040 if (mode_10_bit) {
3041 ecmd->supported = SUPPORTED_10baseT_Half;
3042 } else {
3043 ecmd->supported = (SUPPORTED_10baseT_Half |
3044 SUPPORTED_10baseT_Full |
3045 SUPPORTED_100baseT_Half |
3046 SUPPORTED_100baseT_Full |
3047 SUPPORTED_1000baseT_Full |
3048 (autoneg ? SUPPORTED_Autoneg : 0) |
3049 SUPPORTED_TP);
3050
3051 auto_duplex = !(pcs & MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX);
3052 auto_speed = !(pcs & MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII);
3053
3054 ecmd->advertising = ADVERTISED_TP;
3055
3056 if (autoneg) {
3057 ecmd->advertising |= ADVERTISED_Autoneg;
3058
3059 if (auto_duplex) {
3060 half_duplex = 1;
3061 full_duplex = 1;
3062 } else {
3063 if (pcs & MV643XX_ETH_SET_FULL_DUPLEX_MODE)
3064 full_duplex = 1;
3065 else
3066 half_duplex = 1;
3067 }
3068
3069 if (auto_speed) {
3070 speed_10 = 1;
3071 speed_100 = 1;
3072 speed_1000 = 1;
3073 } else {
3074 if (pcs & MV643XX_ETH_SET_GMII_SPEED_TO_1000)
3075 speed_1000 = 1;
3076 else if (pcs & MV643XX_ETH_SET_MII_SPEED_TO_100)
3077 speed_100 = 1;
3078 else
3079 speed_10 = 1;
3080 }
3081
3082 if (speed_10 & half_duplex)
3083 ecmd->advertising |= ADVERTISED_10baseT_Half;
3084 if (speed_10 & full_duplex)
3085 ecmd->advertising |= ADVERTISED_10baseT_Full;
3086 if (speed_100 & half_duplex)
3087 ecmd->advertising |= ADVERTISED_100baseT_Half;
3088 if (speed_100 & full_duplex)
3089 ecmd->advertising |= ADVERTISED_100baseT_Full;
3090 if (speed_1000)
3091 ecmd->advertising |= ADVERTISED_1000baseT_Full;
3092 }
3093 }
3094
3095 ecmd->port = PORT_TP;
3096 ecmd->phy_address = ethernet_phy_get(port_num);
3097
3098 ecmd->transceiver = XCVR_EXTERNAL;
3099
3100 if (netif_carrier_ok(netdev)) {
3101 if (mode_10_bit)
3102 ecmd->speed = SPEED_10;
3103 else {
3104 if (psr & MV643XX_ETH_PORT_STATUS_GMII_1000)
3105 ecmd->speed = SPEED_1000;
3106 else if (psr & MV643XX_ETH_PORT_STATUS_MII_100)
3107 ecmd->speed = SPEED_100;
3108 else
3109 ecmd->speed = SPEED_10;
3110 }
3111
3112 if (psr & MV643XX_ETH_PORT_STATUS_FULL_DUPLEX)
3113 ecmd->duplex = DUPLEX_FULL;
3114 else
3115 ecmd->duplex = DUPLEX_HALF;
3116 } else {
3117 ecmd->speed = -1;
3118 ecmd->duplex = -1;
3119 }
3120
3121 ecmd->autoneg = autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE;
3122 return 0;
3123}
3124
3125static void mv643xx_get_drvinfo(struct net_device *netdev, 3113static void mv643xx_get_drvinfo(struct net_device *netdev,
3126 struct ethtool_drvinfo *drvinfo) 3114 struct ethtool_drvinfo *drvinfo)
3127{ 3115{
@@ -3168,15 +3156,41 @@ static void mv643xx_get_strings(struct net_device *netdev, uint32_t stringset,
3168 } 3156 }
3169} 3157}
3170 3158
3159static u32 mv643xx_eth_get_link(struct net_device *dev)
3160{
3161 struct mv643xx_private *mp = netdev_priv(dev);
3162
3163 return mii_link_ok(&mp->mii);
3164}
3165
3166static int mv643xx_eth_nway_restart(struct net_device *dev)
3167{
3168 struct mv643xx_private *mp = netdev_priv(dev);
3169
3170 return mii_nway_restart(&mp->mii);
3171}
3172
3173static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
3174{
3175 struct mv643xx_private *mp = netdev_priv(dev);
3176
3177 return generic_mii_ioctl(&mp->mii, if_mii(ifr), cmd, NULL);
3178}
3179
3171static struct ethtool_ops mv643xx_ethtool_ops = { 3180static struct ethtool_ops mv643xx_ethtool_ops = {
3172 .get_settings = mv643xx_get_settings, 3181 .get_settings = mv643xx_get_settings,
3182 .set_settings = mv643xx_set_settings,
3173 .get_drvinfo = mv643xx_get_drvinfo, 3183 .get_drvinfo = mv643xx_get_drvinfo,
3174 .get_link = ethtool_op_get_link, 3184 .get_link = mv643xx_eth_get_link,
3175 .get_sg = ethtool_op_get_sg, 3185 .get_sg = ethtool_op_get_sg,
3176 .set_sg = ethtool_op_set_sg, 3186 .set_sg = ethtool_op_set_sg,
3177 .get_strings = mv643xx_get_strings, 3187 .get_strings = mv643xx_get_strings,
3178 .get_stats_count = mv643xx_get_stats_count, 3188 .get_stats_count = mv643xx_get_stats_count,
3179 .get_ethtool_stats = mv643xx_get_ethtool_stats, 3189 .get_ethtool_stats = mv643xx_get_ethtool_stats,
3190 .get_strings = mv643xx_get_strings,
3191 .get_stats_count = mv643xx_get_stats_count,
3192 .get_ethtool_stats = mv643xx_get_ethtool_stats,
3193 .nway_reset = mv643xx_eth_nway_restart,
3180}; 3194};
3181 3195
3182/************* End ethtool support *************************/ 3196/************* End ethtool support *************************/
diff --git a/drivers/net/mv643xx_eth.h b/drivers/net/mv643xx_eth.h
index f769f9b626ea..a553054e8da7 100644
--- a/drivers/net/mv643xx_eth.h
+++ b/drivers/net/mv643xx_eth.h
@@ -5,6 +5,7 @@
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/spinlock.h> 6#include <linux/spinlock.h>
7#include <linux/workqueue.h> 7#include <linux/workqueue.h>
8#include <linux/mii.h>
8 9
9#include <linux/mv643xx.h> 10#include <linux/mv643xx.h>
10 11
@@ -89,10 +90,6 @@
89 * 90 *
90 */ 91 */
91 92
92/* MAC accepet/reject macros */
93#define ACCEPT_MAC_ADDR 0
94#define REJECT_MAC_ADDR 1
95
96/* Buffer offset from buffer pointer */ 93/* Buffer offset from buffer pointer */
97#define RX_BUF_OFFSET 0x2 94#define RX_BUF_OFFSET 0x2
98 95
@@ -324,11 +321,6 @@ struct mv643xx_mib_counters {
324 321
325struct mv643xx_private { 322struct mv643xx_private {
326 int port_num; /* User Ethernet port number */ 323 int port_num; /* User Ethernet port number */
327 u8 port_mac_addr[6]; /* User defined port MAC address.*/
328 u32 port_config; /* User port configuration value*/
329 u32 port_config_extend; /* User port config extend value*/
330 u32 port_sdma_config; /* User port SDMA config value */
331 u32 port_serial_control; /* User port serial control value */
332 u32 port_tx_queue_command; /* Port active Tx queues summary*/ 324 u32 port_tx_queue_command; /* Port active Tx queues summary*/
333 u32 port_rx_queue_command; /* Port active Rx queues summary*/ 325 u32 port_rx_queue_command; /* Port active Rx queues summary*/
334 326
@@ -376,12 +368,12 @@ struct mv643xx_private {
376 spinlock_t lock; 368 spinlock_t lock;
377 /* Size of Tx Ring per queue */ 369 /* Size of Tx Ring per queue */
378 unsigned int tx_ring_size; 370 unsigned int tx_ring_size;
379 /* Ammont of SKBs outstanding on Tx queue */ 371 /* Number of tx descriptors in use */
380 unsigned int tx_ring_skbs; 372 unsigned int tx_desc_count;
381 /* Size of Rx Ring per queue */ 373 /* Size of Rx Ring per queue */
382 unsigned int rx_ring_size; 374 unsigned int rx_ring_size;
383 /* Ammount of SKBs allocated to Rx Ring per queue */ 375 /* Number of rx descriptors in use */
384 unsigned int rx_ring_skbs; 376 unsigned int rx_desc_count;
385 377
386 /* 378 /*
387 * rx_task used to fill RX ring out of bottom half context 379 * rx_task used to fill RX ring out of bottom half context
@@ -398,6 +390,7 @@ struct mv643xx_private {
398 390
399 u32 rx_int_coal; 391 u32 rx_int_coal;
400 u32 tx_int_coal; 392 u32 tx_int_coal;
393 struct mii_if_info mii;
401}; 394};
402 395
403/* ethernet.h API list */ 396/* ethernet.h API list */
@@ -405,7 +398,7 @@ struct mv643xx_private {
405/* Port operation control routines */ 398/* Port operation control routines */
406static void eth_port_init(struct mv643xx_private *mp); 399static void eth_port_init(struct mv643xx_private *mp);
407static void eth_port_reset(unsigned int eth_port_num); 400static void eth_port_reset(unsigned int eth_port_num);
408static void eth_port_start(struct mv643xx_private *mp); 401static void eth_port_start(struct net_device *dev);
409 402
410/* Port MAC address routines */ 403/* Port MAC address routines */
411static void eth_port_uc_addr_set(unsigned int eth_port_num, 404static void eth_port_uc_addr_set(unsigned int eth_port_num,
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index 8f40368cf2e9..aaebd28a1920 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -27,6 +27,7 @@ static const char version1[] =
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/netdevice.h> 28#include <linux/netdevice.h>
29#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
30#include <linux/jiffies.h>
30 31
31#include <asm/system.h> 32#include <asm/system.h>
32#include <asm/io.h> 33#include <asm/io.h>
@@ -365,7 +366,7 @@ static void ne_reset_8390(struct net_device *dev)
365 366
366 /* This check _should_not_ be necessary, omit eventually. */ 367 /* This check _should_not_ be necessary, omit eventually. */
367 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0) 368 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
368 if (jiffies - reset_start_time > 2*HZ/100) { 369 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
369 printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name); 370 printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name);
370 break; 371 break;
371 } 372 }
@@ -580,7 +581,7 @@ retry:
580#endif 581#endif
581 582
582 while ((inb_p(NE_BASE + EN0_ISR) & ENISR_RDC) == 0) 583 while ((inb_p(NE_BASE + EN0_ISR) & ENISR_RDC) == 0)
583 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ 584 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
584 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name); 585 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
585 ne_reset_8390(dev); 586 ne_reset_8390(dev);
586 NS8390_init(dev,1); 587 NS8390_init(dev,1);
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index 94f782d51f0f..08b218c5bfbc 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -50,6 +50,7 @@ static const char version2[] =
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/netdevice.h> 51#include <linux/netdevice.h>
52#include <linux/etherdevice.h> 52#include <linux/etherdevice.h>
53#include <linux/jiffies.h>
53 54
54#include <asm/system.h> 55#include <asm/system.h>
55#include <asm/io.h> 56#include <asm/io.h>
@@ -341,7 +342,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
341 outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET); 342 outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
342 343
343 while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0) 344 while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
344 if (jiffies - reset_start_time > 2*HZ/100) { 345 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
345 if (bad_card) { 346 if (bad_card) {
346 printk(" (warning: no reset ack)"); 347 printk(" (warning: no reset ack)");
347 break; 348 break;
@@ -580,7 +581,7 @@ static void ne_reset_8390(struct net_device *dev)
580 581
581 /* This check _should_not_ be necessary, omit eventually. */ 582 /* This check _should_not_ be necessary, omit eventually. */
582 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0) 583 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
583 if (jiffies - reset_start_time > 2*HZ/100) { 584 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
584 printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name); 585 printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name);
585 break; 586 break;
586 } 587 }
@@ -787,7 +788,7 @@ retry:
787#endif 788#endif
788 789
789 while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0) 790 while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
790 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ 791 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
791 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name); 792 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
792 ne_reset_8390(dev); 793 ne_reset_8390(dev);
793 NS8390_init(dev,1); 794 NS8390_init(dev,1);
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c
index e6df375a1d4b..2aa7b77f84f8 100644
--- a/drivers/net/ne2.c
+++ b/drivers/net/ne2.c
@@ -75,6 +75,7 @@ static const char *version = "ne2.c:v0.91 Nov 16 1998 Wim Dumon <wimpie@kotnet.o
75#include <linux/etherdevice.h> 75#include <linux/etherdevice.h>
76#include <linux/skbuff.h> 76#include <linux/skbuff.h>
77#include <linux/bitops.h> 77#include <linux/bitops.h>
78#include <linux/jiffies.h>
78 79
79#include <asm/system.h> 80#include <asm/system.h>
80#include <asm/io.h> 81#include <asm/io.h>
@@ -395,7 +396,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot)
395 outb(inb(base_addr + NE_RESET), base_addr + NE_RESET); 396 outb(inb(base_addr + NE_RESET), base_addr + NE_RESET);
396 397
397 while ((inb_p(base_addr + EN0_ISR) & ENISR_RESET) == 0) 398 while ((inb_p(base_addr + EN0_ISR) & ENISR_RESET) == 0)
398 if (jiffies - reset_start_time > 2*HZ/100) { 399 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
399 printk(" not found (no reset ack).\n"); 400 printk(" not found (no reset ack).\n");
400 retval = -ENODEV; 401 retval = -ENODEV;
401 goto out; 402 goto out;
@@ -548,7 +549,7 @@ static void ne_reset_8390(struct net_device *dev)
548 549
549 /* This check _should_not_ be necessary, omit eventually. */ 550 /* This check _should_not_ be necessary, omit eventually. */
550 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0) 551 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
551 if (jiffies - reset_start_time > 2*HZ/100) { 552 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
552 printk("%s: ne_reset_8390() did not complete.\n", 553 printk("%s: ne_reset_8390() did not complete.\n",
553 dev->name); 554 dev->name);
554 break; 555 break;
@@ -749,7 +750,7 @@ retry:
749#endif 750#endif
750 751
751 while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0) 752 while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
752 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ 753 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
753 printk("%s: timeout waiting for Tx RDC.\n", dev->name); 754 printk("%s: timeout waiting for Tx RDC.\n", dev->name);
754 ne_reset_8390(dev); 755 ne_reset_8390(dev);
755 NS8390_init(dev,1); 756 NS8390_init(dev,1);
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index b0c3b6ab6263..253cf018dfba 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -116,6 +116,7 @@
116#include <linux/timer.h> 116#include <linux/timer.h>
117#include <linux/if_vlan.h> 117#include <linux/if_vlan.h>
118#include <linux/rtnetlink.h> 118#include <linux/rtnetlink.h>
119#include <linux/jiffies.h>
119 120
120#include <asm/io.h> 121#include <asm/io.h>
121#include <asm/uaccess.h> 122#include <asm/uaccess.h>
@@ -1607,7 +1608,7 @@ static void ns83820_run_bist(struct net_device *ndev, const char *name, u32 enab
1607{ 1608{
1608 struct ns83820 *dev = PRIV(ndev); 1609 struct ns83820 *dev = PRIV(ndev);
1609 int timed_out = 0; 1610 int timed_out = 0;
1610 long start; 1611 unsigned long start;
1611 u32 status; 1612 u32 status;
1612 int loops = 0; 1613 int loops = 0;
1613 1614
@@ -1625,7 +1626,7 @@ static void ns83820_run_bist(struct net_device *ndev, const char *name, u32 enab
1625 break; 1626 break;
1626 if (status & fail) 1627 if (status & fail)
1627 break; 1628 break;
1628 if ((jiffies - start) >= HZ) { 1629 if (time_after_eq(jiffies, start + HZ)) {
1629 timed_out = 1; 1630 timed_out = 1;
1630 break; 1631 break;
1631 } 1632 }
diff --git a/drivers/net/oaknet.c b/drivers/net/oaknet.c
index 62167a29debe..d0f686d6eaaa 100644
--- a/drivers/net/oaknet.c
+++ b/drivers/net/oaknet.c
@@ -20,6 +20,7 @@
20#include <linux/netdevice.h> 20#include <linux/netdevice.h>
21#include <linux/etherdevice.h> 21#include <linux/etherdevice.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/jiffies.h>
23 24
24#include <asm/board.h> 25#include <asm/board.h>
25#include <asm/io.h> 26#include <asm/io.h>
@@ -606,7 +607,7 @@ retry:
606#endif 607#endif
607 608
608 while ((ei_ibp(base + EN0_ISR) & ENISR_RDC) == 0) { 609 while ((ei_ibp(base + EN0_ISR) & ENISR_RDC) == 0) {
609 if (jiffies - start > OAKNET_WAIT) { 610 if (time_after(jiffies, start + OAKNET_WAIT)) {
610 printk("%s: timeout waiting for Tx RDC.\n", dev->name); 611 printk("%s: timeout waiting for Tx RDC.\n", dev->name);
611 oaknet_reset_8390(dev); 612 oaknet_reset_8390(dev);
612 NS8390_init(dev, TRUE); 613 NS8390_init(dev, TRUE);
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 1c3c9c666f74..c4abc9365f8e 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -39,6 +39,7 @@
39#include <linux/if_arp.h> 39#include <linux/if_arp.h>
40#include <linux/ioport.h> 40#include <linux/ioport.h>
41#include <linux/bitops.h> 41#include <linux/bitops.h>
42#include <linux/jiffies.h>
42 43
43#include <pcmcia/cs_types.h> 44#include <pcmcia/cs_types.h>
44#include <pcmcia/cs.h> 45#include <pcmcia/cs.h>
@@ -796,7 +797,7 @@ static void media_check(unsigned long arg)
796 media = inw(ioaddr+WN4_MEDIA) & 0xc810; 797 media = inw(ioaddr+WN4_MEDIA) & 0xc810;
797 798
798 /* Ignore collisions unless we've had no irq's recently */ 799 /* Ignore collisions unless we've had no irq's recently */
799 if (jiffies - lp->last_irq < HZ) { 800 if (time_before(jiffies, lp->last_irq + HZ)) {
800 media &= ~0x0010; 801 media &= ~0x0010;
801 } else { 802 } else {
802 /* Try harder to detect carrier errors */ 803 /* Try harder to detect carrier errors */
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index aa6540b39466..23659fd7c3a6 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -30,6 +30,7 @@
30#include <linux/ppp_channel.h> 30#include <linux/ppp_channel.h>
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/jiffies.h>
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
34#include <asm/string.h> 35#include <asm/string.h>
35 36
@@ -570,7 +571,7 @@ ppp_async_encode(struct asyncppp *ap)
570 * character if necessary. 571 * character if necessary.
571 */ 572 */
572 if (islcp || flag_time == 0 573 if (islcp || flag_time == 0
573 || jiffies - ap->last_xmit >= flag_time) 574 || time_after_eq(jiffies, ap->last_xmit + flag_time))
574 *buf++ = PPP_FLAG; 575 *buf++ = PPP_FLAG;
575 ap->last_xmit = jiffies; 576 ap->last_xmit = jiffies;
576 fcs = PPP_INITFCS; 577 fcs = PPP_INITFCS;
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 49b597cbc19a..da0d8a85acce 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -72,8 +72,8 @@
72static char s2io_driver_name[] = "Neterion"; 72static char s2io_driver_name[] = "Neterion";
73static char s2io_driver_version[] = DRV_VERSION; 73static char s2io_driver_version[] = DRV_VERSION;
74 74
75int rxd_size[4] = {32,48,48,64}; 75static int rxd_size[4] = {32,48,48,64};
76int rxd_count[4] = {127,85,85,63}; 76static int rxd_count[4] = {127,85,85,63};
77 77
78static inline int RXD_IS_UP2DT(RxD_t *rxdp) 78static inline int RXD_IS_UP2DT(RxD_t *rxdp)
79{ 79{
@@ -2127,7 +2127,7 @@ static void stop_nic(struct s2io_nic *nic)
2127 } 2127 }
2128} 2128}
2129 2129
2130int fill_rxd_3buf(nic_t *nic, RxD_t *rxdp, struct sk_buff *skb) 2130static int fill_rxd_3buf(nic_t *nic, RxD_t *rxdp, struct sk_buff *skb)
2131{ 2131{
2132 struct net_device *dev = nic->dev; 2132 struct net_device *dev = nic->dev;
2133 struct sk_buff *frag_list; 2133 struct sk_buff *frag_list;
@@ -2852,7 +2852,7 @@ static int wait_for_cmd_complete(nic_t * sp)
2852 * void. 2852 * void.
2853 */ 2853 */
2854 2854
2855void s2io_reset(nic_t * sp) 2855static void s2io_reset(nic_t * sp)
2856{ 2856{
2857 XENA_dev_config_t __iomem *bar0 = sp->bar0; 2857 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2858 u64 val64; 2858 u64 val64;
@@ -2940,7 +2940,7 @@ void s2io_reset(nic_t * sp)
2940 * SUCCESS on success and FAILURE on failure. 2940 * SUCCESS on success and FAILURE on failure.
2941 */ 2941 */
2942 2942
2943int s2io_set_swapper(nic_t * sp) 2943static int s2io_set_swapper(nic_t * sp)
2944{ 2944{
2945 struct net_device *dev = sp->dev; 2945 struct net_device *dev = sp->dev;
2946 XENA_dev_config_t __iomem *bar0 = sp->bar0; 2946 XENA_dev_config_t __iomem *bar0 = sp->bar0;
@@ -3089,7 +3089,7 @@ static int wait_for_msix_trans(nic_t *nic, int i)
3089 return ret; 3089 return ret;
3090} 3090}
3091 3091
3092void restore_xmsi_data(nic_t *nic) 3092static void restore_xmsi_data(nic_t *nic)
3093{ 3093{
3094 XENA_dev_config_t __iomem *bar0 = nic->bar0; 3094 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3095 u64 val64; 3095 u64 val64;
@@ -3180,7 +3180,7 @@ int s2io_enable_msi(nic_t *nic)
3180 return 0; 3180 return 0;
3181} 3181}
3182 3182
3183int s2io_enable_msi_x(nic_t *nic) 3183static int s2io_enable_msi_x(nic_t *nic)
3184{ 3184{
3185 XENA_dev_config_t __iomem *bar0 = nic->bar0; 3185 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3186 u64 tx_mat, rx_mat; 3186 u64 tx_mat, rx_mat;
@@ -4128,7 +4128,7 @@ static void s2io_set_multicast(struct net_device *dev)
4128 * as defined in errno.h file on failure. 4128 * as defined in errno.h file on failure.
4129 */ 4129 */
4130 4130
4131int s2io_set_mac_addr(struct net_device *dev, u8 * addr) 4131static int s2io_set_mac_addr(struct net_device *dev, u8 * addr)
4132{ 4132{
4133 nic_t *sp = dev->priv; 4133 nic_t *sp = dev->priv;
4134 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4134 XENA_dev_config_t __iomem *bar0 = sp->bar0;
@@ -5713,7 +5713,7 @@ static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp)
5713 * void. 5713 * void.
5714 */ 5714 */
5715 5715
5716void s2io_link(nic_t * sp, int link) 5716static void s2io_link(nic_t * sp, int link)
5717{ 5717{
5718 struct net_device *dev = (struct net_device *) sp->dev; 5718 struct net_device *dev = (struct net_device *) sp->dev;
5719 5719
@@ -5738,7 +5738,7 @@ void s2io_link(nic_t * sp, int link)
5738 * returns the revision ID of the device. 5738 * returns the revision ID of the device.
5739 */ 5739 */
5740 5740
5741int get_xena_rev_id(struct pci_dev *pdev) 5741static int get_xena_rev_id(struct pci_dev *pdev)
5742{ 5742{
5743 u8 id = 0; 5743 u8 id = 0;
5744 int ret; 5744 int ret;
@@ -6343,7 +6343,7 @@ int __init s2io_starter(void)
6343 * Description: This function is the cleanup routine for the driver. It unregist * ers the driver. 6343 * Description: This function is the cleanup routine for the driver. It unregist * ers the driver.
6344 */ 6344 */
6345 6345
6346void s2io_closer(void) 6346static void s2io_closer(void)
6347{ 6347{
6348 pci_unregister_driver(&s2io_driver); 6348 pci_unregister_driver(&s2io_driver);
6349 DBG_PRINT(INIT_DBG, "cleanup done\n"); 6349 DBG_PRINT(INIT_DBG, "cleanup done\n");
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 852a6a899d07..68ae33651947 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -64,7 +64,7 @@ typedef enum xena_max_outstanding_splits {
64#define INTR_DBG 4 64#define INTR_DBG 4
65 65
66/* Global variable that defines the present debug level of the driver. */ 66/* Global variable that defines the present debug level of the driver. */
67int debug_level = ERR_DBG; /* Default level. */ 67static int debug_level = ERR_DBG;
68 68
69/* DEBUG message print. */ 69/* DEBUG message print. */
70#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) 70#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args)
@@ -268,7 +268,7 @@ typedef struct stat_block {
268#define MAX_RX_RINGS 8 268#define MAX_RX_RINGS 8
269 269
270/* FIFO mappings for all possible number of fifos configured */ 270/* FIFO mappings for all possible number of fifos configured */
271int fifo_map[][MAX_TX_FIFOS] = { 271static int fifo_map[][MAX_TX_FIFOS] = {
272 {0, 0, 0, 0, 0, 0, 0, 0}, 272 {0, 0, 0, 0, 0, 0, 0, 0},
273 {0, 0, 0, 0, 1, 1, 1, 1}, 273 {0, 0, 0, 0, 1, 1, 1, 1},
274 {0, 0, 0, 1, 1, 1, 2, 2}, 274 {0, 0, 0, 1, 1, 1, 2, 2},
@@ -911,18 +911,16 @@ static void tx_intr_handler(fifo_info_t *fifo_data);
911static void alarm_intr_handler(struct s2io_nic *sp); 911static void alarm_intr_handler(struct s2io_nic *sp);
912 912
913static int s2io_starter(void); 913static int s2io_starter(void);
914void s2io_closer(void);
915static void s2io_tx_watchdog(struct net_device *dev); 914static void s2io_tx_watchdog(struct net_device *dev);
916static void s2io_tasklet(unsigned long dev_addr); 915static void s2io_tasklet(unsigned long dev_addr);
917static void s2io_set_multicast(struct net_device *dev); 916static void s2io_set_multicast(struct net_device *dev);
918static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp); 917static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp);
919void s2io_link(nic_t * sp, int link); 918static void s2io_link(nic_t * sp, int link);
920void s2io_reset(nic_t * sp);
921#if defined(CONFIG_S2IO_NAPI) 919#if defined(CONFIG_S2IO_NAPI)
922static int s2io_poll(struct net_device *dev, int *budget); 920static int s2io_poll(struct net_device *dev, int *budget);
923#endif 921#endif
924static void s2io_init_pci(nic_t * sp); 922static void s2io_init_pci(nic_t * sp);
925int s2io_set_mac_addr(struct net_device *dev, u8 * addr); 923static int s2io_set_mac_addr(struct net_device *dev, u8 * addr);
926static void s2io_alarm_handle(unsigned long data); 924static void s2io_alarm_handle(unsigned long data);
927static int s2io_enable_msi(nic_t *nic); 925static int s2io_enable_msi(nic_t *nic);
928static irqreturn_t s2io_msi_handle(int irq, void *dev_id, struct pt_regs *regs); 926static irqreturn_t s2io_msi_handle(int irq, void *dev_id, struct pt_regs *regs);
@@ -930,14 +928,13 @@ static irqreturn_t
930s2io_msix_ring_handle(int irq, void *dev_id, struct pt_regs *regs); 928s2io_msix_ring_handle(int irq, void *dev_id, struct pt_regs *regs);
931static irqreturn_t 929static irqreturn_t
932s2io_msix_fifo_handle(int irq, void *dev_id, struct pt_regs *regs); 930s2io_msix_fifo_handle(int irq, void *dev_id, struct pt_regs *regs);
933int s2io_enable_msi_x(nic_t *nic);
934static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs); 931static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs);
935static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag); 932static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
936static struct ethtool_ops netdev_ethtool_ops; 933static struct ethtool_ops netdev_ethtool_ops;
937static void s2io_set_link(unsigned long data); 934static void s2io_set_link(unsigned long data);
938int s2io_set_swapper(nic_t * sp); 935static int s2io_set_swapper(nic_t * sp);
939static void s2io_card_down(nic_t *nic); 936static void s2io_card_down(nic_t *nic);
940static int s2io_card_up(nic_t *nic); 937static int s2io_card_up(nic_t *nic);
941int get_xena_rev_id(struct pci_dev *pdev); 938static int get_xena_rev_id(struct pci_dev *pdev);
942void restore_xmsi_data(nic_t *nic); 939static void restore_xmsi_data(nic_t *nic);
943#endif /* _S2IO_H */ 940#endif /* _S2IO_H */
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
index 79dca398f3ac..bcef03feb2fc 100644
--- a/drivers/net/seeq8005.c
+++ b/drivers/net/seeq8005.c
@@ -46,6 +46,7 @@ static const char version[] =
46#include <linux/etherdevice.h> 46#include <linux/etherdevice.h>
47#include <linux/skbuff.h> 47#include <linux/skbuff.h>
48#include <linux/bitops.h> 48#include <linux/bitops.h>
49#include <linux/jiffies.h>
49 50
50#include <asm/system.h> 51#include <asm/system.h>
51#include <asm/io.h> 52#include <asm/io.h>
@@ -699,7 +700,7 @@ static void hardware_send_packet(struct net_device * dev, char *buf, int length)
699 int ioaddr = dev->base_addr; 700 int ioaddr = dev->base_addr;
700 int status = inw(SEEQ_STATUS); 701 int status = inw(SEEQ_STATUS);
701 int transmit_ptr = 0; 702 int transmit_ptr = 0;
702 int tmp; 703 unsigned long tmp;
703 704
704 if (net_debug>4) { 705 if (net_debug>4) {
705 printk("%s: send 0x%04x\n",dev->name,length); 706 printk("%s: send 0x%04x\n",dev->name,length);
@@ -724,7 +725,7 @@ static void hardware_send_packet(struct net_device * dev, char *buf, int length)
724 725
725 /* drain FIFO */ 726 /* drain FIFO */
726 tmp = jiffies; 727 tmp = jiffies;
727 while ( (((status=inw(SEEQ_STATUS)) & SEEQSTAT_FIFO_EMPTY) == 0) && (jiffies - tmp < HZ)) 728 while ( (((status=inw(SEEQ_STATUS)) & SEEQSTAT_FIFO_EMPTY) == 0) && time_before(jiffies, tmp + HZ))
728 mb(); 729 mb();
729 730
730 /* doit ! */ 731 /* doit ! */
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c
index 221354eea21f..88e212043a43 100644
--- a/drivers/net/shaper.c
+++ b/drivers/net/shaper.c
@@ -83,6 +83,7 @@
83#include <linux/if_arp.h> 83#include <linux/if_arp.h>
84#include <linux/init.h> 84#include <linux/init.h>
85#include <linux/if_shaper.h> 85#include <linux/if_shaper.h>
86#include <linux/jiffies.h>
86 87
87#include <net/dst.h> 88#include <net/dst.h>
88#include <net/arp.h> 89#include <net/arp.h>
@@ -168,7 +169,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
168 /* 169 /*
169 * Queue over time. Spill packet. 170 * Queue over time. Spill packet.
170 */ 171 */
171 if(SHAPERCB(skb)->shapeclock-jiffies > SHAPER_LATENCY) { 172 if(time_after(SHAPERCB(skb)->shapeclock,jiffies + SHAPER_LATENCY)) {
172 dev_kfree_skb(skb); 173 dev_kfree_skb(skb);
173 shaper->stats.tx_dropped++; 174 shaper->stats.tx_dropped++;
174 } else 175 } else
diff --git a/drivers/net/sk98lin/h/skaddr.h b/drivers/net/sk98lin/h/skaddr.h
index 3a2ea4a4b539..423ad063d09b 100644
--- a/drivers/net/sk98lin/h/skaddr.h
+++ b/drivers/net/sk98lin/h/skaddr.h
@@ -236,18 +236,6 @@ extern int SkAddrMcClear(
236 SK_U32 PortNumber, 236 SK_U32 PortNumber,
237 int Flags); 237 int Flags);
238 238
239extern int SkAddrXmacMcClear(
240 SK_AC *pAC,
241 SK_IOC IoC,
242 SK_U32 PortNumber,
243 int Flags);
244
245extern int SkAddrGmacMcClear(
246 SK_AC *pAC,
247 SK_IOC IoC,
248 SK_U32 PortNumber,
249 int Flags);
250
251extern int SkAddrMcAdd( 239extern int SkAddrMcAdd(
252 SK_AC *pAC, 240 SK_AC *pAC,
253 SK_IOC IoC, 241 SK_IOC IoC,
@@ -255,35 +243,11 @@ extern int SkAddrMcAdd(
255 SK_MAC_ADDR *pMc, 243 SK_MAC_ADDR *pMc,
256 int Flags); 244 int Flags);
257 245
258extern int SkAddrXmacMcAdd(
259 SK_AC *pAC,
260 SK_IOC IoC,
261 SK_U32 PortNumber,
262 SK_MAC_ADDR *pMc,
263 int Flags);
264
265extern int SkAddrGmacMcAdd(
266 SK_AC *pAC,
267 SK_IOC IoC,
268 SK_U32 PortNumber,
269 SK_MAC_ADDR *pMc,
270 int Flags);
271
272extern int SkAddrMcUpdate( 246extern int SkAddrMcUpdate(
273 SK_AC *pAC, 247 SK_AC *pAC,
274 SK_IOC IoC, 248 SK_IOC IoC,
275 SK_U32 PortNumber); 249 SK_U32 PortNumber);
276 250
277extern int SkAddrXmacMcUpdate(
278 SK_AC *pAC,
279 SK_IOC IoC,
280 SK_U32 PortNumber);
281
282extern int SkAddrGmacMcUpdate(
283 SK_AC *pAC,
284 SK_IOC IoC,
285 SK_U32 PortNumber);
286
287extern int SkAddrOverride( 251extern int SkAddrOverride(
288 SK_AC *pAC, 252 SK_AC *pAC,
289 SK_IOC IoC, 253 SK_IOC IoC,
@@ -297,18 +261,6 @@ extern int SkAddrPromiscuousChange(
297 SK_U32 PortNumber, 261 SK_U32 PortNumber,
298 int NewPromMode); 262 int NewPromMode);
299 263
300extern int SkAddrXmacPromiscuousChange(
301 SK_AC *pAC,
302 SK_IOC IoC,
303 SK_U32 PortNumber,
304 int NewPromMode);
305
306extern int SkAddrGmacPromiscuousChange(
307 SK_AC *pAC,
308 SK_IOC IoC,
309 SK_U32 PortNumber,
310 int NewPromMode);
311
312#ifndef SK_SLIM 264#ifndef SK_SLIM
313extern int SkAddrSwap( 265extern int SkAddrSwap(
314 SK_AC *pAC, 266 SK_AC *pAC,
diff --git a/drivers/net/sk98lin/h/skcsum.h b/drivers/net/sk98lin/h/skcsum.h
index 2b94adb93331..6e256bd9a28c 100644
--- a/drivers/net/sk98lin/h/skcsum.h
+++ b/drivers/net/sk98lin/h/skcsum.h
@@ -203,12 +203,6 @@ extern SKCS_STATUS SkCsGetReceiveInfo(
203 unsigned Checksum2, 203 unsigned Checksum2,
204 int NetNumber); 204 int NetNumber);
205 205
206extern void SkCsGetSendInfo(
207 SK_AC *pAc,
208 void *pIpHeader,
209 SKCS_PACKET_INFO *pPacketInfo,
210 int NetNumber);
211
212extern void SkCsSetReceiveFlags( 206extern void SkCsSetReceiveFlags(
213 SK_AC *pAc, 207 SK_AC *pAc,
214 unsigned ReceiveFlags, 208 unsigned ReceiveFlags,
diff --git a/drivers/net/sk98lin/h/skgeinit.h b/drivers/net/sk98lin/h/skgeinit.h
index 184f47c5a60f..143e635ec24d 100644
--- a/drivers/net/sk98lin/h/skgeinit.h
+++ b/drivers/net/sk98lin/h/skgeinit.h
@@ -464,12 +464,6 @@ typedef struct s_GeInit {
464/* 464/*
465 * public functions in skgeinit.c 465 * public functions in skgeinit.c
466 */ 466 */
467extern void SkGePollRxD(
468 SK_AC *pAC,
469 SK_IOC IoC,
470 int Port,
471 SK_BOOL PollRxD);
472
473extern void SkGePollTxD( 467extern void SkGePollTxD(
474 SK_AC *pAC, 468 SK_AC *pAC,
475 SK_IOC IoC, 469 SK_IOC IoC,
@@ -522,10 +516,6 @@ extern void SkGeXmitLED(
522 int Led, 516 int Led,
523 int Mode); 517 int Mode);
524 518
525extern void SkGeInitRamIface(
526 SK_AC *pAC,
527 SK_IOC IoC);
528
529extern int SkGeInitAssignRamToQueues( 519extern int SkGeInitAssignRamToQueues(
530 SK_AC *pAC, 520 SK_AC *pAC,
531 int ActivePort, 521 int ActivePort,
@@ -549,11 +539,6 @@ extern void SkMacHardRst(
549 SK_IOC IoC, 539 SK_IOC IoC,
550 int Port); 540 int Port);
551 541
552extern void SkMacClearRst(
553 SK_AC *pAC,
554 SK_IOC IoC,
555 int Port);
556
557extern void SkXmInitMac( 542extern void SkXmInitMac(
558 SK_AC *pAC, 543 SK_AC *pAC,
559 SK_IOC IoC, 544 SK_IOC IoC,
@@ -580,11 +565,6 @@ extern void SkMacFlushTxFifo(
580 SK_IOC IoC, 565 SK_IOC IoC,
581 int Port); 566 int Port);
582 567
583extern void SkMacFlushRxFifo(
584 SK_AC *pAC,
585 SK_IOC IoC,
586 int Port);
587
588extern void SkMacIrq( 568extern void SkMacIrq(
589 SK_AC *pAC, 569 SK_AC *pAC,
590 SK_IOC IoC, 570 SK_IOC IoC,
@@ -601,12 +581,6 @@ extern void SkMacAutoNegLipaPhy(
601 int Port, 581 int Port,
602 SK_U16 IStatus); 582 SK_U16 IStatus);
603 583
604extern void SkMacSetRxTxEn(
605 SK_AC *pAC,
606 SK_IOC IoC,
607 int Port,
608 int Para);
609
610extern int SkMacRxTxEnable( 584extern int SkMacRxTxEnable(
611 SK_AC *pAC, 585 SK_AC *pAC,
612 SK_IOC IoC, 586 SK_IOC IoC,
@@ -659,16 +633,6 @@ extern void SkXmClrExactAddr(
659 int StartNum, 633 int StartNum,
660 int StopNum); 634 int StopNum);
661 635
662extern void SkXmInitDupMd(
663 SK_AC *pAC,
664 SK_IOC IoC,
665 int Port);
666
667extern void SkXmInitPauseMd(
668 SK_AC *pAC,
669 SK_IOC IoC,
670 int Port);
671
672extern void SkXmAutoNegLipaXmac( 636extern void SkXmAutoNegLipaXmac(
673 SK_AC *pAC, 637 SK_AC *pAC,
674 SK_IOC IoC, 638 SK_IOC IoC,
@@ -729,17 +693,6 @@ extern int SkGmCableDiagStatus(
729 int Port, 693 int Port,
730 SK_BOOL StartTest); 694 SK_BOOL StartTest);
731 695
732extern int SkGmEnterLowPowerMode(
733 SK_AC *pAC,
734 SK_IOC IoC,
735 int Port,
736 SK_U8 Mode);
737
738extern int SkGmLeaveLowPowerMode(
739 SK_AC *pAC,
740 SK_IOC IoC,
741 int Port);
742
743#ifdef SK_DIAG 696#ifdef SK_DIAG
744extern void SkGePhyRead( 697extern void SkGePhyRead(
745 SK_AC *pAC, 698 SK_AC *pAC,
@@ -782,7 +735,6 @@ extern void SkXmSendCont(
782/* 735/*
783 * public functions in skgeinit.c 736 * public functions in skgeinit.c
784 */ 737 */
785extern void SkGePollRxD();
786extern void SkGePollTxD(); 738extern void SkGePollTxD();
787extern void SkGeYellowLED(); 739extern void SkGeYellowLED();
788extern int SkGeCfgSync(); 740extern int SkGeCfgSync();
@@ -792,7 +744,6 @@ extern int SkGeInit();
792extern void SkGeDeInit(); 744extern void SkGeDeInit();
793extern int SkGeInitPort(); 745extern int SkGeInitPort();
794extern void SkGeXmitLED(); 746extern void SkGeXmitLED();
795extern void SkGeInitRamIface();
796extern int SkGeInitAssignRamToQueues(); 747extern int SkGeInitAssignRamToQueues();
797 748
798/* 749/*
@@ -801,18 +752,15 @@ extern int SkGeInitAssignRamToQueues();
801extern void SkMacRxTxDisable(); 752extern void SkMacRxTxDisable();
802extern void SkMacSoftRst(); 753extern void SkMacSoftRst();
803extern void SkMacHardRst(); 754extern void SkMacHardRst();
804extern void SkMacClearRst();
805extern void SkMacInitPhy(); 755extern void SkMacInitPhy();
806extern int SkMacRxTxEnable(); 756extern int SkMacRxTxEnable();
807extern void SkMacPromiscMode(); 757extern void SkMacPromiscMode();
808extern void SkMacHashing(); 758extern void SkMacHashing();
809extern void SkMacIrqDisable(); 759extern void SkMacIrqDisable();
810extern void SkMacFlushTxFifo(); 760extern void SkMacFlushTxFifo();
811extern void SkMacFlushRxFifo();
812extern void SkMacIrq(); 761extern void SkMacIrq();
813extern int SkMacAutoNegDone(); 762extern int SkMacAutoNegDone();
814extern void SkMacAutoNegLipaPhy(); 763extern void SkMacAutoNegLipaPhy();
815extern void SkMacSetRxTxEn();
816extern void SkXmInitMac(); 764extern void SkXmInitMac();
817extern void SkXmPhyRead(); 765extern void SkXmPhyRead();
818extern void SkXmPhyWrite(); 766extern void SkXmPhyWrite();
@@ -820,8 +768,6 @@ extern void SkGmInitMac();
820extern void SkGmPhyRead(); 768extern void SkGmPhyRead();
821extern void SkGmPhyWrite(); 769extern void SkGmPhyWrite();
822extern void SkXmClrExactAddr(); 770extern void SkXmClrExactAddr();
823extern void SkXmInitDupMd();
824extern void SkXmInitPauseMd();
825extern void SkXmAutoNegLipaXmac(); 771extern void SkXmAutoNegLipaXmac();
826extern int SkXmUpdateStats(); 772extern int SkXmUpdateStats();
827extern int SkGmUpdateStats(); 773extern int SkGmUpdateStats();
@@ -832,8 +778,6 @@ extern int SkGmResetCounter();
832extern int SkXmOverflowStatus(); 778extern int SkXmOverflowStatus();
833extern int SkGmOverflowStatus(); 779extern int SkGmOverflowStatus();
834extern int SkGmCableDiagStatus(); 780extern int SkGmCableDiagStatus();
835extern int SkGmEnterLowPowerMode();
836extern int SkGmLeaveLowPowerMode();
837 781
838#ifdef SK_DIAG 782#ifdef SK_DIAG
839extern void SkGePhyRead(); 783extern void SkGePhyRead();
diff --git a/drivers/net/sk98lin/h/skgepnmi.h b/drivers/net/sk98lin/h/skgepnmi.h
index 3b2773e6f822..1ed214ccb253 100644
--- a/drivers/net/sk98lin/h/skgepnmi.h
+++ b/drivers/net/sk98lin/h/skgepnmi.h
@@ -946,10 +946,6 @@ typedef struct s_PnmiData {
946 * Function prototypes 946 * Function prototypes
947 */ 947 */
948extern int SkPnmiInit(SK_AC *pAC, SK_IOC IoC, int Level); 948extern int SkPnmiInit(SK_AC *pAC, SK_IOC IoC, int Level);
949extern int SkPnmiGetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void* pBuf,
950 unsigned int* pLen, SK_U32 Instance, SK_U32 NetIndex);
951extern int SkPnmiPreSetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id,
952 void* pBuf, unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
953extern int SkPnmiSetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void* pBuf, 949extern int SkPnmiSetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void* pBuf,
954 unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex); 950 unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
955extern int SkPnmiGetStruct(SK_AC *pAC, SK_IOC IoC, void* pBuf, 951extern int SkPnmiGetStruct(SK_AC *pAC, SK_IOC IoC, void* pBuf,
diff --git a/drivers/net/sk98lin/h/skgesirq.h b/drivers/net/sk98lin/h/skgesirq.h
index b486bd9b6628..3eec6274e413 100644
--- a/drivers/net/sk98lin/h/skgesirq.h
+++ b/drivers/net/sk98lin/h/skgesirq.h
@@ -105,7 +105,6 @@
105 105
106extern void SkGeSirqIsr(SK_AC *pAC, SK_IOC IoC, SK_U32 Istatus); 106extern void SkGeSirqIsr(SK_AC *pAC, SK_IOC IoC, SK_U32 Istatus);
107extern int SkGeSirqEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para); 107extern int SkGeSirqEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
108extern void SkHWLinkUp(SK_AC *pAC, SK_IOC IoC, int Port);
109extern void SkHWLinkDown(SK_AC *pAC, SK_IOC IoC, int Port); 108extern void SkHWLinkDown(SK_AC *pAC, SK_IOC IoC, int Port);
110 109
111#endif /* _INC_SKGESIRQ_H_ */ 110#endif /* _INC_SKGESIRQ_H_ */
diff --git a/drivers/net/sk98lin/h/ski2c.h b/drivers/net/sk98lin/h/ski2c.h
index 598bb42ccc3d..6a63f4a15de6 100644
--- a/drivers/net/sk98lin/h/ski2c.h
+++ b/drivers/net/sk98lin/h/ski2c.h
@@ -162,9 +162,6 @@ typedef struct s_I2c {
162} SK_I2C; 162} SK_I2C;
163 163
164extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level); 164extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
165extern int SkI2cWrite(SK_AC *pAC, SK_IOC IoC, SK_U32 Data, int Dev, int Size,
166 int Reg, int Burst);
167extern int SkI2cReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
168#ifdef SK_DIAG 165#ifdef SK_DIAG
169extern SK_U32 SkI2cRead(SK_AC *pAC, SK_IOC IoC, int Dev, int Size, int Reg, 166extern SK_U32 SkI2cRead(SK_AC *pAC, SK_IOC IoC, int Dev, int Size, int Reg,
170 int Burst); 167 int Burst);
diff --git a/drivers/net/sk98lin/h/skvpd.h b/drivers/net/sk98lin/h/skvpd.h
index daa9a8d154fc..fdd9e48e8040 100644
--- a/drivers/net/sk98lin/h/skvpd.h
+++ b/drivers/net/sk98lin/h/skvpd.h
@@ -183,14 +183,6 @@ extern SK_U32 VpdReadDWord(
183 int addr); 183 int addr);
184#endif /* SKDIAG */ 184#endif /* SKDIAG */
185 185
186extern int VpdSetupPara(
187 SK_AC *pAC,
188 const char *key,
189 const char *buf,
190 int len,
191 int type,
192 int op);
193
194extern SK_VPD_STATUS *VpdStat( 186extern SK_VPD_STATUS *VpdStat(
195 SK_AC *pAC, 187 SK_AC *pAC,
196 SK_IOC IoC); 188 SK_IOC IoC);
@@ -227,11 +219,6 @@ extern int VpdUpdate(
227 SK_AC *pAC, 219 SK_AC *pAC,
228 SK_IOC IoC); 220 SK_IOC IoC);
229 221
230extern void VpdErrLog(
231 SK_AC *pAC,
232 SK_IOC IoC,
233 char *msg);
234
235#ifdef SKDIAG 222#ifdef SKDIAG
236extern int VpdReadBlock( 223extern int VpdReadBlock(
237 SK_AC *pAC, 224 SK_AC *pAC,
@@ -249,7 +236,6 @@ extern int VpdWriteBlock(
249#endif /* SKDIAG */ 236#endif /* SKDIAG */
250#else /* SK_KR_PROTO */ 237#else /* SK_KR_PROTO */
251extern SK_U32 VpdReadDWord(); 238extern SK_U32 VpdReadDWord();
252extern int VpdSetupPara();
253extern SK_VPD_STATUS *VpdStat(); 239extern SK_VPD_STATUS *VpdStat();
254extern int VpdKeys(); 240extern int VpdKeys();
255extern int VpdRead(); 241extern int VpdRead();
@@ -257,7 +243,6 @@ extern SK_BOOL VpdMayWrite();
257extern int VpdWrite(); 243extern int VpdWrite();
258extern int VpdDelete(); 244extern int VpdDelete();
259extern int VpdUpdate(); 245extern int VpdUpdate();
260extern void VpdErrLog();
261#endif /* SK_KR_PROTO */ 246#endif /* SK_KR_PROTO */
262 247
263#endif /* __INC_SKVPD_H_ */ 248#endif /* __INC_SKVPD_H_ */
diff --git a/drivers/net/sk98lin/skaddr.c b/drivers/net/sk98lin/skaddr.c
index a7e25edc7fc4..6e6c56aa6d6f 100644
--- a/drivers/net/sk98lin/skaddr.c
+++ b/drivers/net/sk98lin/skaddr.c
@@ -87,6 +87,21 @@ static const SK_U16 OnesHash[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
87static int Next0[SK_MAX_MACS] = {0}; 87static int Next0[SK_MAX_MACS] = {0};
88#endif /* DEBUG */ 88#endif /* DEBUG */
89 89
90static int SkAddrGmacMcAdd(SK_AC *pAC, SK_IOC IoC, SK_U32 PortNumber,
91 SK_MAC_ADDR *pMc, int Flags);
92static int SkAddrGmacMcClear(SK_AC *pAC, SK_IOC IoC, SK_U32 PortNumber,
93 int Flags);
94static int SkAddrGmacMcUpdate(SK_AC *pAC, SK_IOC IoC, SK_U32 PortNumber);
95static int SkAddrGmacPromiscuousChange(SK_AC *pAC, SK_IOC IoC,
96 SK_U32 PortNumber, int NewPromMode);
97static int SkAddrXmacMcAdd(SK_AC *pAC, SK_IOC IoC, SK_U32 PortNumber,
98 SK_MAC_ADDR *pMc, int Flags);
99static int SkAddrXmacMcClear(SK_AC *pAC, SK_IOC IoC, SK_U32 PortNumber,
100 int Flags);
101static int SkAddrXmacMcUpdate(SK_AC *pAC, SK_IOC IoC, SK_U32 PortNumber);
102static int SkAddrXmacPromiscuousChange(SK_AC *pAC, SK_IOC IoC,
103 SK_U32 PortNumber, int NewPromMode);
104
90/* functions ******************************************************************/ 105/* functions ******************************************************************/
91 106
92/****************************************************************************** 107/******************************************************************************
@@ -372,7 +387,7 @@ int Flags) /* permanent/non-perm, sw-only */
372 * SK_ADDR_SUCCESS 387 * SK_ADDR_SUCCESS
373 * SK_ADDR_ILLEGAL_PORT 388 * SK_ADDR_ILLEGAL_PORT
374 */ 389 */
375int SkAddrXmacMcClear( 390static int SkAddrXmacMcClear(
376SK_AC *pAC, /* adapter context */ 391SK_AC *pAC, /* adapter context */
377SK_IOC IoC, /* I/O context */ 392SK_IOC IoC, /* I/O context */
378SK_U32 PortNumber, /* Index of affected port */ 393SK_U32 PortNumber, /* Index of affected port */
@@ -429,7 +444,7 @@ int Flags) /* permanent/non-perm, sw-only */
429 * SK_ADDR_SUCCESS 444 * SK_ADDR_SUCCESS
430 * SK_ADDR_ILLEGAL_PORT 445 * SK_ADDR_ILLEGAL_PORT
431 */ 446 */
432int SkAddrGmacMcClear( 447static int SkAddrGmacMcClear(
433SK_AC *pAC, /* adapter context */ 448SK_AC *pAC, /* adapter context */
434SK_IOC IoC, /* I/O context */ 449SK_IOC IoC, /* I/O context */
435SK_U32 PortNumber, /* Index of affected port */ 450SK_U32 PortNumber, /* Index of affected port */
@@ -519,7 +534,7 @@ int Flags) /* permanent/non-perm, sw-only */
519 * Returns: 534 * Returns:
520 * Hash value of multicast address. 535 * Hash value of multicast address.
521 */ 536 */
522SK_U32 SkXmacMcHash( 537static SK_U32 SkXmacMcHash(
523unsigned char *pMc) /* Multicast address */ 538unsigned char *pMc) /* Multicast address */
524{ 539{
525 SK_U32 Idx; 540 SK_U32 Idx;
@@ -557,7 +572,7 @@ unsigned char *pMc) /* Multicast address */
557 * Returns: 572 * Returns:
558 * Hash value of multicast address. 573 * Hash value of multicast address.
559 */ 574 */
560SK_U32 SkGmacMcHash( 575static SK_U32 SkGmacMcHash(
561unsigned char *pMc) /* Multicast address */ 576unsigned char *pMc) /* Multicast address */
562{ 577{
563 SK_U32 Data; 578 SK_U32 Data;
@@ -672,7 +687,7 @@ int Flags) /* permanent/non-permanent */
672 * SK_MC_ILLEGAL_ADDRESS 687 * SK_MC_ILLEGAL_ADDRESS
673 * SK_MC_RLMT_OVERFLOW 688 * SK_MC_RLMT_OVERFLOW
674 */ 689 */
675int SkAddrXmacMcAdd( 690static int SkAddrXmacMcAdd(
676SK_AC *pAC, /* adapter context */ 691SK_AC *pAC, /* adapter context */
677SK_IOC IoC, /* I/O context */ 692SK_IOC IoC, /* I/O context */
678SK_U32 PortNumber, /* Port Number */ 693SK_U32 PortNumber, /* Port Number */
@@ -778,7 +793,7 @@ int Flags) /* permanent/non-permanent */
778 * SK_MC_FILTERING_INEXACT 793 * SK_MC_FILTERING_INEXACT
779 * SK_MC_ILLEGAL_ADDRESS 794 * SK_MC_ILLEGAL_ADDRESS
780 */ 795 */
781int SkAddrGmacMcAdd( 796static int SkAddrGmacMcAdd(
782SK_AC *pAC, /* adapter context */ 797SK_AC *pAC, /* adapter context */
783SK_IOC IoC, /* I/O context */ 798SK_IOC IoC, /* I/O context */
784SK_U32 PortNumber, /* Port Number */ 799SK_U32 PortNumber, /* Port Number */
@@ -937,7 +952,7 @@ SK_U32 PortNumber) /* Port Number */
937 * SK_MC_FILTERING_INEXACT 952 * SK_MC_FILTERING_INEXACT
938 * SK_ADDR_ILLEGAL_PORT 953 * SK_ADDR_ILLEGAL_PORT
939 */ 954 */
940int SkAddrXmacMcUpdate( 955static int SkAddrXmacMcUpdate(
941SK_AC *pAC, /* adapter context */ 956SK_AC *pAC, /* adapter context */
942SK_IOC IoC, /* I/O context */ 957SK_IOC IoC, /* I/O context */
943SK_U32 PortNumber) /* Port Number */ 958SK_U32 PortNumber) /* Port Number */
@@ -1082,7 +1097,7 @@ SK_U32 PortNumber) /* Port Number */
1082 * SK_MC_FILTERING_INEXACT 1097 * SK_MC_FILTERING_INEXACT
1083 * SK_ADDR_ILLEGAL_PORT 1098 * SK_ADDR_ILLEGAL_PORT
1084 */ 1099 */
1085int SkAddrGmacMcUpdate( 1100static int SkAddrGmacMcUpdate(
1086SK_AC *pAC, /* adapter context */ 1101SK_AC *pAC, /* adapter context */
1087SK_IOC IoC, /* I/O context */ 1102SK_IOC IoC, /* I/O context */
1088SK_U32 PortNumber) /* Port Number */ 1103SK_U32 PortNumber) /* Port Number */
@@ -1468,7 +1483,7 @@ int NewPromMode) /* new promiscuous mode */
1468 * SK_ADDR_SUCCESS 1483 * SK_ADDR_SUCCESS
1469 * SK_ADDR_ILLEGAL_PORT 1484 * SK_ADDR_ILLEGAL_PORT
1470 */ 1485 */
1471int SkAddrXmacPromiscuousChange( 1486static int SkAddrXmacPromiscuousChange(
1472SK_AC *pAC, /* adapter context */ 1487SK_AC *pAC, /* adapter context */
1473SK_IOC IoC, /* I/O context */ 1488SK_IOC IoC, /* I/O context */
1474SK_U32 PortNumber, /* port whose promiscuous mode changes */ 1489SK_U32 PortNumber, /* port whose promiscuous mode changes */
@@ -1585,7 +1600,7 @@ int NewPromMode) /* new promiscuous mode */
1585 * SK_ADDR_SUCCESS 1600 * SK_ADDR_SUCCESS
1586 * SK_ADDR_ILLEGAL_PORT 1601 * SK_ADDR_ILLEGAL_PORT
1587 */ 1602 */
1588int SkAddrGmacPromiscuousChange( 1603static int SkAddrGmacPromiscuousChange(
1589SK_AC *pAC, /* adapter context */ 1604SK_AC *pAC, /* adapter context */
1590SK_IOC IoC, /* I/O context */ 1605SK_IOC IoC, /* I/O context */
1591SK_U32 PortNumber, /* port whose promiscuous mode changes */ 1606SK_U32 PortNumber, /* port whose promiscuous mode changes */
diff --git a/drivers/net/sk98lin/skgeinit.c b/drivers/net/sk98lin/skgeinit.c
index 6cb49dd02251..67f1d6a5c15d 100644
--- a/drivers/net/sk98lin/skgeinit.c
+++ b/drivers/net/sk98lin/skgeinit.c
@@ -59,34 +59,6 @@ static struct s_Config OemConfig = {
59 59
60/****************************************************************************** 60/******************************************************************************
61 * 61 *
62 * SkGePollRxD() - Enable / Disable Descriptor Polling of RxD Ring
63 *
64 * Description:
65 * Enable or disable the descriptor polling of the receive descriptor
66 * ring (RxD) for port 'Port'.
67 * The new configuration is *not* saved over any SkGeStopPort() and
68 * SkGeInitPort() calls.
69 *
70 * Returns:
71 * nothing
72 */
73void SkGePollRxD(
74SK_AC *pAC, /* adapter context */
75SK_IOC IoC, /* IO context */
76int Port, /* Port Index (MAC_1 + n) */
77SK_BOOL PollRxD) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
78{
79 SK_GEPORT *pPrt;
80
81 pPrt = &pAC->GIni.GP[Port];
82
83 SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), (PollRxD) ?
84 CSR_ENA_POL : CSR_DIS_POL);
85} /* SkGePollRxD */
86
87
88/******************************************************************************
89 *
90 * SkGePollTxD() - Enable / Disable Descriptor Polling of TxD Rings 62 * SkGePollTxD() - Enable / Disable Descriptor Polling of TxD Rings
91 * 63 *
92 * Description: 64 * Description:
@@ -952,7 +924,7 @@ int Port) /* Port Index (MAC_1 + n) */
952 * Returns: 924 * Returns:
953 * nothing 925 * nothing
954 */ 926 */
955void SkGeInitRamIface( 927static void SkGeInitRamIface(
956SK_AC *pAC, /* adapter context */ 928SK_AC *pAC, /* adapter context */
957SK_IOC IoC) /* IO context */ 929SK_IOC IoC) /* IO context */
958{ 930{
@@ -1409,83 +1381,6 @@ SK_IOC IoC) /* IO context */
1409 1381
1410} /* SkGeInit0*/ 1382} /* SkGeInit0*/
1411 1383
1412#ifdef SK_PCI_RESET
1413
1414/******************************************************************************
1415 *
1416 * SkGePciReset() - Reset PCI interface
1417 *
1418 * Description:
1419 * o Read PCI configuration.
1420 * o Change power state to 3.
1421 * o Change power state to 0.
1422 * o Restore PCI configuration.
1423 *
1424 * Returns:
1425 * 0: Success.
1426 * 1: Power state could not be changed to 3.
1427 */
1428static int SkGePciReset(
1429SK_AC *pAC, /* adapter context */
1430SK_IOC IoC) /* IO context */
1431{
1432 int i;
1433 SK_U16 PmCtlSts;
1434 SK_U32 Bp1;
1435 SK_U32 Bp2;
1436 SK_U16 PciCmd;
1437 SK_U8 Cls;
1438 SK_U8 Lat;
1439 SK_U8 ConfigSpace[PCI_CFG_SIZE];
1440
1441 /*
1442 * Note: Switching to D3 state is like a software reset.
1443 * Switching from D3 to D0 is a hardware reset.
1444 * We have to save and restore the configuration space.
1445 */
1446 for (i = 0; i < PCI_CFG_SIZE; i++) {
1447 SkPciReadCfgDWord(pAC, i*4, &ConfigSpace[i]);
1448 }
1449
1450 /* We know the RAM Interface Arbiter is enabled. */
1451 SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D3);
1452 SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
1453
1454 if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D3) {
1455 return(1);
1456 }
1457
1458 /* Return to D0 state. */
1459 SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D0);
1460
1461 /* Check for D0 state. */
1462 SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts);
1463
1464 if ((PmCtlSts & PCI_PM_STATE_MSK) != PCI_PM_STATE_D0) {
1465 return(1);
1466 }
1467
1468 /* Check PCI Config Registers. */
1469 SkPciReadCfgWord(pAC, PCI_COMMAND, &PciCmd);
1470 SkPciReadCfgByte(pAC, PCI_CACHE_LSZ, &Cls);
1471 SkPciReadCfgDWord(pAC, PCI_BASE_1ST, &Bp1);
1472 SkPciReadCfgDWord(pAC, PCI_BASE_2ND, &Bp2);
1473 SkPciReadCfgByte(pAC, PCI_LAT_TIM, &Lat);
1474
1475 if (PciCmd != 0 || Cls != (SK_U8)0 || Lat != (SK_U8)0 ||
1476 (Bp1 & 0xfffffff0L) != 0 || Bp2 != 1) {
1477 return(1);
1478 }
1479
1480 /* Restore PCI Config Space. */
1481 for (i = 0; i < PCI_CFG_SIZE; i++) {
1482 SkPciWriteCfgDWord(pAC, i*4, ConfigSpace[i]);
1483 }
1484
1485 return(0);
1486} /* SkGePciReset */
1487
1488#endif /* SK_PCI_RESET */
1489 1384
1490/****************************************************************************** 1385/******************************************************************************
1491 * 1386 *
@@ -1524,10 +1419,6 @@ SK_IOC IoC) /* IO context */
1524 /* save CLK_RUN bits (YUKON-Lite) */ 1419 /* save CLK_RUN bits (YUKON-Lite) */
1525 SK_IN16(IoC, B0_CTST, &CtrlStat); 1420 SK_IN16(IoC, B0_CTST, &CtrlStat);
1526 1421
1527#ifdef SK_PCI_RESET
1528 (void)SkGePciReset(pAC, IoC);
1529#endif /* SK_PCI_RESET */
1530
1531 /* do the SW-reset */ 1422 /* do the SW-reset */
1532 SK_OUT8(IoC, B0_CTST, CS_RST_SET); 1423 SK_OUT8(IoC, B0_CTST, CS_RST_SET);
1533 1424
@@ -1991,11 +1882,6 @@ SK_IOC IoC) /* IO context */
1991 int i; 1882 int i;
1992 SK_U16 Word; 1883 SK_U16 Word;
1993 1884
1994#ifdef SK_PHY_LP_MODE
1995 SK_U8 Byte;
1996 SK_U16 PmCtlSts;
1997#endif /* SK_PHY_LP_MODE */
1998
1999#if (!defined(SK_SLIM) && !defined(VCPU)) 1885#if (!defined(SK_SLIM) && !defined(VCPU))
2000 /* ensure I2C is ready */ 1886 /* ensure I2C is ready */
2001 SkI2cWaitIrq(pAC, IoC); 1887 SkI2cWaitIrq(pAC, IoC);
@@ -2010,38 +1896,6 @@ SK_IOC IoC) /* IO context */
2010 } 1896 }
2011 } 1897 }
2012 1898
2013#ifdef SK_PHY_LP_MODE
2014 /*
2015 * for power saving purposes within mobile environments
2016 * we set the PHY to coma mode and switch to D3 power state.
2017 */
2018 if (pAC->GIni.GIYukonLite &&
2019 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2020
2021 /* for all ports switch PHY to coma mode */
2022 for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
2023
2024 SkGmEnterLowPowerMode(pAC, IoC, i, PHY_PM_DEEP_SLEEP);
2025 }
2026
2027 if (pAC->GIni.GIVauxAvail) {
2028 /* switch power to VAUX */
2029 Byte = PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_ON | PC_VCC_OFF;
2030
2031 SK_OUT8(IoC, B0_POWER_CTRL, Byte);
2032 }
2033
2034 /* switch to D3 state */
2035 SK_IN16(IoC, PCI_C(PCI_PM_CTL_STS), &PmCtlSts);
2036
2037 PmCtlSts |= PCI_PM_STATE_D3;
2038
2039 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2040
2041 SK_OUT16(IoC, PCI_C(PCI_PM_CTL_STS), PmCtlSts);
2042 }
2043#endif /* SK_PHY_LP_MODE */
2044
2045 /* Reset all bits in the PCI STATUS register */ 1899 /* Reset all bits in the PCI STATUS register */
2046 /* 1900 /*
2047 * Note: PCI Cfg cycles cannot be used, because they are not 1901 * Note: PCI Cfg cycles cannot be used, because they are not
diff --git a/drivers/net/sk98lin/skgemib.c b/drivers/net/sk98lin/skgemib.c
index 2991bc85cf2c..0a6f67a7a395 100644
--- a/drivers/net/sk98lin/skgemib.c
+++ b/drivers/net/sk98lin/skgemib.c
@@ -871,13 +871,6 @@ PNMI_STATIC const SK_PNMI_TAB_ENTRY IdTable[] = {
871 sizeof(SK_PNMI_CONF), 871 sizeof(SK_PNMI_CONF),
872 SK_PNMI_OFF(Conf) + SK_PNMI_CNF_OFF(ConfPhyType), 872 SK_PNMI_OFF(Conf) + SK_PNMI_CNF_OFF(ConfPhyType),
873 SK_PNMI_RO, MacPrivateConf, 0}, 873 SK_PNMI_RO, MacPrivateConf, 0},
874#ifdef SK_PHY_LP_MODE
875 {OID_SKGE_PHY_LP_MODE,
876 SK_PNMI_MAC_ENTRIES,
877 sizeof(SK_PNMI_CONF),
878 SK_PNMI_OFF(Conf) + SK_PNMI_CNF_OFF(ConfPhyMode),
879 SK_PNMI_RW, MacPrivateConf, 0},
880#endif
881 {OID_SKGE_LINK_CAP, 874 {OID_SKGE_LINK_CAP,
882 SK_PNMI_MAC_ENTRIES, 875 SK_PNMI_MAC_ENTRIES,
883 sizeof(SK_PNMI_CONF), 876 sizeof(SK_PNMI_CONF),
diff --git a/drivers/net/sk98lin/skgepnmi.c b/drivers/net/sk98lin/skgepnmi.c
index a386172107e8..b36dd9ac6b29 100644
--- a/drivers/net/sk98lin/skgepnmi.c
+++ b/drivers/net/sk98lin/skgepnmi.c
@@ -56,10 +56,6 @@ static const char SysKonnectFileId[] =
56 * Public Function prototypes 56 * Public Function prototypes
57 */ 57 */
58int SkPnmiInit(SK_AC *pAC, SK_IOC IoC, int level); 58int SkPnmiInit(SK_AC *pAC, SK_IOC IoC, int level);
59int SkPnmiGetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void *pBuf,
60 unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
61int SkPnmiPreSetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void *pBuf,
62 unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
63int SkPnmiSetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void *pBuf, 59int SkPnmiSetVar(SK_AC *pAC, SK_IOC IoC, SK_U32 Id, void *pBuf,
64 unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex); 60 unsigned int *pLen, SK_U32 Instance, SK_U32 NetIndex);
65int SkPnmiGetStruct(SK_AC *pAC, SK_IOC IoC, void *pBuf, 61int SkPnmiGetStruct(SK_AC *pAC, SK_IOC IoC, void *pBuf,
@@ -587,7 +583,7 @@ int Level) /* Initialization level */
587 * exist (e.g. port instance 3 on a two port 583 * exist (e.g. port instance 3 on a two port
588 * adapter. 584 * adapter.
589 */ 585 */
590int SkPnmiGetVar( 586static int SkPnmiGetVar(
591SK_AC *pAC, /* Pointer to adapter context */ 587SK_AC *pAC, /* Pointer to adapter context */
592SK_IOC IoC, /* IO context handle */ 588SK_IOC IoC, /* IO context handle */
593SK_U32 Id, /* Object ID that is to be processed */ 589SK_U32 Id, /* Object ID that is to be processed */
@@ -629,7 +625,7 @@ SK_U32 NetIndex) /* NetIndex (0..n), in single net mode always zero */
629 * exist (e.g. port instance 3 on a two port 625 * exist (e.g. port instance 3 on a two port
630 * adapter. 626 * adapter.
631 */ 627 */
632int SkPnmiPreSetVar( 628static int SkPnmiPreSetVar(
633SK_AC *pAC, /* Pointer to adapter context */ 629SK_AC *pAC, /* Pointer to adapter context */
634SK_IOC IoC, /* IO context handle */ 630SK_IOC IoC, /* IO context handle */
635SK_U32 Id, /* Object ID that is to be processed */ 631SK_U32 Id, /* Object ID that is to be processed */
@@ -5062,9 +5058,6 @@ SK_U32 NetIndex) /* NetIndex (0..n), in single net mode always zero */
5062 case OID_SKGE_SPEED_CAP: 5058 case OID_SKGE_SPEED_CAP:
5063 case OID_SKGE_SPEED_MODE: 5059 case OID_SKGE_SPEED_MODE:
5064 case OID_SKGE_SPEED_STATUS: 5060 case OID_SKGE_SPEED_STATUS:
5065#ifdef SK_PHY_LP_MODE
5066 case OID_SKGE_PHY_LP_MODE:
5067#endif
5068 if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U8)) { 5061 if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U8)) {
5069 5062
5070 *pLen = (Limit - LogPortIndex) * sizeof(SK_U8); 5063 *pLen = (Limit - LogPortIndex) * sizeof(SK_U8);
@@ -5140,28 +5133,6 @@ SK_U32 NetIndex) /* NetIndex (0..n), in single net mode always zero */
5140 Offset += sizeof(SK_U32); 5133 Offset += sizeof(SK_U32);
5141 break; 5134 break;
5142 5135
5143#ifdef SK_PHY_LP_MODE
5144 case OID_SKGE_PHY_LP_MODE:
5145 if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5146 if (LogPortIndex == 0) {
5147 continue;
5148 }
5149 else {
5150 /* Get value for physical ports */
5151 PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
5152 Val8 = (SK_U8) pAC->GIni.GP[PhysPortIndex].PPhyPowerState;
5153 *pBufPtr = Val8;
5154 }
5155 }
5156 else { /* DualNetMode */
5157
5158 Val8 = (SK_U8) pAC->GIni.GP[PhysPortIndex].PPhyPowerState;
5159 *pBufPtr = Val8;
5160 }
5161 Offset += sizeof(SK_U8);
5162 break;
5163#endif
5164
5165 case OID_SKGE_LINK_CAP: 5136 case OID_SKGE_LINK_CAP:
5166 if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */ 5137 if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5167 if (LogPortIndex == 0) { 5138 if (LogPortIndex == 0) {
@@ -5478,16 +5449,6 @@ SK_U32 NetIndex) /* NetIndex (0..n), in single net mode always zero */
5478 } 5449 }
5479 break; 5450 break;
5480 5451
5481#ifdef SK_PHY_LP_MODE
5482 case OID_SKGE_PHY_LP_MODE:
5483 if (*pLen < Limit - LogPortIndex) {
5484
5485 *pLen = Limit - LogPortIndex;
5486 return (SK_PNMI_ERR_TOO_SHORT);
5487 }
5488 break;
5489#endif
5490
5491 case OID_SKGE_MTU: 5452 case OID_SKGE_MTU:
5492 if (*pLen < sizeof(SK_U32)) { 5453 if (*pLen < sizeof(SK_U32)) {
5493 5454
@@ -5845,116 +5806,6 @@ SK_U32 NetIndex) /* NetIndex (0..n), in single net mode always zero */
5845 Offset += sizeof(SK_U32); 5806 Offset += sizeof(SK_U32);
5846 break; 5807 break;
5847 5808
5848#ifdef SK_PHY_LP_MODE
5849 case OID_SKGE_PHY_LP_MODE:
5850 /* The preset ends here */
5851 if (Action == SK_PNMI_PRESET) {
5852
5853 return (SK_PNMI_ERR_OK);
5854 }
5855
5856 if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
5857 if (LogPortIndex == 0) {
5858 Offset = 0;
5859 continue;
5860 }
5861 else {
5862 /* Set value for physical ports */
5863 PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
5864
5865 switch (*(pBuf + Offset)) {
5866 case 0:
5867 /* If LowPowerMode is active, we can leave it. */
5868 if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
5869
5870 Val32 = SkGmLeaveLowPowerMode(pAC, IoC, PhysPortIndex);
5871
5872 if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState < 3) {
5873
5874 SkDrvInitAdapter(pAC);
5875 }
5876 break;
5877 }
5878 else {
5879 *pLen = 0;
5880 return (SK_PNMI_ERR_GENERAL);
5881 }
5882 case 1:
5883 case 2:
5884 case 3:
5885 case 4:
5886 /* If no LowPowerMode is active, we can enter it. */
5887 if (!pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
5888
5889 if ((*(pBuf + Offset)) < 3) {
5890
5891 SkDrvDeInitAdapter(pAC);
5892 }
5893
5894 Val32 = SkGmEnterLowPowerMode(pAC, IoC, PhysPortIndex, *pBuf);
5895 break;
5896 }
5897 else {
5898 *pLen = 0;
5899 return (SK_PNMI_ERR_GENERAL);
5900 }
5901 default:
5902 *pLen = 0;
5903 return (SK_PNMI_ERR_BAD_VALUE);
5904 }
5905 }
5906 }
5907 else { /* DualNetMode */
5908
5909 switch (*(pBuf + Offset)) {
5910 case 0:
5911 /* If we are in a LowPowerMode, we can leave it. */
5912 if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
5913
5914 Val32 = SkGmLeaveLowPowerMode(pAC, IoC, PhysPortIndex);
5915
5916 if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState < 3) {
5917
5918 SkDrvInitAdapter(pAC);
5919 }
5920 break;
5921 }
5922 else {
5923 *pLen = 0;
5924 return (SK_PNMI_ERR_GENERAL);
5925 }
5926
5927 case 1:
5928 case 2:
5929 case 3:
5930 case 4:
5931 /* If we are not already in LowPowerMode, we can enter it. */
5932 if (!pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
5933
5934 if ((*(pBuf + Offset)) < 3) {
5935
5936 SkDrvDeInitAdapter(pAC);
5937 }
5938 else {
5939
5940 Val32 = SkGmEnterLowPowerMode(pAC, IoC, PhysPortIndex, *pBuf);
5941 }
5942 break;
5943 }
5944 else {
5945 *pLen = 0;
5946 return (SK_PNMI_ERR_GENERAL);
5947 }
5948
5949 default:
5950 *pLen = 0;
5951 return (SK_PNMI_ERR_BAD_VALUE);
5952 }
5953 }
5954 Offset += sizeof(SK_U8);
5955 break;
5956#endif
5957
5958 default: 5809 default:
5959 SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR, 5810 SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
5960 ("MacPrivateConf: Unknown OID should be handled before set")); 5811 ("MacPrivateConf: Unknown OID should be handled before set"));
diff --git a/drivers/net/sk98lin/skgesirq.c b/drivers/net/sk98lin/skgesirq.c
index 87520f0057d7..ab66d80a4455 100644
--- a/drivers/net/sk98lin/skgesirq.c
+++ b/drivers/net/sk98lin/skgesirq.c
@@ -265,7 +265,7 @@ int Port) /* Port Index (MAC_1 + n) */
265 * 265 *
266 * Returns: N/A 266 * Returns: N/A
267 */ 267 */
268void SkHWLinkUp( 268static void SkHWLinkUp(
269SK_AC *pAC, /* adapter context */ 269SK_AC *pAC, /* adapter context */
270SK_IOC IoC, /* IO context */ 270SK_IOC IoC, /* IO context */
271int Port) /* Port Index (MAC_1 + n) */ 271int Port) /* Port Index (MAC_1 + n) */
@@ -612,14 +612,6 @@ SK_U32 Istatus) /* Interrupt status word */
612 * we ignore those 612 * we ignore those
613 */ 613 */
614 pPrt->HalfDupTimerActive = SK_TRUE; 614 pPrt->HalfDupTimerActive = SK_TRUE;
615#ifdef XXX
616 Len = sizeof(SK_U64);
617 SkPnmiGetVar(pAC, IoC, OID_SKGE_STAT_TX_OCTETS, (char *)&Octets,
618 &Len, (SK_U32)SK_PNMI_PORT_PHYS2INST(pAC, 0),
619 pAC->Rlmt.Port[0].Net->NetNumber);
620
621 pPrt->LastOctets = Octets;
622#endif /* XXX */
623 /* Snap statistic counters */ 615 /* Snap statistic counters */
624 (void)SkXmUpdateStats(pAC, IoC, 0); 616 (void)SkXmUpdateStats(pAC, IoC, 0);
625 617
@@ -653,14 +645,6 @@ SK_U32 Istatus) /* Interrupt status word */
653 pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOHALF) && 645 pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOHALF) &&
654 !pPrt->HalfDupTimerActive) { 646 !pPrt->HalfDupTimerActive) {
655 pPrt->HalfDupTimerActive = SK_TRUE; 647 pPrt->HalfDupTimerActive = SK_TRUE;
656#ifdef XXX
657 Len = sizeof(SK_U64);
658 SkPnmiGetVar(pAC, IoC, OID_SKGE_STAT_TX_OCTETS, (char *)&Octets,
659 &Len, (SK_U32)SK_PNMI_PORT_PHYS2INST(pAC, 1),
660 pAC->Rlmt.Port[1].Net->NetNumber);
661
662 pPrt->LastOctets = Octets;
663#endif /* XXX */
664 /* Snap statistic counters */ 648 /* Snap statistic counters */
665 (void)SkXmUpdateStats(pAC, IoC, 1); 649 (void)SkXmUpdateStats(pAC, IoC, 1);
666 650
@@ -2085,12 +2069,6 @@ SK_EVPARA Para) /* Event specific Parameter */
2085 pPrt->HalfDupTimerActive = SK_FALSE; 2069 pPrt->HalfDupTimerActive = SK_FALSE;
2086 if (pPrt->PLinkModeStatus == SK_LMODE_STAT_HALF || 2070 if (pPrt->PLinkModeStatus == SK_LMODE_STAT_HALF ||
2087 pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOHALF) { 2071 pPrt->PLinkModeStatus == SK_LMODE_STAT_AUTOHALF) {
2088#ifdef XXX
2089 Len = sizeof(SK_U64);
2090 SkPnmiGetVar(pAC, IoC, OID_SKGE_STAT_TX_OCTETS, (char *)&Octets,
2091 &Len, (SK_U32)SK_PNMI_PORT_PHYS2INST(pAC, Port),
2092 pAC->Rlmt.Port[Port].Net->NetNumber);
2093#endif /* XXX */
2094 /* Snap statistic counters */ 2072 /* Snap statistic counters */
2095 (void)SkXmUpdateStats(pAC, IoC, Port); 2073 (void)SkXmUpdateStats(pAC, IoC, Port);
2096 2074
diff --git a/drivers/net/sk98lin/ski2c.c b/drivers/net/sk98lin/ski2c.c
index 075a0464e56b..79bf57cb5326 100644
--- a/drivers/net/sk98lin/ski2c.c
+++ b/drivers/net/sk98lin/ski2c.c
@@ -396,7 +396,7 @@ int Rw) /* Read / Write Flag */
396 * 1: error, transfer does not complete, I2C transfer 396 * 1: error, transfer does not complete, I2C transfer
397 * killed, wait loop terminated. 397 * killed, wait loop terminated.
398 */ 398 */
399int SkI2cWait( 399static int SkI2cWait(
400SK_AC *pAC, /* Adapter Context */ 400SK_AC *pAC, /* Adapter Context */
401SK_IOC IoC, /* I/O Context */ 401SK_IOC IoC, /* I/O Context */
402int Event) /* complete event to wait for (I2C_READ or I2C_WRITE) */ 402int Event) /* complete event to wait for (I2C_READ or I2C_WRITE) */
@@ -481,7 +481,7 @@ SK_IOC IoC) /* I/O Context */
481 * returns 0: success 481 * returns 0: success
482 * 1: error 482 * 1: error
483 */ 483 */
484int SkI2cWrite( 484static int SkI2cWrite(
485SK_AC *pAC, /* Adapter Context */ 485SK_AC *pAC, /* Adapter Context */
486SK_IOC IoC, /* I/O Context */ 486SK_IOC IoC, /* I/O Context */
487SK_U32 I2cData, /* I2C Data to write */ 487SK_U32 I2cData, /* I2C Data to write */
@@ -538,7 +538,7 @@ int I2cBurst) /* I2C Burst Flag */
538 * 1 if the read is completed 538 * 1 if the read is completed
539 * 0 if the read must be continued (I2C Bus still allocated) 539 * 0 if the read must be continued (I2C Bus still allocated)
540 */ 540 */
541int SkI2cReadSensor( 541static int SkI2cReadSensor(
542SK_AC *pAC, /* Adapter Context */ 542SK_AC *pAC, /* Adapter Context */
543SK_IOC IoC, /* I/O Context */ 543SK_IOC IoC, /* I/O Context */
544SK_SENSOR *pSen) /* Sensor to be read */ 544SK_SENSOR *pSen) /* Sensor to be read */
diff --git a/drivers/net/sk98lin/sklm80.c b/drivers/net/sk98lin/sklm80.c
index 68292d18175b..a204f5bb55d4 100644
--- a/drivers/net/sk98lin/sklm80.c
+++ b/drivers/net/sk98lin/sklm80.c
@@ -34,79 +34,7 @@ static const char SysKonnectFileId[] =
34#include "h/lm80.h" 34#include "h/lm80.h"
35#include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. */ 35#include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. */
36 36
37#ifdef SK_DIAG
38#define BREAK_OR_WAIT(pAC,IoC,Event) SkI2cWait(pAC,IoC,Event)
39#else /* nSK_DIAG */
40#define BREAK_OR_WAIT(pAC,IoC,Event) break 37#define BREAK_OR_WAIT(pAC,IoC,Event) break
41#endif /* nSK_DIAG */
42
43#ifdef SK_DIAG
44/*
45 * read the register 'Reg' from the device 'Dev'
46 *
47 * return read error -1
48 * success the read value
49 */
50int SkLm80RcvReg(
51SK_IOC IoC, /* Adapter Context */
52int Dev, /* I2C device address */
53int Reg) /* register to read */
54{
55 int Val = 0;
56 int TempExt;
57
58 /* Signal device number */
59 if (SkI2cSndDev(IoC, Dev, I2C_WRITE)) {
60 return(-1);
61 }
62
63 if (SkI2cSndByte(IoC, Reg)) {
64 return(-1);
65 }
66
67 /* repeat start */
68 if (SkI2cSndDev(IoC, Dev, I2C_READ)) {
69 return(-1);
70 }
71
72 switch (Reg) {
73 case LM80_TEMP_IN:
74 Val = (int)SkI2cRcvByte(IoC, 1);
75
76 /* First: correct the value: it might be negative */
77 if ((Val & 0x80) != 0) {
78 /* Value is negative */
79 Val = Val - 256;
80 }
81 Val = Val * SK_LM80_TEMP_LSB;
82 SkI2cStop(IoC);
83
84 TempExt = (int)SkLm80RcvReg(IoC, LM80_ADDR, LM80_TEMP_CTRL);
85
86 if (Val > 0) {
87 Val += ((TempExt >> 7) * SK_LM80_TEMPEXT_LSB);
88 }
89 else {
90 Val -= ((TempExt >> 7) * SK_LM80_TEMPEXT_LSB);
91 }
92 return(Val);
93 break;
94 case LM80_VT0_IN:
95 case LM80_VT1_IN:
96 case LM80_VT2_IN:
97 case LM80_VT3_IN:
98 Val = (int)SkI2cRcvByte(IoC, 1) * SK_LM80_VT_LSB;
99 break;
100
101 default:
102 Val = (int)SkI2cRcvByte(IoC, 1);
103 break;
104 }
105
106 SkI2cStop(IoC);
107 return(Val);
108}
109#endif /* SK_DIAG */
110 38
111/* 39/*
112 * read a sensors value (LM80 specific) 40 * read a sensors value (LM80 specific)
diff --git a/drivers/net/sk98lin/skrlmt.c b/drivers/net/sk98lin/skrlmt.c
index 9ea11ab2296a..be8d1ccddf6d 100644
--- a/drivers/net/sk98lin/skrlmt.c
+++ b/drivers/net/sk98lin/skrlmt.c
@@ -282,7 +282,6 @@ typedef struct s_SpTreeRlmtPacket {
282 282
283SK_MAC_ADDR SkRlmtMcAddr = {{0x01, 0x00, 0x5A, 0x52, 0x4C, 0x4D}}; 283SK_MAC_ADDR SkRlmtMcAddr = {{0x01, 0x00, 0x5A, 0x52, 0x4C, 0x4D}};
284SK_MAC_ADDR BridgeMcAddr = {{0x01, 0x80, 0xC2, 0x00, 0x00, 0x00}}; 284SK_MAC_ADDR BridgeMcAddr = {{0x01, 0x80, 0xC2, 0x00, 0x00, 0x00}};
285SK_MAC_ADDR BcAddr = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
286 285
287/* local variables ************************************************************/ 286/* local variables ************************************************************/
288 287
diff --git a/drivers/net/sk98lin/skvpd.c b/drivers/net/sk98lin/skvpd.c
index eb3c8988ced1..17786056c66a 100644
--- a/drivers/net/sk98lin/skvpd.c
+++ b/drivers/net/sk98lin/skvpd.c
@@ -132,65 +132,6 @@ int addr) /* VPD address */
132 132
133#endif /* SKDIAG */ 133#endif /* SKDIAG */
134 134
135#if 0
136
137/*
138 Write the dword 'data' at address 'addr' into the VPD EEPROM, and
139 verify that the data is written.
140
141 Needed Time:
142
143. MIN MAX
144. -------------------------------------------------------------------
145. write 1.8 ms 3.6 ms
146. internal write cyles 0.7 ms 7.0 ms
147. -------------------------------------------------------------------
148. over all program time 2.5 ms 10.6 ms
149. read 1.3 ms 2.6 ms
150. -------------------------------------------------------------------
151. over all 3.8 ms 13.2 ms
152.
153
154
155 Returns 0: success
156 1: error, I2C transfer does not terminate
157 2: error, data verify error
158
159 */
160static int VpdWriteDWord(
161SK_AC *pAC, /* pAC pointer */
162SK_IOC IoC, /* IO Context */
163int addr, /* VPD address */
164SK_U32 data) /* VPD data to write */
165{
166 /* start VPD write */
167 /* Don't swap here, it's a data stream of bytes */
168 SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_CTRL,
169 ("VPD write dword at addr 0x%x, data = 0x%x\n",addr,data));
170 VPD_OUT32(pAC, IoC, PCI_VPD_DAT_REG, (SK_U32)data);
171 /* But do it here */
172 addr |= VPD_WRITE;
173
174 VPD_OUT16(pAC, IoC, PCI_VPD_ADR_REG, (SK_U16)(addr | VPD_WRITE));
175
176 /* this may take up to 10,6 ms */
177 if (VpdWait(pAC, IoC, VPD_WRITE)) {
178 SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
179 ("Write Timed Out\n"));
180 return(1);
181 };
182
183 /* verify data */
184 if (VpdReadDWord(pAC, IoC, addr) != data) {
185 SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
186 ("Data Verify Error\n"));
187 return(2);
188 }
189 return(0);
190} /* VpdWriteDWord */
191
192#endif /* 0 */
193
194/* 135/*
195 * Read one Stream of 'len' bytes of VPD data, starting at 'addr' from 136 * Read one Stream of 'len' bytes of VPD data, starting at 'addr' from
196 * or to the I2C EEPROM. 137 * or to the I2C EEPROM.
@@ -728,7 +669,7 @@ char *etp) /* end pointer input position */
728 * 6: fatal VPD error 669 * 6: fatal VPD error
729 * 670 *
730 */ 671 */
731int VpdSetupPara( 672static int VpdSetupPara(
732SK_AC *pAC, /* common data base */ 673SK_AC *pAC, /* common data base */
733const char *key, /* keyword to insert */ 674const char *key, /* keyword to insert */
734const char *buf, /* buffer with the keyword value */ 675const char *buf, /* buffer with the keyword value */
@@ -1148,50 +1089,3 @@ SK_IOC IoC) /* IO Context */
1148 return(0); 1089 return(0);
1149} 1090}
1150 1091
1151
1152
1153/*
1154 * Read the contents of the VPD EEPROM and copy it to the VPD buffer
1155 * if not already done. If the keyword "VF" is not present it will be
1156 * created and the error log message will be stored to this keyword.
1157 * If "VF" is not present the error log message will be stored to the
1158 * keyword "VL". "VL" will created or overwritten if "VF" is present.
1159 * The VPD read/write area is saved to the VPD EEPROM.
1160 *
1161 * returns nothing, errors will be ignored.
1162 */
1163void VpdErrLog(
1164SK_AC *pAC, /* common data base */
1165SK_IOC IoC, /* IO Context */
1166char *msg) /* error log message */
1167{
1168 SK_VPD_PARA *v, vf; /* VF */
1169 int len;
1170
1171 SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_TX,
1172 ("VPD error log msg %s\n", msg));
1173 if ((pAC->vpd.v.vpd_status & VPD_VALID) == 0) {
1174 if (VpdInit(pAC, IoC) != 0) {
1175 SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_ERR,
1176 ("VPD init error\n"));
1177 return;
1178 }
1179 }
1180
1181 len = strlen(msg);
1182 if (len > VPD_MAX_LEN) {
1183 /* cut it */
1184 len = VPD_MAX_LEN;
1185 }
1186 if ((v = vpd_find_para(pAC, VPD_VF, &vf)) != NULL) {
1187 SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_TX, ("overwrite VL\n"));
1188 (void)VpdSetupPara(pAC, VPD_VL, msg, len, VPD_RW_KEY, OWR_KEY);
1189 }
1190 else {
1191 SK_DBG_MSG(pAC, SK_DBGMOD_VPD, SK_DBGCAT_TX, ("write VF\n"));
1192 (void)VpdSetupPara(pAC, VPD_VF, msg, len, VPD_RW_KEY, ADD_KEY);
1193 }
1194
1195 (void)VpdUpdate(pAC, IoC);
1196}
1197
diff --git a/drivers/net/sk98lin/skxmac2.c b/drivers/net/sk98lin/skxmac2.c
index 42d2d963150a..b4e75022a657 100644
--- a/drivers/net/sk98lin/skxmac2.c
+++ b/drivers/net/sk98lin/skxmac2.c
@@ -41,13 +41,13 @@ static const char SysKonnectFileId[] =
41#endif 41#endif
42 42
43#ifdef GENESIS 43#ifdef GENESIS
44BCOM_HACK BcomRegA1Hack[] = { 44static BCOM_HACK BcomRegA1Hack[] = {
45 { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1104 }, { 0x17, 0x0013 }, 45 { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1104 }, { 0x17, 0x0013 },
46 { 0x15, 0x0404 }, { 0x17, 0x8006 }, { 0x15, 0x0132 }, { 0x17, 0x8006 }, 46 { 0x15, 0x0404 }, { 0x17, 0x8006 }, { 0x15, 0x0132 }, { 0x17, 0x8006 },
47 { 0x15, 0x0232 }, { 0x17, 0x800D }, { 0x15, 0x000F }, { 0x18, 0x0420 }, 47 { 0x15, 0x0232 }, { 0x17, 0x800D }, { 0x15, 0x000F }, { 0x18, 0x0420 },
48 { 0, 0 } 48 { 0, 0 }
49}; 49};
50BCOM_HACK BcomRegC0Hack[] = { 50static BCOM_HACK BcomRegC0Hack[] = {
51 { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1204 }, { 0x17, 0x0013 }, 51 { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1204 }, { 0x17, 0x0013 },
52 { 0x15, 0x0A04 }, { 0x18, 0x0420 }, 52 { 0x15, 0x0A04 }, { 0x18, 0x0420 },
53 { 0, 0 } 53 { 0, 0 }
@@ -790,7 +790,7 @@ int Port) /* Port Index (MAC_1 + n) */
790 * Returns: 790 * Returns:
791 * nothing 791 * nothing
792 */ 792 */
793void SkMacFlushRxFifo( 793static void SkMacFlushRxFifo(
794SK_AC *pAC, /* adapter context */ 794SK_AC *pAC, /* adapter context */
795SK_IOC IoC, /* IO context */ 795SK_IOC IoC, /* IO context */
796int Port) /* Port Index (MAC_1 + n) */ 796int Port) /* Port Index (MAC_1 + n) */
@@ -1231,38 +1231,6 @@ int Port) /* Port Index (MAC_1 + n) */
1231} /* SkMacHardRst */ 1231} /* SkMacHardRst */
1232 1232
1233 1233
1234/******************************************************************************
1235 *
1236 * SkMacClearRst() - Clear the MAC reset
1237 *
1238 * Description: calls a clear MAC reset routine dep. on board type
1239 *
1240 * Returns:
1241 * nothing
1242 */
1243void SkMacClearRst(
1244SK_AC *pAC, /* adapter context */
1245SK_IOC IoC, /* IO context */
1246int Port) /* Port Index (MAC_1 + n) */
1247{
1248
1249#ifdef GENESIS
1250 if (pAC->GIni.GIGenesis) {
1251
1252 SkXmClearRst(pAC, IoC, Port);
1253 }
1254#endif /* GENESIS */
1255
1256#ifdef YUKON
1257 if (pAC->GIni.GIYukon) {
1258
1259 SkGmClearRst(pAC, IoC, Port);
1260 }
1261#endif /* YUKON */
1262
1263} /* SkMacClearRst */
1264
1265
1266#ifdef GENESIS 1234#ifdef GENESIS
1267/****************************************************************************** 1235/******************************************************************************
1268 * 1236 *
@@ -1713,7 +1681,7 @@ int Port) /* Port Index (MAC_1 + n) */
1713 * Returns: 1681 * Returns:
1714 * nothing 1682 * nothing
1715 */ 1683 */
1716void SkXmInitDupMd( 1684static void SkXmInitDupMd(
1717SK_AC *pAC, /* adapter context */ 1685SK_AC *pAC, /* adapter context */
1718SK_IOC IoC, /* IO context */ 1686SK_IOC IoC, /* IO context */
1719int Port) /* Port Index (MAC_1 + n) */ 1687int Port) /* Port Index (MAC_1 + n) */
@@ -1761,7 +1729,7 @@ int Port) /* Port Index (MAC_1 + n) */
1761 * Returns: 1729 * Returns:
1762 * nothing 1730 * nothing
1763 */ 1731 */
1764void SkXmInitPauseMd( 1732static void SkXmInitPauseMd(
1765SK_AC *pAC, /* adapter context */ 1733SK_AC *pAC, /* adapter context */
1766SK_IOC IoC, /* IO context */ 1734SK_IOC IoC, /* IO context */
1767int Port) /* Port Index (MAC_1 + n) */ 1735int Port) /* Port Index (MAC_1 + n) */
@@ -2076,283 +2044,7 @@ SK_BOOL DoLoop) /* Should a Phy LoopBack be set-up? */
2076} /* SkXmInitPhyBcom */ 2044} /* SkXmInitPhyBcom */
2077#endif /* GENESIS */ 2045#endif /* GENESIS */
2078 2046
2079
2080#ifdef YUKON 2047#ifdef YUKON
2081#ifndef SK_SLIM
2082/******************************************************************************
2083 *
2084 * SkGmEnterLowPowerMode()
2085 *
2086 * Description:
2087 * This function sets the Marvell Alaska PHY to the low power mode
2088 * given by parameter mode.
2089 * The following low power modes are available:
2090 *
2091 * - Coma Mode (Deep Sleep):
2092 * Power consumption: ~15 - 30 mW
2093 * The PHY cannot wake up on its own.
2094 *
2095 * - IEEE 22.2.4.1.5 compatible power down mode
2096 * Power consumption: ~240 mW
2097 * The PHY cannot wake up on its own.
2098 *
2099 * - energy detect mode
2100 * Power consumption: ~160 mW
2101 * The PHY can wake up on its own by detecting activity
2102 * on the CAT 5 cable.
2103 *
2104 * - energy detect plus mode
2105 * Power consumption: ~150 mW
2106 * The PHY can wake up on its own by detecting activity
2107 * on the CAT 5 cable.
2108 * Connected devices can be woken up by sending normal link
2109 * pulses every one second.
2110 *
2111 * Note:
2112 *
2113 * Returns:
2114 * 0: ok
2115 * 1: error
2116 */
2117int SkGmEnterLowPowerMode(
2118SK_AC *pAC, /* adapter context */
2119SK_IOC IoC, /* IO context */
2120int Port, /* Port Index (e.g. MAC_1) */
2121SK_U8 Mode) /* low power mode */
2122{
2123 SK_U16 Word;
2124 SK_U32 DWord;
2125 SK_U8 LastMode;
2126 int Ret = 0;
2127
2128 if (pAC->GIni.GIYukonLite &&
2129 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2130
2131 /* save current power mode */
2132 LastMode = pAC->GIni.GP[Port].PPhyPowerState;
2133 pAC->GIni.GP[Port].PPhyPowerState = Mode;
2134
2135 switch (Mode) {
2136 /* coma mode (deep sleep) */
2137 case PHY_PM_DEEP_SLEEP:
2138 /* setup General Purpose Control Register */
2139 GM_OUT16(IoC, 0, GM_GP_CTRL, GM_GPCR_FL_PASS |
2140 GM_GPCR_SPEED_100 | GM_GPCR_AU_ALL_DIS);
2141
2142 /* apply COMA mode workaround */
2143 SkGmPhyWrite(pAC, IoC, Port, 29, 0x001f);
2144 SkGmPhyWrite(pAC, IoC, Port, 30, 0xfff3);
2145
2146 SK_IN32(IoC, PCI_C(PCI_OUR_REG_1), &DWord);
2147
2148 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2149
2150 /* Set PHY to Coma Mode */
2151 SK_OUT32(IoC, PCI_C(PCI_OUR_REG_1), DWord | PCI_PHY_COMA);
2152
2153 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2154
2155 break;
2156
2157 /* IEEE 22.2.4.1.5 compatible power down mode */
2158 case PHY_PM_IEEE_POWER_DOWN:
2159 /*
2160 * - disable MAC 125 MHz clock
2161 * - allow MAC power down
2162 */
2163 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2164 Word |= PHY_M_PC_DIS_125CLK;
2165 Word &= ~PHY_M_PC_MAC_POW_UP;
2166 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2167
2168 /*
2169 * register changes must be followed by a software
2170 * reset to take effect
2171 */
2172 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2173 Word |= PHY_CT_RESET;
2174 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2175
2176 /* switch IEEE compatible power down mode on */
2177 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2178 Word |= PHY_CT_PDOWN;
2179 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2180 break;
2181
2182 /* energy detect and energy detect plus mode */
2183 case PHY_PM_ENERGY_DETECT:
2184 case PHY_PM_ENERGY_DETECT_PLUS:
2185 /*
2186 * - disable MAC 125 MHz clock
2187 */
2188 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2189 Word |= PHY_M_PC_DIS_125CLK;
2190 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2191
2192 /* activate energy detect mode 1 */
2193 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2194
2195 /* energy detect mode */
2196 if (Mode == PHY_PM_ENERGY_DETECT) {
2197 Word |= PHY_M_PC_EN_DET;
2198 }
2199 /* energy detect plus mode */
2200 else {
2201 Word |= PHY_M_PC_EN_DET_PLUS;
2202 }
2203
2204 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2205
2206 /*
2207 * reinitialize the PHY to force a software reset
2208 * which is necessary after the register settings
2209 * for the energy detect modes.
2210 * Furthermore reinitialisation prevents that the
2211 * PHY is running out of a stable state.
2212 */
2213 SkGmInitPhyMarv(pAC, IoC, Port, SK_FALSE);
2214 break;
2215
2216 /* don't change current power mode */
2217 default:
2218 pAC->GIni.GP[Port].PPhyPowerState = LastMode;
2219 Ret = 1;
2220 break;
2221 }
2222 }
2223 /* low power modes are not supported by this chip */
2224 else {
2225 Ret = 1;
2226 }
2227
2228 return(Ret);
2229
2230} /* SkGmEnterLowPowerMode */
2231
2232/******************************************************************************
2233 *
2234 * SkGmLeaveLowPowerMode()
2235 *
2236 * Description:
2237 * Leave the current low power mode and switch to normal mode
2238 *
2239 * Note:
2240 *
2241 * Returns:
2242 * 0: ok
2243 * 1: error
2244 */
2245int SkGmLeaveLowPowerMode(
2246SK_AC *pAC, /* adapter context */
2247SK_IOC IoC, /* IO context */
2248int Port) /* Port Index (e.g. MAC_1) */
2249{
2250 SK_U32 DWord;
2251 SK_U16 Word;
2252 SK_U8 LastMode;
2253 int Ret = 0;
2254
2255 if (pAC->GIni.GIYukonLite &&
2256 pAC->GIni.GIChipRev >= CHIP_REV_YU_LITE_A3) {
2257
2258 /* save current power mode */
2259 LastMode = pAC->GIni.GP[Port].PPhyPowerState;
2260 pAC->GIni.GP[Port].PPhyPowerState = PHY_PM_OPERATIONAL_MODE;
2261
2262 switch (LastMode) {
2263 /* coma mode (deep sleep) */
2264 case PHY_PM_DEEP_SLEEP:
2265 SK_IN32(IoC, PCI_C(PCI_OUR_REG_1), &DWord);
2266
2267 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2268
2269 /* Release PHY from Coma Mode */
2270 SK_OUT32(IoC, PCI_C(PCI_OUR_REG_1), DWord & ~PCI_PHY_COMA);
2271
2272 SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2273
2274 SK_IN32(IoC, B2_GP_IO, &DWord);
2275
2276 /* set to output */
2277 DWord |= (GP_DIR_9 | GP_IO_9);
2278
2279 /* set PHY reset */
2280 SK_OUT32(IoC, B2_GP_IO, DWord);
2281
2282 DWord &= ~GP_IO_9; /* clear PHY reset (active high) */
2283
2284 /* clear PHY reset */
2285 SK_OUT32(IoC, B2_GP_IO, DWord);
2286 break;
2287
2288 /* IEEE 22.2.4.1.5 compatible power down mode */
2289 case PHY_PM_IEEE_POWER_DOWN:
2290 /*
2291 * - enable MAC 125 MHz clock
2292 * - set MAC power up
2293 */
2294 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2295 Word &= ~PHY_M_PC_DIS_125CLK;
2296 Word |= PHY_M_PC_MAC_POW_UP;
2297 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2298
2299 /*
2300 * register changes must be followed by a software
2301 * reset to take effect
2302 */
2303 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2304 Word |= PHY_CT_RESET;
2305 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2306
2307 /* switch IEEE compatible power down mode off */
2308 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
2309 Word &= ~PHY_CT_PDOWN;
2310 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
2311 break;
2312
2313 /* energy detect and energy detect plus mode */
2314 case PHY_PM_ENERGY_DETECT:
2315 case PHY_PM_ENERGY_DETECT_PLUS:
2316 /*
2317 * - enable MAC 125 MHz clock
2318 */
2319 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2320 Word &= ~PHY_M_PC_DIS_125CLK;
2321 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2322
2323 /* disable energy detect mode */
2324 SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
2325 Word &= ~PHY_M_PC_EN_DET_MSK;
2326 SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
2327
2328 /*
2329 * reinitialize the PHY to force a software reset
2330 * which is necessary after the register settings
2331 * for the energy detect modes.
2332 * Furthermore reinitialisation prevents that the
2333 * PHY is running out of a stable state.
2334 */
2335 SkGmInitPhyMarv(pAC, IoC, Port, SK_FALSE);
2336 break;
2337
2338 /* don't change current power mode */
2339 default:
2340 pAC->GIni.GP[Port].PPhyPowerState = LastMode;
2341 Ret = 1;
2342 break;
2343 }
2344 }
2345 /* low power modes are not supported by this chip */
2346 else {
2347 Ret = 1;
2348 }
2349
2350 return(Ret);
2351
2352} /* SkGmLeaveLowPowerMode */
2353#endif /* !SK_SLIM */
2354
2355
2356/****************************************************************************** 2048/******************************************************************************
2357 * 2049 *
2358 * SkGmInitPhyMarv() - Initialize the Marvell Phy registers 2050 * SkGmInitPhyMarv() - Initialize the Marvell Phy registers
@@ -3420,145 +3112,6 @@ int Port) /* Port Index (MAC_1 + n) */
3420} /* SkMacAutoNegDone */ 3112} /* SkMacAutoNegDone */
3421 3113
3422 3114
3423#ifdef GENESIS
3424/******************************************************************************
3425 *
3426 * SkXmSetRxTxEn() - Special Set Rx/Tx Enable and some features in XMAC
3427 *
3428 * Description:
3429 * sets MAC or PHY LoopBack and Duplex Mode in the MMU Command Reg.
3430 * enables Rx/Tx
3431 *
3432 * Returns: N/A
3433 */
3434static void SkXmSetRxTxEn(
3435SK_AC *pAC, /* Adapter Context */
3436SK_IOC IoC, /* IO context */
3437int Port, /* Port Index (MAC_1 + n) */
3438int Para) /* Parameter to set: MAC or PHY LoopBack, Duplex Mode */
3439{
3440 SK_U16 Word;
3441
3442 XM_IN16(IoC, Port, XM_MMU_CMD, &Word);
3443
3444 switch (Para & (SK_MAC_LOOPB_ON | SK_MAC_LOOPB_OFF)) {
3445 case SK_MAC_LOOPB_ON:
3446 Word |= XM_MMU_MAC_LB;
3447 break;
3448 case SK_MAC_LOOPB_OFF:
3449 Word &= ~XM_MMU_MAC_LB;
3450 break;
3451 }
3452
3453 switch (Para & (SK_PHY_LOOPB_ON | SK_PHY_LOOPB_OFF)) {
3454 case SK_PHY_LOOPB_ON:
3455 Word |= XM_MMU_GMII_LOOP;
3456 break;
3457 case SK_PHY_LOOPB_OFF:
3458 Word &= ~XM_MMU_GMII_LOOP;
3459 break;
3460 }
3461
3462 switch (Para & (SK_PHY_FULLD_ON | SK_PHY_FULLD_OFF)) {
3463 case SK_PHY_FULLD_ON:
3464 Word |= XM_MMU_GMII_FD;
3465 break;
3466 case SK_PHY_FULLD_OFF:
3467 Word &= ~XM_MMU_GMII_FD;
3468 break;
3469 }
3470
3471 XM_OUT16(IoC, Port, XM_MMU_CMD, Word | XM_MMU_ENA_RX | XM_MMU_ENA_TX);
3472
3473 /* dummy read to ensure writing */
3474 XM_IN16(IoC, Port, XM_MMU_CMD, &Word);
3475
3476} /* SkXmSetRxTxEn */
3477#endif /* GENESIS */
3478
3479
3480#ifdef YUKON
3481/******************************************************************************
3482 *
3483 * SkGmSetRxTxEn() - Special Set Rx/Tx Enable and some features in GMAC
3484 *
3485 * Description:
3486 * sets MAC LoopBack and Duplex Mode in the General Purpose Control Reg.
3487 * enables Rx/Tx
3488 *
3489 * Returns: N/A
3490 */
3491static void SkGmSetRxTxEn(
3492SK_AC *pAC, /* Adapter Context */
3493SK_IOC IoC, /* IO context */
3494int Port, /* Port Index (MAC_1 + n) */
3495int Para) /* Parameter to set: MAC LoopBack, Duplex Mode */
3496{
3497 SK_U16 Ctrl;
3498
3499 GM_IN16(IoC, Port, GM_GP_CTRL, &Ctrl);
3500
3501 switch (Para & (SK_MAC_LOOPB_ON | SK_MAC_LOOPB_OFF)) {
3502 case SK_MAC_LOOPB_ON:
3503 Ctrl |= GM_GPCR_LOOP_ENA;
3504 break;
3505 case SK_MAC_LOOPB_OFF:
3506 Ctrl &= ~GM_GPCR_LOOP_ENA;
3507 break;
3508 }
3509
3510 switch (Para & (SK_PHY_FULLD_ON | SK_PHY_FULLD_OFF)) {
3511 case SK_PHY_FULLD_ON:
3512 Ctrl |= GM_GPCR_DUP_FULL;
3513 break;
3514 case SK_PHY_FULLD_OFF:
3515 Ctrl &= ~GM_GPCR_DUP_FULL;
3516 break;
3517 }
3518
3519 GM_OUT16(IoC, Port, GM_GP_CTRL, (SK_U16)(Ctrl | GM_GPCR_RX_ENA |
3520 GM_GPCR_TX_ENA));
3521
3522 /* dummy read to ensure writing */
3523 GM_IN16(IoC, Port, GM_GP_CTRL, &Ctrl);
3524
3525} /* SkGmSetRxTxEn */
3526#endif /* YUKON */
3527
3528
3529#ifndef SK_SLIM
3530/******************************************************************************
3531 *
3532 * SkMacSetRxTxEn() - Special Set Rx/Tx Enable and parameters
3533 *
3534 * Description: calls the Special Set Rx/Tx Enable routines dep. on board type
3535 *
3536 * Returns: N/A
3537 */
3538void SkMacSetRxTxEn(
3539SK_AC *pAC, /* Adapter Context */
3540SK_IOC IoC, /* IO context */
3541int Port, /* Port Index (MAC_1 + n) */
3542int Para)
3543{
3544#ifdef GENESIS
3545 if (pAC->GIni.GIGenesis) {
3546
3547 SkXmSetRxTxEn(pAC, IoC, Port, Para);
3548 }
3549#endif /* GENESIS */
3550
3551#ifdef YUKON
3552 if (pAC->GIni.GIYukon) {
3553
3554 SkGmSetRxTxEn(pAC, IoC, Port, Para);
3555 }
3556#endif /* YUKON */
3557
3558} /* SkMacSetRxTxEn */
3559#endif /* !SK_SLIM */
3560
3561
3562/****************************************************************************** 3115/******************************************************************************
3563 * 3116 *
3564 * SkMacRxTxEnable() - Enable Rx/Tx activity if port is up 3117 * SkMacRxTxEnable() - Enable Rx/Tx activity if port is up
@@ -3976,7 +3529,7 @@ SK_U16 PhyStat) /* PHY Status word to analyse */
3976 * Returns: 3529 * Returns:
3977 * nothing 3530 * nothing
3978 */ 3531 */
3979void SkXmIrq( 3532static void SkXmIrq(
3980SK_AC *pAC, /* adapter context */ 3533SK_AC *pAC, /* adapter context */
3981SK_IOC IoC, /* IO context */ 3534SK_IOC IoC, /* IO context */
3982int Port) /* Port Index (MAC_1 + n) */ 3535int Port) /* Port Index (MAC_1 + n) */
@@ -4112,7 +3665,7 @@ int Port) /* Port Index (MAC_1 + n) */
4112 * Returns: 3665 * Returns:
4113 * nothing 3666 * nothing
4114 */ 3667 */
4115void SkGmIrq( 3668static void SkGmIrq(
4116SK_AC *pAC, /* adapter context */ 3669SK_AC *pAC, /* adapter context */
4117SK_IOC IoC, /* IO context */ 3670SK_IOC IoC, /* IO context */
4118int Port) /* Port Index (MAC_1 + n) */ 3671int Port) /* Port Index (MAC_1 + n) */
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index d167deda9a53..ed5458c45446 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -2084,6 +2084,38 @@ static int netdev_close(struct net_device *dev)
2084 return 0; 2084 return 0;
2085} 2085}
2086 2086
2087#ifdef CONFIG_PM
2088static int starfire_suspend(struct pci_dev *pdev, pm_message_t state)
2089{
2090 struct net_device *dev = pci_get_drvdata(pdev);
2091
2092 if (netif_running(dev)) {
2093 netif_device_detach(dev);
2094 netdev_close(dev);
2095 }
2096
2097 pci_save_state(pdev);
2098 pci_set_power_state(pdev, pci_choose_state(pdev,state));
2099
2100 return 0;
2101}
2102
2103static int starfire_resume(struct pci_dev *pdev)
2104{
2105 struct net_device *dev = pci_get_drvdata(pdev);
2106
2107 pci_set_power_state(pdev, PCI_D0);
2108 pci_restore_state(pdev);
2109
2110 if (netif_running(dev)) {
2111 netdev_open(dev);
2112 netif_device_attach(dev);
2113 }
2114
2115 return 0;
2116}
2117#endif /* CONFIG_PM */
2118
2087 2119
2088static void __devexit starfire_remove_one (struct pci_dev *pdev) 2120static void __devexit starfire_remove_one (struct pci_dev *pdev)
2089{ 2121{
@@ -2115,6 +2147,10 @@ static struct pci_driver starfire_driver = {
2115 .name = DRV_NAME, 2147 .name = DRV_NAME,
2116 .probe = starfire_init_one, 2148 .probe = starfire_init_one,
2117 .remove = __devexit_p(starfire_remove_one), 2149 .remove = __devexit_p(starfire_remove_one),
2150#ifdef CONFIG_PM
2151 .suspend = starfire_suspend,
2152 .resume = starfire_resume,
2153#endif /* CONFIG_PM */
2118 .id_table = starfire_pci_tbl, 2154 .id_table = starfire_pci_tbl,
2119}; 2155};
2120 2156
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 0ab9c38b4a34..8cdeb5cbab5b 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -633,9 +633,13 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
633 633
634 np->phys[0] = 1; /* Default setting */ 634 np->phys[0] = 1; /* Default setting */
635 np->mii_preamble_required++; 635 np->mii_preamble_required++;
636 /*
637 * It seems some phys doesn't deal well with address 0 being accessed
638 * first, so leave address zero to the end of the loop (32 & 31).
639 */
636 for (phy = 1; phy <= 32 && phy_idx < MII_CNT; phy++) { 640 for (phy = 1; phy <= 32 && phy_idx < MII_CNT; phy++) {
637 int mii_status = mdio_read(dev, phy, MII_BMSR);
638 int phyx = phy & 0x1f; 641 int phyx = phy & 0x1f;
642 int mii_status = mdio_read(dev, phyx, MII_BMSR);
639 if (mii_status != 0xffff && mii_status != 0x0000) { 643 if (mii_status != 0xffff && mii_status != 0x0000) {
640 np->phys[phy_idx++] = phyx; 644 np->phys[phy_idx++] = phyx;
641 np->mii_if.advertising = mdio_read(dev, phyx, MII_ADVERTISE); 645 np->mii_if.advertising = mdio_read(dev, phyx, MII_ADVERTISE);
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 97712c3c4e07..c58a4c31d0dd 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -122,6 +122,7 @@
122#include <linux/spinlock.h> 122#include <linux/spinlock.h>
123#include <linux/version.h> 123#include <linux/version.h>
124#include <linux/bitops.h> 124#include <linux/bitops.h>
125#include <linux/jiffies.h>
125 126
126#include <net/checksum.h> 127#include <net/checksum.h>
127 128
@@ -512,7 +513,7 @@ static int streamer_reset(struct net_device *dev)
512 513
513 while (!((readw(streamer_mmio + SISR)) & SISR_SRB_REPLY)) { 514 while (!((readw(streamer_mmio + SISR)) & SISR_SRB_REPLY)) {
514 msleep_interruptible(100); 515 msleep_interruptible(100);
515 if (jiffies - t > 40 * HZ) { 516 if (time_after(jiffies, t + 40 * HZ)) {
516 printk(KERN_ERR 517 printk(KERN_ERR
517 "IBM PCI tokenring card not responding\n"); 518 "IBM PCI tokenring card not responding\n");
518 release_region(dev->base_addr, STREAMER_IO_SPACE); 519 release_region(dev->base_addr, STREAMER_IO_SPACE);
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index 05477d24fd49..23032a7bc0a9 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -100,6 +100,7 @@
100#include <linux/pci.h> 100#include <linux/pci.h>
101#include <linux/spinlock.h> 101#include <linux/spinlock.h>
102#include <linux/bitops.h> 102#include <linux/bitops.h>
103#include <linux/jiffies.h>
103 104
104#include <net/checksum.h> 105#include <net/checksum.h>
105 106
@@ -307,7 +308,7 @@ static int __devinit olympic_init(struct net_device *dev)
307 t=jiffies; 308 t=jiffies;
308 while((readl(olympic_mmio+BCTL)) & BCTL_SOFTRESET) { 309 while((readl(olympic_mmio+BCTL)) & BCTL_SOFTRESET) {
309 schedule(); 310 schedule();
310 if(jiffies-t > 40*HZ) { 311 if(time_after(jiffies, t + 40*HZ)) {
311 printk(KERN_ERR "IBM PCI tokenring card not responding.\n"); 312 printk(KERN_ERR "IBM PCI tokenring card not responding.\n");
312 return -ENODEV; 313 return -ENODEV;
313 } 314 }
@@ -359,7 +360,7 @@ static int __devinit olympic_init(struct net_device *dev)
359 t=jiffies; 360 t=jiffies;
360 while (!readl(olympic_mmio+CLKCTL) & CLKCTL_PAUSE) { 361 while (!readl(olympic_mmio+CLKCTL) & CLKCTL_PAUSE) {
361 schedule() ; 362 schedule() ;
362 if(jiffies-t > 2*HZ) { 363 if(time_after(jiffies, t + 2*HZ)) {
363 printk(KERN_ERR "IBM Cardbus tokenring adapter not responsing.\n") ; 364 printk(KERN_ERR "IBM Cardbus tokenring adapter not responsing.\n") ;
364 return -ENODEV; 365 return -ENODEV;
365 } 366 }
@@ -373,7 +374,7 @@ static int __devinit olympic_init(struct net_device *dev)
373 t=jiffies; 374 t=jiffies;
374 while(!((readl(olympic_mmio+SISR_RR)) & SISR_SRB_REPLY)) { 375 while(!((readl(olympic_mmio+SISR_RR)) & SISR_SRB_REPLY)) {
375 schedule(); 376 schedule();
376 if(jiffies-t > 15*HZ) { 377 if(time_after(jiffies, t + 15*HZ)) {
377 printk(KERN_ERR "IBM PCI tokenring card not responding.\n"); 378 printk(KERN_ERR "IBM PCI tokenring card not responding.\n");
378 return -ENODEV; 379 return -ENODEV;
379 } 380 }
@@ -519,7 +520,7 @@ static int olympic_open(struct net_device *dev)
519 olympic_priv->srb_queued=0; 520 olympic_priv->srb_queued=0;
520 break; 521 break;
521 } 522 }
522 if ((jiffies-t) > 10*HZ) { 523 if (time_after(jiffies, t + 10*HZ)) {
523 printk(KERN_WARNING "%s: SRB timed out. \n",dev->name) ; 524 printk(KERN_WARNING "%s: SRB timed out. \n",dev->name) ;
524 olympic_priv->srb_queued=0; 525 olympic_priv->srb_queued=0;
525 break ; 526 break ;
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index d7fb3ffe06ac..d6c3d52d2e86 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -402,8 +402,7 @@ static void de_rx (struct de_private *de)
402 unsigned copying_skb, buflen; 402 unsigned copying_skb, buflen;
403 403
404 skb = de->rx_skb[rx_tail].skb; 404 skb = de->rx_skb[rx_tail].skb;
405 if (!skb) 405 BUG_ON(!skb);
406 BUG();
407 rmb(); 406 rmb();
408 status = le32_to_cpu(de->rx_ring[rx_tail].opts1); 407 status = le32_to_cpu(de->rx_ring[rx_tail].opts1);
409 if (status & DescOwn) 408 if (status & DescOwn)
@@ -545,8 +544,7 @@ static void de_tx (struct de_private *de)
545 break; 544 break;
546 545
547 skb = de->tx_skb[tx_tail].skb; 546 skb = de->tx_skb[tx_tail].skb;
548 if (!skb) 547 BUG_ON(!skb);
549 BUG();
550 if (unlikely(skb == DE_DUMMY_SKB)) 548 if (unlikely(skb == DE_DUMMY_SKB))
551 goto next; 549 goto next;
552 550
@@ -789,8 +787,7 @@ static void __de_set_rx_mode (struct net_device *dev)
789 787
790 de->tx_head = NEXT_TX(entry); 788 de->tx_head = NEXT_TX(entry);
791 789
792 if (TX_BUFFS_AVAIL(de) < 0) 790 BUG_ON(TX_BUFFS_AVAIL(de) < 0);
793 BUG();
794 if (TX_BUFFS_AVAIL(de) == 0) 791 if (TX_BUFFS_AVAIL(de) == 0)
795 netif_stop_queue(dev); 792 netif_stop_queue(dev);
796 793
@@ -916,8 +913,7 @@ static void de_set_media (struct de_private *de)
916 unsigned media = de->media_type; 913 unsigned media = de->media_type;
917 u32 macmode = dr32(MacMode); 914 u32 macmode = dr32(MacMode);
918 915
919 if (de_is_running(de)) 916 BUG_ON(de_is_running(de));
920 BUG();
921 917
922 if (de->de21040) 918 if (de->de21040)
923 dw32(CSR11, FULL_DUPLEX_MAGIC); 919 dw32(CSR11, FULL_DUPLEX_MAGIC);
@@ -1153,8 +1149,7 @@ static void de_media_interrupt (struct de_private *de, u32 status)
1153 return; 1149 return;
1154 } 1150 }
1155 1151
1156 if (!(status & LinkFail)) 1152 BUG_ON(!(status & LinkFail));
1157 BUG();
1158 1153
1159 if (netif_carrier_ok(de->dev)) { 1154 if (netif_carrier_ok(de->dev)) {
1160 de_link_down(de); 1155 de_link_down(de);
@@ -2092,8 +2087,7 @@ static void __exit de_remove_one (struct pci_dev *pdev)
2092 struct net_device *dev = pci_get_drvdata(pdev); 2087 struct net_device *dev = pci_get_drvdata(pdev);
2093 struct de_private *de = dev->priv; 2088 struct de_private *de = dev->priv;
2094 2089
2095 if (!dev) 2090 BUG_ON(!dev);
2096 BUG();
2097 unregister_netdev(dev); 2091 unregister_netdev(dev);
2098 kfree(de->ee_data); 2092 kfree(de->ee_data);
2099 iounmap(de->regs); 2093 iounmap(de->regs);
diff --git a/drivers/net/tulip/pnic.c b/drivers/net/tulip/pnic.c
index d9980bde7508..ca7e53246adb 100644
--- a/drivers/net/tulip/pnic.c
+++ b/drivers/net/tulip/pnic.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/jiffies.h>
19#include "tulip.h" 20#include "tulip.h"
20 21
21 22
@@ -68,7 +69,7 @@ void pnic_lnk_change(struct net_device *dev, int csr5)
68 */ 69 */
69 if (tulip_media_cap[dev->if_port] & MediaIsMII) 70 if (tulip_media_cap[dev->if_port] & MediaIsMII)
70 return; 71 return;
71 if (! tp->nwayset || jiffies - dev->trans_start > 1*HZ) { 72 if (! tp->nwayset || time_after(jiffies, dev->trans_start + 1*HZ)) {
72 tp->csr6 = 0x00420000 | (tp->csr6 & 0x0000fdff); 73 tp->csr6 = 0x00420000 | (tp->csr6 & 0x0000fdff);
73 iowrite32(tp->csr6, ioaddr + CSR6); 74 iowrite32(tp->csr6, ioaddr + CSR6);
74 iowrite32(0x30, ioaddr + CSR12); 75 iowrite32(0x30, ioaddr + CSR12);
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 5b1af3986abf..ba05dedf29d3 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -1645,7 +1645,7 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
1645 1645
1646 /* no more hardware accesses behind this line. */ 1646 /* no more hardware accesses behind this line. */
1647 1647
1648 if (np->csr6) BUG(); 1648 BUG_ON(np->csr6);
1649 if (ioread32(ioaddr + IntrEnable)) BUG(); 1649 if (ioread32(ioaddr + IntrEnable)) BUG();
1650 1650
1651 /* pci_power_off(pdev, -1); */ 1651 /* pci_power_off(pdev, -1); */
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 42e9ffb07af4..56344103ac23 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -601,10 +601,8 @@ static void setup_descriptors(struct xircom_private *card)
601 enter("setup_descriptors"); 601 enter("setup_descriptors");
602 602
603 603
604 if (card->rx_buffer == NULL) 604 BUG_ON(card->rx_buffer == NULL);
605 BUG(); 605 BUG_ON(card->tx_buffer == NULL);
606 if (card->tx_buffer == NULL)
607 BUG();
608 606
609 /* Receive descriptors */ 607 /* Receive descriptors */
610 memset(card->rx_buffer, 0, 128); /* clear the descriptors */ 608 memset(card->rx_buffer, 0, 128); /* clear the descriptors */
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 233a4f608084..3de5f1d0fbac 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -6,7 +6,8 @@ menu "Wireless LAN (non-hamradio)"
6 depends on NETDEVICES 6 depends on NETDEVICES
7 7
8config NET_RADIO 8config NET_RADIO
9 bool "Wireless LAN drivers (non-hamradio) & Wireless Extensions" 9 bool "Wireless LAN drivers (non-hamradio)"
10 select WIRELESS_EXT
10 ---help--- 11 ---help---
11 Support for wireless LANs and everything having to do with radio, 12 Support for wireless LANs and everything having to do with radio,
12 but not with amateur radio or FM broadcasting. 13 but not with amateur radio or FM broadcasting.
@@ -239,7 +240,8 @@ config IPW2200_DEBUG
239 240
240config AIRO 241config AIRO
241 tristate "Cisco/Aironet 34X/35X/4500/4800 ISA and PCI cards" 242 tristate "Cisco/Aironet 34X/35X/4500/4800 ISA and PCI cards"
242 depends on NET_RADIO && ISA_DMA_API && CRYPTO && (PCI || BROKEN) 243 depends on NET_RADIO && ISA_DMA_API && (PCI || BROKEN)
244 select CRYPTO
243 ---help--- 245 ---help---
244 This is the standard Linux driver to support Cisco/Aironet ISA and 246 This is the standard Linux driver to support Cisco/Aironet ISA and
245 PCI 802.11 wireless cards. 247 PCI 802.11 wireless cards.
@@ -387,6 +389,7 @@ config PCMCIA_SPECTRUM
387config AIRO_CS 389config AIRO_CS
388 tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards" 390 tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards"
389 depends on NET_RADIO && PCMCIA && (BROKEN || !M32R) 391 depends on NET_RADIO && PCMCIA && (BROKEN || !M32R)
392 select CRYPTO
390 ---help--- 393 ---help---
391 This is the standard Linux driver to support Cisco/Aironet PCMCIA 394 This is the standard Linux driver to support Cisco/Aironet PCMCIA
392 802.11 wireless cards. This driver is the same as the Aironet 395 802.11 wireless cards. This driver is the same as the Aironet
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index a4c7ae94614d..ef6495b07890 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -36,6 +36,7 @@
36#include <linux/in.h> 36#include <linux/in.h>
37#include <linux/bitops.h> 37#include <linux/bitops.h>
38#include <linux/scatterlist.h> 38#include <linux/scatterlist.h>
39#include <linux/crypto.h>
39#include <asm/io.h> 40#include <asm/io.h>
40#include <asm/system.h> 41#include <asm/system.h>
41 42
@@ -87,14 +88,6 @@ static struct pci_driver airo_driver = {
87#include <linux/delay.h> 88#include <linux/delay.h>
88#endif 89#endif
89 90
90/* Support Cisco MIC feature */
91#define MICSUPPORT
92
93#if defined(MICSUPPORT) && !defined(CONFIG_CRYPTO)
94#warning MIC support requires Crypto API
95#undef MICSUPPORT
96#endif
97
98/* Hack to do some power saving */ 91/* Hack to do some power saving */
99#define POWER_ON_DOWN 92#define POWER_ON_DOWN
100 93
@@ -1118,7 +1111,6 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp);
1118static int writerids(struct net_device *dev, aironet_ioctl *comp); 1111static int writerids(struct net_device *dev, aironet_ioctl *comp);
1119static int flashcard(struct net_device *dev, aironet_ioctl *comp); 1112static int flashcard(struct net_device *dev, aironet_ioctl *comp);
1120#endif /* CISCO_EXT */ 1113#endif /* CISCO_EXT */
1121#ifdef MICSUPPORT
1122static void micinit(struct airo_info *ai); 1114static void micinit(struct airo_info *ai);
1123static int micsetup(struct airo_info *ai); 1115static int micsetup(struct airo_info *ai);
1124static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len); 1116static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len);
@@ -1127,9 +1119,6 @@ static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket,
1127static u8 airo_rssi_to_dbm (tdsRssiEntry *rssi_rid, u8 rssi); 1119static u8 airo_rssi_to_dbm (tdsRssiEntry *rssi_rid, u8 rssi);
1128static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm); 1120static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm);
1129 1121
1130#include <linux/crypto.h>
1131#endif
1132
1133struct airo_info { 1122struct airo_info {
1134 struct net_device_stats stats; 1123 struct net_device_stats stats;
1135 struct net_device *dev; 1124 struct net_device *dev;
@@ -1190,12 +1179,10 @@ struct airo_info {
1190 unsigned long scan_timestamp; /* Time started to scan */ 1179 unsigned long scan_timestamp; /* Time started to scan */
1191 struct iw_spy_data spy_data; 1180 struct iw_spy_data spy_data;
1192 struct iw_public_data wireless_data; 1181 struct iw_public_data wireless_data;
1193#ifdef MICSUPPORT
1194 /* MIC stuff */ 1182 /* MIC stuff */
1195 struct crypto_tfm *tfm; 1183 struct crypto_tfm *tfm;
1196 mic_module mod[2]; 1184 mic_module mod[2];
1197 mic_statistics micstats; 1185 mic_statistics micstats;
1198#endif
1199 HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors 1186 HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors
1200 HostTxDesc txfids[MPI_MAX_FIDS]; 1187 HostTxDesc txfids[MPI_MAX_FIDS];
1201 HostRidDesc config_desc; 1188 HostRidDesc config_desc;
@@ -1229,7 +1216,6 @@ static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime);
1229static int flashputbuf(struct airo_info *ai); 1216static int flashputbuf(struct airo_info *ai);
1230static int flashrestart(struct airo_info *ai,struct net_device *dev); 1217static int flashrestart(struct airo_info *ai,struct net_device *dev);
1231 1218
1232#ifdef MICSUPPORT
1233/*********************************************************************** 1219/***********************************************************************
1234 * MIC ROUTINES * 1220 * MIC ROUTINES *
1235 *********************************************************************** 1221 ***********************************************************************
@@ -1686,7 +1672,6 @@ static void emmh32_final(emmh32_context *context, u8 digest[4])
1686 digest[2] = (val>>8) & 0xFF; 1672 digest[2] = (val>>8) & 0xFF;
1687 digest[3] = val & 0xFF; 1673 digest[3] = val & 0xFF;
1688} 1674}
1689#endif
1690 1675
1691static int readBSSListRid(struct airo_info *ai, int first, 1676static int readBSSListRid(struct airo_info *ai, int first,
1692 BSSListRid *list) { 1677 BSSListRid *list) {
@@ -2005,7 +1990,6 @@ static int mpi_send_packet (struct net_device *dev)
2005 * Firmware automaticly puts 802 header on so 1990 * Firmware automaticly puts 802 header on so
2006 * we don't need to account for it in the length 1991 * we don't need to account for it in the length
2007 */ 1992 */
2008#ifdef MICSUPPORT
2009 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && 1993 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled &&
2010 (ntohs(((u16 *)buffer)[6]) != 0x888E)) { 1994 (ntohs(((u16 *)buffer)[6]) != 0x888E)) {
2011 MICBuffer pMic; 1995 MICBuffer pMic;
@@ -2022,9 +2006,7 @@ static int mpi_send_packet (struct net_device *dev)
2022 memcpy (sendbuf, &pMic, sizeof(pMic)); 2006 memcpy (sendbuf, &pMic, sizeof(pMic));
2023 sendbuf += sizeof(pMic); 2007 sendbuf += sizeof(pMic);
2024 memcpy (sendbuf, buffer, len - sizeof(etherHead)); 2008 memcpy (sendbuf, buffer, len - sizeof(etherHead));
2025 } else 2009 } else {
2026#endif
2027 {
2028 *payloadLen = cpu_to_le16(len - sizeof(etherHead)); 2010 *payloadLen = cpu_to_le16(len - sizeof(etherHead));
2029 2011
2030 dev->trans_start = jiffies; 2012 dev->trans_start = jiffies;
@@ -2400,9 +2382,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
2400 ai->shared, ai->shared_dma); 2382 ai->shared, ai->shared_dma);
2401 } 2383 }
2402 } 2384 }
2403#ifdef MICSUPPORT
2404 crypto_free_tfm(ai->tfm); 2385 crypto_free_tfm(ai->tfm);
2405#endif
2406 del_airo_dev( dev ); 2386 del_airo_dev( dev );
2407 free_netdev( dev ); 2387 free_netdev( dev );
2408} 2388}
@@ -2726,9 +2706,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2726 ai->thr_pid = kernel_thread(airo_thread, dev, CLONE_FS | CLONE_FILES); 2706 ai->thr_pid = kernel_thread(airo_thread, dev, CLONE_FS | CLONE_FILES);
2727 if (ai->thr_pid < 0) 2707 if (ai->thr_pid < 0)
2728 goto err_out_free; 2708 goto err_out_free;
2729#ifdef MICSUPPORT
2730 ai->tfm = NULL; 2709 ai->tfm = NULL;
2731#endif
2732 rc = add_airo_dev( dev ); 2710 rc = add_airo_dev( dev );
2733 if (rc) 2711 if (rc)
2734 goto err_out_thr; 2712 goto err_out_thr;
@@ -2969,10 +2947,8 @@ static int airo_thread(void *data) {
2969 airo_read_wireless_stats(ai); 2947 airo_read_wireless_stats(ai);
2970 else if (test_bit(JOB_PROMISC, &ai->flags)) 2948 else if (test_bit(JOB_PROMISC, &ai->flags))
2971 airo_set_promisc(ai); 2949 airo_set_promisc(ai);
2972#ifdef MICSUPPORT
2973 else if (test_bit(JOB_MIC, &ai->flags)) 2950 else if (test_bit(JOB_MIC, &ai->flags))
2974 micinit(ai); 2951 micinit(ai);
2975#endif
2976 else if (test_bit(JOB_EVENT, &ai->flags)) 2952 else if (test_bit(JOB_EVENT, &ai->flags))
2977 airo_send_event(dev); 2953 airo_send_event(dev);
2978 else if (test_bit(JOB_AUTOWEP, &ai->flags)) 2954 else if (test_bit(JOB_AUTOWEP, &ai->flags))
@@ -3010,12 +2986,10 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
3010 2986
3011 if ( status & EV_MIC ) { 2987 if ( status & EV_MIC ) {
3012 OUT4500( apriv, EVACK, EV_MIC ); 2988 OUT4500( apriv, EVACK, EV_MIC );
3013#ifdef MICSUPPORT
3014 if (test_bit(FLAG_MIC_CAPABLE, &apriv->flags)) { 2989 if (test_bit(FLAG_MIC_CAPABLE, &apriv->flags)) {
3015 set_bit(JOB_MIC, &apriv->flags); 2990 set_bit(JOB_MIC, &apriv->flags);
3016 wake_up_interruptible(&apriv->thr_wait); 2991 wake_up_interruptible(&apriv->thr_wait);
3017 } 2992 }
3018#endif
3019 } 2993 }
3020 if ( status & EV_LINK ) { 2994 if ( status & EV_LINK ) {
3021 union iwreq_data wrqu; 2995 union iwreq_data wrqu;
@@ -3194,11 +3168,8 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
3194 } 3168 }
3195 bap_read (apriv, buffer + hdrlen/2, len, BAP0); 3169 bap_read (apriv, buffer + hdrlen/2, len, BAP0);
3196 } else { 3170 } else {
3197#ifdef MICSUPPORT
3198 MICBuffer micbuf; 3171 MICBuffer micbuf;
3199#endif
3200 bap_read (apriv, buffer, ETH_ALEN*2, BAP0); 3172 bap_read (apriv, buffer, ETH_ALEN*2, BAP0);
3201#ifdef MICSUPPORT
3202 if (apriv->micstats.enabled) { 3173 if (apriv->micstats.enabled) {
3203 bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0); 3174 bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0);
3204 if (ntohs(micbuf.typelen) > 0x05DC) 3175 if (ntohs(micbuf.typelen) > 0x05DC)
@@ -3211,15 +3182,10 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
3211 skb_trim (skb, len + hdrlen); 3182 skb_trim (skb, len + hdrlen);
3212 } 3183 }
3213 } 3184 }
3214#endif
3215 bap_read(apriv,buffer+ETH_ALEN,len,BAP0); 3185 bap_read(apriv,buffer+ETH_ALEN,len,BAP0);
3216#ifdef MICSUPPORT
3217 if (decapsulate(apriv,&micbuf,(etherHead*)buffer,len)) { 3186 if (decapsulate(apriv,&micbuf,(etherHead*)buffer,len)) {
3218badmic: 3187badmic:
3219 dev_kfree_skb_irq (skb); 3188 dev_kfree_skb_irq (skb);
3220#else
3221 if (0) {
3222#endif
3223badrx: 3189badrx:
3224 OUT4500( apriv, EVACK, EV_RX); 3190 OUT4500( apriv, EVACK, EV_RX);
3225 goto exitrx; 3191 goto exitrx;
@@ -3430,10 +3396,8 @@ static void mpi_receive_802_3(struct airo_info *ai)
3430 int len = 0; 3396 int len = 0;
3431 struct sk_buff *skb; 3397 struct sk_buff *skb;
3432 char *buffer; 3398 char *buffer;
3433#ifdef MICSUPPORT
3434 int off = 0; 3399 int off = 0;
3435 MICBuffer micbuf; 3400 MICBuffer micbuf;
3436#endif
3437 3401
3438 memcpy_fromio(&rxd, ai->rxfids[0].card_ram_off, sizeof(rxd)); 3402 memcpy_fromio(&rxd, ai->rxfids[0].card_ram_off, sizeof(rxd));
3439 /* Make sure we got something */ 3403 /* Make sure we got something */
@@ -3448,7 +3412,6 @@ static void mpi_receive_802_3(struct airo_info *ai)
3448 goto badrx; 3412 goto badrx;
3449 } 3413 }
3450 buffer = skb_put(skb,len); 3414 buffer = skb_put(skb,len);
3451#ifdef MICSUPPORT
3452 memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2); 3415 memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2);
3453 if (ai->micstats.enabled) { 3416 if (ai->micstats.enabled) {
3454 memcpy(&micbuf, 3417 memcpy(&micbuf,
@@ -3470,9 +3433,6 @@ badmic:
3470 dev_kfree_skb_irq (skb); 3433 dev_kfree_skb_irq (skb);
3471 goto badrx; 3434 goto badrx;
3472 } 3435 }
3473#else
3474 memcpy(buffer, ai->rxfids[0].virtual_host_addr, len);
3475#endif
3476#ifdef WIRELESS_SPY 3436#ifdef WIRELESS_SPY
3477 if (ai->spy_data.spy_number > 0) { 3437 if (ai->spy_data.spy_number > 0) {
3478 char *sa; 3438 char *sa;
@@ -3689,13 +3649,11 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
3689 ai->config.authType = AUTH_OPEN; 3649 ai->config.authType = AUTH_OPEN;
3690 ai->config.modulation = MOD_CCK; 3650 ai->config.modulation = MOD_CCK;
3691 3651
3692#ifdef MICSUPPORT
3693 if ((cap_rid.len>=sizeof(cap_rid)) && (cap_rid.extSoftCap&1) && 3652 if ((cap_rid.len>=sizeof(cap_rid)) && (cap_rid.extSoftCap&1) &&
3694 (micsetup(ai) == SUCCESS)) { 3653 (micsetup(ai) == SUCCESS)) {
3695 ai->config.opmode |= MODE_MIC; 3654 ai->config.opmode |= MODE_MIC;
3696 set_bit(FLAG_MIC_CAPABLE, &ai->flags); 3655 set_bit(FLAG_MIC_CAPABLE, &ai->flags);
3697 } 3656 }
3698#endif
3699 3657
3700 /* Save off the MAC */ 3658 /* Save off the MAC */
3701 for( i = 0; i < ETH_ALEN; i++ ) { 3659 for( i = 0; i < ETH_ALEN; i++ ) {
@@ -4170,15 +4128,12 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket)
4170 } 4128 }
4171 len -= ETH_ALEN * 2; 4129 len -= ETH_ALEN * 2;
4172 4130
4173#ifdef MICSUPPORT
4174 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && 4131 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled &&
4175 (ntohs(((u16 *)pPacket)[6]) != 0x888E)) { 4132 (ntohs(((u16 *)pPacket)[6]) != 0x888E)) {
4176 if (encapsulate(ai,(etherHead *)pPacket,&pMic,len) != SUCCESS) 4133 if (encapsulate(ai,(etherHead *)pPacket,&pMic,len) != SUCCESS)
4177 return ERROR; 4134 return ERROR;
4178 miclen = sizeof(pMic); 4135 miclen = sizeof(pMic);
4179 } 4136 }
4180#endif
4181
4182 // packet is destination[6], source[6], payload[len-12] 4137 // packet is destination[6], source[6], payload[len-12]
4183 // write the payload length and dst/src/payload 4138 // write the payload length and dst/src/payload
4184 if (bap_setup(ai, txFid, 0x0036, BAP1) != SUCCESS) return ERROR; 4139 if (bap_setup(ai, txFid, 0x0036, BAP1) != SUCCESS) return ERROR;
@@ -5801,11 +5756,13 @@ static int airo_set_wap(struct net_device *dev,
5801 Cmd cmd; 5756 Cmd cmd;
5802 Resp rsp; 5757 Resp rsp;
5803 APListRid APList_rid; 5758 APListRid APList_rid;
5804 static const unsigned char bcast[ETH_ALEN] = { 255, 255, 255, 255, 255, 255 }; 5759 static const u8 any[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
5760 static const u8 off[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
5805 5761
5806 if (awrq->sa_family != ARPHRD_ETHER) 5762 if (awrq->sa_family != ARPHRD_ETHER)
5807 return -EINVAL; 5763 return -EINVAL;
5808 else if (!memcmp(bcast, awrq->sa_data, ETH_ALEN)) { 5764 else if (!memcmp(any, awrq->sa_data, ETH_ALEN) ||
5765 !memcmp(off, awrq->sa_data, ETH_ALEN)) {
5809 memset(&cmd, 0, sizeof(cmd)); 5766 memset(&cmd, 0, sizeof(cmd));
5810 cmd.cmd=CMD_LOSE_SYNC; 5767 cmd.cmd=CMD_LOSE_SYNC;
5811 if (down_interruptible(&local->sem)) 5768 if (down_interruptible(&local->sem))
@@ -6296,6 +6253,267 @@ static int airo_get_encode(struct net_device *dev,
6296 6253
6297/*------------------------------------------------------------------*/ 6254/*------------------------------------------------------------------*/
6298/* 6255/*
6256 * Wireless Handler : set extended Encryption parameters
6257 */
6258static int airo_set_encodeext(struct net_device *dev,
6259 struct iw_request_info *info,
6260 union iwreq_data *wrqu,
6261 char *extra)
6262{
6263 struct airo_info *local = dev->priv;
6264 struct iw_point *encoding = &wrqu->encoding;
6265 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6266 CapabilityRid cap_rid; /* Card capability info */
6267 int perm = ( encoding->flags & IW_ENCODE_TEMP ? 0 : 1 );
6268 u16 currentAuthType = local->config.authType;
6269 int idx, key_len, alg = ext->alg; /* Check encryption mode */
6270 wep_key_t key;
6271
6272 /* Is WEP supported ? */
6273 readCapabilityRid(local, &cap_rid, 1);
6274 /* Older firmware doesn't support this...
6275 if(!(cap_rid.softCap & 2)) {
6276 return -EOPNOTSUPP;
6277 } */
6278 readConfigRid(local, 1);
6279
6280 /* Determine and validate the key index */
6281 idx = encoding->flags & IW_ENCODE_INDEX;
6282 if (idx) {
6283 if (idx < 1 || idx > ((cap_rid.softCap & 0x80) ? 4:1))
6284 return -EINVAL;
6285 idx--;
6286 } else
6287 idx = get_wep_key(local, 0xffff);
6288
6289 if (encoding->flags & IW_ENCODE_DISABLED)
6290 alg = IW_ENCODE_ALG_NONE;
6291
6292 /* Just setting the transmit key? */
6293 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
6294 set_wep_key(local, idx, NULL, 0, perm, 1);
6295 } else {
6296 /* Set the requested key first */
6297 memset(key.key, 0, MAX_KEY_SIZE);
6298 switch (alg) {
6299 case IW_ENCODE_ALG_NONE:
6300 key.len = 0;
6301 break;
6302 case IW_ENCODE_ALG_WEP:
6303 if (ext->key_len > MIN_KEY_SIZE) {
6304 key.len = MAX_KEY_SIZE;
6305 } else if (ext->key_len > 0) {
6306 key.len = MIN_KEY_SIZE;
6307 } else {
6308 return -EINVAL;
6309 }
6310 key_len = min (ext->key_len, key.len);
6311 memcpy(key.key, ext->key, key_len);
6312 break;
6313 default:
6314 return -EINVAL;
6315 }
6316 /* Send the key to the card */
6317 set_wep_key(local, idx, key.key, key.len, perm, 1);
6318 }
6319
6320 /* Read the flags */
6321 if(encoding->flags & IW_ENCODE_DISABLED)
6322 local->config.authType = AUTH_OPEN; // disable encryption
6323 if(encoding->flags & IW_ENCODE_RESTRICTED)
6324 local->config.authType = AUTH_SHAREDKEY; // Only Both
6325 if(encoding->flags & IW_ENCODE_OPEN)
6326 local->config.authType = AUTH_ENCRYPT; // Only Wep
6327 /* Commit the changes to flags if needed */
6328 if (local->config.authType != currentAuthType)
6329 set_bit (FLAG_COMMIT, &local->flags);
6330
6331 return -EINPROGRESS;
6332}
6333
6334
6335/*------------------------------------------------------------------*/
6336/*
6337 * Wireless Handler : get extended Encryption parameters
6338 */
6339static int airo_get_encodeext(struct net_device *dev,
6340 struct iw_request_info *info,
6341 union iwreq_data *wrqu,
6342 char *extra)
6343{
6344 struct airo_info *local = dev->priv;
6345 struct iw_point *encoding = &wrqu->encoding;
6346 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6347 CapabilityRid cap_rid; /* Card capability info */
6348 int idx, max_key_len;
6349
6350 /* Is it supported ? */
6351 readCapabilityRid(local, &cap_rid, 1);
6352 if(!(cap_rid.softCap & 2)) {
6353 return -EOPNOTSUPP;
6354 }
6355 readConfigRid(local, 1);
6356
6357 max_key_len = encoding->length - sizeof(*ext);
6358 if (max_key_len < 0)
6359 return -EINVAL;
6360
6361 idx = encoding->flags & IW_ENCODE_INDEX;
6362 if (idx) {
6363 if (idx < 1 || idx > ((cap_rid.softCap & 0x80) ? 4:1))
6364 return -EINVAL;
6365 idx--;
6366 } else
6367 idx = get_wep_key(local, 0xffff);
6368
6369 encoding->flags = idx + 1;
6370 memset(ext, 0, sizeof(*ext));
6371
6372 /* Check encryption mode */
6373 switch(local->config.authType) {
6374 case AUTH_ENCRYPT:
6375 encoding->flags = IW_ENCODE_ALG_WEP | IW_ENCODE_ENABLED;
6376 break;
6377 case AUTH_SHAREDKEY:
6378 encoding->flags = IW_ENCODE_ALG_WEP | IW_ENCODE_ENABLED;
6379 break;
6380 default:
6381 case AUTH_OPEN:
6382 encoding->flags = IW_ENCODE_ALG_NONE | IW_ENCODE_DISABLED;
6383 break;
6384 }
6385 /* We can't return the key, so set the proper flag and return zero */
6386 encoding->flags |= IW_ENCODE_NOKEY;
6387 memset(extra, 0, 16);
6388
6389 /* Copy the key to the user buffer */
6390 ext->key_len = get_wep_key(local, idx);
6391 if (ext->key_len > 16) {
6392 ext->key_len=0;
6393 }
6394
6395 return 0;
6396}
6397
6398
6399/*------------------------------------------------------------------*/
6400/*
6401 * Wireless Handler : set extended authentication parameters
6402 */
6403static int airo_set_auth(struct net_device *dev,
6404 struct iw_request_info *info,
6405 union iwreq_data *wrqu, char *extra)
6406{
6407 struct airo_info *local = dev->priv;
6408 struct iw_param *param = &wrqu->param;
6409 u16 currentAuthType = local->config.authType;
6410
6411 switch (param->flags & IW_AUTH_INDEX) {
6412 case IW_AUTH_WPA_VERSION:
6413 case IW_AUTH_CIPHER_PAIRWISE:
6414 case IW_AUTH_CIPHER_GROUP:
6415 case IW_AUTH_KEY_MGMT:
6416 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6417 case IW_AUTH_PRIVACY_INVOKED:
6418 /*
6419 * airo does not use these parameters
6420 */
6421 break;
6422
6423 case IW_AUTH_DROP_UNENCRYPTED:
6424 if (param->value) {
6425 /* Only change auth type if unencrypted */
6426 if (currentAuthType == AUTH_OPEN)
6427 local->config.authType = AUTH_ENCRYPT;
6428 } else {
6429 local->config.authType = AUTH_OPEN;
6430 }
6431
6432 /* Commit the changes to flags if needed */
6433 if (local->config.authType != currentAuthType)
6434 set_bit (FLAG_COMMIT, &local->flags);
6435 break;
6436
6437 case IW_AUTH_80211_AUTH_ALG: {
6438 /* FIXME: What about AUTH_OPEN? This API seems to
6439 * disallow setting our auth to AUTH_OPEN.
6440 */
6441 if (param->value & IW_AUTH_ALG_SHARED_KEY) {
6442 local->config.authType = AUTH_SHAREDKEY;
6443 } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
6444 local->config.authType = AUTH_ENCRYPT;
6445 } else
6446 return -EINVAL;
6447 break;
6448
6449 /* Commit the changes to flags if needed */
6450 if (local->config.authType != currentAuthType)
6451 set_bit (FLAG_COMMIT, &local->flags);
6452 }
6453
6454 case IW_AUTH_WPA_ENABLED:
6455 /* Silently accept disable of WPA */
6456 if (param->value > 0)
6457 return -EOPNOTSUPP;
6458 break;
6459
6460 default:
6461 return -EOPNOTSUPP;
6462 }
6463 return -EINPROGRESS;
6464}
6465
6466
6467/*------------------------------------------------------------------*/
6468/*
6469 * Wireless Handler : get extended authentication parameters
6470 */
6471static int airo_get_auth(struct net_device *dev,
6472 struct iw_request_info *info,
6473 union iwreq_data *wrqu, char *extra)
6474{
6475 struct airo_info *local = dev->priv;
6476 struct iw_param *param = &wrqu->param;
6477 u16 currentAuthType = local->config.authType;
6478
6479 switch (param->flags & IW_AUTH_INDEX) {
6480 case IW_AUTH_DROP_UNENCRYPTED:
6481 switch (currentAuthType) {
6482 case AUTH_SHAREDKEY:
6483 case AUTH_ENCRYPT:
6484 param->value = 1;
6485 break;
6486 default:
6487 param->value = 0;
6488 break;
6489 }
6490 break;
6491
6492 case IW_AUTH_80211_AUTH_ALG:
6493 switch (currentAuthType) {
6494 case AUTH_SHAREDKEY:
6495 param->value = IW_AUTH_ALG_SHARED_KEY;
6496 break;
6497 case AUTH_ENCRYPT:
6498 default:
6499 param->value = IW_AUTH_ALG_OPEN_SYSTEM;
6500 break;
6501 }
6502 break;
6503
6504 case IW_AUTH_WPA_ENABLED:
6505 param->value = 0;
6506 break;
6507
6508 default:
6509 return -EOPNOTSUPP;
6510 }
6511 return 0;
6512}
6513
6514
6515/*------------------------------------------------------------------*/
6516/*
6299 * Wireless Handler : set Tx-Power 6517 * Wireless Handler : set Tx-Power
6300 */ 6518 */
6301static int airo_set_txpow(struct net_device *dev, 6519static int airo_set_txpow(struct net_device *dev,
@@ -7050,6 +7268,15 @@ static const iw_handler airo_handler[] =
7050 (iw_handler) airo_get_encode, /* SIOCGIWENCODE */ 7268 (iw_handler) airo_get_encode, /* SIOCGIWENCODE */
7051 (iw_handler) airo_set_power, /* SIOCSIWPOWER */ 7269 (iw_handler) airo_set_power, /* SIOCSIWPOWER */
7052 (iw_handler) airo_get_power, /* SIOCGIWPOWER */ 7270 (iw_handler) airo_get_power, /* SIOCGIWPOWER */
7271 (iw_handler) NULL, /* -- hole -- */
7272 (iw_handler) NULL, /* -- hole -- */
7273 (iw_handler) NULL, /* SIOCSIWGENIE */
7274 (iw_handler) NULL, /* SIOCGIWGENIE */
7275 (iw_handler) airo_set_auth, /* SIOCSIWAUTH */
7276 (iw_handler) airo_get_auth, /* SIOCGIWAUTH */
7277 (iw_handler) airo_set_encodeext, /* SIOCSIWENCODEEXT */
7278 (iw_handler) airo_get_encodeext, /* SIOCGIWENCODEEXT */
7279 (iw_handler) NULL, /* SIOCSIWPMKSA */
7053}; 7280};
7054 7281
7055/* Note : don't describe AIROIDIFC and AIROOLDIDIFC in here. 7282/* Note : don't describe AIROIDIFC and AIROOLDIDIFC in here.
@@ -7270,13 +7497,11 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
7270 case AIROGSTAT: ridcode = RID_STATUS; break; 7497 case AIROGSTAT: ridcode = RID_STATUS; break;
7271 case AIROGSTATSD32: ridcode = RID_STATSDELTA; break; 7498 case AIROGSTATSD32: ridcode = RID_STATSDELTA; break;
7272 case AIROGSTATSC32: ridcode = RID_STATS; break; 7499 case AIROGSTATSC32: ridcode = RID_STATS; break;
7273#ifdef MICSUPPORT
7274 case AIROGMICSTATS: 7500 case AIROGMICSTATS:
7275 if (copy_to_user(comp->data, &ai->micstats, 7501 if (copy_to_user(comp->data, &ai->micstats,
7276 min((int)comp->len,(int)sizeof(ai->micstats)))) 7502 min((int)comp->len,(int)sizeof(ai->micstats))))
7277 return -EFAULT; 7503 return -EFAULT;
7278 return 0; 7504 return 0;
7279#endif
7280 case AIRORRID: ridcode = comp->ridnum; break; 7505 case AIRORRID: ridcode = comp->ridnum; break;
7281 default: 7506 default:
7282 return -EINVAL; 7507 return -EINVAL;
@@ -7308,9 +7533,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
7308static int writerids(struct net_device *dev, aironet_ioctl *comp) { 7533static int writerids(struct net_device *dev, aironet_ioctl *comp) {
7309 struct airo_info *ai = dev->priv; 7534 struct airo_info *ai = dev->priv;
7310 int ridcode; 7535 int ridcode;
7311#ifdef MICSUPPORT
7312 int enabled; 7536 int enabled;
7313#endif
7314 Resp rsp; 7537 Resp rsp;
7315 static int (* writer)(struct airo_info *, u16 rid, const void *, int, int); 7538 static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
7316 unsigned char *iobuf; 7539 unsigned char *iobuf;
@@ -7367,11 +7590,9 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
7367 7590
7368 PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDSIZE, 1); 7591 PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDSIZE, 1);
7369 7592
7370#ifdef MICSUPPORT
7371 enabled = ai->micstats.enabled; 7593 enabled = ai->micstats.enabled;
7372 memset(&ai->micstats,0,sizeof(ai->micstats)); 7594 memset(&ai->micstats,0,sizeof(ai->micstats));
7373 ai->micstats.enabled = enabled; 7595 ai->micstats.enabled = enabled;
7374#endif
7375 7596
7376 if (copy_to_user(comp->data, iobuf, 7597 if (copy_to_user(comp->data, iobuf,
7377 min((int)comp->len, (int)RIDSIZE))) { 7598 min((int)comp->len, (int)RIDSIZE))) {
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 6290c9f7e939..eb79198ac450 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -167,7 +167,7 @@ that only one external action is invoked at a time.
167 167
168#include "ipw2100.h" 168#include "ipw2100.h"
169 169
170#define IPW2100_VERSION "1.1.3" 170#define IPW2100_VERSION "git-1.1.4"
171 171
172#define DRV_NAME "ipw2100" 172#define DRV_NAME "ipw2100"
173#define DRV_VERSION IPW2100_VERSION 173#define DRV_VERSION IPW2100_VERSION
@@ -1672,6 +1672,18 @@ static int ipw2100_start_scan(struct ipw2100_priv *priv)
1672 return err; 1672 return err;
1673} 1673}
1674 1674
1675static const struct ieee80211_geo ipw_geos[] = {
1676 { /* Restricted */
1677 "---",
1678 .bg_channels = 14,
1679 .bg = {{2412, 1}, {2417, 2}, {2422, 3},
1680 {2427, 4}, {2432, 5}, {2437, 6},
1681 {2442, 7}, {2447, 8}, {2452, 9},
1682 {2457, 10}, {2462, 11}, {2467, 12},
1683 {2472, 13}, {2484, 14}},
1684 },
1685};
1686
1675static int ipw2100_up(struct ipw2100_priv *priv, int deferred) 1687static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1676{ 1688{
1677 unsigned long flags; 1689 unsigned long flags;
@@ -1727,6 +1739,13 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
1727 goto exit; 1739 goto exit;
1728 } 1740 }
1729 1741
1742 /* Initialize the geo */
1743 if (ieee80211_set_geo(priv->ieee, &ipw_geos[0])) {
1744 printk(KERN_WARNING DRV_NAME "Could not set geo\n");
1745 return 0;
1746 }
1747 priv->ieee->freq_band = IEEE80211_24GHZ_BAND;
1748
1730 lock = LOCK_NONE; 1749 lock = LOCK_NONE;
1731 if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) { 1750 if (ipw2100_set_ordinal(priv, IPW_ORD_PERS_DB_LOCK, &lock, &ord_len)) {
1732 printk(KERN_ERR DRV_NAME 1751 printk(KERN_ERR DRV_NAME
@@ -3750,7 +3769,7 @@ static ssize_t store_memory(struct device *d, struct device_attribute *attr,
3750 struct net_device *dev = priv->net_dev; 3769 struct net_device *dev = priv->net_dev;
3751 const char *p = buf; 3770 const char *p = buf;
3752 3771
3753 (void) dev; /* kill unused-var warning for debug-only code */ 3772 (void)dev; /* kill unused-var warning for debug-only code */
3754 3773
3755 if (count < 1) 3774 if (count < 1)
3756 return count; 3775 return count;
@@ -4070,7 +4089,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
4070 unsigned long val; 4089 unsigned long val;
4071 char *p = buffer; 4090 char *p = buffer;
4072 4091
4073 (void) dev; /* kill unused-var warning for debug-only code */ 4092 (void)dev; /* kill unused-var warning for debug-only code */
4074 4093
4075 IPW_DEBUG_INFO("enter\n"); 4094 IPW_DEBUG_INFO("enter\n");
4076 4095
@@ -5107,12 +5126,13 @@ static int ipw2100_set_tx_power(struct ipw2100_priv *priv, u32 tx_power)
5107 .host_command_length = 4 5126 .host_command_length = 4
5108 }; 5127 };
5109 int err = 0; 5128 int err = 0;
5129 u32 tmp = tx_power;
5110 5130
5111 if (tx_power != IPW_TX_POWER_DEFAULT) 5131 if (tx_power != IPW_TX_POWER_DEFAULT)
5112 tx_power = (tx_power - IPW_TX_POWER_MIN_DBM) * 16 / 5132 tmp = (tx_power - IPW_TX_POWER_MIN_DBM) * 16 /
5113 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM); 5133 (IPW_TX_POWER_MAX_DBM - IPW_TX_POWER_MIN_DBM);
5114 5134
5115 cmd.host_command_parameters[0] = tx_power; 5135 cmd.host_command_parameters[0] = tmp;
5116 5136
5117 if (priv->ieee->iw_mode == IW_MODE_ADHOC) 5137 if (priv->ieee->iw_mode == IW_MODE_ADHOC)
5118 err = ipw2100_hw_send_command(priv, &cmd); 5138 err = ipw2100_hw_send_command(priv, &cmd);
@@ -5365,9 +5385,12 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv, int batch_mode)
5365 SEC_LEVEL_0, 0, 1); 5385 SEC_LEVEL_0, 0, 1);
5366 } else { 5386 } else {
5367 auth_mode = IPW_AUTH_OPEN; 5387 auth_mode = IPW_AUTH_OPEN;
5368 if ((priv->ieee->sec.flags & SEC_AUTH_MODE) && 5388 if (priv->ieee->sec.flags & SEC_AUTH_MODE) {
5369 (priv->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY)) 5389 if (priv->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY)
5370 auth_mode = IPW_AUTH_SHARED; 5390 auth_mode = IPW_AUTH_SHARED;
5391 else if (priv->ieee->sec.auth_mode == WLAN_AUTH_LEAP)
5392 auth_mode = IPW_AUTH_LEAP_CISCO_ID;
5393 }
5371 5394
5372 sec_level = SEC_LEVEL_0; 5395 sec_level = SEC_LEVEL_0;
5373 if (priv->ieee->sec.flags & SEC_LEVEL) 5396 if (priv->ieee->sec.flags & SEC_LEVEL)
@@ -5760,6 +5783,9 @@ static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value)
5760 } else if (value & IW_AUTH_ALG_OPEN_SYSTEM) { 5783 } else if (value & IW_AUTH_ALG_OPEN_SYSTEM) {
5761 sec.auth_mode = WLAN_AUTH_OPEN; 5784 sec.auth_mode = WLAN_AUTH_OPEN;
5762 ieee->open_wep = 1; 5785 ieee->open_wep = 1;
5786 } else if (value & IW_AUTH_ALG_LEAP) {
5787 sec.auth_mode = WLAN_AUTH_LEAP;
5788 ieee->open_wep = 1;
5763 } else 5789 } else
5764 return -EINVAL; 5790 return -EINVAL;
5765 5791
@@ -5771,8 +5797,8 @@ static int ipw2100_wpa_set_auth_algs(struct ipw2100_priv *priv, int value)
5771 return ret; 5797 return ret;
5772} 5798}
5773 5799
5774void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv, 5800static void ipw2100_wpa_assoc_frame(struct ipw2100_priv *priv,
5775 char *wpa_ie, int wpa_ie_len) 5801 char *wpa_ie, int wpa_ie_len)
5776{ 5802{
5777 5803
5778 struct ipw2100_wpa_assoc_frame frame; 5804 struct ipw2100_wpa_assoc_frame frame;
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
index f6c51441fa87..51360910d222 100644
--- a/drivers/net/wireless/ipw2100.h
+++ b/drivers/net/wireless/ipw2100.h
@@ -392,8 +392,10 @@ struct ipw2100_notification {
392#define IPW_WEP104_CIPHER (1<<5) 392#define IPW_WEP104_CIPHER (1<<5)
393#define IPW_CKIP_CIPHER (1<<6) 393#define IPW_CKIP_CIPHER (1<<6)
394 394
395#define IPW_AUTH_OPEN 0 395#define IPW_AUTH_OPEN 0
396#define IPW_AUTH_SHARED 1 396#define IPW_AUTH_SHARED 1
397#define IPW_AUTH_LEAP 2
398#define IPW_AUTH_LEAP_CISCO_ID 0x80
397 399
398struct statistic { 400struct statistic {
399 int value; 401 int value;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 14beab4bc91c..0702f0eeb784 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -33,7 +33,7 @@
33#include "ipw2200.h" 33#include "ipw2200.h"
34#include <linux/version.h> 34#include <linux/version.h>
35 35
36#define IPW2200_VERSION "git-1.0.8" 36#define IPW2200_VERSION "git-1.0.10"
37#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver" 37#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver"
38#define DRV_COPYRIGHT "Copyright(c) 2003-2005 Intel Corporation" 38#define DRV_COPYRIGHT "Copyright(c) 2003-2005 Intel Corporation"
39#define DRV_VERSION IPW2200_VERSION 39#define DRV_VERSION IPW2200_VERSION
@@ -55,7 +55,9 @@ static int associate = 1;
55static int auto_create = 1; 55static int auto_create = 1;
56static int led = 0; 56static int led = 0;
57static int disable = 0; 57static int disable = 0;
58static int hwcrypto = 1; 58static int bt_coexist = 0;
59static int hwcrypto = 0;
60static int roaming = 1;
59static const char ipw_modes[] = { 61static const char ipw_modes[] = {
60 'a', 'b', 'g', '?' 62 'a', 'b', 'g', '?'
61}; 63};
@@ -227,12 +229,15 @@ static int snprintk_buf(u8 * output, size_t size, const u8 * data, size_t len)
227 return total; 229 return total;
228} 230}
229 231
232/* alias for 32-bit indirect read (for SRAM/reg above 4K), with debug wrapper */
230static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg); 233static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg);
231#define ipw_read_reg32(a, b) _ipw_read_reg32(a, b) 234#define ipw_read_reg32(a, b) _ipw_read_reg32(a, b)
232 235
236/* alias for 8-bit indirect read (for SRAM/reg above 4K), with debug wrapper */
233static u8 _ipw_read_reg8(struct ipw_priv *ipw, u32 reg); 237static u8 _ipw_read_reg8(struct ipw_priv *ipw, u32 reg);
234#define ipw_read_reg8(a, b) _ipw_read_reg8(a, b) 238#define ipw_read_reg8(a, b) _ipw_read_reg8(a, b)
235 239
240/* 8-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
236static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value); 241static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value);
237static inline void ipw_write_reg8(struct ipw_priv *a, u32 b, u8 c) 242static inline void ipw_write_reg8(struct ipw_priv *a, u32 b, u8 c)
238{ 243{
@@ -241,6 +246,7 @@ static inline void ipw_write_reg8(struct ipw_priv *a, u32 b, u8 c)
241 _ipw_write_reg8(a, b, c); 246 _ipw_write_reg8(a, b, c);
242} 247}
243 248
249/* 16-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
244static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value); 250static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value);
245static inline void ipw_write_reg16(struct ipw_priv *a, u32 b, u16 c) 251static inline void ipw_write_reg16(struct ipw_priv *a, u32 b, u16 c)
246{ 252{
@@ -249,6 +255,7 @@ static inline void ipw_write_reg16(struct ipw_priv *a, u32 b, u16 c)
249 _ipw_write_reg16(a, b, c); 255 _ipw_write_reg16(a, b, c);
250} 256}
251 257
258/* 32-bit indirect write (for SRAM/reg above 4K), with debug wrapper */
252static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value); 259static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value);
253static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c) 260static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c)
254{ 261{
@@ -257,48 +264,70 @@ static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c)
257 _ipw_write_reg32(a, b, c); 264 _ipw_write_reg32(a, b, c);
258} 265}
259 266
267/* 8-bit direct write (low 4K) */
260#define _ipw_write8(ipw, ofs, val) writeb((val), (ipw)->hw_base + (ofs)) 268#define _ipw_write8(ipw, ofs, val) writeb((val), (ipw)->hw_base + (ofs))
269
270/* 8-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
261#define ipw_write8(ipw, ofs, val) \ 271#define ipw_write8(ipw, ofs, val) \
262 IPW_DEBUG_IO("%s %d: write_direct8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ 272 IPW_DEBUG_IO("%s %d: write_direct8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
263 _ipw_write8(ipw, ofs, val) 273 _ipw_write8(ipw, ofs, val)
264 274
275/* 16-bit direct write (low 4K) */
265#define _ipw_write16(ipw, ofs, val) writew((val), (ipw)->hw_base + (ofs)) 276#define _ipw_write16(ipw, ofs, val) writew((val), (ipw)->hw_base + (ofs))
277
278/* 16-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
266#define ipw_write16(ipw, ofs, val) \ 279#define ipw_write16(ipw, ofs, val) \
267 IPW_DEBUG_IO("%s %d: write_direct16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ 280 IPW_DEBUG_IO("%s %d: write_direct16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
268 _ipw_write16(ipw, ofs, val) 281 _ipw_write16(ipw, ofs, val)
269 282
283/* 32-bit direct write (low 4K) */
270#define _ipw_write32(ipw, ofs, val) writel((val), (ipw)->hw_base + (ofs)) 284#define _ipw_write32(ipw, ofs, val) writel((val), (ipw)->hw_base + (ofs))
285
286/* 32-bit direct write (for low 4K of SRAM/regs), with debug wrapper */
271#define ipw_write32(ipw, ofs, val) \ 287#define ipw_write32(ipw, ofs, val) \
272 IPW_DEBUG_IO("%s %d: write_direct32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ 288 IPW_DEBUG_IO("%s %d: write_direct32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \
273 _ipw_write32(ipw, ofs, val) 289 _ipw_write32(ipw, ofs, val)
274 290
291/* 8-bit direct read (low 4K) */
275#define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs)) 292#define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs))
293
294/* 8-bit direct read (low 4K), with debug wrapper */
276static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) 295static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs)
277{ 296{
278 IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32) (ofs)); 297 IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32) (ofs));
279 return _ipw_read8(ipw, ofs); 298 return _ipw_read8(ipw, ofs);
280} 299}
281 300
301/* alias to 8-bit direct read (low 4K of SRAM/regs), with debug wrapper */
282#define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs) 302#define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs)
283 303
304/* 16-bit direct read (low 4K) */
284#define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs)) 305#define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs))
306
307/* 16-bit direct read (low 4K), with debug wrapper */
285static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) 308static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs)
286{ 309{
287 IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32) (ofs)); 310 IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32) (ofs));
288 return _ipw_read16(ipw, ofs); 311 return _ipw_read16(ipw, ofs);
289} 312}
290 313
314/* alias to 16-bit direct read (low 4K of SRAM/regs), with debug wrapper */
291#define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs) 315#define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs)
292 316
317/* 32-bit direct read (low 4K) */
293#define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs)) 318#define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs))
319
320/* 32-bit direct read (low 4K), with debug wrapper */
294static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) 321static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs)
295{ 322{
296 IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32) (ofs)); 323 IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32) (ofs));
297 return _ipw_read32(ipw, ofs); 324 return _ipw_read32(ipw, ofs);
298} 325}
299 326
327/* alias to 32-bit direct read (low 4K of SRAM/regs), with debug wrapper */
300#define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs) 328#define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs)
301 329
330/* multi-byte read (above 4K), with debug wrapper */
302static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); 331static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int);
303static inline void __ipw_read_indirect(const char *f, int l, 332static inline void __ipw_read_indirect(const char *f, int l,
304 struct ipw_priv *a, u32 b, u8 * c, int d) 333 struct ipw_priv *a, u32 b, u8 * c, int d)
@@ -308,15 +337,17 @@ static inline void __ipw_read_indirect(const char *f, int l,
308 _ipw_read_indirect(a, b, c, d); 337 _ipw_read_indirect(a, b, c, d);
309} 338}
310 339
340/* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */
311#define ipw_read_indirect(a, b, c, d) __ipw_read_indirect(__FILE__, __LINE__, a, b, c, d) 341#define ipw_read_indirect(a, b, c, d) __ipw_read_indirect(__FILE__, __LINE__, a, b, c, d)
312 342
343/* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */
313static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * data, 344static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * data,
314 int num); 345 int num);
315#define ipw_write_indirect(a, b, c, d) \ 346#define ipw_write_indirect(a, b, c, d) \
316 IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ 347 IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \
317 _ipw_write_indirect(a, b, c, d) 348 _ipw_write_indirect(a, b, c, d)
318 349
319/* indirect write s */ 350/* 32-bit indirect write (above 4K) */
320static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value) 351static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value)
321{ 352{
322 IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", priv, reg, value); 353 IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", priv, reg, value);
@@ -324,22 +355,29 @@ static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value)
324 _ipw_write32(priv, IPW_INDIRECT_DATA, value); 355 _ipw_write32(priv, IPW_INDIRECT_DATA, value);
325} 356}
326 357
358/* 8-bit indirect write (above 4K) */
327static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value) 359static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value)
328{ 360{
361 u32 aligned_addr = reg & IPW_INDIRECT_ADDR_MASK; /* dword align */
362 u32 dif_len = reg - aligned_addr;
363
329 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value); 364 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value);
330 _ipw_write32(priv, IPW_INDIRECT_ADDR, reg & IPW_INDIRECT_ADDR_MASK); 365 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr);
331 _ipw_write8(priv, IPW_INDIRECT_DATA, value); 366 _ipw_write8(priv, IPW_INDIRECT_DATA + dif_len, value);
332} 367}
333 368
369/* 16-bit indirect write (above 4K) */
334static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value) 370static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value)
335{ 371{
372 u32 aligned_addr = reg & IPW_INDIRECT_ADDR_MASK; /* dword align */
373 u32 dif_len = (reg - aligned_addr) & (~0x1ul);
374
336 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value); 375 IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value);
337 _ipw_write32(priv, IPW_INDIRECT_ADDR, reg & IPW_INDIRECT_ADDR_MASK); 376 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr);
338 _ipw_write16(priv, IPW_INDIRECT_DATA, value); 377 _ipw_write16(priv, IPW_INDIRECT_DATA + dif_len, value);
339} 378}
340 379
341/* indirect read s */ 380/* 8-bit indirect read (above 4K) */
342
343static u8 _ipw_read_reg8(struct ipw_priv *priv, u32 reg) 381static u8 _ipw_read_reg8(struct ipw_priv *priv, u32 reg)
344{ 382{
345 u32 word; 383 u32 word;
@@ -349,6 +387,7 @@ static u8 _ipw_read_reg8(struct ipw_priv *priv, u32 reg)
349 return (word >> ((reg & 0x3) * 8)) & 0xff; 387 return (word >> ((reg & 0x3) * 8)) & 0xff;
350} 388}
351 389
390/* 32-bit indirect read (above 4K) */
352static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg) 391static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg)
353{ 392{
354 u32 value; 393 u32 value;
@@ -361,11 +400,12 @@ static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg)
361 return value; 400 return value;
362} 401}
363 402
364/* iterative/auto-increment 32 bit reads and writes */ 403/* General purpose, no alignment requirement, iterative (multi-byte) read, */
404/* for area above 1st 4K of SRAM/reg space */
365static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf, 405static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
366 int num) 406 int num)
367{ 407{
368 u32 aligned_addr = addr & IPW_INDIRECT_ADDR_MASK; 408 u32 aligned_addr = addr & IPW_INDIRECT_ADDR_MASK; /* dword align */
369 u32 dif_len = addr - aligned_addr; 409 u32 dif_len = addr - aligned_addr;
370 u32 i; 410 u32 i;
371 411
@@ -375,7 +415,7 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
375 return; 415 return;
376 } 416 }
377 417
378 /* Read the first nibble byte by byte */ 418 /* Read the first dword (or portion) byte by byte */
379 if (unlikely(dif_len)) { 419 if (unlikely(dif_len)) {
380 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr); 420 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr);
381 /* Start reading at aligned_addr + dif_len */ 421 /* Start reading at aligned_addr + dif_len */
@@ -384,11 +424,12 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
384 aligned_addr += 4; 424 aligned_addr += 4;
385 } 425 }
386 426
427 /* Read all of the middle dwords as dwords, with auto-increment */
387 _ipw_write32(priv, IPW_AUTOINC_ADDR, aligned_addr); 428 _ipw_write32(priv, IPW_AUTOINC_ADDR, aligned_addr);
388 for (; num >= 4; buf += 4, aligned_addr += 4, num -= 4) 429 for (; num >= 4; buf += 4, aligned_addr += 4, num -= 4)
389 *(u32 *) buf = _ipw_read32(priv, IPW_AUTOINC_DATA); 430 *(u32 *) buf = _ipw_read32(priv, IPW_AUTOINC_DATA);
390 431
391 /* Copy the last nibble */ 432 /* Read the last dword (or portion) byte by byte */
392 if (unlikely(num)) { 433 if (unlikely(num)) {
393 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr); 434 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr);
394 for (i = 0; num > 0; i++, num--) 435 for (i = 0; num > 0; i++, num--)
@@ -396,10 +437,12 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
396 } 437 }
397} 438}
398 439
440/* General purpose, no alignment requirement, iterative (multi-byte) write, */
441/* for area above 1st 4K of SRAM/reg space */
399static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * buf, 442static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
400 int num) 443 int num)
401{ 444{
402 u32 aligned_addr = addr & IPW_INDIRECT_ADDR_MASK; 445 u32 aligned_addr = addr & IPW_INDIRECT_ADDR_MASK; /* dword align */
403 u32 dif_len = addr - aligned_addr; 446 u32 dif_len = addr - aligned_addr;
404 u32 i; 447 u32 i;
405 448
@@ -409,20 +452,21 @@ static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
409 return; 452 return;
410 } 453 }
411 454
412 /* Write the first nibble byte by byte */ 455 /* Write the first dword (or portion) byte by byte */
413 if (unlikely(dif_len)) { 456 if (unlikely(dif_len)) {
414 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr); 457 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr);
415 /* Start reading at aligned_addr + dif_len */ 458 /* Start writing at aligned_addr + dif_len */
416 for (i = dif_len; ((i < 4) && (num > 0)); i++, num--, buf++) 459 for (i = dif_len; ((i < 4) && (num > 0)); i++, num--, buf++)
417 _ipw_write8(priv, IPW_INDIRECT_DATA + i, *buf); 460 _ipw_write8(priv, IPW_INDIRECT_DATA + i, *buf);
418 aligned_addr += 4; 461 aligned_addr += 4;
419 } 462 }
420 463
464 /* Write all of the middle dwords as dwords, with auto-increment */
421 _ipw_write32(priv, IPW_AUTOINC_ADDR, aligned_addr); 465 _ipw_write32(priv, IPW_AUTOINC_ADDR, aligned_addr);
422 for (; num >= 4; buf += 4, aligned_addr += 4, num -= 4) 466 for (; num >= 4; buf += 4, aligned_addr += 4, num -= 4)
423 _ipw_write32(priv, IPW_AUTOINC_DATA, *(u32 *) buf); 467 _ipw_write32(priv, IPW_AUTOINC_DATA, *(u32 *) buf);
424 468
425 /* Copy the last nibble */ 469 /* Write the last dword (or portion) byte by byte */
426 if (unlikely(num)) { 470 if (unlikely(num)) {
427 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr); 471 _ipw_write32(priv, IPW_INDIRECT_ADDR, aligned_addr);
428 for (i = 0; num > 0; i++, num--, buf++) 472 for (i = 0; num > 0; i++, num--, buf++)
@@ -430,17 +474,21 @@ static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * buf,
430 } 474 }
431} 475}
432 476
477/* General purpose, no alignment requirement, iterative (multi-byte) write, */
478/* for 1st 4K of SRAM/regs space */
433static void ipw_write_direct(struct ipw_priv *priv, u32 addr, void *buf, 479static void ipw_write_direct(struct ipw_priv *priv, u32 addr, void *buf,
434 int num) 480 int num)
435{ 481{
436 memcpy_toio((priv->hw_base + addr), buf, num); 482 memcpy_toio((priv->hw_base + addr), buf, num);
437} 483}
438 484
485/* Set bit(s) in low 4K of SRAM/regs */
439static inline void ipw_set_bit(struct ipw_priv *priv, u32 reg, u32 mask) 486static inline void ipw_set_bit(struct ipw_priv *priv, u32 reg, u32 mask)
440{ 487{
441 ipw_write32(priv, reg, ipw_read32(priv, reg) | mask); 488 ipw_write32(priv, reg, ipw_read32(priv, reg) | mask);
442} 489}
443 490
491/* Clear bit(s) in low 4K of SRAM/regs */
444static inline void ipw_clear_bit(struct ipw_priv *priv, u32 reg, u32 mask) 492static inline void ipw_clear_bit(struct ipw_priv *priv, u32 reg, u32 mask)
445{ 493{
446 ipw_write32(priv, reg, ipw_read32(priv, reg) & ~mask); 494 ipw_write32(priv, reg, ipw_read32(priv, reg) & ~mask);
@@ -701,7 +749,7 @@ static void ipw_init_ordinals(struct ipw_priv *priv)
701 749
702} 750}
703 751
704u32 ipw_register_toggle(u32 reg) 752static u32 ipw_register_toggle(u32 reg)
705{ 753{
706 reg &= ~IPW_START_STANDBY; 754 reg &= ~IPW_START_STANDBY;
707 if (reg & IPW_GATE_ODMA) 755 if (reg & IPW_GATE_ODMA)
@@ -722,11 +770,11 @@ u32 ipw_register_toggle(u32 reg)
722 * - On radio OFF, turn off any LEDs started during radio on 770 * - On radio OFF, turn off any LEDs started during radio on
723 * 771 *
724 */ 772 */
725#define LD_TIME_LINK_ON 300 773#define LD_TIME_LINK_ON msecs_to_jiffies(300)
726#define LD_TIME_LINK_OFF 2700 774#define LD_TIME_LINK_OFF msecs_to_jiffies(2700)
727#define LD_TIME_ACT_ON 250 775#define LD_TIME_ACT_ON msecs_to_jiffies(250)
728 776
729void ipw_led_link_on(struct ipw_priv *priv) 777static void ipw_led_link_on(struct ipw_priv *priv)
730{ 778{
731 unsigned long flags; 779 unsigned long flags;
732 u32 led; 780 u32 led;
@@ -764,12 +812,12 @@ void ipw_led_link_on(struct ipw_priv *priv)
764static void ipw_bg_led_link_on(void *data) 812static void ipw_bg_led_link_on(void *data)
765{ 813{
766 struct ipw_priv *priv = data; 814 struct ipw_priv *priv = data;
767 down(&priv->sem); 815 mutex_lock(&priv->mutex);
768 ipw_led_link_on(data); 816 ipw_led_link_on(data);
769 up(&priv->sem); 817 mutex_unlock(&priv->mutex);
770} 818}
771 819
772void ipw_led_link_off(struct ipw_priv *priv) 820static void ipw_led_link_off(struct ipw_priv *priv)
773{ 821{
774 unsigned long flags; 822 unsigned long flags;
775 u32 led; 823 u32 led;
@@ -808,9 +856,9 @@ void ipw_led_link_off(struct ipw_priv *priv)
808static void ipw_bg_led_link_off(void *data) 856static void ipw_bg_led_link_off(void *data)
809{ 857{
810 struct ipw_priv *priv = data; 858 struct ipw_priv *priv = data;
811 down(&priv->sem); 859 mutex_lock(&priv->mutex);
812 ipw_led_link_off(data); 860 ipw_led_link_off(data);
813 up(&priv->sem); 861 mutex_unlock(&priv->mutex);
814} 862}
815 863
816static void __ipw_led_activity_on(struct ipw_priv *priv) 864static void __ipw_led_activity_on(struct ipw_priv *priv)
@@ -847,6 +895,7 @@ static void __ipw_led_activity_on(struct ipw_priv *priv)
847 } 895 }
848} 896}
849 897
898#if 0
850void ipw_led_activity_on(struct ipw_priv *priv) 899void ipw_led_activity_on(struct ipw_priv *priv)
851{ 900{
852 unsigned long flags; 901 unsigned long flags;
@@ -854,8 +903,9 @@ void ipw_led_activity_on(struct ipw_priv *priv)
854 __ipw_led_activity_on(priv); 903 __ipw_led_activity_on(priv);
855 spin_unlock_irqrestore(&priv->lock, flags); 904 spin_unlock_irqrestore(&priv->lock, flags);
856} 905}
906#endif /* 0 */
857 907
858void ipw_led_activity_off(struct ipw_priv *priv) 908static void ipw_led_activity_off(struct ipw_priv *priv)
859{ 909{
860 unsigned long flags; 910 unsigned long flags;
861 u32 led; 911 u32 led;
@@ -885,12 +935,12 @@ void ipw_led_activity_off(struct ipw_priv *priv)
885static void ipw_bg_led_activity_off(void *data) 935static void ipw_bg_led_activity_off(void *data)
886{ 936{
887 struct ipw_priv *priv = data; 937 struct ipw_priv *priv = data;
888 down(&priv->sem); 938 mutex_lock(&priv->mutex);
889 ipw_led_activity_off(data); 939 ipw_led_activity_off(data);
890 up(&priv->sem); 940 mutex_unlock(&priv->mutex);
891} 941}
892 942
893void ipw_led_band_on(struct ipw_priv *priv) 943static void ipw_led_band_on(struct ipw_priv *priv)
894{ 944{
895 unsigned long flags; 945 unsigned long flags;
896 u32 led; 946 u32 led;
@@ -925,7 +975,7 @@ void ipw_led_band_on(struct ipw_priv *priv)
925 spin_unlock_irqrestore(&priv->lock, flags); 975 spin_unlock_irqrestore(&priv->lock, flags);
926} 976}
927 977
928void ipw_led_band_off(struct ipw_priv *priv) 978static void ipw_led_band_off(struct ipw_priv *priv)
929{ 979{
930 unsigned long flags; 980 unsigned long flags;
931 u32 led; 981 u32 led;
@@ -948,24 +998,24 @@ void ipw_led_band_off(struct ipw_priv *priv)
948 spin_unlock_irqrestore(&priv->lock, flags); 998 spin_unlock_irqrestore(&priv->lock, flags);
949} 999}
950 1000
951void ipw_led_radio_on(struct ipw_priv *priv) 1001static void ipw_led_radio_on(struct ipw_priv *priv)
952{ 1002{
953 ipw_led_link_on(priv); 1003 ipw_led_link_on(priv);
954} 1004}
955 1005
956void ipw_led_radio_off(struct ipw_priv *priv) 1006static void ipw_led_radio_off(struct ipw_priv *priv)
957{ 1007{
958 ipw_led_activity_off(priv); 1008 ipw_led_activity_off(priv);
959 ipw_led_link_off(priv); 1009 ipw_led_link_off(priv);
960} 1010}
961 1011
962void ipw_led_link_up(struct ipw_priv *priv) 1012static void ipw_led_link_up(struct ipw_priv *priv)
963{ 1013{
964 /* Set the Link Led on for all nic types */ 1014 /* Set the Link Led on for all nic types */
965 ipw_led_link_on(priv); 1015 ipw_led_link_on(priv);
966} 1016}
967 1017
968void ipw_led_link_down(struct ipw_priv *priv) 1018static void ipw_led_link_down(struct ipw_priv *priv)
969{ 1019{
970 ipw_led_activity_off(priv); 1020 ipw_led_activity_off(priv);
971 ipw_led_link_off(priv); 1021 ipw_led_link_off(priv);
@@ -974,7 +1024,7 @@ void ipw_led_link_down(struct ipw_priv *priv)
974 ipw_led_radio_off(priv); 1024 ipw_led_radio_off(priv);
975} 1025}
976 1026
977void ipw_led_init(struct ipw_priv *priv) 1027static void ipw_led_init(struct ipw_priv *priv)
978{ 1028{
979 priv->nic_type = priv->eeprom[EEPROM_NIC_TYPE]; 1029 priv->nic_type = priv->eeprom[EEPROM_NIC_TYPE];
980 1030
@@ -1025,7 +1075,7 @@ void ipw_led_init(struct ipw_priv *priv)
1025 } 1075 }
1026} 1076}
1027 1077
1028void ipw_led_shutdown(struct ipw_priv *priv) 1078static void ipw_led_shutdown(struct ipw_priv *priv)
1029{ 1079{
1030 ipw_led_activity_off(priv); 1080 ipw_led_activity_off(priv);
1031 ipw_led_link_off(priv); 1081 ipw_led_link_off(priv);
@@ -1074,6 +1124,7 @@ static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO,
1074 1124
1075static inline u32 ipw_get_event_log_len(struct ipw_priv *priv) 1125static inline u32 ipw_get_event_log_len(struct ipw_priv *priv)
1076{ 1126{
1127 /* length = 1st dword in log */
1077 return ipw_read_reg32(priv, ipw_read32(priv, IPW_EVENT_LOG)); 1128 return ipw_read_reg32(priv, ipw_read32(priv, IPW_EVENT_LOG));
1078} 1129}
1079 1130
@@ -1870,7 +1921,8 @@ static char *get_cmd_string(u8 cmd)
1870} 1921}
1871 1922
1872#define HOST_COMPLETE_TIMEOUT HZ 1923#define HOST_COMPLETE_TIMEOUT HZ
1873static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd) 1924
1925static int __ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
1874{ 1926{
1875 int rc = 0; 1927 int rc = 0;
1876 unsigned long flags; 1928 unsigned long flags;
@@ -1897,9 +1949,15 @@ static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
1897 IPW_DEBUG_HC("%s command (#%d) %d bytes: 0x%08X\n", 1949 IPW_DEBUG_HC("%s command (#%d) %d bytes: 0x%08X\n",
1898 get_cmd_string(cmd->cmd), cmd->cmd, cmd->len, 1950 get_cmd_string(cmd->cmd), cmd->cmd, cmd->len,
1899 priv->status); 1951 priv->status);
1900 printk_buf(IPW_DL_HOST_COMMAND, (u8 *) cmd->param, cmd->len);
1901 1952
1902 rc = ipw_queue_tx_hcmd(priv, cmd->cmd, &cmd->param, cmd->len, 0); 1953#ifndef DEBUG_CMD_WEP_KEY
1954 if (cmd->cmd == IPW_CMD_WEP_KEY)
1955 IPW_DEBUG_HC("WEP_KEY command masked out for secure.\n");
1956 else
1957#endif
1958 printk_buf(IPW_DL_HOST_COMMAND, (u8 *) cmd->param, cmd->len);
1959
1960 rc = ipw_queue_tx_hcmd(priv, cmd->cmd, cmd->param, cmd->len, 0);
1903 if (rc) { 1961 if (rc) {
1904 priv->status &= ~STATUS_HCMD_ACTIVE; 1962 priv->status &= ~STATUS_HCMD_ACTIVE;
1905 IPW_ERROR("Failed to send %s: Reason %d\n", 1963 IPW_ERROR("Failed to send %s: Reason %d\n",
@@ -1942,61 +2000,62 @@ static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
1942 return rc; 2000 return rc;
1943} 2001}
1944 2002
1945static int ipw_send_host_complete(struct ipw_priv *priv) 2003static int ipw_send_cmd_simple(struct ipw_priv *priv, u8 command)
1946{ 2004{
1947 struct host_cmd cmd = { 2005 struct host_cmd cmd = {
1948 .cmd = IPW_CMD_HOST_COMPLETE, 2006 .cmd = command,
1949 .len = 0
1950 }; 2007 };
1951 2008
2009 return __ipw_send_cmd(priv, &cmd);
2010}
2011
2012static int ipw_send_cmd_pdu(struct ipw_priv *priv, u8 command, u8 len,
2013 void *data)
2014{
2015 struct host_cmd cmd = {
2016 .cmd = command,
2017 .len = len,
2018 .param = data,
2019 };
2020
2021 return __ipw_send_cmd(priv, &cmd);
2022}
2023
2024static int ipw_send_host_complete(struct ipw_priv *priv)
2025{
1952 if (!priv) { 2026 if (!priv) {
1953 IPW_ERROR("Invalid args\n"); 2027 IPW_ERROR("Invalid args\n");
1954 return -1; 2028 return -1;
1955 } 2029 }
1956 2030
1957 return ipw_send_cmd(priv, &cmd); 2031 return ipw_send_cmd_simple(priv, IPW_CMD_HOST_COMPLETE);
1958} 2032}
1959 2033
1960static int ipw_send_system_config(struct ipw_priv *priv, 2034static int ipw_send_system_config(struct ipw_priv *priv,
1961 struct ipw_sys_config *config) 2035 struct ipw_sys_config *config)
1962{ 2036{
1963 struct host_cmd cmd = {
1964 .cmd = IPW_CMD_SYSTEM_CONFIG,
1965 .len = sizeof(*config)
1966 };
1967
1968 if (!priv || !config) { 2037 if (!priv || !config) {
1969 IPW_ERROR("Invalid args\n"); 2038 IPW_ERROR("Invalid args\n");
1970 return -1; 2039 return -1;
1971 } 2040 }
1972 2041
1973 memcpy(cmd.param, config, sizeof(*config)); 2042 return ipw_send_cmd_pdu(priv, IPW_CMD_SYSTEM_CONFIG, sizeof(*config),
1974 return ipw_send_cmd(priv, &cmd); 2043 config);
1975} 2044}
1976 2045
1977static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len) 2046static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len)
1978{ 2047{
1979 struct host_cmd cmd = {
1980 .cmd = IPW_CMD_SSID,
1981 .len = min(len, IW_ESSID_MAX_SIZE)
1982 };
1983
1984 if (!priv || !ssid) { 2048 if (!priv || !ssid) {
1985 IPW_ERROR("Invalid args\n"); 2049 IPW_ERROR("Invalid args\n");
1986 return -1; 2050 return -1;
1987 } 2051 }
1988 2052
1989 memcpy(cmd.param, ssid, cmd.len); 2053 return ipw_send_cmd_pdu(priv, IPW_CMD_SSID, min(len, IW_ESSID_MAX_SIZE),
1990 return ipw_send_cmd(priv, &cmd); 2054 ssid);
1991} 2055}
1992 2056
1993static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac) 2057static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac)
1994{ 2058{
1995 struct host_cmd cmd = {
1996 .cmd = IPW_CMD_ADAPTER_ADDRESS,
1997 .len = ETH_ALEN
1998 };
1999
2000 if (!priv || !mac) { 2059 if (!priv || !mac) {
2001 IPW_ERROR("Invalid args\n"); 2060 IPW_ERROR("Invalid args\n");
2002 return -1; 2061 return -1;
@@ -2005,8 +2064,7 @@ static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac)
2005 IPW_DEBUG_INFO("%s: Setting MAC to " MAC_FMT "\n", 2064 IPW_DEBUG_INFO("%s: Setting MAC to " MAC_FMT "\n",
2006 priv->net_dev->name, MAC_ARG(mac)); 2065 priv->net_dev->name, MAC_ARG(mac));
2007 2066
2008 memcpy(cmd.param, mac, ETH_ALEN); 2067 return ipw_send_cmd_pdu(priv, IPW_CMD_ADAPTER_ADDRESS, ETH_ALEN, mac);
2009 return ipw_send_cmd(priv, &cmd);
2010} 2068}
2011 2069
2012/* 2070/*
@@ -2036,9 +2094,9 @@ static void ipw_adapter_restart(void *adapter)
2036static void ipw_bg_adapter_restart(void *data) 2094static void ipw_bg_adapter_restart(void *data)
2037{ 2095{
2038 struct ipw_priv *priv = data; 2096 struct ipw_priv *priv = data;
2039 down(&priv->sem); 2097 mutex_lock(&priv->mutex);
2040 ipw_adapter_restart(data); 2098 ipw_adapter_restart(data);
2041 up(&priv->sem); 2099 mutex_unlock(&priv->mutex);
2042} 2100}
2043 2101
2044#define IPW_SCAN_CHECK_WATCHDOG (5 * HZ) 2102#define IPW_SCAN_CHECK_WATCHDOG (5 * HZ)
@@ -2048,8 +2106,8 @@ static void ipw_scan_check(void *data)
2048 struct ipw_priv *priv = data; 2106 struct ipw_priv *priv = data;
2049 if (priv->status & (STATUS_SCANNING | STATUS_SCAN_ABORTING)) { 2107 if (priv->status & (STATUS_SCANNING | STATUS_SCAN_ABORTING)) {
2050 IPW_DEBUG_SCAN("Scan completion watchdog resetting " 2108 IPW_DEBUG_SCAN("Scan completion watchdog resetting "
2051 "adapter (%dms).\n", 2109 "adapter after (%dms).\n",
2052 IPW_SCAN_CHECK_WATCHDOG / 100); 2110 jiffies_to_msecs(IPW_SCAN_CHECK_WATCHDOG));
2053 queue_work(priv->workqueue, &priv->adapter_restart); 2111 queue_work(priv->workqueue, &priv->adapter_restart);
2054 } 2112 }
2055} 2113}
@@ -2057,59 +2115,48 @@ static void ipw_scan_check(void *data)
2057static void ipw_bg_scan_check(void *data) 2115static void ipw_bg_scan_check(void *data)
2058{ 2116{
2059 struct ipw_priv *priv = data; 2117 struct ipw_priv *priv = data;
2060 down(&priv->sem); 2118 mutex_lock(&priv->mutex);
2061 ipw_scan_check(data); 2119 ipw_scan_check(data);
2062 up(&priv->sem); 2120 mutex_unlock(&priv->mutex);
2063} 2121}
2064 2122
2065static int ipw_send_scan_request_ext(struct ipw_priv *priv, 2123static int ipw_send_scan_request_ext(struct ipw_priv *priv,
2066 struct ipw_scan_request_ext *request) 2124 struct ipw_scan_request_ext *request)
2067{ 2125{
2068 struct host_cmd cmd = { 2126 return ipw_send_cmd_pdu(priv, IPW_CMD_SCAN_REQUEST_EXT,
2069 .cmd = IPW_CMD_SCAN_REQUEST_EXT, 2127 sizeof(*request), request);
2070 .len = sizeof(*request)
2071 };
2072
2073 memcpy(cmd.param, request, sizeof(*request));
2074 return ipw_send_cmd(priv, &cmd);
2075} 2128}
2076 2129
2077static int ipw_send_scan_abort(struct ipw_priv *priv) 2130static int ipw_send_scan_abort(struct ipw_priv *priv)
2078{ 2131{
2079 struct host_cmd cmd = {
2080 .cmd = IPW_CMD_SCAN_ABORT,
2081 .len = 0
2082 };
2083
2084 if (!priv) { 2132 if (!priv) {
2085 IPW_ERROR("Invalid args\n"); 2133 IPW_ERROR("Invalid args\n");
2086 return -1; 2134 return -1;
2087 } 2135 }
2088 2136
2089 return ipw_send_cmd(priv, &cmd); 2137 return ipw_send_cmd_simple(priv, IPW_CMD_SCAN_ABORT);
2090} 2138}
2091 2139
2092static int ipw_set_sensitivity(struct ipw_priv *priv, u16 sens) 2140static int ipw_set_sensitivity(struct ipw_priv *priv, u16 sens)
2093{ 2141{
2094 struct host_cmd cmd = { 2142 struct ipw_sensitivity_calib calib = {
2095 .cmd = IPW_CMD_SENSITIVITY_CALIB, 2143 .beacon_rssi_raw = sens,
2096 .len = sizeof(struct ipw_sensitivity_calib)
2097 }; 2144 };
2098 struct ipw_sensitivity_calib *calib = (struct ipw_sensitivity_calib *) 2145
2099 &cmd.param; 2146 return ipw_send_cmd_pdu(priv, IPW_CMD_SENSITIVITY_CALIB, sizeof(calib),
2100 calib->beacon_rssi_raw = sens; 2147 &calib);
2101 return ipw_send_cmd(priv, &cmd);
2102} 2148}
2103 2149
2104static int ipw_send_associate(struct ipw_priv *priv, 2150static int ipw_send_associate(struct ipw_priv *priv,
2105 struct ipw_associate *associate) 2151 struct ipw_associate *associate)
2106{ 2152{
2107 struct host_cmd cmd = {
2108 .cmd = IPW_CMD_ASSOCIATE,
2109 .len = sizeof(*associate)
2110 };
2111
2112 struct ipw_associate tmp_associate; 2153 struct ipw_associate tmp_associate;
2154
2155 if (!priv || !associate) {
2156 IPW_ERROR("Invalid args\n");
2157 return -1;
2158 }
2159
2113 memcpy(&tmp_associate, associate, sizeof(*associate)); 2160 memcpy(&tmp_associate, associate, sizeof(*associate));
2114 tmp_associate.policy_support = 2161 tmp_associate.policy_support =
2115 cpu_to_le16(tmp_associate.policy_support); 2162 cpu_to_le16(tmp_associate.policy_support);
@@ -2122,80 +2169,55 @@ static int ipw_send_associate(struct ipw_priv *priv,
2122 cpu_to_le16(tmp_associate.beacon_interval); 2169 cpu_to_le16(tmp_associate.beacon_interval);
2123 tmp_associate.atim_window = cpu_to_le16(tmp_associate.atim_window); 2170 tmp_associate.atim_window = cpu_to_le16(tmp_associate.atim_window);
2124 2171
2125 if (!priv || !associate) { 2172 return ipw_send_cmd_pdu(priv, IPW_CMD_ASSOCIATE, sizeof(tmp_associate),
2126 IPW_ERROR("Invalid args\n"); 2173 &tmp_associate);
2127 return -1;
2128 }
2129
2130 memcpy(cmd.param, &tmp_associate, sizeof(*associate));
2131 return ipw_send_cmd(priv, &cmd);
2132} 2174}
2133 2175
2134static int ipw_send_supported_rates(struct ipw_priv *priv, 2176static int ipw_send_supported_rates(struct ipw_priv *priv,
2135 struct ipw_supported_rates *rates) 2177 struct ipw_supported_rates *rates)
2136{ 2178{
2137 struct host_cmd cmd = {
2138 .cmd = IPW_CMD_SUPPORTED_RATES,
2139 .len = sizeof(*rates)
2140 };
2141
2142 if (!priv || !rates) { 2179 if (!priv || !rates) {
2143 IPW_ERROR("Invalid args\n"); 2180 IPW_ERROR("Invalid args\n");
2144 return -1; 2181 return -1;
2145 } 2182 }
2146 2183
2147 memcpy(cmd.param, rates, sizeof(*rates)); 2184 return ipw_send_cmd_pdu(priv, IPW_CMD_SUPPORTED_RATES, sizeof(*rates),
2148 return ipw_send_cmd(priv, &cmd); 2185 rates);
2149} 2186}
2150 2187
2151static int ipw_set_random_seed(struct ipw_priv *priv) 2188static int ipw_set_random_seed(struct ipw_priv *priv)
2152{ 2189{
2153 struct host_cmd cmd = { 2190 u32 val;
2154 .cmd = IPW_CMD_SEED_NUMBER,
2155 .len = sizeof(u32)
2156 };
2157 2191
2158 if (!priv) { 2192 if (!priv) {
2159 IPW_ERROR("Invalid args\n"); 2193 IPW_ERROR("Invalid args\n");
2160 return -1; 2194 return -1;
2161 } 2195 }
2162 2196
2163 get_random_bytes(&cmd.param, sizeof(u32)); 2197 get_random_bytes(&val, sizeof(val));
2164 2198
2165 return ipw_send_cmd(priv, &cmd); 2199 return ipw_send_cmd_pdu(priv, IPW_CMD_SEED_NUMBER, sizeof(val), &val);
2166} 2200}
2167 2201
2168static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off) 2202static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off)
2169{ 2203{
2170 struct host_cmd cmd = {
2171 .cmd = IPW_CMD_CARD_DISABLE,
2172 .len = sizeof(u32)
2173 };
2174
2175 if (!priv) { 2204 if (!priv) {
2176 IPW_ERROR("Invalid args\n"); 2205 IPW_ERROR("Invalid args\n");
2177 return -1; 2206 return -1;
2178 } 2207 }
2179 2208
2180 *((u32 *) & cmd.param) = phy_off; 2209 return ipw_send_cmd_pdu(priv, IPW_CMD_CARD_DISABLE, sizeof(phy_off),
2181 2210 &phy_off);
2182 return ipw_send_cmd(priv, &cmd);
2183} 2211}
2184 2212
2185static int ipw_send_tx_power(struct ipw_priv *priv, struct ipw_tx_power *power) 2213static int ipw_send_tx_power(struct ipw_priv *priv, struct ipw_tx_power *power)
2186{ 2214{
2187 struct host_cmd cmd = {
2188 .cmd = IPW_CMD_TX_POWER,
2189 .len = sizeof(*power)
2190 };
2191
2192 if (!priv || !power) { 2215 if (!priv || !power) {
2193 IPW_ERROR("Invalid args\n"); 2216 IPW_ERROR("Invalid args\n");
2194 return -1; 2217 return -1;
2195 } 2218 }
2196 2219
2197 memcpy(cmd.param, power, sizeof(*power)); 2220 return ipw_send_cmd_pdu(priv, IPW_CMD_TX_POWER, sizeof(*power), power);
2198 return ipw_send_cmd(priv, &cmd);
2199} 2221}
2200 2222
2201static int ipw_set_tx_power(struct ipw_priv *priv) 2223static int ipw_set_tx_power(struct ipw_priv *priv)
@@ -2247,18 +2269,14 @@ static int ipw_send_rts_threshold(struct ipw_priv *priv, u16 rts)
2247 struct ipw_rts_threshold rts_threshold = { 2269 struct ipw_rts_threshold rts_threshold = {
2248 .rts_threshold = rts, 2270 .rts_threshold = rts,
2249 }; 2271 };
2250 struct host_cmd cmd = {
2251 .cmd = IPW_CMD_RTS_THRESHOLD,
2252 .len = sizeof(rts_threshold)
2253 };
2254 2272
2255 if (!priv) { 2273 if (!priv) {
2256 IPW_ERROR("Invalid args\n"); 2274 IPW_ERROR("Invalid args\n");
2257 return -1; 2275 return -1;
2258 } 2276 }
2259 2277
2260 memcpy(cmd.param, &rts_threshold, sizeof(rts_threshold)); 2278 return ipw_send_cmd_pdu(priv, IPW_CMD_RTS_THRESHOLD,
2261 return ipw_send_cmd(priv, &cmd); 2279 sizeof(rts_threshold), &rts_threshold);
2262} 2280}
2263 2281
2264static int ipw_send_frag_threshold(struct ipw_priv *priv, u16 frag) 2282static int ipw_send_frag_threshold(struct ipw_priv *priv, u16 frag)
@@ -2266,27 +2284,19 @@ static int ipw_send_frag_threshold(struct ipw_priv *priv, u16 frag)
2266 struct ipw_frag_threshold frag_threshold = { 2284 struct ipw_frag_threshold frag_threshold = {
2267 .frag_threshold = frag, 2285 .frag_threshold = frag,
2268 }; 2286 };
2269 struct host_cmd cmd = {
2270 .cmd = IPW_CMD_FRAG_THRESHOLD,
2271 .len = sizeof(frag_threshold)
2272 };
2273 2287
2274 if (!priv) { 2288 if (!priv) {
2275 IPW_ERROR("Invalid args\n"); 2289 IPW_ERROR("Invalid args\n");
2276 return -1; 2290 return -1;
2277 } 2291 }
2278 2292
2279 memcpy(cmd.param, &frag_threshold, sizeof(frag_threshold)); 2293 return ipw_send_cmd_pdu(priv, IPW_CMD_FRAG_THRESHOLD,
2280 return ipw_send_cmd(priv, &cmd); 2294 sizeof(frag_threshold), &frag_threshold);
2281} 2295}
2282 2296
2283static int ipw_send_power_mode(struct ipw_priv *priv, u32 mode) 2297static int ipw_send_power_mode(struct ipw_priv *priv, u32 mode)
2284{ 2298{
2285 struct host_cmd cmd = { 2299 u32 param;
2286 .cmd = IPW_CMD_POWER_MODE,
2287 .len = sizeof(u32)
2288 };
2289 u32 *param = (u32 *) (&cmd.param);
2290 2300
2291 if (!priv) { 2301 if (!priv) {
2292 IPW_ERROR("Invalid args\n"); 2302 IPW_ERROR("Invalid args\n");
@@ -2297,17 +2307,18 @@ static int ipw_send_power_mode(struct ipw_priv *priv, u32 mode)
2297 * level */ 2307 * level */
2298 switch (mode) { 2308 switch (mode) {
2299 case IPW_POWER_BATTERY: 2309 case IPW_POWER_BATTERY:
2300 *param = IPW_POWER_INDEX_3; 2310 param = IPW_POWER_INDEX_3;
2301 break; 2311 break;
2302 case IPW_POWER_AC: 2312 case IPW_POWER_AC:
2303 *param = IPW_POWER_MODE_CAM; 2313 param = IPW_POWER_MODE_CAM;
2304 break; 2314 break;
2305 default: 2315 default:
2306 *param = mode; 2316 param = mode;
2307 break; 2317 break;
2308 } 2318 }
2309 2319
2310 return ipw_send_cmd(priv, &cmd); 2320 return ipw_send_cmd_pdu(priv, IPW_CMD_POWER_MODE, sizeof(param),
2321 &param);
2311} 2322}
2312 2323
2313static int ipw_send_retry_limit(struct ipw_priv *priv, u8 slimit, u8 llimit) 2324static int ipw_send_retry_limit(struct ipw_priv *priv, u8 slimit, u8 llimit)
@@ -2316,18 +2327,14 @@ static int ipw_send_retry_limit(struct ipw_priv *priv, u8 slimit, u8 llimit)
2316 .short_retry_limit = slimit, 2327 .short_retry_limit = slimit,
2317 .long_retry_limit = llimit 2328 .long_retry_limit = llimit
2318 }; 2329 };
2319 struct host_cmd cmd = {
2320 .cmd = IPW_CMD_RETRY_LIMIT,
2321 .len = sizeof(retry_limit)
2322 };
2323 2330
2324 if (!priv) { 2331 if (!priv) {
2325 IPW_ERROR("Invalid args\n"); 2332 IPW_ERROR("Invalid args\n");
2326 return -1; 2333 return -1;
2327 } 2334 }
2328 2335
2329 memcpy(cmd.param, &retry_limit, sizeof(retry_limit)); 2336 return ipw_send_cmd_pdu(priv, IPW_CMD_RETRY_LIMIT, sizeof(retry_limit),
2330 return ipw_send_cmd(priv, &cmd); 2337 &retry_limit);
2331} 2338}
2332 2339
2333/* 2340/*
@@ -2454,7 +2461,7 @@ static void ipw_eeprom_init_sram(struct ipw_priv *priv)
2454 /* 2461 /*
2455 If the data looks correct, then copy it to our private 2462 If the data looks correct, then copy it to our private
2456 copy. Otherwise let the firmware know to perform the operation 2463 copy. Otherwise let the firmware know to perform the operation
2457 on it's own 2464 on its own.
2458 */ 2465 */
2459 if (priv->eeprom[EEPROM_VERSION] != 0) { 2466 if (priv->eeprom[EEPROM_VERSION] != 0) {
2460 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n"); 2467 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n");
@@ -2707,22 +2714,25 @@ static int ipw_fw_dma_add_buffer(struct ipw_priv *priv,
2707 2714
2708static int ipw_fw_dma_wait(struct ipw_priv *priv) 2715static int ipw_fw_dma_wait(struct ipw_priv *priv)
2709{ 2716{
2710 u32 current_index = 0; 2717 u32 current_index = 0, previous_index;
2711 u32 watchdog = 0; 2718 u32 watchdog = 0;
2712 2719
2713 IPW_DEBUG_FW(">> : \n"); 2720 IPW_DEBUG_FW(">> : \n");
2714 2721
2715 current_index = ipw_fw_dma_command_block_index(priv); 2722 current_index = ipw_fw_dma_command_block_index(priv);
2716 IPW_DEBUG_FW_INFO("sram_desc.last_cb_index:0x%8X\n", 2723 IPW_DEBUG_FW_INFO("sram_desc.last_cb_index:0x%08X\n",
2717 (int)priv->sram_desc.last_cb_index); 2724 (int)priv->sram_desc.last_cb_index);
2718 2725
2719 while (current_index < priv->sram_desc.last_cb_index) { 2726 while (current_index < priv->sram_desc.last_cb_index) {
2720 udelay(50); 2727 udelay(50);
2728 previous_index = current_index;
2721 current_index = ipw_fw_dma_command_block_index(priv); 2729 current_index = ipw_fw_dma_command_block_index(priv);
2722 2730
2723 watchdog++; 2731 if (previous_index < current_index) {
2724 2732 watchdog = 0;
2725 if (watchdog > 400) { 2733 continue;
2734 }
2735 if (++watchdog > 400) {
2726 IPW_DEBUG_FW_INFO("Timeout\n"); 2736 IPW_DEBUG_FW_INFO("Timeout\n");
2727 ipw_fw_dma_dump_command_block(priv); 2737 ipw_fw_dma_dump_command_block(priv);
2728 ipw_fw_dma_abort(priv); 2738 ipw_fw_dma_abort(priv);
@@ -2772,6 +2782,7 @@ static inline int ipw_alive(struct ipw_priv *priv)
2772 return ipw_read32(priv, 0x90) == 0xd55555d5; 2782 return ipw_read32(priv, 0x90) == 0xd55555d5;
2773} 2783}
2774 2784
2785/* timeout in msec, attempted in 10-msec quanta */
2775static int ipw_poll_bit(struct ipw_priv *priv, u32 addr, u32 mask, 2786static int ipw_poll_bit(struct ipw_priv *priv, u32 addr, u32 mask,
2776 int timeout) 2787 int timeout)
2777{ 2788{
@@ -2800,10 +2811,11 @@ static int ipw_stop_master(struct ipw_priv *priv)
2800 /* stop master. typical delay - 0 */ 2811 /* stop master. typical delay - 0 */
2801 ipw_set_bit(priv, IPW_RESET_REG, IPW_RESET_REG_STOP_MASTER); 2812 ipw_set_bit(priv, IPW_RESET_REG, IPW_RESET_REG_STOP_MASTER);
2802 2813
2814 /* timeout is in msec, polled in 10-msec quanta */
2803 rc = ipw_poll_bit(priv, IPW_RESET_REG, 2815 rc = ipw_poll_bit(priv, IPW_RESET_REG,
2804 IPW_RESET_REG_MASTER_DISABLED, 100); 2816 IPW_RESET_REG_MASTER_DISABLED, 100);
2805 if (rc < 0) { 2817 if (rc < 0) {
2806 IPW_ERROR("stop master failed in 10ms\n"); 2818 IPW_ERROR("wait for stop master failed after 100ms\n");
2807 return -1; 2819 return -1;
2808 } 2820 }
2809 2821
@@ -2890,8 +2902,8 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len)
2890 mdelay(1); 2902 mdelay(1);
2891 2903
2892 /* enable ucode store */ 2904 /* enable ucode store */
2893 ipw_write_reg8(priv, DINO_CONTROL_REG, 0x0); 2905 ipw_write_reg8(priv, IPW_BASEBAND_CONTROL_STATUS, 0x0);
2894 ipw_write_reg8(priv, DINO_CONTROL_REG, DINO_ENABLE_CS); 2906 ipw_write_reg8(priv, IPW_BASEBAND_CONTROL_STATUS, DINO_ENABLE_CS);
2895 mdelay(1); 2907 mdelay(1);
2896 2908
2897 /* write ucode */ 2909 /* write ucode */
@@ -3036,7 +3048,7 @@ static int ipw_stop_nic(struct ipw_priv *priv)
3036 rc = ipw_poll_bit(priv, IPW_RESET_REG, 3048 rc = ipw_poll_bit(priv, IPW_RESET_REG,
3037 IPW_RESET_REG_MASTER_DISABLED, 500); 3049 IPW_RESET_REG_MASTER_DISABLED, 500);
3038 if (rc < 0) { 3050 if (rc < 0) {
3039 IPW_ERROR("wait for reg master disabled failed\n"); 3051 IPW_ERROR("wait for reg master disabled failed after 500ms\n");
3040 return rc; 3052 return rc;
3041 } 3053 }
3042 3054
@@ -3209,55 +3221,31 @@ static int ipw_load(struct ipw_priv *priv)
3209 const struct firmware *firmware = NULL; 3221 const struct firmware *firmware = NULL;
3210 const struct firmware *ucode = NULL; 3222 const struct firmware *ucode = NULL;
3211#endif 3223#endif
3224 char *ucode_name;
3225 char *fw_name;
3212 int rc = 0, retries = 3; 3226 int rc = 0, retries = 3;
3213 3227
3214#ifdef CONFIG_PM 3228 switch (priv->ieee->iw_mode) {
3215 if (!fw_loaded) { 3229 case IW_MODE_ADHOC:
3216#endif 3230 ucode_name = IPW_FW_NAME("ibss_ucode");
3217 rc = ipw_get_fw(priv, &bootfw, IPW_FW_NAME("boot")); 3231 fw_name = IPW_FW_NAME("ibss");
3218 if (rc) 3232 break;
3219 goto error;
3220
3221 switch (priv->ieee->iw_mode) {
3222 case IW_MODE_ADHOC:
3223 rc = ipw_get_fw(priv, &ucode,
3224 IPW_FW_NAME("ibss_ucode"));
3225 if (rc)
3226 goto error;
3227
3228 rc = ipw_get_fw(priv, &firmware, IPW_FW_NAME("ibss"));
3229 break;
3230
3231#ifdef CONFIG_IPW2200_MONITOR 3233#ifdef CONFIG_IPW2200_MONITOR
3232 case IW_MODE_MONITOR: 3234 case IW_MODE_MONITOR:
3233 rc = ipw_get_fw(priv, &ucode, 3235 ucode_name = IPW_FW_NAME("sniffer_ucode");
3234 IPW_FW_NAME("sniffer_ucode")); 3236 fw_name = IPW_FW_NAME("sniffer");
3235 if (rc) 3237 break;
3236 goto error;
3237
3238 rc = ipw_get_fw(priv, &firmware,
3239 IPW_FW_NAME("sniffer"));
3240 break;
3241#endif 3238#endif
3242 case IW_MODE_INFRA: 3239 case IW_MODE_INFRA:
3243 rc = ipw_get_fw(priv, &ucode, IPW_FW_NAME("bss_ucode")); 3240 ucode_name = IPW_FW_NAME("bss_ucode");
3244 if (rc) 3241 fw_name = IPW_FW_NAME("bss");
3245 goto error; 3242 break;
3246 3243 default:
3247 rc = ipw_get_fw(priv, &firmware, IPW_FW_NAME("bss")); 3244 rc = -EINVAL;
3248 break;
3249
3250 default:
3251 rc = -EINVAL;
3252 }
3253
3254 if (rc)
3255 goto error;
3256
3257#ifdef CONFIG_PM
3258 fw_loaded = 1;
3259 } 3245 }
3260#endif 3246
3247 if (rc < 0)
3248 goto error;
3261 3249
3262 if (!priv->rxq) 3250 if (!priv->rxq)
3263 priv->rxq = ipw_rx_queue_alloc(priv); 3251 priv->rxq = ipw_rx_queue_alloc(priv);
@@ -3279,7 +3267,7 @@ static int ipw_load(struct ipw_priv *priv)
3279 ipw_stop_nic(priv); 3267 ipw_stop_nic(priv);
3280 3268
3281 rc = ipw_reset_nic(priv); 3269 rc = ipw_reset_nic(priv);
3282 if (rc) { 3270 if (rc < 0) {
3283 IPW_ERROR("Unable to reset NIC\n"); 3271 IPW_ERROR("Unable to reset NIC\n");
3284 goto error; 3272 goto error;
3285 } 3273 }
@@ -3287,6 +3275,15 @@ static int ipw_load(struct ipw_priv *priv)
3287 ipw_zero_memory(priv, IPW_NIC_SRAM_LOWER_BOUND, 3275 ipw_zero_memory(priv, IPW_NIC_SRAM_LOWER_BOUND,
3288 IPW_NIC_SRAM_UPPER_BOUND - IPW_NIC_SRAM_LOWER_BOUND); 3276 IPW_NIC_SRAM_UPPER_BOUND - IPW_NIC_SRAM_LOWER_BOUND);
3289 3277
3278#ifdef CONFIG_PM
3279 if (!fw_loaded) {
3280#endif
3281 rc = ipw_get_fw(priv, &bootfw, IPW_FW_NAME("boot"));
3282 if (rc < 0)
3283 goto error;
3284#ifdef CONFIG_PM
3285 }
3286#endif
3290 /* DMA the initial boot firmware into the device */ 3287 /* DMA the initial boot firmware into the device */
3291 rc = ipw_load_firmware(priv, bootfw->data + sizeof(struct fw_header), 3288 rc = ipw_load_firmware(priv, bootfw->data + sizeof(struct fw_header),
3292 bootfw->size - sizeof(struct fw_header)); 3289 bootfw->size - sizeof(struct fw_header));
@@ -3298,7 +3295,7 @@ static int ipw_load(struct ipw_priv *priv)
3298 /* kick start the device */ 3295 /* kick start the device */
3299 ipw_start_nic(priv); 3296 ipw_start_nic(priv);
3300 3297
3301 /* wait for the device to finish it's initial startup sequence */ 3298 /* wait for the device to finish its initial startup sequence */
3302 rc = ipw_poll_bit(priv, IPW_INTA_RW, 3299 rc = ipw_poll_bit(priv, IPW_INTA_RW,
3303 IPW_INTA_BIT_FW_INITIALIZATION_DONE, 500); 3300 IPW_INTA_BIT_FW_INITIALIZATION_DONE, 500);
3304 if (rc < 0) { 3301 if (rc < 0) {
@@ -3310,6 +3307,16 @@ static int ipw_load(struct ipw_priv *priv)
3310 /* ack fw init done interrupt */ 3307 /* ack fw init done interrupt */
3311 ipw_write32(priv, IPW_INTA_RW, IPW_INTA_BIT_FW_INITIALIZATION_DONE); 3308 ipw_write32(priv, IPW_INTA_RW, IPW_INTA_BIT_FW_INITIALIZATION_DONE);
3312 3309
3310#ifdef CONFIG_PM
3311 if (!fw_loaded) {
3312#endif
3313 rc = ipw_get_fw(priv, &ucode, ucode_name);
3314 if (rc < 0)
3315 goto error;
3316#ifdef CONFIG_PM
3317 }
3318#endif
3319
3313 /* DMA the ucode into the device */ 3320 /* DMA the ucode into the device */
3314 rc = ipw_load_ucode(priv, ucode->data + sizeof(struct fw_header), 3321 rc = ipw_load_ucode(priv, ucode->data + sizeof(struct fw_header),
3315 ucode->size - sizeof(struct fw_header)); 3322 ucode->size - sizeof(struct fw_header));
@@ -3321,6 +3328,16 @@ static int ipw_load(struct ipw_priv *priv)
3321 /* stop nic */ 3328 /* stop nic */
3322 ipw_stop_nic(priv); 3329 ipw_stop_nic(priv);
3323 3330
3331#ifdef CONFIG_PM
3332 if (!fw_loaded) {
3333#endif
3334 rc = ipw_get_fw(priv, &firmware, fw_name);
3335 if (rc < 0)
3336 goto error;
3337#ifdef CONFIG_PM
3338 }
3339#endif
3340
3324 /* DMA bss firmware into the device */ 3341 /* DMA bss firmware into the device */
3325 rc = ipw_load_firmware(priv, firmware->data + 3342 rc = ipw_load_firmware(priv, firmware->data +
3326 sizeof(struct fw_header), 3343 sizeof(struct fw_header),
@@ -3329,11 +3346,14 @@ static int ipw_load(struct ipw_priv *priv)
3329 IPW_ERROR("Unable to load firmware: %d\n", rc); 3346 IPW_ERROR("Unable to load firmware: %d\n", rc);
3330 goto error; 3347 goto error;
3331 } 3348 }
3349#ifdef CONFIG_PM
3350 fw_loaded = 1;
3351#endif
3332 3352
3333 ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0); 3353 ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0);
3334 3354
3335 rc = ipw_queue_reset(priv); 3355 rc = ipw_queue_reset(priv);
3336 if (rc) { 3356 if (rc < 0) {
3337 IPW_ERROR("Unable to initialize queues\n"); 3357 IPW_ERROR("Unable to initialize queues\n");
3338 goto error; 3358 goto error;
3339 } 3359 }
@@ -3362,7 +3382,7 @@ static int ipw_load(struct ipw_priv *priv)
3362 rc = ipw_poll_bit(priv, IPW_INTA_RW, 3382 rc = ipw_poll_bit(priv, IPW_INTA_RW,
3363 IPW_INTA_BIT_FW_INITIALIZATION_DONE, 500); 3383 IPW_INTA_BIT_FW_INITIALIZATION_DONE, 500);
3364 if (rc < 0) { 3384 if (rc < 0) {
3365 IPW_ERROR("device failed to start after 500ms\n"); 3385 IPW_ERROR("device failed to start within 500ms\n");
3366 goto error; 3386 goto error;
3367 } 3387 }
3368 IPW_DEBUG_INFO("device response after %dms\n", rc); 3388 IPW_DEBUG_INFO("device response after %dms\n", rc);
@@ -3715,9 +3735,9 @@ static int ipw_disassociate(void *data)
3715static void ipw_bg_disassociate(void *data) 3735static void ipw_bg_disassociate(void *data)
3716{ 3736{
3717 struct ipw_priv *priv = data; 3737 struct ipw_priv *priv = data;
3718 down(&priv->sem); 3738 mutex_lock(&priv->mutex);
3719 ipw_disassociate(data); 3739 ipw_disassociate(data);
3720 up(&priv->sem); 3740 mutex_unlock(&priv->mutex);
3721} 3741}
3722 3742
3723static void ipw_system_config(void *data) 3743static void ipw_system_config(void *data)
@@ -4077,9 +4097,9 @@ static void ipw_gather_stats(struct ipw_priv *priv)
4077static void ipw_bg_gather_stats(void *data) 4097static void ipw_bg_gather_stats(void *data)
4078{ 4098{
4079 struct ipw_priv *priv = data; 4099 struct ipw_priv *priv = data;
4080 down(&priv->sem); 4100 mutex_lock(&priv->mutex);
4081 ipw_gather_stats(data); 4101 ipw_gather_stats(data);
4082 up(&priv->sem); 4102 mutex_unlock(&priv->mutex);
4083} 4103}
4084 4104
4085/* Missed beacon behavior: 4105/* Missed beacon behavior:
@@ -4121,8 +4141,9 @@ static void ipw_handle_missed_beacon(struct ipw_priv *priv,
4121 return; 4141 return;
4122 } 4142 }
4123 4143
4124 if (missed_count > priv->roaming_threshold && 4144 if (roaming &&
4125 missed_count <= priv->disassociate_threshold) { 4145 (missed_count > priv->roaming_threshold &&
4146 missed_count <= priv->disassociate_threshold)) {
4126 /* If we are not already roaming, set the ROAM 4147 /* If we are not already roaming, set the ROAM
4127 * bit in the status and kick off a scan. 4148 * bit in the status and kick off a scan.
4128 * This can happen several times before we reach 4149 * This can happen several times before we reach
@@ -4150,7 +4171,6 @@ static void ipw_handle_missed_beacon(struct ipw_priv *priv,
4150 } 4171 }
4151 4172
4152 IPW_DEBUG_NOTIF("Missed beacon: %d\n", missed_count); 4173 IPW_DEBUG_NOTIF("Missed beacon: %d\n", missed_count);
4153
4154} 4174}
4155 4175
4156/** 4176/**
@@ -4911,13 +4931,13 @@ static void ipw_rx_queue_replenish(void *data)
4911static void ipw_bg_rx_queue_replenish(void *data) 4931static void ipw_bg_rx_queue_replenish(void *data)
4912{ 4932{
4913 struct ipw_priv *priv = data; 4933 struct ipw_priv *priv = data;
4914 down(&priv->sem); 4934 mutex_lock(&priv->mutex);
4915 ipw_rx_queue_replenish(data); 4935 ipw_rx_queue_replenish(data);
4916 up(&priv->sem); 4936 mutex_unlock(&priv->mutex);
4917} 4937}
4918 4938
4919/* Assumes that the skb field of the buffers in 'pool' is kept accurate. 4939/* Assumes that the skb field of the buffers in 'pool' is kept accurate.
4920 * If an SKB has been detached, the POOL needs to have it's SKB set to NULL 4940 * If an SKB has been detached, the POOL needs to have its SKB set to NULL
4921 * This free routine walks the list of POOL entries and if SKB is set to 4941 * This free routine walks the list of POOL entries and if SKB is set to
4922 * non NULL it is unmapped and freed 4942 * non NULL it is unmapped and freed
4923 */ 4943 */
@@ -5257,10 +5277,11 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5257 if (priv->ieee->scan_age != 0 && 5277 if (priv->ieee->scan_age != 0 &&
5258 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) { 5278 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) {
5259 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT ")' excluded " 5279 IPW_DEBUG_MERGE("Network '%s (" MAC_FMT ")' excluded "
5260 "because of age: %lums.\n", 5280 "because of age: %ums.\n",
5261 escape_essid(network->ssid, network->ssid_len), 5281 escape_essid(network->ssid, network->ssid_len),
5262 MAC_ARG(network->bssid), 5282 MAC_ARG(network->bssid),
5263 1000 * (jiffies - network->last_scanned) / HZ); 5283 jiffies_to_msecs(jiffies -
5284 network->last_scanned));
5264 return 0; 5285 return 0;
5265 } 5286 }
5266 5287
@@ -5369,7 +5390,7 @@ static void ipw_merge_adhoc_network(void *data)
5369 return; 5390 return;
5370 } 5391 }
5371 5392
5372 down(&priv->sem); 5393 mutex_lock(&priv->mutex);
5373 if ((priv->ieee->iw_mode == IW_MODE_ADHOC)) { 5394 if ((priv->ieee->iw_mode == IW_MODE_ADHOC)) {
5374 IPW_DEBUG_MERGE("remove network %s\n", 5395 IPW_DEBUG_MERGE("remove network %s\n",
5375 escape_essid(priv->essid, 5396 escape_essid(priv->essid,
@@ -5379,7 +5400,7 @@ static void ipw_merge_adhoc_network(void *data)
5379 5400
5380 ipw_disassociate(priv); 5401 ipw_disassociate(priv);
5381 priv->assoc_network = match.network; 5402 priv->assoc_network = match.network;
5382 up(&priv->sem); 5403 mutex_unlock(&priv->mutex);
5383 return; 5404 return;
5384 } 5405 }
5385} 5406}
@@ -5467,11 +5488,12 @@ static int ipw_best_network(struct ipw_priv *priv,
5467 if (network->last_associate && 5488 if (network->last_associate &&
5468 time_after(network->last_associate + (HZ * 3UL), jiffies)) { 5489 time_after(network->last_associate + (HZ * 3UL), jiffies)) {
5469 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " 5490 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
5470 "because of storming (%lus since last " 5491 "because of storming (%ums since last "
5471 "assoc attempt).\n", 5492 "assoc attempt).\n",
5472 escape_essid(network->ssid, network->ssid_len), 5493 escape_essid(network->ssid, network->ssid_len),
5473 MAC_ARG(network->bssid), 5494 MAC_ARG(network->bssid),
5474 (jiffies - network->last_associate) / HZ); 5495 jiffies_to_msecs(jiffies -
5496 network->last_associate));
5475 return 0; 5497 return 0;
5476 } 5498 }
5477 5499
@@ -5479,10 +5501,11 @@ static int ipw_best_network(struct ipw_priv *priv,
5479 if (priv->ieee->scan_age != 0 && 5501 if (priv->ieee->scan_age != 0 &&
5480 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) { 5502 time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) {
5481 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " 5503 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
5482 "because of age: %lums.\n", 5504 "because of age: %ums.\n",
5483 escape_essid(network->ssid, network->ssid_len), 5505 escape_essid(network->ssid, network->ssid_len),
5484 MAC_ARG(network->bssid), 5506 MAC_ARG(network->bssid),
5485 1000 * (jiffies - network->last_scanned) / HZ); 5507 jiffies_to_msecs(jiffies -
5508 network->last_scanned));
5486 return 0; 5509 return 0;
5487 } 5510 }
5488 5511
@@ -5671,54 +5694,44 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
5671 5694
5672static void ipw_send_tgi_tx_key(struct ipw_priv *priv, int type, int index) 5695static void ipw_send_tgi_tx_key(struct ipw_priv *priv, int type, int index)
5673{ 5696{
5674 struct ipw_tgi_tx_key *key; 5697 struct ipw_tgi_tx_key key;
5675 struct host_cmd cmd = {
5676 .cmd = IPW_CMD_TGI_TX_KEY,
5677 .len = sizeof(*key)
5678 };
5679 5698
5680 if (!(priv->ieee->sec.flags & (1 << index))) 5699 if (!(priv->ieee->sec.flags & (1 << index)))
5681 return; 5700 return;
5682 5701
5683 key = (struct ipw_tgi_tx_key *)&cmd.param; 5702 key.key_id = index;
5684 key->key_id = index; 5703 memcpy(key.key, priv->ieee->sec.keys[index], SCM_TEMPORAL_KEY_LENGTH);
5685 memcpy(key->key, priv->ieee->sec.keys[index], SCM_TEMPORAL_KEY_LENGTH); 5704 key.security_type = type;
5686 key->security_type = type; 5705 key.station_index = 0; /* always 0 for BSS */
5687 key->station_index = 0; /* always 0 for BSS */ 5706 key.flags = 0;
5688 key->flags = 0;
5689 /* 0 for new key; previous value of counter (after fatal error) */ 5707 /* 0 for new key; previous value of counter (after fatal error) */
5690 key->tx_counter[0] = 0; 5708 key.tx_counter[0] = 0;
5691 key->tx_counter[1] = 0; 5709 key.tx_counter[1] = 0;
5692 5710
5693 ipw_send_cmd(priv, &cmd); 5711 ipw_send_cmd_pdu(priv, IPW_CMD_TGI_TX_KEY, sizeof(key), &key);
5694} 5712}
5695 5713
5696static void ipw_send_wep_keys(struct ipw_priv *priv, int type) 5714static void ipw_send_wep_keys(struct ipw_priv *priv, int type)
5697{ 5715{
5698 struct ipw_wep_key *key; 5716 struct ipw_wep_key key;
5699 int i; 5717 int i;
5700 struct host_cmd cmd = {
5701 .cmd = IPW_CMD_WEP_KEY,
5702 .len = sizeof(*key)
5703 };
5704 5718
5705 key = (struct ipw_wep_key *)&cmd.param; 5719 key.cmd_id = DINO_CMD_WEP_KEY;
5706 key->cmd_id = DINO_CMD_WEP_KEY; 5720 key.seq_num = 0;
5707 key->seq_num = 0;
5708 5721
5709 /* Note: AES keys cannot be set for multiple times. 5722 /* Note: AES keys cannot be set for multiple times.
5710 * Only set it at the first time. */ 5723 * Only set it at the first time. */
5711 for (i = 0; i < 4; i++) { 5724 for (i = 0; i < 4; i++) {
5712 key->key_index = i | type; 5725 key.key_index = i | type;
5713 if (!(priv->ieee->sec.flags & (1 << i))) { 5726 if (!(priv->ieee->sec.flags & (1 << i))) {
5714 key->key_size = 0; 5727 key.key_size = 0;
5715 continue; 5728 continue;
5716 } 5729 }
5717 5730
5718 key->key_size = priv->ieee->sec.key_sizes[i]; 5731 key.key_size = priv->ieee->sec.key_sizes[i];
5719 memcpy(key->key, priv->ieee->sec.keys[i], key->key_size); 5732 memcpy(key.key, priv->ieee->sec.keys[i], key.key_size);
5720 5733
5721 ipw_send_cmd(priv, &cmd); 5734 ipw_send_cmd_pdu(priv, IPW_CMD_WEP_KEY, sizeof(key), &key);
5722 } 5735 }
5723} 5736}
5724 5737
@@ -5822,9 +5835,9 @@ static void ipw_adhoc_check(void *data)
5822static void ipw_bg_adhoc_check(void *data) 5835static void ipw_bg_adhoc_check(void *data)
5823{ 5836{
5824 struct ipw_priv *priv = data; 5837 struct ipw_priv *priv = data;
5825 down(&priv->sem); 5838 mutex_lock(&priv->mutex);
5826 ipw_adhoc_check(data); 5839 ipw_adhoc_check(data);
5827 up(&priv->sem); 5840 mutex_unlock(&priv->mutex);
5828} 5841}
5829 5842
5830#ifdef CONFIG_IPW2200_DEBUG 5843#ifdef CONFIG_IPW2200_DEBUG
@@ -6051,7 +6064,7 @@ static int ipw_request_scan(struct ipw_priv *priv)
6051 (priv->status & STATUS_EXIT_PENDING)) 6064 (priv->status & STATUS_EXIT_PENDING))
6052 return 0; 6065 return 0;
6053 6066
6054 down(&priv->sem); 6067 mutex_lock(&priv->mutex);
6055 6068
6056 if (priv->status & STATUS_SCANNING) { 6069 if (priv->status & STATUS_SCANNING) {
6057 IPW_DEBUG_HC("Concurrent scan requested. Ignoring.\n"); 6070 IPW_DEBUG_HC("Concurrent scan requested. Ignoring.\n");
@@ -6159,16 +6172,16 @@ static int ipw_request_scan(struct ipw_priv *priv)
6159 queue_delayed_work(priv->workqueue, &priv->scan_check, 6172 queue_delayed_work(priv->workqueue, &priv->scan_check,
6160 IPW_SCAN_CHECK_WATCHDOG); 6173 IPW_SCAN_CHECK_WATCHDOG);
6161 done: 6174 done:
6162 up(&priv->sem); 6175 mutex_unlock(&priv->mutex);
6163 return err; 6176 return err;
6164} 6177}
6165 6178
6166static void ipw_bg_abort_scan(void *data) 6179static void ipw_bg_abort_scan(void *data)
6167{ 6180{
6168 struct ipw_priv *priv = data; 6181 struct ipw_priv *priv = data;
6169 down(&priv->sem); 6182 mutex_lock(&priv->mutex);
6170 ipw_abort_scan(data); 6183 ipw_abort_scan(data);
6171 up(&priv->sem); 6184 mutex_unlock(&priv->mutex);
6172} 6185}
6173 6186
6174static int ipw_wpa_enable(struct ipw_priv *priv, int value) 6187static int ipw_wpa_enable(struct ipw_priv *priv, int value)
@@ -6193,6 +6206,9 @@ static int ipw_wpa_set_auth_algs(struct ipw_priv *priv, int value)
6193 } else if (value & IW_AUTH_ALG_OPEN_SYSTEM) { 6206 } else if (value & IW_AUTH_ALG_OPEN_SYSTEM) {
6194 sec.auth_mode = WLAN_AUTH_OPEN; 6207 sec.auth_mode = WLAN_AUTH_OPEN;
6195 ieee->open_wep = 1; 6208 ieee->open_wep = 1;
6209 } else if (value & IW_AUTH_ALG_LEAP) {
6210 sec.auth_mode = WLAN_AUTH_LEAP;
6211 ieee->open_wep = 1;
6196 } else 6212 } else
6197 return -EINVAL; 6213 return -EINVAL;
6198 6214
@@ -6204,7 +6220,8 @@ static int ipw_wpa_set_auth_algs(struct ipw_priv *priv, int value)
6204 return ret; 6220 return ret;
6205} 6221}
6206 6222
6207void ipw_wpa_assoc_frame(struct ipw_priv *priv, char *wpa_ie, int wpa_ie_len) 6223static void ipw_wpa_assoc_frame(struct ipw_priv *priv, char *wpa_ie,
6224 int wpa_ie_len)
6208{ 6225{
6209 /* make sure WPA is enabled */ 6226 /* make sure WPA is enabled */
6210 ipw_wpa_enable(priv, 1); 6227 ipw_wpa_enable(priv, 1);
@@ -6215,15 +6232,10 @@ void ipw_wpa_assoc_frame(struct ipw_priv *priv, char *wpa_ie, int wpa_ie_len)
6215static int ipw_set_rsn_capa(struct ipw_priv *priv, 6232static int ipw_set_rsn_capa(struct ipw_priv *priv,
6216 char *capabilities, int length) 6233 char *capabilities, int length)
6217{ 6234{
6218 struct host_cmd cmd = {
6219 .cmd = IPW_CMD_RSN_CAPABILITIES,
6220 .len = length,
6221 };
6222
6223 IPW_DEBUG_HC("HOST_CMD_RSN_CAPABILITIES\n"); 6235 IPW_DEBUG_HC("HOST_CMD_RSN_CAPABILITIES\n");
6224 6236
6225 memcpy(cmd.param, capabilities, length); 6237 return ipw_send_cmd_pdu(priv, IPW_CMD_RSN_CAPABILITIES, length,
6226 return ipw_send_cmd(priv, &cmd); 6238 capabilities);
6227} 6239}
6228 6240
6229/* 6241/*
@@ -6244,7 +6256,7 @@ static int ipw_wx_set_genie(struct net_device *dev,
6244 (wrqu->data.length && extra == NULL)) 6256 (wrqu->data.length && extra == NULL))
6245 return -EINVAL; 6257 return -EINVAL;
6246 6258
6247 //down(&priv->sem); 6259 //mutex_lock(&priv->mutex);
6248 6260
6249 //if (!ieee->wpa_enabled) { 6261 //if (!ieee->wpa_enabled) {
6250 // err = -EOPNOTSUPP; 6262 // err = -EOPNOTSUPP;
@@ -6270,7 +6282,7 @@ static int ipw_wx_set_genie(struct net_device *dev,
6270 6282
6271 ipw_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len); 6283 ipw_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len);
6272 out: 6284 out:
6273 //up(&priv->sem); 6285 //mutex_unlock(&priv->mutex);
6274 return err; 6286 return err;
6275} 6287}
6276 6288
@@ -6283,7 +6295,7 @@ static int ipw_wx_get_genie(struct net_device *dev,
6283 struct ieee80211_device *ieee = priv->ieee; 6295 struct ieee80211_device *ieee = priv->ieee;
6284 int err = 0; 6296 int err = 0;
6285 6297
6286 //down(&priv->sem); 6298 //mutex_lock(&priv->mutex);
6287 6299
6288 //if (!ieee->wpa_enabled) { 6300 //if (!ieee->wpa_enabled) {
6289 // err = -EOPNOTSUPP; 6301 // err = -EOPNOTSUPP;
@@ -6304,7 +6316,7 @@ static int ipw_wx_get_genie(struct net_device *dev,
6304 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len); 6316 memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len);
6305 6317
6306 out: 6318 out:
6307 //up(&priv->sem); 6319 //mutex_unlock(&priv->mutex);
6308 return err; 6320 return err;
6309} 6321}
6310 6322
@@ -6964,12 +6976,12 @@ static void ipw_bg_qos_activate(void *data)
6964 if (priv == NULL) 6976 if (priv == NULL)
6965 return; 6977 return;
6966 6978
6967 down(&priv->sem); 6979 mutex_lock(&priv->mutex);
6968 6980
6969 if (priv->status & STATUS_ASSOCIATED) 6981 if (priv->status & STATUS_ASSOCIATED)
6970 ipw_qos_activate(priv, &(priv->assoc_network->qos_data)); 6982 ipw_qos_activate(priv, &(priv->assoc_network->qos_data));
6971 6983
6972 up(&priv->sem); 6984 mutex_unlock(&priv->mutex);
6973} 6985}
6974 6986
6975static int ipw_handle_probe_response(struct net_device *dev, 6987static int ipw_handle_probe_response(struct net_device *dev,
@@ -7010,25 +7022,15 @@ static int ipw_handle_assoc_response(struct net_device *dev,
7010static int ipw_send_qos_params_command(struct ipw_priv *priv, struct ieee80211_qos_parameters 7022static int ipw_send_qos_params_command(struct ipw_priv *priv, struct ieee80211_qos_parameters
7011 *qos_param) 7023 *qos_param)
7012{ 7024{
7013 struct host_cmd cmd = { 7025 return ipw_send_cmd_pdu(priv, IPW_CMD_QOS_PARAMETERS,
7014 .cmd = IPW_CMD_QOS_PARAMETERS, 7026 sizeof(*qos_param) * 3, qos_param);
7015 .len = (sizeof(struct ieee80211_qos_parameters) * 3)
7016 };
7017
7018 memcpy(cmd.param, qos_param, sizeof(*qos_param) * 3);
7019 return ipw_send_cmd(priv, &cmd);
7020} 7027}
7021 7028
7022static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos_information_element 7029static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos_information_element
7023 *qos_param) 7030 *qos_param)
7024{ 7031{
7025 struct host_cmd cmd = { 7032 return ipw_send_cmd_pdu(priv, IPW_CMD_WME_INFO, sizeof(*qos_param),
7026 .cmd = IPW_CMD_WME_INFO, 7033 qos_param);
7027 .len = sizeof(*qos_param)
7028 };
7029
7030 memcpy(cmd.param, qos_param, sizeof(*qos_param));
7031 return ipw_send_cmd(priv, &cmd);
7032} 7034}
7033 7035
7034#endif /* CONFIG_IPW_QOS */ 7036#endif /* CONFIG_IPW_QOS */
@@ -7052,19 +7054,22 @@ static int ipw_associate_network(struct ipw_priv *priv,
7052 7054
7053 memset(&priv->assoc_request, 0, sizeof(priv->assoc_request)); 7055 memset(&priv->assoc_request, 0, sizeof(priv->assoc_request));
7054 priv->assoc_request.channel = network->channel; 7056 priv->assoc_request.channel = network->channel;
7057 priv->assoc_request.auth_key = 0;
7058
7055 if ((priv->capability & CAP_PRIVACY_ON) && 7059 if ((priv->capability & CAP_PRIVACY_ON) &&
7056 (priv->capability & CAP_SHARED_KEY)) { 7060 (priv->ieee->sec.auth_mode == WLAN_AUTH_SHARED_KEY)) {
7057 priv->assoc_request.auth_type = AUTH_SHARED_KEY; 7061 priv->assoc_request.auth_type = AUTH_SHARED_KEY;
7058 priv->assoc_request.auth_key = priv->ieee->sec.active_key; 7062 priv->assoc_request.auth_key = priv->ieee->sec.active_key;
7059 7063
7060 if ((priv->capability & CAP_PRIVACY_ON) && 7064 if ((priv->ieee->sec.level == SEC_LEVEL_1) &&
7061 (priv->ieee->sec.level == SEC_LEVEL_1) &&
7062 !(priv->ieee->host_encrypt || priv->ieee->host_decrypt)) 7065 !(priv->ieee->host_encrypt || priv->ieee->host_decrypt))
7063 ipw_send_wep_keys(priv, DCW_WEP_KEY_SEC_TYPE_WEP); 7066 ipw_send_wep_keys(priv, DCW_WEP_KEY_SEC_TYPE_WEP);
7064 } else { 7067
7068 } else if ((priv->capability & CAP_PRIVACY_ON) &&
7069 (priv->ieee->sec.auth_mode == WLAN_AUTH_LEAP))
7070 priv->assoc_request.auth_type = AUTH_LEAP;
7071 else
7065 priv->assoc_request.auth_type = AUTH_OPEN; 7072 priv->assoc_request.auth_type = AUTH_OPEN;
7066 priv->assoc_request.auth_key = 0;
7067 }
7068 7073
7069 if (priv->ieee->wpa_ie_len) { 7074 if (priv->ieee->wpa_ie_len) {
7070 priv->assoc_request.policy_support = 0x02; /* RSN active */ 7075 priv->assoc_request.policy_support = 0x02; /* RSN active */
@@ -7278,9 +7283,9 @@ static void ipw_roam(void *data)
7278static void ipw_bg_roam(void *data) 7283static void ipw_bg_roam(void *data)
7279{ 7284{
7280 struct ipw_priv *priv = data; 7285 struct ipw_priv *priv = data;
7281 down(&priv->sem); 7286 mutex_lock(&priv->mutex);
7282 ipw_roam(data); 7287 ipw_roam(data);
7283 up(&priv->sem); 7288 mutex_unlock(&priv->mutex);
7284} 7289}
7285 7290
7286static int ipw_associate(void *data) 7291static int ipw_associate(void *data)
@@ -7375,9 +7380,9 @@ static int ipw_associate(void *data)
7375static void ipw_bg_associate(void *data) 7380static void ipw_bg_associate(void *data)
7376{ 7381{
7377 struct ipw_priv *priv = data; 7382 struct ipw_priv *priv = data;
7378 down(&priv->sem); 7383 mutex_lock(&priv->mutex);
7379 ipw_associate(data); 7384 ipw_associate(data);
7380 up(&priv->sem); 7385 mutex_unlock(&priv->mutex);
7381} 7386}
7382 7387
7383static void ipw_rebuild_decrypted_skb(struct ipw_priv *priv, 7388static void ipw_rebuild_decrypted_skb(struct ipw_priv *priv,
@@ -8126,7 +8131,7 @@ static int ipw_wx_get_name(struct net_device *dev,
8126 union iwreq_data *wrqu, char *extra) 8131 union iwreq_data *wrqu, char *extra)
8127{ 8132{
8128 struct ipw_priv *priv = ieee80211_priv(dev); 8133 struct ipw_priv *priv = ieee80211_priv(dev);
8129 down(&priv->sem); 8134 mutex_lock(&priv->mutex);
8130 if (priv->status & STATUS_RF_KILL_MASK) 8135 if (priv->status & STATUS_RF_KILL_MASK)
8131 strcpy(wrqu->name, "radio off"); 8136 strcpy(wrqu->name, "radio off");
8132 else if (!(priv->status & STATUS_ASSOCIATED)) 8137 else if (!(priv->status & STATUS_ASSOCIATED))
@@ -8135,7 +8140,7 @@ static int ipw_wx_get_name(struct net_device *dev,
8135 snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11%c", 8140 snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11%c",
8136 ipw_modes[priv->assoc_request.ieee_mode]); 8141 ipw_modes[priv->assoc_request.ieee_mode]);
8137 IPW_DEBUG_WX("Name: %s\n", wrqu->name); 8142 IPW_DEBUG_WX("Name: %s\n", wrqu->name);
8138 up(&priv->sem); 8143 mutex_unlock(&priv->mutex);
8139 return 0; 8144 return 0;
8140} 8145}
8141 8146
@@ -8204,9 +8209,9 @@ static int ipw_wx_set_freq(struct net_device *dev,
8204 8209
8205 if (fwrq->m == 0) { 8210 if (fwrq->m == 0) {
8206 IPW_DEBUG_WX("SET Freq/Channel -> any\n"); 8211 IPW_DEBUG_WX("SET Freq/Channel -> any\n");
8207 down(&priv->sem); 8212 mutex_lock(&priv->mutex);
8208 ret = ipw_set_channel(priv, 0); 8213 ret = ipw_set_channel(priv, 0);
8209 up(&priv->sem); 8214 mutex_unlock(&priv->mutex);
8210 return ret; 8215 return ret;
8211 } 8216 }
8212 /* if setting by freq convert to channel */ 8217 /* if setting by freq convert to channel */
@@ -8234,9 +8239,9 @@ static int ipw_wx_set_freq(struct net_device *dev,
8234 } 8239 }
8235 8240
8236 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m); 8241 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m);
8237 down(&priv->sem); 8242 mutex_lock(&priv->mutex);
8238 ret = ipw_set_channel(priv, channel); 8243 ret = ipw_set_channel(priv, channel);
8239 up(&priv->sem); 8244 mutex_unlock(&priv->mutex);
8240 return ret; 8245 return ret;
8241} 8246}
8242 8247
@@ -8250,14 +8255,14 @@ static int ipw_wx_get_freq(struct net_device *dev,
8250 8255
8251 /* If we are associated, trying to associate, or have a statically 8256 /* If we are associated, trying to associate, or have a statically
8252 * configured CHANNEL then return that; otherwise return ANY */ 8257 * configured CHANNEL then return that; otherwise return ANY */
8253 down(&priv->sem); 8258 mutex_lock(&priv->mutex);
8254 if (priv->config & CFG_STATIC_CHANNEL || 8259 if (priv->config & CFG_STATIC_CHANNEL ||
8255 priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) 8260 priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED))
8256 wrqu->freq.m = priv->channel; 8261 wrqu->freq.m = priv->channel;
8257 else 8262 else
8258 wrqu->freq.m = 0; 8263 wrqu->freq.m = 0;
8259 8264
8260 up(&priv->sem); 8265 mutex_unlock(&priv->mutex);
8261 IPW_DEBUG_WX("GET Freq/Channel -> %d \n", priv->channel); 8266 IPW_DEBUG_WX("GET Freq/Channel -> %d \n", priv->channel);
8262 return 0; 8267 return 0;
8263} 8268}
@@ -8287,7 +8292,7 @@ static int ipw_wx_set_mode(struct net_device *dev,
8287 if (wrqu->mode == priv->ieee->iw_mode) 8292 if (wrqu->mode == priv->ieee->iw_mode)
8288 return 0; 8293 return 0;
8289 8294
8290 down(&priv->sem); 8295 mutex_lock(&priv->mutex);
8291 8296
8292 ipw_sw_reset(priv, 0); 8297 ipw_sw_reset(priv, 0);
8293 8298
@@ -8310,7 +8315,7 @@ static int ipw_wx_set_mode(struct net_device *dev,
8310 priv->ieee->iw_mode = wrqu->mode; 8315 priv->ieee->iw_mode = wrqu->mode;
8311 8316
8312 queue_work(priv->workqueue, &priv->adapter_restart); 8317 queue_work(priv->workqueue, &priv->adapter_restart);
8313 up(&priv->sem); 8318 mutex_unlock(&priv->mutex);
8314 return err; 8319 return err;
8315} 8320}
8316 8321
@@ -8319,10 +8324,10 @@ static int ipw_wx_get_mode(struct net_device *dev,
8319 union iwreq_data *wrqu, char *extra) 8324 union iwreq_data *wrqu, char *extra)
8320{ 8325{
8321 struct ipw_priv *priv = ieee80211_priv(dev); 8326 struct ipw_priv *priv = ieee80211_priv(dev);
8322 down(&priv->sem); 8327 mutex_lock(&priv->mutex);
8323 wrqu->mode = priv->ieee->iw_mode; 8328 wrqu->mode = priv->ieee->iw_mode;
8324 IPW_DEBUG_WX("Get MODE -> %d\n", wrqu->mode); 8329 IPW_DEBUG_WX("Get MODE -> %d\n", wrqu->mode);
8325 up(&priv->sem); 8330 mutex_unlock(&priv->mutex);
8326 return 0; 8331 return 0;
8327} 8332}
8328 8333
@@ -8369,7 +8374,7 @@ static int ipw_wx_get_range(struct net_device *dev,
8369 range->avg_qual.level = 0; /* FIXME to real average level */ 8374 range->avg_qual.level = 0; /* FIXME to real average level */
8370 range->avg_qual.noise = 0; 8375 range->avg_qual.noise = 0;
8371 range->avg_qual.updated = 7; /* Updated all three */ 8376 range->avg_qual.updated = 7; /* Updated all three */
8372 down(&priv->sem); 8377 mutex_lock(&priv->mutex);
8373 range->num_bitrates = min(priv->rates.num_rates, (u8) IW_MAX_BITRATES); 8378 range->num_bitrates = min(priv->rates.num_rates, (u8) IW_MAX_BITRATES);
8374 8379
8375 for (i = 0; i < range->num_bitrates; i++) 8380 for (i = 0; i < range->num_bitrates; i++)
@@ -8387,7 +8392,7 @@ static int ipw_wx_get_range(struct net_device *dev,
8387 8392
8388 /* Set the Wireless Extension versions */ 8393 /* Set the Wireless Extension versions */
8389 range->we_version_compiled = WIRELESS_EXT; 8394 range->we_version_compiled = WIRELESS_EXT;
8390 range->we_version_source = 16; 8395 range->we_version_source = 18;
8391 8396
8392 i = 0; 8397 i = 0;
8393 if (priv->ieee->mode & (IEEE_B | IEEE_G)) { 8398 if (priv->ieee->mode & (IEEE_B | IEEE_G)) {
@@ -8411,7 +8416,7 @@ static int ipw_wx_get_range(struct net_device *dev,
8411 range->num_channels = i; 8416 range->num_channels = i;
8412 range->num_frequency = i; 8417 range->num_frequency = i;
8413 8418
8414 up(&priv->sem); 8419 mutex_unlock(&priv->mutex);
8415 8420
8416 /* Event capability (kernel + driver) */ 8421 /* Event capability (kernel + driver) */
8417 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | 8422 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
@@ -8419,6 +8424,9 @@ static int ipw_wx_get_range(struct net_device *dev,
8419 IW_EVENT_CAPA_MASK(SIOCGIWAP)); 8424 IW_EVENT_CAPA_MASK(SIOCGIWAP));
8420 range->event_capa[1] = IW_EVENT_CAPA_K_1; 8425 range->event_capa[1] = IW_EVENT_CAPA_K_1;
8421 8426
8427 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
8428 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
8429
8422 IPW_DEBUG_WX("GET Range\n"); 8430 IPW_DEBUG_WX("GET Range\n");
8423 return 0; 8431 return 0;
8424} 8432}
@@ -8438,7 +8446,7 @@ static int ipw_wx_set_wap(struct net_device *dev,
8438 8446
8439 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) 8447 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER)
8440 return -EINVAL; 8448 return -EINVAL;
8441 down(&priv->sem); 8449 mutex_lock(&priv->mutex);
8442 if (!memcmp(any, wrqu->ap_addr.sa_data, ETH_ALEN) || 8450 if (!memcmp(any, wrqu->ap_addr.sa_data, ETH_ALEN) ||
8443 !memcmp(off, wrqu->ap_addr.sa_data, ETH_ALEN)) { 8451 !memcmp(off, wrqu->ap_addr.sa_data, ETH_ALEN)) {
8444 /* we disable mandatory BSSID association */ 8452 /* we disable mandatory BSSID association */
@@ -8447,14 +8455,14 @@ static int ipw_wx_set_wap(struct net_device *dev,
8447 IPW_DEBUG_ASSOC("Attempting to associate with new " 8455 IPW_DEBUG_ASSOC("Attempting to associate with new "
8448 "parameters.\n"); 8456 "parameters.\n");
8449 ipw_associate(priv); 8457 ipw_associate(priv);
8450 up(&priv->sem); 8458 mutex_unlock(&priv->mutex);
8451 return 0; 8459 return 0;
8452 } 8460 }
8453 8461
8454 priv->config |= CFG_STATIC_BSSID; 8462 priv->config |= CFG_STATIC_BSSID;
8455 if (!memcmp(priv->bssid, wrqu->ap_addr.sa_data, ETH_ALEN)) { 8463 if (!memcmp(priv->bssid, wrqu->ap_addr.sa_data, ETH_ALEN)) {
8456 IPW_DEBUG_WX("BSSID set to current BSSID.\n"); 8464 IPW_DEBUG_WX("BSSID set to current BSSID.\n");
8457 up(&priv->sem); 8465 mutex_unlock(&priv->mutex);
8458 return 0; 8466 return 0;
8459 } 8467 }
8460 8468
@@ -8468,7 +8476,7 @@ static int ipw_wx_set_wap(struct net_device *dev,
8468 if (!ipw_disassociate(priv)) 8476 if (!ipw_disassociate(priv))
8469 ipw_associate(priv); 8477 ipw_associate(priv);
8470 8478
8471 up(&priv->sem); 8479 mutex_unlock(&priv->mutex);
8472 return 0; 8480 return 0;
8473} 8481}
8474 8482
@@ -8479,7 +8487,7 @@ static int ipw_wx_get_wap(struct net_device *dev,
8479 struct ipw_priv *priv = ieee80211_priv(dev); 8487 struct ipw_priv *priv = ieee80211_priv(dev);
8480 /* If we are associated, trying to associate, or have a statically 8488 /* If we are associated, trying to associate, or have a statically
8481 * configured BSSID then return that; otherwise return ANY */ 8489 * configured BSSID then return that; otherwise return ANY */
8482 down(&priv->sem); 8490 mutex_lock(&priv->mutex);
8483 if (priv->config & CFG_STATIC_BSSID || 8491 if (priv->config & CFG_STATIC_BSSID ||
8484 priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { 8492 priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
8485 wrqu->ap_addr.sa_family = ARPHRD_ETHER; 8493 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
@@ -8489,7 +8497,7 @@ static int ipw_wx_get_wap(struct net_device *dev,
8489 8497
8490 IPW_DEBUG_WX("Getting WAP BSSID: " MAC_FMT "\n", 8498 IPW_DEBUG_WX("Getting WAP BSSID: " MAC_FMT "\n",
8491 MAC_ARG(wrqu->ap_addr.sa_data)); 8499 MAC_ARG(wrqu->ap_addr.sa_data));
8492 up(&priv->sem); 8500 mutex_unlock(&priv->mutex);
8493 return 0; 8501 return 0;
8494} 8502}
8495 8503
@@ -8500,7 +8508,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
8500 struct ipw_priv *priv = ieee80211_priv(dev); 8508 struct ipw_priv *priv = ieee80211_priv(dev);
8501 char *essid = ""; /* ANY */ 8509 char *essid = ""; /* ANY */
8502 int length = 0; 8510 int length = 0;
8503 down(&priv->sem); 8511 mutex_lock(&priv->mutex);
8504 if (wrqu->essid.flags && wrqu->essid.length) { 8512 if (wrqu->essid.flags && wrqu->essid.length) {
8505 length = wrqu->essid.length - 1; 8513 length = wrqu->essid.length - 1;
8506 essid = extra; 8514 essid = extra;
@@ -8515,7 +8523,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
8515 priv->config &= ~CFG_STATIC_ESSID; 8523 priv->config &= ~CFG_STATIC_ESSID;
8516 ipw_associate(priv); 8524 ipw_associate(priv);
8517 } 8525 }
8518 up(&priv->sem); 8526 mutex_unlock(&priv->mutex);
8519 return 0; 8527 return 0;
8520 } 8528 }
8521 8529
@@ -8525,7 +8533,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
8525 8533
8526 if (priv->essid_len == length && !memcmp(priv->essid, extra, length)) { 8534 if (priv->essid_len == length && !memcmp(priv->essid, extra, length)) {
8527 IPW_DEBUG_WX("ESSID set to current ESSID.\n"); 8535 IPW_DEBUG_WX("ESSID set to current ESSID.\n");
8528 up(&priv->sem); 8536 mutex_unlock(&priv->mutex);
8529 return 0; 8537 return 0;
8530 } 8538 }
8531 8539
@@ -8540,7 +8548,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
8540 if (!ipw_disassociate(priv)) 8548 if (!ipw_disassociate(priv))
8541 ipw_associate(priv); 8549 ipw_associate(priv);
8542 8550
8543 up(&priv->sem); 8551 mutex_unlock(&priv->mutex);
8544 return 0; 8552 return 0;
8545} 8553}
8546 8554
@@ -8552,7 +8560,7 @@ static int ipw_wx_get_essid(struct net_device *dev,
8552 8560
8553 /* If we are associated, trying to associate, or have a statically 8561 /* If we are associated, trying to associate, or have a statically
8554 * configured ESSID then return that; otherwise return ANY */ 8562 * configured ESSID then return that; otherwise return ANY */
8555 down(&priv->sem); 8563 mutex_lock(&priv->mutex);
8556 if (priv->config & CFG_STATIC_ESSID || 8564 if (priv->config & CFG_STATIC_ESSID ||
8557 priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { 8565 priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
8558 IPW_DEBUG_WX("Getting essid: '%s'\n", 8566 IPW_DEBUG_WX("Getting essid: '%s'\n",
@@ -8565,7 +8573,7 @@ static int ipw_wx_get_essid(struct net_device *dev,
8565 wrqu->essid.length = 0; 8573 wrqu->essid.length = 0;
8566 wrqu->essid.flags = 0; /* active */ 8574 wrqu->essid.flags = 0; /* active */
8567 } 8575 }
8568 up(&priv->sem); 8576 mutex_unlock(&priv->mutex);
8569 return 0; 8577 return 0;
8570} 8578}
8571 8579
@@ -8578,12 +8586,12 @@ static int ipw_wx_set_nick(struct net_device *dev,
8578 IPW_DEBUG_WX("Setting nick to '%s'\n", extra); 8586 IPW_DEBUG_WX("Setting nick to '%s'\n", extra);
8579 if (wrqu->data.length > IW_ESSID_MAX_SIZE) 8587 if (wrqu->data.length > IW_ESSID_MAX_SIZE)
8580 return -E2BIG; 8588 return -E2BIG;
8581 down(&priv->sem); 8589 mutex_lock(&priv->mutex);
8582 wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick)); 8590 wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick));
8583 memset(priv->nick, 0, sizeof(priv->nick)); 8591 memset(priv->nick, 0, sizeof(priv->nick));
8584 memcpy(priv->nick, extra, wrqu->data.length); 8592 memcpy(priv->nick, extra, wrqu->data.length);
8585 IPW_DEBUG_TRACE("<<\n"); 8593 IPW_DEBUG_TRACE("<<\n");
8586 up(&priv->sem); 8594 mutex_unlock(&priv->mutex);
8587 return 0; 8595 return 0;
8588 8596
8589} 8597}
@@ -8594,11 +8602,11 @@ static int ipw_wx_get_nick(struct net_device *dev,
8594{ 8602{
8595 struct ipw_priv *priv = ieee80211_priv(dev); 8603 struct ipw_priv *priv = ieee80211_priv(dev);
8596 IPW_DEBUG_WX("Getting nick\n"); 8604 IPW_DEBUG_WX("Getting nick\n");
8597 down(&priv->sem); 8605 mutex_lock(&priv->mutex);
8598 wrqu->data.length = strlen(priv->nick) + 1; 8606 wrqu->data.length = strlen(priv->nick) + 1;
8599 memcpy(extra, priv->nick, wrqu->data.length); 8607 memcpy(extra, priv->nick, wrqu->data.length);
8600 wrqu->data.flags = 1; /* active */ 8608 wrqu->data.flags = 1; /* active */
8601 up(&priv->sem); 8609 mutex_unlock(&priv->mutex);
8602 return 0; 8610 return 0;
8603} 8611}
8604 8612
@@ -8691,7 +8699,7 @@ static int ipw_wx_set_rate(struct net_device *dev,
8691 apply: 8699 apply:
8692 IPW_DEBUG_WX("Setting rate mask to 0x%08X [%s]\n", 8700 IPW_DEBUG_WX("Setting rate mask to 0x%08X [%s]\n",
8693 mask, fixed ? "fixed" : "sub-rates"); 8701 mask, fixed ? "fixed" : "sub-rates");
8694 down(&priv->sem); 8702 mutex_lock(&priv->mutex);
8695 if (mask == IEEE80211_DEFAULT_RATES_MASK) { 8703 if (mask == IEEE80211_DEFAULT_RATES_MASK) {
8696 priv->config &= ~CFG_FIXED_RATE; 8704 priv->config &= ~CFG_FIXED_RATE;
8697 ipw_set_fixed_rate(priv, priv->ieee->mode); 8705 ipw_set_fixed_rate(priv, priv->ieee->mode);
@@ -8700,7 +8708,7 @@ static int ipw_wx_set_rate(struct net_device *dev,
8700 8708
8701 if (priv->rates_mask == mask) { 8709 if (priv->rates_mask == mask) {
8702 IPW_DEBUG_WX("Mask set to current mask.\n"); 8710 IPW_DEBUG_WX("Mask set to current mask.\n");
8703 up(&priv->sem); 8711 mutex_unlock(&priv->mutex);
8704 return 0; 8712 return 0;
8705 } 8713 }
8706 8714
@@ -8711,7 +8719,7 @@ static int ipw_wx_set_rate(struct net_device *dev,
8711 if (!ipw_disassociate(priv)) 8719 if (!ipw_disassociate(priv))
8712 ipw_associate(priv); 8720 ipw_associate(priv);
8713 8721
8714 up(&priv->sem); 8722 mutex_unlock(&priv->mutex);
8715 return 0; 8723 return 0;
8716} 8724}
8717 8725
@@ -8720,9 +8728,9 @@ static int ipw_wx_get_rate(struct net_device *dev,
8720 union iwreq_data *wrqu, char *extra) 8728 union iwreq_data *wrqu, char *extra)
8721{ 8729{
8722 struct ipw_priv *priv = ieee80211_priv(dev); 8730 struct ipw_priv *priv = ieee80211_priv(dev);
8723 down(&priv->sem); 8731 mutex_lock(&priv->mutex);
8724 wrqu->bitrate.value = priv->last_rate; 8732 wrqu->bitrate.value = priv->last_rate;
8725 up(&priv->sem); 8733 mutex_unlock(&priv->mutex);
8726 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); 8734 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value);
8727 return 0; 8735 return 0;
8728} 8736}
@@ -8732,20 +8740,20 @@ static int ipw_wx_set_rts(struct net_device *dev,
8732 union iwreq_data *wrqu, char *extra) 8740 union iwreq_data *wrqu, char *extra)
8733{ 8741{
8734 struct ipw_priv *priv = ieee80211_priv(dev); 8742 struct ipw_priv *priv = ieee80211_priv(dev);
8735 down(&priv->sem); 8743 mutex_lock(&priv->mutex);
8736 if (wrqu->rts.disabled) 8744 if (wrqu->rts.disabled)
8737 priv->rts_threshold = DEFAULT_RTS_THRESHOLD; 8745 priv->rts_threshold = DEFAULT_RTS_THRESHOLD;
8738 else { 8746 else {
8739 if (wrqu->rts.value < MIN_RTS_THRESHOLD || 8747 if (wrqu->rts.value < MIN_RTS_THRESHOLD ||
8740 wrqu->rts.value > MAX_RTS_THRESHOLD) { 8748 wrqu->rts.value > MAX_RTS_THRESHOLD) {
8741 up(&priv->sem); 8749 mutex_unlock(&priv->mutex);
8742 return -EINVAL; 8750 return -EINVAL;
8743 } 8751 }
8744 priv->rts_threshold = wrqu->rts.value; 8752 priv->rts_threshold = wrqu->rts.value;
8745 } 8753 }
8746 8754
8747 ipw_send_rts_threshold(priv, priv->rts_threshold); 8755 ipw_send_rts_threshold(priv, priv->rts_threshold);
8748 up(&priv->sem); 8756 mutex_unlock(&priv->mutex);
8749 IPW_DEBUG_WX("SET RTS Threshold -> %d \n", priv->rts_threshold); 8757 IPW_DEBUG_WX("SET RTS Threshold -> %d \n", priv->rts_threshold);
8750 return 0; 8758 return 0;
8751} 8759}
@@ -8755,11 +8763,11 @@ static int ipw_wx_get_rts(struct net_device *dev,
8755 union iwreq_data *wrqu, char *extra) 8763 union iwreq_data *wrqu, char *extra)
8756{ 8764{
8757 struct ipw_priv *priv = ieee80211_priv(dev); 8765 struct ipw_priv *priv = ieee80211_priv(dev);
8758 down(&priv->sem); 8766 mutex_lock(&priv->mutex);
8759 wrqu->rts.value = priv->rts_threshold; 8767 wrqu->rts.value = priv->rts_threshold;
8760 wrqu->rts.fixed = 0; /* no auto select */ 8768 wrqu->rts.fixed = 0; /* no auto select */
8761 wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); 8769 wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD);
8762 up(&priv->sem); 8770 mutex_unlock(&priv->mutex);
8763 IPW_DEBUG_WX("GET RTS Threshold -> %d \n", wrqu->rts.value); 8771 IPW_DEBUG_WX("GET RTS Threshold -> %d \n", wrqu->rts.value);
8764 return 0; 8772 return 0;
8765} 8773}
@@ -8771,7 +8779,7 @@ static int ipw_wx_set_txpow(struct net_device *dev,
8771 struct ipw_priv *priv = ieee80211_priv(dev); 8779 struct ipw_priv *priv = ieee80211_priv(dev);
8772 int err = 0; 8780 int err = 0;
8773 8781
8774 down(&priv->sem); 8782 mutex_lock(&priv->mutex);
8775 if (ipw_radio_kill_sw(priv, wrqu->power.disabled)) { 8783 if (ipw_radio_kill_sw(priv, wrqu->power.disabled)) {
8776 err = -EINPROGRESS; 8784 err = -EINPROGRESS;
8777 goto out; 8785 goto out;
@@ -8794,7 +8802,7 @@ static int ipw_wx_set_txpow(struct net_device *dev,
8794 priv->tx_power = wrqu->power.value; 8802 priv->tx_power = wrqu->power.value;
8795 err = ipw_set_tx_power(priv); 8803 err = ipw_set_tx_power(priv);
8796 out: 8804 out:
8797 up(&priv->sem); 8805 mutex_unlock(&priv->mutex);
8798 return err; 8806 return err;
8799} 8807}
8800 8808
@@ -8803,12 +8811,12 @@ static int ipw_wx_get_txpow(struct net_device *dev,
8803 union iwreq_data *wrqu, char *extra) 8811 union iwreq_data *wrqu, char *extra)
8804{ 8812{
8805 struct ipw_priv *priv = ieee80211_priv(dev); 8813 struct ipw_priv *priv = ieee80211_priv(dev);
8806 down(&priv->sem); 8814 mutex_lock(&priv->mutex);
8807 wrqu->power.value = priv->tx_power; 8815 wrqu->power.value = priv->tx_power;
8808 wrqu->power.fixed = 1; 8816 wrqu->power.fixed = 1;
8809 wrqu->power.flags = IW_TXPOW_DBM; 8817 wrqu->power.flags = IW_TXPOW_DBM;
8810 wrqu->power.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0; 8818 wrqu->power.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0;
8811 up(&priv->sem); 8819 mutex_unlock(&priv->mutex);
8812 8820
8813 IPW_DEBUG_WX("GET TX Power -> %s %d \n", 8821 IPW_DEBUG_WX("GET TX Power -> %s %d \n",
8814 wrqu->power.disabled ? "OFF" : "ON", wrqu->power.value); 8822 wrqu->power.disabled ? "OFF" : "ON", wrqu->power.value);
@@ -8821,13 +8829,13 @@ static int ipw_wx_set_frag(struct net_device *dev,
8821 union iwreq_data *wrqu, char *extra) 8829 union iwreq_data *wrqu, char *extra)
8822{ 8830{
8823 struct ipw_priv *priv = ieee80211_priv(dev); 8831 struct ipw_priv *priv = ieee80211_priv(dev);
8824 down(&priv->sem); 8832 mutex_lock(&priv->mutex);
8825 if (wrqu->frag.disabled) 8833 if (wrqu->frag.disabled)
8826 priv->ieee->fts = DEFAULT_FTS; 8834 priv->ieee->fts = DEFAULT_FTS;
8827 else { 8835 else {
8828 if (wrqu->frag.value < MIN_FRAG_THRESHOLD || 8836 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
8829 wrqu->frag.value > MAX_FRAG_THRESHOLD) { 8837 wrqu->frag.value > MAX_FRAG_THRESHOLD) {
8830 up(&priv->sem); 8838 mutex_unlock(&priv->mutex);
8831 return -EINVAL; 8839 return -EINVAL;
8832 } 8840 }
8833 8841
@@ -8835,7 +8843,7 @@ static int ipw_wx_set_frag(struct net_device *dev,
8835 } 8843 }
8836 8844
8837 ipw_send_frag_threshold(priv, wrqu->frag.value); 8845 ipw_send_frag_threshold(priv, wrqu->frag.value);
8838 up(&priv->sem); 8846 mutex_unlock(&priv->mutex);
8839 IPW_DEBUG_WX("SET Frag Threshold -> %d \n", wrqu->frag.value); 8847 IPW_DEBUG_WX("SET Frag Threshold -> %d \n", wrqu->frag.value);
8840 return 0; 8848 return 0;
8841} 8849}
@@ -8845,11 +8853,11 @@ static int ipw_wx_get_frag(struct net_device *dev,
8845 union iwreq_data *wrqu, char *extra) 8853 union iwreq_data *wrqu, char *extra)
8846{ 8854{
8847 struct ipw_priv *priv = ieee80211_priv(dev); 8855 struct ipw_priv *priv = ieee80211_priv(dev);
8848 down(&priv->sem); 8856 mutex_lock(&priv->mutex);
8849 wrqu->frag.value = priv->ieee->fts; 8857 wrqu->frag.value = priv->ieee->fts;
8850 wrqu->frag.fixed = 0; /* no auto select */ 8858 wrqu->frag.fixed = 0; /* no auto select */
8851 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FTS); 8859 wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FTS);
8852 up(&priv->sem); 8860 mutex_unlock(&priv->mutex);
8853 IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu->frag.value); 8861 IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu->frag.value);
8854 8862
8855 return 0; 8863 return 0;
@@ -8870,7 +8878,7 @@ static int ipw_wx_set_retry(struct net_device *dev,
8870 if (wrqu->retry.value < 0 || wrqu->retry.value > 255) 8878 if (wrqu->retry.value < 0 || wrqu->retry.value > 255)
8871 return -EINVAL; 8879 return -EINVAL;
8872 8880
8873 down(&priv->sem); 8881 mutex_lock(&priv->mutex);
8874 if (wrqu->retry.flags & IW_RETRY_MIN) 8882 if (wrqu->retry.flags & IW_RETRY_MIN)
8875 priv->short_retry_limit = (u8) wrqu->retry.value; 8883 priv->short_retry_limit = (u8) wrqu->retry.value;
8876 else if (wrqu->retry.flags & IW_RETRY_MAX) 8884 else if (wrqu->retry.flags & IW_RETRY_MAX)
@@ -8882,7 +8890,7 @@ static int ipw_wx_set_retry(struct net_device *dev,
8882 8890
8883 ipw_send_retry_limit(priv, priv->short_retry_limit, 8891 ipw_send_retry_limit(priv, priv->short_retry_limit,
8884 priv->long_retry_limit); 8892 priv->long_retry_limit);
8885 up(&priv->sem); 8893 mutex_unlock(&priv->mutex);
8886 IPW_DEBUG_WX("SET retry limit -> short:%d long:%d\n", 8894 IPW_DEBUG_WX("SET retry limit -> short:%d long:%d\n",
8887 priv->short_retry_limit, priv->long_retry_limit); 8895 priv->short_retry_limit, priv->long_retry_limit);
8888 return 0; 8896 return 0;
@@ -8894,11 +8902,11 @@ static int ipw_wx_get_retry(struct net_device *dev,
8894{ 8902{
8895 struct ipw_priv *priv = ieee80211_priv(dev); 8903 struct ipw_priv *priv = ieee80211_priv(dev);
8896 8904
8897 down(&priv->sem); 8905 mutex_lock(&priv->mutex);
8898 wrqu->retry.disabled = 0; 8906 wrqu->retry.disabled = 0;
8899 8907
8900 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { 8908 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
8901 up(&priv->sem); 8909 mutex_unlock(&priv->mutex);
8902 return -EINVAL; 8910 return -EINVAL;
8903 } 8911 }
8904 8912
@@ -8912,7 +8920,7 @@ static int ipw_wx_get_retry(struct net_device *dev,
8912 wrqu->retry.flags = IW_RETRY_LIMIT; 8920 wrqu->retry.flags = IW_RETRY_LIMIT;
8913 wrqu->retry.value = priv->short_retry_limit; 8921 wrqu->retry.value = priv->short_retry_limit;
8914 } 8922 }
8915 up(&priv->sem); 8923 mutex_unlock(&priv->mutex);
8916 8924
8917 IPW_DEBUG_WX("GET retry -> %d \n", wrqu->retry.value); 8925 IPW_DEBUG_WX("GET retry -> %d \n", wrqu->retry.value);
8918 8926
@@ -8929,7 +8937,7 @@ static int ipw_request_direct_scan(struct ipw_priv *priv, char *essid,
8929 (priv->status & STATUS_EXIT_PENDING)) 8937 (priv->status & STATUS_EXIT_PENDING))
8930 return 0; 8938 return 0;
8931 8939
8932 down(&priv->sem); 8940 mutex_lock(&priv->mutex);
8933 8941
8934 if (priv->status & STATUS_RF_KILL_MASK) { 8942 if (priv->status & STATUS_RF_KILL_MASK) {
8935 IPW_DEBUG_HC("Aborting scan due to RF kill activation\n"); 8943 IPW_DEBUG_HC("Aborting scan due to RF kill activation\n");
@@ -8981,7 +8989,7 @@ static int ipw_request_direct_scan(struct ipw_priv *priv, char *essid,
8981 priv->status |= STATUS_SCANNING; 8989 priv->status |= STATUS_SCANNING;
8982 8990
8983 done: 8991 done:
8984 up(&priv->sem); 8992 mutex_unlock(&priv->mutex);
8985 return err; 8993 return err;
8986} 8994}
8987 8995
@@ -9024,7 +9032,7 @@ static int ipw_wx_set_encode(struct net_device *dev,
9024 int ret; 9032 int ret;
9025 u32 cap = priv->capability; 9033 u32 cap = priv->capability;
9026 9034
9027 down(&priv->sem); 9035 mutex_lock(&priv->mutex);
9028 ret = ieee80211_wx_set_encode(priv->ieee, info, wrqu, key); 9036 ret = ieee80211_wx_set_encode(priv->ieee, info, wrqu, key);
9029 9037
9030 /* In IBSS mode, we need to notify the firmware to update 9038 /* In IBSS mode, we need to notify the firmware to update
@@ -9034,7 +9042,7 @@ static int ipw_wx_set_encode(struct net_device *dev,
9034 priv->status & STATUS_ASSOCIATED) 9042 priv->status & STATUS_ASSOCIATED)
9035 ipw_disassociate(priv); 9043 ipw_disassociate(priv);
9036 9044
9037 up(&priv->sem); 9045 mutex_unlock(&priv->mutex);
9038 return ret; 9046 return ret;
9039} 9047}
9040 9048
@@ -9052,17 +9060,17 @@ static int ipw_wx_set_power(struct net_device *dev,
9052{ 9060{
9053 struct ipw_priv *priv = ieee80211_priv(dev); 9061 struct ipw_priv *priv = ieee80211_priv(dev);
9054 int err; 9062 int err;
9055 down(&priv->sem); 9063 mutex_lock(&priv->mutex);
9056 if (wrqu->power.disabled) { 9064 if (wrqu->power.disabled) {
9057 priv->power_mode = IPW_POWER_LEVEL(priv->power_mode); 9065 priv->power_mode = IPW_POWER_LEVEL(priv->power_mode);
9058 err = ipw_send_power_mode(priv, IPW_POWER_MODE_CAM); 9066 err = ipw_send_power_mode(priv, IPW_POWER_MODE_CAM);
9059 if (err) { 9067 if (err) {
9060 IPW_DEBUG_WX("failed setting power mode.\n"); 9068 IPW_DEBUG_WX("failed setting power mode.\n");
9061 up(&priv->sem); 9069 mutex_unlock(&priv->mutex);
9062 return err; 9070 return err;
9063 } 9071 }
9064 IPW_DEBUG_WX("SET Power Management Mode -> off\n"); 9072 IPW_DEBUG_WX("SET Power Management Mode -> off\n");
9065 up(&priv->sem); 9073 mutex_unlock(&priv->mutex);
9066 return 0; 9074 return 0;
9067 } 9075 }
9068 9076
@@ -9074,7 +9082,7 @@ static int ipw_wx_set_power(struct net_device *dev,
9074 default: /* Otherwise we don't support it */ 9082 default: /* Otherwise we don't support it */
9075 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n", 9083 IPW_DEBUG_WX("SET PM Mode: %X not supported.\n",
9076 wrqu->power.flags); 9084 wrqu->power.flags);
9077 up(&priv->sem); 9085 mutex_unlock(&priv->mutex);
9078 return -EOPNOTSUPP; 9086 return -EOPNOTSUPP;
9079 } 9087 }
9080 9088
@@ -9087,12 +9095,12 @@ static int ipw_wx_set_power(struct net_device *dev,
9087 err = ipw_send_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode)); 9095 err = ipw_send_power_mode(priv, IPW_POWER_LEVEL(priv->power_mode));
9088 if (err) { 9096 if (err) {
9089 IPW_DEBUG_WX("failed setting power mode.\n"); 9097 IPW_DEBUG_WX("failed setting power mode.\n");
9090 up(&priv->sem); 9098 mutex_unlock(&priv->mutex);
9091 return err; 9099 return err;
9092 } 9100 }
9093 9101
9094 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode); 9102 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode);
9095 up(&priv->sem); 9103 mutex_unlock(&priv->mutex);
9096 return 0; 9104 return 0;
9097} 9105}
9098 9106
@@ -9101,13 +9109,13 @@ static int ipw_wx_get_power(struct net_device *dev,
9101 union iwreq_data *wrqu, char *extra) 9109 union iwreq_data *wrqu, char *extra)
9102{ 9110{
9103 struct ipw_priv *priv = ieee80211_priv(dev); 9111 struct ipw_priv *priv = ieee80211_priv(dev);
9104 down(&priv->sem); 9112 mutex_lock(&priv->mutex);
9105 if (!(priv->power_mode & IPW_POWER_ENABLED)) 9113 if (!(priv->power_mode & IPW_POWER_ENABLED))
9106 wrqu->power.disabled = 1; 9114 wrqu->power.disabled = 1;
9107 else 9115 else
9108 wrqu->power.disabled = 0; 9116 wrqu->power.disabled = 0;
9109 9117
9110 up(&priv->sem); 9118 mutex_unlock(&priv->mutex);
9111 IPW_DEBUG_WX("GET Power Management Mode -> %02X\n", priv->power_mode); 9119 IPW_DEBUG_WX("GET Power Management Mode -> %02X\n", priv->power_mode);
9112 9120
9113 return 0; 9121 return 0;
@@ -9120,7 +9128,7 @@ static int ipw_wx_set_powermode(struct net_device *dev,
9120 struct ipw_priv *priv = ieee80211_priv(dev); 9128 struct ipw_priv *priv = ieee80211_priv(dev);
9121 int mode = *(int *)extra; 9129 int mode = *(int *)extra;
9122 int err; 9130 int err;
9123 down(&priv->sem); 9131 mutex_lock(&priv->mutex);
9124 if ((mode < 1) || (mode > IPW_POWER_LIMIT)) { 9132 if ((mode < 1) || (mode > IPW_POWER_LIMIT)) {
9125 mode = IPW_POWER_AC; 9133 mode = IPW_POWER_AC;
9126 priv->power_mode = mode; 9134 priv->power_mode = mode;
@@ -9133,11 +9141,11 @@ static int ipw_wx_set_powermode(struct net_device *dev,
9133 9141
9134 if (err) { 9142 if (err) {
9135 IPW_DEBUG_WX("failed setting power mode.\n"); 9143 IPW_DEBUG_WX("failed setting power mode.\n");
9136 up(&priv->sem); 9144 mutex_unlock(&priv->mutex);
9137 return err; 9145 return err;
9138 } 9146 }
9139 } 9147 }
9140 up(&priv->sem); 9148 mutex_unlock(&priv->mutex);
9141 return 0; 9149 return 0;
9142} 9150}
9143 9151
@@ -9186,7 +9194,7 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
9186 IPW_WARNING("Attempt to set invalid wireless mode: %d\n", mode); 9194 IPW_WARNING("Attempt to set invalid wireless mode: %d\n", mode);
9187 return -EINVAL; 9195 return -EINVAL;
9188 } 9196 }
9189 down(&priv->sem); 9197 mutex_lock(&priv->mutex);
9190 if (priv->adapter == IPW_2915ABG) { 9198 if (priv->adapter == IPW_2915ABG) {
9191 priv->ieee->abg_true = 1; 9199 priv->ieee->abg_true = 1;
9192 if (mode & IEEE_A) { 9200 if (mode & IEEE_A) {
@@ -9198,7 +9206,7 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
9198 if (mode & IEEE_A) { 9206 if (mode & IEEE_A) {
9199 IPW_WARNING("Attempt to set 2200BG into " 9207 IPW_WARNING("Attempt to set 2200BG into "
9200 "802.11a mode\n"); 9208 "802.11a mode\n");
9201 up(&priv->sem); 9209 mutex_unlock(&priv->mutex);
9202 return -EINVAL; 9210 return -EINVAL;
9203 } 9211 }
9204 9212
@@ -9235,7 +9243,7 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
9235 IPW_DEBUG_WX("PRIV SET MODE: %c%c%c\n", 9243 IPW_DEBUG_WX("PRIV SET MODE: %c%c%c\n",
9236 mode & IEEE_A ? 'a' : '.', 9244 mode & IEEE_A ? 'a' : '.',
9237 mode & IEEE_B ? 'b' : '.', mode & IEEE_G ? 'g' : '.'); 9245 mode & IEEE_B ? 'b' : '.', mode & IEEE_G ? 'g' : '.');
9238 up(&priv->sem); 9246 mutex_unlock(&priv->mutex);
9239 return 0; 9247 return 0;
9240} 9248}
9241 9249
@@ -9244,7 +9252,7 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev,
9244 union iwreq_data *wrqu, char *extra) 9252 union iwreq_data *wrqu, char *extra)
9245{ 9253{
9246 struct ipw_priv *priv = ieee80211_priv(dev); 9254 struct ipw_priv *priv = ieee80211_priv(dev);
9247 down(&priv->sem); 9255 mutex_lock(&priv->mutex);
9248 switch (priv->ieee->mode) { 9256 switch (priv->ieee->mode) {
9249 case IEEE_A: 9257 case IEEE_A:
9250 strncpy(extra, "802.11a (1)", MAX_WX_STRING); 9258 strncpy(extra, "802.11a (1)", MAX_WX_STRING);
@@ -9275,7 +9283,7 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev,
9275 IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra); 9283 IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra);
9276 9284
9277 wrqu->data.length = strlen(extra) + 1; 9285 wrqu->data.length = strlen(extra) + 1;
9278 up(&priv->sem); 9286 mutex_unlock(&priv->mutex);
9279 9287
9280 return 0; 9288 return 0;
9281} 9289}
@@ -9286,7 +9294,7 @@ static int ipw_wx_set_preamble(struct net_device *dev,
9286{ 9294{
9287 struct ipw_priv *priv = ieee80211_priv(dev); 9295 struct ipw_priv *priv = ieee80211_priv(dev);
9288 int mode = *(int *)extra; 9296 int mode = *(int *)extra;
9289 down(&priv->sem); 9297 mutex_lock(&priv->mutex);
9290 /* Switching from SHORT -> LONG requires a disassociation */ 9298 /* Switching from SHORT -> LONG requires a disassociation */
9291 if (mode == 1) { 9299 if (mode == 1) {
9292 if (!(priv->config & CFG_PREAMBLE_LONG)) { 9300 if (!(priv->config & CFG_PREAMBLE_LONG)) {
@@ -9305,11 +9313,11 @@ static int ipw_wx_set_preamble(struct net_device *dev,
9305 priv->config &= ~CFG_PREAMBLE_LONG; 9313 priv->config &= ~CFG_PREAMBLE_LONG;
9306 goto done; 9314 goto done;
9307 } 9315 }
9308 up(&priv->sem); 9316 mutex_unlock(&priv->mutex);
9309 return -EINVAL; 9317 return -EINVAL;
9310 9318
9311 done: 9319 done:
9312 up(&priv->sem); 9320 mutex_unlock(&priv->mutex);
9313 return 0; 9321 return 0;
9314} 9322}
9315 9323
@@ -9318,12 +9326,12 @@ static int ipw_wx_get_preamble(struct net_device *dev,
9318 union iwreq_data *wrqu, char *extra) 9326 union iwreq_data *wrqu, char *extra)
9319{ 9327{
9320 struct ipw_priv *priv = ieee80211_priv(dev); 9328 struct ipw_priv *priv = ieee80211_priv(dev);
9321 down(&priv->sem); 9329 mutex_lock(&priv->mutex);
9322 if (priv->config & CFG_PREAMBLE_LONG) 9330 if (priv->config & CFG_PREAMBLE_LONG)
9323 snprintf(wrqu->name, IFNAMSIZ, "long (1)"); 9331 snprintf(wrqu->name, IFNAMSIZ, "long (1)");
9324 else 9332 else
9325 snprintf(wrqu->name, IFNAMSIZ, "auto (0)"); 9333 snprintf(wrqu->name, IFNAMSIZ, "auto (0)");
9326 up(&priv->sem); 9334 mutex_unlock(&priv->mutex);
9327 return 0; 9335 return 0;
9328} 9336}
9329 9337
@@ -9335,7 +9343,7 @@ static int ipw_wx_set_monitor(struct net_device *dev,
9335 struct ipw_priv *priv = ieee80211_priv(dev); 9343 struct ipw_priv *priv = ieee80211_priv(dev);
9336 int *parms = (int *)extra; 9344 int *parms = (int *)extra;
9337 int enable = (parms[0] > 0); 9345 int enable = (parms[0] > 0);
9338 down(&priv->sem); 9346 mutex_lock(&priv->mutex);
9339 IPW_DEBUG_WX("SET MONITOR: %d %d\n", enable, parms[1]); 9347 IPW_DEBUG_WX("SET MONITOR: %d %d\n", enable, parms[1]);
9340 if (enable) { 9348 if (enable) {
9341 if (priv->ieee->iw_mode != IW_MODE_MONITOR) { 9349 if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
@@ -9350,13 +9358,13 @@ static int ipw_wx_set_monitor(struct net_device *dev,
9350 ipw_set_channel(priv, parms[1]); 9358 ipw_set_channel(priv, parms[1]);
9351 } else { 9359 } else {
9352 if (priv->ieee->iw_mode != IW_MODE_MONITOR) { 9360 if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
9353 up(&priv->sem); 9361 mutex_unlock(&priv->mutex);
9354 return 0; 9362 return 0;
9355 } 9363 }
9356 priv->net_dev->type = ARPHRD_ETHER; 9364 priv->net_dev->type = ARPHRD_ETHER;
9357 queue_work(priv->workqueue, &priv->adapter_restart); 9365 queue_work(priv->workqueue, &priv->adapter_restart);
9358 } 9366 }
9359 up(&priv->sem); 9367 mutex_unlock(&priv->mutex);
9360 return 0; 9368 return 0;
9361} 9369}
9362 9370
@@ -9386,7 +9394,7 @@ static int ipw_wx_sw_reset(struct net_device *dev,
9386 9394
9387 IPW_DEBUG_WX("SW_RESET\n"); 9395 IPW_DEBUG_WX("SW_RESET\n");
9388 9396
9389 down(&priv->sem); 9397 mutex_lock(&priv->mutex);
9390 9398
9391 ret = ipw_sw_reset(priv, 0); 9399 ret = ipw_sw_reset(priv, 0);
9392 if (!ret) { 9400 if (!ret) {
@@ -9398,9 +9406,9 @@ static int ipw_wx_sw_reset(struct net_device *dev,
9398 * module parameter, so take appropriate action */ 9406 * module parameter, so take appropriate action */
9399 ipw_radio_kill_sw(priv, priv->status & STATUS_RF_KILL_SW); 9407 ipw_radio_kill_sw(priv, priv->status & STATUS_RF_KILL_SW);
9400 9408
9401 up(&priv->sem); 9409 mutex_unlock(&priv->mutex);
9402 ieee80211_wx_set_encode(priv->ieee, info, &wrqu_sec, NULL); 9410 ieee80211_wx_set_encode(priv->ieee, info, &wrqu_sec, NULL);
9403 down(&priv->sem); 9411 mutex_lock(&priv->mutex);
9404 9412
9405 if (!(priv->status & STATUS_RF_KILL_MASK)) { 9413 if (!(priv->status & STATUS_RF_KILL_MASK)) {
9406 /* Configuration likely changed -- force [re]association */ 9414 /* Configuration likely changed -- force [re]association */
@@ -9410,7 +9418,7 @@ static int ipw_wx_sw_reset(struct net_device *dev,
9410 ipw_associate(priv); 9418 ipw_associate(priv);
9411 } 9419 }
9412 9420
9413 up(&priv->sem); 9421 mutex_unlock(&priv->mutex);
9414 9422
9415 return 0; 9423 return 0;
9416} 9424}
@@ -9586,7 +9594,7 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev)
9586static void init_sys_config(struct ipw_sys_config *sys_config) 9594static void init_sys_config(struct ipw_sys_config *sys_config)
9587{ 9595{
9588 memset(sys_config, 0, sizeof(struct ipw_sys_config)); 9596 memset(sys_config, 0, sizeof(struct ipw_sys_config));
9589 sys_config->bt_coexistence = 1; /* We may need to look into prvStaBtConfig */ 9597 sys_config->bt_coexistence = 0;
9590 sys_config->answer_broadcast_ssid_probe = 0; 9598 sys_config->answer_broadcast_ssid_probe = 0;
9591 sys_config->accept_all_data_frames = 0; 9599 sys_config->accept_all_data_frames = 0;
9592 sys_config->accept_non_directed_frames = 1; 9600 sys_config->accept_non_directed_frames = 1;
@@ -9607,11 +9615,11 @@ static int ipw_net_open(struct net_device *dev)
9607 struct ipw_priv *priv = ieee80211_priv(dev); 9615 struct ipw_priv *priv = ieee80211_priv(dev);
9608 IPW_DEBUG_INFO("dev->open\n"); 9616 IPW_DEBUG_INFO("dev->open\n");
9609 /* we should be verifying the device is ready to be opened */ 9617 /* we should be verifying the device is ready to be opened */
9610 down(&priv->sem); 9618 mutex_lock(&priv->mutex);
9611 if (!(priv->status & STATUS_RF_KILL_MASK) && 9619 if (!(priv->status & STATUS_RF_KILL_MASK) &&
9612 (priv->status & STATUS_ASSOCIATED)) 9620 (priv->status & STATUS_ASSOCIATED))
9613 netif_start_queue(dev); 9621 netif_start_queue(dev);
9614 up(&priv->sem); 9622 mutex_unlock(&priv->mutex);
9615 return 0; 9623 return 0;
9616} 9624}
9617 9625
@@ -9890,13 +9898,13 @@ static int ipw_net_set_mac_address(struct net_device *dev, void *p)
9890 struct sockaddr *addr = p; 9898 struct sockaddr *addr = p;
9891 if (!is_valid_ether_addr(addr->sa_data)) 9899 if (!is_valid_ether_addr(addr->sa_data))
9892 return -EADDRNOTAVAIL; 9900 return -EADDRNOTAVAIL;
9893 down(&priv->sem); 9901 mutex_lock(&priv->mutex);
9894 priv->config |= CFG_CUSTOM_MAC; 9902 priv->config |= CFG_CUSTOM_MAC;
9895 memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); 9903 memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN);
9896 printk(KERN_INFO "%s: Setting MAC to " MAC_FMT "\n", 9904 printk(KERN_INFO "%s: Setting MAC to " MAC_FMT "\n",
9897 priv->net_dev->name, MAC_ARG(priv->mac_addr)); 9905 priv->net_dev->name, MAC_ARG(priv->mac_addr));
9898 queue_work(priv->workqueue, &priv->adapter_restart); 9906 queue_work(priv->workqueue, &priv->adapter_restart);
9899 up(&priv->sem); 9907 mutex_unlock(&priv->mutex);
9900 return 0; 9908 return 0;
9901} 9909}
9902 9910
@@ -9940,9 +9948,9 @@ static int ipw_ethtool_get_eeprom(struct net_device *dev,
9940 9948
9941 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE) 9949 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE)
9942 return -EINVAL; 9950 return -EINVAL;
9943 down(&p->sem); 9951 mutex_lock(&p->mutex);
9944 memcpy(bytes, &p->eeprom[eeprom->offset], eeprom->len); 9952 memcpy(bytes, &p->eeprom[eeprom->offset], eeprom->len);
9945 up(&p->sem); 9953 mutex_unlock(&p->mutex);
9946 return 0; 9954 return 0;
9947} 9955}
9948 9956
@@ -9954,12 +9962,12 @@ static int ipw_ethtool_set_eeprom(struct net_device *dev,
9954 9962
9955 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE) 9963 if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE)
9956 return -EINVAL; 9964 return -EINVAL;
9957 down(&p->sem); 9965 mutex_lock(&p->mutex);
9958 memcpy(&p->eeprom[eeprom->offset], bytes, eeprom->len); 9966 memcpy(&p->eeprom[eeprom->offset], bytes, eeprom->len);
9959 for (i = IPW_EEPROM_DATA; 9967 for (i = IPW_EEPROM_DATA;
9960 i < IPW_EEPROM_DATA + IPW_EEPROM_IMAGE_SIZE; i++) 9968 i < IPW_EEPROM_DATA + IPW_EEPROM_IMAGE_SIZE; i++)
9961 ipw_write8(p, i, p->eeprom[i]); 9969 ipw_write8(p, i, p->eeprom[i]);
9962 up(&p->sem); 9970 mutex_unlock(&p->mutex);
9963 return 0; 9971 return 0;
9964} 9972}
9965 9973
@@ -10054,12 +10062,12 @@ static void ipw_rf_kill(void *adapter)
10054static void ipw_bg_rf_kill(void *data) 10062static void ipw_bg_rf_kill(void *data)
10055{ 10063{
10056 struct ipw_priv *priv = data; 10064 struct ipw_priv *priv = data;
10057 down(&priv->sem); 10065 mutex_lock(&priv->mutex);
10058 ipw_rf_kill(data); 10066 ipw_rf_kill(data);
10059 up(&priv->sem); 10067 mutex_unlock(&priv->mutex);
10060} 10068}
10061 10069
10062void ipw_link_up(struct ipw_priv *priv) 10070static void ipw_link_up(struct ipw_priv *priv)
10063{ 10071{
10064 priv->last_seq_num = -1; 10072 priv->last_seq_num = -1;
10065 priv->last_frag_num = -1; 10073 priv->last_frag_num = -1;
@@ -10089,12 +10097,12 @@ void ipw_link_up(struct ipw_priv *priv)
10089static void ipw_bg_link_up(void *data) 10097static void ipw_bg_link_up(void *data)
10090{ 10098{
10091 struct ipw_priv *priv = data; 10099 struct ipw_priv *priv = data;
10092 down(&priv->sem); 10100 mutex_lock(&priv->mutex);
10093 ipw_link_up(data); 10101 ipw_link_up(data);
10094 up(&priv->sem); 10102 mutex_unlock(&priv->mutex);
10095} 10103}
10096 10104
10097void ipw_link_down(struct ipw_priv *priv) 10105static void ipw_link_down(struct ipw_priv *priv)
10098{ 10106{
10099 ipw_led_link_down(priv); 10107 ipw_led_link_down(priv);
10100 netif_carrier_off(priv->net_dev); 10108 netif_carrier_off(priv->net_dev);
@@ -10117,9 +10125,9 @@ void ipw_link_down(struct ipw_priv *priv)
10117static void ipw_bg_link_down(void *data) 10125static void ipw_bg_link_down(void *data)
10118{ 10126{
10119 struct ipw_priv *priv = data; 10127 struct ipw_priv *priv = data;
10120 down(&priv->sem); 10128 mutex_lock(&priv->mutex);
10121 ipw_link_down(data); 10129 ipw_link_down(data);
10122 up(&priv->sem); 10130 mutex_unlock(&priv->mutex);
10123} 10131}
10124 10132
10125static int ipw_setup_deferred_work(struct ipw_priv *priv) 10133static int ipw_setup_deferred_work(struct ipw_priv *priv)
@@ -10292,6 +10300,20 @@ static int ipw_config(struct ipw_priv *priv)
10292 10300
10293 /* set basic system config settings */ 10301 /* set basic system config settings */
10294 init_sys_config(&priv->sys_config); 10302 init_sys_config(&priv->sys_config);
10303
10304 /* Support Bluetooth if we have BT h/w on board, and user wants to.
10305 * Does not support BT priority yet (don't abort or defer our Tx) */
10306 if (bt_coexist) {
10307 unsigned char bt_caps = priv->eeprom[EEPROM_SKU_CAPABILITY];
10308
10309 if (bt_caps & EEPROM_SKU_CAP_BT_CHANNEL_SIG)
10310 priv->sys_config.bt_coexistence
10311 |= CFG_BT_COEXISTENCE_SIGNAL_CHNL;
10312 if (bt_caps & EEPROM_SKU_CAP_BT_OOB)
10313 priv->sys_config.bt_coexistence
10314 |= CFG_BT_COEXISTENCE_OOB;
10315 }
10316
10295 if (priv->ieee->iw_mode == IW_MODE_ADHOC) 10317 if (priv->ieee->iw_mode == IW_MODE_ADHOC)
10296 priv->sys_config.answer_broadcast_ssid_probe = 1; 10318 priv->sys_config.answer_broadcast_ssid_probe = 1;
10297 else 10319 else
@@ -10782,9 +10804,9 @@ static int ipw_up(struct ipw_priv *priv)
10782static void ipw_bg_up(void *data) 10804static void ipw_bg_up(void *data)
10783{ 10805{
10784 struct ipw_priv *priv = data; 10806 struct ipw_priv *priv = data;
10785 down(&priv->sem); 10807 mutex_lock(&priv->mutex);
10786 ipw_up(data); 10808 ipw_up(data);
10787 up(&priv->sem); 10809 mutex_unlock(&priv->mutex);
10788} 10810}
10789 10811
10790static void ipw_deinit(struct ipw_priv *priv) 10812static void ipw_deinit(struct ipw_priv *priv)
@@ -10853,23 +10875,23 @@ static void ipw_down(struct ipw_priv *priv)
10853static void ipw_bg_down(void *data) 10875static void ipw_bg_down(void *data)
10854{ 10876{
10855 struct ipw_priv *priv = data; 10877 struct ipw_priv *priv = data;
10856 down(&priv->sem); 10878 mutex_lock(&priv->mutex);
10857 ipw_down(data); 10879 ipw_down(data);
10858 up(&priv->sem); 10880 mutex_unlock(&priv->mutex);
10859} 10881}
10860 10882
10861/* Called by register_netdev() */ 10883/* Called by register_netdev() */
10862static int ipw_net_init(struct net_device *dev) 10884static int ipw_net_init(struct net_device *dev)
10863{ 10885{
10864 struct ipw_priv *priv = ieee80211_priv(dev); 10886 struct ipw_priv *priv = ieee80211_priv(dev);
10865 down(&priv->sem); 10887 mutex_lock(&priv->mutex);
10866 10888
10867 if (ipw_up(priv)) { 10889 if (ipw_up(priv)) {
10868 up(&priv->sem); 10890 mutex_unlock(&priv->mutex);
10869 return -EIO; 10891 return -EIO;
10870 } 10892 }
10871 10893
10872 up(&priv->sem); 10894 mutex_unlock(&priv->mutex);
10873 return 0; 10895 return 0;
10874} 10896}
10875 10897
@@ -10959,7 +10981,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
10959 for (i = 0; i < IPW_IBSS_MAC_HASH_SIZE; i++) 10981 for (i = 0; i < IPW_IBSS_MAC_HASH_SIZE; i++)
10960 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]); 10982 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
10961 10983
10962 init_MUTEX(&priv->sem); 10984 mutex_init(&priv->mutex);
10963 if (pci_enable_device(pdev)) { 10985 if (pci_enable_device(pdev)) {
10964 err = -ENODEV; 10986 err = -ENODEV;
10965 goto out_free_ieee80211; 10987 goto out_free_ieee80211;
@@ -11017,7 +11039,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
11017 SET_MODULE_OWNER(net_dev); 11039 SET_MODULE_OWNER(net_dev);
11018 SET_NETDEV_DEV(net_dev, &pdev->dev); 11040 SET_NETDEV_DEV(net_dev, &pdev->dev);
11019 11041
11020 down(&priv->sem); 11042 mutex_lock(&priv->mutex);
11021 11043
11022 priv->ieee->hard_start_xmit = ipw_net_hard_start_xmit; 11044 priv->ieee->hard_start_xmit = ipw_net_hard_start_xmit;
11023 priv->ieee->set_security = shim__set_security; 11045 priv->ieee->set_security = shim__set_security;
@@ -11050,11 +11072,11 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
11050 err = sysfs_create_group(&pdev->dev.kobj, &ipw_attribute_group); 11072 err = sysfs_create_group(&pdev->dev.kobj, &ipw_attribute_group);
11051 if (err) { 11073 if (err) {
11052 IPW_ERROR("failed to create sysfs device attributes\n"); 11074 IPW_ERROR("failed to create sysfs device attributes\n");
11053 up(&priv->sem); 11075 mutex_unlock(&priv->mutex);
11054 goto out_release_irq; 11076 goto out_release_irq;
11055 } 11077 }
11056 11078
11057 up(&priv->sem); 11079 mutex_unlock(&priv->mutex);
11058 err = register_netdev(net_dev); 11080 err = register_netdev(net_dev);
11059 if (err) { 11081 if (err) {
11060 IPW_ERROR("failed to register network device\n"); 11082 IPW_ERROR("failed to register network device\n");
@@ -11091,13 +11113,13 @@ static void ipw_pci_remove(struct pci_dev *pdev)
11091 if (!priv) 11113 if (!priv)
11092 return; 11114 return;
11093 11115
11094 down(&priv->sem); 11116 mutex_lock(&priv->mutex);
11095 11117
11096 priv->status |= STATUS_EXIT_PENDING; 11118 priv->status |= STATUS_EXIT_PENDING;
11097 ipw_down(priv); 11119 ipw_down(priv);
11098 sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group); 11120 sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group);
11099 11121
11100 up(&priv->sem); 11122 mutex_unlock(&priv->mutex);
11101 11123
11102 unregister_netdev(priv->net_dev); 11124 unregister_netdev(priv->net_dev);
11103 11125
@@ -11281,12 +11303,18 @@ module_param(mode, int, 0444);
11281MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS)"); 11303MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS)");
11282#endif 11304#endif
11283 11305
11306module_param(bt_coexist, int, 0444);
11307MODULE_PARM_DESC(bt_coexist, "enable bluetooth coexistence (default off)");
11308
11284module_param(hwcrypto, int, 0444); 11309module_param(hwcrypto, int, 0444);
11285MODULE_PARM_DESC(hwcrypto, "enable hardware crypto (default on)"); 11310MODULE_PARM_DESC(hwcrypto, "enable hardware crypto (default off)");
11286 11311
11287module_param(cmdlog, int, 0444); 11312module_param(cmdlog, int, 0444);
11288MODULE_PARM_DESC(cmdlog, 11313MODULE_PARM_DESC(cmdlog,
11289 "allocate a ring buffer for logging firmware commands"); 11314 "allocate a ring buffer for logging firmware commands");
11290 11315
11316module_param(roaming, int, 0444);
11317MODULE_PARM_DESC(roaming, "enable roaming support (default on)");
11318
11291module_exit(ipw_exit); 11319module_exit(ipw_exit);
11292module_init(ipw_init); 11320module_init(ipw_init);
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index e65620a4d79e..5405ba105abf 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -33,6 +33,7 @@
33#include <linux/moduleparam.h> 33#include <linux/moduleparam.h>
34#include <linux/config.h> 34#include <linux/config.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/mutex.h>
36 37
37#include <linux/pci.h> 38#include <linux/pci.h>
38#include <linux/netdevice.h> 39#include <linux/netdevice.h>
@@ -46,6 +47,7 @@
46#include <linux/firmware.h> 47#include <linux/firmware.h>
47#include <linux/wireless.h> 48#include <linux/wireless.h>
48#include <linux/dma-mapping.h> 49#include <linux/dma-mapping.h>
50#include <linux/jiffies.h>
49#include <asm/io.h> 51#include <asm/io.h>
50 52
51#include <net/ieee80211.h> 53#include <net/ieee80211.h>
@@ -852,7 +854,7 @@ struct ipw_scan_request_ext {
852 u16 dwell_time[IPW_SCAN_TYPES]; 854 u16 dwell_time[IPW_SCAN_TYPES];
853} __attribute__ ((packed)); 855} __attribute__ ((packed));
854 856
855extern inline u8 ipw_get_scan_type(struct ipw_scan_request_ext *scan, u8 index) 857static inline u8 ipw_get_scan_type(struct ipw_scan_request_ext *scan, u8 index)
856{ 858{
857 if (index % 2) 859 if (index % 2)
858 return scan->scan_type[index / 2] & 0x0F; 860 return scan->scan_type[index / 2] & 0x0F;
@@ -860,7 +862,7 @@ extern inline u8 ipw_get_scan_type(struct ipw_scan_request_ext *scan, u8 index)
860 return (scan->scan_type[index / 2] & 0xF0) >> 4; 862 return (scan->scan_type[index / 2] & 0xF0) >> 4;
861} 863}
862 864
863extern inline void ipw_set_scan_type(struct ipw_scan_request_ext *scan, 865static inline void ipw_set_scan_type(struct ipw_scan_request_ext *scan,
864 u8 index, u8 scan_type) 866 u8 index, u8 scan_type)
865{ 867{
866 if (index % 2) 868 if (index % 2)
@@ -1120,7 +1122,7 @@ struct ipw_priv {
1120 struct ieee80211_device *ieee; 1122 struct ieee80211_device *ieee;
1121 1123
1122 spinlock_t lock; 1124 spinlock_t lock;
1123 struct semaphore sem; 1125 struct mutex mutex;
1124 1126
1125 /* basic pci-network driver stuff */ 1127 /* basic pci-network driver stuff */
1126 struct pci_dev *pci_dev; 1128 struct pci_dev *pci_dev;
@@ -1406,13 +1408,6 @@ do { if (ipw_debug_level & (level)) \
1406* Register bit definitions 1408* Register bit definitions
1407*/ 1409*/
1408 1410
1409/* Dino control registers bits */
1410
1411#define DINO_ENABLE_SYSTEM 0x80
1412#define DINO_ENABLE_CS 0x40
1413#define DINO_RXFIFO_DATA 0x01
1414#define DINO_CONTROL_REG 0x00200000
1415
1416#define IPW_INTA_RW 0x00000008 1411#define IPW_INTA_RW 0x00000008
1417#define IPW_INTA_MASK_R 0x0000000C 1412#define IPW_INTA_MASK_R 0x0000000C
1418#define IPW_INDIRECT_ADDR 0x00000010 1413#define IPW_INDIRECT_ADDR 0x00000010
@@ -1459,6 +1454,11 @@ do { if (ipw_debug_level & (level)) \
1459#define IPW_DOMAIN_0_END 0x1000 1454#define IPW_DOMAIN_0_END 0x1000
1460#define CLX_MEM_BAR_SIZE 0x1000 1455#define CLX_MEM_BAR_SIZE 0x1000
1461 1456
1457/* Dino/baseband control registers bits */
1458
1459#define DINO_ENABLE_SYSTEM 0x80 /* 1 = baseband processor on, 0 = reset */
1460#define DINO_ENABLE_CS 0x40 /* 1 = enable ucode load */
1461#define DINO_RXFIFO_DATA 0x01 /* 1 = data available */
1462#define IPW_BASEBAND_CONTROL_STATUS 0X00200000 1462#define IPW_BASEBAND_CONTROL_STATUS 0X00200000
1463#define IPW_BASEBAND_TX_FIFO_WRITE 0X00200004 1463#define IPW_BASEBAND_TX_FIFO_WRITE 0X00200004
1464#define IPW_BASEBAND_RX_FIFO_READ 0X00200004 1464#define IPW_BASEBAND_RX_FIFO_READ 0X00200004
@@ -1567,13 +1567,18 @@ do { if (ipw_debug_level & (level)) \
1567#define EEPROM_BSS_CHANNELS_BG (GET_EEPROM_ADDR(0x2c,LSB)) /* 2 bytes */ 1567#define EEPROM_BSS_CHANNELS_BG (GET_EEPROM_ADDR(0x2c,LSB)) /* 2 bytes */
1568#define EEPROM_HW_VERSION (GET_EEPROM_ADDR(0x72,LSB)) /* 2 bytes */ 1568#define EEPROM_HW_VERSION (GET_EEPROM_ADDR(0x72,LSB)) /* 2 bytes */
1569 1569
1570/* NIC type as found in the one byte EEPROM_NIC_TYPE offset*/ 1570/* NIC type as found in the one byte EEPROM_NIC_TYPE offset */
1571#define EEPROM_NIC_TYPE_0 0 1571#define EEPROM_NIC_TYPE_0 0
1572#define EEPROM_NIC_TYPE_1 1 1572#define EEPROM_NIC_TYPE_1 1
1573#define EEPROM_NIC_TYPE_2 2 1573#define EEPROM_NIC_TYPE_2 2
1574#define EEPROM_NIC_TYPE_3 3 1574#define EEPROM_NIC_TYPE_3 3
1575#define EEPROM_NIC_TYPE_4 4 1575#define EEPROM_NIC_TYPE_4 4
1576 1576
1577/* Bluetooth Coexistence capabilities as found in EEPROM_SKU_CAPABILITY */
1578#define EEPROM_SKU_CAP_BT_CHANNEL_SIG 0x01 /* we can tell BT our channel # */
1579#define EEPROM_SKU_CAP_BT_PRIORITY 0x02 /* BT can take priority over us */
1580#define EEPROM_SKU_CAP_BT_OOB 0x04 /* we can signal BT out-of-band */
1581
1577#define FW_MEM_REG_LOWER_BOUND 0x00300000 1582#define FW_MEM_REG_LOWER_BOUND 0x00300000
1578#define FW_MEM_REG_EEPROM_ACCESS (FW_MEM_REG_LOWER_BOUND + 0x40) 1583#define FW_MEM_REG_EEPROM_ACCESS (FW_MEM_REG_LOWER_BOUND + 0x40)
1579#define IPW_EVENT_REG (FW_MEM_REG_LOWER_BOUND + 0x04) 1584#define IPW_EVENT_REG (FW_MEM_REG_LOWER_BOUND + 0x04)
@@ -1658,9 +1663,10 @@ enum {
1658 IPW_FW_ERROR_FATAL_ERROR 1663 IPW_FW_ERROR_FATAL_ERROR
1659}; 1664};
1660 1665
1661#define AUTH_OPEN 0 1666#define AUTH_OPEN 0
1662#define AUTH_SHARED_KEY 1 1667#define AUTH_SHARED_KEY 1
1663#define AUTH_IGNORE 3 1668#define AUTH_LEAP 2
1669#define AUTH_IGNORE 3
1664 1670
1665#define HC_ASSOCIATE 0 1671#define HC_ASSOCIATE 0
1666#define HC_REASSOCIATE 1 1672#define HC_REASSOCIATE 1
@@ -1860,7 +1866,7 @@ struct host_cmd {
1860 u8 cmd; 1866 u8 cmd;
1861 u8 len; 1867 u8 len;
1862 u16 reserved; 1868 u16 reserved;
1863 u32 param[TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH]; 1869 u32 *param;
1864} __attribute__ ((packed)); 1870} __attribute__ ((packed));
1865 1871
1866struct ipw_cmd_log { 1872struct ipw_cmd_log {
@@ -1869,21 +1875,23 @@ struct ipw_cmd_log {
1869 struct host_cmd cmd; 1875 struct host_cmd cmd;
1870}; 1876};
1871 1877
1872#define CFG_BT_COEXISTENCE_MIN 0x00 1878/* SysConfig command parameters ... */
1873#define CFG_BT_COEXISTENCE_DEFER 0x02 1879/* bt_coexistence param */
1874#define CFG_BT_COEXISTENCE_KILL 0x04 1880#define CFG_BT_COEXISTENCE_SIGNAL_CHNL 0x01 /* tell BT our chnl # */
1875#define CFG_BT_COEXISTENCE_WME_OVER_BT 0x08 1881#define CFG_BT_COEXISTENCE_DEFER 0x02 /* defer our Tx if BT traffic */
1876#define CFG_BT_COEXISTENCE_OOB 0x10 1882#define CFG_BT_COEXISTENCE_KILL 0x04 /* kill our Tx if BT traffic */
1877#define CFG_BT_COEXISTENCE_MAX 0xFF 1883#define CFG_BT_COEXISTENCE_WME_OVER_BT 0x08 /* multimedia extensions */
1878#define CFG_BT_COEXISTENCE_DEF 0x80 /* read Bt from EEPROM */ 1884#define CFG_BT_COEXISTENCE_OOB 0x10 /* signal BT via out-of-band */
1879 1885
1880#define CFG_CTS_TO_ITSELF_ENABLED_MIN 0x0 1886/* clear-to-send to self param */
1881#define CFG_CTS_TO_ITSELF_ENABLED_MAX 0x1 1887#define CFG_CTS_TO_ITSELF_ENABLED_MIN 0x00
1888#define CFG_CTS_TO_ITSELF_ENABLED_MAX 0x01
1882#define CFG_CTS_TO_ITSELF_ENABLED_DEF CFG_CTS_TO_ITSELF_ENABLED_MIN 1889#define CFG_CTS_TO_ITSELF_ENABLED_DEF CFG_CTS_TO_ITSELF_ENABLED_MIN
1883 1890
1884#define CFG_SYS_ANTENNA_BOTH 0x000 1891/* Antenna diversity param (h/w can select best antenna, based on signal) */
1885#define CFG_SYS_ANTENNA_A 0x001 1892#define CFG_SYS_ANTENNA_BOTH 0x00 /* NIC selects best antenna */
1886#define CFG_SYS_ANTENNA_B 0x003 1893#define CFG_SYS_ANTENNA_A 0x01 /* force antenna A */
1894#define CFG_SYS_ANTENNA_B 0x03 /* force antenna B */
1887 1895
1888/* 1896/*
1889 * The definitions below were lifted off the ipw2100 driver, which only 1897 * The definitions below were lifted off the ipw2100 driver, which only
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index bf6271ee387a..75ce6ddb0cf5 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -55,10 +55,8 @@
55#include <linux/etherdevice.h> 55#include <linux/etherdevice.h>
56#include <linux/skbuff.h> 56#include <linux/skbuff.h>
57#include <linux/bitops.h> 57#include <linux/bitops.h>
58#ifdef CONFIG_NET_RADIO
59#include <linux/wireless.h> 58#include <linux/wireless.h>
60#include <net/iw_handler.h> 59#include <net/iw_handler.h>
61#endif
62 60
63#include <pcmcia/cs_types.h> 61#include <pcmcia/cs_types.h>
64#include <pcmcia/cs.h> 62#include <pcmcia/cs.h>
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index 18baacfc5a2c..18a44580b53b 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -112,7 +112,7 @@ static const char StripVersion[] = "1.3A-STUART.CHESHIRE";
112#include <linux/ip.h> 112#include <linux/ip.h>
113#include <linux/tcp.h> 113#include <linux/tcp.h>
114#include <linux/time.h> 114#include <linux/time.h>
115 115#include <linux/jiffies.h>
116 116
117/************************************************************************/ 117/************************************************************************/
118/* Useful structures and definitions */ 118/* Useful structures and definitions */
@@ -1569,7 +1569,7 @@ static int strip_xmit(struct sk_buff *skb, struct net_device *dev)
1569 del_timer(&strip_info->idle_timer); 1569 del_timer(&strip_info->idle_timer);
1570 1570
1571 1571
1572 if (jiffies - strip_info->pps_timer > HZ) { 1572 if (time_after(jiffies, strip_info->pps_timer + HZ)) {
1573 unsigned long t = jiffies - strip_info->pps_timer; 1573 unsigned long t = jiffies - strip_info->pps_timer;
1574 unsigned long rx_pps_count = (strip_info->rx_pps_count * HZ * 8 + t / 2) / t; 1574 unsigned long rx_pps_count = (strip_info->rx_pps_count * HZ * 8 + t / 2) / t;
1575 unsigned long tx_pps_count = (strip_info->tx_pps_count * HZ * 8 + t / 2) / t; 1575 unsigned long tx_pps_count = (strip_info->tx_pps_count * HZ * 8 + t / 2) / t;
diff --git a/drivers/net/wireless/wavelan.p.h b/drivers/net/wireless/wavelan.p.h
index 166e28b9a4f7..5cb0bc8bb128 100644
--- a/drivers/net/wireless/wavelan.p.h
+++ b/drivers/net/wireless/wavelan.p.h
@@ -98,11 +98,7 @@
98 * characteristics of the hardware. Applications such as mobile IP may 98 * characteristics of the hardware. Applications such as mobile IP may
99 * take advantage of it. 99 * take advantage of it.
100 * 100 *
101 * You will need to enable the CONFIG_NET_RADIO define in the kernel 101 * It might be a good idea as well to fetch the wireless tools to
102 * configuration to enable the wireless extensions (this is the one
103 * giving access to the radio network device choice).
104 *
105 * It might also be a good idea as well to fetch the wireless tools to
106 * configure the device and play a bit. 102 * configure the device and play a bit.
107 */ 103 */
108 104
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index f2d597568151..451f6271dcbc 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -99,11 +99,7 @@
99 * caracteristics of the hardware in a standard way and support for 99 * caracteristics of the hardware in a standard way and support for
100 * applications for taking advantage of it (like Mobile IP). 100 * applications for taking advantage of it (like Mobile IP).
101 * 101 *
102 * You will need to enable the CONFIG_NET_RADIO define in the kernel 102 * It might be a good idea as well to fetch the wireless tools to
103 * configuration to enable the wireless extensions (this is the one
104 * giving access to the radio network device choice).
105 *
106 * It might also be a good idea as well to fetch the wireless tools to
107 * configure the device and play a bit. 103 * configure the device and play a bit.
108 */ 104 */
109 105
@@ -440,11 +436,8 @@
440#include <linux/ioport.h> 436#include <linux/ioport.h>
441#include <linux/fcntl.h> 437#include <linux/fcntl.h>
442#include <linux/ethtool.h> 438#include <linux/ethtool.h>
443
444#ifdef CONFIG_NET_RADIO
445#include <linux/wireless.h> /* Wireless extensions */ 439#include <linux/wireless.h> /* Wireless extensions */
446#include <net/iw_handler.h> /* New driver API */ 440#include <net/iw_handler.h> /* New driver API */
447#endif
448 441
449/* Pcmcia headers that we need */ 442/* Pcmcia headers that we need */
450#include <pcmcia/cs_types.h> 443#include <pcmcia/cs_types.h>
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index 8ab6e12153ba..761021603597 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -27,6 +27,7 @@
27#include <linux/netdevice.h> 27#include <linux/netdevice.h>
28#include <linux/etherdevice.h> 28#include <linux/etherdevice.h>
29#include <linux/zorro.h> 29#include <linux/zorro.h>
30#include <linux/jiffies.h>
30 31
31#include <asm/system.h> 32#include <asm/system.h>
32#include <asm/irq.h> 33#include <asm/irq.h>
@@ -151,7 +152,7 @@ static int __devinit zorro8390_init(struct net_device *dev,
151 z_writeb(z_readb(ioaddr + NE_RESET), ioaddr + NE_RESET); 152 z_writeb(z_readb(ioaddr + NE_RESET), ioaddr + NE_RESET);
152 153
153 while ((z_readb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0) 154 while ((z_readb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0)
154 if (jiffies - reset_start_time > 2*HZ/100) { 155 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
155 printk(KERN_WARNING " not found (no reset ack).\n"); 156 printk(KERN_WARNING " not found (no reset ack).\n");
156 return -ENODEV; 157 return -ENODEV;
157 } 158 }
@@ -273,7 +274,7 @@ static void zorro8390_reset_8390(struct net_device *dev)
273 274
274 /* This check _should_not_ be necessary, omit eventually. */ 275 /* This check _should_not_ be necessary, omit eventually. */
275 while ((z_readb(NE_BASE+NE_EN0_ISR) & ENISR_RESET) == 0) 276 while ((z_readb(NE_BASE+NE_EN0_ISR) & ENISR_RESET) == 0)
276 if (jiffies - reset_start_time > 2*HZ/100) { 277 if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
277 printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", 278 printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n",
278 dev->name); 279 dev->name);
279 break; 280 break;
@@ -400,7 +401,7 @@ static void zorro8390_block_output(struct net_device *dev, int count,
400 dma_start = jiffies; 401 dma_start = jiffies;
401 402
402 while ((z_readb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0) 403 while ((z_readb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0)
403 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ 404 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
404 printk(KERN_ERR "%s: timeout waiting for Tx RDC.\n", 405 printk(KERN_ERR "%s: timeout waiting for Tx RDC.\n",
405 dev->name); 406 dev->name);
406 zorro8390_reset_8390(dev); 407 zorro8390_reset_8390(dev);