blob: 18c045bcc947ab4b0938debbc6efeb964e8d4d6e [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
Holger Schurig6e85e0b2009-10-22 15:30:52 +020048void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
49{
50 union iwreq_data iwrq;
51 u8 buf[50];
52
53 lbs_deb_enter(LBS_DEB_WEXT);
54
55 memset(&iwrq, 0, sizeof(union iwreq_data));
56 memset(buf, 0, sizeof(buf));
57
58 snprintf(buf, sizeof(buf) - 1, "%s", str);
59
60 iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN;
61
62 /* Send Event to upper layer */
63 lbs_deb_wext("event indication string %s\n", (char *)buf);
64 lbs_deb_wext("event indication length %d\n", iwrq.data.length);
65 lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str);
66
67 wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf);
68
69 lbs_deb_leave(LBS_DEB_WEXT);
70}
71
Amitkumar Karwar49125452009-09-30 20:04:38 -070072/**
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020073 * @brief Find the channel frequency power info with specific channel
74 *
David Woodhouseaa21c002007-12-08 20:04:36 +000075 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020076 * @param band it can be BAND_A, BAND_G or BAND_B
77 * @param channel the channel for looking
78 * @return A pointer to struct chan_freq_power structure or NULL if not find.
79 */
Holger Schurig69f90322007-11-23 15:43:44 +010080struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
David Woodhouseaa21c002007-12-08 20:04:36 +000081 struct lbs_private *priv,
Holger Schurig69f90322007-11-23 15:43:44 +010082 u8 band,
83 u16 channel)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020084{
85 struct chan_freq_power *cfp = NULL;
86 struct region_channel *rc;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020087 int i, j;
88
David Woodhouseaa21c002007-12-08 20:04:36 +000089 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
90 rc = &priv->region_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020091
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020092 if (!rc->valid || !rc->CFP)
93 continue;
94 if (rc->band != band)
95 continue;
96 for (i = 0; i < rc->nrcfp; i++) {
97 if (rc->CFP[i].channel == channel) {
98 cfp = &rc->CFP[i];
99 break;
100 }
101 }
102 }
103
104 if (!cfp && channel)
Holger Schurig10078322007-11-15 18:05:47 -0500105 lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
Holger Schurig9012b282007-05-25 11:27:16 -0400106 "cfp by band %d / channel %d\n", band, channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200107
108 return cfp;
109}
110
111/**
112 * @brief Find the channel frequency power info with specific frequency
113 *
David Woodhouseaa21c002007-12-08 20:04:36 +0000114 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200115 * @param band it can be BAND_A, BAND_G or BAND_B
116 * @param freq the frequency for looking
117 * @return A pointer to struct chan_freq_power structure or NULL if not find.
118 */
Holger Schurig69f90322007-11-23 15:43:44 +0100119static struct chan_freq_power *find_cfp_by_band_and_freq(
David Woodhouseaa21c002007-12-08 20:04:36 +0000120 struct lbs_private *priv,
Holger Schurig69f90322007-11-23 15:43:44 +0100121 u8 band,
122 u32 freq)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200123{
124 struct chan_freq_power *cfp = NULL;
125 struct region_channel *rc;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200126 int i, j;
127
David Woodhouseaa21c002007-12-08 20:04:36 +0000128 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
129 rc = &priv->region_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200130
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200131 if (!rc->valid || !rc->CFP)
132 continue;
133 if (rc->band != band)
134 continue;
135 for (i = 0; i < rc->nrcfp; i++) {
136 if (rc->CFP[i].freq == freq) {
137 cfp = &rc->CFP[i];
138 break;
139 }
140 }
141 }
142
143 if (!cfp && freq)
Holger Schurig9012b282007-05-25 11:27:16 -0400144 lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
145 "band %d / freq %d\n", band, freq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200146
147 return cfp;
148}
149
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200150/**
Dan Williams8c512762007-08-02 11:40:45 -0400151 * @brief Copy active data rates based on adapter mode and status
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200152 *
David Woodhouseaa21c002007-12-08 20:04:36 +0000153 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200154 * @param rate The buf to return the active rates
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200155 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000156static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200157{
Holger Schurig9012b282007-05-25 11:27:16 -0400158 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200159
David Woodhouseaa21c002007-12-08 20:04:36 +0000160 if ((priv->connect_status != LBS_CONNECTED) &&
161 (priv->mesh_connect_status != LBS_CONNECTED))
Holger Schurig10078322007-11-15 18:05:47 -0500162 memcpy(rates, lbs_bg_rates, MAX_RATES);
Dan Williams8c512762007-08-02 11:40:45 -0400163 else
David Woodhouseaa21c002007-12-08 20:04:36 +0000164 memcpy(rates, priv->curbssparams.rates, MAX_RATES);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200165
Dan Williams8c512762007-08-02 11:40:45 -0400166 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200167}
168
Holger Schurig10078322007-11-15 18:05:47 -0500169static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200170 char *cwrq, char *extra)
171{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200172
Holger Schurig9012b282007-05-25 11:27:16 -0400173 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200174
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400175 /* We could add support for 802.11n here as needed. Jean II */
176 snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200177
Holger Schurig9012b282007-05-25 11:27:16 -0400178 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200179 return 0;
180}
181
Holger Schurig10078322007-11-15 18:05:47 -0500182static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200183 struct iw_freq *fwrq, char *extra)
184{
Kiran Divekarab65f642009-02-19 19:32:39 -0500185 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200186 struct chan_freq_power *cfp;
187
Holger Schurig9012b282007-05-25 11:27:16 -0400188 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200189
David Woodhouseaa21c002007-12-08 20:04:36 +0000190 cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
Holger Schurigc14951f2009-10-22 15:30:50 +0200191 priv->channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200192
193 if (!cfp) {
Holger Schurigc14951f2009-10-22 15:30:50 +0200194 if (priv->channel)
Holger Schurig9012b282007-05-25 11:27:16 -0400195 lbs_deb_wext("invalid channel %d\n",
Holger Schurigc14951f2009-10-22 15:30:50 +0200196 priv->channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200197 return -EINVAL;
198 }
199
200 fwrq->m = (long)cfp->freq * 100000;
201 fwrq->e = 1;
202
Holger Schurig9012b282007-05-25 11:27:16 -0400203 lbs_deb_wext("freq %u\n", fwrq->m);
204 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200205 return 0;
206}
207
Holger Schurig10078322007-11-15 18:05:47 -0500208static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200209 struct sockaddr *awrq, char *extra)
210{
Kiran Divekarab65f642009-02-19 19:32:39 -0500211 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200212
Holger Schurig9012b282007-05-25 11:27:16 -0400213 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200214
David Woodhouseaa21c002007-12-08 20:04:36 +0000215 if (priv->connect_status == LBS_CONNECTED) {
216 memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200217 } else {
218 memset(awrq->sa_data, 0, ETH_ALEN);
219 }
220 awrq->sa_family = ARPHRD_ETHER;
221
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_set_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
233 /*
234 * Check the size of the string
235 */
236
237 if (dwrq->length > 16) {
238 return -E2BIG;
239 }
240
David Woodhouseaa21c002007-12-08 20:04:36 +0000241 mutex_lock(&priv->lock);
242 memset(priv->nodename, 0, sizeof(priv->nodename));
243 memcpy(priv->nodename, extra, dwrq->length);
244 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200245
Holger Schurig9012b282007-05-25 11:27:16 -0400246 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200247 return 0;
248}
249
Holger Schurig10078322007-11-15 18:05:47 -0500250static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200251 struct iw_point *dwrq, char *extra)
252{
Kiran Divekarab65f642009-02-19 19:32:39 -0500253 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200254
Holger Schurig9012b282007-05-25 11:27:16 -0400255 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200256
David Woodhouseaa21c002007-12-08 20:04:36 +0000257 dwrq->length = strlen(priv->nodename);
258 memcpy(extra, priv->nodename, dwrq->length);
Holger Schurig04799fa2007-10-09 15:04:14 +0200259 extra[dwrq->length] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200260
Holger Schurig04799fa2007-10-09 15:04:14 +0200261 dwrq->flags = 1; /* active */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200262
Holger Schurig9012b282007-05-25 11:27:16 -0400263 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200264 return 0;
265}
266
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400267static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
268 struct iw_point *dwrq, char *extra)
269{
Kiran Divekarab65f642009-02-19 19:32:39 -0500270 struct lbs_private *priv = dev->ml_priv;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400271
272 lbs_deb_enter(LBS_DEB_WEXT);
273
274 /* Use nickname to indicate that mesh is on */
275
David Woodhouseaa21c002007-12-08 20:04:36 +0000276 if (priv->mesh_connect_status == LBS_CONNECTED) {
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400277 strncpy(extra, "Mesh", 12);
278 extra[12] = '\0';
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400279 dwrq->length = strlen(extra);
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400280 }
281
282 else {
283 extra[0] = '\0';
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400284 dwrq->length = 0;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400285 }
286
287 lbs_deb_leave(LBS_DEB_WEXT);
288 return 0;
289}
Holger Schurig04799fa2007-10-09 15:04:14 +0200290
Holger Schurig10078322007-11-15 18:05:47 -0500291static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200292 struct iw_param *vwrq, char *extra)
293{
294 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -0500295 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400296 u32 val = vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200297
Holger Schurig9012b282007-05-25 11:27:16 -0400298 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200299
Dan Williams39fcf7a2008-09-10 12:49:00 -0400300 if (vwrq->disabled)
301 val = MRVDRV_RTS_MAX_VALUE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200302
John W. Linville375da532008-09-15 17:25:54 -0400303 if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */
Dan Williams39fcf7a2008-09-10 12:49:00 -0400304 return -EINVAL;
305
306 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200307
Holger Schurig9012b282007-05-25 11:27:16 -0400308 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200309 return ret;
310}
311
Holger Schurig10078322007-11-15 18:05:47 -0500312static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200313 struct iw_param *vwrq, char *extra)
314{
Kiran Divekarab65f642009-02-19 19:32:39 -0500315 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400316 int ret = 0;
317 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200318
Holger Schurig9012b282007-05-25 11:27:16 -0400319 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200320
Dan Williams39fcf7a2008-09-10 12:49:00 -0400321 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
Holger Schurig9012b282007-05-25 11:27:16 -0400322 if (ret)
323 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200324
Dan Williams39fcf7a2008-09-10 12:49:00 -0400325 vwrq->value = val;
John W. Linville375da532008-09-15 17:25:54 -0400326 vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200327 vwrq->fixed = 1;
328
Holger Schurig9012b282007-05-25 11:27:16 -0400329out:
330 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
331 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200332}
333
Holger Schurig10078322007-11-15 18:05:47 -0500334static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200335 struct iw_param *vwrq, char *extra)
336{
Kiran Divekarab65f642009-02-19 19:32:39 -0500337 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400338 int ret = 0;
339 u32 val = vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200340
Holger Schurig9012b282007-05-25 11:27:16 -0400341 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200342
Dan Williams39fcf7a2008-09-10 12:49:00 -0400343 if (vwrq->disabled)
344 val = MRVDRV_FRAG_MAX_VALUE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200345
Dan Williams39fcf7a2008-09-10 12:49:00 -0400346 if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
347 return -EINVAL;
348
349 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
Holger Schurig9012b282007-05-25 11:27:16 -0400350
351 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200352 return ret;
353}
354
Holger Schurig10078322007-11-15 18:05:47 -0500355static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200356 struct iw_param *vwrq, char *extra)
357{
Kiran Divekarab65f642009-02-19 19:32:39 -0500358 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400359 int ret = 0;
360 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200361
Holger Schurig9012b282007-05-25 11:27:16 -0400362 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200363
Dan Williams39fcf7a2008-09-10 12:49:00 -0400364 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
Holger Schurig9012b282007-05-25 11:27:16 -0400365 if (ret)
366 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200367
Dan Williams39fcf7a2008-09-10 12:49:00 -0400368 vwrq->value = val;
369 vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
370 || (val > MRVDRV_FRAG_MAX_VALUE));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200371 vwrq->fixed = 1;
372
Holger Schurig9012b282007-05-25 11:27:16 -0400373out:
374 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200375 return ret;
376}
377
Holger Schurig10078322007-11-15 18:05:47 -0500378static int lbs_get_mode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200379 struct iw_request_info *info, u32 * uwrq, char *extra)
380{
Kiran Divekarab65f642009-02-19 19:32:39 -0500381 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200382
Holger Schurig9012b282007-05-25 11:27:16 -0400383 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200384
David Woodhouseaa21c002007-12-08 20:04:36 +0000385 *uwrq = priv->mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200386
Holger Schurig9012b282007-05-25 11:27:16 -0400387 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200388 return 0;
389}
390
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400391static int mesh_wlan_get_mode(struct net_device *dev,
392 struct iw_request_info *info, u32 * uwrq,
393 char *extra)
394{
395 lbs_deb_enter(LBS_DEB_WEXT);
396
Dan Williams39fcf7a2008-09-10 12:49:00 -0400397 *uwrq = IW_MODE_REPEAT;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400398
399 lbs_deb_leave(LBS_DEB_WEXT);
400 return 0;
401}
402
Holger Schurig10078322007-11-15 18:05:47 -0500403static int lbs_get_txpow(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200404 struct iw_request_info *info,
405 struct iw_param *vwrq, char *extra)
406{
Kiran Divekarab65f642009-02-19 19:32:39 -0500407 struct lbs_private *priv = dev->ml_priv;
Dan Williams87c8c722008-08-19 15:15:35 -0400408 s16 curlevel = 0;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400409 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200410
Holger Schurig9012b282007-05-25 11:27:16 -0400411 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200412
Dan Williamsd5db2df2008-08-21 17:51:07 -0400413 if (!priv->radio_on) {
414 lbs_deb_wext("tx power off\n");
415 vwrq->value = 0;
416 vwrq->disabled = 1;
417 goto out;
418 }
419
Dan Williams87c8c722008-08-19 15:15:35 -0400420 ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
Holger Schurig9012b282007-05-25 11:27:16 -0400421 if (ret)
422 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200423
Dan Williams87c8c722008-08-19 15:15:35 -0400424 lbs_deb_wext("tx power level %d dbm\n", curlevel);
Dan Williams87c8c722008-08-19 15:15:35 -0400425 priv->txpower_cur = curlevel;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400426
Dan Williams87c8c722008-08-19 15:15:35 -0400427 vwrq->value = curlevel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200428 vwrq->fixed = 1;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400429 vwrq->disabled = 0;
430 vwrq->flags = IW_TXPOW_DBM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200431
Holger Schurig9012b282007-05-25 11:27:16 -0400432out:
433 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
434 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200435}
436
Holger Schurig10078322007-11-15 18:05:47 -0500437static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200438 struct iw_param *vwrq, char *extra)
439{
Kiran Divekarab65f642009-02-19 19:32:39 -0500440 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400441 int ret = 0;
442 u16 slimit = 0, llimit = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200443
Holger Schurig9012b282007-05-25 11:27:16 -0400444 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200445
Dan Williams39fcf7a2008-09-10 12:49:00 -0400446 if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
447 return -EOPNOTSUPP;
448
449 /* The MAC has a 4-bit Total_Tx_Count register
450 Total_Tx_Count = 1 + Tx_Retry_Count */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200451#define TX_RETRY_MIN 0
452#define TX_RETRY_MAX 14
Dan Williams39fcf7a2008-09-10 12:49:00 -0400453 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
454 return -EINVAL;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200455
Dan Williams39fcf7a2008-09-10 12:49:00 -0400456 /* Add 1 to convert retry count to try count */
457 if (vwrq->flags & IW_RETRY_SHORT)
458 slimit = (u16) (vwrq->value + 1);
459 else if (vwrq->flags & IW_RETRY_LONG)
460 llimit = (u16) (vwrq->value + 1);
461 else
462 slimit = llimit = (u16) (vwrq->value + 1); /* set both */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200463
Dan Williams39fcf7a2008-09-10 12:49:00 -0400464 if (llimit) {
465 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
466 llimit);
Holger Schurig9012b282007-05-25 11:27:16 -0400467 if (ret)
468 goto out;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400469 }
470
471 if (slimit) {
472 /* txretrycount follows the short retry limit */
473 priv->txretrycount = slimit;
474 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
475 slimit);
476 if (ret)
477 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200478 }
479
Holger Schurig9012b282007-05-25 11:27:16 -0400480out:
481 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
482 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200483}
484
Holger Schurig10078322007-11-15 18:05:47 -0500485static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200486 struct iw_param *vwrq, char *extra)
487{
Kiran Divekarab65f642009-02-19 19:32:39 -0500488 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200489 int ret = 0;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400490 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200491
Holger Schurig9012b282007-05-25 11:27:16 -0400492 lbs_deb_enter(LBS_DEB_WEXT);
493
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200494 vwrq->disabled = 0;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400495
496 if (vwrq->flags & IW_RETRY_LONG) {
497 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
498 if (ret)
499 goto out;
500
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200501 /* Subtract 1 to convert try count to retry count */
Dan Williams39fcf7a2008-09-10 12:49:00 -0400502 vwrq->value = val - 1;
503 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
504 } else {
505 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
506 if (ret)
507 goto out;
508
509 /* txretry count follows the short retry limit */
510 priv->txretrycount = val;
511 /* Subtract 1 to convert try count to retry count */
512 vwrq->value = val - 1;
513 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200514 }
515
Holger Schurig9012b282007-05-25 11:27:16 -0400516out:
517 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
518 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200519}
520
521static inline void sort_channels(struct iw_freq *freq, int num)
522{
523 int i, j;
524 struct iw_freq temp;
525
526 for (i = 0; i < num; i++)
527 for (j = i + 1; j < num; j++)
528 if (freq[i].i > freq[j].i) {
529 temp.i = freq[i].i;
530 temp.m = freq[i].m;
531
532 freq[i].i = freq[j].i;
533 freq[i].m = freq[j].m;
534
535 freq[j].i = temp.i;
536 freq[j].m = temp.m;
537 }
538}
539
540/* data rate listing
541 MULTI_BANDS:
542 abg a b b/g
543 Infra G(12) A(8) B(4) G(12)
544 Adhoc A+B(12) A(8) B(4) B(4)
545
546 non-MULTI_BANDS:
547 b b/g
548 Infra B(4) G(12)
549 Adhoc B(4) B(4)
550 */
551/**
552 * @brief Get Range Info
553 *
554 * @param dev A pointer to net_device structure
555 * @param info A pointer to iw_request_info structure
556 * @param vwrq A pointer to iw_param structure
557 * @param extra A pointer to extra data buf
558 * @return 0 --success, otherwise fail
559 */
Holger Schurig10078322007-11-15 18:05:47 -0500560static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200561 struct iw_point *dwrq, char *extra)
562{
563 int i, j;
Kiran Divekarab65f642009-02-19 19:32:39 -0500564 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200565 struct iw_range *range = (struct iw_range *)extra;
566 struct chan_freq_power *cfp;
Dan Williams8c512762007-08-02 11:40:45 -0400567 u8 rates[MAX_RATES + 1];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200568
Holger Schurig9012b282007-05-25 11:27:16 -0400569 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200570
571 dwrq->length = sizeof(struct iw_range);
572 memset(range, 0, sizeof(struct iw_range));
573
574 range->min_nwid = 0;
575 range->max_nwid = 0;
576
577 memset(rates, 0, sizeof(rates));
David Woodhouseaa21c002007-12-08 20:04:36 +0000578 copy_active_data_rates(priv, rates);
Dan Williams8c512762007-08-02 11:40:45 -0400579 range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
580 for (i = 0; i < range->num_bitrates; i++)
581 range->bitrate[i] = rates[i] * 500000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200582 range->num_bitrates = i;
Holger Schurig9012b282007-05-25 11:27:16 -0400583 lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200584 range->num_bitrates);
585
586 range->num_frequency = 0;
Holger Schurig52933d82008-03-05 07:05:32 +0100587
588 range->scan_capa = IW_SCAN_CAPA_ESSID;
589
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200590 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
591 && (j < ARRAY_SIZE(priv->region_channel)); j++) {
592 cfp = priv->region_channel[j].CFP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200593 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200594 && priv->region_channel[j].valid
595 && cfp
596 && (i < priv->region_channel[j].nrcfp); i++) {
597 range->freq[range->num_frequency].i =
598 (long)cfp->channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200599 range->freq[range->num_frequency].m =
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200600 (long)cfp->freq * 100000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200601 range->freq[range->num_frequency].e = 1;
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200602 cfp++;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200603 range->num_frequency++;
604 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200605 }
606
Holger Schurig9012b282007-05-25 11:27:16 -0400607 lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200608 IW_MAX_FREQUENCIES, range->num_frequency);
609
610 range->num_channels = range->num_frequency;
611
612 sort_channels(&range->freq[0], range->num_frequency);
613
614 /*
615 * Set an indication of the max TCP throughput in bit/s that we can
616 * expect using this interface
617 */
618 if (i > 2)
619 range->throughput = 5000 * 1000;
620 else
621 range->throughput = 1500 * 1000;
622
623 range->min_rts = MRVDRV_RTS_MIN_VALUE;
624 range->max_rts = MRVDRV_RTS_MAX_VALUE;
625 range->min_frag = MRVDRV_FRAG_MIN_VALUE;
626 range->max_frag = MRVDRV_FRAG_MAX_VALUE;
627
628 range->encoding_size[0] = 5;
629 range->encoding_size[1] = 13;
630 range->num_encoding_sizes = 2;
631 range->max_encoding_tokens = 4;
632
Holger Schurigd4ff0ef2008-03-19 14:25:18 +0100633 /*
634 * Right now we support only "iwconfig ethX power on|off"
635 */
636 range->pm_capa = IW_POWER_ON;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200637
638 /*
639 * Minimum version we recommend
640 */
641 range->we_version_source = 15;
642
643 /*
644 * Version we are compiled with
645 */
646 range->we_version_compiled = WIRELESS_EXT;
647
648 range->retry_capa = IW_RETRY_LIMIT;
649 range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
650
651 range->min_retry = TX_RETRY_MIN;
652 range->max_retry = TX_RETRY_MAX;
653
654 /*
655 * Set the qual, level and noise range values
656 */
657 range->max_qual.qual = 100;
658 range->max_qual.level = 0;
659 range->max_qual.noise = 0;
660 range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
661
662 range->avg_qual.qual = 70;
663 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
664 range->avg_qual.level = 0;
665 range->avg_qual.noise = 0;
666 range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
667
668 range->sensitivity = 0;
669
Dan Williams87c8c722008-08-19 15:15:35 -0400670 /* Setup the supported power level ranges */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200671 memset(range->txpower, 0, sizeof(range->txpower));
Dan Williams87c8c722008-08-19 15:15:35 -0400672 range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE;
673 range->txpower[0] = priv->txpower_min;
674 range->txpower[1] = priv->txpower_max;
675 range->num_txpower = 2;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200676
677 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
678 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
679 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
680 range->event_capa[1] = IW_EVENT_CAPA_K_1;
681
David Woodhouseaa21c002007-12-08 20:04:36 +0000682 if (priv->fwcapinfo & FW_CAPINFO_WPA) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200683 range->enc_capa = IW_ENC_CAPA_WPA
684 | IW_ENC_CAPA_WPA2
685 | IW_ENC_CAPA_CIPHER_TKIP
686 | IW_ENC_CAPA_CIPHER_CCMP;
687 }
688
Holger Schurig9012b282007-05-25 11:27:16 -0400689 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200690 return 0;
691}
692
Holger Schurig10078322007-11-15 18:05:47 -0500693static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200694 struct iw_param *vwrq, char *extra)
695{
Kiran Divekarab65f642009-02-19 19:32:39 -0500696 struct lbs_private *priv = dev->ml_priv;
Amitkumar Karwar49125452009-09-30 20:04:38 -0700697 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200698
Holger Schurig9012b282007-05-25 11:27:16 -0400699 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200700
Andrey Yurovskye0d61332009-06-16 13:20:01 -0700701 if (!(priv->fwcapinfo & FW_CAPINFO_PS)) {
David Woodhouseb2c57ee2007-12-17 14:41:13 -0500702 if (vwrq->disabled)
703 return 0;
704 else
705 return -EINVAL;
706 }
707
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200708 /* PS is currently supported only in Infrastructure mode
709 * Remove this check if it is to be supported in IBSS mode also
710 */
711
712 if (vwrq->disabled) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000713 priv->psmode = LBS802_11POWERMODECAM;
714 if (priv->psstate != PS_STATE_FULL_POWER) {
Holger Schurig10078322007-11-15 18:05:47 -0500715 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200716 }
717
718 return 0;
719 }
720
721 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
Holger Schurig9012b282007-05-25 11:27:16 -0400722 lbs_deb_wext(
723 "setting power timeout is not supported\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200724 return -EINVAL;
725 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
Amitkumar Karwar49125452009-09-30 20:04:38 -0700726 vwrq->value = vwrq->value / 1000;
727 if (!priv->enter_deep_sleep) {
728 lbs_pr_err("deep sleep feature is not implemented "
729 "for this interface driver\n");
730 return -EINVAL;
731 }
732
733 if (priv->connect_status == LBS_CONNECTED) {
734 if ((priv->is_auto_deep_sleep_enabled) &&
735 (vwrq->value == -1000)) {
736 lbs_exit_auto_deep_sleep(priv);
737 return 0;
738 } else {
739 lbs_pr_err("can't use deep sleep cmd in "
740 "connected state\n");
741 return -EINVAL;
742 }
743 }
744
745 if ((vwrq->value < 0) && (vwrq->value != -1000)) {
746 lbs_pr_err("unknown option\n");
747 return -EINVAL;
748 }
749
750 if (vwrq->value > 0) {
751 if (!priv->is_auto_deep_sleep_enabled) {
752 priv->is_activity_detected = 0;
753 priv->auto_deep_sleep_timeout = vwrq->value;
754 lbs_enter_auto_deep_sleep(priv);
755 } else {
756 priv->auto_deep_sleep_timeout = vwrq->value;
757 lbs_deb_debugfs("auto deep sleep: "
758 "already enabled\n");
759 }
760 return 0;
761 } else {
762 if (priv->is_auto_deep_sleep_enabled) {
763 lbs_exit_auto_deep_sleep(priv);
764 /* Try to exit deep sleep if auto */
765 /*deep sleep disabled */
766 ret = lbs_set_deep_sleep(priv, 0);
767 }
768 if (vwrq->value == 0)
769 ret = lbs_set_deep_sleep(priv, 1);
770 else if (vwrq->value == -1000)
771 ret = lbs_set_deep_sleep(priv, 0);
772 return ret;
773 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200774 }
775
David Woodhouseaa21c002007-12-08 20:04:36 +0000776 if (priv->psmode != LBS802_11POWERMODECAM) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200777 return 0;
778 }
779
David Woodhouseaa21c002007-12-08 20:04:36 +0000780 priv->psmode = LBS802_11POWERMODEMAX_PSP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200781
David Woodhouseaa21c002007-12-08 20:04:36 +0000782 if (priv->connect_status == LBS_CONNECTED) {
Holger Schurig10078322007-11-15 18:05:47 -0500783 lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200784 }
785
Holger Schurig9012b282007-05-25 11:27:16 -0400786 lbs_deb_leave(LBS_DEB_WEXT);
Amitkumar Karwar49125452009-09-30 20:04:38 -0700787
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200788 return 0;
789}
790
Holger Schurig10078322007-11-15 18:05:47 -0500791static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200792 struct iw_param *vwrq, char *extra)
793{
Kiran Divekarab65f642009-02-19 19:32:39 -0500794 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200795
Holger Schurig9012b282007-05-25 11:27:16 -0400796 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200797
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200798 vwrq->value = 0;
Holger Schurigd4ff0ef2008-03-19 14:25:18 +0100799 vwrq->flags = 0;
800 vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM
801 || priv->connect_status == LBS_DISCONNECTED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200802
Holger Schurig9012b282007-05-25 11:27:16 -0400803 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200804 return 0;
805}
806
Holger Schurig10078322007-11-15 18:05:47 -0500807static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200808{
809 enum {
810 POOR = 30,
811 FAIR = 60,
812 GOOD = 80,
813 VERY_GOOD = 90,
814 EXCELLENT = 95,
815 PERFECT = 100
816 };
Kiran Divekarab65f642009-02-19 19:32:39 -0500817 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200818 u32 rssi_qual;
819 u32 tx_qual;
820 u32 quality = 0;
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700821 int ret, stats_valid = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200822 u8 rssi;
823 u32 tx_retries;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100824 struct cmd_ds_802_11_get_log log;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200825
Holger Schurig9012b282007-05-25 11:27:16 -0400826 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200827
David Woodhouseaa21c002007-12-08 20:04:36 +0000828 priv->wstats.status = priv->mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200829
830 /* If we're not associated, all quality values are meaningless */
David Woodhouseaa21c002007-12-08 20:04:36 +0000831 if ((priv->connect_status != LBS_CONNECTED) &&
832 (priv->mesh_connect_status != LBS_CONNECTED))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200833 goto out;
834
835 /* Quality by RSSI */
836 priv->wstats.qual.level =
David Woodhouseaa21c002007-12-08 20:04:36 +0000837 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
838 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200839
David Woodhouseaa21c002007-12-08 20:04:36 +0000840 if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200841 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
842 } else {
843 priv->wstats.qual.noise =
David Woodhouseaa21c002007-12-08 20:04:36 +0000844 CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200845 }
846
Holger Schurig9012b282007-05-25 11:27:16 -0400847 lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
848 lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200849
850 rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
851 if (rssi < 15)
852 rssi_qual = rssi * POOR / 10;
853 else if (rssi < 20)
854 rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
855 else if (rssi < 30)
856 rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
857 else if (rssi < 40)
858 rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
859 10 + GOOD;
860 else
861 rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
862 10 + VERY_GOOD;
863 quality = rssi_qual;
864
865 /* Quality by TX errors */
Stephen Hemmingerbbfc6b72009-03-20 19:36:36 +0000866 priv->wstats.discard.retries = dev->stats.tx_errors;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200867
Holger Schurigc49c3b72008-03-17 12:45:58 +0100868 memset(&log, 0, sizeof(log));
869 log.hdr.size = cpu_to_le16(sizeof(log));
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700870 ret = lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
871 if (ret)
872 goto out;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100873
874 tx_retries = le32_to_cpu(log.retry);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200875
876 if (tx_retries > 75)
877 tx_qual = (90 - tx_retries) * POOR / 15;
878 else if (tx_retries > 70)
879 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
880 else if (tx_retries > 65)
881 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
882 else if (tx_retries > 50)
883 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
884 15 + GOOD;
885 else
886 tx_qual = (50 - tx_retries) *
887 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
888 quality = min(quality, tx_qual);
889
Holger Schurigc49c3b72008-03-17 12:45:58 +0100890 priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200891 priv->wstats.discard.retries = tx_retries;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100892 priv->wstats.discard.misc = le32_to_cpu(log.ackfailure);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200893
894 /* Calculate quality */
Holger Schurigcad9d9b2007-08-02 13:07:15 -0400895 priv->wstats.qual.qual = min_t(u8, quality, 100);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200896 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
897 stats_valid = 1;
898
899 /* update stats asynchronously for future calls */
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700900 ret = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200901 0, 0, NULL);
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700902 if (ret)
903 lbs_pr_err("RSSI command failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200904out:
905 if (!stats_valid) {
906 priv->wstats.miss.beacon = 0;
907 priv->wstats.discard.retries = 0;
908 priv->wstats.qual.qual = 0;
909 priv->wstats.qual.level = 0;
910 priv->wstats.qual.noise = 0;
911 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
912 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
913 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
914 }
915
Holger Schurig9012b282007-05-25 11:27:16 -0400916 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200917 return &priv->wstats;
918
919
920}
921
Holger Schurig10078322007-11-15 18:05:47 -0500922static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200923 struct iw_freq *fwrq, char *extra)
924{
Dan Williamsef9a2642007-05-25 16:46:33 -0400925 int ret = -EINVAL;
Kiran Divekarab65f642009-02-19 19:32:39 -0500926 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200927 struct chan_freq_power *cfp;
Dan Williamsef9a2642007-05-25 16:46:33 -0400928 struct assoc_request * assoc_req;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200929
Holger Schurig9012b282007-05-25 11:27:16 -0400930 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200931
David Woodhouseaa21c002007-12-08 20:04:36 +0000932 mutex_lock(&priv->lock);
933 assoc_req = lbs_get_association_request(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400934 if (!assoc_req) {
935 ret = -ENOMEM;
936 goto out;
937 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200938
Dan Williamsef9a2642007-05-25 16:46:33 -0400939 /* If setting by frequency, convert to a channel */
940 if (fwrq->e == 1) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200941 long f = fwrq->m / 100000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200942
David Woodhouseaa21c002007-12-08 20:04:36 +0000943 cfp = find_cfp_by_band_and_freq(priv, 0, f);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200944 if (!cfp) {
Holger Schurig9012b282007-05-25 11:27:16 -0400945 lbs_deb_wext("invalid freq %ld\n", f);
Dan Williamsef9a2642007-05-25 16:46:33 -0400946 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200947 }
948
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200949 fwrq->e = 0;
Dan Williamsef9a2642007-05-25 16:46:33 -0400950 fwrq->m = (int) cfp->channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200951 }
952
Dan Williamsef9a2642007-05-25 16:46:33 -0400953 /* Setting by channel number */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200954 if (fwrq->m > 1000 || fwrq->e > 0) {
Dan Williamsef9a2642007-05-25 16:46:33 -0400955 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200956 }
957
David Woodhouseaa21c002007-12-08 20:04:36 +0000958 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
Dan Williamsef9a2642007-05-25 16:46:33 -0400959 if (!cfp) {
960 goto out;
961 }
962
963 assoc_req->channel = fwrq->m;
964 ret = 0;
965
Holger Schurig9012b282007-05-25 11:27:16 -0400966out:
Dan Williamsef9a2642007-05-25 16:46:33 -0400967 if (ret == 0) {
968 set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -0500969 lbs_postpone_association_work(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400970 } else {
Holger Schurig10078322007-11-15 18:05:47 -0500971 lbs_cancel_association_work(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400972 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000973 mutex_unlock(&priv->lock);
Dan Williamsef9a2642007-05-25 16:46:33 -0400974
975 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
976 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200977}
978
David Woodhouse823eaa22007-12-11 19:56:28 -0500979static int lbs_mesh_set_freq(struct net_device *dev,
980 struct iw_request_info *info,
981 struct iw_freq *fwrq, char *extra)
982{
Kiran Divekarab65f642009-02-19 19:32:39 -0500983 struct lbs_private *priv = dev->ml_priv;
David Woodhouse823eaa22007-12-11 19:56:28 -0500984 struct chan_freq_power *cfp;
985 int ret = -EINVAL;
986
987 lbs_deb_enter(LBS_DEB_WEXT);
988
989 /* If setting by frequency, convert to a channel */
990 if (fwrq->e == 1) {
991 long f = fwrq->m / 100000;
992
993 cfp = find_cfp_by_band_and_freq(priv, 0, f);
994 if (!cfp) {
995 lbs_deb_wext("invalid freq %ld\n", f);
996 goto out;
997 }
998
999 fwrq->e = 0;
1000 fwrq->m = (int) cfp->channel;
1001 }
1002
1003 /* Setting by channel number */
1004 if (fwrq->m > 1000 || fwrq->e > 0) {
1005 goto out;
1006 }
1007
1008 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
1009 if (!cfp) {
1010 goto out;
1011 }
1012
Holger Schurigc14951f2009-10-22 15:30:50 +02001013 if (fwrq->m != priv->channel) {
David Woodhouse823eaa22007-12-11 19:56:28 -05001014 lbs_deb_wext("mesh channel change forces eth disconnect\n");
1015 if (priv->mode == IW_MODE_INFRA)
Dan Williams191bb402008-08-21 17:46:18 -04001016 lbs_cmd_80211_deauthenticate(priv,
1017 priv->curbssparams.bssid,
1018 WLAN_REASON_DEAUTH_LEAVING);
David Woodhouse823eaa22007-12-11 19:56:28 -05001019 else if (priv->mode == IW_MODE_ADHOC)
Dan Williamsf5fe1fd2008-08-21 21:46:59 -04001020 lbs_adhoc_stop(priv);
David Woodhouse823eaa22007-12-11 19:56:28 -05001021 }
Javier Cardonaedaea5c2008-05-17 00:55:10 -07001022 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m);
David Woodhouse86062132007-12-13 00:32:36 -05001023 lbs_update_channel(priv);
David Woodhouse823eaa22007-12-11 19:56:28 -05001024 ret = 0;
1025
1026out:
1027 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1028 return ret;
1029}
1030
Holger Schurig10078322007-11-15 18:05:47 -05001031static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001032 struct iw_param *vwrq, char *extra)
1033{
Kiran Divekarab65f642009-02-19 19:32:39 -05001034 struct lbs_private *priv = dev->ml_priv;
Dan Williams8e3c91b2007-12-11 15:50:59 -05001035 u8 new_rate = 0;
Dan Williams8c512762007-08-02 11:40:45 -04001036 int ret = -EINVAL;
1037 u8 rates[MAX_RATES + 1];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001038
Holger Schurig9012b282007-05-25 11:27:16 -04001039 lbs_deb_enter(LBS_DEB_WEXT);
Amitkumar Karwar49125452009-09-30 20:04:38 -07001040
Holger Schurig9012b282007-05-25 11:27:16 -04001041 lbs_deb_wext("vwrq->value %d\n", vwrq->value);
Javier Cardona85319f92008-05-24 10:59:49 +01001042 lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed);
1043
1044 if (vwrq->fixed && vwrq->value == -1)
1045 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001046
Dan Williams8c512762007-08-02 11:40:45 -04001047 /* Auto rate? */
Javier Cardona85319f92008-05-24 10:59:49 +01001048 priv->enablehwauto = !vwrq->fixed;
1049
1050 if (vwrq->value == -1)
David Woodhouseaa21c002007-12-08 20:04:36 +00001051 priv->cur_rate = 0;
Javier Cardona85319f92008-05-24 10:59:49 +01001052 else {
Dan Williams8c512762007-08-02 11:40:45 -04001053 if (vwrq->value % 100000)
1054 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001055
Javier Cardona85319f92008-05-24 10:59:49 +01001056 new_rate = vwrq->value / 500000;
1057 priv->cur_rate = new_rate;
1058 /* the rest is only needed for lbs_set_data_rate() */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001059 memset(rates, 0, sizeof(rates));
David Woodhouseaa21c002007-12-08 20:04:36 +00001060 copy_active_data_rates(priv, rates);
Dan Williams8c512762007-08-02 11:40:45 -04001061 if (!memchr(rates, new_rate, sizeof(rates))) {
1062 lbs_pr_alert("fixed data rate 0x%X out of range\n",
1063 new_rate);
1064 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001065 }
Anna Neal3ed6e082008-09-26 11:34:35 -04001066 if (priv->fwrelease < 0x09000000) {
1067 ret = lbs_set_power_adapt_cfg(priv, 0,
1068 POW_ADAPT_DEFAULT_P0,
1069 POW_ADAPT_DEFAULT_P1,
1070 POW_ADAPT_DEFAULT_P2);
1071 if (ret)
1072 goto out;
1073 }
1074 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1075 TPC_DEFAULT_P2, 1);
1076 if (ret)
1077 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001078 }
1079
Javier Cardona85319f92008-05-24 10:59:49 +01001080 /* Try the newer command first (Firmware Spec 5.1 and above) */
1081 ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET);
1082
1083 /* Fallback to older version */
1084 if (ret)
1085 ret = lbs_set_data_rate(priv, new_rate);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001086
Dan Williams8c512762007-08-02 11:40:45 -04001087out:
Holger Schurig9012b282007-05-25 11:27:16 -04001088 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001089 return ret;
1090}
1091
Holger Schurig10078322007-11-15 18:05:47 -05001092static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001093 struct iw_param *vwrq, char *extra)
1094{
Kiran Divekarab65f642009-02-19 19:32:39 -05001095 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001096
Holger Schurig9012b282007-05-25 11:27:16 -04001097 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001098
David Woodhouseaa21c002007-12-08 20:04:36 +00001099 if (priv->connect_status == LBS_CONNECTED) {
1100 vwrq->value = priv->cur_rate * 500000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001101
Javier Cardona85319f92008-05-24 10:59:49 +01001102 if (priv->enablehwauto)
Dan Williams8c512762007-08-02 11:40:45 -04001103 vwrq->fixed = 0;
1104 else
1105 vwrq->fixed = 1;
1106
1107 } else {
1108 vwrq->fixed = 0;
1109 vwrq->value = 0;
1110 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001111
Holger Schurig9012b282007-05-25 11:27:16 -04001112 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001113 return 0;
1114}
1115
Holger Schurig10078322007-11-15 18:05:47 -05001116static int lbs_set_mode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001117 struct iw_request_info *info, u32 * uwrq, char *extra)
1118{
1119 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001120 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001121 struct assoc_request * assoc_req;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001122
Holger Schurig9012b282007-05-25 11:27:16 -04001123 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001124
Dan Williams0dc5a292007-05-10 22:58:02 -04001125 if ( (*uwrq != IW_MODE_ADHOC)
1126 && (*uwrq != IW_MODE_INFRA)
1127 && (*uwrq != IW_MODE_AUTO)) {
Holger Schurig9012b282007-05-25 11:27:16 -04001128 lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq);
Dan Williams0dc5a292007-05-10 22:58:02 -04001129 ret = -EINVAL;
1130 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001131 }
1132
David Woodhouseaa21c002007-12-08 20:04:36 +00001133 mutex_lock(&priv->lock);
1134 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001135 if (!assoc_req) {
1136 ret = -ENOMEM;
Holger Schurig10078322007-11-15 18:05:47 -05001137 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001138 } else {
Dan Williams0dc5a292007-05-10 22:58:02 -04001139 assoc_req->mode = *uwrq;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001140 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001141 lbs_postpone_association_work(priv);
Holger Schurig9012b282007-05-25 11:27:16 -04001142 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001143 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001144 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001145
Dan Williams0dc5a292007-05-10 22:58:02 -04001146out:
Holger Schurig9012b282007-05-25 11:27:16 -04001147 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001148 return ret;
1149}
1150
1151
1152/**
1153 * @brief Get Encryption key
1154 *
1155 * @param dev A pointer to net_device structure
1156 * @param info A pointer to iw_request_info structure
1157 * @param vwrq A pointer to iw_param structure
1158 * @param extra A pointer to extra data buf
1159 * @return 0 --success, otherwise fail
1160 */
Holger Schurig10078322007-11-15 18:05:47 -05001161static int lbs_get_encode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001162 struct iw_request_info *info,
1163 struct iw_point *dwrq, u8 * extra)
1164{
Kiran Divekarab65f642009-02-19 19:32:39 -05001165 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001166 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1167
Holger Schurig9012b282007-05-25 11:27:16 -04001168 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001169
Holger Schurig9012b282007-05-25 11:27:16 -04001170 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +00001171 dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001172
1173 dwrq->flags = 0;
1174
1175 /* Authentication method */
David Woodhouseaa21c002007-12-08 20:04:36 +00001176 switch (priv->secinfo.auth_mode) {
Dan Williams6affe782007-05-10 22:56:42 -04001177 case IW_AUTH_ALG_OPEN_SYSTEM:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001178 dwrq->flags = IW_ENCODE_OPEN;
1179 break;
1180
Dan Williams6affe782007-05-10 22:56:42 -04001181 case IW_AUTH_ALG_SHARED_KEY:
1182 case IW_AUTH_ALG_LEAP:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001183 dwrq->flags = IW_ENCODE_RESTRICTED;
1184 break;
1185 default:
1186 dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
1187 break;
1188 }
1189
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001190 memset(extra, 0, 16);
1191
David Woodhouseaa21c002007-12-08 20:04:36 +00001192 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001193
1194 /* Default to returning current transmit key */
1195 if (index < 0)
David Woodhouseaa21c002007-12-08 20:04:36 +00001196 index = priv->wep_tx_keyidx;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001197
David Woodhouseaa21c002007-12-08 20:04:36 +00001198 if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
1199 memcpy(extra, priv->wep_keys[index].key,
1200 priv->wep_keys[index].len);
1201 dwrq->length = priv->wep_keys[index].len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001202
1203 dwrq->flags |= (index + 1);
1204 /* Return WEP enabled */
1205 dwrq->flags &= ~IW_ENCODE_DISABLED;
David Woodhouseaa21c002007-12-08 20:04:36 +00001206 } else if ((priv->secinfo.WPAenabled)
1207 || (priv->secinfo.WPA2enabled)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001208 /* return WPA enabled */
1209 dwrq->flags &= ~IW_ENCODE_DISABLED;
David Woodhousec12bdc42007-12-07 19:32:12 +00001210 dwrq->flags |= IW_ENCODE_NOKEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001211 } else {
1212 dwrq->flags |= IW_ENCODE_DISABLED;
1213 }
1214
David Woodhouseaa21c002007-12-08 20:04:36 +00001215 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001216
Joe Perches0795af52007-10-03 17:59:30 -07001217 lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001218 extra[0], extra[1], extra[2],
1219 extra[3], extra[4], extra[5], dwrq->length);
1220
Holger Schurig9012b282007-05-25 11:27:16 -04001221 lbs_deb_wext("return flags 0x%x\n", dwrq->flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001222
Holger Schurig9012b282007-05-25 11:27:16 -04001223 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001224 return 0;
1225}
1226
1227/**
1228 * @brief Set Encryption key (internal)
1229 *
1230 * @param priv A pointer to private card structure
1231 * @param key_material A pointer to key material
1232 * @param key_length length of key material
1233 * @param index key index to set
1234 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1235 * @return 0 --success, otherwise fail
1236 */
Holger Schurig10078322007-11-15 18:05:47 -05001237static int lbs_set_wep_key(struct assoc_request *assoc_req,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001238 const char *key_material,
1239 u16 key_length,
1240 u16 index,
1241 int set_tx_key)
1242{
Holger Schurig9012b282007-05-25 11:27:16 -04001243 int ret = 0;
Dan Williams1443b652007-08-02 10:45:55 -04001244 struct enc_key *pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001245
Holger Schurig9012b282007-05-25 11:27:16 -04001246 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001247
1248 /* Paranoid validation of key index */
1249 if (index > 3) {
Holger Schurig9012b282007-05-25 11:27:16 -04001250 ret = -EINVAL;
1251 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001252 }
1253
1254 /* validate max key length */
1255 if (key_length > KEY_LEN_WEP_104) {
Holger Schurig9012b282007-05-25 11:27:16 -04001256 ret = -EINVAL;
1257 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001258 }
1259
1260 pkey = &assoc_req->wep_keys[index];
1261
1262 if (key_length > 0) {
Dan Williams1443b652007-08-02 10:45:55 -04001263 memset(pkey, 0, sizeof(struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001264 pkey->type = KEY_TYPE_ID_WEP;
1265
1266 /* Standardize the key length */
1267 pkey->len = (key_length > KEY_LEN_WEP_40) ?
1268 KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
1269 memcpy(pkey->key, key_material, key_length);
1270 }
1271
1272 if (set_tx_key) {
1273 /* Ensure the chosen key is valid */
1274 if (!pkey->len) {
Holger Schurig9012b282007-05-25 11:27:16 -04001275 lbs_deb_wext("key not set, so cannot enable it\n");
1276 ret = -EINVAL;
1277 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001278 }
1279 assoc_req->wep_tx_keyidx = index;
1280 }
1281
Dan Williams889c05b2007-05-10 22:57:23 -04001282 assoc_req->secinfo.wep_enabled = 1;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001283
Holger Schurig9012b282007-05-25 11:27:16 -04001284out:
1285 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1286 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001287}
1288
1289static int validate_key_index(u16 def_index, u16 raw_index,
1290 u16 *out_index, u16 *is_default)
1291{
1292 if (!out_index || !is_default)
1293 return -EINVAL;
1294
1295 /* Verify index if present, otherwise use default TX key index */
1296 if (raw_index > 0) {
1297 if (raw_index > 4)
1298 return -EINVAL;
1299 *out_index = raw_index - 1;
1300 } else {
1301 *out_index = def_index;
1302 *is_default = 1;
1303 }
1304 return 0;
1305}
1306
1307static void disable_wep(struct assoc_request *assoc_req)
1308{
1309 int i;
1310
Dan Williams90a42212007-05-25 23:01:24 -04001311 lbs_deb_enter(LBS_DEB_WEXT);
1312
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001313 /* Set Open System auth mode */
Dan Williams6affe782007-05-10 22:56:42 -04001314 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001315
1316 /* Clear WEP keys and mark WEP as disabled */
Dan Williams889c05b2007-05-10 22:57:23 -04001317 assoc_req->secinfo.wep_enabled = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001318 for (i = 0; i < 4; i++)
1319 assoc_req->wep_keys[i].len = 0;
1320
1321 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1322 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
Dan Williams90a42212007-05-25 23:01:24 -04001323
1324 lbs_deb_leave(LBS_DEB_WEXT);
1325}
1326
1327static void disable_wpa(struct assoc_request *assoc_req)
1328{
1329 lbs_deb_enter(LBS_DEB_WEXT);
1330
Dan Williams1443b652007-08-02 10:45:55 -04001331 memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key));
Dan Williams90a42212007-05-25 23:01:24 -04001332 assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
1333 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1334
Dan Williams1443b652007-08-02 10:45:55 -04001335 memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key));
Dan Williams90a42212007-05-25 23:01:24 -04001336 assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
1337 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1338
1339 assoc_req->secinfo.WPAenabled = 0;
1340 assoc_req->secinfo.WPA2enabled = 0;
1341 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1342
1343 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001344}
1345
1346/**
1347 * @brief Set Encryption key
1348 *
1349 * @param dev A pointer to net_device structure
1350 * @param info A pointer to iw_request_info structure
1351 * @param vwrq A pointer to iw_param structure
1352 * @param extra A pointer to extra data buf
1353 * @return 0 --success, otherwise fail
1354 */
Holger Schurig10078322007-11-15 18:05:47 -05001355static int lbs_set_encode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001356 struct iw_request_info *info,
1357 struct iw_point *dwrq, char *extra)
1358{
1359 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001360 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001361 struct assoc_request * assoc_req;
1362 u16 is_default = 0, index = 0, set_tx_key = 0;
1363
Holger Schurig9012b282007-05-25 11:27:16 -04001364 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001365
David Woodhouseaa21c002007-12-08 20:04:36 +00001366 mutex_lock(&priv->lock);
1367 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001368 if (!assoc_req) {
1369 ret = -ENOMEM;
1370 goto out;
1371 }
1372
1373 if (dwrq->flags & IW_ENCODE_DISABLED) {
1374 disable_wep (assoc_req);
Dan Williams90a42212007-05-25 23:01:24 -04001375 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001376 goto out;
1377 }
1378
1379 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1380 (dwrq->flags & IW_ENCODE_INDEX),
1381 &index, &is_default);
1382 if (ret) {
1383 ret = -EINVAL;
1384 goto out;
1385 }
1386
1387 /* If WEP isn't enabled, or if there is no key data but a valid
1388 * index, set the TX key.
1389 */
Dan Williams889c05b2007-05-10 22:57:23 -04001390 if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001391 set_tx_key = 1;
1392
Holger Schurig10078322007-11-15 18:05:47 -05001393 ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001394 if (ret)
1395 goto out;
1396
1397 if (dwrq->length)
1398 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1399 if (set_tx_key)
1400 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1401
1402 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
Dan Williams6affe782007-05-10 22:56:42 -04001403 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001404 } else if (dwrq->flags & IW_ENCODE_OPEN) {
Dan Williams6affe782007-05-10 22:56:42 -04001405 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001406 }
1407
1408out:
1409 if (ret == 0) {
1410 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001411 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001412 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001413 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001414 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001415 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001416
Holger Schurig9012b282007-05-25 11:27:16 -04001417 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001418 return ret;
1419}
1420
1421/**
1422 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
1423 *
1424 * @param dev A pointer to net_device structure
1425 * @param info A pointer to iw_request_info structure
1426 * @param vwrq A pointer to iw_param structure
1427 * @param extra A pointer to extra data buf
1428 * @return 0 on success, otherwise failure
1429 */
Holger Schurig10078322007-11-15 18:05:47 -05001430static int lbs_get_encodeext(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001431 struct iw_request_info *info,
1432 struct iw_point *dwrq,
1433 char *extra)
1434{
1435 int ret = -EINVAL;
Kiran Divekarab65f642009-02-19 19:32:39 -05001436 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001437 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1438 int index, max_key_len;
1439
Holger Schurig9012b282007-05-25 11:27:16 -04001440 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001441
1442 max_key_len = dwrq->length - sizeof(*ext);
1443 if (max_key_len < 0)
1444 goto out;
1445
1446 index = dwrq->flags & IW_ENCODE_INDEX;
1447 if (index) {
1448 if (index < 1 || index > 4)
1449 goto out;
1450 index--;
1451 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +00001452 index = priv->wep_tx_keyidx;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001453 }
1454
Roel Kluinf59d9782007-10-26 21:51:26 +02001455 if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001456 ext->alg != IW_ENCODE_ALG_WEP) {
David Woodhouseaa21c002007-12-08 20:04:36 +00001457 if (index != 0 || priv->mode != IW_MODE_INFRA)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001458 goto out;
1459 }
1460
1461 dwrq->flags = index + 1;
1462 memset(ext, 0, sizeof(*ext));
1463
David Woodhouseaa21c002007-12-08 20:04:36 +00001464 if ( !priv->secinfo.wep_enabled
1465 && !priv->secinfo.WPAenabled
1466 && !priv->secinfo.WPA2enabled) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001467 ext->alg = IW_ENCODE_ALG_NONE;
1468 ext->key_len = 0;
1469 dwrq->flags |= IW_ENCODE_DISABLED;
1470 } else {
1471 u8 *key = NULL;
1472
David Woodhouseaa21c002007-12-08 20:04:36 +00001473 if ( priv->secinfo.wep_enabled
1474 && !priv->secinfo.WPAenabled
1475 && !priv->secinfo.WPA2enabled) {
Dan Williams90a42212007-05-25 23:01:24 -04001476 /* WEP */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001477 ext->alg = IW_ENCODE_ALG_WEP;
David Woodhouseaa21c002007-12-08 20:04:36 +00001478 ext->key_len = priv->wep_keys[index].len;
1479 key = &priv->wep_keys[index].key[0];
1480 } else if ( !priv->secinfo.wep_enabled
1481 && (priv->secinfo.WPAenabled ||
1482 priv->secinfo.WPA2enabled)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001483 /* WPA */
Dan Williams1443b652007-08-02 10:45:55 -04001484 struct enc_key * pkey = NULL;
Dan Williams90a42212007-05-25 23:01:24 -04001485
David Woodhouseaa21c002007-12-08 20:04:36 +00001486 if ( priv->wpa_mcast_key.len
1487 && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
1488 pkey = &priv->wpa_mcast_key;
1489 else if ( priv->wpa_unicast_key.len
1490 && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
1491 pkey = &priv->wpa_unicast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001492
1493 if (pkey) {
1494 if (pkey->type == KEY_TYPE_ID_AES) {
1495 ext->alg = IW_ENCODE_ALG_CCMP;
1496 } else {
1497 ext->alg = IW_ENCODE_ALG_TKIP;
1498 }
1499 ext->key_len = pkey->len;
1500 key = &pkey->key[0];
1501 } else {
1502 ext->alg = IW_ENCODE_ALG_TKIP;
1503 ext->key_len = 0;
1504 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001505 } else {
1506 goto out;
1507 }
1508
1509 if (ext->key_len > max_key_len) {
1510 ret = -E2BIG;
1511 goto out;
1512 }
1513
1514 if (ext->key_len)
1515 memcpy(ext->key, key, ext->key_len);
1516 else
1517 dwrq->flags |= IW_ENCODE_NOKEY;
1518 dwrq->flags |= IW_ENCODE_ENABLED;
1519 }
1520 ret = 0;
1521
1522out:
Holger Schurig9012b282007-05-25 11:27:16 -04001523 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001524 return ret;
1525}
1526
1527/**
1528 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
1529 *
1530 * @param dev A pointer to net_device structure
1531 * @param info A pointer to iw_request_info structure
1532 * @param vwrq A pointer to iw_param structure
1533 * @param extra A pointer to extra data buf
1534 * @return 0 --success, otherwise fail
1535 */
Holger Schurig10078322007-11-15 18:05:47 -05001536static int lbs_set_encodeext(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001537 struct iw_request_info *info,
1538 struct iw_point *dwrq,
1539 char *extra)
1540{
1541 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001542 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001543 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1544 int alg = ext->alg;
1545 struct assoc_request * assoc_req;
1546
Holger Schurig9012b282007-05-25 11:27:16 -04001547 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001548
David Woodhouseaa21c002007-12-08 20:04:36 +00001549 mutex_lock(&priv->lock);
1550 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001551 if (!assoc_req) {
1552 ret = -ENOMEM;
1553 goto out;
1554 }
1555
1556 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
1557 disable_wep (assoc_req);
Dan Williams90a42212007-05-25 23:01:24 -04001558 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001559 } else if (alg == IW_ENCODE_ALG_WEP) {
1560 u16 is_default = 0, index, set_tx_key = 0;
1561
1562 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1563 (dwrq->flags & IW_ENCODE_INDEX),
1564 &index, &is_default);
1565 if (ret)
1566 goto out;
1567
1568 /* If WEP isn't enabled, or if there is no key data but a valid
1569 * index, or if the set-TX-key flag was passed, set the TX key.
1570 */
Dan Williams889c05b2007-05-10 22:57:23 -04001571 if ( !assoc_req->secinfo.wep_enabled
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001572 || (dwrq->length == 0 && !is_default)
1573 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
1574 set_tx_key = 1;
1575
1576 /* Copy key to driver */
Holger Schurig10078322007-11-15 18:05:47 -05001577 ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001578 set_tx_key);
1579 if (ret)
1580 goto out;
1581
1582 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
Dan Williams6affe782007-05-10 22:56:42 -04001583 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001584 } else if (dwrq->flags & IW_ENCODE_OPEN) {
Dan Williams6affe782007-05-10 22:56:42 -04001585 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001586 }
1587
1588 /* Mark the various WEP bits as modified */
1589 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1590 if (dwrq->length)
1591 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1592 if (set_tx_key)
1593 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001594 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
Dan Williams1443b652007-08-02 10:45:55 -04001595 struct enc_key * pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001596
1597 /* validate key length */
1598 if (((alg == IW_ENCODE_ALG_TKIP)
1599 && (ext->key_len != KEY_LEN_WPA_TKIP))
1600 || ((alg == IW_ENCODE_ALG_CCMP)
1601 && (ext->key_len != KEY_LEN_WPA_AES))) {
Joe Perches8376e7a2007-11-19 17:48:27 -08001602 lbs_deb_wext("invalid size %d for key of alg "
Holger Schurig9012b282007-05-25 11:27:16 -04001603 "type %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001604 ext->key_len,
1605 alg);
1606 ret = -EINVAL;
1607 goto out;
1608 }
1609
Dan Williams90a42212007-05-25 23:01:24 -04001610 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001611 pkey = &assoc_req->wpa_mcast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001612 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1613 } else {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001614 pkey = &assoc_req->wpa_unicast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001615 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1616 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001617
Dan Williams1443b652007-08-02 10:45:55 -04001618 memset(pkey, 0, sizeof (struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001619 memcpy(pkey->key, ext->key, ext->key_len);
1620 pkey->len = ext->key_len;
Dan Williams90a42212007-05-25 23:01:24 -04001621 if (pkey->len)
1622 pkey->flags |= KEY_INFO_WPA_ENABLED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001623
Dan Williams90a42212007-05-25 23:01:24 -04001624 /* Do this after zeroing key structure */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001625 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1626 pkey->flags |= KEY_INFO_WPA_MCAST;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001627 } else {
1628 pkey->flags |= KEY_INFO_WPA_UNICAST;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001629 }
1630
Dan Williams90a42212007-05-25 23:01:24 -04001631 if (alg == IW_ENCODE_ALG_TKIP) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001632 pkey->type = KEY_TYPE_ID_TKIP;
Dan Williams90a42212007-05-25 23:01:24 -04001633 } else if (alg == IW_ENCODE_ALG_CCMP) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001634 pkey->type = KEY_TYPE_ID_AES;
Dan Williams90a42212007-05-25 23:01:24 -04001635 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001636
1637 /* If WPA isn't enabled yet, do that now */
1638 if ( assoc_req->secinfo.WPAenabled == 0
1639 && assoc_req->secinfo.WPA2enabled == 0) {
1640 assoc_req->secinfo.WPAenabled = 1;
1641 assoc_req->secinfo.WPA2enabled = 1;
1642 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1643 }
1644
Javier Cardona9c31fd632008-09-11 15:32:50 -07001645 /* Only disable wep if necessary: can't waste time here. */
1646 if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
1647 disable_wep(assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001648 }
1649
1650out:
Javier Cardona9c40fc52008-09-16 18:08:39 -07001651 if (ret == 0) {
1652 /* 802.1x and WPA rekeying must happen as quickly as possible,
1653 * especially during the 4-way handshake; thus if in
1654 * infrastructure mode, and either (a) 802.1x is enabled or
1655 * (b) WPA is being used, set the key right away.
1656 */
1657 if (assoc_req->mode == IW_MODE_INFRA &&
1658 ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
1659 (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
1660 assoc_req->secinfo.WPAenabled ||
1661 assoc_req->secinfo.WPA2enabled)) {
1662 lbs_do_association_work(priv);
1663 } else
1664 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001665 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001666 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001667 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001668 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001669
Holger Schurig9012b282007-05-25 11:27:16 -04001670 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001671 return ret;
1672}
1673
1674
Holger Schurig10078322007-11-15 18:05:47 -05001675static int lbs_set_genie(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001676 struct iw_request_info *info,
1677 struct iw_point *dwrq,
1678 char *extra)
1679{
Kiran Divekarab65f642009-02-19 19:32:39 -05001680 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001681 int ret = 0;
1682 struct assoc_request * assoc_req;
1683
Holger Schurig9012b282007-05-25 11:27:16 -04001684 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001685
David Woodhouseaa21c002007-12-08 20:04:36 +00001686 mutex_lock(&priv->lock);
1687 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001688 if (!assoc_req) {
1689 ret = -ENOMEM;
1690 goto out;
1691 }
1692
1693 if (dwrq->length > MAX_WPA_IE_LEN ||
1694 (dwrq->length && extra == NULL)) {
1695 ret = -EINVAL;
1696 goto out;
1697 }
1698
1699 if (dwrq->length) {
1700 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
1701 assoc_req->wpa_ie_len = dwrq->length;
1702 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +00001703 memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001704 assoc_req->wpa_ie_len = 0;
1705 }
1706
1707out:
1708 if (ret == 0) {
1709 set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001710 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001711 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001712 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001713 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001714 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001715
Holger Schurig9012b282007-05-25 11:27:16 -04001716 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001717 return ret;
1718}
1719
Holger Schurig10078322007-11-15 18:05:47 -05001720static int lbs_get_genie(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001721 struct iw_request_info *info,
1722 struct iw_point *dwrq,
1723 char *extra)
1724{
Holger Schurig9012b282007-05-25 11:27:16 -04001725 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001726 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001727
Holger Schurig9012b282007-05-25 11:27:16 -04001728 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001729
David Woodhouseaa21c002007-12-08 20:04:36 +00001730 if (priv->wpa_ie_len == 0) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001731 dwrq->length = 0;
Holger Schurig9012b282007-05-25 11:27:16 -04001732 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001733 }
1734
David Woodhouseaa21c002007-12-08 20:04:36 +00001735 if (dwrq->length < priv->wpa_ie_len) {
Holger Schurig9012b282007-05-25 11:27:16 -04001736 ret = -E2BIG;
1737 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001738 }
1739
David Woodhouseaa21c002007-12-08 20:04:36 +00001740 dwrq->length = priv->wpa_ie_len;
1741 memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001742
Holger Schurig9012b282007-05-25 11:27:16 -04001743out:
1744 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1745 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001746}
1747
1748
Holger Schurig10078322007-11-15 18:05:47 -05001749static int lbs_set_auth(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001750 struct iw_request_info *info,
1751 struct iw_param *dwrq,
1752 char *extra)
1753{
Kiran Divekarab65f642009-02-19 19:32:39 -05001754 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001755 struct assoc_request * assoc_req;
1756 int ret = 0;
1757 int updated = 0;
1758
Holger Schurig9012b282007-05-25 11:27:16 -04001759 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001760
David Woodhouseaa21c002007-12-08 20:04:36 +00001761 mutex_lock(&priv->lock);
1762 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001763 if (!assoc_req) {
1764 ret = -ENOMEM;
1765 goto out;
1766 }
1767
1768 switch (dwrq->flags & IW_AUTH_INDEX) {
Maithili Hinge2c8d5102009-07-31 20:02:19 -07001769 case IW_AUTH_PRIVACY_INVOKED:
1770 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001771 case IW_AUTH_TKIP_COUNTERMEASURES:
1772 case IW_AUTH_CIPHER_PAIRWISE:
1773 case IW_AUTH_CIPHER_GROUP:
Dan Williams90a42212007-05-25 23:01:24 -04001774 case IW_AUTH_DROP_UNENCRYPTED:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001775 /*
1776 * libertas does not use these parameters
1777 */
1778 break;
1779
Javier Cardona9c40fc52008-09-16 18:08:39 -07001780 case IW_AUTH_KEY_MGMT:
1781 assoc_req->secinfo.key_mgmt = dwrq->value;
1782 updated = 1;
1783 break;
1784
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001785 case IW_AUTH_WPA_VERSION:
1786 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
1787 assoc_req->secinfo.WPAenabled = 0;
1788 assoc_req->secinfo.WPA2enabled = 0;
Dan Williams90a42212007-05-25 23:01:24 -04001789 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001790 }
1791 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
1792 assoc_req->secinfo.WPAenabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001793 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001794 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001795 }
1796 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
1797 assoc_req->secinfo.WPA2enabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001798 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001799 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001800 }
1801 updated = 1;
1802 break;
1803
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001804 case IW_AUTH_80211_AUTH_ALG:
1805 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
Dan Williams6affe782007-05-10 22:56:42 -04001806 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001807 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
Dan Williams6affe782007-05-10 22:56:42 -04001808 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001809 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
Dan Williams6affe782007-05-10 22:56:42 -04001810 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001811 } else {
1812 ret = -EINVAL;
1813 }
1814 updated = 1;
1815 break;
1816
1817 case IW_AUTH_WPA_ENABLED:
1818 if (dwrq->value) {
1819 if (!assoc_req->secinfo.WPAenabled &&
1820 !assoc_req->secinfo.WPA2enabled) {
1821 assoc_req->secinfo.WPAenabled = 1;
1822 assoc_req->secinfo.WPA2enabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001823 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001824 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001825 }
1826 } else {
1827 assoc_req->secinfo.WPAenabled = 0;
1828 assoc_req->secinfo.WPA2enabled = 0;
Dan Williams90a42212007-05-25 23:01:24 -04001829 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001830 }
1831 updated = 1;
1832 break;
1833
1834 default:
1835 ret = -EOPNOTSUPP;
1836 break;
1837 }
1838
1839out:
1840 if (ret == 0) {
1841 if (updated)
1842 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001843 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001844 } else if (ret != -EOPNOTSUPP) {
Holger Schurig10078322007-11-15 18:05:47 -05001845 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001846 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001847 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001848
Holger Schurig9012b282007-05-25 11:27:16 -04001849 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001850 return ret;
1851}
1852
Holger Schurig10078322007-11-15 18:05:47 -05001853static int lbs_get_auth(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001854 struct iw_request_info *info,
1855 struct iw_param *dwrq,
1856 char *extra)
1857{
Holger Schurig9012b282007-05-25 11:27:16 -04001858 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001859 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001860
Holger Schurig9012b282007-05-25 11:27:16 -04001861 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001862
1863 switch (dwrq->flags & IW_AUTH_INDEX) {
Javier Cardona9c40fc52008-09-16 18:08:39 -07001864 case IW_AUTH_KEY_MGMT:
1865 dwrq->value = priv->secinfo.key_mgmt;
1866 break;
1867
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001868 case IW_AUTH_WPA_VERSION:
1869 dwrq->value = 0;
David Woodhouseaa21c002007-12-08 20:04:36 +00001870 if (priv->secinfo.WPAenabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001871 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
David Woodhouseaa21c002007-12-08 20:04:36 +00001872 if (priv->secinfo.WPA2enabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001873 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
1874 if (!dwrq->value)
1875 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
1876 break;
1877
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001878 case IW_AUTH_80211_AUTH_ALG:
David Woodhouseaa21c002007-12-08 20:04:36 +00001879 dwrq->value = priv->secinfo.auth_mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001880 break;
1881
1882 case IW_AUTH_WPA_ENABLED:
David Woodhouseaa21c002007-12-08 20:04:36 +00001883 if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001884 dwrq->value = 1;
1885 break;
1886
1887 default:
Holger Schurig9012b282007-05-25 11:27:16 -04001888 ret = -EOPNOTSUPP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001889 }
1890
Holger Schurig9012b282007-05-25 11:27:16 -04001891 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1892 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001893}
1894
1895
Holger Schurig10078322007-11-15 18:05:47 -05001896static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001897 struct iw_param *vwrq, char *extra)
1898{
1899 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001900 struct lbs_private *priv = dev->ml_priv;
Dan Williams87c8c722008-08-19 15:15:35 -04001901 s16 dbm = (s16) vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001902
Holger Schurig9012b282007-05-25 11:27:16 -04001903 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001904
1905 if (vwrq->disabled) {
Dan Williamsd5db2df2008-08-21 17:51:07 -04001906 lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
Dan Williams87c8c722008-08-19 15:15:35 -04001907 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001908 }
1909
Dan Williams87c8c722008-08-19 15:15:35 -04001910 if (vwrq->fixed == 0) {
Anna Neal0112c9e2008-09-11 11:17:25 -07001911 /* User requests automatic tx power control, however there are
1912 * many auto tx settings. For now use firmware defaults until
1913 * we come up with a good way to expose these to the user. */
1914 if (priv->fwrelease < 0x09000000) {
1915 ret = lbs_set_power_adapt_cfg(priv, 1,
1916 POW_ADAPT_DEFAULT_P0,
1917 POW_ADAPT_DEFAULT_P1,
1918 POW_ADAPT_DEFAULT_P2);
1919 if (ret)
1920 goto out;
1921 }
1922 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1923 TPC_DEFAULT_P2, 1);
1924 if (ret)
1925 goto out;
Dan Williams87c8c722008-08-19 15:15:35 -04001926 dbm = priv->txpower_max;
1927 } else {
1928 /* Userspace check in iwrange if it should use dBm or mW,
1929 * therefore this should never happen... Jean II */
1930 if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
1931 ret = -EOPNOTSUPP;
1932 goto out;
1933 }
1934
Anna Neal0112c9e2008-09-11 11:17:25 -07001935 /* Validate requested power level against firmware allowed
1936 * levels */
Dan Williams87c8c722008-08-19 15:15:35 -04001937 if (priv->txpower_min && (dbm < priv->txpower_min)) {
1938 ret = -EINVAL;
1939 goto out;
1940 }
1941
1942 if (priv->txpower_max && (dbm > priv->txpower_max)) {
1943 ret = -EINVAL;
1944 goto out;
1945 }
Anna Neal0112c9e2008-09-11 11:17:25 -07001946 if (priv->fwrelease < 0x09000000) {
1947 ret = lbs_set_power_adapt_cfg(priv, 0,
1948 POW_ADAPT_DEFAULT_P0,
1949 POW_ADAPT_DEFAULT_P1,
1950 POW_ADAPT_DEFAULT_P2);
1951 if (ret)
1952 goto out;
1953 }
1954 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1955 TPC_DEFAULT_P2, 1);
1956 if (ret)
1957 goto out;
Dan Williams87c8c722008-08-19 15:15:35 -04001958 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001959
Dan Williamsd5db2df2008-08-21 17:51:07 -04001960 /* If the radio was off, turn it on */
1961 if (!priv->radio_on) {
1962 ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
1963 if (ret)
1964 goto out;
1965 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001966
Dan Williams87c8c722008-08-19 15:15:35 -04001967 lbs_deb_wext("txpower set %d dBm\n", dbm);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001968
Dan Williams87c8c722008-08-19 15:15:35 -04001969 ret = lbs_set_tx_power(priv, dbm);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001970
Dan Williams87c8c722008-08-19 15:15:35 -04001971out:
Holger Schurig9012b282007-05-25 11:27:16 -04001972 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001973 return ret;
1974}
1975
Holger Schurig10078322007-11-15 18:05:47 -05001976static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001977 struct iw_point *dwrq, char *extra)
1978{
Kiran Divekarab65f642009-02-19 19:32:39 -05001979 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001980
Holger Schurig9012b282007-05-25 11:27:16 -04001981 lbs_deb_enter(LBS_DEB_WEXT);
1982
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001983 /*
1984 * Note : if dwrq->flags != 0, we should get the relevant SSID from
1985 * the SSID list...
1986 */
1987
1988 /*
1989 * Get the current SSID
1990 */
David Woodhouseaa21c002007-12-08 20:04:36 +00001991 if (priv->connect_status == LBS_CONNECTED) {
1992 memcpy(extra, priv->curbssparams.ssid,
1993 priv->curbssparams.ssid_len);
1994 extra[priv->curbssparams.ssid_len] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001995 } else {
1996 memset(extra, 0, 32);
David Woodhouseaa21c002007-12-08 20:04:36 +00001997 extra[priv->curbssparams.ssid_len] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001998 }
1999 /*
2000 * If none, we may want to get the one that was set
2001 */
2002
David Woodhouseaa21c002007-12-08 20:04:36 +00002003 dwrq->length = priv->curbssparams.ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002004
2005 dwrq->flags = 1; /* active */
2006
Holger Schurig9012b282007-05-25 11:27:16 -04002007 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002008 return 0;
2009}
2010
Holger Schurig10078322007-11-15 18:05:47 -05002011static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002012 struct iw_point *dwrq, char *extra)
2013{
Kiran Divekarab65f642009-02-19 19:32:39 -05002014 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002015 int ret = 0;
Holger Schurig243e84e2009-10-22 15:30:47 +02002016 u8 ssid[IEEE80211_MAX_SSID_LEN];
Dan Williamsd8efea22007-05-28 23:54:55 -04002017 u8 ssid_len = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002018 struct assoc_request * assoc_req;
Dan Williamsd8efea22007-05-28 23:54:55 -04002019 int in_ssid_len = dwrq->length;
John W. Linville9387b7c2008-09-30 20:59:05 -04002020 DECLARE_SSID_BUF(ssid_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002021
Holger Schurig9012b282007-05-25 11:27:16 -04002022 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002023
Dan Williamsd5db2df2008-08-21 17:51:07 -04002024 if (!priv->radio_on) {
2025 ret = -EINVAL;
2026 goto out;
2027 }
2028
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002029 /* Check the size of the string */
Holger Schurig243e84e2009-10-22 15:30:47 +02002030 if (in_ssid_len > IEEE80211_MAX_SSID_LEN) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002031 ret = -E2BIG;
2032 goto out;
2033 }
2034
Dan Williamsd8efea22007-05-28 23:54:55 -04002035 memset(&ssid, 0, sizeof(ssid));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002036
Dan Williamsd8efea22007-05-28 23:54:55 -04002037 if (!dwrq->flags || !in_ssid_len) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002038 /* "any" SSID requested; leave SSID blank */
2039 } else {
2040 /* Specific SSID requested */
Dan Williamsd8efea22007-05-28 23:54:55 -04002041 memcpy(&ssid, extra, in_ssid_len);
2042 ssid_len = in_ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002043 }
2044
Dan Williamsd8efea22007-05-28 23:54:55 -04002045 if (!ssid_len) {
2046 lbs_deb_wext("requested any SSID\n");
2047 } else {
2048 lbs_deb_wext("requested SSID '%s'\n",
John W. Linville9387b7c2008-09-30 20:59:05 -04002049 print_ssid(ssid_buf, ssid, ssid_len));
Dan Williamsd8efea22007-05-28 23:54:55 -04002050 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002051
2052out:
David Woodhouseaa21c002007-12-08 20:04:36 +00002053 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002054 if (ret == 0) {
2055 /* Get or create the current association request */
David Woodhouseaa21c002007-12-08 20:04:36 +00002056 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002057 if (!assoc_req) {
2058 ret = -ENOMEM;
2059 } else {
2060 /* Copy the SSID to the association request */
Holger Schurig243e84e2009-10-22 15:30:47 +02002061 memcpy(&assoc_req->ssid, &ssid, IEEE80211_MAX_SSID_LEN);
Dan Williamsd8efea22007-05-28 23:54:55 -04002062 assoc_req->ssid_len = ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002063 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05002064 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002065 }
2066 }
2067
2068 /* Cancel the association request if there was an error */
2069 if (ret != 0) {
Holger Schurig10078322007-11-15 18:05:47 -05002070 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002071 }
2072
David Woodhouseaa21c002007-12-08 20:04:36 +00002073 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002074
Holger Schurig9012b282007-05-25 11:27:16 -04002075 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002076 return ret;
2077}
2078
David Woodhousef5956bf2007-12-11 19:30:57 -05002079static int lbs_mesh_get_essid(struct net_device *dev,
2080 struct iw_request_info *info,
2081 struct iw_point *dwrq, char *extra)
2082{
Kiran Divekarab65f642009-02-19 19:32:39 -05002083 struct lbs_private *priv = dev->ml_priv;
David Woodhousef5956bf2007-12-11 19:30:57 -05002084
2085 lbs_deb_enter(LBS_DEB_WEXT);
2086
2087 memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
2088
2089 dwrq->length = priv->mesh_ssid_len;
2090
2091 dwrq->flags = 1; /* active */
2092
2093 lbs_deb_leave(LBS_DEB_WEXT);
2094 return 0;
2095}
2096
2097static int lbs_mesh_set_essid(struct net_device *dev,
2098 struct iw_request_info *info,
2099 struct iw_point *dwrq, char *extra)
2100{
Kiran Divekarab65f642009-02-19 19:32:39 -05002101 struct lbs_private *priv = dev->ml_priv;
David Woodhousef5956bf2007-12-11 19:30:57 -05002102 int ret = 0;
2103
2104 lbs_deb_enter(LBS_DEB_WEXT);
2105
Dan Williamsd5db2df2008-08-21 17:51:07 -04002106 if (!priv->radio_on) {
2107 ret = -EINVAL;
2108 goto out;
2109 }
2110
David Woodhousef5956bf2007-12-11 19:30:57 -05002111 /* Check the size of the string */
Holger Schurig243e84e2009-10-22 15:30:47 +02002112 if (dwrq->length > IEEE80211_MAX_SSID_LEN) {
David Woodhousef5956bf2007-12-11 19:30:57 -05002113 ret = -E2BIG;
2114 goto out;
2115 }
2116
2117 if (!dwrq->flags || !dwrq->length) {
2118 ret = -EINVAL;
2119 goto out;
2120 } else {
2121 /* Specific SSID requested */
2122 memcpy(priv->mesh_ssid, extra, dwrq->length);
2123 priv->mesh_ssid_len = dwrq->length;
2124 }
2125
Javier Cardonaedaea5c2008-05-17 00:55:10 -07002126 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
Holger Schurigc14951f2009-10-22 15:30:50 +02002127 priv->channel);
David Woodhousef5956bf2007-12-11 19:30:57 -05002128 out:
2129 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2130 return ret;
2131}
2132
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002133/**
2134 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2135 *
2136 * @param dev A pointer to net_device structure
2137 * @param info A pointer to iw_request_info structure
2138 * @param awrq A pointer to iw_param structure
2139 * @param extra A pointer to extra data buf
2140 * @return 0 --success, otherwise fail
2141 */
Holger Schurig10078322007-11-15 18:05:47 -05002142static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002143 struct sockaddr *awrq, char *extra)
2144{
Kiran Divekarab65f642009-02-19 19:32:39 -05002145 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002146 struct assoc_request * assoc_req;
2147 int ret = 0;
2148
Holger Schurig9012b282007-05-25 11:27:16 -04002149 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002150
Dan Williamsd5db2df2008-08-21 17:51:07 -04002151 if (!priv->radio_on)
2152 return -EINVAL;
2153
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002154 if (awrq->sa_family != ARPHRD_ETHER)
2155 return -EINVAL;
2156
Johannes Berge1749612008-10-27 15:59:26 -07002157 lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002158
David Woodhouseaa21c002007-12-08 20:04:36 +00002159 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002160
2161 /* Get or create the current association request */
David Woodhouseaa21c002007-12-08 20:04:36 +00002162 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002163 if (!assoc_req) {
Holger Schurig10078322007-11-15 18:05:47 -05002164 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002165 ret = -ENOMEM;
2166 } else {
2167 /* Copy the BSSID to the association request */
2168 memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
2169 set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05002170 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002171 }
2172
David Woodhouseaa21c002007-12-08 20:04:36 +00002173 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002174
2175 return ret;
2176}
2177
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002178/*
2179 * iwconfig settable callbacks
2180 */
Holger Schurig10078322007-11-15 18:05:47 -05002181static const iw_handler lbs_handler[] = {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002182 (iw_handler) NULL, /* SIOCSIWCOMMIT */
Holger Schurig10078322007-11-15 18:05:47 -05002183 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002184 (iw_handler) NULL, /* SIOCSIWNWID */
2185 (iw_handler) NULL, /* SIOCGIWNWID */
Holger Schurig10078322007-11-15 18:05:47 -05002186 (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */
2187 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
2188 (iw_handler) lbs_set_mode, /* SIOCSIWMODE */
2189 (iw_handler) lbs_get_mode, /* SIOCGIWMODE */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002190 (iw_handler) NULL, /* SIOCSIWSENS */
2191 (iw_handler) NULL, /* SIOCGIWSENS */
2192 (iw_handler) NULL, /* SIOCSIWRANGE */
Holger Schurig10078322007-11-15 18:05:47 -05002193 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002194 (iw_handler) NULL, /* SIOCSIWPRIV */
2195 (iw_handler) NULL, /* SIOCGIWPRIV */
2196 (iw_handler) NULL, /* SIOCSIWSTATS */
2197 (iw_handler) NULL, /* SIOCGIWSTATS */
2198 iw_handler_set_spy, /* SIOCSIWSPY */
2199 iw_handler_get_spy, /* SIOCGIWSPY */
2200 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2201 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
Holger Schurig10078322007-11-15 18:05:47 -05002202 (iw_handler) lbs_set_wap, /* SIOCSIWAP */
2203 (iw_handler) lbs_get_wap, /* SIOCGIWAP */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002204 (iw_handler) NULL, /* SIOCSIWMLME */
2205 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
Holger Schurig10078322007-11-15 18:05:47 -05002206 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2207 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
2208 (iw_handler) lbs_set_essid, /* SIOCSIWESSID */
2209 (iw_handler) lbs_get_essid, /* SIOCGIWESSID */
2210 (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */
2211 (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002212 (iw_handler) NULL, /* -- hole -- */
2213 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002214 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2215 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2216 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2217 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2218 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2219 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2220 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2221 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2222 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2223 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2224 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2225 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2226 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2227 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002228 (iw_handler) NULL, /* -- hole -- */
2229 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002230 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2231 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2232 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2233 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2234 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2235 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002236 (iw_handler) NULL, /* SIOCSIWPMKSA */
2237};
2238
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002239static const iw_handler mesh_wlan_handler[] = {
2240 (iw_handler) NULL, /* SIOCSIWCOMMIT */
Holger Schurig10078322007-11-15 18:05:47 -05002241 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002242 (iw_handler) NULL, /* SIOCSIWNWID */
2243 (iw_handler) NULL, /* SIOCGIWNWID */
David Woodhouse823eaa22007-12-11 19:56:28 -05002244 (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
Holger Schurig10078322007-11-15 18:05:47 -05002245 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002246 (iw_handler) NULL, /* SIOCSIWMODE */
2247 (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
2248 (iw_handler) NULL, /* SIOCSIWSENS */
2249 (iw_handler) NULL, /* SIOCGIWSENS */
2250 (iw_handler) NULL, /* SIOCSIWRANGE */
Holger Schurig10078322007-11-15 18:05:47 -05002251 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002252 (iw_handler) NULL, /* SIOCSIWPRIV */
2253 (iw_handler) NULL, /* SIOCGIWPRIV */
2254 (iw_handler) NULL, /* SIOCSIWSTATS */
2255 (iw_handler) NULL, /* SIOCGIWSTATS */
2256 iw_handler_set_spy, /* SIOCSIWSPY */
2257 iw_handler_get_spy, /* SIOCGIWSPY */
2258 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2259 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2260 (iw_handler) NULL, /* SIOCSIWAP */
2261 (iw_handler) NULL, /* SIOCGIWAP */
2262 (iw_handler) NULL, /* SIOCSIWMLME */
2263 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
Holger Schurig10078322007-11-15 18:05:47 -05002264 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2265 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
David Woodhousef5956bf2007-12-11 19:30:57 -05002266 (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
2267 (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002268 (iw_handler) NULL, /* SIOCSIWNICKN */
2269 (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
2270 (iw_handler) NULL, /* -- hole -- */
2271 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002272 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2273 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2274 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2275 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2276 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2277 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2278 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2279 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2280 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2281 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2282 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2283 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2284 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2285 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002286 (iw_handler) NULL, /* -- hole -- */
2287 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002288 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2289 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2290 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2291 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2292 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2293 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002294 (iw_handler) NULL, /* SIOCSIWPMKSA */
2295};
Holger Schurig10078322007-11-15 18:05:47 -05002296struct iw_handler_def lbs_handler_def = {
2297 .num_standard = ARRAY_SIZE(lbs_handler),
2298 .standard = (iw_handler *) lbs_handler,
2299 .get_wireless_stats = lbs_get_wireless_stats,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002300};
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002301
2302struct iw_handler_def mesh_handler_def = {
Denis Chengff8ac602007-09-02 18:30:18 +08002303 .num_standard = ARRAY_SIZE(mesh_wlan_handler),
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002304 .standard = (iw_handler *) mesh_wlan_handler,
Holger Schurig10078322007-11-15 18:05:47 -05002305 .get_wireless_stats = lbs_get_wireless_stats,
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002306};