wmi_unified_roam_tlv.c 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280
  1. /*
  2. * Copyright (c) 2013-2018 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. #ifdef FEATURE_LFR_SUBNET_DETECTION
  24. /**
  25. * send_set_gateway_params_cmd_tlv() - set gateway parameters
  26. * @wmi_handle: wmi handle
  27. * @req: gateway parameter update request structure
  28. *
  29. * This function reads the incoming @req and fill in the destination
  30. * WMI structure and sends down the gateway configs down to the firmware
  31. *
  32. * Return: QDF_STATUS
  33. */
  34. static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
  35. struct gateway_update_req_param *req)
  36. {
  37. wmi_roam_subnet_change_config_fixed_param *cmd;
  38. wmi_buf_t buf;
  39. QDF_STATUS ret;
  40. int len = sizeof(*cmd);
  41. buf = wmi_buf_alloc(wmi_handle, len);
  42. if (!buf) {
  43. return QDF_STATUS_E_NOMEM;
  44. }
  45. cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
  46. WMITLV_SET_HDR(&cmd->tlv_header,
  47. WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
  48. WMITLV_GET_STRUCT_TLVLEN(
  49. wmi_roam_subnet_change_config_fixed_param));
  50. cmd->vdev_id = req->session_id;
  51. qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
  52. QDF_IPV4_ADDR_SIZE);
  53. qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
  54. QDF_IPV6_ADDR_SIZE);
  55. WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
  56. &cmd->inet_gw_mac_addr);
  57. cmd->max_retries = req->max_retries;
  58. cmd->timeout = req->timeout;
  59. cmd->num_skip_subnet_change_detection_bssid_list = 0;
  60. cmd->flag = 0;
  61. if (req->ipv4_addr_type)
  62. WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
  63. if (req->ipv6_addr_type)
  64. WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
  65. wmi_mtrace(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID, cmd->vdev_id, 0);
  66. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  67. WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
  68. if (QDF_IS_STATUS_ERROR(ret)) {
  69. WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
  70. ret);
  71. wmi_buf_free(buf);
  72. }
  73. return ret;
  74. }
  75. void wmi_lfr_subnet_detection_attach_tlv(struct wmi_unified *wmi_handle)
  76. {
  77. struct wmi_ops *ops = wmi_handle->ops;
  78. ops->send_set_gateway_params_cmd = send_set_gateway_params_cmd_tlv;
  79. }
  80. #endif /* FEATURE_LFR_SUBNET_DETECTION */
  81. #ifdef FEATURE_RSSI_MONITOR
  82. /**
  83. * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
  84. * @wmi_handle: wmi handle
  85. * @req: rssi monitoring request structure
  86. *
  87. * This function reads the incoming @req and fill in the destination
  88. * WMI structure and send down the rssi monitoring configs down to the firmware
  89. *
  90. * Return: 0 on success; error number otherwise
  91. */
  92. static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
  93. struct rssi_monitor_param *req)
  94. {
  95. wmi_rssi_breach_monitor_config_fixed_param *cmd;
  96. wmi_buf_t buf;
  97. QDF_STATUS ret;
  98. uint32_t len = sizeof(*cmd);
  99. buf = wmi_buf_alloc(wmi_handle, len);
  100. if (!buf) {
  101. return QDF_STATUS_E_NOMEM;
  102. }
  103. cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
  104. WMITLV_SET_HDR(&cmd->tlv_header,
  105. WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
  106. WMITLV_GET_STRUCT_TLVLEN(
  107. wmi_rssi_breach_monitor_config_fixed_param));
  108. cmd->vdev_id = req->session_id;
  109. cmd->request_id = req->request_id;
  110. cmd->lo_rssi_reenable_hysteresis = 0;
  111. cmd->hi_rssi_reenable_histeresis = 0;
  112. cmd->min_report_interval = 0;
  113. cmd->max_num_report = 1;
  114. if (req->control) {
  115. /* enable one threshold for each min/max */
  116. cmd->enabled_bitmap = 0x09;
  117. cmd->low_rssi_breach_threshold[0] = req->min_rssi;
  118. cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
  119. } else {
  120. cmd->enabled_bitmap = 0;
  121. cmd->low_rssi_breach_threshold[0] = 0;
  122. cmd->hi_rssi_breach_threshold[0] = 0;
  123. }
  124. wmi_mtrace(WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID, cmd->vdev_id, 0);
  125. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  126. WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
  127. if (QDF_IS_STATUS_ERROR(ret)) {
  128. WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
  129. wmi_buf_free(buf);
  130. }
  131. WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
  132. return ret;
  133. }
  134. void wmi_rssi_monitor_attach_tlv(struct wmi_unified *wmi_handle)
  135. {
  136. struct wmi_ops *ops = wmi_handle->ops;
  137. ops->send_set_rssi_monitoring_cmd = send_set_rssi_monitoring_cmd_tlv;
  138. }
  139. #endif /* FEATURE_RSSI_MONITOR */
  140. /**
  141. * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
  142. * rssi threashold
  143. * @wmi_handle: wmi handle
  144. * @roam_req: Roaming request buffer
  145. *
  146. * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
  147. *
  148. * Return: QDF status
  149. */
  150. static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
  151. struct roam_offload_scan_rssi_params *roam_req)
  152. {
  153. wmi_buf_t buf = NULL;
  154. QDF_STATUS status;
  155. int len;
  156. uint8_t *buf_ptr;
  157. wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
  158. wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
  159. wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
  160. wmi_roam_dense_thres_param *dense_thresholds = NULL;
  161. wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
  162. len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
  163. len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
  164. len += sizeof(wmi_roam_scan_extended_threshold_param);
  165. len += WMI_TLV_HDR_SIZE;
  166. len += sizeof(wmi_roam_earlystop_rssi_thres_param);
  167. len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
  168. len += sizeof(wmi_roam_dense_thres_param);
  169. len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
  170. len += sizeof(wmi_roam_bg_scan_roaming_param);
  171. buf = wmi_buf_alloc(wmi_handle, len);
  172. if (!buf) {
  173. return QDF_STATUS_E_NOMEM;
  174. }
  175. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  176. rssi_threshold_fp =
  177. (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
  178. WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
  179. WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
  180. WMITLV_GET_STRUCT_TLVLEN
  181. (wmi_roam_scan_rssi_threshold_fixed_param));
  182. /* fill in threshold values */
  183. rssi_threshold_fp->vdev_id = roam_req->session_id;
  184. rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
  185. rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
  186. rssi_threshold_fp->hirssi_scan_max_count =
  187. roam_req->hi_rssi_scan_max_count;
  188. rssi_threshold_fp->hirssi_scan_delta =
  189. roam_req->hi_rssi_scan_rssi_delta;
  190. rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
  191. rssi_threshold_fp->rssi_thresh_offset_5g =
  192. roam_req->rssi_thresh_offset_5g;
  193. buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
  194. WMITLV_SET_HDR(buf_ptr,
  195. WMITLV_TAG_ARRAY_STRUC,
  196. sizeof(wmi_roam_scan_extended_threshold_param));
  197. buf_ptr += WMI_TLV_HDR_SIZE;
  198. ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
  199. ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
  200. if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
  201. ext_thresholds->boost_threshold_5g =
  202. roam_req->boost_threshold_5g;
  203. ext_thresholds->boost_algorithm_5g =
  204. WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
  205. ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
  206. ext_thresholds->penalty_algorithm_5g =
  207. WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
  208. ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
  209. ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
  210. ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
  211. ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
  212. WMITLV_SET_HDR(&ext_thresholds->tlv_header,
  213. WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
  214. WMITLV_GET_STRUCT_TLVLEN
  215. (wmi_roam_scan_extended_threshold_param));
  216. buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
  217. WMITLV_SET_HDR(buf_ptr,
  218. WMITLV_TAG_ARRAY_STRUC,
  219. sizeof(wmi_roam_earlystop_rssi_thres_param));
  220. buf_ptr += WMI_TLV_HDR_SIZE;
  221. early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
  222. early_stop_thresholds->roam_earlystop_thres_min =
  223. roam_req->roam_earlystop_thres_min;
  224. early_stop_thresholds->roam_earlystop_thres_max =
  225. roam_req->roam_earlystop_thres_max;
  226. WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
  227. WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
  228. WMITLV_GET_STRUCT_TLVLEN
  229. (wmi_roam_earlystop_rssi_thres_param));
  230. buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
  231. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  232. sizeof(wmi_roam_dense_thres_param));
  233. buf_ptr += WMI_TLV_HDR_SIZE;
  234. dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
  235. dense_thresholds->roam_dense_rssi_thres_offset =
  236. roam_req->dense_rssi_thresh_offset;
  237. dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
  238. dense_thresholds->roam_dense_traffic_thres =
  239. roam_req->traffic_threshold;
  240. dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
  241. WMITLV_SET_HDR(&dense_thresholds->tlv_header,
  242. WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
  243. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_dense_thres_param));
  244. buf_ptr += sizeof(wmi_roam_dense_thres_param);
  245. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  246. sizeof(wmi_roam_bg_scan_roaming_param));
  247. buf_ptr += WMI_TLV_HDR_SIZE;
  248. bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
  249. bg_scan_params->roam_bg_scan_bad_rssi_thresh =
  250. roam_req->bg_scan_bad_rssi_thresh;
  251. bg_scan_params->roam_bg_scan_client_bitmap =
  252. roam_req->bg_scan_client_bitmap;
  253. bg_scan_params->bad_rssi_thresh_offset_2g =
  254. roam_req->roam_bad_rssi_thresh_offset_2g;
  255. bg_scan_params->flags = roam_req->flags;
  256. WMITLV_SET_HDR(&bg_scan_params->tlv_header,
  257. WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
  258. WMITLV_GET_STRUCT_TLVLEN
  259. (wmi_roam_bg_scan_roaming_param));
  260. wmi_mtrace(WMI_ROAM_SCAN_RSSI_THRESHOLD, NO_SESSION, 0);
  261. status = wmi_unified_cmd_send(wmi_handle, buf,
  262. len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
  263. if (QDF_IS_STATUS_ERROR(status)) {
  264. WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
  265. status);
  266. wmi_buf_free(buf);
  267. }
  268. return status;
  269. }
  270. static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
  271. struct wmi_mawc_roam_params *params)
  272. {
  273. wmi_buf_t buf = NULL;
  274. QDF_STATUS status;
  275. int len;
  276. uint8_t *buf_ptr;
  277. wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
  278. len = sizeof(*wmi_roam_mawc_params);
  279. buf = wmi_buf_alloc(wmi_handle, len);
  280. if (!buf) {
  281. return QDF_STATUS_E_NOMEM;
  282. }
  283. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  284. wmi_roam_mawc_params =
  285. (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
  286. WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
  287. WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
  288. WMITLV_GET_STRUCT_TLVLEN
  289. (wmi_roam_configure_mawc_cmd_fixed_param));
  290. wmi_roam_mawc_params->vdev_id = params->vdev_id;
  291. if (params->enable)
  292. wmi_roam_mawc_params->enable = 1;
  293. else
  294. wmi_roam_mawc_params->enable = 0;
  295. wmi_roam_mawc_params->traffic_load_threshold =
  296. params->traffic_load_threshold;
  297. wmi_roam_mawc_params->best_ap_rssi_threshold =
  298. params->best_ap_rssi_threshold;
  299. wmi_roam_mawc_params->rssi_stationary_high_adjust =
  300. params->rssi_stationary_high_adjust;
  301. wmi_roam_mawc_params->rssi_stationary_low_adjust =
  302. params->rssi_stationary_low_adjust;
  303. WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
  304. wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
  305. wmi_roam_mawc_params->traffic_load_threshold,
  306. wmi_roam_mawc_params->best_ap_rssi_threshold,
  307. wmi_roam_mawc_params->rssi_stationary_high_adjust,
  308. wmi_roam_mawc_params->rssi_stationary_low_adjust);
  309. wmi_mtrace(WMI_ROAM_CONFIGURE_MAWC_CMDID, NO_SESSION, 0);
  310. status = wmi_unified_cmd_send(wmi_handle, buf,
  311. len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
  312. if (QDF_IS_STATUS_ERROR(status)) {
  313. WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
  314. status);
  315. wmi_buf_free(buf);
  316. return status;
  317. }
  318. return QDF_STATUS_SUCCESS;
  319. }
  320. /**
  321. * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
  322. * @wmi_handle: wmi handle
  323. * @roam_req: Request which contains the filters
  324. *
  325. * There are filters such as whitelist, blacklist and preferred
  326. * list that need to be applied to the scan results to form the
  327. * probable candidates for roaming.
  328. *
  329. * Return: Return success upon successfully passing the
  330. * parameters to the firmware, otherwise failure.
  331. */
  332. static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
  333. struct roam_scan_filter_params *roam_req)
  334. {
  335. wmi_buf_t buf = NULL;
  336. QDF_STATUS status;
  337. uint32_t i;
  338. uint32_t len, blist_len = 0;
  339. uint8_t *buf_ptr;
  340. wmi_roam_filter_fixed_param *roam_filter;
  341. uint8_t *bssid_src_ptr = NULL;
  342. wmi_mac_addr *bssid_dst_ptr = NULL;
  343. wmi_ssid *ssid_ptr = NULL;
  344. uint32_t *bssid_preferred_factor_ptr = NULL;
  345. wmi_roam_lca_disallow_config_tlv_param *blist_param;
  346. wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
  347. len = sizeof(wmi_roam_filter_fixed_param);
  348. len += WMI_TLV_HDR_SIZE;
  349. if (roam_req->num_bssid_black_list)
  350. len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
  351. len += WMI_TLV_HDR_SIZE;
  352. if (roam_req->num_ssid_white_list)
  353. len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
  354. len += 2 * WMI_TLV_HDR_SIZE;
  355. if (roam_req->num_bssid_preferred_list) {
  356. len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
  357. len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
  358. }
  359. len += WMI_TLV_HDR_SIZE;
  360. if (roam_req->lca_disallow_config_present) {
  361. len += sizeof(*blist_param);
  362. blist_len = sizeof(*blist_param);
  363. }
  364. len += WMI_TLV_HDR_SIZE;
  365. if (roam_req->num_rssi_rejection_ap)
  366. len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
  367. buf = wmi_buf_alloc(wmi_handle, len);
  368. if (!buf) {
  369. return QDF_STATUS_E_NOMEM;
  370. }
  371. buf_ptr = (u_int8_t *) wmi_buf_data(buf);
  372. roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
  373. WMITLV_SET_HDR(&roam_filter->tlv_header,
  374. WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
  375. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
  376. /* fill in fixed values */
  377. roam_filter->vdev_id = roam_req->session_id;
  378. roam_filter->flags = 0;
  379. roam_filter->op_bitmap = roam_req->op_bitmap;
  380. roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
  381. roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
  382. roam_filter->num_bssid_preferred_list =
  383. roam_req->num_bssid_preferred_list;
  384. roam_filter->num_rssi_rejection_ap =
  385. roam_req->num_rssi_rejection_ap;
  386. buf_ptr += sizeof(wmi_roam_filter_fixed_param);
  387. WMITLV_SET_HDR((buf_ptr),
  388. WMITLV_TAG_ARRAY_FIXED_STRUC,
  389. (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
  390. bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
  391. bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
  392. for (i = 0; i < roam_req->num_bssid_black_list; i++) {
  393. WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
  394. bssid_src_ptr += ATH_MAC_LEN;
  395. bssid_dst_ptr++;
  396. }
  397. buf_ptr += WMI_TLV_HDR_SIZE +
  398. (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
  399. WMITLV_SET_HDR((buf_ptr),
  400. WMITLV_TAG_ARRAY_FIXED_STRUC,
  401. (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
  402. ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
  403. for (i = 0; i < roam_req->num_ssid_white_list; i++) {
  404. qdf_mem_copy(&ssid_ptr->ssid,
  405. &roam_req->ssid_allowed_list[i].mac_ssid,
  406. roam_req->ssid_allowed_list[i].length);
  407. ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
  408. ssid_ptr++;
  409. }
  410. buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
  411. sizeof(wmi_ssid));
  412. WMITLV_SET_HDR((buf_ptr),
  413. WMITLV_TAG_ARRAY_FIXED_STRUC,
  414. (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
  415. bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
  416. bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
  417. for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
  418. WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
  419. (wmi_mac_addr *)bssid_dst_ptr);
  420. bssid_src_ptr += ATH_MAC_LEN;
  421. bssid_dst_ptr++;
  422. }
  423. buf_ptr += WMI_TLV_HDR_SIZE +
  424. (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
  425. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  426. (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
  427. bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
  428. for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
  429. *bssid_preferred_factor_ptr =
  430. roam_req->bssid_favored_factor[i];
  431. bssid_preferred_factor_ptr++;
  432. }
  433. buf_ptr += WMI_TLV_HDR_SIZE +
  434. (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
  435. WMITLV_SET_HDR(buf_ptr,
  436. WMITLV_TAG_ARRAY_STRUC, blist_len);
  437. buf_ptr += WMI_TLV_HDR_SIZE;
  438. if (roam_req->lca_disallow_config_present) {
  439. blist_param =
  440. (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
  441. WMITLV_SET_HDR(&blist_param->tlv_header,
  442. WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
  443. WMITLV_GET_STRUCT_TLVLEN(
  444. wmi_roam_lca_disallow_config_tlv_param));
  445. blist_param->disallow_duration = roam_req->disallow_duration;
  446. blist_param->rssi_channel_penalization =
  447. roam_req->rssi_channel_penalization;
  448. blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
  449. blist_param->disallow_lca_enable_source_bitmap =
  450. (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
  451. WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
  452. buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
  453. }
  454. WMITLV_SET_HDR(buf_ptr,
  455. WMITLV_TAG_ARRAY_STRUC,
  456. (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
  457. buf_ptr += WMI_TLV_HDR_SIZE;
  458. for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
  459. rssi_rej =
  460. (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
  461. WMITLV_SET_HDR(&rssi_rej->tlv_header,
  462. WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
  463. WMITLV_GET_STRUCT_TLVLEN(
  464. wmi_roam_rssi_rejection_oce_config_param));
  465. WMI_CHAR_ARRAY_TO_MAC_ADDR(
  466. roam_req->rssi_rejection_ap[i].bssid.bytes,
  467. &rssi_rej->bssid);
  468. rssi_rej->remaining_disallow_duration =
  469. roam_req->rssi_rejection_ap[i].remaining_duration;
  470. rssi_rej->requested_rssi =
  471. (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
  472. buf_ptr +=
  473. (sizeof(wmi_roam_rssi_rejection_oce_config_param));
  474. }
  475. wmi_mtrace(WMI_ROAM_FILTER_CMDID, NO_SESSION, 0);
  476. status = wmi_unified_cmd_send(wmi_handle, buf,
  477. len, WMI_ROAM_FILTER_CMDID);
  478. if (QDF_IS_STATUS_ERROR(status)) {
  479. WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
  480. status);
  481. wmi_buf_free(buf);
  482. }
  483. return status;
  484. }
  485. #ifdef FEATURE_WLAN_ESE
  486. /**
  487. * send_plm_stop_cmd_tlv() - plm stop request
  488. * @wmi_handle: wmi handle
  489. * @plm: plm request parameters
  490. *
  491. * This function request FW to stop PLM.
  492. *
  493. * Return: CDF status
  494. */
  495. static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
  496. const struct plm_req_params *plm)
  497. {
  498. wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
  499. int32_t len;
  500. wmi_buf_t buf;
  501. uint8_t *buf_ptr;
  502. int ret;
  503. len = sizeof(*cmd);
  504. buf = wmi_buf_alloc(wmi_handle, len);
  505. if (!buf) {
  506. return QDF_STATUS_E_NOMEM;
  507. }
  508. cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
  509. buf_ptr = (uint8_t *) cmd;
  510. WMITLV_SET_HDR(&cmd->tlv_header,
  511. WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
  512. WMITLV_GET_STRUCT_TLVLEN
  513. (wmi_vdev_plmreq_stop_cmd_fixed_param));
  514. cmd->vdev_id = plm->session_id;
  515. cmd->meas_token = plm->meas_token;
  516. WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
  517. wmi_mtrace(WMI_VDEV_PLMREQ_STOP_CMDID, cmd->vdev_id, 0);
  518. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  519. WMI_VDEV_PLMREQ_STOP_CMDID);
  520. if (ret) {
  521. WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
  522. wmi_buf_free(buf);
  523. return QDF_STATUS_E_FAILURE;
  524. }
  525. return QDF_STATUS_SUCCESS;
  526. }
  527. /**
  528. * send_plm_start_cmd_tlv() - plm start request
  529. * @wmi_handle: wmi handle
  530. * @plm: plm request parameters
  531. *
  532. * This function request FW to start PLM.
  533. *
  534. * Return: CDF status
  535. */
  536. static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
  537. const struct plm_req_params *plm,
  538. uint32_t *gchannel_list)
  539. {
  540. wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
  541. uint32_t *channel_list;
  542. int32_t len;
  543. wmi_buf_t buf;
  544. uint8_t *buf_ptr;
  545. uint8_t count;
  546. int ret;
  547. /* TLV place holder for channel_list */
  548. len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
  549. len += sizeof(uint32_t) * plm->plm_num_ch;
  550. buf = wmi_buf_alloc(wmi_handle, len);
  551. if (!buf) {
  552. return QDF_STATUS_E_NOMEM;
  553. }
  554. cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
  555. buf_ptr = (uint8_t *) cmd;
  556. WMITLV_SET_HDR(&cmd->tlv_header,
  557. WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
  558. WMITLV_GET_STRUCT_TLVLEN
  559. (wmi_vdev_plmreq_start_cmd_fixed_param));
  560. cmd->vdev_id = plm->session_id;
  561. cmd->meas_token = plm->meas_token;
  562. cmd->dialog_token = plm->diag_token;
  563. cmd->number_bursts = plm->num_bursts;
  564. cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
  565. cmd->off_duration = plm->meas_duration;
  566. cmd->burst_cycle = plm->burst_len;
  567. cmd->tx_power = plm->desired_tx_pwr;
  568. WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
  569. cmd->num_chans = plm->plm_num_ch;
  570. buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
  571. WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
  572. WMI_LOGD("dialog_token: %d", cmd->dialog_token);
  573. WMI_LOGD("number_bursts: %d", cmd->number_bursts);
  574. WMI_LOGD("burst_interval: %d", cmd->burst_interval);
  575. WMI_LOGD("off_duration: %d", cmd->off_duration);
  576. WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
  577. WMI_LOGD("tx_power: %d", cmd->tx_power);
  578. WMI_LOGD("Number of channels : %d", cmd->num_chans);
  579. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  580. (cmd->num_chans * sizeof(uint32_t)));
  581. buf_ptr += WMI_TLV_HDR_SIZE;
  582. if (cmd->num_chans) {
  583. channel_list = (uint32_t *) buf_ptr;
  584. for (count = 0; count < cmd->num_chans; count++) {
  585. channel_list[count] = plm->plm_ch_list[count];
  586. if (channel_list[count] < WMI_NLO_FREQ_THRESH)
  587. channel_list[count] =
  588. gchannel_list[count];
  589. WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
  590. }
  591. buf_ptr += cmd->num_chans * sizeof(uint32_t);
  592. }
  593. wmi_mtrace(WMI_VDEV_PLMREQ_START_CMDID, cmd->vdev_id, 0);
  594. ret = wmi_unified_cmd_send(wmi_handle, buf, len,
  595. WMI_VDEV_PLMREQ_START_CMDID);
  596. if (ret) {
  597. WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
  598. wmi_buf_free(buf);
  599. return QDF_STATUS_E_FAILURE;
  600. }
  601. return QDF_STATUS_SUCCESS;
  602. }
  603. void wmi_ese_attach_tlv(wmi_unified_t wmi_handle)
  604. {
  605. struct wmi_ops *ops = wmi_handle->ops;
  606. ops->send_plm_stop_cmd = send_plm_stop_cmd_tlv;
  607. ops->send_plm_start_cmd = send_plm_start_cmd_tlv;
  608. }
  609. #endif /* FEATURE_WLAN_ESE */
  610. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  611. /* send_set_ric_req_cmd_tlv() - set ric request element
  612. * @wmi_handle: wmi handle
  613. * @msg: message
  614. * @is_add_ts: is addts required
  615. *
  616. * This function sets ric request element for 11r roaming.
  617. *
  618. * Return: CDF status
  619. */
  620. static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
  621. void *msg, uint8_t is_add_ts)
  622. {
  623. wmi_ric_request_fixed_param *cmd;
  624. wmi_ric_tspec *tspec_param;
  625. wmi_buf_t buf;
  626. uint8_t *buf_ptr;
  627. struct mac_tspec_ie *ptspecIE = NULL;
  628. int32_t len = sizeof(wmi_ric_request_fixed_param) +
  629. WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
  630. buf = wmi_buf_alloc(wmi_handle, len);
  631. if (!buf) {
  632. return QDF_STATUS_E_NOMEM;
  633. }
  634. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  635. cmd = (wmi_ric_request_fixed_param *) buf_ptr;
  636. WMITLV_SET_HDR(&cmd->tlv_header,
  637. WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
  638. WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
  639. if (is_add_ts)
  640. cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
  641. else
  642. cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
  643. cmd->num_ric_request = 1;
  644. cmd->is_add_ric = is_add_ts;
  645. buf_ptr += sizeof(wmi_ric_request_fixed_param);
  646. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
  647. buf_ptr += WMI_TLV_HDR_SIZE;
  648. tspec_param = (wmi_ric_tspec *) buf_ptr;
  649. WMITLV_SET_HDR(&tspec_param->tlv_header,
  650. WMITLV_TAG_STRUC_wmi_ric_tspec,
  651. WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
  652. if (is_add_ts)
  653. ptspecIE = &(((struct add_ts_param *) msg)->tspec);
  654. else
  655. ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
  656. if (ptspecIE) {
  657. /* Fill the tsinfo in the format expected by firmware */
  658. #ifndef ANI_LITTLE_BIT_ENDIAN
  659. qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
  660. ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
  661. #else
  662. qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
  663. ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
  664. #endif /* ANI_LITTLE_BIT_ENDIAN */
  665. tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
  666. tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
  667. tspec_param->min_service_interval = ptspecIE->minSvcInterval;
  668. tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
  669. tspec_param->inactivity_interval = ptspecIE->inactInterval;
  670. tspec_param->suspension_interval = ptspecIE->suspendInterval;
  671. tspec_param->svc_start_time = ptspecIE->svcStartTime;
  672. tspec_param->min_data_rate = ptspecIE->minDataRate;
  673. tspec_param->mean_data_rate = ptspecIE->meanDataRate;
  674. tspec_param->peak_data_rate = ptspecIE->peakDataRate;
  675. tspec_param->max_burst_size = ptspecIE->maxBurstSz;
  676. tspec_param->delay_bound = ptspecIE->delayBound;
  677. tspec_param->min_phy_rate = ptspecIE->minPhyRate;
  678. tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
  679. tspec_param->medium_time = 0;
  680. }
  681. WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
  682. wmi_mtrace(WMI_ROAM_SET_RIC_REQUEST_CMDID, cmd->vdev_id, 0);
  683. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  684. WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
  685. WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
  686. __func__);
  687. if (is_add_ts)
  688. ((struct add_ts_param *) msg)->status =
  689. QDF_STATUS_E_FAILURE;
  690. wmi_buf_free(buf);
  691. return QDF_STATUS_E_FAILURE;
  692. }
  693. return QDF_STATUS_SUCCESS;
  694. }
  695. /**
  696. * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
  697. * @wmi_handle: wmi handle
  698. * @vdev_id: vdev id
  699. *
  700. * This function sends roam synch complete event to fw.
  701. *
  702. * Return: CDF STATUS
  703. */
  704. static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
  705. uint8_t vdev_id)
  706. {
  707. wmi_roam_synch_complete_fixed_param *cmd;
  708. wmi_buf_t wmi_buf;
  709. uint8_t *buf_ptr;
  710. uint16_t len;
  711. len = sizeof(wmi_roam_synch_complete_fixed_param);
  712. wmi_buf = wmi_buf_alloc(wmi_handle, len);
  713. if (!wmi_buf) {
  714. return QDF_STATUS_E_NOMEM;
  715. }
  716. cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
  717. buf_ptr = (uint8_t *) cmd;
  718. WMITLV_SET_HDR(&cmd->tlv_header,
  719. WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
  720. WMITLV_GET_STRUCT_TLVLEN
  721. (wmi_roam_synch_complete_fixed_param));
  722. cmd->vdev_id = vdev_id;
  723. wmi_mtrace(WMI_ROAM_SYNCH_COMPLETE, cmd->vdev_id, 0);
  724. if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
  725. WMI_ROAM_SYNCH_COMPLETE)) {
  726. WMI_LOGP("%s: failed to send roam synch confirmation",
  727. __func__);
  728. wmi_buf_free(wmi_buf);
  729. return QDF_STATUS_E_FAILURE;
  730. }
  731. return QDF_STATUS_SUCCESS;
  732. }
  733. /**
  734. * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
  735. * @wmi_handle: wma handle
  736. * @roaminvoke: roam invoke command
  737. *
  738. * Send roam invoke command to fw for fastreassoc.
  739. *
  740. * Return: CDF STATUS
  741. */
  742. static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
  743. struct wmi_roam_invoke_cmd *roaminvoke,
  744. uint32_t ch_hz)
  745. {
  746. wmi_roam_invoke_cmd_fixed_param *cmd;
  747. wmi_buf_t wmi_buf;
  748. u_int8_t *buf_ptr;
  749. u_int16_t len, args_tlv_len;
  750. uint32_t *channel_list;
  751. wmi_mac_addr *bssid_list;
  752. wmi_tlv_buf_len_param *buf_len_tlv;
  753. /* Host sends only one channel and one bssid */
  754. args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
  755. sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
  756. roundup(roaminvoke->frame_len, sizeof(uint32_t));
  757. len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
  758. wmi_buf = wmi_buf_alloc(wmi_handle, len);
  759. if (!wmi_buf) {
  760. return QDF_STATUS_E_NOMEM;
  761. }
  762. cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
  763. buf_ptr = (u_int8_t *) cmd;
  764. WMITLV_SET_HDR(&cmd->tlv_header,
  765. WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
  766. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
  767. cmd->vdev_id = roaminvoke->vdev_id;
  768. cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
  769. if (roaminvoke->is_same_bssid)
  770. cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
  771. WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
  772. if (roaminvoke->frame_len) {
  773. cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
  774. /* packing 1 beacon/probe_rsp frame with WMI cmd */
  775. cmd->num_buf = 1;
  776. } else {
  777. cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
  778. cmd->num_buf = 0;
  779. }
  780. cmd->roam_ap_sel_mode = 0;
  781. cmd->roam_delay = 0;
  782. cmd->num_chan = 1;
  783. cmd->num_bssid = 1;
  784. buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
  785. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  786. (sizeof(u_int32_t)));
  787. channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
  788. *channel_list = ch_hz;
  789. buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
  790. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
  791. (sizeof(wmi_mac_addr)));
  792. bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
  793. WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
  794. /* move to next tlv i.e. bcn_prb_buf_list */
  795. buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
  796. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
  797. sizeof(wmi_tlv_buf_len_param));
  798. buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
  799. buf_len_tlv->buf_len = roaminvoke->frame_len;
  800. /* move to next tlv i.e. bcn_prb_frm */
  801. buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
  802. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  803. roundup(roaminvoke->frame_len, sizeof(uint32_t)));
  804. /* copy frame after the header */
  805. qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
  806. roaminvoke->frame_buf,
  807. roaminvoke->frame_len);
  808. WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
  809. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
  810. buf_ptr + WMI_TLV_HDR_SIZE,
  811. roaminvoke->frame_len);
  812. WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
  813. cmd->flags, cmd->roam_scan_mode,
  814. cmd->roam_ap_sel_mode, cmd->roam_delay,
  815. cmd->num_chan, cmd->num_bssid);
  816. WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
  817. wmi_mtrace(WMI_ROAM_INVOKE_CMDID, cmd->vdev_id, 0);
  818. if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
  819. WMI_ROAM_INVOKE_CMDID)) {
  820. WMI_LOGP("%s: failed to send roam invoke command", __func__);
  821. wmi_buf_free(wmi_buf);
  822. return QDF_STATUS_E_FAILURE;
  823. }
  824. return QDF_STATUS_SUCCESS;
  825. }
  826. void wmi_roam_offload_attach_tlv(wmi_unified_t wmi_handle)
  827. {
  828. struct wmi_ops *ops = wmi_handle->ops;
  829. ops->send_set_ric_req_cmd = send_set_ric_req_cmd_tlv;
  830. ops->send_process_roam_synch_complete_cmd =
  831. send_process_roam_synch_complete_cmd_tlv;
  832. ops->send_roam_invoke_cmd = send_roam_invoke_cmd_tlv;
  833. }
  834. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  835. #if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
  836. /**
  837. * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
  838. * @wmi_handle: wmi handle
  839. * @roam_req: Roam scan offload params
  840. * @buf_ptr: command buffer to send
  841. * @fils_tlv_len: fils tlv length
  842. *
  843. * Return: Updated buffer pointer
  844. */
  845. static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
  846. struct roam_offload_scan_params *roam_req,
  847. uint8_t *buf_ptr, uint32_t fils_tlv_len)
  848. {
  849. wmi_roam_fils_offload_tlv_param *fils_tlv;
  850. wmi_erp_info *erp_info;
  851. struct roam_fils_params *roam_fils_params;
  852. if (!roam_req->add_fils_tlv)
  853. return buf_ptr;
  854. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  855. sizeof(*fils_tlv));
  856. buf_ptr += WMI_TLV_HDR_SIZE;
  857. fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
  858. WMITLV_SET_HDR(&fils_tlv->tlv_header,
  859. WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
  860. WMITLV_GET_STRUCT_TLVLEN
  861. (wmi_roam_fils_offload_tlv_param));
  862. roam_fils_params = &roam_req->roam_fils_params;
  863. erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
  864. erp_info->username_length = roam_fils_params->username_length;
  865. qdf_mem_copy(erp_info->username, roam_fils_params->username,
  866. erp_info->username_length);
  867. erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
  868. erp_info->rRk_length = roam_fils_params->rrk_length;
  869. qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
  870. erp_info->rRk_length);
  871. erp_info->rIk_length = roam_fils_params->rik_length;
  872. qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
  873. erp_info->rIk_length);
  874. erp_info->realm_len = roam_fils_params->realm_len;
  875. qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
  876. erp_info->realm_len);
  877. buf_ptr += sizeof(*fils_tlv);
  878. return buf_ptr;
  879. }
  880. #else
  881. static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
  882. struct roam_offload_scan_params *roam_req,
  883. uint8_t *buf_ptr, uint32_t fils_tlv_len)
  884. {
  885. return buf_ptr;
  886. }
  887. #endif
  888. /**
  889. * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
  890. * @wmi_handle: wmi handle
  891. * @scan_cmd_fp: start scan command ptr
  892. * @roam_req: roam request param
  893. *
  894. * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
  895. * of WMI_ROAM_SCAN_MODE.
  896. *
  897. * Return: QDF status
  898. */
  899. static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
  900. wmi_start_scan_cmd_fixed_param *
  901. scan_cmd_fp,
  902. struct roam_offload_scan_params *roam_req)
  903. {
  904. wmi_buf_t buf = NULL;
  905. QDF_STATUS status;
  906. int len;
  907. uint8_t *buf_ptr;
  908. wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
  909. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  910. int auth_mode = roam_req->auth_mode;
  911. roam_offload_param *req_offload_params =
  912. &roam_req->roam_offload_params;
  913. wmi_roam_offload_tlv_param *roam_offload_params;
  914. wmi_roam_11i_offload_tlv_param *roam_offload_11i;
  915. wmi_roam_11r_offload_tlv_param *roam_offload_11r;
  916. wmi_roam_ese_offload_tlv_param *roam_offload_ese;
  917. wmi_tlv_buf_len_param *assoc_ies;
  918. uint32_t fils_tlv_len = 0;
  919. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  920. /* Need to create a buf with roam_scan command at
  921. * front and piggyback with scan command */
  922. len = sizeof(wmi_roam_scan_mode_fixed_param) +
  923. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  924. (2 * WMI_TLV_HDR_SIZE) +
  925. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  926. sizeof(wmi_start_scan_cmd_fixed_param);
  927. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  928. WMI_LOGD("auth_mode = %d", auth_mode);
  929. if (roam_req->is_roam_req_valid &&
  930. roam_req->roam_offload_enabled) {
  931. len += sizeof(wmi_roam_offload_tlv_param);
  932. len += WMI_TLV_HDR_SIZE;
  933. if ((auth_mode != WMI_AUTH_NONE) &&
  934. ((auth_mode != WMI_AUTH_OPEN) ||
  935. (auth_mode == WMI_AUTH_OPEN &&
  936. roam_req->mdid.mdie_present &&
  937. roam_req->is_11r_assoc) ||
  938. roam_req->is_ese_assoc)) {
  939. len += WMI_TLV_HDR_SIZE;
  940. if (roam_req->is_ese_assoc)
  941. len +=
  942. sizeof(wmi_roam_ese_offload_tlv_param);
  943. else if (auth_mode == WMI_AUTH_FT_RSNA ||
  944. auth_mode == WMI_AUTH_FT_RSNA_PSK ||
  945. (auth_mode == WMI_AUTH_OPEN &&
  946. roam_req->mdid.mdie_present &&
  947. roam_req->is_11r_assoc))
  948. len +=
  949. sizeof(wmi_roam_11r_offload_tlv_param);
  950. else
  951. len +=
  952. sizeof(wmi_roam_11i_offload_tlv_param);
  953. } else {
  954. len += WMI_TLV_HDR_SIZE;
  955. }
  956. len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
  957. + roundup(roam_req->assoc_ie_length,
  958. sizeof(uint32_t)));
  959. if (roam_req->add_fils_tlv) {
  960. fils_tlv_len = sizeof(
  961. wmi_roam_fils_offload_tlv_param);
  962. len += WMI_TLV_HDR_SIZE + fils_tlv_len;
  963. }
  964. } else {
  965. if (roam_req->is_roam_req_valid)
  966. WMI_LOGD("%s : roam offload = %d",
  967. __func__,
  968. roam_req->roam_offload_enabled);
  969. else
  970. WMI_LOGD("%s : roam_req is NULL", __func__);
  971. len += (4 * WMI_TLV_HDR_SIZE);
  972. }
  973. if (roam_req->is_roam_req_valid &&
  974. roam_req->roam_offload_enabled) {
  975. roam_req->mode = roam_req->mode |
  976. WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
  977. }
  978. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  979. if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
  980. |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
  981. len = sizeof(wmi_roam_scan_mode_fixed_param);
  982. buf = wmi_buf_alloc(wmi_handle, len);
  983. if (!buf) {
  984. return QDF_STATUS_E_NOMEM;
  985. }
  986. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  987. roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
  988. WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
  989. WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
  990. WMITLV_GET_STRUCT_TLVLEN
  991. (wmi_roam_scan_mode_fixed_param));
  992. roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
  993. roam_req->roam_trigger_reason_bitmask;
  994. roam_scan_mode_fp->min_delay_btw_scans =
  995. WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
  996. roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
  997. roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
  998. if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
  999. WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
  1000. roam_scan_mode_fp->flags |=
  1001. WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
  1002. goto send_roam_scan_mode_cmd;
  1003. }
  1004. /* Fill in scan parameters suitable for roaming scan */
  1005. buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
  1006. qdf_mem_copy(buf_ptr, scan_cmd_fp,
  1007. sizeof(wmi_start_scan_cmd_fixed_param));
  1008. /* Ensure there is no additional IEs */
  1009. scan_cmd_fp->ie_len = 0;
  1010. WMITLV_SET_HDR(buf_ptr,
  1011. WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
  1012. WMITLV_GET_STRUCT_TLVLEN
  1013. (wmi_start_scan_cmd_fixed_param));
  1014. #ifdef WLAN_FEATURE_ROAM_OFFLOAD
  1015. buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
  1016. if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
  1017. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1018. sizeof(wmi_roam_offload_tlv_param));
  1019. buf_ptr += WMI_TLV_HDR_SIZE;
  1020. roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
  1021. WMITLV_SET_HDR(buf_ptr,
  1022. WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
  1023. WMITLV_GET_STRUCT_TLVLEN
  1024. (wmi_roam_offload_tlv_param));
  1025. roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
  1026. roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
  1027. roam_offload_params->select_5g_margin =
  1028. roam_req->select_5ghz_margin;
  1029. roam_offload_params->handoff_delay_for_rx =
  1030. req_offload_params->ho_delay_for_rx;
  1031. roam_offload_params->max_mlme_sw_retries =
  1032. req_offload_params->roam_preauth_retry_count;
  1033. roam_offload_params->no_ack_timeout =
  1034. req_offload_params->roam_preauth_no_ack_timeout;
  1035. roam_offload_params->reassoc_failure_timeout =
  1036. roam_req->reassoc_failure_timeout;
  1037. roam_offload_params->roam_candidate_validity_time =
  1038. roam_req->rct_validity_timer;
  1039. /* Fill the capabilities */
  1040. roam_offload_params->capability =
  1041. req_offload_params->capability;
  1042. roam_offload_params->ht_caps_info =
  1043. req_offload_params->ht_caps_info;
  1044. roam_offload_params->ampdu_param =
  1045. req_offload_params->ampdu_param;
  1046. roam_offload_params->ht_ext_cap =
  1047. req_offload_params->ht_ext_cap;
  1048. roam_offload_params->ht_txbf = req_offload_params->ht_txbf;
  1049. roam_offload_params->asel_cap = req_offload_params->asel_cap;
  1050. roam_offload_params->qos_caps = req_offload_params->qos_caps;
  1051. roam_offload_params->qos_enabled =
  1052. req_offload_params->qos_enabled;
  1053. roam_offload_params->wmm_caps = req_offload_params->wmm_caps;
  1054. qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
  1055. (uint8_t *)req_offload_params->mcsset,
  1056. ROAM_OFFLOAD_NUM_MCS_SET);
  1057. buf_ptr += sizeof(wmi_roam_offload_tlv_param);
  1058. /* The TLV's are in the order of 11i, 11R, ESE. Hence,
  1059. * they are filled in the same order.Depending on the
  1060. * authentication type, the other mode TLV's are nullified
  1061. * and only headers are filled.*/
  1062. if ((auth_mode != WMI_AUTH_NONE) &&
  1063. ((auth_mode != WMI_AUTH_OPEN) ||
  1064. (auth_mode == WMI_AUTH_OPEN
  1065. && roam_req->mdid.mdie_present &&
  1066. roam_req->is_11r_assoc) ||
  1067. roam_req->is_ese_assoc)) {
  1068. if (roam_req->is_ese_assoc) {
  1069. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1070. WMITLV_GET_STRUCT_TLVLEN(0));
  1071. buf_ptr += WMI_TLV_HDR_SIZE;
  1072. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1073. WMITLV_GET_STRUCT_TLVLEN(0));
  1074. buf_ptr += WMI_TLV_HDR_SIZE;
  1075. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1076. sizeof(wmi_roam_ese_offload_tlv_param));
  1077. buf_ptr += WMI_TLV_HDR_SIZE;
  1078. roam_offload_ese =
  1079. (wmi_roam_ese_offload_tlv_param *) buf_ptr;
  1080. qdf_mem_copy(roam_offload_ese->krk,
  1081. roam_req->krk,
  1082. sizeof(roam_req->krk));
  1083. qdf_mem_copy(roam_offload_ese->btk,
  1084. roam_req->btk,
  1085. sizeof(roam_req->btk));
  1086. WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
  1087. WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
  1088. WMITLV_GET_STRUCT_TLVLEN
  1089. (wmi_roam_ese_offload_tlv_param));
  1090. buf_ptr +=
  1091. sizeof(wmi_roam_ese_offload_tlv_param);
  1092. } else if (auth_mode == WMI_AUTH_FT_RSNA
  1093. || auth_mode == WMI_AUTH_FT_RSNA_PSK
  1094. || (auth_mode == WMI_AUTH_OPEN
  1095. && roam_req->mdid.mdie_present &&
  1096. roam_req->is_11r_assoc)) {
  1097. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1098. 0);
  1099. buf_ptr += WMI_TLV_HDR_SIZE;
  1100. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1101. sizeof(wmi_roam_11r_offload_tlv_param));
  1102. buf_ptr += WMI_TLV_HDR_SIZE;
  1103. roam_offload_11r =
  1104. (wmi_roam_11r_offload_tlv_param *) buf_ptr;
  1105. roam_offload_11r->r0kh_id_len =
  1106. roam_req->rokh_id_length;
  1107. qdf_mem_copy(roam_offload_11r->r0kh_id,
  1108. roam_req->rokh_id,
  1109. roam_offload_11r->r0kh_id_len);
  1110. qdf_mem_copy(roam_offload_11r->psk_msk,
  1111. roam_req->psk_pmk,
  1112. sizeof(roam_req->psk_pmk));
  1113. roam_offload_11r->psk_msk_len =
  1114. roam_req->pmk_len;
  1115. roam_offload_11r->mdie_present =
  1116. roam_req->mdid.mdie_present;
  1117. roam_offload_11r->mdid =
  1118. roam_req->mdid.mobility_domain;
  1119. if (auth_mode == WMI_AUTH_OPEN) {
  1120. /* If FT-Open ensure pmk length
  1121. and r0khid len are zero */
  1122. roam_offload_11r->r0kh_id_len = 0;
  1123. roam_offload_11r->psk_msk_len = 0;
  1124. }
  1125. WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
  1126. WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
  1127. WMITLV_GET_STRUCT_TLVLEN
  1128. (wmi_roam_11r_offload_tlv_param));
  1129. buf_ptr +=
  1130. sizeof(wmi_roam_11r_offload_tlv_param);
  1131. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1132. WMITLV_GET_STRUCT_TLVLEN(0));
  1133. buf_ptr += WMI_TLV_HDR_SIZE;
  1134. WMI_LOGD("psk_msk_len = %d",
  1135. roam_offload_11r->psk_msk_len);
  1136. if (roam_offload_11r->psk_msk_len)
  1137. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
  1138. QDF_TRACE_LEVEL_DEBUG,
  1139. roam_offload_11r->psk_msk,
  1140. roam_offload_11r->psk_msk_len);
  1141. } else {
  1142. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1143. sizeof(wmi_roam_11i_offload_tlv_param));
  1144. buf_ptr += WMI_TLV_HDR_SIZE;
  1145. roam_offload_11i =
  1146. (wmi_roam_11i_offload_tlv_param *) buf_ptr;
  1147. if (roam_req->roam_key_mgmt_offload_enabled &&
  1148. roam_req->fw_okc) {
  1149. WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
  1150. (roam_offload_11i->flags);
  1151. WMI_LOGI("LFR3:OKC enabled");
  1152. } else {
  1153. WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
  1154. (roam_offload_11i->flags);
  1155. WMI_LOGI("LFR3:OKC disabled");
  1156. }
  1157. if (roam_req->roam_key_mgmt_offload_enabled &&
  1158. roam_req->fw_pmksa_cache) {
  1159. WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
  1160. (roam_offload_11i->flags);
  1161. WMI_LOGI("LFR3:PMKSA caching enabled");
  1162. } else {
  1163. WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
  1164. (roam_offload_11i->flags);
  1165. WMI_LOGI("LFR3:PMKSA caching disabled");
  1166. }
  1167. qdf_mem_copy(roam_offload_11i->pmk,
  1168. roam_req->psk_pmk,
  1169. sizeof(roam_req->psk_pmk));
  1170. roam_offload_11i->pmk_len = roam_req->pmk_len;
  1171. WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
  1172. WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
  1173. WMITLV_GET_STRUCT_TLVLEN
  1174. (wmi_roam_11i_offload_tlv_param));
  1175. buf_ptr +=
  1176. sizeof(wmi_roam_11i_offload_tlv_param);
  1177. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1178. 0);
  1179. buf_ptr += WMI_TLV_HDR_SIZE;
  1180. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1181. 0);
  1182. buf_ptr += WMI_TLV_HDR_SIZE;
  1183. WMI_LOGD("pmk_len = %d",
  1184. roam_offload_11i->pmk_len);
  1185. if (roam_offload_11i->pmk_len)
  1186. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
  1187. QDF_TRACE_LEVEL_DEBUG,
  1188. roam_offload_11i->pmk,
  1189. roam_offload_11i->pmk_len);
  1190. }
  1191. } else {
  1192. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1193. WMITLV_GET_STRUCT_TLVLEN(0));
  1194. buf_ptr += WMI_TLV_HDR_SIZE;
  1195. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1196. WMITLV_GET_STRUCT_TLVLEN(0));
  1197. buf_ptr += WMI_TLV_HDR_SIZE;
  1198. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1199. WMITLV_GET_STRUCT_TLVLEN(0));
  1200. buf_ptr += WMI_TLV_HDR_SIZE;
  1201. }
  1202. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1203. sizeof(*assoc_ies));
  1204. buf_ptr += WMI_TLV_HDR_SIZE;
  1205. assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
  1206. WMITLV_SET_HDR(&assoc_ies->tlv_header,
  1207. WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
  1208. WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
  1209. assoc_ies->buf_len = roam_req->assoc_ie_length;
  1210. buf_ptr += sizeof(*assoc_ies);
  1211. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1212. roundup(assoc_ies->buf_len, sizeof(uint32_t)));
  1213. buf_ptr += WMI_TLV_HDR_SIZE;
  1214. if (assoc_ies->buf_len != 0) {
  1215. qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
  1216. assoc_ies->buf_len);
  1217. }
  1218. buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
  1219. buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
  1220. buf_ptr, fils_tlv_len);
  1221. } else {
  1222. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1223. WMITLV_GET_STRUCT_TLVLEN(0));
  1224. buf_ptr += WMI_TLV_HDR_SIZE;
  1225. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1226. WMITLV_GET_STRUCT_TLVLEN(0));
  1227. buf_ptr += WMI_TLV_HDR_SIZE;
  1228. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1229. WMITLV_GET_STRUCT_TLVLEN(0));
  1230. buf_ptr += WMI_TLV_HDR_SIZE;
  1231. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1232. WMITLV_GET_STRUCT_TLVLEN(0));
  1233. buf_ptr += WMI_TLV_HDR_SIZE;
  1234. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1235. WMITLV_GET_STRUCT_TLVLEN(0));
  1236. buf_ptr += WMI_TLV_HDR_SIZE;
  1237. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1238. WMITLV_GET_STRUCT_TLVLEN(0));
  1239. }
  1240. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  1241. send_roam_scan_mode_cmd:
  1242. wmi_mtrace(WMI_ROAM_SCAN_MODE, NO_SESSION, 0);
  1243. status = wmi_unified_cmd_send(wmi_handle, buf,
  1244. len, WMI_ROAM_SCAN_MODE);
  1245. if (QDF_IS_STATUS_ERROR(status)) {
  1246. WMI_LOGE(
  1247. "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
  1248. status);
  1249. wmi_buf_free(buf);
  1250. }
  1251. return status;
  1252. }
  1253. /**
  1254. * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
  1255. * @wmi_handle: wmi handle
  1256. * @ap_profile_p: ap profile
  1257. * @vdev_id: vdev id
  1258. *
  1259. * Send WMI_ROAM_AP_PROFILE to firmware
  1260. *
  1261. * Return: CDF status
  1262. */
  1263. static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
  1264. struct ap_profile_params *ap_profile)
  1265. {
  1266. wmi_buf_t buf = NULL;
  1267. QDF_STATUS status;
  1268. int len;
  1269. uint8_t *buf_ptr;
  1270. wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
  1271. wmi_roam_cnd_scoring_param *score_param;
  1272. wmi_ap_profile *profile;
  1273. len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
  1274. len += sizeof(*score_param);
  1275. buf = wmi_buf_alloc(wmi_handle, len);
  1276. if (!buf) {
  1277. return QDF_STATUS_E_NOMEM;
  1278. }
  1279. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1280. roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
  1281. WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
  1282. WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
  1283. WMITLV_GET_STRUCT_TLVLEN
  1284. (wmi_roam_ap_profile_fixed_param));
  1285. /* fill in threshold values */
  1286. roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
  1287. roam_ap_profile_fp->id = 0;
  1288. buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
  1289. profile = (wmi_ap_profile *)buf_ptr;
  1290. WMITLV_SET_HDR(&profile->tlv_header,
  1291. WMITLV_TAG_STRUC_wmi_ap_profile,
  1292. WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
  1293. profile->flags = ap_profile->profile.flags;
  1294. profile->rssi_threshold = ap_profile->profile.rssi_threshold;
  1295. profile->ssid.ssid_len = ap_profile->profile.ssid.length;
  1296. qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
  1297. profile->ssid.ssid_len);
  1298. profile->rsn_authmode = ap_profile->profile.rsn_authmode;
  1299. profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
  1300. profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
  1301. profile->rsn_mcastmgmtcipherset =
  1302. ap_profile->profile.rsn_mcastmgmtcipherset;
  1303. profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
  1304. 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",
  1305. profile->flags, profile->rssi_threshold,
  1306. profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
  1307. profile->rsn_authmode, profile->rsn_ucastcipherset,
  1308. profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
  1309. profile->rssi_abs_thresh);
  1310. buf_ptr += sizeof(wmi_ap_profile);
  1311. score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
  1312. WMITLV_SET_HDR(&score_param->tlv_header,
  1313. WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
  1314. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
  1315. score_param->disable_bitmap = ap_profile->param.disable_bitmap;
  1316. score_param->rssi_weightage_pcnt =
  1317. ap_profile->param.rssi_weightage;
  1318. score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
  1319. score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
  1320. score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
  1321. score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
  1322. score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
  1323. score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
  1324. score_param->esp_qbss_weightage_pcnt =
  1325. ap_profile->param.esp_qbss_weightage;
  1326. score_param->beamforming_weightage_pcnt =
  1327. ap_profile->param.beamforming_weightage;
  1328. score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
  1329. score_param->oce_wan_weightage_pcnt =
  1330. ap_profile->param.oce_wan_weightage;
  1331. 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",
  1332. score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
  1333. score_param->ht_weightage_pcnt,
  1334. score_param->vht_weightage_pcnt,
  1335. score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
  1336. score_param->band_weightage_pcnt,
  1337. score_param->nss_weightage_pcnt,
  1338. score_param->esp_qbss_weightage_pcnt,
  1339. score_param->beamforming_weightage_pcnt,
  1340. score_param->pcl_weightage_pcnt,
  1341. score_param->oce_wan_weightage_pcnt);
  1342. score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
  1343. score_param->band_scoring.score_pcnt =
  1344. ap_profile->param.band_index_score;
  1345. score_param->nss_scoring.score_pcnt =
  1346. ap_profile->param.nss_index_score;
  1347. WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
  1348. score_param->bw_scoring.score_pcnt,
  1349. score_param->band_scoring.score_pcnt,
  1350. score_param->nss_scoring.score_pcnt);
  1351. score_param->rssi_scoring.best_rssi_threshold =
  1352. (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
  1353. score_param->rssi_scoring.good_rssi_threshold =
  1354. (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
  1355. score_param->rssi_scoring.bad_rssi_threshold =
  1356. (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
  1357. score_param->rssi_scoring.good_rssi_pcnt =
  1358. ap_profile->param.rssi_scoring.good_rssi_pcnt;
  1359. score_param->rssi_scoring.bad_rssi_pcnt =
  1360. ap_profile->param.rssi_scoring.bad_rssi_pcnt;
  1361. score_param->rssi_scoring.good_bucket_size =
  1362. ap_profile->param.rssi_scoring.good_bucket_size;
  1363. score_param->rssi_scoring.bad_bucket_size =
  1364. ap_profile->param.rssi_scoring.bad_bucket_size;
  1365. score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
  1366. (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
  1367. WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
  1368. score_param->rssi_scoring.best_rssi_threshold,
  1369. score_param->rssi_scoring.good_rssi_threshold,
  1370. score_param->rssi_scoring.bad_rssi_threshold,
  1371. score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
  1372. WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
  1373. score_param->rssi_scoring.good_rssi_pcnt,
  1374. score_param->rssi_scoring.bad_rssi_pcnt,
  1375. score_param->rssi_scoring.good_bucket_size,
  1376. score_param->rssi_scoring.bad_bucket_size);
  1377. score_param->esp_qbss_scoring.num_slot =
  1378. ap_profile->param.esp_qbss_scoring.num_slot;
  1379. score_param->esp_qbss_scoring.score_pcnt3_to_0 =
  1380. ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
  1381. score_param->esp_qbss_scoring.score_pcnt7_to_4 =
  1382. ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
  1383. score_param->esp_qbss_scoring.score_pcnt11_to_8 =
  1384. ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
  1385. score_param->esp_qbss_scoring.score_pcnt15_to_12 =
  1386. ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
  1387. WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
  1388. score_param->esp_qbss_scoring.num_slot,
  1389. score_param->esp_qbss_scoring.score_pcnt3_to_0,
  1390. score_param->esp_qbss_scoring.score_pcnt7_to_4,
  1391. score_param->esp_qbss_scoring.score_pcnt11_to_8,
  1392. score_param->esp_qbss_scoring.score_pcnt15_to_12);
  1393. score_param->oce_wan_scoring.num_slot =
  1394. ap_profile->param.oce_wan_scoring.num_slot;
  1395. score_param->oce_wan_scoring.score_pcnt3_to_0 =
  1396. ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
  1397. score_param->oce_wan_scoring.score_pcnt7_to_4 =
  1398. ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
  1399. score_param->oce_wan_scoring.score_pcnt11_to_8 =
  1400. ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
  1401. score_param->oce_wan_scoring.score_pcnt15_to_12 =
  1402. ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
  1403. WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
  1404. score_param->oce_wan_scoring.num_slot,
  1405. score_param->oce_wan_scoring.score_pcnt3_to_0,
  1406. score_param->oce_wan_scoring.score_pcnt7_to_4,
  1407. score_param->oce_wan_scoring.score_pcnt11_to_8,
  1408. score_param->oce_wan_scoring.score_pcnt15_to_12);
  1409. score_param->roam_score_delta_pcnt = ap_profile->param.roam_score_delta;
  1410. score_param->roam_score_delta_mask =
  1411. ap_profile->param.roam_trigger_bitmap;
  1412. WMI_LOGD("Roam score delta:%d Roam_trigger_bitmap:%x",
  1413. score_param->roam_score_delta_pcnt,
  1414. score_param->roam_score_delta_mask);
  1415. wmi_mtrace(WMI_ROAM_AP_PROFILE, NO_SESSION, 0);
  1416. status = wmi_unified_cmd_send(wmi_handle, buf,
  1417. len, WMI_ROAM_AP_PROFILE);
  1418. if (QDF_IS_STATUS_ERROR(status)) {
  1419. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
  1420. status);
  1421. wmi_buf_free(buf);
  1422. }
  1423. WMI_LOGD("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
  1424. return status;
  1425. }
  1426. /**
  1427. * send_roam_scan_offload_cmd_tlv() - set roam offload command
  1428. * @wmi_handle: wmi handle
  1429. * @command: command
  1430. * @vdev_id: vdev id
  1431. *
  1432. * This function set roam offload command to fw.
  1433. *
  1434. * Return: CDF status
  1435. */
  1436. static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
  1437. uint32_t command, uint32_t vdev_id)
  1438. {
  1439. QDF_STATUS status;
  1440. wmi_roam_scan_cmd_fixed_param *cmd_fp;
  1441. wmi_buf_t buf = NULL;
  1442. int len;
  1443. uint8_t *buf_ptr;
  1444. len = sizeof(wmi_roam_scan_cmd_fixed_param);
  1445. buf = wmi_buf_alloc(wmi_handle, len);
  1446. if (!buf) {
  1447. return QDF_STATUS_E_NOMEM;
  1448. }
  1449. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1450. cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
  1451. WMITLV_SET_HDR(&cmd_fp->tlv_header,
  1452. WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
  1453. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
  1454. cmd_fp->vdev_id = vdev_id;
  1455. cmd_fp->command_arg = command;
  1456. wmi_mtrace(WMI_ROAM_SCAN_CMD, NO_SESSION, 0);
  1457. status = wmi_unified_cmd_send(wmi_handle, buf,
  1458. len, WMI_ROAM_SCAN_CMD);
  1459. if (QDF_IS_STATUS_ERROR(status)) {
  1460. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
  1461. status);
  1462. goto error;
  1463. }
  1464. WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
  1465. return QDF_STATUS_SUCCESS;
  1466. error:
  1467. wmi_buf_free(buf);
  1468. return status;
  1469. }
  1470. /**
  1471. * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
  1472. * @wmi_handle: wmi handle
  1473. * @scan_period: scan period
  1474. * @scan_age: scan age
  1475. * @vdev_id: vdev id
  1476. *
  1477. * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
  1478. *
  1479. * Return: CDF status
  1480. */
  1481. static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
  1482. uint32_t scan_period,
  1483. uint32_t scan_age,
  1484. uint32_t vdev_id)
  1485. {
  1486. QDF_STATUS status;
  1487. wmi_buf_t buf = NULL;
  1488. int len;
  1489. uint8_t *buf_ptr;
  1490. wmi_roam_scan_period_fixed_param *scan_period_fp;
  1491. /* Send scan period values */
  1492. len = sizeof(wmi_roam_scan_period_fixed_param);
  1493. buf = wmi_buf_alloc(wmi_handle, len);
  1494. if (!buf) {
  1495. return QDF_STATUS_E_NOMEM;
  1496. }
  1497. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1498. scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
  1499. WMITLV_SET_HDR(&scan_period_fp->tlv_header,
  1500. WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
  1501. WMITLV_GET_STRUCT_TLVLEN
  1502. (wmi_roam_scan_period_fixed_param));
  1503. /* fill in scan period values */
  1504. scan_period_fp->vdev_id = vdev_id;
  1505. scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
  1506. scan_period_fp->roam_scan_age = scan_age;
  1507. wmi_mtrace(WMI_ROAM_SCAN_PERIOD, NO_SESSION, 0);
  1508. status = wmi_unified_cmd_send(wmi_handle, buf,
  1509. len, WMI_ROAM_SCAN_PERIOD);
  1510. if (QDF_IS_STATUS_ERROR(status)) {
  1511. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
  1512. status);
  1513. goto error;
  1514. }
  1515. WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
  1516. __func__, scan_period, scan_age);
  1517. return QDF_STATUS_SUCCESS;
  1518. error:
  1519. wmi_buf_free(buf);
  1520. return status;
  1521. }
  1522. /**
  1523. * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
  1524. * @wmi_handle: wmi handle
  1525. * @chan_count: channel count
  1526. * @chan_list: channel list
  1527. * @list_type: list type
  1528. * @vdev_id: vdev id
  1529. *
  1530. * Set roam offload channel list.
  1531. *
  1532. * Return: CDF status
  1533. */
  1534. static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
  1535. uint8_t chan_count,
  1536. uint32_t *chan_list,
  1537. uint8_t list_type, uint32_t vdev_id)
  1538. {
  1539. wmi_buf_t buf = NULL;
  1540. QDF_STATUS status;
  1541. int len, list_tlv_len;
  1542. int i;
  1543. uint8_t *buf_ptr;
  1544. wmi_roam_chan_list_fixed_param *chan_list_fp;
  1545. uint32_t *roam_chan_list_array;
  1546. if (chan_count == 0) {
  1547. WMI_LOGD("%s : invalid number of channels %d", __func__,
  1548. chan_count);
  1549. return QDF_STATUS_E_EMPTY;
  1550. }
  1551. /* Channel list is a table of 2 TLV's */
  1552. list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
  1553. len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
  1554. buf = wmi_buf_alloc(wmi_handle, len);
  1555. if (!buf) {
  1556. return QDF_STATUS_E_NOMEM;
  1557. }
  1558. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1559. chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
  1560. WMITLV_SET_HDR(&chan_list_fp->tlv_header,
  1561. WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
  1562. WMITLV_GET_STRUCT_TLVLEN
  1563. (wmi_roam_chan_list_fixed_param));
  1564. chan_list_fp->vdev_id = vdev_id;
  1565. chan_list_fp->num_chan = chan_count;
  1566. if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
  1567. /* external app is controlling channel list */
  1568. chan_list_fp->chan_list_type =
  1569. WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
  1570. } else {
  1571. /* umac supplied occupied channel list in LFR */
  1572. chan_list_fp->chan_list_type =
  1573. WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
  1574. }
  1575. buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
  1576. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  1577. (chan_list_fp->num_chan * sizeof(uint32_t)));
  1578. roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
  1579. WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
  1580. for (i = 0; ((i < chan_list_fp->num_chan) &&
  1581. (i < WMI_ROAM_MAX_CHANNELS)); i++) {
  1582. roam_chan_list_array[i] = chan_list[i];
  1583. WMI_LOGD("%d,", roam_chan_list_array[i]);
  1584. }
  1585. wmi_mtrace(WMI_ROAM_CHAN_LIST, NO_SESSION, 0);
  1586. status = wmi_unified_cmd_send(wmi_handle, buf,
  1587. len, WMI_ROAM_CHAN_LIST);
  1588. if (QDF_IS_STATUS_ERROR(status)) {
  1589. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
  1590. status);
  1591. goto error;
  1592. }
  1593. WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
  1594. return QDF_STATUS_SUCCESS;
  1595. error:
  1596. wmi_buf_free(buf);
  1597. return status;
  1598. }
  1599. /**
  1600. * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
  1601. * @wmi_handle: wmi handle
  1602. * @rssi_change_thresh: RSSI Change threshold
  1603. * @bcn_rssi_weight: beacon RSSI weight
  1604. * @vdev_id: vdev id
  1605. *
  1606. * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
  1607. *
  1608. * Return: CDF status
  1609. */
  1610. static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
  1611. uint32_t vdev_id,
  1612. int32_t rssi_change_thresh,
  1613. uint32_t bcn_rssi_weight,
  1614. uint32_t hirssi_delay_btw_scans)
  1615. {
  1616. wmi_buf_t buf = NULL;
  1617. QDF_STATUS status;
  1618. int len;
  1619. uint8_t *buf_ptr;
  1620. wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
  1621. /* Send rssi change parameters */
  1622. len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
  1623. buf = wmi_buf_alloc(wmi_handle, len);
  1624. if (!buf) {
  1625. return QDF_STATUS_E_NOMEM;
  1626. }
  1627. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1628. rssi_change_fp =
  1629. (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
  1630. WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
  1631. WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
  1632. WMITLV_GET_STRUCT_TLVLEN
  1633. (wmi_roam_scan_rssi_change_threshold_fixed_param));
  1634. /* fill in rssi change threshold (hysteresis) values */
  1635. rssi_change_fp->vdev_id = vdev_id;
  1636. rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
  1637. rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
  1638. rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
  1639. wmi_mtrace(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, NO_SESSION, 0);
  1640. status = wmi_unified_cmd_send(wmi_handle, buf,
  1641. len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
  1642. if (QDF_IS_STATUS_ERROR(status)) {
  1643. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
  1644. status);
  1645. goto error;
  1646. }
  1647. WMI_LOGD(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
  1648. rssi_change_thresh, bcn_rssi_weight);
  1649. WMI_LOGD(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
  1650. return QDF_STATUS_SUCCESS;
  1651. error:
  1652. wmi_buf_free(buf);
  1653. return status;
  1654. }
  1655. /**
  1656. * send_per_roam_config_cmd_tlv() - set per roaming config to FW
  1657. * @wmi_handle: wmi handle
  1658. * @req_buf: per roam config buffer
  1659. *
  1660. * Return: QDF status
  1661. */
  1662. static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
  1663. struct wmi_per_roam_config_req *req_buf)
  1664. {
  1665. wmi_buf_t buf = NULL;
  1666. QDF_STATUS status;
  1667. int len;
  1668. uint8_t *buf_ptr;
  1669. wmi_roam_per_config_fixed_param *wmi_per_config;
  1670. len = sizeof(wmi_roam_per_config_fixed_param);
  1671. buf = wmi_buf_alloc(wmi_handle, len);
  1672. if (!buf) {
  1673. return QDF_STATUS_E_NOMEM;
  1674. }
  1675. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1676. wmi_per_config =
  1677. (wmi_roam_per_config_fixed_param *) buf_ptr;
  1678. WMITLV_SET_HDR(&wmi_per_config->tlv_header,
  1679. WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
  1680. WMITLV_GET_STRUCT_TLVLEN
  1681. (wmi_roam_per_config_fixed_param));
  1682. /* fill in per roam config values */
  1683. wmi_per_config->vdev_id = req_buf->vdev_id;
  1684. wmi_per_config->enable = req_buf->per_config.enable;
  1685. wmi_per_config->high_rate_thresh =
  1686. (req_buf->per_config.tx_high_rate_thresh << 16) |
  1687. (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
  1688. wmi_per_config->low_rate_thresh =
  1689. (req_buf->per_config.tx_low_rate_thresh << 16) |
  1690. (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
  1691. wmi_per_config->pkt_err_rate_thresh_pct =
  1692. (req_buf->per_config.tx_rate_thresh_percnt << 16) |
  1693. (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
  1694. wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
  1695. wmi_per_config->pkt_err_rate_mon_time =
  1696. (req_buf->per_config.tx_per_mon_time << 16) |
  1697. (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
  1698. wmi_per_config->min_candidate_rssi =
  1699. req_buf->per_config.min_candidate_rssi;
  1700. /* Send per roam config parameters */
  1701. wmi_mtrace(WMI_ROAM_PER_CONFIG_CMDID, NO_SESSION, 0);
  1702. status = wmi_unified_cmd_send(wmi_handle, buf,
  1703. len, WMI_ROAM_PER_CONFIG_CMDID);
  1704. if (QDF_IS_STATUS_ERROR(status)) {
  1705. WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
  1706. status);
  1707. wmi_buf_free(buf);
  1708. return status;
  1709. }
  1710. WMI_LOGD(FL("per roam enable=%d, vdev=%d"),
  1711. req_buf->per_config.enable, req_buf->vdev_id);
  1712. return QDF_STATUS_SUCCESS;
  1713. }
  1714. /**
  1715. * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
  1716. * configuration params
  1717. * @wmi_handle: wmi handler
  1718. * @limit_off_chan_param: pointer to wmi_off_chan_param
  1719. *
  1720. * Return: 0 for success and non zero for failure
  1721. */
  1722. static
  1723. QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
  1724. struct wmi_limit_off_chan_param *limit_off_chan_param)
  1725. {
  1726. wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
  1727. wmi_buf_t buf;
  1728. uint32_t len = sizeof(*cmd);
  1729. int err;
  1730. buf = wmi_buf_alloc(wmi_handle, len);
  1731. if (!buf) {
  1732. return QDF_STATUS_E_NOMEM;
  1733. }
  1734. cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
  1735. WMITLV_SET_HDR(&cmd->tlv_header,
  1736. WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
  1737. WMITLV_GET_STRUCT_TLVLEN(
  1738. wmi_vdev_limit_offchan_cmd_fixed_param));
  1739. cmd->vdev_id = limit_off_chan_param->vdev_id;
  1740. cmd->flags &= 0;
  1741. if (limit_off_chan_param->status)
  1742. cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
  1743. if (limit_off_chan_param->skip_dfs_chans)
  1744. cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
  1745. cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
  1746. cmd->rest_time = limit_off_chan_param->rest_time;
  1747. WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
  1748. __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
  1749. cmd->rest_time);
  1750. wmi_mtrace(WMI_VDEV_LIMIT_OFFCHAN_CMDID, cmd->vdev_id, 0);
  1751. err = wmi_unified_cmd_send(wmi_handle, buf,
  1752. len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
  1753. if (QDF_IS_STATUS_ERROR(err)) {
  1754. WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
  1755. wmi_buf_free(buf);
  1756. return QDF_STATUS_E_FAILURE;
  1757. }
  1758. return QDF_STATUS_SUCCESS;
  1759. }
  1760. #ifdef WLAN_FEATURE_FILS_SK
  1761. static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
  1762. struct hlp_params *params)
  1763. {
  1764. uint32_t len;
  1765. uint8_t *buf_ptr;
  1766. wmi_buf_t buf = NULL;
  1767. wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
  1768. len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
  1769. len += WMI_TLV_HDR_SIZE;
  1770. len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
  1771. buf = wmi_buf_alloc(wmi_handle, len);
  1772. if (!buf) {
  1773. return QDF_STATUS_E_NOMEM;
  1774. }
  1775. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1776. hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
  1777. WMITLV_SET_HDR(&hlp_params->tlv_header,
  1778. WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
  1779. WMITLV_GET_STRUCT_TLVLEN(
  1780. wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
  1781. hlp_params->vdev_id = params->vdev_id;
  1782. hlp_params->size = params->hlp_ie_len;
  1783. hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
  1784. buf_ptr += sizeof(*hlp_params);
  1785. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1786. round_up(params->hlp_ie_len,
  1787. sizeof(uint32_t)));
  1788. buf_ptr += WMI_TLV_HDR_SIZE;
  1789. qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
  1790. WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
  1791. hlp_params->vdev_id, hlp_params->size);
  1792. wmi_mtrace(WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID, NO_SESSION, 0);
  1793. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1794. WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
  1795. WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
  1796. wmi_buf_free(buf);
  1797. return QDF_STATUS_E_FAILURE;
  1798. }
  1799. return QDF_STATUS_SUCCESS;
  1800. }
  1801. void wmi_fils_sk_attach_tlv(wmi_unified_t wmi_handle)
  1802. {
  1803. struct wmi_ops *ops = wmi_handle->ops;
  1804. ops->send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv;
  1805. }
  1806. #endif /* WLAN_FEATURE_FILS_SK */
  1807. /*
  1808. * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
  1809. * @wmi_handle: wmi handle
  1810. * @params: pointer to wmi_btm_config
  1811. *
  1812. * Return: QDF_STATUS
  1813. */
  1814. static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
  1815. struct wmi_btm_config *params)
  1816. {
  1817. wmi_btm_config_fixed_param *cmd;
  1818. wmi_buf_t buf;
  1819. uint32_t len;
  1820. len = sizeof(*cmd);
  1821. buf = wmi_buf_alloc(wmi_handle, len);
  1822. if (!buf) {
  1823. return QDF_STATUS_E_NOMEM;
  1824. }
  1825. cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
  1826. WMITLV_SET_HDR(&cmd->tlv_header,
  1827. WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
  1828. WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
  1829. cmd->vdev_id = params->vdev_id;
  1830. cmd->flags = params->btm_offload_config;
  1831. cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
  1832. cmd->solicited_timeout_ms = params->btm_solicited_timeout;
  1833. cmd->stick_time_seconds = params->btm_sticky_time;
  1834. cmd->disassoc_timer_threshold = params->disassoc_timer_threshold;
  1835. wmi_mtrace(WMI_ROAM_BTM_CONFIG_CMDID, cmd->vdev_id, 0);
  1836. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1837. WMI_ROAM_BTM_CONFIG_CMDID)) {
  1838. WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
  1839. __func__);
  1840. wmi_buf_free(buf);
  1841. return QDF_STATUS_E_FAILURE;
  1842. }
  1843. return QDF_STATUS_SUCCESS;
  1844. }
  1845. /**
  1846. * send_roam_bss_load_config_tlv() - send roam load bss trigger configuration
  1847. * @wmi_handle: wmi handle
  1848. * @parms: pointer to wmi_bss_load_config
  1849. *
  1850. * This function sends the roam load bss trigger configuration to fw.
  1851. * the bss_load_threshold parameter is used to configure the maximum
  1852. * bss load percentage, above which the firmware should trigger roaming
  1853. *
  1854. * Return: QDF status
  1855. */
  1856. static QDF_STATUS
  1857. send_roam_bss_load_config_tlv(wmi_unified_t wmi_handle,
  1858. struct wmi_bss_load_config *params)
  1859. {
  1860. wmi_roam_bss_load_config_cmd_fixed_param *cmd;
  1861. wmi_buf_t buf;
  1862. uint32_t len;
  1863. len = sizeof(*cmd);
  1864. buf = wmi_buf_alloc(wmi_handle, len);
  1865. if (!buf)
  1866. return QDF_STATUS_E_NOMEM;
  1867. cmd = (wmi_roam_bss_load_config_cmd_fixed_param *)wmi_buf_data(buf);
  1868. WMITLV_SET_HDR(
  1869. &cmd->tlv_header,
  1870. WMITLV_TAG_STRUC_wmi_roam_bss_load_config_cmd_fixed_param,
  1871. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_bss_load_config_cmd_fixed_param));
  1872. cmd->vdev_id = params->vdev_id;
  1873. cmd->bss_load_threshold = params->bss_load_threshold;
  1874. cmd->monitor_time_window = params->bss_load_sample_time;
  1875. wmi_mtrace(WMI_ROAM_BSS_LOAD_CONFIG_CMDID, cmd->vdev_id, 0);
  1876. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1877. WMI_ROAM_BSS_LOAD_CONFIG_CMDID)) {
  1878. WMI_LOGE("%s: failed to send WMI_ROAM_BSS_LOAD_CONFIG_CMDID ",
  1879. __func__);
  1880. wmi_buf_free(buf);
  1881. return QDF_STATUS_E_FAILURE;
  1882. }
  1883. return QDF_STATUS_SUCCESS;
  1884. }
  1885. /**
  1886. * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
  1887. * @wmi_handle: wmi handler
  1888. * @params: pointer to 11k offload params
  1889. *
  1890. * Return: 0 for success and non zero for failure
  1891. */
  1892. static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
  1893. struct wmi_11k_offload_params *params)
  1894. {
  1895. wmi_11k_offload_report_fixed_param *cmd;
  1896. wmi_buf_t buf;
  1897. QDF_STATUS status;
  1898. uint8_t *buf_ptr;
  1899. wmi_neighbor_report_11k_offload_tlv_param
  1900. *neighbor_report_offload_params;
  1901. wmi_neighbor_report_offload *neighbor_report_offload;
  1902. uint32_t len = sizeof(*cmd);
  1903. if (params->offload_11k_bitmask &
  1904. WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
  1905. len += WMI_TLV_HDR_SIZE +
  1906. sizeof(wmi_neighbor_report_11k_offload_tlv_param);
  1907. buf = wmi_buf_alloc(wmi_handle, len);
  1908. if (!buf) {
  1909. return QDF_STATUS_E_NOMEM;
  1910. }
  1911. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1912. cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
  1913. WMITLV_SET_HDR(&cmd->tlv_header,
  1914. WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
  1915. WMITLV_GET_STRUCT_TLVLEN(
  1916. wmi_11k_offload_report_fixed_param));
  1917. cmd->vdev_id = params->vdev_id;
  1918. cmd->offload_11k = params->offload_11k_bitmask;
  1919. if (params->offload_11k_bitmask &
  1920. WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
  1921. buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
  1922. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1923. sizeof(wmi_neighbor_report_11k_offload_tlv_param));
  1924. buf_ptr += WMI_TLV_HDR_SIZE;
  1925. neighbor_report_offload_params =
  1926. (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
  1927. WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
  1928. WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
  1929. WMITLV_GET_STRUCT_TLVLEN(
  1930. wmi_neighbor_report_11k_offload_tlv_param));
  1931. neighbor_report_offload = &neighbor_report_offload_params->
  1932. neighbor_rep_ofld_params;
  1933. neighbor_report_offload->time_offset =
  1934. params->neighbor_report_params.time_offset;
  1935. neighbor_report_offload->low_rssi_offset =
  1936. params->neighbor_report_params.low_rssi_offset;
  1937. neighbor_report_offload->bmiss_count_trigger =
  1938. params->neighbor_report_params.bmiss_count_trigger;
  1939. neighbor_report_offload->per_threshold_offset =
  1940. params->neighbor_report_params.per_threshold_offset;
  1941. neighbor_report_offload->neighbor_report_cache_timeout =
  1942. params->neighbor_report_params.
  1943. neighbor_report_cache_timeout;
  1944. neighbor_report_offload->max_neighbor_report_req_cap =
  1945. params->neighbor_report_params.
  1946. max_neighbor_report_req_cap;
  1947. neighbor_report_offload->ssid.ssid_len =
  1948. params->neighbor_report_params.ssid.length;
  1949. qdf_mem_copy(neighbor_report_offload->ssid.ssid,
  1950. &params->neighbor_report_params.ssid.mac_ssid,
  1951. neighbor_report_offload->ssid.ssid_len);
  1952. }
  1953. wmi_mtrace(WMI_11K_OFFLOAD_REPORT_CMDID, cmd->vdev_id, 0);
  1954. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  1955. WMI_11K_OFFLOAD_REPORT_CMDID);
  1956. if (status != QDF_STATUS_SUCCESS) {
  1957. WMI_LOGE("%s: failed to send 11k offload command %d",
  1958. __func__, status);
  1959. wmi_buf_free(buf);
  1960. }
  1961. return status;
  1962. }
  1963. /**
  1964. * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
  1965. * command
  1966. * @wmi_handle: wmi handler
  1967. * @params: pointer to neighbor report invoke params
  1968. *
  1969. * Return: 0 for success and non zero for failure
  1970. */
  1971. static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
  1972. struct wmi_invoke_neighbor_report_params *params)
  1973. {
  1974. wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
  1975. wmi_buf_t buf;
  1976. QDF_STATUS status;
  1977. uint8_t *buf_ptr;
  1978. uint32_t len = sizeof(*cmd);
  1979. buf = wmi_buf_alloc(wmi_handle, len);
  1980. if (!buf) {
  1981. return QDF_STATUS_E_NOMEM;
  1982. }
  1983. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1984. cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
  1985. WMITLV_SET_HDR(&cmd->tlv_header,
  1986. WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
  1987. WMITLV_GET_STRUCT_TLVLEN(
  1988. wmi_11k_offload_invoke_neighbor_report_fixed_param));
  1989. cmd->vdev_id = params->vdev_id;
  1990. cmd->flags = params->send_resp_to_host;
  1991. cmd->ssid.ssid_len = params->ssid.length;
  1992. qdf_mem_copy(cmd->ssid.ssid,
  1993. &params->ssid.mac_ssid,
  1994. cmd->ssid.ssid_len);
  1995. wmi_mtrace(WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID, cmd->vdev_id, 0);
  1996. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  1997. WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
  1998. if (status != QDF_STATUS_SUCCESS) {
  1999. WMI_LOGE("%s: failed to send invoke neighbor report command %d",
  2000. __func__, status);
  2001. wmi_buf_free(buf);
  2002. }
  2003. return status;
  2004. }
  2005. void wmi_roam_attach_tlv(wmi_unified_t wmi_handle)
  2006. {
  2007. struct wmi_ops *ops = wmi_handle->ops;
  2008. ops->send_roam_scan_offload_rssi_thresh_cmd =
  2009. send_roam_scan_offload_rssi_thresh_cmd_tlv;
  2010. ops->send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv;
  2011. ops->send_roam_scan_filter_cmd =
  2012. send_roam_scan_filter_cmd_tlv;
  2013. ops->send_roam_scan_offload_mode_cmd =
  2014. send_roam_scan_offload_mode_cmd_tlv;
  2015. ops->send_roam_scan_offload_ap_profile_cmd =
  2016. send_roam_scan_offload_ap_profile_cmd_tlv;
  2017. ops->send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv;
  2018. ops->send_roam_scan_offload_scan_period_cmd =
  2019. send_roam_scan_offload_scan_period_cmd_tlv;
  2020. ops->send_roam_scan_offload_chan_list_cmd =
  2021. send_roam_scan_offload_chan_list_cmd_tlv;
  2022. ops->send_roam_scan_offload_rssi_change_cmd =
  2023. send_roam_scan_offload_rssi_change_cmd_tlv;
  2024. ops->send_per_roam_config_cmd = send_per_roam_config_cmd_tlv;
  2025. ops->send_limit_off_chan_cmd = send_limit_off_chan_cmd_tlv;
  2026. ops->send_btm_config = send_btm_config_cmd_tlv;
  2027. ops->send_offload_11k_cmd = send_offload_11k_cmd_tlv;
  2028. ops->send_invoke_neighbor_report_cmd =
  2029. send_invoke_neighbor_report_cmd_tlv;
  2030. ops->send_roam_bss_load_config = send_roam_bss_load_config_tlv;
  2031. wmi_lfr_subnet_detection_attach_tlv(wmi_handle);
  2032. wmi_rssi_monitor_attach_tlv(wmi_handle);
  2033. wmi_ese_attach_tlv(wmi_handle);
  2034. wmi_roam_offload_attach_tlv(wmi_handle);
  2035. wmi_fils_sk_attach_tlv(wmi_handle);
  2036. }