wmi-tlv.c 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509
  1. /*
  2. * Copyright (c) 2005-2011 Atheros Communications Inc.
  3. * Copyright (c) 2011-2014 Qualcomm Atheros, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include "core.h"
  18. #include "debug.h"
  19. #include "mac.h"
  20. #include "hw.h"
  21. #include "mac.h"
  22. #include "wmi.h"
  23. #include "wmi-ops.h"
  24. #include "wmi-tlv.h"
  25. #include "p2p.h"
  26. #include "testmode.h"
  27. /***************/
  28. /* TLV helpers */
  29. /**************/
  30. struct wmi_tlv_policy {
  31. size_t min_len;
  32. };
  33. static const struct wmi_tlv_policy wmi_tlv_policies[] = {
  34. [WMI_TLV_TAG_ARRAY_BYTE]
  35. = { .min_len = 0 },
  36. [WMI_TLV_TAG_ARRAY_UINT32]
  37. = { .min_len = 0 },
  38. [WMI_TLV_TAG_STRUCT_SCAN_EVENT]
  39. = { .min_len = sizeof(struct wmi_scan_event) },
  40. [WMI_TLV_TAG_STRUCT_MGMT_RX_HDR]
  41. = { .min_len = sizeof(struct wmi_tlv_mgmt_rx_ev) },
  42. [WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT]
  43. = { .min_len = sizeof(struct wmi_chan_info_event) },
  44. [WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT]
  45. = { .min_len = sizeof(struct wmi_vdev_start_response_event) },
  46. [WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT]
  47. = { .min_len = sizeof(struct wmi_peer_sta_kickout_event) },
  48. [WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT]
  49. = { .min_len = sizeof(struct wmi_host_swba_event) },
  50. [WMI_TLV_TAG_STRUCT_TIM_INFO]
  51. = { .min_len = sizeof(struct wmi_tim_info) },
  52. [WMI_TLV_TAG_STRUCT_P2P_NOA_INFO]
  53. = { .min_len = sizeof(struct wmi_p2p_noa_info) },
  54. [WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT]
  55. = { .min_len = sizeof(struct wmi_tlv_svc_rdy_ev) },
  56. [WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES]
  57. = { .min_len = sizeof(struct hal_reg_capabilities) },
  58. [WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ]
  59. = { .min_len = sizeof(struct wlan_host_mem_req) },
  60. [WMI_TLV_TAG_STRUCT_READY_EVENT]
  61. = { .min_len = sizeof(struct wmi_tlv_rdy_ev) },
  62. [WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT]
  63. = { .min_len = sizeof(struct wmi_tlv_bcn_tx_status_ev) },
  64. [WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT]
  65. = { .min_len = sizeof(struct wmi_tlv_diag_data_ev) },
  66. [WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT]
  67. = { .min_len = sizeof(struct wmi_tlv_p2p_noa_ev) },
  68. [WMI_TLV_TAG_STRUCT_ROAM_EVENT]
  69. = { .min_len = sizeof(struct wmi_tlv_roam_ev) },
  70. [WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO]
  71. = { .min_len = sizeof(struct wmi_tlv_wow_event_info) },
  72. [WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT]
  73. = { .min_len = sizeof(struct wmi_tlv_tx_pause_ev) },
  74. };
  75. static int
  76. ath10k_wmi_tlv_iter(struct ath10k *ar, const void *ptr, size_t len,
  77. int (*iter)(struct ath10k *ar, u16 tag, u16 len,
  78. const void *ptr, void *data),
  79. void *data)
  80. {
  81. const void *begin = ptr;
  82. const struct wmi_tlv *tlv;
  83. u16 tlv_tag, tlv_len;
  84. int ret;
  85. while (len > 0) {
  86. if (len < sizeof(*tlv)) {
  87. ath10k_dbg(ar, ATH10K_DBG_WMI,
  88. "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n",
  89. ptr - begin, len, sizeof(*tlv));
  90. return -EINVAL;
  91. }
  92. tlv = ptr;
  93. tlv_tag = __le16_to_cpu(tlv->tag);
  94. tlv_len = __le16_to_cpu(tlv->len);
  95. ptr += sizeof(*tlv);
  96. len -= sizeof(*tlv);
  97. if (tlv_len > len) {
  98. ath10k_dbg(ar, ATH10K_DBG_WMI,
  99. "wmi tlv parse failure of tag %hhu at byte %zd (%zu bytes left, %hhu expected)\n",
  100. tlv_tag, ptr - begin, len, tlv_len);
  101. return -EINVAL;
  102. }
  103. if (tlv_tag < ARRAY_SIZE(wmi_tlv_policies) &&
  104. wmi_tlv_policies[tlv_tag].min_len &&
  105. wmi_tlv_policies[tlv_tag].min_len > tlv_len) {
  106. ath10k_dbg(ar, ATH10K_DBG_WMI,
  107. "wmi tlv parse failure of tag %hhu at byte %zd (%hhu bytes is less than min length %zu)\n",
  108. tlv_tag, ptr - begin, tlv_len,
  109. wmi_tlv_policies[tlv_tag].min_len);
  110. return -EINVAL;
  111. }
  112. ret = iter(ar, tlv_tag, tlv_len, ptr, data);
  113. if (ret)
  114. return ret;
  115. ptr += tlv_len;
  116. len -= tlv_len;
  117. }
  118. return 0;
  119. }
  120. static int ath10k_wmi_tlv_iter_parse(struct ath10k *ar, u16 tag, u16 len,
  121. const void *ptr, void *data)
  122. {
  123. const void **tb = data;
  124. if (tag < WMI_TLV_TAG_MAX)
  125. tb[tag] = ptr;
  126. return 0;
  127. }
  128. static int ath10k_wmi_tlv_parse(struct ath10k *ar, const void **tb,
  129. const void *ptr, size_t len)
  130. {
  131. return ath10k_wmi_tlv_iter(ar, ptr, len, ath10k_wmi_tlv_iter_parse,
  132. (void *)tb);
  133. }
  134. static const void **
  135. ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr,
  136. size_t len, gfp_t gfp)
  137. {
  138. const void **tb;
  139. int ret;
  140. tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp);
  141. if (!tb)
  142. return ERR_PTR(-ENOMEM);
  143. ret = ath10k_wmi_tlv_parse(ar, tb, ptr, len);
  144. if (ret) {
  145. kfree(tb);
  146. return ERR_PTR(ret);
  147. }
  148. return tb;
  149. }
  150. static u16 ath10k_wmi_tlv_len(const void *ptr)
  151. {
  152. return __le16_to_cpu((((const struct wmi_tlv *)ptr) - 1)->len);
  153. }
  154. /**************/
  155. /* TLV events */
  156. /**************/
  157. static int ath10k_wmi_tlv_event_bcn_tx_status(struct ath10k *ar,
  158. struct sk_buff *skb)
  159. {
  160. const void **tb;
  161. const struct wmi_tlv_bcn_tx_status_ev *ev;
  162. struct ath10k_vif *arvif;
  163. u32 vdev_id, tx_status;
  164. int ret;
  165. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  166. if (IS_ERR(tb)) {
  167. ret = PTR_ERR(tb);
  168. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  169. return ret;
  170. }
  171. ev = tb[WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT];
  172. if (!ev) {
  173. kfree(tb);
  174. return -EPROTO;
  175. }
  176. tx_status = __le32_to_cpu(ev->tx_status);
  177. vdev_id = __le32_to_cpu(ev->vdev_id);
  178. switch (tx_status) {
  179. case WMI_TLV_BCN_TX_STATUS_OK:
  180. break;
  181. case WMI_TLV_BCN_TX_STATUS_XRETRY:
  182. case WMI_TLV_BCN_TX_STATUS_DROP:
  183. case WMI_TLV_BCN_TX_STATUS_FILTERED:
  184. /* FIXME: It's probably worth telling mac80211 to stop the
  185. * interface as it is crippled.
  186. */
  187. ath10k_warn(ar, "received bcn tmpl tx status on vdev %i: %d",
  188. vdev_id, tx_status);
  189. break;
  190. }
  191. arvif = ath10k_get_arvif(ar, vdev_id);
  192. if (arvif && arvif->is_up && arvif->vif->csa_active)
  193. ieee80211_queue_work(ar->hw, &arvif->ap_csa_work);
  194. kfree(tb);
  195. return 0;
  196. }
  197. static int ath10k_wmi_tlv_event_diag_data(struct ath10k *ar,
  198. struct sk_buff *skb)
  199. {
  200. const void **tb;
  201. const struct wmi_tlv_diag_data_ev *ev;
  202. const struct wmi_tlv_diag_item *item;
  203. const void *data;
  204. int ret, num_items, len;
  205. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  206. if (IS_ERR(tb)) {
  207. ret = PTR_ERR(tb);
  208. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  209. return ret;
  210. }
  211. ev = tb[WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT];
  212. data = tb[WMI_TLV_TAG_ARRAY_BYTE];
  213. if (!ev || !data) {
  214. kfree(tb);
  215. return -EPROTO;
  216. }
  217. num_items = __le32_to_cpu(ev->num_items);
  218. len = ath10k_wmi_tlv_len(data);
  219. while (num_items--) {
  220. if (len == 0)
  221. break;
  222. if (len < sizeof(*item)) {
  223. ath10k_warn(ar, "failed to parse diag data: can't fit item header\n");
  224. break;
  225. }
  226. item = data;
  227. if (len < sizeof(*item) + __le16_to_cpu(item->len)) {
  228. ath10k_warn(ar, "failed to parse diag data: item is too long\n");
  229. break;
  230. }
  231. trace_ath10k_wmi_diag_container(ar,
  232. item->type,
  233. __le32_to_cpu(item->timestamp),
  234. __le32_to_cpu(item->code),
  235. __le16_to_cpu(item->len),
  236. item->payload);
  237. len -= sizeof(*item);
  238. len -= roundup(__le16_to_cpu(item->len), 4);
  239. data += sizeof(*item);
  240. data += roundup(__le16_to_cpu(item->len), 4);
  241. }
  242. if (num_items != -1 || len != 0)
  243. ath10k_warn(ar, "failed to parse diag data event: num_items %d len %d\n",
  244. num_items, len);
  245. kfree(tb);
  246. return 0;
  247. }
  248. static int ath10k_wmi_tlv_event_diag(struct ath10k *ar,
  249. struct sk_buff *skb)
  250. {
  251. const void **tb;
  252. const void *data;
  253. int ret, len;
  254. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  255. if (IS_ERR(tb)) {
  256. ret = PTR_ERR(tb);
  257. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  258. return ret;
  259. }
  260. data = tb[WMI_TLV_TAG_ARRAY_BYTE];
  261. if (!data) {
  262. kfree(tb);
  263. return -EPROTO;
  264. }
  265. len = ath10k_wmi_tlv_len(data);
  266. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv diag event len %d\n", len);
  267. trace_ath10k_wmi_diag(ar, data, len);
  268. kfree(tb);
  269. return 0;
  270. }
  271. static int ath10k_wmi_tlv_event_p2p_noa(struct ath10k *ar,
  272. struct sk_buff *skb)
  273. {
  274. const void **tb;
  275. const struct wmi_tlv_p2p_noa_ev *ev;
  276. const struct wmi_p2p_noa_info *noa;
  277. int ret, vdev_id;
  278. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  279. if (IS_ERR(tb)) {
  280. ret = PTR_ERR(tb);
  281. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  282. return ret;
  283. }
  284. ev = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT];
  285. noa = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_INFO];
  286. if (!ev || !noa) {
  287. kfree(tb);
  288. return -EPROTO;
  289. }
  290. vdev_id = __le32_to_cpu(ev->vdev_id);
  291. ath10k_dbg(ar, ATH10K_DBG_WMI,
  292. "wmi tlv p2p noa vdev_id %i descriptors %hhu\n",
  293. vdev_id, noa->num_descriptors);
  294. ath10k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
  295. kfree(tb);
  296. return 0;
  297. }
  298. static int ath10k_wmi_tlv_event_tx_pause(struct ath10k *ar,
  299. struct sk_buff *skb)
  300. {
  301. const void **tb;
  302. const struct wmi_tlv_tx_pause_ev *ev;
  303. int ret, vdev_id;
  304. u32 pause_id, action, vdev_map, peer_id, tid_map;
  305. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  306. if (IS_ERR(tb)) {
  307. ret = PTR_ERR(tb);
  308. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  309. return ret;
  310. }
  311. ev = tb[WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT];
  312. if (!ev) {
  313. kfree(tb);
  314. return -EPROTO;
  315. }
  316. pause_id = __le32_to_cpu(ev->pause_id);
  317. action = __le32_to_cpu(ev->action);
  318. vdev_map = __le32_to_cpu(ev->vdev_map);
  319. peer_id = __le32_to_cpu(ev->peer_id);
  320. tid_map = __le32_to_cpu(ev->tid_map);
  321. ath10k_dbg(ar, ATH10K_DBG_WMI,
  322. "wmi tlv tx pause pause_id %u action %u vdev_map 0x%08x peer_id %u tid_map 0x%08x\n",
  323. pause_id, action, vdev_map, peer_id, tid_map);
  324. switch (pause_id) {
  325. case WMI_TLV_TX_PAUSE_ID_MCC:
  326. case WMI_TLV_TX_PAUSE_ID_P2P_CLI_NOA:
  327. case WMI_TLV_TX_PAUSE_ID_P2P_GO_PS:
  328. case WMI_TLV_TX_PAUSE_ID_AP_PS:
  329. case WMI_TLV_TX_PAUSE_ID_IBSS_PS:
  330. for (vdev_id = 0; vdev_map; vdev_id++) {
  331. if (!(vdev_map & BIT(vdev_id)))
  332. continue;
  333. vdev_map &= ~BIT(vdev_id);
  334. ath10k_mac_handle_tx_pause_vdev(ar, vdev_id, pause_id,
  335. action);
  336. }
  337. break;
  338. case WMI_TLV_TX_PAUSE_ID_AP_PEER_PS:
  339. case WMI_TLV_TX_PAUSE_ID_AP_PEER_UAPSD:
  340. case WMI_TLV_TX_PAUSE_ID_STA_ADD_BA:
  341. case WMI_TLV_TX_PAUSE_ID_HOST:
  342. ath10k_dbg(ar, ATH10K_DBG_MAC,
  343. "mac ignoring unsupported tx pause id %d\n",
  344. pause_id);
  345. break;
  346. default:
  347. ath10k_dbg(ar, ATH10K_DBG_MAC,
  348. "mac ignoring unknown tx pause vdev %d\n",
  349. pause_id);
  350. break;
  351. }
  352. kfree(tb);
  353. return 0;
  354. }
  355. /***********/
  356. /* TLV ops */
  357. /***********/
  358. static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb)
  359. {
  360. struct wmi_cmd_hdr *cmd_hdr;
  361. enum wmi_tlv_event_id id;
  362. bool consumed;
  363. cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
  364. id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
  365. if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
  366. goto out;
  367. trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
  368. consumed = ath10k_tm_event_wmi(ar, id, skb);
  369. /* Ready event must be handled normally also in UTF mode so that we
  370. * know the UTF firmware has booted, others we are just bypass WMI
  371. * events to testmode.
  372. */
  373. if (consumed && id != WMI_TLV_READY_EVENTID) {
  374. ath10k_dbg(ar, ATH10K_DBG_WMI,
  375. "wmi tlv testmode consumed 0x%x\n", id);
  376. goto out;
  377. }
  378. switch (id) {
  379. case WMI_TLV_MGMT_RX_EVENTID:
  380. ath10k_wmi_event_mgmt_rx(ar, skb);
  381. /* mgmt_rx() owns the skb now! */
  382. return;
  383. case WMI_TLV_SCAN_EVENTID:
  384. ath10k_wmi_event_scan(ar, skb);
  385. break;
  386. case WMI_TLV_CHAN_INFO_EVENTID:
  387. ath10k_wmi_event_chan_info(ar, skb);
  388. break;
  389. case WMI_TLV_ECHO_EVENTID:
  390. ath10k_wmi_event_echo(ar, skb);
  391. break;
  392. case WMI_TLV_DEBUG_MESG_EVENTID:
  393. ath10k_wmi_event_debug_mesg(ar, skb);
  394. break;
  395. case WMI_TLV_UPDATE_STATS_EVENTID:
  396. ath10k_wmi_event_update_stats(ar, skb);
  397. break;
  398. case WMI_TLV_VDEV_START_RESP_EVENTID:
  399. ath10k_wmi_event_vdev_start_resp(ar, skb);
  400. break;
  401. case WMI_TLV_VDEV_STOPPED_EVENTID:
  402. ath10k_wmi_event_vdev_stopped(ar, skb);
  403. break;
  404. case WMI_TLV_PEER_STA_KICKOUT_EVENTID:
  405. ath10k_wmi_event_peer_sta_kickout(ar, skb);
  406. break;
  407. case WMI_TLV_HOST_SWBA_EVENTID:
  408. ath10k_wmi_event_host_swba(ar, skb);
  409. break;
  410. case WMI_TLV_TBTTOFFSET_UPDATE_EVENTID:
  411. ath10k_wmi_event_tbttoffset_update(ar, skb);
  412. break;
  413. case WMI_TLV_PHYERR_EVENTID:
  414. ath10k_wmi_event_phyerr(ar, skb);
  415. break;
  416. case WMI_TLV_ROAM_EVENTID:
  417. ath10k_wmi_event_roam(ar, skb);
  418. break;
  419. case WMI_TLV_PROFILE_MATCH:
  420. ath10k_wmi_event_profile_match(ar, skb);
  421. break;
  422. case WMI_TLV_DEBUG_PRINT_EVENTID:
  423. ath10k_wmi_event_debug_print(ar, skb);
  424. break;
  425. case WMI_TLV_PDEV_QVIT_EVENTID:
  426. ath10k_wmi_event_pdev_qvit(ar, skb);
  427. break;
  428. case WMI_TLV_WLAN_PROFILE_DATA_EVENTID:
  429. ath10k_wmi_event_wlan_profile_data(ar, skb);
  430. break;
  431. case WMI_TLV_RTT_MEASUREMENT_REPORT_EVENTID:
  432. ath10k_wmi_event_rtt_measurement_report(ar, skb);
  433. break;
  434. case WMI_TLV_TSF_MEASUREMENT_REPORT_EVENTID:
  435. ath10k_wmi_event_tsf_measurement_report(ar, skb);
  436. break;
  437. case WMI_TLV_RTT_ERROR_REPORT_EVENTID:
  438. ath10k_wmi_event_rtt_error_report(ar, skb);
  439. break;
  440. case WMI_TLV_WOW_WAKEUP_HOST_EVENTID:
  441. ath10k_wmi_event_wow_wakeup_host(ar, skb);
  442. break;
  443. case WMI_TLV_DCS_INTERFERENCE_EVENTID:
  444. ath10k_wmi_event_dcs_interference(ar, skb);
  445. break;
  446. case WMI_TLV_PDEV_TPC_CONFIG_EVENTID:
  447. ath10k_wmi_event_pdev_tpc_config(ar, skb);
  448. break;
  449. case WMI_TLV_PDEV_FTM_INTG_EVENTID:
  450. ath10k_wmi_event_pdev_ftm_intg(ar, skb);
  451. break;
  452. case WMI_TLV_GTK_OFFLOAD_STATUS_EVENTID:
  453. ath10k_wmi_event_gtk_offload_status(ar, skb);
  454. break;
  455. case WMI_TLV_GTK_REKEY_FAIL_EVENTID:
  456. ath10k_wmi_event_gtk_rekey_fail(ar, skb);
  457. break;
  458. case WMI_TLV_TX_DELBA_COMPLETE_EVENTID:
  459. ath10k_wmi_event_delba_complete(ar, skb);
  460. break;
  461. case WMI_TLV_TX_ADDBA_COMPLETE_EVENTID:
  462. ath10k_wmi_event_addba_complete(ar, skb);
  463. break;
  464. case WMI_TLV_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
  465. ath10k_wmi_event_vdev_install_key_complete(ar, skb);
  466. break;
  467. case WMI_TLV_SERVICE_READY_EVENTID:
  468. ath10k_wmi_event_service_ready(ar, skb);
  469. return;
  470. case WMI_TLV_READY_EVENTID:
  471. ath10k_wmi_event_ready(ar, skb);
  472. break;
  473. case WMI_TLV_OFFLOAD_BCN_TX_STATUS_EVENTID:
  474. ath10k_wmi_tlv_event_bcn_tx_status(ar, skb);
  475. break;
  476. case WMI_TLV_DIAG_DATA_CONTAINER_EVENTID:
  477. ath10k_wmi_tlv_event_diag_data(ar, skb);
  478. break;
  479. case WMI_TLV_DIAG_EVENTID:
  480. ath10k_wmi_tlv_event_diag(ar, skb);
  481. break;
  482. case WMI_TLV_P2P_NOA_EVENTID:
  483. ath10k_wmi_tlv_event_p2p_noa(ar, skb);
  484. break;
  485. case WMI_TLV_TX_PAUSE_EVENTID:
  486. ath10k_wmi_tlv_event_tx_pause(ar, skb);
  487. break;
  488. default:
  489. ath10k_warn(ar, "Unknown eventid: %d\n", id);
  490. break;
  491. }
  492. out:
  493. dev_kfree_skb(skb);
  494. }
  495. static int ath10k_wmi_tlv_op_pull_scan_ev(struct ath10k *ar,
  496. struct sk_buff *skb,
  497. struct wmi_scan_ev_arg *arg)
  498. {
  499. const void **tb;
  500. const struct wmi_scan_event *ev;
  501. int ret;
  502. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  503. if (IS_ERR(tb)) {
  504. ret = PTR_ERR(tb);
  505. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  506. return ret;
  507. }
  508. ev = tb[WMI_TLV_TAG_STRUCT_SCAN_EVENT];
  509. if (!ev) {
  510. kfree(tb);
  511. return -EPROTO;
  512. }
  513. arg->event_type = ev->event_type;
  514. arg->reason = ev->reason;
  515. arg->channel_freq = ev->channel_freq;
  516. arg->scan_req_id = ev->scan_req_id;
  517. arg->scan_id = ev->scan_id;
  518. arg->vdev_id = ev->vdev_id;
  519. kfree(tb);
  520. return 0;
  521. }
  522. static int ath10k_wmi_tlv_op_pull_mgmt_rx_ev(struct ath10k *ar,
  523. struct sk_buff *skb,
  524. struct wmi_mgmt_rx_ev_arg *arg)
  525. {
  526. const void **tb;
  527. const struct wmi_tlv_mgmt_rx_ev *ev;
  528. const u8 *frame;
  529. u32 msdu_len;
  530. int ret;
  531. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  532. if (IS_ERR(tb)) {
  533. ret = PTR_ERR(tb);
  534. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  535. return ret;
  536. }
  537. ev = tb[WMI_TLV_TAG_STRUCT_MGMT_RX_HDR];
  538. frame = tb[WMI_TLV_TAG_ARRAY_BYTE];
  539. if (!ev || !frame) {
  540. kfree(tb);
  541. return -EPROTO;
  542. }
  543. arg->channel = ev->channel;
  544. arg->buf_len = ev->buf_len;
  545. arg->status = ev->status;
  546. arg->snr = ev->snr;
  547. arg->phy_mode = ev->phy_mode;
  548. arg->rate = ev->rate;
  549. msdu_len = __le32_to_cpu(arg->buf_len);
  550. if (skb->len < (frame - skb->data) + msdu_len) {
  551. kfree(tb);
  552. return -EPROTO;
  553. }
  554. /* shift the sk_buff to point to `frame` */
  555. skb_trim(skb, 0);
  556. skb_put(skb, frame - skb->data);
  557. skb_pull(skb, frame - skb->data);
  558. skb_put(skb, msdu_len);
  559. kfree(tb);
  560. return 0;
  561. }
  562. static int ath10k_wmi_tlv_op_pull_ch_info_ev(struct ath10k *ar,
  563. struct sk_buff *skb,
  564. struct wmi_ch_info_ev_arg *arg)
  565. {
  566. const void **tb;
  567. const struct wmi_chan_info_event *ev;
  568. int ret;
  569. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  570. if (IS_ERR(tb)) {
  571. ret = PTR_ERR(tb);
  572. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  573. return ret;
  574. }
  575. ev = tb[WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT];
  576. if (!ev) {
  577. kfree(tb);
  578. return -EPROTO;
  579. }
  580. arg->err_code = ev->err_code;
  581. arg->freq = ev->freq;
  582. arg->cmd_flags = ev->cmd_flags;
  583. arg->noise_floor = ev->noise_floor;
  584. arg->rx_clear_count = ev->rx_clear_count;
  585. arg->cycle_count = ev->cycle_count;
  586. kfree(tb);
  587. return 0;
  588. }
  589. static int
  590. ath10k_wmi_tlv_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
  591. struct wmi_vdev_start_ev_arg *arg)
  592. {
  593. const void **tb;
  594. const struct wmi_vdev_start_response_event *ev;
  595. int ret;
  596. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  597. if (IS_ERR(tb)) {
  598. ret = PTR_ERR(tb);
  599. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  600. return ret;
  601. }
  602. ev = tb[WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT];
  603. if (!ev) {
  604. kfree(tb);
  605. return -EPROTO;
  606. }
  607. skb_pull(skb, sizeof(*ev));
  608. arg->vdev_id = ev->vdev_id;
  609. arg->req_id = ev->req_id;
  610. arg->resp_type = ev->resp_type;
  611. arg->status = ev->status;
  612. kfree(tb);
  613. return 0;
  614. }
  615. static int ath10k_wmi_tlv_op_pull_peer_kick_ev(struct ath10k *ar,
  616. struct sk_buff *skb,
  617. struct wmi_peer_kick_ev_arg *arg)
  618. {
  619. const void **tb;
  620. const struct wmi_peer_sta_kickout_event *ev;
  621. int ret;
  622. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  623. if (IS_ERR(tb)) {
  624. ret = PTR_ERR(tb);
  625. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  626. return ret;
  627. }
  628. ev = tb[WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT];
  629. if (!ev) {
  630. kfree(tb);
  631. return -EPROTO;
  632. }
  633. arg->mac_addr = ev->peer_macaddr.addr;
  634. kfree(tb);
  635. return 0;
  636. }
  637. struct wmi_tlv_swba_parse {
  638. const struct wmi_host_swba_event *ev;
  639. bool tim_done;
  640. bool noa_done;
  641. size_t n_tim;
  642. size_t n_noa;
  643. struct wmi_swba_ev_arg *arg;
  644. };
  645. static int ath10k_wmi_tlv_swba_tim_parse(struct ath10k *ar, u16 tag, u16 len,
  646. const void *ptr, void *data)
  647. {
  648. struct wmi_tlv_swba_parse *swba = data;
  649. struct wmi_tim_info_arg *tim_info_arg;
  650. const struct wmi_tim_info *tim_info_ev = ptr;
  651. if (tag != WMI_TLV_TAG_STRUCT_TIM_INFO)
  652. return -EPROTO;
  653. if (swba->n_tim >= ARRAY_SIZE(swba->arg->tim_info))
  654. return -ENOBUFS;
  655. if (__le32_to_cpu(tim_info_ev->tim_len) >
  656. sizeof(tim_info_ev->tim_bitmap)) {
  657. ath10k_warn(ar, "refusing to parse invalid swba structure\n");
  658. return -EPROTO;
  659. }
  660. tim_info_arg = &swba->arg->tim_info[swba->n_tim];
  661. tim_info_arg->tim_len = tim_info_ev->tim_len;
  662. tim_info_arg->tim_mcast = tim_info_ev->tim_mcast;
  663. tim_info_arg->tim_bitmap = tim_info_ev->tim_bitmap;
  664. tim_info_arg->tim_changed = tim_info_ev->tim_changed;
  665. tim_info_arg->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
  666. swba->n_tim++;
  667. return 0;
  668. }
  669. static int ath10k_wmi_tlv_swba_noa_parse(struct ath10k *ar, u16 tag, u16 len,
  670. const void *ptr, void *data)
  671. {
  672. struct wmi_tlv_swba_parse *swba = data;
  673. if (tag != WMI_TLV_TAG_STRUCT_P2P_NOA_INFO)
  674. return -EPROTO;
  675. if (swba->n_noa >= ARRAY_SIZE(swba->arg->noa_info))
  676. return -ENOBUFS;
  677. swba->arg->noa_info[swba->n_noa++] = ptr;
  678. return 0;
  679. }
  680. static int ath10k_wmi_tlv_swba_parse(struct ath10k *ar, u16 tag, u16 len,
  681. const void *ptr, void *data)
  682. {
  683. struct wmi_tlv_swba_parse *swba = data;
  684. int ret;
  685. switch (tag) {
  686. case WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT:
  687. swba->ev = ptr;
  688. break;
  689. case WMI_TLV_TAG_ARRAY_STRUCT:
  690. if (!swba->tim_done) {
  691. swba->tim_done = true;
  692. ret = ath10k_wmi_tlv_iter(ar, ptr, len,
  693. ath10k_wmi_tlv_swba_tim_parse,
  694. swba);
  695. if (ret)
  696. return ret;
  697. } else if (!swba->noa_done) {
  698. swba->noa_done = true;
  699. ret = ath10k_wmi_tlv_iter(ar, ptr, len,
  700. ath10k_wmi_tlv_swba_noa_parse,
  701. swba);
  702. if (ret)
  703. return ret;
  704. }
  705. break;
  706. default:
  707. break;
  708. }
  709. return 0;
  710. }
  711. static int ath10k_wmi_tlv_op_pull_swba_ev(struct ath10k *ar,
  712. struct sk_buff *skb,
  713. struct wmi_swba_ev_arg *arg)
  714. {
  715. struct wmi_tlv_swba_parse swba = { .arg = arg };
  716. u32 map;
  717. size_t n_vdevs;
  718. int ret;
  719. ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len,
  720. ath10k_wmi_tlv_swba_parse, &swba);
  721. if (ret) {
  722. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  723. return ret;
  724. }
  725. if (!swba.ev)
  726. return -EPROTO;
  727. arg->vdev_map = swba.ev->vdev_map;
  728. for (map = __le32_to_cpu(arg->vdev_map), n_vdevs = 0; map; map >>= 1)
  729. if (map & BIT(0))
  730. n_vdevs++;
  731. if (n_vdevs != swba.n_tim ||
  732. n_vdevs != swba.n_noa)
  733. return -EPROTO;
  734. return 0;
  735. }
  736. static int ath10k_wmi_tlv_op_pull_phyerr_ev_hdr(struct ath10k *ar,
  737. struct sk_buff *skb,
  738. struct wmi_phyerr_hdr_arg *arg)
  739. {
  740. const void **tb;
  741. const struct wmi_tlv_phyerr_ev *ev;
  742. const void *phyerrs;
  743. int ret;
  744. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  745. if (IS_ERR(tb)) {
  746. ret = PTR_ERR(tb);
  747. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  748. return ret;
  749. }
  750. ev = tb[WMI_TLV_TAG_STRUCT_COMB_PHYERR_RX_HDR];
  751. phyerrs = tb[WMI_TLV_TAG_ARRAY_BYTE];
  752. if (!ev || !phyerrs) {
  753. kfree(tb);
  754. return -EPROTO;
  755. }
  756. arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
  757. arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
  758. arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
  759. arg->buf_len = __le32_to_cpu(ev->buf_len);
  760. arg->phyerrs = phyerrs;
  761. kfree(tb);
  762. return 0;
  763. }
  764. #define WMI_TLV_ABI_VER_NS0 0x5F414351
  765. #define WMI_TLV_ABI_VER_NS1 0x00004C4D
  766. #define WMI_TLV_ABI_VER_NS2 0x00000000
  767. #define WMI_TLV_ABI_VER_NS3 0x00000000
  768. #define WMI_TLV_ABI_VER0_MAJOR 1
  769. #define WMI_TLV_ABI_VER0_MINOR 0
  770. #define WMI_TLV_ABI_VER0 ((((WMI_TLV_ABI_VER0_MAJOR) << 24) & 0xFF000000) | \
  771. (((WMI_TLV_ABI_VER0_MINOR) << 0) & 0x00FFFFFF))
  772. #define WMI_TLV_ABI_VER1 53
  773. static int
  774. ath10k_wmi_tlv_parse_mem_reqs(struct ath10k *ar, u16 tag, u16 len,
  775. const void *ptr, void *data)
  776. {
  777. struct wmi_svc_rdy_ev_arg *arg = data;
  778. int i;
  779. if (tag != WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ)
  780. return -EPROTO;
  781. for (i = 0; i < ARRAY_SIZE(arg->mem_reqs); i++) {
  782. if (!arg->mem_reqs[i]) {
  783. arg->mem_reqs[i] = ptr;
  784. return 0;
  785. }
  786. }
  787. return -ENOMEM;
  788. }
  789. static int ath10k_wmi_tlv_op_pull_svc_rdy_ev(struct ath10k *ar,
  790. struct sk_buff *skb,
  791. struct wmi_svc_rdy_ev_arg *arg)
  792. {
  793. const void **tb;
  794. const struct hal_reg_capabilities *reg;
  795. const struct wmi_tlv_svc_rdy_ev *ev;
  796. const __le32 *svc_bmap;
  797. const struct wlan_host_mem_req *mem_reqs;
  798. int ret;
  799. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  800. if (IS_ERR(tb)) {
  801. ret = PTR_ERR(tb);
  802. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  803. return ret;
  804. }
  805. ev = tb[WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT];
  806. reg = tb[WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES];
  807. svc_bmap = tb[WMI_TLV_TAG_ARRAY_UINT32];
  808. mem_reqs = tb[WMI_TLV_TAG_ARRAY_STRUCT];
  809. if (!ev || !reg || !svc_bmap || !mem_reqs) {
  810. kfree(tb);
  811. return -EPROTO;
  812. }
  813. /* This is an internal ABI compatibility check for WMI TLV so check it
  814. * here instead of the generic WMI code.
  815. */
  816. ath10k_dbg(ar, ATH10K_DBG_WMI,
  817. "wmi tlv abi 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x\n",
  818. __le32_to_cpu(ev->abi.abi_ver0), WMI_TLV_ABI_VER0,
  819. __le32_to_cpu(ev->abi.abi_ver_ns0), WMI_TLV_ABI_VER_NS0,
  820. __le32_to_cpu(ev->abi.abi_ver_ns1), WMI_TLV_ABI_VER_NS1,
  821. __le32_to_cpu(ev->abi.abi_ver_ns2), WMI_TLV_ABI_VER_NS2,
  822. __le32_to_cpu(ev->abi.abi_ver_ns3), WMI_TLV_ABI_VER_NS3);
  823. if (__le32_to_cpu(ev->abi.abi_ver0) != WMI_TLV_ABI_VER0 ||
  824. __le32_to_cpu(ev->abi.abi_ver_ns0) != WMI_TLV_ABI_VER_NS0 ||
  825. __le32_to_cpu(ev->abi.abi_ver_ns1) != WMI_TLV_ABI_VER_NS1 ||
  826. __le32_to_cpu(ev->abi.abi_ver_ns2) != WMI_TLV_ABI_VER_NS2 ||
  827. __le32_to_cpu(ev->abi.abi_ver_ns3) != WMI_TLV_ABI_VER_NS3) {
  828. kfree(tb);
  829. return -ENOTSUPP;
  830. }
  831. arg->min_tx_power = ev->hw_min_tx_power;
  832. arg->max_tx_power = ev->hw_max_tx_power;
  833. arg->ht_cap = ev->ht_cap_info;
  834. arg->vht_cap = ev->vht_cap_info;
  835. arg->sw_ver0 = ev->abi.abi_ver0;
  836. arg->sw_ver1 = ev->abi.abi_ver1;
  837. arg->fw_build = ev->fw_build_vers;
  838. arg->phy_capab = ev->phy_capability;
  839. arg->num_rf_chains = ev->num_rf_chains;
  840. arg->eeprom_rd = reg->eeprom_rd;
  841. arg->num_mem_reqs = ev->num_mem_reqs;
  842. arg->service_map = svc_bmap;
  843. arg->service_map_len = ath10k_wmi_tlv_len(svc_bmap);
  844. ret = ath10k_wmi_tlv_iter(ar, mem_reqs, ath10k_wmi_tlv_len(mem_reqs),
  845. ath10k_wmi_tlv_parse_mem_reqs, arg);
  846. if (ret) {
  847. kfree(tb);
  848. ath10k_warn(ar, "failed to parse mem_reqs tlv: %d\n", ret);
  849. return ret;
  850. }
  851. kfree(tb);
  852. return 0;
  853. }
  854. static int ath10k_wmi_tlv_op_pull_rdy_ev(struct ath10k *ar,
  855. struct sk_buff *skb,
  856. struct wmi_rdy_ev_arg *arg)
  857. {
  858. const void **tb;
  859. const struct wmi_tlv_rdy_ev *ev;
  860. int ret;
  861. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  862. if (IS_ERR(tb)) {
  863. ret = PTR_ERR(tb);
  864. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  865. return ret;
  866. }
  867. ev = tb[WMI_TLV_TAG_STRUCT_READY_EVENT];
  868. if (!ev) {
  869. kfree(tb);
  870. return -EPROTO;
  871. }
  872. arg->sw_version = ev->abi.abi_ver0;
  873. arg->abi_version = ev->abi.abi_ver1;
  874. arg->status = ev->status;
  875. arg->mac_addr = ev->mac_addr.addr;
  876. kfree(tb);
  877. return 0;
  878. }
  879. static void ath10k_wmi_tlv_pull_vdev_stats(const struct wmi_tlv_vdev_stats *src,
  880. struct ath10k_fw_stats_vdev *dst)
  881. {
  882. int i;
  883. dst->vdev_id = __le32_to_cpu(src->vdev_id);
  884. dst->beacon_snr = __le32_to_cpu(src->beacon_snr);
  885. dst->data_snr = __le32_to_cpu(src->data_snr);
  886. dst->num_rx_frames = __le32_to_cpu(src->num_rx_frames);
  887. dst->num_rts_fail = __le32_to_cpu(src->num_rts_fail);
  888. dst->num_rts_success = __le32_to_cpu(src->num_rts_success);
  889. dst->num_rx_err = __le32_to_cpu(src->num_rx_err);
  890. dst->num_rx_discard = __le32_to_cpu(src->num_rx_discard);
  891. dst->num_tx_not_acked = __le32_to_cpu(src->num_tx_not_acked);
  892. for (i = 0; i < ARRAY_SIZE(src->num_tx_frames); i++)
  893. dst->num_tx_frames[i] =
  894. __le32_to_cpu(src->num_tx_frames[i]);
  895. for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_retries); i++)
  896. dst->num_tx_frames_retries[i] =
  897. __le32_to_cpu(src->num_tx_frames_retries[i]);
  898. for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_failures); i++)
  899. dst->num_tx_frames_failures[i] =
  900. __le32_to_cpu(src->num_tx_frames_failures[i]);
  901. for (i = 0; i < ARRAY_SIZE(src->tx_rate_history); i++)
  902. dst->tx_rate_history[i] =
  903. __le32_to_cpu(src->tx_rate_history[i]);
  904. for (i = 0; i < ARRAY_SIZE(src->beacon_rssi_history); i++)
  905. dst->beacon_rssi_history[i] =
  906. __le32_to_cpu(src->beacon_rssi_history[i]);
  907. }
  908. static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
  909. struct sk_buff *skb,
  910. struct ath10k_fw_stats *stats)
  911. {
  912. const void **tb;
  913. const struct wmi_tlv_stats_ev *ev;
  914. const void *data;
  915. u32 num_pdev_stats;
  916. u32 num_vdev_stats;
  917. u32 num_peer_stats;
  918. u32 num_bcnflt_stats;
  919. u32 num_chan_stats;
  920. size_t data_len;
  921. int ret;
  922. int i;
  923. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  924. if (IS_ERR(tb)) {
  925. ret = PTR_ERR(tb);
  926. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  927. return ret;
  928. }
  929. ev = tb[WMI_TLV_TAG_STRUCT_STATS_EVENT];
  930. data = tb[WMI_TLV_TAG_ARRAY_BYTE];
  931. if (!ev || !data) {
  932. kfree(tb);
  933. return -EPROTO;
  934. }
  935. data_len = ath10k_wmi_tlv_len(data);
  936. num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
  937. num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
  938. num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
  939. num_bcnflt_stats = __le32_to_cpu(ev->num_bcnflt_stats);
  940. num_chan_stats = __le32_to_cpu(ev->num_chan_stats);
  941. ath10k_dbg(ar, ATH10K_DBG_WMI,
  942. "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i\n",
  943. num_pdev_stats, num_vdev_stats, num_peer_stats,
  944. num_bcnflt_stats, num_chan_stats);
  945. for (i = 0; i < num_pdev_stats; i++) {
  946. const struct wmi_pdev_stats *src;
  947. struct ath10k_fw_stats_pdev *dst;
  948. src = data;
  949. if (data_len < sizeof(*src)) {
  950. kfree(tb);
  951. return -EPROTO;
  952. }
  953. data += sizeof(*src);
  954. data_len -= sizeof(*src);
  955. dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
  956. if (!dst)
  957. continue;
  958. ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
  959. ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
  960. ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
  961. list_add_tail(&dst->list, &stats->pdevs);
  962. }
  963. for (i = 0; i < num_vdev_stats; i++) {
  964. const struct wmi_tlv_vdev_stats *src;
  965. struct ath10k_fw_stats_vdev *dst;
  966. src = data;
  967. if (data_len < sizeof(*src)) {
  968. kfree(tb);
  969. return -EPROTO;
  970. }
  971. data += sizeof(*src);
  972. data_len -= sizeof(*src);
  973. dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
  974. if (!dst)
  975. continue;
  976. ath10k_wmi_tlv_pull_vdev_stats(src, dst);
  977. list_add_tail(&dst->list, &stats->vdevs);
  978. }
  979. for (i = 0; i < num_peer_stats; i++) {
  980. const struct wmi_10x_peer_stats *src;
  981. struct ath10k_fw_stats_peer *dst;
  982. src = data;
  983. if (data_len < sizeof(*src)) {
  984. kfree(tb);
  985. return -EPROTO;
  986. }
  987. data += sizeof(*src);
  988. data_len -= sizeof(*src);
  989. dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
  990. if (!dst)
  991. continue;
  992. ath10k_wmi_pull_peer_stats(&src->old, dst);
  993. dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
  994. list_add_tail(&dst->list, &stats->peers);
  995. }
  996. kfree(tb);
  997. return 0;
  998. }
  999. static int ath10k_wmi_tlv_op_pull_roam_ev(struct ath10k *ar,
  1000. struct sk_buff *skb,
  1001. struct wmi_roam_ev_arg *arg)
  1002. {
  1003. const void **tb;
  1004. const struct wmi_tlv_roam_ev *ev;
  1005. int ret;
  1006. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  1007. if (IS_ERR(tb)) {
  1008. ret = PTR_ERR(tb);
  1009. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  1010. return ret;
  1011. }
  1012. ev = tb[WMI_TLV_TAG_STRUCT_ROAM_EVENT];
  1013. if (!ev) {
  1014. kfree(tb);
  1015. return -EPROTO;
  1016. }
  1017. arg->vdev_id = ev->vdev_id;
  1018. arg->reason = ev->reason;
  1019. arg->rssi = ev->rssi;
  1020. kfree(tb);
  1021. return 0;
  1022. }
  1023. static int
  1024. ath10k_wmi_tlv_op_pull_wow_ev(struct ath10k *ar, struct sk_buff *skb,
  1025. struct wmi_wow_ev_arg *arg)
  1026. {
  1027. const void **tb;
  1028. const struct wmi_tlv_wow_event_info *ev;
  1029. int ret;
  1030. tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
  1031. if (IS_ERR(tb)) {
  1032. ret = PTR_ERR(tb);
  1033. ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
  1034. return ret;
  1035. }
  1036. ev = tb[WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO];
  1037. if (!ev) {
  1038. kfree(tb);
  1039. return -EPROTO;
  1040. }
  1041. arg->vdev_id = __le32_to_cpu(ev->vdev_id);
  1042. arg->flag = __le32_to_cpu(ev->flag);
  1043. arg->wake_reason = __le32_to_cpu(ev->wake_reason);
  1044. arg->data_len = __le32_to_cpu(ev->data_len);
  1045. kfree(tb);
  1046. return 0;
  1047. }
  1048. static struct sk_buff *
  1049. ath10k_wmi_tlv_op_gen_pdev_suspend(struct ath10k *ar, u32 opt)
  1050. {
  1051. struct wmi_tlv_pdev_suspend *cmd;
  1052. struct wmi_tlv *tlv;
  1053. struct sk_buff *skb;
  1054. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1055. if (!skb)
  1056. return ERR_PTR(-ENOMEM);
  1057. tlv = (void *)skb->data;
  1058. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SUSPEND_CMD);
  1059. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1060. cmd = (void *)tlv->value;
  1061. cmd->opt = __cpu_to_le32(opt);
  1062. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev suspend\n");
  1063. return skb;
  1064. }
  1065. static struct sk_buff *
  1066. ath10k_wmi_tlv_op_gen_pdev_resume(struct ath10k *ar)
  1067. {
  1068. struct wmi_tlv_resume_cmd *cmd;
  1069. struct wmi_tlv *tlv;
  1070. struct sk_buff *skb;
  1071. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1072. if (!skb)
  1073. return ERR_PTR(-ENOMEM);
  1074. tlv = (void *)skb->data;
  1075. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_RESUME_CMD);
  1076. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1077. cmd = (void *)tlv->value;
  1078. cmd->reserved = __cpu_to_le32(0);
  1079. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev resume\n");
  1080. return skb;
  1081. }
  1082. static struct sk_buff *
  1083. ath10k_wmi_tlv_op_gen_pdev_set_rd(struct ath10k *ar,
  1084. u16 rd, u16 rd2g, u16 rd5g,
  1085. u16 ctl2g, u16 ctl5g,
  1086. enum wmi_dfs_region dfs_reg)
  1087. {
  1088. struct wmi_tlv_pdev_set_rd_cmd *cmd;
  1089. struct wmi_tlv *tlv;
  1090. struct sk_buff *skb;
  1091. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1092. if (!skb)
  1093. return ERR_PTR(-ENOMEM);
  1094. tlv = (void *)skb->data;
  1095. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_REGDOMAIN_CMD);
  1096. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1097. cmd = (void *)tlv->value;
  1098. cmd->regd = __cpu_to_le32(rd);
  1099. cmd->regd_2ghz = __cpu_to_le32(rd2g);
  1100. cmd->regd_5ghz = __cpu_to_le32(rd5g);
  1101. cmd->conform_limit_2ghz = __cpu_to_le32(rd2g);
  1102. cmd->conform_limit_5ghz = __cpu_to_le32(rd5g);
  1103. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set rd\n");
  1104. return skb;
  1105. }
  1106. static enum wmi_txbf_conf ath10k_wmi_tlv_txbf_conf_scheme(struct ath10k *ar)
  1107. {
  1108. return WMI_TXBF_CONF_AFTER_ASSOC;
  1109. }
  1110. static struct sk_buff *
  1111. ath10k_wmi_tlv_op_gen_pdev_set_param(struct ath10k *ar, u32 param_id,
  1112. u32 param_value)
  1113. {
  1114. struct wmi_tlv_pdev_set_param_cmd *cmd;
  1115. struct wmi_tlv *tlv;
  1116. struct sk_buff *skb;
  1117. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1118. if (!skb)
  1119. return ERR_PTR(-ENOMEM);
  1120. tlv = (void *)skb->data;
  1121. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_PARAM_CMD);
  1122. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1123. cmd = (void *)tlv->value;
  1124. cmd->param_id = __cpu_to_le32(param_id);
  1125. cmd->param_value = __cpu_to_le32(param_value);
  1126. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set param\n");
  1127. return skb;
  1128. }
  1129. static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct ath10k *ar)
  1130. {
  1131. struct sk_buff *skb;
  1132. struct wmi_tlv *tlv;
  1133. struct wmi_tlv_init_cmd *cmd;
  1134. struct wmi_tlv_resource_config *cfg;
  1135. struct wmi_host_mem_chunks *chunks;
  1136. size_t len, chunks_len;
  1137. void *ptr;
  1138. chunks_len = ar->wmi.num_mem_chunks * sizeof(struct host_memory_chunk);
  1139. len = (sizeof(*tlv) + sizeof(*cmd)) +
  1140. (sizeof(*tlv) + sizeof(*cfg)) +
  1141. (sizeof(*tlv) + chunks_len);
  1142. skb = ath10k_wmi_alloc_skb(ar, len);
  1143. if (!skb)
  1144. return ERR_PTR(-ENOMEM);
  1145. ptr = skb->data;
  1146. tlv = ptr;
  1147. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_INIT_CMD);
  1148. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1149. cmd = (void *)tlv->value;
  1150. ptr += sizeof(*tlv);
  1151. ptr += sizeof(*cmd);
  1152. tlv = ptr;
  1153. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG);
  1154. tlv->len = __cpu_to_le16(sizeof(*cfg));
  1155. cfg = (void *)tlv->value;
  1156. ptr += sizeof(*tlv);
  1157. ptr += sizeof(*cfg);
  1158. tlv = ptr;
  1159. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  1160. tlv->len = __cpu_to_le16(chunks_len);
  1161. chunks = (void *)tlv->value;
  1162. ptr += sizeof(*tlv);
  1163. ptr += chunks_len;
  1164. cmd->abi.abi_ver0 = __cpu_to_le32(WMI_TLV_ABI_VER0);
  1165. cmd->abi.abi_ver1 = __cpu_to_le32(WMI_TLV_ABI_VER1);
  1166. cmd->abi.abi_ver_ns0 = __cpu_to_le32(WMI_TLV_ABI_VER_NS0);
  1167. cmd->abi.abi_ver_ns1 = __cpu_to_le32(WMI_TLV_ABI_VER_NS1);
  1168. cmd->abi.abi_ver_ns2 = __cpu_to_le32(WMI_TLV_ABI_VER_NS2);
  1169. cmd->abi.abi_ver_ns3 = __cpu_to_le32(WMI_TLV_ABI_VER_NS3);
  1170. cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
  1171. cfg->num_vdevs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
  1172. cfg->num_peers = __cpu_to_le32(TARGET_TLV_NUM_PEERS);
  1173. if (test_bit(WMI_SERVICE_RX_FULL_REORDER, ar->wmi.svc_map)) {
  1174. cfg->num_offload_peers = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
  1175. cfg->num_offload_reorder_bufs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
  1176. } else {
  1177. cfg->num_offload_peers = __cpu_to_le32(0);
  1178. cfg->num_offload_reorder_bufs = __cpu_to_le32(0);
  1179. }
  1180. cfg->num_peer_keys = __cpu_to_le32(2);
  1181. cfg->num_tids = __cpu_to_le32(TARGET_TLV_NUM_TIDS);
  1182. cfg->ast_skid_limit = __cpu_to_le32(0x10);
  1183. cfg->tx_chain_mask = __cpu_to_le32(0x7);
  1184. cfg->rx_chain_mask = __cpu_to_le32(0x7);
  1185. cfg->rx_timeout_pri[0] = __cpu_to_le32(0x64);
  1186. cfg->rx_timeout_pri[1] = __cpu_to_le32(0x64);
  1187. cfg->rx_timeout_pri[2] = __cpu_to_le32(0x64);
  1188. cfg->rx_timeout_pri[3] = __cpu_to_le32(0x28);
  1189. cfg->rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
  1190. cfg->scan_max_pending_reqs = __cpu_to_le32(4);
  1191. cfg->bmiss_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
  1192. cfg->roam_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
  1193. cfg->roam_offload_max_ap_profiles = __cpu_to_le32(8);
  1194. cfg->num_mcast_groups = __cpu_to_le32(0);
  1195. cfg->num_mcast_table_elems = __cpu_to_le32(0);
  1196. cfg->mcast2ucast_mode = __cpu_to_le32(0);
  1197. cfg->tx_dbg_log_size = __cpu_to_le32(0x400);
  1198. cfg->num_wds_entries = __cpu_to_le32(0x20);
  1199. cfg->dma_burst_size = __cpu_to_le32(0);
  1200. cfg->mac_aggr_delim = __cpu_to_le32(0);
  1201. cfg->rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(0);
  1202. cfg->vow_config = __cpu_to_le32(0);
  1203. cfg->gtk_offload_max_vdev = __cpu_to_le32(2);
  1204. cfg->num_msdu_desc = __cpu_to_le32(TARGET_TLV_NUM_MSDU_DESC);
  1205. cfg->max_frag_entries = __cpu_to_le32(2);
  1206. cfg->num_tdls_vdevs = __cpu_to_le32(TARGET_TLV_NUM_TDLS_VDEVS);
  1207. cfg->num_tdls_conn_table_entries = __cpu_to_le32(0x20);
  1208. cfg->beacon_tx_offload_max_vdev = __cpu_to_le32(2);
  1209. cfg->num_multicast_filter_entries = __cpu_to_le32(5);
  1210. cfg->num_wow_filters = __cpu_to_le32(ar->wow.max_num_patterns);
  1211. cfg->num_keep_alive_pattern = __cpu_to_le32(6);
  1212. cfg->keep_alive_pattern_size = __cpu_to_le32(0);
  1213. cfg->max_tdls_concurrent_sleep_sta = __cpu_to_le32(1);
  1214. cfg->max_tdls_concurrent_buffer_sta = __cpu_to_le32(1);
  1215. cfg->wmi_send_separate = __cpu_to_le32(0);
  1216. cfg->num_ocb_vdevs = __cpu_to_le32(0);
  1217. cfg->num_ocb_channels = __cpu_to_le32(0);
  1218. cfg->num_ocb_schedules = __cpu_to_le32(0);
  1219. cfg->host_capab = __cpu_to_le32(0);
  1220. ath10k_wmi_put_host_mem_chunks(ar, chunks);
  1221. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv init\n");
  1222. return skb;
  1223. }
  1224. static struct sk_buff *
  1225. ath10k_wmi_tlv_op_gen_start_scan(struct ath10k *ar,
  1226. const struct wmi_start_scan_arg *arg)
  1227. {
  1228. struct wmi_tlv_start_scan_cmd *cmd;
  1229. struct wmi_tlv *tlv;
  1230. struct sk_buff *skb;
  1231. size_t len, chan_len, ssid_len, bssid_len, ie_len;
  1232. __le32 *chans;
  1233. struct wmi_ssid *ssids;
  1234. struct wmi_mac_addr *addrs;
  1235. void *ptr;
  1236. int i, ret;
  1237. ret = ath10k_wmi_start_scan_verify(arg);
  1238. if (ret)
  1239. return ERR_PTR(ret);
  1240. chan_len = arg->n_channels * sizeof(__le32);
  1241. ssid_len = arg->n_ssids * sizeof(struct wmi_ssid);
  1242. bssid_len = arg->n_bssids * sizeof(struct wmi_mac_addr);
  1243. ie_len = roundup(arg->ie_len, 4);
  1244. len = (sizeof(*tlv) + sizeof(*cmd)) +
  1245. sizeof(*tlv) + chan_len +
  1246. sizeof(*tlv) + ssid_len +
  1247. sizeof(*tlv) + bssid_len +
  1248. sizeof(*tlv) + ie_len;
  1249. skb = ath10k_wmi_alloc_skb(ar, len);
  1250. if (!skb)
  1251. return ERR_PTR(-ENOMEM);
  1252. ptr = (void *)skb->data;
  1253. tlv = ptr;
  1254. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_START_SCAN_CMD);
  1255. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1256. cmd = (void *)tlv->value;
  1257. ath10k_wmi_put_start_scan_common(&cmd->common, arg);
  1258. cmd->burst_duration_ms = __cpu_to_le32(arg->burst_duration_ms);
  1259. cmd->num_channels = __cpu_to_le32(arg->n_channels);
  1260. cmd->num_ssids = __cpu_to_le32(arg->n_ssids);
  1261. cmd->num_bssids = __cpu_to_le32(arg->n_bssids);
  1262. cmd->ie_len = __cpu_to_le32(arg->ie_len);
  1263. cmd->num_probes = __cpu_to_le32(3);
  1264. /* FIXME: There are some scan flag inconsistencies across firmwares,
  1265. * e.g. WMI-TLV inverts the logic behind the following flag.
  1266. */
  1267. cmd->common.scan_ctrl_flags ^= __cpu_to_le32(WMI_SCAN_FILTER_PROBE_REQ);
  1268. ptr += sizeof(*tlv);
  1269. ptr += sizeof(*cmd);
  1270. tlv = ptr;
  1271. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
  1272. tlv->len = __cpu_to_le16(chan_len);
  1273. chans = (void *)tlv->value;
  1274. for (i = 0; i < arg->n_channels; i++)
  1275. chans[i] = __cpu_to_le32(arg->channels[i]);
  1276. ptr += sizeof(*tlv);
  1277. ptr += chan_len;
  1278. tlv = ptr;
  1279. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
  1280. tlv->len = __cpu_to_le16(ssid_len);
  1281. ssids = (void *)tlv->value;
  1282. for (i = 0; i < arg->n_ssids; i++) {
  1283. ssids[i].ssid_len = __cpu_to_le32(arg->ssids[i].len);
  1284. memcpy(ssids[i].ssid, arg->ssids[i].ssid, arg->ssids[i].len);
  1285. }
  1286. ptr += sizeof(*tlv);
  1287. ptr += ssid_len;
  1288. tlv = ptr;
  1289. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
  1290. tlv->len = __cpu_to_le16(bssid_len);
  1291. addrs = (void *)tlv->value;
  1292. for (i = 0; i < arg->n_bssids; i++)
  1293. ether_addr_copy(addrs[i].addr, arg->bssids[i].bssid);
  1294. ptr += sizeof(*tlv);
  1295. ptr += bssid_len;
  1296. tlv = ptr;
  1297. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
  1298. tlv->len = __cpu_to_le16(ie_len);
  1299. memcpy(tlv->value, arg->ie, arg->ie_len);
  1300. ptr += sizeof(*tlv);
  1301. ptr += ie_len;
  1302. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start scan\n");
  1303. return skb;
  1304. }
  1305. static struct sk_buff *
  1306. ath10k_wmi_tlv_op_gen_stop_scan(struct ath10k *ar,
  1307. const struct wmi_stop_scan_arg *arg)
  1308. {
  1309. struct wmi_stop_scan_cmd *cmd;
  1310. struct wmi_tlv *tlv;
  1311. struct sk_buff *skb;
  1312. u32 scan_id;
  1313. u32 req_id;
  1314. if (arg->req_id > 0xFFF)
  1315. return ERR_PTR(-EINVAL);
  1316. if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
  1317. return ERR_PTR(-EINVAL);
  1318. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1319. if (!skb)
  1320. return ERR_PTR(-ENOMEM);
  1321. scan_id = arg->u.scan_id;
  1322. scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
  1323. req_id = arg->req_id;
  1324. req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
  1325. tlv = (void *)skb->data;
  1326. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STOP_SCAN_CMD);
  1327. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1328. cmd = (void *)tlv->value;
  1329. cmd->req_type = __cpu_to_le32(arg->req_type);
  1330. cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
  1331. cmd->scan_id = __cpu_to_le32(scan_id);
  1332. cmd->scan_req_id = __cpu_to_le32(req_id);
  1333. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop scan\n");
  1334. return skb;
  1335. }
  1336. static struct sk_buff *
  1337. ath10k_wmi_tlv_op_gen_vdev_create(struct ath10k *ar,
  1338. u32 vdev_id,
  1339. enum wmi_vdev_type vdev_type,
  1340. enum wmi_vdev_subtype vdev_subtype,
  1341. const u8 mac_addr[ETH_ALEN])
  1342. {
  1343. struct wmi_vdev_create_cmd *cmd;
  1344. struct wmi_tlv *tlv;
  1345. struct sk_buff *skb;
  1346. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1347. if (!skb)
  1348. return ERR_PTR(-ENOMEM);
  1349. tlv = (void *)skb->data;
  1350. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_CREATE_CMD);
  1351. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1352. cmd = (void *)tlv->value;
  1353. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1354. cmd->vdev_type = __cpu_to_le32(vdev_type);
  1355. cmd->vdev_subtype = __cpu_to_le32(vdev_subtype);
  1356. ether_addr_copy(cmd->vdev_macaddr.addr, mac_addr);
  1357. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev create\n");
  1358. return skb;
  1359. }
  1360. static struct sk_buff *
  1361. ath10k_wmi_tlv_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
  1362. {
  1363. struct wmi_vdev_delete_cmd *cmd;
  1364. struct wmi_tlv *tlv;
  1365. struct sk_buff *skb;
  1366. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1367. if (!skb)
  1368. return ERR_PTR(-ENOMEM);
  1369. tlv = (void *)skb->data;
  1370. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DELETE_CMD);
  1371. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1372. cmd = (void *)tlv->value;
  1373. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1374. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev delete\n");
  1375. return skb;
  1376. }
  1377. static struct sk_buff *
  1378. ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k *ar,
  1379. const struct wmi_vdev_start_request_arg *arg,
  1380. bool restart)
  1381. {
  1382. struct wmi_tlv_vdev_start_cmd *cmd;
  1383. struct wmi_channel *ch;
  1384. struct wmi_p2p_noa_descriptor *noa;
  1385. struct wmi_tlv *tlv;
  1386. struct sk_buff *skb;
  1387. size_t len;
  1388. void *ptr;
  1389. u32 flags = 0;
  1390. if (WARN_ON(arg->hidden_ssid && !arg->ssid))
  1391. return ERR_PTR(-EINVAL);
  1392. if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
  1393. return ERR_PTR(-EINVAL);
  1394. len = (sizeof(*tlv) + sizeof(*cmd)) +
  1395. (sizeof(*tlv) + sizeof(*ch)) +
  1396. (sizeof(*tlv) + 0);
  1397. skb = ath10k_wmi_alloc_skb(ar, len);
  1398. if (!skb)
  1399. return ERR_PTR(-ENOMEM);
  1400. if (arg->hidden_ssid)
  1401. flags |= WMI_VDEV_START_HIDDEN_SSID;
  1402. if (arg->pmf_enabled)
  1403. flags |= WMI_VDEV_START_PMF_ENABLED;
  1404. ptr = (void *)skb->data;
  1405. tlv = ptr;
  1406. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_START_REQUEST_CMD);
  1407. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1408. cmd = (void *)tlv->value;
  1409. cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
  1410. cmd->bcn_intval = __cpu_to_le32(arg->bcn_intval);
  1411. cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
  1412. cmd->flags = __cpu_to_le32(flags);
  1413. cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
  1414. cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
  1415. cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
  1416. if (arg->ssid) {
  1417. cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
  1418. memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
  1419. }
  1420. ptr += sizeof(*tlv);
  1421. ptr += sizeof(*cmd);
  1422. tlv = ptr;
  1423. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
  1424. tlv->len = __cpu_to_le16(sizeof(*ch));
  1425. ch = (void *)tlv->value;
  1426. ath10k_wmi_put_wmi_channel(ch, &arg->channel);
  1427. ptr += sizeof(*tlv);
  1428. ptr += sizeof(*ch);
  1429. tlv = ptr;
  1430. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  1431. tlv->len = 0;
  1432. noa = (void *)tlv->value;
  1433. /* Note: This is a nested TLV containing:
  1434. * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
  1435. */
  1436. ptr += sizeof(*tlv);
  1437. ptr += 0;
  1438. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev start\n");
  1439. return skb;
  1440. }
  1441. static struct sk_buff *
  1442. ath10k_wmi_tlv_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
  1443. {
  1444. struct wmi_vdev_stop_cmd *cmd;
  1445. struct wmi_tlv *tlv;
  1446. struct sk_buff *skb;
  1447. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1448. if (!skb)
  1449. return ERR_PTR(-ENOMEM);
  1450. tlv = (void *)skb->data;
  1451. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_STOP_CMD);
  1452. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1453. cmd = (void *)tlv->value;
  1454. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1455. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev stop\n");
  1456. return skb;
  1457. }
  1458. static struct sk_buff *
  1459. ath10k_wmi_tlv_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
  1460. const u8 *bssid)
  1461. {
  1462. struct wmi_vdev_up_cmd *cmd;
  1463. struct wmi_tlv *tlv;
  1464. struct sk_buff *skb;
  1465. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1466. if (!skb)
  1467. return ERR_PTR(-ENOMEM);
  1468. tlv = (void *)skb->data;
  1469. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_UP_CMD);
  1470. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1471. cmd = (void *)tlv->value;
  1472. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1473. cmd->vdev_assoc_id = __cpu_to_le32(aid);
  1474. ether_addr_copy(cmd->vdev_bssid.addr, bssid);
  1475. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev up\n");
  1476. return skb;
  1477. }
  1478. static struct sk_buff *
  1479. ath10k_wmi_tlv_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
  1480. {
  1481. struct wmi_vdev_down_cmd *cmd;
  1482. struct wmi_tlv *tlv;
  1483. struct sk_buff *skb;
  1484. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1485. if (!skb)
  1486. return ERR_PTR(-ENOMEM);
  1487. tlv = (void *)skb->data;
  1488. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DOWN_CMD);
  1489. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1490. cmd = (void *)tlv->value;
  1491. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1492. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev down\n");
  1493. return skb;
  1494. }
  1495. static struct sk_buff *
  1496. ath10k_wmi_tlv_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
  1497. u32 param_id, u32 param_value)
  1498. {
  1499. struct wmi_vdev_set_param_cmd *cmd;
  1500. struct wmi_tlv *tlv;
  1501. struct sk_buff *skb;
  1502. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1503. if (!skb)
  1504. return ERR_PTR(-ENOMEM);
  1505. tlv = (void *)skb->data;
  1506. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_PARAM_CMD);
  1507. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1508. cmd = (void *)tlv->value;
  1509. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1510. cmd->param_id = __cpu_to_le32(param_id);
  1511. cmd->param_value = __cpu_to_le32(param_value);
  1512. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev set param\n");
  1513. return skb;
  1514. }
  1515. static struct sk_buff *
  1516. ath10k_wmi_tlv_op_gen_vdev_install_key(struct ath10k *ar,
  1517. const struct wmi_vdev_install_key_arg *arg)
  1518. {
  1519. struct wmi_vdev_install_key_cmd *cmd;
  1520. struct wmi_tlv *tlv;
  1521. struct sk_buff *skb;
  1522. size_t len;
  1523. void *ptr;
  1524. if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
  1525. return ERR_PTR(-EINVAL);
  1526. if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
  1527. return ERR_PTR(-EINVAL);
  1528. len = sizeof(*tlv) + sizeof(*cmd) +
  1529. sizeof(*tlv) + roundup(arg->key_len, sizeof(__le32));
  1530. skb = ath10k_wmi_alloc_skb(ar, len);
  1531. if (!skb)
  1532. return ERR_PTR(-ENOMEM);
  1533. ptr = (void *)skb->data;
  1534. tlv = ptr;
  1535. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_INSTALL_KEY_CMD);
  1536. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1537. cmd = (void *)tlv->value;
  1538. cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
  1539. cmd->key_idx = __cpu_to_le32(arg->key_idx);
  1540. cmd->key_flags = __cpu_to_le32(arg->key_flags);
  1541. cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
  1542. cmd->key_len = __cpu_to_le32(arg->key_len);
  1543. cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
  1544. cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
  1545. if (arg->macaddr)
  1546. ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
  1547. ptr += sizeof(*tlv);
  1548. ptr += sizeof(*cmd);
  1549. tlv = ptr;
  1550. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
  1551. tlv->len = __cpu_to_le16(roundup(arg->key_len, sizeof(__le32)));
  1552. if (arg->key_data)
  1553. memcpy(tlv->value, arg->key_data, arg->key_len);
  1554. ptr += sizeof(*tlv);
  1555. ptr += roundup(arg->key_len, sizeof(__le32));
  1556. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev install key\n");
  1557. return skb;
  1558. }
  1559. static void *ath10k_wmi_tlv_put_uapsd_ac(struct ath10k *ar, void *ptr,
  1560. const struct wmi_sta_uapsd_auto_trig_arg *arg)
  1561. {
  1562. struct wmi_sta_uapsd_auto_trig_param *ac;
  1563. struct wmi_tlv *tlv;
  1564. tlv = ptr;
  1565. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_PARAM);
  1566. tlv->len = __cpu_to_le16(sizeof(*ac));
  1567. ac = (void *)tlv->value;
  1568. ac->wmm_ac = __cpu_to_le32(arg->wmm_ac);
  1569. ac->user_priority = __cpu_to_le32(arg->user_priority);
  1570. ac->service_interval = __cpu_to_le32(arg->service_interval);
  1571. ac->suspend_interval = __cpu_to_le32(arg->suspend_interval);
  1572. ac->delay_interval = __cpu_to_le32(arg->delay_interval);
  1573. ath10k_dbg(ar, ATH10K_DBG_WMI,
  1574. "wmi tlv vdev sta uapsd auto trigger ac %d prio %d svc int %d susp int %d delay int %d\n",
  1575. ac->wmm_ac, ac->user_priority, ac->service_interval,
  1576. ac->suspend_interval, ac->delay_interval);
  1577. return ptr + sizeof(*tlv) + sizeof(*ac);
  1578. }
  1579. static struct sk_buff *
  1580. ath10k_wmi_tlv_op_gen_vdev_sta_uapsd(struct ath10k *ar, u32 vdev_id,
  1581. const u8 peer_addr[ETH_ALEN],
  1582. const struct wmi_sta_uapsd_auto_trig_arg *args,
  1583. u32 num_ac)
  1584. {
  1585. struct wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
  1586. struct wmi_sta_uapsd_auto_trig_param *ac;
  1587. struct wmi_tlv *tlv;
  1588. struct sk_buff *skb;
  1589. size_t len;
  1590. size_t ac_tlv_len;
  1591. void *ptr;
  1592. int i;
  1593. ac_tlv_len = num_ac * (sizeof(*tlv) + sizeof(*ac));
  1594. len = sizeof(*tlv) + sizeof(*cmd) +
  1595. sizeof(*tlv) + ac_tlv_len;
  1596. skb = ath10k_wmi_alloc_skb(ar, len);
  1597. if (!skb)
  1598. return ERR_PTR(-ENOMEM);
  1599. ptr = (void *)skb->data;
  1600. tlv = ptr;
  1601. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_CMD);
  1602. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1603. cmd = (void *)tlv->value;
  1604. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1605. cmd->num_ac = __cpu_to_le32(num_ac);
  1606. ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
  1607. ptr += sizeof(*tlv);
  1608. ptr += sizeof(*cmd);
  1609. tlv = ptr;
  1610. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  1611. tlv->len = __cpu_to_le16(ac_tlv_len);
  1612. ac = (void *)tlv->value;
  1613. ptr += sizeof(*tlv);
  1614. for (i = 0; i < num_ac; i++)
  1615. ptr = ath10k_wmi_tlv_put_uapsd_ac(ar, ptr, &args[i]);
  1616. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev sta uapsd auto trigger\n");
  1617. return skb;
  1618. }
  1619. static void *ath10k_wmi_tlv_put_wmm(void *ptr,
  1620. const struct wmi_wmm_params_arg *arg)
  1621. {
  1622. struct wmi_wmm_params *wmm;
  1623. struct wmi_tlv *tlv;
  1624. tlv = ptr;
  1625. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WMM_PARAMS);
  1626. tlv->len = __cpu_to_le16(sizeof(*wmm));
  1627. wmm = (void *)tlv->value;
  1628. ath10k_wmi_set_wmm_param(wmm, arg);
  1629. return ptr + sizeof(*tlv) + sizeof(*wmm);
  1630. }
  1631. static struct sk_buff *
  1632. ath10k_wmi_tlv_op_gen_vdev_wmm_conf(struct ath10k *ar, u32 vdev_id,
  1633. const struct wmi_wmm_params_all_arg *arg)
  1634. {
  1635. struct wmi_tlv_vdev_set_wmm_cmd *cmd;
  1636. struct wmi_tlv *tlv;
  1637. struct sk_buff *skb;
  1638. size_t len;
  1639. void *ptr;
  1640. len = sizeof(*tlv) + sizeof(*cmd);
  1641. skb = ath10k_wmi_alloc_skb(ar, len);
  1642. if (!skb)
  1643. return ERR_PTR(-ENOMEM);
  1644. ptr = (void *)skb->data;
  1645. tlv = ptr;
  1646. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_WMM_PARAMS_CMD);
  1647. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1648. cmd = (void *)tlv->value;
  1649. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1650. ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[0].params, &arg->ac_be);
  1651. ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[1].params, &arg->ac_bk);
  1652. ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[2].params, &arg->ac_vi);
  1653. ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[3].params, &arg->ac_vo);
  1654. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev wmm conf\n");
  1655. return skb;
  1656. }
  1657. static struct sk_buff *
  1658. ath10k_wmi_tlv_op_gen_sta_keepalive(struct ath10k *ar,
  1659. const struct wmi_sta_keepalive_arg *arg)
  1660. {
  1661. struct wmi_tlv_sta_keepalive_cmd *cmd;
  1662. struct wmi_sta_keepalive_arp_resp *arp;
  1663. struct sk_buff *skb;
  1664. struct wmi_tlv *tlv;
  1665. void *ptr;
  1666. size_t len;
  1667. len = sizeof(*tlv) + sizeof(*cmd) +
  1668. sizeof(*tlv) + sizeof(*arp);
  1669. skb = ath10k_wmi_alloc_skb(ar, len);
  1670. if (!skb)
  1671. return ERR_PTR(-ENOMEM);
  1672. ptr = (void *)skb->data;
  1673. tlv = ptr;
  1674. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALIVE_CMD);
  1675. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1676. cmd = (void *)tlv->value;
  1677. cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
  1678. cmd->enabled = __cpu_to_le32(arg->enabled);
  1679. cmd->method = __cpu_to_le32(arg->method);
  1680. cmd->interval = __cpu_to_le32(arg->interval);
  1681. ptr += sizeof(*tlv);
  1682. ptr += sizeof(*cmd);
  1683. tlv = ptr;
  1684. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALVE_ARP_RESPONSE);
  1685. tlv->len = __cpu_to_le16(sizeof(*arp));
  1686. arp = (void *)tlv->value;
  1687. arp->src_ip4_addr = arg->src_ip4_addr;
  1688. arp->dest_ip4_addr = arg->dest_ip4_addr;
  1689. ether_addr_copy(arp->dest_mac_addr.addr, arg->dest_mac_addr);
  1690. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv sta keepalive vdev %d enabled %d method %d inverval %d\n",
  1691. arg->vdev_id, arg->enabled, arg->method, arg->interval);
  1692. return skb;
  1693. }
  1694. static struct sk_buff *
  1695. ath10k_wmi_tlv_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
  1696. const u8 peer_addr[ETH_ALEN],
  1697. enum wmi_peer_type peer_type)
  1698. {
  1699. struct wmi_tlv_peer_create_cmd *cmd;
  1700. struct wmi_tlv *tlv;
  1701. struct sk_buff *skb;
  1702. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1703. if (!skb)
  1704. return ERR_PTR(-ENOMEM);
  1705. tlv = (void *)skb->data;
  1706. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_CREATE_CMD);
  1707. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1708. cmd = (void *)tlv->value;
  1709. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1710. cmd->peer_type = __cpu_to_le32(peer_type);
  1711. ether_addr_copy(cmd->peer_addr.addr, peer_addr);
  1712. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer create\n");
  1713. return skb;
  1714. }
  1715. static struct sk_buff *
  1716. ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
  1717. const u8 peer_addr[ETH_ALEN])
  1718. {
  1719. struct wmi_peer_delete_cmd *cmd;
  1720. struct wmi_tlv *tlv;
  1721. struct sk_buff *skb;
  1722. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1723. if (!skb)
  1724. return ERR_PTR(-ENOMEM);
  1725. tlv = (void *)skb->data;
  1726. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_DELETE_CMD);
  1727. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1728. cmd = (void *)tlv->value;
  1729. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1730. ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
  1731. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer delete\n");
  1732. return skb;
  1733. }
  1734. static struct sk_buff *
  1735. ath10k_wmi_tlv_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
  1736. const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
  1737. {
  1738. struct wmi_peer_flush_tids_cmd *cmd;
  1739. struct wmi_tlv *tlv;
  1740. struct sk_buff *skb;
  1741. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1742. if (!skb)
  1743. return ERR_PTR(-ENOMEM);
  1744. tlv = (void *)skb->data;
  1745. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_FLUSH_TIDS_CMD);
  1746. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1747. cmd = (void *)tlv->value;
  1748. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1749. cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
  1750. ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
  1751. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer flush\n");
  1752. return skb;
  1753. }
  1754. static struct sk_buff *
  1755. ath10k_wmi_tlv_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
  1756. const u8 *peer_addr,
  1757. enum wmi_peer_param param_id,
  1758. u32 param_value)
  1759. {
  1760. struct wmi_peer_set_param_cmd *cmd;
  1761. struct wmi_tlv *tlv;
  1762. struct sk_buff *skb;
  1763. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1764. if (!skb)
  1765. return ERR_PTR(-ENOMEM);
  1766. tlv = (void *)skb->data;
  1767. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_SET_PARAM_CMD);
  1768. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1769. cmd = (void *)tlv->value;
  1770. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1771. cmd->param_id = __cpu_to_le32(param_id);
  1772. cmd->param_value = __cpu_to_le32(param_value);
  1773. ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
  1774. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer set param\n");
  1775. return skb;
  1776. }
  1777. static struct sk_buff *
  1778. ath10k_wmi_tlv_op_gen_peer_assoc(struct ath10k *ar,
  1779. const struct wmi_peer_assoc_complete_arg *arg)
  1780. {
  1781. struct wmi_tlv_peer_assoc_cmd *cmd;
  1782. struct wmi_vht_rate_set *vht_rate;
  1783. struct wmi_tlv *tlv;
  1784. struct sk_buff *skb;
  1785. size_t len, legacy_rate_len, ht_rate_len;
  1786. void *ptr;
  1787. if (arg->peer_mpdu_density > 16)
  1788. return ERR_PTR(-EINVAL);
  1789. if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
  1790. return ERR_PTR(-EINVAL);
  1791. if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
  1792. return ERR_PTR(-EINVAL);
  1793. legacy_rate_len = roundup(arg->peer_legacy_rates.num_rates,
  1794. sizeof(__le32));
  1795. ht_rate_len = roundup(arg->peer_ht_rates.num_rates, sizeof(__le32));
  1796. len = (sizeof(*tlv) + sizeof(*cmd)) +
  1797. (sizeof(*tlv) + legacy_rate_len) +
  1798. (sizeof(*tlv) + ht_rate_len) +
  1799. (sizeof(*tlv) + sizeof(*vht_rate));
  1800. skb = ath10k_wmi_alloc_skb(ar, len);
  1801. if (!skb)
  1802. return ERR_PTR(-ENOMEM);
  1803. ptr = (void *)skb->data;
  1804. tlv = ptr;
  1805. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_ASSOC_COMPLETE_CMD);
  1806. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1807. cmd = (void *)tlv->value;
  1808. cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
  1809. cmd->new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
  1810. cmd->assoc_id = __cpu_to_le32(arg->peer_aid);
  1811. cmd->flags = __cpu_to_le32(arg->peer_flags);
  1812. cmd->caps = __cpu_to_le32(arg->peer_caps);
  1813. cmd->listen_intval = __cpu_to_le32(arg->peer_listen_intval);
  1814. cmd->ht_caps = __cpu_to_le32(arg->peer_ht_caps);
  1815. cmd->max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
  1816. cmd->mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
  1817. cmd->rate_caps = __cpu_to_le32(arg->peer_rate_caps);
  1818. cmd->nss = __cpu_to_le32(arg->peer_num_spatial_streams);
  1819. cmd->vht_caps = __cpu_to_le32(arg->peer_vht_caps);
  1820. cmd->phy_mode = __cpu_to_le32(arg->peer_phymode);
  1821. cmd->num_legacy_rates = __cpu_to_le32(arg->peer_legacy_rates.num_rates);
  1822. cmd->num_ht_rates = __cpu_to_le32(arg->peer_ht_rates.num_rates);
  1823. ether_addr_copy(cmd->mac_addr.addr, arg->addr);
  1824. ptr += sizeof(*tlv);
  1825. ptr += sizeof(*cmd);
  1826. tlv = ptr;
  1827. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
  1828. tlv->len = __cpu_to_le16(legacy_rate_len);
  1829. memcpy(tlv->value, arg->peer_legacy_rates.rates,
  1830. arg->peer_legacy_rates.num_rates);
  1831. ptr += sizeof(*tlv);
  1832. ptr += legacy_rate_len;
  1833. tlv = ptr;
  1834. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
  1835. tlv->len = __cpu_to_le16(ht_rate_len);
  1836. memcpy(tlv->value, arg->peer_ht_rates.rates,
  1837. arg->peer_ht_rates.num_rates);
  1838. ptr += sizeof(*tlv);
  1839. ptr += ht_rate_len;
  1840. tlv = ptr;
  1841. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VHT_RATE_SET);
  1842. tlv->len = __cpu_to_le16(sizeof(*vht_rate));
  1843. vht_rate = (void *)tlv->value;
  1844. vht_rate->rx_max_rate = __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
  1845. vht_rate->rx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
  1846. vht_rate->tx_max_rate = __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
  1847. vht_rate->tx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
  1848. ptr += sizeof(*tlv);
  1849. ptr += sizeof(*vht_rate);
  1850. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer assoc\n");
  1851. return skb;
  1852. }
  1853. static struct sk_buff *
  1854. ath10k_wmi_tlv_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
  1855. enum wmi_sta_ps_mode psmode)
  1856. {
  1857. struct wmi_sta_powersave_mode_cmd *cmd;
  1858. struct wmi_tlv *tlv;
  1859. struct sk_buff *skb;
  1860. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1861. if (!skb)
  1862. return ERR_PTR(-ENOMEM);
  1863. tlv = (void *)skb->data;
  1864. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_MODE_CMD);
  1865. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1866. cmd = (void *)tlv->value;
  1867. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1868. cmd->sta_ps_mode = __cpu_to_le32(psmode);
  1869. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set psmode\n");
  1870. return skb;
  1871. }
  1872. static struct sk_buff *
  1873. ath10k_wmi_tlv_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
  1874. enum wmi_sta_powersave_param param_id,
  1875. u32 param_value)
  1876. {
  1877. struct wmi_sta_powersave_param_cmd *cmd;
  1878. struct wmi_tlv *tlv;
  1879. struct sk_buff *skb;
  1880. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1881. if (!skb)
  1882. return ERR_PTR(-ENOMEM);
  1883. tlv = (void *)skb->data;
  1884. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_PARAM_CMD);
  1885. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1886. cmd = (void *)tlv->value;
  1887. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1888. cmd->param_id = __cpu_to_le32(param_id);
  1889. cmd->param_value = __cpu_to_le32(param_value);
  1890. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set sta ps\n");
  1891. return skb;
  1892. }
  1893. static struct sk_buff *
  1894. ath10k_wmi_tlv_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
  1895. enum wmi_ap_ps_peer_param param_id, u32 value)
  1896. {
  1897. struct wmi_ap_ps_peer_cmd *cmd;
  1898. struct wmi_tlv *tlv;
  1899. struct sk_buff *skb;
  1900. if (!mac)
  1901. return ERR_PTR(-EINVAL);
  1902. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1903. if (!skb)
  1904. return ERR_PTR(-ENOMEM);
  1905. tlv = (void *)skb->data;
  1906. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_AP_PS_PEER_CMD);
  1907. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1908. cmd = (void *)tlv->value;
  1909. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1910. cmd->param_id = __cpu_to_le32(param_id);
  1911. cmd->param_value = __cpu_to_le32(value);
  1912. ether_addr_copy(cmd->peer_macaddr.addr, mac);
  1913. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv ap ps param\n");
  1914. return skb;
  1915. }
  1916. static struct sk_buff *
  1917. ath10k_wmi_tlv_op_gen_scan_chan_list(struct ath10k *ar,
  1918. const struct wmi_scan_chan_list_arg *arg)
  1919. {
  1920. struct wmi_tlv_scan_chan_list_cmd *cmd;
  1921. struct wmi_channel *ci;
  1922. struct wmi_channel_arg *ch;
  1923. struct wmi_tlv *tlv;
  1924. struct sk_buff *skb;
  1925. size_t chans_len, len;
  1926. int i;
  1927. void *ptr, *chans;
  1928. chans_len = arg->n_channels * (sizeof(*tlv) + sizeof(*ci));
  1929. len = (sizeof(*tlv) + sizeof(*cmd)) +
  1930. (sizeof(*tlv) + chans_len);
  1931. skb = ath10k_wmi_alloc_skb(ar, len);
  1932. if (!skb)
  1933. return ERR_PTR(-ENOMEM);
  1934. ptr = (void *)skb->data;
  1935. tlv = ptr;
  1936. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_CHAN_LIST_CMD);
  1937. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1938. cmd = (void *)tlv->value;
  1939. cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
  1940. ptr += sizeof(*tlv);
  1941. ptr += sizeof(*cmd);
  1942. tlv = ptr;
  1943. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  1944. tlv->len = __cpu_to_le16(chans_len);
  1945. chans = (void *)tlv->value;
  1946. for (i = 0; i < arg->n_channels; i++) {
  1947. ch = &arg->channels[i];
  1948. tlv = chans;
  1949. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
  1950. tlv->len = __cpu_to_le16(sizeof(*ci));
  1951. ci = (void *)tlv->value;
  1952. ath10k_wmi_put_wmi_channel(ci, ch);
  1953. chans += sizeof(*tlv);
  1954. chans += sizeof(*ci);
  1955. }
  1956. ptr += sizeof(*tlv);
  1957. ptr += chans_len;
  1958. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv scan chan list\n");
  1959. return skb;
  1960. }
  1961. static struct sk_buff *
  1962. ath10k_wmi_tlv_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id,
  1963. const void *bcn, size_t bcn_len,
  1964. u32 bcn_paddr, bool dtim_zero,
  1965. bool deliver_cab)
  1966. {
  1967. struct wmi_bcn_tx_ref_cmd *cmd;
  1968. struct wmi_tlv *tlv;
  1969. struct sk_buff *skb;
  1970. struct ieee80211_hdr *hdr;
  1971. u16 fc;
  1972. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  1973. if (!skb)
  1974. return ERR_PTR(-ENOMEM);
  1975. hdr = (struct ieee80211_hdr *)bcn;
  1976. fc = le16_to_cpu(hdr->frame_control);
  1977. tlv = (void *)skb->data;
  1978. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_SEND_FROM_HOST_CMD);
  1979. tlv->len = __cpu_to_le16(sizeof(*cmd));
  1980. cmd = (void *)tlv->value;
  1981. cmd->vdev_id = __cpu_to_le32(vdev_id);
  1982. cmd->data_len = __cpu_to_le32(bcn_len);
  1983. cmd->data_ptr = __cpu_to_le32(bcn_paddr);
  1984. cmd->msdu_id = 0;
  1985. cmd->frame_control = __cpu_to_le32(fc);
  1986. cmd->flags = 0;
  1987. if (dtim_zero)
  1988. cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
  1989. if (deliver_cab)
  1990. cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
  1991. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv beacon dma\n");
  1992. return skb;
  1993. }
  1994. static struct sk_buff *
  1995. ath10k_wmi_tlv_op_gen_pdev_set_wmm(struct ath10k *ar,
  1996. const struct wmi_wmm_params_all_arg *arg)
  1997. {
  1998. struct wmi_tlv_pdev_set_wmm_cmd *cmd;
  1999. struct wmi_wmm_params *wmm;
  2000. struct wmi_tlv *tlv;
  2001. struct sk_buff *skb;
  2002. size_t len;
  2003. void *ptr;
  2004. len = (sizeof(*tlv) + sizeof(*cmd)) +
  2005. (4 * (sizeof(*tlv) + sizeof(*wmm)));
  2006. skb = ath10k_wmi_alloc_skb(ar, len);
  2007. if (!skb)
  2008. return ERR_PTR(-ENOMEM);
  2009. ptr = (void *)skb->data;
  2010. tlv = ptr;
  2011. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_WMM_PARAMS_CMD);
  2012. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2013. cmd = (void *)tlv->value;
  2014. /* nothing to set here */
  2015. ptr += sizeof(*tlv);
  2016. ptr += sizeof(*cmd);
  2017. ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_be);
  2018. ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_bk);
  2019. ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vi);
  2020. ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vo);
  2021. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set wmm\n");
  2022. return skb;
  2023. }
  2024. static struct sk_buff *
  2025. ath10k_wmi_tlv_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
  2026. {
  2027. struct wmi_request_stats_cmd *cmd;
  2028. struct wmi_tlv *tlv;
  2029. struct sk_buff *skb;
  2030. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  2031. if (!skb)
  2032. return ERR_PTR(-ENOMEM);
  2033. tlv = (void *)skb->data;
  2034. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_REQUEST_STATS_CMD);
  2035. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2036. cmd = (void *)tlv->value;
  2037. cmd->stats_id = __cpu_to_le32(stats_mask);
  2038. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv request stats\n");
  2039. return skb;
  2040. }
  2041. static struct sk_buff *
  2042. ath10k_wmi_tlv_op_gen_force_fw_hang(struct ath10k *ar,
  2043. enum wmi_force_fw_hang_type type,
  2044. u32 delay_ms)
  2045. {
  2046. struct wmi_force_fw_hang_cmd *cmd;
  2047. struct wmi_tlv *tlv;
  2048. struct sk_buff *skb;
  2049. skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
  2050. if (!skb)
  2051. return ERR_PTR(-ENOMEM);
  2052. tlv = (void *)skb->data;
  2053. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_FORCE_FW_HANG_CMD);
  2054. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2055. cmd = (void *)tlv->value;
  2056. cmd->type = __cpu_to_le32(type);
  2057. cmd->delay_ms = __cpu_to_le32(delay_ms);
  2058. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv force fw hang\n");
  2059. return skb;
  2060. }
  2061. static struct sk_buff *
  2062. ath10k_wmi_tlv_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
  2063. u32 log_level) {
  2064. struct wmi_tlv_dbglog_cmd *cmd;
  2065. struct wmi_tlv *tlv;
  2066. struct sk_buff *skb;
  2067. size_t len, bmap_len;
  2068. u32 value;
  2069. void *ptr;
  2070. if (module_enable) {
  2071. value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
  2072. module_enable,
  2073. WMI_TLV_DBGLOG_LOG_LEVEL_VERBOSE);
  2074. } else {
  2075. value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
  2076. WMI_TLV_DBGLOG_ALL_MODULES,
  2077. WMI_TLV_DBGLOG_LOG_LEVEL_WARN);
  2078. }
  2079. bmap_len = 0;
  2080. len = sizeof(*tlv) + sizeof(*cmd) + sizeof(*tlv) + bmap_len;
  2081. skb = ath10k_wmi_alloc_skb(ar, len);
  2082. if (!skb)
  2083. return ERR_PTR(-ENOMEM);
  2084. ptr = (void *)skb->data;
  2085. tlv = ptr;
  2086. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_DEBUG_LOG_CONFIG_CMD);
  2087. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2088. cmd = (void *)tlv->value;
  2089. cmd->param = __cpu_to_le32(WMI_TLV_DBGLOG_PARAM_LOG_LEVEL);
  2090. cmd->value = __cpu_to_le32(value);
  2091. ptr += sizeof(*tlv);
  2092. ptr += sizeof(*cmd);
  2093. tlv = ptr;
  2094. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
  2095. tlv->len = __cpu_to_le16(bmap_len);
  2096. /* nothing to do here */
  2097. ptr += sizeof(*tlv);
  2098. ptr += sizeof(bmap_len);
  2099. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv dbglog value 0x%08x\n", value);
  2100. return skb;
  2101. }
  2102. static struct sk_buff *
  2103. ath10k_wmi_tlv_op_gen_pktlog_enable(struct ath10k *ar, u32 filter)
  2104. {
  2105. struct wmi_tlv_pktlog_enable *cmd;
  2106. struct wmi_tlv *tlv;
  2107. struct sk_buff *skb;
  2108. void *ptr;
  2109. size_t len;
  2110. len = sizeof(*tlv) + sizeof(*cmd);
  2111. skb = ath10k_wmi_alloc_skb(ar, len);
  2112. if (!skb)
  2113. return ERR_PTR(-ENOMEM);
  2114. ptr = (void *)skb->data;
  2115. tlv = ptr;
  2116. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_ENABLE_CMD);
  2117. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2118. cmd = (void *)tlv->value;
  2119. cmd->filter = __cpu_to_le32(filter);
  2120. ptr += sizeof(*tlv);
  2121. ptr += sizeof(*cmd);
  2122. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog enable filter 0x%08x\n",
  2123. filter);
  2124. return skb;
  2125. }
  2126. static struct sk_buff *
  2127. ath10k_wmi_tlv_op_gen_pktlog_disable(struct ath10k *ar)
  2128. {
  2129. struct wmi_tlv_pktlog_disable *cmd;
  2130. struct wmi_tlv *tlv;
  2131. struct sk_buff *skb;
  2132. void *ptr;
  2133. size_t len;
  2134. len = sizeof(*tlv) + sizeof(*cmd);
  2135. skb = ath10k_wmi_alloc_skb(ar, len);
  2136. if (!skb)
  2137. return ERR_PTR(-ENOMEM);
  2138. ptr = (void *)skb->data;
  2139. tlv = ptr;
  2140. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_DISABLE_CMD);
  2141. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2142. cmd = (void *)tlv->value;
  2143. ptr += sizeof(*tlv);
  2144. ptr += sizeof(*cmd);
  2145. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog disable\n");
  2146. return skb;
  2147. }
  2148. static struct sk_buff *
  2149. ath10k_wmi_tlv_op_gen_bcn_tmpl(struct ath10k *ar, u32 vdev_id,
  2150. u32 tim_ie_offset, struct sk_buff *bcn,
  2151. u32 prb_caps, u32 prb_erp, void *prb_ies,
  2152. size_t prb_ies_len)
  2153. {
  2154. struct wmi_tlv_bcn_tmpl_cmd *cmd;
  2155. struct wmi_tlv_bcn_prb_info *info;
  2156. struct wmi_tlv *tlv;
  2157. struct sk_buff *skb;
  2158. void *ptr;
  2159. size_t len;
  2160. if (WARN_ON(prb_ies_len > 0 && !prb_ies))
  2161. return ERR_PTR(-EINVAL);
  2162. len = sizeof(*tlv) + sizeof(*cmd) +
  2163. sizeof(*tlv) + sizeof(*info) + prb_ies_len +
  2164. sizeof(*tlv) + roundup(bcn->len, 4);
  2165. skb = ath10k_wmi_alloc_skb(ar, len);
  2166. if (!skb)
  2167. return ERR_PTR(-ENOMEM);
  2168. ptr = (void *)skb->data;
  2169. tlv = ptr;
  2170. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_TMPL_CMD);
  2171. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2172. cmd = (void *)tlv->value;
  2173. cmd->vdev_id = __cpu_to_le32(vdev_id);
  2174. cmd->tim_ie_offset = __cpu_to_le32(tim_ie_offset);
  2175. cmd->buf_len = __cpu_to_le32(bcn->len);
  2176. ptr += sizeof(*tlv);
  2177. ptr += sizeof(*cmd);
  2178. /* FIXME: prb_ies_len should be probably aligned to 4byte boundary but
  2179. * then it is then impossible to pass original ie len.
  2180. * This chunk is not used yet so if setting probe resp template yields
  2181. * problems with beaconing or crashes firmware look here.
  2182. */
  2183. tlv = ptr;
  2184. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
  2185. tlv->len = __cpu_to_le16(sizeof(*info) + prb_ies_len);
  2186. info = (void *)tlv->value;
  2187. info->caps = __cpu_to_le32(prb_caps);
  2188. info->erp = __cpu_to_le32(prb_erp);
  2189. memcpy(info->ies, prb_ies, prb_ies_len);
  2190. ptr += sizeof(*tlv);
  2191. ptr += sizeof(*info);
  2192. ptr += prb_ies_len;
  2193. tlv = ptr;
  2194. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
  2195. tlv->len = __cpu_to_le16(roundup(bcn->len, 4));
  2196. memcpy(tlv->value, bcn->data, bcn->len);
  2197. /* FIXME: Adjust TSF? */
  2198. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv bcn tmpl vdev_id %i\n",
  2199. vdev_id);
  2200. return skb;
  2201. }
  2202. static struct sk_buff *
  2203. ath10k_wmi_tlv_op_gen_prb_tmpl(struct ath10k *ar, u32 vdev_id,
  2204. struct sk_buff *prb)
  2205. {
  2206. struct wmi_tlv_prb_tmpl_cmd *cmd;
  2207. struct wmi_tlv_bcn_prb_info *info;
  2208. struct wmi_tlv *tlv;
  2209. struct sk_buff *skb;
  2210. void *ptr;
  2211. size_t len;
  2212. len = sizeof(*tlv) + sizeof(*cmd) +
  2213. sizeof(*tlv) + sizeof(*info) +
  2214. sizeof(*tlv) + roundup(prb->len, 4);
  2215. skb = ath10k_wmi_alloc_skb(ar, len);
  2216. if (!skb)
  2217. return ERR_PTR(-ENOMEM);
  2218. ptr = (void *)skb->data;
  2219. tlv = ptr;
  2220. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PRB_TMPL_CMD);
  2221. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2222. cmd = (void *)tlv->value;
  2223. cmd->vdev_id = __cpu_to_le32(vdev_id);
  2224. cmd->buf_len = __cpu_to_le32(prb->len);
  2225. ptr += sizeof(*tlv);
  2226. ptr += sizeof(*cmd);
  2227. tlv = ptr;
  2228. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
  2229. tlv->len = __cpu_to_le16(sizeof(*info));
  2230. info = (void *)tlv->value;
  2231. info->caps = 0;
  2232. info->erp = 0;
  2233. ptr += sizeof(*tlv);
  2234. ptr += sizeof(*info);
  2235. tlv = ptr;
  2236. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
  2237. tlv->len = __cpu_to_le16(roundup(prb->len, 4));
  2238. memcpy(tlv->value, prb->data, prb->len);
  2239. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv prb tmpl vdev_id %i\n",
  2240. vdev_id);
  2241. return skb;
  2242. }
  2243. static struct sk_buff *
  2244. ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie(struct ath10k *ar, u32 vdev_id,
  2245. const u8 *p2p_ie)
  2246. {
  2247. struct wmi_tlv_p2p_go_bcn_ie *cmd;
  2248. struct wmi_tlv *tlv;
  2249. struct sk_buff *skb;
  2250. void *ptr;
  2251. size_t len;
  2252. len = sizeof(*tlv) + sizeof(*cmd) +
  2253. sizeof(*tlv) + roundup(p2p_ie[1] + 2, 4);
  2254. skb = ath10k_wmi_alloc_skb(ar, len);
  2255. if (!skb)
  2256. return ERR_PTR(-ENOMEM);
  2257. ptr = (void *)skb->data;
  2258. tlv = ptr;
  2259. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_P2P_GO_SET_BEACON_IE);
  2260. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2261. cmd = (void *)tlv->value;
  2262. cmd->vdev_id = __cpu_to_le32(vdev_id);
  2263. cmd->ie_len = __cpu_to_le32(p2p_ie[1] + 2);
  2264. ptr += sizeof(*tlv);
  2265. ptr += sizeof(*cmd);
  2266. tlv = ptr;
  2267. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
  2268. tlv->len = __cpu_to_le16(roundup(p2p_ie[1] + 2, 4));
  2269. memcpy(tlv->value, p2p_ie, p2p_ie[1] + 2);
  2270. ptr += sizeof(*tlv);
  2271. ptr += roundup(p2p_ie[1] + 2, 4);
  2272. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv p2p go bcn ie for vdev %i\n",
  2273. vdev_id);
  2274. return skb;
  2275. }
  2276. static struct sk_buff *
  2277. ath10k_wmi_tlv_op_gen_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
  2278. enum wmi_tdls_state state)
  2279. {
  2280. struct wmi_tdls_set_state_cmd *cmd;
  2281. struct wmi_tlv *tlv;
  2282. struct sk_buff *skb;
  2283. void *ptr;
  2284. size_t len;
  2285. /* Set to options from wmi_tlv_tdls_options,
  2286. * for now none of them are enabled.
  2287. */
  2288. u32 options = 0;
  2289. len = sizeof(*tlv) + sizeof(*cmd);
  2290. skb = ath10k_wmi_alloc_skb(ar, len);
  2291. if (!skb)
  2292. return ERR_PTR(-ENOMEM);
  2293. ptr = (void *)skb->data;
  2294. tlv = ptr;
  2295. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_SET_STATE_CMD);
  2296. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2297. cmd = (void *)tlv->value;
  2298. cmd->vdev_id = __cpu_to_le32(vdev_id);
  2299. cmd->state = __cpu_to_le32(state);
  2300. cmd->notification_interval_ms = __cpu_to_le32(5000);
  2301. cmd->tx_discovery_threshold = __cpu_to_le32(100);
  2302. cmd->tx_teardown_threshold = __cpu_to_le32(5);
  2303. cmd->rssi_teardown_threshold = __cpu_to_le32(-75);
  2304. cmd->rssi_delta = __cpu_to_le32(-20);
  2305. cmd->tdls_options = __cpu_to_le32(options);
  2306. cmd->tdls_peer_traffic_ind_window = __cpu_to_le32(2);
  2307. cmd->tdls_peer_traffic_response_timeout_ms = __cpu_to_le32(5000);
  2308. cmd->tdls_puapsd_mask = __cpu_to_le32(0xf);
  2309. cmd->tdls_puapsd_inactivity_time_ms = __cpu_to_le32(0);
  2310. cmd->tdls_puapsd_rx_frame_threshold = __cpu_to_le32(10);
  2311. ptr += sizeof(*tlv);
  2312. ptr += sizeof(*cmd);
  2313. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv update fw tdls state %d for vdev %i\n",
  2314. state, vdev_id);
  2315. return skb;
  2316. }
  2317. static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues, u8 sp)
  2318. {
  2319. u32 peer_qos = 0;
  2320. if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
  2321. peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VO;
  2322. if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
  2323. peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VI;
  2324. if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
  2325. peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BK;
  2326. if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
  2327. peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BE;
  2328. peer_qos |= SM(sp, WMI_TLV_TDLS_PEER_SP);
  2329. return peer_qos;
  2330. }
  2331. static struct sk_buff *
  2332. ath10k_wmi_tlv_op_gen_tdls_peer_update(struct ath10k *ar,
  2333. const struct wmi_tdls_peer_update_cmd_arg *arg,
  2334. const struct wmi_tdls_peer_capab_arg *cap,
  2335. const struct wmi_channel_arg *chan_arg)
  2336. {
  2337. struct wmi_tdls_peer_update_cmd *cmd;
  2338. struct wmi_tdls_peer_capab *peer_cap;
  2339. struct wmi_channel *chan;
  2340. struct wmi_tlv *tlv;
  2341. struct sk_buff *skb;
  2342. u32 peer_qos;
  2343. void *ptr;
  2344. int len;
  2345. int i;
  2346. len = sizeof(*tlv) + sizeof(*cmd) +
  2347. sizeof(*tlv) + sizeof(*peer_cap) +
  2348. sizeof(*tlv) + cap->peer_chan_len * sizeof(*chan);
  2349. skb = ath10k_wmi_alloc_skb(ar, len);
  2350. if (!skb)
  2351. return ERR_PTR(-ENOMEM);
  2352. ptr = (void *)skb->data;
  2353. tlv = ptr;
  2354. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_UPDATE_CMD);
  2355. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2356. cmd = (void *)tlv->value;
  2357. cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
  2358. ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
  2359. cmd->peer_state = __cpu_to_le32(arg->peer_state);
  2360. ptr += sizeof(*tlv);
  2361. ptr += sizeof(*cmd);
  2362. tlv = ptr;
  2363. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_CAPABILITIES);
  2364. tlv->len = __cpu_to_le16(sizeof(*peer_cap));
  2365. peer_cap = (void *)tlv->value;
  2366. peer_qos = ath10k_wmi_tlv_prepare_peer_qos(cap->peer_uapsd_queues,
  2367. cap->peer_max_sp);
  2368. peer_cap->peer_qos = __cpu_to_le32(peer_qos);
  2369. peer_cap->buff_sta_support = __cpu_to_le32(cap->buff_sta_support);
  2370. peer_cap->off_chan_support = __cpu_to_le32(cap->off_chan_support);
  2371. peer_cap->peer_curr_operclass = __cpu_to_le32(cap->peer_curr_operclass);
  2372. peer_cap->self_curr_operclass = __cpu_to_le32(cap->self_curr_operclass);
  2373. peer_cap->peer_chan_len = __cpu_to_le32(cap->peer_chan_len);
  2374. peer_cap->peer_operclass_len = __cpu_to_le32(cap->peer_operclass_len);
  2375. for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++)
  2376. peer_cap->peer_operclass[i] = cap->peer_operclass[i];
  2377. peer_cap->is_peer_responder = __cpu_to_le32(cap->is_peer_responder);
  2378. peer_cap->pref_offchan_num = __cpu_to_le32(cap->pref_offchan_num);
  2379. peer_cap->pref_offchan_bw = __cpu_to_le32(cap->pref_offchan_bw);
  2380. ptr += sizeof(*tlv);
  2381. ptr += sizeof(*peer_cap);
  2382. tlv = ptr;
  2383. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  2384. tlv->len = __cpu_to_le16(cap->peer_chan_len * sizeof(*chan));
  2385. ptr += sizeof(*tlv);
  2386. for (i = 0; i < cap->peer_chan_len; i++) {
  2387. tlv = ptr;
  2388. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
  2389. tlv->len = __cpu_to_le16(sizeof(*chan));
  2390. chan = (void *)tlv->value;
  2391. ath10k_wmi_put_wmi_channel(chan, &chan_arg[i]);
  2392. ptr += sizeof(*tlv);
  2393. ptr += sizeof(*chan);
  2394. }
  2395. ath10k_dbg(ar, ATH10K_DBG_WMI,
  2396. "wmi tlv tdls peer update vdev %i state %d n_chans %u\n",
  2397. arg->vdev_id, arg->peer_state, cap->peer_chan_len);
  2398. return skb;
  2399. }
  2400. static struct sk_buff *
  2401. ath10k_wmi_tlv_op_gen_wow_enable(struct ath10k *ar)
  2402. {
  2403. struct wmi_tlv_wow_enable_cmd *cmd;
  2404. struct wmi_tlv *tlv;
  2405. struct sk_buff *skb;
  2406. size_t len;
  2407. len = sizeof(*tlv) + sizeof(*cmd);
  2408. skb = ath10k_wmi_alloc_skb(ar, len);
  2409. if (!skb)
  2410. return ERR_PTR(-ENOMEM);
  2411. tlv = (struct wmi_tlv *)skb->data;
  2412. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ENABLE_CMD);
  2413. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2414. cmd = (void *)tlv->value;
  2415. cmd->enable = __cpu_to_le32(1);
  2416. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow enable\n");
  2417. return skb;
  2418. }
  2419. static struct sk_buff *
  2420. ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k *ar,
  2421. u32 vdev_id,
  2422. enum wmi_wow_wakeup_event event,
  2423. u32 enable)
  2424. {
  2425. struct wmi_tlv_wow_add_del_event_cmd *cmd;
  2426. struct wmi_tlv *tlv;
  2427. struct sk_buff *skb;
  2428. size_t len;
  2429. len = sizeof(*tlv) + sizeof(*cmd);
  2430. skb = ath10k_wmi_alloc_skb(ar, len);
  2431. if (!skb)
  2432. return ERR_PTR(-ENOMEM);
  2433. tlv = (struct wmi_tlv *)skb->data;
  2434. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_DEL_EVT_CMD);
  2435. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2436. cmd = (void *)tlv->value;
  2437. cmd->vdev_id = __cpu_to_le32(vdev_id);
  2438. cmd->is_add = __cpu_to_le32(enable);
  2439. cmd->event_bitmap = __cpu_to_le32(1 << event);
  2440. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add wakeup event %s enable %d vdev_id %d\n",
  2441. wow_wakeup_event(event), enable, vdev_id);
  2442. return skb;
  2443. }
  2444. static struct sk_buff *
  2445. ath10k_wmi_tlv_gen_wow_host_wakeup_ind(struct ath10k *ar)
  2446. {
  2447. struct wmi_tlv_wow_host_wakeup_ind *cmd;
  2448. struct wmi_tlv *tlv;
  2449. struct sk_buff *skb;
  2450. size_t len;
  2451. len = sizeof(*tlv) + sizeof(*cmd);
  2452. skb = ath10k_wmi_alloc_skb(ar, len);
  2453. if (!skb)
  2454. return ERR_PTR(-ENOMEM);
  2455. tlv = (struct wmi_tlv *)skb->data;
  2456. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
  2457. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2458. cmd = (void *)tlv->value;
  2459. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow host wakeup ind\n");
  2460. return skb;
  2461. }
  2462. static struct sk_buff *
  2463. ath10k_wmi_tlv_op_gen_wow_add_pattern(struct ath10k *ar, u32 vdev_id,
  2464. u32 pattern_id, const u8 *pattern,
  2465. const u8 *bitmask, int pattern_len,
  2466. int pattern_offset)
  2467. {
  2468. struct wmi_tlv_wow_add_pattern_cmd *cmd;
  2469. struct wmi_tlv_wow_bitmap_pattern *bitmap;
  2470. struct wmi_tlv *tlv;
  2471. struct sk_buff *skb;
  2472. void *ptr;
  2473. size_t len;
  2474. len = sizeof(*tlv) + sizeof(*cmd) +
  2475. sizeof(*tlv) + /* array struct */
  2476. sizeof(*tlv) + sizeof(*bitmap) + /* bitmap */
  2477. sizeof(*tlv) + /* empty ipv4 sync */
  2478. sizeof(*tlv) + /* empty ipv6 sync */
  2479. sizeof(*tlv) + /* empty magic */
  2480. sizeof(*tlv) + /* empty info timeout */
  2481. sizeof(*tlv) + sizeof(u32); /* ratelimit interval */
  2482. skb = ath10k_wmi_alloc_skb(ar, len);
  2483. if (!skb)
  2484. return ERR_PTR(-ENOMEM);
  2485. /* cmd */
  2486. ptr = (void *)skb->data;
  2487. tlv = ptr;
  2488. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_PATTERN_CMD);
  2489. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2490. cmd = (void *)tlv->value;
  2491. cmd->vdev_id = __cpu_to_le32(vdev_id);
  2492. cmd->pattern_id = __cpu_to_le32(pattern_id);
  2493. cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN);
  2494. ptr += sizeof(*tlv);
  2495. ptr += sizeof(*cmd);
  2496. /* bitmap */
  2497. tlv = ptr;
  2498. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  2499. tlv->len = __cpu_to_le16(sizeof(*tlv) + sizeof(*bitmap));
  2500. ptr += sizeof(*tlv);
  2501. tlv = ptr;
  2502. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_BITMAP_PATTERN_T);
  2503. tlv->len = __cpu_to_le16(sizeof(*bitmap));
  2504. bitmap = (void *)tlv->value;
  2505. memcpy(bitmap->patternbuf, pattern, pattern_len);
  2506. memcpy(bitmap->bitmaskbuf, bitmask, pattern_len);
  2507. bitmap->pattern_offset = __cpu_to_le32(pattern_offset);
  2508. bitmap->pattern_len = __cpu_to_le32(pattern_len);
  2509. bitmap->bitmask_len = __cpu_to_le32(pattern_len);
  2510. bitmap->pattern_id = __cpu_to_le32(pattern_id);
  2511. ptr += sizeof(*tlv);
  2512. ptr += sizeof(*bitmap);
  2513. /* ipv4 sync */
  2514. tlv = ptr;
  2515. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  2516. tlv->len = __cpu_to_le16(0);
  2517. ptr += sizeof(*tlv);
  2518. /* ipv6 sync */
  2519. tlv = ptr;
  2520. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  2521. tlv->len = __cpu_to_le16(0);
  2522. ptr += sizeof(*tlv);
  2523. /* magic */
  2524. tlv = ptr;
  2525. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
  2526. tlv->len = __cpu_to_le16(0);
  2527. ptr += sizeof(*tlv);
  2528. /* pattern info timeout */
  2529. tlv = ptr;
  2530. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
  2531. tlv->len = __cpu_to_le16(0);
  2532. ptr += sizeof(*tlv);
  2533. /* ratelimit interval */
  2534. tlv = ptr;
  2535. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
  2536. tlv->len = __cpu_to_le16(sizeof(u32));
  2537. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add pattern vdev_id %d pattern_id %d, pattern_offset %d\n",
  2538. vdev_id, pattern_id, pattern_offset);
  2539. return skb;
  2540. }
  2541. static struct sk_buff *
  2542. ath10k_wmi_tlv_op_gen_wow_del_pattern(struct ath10k *ar, u32 vdev_id,
  2543. u32 pattern_id)
  2544. {
  2545. struct wmi_tlv_wow_del_pattern_cmd *cmd;
  2546. struct wmi_tlv *tlv;
  2547. struct sk_buff *skb;
  2548. size_t len;
  2549. len = sizeof(*tlv) + sizeof(*cmd);
  2550. skb = ath10k_wmi_alloc_skb(ar, len);
  2551. if (!skb)
  2552. return ERR_PTR(-ENOMEM);
  2553. tlv = (struct wmi_tlv *)skb->data;
  2554. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_DEL_PATTERN_CMD);
  2555. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2556. cmd = (void *)tlv->value;
  2557. cmd->vdev_id = __cpu_to_le32(vdev_id);
  2558. cmd->pattern_id = __cpu_to_le32(pattern_id);
  2559. cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN);
  2560. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow del pattern vdev_id %d pattern_id %d\n",
  2561. vdev_id, pattern_id);
  2562. return skb;
  2563. }
  2564. static struct sk_buff *
  2565. ath10k_wmi_tlv_op_gen_adaptive_qcs(struct ath10k *ar, bool enable)
  2566. {
  2567. struct wmi_tlv_adaptive_qcs *cmd;
  2568. struct wmi_tlv *tlv;
  2569. struct sk_buff *skb;
  2570. void *ptr;
  2571. size_t len;
  2572. len = sizeof(*tlv) + sizeof(*cmd);
  2573. skb = ath10k_wmi_alloc_skb(ar, len);
  2574. if (!skb)
  2575. return ERR_PTR(-ENOMEM);
  2576. ptr = (void *)skb->data;
  2577. tlv = ptr;
  2578. tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESMGR_ADAPTIVE_OCS_CMD);
  2579. tlv->len = __cpu_to_le16(sizeof(*cmd));
  2580. cmd = (void *)tlv->value;
  2581. cmd->enable = __cpu_to_le32(enable ? 1 : 0);
  2582. ptr += sizeof(*tlv);
  2583. ptr += sizeof(*cmd);
  2584. ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv adaptive qcs %d\n", enable);
  2585. return skb;
  2586. }
  2587. /****************/
  2588. /* TLV mappings */
  2589. /****************/
  2590. static struct wmi_cmd_map wmi_tlv_cmd_map = {
  2591. .init_cmdid = WMI_TLV_INIT_CMDID,
  2592. .start_scan_cmdid = WMI_TLV_START_SCAN_CMDID,
  2593. .stop_scan_cmdid = WMI_TLV_STOP_SCAN_CMDID,
  2594. .scan_chan_list_cmdid = WMI_TLV_SCAN_CHAN_LIST_CMDID,
  2595. .scan_sch_prio_tbl_cmdid = WMI_TLV_SCAN_SCH_PRIO_TBL_CMDID,
  2596. .pdev_set_regdomain_cmdid = WMI_TLV_PDEV_SET_REGDOMAIN_CMDID,
  2597. .pdev_set_channel_cmdid = WMI_TLV_PDEV_SET_CHANNEL_CMDID,
  2598. .pdev_set_param_cmdid = WMI_TLV_PDEV_SET_PARAM_CMDID,
  2599. .pdev_pktlog_enable_cmdid = WMI_TLV_PDEV_PKTLOG_ENABLE_CMDID,
  2600. .pdev_pktlog_disable_cmdid = WMI_TLV_PDEV_PKTLOG_DISABLE_CMDID,
  2601. .pdev_set_wmm_params_cmdid = WMI_TLV_PDEV_SET_WMM_PARAMS_CMDID,
  2602. .pdev_set_ht_cap_ie_cmdid = WMI_TLV_PDEV_SET_HT_CAP_IE_CMDID,
  2603. .pdev_set_vht_cap_ie_cmdid = WMI_TLV_PDEV_SET_VHT_CAP_IE_CMDID,
  2604. .pdev_set_dscp_tid_map_cmdid = WMI_TLV_PDEV_SET_DSCP_TID_MAP_CMDID,
  2605. .pdev_set_quiet_mode_cmdid = WMI_TLV_PDEV_SET_QUIET_MODE_CMDID,
  2606. .pdev_green_ap_ps_enable_cmdid = WMI_TLV_PDEV_GREEN_AP_PS_ENABLE_CMDID,
  2607. .pdev_get_tpc_config_cmdid = WMI_TLV_PDEV_GET_TPC_CONFIG_CMDID,
  2608. .pdev_set_base_macaddr_cmdid = WMI_TLV_PDEV_SET_BASE_MACADDR_CMDID,
  2609. .vdev_create_cmdid = WMI_TLV_VDEV_CREATE_CMDID,
  2610. .vdev_delete_cmdid = WMI_TLV_VDEV_DELETE_CMDID,
  2611. .vdev_start_request_cmdid = WMI_TLV_VDEV_START_REQUEST_CMDID,
  2612. .vdev_restart_request_cmdid = WMI_TLV_VDEV_RESTART_REQUEST_CMDID,
  2613. .vdev_up_cmdid = WMI_TLV_VDEV_UP_CMDID,
  2614. .vdev_stop_cmdid = WMI_TLV_VDEV_STOP_CMDID,
  2615. .vdev_down_cmdid = WMI_TLV_VDEV_DOWN_CMDID,
  2616. .vdev_set_param_cmdid = WMI_TLV_VDEV_SET_PARAM_CMDID,
  2617. .vdev_install_key_cmdid = WMI_TLV_VDEV_INSTALL_KEY_CMDID,
  2618. .peer_create_cmdid = WMI_TLV_PEER_CREATE_CMDID,
  2619. .peer_delete_cmdid = WMI_TLV_PEER_DELETE_CMDID,
  2620. .peer_flush_tids_cmdid = WMI_TLV_PEER_FLUSH_TIDS_CMDID,
  2621. .peer_set_param_cmdid = WMI_TLV_PEER_SET_PARAM_CMDID,
  2622. .peer_assoc_cmdid = WMI_TLV_PEER_ASSOC_CMDID,
  2623. .peer_add_wds_entry_cmdid = WMI_TLV_PEER_ADD_WDS_ENTRY_CMDID,
  2624. .peer_remove_wds_entry_cmdid = WMI_TLV_PEER_REMOVE_WDS_ENTRY_CMDID,
  2625. .peer_mcast_group_cmdid = WMI_TLV_PEER_MCAST_GROUP_CMDID,
  2626. .bcn_tx_cmdid = WMI_TLV_BCN_TX_CMDID,
  2627. .pdev_send_bcn_cmdid = WMI_TLV_PDEV_SEND_BCN_CMDID,
  2628. .bcn_tmpl_cmdid = WMI_TLV_BCN_TMPL_CMDID,
  2629. .bcn_filter_rx_cmdid = WMI_TLV_BCN_FILTER_RX_CMDID,
  2630. .prb_req_filter_rx_cmdid = WMI_TLV_PRB_REQ_FILTER_RX_CMDID,
  2631. .mgmt_tx_cmdid = WMI_TLV_MGMT_TX_CMDID,
  2632. .prb_tmpl_cmdid = WMI_TLV_PRB_TMPL_CMDID,
  2633. .addba_clear_resp_cmdid = WMI_TLV_ADDBA_CLEAR_RESP_CMDID,
  2634. .addba_send_cmdid = WMI_TLV_ADDBA_SEND_CMDID,
  2635. .addba_status_cmdid = WMI_TLV_ADDBA_STATUS_CMDID,
  2636. .delba_send_cmdid = WMI_TLV_DELBA_SEND_CMDID,
  2637. .addba_set_resp_cmdid = WMI_TLV_ADDBA_SET_RESP_CMDID,
  2638. .send_singleamsdu_cmdid = WMI_TLV_SEND_SINGLEAMSDU_CMDID,
  2639. .sta_powersave_mode_cmdid = WMI_TLV_STA_POWERSAVE_MODE_CMDID,
  2640. .sta_powersave_param_cmdid = WMI_TLV_STA_POWERSAVE_PARAM_CMDID,
  2641. .sta_mimo_ps_mode_cmdid = WMI_TLV_STA_MIMO_PS_MODE_CMDID,
  2642. .pdev_dfs_enable_cmdid = WMI_TLV_PDEV_DFS_ENABLE_CMDID,
  2643. .pdev_dfs_disable_cmdid = WMI_TLV_PDEV_DFS_DISABLE_CMDID,
  2644. .roam_scan_mode = WMI_TLV_ROAM_SCAN_MODE,
  2645. .roam_scan_rssi_threshold = WMI_TLV_ROAM_SCAN_RSSI_THRESHOLD,
  2646. .roam_scan_period = WMI_TLV_ROAM_SCAN_PERIOD,
  2647. .roam_scan_rssi_change_threshold =
  2648. WMI_TLV_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
  2649. .roam_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
  2650. .ofl_scan_add_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
  2651. .ofl_scan_remove_ap_profile = WMI_TLV_OFL_SCAN_REMOVE_AP_PROFILE,
  2652. .ofl_scan_period = WMI_TLV_OFL_SCAN_PERIOD,
  2653. .p2p_dev_set_device_info = WMI_TLV_P2P_DEV_SET_DEVICE_INFO,
  2654. .p2p_dev_set_discoverability = WMI_TLV_P2P_DEV_SET_DISCOVERABILITY,
  2655. .p2p_go_set_beacon_ie = WMI_TLV_P2P_GO_SET_BEACON_IE,
  2656. .p2p_go_set_probe_resp_ie = WMI_TLV_P2P_GO_SET_PROBE_RESP_IE,
  2657. .p2p_set_vendor_ie_data_cmdid = WMI_TLV_P2P_SET_VENDOR_IE_DATA_CMDID,
  2658. .ap_ps_peer_param_cmdid = WMI_TLV_AP_PS_PEER_PARAM_CMDID,
  2659. .ap_ps_peer_uapsd_coex_cmdid = WMI_TLV_AP_PS_PEER_UAPSD_COEX_CMDID,
  2660. .peer_rate_retry_sched_cmdid = WMI_TLV_PEER_RATE_RETRY_SCHED_CMDID,
  2661. .wlan_profile_trigger_cmdid = WMI_TLV_WLAN_PROFILE_TRIGGER_CMDID,
  2662. .wlan_profile_set_hist_intvl_cmdid =
  2663. WMI_TLV_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
  2664. .wlan_profile_get_profile_data_cmdid =
  2665. WMI_TLV_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
  2666. .wlan_profile_enable_profile_id_cmdid =
  2667. WMI_TLV_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
  2668. .wlan_profile_list_profile_id_cmdid =
  2669. WMI_TLV_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
  2670. .pdev_suspend_cmdid = WMI_TLV_PDEV_SUSPEND_CMDID,
  2671. .pdev_resume_cmdid = WMI_TLV_PDEV_RESUME_CMDID,
  2672. .add_bcn_filter_cmdid = WMI_TLV_ADD_BCN_FILTER_CMDID,
  2673. .rmv_bcn_filter_cmdid = WMI_TLV_RMV_BCN_FILTER_CMDID,
  2674. .wow_add_wake_pattern_cmdid = WMI_TLV_WOW_ADD_WAKE_PATTERN_CMDID,
  2675. .wow_del_wake_pattern_cmdid = WMI_TLV_WOW_DEL_WAKE_PATTERN_CMDID,
  2676. .wow_enable_disable_wake_event_cmdid =
  2677. WMI_TLV_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
  2678. .wow_enable_cmdid = WMI_TLV_WOW_ENABLE_CMDID,
  2679. .wow_hostwakeup_from_sleep_cmdid =
  2680. WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
  2681. .rtt_measreq_cmdid = WMI_TLV_RTT_MEASREQ_CMDID,
  2682. .rtt_tsf_cmdid = WMI_TLV_RTT_TSF_CMDID,
  2683. .vdev_spectral_scan_configure_cmdid = WMI_TLV_SPECTRAL_SCAN_CONF_CMDID,
  2684. .vdev_spectral_scan_enable_cmdid = WMI_TLV_SPECTRAL_SCAN_ENABLE_CMDID,
  2685. .request_stats_cmdid = WMI_TLV_REQUEST_STATS_CMDID,
  2686. .set_arp_ns_offload_cmdid = WMI_TLV_SET_ARP_NS_OFFLOAD_CMDID,
  2687. .network_list_offload_config_cmdid =
  2688. WMI_TLV_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
  2689. .gtk_offload_cmdid = WMI_TLV_GTK_OFFLOAD_CMDID,
  2690. .csa_offload_enable_cmdid = WMI_TLV_CSA_OFFLOAD_ENABLE_CMDID,
  2691. .csa_offload_chanswitch_cmdid = WMI_TLV_CSA_OFFLOAD_CHANSWITCH_CMDID,
  2692. .chatter_set_mode_cmdid = WMI_TLV_CHATTER_SET_MODE_CMDID,
  2693. .peer_tid_addba_cmdid = WMI_TLV_PEER_TID_ADDBA_CMDID,
  2694. .peer_tid_delba_cmdid = WMI_TLV_PEER_TID_DELBA_CMDID,
  2695. .sta_dtim_ps_method_cmdid = WMI_TLV_STA_DTIM_PS_METHOD_CMDID,
  2696. .sta_uapsd_auto_trig_cmdid = WMI_TLV_STA_UAPSD_AUTO_TRIG_CMDID,
  2697. .sta_keepalive_cmd = WMI_TLV_STA_KEEPALIVE_CMDID,
  2698. .echo_cmdid = WMI_TLV_ECHO_CMDID,
  2699. .pdev_utf_cmdid = WMI_TLV_PDEV_UTF_CMDID,
  2700. .dbglog_cfg_cmdid = WMI_TLV_DBGLOG_CFG_CMDID,
  2701. .pdev_qvit_cmdid = WMI_TLV_PDEV_QVIT_CMDID,
  2702. .pdev_ftm_intg_cmdid = WMI_TLV_PDEV_FTM_INTG_CMDID,
  2703. .vdev_set_keepalive_cmdid = WMI_TLV_VDEV_SET_KEEPALIVE_CMDID,
  2704. .vdev_get_keepalive_cmdid = WMI_TLV_VDEV_GET_KEEPALIVE_CMDID,
  2705. .force_fw_hang_cmdid = WMI_TLV_FORCE_FW_HANG_CMDID,
  2706. .gpio_config_cmdid = WMI_TLV_GPIO_CONFIG_CMDID,
  2707. .gpio_output_cmdid = WMI_TLV_GPIO_OUTPUT_CMDID,
  2708. .pdev_get_temperature_cmdid = WMI_TLV_CMD_UNSUPPORTED,
  2709. .vdev_set_wmm_params_cmdid = WMI_TLV_VDEV_SET_WMM_PARAMS_CMDID,
  2710. .tdls_set_state_cmdid = WMI_TLV_TDLS_SET_STATE_CMDID,
  2711. .tdls_peer_update_cmdid = WMI_TLV_TDLS_PEER_UPDATE_CMDID,
  2712. .adaptive_qcs_cmdid = WMI_TLV_RESMGR_ADAPTIVE_OCS_CMDID,
  2713. .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
  2714. .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
  2715. .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
  2716. .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
  2717. .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
  2718. .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
  2719. .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
  2720. .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
  2721. .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
  2722. .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
  2723. .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
  2724. .nan_cmdid = WMI_CMD_UNSUPPORTED,
  2725. .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
  2726. .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
  2727. .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
  2728. .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
  2729. .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
  2730. .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
  2731. .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
  2732. .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
  2733. .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
  2734. .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
  2735. .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
  2736. .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
  2737. .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
  2738. .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
  2739. .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
  2740. .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
  2741. .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
  2742. .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
  2743. .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
  2744. .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
  2745. };
  2746. static struct wmi_pdev_param_map wmi_tlv_pdev_param_map = {
  2747. .tx_chain_mask = WMI_TLV_PDEV_PARAM_TX_CHAIN_MASK,
  2748. .rx_chain_mask = WMI_TLV_PDEV_PARAM_RX_CHAIN_MASK,
  2749. .txpower_limit2g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT2G,
  2750. .txpower_limit5g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT5G,
  2751. .txpower_scale = WMI_TLV_PDEV_PARAM_TXPOWER_SCALE,
  2752. .beacon_gen_mode = WMI_TLV_PDEV_PARAM_BEACON_GEN_MODE,
  2753. .beacon_tx_mode = WMI_TLV_PDEV_PARAM_BEACON_TX_MODE,
  2754. .resmgr_offchan_mode = WMI_TLV_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
  2755. .protection_mode = WMI_TLV_PDEV_PARAM_PROTECTION_MODE,
  2756. .dynamic_bw = WMI_TLV_PDEV_PARAM_DYNAMIC_BW,
  2757. .non_agg_sw_retry_th = WMI_TLV_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
  2758. .agg_sw_retry_th = WMI_TLV_PDEV_PARAM_AGG_SW_RETRY_TH,
  2759. .sta_kickout_th = WMI_TLV_PDEV_PARAM_STA_KICKOUT_TH,
  2760. .ac_aggrsize_scaling = WMI_TLV_PDEV_PARAM_AC_AGGRSIZE_SCALING,
  2761. .ltr_enable = WMI_TLV_PDEV_PARAM_LTR_ENABLE,
  2762. .ltr_ac_latency_be = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BE,
  2763. .ltr_ac_latency_bk = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BK,
  2764. .ltr_ac_latency_vi = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VI,
  2765. .ltr_ac_latency_vo = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VO,
  2766. .ltr_ac_latency_timeout = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
  2767. .ltr_sleep_override = WMI_TLV_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
  2768. .ltr_rx_override = WMI_TLV_PDEV_PARAM_LTR_RX_OVERRIDE,
  2769. .ltr_tx_activity_timeout = WMI_TLV_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
  2770. .l1ss_enable = WMI_TLV_PDEV_PARAM_L1SS_ENABLE,
  2771. .dsleep_enable = WMI_TLV_PDEV_PARAM_DSLEEP_ENABLE,
  2772. .pcielp_txbuf_flush = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
  2773. .pcielp_txbuf_watermark = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
  2774. .pcielp_txbuf_tmo_en = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
  2775. .pcielp_txbuf_tmo_value = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
  2776. .pdev_stats_update_period = WMI_TLV_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
  2777. .vdev_stats_update_period = WMI_TLV_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
  2778. .peer_stats_update_period = WMI_TLV_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
  2779. .bcnflt_stats_update_period =
  2780. WMI_TLV_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
  2781. .pmf_qos = WMI_TLV_PDEV_PARAM_PMF_QOS,
  2782. .arp_ac_override = WMI_TLV_PDEV_PARAM_ARP_AC_OVERRIDE,
  2783. .dcs = WMI_TLV_PDEV_PARAM_DCS,
  2784. .ani_enable = WMI_TLV_PDEV_PARAM_ANI_ENABLE,
  2785. .ani_poll_period = WMI_TLV_PDEV_PARAM_ANI_POLL_PERIOD,
  2786. .ani_listen_period = WMI_TLV_PDEV_PARAM_ANI_LISTEN_PERIOD,
  2787. .ani_ofdm_level = WMI_TLV_PDEV_PARAM_ANI_OFDM_LEVEL,
  2788. .ani_cck_level = WMI_TLV_PDEV_PARAM_ANI_CCK_LEVEL,
  2789. .dyntxchain = WMI_TLV_PDEV_PARAM_DYNTXCHAIN,
  2790. .proxy_sta = WMI_TLV_PDEV_PARAM_PROXY_STA,
  2791. .idle_ps_config = WMI_TLV_PDEV_PARAM_IDLE_PS_CONFIG,
  2792. .power_gating_sleep = WMI_TLV_PDEV_PARAM_POWER_GATING_SLEEP,
  2793. .fast_channel_reset = WMI_TLV_PDEV_PARAM_UNSUPPORTED,
  2794. .burst_dur = WMI_TLV_PDEV_PARAM_BURST_DUR,
  2795. .burst_enable = WMI_TLV_PDEV_PARAM_BURST_ENABLE,
  2796. .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
  2797. .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
  2798. .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
  2799. .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
  2800. .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
  2801. .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
  2802. .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
  2803. .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
  2804. .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
  2805. .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
  2806. .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
  2807. .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
  2808. .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
  2809. .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
  2810. .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
  2811. .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
  2812. .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
  2813. .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
  2814. .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
  2815. .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
  2816. .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
  2817. .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
  2818. .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
  2819. .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
  2820. .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
  2821. .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
  2822. .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
  2823. .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
  2824. .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
  2825. .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
  2826. .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
  2827. .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
  2828. .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
  2829. .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
  2830. .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
  2831. .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
  2832. .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
  2833. .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
  2834. .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
  2835. .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
  2836. .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
  2837. .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
  2838. .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
  2839. };
  2840. static struct wmi_vdev_param_map wmi_tlv_vdev_param_map = {
  2841. .rts_threshold = WMI_TLV_VDEV_PARAM_RTS_THRESHOLD,
  2842. .fragmentation_threshold = WMI_TLV_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
  2843. .beacon_interval = WMI_TLV_VDEV_PARAM_BEACON_INTERVAL,
  2844. .listen_interval = WMI_TLV_VDEV_PARAM_LISTEN_INTERVAL,
  2845. .multicast_rate = WMI_TLV_VDEV_PARAM_MULTICAST_RATE,
  2846. .mgmt_tx_rate = WMI_TLV_VDEV_PARAM_MGMT_TX_RATE,
  2847. .slot_time = WMI_TLV_VDEV_PARAM_SLOT_TIME,
  2848. .preamble = WMI_TLV_VDEV_PARAM_PREAMBLE,
  2849. .swba_time = WMI_TLV_VDEV_PARAM_SWBA_TIME,
  2850. .wmi_vdev_stats_update_period = WMI_TLV_VDEV_STATS_UPDATE_PERIOD,
  2851. .wmi_vdev_pwrsave_ageout_time = WMI_TLV_VDEV_PWRSAVE_AGEOUT_TIME,
  2852. .wmi_vdev_host_swba_interval = WMI_TLV_VDEV_HOST_SWBA_INTERVAL,
  2853. .dtim_period = WMI_TLV_VDEV_PARAM_DTIM_PERIOD,
  2854. .wmi_vdev_oc_scheduler_air_time_limit =
  2855. WMI_TLV_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
  2856. .wds = WMI_TLV_VDEV_PARAM_WDS,
  2857. .atim_window = WMI_TLV_VDEV_PARAM_ATIM_WINDOW,
  2858. .bmiss_count_max = WMI_TLV_VDEV_PARAM_BMISS_COUNT_MAX,
  2859. .bmiss_first_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FIRST_BCNT,
  2860. .bmiss_final_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FINAL_BCNT,
  2861. .feature_wmm = WMI_TLV_VDEV_PARAM_FEATURE_WMM,
  2862. .chwidth = WMI_TLV_VDEV_PARAM_CHWIDTH,
  2863. .chextoffset = WMI_TLV_VDEV_PARAM_CHEXTOFFSET,
  2864. .disable_htprotection = WMI_TLV_VDEV_PARAM_DISABLE_HTPROTECTION,
  2865. .sta_quickkickout = WMI_TLV_VDEV_PARAM_STA_QUICKKICKOUT,
  2866. .mgmt_rate = WMI_TLV_VDEV_PARAM_MGMT_RATE,
  2867. .protection_mode = WMI_TLV_VDEV_PARAM_PROTECTION_MODE,
  2868. .fixed_rate = WMI_TLV_VDEV_PARAM_FIXED_RATE,
  2869. .sgi = WMI_TLV_VDEV_PARAM_SGI,
  2870. .ldpc = WMI_TLV_VDEV_PARAM_LDPC,
  2871. .tx_stbc = WMI_TLV_VDEV_PARAM_TX_STBC,
  2872. .rx_stbc = WMI_TLV_VDEV_PARAM_RX_STBC,
  2873. .intra_bss_fwd = WMI_TLV_VDEV_PARAM_INTRA_BSS_FWD,
  2874. .def_keyid = WMI_TLV_VDEV_PARAM_DEF_KEYID,
  2875. .nss = WMI_TLV_VDEV_PARAM_NSS,
  2876. .bcast_data_rate = WMI_TLV_VDEV_PARAM_BCAST_DATA_RATE,
  2877. .mcast_data_rate = WMI_TLV_VDEV_PARAM_MCAST_DATA_RATE,
  2878. .mcast_indicate = WMI_TLV_VDEV_PARAM_MCAST_INDICATE,
  2879. .dhcp_indicate = WMI_TLV_VDEV_PARAM_DHCP_INDICATE,
  2880. .unknown_dest_indicate = WMI_TLV_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
  2881. .ap_keepalive_min_idle_inactive_time_secs =
  2882. WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
  2883. .ap_keepalive_max_idle_inactive_time_secs =
  2884. WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
  2885. .ap_keepalive_max_unresponsive_time_secs =
  2886. WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
  2887. .ap_enable_nawds = WMI_TLV_VDEV_PARAM_AP_ENABLE_NAWDS,
  2888. .mcast2ucast_set = WMI_TLV_VDEV_PARAM_UNSUPPORTED,
  2889. .enable_rtscts = WMI_TLV_VDEV_PARAM_ENABLE_RTSCTS,
  2890. .txbf = WMI_TLV_VDEV_PARAM_TXBF,
  2891. .packet_powersave = WMI_TLV_VDEV_PARAM_PACKET_POWERSAVE,
  2892. .drop_unencry = WMI_TLV_VDEV_PARAM_DROP_UNENCRY,
  2893. .tx_encap_type = WMI_TLV_VDEV_PARAM_TX_ENCAP_TYPE,
  2894. .ap_detect_out_of_sync_sleeping_sta_time_secs =
  2895. WMI_TLV_VDEV_PARAM_UNSUPPORTED,
  2896. .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
  2897. .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
  2898. .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
  2899. .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
  2900. .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
  2901. .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
  2902. .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
  2903. .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
  2904. .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
  2905. .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
  2906. .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
  2907. .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
  2908. .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
  2909. .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
  2910. .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
  2911. .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
  2912. };
  2913. static const struct wmi_ops wmi_tlv_ops = {
  2914. .rx = ath10k_wmi_tlv_op_rx,
  2915. .map_svc = wmi_tlv_svc_map,
  2916. .pull_scan = ath10k_wmi_tlv_op_pull_scan_ev,
  2917. .pull_mgmt_rx = ath10k_wmi_tlv_op_pull_mgmt_rx_ev,
  2918. .pull_ch_info = ath10k_wmi_tlv_op_pull_ch_info_ev,
  2919. .pull_vdev_start = ath10k_wmi_tlv_op_pull_vdev_start_ev,
  2920. .pull_peer_kick = ath10k_wmi_tlv_op_pull_peer_kick_ev,
  2921. .pull_swba = ath10k_wmi_tlv_op_pull_swba_ev,
  2922. .pull_phyerr_hdr = ath10k_wmi_tlv_op_pull_phyerr_ev_hdr,
  2923. .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
  2924. .pull_svc_rdy = ath10k_wmi_tlv_op_pull_svc_rdy_ev,
  2925. .pull_rdy = ath10k_wmi_tlv_op_pull_rdy_ev,
  2926. .pull_fw_stats = ath10k_wmi_tlv_op_pull_fw_stats,
  2927. .pull_roam_ev = ath10k_wmi_tlv_op_pull_roam_ev,
  2928. .pull_wow_event = ath10k_wmi_tlv_op_pull_wow_ev,
  2929. .get_txbf_conf_scheme = ath10k_wmi_tlv_txbf_conf_scheme,
  2930. .gen_pdev_suspend = ath10k_wmi_tlv_op_gen_pdev_suspend,
  2931. .gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume,
  2932. .gen_pdev_set_rd = ath10k_wmi_tlv_op_gen_pdev_set_rd,
  2933. .gen_pdev_set_param = ath10k_wmi_tlv_op_gen_pdev_set_param,
  2934. .gen_init = ath10k_wmi_tlv_op_gen_init,
  2935. .gen_start_scan = ath10k_wmi_tlv_op_gen_start_scan,
  2936. .gen_stop_scan = ath10k_wmi_tlv_op_gen_stop_scan,
  2937. .gen_vdev_create = ath10k_wmi_tlv_op_gen_vdev_create,
  2938. .gen_vdev_delete = ath10k_wmi_tlv_op_gen_vdev_delete,
  2939. .gen_vdev_start = ath10k_wmi_tlv_op_gen_vdev_start,
  2940. .gen_vdev_stop = ath10k_wmi_tlv_op_gen_vdev_stop,
  2941. .gen_vdev_up = ath10k_wmi_tlv_op_gen_vdev_up,
  2942. .gen_vdev_down = ath10k_wmi_tlv_op_gen_vdev_down,
  2943. .gen_vdev_set_param = ath10k_wmi_tlv_op_gen_vdev_set_param,
  2944. .gen_vdev_install_key = ath10k_wmi_tlv_op_gen_vdev_install_key,
  2945. .gen_vdev_wmm_conf = ath10k_wmi_tlv_op_gen_vdev_wmm_conf,
  2946. .gen_peer_create = ath10k_wmi_tlv_op_gen_peer_create,
  2947. .gen_peer_delete = ath10k_wmi_tlv_op_gen_peer_delete,
  2948. .gen_peer_flush = ath10k_wmi_tlv_op_gen_peer_flush,
  2949. .gen_peer_set_param = ath10k_wmi_tlv_op_gen_peer_set_param,
  2950. .gen_peer_assoc = ath10k_wmi_tlv_op_gen_peer_assoc,
  2951. .gen_set_psmode = ath10k_wmi_tlv_op_gen_set_psmode,
  2952. .gen_set_sta_ps = ath10k_wmi_tlv_op_gen_set_sta_ps,
  2953. .gen_set_ap_ps = ath10k_wmi_tlv_op_gen_set_ap_ps,
  2954. .gen_scan_chan_list = ath10k_wmi_tlv_op_gen_scan_chan_list,
  2955. .gen_beacon_dma = ath10k_wmi_tlv_op_gen_beacon_dma,
  2956. .gen_pdev_set_wmm = ath10k_wmi_tlv_op_gen_pdev_set_wmm,
  2957. .gen_request_stats = ath10k_wmi_tlv_op_gen_request_stats,
  2958. .gen_force_fw_hang = ath10k_wmi_tlv_op_gen_force_fw_hang,
  2959. /* .gen_mgmt_tx = not implemented; HTT is used */
  2960. .gen_dbglog_cfg = ath10k_wmi_tlv_op_gen_dbglog_cfg,
  2961. .gen_pktlog_enable = ath10k_wmi_tlv_op_gen_pktlog_enable,
  2962. .gen_pktlog_disable = ath10k_wmi_tlv_op_gen_pktlog_disable,
  2963. /* .gen_pdev_set_quiet_mode not implemented */
  2964. /* .gen_pdev_get_temperature not implemented */
  2965. /* .gen_addba_clear_resp not implemented */
  2966. /* .gen_addba_send not implemented */
  2967. /* .gen_addba_set_resp not implemented */
  2968. /* .gen_delba_send not implemented */
  2969. .gen_bcn_tmpl = ath10k_wmi_tlv_op_gen_bcn_tmpl,
  2970. .gen_prb_tmpl = ath10k_wmi_tlv_op_gen_prb_tmpl,
  2971. .gen_p2p_go_bcn_ie = ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie,
  2972. .gen_vdev_sta_uapsd = ath10k_wmi_tlv_op_gen_vdev_sta_uapsd,
  2973. .gen_sta_keepalive = ath10k_wmi_tlv_op_gen_sta_keepalive,
  2974. .gen_wow_enable = ath10k_wmi_tlv_op_gen_wow_enable,
  2975. .gen_wow_add_wakeup_event = ath10k_wmi_tlv_op_gen_wow_add_wakeup_event,
  2976. .gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind,
  2977. .gen_wow_add_pattern = ath10k_wmi_tlv_op_gen_wow_add_pattern,
  2978. .gen_wow_del_pattern = ath10k_wmi_tlv_op_gen_wow_del_pattern,
  2979. .gen_update_fw_tdls_state = ath10k_wmi_tlv_op_gen_update_fw_tdls_state,
  2980. .gen_tdls_peer_update = ath10k_wmi_tlv_op_gen_tdls_peer_update,
  2981. .gen_adaptive_qcs = ath10k_wmi_tlv_op_gen_adaptive_qcs,
  2982. .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
  2983. };
  2984. /************/
  2985. /* TLV init */
  2986. /************/
  2987. void ath10k_wmi_tlv_attach(struct ath10k *ar)
  2988. {
  2989. ar->wmi.cmd = &wmi_tlv_cmd_map;
  2990. ar->wmi.vdev_param = &wmi_tlv_vdev_param_map;
  2991. ar->wmi.pdev_param = &wmi_tlv_pdev_param_map;
  2992. ar->wmi.ops = &wmi_tlv_ops;
  2993. }