wmi.c 95 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653
  1. /*
  2. * Copyright (c) 2004-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <linux/ip.h>
  17. #include "core.h"
  18. #include "debug.h"
  19. #include "testmode.h"
  20. #include "../regd.h"
  21. #include "../regd_common.h"
  22. static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx);
  23. static const s32 wmi_rate_tbl[][2] = {
  24. /* {W/O SGI, with SGI} */
  25. {1000, 1000},
  26. {2000, 2000},
  27. {5500, 5500},
  28. {11000, 11000},
  29. {6000, 6000},
  30. {9000, 9000},
  31. {12000, 12000},
  32. {18000, 18000},
  33. {24000, 24000},
  34. {36000, 36000},
  35. {48000, 48000},
  36. {54000, 54000},
  37. {6500, 7200},
  38. {13000, 14400},
  39. {19500, 21700},
  40. {26000, 28900},
  41. {39000, 43300},
  42. {52000, 57800},
  43. {58500, 65000},
  44. {65000, 72200},
  45. {13500, 15000},
  46. {27000, 30000},
  47. {40500, 45000},
  48. {54000, 60000},
  49. {81000, 90000},
  50. {108000, 120000},
  51. {121500, 135000},
  52. {135000, 150000},
  53. {0, 0}
  54. };
  55. /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
  56. static const u8 up_to_ac[] = {
  57. WMM_AC_BE,
  58. WMM_AC_BK,
  59. WMM_AC_BK,
  60. WMM_AC_BE,
  61. WMM_AC_VI,
  62. WMM_AC_VI,
  63. WMM_AC_VO,
  64. WMM_AC_VO,
  65. };
  66. void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id)
  67. {
  68. if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX))
  69. return;
  70. wmi->ep_id = ep_id;
  71. }
  72. enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi)
  73. {
  74. return wmi->ep_id;
  75. }
  76. struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx)
  77. {
  78. struct ath6kl_vif *vif, *found = NULL;
  79. if (WARN_ON(if_idx > (ar->vif_max - 1)))
  80. return NULL;
  81. /* FIXME: Locking */
  82. spin_lock_bh(&ar->list_lock);
  83. list_for_each_entry(vif, &ar->vif_list, list) {
  84. if (vif->fw_vif_idx == if_idx) {
  85. found = vif;
  86. break;
  87. }
  88. }
  89. spin_unlock_bh(&ar->list_lock);
  90. return found;
  91. }
  92. /* Performs DIX to 802.3 encapsulation for transmit packets.
  93. * Assumes the entire DIX header is contigous and that there is
  94. * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
  95. */
  96. int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb)
  97. {
  98. struct ath6kl_llc_snap_hdr *llc_hdr;
  99. struct ethhdr *eth_hdr;
  100. size_t new_len;
  101. __be16 type;
  102. u8 *datap;
  103. u16 size;
  104. if (WARN_ON(skb == NULL))
  105. return -EINVAL;
  106. size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr);
  107. if (skb_headroom(skb) < size)
  108. return -ENOMEM;
  109. eth_hdr = (struct ethhdr *) skb->data;
  110. type = eth_hdr->h_proto;
  111. if (!is_ethertype(be16_to_cpu(type))) {
  112. ath6kl_dbg(ATH6KL_DBG_WMI,
  113. "%s: pkt is already in 802.3 format\n", __func__);
  114. return 0;
  115. }
  116. new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr);
  117. skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr));
  118. datap = skb->data;
  119. eth_hdr->h_proto = cpu_to_be16(new_len);
  120. memcpy(datap, eth_hdr, sizeof(*eth_hdr));
  121. llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr));
  122. llc_hdr->dsap = 0xAA;
  123. llc_hdr->ssap = 0xAA;
  124. llc_hdr->cntl = 0x03;
  125. llc_hdr->org_code[0] = 0x0;
  126. llc_hdr->org_code[1] = 0x0;
  127. llc_hdr->org_code[2] = 0x0;
  128. llc_hdr->eth_type = type;
  129. return 0;
  130. }
  131. static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb,
  132. u8 *version, void *tx_meta_info)
  133. {
  134. struct wmi_tx_meta_v1 *v1;
  135. struct wmi_tx_meta_v2 *v2;
  136. if (WARN_ON(skb == NULL || version == NULL))
  137. return -EINVAL;
  138. switch (*version) {
  139. case WMI_META_VERSION_1:
  140. skb_push(skb, WMI_MAX_TX_META_SZ);
  141. v1 = (struct wmi_tx_meta_v1 *) skb->data;
  142. v1->pkt_id = 0;
  143. v1->rate_plcy_id = 0;
  144. *version = WMI_META_VERSION_1;
  145. break;
  146. case WMI_META_VERSION_2:
  147. skb_push(skb, WMI_MAX_TX_META_SZ);
  148. v2 = (struct wmi_tx_meta_v2 *) skb->data;
  149. memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info,
  150. sizeof(struct wmi_tx_meta_v2));
  151. break;
  152. }
  153. return 0;
  154. }
  155. int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb,
  156. u8 msg_type, u32 flags,
  157. enum wmi_data_hdr_data_type data_type,
  158. u8 meta_ver, void *tx_meta_info, u8 if_idx)
  159. {
  160. struct wmi_data_hdr *data_hdr;
  161. int ret;
  162. if (WARN_ON(skb == NULL || (if_idx > wmi->parent_dev->vif_max - 1)))
  163. return -EINVAL;
  164. if (tx_meta_info) {
  165. ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info);
  166. if (ret)
  167. return ret;
  168. }
  169. skb_push(skb, sizeof(struct wmi_data_hdr));
  170. data_hdr = (struct wmi_data_hdr *)skb->data;
  171. memset(data_hdr, 0, sizeof(struct wmi_data_hdr));
  172. data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT;
  173. data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT;
  174. if (flags & WMI_DATA_HDR_FLAGS_MORE)
  175. data_hdr->info |= WMI_DATA_HDR_MORE;
  176. if (flags & WMI_DATA_HDR_FLAGS_EOSP)
  177. data_hdr->info3 |= cpu_to_le16(WMI_DATA_HDR_EOSP);
  178. data_hdr->info2 |= cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT);
  179. data_hdr->info3 |= cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
  180. return 0;
  181. }
  182. u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri)
  183. {
  184. struct iphdr *ip_hdr = (struct iphdr *) pkt;
  185. u8 ip_pri;
  186. /*
  187. * Determine IPTOS priority
  188. *
  189. * IP-TOS - 8bits
  190. * : DSCP(6-bits) ECN(2-bits)
  191. * : DSCP - P2 P1 P0 X X X
  192. * where (P2 P1 P0) form 802.1D
  193. */
  194. ip_pri = ip_hdr->tos >> 5;
  195. ip_pri &= 0x7;
  196. if ((layer2_pri & 0x7) > ip_pri)
  197. return (u8) layer2_pri & 0x7;
  198. else
  199. return ip_pri;
  200. }
  201. u8 ath6kl_wmi_get_traffic_class(u8 user_priority)
  202. {
  203. return up_to_ac[user_priority & 0x7];
  204. }
  205. int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx,
  206. struct sk_buff *skb,
  207. u32 layer2_priority, bool wmm_enabled,
  208. u8 *ac)
  209. {
  210. struct wmi_data_hdr *data_hdr;
  211. struct ath6kl_llc_snap_hdr *llc_hdr;
  212. struct wmi_create_pstream_cmd cmd;
  213. u32 meta_size, hdr_size;
  214. u16 ip_type = IP_ETHERTYPE;
  215. u8 stream_exist, usr_pri;
  216. u8 traffic_class = WMM_AC_BE;
  217. u8 *datap;
  218. if (WARN_ON(skb == NULL))
  219. return -EINVAL;
  220. datap = skb->data;
  221. data_hdr = (struct wmi_data_hdr *) datap;
  222. meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) &
  223. WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0;
  224. if (!wmm_enabled) {
  225. /* If WMM is disabled all traffic goes as BE traffic */
  226. usr_pri = 0;
  227. } else {
  228. hdr_size = sizeof(struct ethhdr);
  229. llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap +
  230. sizeof(struct
  231. wmi_data_hdr) +
  232. meta_size + hdr_size);
  233. if (llc_hdr->eth_type == htons(ip_type)) {
  234. /*
  235. * Extract the endpoint info from the TOS field
  236. * in the IP header.
  237. */
  238. usr_pri =
  239. ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) +
  240. sizeof(struct ath6kl_llc_snap_hdr),
  241. layer2_priority);
  242. } else
  243. usr_pri = layer2_priority & 0x7;
  244. }
  245. /*
  246. * workaround for WMM S5
  247. *
  248. * FIXME: wmi->traffic_class is always 100 so this test doesn't
  249. * make sense
  250. */
  251. if ((wmi->traffic_class == WMM_AC_VI) &&
  252. ((usr_pri == 5) || (usr_pri == 4)))
  253. usr_pri = 1;
  254. /* Convert user priority to traffic class */
  255. traffic_class = up_to_ac[usr_pri & 0x7];
  256. wmi_data_hdr_set_up(data_hdr, usr_pri);
  257. spin_lock_bh(&wmi->lock);
  258. stream_exist = wmi->fat_pipe_exist;
  259. spin_unlock_bh(&wmi->lock);
  260. if (!(stream_exist & (1 << traffic_class))) {
  261. memset(&cmd, 0, sizeof(cmd));
  262. cmd.traffic_class = traffic_class;
  263. cmd.user_pri = usr_pri;
  264. cmd.inactivity_int =
  265. cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT);
  266. /* Implicit streams are created with TSID 0xFF */
  267. cmd.tsid = WMI_IMPLICIT_PSTREAM;
  268. ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd);
  269. }
  270. *ac = traffic_class;
  271. return 0;
  272. }
  273. int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb)
  274. {
  275. struct ieee80211_hdr_3addr *pwh, wh;
  276. struct ath6kl_llc_snap_hdr *llc_hdr;
  277. struct ethhdr eth_hdr;
  278. u32 hdr_size;
  279. u8 *datap;
  280. __le16 sub_type;
  281. if (WARN_ON(skb == NULL))
  282. return -EINVAL;
  283. datap = skb->data;
  284. pwh = (struct ieee80211_hdr_3addr *) datap;
  285. sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE);
  286. memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr));
  287. /* Strip off the 802.11 header */
  288. if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
  289. hdr_size = roundup(sizeof(struct ieee80211_qos_hdr),
  290. sizeof(u32));
  291. skb_pull(skb, hdr_size);
  292. } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA))
  293. skb_pull(skb, sizeof(struct ieee80211_hdr_3addr));
  294. datap = skb->data;
  295. llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap);
  296. memset(&eth_hdr, 0, sizeof(eth_hdr));
  297. eth_hdr.h_proto = llc_hdr->eth_type;
  298. switch ((le16_to_cpu(wh.frame_control)) &
  299. (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
  300. case 0:
  301. memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
  302. memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
  303. break;
  304. case IEEE80211_FCTL_TODS:
  305. memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN);
  306. memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
  307. break;
  308. case IEEE80211_FCTL_FROMDS:
  309. memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
  310. memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN);
  311. break;
  312. case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
  313. break;
  314. }
  315. skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
  316. skb_push(skb, sizeof(eth_hdr));
  317. datap = skb->data;
  318. memcpy(datap, &eth_hdr, sizeof(eth_hdr));
  319. return 0;
  320. }
  321. /*
  322. * Performs 802.3 to DIX encapsulation for received packets.
  323. * Assumes the entire 802.3 header is contigous.
  324. */
  325. int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb)
  326. {
  327. struct ath6kl_llc_snap_hdr *llc_hdr;
  328. struct ethhdr eth_hdr;
  329. u8 *datap;
  330. if (WARN_ON(skb == NULL))
  331. return -EINVAL;
  332. datap = skb->data;
  333. memcpy(&eth_hdr, datap, sizeof(eth_hdr));
  334. llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr));
  335. eth_hdr.h_proto = llc_hdr->eth_type;
  336. skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
  337. datap = skb->data;
  338. memcpy(datap, &eth_hdr, sizeof(eth_hdr));
  339. return 0;
  340. }
  341. static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)
  342. {
  343. struct tx_complete_msg_v1 *msg_v1;
  344. struct wmi_tx_complete_event *evt;
  345. int index;
  346. u16 size;
  347. evt = (struct wmi_tx_complete_event *) datap;
  348. ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n",
  349. evt->num_msg, evt->msg_len, evt->msg_type);
  350. for (index = 0; index < evt->num_msg; index++) {
  351. size = sizeof(struct wmi_tx_complete_event) +
  352. (index * sizeof(struct tx_complete_msg_v1));
  353. msg_v1 = (struct tx_complete_msg_v1 *)(datap + size);
  354. ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n",
  355. msg_v1->status, msg_v1->pkt_id,
  356. msg_v1->rate_idx, msg_v1->ack_failures);
  357. }
  358. return 0;
  359. }
  360. static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap,
  361. int len, struct ath6kl_vif *vif)
  362. {
  363. struct wmi_remain_on_chnl_event *ev;
  364. u32 freq;
  365. u32 dur;
  366. struct ieee80211_channel *chan;
  367. struct ath6kl *ar = wmi->parent_dev;
  368. u32 id;
  369. if (len < sizeof(*ev))
  370. return -EINVAL;
  371. ev = (struct wmi_remain_on_chnl_event *) datap;
  372. freq = le32_to_cpu(ev->freq);
  373. dur = le32_to_cpu(ev->duration);
  374. ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n",
  375. freq, dur);
  376. chan = ieee80211_get_channel(ar->wiphy, freq);
  377. if (!chan) {
  378. ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel "
  379. "(freq=%u)\n", freq);
  380. return -EINVAL;
  381. }
  382. id = vif->last_roc_id;
  383. cfg80211_ready_on_channel(vif->ndev, id, chan, NL80211_CHAN_NO_HT,
  384. dur, GFP_ATOMIC);
  385. return 0;
  386. }
  387. static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi,
  388. u8 *datap, int len,
  389. struct ath6kl_vif *vif)
  390. {
  391. struct wmi_cancel_remain_on_chnl_event *ev;
  392. u32 freq;
  393. u32 dur;
  394. struct ieee80211_channel *chan;
  395. struct ath6kl *ar = wmi->parent_dev;
  396. u32 id;
  397. if (len < sizeof(*ev))
  398. return -EINVAL;
  399. ev = (struct wmi_cancel_remain_on_chnl_event *) datap;
  400. freq = le32_to_cpu(ev->freq);
  401. dur = le32_to_cpu(ev->duration);
  402. ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u "
  403. "status=%u\n", freq, dur, ev->status);
  404. chan = ieee80211_get_channel(ar->wiphy, freq);
  405. if (!chan) {
  406. ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown "
  407. "channel (freq=%u)\n", freq);
  408. return -EINVAL;
  409. }
  410. if (vif->last_cancel_roc_id &&
  411. vif->last_cancel_roc_id + 1 == vif->last_roc_id)
  412. id = vif->last_cancel_roc_id; /* event for cancel command */
  413. else
  414. id = vif->last_roc_id; /* timeout on uncanceled r-o-c */
  415. vif->last_cancel_roc_id = 0;
  416. cfg80211_remain_on_channel_expired(vif->ndev, id, chan,
  417. NL80211_CHAN_NO_HT, GFP_ATOMIC);
  418. return 0;
  419. }
  420. static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len,
  421. struct ath6kl_vif *vif)
  422. {
  423. struct wmi_tx_status_event *ev;
  424. u32 id;
  425. if (len < sizeof(*ev))
  426. return -EINVAL;
  427. ev = (struct wmi_tx_status_event *) datap;
  428. id = le32_to_cpu(ev->id);
  429. ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n",
  430. id, ev->ack_status);
  431. if (wmi->last_mgmt_tx_frame) {
  432. cfg80211_mgmt_tx_status(vif->ndev, id,
  433. wmi->last_mgmt_tx_frame,
  434. wmi->last_mgmt_tx_frame_len,
  435. !!ev->ack_status, GFP_ATOMIC);
  436. kfree(wmi->last_mgmt_tx_frame);
  437. wmi->last_mgmt_tx_frame = NULL;
  438. wmi->last_mgmt_tx_frame_len = 0;
  439. }
  440. return 0;
  441. }
  442. static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len,
  443. struct ath6kl_vif *vif)
  444. {
  445. struct wmi_p2p_rx_probe_req_event *ev;
  446. u32 freq;
  447. u16 dlen;
  448. if (len < sizeof(*ev))
  449. return -EINVAL;
  450. ev = (struct wmi_p2p_rx_probe_req_event *) datap;
  451. freq = le32_to_cpu(ev->freq);
  452. dlen = le16_to_cpu(ev->len);
  453. if (datap + len < ev->data + dlen) {
  454. ath6kl_err("invalid wmi_p2p_rx_probe_req_event: "
  455. "len=%d dlen=%u\n", len, dlen);
  456. return -EINVAL;
  457. }
  458. ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u "
  459. "probe_req_report=%d\n",
  460. dlen, freq, vif->probe_req_report);
  461. if (vif->probe_req_report || vif->nw_type == AP_NETWORK)
  462. cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC);
  463. return 0;
  464. }
  465. static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len)
  466. {
  467. struct wmi_p2p_capabilities_event *ev;
  468. u16 dlen;
  469. if (len < sizeof(*ev))
  470. return -EINVAL;
  471. ev = (struct wmi_p2p_capabilities_event *) datap;
  472. dlen = le16_to_cpu(ev->len);
  473. ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen);
  474. return 0;
  475. }
  476. static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len,
  477. struct ath6kl_vif *vif)
  478. {
  479. struct wmi_rx_action_event *ev;
  480. u32 freq;
  481. u16 dlen;
  482. if (len < sizeof(*ev))
  483. return -EINVAL;
  484. ev = (struct wmi_rx_action_event *) datap;
  485. freq = le32_to_cpu(ev->freq);
  486. dlen = le16_to_cpu(ev->len);
  487. if (datap + len < ev->data + dlen) {
  488. ath6kl_err("invalid wmi_rx_action_event: "
  489. "len=%d dlen=%u\n", len, dlen);
  490. return -EINVAL;
  491. }
  492. ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq);
  493. cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC);
  494. return 0;
  495. }
  496. static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len)
  497. {
  498. struct wmi_p2p_info_event *ev;
  499. u32 flags;
  500. u16 dlen;
  501. if (len < sizeof(*ev))
  502. return -EINVAL;
  503. ev = (struct wmi_p2p_info_event *) datap;
  504. flags = le32_to_cpu(ev->info_req_flags);
  505. dlen = le16_to_cpu(ev->len);
  506. ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen);
  507. if (flags & P2P_FLAG_CAPABILITIES_REQ) {
  508. struct wmi_p2p_capabilities *cap;
  509. if (dlen < sizeof(*cap))
  510. return -EINVAL;
  511. cap = (struct wmi_p2p_capabilities *) ev->data;
  512. ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n",
  513. cap->go_power_save);
  514. }
  515. if (flags & P2P_FLAG_MACADDR_REQ) {
  516. struct wmi_p2p_macaddr *mac;
  517. if (dlen < sizeof(*mac))
  518. return -EINVAL;
  519. mac = (struct wmi_p2p_macaddr *) ev->data;
  520. ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n",
  521. mac->mac_addr);
  522. }
  523. if (flags & P2P_FLAG_HMODEL_REQ) {
  524. struct wmi_p2p_hmodel *mod;
  525. if (dlen < sizeof(*mod))
  526. return -EINVAL;
  527. mod = (struct wmi_p2p_hmodel *) ev->data;
  528. ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n",
  529. mod->p2p_model,
  530. mod->p2p_model ? "host" : "firmware");
  531. }
  532. return 0;
  533. }
  534. static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size)
  535. {
  536. struct sk_buff *skb;
  537. skb = ath6kl_buf_alloc(size);
  538. if (!skb)
  539. return NULL;
  540. skb_put(skb, size);
  541. if (size)
  542. memset(skb->data, 0, size);
  543. return skb;
  544. }
  545. /* Send a "simple" wmi command -- one with no arguments */
  546. static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx,
  547. enum wmi_cmd_id cmd_id)
  548. {
  549. struct sk_buff *skb;
  550. int ret;
  551. skb = ath6kl_wmi_get_new_buf(0);
  552. if (!skb)
  553. return -ENOMEM;
  554. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG);
  555. return ret;
  556. }
  557. static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len)
  558. {
  559. struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap;
  560. if (len < sizeof(struct wmi_ready_event_2))
  561. return -EINVAL;
  562. ath6kl_ready_event(wmi->parent_dev, ev->mac_addr,
  563. le32_to_cpu(ev->sw_version),
  564. le32_to_cpu(ev->abi_version));
  565. return 0;
  566. }
  567. /*
  568. * Mechanism to modify the roaming behavior in the firmware. The lower rssi
  569. * at which the station has to roam can be passed with
  570. * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level
  571. * in dBm.
  572. */
  573. int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi)
  574. {
  575. struct sk_buff *skb;
  576. struct roam_ctrl_cmd *cmd;
  577. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  578. if (!skb)
  579. return -ENOMEM;
  580. cmd = (struct roam_ctrl_cmd *) skb->data;
  581. cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD);
  582. cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi +
  583. DEF_SCAN_FOR_ROAM_INTVL);
  584. cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi);
  585. cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR;
  586. cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS;
  587. ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
  588. NO_SYNC_WMIFLAG);
  589. return 0;
  590. }
  591. int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid)
  592. {
  593. struct sk_buff *skb;
  594. struct roam_ctrl_cmd *cmd;
  595. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  596. if (!skb)
  597. return -ENOMEM;
  598. cmd = (struct roam_ctrl_cmd *) skb->data;
  599. memset(cmd, 0, sizeof(*cmd));
  600. memcpy(cmd->info.bssid, bssid, ETH_ALEN);
  601. cmd->roam_ctrl = WMI_FORCE_ROAM;
  602. ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid);
  603. return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
  604. NO_SYNC_WMIFLAG);
  605. }
  606. int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode)
  607. {
  608. struct sk_buff *skb;
  609. struct roam_ctrl_cmd *cmd;
  610. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  611. if (!skb)
  612. return -ENOMEM;
  613. cmd = (struct roam_ctrl_cmd *) skb->data;
  614. memset(cmd, 0, sizeof(*cmd));
  615. cmd->info.roam_mode = mode;
  616. cmd->roam_ctrl = WMI_SET_ROAM_MODE;
  617. ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode);
  618. return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
  619. NO_SYNC_WMIFLAG);
  620. }
  621. static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len,
  622. struct ath6kl_vif *vif)
  623. {
  624. struct wmi_connect_event *ev;
  625. u8 *pie, *peie;
  626. if (len < sizeof(struct wmi_connect_event))
  627. return -EINVAL;
  628. ev = (struct wmi_connect_event *) datap;
  629. if (vif->nw_type == AP_NETWORK) {
  630. /* AP mode start/STA connected event */
  631. struct net_device *dev = vif->ndev;
  632. if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) {
  633. ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM "
  634. "(AP started)\n",
  635. __func__, le16_to_cpu(ev->u.ap_bss.ch),
  636. ev->u.ap_bss.bssid);
  637. ath6kl_connect_ap_mode_bss(
  638. vif, le16_to_cpu(ev->u.ap_bss.ch));
  639. } else {
  640. ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM "
  641. "auth=%u keymgmt=%u cipher=%u apsd_info=%u "
  642. "(STA connected)\n",
  643. __func__, ev->u.ap_sta.aid,
  644. ev->u.ap_sta.mac_addr,
  645. ev->u.ap_sta.auth,
  646. ev->u.ap_sta.keymgmt,
  647. le16_to_cpu(ev->u.ap_sta.cipher),
  648. ev->u.ap_sta.apsd_info);
  649. ath6kl_connect_ap_mode_sta(
  650. vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr,
  651. ev->u.ap_sta.keymgmt,
  652. le16_to_cpu(ev->u.ap_sta.cipher),
  653. ev->u.ap_sta.auth, ev->assoc_req_len,
  654. ev->assoc_info + ev->beacon_ie_len,
  655. ev->u.ap_sta.apsd_info);
  656. }
  657. return 0;
  658. }
  659. /* STA/IBSS mode connection event */
  660. ath6kl_dbg(ATH6KL_DBG_WMI,
  661. "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n",
  662. le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid,
  663. le16_to_cpu(ev->u.sta.listen_intvl),
  664. le16_to_cpu(ev->u.sta.beacon_intvl),
  665. le32_to_cpu(ev->u.sta.nw_type));
  666. /* Start of assoc rsp IEs */
  667. pie = ev->assoc_info + ev->beacon_ie_len +
  668. ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */
  669. /* End of assoc rsp IEs */
  670. peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len +
  671. ev->assoc_resp_len;
  672. while (pie < peie) {
  673. switch (*pie) {
  674. case WLAN_EID_VENDOR_SPECIFIC:
  675. if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 &&
  676. pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) {
  677. /* WMM OUT (00:50:F2) */
  678. if (pie[1] > 5
  679. && pie[6] == WMM_PARAM_OUI_SUBTYPE)
  680. wmi->is_wmm_enabled = true;
  681. }
  682. break;
  683. }
  684. if (wmi->is_wmm_enabled)
  685. break;
  686. pie += pie[1] + 2;
  687. }
  688. ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch),
  689. ev->u.sta.bssid,
  690. le16_to_cpu(ev->u.sta.listen_intvl),
  691. le16_to_cpu(ev->u.sta.beacon_intvl),
  692. le32_to_cpu(ev->u.sta.nw_type),
  693. ev->beacon_ie_len, ev->assoc_req_len,
  694. ev->assoc_resp_len, ev->assoc_info);
  695. return 0;
  696. }
  697. static struct country_code_to_enum_rd *
  698. ath6kl_regd_find_country(u16 countryCode)
  699. {
  700. int i;
  701. for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
  702. if (allCountries[i].countryCode == countryCode)
  703. return &allCountries[i];
  704. }
  705. return NULL;
  706. }
  707. static struct reg_dmn_pair_mapping *
  708. ath6kl_get_regpair(u16 regdmn)
  709. {
  710. int i;
  711. if (regdmn == NO_ENUMRD)
  712. return NULL;
  713. for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) {
  714. if (regDomainPairs[i].regDmnEnum == regdmn)
  715. return &regDomainPairs[i];
  716. }
  717. return NULL;
  718. }
  719. static struct country_code_to_enum_rd *
  720. ath6kl_regd_find_country_by_rd(u16 regdmn)
  721. {
  722. int i;
  723. for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
  724. if (allCountries[i].regDmnEnum == regdmn)
  725. return &allCountries[i];
  726. }
  727. return NULL;
  728. }
  729. static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
  730. {
  731. struct ath6kl_wmi_regdomain *ev;
  732. struct country_code_to_enum_rd *country = NULL;
  733. struct reg_dmn_pair_mapping *regpair = NULL;
  734. char alpha2[2];
  735. u32 reg_code;
  736. ev = (struct ath6kl_wmi_regdomain *) datap;
  737. reg_code = le32_to_cpu(ev->reg_code);
  738. if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG)
  739. country = ath6kl_regd_find_country((u16) reg_code);
  740. else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
  741. regpair = ath6kl_get_regpair((u16) reg_code);
  742. country = ath6kl_regd_find_country_by_rd((u16) reg_code);
  743. ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n",
  744. regpair->regDmnEnum);
  745. }
  746. if (country) {
  747. alpha2[0] = country->isoName[0];
  748. alpha2[1] = country->isoName[1];
  749. regulatory_hint(wmi->parent_dev->wiphy, alpha2);
  750. ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n",
  751. alpha2[0], alpha2[1]);
  752. }
  753. }
  754. static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len,
  755. struct ath6kl_vif *vif)
  756. {
  757. struct wmi_disconnect_event *ev;
  758. wmi->traffic_class = 100;
  759. if (len < sizeof(struct wmi_disconnect_event))
  760. return -EINVAL;
  761. ev = (struct wmi_disconnect_event *) datap;
  762. ath6kl_dbg(ATH6KL_DBG_WMI,
  763. "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n",
  764. le16_to_cpu(ev->proto_reason_status), ev->bssid,
  765. ev->disconn_reason, ev->assoc_resp_len);
  766. wmi->is_wmm_enabled = false;
  767. ath6kl_disconnect_event(vif, ev->disconn_reason,
  768. ev->bssid, ev->assoc_resp_len, ev->assoc_info,
  769. le16_to_cpu(ev->proto_reason_status));
  770. return 0;
  771. }
  772. static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len)
  773. {
  774. struct wmi_peer_node_event *ev;
  775. if (len < sizeof(struct wmi_peer_node_event))
  776. return -EINVAL;
  777. ev = (struct wmi_peer_node_event *) datap;
  778. if (ev->event_code == PEER_NODE_JOIN_EVENT)
  779. ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n",
  780. ev->peer_mac_addr);
  781. else if (ev->event_code == PEER_NODE_LEAVE_EVENT)
  782. ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n",
  783. ev->peer_mac_addr);
  784. return 0;
  785. }
  786. static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len,
  787. struct ath6kl_vif *vif)
  788. {
  789. struct wmi_tkip_micerr_event *ev;
  790. if (len < sizeof(struct wmi_tkip_micerr_event))
  791. return -EINVAL;
  792. ev = (struct wmi_tkip_micerr_event *) datap;
  793. ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast);
  794. return 0;
  795. }
  796. void ath6kl_wmi_sscan_timer(unsigned long ptr)
  797. {
  798. struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr;
  799. cfg80211_sched_scan_results(vif->ar->wiphy);
  800. }
  801. static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len,
  802. struct ath6kl_vif *vif)
  803. {
  804. struct wmi_bss_info_hdr2 *bih;
  805. u8 *buf;
  806. struct ieee80211_channel *channel;
  807. struct ath6kl *ar = wmi->parent_dev;
  808. struct ieee80211_mgmt *mgmt;
  809. struct cfg80211_bss *bss;
  810. if (len <= sizeof(struct wmi_bss_info_hdr2))
  811. return -EINVAL;
  812. bih = (struct wmi_bss_info_hdr2 *) datap;
  813. buf = datap + sizeof(struct wmi_bss_info_hdr2);
  814. len -= sizeof(struct wmi_bss_info_hdr2);
  815. ath6kl_dbg(ATH6KL_DBG_WMI,
  816. "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
  817. "frame_type=%d\n",
  818. bih->ch, bih->snr, bih->snr - 95, bih->bssid,
  819. bih->frame_type);
  820. if (bih->frame_type != BEACON_FTYPE &&
  821. bih->frame_type != PROBERESP_FTYPE)
  822. return 0; /* Only update BSS table for now */
  823. if (bih->frame_type == BEACON_FTYPE &&
  824. test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) {
  825. clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
  826. ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
  827. NONE_BSS_FILTER, 0);
  828. }
  829. channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch));
  830. if (channel == NULL)
  831. return -EINVAL;
  832. if (len < 8 + 2 + 2)
  833. return -EINVAL;
  834. if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags)
  835. && memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) {
  836. const u8 *tim;
  837. tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2,
  838. len - 8 - 2 - 2);
  839. if (tim && tim[1] >= 2) {
  840. vif->assoc_bss_dtim_period = tim[3];
  841. set_bit(DTIM_PERIOD_AVAIL, &vif->flags);
  842. }
  843. }
  844. /*
  845. * In theory, use of cfg80211_inform_bss() would be more natural here
  846. * since we do not have the full frame. However, at least for now,
  847. * cfg80211 can only distinguish Beacon and Probe Response frames from
  848. * each other when using cfg80211_inform_bss_frame(), so let's build a
  849. * fake IEEE 802.11 header to be able to take benefit of this.
  850. */
  851. mgmt = kmalloc(24 + len, GFP_ATOMIC);
  852. if (mgmt == NULL)
  853. return -EINVAL;
  854. if (bih->frame_type == BEACON_FTYPE) {
  855. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  856. IEEE80211_STYPE_BEACON);
  857. memset(mgmt->da, 0xff, ETH_ALEN);
  858. } else {
  859. struct net_device *dev = vif->ndev;
  860. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  861. IEEE80211_STYPE_PROBE_RESP);
  862. memcpy(mgmt->da, dev->dev_addr, ETH_ALEN);
  863. }
  864. mgmt->duration = cpu_to_le16(0);
  865. memcpy(mgmt->sa, bih->bssid, ETH_ALEN);
  866. memcpy(mgmt->bssid, bih->bssid, ETH_ALEN);
  867. mgmt->seq_ctrl = cpu_to_le16(0);
  868. memcpy(&mgmt->u.beacon, buf, len);
  869. bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt,
  870. 24 + len, (bih->snr - 95) * 100,
  871. GFP_ATOMIC);
  872. kfree(mgmt);
  873. if (bss == NULL)
  874. return -ENOMEM;
  875. cfg80211_put_bss(bss);
  876. /*
  877. * Firmware doesn't return any event when scheduled scan has
  878. * finished, so we need to use a timer to find out when there are
  879. * no more results.
  880. *
  881. * The timer is started from the first bss info received, otherwise
  882. * the timer would not ever fire if the scan interval is short
  883. * enough.
  884. */
  885. if (ar->state == ATH6KL_STATE_SCHED_SCAN &&
  886. !timer_pending(&vif->sched_scan_timer)) {
  887. mod_timer(&vif->sched_scan_timer, jiffies +
  888. msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY));
  889. }
  890. return 0;
  891. }
  892. /* Inactivity timeout of a fatpipe(pstream) at the target */
  893. static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap,
  894. int len)
  895. {
  896. struct wmi_pstream_timeout_event *ev;
  897. if (len < sizeof(struct wmi_pstream_timeout_event))
  898. return -EINVAL;
  899. ev = (struct wmi_pstream_timeout_event *) datap;
  900. /*
  901. * When the pstream (fat pipe == AC) timesout, it means there were
  902. * no thinStreams within this pstream & it got implicitly created
  903. * due to data flow on this AC. We start the inactivity timer only
  904. * for implicitly created pstream. Just reset the host state.
  905. */
  906. spin_lock_bh(&wmi->lock);
  907. wmi->stream_exist_for_ac[ev->traffic_class] = 0;
  908. wmi->fat_pipe_exist &= ~(1 << ev->traffic_class);
  909. spin_unlock_bh(&wmi->lock);
  910. /* Indicate inactivity to driver layer for this fatpipe (pstream) */
  911. ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false);
  912. return 0;
  913. }
  914. static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len)
  915. {
  916. struct wmi_bit_rate_reply *reply;
  917. s32 rate;
  918. u32 sgi, index;
  919. if (len < sizeof(struct wmi_bit_rate_reply))
  920. return -EINVAL;
  921. reply = (struct wmi_bit_rate_reply *) datap;
  922. ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index);
  923. if (reply->rate_index == (s8) RATE_AUTO) {
  924. rate = RATE_AUTO;
  925. } else {
  926. index = reply->rate_index & 0x7f;
  927. sgi = (reply->rate_index & 0x80) ? 1 : 0;
  928. rate = wmi_rate_tbl[index][sgi];
  929. }
  930. ath6kl_wakeup_event(wmi->parent_dev);
  931. return 0;
  932. }
  933. static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len)
  934. {
  935. ath6kl_tm_rx_event(wmi->parent_dev, datap, len);
  936. return 0;
  937. }
  938. static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len)
  939. {
  940. if (len < sizeof(struct wmi_fix_rates_reply))
  941. return -EINVAL;
  942. ath6kl_wakeup_event(wmi->parent_dev);
  943. return 0;
  944. }
  945. static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len)
  946. {
  947. if (len < sizeof(struct wmi_channel_list_reply))
  948. return -EINVAL;
  949. ath6kl_wakeup_event(wmi->parent_dev);
  950. return 0;
  951. }
  952. static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len)
  953. {
  954. struct wmi_tx_pwr_reply *reply;
  955. if (len < sizeof(struct wmi_tx_pwr_reply))
  956. return -EINVAL;
  957. reply = (struct wmi_tx_pwr_reply *) datap;
  958. ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM);
  959. return 0;
  960. }
  961. static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len)
  962. {
  963. if (len < sizeof(struct wmi_get_keepalive_cmd))
  964. return -EINVAL;
  965. ath6kl_wakeup_event(wmi->parent_dev);
  966. return 0;
  967. }
  968. static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len,
  969. struct ath6kl_vif *vif)
  970. {
  971. struct wmi_scan_complete_event *ev;
  972. ev = (struct wmi_scan_complete_event *) datap;
  973. ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status));
  974. wmi->is_probe_ssid = false;
  975. return 0;
  976. }
  977. static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap,
  978. int len, struct ath6kl_vif *vif)
  979. {
  980. struct wmi_neighbor_report_event *ev;
  981. u8 i;
  982. if (len < sizeof(*ev))
  983. return -EINVAL;
  984. ev = (struct wmi_neighbor_report_event *) datap;
  985. if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info)
  986. > len) {
  987. ath6kl_dbg(ATH6KL_DBG_WMI, "truncated neighbor event "
  988. "(num=%d len=%d)\n", ev->num_neighbors, len);
  989. return -EINVAL;
  990. }
  991. for (i = 0; i < ev->num_neighbors; i++) {
  992. ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n",
  993. i + 1, ev->num_neighbors, ev->neighbor[i].bssid,
  994. ev->neighbor[i].bss_flags);
  995. cfg80211_pmksa_candidate_notify(vif->ndev, i,
  996. ev->neighbor[i].bssid,
  997. !!(ev->neighbor[i].bss_flags &
  998. WMI_PREAUTH_CAPABLE_BSS),
  999. GFP_ATOMIC);
  1000. }
  1001. return 0;
  1002. }
  1003. /*
  1004. * Target is reporting a programming error. This is for
  1005. * developer aid only. Target only checks a few common violations
  1006. * and it is responsibility of host to do all error checking.
  1007. * Behavior of target after wmi error event is undefined.
  1008. * A reset is recommended.
  1009. */
  1010. static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len)
  1011. {
  1012. const char *type = "unknown error";
  1013. struct wmi_cmd_error_event *ev;
  1014. ev = (struct wmi_cmd_error_event *) datap;
  1015. switch (ev->err_code) {
  1016. case INVALID_PARAM:
  1017. type = "invalid parameter";
  1018. break;
  1019. case ILLEGAL_STATE:
  1020. type = "invalid state";
  1021. break;
  1022. case INTERNAL_ERROR:
  1023. type = "internal error";
  1024. break;
  1025. }
  1026. ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n",
  1027. ev->cmd_id, type);
  1028. return 0;
  1029. }
  1030. static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len,
  1031. struct ath6kl_vif *vif)
  1032. {
  1033. ath6kl_tgt_stats_event(vif, datap, len);
  1034. return 0;
  1035. }
  1036. static u8 ath6kl_wmi_get_upper_threshold(s16 rssi,
  1037. struct sq_threshold_params *sq_thresh,
  1038. u32 size)
  1039. {
  1040. u32 index;
  1041. u8 threshold = (u8) sq_thresh->upper_threshold[size - 1];
  1042. /* The list is already in sorted order. Get the next lower value */
  1043. for (index = 0; index < size; index++) {
  1044. if (rssi < sq_thresh->upper_threshold[index]) {
  1045. threshold = (u8) sq_thresh->upper_threshold[index];
  1046. break;
  1047. }
  1048. }
  1049. return threshold;
  1050. }
  1051. static u8 ath6kl_wmi_get_lower_threshold(s16 rssi,
  1052. struct sq_threshold_params *sq_thresh,
  1053. u32 size)
  1054. {
  1055. u32 index;
  1056. u8 threshold = (u8) sq_thresh->lower_threshold[size - 1];
  1057. /* The list is already in sorted order. Get the next lower value */
  1058. for (index = 0; index < size; index++) {
  1059. if (rssi > sq_thresh->lower_threshold[index]) {
  1060. threshold = (u8) sq_thresh->lower_threshold[index];
  1061. break;
  1062. }
  1063. }
  1064. return threshold;
  1065. }
  1066. static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi,
  1067. struct wmi_rssi_threshold_params_cmd *rssi_cmd)
  1068. {
  1069. struct sk_buff *skb;
  1070. struct wmi_rssi_threshold_params_cmd *cmd;
  1071. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1072. if (!skb)
  1073. return -ENOMEM;
  1074. cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data;
  1075. memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd));
  1076. return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
  1077. NO_SYNC_WMIFLAG);
  1078. }
  1079. static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap,
  1080. int len)
  1081. {
  1082. struct wmi_rssi_threshold_event *reply;
  1083. struct wmi_rssi_threshold_params_cmd cmd;
  1084. struct sq_threshold_params *sq_thresh;
  1085. enum wmi_rssi_threshold_val new_threshold;
  1086. u8 upper_rssi_threshold, lower_rssi_threshold;
  1087. s16 rssi;
  1088. int ret;
  1089. if (len < sizeof(struct wmi_rssi_threshold_event))
  1090. return -EINVAL;
  1091. reply = (struct wmi_rssi_threshold_event *) datap;
  1092. new_threshold = (enum wmi_rssi_threshold_val) reply->range;
  1093. rssi = a_sle16_to_cpu(reply->rssi);
  1094. sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI];
  1095. /*
  1096. * Identify the threshold breached and communicate that to the app.
  1097. * After that install a new set of thresholds based on the signal
  1098. * quality reported by the target
  1099. */
  1100. if (new_threshold) {
  1101. /* Upper threshold breached */
  1102. if (rssi < sq_thresh->upper_threshold[0]) {
  1103. ath6kl_dbg(ATH6KL_DBG_WMI,
  1104. "spurious upper rssi threshold event: %d\n",
  1105. rssi);
  1106. } else if ((rssi < sq_thresh->upper_threshold[1]) &&
  1107. (rssi >= sq_thresh->upper_threshold[0])) {
  1108. new_threshold = WMI_RSSI_THRESHOLD1_ABOVE;
  1109. } else if ((rssi < sq_thresh->upper_threshold[2]) &&
  1110. (rssi >= sq_thresh->upper_threshold[1])) {
  1111. new_threshold = WMI_RSSI_THRESHOLD2_ABOVE;
  1112. } else if ((rssi < sq_thresh->upper_threshold[3]) &&
  1113. (rssi >= sq_thresh->upper_threshold[2])) {
  1114. new_threshold = WMI_RSSI_THRESHOLD3_ABOVE;
  1115. } else if ((rssi < sq_thresh->upper_threshold[4]) &&
  1116. (rssi >= sq_thresh->upper_threshold[3])) {
  1117. new_threshold = WMI_RSSI_THRESHOLD4_ABOVE;
  1118. } else if ((rssi < sq_thresh->upper_threshold[5]) &&
  1119. (rssi >= sq_thresh->upper_threshold[4])) {
  1120. new_threshold = WMI_RSSI_THRESHOLD5_ABOVE;
  1121. } else if (rssi >= sq_thresh->upper_threshold[5]) {
  1122. new_threshold = WMI_RSSI_THRESHOLD6_ABOVE;
  1123. }
  1124. } else {
  1125. /* Lower threshold breached */
  1126. if (rssi > sq_thresh->lower_threshold[0]) {
  1127. ath6kl_dbg(ATH6KL_DBG_WMI,
  1128. "spurious lower rssi threshold event: %d %d\n",
  1129. rssi, sq_thresh->lower_threshold[0]);
  1130. } else if ((rssi > sq_thresh->lower_threshold[1]) &&
  1131. (rssi <= sq_thresh->lower_threshold[0])) {
  1132. new_threshold = WMI_RSSI_THRESHOLD6_BELOW;
  1133. } else if ((rssi > sq_thresh->lower_threshold[2]) &&
  1134. (rssi <= sq_thresh->lower_threshold[1])) {
  1135. new_threshold = WMI_RSSI_THRESHOLD5_BELOW;
  1136. } else if ((rssi > sq_thresh->lower_threshold[3]) &&
  1137. (rssi <= sq_thresh->lower_threshold[2])) {
  1138. new_threshold = WMI_RSSI_THRESHOLD4_BELOW;
  1139. } else if ((rssi > sq_thresh->lower_threshold[4]) &&
  1140. (rssi <= sq_thresh->lower_threshold[3])) {
  1141. new_threshold = WMI_RSSI_THRESHOLD3_BELOW;
  1142. } else if ((rssi > sq_thresh->lower_threshold[5]) &&
  1143. (rssi <= sq_thresh->lower_threshold[4])) {
  1144. new_threshold = WMI_RSSI_THRESHOLD2_BELOW;
  1145. } else if (rssi <= sq_thresh->lower_threshold[5]) {
  1146. new_threshold = WMI_RSSI_THRESHOLD1_BELOW;
  1147. }
  1148. }
  1149. /* Calculate and install the next set of thresholds */
  1150. lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh,
  1151. sq_thresh->lower_threshold_valid_count);
  1152. upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh,
  1153. sq_thresh->upper_threshold_valid_count);
  1154. /* Issue a wmi command to install the thresholds */
  1155. cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold);
  1156. cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold);
  1157. cmd.weight = sq_thresh->weight;
  1158. cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
  1159. ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd);
  1160. if (ret) {
  1161. ath6kl_err("unable to configure rssi thresholds\n");
  1162. return -EIO;
  1163. }
  1164. return 0;
  1165. }
  1166. static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len,
  1167. struct ath6kl_vif *vif)
  1168. {
  1169. struct wmi_cac_event *reply;
  1170. struct ieee80211_tspec_ie *ts;
  1171. u16 active_tsids, tsinfo;
  1172. u8 tsid, index;
  1173. u8 ts_id;
  1174. if (len < sizeof(struct wmi_cac_event))
  1175. return -EINVAL;
  1176. reply = (struct wmi_cac_event *) datap;
  1177. if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) &&
  1178. (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) {
  1179. ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
  1180. tsinfo = le16_to_cpu(ts->tsinfo);
  1181. tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
  1182. IEEE80211_WMM_IE_TSPEC_TID_MASK;
  1183. ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
  1184. reply->ac, tsid);
  1185. } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) {
  1186. /*
  1187. * Following assumes that there is only one outstanding
  1188. * ADDTS request when this event is received
  1189. */
  1190. spin_lock_bh(&wmi->lock);
  1191. active_tsids = wmi->stream_exist_for_ac[reply->ac];
  1192. spin_unlock_bh(&wmi->lock);
  1193. for (index = 0; index < sizeof(active_tsids) * 8; index++) {
  1194. if ((active_tsids >> index) & 1)
  1195. break;
  1196. }
  1197. if (index < (sizeof(active_tsids) * 8))
  1198. ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
  1199. reply->ac, index);
  1200. }
  1201. /*
  1202. * Clear active tsids and Add missing handling
  1203. * for delete qos stream from AP
  1204. */
  1205. else if (reply->cac_indication == CAC_INDICATION_DELETE) {
  1206. ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
  1207. tsinfo = le16_to_cpu(ts->tsinfo);
  1208. ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
  1209. IEEE80211_WMM_IE_TSPEC_TID_MASK);
  1210. spin_lock_bh(&wmi->lock);
  1211. wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id);
  1212. active_tsids = wmi->stream_exist_for_ac[reply->ac];
  1213. spin_unlock_bh(&wmi->lock);
  1214. /* Indicate stream inactivity to driver layer only if all tsids
  1215. * within this AC are deleted.
  1216. */
  1217. if (!active_tsids) {
  1218. ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac,
  1219. false);
  1220. wmi->fat_pipe_exist &= ~(1 << reply->ac);
  1221. }
  1222. }
  1223. return 0;
  1224. }
  1225. static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi,
  1226. struct wmi_snr_threshold_params_cmd *snr_cmd)
  1227. {
  1228. struct sk_buff *skb;
  1229. struct wmi_snr_threshold_params_cmd *cmd;
  1230. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1231. if (!skb)
  1232. return -ENOMEM;
  1233. cmd = (struct wmi_snr_threshold_params_cmd *) skb->data;
  1234. memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd));
  1235. return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID,
  1236. NO_SYNC_WMIFLAG);
  1237. }
  1238. static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap,
  1239. int len)
  1240. {
  1241. struct wmi_snr_threshold_event *reply;
  1242. struct sq_threshold_params *sq_thresh;
  1243. struct wmi_snr_threshold_params_cmd cmd;
  1244. enum wmi_snr_threshold_val new_threshold;
  1245. u8 upper_snr_threshold, lower_snr_threshold;
  1246. s16 snr;
  1247. int ret;
  1248. if (len < sizeof(struct wmi_snr_threshold_event))
  1249. return -EINVAL;
  1250. reply = (struct wmi_snr_threshold_event *) datap;
  1251. new_threshold = (enum wmi_snr_threshold_val) reply->range;
  1252. snr = reply->snr;
  1253. sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR];
  1254. /*
  1255. * Identify the threshold breached and communicate that to the app.
  1256. * After that install a new set of thresholds based on the signal
  1257. * quality reported by the target.
  1258. */
  1259. if (new_threshold) {
  1260. /* Upper threshold breached */
  1261. if (snr < sq_thresh->upper_threshold[0]) {
  1262. ath6kl_dbg(ATH6KL_DBG_WMI,
  1263. "spurious upper snr threshold event: %d\n",
  1264. snr);
  1265. } else if ((snr < sq_thresh->upper_threshold[1]) &&
  1266. (snr >= sq_thresh->upper_threshold[0])) {
  1267. new_threshold = WMI_SNR_THRESHOLD1_ABOVE;
  1268. } else if ((snr < sq_thresh->upper_threshold[2]) &&
  1269. (snr >= sq_thresh->upper_threshold[1])) {
  1270. new_threshold = WMI_SNR_THRESHOLD2_ABOVE;
  1271. } else if ((snr < sq_thresh->upper_threshold[3]) &&
  1272. (snr >= sq_thresh->upper_threshold[2])) {
  1273. new_threshold = WMI_SNR_THRESHOLD3_ABOVE;
  1274. } else if (snr >= sq_thresh->upper_threshold[3]) {
  1275. new_threshold = WMI_SNR_THRESHOLD4_ABOVE;
  1276. }
  1277. } else {
  1278. /* Lower threshold breached */
  1279. if (snr > sq_thresh->lower_threshold[0]) {
  1280. ath6kl_dbg(ATH6KL_DBG_WMI,
  1281. "spurious lower snr threshold event: %d\n",
  1282. sq_thresh->lower_threshold[0]);
  1283. } else if ((snr > sq_thresh->lower_threshold[1]) &&
  1284. (snr <= sq_thresh->lower_threshold[0])) {
  1285. new_threshold = WMI_SNR_THRESHOLD4_BELOW;
  1286. } else if ((snr > sq_thresh->lower_threshold[2]) &&
  1287. (snr <= sq_thresh->lower_threshold[1])) {
  1288. new_threshold = WMI_SNR_THRESHOLD3_BELOW;
  1289. } else if ((snr > sq_thresh->lower_threshold[3]) &&
  1290. (snr <= sq_thresh->lower_threshold[2])) {
  1291. new_threshold = WMI_SNR_THRESHOLD2_BELOW;
  1292. } else if (snr <= sq_thresh->lower_threshold[3]) {
  1293. new_threshold = WMI_SNR_THRESHOLD1_BELOW;
  1294. }
  1295. }
  1296. /* Calculate and install the next set of thresholds */
  1297. lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh,
  1298. sq_thresh->lower_threshold_valid_count);
  1299. upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh,
  1300. sq_thresh->upper_threshold_valid_count);
  1301. /* Issue a wmi command to install the thresholds */
  1302. cmd.thresh_above1_val = upper_snr_threshold;
  1303. cmd.thresh_below1_val = lower_snr_threshold;
  1304. cmd.weight = sq_thresh->weight;
  1305. cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
  1306. ath6kl_dbg(ATH6KL_DBG_WMI,
  1307. "snr: %d, threshold: %d, lower: %d, upper: %d\n",
  1308. snr, new_threshold,
  1309. lower_snr_threshold, upper_snr_threshold);
  1310. ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd);
  1311. if (ret) {
  1312. ath6kl_err("unable to configure snr threshold\n");
  1313. return -EIO;
  1314. }
  1315. return 0;
  1316. }
  1317. static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len)
  1318. {
  1319. u16 ap_info_entry_size;
  1320. struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap;
  1321. struct wmi_ap_info_v1 *ap_info_v1;
  1322. u8 index;
  1323. if (len < sizeof(struct wmi_aplist_event) ||
  1324. ev->ap_list_ver != APLIST_VER1)
  1325. return -EINVAL;
  1326. ap_info_entry_size = sizeof(struct wmi_ap_info_v1);
  1327. ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list;
  1328. ath6kl_dbg(ATH6KL_DBG_WMI,
  1329. "number of APs in aplist event: %d\n", ev->num_ap);
  1330. if (len < (int) (sizeof(struct wmi_aplist_event) +
  1331. (ev->num_ap - 1) * ap_info_entry_size))
  1332. return -EINVAL;
  1333. /* AP list version 1 contents */
  1334. for (index = 0; index < ev->num_ap; index++) {
  1335. ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n",
  1336. index, ap_info_v1->bssid, ap_info_v1->channel);
  1337. ap_info_v1++;
  1338. }
  1339. return 0;
  1340. }
  1341. int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb,
  1342. enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag)
  1343. {
  1344. struct wmi_cmd_hdr *cmd_hdr;
  1345. enum htc_endpoint_id ep_id = wmi->ep_id;
  1346. int ret;
  1347. u16 info1;
  1348. if (WARN_ON(skb == NULL || (if_idx > (wmi->parent_dev->vif_max - 1))))
  1349. return -EINVAL;
  1350. ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n",
  1351. cmd_id, skb->len, sync_flag);
  1352. ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ",
  1353. skb->data, skb->len);
  1354. if (sync_flag >= END_WMIFLAG) {
  1355. dev_kfree_skb(skb);
  1356. return -EINVAL;
  1357. }
  1358. if ((sync_flag == SYNC_BEFORE_WMIFLAG) ||
  1359. (sync_flag == SYNC_BOTH_WMIFLAG)) {
  1360. /*
  1361. * Make sure all data currently queued is transmitted before
  1362. * the cmd execution. Establish a new sync point.
  1363. */
  1364. ath6kl_wmi_sync_point(wmi, if_idx);
  1365. }
  1366. skb_push(skb, sizeof(struct wmi_cmd_hdr));
  1367. cmd_hdr = (struct wmi_cmd_hdr *) skb->data;
  1368. cmd_hdr->cmd_id = cpu_to_le16(cmd_id);
  1369. info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK;
  1370. cmd_hdr->info1 = cpu_to_le16(info1);
  1371. /* Only for OPT_TX_CMD, use BE endpoint. */
  1372. if (cmd_id == WMI_OPT_TX_FRAME_CMDID) {
  1373. ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE,
  1374. false, false, 0, NULL, if_idx);
  1375. if (ret) {
  1376. dev_kfree_skb(skb);
  1377. return ret;
  1378. }
  1379. ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE);
  1380. }
  1381. ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
  1382. if ((sync_flag == SYNC_AFTER_WMIFLAG) ||
  1383. (sync_flag == SYNC_BOTH_WMIFLAG)) {
  1384. /*
  1385. * Make sure all new data queued waits for the command to
  1386. * execute. Establish a new sync point.
  1387. */
  1388. ath6kl_wmi_sync_point(wmi, if_idx);
  1389. }
  1390. return 0;
  1391. }
  1392. int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx,
  1393. enum network_type nw_type,
  1394. enum dot11_auth_mode dot11_auth_mode,
  1395. enum auth_mode auth_mode,
  1396. enum crypto_type pairwise_crypto,
  1397. u8 pairwise_crypto_len,
  1398. enum crypto_type group_crypto,
  1399. u8 group_crypto_len, int ssid_len, u8 *ssid,
  1400. u8 *bssid, u16 channel, u32 ctrl_flags,
  1401. u8 nw_subtype)
  1402. {
  1403. struct sk_buff *skb;
  1404. struct wmi_connect_cmd *cc;
  1405. int ret;
  1406. ath6kl_dbg(ATH6KL_DBG_WMI,
  1407. "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d "
  1408. "type %d dot11_auth %d auth %d pairwise %d group %d\n",
  1409. bssid, channel, ctrl_flags, ssid_len, nw_type,
  1410. dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto);
  1411. ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len);
  1412. wmi->traffic_class = 100;
  1413. if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT))
  1414. return -EINVAL;
  1415. if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT))
  1416. return -EINVAL;
  1417. skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd));
  1418. if (!skb)
  1419. return -ENOMEM;
  1420. cc = (struct wmi_connect_cmd *) skb->data;
  1421. if (ssid_len)
  1422. memcpy(cc->ssid, ssid, ssid_len);
  1423. cc->ssid_len = ssid_len;
  1424. cc->nw_type = nw_type;
  1425. cc->dot11_auth_mode = dot11_auth_mode;
  1426. cc->auth_mode = auth_mode;
  1427. cc->prwise_crypto_type = pairwise_crypto;
  1428. cc->prwise_crypto_len = pairwise_crypto_len;
  1429. cc->grp_crypto_type = group_crypto;
  1430. cc->grp_crypto_len = group_crypto_len;
  1431. cc->ch = cpu_to_le16(channel);
  1432. cc->ctrl_flags = cpu_to_le32(ctrl_flags);
  1433. cc->nw_subtype = nw_subtype;
  1434. if (bssid != NULL)
  1435. memcpy(cc->bssid, bssid, ETH_ALEN);
  1436. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID,
  1437. NO_SYNC_WMIFLAG);
  1438. return ret;
  1439. }
  1440. int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid,
  1441. u16 channel)
  1442. {
  1443. struct sk_buff *skb;
  1444. struct wmi_reconnect_cmd *cc;
  1445. int ret;
  1446. ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n",
  1447. bssid, channel);
  1448. wmi->traffic_class = 100;
  1449. skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd));
  1450. if (!skb)
  1451. return -ENOMEM;
  1452. cc = (struct wmi_reconnect_cmd *) skb->data;
  1453. cc->channel = cpu_to_le16(channel);
  1454. if (bssid != NULL)
  1455. memcpy(cc->bssid, bssid, ETH_ALEN);
  1456. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID,
  1457. NO_SYNC_WMIFLAG);
  1458. return ret;
  1459. }
  1460. int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx)
  1461. {
  1462. int ret;
  1463. ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n");
  1464. wmi->traffic_class = 100;
  1465. /* Disconnect command does not need to do a SYNC before. */
  1466. ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID);
  1467. return ret;
  1468. }
  1469. int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx,
  1470. enum wmi_scan_type scan_type,
  1471. u32 force_fgscan, u32 is_legacy,
  1472. u32 home_dwell_time, u32 force_scan_interval,
  1473. s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates)
  1474. {
  1475. struct sk_buff *skb;
  1476. struct wmi_begin_scan_cmd *sc;
  1477. s8 size;
  1478. int i, band, ret;
  1479. struct ath6kl *ar = wmi->parent_dev;
  1480. int num_rates;
  1481. size = sizeof(struct wmi_begin_scan_cmd);
  1482. if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
  1483. return -EINVAL;
  1484. if (num_chan > WMI_MAX_CHANNELS)
  1485. return -EINVAL;
  1486. if (num_chan)
  1487. size += sizeof(u16) * (num_chan - 1);
  1488. skb = ath6kl_wmi_get_new_buf(size);
  1489. if (!skb)
  1490. return -ENOMEM;
  1491. sc = (struct wmi_begin_scan_cmd *) skb->data;
  1492. sc->scan_type = scan_type;
  1493. sc->force_fg_scan = cpu_to_le32(force_fgscan);
  1494. sc->is_legacy = cpu_to_le32(is_legacy);
  1495. sc->home_dwell_time = cpu_to_le32(home_dwell_time);
  1496. sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
  1497. sc->no_cck = cpu_to_le32(no_cck);
  1498. sc->num_ch = num_chan;
  1499. for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
  1500. struct ieee80211_supported_band *sband =
  1501. ar->wiphy->bands[band];
  1502. u32 ratemask = rates[band];
  1503. u8 *supp_rates = sc->supp_rates[band].rates;
  1504. num_rates = 0;
  1505. for (i = 0; i < sband->n_bitrates; i++) {
  1506. if ((BIT(i) & ratemask) == 0)
  1507. continue; /* skip rate */
  1508. supp_rates[num_rates++] =
  1509. (u8) (sband->bitrates[i].bitrate / 5);
  1510. }
  1511. sc->supp_rates[band].nrates = num_rates;
  1512. }
  1513. for (i = 0; i < num_chan; i++)
  1514. sc->ch_list[i] = cpu_to_le16(ch_list[i]);
  1515. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_BEGIN_SCAN_CMDID,
  1516. NO_SYNC_WMIFLAG);
  1517. return ret;
  1518. }
  1519. /* ath6kl_wmi_start_scan_cmd is to be deprecated. Use
  1520. * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P
  1521. * mgmt operations using station interface.
  1522. */
  1523. int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx,
  1524. enum wmi_scan_type scan_type,
  1525. u32 force_fgscan, u32 is_legacy,
  1526. u32 home_dwell_time, u32 force_scan_interval,
  1527. s8 num_chan, u16 *ch_list)
  1528. {
  1529. struct sk_buff *skb;
  1530. struct wmi_start_scan_cmd *sc;
  1531. s8 size;
  1532. int i, ret;
  1533. size = sizeof(struct wmi_start_scan_cmd);
  1534. if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
  1535. return -EINVAL;
  1536. if (num_chan > WMI_MAX_CHANNELS)
  1537. return -EINVAL;
  1538. if (num_chan)
  1539. size += sizeof(u16) * (num_chan - 1);
  1540. skb = ath6kl_wmi_get_new_buf(size);
  1541. if (!skb)
  1542. return -ENOMEM;
  1543. sc = (struct wmi_start_scan_cmd *) skb->data;
  1544. sc->scan_type = scan_type;
  1545. sc->force_fg_scan = cpu_to_le32(force_fgscan);
  1546. sc->is_legacy = cpu_to_le32(is_legacy);
  1547. sc->home_dwell_time = cpu_to_le32(home_dwell_time);
  1548. sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
  1549. sc->num_ch = num_chan;
  1550. for (i = 0; i < num_chan; i++)
  1551. sc->ch_list[i] = cpu_to_le16(ch_list[i]);
  1552. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID,
  1553. NO_SYNC_WMIFLAG);
  1554. return ret;
  1555. }
  1556. int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx,
  1557. u16 fg_start_sec,
  1558. u16 fg_end_sec, u16 bg_sec,
  1559. u16 minact_chdw_msec, u16 maxact_chdw_msec,
  1560. u16 pas_chdw_msec, u8 short_scan_ratio,
  1561. u8 scan_ctrl_flag, u32 max_dfsch_act_time,
  1562. u16 maxact_scan_per_ssid)
  1563. {
  1564. struct sk_buff *skb;
  1565. struct wmi_scan_params_cmd *sc;
  1566. int ret;
  1567. skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
  1568. if (!skb)
  1569. return -ENOMEM;
  1570. sc = (struct wmi_scan_params_cmd *) skb->data;
  1571. sc->fg_start_period = cpu_to_le16(fg_start_sec);
  1572. sc->fg_end_period = cpu_to_le16(fg_end_sec);
  1573. sc->bg_period = cpu_to_le16(bg_sec);
  1574. sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec);
  1575. sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec);
  1576. sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec);
  1577. sc->short_scan_ratio = short_scan_ratio;
  1578. sc->scan_ctrl_flags = scan_ctrl_flag;
  1579. sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time);
  1580. sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid);
  1581. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID,
  1582. NO_SYNC_WMIFLAG);
  1583. return ret;
  1584. }
  1585. int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask)
  1586. {
  1587. struct sk_buff *skb;
  1588. struct wmi_bss_filter_cmd *cmd;
  1589. int ret;
  1590. if (filter >= LAST_BSS_FILTER)
  1591. return -EINVAL;
  1592. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1593. if (!skb)
  1594. return -ENOMEM;
  1595. cmd = (struct wmi_bss_filter_cmd *) skb->data;
  1596. cmd->bss_filter = filter;
  1597. cmd->ie_mask = cpu_to_le32(ie_mask);
  1598. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID,
  1599. NO_SYNC_WMIFLAG);
  1600. return ret;
  1601. }
  1602. int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag,
  1603. u8 ssid_len, u8 *ssid)
  1604. {
  1605. struct sk_buff *skb;
  1606. struct wmi_probed_ssid_cmd *cmd;
  1607. int ret;
  1608. if (index > MAX_PROBED_SSID_INDEX)
  1609. return -EINVAL;
  1610. if (ssid_len > sizeof(cmd->ssid))
  1611. return -EINVAL;
  1612. if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0))
  1613. return -EINVAL;
  1614. if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len)
  1615. return -EINVAL;
  1616. if (flag & SPECIFIC_SSID_FLAG)
  1617. wmi->is_probe_ssid = true;
  1618. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1619. if (!skb)
  1620. return -ENOMEM;
  1621. cmd = (struct wmi_probed_ssid_cmd *) skb->data;
  1622. cmd->entry_index = index;
  1623. cmd->flag = flag;
  1624. cmd->ssid_len = ssid_len;
  1625. memcpy(cmd->ssid, ssid, ssid_len);
  1626. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID,
  1627. NO_SYNC_WMIFLAG);
  1628. return ret;
  1629. }
  1630. int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx,
  1631. u16 listen_interval,
  1632. u16 listen_beacons)
  1633. {
  1634. struct sk_buff *skb;
  1635. struct wmi_listen_int_cmd *cmd;
  1636. int ret;
  1637. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1638. if (!skb)
  1639. return -ENOMEM;
  1640. cmd = (struct wmi_listen_int_cmd *) skb->data;
  1641. cmd->listen_intvl = cpu_to_le16(listen_interval);
  1642. cmd->num_beacons = cpu_to_le16(listen_beacons);
  1643. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID,
  1644. NO_SYNC_WMIFLAG);
  1645. return ret;
  1646. }
  1647. int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode)
  1648. {
  1649. struct sk_buff *skb;
  1650. struct wmi_power_mode_cmd *cmd;
  1651. int ret;
  1652. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1653. if (!skb)
  1654. return -ENOMEM;
  1655. cmd = (struct wmi_power_mode_cmd *) skb->data;
  1656. cmd->pwr_mode = pwr_mode;
  1657. wmi->pwr_mode = pwr_mode;
  1658. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID,
  1659. NO_SYNC_WMIFLAG);
  1660. return ret;
  1661. }
  1662. int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period,
  1663. u16 ps_poll_num, u16 dtim_policy,
  1664. u16 tx_wakeup_policy, u16 num_tx_to_wakeup,
  1665. u16 ps_fail_event_policy)
  1666. {
  1667. struct sk_buff *skb;
  1668. struct wmi_power_params_cmd *pm;
  1669. int ret;
  1670. skb = ath6kl_wmi_get_new_buf(sizeof(*pm));
  1671. if (!skb)
  1672. return -ENOMEM;
  1673. pm = (struct wmi_power_params_cmd *)skb->data;
  1674. pm->idle_period = cpu_to_le16(idle_period);
  1675. pm->pspoll_number = cpu_to_le16(ps_poll_num);
  1676. pm->dtim_policy = cpu_to_le16(dtim_policy);
  1677. pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy);
  1678. pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup);
  1679. pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy);
  1680. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID,
  1681. NO_SYNC_WMIFLAG);
  1682. return ret;
  1683. }
  1684. int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout)
  1685. {
  1686. struct sk_buff *skb;
  1687. struct wmi_disc_timeout_cmd *cmd;
  1688. int ret;
  1689. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1690. if (!skb)
  1691. return -ENOMEM;
  1692. cmd = (struct wmi_disc_timeout_cmd *) skb->data;
  1693. cmd->discon_timeout = timeout;
  1694. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID,
  1695. NO_SYNC_WMIFLAG);
  1696. if (ret == 0)
  1697. ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout);
  1698. return ret;
  1699. }
  1700. int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index,
  1701. enum crypto_type key_type,
  1702. u8 key_usage, u8 key_len,
  1703. u8 *key_rsc, unsigned int key_rsc_len,
  1704. u8 *key_material,
  1705. u8 key_op_ctrl, u8 *mac_addr,
  1706. enum wmi_sync_flag sync_flag)
  1707. {
  1708. struct sk_buff *skb;
  1709. struct wmi_add_cipher_key_cmd *cmd;
  1710. int ret;
  1711. ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d "
  1712. "key_usage=%d key_len=%d key_op_ctrl=%d\n",
  1713. key_index, key_type, key_usage, key_len, key_op_ctrl);
  1714. if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) ||
  1715. (key_material == NULL) || key_rsc_len > 8)
  1716. return -EINVAL;
  1717. if ((WEP_CRYPT != key_type) && (NULL == key_rsc))
  1718. return -EINVAL;
  1719. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1720. if (!skb)
  1721. return -ENOMEM;
  1722. cmd = (struct wmi_add_cipher_key_cmd *) skb->data;
  1723. cmd->key_index = key_index;
  1724. cmd->key_type = key_type;
  1725. cmd->key_usage = key_usage;
  1726. cmd->key_len = key_len;
  1727. memcpy(cmd->key, key_material, key_len);
  1728. if (key_rsc != NULL)
  1729. memcpy(cmd->key_rsc, key_rsc, key_rsc_len);
  1730. cmd->key_op_ctrl = key_op_ctrl;
  1731. if (mac_addr)
  1732. memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN);
  1733. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID,
  1734. sync_flag);
  1735. return ret;
  1736. }
  1737. int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk)
  1738. {
  1739. struct sk_buff *skb;
  1740. struct wmi_add_krk_cmd *cmd;
  1741. int ret;
  1742. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1743. if (!skb)
  1744. return -ENOMEM;
  1745. cmd = (struct wmi_add_krk_cmd *) skb->data;
  1746. memcpy(cmd->krk, krk, WMI_KRK_LEN);
  1747. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID,
  1748. NO_SYNC_WMIFLAG);
  1749. return ret;
  1750. }
  1751. int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index)
  1752. {
  1753. struct sk_buff *skb;
  1754. struct wmi_delete_cipher_key_cmd *cmd;
  1755. int ret;
  1756. if (key_index > WMI_MAX_KEY_INDEX)
  1757. return -EINVAL;
  1758. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1759. if (!skb)
  1760. return -ENOMEM;
  1761. cmd = (struct wmi_delete_cipher_key_cmd *) skb->data;
  1762. cmd->key_index = key_index;
  1763. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID,
  1764. NO_SYNC_WMIFLAG);
  1765. return ret;
  1766. }
  1767. int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid,
  1768. const u8 *pmkid, bool set)
  1769. {
  1770. struct sk_buff *skb;
  1771. struct wmi_setpmkid_cmd *cmd;
  1772. int ret;
  1773. if (bssid == NULL)
  1774. return -EINVAL;
  1775. if (set && pmkid == NULL)
  1776. return -EINVAL;
  1777. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1778. if (!skb)
  1779. return -ENOMEM;
  1780. cmd = (struct wmi_setpmkid_cmd *) skb->data;
  1781. memcpy(cmd->bssid, bssid, ETH_ALEN);
  1782. if (set) {
  1783. memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid));
  1784. cmd->enable = PMKID_ENABLE;
  1785. } else {
  1786. memset(cmd->pmkid, 0, sizeof(cmd->pmkid));
  1787. cmd->enable = PMKID_DISABLE;
  1788. }
  1789. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID,
  1790. NO_SYNC_WMIFLAG);
  1791. return ret;
  1792. }
  1793. static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb,
  1794. enum htc_endpoint_id ep_id, u8 if_idx)
  1795. {
  1796. struct wmi_data_hdr *data_hdr;
  1797. int ret;
  1798. if (WARN_ON(skb == NULL || ep_id == wmi->ep_id))
  1799. return -EINVAL;
  1800. skb_push(skb, sizeof(struct wmi_data_hdr));
  1801. data_hdr = (struct wmi_data_hdr *) skb->data;
  1802. data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT;
  1803. data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
  1804. ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
  1805. return ret;
  1806. }
  1807. static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx)
  1808. {
  1809. struct sk_buff *skb;
  1810. struct wmi_sync_cmd *cmd;
  1811. struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC];
  1812. enum htc_endpoint_id ep_id;
  1813. u8 index, num_pri_streams = 0;
  1814. int ret = 0;
  1815. memset(data_sync_bufs, 0, sizeof(data_sync_bufs));
  1816. spin_lock_bh(&wmi->lock);
  1817. for (index = 0; index < WMM_NUM_AC; index++) {
  1818. if (wmi->fat_pipe_exist & (1 << index)) {
  1819. num_pri_streams++;
  1820. data_sync_bufs[num_pri_streams - 1].traffic_class =
  1821. index;
  1822. }
  1823. }
  1824. spin_unlock_bh(&wmi->lock);
  1825. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1826. if (!skb) {
  1827. ret = -ENOMEM;
  1828. goto free_skb;
  1829. }
  1830. cmd = (struct wmi_sync_cmd *) skb->data;
  1831. /*
  1832. * In the SYNC cmd sent on the control Ep, send a bitmap
  1833. * of the data eps on which the Data Sync will be sent
  1834. */
  1835. cmd->data_sync_map = wmi->fat_pipe_exist;
  1836. for (index = 0; index < num_pri_streams; index++) {
  1837. data_sync_bufs[index].skb = ath6kl_buf_alloc(0);
  1838. if (data_sync_bufs[index].skb == NULL) {
  1839. ret = -ENOMEM;
  1840. break;
  1841. }
  1842. }
  1843. /*
  1844. * If buffer allocation for any of the dataSync fails,
  1845. * then do not send the Synchronize cmd on the control ep
  1846. */
  1847. if (ret)
  1848. goto free_skb;
  1849. /*
  1850. * Send sync cmd followed by sync data messages on all
  1851. * endpoints being used
  1852. */
  1853. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID,
  1854. NO_SYNC_WMIFLAG);
  1855. if (ret)
  1856. goto free_skb;
  1857. /* cmd buffer sent, we no longer own it */
  1858. skb = NULL;
  1859. for (index = 0; index < num_pri_streams; index++) {
  1860. if (WARN_ON(!data_sync_bufs[index].skb))
  1861. break;
  1862. ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
  1863. data_sync_bufs[index].
  1864. traffic_class);
  1865. ret =
  1866. ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb,
  1867. ep_id, if_idx);
  1868. if (ret)
  1869. break;
  1870. data_sync_bufs[index].skb = NULL;
  1871. }
  1872. free_skb:
  1873. /* free up any resources left over (possibly due to an error) */
  1874. if (skb)
  1875. dev_kfree_skb(skb);
  1876. for (index = 0; index < num_pri_streams; index++) {
  1877. if (data_sync_bufs[index].skb != NULL) {
  1878. dev_kfree_skb((struct sk_buff *)data_sync_bufs[index].
  1879. skb);
  1880. }
  1881. }
  1882. return ret;
  1883. }
  1884. int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx,
  1885. struct wmi_create_pstream_cmd *params)
  1886. {
  1887. struct sk_buff *skb;
  1888. struct wmi_create_pstream_cmd *cmd;
  1889. u8 fatpipe_exist_for_ac = 0;
  1890. s32 min_phy = 0;
  1891. s32 nominal_phy = 0;
  1892. int ret;
  1893. if (!((params->user_pri < 8) &&
  1894. (params->user_pri <= 0x7) &&
  1895. (up_to_ac[params->user_pri & 0x7] == params->traffic_class) &&
  1896. (params->traffic_direc == UPLINK_TRAFFIC ||
  1897. params->traffic_direc == DNLINK_TRAFFIC ||
  1898. params->traffic_direc == BIDIR_TRAFFIC) &&
  1899. (params->traffic_type == TRAFFIC_TYPE_APERIODIC ||
  1900. params->traffic_type == TRAFFIC_TYPE_PERIODIC) &&
  1901. (params->voice_psc_cap == DISABLE_FOR_THIS_AC ||
  1902. params->voice_psc_cap == ENABLE_FOR_THIS_AC ||
  1903. params->voice_psc_cap == ENABLE_FOR_ALL_AC) &&
  1904. (params->tsid == WMI_IMPLICIT_PSTREAM ||
  1905. params->tsid <= WMI_MAX_THINSTREAM))) {
  1906. return -EINVAL;
  1907. }
  1908. /*
  1909. * Check nominal PHY rate is >= minimalPHY,
  1910. * so that DUT can allow TSRS IE
  1911. */
  1912. /* Get the physical rate (units of bps) */
  1913. min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000);
  1914. /* Check minimal phy < nominal phy rate */
  1915. if (params->nominal_phy >= min_phy) {
  1916. /* unit of 500 kbps */
  1917. nominal_phy = (params->nominal_phy * 1000) / 500;
  1918. ath6kl_dbg(ATH6KL_DBG_WMI,
  1919. "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
  1920. min_phy, nominal_phy);
  1921. params->nominal_phy = nominal_phy;
  1922. } else {
  1923. params->nominal_phy = 0;
  1924. }
  1925. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1926. if (!skb)
  1927. return -ENOMEM;
  1928. ath6kl_dbg(ATH6KL_DBG_WMI,
  1929. "sending create_pstream_cmd: ac=%d tsid:%d\n",
  1930. params->traffic_class, params->tsid);
  1931. cmd = (struct wmi_create_pstream_cmd *) skb->data;
  1932. memcpy(cmd, params, sizeof(*cmd));
  1933. /* This is an implicitly created Fat pipe */
  1934. if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) {
  1935. spin_lock_bh(&wmi->lock);
  1936. fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
  1937. (1 << params->traffic_class));
  1938. wmi->fat_pipe_exist |= (1 << params->traffic_class);
  1939. spin_unlock_bh(&wmi->lock);
  1940. } else {
  1941. /* explicitly created thin stream within a fat pipe */
  1942. spin_lock_bh(&wmi->lock);
  1943. fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
  1944. (1 << params->traffic_class));
  1945. wmi->stream_exist_for_ac[params->traffic_class] |=
  1946. (1 << params->tsid);
  1947. /*
  1948. * If a thinstream becomes active, the fat pipe automatically
  1949. * becomes active
  1950. */
  1951. wmi->fat_pipe_exist |= (1 << params->traffic_class);
  1952. spin_unlock_bh(&wmi->lock);
  1953. }
  1954. /*
  1955. * Indicate activty change to driver layer only if this is the
  1956. * first TSID to get created in this AC explicitly or an implicit
  1957. * fat pipe is getting created.
  1958. */
  1959. if (!fatpipe_exist_for_ac)
  1960. ath6kl_indicate_tx_activity(wmi->parent_dev,
  1961. params->traffic_class, true);
  1962. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID,
  1963. NO_SYNC_WMIFLAG);
  1964. return ret;
  1965. }
  1966. int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class,
  1967. u8 tsid)
  1968. {
  1969. struct sk_buff *skb;
  1970. struct wmi_delete_pstream_cmd *cmd;
  1971. u16 active_tsids = 0;
  1972. int ret;
  1973. if (traffic_class > 3) {
  1974. ath6kl_err("invalid traffic class: %d\n", traffic_class);
  1975. return -EINVAL;
  1976. }
  1977. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  1978. if (!skb)
  1979. return -ENOMEM;
  1980. cmd = (struct wmi_delete_pstream_cmd *) skb->data;
  1981. cmd->traffic_class = traffic_class;
  1982. cmd->tsid = tsid;
  1983. spin_lock_bh(&wmi->lock);
  1984. active_tsids = wmi->stream_exist_for_ac[traffic_class];
  1985. spin_unlock_bh(&wmi->lock);
  1986. if (!(active_tsids & (1 << tsid))) {
  1987. dev_kfree_skb(skb);
  1988. ath6kl_dbg(ATH6KL_DBG_WMI,
  1989. "TSID %d doesn't exist for traffic class: %d\n",
  1990. tsid, traffic_class);
  1991. return -ENODATA;
  1992. }
  1993. ath6kl_dbg(ATH6KL_DBG_WMI,
  1994. "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
  1995. traffic_class, tsid);
  1996. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID,
  1997. SYNC_BEFORE_WMIFLAG);
  1998. spin_lock_bh(&wmi->lock);
  1999. wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid);
  2000. active_tsids = wmi->stream_exist_for_ac[traffic_class];
  2001. spin_unlock_bh(&wmi->lock);
  2002. /*
  2003. * Indicate stream inactivity to driver layer only if all tsids
  2004. * within this AC are deleted.
  2005. */
  2006. if (!active_tsids) {
  2007. ath6kl_indicate_tx_activity(wmi->parent_dev,
  2008. traffic_class, false);
  2009. wmi->fat_pipe_exist &= ~(1 << traffic_class);
  2010. }
  2011. return ret;
  2012. }
  2013. int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx,
  2014. __be32 ips0, __be32 ips1)
  2015. {
  2016. struct sk_buff *skb;
  2017. struct wmi_set_ip_cmd *cmd;
  2018. int ret;
  2019. /* Multicast address are not valid */
  2020. if (ipv4_is_multicast(ips0) ||
  2021. ipv4_is_multicast(ips1))
  2022. return -EINVAL;
  2023. skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd));
  2024. if (!skb)
  2025. return -ENOMEM;
  2026. cmd = (struct wmi_set_ip_cmd *) skb->data;
  2027. cmd->ips[0] = ips0;
  2028. cmd->ips[1] = ips1;
  2029. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID,
  2030. NO_SYNC_WMIFLAG);
  2031. return ret;
  2032. }
  2033. static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi)
  2034. {
  2035. u16 active_tsids;
  2036. u8 stream_exist;
  2037. int i;
  2038. /*
  2039. * Relinquish credits from all implicitly created pstreams
  2040. * since when we go to sleep. If user created explicit
  2041. * thinstreams exists with in a fatpipe leave them intact
  2042. * for the user to delete.
  2043. */
  2044. spin_lock_bh(&wmi->lock);
  2045. stream_exist = wmi->fat_pipe_exist;
  2046. spin_unlock_bh(&wmi->lock);
  2047. for (i = 0; i < WMM_NUM_AC; i++) {
  2048. if (stream_exist & (1 << i)) {
  2049. /*
  2050. * FIXME: Is this lock & unlock inside
  2051. * for loop correct? may need rework.
  2052. */
  2053. spin_lock_bh(&wmi->lock);
  2054. active_tsids = wmi->stream_exist_for_ac[i];
  2055. spin_unlock_bh(&wmi->lock);
  2056. /*
  2057. * If there are no user created thin streams
  2058. * delete the fatpipe
  2059. */
  2060. if (!active_tsids) {
  2061. stream_exist &= ~(1 << i);
  2062. /*
  2063. * Indicate inactivity to driver layer for
  2064. * this fatpipe (pstream)
  2065. */
  2066. ath6kl_indicate_tx_activity(wmi->parent_dev,
  2067. i, false);
  2068. }
  2069. }
  2070. }
  2071. /* FIXME: Can we do this assignment without locking ? */
  2072. spin_lock_bh(&wmi->lock);
  2073. wmi->fat_pipe_exist = stream_exist;
  2074. spin_unlock_bh(&wmi->lock);
  2075. }
  2076. int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx,
  2077. enum ath6kl_host_mode host_mode)
  2078. {
  2079. struct sk_buff *skb;
  2080. struct wmi_set_host_sleep_mode_cmd *cmd;
  2081. int ret;
  2082. if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) &&
  2083. (host_mode != ATH6KL_HOST_MODE_AWAKE)) {
  2084. ath6kl_err("invalid host sleep mode: %d\n", host_mode);
  2085. return -EINVAL;
  2086. }
  2087. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2088. if (!skb)
  2089. return -ENOMEM;
  2090. cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data;
  2091. if (host_mode == ATH6KL_HOST_MODE_ASLEEP) {
  2092. ath6kl_wmi_relinquish_implicit_pstream_credits(wmi);
  2093. cmd->asleep = cpu_to_le32(1);
  2094. } else
  2095. cmd->awake = cpu_to_le32(1);
  2096. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
  2097. WMI_SET_HOST_SLEEP_MODE_CMDID,
  2098. NO_SYNC_WMIFLAG);
  2099. return ret;
  2100. }
  2101. /* This command has zero length payload */
  2102. static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi *wmi,
  2103. struct ath6kl_vif *vif)
  2104. {
  2105. struct ath6kl *ar = wmi->parent_dev;
  2106. set_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags);
  2107. wake_up(&ar->event_wq);
  2108. return 0;
  2109. }
  2110. int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx,
  2111. enum ath6kl_wow_mode wow_mode,
  2112. u32 filter, u16 host_req_delay)
  2113. {
  2114. struct sk_buff *skb;
  2115. struct wmi_set_wow_mode_cmd *cmd;
  2116. int ret;
  2117. if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) &&
  2118. wow_mode != ATH6KL_WOW_MODE_DISABLE) {
  2119. ath6kl_err("invalid wow mode: %d\n", wow_mode);
  2120. return -EINVAL;
  2121. }
  2122. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2123. if (!skb)
  2124. return -ENOMEM;
  2125. cmd = (struct wmi_set_wow_mode_cmd *) skb->data;
  2126. cmd->enable_wow = cpu_to_le32(wow_mode);
  2127. cmd->filter = cpu_to_le32(filter);
  2128. cmd->host_req_delay = cpu_to_le16(host_req_delay);
  2129. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID,
  2130. NO_SYNC_WMIFLAG);
  2131. return ret;
  2132. }
  2133. int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
  2134. u8 list_id, u8 filter_size,
  2135. u8 filter_offset, const u8 *filter,
  2136. const u8 *mask)
  2137. {
  2138. struct sk_buff *skb;
  2139. struct wmi_add_wow_pattern_cmd *cmd;
  2140. u16 size;
  2141. u8 *filter_mask;
  2142. int ret;
  2143. /*
  2144. * Allocate additional memory in the buffer to hold
  2145. * filter and mask value, which is twice of filter_size.
  2146. */
  2147. size = sizeof(*cmd) + (2 * filter_size);
  2148. skb = ath6kl_wmi_get_new_buf(size);
  2149. if (!skb)
  2150. return -ENOMEM;
  2151. cmd = (struct wmi_add_wow_pattern_cmd *) skb->data;
  2152. cmd->filter_list_id = list_id;
  2153. cmd->filter_size = filter_size;
  2154. cmd->filter_offset = filter_offset;
  2155. memcpy(cmd->filter, filter, filter_size);
  2156. filter_mask = (u8 *) (cmd->filter + filter_size);
  2157. memcpy(filter_mask, mask, filter_size);
  2158. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID,
  2159. NO_SYNC_WMIFLAG);
  2160. return ret;
  2161. }
  2162. int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
  2163. u16 list_id, u16 filter_id)
  2164. {
  2165. struct sk_buff *skb;
  2166. struct wmi_del_wow_pattern_cmd *cmd;
  2167. int ret;
  2168. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2169. if (!skb)
  2170. return -ENOMEM;
  2171. cmd = (struct wmi_del_wow_pattern_cmd *) skb->data;
  2172. cmd->filter_list_id = cpu_to_le16(list_id);
  2173. cmd->filter_id = cpu_to_le16(filter_id);
  2174. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID,
  2175. NO_SYNC_WMIFLAG);
  2176. return ret;
  2177. }
  2178. static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb,
  2179. enum wmix_command_id cmd_id,
  2180. enum wmi_sync_flag sync_flag)
  2181. {
  2182. struct wmix_cmd_hdr *cmd_hdr;
  2183. int ret;
  2184. skb_push(skb, sizeof(struct wmix_cmd_hdr));
  2185. cmd_hdr = (struct wmix_cmd_hdr *) skb->data;
  2186. cmd_hdr->cmd_id = cpu_to_le32(cmd_id);
  2187. ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag);
  2188. return ret;
  2189. }
  2190. int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source)
  2191. {
  2192. struct sk_buff *skb;
  2193. struct wmix_hb_challenge_resp_cmd *cmd;
  2194. int ret;
  2195. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2196. if (!skb)
  2197. return -ENOMEM;
  2198. cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data;
  2199. cmd->cookie = cpu_to_le32(cookie);
  2200. cmd->source = cpu_to_le32(source);
  2201. ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID,
  2202. NO_SYNC_WMIFLAG);
  2203. return ret;
  2204. }
  2205. int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config)
  2206. {
  2207. struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd;
  2208. struct sk_buff *skb;
  2209. int ret;
  2210. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2211. if (!skb)
  2212. return -ENOMEM;
  2213. cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data;
  2214. cmd->valid = cpu_to_le32(valid);
  2215. cmd->config = cpu_to_le32(config);
  2216. ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID,
  2217. NO_SYNC_WMIFLAG);
  2218. return ret;
  2219. }
  2220. int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx)
  2221. {
  2222. return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID);
  2223. }
  2224. int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM)
  2225. {
  2226. struct sk_buff *skb;
  2227. struct wmi_set_tx_pwr_cmd *cmd;
  2228. int ret;
  2229. skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd));
  2230. if (!skb)
  2231. return -ENOMEM;
  2232. cmd = (struct wmi_set_tx_pwr_cmd *) skb->data;
  2233. cmd->dbM = dbM;
  2234. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID,
  2235. NO_SYNC_WMIFLAG);
  2236. return ret;
  2237. }
  2238. int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx)
  2239. {
  2240. return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID);
  2241. }
  2242. int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi)
  2243. {
  2244. return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID);
  2245. }
  2246. int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status,
  2247. u8 preamble_policy)
  2248. {
  2249. struct sk_buff *skb;
  2250. struct wmi_set_lpreamble_cmd *cmd;
  2251. int ret;
  2252. skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd));
  2253. if (!skb)
  2254. return -ENOMEM;
  2255. cmd = (struct wmi_set_lpreamble_cmd *) skb->data;
  2256. cmd->status = status;
  2257. cmd->preamble_policy = preamble_policy;
  2258. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID,
  2259. NO_SYNC_WMIFLAG);
  2260. return ret;
  2261. }
  2262. int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold)
  2263. {
  2264. struct sk_buff *skb;
  2265. struct wmi_set_rts_cmd *cmd;
  2266. int ret;
  2267. skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd));
  2268. if (!skb)
  2269. return -ENOMEM;
  2270. cmd = (struct wmi_set_rts_cmd *) skb->data;
  2271. cmd->threshold = cpu_to_le16(threshold);
  2272. ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID,
  2273. NO_SYNC_WMIFLAG);
  2274. return ret;
  2275. }
  2276. int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg)
  2277. {
  2278. struct sk_buff *skb;
  2279. struct wmi_set_wmm_txop_cmd *cmd;
  2280. int ret;
  2281. if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)))
  2282. return -EINVAL;
  2283. skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd));
  2284. if (!skb)
  2285. return -ENOMEM;
  2286. cmd = (struct wmi_set_wmm_txop_cmd *) skb->data;
  2287. cmd->txop_enable = cfg;
  2288. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID,
  2289. NO_SYNC_WMIFLAG);
  2290. return ret;
  2291. }
  2292. int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx,
  2293. u8 keep_alive_intvl)
  2294. {
  2295. struct sk_buff *skb;
  2296. struct wmi_set_keepalive_cmd *cmd;
  2297. int ret;
  2298. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2299. if (!skb)
  2300. return -ENOMEM;
  2301. cmd = (struct wmi_set_keepalive_cmd *) skb->data;
  2302. cmd->keep_alive_intvl = keep_alive_intvl;
  2303. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID,
  2304. NO_SYNC_WMIFLAG);
  2305. if (ret == 0)
  2306. ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl);
  2307. return ret;
  2308. }
  2309. int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len)
  2310. {
  2311. struct sk_buff *skb;
  2312. int ret;
  2313. skb = ath6kl_wmi_get_new_buf(len);
  2314. if (!skb)
  2315. return -ENOMEM;
  2316. memcpy(skb->data, buf, len);
  2317. ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG);
  2318. return ret;
  2319. }
  2320. int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on)
  2321. {
  2322. struct sk_buff *skb;
  2323. struct wmi_mcast_filter_cmd *cmd;
  2324. int ret;
  2325. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2326. if (!skb)
  2327. return -ENOMEM;
  2328. cmd = (struct wmi_mcast_filter_cmd *) skb->data;
  2329. cmd->mcast_all_enable = mc_all_on;
  2330. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID,
  2331. NO_SYNC_WMIFLAG);
  2332. return ret;
  2333. }
  2334. int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx,
  2335. u8 *filter, bool add_filter)
  2336. {
  2337. struct sk_buff *skb;
  2338. struct wmi_mcast_filter_add_del_cmd *cmd;
  2339. int ret;
  2340. if ((filter[0] != 0x33 || filter[1] != 0x33) &&
  2341. (filter[0] != 0x01 || filter[1] != 0x00 ||
  2342. filter[2] != 0x5e || filter[3] > 0x7f)) {
  2343. ath6kl_warn("invalid multicast filter address\n");
  2344. return -EINVAL;
  2345. }
  2346. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2347. if (!skb)
  2348. return -ENOMEM;
  2349. cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data;
  2350. memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE);
  2351. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
  2352. add_filter ? WMI_SET_MCAST_FILTER_CMDID :
  2353. WMI_DEL_MCAST_FILTER_CMDID,
  2354. NO_SYNC_WMIFLAG);
  2355. return ret;
  2356. }
  2357. s32 ath6kl_wmi_get_rate(s8 rate_index)
  2358. {
  2359. if (rate_index == RATE_AUTO)
  2360. return 0;
  2361. return wmi_rate_tbl[(u32) rate_index][0];
  2362. }
  2363. static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,
  2364. u32 len)
  2365. {
  2366. struct wmi_pmkid_list_reply *reply;
  2367. u32 expected_len;
  2368. if (len < sizeof(struct wmi_pmkid_list_reply))
  2369. return -EINVAL;
  2370. reply = (struct wmi_pmkid_list_reply *)datap;
  2371. expected_len = sizeof(reply->num_pmkid) +
  2372. le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN;
  2373. if (len < expected_len)
  2374. return -EINVAL;
  2375. return 0;
  2376. }
  2377. static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
  2378. struct ath6kl_vif *vif)
  2379. {
  2380. struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap;
  2381. aggr_recv_addba_req_evt(vif, cmd->tid,
  2382. le16_to_cpu(cmd->st_seq_no), cmd->win_sz);
  2383. return 0;
  2384. }
  2385. static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
  2386. struct ath6kl_vif *vif)
  2387. {
  2388. struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap;
  2389. aggr_recv_delba_req_evt(vif, cmd->tid);
  2390. return 0;
  2391. }
  2392. /* AP mode functions */
  2393. int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx,
  2394. struct wmi_connect_cmd *p)
  2395. {
  2396. struct sk_buff *skb;
  2397. struct wmi_connect_cmd *cm;
  2398. int res;
  2399. skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
  2400. if (!skb)
  2401. return -ENOMEM;
  2402. cm = (struct wmi_connect_cmd *) skb->data;
  2403. memcpy(cm, p, sizeof(*cm));
  2404. res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID,
  2405. NO_SYNC_WMIFLAG);
  2406. ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u "
  2407. "ctrl_flags=0x%x-> res=%d\n",
  2408. __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch),
  2409. le32_to_cpu(p->ctrl_flags), res);
  2410. return res;
  2411. }
  2412. int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac,
  2413. u16 reason)
  2414. {
  2415. struct sk_buff *skb;
  2416. struct wmi_ap_set_mlme_cmd *cm;
  2417. skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
  2418. if (!skb)
  2419. return -ENOMEM;
  2420. cm = (struct wmi_ap_set_mlme_cmd *) skb->data;
  2421. memcpy(cm->mac, mac, ETH_ALEN);
  2422. cm->reason = cpu_to_le16(reason);
  2423. cm->cmd = cmd;
  2424. return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID,
  2425. NO_SYNC_WMIFLAG);
  2426. }
  2427. /* This command will be used to enable/disable AP uAPSD feature */
  2428. int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable)
  2429. {
  2430. struct wmi_ap_set_apsd_cmd *cmd;
  2431. struct sk_buff *skb;
  2432. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2433. if (!skb)
  2434. return -ENOMEM;
  2435. cmd = (struct wmi_ap_set_apsd_cmd *)skb->data;
  2436. cmd->enable = enable;
  2437. return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID,
  2438. NO_SYNC_WMIFLAG);
  2439. }
  2440. int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx,
  2441. u16 aid, u16 bitmap, u32 flags)
  2442. {
  2443. struct wmi_ap_apsd_buffered_traffic_cmd *cmd;
  2444. struct sk_buff *skb;
  2445. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2446. if (!skb)
  2447. return -ENOMEM;
  2448. cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data;
  2449. cmd->aid = cpu_to_le16(aid);
  2450. cmd->bitmap = cpu_to_le16(bitmap);
  2451. cmd->flags = cpu_to_le32(flags);
  2452. return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
  2453. WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID,
  2454. NO_SYNC_WMIFLAG);
  2455. }
  2456. static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len,
  2457. struct ath6kl_vif *vif)
  2458. {
  2459. struct wmi_pspoll_event *ev;
  2460. if (len < sizeof(struct wmi_pspoll_event))
  2461. return -EINVAL;
  2462. ev = (struct wmi_pspoll_event *) datap;
  2463. ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid));
  2464. return 0;
  2465. }
  2466. static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len,
  2467. struct ath6kl_vif *vif)
  2468. {
  2469. ath6kl_dtimexpiry_event(vif);
  2470. return 0;
  2471. }
  2472. int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid,
  2473. bool flag)
  2474. {
  2475. struct sk_buff *skb;
  2476. struct wmi_ap_set_pvb_cmd *cmd;
  2477. int ret;
  2478. skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd));
  2479. if (!skb)
  2480. return -ENOMEM;
  2481. cmd = (struct wmi_ap_set_pvb_cmd *) skb->data;
  2482. cmd->aid = cpu_to_le16(aid);
  2483. cmd->rsvd = cpu_to_le16(0);
  2484. cmd->flag = cpu_to_le32(flag);
  2485. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID,
  2486. NO_SYNC_WMIFLAG);
  2487. return 0;
  2488. }
  2489. int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx,
  2490. u8 rx_meta_ver,
  2491. bool rx_dot11_hdr, bool defrag_on_host)
  2492. {
  2493. struct sk_buff *skb;
  2494. struct wmi_rx_frame_format_cmd *cmd;
  2495. int ret;
  2496. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2497. if (!skb)
  2498. return -ENOMEM;
  2499. cmd = (struct wmi_rx_frame_format_cmd *) skb->data;
  2500. cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0;
  2501. cmd->defrag_on_host = defrag_on_host ? 1 : 0;
  2502. cmd->meta_ver = rx_meta_ver;
  2503. /* Delete the local aggr state, on host */
  2504. ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID,
  2505. NO_SYNC_WMIFLAG);
  2506. return ret;
  2507. }
  2508. int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type,
  2509. const u8 *ie, u8 ie_len)
  2510. {
  2511. struct sk_buff *skb;
  2512. struct wmi_set_appie_cmd *p;
  2513. skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
  2514. if (!skb)
  2515. return -ENOMEM;
  2516. ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u "
  2517. "ie_len=%u\n", mgmt_frm_type, ie_len);
  2518. p = (struct wmi_set_appie_cmd *) skb->data;
  2519. p->mgmt_frm_type = mgmt_frm_type;
  2520. p->ie_len = ie_len;
  2521. if (ie != NULL && ie_len > 0)
  2522. memcpy(p->ie_info, ie, ie_len);
  2523. return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID,
  2524. NO_SYNC_WMIFLAG);
  2525. }
  2526. int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable)
  2527. {
  2528. struct sk_buff *skb;
  2529. struct wmi_disable_11b_rates_cmd *cmd;
  2530. skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
  2531. if (!skb)
  2532. return -ENOMEM;
  2533. ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n",
  2534. disable);
  2535. cmd = (struct wmi_disable_11b_rates_cmd *) skb->data;
  2536. cmd->disable = disable ? 1 : 0;
  2537. return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID,
  2538. NO_SYNC_WMIFLAG);
  2539. }
  2540. int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur)
  2541. {
  2542. struct sk_buff *skb;
  2543. struct wmi_remain_on_chnl_cmd *p;
  2544. skb = ath6kl_wmi_get_new_buf(sizeof(*p));
  2545. if (!skb)
  2546. return -ENOMEM;
  2547. ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n",
  2548. freq, dur);
  2549. p = (struct wmi_remain_on_chnl_cmd *) skb->data;
  2550. p->freq = cpu_to_le32(freq);
  2551. p->duration = cpu_to_le32(dur);
  2552. return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID,
  2553. NO_SYNC_WMIFLAG);
  2554. }
  2555. /* ath6kl_wmi_send_action_cmd is to be deprecated. Use
  2556. * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P
  2557. * mgmt operations using station interface.
  2558. */
  2559. int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq,
  2560. u32 wait, const u8 *data, u16 data_len)
  2561. {
  2562. struct sk_buff *skb;
  2563. struct wmi_send_action_cmd *p;
  2564. u8 *buf;
  2565. if (wait)
  2566. return -EINVAL; /* Offload for wait not supported */
  2567. buf = kmalloc(data_len, GFP_KERNEL);
  2568. if (!buf)
  2569. return -ENOMEM;
  2570. skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
  2571. if (!skb) {
  2572. kfree(buf);
  2573. return -ENOMEM;
  2574. }
  2575. kfree(wmi->last_mgmt_tx_frame);
  2576. memcpy(buf, data, data_len);
  2577. wmi->last_mgmt_tx_frame = buf;
  2578. wmi->last_mgmt_tx_frame_len = data_len;
  2579. ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
  2580. "len=%u\n", id, freq, wait, data_len);
  2581. p = (struct wmi_send_action_cmd *) skb->data;
  2582. p->id = cpu_to_le32(id);
  2583. p->freq = cpu_to_le32(freq);
  2584. p->wait = cpu_to_le32(wait);
  2585. p->len = cpu_to_le16(data_len);
  2586. memcpy(p->data, data, data_len);
  2587. return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID,
  2588. NO_SYNC_WMIFLAG);
  2589. }
  2590. int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq,
  2591. u32 wait, const u8 *data, u16 data_len,
  2592. u32 no_cck)
  2593. {
  2594. struct sk_buff *skb;
  2595. struct wmi_send_mgmt_cmd *p;
  2596. u8 *buf;
  2597. if (wait)
  2598. return -EINVAL; /* Offload for wait not supported */
  2599. buf = kmalloc(data_len, GFP_KERNEL);
  2600. if (!buf)
  2601. return -ENOMEM;
  2602. skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
  2603. if (!skb) {
  2604. kfree(buf);
  2605. return -ENOMEM;
  2606. }
  2607. kfree(wmi->last_mgmt_tx_frame);
  2608. memcpy(buf, data, data_len);
  2609. wmi->last_mgmt_tx_frame = buf;
  2610. wmi->last_mgmt_tx_frame_len = data_len;
  2611. ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
  2612. "len=%u\n", id, freq, wait, data_len);
  2613. p = (struct wmi_send_mgmt_cmd *) skb->data;
  2614. p->id = cpu_to_le32(id);
  2615. p->freq = cpu_to_le32(freq);
  2616. p->wait = cpu_to_le32(wait);
  2617. p->no_cck = cpu_to_le32(no_cck);
  2618. p->len = cpu_to_le16(data_len);
  2619. memcpy(p->data, data, data_len);
  2620. return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_MGMT_CMDID,
  2621. NO_SYNC_WMIFLAG);
  2622. }
  2623. int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq,
  2624. const u8 *dst, const u8 *data,
  2625. u16 data_len)
  2626. {
  2627. struct sk_buff *skb;
  2628. struct wmi_p2p_probe_response_cmd *p;
  2629. size_t cmd_len = sizeof(*p) + data_len;
  2630. if (data_len == 0)
  2631. cmd_len++; /* work around target minimum length requirement */
  2632. skb = ath6kl_wmi_get_new_buf(cmd_len);
  2633. if (!skb)
  2634. return -ENOMEM;
  2635. ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM "
  2636. "len=%u\n", freq, dst, data_len);
  2637. p = (struct wmi_p2p_probe_response_cmd *) skb->data;
  2638. p->freq = cpu_to_le32(freq);
  2639. memcpy(p->destination_addr, dst, ETH_ALEN);
  2640. p->len = cpu_to_le16(data_len);
  2641. memcpy(p->data, data, data_len);
  2642. return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
  2643. WMI_SEND_PROBE_RESPONSE_CMDID,
  2644. NO_SYNC_WMIFLAG);
  2645. }
  2646. int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable)
  2647. {
  2648. struct sk_buff *skb;
  2649. struct wmi_probe_req_report_cmd *p;
  2650. skb = ath6kl_wmi_get_new_buf(sizeof(*p));
  2651. if (!skb)
  2652. return -ENOMEM;
  2653. ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n",
  2654. enable);
  2655. p = (struct wmi_probe_req_report_cmd *) skb->data;
  2656. p->enable = enable ? 1 : 0;
  2657. return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID,
  2658. NO_SYNC_WMIFLAG);
  2659. }
  2660. int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags)
  2661. {
  2662. struct sk_buff *skb;
  2663. struct wmi_get_p2p_info *p;
  2664. skb = ath6kl_wmi_get_new_buf(sizeof(*p));
  2665. if (!skb)
  2666. return -ENOMEM;
  2667. ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n",
  2668. info_req_flags);
  2669. p = (struct wmi_get_p2p_info *) skb->data;
  2670. p->info_req_flags = cpu_to_le32(info_req_flags);
  2671. return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID,
  2672. NO_SYNC_WMIFLAG);
  2673. }
  2674. int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx)
  2675. {
  2676. ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n");
  2677. return ath6kl_wmi_simple_cmd(wmi, if_idx,
  2678. WMI_CANCEL_REMAIN_ON_CHNL_CMDID);
  2679. }
  2680. static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
  2681. {
  2682. struct wmix_cmd_hdr *cmd;
  2683. u32 len;
  2684. u16 id;
  2685. u8 *datap;
  2686. int ret = 0;
  2687. if (skb->len < sizeof(struct wmix_cmd_hdr)) {
  2688. ath6kl_err("bad packet 1\n");
  2689. return -EINVAL;
  2690. }
  2691. cmd = (struct wmix_cmd_hdr *) skb->data;
  2692. id = le32_to_cpu(cmd->cmd_id);
  2693. skb_pull(skb, sizeof(struct wmix_cmd_hdr));
  2694. datap = skb->data;
  2695. len = skb->len;
  2696. switch (id) {
  2697. case WMIX_HB_CHALLENGE_RESP_EVENTID:
  2698. ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n");
  2699. break;
  2700. case WMIX_DBGLOG_EVENTID:
  2701. ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len);
  2702. ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len);
  2703. break;
  2704. default:
  2705. ath6kl_warn("unknown cmd id 0x%x\n", id);
  2706. ret = -EINVAL;
  2707. break;
  2708. }
  2709. return ret;
  2710. }
  2711. static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len)
  2712. {
  2713. return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len);
  2714. }
  2715. /* Control Path */
  2716. int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
  2717. {
  2718. struct wmi_cmd_hdr *cmd;
  2719. struct ath6kl_vif *vif;
  2720. u32 len;
  2721. u16 id;
  2722. u8 if_idx;
  2723. u8 *datap;
  2724. int ret = 0;
  2725. if (WARN_ON(skb == NULL))
  2726. return -EINVAL;
  2727. if (skb->len < sizeof(struct wmi_cmd_hdr)) {
  2728. ath6kl_err("bad packet 1\n");
  2729. dev_kfree_skb(skb);
  2730. return -EINVAL;
  2731. }
  2732. cmd = (struct wmi_cmd_hdr *) skb->data;
  2733. id = le16_to_cpu(cmd->cmd_id);
  2734. if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK;
  2735. skb_pull(skb, sizeof(struct wmi_cmd_hdr));
  2736. datap = skb->data;
  2737. len = skb->len;
  2738. ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len);
  2739. ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ",
  2740. datap, len);
  2741. vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx);
  2742. if (!vif) {
  2743. ath6kl_dbg(ATH6KL_DBG_WMI,
  2744. "Wmi event for unavailable vif, vif_index:%d\n",
  2745. if_idx);
  2746. dev_kfree_skb(skb);
  2747. return -EINVAL;
  2748. }
  2749. switch (id) {
  2750. case WMI_GET_BITRATE_CMDID:
  2751. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n");
  2752. ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len);
  2753. break;
  2754. case WMI_GET_CHANNEL_LIST_CMDID:
  2755. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n");
  2756. ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len);
  2757. break;
  2758. case WMI_GET_TX_PWR_CMDID:
  2759. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n");
  2760. ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len);
  2761. break;
  2762. case WMI_READY_EVENTID:
  2763. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n");
  2764. ret = ath6kl_wmi_ready_event_rx(wmi, datap, len);
  2765. break;
  2766. case WMI_CONNECT_EVENTID:
  2767. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n");
  2768. ret = ath6kl_wmi_connect_event_rx(wmi, datap, len, vif);
  2769. break;
  2770. case WMI_DISCONNECT_EVENTID:
  2771. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n");
  2772. ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif);
  2773. break;
  2774. case WMI_PEER_NODE_EVENTID:
  2775. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n");
  2776. ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len);
  2777. break;
  2778. case WMI_TKIP_MICERR_EVENTID:
  2779. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n");
  2780. ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif);
  2781. break;
  2782. case WMI_BSSINFO_EVENTID:
  2783. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n");
  2784. ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif);
  2785. break;
  2786. case WMI_REGDOMAIN_EVENTID:
  2787. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
  2788. ath6kl_wmi_regdomain_event(wmi, datap, len);
  2789. break;
  2790. case WMI_PSTREAM_TIMEOUT_EVENTID:
  2791. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
  2792. ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len);
  2793. break;
  2794. case WMI_NEIGHBOR_REPORT_EVENTID:
  2795. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n");
  2796. ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len,
  2797. vif);
  2798. break;
  2799. case WMI_SCAN_COMPLETE_EVENTID:
  2800. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n");
  2801. ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif);
  2802. break;
  2803. case WMI_CMDERROR_EVENTID:
  2804. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n");
  2805. ret = ath6kl_wmi_error_event_rx(wmi, datap, len);
  2806. break;
  2807. case WMI_REPORT_STATISTICS_EVENTID:
  2808. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n");
  2809. ret = ath6kl_wmi_stats_event_rx(wmi, datap, len, vif);
  2810. break;
  2811. case WMI_RSSI_THRESHOLD_EVENTID:
  2812. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n");
  2813. ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len);
  2814. break;
  2815. case WMI_ERROR_REPORT_EVENTID:
  2816. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n");
  2817. break;
  2818. case WMI_OPT_RX_FRAME_EVENTID:
  2819. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n");
  2820. /* this event has been deprecated */
  2821. break;
  2822. case WMI_REPORT_ROAM_TBL_EVENTID:
  2823. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n");
  2824. ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len);
  2825. break;
  2826. case WMI_EXTENSION_EVENTID:
  2827. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n");
  2828. ret = ath6kl_wmi_control_rx_xtnd(wmi, skb);
  2829. break;
  2830. case WMI_CAC_EVENTID:
  2831. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n");
  2832. ret = ath6kl_wmi_cac_event_rx(wmi, datap, len, vif);
  2833. break;
  2834. case WMI_CHANNEL_CHANGE_EVENTID:
  2835. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n");
  2836. break;
  2837. case WMI_REPORT_ROAM_DATA_EVENTID:
  2838. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n");
  2839. break;
  2840. case WMI_TEST_EVENTID:
  2841. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n");
  2842. ret = ath6kl_wmi_test_rx(wmi, datap, len);
  2843. break;
  2844. case WMI_GET_FIXRATES_CMDID:
  2845. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n");
  2846. ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len);
  2847. break;
  2848. case WMI_TX_RETRY_ERR_EVENTID:
  2849. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n");
  2850. break;
  2851. case WMI_SNR_THRESHOLD_EVENTID:
  2852. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n");
  2853. ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len);
  2854. break;
  2855. case WMI_LQ_THRESHOLD_EVENTID:
  2856. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n");
  2857. break;
  2858. case WMI_APLIST_EVENTID:
  2859. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n");
  2860. ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len);
  2861. break;
  2862. case WMI_GET_KEEPALIVE_CMDID:
  2863. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n");
  2864. ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len);
  2865. break;
  2866. case WMI_GET_WOW_LIST_EVENTID:
  2867. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n");
  2868. break;
  2869. case WMI_GET_PMKID_LIST_EVENTID:
  2870. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n");
  2871. ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len);
  2872. break;
  2873. case WMI_PSPOLL_EVENTID:
  2874. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n");
  2875. ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif);
  2876. break;
  2877. case WMI_DTIMEXPIRY_EVENTID:
  2878. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n");
  2879. ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif);
  2880. break;
  2881. case WMI_SET_PARAMS_REPLY_EVENTID:
  2882. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n");
  2883. break;
  2884. case WMI_ADDBA_REQ_EVENTID:
  2885. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n");
  2886. ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif);
  2887. break;
  2888. case WMI_ADDBA_RESP_EVENTID:
  2889. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n");
  2890. break;
  2891. case WMI_DELBA_REQ_EVENTID:
  2892. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n");
  2893. ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif);
  2894. break;
  2895. case WMI_REPORT_BTCOEX_CONFIG_EVENTID:
  2896. ath6kl_dbg(ATH6KL_DBG_WMI,
  2897. "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
  2898. break;
  2899. case WMI_REPORT_BTCOEX_STATS_EVENTID:
  2900. ath6kl_dbg(ATH6KL_DBG_WMI,
  2901. "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
  2902. break;
  2903. case WMI_TX_COMPLETE_EVENTID:
  2904. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n");
  2905. ret = ath6kl_wmi_tx_complete_event_rx(datap, len);
  2906. break;
  2907. case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID:
  2908. ath6kl_dbg(ATH6KL_DBG_WMI,
  2909. "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID");
  2910. ret = ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif);
  2911. break;
  2912. case WMI_REMAIN_ON_CHNL_EVENTID:
  2913. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n");
  2914. ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif);
  2915. break;
  2916. case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID:
  2917. ath6kl_dbg(ATH6KL_DBG_WMI,
  2918. "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
  2919. ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap,
  2920. len, vif);
  2921. break;
  2922. case WMI_TX_STATUS_EVENTID:
  2923. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n");
  2924. ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif);
  2925. break;
  2926. case WMI_RX_PROBE_REQ_EVENTID:
  2927. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n");
  2928. ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif);
  2929. break;
  2930. case WMI_P2P_CAPABILITIES_EVENTID:
  2931. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n");
  2932. ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len);
  2933. break;
  2934. case WMI_RX_ACTION_EVENTID:
  2935. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n");
  2936. ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif);
  2937. break;
  2938. case WMI_P2P_INFO_EVENTID:
  2939. ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n");
  2940. ret = ath6kl_wmi_p2p_info_event_rx(datap, len);
  2941. break;
  2942. default:
  2943. ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id);
  2944. ret = -EINVAL;
  2945. break;
  2946. }
  2947. dev_kfree_skb(skb);
  2948. return ret;
  2949. }
  2950. void ath6kl_wmi_reset(struct wmi *wmi)
  2951. {
  2952. spin_lock_bh(&wmi->lock);
  2953. wmi->fat_pipe_exist = 0;
  2954. memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac));
  2955. spin_unlock_bh(&wmi->lock);
  2956. }
  2957. void *ath6kl_wmi_init(struct ath6kl *dev)
  2958. {
  2959. struct wmi *wmi;
  2960. wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL);
  2961. if (!wmi)
  2962. return NULL;
  2963. spin_lock_init(&wmi->lock);
  2964. wmi->parent_dev = dev;
  2965. wmi->pwr_mode = REC_POWER;
  2966. ath6kl_wmi_reset(wmi);
  2967. return wmi;
  2968. }
  2969. void ath6kl_wmi_shutdown(struct wmi *wmi)
  2970. {
  2971. if (!wmi)
  2972. return;
  2973. kfree(wmi->last_mgmt_tx_frame);
  2974. kfree(wmi);
  2975. }