aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/arm/ixp4xx_eth.c3
-rw-r--r--drivers/net/bonding/bond_alb.c6
-rw-r--r--drivers/net/bonding/bond_main.c39
-rw-r--r--drivers/net/macvlan.c14
-rw-r--r--drivers/net/tun.c322
-rw-r--r--drivers/net/wan/Kconfig3
-rw-r--r--drivers/net/wireless/ath5k/base.c13
-rw-r--r--drivers/net/wireless/b43/main.c48
-rw-r--r--drivers/net/wireless/b43/xmit.c3
-rw-r--r--drivers/net/wireless/b43legacy/main.c45
-rw-r--r--drivers/net/wireless/b43legacy/xmit.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-led.c146
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-led.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c50
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-hw.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-rs.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c42
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000-hw.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c48
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h30
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c207
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.h5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c37
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c103
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c145
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c108
-rw-r--r--drivers/net/wireless/libertas/scan.c4
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c100
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c101
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c161
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h37
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00firmware.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c40
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c67
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c112
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c124
-rw-r--r--drivers/net/wireless/rtl8187_dev.c23
-rw-r--r--drivers/net/wireless/rtl8187_rtl8225.c21
-rw-r--r--drivers/net/wireless/rtl8187_rtl8225.h15
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c23
49 files changed, 1122 insertions, 1223 deletions
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
index c617b64c288e..9b777d9433cd 100644
--- a/drivers/net/arm/ixp4xx_eth.c
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -522,7 +522,6 @@ static int eth_poll(struct napi_struct *napi, int budget)
522#endif 522#endif
523 523
524 if ((n = queue_get_desc(rxq, port, 0)) < 0) { 524 if ((n = queue_get_desc(rxq, port, 0)) < 0) {
525 received = 0; /* No packet received */
526#if DEBUG_RX 525#if DEBUG_RX
527 printk(KERN_DEBUG "%s: eth_poll netif_rx_complete\n", 526 printk(KERN_DEBUG "%s: eth_poll netif_rx_complete\n",
528 dev->name); 527 dev->name);
@@ -543,7 +542,7 @@ static int eth_poll(struct napi_struct *napi, int budget)
543 printk(KERN_DEBUG "%s: eth_poll all done\n", 542 printk(KERN_DEBUG "%s: eth_poll all done\n",
544 dev->name); 543 dev->name);
545#endif 544#endif
546 return 0; /* all work done */ 545 return received; /* all work done */
547 } 546 }
548 547
549 desc = rx_desc_ptr(port, n); 548 desc = rx_desc_ptr(port, n);
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 5a673725471c..b211486a0ca3 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -419,8 +419,10 @@ static void rlb_teach_disabled_mac_on_primary(struct bonding *bond, u8 addr[])
419 } 419 }
420 420
421 if (!bond->alb_info.primary_is_promisc) { 421 if (!bond->alb_info.primary_is_promisc) {
422 bond->alb_info.primary_is_promisc = 1; 422 if (!dev_set_promiscuity(bond->curr_active_slave->dev, 1))
423 dev_set_promiscuity(bond->curr_active_slave->dev, 1); 423 bond->alb_info.primary_is_promisc = 1;
424 else
425 bond->alb_info.primary_is_promisc = 0;
424 } 426 }
425 427
426 bond->alb_info.rlb_promisc_timeout_counter = 0; 428 bond->alb_info.rlb_promisc_timeout_counter = 0;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index dc733d75a5e9..8ae7ff313218 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -772,39 +772,49 @@ static struct dev_mc_list *bond_mc_list_find_dmi(struct dev_mc_list *dmi, struct
772/* 772/*
773 * Push the promiscuity flag down to appropriate slaves 773 * Push the promiscuity flag down to appropriate slaves
774 */ 774 */
775static void bond_set_promiscuity(struct bonding *bond, int inc) 775static int bond_set_promiscuity(struct bonding *bond, int inc)
776{ 776{
777 int err = 0;
777 if (USES_PRIMARY(bond->params.mode)) { 778 if (USES_PRIMARY(bond->params.mode)) {
778 /* write lock already acquired */ 779 /* write lock already acquired */
779 if (bond->curr_active_slave) { 780 if (bond->curr_active_slave) {
780 dev_set_promiscuity(bond->curr_active_slave->dev, inc); 781 err = dev_set_promiscuity(bond->curr_active_slave->dev,
782 inc);
781 } 783 }
782 } else { 784 } else {
783 struct slave *slave; 785 struct slave *slave;
784 int i; 786 int i;
785 bond_for_each_slave(bond, slave, i) { 787 bond_for_each_slave(bond, slave, i) {
786 dev_set_promiscuity(slave->dev, inc); 788 err = dev_set_promiscuity(slave->dev, inc);
789 if (err)
790 return err;
787 } 791 }
788 } 792 }
793 return err;
789} 794}
790 795
791/* 796/*
792 * Push the allmulti flag down to all slaves 797 * Push the allmulti flag down to all slaves
793 */ 798 */
794static void bond_set_allmulti(struct bonding *bond, int inc) 799static int bond_set_allmulti(struct bonding *bond, int inc)
795{ 800{
801 int err = 0;
796 if (USES_PRIMARY(bond->params.mode)) { 802 if (USES_PRIMARY(bond->params.mode)) {
797 /* write lock already acquired */ 803 /* write lock already acquired */
798 if (bond->curr_active_slave) { 804 if (bond->curr_active_slave) {
799 dev_set_allmulti(bond->curr_active_slave->dev, inc); 805 err = dev_set_allmulti(bond->curr_active_slave->dev,
806 inc);
800 } 807 }
801 } else { 808 } else {
802 struct slave *slave; 809 struct slave *slave;
803 int i; 810 int i;
804 bond_for_each_slave(bond, slave, i) { 811 bond_for_each_slave(bond, slave, i) {
805 dev_set_allmulti(slave->dev, inc); 812 err = dev_set_allmulti(slave->dev, inc);
813 if (err)
814 return err;
806 } 815 }
807 } 816 }
817 return err;
808} 818}
809 819
810/* 820/*
@@ -965,6 +975,7 @@ static void bond_mc_swap(struct bonding *bond, struct slave *new_active, struct
965 } 975 }
966 976
967 if (new_active) { 977 if (new_active) {
978 /* FIXME: Signal errors upstream. */
968 if (bond->dev->flags & IFF_PROMISC) { 979 if (bond->dev->flags & IFF_PROMISC) {
969 dev_set_promiscuity(new_active->dev, 1); 980 dev_set_promiscuity(new_active->dev, 1);
970 } 981 }
@@ -1544,12 +1555,16 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1544 if (!USES_PRIMARY(bond->params.mode)) { 1555 if (!USES_PRIMARY(bond->params.mode)) {
1545 /* set promiscuity level to new slave */ 1556 /* set promiscuity level to new slave */
1546 if (bond_dev->flags & IFF_PROMISC) { 1557 if (bond_dev->flags & IFF_PROMISC) {
1547 dev_set_promiscuity(slave_dev, 1); 1558 res = dev_set_promiscuity(slave_dev, 1);
1559 if (res)
1560 goto err_close;
1548 } 1561 }
1549 1562
1550 /* set allmulti level to new slave */ 1563 /* set allmulti level to new slave */
1551 if (bond_dev->flags & IFF_ALLMULTI) { 1564 if (bond_dev->flags & IFF_ALLMULTI) {
1552 dev_set_allmulti(slave_dev, 1); 1565 res = dev_set_allmulti(slave_dev, 1);
1566 if (res)
1567 goto err_close;
1553 } 1568 }
1554 1569
1555 netif_tx_lock_bh(bond_dev); 1570 netif_tx_lock_bh(bond_dev);
@@ -4065,6 +4080,10 @@ static void bond_set_multicast_list(struct net_device *bond_dev)
4065 * Do promisc before checking multicast_mode 4080 * Do promisc before checking multicast_mode
4066 */ 4081 */
4067 if ((bond_dev->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC)) { 4082 if ((bond_dev->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC)) {
4083 /*
4084 * FIXME: Need to handle the error when one of the multi-slaves
4085 * encounters error.
4086 */
4068 bond_set_promiscuity(bond, 1); 4087 bond_set_promiscuity(bond, 1);
4069 } 4088 }
4070 4089
@@ -4074,6 +4093,10 @@ static void bond_set_multicast_list(struct net_device *bond_dev)
4074 4093
4075 /* set allmulti flag to slaves */ 4094 /* set allmulti flag to slaves */
4076 if ((bond_dev->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI)) { 4095 if ((bond_dev->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI)) {
4096 /*
4097 * FIXME: Need to handle the error when one of the multi-slaves
4098 * encounters error.
4099 */
4077 bond_set_allmulti(bond, 1); 4100 bond_set_allmulti(bond, 1);
4078 } 4101 }
4079 4102
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index c02ceaa4a216..980001c2cf96 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -189,12 +189,20 @@ static int macvlan_open(struct net_device *dev)
189 189
190 err = dev_unicast_add(lowerdev, dev->dev_addr, ETH_ALEN); 190 err = dev_unicast_add(lowerdev, dev->dev_addr, ETH_ALEN);
191 if (err < 0) 191 if (err < 0)
192 return err; 192 goto out;
193 if (dev->flags & IFF_ALLMULTI) 193 if (dev->flags & IFF_ALLMULTI) {
194 dev_set_allmulti(lowerdev, 1); 194 err = dev_set_allmulti(lowerdev, 1);
195 if (err < 0)
196 goto del_unicast;
197 }
195 198
196 hlist_add_head_rcu(&vlan->hlist, &port->vlan_hash[dev->dev_addr[5]]); 199 hlist_add_head_rcu(&vlan->hlist, &port->vlan_hash[dev->dev_addr[5]]);
197 return 0; 200 return 0;
201
202del_unicast:
203 dev_unicast_delete(lowerdev, dev->dev_addr, ETH_ALEN);
204out:
205 return err;
198} 206}
199 207
200static int macvlan_stop(struct net_device *dev) 208static int macvlan_stop(struct net_device *dev)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index aa4ee4439f04..901551c8ca0e 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -18,15 +18,11 @@
18/* 18/*
19 * Changes: 19 * Changes:
20 * 20 *
21 * Brian Braunstein <linuxkernel@bristyle.com> 2007/03/23
22 * Fixed hw address handling. Now net_device.dev_addr is kept consistent
23 * with tun.dev_addr when the address is set by this module.
24 *
25 * Mike Kershaw <dragorn@kismetwireless.net> 2005/08/14 21 * Mike Kershaw <dragorn@kismetwireless.net> 2005/08/14
26 * Add TUNSETLINK ioctl to set the link encapsulation 22 * Add TUNSETLINK ioctl to set the link encapsulation
27 * 23 *
28 * Mark Smith <markzzzsmith@yahoo.com.au> 24 * Mark Smith <markzzzsmith@yahoo.com.au>
29 * Use random_ether_addr() for tap MAC address. 25 * Use random_ether_addr() for tap MAC address.
30 * 26 *
31 * Harald Roelle <harald.roelle@ifi.lmu.de> 2004/04/20 27 * Harald Roelle <harald.roelle@ifi.lmu.de> 2004/04/20
32 * Fixes in packet dropping, queue length setting and queue wakeup. 28 * Fixes in packet dropping, queue length setting and queue wakeup.
@@ -83,9 +79,16 @@ static int debug;
83#define DBG1( a... ) 79#define DBG1( a... )
84#endif 80#endif
85 81
82#define FLT_EXACT_COUNT 8
83struct tap_filter {
84 unsigned int count; /* Number of addrs. Zero means disabled */
85 u32 mask[2]; /* Mask of the hashed addrs */
86 unsigned char addr[FLT_EXACT_COUNT][ETH_ALEN];
87};
88
86struct tun_struct { 89struct tun_struct {
87 struct list_head list; 90 struct list_head list;
88 unsigned long flags; 91 unsigned int flags;
89 int attached; 92 int attached;
90 uid_t owner; 93 uid_t owner;
91 gid_t group; 94 gid_t group;
@@ -94,19 +97,119 @@ struct tun_struct {
94 struct sk_buff_head readq; 97 struct sk_buff_head readq;
95 98
96 struct net_device *dev; 99 struct net_device *dev;
100 struct fasync_struct *fasync;
97 101
98 struct fasync_struct *fasync; 102 struct tap_filter txflt;
99
100 unsigned long if_flags;
101 u8 dev_addr[ETH_ALEN];
102 u32 chr_filter[2];
103 u32 net_filter[2];
104 103
105#ifdef TUN_DEBUG 104#ifdef TUN_DEBUG
106 int debug; 105 int debug;
107#endif 106#endif
108}; 107};
109 108
109/* TAP filterting */
110static void addr_hash_set(u32 *mask, const u8 *addr)
111{
112 int n = ether_crc(ETH_ALEN, addr) >> 26;
113 mask[n >> 5] |= (1 << (n & 31));
114}
115
116static unsigned int addr_hash_test(const u32 *mask, const u8 *addr)
117{
118 int n = ether_crc(ETH_ALEN, addr) >> 26;
119 return mask[n >> 5] & (1 << (n & 31));
120}
121
122static int update_filter(struct tap_filter *filter, void __user *arg)
123{
124 struct { u8 u[ETH_ALEN]; } *addr;
125 struct tun_filter uf;
126 int err, alen, n, nexact;
127
128 if (copy_from_user(&uf, arg, sizeof(uf)))
129 return -EFAULT;
130
131 if (!uf.count) {
132 /* Disabled */
133 filter->count = 0;
134 return 0;
135 }
136
137 alen = ETH_ALEN * uf.count;
138 addr = kmalloc(alen, GFP_KERNEL);
139 if (!addr)
140 return -ENOMEM;
141
142 if (copy_from_user(addr, arg + sizeof(uf), alen)) {
143 err = -EFAULT;
144 goto done;
145 }
146
147 /* The filter is updated without holding any locks. Which is
148 * perfectly safe. We disable it first and in the worst
149 * case we'll accept a few undesired packets. */
150 filter->count = 0;
151 wmb();
152
153 /* Use first set of addresses as an exact filter */
154 for (n = 0; n < uf.count && n < FLT_EXACT_COUNT; n++)
155 memcpy(filter->addr[n], addr[n].u, ETH_ALEN);
156
157 nexact = n;
158
159 /* The rest is hashed */
160 memset(filter->mask, 0, sizeof(filter->mask));
161 for (; n < uf.count; n++)
162 addr_hash_set(filter->mask, addr[n].u);
163
164 /* For ALLMULTI just set the mask to all ones.
165 * This overrides the mask populated above. */
166 if ((uf.flags & TUN_FLT_ALLMULTI))
167 memset(filter->mask, ~0, sizeof(filter->mask));
168
169 /* Now enable the filter */
170 wmb();
171 filter->count = nexact;
172
173 /* Return the number of exact filters */
174 err = nexact;
175
176done:
177 kfree(addr);
178 return err;
179}
180
181/* Returns: 0 - drop, !=0 - accept */
182static int run_filter(struct tap_filter *filter, const struct sk_buff *skb)
183{
184 /* Cannot use eth_hdr(skb) here because skb_mac_hdr() is incorrect
185 * at this point. */
186 struct ethhdr *eh = (struct ethhdr *) skb->data;
187 int i;
188
189 /* Exact match */
190 for (i = 0; i < filter->count; i++)
191 if (!compare_ether_addr(eh->h_dest, filter->addr[i]))
192 return 1;
193
194 /* Inexact match (multicast only) */
195 if (is_multicast_ether_addr(eh->h_dest))
196 return addr_hash_test(filter->mask, eh->h_dest);
197
198 return 0;
199}
200
201/*
202 * Checks whether the packet is accepted or not.
203 * Returns: 0 - drop, !=0 - accept
204 */
205static int check_filter(struct tap_filter *filter, const struct sk_buff *skb)
206{
207 if (!filter->count)
208 return 1;
209
210 return run_filter(filter, skb);
211}
212
110/* Network device part of the driver */ 213/* Network device part of the driver */
111 214
112static unsigned int tun_net_id; 215static unsigned int tun_net_id;
@@ -141,7 +244,12 @@ static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
141 if (!tun->attached) 244 if (!tun->attached)
142 goto drop; 245 goto drop;
143 246
144 /* Packet dropping */ 247 /* Drop if the filter does not like it.
248 * This is a noop if the filter is disabled.
249 * Filter can be enabled only for the TAP devices. */
250 if (!check_filter(&tun->txflt, skb))
251 goto drop;
252
145 if (skb_queue_len(&tun->readq) >= dev->tx_queue_len) { 253 if (skb_queue_len(&tun->readq) >= dev->tx_queue_len) {
146 if (!(tun->flags & TUN_ONE_QUEUE)) { 254 if (!(tun->flags & TUN_ONE_QUEUE)) {
147 /* Normal queueing mode. */ 255 /* Normal queueing mode. */
@@ -158,7 +266,7 @@ static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
158 } 266 }
159 } 267 }
160 268
161 /* Queue packet */ 269 /* Enqueue packet */
162 skb_queue_tail(&tun->readq, skb); 270 skb_queue_tail(&tun->readq, skb);
163 dev->trans_start = jiffies; 271 dev->trans_start = jiffies;
164 272
@@ -174,41 +282,14 @@ drop:
174 return 0; 282 return 0;
175} 283}
176 284
177/** Add the specified Ethernet address to this multicast filter. */ 285static void tun_net_mclist(struct net_device *dev)
178static void
179add_multi(u32* filter, const u8* addr)
180{
181 int bit_nr = ether_crc(ETH_ALEN, addr) >> 26;
182 filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
183}
184
185/** Remove the specified Ethernet addres from this multicast filter. */
186static void
187del_multi(u32* filter, const u8* addr)
188{ 286{
189 int bit_nr = ether_crc(ETH_ALEN, addr) >> 26; 287 /*
190 filter[bit_nr >> 5] &= ~(1 << (bit_nr & 31)); 288 * This callback is supposed to deal with mc filter in
191} 289 * _rx_ path and has nothing to do with the _tx_ path.
192 290 * In rx path we always accept everything userspace gives us.
193/** Update the list of multicast groups to which the network device belongs. 291 */
194 * This list is used to filter packets being sent from the character device to 292 return;
195 * the network device. */
196static void
197tun_net_mclist(struct net_device *dev)
198{
199 struct tun_struct *tun = netdev_priv(dev);
200 const struct dev_mc_list *mclist;
201 int i;
202 DECLARE_MAC_BUF(mac);
203 DBG(KERN_DEBUG "%s: tun_net_mclist: mc_count %d\n",
204 dev->name, dev->mc_count);
205 memset(tun->chr_filter, 0, sizeof tun->chr_filter);
206 for (i = 0, mclist = dev->mc_list; i < dev->mc_count && mclist != NULL;
207 i++, mclist = mclist->next) {
208 add_multi(tun->net_filter, mclist->dmi_addr);
209 DBG(KERN_DEBUG "%s: tun_net_mclist: %s\n",
210 dev->name, print_mac(mac, mclist->dmi_addr));
211 }
212} 293}
213 294
214#define MIN_MTU 68 295#define MIN_MTU 68
@@ -244,13 +325,11 @@ static void tun_net_init(struct net_device *dev)
244 325
245 case TUN_TAP_DEV: 326 case TUN_TAP_DEV:
246 /* Ethernet TAP Device */ 327 /* Ethernet TAP Device */
247 dev->set_multicast_list = tun_net_mclist;
248
249 ether_setup(dev); 328 ether_setup(dev);
250 dev->change_mtu = tun_net_change_mtu; 329 dev->change_mtu = tun_net_change_mtu;
330 dev->set_multicast_list = tun_net_mclist;
251 331
252 /* random address already created for us by tun_set_iff, use it */ 332 random_ether_addr(dev->dev_addr);
253 memcpy(dev->dev_addr, tun->dev_addr, min(sizeof(tun->dev_addr), sizeof(dev->dev_addr)) );
254 333
255 dev->tx_queue_len = TUN_READQ_SIZE; /* We prefer our own queue length */ 334 dev->tx_queue_len = TUN_READQ_SIZE; /* We prefer our own queue length */
256 break; 335 break;
@@ -486,7 +565,6 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
486 DECLARE_WAITQUEUE(wait, current); 565 DECLARE_WAITQUEUE(wait, current);
487 struct sk_buff *skb; 566 struct sk_buff *skb;
488 ssize_t len, ret = 0; 567 ssize_t len, ret = 0;
489 DECLARE_MAC_BUF(mac);
490 568
491 if (!tun) 569 if (!tun)
492 return -EBADFD; 570 return -EBADFD;
@@ -499,10 +577,6 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
499 577
500 add_wait_queue(&tun->read_wait, &wait); 578 add_wait_queue(&tun->read_wait, &wait);
501 while (len) { 579 while (len) {
502 const u8 ones[ ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
503 u8 addr[ ETH_ALEN];
504 int bit_nr;
505
506 current->state = TASK_INTERRUPTIBLE; 580 current->state = TASK_INTERRUPTIBLE;
507 581
508 /* Read frames from the queue */ 582 /* Read frames from the queue */
@@ -522,36 +596,9 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
522 } 596 }
523 netif_wake_queue(tun->dev); 597 netif_wake_queue(tun->dev);
524 598
525 /** Decide whether to accept this packet. This code is designed to 599 ret = tun_put_user(tun, skb, (struct iovec *) iv, len);
526 * behave identically to an Ethernet interface. Accept the packet if 600 kfree_skb(skb);
527 * - we are promiscuous. 601 break;
528 * - the packet is addressed to us.
529 * - the packet is broadcast.
530 * - the packet is multicast and
531 * - we are multicast promiscous.
532 * - we belong to the multicast group.
533 */
534 skb_copy_from_linear_data(skb, addr, min_t(size_t, sizeof addr,
535 skb->len));
536 bit_nr = ether_crc(sizeof addr, addr) >> 26;
537 if ((tun->if_flags & IFF_PROMISC) ||
538 memcmp(addr, tun->dev_addr, sizeof addr) == 0 ||
539 memcmp(addr, ones, sizeof addr) == 0 ||
540 (((addr[0] == 1 && addr[1] == 0 && addr[2] == 0x5e) ||
541 (addr[0] == 0x33 && addr[1] == 0x33)) &&
542 ((tun->if_flags & IFF_ALLMULTI) ||
543 (tun->chr_filter[bit_nr >> 5] & (1 << (bit_nr & 31)))))) {
544 DBG(KERN_DEBUG "%s: tun_chr_readv: accepted: %s\n",
545 tun->dev->name, print_mac(mac, addr));
546 ret = tun_put_user(tun, skb, (struct iovec *) iv, len);
547 kfree_skb(skb);
548 break;
549 } else {
550 DBG(KERN_DEBUG "%s: tun_chr_readv: rejected: %s\n",
551 tun->dev->name, print_mac(mac, addr));
552 kfree_skb(skb);
553 continue;
554 }
555 } 602 }
556 603
557 current->state = TASK_RUNNING; 604 current->state = TASK_RUNNING;
@@ -647,12 +694,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
647 tun = netdev_priv(dev); 694 tun = netdev_priv(dev);
648 tun->dev = dev; 695 tun->dev = dev;
649 tun->flags = flags; 696 tun->flags = flags;
650 /* Be promiscuous by default to maintain previous behaviour. */ 697 tun->txflt.count = 0;
651 tun->if_flags = IFF_PROMISC;
652 /* Generate random Ethernet address. */
653 *(__be16 *)tun->dev_addr = htons(0x00FF);
654 get_random_bytes(tun->dev_addr + sizeof(u16), 4);
655 memset(tun->chr_filter, 0, sizeof tun->chr_filter);
656 698
657 tun_net_init(dev); 699 tun_net_init(dev);
658 700
@@ -690,6 +732,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
690 tun->attached = 1; 732 tun->attached = 1;
691 get_net(dev_net(tun->dev)); 733 get_net(dev_net(tun->dev));
692 734
735 /* Make sure persistent devices do not get stuck in
736 * xoff state.
737 */
738 if (netif_running(tun->dev))
739 netif_wake_queue(tun->dev);
740
693 strcpy(ifr->ifr_name, tun->dev->name); 741 strcpy(ifr->ifr_name, tun->dev->name);
694 return 0; 742 return 0;
695 743
@@ -745,6 +793,7 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
745 struct tun_struct *tun = file->private_data; 793 struct tun_struct *tun = file->private_data;
746 void __user* argp = (void __user*)arg; 794 void __user* argp = (void __user*)arg;
747 struct ifreq ifr; 795 struct ifreq ifr;
796 int ret;
748 DECLARE_MAC_BUF(mac); 797 DECLARE_MAC_BUF(mac);
749 798
750 if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89) 799 if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89)
@@ -820,9 +869,6 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
820 break; 869 break;
821 870
822 case TUNSETLINK: 871 case TUNSETLINK:
823 {
824 int ret;
825
826 /* Only allow setting the type when the interface is down */ 872 /* Only allow setting the type when the interface is down */
827 rtnl_lock(); 873 rtnl_lock();
828 if (tun->dev->flags & IFF_UP) { 874 if (tun->dev->flags & IFF_UP) {
@@ -836,94 +882,44 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
836 } 882 }
837 rtnl_unlock(); 883 rtnl_unlock();
838 return ret; 884 return ret;
839 }
840 885
841#ifdef TUN_DEBUG 886#ifdef TUN_DEBUG
842 case TUNSETDEBUG: 887 case TUNSETDEBUG:
843 tun->debug = arg; 888 tun->debug = arg;
844 break; 889 break;
845#endif 890#endif
846
847 case TUNSETOFFLOAD: 891 case TUNSETOFFLOAD:
848 {
849 int ret;
850 rtnl_lock(); 892 rtnl_lock();
851 ret = set_offload(tun->dev, arg); 893 ret = set_offload(tun->dev, arg);
852 rtnl_unlock(); 894 rtnl_unlock();
853 return ret; 895 return ret;
854 }
855 896
856 case SIOCGIFFLAGS: 897 case TUNSETTXFILTER:
857 ifr.ifr_flags = tun->if_flags; 898 /* Can be set only for TAPs */
858 if (copy_to_user( argp, &ifr, sizeof ifr)) 899 if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV)
859 return -EFAULT; 900 return -EINVAL;
860 return 0; 901 rtnl_lock();
861 902 ret = update_filter(&tun->txflt, (void *) __user arg);
862 case SIOCSIFFLAGS: 903 rtnl_unlock();
863 /** Set the character device's interface flags. Currently only 904 return ret;
864 * IFF_PROMISC and IFF_ALLMULTI are used. */
865 tun->if_flags = ifr.ifr_flags;
866 DBG(KERN_INFO "%s: interface flags 0x%lx\n",
867 tun->dev->name, tun->if_flags);
868 return 0;
869 905
870 case SIOCGIFHWADDR: 906 case SIOCGIFHWADDR:
871 /* Note: the actual net device's address may be different */ 907 /* Get hw addres */
872 memcpy(ifr.ifr_hwaddr.sa_data, tun->dev_addr, 908 memcpy(ifr.ifr_hwaddr.sa_data, tun->dev->dev_addr, ETH_ALEN);
873 min(sizeof ifr.ifr_hwaddr.sa_data, sizeof tun->dev_addr)); 909 ifr.ifr_hwaddr.sa_family = tun->dev->type;
874 if (copy_to_user( argp, &ifr, sizeof ifr)) 910 if (copy_to_user(argp, &ifr, sizeof ifr))
875 return -EFAULT; 911 return -EFAULT;
876 return 0; 912 return 0;
877 913
878 case SIOCSIFHWADDR: 914 case SIOCSIFHWADDR:
879 { 915 /* Set hw address */
880 /* try to set the actual net device's hw address */ 916 DBG(KERN_DEBUG "%s: set hw address: %s\n",
881 int ret; 917 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
882 918
883 rtnl_lock(); 919 rtnl_lock();
884 ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr); 920 ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr);
885 rtnl_unlock(); 921 rtnl_unlock();
886 922 return ret;
887 if (ret == 0) {
888 /** Set the character device's hardware address. This is used when
889 * filtering packets being sent from the network device to the character
890 * device. */
891 memcpy(tun->dev_addr, ifr.ifr_hwaddr.sa_data,
892 min(sizeof ifr.ifr_hwaddr.sa_data, sizeof tun->dev_addr));
893 DBG(KERN_DEBUG "%s: set hardware address: %x:%x:%x:%x:%x:%x\n",
894 tun->dev->name,
895 tun->dev_addr[0], tun->dev_addr[1], tun->dev_addr[2],
896 tun->dev_addr[3], tun->dev_addr[4], tun->dev_addr[5]);
897 }
898
899 return ret;
900 }
901
902 case SIOCADDMULTI:
903 /** Add the specified group to the character device's multicast filter
904 * list. */
905 rtnl_lock();
906 netif_tx_lock_bh(tun->dev);
907 add_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
908 netif_tx_unlock_bh(tun->dev);
909 rtnl_unlock();
910
911 DBG(KERN_DEBUG "%s: add multi: %s\n",
912 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
913 return 0;
914
915 case SIOCDELMULTI:
916 /** Remove the specified group from the character device's multicast
917 * filter list. */
918 rtnl_lock();
919 netif_tx_lock_bh(tun->dev);
920 del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
921 netif_tx_unlock_bh(tun->dev);
922 rtnl_unlock();
923
924 DBG(KERN_DEBUG "%s: del multi: %s\n",
925 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
926 return 0;
927 923
928 default: 924 default:
929 return -EINVAL; 925 return -EINVAL;
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index d5140aed7b79..846be60e7821 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -390,8 +390,7 @@ config WAN_ROUTER_DRIVERS
390 390
391 Select driver your card and remember to say Y to "Wan Router." 391 Select driver your card and remember to say Y to "Wan Router."
392 You will need the wan-tools package which is available from 392 You will need the wan-tools package which is available from
393 <ftp://ftp.sangoma.com/>. For more information read: 393 <ftp://ftp.sangoma.com/>.
394 <file:Documentation/networking/wan-router.txt>.
395 394
396 Note that the answer to this question won't directly affect the 395 Note that the answer to this question won't directly affect the
397 kernel except for how subordinate drivers may be built: 396 kernel except for how subordinate drivers may be built:
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index a43e9b25169b..217d506527a9 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -207,7 +207,6 @@ static struct ieee80211_ops ath5k_hw_ops = {
207 .get_tx_stats = ath5k_get_tx_stats, 207 .get_tx_stats = ath5k_get_tx_stats,
208 .get_tsf = ath5k_get_tsf, 208 .get_tsf = ath5k_get_tsf,
209 .reset_tsf = ath5k_reset_tsf, 209 .reset_tsf = ath5k_reset_tsf,
210 .beacon_update = ath5k_beacon_update,
211}; 210};
212 211
213/* 212/*
@@ -2785,6 +2784,18 @@ ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2785 * a clean way of letting us retrieve this yet. */ 2784 * a clean way of letting us retrieve this yet. */
2786 ath5k_hw_set_associd(ah, ah->ah_bssid, 0); 2785 ath5k_hw_set_associd(ah, ah->ah_bssid, 0);
2787 } 2786 }
2787
2788 if (conf->changed & IEEE80211_IFCC_BEACON &&
2789 vif->type == IEEE80211_IF_TYPE_IBSS) {
2790 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
2791 if (!beacon) {
2792 ret = -ENOMEM;
2793 goto unlock;
2794 }
2795 /* call old handler for now */
2796 ath5k_beacon_update(hw, beacon);
2797 }
2798
2788 mutex_unlock(&sc->lock); 2799 mutex_unlock(&sc->lock);
2789 2800
2790 return ath5k_reset(hw); 2801 return ath5k_reset(hw);
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 9d2eb273b726..381dbd33dfc2 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1675,14 +1675,24 @@ static void b43_beacon_update_trigger_work(struct work_struct *work)
1675 1675
1676/* Asynchronously update the packet templates in template RAM. 1676/* Asynchronously update the packet templates in template RAM.
1677 * Locking: Requires wl->irq_lock to be locked. */ 1677 * Locking: Requires wl->irq_lock to be locked. */
1678static void b43_update_templates(struct b43_wl *wl, struct sk_buff *beacon) 1678static void b43_update_templates(struct b43_wl *wl)
1679{ 1679{
1680 struct sk_buff *beacon;
1681
1680 /* This is the top half of the ansynchronous beacon update. 1682 /* This is the top half of the ansynchronous beacon update.
1681 * The bottom half is the beacon IRQ. 1683 * The bottom half is the beacon IRQ.
1682 * Beacon update must be asynchronous to avoid sending an 1684 * Beacon update must be asynchronous to avoid sending an
1683 * invalid beacon. This can happen for example, if the firmware 1685 * invalid beacon. This can happen for example, if the firmware
1684 * transmits a beacon while we are updating it. */ 1686 * transmits a beacon while we are updating it. */
1685 1687
1688 /* We could modify the existing beacon and set the aid bit in
1689 * the TIM field, but that would probably require resizing and
1690 * moving of data within the beacon template.
1691 * Simply request a new beacon and let mac80211 do the hard work. */
1692 beacon = ieee80211_beacon_get(wl->hw, wl->vif);
1693 if (unlikely(!beacon))
1694 return;
1695
1686 if (wl->current_beacon) 1696 if (wl->current_beacon)
1687 dev_kfree_skb_any(wl->current_beacon); 1697 dev_kfree_skb_any(wl->current_beacon);
1688 wl->current_beacon = beacon; 1698 wl->current_beacon = beacon;
@@ -3645,10 +3655,14 @@ static int b43_op_config_interface(struct ieee80211_hw *hw,
3645 if (b43_status(dev) >= B43_STAT_INITIALIZED) { 3655 if (b43_status(dev) >= B43_STAT_INITIALIZED) {
3646 if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP) || 3656 if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP) ||
3647 b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) { 3657 b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) {
3648 B43_WARN_ON(conf->type != wl->if_type); 3658 B43_WARN_ON(vif->type != wl->if_type);
3649 b43_set_ssid(dev, conf->ssid, conf->ssid_len); 3659 if (conf->changed & IEEE80211_IFCC_SSID)
3650 if (conf->beacon) 3660 b43_set_ssid(dev, conf->ssid, conf->ssid_len);
3651 b43_update_templates(wl, conf->beacon); 3661 if (conf->changed & IEEE80211_IFCC_BEACON)
3662 b43_update_templates(wl);
3663 } else if (b43_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) {
3664 if (conf->changed & IEEE80211_IFCC_BEACON)
3665 b43_update_templates(wl);
3652 } 3666 }
3653 b43_write_mac_bssid_templates(dev); 3667 b43_write_mac_bssid_templates(dev);
3654 } 3668 }
@@ -4336,31 +4350,10 @@ out_unlock:
4336static int b43_op_beacon_set_tim(struct ieee80211_hw *hw, int aid, int set) 4350static int b43_op_beacon_set_tim(struct ieee80211_hw *hw, int aid, int set)
4337{ 4351{
4338 struct b43_wl *wl = hw_to_b43_wl(hw); 4352 struct b43_wl *wl = hw_to_b43_wl(hw);
4339 struct sk_buff *beacon;
4340 unsigned long flags;
4341
4342 /* We could modify the existing beacon and set the aid bit in
4343 * the TIM field, but that would probably require resizing and
4344 * moving of data within the beacon template.
4345 * Simply request a new beacon and let mac80211 do the hard work. */
4346 beacon = ieee80211_beacon_get(hw, wl->vif);
4347 if (unlikely(!beacon))
4348 return -ENOMEM;
4349 spin_lock_irqsave(&wl->irq_lock, flags);
4350 b43_update_templates(wl, beacon);
4351 spin_unlock_irqrestore(&wl->irq_lock, flags);
4352
4353 return 0;
4354}
4355
4356static int b43_op_ibss_beacon_update(struct ieee80211_hw *hw,
4357 struct sk_buff *beacon)
4358{
4359 struct b43_wl *wl = hw_to_b43_wl(hw);
4360 unsigned long flags; 4353 unsigned long flags;
4361 4354
4362 spin_lock_irqsave(&wl->irq_lock, flags); 4355 spin_lock_irqsave(&wl->irq_lock, flags);
4363 b43_update_templates(wl, beacon); 4356 b43_update_templates(wl);
4364 spin_unlock_irqrestore(&wl->irq_lock, flags); 4357 spin_unlock_irqrestore(&wl->irq_lock, flags);
4365 4358
4366 return 0; 4359 return 0;
@@ -4391,7 +4384,6 @@ static const struct ieee80211_ops b43_hw_ops = {
4391 .stop = b43_op_stop, 4384 .stop = b43_op_stop,
4392 .set_retry_limit = b43_op_set_retry_limit, 4385 .set_retry_limit = b43_op_set_retry_limit,
4393 .set_tim = b43_op_beacon_set_tim, 4386 .set_tim = b43_op_beacon_set_tim,
4394 .beacon_update = b43_op_ibss_beacon_update,
4395 .sta_notify = b43_op_sta_notify, 4387 .sta_notify = b43_op_sta_notify,
4396}; 4388};
4397 4389
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index bf6f6c1ed4cf..8d54502222a6 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -317,7 +317,8 @@ int b43_generate_txhdr(struct b43_wldev *dev,
317 /* MAC control */ 317 /* MAC control */
318 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) 318 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
319 mac_ctl |= B43_TXH_MAC_ACK; 319 mac_ctl |= B43_TXH_MAC_ACK;
320 if (!ieee80211_is_pspoll(fctl)) 320 /* use hardware sequence counter as the non-TID counter */
321 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
321 mac_ctl |= B43_TXH_MAC_HWSEQ; 322 mac_ctl |= B43_TXH_MAC_HWSEQ;
322 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) 323 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
323 mac_ctl |= B43_TXH_MAC_STMSDU; 324 mac_ctl |= B43_TXH_MAC_STMSDU;
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index 069157eea05c..a1b8bf3ee732 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -1138,14 +1138,22 @@ static void b43legacy_write_probe_resp_template(struct b43legacy_wldev *dev,
1138 1138
1139/* Asynchronously update the packet templates in template RAM. 1139/* Asynchronously update the packet templates in template RAM.
1140 * Locking: Requires wl->irq_lock to be locked. */ 1140 * Locking: Requires wl->irq_lock to be locked. */
1141static void b43legacy_update_templates(struct b43legacy_wl *wl, 1141static void b43legacy_update_templates(struct b43legacy_wl *wl)
1142 struct sk_buff *beacon)
1143{ 1142{
1143 struct sk_buff *beacon;
1144 /* This is the top half of the ansynchronous beacon update. The bottom 1144 /* This is the top half of the ansynchronous beacon update. The bottom
1145 * half is the beacon IRQ. Beacon update must be asynchronous to avoid 1145 * half is the beacon IRQ. Beacon update must be asynchronous to avoid
1146 * sending an invalid beacon. This can happen for example, if the 1146 * sending an invalid beacon. This can happen for example, if the
1147 * firmware transmits a beacon while we are updating it. */ 1147 * firmware transmits a beacon while we are updating it. */
1148 1148
1149 /* We could modify the existing beacon and set the aid bit in the TIM
1150 * field, but that would probably require resizing and moving of data
1151 * within the beacon template. Simply request a new beacon and let
1152 * mac80211 do the hard work. */
1153 beacon = ieee80211_beacon_get(wl->hw, wl->vif);
1154 if (unlikely(!beacon))
1155 return;
1156
1149 if (wl->current_beacon) 1157 if (wl->current_beacon)
1150 dev_kfree_skb_any(wl->current_beacon); 1158 dev_kfree_skb_any(wl->current_beacon);
1151 wl->current_beacon = beacon; 1159 wl->current_beacon = beacon;
@@ -2727,10 +2735,13 @@ static int b43legacy_op_config_interface(struct ieee80211_hw *hw,
2727 memset(wl->bssid, 0, ETH_ALEN); 2735 memset(wl->bssid, 0, ETH_ALEN);
2728 if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) { 2736 if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) {
2729 if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP)) { 2737 if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP)) {
2730 B43legacy_WARN_ON(conf->type != IEEE80211_IF_TYPE_AP); 2738 B43legacy_WARN_ON(vif->type != IEEE80211_IF_TYPE_AP);
2731 b43legacy_set_ssid(dev, conf->ssid, conf->ssid_len); 2739 b43legacy_set_ssid(dev, conf->ssid, conf->ssid_len);
2732 if (conf->beacon) 2740 if (conf->changed & IEEE80211_IFCC_BEACON)
2733 b43legacy_update_templates(wl, conf->beacon); 2741 b43legacy_update_templates(wl);
2742 } else if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) {
2743 if (conf->changed & IEEE80211_IFCC_BEACON)
2744 b43legacy_update_templates(wl);
2734 } 2745 }
2735 b43legacy_write_mac_bssid_templates(dev); 2746 b43legacy_write_mac_bssid_templates(dev);
2736 } 2747 }
@@ -3396,31 +3407,10 @@ static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw,
3396 int aid, int set) 3407 int aid, int set)
3397{ 3408{
3398 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); 3409 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3399 struct sk_buff *beacon;
3400 unsigned long flags;
3401
3402 /* We could modify the existing beacon and set the aid bit in the TIM
3403 * field, but that would probably require resizing and moving of data
3404 * within the beacon template. Simply request a new beacon and let
3405 * mac80211 do the hard work. */
3406 beacon = ieee80211_beacon_get(hw, wl->vif);
3407 if (unlikely(!beacon))
3408 return -ENOMEM;
3409 spin_lock_irqsave(&wl->irq_lock, flags);
3410 b43legacy_update_templates(wl, beacon);
3411 spin_unlock_irqrestore(&wl->irq_lock, flags);
3412
3413 return 0;
3414}
3415
3416static int b43legacy_op_ibss_beacon_update(struct ieee80211_hw *hw,
3417 struct sk_buff *beacon)
3418{
3419 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3420 unsigned long flags; 3410 unsigned long flags;
3421 3411
3422 spin_lock_irqsave(&wl->irq_lock, flags); 3412 spin_lock_irqsave(&wl->irq_lock, flags);
3423 b43legacy_update_templates(wl, beacon); 3413 b43legacy_update_templates(wl);
3424 spin_unlock_irqrestore(&wl->irq_lock, flags); 3414 spin_unlock_irqrestore(&wl->irq_lock, flags);
3425 3415
3426 return 0; 3416 return 0;
@@ -3440,7 +3430,6 @@ static const struct ieee80211_ops b43legacy_hw_ops = {
3440 .stop = b43legacy_op_stop, 3430 .stop = b43legacy_op_stop,
3441 .set_retry_limit = b43legacy_op_set_retry_limit, 3431 .set_retry_limit = b43legacy_op_set_retry_limit,
3442 .set_tim = b43legacy_op_beacon_set_tim, 3432 .set_tim = b43legacy_op_beacon_set_tim,
3443 .beacon_update = b43legacy_op_ibss_beacon_update,
3444}; 3433};
3445 3434
3446/* Hard-reset the chip. Do not call this directly. 3435/* Hard-reset the chip. Do not call this directly.
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c
index a3540787eb50..e969ed8d412d 100644
--- a/drivers/net/wireless/b43legacy/xmit.c
+++ b/drivers/net/wireless/b43legacy/xmit.c
@@ -295,8 +295,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
295 /* MAC control */ 295 /* MAC control */
296 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) 296 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
297 mac_ctl |= B43legacy_TX4_MAC_ACK; 297 mac_ctl |= B43legacy_TX4_MAC_ACK;
298 if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && 298 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
299 ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)))
300 mac_ctl |= B43legacy_TX4_MAC_HWSEQ; 299 mac_ctl |= B43legacy_TX4_MAC_HWSEQ;
301 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) 300 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
302 mac_ctl |= B43legacy_TX4_MAC_STMSDU; 301 mac_ctl |= B43legacy_TX4_MAC_STMSDU;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
index 8b1528e52d43..6be1fe13fa57 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
@@ -42,14 +42,11 @@
42#include "iwl-3945.h" 42#include "iwl-3945.h"
43#include "iwl-helpers.h" 43#include "iwl-helpers.h"
44 44
45#define IWL_1MB_RATE (128 * 1024)
46#define IWL_LED_THRESHOLD (16)
47#define IWL_MAX_BLINK_TBL (10)
48 45
49static const struct { 46static const struct {
50 u16 brightness; 47 u16 brightness;
51 u8 on_time; 48 u8 on_time;
52 u8 of_time; 49 u8 off_time;
53} blink_tbl[] = 50} blink_tbl[] =
54{ 51{
55 {300, 25, 25}, 52 {300, 25, 25},
@@ -61,9 +58,16 @@ static const struct {
61 {15, 95, 95 }, 58 {15, 95, 95 },
62 {10, 110, 110}, 59 {10, 110, 110},
63 {5, 130, 130}, 60 {5, 130, 130},
64 {0, 167, 167} 61 {0, 167, 167},
62 /*SOLID_ON*/
63 {-1, IWL_LED_SOLID, 0}
65}; 64};
66 65
66#define IWL_1MB_RATE (128 * 1024)
67#define IWL_LED_THRESHOLD (16)
68#define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /*Exclude Solid on*/
69#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1)
70
67static int iwl3945_led_cmd_callback(struct iwl3945_priv *priv, 71static int iwl3945_led_cmd_callback(struct iwl3945_priv *priv,
68 struct iwl3945_cmd *cmd, 72 struct iwl3945_cmd *cmd,
69 struct sk_buff *skb) 73 struct sk_buff *skb)
@@ -71,6 +75,10 @@ static int iwl3945_led_cmd_callback(struct iwl3945_priv *priv,
71 return 1; 75 return 1;
72} 76}
73 77
78static inline int iwl3945_brightness_to_idx(enum led_brightness brightness)
79{
80 return fls(0x000000FF & (u32)brightness);
81}
74 82
75/* Send led command */ 83/* Send led command */
76static int iwl_send_led_cmd(struct iwl3945_priv *priv, 84static int iwl_send_led_cmd(struct iwl3945_priv *priv,
@@ -81,49 +89,45 @@ static int iwl_send_led_cmd(struct iwl3945_priv *priv,
81 .len = sizeof(struct iwl3945_led_cmd), 89 .len = sizeof(struct iwl3945_led_cmd),
82 .data = led_cmd, 90 .data = led_cmd,
83 .meta.flags = CMD_ASYNC, 91 .meta.flags = CMD_ASYNC,
84 .meta.u.callback = iwl3945_led_cmd_callback 92 .meta.u.callback = iwl3945_led_cmd_callback,
85 }; 93 };
86 94
87 return iwl3945_send_cmd(priv, &cmd); 95 return iwl3945_send_cmd(priv, &cmd);
88} 96}
89 97
90 98
99
91/* Set led on command */ 100/* Set led on command */
92static int iwl3945_led_on(struct iwl3945_priv *priv, int led_id) 101static int iwl3945_led_pattern(struct iwl3945_priv *priv, int led_id,
102 unsigned int idx)
93{ 103{
94 struct iwl3945_led_cmd led_cmd = { 104 struct iwl3945_led_cmd led_cmd = {
95 .id = led_id, 105 .id = led_id,
96 .on = IWL_LED_SOLID,
97 .off = 0,
98 .interval = IWL_DEF_LED_INTRVL 106 .interval = IWL_DEF_LED_INTRVL
99 }; 107 };
108
109 BUG_ON(idx > IWL_MAX_BLINK_TBL);
110
111 led_cmd.on = blink_tbl[idx].on_time;
112 led_cmd.off = blink_tbl[idx].off_time;
113
100 return iwl_send_led_cmd(priv, &led_cmd); 114 return iwl_send_led_cmd(priv, &led_cmd);
101} 115}
102 116
117
118#if 1
103/* Set led on command */ 119/* Set led on command */
104static int iwl3945_led_pattern(struct iwl3945_priv *priv, int led_id, 120static int iwl3945_led_on(struct iwl3945_priv *priv, int led_id)
105 enum led_brightness brightness)
106{ 121{
107 struct iwl3945_led_cmd led_cmd = { 122 struct iwl3945_led_cmd led_cmd = {
108 .id = led_id, 123 .id = led_id,
109 .on = brightness, 124 .on = IWL_LED_SOLID,
110 .off = brightness, 125 .off = 0,
111 .interval = IWL_DEF_LED_INTRVL 126 .interval = IWL_DEF_LED_INTRVL
112 }; 127 };
113 if (brightness == LED_FULL) {
114 led_cmd.on = IWL_LED_SOLID;
115 led_cmd.off = 0;
116 }
117 return iwl_send_led_cmd(priv, &led_cmd); 128 return iwl_send_led_cmd(priv, &led_cmd);
118} 129}
119 130
120/* Set led register off */
121static int iwl3945_led_on_reg(struct iwl3945_priv *priv, int led_id)
122{
123 IWL_DEBUG_LED("led on %d\n", led_id);
124 return iwl3945_led_on(priv, led_id);
125}
126
127/* Set led off command */ 131/* Set led off command */
128static int iwl3945_led_off(struct iwl3945_priv *priv, int led_id) 132static int iwl3945_led_off(struct iwl3945_priv *priv, int led_id)
129{ 133{
@@ -136,27 +140,7 @@ static int iwl3945_led_off(struct iwl3945_priv *priv, int led_id)
136 IWL_DEBUG_LED("led off %d\n", led_id); 140 IWL_DEBUG_LED("led off %d\n", led_id);
137 return iwl_send_led_cmd(priv, &led_cmd); 141 return iwl_send_led_cmd(priv, &led_cmd);
138} 142}
139 143#endif
140/* Set led register off */
141static int iwl3945_led_off_reg(struct iwl3945_priv *priv, int led_id)
142{
143 iwl3945_led_off(priv, led_id);
144 return 0;
145}
146
147/* Set led blink command */
148static int iwl3945_led_not_solid(struct iwl3945_priv *priv, int led_id,
149 u8 brightness)
150{
151 struct iwl3945_led_cmd led_cmd = {
152 .id = led_id,
153 .on = brightness,
154 .off = brightness,
155 .interval = IWL_DEF_LED_INTRVL
156 };
157
158 return iwl_send_led_cmd(priv, &led_cmd);
159}
160 144
161 145
162/* 146/*
@@ -206,8 +190,10 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
206 led->led_off(priv, IWL_LED_LINK); 190 led->led_off(priv, IWL_LED_LINK);
207 break; 191 break;
208 default: 192 default:
209 if (led->led_pattern) 193 if (led->led_pattern) {
210 led->led_pattern(priv, IWL_LED_LINK, brightness); 194 int idx = iwl3945_brightness_to_idx(brightness);
195 led->led_pattern(priv, IWL_LED_LINK, idx);
196 }
211 break; 197 break;
212 } 198 }
213} 199}
@@ -252,24 +238,20 @@ static int iwl3945_led_register_led(struct iwl3945_priv *priv,
252static inline u8 get_blink_rate(struct iwl3945_priv *priv) 238static inline u8 get_blink_rate(struct iwl3945_priv *priv)
253{ 239{
254 int index; 240 int index;
255 u8 blink_rate; 241 u64 current_tpt = priv->rxtxpackets;
256 242 s64 tpt = current_tpt - priv->led_tpt;
257 if (priv->rxtxpackets < IWL_LED_THRESHOLD)
258 index = 10;
259 else {
260 for (index = 0; index < IWL_MAX_BLINK_TBL; index++) {
261 if (priv->rxtxpackets > (blink_tbl[index].brightness *
262 IWL_1MB_RATE))
263 break;
264 }
265 }
266 /* if 0 frame is transfered */
267 if ((index == IWL_MAX_BLINK_TBL) || !priv->allow_blinking)
268 blink_rate = IWL_LED_SOLID;
269 else
270 blink_rate = blink_tbl[index].on_time;
271 243
272 return blink_rate; 244 if (tpt < 0)
245 tpt = -tpt;
246 priv->led_tpt = current_tpt;
247
248 if (!priv->allow_blinking)
249 index = IWL_MAX_BLINK_TBL;
250 else
251 for (index = 0; index < IWL_MAX_BLINK_TBL; index++)
252 if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE))
253 break;
254 return index;
273} 255}
274 256
275static inline int is_rf_kill(struct iwl3945_priv *priv) 257static inline int is_rf_kill(struct iwl3945_priv *priv)
@@ -285,7 +267,7 @@ static inline int is_rf_kill(struct iwl3945_priv *priv)
285 */ 267 */
286void iwl3945_led_background(struct iwl3945_priv *priv) 268void iwl3945_led_background(struct iwl3945_priv *priv)
287{ 269{
288 u8 blink_rate; 270 u8 blink_idx;
289 271
290 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 272 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
291 priv->last_blink_time = 0; 273 priv->last_blink_time = 0;
@@ -298,9 +280,10 @@ void iwl3945_led_background(struct iwl3945_priv *priv)
298 280
299 if (!priv->allow_blinking) { 281 if (!priv->allow_blinking) {
300 priv->last_blink_time = 0; 282 priv->last_blink_time = 0;
301 if (priv->last_blink_rate != IWL_LED_SOLID) { 283 if (priv->last_blink_rate != IWL_SOLID_BLINK_IDX) {
302 priv->last_blink_rate = IWL_LED_SOLID; 284 priv->last_blink_rate = IWL_SOLID_BLINK_IDX;
303 iwl3945_led_on(priv, IWL_LED_LINK); 285 iwl3945_led_pattern(priv, IWL_LED_LINK,
286 IWL_SOLID_BLINK_IDX);
304 } 287 }
305 return; 288 return;
306 } 289 }
@@ -309,21 +292,14 @@ void iwl3945_led_background(struct iwl3945_priv *priv)
309 msecs_to_jiffies(1000))) 292 msecs_to_jiffies(1000)))
310 return; 293 return;
311 294
312 blink_rate = get_blink_rate(priv); 295 blink_idx = get_blink_rate(priv);
313 296
314 /* call only if blink rate change */ 297 /* call only if blink rate change */
315 if (blink_rate != priv->last_blink_rate) { 298 if (blink_idx != priv->last_blink_rate)
316 if (blink_rate != IWL_LED_SOLID) { 299 iwl3945_led_pattern(priv, IWL_LED_LINK, blink_idx);
317 priv->last_blink_time = jiffies +
318 msecs_to_jiffies(1000);
319 iwl3945_led_not_solid(priv, IWL_LED_LINK, blink_rate);
320 } else {
321 priv->last_blink_time = 0;
322 iwl3945_led_on(priv, IWL_LED_LINK);
323 }
324 }
325 300
326 priv->last_blink_rate = blink_rate; 301 priv->last_blink_time = jiffies;
302 priv->last_blink_rate = blink_idx;
327 priv->rxtxpackets = 0; 303 priv->rxtxpackets = 0;
328} 304}
329 305
@@ -337,6 +313,7 @@ int iwl3945_led_register(struct iwl3945_priv *priv)
337 313
338 priv->last_blink_rate = 0; 314 priv->last_blink_rate = 0;
339 priv->rxtxpackets = 0; 315 priv->rxtxpackets = 0;
316 priv->led_tpt = 0;
340 priv->last_blink_time = 0; 317 priv->last_blink_time = 0;
341 priv->allow_blinking = 0; 318 priv->allow_blinking = 0;
342 319
@@ -344,8 +321,8 @@ int iwl3945_led_register(struct iwl3945_priv *priv)
344 snprintf(name, sizeof(name), "iwl-%s:radio", 321 snprintf(name, sizeof(name), "iwl-%s:radio",
345 wiphy_name(priv->hw->wiphy)); 322 wiphy_name(priv->hw->wiphy));
346 323
347 priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on_reg; 324 priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on;
348 priv->led[IWL_LED_TRG_RADIO].led_off = iwl3945_led_off_reg; 325 priv->led[IWL_LED_TRG_RADIO].led_off = iwl3945_led_off;
349 priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL; 326 priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
350 327
351 ret = iwl3945_led_register_led(priv, 328 ret = iwl3945_led_register_led(priv,
@@ -364,8 +341,8 @@ int iwl3945_led_register(struct iwl3945_priv *priv)
364 IWL_LED_TRG_ASSOC, 0, 341 IWL_LED_TRG_ASSOC, 0,
365 name, trigger); 342 name, trigger);
366 /* for assoc always turn led on */ 343 /* for assoc always turn led on */
367 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on_reg; 344 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on;
368 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on_reg; 345 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on;
369 priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL; 346 priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
370 347
371 if (ret) 348 if (ret)
@@ -391,6 +368,7 @@ int iwl3945_led_register(struct iwl3945_priv *priv)
391 trigger = ieee80211_get_tx_led_name(priv->hw); 368 trigger = ieee80211_get_tx_led_name(priv->hw);
392 snprintf(name, sizeof(name), "iwl-%s:TX", 369 snprintf(name, sizeof(name), "iwl-%s:TX",
393 wiphy_name(priv->hw->wiphy)); 370 wiphy_name(priv->hw->wiphy));
371
394 ret = iwl3945_led_register_led(priv, 372 ret = iwl3945_led_register_led(priv,
395 &priv->led[IWL_LED_TRG_TX], 373 &priv->led[IWL_LED_TRG_TX],
396 IWL_LED_TRG_TX, 0, 374 IWL_LED_TRG_TX, 0,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.h b/drivers/net/wireless/iwlwifi/iwl-3945-led.h
index b1d2f6b8b259..47b7e0bac802 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-led.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.h
@@ -54,7 +54,7 @@ struct iwl3945_led {
54 int (*led_on) (struct iwl3945_priv *priv, int led_id); 54 int (*led_on) (struct iwl3945_priv *priv, int led_id);
55 int (*led_off) (struct iwl3945_priv *priv, int led_id); 55 int (*led_off) (struct iwl3945_priv *priv, int led_id);
56 int (*led_pattern) (struct iwl3945_priv *priv, int led_id, 56 int (*led_pattern) (struct iwl3945_priv *priv, int led_id,
57 enum led_brightness brightness); 57 unsigned int idx);
58 58
59 enum led_type type; 59 enum led_type type;
60 unsigned int registered; 60 unsigned int registered;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 94e177a9f51c..c2a76785b665 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -514,6 +514,23 @@ static inline void iwl3945_dbg_report_frame(struct iwl3945_priv *priv,
514} 514}
515#endif 515#endif
516 516
517/* This is necessary only for a number of statistics, see the caller. */
518static int iwl3945_is_network_packet(struct iwl3945_priv *priv,
519 struct ieee80211_hdr *header)
520{
521 /* Filter incoming packets to determine if they are targeted toward
522 * this network, discarding packets coming from ourselves */
523 switch (priv->iw_mode) {
524 case IEEE80211_IF_TYPE_IBSS: /* Header: Dest. | Source | BSSID */
525 /* packets to our IBSS update information */
526 return !compare_ether_addr(header->addr3, priv->bssid);
527 case IEEE80211_IF_TYPE_STA: /* Header: Dest. | AP{BSSID} | Source */
528 /* packets to our IBSS update information */
529 return !compare_ether_addr(header->addr2, priv->bssid);
530 default:
531 return 1;
532 }
533}
517 534
518static void iwl3945_add_radiotap(struct iwl3945_priv *priv, 535static void iwl3945_add_radiotap(struct iwl3945_priv *priv,
519 struct sk_buff *skb, 536 struct sk_buff *skb,
@@ -608,12 +625,12 @@ static void iwl3945_add_radiotap(struct iwl3945_priv *priv,
608 stats->flag |= RX_FLAG_RADIOTAP; 625 stats->flag |= RX_FLAG_RADIOTAP;
609} 626}
610 627
611static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data, 628static void iwl3945_pass_packet_to_mac80211(struct iwl3945_priv *priv,
612 struct iwl3945_rx_mem_buffer *rxb, 629 struct iwl3945_rx_mem_buffer *rxb,
613 struct ieee80211_rx_status *stats) 630 struct ieee80211_rx_status *stats)
614{ 631{
615 struct ieee80211_hdr *hdr;
616 struct iwl3945_rx_packet *pkt = (struct iwl3945_rx_packet *)rxb->skb->data; 632 struct iwl3945_rx_packet *pkt = (struct iwl3945_rx_packet *)rxb->skb->data;
633 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IWL_RX_DATA(pkt);
617 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt); 634 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
618 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt); 635 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt);
619 short len = le16_to_cpu(rx_hdr->len); 636 short len = le16_to_cpu(rx_hdr->len);
@@ -635,8 +652,6 @@ static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data,
635 /* Set the size of the skb to the size of the frame */ 652 /* Set the size of the skb to the size of the frame */
636 skb_put(rxb->skb, le16_to_cpu(rx_hdr->len)); 653 skb_put(rxb->skb, le16_to_cpu(rx_hdr->len));
637 654
638 hdr = (void *)rxb->skb->data;
639
640 if (iwl3945_param_hwcrypto) 655 if (iwl3945_param_hwcrypto)
641 iwl3945_set_decrypted_flag(priv, rxb->skb, 656 iwl3945_set_decrypted_flag(priv, rxb->skb,
642 le32_to_cpu(rx_end->status), stats); 657 le32_to_cpu(rx_end->status), stats);
@@ -645,7 +660,7 @@ static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data,
645 iwl3945_add_radiotap(priv, rxb->skb, rx_hdr, stats); 660 iwl3945_add_radiotap(priv, rxb->skb, rx_hdr, stats);
646 661
647#ifdef CONFIG_IWL3945_LEDS 662#ifdef CONFIG_IWL3945_LEDS
648 if (is_data) 663 if (ieee80211_is_data(hdr->frame_control))
649 priv->rxtxpackets += len; 664 priv->rxtxpackets += len;
650#endif 665#endif
651 ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats); 666 ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
@@ -694,7 +709,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
694 } 709 }
695 710
696 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { 711 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) {
697 iwl3945_handle_data_packet(priv, 1, rxb, &rx_status); 712 iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status);
698 return; 713 return;
699 } 714 }
700 715
@@ -842,27 +857,12 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
842 } 857 }
843 } 858 }
844 859
845 iwl3945_handle_data_packet(priv, 0, rxb, &rx_status); 860 case IEEE80211_FTYPE_DATA:
846 break; 861 /* fall through */
847 862 default:
848 case IEEE80211_FTYPE_CTL: 863 iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status);
849 break;
850
851 case IEEE80211_FTYPE_DATA: {
852 DECLARE_MAC_BUF(mac1);
853 DECLARE_MAC_BUF(mac2);
854 DECLARE_MAC_BUF(mac3);
855
856 if (unlikely(iwl3945_is_duplicate_packet(priv, header)))
857 IWL_DEBUG_DROP("Dropping (dup): %s, %s, %s\n",
858 print_mac(mac1, header->addr1),
859 print_mac(mac2, header->addr2),
860 print_mac(mac3, header->addr3));
861 else
862 iwl3945_handle_data_packet(priv, 1, rxb, &rx_status);
863 break; 864 break;
864 } 865 }
865 }
866} 866}
867 867
868int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl3945_priv *priv, void *ptr, 868int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl3945_priv *priv, void *ptr,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 9c0a09eaca6f..fa81ba1af3d3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -510,8 +510,6 @@ struct iwl3945_ucode {
510 u8 data[0]; /* data in same order as "size" elements */ 510 u8 data[0]; /* data in same order as "size" elements */
511}; 511};
512 512
513#define IWL_IBSS_MAC_HASH_SIZE 32
514
515struct iwl3945_ibss_seq { 513struct iwl3945_ibss_seq {
516 u8 mac[ETH_ALEN]; 514 u8 mac[ETH_ALEN];
517 u16 seq_num; 515 u16 seq_num;
@@ -569,17 +567,8 @@ extern int iwl3945_send_add_station(struct iwl3945_priv *priv,
569 struct iwl3945_addsta_cmd *sta, u8 flags); 567 struct iwl3945_addsta_cmd *sta, u8 flags);
570extern u8 iwl3945_add_station(struct iwl3945_priv *priv, const u8 *bssid, 568extern u8 iwl3945_add_station(struct iwl3945_priv *priv, const u8 *bssid,
571 int is_ap, u8 flags); 569 int is_ap, u8 flags);
572extern int iwl3945_is_network_packet(struct iwl3945_priv *priv,
573 struct ieee80211_hdr *header);
574extern int iwl3945_power_init_handle(struct iwl3945_priv *priv); 570extern int iwl3945_power_init_handle(struct iwl3945_priv *priv);
575extern int iwl3945_eeprom_init(struct iwl3945_priv *priv); 571extern int iwl3945_eeprom_init(struct iwl3945_priv *priv);
576extern void iwl3945_handle_data_packet_monitor(struct iwl3945_priv *priv,
577 struct iwl3945_rx_mem_buffer *rxb,
578 void *data, short len,
579 struct ieee80211_rx_status *stats,
580 u16 phy_flags);
581extern int iwl3945_is_duplicate_packet(struct iwl3945_priv *priv,
582 struct ieee80211_hdr *header);
583extern int iwl3945_rx_queue_alloc(struct iwl3945_priv *priv); 572extern int iwl3945_rx_queue_alloc(struct iwl3945_priv *priv);
584extern void iwl3945_rx_queue_reset(struct iwl3945_priv *priv, 573extern void iwl3945_rx_queue_reset(struct iwl3945_priv *priv,
585 struct iwl3945_rx_queue *rxq); 574 struct iwl3945_rx_queue *rxq);
@@ -805,6 +794,7 @@ struct iwl3945_priv {
805 u8 last_blink_rate; 794 u8 last_blink_rate;
806 u8 allow_blinking; 795 u8 allow_blinking;
807 unsigned int rxtxpackets; 796 unsigned int rxtxpackets;
797 u64 led_tpt;
808#endif 798#endif
809 799
810 800
@@ -859,14 +849,6 @@ struct iwl3945_priv {
859 u32 last_beacon_time; 849 u32 last_beacon_time;
860 u64 last_tsf; 850 u64 last_tsf;
861 851
862 /* Duplicate packet detection */
863 u16 last_seq_num;
864 u16 last_frag_num;
865 unsigned long last_packet_time;
866
867 /* Hash table for finding stations in IBSS network */
868 struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE];
869
870 /* eeprom */ 852 /* eeprom */
871 struct iwl3945_eeprom eeprom; 853 struct iwl3945_eeprom eeprom;
872 854
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
index 10f630e1afa6..fce950f4163c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
@@ -819,6 +819,7 @@ enum {
819#define IWL49_NUM_FIFOS 7 819#define IWL49_NUM_FIFOS 7
820#define IWL49_CMD_FIFO_NUM 4 820#define IWL49_CMD_FIFO_NUM 4
821#define IWL49_NUM_QUEUES 16 821#define IWL49_NUM_QUEUES 16
822#define IWL49_NUM_AMPDU_QUEUES 8
822 823
823/** 824/**
824 * struct iwl_tfd_frame_data 825 * struct iwl_tfd_frame_data
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
index c7ebb3bf06f5..3ccb84aa5dbc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
@@ -2265,9 +2265,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2265 2265
2266 /* as default allow aggregation for all tids */ 2266 /* as default allow aggregation for all tids */
2267 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; 2267 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID;
2268#ifdef CONFIG_MAC80211_DEBUGFS
2269 lq_sta->drv = priv; 2268 lq_sta->drv = priv;
2270#endif
2271 2269
2272 rs_initialize_lq(priv, conf, sta); 2270 rs_initialize_lq(priv, conf, sta);
2273} 2271}
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 04365b39279c..9afecb813716 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -49,9 +49,17 @@
49static int iwl4965_send_tx_power(struct iwl_priv *priv); 49static int iwl4965_send_tx_power(struct iwl_priv *priv);
50static int iwl4965_hw_get_temperature(const struct iwl_priv *priv); 50static int iwl4965_hw_get_temperature(const struct iwl_priv *priv);
51 51
52/* Change firmware file name, using "-" and incrementing number,
53 * *only* when uCode interface or architecture changes so that it
54 * is not compatible with earlier drivers.
55 * This number will also appear in << 8 position of 1st dword of uCode file */
56#define IWL4965_UCODE_API "-2"
57
58
52/* module parameters */ 59/* module parameters */
53static struct iwl_mod_params iwl4965_mod_params = { 60static struct iwl_mod_params iwl4965_mod_params = {
54 .num_of_queues = IWL49_NUM_QUEUES, 61 .num_of_queues = IWL49_NUM_QUEUES,
62 .num_of_ampdu_queues = IWL49_NUM_AMPDU_QUEUES,
55 .enable_qos = 1, 63 .enable_qos = 1,
56 .amsdu_size_8K = 1, 64 .amsdu_size_8K = 1,
57 .restart_fw = 1, 65 .restart_fw = 1,
@@ -642,6 +650,18 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
642 data->beacon_count = 0; 650 data->beacon_count = 0;
643} 651}
644 652
653static void iwl4965_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
654 __le32 *tx_flags)
655{
656 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) {
657 *tx_flags |= TX_CMD_FLG_RTS_MSK;
658 *tx_flags &= ~TX_CMD_FLG_CTS_MSK;
659 } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
660 *tx_flags &= ~TX_CMD_FLG_RTS_MSK;
661 *tx_flags |= TX_CMD_FLG_CTS_MSK;
662 }
663}
664
645static void iwl4965_bg_txpower_work(struct work_struct *work) 665static void iwl4965_bg_txpower_work(struct work_struct *work)
646{ 666{
647 struct iwl_priv *priv = container_of(work, struct iwl_priv, 667 struct iwl_priv *priv = container_of(work, struct iwl_priv,
@@ -1931,9 +1951,11 @@ static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
1931{ 1951{
1932 int ret = 0; 1952 int ret = 0;
1933 1953
1934 if (IWL49_FIRST_AMPDU_QUEUE > txq_id) { 1954 if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) ||
1935 IWL_WARNING("queue number too small: %d, must be > %d\n", 1955 (IWL49_FIRST_AMPDU_QUEUE + IWL49_NUM_AMPDU_QUEUES <= txq_id)) {
1936 txq_id, IWL49_FIRST_AMPDU_QUEUE); 1956 IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
1957 txq_id, IWL49_FIRST_AMPDU_QUEUE,
1958 IWL49_FIRST_AMPDU_QUEUE + IWL49_NUM_AMPDU_QUEUES - 1);
1937 return -EINVAL; 1959 return -EINVAL;
1938 } 1960 }
1939 1961
@@ -2000,9 +2022,13 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
2000 int ret; 2022 int ret;
2001 u16 ra_tid; 2023 u16 ra_tid;
2002 2024
2003 if (IWL49_FIRST_AMPDU_QUEUE > txq_id) 2025 if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) ||
2004 IWL_WARNING("queue number too small: %d, must be > %d\n", 2026 (IWL49_FIRST_AMPDU_QUEUE + IWL49_NUM_AMPDU_QUEUES <= txq_id)) {
2005 txq_id, IWL49_FIRST_AMPDU_QUEUE); 2027 IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
2028 txq_id, IWL49_FIRST_AMPDU_QUEUE,
2029 IWL49_FIRST_AMPDU_QUEUE + IWL49_NUM_AMPDU_QUEUES - 1);
2030 return -EINVAL;
2031 }
2006 2032
2007 ra_tid = BUILD_RAxTID(sta_id, tid); 2033 ra_tid = BUILD_RAxTID(sta_id, tid);
2008 2034
@@ -2372,6 +2398,7 @@ static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
2372 .build_addsta_hcmd = iwl4965_build_addsta_hcmd, 2398 .build_addsta_hcmd = iwl4965_build_addsta_hcmd,
2373 .chain_noise_reset = iwl4965_chain_noise_reset, 2399 .chain_noise_reset = iwl4965_chain_noise_reset,
2374 .gain_computation = iwl4965_gain_computation, 2400 .gain_computation = iwl4965_gain_computation,
2401 .rts_tx_cmd_flag = iwl4965_rts_tx_cmd_flag,
2375}; 2402};
2376 2403
2377static struct iwl_lib_ops iwl4965_lib = { 2404static struct iwl_lib_ops iwl4965_lib = {
@@ -2434,6 +2461,9 @@ struct iwl_cfg iwl4965_agn_cfg = {
2434 .mod_params = &iwl4965_mod_params, 2461 .mod_params = &iwl4965_mod_params,
2435}; 2462};
2436 2463
2464/* Module firmware */
2465MODULE_FIRMWARE("iwlwifi-4965" IWL4965_UCODE_API ".ucode");
2466
2437module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444); 2467module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444);
2438MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); 2468MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
2439module_param_named(disable, iwl4965_mod_params.disable, int, 0444); 2469module_param_named(disable, iwl4965_mod_params.disable, int, 0444);
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
index 4efe0c06b5b2..17d4f31c5934 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
@@ -81,6 +81,7 @@
81#define IWL50_QUEUE_SIZE 256 81#define IWL50_QUEUE_SIZE 256
82#define IWL50_CMD_FIFO_NUM 7 82#define IWL50_CMD_FIFO_NUM 7
83#define IWL50_NUM_QUEUES 20 83#define IWL50_NUM_QUEUES 20
84#define IWL50_NUM_AMPDU_QUEUES 10
84#define IWL50_FIRST_AMPDU_QUEUE 10 85#define IWL50_FIRST_AMPDU_QUEUE 10
85 86
86#define IWL_sta_id_POS 12 87#define IWL_sta_id_POS 12
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 717db0d5ffb3..878d6193b232 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -370,6 +370,16 @@ static void iwl5000_chain_noise_reset(struct iwl_priv *priv)
370 } 370 }
371} 371}
372 372
373static void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
374 __le32 *tx_flags)
375{
376 if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
377 (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT))
378 *tx_flags |= TX_CMD_FLG_RTS_CTS_MSK;
379 else
380 *tx_flags &= ~TX_CMD_FLG_RTS_CTS_MSK;
381}
382
373static struct iwl_sensitivity_ranges iwl5000_sensitivity = { 383static struct iwl_sensitivity_ranges iwl5000_sensitivity = {
374 .min_nrg_cck = 95, 384 .min_nrg_cck = 95,
375 .max_nrg_cck = 0, 385 .max_nrg_cck = 0,
@@ -1006,9 +1016,13 @@ static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
1006 int ret; 1016 int ret;
1007 u16 ra_tid; 1017 u16 ra_tid;
1008 1018
1009 if (IWL50_FIRST_AMPDU_QUEUE > txq_id) 1019 if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
1010 IWL_WARNING("queue number too small: %d, must be > %d\n", 1020 (IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
1011 txq_id, IWL50_FIRST_AMPDU_QUEUE); 1021 IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
1022 txq_id, IWL50_FIRST_AMPDU_QUEUE,
1023 IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES - 1);
1024 return -EINVAL;
1025 }
1012 1026
1013 ra_tid = BUILD_RAxTID(sta_id, tid); 1027 ra_tid = BUILD_RAxTID(sta_id, tid);
1014 1028
@@ -1067,9 +1081,11 @@ static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
1067{ 1081{
1068 int ret; 1082 int ret;
1069 1083
1070 if (IWL50_FIRST_AMPDU_QUEUE > txq_id) { 1084 if ((IWL50_FIRST_AMPDU_QUEUE > txq_id) ||
1071 IWL_WARNING("queue number too small: %d, must be > %d\n", 1085 (IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES <= txq_id)) {
1072 txq_id, IWL50_FIRST_AMPDU_QUEUE); 1086 IWL_WARNING("queue number out of range: %d, must be %d to %d\n",
1087 txq_id, IWL50_FIRST_AMPDU_QUEUE,
1088 IWL50_FIRST_AMPDU_QUEUE + IWL50_NUM_AMPDU_QUEUES - 1);
1073 return -EINVAL; 1089 return -EINVAL;
1074 } 1090 }
1075 1091
@@ -1437,6 +1453,7 @@ static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
1437 .build_addsta_hcmd = iwl5000_build_addsta_hcmd, 1453 .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
1438 .gain_computation = iwl5000_gain_computation, 1454 .gain_computation = iwl5000_gain_computation,
1439 .chain_noise_reset = iwl5000_chain_noise_reset, 1455 .chain_noise_reset = iwl5000_chain_noise_reset,
1456 .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
1440}; 1457};
1441 1458
1442static struct iwl_lib_ops iwl5000_lib = { 1459static struct iwl_lib_ops iwl5000_lib = {
@@ -1490,6 +1507,7 @@ static struct iwl_ops iwl5000_ops = {
1490 1507
1491static struct iwl_mod_params iwl50_mod_params = { 1508static struct iwl_mod_params iwl50_mod_params = {
1492 .num_of_queues = IWL50_NUM_QUEUES, 1509 .num_of_queues = IWL50_NUM_QUEUES,
1510 .num_of_ampdu_queues = IWL50_NUM_AMPDU_QUEUES,
1493 .enable_qos = 1, 1511 .enable_qos = 1,
1494 .amsdu_size_8K = 1, 1512 .amsdu_size_8K = 1,
1495 .restart_fw = 1, 1513 .restart_fw = 1,
@@ -1506,6 +1524,24 @@ struct iwl_cfg iwl5300_agn_cfg = {
1506 .mod_params = &iwl50_mod_params, 1524 .mod_params = &iwl50_mod_params,
1507}; 1525};
1508 1526
1527struct iwl_cfg iwl5100_bg_cfg = {
1528 .name = "5100BG",
1529 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
1530 .sku = IWL_SKU_G,
1531 .ops = &iwl5000_ops,
1532 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
1533 .mod_params = &iwl50_mod_params,
1534};
1535
1536struct iwl_cfg iwl5100_abg_cfg = {
1537 .name = "5100ABG",
1538 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
1539 .sku = IWL_SKU_A|IWL_SKU_G,
1540 .ops = &iwl5000_ops,
1541 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
1542 .mod_params = &iwl50_mod_params,
1543};
1544
1509struct iwl_cfg iwl5100_agn_cfg = { 1545struct iwl_cfg iwl5100_agn_cfg = {
1510 .name = "5100AGN", 1546 .name = "5100AGN",
1511 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode", 1547 .fw_name = "iwlwifi-5000" IWL5000_UCODE_API ".ucode",
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index fe05d60ebe63..e9bb1de0ce3f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -556,6 +556,8 @@ enum {
556#define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3 << 25) 556#define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3 << 25)
557#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1 << 25) 557#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1 << 25)
558#define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2 << 25) 558#define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2 << 25)
559/* CTS to self (if spec allows) flag */
560#define RXON_FLG_SELF_CTS_EN __constant_cpu_to_le32(0x1<<30)
559 561
560/* rx_config filter flags */ 562/* rx_config filter flags */
561/* accept all data frames */ 563/* accept all data frames */
@@ -723,7 +725,7 @@ struct iwl4965_csa_notification {
723 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW 725 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
724 * value, to cap the CW value. 726 * value, to cap the CW value.
725 */ 727 */
726struct iwl4965_ac_qos { 728struct iwl_ac_qos {
727 __le16 cw_min; 729 __le16 cw_min;
728 __le16 cw_max; 730 __le16 cw_max;
729 u8 aifsn; 731 u8 aifsn;
@@ -745,9 +747,9 @@ struct iwl4965_ac_qos {
745 * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs 747 * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
746 * 0: Background, 1: Best Effort, 2: Video, 3: Voice. 748 * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
747 */ 749 */
748struct iwl4965_qosparam_cmd { 750struct iwl_qosparam_cmd {
749 __le32 qos_flags; 751 __le32 qos_flags;
750 struct iwl4965_ac_qos ac[AC_NUM]; 752 struct iwl_ac_qos ac[AC_NUM];
751} __attribute__ ((packed)); 753} __attribute__ ((packed));
752 754
753/****************************************************************************** 755/******************************************************************************
@@ -1139,6 +1141,11 @@ struct iwl4965_rx_mpdu_res_start {
1139 1141
1140/* REPLY_TX Tx flags field */ 1142/* REPLY_TX Tx flags field */
1141 1143
1144/* 1: Use RTS/CTS protocol or CTS-to-self if spec alows it
1145 * before this frame. if CTS-to-self required check
1146 * RXON_FLG_SELF_CTS_EN status. */
1147#define TX_CMD_FLG_RTS_CTS_MSK __constant_cpu_to_le32(1 << 0)
1148
1142/* 1: Use Request-To-Send protocol before this frame. 1149/* 1: Use Request-To-Send protocol before this frame.
1143 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */ 1150 * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */
1144#define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1) 1151#define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1)
@@ -2092,6 +2099,9 @@ struct iwl_ct_kill_config {
2092 * 2099 *
2093 *****************************************************************************/ 2100 *****************************************************************************/
2094 2101
2102#define SCAN_CHANNEL_TYPE_PASSIVE __constant_cpu_to_le32(0)
2103#define SCAN_CHANNEL_TYPE_ACTIVE __constant_cpu_to_le32(1)
2104
2095/** 2105/**
2096 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table 2106 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
2097 * 2107 *
@@ -2115,12 +2125,12 @@ struct iwl_scan_channel {
2115 /* 2125 /*
2116 * type is defined as: 2126 * type is defined as:
2117 * 0:0 1 = active, 0 = passive 2127 * 0:0 1 = active, 0 = passive
2118 * 1:4 SSID direct bit map; if a bit is set, then corresponding 2128 * 1:20 SSID direct bit map; if a bit is set, then corresponding
2119 * SSID IE is transmitted in probe request. 2129 * SSID IE is transmitted in probe request.
2120 * 5:7 reserved 2130 * 21:31 reserved
2121 */ 2131 */
2122 u8 type; 2132 __le32 type;
2123 u8 channel; /* band is selected by iwl4965_scan_cmd "flags" field */ 2133 __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */
2124 u8 tx_gain; /* gain for analog radio */ 2134 u8 tx_gain; /* gain for analog radio */
2125 u8 dsp_atten; /* gain for DSP */ 2135 u8 dsp_atten; /* gain for DSP */
2126 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ 2136 __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
@@ -2140,9 +2150,9 @@ struct iwl_ssid_ie {
2140 u8 ssid[32]; 2150 u8 ssid[32];
2141} __attribute__ ((packed)); 2151} __attribute__ ((packed));
2142 2152
2143#define PROBE_OPTION_MAX 0x4 2153#define PROBE_OPTION_MAX 0x14
2144#define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF) 2154#define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF)
2145#define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1) 2155#define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1)
2146#define IWL_MAX_SCAN_SIZE 1024 2156#define IWL_MAX_SCAN_SIZE 1024
2147 2157
2148/* 2158/*
@@ -2919,7 +2929,7 @@ struct iwl5000_calibration_chain_noise_gain_cmd {
2919 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), 2929 * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
2920 * this command turns it on or off, or sets up a periodic blinking cycle. 2930 * this command turns it on or off, or sets up a periodic blinking cycle.
2921 */ 2931 */
2922struct iwl4965_led_cmd { 2932struct iwl_led_cmd {
2923 __le32 interval; /* "interval" in uSec */ 2933 __le32 interval; /* "interval" in uSec */
2924 u8 id; /* 1: Activity, 2: Link, 3: Tech */ 2934 u8 id; /* 1: Activity, 2: Link, 3: Tech */
2925 u8 off; /* # intervals off while blinking; 2935 u8 off; /* # intervals off while blinking;
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index eee220cf52a2..a44188bf4459 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -825,7 +825,7 @@ int iwl_setup_mac(struct iwl_priv *priv)
825 hw->queues = 4; 825 hw->queues = 4;
826 /* queues to support 11n aggregation */ 826 /* queues to support 11n aggregation */
827 if (priv->cfg->sku & IWL_SKU_N) 827 if (priv->cfg->sku & IWL_SKU_N)
828 hw->ampdu_queues = 12; 828 hw->ampdu_queues = priv->cfg->mod_params->num_of_ampdu_queues;
829 829
830 hw->conf.beacon_int = 100; 830 hw->conf.beacon_int = 100;
831 831
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index dafd62c7dfd6..db66114f1e56 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -70,7 +70,7 @@ struct iwl_host_cmd;
70struct iwl_cmd; 70struct iwl_cmd;
71 71
72 72
73#define IWLWIFI_VERSION "1.2.26k" 73#define IWLWIFI_VERSION "1.3.27k"
74#define DRV_COPYRIGHT "Copyright(c) 2003-2008 Intel Corporation" 74#define DRV_COPYRIGHT "Copyright(c) 2003-2008 Intel Corporation"
75 75
76#define IWL_PCI_DEVICE(dev, subdev, cfg) \ 76#define IWL_PCI_DEVICE(dev, subdev, cfg) \
@@ -93,6 +93,8 @@ struct iwl_hcmd_utils_ops {
93 u16 min_average_noise_antennat_i, 93 u16 min_average_noise_antennat_i,
94 u32 min_average_noise); 94 u32 min_average_noise);
95 void (*chain_noise_reset)(struct iwl_priv *priv); 95 void (*chain_noise_reset)(struct iwl_priv *priv);
96 void (*rts_tx_cmd_flag)(struct ieee80211_tx_info *info,
97 __le32 *tx_flags);
96}; 98};
97 99
98struct iwl_lib_ops { 100struct iwl_lib_ops {
@@ -157,6 +159,7 @@ struct iwl_mod_params {
157 int debug; /* def: 0 = minimal debug log messages */ 159 int debug; /* def: 0 = minimal debug log messages */
158 int disable_hw_scan; /* def: 0 = use h/w scan */ 160 int disable_hw_scan; /* def: 0 = use h/w scan */
159 int num_of_queues; /* def: HW dependent */ 161 int num_of_queues; /* def: HW dependent */
162 int num_of_ampdu_queues;/* def: HW dependent */
160 int enable_qos; /* def: 1 = use quality of service */ 163 int enable_qos; /* def: 1 = use quality of service */
161 int disable_11n; /* def: 0 = disable 11n capabilities */ 164 int disable_11n; /* def: 0 = disable 11n capabilities */
162 int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ 165 int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c8d3d97cf48d..4d789e353e3a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -51,12 +51,8 @@ extern struct iwl_cfg iwl4965_agn_cfg;
51extern struct iwl_cfg iwl5300_agn_cfg; 51extern struct iwl_cfg iwl5300_agn_cfg;
52extern struct iwl_cfg iwl5100_agn_cfg; 52extern struct iwl_cfg iwl5100_agn_cfg;
53extern struct iwl_cfg iwl5350_agn_cfg; 53extern struct iwl_cfg iwl5350_agn_cfg;
54 54extern struct iwl_cfg iwl5100_bg_cfg;
55/* Change firmware file name, using "-" and incrementing number, 55extern struct iwl_cfg iwl5100_abg_cfg;
56 * *only* when uCode interface or architecture changes so that it
57 * is not compatible with earlier drivers.
58 * This number will also appear in << 8 position of 1st dword of uCode file */
59#define IWL4965_UCODE_API "-1"
60 56
61/* CT-KILL constants */ 57/* CT-KILL constants */
62#define CT_KILL_THRESHOLD 110 /* in Celsius */ 58#define CT_KILL_THRESHOLD 110 /* in Celsius */
@@ -280,7 +276,7 @@ struct iwl_cmd {
280 struct iwl_cmd_header hdr; /* uCode API */ 276 struct iwl_cmd_header hdr; /* uCode API */
281 union { 277 union {
282 struct iwl_addsta_cmd addsta; 278 struct iwl_addsta_cmd addsta;
283 struct iwl4965_led_cmd led; 279 struct iwl_led_cmd led;
284 u32 flags; 280 u32 flags;
285 u8 val8; 281 u8 val8;
286 u16 val16; 282 u16 val16;
@@ -288,7 +284,7 @@ struct iwl_cmd {
288 struct iwl4965_bt_cmd bt; 284 struct iwl4965_bt_cmd bt;
289 struct iwl4965_rxon_time_cmd rxon_time; 285 struct iwl4965_rxon_time_cmd rxon_time;
290 struct iwl4965_powertable_cmd powertable; 286 struct iwl4965_powertable_cmd powertable;
291 struct iwl4965_qosparam_cmd qosparam; 287 struct iwl_qosparam_cmd qosparam;
292 struct iwl_tx_cmd tx; 288 struct iwl_tx_cmd tx;
293 struct iwl4965_tx_beacon_cmd tx_beacon; 289 struct iwl4965_tx_beacon_cmd tx_beacon;
294 struct iwl4965_rxon_assoc_cmd rxon_assoc; 290 struct iwl4965_rxon_assoc_cmd rxon_assoc;
@@ -433,7 +429,7 @@ struct iwl_ht_info {
433 u8 non_GF_STA_present; 429 u8 non_GF_STA_present;
434}; 430};
435 431
436union iwl4965_qos_capabity { 432union iwl_qos_capabity {
437 struct { 433 struct {
438 u8 edca_count:4; /* bit 0-3 */ 434 u8 edca_count:4; /* bit 0-3 */
439 u8 q_ack:1; /* bit 4 */ 435 u8 q_ack:1; /* bit 4 */
@@ -454,11 +450,11 @@ union iwl4965_qos_capabity {
454}; 450};
455 451
456/* QoS structures */ 452/* QoS structures */
457struct iwl4965_qos_info { 453struct iwl_qos_info {
458 int qos_enable; 454 int qos_enable;
459 int qos_active; 455 int qos_active;
460 union iwl4965_qos_capabity qos_cap; 456 union iwl_qos_capabity qos_cap;
461 struct iwl4965_qosparam_cmd def_qos_parm; 457 struct iwl_qosparam_cmd def_qos_parm;
462}; 458};
463 459
464#define STA_PS_STATUS_WAKE 0 460#define STA_PS_STATUS_WAKE 0
@@ -490,8 +486,6 @@ struct iwl_ucode {
490 u8 data[0]; /* data in same order as "size" elements */ 486 u8 data[0]; /* data in same order as "size" elements */
491}; 487};
492 488
493#define IWL_IBSS_MAC_HASH_SIZE 32
494
495struct iwl4965_ibss_seq { 489struct iwl4965_ibss_seq {
496 u8 mac[ETH_ALEN]; 490 u8 mac[ETH_ALEN];
497 u16 seq_num; 491 u16 seq_num;
@@ -933,7 +927,7 @@ struct iwl_priv {
933#endif 927#endif
934 928
935#ifdef CONFIG_IWLWIFI_LEDS 929#ifdef CONFIG_IWLWIFI_LEDS
936 struct iwl4965_led led[IWL_LED_TRG_MAX]; 930 struct iwl_led led[IWL_LED_TRG_MAX];
937 unsigned long last_blink_time; 931 unsigned long last_blink_time;
938 u8 last_blink_rate; 932 u8 last_blink_rate;
939 u8 allow_blinking; 933 u8 allow_blinking;
@@ -1042,7 +1036,7 @@ struct iwl_priv {
1042 u16 assoc_capability; 1036 u16 assoc_capability;
1043 u8 ps_mode; 1037 u8 ps_mode;
1044 1038
1045 struct iwl4965_qos_info qos_data; 1039 struct iwl_qos_info qos_data;
1046 1040
1047 struct workqueue_struct *workqueue; 1041 struct workqueue_struct *workqueue;
1048 1042
@@ -1065,7 +1059,6 @@ struct iwl_priv {
1065 struct delayed_work init_alive_start; 1059 struct delayed_work init_alive_start;
1066 struct delayed_work alive_start; 1060 struct delayed_work alive_start;
1067 struct delayed_work scan_check; 1061 struct delayed_work scan_check;
1068 struct delayed_work post_associate;
1069 /* TX Power */ 1062 /* TX Power */
1070 s8 tx_power_user_lmt; 1063 s8 tx_power_user_lmt;
1071 s8 tx_power_channel_lmt; 1064 s8 tx_power_channel_lmt;
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index aa6ad18494ce..899d7a2567a8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -44,14 +44,21 @@
44#include "iwl-io.h" 44#include "iwl-io.h"
45#include "iwl-helpers.h" 45#include "iwl-helpers.h"
46 46
47#define IWL_1MB_RATE (128 * 1024) 47#ifdef CONFIG_IWLWIFI_DEBUG
48#define IWL_LED_THRESHOLD (16) 48static const char *led_type_str[] = {
49#define IWL_MAX_BLINK_TBL (10) 49 __stringify(IWL_LED_TRG_TX),
50 __stringify(IWL_LED_TRG_RX),
51 __stringify(IWL_LED_TRG_ASSOC),
52 __stringify(IWL_LED_TRG_RADIO),
53 NULL
54};
55#endif /* CONFIG_IWLWIFI_DEBUG */
56
50 57
51static const struct { 58static const struct {
52 u16 tpt; 59 u16 tpt;
53 u8 on_time; 60 u8 on_time;
54 u8 of_time; 61 u8 off_time;
55} blink_tbl[] = 62} blink_tbl[] =
56{ 63{
57 {300, 25, 25}, 64 {300, 25, 25},
@@ -63,26 +70,31 @@ static const struct {
63 {15, 95, 95 }, 70 {15, 95, 95 },
64 {10, 110, 110}, 71 {10, 110, 110},
65 {5, 130, 130}, 72 {5, 130, 130},
66 {0, 167, 167} 73 {0, 167, 167},
74/* SOLID_ON */
75 {-1, IWL_LED_SOLID, 0}
67}; 76};
68 77
69static int iwl_led_cmd_callback(struct iwl_priv *priv, 78#define IWL_1MB_RATE (128 * 1024)
70 struct iwl_cmd *cmd, struct sk_buff *skb) 79#define IWL_LED_THRESHOLD (16)
80#define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /* exclude SOLID_ON */
81#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1)
82
83/* [0-256] -> [0..8] FIXME: we need [0..10] */
84static inline int iwl_brightness_to_idx(enum led_brightness brightness)
71{ 85{
72 return 1; 86 return fls(0x000000FF & (u32)brightness);
73} 87}
74 88
75
76/* Send led command */ 89/* Send led command */
77static int iwl_send_led_cmd(struct iwl_priv *priv, 90static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
78 struct iwl4965_led_cmd *led_cmd)
79{ 91{
80 struct iwl_host_cmd cmd = { 92 struct iwl_host_cmd cmd = {
81 .id = REPLY_LEDS_CMD, 93 .id = REPLY_LEDS_CMD,
82 .len = sizeof(struct iwl4965_led_cmd), 94 .len = sizeof(struct iwl_led_cmd),
83 .data = led_cmd, 95 .data = led_cmd,
84 .meta.flags = CMD_ASYNC, 96 .meta.flags = CMD_ASYNC,
85 .meta.u.callback = iwl_led_cmd_callback 97 .meta.u.callback = NULL,
86 }; 98 };
87 u32 reg; 99 u32 reg;
88 100
@@ -93,33 +105,20 @@ static int iwl_send_led_cmd(struct iwl_priv *priv,
93 return iwl_send_cmd(priv, &cmd); 105 return iwl_send_cmd(priv, &cmd);
94} 106}
95 107
96 108/* Set led pattern command */
97/* Set led on command */
98static int iwl4965_led_on(struct iwl_priv *priv, int led_id)
99{
100 struct iwl4965_led_cmd led_cmd = {
101 .id = led_id,
102 .on = IWL_LED_SOLID,
103 .off = 0,
104 .interval = IWL_DEF_LED_INTRVL
105 };
106 return iwl_send_led_cmd(priv, &led_cmd);
107}
108
109/* Set led on command */
110static int iwl4965_led_pattern(struct iwl_priv *priv, int led_id, 109static int iwl4965_led_pattern(struct iwl_priv *priv, int led_id,
111 enum led_brightness brightness) 110 unsigned int idx)
112{ 111{
113 struct iwl4965_led_cmd led_cmd = { 112 struct iwl_led_cmd led_cmd = {
114 .id = led_id, 113 .id = led_id,
115 .on = brightness,
116 .off = brightness,
117 .interval = IWL_DEF_LED_INTRVL 114 .interval = IWL_DEF_LED_INTRVL
118 }; 115 };
119 if (brightness == LED_FULL) { 116
120 led_cmd.on = IWL_LED_SOLID; 117 BUG_ON(idx > IWL_MAX_BLINK_TBL);
121 led_cmd.off = 0; 118
122 } 119 led_cmd.on = blink_tbl[idx].on_time;
120 led_cmd.off = blink_tbl[idx].off_time;
121
123 return iwl_send_led_cmd(priv, &led_cmd); 122 return iwl_send_led_cmd(priv, &led_cmd);
124} 123}
125 124
@@ -132,10 +131,22 @@ static int iwl4965_led_on_reg(struct iwl_priv *priv, int led_id)
132} 131}
133 132
134#if 0 133#if 0
134/* Set led on command */
135static int iwl4965_led_on(struct iwl_priv *priv, int led_id)
136{
137 struct iwl_led_cmd led_cmd = {
138 .id = led_id,
139 .on = IWL_LED_SOLID,
140 .off = 0,
141 .interval = IWL_DEF_LED_INTRVL
142 };
143 return iwl_send_led_cmd(priv, &led_cmd);
144}
145
135/* Set led off command */ 146/* Set led off command */
136int iwl4965_led_off(struct iwl_priv *priv, int led_id) 147int iwl4965_led_off(struct iwl_priv *priv, int led_id)
137{ 148{
138 struct iwl4965_led_cmd led_cmd = { 149 struct iwl_led_cmd led_cmd = {
139 .id = led_id, 150 .id = led_id,
140 .on = 0, 151 .on = 0,
141 .off = 0, 152 .off = 0,
@@ -155,25 +166,10 @@ static int iwl4965_led_off_reg(struct iwl_priv *priv, int led_id)
155 return 0; 166 return 0;
156} 167}
157 168
158/* Set led blink command */
159static int iwl4965_led_not_solid(struct iwl_priv *priv, int led_id,
160 u8 brightness)
161{
162 struct iwl4965_led_cmd led_cmd = {
163 .id = led_id,
164 .on = brightness,
165 .off = brightness,
166 .interval = IWL_DEF_LED_INTRVL
167 };
168
169 return iwl_send_led_cmd(priv, &led_cmd);
170}
171
172
173/* 169/*
174 * brightness call back function for Tx/Rx LED 170 * brightness call back function for Tx/Rx LED
175 */ 171 */
176static int iwl4965_led_associated(struct iwl_priv *priv, int led_id) 172static int iwl_led_associated(struct iwl_priv *priv, int led_id)
177{ 173{
178 if (test_bit(STATUS_EXIT_PENDING, &priv->status) || 174 if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
179 !test_bit(STATUS_READY, &priv->status)) 175 !test_bit(STATUS_READY, &priv->status))
@@ -189,16 +185,18 @@ static int iwl4965_led_associated(struct iwl_priv *priv, int led_id)
189/* 185/*
190 * brightness call back for association and radio 186 * brightness call back for association and radio
191 */ 187 */
192static void iwl4965_led_brightness_set(struct led_classdev *led_cdev, 188static void iwl_led_brightness_set(struct led_classdev *led_cdev,
193 enum led_brightness brightness) 189 enum led_brightness brightness)
194{ 190{
195 struct iwl4965_led *led = container_of(led_cdev, 191 struct iwl_led *led = container_of(led_cdev, struct iwl_led, led_dev);
196 struct iwl4965_led, led_dev);
197 struct iwl_priv *priv = led->priv; 192 struct iwl_priv *priv = led->priv;
198 193
199 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 194 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
200 return; 195 return;
201 196
197
198 IWL_DEBUG_LED("Led type = %s brightness = %d\n",
199 led_type_str[led->type], brightness);
202 switch (brightness) { 200 switch (brightness) {
203 case LED_FULL: 201 case LED_FULL:
204 if (led->type == IWL_LED_TRG_ASSOC) 202 if (led->type == IWL_LED_TRG_ASSOC)
@@ -215,8 +213,10 @@ static void iwl4965_led_brightness_set(struct led_classdev *led_cdev,
215 led->led_off(priv, IWL_LED_LINK); 213 led->led_off(priv, IWL_LED_LINK);
216 break; 214 break;
217 default: 215 default:
218 if (led->led_pattern) 216 if (led->led_pattern) {
219 led->led_pattern(priv, IWL_LED_LINK, brightness); 217 int idx = iwl_brightness_to_idx(brightness);
218 led->led_pattern(priv, IWL_LED_LINK, idx);
219 }
220 break; 220 break;
221 } 221 }
222} 222}
@@ -226,8 +226,7 @@ static void iwl4965_led_brightness_set(struct led_classdev *led_cdev,
226/* 226/*
227 * Register led class with the system 227 * Register led class with the system
228 */ 228 */
229static int iwl_leds_register_led(struct iwl_priv *priv, 229static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led,
230 struct iwl4965_led *led,
231 enum led_type type, u8 set_led, 230 enum led_type type, u8 set_led,
232 const char *name, char *trigger) 231 const char *name, char *trigger)
233{ 232{
@@ -235,7 +234,7 @@ static int iwl_leds_register_led(struct iwl_priv *priv,
235 int ret; 234 int ret;
236 235
237 led->led_dev.name = name; 236 led->led_dev.name = name;
238 led->led_dev.brightness_set = iwl4965_led_brightness_set; 237 led->led_dev.brightness_set = iwl_led_brightness_set;
239 led->led_dev.default_trigger = trigger; 238 led->led_dev.default_trigger = trigger;
240 239
241 led->priv = priv; 240 led->priv = priv;
@@ -259,32 +258,28 @@ static int iwl_leds_register_led(struct iwl_priv *priv,
259/* 258/*
260 * calculate blink rate according to last 2 sec Tx/Rx activities 259 * calculate blink rate according to last 2 sec Tx/Rx activities
261 */ 260 */
262static inline u8 get_blink_rate(struct iwl_priv *priv) 261static int iwl_get_blink_rate(struct iwl_priv *priv)
263{ 262{
264 int i; 263 int i;
265 u8 blink_rate; 264 u64 current_tpt = priv->tx_stats[2].bytes;
266 u64 current_tpt = priv->tx_stats[2].bytes + priv->rx_stats[2].bytes; 265 /* FIXME: + priv->rx_stats[2].bytes; */
267 s64 tpt = current_tpt - priv->led_tpt; 266 s64 tpt = current_tpt - priv->led_tpt;
268 267
269 if (tpt < 0) /* wrapparound */ 268 if (tpt < 0) /* wrapparound */
270 tpt = -tpt; 269 tpt = -tpt;
271 270
271 IWL_DEBUG_LED("tpt %lld current_tpt %lld\n", tpt, current_tpt);
272 priv->led_tpt = current_tpt; 272 priv->led_tpt = current_tpt;
273 273
274 if (tpt < IWL_LED_THRESHOLD) { 274 if (!priv->allow_blinking)
275 i = IWL_MAX_BLINK_TBL; 275 i = IWL_MAX_BLINK_TBL;
276 } else { 276 else
277 for (i = 0; i < IWL_MAX_BLINK_TBL; i++) 277 for (i = 0; i < IWL_MAX_BLINK_TBL; i++)
278 if (tpt > (blink_tbl[i].tpt * IWL_1MB_RATE)) 278 if (tpt > (blink_tbl[i].tpt * IWL_1MB_RATE))
279 break; 279 break;
280 }
281 /* if 0 frame is transfered */
282 if ((i == IWL_MAX_BLINK_TBL) || !priv->allow_blinking)
283 blink_rate = IWL_LED_SOLID;
284 else
285 blink_rate = blink_tbl[i].on_time;
286 280
287 return blink_rate; 281 IWL_DEBUG_LED("LED BLINK IDX=%d", i);
282 return i;
288} 283}
289 284
290static inline int is_rf_kill(struct iwl_priv *priv) 285static inline int is_rf_kill(struct iwl_priv *priv)
@@ -300,7 +295,7 @@ static inline int is_rf_kill(struct iwl_priv *priv)
300 */ 295 */
301void iwl_leds_background(struct iwl_priv *priv) 296void iwl_leds_background(struct iwl_priv *priv)
302{ 297{
303 u8 blink_rate; 298 u8 blink_idx;
304 299
305 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 300 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
306 priv->last_blink_time = 0; 301 priv->last_blink_time = 0;
@@ -313,9 +308,10 @@ void iwl_leds_background(struct iwl_priv *priv)
313 308
314 if (!priv->allow_blinking) { 309 if (!priv->allow_blinking) {
315 priv->last_blink_time = 0; 310 priv->last_blink_time = 0;
316 if (priv->last_blink_rate != IWL_LED_SOLID) { 311 if (priv->last_blink_rate != IWL_SOLID_BLINK_IDX) {
317 priv->last_blink_rate = IWL_LED_SOLID; 312 priv->last_blink_rate = IWL_SOLID_BLINK_IDX;
318 iwl4965_led_on(priv, IWL_LED_LINK); 313 iwl4965_led_pattern(priv, IWL_LED_LINK,
314 IWL_SOLID_BLINK_IDX);
319 } 315 }
320 return; 316 return;
321 } 317 }
@@ -324,21 +320,14 @@ void iwl_leds_background(struct iwl_priv *priv)
324 msecs_to_jiffies(1000))) 320 msecs_to_jiffies(1000)))
325 return; 321 return;
326 322
327 blink_rate = get_blink_rate(priv); 323 blink_idx = iwl_get_blink_rate(priv);
328 324
329 /* call only if blink rate change */ 325 /* call only if blink rate change */
330 if (blink_rate != priv->last_blink_rate) { 326 if (blink_idx != priv->last_blink_rate)
331 if (blink_rate != IWL_LED_SOLID) { 327 iwl4965_led_pattern(priv, IWL_LED_LINK, blink_idx);
332 priv->last_blink_time = jiffies +
333 msecs_to_jiffies(1000);
334 iwl4965_led_not_solid(priv, IWL_LED_LINK, blink_rate);
335 } else {
336 priv->last_blink_time = 0;
337 iwl4965_led_on(priv, IWL_LED_LINK);
338 }
339 }
340 328
341 priv->last_blink_rate = blink_rate; 329 priv->last_blink_time = jiffies;
330 priv->last_blink_rate = blink_idx;
342} 331}
343EXPORT_SYMBOL(iwl_leds_background); 332EXPORT_SYMBOL(iwl_leds_background);
344 333
@@ -362,10 +351,8 @@ int iwl_leds_register(struct iwl_priv *priv)
362 priv->led[IWL_LED_TRG_RADIO].led_off = iwl4965_led_off_reg; 351 priv->led[IWL_LED_TRG_RADIO].led_off = iwl4965_led_off_reg;
363 priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL; 352 priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
364 353
365 ret = iwl_leds_register_led(priv, 354 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RADIO],
366 &priv->led[IWL_LED_TRG_RADIO], 355 IWL_LED_TRG_RADIO, 1, name, trigger);
367 IWL_LED_TRG_RADIO, 1,
368 name, trigger);
369 if (ret) 356 if (ret)
370 goto exit_fail; 357 goto exit_fail;
371 358
@@ -373,10 +360,9 @@ int iwl_leds_register(struct iwl_priv *priv)
373 snprintf(name, sizeof(name), "iwl-%s:assoc", 360 snprintf(name, sizeof(name), "iwl-%s:assoc",
374 wiphy_name(priv->hw->wiphy)); 361 wiphy_name(priv->hw->wiphy));
375 362
376 ret = iwl_leds_register_led(priv, 363 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC],
377 &priv->led[IWL_LED_TRG_ASSOC], 364 IWL_LED_TRG_ASSOC, 0, name, trigger);
378 IWL_LED_TRG_ASSOC, 0, 365
379 name, trigger);
380 /* for assoc always turn led on */ 366 /* for assoc always turn led on */
381 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl4965_led_on_reg; 367 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl4965_led_on_reg;
382 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl4965_led_on_reg; 368 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl4965_led_on_reg;
@@ -386,31 +372,26 @@ int iwl_leds_register(struct iwl_priv *priv)
386 goto exit_fail; 372 goto exit_fail;
387 373
388 trigger = ieee80211_get_rx_led_name(priv->hw); 374 trigger = ieee80211_get_rx_led_name(priv->hw);
389 snprintf(name, sizeof(name), "iwl-%s:RX", 375 snprintf(name, sizeof(name), "iwl-%s:RX", wiphy_name(priv->hw->wiphy));
390 wiphy_name(priv->hw->wiphy));
391 376
392 377
393 ret = iwl_leds_register_led(priv, 378 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX],
394 &priv->led[IWL_LED_TRG_RX], 379 IWL_LED_TRG_RX, 0, name, trigger);
395 IWL_LED_TRG_RX, 0,
396 name, trigger);
397 380
398 priv->led[IWL_LED_TRG_RX].led_on = iwl4965_led_associated; 381 priv->led[IWL_LED_TRG_RX].led_on = iwl_led_associated;
399 priv->led[IWL_LED_TRG_RX].led_off = iwl4965_led_associated; 382 priv->led[IWL_LED_TRG_RX].led_off = iwl_led_associated;
400 priv->led[IWL_LED_TRG_RX].led_pattern = iwl4965_led_pattern; 383 priv->led[IWL_LED_TRG_RX].led_pattern = iwl4965_led_pattern;
401 384
402 if (ret) 385 if (ret)
403 goto exit_fail; 386 goto exit_fail;
404 387
405 trigger = ieee80211_get_tx_led_name(priv->hw); 388 trigger = ieee80211_get_tx_led_name(priv->hw);
406 snprintf(name, sizeof(name), "iwl-%s:TX", 389 snprintf(name, sizeof(name), "iwl-%s:TX", wiphy_name(priv->hw->wiphy));
407 wiphy_name(priv->hw->wiphy)); 390 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX],
408 ret = iwl_leds_register_led(priv, 391 IWL_LED_TRG_TX, 0, name, trigger);
409 &priv->led[IWL_LED_TRG_TX], 392
410 IWL_LED_TRG_TX, 0, 393 priv->led[IWL_LED_TRG_TX].led_on = iwl_led_associated;
411 name, trigger); 394 priv->led[IWL_LED_TRG_TX].led_off = iwl_led_associated;
412 priv->led[IWL_LED_TRG_TX].led_on = iwl4965_led_associated;
413 priv->led[IWL_LED_TRG_TX].led_off = iwl4965_led_associated;
414 priv->led[IWL_LED_TRG_TX].led_pattern = iwl4965_led_pattern; 395 priv->led[IWL_LED_TRG_TX].led_pattern = iwl4965_led_pattern;
415 396
416 if (ret) 397 if (ret)
@@ -425,7 +406,7 @@ exit_fail:
425EXPORT_SYMBOL(iwl_leds_register); 406EXPORT_SYMBOL(iwl_leds_register);
426 407
427/* unregister led class */ 408/* unregister led class */
428static void iwl_leds_unregister_led(struct iwl4965_led *led, u8 set_led) 409static void iwl_leds_unregister_led(struct iwl_led *led, u8 set_led)
429{ 410{
430 if (!led->registered) 411 if (!led->registered)
431 return; 412 return;
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.h b/drivers/net/wireless/iwlwifi/iwl-led.h
index 5bb04128cd65..1980ae5a7e82 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.h
+++ b/drivers/net/wireless/iwlwifi/iwl-led.h
@@ -49,14 +49,13 @@ enum led_type {
49}; 49};
50 50
51 51
52struct iwl4965_led { 52struct iwl_led {
53 struct iwl_priv *priv; 53 struct iwl_priv *priv;
54 struct led_classdev led_dev; 54 struct led_classdev led_dev;
55 55
56 int (*led_on) (struct iwl_priv *priv, int led_id); 56 int (*led_on) (struct iwl_priv *priv, int led_id);
57 int (*led_off) (struct iwl_priv *priv, int led_id); 57 int (*led_off) (struct iwl_priv *priv, int led_id);
58 int (*led_pattern) (struct iwl_priv *priv, int led_id, 58 int (*led_pattern) (struct iwl_priv *priv, int led_id, unsigned int idx);
59 enum led_brightness brightness);
60 59
61 enum led_type type; 60 enum led_type type;
62 unsigned int registered; 61 unsigned int registered;
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 3e8500ecf598..e2d9afba38a5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
31#include <net/mac80211.h> 31#include <net/mac80211.h>
32#include <asm/unaligned.h>
32#include "iwl-eeprom.h" 33#include "iwl-eeprom.h"
33#include "iwl-dev.h" 34#include "iwl-dev.h"
34#include "iwl-core.h" 35#include "iwl-core.h"
@@ -829,23 +830,22 @@ static void iwl_add_radiotap(struct iwl_priv *priv,
829 iwl4965_rt->rt_hdr.it_pad = 0; 830 iwl4965_rt->rt_hdr.it_pad = 0;
830 831
831 /* total header + data */ 832 /* total header + data */
832 put_unaligned(cpu_to_le16(sizeof(*iwl4965_rt)), 833 put_unaligned_le16(sizeof(*iwl4965_rt), &iwl4965_rt->rt_hdr.it_len);
833 &iwl4965_rt->rt_hdr.it_len);
834 834
835 /* Indicate all the fields we add to the radiotap header */ 835 /* Indicate all the fields we add to the radiotap header */
836 put_unaligned(cpu_to_le32((1 << IEEE80211_RADIOTAP_TSFT) | 836 put_unaligned_le32((1 << IEEE80211_RADIOTAP_TSFT) |
837 (1 << IEEE80211_RADIOTAP_FLAGS) | 837 (1 << IEEE80211_RADIOTAP_FLAGS) |
838 (1 << IEEE80211_RADIOTAP_RATE) | 838 (1 << IEEE80211_RADIOTAP_RATE) |
839 (1 << IEEE80211_RADIOTAP_CHANNEL) | 839 (1 << IEEE80211_RADIOTAP_CHANNEL) |
840 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | 840 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
841 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | 841 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |
842 (1 << IEEE80211_RADIOTAP_ANTENNA)), 842 (1 << IEEE80211_RADIOTAP_ANTENNA),
843 &iwl4965_rt->rt_hdr.it_present); 843 &(iwl4965_rt->rt_hdr.it_present));
844 844
845 /* Zero the flags, we'll add to them as we go */ 845 /* Zero the flags, we'll add to them as we go */
846 iwl4965_rt->rt_flags = 0; 846 iwl4965_rt->rt_flags = 0;
847 847
848 put_unaligned(cpu_to_le64(tsf), &iwl4965_rt->rt_tsf); 848 put_unaligned_le64(tsf, &iwl4965_rt->rt_tsf);
849 849
850 iwl4965_rt->rt_dbmsignal = signal; 850 iwl4965_rt->rt_dbmsignal = signal;
851 iwl4965_rt->rt_dbmnoise = noise; 851 iwl4965_rt->rt_dbmnoise = noise;
@@ -853,17 +853,14 @@ static void iwl_add_radiotap(struct iwl_priv *priv,
853 /* Convert the channel frequency and set the flags */ 853 /* Convert the channel frequency and set the flags */
854 put_unaligned(cpu_to_le16(stats->freq), &iwl4965_rt->rt_channelMHz); 854 put_unaligned(cpu_to_le16(stats->freq), &iwl4965_rt->rt_channelMHz);
855 if (!(phy_flags_hw & RX_RES_PHY_FLAGS_BAND_24_MSK)) 855 if (!(phy_flags_hw & RX_RES_PHY_FLAGS_BAND_24_MSK))
856 put_unaligned(cpu_to_le16(IEEE80211_CHAN_OFDM | 856 put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ,
857 IEEE80211_CHAN_5GHZ), 857 &iwl4965_rt->rt_chbitmask);
858 &iwl4965_rt->rt_chbitmask);
859 else if (phy_flags_hw & RX_RES_PHY_FLAGS_MOD_CCK_MSK) 858 else if (phy_flags_hw & RX_RES_PHY_FLAGS_MOD_CCK_MSK)
860 put_unaligned(cpu_to_le16(IEEE80211_CHAN_CCK | 859 put_unaligned_le16(IEEE80211_CHAN_CCK | IEEE80211_CHAN_2GHZ,
861 IEEE80211_CHAN_2GHZ), 860 &iwl4965_rt->rt_chbitmask);
862 &iwl4965_rt->rt_chbitmask);
863 else /* 802.11g */ 861 else /* 802.11g */
864 put_unaligned(cpu_to_le16(IEEE80211_CHAN_OFDM | 862 put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ,
865 IEEE80211_CHAN_2GHZ), 863 &iwl4965_rt->rt_chbitmask);
866 &iwl4965_rt->rt_chbitmask);
867 864
868 if (rate == -1) 865 if (rate == -1)
869 iwl4965_rt->rt_rate = 0; 866 iwl4965_rt->rt_rate = 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 5b420b43af5c..efc750d2fc5c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -38,8 +38,11 @@
38/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after 38/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after
39 * sending probe req. This should be set long enough to hear probe responses 39 * sending probe req. This should be set long enough to hear probe responses
40 * from more than one AP. */ 40 * from more than one AP. */
41#define IWL_ACTIVE_DWELL_TIME_24 (20) /* all times in msec */ 41#define IWL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */
42#define IWL_ACTIVE_DWELL_TIME_52 (10) 42#define IWL_ACTIVE_DWELL_TIME_52 (20)
43
44#define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3)
45#define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2)
43 46
44/* For faster active scanning, scan will move to the next channel if fewer than 47/* For faster active scanning, scan will move to the next channel if fewer than
45 * PLCP_QUIET_THRESH packets are heard on this channel within 48 * PLCP_QUIET_THRESH packets are heard on this channel within
@@ -48,7 +51,7 @@
48 * no other traffic). 51 * no other traffic).
49 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ 52 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
50#define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */ 53#define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */
51#define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(5) /* msec */ 54#define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(10) /* msec */
52 55
53/* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. 56/* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel.
54 * Must be set longer than active dwell time. 57 * Must be set longer than active dwell time.
@@ -58,10 +61,15 @@
58#define IWL_PASSIVE_DWELL_BASE (100) 61#define IWL_PASSIVE_DWELL_BASE (100)
59#define IWL_CHANNEL_TUNE_TIME 5 62#define IWL_CHANNEL_TUNE_TIME 5
60 63
64#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
65
66
61static int scan_tx_ant[3] = { 67static int scan_tx_ant[3] = {
62 RATE_MCS_ANT_A_MSK, RATE_MCS_ANT_B_MSK, RATE_MCS_ANT_C_MSK 68 RATE_MCS_ANT_A_MSK, RATE_MCS_ANT_B_MSK, RATE_MCS_ANT_C_MSK
63}; 69};
64 70
71
72
65static int iwl_is_empty_essid(const char *essid, int essid_len) 73static int iwl_is_empty_essid(const char *essid, int essid_len)
66{ 74{
67 /* Single white space is for Linksys APs */ 75 /* Single white space is for Linksys APs */
@@ -226,8 +234,9 @@ static void iwl_rx_scan_start_notif(struct iwl_priv *priv,
226 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", 234 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n",
227 notif->channel, 235 notif->channel,
228 notif->band ? "bg" : "a", 236 notif->band ? "bg" : "a",
229 notif->tsf_high, 237 le32_to_cpu(notif->tsf_high),
230 notif->tsf_low, notif->status, notif->beacon_timer); 238 le32_to_cpu(notif->tsf_low),
239 notif->status, notif->beacon_timer);
231} 240}
232 241
233/* Service SCAN_RESULTS_NOTIFICATION (0x83) */ 242/* Service SCAN_RESULTS_NOTIFICATION (0x83) */
@@ -332,19 +341,21 @@ void iwl_setup_rx_scan_handlers(struct iwl_priv *priv)
332EXPORT_SYMBOL(iwl_setup_rx_scan_handlers); 341EXPORT_SYMBOL(iwl_setup_rx_scan_handlers);
333 342
334static inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv, 343static inline u16 iwl_get_active_dwell_time(struct iwl_priv *priv,
335 enum ieee80211_band band) 344 enum ieee80211_band band,
345 u8 n_probes)
336{ 346{
337 if (band == IEEE80211_BAND_5GHZ) 347 if (band == IEEE80211_BAND_5GHZ)
338 return IWL_ACTIVE_DWELL_TIME_52; 348 return IWL_ACTIVE_DWELL_TIME_52 +
349 IWL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1);
339 else 350 else
340 return IWL_ACTIVE_DWELL_TIME_24; 351 return IWL_ACTIVE_DWELL_TIME_24 +
352 IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1);
341} 353}
342 354
343static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv, 355static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
344 enum ieee80211_band band) 356 enum ieee80211_band band)
345{ 357{
346 u16 active = iwl_get_active_dwell_time(priv, band); 358 u16 passive = (band == IEEE80211_BAND_2GHZ) ?
347 u16 passive = (band != IEEE80211_BAND_5GHZ) ?
348 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : 359 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 :
349 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; 360 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52;
350 361
@@ -358,15 +369,12 @@ static u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
358 passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; 369 passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2;
359 } 370 }
360 371
361 if (passive <= active)
362 passive = active + 1;
363
364 return passive; 372 return passive;
365} 373}
366 374
367static int iwl_get_channels_for_scan(struct iwl_priv *priv, 375static int iwl_get_channels_for_scan(struct iwl_priv *priv,
368 enum ieee80211_band band, 376 enum ieee80211_band band,
369 u8 is_active, u8 direct_mask, 377 u8 is_active, u8 n_probes,
370 struct iwl_scan_channel *scan_ch) 378 struct iwl_scan_channel *scan_ch)
371{ 379{
372 const struct ieee80211_channel *channels = NULL; 380 const struct ieee80211_channel *channels = NULL;
@@ -375,6 +383,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
375 u16 passive_dwell = 0; 383 u16 passive_dwell = 0;
376 u16 active_dwell = 0; 384 u16 active_dwell = 0;
377 int added, i; 385 int added, i;
386 u16 channel;
378 387
379 sband = iwl_get_hw_mode(priv, band); 388 sband = iwl_get_hw_mode(priv, band);
380 if (!sband) 389 if (!sband)
@@ -382,31 +391,35 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
382 391
383 channels = sband->channels; 392 channels = sband->channels;
384 393
385 active_dwell = iwl_get_active_dwell_time(priv, band); 394 active_dwell = iwl_get_active_dwell_time(priv, band, n_probes);
386 passive_dwell = iwl_get_passive_dwell_time(priv, band); 395 passive_dwell = iwl_get_passive_dwell_time(priv, band);
387 396
397 if (passive_dwell <= active_dwell)
398 passive_dwell = active_dwell + 1;
399
388 for (i = 0, added = 0; i < sband->n_channels; i++) { 400 for (i = 0, added = 0; i < sband->n_channels; i++) {
389 if (channels[i].flags & IEEE80211_CHAN_DISABLED) 401 if (channels[i].flags & IEEE80211_CHAN_DISABLED)
390 continue; 402 continue;
391 403
392 scan_ch->channel = 404 channel =
393 ieee80211_frequency_to_channel(channels[i].center_freq); 405 ieee80211_frequency_to_channel(channels[i].center_freq);
406 scan_ch->channel = cpu_to_le16(channel);
394 407
395 ch_info = iwl_get_channel_info(priv, band, scan_ch->channel); 408 ch_info = iwl_get_channel_info(priv, band, channel);
396 if (!is_channel_valid(ch_info)) { 409 if (!is_channel_valid(ch_info)) {
397 IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n", 410 IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n",
398 scan_ch->channel); 411 channel);
399 continue; 412 continue;
400 } 413 }
401 414
402 if (!is_active || is_channel_passive(ch_info) || 415 if (!is_active || is_channel_passive(ch_info) ||
403 (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) 416 (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN))
404 scan_ch->type = 0; 417 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
405 else 418 else
406 scan_ch->type = 1; 419 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
407 420
408 if (scan_ch->type & 1) 421 if ((scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) && n_probes)
409 scan_ch->type |= (direct_mask << 1); 422 scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
410 423
411 scan_ch->active_dwell = cpu_to_le16(active_dwell); 424 scan_ch->active_dwell = cpu_to_le16(active_dwell);
412 scan_ch->passive_dwell = cpu_to_le16(passive_dwell); 425 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
@@ -414,20 +427,20 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
414 /* Set txpower levels to defaults */ 427 /* Set txpower levels to defaults */
415 scan_ch->dsp_atten = 110; 428 scan_ch->dsp_atten = 110;
416 429
430 /* NOTE: if we were doing 6Mb OFDM for scans we'd use
431 * power level:
432 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
433 */
417 if (band == IEEE80211_BAND_5GHZ) 434 if (band == IEEE80211_BAND_5GHZ)
418 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; 435 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
419 else { 436 else
420 scan_ch->tx_gain = ((1 << 5) | (5 << 3)); 437 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
421 /* NOTE: if we were doing 6Mb OFDM for scans we'd use
422 * power level:
423 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
424 */
425 }
426 438
427 IWL_DEBUG_SCAN("Scanning %d [%s %d]\n", 439 IWL_DEBUG_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n",
428 scan_ch->channel, 440 channel, le32_to_cpu(scan_ch->type),
429 (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", 441 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
430 (scan_ch->type & 1) ? 442 "ACTIVE" : "PASSIVE",
443 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
431 active_dwell : passive_dwell); 444 active_dwell : passive_dwell);
432 445
433 scan_ch++; 446 scan_ch++;
@@ -673,7 +686,7 @@ static u32 iwl_scan_tx_ant(struct iwl_priv *priv, enum ieee80211_band band)
673 break; 686 break;
674 } 687 }
675 } 688 }
676 689 IWL_DEBUG_SCAN("select TX ANT = %c\n", 'A' + ind);
677 return scan_tx_ant[ind]; 690 return scan_tx_ant[ind];
678} 691}
679 692
@@ -693,7 +706,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
693 u32 tx_ant; 706 u32 tx_ant;
694 u16 cmd_len; 707 u16 cmd_len;
695 enum ieee80211_band band; 708 enum ieee80211_band band;
696 u8 direct_mask; 709 u8 n_probes = 2;
697 u8 rx_chain = 0x7; /* bitmap: ABC chains */ 710 u8 rx_chain = 0x7; /* bitmap: ABC chains */
698 711
699 conf = ieee80211_get_hw_conf(priv->hw); 712 conf = ieee80211_get_hw_conf(priv->hw);
@@ -793,17 +806,16 @@ static void iwl_bg_request_scan(struct work_struct *data)
793 scan->direct_scan[0].len = priv->direct_ssid_len; 806 scan->direct_scan[0].len = priv->direct_ssid_len;
794 memcpy(scan->direct_scan[0].ssid, 807 memcpy(scan->direct_scan[0].ssid,
795 priv->direct_ssid, priv->direct_ssid_len); 808 priv->direct_ssid, priv->direct_ssid_len);
796 direct_mask = 1; 809 n_probes++;
797 } else if (!iwl_is_associated(priv) && priv->essid_len) { 810 } else if (!iwl_is_associated(priv) && priv->essid_len) {
798 IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n", 811 IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n",
799 iwl_escape_essid(priv->essid, priv->essid_len)); 812 iwl_escape_essid(priv->essid, priv->essid_len));
800 scan->direct_scan[0].id = WLAN_EID_SSID; 813 scan->direct_scan[0].id = WLAN_EID_SSID;
801 scan->direct_scan[0].len = priv->essid_len; 814 scan->direct_scan[0].len = priv->essid_len;
802 memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); 815 memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
803 direct_mask = 1; 816 n_probes++;
804 } else { 817 } else {
805 IWL_DEBUG_SCAN("Start indirect scan.\n"); 818 IWL_DEBUG_SCAN("Start indirect scan.\n");
806 direct_mask = 0;
807 } 819 }
808 820
809 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 821 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
@@ -860,16 +872,11 @@ static void iwl_bg_request_scan(struct work_struct *data)
860 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | 872 scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK |
861 RXON_FILTER_BCON_AWARE_MSK); 873 RXON_FILTER_BCON_AWARE_MSK);
862 874
863 if (direct_mask) 875 scan->channel_count =
864 scan->channel_count = 876 iwl_get_channels_for_scan(priv, band, 1, /* active */
865 iwl_get_channels_for_scan(priv, band, 1, /* active */ 877 n_probes,
866 direct_mask, 878 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
867 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 879
868 else
869 scan->channel_count =
870 iwl_get_channels_for_scan(priv, band, 0, /* passive */
871 direct_mask,
872 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
873 if (scan->channel_count == 0) { 880 if (scan->channel_count == 0) {
874 IWL_DEBUG_SCAN("channel count %d\n", scan->channel_count); 881 IWL_DEBUG_SCAN("channel count %d\n", scan->channel_count);
875 goto done; 882 goto done;
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 0be2a71990b0..9b50b1052b09 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -601,13 +601,7 @@ static void iwl_tx_cmd_build_basic(struct iwl_priv *priv,
601 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 601 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
602 } 602 }
603 603
604 if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { 604 priv->cfg->ops->utils->rts_tx_cmd_flag(info, &tx_flags);
605 tx_flags |= TX_CMD_FLG_RTS_MSK;
606 tx_flags &= ~TX_CMD_FLG_CTS_MSK;
607 } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) {
608 tx_flags &= ~TX_CMD_FLG_RTS_MSK;
609 tx_flags |= TX_CMD_FLG_CTS_MSK;
610 }
611 605
612 if ((tx_flags & TX_CMD_FLG_RTS_MSK) || (tx_flags & TX_CMD_FLG_CTS_MSK)) 606 if ((tx_flags & TX_CMD_FLG_RTS_MSK) || (tx_flags & TX_CMD_FLG_CTS_MSK))
613 tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; 607 tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK;
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 1a7d18fea89d..4a22d3fba75b 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -2035,36 +2035,6 @@ static int iwl3945_send_power_mode(struct iwl3945_priv *priv, u32 mode)
2035 return rc; 2035 return rc;
2036} 2036}
2037 2037
2038int iwl3945_is_network_packet(struct iwl3945_priv *priv, struct ieee80211_hdr *header)
2039{
2040 /* Filter incoming packets to determine if they are targeted toward
2041 * this network, discarding packets coming from ourselves */
2042 switch (priv->iw_mode) {
2043 case IEEE80211_IF_TYPE_IBSS: /* Header: Dest. | Source | BSSID */
2044 /* packets from our adapter are dropped (echo) */
2045 if (!compare_ether_addr(header->addr2, priv->mac_addr))
2046 return 0;
2047 /* {broad,multi}cast packets to our IBSS go through */
2048 if (is_multicast_ether_addr(header->addr1))
2049 return !compare_ether_addr(header->addr3, priv->bssid);
2050 /* packets to our adapter go through */
2051 return !compare_ether_addr(header->addr1, priv->mac_addr);
2052 case IEEE80211_IF_TYPE_STA: /* Header: Dest. | AP{BSSID} | Source */
2053 /* packets from our adapter are dropped (echo) */
2054 if (!compare_ether_addr(header->addr3, priv->mac_addr))
2055 return 0;
2056 /* {broad,multi}cast packets to our BSS go through */
2057 if (is_multicast_ether_addr(header->addr1))
2058 return !compare_ether_addr(header->addr2, priv->bssid);
2059 /* packets to our adapter go through */
2060 return !compare_ether_addr(header->addr1, priv->mac_addr);
2061 default:
2062 return 1;
2063 }
2064
2065 return 1;
2066}
2067
2068/** 2038/**
2069 * iwl3945_scan_cancel - Cancel any currently executing HW scan 2039 * iwl3945_scan_cancel - Cancel any currently executing HW scan
2070 * 2040 *
@@ -2117,20 +2087,6 @@ static int iwl3945_scan_cancel_timeout(struct iwl3945_priv *priv, unsigned long
2117 return ret; 2087 return ret;
2118} 2088}
2119 2089
2120static void iwl3945_sequence_reset(struct iwl3945_priv *priv)
2121{
2122 /* Reset ieee stats */
2123
2124 /* We don't reset the net_device_stats (ieee->stats) on
2125 * re-association */
2126
2127 priv->last_seq_num = -1;
2128 priv->last_frag_num = -1;
2129 priv->last_packet_time = 0;
2130
2131 iwl3945_scan_cancel(priv);
2132}
2133
2134#define MAX_UCODE_BEACON_INTERVAL 1024 2090#define MAX_UCODE_BEACON_INTERVAL 1024
2135#define INTEL_CONN_LISTEN_INTERVAL __constant_cpu_to_le16(0xA) 2091#define INTEL_CONN_LISTEN_INTERVAL __constant_cpu_to_le16(0xA)
2136 2092
@@ -2925,72 +2881,6 @@ void iwl3945_set_decrypted_flag(struct iwl3945_priv *priv, struct sk_buff *skb,
2925 } 2881 }
2926} 2882}
2927 2883
2928#define IWL_PACKET_RETRY_TIME HZ
2929
2930int iwl3945_is_duplicate_packet(struct iwl3945_priv *priv, struct ieee80211_hdr *header)
2931{
2932 u16 sc = le16_to_cpu(header->seq_ctrl);
2933 u16 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
2934 u16 frag = sc & IEEE80211_SCTL_FRAG;
2935 u16 *last_seq, *last_frag;
2936 unsigned long *last_time;
2937
2938 switch (priv->iw_mode) {
2939 case IEEE80211_IF_TYPE_IBSS:{
2940 struct list_head *p;
2941 struct iwl3945_ibss_seq *entry = NULL;
2942 u8 *mac = header->addr2;
2943 int index = mac[5] & (IWL_IBSS_MAC_HASH_SIZE - 1);
2944
2945 __list_for_each(p, &priv->ibss_mac_hash[index]) {
2946 entry = list_entry(p, struct iwl3945_ibss_seq, list);
2947 if (!compare_ether_addr(entry->mac, mac))
2948 break;
2949 }
2950 if (p == &priv->ibss_mac_hash[index]) {
2951 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
2952 if (!entry) {
2953 IWL_ERROR("Cannot malloc new mac entry\n");
2954 return 0;
2955 }
2956 memcpy(entry->mac, mac, ETH_ALEN);
2957 entry->seq_num = seq;
2958 entry->frag_num = frag;
2959 entry->packet_time = jiffies;
2960 list_add(&entry->list, &priv->ibss_mac_hash[index]);
2961 return 0;
2962 }
2963 last_seq = &entry->seq_num;
2964 last_frag = &entry->frag_num;
2965 last_time = &entry->packet_time;
2966 break;
2967 }
2968 case IEEE80211_IF_TYPE_STA:
2969 last_seq = &priv->last_seq_num;
2970 last_frag = &priv->last_frag_num;
2971 last_time = &priv->last_packet_time;
2972 break;
2973 default:
2974 return 0;
2975 }
2976 if ((*last_seq == seq) &&
2977 time_after(*last_time + IWL_PACKET_RETRY_TIME, jiffies)) {
2978 if (*last_frag == frag)
2979 goto drop;
2980 if (*last_frag + 1 != frag)
2981 /* out-of-order fragment */
2982 goto drop;
2983 } else
2984 *last_seq = seq;
2985
2986 *last_frag = frag;
2987 *last_time = jiffies;
2988 return 0;
2989
2990 drop:
2991 return 1;
2992}
2993
2994#ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT 2884#ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT
2995 2885
2996#include "iwl-spectrum.h" 2886#include "iwl-spectrum.h"
@@ -6531,8 +6421,6 @@ static void iwl3945_bg_post_associate(struct work_struct *data)
6531 break; 6421 break;
6532 } 6422 }
6533 6423
6534 iwl3945_sequence_reset(priv);
6535
6536 iwl3945_activate_qos(priv, 0); 6424 iwl3945_activate_qos(priv, 0);
6537 6425
6538 /* we have just associated, don't start scan too early */ 6426 /* we have just associated, don't start scan too early */
@@ -6907,6 +6795,9 @@ static void iwl3945_config_ap(struct iwl3945_priv *priv)
6907 * clear sta table, add BCAST sta... */ 6795 * clear sta table, add BCAST sta... */
6908} 6796}
6909 6797
6798/* temporary */
6799static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb);
6800
6910static int iwl3945_mac_config_interface(struct ieee80211_hw *hw, 6801static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6911 struct ieee80211_vif *vif, 6802 struct ieee80211_vif *vif,
6912 struct ieee80211_if_conf *conf) 6803 struct ieee80211_if_conf *conf)
@@ -6924,10 +6815,21 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6924 return 0; 6815 return 0;
6925 } 6816 }
6926 6817
6818 /* handle this temporarily here */
6819 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS &&
6820 conf->changed & IEEE80211_IFCC_BEACON) {
6821 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
6822 if (!beacon)
6823 return -ENOMEM;
6824 rc = iwl3945_mac_beacon_update(hw, beacon);
6825 if (rc)
6826 return rc;
6827 }
6828
6927 /* XXX: this MUST use conf->mac_addr */ 6829 /* XXX: this MUST use conf->mac_addr */
6928 6830
6929 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) && 6831 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) &&
6930 (!conf->beacon || !conf->ssid_len)) { 6832 (!conf->ssid_len)) {
6931 IWL_DEBUG_MAC80211 6833 IWL_DEBUG_MAC80211
6932 ("Leaving in AP mode because HostAPD is not ready.\n"); 6834 ("Leaving in AP mode because HostAPD is not ready.\n");
6933 return 0; 6835 return 0;
@@ -6959,7 +6861,7 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
6959 if (priv->ibss_beacon) 6861 if (priv->ibss_beacon)
6960 dev_kfree_skb(priv->ibss_beacon); 6862 dev_kfree_skb(priv->ibss_beacon);
6961 6863
6962 priv->ibss_beacon = conf->beacon; 6864 priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
6963 } 6865 }
6964 6866
6965 if (iwl3945_is_rfkill(priv)) 6867 if (iwl3945_is_rfkill(priv))
@@ -7940,7 +7842,6 @@ static struct ieee80211_ops iwl3945_hw_ops = {
7940 .conf_tx = iwl3945_mac_conf_tx, 7842 .conf_tx = iwl3945_mac_conf_tx,
7941 .get_tsf = iwl3945_mac_get_tsf, 7843 .get_tsf = iwl3945_mac_get_tsf,
7942 .reset_tsf = iwl3945_mac_reset_tsf, 7844 .reset_tsf = iwl3945_mac_reset_tsf,
7943 .beacon_update = iwl3945_mac_beacon_update,
7944 .hw_scan = iwl3945_mac_hw_scan 7845 .hw_scan = iwl3945_mac_hw_scan
7945}; 7846};
7946 7847
@@ -7950,7 +7851,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7950 struct iwl3945_priv *priv; 7851 struct iwl3945_priv *priv;
7951 struct ieee80211_hw *hw; 7852 struct ieee80211_hw *hw;
7952 struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data); 7853 struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data);
7953 int i;
7954 unsigned long flags; 7854 unsigned long flags;
7955 DECLARE_MAC_BUF(mac); 7855 DECLARE_MAC_BUF(mac);
7956 7856
@@ -8011,9 +7911,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8011 spin_lock_init(&priv->sta_lock); 7911 spin_lock_init(&priv->sta_lock);
8012 spin_lock_init(&priv->hcmd_lock); 7912 spin_lock_init(&priv->hcmd_lock);
8013 7913
8014 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
8015 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
8016
8017 INIT_LIST_HEAD(&priv->free_frames); 7914 INIT_LIST_HEAD(&priv->free_frames);
8018 7915
8019 mutex_init(&priv->mutex); 7916 mutex_init(&priv->mutex);
@@ -8186,8 +8083,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8186static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) 8083static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
8187{ 8084{
8188 struct iwl3945_priv *priv = pci_get_drvdata(pdev); 8085 struct iwl3945_priv *priv = pci_get_drvdata(pdev);
8189 struct list_head *p, *q;
8190 int i;
8191 unsigned long flags; 8086 unsigned long flags;
8192 8087
8193 if (!priv) 8088 if (!priv)
@@ -8208,14 +8103,6 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
8208 8103
8209 iwl_synchronize_irq(priv); 8104 iwl_synchronize_irq(priv);
8210 8105
8211 /* Free MAC hash list for ADHOC */
8212 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++) {
8213 list_for_each_safe(p, q, &priv->ibss_mac_hash[i]) {
8214 list_del(p);
8215 kfree(list_entry(p, struct iwl3945_ibss_seq, list));
8216 }
8217 }
8218
8219 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); 8106 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
8220 8107
8221 iwl3945_rfkill_unregister(priv); 8108 iwl3945_rfkill_unregister(priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 7f65d9123b2a..71f5da3fe5c4 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -250,6 +250,9 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
250 250
251 /* always get timestamp with Rx frame */ 251 /* always get timestamp with Rx frame */
252 priv->staging_rxon.flags |= RXON_FLG_TSF2HOST_MSK; 252 priv->staging_rxon.flags |= RXON_FLG_TSF2HOST_MSK;
253 /* allow CTS-to-self if possible. this is relevant only for
254 * 5000, but will not damage 4965 */
255 priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN;
253 256
254 ret = iwl4965_check_rxon_cmd(&priv->staging_rxon); 257 ret = iwl4965_check_rxon_cmd(&priv->staging_rxon);
255 if (ret) { 258 if (ret) {
@@ -325,16 +328,6 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
325 if (!priv->error_recovering) 328 if (!priv->error_recovering)
326 priv->start_calib = 0; 329 priv->start_calib = 0;
327 330
328 iwl_init_sensitivity(priv);
329
330 /* If we issue a new RXON command which required a tune then we must
331 * send a new TXPOWER command or we won't be able to Tx any frames */
332 ret = iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
333 if (ret) {
334 IWL_ERROR("Error sending TX power (%d)\n", ret);
335 return ret;
336 }
337
338 /* Add the broadcast address so we can send broadcast frames */ 331 /* Add the broadcast address so we can send broadcast frames */
339 if (iwl_rxon_add_station(priv, iwl_bcast_addr, 0) == 332 if (iwl_rxon_add_station(priv, iwl_bcast_addr, 0) ==
340 IWL_INVALID_STATION) { 333 IWL_INVALID_STATION) {
@@ -370,6 +363,16 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
370 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon)); 363 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
371 } 364 }
372 365
366 iwl_init_sensitivity(priv);
367
368 /* If we issue a new RXON command which required a tune then we must
369 * send a new TXPOWER command or we won't be able to Tx any frames */
370 ret = iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
371 if (ret) {
372 IWL_ERROR("Error sending TX power (%d)\n", ret);
373 return ret;
374 }
375
373 return 0; 376 return 0;
374} 377}
375 378
@@ -572,25 +575,14 @@ static void iwl4965_ht_conf(struct iwl_priv *priv,
572/* 575/*
573 * QoS support 576 * QoS support
574*/ 577*/
575static int iwl4965_send_qos_params_command(struct iwl_priv *priv, 578static void iwl_activate_qos(struct iwl_priv *priv, u8 force)
576 struct iwl4965_qosparam_cmd *qos)
577{
578
579 return iwl_send_cmd_pdu(priv, REPLY_QOS_PARAM,
580 sizeof(struct iwl4965_qosparam_cmd), qos);
581}
582
583static void iwl4965_activate_qos(struct iwl_priv *priv, u8 force)
584{ 579{
585 unsigned long flags;
586
587 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 580 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
588 return; 581 return;
589 582
590 if (!priv->qos_data.qos_enable) 583 if (!priv->qos_data.qos_enable)
591 return; 584 return;
592 585
593 spin_lock_irqsave(&priv->lock, flags);
594 priv->qos_data.def_qos_parm.qos_flags = 0; 586 priv->qos_data.def_qos_parm.qos_flags = 0;
595 587
596 if (priv->qos_data.qos_cap.q_AP.queue_request && 588 if (priv->qos_data.qos_cap.q_AP.queue_request &&
@@ -604,15 +596,14 @@ static void iwl4965_activate_qos(struct iwl_priv *priv, u8 force)
604 if (priv->current_ht_config.is_ht) 596 if (priv->current_ht_config.is_ht)
605 priv->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; 597 priv->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
606 598
607 spin_unlock_irqrestore(&priv->lock, flags);
608
609 if (force || iwl_is_associated(priv)) { 599 if (force || iwl_is_associated(priv)) {
610 IWL_DEBUG_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", 600 IWL_DEBUG_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n",
611 priv->qos_data.qos_active, 601 priv->qos_data.qos_active,
612 priv->qos_data.def_qos_parm.qos_flags); 602 priv->qos_data.def_qos_parm.qos_flags);
613 603
614 iwl4965_send_qos_params_command(priv, 604 iwl_send_cmd_pdu_async(priv, REPLY_QOS_PARAM,
615 &(priv->qos_data.def_qos_parm)); 605 sizeof(struct iwl_qosparam_cmd),
606 &priv->qos_data.def_qos_parm, NULL);
616 } 607 }
617} 608}
618 609
@@ -2421,6 +2412,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2421 struct ieee80211_conf *conf = NULL; 2412 struct ieee80211_conf *conf = NULL;
2422 int ret = 0; 2413 int ret = 0;
2423 DECLARE_MAC_BUF(mac); 2414 DECLARE_MAC_BUF(mac);
2415 unsigned long flags;
2424 2416
2425 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 2417 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
2426 IWL_ERROR("%s Should not be called in AP mode\n", __FUNCTION__); 2418 IWL_ERROR("%s Should not be called in AP mode\n", __FUNCTION__);
@@ -2510,25 +2502,15 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2510 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 2502 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)
2511 priv->assoc_station_added = 1; 2503 priv->assoc_station_added = 1;
2512 2504
2513 iwl4965_activate_qos(priv, 0); 2505 spin_lock_irqsave(&priv->lock, flags);
2506 iwl_activate_qos(priv, 0);
2507 spin_unlock_irqrestore(&priv->lock, flags);
2514 2508
2515 iwl_power_update_mode(priv, 0); 2509 iwl_power_update_mode(priv, 0);
2516 /* we have just associated, don't start scan too early */ 2510 /* we have just associated, don't start scan too early */
2517 priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN; 2511 priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN;
2518} 2512}
2519 2513
2520
2521static void iwl4965_bg_post_associate(struct work_struct *data)
2522{
2523 struct iwl_priv *priv = container_of(data, struct iwl_priv,
2524 post_associate.work);
2525
2526 mutex_lock(&priv->mutex);
2527 iwl4965_post_associate(priv);
2528 mutex_unlock(&priv->mutex);
2529
2530}
2531
2532static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 2514static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
2533 2515
2534static void iwl_bg_scan_completed(struct work_struct *work) 2516static void iwl_bg_scan_completed(struct work_struct *work)
@@ -2659,7 +2641,6 @@ static void iwl4965_mac_stop(struct ieee80211_hw *hw)
2659 */ 2641 */
2660 mutex_lock(&priv->mutex); 2642 mutex_lock(&priv->mutex);
2661 iwl_scan_cancel_timeout(priv, 100); 2643 iwl_scan_cancel_timeout(priv, 100);
2662 cancel_delayed_work(&priv->post_associate);
2663 mutex_unlock(&priv->mutex); 2644 mutex_unlock(&priv->mutex);
2664 } 2645 }
2665 2646
@@ -2855,6 +2836,7 @@ out:
2855static void iwl4965_config_ap(struct iwl_priv *priv) 2836static void iwl4965_config_ap(struct iwl_priv *priv)
2856{ 2837{
2857 int ret = 0; 2838 int ret = 0;
2839 unsigned long flags;
2858 2840
2859 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2841 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2860 return; 2842 return;
@@ -2902,7 +2884,9 @@ static void iwl4965_config_ap(struct iwl_priv *priv)
2902 /* restore RXON assoc */ 2884 /* restore RXON assoc */
2903 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 2885 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
2904 iwl4965_commit_rxon(priv); 2886 iwl4965_commit_rxon(priv);
2905 iwl4965_activate_qos(priv, 1); 2887 spin_lock_irqsave(&priv->lock, flags);
2888 iwl_activate_qos(priv, 1);
2889 spin_unlock_irqrestore(&priv->lock, flags);
2906 iwl_rxon_add_station(priv, iwl_bcast_addr, 0); 2890 iwl_rxon_add_station(priv, iwl_bcast_addr, 0);
2907 } 2891 }
2908 iwl4965_send_beacon_cmd(priv); 2892 iwl4965_send_beacon_cmd(priv);
@@ -2912,6 +2896,9 @@ static void iwl4965_config_ap(struct iwl_priv *priv)
2912 * clear sta table, add BCAST sta... */ 2896 * clear sta table, add BCAST sta... */
2913} 2897}
2914 2898
2899/* temporary */
2900static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb);
2901
2915static int iwl4965_mac_config_interface(struct ieee80211_hw *hw, 2902static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
2916 struct ieee80211_vif *vif, 2903 struct ieee80211_vif *vif,
2917 struct ieee80211_if_conf *conf) 2904 struct ieee80211_if_conf *conf)
@@ -2929,8 +2916,18 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
2929 return 0; 2916 return 0;
2930 } 2917 }
2931 2918
2919 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS &&
2920 conf->changed & IEEE80211_IFCC_BEACON) {
2921 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
2922 if (!beacon)
2923 return -ENOMEM;
2924 rc = iwl4965_mac_beacon_update(hw, beacon);
2925 if (rc)
2926 return rc;
2927 }
2928
2932 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) && 2929 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) &&
2933 (!conf->beacon || !conf->ssid_len)) { 2930 (!conf->ssid_len)) {
2934 IWL_DEBUG_MAC80211 2931 IWL_DEBUG_MAC80211
2935 ("Leaving in AP mode because HostAPD is not ready.\n"); 2932 ("Leaving in AP mode because HostAPD is not ready.\n");
2936 return 0; 2933 return 0;
@@ -2962,7 +2959,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
2962 if (priv->ibss_beacon) 2959 if (priv->ibss_beacon)
2963 dev_kfree_skb(priv->ibss_beacon); 2960 dev_kfree_skb(priv->ibss_beacon);
2964 2961
2965 priv->ibss_beacon = conf->beacon; 2962 priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
2966 } 2963 }
2967 2964
2968 if (iwl_is_rfkill(priv)) 2965 if (iwl_is_rfkill(priv))
@@ -3048,7 +3045,6 @@ static void iwl4965_mac_remove_interface(struct ieee80211_hw *hw,
3048 3045
3049 if (iwl_is_ready_rf(priv)) { 3046 if (iwl_is_ready_rf(priv)) {
3050 iwl_scan_cancel_timeout(priv, 100); 3047 iwl_scan_cancel_timeout(priv, 100);
3051 cancel_delayed_work(&priv->post_associate);
3052 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3048 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3053 iwl4965_commit_rxon(priv); 3049 iwl4965_commit_rxon(priv);
3054 } 3050 }
@@ -3338,15 +3334,12 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
3338 priv->qos_data.def_qos_parm.ac[q].reserved1 = 0; 3334 priv->qos_data.def_qos_parm.ac[q].reserved1 = 0;
3339 priv->qos_data.qos_active = 1; 3335 priv->qos_data.qos_active = 1;
3340 3336
3341 spin_unlock_irqrestore(&priv->lock, flags);
3342
3343 mutex_lock(&priv->mutex);
3344 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) 3337 if (priv->iw_mode == IEEE80211_IF_TYPE_AP)
3345 iwl4965_activate_qos(priv, 1); 3338 iwl_activate_qos(priv, 1);
3346 else if (priv->assoc_id && iwl_is_associated(priv)) 3339 else if (priv->assoc_id && iwl_is_associated(priv))
3347 iwl4965_activate_qos(priv, 0); 3340 iwl_activate_qos(priv, 0);
3348 3341
3349 mutex_unlock(&priv->mutex); 3342 spin_unlock_irqrestore(&priv->lock, flags);
3350 3343
3351 IWL_DEBUG_MAC80211("leave\n"); 3344 IWL_DEBUG_MAC80211("leave\n");
3352 return 0; 3345 return 0;
@@ -3413,8 +3406,6 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
3413 3406
3414 iwl_reset_qos(priv); 3407 iwl_reset_qos(priv);
3415 3408
3416 cancel_delayed_work(&priv->post_associate);
3417
3418 spin_lock_irqsave(&priv->lock, flags); 3409 spin_lock_irqsave(&priv->lock, flags);
3419 priv->assoc_id = 0; 3410 priv->assoc_id = 0;
3420 priv->assoc_capability = 0; 3411 priv->assoc_capability = 0;
@@ -4016,7 +4007,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
4016 INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); 4007 INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update);
4017 INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); 4008 INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor);
4018 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); 4009 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work);
4019 INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate);
4020 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); 4010 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start);
4021 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); 4011 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start);
4022 4012
@@ -4043,7 +4033,6 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
4043 cancel_delayed_work_sync(&priv->init_alive_start); 4033 cancel_delayed_work_sync(&priv->init_alive_start);
4044 cancel_delayed_work(&priv->scan_check); 4034 cancel_delayed_work(&priv->scan_check);
4045 cancel_delayed_work(&priv->alive_start); 4035 cancel_delayed_work(&priv->alive_start);
4046 cancel_delayed_work(&priv->post_associate);
4047 cancel_work_sync(&priv->beacon_update); 4036 cancel_work_sync(&priv->beacon_update);
4048 del_timer_sync(&priv->statistics_periodic); 4037 del_timer_sync(&priv->statistics_periodic);
4049} 4038}
@@ -4090,7 +4079,6 @@ static struct ieee80211_ops iwl4965_hw_ops = {
4090 .get_tx_stats = iwl4965_mac_get_tx_stats, 4079 .get_tx_stats = iwl4965_mac_get_tx_stats,
4091 .conf_tx = iwl4965_mac_conf_tx, 4080 .conf_tx = iwl4965_mac_conf_tx,
4092 .reset_tsf = iwl4965_mac_reset_tsf, 4081 .reset_tsf = iwl4965_mac_reset_tsf,
4093 .beacon_update = iwl4965_mac_beacon_update,
4094 .bss_info_changed = iwl4965_bss_info_changed, 4082 .bss_info_changed = iwl4965_bss_info_changed,
4095 .ampdu_action = iwl4965_mac_ampdu_action, 4083 .ampdu_action = iwl4965_mac_ampdu_action,
4096 .hw_scan = iwl4965_mac_hw_scan 4084 .hw_scan = iwl4965_mac_hw_scan
@@ -4409,8 +4397,16 @@ static struct pci_device_id iwl_hw_card_ids[] = {
4409 {IWL_PCI_DEVICE(0x4229, PCI_ANY_ID, iwl4965_agn_cfg)}, 4397 {IWL_PCI_DEVICE(0x4229, PCI_ANY_ID, iwl4965_agn_cfg)},
4410 {IWL_PCI_DEVICE(0x4230, PCI_ANY_ID, iwl4965_agn_cfg)}, 4398 {IWL_PCI_DEVICE(0x4230, PCI_ANY_ID, iwl4965_agn_cfg)},
4411#ifdef CONFIG_IWL5000 4399#ifdef CONFIG_IWL5000
4412 {IWL_PCI_DEVICE(0x4235, PCI_ANY_ID, iwl5300_agn_cfg)}, 4400 {IWL_PCI_DEVICE(0x4232, 0x1205, iwl5100_bg_cfg)},
4401 {IWL_PCI_DEVICE(0x4232, 0x1305, iwl5100_bg_cfg)},
4402 {IWL_PCI_DEVICE(0x4232, 0x1206, iwl5100_abg_cfg)},
4403 {IWL_PCI_DEVICE(0x4232, 0x1306, iwl5100_abg_cfg)},
4404 {IWL_PCI_DEVICE(0x4232, 0x1326, iwl5100_abg_cfg)},
4405 {IWL_PCI_DEVICE(0x4237, 0x1216, iwl5100_abg_cfg)},
4413 {IWL_PCI_DEVICE(0x4232, PCI_ANY_ID, iwl5100_agn_cfg)}, 4406 {IWL_PCI_DEVICE(0x4232, PCI_ANY_ID, iwl5100_agn_cfg)},
4407 {IWL_PCI_DEVICE(0x4235, PCI_ANY_ID, iwl5300_agn_cfg)},
4408 {IWL_PCI_DEVICE(0x4236, PCI_ANY_ID, iwl5300_agn_cfg)},
4409 {IWL_PCI_DEVICE(0x4237, PCI_ANY_ID, iwl5100_agn_cfg)},
4414 {IWL_PCI_DEVICE(0x423A, PCI_ANY_ID, iwl5350_agn_cfg)}, 4410 {IWL_PCI_DEVICE(0x423A, PCI_ANY_ID, iwl5350_agn_cfg)},
4415#endif /* CONFIG_IWL5000 */ 4411#endif /* CONFIG_IWL5000 */
4416 {0} 4412 {0}
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 343ed38f772d..4b274562f965 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -567,11 +567,11 @@ static int lbs_process_bss(struct bss_descriptor *bss,
567 pos += 8; 567 pos += 8;
568 568
569 /* beacon interval is 2 bytes long */ 569 /* beacon interval is 2 bytes long */
570 bss->beaconperiod = le16_to_cpup((void *) pos); 570 bss->beaconperiod = get_unaligned_le16(pos);
571 pos += 2; 571 pos += 2;
572 572
573 /* capability information is 2 bytes long */ 573 /* capability information is 2 bytes long */
574 bss->capability = le16_to_cpup((void *) pos); 574 bss->capability = get_unaligned_le16(pos);
575 lbs_deb_scan("process_bss: capabilities 0x%04x\n", bss->capability); 575 lbs_deb_scan("process_bss: capabilities 0x%04x\n", bss->capability);
576 pos += 2; 576 pos += 2;
577 577
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 5d30c57e3969..913dc9fe08f9 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -126,7 +126,7 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
126 (1 << IEEE80211_RADIOTAP_CHANNEL)); 126 (1 << IEEE80211_RADIOTAP_CHANNEL));
127 hdr->rt_flags = 0; 127 hdr->rt_flags = 0;
128 hdr->rt_rate = txrate->bitrate / 5; 128 hdr->rt_rate = txrate->bitrate / 5;
129 hdr->rt_channel = data->channel->center_freq; 129 hdr->rt_channel = cpu_to_le16(data->channel->center_freq);
130 flags = IEEE80211_CHAN_2GHZ; 130 flags = IEEE80211_CHAN_2GHZ;
131 if (txrate->flags & IEEE80211_RATE_ERP_G) 131 if (txrate->flags & IEEE80211_RATE_ERP_G)
132 flags |= IEEE80211_CHAN_OFDM; 132 flags |= IEEE80211_CHAN_OFDM;
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index ee953ca0c6a3..4c0538d6099b 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -733,6 +733,17 @@ static int rt2400pci_init_registers(struct rt2x00_dev *rt2x00dev)
733 (rt2x00dev->rx->data_size / 128)); 733 (rt2x00dev->rx->data_size / 128));
734 rt2x00pci_register_write(rt2x00dev, CSR9, reg); 734 rt2x00pci_register_write(rt2x00dev, CSR9, reg);
735 735
736 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
737 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
738 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
739 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
740 rt2x00_set_field32(&reg, CSR14_TCFP, 0);
741 rt2x00_set_field32(&reg, CSR14_TATIMW, 0);
742 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
743 rt2x00_set_field32(&reg, CSR14_CFP_COUNT_PRELOAD, 0);
744 rt2x00_set_field32(&reg, CSR14_TBCM_PRELOAD, 0);
745 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
746
736 rt2x00pci_register_write(rt2x00dev, CNT3, 0x3f080000); 747 rt2x00pci_register_write(rt2x00dev, CNT3, 0x3f080000);
737 748
738 rt2x00pci_register_read(rt2x00dev, ARCSR0, &reg); 749 rt2x00pci_register_read(rt2x00dev, ARCSR0, &reg);
@@ -1058,6 +1069,40 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1058/* 1069/*
1059 * TX data initialization 1070 * TX data initialization
1060 */ 1071 */
1072static void rt2400pci_write_beacon(struct queue_entry *entry)
1073{
1074 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1075 struct queue_entry_priv_pci *entry_priv = entry->priv_data;
1076 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1077 u32 word;
1078 u32 reg;
1079
1080 /*
1081 * Disable beaconing while we are reloading the beacon data,
1082 * otherwise we might be sending out invalid data.
1083 */
1084 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
1085 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
1086 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
1087 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
1088 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1089
1090 /*
1091 * Replace rt2x00lib allocated descriptor with the
1092 * pointer to the _real_ hardware descriptor.
1093 * After that, map the beacon to DMA and update the
1094 * descriptor.
1095 */
1096 memcpy(entry_priv->desc, skbdesc->desc, skbdesc->desc_len);
1097 skbdesc->desc = entry_priv->desc;
1098
1099 rt2x00queue_map_txskb(rt2x00dev, entry->skb);
1100
1101 rt2x00_desc_read(entry_priv->desc, 1, &word);
1102 rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
1103 rt2x00_desc_write(entry_priv->desc, 1, word);
1104}
1105
1061static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev, 1106static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1062 const enum data_queue_qid queue) 1107 const enum data_queue_qid queue)
1063{ 1108{
@@ -1504,59 +1549,6 @@ static u64 rt2400pci_get_tsf(struct ieee80211_hw *hw)
1504 return tsf; 1549 return tsf;
1505} 1550}
1506 1551
1507static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
1508{
1509 struct rt2x00_dev *rt2x00dev = hw->priv;
1510 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1511 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
1512 struct queue_entry_priv_pci *entry_priv;
1513 struct skb_frame_desc *skbdesc;
1514 struct txentry_desc txdesc;
1515 u32 reg;
1516
1517 if (unlikely(!intf->beacon))
1518 return -ENOBUFS;
1519 entry_priv = intf->beacon->priv_data;
1520
1521 /*
1522 * Copy all TX descriptor information into txdesc,
1523 * after that we are free to use the skb->cb array
1524 * for our information.
1525 */
1526 intf->beacon->skb = skb;
1527 rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
1528
1529 /*
1530 * Fill in skb descriptor
1531 */
1532 skbdesc = get_skb_frame_desc(skb);
1533 memset(skbdesc, 0, sizeof(*skbdesc));
1534 skbdesc->desc = entry_priv->desc;
1535 skbdesc->desc_len = intf->beacon->queue->desc_size;
1536 skbdesc->entry = intf->beacon;
1537
1538 /*
1539 * Disable beaconing while we are reloading the beacon data,
1540 * otherwise we might be sending out invalid data.
1541 */
1542 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
1543 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
1544 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
1545 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
1546 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1547
1548 /*
1549 * Enable beacon generation.
1550 * Write entire beacon with descriptor to register,
1551 * and kick the beacon generator.
1552 */
1553 rt2x00queue_map_txskb(rt2x00dev, intf->beacon->skb);
1554 rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc);
1555 rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON);
1556
1557 return 0;
1558}
1559
1560static int rt2400pci_tx_last_beacon(struct ieee80211_hw *hw) 1552static int rt2400pci_tx_last_beacon(struct ieee80211_hw *hw)
1561{ 1553{
1562 struct rt2x00_dev *rt2x00dev = hw->priv; 1554 struct rt2x00_dev *rt2x00dev = hw->priv;
@@ -1581,7 +1573,6 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
1581 .conf_tx = rt2400pci_conf_tx, 1573 .conf_tx = rt2400pci_conf_tx,
1582 .get_tx_stats = rt2x00mac_get_tx_stats, 1574 .get_tx_stats = rt2x00mac_get_tx_stats,
1583 .get_tsf = rt2400pci_get_tsf, 1575 .get_tsf = rt2400pci_get_tsf,
1584 .beacon_update = rt2400pci_beacon_update,
1585 .tx_last_beacon = rt2400pci_tx_last_beacon, 1576 .tx_last_beacon = rt2400pci_tx_last_beacon,
1586}; 1577};
1587 1578
@@ -1599,6 +1590,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1599 .link_tuner = rt2400pci_link_tuner, 1590 .link_tuner = rt2400pci_link_tuner,
1600 .write_tx_desc = rt2400pci_write_tx_desc, 1591 .write_tx_desc = rt2400pci_write_tx_desc,
1601 .write_tx_data = rt2x00pci_write_tx_data, 1592 .write_tx_data = rt2x00pci_write_tx_data,
1593 .write_beacon = rt2400pci_write_beacon,
1602 .kick_tx_queue = rt2400pci_kick_tx_queue, 1594 .kick_tx_queue = rt2400pci_kick_tx_queue,
1603 .fill_rxdone = rt2400pci_fill_rxdone, 1595 .fill_rxdone = rt2400pci_fill_rxdone,
1604 .config_filter = rt2400pci_config_filter, 1596 .config_filter = rt2400pci_config_filter,
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 0423c251c78e..aa6dfb811c71 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -831,6 +831,17 @@ static int rt2500pci_init_registers(struct rt2x00_dev *rt2x00dev)
831 rt2x00_set_field32(&reg, CSR11_CW_SELECT, 0); 831 rt2x00_set_field32(&reg, CSR11_CW_SELECT, 0);
832 rt2x00pci_register_write(rt2x00dev, CSR11, reg); 832 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
833 833
834 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
835 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
836 rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
837 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
838 rt2x00_set_field32(&reg, CSR14_TCFP, 0);
839 rt2x00_set_field32(&reg, CSR14_TATIMW, 0);
840 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
841 rt2x00_set_field32(&reg, CSR14_CFP_COUNT_PRELOAD, 0);
842 rt2x00_set_field32(&reg, CSR14_TBCM_PRELOAD, 0);
843 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
844
834 rt2x00pci_register_write(rt2x00dev, CNT3, 0); 845 rt2x00pci_register_write(rt2x00dev, CNT3, 0);
835 846
836 rt2x00pci_register_read(rt2x00dev, TXCSR8, &reg); 847 rt2x00pci_register_read(rt2x00dev, TXCSR8, &reg);
@@ -1216,6 +1227,40 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1216/* 1227/*
1217 * TX data initialization 1228 * TX data initialization
1218 */ 1229 */
1230static void rt2500pci_write_beacon(struct queue_entry *entry)
1231{
1232 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1233 struct queue_entry_priv_pci *entry_priv = entry->priv_data;
1234 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1235 u32 word;
1236 u32 reg;
1237
1238 /*
1239 * Disable beaconing while we are reloading the beacon data,
1240 * otherwise we might be sending out invalid data.
1241 */
1242 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
1243 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
1244 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
1245 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
1246 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1247
1248 /*
1249 * Replace rt2x00lib allocated descriptor with the
1250 * pointer to the _real_ hardware descriptor.
1251 * After that, map the beacon to DMA and update the
1252 * descriptor.
1253 */
1254 memcpy(entry_priv->desc, skbdesc->desc, skbdesc->desc_len);
1255 skbdesc->desc = entry_priv->desc;
1256
1257 rt2x00queue_map_txskb(rt2x00dev, entry->skb);
1258
1259 rt2x00_desc_read(entry_priv->desc, 1, &word);
1260 rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, skbdesc->skb_dma);
1261 rt2x00_desc_write(entry_priv->desc, 1, word);
1262}
1263
1219static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev, 1264static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1220 const enum data_queue_qid queue) 1265 const enum data_queue_qid queue)
1221{ 1266{
@@ -1797,60 +1842,6 @@ static u64 rt2500pci_get_tsf(struct ieee80211_hw *hw)
1797 return tsf; 1842 return tsf;
1798} 1843}
1799 1844
1800static int rt2500pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
1801{
1802 struct rt2x00_dev *rt2x00dev = hw->priv;
1803 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1804 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
1805 struct queue_entry_priv_pci *entry_priv;
1806 struct skb_frame_desc *skbdesc;
1807 struct txentry_desc txdesc;
1808 u32 reg;
1809
1810 if (unlikely(!intf->beacon))
1811 return -ENOBUFS;
1812
1813 entry_priv = intf->beacon->priv_data;
1814
1815 /*
1816 * Copy all TX descriptor information into txdesc,
1817 * after that we are free to use the skb->cb array
1818 * for our information.
1819 */
1820 intf->beacon->skb = skb;
1821 rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
1822
1823 /*
1824 * Fill in skb descriptor
1825 */
1826 skbdesc = get_skb_frame_desc(skb);
1827 memset(skbdesc, 0, sizeof(*skbdesc));
1828 skbdesc->desc = entry_priv->desc;
1829 skbdesc->desc_len = intf->beacon->queue->desc_size;
1830 skbdesc->entry = intf->beacon;
1831
1832 /*
1833 * Disable beaconing while we are reloading the beacon data,
1834 * otherwise we might be sending out invalid data.
1835 */
1836 rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
1837 rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
1838 rt2x00_set_field32(&reg, CSR14_TBCN, 0);
1839 rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
1840 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
1841
1842 /*
1843 * Enable beacon generation.
1844 * Write entire beacon with descriptor to register,
1845 * and kick the beacon generator.
1846 */
1847 rt2x00queue_map_txskb(rt2x00dev, intf->beacon->skb);
1848 rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc);
1849 rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON);
1850
1851 return 0;
1852}
1853
1854static int rt2500pci_tx_last_beacon(struct ieee80211_hw *hw) 1845static int rt2500pci_tx_last_beacon(struct ieee80211_hw *hw)
1855{ 1846{
1856 struct rt2x00_dev *rt2x00dev = hw->priv; 1847 struct rt2x00_dev *rt2x00dev = hw->priv;
@@ -1875,7 +1866,6 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = {
1875 .conf_tx = rt2x00mac_conf_tx, 1866 .conf_tx = rt2x00mac_conf_tx,
1876 .get_tx_stats = rt2x00mac_get_tx_stats, 1867 .get_tx_stats = rt2x00mac_get_tx_stats,
1877 .get_tsf = rt2500pci_get_tsf, 1868 .get_tsf = rt2500pci_get_tsf,
1878 .beacon_update = rt2500pci_beacon_update,
1879 .tx_last_beacon = rt2500pci_tx_last_beacon, 1869 .tx_last_beacon = rt2500pci_tx_last_beacon,
1880}; 1870};
1881 1871
@@ -1893,6 +1883,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1893 .link_tuner = rt2500pci_link_tuner, 1883 .link_tuner = rt2500pci_link_tuner,
1894 .write_tx_desc = rt2500pci_write_tx_desc, 1884 .write_tx_desc = rt2500pci_write_tx_desc,
1895 .write_tx_data = rt2x00pci_write_tx_data, 1885 .write_tx_data = rt2x00pci_write_tx_data,
1886 .write_beacon = rt2500pci_write_beacon,
1896 .kick_tx_queue = rt2500pci_kick_tx_queue, 1887 .kick_tx_queue = rt2500pci_kick_tx_queue,
1897 .fill_rxdone = rt2500pci_fill_rxdone, 1888 .fill_rxdone = rt2500pci_fill_rxdone,
1898 .config_filter = rt2500pci_config_filter, 1889 .config_filter = rt2500pci_config_filter,
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 0dd1cb537b92..3558cb210747 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -812,6 +812,13 @@ static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
812 rt2x00_set_field16(&reg, TXRX_CSR8_BBP_ID1_VALID, 0); 812 rt2x00_set_field16(&reg, TXRX_CSR8_BBP_ID1_VALID, 0);
813 rt2500usb_register_write(rt2x00dev, TXRX_CSR8, reg); 813 rt2500usb_register_write(rt2x00dev, TXRX_CSR8, reg);
814 814
815 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
816 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 0);
817 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 0);
818 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 0);
819 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
820 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
821
815 rt2500usb_register_write(rt2x00dev, TXRX_CSR21, 0xe78f); 822 rt2500usb_register_write(rt2x00dev, TXRX_CSR21, 0xe78f);
816 rt2500usb_register_write(rt2x00dev, MAC_CSR9, 0xff1d); 823 rt2500usb_register_write(rt2x00dev, MAC_CSR9, 0xff1d);
817 824
@@ -1100,6 +1107,65 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1100 rt2x00_desc_write(txd, 0, word); 1107 rt2x00_desc_write(txd, 0, word);
1101} 1108}
1102 1109
1110/*
1111 * TX data initialization
1112 */
1113static void rt2500usb_beacondone(struct urb *urb);
1114
1115static void rt2500usb_write_beacon(struct queue_entry *entry)
1116{
1117 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1118 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
1119 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data;
1120 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1121 int pipe = usb_sndbulkpipe(usb_dev, 1);
1122 int length;
1123 u16 reg;
1124
1125 /*
1126 * Add the descriptor in front of the skb.
1127 */
1128 skb_push(entry->skb, entry->queue->desc_size);
1129 memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
1130 skbdesc->desc = entry->skb->data;
1131
1132 /*
1133 * Disable beaconing while we are reloading the beacon data,
1134 * otherwise we might be sending out invalid data.
1135 */
1136 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
1137 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 0);
1138 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 0);
1139 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
1140 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
1141
1142 /*
1143 * USB devices cannot blindly pass the skb->len as the
1144 * length of the data to usb_fill_bulk_urb. Pass the skb
1145 * to the driver to determine what the length should be.
1146 */
1147 length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, entry->skb);
1148
1149 usb_fill_bulk_urb(bcn_priv->urb, usb_dev, pipe,
1150 entry->skb->data, length, rt2500usb_beacondone,
1151 entry);
1152
1153 /*
1154 * Second we need to create the guardian byte.
1155 * We only need a single byte, so lets recycle
1156 * the 'flags' field we are not using for beacons.
1157 */
1158 bcn_priv->guardian_data = 0;
1159 usb_fill_bulk_urb(bcn_priv->guardian_urb, usb_dev, pipe,
1160 &bcn_priv->guardian_data, 1, rt2500usb_beacondone,
1161 entry);
1162
1163 /*
1164 * Send out the guardian byte.
1165 */
1166 usb_submit_urb(bcn_priv->guardian_urb, GFP_ATOMIC);
1167}
1168
1103static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev, 1169static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1104 struct sk_buff *skb) 1170 struct sk_buff *skb)
1105{ 1171{
@@ -1115,9 +1181,6 @@ static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1115 return length; 1181 return length;
1116} 1182}
1117 1183
1118/*
1119 * TX data initialization
1120 */
1121static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev, 1184static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1122 const enum data_queue_qid queue) 1185 const enum data_queue_qid queue)
1123{ 1186{
@@ -1672,96 +1735,6 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1672 return 0; 1735 return 0;
1673} 1736}
1674 1737
1675/*
1676 * IEEE80211 stack callback functions.
1677 */
1678static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
1679{
1680 struct rt2x00_dev *rt2x00dev = hw->priv;
1681 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
1682 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1683 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
1684 struct queue_entry_priv_usb_bcn *bcn_priv;
1685 struct skb_frame_desc *skbdesc;
1686 struct txentry_desc txdesc;
1687 int pipe = usb_sndbulkpipe(usb_dev, 1);
1688 int length;
1689 u16 reg;
1690
1691 if (unlikely(!intf->beacon))
1692 return -ENOBUFS;
1693
1694 bcn_priv = intf->beacon->priv_data;
1695
1696 /*
1697 * Copy all TX descriptor information into txdesc,
1698 * after that we are free to use the skb->cb array
1699 * for our information.
1700 */
1701 intf->beacon->skb = skb;
1702 rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
1703
1704 /*
1705 * Add the descriptor in front of the skb.
1706 */
1707 skb_push(skb, intf->beacon->queue->desc_size);
1708 memset(skb->data, 0, intf->beacon->queue->desc_size);
1709
1710 /*
1711 * Fill in skb descriptor
1712 */
1713 skbdesc = get_skb_frame_desc(skb);
1714 memset(skbdesc, 0, sizeof(*skbdesc));
1715 skbdesc->desc = skb->data;
1716 skbdesc->desc_len = intf->beacon->queue->desc_size;
1717 skbdesc->entry = intf->beacon;
1718
1719 /*
1720 * Disable beaconing while we are reloading the beacon data,
1721 * otherwise we might be sending out invalid data.
1722 */
1723 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
1724 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 0);
1725 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 0);
1726 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
1727 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
1728
1729 rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc);
1730
1731 /*
1732 * USB devices cannot blindly pass the skb->len as the
1733 * length of the data to usb_fill_bulk_urb. Pass the skb
1734 * to the driver to determine what the length should be.
1735 */
1736 length = rt2500usb_get_tx_data_len(rt2x00dev, skb);
1737
1738 usb_fill_bulk_urb(bcn_priv->urb, usb_dev, pipe,
1739 skb->data, length, rt2500usb_beacondone,
1740 intf->beacon);
1741
1742 /*
1743 * Second we need to create the guardian byte.
1744 * We only need a single byte, so lets recycle
1745 * the 'flags' field we are not using for beacons.
1746 */
1747 bcn_priv->guardian_data = 0;
1748 usb_fill_bulk_urb(bcn_priv->guardian_urb, usb_dev, pipe,
1749 &bcn_priv->guardian_data, 1, rt2500usb_beacondone,
1750 intf->beacon);
1751
1752 /*
1753 * Send out the guardian byte.
1754 */
1755 usb_submit_urb(bcn_priv->guardian_urb, GFP_ATOMIC);
1756
1757 /*
1758 * Enable beacon generation.
1759 */
1760 rt2500usb_kick_tx_queue(rt2x00dev, QID_BEACON);
1761
1762 return 0;
1763}
1764
1765static const struct ieee80211_ops rt2500usb_mac80211_ops = { 1738static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1766 .tx = rt2x00mac_tx, 1739 .tx = rt2x00mac_tx,
1767 .start = rt2x00mac_start, 1740 .start = rt2x00mac_start,
@@ -1775,7 +1748,6 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1775 .bss_info_changed = rt2x00mac_bss_info_changed, 1748 .bss_info_changed = rt2x00mac_bss_info_changed,
1776 .conf_tx = rt2x00mac_conf_tx, 1749 .conf_tx = rt2x00mac_conf_tx,
1777 .get_tx_stats = rt2x00mac_get_tx_stats, 1750 .get_tx_stats = rt2x00mac_get_tx_stats,
1778 .beacon_update = rt2500usb_beacon_update,
1779}; 1751};
1780 1752
1781static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = { 1753static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
@@ -1790,6 +1762,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1790 .link_tuner = rt2500usb_link_tuner, 1762 .link_tuner = rt2500usb_link_tuner,
1791 .write_tx_desc = rt2500usb_write_tx_desc, 1763 .write_tx_desc = rt2500usb_write_tx_desc,
1792 .write_tx_data = rt2x00usb_write_tx_data, 1764 .write_tx_data = rt2x00usb_write_tx_data,
1765 .write_beacon = rt2500usb_write_beacon,
1793 .get_tx_data_len = rt2500usb_get_tx_data_len, 1766 .get_tx_data_len = rt2500usb_get_tx_data_len,
1794 .kick_tx_queue = rt2500usb_kick_tx_queue, 1767 .kick_tx_queue = rt2500usb_kick_tx_queue,
1795 .fill_rxdone = rt2500usb_fill_rxdone, 1768 .fill_rxdone = rt2500usb_fill_rxdone,
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index c07d9ef383f0..9fab0df18c3c 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -364,6 +364,8 @@ struct rt2x00_intf {
364#define DELAYED_UPDATE_BEACON 0x00000001 364#define DELAYED_UPDATE_BEACON 0x00000001
365#define DELAYED_CONFIG_ERP 0x00000002 365#define DELAYED_CONFIG_ERP 0x00000002
366#define DELAYED_LED_ASSOC 0x00000004 366#define DELAYED_LED_ASSOC 0x00000004
367
368 u16 seqno;
367}; 369};
368 370
369static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif) 371static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
@@ -434,6 +436,7 @@ struct rt2x00lib_conf {
434 */ 436 */
435struct rt2x00lib_erp { 437struct rt2x00lib_erp {
436 int short_preamble; 438 int short_preamble;
439 int cts_protection;
437 440
438 int ack_timeout; 441 int ack_timeout;
439 int ack_consume_time; 442 int ack_consume_time;
@@ -520,6 +523,7 @@ struct rt2x00lib_ops {
520 struct sk_buff *skb, 523 struct sk_buff *skb,
521 struct txentry_desc *txdesc); 524 struct txentry_desc *txdesc);
522 int (*write_tx_data) (struct queue_entry *entry); 525 int (*write_tx_data) (struct queue_entry *entry);
526 void (*write_beacon) (struct queue_entry *entry);
523 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, 527 int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev,
524 struct sk_buff *skb); 528 struct sk_buff *skb);
525 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, 529 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
@@ -910,39 +914,6 @@ static inline u16 get_duration_res(const unsigned int size, const u8 rate)
910void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb); 914void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
911 915
912/** 916/**
913 * rt2x00queue_create_tx_descriptor - Create TX descriptor from mac80211 input
914 * @entry: The entry which will be used to transfer the TX frame.
915 * @txdesc: rt2x00 TX descriptor which will be initialized by this function.
916 *
917 * This function will initialize the &struct txentry_desc based on information
918 * from mac80211. This descriptor can then be used by rt2x00lib and the drivers
919 * to correctly initialize the hardware descriptor.
920 * Note that before calling this function the skb->cb array must be untouched
921 * by rt2x00lib. Only after this function completes will it be save to
922 * overwrite the skb->cb information.
923 * The reason for this is that mac80211 writes its own tx information into
924 * the skb->cb array, and this function will use that information to initialize
925 * the &struct txentry_desc structure.
926 */
927void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
928 struct txentry_desc *txdesc);
929
930/**
931 * rt2x00queue_write_tx_descriptor - Write TX descriptor to hardware
932 * @entry: The entry which will be used to transfer the TX frame.
933 * @txdesc: TX descriptor which will be used to write hardware descriptor
934 *
935 * This function will write a TX descriptor initialized by
936 * &rt2x00queue_create_tx_descriptor to the hardware. After this call
937 * has completed the frame is now owned by the hardware, the hardware
938 * queue will have automatically be kicked unless this frame was generated
939 * by rt2x00lib, in which case the frame is "special" and must be kicked
940 * by the caller.
941 */
942void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
943 struct txentry_desc *txdesc);
944
945/**
946 * rt2x00queue_get_queue - Convert queue index to queue pointer 917 * rt2x00queue_get_queue - Convert queue index to queue pointer
947 * @rt2x00dev: Pointer to &struct rt2x00_dev. 918 * @rt2x00dev: Pointer to &struct rt2x00_dev.
948 * @queue: rt2x00 queue index (see &enum data_queue_qid). 919 * @queue: rt2x00 queue index (see &enum data_queue_qid).
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 48608e8cc8b4..f20ca712504f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -84,6 +84,8 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
84 memset(&erp, 0, sizeof(erp)); 84 memset(&erp, 0, sizeof(erp));
85 85
86 erp.short_preamble = bss_conf->use_short_preamble; 86 erp.short_preamble = bss_conf->use_short_preamble;
87 erp.cts_protection = bss_conf->use_cts_prot;
88
87 erp.ack_timeout = PLCP + get_duration(ACK_SIZE, 10); 89 erp.ack_timeout = PLCP + get_duration(ACK_SIZE, 10);
88 erp.ack_consume_time = SIFS + PLCP + get_duration(ACK_SIZE, 10); 90 erp.ack_consume_time = SIFS + PLCP + get_duration(ACK_SIZE, 10);
89 91
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index b48c04e80a38..8c93eb8353b0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -409,7 +409,6 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
409{ 409{
410 struct rt2x00_dev *rt2x00dev = data; 410 struct rt2x00_dev *rt2x00dev = data;
411 struct rt2x00_intf *intf = vif_to_intf(vif); 411 struct rt2x00_intf *intf = vif_to_intf(vif);
412 struct sk_buff *skb;
413 struct ieee80211_bss_conf conf; 412 struct ieee80211_bss_conf conf;
414 int delayed_flags; 413 int delayed_flags;
415 414
@@ -435,12 +434,8 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
435 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 434 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
436 return; 435 return;
437 436
438 if (delayed_flags & DELAYED_UPDATE_BEACON) { 437 if (delayed_flags & DELAYED_UPDATE_BEACON)
439 skb = ieee80211_beacon_get(rt2x00dev->hw, vif); 438 rt2x00queue_update_beacon(rt2x00dev, vif);
440 if (skb &&
441 rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, skb))
442 dev_kfree_skb(skb);
443 }
444 439
445 if (delayed_flags & DELAYED_CONFIG_ERP) 440 if (delayed_flags & DELAYED_CONFIG_ERP)
446 rt2x00lib_config_erp(rt2x00dev, intf, &conf); 441 rt2x00lib_config_erp(rt2x00dev, intf, &conf);
diff --git a/drivers/net/wireless/rt2x00/rt2x00firmware.c b/drivers/net/wireless/rt2x00/rt2x00firmware.c
index b971bc6e7ee2..bab05a56e7a0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00firmware.c
+++ b/drivers/net/wireless/rt2x00/rt2x00firmware.c
@@ -100,6 +100,14 @@ int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev)
100 retval = rt2x00dev->ops->lib->load_firmware(rt2x00dev, 100 retval = rt2x00dev->ops->lib->load_firmware(rt2x00dev,
101 rt2x00dev->fw->data, 101 rt2x00dev->fw->data,
102 rt2x00dev->fw->size); 102 rt2x00dev->fw->size);
103
104 /*
105 * When the firmware is uploaded to the hardware the LED
106 * association status might have been triggered, for correct
107 * LED handling it should now be reset.
108 */
109 rt2x00leds_led_assoc(rt2x00dev, false);
110
103 return retval; 111 return retval;
104} 112}
105 113
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index eae5ce1d4de3..f2c9b0e79b5f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -139,6 +139,14 @@ void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
139int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb); 139int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb);
140 140
141/** 141/**
142 * rt2x00queue_update_beacon - Send new beacon from mac80211 to hardware
143 * @rt2x00dev: Pointer to &struct rt2x00_dev.
144 * @vif: Interface for which the beacon should be updated.
145 */
146int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
147 struct ieee80211_vif *vif);
148
149/**
142 * rt2x00queue_index_inc - Index incrementation function 150 * rt2x00queue_index_inc - Index incrementation function
143 * @queue: Queue (&struct data_queue) to perform the action on. 151 * @queue: Queue (&struct data_queue) to perform the action on.
144 * @index: Index type (&enum queue_index) to perform the action on. 152 * @index: Index type (&enum queue_index) to perform the action on.
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 3a1fb6d47e5d..77af1df5d899 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -96,6 +96,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
96 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 96 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
97 struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data; 97 struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data;
98 enum data_queue_qid qid = skb_get_queue_mapping(skb); 98 enum data_queue_qid qid = skb_get_queue_mapping(skb);
99 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
99 struct data_queue *queue; 100 struct data_queue *queue;
100 u16 frame_control; 101 u16 frame_control;
101 102
@@ -151,6 +152,18 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
151 } 152 }
152 } 153 }
153 154
155 /*
156 * XXX: This is as wrong as the old mac80211 code was,
157 * due to beacons not getting sequence numbers assigned
158 * properly.
159 */
160 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
161 if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
162 intf->seqno += 0x10;
163 ieee80211hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
164 ieee80211hdr->seq_ctrl |= cpu_to_le16(intf->seqno);
165 }
166
154 if (rt2x00queue_write_tx_frame(queue, skb)) { 167 if (rt2x00queue_write_tx_frame(queue, skb)) {
155 ieee80211_stop_queue(rt2x00dev->hw, qid); 168 ieee80211_stop_queue(rt2x00dev->hw, qid);
156 return NETDEV_TX_BUSY; 169 return NETDEV_TX_BUSY;
@@ -348,7 +361,8 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
348{ 361{
349 struct rt2x00_dev *rt2x00dev = hw->priv; 362 struct rt2x00_dev *rt2x00dev = hw->priv;
350 struct rt2x00_intf *intf = vif_to_intf(vif); 363 struct rt2x00_intf *intf = vif_to_intf(vif);
351 int status; 364 int update_bssid = 0;
365 int status = 0;
352 366
353 /* 367 /*
354 * Mac80211 might be calling this function while we are trying 368 * Mac80211 might be calling this function while we are trying
@@ -360,12 +374,13 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
360 spin_lock(&intf->lock); 374 spin_lock(&intf->lock);
361 375
362 /* 376 /*
363 * If the interface does not work in master mode, 377 * conf->bssid can be NULL if coming from the internal
364 * then the bssid value in the interface structure 378 * beacon update routine.
365 * should now be set.
366 */ 379 */
367 if (conf->type != IEEE80211_IF_TYPE_AP) 380 if (conf->changed & IEEE80211_IFCC_BSSID && conf->bssid) {
381 update_bssid = 1;
368 memcpy(&intf->bssid, conf->bssid, ETH_ALEN); 382 memcpy(&intf->bssid, conf->bssid, ETH_ALEN);
383 }
369 384
370 spin_unlock(&intf->lock); 385 spin_unlock(&intf->lock);
371 386
@@ -375,17 +390,14 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
375 * values as arguments we make keep access to rt2x00_intf thread safe 390 * values as arguments we make keep access to rt2x00_intf thread safe
376 * even without the lock. 391 * even without the lock.
377 */ 392 */
378 rt2x00lib_config_intf(rt2x00dev, intf, conf->type, NULL, conf->bssid); 393 rt2x00lib_config_intf(rt2x00dev, intf, vif->type, NULL,
394 update_bssid ? conf->bssid : NULL);
379 395
380 /* 396 /*
381 * We only need to initialize the beacon when master mode is enabled. 397 * Update the beacon.
382 */ 398 */
383 if (conf->type != IEEE80211_IF_TYPE_AP || !conf->beacon) 399 if (conf->changed & IEEE80211_IFCC_BEACON)
384 return 0; 400 status = rt2x00queue_update_beacon(rt2x00dev, vif);
385
386 status = rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, conf->beacon);
387 if (status)
388 dev_kfree_skb(conf->beacon);
389 401
390 return status; 402 return status;
391} 403}
@@ -501,7 +513,7 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
501 * When the erp information has changed, we should perform 513 * When the erp information has changed, we should perform
502 * additional configuration steps. For all other changes we are done. 514 * additional configuration steps. For all other changes we are done.
503 */ 515 */
504 if (changes & BSS_CHANGED_ERP_PREAMBLE) { 516 if (changes & (BSS_CHANGED_ERP_PREAMBLE | BSS_CHANGED_ERP_CTS_PROT)) {
505 if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags)) 517 if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags))
506 rt2x00lib_config_erp(rt2x00dev, intf, bss_conf); 518 rt2x00lib_config_erp(rt2x00dev, intf, bss_conf);
507 else 519 else
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 3ddce538ef4a..7f442030f5ad 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -108,12 +108,15 @@ void rt2x00queue_unmap_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
108 108
109void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb) 109void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
110{ 110{
111 if (!skb)
112 return;
113
111 rt2x00queue_unmap_skb(rt2x00dev, skb); 114 rt2x00queue_unmap_skb(rt2x00dev, skb);
112 dev_kfree_skb_any(skb); 115 dev_kfree_skb_any(skb);
113} 116}
114 117
115void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, 118static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
116 struct txentry_desc *txdesc) 119 struct txentry_desc *txdesc)
117{ 120{
118 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 121 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
119 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); 122 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);
@@ -237,10 +240,9 @@ void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
237 txdesc->signal |= 0x08; 240 txdesc->signal |= 0x08;
238 } 241 }
239} 242}
240EXPORT_SYMBOL_GPL(rt2x00queue_create_tx_descriptor);
241 243
242void rt2x00queue_write_tx_descriptor(struct queue_entry *entry, 244static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
243 struct txentry_desc *txdesc) 245 struct txentry_desc *txdesc)
244{ 246{
245 struct data_queue *queue = entry->queue; 247 struct data_queue *queue = entry->queue;
246 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; 248 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
@@ -270,7 +272,6 @@ void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,
270 !test_bit(ENTRY_TXD_BURST, &txdesc->flags)) 272 !test_bit(ENTRY_TXD_BURST, &txdesc->flags))
271 rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, queue->qid); 273 rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, queue->qid);
272} 274}
273EXPORT_SYMBOL_GPL(rt2x00queue_write_tx_descriptor);
274 275
275int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb) 276int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
276{ 277{
@@ -320,6 +321,60 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
320 return 0; 321 return 0;
321} 322}
322 323
324int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
325 struct ieee80211_vif *vif)
326{
327 struct rt2x00_intf *intf = vif_to_intf(vif);
328 struct skb_frame_desc *skbdesc;
329 struct txentry_desc txdesc;
330 __le32 desc[16];
331
332 if (unlikely(!intf->beacon))
333 return -ENOBUFS;
334
335 intf->beacon->skb = ieee80211_beacon_get(rt2x00dev->hw, vif);
336 if (!intf->beacon->skb)
337 return -ENOMEM;
338
339 /*
340 * Copy all TX descriptor information into txdesc,
341 * after that we are free to use the skb->cb array
342 * for our information.
343 */
344 rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
345
346 /*
347 * For the descriptor we use a local array from where the
348 * driver can move it to the correct location required for
349 * the hardware.
350 */
351 memset(desc, 0, sizeof(desc));
352
353 /*
354 * Fill in skb descriptor
355 */
356 skbdesc = get_skb_frame_desc(intf->beacon->skb);
357 memset(skbdesc, 0, sizeof(*skbdesc));
358 skbdesc->desc = desc;
359 skbdesc->desc_len = intf->beacon->queue->desc_size;
360 skbdesc->entry = intf->beacon;
361
362 /*
363 * Write TX descriptor into reserved room in front of the beacon.
364 */
365 rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc);
366
367 /*
368 * Send beacon to hardware.
369 * Also enable beacon generation, which might have been disabled
370 * by the driver during the config_beacon() callback function.
371 */
372 rt2x00dev->ops->lib->write_beacon(intf->beacon);
373 rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON);
374
375 return 0;
376}
377
323struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev, 378struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
324 const enum data_queue_qid queue) 379 const enum data_queue_qid queue)
325{ 380{
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index bbf1048f6400..70ef7bf434ab 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1198,6 +1198,15 @@ static int rt61pci_init_registers(struct rt2x00_dev *rt2x00dev)
1198 rt2x00_set_field32(&reg, TXRX_CSR8_ACK_CTS_54MBS, 42); 1198 rt2x00_set_field32(&reg, TXRX_CSR8_ACK_CTS_54MBS, 42);
1199 rt2x00pci_register_write(rt2x00dev, TXRX_CSR8, reg); 1199 rt2x00pci_register_write(rt2x00dev, TXRX_CSR8, reg);
1200 1200
1201 rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
1202 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_INTERVAL, 0);
1203 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1204 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0);
1205 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1206 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1207 rt2x00_set_field32(&reg, TXRX_CSR9_TIMESTAMP_COMPENSATE, 0);
1208 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
1209
1201 rt2x00pci_register_write(rt2x00dev, TXRX_CSR15, 0x0000000f); 1210 rt2x00pci_register_write(rt2x00dev, TXRX_CSR15, 0x0000000f);
1202 1211
1203 rt2x00pci_register_write(rt2x00dev, MAC_CSR6, 0x00000fff); 1212 rt2x00pci_register_write(rt2x00dev, MAC_CSR6, 0x00000fff);
@@ -1591,6 +1600,41 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1591/* 1600/*
1592 * TX data initialization 1601 * TX data initialization
1593 */ 1602 */
1603static void rt61pci_write_beacon(struct queue_entry *entry)
1604{
1605 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1606 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1607 unsigned int beacon_base;
1608 u32 reg;
1609
1610 /*
1611 * Disable beaconing while we are reloading the beacon data,
1612 * otherwise we might be sending out invalid data.
1613 */
1614 rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
1615 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1616 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1617 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1618 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
1619
1620 /*
1621 * Write entire beacon with descriptor to register.
1622 */
1623 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
1624 rt2x00pci_register_multiwrite(rt2x00dev,
1625 beacon_base,
1626 skbdesc->desc, skbdesc->desc_len);
1627 rt2x00pci_register_multiwrite(rt2x00dev,
1628 beacon_base + skbdesc->desc_len,
1629 entry->skb->data, entry->skb->len);
1630
1631 /*
1632 * Clean up beacon skb.
1633 */
1634 dev_kfree_skb_any(entry->skb);
1635 entry->skb = NULL;
1636}
1637
1594static void rt61pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev, 1638static void rt61pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1595 const enum data_queue_qid queue) 1639 const enum data_queue_qid queue)
1596{ 1640{
@@ -2346,72 +2390,6 @@ static u64 rt61pci_get_tsf(struct ieee80211_hw *hw)
2346 return tsf; 2390 return tsf;
2347} 2391}
2348 2392
2349static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
2350{
2351 struct rt2x00_dev *rt2x00dev = hw->priv;
2352 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
2353 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
2354 struct queue_entry_priv_pci *entry_priv;
2355 struct skb_frame_desc *skbdesc;
2356 struct txentry_desc txdesc;
2357 unsigned int beacon_base;
2358 u32 reg;
2359
2360 if (unlikely(!intf->beacon))
2361 return -ENOBUFS;
2362
2363 /*
2364 * Copy all TX descriptor information into txdesc,
2365 * after that we are free to use the skb->cb array
2366 * for our information.
2367 */
2368 intf->beacon->skb = skb;
2369 rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
2370
2371 entry_priv = intf->beacon->priv_data;
2372 memset(entry_priv->desc, 0, intf->beacon->queue->desc_size);
2373
2374 /*
2375 * Fill in skb descriptor
2376 */
2377 skbdesc = get_skb_frame_desc(skb);
2378 memset(skbdesc, 0, sizeof(*skbdesc));
2379 skbdesc->desc = entry_priv->desc;
2380 skbdesc->desc_len = intf->beacon->queue->desc_size;
2381 skbdesc->entry = intf->beacon;
2382
2383 /*
2384 * Disable beaconing while we are reloading the beacon data,
2385 * otherwise we might be sending out invalid data.
2386 */
2387 rt2x00pci_register_read(rt2x00dev, TXRX_CSR9, &reg);
2388 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
2389 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
2390 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
2391 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
2392
2393 /*
2394 * Write entire beacon with descriptor to register,
2395 * and kick the beacon generator.
2396 */
2397 rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc);
2398 beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
2399 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base,
2400 skbdesc->desc, skbdesc->desc_len);
2401 rt2x00pci_register_multiwrite(rt2x00dev,
2402 beacon_base + skbdesc->desc_len,
2403 skb->data, skb->len);
2404 rt61pci_kick_tx_queue(rt2x00dev, QID_BEACON);
2405
2406 /*
2407 * Clean up beacon skb.
2408 */
2409 dev_kfree_skb_any(skb);
2410 intf->beacon->skb = NULL;
2411
2412 return 0;
2413}
2414
2415static const struct ieee80211_ops rt61pci_mac80211_ops = { 2393static const struct ieee80211_ops rt61pci_mac80211_ops = {
2416 .tx = rt2x00mac_tx, 2394 .tx = rt2x00mac_tx,
2417 .start = rt2x00mac_start, 2395 .start = rt2x00mac_start,
@@ -2427,7 +2405,6 @@ static const struct ieee80211_ops rt61pci_mac80211_ops = {
2427 .conf_tx = rt2x00mac_conf_tx, 2405 .conf_tx = rt2x00mac_conf_tx,
2428 .get_tx_stats = rt2x00mac_get_tx_stats, 2406 .get_tx_stats = rt2x00mac_get_tx_stats,
2429 .get_tsf = rt61pci_get_tsf, 2407 .get_tsf = rt61pci_get_tsf,
2430 .beacon_update = rt61pci_beacon_update,
2431}; 2408};
2432 2409
2433static const struct rt2x00lib_ops rt61pci_rt2x00_ops = { 2410static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
@@ -2447,6 +2424,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2447 .link_tuner = rt61pci_link_tuner, 2424 .link_tuner = rt61pci_link_tuner,
2448 .write_tx_desc = rt61pci_write_tx_desc, 2425 .write_tx_desc = rt61pci_write_tx_desc,
2449 .write_tx_data = rt2x00pci_write_tx_data, 2426 .write_tx_data = rt2x00pci_write_tx_data,
2427 .write_beacon = rt61pci_write_beacon,
2450 .kick_tx_queue = rt61pci_kick_tx_queue, 2428 .kick_tx_queue = rt61pci_kick_tx_queue,
2451 .fill_rxdone = rt61pci_fill_rxdone, 2429 .fill_rxdone = rt61pci_fill_rxdone,
2452 .config_filter = rt61pci_config_filter, 2430 .config_filter = rt61pci_config_filter,
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 3ef318e098e7..34c6ff27afc4 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1016,6 +1016,15 @@ static int rt73usb_init_registers(struct rt2x00_dev *rt2x00dev)
1016 rt2x00_set_field32(&reg, TXRX_CSR8_ACK_CTS_54MBS, 42); 1016 rt2x00_set_field32(&reg, TXRX_CSR8_ACK_CTS_54MBS, 42);
1017 rt73usb_register_write(rt2x00dev, TXRX_CSR8, reg); 1017 rt73usb_register_write(rt2x00dev, TXRX_CSR8, reg);
1018 1018
1019 rt73usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
1020 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_INTERVAL, 0);
1021 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1022 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0);
1023 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1024 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1025 rt2x00_set_field32(&reg, TXRX_CSR9_TIMESTAMP_COMPENSATE, 0);
1026 rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1027
1019 rt73usb_register_write(rt2x00dev, TXRX_CSR15, 0x0000000f); 1028 rt73usb_register_write(rt2x00dev, TXRX_CSR15, 0x0000000f);
1020 1029
1021 rt73usb_register_read(rt2x00dev, MAC_CSR6, &reg); 1030 rt73usb_register_read(rt2x00dev, MAC_CSR6, &reg);
@@ -1334,6 +1343,49 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1334 rt2x00_desc_write(txd, 0, word); 1343 rt2x00_desc_write(txd, 0, word);
1335} 1344}
1336 1345
1346/*
1347 * TX data initialization
1348 */
1349static void rt73usb_write_beacon(struct queue_entry *entry)
1350{
1351 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1352 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1353 unsigned int beacon_base;
1354 u32 reg;
1355
1356 /*
1357 * Add the descriptor in front of the skb.
1358 */
1359 skb_push(entry->skb, entry->queue->desc_size);
1360 memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
1361 skbdesc->desc = entry->skb->data;
1362
1363 /*
1364 * Disable beaconing while we are reloading the beacon data,
1365 * otherwise we might be sending out invalid data.
1366 */
1367 rt73usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
1368 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1369 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1370 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1371 rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1372
1373 /*
1374 * Write entire beacon with descriptor to register.
1375 */
1376 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
1377 rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE,
1378 USB_VENDOR_REQUEST_OUT, beacon_base, 0,
1379 entry->skb->data, entry->skb->len,
1380 REGISTER_TIMEOUT32(entry->skb->len));
1381
1382 /*
1383 * Clean up the beacon skb.
1384 */
1385 dev_kfree_skb(entry->skb);
1386 entry->skb = NULL;
1387}
1388
1337static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev, 1389static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1338 struct sk_buff *skb) 1390 struct sk_buff *skb)
1339{ 1391{
@@ -1349,9 +1401,6 @@ static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
1349 return length; 1401 return length;
1350} 1402}
1351 1403
1352/*
1353 * TX data initialization
1354 */
1355static void rt73usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev, 1404static void rt73usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1356 const enum data_queue_qid queue) 1405 const enum data_queue_qid queue)
1357{ 1406{
@@ -1949,73 +1998,6 @@ static u64 rt73usb_get_tsf(struct ieee80211_hw *hw)
1949#define rt73usb_get_tsf NULL 1998#define rt73usb_get_tsf NULL
1950#endif 1999#endif
1951 2000
1952static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
1953{
1954 struct rt2x00_dev *rt2x00dev = hw->priv;
1955 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1956 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
1957 struct skb_frame_desc *skbdesc;
1958 struct txentry_desc txdesc;
1959 unsigned int beacon_base;
1960 u32 reg;
1961
1962 if (unlikely(!intf->beacon))
1963 return -ENOBUFS;
1964
1965 /*
1966 * Copy all TX descriptor information into txdesc,
1967 * after that we are free to use the skb->cb array
1968 * for our information.
1969 */
1970 intf->beacon->skb = skb;
1971 rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc);
1972
1973 /*
1974 * Add the descriptor in front of the skb.
1975 */
1976 skb_push(skb, intf->beacon->queue->desc_size);
1977 memset(skb->data, 0, intf->beacon->queue->desc_size);
1978
1979 /*
1980 * Fill in skb descriptor
1981 */
1982 skbdesc = get_skb_frame_desc(skb);
1983 memset(skbdesc, 0, sizeof(*skbdesc));
1984 skbdesc->desc = skb->data;
1985 skbdesc->desc_len = intf->beacon->queue->desc_size;
1986 skbdesc->entry = intf->beacon;
1987
1988 /*
1989 * Disable beaconing while we are reloading the beacon data,
1990 * otherwise we might be sending out invalid data.
1991 */
1992 rt73usb_register_read(rt2x00dev, TXRX_CSR9, &reg);
1993 rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 0);
1994 rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 0);
1995 rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
1996 rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1997
1998 /*
1999 * Write entire beacon with descriptor to register,
2000 * and kick the beacon generator.
2001 */
2002 rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc);
2003 beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
2004 rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE,
2005 USB_VENDOR_REQUEST_OUT, beacon_base, 0,
2006 skb->data, skb->len,
2007 REGISTER_TIMEOUT32(skb->len));
2008 rt73usb_kick_tx_queue(rt2x00dev, QID_BEACON);
2009
2010 /*
2011 * Clean up the beacon skb.
2012 */
2013 dev_kfree_skb(skb);
2014 intf->beacon->skb = NULL;
2015
2016 return 0;
2017}
2018
2019static const struct ieee80211_ops rt73usb_mac80211_ops = { 2001static const struct ieee80211_ops rt73usb_mac80211_ops = {
2020 .tx = rt2x00mac_tx, 2002 .tx = rt2x00mac_tx,
2021 .start = rt2x00mac_start, 2003 .start = rt2x00mac_start,
@@ -2031,7 +2013,6 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
2031 .conf_tx = rt2x00mac_conf_tx, 2013 .conf_tx = rt2x00mac_conf_tx,
2032 .get_tx_stats = rt2x00mac_get_tx_stats, 2014 .get_tx_stats = rt2x00mac_get_tx_stats,
2033 .get_tsf = rt73usb_get_tsf, 2015 .get_tsf = rt73usb_get_tsf,
2034 .beacon_update = rt73usb_beacon_update,
2035}; 2016};
2036 2017
2037static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { 2018static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
@@ -2049,6 +2030,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2049 .link_tuner = rt73usb_link_tuner, 2030 .link_tuner = rt73usb_link_tuner,
2050 .write_tx_desc = rt73usb_write_tx_desc, 2031 .write_tx_desc = rt73usb_write_tx_desc,
2051 .write_tx_data = rt2x00usb_write_tx_data, 2032 .write_tx_data = rt2x00usb_write_tx_data,
2033 .write_beacon = rt73usb_write_beacon,
2052 .get_tx_data_len = rt73usb_get_tx_data_len, 2034 .get_tx_data_len = rt73usb_get_tx_data_len,
2053 .kick_tx_queue = rt73usb_kick_tx_queue, 2035 .kick_tx_queue = rt73usb_kick_tx_queue,
2054 .fill_rxdone = rt73usb_fill_rxdone, 2036 .fill_rxdone = rt73usb_fill_rxdone,
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
index 33527e58256f..d3067b1216ca 100644
--- a/drivers/net/wireless/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl8187_dev.c
@@ -430,8 +430,10 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
430 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); 430 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
431 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | 431 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg |
432 RTL818X_CONFIG3_ANAPARAM_WRITE); 432 RTL818X_CONFIG3_ANAPARAM_WRITE);
433 rtl818x_iowrite32(priv, &priv->map->ANAPARAM, RTL8225_ANAPARAM_ON); 433 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
434 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, RTL8225_ANAPARAM2_ON); 434 RTL8187_RTL8225_ANAPARAM_ON);
435 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
436 RTL8187_RTL8225_ANAPARAM2_ON);
435 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg & 437 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg &
436 ~RTL818X_CONFIG3_ANAPARAM_WRITE); 438 ~RTL818X_CONFIG3_ANAPARAM_WRITE);
437 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, 439 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
@@ -453,8 +455,10 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
453 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); 455 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
454 rtl818x_iowrite8(priv, &priv->map->CONFIG3, 456 rtl818x_iowrite8(priv, &priv->map->CONFIG3,
455 reg | RTL818X_CONFIG3_ANAPARAM_WRITE); 457 reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
456 rtl818x_iowrite32(priv, &priv->map->ANAPARAM, RTL8225_ANAPARAM_ON); 458 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
457 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, RTL8225_ANAPARAM2_ON); 459 RTL8187_RTL8225_ANAPARAM_ON);
460 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
461 RTL8187_RTL8225_ANAPARAM2_ON);
458 rtl818x_iowrite8(priv, &priv->map->CONFIG3, 462 rtl818x_iowrite8(priv, &priv->map->CONFIG3,
459 reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE); 463 reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
460 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); 464 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
@@ -566,9 +570,12 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
566 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); 570 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
567 reg |= RTL818X_CONFIG3_ANAPARAM_WRITE | RTL818X_CONFIG3_GNT_SELECT; 571 reg |= RTL818X_CONFIG3_ANAPARAM_WRITE | RTL818X_CONFIG3_GNT_SELECT;
568 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg); 572 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
569 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, 0x727f3f52); 573 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
570 rtl818x_iowrite32(priv, &priv->map->ANAPARAM, 0x45090658); 574 RTL8187B_RTL8225_ANAPARAM2_ON);
571 rtl818x_iowrite8(priv, &priv->map->ANAPARAM3, 0); 575 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
576 RTL8187B_RTL8225_ANAPARAM_ON);
577 rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
578 RTL8187B_RTL8225_ANAPARAM3_ON);
572 579
573 rtl818x_iowrite8(priv, (u8 *)0xFF61, 0x10); 580 rtl818x_iowrite8(priv, (u8 *)0xFF61, 0x10);
574 reg = rtl818x_ioread8(priv, (u8 *)0xFF62); 581 reg = rtl818x_ioread8(priv, (u8 *)0xFF62);
@@ -1180,7 +1187,7 @@ static struct usb_driver rtl8187_driver = {
1180 .name = KBUILD_MODNAME, 1187 .name = KBUILD_MODNAME,
1181 .id_table = rtl8187_table, 1188 .id_table = rtl8187_table,
1182 .probe = rtl8187_probe, 1189 .probe = rtl8187_probe,
1183 .disconnect = rtl8187_disconnect, 1190 .disconnect = __devexit_p(rtl8187_disconnect),
1184}; 1191};
1185 1192
1186static int __init rtl8187_init(void) 1193static int __init rtl8187_init(void)
diff --git a/drivers/net/wireless/rtl8187_rtl8225.c b/drivers/net/wireless/rtl8187_rtl8225.c
index 1e059de97116..1bae89903410 100644
--- a/drivers/net/wireless/rtl8187_rtl8225.c
+++ b/drivers/net/wireless/rtl8187_rtl8225.c
@@ -307,7 +307,8 @@ static void rtl8225_rf_set_tx_power(struct ieee80211_hw *dev, int channel)
307 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); 307 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
308 rtl818x_iowrite8(priv, &priv->map->CONFIG3, 308 rtl818x_iowrite8(priv, &priv->map->CONFIG3,
309 reg | RTL818X_CONFIG3_ANAPARAM_WRITE); 309 reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
310 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, RTL8225_ANAPARAM2_ON); 310 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
311 RTL8187_RTL8225_ANAPARAM2_ON);
311 rtl818x_iowrite8(priv, &priv->map->CONFIG3, 312 rtl818x_iowrite8(priv, &priv->map->CONFIG3,
312 reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE); 313 reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
313 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); 314 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
@@ -560,7 +561,8 @@ static void rtl8225z2_rf_set_tx_power(struct ieee80211_hw *dev, int channel)
560 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); 561 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
561 rtl818x_iowrite8(priv, &priv->map->CONFIG3, 562 rtl818x_iowrite8(priv, &priv->map->CONFIG3,
562 reg | RTL818X_CONFIG3_ANAPARAM_WRITE); 563 reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
563 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, RTL8225_ANAPARAM2_ON); 564 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
565 RTL8187_RTL8225_ANAPARAM2_ON);
564 rtl818x_iowrite8(priv, &priv->map->CONFIG3, 566 rtl818x_iowrite8(priv, &priv->map->CONFIG3,
565 reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE); 567 reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
566 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); 568 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
@@ -913,8 +915,19 @@ static void rtl8225_rf_stop(struct ieee80211_hw *dev)
913 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); 915 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
914 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); 916 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
915 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | RTL818X_CONFIG3_ANAPARAM_WRITE); 917 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
916 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, RTL8225_ANAPARAM2_OFF); 918 if (!priv->is_rtl8187b) {
917 rtl818x_iowrite32(priv, &priv->map->ANAPARAM, RTL8225_ANAPARAM_OFF); 919 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
920 RTL8187_RTL8225_ANAPARAM2_OFF);
921 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
922 RTL8187_RTL8225_ANAPARAM_OFF);
923 } else {
924 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
925 RTL8187B_RTL8225_ANAPARAM2_OFF);
926 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
927 RTL8187B_RTL8225_ANAPARAM_OFF);
928 rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
929 RTL8187B_RTL8225_ANAPARAM3_OFF);
930 }
918 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE); 931 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
919 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); 932 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
920} 933}
diff --git a/drivers/net/wireless/rtl8187_rtl8225.h b/drivers/net/wireless/rtl8187_rtl8225.h
index d39ed0295b6e..20c5b6ead0f6 100644
--- a/drivers/net/wireless/rtl8187_rtl8225.h
+++ b/drivers/net/wireless/rtl8187_rtl8225.h
@@ -15,10 +15,17 @@
15#ifndef RTL8187_RTL8225_H 15#ifndef RTL8187_RTL8225_H
16#define RTL8187_RTL8225_H 16#define RTL8187_RTL8225_H
17 17
18#define RTL8225_ANAPARAM_ON 0xa0000a59 18#define RTL8187_RTL8225_ANAPARAM_ON 0xa0000a59
19#define RTL8225_ANAPARAM2_ON 0x860c7312 19#define RTL8187_RTL8225_ANAPARAM2_ON 0x860c7312
20#define RTL8225_ANAPARAM_OFF 0xa00beb59 20#define RTL8187_RTL8225_ANAPARAM_OFF 0xa00beb59
21#define RTL8225_ANAPARAM2_OFF 0x840dec11 21#define RTL8187_RTL8225_ANAPARAM2_OFF 0x840dec11
22
23#define RTL8187B_RTL8225_ANAPARAM_ON 0x45090658
24#define RTL8187B_RTL8225_ANAPARAM2_ON 0x727f3f52
25#define RTL8187B_RTL8225_ANAPARAM3_ON 0x00
26#define RTL8187B_RTL8225_ANAPARAM_OFF 0x55480658
27#define RTL8187B_RTL8225_ANAPARAM2_OFF 0x72003f50
28#define RTL8187B_RTL8225_ANAPARAM3_OFF 0x00
22 29
23const struct rtl818x_rf_ops * rtl8187_detect_rf(struct ieee80211_hw *); 30const struct rtl818x_rf_ops * rtl8187_detect_rf(struct ieee80211_hw *);
24 31
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 665f76af2fec..fcc532bb6a7e 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -707,6 +707,7 @@ static void zd_op_remove_interface(struct ieee80211_hw *hw,
707{ 707{
708 struct zd_mac *mac = zd_hw_mac(hw); 708 struct zd_mac *mac = zd_hw_mac(hw);
709 mac->type = IEEE80211_IF_TYPE_INVALID; 709 mac->type = IEEE80211_IF_TYPE_INVALID;
710 zd_set_beacon_interval(&mac->chip, 0);
710 zd_write_mac_addr(&mac->chip, NULL); 711 zd_write_mac_addr(&mac->chip, NULL);
711} 712}
712 713
@@ -727,15 +728,19 @@ static int zd_op_config_interface(struct ieee80211_hw *hw,
727 if (mac->type == IEEE80211_IF_TYPE_MESH_POINT || 728 if (mac->type == IEEE80211_IF_TYPE_MESH_POINT ||
728 mac->type == IEEE80211_IF_TYPE_IBSS) { 729 mac->type == IEEE80211_IF_TYPE_IBSS) {
729 associated = true; 730 associated = true;
730 if (conf->beacon) { 731 if (conf->changed & IEEE80211_IFCC_BEACON) {
731 r = zd_mac_config_beacon(hw, conf->beacon); 732 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
733
734 if (!beacon)
735 return -ENOMEM;
736 r = zd_mac_config_beacon(hw, beacon);
732 if (r < 0) 737 if (r < 0)
733 return r; 738 return r;
734 r = zd_set_beacon_interval(&mac->chip, BCN_MODE_IBSS | 739 r = zd_set_beacon_interval(&mac->chip, BCN_MODE_IBSS |
735 hw->conf.beacon_int); 740 hw->conf.beacon_int);
736 if (r < 0) 741 if (r < 0)
737 return r; 742 return r;
738 kfree_skb(conf->beacon); 743 kfree_skb(beacon);
739 } 744 }
740 } else 745 } else
741 associated = is_valid_ether_addr(conf->bssid); 746 associated = is_valid_ether_addr(conf->bssid);
@@ -889,17 +894,6 @@ static void zd_op_bss_info_changed(struct ieee80211_hw *hw,
889 } 894 }
890} 895}
891 896
892static int zd_op_beacon_update(struct ieee80211_hw *hw,
893 struct sk_buff *skb)
894{
895 struct zd_mac *mac = zd_hw_mac(hw);
896 zd_mac_config_beacon(hw, skb);
897 kfree_skb(skb);
898 zd_set_beacon_interval(&mac->chip, BCN_MODE_IBSS |
899 hw->conf.beacon_int);
900 return 0;
901}
902
903static const struct ieee80211_ops zd_ops = { 897static const struct ieee80211_ops zd_ops = {
904 .tx = zd_op_tx, 898 .tx = zd_op_tx,
905 .start = zd_op_start, 899 .start = zd_op_start,
@@ -910,7 +904,6 @@ static const struct ieee80211_ops zd_ops = {
910 .config_interface = zd_op_config_interface, 904 .config_interface = zd_op_config_interface,
911 .configure_filter = zd_op_configure_filter, 905 .configure_filter = zd_op_configure_filter,
912 .bss_info_changed = zd_op_bss_info_changed, 906 .bss_info_changed = zd_op_bss_info_changed,
913 .beacon_update = zd_op_beacon_update,
914}; 907};
915 908
916struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) 909struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)