wmi_unified_roam_tlv.c 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273
  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. wmi_mtrace(WMI_ROAM_AP_PROFILE, NO_SESSION, 0);
  1410. status = wmi_unified_cmd_send(wmi_handle, buf,
  1411. len, WMI_ROAM_AP_PROFILE);
  1412. if (QDF_IS_STATUS_ERROR(status)) {
  1413. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
  1414. status);
  1415. wmi_buf_free(buf);
  1416. }
  1417. WMI_LOGD("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
  1418. return status;
  1419. }
  1420. /**
  1421. * send_roam_scan_offload_cmd_tlv() - set roam offload command
  1422. * @wmi_handle: wmi handle
  1423. * @command: command
  1424. * @vdev_id: vdev id
  1425. *
  1426. * This function set roam offload command to fw.
  1427. *
  1428. * Return: CDF status
  1429. */
  1430. static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
  1431. uint32_t command, uint32_t vdev_id)
  1432. {
  1433. QDF_STATUS status;
  1434. wmi_roam_scan_cmd_fixed_param *cmd_fp;
  1435. wmi_buf_t buf = NULL;
  1436. int len;
  1437. uint8_t *buf_ptr;
  1438. len = sizeof(wmi_roam_scan_cmd_fixed_param);
  1439. buf = wmi_buf_alloc(wmi_handle, len);
  1440. if (!buf) {
  1441. return QDF_STATUS_E_NOMEM;
  1442. }
  1443. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1444. cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
  1445. WMITLV_SET_HDR(&cmd_fp->tlv_header,
  1446. WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
  1447. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
  1448. cmd_fp->vdev_id = vdev_id;
  1449. cmd_fp->command_arg = command;
  1450. wmi_mtrace(WMI_ROAM_SCAN_CMD, NO_SESSION, 0);
  1451. status = wmi_unified_cmd_send(wmi_handle, buf,
  1452. len, WMI_ROAM_SCAN_CMD);
  1453. if (QDF_IS_STATUS_ERROR(status)) {
  1454. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
  1455. status);
  1456. goto error;
  1457. }
  1458. WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
  1459. return QDF_STATUS_SUCCESS;
  1460. error:
  1461. wmi_buf_free(buf);
  1462. return status;
  1463. }
  1464. /**
  1465. * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
  1466. * @wmi_handle: wmi handle
  1467. * @scan_period: scan period
  1468. * @scan_age: scan age
  1469. * @vdev_id: vdev id
  1470. *
  1471. * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
  1472. *
  1473. * Return: CDF status
  1474. */
  1475. static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
  1476. uint32_t scan_period,
  1477. uint32_t scan_age,
  1478. uint32_t vdev_id)
  1479. {
  1480. QDF_STATUS status;
  1481. wmi_buf_t buf = NULL;
  1482. int len;
  1483. uint8_t *buf_ptr;
  1484. wmi_roam_scan_period_fixed_param *scan_period_fp;
  1485. /* Send scan period values */
  1486. len = sizeof(wmi_roam_scan_period_fixed_param);
  1487. buf = wmi_buf_alloc(wmi_handle, len);
  1488. if (!buf) {
  1489. return QDF_STATUS_E_NOMEM;
  1490. }
  1491. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1492. scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
  1493. WMITLV_SET_HDR(&scan_period_fp->tlv_header,
  1494. WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
  1495. WMITLV_GET_STRUCT_TLVLEN
  1496. (wmi_roam_scan_period_fixed_param));
  1497. /* fill in scan period values */
  1498. scan_period_fp->vdev_id = vdev_id;
  1499. scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
  1500. scan_period_fp->roam_scan_age = scan_age;
  1501. wmi_mtrace(WMI_ROAM_SCAN_PERIOD, NO_SESSION, 0);
  1502. status = wmi_unified_cmd_send(wmi_handle, buf,
  1503. len, WMI_ROAM_SCAN_PERIOD);
  1504. if (QDF_IS_STATUS_ERROR(status)) {
  1505. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
  1506. status);
  1507. goto error;
  1508. }
  1509. WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
  1510. __func__, scan_period, scan_age);
  1511. return QDF_STATUS_SUCCESS;
  1512. error:
  1513. wmi_buf_free(buf);
  1514. return status;
  1515. }
  1516. /**
  1517. * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
  1518. * @wmi_handle: wmi handle
  1519. * @chan_count: channel count
  1520. * @chan_list: channel list
  1521. * @list_type: list type
  1522. * @vdev_id: vdev id
  1523. *
  1524. * Set roam offload channel list.
  1525. *
  1526. * Return: CDF status
  1527. */
  1528. static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
  1529. uint8_t chan_count,
  1530. uint32_t *chan_list,
  1531. uint8_t list_type, uint32_t vdev_id)
  1532. {
  1533. wmi_buf_t buf = NULL;
  1534. QDF_STATUS status;
  1535. int len, list_tlv_len;
  1536. int i;
  1537. uint8_t *buf_ptr;
  1538. wmi_roam_chan_list_fixed_param *chan_list_fp;
  1539. uint32_t *roam_chan_list_array;
  1540. if (chan_count == 0) {
  1541. WMI_LOGD("%s : invalid number of channels %d", __func__,
  1542. chan_count);
  1543. return QDF_STATUS_E_EMPTY;
  1544. }
  1545. /* Channel list is a table of 2 TLV's */
  1546. list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
  1547. len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
  1548. buf = wmi_buf_alloc(wmi_handle, len);
  1549. if (!buf) {
  1550. return QDF_STATUS_E_NOMEM;
  1551. }
  1552. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1553. chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
  1554. WMITLV_SET_HDR(&chan_list_fp->tlv_header,
  1555. WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
  1556. WMITLV_GET_STRUCT_TLVLEN
  1557. (wmi_roam_chan_list_fixed_param));
  1558. chan_list_fp->vdev_id = vdev_id;
  1559. chan_list_fp->num_chan = chan_count;
  1560. if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
  1561. /* external app is controlling channel list */
  1562. chan_list_fp->chan_list_type =
  1563. WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
  1564. } else {
  1565. /* umac supplied occupied channel list in LFR */
  1566. chan_list_fp->chan_list_type =
  1567. WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
  1568. }
  1569. buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
  1570. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  1571. (chan_list_fp->num_chan * sizeof(uint32_t)));
  1572. roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
  1573. WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
  1574. for (i = 0; ((i < chan_list_fp->num_chan) &&
  1575. (i < WMI_ROAM_MAX_CHANNELS)); i++) {
  1576. roam_chan_list_array[i] = chan_list[i];
  1577. WMI_LOGD("%d,", roam_chan_list_array[i]);
  1578. }
  1579. wmi_mtrace(WMI_ROAM_CHAN_LIST, NO_SESSION, 0);
  1580. status = wmi_unified_cmd_send(wmi_handle, buf,
  1581. len, WMI_ROAM_CHAN_LIST);
  1582. if (QDF_IS_STATUS_ERROR(status)) {
  1583. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
  1584. status);
  1585. goto error;
  1586. }
  1587. WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
  1588. return QDF_STATUS_SUCCESS;
  1589. error:
  1590. wmi_buf_free(buf);
  1591. return status;
  1592. }
  1593. /**
  1594. * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
  1595. * @wmi_handle: wmi handle
  1596. * @rssi_change_thresh: RSSI Change threshold
  1597. * @bcn_rssi_weight: beacon RSSI weight
  1598. * @vdev_id: vdev id
  1599. *
  1600. * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
  1601. *
  1602. * Return: CDF status
  1603. */
  1604. static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
  1605. uint32_t vdev_id,
  1606. int32_t rssi_change_thresh,
  1607. uint32_t bcn_rssi_weight,
  1608. uint32_t hirssi_delay_btw_scans)
  1609. {
  1610. wmi_buf_t buf = NULL;
  1611. QDF_STATUS status;
  1612. int len;
  1613. uint8_t *buf_ptr;
  1614. wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
  1615. /* Send rssi change parameters */
  1616. len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
  1617. buf = wmi_buf_alloc(wmi_handle, len);
  1618. if (!buf) {
  1619. return QDF_STATUS_E_NOMEM;
  1620. }
  1621. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1622. rssi_change_fp =
  1623. (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
  1624. WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
  1625. WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
  1626. WMITLV_GET_STRUCT_TLVLEN
  1627. (wmi_roam_scan_rssi_change_threshold_fixed_param));
  1628. /* fill in rssi change threshold (hysteresis) values */
  1629. rssi_change_fp->vdev_id = vdev_id;
  1630. rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
  1631. rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
  1632. rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
  1633. wmi_mtrace(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, NO_SESSION, 0);
  1634. status = wmi_unified_cmd_send(wmi_handle, buf,
  1635. len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
  1636. if (QDF_IS_STATUS_ERROR(status)) {
  1637. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
  1638. status);
  1639. goto error;
  1640. }
  1641. WMI_LOGD(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
  1642. rssi_change_thresh, bcn_rssi_weight);
  1643. WMI_LOGD(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
  1644. return QDF_STATUS_SUCCESS;
  1645. error:
  1646. wmi_buf_free(buf);
  1647. return status;
  1648. }
  1649. /**
  1650. * send_per_roam_config_cmd_tlv() - set per roaming config to FW
  1651. * @wmi_handle: wmi handle
  1652. * @req_buf: per roam config buffer
  1653. *
  1654. * Return: QDF status
  1655. */
  1656. static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
  1657. struct wmi_per_roam_config_req *req_buf)
  1658. {
  1659. wmi_buf_t buf = NULL;
  1660. QDF_STATUS status;
  1661. int len;
  1662. uint8_t *buf_ptr;
  1663. wmi_roam_per_config_fixed_param *wmi_per_config;
  1664. len = sizeof(wmi_roam_per_config_fixed_param);
  1665. buf = wmi_buf_alloc(wmi_handle, len);
  1666. if (!buf) {
  1667. return QDF_STATUS_E_NOMEM;
  1668. }
  1669. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1670. wmi_per_config =
  1671. (wmi_roam_per_config_fixed_param *) buf_ptr;
  1672. WMITLV_SET_HDR(&wmi_per_config->tlv_header,
  1673. WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
  1674. WMITLV_GET_STRUCT_TLVLEN
  1675. (wmi_roam_per_config_fixed_param));
  1676. /* fill in per roam config values */
  1677. wmi_per_config->vdev_id = req_buf->vdev_id;
  1678. wmi_per_config->enable = req_buf->per_config.enable;
  1679. wmi_per_config->high_rate_thresh =
  1680. (req_buf->per_config.tx_high_rate_thresh << 16) |
  1681. (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
  1682. wmi_per_config->low_rate_thresh =
  1683. (req_buf->per_config.tx_low_rate_thresh << 16) |
  1684. (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
  1685. wmi_per_config->pkt_err_rate_thresh_pct =
  1686. (req_buf->per_config.tx_rate_thresh_percnt << 16) |
  1687. (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
  1688. wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
  1689. wmi_per_config->pkt_err_rate_mon_time =
  1690. (req_buf->per_config.tx_per_mon_time << 16) |
  1691. (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
  1692. wmi_per_config->min_candidate_rssi =
  1693. req_buf->per_config.min_candidate_rssi;
  1694. /* Send per roam config parameters */
  1695. wmi_mtrace(WMI_ROAM_PER_CONFIG_CMDID, NO_SESSION, 0);
  1696. status = wmi_unified_cmd_send(wmi_handle, buf,
  1697. len, WMI_ROAM_PER_CONFIG_CMDID);
  1698. if (QDF_IS_STATUS_ERROR(status)) {
  1699. WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
  1700. status);
  1701. wmi_buf_free(buf);
  1702. return status;
  1703. }
  1704. WMI_LOGD(FL("per roam enable=%d, vdev=%d"),
  1705. req_buf->per_config.enable, req_buf->vdev_id);
  1706. return QDF_STATUS_SUCCESS;
  1707. }
  1708. /**
  1709. * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
  1710. * configuration params
  1711. * @wmi_handle: wmi handler
  1712. * @limit_off_chan_param: pointer to wmi_off_chan_param
  1713. *
  1714. * Return: 0 for success and non zero for failure
  1715. */
  1716. static
  1717. QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
  1718. struct wmi_limit_off_chan_param *limit_off_chan_param)
  1719. {
  1720. wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
  1721. wmi_buf_t buf;
  1722. uint32_t len = sizeof(*cmd);
  1723. int err;
  1724. buf = wmi_buf_alloc(wmi_handle, len);
  1725. if (!buf) {
  1726. return QDF_STATUS_E_NOMEM;
  1727. }
  1728. cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
  1729. WMITLV_SET_HDR(&cmd->tlv_header,
  1730. WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
  1731. WMITLV_GET_STRUCT_TLVLEN(
  1732. wmi_vdev_limit_offchan_cmd_fixed_param));
  1733. cmd->vdev_id = limit_off_chan_param->vdev_id;
  1734. cmd->flags &= 0;
  1735. if (limit_off_chan_param->status)
  1736. cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
  1737. if (limit_off_chan_param->skip_dfs_chans)
  1738. cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
  1739. cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
  1740. cmd->rest_time = limit_off_chan_param->rest_time;
  1741. WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
  1742. __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
  1743. cmd->rest_time);
  1744. wmi_mtrace(WMI_VDEV_LIMIT_OFFCHAN_CMDID, cmd->vdev_id, 0);
  1745. err = wmi_unified_cmd_send(wmi_handle, buf,
  1746. len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
  1747. if (QDF_IS_STATUS_ERROR(err)) {
  1748. WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
  1749. wmi_buf_free(buf);
  1750. return QDF_STATUS_E_FAILURE;
  1751. }
  1752. return QDF_STATUS_SUCCESS;
  1753. }
  1754. #ifdef WLAN_FEATURE_FILS_SK
  1755. static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
  1756. struct hlp_params *params)
  1757. {
  1758. uint32_t len;
  1759. uint8_t *buf_ptr;
  1760. wmi_buf_t buf = NULL;
  1761. wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
  1762. len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
  1763. len += WMI_TLV_HDR_SIZE;
  1764. len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
  1765. buf = wmi_buf_alloc(wmi_handle, len);
  1766. if (!buf) {
  1767. return QDF_STATUS_E_NOMEM;
  1768. }
  1769. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1770. hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
  1771. WMITLV_SET_HDR(&hlp_params->tlv_header,
  1772. WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
  1773. WMITLV_GET_STRUCT_TLVLEN(
  1774. wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
  1775. hlp_params->vdev_id = params->vdev_id;
  1776. hlp_params->size = params->hlp_ie_len;
  1777. hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
  1778. buf_ptr += sizeof(*hlp_params);
  1779. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1780. round_up(params->hlp_ie_len,
  1781. sizeof(uint32_t)));
  1782. buf_ptr += WMI_TLV_HDR_SIZE;
  1783. qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
  1784. WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
  1785. hlp_params->vdev_id, hlp_params->size);
  1786. wmi_mtrace(WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID, NO_SESSION, 0);
  1787. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1788. WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
  1789. WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
  1790. wmi_buf_free(buf);
  1791. return QDF_STATUS_E_FAILURE;
  1792. }
  1793. return QDF_STATUS_SUCCESS;
  1794. }
  1795. void wmi_fils_sk_attach_tlv(wmi_unified_t wmi_handle)
  1796. {
  1797. struct wmi_ops *ops = wmi_handle->ops;
  1798. ops->send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv;
  1799. }
  1800. #endif /* WLAN_FEATURE_FILS_SK */
  1801. /*
  1802. * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
  1803. * @wmi_handle: wmi handle
  1804. * @params: pointer to wmi_btm_config
  1805. *
  1806. * Return: QDF_STATUS
  1807. */
  1808. static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
  1809. struct wmi_btm_config *params)
  1810. {
  1811. wmi_btm_config_fixed_param *cmd;
  1812. wmi_buf_t buf;
  1813. uint32_t len;
  1814. len = sizeof(*cmd);
  1815. buf = wmi_buf_alloc(wmi_handle, len);
  1816. if (!buf) {
  1817. return QDF_STATUS_E_NOMEM;
  1818. }
  1819. cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
  1820. WMITLV_SET_HDR(&cmd->tlv_header,
  1821. WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
  1822. WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
  1823. cmd->vdev_id = params->vdev_id;
  1824. cmd->flags = params->btm_offload_config;
  1825. cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
  1826. cmd->solicited_timeout_ms = params->btm_solicited_timeout;
  1827. cmd->stick_time_seconds = params->btm_sticky_time;
  1828. cmd->disassoc_timer_threshold = params->disassoc_timer_threshold;
  1829. wmi_mtrace(WMI_ROAM_BTM_CONFIG_CMDID, cmd->vdev_id, 0);
  1830. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1831. WMI_ROAM_BTM_CONFIG_CMDID)) {
  1832. WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
  1833. __func__);
  1834. wmi_buf_free(buf);
  1835. return QDF_STATUS_E_FAILURE;
  1836. }
  1837. return QDF_STATUS_SUCCESS;
  1838. }
  1839. /**
  1840. * send_roam_bss_load_config_tlv() - send roam load bss trigger configuration
  1841. * @wmi_handle: wmi handle
  1842. * @parms: pointer to wmi_bss_load_config
  1843. *
  1844. * This function sends the roam load bss trigger configuration to fw.
  1845. * the bss_load_threshold parameter is used to configure the maximum
  1846. * bss load percentage, above which the firmware should trigger roaming
  1847. *
  1848. * Return: QDF status
  1849. */
  1850. static QDF_STATUS
  1851. send_roam_bss_load_config_tlv(wmi_unified_t wmi_handle,
  1852. struct wmi_bss_load_config *params)
  1853. {
  1854. wmi_roam_bss_load_config_cmd_fixed_param *cmd;
  1855. wmi_buf_t buf;
  1856. uint32_t len;
  1857. len = sizeof(*cmd);
  1858. buf = wmi_buf_alloc(wmi_handle, len);
  1859. if (!buf)
  1860. return QDF_STATUS_E_NOMEM;
  1861. cmd = (wmi_roam_bss_load_config_cmd_fixed_param *)wmi_buf_data(buf);
  1862. WMITLV_SET_HDR(
  1863. &cmd->tlv_header,
  1864. WMITLV_TAG_STRUC_wmi_roam_bss_load_config_cmd_fixed_param,
  1865. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_bss_load_config_cmd_fixed_param));
  1866. cmd->vdev_id = params->vdev_id;
  1867. cmd->bss_load_threshold = params->bss_load_threshold;
  1868. cmd->monitor_time_window = params->bss_load_sample_time;
  1869. wmi_mtrace(WMI_ROAM_BSS_LOAD_CONFIG_CMDID, cmd->vdev_id, 0);
  1870. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1871. WMI_ROAM_BSS_LOAD_CONFIG_CMDID)) {
  1872. WMI_LOGE("%s: failed to send WMI_ROAM_BSS_LOAD_CONFIG_CMDID ",
  1873. __func__);
  1874. wmi_buf_free(buf);
  1875. return QDF_STATUS_E_FAILURE;
  1876. }
  1877. return QDF_STATUS_SUCCESS;
  1878. }
  1879. /**
  1880. * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
  1881. * @wmi_handle: wmi handler
  1882. * @params: pointer to 11k offload params
  1883. *
  1884. * Return: 0 for success and non zero for failure
  1885. */
  1886. static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
  1887. struct wmi_11k_offload_params *params)
  1888. {
  1889. wmi_11k_offload_report_fixed_param *cmd;
  1890. wmi_buf_t buf;
  1891. QDF_STATUS status;
  1892. uint8_t *buf_ptr;
  1893. wmi_neighbor_report_11k_offload_tlv_param
  1894. *neighbor_report_offload_params;
  1895. wmi_neighbor_report_offload *neighbor_report_offload;
  1896. uint32_t len = sizeof(*cmd);
  1897. if (params->offload_11k_bitmask &
  1898. WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
  1899. len += WMI_TLV_HDR_SIZE +
  1900. sizeof(wmi_neighbor_report_11k_offload_tlv_param);
  1901. buf = wmi_buf_alloc(wmi_handle, len);
  1902. if (!buf) {
  1903. return QDF_STATUS_E_NOMEM;
  1904. }
  1905. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1906. cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
  1907. WMITLV_SET_HDR(&cmd->tlv_header,
  1908. WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
  1909. WMITLV_GET_STRUCT_TLVLEN(
  1910. wmi_11k_offload_report_fixed_param));
  1911. cmd->vdev_id = params->vdev_id;
  1912. cmd->offload_11k = params->offload_11k_bitmask;
  1913. if (params->offload_11k_bitmask &
  1914. WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
  1915. buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
  1916. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1917. sizeof(wmi_neighbor_report_11k_offload_tlv_param));
  1918. buf_ptr += WMI_TLV_HDR_SIZE;
  1919. neighbor_report_offload_params =
  1920. (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
  1921. WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
  1922. WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
  1923. WMITLV_GET_STRUCT_TLVLEN(
  1924. wmi_neighbor_report_11k_offload_tlv_param));
  1925. neighbor_report_offload = &neighbor_report_offload_params->
  1926. neighbor_rep_ofld_params;
  1927. neighbor_report_offload->time_offset =
  1928. params->neighbor_report_params.time_offset;
  1929. neighbor_report_offload->low_rssi_offset =
  1930. params->neighbor_report_params.low_rssi_offset;
  1931. neighbor_report_offload->bmiss_count_trigger =
  1932. params->neighbor_report_params.bmiss_count_trigger;
  1933. neighbor_report_offload->per_threshold_offset =
  1934. params->neighbor_report_params.per_threshold_offset;
  1935. neighbor_report_offload->neighbor_report_cache_timeout =
  1936. params->neighbor_report_params.
  1937. neighbor_report_cache_timeout;
  1938. neighbor_report_offload->max_neighbor_report_req_cap =
  1939. params->neighbor_report_params.
  1940. max_neighbor_report_req_cap;
  1941. neighbor_report_offload->ssid.ssid_len =
  1942. params->neighbor_report_params.ssid.length;
  1943. qdf_mem_copy(neighbor_report_offload->ssid.ssid,
  1944. &params->neighbor_report_params.ssid.mac_ssid,
  1945. neighbor_report_offload->ssid.ssid_len);
  1946. }
  1947. wmi_mtrace(WMI_11K_OFFLOAD_REPORT_CMDID, cmd->vdev_id, 0);
  1948. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  1949. WMI_11K_OFFLOAD_REPORT_CMDID);
  1950. if (status != QDF_STATUS_SUCCESS) {
  1951. WMI_LOGE("%s: failed to send 11k offload command %d",
  1952. __func__, status);
  1953. wmi_buf_free(buf);
  1954. }
  1955. return status;
  1956. }
  1957. /**
  1958. * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
  1959. * command
  1960. * @wmi_handle: wmi handler
  1961. * @params: pointer to neighbor report invoke params
  1962. *
  1963. * Return: 0 for success and non zero for failure
  1964. */
  1965. static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
  1966. struct wmi_invoke_neighbor_report_params *params)
  1967. {
  1968. wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
  1969. wmi_buf_t buf;
  1970. QDF_STATUS status;
  1971. uint8_t *buf_ptr;
  1972. uint32_t len = sizeof(*cmd);
  1973. buf = wmi_buf_alloc(wmi_handle, len);
  1974. if (!buf) {
  1975. return QDF_STATUS_E_NOMEM;
  1976. }
  1977. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1978. cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
  1979. WMITLV_SET_HDR(&cmd->tlv_header,
  1980. WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
  1981. WMITLV_GET_STRUCT_TLVLEN(
  1982. wmi_11k_offload_invoke_neighbor_report_fixed_param));
  1983. cmd->vdev_id = params->vdev_id;
  1984. cmd->flags = params->send_resp_to_host;
  1985. cmd->ssid.ssid_len = params->ssid.length;
  1986. qdf_mem_copy(cmd->ssid.ssid,
  1987. &params->ssid.mac_ssid,
  1988. cmd->ssid.ssid_len);
  1989. wmi_mtrace(WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID, cmd->vdev_id, 0);
  1990. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  1991. WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
  1992. if (status != QDF_STATUS_SUCCESS) {
  1993. WMI_LOGE("%s: failed to send invoke neighbor report command %d",
  1994. __func__, status);
  1995. wmi_buf_free(buf);
  1996. }
  1997. return status;
  1998. }
  1999. void wmi_roam_attach_tlv(wmi_unified_t wmi_handle)
  2000. {
  2001. struct wmi_ops *ops = wmi_handle->ops;
  2002. ops->send_roam_scan_offload_rssi_thresh_cmd =
  2003. send_roam_scan_offload_rssi_thresh_cmd_tlv;
  2004. ops->send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv;
  2005. ops->send_roam_scan_filter_cmd =
  2006. send_roam_scan_filter_cmd_tlv;
  2007. ops->send_roam_scan_offload_mode_cmd =
  2008. send_roam_scan_offload_mode_cmd_tlv;
  2009. ops->send_roam_scan_offload_ap_profile_cmd =
  2010. send_roam_scan_offload_ap_profile_cmd_tlv;
  2011. ops->send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv;
  2012. ops->send_roam_scan_offload_scan_period_cmd =
  2013. send_roam_scan_offload_scan_period_cmd_tlv;
  2014. ops->send_roam_scan_offload_chan_list_cmd =
  2015. send_roam_scan_offload_chan_list_cmd_tlv;
  2016. ops->send_roam_scan_offload_rssi_change_cmd =
  2017. send_roam_scan_offload_rssi_change_cmd_tlv;
  2018. ops->send_per_roam_config_cmd = send_per_roam_config_cmd_tlv;
  2019. ops->send_limit_off_chan_cmd = send_limit_off_chan_cmd_tlv;
  2020. ops->send_btm_config = send_btm_config_cmd_tlv;
  2021. ops->send_offload_11k_cmd = send_offload_11k_cmd_tlv;
  2022. ops->send_invoke_neighbor_report_cmd =
  2023. send_invoke_neighbor_report_cmd_tlv;
  2024. ops->send_roam_bss_load_config = send_roam_bss_load_config_tlv;
  2025. wmi_lfr_subnet_detection_attach_tlv(wmi_handle);
  2026. wmi_rssi_monitor_attach_tlv(wmi_handle);
  2027. wmi_ese_attach_tlv(wmi_handle);
  2028. wmi_roam_offload_attach_tlv(wmi_handle);
  2029. wmi_fils_sk_attach_tlv(wmi_handle);
  2030. }