wext.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315
  1. /**
  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. #include <net/lib80211.h>
  11. #include <net/iw_handler.h>
  12. #include "host.h"
  13. #include "radiotap.h"
  14. #include "decl.h"
  15. #include "defs.h"
  16. #include "dev.h"
  17. #include "wext.h"
  18. #include "scan.h"
  19. #include "assoc.h"
  20. #include "cmd.h"
  21. static inline void lbs_postpone_association_work(struct lbs_private *priv)
  22. {
  23. if (priv->surpriseremoved)
  24. return;
  25. cancel_delayed_work(&priv->assoc_work);
  26. queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
  27. }
  28. static inline void lbs_do_association_work(struct lbs_private *priv)
  29. {
  30. if (priv->surpriseremoved)
  31. return;
  32. cancel_delayed_work(&priv->assoc_work);
  33. queue_delayed_work(priv->work_thread, &priv->assoc_work, 0);
  34. }
  35. static inline void lbs_cancel_association_work(struct lbs_private *priv)
  36. {
  37. cancel_delayed_work(&priv->assoc_work);
  38. kfree(priv->pending_assoc_req);
  39. priv->pending_assoc_req = NULL;
  40. }
  41. void lbs_send_disconnect_notification(struct lbs_private *priv)
  42. {
  43. union iwreq_data wrqu;
  44. memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
  45. wrqu.ap_addr.sa_family = ARPHRD_ETHER;
  46. wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
  47. }
  48. void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
  49. {
  50. union iwreq_data iwrq;
  51. u8 buf[50];
  52. lbs_deb_enter(LBS_DEB_WEXT);
  53. memset(&iwrq, 0, sizeof(union iwreq_data));
  54. memset(buf, 0, sizeof(buf));
  55. snprintf(buf, sizeof(buf) - 1, "%s", str);
  56. iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN;
  57. /* Send Event to upper layer */
  58. lbs_deb_wext("event indication string %s\n", (char *)buf);
  59. lbs_deb_wext("event indication length %d\n", iwrq.data.length);
  60. lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str);
  61. wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf);
  62. lbs_deb_leave(LBS_DEB_WEXT);
  63. }
  64. /**
  65. * @brief Find the channel frequency power info with specific channel
  66. *
  67. * @param priv A pointer to struct lbs_private structure
  68. * @param band it can be BAND_A, BAND_G or BAND_B
  69. * @param channel the channel for looking
  70. * @return A pointer to struct chan_freq_power structure or NULL if not find.
  71. */
  72. struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
  73. struct lbs_private *priv,
  74. u8 band,
  75. u16 channel)
  76. {
  77. struct chan_freq_power *cfp = NULL;
  78. struct region_channel *rc;
  79. int i, j;
  80. for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
  81. rc = &priv->region_channel[j];
  82. if (!rc->valid || !rc->CFP)
  83. continue;
  84. if (rc->band != band)
  85. continue;
  86. for (i = 0; i < rc->nrcfp; i++) {
  87. if (rc->CFP[i].channel == channel) {
  88. cfp = &rc->CFP[i];
  89. break;
  90. }
  91. }
  92. }
  93. if (!cfp && channel)
  94. lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
  95. "cfp by band %d / channel %d\n", band, channel);
  96. return cfp;
  97. }
  98. /**
  99. * @brief Find the channel frequency power info with specific frequency
  100. *
  101. * @param priv A pointer to struct lbs_private structure
  102. * @param band it can be BAND_A, BAND_G or BAND_B
  103. * @param freq the frequency for looking
  104. * @return A pointer to struct chan_freq_power structure or NULL if not find.
  105. */
  106. static struct chan_freq_power *find_cfp_by_band_and_freq(
  107. struct lbs_private *priv,
  108. u8 band,
  109. u32 freq)
  110. {
  111. struct chan_freq_power *cfp = NULL;
  112. struct region_channel *rc;
  113. int i, j;
  114. for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
  115. rc = &priv->region_channel[j];
  116. if (!rc->valid || !rc->CFP)
  117. continue;
  118. if (rc->band != band)
  119. continue;
  120. for (i = 0; i < rc->nrcfp; i++) {
  121. if (rc->CFP[i].freq == freq) {
  122. cfp = &rc->CFP[i];
  123. break;
  124. }
  125. }
  126. }
  127. if (!cfp && freq)
  128. lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
  129. "band %d / freq %d\n", band, freq);
  130. return cfp;
  131. }
  132. /**
  133. * @brief Copy active data rates based on adapter mode and status
  134. *
  135. * @param priv A pointer to struct lbs_private structure
  136. * @param rate The buf to return the active rates
  137. */
  138. static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
  139. {
  140. lbs_deb_enter(LBS_DEB_WEXT);
  141. if ((priv->connect_status != LBS_CONNECTED) &&
  142. (priv->mesh_connect_status != LBS_CONNECTED))
  143. memcpy(rates, lbs_bg_rates, MAX_RATES);
  144. else
  145. memcpy(rates, priv->curbssparams.rates, MAX_RATES);
  146. lbs_deb_leave(LBS_DEB_WEXT);
  147. }
  148. static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
  149. char *cwrq, char *extra)
  150. {
  151. lbs_deb_enter(LBS_DEB_WEXT);
  152. /* We could add support for 802.11n here as needed. Jean II */
  153. snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g");
  154. lbs_deb_leave(LBS_DEB_WEXT);
  155. return 0;
  156. }
  157. static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
  158. struct iw_freq *fwrq, char *extra)
  159. {
  160. struct lbs_private *priv = dev->ml_priv;
  161. struct chan_freq_power *cfp;
  162. lbs_deb_enter(LBS_DEB_WEXT);
  163. cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
  164. priv->channel);
  165. if (!cfp) {
  166. if (priv->channel)
  167. lbs_deb_wext("invalid channel %d\n",
  168. priv->channel);
  169. return -EINVAL;
  170. }
  171. fwrq->m = (long)cfp->freq * 100000;
  172. fwrq->e = 1;
  173. lbs_deb_wext("freq %u\n", fwrq->m);
  174. lbs_deb_leave(LBS_DEB_WEXT);
  175. return 0;
  176. }
  177. static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
  178. struct sockaddr *awrq, char *extra)
  179. {
  180. struct lbs_private *priv = dev->ml_priv;
  181. lbs_deb_enter(LBS_DEB_WEXT);
  182. if (priv->connect_status == LBS_CONNECTED) {
  183. memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
  184. } else {
  185. memset(awrq->sa_data, 0, ETH_ALEN);
  186. }
  187. awrq->sa_family = ARPHRD_ETHER;
  188. lbs_deb_leave(LBS_DEB_WEXT);
  189. return 0;
  190. }
  191. static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
  192. struct iw_point *dwrq, char *extra)
  193. {
  194. struct lbs_private *priv = dev->ml_priv;
  195. lbs_deb_enter(LBS_DEB_WEXT);
  196. /*
  197. * Check the size of the string
  198. */
  199. if (dwrq->length > 16) {
  200. return -E2BIG;
  201. }
  202. mutex_lock(&priv->lock);
  203. memset(priv->nodename, 0, sizeof(priv->nodename));
  204. memcpy(priv->nodename, extra, dwrq->length);
  205. mutex_unlock(&priv->lock);
  206. lbs_deb_leave(LBS_DEB_WEXT);
  207. return 0;
  208. }
  209. static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
  210. struct iw_point *dwrq, char *extra)
  211. {
  212. struct lbs_private *priv = dev->ml_priv;
  213. lbs_deb_enter(LBS_DEB_WEXT);
  214. dwrq->length = strlen(priv->nodename);
  215. memcpy(extra, priv->nodename, dwrq->length);
  216. extra[dwrq->length] = '\0';
  217. dwrq->flags = 1; /* active */
  218. lbs_deb_leave(LBS_DEB_WEXT);
  219. return 0;
  220. }
  221. static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
  222. struct iw_point *dwrq, char *extra)
  223. {
  224. struct lbs_private *priv = dev->ml_priv;
  225. lbs_deb_enter(LBS_DEB_WEXT);
  226. /* Use nickname to indicate that mesh is on */
  227. if (priv->mesh_connect_status == LBS_CONNECTED) {
  228. strncpy(extra, "Mesh", 12);
  229. extra[12] = '\0';
  230. dwrq->length = strlen(extra);
  231. }
  232. else {
  233. extra[0] = '\0';
  234. dwrq->length = 0;
  235. }
  236. lbs_deb_leave(LBS_DEB_WEXT);
  237. return 0;
  238. }
  239. static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
  240. struct iw_param *vwrq, char *extra)
  241. {
  242. int ret = 0;
  243. struct lbs_private *priv = dev->ml_priv;
  244. u32 val = vwrq->value;
  245. lbs_deb_enter(LBS_DEB_WEXT);
  246. if (vwrq->disabled)
  247. val = MRVDRV_RTS_MAX_VALUE;
  248. if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */
  249. return -EINVAL;
  250. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
  251. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  252. return ret;
  253. }
  254. static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
  255. struct iw_param *vwrq, char *extra)
  256. {
  257. struct lbs_private *priv = dev->ml_priv;
  258. int ret = 0;
  259. u16 val = 0;
  260. lbs_deb_enter(LBS_DEB_WEXT);
  261. ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
  262. if (ret)
  263. goto out;
  264. vwrq->value = val;
  265. vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */
  266. vwrq->fixed = 1;
  267. out:
  268. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  269. return ret;
  270. }
  271. static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
  272. struct iw_param *vwrq, char *extra)
  273. {
  274. struct lbs_private *priv = dev->ml_priv;
  275. int ret = 0;
  276. u32 val = vwrq->value;
  277. lbs_deb_enter(LBS_DEB_WEXT);
  278. if (vwrq->disabled)
  279. val = MRVDRV_FRAG_MAX_VALUE;
  280. if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
  281. return -EINVAL;
  282. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
  283. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  284. return ret;
  285. }
  286. static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
  287. struct iw_param *vwrq, char *extra)
  288. {
  289. struct lbs_private *priv = dev->ml_priv;
  290. int ret = 0;
  291. u16 val = 0;
  292. lbs_deb_enter(LBS_DEB_WEXT);
  293. ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
  294. if (ret)
  295. goto out;
  296. vwrq->value = val;
  297. vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
  298. || (val > MRVDRV_FRAG_MAX_VALUE));
  299. vwrq->fixed = 1;
  300. out:
  301. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  302. return ret;
  303. }
  304. static int lbs_get_mode(struct net_device *dev,
  305. struct iw_request_info *info, u32 * uwrq, char *extra)
  306. {
  307. struct lbs_private *priv = dev->ml_priv;
  308. lbs_deb_enter(LBS_DEB_WEXT);
  309. *uwrq = priv->mode;
  310. lbs_deb_leave(LBS_DEB_WEXT);
  311. return 0;
  312. }
  313. static int mesh_wlan_get_mode(struct net_device *dev,
  314. struct iw_request_info *info, u32 * uwrq,
  315. char *extra)
  316. {
  317. lbs_deb_enter(LBS_DEB_WEXT);
  318. *uwrq = IW_MODE_REPEAT;
  319. lbs_deb_leave(LBS_DEB_WEXT);
  320. return 0;
  321. }
  322. static int lbs_get_txpow(struct net_device *dev,
  323. struct iw_request_info *info,
  324. struct iw_param *vwrq, char *extra)
  325. {
  326. struct lbs_private *priv = dev->ml_priv;
  327. s16 curlevel = 0;
  328. int ret = 0;
  329. lbs_deb_enter(LBS_DEB_WEXT);
  330. if (!priv->radio_on) {
  331. lbs_deb_wext("tx power off\n");
  332. vwrq->value = 0;
  333. vwrq->disabled = 1;
  334. goto out;
  335. }
  336. ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
  337. if (ret)
  338. goto out;
  339. lbs_deb_wext("tx power level %d dbm\n", curlevel);
  340. priv->txpower_cur = curlevel;
  341. vwrq->value = curlevel;
  342. vwrq->fixed = 1;
  343. vwrq->disabled = 0;
  344. vwrq->flags = IW_TXPOW_DBM;
  345. out:
  346. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  347. return ret;
  348. }
  349. static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
  350. struct iw_param *vwrq, char *extra)
  351. {
  352. struct lbs_private *priv = dev->ml_priv;
  353. int ret = 0;
  354. u16 slimit = 0, llimit = 0;
  355. lbs_deb_enter(LBS_DEB_WEXT);
  356. if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
  357. return -EOPNOTSUPP;
  358. /* The MAC has a 4-bit Total_Tx_Count register
  359. Total_Tx_Count = 1 + Tx_Retry_Count */
  360. #define TX_RETRY_MIN 0
  361. #define TX_RETRY_MAX 14
  362. if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
  363. return -EINVAL;
  364. /* Add 1 to convert retry count to try count */
  365. if (vwrq->flags & IW_RETRY_SHORT)
  366. slimit = (u16) (vwrq->value + 1);
  367. else if (vwrq->flags & IW_RETRY_LONG)
  368. llimit = (u16) (vwrq->value + 1);
  369. else
  370. slimit = llimit = (u16) (vwrq->value + 1); /* set both */
  371. if (llimit) {
  372. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
  373. llimit);
  374. if (ret)
  375. goto out;
  376. }
  377. if (slimit) {
  378. /* txretrycount follows the short retry limit */
  379. priv->txretrycount = slimit;
  380. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
  381. slimit);
  382. if (ret)
  383. goto out;
  384. }
  385. out:
  386. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  387. return ret;
  388. }
  389. static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
  390. struct iw_param *vwrq, char *extra)
  391. {
  392. struct lbs_private *priv = dev->ml_priv;
  393. int ret = 0;
  394. u16 val = 0;
  395. lbs_deb_enter(LBS_DEB_WEXT);
  396. vwrq->disabled = 0;
  397. if (vwrq->flags & IW_RETRY_LONG) {
  398. ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
  399. if (ret)
  400. goto out;
  401. /* Subtract 1 to convert try count to retry count */
  402. vwrq->value = val - 1;
  403. vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
  404. } else {
  405. ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
  406. if (ret)
  407. goto out;
  408. /* txretry count follows the short retry limit */
  409. priv->txretrycount = val;
  410. /* Subtract 1 to convert try count to retry count */
  411. vwrq->value = val - 1;
  412. vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
  413. }
  414. out:
  415. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  416. return ret;
  417. }
  418. static inline void sort_channels(struct iw_freq *freq, int num)
  419. {
  420. int i, j;
  421. struct iw_freq temp;
  422. for (i = 0; i < num; i++)
  423. for (j = i + 1; j < num; j++)
  424. if (freq[i].i > freq[j].i) {
  425. temp.i = freq[i].i;
  426. temp.m = freq[i].m;
  427. freq[i].i = freq[j].i;
  428. freq[i].m = freq[j].m;
  429. freq[j].i = temp.i;
  430. freq[j].m = temp.m;
  431. }
  432. }
  433. /* data rate listing
  434. MULTI_BANDS:
  435. abg a b b/g
  436. Infra G(12) A(8) B(4) G(12)
  437. Adhoc A+B(12) A(8) B(4) B(4)
  438. non-MULTI_BANDS:
  439. b b/g
  440. Infra B(4) G(12)
  441. Adhoc B(4) B(4)
  442. */
  443. /**
  444. * @brief Get Range Info
  445. *
  446. * @param dev A pointer to net_device structure
  447. * @param info A pointer to iw_request_info structure
  448. * @param vwrq A pointer to iw_param structure
  449. * @param extra A pointer to extra data buf
  450. * @return 0 --success, otherwise fail
  451. */
  452. static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
  453. struct iw_point *dwrq, char *extra)
  454. {
  455. int i, j;
  456. struct lbs_private *priv = dev->ml_priv;
  457. struct iw_range *range = (struct iw_range *)extra;
  458. struct chan_freq_power *cfp;
  459. u8 rates[MAX_RATES + 1];
  460. lbs_deb_enter(LBS_DEB_WEXT);
  461. dwrq->length = sizeof(struct iw_range);
  462. memset(range, 0, sizeof(struct iw_range));
  463. range->min_nwid = 0;
  464. range->max_nwid = 0;
  465. memset(rates, 0, sizeof(rates));
  466. copy_active_data_rates(priv, rates);
  467. range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
  468. for (i = 0; i < range->num_bitrates; i++)
  469. range->bitrate[i] = rates[i] * 500000;
  470. range->num_bitrates = i;
  471. lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES,
  472. range->num_bitrates);
  473. range->num_frequency = 0;
  474. range->scan_capa = IW_SCAN_CAPA_ESSID;
  475. for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
  476. && (j < ARRAY_SIZE(priv->region_channel)); j++) {
  477. cfp = priv->region_channel[j].CFP;
  478. for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
  479. && priv->region_channel[j].valid
  480. && cfp
  481. && (i < priv->region_channel[j].nrcfp); i++) {
  482. range->freq[range->num_frequency].i =
  483. (long)cfp->channel;
  484. range->freq[range->num_frequency].m =
  485. (long)cfp->freq * 100000;
  486. range->freq[range->num_frequency].e = 1;
  487. cfp++;
  488. range->num_frequency++;
  489. }
  490. }
  491. lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
  492. IW_MAX_FREQUENCIES, range->num_frequency);
  493. range->num_channels = range->num_frequency;
  494. sort_channels(&range->freq[0], range->num_frequency);
  495. /*
  496. * Set an indication of the max TCP throughput in bit/s that we can
  497. * expect using this interface
  498. */
  499. if (i > 2)
  500. range->throughput = 5000 * 1000;
  501. else
  502. range->throughput = 1500 * 1000;
  503. range->min_rts = MRVDRV_RTS_MIN_VALUE;
  504. range->max_rts = MRVDRV_RTS_MAX_VALUE;
  505. range->min_frag = MRVDRV_FRAG_MIN_VALUE;
  506. range->max_frag = MRVDRV_FRAG_MAX_VALUE;
  507. range->encoding_size[0] = 5;
  508. range->encoding_size[1] = 13;
  509. range->num_encoding_sizes = 2;
  510. range->max_encoding_tokens = 4;
  511. /*
  512. * Right now we support only "iwconfig ethX power on|off"
  513. */
  514. range->pm_capa = IW_POWER_ON;
  515. /*
  516. * Minimum version we recommend
  517. */
  518. range->we_version_source = 15;
  519. /*
  520. * Version we are compiled with
  521. */
  522. range->we_version_compiled = WIRELESS_EXT;
  523. range->retry_capa = IW_RETRY_LIMIT;
  524. range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
  525. range->min_retry = TX_RETRY_MIN;
  526. range->max_retry = TX_RETRY_MAX;
  527. /*
  528. * Set the qual, level and noise range values
  529. */
  530. range->max_qual.qual = 100;
  531. range->max_qual.level = 0;
  532. range->max_qual.noise = 0;
  533. range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
  534. range->avg_qual.qual = 70;
  535. /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
  536. range->avg_qual.level = 0;
  537. range->avg_qual.noise = 0;
  538. range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
  539. range->sensitivity = 0;
  540. /* Setup the supported power level ranges */
  541. memset(range->txpower, 0, sizeof(range->txpower));
  542. range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE;
  543. range->txpower[0] = priv->txpower_min;
  544. range->txpower[1] = priv->txpower_max;
  545. range->num_txpower = 2;
  546. range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
  547. IW_EVENT_CAPA_MASK(SIOCGIWAP) |
  548. IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
  549. range->event_capa[1] = IW_EVENT_CAPA_K_1;
  550. if (priv->fwcapinfo & FW_CAPINFO_WPA) {
  551. range->enc_capa = IW_ENC_CAPA_WPA
  552. | IW_ENC_CAPA_WPA2
  553. | IW_ENC_CAPA_CIPHER_TKIP
  554. | IW_ENC_CAPA_CIPHER_CCMP;
  555. }
  556. lbs_deb_leave(LBS_DEB_WEXT);
  557. return 0;
  558. }
  559. static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
  560. struct iw_param *vwrq, char *extra)
  561. {
  562. struct lbs_private *priv = dev->ml_priv;
  563. int ret = 0;
  564. lbs_deb_enter(LBS_DEB_WEXT);
  565. if (!(priv->fwcapinfo & FW_CAPINFO_PS)) {
  566. if (vwrq->disabled)
  567. return 0;
  568. else
  569. return -EINVAL;
  570. }
  571. /* PS is currently supported only in Infrastructure mode
  572. * Remove this check if it is to be supported in IBSS mode also
  573. */
  574. if (vwrq->disabled) {
  575. priv->psmode = LBS802_11POWERMODECAM;
  576. if (priv->psstate != PS_STATE_FULL_POWER) {
  577. lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
  578. }
  579. return 0;
  580. }
  581. if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
  582. lbs_deb_wext(
  583. "setting power timeout is not supported\n");
  584. return -EINVAL;
  585. } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
  586. vwrq->value = vwrq->value / 1000;
  587. if (!priv->enter_deep_sleep) {
  588. lbs_pr_err("deep sleep feature is not implemented "
  589. "for this interface driver\n");
  590. return -EINVAL;
  591. }
  592. if (priv->connect_status == LBS_CONNECTED) {
  593. if ((priv->is_auto_deep_sleep_enabled) &&
  594. (vwrq->value == -1000)) {
  595. lbs_exit_auto_deep_sleep(priv);
  596. return 0;
  597. } else {
  598. lbs_pr_err("can't use deep sleep cmd in "
  599. "connected state\n");
  600. return -EINVAL;
  601. }
  602. }
  603. if ((vwrq->value < 0) && (vwrq->value != -1000)) {
  604. lbs_pr_err("unknown option\n");
  605. return -EINVAL;
  606. }
  607. if (vwrq->value > 0) {
  608. if (!priv->is_auto_deep_sleep_enabled) {
  609. priv->is_activity_detected = 0;
  610. priv->auto_deep_sleep_timeout = vwrq->value;
  611. lbs_enter_auto_deep_sleep(priv);
  612. } else {
  613. priv->auto_deep_sleep_timeout = vwrq->value;
  614. lbs_deb_debugfs("auto deep sleep: "
  615. "already enabled\n");
  616. }
  617. return 0;
  618. } else {
  619. if (priv->is_auto_deep_sleep_enabled) {
  620. lbs_exit_auto_deep_sleep(priv);
  621. /* Try to exit deep sleep if auto */
  622. /*deep sleep disabled */
  623. ret = lbs_set_deep_sleep(priv, 0);
  624. }
  625. if (vwrq->value == 0)
  626. ret = lbs_set_deep_sleep(priv, 1);
  627. else if (vwrq->value == -1000)
  628. ret = lbs_set_deep_sleep(priv, 0);
  629. return ret;
  630. }
  631. }
  632. if (priv->psmode != LBS802_11POWERMODECAM) {
  633. return 0;
  634. }
  635. priv->psmode = LBS802_11POWERMODEMAX_PSP;
  636. if (priv->connect_status == LBS_CONNECTED) {
  637. lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
  638. }
  639. lbs_deb_leave(LBS_DEB_WEXT);
  640. return 0;
  641. }
  642. static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
  643. struct iw_param *vwrq, char *extra)
  644. {
  645. struct lbs_private *priv = dev->ml_priv;
  646. lbs_deb_enter(LBS_DEB_WEXT);
  647. vwrq->value = 0;
  648. vwrq->flags = 0;
  649. vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM
  650. || priv->connect_status == LBS_DISCONNECTED;
  651. lbs_deb_leave(LBS_DEB_WEXT);
  652. return 0;
  653. }
  654. static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
  655. {
  656. enum {
  657. POOR = 30,
  658. FAIR = 60,
  659. GOOD = 80,
  660. VERY_GOOD = 90,
  661. EXCELLENT = 95,
  662. PERFECT = 100
  663. };
  664. struct lbs_private *priv = dev->ml_priv;
  665. u32 rssi_qual;
  666. u32 tx_qual;
  667. u32 quality = 0;
  668. int ret, stats_valid = 0;
  669. u8 rssi;
  670. u32 tx_retries;
  671. struct cmd_ds_802_11_get_log log;
  672. lbs_deb_enter(LBS_DEB_WEXT);
  673. priv->wstats.status = priv->mode;
  674. /* If we're not associated, all quality values are meaningless */
  675. if ((priv->connect_status != LBS_CONNECTED) &&
  676. (priv->mesh_connect_status != LBS_CONNECTED))
  677. goto out;
  678. /* Quality by RSSI */
  679. priv->wstats.qual.level =
  680. CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
  681. priv->NF[TYPE_BEACON][TYPE_NOAVG]);
  682. if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
  683. priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
  684. } else {
  685. priv->wstats.qual.noise =
  686. CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
  687. }
  688. lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
  689. lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise);
  690. rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
  691. if (rssi < 15)
  692. rssi_qual = rssi * POOR / 10;
  693. else if (rssi < 20)
  694. rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
  695. else if (rssi < 30)
  696. rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
  697. else if (rssi < 40)
  698. rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
  699. 10 + GOOD;
  700. else
  701. rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
  702. 10 + VERY_GOOD;
  703. quality = rssi_qual;
  704. /* Quality by TX errors */
  705. priv->wstats.discard.retries = dev->stats.tx_errors;
  706. memset(&log, 0, sizeof(log));
  707. log.hdr.size = cpu_to_le16(sizeof(log));
  708. ret = lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
  709. if (ret)
  710. goto out;
  711. tx_retries = le32_to_cpu(log.retry);
  712. if (tx_retries > 75)
  713. tx_qual = (90 - tx_retries) * POOR / 15;
  714. else if (tx_retries > 70)
  715. tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
  716. else if (tx_retries > 65)
  717. tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
  718. else if (tx_retries > 50)
  719. tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
  720. 15 + GOOD;
  721. else
  722. tx_qual = (50 - tx_retries) *
  723. (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
  724. quality = min(quality, tx_qual);
  725. priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable);
  726. priv->wstats.discard.retries = tx_retries;
  727. priv->wstats.discard.misc = le32_to_cpu(log.ackfailure);
  728. /* Calculate quality */
  729. priv->wstats.qual.qual = min_t(u8, quality, 100);
  730. priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
  731. stats_valid = 1;
  732. /* update stats asynchronously for future calls */
  733. ret = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
  734. 0, 0, NULL);
  735. if (ret)
  736. lbs_pr_err("RSSI command failed\n");
  737. out:
  738. if (!stats_valid) {
  739. priv->wstats.miss.beacon = 0;
  740. priv->wstats.discard.retries = 0;
  741. priv->wstats.qual.qual = 0;
  742. priv->wstats.qual.level = 0;
  743. priv->wstats.qual.noise = 0;
  744. priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
  745. priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
  746. IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
  747. }
  748. lbs_deb_leave(LBS_DEB_WEXT);
  749. return &priv->wstats;
  750. }
  751. static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
  752. struct iw_freq *fwrq, char *extra)
  753. {
  754. int ret = -EINVAL;
  755. struct lbs_private *priv = dev->ml_priv;
  756. struct chan_freq_power *cfp;
  757. struct assoc_request * assoc_req;
  758. lbs_deb_enter(LBS_DEB_WEXT);
  759. mutex_lock(&priv->lock);
  760. assoc_req = lbs_get_association_request(priv);
  761. if (!assoc_req) {
  762. ret = -ENOMEM;
  763. goto out;
  764. }
  765. /* If setting by frequency, convert to a channel */
  766. if (fwrq->e == 1) {
  767. long f = fwrq->m / 100000;
  768. cfp = find_cfp_by_band_and_freq(priv, 0, f);
  769. if (!cfp) {
  770. lbs_deb_wext("invalid freq %ld\n", f);
  771. goto out;
  772. }
  773. fwrq->e = 0;
  774. fwrq->m = (int) cfp->channel;
  775. }
  776. /* Setting by channel number */
  777. if (fwrq->m > 1000 || fwrq->e > 0) {
  778. goto out;
  779. }
  780. cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
  781. if (!cfp) {
  782. goto out;
  783. }
  784. assoc_req->channel = fwrq->m;
  785. ret = 0;
  786. out:
  787. if (ret == 0) {
  788. set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
  789. lbs_postpone_association_work(priv);
  790. } else {
  791. lbs_cancel_association_work(priv);
  792. }
  793. mutex_unlock(&priv->lock);
  794. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  795. return ret;
  796. }
  797. static int lbs_mesh_set_freq(struct net_device *dev,
  798. struct iw_request_info *info,
  799. struct iw_freq *fwrq, char *extra)
  800. {
  801. struct lbs_private *priv = dev->ml_priv;
  802. struct chan_freq_power *cfp;
  803. int ret = -EINVAL;
  804. lbs_deb_enter(LBS_DEB_WEXT);
  805. /* If setting by frequency, convert to a channel */
  806. if (fwrq->e == 1) {
  807. long f = fwrq->m / 100000;
  808. cfp = find_cfp_by_band_and_freq(priv, 0, f);
  809. if (!cfp) {
  810. lbs_deb_wext("invalid freq %ld\n", f);
  811. goto out;
  812. }
  813. fwrq->e = 0;
  814. fwrq->m = (int) cfp->channel;
  815. }
  816. /* Setting by channel number */
  817. if (fwrq->m > 1000 || fwrq->e > 0) {
  818. goto out;
  819. }
  820. cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
  821. if (!cfp) {
  822. goto out;
  823. }
  824. if (fwrq->m != priv->channel) {
  825. lbs_deb_wext("mesh channel change forces eth disconnect\n");
  826. if (priv->mode == IW_MODE_INFRA)
  827. lbs_cmd_80211_deauthenticate(priv,
  828. priv->curbssparams.bssid,
  829. WLAN_REASON_DEAUTH_LEAVING);
  830. else if (priv->mode == IW_MODE_ADHOC)
  831. lbs_adhoc_stop(priv);
  832. }
  833. lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m);
  834. lbs_update_channel(priv);
  835. ret = 0;
  836. out:
  837. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  838. return ret;
  839. }
  840. static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
  841. struct iw_param *vwrq, char *extra)
  842. {
  843. struct lbs_private *priv = dev->ml_priv;
  844. u8 new_rate = 0;
  845. int ret = -EINVAL;
  846. u8 rates[MAX_RATES + 1];
  847. lbs_deb_enter(LBS_DEB_WEXT);
  848. lbs_deb_wext("vwrq->value %d\n", vwrq->value);
  849. lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed);
  850. if (vwrq->fixed && vwrq->value == -1)
  851. goto out;
  852. /* Auto rate? */
  853. priv->enablehwauto = !vwrq->fixed;
  854. if (vwrq->value == -1)
  855. priv->cur_rate = 0;
  856. else {
  857. if (vwrq->value % 100000)
  858. goto out;
  859. new_rate = vwrq->value / 500000;
  860. priv->cur_rate = new_rate;
  861. /* the rest is only needed for lbs_set_data_rate() */
  862. memset(rates, 0, sizeof(rates));
  863. copy_active_data_rates(priv, rates);
  864. if (!memchr(rates, new_rate, sizeof(rates))) {
  865. lbs_pr_alert("fixed data rate 0x%X out of range\n",
  866. new_rate);
  867. goto out;
  868. }
  869. if (priv->fwrelease < 0x09000000) {
  870. ret = lbs_set_power_adapt_cfg(priv, 0,
  871. POW_ADAPT_DEFAULT_P0,
  872. POW_ADAPT_DEFAULT_P1,
  873. POW_ADAPT_DEFAULT_P2);
  874. if (ret)
  875. goto out;
  876. }
  877. ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
  878. TPC_DEFAULT_P2, 1);
  879. if (ret)
  880. goto out;
  881. }
  882. /* Try the newer command first (Firmware Spec 5.1 and above) */
  883. ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET);
  884. /* Fallback to older version */
  885. if (ret)
  886. ret = lbs_set_data_rate(priv, new_rate);
  887. out:
  888. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  889. return ret;
  890. }
  891. static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
  892. struct iw_param *vwrq, char *extra)
  893. {
  894. struct lbs_private *priv = dev->ml_priv;
  895. lbs_deb_enter(LBS_DEB_WEXT);
  896. if (priv->connect_status == LBS_CONNECTED) {
  897. vwrq->value = priv->cur_rate * 500000;
  898. if (priv->enablehwauto)
  899. vwrq->fixed = 0;
  900. else
  901. vwrq->fixed = 1;
  902. } else {
  903. vwrq->fixed = 0;
  904. vwrq->value = 0;
  905. }
  906. lbs_deb_leave(LBS_DEB_WEXT);
  907. return 0;
  908. }
  909. static int lbs_set_mode(struct net_device *dev,
  910. struct iw_request_info *info, u32 * uwrq, char *extra)
  911. {
  912. int ret = 0;
  913. struct lbs_private *priv = dev->ml_priv;
  914. struct assoc_request * assoc_req;
  915. lbs_deb_enter(LBS_DEB_WEXT);
  916. if ( (*uwrq != IW_MODE_ADHOC)
  917. && (*uwrq != IW_MODE_INFRA)
  918. && (*uwrq != IW_MODE_AUTO)) {
  919. lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq);
  920. ret = -EINVAL;
  921. goto out;
  922. }
  923. mutex_lock(&priv->lock);
  924. assoc_req = lbs_get_association_request(priv);
  925. if (!assoc_req) {
  926. ret = -ENOMEM;
  927. lbs_cancel_association_work(priv);
  928. } else {
  929. assoc_req->mode = *uwrq;
  930. set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
  931. lbs_postpone_association_work(priv);
  932. lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
  933. }
  934. mutex_unlock(&priv->lock);
  935. out:
  936. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  937. return ret;
  938. }
  939. /**
  940. * @brief Get Encryption key
  941. *
  942. * @param dev A pointer to net_device structure
  943. * @param info A pointer to iw_request_info structure
  944. * @param vwrq A pointer to iw_param structure
  945. * @param extra A pointer to extra data buf
  946. * @return 0 --success, otherwise fail
  947. */
  948. static int lbs_get_encode(struct net_device *dev,
  949. struct iw_request_info *info,
  950. struct iw_point *dwrq, u8 * extra)
  951. {
  952. struct lbs_private *priv = dev->ml_priv;
  953. int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
  954. lbs_deb_enter(LBS_DEB_WEXT);
  955. lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
  956. dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
  957. dwrq->flags = 0;
  958. /* Authentication method */
  959. switch (priv->secinfo.auth_mode) {
  960. case IW_AUTH_ALG_OPEN_SYSTEM:
  961. dwrq->flags = IW_ENCODE_OPEN;
  962. break;
  963. case IW_AUTH_ALG_SHARED_KEY:
  964. case IW_AUTH_ALG_LEAP:
  965. dwrq->flags = IW_ENCODE_RESTRICTED;
  966. break;
  967. default:
  968. dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
  969. break;
  970. }
  971. memset(extra, 0, 16);
  972. mutex_lock(&priv->lock);
  973. /* Default to returning current transmit key */
  974. if (index < 0)
  975. index = priv->wep_tx_keyidx;
  976. if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
  977. memcpy(extra, priv->wep_keys[index].key,
  978. priv->wep_keys[index].len);
  979. dwrq->length = priv->wep_keys[index].len;
  980. dwrq->flags |= (index + 1);
  981. /* Return WEP enabled */
  982. dwrq->flags &= ~IW_ENCODE_DISABLED;
  983. } else if ((priv->secinfo.WPAenabled)
  984. || (priv->secinfo.WPA2enabled)) {
  985. /* return WPA enabled */
  986. dwrq->flags &= ~IW_ENCODE_DISABLED;
  987. dwrq->flags |= IW_ENCODE_NOKEY;
  988. } else {
  989. dwrq->flags |= IW_ENCODE_DISABLED;
  990. }
  991. mutex_unlock(&priv->lock);
  992. lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
  993. extra[0], extra[1], extra[2],
  994. extra[3], extra[4], extra[5], dwrq->length);
  995. lbs_deb_wext("return flags 0x%x\n", dwrq->flags);
  996. lbs_deb_leave(LBS_DEB_WEXT);
  997. return 0;
  998. }
  999. /**
  1000. * @brief Set Encryption key (internal)
  1001. *
  1002. * @param priv A pointer to private card structure
  1003. * @param key_material A pointer to key material
  1004. * @param key_length length of key material
  1005. * @param index key index to set
  1006. * @param set_tx_key Force set TX key (1 = yes, 0 = no)
  1007. * @return 0 --success, otherwise fail
  1008. */
  1009. static int lbs_set_wep_key(struct assoc_request *assoc_req,
  1010. const char *key_material,
  1011. u16 key_length,
  1012. u16 index,
  1013. int set_tx_key)
  1014. {
  1015. int ret = 0;
  1016. struct enc_key *pkey;
  1017. lbs_deb_enter(LBS_DEB_WEXT);
  1018. /* Paranoid validation of key index */
  1019. if (index > 3) {
  1020. ret = -EINVAL;
  1021. goto out;
  1022. }
  1023. /* validate max key length */
  1024. if (key_length > KEY_LEN_WEP_104) {
  1025. ret = -EINVAL;
  1026. goto out;
  1027. }
  1028. pkey = &assoc_req->wep_keys[index];
  1029. if (key_length > 0) {
  1030. memset(pkey, 0, sizeof(struct enc_key));
  1031. pkey->type = KEY_TYPE_ID_WEP;
  1032. /* Standardize the key length */
  1033. pkey->len = (key_length > KEY_LEN_WEP_40) ?
  1034. KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
  1035. memcpy(pkey->key, key_material, key_length);
  1036. }
  1037. if (set_tx_key) {
  1038. /* Ensure the chosen key is valid */
  1039. if (!pkey->len) {
  1040. lbs_deb_wext("key not set, so cannot enable it\n");
  1041. ret = -EINVAL;
  1042. goto out;
  1043. }
  1044. assoc_req->wep_tx_keyidx = index;
  1045. }
  1046. assoc_req->secinfo.wep_enabled = 1;
  1047. out:
  1048. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1049. return ret;
  1050. }
  1051. static int validate_key_index(u16 def_index, u16 raw_index,
  1052. u16 *out_index, u16 *is_default)
  1053. {
  1054. if (!out_index || !is_default)
  1055. return -EINVAL;
  1056. /* Verify index if present, otherwise use default TX key index */
  1057. if (raw_index > 0) {
  1058. if (raw_index > 4)
  1059. return -EINVAL;
  1060. *out_index = raw_index - 1;
  1061. } else {
  1062. *out_index = def_index;
  1063. *is_default = 1;
  1064. }
  1065. return 0;
  1066. }
  1067. static void disable_wep(struct assoc_request *assoc_req)
  1068. {
  1069. int i;
  1070. lbs_deb_enter(LBS_DEB_WEXT);
  1071. /* Set Open System auth mode */
  1072. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1073. /* Clear WEP keys and mark WEP as disabled */
  1074. assoc_req->secinfo.wep_enabled = 0;
  1075. for (i = 0; i < 4; i++)
  1076. assoc_req->wep_keys[i].len = 0;
  1077. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1078. set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
  1079. lbs_deb_leave(LBS_DEB_WEXT);
  1080. }
  1081. static void disable_wpa(struct assoc_request *assoc_req)
  1082. {
  1083. lbs_deb_enter(LBS_DEB_WEXT);
  1084. memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key));
  1085. assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
  1086. set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
  1087. memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key));
  1088. assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
  1089. set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
  1090. assoc_req->secinfo.WPAenabled = 0;
  1091. assoc_req->secinfo.WPA2enabled = 0;
  1092. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1093. lbs_deb_leave(LBS_DEB_WEXT);
  1094. }
  1095. /**
  1096. * @brief Set Encryption key
  1097. *
  1098. * @param dev A pointer to net_device structure
  1099. * @param info A pointer to iw_request_info structure
  1100. * @param vwrq A pointer to iw_param structure
  1101. * @param extra A pointer to extra data buf
  1102. * @return 0 --success, otherwise fail
  1103. */
  1104. static int lbs_set_encode(struct net_device *dev,
  1105. struct iw_request_info *info,
  1106. struct iw_point *dwrq, char *extra)
  1107. {
  1108. int ret = 0;
  1109. struct lbs_private *priv = dev->ml_priv;
  1110. struct assoc_request * assoc_req;
  1111. u16 is_default = 0, index = 0, set_tx_key = 0;
  1112. lbs_deb_enter(LBS_DEB_WEXT);
  1113. mutex_lock(&priv->lock);
  1114. assoc_req = lbs_get_association_request(priv);
  1115. if (!assoc_req) {
  1116. ret = -ENOMEM;
  1117. goto out;
  1118. }
  1119. if (dwrq->flags & IW_ENCODE_DISABLED) {
  1120. disable_wep (assoc_req);
  1121. disable_wpa (assoc_req);
  1122. goto out;
  1123. }
  1124. ret = validate_key_index(assoc_req->wep_tx_keyidx,
  1125. (dwrq->flags & IW_ENCODE_INDEX),
  1126. &index, &is_default);
  1127. if (ret) {
  1128. ret = -EINVAL;
  1129. goto out;
  1130. }
  1131. /* If WEP isn't enabled, or if there is no key data but a valid
  1132. * index, set the TX key.
  1133. */
  1134. if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
  1135. set_tx_key = 1;
  1136. ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
  1137. if (ret)
  1138. goto out;
  1139. if (dwrq->length)
  1140. set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
  1141. if (set_tx_key)
  1142. set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
  1143. if (dwrq->flags & IW_ENCODE_RESTRICTED) {
  1144. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1145. } else if (dwrq->flags & IW_ENCODE_OPEN) {
  1146. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1147. }
  1148. out:
  1149. if (ret == 0) {
  1150. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1151. lbs_postpone_association_work(priv);
  1152. } else {
  1153. lbs_cancel_association_work(priv);
  1154. }
  1155. mutex_unlock(&priv->lock);
  1156. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1157. return ret;
  1158. }
  1159. /**
  1160. * @brief Get Extended Encryption key (WPA/802.1x and WEP)
  1161. *
  1162. * @param dev A pointer to net_device structure
  1163. * @param info A pointer to iw_request_info structure
  1164. * @param vwrq A pointer to iw_param structure
  1165. * @param extra A pointer to extra data buf
  1166. * @return 0 on success, otherwise failure
  1167. */
  1168. static int lbs_get_encodeext(struct net_device *dev,
  1169. struct iw_request_info *info,
  1170. struct iw_point *dwrq,
  1171. char *extra)
  1172. {
  1173. int ret = -EINVAL;
  1174. struct lbs_private *priv = dev->ml_priv;
  1175. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  1176. int index, max_key_len;
  1177. lbs_deb_enter(LBS_DEB_WEXT);
  1178. max_key_len = dwrq->length - sizeof(*ext);
  1179. if (max_key_len < 0)
  1180. goto out;
  1181. index = dwrq->flags & IW_ENCODE_INDEX;
  1182. if (index) {
  1183. if (index < 1 || index > 4)
  1184. goto out;
  1185. index--;
  1186. } else {
  1187. index = priv->wep_tx_keyidx;
  1188. }
  1189. if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
  1190. ext->alg != IW_ENCODE_ALG_WEP) {
  1191. if (index != 0 || priv->mode != IW_MODE_INFRA)
  1192. goto out;
  1193. }
  1194. dwrq->flags = index + 1;
  1195. memset(ext, 0, sizeof(*ext));
  1196. if ( !priv->secinfo.wep_enabled
  1197. && !priv->secinfo.WPAenabled
  1198. && !priv->secinfo.WPA2enabled) {
  1199. ext->alg = IW_ENCODE_ALG_NONE;
  1200. ext->key_len = 0;
  1201. dwrq->flags |= IW_ENCODE_DISABLED;
  1202. } else {
  1203. u8 *key = NULL;
  1204. if ( priv->secinfo.wep_enabled
  1205. && !priv->secinfo.WPAenabled
  1206. && !priv->secinfo.WPA2enabled) {
  1207. /* WEP */
  1208. ext->alg = IW_ENCODE_ALG_WEP;
  1209. ext->key_len = priv->wep_keys[index].len;
  1210. key = &priv->wep_keys[index].key[0];
  1211. } else if ( !priv->secinfo.wep_enabled
  1212. && (priv->secinfo.WPAenabled ||
  1213. priv->secinfo.WPA2enabled)) {
  1214. /* WPA */
  1215. struct enc_key * pkey = NULL;
  1216. if ( priv->wpa_mcast_key.len
  1217. && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
  1218. pkey = &priv->wpa_mcast_key;
  1219. else if ( priv->wpa_unicast_key.len
  1220. && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
  1221. pkey = &priv->wpa_unicast_key;
  1222. if (pkey) {
  1223. if (pkey->type == KEY_TYPE_ID_AES) {
  1224. ext->alg = IW_ENCODE_ALG_CCMP;
  1225. } else {
  1226. ext->alg = IW_ENCODE_ALG_TKIP;
  1227. }
  1228. ext->key_len = pkey->len;
  1229. key = &pkey->key[0];
  1230. } else {
  1231. ext->alg = IW_ENCODE_ALG_TKIP;
  1232. ext->key_len = 0;
  1233. }
  1234. } else {
  1235. goto out;
  1236. }
  1237. if (ext->key_len > max_key_len) {
  1238. ret = -E2BIG;
  1239. goto out;
  1240. }
  1241. if (ext->key_len)
  1242. memcpy(ext->key, key, ext->key_len);
  1243. else
  1244. dwrq->flags |= IW_ENCODE_NOKEY;
  1245. dwrq->flags |= IW_ENCODE_ENABLED;
  1246. }
  1247. ret = 0;
  1248. out:
  1249. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1250. return ret;
  1251. }
  1252. /**
  1253. * @brief Set Encryption key Extended (WPA/802.1x and WEP)
  1254. *
  1255. * @param dev A pointer to net_device structure
  1256. * @param info A pointer to iw_request_info structure
  1257. * @param vwrq A pointer to iw_param structure
  1258. * @param extra A pointer to extra data buf
  1259. * @return 0 --success, otherwise fail
  1260. */
  1261. static int lbs_set_encodeext(struct net_device *dev,
  1262. struct iw_request_info *info,
  1263. struct iw_point *dwrq,
  1264. char *extra)
  1265. {
  1266. int ret = 0;
  1267. struct lbs_private *priv = dev->ml_priv;
  1268. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  1269. int alg = ext->alg;
  1270. struct assoc_request * assoc_req;
  1271. lbs_deb_enter(LBS_DEB_WEXT);
  1272. mutex_lock(&priv->lock);
  1273. assoc_req = lbs_get_association_request(priv);
  1274. if (!assoc_req) {
  1275. ret = -ENOMEM;
  1276. goto out;
  1277. }
  1278. if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
  1279. disable_wep (assoc_req);
  1280. disable_wpa (assoc_req);
  1281. } else if (alg == IW_ENCODE_ALG_WEP) {
  1282. u16 is_default = 0, index, set_tx_key = 0;
  1283. ret = validate_key_index(assoc_req->wep_tx_keyidx,
  1284. (dwrq->flags & IW_ENCODE_INDEX),
  1285. &index, &is_default);
  1286. if (ret)
  1287. goto out;
  1288. /* If WEP isn't enabled, or if there is no key data but a valid
  1289. * index, or if the set-TX-key flag was passed, set the TX key.
  1290. */
  1291. if ( !assoc_req->secinfo.wep_enabled
  1292. || (dwrq->length == 0 && !is_default)
  1293. || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
  1294. set_tx_key = 1;
  1295. /* Copy key to driver */
  1296. ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
  1297. set_tx_key);
  1298. if (ret)
  1299. goto out;
  1300. if (dwrq->flags & IW_ENCODE_RESTRICTED) {
  1301. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1302. } else if (dwrq->flags & IW_ENCODE_OPEN) {
  1303. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1304. }
  1305. /* Mark the various WEP bits as modified */
  1306. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1307. if (dwrq->length)
  1308. set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
  1309. if (set_tx_key)
  1310. set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
  1311. } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
  1312. struct enc_key * pkey;
  1313. /* validate key length */
  1314. if (((alg == IW_ENCODE_ALG_TKIP)
  1315. && (ext->key_len != KEY_LEN_WPA_TKIP))
  1316. || ((alg == IW_ENCODE_ALG_CCMP)
  1317. && (ext->key_len != KEY_LEN_WPA_AES))) {
  1318. lbs_deb_wext("invalid size %d for key of alg "
  1319. "type %d\n",
  1320. ext->key_len,
  1321. alg);
  1322. ret = -EINVAL;
  1323. goto out;
  1324. }
  1325. if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
  1326. pkey = &assoc_req->wpa_mcast_key;
  1327. set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
  1328. } else {
  1329. pkey = &assoc_req->wpa_unicast_key;
  1330. set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
  1331. }
  1332. memset(pkey, 0, sizeof (struct enc_key));
  1333. memcpy(pkey->key, ext->key, ext->key_len);
  1334. pkey->len = ext->key_len;
  1335. if (pkey->len)
  1336. pkey->flags |= KEY_INFO_WPA_ENABLED;
  1337. /* Do this after zeroing key structure */
  1338. if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
  1339. pkey->flags |= KEY_INFO_WPA_MCAST;
  1340. } else {
  1341. pkey->flags |= KEY_INFO_WPA_UNICAST;
  1342. }
  1343. if (alg == IW_ENCODE_ALG_TKIP) {
  1344. pkey->type = KEY_TYPE_ID_TKIP;
  1345. } else if (alg == IW_ENCODE_ALG_CCMP) {
  1346. pkey->type = KEY_TYPE_ID_AES;
  1347. }
  1348. /* If WPA isn't enabled yet, do that now */
  1349. if ( assoc_req->secinfo.WPAenabled == 0
  1350. && assoc_req->secinfo.WPA2enabled == 0) {
  1351. assoc_req->secinfo.WPAenabled = 1;
  1352. assoc_req->secinfo.WPA2enabled = 1;
  1353. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1354. }
  1355. /* Only disable wep if necessary: can't waste time here. */
  1356. if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
  1357. disable_wep(assoc_req);
  1358. }
  1359. out:
  1360. if (ret == 0) {
  1361. /* 802.1x and WPA rekeying must happen as quickly as possible,
  1362. * especially during the 4-way handshake; thus if in
  1363. * infrastructure mode, and either (a) 802.1x is enabled or
  1364. * (b) WPA is being used, set the key right away.
  1365. */
  1366. if (assoc_req->mode == IW_MODE_INFRA &&
  1367. ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
  1368. (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
  1369. assoc_req->secinfo.WPAenabled ||
  1370. assoc_req->secinfo.WPA2enabled)) {
  1371. lbs_do_association_work(priv);
  1372. } else
  1373. lbs_postpone_association_work(priv);
  1374. } else {
  1375. lbs_cancel_association_work(priv);
  1376. }
  1377. mutex_unlock(&priv->lock);
  1378. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1379. return ret;
  1380. }
  1381. static int lbs_set_genie(struct net_device *dev,
  1382. struct iw_request_info *info,
  1383. struct iw_point *dwrq,
  1384. char *extra)
  1385. {
  1386. struct lbs_private *priv = dev->ml_priv;
  1387. int ret = 0;
  1388. struct assoc_request * assoc_req;
  1389. lbs_deb_enter(LBS_DEB_WEXT);
  1390. mutex_lock(&priv->lock);
  1391. assoc_req = lbs_get_association_request(priv);
  1392. if (!assoc_req) {
  1393. ret = -ENOMEM;
  1394. goto out;
  1395. }
  1396. if (dwrq->length > MAX_WPA_IE_LEN ||
  1397. (dwrq->length && extra == NULL)) {
  1398. ret = -EINVAL;
  1399. goto out;
  1400. }
  1401. if (dwrq->length) {
  1402. memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
  1403. assoc_req->wpa_ie_len = dwrq->length;
  1404. } else {
  1405. memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
  1406. assoc_req->wpa_ie_len = 0;
  1407. }
  1408. out:
  1409. if (ret == 0) {
  1410. set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
  1411. lbs_postpone_association_work(priv);
  1412. } else {
  1413. lbs_cancel_association_work(priv);
  1414. }
  1415. mutex_unlock(&priv->lock);
  1416. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1417. return ret;
  1418. }
  1419. static int lbs_get_genie(struct net_device *dev,
  1420. struct iw_request_info *info,
  1421. struct iw_point *dwrq,
  1422. char *extra)
  1423. {
  1424. int ret = 0;
  1425. struct lbs_private *priv = dev->ml_priv;
  1426. lbs_deb_enter(LBS_DEB_WEXT);
  1427. if (priv->wpa_ie_len == 0) {
  1428. dwrq->length = 0;
  1429. goto out;
  1430. }
  1431. if (dwrq->length < priv->wpa_ie_len) {
  1432. ret = -E2BIG;
  1433. goto out;
  1434. }
  1435. dwrq->length = priv->wpa_ie_len;
  1436. memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
  1437. out:
  1438. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1439. return ret;
  1440. }
  1441. static int lbs_set_auth(struct net_device *dev,
  1442. struct iw_request_info *info,
  1443. struct iw_param *dwrq,
  1444. char *extra)
  1445. {
  1446. struct lbs_private *priv = dev->ml_priv;
  1447. struct assoc_request * assoc_req;
  1448. int ret = 0;
  1449. int updated = 0;
  1450. lbs_deb_enter(LBS_DEB_WEXT);
  1451. mutex_lock(&priv->lock);
  1452. assoc_req = lbs_get_association_request(priv);
  1453. if (!assoc_req) {
  1454. ret = -ENOMEM;
  1455. goto out;
  1456. }
  1457. switch (dwrq->flags & IW_AUTH_INDEX) {
  1458. case IW_AUTH_PRIVACY_INVOKED:
  1459. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  1460. case IW_AUTH_TKIP_COUNTERMEASURES:
  1461. case IW_AUTH_CIPHER_PAIRWISE:
  1462. case IW_AUTH_CIPHER_GROUP:
  1463. case IW_AUTH_DROP_UNENCRYPTED:
  1464. /*
  1465. * libertas does not use these parameters
  1466. */
  1467. break;
  1468. case IW_AUTH_KEY_MGMT:
  1469. assoc_req->secinfo.key_mgmt = dwrq->value;
  1470. updated = 1;
  1471. break;
  1472. case IW_AUTH_WPA_VERSION:
  1473. if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
  1474. assoc_req->secinfo.WPAenabled = 0;
  1475. assoc_req->secinfo.WPA2enabled = 0;
  1476. disable_wpa (assoc_req);
  1477. }
  1478. if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
  1479. assoc_req->secinfo.WPAenabled = 1;
  1480. assoc_req->secinfo.wep_enabled = 0;
  1481. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1482. }
  1483. if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
  1484. assoc_req->secinfo.WPA2enabled = 1;
  1485. assoc_req->secinfo.wep_enabled = 0;
  1486. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1487. }
  1488. updated = 1;
  1489. break;
  1490. case IW_AUTH_80211_AUTH_ALG:
  1491. if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
  1492. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1493. } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
  1494. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1495. } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
  1496. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
  1497. } else {
  1498. ret = -EINVAL;
  1499. }
  1500. updated = 1;
  1501. break;
  1502. case IW_AUTH_WPA_ENABLED:
  1503. if (dwrq->value) {
  1504. if (!assoc_req->secinfo.WPAenabled &&
  1505. !assoc_req->secinfo.WPA2enabled) {
  1506. assoc_req->secinfo.WPAenabled = 1;
  1507. assoc_req->secinfo.WPA2enabled = 1;
  1508. assoc_req->secinfo.wep_enabled = 0;
  1509. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1510. }
  1511. } else {
  1512. assoc_req->secinfo.WPAenabled = 0;
  1513. assoc_req->secinfo.WPA2enabled = 0;
  1514. disable_wpa (assoc_req);
  1515. }
  1516. updated = 1;
  1517. break;
  1518. default:
  1519. ret = -EOPNOTSUPP;
  1520. break;
  1521. }
  1522. out:
  1523. if (ret == 0) {
  1524. if (updated)
  1525. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1526. lbs_postpone_association_work(priv);
  1527. } else if (ret != -EOPNOTSUPP) {
  1528. lbs_cancel_association_work(priv);
  1529. }
  1530. mutex_unlock(&priv->lock);
  1531. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1532. return ret;
  1533. }
  1534. static int lbs_get_auth(struct net_device *dev,
  1535. struct iw_request_info *info,
  1536. struct iw_param *dwrq,
  1537. char *extra)
  1538. {
  1539. int ret = 0;
  1540. struct lbs_private *priv = dev->ml_priv;
  1541. lbs_deb_enter(LBS_DEB_WEXT);
  1542. switch (dwrq->flags & IW_AUTH_INDEX) {
  1543. case IW_AUTH_KEY_MGMT:
  1544. dwrq->value = priv->secinfo.key_mgmt;
  1545. break;
  1546. case IW_AUTH_WPA_VERSION:
  1547. dwrq->value = 0;
  1548. if (priv->secinfo.WPAenabled)
  1549. dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
  1550. if (priv->secinfo.WPA2enabled)
  1551. dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
  1552. if (!dwrq->value)
  1553. dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
  1554. break;
  1555. case IW_AUTH_80211_AUTH_ALG:
  1556. dwrq->value = priv->secinfo.auth_mode;
  1557. break;
  1558. case IW_AUTH_WPA_ENABLED:
  1559. if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
  1560. dwrq->value = 1;
  1561. break;
  1562. default:
  1563. ret = -EOPNOTSUPP;
  1564. }
  1565. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1566. return ret;
  1567. }
  1568. static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
  1569. struct iw_param *vwrq, char *extra)
  1570. {
  1571. int ret = 0;
  1572. struct lbs_private *priv = dev->ml_priv;
  1573. s16 dbm = (s16) vwrq->value;
  1574. lbs_deb_enter(LBS_DEB_WEXT);
  1575. if (vwrq->disabled) {
  1576. lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
  1577. goto out;
  1578. }
  1579. if (vwrq->fixed == 0) {
  1580. /* User requests automatic tx power control, however there are
  1581. * many auto tx settings. For now use firmware defaults until
  1582. * we come up with a good way to expose these to the user. */
  1583. if (priv->fwrelease < 0x09000000) {
  1584. ret = lbs_set_power_adapt_cfg(priv, 1,
  1585. POW_ADAPT_DEFAULT_P0,
  1586. POW_ADAPT_DEFAULT_P1,
  1587. POW_ADAPT_DEFAULT_P2);
  1588. if (ret)
  1589. goto out;
  1590. }
  1591. ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
  1592. TPC_DEFAULT_P2, 1);
  1593. if (ret)
  1594. goto out;
  1595. dbm = priv->txpower_max;
  1596. } else {
  1597. /* Userspace check in iwrange if it should use dBm or mW,
  1598. * therefore this should never happen... Jean II */
  1599. if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
  1600. ret = -EOPNOTSUPP;
  1601. goto out;
  1602. }
  1603. /* Validate requested power level against firmware allowed
  1604. * levels */
  1605. if (priv->txpower_min && (dbm < priv->txpower_min)) {
  1606. ret = -EINVAL;
  1607. goto out;
  1608. }
  1609. if (priv->txpower_max && (dbm > priv->txpower_max)) {
  1610. ret = -EINVAL;
  1611. goto out;
  1612. }
  1613. if (priv->fwrelease < 0x09000000) {
  1614. ret = lbs_set_power_adapt_cfg(priv, 0,
  1615. POW_ADAPT_DEFAULT_P0,
  1616. POW_ADAPT_DEFAULT_P1,
  1617. POW_ADAPT_DEFAULT_P2);
  1618. if (ret)
  1619. goto out;
  1620. }
  1621. ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
  1622. TPC_DEFAULT_P2, 1);
  1623. if (ret)
  1624. goto out;
  1625. }
  1626. /* If the radio was off, turn it on */
  1627. if (!priv->radio_on) {
  1628. ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
  1629. if (ret)
  1630. goto out;
  1631. }
  1632. lbs_deb_wext("txpower set %d dBm\n", dbm);
  1633. ret = lbs_set_tx_power(priv, dbm);
  1634. out:
  1635. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1636. return ret;
  1637. }
  1638. static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
  1639. struct iw_point *dwrq, char *extra)
  1640. {
  1641. struct lbs_private *priv = dev->ml_priv;
  1642. lbs_deb_enter(LBS_DEB_WEXT);
  1643. /*
  1644. * Note : if dwrq->flags != 0, we should get the relevant SSID from
  1645. * the SSID list...
  1646. */
  1647. /*
  1648. * Get the current SSID
  1649. */
  1650. if (priv->connect_status == LBS_CONNECTED) {
  1651. memcpy(extra, priv->curbssparams.ssid,
  1652. priv->curbssparams.ssid_len);
  1653. extra[priv->curbssparams.ssid_len] = '\0';
  1654. } else {
  1655. memset(extra, 0, 32);
  1656. extra[priv->curbssparams.ssid_len] = '\0';
  1657. }
  1658. /*
  1659. * If none, we may want to get the one that was set
  1660. */
  1661. dwrq->length = priv->curbssparams.ssid_len;
  1662. dwrq->flags = 1; /* active */
  1663. lbs_deb_leave(LBS_DEB_WEXT);
  1664. return 0;
  1665. }
  1666. static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
  1667. struct iw_point *dwrq, char *extra)
  1668. {
  1669. struct lbs_private *priv = dev->ml_priv;
  1670. int ret = 0;
  1671. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1672. u8 ssid_len = 0;
  1673. struct assoc_request * assoc_req;
  1674. int in_ssid_len = dwrq->length;
  1675. DECLARE_SSID_BUF(ssid_buf);
  1676. lbs_deb_enter(LBS_DEB_WEXT);
  1677. if (!priv->radio_on) {
  1678. ret = -EINVAL;
  1679. goto out;
  1680. }
  1681. /* Check the size of the string */
  1682. if (in_ssid_len > IEEE80211_MAX_SSID_LEN) {
  1683. ret = -E2BIG;
  1684. goto out;
  1685. }
  1686. memset(&ssid, 0, sizeof(ssid));
  1687. if (!dwrq->flags || !in_ssid_len) {
  1688. /* "any" SSID requested; leave SSID blank */
  1689. } else {
  1690. /* Specific SSID requested */
  1691. memcpy(&ssid, extra, in_ssid_len);
  1692. ssid_len = in_ssid_len;
  1693. }
  1694. if (!ssid_len) {
  1695. lbs_deb_wext("requested any SSID\n");
  1696. } else {
  1697. lbs_deb_wext("requested SSID '%s'\n",
  1698. print_ssid(ssid_buf, ssid, ssid_len));
  1699. }
  1700. out:
  1701. mutex_lock(&priv->lock);
  1702. if (ret == 0) {
  1703. /* Get or create the current association request */
  1704. assoc_req = lbs_get_association_request(priv);
  1705. if (!assoc_req) {
  1706. ret = -ENOMEM;
  1707. } else {
  1708. /* Copy the SSID to the association request */
  1709. memcpy(&assoc_req->ssid, &ssid, IEEE80211_MAX_SSID_LEN);
  1710. assoc_req->ssid_len = ssid_len;
  1711. set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
  1712. lbs_postpone_association_work(priv);
  1713. }
  1714. }
  1715. /* Cancel the association request if there was an error */
  1716. if (ret != 0) {
  1717. lbs_cancel_association_work(priv);
  1718. }
  1719. mutex_unlock(&priv->lock);
  1720. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1721. return ret;
  1722. }
  1723. static int lbs_mesh_get_essid(struct net_device *dev,
  1724. struct iw_request_info *info,
  1725. struct iw_point *dwrq, char *extra)
  1726. {
  1727. struct lbs_private *priv = dev->ml_priv;
  1728. lbs_deb_enter(LBS_DEB_WEXT);
  1729. memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
  1730. dwrq->length = priv->mesh_ssid_len;
  1731. dwrq->flags = 1; /* active */
  1732. lbs_deb_leave(LBS_DEB_WEXT);
  1733. return 0;
  1734. }
  1735. static int lbs_mesh_set_essid(struct net_device *dev,
  1736. struct iw_request_info *info,
  1737. struct iw_point *dwrq, char *extra)
  1738. {
  1739. struct lbs_private *priv = dev->ml_priv;
  1740. int ret = 0;
  1741. lbs_deb_enter(LBS_DEB_WEXT);
  1742. if (!priv->radio_on) {
  1743. ret = -EINVAL;
  1744. goto out;
  1745. }
  1746. /* Check the size of the string */
  1747. if (dwrq->length > IEEE80211_MAX_SSID_LEN) {
  1748. ret = -E2BIG;
  1749. goto out;
  1750. }
  1751. if (!dwrq->flags || !dwrq->length) {
  1752. ret = -EINVAL;
  1753. goto out;
  1754. } else {
  1755. /* Specific SSID requested */
  1756. memcpy(priv->mesh_ssid, extra, dwrq->length);
  1757. priv->mesh_ssid_len = dwrq->length;
  1758. }
  1759. lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
  1760. priv->channel);
  1761. out:
  1762. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1763. return ret;
  1764. }
  1765. /**
  1766. * @brief Connect to the AP or Ad-hoc Network with specific bssid
  1767. *
  1768. * @param dev A pointer to net_device structure
  1769. * @param info A pointer to iw_request_info structure
  1770. * @param awrq A pointer to iw_param structure
  1771. * @param extra A pointer to extra data buf
  1772. * @return 0 --success, otherwise fail
  1773. */
  1774. static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
  1775. struct sockaddr *awrq, char *extra)
  1776. {
  1777. struct lbs_private *priv = dev->ml_priv;
  1778. struct assoc_request * assoc_req;
  1779. int ret = 0;
  1780. lbs_deb_enter(LBS_DEB_WEXT);
  1781. if (!priv->radio_on)
  1782. return -EINVAL;
  1783. if (awrq->sa_family != ARPHRD_ETHER)
  1784. return -EINVAL;
  1785. lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
  1786. mutex_lock(&priv->lock);
  1787. /* Get or create the current association request */
  1788. assoc_req = lbs_get_association_request(priv);
  1789. if (!assoc_req) {
  1790. lbs_cancel_association_work(priv);
  1791. ret = -ENOMEM;
  1792. } else {
  1793. /* Copy the BSSID to the association request */
  1794. memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
  1795. set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
  1796. lbs_postpone_association_work(priv);
  1797. }
  1798. mutex_unlock(&priv->lock);
  1799. return ret;
  1800. }
  1801. /*
  1802. * iwconfig settable callbacks
  1803. */
  1804. static const iw_handler lbs_handler[] = {
  1805. (iw_handler) NULL, /* SIOCSIWCOMMIT */
  1806. (iw_handler) lbs_get_name, /* SIOCGIWNAME */
  1807. (iw_handler) NULL, /* SIOCSIWNWID */
  1808. (iw_handler) NULL, /* SIOCGIWNWID */
  1809. (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */
  1810. (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
  1811. (iw_handler) lbs_set_mode, /* SIOCSIWMODE */
  1812. (iw_handler) lbs_get_mode, /* SIOCGIWMODE */
  1813. (iw_handler) NULL, /* SIOCSIWSENS */
  1814. (iw_handler) NULL, /* SIOCGIWSENS */
  1815. (iw_handler) NULL, /* SIOCSIWRANGE */
  1816. (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
  1817. (iw_handler) NULL, /* SIOCSIWPRIV */
  1818. (iw_handler) NULL, /* SIOCGIWPRIV */
  1819. (iw_handler) NULL, /* SIOCSIWSTATS */
  1820. (iw_handler) NULL, /* SIOCGIWSTATS */
  1821. iw_handler_set_spy, /* SIOCSIWSPY */
  1822. iw_handler_get_spy, /* SIOCGIWSPY */
  1823. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  1824. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  1825. (iw_handler) lbs_set_wap, /* SIOCSIWAP */
  1826. (iw_handler) lbs_get_wap, /* SIOCGIWAP */
  1827. (iw_handler) NULL, /* SIOCSIWMLME */
  1828. (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
  1829. (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
  1830. (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
  1831. (iw_handler) lbs_set_essid, /* SIOCSIWESSID */
  1832. (iw_handler) lbs_get_essid, /* SIOCGIWESSID */
  1833. (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */
  1834. (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */
  1835. (iw_handler) NULL, /* -- hole -- */
  1836. (iw_handler) NULL, /* -- hole -- */
  1837. (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
  1838. (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
  1839. (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
  1840. (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
  1841. (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
  1842. (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
  1843. (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
  1844. (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
  1845. (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
  1846. (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
  1847. (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
  1848. (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
  1849. (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
  1850. (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
  1851. (iw_handler) NULL, /* -- hole -- */
  1852. (iw_handler) NULL, /* -- hole -- */
  1853. (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
  1854. (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
  1855. (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
  1856. (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
  1857. (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
  1858. (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
  1859. (iw_handler) NULL, /* SIOCSIWPMKSA */
  1860. };
  1861. static const iw_handler mesh_wlan_handler[] = {
  1862. (iw_handler) NULL, /* SIOCSIWCOMMIT */
  1863. (iw_handler) lbs_get_name, /* SIOCGIWNAME */
  1864. (iw_handler) NULL, /* SIOCSIWNWID */
  1865. (iw_handler) NULL, /* SIOCGIWNWID */
  1866. (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
  1867. (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
  1868. (iw_handler) NULL, /* SIOCSIWMODE */
  1869. (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
  1870. (iw_handler) NULL, /* SIOCSIWSENS */
  1871. (iw_handler) NULL, /* SIOCGIWSENS */
  1872. (iw_handler) NULL, /* SIOCSIWRANGE */
  1873. (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
  1874. (iw_handler) NULL, /* SIOCSIWPRIV */
  1875. (iw_handler) NULL, /* SIOCGIWPRIV */
  1876. (iw_handler) NULL, /* SIOCSIWSTATS */
  1877. (iw_handler) NULL, /* SIOCGIWSTATS */
  1878. iw_handler_set_spy, /* SIOCSIWSPY */
  1879. iw_handler_get_spy, /* SIOCGIWSPY */
  1880. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  1881. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  1882. (iw_handler) NULL, /* SIOCSIWAP */
  1883. (iw_handler) NULL, /* SIOCGIWAP */
  1884. (iw_handler) NULL, /* SIOCSIWMLME */
  1885. (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
  1886. (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
  1887. (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
  1888. (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
  1889. (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
  1890. (iw_handler) NULL, /* SIOCSIWNICKN */
  1891. (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
  1892. (iw_handler) NULL, /* -- hole -- */
  1893. (iw_handler) NULL, /* -- hole -- */
  1894. (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
  1895. (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
  1896. (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
  1897. (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
  1898. (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
  1899. (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
  1900. (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
  1901. (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
  1902. (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
  1903. (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
  1904. (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
  1905. (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
  1906. (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
  1907. (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
  1908. (iw_handler) NULL, /* -- hole -- */
  1909. (iw_handler) NULL, /* -- hole -- */
  1910. (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
  1911. (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
  1912. (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
  1913. (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
  1914. (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
  1915. (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
  1916. (iw_handler) NULL, /* SIOCSIWPMKSA */
  1917. };
  1918. struct iw_handler_def lbs_handler_def = {
  1919. .num_standard = ARRAY_SIZE(lbs_handler),
  1920. .standard = (iw_handler *) lbs_handler,
  1921. .get_wireless_stats = lbs_get_wireless_stats,
  1922. };
  1923. struct iw_handler_def mesh_handler_def = {
  1924. .num_standard = ARRAY_SIZE(mesh_wlan_handler),
  1925. .standard = (iw_handler *) mesh_wlan_handler,
  1926. .get_wireless_stats = lbs_get_wireless_stats,
  1927. };