wmi_unified_roam_tlv.c 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237
  1. /*
  2. * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /**
  17. * DOC: Implement API's specific to roaming component.
  18. */
  19. #include <wmi_unified_priv.h>
  20. #include <wmi_unified_roam_api.h>
  21. #include "wmi.h"
  22. #ifdef FEATURE_LFR_SUBNET_DETECTION
  23. /**
  24. * send_set_gateway_params_cmd_tlv() - set gateway parameters
  25. * @wmi_handle: wmi handle
  26. * @req: gateway parameter update request structure
  27. *
  28. * This function reads the incoming @req and fill in the destination
  29. * WMI structure and sends down the gateway configs down to the firmware
  30. *
  31. * Return: QDF_STATUS
  32. */
  33. static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
  34. struct gateway_update_req_param *req)
  35. {
  36. wmi_roam_subnet_change_config_fixed_param *cmd;
  37. wmi_buf_t buf;
  38. QDF_STATUS ret;
  39. int len = sizeof(*cmd);
  40. buf = wmi_buf_alloc(wmi_handle, len);
  41. if (!buf)
  42. return QDF_STATUS_E_NOMEM;
  43. cmd = (wmi_roam_subnet_change_config_fixed_param *)wmi_buf_data(buf);
  44. WMITLV_SET_HDR(&cmd->tlv_header,
  45. WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
  46. WMITLV_GET_STRUCT_TLVLEN(
  47. wmi_roam_subnet_change_config_fixed_param));
  48. cmd->vdev_id = req->vdev_id;
  49. qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
  50. QDF_IPV4_ADDR_SIZE);
  51. qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
  52. QDF_IPV6_ADDR_SIZE);
  53. WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
  54. &cmd->inet_gw_mac_addr);
  55. cmd->max_retries = req->max_retries;
  56. cmd->timeout = req->timeout;
  57. cmd->num_skip_subnet_change_detection_bssid_list = 0;
  58. cmd->flag = 0;
  59. if (req->ipv4_addr_type)
  60. WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
  61. if (req->ipv6_addr_type)
  62. WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
  63. wmi_mtrace(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID, cmd->vdev_id, 0);
  64. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  65. WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
  66. if (QDF_IS_STATUS_ERROR(ret)) {
  67. WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
  68. ret);
  69. wmi_buf_free(buf);
  70. }
  71. return ret;
  72. }
  73. void wmi_lfr_subnet_detection_attach_tlv(struct wmi_unified *wmi_handle)
  74. {
  75. struct wmi_ops *ops = wmi_handle->ops;
  76. ops->send_set_gateway_params_cmd = send_set_gateway_params_cmd_tlv;
  77. }
  78. #endif /* FEATURE_LFR_SUBNET_DETECTION */
  79. #ifdef FEATURE_RSSI_MONITOR
  80. /**
  81. * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
  82. * @wmi_handle: wmi handle
  83. * @req: rssi monitoring request structure
  84. *
  85. * This function reads the incoming @req and fill in the destination
  86. * WMI structure and send down the rssi monitoring configs down to the firmware
  87. *
  88. * Return: 0 on success; error number otherwise
  89. */
  90. static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
  91. struct rssi_monitor_param *req)
  92. {
  93. wmi_rssi_breach_monitor_config_fixed_param *cmd;
  94. wmi_buf_t buf;
  95. QDF_STATUS ret;
  96. uint32_t len = sizeof(*cmd);
  97. buf = wmi_buf_alloc(wmi_handle, len);
  98. if (!buf)
  99. return QDF_STATUS_E_NOMEM;
  100. cmd = (wmi_rssi_breach_monitor_config_fixed_param *)wmi_buf_data(buf);
  101. WMITLV_SET_HDR(&cmd->tlv_header,
  102. WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
  103. WMITLV_GET_STRUCT_TLVLEN(
  104. wmi_rssi_breach_monitor_config_fixed_param));
  105. cmd->vdev_id = req->vdev_id;
  106. cmd->request_id = req->request_id;
  107. cmd->lo_rssi_reenable_hysteresis = 0;
  108. cmd->hi_rssi_reenable_histeresis = 0;
  109. cmd->min_report_interval = 0;
  110. cmd->max_num_report = 1;
  111. if (req->control) {
  112. /* enable one threshold for each min/max */
  113. cmd->enabled_bitmap = 0x09;
  114. cmd->low_rssi_breach_threshold[0] = req->min_rssi;
  115. cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
  116. } else {
  117. cmd->enabled_bitmap = 0;
  118. cmd->low_rssi_breach_threshold[0] = 0;
  119. cmd->hi_rssi_breach_threshold[0] = 0;
  120. }
  121. wmi_mtrace(WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID, cmd->vdev_id, 0);
  122. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  123. WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
  124. if (QDF_IS_STATUS_ERROR(ret)) {
  125. WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
  126. wmi_buf_free(buf);
  127. }
  128. WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
  129. return ret;
  130. }
  131. void wmi_rssi_monitor_attach_tlv(struct wmi_unified *wmi_handle)
  132. {
  133. struct wmi_ops *ops = wmi_handle->ops;
  134. ops->send_set_rssi_monitoring_cmd = send_set_rssi_monitoring_cmd_tlv;
  135. }
  136. #endif /* FEATURE_RSSI_MONITOR */
  137. #ifdef ROAM_OFFLOAD_V1
  138. /**
  139. * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
  140. * rssi threashold
  141. * @wmi_handle: wmi handle
  142. * @roam_req: Roaming request buffer
  143. *
  144. * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
  145. *
  146. * Return: QDF status
  147. */
  148. static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(
  149. wmi_unified_t wmi_handle,
  150. struct wlan_roam_offload_scan_rssi_params *roam_req)
  151. {
  152. wmi_buf_t buf = NULL;
  153. QDF_STATUS status;
  154. int len;
  155. uint8_t *buf_ptr;
  156. wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
  157. wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
  158. wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
  159. wmi_roam_dense_thres_param *dense_thresholds = NULL;
  160. wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
  161. len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
  162. len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
  163. len += sizeof(wmi_roam_scan_extended_threshold_param);
  164. len += WMI_TLV_HDR_SIZE;
  165. len += sizeof(wmi_roam_earlystop_rssi_thres_param);
  166. len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
  167. len += sizeof(wmi_roam_dense_thres_param);
  168. len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
  169. len += sizeof(wmi_roam_bg_scan_roaming_param);
  170. buf = wmi_buf_alloc(wmi_handle, len);
  171. if (!buf)
  172. return QDF_STATUS_E_NOMEM;
  173. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  174. rssi_threshold_fp =
  175. (wmi_roam_scan_rssi_threshold_fixed_param *)buf_ptr;
  176. WMITLV_SET_HDR(
  177. &rssi_threshold_fp->tlv_header,
  178. WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
  179. WMITLV_GET_STRUCT_TLVLEN
  180. (wmi_roam_scan_rssi_threshold_fixed_param));
  181. /* fill in threshold values */
  182. rssi_threshold_fp->vdev_id = roam_req->vdev_id;
  183. rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
  184. rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
  185. rssi_threshold_fp->hirssi_scan_max_count =
  186. roam_req->hi_rssi_scan_max_count;
  187. rssi_threshold_fp->hirssi_scan_delta =
  188. roam_req->hi_rssi_scan_rssi_delta;
  189. rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
  190. rssi_threshold_fp->rssi_thresh_offset_5g =
  191. roam_req->rssi_thresh_offset_5g;
  192. buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
  193. WMITLV_SET_HDR(buf_ptr,
  194. WMITLV_TAG_ARRAY_STRUC,
  195. sizeof(wmi_roam_scan_extended_threshold_param));
  196. buf_ptr += WMI_TLV_HDR_SIZE;
  197. ext_thresholds = (wmi_roam_scan_extended_threshold_param *)buf_ptr;
  198. ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
  199. if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
  200. ext_thresholds->boost_threshold_5g =
  201. roam_req->boost_threshold_5g;
  202. ext_thresholds->boost_algorithm_5g =
  203. WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
  204. ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
  205. ext_thresholds->penalty_algorithm_5g =
  206. WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
  207. ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
  208. ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
  209. ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
  210. ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
  211. WMITLV_SET_HDR(&ext_thresholds->tlv_header,
  212. WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
  213. WMITLV_GET_STRUCT_TLVLEN
  214. (wmi_roam_scan_extended_threshold_param));
  215. buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
  216. WMITLV_SET_HDR(buf_ptr,
  217. WMITLV_TAG_ARRAY_STRUC,
  218. sizeof(wmi_roam_earlystop_rssi_thres_param));
  219. buf_ptr += WMI_TLV_HDR_SIZE;
  220. early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *)buf_ptr;
  221. early_stop_thresholds->roam_earlystop_thres_min =
  222. roam_req->roam_earlystop_thres_min;
  223. early_stop_thresholds->roam_earlystop_thres_max =
  224. roam_req->roam_earlystop_thres_max;
  225. WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
  226. WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
  227. WMITLV_GET_STRUCT_TLVLEN
  228. (wmi_roam_earlystop_rssi_thres_param));
  229. buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
  230. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  231. sizeof(wmi_roam_dense_thres_param));
  232. buf_ptr += WMI_TLV_HDR_SIZE;
  233. dense_thresholds = (wmi_roam_dense_thres_param *)buf_ptr;
  234. dense_thresholds->roam_dense_rssi_thres_offset =
  235. roam_req->dense_rssi_thresh_offset;
  236. dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
  237. dense_thresholds->roam_dense_traffic_thres =
  238. roam_req->traffic_threshold;
  239. dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
  240. WMITLV_SET_HDR(&dense_thresholds->tlv_header,
  241. WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
  242. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_dense_thres_param));
  243. buf_ptr += sizeof(wmi_roam_dense_thres_param);
  244. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  245. sizeof(wmi_roam_bg_scan_roaming_param));
  246. buf_ptr += WMI_TLV_HDR_SIZE;
  247. bg_scan_params = (wmi_roam_bg_scan_roaming_param *)buf_ptr;
  248. bg_scan_params->roam_bg_scan_bad_rssi_thresh =
  249. roam_req->bg_scan_bad_rssi_thresh;
  250. bg_scan_params->roam_bg_scan_client_bitmap =
  251. roam_req->bg_scan_client_bitmap;
  252. bg_scan_params->bad_rssi_thresh_offset_2g =
  253. roam_req->roam_bad_rssi_thresh_offset_2g;
  254. bg_scan_params->flags = 0;
  255. if (roam_req->roam_bad_rssi_thresh_offset_2g)
  256. bg_scan_params->flags |= WMI_ROAM_BG_SCAN_FLAGS_2G_TO_5G_ONLY;
  257. WMITLV_SET_HDR(&bg_scan_params->tlv_header,
  258. WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
  259. WMITLV_GET_STRUCT_TLVLEN
  260. (wmi_roam_bg_scan_roaming_param));
  261. wmi_mtrace(WMI_ROAM_SCAN_RSSI_THRESHOLD, NO_SESSION, 0);
  262. status = wmi_unified_cmd_send(wmi_handle, buf,
  263. len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
  264. if (QDF_IS_STATUS_ERROR(status)) {
  265. WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
  266. status);
  267. wmi_buf_free(buf);
  268. }
  269. return status;
  270. }
  271. /**
  272. * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
  273. * @wmi_handle: wmi handle
  274. * @param: roam scan parameters to be sent to firmware
  275. *
  276. * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
  277. *
  278. * Return: QDF status
  279. */
  280. static QDF_STATUS
  281. send_roam_scan_offload_scan_period_cmd_tlv(
  282. wmi_unified_t wmi_handle,
  283. struct wlan_roam_scan_period_params *param)
  284. {
  285. QDF_STATUS status;
  286. wmi_buf_t buf = NULL;
  287. int len;
  288. uint8_t *buf_ptr;
  289. wmi_roam_scan_period_fixed_param *scan_period_fp;
  290. /* Send scan period values */
  291. len = sizeof(wmi_roam_scan_period_fixed_param);
  292. buf = wmi_buf_alloc(wmi_handle, len);
  293. if (!buf)
  294. return QDF_STATUS_E_NOMEM;
  295. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  296. scan_period_fp = (wmi_roam_scan_period_fixed_param *)buf_ptr;
  297. WMITLV_SET_HDR(&scan_period_fp->tlv_header,
  298. WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
  299. WMITLV_GET_STRUCT_TLVLEN
  300. (wmi_roam_scan_period_fixed_param));
  301. /* fill in scan period values */
  302. scan_period_fp->vdev_id = param->vdev_id;
  303. scan_period_fp->roam_scan_period = param->scan_period;
  304. scan_period_fp->roam_scan_age = param->scan_age;
  305. scan_period_fp->inactivity_time_period =
  306. param->roam_scan_inactivity_time;
  307. scan_period_fp->roam_inactive_count =
  308. param->roam_inactive_data_packet_count;
  309. scan_period_fp->roam_scan_period_after_inactivity =
  310. param->roam_scan_period_after_inactivity;
  311. /* Firmware expects the full scan preriod in msec whereas host
  312. * provides the same in seconds.
  313. * Convert it to msec and send to firmware
  314. */
  315. scan_period_fp->roam_full_scan_period = param->full_scan_period * 1000;
  316. wmi_debug("roam_scan_period=%d, roam_scan_age=%d, full_scan_period= %u",
  317. scan_period_fp->roam_scan_period,
  318. scan_period_fp->roam_scan_age,
  319. scan_period_fp->roam_full_scan_period);
  320. wmi_debug("inactiviy time:%d inactive cnt:%d time after inactivity:%d",
  321. scan_period_fp->inactivity_time_period,
  322. scan_period_fp->roam_inactive_count,
  323. scan_period_fp->roam_scan_period_after_inactivity);
  324. wmi_mtrace(WMI_ROAM_SCAN_PERIOD, NO_SESSION, 0);
  325. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  326. WMI_ROAM_SCAN_PERIOD);
  327. if (QDF_IS_STATUS_ERROR(status)) {
  328. wmi_buf_free(buf);
  329. return status;
  330. }
  331. return QDF_STATUS_SUCCESS;
  332. }
  333. #else
  334. static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(
  335. wmi_unified_t wmi_handle,
  336. struct roam_offload_scan_rssi_params *roam_req)
  337. {
  338. wmi_buf_t buf = NULL;
  339. QDF_STATUS status;
  340. int len;
  341. uint8_t *buf_ptr;
  342. wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
  343. wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
  344. wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
  345. wmi_roam_dense_thres_param *dense_thresholds = NULL;
  346. wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
  347. len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
  348. len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
  349. len += sizeof(wmi_roam_scan_extended_threshold_param);
  350. len += WMI_TLV_HDR_SIZE;
  351. len += sizeof(wmi_roam_earlystop_rssi_thres_param);
  352. len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
  353. len += sizeof(wmi_roam_dense_thres_param);
  354. len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
  355. len += sizeof(wmi_roam_bg_scan_roaming_param);
  356. buf = wmi_buf_alloc(wmi_handle, len);
  357. if (!buf)
  358. return QDF_STATUS_E_NOMEM;
  359. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  360. rssi_threshold_fp =
  361. (wmi_roam_scan_rssi_threshold_fixed_param *)buf_ptr;
  362. WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
  363. WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
  364. WMITLV_GET_STRUCT_TLVLEN
  365. (wmi_roam_scan_rssi_threshold_fixed_param));
  366. /* fill in threshold values */
  367. rssi_threshold_fp->vdev_id = roam_req->vdev_id;
  368. rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
  369. rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
  370. rssi_threshold_fp->hirssi_scan_max_count =
  371. roam_req->hi_rssi_scan_max_count;
  372. rssi_threshold_fp->hirssi_scan_delta =
  373. roam_req->hi_rssi_scan_rssi_delta;
  374. rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
  375. rssi_threshold_fp->rssi_thresh_offset_5g =
  376. roam_req->rssi_thresh_offset_5g;
  377. buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
  378. WMITLV_SET_HDR(buf_ptr,
  379. WMITLV_TAG_ARRAY_STRUC,
  380. sizeof(wmi_roam_scan_extended_threshold_param));
  381. buf_ptr += WMI_TLV_HDR_SIZE;
  382. ext_thresholds = (wmi_roam_scan_extended_threshold_param *)buf_ptr;
  383. ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
  384. if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
  385. ext_thresholds->boost_threshold_5g =
  386. roam_req->boost_threshold_5g;
  387. ext_thresholds->boost_algorithm_5g =
  388. WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
  389. ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
  390. ext_thresholds->penalty_algorithm_5g =
  391. WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
  392. ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
  393. ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
  394. ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
  395. ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
  396. WMITLV_SET_HDR(&ext_thresholds->tlv_header,
  397. WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
  398. WMITLV_GET_STRUCT_TLVLEN
  399. (wmi_roam_scan_extended_threshold_param));
  400. buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
  401. WMITLV_SET_HDR(buf_ptr,
  402. WMITLV_TAG_ARRAY_STRUC,
  403. sizeof(wmi_roam_earlystop_rssi_thres_param));
  404. buf_ptr += WMI_TLV_HDR_SIZE;
  405. early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *)buf_ptr;
  406. early_stop_thresholds->roam_earlystop_thres_min =
  407. roam_req->roam_earlystop_thres_min;
  408. early_stop_thresholds->roam_earlystop_thres_max =
  409. roam_req->roam_earlystop_thres_max;
  410. WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
  411. WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
  412. WMITLV_GET_STRUCT_TLVLEN
  413. (wmi_roam_earlystop_rssi_thres_param));
  414. buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
  415. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  416. sizeof(wmi_roam_dense_thres_param));
  417. buf_ptr += WMI_TLV_HDR_SIZE;
  418. dense_thresholds = (wmi_roam_dense_thres_param *)buf_ptr;
  419. dense_thresholds->roam_dense_rssi_thres_offset =
  420. roam_req->dense_rssi_thresh_offset;
  421. dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
  422. dense_thresholds->roam_dense_traffic_thres =
  423. roam_req->traffic_threshold;
  424. dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
  425. WMITLV_SET_HDR(&dense_thresholds->tlv_header,
  426. WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
  427. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_dense_thres_param));
  428. buf_ptr += sizeof(wmi_roam_dense_thres_param);
  429. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  430. sizeof(wmi_roam_bg_scan_roaming_param));
  431. buf_ptr += WMI_TLV_HDR_SIZE;
  432. bg_scan_params = (wmi_roam_bg_scan_roaming_param *)buf_ptr;
  433. bg_scan_params->roam_bg_scan_bad_rssi_thresh =
  434. roam_req->bg_scan_bad_rssi_thresh;
  435. bg_scan_params->roam_bg_scan_client_bitmap =
  436. roam_req->bg_scan_client_bitmap;
  437. bg_scan_params->bad_rssi_thresh_offset_2g =
  438. roam_req->roam_bad_rssi_thresh_offset_2g;
  439. bg_scan_params->flags = roam_req->flags;
  440. WMITLV_SET_HDR(&bg_scan_params->tlv_header,
  441. WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
  442. WMITLV_GET_STRUCT_TLVLEN
  443. (wmi_roam_bg_scan_roaming_param));
  444. wmi_mtrace(WMI_ROAM_SCAN_RSSI_THRESHOLD, NO_SESSION, 0);
  445. status = wmi_unified_cmd_send(wmi_handle, buf,
  446. len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
  447. if (QDF_IS_STATUS_ERROR(status)) {
  448. WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
  449. status);
  450. wmi_buf_free(buf);
  451. }
  452. return status;
  453. }
  454. /**
  455. * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
  456. * @wmi_handle: wmi handle
  457. * @param: roam scan parameters to be sent to firmware
  458. *
  459. * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
  460. *
  461. * Return: QDF status
  462. */
  463. static QDF_STATUS
  464. send_roam_scan_offload_scan_period_cmd_tlv(
  465. wmi_unified_t wmi_handle,
  466. struct roam_scan_period_params *param)
  467. {
  468. QDF_STATUS status;
  469. wmi_buf_t buf = NULL;
  470. int len;
  471. uint8_t *buf_ptr;
  472. wmi_roam_scan_period_fixed_param *scan_period_fp;
  473. /* Send scan period values */
  474. len = sizeof(wmi_roam_scan_period_fixed_param);
  475. buf = wmi_buf_alloc(wmi_handle, len);
  476. if (!buf)
  477. return QDF_STATUS_E_NOMEM;
  478. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  479. scan_period_fp = (wmi_roam_scan_period_fixed_param *)buf_ptr;
  480. WMITLV_SET_HDR(&scan_period_fp->tlv_header,
  481. WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
  482. WMITLV_GET_STRUCT_TLVLEN
  483. (wmi_roam_scan_period_fixed_param));
  484. /* fill in scan period values */
  485. scan_period_fp->vdev_id = param->vdev_id;
  486. scan_period_fp->roam_scan_period = param->scan_period;
  487. scan_period_fp->roam_scan_age = param->scan_age;
  488. scan_period_fp->inactivity_time_period =
  489. param->roam_scan_inactivity_time;
  490. scan_period_fp->roam_inactive_count =
  491. param->roam_inactive_data_packet_count;
  492. scan_period_fp->roam_scan_period_after_inactivity =
  493. param->roam_scan_period_after_inactivity;
  494. /* Firmware expects the full scan preriod in msec whereas host
  495. * provides the same in seconds.
  496. * Convert it to msec and send to firmware
  497. */
  498. scan_period_fp->roam_full_scan_period = param->full_scan_period * 1000;
  499. wmi_debug("roam_scan_period=%d, roam_scan_age=%d, full_scan_period= %u",
  500. scan_period_fp->roam_scan_period,
  501. scan_period_fp->roam_scan_age,
  502. scan_period_fp->roam_full_scan_period);
  503. wmi_debug("inactiviy time:%d inactive cnt:%d time after inactivity:%d",
  504. scan_period_fp->inactivity_time_period,
  505. scan_period_fp->roam_inactive_count,
  506. scan_period_fp->roam_scan_period_after_inactivity);
  507. wmi_mtrace(WMI_ROAM_SCAN_PERIOD, NO_SESSION, 0);
  508. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  509. WMI_ROAM_SCAN_PERIOD);
  510. if (QDF_IS_STATUS_ERROR(status)) {
  511. wmi_buf_free(buf);
  512. return status;
  513. }
  514. return QDF_STATUS_SUCCESS;
  515. }
  516. #endif
  517. static QDF_STATUS send_roam_mawc_params_cmd_tlv(
  518. wmi_unified_t wmi_handle,
  519. struct wlan_roam_mawc_params *params)
  520. {
  521. wmi_buf_t buf = NULL;
  522. QDF_STATUS status;
  523. int len;
  524. uint8_t *buf_ptr;
  525. wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
  526. len = sizeof(*wmi_roam_mawc_params);
  527. buf = wmi_buf_alloc(wmi_handle, len);
  528. if (!buf)
  529. return QDF_STATUS_E_NOMEM;
  530. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  531. wmi_roam_mawc_params =
  532. (wmi_roam_configure_mawc_cmd_fixed_param *)buf_ptr;
  533. WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
  534. WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
  535. WMITLV_GET_STRUCT_TLVLEN
  536. (wmi_roam_configure_mawc_cmd_fixed_param));
  537. wmi_roam_mawc_params->vdev_id = params->vdev_id;
  538. if (params->enable)
  539. wmi_roam_mawc_params->enable = 1;
  540. else
  541. wmi_roam_mawc_params->enable = 0;
  542. wmi_roam_mawc_params->traffic_load_threshold =
  543. params->traffic_load_threshold;
  544. wmi_roam_mawc_params->best_ap_rssi_threshold =
  545. params->best_ap_rssi_threshold;
  546. wmi_roam_mawc_params->rssi_stationary_high_adjust =
  547. params->rssi_stationary_high_adjust;
  548. wmi_roam_mawc_params->rssi_stationary_low_adjust =
  549. params->rssi_stationary_low_adjust;
  550. WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
  551. wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
  552. wmi_roam_mawc_params->traffic_load_threshold,
  553. wmi_roam_mawc_params->best_ap_rssi_threshold,
  554. wmi_roam_mawc_params->rssi_stationary_high_adjust,
  555. wmi_roam_mawc_params->rssi_stationary_low_adjust);
  556. wmi_mtrace(WMI_ROAM_CONFIGURE_MAWC_CMDID, NO_SESSION, 0);
  557. status = wmi_unified_cmd_send(wmi_handle, buf,
  558. len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
  559. if (QDF_IS_STATUS_ERROR(status)) {
  560. WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
  561. status);
  562. wmi_buf_free(buf);
  563. return status;
  564. }
  565. return QDF_STATUS_SUCCESS;
  566. }
  567. /**
  568. * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
  569. * @wmi_handle: wmi handle
  570. * @roam_req: Request which contains the filters
  571. *
  572. * There are filters such as whitelist, blacklist and preferred
  573. * list that need to be applied to the scan results to form the
  574. * probable candidates for roaming.
  575. *
  576. * Return: Return success upon successfully passing the
  577. * parameters to the firmware, otherwise failure.
  578. */
  579. static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
  580. struct roam_scan_filter_params *roam_req)
  581. {
  582. wmi_buf_t buf = NULL;
  583. QDF_STATUS status;
  584. uint32_t i;
  585. uint32_t len, blist_len = 0;
  586. uint8_t *buf_ptr;
  587. wmi_roam_filter_fixed_param *roam_filter;
  588. uint8_t *bssid_src_ptr = NULL;
  589. wmi_mac_addr *bssid_dst_ptr = NULL;
  590. wmi_ssid *ssid_ptr = NULL;
  591. uint32_t *bssid_preferred_factor_ptr = NULL;
  592. wmi_roam_lca_disallow_config_tlv_param *blist_param;
  593. wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
  594. len = sizeof(wmi_roam_filter_fixed_param);
  595. len += WMI_TLV_HDR_SIZE;
  596. if (roam_req->num_bssid_black_list)
  597. len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
  598. len += WMI_TLV_HDR_SIZE;
  599. if (roam_req->num_ssid_white_list)
  600. len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
  601. len += 2 * WMI_TLV_HDR_SIZE;
  602. if (roam_req->num_bssid_preferred_list) {
  603. len += (roam_req->num_bssid_preferred_list *
  604. sizeof(wmi_mac_addr));
  605. len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
  606. }
  607. len += WMI_TLV_HDR_SIZE;
  608. if (roam_req->lca_disallow_config_present) {
  609. len += sizeof(*blist_param);
  610. blist_len = sizeof(*blist_param);
  611. }
  612. len += WMI_TLV_HDR_SIZE;
  613. if (roam_req->num_rssi_rejection_ap)
  614. len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
  615. buf = wmi_buf_alloc(wmi_handle, len);
  616. if (!buf)
  617. return QDF_STATUS_E_NOMEM;
  618. buf_ptr = (u_int8_t *)wmi_buf_data(buf);
  619. roam_filter = (wmi_roam_filter_fixed_param *)buf_ptr;
  620. WMITLV_SET_HDR(&roam_filter->tlv_header,
  621. WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
  622. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
  623. /* fill in fixed values */
  624. roam_filter->vdev_id = roam_req->vdev_id;
  625. roam_filter->flags = 0;
  626. roam_filter->op_bitmap = roam_req->op_bitmap;
  627. roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
  628. roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
  629. roam_filter->num_bssid_preferred_list =
  630. roam_req->num_bssid_preferred_list;
  631. roam_filter->num_rssi_rejection_ap =
  632. roam_req->num_rssi_rejection_ap;
  633. roam_filter->delta_rssi = roam_req->delta_rssi;
  634. buf_ptr += sizeof(wmi_roam_filter_fixed_param);
  635. WMITLV_SET_HDR((buf_ptr),
  636. WMITLV_TAG_ARRAY_FIXED_STRUC,
  637. (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
  638. bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
  639. bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
  640. for (i = 0; i < roam_req->num_bssid_black_list; i++) {
  641. WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
  642. bssid_src_ptr += ATH_MAC_LEN;
  643. bssid_dst_ptr++;
  644. }
  645. buf_ptr += WMI_TLV_HDR_SIZE +
  646. (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
  647. WMITLV_SET_HDR((buf_ptr),
  648. WMITLV_TAG_ARRAY_FIXED_STRUC,
  649. (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
  650. ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
  651. for (i = 0; i < roam_req->num_ssid_white_list; i++) {
  652. qdf_mem_copy(&ssid_ptr->ssid,
  653. &roam_req->ssid_allowed_list[i].ssid,
  654. roam_req->ssid_allowed_list[i].length);
  655. ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
  656. ssid_ptr++;
  657. }
  658. buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
  659. sizeof(wmi_ssid));
  660. WMITLV_SET_HDR((buf_ptr),
  661. WMITLV_TAG_ARRAY_FIXED_STRUC,
  662. (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
  663. bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
  664. bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
  665. for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
  666. WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
  667. (wmi_mac_addr *)bssid_dst_ptr);
  668. bssid_src_ptr += ATH_MAC_LEN;
  669. bssid_dst_ptr++;
  670. }
  671. buf_ptr += WMI_TLV_HDR_SIZE +
  672. (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
  673. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  674. (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
  675. bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
  676. for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
  677. *bssid_preferred_factor_ptr =
  678. roam_req->bssid_favored_factor[i];
  679. bssid_preferred_factor_ptr++;
  680. }
  681. buf_ptr += WMI_TLV_HDR_SIZE +
  682. (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
  683. WMITLV_SET_HDR(buf_ptr,
  684. WMITLV_TAG_ARRAY_STRUC, blist_len);
  685. buf_ptr += WMI_TLV_HDR_SIZE;
  686. if (roam_req->lca_disallow_config_present) {
  687. blist_param =
  688. (wmi_roam_lca_disallow_config_tlv_param *)buf_ptr;
  689. WMITLV_SET_HDR(&blist_param->tlv_header,
  690. WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
  691. WMITLV_GET_STRUCT_TLVLEN(
  692. wmi_roam_lca_disallow_config_tlv_param));
  693. blist_param->disallow_duration = roam_req->disallow_duration;
  694. blist_param->rssi_channel_penalization =
  695. roam_req->rssi_channel_penalization;
  696. blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
  697. blist_param->disallow_lca_enable_source_bitmap =
  698. (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
  699. WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
  700. buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
  701. }
  702. WMITLV_SET_HDR(buf_ptr,
  703. WMITLV_TAG_ARRAY_STRUC,
  704. (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
  705. buf_ptr += WMI_TLV_HDR_SIZE;
  706. for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
  707. rssi_rej =
  708. (wmi_roam_rssi_rejection_oce_config_param *)buf_ptr;
  709. WMITLV_SET_HDR(&rssi_rej->tlv_header,
  710. WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
  711. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_rssi_rejection_oce_config_param));
  712. WMI_CHAR_ARRAY_TO_MAC_ADDR(
  713. roam_req->rssi_rejection_ap[i].bssid.bytes,
  714. &rssi_rej->bssid);
  715. rssi_rej->remaining_disallow_duration =
  716. roam_req->rssi_rejection_ap[i].reject_duration;
  717. rssi_rej->requested_rssi =
  718. (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
  719. buf_ptr +=
  720. (sizeof(wmi_roam_rssi_rejection_oce_config_param));
  721. }
  722. wmi_mtrace(WMI_ROAM_FILTER_CMDID, NO_SESSION, 0);
  723. status = wmi_unified_cmd_send(wmi_handle, buf,
  724. len, WMI_ROAM_FILTER_CMDID);
  725. if (QDF_IS_STATUS_ERROR(status)) {
  726. WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
  727. status);
  728. wmi_buf_free(buf);
  729. }
  730. return status;
  731. }
  732. #ifdef FEATURE_WLAN_ESE
  733. /**
  734. * send_plm_stop_cmd_tlv() - plm stop request
  735. * @wmi_handle: wmi handle
  736. * @plm: plm request parameters
  737. *
  738. * This function request FW to stop PLM.
  739. *
  740. * Return: CDF status
  741. */
  742. static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
  743. const struct plm_req_params *plm)
  744. {
  745. wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
  746. int32_t len;
  747. wmi_buf_t buf;
  748. uint8_t *buf_ptr;
  749. int ret;
  750. len = sizeof(*cmd);
  751. buf = wmi_buf_alloc(wmi_handle, len);
  752. if (!buf)
  753. return QDF_STATUS_E_NOMEM;
  754. cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *)wmi_buf_data(buf);
  755. buf_ptr = (uint8_t *)cmd;
  756. WMITLV_SET_HDR(&cmd->tlv_header,
  757. WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
  758. WMITLV_GET_STRUCT_TLVLEN
  759. (wmi_vdev_plmreq_stop_cmd_fixed_param));
  760. cmd->vdev_id = plm->vdev_id;
  761. cmd->meas_token = plm->meas_token;
  762. WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
  763. wmi_mtrace(WMI_VDEV_PLMREQ_STOP_CMDID, cmd->vdev_id, 0);
  764. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  765. WMI_VDEV_PLMREQ_STOP_CMDID);
  766. if (ret) {
  767. WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
  768. wmi_buf_free(buf);
  769. return QDF_STATUS_E_FAILURE;
  770. }
  771. return QDF_STATUS_SUCCESS;
  772. }
  773. /**
  774. * send_plm_start_cmd_tlv() - plm start request
  775. * @wmi_handle: wmi handle
  776. * @plm: plm request parameters
  777. *
  778. * This function request FW to start PLM.
  779. *
  780. * Return: CDF status
  781. */
  782. static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
  783. const struct plm_req_params *plm)
  784. {
  785. wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
  786. uint32_t *channel_list;
  787. int32_t len;
  788. wmi_buf_t buf;
  789. uint8_t *buf_ptr;
  790. uint8_t count;
  791. int ret;
  792. /* TLV place holder for channel_list */
  793. len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
  794. len += sizeof(uint32_t) * plm->plm_num_ch;
  795. buf = wmi_buf_alloc(wmi_handle, len);
  796. if (!buf)
  797. return QDF_STATUS_E_NOMEM;
  798. cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *)wmi_buf_data(buf);
  799. buf_ptr = (uint8_t *)cmd;
  800. WMITLV_SET_HDR(&cmd->tlv_header,
  801. WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
  802. WMITLV_GET_STRUCT_TLVLEN
  803. (wmi_vdev_plmreq_start_cmd_fixed_param));
  804. cmd->vdev_id = plm->vdev_id;
  805. cmd->meas_token = plm->meas_token;
  806. cmd->dialog_token = plm->diag_token;
  807. cmd->number_bursts = plm->num_bursts;
  808. cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
  809. cmd->off_duration = plm->meas_duration;
  810. cmd->burst_cycle = plm->burst_len;
  811. cmd->tx_power = plm->desired_tx_pwr;
  812. WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
  813. cmd->num_chans = plm->plm_num_ch;
  814. buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
  815. WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
  816. WMI_LOGD("dialog_token: %d", cmd->dialog_token);
  817. WMI_LOGD("number_bursts: %d", cmd->number_bursts);
  818. WMI_LOGD("burst_interval: %d", cmd->burst_interval);
  819. WMI_LOGD("off_duration: %d", cmd->off_duration);
  820. WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
  821. WMI_LOGD("tx_power: %d", cmd->tx_power);
  822. WMI_LOGD("Number of channels : %d", cmd->num_chans);
  823. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  824. (cmd->num_chans * sizeof(uint32_t)));
  825. buf_ptr += WMI_TLV_HDR_SIZE;
  826. if (cmd->num_chans) {
  827. channel_list = (uint32_t *)buf_ptr;
  828. for (count = 0; count < cmd->num_chans; count++) {
  829. channel_list[count] = plm->plm_ch_freq_list[count];
  830. WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
  831. }
  832. buf_ptr += cmd->num_chans * sizeof(uint32_t);
  833. }
  834. wmi_mtrace(WMI_VDEV_PLMREQ_START_CMDID, cmd->vdev_id, 0);
  835. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  836. WMI_VDEV_PLMREQ_START_CMDID);
  837. if (ret) {
  838. WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
  839. wmi_buf_free(buf);
  840. return QDF_STATUS_E_FAILURE;
  841. }
  842. return QDF_STATUS_SUCCESS;
  843. }
  844. void wmi_ese_attach_tlv(wmi_unified_t wmi_handle)
  845. {
  846. struct wmi_ops *ops = wmi_handle->ops;
  847. ops->send_plm_stop_cmd = send_plm_stop_cmd_tlv;
  848. ops->send_plm_start_cmd = send_plm_start_cmd_tlv;
  849. }
  850. #endif /* FEATURE_WLAN_ESE */
  851. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  852. /* send_set_ric_req_cmd_tlv() - set ric request element
  853. * @wmi_handle: wmi handle
  854. * @msg: message
  855. * @is_add_ts: is addts required
  856. *
  857. * This function sets ric request element for 11r roaming.
  858. *
  859. * Return: CDF status
  860. */
  861. static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
  862. void *msg, uint8_t is_add_ts)
  863. {
  864. wmi_ric_request_fixed_param *cmd;
  865. wmi_ric_tspec *tspec_param;
  866. wmi_buf_t buf;
  867. uint8_t *buf_ptr;
  868. struct mac_tspec_ie *tspec_ie = NULL;
  869. int32_t len = sizeof(wmi_ric_request_fixed_param) +
  870. WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
  871. buf = wmi_buf_alloc(wmi_handle, len);
  872. if (!buf)
  873. return QDF_STATUS_E_NOMEM;
  874. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  875. cmd = (wmi_ric_request_fixed_param *)buf_ptr;
  876. WMITLV_SET_HDR(&cmd->tlv_header,
  877. WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
  878. WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
  879. if (is_add_ts)
  880. cmd->vdev_id = ((struct add_ts_param *)msg)->vdev_id;
  881. else
  882. cmd->vdev_id = ((struct del_ts_params *)msg)->sessionId;
  883. cmd->num_ric_request = 1;
  884. cmd->is_add_ric = is_add_ts;
  885. buf_ptr += sizeof(wmi_ric_request_fixed_param);
  886. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
  887. buf_ptr += WMI_TLV_HDR_SIZE;
  888. tspec_param = (wmi_ric_tspec *)buf_ptr;
  889. WMITLV_SET_HDR(&tspec_param->tlv_header,
  890. WMITLV_TAG_STRUC_wmi_ric_tspec,
  891. WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
  892. if (is_add_ts)
  893. tspec_ie = &(((struct add_ts_param *)msg)->tspec);
  894. else
  895. tspec_ie = &(((struct del_ts_params *)msg)->delTsInfo.tspec);
  896. if (tspec_ie) {
  897. /* Fill the tsinfo in the format expected by firmware */
  898. #ifndef ANI_LITTLE_BIT_ENDIAN
  899. qdf_mem_copy(((uint8_t *)&tspec_param->ts_info) + 1,
  900. ((uint8_t *)&tspec_ie->tsinfo) + 1, 2);
  901. #else
  902. qdf_mem_copy(((uint8_t *)&tspec_param->ts_info),
  903. ((uint8_t *)&tspec_ie->tsinfo) + 1, 2);
  904. #endif /* ANI_LITTLE_BIT_ENDIAN */
  905. tspec_param->nominal_msdu_size = tspec_ie->nomMsduSz;
  906. tspec_param->maximum_msdu_size = tspec_ie->maxMsduSz;
  907. tspec_param->min_service_interval = tspec_ie->minSvcInterval;
  908. tspec_param->max_service_interval = tspec_ie->maxSvcInterval;
  909. tspec_param->inactivity_interval = tspec_ie->inactInterval;
  910. tspec_param->suspension_interval = tspec_ie->suspendInterval;
  911. tspec_param->svc_start_time = tspec_ie->svcStartTime;
  912. tspec_param->min_data_rate = tspec_ie->minDataRate;
  913. tspec_param->mean_data_rate = tspec_ie->meanDataRate;
  914. tspec_param->peak_data_rate = tspec_ie->peakDataRate;
  915. tspec_param->max_burst_size = tspec_ie->maxBurstSz;
  916. tspec_param->delay_bound = tspec_ie->delayBound;
  917. tspec_param->min_phy_rate = tspec_ie->minPhyRate;
  918. tspec_param->surplus_bw_allowance = tspec_ie->surplusBw;
  919. tspec_param->medium_time = 0;
  920. }
  921. WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
  922. wmi_mtrace(WMI_ROAM_SET_RIC_REQUEST_CMDID, cmd->vdev_id, 0);
  923. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  924. WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
  925. WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
  926. __func__);
  927. if (is_add_ts)
  928. ((struct add_ts_param *)msg)->status =
  929. QDF_STATUS_E_FAILURE;
  930. wmi_buf_free(buf);
  931. return QDF_STATUS_E_FAILURE;
  932. }
  933. return QDF_STATUS_SUCCESS;
  934. }
  935. /**
  936. * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to
  937. * fw.
  938. * @wmi_handle: wmi handle
  939. * @vdev_id: vdev id
  940. *
  941. * This function sends roam synch complete event to fw.
  942. *
  943. * Return: QDF STATUS
  944. */
  945. static QDF_STATUS
  946. send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
  947. uint8_t vdev_id)
  948. {
  949. wmi_roam_synch_complete_fixed_param *cmd;
  950. wmi_buf_t wmi_buf;
  951. uint8_t *buf_ptr;
  952. uint16_t len;
  953. len = sizeof(wmi_roam_synch_complete_fixed_param);
  954. wmi_buf = wmi_buf_alloc(wmi_handle, len);
  955. if (!wmi_buf)
  956. return QDF_STATUS_E_NOMEM;
  957. cmd = (wmi_roam_synch_complete_fixed_param *)wmi_buf_data(wmi_buf);
  958. buf_ptr = (uint8_t *)cmd;
  959. WMITLV_SET_HDR(&cmd->tlv_header,
  960. WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
  961. WMITLV_GET_STRUCT_TLVLEN
  962. (wmi_roam_synch_complete_fixed_param));
  963. cmd->vdev_id = vdev_id;
  964. wmi_mtrace(WMI_ROAM_SYNCH_COMPLETE, cmd->vdev_id, 0);
  965. if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
  966. WMI_ROAM_SYNCH_COMPLETE)) {
  967. WMI_LOGP("%s: failed to send roam synch confirmation",
  968. __func__);
  969. wmi_buf_free(wmi_buf);
  970. return QDF_STATUS_E_FAILURE;
  971. }
  972. return QDF_STATUS_SUCCESS;
  973. }
  974. /**
  975. * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
  976. * @wmi_handle: wma handle
  977. * @roaminvoke: roam invoke command
  978. *
  979. * Send roam invoke command to fw for fastreassoc.
  980. *
  981. * Return: CDF STATUS
  982. */
  983. static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
  984. struct wmi_roam_invoke_cmd *roaminvoke,
  985. uint32_t ch_hz)
  986. {
  987. wmi_roam_invoke_cmd_fixed_param *cmd;
  988. wmi_buf_t wmi_buf;
  989. u_int8_t *buf_ptr;
  990. u_int16_t len, args_tlv_len;
  991. uint32_t *channel_list;
  992. wmi_mac_addr *bssid_list;
  993. wmi_tlv_buf_len_param *buf_len_tlv;
  994. args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
  995. sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
  996. roundup(roaminvoke->frame_len, sizeof(uint32_t));
  997. len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
  998. wmi_buf = wmi_buf_alloc(wmi_handle, len);
  999. if (!wmi_buf)
  1000. return QDF_STATUS_E_NOMEM;
  1001. cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
  1002. buf_ptr = (u_int8_t *)cmd;
  1003. WMITLV_SET_HDR(&cmd->tlv_header,
  1004. WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
  1005. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
  1006. cmd->vdev_id = roaminvoke->vdev_id;
  1007. cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
  1008. if (roaminvoke->is_same_bssid)
  1009. cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
  1010. if (roaminvoke->frame_len) {
  1011. cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
  1012. /* packing 1 beacon/probe_rsp frame with WMI cmd */
  1013. cmd->num_buf = 1;
  1014. } else {
  1015. cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
  1016. cmd->num_buf = 0;
  1017. }
  1018. cmd->roam_ap_sel_mode = 0;
  1019. cmd->roam_delay = 0;
  1020. cmd->num_chan = 1;
  1021. cmd->num_bssid = 1;
  1022. if (roaminvoke->forced_roaming) {
  1023. cmd->num_chan = 0;
  1024. cmd->num_bssid = 0;
  1025. cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_CACHE_MAP;
  1026. cmd->flags |=
  1027. (1 << WMI_ROAM_INVOKE_FLAG_FULL_SCAN_IF_NO_CANDIDATE);
  1028. cmd->reason = ROAM_INVOKE_REASON_NUD_FAILURE;
  1029. } else {
  1030. cmd->reason = ROAM_INVOKE_REASON_USER_SPACE;
  1031. }
  1032. buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
  1033. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  1034. (sizeof(u_int32_t)));
  1035. channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
  1036. *channel_list = ch_hz;
  1037. buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
  1038. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
  1039. (sizeof(wmi_mac_addr)));
  1040. bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
  1041. WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
  1042. /* move to next tlv i.e. bcn_prb_buf_list */
  1043. buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
  1044. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
  1045. sizeof(wmi_tlv_buf_len_param));
  1046. buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
  1047. WMITLV_SET_HDR(&buf_len_tlv->tlv_header,
  1048. WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
  1049. WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
  1050. buf_len_tlv->buf_len = roaminvoke->frame_len;
  1051. /* move to next tlv i.e. bcn_prb_frm */
  1052. buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
  1053. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1054. roundup(roaminvoke->frame_len, sizeof(uint32_t)));
  1055. /* copy frame after the header */
  1056. qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
  1057. roaminvoke->frame_buf,
  1058. roaminvoke->frame_len);
  1059. wmi_debug("flag:%d, MODE:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d, ch:%d, is_same_bss:%d",
  1060. cmd->flags, cmd->roam_scan_mode,
  1061. cmd->roam_ap_sel_mode, cmd->roam_delay,
  1062. cmd->num_chan, cmd->num_bssid, ch_hz,
  1063. roaminvoke->is_same_bssid);
  1064. wmi_mtrace(WMI_ROAM_INVOKE_CMDID, cmd->vdev_id, 0);
  1065. if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
  1066. WMI_ROAM_INVOKE_CMDID)) {
  1067. WMI_LOGP("%s: failed to send roam invoke command", __func__);
  1068. wmi_buf_free(wmi_buf);
  1069. return QDF_STATUS_E_FAILURE;
  1070. }
  1071. return QDF_STATUS_SUCCESS;
  1072. }
  1073. /**
  1074. * convert_control_roam_trigger_reason_bitmap() - Convert roam trigger bitmap
  1075. *
  1076. * @trigger_reason_bitmap: Roam trigger reason bitmap received from upper layers
  1077. *
  1078. * Converts the controlled roam trigger reason bitmap of
  1079. * type @roam_control_trigger_reason to firmware trigger
  1080. * reason bitmap as defined in
  1081. * trigger_reason_bitmask @wmi_roam_enable_disable_trigger_reason_fixed_param
  1082. *
  1083. * Return: trigger_reason_bitmask as defined in
  1084. * wmi_roam_enable_disable_trigger_reason_fixed_param
  1085. */
  1086. static uint32_t
  1087. convert_control_roam_trigger_reason_bitmap(uint32_t trigger_reason_bitmap)
  1088. {
  1089. uint32_t fw_trigger_bitmap = 0, all_bitmap;
  1090. /* Enable the complete trigger bitmap when all bits are set in
  1091. * the control config bitmap
  1092. */
  1093. all_bitmap = BIT(ROAM_TRIGGER_REASON_MAX) - 1;
  1094. if (trigger_reason_bitmap == all_bitmap)
  1095. return BIT(WMI_ROAM_TRIGGER_EXT_REASON_MAX) - 1;
  1096. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_NONE))
  1097. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_NONE);
  1098. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_PER))
  1099. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_PER);
  1100. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_BMISS))
  1101. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_BMISS);
  1102. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_LOW_RSSI))
  1103. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_LOW_RSSI);
  1104. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_HIGH_RSSI))
  1105. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_HIGH_RSSI);
  1106. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_PERIODIC))
  1107. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_PERIODIC);
  1108. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_MAWC))
  1109. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_MAWC);
  1110. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_DENSE))
  1111. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_DENSE);
  1112. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_BACKGROUND))
  1113. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_BACKGROUND);
  1114. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_FORCED))
  1115. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_FORCED);
  1116. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_BTM))
  1117. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_BTM);
  1118. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_UNIT_TEST))
  1119. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_UNIT_TEST);
  1120. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_BSS_LOAD))
  1121. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_BSS_LOAD);
  1122. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_DEAUTH))
  1123. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_DEAUTH);
  1124. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_IDLE))
  1125. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_IDLE);
  1126. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_STA_KICKOUT))
  1127. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_STA_KICKOUT);
  1128. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_ESS_RSSI))
  1129. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_ESS_RSSI);
  1130. if (trigger_reason_bitmap & BIT(ROAM_TRIGGER_REASON_WTC_BTM))
  1131. fw_trigger_bitmap |= BIT(WMI_ROAM_TRIGGER_REASON_WTC_BTM);
  1132. return fw_trigger_bitmap;
  1133. }
  1134. /**
  1135. * get_internal_mandatory_roam_triggers() - Internal triggers to be added
  1136. *
  1137. * Return: the bitmap of mandatory triggers to be sent to firmware but not given
  1138. * by user.
  1139. */
  1140. static uint32_t
  1141. get_internal_mandatory_roam_triggers(void)
  1142. {
  1143. return BIT(WMI_ROAM_TRIGGER_REASON_FORCED);
  1144. }
  1145. /**
  1146. * convert_roam_trigger_scan_mode() - Function to convert unified Roam trigger
  1147. * scan mode enum to TLV specific ROAM_TRIGGER_SCAN_MODE
  1148. * @scan_freq_scheme: scan freq scheme coming from userspace
  1149. *
  1150. * Return: ROAM_TRIGGER_SCAN_MODE
  1151. */
  1152. static WMI_ROAM_TRIGGER_SCAN_MODE
  1153. convert_roam_trigger_scan_mode(enum roam_scan_freq_scheme scan_freq_scheme)
  1154. {
  1155. switch (scan_freq_scheme) {
  1156. case ROAM_SCAN_FREQ_SCHEME_NO_SCAN:
  1157. return ROAM_TRIGGER_SCAN_MODE_NO_SCAN_DISCONNECTION;
  1158. case ROAM_SCAN_FREQ_SCHEME_PARTIAL_SCAN:
  1159. return ROAM_TRIGGER_SCAN_MODE_PARTIAL;
  1160. case ROAM_SCAN_FREQ_SCHEME_FULL_SCAN:
  1161. return ROAM_TRIGGER_SCAN_MODE_FULL;
  1162. default:
  1163. return ROAM_TRIGGER_SCAN_MODE_NONE;
  1164. }
  1165. }
  1166. /**
  1167. * send_set_roam_trigger_cmd_tlv() - send set roam triggers to fw
  1168. *
  1169. * @wmi_handle: wmi handle
  1170. * @vdev_id: vdev id
  1171. * @trigger_bitmap: roam trigger bitmap to be enabled
  1172. *
  1173. * Send WMI_ROAM_ENABLE_DISABLE_TRIGGER_REASON_CMDID to fw.
  1174. *
  1175. * Return: QDF_STATUS
  1176. */
  1177. static QDF_STATUS send_set_roam_trigger_cmd_tlv(wmi_unified_t wmi_handle,
  1178. struct wlan_roam_triggers *triggers)
  1179. {
  1180. wmi_buf_t buf;
  1181. wmi_roam_enable_disable_trigger_reason_fixed_param *cmd;
  1182. uint16_t len = sizeof(*cmd);
  1183. int ret;
  1184. uint8_t *buf_ptr;
  1185. wmi_configure_roam_trigger_parameters
  1186. *roam_trigger_parameters;
  1187. len += WMI_TLV_HDR_SIZE +
  1188. sizeof(wmi_configure_roam_trigger_parameters);
  1189. buf = wmi_buf_alloc(wmi_handle, len);
  1190. if (!buf) {
  1191. WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
  1192. return QDF_STATUS_E_NOMEM;
  1193. }
  1194. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  1195. cmd = (wmi_roam_enable_disable_trigger_reason_fixed_param *)
  1196. wmi_buf_data(buf);
  1197. WMITLV_SET_HDR(&cmd->tlv_header,
  1198. WMITLV_TAG_STRUC_wmi_roam_enable_disable_trigger_reason_fixed_param,
  1199. WMITLV_GET_STRUCT_TLVLEN
  1200. (wmi_roam_enable_disable_trigger_reason_fixed_param));
  1201. cmd->vdev_id = triggers->vdev_id;
  1202. cmd->trigger_reason_bitmask =
  1203. convert_control_roam_trigger_reason_bitmap(triggers->trigger_bitmap);
  1204. WMI_LOGD("Received trigger bitmap: 0x%x converted trigger_bitmap: 0x%x",
  1205. triggers->trigger_bitmap, cmd->trigger_reason_bitmask);
  1206. cmd->trigger_reason_bitmask |= get_internal_mandatory_roam_triggers();
  1207. WMI_LOGD("vdev id: %d final trigger_bitmap: 0x%x",
  1208. cmd->vdev_id, cmd->trigger_reason_bitmask);
  1209. buf_ptr += sizeof(wmi_roam_enable_disable_trigger_reason_fixed_param);
  1210. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1211. sizeof(wmi_configure_roam_trigger_parameters));
  1212. buf_ptr += WMI_TLV_HDR_SIZE;
  1213. roam_trigger_parameters =
  1214. (wmi_configure_roam_trigger_parameters *)buf_ptr;
  1215. WMITLV_SET_HDR(&roam_trigger_parameters->tlv_header,
  1216. WMITLV_TAG_STRUC_wmi_configure_roam_trigger_parameters,
  1217. WMITLV_GET_STRUCT_TLVLEN(
  1218. wmi_configure_roam_trigger_parameters));
  1219. roam_trigger_parameters->trigger_reason =
  1220. WMI_ROAM_TRIGGER_REASON_WTC_BTM;
  1221. if (triggers->vendor_btm_param.user_roam_reason == 0)
  1222. roam_trigger_parameters->enable = 1;
  1223. roam_trigger_parameters->scan_mode =
  1224. convert_roam_trigger_scan_mode(triggers->vendor_btm_param.
  1225. scan_freq_scheme);
  1226. roam_trigger_parameters->trigger_rssi_threshold =
  1227. triggers->vendor_btm_param.connected_rssi_threshold;
  1228. roam_trigger_parameters->cand_ap_min_rssi_threshold =
  1229. triggers->vendor_btm_param.candidate_rssi_threshold;
  1230. roam_trigger_parameters->roam_score_delta_percentage =
  1231. triggers->roam_score_delta;
  1232. roam_trigger_parameters->reason_code =
  1233. triggers->vendor_btm_param.user_roam_reason;
  1234. wmi_mtrace(WMI_ROAM_ENABLE_DISABLE_TRIGGER_REASON_CMDID,
  1235. triggers->vdev_id, 0);
  1236. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  1237. WMI_ROAM_ENABLE_DISABLE_TRIGGER_REASON_CMDID);
  1238. if (QDF_IS_STATUS_ERROR(ret)) {
  1239. WMI_LOGE("Failed to send set roam triggers command ret = %d",
  1240. ret);
  1241. wmi_buf_free(buf);
  1242. }
  1243. return ret;
  1244. }
  1245. /**
  1246. * send_vdev_set_pcl_cmd_tlv() - Send WMI_VDEV_SET_PCL_CMDID to FW
  1247. * @wmi_handle: wmi handle
  1248. * @params: Set VDEV PCL params
  1249. *
  1250. * WMI_VDEV_SET_PCL_CMDID provides the Preferred Channel List (PCL) to WLAN
  1251. * firmware. The roaming module is the consumer of this information
  1252. * in the WLAN firmware. The channel list will be used when a VDEV needs
  1253. * to migrate to a new channel without host driver involvement. An example of
  1254. * this behavior is Legacy Fast Roaming (LFR 3.0).
  1255. *
  1256. * WMI_VDEV_SET_PCL_CMDID will carry only the weight list and not the actual
  1257. * channel list. The weights corresponds to the channels sent in
  1258. * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
  1259. * weightage compared to the non PCL channels.
  1260. *
  1261. * When roaming is enabled on STA 1, PDEV pcl will be sent. When STA2 is
  1262. * up, VDEV pcl will be sent on STA 1 after calculating pcl again applying
  1263. * the bandmask and VDEV pcl will be sent for STA2. When one of the STA
  1264. * is disconnected, PDEV pcl will be sent on the other STA again.
  1265. *
  1266. * Return: Success if the cmd is sent successfully to the firmware
  1267. */
  1268. static QDF_STATUS
  1269. send_vdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
  1270. struct set_pcl_cmd_params *params)
  1271. {
  1272. wmi_vdev_set_pcl_cmd_fixed_param *cmd;
  1273. wmi_buf_t buf;
  1274. uint8_t *buf_ptr;
  1275. uint32_t *ch_weight, i;
  1276. size_t len;
  1277. uint32_t chan_len;
  1278. chan_len = params->weights->saved_num_chan;
  1279. len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
  1280. buf = wmi_buf_alloc(wmi_handle, len);
  1281. if (!buf)
  1282. return QDF_STATUS_E_NOMEM;
  1283. cmd = (wmi_vdev_set_pcl_cmd_fixed_param *)wmi_buf_data(buf);
  1284. buf_ptr = (uint8_t *)cmd;
  1285. WMITLV_SET_HDR(&cmd->tlv_header,
  1286. WMITLV_TAG_STRUC_wmi_vdev_set_pcl_cmd_fixed_param,
  1287. WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_set_pcl_cmd_fixed_param));
  1288. cmd->vdev_id = params->vdev_id;
  1289. buf_ptr += sizeof(wmi_vdev_set_pcl_cmd_fixed_param);
  1290. /* Channel weights uint32 Array TLV */
  1291. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  1292. (chan_len * sizeof(uint32_t)));
  1293. ch_weight = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
  1294. for (i = 0; i < chan_len; i++)
  1295. ch_weight[i] = params->weights->weighed_valid_list[i];
  1296. wmi_mtrace(WMI_VDEV_SET_PCL_CMDID, params->vdev_id, 0);
  1297. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1298. WMI_VDEV_SET_PCL_CMDID)) {
  1299. WMI_LOGE("%s: Failed to send WMI_VDEV_SET_PCL_CMDID", __func__);
  1300. wmi_buf_free(buf);
  1301. return QDF_STATUS_E_FAILURE;
  1302. }
  1303. return QDF_STATUS_SUCCESS;
  1304. }
  1305. /**
  1306. * extract_roam_btm_response_stats_tlv() - Extract the btm rsp stats
  1307. * from the WMI_ROAM_STATS_EVENTID
  1308. * @wmi_handle: wmi handle
  1309. * @evt_buf: Pointer to the event buffer
  1310. * @dst: Pointer to destination structure to fill data
  1311. * @idx: TLV id
  1312. */
  1313. static QDF_STATUS
  1314. extract_roam_btm_response_stats_tlv(wmi_unified_t wmi_handle, void *evt_buf,
  1315. struct roam_btm_response_data *dst,
  1316. uint8_t idx)
  1317. {
  1318. WMI_ROAM_STATS_EVENTID_param_tlvs *param_buf;
  1319. wmi_roam_btm_response_info *src_data = NULL;
  1320. param_buf = (WMI_ROAM_STATS_EVENTID_param_tlvs *)evt_buf;
  1321. if (!param_buf || !param_buf->roam_btm_response_info ||
  1322. !param_buf->num_roam_btm_response_info ||
  1323. idx >= param_buf->num_roam_btm_response_info) {
  1324. WMI_LOGD("%s: Empty btm response param buf", __func__);
  1325. return QDF_STATUS_SUCCESS;
  1326. }
  1327. src_data = &param_buf->roam_btm_response_info[idx];
  1328. dst->present = true;
  1329. dst->btm_status = src_data->btm_status;
  1330. WMI_MAC_ADDR_TO_CHAR_ARRAY(&src_data->target_bssid,
  1331. dst->target_bssid.bytes);
  1332. dst->vsie_reason = src_data->vsie_reason;
  1333. dst->timestamp = src_data->timestamp;
  1334. return QDF_STATUS_SUCCESS;
  1335. }
  1336. /**
  1337. * extract_roam_initial_info_tlv() - Extract the roam initial info
  1338. * from the WMI_ROAM_STATS_EVENTID
  1339. * @wmi_handle: wmi handle
  1340. * @evt_buf: Pointer to the event buffer
  1341. * @dst: Pointer to destination structure to fill data
  1342. * @idx: TLV id
  1343. */
  1344. static QDF_STATUS
  1345. extract_roam_initial_info_tlv(wmi_unified_t wmi_handle, void *evt_buf,
  1346. struct roam_initial_data *dst, uint8_t idx)
  1347. {
  1348. WMI_ROAM_STATS_EVENTID_param_tlvs *param_buf;
  1349. wmi_roam_initial_info *src_data = NULL;
  1350. param_buf = (WMI_ROAM_STATS_EVENTID_param_tlvs *)evt_buf;
  1351. if (!param_buf || !param_buf->roam_initial_info ||
  1352. !param_buf->num_roam_initial_info ||
  1353. idx >= param_buf->num_roam_initial_info) {
  1354. WMI_LOGD("%s: Empty roam_initial_info param buf", __func__);
  1355. return QDF_STATUS_SUCCESS;
  1356. }
  1357. src_data = &param_buf->roam_initial_info[idx];
  1358. dst->present = true;
  1359. dst->roam_full_scan_count = src_data->roam_full_scan_count;
  1360. dst->rssi_th = src_data->rssi_th;
  1361. dst->cu_th = src_data->cu_th;
  1362. dst->fw_cancel_timer_bitmap = src_data->timer_canceled;
  1363. return QDF_STATUS_SUCCESS;
  1364. }
  1365. void wmi_roam_offload_attach_tlv(wmi_unified_t wmi_handle)
  1366. {
  1367. struct wmi_ops *ops = wmi_handle->ops;
  1368. ops->extract_roam_btm_response_stats =
  1369. extract_roam_btm_response_stats_tlv;
  1370. ops->extract_roam_initial_info = extract_roam_initial_info_tlv;
  1371. ops->send_set_ric_req_cmd = send_set_ric_req_cmd_tlv;
  1372. ops->send_process_roam_synch_complete_cmd =
  1373. send_process_roam_synch_complete_cmd_tlv;
  1374. ops->send_roam_invoke_cmd = send_roam_invoke_cmd_tlv;
  1375. ops->send_vdev_set_pcl_cmd = send_vdev_set_pcl_cmd_tlv;
  1376. ops->send_set_roam_trigger_cmd = send_set_roam_trigger_cmd_tlv;
  1377. }
  1378. #else
  1379. static inline QDF_STATUS
  1380. extract_roam_btm_response_stats_tlv(wmi_unified_t wmi_handle, void *evt_buf,
  1381. struct roam_btm_response_data *dst,
  1382. uint8_t idx)
  1383. {
  1384. return QDF_STATUS_E_NOSUPPORT;
  1385. }
  1386. static inline QDF_STATUS
  1387. extract_roam_initial_info_tlv(wmi_unified_t wmi_handle, void *evt_buf,
  1388. struct roam_initial_data *dst, uint8_t idx)
  1389. {
  1390. return QDF_STATUS_E_NOSUPPORT;
  1391. }
  1392. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  1393. #if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
  1394. /**
  1395. * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
  1396. * @wmi_handle: wmi handle
  1397. * @roam_req: Roam scan offload params
  1398. * @buf_ptr: command buffer to send
  1399. * @fils_tlv_len: fils tlv length
  1400. *
  1401. * Return: Updated buffer pointer
  1402. */
  1403. static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
  1404. struct roam_offload_scan_params *roam_req,
  1405. uint8_t *buf_ptr, uint32_t fils_tlv_len)
  1406. {
  1407. wmi_roam_fils_offload_tlv_param *fils_tlv;
  1408. wmi_erp_info *erp_info;
  1409. struct roam_fils_params *roam_fils_params;
  1410. if (!roam_req->add_fils_tlv)
  1411. return buf_ptr;
  1412. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1413. sizeof(*fils_tlv));
  1414. buf_ptr += WMI_TLV_HDR_SIZE;
  1415. fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
  1416. WMITLV_SET_HDR(&fils_tlv->tlv_header,
  1417. WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
  1418. WMITLV_GET_STRUCT_TLVLEN
  1419. (wmi_roam_fils_offload_tlv_param));
  1420. roam_fils_params = &roam_req->roam_fils_params;
  1421. erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
  1422. erp_info->username_length = roam_fils_params->username_length;
  1423. qdf_mem_copy(erp_info->username, roam_fils_params->username,
  1424. erp_info->username_length);
  1425. erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
  1426. erp_info->rRk_length = roam_fils_params->rrk_length;
  1427. qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
  1428. erp_info->rRk_length);
  1429. erp_info->rIk_length = roam_fils_params->rik_length;
  1430. qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
  1431. erp_info->rIk_length);
  1432. erp_info->realm_len = roam_fils_params->realm_len;
  1433. qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
  1434. erp_info->realm_len);
  1435. buf_ptr += sizeof(*fils_tlv);
  1436. return buf_ptr;
  1437. }
  1438. #else
  1439. static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
  1440. struct roam_offload_scan_params *roam_req,
  1441. uint8_t *buf_ptr, uint32_t fils_tlv_len)
  1442. {
  1443. return buf_ptr;
  1444. }
  1445. #endif
  1446. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  1447. /**
  1448. * fill_roam_offload_11r_params() - Fill roam scan params to send it to fw
  1449. * @auth_mode: Authentication mode
  1450. * @roam_offload_11r: TLV to be filled with 11r params
  1451. * @roam_req: roam request param
  1452. */
  1453. static void
  1454. fill_roam_offload_11r_params(uint32_t auth_mode,
  1455. wmi_roam_11r_offload_tlv_param *roam_offload_11r,
  1456. struct roam_offload_scan_params *roam_req)
  1457. {
  1458. uint8_t *psk_msk, len;
  1459. if (auth_mode == WMI_AUTH_FT_RSNA_FILS_SHA256 ||
  1460. auth_mode == WMI_AUTH_FT_RSNA_FILS_SHA384) {
  1461. psk_msk = roam_req->roam_fils_params.fils_ft;
  1462. len = roam_req->roam_fils_params.fils_ft_len;
  1463. } else {
  1464. psk_msk = roam_req->psk_pmk;
  1465. len = roam_req->pmk_len;
  1466. }
  1467. /*
  1468. * For SHA384 based akm, the pmk length is 48 bytes. So fill
  1469. * first 32 bytes in roam_offload_11r->psk_msk and the remaining
  1470. * bytes in roam_offload_11r->psk_msk_ext buffer
  1471. */
  1472. roam_offload_11r->psk_msk_len = len > ROAM_OFFLOAD_PSK_MSK_BYTES ?
  1473. ROAM_OFFLOAD_PSK_MSK_BYTES : len;
  1474. qdf_mem_copy(roam_offload_11r->psk_msk, psk_msk,
  1475. roam_offload_11r->psk_msk_len);
  1476. roam_offload_11r->psk_msk_ext_len = 0;
  1477. if (len > ROAM_OFFLOAD_PSK_MSK_BYTES) {
  1478. roam_offload_11r->psk_msk_ext_len =
  1479. len - roam_offload_11r->psk_msk_len;
  1480. qdf_mem_copy(roam_offload_11r->psk_msk_ext,
  1481. &psk_msk[roam_offload_11r->psk_msk_len],
  1482. roam_offload_11r->psk_msk_ext_len);
  1483. }
  1484. }
  1485. /**
  1486. * wmi_fill_sae_single_pmk_param() - Fill sae single pmk flag to indicate fw to
  1487. * use same PMKID for WPA3 SAE roaming.
  1488. * @params: roam request param
  1489. * @roam_offload_11i: pointer to 11i params
  1490. *
  1491. * Return: None
  1492. */
  1493. static inline void
  1494. wmi_fill_sae_single_pmk_param(struct roam_offload_scan_params *params,
  1495. wmi_roam_11i_offload_tlv_param *roam_offload_11i)
  1496. {
  1497. if (params->is_sae_same_pmk)
  1498. roam_offload_11i->flags |=
  1499. 1 << WMI_ROAM_OFFLOAD_FLAG_SAE_SAME_PMKID;
  1500. }
  1501. #else
  1502. static inline void
  1503. wmi_fill_sae_single_pmk_param(struct roam_offload_scan_params *params,
  1504. wmi_roam_11i_offload_tlv_param *roam_offload_11i)
  1505. {
  1506. }
  1507. #endif
  1508. #define ROAM_OFFLOAD_PMK_EXT_BYTES 16
  1509. /**
  1510. * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
  1511. * @wmi_handle: wmi handle
  1512. * @scan_cmd_fp: start scan command ptr
  1513. * @roam_req: roam request param
  1514. *
  1515. * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
  1516. * of WMI_ROAM_SCAN_MODE.
  1517. *
  1518. * Return: QDF status
  1519. */
  1520. static QDF_STATUS
  1521. send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
  1522. wmi_start_scan_cmd_fixed_param *scan_cmd_fp,
  1523. struct roam_offload_scan_params *roam_req)
  1524. {
  1525. wmi_buf_t buf = NULL;
  1526. QDF_STATUS status;
  1527. int len;
  1528. uint8_t *buf_ptr;
  1529. wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
  1530. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  1531. int auth_mode = roam_req->auth_mode;
  1532. roam_offload_param *req_offload_params =
  1533. &roam_req->roam_offload_params;
  1534. wmi_roam_offload_tlv_param *roam_offload_params;
  1535. wmi_roam_11i_offload_tlv_param *roam_offload_11i;
  1536. wmi_roam_11r_offload_tlv_param *roam_offload_11r;
  1537. wmi_roam_ese_offload_tlv_param *roam_offload_ese;
  1538. wmi_tlv_buf_len_param *assoc_ies;
  1539. uint32_t fils_tlv_len = 0;
  1540. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  1541. /* Need to create a buf with roam_scan command at
  1542. * front and piggyback with scan command */
  1543. len = sizeof(wmi_roam_scan_mode_fixed_param) +
  1544. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  1545. (2 * WMI_TLV_HDR_SIZE) +
  1546. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  1547. sizeof(wmi_start_scan_cmd_fixed_param);
  1548. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  1549. wmi_debug("auth_mode = %d", auth_mode);
  1550. if (roam_req->is_roam_req_valid &&
  1551. roam_req->roam_offload_enabled) {
  1552. len += sizeof(wmi_roam_offload_tlv_param);
  1553. len += WMI_TLV_HDR_SIZE;
  1554. if ((auth_mode != WMI_AUTH_NONE) &&
  1555. ((auth_mode != WMI_AUTH_OPEN) ||
  1556. (auth_mode == WMI_AUTH_OPEN &&
  1557. roam_req->mdid.mdie_present &&
  1558. roam_req->is_11r_assoc) ||
  1559. roam_req->is_ese_assoc)) {
  1560. len += WMI_TLV_HDR_SIZE;
  1561. if (roam_req->is_ese_assoc)
  1562. len += sizeof(wmi_roam_ese_offload_tlv_param);
  1563. else if ((auth_mode == WMI_AUTH_FT_RSNA) ||
  1564. (auth_mode == WMI_AUTH_FT_RSNA_PSK) ||
  1565. (auth_mode == WMI_AUTH_FT_RSNA_SAE) ||
  1566. (auth_mode ==
  1567. WMI_AUTH_FT_RSNA_SUITE_B_8021X_SHA384) ||
  1568. (auth_mode ==
  1569. WMI_AUTH_FT_RSNA_FILS_SHA256) ||
  1570. (auth_mode ==
  1571. WMI_AUTH_FT_RSNA_FILS_SHA384) ||
  1572. (auth_mode == WMI_AUTH_OPEN &&
  1573. roam_req->mdid.mdie_present &&
  1574. roam_req->is_11r_assoc))
  1575. len += sizeof(wmi_roam_11r_offload_tlv_param);
  1576. else
  1577. len += sizeof(wmi_roam_11i_offload_tlv_param);
  1578. } else {
  1579. len += WMI_TLV_HDR_SIZE;
  1580. }
  1581. len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
  1582. + roundup(roam_req->assoc_ie_length, sizeof(uint32_t)));
  1583. if (roam_req->add_fils_tlv) {
  1584. fils_tlv_len = sizeof(wmi_roam_fils_offload_tlv_param);
  1585. len += WMI_TLV_HDR_SIZE + fils_tlv_len;
  1586. }
  1587. } else {
  1588. if (roam_req->is_roam_req_valid)
  1589. WMI_LOGD("%s : roam offload = %d", __func__,
  1590. roam_req->roam_offload_enabled);
  1591. len += (4 * WMI_TLV_HDR_SIZE);
  1592. }
  1593. if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled)
  1594. roam_req->mode |= WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
  1595. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  1596. if (roam_req->mode ==
  1597. (WMI_ROAM_SCAN_MODE_NONE | WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
  1598. len = sizeof(wmi_roam_scan_mode_fixed_param);
  1599. buf = wmi_buf_alloc(wmi_handle, len);
  1600. if (!buf)
  1601. return QDF_STATUS_E_NOMEM;
  1602. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  1603. roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *)buf_ptr;
  1604. WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
  1605. WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
  1606. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_mode_fixed_param));
  1607. roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
  1608. roam_req->roam_trigger_reason_bitmask;
  1609. roam_scan_mode_fp->min_delay_btw_scans =
  1610. WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
  1611. roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
  1612. roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
  1613. wmi_debug("roam scan mode: %d", roam_req->mode);
  1614. if (roam_req->mode ==
  1615. (WMI_ROAM_SCAN_MODE_NONE | WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
  1616. roam_scan_mode_fp->flags |=
  1617. WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
  1618. goto send_roam_scan_mode_cmd;
  1619. }
  1620. /* Fill in scan parameters suitable for roaming scan */
  1621. buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
  1622. qdf_mem_copy(buf_ptr, scan_cmd_fp,
  1623. sizeof(wmi_start_scan_cmd_fixed_param));
  1624. /* Ensure there is no additional IEs */
  1625. scan_cmd_fp->ie_len = 0;
  1626. WMITLV_SET_HDR(buf_ptr,
  1627. WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
  1628. WMITLV_GET_STRUCT_TLVLEN(wmi_start_scan_cmd_fixed_param));
  1629. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  1630. buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
  1631. if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
  1632. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1633. sizeof(wmi_roam_offload_tlv_param));
  1634. buf_ptr += WMI_TLV_HDR_SIZE;
  1635. roam_offload_params = (wmi_roam_offload_tlv_param *)buf_ptr;
  1636. WMITLV_SET_HDR(buf_ptr,
  1637. WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
  1638. WMITLV_GET_STRUCT_TLVLEN
  1639. (wmi_roam_offload_tlv_param));
  1640. roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
  1641. roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
  1642. roam_offload_params->select_5g_margin =
  1643. roam_req->select_5ghz_margin;
  1644. roam_offload_params->handoff_delay_for_rx =
  1645. req_offload_params->ho_delay_for_rx;
  1646. roam_offload_params->max_mlme_sw_retries =
  1647. req_offload_params->roam_preauth_retry_count;
  1648. roam_offload_params->no_ack_timeout =
  1649. req_offload_params->roam_preauth_no_ack_timeout;
  1650. roam_offload_params->reassoc_failure_timeout =
  1651. roam_req->reassoc_failure_timeout;
  1652. roam_offload_params->roam_candidate_validity_time =
  1653. roam_req->rct_validity_timer;
  1654. roam_offload_params->roam_to_current_bss_disable =
  1655. roam_req->disable_self_roam;
  1656. /* Fill the capabilities */
  1657. roam_offload_params->capability =
  1658. req_offload_params->capability;
  1659. roam_offload_params->ht_caps_info =
  1660. req_offload_params->ht_caps_info;
  1661. roam_offload_params->ampdu_param =
  1662. req_offload_params->ampdu_param;
  1663. roam_offload_params->ht_ext_cap =
  1664. req_offload_params->ht_ext_cap;
  1665. roam_offload_params->ht_txbf = req_offload_params->ht_txbf;
  1666. roam_offload_params->asel_cap = req_offload_params->asel_cap;
  1667. roam_offload_params->qos_caps = req_offload_params->qos_caps;
  1668. roam_offload_params->qos_enabled =
  1669. req_offload_params->qos_enabled;
  1670. roam_offload_params->wmm_caps = req_offload_params->wmm_caps;
  1671. qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
  1672. (uint8_t *)req_offload_params->mcsset,
  1673. ROAM_OFFLOAD_NUM_MCS_SET);
  1674. buf_ptr += sizeof(wmi_roam_offload_tlv_param);
  1675. /* The TLV's are in the order of 11i, 11R, ESE. Hence,
  1676. * they are filled in the same order.Depending on the
  1677. * authentication type, the other mode TLV's are nullified
  1678. * and only headers are filled.*/
  1679. if (auth_mode != WMI_AUTH_NONE &&
  1680. (auth_mode != WMI_AUTH_OPEN ||
  1681. roam_req->is_ese_assoc ||
  1682. (auth_mode == WMI_AUTH_OPEN &&
  1683. roam_req->mdid.mdie_present && roam_req->is_11r_assoc))) {
  1684. if (roam_req->is_ese_assoc) {
  1685. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1686. WMITLV_GET_STRUCT_TLVLEN(0));
  1687. buf_ptr += WMI_TLV_HDR_SIZE;
  1688. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1689. WMITLV_GET_STRUCT_TLVLEN(0));
  1690. buf_ptr += WMI_TLV_HDR_SIZE;
  1691. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1692. sizeof(wmi_roam_ese_offload_tlv_param));
  1693. buf_ptr += WMI_TLV_HDR_SIZE;
  1694. roam_offload_ese =
  1695. (wmi_roam_ese_offload_tlv_param *)buf_ptr;
  1696. qdf_mem_copy(roam_offload_ese->krk,
  1697. roam_req->krk,
  1698. sizeof(roam_req->krk));
  1699. qdf_mem_copy(roam_offload_ese->btk,
  1700. roam_req->btk,
  1701. sizeof(roam_req->btk));
  1702. WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
  1703. WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
  1704. WMITLV_GET_STRUCT_TLVLEN
  1705. (wmi_roam_ese_offload_tlv_param));
  1706. buf_ptr +=
  1707. sizeof(wmi_roam_ese_offload_tlv_param);
  1708. } else if (auth_mode == WMI_AUTH_FT_RSNA ||
  1709. auth_mode == WMI_AUTH_FT_RSNA_PSK ||
  1710. auth_mode == WMI_AUTH_FT_RSNA_SAE ||
  1711. (auth_mode ==
  1712. WMI_AUTH_FT_RSNA_SUITE_B_8021X_SHA384) ||
  1713. (auth_mode ==
  1714. WMI_AUTH_FT_RSNA_FILS_SHA256) ||
  1715. (auth_mode ==
  1716. WMI_AUTH_FT_RSNA_FILS_SHA384) ||
  1717. (auth_mode == WMI_AUTH_OPEN &&
  1718. roam_req->mdid.mdie_present &&
  1719. roam_req->is_11r_assoc)) {
  1720. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1721. 0);
  1722. buf_ptr += WMI_TLV_HDR_SIZE;
  1723. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1724. sizeof(wmi_roam_11r_offload_tlv_param));
  1725. buf_ptr += WMI_TLV_HDR_SIZE;
  1726. roam_offload_11r =
  1727. (wmi_roam_11r_offload_tlv_param *)buf_ptr;
  1728. roam_offload_11r->r0kh_id_len =
  1729. roam_req->rokh_id_length;
  1730. qdf_mem_copy(roam_offload_11r->r0kh_id,
  1731. roam_req->rokh_id,
  1732. roam_offload_11r->r0kh_id_len);
  1733. fill_roam_offload_11r_params(auth_mode,
  1734. roam_offload_11r,
  1735. roam_req);
  1736. roam_offload_11r->mdie_present =
  1737. roam_req->mdid.mdie_present;
  1738. roam_offload_11r->mdid =
  1739. roam_req->mdid.mobility_domain;
  1740. roam_offload_11r->adaptive_11r =
  1741. roam_req->is_adaptive_11r;
  1742. roam_offload_11r->ft_im_for_deauth =
  1743. roam_req->enable_ft_im_roaming;
  1744. if (auth_mode == WMI_AUTH_OPEN) {
  1745. /*
  1746. * If FT-Open ensure pmk length and
  1747. * r0khid len are zero
  1748. */
  1749. roam_offload_11r->r0kh_id_len = 0;
  1750. roam_offload_11r->psk_msk_len = 0;
  1751. }
  1752. WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
  1753. WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
  1754. WMITLV_GET_STRUCT_TLVLEN
  1755. (wmi_roam_11r_offload_tlv_param));
  1756. buf_ptr +=
  1757. sizeof(wmi_roam_11r_offload_tlv_param);
  1758. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1759. WMITLV_GET_STRUCT_TLVLEN(0));
  1760. buf_ptr += WMI_TLV_HDR_SIZE;
  1761. WMI_LOGD("psk_msk_len = %d psk_msk_ext:%d",
  1762. roam_offload_11r->psk_msk_len,
  1763. roam_offload_11r->psk_msk_ext_len);
  1764. if (roam_offload_11r->psk_msk_len)
  1765. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
  1766. QDF_TRACE_LEVEL_DEBUG,
  1767. roam_offload_11r->psk_msk,
  1768. roam_offload_11r->psk_msk_len);
  1769. } else {
  1770. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1771. sizeof(wmi_roam_11i_offload_tlv_param));
  1772. buf_ptr += WMI_TLV_HDR_SIZE;
  1773. roam_offload_11i =
  1774. (wmi_roam_11i_offload_tlv_param *)buf_ptr;
  1775. if (roam_req->fw_okc) {
  1776. WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
  1777. (roam_offload_11i->flags);
  1778. WMI_LOGI("LFR3:OKC enabled");
  1779. } else {
  1780. WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
  1781. (roam_offload_11i->flags);
  1782. WMI_LOGI("LFR3:OKC disabled");
  1783. }
  1784. if (roam_req->fw_pmksa_cache) {
  1785. WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
  1786. (roam_offload_11i->flags);
  1787. WMI_LOGI("LFR3:PMKSA caching enabled");
  1788. } else {
  1789. WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
  1790. (roam_offload_11i->flags);
  1791. WMI_LOGI("LFR3:PMKSA caching disabled");
  1792. }
  1793. wmi_fill_sae_single_pmk_param(roam_req,
  1794. roam_offload_11i);
  1795. roam_offload_11i->pmk_len = roam_req->pmk_len >
  1796. ROAM_OFFLOAD_PMK_BYTES ?
  1797. ROAM_OFFLOAD_PMK_BYTES :
  1798. roam_req->pmk_len;
  1799. qdf_mem_copy(roam_offload_11i->pmk,
  1800. roam_req->psk_pmk,
  1801. roam_offload_11i->pmk_len);
  1802. roam_offload_11i->pmk_ext_len =
  1803. ((roam_req->pmk_len >
  1804. ROAM_OFFLOAD_PMK_BYTES) &&
  1805. (auth_mode ==
  1806. WMI_AUTH_RSNA_SUITE_B_8021X_SHA384)) ?
  1807. ROAM_OFFLOAD_PMK_EXT_BYTES : 0;
  1808. qdf_mem_copy(roam_offload_11i->pmk_ext,
  1809. &roam_req->psk_pmk[
  1810. ROAM_OFFLOAD_PMK_BYTES],
  1811. roam_offload_11i->pmk_ext_len);
  1812. WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
  1813. WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
  1814. WMITLV_GET_STRUCT_TLVLEN
  1815. (wmi_roam_11i_offload_tlv_param));
  1816. buf_ptr +=
  1817. sizeof(wmi_roam_11i_offload_tlv_param);
  1818. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1819. 0);
  1820. buf_ptr += WMI_TLV_HDR_SIZE;
  1821. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1822. 0);
  1823. buf_ptr += WMI_TLV_HDR_SIZE;
  1824. WMI_LOGD("pmk_len:%d pmk_ext_len:%d",
  1825. roam_offload_11i->pmk_len,
  1826. roam_offload_11i->pmk_ext_len);
  1827. }
  1828. } else {
  1829. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1830. WMITLV_GET_STRUCT_TLVLEN(0));
  1831. buf_ptr += WMI_TLV_HDR_SIZE;
  1832. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1833. WMITLV_GET_STRUCT_TLVLEN(0));
  1834. buf_ptr += WMI_TLV_HDR_SIZE;
  1835. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1836. WMITLV_GET_STRUCT_TLVLEN(0));
  1837. buf_ptr += WMI_TLV_HDR_SIZE;
  1838. }
  1839. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1840. sizeof(*assoc_ies));
  1841. buf_ptr += WMI_TLV_HDR_SIZE;
  1842. assoc_ies = (wmi_tlv_buf_len_param *)buf_ptr;
  1843. WMITLV_SET_HDR(&assoc_ies->tlv_header,
  1844. WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
  1845. WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
  1846. assoc_ies->buf_len = roam_req->assoc_ie_length;
  1847. buf_ptr += sizeof(*assoc_ies);
  1848. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1849. roundup(assoc_ies->buf_len, sizeof(uint32_t)));
  1850. buf_ptr += WMI_TLV_HDR_SIZE;
  1851. if (assoc_ies->buf_len != 0)
  1852. qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
  1853. assoc_ies->buf_len);
  1854. buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
  1855. buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
  1856. buf_ptr, fils_tlv_len);
  1857. } else {
  1858. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1859. WMITLV_GET_STRUCT_TLVLEN(0));
  1860. buf_ptr += WMI_TLV_HDR_SIZE;
  1861. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1862. WMITLV_GET_STRUCT_TLVLEN(0));
  1863. buf_ptr += WMI_TLV_HDR_SIZE;
  1864. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1865. WMITLV_GET_STRUCT_TLVLEN(0));
  1866. buf_ptr += WMI_TLV_HDR_SIZE;
  1867. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1868. WMITLV_GET_STRUCT_TLVLEN(0));
  1869. buf_ptr += WMI_TLV_HDR_SIZE;
  1870. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1871. WMITLV_GET_STRUCT_TLVLEN(0));
  1872. buf_ptr += WMI_TLV_HDR_SIZE;
  1873. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1874. WMITLV_GET_STRUCT_TLVLEN(0));
  1875. }
  1876. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  1877. send_roam_scan_mode_cmd:
  1878. wmi_mtrace(WMI_ROAM_SCAN_MODE, NO_SESSION, 0);
  1879. status = wmi_unified_cmd_send(wmi_handle, buf,
  1880. len, WMI_ROAM_SCAN_MODE);
  1881. if (QDF_IS_STATUS_ERROR(status))
  1882. wmi_buf_free(buf);
  1883. return status;
  1884. }
  1885. /**
  1886. * convert_roam_trigger_reason() - Function to convert unified Roam trigger
  1887. * enum to TLV specific WMI_ROAM_TRIGGER_REASON_ID
  1888. * @reason: Roam trigger reason
  1889. *
  1890. * Return: WMI_ROAM_TRIGGER_REASON_ID
  1891. */
  1892. static WMI_ROAM_TRIGGER_REASON_ID
  1893. convert_roam_trigger_reason(enum roam_trigger_reason trigger_reason)
  1894. {
  1895. switch (trigger_reason) {
  1896. case ROAM_TRIGGER_REASON_NONE:
  1897. return WMI_ROAM_TRIGGER_REASON_NONE;
  1898. case ROAM_TRIGGER_REASON_PER:
  1899. return WMI_ROAM_TRIGGER_REASON_PER;
  1900. case ROAM_TRIGGER_REASON_BMISS:
  1901. return WMI_ROAM_TRIGGER_REASON_BMISS;
  1902. case ROAM_TRIGGER_REASON_LOW_RSSI:
  1903. return WMI_ROAM_TRIGGER_REASON_LOW_RSSI;
  1904. case ROAM_TRIGGER_REASON_HIGH_RSSI:
  1905. return WMI_ROAM_TRIGGER_REASON_HIGH_RSSI;
  1906. case ROAM_TRIGGER_REASON_PERIODIC:
  1907. return WMI_ROAM_TRIGGER_REASON_PERIODIC;
  1908. case ROAM_TRIGGER_REASON_MAWC:
  1909. return WMI_ROAM_TRIGGER_REASON_MAWC;
  1910. case ROAM_TRIGGER_REASON_DENSE:
  1911. return WMI_ROAM_TRIGGER_REASON_DENSE;
  1912. case ROAM_TRIGGER_REASON_BACKGROUND:
  1913. return WMI_ROAM_TRIGGER_REASON_BACKGROUND;
  1914. case ROAM_TRIGGER_REASON_FORCED:
  1915. return WMI_ROAM_TRIGGER_REASON_FORCED;
  1916. case ROAM_TRIGGER_REASON_BTM:
  1917. return WMI_ROAM_TRIGGER_REASON_BTM;
  1918. case ROAM_TRIGGER_REASON_UNIT_TEST:
  1919. return WMI_ROAM_TRIGGER_REASON_UNIT_TEST;
  1920. case ROAM_TRIGGER_REASON_BSS_LOAD:
  1921. return WMI_ROAM_TRIGGER_REASON_BSS_LOAD;
  1922. case ROAM_TRIGGER_REASON_DEAUTH:
  1923. return WMI_ROAM_TRIGGER_REASON_DEAUTH;
  1924. case ROAM_TRIGGER_REASON_IDLE:
  1925. return WMI_ROAM_TRIGGER_REASON_IDLE;
  1926. case ROAM_TRIGGER_REASON_MAX:
  1927. return WMI_ROAM_TRIGGER_REASON_MAX;
  1928. default:
  1929. return WMI_ROAM_TRIGGER_REASON_NONE;
  1930. }
  1931. }
  1932. /**
  1933. * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
  1934. * @wmi_handle: wmi handle
  1935. * @ap_profile_p: ap profile
  1936. *
  1937. * Send WMI_ROAM_AP_PROFILE to firmware
  1938. *
  1939. * Return: CDF status
  1940. */
  1941. static QDF_STATUS
  1942. send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
  1943. struct ap_profile_params *ap_profile)
  1944. {
  1945. wmi_buf_t buf = NULL;
  1946. QDF_STATUS status;
  1947. size_t len;
  1948. uint8_t *buf_ptr;
  1949. wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
  1950. wmi_roam_cnd_scoring_param *score_param;
  1951. wmi_ap_profile *profile;
  1952. wmi_roam_score_delta_param *score_delta_param;
  1953. wmi_roam_cnd_min_rssi_param *min_rssi_param;
  1954. enum roam_trigger_reason trig_reason;
  1955. len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
  1956. len += sizeof(*score_param);
  1957. len += WMI_TLV_HDR_SIZE;
  1958. len += NUM_OF_ROAM_TRIGGERS * sizeof(*score_delta_param);
  1959. len += WMI_TLV_HDR_SIZE;
  1960. len += NUM_OF_ROAM_TRIGGERS * sizeof(*min_rssi_param);
  1961. buf = wmi_buf_alloc(wmi_handle, len);
  1962. if (!buf)
  1963. return QDF_STATUS_E_NOMEM;
  1964. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  1965. roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *)buf_ptr;
  1966. WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
  1967. WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
  1968. WMITLV_GET_STRUCT_TLVLEN
  1969. (wmi_roam_ap_profile_fixed_param));
  1970. /* fill in threshold values */
  1971. roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
  1972. roam_ap_profile_fp->id = 0;
  1973. buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
  1974. profile = (wmi_ap_profile *)buf_ptr;
  1975. WMITLV_SET_HDR(&profile->tlv_header,
  1976. WMITLV_TAG_STRUC_wmi_ap_profile,
  1977. WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
  1978. profile->flags = ap_profile->profile.flags;
  1979. profile->rssi_threshold = ap_profile->profile.rssi_threshold;
  1980. profile->ssid.ssid_len = ap_profile->profile.ssid.length;
  1981. qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.ssid,
  1982. profile->ssid.ssid_len);
  1983. profile->rsn_authmode = ap_profile->profile.rsn_authmode;
  1984. profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
  1985. profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
  1986. profile->rsn_mcastmgmtcipherset =
  1987. ap_profile->profile.rsn_mcastmgmtcipherset;
  1988. profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
  1989. WMI_LOGD("AP PROFILE: flags %x rssi_thres:%d ssid:%.*s authmode %d uc cipher %d mc cipher %d mc mgmt cipher %d rssi abs thresh %d",
  1990. profile->flags, profile->rssi_threshold,
  1991. profile->ssid.ssid_len, ap_profile->profile.ssid.ssid,
  1992. profile->rsn_authmode, profile->rsn_ucastcipherset,
  1993. profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
  1994. profile->rssi_abs_thresh);
  1995. buf_ptr += sizeof(wmi_ap_profile);
  1996. score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
  1997. WMITLV_SET_HDR(&score_param->tlv_header,
  1998. WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
  1999. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
  2000. score_param->disable_bitmap = ap_profile->param.disable_bitmap;
  2001. score_param->rssi_weightage_pcnt =
  2002. ap_profile->param.rssi_weightage;
  2003. score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
  2004. score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
  2005. score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
  2006. score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
  2007. score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
  2008. score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
  2009. score_param->esp_qbss_weightage_pcnt =
  2010. ap_profile->param.esp_qbss_weightage;
  2011. score_param->beamforming_weightage_pcnt =
  2012. ap_profile->param.beamforming_weightage;
  2013. score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
  2014. score_param->oce_wan_weightage_pcnt =
  2015. ap_profile->param.oce_wan_weightage;
  2016. score_param->oce_ap_tx_pwr_weightage_pcnt =
  2017. ap_profile->param.oce_ap_tx_pwr_weightage;
  2018. score_param->oce_ap_subnet_id_weightage_pcnt =
  2019. ap_profile->param.oce_subnet_id_weightage;
  2020. score_param->vendor_roam_score_algorithm_id =
  2021. ap_profile->param.vendor_roam_score_algorithm;
  2022. WMI_LOGD("Score params weightage: disable_bitmap %x rssi %d ht %d vht %d he %d BW %d band %d NSS %d ESP %d BF %d PCL %d OCE WAN %d APTX %d roam score algo %d subnet id %d",
  2023. score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
  2024. score_param->ht_weightage_pcnt,
  2025. score_param->vht_weightage_pcnt,
  2026. score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
  2027. score_param->band_weightage_pcnt,
  2028. score_param->nss_weightage_pcnt,
  2029. score_param->esp_qbss_weightage_pcnt,
  2030. score_param->beamforming_weightage_pcnt,
  2031. score_param->pcl_weightage_pcnt,
  2032. score_param->oce_wan_weightage_pcnt,
  2033. score_param->oce_ap_tx_pwr_weightage_pcnt,
  2034. score_param->vendor_roam_score_algorithm_id,
  2035. score_param->oce_ap_subnet_id_weightage_pcnt);
  2036. score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
  2037. score_param->band_scoring.score_pcnt =
  2038. ap_profile->param.band_index_score;
  2039. score_param->nss_scoring.score_pcnt =
  2040. ap_profile->param.nss_index_score;
  2041. wmi_debug("bw_index_score %x band_index_score %x nss_index_score %x",
  2042. score_param->bw_scoring.score_pcnt,
  2043. score_param->band_scoring.score_pcnt,
  2044. score_param->nss_scoring.score_pcnt);
  2045. score_param->rssi_scoring.best_rssi_threshold =
  2046. (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
  2047. score_param->rssi_scoring.good_rssi_threshold =
  2048. (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
  2049. score_param->rssi_scoring.bad_rssi_threshold =
  2050. (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
  2051. score_param->rssi_scoring.good_rssi_pcnt =
  2052. ap_profile->param.rssi_scoring.good_rssi_pcnt;
  2053. score_param->rssi_scoring.bad_rssi_pcnt =
  2054. ap_profile->param.rssi_scoring.bad_rssi_pcnt;
  2055. score_param->rssi_scoring.good_bucket_size =
  2056. ap_profile->param.rssi_scoring.good_rssi_bucket_size;
  2057. score_param->rssi_scoring.bad_bucket_size =
  2058. ap_profile->param.rssi_scoring.bad_rssi_bucket_size;
  2059. score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
  2060. (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
  2061. WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
  2062. score_param->rssi_scoring.best_rssi_threshold,
  2063. score_param->rssi_scoring.good_rssi_threshold,
  2064. score_param->rssi_scoring.bad_rssi_threshold,
  2065. score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
  2066. WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
  2067. score_param->rssi_scoring.good_rssi_pcnt,
  2068. score_param->rssi_scoring.bad_rssi_pcnt,
  2069. score_param->rssi_scoring.good_bucket_size,
  2070. score_param->rssi_scoring.bad_bucket_size);
  2071. score_param->esp_qbss_scoring.num_slot =
  2072. ap_profile->param.esp_qbss_scoring.num_slot;
  2073. score_param->esp_qbss_scoring.score_pcnt3_to_0 =
  2074. ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
  2075. score_param->esp_qbss_scoring.score_pcnt7_to_4 =
  2076. ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
  2077. score_param->esp_qbss_scoring.score_pcnt11_to_8 =
  2078. ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
  2079. score_param->esp_qbss_scoring.score_pcnt15_to_12 =
  2080. ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
  2081. WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
  2082. score_param->esp_qbss_scoring.num_slot,
  2083. score_param->esp_qbss_scoring.score_pcnt3_to_0,
  2084. score_param->esp_qbss_scoring.score_pcnt7_to_4,
  2085. score_param->esp_qbss_scoring.score_pcnt11_to_8,
  2086. score_param->esp_qbss_scoring.score_pcnt15_to_12);
  2087. score_param->oce_wan_scoring.num_slot =
  2088. ap_profile->param.oce_wan_scoring.num_slot;
  2089. score_param->oce_wan_scoring.score_pcnt3_to_0 =
  2090. ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
  2091. score_param->oce_wan_scoring.score_pcnt7_to_4 =
  2092. ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
  2093. score_param->oce_wan_scoring.score_pcnt11_to_8 =
  2094. ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
  2095. score_param->oce_wan_scoring.score_pcnt15_to_12 =
  2096. ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
  2097. WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
  2098. score_param->oce_wan_scoring.num_slot,
  2099. score_param->oce_wan_scoring.score_pcnt3_to_0,
  2100. score_param->oce_wan_scoring.score_pcnt7_to_4,
  2101. score_param->oce_wan_scoring.score_pcnt11_to_8,
  2102. score_param->oce_wan_scoring.score_pcnt15_to_12);
  2103. score_param->roam_score_delta_pcnt = ap_profile->param.roam_score_delta;
  2104. score_param->roam_score_delta_mask =
  2105. ap_profile->param.roam_trigger_bitmap;
  2106. score_param->candidate_min_roam_score_delta =
  2107. ap_profile->param.cand_min_roam_score_delta;
  2108. WMI_LOGD("Roam score delta:%d Roam_trigger_bitmap:%x cand min score delta = %d",
  2109. score_param->roam_score_delta_pcnt,
  2110. score_param->roam_score_delta_mask,
  2111. score_param->candidate_min_roam_score_delta);
  2112. buf_ptr += sizeof(*score_param);
  2113. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  2114. (NUM_OF_ROAM_TRIGGERS * sizeof(*score_delta_param)));
  2115. buf_ptr += WMI_TLV_HDR_SIZE;
  2116. score_delta_param = (wmi_roam_score_delta_param *)buf_ptr;
  2117. WMITLV_SET_HDR(&score_delta_param->tlv_header,
  2118. WMITLV_TAG_STRUC_wmi_roam_score_delta_param,
  2119. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_score_delta_param));
  2120. trig_reason =
  2121. ap_profile->score_delta_param[IDLE_ROAM_TRIGGER].trigger_reason;
  2122. score_delta_param->roam_trigger_reason =
  2123. convert_roam_trigger_reason(trig_reason);
  2124. score_delta_param->roam_score_delta =
  2125. ap_profile->score_delta_param[IDLE_ROAM_TRIGGER].roam_score_delta;
  2126. buf_ptr += sizeof(*score_delta_param);
  2127. score_delta_param = (wmi_roam_score_delta_param *)buf_ptr;
  2128. WMITLV_SET_HDR(&score_delta_param->tlv_header,
  2129. WMITLV_TAG_STRUC_wmi_roam_score_delta_param,
  2130. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_score_delta_param));
  2131. trig_reason =
  2132. ap_profile->score_delta_param[BTM_ROAM_TRIGGER].trigger_reason;
  2133. score_delta_param->roam_trigger_reason =
  2134. convert_roam_trigger_reason(trig_reason);
  2135. score_delta_param->roam_score_delta =
  2136. ap_profile->score_delta_param[BTM_ROAM_TRIGGER].roam_score_delta;
  2137. buf_ptr += sizeof(*score_delta_param);
  2138. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  2139. (NUM_OF_ROAM_TRIGGERS * sizeof(*min_rssi_param)));
  2140. buf_ptr += WMI_TLV_HDR_SIZE;
  2141. min_rssi_param = (wmi_roam_cnd_min_rssi_param *)buf_ptr;
  2142. WMITLV_SET_HDR(&min_rssi_param->tlv_header,
  2143. WMITLV_TAG_STRUC_wmi_roam_cnd_min_rssi_param,
  2144. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_min_rssi_param));
  2145. trig_reason =
  2146. ap_profile->min_rssi_params[DEAUTH_MIN_RSSI].trigger_reason;
  2147. min_rssi_param->roam_trigger_reason =
  2148. convert_roam_trigger_reason(trig_reason);
  2149. min_rssi_param->candidate_min_rssi =
  2150. ap_profile->min_rssi_params[DEAUTH_MIN_RSSI].min_rssi;
  2151. buf_ptr += sizeof(*min_rssi_param);
  2152. min_rssi_param = (wmi_roam_cnd_min_rssi_param *)buf_ptr;
  2153. WMITLV_SET_HDR(&min_rssi_param->tlv_header,
  2154. WMITLV_TAG_STRUC_wmi_roam_cnd_min_rssi_param,
  2155. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_min_rssi_param));
  2156. trig_reason =
  2157. ap_profile->min_rssi_params[BMISS_MIN_RSSI].trigger_reason;
  2158. min_rssi_param->roam_trigger_reason =
  2159. convert_roam_trigger_reason(trig_reason);
  2160. min_rssi_param->candidate_min_rssi =
  2161. ap_profile->min_rssi_params[BMISS_MIN_RSSI].min_rssi;
  2162. wmi_mtrace(WMI_ROAM_AP_PROFILE, NO_SESSION, 0);
  2163. status = wmi_unified_cmd_send(wmi_handle, buf,
  2164. len, WMI_ROAM_AP_PROFILE);
  2165. if (QDF_IS_STATUS_ERROR(status))
  2166. wmi_buf_free(buf);
  2167. return status;
  2168. }
  2169. /**
  2170. * send_roam_scan_offload_cmd_tlv() - set roam offload command
  2171. * @wmi_handle: wmi handle
  2172. * @command: command
  2173. * @vdev_id: vdev id
  2174. *
  2175. * This function set roam offload command to fw.
  2176. *
  2177. * Return: QDF status
  2178. */
  2179. static QDF_STATUS
  2180. send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
  2181. uint32_t command, uint32_t vdev_id)
  2182. {
  2183. QDF_STATUS status;
  2184. wmi_roam_scan_cmd_fixed_param *cmd_fp;
  2185. wmi_buf_t buf = NULL;
  2186. int len;
  2187. uint8_t *buf_ptr;
  2188. len = sizeof(wmi_roam_scan_cmd_fixed_param);
  2189. buf = wmi_buf_alloc(wmi_handle, len);
  2190. if (!buf)
  2191. return QDF_STATUS_E_NOMEM;
  2192. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  2193. cmd_fp = (wmi_roam_scan_cmd_fixed_param *)buf_ptr;
  2194. WMITLV_SET_HDR(&cmd_fp->tlv_header,
  2195. WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
  2196. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
  2197. cmd_fp->vdev_id = vdev_id;
  2198. cmd_fp->command_arg = command;
  2199. wmi_mtrace(WMI_ROAM_SCAN_CMD, NO_SESSION, 0);
  2200. status = wmi_unified_cmd_send(wmi_handle, buf,
  2201. len, WMI_ROAM_SCAN_CMD);
  2202. if (QDF_IS_STATUS_ERROR(status))
  2203. goto error;
  2204. WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
  2205. return QDF_STATUS_SUCCESS;
  2206. error:
  2207. wmi_buf_free(buf);
  2208. return status;
  2209. }
  2210. /**
  2211. * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
  2212. * @wmi_handle: wmi handle
  2213. * @chan_count: channel count
  2214. * @chan_list: channel list
  2215. * @list_type: list type
  2216. * @vdev_id: vdev id
  2217. *
  2218. * Set roam offload channel list.
  2219. *
  2220. * Return: QDF status
  2221. */
  2222. static QDF_STATUS
  2223. send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
  2224. uint8_t chan_count,
  2225. uint32_t *chan_list,
  2226. uint8_t list_type, uint32_t vdev_id)
  2227. {
  2228. wmi_buf_t buf = NULL;
  2229. QDF_STATUS status;
  2230. int len, list_tlv_len;
  2231. int i;
  2232. uint8_t *buf_ptr;
  2233. wmi_roam_chan_list_fixed_param *chan_list_fp;
  2234. uint32_t *roam_chan_list_array;
  2235. /* Channel list is a table of 2 TLV's */
  2236. list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
  2237. len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
  2238. buf = wmi_buf_alloc(wmi_handle, len);
  2239. if (!buf)
  2240. return QDF_STATUS_E_NOMEM;
  2241. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  2242. chan_list_fp = (wmi_roam_chan_list_fixed_param *)buf_ptr;
  2243. WMITLV_SET_HDR(&chan_list_fp->tlv_header,
  2244. WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
  2245. WMITLV_GET_STRUCT_TLVLEN
  2246. (wmi_roam_chan_list_fixed_param));
  2247. chan_list_fp->vdev_id = vdev_id;
  2248. chan_list_fp->num_chan = chan_count;
  2249. if (list_type == WMI_CHANNEL_LIST_STATIC) {
  2250. /* external app is controlling channel list */
  2251. chan_list_fp->chan_list_type =
  2252. WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
  2253. } else {
  2254. /* umac supplied occupied channel list in LFR */
  2255. chan_list_fp->chan_list_type =
  2256. WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
  2257. }
  2258. buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
  2259. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  2260. (chan_list_fp->num_chan * sizeof(uint32_t)));
  2261. roam_chan_list_array = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
  2262. for (i = 0; ((i < chan_list_fp->num_chan) &&
  2263. (i < WMI_ROAM_MAX_CHANNELS)); i++)
  2264. roam_chan_list_array[i] = chan_list[i];
  2265. wmi_mtrace(WMI_ROAM_CHAN_LIST, NO_SESSION, 0);
  2266. status = wmi_unified_cmd_send(wmi_handle, buf,
  2267. len, WMI_ROAM_CHAN_LIST);
  2268. if (QDF_IS_STATUS_ERROR(status))
  2269. goto error;
  2270. return QDF_STATUS_SUCCESS;
  2271. error:
  2272. wmi_buf_free(buf);
  2273. return status;
  2274. }
  2275. /**
  2276. * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
  2277. * @wmi_handle: wmi handle
  2278. * @rssi_change_thresh: RSSI Change threshold
  2279. * @bcn_rssi_weight: beacon RSSI weight
  2280. * @vdev_id: vdev id
  2281. *
  2282. * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
  2283. *
  2284. * Return: CDF status
  2285. */
  2286. static QDF_STATUS
  2287. send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
  2288. uint32_t vdev_id,
  2289. int32_t rssi_change_thresh,
  2290. uint32_t bcn_rssi_weight,
  2291. uint32_t hirssi_delay_btw_scans)
  2292. {
  2293. wmi_buf_t buf = NULL;
  2294. QDF_STATUS status;
  2295. int len;
  2296. uint8_t *buf_ptr;
  2297. wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
  2298. /* Send rssi change parameters */
  2299. len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
  2300. buf = wmi_buf_alloc(wmi_handle, len);
  2301. if (!buf)
  2302. return QDF_STATUS_E_NOMEM;
  2303. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  2304. rssi_change_fp =
  2305. (wmi_roam_scan_rssi_change_threshold_fixed_param *)buf_ptr;
  2306. WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
  2307. WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
  2308. WMITLV_GET_STRUCT_TLVLEN
  2309. (wmi_roam_scan_rssi_change_threshold_fixed_param));
  2310. /* fill in rssi change threshold (hysteresis) values */
  2311. rssi_change_fp->vdev_id = vdev_id;
  2312. rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
  2313. rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
  2314. rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
  2315. wmi_mtrace(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, NO_SESSION, 0);
  2316. status = wmi_unified_cmd_send(wmi_handle, buf,
  2317. len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
  2318. if (QDF_IS_STATUS_ERROR(status))
  2319. goto error;
  2320. wmi_nofl_debug("roam_scan_rssi_change_thresh %d bcn_rssi_weight %d hirssi_delay_btw_scans %d",
  2321. rssi_change_thresh, bcn_rssi_weight,
  2322. hirssi_delay_btw_scans);
  2323. return QDF_STATUS_SUCCESS;
  2324. error:
  2325. wmi_buf_free(buf);
  2326. return status;
  2327. }
  2328. /**
  2329. * send_per_roam_config_cmd_tlv() - set per roaming config to FW
  2330. * @wmi_handle: wmi handle
  2331. * @req_buf: per roam config buffer
  2332. *
  2333. * Return: QDF status
  2334. */
  2335. static QDF_STATUS
  2336. send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
  2337. struct wlan_per_roam_config_req *req_buf)
  2338. {
  2339. wmi_buf_t buf = NULL;
  2340. QDF_STATUS status;
  2341. int len;
  2342. uint8_t *buf_ptr;
  2343. wmi_roam_per_config_fixed_param *wmi_per_config;
  2344. len = sizeof(wmi_roam_per_config_fixed_param);
  2345. buf = wmi_buf_alloc(wmi_handle, len);
  2346. if (!buf)
  2347. return QDF_STATUS_E_NOMEM;
  2348. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  2349. wmi_per_config =
  2350. (wmi_roam_per_config_fixed_param *)buf_ptr;
  2351. WMITLV_SET_HDR(&wmi_per_config->tlv_header,
  2352. WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
  2353. WMITLV_GET_STRUCT_TLVLEN
  2354. (wmi_roam_per_config_fixed_param));
  2355. /* fill in per roam config values */
  2356. wmi_per_config->vdev_id = req_buf->vdev_id;
  2357. wmi_per_config->enable = req_buf->per_config.enable;
  2358. wmi_per_config->high_rate_thresh =
  2359. (req_buf->per_config.tx_high_rate_thresh << 16) |
  2360. (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
  2361. wmi_per_config->low_rate_thresh =
  2362. (req_buf->per_config.tx_low_rate_thresh << 16) |
  2363. (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
  2364. wmi_per_config->pkt_err_rate_thresh_pct =
  2365. (req_buf->per_config.tx_rate_thresh_percnt << 16) |
  2366. (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
  2367. wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
  2368. wmi_per_config->pkt_err_rate_mon_time =
  2369. (req_buf->per_config.tx_per_mon_time << 16) |
  2370. (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
  2371. wmi_per_config->min_candidate_rssi =
  2372. req_buf->per_config.min_candidate_rssi;
  2373. /* Send per roam config parameters */
  2374. wmi_mtrace(WMI_ROAM_PER_CONFIG_CMDID, NO_SESSION, 0);
  2375. status = wmi_unified_cmd_send(wmi_handle, buf,
  2376. len, WMI_ROAM_PER_CONFIG_CMDID);
  2377. if (QDF_IS_STATUS_ERROR(status)) {
  2378. WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
  2379. status);
  2380. wmi_buf_free(buf);
  2381. return status;
  2382. }
  2383. WMI_LOGD(FL("per roam enable=%d, vdev=%d"),
  2384. req_buf->per_config.enable, req_buf->vdev_id);
  2385. return QDF_STATUS_SUCCESS;
  2386. }
  2387. /**
  2388. * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
  2389. * configuration params
  2390. * @wmi_handle: wmi handler
  2391. * @limit_off_chan_param: pointer to wmi_off_chan_param
  2392. *
  2393. * Return: 0 for success and non zero for failure
  2394. */
  2395. static QDF_STATUS send_limit_off_chan_cmd_tlv(
  2396. wmi_unified_t wmi_handle,
  2397. struct wmi_limit_off_chan_param *limit_off_chan_param)
  2398. {
  2399. wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
  2400. wmi_buf_t buf;
  2401. uint32_t len = sizeof(*cmd);
  2402. int err;
  2403. buf = wmi_buf_alloc(wmi_handle, len);
  2404. if (!buf)
  2405. return QDF_STATUS_E_NOMEM;
  2406. cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
  2407. WMITLV_SET_HDR(&cmd->tlv_header,
  2408. WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
  2409. WMITLV_GET_STRUCT_TLVLEN(
  2410. wmi_vdev_limit_offchan_cmd_fixed_param));
  2411. cmd->vdev_id = limit_off_chan_param->vdev_id;
  2412. cmd->flags &= 0;
  2413. if (limit_off_chan_param->status)
  2414. cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
  2415. if (limit_off_chan_param->skip_dfs_chans)
  2416. cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
  2417. cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
  2418. cmd->rest_time = limit_off_chan_param->rest_time;
  2419. WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
  2420. __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
  2421. cmd->rest_time);
  2422. wmi_mtrace(WMI_VDEV_LIMIT_OFFCHAN_CMDID, cmd->vdev_id, 0);
  2423. err = wmi_unified_cmd_send(wmi_handle, buf,
  2424. len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
  2425. if (QDF_IS_STATUS_ERROR(err)) {
  2426. WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
  2427. wmi_buf_free(buf);
  2428. return QDF_STATUS_E_FAILURE;
  2429. }
  2430. return QDF_STATUS_SUCCESS;
  2431. }
  2432. #ifdef WLAN_FEATURE_FILS_SK
  2433. static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
  2434. struct hlp_params *params)
  2435. {
  2436. uint32_t len;
  2437. uint8_t *buf_ptr;
  2438. wmi_buf_t buf = NULL;
  2439. wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
  2440. len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
  2441. len += WMI_TLV_HDR_SIZE;
  2442. len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
  2443. buf = wmi_buf_alloc(wmi_handle, len);
  2444. if (!buf)
  2445. return QDF_STATUS_E_NOMEM;
  2446. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  2447. hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *)buf_ptr;
  2448. WMITLV_SET_HDR(&hlp_params->tlv_header,
  2449. WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
  2450. WMITLV_GET_STRUCT_TLVLEN(
  2451. wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
  2452. hlp_params->vdev_id = params->vdev_id;
  2453. hlp_params->size = params->hlp_ie_len;
  2454. hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
  2455. buf_ptr += sizeof(*hlp_params);
  2456. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  2457. round_up(params->hlp_ie_len, sizeof(uint32_t)));
  2458. buf_ptr += WMI_TLV_HDR_SIZE;
  2459. qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
  2460. WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
  2461. hlp_params->vdev_id, hlp_params->size);
  2462. wmi_mtrace(WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID, NO_SESSION, 0);
  2463. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  2464. WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
  2465. WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
  2466. wmi_buf_free(buf);
  2467. return QDF_STATUS_E_FAILURE;
  2468. }
  2469. return QDF_STATUS_SUCCESS;
  2470. }
  2471. void wmi_fils_sk_attach_tlv(wmi_unified_t wmi_handle)
  2472. {
  2473. struct wmi_ops *ops = wmi_handle->ops;
  2474. ops->send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv;
  2475. }
  2476. #endif /* WLAN_FEATURE_FILS_SK */
  2477. /*
  2478. * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
  2479. * @wmi_handle: wmi handle
  2480. * @params: pointer to wlan_roam_btm_config
  2481. *
  2482. * Return: QDF_STATUS
  2483. */
  2484. static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
  2485. struct wlan_roam_btm_config *params)
  2486. {
  2487. wmi_btm_config_fixed_param *cmd;
  2488. wmi_buf_t buf;
  2489. uint32_t len;
  2490. len = sizeof(*cmd);
  2491. buf = wmi_buf_alloc(wmi_handle, len);
  2492. if (!buf)
  2493. return QDF_STATUS_E_NOMEM;
  2494. cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
  2495. WMITLV_SET_HDR(&cmd->tlv_header,
  2496. WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
  2497. WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
  2498. cmd->vdev_id = params->vdev_id;
  2499. cmd->flags = params->btm_offload_config;
  2500. cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
  2501. cmd->solicited_timeout_ms = params->btm_solicited_timeout;
  2502. cmd->stick_time_seconds = params->btm_sticky_time;
  2503. cmd->disassoc_timer_threshold = params->disassoc_timer_threshold;
  2504. cmd->btm_bitmap = params->btm_query_bitmask;
  2505. cmd->btm_candidate_min_score = params->btm_candidate_min_score;
  2506. wmi_mtrace(WMI_ROAM_BTM_CONFIG_CMDID, cmd->vdev_id, 0);
  2507. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  2508. WMI_ROAM_BTM_CONFIG_CMDID)) {
  2509. WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
  2510. __func__);
  2511. wmi_buf_free(buf);
  2512. return QDF_STATUS_E_FAILURE;
  2513. }
  2514. return QDF_STATUS_SUCCESS;
  2515. }
  2516. /**
  2517. * send_roam_bss_load_config_tlv() - send roam load bss trigger configuration
  2518. * @wmi_handle: wmi handle
  2519. * @parms: pointer to wlan_roam_bss_load_config
  2520. *
  2521. * This function sends the roam load bss trigger configuration to fw.
  2522. * the bss_load_threshold parameter is used to configure the maximum
  2523. * bss load percentage, above which the firmware should trigger roaming
  2524. *
  2525. * Return: QDF status
  2526. */
  2527. static QDF_STATUS
  2528. send_roam_bss_load_config_tlv(wmi_unified_t wmi_handle,
  2529. struct wlan_roam_bss_load_config *params)
  2530. {
  2531. wmi_roam_bss_load_config_cmd_fixed_param *cmd;
  2532. wmi_buf_t buf;
  2533. uint32_t len;
  2534. len = sizeof(*cmd);
  2535. buf = wmi_buf_alloc(wmi_handle, len);
  2536. if (!buf)
  2537. return QDF_STATUS_E_NOMEM;
  2538. cmd = (wmi_roam_bss_load_config_cmd_fixed_param *)wmi_buf_data(buf);
  2539. WMITLV_SET_HDR(
  2540. &cmd->tlv_header,
  2541. WMITLV_TAG_STRUC_wmi_roam_bss_load_config_cmd_fixed_param,
  2542. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_bss_load_config_cmd_fixed_param));
  2543. cmd->vdev_id = params->vdev_id;
  2544. cmd->bss_load_threshold = params->bss_load_threshold;
  2545. cmd->monitor_time_window = params->bss_load_sample_time;
  2546. cmd->rssi_2g_threshold = params->rssi_threshold_24ghz;
  2547. cmd->rssi_5g_threshold = params->rssi_threshold_5ghz;
  2548. wmi_debug("vdev:%d bss_load_thres:%d monitor_time:%d rssi_2g:%d rssi_5g:%d",
  2549. cmd->vdev_id, cmd->bss_load_threshold,
  2550. cmd->monitor_time_window, cmd->rssi_2g_threshold,
  2551. cmd->rssi_5g_threshold);
  2552. wmi_mtrace(WMI_ROAM_BSS_LOAD_CONFIG_CMDID, cmd->vdev_id, 0);
  2553. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  2554. WMI_ROAM_BSS_LOAD_CONFIG_CMDID)) {
  2555. WMI_LOGE("%s: failed to send WMI_ROAM_BSS_LOAD_CONFIG_CMDID ",
  2556. __func__);
  2557. wmi_buf_free(buf);
  2558. return QDF_STATUS_E_FAILURE;
  2559. }
  2560. return QDF_STATUS_SUCCESS;
  2561. }
  2562. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  2563. /**
  2564. * send_disconnect_roam_params_tlv() - send disconnect roam trigger parameters
  2565. * @wmi_handle: wmi handle
  2566. * @disconnect_roam: pointer to wlan_roam_disconnect_params which carries the
  2567. * disconnect_roam_trigger parameters from CSR
  2568. *
  2569. * This function sends the disconnect roam trigger parameters to fw.
  2570. *
  2571. * Return: QDF status
  2572. */
  2573. static QDF_STATUS
  2574. send_disconnect_roam_params_tlv(wmi_unified_t wmi_handle,
  2575. struct wlan_roam_disconnect_params *req)
  2576. {
  2577. wmi_roam_deauth_config_cmd_fixed_param *cmd;
  2578. wmi_buf_t buf;
  2579. uint32_t len;
  2580. len = sizeof(*cmd);
  2581. buf = wmi_buf_alloc(wmi_handle, len);
  2582. if (!buf)
  2583. return QDF_STATUS_E_NOMEM;
  2584. cmd = (wmi_roam_deauth_config_cmd_fixed_param *)wmi_buf_data(buf);
  2585. WMITLV_SET_HDR(
  2586. &cmd->tlv_header,
  2587. WMITLV_TAG_STRUC_wmi_roam_deauth_config_cmd_fixed_param,
  2588. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_deauth_config_cmd_fixed_param));
  2589. cmd->vdev_id = req->vdev_id;
  2590. cmd->enable = req->enable;
  2591. WMI_LOGD("%s: Send WMI_ROAM_DEAUTH_CONFIG vdev_id:%d enable:%d",
  2592. __func__, cmd->vdev_id, cmd->enable);
  2593. wmi_mtrace(WMI_ROAM_DEAUTH_CONFIG_CMDID, cmd->vdev_id, 0);
  2594. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  2595. WMI_ROAM_DEAUTH_CONFIG_CMDID)) {
  2596. WMI_LOGE("%s: failed to send WMI_ROAM_DEAUTH_CONFIG_CMDID",
  2597. __func__);
  2598. wmi_buf_free(buf);
  2599. return QDF_STATUS_E_FAILURE;
  2600. }
  2601. return QDF_STATUS_SUCCESS;
  2602. }
  2603. /**
  2604. * send_idle_roam_params_tlv() - send idle roam trigger parameters
  2605. * @wmi_handle: wmi handle
  2606. * @idle_roam_params: pointer to wlan_roam_idle_params which carries the
  2607. * idle roam parameters from CSR
  2608. *
  2609. * This function sends the idle roam trigger parameters to fw.
  2610. *
  2611. * Return: QDF status
  2612. */
  2613. static QDF_STATUS
  2614. send_idle_roam_params_tlv(wmi_unified_t wmi_handle,
  2615. struct wlan_roam_idle_params *idle_roam_params)
  2616. {
  2617. wmi_roam_idle_config_cmd_fixed_param *cmd;
  2618. wmi_buf_t buf;
  2619. uint32_t len;
  2620. len = sizeof(*cmd);
  2621. buf = wmi_buf_alloc(wmi_handle, len);
  2622. if (!buf)
  2623. return QDF_STATUS_E_NOMEM;
  2624. cmd = (wmi_roam_idle_config_cmd_fixed_param *)wmi_buf_data(buf);
  2625. WMITLV_SET_HDR(
  2626. &cmd->tlv_header,
  2627. WMITLV_TAG_STRUC_wmi_roam_idle_config_cmd_fixed_param,
  2628. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_idle_config_cmd_fixed_param));
  2629. cmd->vdev_id = idle_roam_params->vdev_id;
  2630. cmd->enable = idle_roam_params->enable;
  2631. cmd->band = idle_roam_params->band;
  2632. cmd->rssi_delta = idle_roam_params->conn_ap_rssi_delta;
  2633. cmd->min_rssi = idle_roam_params->conn_ap_min_rssi;
  2634. cmd->idle_time = idle_roam_params->inactive_time;
  2635. cmd->data_packet_count = idle_roam_params->data_pkt_count;
  2636. WMI_LOGD("%s: Send WMI_ROAM_IDLE_CONFIG_CMDID vdev_id:%d enable:%d",
  2637. __func__, cmd->vdev_id, cmd->enable);
  2638. WMI_LOGD("%s: band:%d rssi_delta:%d min_rssi:%d idle_time:%d data_pkt:%d",
  2639. __func__, cmd->band, cmd->rssi_delta, cmd->min_rssi,
  2640. cmd->idle_time, cmd->data_packet_count);
  2641. wmi_mtrace(WMI_ROAM_IDLE_CONFIG_CMDID, cmd->vdev_id, 0);
  2642. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  2643. WMI_ROAM_IDLE_CONFIG_CMDID)) {
  2644. WMI_LOGE("%s: failed to send WMI_ROAM_IDLE_CONFIG_CMDID",
  2645. __func__);
  2646. wmi_buf_free(buf);
  2647. return QDF_STATUS_E_FAILURE;
  2648. }
  2649. return QDF_STATUS_SUCCESS;
  2650. }
  2651. /**
  2652. * send_roam_preauth_status_tlv() - send roam pre-authentication status
  2653. * @wmi_handle: wmi handle
  2654. * @params: pre-auth status params
  2655. *
  2656. * This function sends the roam pre-authentication status for WPA3 SAE
  2657. * pre-auth to target.
  2658. *
  2659. * Return: QDF status
  2660. */
  2661. static QDF_STATUS
  2662. send_roam_preauth_status_tlv(wmi_unified_t wmi_handle,
  2663. struct wmi_roam_auth_status_params *params)
  2664. {
  2665. wmi_roam_preauth_status_cmd_fixed_param *cmd;
  2666. wmi_buf_t buf;
  2667. uint32_t len;
  2668. uint8_t *buf_ptr;
  2669. len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + PMKID_LEN;
  2670. buf = wmi_buf_alloc(wmi_handle, len);
  2671. if (!buf)
  2672. return QDF_STATUS_E_NOMEM;
  2673. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  2674. cmd = (wmi_roam_preauth_status_cmd_fixed_param *)buf_ptr;
  2675. WMITLV_SET_HDR(
  2676. &cmd->tlv_header,
  2677. WMITLV_TAG_STRUC_wmi_roam_preauth_status_cmd_fixed_param,
  2678. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_preauth_status_cmd_fixed_param));
  2679. cmd->vdev_id = params->vdev_id;
  2680. cmd->preauth_status = params->preauth_status;
  2681. WMI_CHAR_ARRAY_TO_MAC_ADDR(params->bssid.bytes,
  2682. &cmd->candidate_ap_bssid);
  2683. buf_ptr += sizeof(wmi_roam_preauth_status_cmd_fixed_param);
  2684. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, PMKID_LEN);
  2685. buf_ptr += WMI_TLV_HDR_SIZE;
  2686. qdf_mem_copy(buf_ptr, params->pmkid, PMKID_LEN);
  2687. WMI_LOGD("%s: vdev_id:%d status:%d bssid:%pM", __func__, cmd->vdev_id,
  2688. cmd->preauth_status, params->bssid.bytes);
  2689. wmi_mtrace(WMI_ROAM_PREAUTH_STATUS_CMDID, cmd->vdev_id, 0);
  2690. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  2691. WMI_ROAM_PREAUTH_STATUS_CMDID)) {
  2692. wmi_buf_free(buf);
  2693. return QDF_STATUS_E_FAILURE;
  2694. }
  2695. return QDF_STATUS_SUCCESS;
  2696. }
  2697. #else
  2698. static inline QDF_STATUS
  2699. send_disconnect_roam_params_tlv(wmi_unified_t wmi_handle,
  2700. struct wlan_roam_disconnect_params *req)
  2701. {
  2702. return QDF_STATUS_E_FAILURE;
  2703. }
  2704. static inline QDF_STATUS
  2705. send_idle_roam_params_tlv(wmi_unified_t wmi_handle,
  2706. struct wlan_roam_idle_params *idle_roam_params)
  2707. {
  2708. return QDF_STATUS_E_FAILURE;
  2709. }
  2710. static inline QDF_STATUS
  2711. send_roam_preauth_status_tlv(wmi_unified_t wmi_handle,
  2712. struct wmi_roam_auth_status_params *params)
  2713. {
  2714. return QDF_STATUS_E_FAILURE;
  2715. }
  2716. #endif
  2717. /**
  2718. * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
  2719. * @wmi_handle: wmi handler
  2720. * @params: pointer to 11k offload params
  2721. *
  2722. * Return: 0 for success and non zero for failure
  2723. */
  2724. static QDF_STATUS
  2725. send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
  2726. struct wlan_roam_11k_offload_params *params)
  2727. {
  2728. wmi_11k_offload_report_fixed_param *cmd;
  2729. wmi_buf_t buf;
  2730. QDF_STATUS status;
  2731. uint8_t *buf_ptr;
  2732. wmi_neighbor_report_11k_offload_tlv_param
  2733. *neighbor_report_offload_params;
  2734. wmi_neighbor_report_offload *neighbor_report_offload;
  2735. uint32_t len = sizeof(*cmd);
  2736. if (params->offload_11k_bitmask &
  2737. WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
  2738. len += WMI_TLV_HDR_SIZE +
  2739. sizeof(wmi_neighbor_report_11k_offload_tlv_param);
  2740. buf = wmi_buf_alloc(wmi_handle, len);
  2741. if (!buf)
  2742. return QDF_STATUS_E_NOMEM;
  2743. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  2744. cmd = (wmi_11k_offload_report_fixed_param *)buf_ptr;
  2745. WMITLV_SET_HDR(&cmd->tlv_header,
  2746. WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
  2747. WMITLV_GET_STRUCT_TLVLEN(
  2748. wmi_11k_offload_report_fixed_param));
  2749. cmd->vdev_id = params->vdev_id;
  2750. cmd->offload_11k = params->offload_11k_bitmask;
  2751. if (params->offload_11k_bitmask &
  2752. WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
  2753. buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
  2754. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  2755. sizeof(wmi_neighbor_report_11k_offload_tlv_param));
  2756. buf_ptr += WMI_TLV_HDR_SIZE;
  2757. neighbor_report_offload_params =
  2758. (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
  2759. WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
  2760. WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
  2761. WMITLV_GET_STRUCT_TLVLEN(
  2762. wmi_neighbor_report_11k_offload_tlv_param));
  2763. neighbor_report_offload = &neighbor_report_offload_params->
  2764. neighbor_rep_ofld_params;
  2765. neighbor_report_offload->time_offset =
  2766. params->neighbor_report_params.time_offset;
  2767. neighbor_report_offload->low_rssi_offset =
  2768. params->neighbor_report_params.low_rssi_offset;
  2769. neighbor_report_offload->bmiss_count_trigger =
  2770. params->neighbor_report_params.bmiss_count_trigger;
  2771. neighbor_report_offload->per_threshold_offset =
  2772. params->neighbor_report_params.per_threshold_offset;
  2773. neighbor_report_offload->neighbor_report_cache_timeout =
  2774. params->neighbor_report_params.
  2775. neighbor_report_cache_timeout;
  2776. neighbor_report_offload->max_neighbor_report_req_cap =
  2777. params->neighbor_report_params.
  2778. max_neighbor_report_req_cap;
  2779. neighbor_report_offload->ssid.ssid_len =
  2780. params->neighbor_report_params.ssid.length;
  2781. qdf_mem_copy(neighbor_report_offload->ssid.ssid,
  2782. &params->neighbor_report_params.ssid.ssid,
  2783. neighbor_report_offload->ssid.ssid_len);
  2784. }
  2785. wmi_mtrace(WMI_11K_OFFLOAD_REPORT_CMDID, cmd->vdev_id, 0);
  2786. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  2787. WMI_11K_OFFLOAD_REPORT_CMDID);
  2788. if (status != QDF_STATUS_SUCCESS) {
  2789. WMI_LOGE("%s: failed to send 11k offload command %d",
  2790. __func__, status);
  2791. wmi_buf_free(buf);
  2792. }
  2793. return status;
  2794. }
  2795. /**
  2796. * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
  2797. * command
  2798. * @wmi_handle: wmi handler
  2799. * @params: pointer to neighbor report invoke params
  2800. *
  2801. * Return: 0 for success and non zero for failure
  2802. */
  2803. static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(
  2804. wmi_unified_t wmi_handle,
  2805. struct wmi_invoke_neighbor_report_params *params)
  2806. {
  2807. wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
  2808. wmi_buf_t buf;
  2809. QDF_STATUS status;
  2810. uint8_t *buf_ptr;
  2811. uint32_t len = sizeof(*cmd);
  2812. buf = wmi_buf_alloc(wmi_handle, len);
  2813. if (!buf)
  2814. return QDF_STATUS_E_NOMEM;
  2815. buf_ptr = (uint8_t *)wmi_buf_data(buf);
  2816. cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *)buf_ptr;
  2817. WMITLV_SET_HDR(&cmd->tlv_header,
  2818. WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
  2819. WMITLV_GET_STRUCT_TLVLEN(
  2820. wmi_11k_offload_invoke_neighbor_report_fixed_param));
  2821. cmd->vdev_id = params->vdev_id;
  2822. cmd->flags = params->send_resp_to_host;
  2823. cmd->ssid.ssid_len = params->ssid.length;
  2824. qdf_mem_copy(cmd->ssid.ssid, &params->ssid.ssid, cmd->ssid.ssid_len);
  2825. wmi_mtrace(WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID, cmd->vdev_id, 0);
  2826. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  2827. WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
  2828. if (status != QDF_STATUS_SUCCESS) {
  2829. WMI_LOGE("%s: failed to send invoke neighbor report command %d",
  2830. __func__, status);
  2831. wmi_buf_free(buf);
  2832. }
  2833. return status;
  2834. }
  2835. void wmi_roam_attach_tlv(wmi_unified_t wmi_handle)
  2836. {
  2837. struct wmi_ops *ops = wmi_handle->ops;
  2838. ops->send_roam_scan_offload_rssi_thresh_cmd =
  2839. send_roam_scan_offload_rssi_thresh_cmd_tlv;
  2840. ops->send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv;
  2841. ops->send_roam_scan_filter_cmd =
  2842. send_roam_scan_filter_cmd_tlv;
  2843. ops->send_roam_scan_offload_mode_cmd =
  2844. send_roam_scan_offload_mode_cmd_tlv;
  2845. ops->send_roam_scan_offload_ap_profile_cmd =
  2846. send_roam_scan_offload_ap_profile_cmd_tlv;
  2847. ops->send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv;
  2848. ops->send_roam_scan_offload_scan_period_cmd =
  2849. send_roam_scan_offload_scan_period_cmd_tlv;
  2850. ops->send_roam_scan_offload_chan_list_cmd =
  2851. send_roam_scan_offload_chan_list_cmd_tlv;
  2852. ops->send_roam_scan_offload_rssi_change_cmd =
  2853. send_roam_scan_offload_rssi_change_cmd_tlv;
  2854. ops->send_per_roam_config_cmd = send_per_roam_config_cmd_tlv;
  2855. ops->send_limit_off_chan_cmd = send_limit_off_chan_cmd_tlv;
  2856. ops->send_btm_config = send_btm_config_cmd_tlv;
  2857. ops->send_offload_11k_cmd = send_offload_11k_cmd_tlv;
  2858. ops->send_invoke_neighbor_report_cmd =
  2859. send_invoke_neighbor_report_cmd_tlv;
  2860. ops->send_roam_bss_load_config = send_roam_bss_load_config_tlv;
  2861. ops->send_idle_roam_params = send_idle_roam_params_tlv;
  2862. ops->send_disconnect_roam_params = send_disconnect_roam_params_tlv;
  2863. ops->send_roam_preauth_status = send_roam_preauth_status_tlv;
  2864. wmi_lfr_subnet_detection_attach_tlv(wmi_handle);
  2865. wmi_rssi_monitor_attach_tlv(wmi_handle);
  2866. wmi_ese_attach_tlv(wmi_handle);
  2867. wmi_roam_offload_attach_tlv(wmi_handle);
  2868. wmi_fils_sk_attach_tlv(wmi_handle);
  2869. }