blob: 4594841cd4afd129f51487ab89bea5ccd4ceca0c [file] [log] [blame]
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001/**
2 * This file contains ioctl functions
3 */
4#include <linux/ctype.h>
5#include <linux/delay.h>
6#include <linux/if.h>
7#include <linux/if_arp.h>
8#include <linux/wireless.h>
9#include <linux/bitops.h>
10
John W. Linville7e272fc2008-09-24 18:13:14 -040011#include <net/lib80211.h>
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020012#include <net/iw_handler.h>
13
14#include "host.h"
15#include "radiotap.h"
16#include "decl.h"
17#include "defs.h"
18#include "dev.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020019#include "wext.h"
Holger Schurig245bf202008-04-02 16:27:42 +020020#include "scan.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020021#include "assoc.h"
Dan Williams8e3c91b2007-12-11 15:50:59 -050022#include "cmd.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020023
24
Holger Schurig69f90322007-11-23 15:43:44 +010025static inline void lbs_postpone_association_work(struct lbs_private *priv)
Holger Schurig9f9dac22007-10-26 10:12:14 +020026{
David Woodhouseaa21c002007-12-08 20:04:36 +000027 if (priv->surpriseremoved)
Holger Schurig9f9dac22007-10-26 10:12:14 +020028 return;
29 cancel_delayed_work(&priv->assoc_work);
30 queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
31}
32
Javier Cardona9c31fd632008-09-11 15:32:50 -070033static inline void lbs_do_association_work(struct lbs_private *priv)
34{
35 if (priv->surpriseremoved)
36 return;
37 cancel_delayed_work(&priv->assoc_work);
38 queue_delayed_work(priv->work_thread, &priv->assoc_work, 0);
39}
40
Holger Schurig69f90322007-11-23 15:43:44 +010041static inline void lbs_cancel_association_work(struct lbs_private *priv)
Holger Schurig9f9dac22007-10-26 10:12:14 +020042{
43 cancel_delayed_work(&priv->assoc_work);
David Woodhouseaa21c002007-12-08 20:04:36 +000044 kfree(priv->pending_assoc_req);
45 priv->pending_assoc_req = NULL;
Holger Schurig9f9dac22007-10-26 10:12:14 +020046}
47
Amitkumar Karwar49125452009-09-30 20:04:38 -070048/**
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020049 * @brief Find the channel frequency power info with specific channel
50 *
David Woodhouseaa21c002007-12-08 20:04:36 +000051 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020052 * @param band it can be BAND_A, BAND_G or BAND_B
53 * @param channel the channel for looking
54 * @return A pointer to struct chan_freq_power structure or NULL if not find.
55 */
Holger Schurig69f90322007-11-23 15:43:44 +010056struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
David Woodhouseaa21c002007-12-08 20:04:36 +000057 struct lbs_private *priv,
Holger Schurig69f90322007-11-23 15:43:44 +010058 u8 band,
59 u16 channel)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020060{
61 struct chan_freq_power *cfp = NULL;
62 struct region_channel *rc;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020063 int i, j;
64
David Woodhouseaa21c002007-12-08 20:04:36 +000065 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
66 rc = &priv->region_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020067
David Woodhouseaa21c002007-12-08 20:04:36 +000068 if (priv->enable11d)
69 rc = &priv->universal_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020070 if (!rc->valid || !rc->CFP)
71 continue;
72 if (rc->band != band)
73 continue;
74 for (i = 0; i < rc->nrcfp; i++) {
75 if (rc->CFP[i].channel == channel) {
76 cfp = &rc->CFP[i];
77 break;
78 }
79 }
80 }
81
82 if (!cfp && channel)
Holger Schurig10078322007-11-15 18:05:47 -050083 lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
Holger Schurig9012b282007-05-25 11:27:16 -040084 "cfp by band %d / channel %d\n", band, channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020085
86 return cfp;
87}
88
89/**
90 * @brief Find the channel frequency power info with specific frequency
91 *
David Woodhouseaa21c002007-12-08 20:04:36 +000092 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020093 * @param band it can be BAND_A, BAND_G or BAND_B
94 * @param freq the frequency for looking
95 * @return A pointer to struct chan_freq_power structure or NULL if not find.
96 */
Holger Schurig69f90322007-11-23 15:43:44 +010097static struct chan_freq_power *find_cfp_by_band_and_freq(
David Woodhouseaa21c002007-12-08 20:04:36 +000098 struct lbs_private *priv,
Holger Schurig69f90322007-11-23 15:43:44 +010099 u8 band,
100 u32 freq)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200101{
102 struct chan_freq_power *cfp = NULL;
103 struct region_channel *rc;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200104 int i, j;
105
David Woodhouseaa21c002007-12-08 20:04:36 +0000106 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
107 rc = &priv->region_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200108
David Woodhouseaa21c002007-12-08 20:04:36 +0000109 if (priv->enable11d)
110 rc = &priv->universal_channel[j];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200111 if (!rc->valid || !rc->CFP)
112 continue;
113 if (rc->band != band)
114 continue;
115 for (i = 0; i < rc->nrcfp; i++) {
116 if (rc->CFP[i].freq == freq) {
117 cfp = &rc->CFP[i];
118 break;
119 }
120 }
121 }
122
123 if (!cfp && freq)
Holger Schurig9012b282007-05-25 11:27:16 -0400124 lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
125 "band %d / freq %d\n", band, freq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200126
127 return cfp;
128}
129
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200130/**
Dan Williams8c512762007-08-02 11:40:45 -0400131 * @brief Copy active data rates based on adapter mode and status
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200132 *
David Woodhouseaa21c002007-12-08 20:04:36 +0000133 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200134 * @param rate The buf to return the active rates
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200135 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000136static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200137{
Holger Schurig9012b282007-05-25 11:27:16 -0400138 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200139
David Woodhouseaa21c002007-12-08 20:04:36 +0000140 if ((priv->connect_status != LBS_CONNECTED) &&
141 (priv->mesh_connect_status != LBS_CONNECTED))
Holger Schurig10078322007-11-15 18:05:47 -0500142 memcpy(rates, lbs_bg_rates, MAX_RATES);
Dan Williams8c512762007-08-02 11:40:45 -0400143 else
David Woodhouseaa21c002007-12-08 20:04:36 +0000144 memcpy(rates, priv->curbssparams.rates, MAX_RATES);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200145
Dan Williams8c512762007-08-02 11:40:45 -0400146 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200147}
148
Holger Schurig10078322007-11-15 18:05:47 -0500149static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200150 char *cwrq, char *extra)
151{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200152
Holger Schurig9012b282007-05-25 11:27:16 -0400153 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200154
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400155 /* We could add support for 802.11n here as needed. Jean II */
156 snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200157
Holger Schurig9012b282007-05-25 11:27:16 -0400158 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200159 return 0;
160}
161
Holger Schurig10078322007-11-15 18:05:47 -0500162static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200163 struct iw_freq *fwrq, char *extra)
164{
Kiran Divekarab65f642009-02-19 19:32:39 -0500165 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200166 struct chan_freq_power *cfp;
167
Holger Schurig9012b282007-05-25 11:27:16 -0400168 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200169
David Woodhouseaa21c002007-12-08 20:04:36 +0000170 cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
171 priv->curbssparams.channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200172
173 if (!cfp) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000174 if (priv->curbssparams.channel)
Holger Schurig9012b282007-05-25 11:27:16 -0400175 lbs_deb_wext("invalid channel %d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000176 priv->curbssparams.channel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200177 return -EINVAL;
178 }
179
180 fwrq->m = (long)cfp->freq * 100000;
181 fwrq->e = 1;
182
Holger Schurig9012b282007-05-25 11:27:16 -0400183 lbs_deb_wext("freq %u\n", fwrq->m);
184 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200185 return 0;
186}
187
Holger Schurig10078322007-11-15 18:05:47 -0500188static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200189 struct sockaddr *awrq, char *extra)
190{
Kiran Divekarab65f642009-02-19 19:32:39 -0500191 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200192
Holger Schurig9012b282007-05-25 11:27:16 -0400193 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200194
David Woodhouseaa21c002007-12-08 20:04:36 +0000195 if (priv->connect_status == LBS_CONNECTED) {
196 memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200197 } else {
198 memset(awrq->sa_data, 0, ETH_ALEN);
199 }
200 awrq->sa_family = ARPHRD_ETHER;
201
Holger Schurig9012b282007-05-25 11:27:16 -0400202 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200203 return 0;
204}
205
Holger Schurig10078322007-11-15 18:05:47 -0500206static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200207 struct iw_point *dwrq, char *extra)
208{
Kiran Divekarab65f642009-02-19 19:32:39 -0500209 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200210
Holger Schurig9012b282007-05-25 11:27:16 -0400211 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200212
213 /*
214 * Check the size of the string
215 */
216
217 if (dwrq->length > 16) {
218 return -E2BIG;
219 }
220
David Woodhouseaa21c002007-12-08 20:04:36 +0000221 mutex_lock(&priv->lock);
222 memset(priv->nodename, 0, sizeof(priv->nodename));
223 memcpy(priv->nodename, extra, dwrq->length);
224 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200225
Holger Schurig9012b282007-05-25 11:27:16 -0400226 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200227 return 0;
228}
229
Holger Schurig10078322007-11-15 18:05:47 -0500230static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200231 struct iw_point *dwrq, char *extra)
232{
Kiran Divekarab65f642009-02-19 19:32:39 -0500233 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200234
Holger Schurig9012b282007-05-25 11:27:16 -0400235 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200236
David Woodhouseaa21c002007-12-08 20:04:36 +0000237 dwrq->length = strlen(priv->nodename);
238 memcpy(extra, priv->nodename, dwrq->length);
Holger Schurig04799fa2007-10-09 15:04:14 +0200239 extra[dwrq->length] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200240
Holger Schurig04799fa2007-10-09 15:04:14 +0200241 dwrq->flags = 1; /* active */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200242
Holger Schurig9012b282007-05-25 11:27:16 -0400243 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200244 return 0;
245}
246
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400247static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
248 struct iw_point *dwrq, char *extra)
249{
Kiran Divekarab65f642009-02-19 19:32:39 -0500250 struct lbs_private *priv = dev->ml_priv;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400251
252 lbs_deb_enter(LBS_DEB_WEXT);
253
254 /* Use nickname to indicate that mesh is on */
255
David Woodhouseaa21c002007-12-08 20:04:36 +0000256 if (priv->mesh_connect_status == LBS_CONNECTED) {
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400257 strncpy(extra, "Mesh", 12);
258 extra[12] = '\0';
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400259 dwrq->length = strlen(extra);
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400260 }
261
262 else {
263 extra[0] = '\0';
Jean Tourrilhes9483f032007-08-02 13:16:30 -0400264 dwrq->length = 0;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400265 }
266
267 lbs_deb_leave(LBS_DEB_WEXT);
268 return 0;
269}
Holger Schurig04799fa2007-10-09 15:04:14 +0200270
Holger Schurig10078322007-11-15 18:05:47 -0500271static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200272 struct iw_param *vwrq, char *extra)
273{
274 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -0500275 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400276 u32 val = vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200277
Holger Schurig9012b282007-05-25 11:27:16 -0400278 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200279
Dan Williams39fcf7a2008-09-10 12:49:00 -0400280 if (vwrq->disabled)
281 val = MRVDRV_RTS_MAX_VALUE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200282
John W. Linville375da532008-09-15 17:25:54 -0400283 if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */
Dan Williams39fcf7a2008-09-10 12:49:00 -0400284 return -EINVAL;
285
286 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200287
Holger Schurig9012b282007-05-25 11:27:16 -0400288 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200289 return ret;
290}
291
Holger Schurig10078322007-11-15 18:05:47 -0500292static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200293 struct iw_param *vwrq, char *extra)
294{
Kiran Divekarab65f642009-02-19 19:32:39 -0500295 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400296 int ret = 0;
297 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200298
Holger Schurig9012b282007-05-25 11:27:16 -0400299 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200300
Dan Williams39fcf7a2008-09-10 12:49:00 -0400301 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
Holger Schurig9012b282007-05-25 11:27:16 -0400302 if (ret)
303 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200304
Dan Williams39fcf7a2008-09-10 12:49:00 -0400305 vwrq->value = val;
John W. Linville375da532008-09-15 17:25:54 -0400306 vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200307 vwrq->fixed = 1;
308
Holger Schurig9012b282007-05-25 11:27:16 -0400309out:
310 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
311 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200312}
313
Holger Schurig10078322007-11-15 18:05:47 -0500314static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200315 struct iw_param *vwrq, char *extra)
316{
Kiran Divekarab65f642009-02-19 19:32:39 -0500317 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400318 int ret = 0;
319 u32 val = vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200320
Holger Schurig9012b282007-05-25 11:27:16 -0400321 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200322
Dan Williams39fcf7a2008-09-10 12:49:00 -0400323 if (vwrq->disabled)
324 val = MRVDRV_FRAG_MAX_VALUE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200325
Dan Williams39fcf7a2008-09-10 12:49:00 -0400326 if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
327 return -EINVAL;
328
329 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
Holger Schurig9012b282007-05-25 11:27:16 -0400330
331 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200332 return ret;
333}
334
Holger Schurig10078322007-11-15 18:05:47 -0500335static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200336 struct iw_param *vwrq, char *extra)
337{
Kiran Divekarab65f642009-02-19 19:32:39 -0500338 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400339 int ret = 0;
340 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200341
Holger Schurig9012b282007-05-25 11:27:16 -0400342 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200343
Dan Williams39fcf7a2008-09-10 12:49:00 -0400344 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
Holger Schurig9012b282007-05-25 11:27:16 -0400345 if (ret)
346 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200347
Dan Williams39fcf7a2008-09-10 12:49:00 -0400348 vwrq->value = val;
349 vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
350 || (val > MRVDRV_FRAG_MAX_VALUE));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200351 vwrq->fixed = 1;
352
Holger Schurig9012b282007-05-25 11:27:16 -0400353out:
354 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200355 return ret;
356}
357
Holger Schurig10078322007-11-15 18:05:47 -0500358static int lbs_get_mode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200359 struct iw_request_info *info, u32 * uwrq, char *extra)
360{
Kiran Divekarab65f642009-02-19 19:32:39 -0500361 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200362
Holger Schurig9012b282007-05-25 11:27:16 -0400363 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200364
David Woodhouseaa21c002007-12-08 20:04:36 +0000365 *uwrq = priv->mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200366
Holger Schurig9012b282007-05-25 11:27:16 -0400367 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200368 return 0;
369}
370
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400371static int mesh_wlan_get_mode(struct net_device *dev,
372 struct iw_request_info *info, u32 * uwrq,
373 char *extra)
374{
375 lbs_deb_enter(LBS_DEB_WEXT);
376
Dan Williams39fcf7a2008-09-10 12:49:00 -0400377 *uwrq = IW_MODE_REPEAT;
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -0400378
379 lbs_deb_leave(LBS_DEB_WEXT);
380 return 0;
381}
382
Holger Schurig10078322007-11-15 18:05:47 -0500383static int lbs_get_txpow(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200384 struct iw_request_info *info,
385 struct iw_param *vwrq, char *extra)
386{
Kiran Divekarab65f642009-02-19 19:32:39 -0500387 struct lbs_private *priv = dev->ml_priv;
Dan Williams87c8c722008-08-19 15:15:35 -0400388 s16 curlevel = 0;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400389 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200390
Holger Schurig9012b282007-05-25 11:27:16 -0400391 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200392
Dan Williamsd5db2df2008-08-21 17:51:07 -0400393 if (!priv->radio_on) {
394 lbs_deb_wext("tx power off\n");
395 vwrq->value = 0;
396 vwrq->disabled = 1;
397 goto out;
398 }
399
Dan Williams87c8c722008-08-19 15:15:35 -0400400 ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
Holger Schurig9012b282007-05-25 11:27:16 -0400401 if (ret)
402 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200403
Dan Williams87c8c722008-08-19 15:15:35 -0400404 lbs_deb_wext("tx power level %d dbm\n", curlevel);
Dan Williams87c8c722008-08-19 15:15:35 -0400405 priv->txpower_cur = curlevel;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400406
Dan Williams87c8c722008-08-19 15:15:35 -0400407 vwrq->value = curlevel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200408 vwrq->fixed = 1;
Dan Williamsd5db2df2008-08-21 17:51:07 -0400409 vwrq->disabled = 0;
410 vwrq->flags = IW_TXPOW_DBM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200411
Holger Schurig9012b282007-05-25 11:27:16 -0400412out:
413 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
414 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200415}
416
Holger Schurig10078322007-11-15 18:05:47 -0500417static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200418 struct iw_param *vwrq, char *extra)
419{
Kiran Divekarab65f642009-02-19 19:32:39 -0500420 struct lbs_private *priv = dev->ml_priv;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400421 int ret = 0;
422 u16 slimit = 0, llimit = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200423
Holger Schurig9012b282007-05-25 11:27:16 -0400424 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200425
Dan Williams39fcf7a2008-09-10 12:49:00 -0400426 if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
427 return -EOPNOTSUPP;
428
429 /* The MAC has a 4-bit Total_Tx_Count register
430 Total_Tx_Count = 1 + Tx_Retry_Count */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200431#define TX_RETRY_MIN 0
432#define TX_RETRY_MAX 14
Dan Williams39fcf7a2008-09-10 12:49:00 -0400433 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
434 return -EINVAL;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200435
Dan Williams39fcf7a2008-09-10 12:49:00 -0400436 /* Add 1 to convert retry count to try count */
437 if (vwrq->flags & IW_RETRY_SHORT)
438 slimit = (u16) (vwrq->value + 1);
439 else if (vwrq->flags & IW_RETRY_LONG)
440 llimit = (u16) (vwrq->value + 1);
441 else
442 slimit = llimit = (u16) (vwrq->value + 1); /* set both */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200443
Dan Williams39fcf7a2008-09-10 12:49:00 -0400444 if (llimit) {
445 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
446 llimit);
Holger Schurig9012b282007-05-25 11:27:16 -0400447 if (ret)
448 goto out;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400449 }
450
451 if (slimit) {
452 /* txretrycount follows the short retry limit */
453 priv->txretrycount = slimit;
454 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
455 slimit);
456 if (ret)
457 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200458 }
459
Holger Schurig9012b282007-05-25 11:27:16 -0400460out:
461 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
462 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200463}
464
Holger Schurig10078322007-11-15 18:05:47 -0500465static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200466 struct iw_param *vwrq, char *extra)
467{
Kiran Divekarab65f642009-02-19 19:32:39 -0500468 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200469 int ret = 0;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400470 u16 val = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200471
Holger Schurig9012b282007-05-25 11:27:16 -0400472 lbs_deb_enter(LBS_DEB_WEXT);
473
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200474 vwrq->disabled = 0;
Dan Williams39fcf7a2008-09-10 12:49:00 -0400475
476 if (vwrq->flags & IW_RETRY_LONG) {
477 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
478 if (ret)
479 goto out;
480
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200481 /* Subtract 1 to convert try count to retry count */
Dan Williams39fcf7a2008-09-10 12:49:00 -0400482 vwrq->value = val - 1;
483 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
484 } else {
485 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
486 if (ret)
487 goto out;
488
489 /* txretry count follows the short retry limit */
490 priv->txretrycount = val;
491 /* Subtract 1 to convert try count to retry count */
492 vwrq->value = val - 1;
493 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200494 }
495
Holger Schurig9012b282007-05-25 11:27:16 -0400496out:
497 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
498 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200499}
500
501static inline void sort_channels(struct iw_freq *freq, int num)
502{
503 int i, j;
504 struct iw_freq temp;
505
506 for (i = 0; i < num; i++)
507 for (j = i + 1; j < num; j++)
508 if (freq[i].i > freq[j].i) {
509 temp.i = freq[i].i;
510 temp.m = freq[i].m;
511
512 freq[i].i = freq[j].i;
513 freq[i].m = freq[j].m;
514
515 freq[j].i = temp.i;
516 freq[j].m = temp.m;
517 }
518}
519
520/* data rate listing
521 MULTI_BANDS:
522 abg a b b/g
523 Infra G(12) A(8) B(4) G(12)
524 Adhoc A+B(12) A(8) B(4) B(4)
525
526 non-MULTI_BANDS:
527 b b/g
528 Infra B(4) G(12)
529 Adhoc B(4) B(4)
530 */
531/**
532 * @brief Get Range Info
533 *
534 * @param dev A pointer to net_device structure
535 * @param info A pointer to iw_request_info structure
536 * @param vwrq A pointer to iw_param structure
537 * @param extra A pointer to extra data buf
538 * @return 0 --success, otherwise fail
539 */
Holger Schurig10078322007-11-15 18:05:47 -0500540static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200541 struct iw_point *dwrq, char *extra)
542{
543 int i, j;
Kiran Divekarab65f642009-02-19 19:32:39 -0500544 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200545 struct iw_range *range = (struct iw_range *)extra;
546 struct chan_freq_power *cfp;
Dan Williams8c512762007-08-02 11:40:45 -0400547 u8 rates[MAX_RATES + 1];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200548
549 u8 flag = 0;
550
Holger Schurig9012b282007-05-25 11:27:16 -0400551 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200552
553 dwrq->length = sizeof(struct iw_range);
554 memset(range, 0, sizeof(struct iw_range));
555
556 range->min_nwid = 0;
557 range->max_nwid = 0;
558
559 memset(rates, 0, sizeof(rates));
David Woodhouseaa21c002007-12-08 20:04:36 +0000560 copy_active_data_rates(priv, rates);
Dan Williams8c512762007-08-02 11:40:45 -0400561 range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
562 for (i = 0; i < range->num_bitrates; i++)
563 range->bitrate[i] = rates[i] * 500000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200564 range->num_bitrates = i;
Holger Schurig9012b282007-05-25 11:27:16 -0400565 lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200566 range->num_bitrates);
567
568 range->num_frequency = 0;
Holger Schurig52933d82008-03-05 07:05:32 +0100569
570 range->scan_capa = IW_SCAN_CAPA_ESSID;
571
David Woodhouseaa21c002007-12-08 20:04:36 +0000572 if (priv->enable11d &&
573 (priv->connect_status == LBS_CONNECTED ||
574 priv->mesh_connect_status == LBS_CONNECTED)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200575 u8 chan_no;
576 u8 band;
577
578 struct parsed_region_chan_11d *parsed_region_chan =
David Woodhouseaa21c002007-12-08 20:04:36 +0000579 &priv->parsed_region_chan;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200580
581 if (parsed_region_chan == NULL) {
Holger Schurig9012b282007-05-25 11:27:16 -0400582 lbs_deb_wext("11d: parsed_region_chan is NULL\n");
583 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200584 }
585 band = parsed_region_chan->band;
Holger Schurig9012b282007-05-25 11:27:16 -0400586 lbs_deb_wext("band %d, nr_char %d\n", band,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200587 parsed_region_chan->nr_chan);
588
589 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
590 && (i < parsed_region_chan->nr_chan); i++) {
591 chan_no = parsed_region_chan->chanpwr[i].chan;
Holger Schurig9012b282007-05-25 11:27:16 -0400592 lbs_deb_wext("chan_no %d\n", chan_no);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200593 range->freq[range->num_frequency].i = (long)chan_no;
594 range->freq[range->num_frequency].m =
Holger Schurige98a88d2008-03-19 14:25:58 +0100595 (long)lbs_chan_2_freq(chan_no) * 100000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200596 range->freq[range->num_frequency].e = 1;
597 range->num_frequency++;
598 }
599 flag = 1;
600 }
601 if (!flag) {
602 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
David Woodhouseaa21c002007-12-08 20:04:36 +0000603 && (j < ARRAY_SIZE(priv->region_channel)); j++) {
604 cfp = priv->region_channel[j].CFP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200605 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
David Woodhouseaa21c002007-12-08 20:04:36 +0000606 && priv->region_channel[j].valid
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200607 && cfp
David Woodhouseaa21c002007-12-08 20:04:36 +0000608 && (i < priv->region_channel[j].nrcfp); i++) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200609 range->freq[range->num_frequency].i =
610 (long)cfp->channel;
611 range->freq[range->num_frequency].m =
612 (long)cfp->freq * 100000;
613 range->freq[range->num_frequency].e = 1;
614 cfp++;
615 range->num_frequency++;
616 }
617 }
618 }
619
Holger Schurig9012b282007-05-25 11:27:16 -0400620 lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200621 IW_MAX_FREQUENCIES, range->num_frequency);
622
623 range->num_channels = range->num_frequency;
624
625 sort_channels(&range->freq[0], range->num_frequency);
626
627 /*
628 * Set an indication of the max TCP throughput in bit/s that we can
629 * expect using this interface
630 */
631 if (i > 2)
632 range->throughput = 5000 * 1000;
633 else
634 range->throughput = 1500 * 1000;
635
636 range->min_rts = MRVDRV_RTS_MIN_VALUE;
637 range->max_rts = MRVDRV_RTS_MAX_VALUE;
638 range->min_frag = MRVDRV_FRAG_MIN_VALUE;
639 range->max_frag = MRVDRV_FRAG_MAX_VALUE;
640
641 range->encoding_size[0] = 5;
642 range->encoding_size[1] = 13;
643 range->num_encoding_sizes = 2;
644 range->max_encoding_tokens = 4;
645
Holger Schurigd4ff0ef2008-03-19 14:25:18 +0100646 /*
647 * Right now we support only "iwconfig ethX power on|off"
648 */
649 range->pm_capa = IW_POWER_ON;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200650
651 /*
652 * Minimum version we recommend
653 */
654 range->we_version_source = 15;
655
656 /*
657 * Version we are compiled with
658 */
659 range->we_version_compiled = WIRELESS_EXT;
660
661 range->retry_capa = IW_RETRY_LIMIT;
662 range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
663
664 range->min_retry = TX_RETRY_MIN;
665 range->max_retry = TX_RETRY_MAX;
666
667 /*
668 * Set the qual, level and noise range values
669 */
670 range->max_qual.qual = 100;
671 range->max_qual.level = 0;
672 range->max_qual.noise = 0;
673 range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
674
675 range->avg_qual.qual = 70;
676 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
677 range->avg_qual.level = 0;
678 range->avg_qual.noise = 0;
679 range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
680
681 range->sensitivity = 0;
682
Dan Williams87c8c722008-08-19 15:15:35 -0400683 /* Setup the supported power level ranges */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200684 memset(range->txpower, 0, sizeof(range->txpower));
Dan Williams87c8c722008-08-19 15:15:35 -0400685 range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE;
686 range->txpower[0] = priv->txpower_min;
687 range->txpower[1] = priv->txpower_max;
688 range->num_txpower = 2;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200689
690 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
691 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
692 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
693 range->event_capa[1] = IW_EVENT_CAPA_K_1;
694
David Woodhouseaa21c002007-12-08 20:04:36 +0000695 if (priv->fwcapinfo & FW_CAPINFO_WPA) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200696 range->enc_capa = IW_ENC_CAPA_WPA
697 | IW_ENC_CAPA_WPA2
698 | IW_ENC_CAPA_CIPHER_TKIP
699 | IW_ENC_CAPA_CIPHER_CCMP;
700 }
701
Holger Schurig9012b282007-05-25 11:27:16 -0400702out:
703 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200704 return 0;
705}
706
Holger Schurig10078322007-11-15 18:05:47 -0500707static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200708 struct iw_param *vwrq, char *extra)
709{
Kiran Divekarab65f642009-02-19 19:32:39 -0500710 struct lbs_private *priv = dev->ml_priv;
Amitkumar Karwar49125452009-09-30 20:04:38 -0700711 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200712
Holger Schurig9012b282007-05-25 11:27:16 -0400713 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200714
Andrey Yurovskye0d61332009-06-16 13:20:01 -0700715 if (!(priv->fwcapinfo & FW_CAPINFO_PS)) {
David Woodhouseb2c57ee2007-12-17 14:41:13 -0500716 if (vwrq->disabled)
717 return 0;
718 else
719 return -EINVAL;
720 }
721
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200722 /* PS is currently supported only in Infrastructure mode
723 * Remove this check if it is to be supported in IBSS mode also
724 */
725
726 if (vwrq->disabled) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000727 priv->psmode = LBS802_11POWERMODECAM;
728 if (priv->psstate != PS_STATE_FULL_POWER) {
Holger Schurig10078322007-11-15 18:05:47 -0500729 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200730 }
731
732 return 0;
733 }
734
735 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
Holger Schurig9012b282007-05-25 11:27:16 -0400736 lbs_deb_wext(
737 "setting power timeout is not supported\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200738 return -EINVAL;
739 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
Amitkumar Karwar49125452009-09-30 20:04:38 -0700740 vwrq->value = vwrq->value / 1000;
741 if (!priv->enter_deep_sleep) {
742 lbs_pr_err("deep sleep feature is not implemented "
743 "for this interface driver\n");
744 return -EINVAL;
745 }
746
747 if (priv->connect_status == LBS_CONNECTED) {
748 if ((priv->is_auto_deep_sleep_enabled) &&
749 (vwrq->value == -1000)) {
750 lbs_exit_auto_deep_sleep(priv);
751 return 0;
752 } else {
753 lbs_pr_err("can't use deep sleep cmd in "
754 "connected state\n");
755 return -EINVAL;
756 }
757 }
758
759 if ((vwrq->value < 0) && (vwrq->value != -1000)) {
760 lbs_pr_err("unknown option\n");
761 return -EINVAL;
762 }
763
764 if (vwrq->value > 0) {
765 if (!priv->is_auto_deep_sleep_enabled) {
766 priv->is_activity_detected = 0;
767 priv->auto_deep_sleep_timeout = vwrq->value;
768 lbs_enter_auto_deep_sleep(priv);
769 } else {
770 priv->auto_deep_sleep_timeout = vwrq->value;
771 lbs_deb_debugfs("auto deep sleep: "
772 "already enabled\n");
773 }
774 return 0;
775 } else {
776 if (priv->is_auto_deep_sleep_enabled) {
777 lbs_exit_auto_deep_sleep(priv);
778 /* Try to exit deep sleep if auto */
779 /*deep sleep disabled */
780 ret = lbs_set_deep_sleep(priv, 0);
781 }
782 if (vwrq->value == 0)
783 ret = lbs_set_deep_sleep(priv, 1);
784 else if (vwrq->value == -1000)
785 ret = lbs_set_deep_sleep(priv, 0);
786 return ret;
787 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200788 }
789
David Woodhouseaa21c002007-12-08 20:04:36 +0000790 if (priv->psmode != LBS802_11POWERMODECAM) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200791 return 0;
792 }
793
David Woodhouseaa21c002007-12-08 20:04:36 +0000794 priv->psmode = LBS802_11POWERMODEMAX_PSP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200795
David Woodhouseaa21c002007-12-08 20:04:36 +0000796 if (priv->connect_status == LBS_CONNECTED) {
Holger Schurig10078322007-11-15 18:05:47 -0500797 lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200798 }
799
Holger Schurig9012b282007-05-25 11:27:16 -0400800 lbs_deb_leave(LBS_DEB_WEXT);
Amitkumar Karwar49125452009-09-30 20:04:38 -0700801
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200802 return 0;
803}
804
Holger Schurig10078322007-11-15 18:05:47 -0500805static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200806 struct iw_param *vwrq, char *extra)
807{
Kiran Divekarab65f642009-02-19 19:32:39 -0500808 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200809
Holger Schurig9012b282007-05-25 11:27:16 -0400810 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200811
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200812 vwrq->value = 0;
Holger Schurigd4ff0ef2008-03-19 14:25:18 +0100813 vwrq->flags = 0;
814 vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM
815 || priv->connect_status == LBS_DISCONNECTED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200816
Holger Schurig9012b282007-05-25 11:27:16 -0400817 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200818 return 0;
819}
820
Holger Schurig10078322007-11-15 18:05:47 -0500821static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200822{
823 enum {
824 POOR = 30,
825 FAIR = 60,
826 GOOD = 80,
827 VERY_GOOD = 90,
828 EXCELLENT = 95,
829 PERFECT = 100
830 };
Kiran Divekarab65f642009-02-19 19:32:39 -0500831 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200832 u32 rssi_qual;
833 u32 tx_qual;
834 u32 quality = 0;
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700835 int ret, stats_valid = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200836 u8 rssi;
837 u32 tx_retries;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100838 struct cmd_ds_802_11_get_log log;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200839
Holger Schurig9012b282007-05-25 11:27:16 -0400840 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200841
David Woodhouseaa21c002007-12-08 20:04:36 +0000842 priv->wstats.status = priv->mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200843
844 /* If we're not associated, all quality values are meaningless */
David Woodhouseaa21c002007-12-08 20:04:36 +0000845 if ((priv->connect_status != LBS_CONNECTED) &&
846 (priv->mesh_connect_status != LBS_CONNECTED))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200847 goto out;
848
849 /* Quality by RSSI */
850 priv->wstats.qual.level =
David Woodhouseaa21c002007-12-08 20:04:36 +0000851 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
852 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200853
David Woodhouseaa21c002007-12-08 20:04:36 +0000854 if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200855 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
856 } else {
857 priv->wstats.qual.noise =
David Woodhouseaa21c002007-12-08 20:04:36 +0000858 CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200859 }
860
Holger Schurig9012b282007-05-25 11:27:16 -0400861 lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
862 lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200863
864 rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
865 if (rssi < 15)
866 rssi_qual = rssi * POOR / 10;
867 else if (rssi < 20)
868 rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
869 else if (rssi < 30)
870 rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
871 else if (rssi < 40)
872 rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
873 10 + GOOD;
874 else
875 rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
876 10 + VERY_GOOD;
877 quality = rssi_qual;
878
879 /* Quality by TX errors */
Stephen Hemmingerbbfc6b72009-03-20 19:36:36 +0000880 priv->wstats.discard.retries = dev->stats.tx_errors;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200881
Holger Schurigc49c3b72008-03-17 12:45:58 +0100882 memset(&log, 0, sizeof(log));
883 log.hdr.size = cpu_to_le16(sizeof(log));
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700884 ret = lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
885 if (ret)
886 goto out;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100887
888 tx_retries = le32_to_cpu(log.retry);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200889
890 if (tx_retries > 75)
891 tx_qual = (90 - tx_retries) * POOR / 15;
892 else if (tx_retries > 70)
893 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
894 else if (tx_retries > 65)
895 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
896 else if (tx_retries > 50)
897 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
898 15 + GOOD;
899 else
900 tx_qual = (50 - tx_retries) *
901 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
902 quality = min(quality, tx_qual);
903
Holger Schurigc49c3b72008-03-17 12:45:58 +0100904 priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200905 priv->wstats.discard.retries = tx_retries;
Holger Schurigc49c3b72008-03-17 12:45:58 +0100906 priv->wstats.discard.misc = le32_to_cpu(log.ackfailure);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200907
908 /* Calculate quality */
Holger Schurigcad9d9b2007-08-02 13:07:15 -0400909 priv->wstats.qual.qual = min_t(u8, quality, 100);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200910 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
911 stats_valid = 1;
912
913 /* update stats asynchronously for future calls */
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700914 ret = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200915 0, 0, NULL);
Amitkumar Karwarc0bbd572009-10-08 19:38:45 -0700916 if (ret)
917 lbs_pr_err("RSSI command failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200918out:
919 if (!stats_valid) {
920 priv->wstats.miss.beacon = 0;
921 priv->wstats.discard.retries = 0;
922 priv->wstats.qual.qual = 0;
923 priv->wstats.qual.level = 0;
924 priv->wstats.qual.noise = 0;
925 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
926 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
927 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
928 }
929
Holger Schurig9012b282007-05-25 11:27:16 -0400930 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200931 return &priv->wstats;
932
933
934}
935
Holger Schurig10078322007-11-15 18:05:47 -0500936static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200937 struct iw_freq *fwrq, char *extra)
938{
Dan Williamsef9a2642007-05-25 16:46:33 -0400939 int ret = -EINVAL;
Kiran Divekarab65f642009-02-19 19:32:39 -0500940 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200941 struct chan_freq_power *cfp;
Dan Williamsef9a2642007-05-25 16:46:33 -0400942 struct assoc_request * assoc_req;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200943
Holger Schurig9012b282007-05-25 11:27:16 -0400944 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200945
David Woodhouseaa21c002007-12-08 20:04:36 +0000946 mutex_lock(&priv->lock);
947 assoc_req = lbs_get_association_request(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400948 if (!assoc_req) {
949 ret = -ENOMEM;
950 goto out;
951 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200952
Dan Williamsef9a2642007-05-25 16:46:33 -0400953 /* If setting by frequency, convert to a channel */
954 if (fwrq->e == 1) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200955 long f = fwrq->m / 100000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200956
David Woodhouseaa21c002007-12-08 20:04:36 +0000957 cfp = find_cfp_by_band_and_freq(priv, 0, f);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200958 if (!cfp) {
Holger Schurig9012b282007-05-25 11:27:16 -0400959 lbs_deb_wext("invalid freq %ld\n", f);
Dan Williamsef9a2642007-05-25 16:46:33 -0400960 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200961 }
962
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200963 fwrq->e = 0;
Dan Williamsef9a2642007-05-25 16:46:33 -0400964 fwrq->m = (int) cfp->channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200965 }
966
Dan Williamsef9a2642007-05-25 16:46:33 -0400967 /* Setting by channel number */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200968 if (fwrq->m > 1000 || fwrq->e > 0) {
Dan Williamsef9a2642007-05-25 16:46:33 -0400969 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200970 }
971
David Woodhouseaa21c002007-12-08 20:04:36 +0000972 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
Dan Williamsef9a2642007-05-25 16:46:33 -0400973 if (!cfp) {
974 goto out;
975 }
976
977 assoc_req->channel = fwrq->m;
978 ret = 0;
979
Holger Schurig9012b282007-05-25 11:27:16 -0400980out:
Dan Williamsef9a2642007-05-25 16:46:33 -0400981 if (ret == 0) {
982 set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -0500983 lbs_postpone_association_work(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400984 } else {
Holger Schurig10078322007-11-15 18:05:47 -0500985 lbs_cancel_association_work(priv);
Dan Williamsef9a2642007-05-25 16:46:33 -0400986 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000987 mutex_unlock(&priv->lock);
Dan Williamsef9a2642007-05-25 16:46:33 -0400988
989 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
990 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200991}
992
David Woodhouse823eaa22007-12-11 19:56:28 -0500993static int lbs_mesh_set_freq(struct net_device *dev,
994 struct iw_request_info *info,
995 struct iw_freq *fwrq, char *extra)
996{
Kiran Divekarab65f642009-02-19 19:32:39 -0500997 struct lbs_private *priv = dev->ml_priv;
David Woodhouse823eaa22007-12-11 19:56:28 -0500998 struct chan_freq_power *cfp;
999 int ret = -EINVAL;
1000
1001 lbs_deb_enter(LBS_DEB_WEXT);
1002
1003 /* If setting by frequency, convert to a channel */
1004 if (fwrq->e == 1) {
1005 long f = fwrq->m / 100000;
1006
1007 cfp = find_cfp_by_band_and_freq(priv, 0, f);
1008 if (!cfp) {
1009 lbs_deb_wext("invalid freq %ld\n", f);
1010 goto out;
1011 }
1012
1013 fwrq->e = 0;
1014 fwrq->m = (int) cfp->channel;
1015 }
1016
1017 /* Setting by channel number */
1018 if (fwrq->m > 1000 || fwrq->e > 0) {
1019 goto out;
1020 }
1021
1022 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
1023 if (!cfp) {
1024 goto out;
1025 }
1026
1027 if (fwrq->m != priv->curbssparams.channel) {
1028 lbs_deb_wext("mesh channel change forces eth disconnect\n");
1029 if (priv->mode == IW_MODE_INFRA)
Dan Williams191bb402008-08-21 17:46:18 -04001030 lbs_cmd_80211_deauthenticate(priv,
1031 priv->curbssparams.bssid,
1032 WLAN_REASON_DEAUTH_LEAVING);
David Woodhouse823eaa22007-12-11 19:56:28 -05001033 else if (priv->mode == IW_MODE_ADHOC)
Dan Williamsf5fe1fd2008-08-21 21:46:59 -04001034 lbs_adhoc_stop(priv);
David Woodhouse823eaa22007-12-11 19:56:28 -05001035 }
Javier Cardonaedaea5c2008-05-17 00:55:10 -07001036 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m);
David Woodhouse86062132007-12-13 00:32:36 -05001037 lbs_update_channel(priv);
David Woodhouse823eaa22007-12-11 19:56:28 -05001038 ret = 0;
1039
1040out:
1041 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1042 return ret;
1043}
1044
Holger Schurig10078322007-11-15 18:05:47 -05001045static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001046 struct iw_param *vwrq, char *extra)
1047{
Kiran Divekarab65f642009-02-19 19:32:39 -05001048 struct lbs_private *priv = dev->ml_priv;
Dan Williams8e3c91b2007-12-11 15:50:59 -05001049 u8 new_rate = 0;
Dan Williams8c512762007-08-02 11:40:45 -04001050 int ret = -EINVAL;
1051 u8 rates[MAX_RATES + 1];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001052
Holger Schurig9012b282007-05-25 11:27:16 -04001053 lbs_deb_enter(LBS_DEB_WEXT);
Amitkumar Karwar49125452009-09-30 20:04:38 -07001054
Holger Schurig9012b282007-05-25 11:27:16 -04001055 lbs_deb_wext("vwrq->value %d\n", vwrq->value);
Javier Cardona85319f92008-05-24 10:59:49 +01001056 lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed);
1057
1058 if (vwrq->fixed && vwrq->value == -1)
1059 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001060
Dan Williams8c512762007-08-02 11:40:45 -04001061 /* Auto rate? */
Javier Cardona85319f92008-05-24 10:59:49 +01001062 priv->enablehwauto = !vwrq->fixed;
1063
1064 if (vwrq->value == -1)
David Woodhouseaa21c002007-12-08 20:04:36 +00001065 priv->cur_rate = 0;
Javier Cardona85319f92008-05-24 10:59:49 +01001066 else {
Dan Williams8c512762007-08-02 11:40:45 -04001067 if (vwrq->value % 100000)
1068 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001069
Javier Cardona85319f92008-05-24 10:59:49 +01001070 new_rate = vwrq->value / 500000;
1071 priv->cur_rate = new_rate;
1072 /* the rest is only needed for lbs_set_data_rate() */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001073 memset(rates, 0, sizeof(rates));
David Woodhouseaa21c002007-12-08 20:04:36 +00001074 copy_active_data_rates(priv, rates);
Dan Williams8c512762007-08-02 11:40:45 -04001075 if (!memchr(rates, new_rate, sizeof(rates))) {
1076 lbs_pr_alert("fixed data rate 0x%X out of range\n",
1077 new_rate);
1078 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001079 }
Anna Neal3ed6e082008-09-26 11:34:35 -04001080 if (priv->fwrelease < 0x09000000) {
1081 ret = lbs_set_power_adapt_cfg(priv, 0,
1082 POW_ADAPT_DEFAULT_P0,
1083 POW_ADAPT_DEFAULT_P1,
1084 POW_ADAPT_DEFAULT_P2);
1085 if (ret)
1086 goto out;
1087 }
1088 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1089 TPC_DEFAULT_P2, 1);
1090 if (ret)
1091 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001092 }
1093
Javier Cardona85319f92008-05-24 10:59:49 +01001094 /* Try the newer command first (Firmware Spec 5.1 and above) */
1095 ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET);
1096
1097 /* Fallback to older version */
1098 if (ret)
1099 ret = lbs_set_data_rate(priv, new_rate);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001100
Dan Williams8c512762007-08-02 11:40:45 -04001101out:
Holger Schurig9012b282007-05-25 11:27:16 -04001102 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001103 return ret;
1104}
1105
Holger Schurig10078322007-11-15 18:05:47 -05001106static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001107 struct iw_param *vwrq, char *extra)
1108{
Kiran Divekarab65f642009-02-19 19:32:39 -05001109 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001110
Holger Schurig9012b282007-05-25 11:27:16 -04001111 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001112
David Woodhouseaa21c002007-12-08 20:04:36 +00001113 if (priv->connect_status == LBS_CONNECTED) {
1114 vwrq->value = priv->cur_rate * 500000;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001115
Javier Cardona85319f92008-05-24 10:59:49 +01001116 if (priv->enablehwauto)
Dan Williams8c512762007-08-02 11:40:45 -04001117 vwrq->fixed = 0;
1118 else
1119 vwrq->fixed = 1;
1120
1121 } else {
1122 vwrq->fixed = 0;
1123 vwrq->value = 0;
1124 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001125
Holger Schurig9012b282007-05-25 11:27:16 -04001126 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001127 return 0;
1128}
1129
Holger Schurig10078322007-11-15 18:05:47 -05001130static int lbs_set_mode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001131 struct iw_request_info *info, u32 * uwrq, char *extra)
1132{
1133 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001134 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001135 struct assoc_request * assoc_req;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001136
Holger Schurig9012b282007-05-25 11:27:16 -04001137 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001138
Dan Williams0dc5a292007-05-10 22:58:02 -04001139 if ( (*uwrq != IW_MODE_ADHOC)
1140 && (*uwrq != IW_MODE_INFRA)
1141 && (*uwrq != IW_MODE_AUTO)) {
Holger Schurig9012b282007-05-25 11:27:16 -04001142 lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq);
Dan Williams0dc5a292007-05-10 22:58:02 -04001143 ret = -EINVAL;
1144 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001145 }
1146
David Woodhouseaa21c002007-12-08 20:04:36 +00001147 mutex_lock(&priv->lock);
1148 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001149 if (!assoc_req) {
1150 ret = -ENOMEM;
Holger Schurig10078322007-11-15 18:05:47 -05001151 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001152 } else {
Dan Williams0dc5a292007-05-10 22:58:02 -04001153 assoc_req->mode = *uwrq;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001154 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001155 lbs_postpone_association_work(priv);
Holger Schurig9012b282007-05-25 11:27:16 -04001156 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001157 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001158 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001159
Dan Williams0dc5a292007-05-10 22:58:02 -04001160out:
Holger Schurig9012b282007-05-25 11:27:16 -04001161 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001162 return ret;
1163}
1164
1165
1166/**
1167 * @brief Get Encryption key
1168 *
1169 * @param dev A pointer to net_device structure
1170 * @param info A pointer to iw_request_info structure
1171 * @param vwrq A pointer to iw_param structure
1172 * @param extra A pointer to extra data buf
1173 * @return 0 --success, otherwise fail
1174 */
Holger Schurig10078322007-11-15 18:05:47 -05001175static int lbs_get_encode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001176 struct iw_request_info *info,
1177 struct iw_point *dwrq, u8 * extra)
1178{
Kiran Divekarab65f642009-02-19 19:32:39 -05001179 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001180 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1181
Holger Schurig9012b282007-05-25 11:27:16 -04001182 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001183
Holger Schurig9012b282007-05-25 11:27:16 -04001184 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +00001185 dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001186
1187 dwrq->flags = 0;
1188
1189 /* Authentication method */
David Woodhouseaa21c002007-12-08 20:04:36 +00001190 switch (priv->secinfo.auth_mode) {
Dan Williams6affe782007-05-10 22:56:42 -04001191 case IW_AUTH_ALG_OPEN_SYSTEM:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001192 dwrq->flags = IW_ENCODE_OPEN;
1193 break;
1194
Dan Williams6affe782007-05-10 22:56:42 -04001195 case IW_AUTH_ALG_SHARED_KEY:
1196 case IW_AUTH_ALG_LEAP:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001197 dwrq->flags = IW_ENCODE_RESTRICTED;
1198 break;
1199 default:
1200 dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
1201 break;
1202 }
1203
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001204 memset(extra, 0, 16);
1205
David Woodhouseaa21c002007-12-08 20:04:36 +00001206 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001207
1208 /* Default to returning current transmit key */
1209 if (index < 0)
David Woodhouseaa21c002007-12-08 20:04:36 +00001210 index = priv->wep_tx_keyidx;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001211
David Woodhouseaa21c002007-12-08 20:04:36 +00001212 if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
1213 memcpy(extra, priv->wep_keys[index].key,
1214 priv->wep_keys[index].len);
1215 dwrq->length = priv->wep_keys[index].len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001216
1217 dwrq->flags |= (index + 1);
1218 /* Return WEP enabled */
1219 dwrq->flags &= ~IW_ENCODE_DISABLED;
David Woodhouseaa21c002007-12-08 20:04:36 +00001220 } else if ((priv->secinfo.WPAenabled)
1221 || (priv->secinfo.WPA2enabled)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001222 /* return WPA enabled */
1223 dwrq->flags &= ~IW_ENCODE_DISABLED;
David Woodhousec12bdc42007-12-07 19:32:12 +00001224 dwrq->flags |= IW_ENCODE_NOKEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001225 } else {
1226 dwrq->flags |= IW_ENCODE_DISABLED;
1227 }
1228
David Woodhouseaa21c002007-12-08 20:04:36 +00001229 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001230
Joe Perches0795af52007-10-03 17:59:30 -07001231 lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001232 extra[0], extra[1], extra[2],
1233 extra[3], extra[4], extra[5], dwrq->length);
1234
Holger Schurig9012b282007-05-25 11:27:16 -04001235 lbs_deb_wext("return flags 0x%x\n", dwrq->flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001236
Holger Schurig9012b282007-05-25 11:27:16 -04001237 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001238 return 0;
1239}
1240
1241/**
1242 * @brief Set Encryption key (internal)
1243 *
1244 * @param priv A pointer to private card structure
1245 * @param key_material A pointer to key material
1246 * @param key_length length of key material
1247 * @param index key index to set
1248 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1249 * @return 0 --success, otherwise fail
1250 */
Holger Schurig10078322007-11-15 18:05:47 -05001251static int lbs_set_wep_key(struct assoc_request *assoc_req,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001252 const char *key_material,
1253 u16 key_length,
1254 u16 index,
1255 int set_tx_key)
1256{
Holger Schurig9012b282007-05-25 11:27:16 -04001257 int ret = 0;
Dan Williams1443b652007-08-02 10:45:55 -04001258 struct enc_key *pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001259
Holger Schurig9012b282007-05-25 11:27:16 -04001260 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001261
1262 /* Paranoid validation of key index */
1263 if (index > 3) {
Holger Schurig9012b282007-05-25 11:27:16 -04001264 ret = -EINVAL;
1265 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001266 }
1267
1268 /* validate max key length */
1269 if (key_length > KEY_LEN_WEP_104) {
Holger Schurig9012b282007-05-25 11:27:16 -04001270 ret = -EINVAL;
1271 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001272 }
1273
1274 pkey = &assoc_req->wep_keys[index];
1275
1276 if (key_length > 0) {
Dan Williams1443b652007-08-02 10:45:55 -04001277 memset(pkey, 0, sizeof(struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001278 pkey->type = KEY_TYPE_ID_WEP;
1279
1280 /* Standardize the key length */
1281 pkey->len = (key_length > KEY_LEN_WEP_40) ?
1282 KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
1283 memcpy(pkey->key, key_material, key_length);
1284 }
1285
1286 if (set_tx_key) {
1287 /* Ensure the chosen key is valid */
1288 if (!pkey->len) {
Holger Schurig9012b282007-05-25 11:27:16 -04001289 lbs_deb_wext("key not set, so cannot enable it\n");
1290 ret = -EINVAL;
1291 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001292 }
1293 assoc_req->wep_tx_keyidx = index;
1294 }
1295
Dan Williams889c05b2007-05-10 22:57:23 -04001296 assoc_req->secinfo.wep_enabled = 1;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001297
Holger Schurig9012b282007-05-25 11:27:16 -04001298out:
1299 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1300 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001301}
1302
1303static int validate_key_index(u16 def_index, u16 raw_index,
1304 u16 *out_index, u16 *is_default)
1305{
1306 if (!out_index || !is_default)
1307 return -EINVAL;
1308
1309 /* Verify index if present, otherwise use default TX key index */
1310 if (raw_index > 0) {
1311 if (raw_index > 4)
1312 return -EINVAL;
1313 *out_index = raw_index - 1;
1314 } else {
1315 *out_index = def_index;
1316 *is_default = 1;
1317 }
1318 return 0;
1319}
1320
1321static void disable_wep(struct assoc_request *assoc_req)
1322{
1323 int i;
1324
Dan Williams90a42212007-05-25 23:01:24 -04001325 lbs_deb_enter(LBS_DEB_WEXT);
1326
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001327 /* Set Open System auth mode */
Dan Williams6affe782007-05-10 22:56:42 -04001328 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001329
1330 /* Clear WEP keys and mark WEP as disabled */
Dan Williams889c05b2007-05-10 22:57:23 -04001331 assoc_req->secinfo.wep_enabled = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001332 for (i = 0; i < 4; i++)
1333 assoc_req->wep_keys[i].len = 0;
1334
1335 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1336 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
Dan Williams90a42212007-05-25 23:01:24 -04001337
1338 lbs_deb_leave(LBS_DEB_WEXT);
1339}
1340
1341static void disable_wpa(struct assoc_request *assoc_req)
1342{
1343 lbs_deb_enter(LBS_DEB_WEXT);
1344
Dan Williams1443b652007-08-02 10:45:55 -04001345 memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key));
Dan Williams90a42212007-05-25 23:01:24 -04001346 assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
1347 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1348
Dan Williams1443b652007-08-02 10:45:55 -04001349 memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key));
Dan Williams90a42212007-05-25 23:01:24 -04001350 assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
1351 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1352
1353 assoc_req->secinfo.WPAenabled = 0;
1354 assoc_req->secinfo.WPA2enabled = 0;
1355 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1356
1357 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001358}
1359
1360/**
1361 * @brief Set Encryption key
1362 *
1363 * @param dev A pointer to net_device structure
1364 * @param info A pointer to iw_request_info structure
1365 * @param vwrq A pointer to iw_param structure
1366 * @param extra A pointer to extra data buf
1367 * @return 0 --success, otherwise fail
1368 */
Holger Schurig10078322007-11-15 18:05:47 -05001369static int lbs_set_encode(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001370 struct iw_request_info *info,
1371 struct iw_point *dwrq, char *extra)
1372{
1373 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001374 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001375 struct assoc_request * assoc_req;
1376 u16 is_default = 0, index = 0, set_tx_key = 0;
1377
Holger Schurig9012b282007-05-25 11:27:16 -04001378 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001379
David Woodhouseaa21c002007-12-08 20:04:36 +00001380 mutex_lock(&priv->lock);
1381 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001382 if (!assoc_req) {
1383 ret = -ENOMEM;
1384 goto out;
1385 }
1386
1387 if (dwrq->flags & IW_ENCODE_DISABLED) {
1388 disable_wep (assoc_req);
Dan Williams90a42212007-05-25 23:01:24 -04001389 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001390 goto out;
1391 }
1392
1393 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1394 (dwrq->flags & IW_ENCODE_INDEX),
1395 &index, &is_default);
1396 if (ret) {
1397 ret = -EINVAL;
1398 goto out;
1399 }
1400
1401 /* If WEP isn't enabled, or if there is no key data but a valid
1402 * index, set the TX key.
1403 */
Dan Williams889c05b2007-05-10 22:57:23 -04001404 if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001405 set_tx_key = 1;
1406
Holger Schurig10078322007-11-15 18:05:47 -05001407 ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001408 if (ret)
1409 goto out;
1410
1411 if (dwrq->length)
1412 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1413 if (set_tx_key)
1414 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1415
1416 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
Dan Williams6affe782007-05-10 22:56:42 -04001417 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001418 } else if (dwrq->flags & IW_ENCODE_OPEN) {
Dan Williams6affe782007-05-10 22:56:42 -04001419 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001420 }
1421
1422out:
1423 if (ret == 0) {
1424 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001425 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001426 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001427 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001428 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001429 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001430
Holger Schurig9012b282007-05-25 11:27:16 -04001431 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001432 return ret;
1433}
1434
1435/**
1436 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
1437 *
1438 * @param dev A pointer to net_device structure
1439 * @param info A pointer to iw_request_info structure
1440 * @param vwrq A pointer to iw_param structure
1441 * @param extra A pointer to extra data buf
1442 * @return 0 on success, otherwise failure
1443 */
Holger Schurig10078322007-11-15 18:05:47 -05001444static int lbs_get_encodeext(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001445 struct iw_request_info *info,
1446 struct iw_point *dwrq,
1447 char *extra)
1448{
1449 int ret = -EINVAL;
Kiran Divekarab65f642009-02-19 19:32:39 -05001450 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001451 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1452 int index, max_key_len;
1453
Holger Schurig9012b282007-05-25 11:27:16 -04001454 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001455
1456 max_key_len = dwrq->length - sizeof(*ext);
1457 if (max_key_len < 0)
1458 goto out;
1459
1460 index = dwrq->flags & IW_ENCODE_INDEX;
1461 if (index) {
1462 if (index < 1 || index > 4)
1463 goto out;
1464 index--;
1465 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +00001466 index = priv->wep_tx_keyidx;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001467 }
1468
Roel Kluinf59d9782007-10-26 21:51:26 +02001469 if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001470 ext->alg != IW_ENCODE_ALG_WEP) {
David Woodhouseaa21c002007-12-08 20:04:36 +00001471 if (index != 0 || priv->mode != IW_MODE_INFRA)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001472 goto out;
1473 }
1474
1475 dwrq->flags = index + 1;
1476 memset(ext, 0, sizeof(*ext));
1477
David Woodhouseaa21c002007-12-08 20:04:36 +00001478 if ( !priv->secinfo.wep_enabled
1479 && !priv->secinfo.WPAenabled
1480 && !priv->secinfo.WPA2enabled) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001481 ext->alg = IW_ENCODE_ALG_NONE;
1482 ext->key_len = 0;
1483 dwrq->flags |= IW_ENCODE_DISABLED;
1484 } else {
1485 u8 *key = NULL;
1486
David Woodhouseaa21c002007-12-08 20:04:36 +00001487 if ( priv->secinfo.wep_enabled
1488 && !priv->secinfo.WPAenabled
1489 && !priv->secinfo.WPA2enabled) {
Dan Williams90a42212007-05-25 23:01:24 -04001490 /* WEP */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001491 ext->alg = IW_ENCODE_ALG_WEP;
David Woodhouseaa21c002007-12-08 20:04:36 +00001492 ext->key_len = priv->wep_keys[index].len;
1493 key = &priv->wep_keys[index].key[0];
1494 } else if ( !priv->secinfo.wep_enabled
1495 && (priv->secinfo.WPAenabled ||
1496 priv->secinfo.WPA2enabled)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001497 /* WPA */
Dan Williams1443b652007-08-02 10:45:55 -04001498 struct enc_key * pkey = NULL;
Dan Williams90a42212007-05-25 23:01:24 -04001499
David Woodhouseaa21c002007-12-08 20:04:36 +00001500 if ( priv->wpa_mcast_key.len
1501 && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
1502 pkey = &priv->wpa_mcast_key;
1503 else if ( priv->wpa_unicast_key.len
1504 && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
1505 pkey = &priv->wpa_unicast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001506
1507 if (pkey) {
1508 if (pkey->type == KEY_TYPE_ID_AES) {
1509 ext->alg = IW_ENCODE_ALG_CCMP;
1510 } else {
1511 ext->alg = IW_ENCODE_ALG_TKIP;
1512 }
1513 ext->key_len = pkey->len;
1514 key = &pkey->key[0];
1515 } else {
1516 ext->alg = IW_ENCODE_ALG_TKIP;
1517 ext->key_len = 0;
1518 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001519 } else {
1520 goto out;
1521 }
1522
1523 if (ext->key_len > max_key_len) {
1524 ret = -E2BIG;
1525 goto out;
1526 }
1527
1528 if (ext->key_len)
1529 memcpy(ext->key, key, ext->key_len);
1530 else
1531 dwrq->flags |= IW_ENCODE_NOKEY;
1532 dwrq->flags |= IW_ENCODE_ENABLED;
1533 }
1534 ret = 0;
1535
1536out:
Holger Schurig9012b282007-05-25 11:27:16 -04001537 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001538 return ret;
1539}
1540
1541/**
1542 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
1543 *
1544 * @param dev A pointer to net_device structure
1545 * @param info A pointer to iw_request_info structure
1546 * @param vwrq A pointer to iw_param structure
1547 * @param extra A pointer to extra data buf
1548 * @return 0 --success, otherwise fail
1549 */
Holger Schurig10078322007-11-15 18:05:47 -05001550static int lbs_set_encodeext(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001551 struct iw_request_info *info,
1552 struct iw_point *dwrq,
1553 char *extra)
1554{
1555 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001556 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001557 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1558 int alg = ext->alg;
1559 struct assoc_request * assoc_req;
1560
Holger Schurig9012b282007-05-25 11:27:16 -04001561 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001562
David Woodhouseaa21c002007-12-08 20:04:36 +00001563 mutex_lock(&priv->lock);
1564 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001565 if (!assoc_req) {
1566 ret = -ENOMEM;
1567 goto out;
1568 }
1569
1570 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
1571 disable_wep (assoc_req);
Dan Williams90a42212007-05-25 23:01:24 -04001572 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001573 } else if (alg == IW_ENCODE_ALG_WEP) {
1574 u16 is_default = 0, index, set_tx_key = 0;
1575
1576 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1577 (dwrq->flags & IW_ENCODE_INDEX),
1578 &index, &is_default);
1579 if (ret)
1580 goto out;
1581
1582 /* If WEP isn't enabled, or if there is no key data but a valid
1583 * index, or if the set-TX-key flag was passed, set the TX key.
1584 */
Dan Williams889c05b2007-05-10 22:57:23 -04001585 if ( !assoc_req->secinfo.wep_enabled
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001586 || (dwrq->length == 0 && !is_default)
1587 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
1588 set_tx_key = 1;
1589
1590 /* Copy key to driver */
Holger Schurig10078322007-11-15 18:05:47 -05001591 ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001592 set_tx_key);
1593 if (ret)
1594 goto out;
1595
1596 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
Dan Williams6affe782007-05-10 22:56:42 -04001597 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001598 } else if (dwrq->flags & IW_ENCODE_OPEN) {
Dan Williams6affe782007-05-10 22:56:42 -04001599 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001600 }
1601
1602 /* Mark the various WEP bits as modified */
1603 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1604 if (dwrq->length)
1605 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1606 if (set_tx_key)
1607 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001608 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
Dan Williams1443b652007-08-02 10:45:55 -04001609 struct enc_key * pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001610
1611 /* validate key length */
1612 if (((alg == IW_ENCODE_ALG_TKIP)
1613 && (ext->key_len != KEY_LEN_WPA_TKIP))
1614 || ((alg == IW_ENCODE_ALG_CCMP)
1615 && (ext->key_len != KEY_LEN_WPA_AES))) {
Joe Perches8376e7a2007-11-19 17:48:27 -08001616 lbs_deb_wext("invalid size %d for key of alg "
Holger Schurig9012b282007-05-25 11:27:16 -04001617 "type %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001618 ext->key_len,
1619 alg);
1620 ret = -EINVAL;
1621 goto out;
1622 }
1623
Dan Williams90a42212007-05-25 23:01:24 -04001624 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001625 pkey = &assoc_req->wpa_mcast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001626 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1627 } else {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001628 pkey = &assoc_req->wpa_unicast_key;
Dan Williams90a42212007-05-25 23:01:24 -04001629 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1630 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001631
Dan Williams1443b652007-08-02 10:45:55 -04001632 memset(pkey, 0, sizeof (struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001633 memcpy(pkey->key, ext->key, ext->key_len);
1634 pkey->len = ext->key_len;
Dan Williams90a42212007-05-25 23:01:24 -04001635 if (pkey->len)
1636 pkey->flags |= KEY_INFO_WPA_ENABLED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001637
Dan Williams90a42212007-05-25 23:01:24 -04001638 /* Do this after zeroing key structure */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001639 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1640 pkey->flags |= KEY_INFO_WPA_MCAST;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001641 } else {
1642 pkey->flags |= KEY_INFO_WPA_UNICAST;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001643 }
1644
Dan Williams90a42212007-05-25 23:01:24 -04001645 if (alg == IW_ENCODE_ALG_TKIP) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001646 pkey->type = KEY_TYPE_ID_TKIP;
Dan Williams90a42212007-05-25 23:01:24 -04001647 } else if (alg == IW_ENCODE_ALG_CCMP) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001648 pkey->type = KEY_TYPE_ID_AES;
Dan Williams90a42212007-05-25 23:01:24 -04001649 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001650
1651 /* If WPA isn't enabled yet, do that now */
1652 if ( assoc_req->secinfo.WPAenabled == 0
1653 && assoc_req->secinfo.WPA2enabled == 0) {
1654 assoc_req->secinfo.WPAenabled = 1;
1655 assoc_req->secinfo.WPA2enabled = 1;
1656 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1657 }
1658
Javier Cardona9c31fd632008-09-11 15:32:50 -07001659 /* Only disable wep if necessary: can't waste time here. */
1660 if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
1661 disable_wep(assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001662 }
1663
1664out:
Javier Cardona9c40fc52008-09-16 18:08:39 -07001665 if (ret == 0) {
1666 /* 802.1x and WPA rekeying must happen as quickly as possible,
1667 * especially during the 4-way handshake; thus if in
1668 * infrastructure mode, and either (a) 802.1x is enabled or
1669 * (b) WPA is being used, set the key right away.
1670 */
1671 if (assoc_req->mode == IW_MODE_INFRA &&
1672 ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
1673 (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
1674 assoc_req->secinfo.WPAenabled ||
1675 assoc_req->secinfo.WPA2enabled)) {
1676 lbs_do_association_work(priv);
1677 } else
1678 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001679 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001680 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001681 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001682 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001683
Holger Schurig9012b282007-05-25 11:27:16 -04001684 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001685 return ret;
1686}
1687
1688
Holger Schurig10078322007-11-15 18:05:47 -05001689static int lbs_set_genie(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001690 struct iw_request_info *info,
1691 struct iw_point *dwrq,
1692 char *extra)
1693{
Kiran Divekarab65f642009-02-19 19:32:39 -05001694 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001695 int ret = 0;
1696 struct assoc_request * assoc_req;
1697
Holger Schurig9012b282007-05-25 11:27:16 -04001698 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001699
David Woodhouseaa21c002007-12-08 20:04:36 +00001700 mutex_lock(&priv->lock);
1701 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001702 if (!assoc_req) {
1703 ret = -ENOMEM;
1704 goto out;
1705 }
1706
1707 if (dwrq->length > MAX_WPA_IE_LEN ||
1708 (dwrq->length && extra == NULL)) {
1709 ret = -EINVAL;
1710 goto out;
1711 }
1712
1713 if (dwrq->length) {
1714 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
1715 assoc_req->wpa_ie_len = dwrq->length;
1716 } else {
David Woodhouseaa21c002007-12-08 20:04:36 +00001717 memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001718 assoc_req->wpa_ie_len = 0;
1719 }
1720
1721out:
1722 if (ret == 0) {
1723 set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001724 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001725 } else {
Holger Schurig10078322007-11-15 18:05:47 -05001726 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001727 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001728 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001729
Holger Schurig9012b282007-05-25 11:27:16 -04001730 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001731 return ret;
1732}
1733
Holger Schurig10078322007-11-15 18:05:47 -05001734static int lbs_get_genie(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001735 struct iw_request_info *info,
1736 struct iw_point *dwrq,
1737 char *extra)
1738{
Holger Schurig9012b282007-05-25 11:27:16 -04001739 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001740 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001741
Holger Schurig9012b282007-05-25 11:27:16 -04001742 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001743
David Woodhouseaa21c002007-12-08 20:04:36 +00001744 if (priv->wpa_ie_len == 0) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001745 dwrq->length = 0;
Holger Schurig9012b282007-05-25 11:27:16 -04001746 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001747 }
1748
David Woodhouseaa21c002007-12-08 20:04:36 +00001749 if (dwrq->length < priv->wpa_ie_len) {
Holger Schurig9012b282007-05-25 11:27:16 -04001750 ret = -E2BIG;
1751 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001752 }
1753
David Woodhouseaa21c002007-12-08 20:04:36 +00001754 dwrq->length = priv->wpa_ie_len;
1755 memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001756
Holger Schurig9012b282007-05-25 11:27:16 -04001757out:
1758 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1759 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001760}
1761
1762
Holger Schurig10078322007-11-15 18:05:47 -05001763static int lbs_set_auth(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001764 struct iw_request_info *info,
1765 struct iw_param *dwrq,
1766 char *extra)
1767{
Kiran Divekarab65f642009-02-19 19:32:39 -05001768 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001769 struct assoc_request * assoc_req;
1770 int ret = 0;
1771 int updated = 0;
1772
Holger Schurig9012b282007-05-25 11:27:16 -04001773 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001774
David Woodhouseaa21c002007-12-08 20:04:36 +00001775 mutex_lock(&priv->lock);
1776 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001777 if (!assoc_req) {
1778 ret = -ENOMEM;
1779 goto out;
1780 }
1781
1782 switch (dwrq->flags & IW_AUTH_INDEX) {
Maithili Hinge2c8d5102009-07-31 20:02:19 -07001783 case IW_AUTH_PRIVACY_INVOKED:
1784 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001785 case IW_AUTH_TKIP_COUNTERMEASURES:
1786 case IW_AUTH_CIPHER_PAIRWISE:
1787 case IW_AUTH_CIPHER_GROUP:
Dan Williams90a42212007-05-25 23:01:24 -04001788 case IW_AUTH_DROP_UNENCRYPTED:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001789 /*
1790 * libertas does not use these parameters
1791 */
1792 break;
1793
Javier Cardona9c40fc52008-09-16 18:08:39 -07001794 case IW_AUTH_KEY_MGMT:
1795 assoc_req->secinfo.key_mgmt = dwrq->value;
1796 updated = 1;
1797 break;
1798
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001799 case IW_AUTH_WPA_VERSION:
1800 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
1801 assoc_req->secinfo.WPAenabled = 0;
1802 assoc_req->secinfo.WPA2enabled = 0;
Dan Williams90a42212007-05-25 23:01:24 -04001803 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001804 }
1805 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
1806 assoc_req->secinfo.WPAenabled = 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 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
1811 assoc_req->secinfo.WPA2enabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001812 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001813 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001814 }
1815 updated = 1;
1816 break;
1817
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001818 case IW_AUTH_80211_AUTH_ALG:
1819 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
Dan Williams6affe782007-05-10 22:56:42 -04001820 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001821 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
Dan Williams6affe782007-05-10 22:56:42 -04001822 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001823 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
Dan Williams6affe782007-05-10 22:56:42 -04001824 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001825 } else {
1826 ret = -EINVAL;
1827 }
1828 updated = 1;
1829 break;
1830
1831 case IW_AUTH_WPA_ENABLED:
1832 if (dwrq->value) {
1833 if (!assoc_req->secinfo.WPAenabled &&
1834 !assoc_req->secinfo.WPA2enabled) {
1835 assoc_req->secinfo.WPAenabled = 1;
1836 assoc_req->secinfo.WPA2enabled = 1;
Dan Williams889c05b2007-05-10 22:57:23 -04001837 assoc_req->secinfo.wep_enabled = 0;
Dan Williams6affe782007-05-10 22:56:42 -04001838 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001839 }
1840 } else {
1841 assoc_req->secinfo.WPAenabled = 0;
1842 assoc_req->secinfo.WPA2enabled = 0;
Dan Williams90a42212007-05-25 23:01:24 -04001843 disable_wpa (assoc_req);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001844 }
1845 updated = 1;
1846 break;
1847
1848 default:
1849 ret = -EOPNOTSUPP;
1850 break;
1851 }
1852
1853out:
1854 if (ret == 0) {
1855 if (updated)
1856 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05001857 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001858 } else if (ret != -EOPNOTSUPP) {
Holger Schurig10078322007-11-15 18:05:47 -05001859 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001860 }
David Woodhouseaa21c002007-12-08 20:04:36 +00001861 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001862
Holger Schurig9012b282007-05-25 11:27:16 -04001863 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001864 return ret;
1865}
1866
Holger Schurig10078322007-11-15 18:05:47 -05001867static int lbs_get_auth(struct net_device *dev,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001868 struct iw_request_info *info,
1869 struct iw_param *dwrq,
1870 char *extra)
1871{
Holger Schurig9012b282007-05-25 11:27:16 -04001872 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001873 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001874
Holger Schurig9012b282007-05-25 11:27:16 -04001875 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001876
1877 switch (dwrq->flags & IW_AUTH_INDEX) {
Javier Cardona9c40fc52008-09-16 18:08:39 -07001878 case IW_AUTH_KEY_MGMT:
1879 dwrq->value = priv->secinfo.key_mgmt;
1880 break;
1881
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001882 case IW_AUTH_WPA_VERSION:
1883 dwrq->value = 0;
David Woodhouseaa21c002007-12-08 20:04:36 +00001884 if (priv->secinfo.WPAenabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001885 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
David Woodhouseaa21c002007-12-08 20:04:36 +00001886 if (priv->secinfo.WPA2enabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001887 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
1888 if (!dwrq->value)
1889 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
1890 break;
1891
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001892 case IW_AUTH_80211_AUTH_ALG:
David Woodhouseaa21c002007-12-08 20:04:36 +00001893 dwrq->value = priv->secinfo.auth_mode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001894 break;
1895
1896 case IW_AUTH_WPA_ENABLED:
David Woodhouseaa21c002007-12-08 20:04:36 +00001897 if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001898 dwrq->value = 1;
1899 break;
1900
1901 default:
Holger Schurig9012b282007-05-25 11:27:16 -04001902 ret = -EOPNOTSUPP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001903 }
1904
Holger Schurig9012b282007-05-25 11:27:16 -04001905 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1906 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001907}
1908
1909
Holger Schurig10078322007-11-15 18:05:47 -05001910static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001911 struct iw_param *vwrq, char *extra)
1912{
1913 int ret = 0;
Kiran Divekarab65f642009-02-19 19:32:39 -05001914 struct lbs_private *priv = dev->ml_priv;
Dan Williams87c8c722008-08-19 15:15:35 -04001915 s16 dbm = (s16) vwrq->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001916
Holger Schurig9012b282007-05-25 11:27:16 -04001917 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001918
1919 if (vwrq->disabled) {
Dan Williamsd5db2df2008-08-21 17:51:07 -04001920 lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
Dan Williams87c8c722008-08-19 15:15:35 -04001921 goto out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001922 }
1923
Dan Williams87c8c722008-08-19 15:15:35 -04001924 if (vwrq->fixed == 0) {
Anna Neal0112c9e2008-09-11 11:17:25 -07001925 /* User requests automatic tx power control, however there are
1926 * many auto tx settings. For now use firmware defaults until
1927 * we come up with a good way to expose these to the user. */
1928 if (priv->fwrelease < 0x09000000) {
1929 ret = lbs_set_power_adapt_cfg(priv, 1,
1930 POW_ADAPT_DEFAULT_P0,
1931 POW_ADAPT_DEFAULT_P1,
1932 POW_ADAPT_DEFAULT_P2);
1933 if (ret)
1934 goto out;
1935 }
1936 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1937 TPC_DEFAULT_P2, 1);
1938 if (ret)
1939 goto out;
Dan Williams87c8c722008-08-19 15:15:35 -04001940 dbm = priv->txpower_max;
1941 } else {
1942 /* Userspace check in iwrange if it should use dBm or mW,
1943 * therefore this should never happen... Jean II */
1944 if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
1945 ret = -EOPNOTSUPP;
1946 goto out;
1947 }
1948
Anna Neal0112c9e2008-09-11 11:17:25 -07001949 /* Validate requested power level against firmware allowed
1950 * levels */
Dan Williams87c8c722008-08-19 15:15:35 -04001951 if (priv->txpower_min && (dbm < priv->txpower_min)) {
1952 ret = -EINVAL;
1953 goto out;
1954 }
1955
1956 if (priv->txpower_max && (dbm > priv->txpower_max)) {
1957 ret = -EINVAL;
1958 goto out;
1959 }
Anna Neal0112c9e2008-09-11 11:17:25 -07001960 if (priv->fwrelease < 0x09000000) {
1961 ret = lbs_set_power_adapt_cfg(priv, 0,
1962 POW_ADAPT_DEFAULT_P0,
1963 POW_ADAPT_DEFAULT_P1,
1964 POW_ADAPT_DEFAULT_P2);
1965 if (ret)
1966 goto out;
1967 }
1968 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1969 TPC_DEFAULT_P2, 1);
1970 if (ret)
1971 goto out;
Dan Williams87c8c722008-08-19 15:15:35 -04001972 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001973
Dan Williamsd5db2df2008-08-21 17:51:07 -04001974 /* If the radio was off, turn it on */
1975 if (!priv->radio_on) {
1976 ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
1977 if (ret)
1978 goto out;
1979 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001980
Dan Williams87c8c722008-08-19 15:15:35 -04001981 lbs_deb_wext("txpower set %d dBm\n", dbm);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001982
Dan Williams87c8c722008-08-19 15:15:35 -04001983 ret = lbs_set_tx_power(priv, dbm);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001984
Dan Williams87c8c722008-08-19 15:15:35 -04001985out:
Holger Schurig9012b282007-05-25 11:27:16 -04001986 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001987 return ret;
1988}
1989
Holger Schurig10078322007-11-15 18:05:47 -05001990static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001991 struct iw_point *dwrq, char *extra)
1992{
Kiran Divekarab65f642009-02-19 19:32:39 -05001993 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001994
Holger Schurig9012b282007-05-25 11:27:16 -04001995 lbs_deb_enter(LBS_DEB_WEXT);
1996
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001997 /*
1998 * Note : if dwrq->flags != 0, we should get the relevant SSID from
1999 * the SSID list...
2000 */
2001
2002 /*
2003 * Get the current SSID
2004 */
David Woodhouseaa21c002007-12-08 20:04:36 +00002005 if (priv->connect_status == LBS_CONNECTED) {
2006 memcpy(extra, priv->curbssparams.ssid,
2007 priv->curbssparams.ssid_len);
2008 extra[priv->curbssparams.ssid_len] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002009 } else {
2010 memset(extra, 0, 32);
David Woodhouseaa21c002007-12-08 20:04:36 +00002011 extra[priv->curbssparams.ssid_len] = '\0';
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002012 }
2013 /*
2014 * If none, we may want to get the one that was set
2015 */
2016
David Woodhouseaa21c002007-12-08 20:04:36 +00002017 dwrq->length = priv->curbssparams.ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002018
2019 dwrq->flags = 1; /* active */
2020
Holger Schurig9012b282007-05-25 11:27:16 -04002021 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002022 return 0;
2023}
2024
Holger Schurig10078322007-11-15 18:05:47 -05002025static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002026 struct iw_point *dwrq, char *extra)
2027{
Kiran Divekarab65f642009-02-19 19:32:39 -05002028 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002029 int ret = 0;
Dan Williamsd8efea22007-05-28 23:54:55 -04002030 u8 ssid[IW_ESSID_MAX_SIZE];
2031 u8 ssid_len = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002032 struct assoc_request * assoc_req;
Dan Williamsd8efea22007-05-28 23:54:55 -04002033 int in_ssid_len = dwrq->length;
John W. Linville9387b7c2008-09-30 20:59:05 -04002034 DECLARE_SSID_BUF(ssid_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002035
Holger Schurig9012b282007-05-25 11:27:16 -04002036 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002037
Dan Williamsd5db2df2008-08-21 17:51:07 -04002038 if (!priv->radio_on) {
2039 ret = -EINVAL;
2040 goto out;
2041 }
2042
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002043 /* Check the size of the string */
Dan Williamsd8efea22007-05-28 23:54:55 -04002044 if (in_ssid_len > IW_ESSID_MAX_SIZE) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002045 ret = -E2BIG;
2046 goto out;
2047 }
2048
Dan Williamsd8efea22007-05-28 23:54:55 -04002049 memset(&ssid, 0, sizeof(ssid));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002050
Dan Williamsd8efea22007-05-28 23:54:55 -04002051 if (!dwrq->flags || !in_ssid_len) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002052 /* "any" SSID requested; leave SSID blank */
2053 } else {
2054 /* Specific SSID requested */
Dan Williamsd8efea22007-05-28 23:54:55 -04002055 memcpy(&ssid, extra, in_ssid_len);
2056 ssid_len = in_ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002057 }
2058
Dan Williamsd8efea22007-05-28 23:54:55 -04002059 if (!ssid_len) {
2060 lbs_deb_wext("requested any SSID\n");
2061 } else {
2062 lbs_deb_wext("requested SSID '%s'\n",
John W. Linville9387b7c2008-09-30 20:59:05 -04002063 print_ssid(ssid_buf, ssid, ssid_len));
Dan Williamsd8efea22007-05-28 23:54:55 -04002064 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002065
2066out:
David Woodhouseaa21c002007-12-08 20:04:36 +00002067 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002068 if (ret == 0) {
2069 /* Get or create the current association request */
David Woodhouseaa21c002007-12-08 20:04:36 +00002070 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002071 if (!assoc_req) {
2072 ret = -ENOMEM;
2073 } else {
2074 /* Copy the SSID to the association request */
Dan Williamsd8efea22007-05-28 23:54:55 -04002075 memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE);
2076 assoc_req->ssid_len = ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002077 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05002078 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002079 }
2080 }
2081
2082 /* Cancel the association request if there was an error */
2083 if (ret != 0) {
Holger Schurig10078322007-11-15 18:05:47 -05002084 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002085 }
2086
David Woodhouseaa21c002007-12-08 20:04:36 +00002087 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002088
Holger Schurig9012b282007-05-25 11:27:16 -04002089 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002090 return ret;
2091}
2092
David Woodhousef5956bf2007-12-11 19:30:57 -05002093static int lbs_mesh_get_essid(struct net_device *dev,
2094 struct iw_request_info *info,
2095 struct iw_point *dwrq, char *extra)
2096{
Kiran Divekarab65f642009-02-19 19:32:39 -05002097 struct lbs_private *priv = dev->ml_priv;
David Woodhousef5956bf2007-12-11 19:30:57 -05002098
2099 lbs_deb_enter(LBS_DEB_WEXT);
2100
2101 memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
2102
2103 dwrq->length = priv->mesh_ssid_len;
2104
2105 dwrq->flags = 1; /* active */
2106
2107 lbs_deb_leave(LBS_DEB_WEXT);
2108 return 0;
2109}
2110
2111static int lbs_mesh_set_essid(struct net_device *dev,
2112 struct iw_request_info *info,
2113 struct iw_point *dwrq, char *extra)
2114{
Kiran Divekarab65f642009-02-19 19:32:39 -05002115 struct lbs_private *priv = dev->ml_priv;
David Woodhousef5956bf2007-12-11 19:30:57 -05002116 int ret = 0;
2117
2118 lbs_deb_enter(LBS_DEB_WEXT);
2119
Dan Williamsd5db2df2008-08-21 17:51:07 -04002120 if (!priv->radio_on) {
2121 ret = -EINVAL;
2122 goto out;
2123 }
2124
David Woodhousef5956bf2007-12-11 19:30:57 -05002125 /* Check the size of the string */
2126 if (dwrq->length > IW_ESSID_MAX_SIZE) {
2127 ret = -E2BIG;
2128 goto out;
2129 }
2130
2131 if (!dwrq->flags || !dwrq->length) {
2132 ret = -EINVAL;
2133 goto out;
2134 } else {
2135 /* Specific SSID requested */
2136 memcpy(priv->mesh_ssid, extra, dwrq->length);
2137 priv->mesh_ssid_len = dwrq->length;
2138 }
2139
Javier Cardonaedaea5c2008-05-17 00:55:10 -07002140 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
2141 priv->curbssparams.channel);
David Woodhousef5956bf2007-12-11 19:30:57 -05002142 out:
2143 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
2144 return ret;
2145}
2146
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002147/**
2148 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2149 *
2150 * @param dev A pointer to net_device structure
2151 * @param info A pointer to iw_request_info structure
2152 * @param awrq A pointer to iw_param structure
2153 * @param extra A pointer to extra data buf
2154 * @return 0 --success, otherwise fail
2155 */
Holger Schurig10078322007-11-15 18:05:47 -05002156static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002157 struct sockaddr *awrq, char *extra)
2158{
Kiran Divekarab65f642009-02-19 19:32:39 -05002159 struct lbs_private *priv = dev->ml_priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002160 struct assoc_request * assoc_req;
2161 int ret = 0;
2162
Holger Schurig9012b282007-05-25 11:27:16 -04002163 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002164
Dan Williamsd5db2df2008-08-21 17:51:07 -04002165 if (!priv->radio_on)
2166 return -EINVAL;
2167
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002168 if (awrq->sa_family != ARPHRD_ETHER)
2169 return -EINVAL;
2170
Johannes Berge1749612008-10-27 15:59:26 -07002171 lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002172
David Woodhouseaa21c002007-12-08 20:04:36 +00002173 mutex_lock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002174
2175 /* Get or create the current association request */
David Woodhouseaa21c002007-12-08 20:04:36 +00002176 assoc_req = lbs_get_association_request(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002177 if (!assoc_req) {
Holger Schurig10078322007-11-15 18:05:47 -05002178 lbs_cancel_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002179 ret = -ENOMEM;
2180 } else {
2181 /* Copy the BSSID to the association request */
2182 memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
2183 set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
Holger Schurig10078322007-11-15 18:05:47 -05002184 lbs_postpone_association_work(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002185 }
2186
David Woodhouseaa21c002007-12-08 20:04:36 +00002187 mutex_unlock(&priv->lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002188
2189 return ret;
2190}
2191
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002192/*
2193 * iwconfig settable callbacks
2194 */
Holger Schurig10078322007-11-15 18:05:47 -05002195static const iw_handler lbs_handler[] = {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002196 (iw_handler) NULL, /* SIOCSIWCOMMIT */
Holger Schurig10078322007-11-15 18:05:47 -05002197 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002198 (iw_handler) NULL, /* SIOCSIWNWID */
2199 (iw_handler) NULL, /* SIOCGIWNWID */
Holger Schurig10078322007-11-15 18:05:47 -05002200 (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */
2201 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
2202 (iw_handler) lbs_set_mode, /* SIOCSIWMODE */
2203 (iw_handler) lbs_get_mode, /* SIOCGIWMODE */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002204 (iw_handler) NULL, /* SIOCSIWSENS */
2205 (iw_handler) NULL, /* SIOCGIWSENS */
2206 (iw_handler) NULL, /* SIOCSIWRANGE */
Holger Schurig10078322007-11-15 18:05:47 -05002207 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002208 (iw_handler) NULL, /* SIOCSIWPRIV */
2209 (iw_handler) NULL, /* SIOCGIWPRIV */
2210 (iw_handler) NULL, /* SIOCSIWSTATS */
2211 (iw_handler) NULL, /* SIOCGIWSTATS */
2212 iw_handler_set_spy, /* SIOCSIWSPY */
2213 iw_handler_get_spy, /* SIOCGIWSPY */
2214 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2215 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
Holger Schurig10078322007-11-15 18:05:47 -05002216 (iw_handler) lbs_set_wap, /* SIOCSIWAP */
2217 (iw_handler) lbs_get_wap, /* SIOCGIWAP */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002218 (iw_handler) NULL, /* SIOCSIWMLME */
2219 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
Holger Schurig10078322007-11-15 18:05:47 -05002220 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2221 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
2222 (iw_handler) lbs_set_essid, /* SIOCSIWESSID */
2223 (iw_handler) lbs_get_essid, /* SIOCGIWESSID */
2224 (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */
2225 (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002226 (iw_handler) NULL, /* -- hole -- */
2227 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002228 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2229 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2230 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2231 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2232 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2233 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2234 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2235 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2236 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2237 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2238 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2239 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2240 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2241 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002242 (iw_handler) NULL, /* -- hole -- */
2243 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002244 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2245 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2246 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2247 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2248 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2249 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002250 (iw_handler) NULL, /* SIOCSIWPMKSA */
2251};
2252
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002253static const iw_handler mesh_wlan_handler[] = {
2254 (iw_handler) NULL, /* SIOCSIWCOMMIT */
Holger Schurig10078322007-11-15 18:05:47 -05002255 (iw_handler) lbs_get_name, /* SIOCGIWNAME */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002256 (iw_handler) NULL, /* SIOCSIWNWID */
2257 (iw_handler) NULL, /* SIOCGIWNWID */
David Woodhouse823eaa22007-12-11 19:56:28 -05002258 (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
Holger Schurig10078322007-11-15 18:05:47 -05002259 (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002260 (iw_handler) NULL, /* SIOCSIWMODE */
2261 (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
2262 (iw_handler) NULL, /* SIOCSIWSENS */
2263 (iw_handler) NULL, /* SIOCGIWSENS */
2264 (iw_handler) NULL, /* SIOCSIWRANGE */
Holger Schurig10078322007-11-15 18:05:47 -05002265 (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002266 (iw_handler) NULL, /* SIOCSIWPRIV */
2267 (iw_handler) NULL, /* SIOCGIWPRIV */
2268 (iw_handler) NULL, /* SIOCSIWSTATS */
2269 (iw_handler) NULL, /* SIOCGIWSTATS */
2270 iw_handler_set_spy, /* SIOCSIWSPY */
2271 iw_handler_get_spy, /* SIOCGIWSPY */
2272 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2273 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2274 (iw_handler) NULL, /* SIOCSIWAP */
2275 (iw_handler) NULL, /* SIOCGIWAP */
2276 (iw_handler) NULL, /* SIOCSIWMLME */
2277 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
Holger Schurig10078322007-11-15 18:05:47 -05002278 (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
2279 (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
David Woodhousef5956bf2007-12-11 19:30:57 -05002280 (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
2281 (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002282 (iw_handler) NULL, /* SIOCSIWNICKN */
2283 (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
2284 (iw_handler) NULL, /* -- hole -- */
2285 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002286 (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
2287 (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
2288 (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
2289 (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
2290 (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
2291 (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
2292 (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
2293 (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
2294 (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
2295 (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
2296 (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
2297 (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
2298 (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
2299 (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002300 (iw_handler) NULL, /* -- hole -- */
2301 (iw_handler) NULL, /* -- hole -- */
Holger Schurig10078322007-11-15 18:05:47 -05002302 (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
2303 (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
2304 (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
2305 (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
2306 (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
2307 (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002308 (iw_handler) NULL, /* SIOCSIWPMKSA */
2309};
Holger Schurig10078322007-11-15 18:05:47 -05002310struct iw_handler_def lbs_handler_def = {
2311 .num_standard = ARRAY_SIZE(lbs_handler),
2312 .standard = (iw_handler *) lbs_handler,
2313 .get_wireless_stats = lbs_get_wireless_stats,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002314};
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002315
2316struct iw_handler_def mesh_handler_def = {
Denis Chengff8ac602007-09-02 18:30:18 +08002317 .num_standard = ARRAY_SIZE(mesh_wlan_handler),
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002318 .standard = (iw_handler *) mesh_wlan_handler,
Holger Schurig10078322007-11-15 18:05:47 -05002319 .get_wireless_stats = lbs_get_wireless_stats,
Luis Carlos Cobo Rusf5e05b62007-05-25 23:08:34 -04002320};