prism2sta.c 53 KB

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