wmi_unified_roam_tlv.c 108 KB

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