blob: dc63b33b01f0c2628b066b197da29cf12e427d44 [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 Schurigfea2b8e2009-10-22 15:30:56 +020048void lbs_send_disconnect_notification(struct lbs_private *priv)
49{
50 union iwreq_data wrqu;
51
52 memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
53 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
54 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
55}
56
Holger Schurig6e85e0b2009-10-22 15:30:52 +020057void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
58{
59 union iwreq_data iwrq;
60 u8 buf[50];
61
62 lbs_deb_enter(LBS_DEB_WEXT);
63
64 memset(&iwrq, 0, sizeof(union iwreq_data));
65 memset(buf, 0, sizeof(buf));
66
67 snprintf(buf, sizeof(buf) - 1, "%s", str);
68
69 iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN;
70
71 /* Send Event to upper layer */
72 lbs_deb_wext("event indication string %s\n", (char *)buf);
73 lbs_deb_wext("event indication length %d\n", iwrq.data.length);
74 lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str);
75
76 wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf);
77
78 lbs_deb_leave(LBS_DEB_WEXT);
79}
80
Amitkumar Karwar49125452009-09-30 20:04:38 -070081/**
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020082 * @brief Find the channel frequency power info with specific channel
83 *
David Woodhouseaa21c002007-12-08 20:04:36 +000084 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020085 * @param band it can be BAND_A, BAND_G or BAND_B
86 * @param channel the channel for looking
87 * @return A pointer to struct chan_freq_power structure or NULL if not find.
88 */
Holger Schurig69f90322007-11-23 15:43:44 +010089struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
David Woodhouseaa21c002007-12-08 20:04:36 +000090 struct lbs_private *priv,
Holger Schurig69f90322007-11-23 15:43:44 +010091 u8 band,
92 u16 channel)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020093{
94 struct chan_freq_power *cfp = NULL;
95 struct region_channel *rc;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020096 int i, j;
97
David Woodhouseaa21c002007-12-08 20:04:36 +000098 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
99 rc = &priv->region_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200100
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200101 if (!rc->valid || !rc->CFP)
102 continue;
103 if (rc->band != band)
104 continue;
105 for (i = 0; i < rc->nrcfp; i++) {
106 if (rc->CFP[i].channel == channel) {
107 cfp = &rc->CFP[i];
108 break;
109 }
110 }
111 }
112
113 if (!cfp && channel)
Holger Schurig10078322007-11-15 18:05:47 -0500114 lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
Holger Schurig9012b282007-05-25 11:27:16 -0400115 "cfp by band %d / channel %d\n", band, channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200116
117 return cfp;
118}
119
120/**
121 * @brief Find the channel frequency power info with specific frequency
122 *
David Woodhouseaa21c002007-12-08 20:04:36 +0000123 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200124 * @param band it can be BAND_A, BAND_G or BAND_B
125 * @param freq the frequency for looking
126 * @return A pointer to struct chan_freq_power structure or NULL if not find.
127 */
Holger Schurig69f90322007-11-23 15:43:44 +0100128static struct chan_freq_power *find_cfp_by_band_and_freq(
David Woodhouseaa21c002007-12-08 20:04:36 +0000129 struct lbs_private *priv,
Holger Schurig69f90322007-11-23 15:43:44 +0100130 u8 band,
131 u32 freq)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200132{
133 struct chan_freq_power *cfp = NULL;
134 struct region_channel *rc;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200135 int i, j;
136
David Woodhouseaa21c002007-12-08 20:04:36 +0000137 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
138 rc = &priv->region_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200139
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200140 if (!rc->valid || !rc->CFP)
141 continue;
142 if (rc->band != band)
143 continue;
144 for (i = 0; i < rc->nrcfp; i++) {
145 if (rc->CFP[i].freq == freq) {
146 cfp = &rc->CFP[i];
147 break;
148 }
149 }
150 }
151
152 if (!cfp && freq)
Holger Schurig9012b282007-05-25 11:27:16 -0400153 lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
154 "band %d / freq %d\n", band, freq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200155
156 return cfp;
157}
158
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200159/**
Dan Williams8c512762007-08-02 11:40:45 -0400160 * @brief Copy active data rates based on adapter mode and status
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200161 *
David Woodhouseaa21c002007-12-08 20:04:36 +0000162 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200163 * @param rate The buf to return the active rates
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200164 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000165static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200166{
Holger Schurig9012b282007-05-25 11:27:16 -0400167 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200168
David Woodhouseaa21c002007-12-08 20:04:36 +0000169 if ((priv->connect_status != LBS_CONNECTED) &&
170 (priv->mesh_connect_status != LBS_CONNECTED))
Holger Schurig10078322007-11-15 18:05:47 -0500171 memcpy(rates, lbs_bg_rates, MAX_RATES);
Dan Williams8c512762007-08-02 11:40:45 -0400172 else
David Woodhouseaa21c002007-12-08 20:04:36 +0000173 memcpy(rates, priv->curbssparams.rates, MAX_RATES);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200174
Dan Williams8c512762007-08-02 11:40:45 -0400175 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200176}
177
Holger Schurig10078322007-11-15 18:05:47 -0500178static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200179 char *cwrq, char *extra)
180{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200181
Holger Schurig9012b282007-05-25 11:27:16 -0400182 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200183
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400184 /* We could add support for 802.11n here as needed. Jean II */
185 snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200186
Holger Schurig9012b282007-05-25 11:27:16 -0400187 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200188 return 0;
189}
190
Holger Schurig10078322007-11-15 18:05:47 -0500191static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200192 struct iw_freq *fwrq, char *extra)
193{
Kiran Divekarab65f642009-02-19 19:32:39 -0500194 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200195 struct chan_freq_power *cfp;
196
Holger Schurig9012b282007-05-25 11:27:16 -0400197 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200198
David Woodhouseaa21c002007-12-08 20:04:36 +0000199 cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
Holger Schurigc14951f2009-10-22 15:30:50 +0200200 priv->channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200201
202 if (!cfp) {
Holger Schurigc14951f2009-10-22 15:30:50 +0200203 if (priv->channel)
Holger Schurig9012b282007-05-25 11:27:16 -0400204 lbs_deb_wext("invalid channel %d\n",
Holger Schurigc14951f2009-10-22 15:30:50 +0200205 priv->channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200206 return -EINVAL;
207 }
208
209 fwrq->m = (long)cfp->freq * 100000;
210 fwrq->e = 1;
211
Holger Schurig9012b282007-05-25 11:27:16 -0400212 lbs_deb_wext("freq %u\n", fwrq->m);
213 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200214 return 0;
215}
216
Holger Schurig10078322007-11-15 18:05:47 -0500217static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200218 struct sockaddr *awrq, char *extra)
219{
Kiran Divekarab65f642009-02-19 19:32:39 -0500220 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200221
Holger Schurig9012b282007-05-25 11:27:16 -0400222 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200223
David Woodhouseaa21c002007-12-08 20:04:36 +0000224 if (priv->connect_status == LBS_CONNECTED) {
225 memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200226 } else {
227 memset(awrq->sa_data, 0, ETH_ALEN);
228 }
229 awrq->sa_family = ARPHRD_ETHER;
230
Holger Schurig9012b282007-05-25 11:27:16 -0400231 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200232 return 0;
233}
234
Holger Schurig10078322007-11-15 18:05:47 -0500235static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200236 struct iw_point *dwrq, char *extra)
237{
Kiran Divekarab65f642009-02-19 19:32:39 -0500238 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200239
Holger Schurig9012b282007-05-25 11:27:16 -0400240 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200241
242 /*
243 * Check the size of the string
244 */
245
246 if (dwrq->length > 16) {
247 return -E2BIG;
248 }
249
David Woodhouseaa21c002007-12-08 20:04:36 +0000250 mutex_lock(&priv->lock);
251 memset(priv->nodename, 0, sizeof(priv->nodename));
252 memcpy(priv->nodename, extra, dwrq->length);
253 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200254
Holger Schurig9012b282007-05-25 11:27:16 -0400255 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200256 return 0;
257}
258
Holger Schurig10078322007-11-15 18:05:47 -0500259static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200260 struct iw_point *dwrq, char *extra)
261{
Kiran Divekarab65f642009-02-19 19:32:39 -0500262 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200263
Holger Schurig9012b282007-05-25 11:27:16 -0400264 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200265
David Woodhouseaa21c002007-12-08 20:04:36 +0000266 dwrq->length = strlen(priv->nodename);
267 memcpy(extra, priv->nodename, dwrq->length);
Holger Schurig04799fa2007-10-09 15:04:14 +0200268 extra[dwrq->length] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200269
Holger Schurig04799fa2007-10-09 15:04:14 +0200270 dwrq->flags = 1; /* active */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200271
Holger Schurig9012b282007-05-25 11:27:16 -0400272 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200273 return 0;
274}
275
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400276static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
277 struct iw_point *dwrq, char *extra)
278{
Kiran Divekarab65f642009-02-19 19:32:39 -0500279 struct lbs_private *priv = dev->ml_priv;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400280
281 lbs_deb_enter(LBS_DEB_WEXT);
282
283 /* Use nickname to indicate that mesh is on */
284
David Woodhouseaa21c002007-12-08 20:04:36 +0000285 if (priv->mesh_connect_status == LBS_CONNECTED) {
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400286 strncpy(extra, "Mesh", 12);
287 extra[12] = '\0';
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400288 dwrq->length = strlen(extra);
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400289 }
290
291 else {
292 extra[0] = '\0';
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400293 dwrq->length = 0;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400294 }
295
296 lbs_deb_leave(LBS_DEB_WEXT);
297 return 0;
298}
Holger Schurig04799fa2007-10-09 15:04:14 +0200299
Holger Schurig10078322007-11-15 18:05:47 -0500300static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200301 struct iw_param *vwrq, char *extra)
302{
303 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -0500304 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400305 u32 val = vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200306
Holger Schurig9012b282007-05-25 11:27:16 -0400307 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200308
Dan Williams39fcf7a2008-09-10 12:49:00 -0400309 if (vwrq->disabled)
310 val = MRVDRV_RTS_MAX_VALUE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200311
John W. Linville375da532008-09-15 17:25:54 -0400312 if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */
Dan Williams39fcf7a2008-09-10 12:49:00 -0400313 return -EINVAL;
314
315 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200316
Holger Schurig9012b282007-05-25 11:27:16 -0400317 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200318 return ret;
319}
320
Holger Schurig10078322007-11-15 18:05:47 -0500321static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200322 struct iw_param *vwrq, char *extra)
323{
Kiran Divekarab65f642009-02-19 19:32:39 -0500324 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400325 int ret = 0;
326 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200327
Holger Schurig9012b282007-05-25 11:27:16 -0400328 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200329
Dan Williams39fcf7a2008-09-10 12:49:00 -0400330 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
Holger Schurig9012b282007-05-25 11:27:16 -0400331 if (ret)
332 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200333
Dan Williams39fcf7a2008-09-10 12:49:00 -0400334 vwrq->value = val;
John W. Linville375da532008-09-15 17:25:54 -0400335 vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200336 vwrq->fixed = 1;
337
Holger Schurig9012b282007-05-25 11:27:16 -0400338out:
339 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
340 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200341}
342
Holger Schurig10078322007-11-15 18:05:47 -0500343static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200344 struct iw_param *vwrq, char *extra)
345{
Kiran Divekarab65f642009-02-19 19:32:39 -0500346 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400347 int ret = 0;
348 u32 val = vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200349
Holger Schurig9012b282007-05-25 11:27:16 -0400350 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200351
Dan Williams39fcf7a2008-09-10 12:49:00 -0400352 if (vwrq->disabled)
353 val = MRVDRV_FRAG_MAX_VALUE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200354
Dan Williams39fcf7a2008-09-10 12:49:00 -0400355 if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
356 return -EINVAL;
357
358 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
Holger Schurig9012b282007-05-25 11:27:16 -0400359
360 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200361 return ret;
362}
363
Holger Schurig10078322007-11-15 18:05:47 -0500364static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200365 struct iw_param *vwrq, char *extra)
366{
Kiran Divekarab65f642009-02-19 19:32:39 -0500367 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400368 int ret = 0;
369 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200370
Holger Schurig9012b282007-05-25 11:27:16 -0400371 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200372
Dan Williams39fcf7a2008-09-10 12:49:00 -0400373 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
Holger Schurig9012b282007-05-25 11:27:16 -0400374 if (ret)
375 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200376
Dan Williams39fcf7a2008-09-10 12:49:00 -0400377 vwrq->value = val;
378 vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
379 || (val > MRVDRV_FRAG_MAX_VALUE));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200380 vwrq->fixed = 1;
381
Holger Schurig9012b282007-05-25 11:27:16 -0400382out:
383 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200384 return ret;
385}
386
Holger Schurig10078322007-11-15 18:05:47 -0500387static int lbs_get_mode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200388 struct iw_request_info *info, u32 * uwrq, char *extra)
389{
Kiran Divekarab65f642009-02-19 19:32:39 -0500390 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200391
Holger Schurig9012b282007-05-25 11:27:16 -0400392 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200393
David Woodhouseaa21c002007-12-08 20:04:36 +0000394 *uwrq = priv->mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200395
Holger Schurig9012b282007-05-25 11:27:16 -0400396 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200397 return 0;
398}
399
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400400static int mesh_wlan_get_mode(struct net_device *dev,
401 struct iw_request_info *info, u32 * uwrq,
402 char *extra)
403{
404 lbs_deb_enter(LBS_DEB_WEXT);
405
Dan Williams39fcf7a2008-09-10 12:49:00 -0400406 *uwrq = IW_MODE_REPEAT;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400407
408 lbs_deb_leave(LBS_DEB_WEXT);
409 return 0;
410}
411
Holger Schurig10078322007-11-15 18:05:47 -0500412static int lbs_get_txpow(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200413 struct iw_request_info *info,
414 struct iw_param *vwrq, char *extra)
415{
Kiran Divekarab65f642009-02-19 19:32:39 -0500416 struct lbs_private *priv = dev->ml_priv;
Dan Williams87c8c722008-08-19 15:15:35 -0400417 s16 curlevel = 0;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400418 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200419
Holger Schurig9012b282007-05-25 11:27:16 -0400420 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200421
Dan Williamsd5db2df2008-08-21 17:51:07 -0400422 if (!priv->radio_on) {
423 lbs_deb_wext("tx power off\n");
424 vwrq->value = 0;
425 vwrq->disabled = 1;
426 goto out;
427 }
428
Dan Williams87c8c722008-08-19 15:15:35 -0400429 ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
Holger Schurig9012b282007-05-25 11:27:16 -0400430 if (ret)
431 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200432
Dan Williams87c8c722008-08-19 15:15:35 -0400433 lbs_deb_wext("tx power level %d dbm\n", curlevel);
Dan Williams87c8c722008-08-19 15:15:35 -0400434 priv->txpower_cur = curlevel;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400435
Dan Williams87c8c722008-08-19 15:15:35 -0400436 vwrq->value = curlevel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200437 vwrq->fixed = 1;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400438 vwrq->disabled = 0;
439 vwrq->flags = IW_TXPOW_DBM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200440
Holger Schurig9012b282007-05-25 11:27:16 -0400441out:
442 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
443 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200444}
445
Holger Schurig10078322007-11-15 18:05:47 -0500446static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200447 struct iw_param *vwrq, char *extra)
448{
Kiran Divekarab65f642009-02-19 19:32:39 -0500449 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400450 int ret = 0;
451 u16 slimit = 0, llimit = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200452
Holger Schurig9012b282007-05-25 11:27:16 -0400453 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200454
Dan Williams39fcf7a2008-09-10 12:49:00 -0400455 if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
456 return -EOPNOTSUPP;
457
458 /* The MAC has a 4-bit Total_Tx_Count register
459 Total_Tx_Count = 1 + Tx_Retry_Count */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200460#define TX_RETRY_MIN 0
461#define TX_RETRY_MAX 14
Dan Williams39fcf7a2008-09-10 12:49:00 -0400462 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
463 return -EINVAL;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200464
Dan Williams39fcf7a2008-09-10 12:49:00 -0400465 /* Add 1 to convert retry count to try count */
466 if (vwrq->flags & IW_RETRY_SHORT)
467 slimit = (u16) (vwrq->value + 1);
468 else if (vwrq->flags & IW_RETRY_LONG)
469 llimit = (u16) (vwrq->value + 1);
470 else
471 slimit = llimit = (u16) (vwrq->value + 1); /* set both */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200472
Dan Williams39fcf7a2008-09-10 12:49:00 -0400473 if (llimit) {
474 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
475 llimit);
Holger Schurig9012b282007-05-25 11:27:16 -0400476 if (ret)
477 goto out;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400478 }
479
480 if (slimit) {
481 /* txretrycount follows the short retry limit */
482 priv->txretrycount = slimit;
483 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
484 slimit);
485 if (ret)
486 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200487 }
488
Holger Schurig9012b282007-05-25 11:27:16 -0400489out:
490 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
491 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200492}
493
Holger Schurig10078322007-11-15 18:05:47 -0500494static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200495 struct iw_param *vwrq, char *extra)
496{
Kiran Divekarab65f642009-02-19 19:32:39 -0500497 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200498 int ret = 0;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400499 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200500
Holger Schurig9012b282007-05-25 11:27:16 -0400501 lbs_deb_enter(LBS_DEB_WEXT);
502
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200503 vwrq->disabled = 0;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400504
505 if (vwrq->flags & IW_RETRY_LONG) {
506 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
507 if (ret)
508 goto out;
509
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200510 /* Subtract 1 to convert try count to retry count */
Dan Williams39fcf7a2008-09-10 12:49:00 -0400511 vwrq->value = val - 1;
512 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
513 } else {
514 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
515 if (ret)
516 goto out;
517
518 /* txretry count follows the short retry limit */
519 priv->txretrycount = val;
520 /* Subtract 1 to convert try count to retry count */
521 vwrq->value = val - 1;
522 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200523 }
524
Holger Schurig9012b282007-05-25 11:27:16 -0400525out:
526 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
527 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200528}
529
530static inline void sort_channels(struct iw_freq *freq, int num)
531{
532 int i, j;
533 struct iw_freq temp;
534
535 for (i = 0; i < num; i++)
536 for (j = i + 1; j < num; j++)
537 if (freq[i].i > freq[j].i) {
538 temp.i = freq[i].i;
539 temp.m = freq[i].m;
540
541 freq[i].i = freq[j].i;
542 freq[i].m = freq[j].m;
543
544 freq[j].i = temp.i;
545 freq[j].m = temp.m;
546 }
547}
548
549/* data rate listing
550 MULTI_BANDS:
551 abg a b b/g
552 Infra G(12) A(8) B(4) G(12)
553 Adhoc A+B(12) A(8) B(4) B(4)
554
555 non-MULTI_BANDS:
556 b b/g
557 Infra B(4) G(12)
558 Adhoc B(4) B(4)
559 */
560/**
561 * @brief Get Range Info
562 *
563 * @param dev A pointer to net_device structure
564 * @param info A pointer to iw_request_info structure
565 * @param vwrq A pointer to iw_param structure
566 * @param extra A pointer to extra data buf
567 * @return 0 --success, otherwise fail
568 */
Holger Schurig10078322007-11-15 18:05:47 -0500569static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200570 struct iw_point *dwrq, char *extra)
571{
572 int i, j;
Kiran Divekarab65f642009-02-19 19:32:39 -0500573 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200574 struct iw_range *range = (struct iw_range *)extra;
575 struct chan_freq_power *cfp;
Dan Williams8c512762007-08-02 11:40:45 -0400576 u8 rates[MAX_RATES + 1];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200577
Holger Schurig9012b282007-05-25 11:27:16 -0400578 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200579
580 dwrq->length = sizeof(struct iw_range);
581 memset(range, 0, sizeof(struct iw_range));
582
583 range->min_nwid = 0;
584 range->max_nwid = 0;
585
586 memset(rates, 0, sizeof(rates));
David Woodhouseaa21c002007-12-08 20:04:36 +0000587 copy_active_data_rates(priv, rates);
Dan Williams8c512762007-08-02 11:40:45 -0400588 range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
589 for (i = 0; i < range->num_bitrates; i++)
590 range->bitrate[i] = rates[i] * 500000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200591 range->num_bitrates = i;
Holger Schurig9012b282007-05-25 11:27:16 -0400592 lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200593 range->num_bitrates);
594
595 range->num_frequency = 0;
Holger Schurig52933d82008-03-05 07:05:32 +0100596
597 range->scan_capa = IW_SCAN_CAPA_ESSID;
598
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200599 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
600 && (j < ARRAY_SIZE(priv->region_channel)); j++) {
601 cfp = priv->region_channel[j].CFP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200602 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200603 && priv->region_channel[j].valid
604 && cfp
605 && (i < priv->region_channel[j].nrcfp); i++) {
606 range->freq[range->num_frequency].i =
607 (long)cfp->channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200608 range->freq[range->num_frequency].m =
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200609 (long)cfp->freq * 100000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200610 range->freq[range->num_frequency].e = 1;
Holger Schurigd37b4fd2009-10-22 15:30:45 +0200611 cfp++;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200612 range->num_frequency++;
613 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200614 }
615
Holger Schurig9012b282007-05-25 11:27:16 -0400616 lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200617 IW_MAX_FREQUENCIES, range->num_frequency);
618
619 range->num_channels = range->num_frequency;
620
621 sort_channels(&range->freq[0], range->num_frequency);
622
623 /*
624 * Set an indication of the max TCP throughput in bit/s that we can
625 * expect using this interface
626 */
627 if (i > 2)
628 range->throughput = 5000 * 1000;
629 else
630 range->throughput = 1500 * 1000;
631
632 range->min_rts = MRVDRV_RTS_MIN_VALUE;
633 range->max_rts = MRVDRV_RTS_MAX_VALUE;
634 range->min_frag = MRVDRV_FRAG_MIN_VALUE;
635 range->max_frag = MRVDRV_FRAG_MAX_VALUE;
636
637 range->encoding_size[0] = 5;
638 range->encoding_size[1] = 13;
639 range->num_encoding_sizes = 2;
640 range->max_encoding_tokens = 4;
641
Holger Schurigd4ff0ef2008-03-19 14:25:18 +0100642 /*
643 * Right now we support only "iwconfig ethX power on|off"
644 */
645 range->pm_capa = IW_POWER_ON;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200646
647 /*
648 * Minimum version we recommend
649 */
650 range->we_version_source = 15;
651
652 /*
653 * Version we are compiled with
654 */
655 range->we_version_compiled = WIRELESS_EXT;
656
657 range->retry_capa = IW_RETRY_LIMIT;
658 range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
659
660 range->min_retry = TX_RETRY_MIN;
661 range->max_retry = TX_RETRY_MAX;
662
663 /*
664 * Set the qual, level and noise range values
665 */
666 range->max_qual.qual = 100;
667 range->max_qual.level = 0;
668 range->max_qual.noise = 0;
669 range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
670
671 range->avg_qual.qual = 70;
672 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
673 range->avg_qual.level = 0;
674 range->avg_qual.noise = 0;
675 range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
676
677 range->sensitivity = 0;
678
Dan Williams87c8c722008-08-19 15:15:35 -0400679 /* Setup the supported power level ranges */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200680 memset(range->txpower, 0, sizeof(range->txpower));
Dan Williams87c8c722008-08-19 15:15:35 -0400681 range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE;
682 range->txpower[0] = priv->txpower_min;
683 range->txpower[1] = priv->txpower_max;
684 range->num_txpower = 2;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200685
686 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
687 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
688 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
689 range->event_capa[1] = IW_EVENT_CAPA_K_1;
690
David Woodhouseaa21c002007-12-08 20:04:36 +0000691 if (priv->fwcapinfo & FW_CAPINFO_WPA) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200692 range->enc_capa = IW_ENC_CAPA_WPA
693 | IW_ENC_CAPA_WPA2
694 | IW_ENC_CAPA_CIPHER_TKIP
695 | IW_ENC_CAPA_CIPHER_CCMP;
696 }
697
Holger Schurig9012b282007-05-25 11:27:16 -0400698 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200699 return 0;
700}
701
Holger Schurig10078322007-11-15 18:05:47 -0500702static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200703 struct iw_param *vwrq, char *extra)
704{
Kiran Divekarab65f642009-02-19 19:32:39 -0500705 struct lbs_private *priv = dev->ml_priv;
Amitkumar Karwar49125452009-09-30 20:04:38 -0700706 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200707
Holger Schurig9012b282007-05-25 11:27:16 -0400708 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200709
Andrey Yurovskye0d61332009-06-16 13:20:01 -0700710 if (!(priv->fwcapinfo & FW_CAPINFO_PS)) {
David Woodhouseb2c57ee2007-12-17 14:41:13 -0500711 if (vwrq->disabled)
712 return 0;
713 else
714 return -EINVAL;
715 }
716
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200717 /* PS is currently supported only in Infrastructure mode
718 * Remove this check if it is to be supported in IBSS mode also
719 */
720
721 if (vwrq->disabled) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000722 priv->psmode = LBS802_11POWERMODECAM;
723 if (priv->psstate != PS_STATE_FULL_POWER) {
Holger Schurig10078322007-11-15 18:05:47 -0500724 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200725 }
726
727 return 0;
728 }
729
730 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
Holger Schurig9012b282007-05-25 11:27:16 -0400731 lbs_deb_wext(
732 "setting power timeout is not supported\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200733 return -EINVAL;
734 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
Amitkumar Karwar49125452009-09-30 20:04:38 -0700735 vwrq->value = vwrq->value / 1000;
736 if (!priv->enter_deep_sleep) {
737 lbs_pr_err("deep sleep feature is not implemented "
738 "for this interface driver\n");
739 return -EINVAL;
740 }
741
742 if (priv->connect_status == LBS_CONNECTED) {
743 if ((priv->is_auto_deep_sleep_enabled) &&
744 (vwrq->value == -1000)) {
745 lbs_exit_auto_deep_sleep(priv);
746 return 0;
747 } else {
748 lbs_pr_err("can't use deep sleep cmd in "
749 "connected state\n");
750 return -EINVAL;
751 }
752 }
753
754 if ((vwrq->value < 0) && (vwrq->value != -1000)) {
755 lbs_pr_err("unknown option\n");
756 return -EINVAL;
757 }
758
759 if (vwrq->value > 0) {
760 if (!priv->is_auto_deep_sleep_enabled) {
761 priv->is_activity_detected = 0;
762 priv->auto_deep_sleep_timeout = vwrq->value;
763 lbs_enter_auto_deep_sleep(priv);
764 } else {
765 priv->auto_deep_sleep_timeout = vwrq->value;
766 lbs_deb_debugfs("auto deep sleep: "
767 "already enabled\n");
768 }
769 return 0;
770 } else {
771 if (priv->is_auto_deep_sleep_enabled) {
772 lbs_exit_auto_deep_sleep(priv);
773 /* Try to exit deep sleep if auto */
774 /*deep sleep disabled */
775 ret = lbs_set_deep_sleep(priv, 0);
776 }
777 if (vwrq->value == 0)
778 ret = lbs_set_deep_sleep(priv, 1);
779 else if (vwrq->value == -1000)
780 ret = lbs_set_deep_sleep(priv, 0);
781 return ret;
782 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200783 }
784
David Woodhouseaa21c002007-12-08 20:04:36 +0000785 if (priv->psmode != LBS802_11POWERMODECAM) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200786 return 0;
787 }
788
David Woodhouseaa21c002007-12-08 20:04:36 +0000789 priv->psmode = LBS802_11POWERMODEMAX_PSP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200790
David Woodhouseaa21c002007-12-08 20:04:36 +0000791 if (priv->connect_status == LBS_CONNECTED) {
Holger Schurig10078322007-11-15 18:05:47 -0500792 lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200793 }
794
Holger Schurig9012b282007-05-25 11:27:16 -0400795 lbs_deb_leave(LBS_DEB_WEXT);
Amitkumar Karwar49125452009-09-30 20:04:38 -0700796
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200797 return 0;
798}
799
Holger Schurig10078322007-11-15 18:05:47 -0500800static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200801 struct iw_param *vwrq, char *extra)
802{
Kiran Divekarab65f642009-02-19 19:32:39 -0500803 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200804
Holger Schurig9012b282007-05-25 11:27:16 -0400805 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200806
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200807 vwrq->value = 0;
Holger Schurigd4ff0ef2008-03-19 14:25:18 +0100808 vwrq->flags = 0;
809 vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM
810 || priv->connect_status == LBS_DISCONNECTED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200811
Holger Schurig9012b282007-05-25 11:27:16 -0400812 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200813 return 0;
814}
815
Holger Schurig10078322007-11-15 18:05:47 -0500816static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200817{
818 enum {
819 POOR = 30,
820 FAIR = 60,
821 GOOD = 80,
822 VERY_GOOD = 90,
823 EXCELLENT = 95,
824 PERFECT = 100
825 };
Kiran Divekarab65f642009-02-19 19:32:39 -0500826 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200827 u32 rssi_qual;
828 u32 tx_qual;
829 u32 quality = 0;
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700830 int ret, stats_valid = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200831 u8 rssi;
832 u32 tx_retries;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100833 struct cmd_ds_802_11_get_log log;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200834
Holger Schurig9012b282007-05-25 11:27:16 -0400835 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200836
David Woodhouseaa21c002007-12-08 20:04:36 +0000837 priv->wstats.status = priv->mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200838
839 /* If we're not associated, all quality values are meaningless */
David Woodhouseaa21c002007-12-08 20:04:36 +0000840 if ((priv->connect_status != LBS_CONNECTED) &&
841 (priv->mesh_connect_status != LBS_CONNECTED))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200842 goto out;
843
844 /* Quality by RSSI */
845 priv->wstats.qual.level =
David Woodhouseaa21c002007-12-08 20:04:36 +0000846 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
847 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200848
David Woodhouseaa21c002007-12-08 20:04:36 +0000849 if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200850 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
851 } else {
852 priv->wstats.qual.noise =
David Woodhouseaa21c002007-12-08 20:04:36 +0000853 CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200854 }
855
Holger Schurig9012b282007-05-25 11:27:16 -0400856 lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
857 lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200858
859 rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
860 if (rssi < 15)
861 rssi_qual = rssi * POOR / 10;
862 else if (rssi < 20)
863 rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
864 else if (rssi < 30)
865 rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
866 else if (rssi < 40)
867 rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
868 10 + GOOD;
869 else
870 rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
871 10 + VERY_GOOD;
872 quality = rssi_qual;
873
874 /* Quality by TX errors */
Stephen Hemmingerbbfc6b72009-03-20 19:36:36 +0000875 priv->wstats.discard.retries = dev->stats.tx_errors;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200876
Holger Schurigc49c3b72008-03-17 12:45:58 +0100877 memset(&log, 0, sizeof(log));
878 log.hdr.size = cpu_to_le16(sizeof(log));
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700879 ret = lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
880 if (ret)
881 goto out;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100882
883 tx_retries = le32_to_cpu(log.retry);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200884
885 if (tx_retries > 75)
886 tx_qual = (90 - tx_retries) * POOR / 15;
887 else if (tx_retries > 70)
888 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
889 else if (tx_retries > 65)
890 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
891 else if (tx_retries > 50)
892 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
893 15 + GOOD;
894 else
895 tx_qual = (50 - tx_retries) *
896 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
897 quality = min(quality, tx_qual);
898
Holger Schurigc49c3b72008-03-17 12:45:58 +0100899 priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200900 priv->wstats.discard.retries = tx_retries;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100901 priv->wstats.discard.misc = le32_to_cpu(log.ackfailure);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200902
903 /* Calculate quality */
Holger Schurigcad9d9b2007-08-02 13:07:15 -0400904 priv->wstats.qual.qual = min_t(u8, quality, 100);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200905 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
906 stats_valid = 1;
907
908 /* update stats asynchronously for future calls */
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700909 ret = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200910 0, 0, NULL);
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700911 if (ret)
912 lbs_pr_err("RSSI command failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200913out:
914 if (!stats_valid) {
915 priv->wstats.miss.beacon = 0;
916 priv->wstats.discard.retries = 0;
917 priv->wstats.qual.qual = 0;
918 priv->wstats.qual.level = 0;
919 priv->wstats.qual.noise = 0;
920 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
921 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
922 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
923 }
924
Holger Schurig9012b282007-05-25 11:27:16 -0400925 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200926 return &priv->wstats;
927
928
929}
930
Holger Schurig10078322007-11-15 18:05:47 -0500931static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200932 struct iw_freq *fwrq, char *extra)
933{
Dan Williamsef9a2642007-05-25 16:46:33 -0400934 int ret = -EINVAL;
Kiran Divekarab65f642009-02-19 19:32:39 -0500935 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200936 struct chan_freq_power *cfp;
Dan Williamsef9a2642007-05-25 16:46:33 -0400937 struct assoc_request * assoc_req;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200938
Holger Schurig9012b282007-05-25 11:27:16 -0400939 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200940
David Woodhouseaa21c002007-12-08 20:04:36 +0000941 mutex_lock(&priv->lock);
942 assoc_req = lbs_get_association_request(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400943 if (!assoc_req) {
944 ret = -ENOMEM;
945 goto out;
946 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200947
Dan Williamsef9a2642007-05-25 16:46:33 -0400948 /* If setting by frequency, convert to a channel */
949 if (fwrq->e == 1) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200950 long f = fwrq->m / 100000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200951
David Woodhouseaa21c002007-12-08 20:04:36 +0000952 cfp = find_cfp_by_band_and_freq(priv, 0, f);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200953 if (!cfp) {
Holger Schurig9012b282007-05-25 11:27:16 -0400954 lbs_deb_wext("invalid freq %ld\n", f);
Dan Williamsef9a2642007-05-25 16:46:33 -0400955 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200956 }
957
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200958 fwrq->e = 0;
Dan Williamsef9a2642007-05-25 16:46:33 -0400959 fwrq->m = (int) cfp->channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200960 }
961
Dan Williamsef9a2642007-05-25 16:46:33 -0400962 /* Setting by channel number */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200963 if (fwrq->m > 1000 || fwrq->e > 0) {
Dan Williamsef9a2642007-05-25 16:46:33 -0400964 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200965 }
966
David Woodhouseaa21c002007-12-08 20:04:36 +0000967 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
Dan Williamsef9a2642007-05-25 16:46:33 -0400968 if (!cfp) {
969 goto out;
970 }
971
972 assoc_req->channel = fwrq->m;
973 ret = 0;
974
Holger Schurig9012b282007-05-25 11:27:16 -0400975out:
Dan Williamsef9a2642007-05-25 16:46:33 -0400976 if (ret == 0) {
977 set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -0500978 lbs_postpone_association_work(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400979 } else {
Holger Schurig10078322007-11-15 18:05:47 -0500980 lbs_cancel_association_work(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400981 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000982 mutex_unlock(&priv->lock);
Dan Williamsef9a2642007-05-25 16:46:33 -0400983
984 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
985 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200986}
987
David Woodhouse823eaa22007-12-11 19:56:28 -0500988static int lbs_mesh_set_freq(struct net_device *dev,
989 struct iw_request_info *info,
990 struct iw_freq *fwrq, char *extra)
991{
Kiran Divekarab65f642009-02-19 19:32:39 -0500992 struct lbs_private *priv = dev->ml_priv;
David Woodhouse823eaa22007-12-11 19:56:28 -0500993 struct chan_freq_power *cfp;
994 int ret = -EINVAL;
995
996 lbs_deb_enter(LBS_DEB_WEXT);
997
998 /* If setting by frequency, convert to a channel */
999 if (fwrq->e == 1) {
1000 long f = fwrq->m / 100000;
1001
1002 cfp = find_cfp_by_band_and_freq(priv, 0, f);
1003 if (!cfp) {
1004 lbs_deb_wext("invalid freq %ld\n", f);
1005 goto out;
1006 }
1007
1008 fwrq->e = 0;
1009 fwrq->m = (int) cfp->channel;
1010 }
1011
1012 /* Setting by channel number */
1013 if (fwrq->m > 1000 || fwrq->e > 0) {
1014 goto out;
1015 }
1016
1017 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
1018 if (!cfp) {
1019 goto out;
1020 }
1021
Holger Schurigc14951f2009-10-22 15:30:50 +02001022 if (fwrq->m != priv->channel) {
David Woodhouse823eaa22007-12-11 19:56:28 -05001023 lbs_deb_wext("mesh channel change forces eth disconnect\n");
1024 if (priv->mode == IW_MODE_INFRA)
Dan Williams191bb402008-08-21 17:46:18 -04001025 lbs_cmd_80211_deauthenticate(priv,
1026 priv->curbssparams.bssid,
1027 WLAN_REASON_DEAUTH_LEAVING);
David Woodhouse823eaa22007-12-11 19:56:28 -05001028 else if (priv->mode == IW_MODE_ADHOC)
Dan Williamsf5fe1fd2008-08-21 21:46:59 -04001029 lbs_adhoc_stop(priv);
David Woodhouse823eaa22007-12-11 19:56:28 -05001030 }
Javier Cardonaedaea5c2008-05-17 00:55:10 -07001031 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m);
David Woodhouse86062132007-12-13 00:32:36 -05001032 lbs_update_channel(priv);
David Woodhouse823eaa22007-12-11 19:56:28 -05001033 ret = 0;
1034
1035out:
1036 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1037 return ret;
1038}
1039
Holger Schurig10078322007-11-15 18:05:47 -05001040static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001041 struct iw_param *vwrq, char *extra)
1042{
Kiran Divekarab65f642009-02-19 19:32:39 -05001043 struct lbs_private *priv = dev->ml_priv;
Dan Williams8e3c91b2007-12-11 15:50:59 -05001044 u8 new_rate = 0;
Dan Williams8c512762007-08-02 11:40:45 -04001045 int ret = -EINVAL;
1046 u8 rates[MAX_RATES + 1];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001047
Holger Schurig9012b282007-05-25 11:27:16 -04001048 lbs_deb_enter(LBS_DEB_WEXT);
Amitkumar Karwar49125452009-09-30 20:04:38 -07001049
Holger Schurig9012b282007-05-25 11:27:16 -04001050 lbs_deb_wext("vwrq->value %d\n", vwrq->value);
Javier Cardona85319f92008-05-24 10:59:49 +01001051 lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed);
1052
1053 if (vwrq->fixed && vwrq->value == -1)
1054 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001055
Dan Williams8c512762007-08-02 11:40:45 -04001056 /* Auto rate? */
Javier Cardona85319f92008-05-24 10:59:49 +01001057 priv->enablehwauto = !vwrq->fixed;
1058
1059 if (vwrq->value == -1)
David Woodhouseaa21c002007-12-08 20:04:36 +00001060 priv->cur_rate = 0;
Javier Cardona85319f92008-05-24 10:59:49 +01001061 else {
Dan Williams8c512762007-08-02 11:40:45 -04001062 if (vwrq->value % 100000)
1063 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001064
Javier Cardona85319f92008-05-24 10:59:49 +01001065 new_rate = vwrq->value / 500000;
1066 priv->cur_rate = new_rate;
1067 /* the rest is only needed for lbs_set_data_rate() */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001068 memset(rates, 0, sizeof(rates));
David Woodhouseaa21c002007-12-08 20:04:36 +00001069 copy_active_data_rates(priv, rates);
Dan Williams8c512762007-08-02 11:40:45 -04001070 if (!memchr(rates, new_rate, sizeof(rates))) {
1071 lbs_pr_alert("fixed data rate 0x%X out of range\n",
1072 new_rate);
1073 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001074 }
Anna Neal3ed6e082008-09-26 11:34:35 -04001075 if (priv->fwrelease < 0x09000000) {
1076 ret = lbs_set_power_adapt_cfg(priv, 0,
1077 POW_ADAPT_DEFAULT_P0,
1078 POW_ADAPT_DEFAULT_P1,
1079 POW_ADAPT_DEFAULT_P2);
1080 if (ret)
1081 goto out;
1082 }
1083 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1084 TPC_DEFAULT_P2, 1);
1085 if (ret)
1086 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001087 }
1088
Javier Cardona85319f92008-05-24 10:59:49 +01001089 /* Try the newer command first (Firmware Spec 5.1 and above) */
1090 ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET);
1091
1092 /* Fallback to older version */
1093 if (ret)
1094 ret = lbs_set_data_rate(priv, new_rate);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001095
Dan Williams8c512762007-08-02 11:40:45 -04001096out:
Holger Schurig9012b282007-05-25 11:27:16 -04001097 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001098 return ret;
1099}
1100
Holger Schurig10078322007-11-15 18:05:47 -05001101static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001102 struct iw_param *vwrq, char *extra)
1103{
Kiran Divekarab65f642009-02-19 19:32:39 -05001104 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001105
Holger Schurig9012b282007-05-25 11:27:16 -04001106 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001107
David Woodhouseaa21c002007-12-08 20:04:36 +00001108 if (priv->connect_status == LBS_CONNECTED) {
1109 vwrq->value = priv->cur_rate * 500000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001110
Javier Cardona85319f92008-05-24 10:59:49 +01001111 if (priv->enablehwauto)
Dan Williams8c512762007-08-02 11:40:45 -04001112 vwrq->fixed = 0;
1113 else
1114 vwrq->fixed = 1;
1115
1116 } else {
1117 vwrq->fixed = 0;
1118 vwrq->value = 0;
1119 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001120
Holger Schurig9012b282007-05-25 11:27:16 -04001121 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001122 return 0;
1123}
1124
Holger Schurig10078322007-11-15 18:05:47 -05001125static int lbs_set_mode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001126 struct iw_request_info *info, u32 * uwrq, char *extra)
1127{
1128 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001129 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001130 struct assoc_request * assoc_req;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001131
Holger Schurig9012b282007-05-25 11:27:16 -04001132 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001133
Dan Williams0dc5a292007-05-10 22:58:02 -04001134 if ( (*uwrq != IW_MODE_ADHOC)
1135 && (*uwrq != IW_MODE_INFRA)
1136 && (*uwrq != IW_MODE_AUTO)) {
Holger Schurig9012b282007-05-25 11:27:16 -04001137 lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq);
Dan Williams0dc5a292007-05-10 22:58:02 -04001138 ret = -EINVAL;
1139 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001140 }
1141
David Woodhouseaa21c002007-12-08 20:04:36 +00001142 mutex_lock(&priv->lock);
1143 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001144 if (!assoc_req) {
1145 ret = -ENOMEM;
Holger Schurig10078322007-11-15 18:05:47 -05001146 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001147 } else {
Dan Williams0dc5a292007-05-10 22:58:02 -04001148 assoc_req->mode = *uwrq;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001149 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001150 lbs_postpone_association_work(priv);
Holger Schurig9012b282007-05-25 11:27:16 -04001151 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001152 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001153 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001154
Dan Williams0dc5a292007-05-10 22:58:02 -04001155out:
Holger Schurig9012b282007-05-25 11:27:16 -04001156 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001157 return ret;
1158}
1159
1160
1161/**
1162 * @brief Get Encryption key
1163 *
1164 * @param dev A pointer to net_device structure
1165 * @param info A pointer to iw_request_info structure
1166 * @param vwrq A pointer to iw_param structure
1167 * @param extra A pointer to extra data buf
1168 * @return 0 --success, otherwise fail
1169 */
Holger Schurig10078322007-11-15 18:05:47 -05001170static int lbs_get_encode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001171 struct iw_request_info *info,
1172 struct iw_point *dwrq, u8 * extra)
1173{
Kiran Divekarab65f642009-02-19 19:32:39 -05001174 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001175 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1176
Holger Schurig9012b282007-05-25 11:27:16 -04001177 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001178
Holger Schurig9012b282007-05-25 11:27:16 -04001179 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +00001180 dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001181
1182 dwrq->flags = 0;
1183
1184 /* Authentication method */
David Woodhouseaa21c002007-12-08 20:04:36 +00001185 switch (priv->secinfo.auth_mode) {
Dan Williams6affe782007-05-10 22:56:42 -04001186 case IW_AUTH_ALG_OPEN_SYSTEM:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001187 dwrq->flags = IW_ENCODE_OPEN;
1188 break;
1189
Dan Williams6affe782007-05-10 22:56:42 -04001190 case IW_AUTH_ALG_SHARED_KEY:
1191 case IW_AUTH_ALG_LEAP:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001192 dwrq->flags = IW_ENCODE_RESTRICTED;
1193 break;
1194 default:
1195 dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
1196 break;
1197 }
1198
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001199 memset(extra, 0, 16);
1200
David Woodhouseaa21c002007-12-08 20:04:36 +00001201 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001202
1203 /* Default to returning current transmit key */
1204 if (index < 0)
David Woodhouseaa21c002007-12-08 20:04:36 +00001205 index = priv->wep_tx_keyidx;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001206
David Woodhouseaa21c002007-12-08 20:04:36 +00001207 if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
1208 memcpy(extra, priv->wep_keys[index].key,
1209 priv->wep_keys[index].len);
1210 dwrq->length = priv->wep_keys[index].len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001211
1212 dwrq->flags |= (index + 1);
1213 /* Return WEP enabled */
1214 dwrq->flags &= ~IW_ENCODE_DISABLED;
David Woodhouseaa21c002007-12-08 20:04:36 +00001215 } else if ((priv->secinfo.WPAenabled)
1216 || (priv->secinfo.WPA2enabled)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001217 /* return WPA enabled */
1218 dwrq->flags &= ~IW_ENCODE_DISABLED;
David Woodhousec12bdc42007-12-07 19:32:12 +00001219 dwrq->flags |= IW_ENCODE_NOKEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001220 } else {
1221 dwrq->flags |= IW_ENCODE_DISABLED;
1222 }
1223
David Woodhouseaa21c002007-12-08 20:04:36 +00001224 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001225
Joe Perches0795af52007-10-03 17:59:30 -07001226 lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001227 extra[0], extra[1], extra[2],
1228 extra[3], extra[4], extra[5], dwrq->length);
1229
Holger Schurig9012b282007-05-25 11:27:16 -04001230 lbs_deb_wext("return flags 0x%x\n", dwrq->flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001231
Holger Schurig9012b282007-05-25 11:27:16 -04001232 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001233 return 0;
1234}
1235
1236/**
1237 * @brief Set Encryption key (internal)
1238 *
1239 * @param priv A pointer to private card structure
1240 * @param key_material A pointer to key material
1241 * @param key_length length of key material
1242 * @param index key index to set
1243 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1244 * @return 0 --success, otherwise fail
1245 */
Holger Schurig10078322007-11-15 18:05:47 -05001246static int lbs_set_wep_key(struct assoc_request *assoc_req,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001247 const char *key_material,
1248 u16 key_length,
1249 u16 index,
1250 int set_tx_key)
1251{
Holger Schurig9012b282007-05-25 11:27:16 -04001252 int ret = 0;
Dan Williams1443b652007-08-02 10:45:55 -04001253 struct enc_key *pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001254
Holger Schurig9012b282007-05-25 11:27:16 -04001255 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001256
1257 /* Paranoid validation of key index */
1258 if (index > 3) {
Holger Schurig9012b282007-05-25 11:27:16 -04001259 ret = -EINVAL;
1260 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001261 }
1262
1263 /* validate max key length */
1264 if (key_length > KEY_LEN_WEP_104) {
Holger Schurig9012b282007-05-25 11:27:16 -04001265 ret = -EINVAL;
1266 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001267 }
1268
1269 pkey = &assoc_req->wep_keys[index];
1270
1271 if (key_length > 0) {
Dan Williams1443b652007-08-02 10:45:55 -04001272 memset(pkey, 0, sizeof(struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001273 pkey->type = KEY_TYPE_ID_WEP;
1274
1275 /* Standardize the key length */
1276 pkey->len = (key_length > KEY_LEN_WEP_40) ?
1277 KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
1278 memcpy(pkey->key, key_material, key_length);
1279 }
1280
1281 if (set_tx_key) {
1282 /* Ensure the chosen key is valid */
1283 if (!pkey->len) {
Holger Schurig9012b282007-05-25 11:27:16 -04001284 lbs_deb_wext("key not set, so cannot enable it\n");
1285 ret = -EINVAL;
1286 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001287 }
1288 assoc_req->wep_tx_keyidx = index;
1289 }
1290
Dan Williams889c05b2007-05-10 22:57:23 -04001291 assoc_req->secinfo.wep_enabled = 1;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001292
Holger Schurig9012b282007-05-25 11:27:16 -04001293out:
1294 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1295 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001296}
1297
1298static int validate_key_index(u16 def_index, u16 raw_index,
1299 u16 *out_index, u16 *is_default)
1300{
1301 if (!out_index || !is_default)
1302 return -EINVAL;
1303
1304 /* Verify index if present, otherwise use default TX key index */
1305 if (raw_index > 0) {
1306 if (raw_index > 4)
1307 return -EINVAL;
1308 *out_index = raw_index - 1;
1309 } else {
1310 *out_index = def_index;
1311 *is_default = 1;
1312 }
1313 return 0;
1314}
1315
1316static void disable_wep(struct assoc_request *assoc_req)
1317{
1318 int i;
1319
Dan Williams90a42212007-05-25 23:01:24 -04001320 lbs_deb_enter(LBS_DEB_WEXT);
1321
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001322 /* Set Open System auth mode */
Dan Williams6affe782007-05-10 22:56:42 -04001323 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001324
1325 /* Clear WEP keys and mark WEP as disabled */
Dan Williams889c05b2007-05-10 22:57:23 -04001326 assoc_req->secinfo.wep_enabled = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001327 for (i = 0; i < 4; i++)
1328 assoc_req->wep_keys[i].len = 0;
1329
1330 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1331 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
Dan Williams90a42212007-05-25 23:01:24 -04001332
1333 lbs_deb_leave(LBS_DEB_WEXT);
1334}
1335
1336static void disable_wpa(struct assoc_request *assoc_req)
1337{
1338 lbs_deb_enter(LBS_DEB_WEXT);
1339
Dan Williams1443b652007-08-02 10:45:55 -04001340 memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key));
Dan Williams90a42212007-05-25 23:01:24 -04001341 assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
1342 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1343
Dan Williams1443b652007-08-02 10:45:55 -04001344 memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key));
Dan Williams90a42212007-05-25 23:01:24 -04001345 assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
1346 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1347
1348 assoc_req->secinfo.WPAenabled = 0;
1349 assoc_req->secinfo.WPA2enabled = 0;
1350 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1351
1352 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001353}
1354
1355/**
1356 * @brief Set Encryption key
1357 *
1358 * @param dev A pointer to net_device structure
1359 * @param info A pointer to iw_request_info structure
1360 * @param vwrq A pointer to iw_param structure
1361 * @param extra A pointer to extra data buf
1362 * @return 0 --success, otherwise fail
1363 */
Holger Schurig10078322007-11-15 18:05:47 -05001364static int lbs_set_encode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001365 struct iw_request_info *info,
1366 struct iw_point *dwrq, char *extra)
1367{
1368 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001369 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001370 struct assoc_request * assoc_req;
1371 u16 is_default = 0, index = 0, set_tx_key = 0;
1372
Holger Schurig9012b282007-05-25 11:27:16 -04001373 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001374
David Woodhouseaa21c002007-12-08 20:04:36 +00001375 mutex_lock(&priv->lock);
1376 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001377 if (!assoc_req) {
1378 ret = -ENOMEM;
1379 goto out;
1380 }
1381
1382 if (dwrq->flags & IW_ENCODE_DISABLED) {
1383 disable_wep (assoc_req);
Dan Williams90a42212007-05-25 23:01:24 -04001384 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001385 goto out;
1386 }
1387
1388 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1389 (dwrq->flags & IW_ENCODE_INDEX),
1390 &index, &is_default);
1391 if (ret) {
1392 ret = -EINVAL;
1393 goto out;
1394 }
1395
1396 /* If WEP isn't enabled, or if there is no key data but a valid
1397 * index, set the TX key.
1398 */
Dan Williams889c05b2007-05-10 22:57:23 -04001399 if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001400 set_tx_key = 1;
1401
Holger Schurig10078322007-11-15 18:05:47 -05001402 ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001403 if (ret)
1404 goto out;
1405
1406 if (dwrq->length)
1407 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1408 if (set_tx_key)
1409 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1410
1411 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
Dan Williams6affe782007-05-10 22:56:42 -04001412 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001413 } else if (dwrq->flags & IW_ENCODE_OPEN) {
Dan Williams6affe782007-05-10 22:56:42 -04001414 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001415 }
1416
1417out:
1418 if (ret == 0) {
1419 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001420 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001421 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001422 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001423 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001424 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001425
Holger Schurig9012b282007-05-25 11:27:16 -04001426 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001427 return ret;
1428}
1429
1430/**
1431 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
1432 *
1433 * @param dev A pointer to net_device structure
1434 * @param info A pointer to iw_request_info structure
1435 * @param vwrq A pointer to iw_param structure
1436 * @param extra A pointer to extra data buf
1437 * @return 0 on success, otherwise failure
1438 */
Holger Schurig10078322007-11-15 18:05:47 -05001439static int lbs_get_encodeext(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001440 struct iw_request_info *info,
1441 struct iw_point *dwrq,
1442 char *extra)
1443{
1444 int ret = -EINVAL;
Kiran Divekarab65f642009-02-19 19:32:39 -05001445 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001446 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1447 int index, max_key_len;
1448
Holger Schurig9012b282007-05-25 11:27:16 -04001449 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001450
1451 max_key_len = dwrq->length - sizeof(*ext);
1452 if (max_key_len < 0)
1453 goto out;
1454
1455 index = dwrq->flags & IW_ENCODE_INDEX;
1456 if (index) {
1457 if (index < 1 || index > 4)
1458 goto out;
1459 index--;
1460 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +00001461 index = priv->wep_tx_keyidx;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001462 }
1463
Roel Kluinf59d9782007-10-26 21:51:26 +02001464 if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001465 ext->alg != IW_ENCODE_ALG_WEP) {
David Woodhouseaa21c002007-12-08 20:04:36 +00001466 if (index != 0 || priv->mode != IW_MODE_INFRA)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001467 goto out;
1468 }
1469
1470 dwrq->flags = index + 1;
1471 memset(ext, 0, sizeof(*ext));
1472
David Woodhouseaa21c002007-12-08 20:04:36 +00001473 if ( !priv->secinfo.wep_enabled
1474 && !priv->secinfo.WPAenabled
1475 && !priv->secinfo.WPA2enabled) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001476 ext->alg = IW_ENCODE_ALG_NONE;
1477 ext->key_len = 0;
1478 dwrq->flags |= IW_ENCODE_DISABLED;
1479 } else {
1480 u8 *key = NULL;
1481
David Woodhouseaa21c002007-12-08 20:04:36 +00001482 if ( priv->secinfo.wep_enabled
1483 && !priv->secinfo.WPAenabled
1484 && !priv->secinfo.WPA2enabled) {
Dan Williams90a42212007-05-25 23:01:24 -04001485 /* WEP */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001486 ext->alg = IW_ENCODE_ALG_WEP;
David Woodhouseaa21c002007-12-08 20:04:36 +00001487 ext->key_len = priv->wep_keys[index].len;
1488 key = &priv->wep_keys[index].key[0];
1489 } else if ( !priv->secinfo.wep_enabled
1490 && (priv->secinfo.WPAenabled ||
1491 priv->secinfo.WPA2enabled)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001492 /* WPA */
Dan Williams1443b652007-08-02 10:45:55 -04001493 struct enc_key * pkey = NULL;
Dan Williams90a42212007-05-25 23:01:24 -04001494
David Woodhouseaa21c002007-12-08 20:04:36 +00001495 if ( priv->wpa_mcast_key.len
1496 && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
1497 pkey = &priv->wpa_mcast_key;
1498 else if ( priv->wpa_unicast_key.len
1499 && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
1500 pkey = &priv->wpa_unicast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001501
1502 if (pkey) {
1503 if (pkey->type == KEY_TYPE_ID_AES) {
1504 ext->alg = IW_ENCODE_ALG_CCMP;
1505 } else {
1506 ext->alg = IW_ENCODE_ALG_TKIP;
1507 }
1508 ext->key_len = pkey->len;
1509 key = &pkey->key[0];
1510 } else {
1511 ext->alg = IW_ENCODE_ALG_TKIP;
1512 ext->key_len = 0;
1513 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001514 } else {
1515 goto out;
1516 }
1517
1518 if (ext->key_len > max_key_len) {
1519 ret = -E2BIG;
1520 goto out;
1521 }
1522
1523 if (ext->key_len)
1524 memcpy(ext->key, key, ext->key_len);
1525 else
1526 dwrq->flags |= IW_ENCODE_NOKEY;
1527 dwrq->flags |= IW_ENCODE_ENABLED;
1528 }
1529 ret = 0;
1530
1531out:
Holger Schurig9012b282007-05-25 11:27:16 -04001532 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001533 return ret;
1534}
1535
1536/**
1537 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
1538 *
1539 * @param dev A pointer to net_device structure
1540 * @param info A pointer to iw_request_info structure
1541 * @param vwrq A pointer to iw_param structure
1542 * @param extra A pointer to extra data buf
1543 * @return 0 --success, otherwise fail
1544 */
Holger Schurig10078322007-11-15 18:05:47 -05001545static int lbs_set_encodeext(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001546 struct iw_request_info *info,
1547 struct iw_point *dwrq,
1548 char *extra)
1549{
1550 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001551 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001552 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1553 int alg = ext->alg;
1554 struct assoc_request * assoc_req;
1555
Holger Schurig9012b282007-05-25 11:27:16 -04001556 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001557
David Woodhouseaa21c002007-12-08 20:04:36 +00001558 mutex_lock(&priv->lock);
1559 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001560 if (!assoc_req) {
1561 ret = -ENOMEM;
1562 goto out;
1563 }
1564
1565 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
1566 disable_wep (assoc_req);
Dan Williams90a42212007-05-25 23:01:24 -04001567 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001568 } else if (alg == IW_ENCODE_ALG_WEP) {
1569 u16 is_default = 0, index, set_tx_key = 0;
1570
1571 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1572 (dwrq->flags & IW_ENCODE_INDEX),
1573 &index, &is_default);
1574 if (ret)
1575 goto out;
1576
1577 /* If WEP isn't enabled, or if there is no key data but a valid
1578 * index, or if the set-TX-key flag was passed, set the TX key.
1579 */
Dan Williams889c05b2007-05-10 22:57:23 -04001580 if ( !assoc_req->secinfo.wep_enabled
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001581 || (dwrq->length == 0 && !is_default)
1582 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
1583 set_tx_key = 1;
1584
1585 /* Copy key to driver */
Holger Schurig10078322007-11-15 18:05:47 -05001586 ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001587 set_tx_key);
1588 if (ret)
1589 goto out;
1590
1591 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
Dan Williams6affe782007-05-10 22:56:42 -04001592 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001593 } else if (dwrq->flags & IW_ENCODE_OPEN) {
Dan Williams6affe782007-05-10 22:56:42 -04001594 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001595 }
1596
1597 /* Mark the various WEP bits as modified */
1598 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1599 if (dwrq->length)
1600 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1601 if (set_tx_key)
1602 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001603 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
Dan Williams1443b652007-08-02 10:45:55 -04001604 struct enc_key * pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001605
1606 /* validate key length */
1607 if (((alg == IW_ENCODE_ALG_TKIP)
1608 && (ext->key_len != KEY_LEN_WPA_TKIP))
1609 || ((alg == IW_ENCODE_ALG_CCMP)
1610 && (ext->key_len != KEY_LEN_WPA_AES))) {
Joe Perches8376e7a2007-11-19 17:48:27 -08001611 lbs_deb_wext("invalid size %d for key of alg "
Holger Schurig9012b282007-05-25 11:27:16 -04001612 "type %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001613 ext->key_len,
1614 alg);
1615 ret = -EINVAL;
1616 goto out;
1617 }
1618
Dan Williams90a42212007-05-25 23:01:24 -04001619 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001620 pkey = &assoc_req->wpa_mcast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001621 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1622 } else {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001623 pkey = &assoc_req->wpa_unicast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001624 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1625 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001626
Dan Williams1443b652007-08-02 10:45:55 -04001627 memset(pkey, 0, sizeof (struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001628 memcpy(pkey->key, ext->key, ext->key_len);
1629 pkey->len = ext->key_len;
Dan Williams90a42212007-05-25 23:01:24 -04001630 if (pkey->len)
1631 pkey->flags |= KEY_INFO_WPA_ENABLED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001632
Dan Williams90a42212007-05-25 23:01:24 -04001633 /* Do this after zeroing key structure */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001634 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1635 pkey->flags |= KEY_INFO_WPA_MCAST;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001636 } else {
1637 pkey->flags |= KEY_INFO_WPA_UNICAST;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001638 }
1639
Dan Williams90a42212007-05-25 23:01:24 -04001640 if (alg == IW_ENCODE_ALG_TKIP) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001641 pkey->type = KEY_TYPE_ID_TKIP;
Dan Williams90a42212007-05-25 23:01:24 -04001642 } else if (alg == IW_ENCODE_ALG_CCMP) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001643 pkey->type = KEY_TYPE_ID_AES;
Dan Williams90a42212007-05-25 23:01:24 -04001644 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001645
1646 /* If WPA isn't enabled yet, do that now */
1647 if ( assoc_req->secinfo.WPAenabled == 0
1648 && assoc_req->secinfo.WPA2enabled == 0) {
1649 assoc_req->secinfo.WPAenabled = 1;
1650 assoc_req->secinfo.WPA2enabled = 1;
1651 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1652 }
1653
Javier Cardona9c31fd632008-09-11 15:32:50 -07001654 /* Only disable wep if necessary: can't waste time here. */
1655 if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
1656 disable_wep(assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001657 }
1658
1659out:
Javier Cardona9c40fc52008-09-16 18:08:39 -07001660 if (ret == 0) {
1661 /* 802.1x and WPA rekeying must happen as quickly as possible,
1662 * especially during the 4-way handshake; thus if in
1663 * infrastructure mode, and either (a) 802.1x is enabled or
1664 * (b) WPA is being used, set the key right away.
1665 */
1666 if (assoc_req->mode == IW_MODE_INFRA &&
1667 ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
1668 (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
1669 assoc_req->secinfo.WPAenabled ||
1670 assoc_req->secinfo.WPA2enabled)) {
1671 lbs_do_association_work(priv);
1672 } else
1673 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001674 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001675 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001676 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001677 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001678
Holger Schurig9012b282007-05-25 11:27:16 -04001679 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001680 return ret;
1681}
1682
1683
Holger Schurig10078322007-11-15 18:05:47 -05001684static int lbs_set_genie(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001685 struct iw_request_info *info,
1686 struct iw_point *dwrq,
1687 char *extra)
1688{
Kiran Divekarab65f642009-02-19 19:32:39 -05001689 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001690 int ret = 0;
1691 struct assoc_request * assoc_req;
1692
Holger Schurig9012b282007-05-25 11:27:16 -04001693 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001694
David Woodhouseaa21c002007-12-08 20:04:36 +00001695 mutex_lock(&priv->lock);
1696 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001697 if (!assoc_req) {
1698 ret = -ENOMEM;
1699 goto out;
1700 }
1701
1702 if (dwrq->length > MAX_WPA_IE_LEN ||
1703 (dwrq->length && extra == NULL)) {
1704 ret = -EINVAL;
1705 goto out;
1706 }
1707
1708 if (dwrq->length) {
1709 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
1710 assoc_req->wpa_ie_len = dwrq->length;
1711 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +00001712 memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001713 assoc_req->wpa_ie_len = 0;
1714 }
1715
1716out:
1717 if (ret == 0) {
1718 set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001719 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001720 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001721 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001722 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001723 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001724
Holger Schurig9012b282007-05-25 11:27:16 -04001725 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001726 return ret;
1727}
1728
Holger Schurig10078322007-11-15 18:05:47 -05001729static int lbs_get_genie(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001730 struct iw_request_info *info,
1731 struct iw_point *dwrq,
1732 char *extra)
1733{
Holger Schurig9012b282007-05-25 11:27:16 -04001734 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001735 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001736
Holger Schurig9012b282007-05-25 11:27:16 -04001737 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001738
David Woodhouseaa21c002007-12-08 20:04:36 +00001739 if (priv->wpa_ie_len == 0) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001740 dwrq->length = 0;
Holger Schurig9012b282007-05-25 11:27:16 -04001741 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001742 }
1743
David Woodhouseaa21c002007-12-08 20:04:36 +00001744 if (dwrq->length < priv->wpa_ie_len) {
Holger Schurig9012b282007-05-25 11:27:16 -04001745 ret = -E2BIG;
1746 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001747 }
1748
David Woodhouseaa21c002007-12-08 20:04:36 +00001749 dwrq->length = priv->wpa_ie_len;
1750 memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001751
Holger Schurig9012b282007-05-25 11:27:16 -04001752out:
1753 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1754 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001755}
1756
1757
Holger Schurig10078322007-11-15 18:05:47 -05001758static int lbs_set_auth(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001759 struct iw_request_info *info,
1760 struct iw_param *dwrq,
1761 char *extra)
1762{
Kiran Divekarab65f642009-02-19 19:32:39 -05001763 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001764 struct assoc_request * assoc_req;
1765 int ret = 0;
1766 int updated = 0;
1767
Holger Schurig9012b282007-05-25 11:27:16 -04001768 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001769
David Woodhouseaa21c002007-12-08 20:04:36 +00001770 mutex_lock(&priv->lock);
1771 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001772 if (!assoc_req) {
1773 ret = -ENOMEM;
1774 goto out;
1775 }
1776
1777 switch (dwrq->flags & IW_AUTH_INDEX) {
Maithili Hinge2c8d5102009-07-31 20:02:19 -07001778 case IW_AUTH_PRIVACY_INVOKED:
1779 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001780 case IW_AUTH_TKIP_COUNTERMEASURES:
1781 case IW_AUTH_CIPHER_PAIRWISE:
1782 case IW_AUTH_CIPHER_GROUP:
Dan Williams90a42212007-05-25 23:01:24 -04001783 case IW_AUTH_DROP_UNENCRYPTED:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001784 /*
1785 * libertas does not use these parameters
1786 */
1787 break;
1788
Javier Cardona9c40fc52008-09-16 18:08:39 -07001789 case IW_AUTH_KEY_MGMT:
1790 assoc_req->secinfo.key_mgmt = dwrq->value;
1791 updated = 1;
1792 break;
1793
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001794 case IW_AUTH_WPA_VERSION:
1795 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
1796 assoc_req->secinfo.WPAenabled = 0;
1797 assoc_req->secinfo.WPA2enabled = 0;
Dan Williams90a42212007-05-25 23:01:24 -04001798 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001799 }
1800 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
1801 assoc_req->secinfo.WPAenabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001802 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001803 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001804 }
1805 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
1806 assoc_req->secinfo.WPA2enabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001807 assoc_req->secinfo.wep_enabled = 0;
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 }
1810 updated = 1;
1811 break;
1812
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001813 case IW_AUTH_80211_AUTH_ALG:
1814 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
Dan Williams6affe782007-05-10 22:56:42 -04001815 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001816 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
Dan Williams6affe782007-05-10 22:56:42 -04001817 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001818 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
Dan Williams6affe782007-05-10 22:56:42 -04001819 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001820 } else {
1821 ret = -EINVAL;
1822 }
1823 updated = 1;
1824 break;
1825
1826 case IW_AUTH_WPA_ENABLED:
1827 if (dwrq->value) {
1828 if (!assoc_req->secinfo.WPAenabled &&
1829 !assoc_req->secinfo.WPA2enabled) {
1830 assoc_req->secinfo.WPAenabled = 1;
1831 assoc_req->secinfo.WPA2enabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001832 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001833 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001834 }
1835 } else {
1836 assoc_req->secinfo.WPAenabled = 0;
1837 assoc_req->secinfo.WPA2enabled = 0;
Dan Williams90a42212007-05-25 23:01:24 -04001838 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001839 }
1840 updated = 1;
1841 break;
1842
1843 default:
1844 ret = -EOPNOTSUPP;
1845 break;
1846 }
1847
1848out:
1849 if (ret == 0) {
1850 if (updated)
1851 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001852 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001853 } else if (ret != -EOPNOTSUPP) {
Holger Schurig10078322007-11-15 18:05:47 -05001854 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001855 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001856 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001857
Holger Schurig9012b282007-05-25 11:27:16 -04001858 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001859 return ret;
1860}
1861
Holger Schurig10078322007-11-15 18:05:47 -05001862static int lbs_get_auth(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001863 struct iw_request_info *info,
1864 struct iw_param *dwrq,
1865 char *extra)
1866{
Holger Schurig9012b282007-05-25 11:27:16 -04001867 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001868 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001869
Holger Schurig9012b282007-05-25 11:27:16 -04001870 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001871
1872 switch (dwrq->flags & IW_AUTH_INDEX) {
Javier Cardona9c40fc52008-09-16 18:08:39 -07001873 case IW_AUTH_KEY_MGMT:
1874 dwrq->value = priv->secinfo.key_mgmt;
1875 break;
1876
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001877 case IW_AUTH_WPA_VERSION:
1878 dwrq->value = 0;
David Woodhouseaa21c002007-12-08 20:04:36 +00001879 if (priv->secinfo.WPAenabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001880 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
David Woodhouseaa21c002007-12-08 20:04:36 +00001881 if (priv->secinfo.WPA2enabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001882 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
1883 if (!dwrq->value)
1884 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
1885 break;
1886
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001887 case IW_AUTH_80211_AUTH_ALG:
David Woodhouseaa21c002007-12-08 20:04:36 +00001888 dwrq->value = priv->secinfo.auth_mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001889 break;
1890
1891 case IW_AUTH_WPA_ENABLED:
David Woodhouseaa21c002007-12-08 20:04:36 +00001892 if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001893 dwrq->value = 1;
1894 break;
1895
1896 default:
Holger Schurig9012b282007-05-25 11:27:16 -04001897 ret = -EOPNOTSUPP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001898 }
1899
Holger Schurig9012b282007-05-25 11:27:16 -04001900 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1901 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001902}
1903
1904
Holger Schurig10078322007-11-15 18:05:47 -05001905static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001906 struct iw_param *vwrq, char *extra)
1907{
1908 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001909 struct lbs_private *priv = dev->ml_priv;
Dan Williams87c8c722008-08-19 15:15:35 -04001910 s16 dbm = (s16) vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001911
Holger Schurig9012b282007-05-25 11:27:16 -04001912 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001913
1914 if (vwrq->disabled) {
Dan Williamsd5db2df2008-08-21 17:51:07 -04001915 lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
Dan Williams87c8c722008-08-19 15:15:35 -04001916 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001917 }
1918
Dan Williams87c8c722008-08-19 15:15:35 -04001919 if (vwrq->fixed == 0) {
Anna Neal0112c9e2008-09-11 11:17:25 -07001920 /* User requests automatic tx power control, however there are
1921 * many auto tx settings. For now use firmware defaults until
1922 * we come up with a good way to expose these to the user. */
1923 if (priv->fwrelease < 0x09000000) {
1924 ret = lbs_set_power_adapt_cfg(priv, 1,
1925 POW_ADAPT_DEFAULT_P0,
1926 POW_ADAPT_DEFAULT_P1,
1927 POW_ADAPT_DEFAULT_P2);
1928 if (ret)
1929 goto out;
1930 }
1931 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1932 TPC_DEFAULT_P2, 1);
1933 if (ret)
1934 goto out;
Dan Williams87c8c722008-08-19 15:15:35 -04001935 dbm = priv->txpower_max;
1936 } else {
1937 /* Userspace check in iwrange if it should use dBm or mW,
1938 * therefore this should never happen... Jean II */
1939 if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
1940 ret = -EOPNOTSUPP;
1941 goto out;
1942 }
1943
Anna Neal0112c9e2008-09-11 11:17:25 -07001944 /* Validate requested power level against firmware allowed
1945 * levels */
Dan Williams87c8c722008-08-19 15:15:35 -04001946 if (priv->txpower_min && (dbm < priv->txpower_min)) {
1947 ret = -EINVAL;
1948 goto out;
1949 }
1950
1951 if (priv->txpower_max && (dbm > priv->txpower_max)) {
1952 ret = -EINVAL;
1953 goto out;
1954 }
Anna Neal0112c9e2008-09-11 11:17:25 -07001955 if (priv->fwrelease < 0x09000000) {
1956 ret = lbs_set_power_adapt_cfg(priv, 0,
1957 POW_ADAPT_DEFAULT_P0,
1958 POW_ADAPT_DEFAULT_P1,
1959 POW_ADAPT_DEFAULT_P2);
1960 if (ret)
1961 goto out;
1962 }
1963 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1964 TPC_DEFAULT_P2, 1);
1965 if (ret)
1966 goto out;
Dan Williams87c8c722008-08-19 15:15:35 -04001967 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001968
Dan Williamsd5db2df2008-08-21 17:51:07 -04001969 /* If the radio was off, turn it on */
1970 if (!priv->radio_on) {
1971 ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
1972 if (ret)
1973 goto out;
1974 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001975
Dan Williams87c8c722008-08-19 15:15:35 -04001976 lbs_deb_wext("txpower set %d dBm\n", dbm);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001977
Dan Williams87c8c722008-08-19 15:15:35 -04001978 ret = lbs_set_tx_power(priv, dbm);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001979
Dan Williams87c8c722008-08-19 15:15:35 -04001980out:
Holger Schurig9012b282007-05-25 11:27:16 -04001981 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001982 return ret;
1983}
1984
Holger Schurig10078322007-11-15 18:05:47 -05001985static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001986 struct iw_point *dwrq, char *extra)
1987{
Kiran Divekarab65f642009-02-19 19:32:39 -05001988 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001989
Holger Schurig9012b282007-05-25 11:27:16 -04001990 lbs_deb_enter(LBS_DEB_WEXT);
1991
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001992 /*
1993 * Note : if dwrq->flags != 0, we should get the relevant SSID from
1994 * the SSID list...
1995 */
1996
1997 /*
1998 * Get the current SSID
1999 */
David Woodhouseaa21c002007-12-08 20:04:36 +00002000 if (priv->connect_status == LBS_CONNECTED) {
2001 memcpy(extra, priv->curbssparams.ssid,
2002 priv->curbssparams.ssid_len);
2003 extra[priv->curbssparams.ssid_len] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002004 } else {
2005 memset(extra, 0, 32);
David Woodhouseaa21c002007-12-08 20:04:36 +00002006 extra[priv->curbssparams.ssid_len] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002007 }
2008 /*
2009 * If none, we may want to get the one that was set
2010 */
2011
David Woodhouseaa21c002007-12-08 20:04:36 +00002012 dwrq->length = priv->curbssparams.ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002013
2014 dwrq->flags = 1; /* active */
2015
Holger Schurig9012b282007-05-25 11:27:16 -04002016 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002017 return 0;
2018}
2019
Holger Schurig10078322007-11-15 18:05:47 -05002020static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002021 struct iw_point *dwrq, char *extra)
2022{
Kiran Divekarab65f642009-02-19 19:32:39 -05002023 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002024 int ret = 0;
Holger Schurig243e84e2009-10-22 15:30:47 +02002025 u8 ssid[IEEE80211_MAX_SSID_LEN];
Dan Williamsd8efea22007-05-28 23:54:55 -04002026 u8 ssid_len = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002027 struct assoc_request * assoc_req;
Dan Williamsd8efea22007-05-28 23:54:55 -04002028 int in_ssid_len = dwrq->length;
John W. Linville9387b7c2008-09-30 20:59:05 -04002029 DECLARE_SSID_BUF(ssid_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002030
Holger Schurig9012b282007-05-25 11:27:16 -04002031 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002032
Dan Williamsd5db2df2008-08-21 17:51:07 -04002033 if (!priv->radio_on) {
2034 ret = -EINVAL;
2035 goto out;
2036 }
2037
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002038 /* Check the size of the string */
Holger Schurig243e84e2009-10-22 15:30:47 +02002039 if (in_ssid_len > IEEE80211_MAX_SSID_LEN) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002040 ret = -E2BIG;
2041 goto out;
2042 }
2043
Dan Williamsd8efea22007-05-28 23:54:55 -04002044 memset(&ssid, 0, sizeof(ssid));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002045
Dan Williamsd8efea22007-05-28 23:54:55 -04002046 if (!dwrq->flags || !in_ssid_len) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002047 /* "any" SSID requested; leave SSID blank */
2048 } else {
2049 /* Specific SSID requested */
Dan Williamsd8efea22007-05-28 23:54:55 -04002050 memcpy(&ssid, extra, in_ssid_len);
2051 ssid_len = in_ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002052 }
2053
Dan Williamsd8efea22007-05-28 23:54:55 -04002054 if (!ssid_len) {
2055 lbs_deb_wext("requested any SSID\n");
2056 } else {
2057 lbs_deb_wext("requested SSID '%s'\n",
John W. Linville9387b7c2008-09-30 20:59:05 -04002058 print_ssid(ssid_buf, ssid, ssid_len));
Dan Williamsd8efea22007-05-28 23:54:55 -04002059 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002060
2061out:
David Woodhouseaa21c002007-12-08 20:04:36 +00002062 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002063 if (ret == 0) {
2064 /* Get or create the current association request */
David Woodhouseaa21c002007-12-08 20:04:36 +00002065 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002066 if (!assoc_req) {
2067 ret = -ENOMEM;
2068 } else {
2069 /* Copy the SSID to the association request */
Holger Schurig243e84e2009-10-22 15:30:47 +02002070 memcpy(&assoc_req->ssid, &ssid, IEEE80211_MAX_SSID_LEN);
Dan Williamsd8efea22007-05-28 23:54:55 -04002071 assoc_req->ssid_len = ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002072 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05002073 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002074 }
2075 }
2076
2077 /* Cancel the association request if there was an error */
2078 if (ret != 0) {
Holger Schurig10078322007-11-15 18:05:47 -05002079 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002080 }
2081
David Woodhouseaa21c002007-12-08 20:04:36 +00002082 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002083
Holger Schurig9012b282007-05-25 11:27:16 -04002084 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002085 return ret;
2086}
2087
David Woodhousef5956bf2007-12-11 19:30:57 -05002088static int lbs_mesh_get_essid(struct net_device *dev,
2089 struct iw_request_info *info,
2090 struct iw_point *dwrq, char *extra)
2091{
Kiran Divekarab65f642009-02-19 19:32:39 -05002092 struct lbs_private *priv = dev->ml_priv;
David Woodhousef5956bf2007-12-11 19:30:57 -05002093
2094 lbs_deb_enter(LBS_DEB_WEXT);
2095
2096 memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
2097
2098 dwrq->length = priv->mesh_ssid_len;
2099
2100 dwrq->flags = 1; /* active */
2101
2102 lbs_deb_leave(LBS_DEB_WEXT);
2103 return 0;
2104}
2105
2106static int lbs_mesh_set_essid(struct net_device *dev,
2107 struct iw_request_info *info,
2108 struct iw_point *dwrq, char *extra)
2109{
Kiran Divekarab65f642009-02-19 19:32:39 -05002110 struct lbs_private *priv = dev->ml_priv;
David Woodhousef5956bf2007-12-11 19:30:57 -05002111 int ret = 0;
2112
2113 lbs_deb_enter(LBS_DEB_WEXT);
2114
Dan Williamsd5db2df2008-08-21 17:51:07 -04002115 if (!priv->radio_on) {
2116 ret = -EINVAL;
2117 goto out;
2118 }
2119
David Woodhousef5956bf2007-12-11 19:30:57 -05002120 /* Check the size of the string */
Holger Schurig243e84e2009-10-22 15:30:47 +02002121 if (dwrq->length > IEEE80211_MAX_SSID_LEN) {
David Woodhousef5956bf2007-12-11 19:30:57 -05002122 ret = -E2BIG;
2123 goto out;
2124 }
2125
2126 if (!dwrq->flags || !dwrq->length) {
2127 ret = -EINVAL;
2128 goto out;
2129 } else {
2130 /* Specific SSID requested */
2131 memcpy(priv->mesh_ssid, extra, dwrq->length);
2132 priv->mesh_ssid_len = dwrq->length;
2133 }
2134
Javier Cardonaedaea5c2008-05-17 00:55:10 -07002135 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
Holger Schurigc14951f2009-10-22 15:30:50 +02002136 priv->channel);
David Woodhousef5956bf2007-12-11 19:30:57 -05002137 out:
2138 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2139 return ret;
2140}
2141
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002142/**
2143 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2144 *
2145 * @param dev A pointer to net_device structure
2146 * @param info A pointer to iw_request_info structure
2147 * @param awrq A pointer to iw_param structure
2148 * @param extra A pointer to extra data buf
2149 * @return 0 --success, otherwise fail
2150 */
Holger Schurig10078322007-11-15 18:05:47 -05002151static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002152 struct sockaddr *awrq, char *extra)
2153{
Kiran Divekarab65f642009-02-19 19:32:39 -05002154 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002155 struct assoc_request * assoc_req;
2156 int ret = 0;
2157
Holger Schurig9012b282007-05-25 11:27:16 -04002158 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002159
Dan Williamsd5db2df2008-08-21 17:51:07 -04002160 if (!priv->radio_on)
2161 return -EINVAL;
2162
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002163 if (awrq->sa_family != ARPHRD_ETHER)
2164 return -EINVAL;
2165
Johannes Berge1749612008-10-27 15:59:26 -07002166 lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002167
David Woodhouseaa21c002007-12-08 20:04:36 +00002168 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002169
2170 /* Get or create the current association request */
David Woodhouseaa21c002007-12-08 20:04:36 +00002171 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002172 if (!assoc_req) {
Holger Schurig10078322007-11-15 18:05:47 -05002173 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002174 ret = -ENOMEM;
2175 } else {
2176 /* Copy the BSSID to the association request */
2177 memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
2178 set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05002179 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002180 }
2181
David Woodhouseaa21c002007-12-08 20:04:36 +00002182 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002183
2184 return ret;
2185}
2186
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002187/*
2188 * iwconfig settable callbacks
2189 */
Holger Schurig10078322007-11-15 18:05:47 -05002190static const iw_handler lbs_handler[] = {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002191 (iw_handler) NULL, /* SIOCSIWCOMMIT */
Holger Schurig10078322007-11-15 18:05:47 -05002192 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002193 (iw_handler) NULL, /* SIOCSIWNWID */
2194 (iw_handler) NULL, /* SIOCGIWNWID */
Holger Schurig10078322007-11-15 18:05:47 -05002195 (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */
2196 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
2197 (iw_handler) lbs_set_mode, /* SIOCSIWMODE */
2198 (iw_handler) lbs_get_mode, /* SIOCGIWMODE */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002199 (iw_handler) NULL, /* SIOCSIWSENS */
2200 (iw_handler) NULL, /* SIOCGIWSENS */
2201 (iw_handler) NULL, /* SIOCSIWRANGE */
Holger Schurig10078322007-11-15 18:05:47 -05002202 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002203 (iw_handler) NULL, /* SIOCSIWPRIV */
2204 (iw_handler) NULL, /* SIOCGIWPRIV */
2205 (iw_handler) NULL, /* SIOCSIWSTATS */
2206 (iw_handler) NULL, /* SIOCGIWSTATS */
2207 iw_handler_set_spy, /* SIOCSIWSPY */
2208 iw_handler_get_spy, /* SIOCGIWSPY */
2209 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2210 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
Holger Schurig10078322007-11-15 18:05:47 -05002211 (iw_handler) lbs_set_wap, /* SIOCSIWAP */
2212 (iw_handler) lbs_get_wap, /* SIOCGIWAP */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002213 (iw_handler) NULL, /* SIOCSIWMLME */
2214 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
Holger Schurig10078322007-11-15 18:05:47 -05002215 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2216 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
2217 (iw_handler) lbs_set_essid, /* SIOCSIWESSID */
2218 (iw_handler) lbs_get_essid, /* SIOCGIWESSID */
2219 (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */
2220 (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002221 (iw_handler) NULL, /* -- hole -- */
2222 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002223 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2224 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2225 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2226 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2227 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2228 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2229 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2230 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2231 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2232 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2233 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2234 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2235 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2236 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002237 (iw_handler) NULL, /* -- hole -- */
2238 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002239 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2240 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2241 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2242 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2243 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2244 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002245 (iw_handler) NULL, /* SIOCSIWPMKSA */
2246};
2247
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002248static const iw_handler mesh_wlan_handler[] = {
2249 (iw_handler) NULL, /* SIOCSIWCOMMIT */
Holger Schurig10078322007-11-15 18:05:47 -05002250 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002251 (iw_handler) NULL, /* SIOCSIWNWID */
2252 (iw_handler) NULL, /* SIOCGIWNWID */
David Woodhouse823eaa22007-12-11 19:56:28 -05002253 (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
Holger Schurig10078322007-11-15 18:05:47 -05002254 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002255 (iw_handler) NULL, /* SIOCSIWMODE */
2256 (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
2257 (iw_handler) NULL, /* SIOCSIWSENS */
2258 (iw_handler) NULL, /* SIOCGIWSENS */
2259 (iw_handler) NULL, /* SIOCSIWRANGE */
Holger Schurig10078322007-11-15 18:05:47 -05002260 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002261 (iw_handler) NULL, /* SIOCSIWPRIV */
2262 (iw_handler) NULL, /* SIOCGIWPRIV */
2263 (iw_handler) NULL, /* SIOCSIWSTATS */
2264 (iw_handler) NULL, /* SIOCGIWSTATS */
2265 iw_handler_set_spy, /* SIOCSIWSPY */
2266 iw_handler_get_spy, /* SIOCGIWSPY */
2267 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2268 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2269 (iw_handler) NULL, /* SIOCSIWAP */
2270 (iw_handler) NULL, /* SIOCGIWAP */
2271 (iw_handler) NULL, /* SIOCSIWMLME */
2272 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
Holger Schurig10078322007-11-15 18:05:47 -05002273 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2274 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
David Woodhousef5956bf2007-12-11 19:30:57 -05002275 (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
2276 (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002277 (iw_handler) NULL, /* SIOCSIWNICKN */
2278 (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
2279 (iw_handler) NULL, /* -- hole -- */
2280 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002281 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2282 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2283 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2284 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2285 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2286 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2287 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2288 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2289 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2290 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2291 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2292 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2293 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2294 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002295 (iw_handler) NULL, /* -- hole -- */
2296 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002297 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2298 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2299 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2300 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2301 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2302 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002303 (iw_handler) NULL, /* SIOCSIWPMKSA */
2304};
Holger Schurig10078322007-11-15 18:05:47 -05002305struct iw_handler_def lbs_handler_def = {
2306 .num_standard = ARRAY_SIZE(lbs_handler),
2307 .standard = (iw_handler *) lbs_handler,
2308 .get_wireless_stats = lbs_get_wireless_stats,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002309};
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002310
2311struct iw_handler_def mesh_handler_def = {
Denis Chengff8ac602007-09-02 18:30:18 +08002312 .num_standard = ARRAY_SIZE(mesh_wlan_handler),
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002313 .standard = (iw_handler *) mesh_wlan_handler,
Holger Schurig10078322007-11-15 18:05:47 -05002314 .get_wireless_stats = lbs_get_wireless_stats,
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002315};