prism2sta.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. /* src/prism2/driver/prism2sta.c
  2. *
  3. * Implements the station functionality for prism2
  4. *
  5. * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
  6. * --------------------------------------------------------------------
  7. *
  8. * linux-wlan
  9. *
  10. * The contents of this file are subject to the Mozilla Public
  11. * License Version 1.1 (the "License"); you may not use this file
  12. * except in compliance with the License. You may obtain a copy of
  13. * the License at http://www.mozilla.org/MPL/
  14. *
  15. * Software distributed under the License is distributed on an "AS
  16. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  17. * implied. See the License for the specific language governing
  18. * rights and limitations under the License.
  19. *
  20. * Alternatively, the contents of this file may be used under the
  21. * terms of the GNU Public License version 2 (the "GPL"), in which
  22. * case the provisions of the GPL are applicable instead of the
  23. * above. If you wish to allow the use of your version of this file
  24. * only under the terms of the GPL and not to allow others to use
  25. * your version of this file under the MPL, indicate your decision
  26. * by deleting the provisions above and replace them with the notice
  27. * and other provisions required by the GPL. If you do not delete
  28. * the provisions above, a recipient may use your version of this
  29. * file under either the MPL or the GPL.
  30. *
  31. * --------------------------------------------------------------------
  32. *
  33. * Inquiries regarding the linux-wlan Open Source project can be
  34. * made directly to:
  35. *
  36. * AbsoluteValue Systems Inc.
  37. * info@linux-wlan.com
  38. * http://www.linux-wlan.com
  39. *
  40. * --------------------------------------------------------------------
  41. *
  42. * Portions of the development of this software were funded by
  43. * Intersil Corporation as part of PRISM(R) chipset product development.
  44. *
  45. * --------------------------------------------------------------------
  46. *
  47. * This file implements the module and linux pcmcia routines for the
  48. * prism2 driver.
  49. *
  50. * --------------------------------------------------------------------
  51. */
  52. #include <linux/module.h>
  53. #include <linux/moduleparam.h>
  54. #include <linux/kernel.h>
  55. #include <linux/sched.h>
  56. #include <linux/types.h>
  57. #include <linux/slab.h>
  58. #include <linux/wireless.h>
  59. #include <linux/netdevice.h>
  60. #include <linux/workqueue.h>
  61. #include <linux/byteorder/generic.h>
  62. #include <linux/io.h>
  63. #include <linux/delay.h>
  64. #include <asm/byteorder.h>
  65. #include <linux/if_arp.h>
  66. #include <linux/if_ether.h>
  67. #include <linux/bitops.h>
  68. #include "p80211types.h"
  69. #include "p80211hdr.h"
  70. #include "p80211mgmt.h"
  71. #include "p80211conv.h"
  72. #include "p80211msg.h"
  73. #include "p80211netdev.h"
  74. #include "p80211req.h"
  75. #include "p80211metadef.h"
  76. #include "p80211metastruct.h"
  77. #include "hfa384x.h"
  78. #include "prism2mgmt.h"
  79. static char *dev_info = "prism2_usb";
  80. static wlandevice_t *create_wlan(void);
  81. int prism2_reset_holdtime = 30; /* Reset hold time in ms */
  82. int prism2_reset_settletime = 100; /* Reset settle time in ms */
  83. static int prism2_doreset; /* Do a reset at init? */
  84. module_param(prism2_doreset, int, 0644);
  85. MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
  86. module_param(prism2_reset_holdtime, int, 0644);
  87. MODULE_PARM_DESC(prism2_reset_holdtime, "reset hold time in ms");
  88. module_param(prism2_reset_settletime, int, 0644);
  89. MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms");
  90. MODULE_LICENSE("Dual MPL/GPL");
  91. static int prism2sta_open(wlandevice_t *wlandev);
  92. static int prism2sta_close(wlandevice_t *wlandev);
  93. static void prism2sta_reset(wlandevice_t *wlandev);
  94. static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
  95. union p80211_hdr *p80211_hdr,
  96. struct p80211_metawep *p80211_wep);
  97. static int prism2sta_mlmerequest(wlandevice_t *wlandev, struct p80211msg *msg);
  98. static int prism2sta_getcardinfo(wlandevice_t *wlandev);
  99. static int prism2sta_globalsetup(wlandevice_t *wlandev);
  100. static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev);
  101. static void prism2sta_inf_handover(wlandevice_t *wlandev,
  102. hfa384x_InfFrame_t *inf);
  103. static void prism2sta_inf_tallies(wlandevice_t *wlandev,
  104. hfa384x_InfFrame_t *inf);
  105. static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
  106. hfa384x_InfFrame_t *inf);
  107. static void prism2sta_inf_scanresults(wlandevice_t *wlandev,
  108. hfa384x_InfFrame_t *inf);
  109. static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
  110. hfa384x_InfFrame_t *inf);
  111. static void prism2sta_inf_linkstatus(wlandevice_t *wlandev,
  112. hfa384x_InfFrame_t *inf);
  113. static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
  114. hfa384x_InfFrame_t *inf);
  115. static void prism2sta_inf_authreq(wlandevice_t *wlandev,
  116. hfa384x_InfFrame_t *inf);
  117. static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
  118. hfa384x_InfFrame_t *inf);
  119. static void prism2sta_inf_psusercnt(wlandevice_t *wlandev,
  120. hfa384x_InfFrame_t *inf);
  121. /*----------------------------------------------------------------
  122. * prism2sta_open
  123. *
  124. * WLAN device open method. Called from p80211netdev when kernel
  125. * device open (start) method is called in response to the
  126. * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
  127. * from clear to set.
  128. *
  129. * Arguments:
  130. * wlandev wlan device structure
  131. *
  132. * Returns:
  133. * 0 success
  134. * >0 f/w reported error
  135. * <0 driver reported error
  136. *
  137. * Side effects:
  138. *
  139. * Call context:
  140. * process thread
  141. ----------------------------------------------------------------*/
  142. static int prism2sta_open(wlandevice_t *wlandev)
  143. {
  144. /* We don't currently have to do anything else.
  145. * The setup of the MAC should be subsequently completed via
  146. * the mlme commands.
  147. * Higher layers know we're ready from dev->start==1 and
  148. * dev->tbusy==0. Our rx path knows to pass up received/
  149. * frames because of dev->flags&IFF_UP is true.
  150. */
  151. return 0;
  152. }
  153. /*----------------------------------------------------------------
  154. * prism2sta_close
  155. *
  156. * WLAN device close method. Called from p80211netdev when kernel
  157. * device close method is called in response to the
  158. * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
  159. * from set to clear.
  160. *
  161. * Arguments:
  162. * wlandev wlan device structure
  163. *
  164. * Returns:
  165. * 0 success
  166. * >0 f/w reported error
  167. * <0 driver reported error
  168. *
  169. * Side effects:
  170. *
  171. * Call context:
  172. * process thread
  173. ----------------------------------------------------------------*/
  174. static int prism2sta_close(wlandevice_t *wlandev)
  175. {
  176. /* We don't currently have to do anything else.
  177. * Higher layers know we're not ready from dev->start==0 and
  178. * dev->tbusy==1. Our rx path knows to not pass up received
  179. * frames because of dev->flags&IFF_UP is false.
  180. */
  181. return 0;
  182. }
  183. /*----------------------------------------------------------------
  184. * prism2sta_reset
  185. *
  186. * Not currently implented.
  187. *
  188. * Arguments:
  189. * wlandev wlan device structure
  190. * none
  191. *
  192. * Returns:
  193. * nothing
  194. *
  195. * Side effects:
  196. *
  197. * Call context:
  198. * process thread
  199. ----------------------------------------------------------------*/
  200. static void prism2sta_reset(wlandevice_t *wlandev)
  201. {
  202. }
  203. /*----------------------------------------------------------------
  204. * prism2sta_txframe
  205. *
  206. * Takes a frame from p80211 and queues it for transmission.
  207. *
  208. * Arguments:
  209. * wlandev wlan device structure
  210. * pb packet buffer struct. Contains an 802.11
  211. * data frame.
  212. * p80211_hdr points to the 802.11 header for the packet.
  213. * Returns:
  214. * 0 Success and more buffs available
  215. * 1 Success but no more buffs
  216. * 2 Allocation failure
  217. * 4 Buffer full or queue busy
  218. *
  219. * Side effects:
  220. *
  221. * Call context:
  222. * process thread
  223. ----------------------------------------------------------------*/
  224. static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
  225. union p80211_hdr *p80211_hdr,
  226. struct p80211_metawep *p80211_wep)
  227. {
  228. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  229. int result;
  230. /* If necessary, set the 802.11 WEP bit */
  231. if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) ==
  232. HOSTWEP_PRIVACYINVOKED) {
  233. p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
  234. }
  235. result = hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
  236. return result;
  237. }
  238. /*----------------------------------------------------------------
  239. * prism2sta_mlmerequest
  240. *
  241. * wlan command message handler. All we do here is pass the message
  242. * over to the prism2sta_mgmt_handler.
  243. *
  244. * Arguments:
  245. * wlandev wlan device structure
  246. * msg wlan command message
  247. * Returns:
  248. * 0 success
  249. * <0 successful acceptance of message, but we're
  250. * waiting for an async process to finish before
  251. * we're done with the msg. When the asynch
  252. * process is done, we'll call the p80211
  253. * function p80211req_confirm() .
  254. * >0 An error occurred while we were handling
  255. * the message.
  256. *
  257. * Side effects:
  258. *
  259. * Call context:
  260. * process thread
  261. ----------------------------------------------------------------*/
  262. static int prism2sta_mlmerequest(wlandevice_t *wlandev, struct p80211msg *msg)
  263. {
  264. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  265. int result = 0;
  266. switch (msg->msgcode) {
  267. case DIDmsg_dot11req_mibget:
  268. pr_debug("Received mibget request\n");
  269. result = prism2mgmt_mibset_mibget(wlandev, msg);
  270. break;
  271. case DIDmsg_dot11req_mibset:
  272. pr_debug("Received mibset request\n");
  273. result = prism2mgmt_mibset_mibget(wlandev, msg);
  274. break;
  275. case DIDmsg_dot11req_scan:
  276. pr_debug("Received scan request\n");
  277. result = prism2mgmt_scan(wlandev, msg);
  278. break;
  279. case DIDmsg_dot11req_scan_results:
  280. pr_debug("Received scan_results request\n");
  281. result = prism2mgmt_scan_results(wlandev, msg);
  282. break;
  283. case DIDmsg_dot11req_start:
  284. pr_debug("Received mlme start request\n");
  285. result = prism2mgmt_start(wlandev, msg);
  286. break;
  287. /*
  288. * Prism2 specific messages
  289. */
  290. case DIDmsg_p2req_readpda:
  291. pr_debug("Received mlme readpda request\n");
  292. result = prism2mgmt_readpda(wlandev, msg);
  293. break;
  294. case DIDmsg_p2req_ramdl_state:
  295. pr_debug("Received mlme ramdl_state request\n");
  296. result = prism2mgmt_ramdl_state(wlandev, msg);
  297. break;
  298. case DIDmsg_p2req_ramdl_write:
  299. pr_debug("Received mlme ramdl_write request\n");
  300. result = prism2mgmt_ramdl_write(wlandev, msg);
  301. break;
  302. case DIDmsg_p2req_flashdl_state:
  303. pr_debug("Received mlme flashdl_state request\n");
  304. result = prism2mgmt_flashdl_state(wlandev, msg);
  305. break;
  306. case DIDmsg_p2req_flashdl_write:
  307. pr_debug("Received mlme flashdl_write request\n");
  308. result = prism2mgmt_flashdl_write(wlandev, msg);
  309. break;
  310. /*
  311. * Linux specific messages
  312. */
  313. case DIDmsg_lnxreq_hostwep:
  314. break; /* ignore me. */
  315. case DIDmsg_lnxreq_ifstate:
  316. {
  317. struct p80211msg_lnxreq_ifstate *ifstatemsg;
  318. pr_debug("Received mlme ifstate request\n");
  319. ifstatemsg = (struct p80211msg_lnxreq_ifstate *) msg;
  320. result =
  321. prism2sta_ifstate(wlandev,
  322. ifstatemsg->ifstate.data);
  323. ifstatemsg->resultcode.status =
  324. P80211ENUM_msgitem_status_data_ok;
  325. ifstatemsg->resultcode.data = result;
  326. result = 0;
  327. }
  328. break;
  329. case DIDmsg_lnxreq_wlansniff:
  330. pr_debug("Received mlme wlansniff request\n");
  331. result = prism2mgmt_wlansniff(wlandev, msg);
  332. break;
  333. case DIDmsg_lnxreq_autojoin:
  334. pr_debug("Received mlme autojoin request\n");
  335. result = prism2mgmt_autojoin(wlandev, msg);
  336. break;
  337. case DIDmsg_lnxreq_commsquality:{
  338. struct p80211msg_lnxreq_commsquality *qualmsg;
  339. pr_debug("Received commsquality request\n");
  340. qualmsg = (struct p80211msg_lnxreq_commsquality *) msg;
  341. qualmsg->link.status =
  342. P80211ENUM_msgitem_status_data_ok;
  343. qualmsg->level.status =
  344. P80211ENUM_msgitem_status_data_ok;
  345. qualmsg->noise.status =
  346. P80211ENUM_msgitem_status_data_ok;
  347. qualmsg->link.data = le16_to_cpu(hw->qual.CQ_currBSS);
  348. qualmsg->level.data = le16_to_cpu(hw->qual.ASL_currBSS);
  349. qualmsg->noise.data = le16_to_cpu(hw->qual.ANL_currFC);
  350. qualmsg->txrate.data = hw->txrate;
  351. break;
  352. }
  353. default:
  354. netdev_warn(wlandev->netdev,
  355. "Unknown mgmt request message 0x%08x",
  356. msg->msgcode);
  357. break;
  358. }
  359. return result;
  360. }
  361. /*----------------------------------------------------------------
  362. * prism2sta_ifstate
  363. *
  364. * Interface state. This is the primary WLAN interface enable/disable
  365. * handler. Following the driver/load/deviceprobe sequence, this
  366. * function must be called with a state of "enable" before any other
  367. * commands will be accepted.
  368. *
  369. * Arguments:
  370. * wlandev wlan device structure
  371. * msgp ptr to msg buffer
  372. *
  373. * Returns:
  374. * A p80211 message resultcode value.
  375. *
  376. * Side effects:
  377. *
  378. * Call context:
  379. * process thread (usually)
  380. * interrupt
  381. ----------------------------------------------------------------*/
  382. u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate)
  383. {
  384. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  385. u32 result;
  386. result = P80211ENUM_resultcode_implementation_failure;
  387. pr_debug("Current MSD state(%d), requesting(%d)\n",
  388. wlandev->msdstate, ifstate);
  389. switch (ifstate) {
  390. case P80211ENUM_ifstate_fwload:
  391. switch (wlandev->msdstate) {
  392. case WLAN_MSD_HWPRESENT:
  393. wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING;
  394. /*
  395. * Initialize the device+driver sufficiently
  396. * for firmware loading.
  397. */
  398. result = hfa384x_drvr_start(hw);
  399. if (result) {
  400. netdev_err(wlandev->netdev,
  401. "hfa384x_drvr_start() failed,result=%d\n", (int)result);
  402. result =
  403. P80211ENUM_resultcode_implementation_failure;
  404. wlandev->msdstate = WLAN_MSD_HWPRESENT;
  405. break;
  406. }
  407. wlandev->msdstate = WLAN_MSD_FWLOAD;
  408. result = P80211ENUM_resultcode_success;
  409. break;
  410. case WLAN_MSD_FWLOAD:
  411. hfa384x_cmd_initialize(hw);
  412. result = P80211ENUM_resultcode_success;
  413. break;
  414. case WLAN_MSD_RUNNING:
  415. netdev_warn(wlandev->netdev,
  416. "Cannot enter fwload state from enable state, you must disable first.\n");
  417. result = P80211ENUM_resultcode_invalid_parameters;
  418. break;
  419. case WLAN_MSD_HWFAIL:
  420. default:
  421. /* probe() had a problem or the msdstate contains
  422. * an unrecognized value, there's nothing we can do.
  423. */
  424. result = P80211ENUM_resultcode_implementation_failure;
  425. break;
  426. }
  427. break;
  428. case P80211ENUM_ifstate_enable:
  429. switch (wlandev->msdstate) {
  430. case WLAN_MSD_HWPRESENT:
  431. case WLAN_MSD_FWLOAD:
  432. wlandev->msdstate = WLAN_MSD_RUNNING_PENDING;
  433. /* Initialize the device+driver for full
  434. * operation. Note that this might me an FWLOAD to
  435. * to RUNNING transition so we must not do a chip
  436. * or board level reset. Note that on failure,
  437. * the MSD state is set to HWPRESENT because we
  438. * can't make any assumptions about the state
  439. * of the hardware or a previous firmware load.
  440. */
  441. result = hfa384x_drvr_start(hw);
  442. if (result) {
  443. netdev_err(wlandev->netdev,
  444. "hfa384x_drvr_start() failed,result=%d\n", (int)result);
  445. result =
  446. P80211ENUM_resultcode_implementation_failure;
  447. wlandev->msdstate = WLAN_MSD_HWPRESENT;
  448. break;
  449. }
  450. result = prism2sta_getcardinfo(wlandev);
  451. if (result) {
  452. netdev_err(wlandev->netdev,
  453. "prism2sta_getcardinfo() failed,result=%d\n", (int)result);
  454. result =
  455. P80211ENUM_resultcode_implementation_failure;
  456. hfa384x_drvr_stop(hw);
  457. wlandev->msdstate = WLAN_MSD_HWPRESENT;
  458. break;
  459. }
  460. result = prism2sta_globalsetup(wlandev);
  461. if (result) {
  462. netdev_err(wlandev->netdev,
  463. "prism2sta_globalsetup() failed,result=%d\n", (int)result);
  464. result =
  465. P80211ENUM_resultcode_implementation_failure;
  466. hfa384x_drvr_stop(hw);
  467. wlandev->msdstate = WLAN_MSD_HWPRESENT;
  468. break;
  469. }
  470. wlandev->msdstate = WLAN_MSD_RUNNING;
  471. hw->join_ap = 0;
  472. hw->join_retries = 60;
  473. result = P80211ENUM_resultcode_success;
  474. break;
  475. case WLAN_MSD_RUNNING:
  476. /* Do nothing, we're already in this state. */
  477. result = P80211ENUM_resultcode_success;
  478. break;
  479. case WLAN_MSD_HWFAIL:
  480. default:
  481. /* probe() had a problem or the msdstate contains
  482. * an unrecognized value, there's nothing we can do.
  483. */
  484. result = P80211ENUM_resultcode_implementation_failure;
  485. break;
  486. }
  487. break;
  488. case P80211ENUM_ifstate_disable:
  489. switch (wlandev->msdstate) {
  490. case WLAN_MSD_HWPRESENT:
  491. /* Do nothing, we're already in this state. */
  492. result = P80211ENUM_resultcode_success;
  493. break;
  494. case WLAN_MSD_FWLOAD:
  495. case WLAN_MSD_RUNNING:
  496. wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
  497. /*
  498. * TODO: Shut down the MAC completely. Here a chip
  499. * or board level reset is probably called for.
  500. * After a "disable" _all_ results are lost, even
  501. * those from a fwload.
  502. */
  503. if (!wlandev->hwremoved)
  504. netif_carrier_off(wlandev->netdev);
  505. hfa384x_drvr_stop(hw);
  506. wlandev->macmode = WLAN_MACMODE_NONE;
  507. wlandev->msdstate = WLAN_MSD_HWPRESENT;
  508. result = P80211ENUM_resultcode_success;
  509. break;
  510. case WLAN_MSD_HWFAIL:
  511. default:
  512. /* probe() had a problem or the msdstate contains
  513. * an unrecognized value, there's nothing we can do.
  514. */
  515. result = P80211ENUM_resultcode_implementation_failure;
  516. break;
  517. }
  518. break;
  519. default:
  520. result = P80211ENUM_resultcode_invalid_parameters;
  521. break;
  522. }
  523. return result;
  524. }
  525. /*----------------------------------------------------------------
  526. * prism2sta_getcardinfo
  527. *
  528. * Collect the NICID, firmware version and any other identifiers
  529. * we'd like to have in host-side data structures.
  530. *
  531. * Arguments:
  532. * wlandev wlan device structure
  533. *
  534. * Returns:
  535. * 0 success
  536. * >0 f/w reported error
  537. * <0 driver reported error
  538. *
  539. * Side effects:
  540. *
  541. * Call context:
  542. * Either.
  543. ----------------------------------------------------------------*/
  544. static int prism2sta_getcardinfo(wlandevice_t *wlandev)
  545. {
  546. int result = 0;
  547. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  548. u16 temp;
  549. u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
  550. /* Collect version and compatibility info */
  551. /* Some are critical, some are not */
  552. /* NIC identity */
  553. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY,
  554. &hw->ident_nic,
  555. sizeof(hfa384x_compident_t));
  556. if (result) {
  557. netdev_err(wlandev->netdev, "Failed to retrieve NICIDENTITY\n");
  558. goto failed;
  559. }
  560. /* get all the nic id fields in host byte order */
  561. hw->ident_nic.id = le16_to_cpu(hw->ident_nic.id);
  562. hw->ident_nic.variant = le16_to_cpu(hw->ident_nic.variant);
  563. hw->ident_nic.major = le16_to_cpu(hw->ident_nic.major);
  564. hw->ident_nic.minor = le16_to_cpu(hw->ident_nic.minor);
  565. netdev_info(wlandev->netdev, "ident: nic h/w: id=0x%02x %d.%d.%d\n",
  566. hw->ident_nic.id, hw->ident_nic.major,
  567. hw->ident_nic.minor, hw->ident_nic.variant);
  568. /* Primary f/w identity */
  569. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,
  570. &hw->ident_pri_fw,
  571. sizeof(hfa384x_compident_t));
  572. if (result) {
  573. netdev_err(wlandev->netdev, "Failed to retrieve PRIIDENTITY\n");
  574. goto failed;
  575. }
  576. /* get all the private fw id fields in host byte order */
  577. hw->ident_pri_fw.id = le16_to_cpu(hw->ident_pri_fw.id);
  578. hw->ident_pri_fw.variant = le16_to_cpu(hw->ident_pri_fw.variant);
  579. hw->ident_pri_fw.major = le16_to_cpu(hw->ident_pri_fw.major);
  580. hw->ident_pri_fw.minor = le16_to_cpu(hw->ident_pri_fw.minor);
  581. netdev_info(wlandev->netdev, "ident: pri f/w: id=0x%02x %d.%d.%d\n",
  582. hw->ident_pri_fw.id, hw->ident_pri_fw.major,
  583. hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
  584. /* Station (Secondary?) f/w identity */
  585. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,
  586. &hw->ident_sta_fw,
  587. sizeof(hfa384x_compident_t));
  588. if (result) {
  589. netdev_err(wlandev->netdev, "Failed to retrieve STAIDENTITY\n");
  590. goto failed;
  591. }
  592. if (hw->ident_nic.id < 0x8000) {
  593. netdev_err(wlandev->netdev,
  594. "FATAL: Card is not an Intersil Prism2/2.5/3\n");
  595. result = -1;
  596. goto failed;
  597. }
  598. /* get all the station fw id fields in host byte order */
  599. hw->ident_sta_fw.id = le16_to_cpu(hw->ident_sta_fw.id);
  600. hw->ident_sta_fw.variant = le16_to_cpu(hw->ident_sta_fw.variant);
  601. hw->ident_sta_fw.major = le16_to_cpu(hw->ident_sta_fw.major);
  602. hw->ident_sta_fw.minor = le16_to_cpu(hw->ident_sta_fw.minor);
  603. /* strip out the 'special' variant bits */
  604. hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15));
  605. hw->ident_sta_fw.variant &= ~((u16) (BIT(14) | BIT(15)));
  606. if (hw->ident_sta_fw.id == 0x1f) {
  607. netdev_info(wlandev->netdev,
  608. "ident: sta f/w: id=0x%02x %d.%d.%d\n",
  609. hw->ident_sta_fw.id, hw->ident_sta_fw.major,
  610. hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
  611. } else {
  612. netdev_info(wlandev->netdev,
  613. "ident: ap f/w: id=0x%02x %d.%d.%d\n",
  614. hw->ident_sta_fw.id, hw->ident_sta_fw.major,
  615. hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
  616. netdev_err(wlandev->netdev, "Unsupported Tertiary AP firmeare loaded!\n");
  617. goto failed;
  618. }
  619. /* Compatibility range, Modem supplier */
  620. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,
  621. &hw->cap_sup_mfi,
  622. sizeof(hfa384x_caplevel_t));
  623. if (result) {
  624. netdev_err(wlandev->netdev, "Failed to retrieve MFISUPRANGE\n");
  625. goto failed;
  626. }
  627. /* get all the Compatibility range, modem interface supplier
  628. fields in byte order */
  629. hw->cap_sup_mfi.role = le16_to_cpu(hw->cap_sup_mfi.role);
  630. hw->cap_sup_mfi.id = le16_to_cpu(hw->cap_sup_mfi.id);
  631. hw->cap_sup_mfi.variant = le16_to_cpu(hw->cap_sup_mfi.variant);
  632. hw->cap_sup_mfi.bottom = le16_to_cpu(hw->cap_sup_mfi.bottom);
  633. hw->cap_sup_mfi.top = le16_to_cpu(hw->cap_sup_mfi.top);
  634. netdev_info(wlandev->netdev,
  635. "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
  636. hw->cap_sup_mfi.role, hw->cap_sup_mfi.id,
  637. hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom,
  638. hw->cap_sup_mfi.top);
  639. /* Compatibility range, Controller supplier */
  640. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,
  641. &hw->cap_sup_cfi,
  642. sizeof(hfa384x_caplevel_t));
  643. if (result) {
  644. netdev_err(wlandev->netdev, "Failed to retrieve CFISUPRANGE\n");
  645. goto failed;
  646. }
  647. /* get all the Compatibility range, controller interface supplier
  648. fields in byte order */
  649. hw->cap_sup_cfi.role = le16_to_cpu(hw->cap_sup_cfi.role);
  650. hw->cap_sup_cfi.id = le16_to_cpu(hw->cap_sup_cfi.id);
  651. hw->cap_sup_cfi.variant = le16_to_cpu(hw->cap_sup_cfi.variant);
  652. hw->cap_sup_cfi.bottom = le16_to_cpu(hw->cap_sup_cfi.bottom);
  653. hw->cap_sup_cfi.top = le16_to_cpu(hw->cap_sup_cfi.top);
  654. netdev_info(wlandev->netdev,
  655. "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
  656. hw->cap_sup_cfi.role, hw->cap_sup_cfi.id,
  657. hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom,
  658. hw->cap_sup_cfi.top);
  659. /* Compatibility range, Primary f/w supplier */
  660. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE,
  661. &hw->cap_sup_pri,
  662. sizeof(hfa384x_caplevel_t));
  663. if (result) {
  664. netdev_err(wlandev->netdev, "Failed to retrieve PRISUPRANGE\n");
  665. goto failed;
  666. }
  667. /* get all the Compatibility range, primary firmware supplier
  668. fields in byte order */
  669. hw->cap_sup_pri.role = le16_to_cpu(hw->cap_sup_pri.role);
  670. hw->cap_sup_pri.id = le16_to_cpu(hw->cap_sup_pri.id);
  671. hw->cap_sup_pri.variant = le16_to_cpu(hw->cap_sup_pri.variant);
  672. hw->cap_sup_pri.bottom = le16_to_cpu(hw->cap_sup_pri.bottom);
  673. hw->cap_sup_pri.top = le16_to_cpu(hw->cap_sup_pri.top);
  674. netdev_info(wlandev->netdev,
  675. "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
  676. hw->cap_sup_pri.role, hw->cap_sup_pri.id,
  677. hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom,
  678. hw->cap_sup_pri.top);
  679. /* Compatibility range, Station f/w supplier */
  680. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE,
  681. &hw->cap_sup_sta,
  682. sizeof(hfa384x_caplevel_t));
  683. if (result) {
  684. netdev_err(wlandev->netdev, "Failed to retrieve STASUPRANGE\n");
  685. goto failed;
  686. }
  687. /* get all the Compatibility range, station firmware supplier
  688. fields in byte order */
  689. hw->cap_sup_sta.role = le16_to_cpu(hw->cap_sup_sta.role);
  690. hw->cap_sup_sta.id = le16_to_cpu(hw->cap_sup_sta.id);
  691. hw->cap_sup_sta.variant = le16_to_cpu(hw->cap_sup_sta.variant);
  692. hw->cap_sup_sta.bottom = le16_to_cpu(hw->cap_sup_sta.bottom);
  693. hw->cap_sup_sta.top = le16_to_cpu(hw->cap_sup_sta.top);
  694. if (hw->cap_sup_sta.id == 0x04) {
  695. netdev_info(wlandev->netdev,
  696. "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
  697. hw->cap_sup_sta.role, hw->cap_sup_sta.id,
  698. hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
  699. hw->cap_sup_sta.top);
  700. } else {
  701. netdev_info(wlandev->netdev,
  702. "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
  703. hw->cap_sup_sta.role, hw->cap_sup_sta.id,
  704. hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
  705. hw->cap_sup_sta.top);
  706. }
  707. /* Compatibility range, primary f/w actor, CFI supplier */
  708. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES,
  709. &hw->cap_act_pri_cfi,
  710. sizeof(hfa384x_caplevel_t));
  711. if (result) {
  712. netdev_err(wlandev->netdev, "Failed to retrieve PRI_CFIACTRANGES\n");
  713. goto failed;
  714. }
  715. /* get all the Compatibility range, primary f/w actor, CFI supplier
  716. fields in byte order */
  717. hw->cap_act_pri_cfi.role = le16_to_cpu(hw->cap_act_pri_cfi.role);
  718. hw->cap_act_pri_cfi.id = le16_to_cpu(hw->cap_act_pri_cfi.id);
  719. hw->cap_act_pri_cfi.variant = le16_to_cpu(hw->cap_act_pri_cfi.variant);
  720. hw->cap_act_pri_cfi.bottom = le16_to_cpu(hw->cap_act_pri_cfi.bottom);
  721. hw->cap_act_pri_cfi.top = le16_to_cpu(hw->cap_act_pri_cfi.top);
  722. netdev_info(wlandev->netdev,
  723. "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
  724. hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id,
  725. hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom,
  726. hw->cap_act_pri_cfi.top);
  727. /* Compatibility range, sta f/w actor, CFI supplier */
  728. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES,
  729. &hw->cap_act_sta_cfi,
  730. sizeof(hfa384x_caplevel_t));
  731. if (result) {
  732. netdev_err(wlandev->netdev, "Failed to retrieve STA_CFIACTRANGES\n");
  733. goto failed;
  734. }
  735. /* get all the Compatibility range, station f/w actor, CFI supplier
  736. fields in byte order */
  737. hw->cap_act_sta_cfi.role = le16_to_cpu(hw->cap_act_sta_cfi.role);
  738. hw->cap_act_sta_cfi.id = le16_to_cpu(hw->cap_act_sta_cfi.id);
  739. hw->cap_act_sta_cfi.variant = le16_to_cpu(hw->cap_act_sta_cfi.variant);
  740. hw->cap_act_sta_cfi.bottom = le16_to_cpu(hw->cap_act_sta_cfi.bottom);
  741. hw->cap_act_sta_cfi.top = le16_to_cpu(hw->cap_act_sta_cfi.top);
  742. netdev_info(wlandev->netdev,
  743. "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
  744. hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id,
  745. hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom,
  746. hw->cap_act_sta_cfi.top);
  747. /* Compatibility range, sta f/w actor, MFI supplier */
  748. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES,
  749. &hw->cap_act_sta_mfi,
  750. sizeof(hfa384x_caplevel_t));
  751. if (result) {
  752. netdev_err(wlandev->netdev, "Failed to retrieve STA_MFIACTRANGES\n");
  753. goto failed;
  754. }
  755. /* get all the Compatibility range, station f/w actor, MFI supplier
  756. fields in byte order */
  757. hw->cap_act_sta_mfi.role = le16_to_cpu(hw->cap_act_sta_mfi.role);
  758. hw->cap_act_sta_mfi.id = le16_to_cpu(hw->cap_act_sta_mfi.id);
  759. hw->cap_act_sta_mfi.variant = le16_to_cpu(hw->cap_act_sta_mfi.variant);
  760. hw->cap_act_sta_mfi.bottom = le16_to_cpu(hw->cap_act_sta_mfi.bottom);
  761. hw->cap_act_sta_mfi.top = le16_to_cpu(hw->cap_act_sta_mfi.top);
  762. netdev_info(wlandev->netdev,
  763. "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
  764. hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id,
  765. hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom,
  766. hw->cap_act_sta_mfi.top);
  767. /* Serial Number */
  768. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
  769. snum, HFA384x_RID_NICSERIALNUMBER_LEN);
  770. if (!result) {
  771. netdev_info(wlandev->netdev, "Prism2 card SN: %*pEhp\n",
  772. HFA384x_RID_NICSERIALNUMBER_LEN, snum);
  773. } else {
  774. netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n");
  775. goto failed;
  776. }
  777. /* Collect the MAC address */
  778. result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
  779. wlandev->netdev->dev_addr, ETH_ALEN);
  780. if (result != 0) {
  781. netdev_err(wlandev->netdev, "Failed to retrieve mac address\n");
  782. goto failed;
  783. }
  784. /* short preamble is always implemented */
  785. wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE;
  786. /* find out if hardware wep is implemented */
  787. hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp);
  788. if (temp)
  789. wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP;
  790. /* get the dBm Scaling constant */
  791. hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp);
  792. hw->dbmadjust = temp;
  793. /* Only enable scan by default on newer firmware */
  794. if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
  795. hw->ident_sta_fw.minor,
  796. hw->ident_sta_fw.variant) <
  797. HFA384x_FIRMWARE_VERSION(1, 5, 5)) {
  798. wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN;
  799. }
  800. /* TODO: Set any internally managed config items */
  801. goto done;
  802. failed:
  803. netdev_err(wlandev->netdev, "Failed, result=%d\n", result);
  804. done:
  805. return result;
  806. }
  807. /*----------------------------------------------------------------
  808. * prism2sta_globalsetup
  809. *
  810. * Set any global RIDs that we want to set at device activation.
  811. *
  812. * Arguments:
  813. * wlandev wlan device structure
  814. *
  815. * Returns:
  816. * 0 success
  817. * >0 f/w reported error
  818. * <0 driver reported error
  819. *
  820. * Side effects:
  821. *
  822. * Call context:
  823. * process thread
  824. ----------------------------------------------------------------*/
  825. static int prism2sta_globalsetup(wlandevice_t *wlandev)
  826. {
  827. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  828. /* Set the maximum frame size */
  829. return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN,
  830. WLAN_DATA_MAXLEN);
  831. }
  832. static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev)
  833. {
  834. int result = 0;
  835. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  836. u16 promisc;
  837. /* If we're not ready, what's the point? */
  838. if (hw->state != HFA384x_STATE_RUNNING)
  839. goto exit;
  840. if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0)
  841. promisc = P80211ENUM_truth_true;
  842. else
  843. promisc = P80211ENUM_truth_false;
  844. result =
  845. hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE,
  846. promisc);
  847. exit:
  848. return result;
  849. }
  850. /*----------------------------------------------------------------
  851. * prism2sta_inf_handover
  852. *
  853. * Handles the receipt of a Handover info frame. Should only be present
  854. * in APs only.
  855. *
  856. * Arguments:
  857. * wlandev wlan device structure
  858. * inf ptr to info frame (contents in hfa384x order)
  859. *
  860. * Returns:
  861. * nothing
  862. *
  863. * Side effects:
  864. *
  865. * Call context:
  866. * interrupt
  867. ----------------------------------------------------------------*/
  868. static void prism2sta_inf_handover(wlandevice_t *wlandev,
  869. hfa384x_InfFrame_t *inf)
  870. {
  871. pr_debug("received infoframe:HANDOVER (unhandled)\n");
  872. }
  873. /*----------------------------------------------------------------
  874. * prism2sta_inf_tallies
  875. *
  876. * Handles the receipt of a CommTallies info frame.
  877. *
  878. * Arguments:
  879. * wlandev wlan device structure
  880. * inf ptr to info frame (contents in hfa384x order)
  881. *
  882. * Returns:
  883. * nothing
  884. *
  885. * Side effects:
  886. *
  887. * Call context:
  888. * interrupt
  889. ----------------------------------------------------------------*/
  890. static void prism2sta_inf_tallies(wlandevice_t *wlandev,
  891. hfa384x_InfFrame_t *inf)
  892. {
  893. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  894. u16 *src16;
  895. u32 *dst;
  896. u32 *src32;
  897. int i;
  898. int cnt;
  899. /*
  900. ** Determine if these are 16-bit or 32-bit tallies, based on the
  901. ** record length of the info record.
  902. */
  903. cnt = sizeof(hfa384x_CommTallies32_t) / sizeof(u32);
  904. if (inf->framelen > 22) {
  905. dst = (u32 *) &hw->tallies;
  906. src32 = (u32 *) &inf->info.commtallies32;
  907. for (i = 0; i < cnt; i++, dst++, src32++)
  908. *dst += le32_to_cpu(*src32);
  909. } else {
  910. dst = (u32 *) &hw->tallies;
  911. src16 = (u16 *) &inf->info.commtallies16;
  912. for (i = 0; i < cnt; i++, dst++, src16++)
  913. *dst += le16_to_cpu(*src16);
  914. }
  915. }
  916. /*----------------------------------------------------------------
  917. * prism2sta_inf_scanresults
  918. *
  919. * Handles the receipt of a Scan Results info frame.
  920. *
  921. * Arguments:
  922. * wlandev wlan device structure
  923. * inf ptr to info frame (contents in hfa384x order)
  924. *
  925. * Returns:
  926. * nothing
  927. *
  928. * Side effects:
  929. *
  930. * Call context:
  931. * interrupt
  932. ----------------------------------------------------------------*/
  933. static void prism2sta_inf_scanresults(wlandevice_t *wlandev,
  934. hfa384x_InfFrame_t *inf)
  935. {
  936. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  937. int nbss;
  938. hfa384x_ScanResult_t *sr = &(inf->info.scanresult);
  939. int i;
  940. hfa384x_JoinRequest_data_t joinreq;
  941. int result;
  942. /* Get the number of results, first in bytes, then in results */
  943. nbss = (inf->framelen * sizeof(u16)) -
  944. sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason);
  945. nbss /= sizeof(hfa384x_ScanResultSub_t);
  946. /* Print em */
  947. pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
  948. inf->info.scanresult.scanreason, nbss);
  949. for (i = 0; i < nbss; i++) {
  950. pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
  951. sr->result[i].chid,
  952. sr->result[i].anl,
  953. sr->result[i].sl, sr->result[i].bcnint);
  954. pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
  955. sr->result[i].capinfo, sr->result[i].proberesp_rate);
  956. }
  957. /* issue a join request */
  958. joinreq.channel = sr->result[0].chid;
  959. memcpy(joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN);
  960. result = hfa384x_drvr_setconfig(hw,
  961. HFA384x_RID_JOINREQUEST,
  962. &joinreq, HFA384x_RID_JOINREQUEST_LEN);
  963. if (result) {
  964. netdev_err(wlandev->netdev, "setconfig(joinreq) failed, result=%d\n",
  965. result);
  966. }
  967. }
  968. /*----------------------------------------------------------------
  969. * prism2sta_inf_hostscanresults
  970. *
  971. * Handles the receipt of a Scan Results info frame.
  972. *
  973. * Arguments:
  974. * wlandev wlan device structure
  975. * inf ptr to info frame (contents in hfa384x order)
  976. *
  977. * Returns:
  978. * nothing
  979. *
  980. * Side effects:
  981. *
  982. * Call context:
  983. * interrupt
  984. ----------------------------------------------------------------*/
  985. static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
  986. hfa384x_InfFrame_t *inf)
  987. {
  988. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  989. int nbss;
  990. nbss = (inf->framelen - 3) / 32;
  991. pr_debug("Received %d hostscan results\n", nbss);
  992. if (nbss > 32)
  993. nbss = 32;
  994. kfree(hw->scanresults);
  995. hw->scanresults = kmemdup(inf, sizeof(hfa384x_InfFrame_t), GFP_ATOMIC);
  996. if (nbss == 0)
  997. nbss = -1;
  998. /* Notify/wake the sleeping caller. */
  999. hw->scanflag = nbss;
  1000. wake_up_interruptible(&hw->cmdq);
  1001. };
  1002. /*----------------------------------------------------------------
  1003. * prism2sta_inf_chinforesults
  1004. *
  1005. * Handles the receipt of a Channel Info Results info frame.
  1006. *
  1007. * Arguments:
  1008. * wlandev wlan device structure
  1009. * inf ptr to info frame (contents in hfa384x order)
  1010. *
  1011. * Returns:
  1012. * nothing
  1013. *
  1014. * Side effects:
  1015. *
  1016. * Call context:
  1017. * interrupt
  1018. ----------------------------------------------------------------*/
  1019. static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
  1020. hfa384x_InfFrame_t *inf)
  1021. {
  1022. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  1023. unsigned int i, n;
  1024. hw->channel_info.results.scanchannels =
  1025. le16_to_cpu(inf->info.chinforesult.scanchannels);
  1026. for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
  1027. hfa384x_ChInfoResultSub_t *result;
  1028. hfa384x_ChInfoResultSub_t *chinforesult;
  1029. int chan;
  1030. if (!(hw->channel_info.results.scanchannels & (1 << i)))
  1031. continue;
  1032. result = &inf->info.chinforesult.result[n];
  1033. chan = le16_to_cpu(result->chid) - 1;
  1034. if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX)
  1035. continue;
  1036. chinforesult = &hw->channel_info.results.result[chan];
  1037. chinforesult->chid = chan;
  1038. chinforesult->anl = le16_to_cpu(result->anl);
  1039. chinforesult->pnl = le16_to_cpu(result->pnl);
  1040. chinforesult->active = le16_to_cpu(result->active);
  1041. pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
  1042. chan + 1,
  1043. (chinforesult->active & HFA384x_CHINFORESULT_BSSACTIVE)
  1044. ? "signal" : "noise",
  1045. chinforesult->anl, chinforesult->pnl,
  1046. (chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE)
  1047. ? 1 : 0);
  1048. n++;
  1049. }
  1050. atomic_set(&hw->channel_info.done, 2);
  1051. hw->channel_info.count = n;
  1052. }
  1053. void prism2sta_processing_defer(struct work_struct *data)
  1054. {
  1055. hfa384x_t *hw = container_of(data, struct hfa384x, link_bh);
  1056. wlandevice_t *wlandev = hw->wlandev;
  1057. hfa384x_bytestr32_t ssid;
  1058. int result;
  1059. /* First let's process the auth frames */
  1060. {
  1061. struct sk_buff *skb;
  1062. hfa384x_InfFrame_t *inf;
  1063. while ((skb = skb_dequeue(&hw->authq))) {
  1064. inf = (hfa384x_InfFrame_t *) skb->data;
  1065. prism2sta_inf_authreq_defer(wlandev, inf);
  1066. }
  1067. }
  1068. /* Now let's handle the linkstatus stuff */
  1069. if (hw->link_status == hw->link_status_new)
  1070. return;
  1071. hw->link_status = hw->link_status_new;
  1072. switch (hw->link_status) {
  1073. case HFA384x_LINK_NOTCONNECTED:
  1074. /* I'm currently assuming that this is the initial link
  1075. * state. It should only be possible immediately
  1076. * following an Enable command.
  1077. * Response:
  1078. * Block Transmits, Ignore receives of data frames
  1079. */
  1080. netif_carrier_off(wlandev->netdev);
  1081. netdev_info(wlandev->netdev, "linkstatus=NOTCONNECTED (unhandled)\n");
  1082. break;
  1083. case HFA384x_LINK_CONNECTED:
  1084. /* This one indicates a successful scan/join/auth/assoc.
  1085. * When we have the full MLME complement, this event will
  1086. * signify successful completion of both mlme_authenticate
  1087. * and mlme_associate. State management will get a little
  1088. * ugly here.
  1089. * Response:
  1090. * Indicate authentication and/or association
  1091. * Enable Transmits, Receives and pass up data frames
  1092. */
  1093. netif_carrier_on(wlandev->netdev);
  1094. /* If we are joining a specific AP, set our
  1095. * state and reset retries
  1096. */
  1097. if (hw->join_ap == 1)
  1098. hw->join_ap = 2;
  1099. hw->join_retries = 60;
  1100. /* Don't call this in monitor mode */
  1101. if (wlandev->netdev->type == ARPHRD_ETHER) {
  1102. u16 portstatus;
  1103. netdev_info(wlandev->netdev, "linkstatus=CONNECTED\n");
  1104. /* For non-usb devices, we can use the sync versions */
  1105. /* Collect the BSSID, and set state to allow tx */
  1106. result = hfa384x_drvr_getconfig(hw,
  1107. HFA384x_RID_CURRENTBSSID,
  1108. wlandev->bssid,
  1109. WLAN_BSSID_LEN);
  1110. if (result) {
  1111. pr_debug
  1112. ("getconfig(0x%02x) failed, result = %d\n",
  1113. HFA384x_RID_CURRENTBSSID, result);
  1114. return;
  1115. }
  1116. result = hfa384x_drvr_getconfig(hw,
  1117. HFA384x_RID_CURRENTSSID,
  1118. &ssid, sizeof(ssid));
  1119. if (result) {
  1120. pr_debug
  1121. ("getconfig(0x%02x) failed, result = %d\n",
  1122. HFA384x_RID_CURRENTSSID, result);
  1123. return;
  1124. }
  1125. prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *) &ssid,
  1126. (p80211pstrd_t *) &
  1127. wlandev->ssid);
  1128. /* Collect the port status */
  1129. result = hfa384x_drvr_getconfig16(hw,
  1130. HFA384x_RID_PORTSTATUS,
  1131. &portstatus);
  1132. if (result) {
  1133. pr_debug
  1134. ("getconfig(0x%02x) failed, result = %d\n",
  1135. HFA384x_RID_PORTSTATUS, result);
  1136. return;
  1137. }
  1138. wlandev->macmode =
  1139. (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
  1140. WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
  1141. /* signal back up to cfg80211 layer */
  1142. prism2_connect_result(wlandev, P80211ENUM_truth_false);
  1143. /* Get the ball rolling on the comms quality stuff */
  1144. prism2sta_commsqual_defer(&hw->commsqual_bh);
  1145. }
  1146. break;
  1147. case HFA384x_LINK_DISCONNECTED:
  1148. /* This one indicates that our association is gone. We've
  1149. * lost connection with the AP and/or been disassociated.
  1150. * This indicates that the MAC has completely cleared it's
  1151. * associated state. We * should send a deauth indication
  1152. * (implying disassoc) up * to the MLME.
  1153. * Response:
  1154. * Indicate Deauthentication
  1155. * Block Transmits, Ignore receives of data frames
  1156. */
  1157. if (wlandev->netdev->type == ARPHRD_ETHER)
  1158. netdev_info(wlandev->netdev,
  1159. "linkstatus=DISCONNECTED (unhandled)\n");
  1160. wlandev->macmode = WLAN_MACMODE_NONE;
  1161. netif_carrier_off(wlandev->netdev);
  1162. /* signal back up to cfg80211 layer */
  1163. prism2_disconnected(wlandev);
  1164. break;
  1165. case HFA384x_LINK_AP_CHANGE:
  1166. /* This one indicates that the MAC has decided to and
  1167. * successfully completed a change to another AP. We
  1168. * should probably implement a reassociation indication
  1169. * in response to this one. I'm thinking that the the
  1170. * p80211 layer needs to be notified in case of
  1171. * buffering/queueing issues. User mode also needs to be
  1172. * notified so that any BSS dependent elements can be
  1173. * updated.
  1174. * associated state. We * should send a deauth indication
  1175. * (implying disassoc) up * to the MLME.
  1176. * Response:
  1177. * Indicate Reassociation
  1178. * Enable Transmits, Receives and pass up data frames
  1179. */
  1180. netdev_info(wlandev->netdev, "linkstatus=AP_CHANGE\n");
  1181. result = hfa384x_drvr_getconfig(hw,
  1182. HFA384x_RID_CURRENTBSSID,
  1183. wlandev->bssid, WLAN_BSSID_LEN);
  1184. if (result) {
  1185. pr_debug("getconfig(0x%02x) failed, result = %d\n",
  1186. HFA384x_RID_CURRENTBSSID, result);
  1187. return;
  1188. }
  1189. result = hfa384x_drvr_getconfig(hw,
  1190. HFA384x_RID_CURRENTSSID,
  1191. &ssid, sizeof(ssid));
  1192. if (result) {
  1193. pr_debug("getconfig(0x%02x) failed, result = %d\n",
  1194. HFA384x_RID_CURRENTSSID, result);
  1195. return;
  1196. }
  1197. prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *) &ssid,
  1198. (p80211pstrd_t *) &wlandev->ssid);
  1199. hw->link_status = HFA384x_LINK_CONNECTED;
  1200. netif_carrier_on(wlandev->netdev);
  1201. /* signal back up to cfg80211 layer */
  1202. prism2_roamed(wlandev);
  1203. break;
  1204. case HFA384x_LINK_AP_OUTOFRANGE:
  1205. /* This one indicates that the MAC has decided that the
  1206. * AP is out of range, but hasn't found a better candidate
  1207. * so the MAC maintains its "associated" state in case
  1208. * we get back in range. We should block transmits and
  1209. * receives in this state. Do we need an indication here?
  1210. * Probably not since a polling user-mode element would
  1211. * get this status from from p2PortStatus(FD40). What about
  1212. * p80211?
  1213. * Response:
  1214. * Block Transmits, Ignore receives of data frames
  1215. */
  1216. netdev_info(wlandev->netdev, "linkstatus=AP_OUTOFRANGE (unhandled)\n");
  1217. netif_carrier_off(wlandev->netdev);
  1218. break;
  1219. case HFA384x_LINK_AP_INRANGE:
  1220. /* This one indicates that the MAC has decided that the
  1221. * AP is back in range. We continue working with our
  1222. * existing association.
  1223. * Response:
  1224. * Enable Transmits, Receives and pass up data frames
  1225. */
  1226. netdev_info(wlandev->netdev, "linkstatus=AP_INRANGE\n");
  1227. hw->link_status = HFA384x_LINK_CONNECTED;
  1228. netif_carrier_on(wlandev->netdev);
  1229. break;
  1230. case HFA384x_LINK_ASSOCFAIL:
  1231. /* This one is actually a peer to CONNECTED. We've
  1232. * requested a join for a given SSID and optionally BSSID.
  1233. * We can use this one to indicate authentication and
  1234. * association failures. The trick is going to be
  1235. * 1) identifying the failure, and 2) state management.
  1236. * Response:
  1237. * Disable Transmits, Ignore receives of data frames
  1238. */
  1239. if (hw->join_ap && --hw->join_retries > 0) {
  1240. hfa384x_JoinRequest_data_t joinreq;
  1241. joinreq = hw->joinreq;
  1242. /* Send the join request */
  1243. hfa384x_drvr_setconfig(hw,
  1244. HFA384x_RID_JOINREQUEST,
  1245. &joinreq,
  1246. HFA384x_RID_JOINREQUEST_LEN);
  1247. netdev_info(wlandev->netdev,
  1248. "linkstatus=ASSOCFAIL (re-submitting join)\n");
  1249. } else {
  1250. netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (unhandled)\n");
  1251. }
  1252. netif_carrier_off(wlandev->netdev);
  1253. /* signal back up to cfg80211 layer */
  1254. prism2_connect_result(wlandev, P80211ENUM_truth_true);
  1255. break;
  1256. default:
  1257. /* This is bad, IO port problems? */
  1258. netdev_warn(wlandev->netdev,
  1259. "unknown linkstatus=0x%02x\n", hw->link_status);
  1260. return;
  1261. }
  1262. wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
  1263. }
  1264. /*----------------------------------------------------------------
  1265. * prism2sta_inf_linkstatus
  1266. *
  1267. * Handles the receipt of a Link Status info frame.
  1268. *
  1269. * Arguments:
  1270. * wlandev wlan device structure
  1271. * inf ptr to info frame (contents in hfa384x order)
  1272. *
  1273. * Returns:
  1274. * nothing
  1275. *
  1276. * Side effects:
  1277. *
  1278. * Call context:
  1279. * interrupt
  1280. ----------------------------------------------------------------*/
  1281. static void prism2sta_inf_linkstatus(wlandevice_t *wlandev,
  1282. hfa384x_InfFrame_t *inf)
  1283. {
  1284. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  1285. hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
  1286. schedule_work(&hw->link_bh);
  1287. }
  1288. /*----------------------------------------------------------------
  1289. * prism2sta_inf_assocstatus
  1290. *
  1291. * Handles the receipt of an Association Status info frame. Should
  1292. * be present in APs only.
  1293. *
  1294. * Arguments:
  1295. * wlandev wlan device structure
  1296. * inf ptr to info frame (contents in hfa384x order)
  1297. *
  1298. * Returns:
  1299. * nothing
  1300. *
  1301. * Side effects:
  1302. *
  1303. * Call context:
  1304. * interrupt
  1305. ----------------------------------------------------------------*/
  1306. static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
  1307. hfa384x_InfFrame_t *inf)
  1308. {
  1309. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  1310. hfa384x_AssocStatus_t rec;
  1311. int i;
  1312. memcpy(&rec, &inf->info.assocstatus, sizeof(rec));
  1313. rec.assocstatus = le16_to_cpu(rec.assocstatus);
  1314. rec.reason = le16_to_cpu(rec.reason);
  1315. /*
  1316. ** Find the address in the list of authenticated stations.
  1317. ** If it wasn't found, then this address has not been previously
  1318. ** authenticated and something weird has happened if this is
  1319. ** anything other than an "authentication failed" message.
  1320. ** If the address was found, then set the "associated" flag for
  1321. ** that station, based on whether the station is associating or
  1322. ** losing its association. Something weird has also happened
  1323. ** if we find the address in the list of authenticated stations
  1324. ** but we are getting an "authentication failed" message.
  1325. */
  1326. for (i = 0; i < hw->authlist.cnt; i++)
  1327. if (memcmp(rec.sta_addr, hw->authlist.addr[i], ETH_ALEN) == 0)
  1328. break;
  1329. if (i >= hw->authlist.cnt) {
  1330. if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
  1331. netdev_warn(wlandev->netdev,
  1332. "assocstatus info frame received for non-authenticated station.\n");
  1333. } else {
  1334. hw->authlist.assoc[i] =
  1335. (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
  1336. rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);
  1337. if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
  1338. netdev_warn(wlandev->netdev,
  1339. "authfail assocstatus info frame received for authenticated station.\n");
  1340. }
  1341. }
  1342. /*----------------------------------------------------------------
  1343. * prism2sta_inf_authreq
  1344. *
  1345. * Handles the receipt of an Authentication Request info frame. Should
  1346. * be present in APs only.
  1347. *
  1348. * Arguments:
  1349. * wlandev wlan device structure
  1350. * inf ptr to info frame (contents in hfa384x order)
  1351. *
  1352. * Returns:
  1353. * nothing
  1354. *
  1355. * Side effects:
  1356. *
  1357. * Call context:
  1358. * interrupt
  1359. *
  1360. ----------------------------------------------------------------*/
  1361. static void prism2sta_inf_authreq(wlandevice_t *wlandev,
  1362. hfa384x_InfFrame_t *inf)
  1363. {
  1364. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  1365. struct sk_buff *skb;
  1366. skb = dev_alloc_skb(sizeof(*inf));
  1367. if (skb) {
  1368. skb_put(skb, sizeof(*inf));
  1369. memcpy(skb->data, inf, sizeof(*inf));
  1370. skb_queue_tail(&hw->authq, skb);
  1371. schedule_work(&hw->link_bh);
  1372. }
  1373. }
  1374. static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
  1375. hfa384x_InfFrame_t *inf)
  1376. {
  1377. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  1378. hfa384x_authenticateStation_data_t rec;
  1379. int i, added, result, cnt;
  1380. u8 *addr;
  1381. /*
  1382. ** Build the AuthenticateStation record. Initialize it for denying
  1383. ** authentication.
  1384. */
  1385. memcpy(rec.address, inf->info.authreq.sta_addr, ETH_ALEN);
  1386. rec.status = P80211ENUM_status_unspec_failure;
  1387. /*
  1388. ** Authenticate based on the access mode.
  1389. */
  1390. switch (hw->accessmode) {
  1391. case WLAN_ACCESS_NONE:
  1392. /*
  1393. ** Deny all new authentications. However, if a station
  1394. ** is ALREADY authenticated, then accept it.
  1395. */
  1396. for (i = 0; i < hw->authlist.cnt; i++)
  1397. if (memcmp(rec.address, hw->authlist.addr[i],
  1398. ETH_ALEN) == 0) {
  1399. rec.status = P80211ENUM_status_successful;
  1400. break;
  1401. }
  1402. break;
  1403. case WLAN_ACCESS_ALL:
  1404. /*
  1405. ** Allow all authentications.
  1406. */
  1407. rec.status = P80211ENUM_status_successful;
  1408. break;
  1409. case WLAN_ACCESS_ALLOW:
  1410. /*
  1411. ** Only allow the authentication if the MAC address
  1412. ** is in the list of allowed addresses.
  1413. **
  1414. ** Since this is the interrupt handler, we may be here
  1415. ** while the access list is in the middle of being
  1416. ** updated. Choose the list which is currently okay.
  1417. ** See "prism2mib_priv_accessallow()" for details.
  1418. */
  1419. if (hw->allow.modify == 0) {
  1420. cnt = hw->allow.cnt;
  1421. addr = hw->allow.addr[0];
  1422. } else {
  1423. cnt = hw->allow.cnt1;
  1424. addr = hw->allow.addr1[0];
  1425. }
  1426. for (i = 0; i < cnt; i++, addr += ETH_ALEN)
  1427. if (memcmp(rec.address, addr, ETH_ALEN) == 0) {
  1428. rec.status = P80211ENUM_status_successful;
  1429. break;
  1430. }
  1431. break;
  1432. case WLAN_ACCESS_DENY:
  1433. /*
  1434. ** Allow the authentication UNLESS the MAC address is
  1435. ** in the list of denied addresses.
  1436. **
  1437. ** Since this is the interrupt handler, we may be here
  1438. ** while the access list is in the middle of being
  1439. ** updated. Choose the list which is currently okay.
  1440. ** See "prism2mib_priv_accessdeny()" for details.
  1441. */
  1442. if (hw->deny.modify == 0) {
  1443. cnt = hw->deny.cnt;
  1444. addr = hw->deny.addr[0];
  1445. } else {
  1446. cnt = hw->deny.cnt1;
  1447. addr = hw->deny.addr1[0];
  1448. }
  1449. rec.status = P80211ENUM_status_successful;
  1450. for (i = 0; i < cnt; i++, addr += ETH_ALEN)
  1451. if (memcmp(rec.address, addr, ETH_ALEN) == 0) {
  1452. rec.status = P80211ENUM_status_unspec_failure;
  1453. break;
  1454. }
  1455. break;
  1456. }
  1457. /*
  1458. ** If the authentication is okay, then add the MAC address to the
  1459. ** list of authenticated stations. Don't add the address if it
  1460. ** is already in the list. (802.11b does not seem to disallow
  1461. ** a station from issuing an authentication request when the
  1462. ** station is already authenticated. Does this sort of thing
  1463. ** ever happen? We might as well do the check just in case.)
  1464. */
  1465. added = 0;
  1466. if (rec.status == P80211ENUM_status_successful) {
  1467. for (i = 0; i < hw->authlist.cnt; i++)
  1468. if (memcmp(rec.address, hw->authlist.addr[i], ETH_ALEN)
  1469. == 0)
  1470. break;
  1471. if (i >= hw->authlist.cnt) {
  1472. if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
  1473. rec.status = P80211ENUM_status_ap_full;
  1474. } else {
  1475. memcpy(hw->authlist.addr[hw->authlist.cnt],
  1476. rec.address, ETH_ALEN);
  1477. hw->authlist.cnt++;
  1478. added = 1;
  1479. }
  1480. }
  1481. }
  1482. /*
  1483. ** Send back the results of the authentication. If this doesn't work,
  1484. ** then make sure to remove the address from the authenticated list if
  1485. ** it was added.
  1486. */
  1487. rec.status = cpu_to_le16(rec.status);
  1488. rec.algorithm = inf->info.authreq.algorithm;
  1489. result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
  1490. &rec, sizeof(rec));
  1491. if (result) {
  1492. if (added)
  1493. hw->authlist.cnt--;
  1494. netdev_err(wlandev->netdev,
  1495. "setconfig(authenticatestation) failed, result=%d\n",
  1496. result);
  1497. }
  1498. }
  1499. /*----------------------------------------------------------------
  1500. * prism2sta_inf_psusercnt
  1501. *
  1502. * Handles the receipt of a PowerSaveUserCount info frame. Should
  1503. * be present in APs only.
  1504. *
  1505. * Arguments:
  1506. * wlandev wlan device structure
  1507. * inf ptr to info frame (contents in hfa384x order)
  1508. *
  1509. * Returns:
  1510. * nothing
  1511. *
  1512. * Side effects:
  1513. *
  1514. * Call context:
  1515. * interrupt
  1516. ----------------------------------------------------------------*/
  1517. static void prism2sta_inf_psusercnt(wlandevice_t *wlandev,
  1518. hfa384x_InfFrame_t *inf)
  1519. {
  1520. hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
  1521. hw->psusercount = le16_to_cpu(inf->info.psusercnt.usercnt);
  1522. }
  1523. /*----------------------------------------------------------------
  1524. * prism2sta_ev_info
  1525. *
  1526. * Handles the Info event.
  1527. *
  1528. * Arguments:
  1529. * wlandev wlan device structure
  1530. * inf ptr to a generic info frame
  1531. *
  1532. * Returns:
  1533. * nothing
  1534. *
  1535. * Side effects:
  1536. *
  1537. * Call context:
  1538. * interrupt
  1539. ----------------------------------------------------------------*/
  1540. void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
  1541. {
  1542. inf->infotype = le16_to_cpu(inf->infotype);
  1543. /* Dispatch */
  1544. switch (inf->infotype) {
  1545. case HFA384x_IT_HANDOVERADDR:
  1546. prism2sta_inf_handover(wlandev, inf);
  1547. break;
  1548. case HFA384x_IT_COMMTALLIES:
  1549. prism2sta_inf_tallies(wlandev, inf);
  1550. break;
  1551. case HFA384x_IT_HOSTSCANRESULTS:
  1552. prism2sta_inf_hostscanresults(wlandev, inf);
  1553. break;
  1554. case HFA384x_IT_SCANRESULTS:
  1555. prism2sta_inf_scanresults(wlandev, inf);
  1556. break;
  1557. case HFA384x_IT_CHINFORESULTS:
  1558. prism2sta_inf_chinforesults(wlandev, inf);
  1559. break;
  1560. case HFA384x_IT_LINKSTATUS:
  1561. prism2sta_inf_linkstatus(wlandev, inf);
  1562. break;
  1563. case HFA384x_IT_ASSOCSTATUS:
  1564. prism2sta_inf_assocstatus(wlandev, inf);
  1565. break;
  1566. case HFA384x_IT_AUTHREQ:
  1567. prism2sta_inf_authreq(wlandev, inf);
  1568. break;
  1569. case HFA384x_IT_PSUSERCNT:
  1570. prism2sta_inf_psusercnt(wlandev, inf);
  1571. break;
  1572. case HFA384x_IT_KEYIDCHANGED:
  1573. netdev_warn(wlandev->netdev, "Unhandled IT_KEYIDCHANGED\n");
  1574. break;
  1575. case HFA384x_IT_ASSOCREQ:
  1576. netdev_warn(wlandev->netdev, "Unhandled IT_ASSOCREQ\n");
  1577. break;
  1578. case HFA384x_IT_MICFAILURE:
  1579. netdev_warn(wlandev->netdev, "Unhandled IT_MICFAILURE\n");
  1580. break;
  1581. default:
  1582. netdev_warn(wlandev->netdev,
  1583. "Unknown info type=0x%02x\n", inf->infotype);
  1584. break;
  1585. }
  1586. }
  1587. /*----------------------------------------------------------------
  1588. * prism2sta_ev_txexc
  1589. *
  1590. * Handles the TxExc event. A Transmit Exception event indicates
  1591. * that the MAC's TX process was unsuccessful - so the packet did
  1592. * not get transmitted.
  1593. *
  1594. * Arguments:
  1595. * wlandev wlan device structure
  1596. * status tx frame status word
  1597. *
  1598. * Returns:
  1599. * nothing
  1600. *
  1601. * Side effects:
  1602. *
  1603. * Call context:
  1604. * interrupt
  1605. ----------------------------------------------------------------*/
  1606. void prism2sta_ev_txexc(wlandevice_t *wlandev, u16 status)
  1607. {
  1608. pr_debug("TxExc status=0x%x.\n", status);
  1609. }
  1610. /*----------------------------------------------------------------
  1611. * prism2sta_ev_tx
  1612. *
  1613. * Handles the Tx event.
  1614. *
  1615. * Arguments:
  1616. * wlandev wlan device structure
  1617. * status tx frame status word
  1618. * Returns:
  1619. * nothing
  1620. *
  1621. * Side effects:
  1622. *
  1623. * Call context:
  1624. * interrupt
  1625. ----------------------------------------------------------------*/
  1626. void prism2sta_ev_tx(wlandevice_t *wlandev, u16 status)
  1627. {
  1628. pr_debug("Tx Complete, status=0x%04x\n", status);
  1629. /* update linux network stats */
  1630. wlandev->netdev->stats.tx_packets++;
  1631. }
  1632. /*----------------------------------------------------------------
  1633. * prism2sta_ev_rx
  1634. *
  1635. * Handles the Rx event.
  1636. *
  1637. * Arguments:
  1638. * wlandev wlan device structure
  1639. *
  1640. * Returns:
  1641. * nothing
  1642. *
  1643. * Side effects:
  1644. *
  1645. * Call context:
  1646. * interrupt
  1647. ----------------------------------------------------------------*/
  1648. void prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
  1649. {
  1650. p80211netdev_rx(wlandev, skb);
  1651. }
  1652. /*----------------------------------------------------------------
  1653. * prism2sta_ev_alloc
  1654. *
  1655. * Handles the Alloc event.
  1656. *
  1657. * Arguments:
  1658. * wlandev wlan device structure
  1659. *
  1660. * Returns:
  1661. * nothing
  1662. *
  1663. * Side effects:
  1664. *
  1665. * Call context:
  1666. * interrupt
  1667. ----------------------------------------------------------------*/
  1668. void prism2sta_ev_alloc(wlandevice_t *wlandev)
  1669. {
  1670. netif_wake_queue(wlandev->netdev);
  1671. }
  1672. /*----------------------------------------------------------------
  1673. * create_wlan
  1674. *
  1675. * Called at module init time. This creates the wlandevice_t structure
  1676. * and initializes it with relevant bits.
  1677. *
  1678. * Arguments:
  1679. * none
  1680. *
  1681. * Returns:
  1682. * the created wlandevice_t structure.
  1683. *
  1684. * Side effects:
  1685. * also allocates the priv/hw structures.
  1686. *
  1687. * Call context:
  1688. * process thread
  1689. *
  1690. ----------------------------------------------------------------*/
  1691. static wlandevice_t *create_wlan(void)
  1692. {
  1693. wlandevice_t *wlandev = NULL;
  1694. hfa384x_t *hw = NULL;
  1695. /* Alloc our structures */
  1696. wlandev = kzalloc(sizeof(wlandevice_t), GFP_KERNEL);
  1697. hw = kzalloc(sizeof(hfa384x_t), GFP_KERNEL);
  1698. if (!wlandev || !hw) {
  1699. pr_err("%s: Memory allocation failure.\n", dev_info);
  1700. kfree(wlandev);
  1701. kfree(hw);
  1702. return NULL;
  1703. }
  1704. /* Initialize the network device object. */
  1705. wlandev->nsdname = dev_info;
  1706. wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
  1707. wlandev->priv = hw;
  1708. wlandev->open = prism2sta_open;
  1709. wlandev->close = prism2sta_close;
  1710. wlandev->reset = prism2sta_reset;
  1711. wlandev->txframe = prism2sta_txframe;
  1712. wlandev->mlmerequest = prism2sta_mlmerequest;
  1713. wlandev->set_multicast_list = prism2sta_setmulticast;
  1714. wlandev->tx_timeout = hfa384x_tx_timeout;
  1715. wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT | P80211_NSDCAP_AUTOJOIN;
  1716. /* Initialize the device private data structure. */
  1717. hw->dot11_desired_bss_type = 1;
  1718. return wlandev;
  1719. }
  1720. void prism2sta_commsqual_defer(struct work_struct *data)
  1721. {
  1722. hfa384x_t *hw = container_of(data, struct hfa384x, commsqual_bh);
  1723. wlandevice_t *wlandev = hw->wlandev;
  1724. hfa384x_bytestr32_t ssid;
  1725. struct p80211msg_dot11req_mibget msg;
  1726. p80211item_uint32_t *mibitem = (p80211item_uint32_t *)
  1727. &msg.mibattribute.data;
  1728. int result = 0;
  1729. if (hw->wlandev->hwremoved)
  1730. return;
  1731. /* we don't care if we're in AP mode */
  1732. if ((wlandev->macmode == WLAN_MACMODE_NONE) ||
  1733. (wlandev->macmode == WLAN_MACMODE_ESS_AP)) {
  1734. return;
  1735. }
  1736. /* It only makes sense to poll these in non-IBSS */
  1737. if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
  1738. result = hfa384x_drvr_getconfig(
  1739. hw, HFA384x_RID_DBMCOMMSQUALITY,
  1740. &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN);
  1741. if (result) {
  1742. netdev_err(wlandev->netdev, "error fetching commsqual\n");
  1743. return;
  1744. }
  1745. pr_debug("commsqual %d %d %d\n",
  1746. le16_to_cpu(hw->qual.CQ_currBSS),
  1747. le16_to_cpu(hw->qual.ASL_currBSS),
  1748. le16_to_cpu(hw->qual.ANL_currFC));
  1749. }
  1750. /* Get the signal rate */
  1751. msg.msgcode = DIDmsg_dot11req_mibget;
  1752. mibitem->did = DIDmib_p2_p2MAC_p2CurrentTxRate;
  1753. result = p80211req_dorequest(wlandev, (u8 *) &msg);
  1754. if (result) {
  1755. pr_debug("get signal rate failed, result = %d\n",
  1756. result);
  1757. return;
  1758. }
  1759. switch (mibitem->data) {
  1760. case HFA384x_RATEBIT_1:
  1761. hw->txrate = 10;
  1762. break;
  1763. case HFA384x_RATEBIT_2:
  1764. hw->txrate = 20;
  1765. break;
  1766. case HFA384x_RATEBIT_5dot5:
  1767. hw->txrate = 55;
  1768. break;
  1769. case HFA384x_RATEBIT_11:
  1770. hw->txrate = 110;
  1771. break;
  1772. default:
  1773. pr_debug("Bad ratebit (%d)\n", mibitem->data);
  1774. }
  1775. /* Lastly, we need to make sure the BSSID didn't change on us */
  1776. result = hfa384x_drvr_getconfig(hw,
  1777. HFA384x_RID_CURRENTBSSID,
  1778. wlandev->bssid, WLAN_BSSID_LEN);
  1779. if (result) {
  1780. pr_debug("getconfig(0x%02x) failed, result = %d\n",
  1781. HFA384x_RID_CURRENTBSSID, result);
  1782. return;
  1783. }
  1784. result = hfa384x_drvr_getconfig(hw,
  1785. HFA384x_RID_CURRENTSSID,
  1786. &ssid, sizeof(ssid));
  1787. if (result) {
  1788. pr_debug("getconfig(0x%02x) failed, result = %d\n",
  1789. HFA384x_RID_CURRENTSSID, result);
  1790. return;
  1791. }
  1792. prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *) &ssid,
  1793. (p80211pstrd_t *) &wlandev->ssid);
  1794. /* Reschedule timer */
  1795. mod_timer(&hw->commsqual_timer, jiffies + HZ);
  1796. }
  1797. void prism2sta_commsqual_timer(unsigned long data)
  1798. {
  1799. hfa384x_t *hw = (hfa384x_t *) data;
  1800. schedule_work(&hw->commsqual_bh);
  1801. }