wmi.c 81 KB

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