blob: c688ca7ab322dd326412ef0507db0aad445dab0c [file] [log] [blame]
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001/**
2 * This file contains ioctl functions
3 */
4#include <linux/ctype.h>
5#include <linux/delay.h>
6#include <linux/if.h>
7#include <linux/if_arp.h>
8#include <linux/wireless.h>
9#include <linux/bitops.h>
10
John W. Linville7e272fc2008-09-24 18:13:14 -040011#include <net/lib80211.h>
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020012#include <net/iw_handler.h>
13
14#include "host.h"
15#include "radiotap.h"
16#include "decl.h"
17#include "defs.h"
18#include "dev.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020019#include "wext.h"
Holger Schurig245bf202008-04-02 16:27:42 +020020#include "scan.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020021#include "assoc.h"
Dan Williams8e3c91b2007-12-11 15:50:59 -050022#include "cmd.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020023
24
Holger Schurig69f90322007-11-23 15:43:44 +010025static inline void lbs_postpone_association_work(struct lbs_private *priv)
Holger Schurig9f9dac22007-10-26 10:12:14 +020026{
David Woodhouseaa21c002007-12-08 20:04:36 +000027 if (priv->surpriseremoved)
Holger Schurig9f9dac22007-10-26 10:12:14 +020028 return;
29 cancel_delayed_work(&priv->assoc_work);
30 queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
31}
32
Javier Cardona9c31fd632008-09-11 15:32:50 -070033static inline void lbs_do_association_work(struct lbs_private *priv)
34{
35 if (priv->surpriseremoved)
36 return;
37 cancel_delayed_work(&priv->assoc_work);
38 queue_delayed_work(priv->work_thread, &priv->assoc_work, 0);
39}
40
Holger Schurig69f90322007-11-23 15:43:44 +010041static inline void lbs_cancel_association_work(struct lbs_private *priv)
Holger Schurig9f9dac22007-10-26 10:12:14 +020042{
43 cancel_delayed_work(&priv->assoc_work);
David Woodhouseaa21c002007-12-08 20:04:36 +000044 kfree(priv->pending_assoc_req);
45 priv->pending_assoc_req = NULL;
Holger Schurig9f9dac22007-10-26 10:12:14 +020046}
47
Amitkumar Karwar49125452009-09-30 20:04:38 -070048/**
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020049 * @brief Find the channel frequency power info with specific channel
50 *
David Woodhouseaa21c002007-12-08 20:04:36 +000051 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020052 * @param band it can be BAND_A, BAND_G or BAND_B
53 * @param channel the channel for looking
54 * @return A pointer to struct chan_freq_power structure or NULL if not find.
55 */
Holger Schurig69f90322007-11-23 15:43:44 +010056struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
David Woodhouseaa21c002007-12-08 20:04:36 +000057 struct lbs_private *priv,
Holger Schurig69f90322007-11-23 15:43:44 +010058 u8 band,
59 u16 channel)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020060{
61 struct chan_freq_power *cfp = NULL;
62 struct region_channel *rc;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020063 int i, j;
64
David Woodhouseaa21c002007-12-08 20:04:36 +000065 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
66 rc = &priv->region_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020067
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020068 if (!rc->valid || !rc->CFP)
69 continue;
70 if (rc->band != band)
71 continue;
72 for (i = 0; i < rc->nrcfp; i++) {
73 if (rc->CFP[i].channel == channel) {
74 cfp = &rc->CFP[i];
75 break;
76 }
77 }
78 }
79
80 if (!cfp && channel)
Holger Schurig10078322007-11-15 18:05:47 -050081 lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
Holger Schurig9012b282007-05-25 11:27:16 -040082 "cfp by band %d / channel %d\n", band, channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020083
84 return cfp;
85}
86
87/**
88 * @brief Find the channel frequency power info with specific frequency
89 *
David Woodhouseaa21c002007-12-08 20:04:36 +000090 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020091 * @param band it can be BAND_A, BAND_G or BAND_B
92 * @param freq the frequency for looking
93 * @return A pointer to struct chan_freq_power structure or NULL if not find.
94 */
Holger Schurig69f90322007-11-23 15:43:44 +010095static struct chan_freq_power *find_cfp_by_band_and_freq(
David Woodhouseaa21c002007-12-08 20:04:36 +000096 struct lbs_private *priv,
Holger Schurig69f90322007-11-23 15:43:44 +010097 u8 band,
98 u32 freq)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020099{
100 struct chan_freq_power *cfp = NULL;
101 struct region_channel *rc;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200102 int i, j;
103
David Woodhouseaa21c002007-12-08 20:04:36 +0000104 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
105 rc = &priv->region_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200106
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200107 if (!rc->valid || !rc->CFP)
108 continue;
109 if (rc->band != band)
110 continue;
111 for (i = 0; i < rc->nrcfp; i++) {
112 if (rc->CFP[i].freq == freq) {
113 cfp = &rc->CFP[i];
114 break;
115 }
116 }
117 }
118
119 if (!cfp && freq)
Holger Schurig9012b282007-05-25 11:27:16 -0400120 lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
121 "band %d / freq %d\n", band, freq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200122
123 return cfp;
124}
125
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200126/**
Dan Williams8c512762007-08-02 11:40:45 -0400127 * @brief Copy active data rates based on adapter mode and status
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200128 *
David Woodhouseaa21c002007-12-08 20:04:36 +0000129 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200130 * @param rate The buf to return the active rates
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200131 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000132static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200133{
Holger Schurig9012b282007-05-25 11:27:16 -0400134 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200135
David Woodhouseaa21c002007-12-08 20:04:36 +0000136 if ((priv->connect_status != LBS_CONNECTED) &&
137 (priv->mesh_connect_status != LBS_CONNECTED))
Holger Schurig10078322007-11-15 18:05:47 -0500138 memcpy(rates, lbs_bg_rates, MAX_RATES);
Dan Williams8c512762007-08-02 11:40:45 -0400139 else
David Woodhouseaa21c002007-12-08 20:04:36 +0000140 memcpy(rates, priv->curbssparams.rates, MAX_RATES);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200141
Dan Williams8c512762007-08-02 11:40:45 -0400142 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200143}
144
Holger Schurig10078322007-11-15 18:05:47 -0500145static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200146 char *cwrq, char *extra)
147{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200148
Holger Schurig9012b282007-05-25 11:27:16 -0400149 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200150
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400151 /* We could add support for 802.11n here as needed. Jean II */
152 snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200153
Holger Schurig9012b282007-05-25 11:27:16 -0400154 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200155 return 0;
156}
157
Holger Schurig10078322007-11-15 18:05:47 -0500158static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200159 struct iw_freq *fwrq, char *extra)
160{
Kiran Divekarab65f642009-02-19 19:32:39 -0500161 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200162 struct chan_freq_power *cfp;
163
Holger Schurig9012b282007-05-25 11:27:16 -0400164 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200165
David Woodhouseaa21c002007-12-08 20:04:36 +0000166 cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
Holger Schurigc14951f2009-10-22 15:30:50 +0200167 priv->channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200168
169 if (!cfp) {
Holger Schurigc14951f2009-10-22 15:30:50 +0200170 if (priv->channel)
Holger Schurig9012b282007-05-25 11:27:16 -0400171 lbs_deb_wext("invalid channel %d\n",
Holger Schurigc14951f2009-10-22 15:30:50 +0200172 priv->channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200173 return -EINVAL;
174 }
175
176 fwrq->m = (long)cfp->freq * 100000;
177 fwrq->e = 1;
178
Holger Schurig9012b282007-05-25 11:27:16 -0400179 lbs_deb_wext("freq %u\n", fwrq->m);
180 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200181 return 0;
182}
183
Holger Schurig10078322007-11-15 18:05:47 -0500184static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200185 struct sockaddr *awrq, char *extra)
186{
Kiran Divekarab65f642009-02-19 19:32:39 -0500187 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200188
Holger Schurig9012b282007-05-25 11:27:16 -0400189 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200190
David Woodhouseaa21c002007-12-08 20:04:36 +0000191 if (priv->connect_status == LBS_CONNECTED) {
192 memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200193 } else {
194 memset(awrq->sa_data, 0, ETH_ALEN);
195 }
196 awrq->sa_family = ARPHRD_ETHER;
197
Holger Schurig9012b282007-05-25 11:27:16 -0400198 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200199 return 0;
200}
201
Holger Schurig10078322007-11-15 18:05:47 -0500202static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200203 struct iw_point *dwrq, char *extra)
204{
Kiran Divekarab65f642009-02-19 19:32:39 -0500205 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200206
Holger Schurig9012b282007-05-25 11:27:16 -0400207 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200208
209 /*
210 * Check the size of the string
211 */
212
213 if (dwrq->length > 16) {
214 return -E2BIG;
215 }
216
David Woodhouseaa21c002007-12-08 20:04:36 +0000217 mutex_lock(&priv->lock);
218 memset(priv->nodename, 0, sizeof(priv->nodename));
219 memcpy(priv->nodename, extra, dwrq->length);
220 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200221
Holger Schurig9012b282007-05-25 11:27:16 -0400222 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200223 return 0;
224}
225
Holger Schurig10078322007-11-15 18:05:47 -0500226static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200227 struct iw_point *dwrq, char *extra)
228{
Kiran Divekarab65f642009-02-19 19:32:39 -0500229 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200230
Holger Schurig9012b282007-05-25 11:27:16 -0400231 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200232
David Woodhouseaa21c002007-12-08 20:04:36 +0000233 dwrq->length = strlen(priv->nodename);
234 memcpy(extra, priv->nodename, dwrq->length);
Holger Schurig04799fa2007-10-09 15:04:14 +0200235 extra[dwrq->length] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200236
Holger Schurig04799fa2007-10-09 15:04:14 +0200237 dwrq->flags = 1; /* active */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200238
Holger Schurig9012b282007-05-25 11:27:16 -0400239 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200240 return 0;
241}
242
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400243static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
244 struct iw_point *dwrq, char *extra)
245{
Kiran Divekarab65f642009-02-19 19:32:39 -0500246 struct lbs_private *priv = dev->ml_priv;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400247
248 lbs_deb_enter(LBS_DEB_WEXT);
249
250 /* Use nickname to indicate that mesh is on */
251
David Woodhouseaa21c002007-12-08 20:04:36 +0000252 if (priv->mesh_connect_status == LBS_CONNECTED) {
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400253 strncpy(extra, "Mesh", 12);
254 extra[12] = '\0';
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400255 dwrq->length = strlen(extra);
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400256 }
257
258 else {
259 extra[0] = '\0';
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400260 dwrq->length = 0;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400261 }
262
263 lbs_deb_leave(LBS_DEB_WEXT);
264 return 0;
265}
Holger Schurig04799fa2007-10-09 15:04:14 +0200266
Holger Schurig10078322007-11-15 18:05:47 -0500267static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200268 struct iw_param *vwrq, char *extra)
269{
270 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -0500271 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400272 u32 val = vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200273
Holger Schurig9012b282007-05-25 11:27:16 -0400274 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200275
Dan Williams39fcf7a2008-09-10 12:49:00 -0400276 if (vwrq->disabled)
277 val = MRVDRV_RTS_MAX_VALUE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200278
John W. Linville375da532008-09-15 17:25:54 -0400279 if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */
Dan Williams39fcf7a2008-09-10 12:49:00 -0400280 return -EINVAL;
281
282 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200283
Holger Schurig9012b282007-05-25 11:27:16 -0400284 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200285 return ret;
286}
287
Holger Schurig10078322007-11-15 18:05:47 -0500288static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200289 struct iw_param *vwrq, char *extra)
290{
Kiran Divekarab65f642009-02-19 19:32:39 -0500291 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400292 int ret = 0;
293 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200294
Holger Schurig9012b282007-05-25 11:27:16 -0400295 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200296
Dan Williams39fcf7a2008-09-10 12:49:00 -0400297 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
Holger Schurig9012b282007-05-25 11:27:16 -0400298 if (ret)
299 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200300
Dan Williams39fcf7a2008-09-10 12:49:00 -0400301 vwrq->value = val;
John W. Linville375da532008-09-15 17:25:54 -0400302 vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200303 vwrq->fixed = 1;
304
Holger Schurig9012b282007-05-25 11:27:16 -0400305out:
306 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
307 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200308}
309
Holger Schurig10078322007-11-15 18:05:47 -0500310static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200311 struct iw_param *vwrq, char *extra)
312{
Kiran Divekarab65f642009-02-19 19:32:39 -0500313 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400314 int ret = 0;
315 u32 val = vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200316
Holger Schurig9012b282007-05-25 11:27:16 -0400317 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200318
Dan Williams39fcf7a2008-09-10 12:49:00 -0400319 if (vwrq->disabled)
320 val = MRVDRV_FRAG_MAX_VALUE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200321
Dan Williams39fcf7a2008-09-10 12:49:00 -0400322 if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
323 return -EINVAL;
324
325 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
Holger Schurig9012b282007-05-25 11:27:16 -0400326
327 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200328 return ret;
329}
330
Holger Schurig10078322007-11-15 18:05:47 -0500331static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200332 struct iw_param *vwrq, char *extra)
333{
Kiran Divekarab65f642009-02-19 19:32:39 -0500334 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400335 int ret = 0;
336 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200337
Holger Schurig9012b282007-05-25 11:27:16 -0400338 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200339
Dan Williams39fcf7a2008-09-10 12:49:00 -0400340 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
Holger Schurig9012b282007-05-25 11:27:16 -0400341 if (ret)
342 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200343
Dan Williams39fcf7a2008-09-10 12:49:00 -0400344 vwrq->value = val;
345 vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
346 || (val > MRVDRV_FRAG_MAX_VALUE));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200347 vwrq->fixed = 1;
348
Holger Schurig9012b282007-05-25 11:27:16 -0400349out:
350 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200351 return ret;
352}
353
Holger Schurig10078322007-11-15 18:05:47 -0500354static int lbs_get_mode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200355 struct iw_request_info *info, u32 * uwrq, char *extra)
356{
Kiran Divekarab65f642009-02-19 19:32:39 -0500357 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200358
Holger Schurig9012b282007-05-25 11:27:16 -0400359 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200360
David Woodhouseaa21c002007-12-08 20:04:36 +0000361 *uwrq = priv->mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200362
Holger Schurig9012b282007-05-25 11:27:16 -0400363 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200364 return 0;
365}
366
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400367static int mesh_wlan_get_mode(struct net_device *dev,
368 struct iw_request_info *info, u32 * uwrq,
369 char *extra)
370{
371 lbs_deb_enter(LBS_DEB_WEXT);
372
Dan Williams39fcf7a2008-09-10 12:49:00 -0400373 *uwrq = IW_MODE_REPEAT;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400374
375 lbs_deb_leave(LBS_DEB_WEXT);
376 return 0;
377}
378
Holger Schurig10078322007-11-15 18:05:47 -0500379static int lbs_get_txpow(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200380 struct iw_request_info *info,
381 struct iw_param *vwrq, char *extra)
382{
Kiran Divekarab65f642009-02-19 19:32:39 -0500383 struct lbs_private *priv = dev->ml_priv;
Dan Williams87c8c722008-08-19 15:15:35 -0400384 s16 curlevel = 0;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400385 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200386
Holger Schurig9012b282007-05-25 11:27:16 -0400387 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200388
Dan Williamsd5db2df2008-08-21 17:51:07 -0400389 if (!priv->radio_on) {
390 lbs_deb_wext("tx power off\n");
391 vwrq->value = 0;
392 vwrq->disabled = 1;
393 goto out;
394 }
395
Dan Williams87c8c722008-08-19 15:15:35 -0400396 ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
Holger Schurig9012b282007-05-25 11:27:16 -0400397 if (ret)
398 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200399
Dan Williams87c8c722008-08-19 15:15:35 -0400400 lbs_deb_wext("tx power level %d dbm\n", curlevel);
Dan Williams87c8c722008-08-19 15:15:35 -0400401 priv->txpower_cur = curlevel;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400402
Dan Williams87c8c722008-08-19 15:15:35 -0400403 vwrq->value = curlevel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200404 vwrq->fixed = 1;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400405 vwrq->disabled = 0;
406 vwrq->flags = IW_TXPOW_DBM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200407
Holger Schurig9012b282007-05-25 11:27:16 -0400408out:
409 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
410 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200411}
412
Holger Schurig10078322007-11-15 18:05:47 -0500413static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200414 struct iw_param *vwrq, char *extra)
415{
Kiran Divekarab65f642009-02-19 19:32:39 -0500416 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400417 int ret = 0;
418 u16 slimit = 0, llimit = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200419
Holger Schurig9012b282007-05-25 11:27:16 -0400420 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200421
Dan Williams39fcf7a2008-09-10 12:49:00 -0400422 if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
423 return -EOPNOTSUPP;
424
425 /* The MAC has a 4-bit Total_Tx_Count register
426 Total_Tx_Count = 1 + Tx_Retry_Count */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200427#define TX_RETRY_MIN 0
428#define TX_RETRY_MAX 14
Dan Williams39fcf7a2008-09-10 12:49:00 -0400429 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
430 return -EINVAL;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200431
Dan Williams39fcf7a2008-09-10 12:49:00 -0400432 /* Add 1 to convert retry count to try count */
433 if (vwrq->flags & IW_RETRY_SHORT)
434 slimit = (u16) (vwrq->value + 1);
435 else if (vwrq->flags & IW_RETRY_LONG)
436 llimit = (u16) (vwrq->value + 1);
437 else
438 slimit = llimit = (u16) (vwrq->value + 1); /* set both */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200439
Dan Williams39fcf7a2008-09-10 12:49:00 -0400440 if (llimit) {
441 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
442 llimit);
Holger Schurig9012b282007-05-25 11:27:16 -0400443 if (ret)
444 goto out;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400445 }
446
447 if (slimit) {
448 /* txretrycount follows the short retry limit */
449 priv->txretrycount = slimit;
450 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
451 slimit);
452 if (ret)
453 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200454 }
455
Holger Schurig9012b282007-05-25 11:27:16 -0400456out:
457 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
458 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200459}
460
Holger Schurig10078322007-11-15 18:05:47 -0500461static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200462 struct iw_param *vwrq, char *extra)
463{
Kiran Divekarab65f642009-02-19 19:32:39 -0500464 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200465 int ret = 0;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400466 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200467
Holger Schurig9012b282007-05-25 11:27:16 -0400468 lbs_deb_enter(LBS_DEB_WEXT);
469
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200470 vwrq->disabled = 0;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400471
472 if (vwrq->flags & IW_RETRY_LONG) {
473 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
474 if (ret)
475 goto out;
476
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200477 /* Subtract 1 to convert try count to retry count */
Dan Williams39fcf7a2008-09-10 12:49:00 -0400478 vwrq->value = val - 1;
479 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
480 } else {
481 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
482 if (ret)
483 goto out;
484
485 /* txretry count follows the short retry limit */
486 priv->txretrycount = val;
487 /* Subtract 1 to convert try count to retry count */
488 vwrq->value = val - 1;
489 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200490 }
491
Holger Schurig9012b282007-05-25 11:27:16 -0400492out:
493 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
494 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200495}
496
497static inline void sort_channels(struct iw_freq *freq, int num)
498{
499 int i, j;
500 struct iw_freq temp;
501
502 for (i = 0; i < num; i++)
503 for (j = i + 1; j < num; j++)
504 if (freq[i].i > freq[j].i) {
505 temp.i = freq[i].i;
506 temp.m = freq[i].m;
507
508 freq[i].i = freq[j].i;
509 freq[i].m = freq[j].m;
510
511 freq[j].i = temp.i;
512 freq[j].m = temp.m;
513 }
514}
515
516/* data rate listing
517 MULTI_BANDS:
518 abg a b b/g
519 Infra G(12) A(8) B(4) G(12)
520 Adhoc A+B(12) A(8) B(4) B(4)
521
522 non-MULTI_BANDS:
523 b b/g
524 Infra B(4) G(12)
525 Adhoc B(4) B(4)
526 */
527/**
528 * @brief Get Range Info
529 *
530 * @param dev A pointer to net_device structure
531 * @param info A pointer to iw_request_info structure
532 * @param vwrq A pointer to iw_param structure
533 * @param extra A pointer to extra data buf
534 * @return 0 --success, otherwise fail
535 */
Holger Schurig10078322007-11-15 18:05:47 -0500536static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200537 struct iw_point *dwrq, char *extra)
538{
539 int i, j;
Kiran Divekarab65f642009-02-19 19:32:39 -0500540 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200541 struct iw_range *range = (struct iw_range *)extra;
542 struct chan_freq_power *cfp;
Dan Williams8c512762007-08-02 11:40:45 -0400543 u8 rates[MAX_RATES + 1];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200544
Holger Schurig9012b282007-05-25 11:27:16 -0400545 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200546
547 dwrq->length = sizeof(struct iw_range);
548 memset(range, 0, sizeof(struct iw_range));
549
550 range->min_nwid = 0;
551 range->max_nwid = 0;
552
553 memset(rates, 0, sizeof(rates));
David Woodhouseaa21c002007-12-08 20:04:36 +0000554 copy_active_data_rates(priv, rates);
Dan Williams8c512762007-08-02 11:40:45 -0400555 range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
556 for (i = 0; i < range->num_bitrates; i++)
557 range->bitrate[i] = rates[i] * 500000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200558 range->num_bitrates = i;
Holger Schurig9012b282007-05-25 11:27:16 -0400559 lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200560 range->num_bitrates);
561
562 range->num_frequency = 0;
Holger Schurig52933d82008-03-05 07:05:32 +0100563
564 range->scan_capa = IW_SCAN_CAPA_ESSID;
565
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200566 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
567 && (j < ARRAY_SIZE(priv->region_channel)); j++) {
568 cfp = priv->region_channel[j].CFP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200569 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200570 && priv->region_channel[j].valid
571 && cfp
572 && (i < priv->region_channel[j].nrcfp); i++) {
573 range->freq[range->num_frequency].i =
574 (long)cfp->channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200575 range->freq[range->num_frequency].m =
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200576 (long)cfp->freq * 100000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200577 range->freq[range->num_frequency].e = 1;
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200578 cfp++;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200579 range->num_frequency++;
580 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200581 }
582
Holger Schurig9012b282007-05-25 11:27:16 -0400583 lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200584 IW_MAX_FREQUENCIES, range->num_frequency);
585
586 range->num_channels = range->num_frequency;
587
588 sort_channels(&range->freq[0], range->num_frequency);
589
590 /*
591 * Set an indication of the max TCP throughput in bit/s that we can
592 * expect using this interface
593 */
594 if (i > 2)
595 range->throughput = 5000 * 1000;
596 else
597 range->throughput = 1500 * 1000;
598
599 range->min_rts = MRVDRV_RTS_MIN_VALUE;
600 range->max_rts = MRVDRV_RTS_MAX_VALUE;
601 range->min_frag = MRVDRV_FRAG_MIN_VALUE;
602 range->max_frag = MRVDRV_FRAG_MAX_VALUE;
603
604 range->encoding_size[0] = 5;
605 range->encoding_size[1] = 13;
606 range->num_encoding_sizes = 2;
607 range->max_encoding_tokens = 4;
608
Holger Schurigd4ff0ef2008-03-19 14:25:18 +0100609 /*
610 * Right now we support only "iwconfig ethX power on|off"
611 */
612 range->pm_capa = IW_POWER_ON;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200613
614 /*
615 * Minimum version we recommend
616 */
617 range->we_version_source = 15;
618
619 /*
620 * Version we are compiled with
621 */
622 range->we_version_compiled = WIRELESS_EXT;
623
624 range->retry_capa = IW_RETRY_LIMIT;
625 range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
626
627 range->min_retry = TX_RETRY_MIN;
628 range->max_retry = TX_RETRY_MAX;
629
630 /*
631 * Set the qual, level and noise range values
632 */
633 range->max_qual.qual = 100;
634 range->max_qual.level = 0;
635 range->max_qual.noise = 0;
636 range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
637
638 range->avg_qual.qual = 70;
639 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
640 range->avg_qual.level = 0;
641 range->avg_qual.noise = 0;
642 range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
643
644 range->sensitivity = 0;
645
Dan Williams87c8c722008-08-19 15:15:35 -0400646 /* Setup the supported power level ranges */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200647 memset(range->txpower, 0, sizeof(range->txpower));
Dan Williams87c8c722008-08-19 15:15:35 -0400648 range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE;
649 range->txpower[0] = priv->txpower_min;
650 range->txpower[1] = priv->txpower_max;
651 range->num_txpower = 2;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200652
653 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
654 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
655 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
656 range->event_capa[1] = IW_EVENT_CAPA_K_1;
657
David Woodhouseaa21c002007-12-08 20:04:36 +0000658 if (priv->fwcapinfo & FW_CAPINFO_WPA) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200659 range->enc_capa = IW_ENC_CAPA_WPA
660 | IW_ENC_CAPA_WPA2
661 | IW_ENC_CAPA_CIPHER_TKIP
662 | IW_ENC_CAPA_CIPHER_CCMP;
663 }
664
Holger Schurig9012b282007-05-25 11:27:16 -0400665 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200666 return 0;
667}
668
Holger Schurig10078322007-11-15 18:05:47 -0500669static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200670 struct iw_param *vwrq, char *extra)
671{
Kiran Divekarab65f642009-02-19 19:32:39 -0500672 struct lbs_private *priv = dev->ml_priv;
Amitkumar Karwar49125452009-09-30 20:04:38 -0700673 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200674
Holger Schurig9012b282007-05-25 11:27:16 -0400675 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200676
Andrey Yurovskye0d61332009-06-16 13:20:01 -0700677 if (!(priv->fwcapinfo & FW_CAPINFO_PS)) {
David Woodhouseb2c57ee2007-12-17 14:41:13 -0500678 if (vwrq->disabled)
679 return 0;
680 else
681 return -EINVAL;
682 }
683
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200684 /* PS is currently supported only in Infrastructure mode
685 * Remove this check if it is to be supported in IBSS mode also
686 */
687
688 if (vwrq->disabled) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000689 priv->psmode = LBS802_11POWERMODECAM;
690 if (priv->psstate != PS_STATE_FULL_POWER) {
Holger Schurig10078322007-11-15 18:05:47 -0500691 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200692 }
693
694 return 0;
695 }
696
697 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
Holger Schurig9012b282007-05-25 11:27:16 -0400698 lbs_deb_wext(
699 "setting power timeout is not supported\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200700 return -EINVAL;
701 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
Amitkumar Karwar49125452009-09-30 20:04:38 -0700702 vwrq->value = vwrq->value / 1000;
703 if (!priv->enter_deep_sleep) {
704 lbs_pr_err("deep sleep feature is not implemented "
705 "for this interface driver\n");
706 return -EINVAL;
707 }
708
709 if (priv->connect_status == LBS_CONNECTED) {
710 if ((priv->is_auto_deep_sleep_enabled) &&
711 (vwrq->value == -1000)) {
712 lbs_exit_auto_deep_sleep(priv);
713 return 0;
714 } else {
715 lbs_pr_err("can't use deep sleep cmd in "
716 "connected state\n");
717 return -EINVAL;
718 }
719 }
720
721 if ((vwrq->value < 0) && (vwrq->value != -1000)) {
722 lbs_pr_err("unknown option\n");
723 return -EINVAL;
724 }
725
726 if (vwrq->value > 0) {
727 if (!priv->is_auto_deep_sleep_enabled) {
728 priv->is_activity_detected = 0;
729 priv->auto_deep_sleep_timeout = vwrq->value;
730 lbs_enter_auto_deep_sleep(priv);
731 } else {
732 priv->auto_deep_sleep_timeout = vwrq->value;
733 lbs_deb_debugfs("auto deep sleep: "
734 "already enabled\n");
735 }
736 return 0;
737 } else {
738 if (priv->is_auto_deep_sleep_enabled) {
739 lbs_exit_auto_deep_sleep(priv);
740 /* Try to exit deep sleep if auto */
741 /*deep sleep disabled */
742 ret = lbs_set_deep_sleep(priv, 0);
743 }
744 if (vwrq->value == 0)
745 ret = lbs_set_deep_sleep(priv, 1);
746 else if (vwrq->value == -1000)
747 ret = lbs_set_deep_sleep(priv, 0);
748 return ret;
749 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200750 }
751
David Woodhouseaa21c002007-12-08 20:04:36 +0000752 if (priv->psmode != LBS802_11POWERMODECAM) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200753 return 0;
754 }
755
David Woodhouseaa21c002007-12-08 20:04:36 +0000756 priv->psmode = LBS802_11POWERMODEMAX_PSP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200757
David Woodhouseaa21c002007-12-08 20:04:36 +0000758 if (priv->connect_status == LBS_CONNECTED) {
Holger Schurig10078322007-11-15 18:05:47 -0500759 lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200760 }
761
Holger Schurig9012b282007-05-25 11:27:16 -0400762 lbs_deb_leave(LBS_DEB_WEXT);
Amitkumar Karwar49125452009-09-30 20:04:38 -0700763
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200764 return 0;
765}
766
Holger Schurig10078322007-11-15 18:05:47 -0500767static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200768 struct iw_param *vwrq, char *extra)
769{
Kiran Divekarab65f642009-02-19 19:32:39 -0500770 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200771
Holger Schurig9012b282007-05-25 11:27:16 -0400772 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200773
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200774 vwrq->value = 0;
Holger Schurigd4ff0ef2008-03-19 14:25:18 +0100775 vwrq->flags = 0;
776 vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM
777 || priv->connect_status == LBS_DISCONNECTED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200778
Holger Schurig9012b282007-05-25 11:27:16 -0400779 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200780 return 0;
781}
782
Holger Schurig10078322007-11-15 18:05:47 -0500783static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200784{
785 enum {
786 POOR = 30,
787 FAIR = 60,
788 GOOD = 80,
789 VERY_GOOD = 90,
790 EXCELLENT = 95,
791 PERFECT = 100
792 };
Kiran Divekarab65f642009-02-19 19:32:39 -0500793 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200794 u32 rssi_qual;
795 u32 tx_qual;
796 u32 quality = 0;
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700797 int ret, stats_valid = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200798 u8 rssi;
799 u32 tx_retries;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100800 struct cmd_ds_802_11_get_log log;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200801
Holger Schurig9012b282007-05-25 11:27:16 -0400802 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200803
David Woodhouseaa21c002007-12-08 20:04:36 +0000804 priv->wstats.status = priv->mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200805
806 /* If we're not associated, all quality values are meaningless */
David Woodhouseaa21c002007-12-08 20:04:36 +0000807 if ((priv->connect_status != LBS_CONNECTED) &&
808 (priv->mesh_connect_status != LBS_CONNECTED))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200809 goto out;
810
811 /* Quality by RSSI */
812 priv->wstats.qual.level =
David Woodhouseaa21c002007-12-08 20:04:36 +0000813 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
814 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200815
David Woodhouseaa21c002007-12-08 20:04:36 +0000816 if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200817 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
818 } else {
819 priv->wstats.qual.noise =
David Woodhouseaa21c002007-12-08 20:04:36 +0000820 CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200821 }
822
Holger Schurig9012b282007-05-25 11:27:16 -0400823 lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
824 lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200825
826 rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
827 if (rssi < 15)
828 rssi_qual = rssi * POOR / 10;
829 else if (rssi < 20)
830 rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
831 else if (rssi < 30)
832 rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
833 else if (rssi < 40)
834 rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
835 10 + GOOD;
836 else
837 rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
838 10 + VERY_GOOD;
839 quality = rssi_qual;
840
841 /* Quality by TX errors */
Stephen Hemmingerbbfc6b72009-03-20 19:36:36 +0000842 priv->wstats.discard.retries = dev->stats.tx_errors;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200843
Holger Schurigc49c3b72008-03-17 12:45:58 +0100844 memset(&log, 0, sizeof(log));
845 log.hdr.size = cpu_to_le16(sizeof(log));
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700846 ret = lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
847 if (ret)
848 goto out;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100849
850 tx_retries = le32_to_cpu(log.retry);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200851
852 if (tx_retries > 75)
853 tx_qual = (90 - tx_retries) * POOR / 15;
854 else if (tx_retries > 70)
855 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
856 else if (tx_retries > 65)
857 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
858 else if (tx_retries > 50)
859 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
860 15 + GOOD;
861 else
862 tx_qual = (50 - tx_retries) *
863 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
864 quality = min(quality, tx_qual);
865
Holger Schurigc49c3b72008-03-17 12:45:58 +0100866 priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200867 priv->wstats.discard.retries = tx_retries;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100868 priv->wstats.discard.misc = le32_to_cpu(log.ackfailure);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200869
870 /* Calculate quality */
Holger Schurigcad9d9b2007-08-02 13:07:15 -0400871 priv->wstats.qual.qual = min_t(u8, quality, 100);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200872 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
873 stats_valid = 1;
874
875 /* update stats asynchronously for future calls */
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700876 ret = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200877 0, 0, NULL);
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700878 if (ret)
879 lbs_pr_err("RSSI command failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200880out:
881 if (!stats_valid) {
882 priv->wstats.miss.beacon = 0;
883 priv->wstats.discard.retries = 0;
884 priv->wstats.qual.qual = 0;
885 priv->wstats.qual.level = 0;
886 priv->wstats.qual.noise = 0;
887 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
888 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
889 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
890 }
891
Holger Schurig9012b282007-05-25 11:27:16 -0400892 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200893 return &priv->wstats;
894
895
896}
897
Holger Schurig10078322007-11-15 18:05:47 -0500898static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200899 struct iw_freq *fwrq, char *extra)
900{
Dan Williamsef9a2642007-05-25 16:46:33 -0400901 int ret = -EINVAL;
Kiran Divekarab65f642009-02-19 19:32:39 -0500902 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200903 struct chan_freq_power *cfp;
Dan Williamsef9a2642007-05-25 16:46:33 -0400904 struct assoc_request * assoc_req;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200905
Holger Schurig9012b282007-05-25 11:27:16 -0400906 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200907
David Woodhouseaa21c002007-12-08 20:04:36 +0000908 mutex_lock(&priv->lock);
909 assoc_req = lbs_get_association_request(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400910 if (!assoc_req) {
911 ret = -ENOMEM;
912 goto out;
913 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200914
Dan Williamsef9a2642007-05-25 16:46:33 -0400915 /* If setting by frequency, convert to a channel */
916 if (fwrq->e == 1) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200917 long f = fwrq->m / 100000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200918
David Woodhouseaa21c002007-12-08 20:04:36 +0000919 cfp = find_cfp_by_band_and_freq(priv, 0, f);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200920 if (!cfp) {
Holger Schurig9012b282007-05-25 11:27:16 -0400921 lbs_deb_wext("invalid freq %ld\n", f);
Dan Williamsef9a2642007-05-25 16:46:33 -0400922 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200923 }
924
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200925 fwrq->e = 0;
Dan Williamsef9a2642007-05-25 16:46:33 -0400926 fwrq->m = (int) cfp->channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200927 }
928
Dan Williamsef9a2642007-05-25 16:46:33 -0400929 /* Setting by channel number */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200930 if (fwrq->m > 1000 || fwrq->e > 0) {
Dan Williamsef9a2642007-05-25 16:46:33 -0400931 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200932 }
933
David Woodhouseaa21c002007-12-08 20:04:36 +0000934 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
Dan Williamsef9a2642007-05-25 16:46:33 -0400935 if (!cfp) {
936 goto out;
937 }
938
939 assoc_req->channel = fwrq->m;
940 ret = 0;
941
Holger Schurig9012b282007-05-25 11:27:16 -0400942out:
Dan Williamsef9a2642007-05-25 16:46:33 -0400943 if (ret == 0) {
944 set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -0500945 lbs_postpone_association_work(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400946 } else {
Holger Schurig10078322007-11-15 18:05:47 -0500947 lbs_cancel_association_work(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400948 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000949 mutex_unlock(&priv->lock);
Dan Williamsef9a2642007-05-25 16:46:33 -0400950
951 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
952 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200953}
954
David Woodhouse823eaa22007-12-11 19:56:28 -0500955static int lbs_mesh_set_freq(struct net_device *dev,
956 struct iw_request_info *info,
957 struct iw_freq *fwrq, char *extra)
958{
Kiran Divekarab65f642009-02-19 19:32:39 -0500959 struct lbs_private *priv = dev->ml_priv;
David Woodhouse823eaa22007-12-11 19:56:28 -0500960 struct chan_freq_power *cfp;
961 int ret = -EINVAL;
962
963 lbs_deb_enter(LBS_DEB_WEXT);
964
965 /* If setting by frequency, convert to a channel */
966 if (fwrq->e == 1) {
967 long f = fwrq->m / 100000;
968
969 cfp = find_cfp_by_band_and_freq(priv, 0, f);
970 if (!cfp) {
971 lbs_deb_wext("invalid freq %ld\n", f);
972 goto out;
973 }
974
975 fwrq->e = 0;
976 fwrq->m = (int) cfp->channel;
977 }
978
979 /* Setting by channel number */
980 if (fwrq->m > 1000 || fwrq->e > 0) {
981 goto out;
982 }
983
984 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
985 if (!cfp) {
986 goto out;
987 }
988
Holger Schurigc14951f2009-10-22 15:30:50 +0200989 if (fwrq->m != priv->channel) {
David Woodhouse823eaa22007-12-11 19:56:28 -0500990 lbs_deb_wext("mesh channel change forces eth disconnect\n");
991 if (priv->mode == IW_MODE_INFRA)
Dan Williams191bb402008-08-21 17:46:18 -0400992 lbs_cmd_80211_deauthenticate(priv,
993 priv->curbssparams.bssid,
994 WLAN_REASON_DEAUTH_LEAVING);
David Woodhouse823eaa22007-12-11 19:56:28 -0500995 else if (priv->mode == IW_MODE_ADHOC)
Dan Williamsf5fe1fd2008-08-21 21:46:59 -0400996 lbs_adhoc_stop(priv);
David Woodhouse823eaa22007-12-11 19:56:28 -0500997 }
Javier Cardonaedaea5c2008-05-17 00:55:10 -0700998 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m);
David Woodhouse86062132007-12-13 00:32:36 -0500999 lbs_update_channel(priv);
David Woodhouse823eaa22007-12-11 19:56:28 -05001000 ret = 0;
1001
1002out:
1003 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1004 return ret;
1005}
1006
Holger Schurig10078322007-11-15 18:05:47 -05001007static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001008 struct iw_param *vwrq, char *extra)
1009{
Kiran Divekarab65f642009-02-19 19:32:39 -05001010 struct lbs_private *priv = dev->ml_priv;
Dan Williams8e3c91b2007-12-11 15:50:59 -05001011 u8 new_rate = 0;
Dan Williams8c512762007-08-02 11:40:45 -04001012 int ret = -EINVAL;
1013 u8 rates[MAX_RATES + 1];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001014
Holger Schurig9012b282007-05-25 11:27:16 -04001015 lbs_deb_enter(LBS_DEB_WEXT);
Amitkumar Karwar49125452009-09-30 20:04:38 -07001016
Holger Schurig9012b282007-05-25 11:27:16 -04001017 lbs_deb_wext("vwrq->value %d\n", vwrq->value);
Javier Cardona85319f92008-05-24 10:59:49 +01001018 lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed);
1019
1020 if (vwrq->fixed && vwrq->value == -1)
1021 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001022
Dan Williams8c512762007-08-02 11:40:45 -04001023 /* Auto rate? */
Javier Cardona85319f92008-05-24 10:59:49 +01001024 priv->enablehwauto = !vwrq->fixed;
1025
1026 if (vwrq->value == -1)
David Woodhouseaa21c002007-12-08 20:04:36 +00001027 priv->cur_rate = 0;
Javier Cardona85319f92008-05-24 10:59:49 +01001028 else {
Dan Williams8c512762007-08-02 11:40:45 -04001029 if (vwrq->value % 100000)
1030 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001031
Javier Cardona85319f92008-05-24 10:59:49 +01001032 new_rate = vwrq->value / 500000;
1033 priv->cur_rate = new_rate;
1034 /* the rest is only needed for lbs_set_data_rate() */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001035 memset(rates, 0, sizeof(rates));
David Woodhouseaa21c002007-12-08 20:04:36 +00001036 copy_active_data_rates(priv, rates);
Dan Williams8c512762007-08-02 11:40:45 -04001037 if (!memchr(rates, new_rate, sizeof(rates))) {
1038 lbs_pr_alert("fixed data rate 0x%X out of range\n",
1039 new_rate);
1040 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001041 }
Anna Neal3ed6e082008-09-26 11:34:35 -04001042 if (priv->fwrelease < 0x09000000) {
1043 ret = lbs_set_power_adapt_cfg(priv, 0,
1044 POW_ADAPT_DEFAULT_P0,
1045 POW_ADAPT_DEFAULT_P1,
1046 POW_ADAPT_DEFAULT_P2);
1047 if (ret)
1048 goto out;
1049 }
1050 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1051 TPC_DEFAULT_P2, 1);
1052 if (ret)
1053 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001054 }
1055
Javier Cardona85319f92008-05-24 10:59:49 +01001056 /* Try the newer command first (Firmware Spec 5.1 and above) */
1057 ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET);
1058
1059 /* Fallback to older version */
1060 if (ret)
1061 ret = lbs_set_data_rate(priv, new_rate);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001062
Dan Williams8c512762007-08-02 11:40:45 -04001063out:
Holger Schurig9012b282007-05-25 11:27:16 -04001064 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001065 return ret;
1066}
1067
Holger Schurig10078322007-11-15 18:05:47 -05001068static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001069 struct iw_param *vwrq, char *extra)
1070{
Kiran Divekarab65f642009-02-19 19:32:39 -05001071 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001072
Holger Schurig9012b282007-05-25 11:27:16 -04001073 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001074
David Woodhouseaa21c002007-12-08 20:04:36 +00001075 if (priv->connect_status == LBS_CONNECTED) {
1076 vwrq->value = priv->cur_rate * 500000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001077
Javier Cardona85319f92008-05-24 10:59:49 +01001078 if (priv->enablehwauto)
Dan Williams8c512762007-08-02 11:40:45 -04001079 vwrq->fixed = 0;
1080 else
1081 vwrq->fixed = 1;
1082
1083 } else {
1084 vwrq->fixed = 0;
1085 vwrq->value = 0;
1086 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001087
Holger Schurig9012b282007-05-25 11:27:16 -04001088 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001089 return 0;
1090}
1091
Holger Schurig10078322007-11-15 18:05:47 -05001092static int lbs_set_mode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001093 struct iw_request_info *info, u32 * uwrq, char *extra)
1094{
1095 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001096 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001097 struct assoc_request * assoc_req;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001098
Holger Schurig9012b282007-05-25 11:27:16 -04001099 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001100
Dan Williams0dc5a292007-05-10 22:58:02 -04001101 if ( (*uwrq != IW_MODE_ADHOC)
1102 && (*uwrq != IW_MODE_INFRA)
1103 && (*uwrq != IW_MODE_AUTO)) {
Holger Schurig9012b282007-05-25 11:27:16 -04001104 lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq);
Dan Williams0dc5a292007-05-10 22:58:02 -04001105 ret = -EINVAL;
1106 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001107 }
1108
David Woodhouseaa21c002007-12-08 20:04:36 +00001109 mutex_lock(&priv->lock);
1110 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001111 if (!assoc_req) {
1112 ret = -ENOMEM;
Holger Schurig10078322007-11-15 18:05:47 -05001113 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001114 } else {
Dan Williams0dc5a292007-05-10 22:58:02 -04001115 assoc_req->mode = *uwrq;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001116 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001117 lbs_postpone_association_work(priv);
Holger Schurig9012b282007-05-25 11:27:16 -04001118 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001119 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001120 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001121
Dan Williams0dc5a292007-05-10 22:58:02 -04001122out:
Holger Schurig9012b282007-05-25 11:27:16 -04001123 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001124 return ret;
1125}
1126
1127
1128/**
1129 * @brief Get Encryption key
1130 *
1131 * @param dev A pointer to net_device structure
1132 * @param info A pointer to iw_request_info structure
1133 * @param vwrq A pointer to iw_param structure
1134 * @param extra A pointer to extra data buf
1135 * @return 0 --success, otherwise fail
1136 */
Holger Schurig10078322007-11-15 18:05:47 -05001137static int lbs_get_encode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001138 struct iw_request_info *info,
1139 struct iw_point *dwrq, u8 * extra)
1140{
Kiran Divekarab65f642009-02-19 19:32:39 -05001141 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001142 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1143
Holger Schurig9012b282007-05-25 11:27:16 -04001144 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001145
Holger Schurig9012b282007-05-25 11:27:16 -04001146 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +00001147 dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001148
1149 dwrq->flags = 0;
1150
1151 /* Authentication method */
David Woodhouseaa21c002007-12-08 20:04:36 +00001152 switch (priv->secinfo.auth_mode) {
Dan Williams6affe782007-05-10 22:56:42 -04001153 case IW_AUTH_ALG_OPEN_SYSTEM:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001154 dwrq->flags = IW_ENCODE_OPEN;
1155 break;
1156
Dan Williams6affe782007-05-10 22:56:42 -04001157 case IW_AUTH_ALG_SHARED_KEY:
1158 case IW_AUTH_ALG_LEAP:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001159 dwrq->flags = IW_ENCODE_RESTRICTED;
1160 break;
1161 default:
1162 dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
1163 break;
1164 }
1165
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001166 memset(extra, 0, 16);
1167
David Woodhouseaa21c002007-12-08 20:04:36 +00001168 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001169
1170 /* Default to returning current transmit key */
1171 if (index < 0)
David Woodhouseaa21c002007-12-08 20:04:36 +00001172 index = priv->wep_tx_keyidx;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001173
David Woodhouseaa21c002007-12-08 20:04:36 +00001174 if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
1175 memcpy(extra, priv->wep_keys[index].key,
1176 priv->wep_keys[index].len);
1177 dwrq->length = priv->wep_keys[index].len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001178
1179 dwrq->flags |= (index + 1);
1180 /* Return WEP enabled */
1181 dwrq->flags &= ~IW_ENCODE_DISABLED;
David Woodhouseaa21c002007-12-08 20:04:36 +00001182 } else if ((priv->secinfo.WPAenabled)
1183 || (priv->secinfo.WPA2enabled)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001184 /* return WPA enabled */
1185 dwrq->flags &= ~IW_ENCODE_DISABLED;
David Woodhousec12bdc42007-12-07 19:32:12 +00001186 dwrq->flags |= IW_ENCODE_NOKEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001187 } else {
1188 dwrq->flags |= IW_ENCODE_DISABLED;
1189 }
1190
David Woodhouseaa21c002007-12-08 20:04:36 +00001191 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001192
Joe Perches0795af52007-10-03 17:59:30 -07001193 lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001194 extra[0], extra[1], extra[2],
1195 extra[3], extra[4], extra[5], dwrq->length);
1196
Holger Schurig9012b282007-05-25 11:27:16 -04001197 lbs_deb_wext("return flags 0x%x\n", dwrq->flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001198
Holger Schurig9012b282007-05-25 11:27:16 -04001199 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001200 return 0;
1201}
1202
1203/**
1204 * @brief Set Encryption key (internal)
1205 *
1206 * @param priv A pointer to private card structure
1207 * @param key_material A pointer to key material
1208 * @param key_length length of key material
1209 * @param index key index to set
1210 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1211 * @return 0 --success, otherwise fail
1212 */
Holger Schurig10078322007-11-15 18:05:47 -05001213static int lbs_set_wep_key(struct assoc_request *assoc_req,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001214 const char *key_material,
1215 u16 key_length,
1216 u16 index,
1217 int set_tx_key)
1218{
Holger Schurig9012b282007-05-25 11:27:16 -04001219 int ret = 0;
Dan Williams1443b652007-08-02 10:45:55 -04001220 struct enc_key *pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001221
Holger Schurig9012b282007-05-25 11:27:16 -04001222 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001223
1224 /* Paranoid validation of key index */
1225 if (index > 3) {
Holger Schurig9012b282007-05-25 11:27:16 -04001226 ret = -EINVAL;
1227 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001228 }
1229
1230 /* validate max key length */
1231 if (key_length > KEY_LEN_WEP_104) {
Holger Schurig9012b282007-05-25 11:27:16 -04001232 ret = -EINVAL;
1233 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001234 }
1235
1236 pkey = &assoc_req->wep_keys[index];
1237
1238 if (key_length > 0) {
Dan Williams1443b652007-08-02 10:45:55 -04001239 memset(pkey, 0, sizeof(struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001240 pkey->type = KEY_TYPE_ID_WEP;
1241
1242 /* Standardize the key length */
1243 pkey->len = (key_length > KEY_LEN_WEP_40) ?
1244 KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
1245 memcpy(pkey->key, key_material, key_length);
1246 }
1247
1248 if (set_tx_key) {
1249 /* Ensure the chosen key is valid */
1250 if (!pkey->len) {
Holger Schurig9012b282007-05-25 11:27:16 -04001251 lbs_deb_wext("key not set, so cannot enable it\n");
1252 ret = -EINVAL;
1253 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001254 }
1255 assoc_req->wep_tx_keyidx = index;
1256 }
1257
Dan Williams889c05b2007-05-10 22:57:23 -04001258 assoc_req->secinfo.wep_enabled = 1;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001259
Holger Schurig9012b282007-05-25 11:27:16 -04001260out:
1261 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1262 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001263}
1264
1265static int validate_key_index(u16 def_index, u16 raw_index,
1266 u16 *out_index, u16 *is_default)
1267{
1268 if (!out_index || !is_default)
1269 return -EINVAL;
1270
1271 /* Verify index if present, otherwise use default TX key index */
1272 if (raw_index > 0) {
1273 if (raw_index > 4)
1274 return -EINVAL;
1275 *out_index = raw_index - 1;
1276 } else {
1277 *out_index = def_index;
1278 *is_default = 1;
1279 }
1280 return 0;
1281}
1282
1283static void disable_wep(struct assoc_request *assoc_req)
1284{
1285 int i;
1286
Dan Williams90a42212007-05-25 23:01:24 -04001287 lbs_deb_enter(LBS_DEB_WEXT);
1288
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001289 /* Set Open System auth mode */
Dan Williams6affe782007-05-10 22:56:42 -04001290 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001291
1292 /* Clear WEP keys and mark WEP as disabled */
Dan Williams889c05b2007-05-10 22:57:23 -04001293 assoc_req->secinfo.wep_enabled = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001294 for (i = 0; i < 4; i++)
1295 assoc_req->wep_keys[i].len = 0;
1296
1297 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1298 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
Dan Williams90a42212007-05-25 23:01:24 -04001299
1300 lbs_deb_leave(LBS_DEB_WEXT);
1301}
1302
1303static void disable_wpa(struct assoc_request *assoc_req)
1304{
1305 lbs_deb_enter(LBS_DEB_WEXT);
1306
Dan Williams1443b652007-08-02 10:45:55 -04001307 memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key));
Dan Williams90a42212007-05-25 23:01:24 -04001308 assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
1309 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1310
Dan Williams1443b652007-08-02 10:45:55 -04001311 memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key));
Dan Williams90a42212007-05-25 23:01:24 -04001312 assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
1313 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1314
1315 assoc_req->secinfo.WPAenabled = 0;
1316 assoc_req->secinfo.WPA2enabled = 0;
1317 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1318
1319 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001320}
1321
1322/**
1323 * @brief Set Encryption key
1324 *
1325 * @param dev A pointer to net_device structure
1326 * @param info A pointer to iw_request_info structure
1327 * @param vwrq A pointer to iw_param structure
1328 * @param extra A pointer to extra data buf
1329 * @return 0 --success, otherwise fail
1330 */
Holger Schurig10078322007-11-15 18:05:47 -05001331static int lbs_set_encode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001332 struct iw_request_info *info,
1333 struct iw_point *dwrq, char *extra)
1334{
1335 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001336 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001337 struct assoc_request * assoc_req;
1338 u16 is_default = 0, index = 0, set_tx_key = 0;
1339
Holger Schurig9012b282007-05-25 11:27:16 -04001340 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001341
David Woodhouseaa21c002007-12-08 20:04:36 +00001342 mutex_lock(&priv->lock);
1343 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001344 if (!assoc_req) {
1345 ret = -ENOMEM;
1346 goto out;
1347 }
1348
1349 if (dwrq->flags & IW_ENCODE_DISABLED) {
1350 disable_wep (assoc_req);
Dan Williams90a42212007-05-25 23:01:24 -04001351 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001352 goto out;
1353 }
1354
1355 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1356 (dwrq->flags & IW_ENCODE_INDEX),
1357 &index, &is_default);
1358 if (ret) {
1359 ret = -EINVAL;
1360 goto out;
1361 }
1362
1363 /* If WEP isn't enabled, or if there is no key data but a valid
1364 * index, set the TX key.
1365 */
Dan Williams889c05b2007-05-10 22:57:23 -04001366 if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001367 set_tx_key = 1;
1368
Holger Schurig10078322007-11-15 18:05:47 -05001369 ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001370 if (ret)
1371 goto out;
1372
1373 if (dwrq->length)
1374 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1375 if (set_tx_key)
1376 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1377
1378 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
Dan Williams6affe782007-05-10 22:56:42 -04001379 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001380 } else if (dwrq->flags & IW_ENCODE_OPEN) {
Dan Williams6affe782007-05-10 22:56:42 -04001381 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001382 }
1383
1384out:
1385 if (ret == 0) {
1386 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001387 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001388 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001389 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001390 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001391 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001392
Holger Schurig9012b282007-05-25 11:27:16 -04001393 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001394 return ret;
1395}
1396
1397/**
1398 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
1399 *
1400 * @param dev A pointer to net_device structure
1401 * @param info A pointer to iw_request_info structure
1402 * @param vwrq A pointer to iw_param structure
1403 * @param extra A pointer to extra data buf
1404 * @return 0 on success, otherwise failure
1405 */
Holger Schurig10078322007-11-15 18:05:47 -05001406static int lbs_get_encodeext(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001407 struct iw_request_info *info,
1408 struct iw_point *dwrq,
1409 char *extra)
1410{
1411 int ret = -EINVAL;
Kiran Divekarab65f642009-02-19 19:32:39 -05001412 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001413 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1414 int index, max_key_len;
1415
Holger Schurig9012b282007-05-25 11:27:16 -04001416 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001417
1418 max_key_len = dwrq->length - sizeof(*ext);
1419 if (max_key_len < 0)
1420 goto out;
1421
1422 index = dwrq->flags & IW_ENCODE_INDEX;
1423 if (index) {
1424 if (index < 1 || index > 4)
1425 goto out;
1426 index--;
1427 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +00001428 index = priv->wep_tx_keyidx;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001429 }
1430
Roel Kluinf59d9782007-10-26 21:51:26 +02001431 if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001432 ext->alg != IW_ENCODE_ALG_WEP) {
David Woodhouseaa21c002007-12-08 20:04:36 +00001433 if (index != 0 || priv->mode != IW_MODE_INFRA)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001434 goto out;
1435 }
1436
1437 dwrq->flags = index + 1;
1438 memset(ext, 0, sizeof(*ext));
1439
David Woodhouseaa21c002007-12-08 20:04:36 +00001440 if ( !priv->secinfo.wep_enabled
1441 && !priv->secinfo.WPAenabled
1442 && !priv->secinfo.WPA2enabled) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001443 ext->alg = IW_ENCODE_ALG_NONE;
1444 ext->key_len = 0;
1445 dwrq->flags |= IW_ENCODE_DISABLED;
1446 } else {
1447 u8 *key = NULL;
1448
David Woodhouseaa21c002007-12-08 20:04:36 +00001449 if ( priv->secinfo.wep_enabled
1450 && !priv->secinfo.WPAenabled
1451 && !priv->secinfo.WPA2enabled) {
Dan Williams90a42212007-05-25 23:01:24 -04001452 /* WEP */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001453 ext->alg = IW_ENCODE_ALG_WEP;
David Woodhouseaa21c002007-12-08 20:04:36 +00001454 ext->key_len = priv->wep_keys[index].len;
1455 key = &priv->wep_keys[index].key[0];
1456 } else if ( !priv->secinfo.wep_enabled
1457 && (priv->secinfo.WPAenabled ||
1458 priv->secinfo.WPA2enabled)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001459 /* WPA */
Dan Williams1443b652007-08-02 10:45:55 -04001460 struct enc_key * pkey = NULL;
Dan Williams90a42212007-05-25 23:01:24 -04001461
David Woodhouseaa21c002007-12-08 20:04:36 +00001462 if ( priv->wpa_mcast_key.len
1463 && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
1464 pkey = &priv->wpa_mcast_key;
1465 else if ( priv->wpa_unicast_key.len
1466 && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
1467 pkey = &priv->wpa_unicast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001468
1469 if (pkey) {
1470 if (pkey->type == KEY_TYPE_ID_AES) {
1471 ext->alg = IW_ENCODE_ALG_CCMP;
1472 } else {
1473 ext->alg = IW_ENCODE_ALG_TKIP;
1474 }
1475 ext->key_len = pkey->len;
1476 key = &pkey->key[0];
1477 } else {
1478 ext->alg = IW_ENCODE_ALG_TKIP;
1479 ext->key_len = 0;
1480 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001481 } else {
1482 goto out;
1483 }
1484
1485 if (ext->key_len > max_key_len) {
1486 ret = -E2BIG;
1487 goto out;
1488 }
1489
1490 if (ext->key_len)
1491 memcpy(ext->key, key, ext->key_len);
1492 else
1493 dwrq->flags |= IW_ENCODE_NOKEY;
1494 dwrq->flags |= IW_ENCODE_ENABLED;
1495 }
1496 ret = 0;
1497
1498out:
Holger Schurig9012b282007-05-25 11:27:16 -04001499 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001500 return ret;
1501}
1502
1503/**
1504 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
1505 *
1506 * @param dev A pointer to net_device structure
1507 * @param info A pointer to iw_request_info structure
1508 * @param vwrq A pointer to iw_param structure
1509 * @param extra A pointer to extra data buf
1510 * @return 0 --success, otherwise fail
1511 */
Holger Schurig10078322007-11-15 18:05:47 -05001512static int lbs_set_encodeext(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001513 struct iw_request_info *info,
1514 struct iw_point *dwrq,
1515 char *extra)
1516{
1517 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001518 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001519 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1520 int alg = ext->alg;
1521 struct assoc_request * assoc_req;
1522
Holger Schurig9012b282007-05-25 11:27:16 -04001523 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001524
David Woodhouseaa21c002007-12-08 20:04:36 +00001525 mutex_lock(&priv->lock);
1526 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001527 if (!assoc_req) {
1528 ret = -ENOMEM;
1529 goto out;
1530 }
1531
1532 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
1533 disable_wep (assoc_req);
Dan Williams90a42212007-05-25 23:01:24 -04001534 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001535 } else if (alg == IW_ENCODE_ALG_WEP) {
1536 u16 is_default = 0, index, set_tx_key = 0;
1537
1538 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1539 (dwrq->flags & IW_ENCODE_INDEX),
1540 &index, &is_default);
1541 if (ret)
1542 goto out;
1543
1544 /* If WEP isn't enabled, or if there is no key data but a valid
1545 * index, or if the set-TX-key flag was passed, set the TX key.
1546 */
Dan Williams889c05b2007-05-10 22:57:23 -04001547 if ( !assoc_req->secinfo.wep_enabled
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001548 || (dwrq->length == 0 && !is_default)
1549 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
1550 set_tx_key = 1;
1551
1552 /* Copy key to driver */
Holger Schurig10078322007-11-15 18:05:47 -05001553 ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001554 set_tx_key);
1555 if (ret)
1556 goto out;
1557
1558 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
Dan Williams6affe782007-05-10 22:56:42 -04001559 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001560 } else if (dwrq->flags & IW_ENCODE_OPEN) {
Dan Williams6affe782007-05-10 22:56:42 -04001561 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001562 }
1563
1564 /* Mark the various WEP bits as modified */
1565 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1566 if (dwrq->length)
1567 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1568 if (set_tx_key)
1569 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001570 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
Dan Williams1443b652007-08-02 10:45:55 -04001571 struct enc_key * pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001572
1573 /* validate key length */
1574 if (((alg == IW_ENCODE_ALG_TKIP)
1575 && (ext->key_len != KEY_LEN_WPA_TKIP))
1576 || ((alg == IW_ENCODE_ALG_CCMP)
1577 && (ext->key_len != KEY_LEN_WPA_AES))) {
Joe Perches8376e7a2007-11-19 17:48:27 -08001578 lbs_deb_wext("invalid size %d for key of alg "
Holger Schurig9012b282007-05-25 11:27:16 -04001579 "type %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001580 ext->key_len,
1581 alg);
1582 ret = -EINVAL;
1583 goto out;
1584 }
1585
Dan Williams90a42212007-05-25 23:01:24 -04001586 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001587 pkey = &assoc_req->wpa_mcast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001588 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1589 } else {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001590 pkey = &assoc_req->wpa_unicast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001591 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1592 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001593
Dan Williams1443b652007-08-02 10:45:55 -04001594 memset(pkey, 0, sizeof (struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001595 memcpy(pkey->key, ext->key, ext->key_len);
1596 pkey->len = ext->key_len;
Dan Williams90a42212007-05-25 23:01:24 -04001597 if (pkey->len)
1598 pkey->flags |= KEY_INFO_WPA_ENABLED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001599
Dan Williams90a42212007-05-25 23:01:24 -04001600 /* Do this after zeroing key structure */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001601 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1602 pkey->flags |= KEY_INFO_WPA_MCAST;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001603 } else {
1604 pkey->flags |= KEY_INFO_WPA_UNICAST;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001605 }
1606
Dan Williams90a42212007-05-25 23:01:24 -04001607 if (alg == IW_ENCODE_ALG_TKIP) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001608 pkey->type = KEY_TYPE_ID_TKIP;
Dan Williams90a42212007-05-25 23:01:24 -04001609 } else if (alg == IW_ENCODE_ALG_CCMP) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001610 pkey->type = KEY_TYPE_ID_AES;
Dan Williams90a42212007-05-25 23:01:24 -04001611 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001612
1613 /* If WPA isn't enabled yet, do that now */
1614 if ( assoc_req->secinfo.WPAenabled == 0
1615 && assoc_req->secinfo.WPA2enabled == 0) {
1616 assoc_req->secinfo.WPAenabled = 1;
1617 assoc_req->secinfo.WPA2enabled = 1;
1618 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1619 }
1620
Javier Cardona9c31fd632008-09-11 15:32:50 -07001621 /* Only disable wep if necessary: can't waste time here. */
1622 if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
1623 disable_wep(assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001624 }
1625
1626out:
Javier Cardona9c40fc52008-09-16 18:08:39 -07001627 if (ret == 0) {
1628 /* 802.1x and WPA rekeying must happen as quickly as possible,
1629 * especially during the 4-way handshake; thus if in
1630 * infrastructure mode, and either (a) 802.1x is enabled or
1631 * (b) WPA is being used, set the key right away.
1632 */
1633 if (assoc_req->mode == IW_MODE_INFRA &&
1634 ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
1635 (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
1636 assoc_req->secinfo.WPAenabled ||
1637 assoc_req->secinfo.WPA2enabled)) {
1638 lbs_do_association_work(priv);
1639 } else
1640 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001641 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001642 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001643 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001644 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001645
Holger Schurig9012b282007-05-25 11:27:16 -04001646 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001647 return ret;
1648}
1649
1650
Holger Schurig10078322007-11-15 18:05:47 -05001651static int lbs_set_genie(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001652 struct iw_request_info *info,
1653 struct iw_point *dwrq,
1654 char *extra)
1655{
Kiran Divekarab65f642009-02-19 19:32:39 -05001656 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001657 int ret = 0;
1658 struct assoc_request * assoc_req;
1659
Holger Schurig9012b282007-05-25 11:27:16 -04001660 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001661
David Woodhouseaa21c002007-12-08 20:04:36 +00001662 mutex_lock(&priv->lock);
1663 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001664 if (!assoc_req) {
1665 ret = -ENOMEM;
1666 goto out;
1667 }
1668
1669 if (dwrq->length > MAX_WPA_IE_LEN ||
1670 (dwrq->length && extra == NULL)) {
1671 ret = -EINVAL;
1672 goto out;
1673 }
1674
1675 if (dwrq->length) {
1676 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
1677 assoc_req->wpa_ie_len = dwrq->length;
1678 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +00001679 memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001680 assoc_req->wpa_ie_len = 0;
1681 }
1682
1683out:
1684 if (ret == 0) {
1685 set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001686 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001687 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001688 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001689 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001690 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001691
Holger Schurig9012b282007-05-25 11:27:16 -04001692 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001693 return ret;
1694}
1695
Holger Schurig10078322007-11-15 18:05:47 -05001696static int lbs_get_genie(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001697 struct iw_request_info *info,
1698 struct iw_point *dwrq,
1699 char *extra)
1700{
Holger Schurig9012b282007-05-25 11:27:16 -04001701 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001702 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001703
Holger Schurig9012b282007-05-25 11:27:16 -04001704 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001705
David Woodhouseaa21c002007-12-08 20:04:36 +00001706 if (priv->wpa_ie_len == 0) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001707 dwrq->length = 0;
Holger Schurig9012b282007-05-25 11:27:16 -04001708 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001709 }
1710
David Woodhouseaa21c002007-12-08 20:04:36 +00001711 if (dwrq->length < priv->wpa_ie_len) {
Holger Schurig9012b282007-05-25 11:27:16 -04001712 ret = -E2BIG;
1713 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001714 }
1715
David Woodhouseaa21c002007-12-08 20:04:36 +00001716 dwrq->length = priv->wpa_ie_len;
1717 memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001718
Holger Schurig9012b282007-05-25 11:27:16 -04001719out:
1720 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1721 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001722}
1723
1724
Holger Schurig10078322007-11-15 18:05:47 -05001725static int lbs_set_auth(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001726 struct iw_request_info *info,
1727 struct iw_param *dwrq,
1728 char *extra)
1729{
Kiran Divekarab65f642009-02-19 19:32:39 -05001730 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001731 struct assoc_request * assoc_req;
1732 int ret = 0;
1733 int updated = 0;
1734
Holger Schurig9012b282007-05-25 11:27:16 -04001735 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001736
David Woodhouseaa21c002007-12-08 20:04:36 +00001737 mutex_lock(&priv->lock);
1738 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001739 if (!assoc_req) {
1740 ret = -ENOMEM;
1741 goto out;
1742 }
1743
1744 switch (dwrq->flags & IW_AUTH_INDEX) {
Maithili Hinge2c8d5102009-07-31 20:02:19 -07001745 case IW_AUTH_PRIVACY_INVOKED:
1746 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001747 case IW_AUTH_TKIP_COUNTERMEASURES:
1748 case IW_AUTH_CIPHER_PAIRWISE:
1749 case IW_AUTH_CIPHER_GROUP:
Dan Williams90a42212007-05-25 23:01:24 -04001750 case IW_AUTH_DROP_UNENCRYPTED:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001751 /*
1752 * libertas does not use these parameters
1753 */
1754 break;
1755
Javier Cardona9c40fc52008-09-16 18:08:39 -07001756 case IW_AUTH_KEY_MGMT:
1757 assoc_req->secinfo.key_mgmt = dwrq->value;
1758 updated = 1;
1759 break;
1760
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001761 case IW_AUTH_WPA_VERSION:
1762 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
1763 assoc_req->secinfo.WPAenabled = 0;
1764 assoc_req->secinfo.WPA2enabled = 0;
Dan Williams90a42212007-05-25 23:01:24 -04001765 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001766 }
1767 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
1768 assoc_req->secinfo.WPAenabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001769 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001770 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001771 }
1772 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
1773 assoc_req->secinfo.WPA2enabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001774 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001775 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001776 }
1777 updated = 1;
1778 break;
1779
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001780 case IW_AUTH_80211_AUTH_ALG:
1781 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
Dan Williams6affe782007-05-10 22:56:42 -04001782 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001783 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
Dan Williams6affe782007-05-10 22:56:42 -04001784 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001785 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
Dan Williams6affe782007-05-10 22:56:42 -04001786 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001787 } else {
1788 ret = -EINVAL;
1789 }
1790 updated = 1;
1791 break;
1792
1793 case IW_AUTH_WPA_ENABLED:
1794 if (dwrq->value) {
1795 if (!assoc_req->secinfo.WPAenabled &&
1796 !assoc_req->secinfo.WPA2enabled) {
1797 assoc_req->secinfo.WPAenabled = 1;
1798 assoc_req->secinfo.WPA2enabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001799 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001800 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001801 }
1802 } else {
1803 assoc_req->secinfo.WPAenabled = 0;
1804 assoc_req->secinfo.WPA2enabled = 0;
Dan Williams90a42212007-05-25 23:01:24 -04001805 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001806 }
1807 updated = 1;
1808 break;
1809
1810 default:
1811 ret = -EOPNOTSUPP;
1812 break;
1813 }
1814
1815out:
1816 if (ret == 0) {
1817 if (updated)
1818 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001819 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001820 } else if (ret != -EOPNOTSUPP) {
Holger Schurig10078322007-11-15 18:05:47 -05001821 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001822 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001823 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001824
Holger Schurig9012b282007-05-25 11:27:16 -04001825 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001826 return ret;
1827}
1828
Holger Schurig10078322007-11-15 18:05:47 -05001829static int lbs_get_auth(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001830 struct iw_request_info *info,
1831 struct iw_param *dwrq,
1832 char *extra)
1833{
Holger Schurig9012b282007-05-25 11:27:16 -04001834 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001835 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001836
Holger Schurig9012b282007-05-25 11:27:16 -04001837 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001838
1839 switch (dwrq->flags & IW_AUTH_INDEX) {
Javier Cardona9c40fc52008-09-16 18:08:39 -07001840 case IW_AUTH_KEY_MGMT:
1841 dwrq->value = priv->secinfo.key_mgmt;
1842 break;
1843
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001844 case IW_AUTH_WPA_VERSION:
1845 dwrq->value = 0;
David Woodhouseaa21c002007-12-08 20:04:36 +00001846 if (priv->secinfo.WPAenabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001847 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
David Woodhouseaa21c002007-12-08 20:04:36 +00001848 if (priv->secinfo.WPA2enabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001849 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
1850 if (!dwrq->value)
1851 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
1852 break;
1853
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001854 case IW_AUTH_80211_AUTH_ALG:
David Woodhouseaa21c002007-12-08 20:04:36 +00001855 dwrq->value = priv->secinfo.auth_mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001856 break;
1857
1858 case IW_AUTH_WPA_ENABLED:
David Woodhouseaa21c002007-12-08 20:04:36 +00001859 if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001860 dwrq->value = 1;
1861 break;
1862
1863 default:
Holger Schurig9012b282007-05-25 11:27:16 -04001864 ret = -EOPNOTSUPP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001865 }
1866
Holger Schurig9012b282007-05-25 11:27:16 -04001867 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1868 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001869}
1870
1871
Holger Schurig10078322007-11-15 18:05:47 -05001872static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001873 struct iw_param *vwrq, char *extra)
1874{
1875 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001876 struct lbs_private *priv = dev->ml_priv;
Dan Williams87c8c722008-08-19 15:15:35 -04001877 s16 dbm = (s16) vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001878
Holger Schurig9012b282007-05-25 11:27:16 -04001879 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001880
1881 if (vwrq->disabled) {
Dan Williamsd5db2df2008-08-21 17:51:07 -04001882 lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
Dan Williams87c8c722008-08-19 15:15:35 -04001883 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001884 }
1885
Dan Williams87c8c722008-08-19 15:15:35 -04001886 if (vwrq->fixed == 0) {
Anna Neal0112c9e2008-09-11 11:17:25 -07001887 /* User requests automatic tx power control, however there are
1888 * many auto tx settings. For now use firmware defaults until
1889 * we come up with a good way to expose these to the user. */
1890 if (priv->fwrelease < 0x09000000) {
1891 ret = lbs_set_power_adapt_cfg(priv, 1,
1892 POW_ADAPT_DEFAULT_P0,
1893 POW_ADAPT_DEFAULT_P1,
1894 POW_ADAPT_DEFAULT_P2);
1895 if (ret)
1896 goto out;
1897 }
1898 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1899 TPC_DEFAULT_P2, 1);
1900 if (ret)
1901 goto out;
Dan Williams87c8c722008-08-19 15:15:35 -04001902 dbm = priv->txpower_max;
1903 } else {
1904 /* Userspace check in iwrange if it should use dBm or mW,
1905 * therefore this should never happen... Jean II */
1906 if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
1907 ret = -EOPNOTSUPP;
1908 goto out;
1909 }
1910
Anna Neal0112c9e2008-09-11 11:17:25 -07001911 /* Validate requested power level against firmware allowed
1912 * levels */
Dan Williams87c8c722008-08-19 15:15:35 -04001913 if (priv->txpower_min && (dbm < priv->txpower_min)) {
1914 ret = -EINVAL;
1915 goto out;
1916 }
1917
1918 if (priv->txpower_max && (dbm > priv->txpower_max)) {
1919 ret = -EINVAL;
1920 goto out;
1921 }
Anna Neal0112c9e2008-09-11 11:17:25 -07001922 if (priv->fwrelease < 0x09000000) {
1923 ret = lbs_set_power_adapt_cfg(priv, 0,
1924 POW_ADAPT_DEFAULT_P0,
1925 POW_ADAPT_DEFAULT_P1,
1926 POW_ADAPT_DEFAULT_P2);
1927 if (ret)
1928 goto out;
1929 }
1930 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1931 TPC_DEFAULT_P2, 1);
1932 if (ret)
1933 goto out;
Dan Williams87c8c722008-08-19 15:15:35 -04001934 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001935
Dan Williamsd5db2df2008-08-21 17:51:07 -04001936 /* If the radio was off, turn it on */
1937 if (!priv->radio_on) {
1938 ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
1939 if (ret)
1940 goto out;
1941 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001942
Dan Williams87c8c722008-08-19 15:15:35 -04001943 lbs_deb_wext("txpower set %d dBm\n", dbm);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001944
Dan Williams87c8c722008-08-19 15:15:35 -04001945 ret = lbs_set_tx_power(priv, dbm);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001946
Dan Williams87c8c722008-08-19 15:15:35 -04001947out:
Holger Schurig9012b282007-05-25 11:27:16 -04001948 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001949 return ret;
1950}
1951
Holger Schurig10078322007-11-15 18:05:47 -05001952static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001953 struct iw_point *dwrq, char *extra)
1954{
Kiran Divekarab65f642009-02-19 19:32:39 -05001955 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001956
Holger Schurig9012b282007-05-25 11:27:16 -04001957 lbs_deb_enter(LBS_DEB_WEXT);
1958
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001959 /*
1960 * Note : if dwrq->flags != 0, we should get the relevant SSID from
1961 * the SSID list...
1962 */
1963
1964 /*
1965 * Get the current SSID
1966 */
David Woodhouseaa21c002007-12-08 20:04:36 +00001967 if (priv->connect_status == LBS_CONNECTED) {
1968 memcpy(extra, priv->curbssparams.ssid,
1969 priv->curbssparams.ssid_len);
1970 extra[priv->curbssparams.ssid_len] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001971 } else {
1972 memset(extra, 0, 32);
David Woodhouseaa21c002007-12-08 20:04:36 +00001973 extra[priv->curbssparams.ssid_len] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001974 }
1975 /*
1976 * If none, we may want to get the one that was set
1977 */
1978
David Woodhouseaa21c002007-12-08 20:04:36 +00001979 dwrq->length = priv->curbssparams.ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001980
1981 dwrq->flags = 1; /* active */
1982
Holger Schurig9012b282007-05-25 11:27:16 -04001983 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001984 return 0;
1985}
1986
Holger Schurig10078322007-11-15 18:05:47 -05001987static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001988 struct iw_point *dwrq, char *extra)
1989{
Kiran Divekarab65f642009-02-19 19:32:39 -05001990 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001991 int ret = 0;
Holger Schurig243e84e2009-10-22 15:30:47 +02001992 u8 ssid[IEEE80211_MAX_SSID_LEN];
Dan Williamsd8efea22007-05-28 23:54:55 -04001993 u8 ssid_len = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001994 struct assoc_request * assoc_req;
Dan Williamsd8efea22007-05-28 23:54:55 -04001995 int in_ssid_len = dwrq->length;
John W. Linville9387b7c2008-09-30 20:59:05 -04001996 DECLARE_SSID_BUF(ssid_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001997
Holger Schurig9012b282007-05-25 11:27:16 -04001998 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001999
Dan Williamsd5db2df2008-08-21 17:51:07 -04002000 if (!priv->radio_on) {
2001 ret = -EINVAL;
2002 goto out;
2003 }
2004
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002005 /* Check the size of the string */
Holger Schurig243e84e2009-10-22 15:30:47 +02002006 if (in_ssid_len > IEEE80211_MAX_SSID_LEN) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002007 ret = -E2BIG;
2008 goto out;
2009 }
2010
Dan Williamsd8efea22007-05-28 23:54:55 -04002011 memset(&ssid, 0, sizeof(ssid));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002012
Dan Williamsd8efea22007-05-28 23:54:55 -04002013 if (!dwrq->flags || !in_ssid_len) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002014 /* "any" SSID requested; leave SSID blank */
2015 } else {
2016 /* Specific SSID requested */
Dan Williamsd8efea22007-05-28 23:54:55 -04002017 memcpy(&ssid, extra, in_ssid_len);
2018 ssid_len = in_ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002019 }
2020
Dan Williamsd8efea22007-05-28 23:54:55 -04002021 if (!ssid_len) {
2022 lbs_deb_wext("requested any SSID\n");
2023 } else {
2024 lbs_deb_wext("requested SSID '%s'\n",
John W. Linville9387b7c2008-09-30 20:59:05 -04002025 print_ssid(ssid_buf, ssid, ssid_len));
Dan Williamsd8efea22007-05-28 23:54:55 -04002026 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002027
2028out:
David Woodhouseaa21c002007-12-08 20:04:36 +00002029 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002030 if (ret == 0) {
2031 /* Get or create the current association request */
David Woodhouseaa21c002007-12-08 20:04:36 +00002032 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002033 if (!assoc_req) {
2034 ret = -ENOMEM;
2035 } else {
2036 /* Copy the SSID to the association request */
Holger Schurig243e84e2009-10-22 15:30:47 +02002037 memcpy(&assoc_req->ssid, &ssid, IEEE80211_MAX_SSID_LEN);
Dan Williamsd8efea22007-05-28 23:54:55 -04002038 assoc_req->ssid_len = ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002039 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05002040 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002041 }
2042 }
2043
2044 /* Cancel the association request if there was an error */
2045 if (ret != 0) {
Holger Schurig10078322007-11-15 18:05:47 -05002046 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002047 }
2048
David Woodhouseaa21c002007-12-08 20:04:36 +00002049 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002050
Holger Schurig9012b282007-05-25 11:27:16 -04002051 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002052 return ret;
2053}
2054
David Woodhousef5956bf2007-12-11 19:30:57 -05002055static int lbs_mesh_get_essid(struct net_device *dev,
2056 struct iw_request_info *info,
2057 struct iw_point *dwrq, char *extra)
2058{
Kiran Divekarab65f642009-02-19 19:32:39 -05002059 struct lbs_private *priv = dev->ml_priv;
David Woodhousef5956bf2007-12-11 19:30:57 -05002060
2061 lbs_deb_enter(LBS_DEB_WEXT);
2062
2063 memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
2064
2065 dwrq->length = priv->mesh_ssid_len;
2066
2067 dwrq->flags = 1; /* active */
2068
2069 lbs_deb_leave(LBS_DEB_WEXT);
2070 return 0;
2071}
2072
2073static int lbs_mesh_set_essid(struct net_device *dev,
2074 struct iw_request_info *info,
2075 struct iw_point *dwrq, char *extra)
2076{
Kiran Divekarab65f642009-02-19 19:32:39 -05002077 struct lbs_private *priv = dev->ml_priv;
David Woodhousef5956bf2007-12-11 19:30:57 -05002078 int ret = 0;
2079
2080 lbs_deb_enter(LBS_DEB_WEXT);
2081
Dan Williamsd5db2df2008-08-21 17:51:07 -04002082 if (!priv->radio_on) {
2083 ret = -EINVAL;
2084 goto out;
2085 }
2086
David Woodhousef5956bf2007-12-11 19:30:57 -05002087 /* Check the size of the string */
Holger Schurig243e84e2009-10-22 15:30:47 +02002088 if (dwrq->length > IEEE80211_MAX_SSID_LEN) {
David Woodhousef5956bf2007-12-11 19:30:57 -05002089 ret = -E2BIG;
2090 goto out;
2091 }
2092
2093 if (!dwrq->flags || !dwrq->length) {
2094 ret = -EINVAL;
2095 goto out;
2096 } else {
2097 /* Specific SSID requested */
2098 memcpy(priv->mesh_ssid, extra, dwrq->length);
2099 priv->mesh_ssid_len = dwrq->length;
2100 }
2101
Javier Cardonaedaea5c2008-05-17 00:55:10 -07002102 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
Holger Schurigc14951f2009-10-22 15:30:50 +02002103 priv->channel);
David Woodhousef5956bf2007-12-11 19:30:57 -05002104 out:
2105 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2106 return ret;
2107}
2108
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002109/**
2110 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2111 *
2112 * @param dev A pointer to net_device structure
2113 * @param info A pointer to iw_request_info structure
2114 * @param awrq A pointer to iw_param structure
2115 * @param extra A pointer to extra data buf
2116 * @return 0 --success, otherwise fail
2117 */
Holger Schurig10078322007-11-15 18:05:47 -05002118static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002119 struct sockaddr *awrq, char *extra)
2120{
Kiran Divekarab65f642009-02-19 19:32:39 -05002121 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002122 struct assoc_request * assoc_req;
2123 int ret = 0;
2124
Holger Schurig9012b282007-05-25 11:27:16 -04002125 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002126
Dan Williamsd5db2df2008-08-21 17:51:07 -04002127 if (!priv->radio_on)
2128 return -EINVAL;
2129
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002130 if (awrq->sa_family != ARPHRD_ETHER)
2131 return -EINVAL;
2132
Johannes Berge1749612008-10-27 15:59:26 -07002133 lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002134
David Woodhouseaa21c002007-12-08 20:04:36 +00002135 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002136
2137 /* Get or create the current association request */
David Woodhouseaa21c002007-12-08 20:04:36 +00002138 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002139 if (!assoc_req) {
Holger Schurig10078322007-11-15 18:05:47 -05002140 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002141 ret = -ENOMEM;
2142 } else {
2143 /* Copy the BSSID to the association request */
2144 memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
2145 set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05002146 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002147 }
2148
David Woodhouseaa21c002007-12-08 20:04:36 +00002149 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002150
2151 return ret;
2152}
2153
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002154/*
2155 * iwconfig settable callbacks
2156 */
Holger Schurig10078322007-11-15 18:05:47 -05002157static const iw_handler lbs_handler[] = {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002158 (iw_handler) NULL, /* SIOCSIWCOMMIT */
Holger Schurig10078322007-11-15 18:05:47 -05002159 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002160 (iw_handler) NULL, /* SIOCSIWNWID */
2161 (iw_handler) NULL, /* SIOCGIWNWID */
Holger Schurig10078322007-11-15 18:05:47 -05002162 (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */
2163 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
2164 (iw_handler) lbs_set_mode, /* SIOCSIWMODE */
2165 (iw_handler) lbs_get_mode, /* SIOCGIWMODE */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002166 (iw_handler) NULL, /* SIOCSIWSENS */
2167 (iw_handler) NULL, /* SIOCGIWSENS */
2168 (iw_handler) NULL, /* SIOCSIWRANGE */
Holger Schurig10078322007-11-15 18:05:47 -05002169 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002170 (iw_handler) NULL, /* SIOCSIWPRIV */
2171 (iw_handler) NULL, /* SIOCGIWPRIV */
2172 (iw_handler) NULL, /* SIOCSIWSTATS */
2173 (iw_handler) NULL, /* SIOCGIWSTATS */
2174 iw_handler_set_spy, /* SIOCSIWSPY */
2175 iw_handler_get_spy, /* SIOCGIWSPY */
2176 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2177 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
Holger Schurig10078322007-11-15 18:05:47 -05002178 (iw_handler) lbs_set_wap, /* SIOCSIWAP */
2179 (iw_handler) lbs_get_wap, /* SIOCGIWAP */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002180 (iw_handler) NULL, /* SIOCSIWMLME */
2181 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
Holger Schurig10078322007-11-15 18:05:47 -05002182 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2183 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
2184 (iw_handler) lbs_set_essid, /* SIOCSIWESSID */
2185 (iw_handler) lbs_get_essid, /* SIOCGIWESSID */
2186 (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */
2187 (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002188 (iw_handler) NULL, /* -- hole -- */
2189 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002190 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2191 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2192 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2193 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2194 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2195 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2196 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2197 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2198 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2199 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2200 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2201 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2202 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2203 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002204 (iw_handler) NULL, /* -- hole -- */
2205 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002206 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2207 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2208 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2209 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2210 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2211 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002212 (iw_handler) NULL, /* SIOCSIWPMKSA */
2213};
2214
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002215static const iw_handler mesh_wlan_handler[] = {
2216 (iw_handler) NULL, /* SIOCSIWCOMMIT */
Holger Schurig10078322007-11-15 18:05:47 -05002217 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002218 (iw_handler) NULL, /* SIOCSIWNWID */
2219 (iw_handler) NULL, /* SIOCGIWNWID */
David Woodhouse823eaa22007-12-11 19:56:28 -05002220 (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
Holger Schurig10078322007-11-15 18:05:47 -05002221 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002222 (iw_handler) NULL, /* SIOCSIWMODE */
2223 (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
2224 (iw_handler) NULL, /* SIOCSIWSENS */
2225 (iw_handler) NULL, /* SIOCGIWSENS */
2226 (iw_handler) NULL, /* SIOCSIWRANGE */
Holger Schurig10078322007-11-15 18:05:47 -05002227 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002228 (iw_handler) NULL, /* SIOCSIWPRIV */
2229 (iw_handler) NULL, /* SIOCGIWPRIV */
2230 (iw_handler) NULL, /* SIOCSIWSTATS */
2231 (iw_handler) NULL, /* SIOCGIWSTATS */
2232 iw_handler_set_spy, /* SIOCSIWSPY */
2233 iw_handler_get_spy, /* SIOCGIWSPY */
2234 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2235 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2236 (iw_handler) NULL, /* SIOCSIWAP */
2237 (iw_handler) NULL, /* SIOCGIWAP */
2238 (iw_handler) NULL, /* SIOCSIWMLME */
2239 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
Holger Schurig10078322007-11-15 18:05:47 -05002240 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2241 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
David Woodhousef5956bf2007-12-11 19:30:57 -05002242 (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
2243 (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002244 (iw_handler) NULL, /* SIOCSIWNICKN */
2245 (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
2246 (iw_handler) NULL, /* -- hole -- */
2247 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002248 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2249 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2250 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2251 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2252 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2253 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2254 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2255 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2256 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2257 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2258 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2259 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2260 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2261 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002262 (iw_handler) NULL, /* -- hole -- */
2263 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002264 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2265 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2266 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2267 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2268 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2269 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002270 (iw_handler) NULL, /* SIOCSIWPMKSA */
2271};
Holger Schurig10078322007-11-15 18:05:47 -05002272struct iw_handler_def lbs_handler_def = {
2273 .num_standard = ARRAY_SIZE(lbs_handler),
2274 .standard = (iw_handler *) lbs_handler,
2275 .get_wireless_stats = lbs_get_wireless_stats,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002276};
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002277
2278struct iw_handler_def mesh_handler_def = {
Denis Chengff8ac602007-09-02 18:30:18 +08002279 .num_standard = ARRAY_SIZE(mesh_wlan_handler),
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002280 .standard = (iw_handler *) mesh_wlan_handler,
Holger Schurig10078322007-11-15 18:05:47 -05002281 .get_wireless_stats = lbs_get_wireless_stats,
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002282};