wmi.c 84 KB

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