prism2sta.c 54 KB

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