wmi_unified_roam_tlv.c 94 KB

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