wmi_unified_roam_tlv.c 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270
  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. /* Fill the capabilities */
  1038. roam_offload_params->capability =
  1039. req_offload_params->capability;
  1040. roam_offload_params->ht_caps_info =
  1041. req_offload_params->ht_caps_info;
  1042. roam_offload_params->ampdu_param =
  1043. req_offload_params->ampdu_param;
  1044. roam_offload_params->ht_ext_cap =
  1045. req_offload_params->ht_ext_cap;
  1046. roam_offload_params->ht_txbf = req_offload_params->ht_txbf;
  1047. roam_offload_params->asel_cap = req_offload_params->asel_cap;
  1048. roam_offload_params->qos_caps = req_offload_params->qos_caps;
  1049. roam_offload_params->qos_enabled =
  1050. req_offload_params->qos_enabled;
  1051. roam_offload_params->wmm_caps = req_offload_params->wmm_caps;
  1052. qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
  1053. (uint8_t *)req_offload_params->mcsset,
  1054. ROAM_OFFLOAD_NUM_MCS_SET);
  1055. buf_ptr += sizeof(wmi_roam_offload_tlv_param);
  1056. /* The TLV's are in the order of 11i, 11R, ESE. Hence,
  1057. * they are filled in the same order.Depending on the
  1058. * authentication type, the other mode TLV's are nullified
  1059. * and only headers are filled.*/
  1060. if ((auth_mode != WMI_AUTH_NONE) &&
  1061. ((auth_mode != WMI_AUTH_OPEN) ||
  1062. (auth_mode == WMI_AUTH_OPEN
  1063. && roam_req->mdid.mdie_present &&
  1064. roam_req->is_11r_assoc) ||
  1065. roam_req->is_ese_assoc)) {
  1066. if (roam_req->is_ese_assoc) {
  1067. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1068. WMITLV_GET_STRUCT_TLVLEN(0));
  1069. buf_ptr += WMI_TLV_HDR_SIZE;
  1070. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1071. WMITLV_GET_STRUCT_TLVLEN(0));
  1072. buf_ptr += WMI_TLV_HDR_SIZE;
  1073. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1074. sizeof(wmi_roam_ese_offload_tlv_param));
  1075. buf_ptr += WMI_TLV_HDR_SIZE;
  1076. roam_offload_ese =
  1077. (wmi_roam_ese_offload_tlv_param *) buf_ptr;
  1078. qdf_mem_copy(roam_offload_ese->krk,
  1079. roam_req->krk,
  1080. sizeof(roam_req->krk));
  1081. qdf_mem_copy(roam_offload_ese->btk,
  1082. roam_req->btk,
  1083. sizeof(roam_req->btk));
  1084. WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
  1085. WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
  1086. WMITLV_GET_STRUCT_TLVLEN
  1087. (wmi_roam_ese_offload_tlv_param));
  1088. buf_ptr +=
  1089. sizeof(wmi_roam_ese_offload_tlv_param);
  1090. } else if (auth_mode == WMI_AUTH_FT_RSNA
  1091. || auth_mode == WMI_AUTH_FT_RSNA_PSK
  1092. || (auth_mode == WMI_AUTH_OPEN
  1093. && roam_req->mdid.mdie_present &&
  1094. roam_req->is_11r_assoc)) {
  1095. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1096. 0);
  1097. buf_ptr += WMI_TLV_HDR_SIZE;
  1098. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1099. sizeof(wmi_roam_11r_offload_tlv_param));
  1100. buf_ptr += WMI_TLV_HDR_SIZE;
  1101. roam_offload_11r =
  1102. (wmi_roam_11r_offload_tlv_param *) buf_ptr;
  1103. roam_offload_11r->r0kh_id_len =
  1104. roam_req->rokh_id_length;
  1105. qdf_mem_copy(roam_offload_11r->r0kh_id,
  1106. roam_req->rokh_id,
  1107. roam_offload_11r->r0kh_id_len);
  1108. qdf_mem_copy(roam_offload_11r->psk_msk,
  1109. roam_req->psk_pmk,
  1110. sizeof(roam_req->psk_pmk));
  1111. roam_offload_11r->psk_msk_len =
  1112. roam_req->pmk_len;
  1113. roam_offload_11r->mdie_present =
  1114. roam_req->mdid.mdie_present;
  1115. roam_offload_11r->mdid =
  1116. roam_req->mdid.mobility_domain;
  1117. if (auth_mode == WMI_AUTH_OPEN) {
  1118. /* If FT-Open ensure pmk length
  1119. and r0khid len are zero */
  1120. roam_offload_11r->r0kh_id_len = 0;
  1121. roam_offload_11r->psk_msk_len = 0;
  1122. }
  1123. WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
  1124. WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
  1125. WMITLV_GET_STRUCT_TLVLEN
  1126. (wmi_roam_11r_offload_tlv_param));
  1127. buf_ptr +=
  1128. sizeof(wmi_roam_11r_offload_tlv_param);
  1129. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1130. WMITLV_GET_STRUCT_TLVLEN(0));
  1131. buf_ptr += WMI_TLV_HDR_SIZE;
  1132. WMI_LOGD("psk_msk_len = %d",
  1133. roam_offload_11r->psk_msk_len);
  1134. if (roam_offload_11r->psk_msk_len)
  1135. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
  1136. QDF_TRACE_LEVEL_DEBUG,
  1137. roam_offload_11r->psk_msk,
  1138. roam_offload_11r->psk_msk_len);
  1139. } else {
  1140. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1141. sizeof(wmi_roam_11i_offload_tlv_param));
  1142. buf_ptr += WMI_TLV_HDR_SIZE;
  1143. roam_offload_11i =
  1144. (wmi_roam_11i_offload_tlv_param *) buf_ptr;
  1145. if (roam_req->roam_key_mgmt_offload_enabled &&
  1146. roam_req->fw_okc) {
  1147. WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
  1148. (roam_offload_11i->flags);
  1149. WMI_LOGI("LFR3:OKC enabled");
  1150. } else {
  1151. WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
  1152. (roam_offload_11i->flags);
  1153. WMI_LOGI("LFR3:OKC disabled");
  1154. }
  1155. if (roam_req->roam_key_mgmt_offload_enabled &&
  1156. roam_req->fw_pmksa_cache) {
  1157. WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
  1158. (roam_offload_11i->flags);
  1159. WMI_LOGI("LFR3:PMKSA caching enabled");
  1160. } else {
  1161. WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
  1162. (roam_offload_11i->flags);
  1163. WMI_LOGI("LFR3:PMKSA caching disabled");
  1164. }
  1165. qdf_mem_copy(roam_offload_11i->pmk,
  1166. roam_req->psk_pmk,
  1167. sizeof(roam_req->psk_pmk));
  1168. roam_offload_11i->pmk_len = roam_req->pmk_len;
  1169. WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
  1170. WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
  1171. WMITLV_GET_STRUCT_TLVLEN
  1172. (wmi_roam_11i_offload_tlv_param));
  1173. buf_ptr +=
  1174. sizeof(wmi_roam_11i_offload_tlv_param);
  1175. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1176. 0);
  1177. buf_ptr += WMI_TLV_HDR_SIZE;
  1178. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1179. 0);
  1180. buf_ptr += WMI_TLV_HDR_SIZE;
  1181. WMI_LOGD("pmk_len = %d",
  1182. roam_offload_11i->pmk_len);
  1183. if (roam_offload_11i->pmk_len)
  1184. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
  1185. QDF_TRACE_LEVEL_DEBUG,
  1186. roam_offload_11i->pmk,
  1187. roam_offload_11i->pmk_len);
  1188. }
  1189. } else {
  1190. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1191. WMITLV_GET_STRUCT_TLVLEN(0));
  1192. buf_ptr += WMI_TLV_HDR_SIZE;
  1193. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1194. WMITLV_GET_STRUCT_TLVLEN(0));
  1195. buf_ptr += WMI_TLV_HDR_SIZE;
  1196. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1197. WMITLV_GET_STRUCT_TLVLEN(0));
  1198. buf_ptr += WMI_TLV_HDR_SIZE;
  1199. }
  1200. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1201. sizeof(*assoc_ies));
  1202. buf_ptr += WMI_TLV_HDR_SIZE;
  1203. assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
  1204. WMITLV_SET_HDR(&assoc_ies->tlv_header,
  1205. WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
  1206. WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
  1207. assoc_ies->buf_len = roam_req->assoc_ie_length;
  1208. buf_ptr += sizeof(*assoc_ies);
  1209. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1210. roundup(assoc_ies->buf_len, sizeof(uint32_t)));
  1211. buf_ptr += WMI_TLV_HDR_SIZE;
  1212. if (assoc_ies->buf_len != 0) {
  1213. qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
  1214. assoc_ies->buf_len);
  1215. }
  1216. buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
  1217. buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
  1218. buf_ptr, fils_tlv_len);
  1219. } else {
  1220. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1221. WMITLV_GET_STRUCT_TLVLEN(0));
  1222. buf_ptr += WMI_TLV_HDR_SIZE;
  1223. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1224. WMITLV_GET_STRUCT_TLVLEN(0));
  1225. buf_ptr += WMI_TLV_HDR_SIZE;
  1226. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1227. WMITLV_GET_STRUCT_TLVLEN(0));
  1228. buf_ptr += WMI_TLV_HDR_SIZE;
  1229. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1230. WMITLV_GET_STRUCT_TLVLEN(0));
  1231. buf_ptr += WMI_TLV_HDR_SIZE;
  1232. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1233. WMITLV_GET_STRUCT_TLVLEN(0));
  1234. buf_ptr += WMI_TLV_HDR_SIZE;
  1235. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1236. WMITLV_GET_STRUCT_TLVLEN(0));
  1237. }
  1238. #endif /* WLAN_FEATURE_ROAM_OFFLOAD */
  1239. send_roam_scan_mode_cmd:
  1240. wmi_mtrace(WMI_ROAM_SCAN_MODE, NO_SESSION, 0);
  1241. status = wmi_unified_cmd_send(wmi_handle, buf,
  1242. len, WMI_ROAM_SCAN_MODE);
  1243. if (QDF_IS_STATUS_ERROR(status)) {
  1244. WMI_LOGE(
  1245. "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
  1246. status);
  1247. wmi_buf_free(buf);
  1248. }
  1249. return status;
  1250. }
  1251. /**
  1252. * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
  1253. * @wmi_handle: wmi handle
  1254. * @ap_profile_p: ap profile
  1255. * @vdev_id: vdev id
  1256. *
  1257. * Send WMI_ROAM_AP_PROFILE to firmware
  1258. *
  1259. * Return: CDF status
  1260. */
  1261. static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
  1262. struct ap_profile_params *ap_profile)
  1263. {
  1264. wmi_buf_t buf = NULL;
  1265. QDF_STATUS status;
  1266. int len;
  1267. uint8_t *buf_ptr;
  1268. wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
  1269. wmi_roam_cnd_scoring_param *score_param;
  1270. wmi_ap_profile *profile;
  1271. len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
  1272. len += sizeof(*score_param);
  1273. buf = wmi_buf_alloc(wmi_handle, len);
  1274. if (!buf) {
  1275. return QDF_STATUS_E_NOMEM;
  1276. }
  1277. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1278. roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
  1279. WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
  1280. WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
  1281. WMITLV_GET_STRUCT_TLVLEN
  1282. (wmi_roam_ap_profile_fixed_param));
  1283. /* fill in threshold values */
  1284. roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
  1285. roam_ap_profile_fp->id = 0;
  1286. buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
  1287. profile = (wmi_ap_profile *)buf_ptr;
  1288. WMITLV_SET_HDR(&profile->tlv_header,
  1289. WMITLV_TAG_STRUC_wmi_ap_profile,
  1290. WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
  1291. profile->flags = ap_profile->profile.flags;
  1292. profile->rssi_threshold = ap_profile->profile.rssi_threshold;
  1293. profile->ssid.ssid_len = ap_profile->profile.ssid.length;
  1294. qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
  1295. profile->ssid.ssid_len);
  1296. profile->rsn_authmode = ap_profile->profile.rsn_authmode;
  1297. profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
  1298. profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
  1299. profile->rsn_mcastmgmtcipherset =
  1300. ap_profile->profile.rsn_mcastmgmtcipherset;
  1301. profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
  1302. 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",
  1303. profile->flags, profile->rssi_threshold,
  1304. profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
  1305. profile->rsn_authmode, profile->rsn_ucastcipherset,
  1306. profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
  1307. profile->rssi_abs_thresh);
  1308. buf_ptr += sizeof(wmi_ap_profile);
  1309. score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
  1310. WMITLV_SET_HDR(&score_param->tlv_header,
  1311. WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
  1312. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
  1313. score_param->disable_bitmap = ap_profile->param.disable_bitmap;
  1314. score_param->rssi_weightage_pcnt =
  1315. ap_profile->param.rssi_weightage;
  1316. score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
  1317. score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
  1318. score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
  1319. score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
  1320. score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
  1321. score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
  1322. score_param->esp_qbss_weightage_pcnt =
  1323. ap_profile->param.esp_qbss_weightage;
  1324. score_param->beamforming_weightage_pcnt =
  1325. ap_profile->param.beamforming_weightage;
  1326. score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
  1327. score_param->oce_wan_weightage_pcnt =
  1328. ap_profile->param.oce_wan_weightage;
  1329. 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",
  1330. score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
  1331. score_param->ht_weightage_pcnt,
  1332. score_param->vht_weightage_pcnt,
  1333. score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
  1334. score_param->band_weightage_pcnt,
  1335. score_param->nss_weightage_pcnt,
  1336. score_param->esp_qbss_weightage_pcnt,
  1337. score_param->beamforming_weightage_pcnt,
  1338. score_param->pcl_weightage_pcnt,
  1339. score_param->oce_wan_weightage_pcnt);
  1340. score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
  1341. score_param->band_scoring.score_pcnt =
  1342. ap_profile->param.band_index_score;
  1343. score_param->nss_scoring.score_pcnt =
  1344. ap_profile->param.nss_index_score;
  1345. WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
  1346. score_param->bw_scoring.score_pcnt,
  1347. score_param->band_scoring.score_pcnt,
  1348. score_param->nss_scoring.score_pcnt);
  1349. score_param->rssi_scoring.best_rssi_threshold =
  1350. (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
  1351. score_param->rssi_scoring.good_rssi_threshold =
  1352. (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
  1353. score_param->rssi_scoring.bad_rssi_threshold =
  1354. (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
  1355. score_param->rssi_scoring.good_rssi_pcnt =
  1356. ap_profile->param.rssi_scoring.good_rssi_pcnt;
  1357. score_param->rssi_scoring.bad_rssi_pcnt =
  1358. ap_profile->param.rssi_scoring.bad_rssi_pcnt;
  1359. score_param->rssi_scoring.good_bucket_size =
  1360. ap_profile->param.rssi_scoring.good_bucket_size;
  1361. score_param->rssi_scoring.bad_bucket_size =
  1362. ap_profile->param.rssi_scoring.bad_bucket_size;
  1363. score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
  1364. (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
  1365. WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
  1366. score_param->rssi_scoring.best_rssi_threshold,
  1367. score_param->rssi_scoring.good_rssi_threshold,
  1368. score_param->rssi_scoring.bad_rssi_threshold,
  1369. score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
  1370. WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
  1371. score_param->rssi_scoring.good_rssi_pcnt,
  1372. score_param->rssi_scoring.bad_rssi_pcnt,
  1373. score_param->rssi_scoring.good_bucket_size,
  1374. score_param->rssi_scoring.bad_bucket_size);
  1375. score_param->esp_qbss_scoring.num_slot =
  1376. ap_profile->param.esp_qbss_scoring.num_slot;
  1377. score_param->esp_qbss_scoring.score_pcnt3_to_0 =
  1378. ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
  1379. score_param->esp_qbss_scoring.score_pcnt7_to_4 =
  1380. ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
  1381. score_param->esp_qbss_scoring.score_pcnt11_to_8 =
  1382. ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
  1383. score_param->esp_qbss_scoring.score_pcnt15_to_12 =
  1384. ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
  1385. WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
  1386. score_param->esp_qbss_scoring.num_slot,
  1387. score_param->esp_qbss_scoring.score_pcnt3_to_0,
  1388. score_param->esp_qbss_scoring.score_pcnt7_to_4,
  1389. score_param->esp_qbss_scoring.score_pcnt11_to_8,
  1390. score_param->esp_qbss_scoring.score_pcnt15_to_12);
  1391. score_param->oce_wan_scoring.num_slot =
  1392. ap_profile->param.oce_wan_scoring.num_slot;
  1393. score_param->oce_wan_scoring.score_pcnt3_to_0 =
  1394. ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
  1395. score_param->oce_wan_scoring.score_pcnt7_to_4 =
  1396. ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
  1397. score_param->oce_wan_scoring.score_pcnt11_to_8 =
  1398. ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
  1399. score_param->oce_wan_scoring.score_pcnt15_to_12 =
  1400. ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
  1401. WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
  1402. score_param->oce_wan_scoring.num_slot,
  1403. score_param->oce_wan_scoring.score_pcnt3_to_0,
  1404. score_param->oce_wan_scoring.score_pcnt7_to_4,
  1405. score_param->oce_wan_scoring.score_pcnt11_to_8,
  1406. score_param->oce_wan_scoring.score_pcnt15_to_12);
  1407. wmi_mtrace(WMI_ROAM_AP_PROFILE, NO_SESSION, 0);
  1408. status = wmi_unified_cmd_send(wmi_handle, buf,
  1409. len, WMI_ROAM_AP_PROFILE);
  1410. if (QDF_IS_STATUS_ERROR(status)) {
  1411. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
  1412. status);
  1413. wmi_buf_free(buf);
  1414. }
  1415. WMI_LOGD("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
  1416. return status;
  1417. }
  1418. /**
  1419. * send_roam_scan_offload_cmd_tlv() - set roam offload command
  1420. * @wmi_handle: wmi handle
  1421. * @command: command
  1422. * @vdev_id: vdev id
  1423. *
  1424. * This function set roam offload command to fw.
  1425. *
  1426. * Return: CDF status
  1427. */
  1428. static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
  1429. uint32_t command, uint32_t vdev_id)
  1430. {
  1431. QDF_STATUS status;
  1432. wmi_roam_scan_cmd_fixed_param *cmd_fp;
  1433. wmi_buf_t buf = NULL;
  1434. int len;
  1435. uint8_t *buf_ptr;
  1436. len = sizeof(wmi_roam_scan_cmd_fixed_param);
  1437. buf = wmi_buf_alloc(wmi_handle, len);
  1438. if (!buf) {
  1439. return QDF_STATUS_E_NOMEM;
  1440. }
  1441. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1442. cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
  1443. WMITLV_SET_HDR(&cmd_fp->tlv_header,
  1444. WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
  1445. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
  1446. cmd_fp->vdev_id = vdev_id;
  1447. cmd_fp->command_arg = command;
  1448. wmi_mtrace(WMI_ROAM_SCAN_CMD, NO_SESSION, 0);
  1449. status = wmi_unified_cmd_send(wmi_handle, buf,
  1450. len, WMI_ROAM_SCAN_CMD);
  1451. if (QDF_IS_STATUS_ERROR(status)) {
  1452. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
  1453. status);
  1454. goto error;
  1455. }
  1456. WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
  1457. return QDF_STATUS_SUCCESS;
  1458. error:
  1459. wmi_buf_free(buf);
  1460. return status;
  1461. }
  1462. /**
  1463. * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
  1464. * @wmi_handle: wmi handle
  1465. * @scan_period: scan period
  1466. * @scan_age: scan age
  1467. * @vdev_id: vdev id
  1468. *
  1469. * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
  1470. *
  1471. * Return: CDF status
  1472. */
  1473. static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
  1474. uint32_t scan_period,
  1475. uint32_t scan_age,
  1476. uint32_t vdev_id)
  1477. {
  1478. QDF_STATUS status;
  1479. wmi_buf_t buf = NULL;
  1480. int len;
  1481. uint8_t *buf_ptr;
  1482. wmi_roam_scan_period_fixed_param *scan_period_fp;
  1483. /* Send scan period values */
  1484. len = sizeof(wmi_roam_scan_period_fixed_param);
  1485. buf = wmi_buf_alloc(wmi_handle, len);
  1486. if (!buf) {
  1487. return QDF_STATUS_E_NOMEM;
  1488. }
  1489. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1490. scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
  1491. WMITLV_SET_HDR(&scan_period_fp->tlv_header,
  1492. WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
  1493. WMITLV_GET_STRUCT_TLVLEN
  1494. (wmi_roam_scan_period_fixed_param));
  1495. /* fill in scan period values */
  1496. scan_period_fp->vdev_id = vdev_id;
  1497. scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
  1498. scan_period_fp->roam_scan_age = scan_age;
  1499. wmi_mtrace(WMI_ROAM_SCAN_PERIOD, NO_SESSION, 0);
  1500. status = wmi_unified_cmd_send(wmi_handle, buf,
  1501. len, WMI_ROAM_SCAN_PERIOD);
  1502. if (QDF_IS_STATUS_ERROR(status)) {
  1503. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
  1504. status);
  1505. goto error;
  1506. }
  1507. WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
  1508. __func__, scan_period, scan_age);
  1509. return QDF_STATUS_SUCCESS;
  1510. error:
  1511. wmi_buf_free(buf);
  1512. return status;
  1513. }
  1514. /**
  1515. * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
  1516. * @wmi_handle: wmi handle
  1517. * @chan_count: channel count
  1518. * @chan_list: channel list
  1519. * @list_type: list type
  1520. * @vdev_id: vdev id
  1521. *
  1522. * Set roam offload channel list.
  1523. *
  1524. * Return: CDF status
  1525. */
  1526. static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
  1527. uint8_t chan_count,
  1528. uint32_t *chan_list,
  1529. uint8_t list_type, uint32_t vdev_id)
  1530. {
  1531. wmi_buf_t buf = NULL;
  1532. QDF_STATUS status;
  1533. int len, list_tlv_len;
  1534. int i;
  1535. uint8_t *buf_ptr;
  1536. wmi_roam_chan_list_fixed_param *chan_list_fp;
  1537. uint32_t *roam_chan_list_array;
  1538. if (chan_count == 0) {
  1539. WMI_LOGD("%s : invalid number of channels %d", __func__,
  1540. chan_count);
  1541. return QDF_STATUS_E_EMPTY;
  1542. }
  1543. /* Channel list is a table of 2 TLV's */
  1544. list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
  1545. len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
  1546. buf = wmi_buf_alloc(wmi_handle, len);
  1547. if (!buf) {
  1548. return QDF_STATUS_E_NOMEM;
  1549. }
  1550. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1551. chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
  1552. WMITLV_SET_HDR(&chan_list_fp->tlv_header,
  1553. WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
  1554. WMITLV_GET_STRUCT_TLVLEN
  1555. (wmi_roam_chan_list_fixed_param));
  1556. chan_list_fp->vdev_id = vdev_id;
  1557. chan_list_fp->num_chan = chan_count;
  1558. if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
  1559. /* external app is controlling channel list */
  1560. chan_list_fp->chan_list_type =
  1561. WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
  1562. } else {
  1563. /* umac supplied occupied channel list in LFR */
  1564. chan_list_fp->chan_list_type =
  1565. WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
  1566. }
  1567. buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
  1568. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
  1569. (chan_list_fp->num_chan * sizeof(uint32_t)));
  1570. roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
  1571. WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
  1572. for (i = 0; ((i < chan_list_fp->num_chan) &&
  1573. (i < WMI_ROAM_MAX_CHANNELS)); i++) {
  1574. roam_chan_list_array[i] = chan_list[i];
  1575. WMI_LOGD("%d,", roam_chan_list_array[i]);
  1576. }
  1577. wmi_mtrace(WMI_ROAM_CHAN_LIST, NO_SESSION, 0);
  1578. status = wmi_unified_cmd_send(wmi_handle, buf,
  1579. len, WMI_ROAM_CHAN_LIST);
  1580. if (QDF_IS_STATUS_ERROR(status)) {
  1581. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
  1582. status);
  1583. goto error;
  1584. }
  1585. WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
  1586. return QDF_STATUS_SUCCESS;
  1587. error:
  1588. wmi_buf_free(buf);
  1589. return status;
  1590. }
  1591. /**
  1592. * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
  1593. * @wmi_handle: wmi handle
  1594. * @rssi_change_thresh: RSSI Change threshold
  1595. * @bcn_rssi_weight: beacon RSSI weight
  1596. * @vdev_id: vdev id
  1597. *
  1598. * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
  1599. *
  1600. * Return: CDF status
  1601. */
  1602. static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
  1603. uint32_t vdev_id,
  1604. int32_t rssi_change_thresh,
  1605. uint32_t bcn_rssi_weight,
  1606. uint32_t hirssi_delay_btw_scans)
  1607. {
  1608. wmi_buf_t buf = NULL;
  1609. QDF_STATUS status;
  1610. int len;
  1611. uint8_t *buf_ptr;
  1612. wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
  1613. /* Send rssi change parameters */
  1614. len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
  1615. buf = wmi_buf_alloc(wmi_handle, len);
  1616. if (!buf) {
  1617. return QDF_STATUS_E_NOMEM;
  1618. }
  1619. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1620. rssi_change_fp =
  1621. (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
  1622. WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
  1623. WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
  1624. WMITLV_GET_STRUCT_TLVLEN
  1625. (wmi_roam_scan_rssi_change_threshold_fixed_param));
  1626. /* fill in rssi change threshold (hysteresis) values */
  1627. rssi_change_fp->vdev_id = vdev_id;
  1628. rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
  1629. rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
  1630. rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
  1631. wmi_mtrace(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, NO_SESSION, 0);
  1632. status = wmi_unified_cmd_send(wmi_handle, buf,
  1633. len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
  1634. if (QDF_IS_STATUS_ERROR(status)) {
  1635. WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
  1636. status);
  1637. goto error;
  1638. }
  1639. WMI_LOGD(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
  1640. rssi_change_thresh, bcn_rssi_weight);
  1641. WMI_LOGD(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
  1642. return QDF_STATUS_SUCCESS;
  1643. error:
  1644. wmi_buf_free(buf);
  1645. return status;
  1646. }
  1647. /**
  1648. * send_per_roam_config_cmd_tlv() - set per roaming config to FW
  1649. * @wmi_handle: wmi handle
  1650. * @req_buf: per roam config buffer
  1651. *
  1652. * Return: QDF status
  1653. */
  1654. static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
  1655. struct wmi_per_roam_config_req *req_buf)
  1656. {
  1657. wmi_buf_t buf = NULL;
  1658. QDF_STATUS status;
  1659. int len;
  1660. uint8_t *buf_ptr;
  1661. wmi_roam_per_config_fixed_param *wmi_per_config;
  1662. len = sizeof(wmi_roam_per_config_fixed_param);
  1663. buf = wmi_buf_alloc(wmi_handle, len);
  1664. if (!buf) {
  1665. return QDF_STATUS_E_NOMEM;
  1666. }
  1667. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1668. wmi_per_config =
  1669. (wmi_roam_per_config_fixed_param *) buf_ptr;
  1670. WMITLV_SET_HDR(&wmi_per_config->tlv_header,
  1671. WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
  1672. WMITLV_GET_STRUCT_TLVLEN
  1673. (wmi_roam_per_config_fixed_param));
  1674. /* fill in per roam config values */
  1675. wmi_per_config->vdev_id = req_buf->vdev_id;
  1676. wmi_per_config->enable = req_buf->per_config.enable;
  1677. wmi_per_config->high_rate_thresh =
  1678. (req_buf->per_config.tx_high_rate_thresh << 16) |
  1679. (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
  1680. wmi_per_config->low_rate_thresh =
  1681. (req_buf->per_config.tx_low_rate_thresh << 16) |
  1682. (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
  1683. wmi_per_config->pkt_err_rate_thresh_pct =
  1684. (req_buf->per_config.tx_rate_thresh_percnt << 16) |
  1685. (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
  1686. wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
  1687. wmi_per_config->pkt_err_rate_mon_time =
  1688. (req_buf->per_config.tx_per_mon_time << 16) |
  1689. (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
  1690. wmi_per_config->min_candidate_rssi =
  1691. req_buf->per_config.min_candidate_rssi;
  1692. /* Send per roam config parameters */
  1693. wmi_mtrace(WMI_ROAM_PER_CONFIG_CMDID, NO_SESSION, 0);
  1694. status = wmi_unified_cmd_send(wmi_handle, buf,
  1695. len, WMI_ROAM_PER_CONFIG_CMDID);
  1696. if (QDF_IS_STATUS_ERROR(status)) {
  1697. WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
  1698. status);
  1699. wmi_buf_free(buf);
  1700. return status;
  1701. }
  1702. WMI_LOGD(FL("per roam enable=%d, vdev=%d"),
  1703. req_buf->per_config.enable, req_buf->vdev_id);
  1704. return QDF_STATUS_SUCCESS;
  1705. }
  1706. /**
  1707. * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
  1708. * configuration params
  1709. * @wmi_handle: wmi handler
  1710. * @limit_off_chan_param: pointer to wmi_off_chan_param
  1711. *
  1712. * Return: 0 for success and non zero for failure
  1713. */
  1714. static
  1715. QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
  1716. struct wmi_limit_off_chan_param *limit_off_chan_param)
  1717. {
  1718. wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
  1719. wmi_buf_t buf;
  1720. uint32_t len = sizeof(*cmd);
  1721. int err;
  1722. buf = wmi_buf_alloc(wmi_handle, len);
  1723. if (!buf) {
  1724. return QDF_STATUS_E_NOMEM;
  1725. }
  1726. cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
  1727. WMITLV_SET_HDR(&cmd->tlv_header,
  1728. WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
  1729. WMITLV_GET_STRUCT_TLVLEN(
  1730. wmi_vdev_limit_offchan_cmd_fixed_param));
  1731. cmd->vdev_id = limit_off_chan_param->vdev_id;
  1732. cmd->flags &= 0;
  1733. if (limit_off_chan_param->status)
  1734. cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
  1735. if (limit_off_chan_param->skip_dfs_chans)
  1736. cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
  1737. cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
  1738. cmd->rest_time = limit_off_chan_param->rest_time;
  1739. WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
  1740. __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
  1741. cmd->rest_time);
  1742. wmi_mtrace(WMI_VDEV_LIMIT_OFFCHAN_CMDID, cmd->vdev_id, 0);
  1743. err = wmi_unified_cmd_send(wmi_handle, buf,
  1744. len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
  1745. if (QDF_IS_STATUS_ERROR(err)) {
  1746. WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
  1747. wmi_buf_free(buf);
  1748. return QDF_STATUS_E_FAILURE;
  1749. }
  1750. return QDF_STATUS_SUCCESS;
  1751. }
  1752. #ifdef WLAN_FEATURE_FILS_SK
  1753. static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
  1754. struct hlp_params *params)
  1755. {
  1756. uint32_t len;
  1757. uint8_t *buf_ptr;
  1758. wmi_buf_t buf = NULL;
  1759. wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
  1760. len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
  1761. len += WMI_TLV_HDR_SIZE;
  1762. len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
  1763. buf = wmi_buf_alloc(wmi_handle, len);
  1764. if (!buf) {
  1765. return QDF_STATUS_E_NOMEM;
  1766. }
  1767. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1768. hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
  1769. WMITLV_SET_HDR(&hlp_params->tlv_header,
  1770. WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
  1771. WMITLV_GET_STRUCT_TLVLEN(
  1772. wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
  1773. hlp_params->vdev_id = params->vdev_id;
  1774. hlp_params->size = params->hlp_ie_len;
  1775. hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
  1776. buf_ptr += sizeof(*hlp_params);
  1777. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
  1778. round_up(params->hlp_ie_len,
  1779. sizeof(uint32_t)));
  1780. buf_ptr += WMI_TLV_HDR_SIZE;
  1781. qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
  1782. WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
  1783. hlp_params->vdev_id, hlp_params->size);
  1784. wmi_mtrace(WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID, NO_SESSION, 0);
  1785. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1786. WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
  1787. WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
  1788. wmi_buf_free(buf);
  1789. return QDF_STATUS_E_FAILURE;
  1790. }
  1791. return QDF_STATUS_SUCCESS;
  1792. }
  1793. void wmi_fils_sk_attach_tlv(wmi_unified_t wmi_handle)
  1794. {
  1795. struct wmi_ops *ops = wmi_handle->ops;
  1796. ops->send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv;
  1797. }
  1798. #endif /* WLAN_FEATURE_FILS_SK */
  1799. /*
  1800. * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
  1801. * @wmi_handle: wmi handle
  1802. * @params: pointer to wmi_btm_config
  1803. *
  1804. * Return: QDF_STATUS
  1805. */
  1806. static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
  1807. struct wmi_btm_config *params)
  1808. {
  1809. wmi_btm_config_fixed_param *cmd;
  1810. wmi_buf_t buf;
  1811. uint32_t len;
  1812. len = sizeof(*cmd);
  1813. buf = wmi_buf_alloc(wmi_handle, len);
  1814. if (!buf) {
  1815. return QDF_STATUS_E_NOMEM;
  1816. }
  1817. cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
  1818. WMITLV_SET_HDR(&cmd->tlv_header,
  1819. WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
  1820. WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
  1821. cmd->vdev_id = params->vdev_id;
  1822. cmd->flags = params->btm_offload_config;
  1823. cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
  1824. cmd->solicited_timeout_ms = params->btm_solicited_timeout;
  1825. cmd->stick_time_seconds = params->btm_sticky_time;
  1826. wmi_mtrace(WMI_ROAM_BTM_CONFIG_CMDID, cmd->vdev_id, 0);
  1827. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1828. WMI_ROAM_BTM_CONFIG_CMDID)) {
  1829. WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
  1830. __func__);
  1831. wmi_buf_free(buf);
  1832. return QDF_STATUS_E_FAILURE;
  1833. }
  1834. return QDF_STATUS_SUCCESS;
  1835. }
  1836. /**
  1837. * send_roam_bss_load_config_tlv() - send roam load bss trigger configuration
  1838. * @wmi_handle: wmi handle
  1839. * @parms: pointer to wmi_bss_load_config
  1840. *
  1841. * This function sends the roam load bss trigger configuration to fw.
  1842. * the bss_load_threshold parameter is used to configure the maximum
  1843. * bss load percentage, above which the firmware should trigger roaming
  1844. *
  1845. * Return: QDF status
  1846. */
  1847. static QDF_STATUS
  1848. send_roam_bss_load_config_tlv(wmi_unified_t wmi_handle,
  1849. struct wmi_bss_load_config *params)
  1850. {
  1851. wmi_roam_bss_load_config_cmd_fixed_param *cmd;
  1852. wmi_buf_t buf;
  1853. uint32_t len;
  1854. len = sizeof(*cmd);
  1855. buf = wmi_buf_alloc(wmi_handle, len);
  1856. if (!buf)
  1857. return QDF_STATUS_E_NOMEM;
  1858. cmd = (wmi_roam_bss_load_config_cmd_fixed_param *)wmi_buf_data(buf);
  1859. WMITLV_SET_HDR(
  1860. &cmd->tlv_header,
  1861. WMITLV_TAG_STRUC_wmi_roam_bss_load_config_cmd_fixed_param,
  1862. WMITLV_GET_STRUCT_TLVLEN(wmi_roam_bss_load_config_cmd_fixed_param));
  1863. cmd->vdev_id = params->vdev_id;
  1864. cmd->bss_load_threshold = params->bss_load_threshold;
  1865. cmd->monitor_time_window = params->bss_load_sample_time;
  1866. wmi_mtrace(WMI_ROAM_BSS_LOAD_CONFIG_CMDID, cmd->vdev_id, 0);
  1867. if (wmi_unified_cmd_send(wmi_handle, buf, len,
  1868. WMI_ROAM_BSS_LOAD_CONFIG_CMDID)) {
  1869. WMI_LOGE("%s: failed to send WMI_ROAM_BSS_LOAD_CONFIG_CMDID ",
  1870. __func__);
  1871. wmi_buf_free(buf);
  1872. return QDF_STATUS_E_FAILURE;
  1873. }
  1874. return QDF_STATUS_SUCCESS;
  1875. }
  1876. /**
  1877. * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
  1878. * @wmi_handle: wmi handler
  1879. * @params: pointer to 11k offload params
  1880. *
  1881. * Return: 0 for success and non zero for failure
  1882. */
  1883. static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
  1884. struct wmi_11k_offload_params *params)
  1885. {
  1886. wmi_11k_offload_report_fixed_param *cmd;
  1887. wmi_buf_t buf;
  1888. QDF_STATUS status;
  1889. uint8_t *buf_ptr;
  1890. wmi_neighbor_report_11k_offload_tlv_param
  1891. *neighbor_report_offload_params;
  1892. wmi_neighbor_report_offload *neighbor_report_offload;
  1893. uint32_t len = sizeof(*cmd);
  1894. if (params->offload_11k_bitmask &
  1895. WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
  1896. len += WMI_TLV_HDR_SIZE +
  1897. sizeof(wmi_neighbor_report_11k_offload_tlv_param);
  1898. buf = wmi_buf_alloc(wmi_handle, len);
  1899. if (!buf) {
  1900. return QDF_STATUS_E_NOMEM;
  1901. }
  1902. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1903. cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
  1904. WMITLV_SET_HDR(&cmd->tlv_header,
  1905. WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
  1906. WMITLV_GET_STRUCT_TLVLEN(
  1907. wmi_11k_offload_report_fixed_param));
  1908. cmd->vdev_id = params->vdev_id;
  1909. cmd->offload_11k = params->offload_11k_bitmask;
  1910. if (params->offload_11k_bitmask &
  1911. WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
  1912. buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
  1913. WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
  1914. sizeof(wmi_neighbor_report_11k_offload_tlv_param));
  1915. buf_ptr += WMI_TLV_HDR_SIZE;
  1916. neighbor_report_offload_params =
  1917. (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
  1918. WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
  1919. WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
  1920. WMITLV_GET_STRUCT_TLVLEN(
  1921. wmi_neighbor_report_11k_offload_tlv_param));
  1922. neighbor_report_offload = &neighbor_report_offload_params->
  1923. neighbor_rep_ofld_params;
  1924. neighbor_report_offload->time_offset =
  1925. params->neighbor_report_params.time_offset;
  1926. neighbor_report_offload->low_rssi_offset =
  1927. params->neighbor_report_params.low_rssi_offset;
  1928. neighbor_report_offload->bmiss_count_trigger =
  1929. params->neighbor_report_params.bmiss_count_trigger;
  1930. neighbor_report_offload->per_threshold_offset =
  1931. params->neighbor_report_params.per_threshold_offset;
  1932. neighbor_report_offload->neighbor_report_cache_timeout =
  1933. params->neighbor_report_params.
  1934. neighbor_report_cache_timeout;
  1935. neighbor_report_offload->max_neighbor_report_req_cap =
  1936. params->neighbor_report_params.
  1937. max_neighbor_report_req_cap;
  1938. neighbor_report_offload->ssid.ssid_len =
  1939. params->neighbor_report_params.ssid.length;
  1940. qdf_mem_copy(neighbor_report_offload->ssid.ssid,
  1941. &params->neighbor_report_params.ssid.mac_ssid,
  1942. neighbor_report_offload->ssid.ssid_len);
  1943. }
  1944. wmi_mtrace(WMI_11K_OFFLOAD_REPORT_CMDID, cmd->vdev_id, 0);
  1945. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  1946. WMI_11K_OFFLOAD_REPORT_CMDID);
  1947. if (status != QDF_STATUS_SUCCESS) {
  1948. WMI_LOGE("%s: failed to send 11k offload command %d",
  1949. __func__, status);
  1950. wmi_buf_free(buf);
  1951. }
  1952. return status;
  1953. }
  1954. /**
  1955. * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
  1956. * command
  1957. * @wmi_handle: wmi handler
  1958. * @params: pointer to neighbor report invoke params
  1959. *
  1960. * Return: 0 for success and non zero for failure
  1961. */
  1962. static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
  1963. struct wmi_invoke_neighbor_report_params *params)
  1964. {
  1965. wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
  1966. wmi_buf_t buf;
  1967. QDF_STATUS status;
  1968. uint8_t *buf_ptr;
  1969. uint32_t len = sizeof(*cmd);
  1970. buf = wmi_buf_alloc(wmi_handle, len);
  1971. if (!buf) {
  1972. return QDF_STATUS_E_NOMEM;
  1973. }
  1974. buf_ptr = (uint8_t *) wmi_buf_data(buf);
  1975. cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
  1976. WMITLV_SET_HDR(&cmd->tlv_header,
  1977. WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
  1978. WMITLV_GET_STRUCT_TLVLEN(
  1979. wmi_11k_offload_invoke_neighbor_report_fixed_param));
  1980. cmd->vdev_id = params->vdev_id;
  1981. cmd->flags = params->send_resp_to_host;
  1982. cmd->ssid.ssid_len = params->ssid.length;
  1983. qdf_mem_copy(cmd->ssid.ssid,
  1984. &params->ssid.mac_ssid,
  1985. cmd->ssid.ssid_len);
  1986. wmi_mtrace(WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID, cmd->vdev_id, 0);
  1987. status = wmi_unified_cmd_send(wmi_handle, buf, len,
  1988. WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
  1989. if (status != QDF_STATUS_SUCCESS) {
  1990. WMI_LOGE("%s: failed to send invoke neighbor report command %d",
  1991. __func__, status);
  1992. wmi_buf_free(buf);
  1993. }
  1994. return status;
  1995. }
  1996. void wmi_roam_attach_tlv(wmi_unified_t wmi_handle)
  1997. {
  1998. struct wmi_ops *ops = wmi_handle->ops;
  1999. ops->send_roam_scan_offload_rssi_thresh_cmd =
  2000. send_roam_scan_offload_rssi_thresh_cmd_tlv;
  2001. ops->send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv;
  2002. ops->send_roam_scan_filter_cmd =
  2003. send_roam_scan_filter_cmd_tlv;
  2004. ops->send_roam_scan_offload_mode_cmd =
  2005. send_roam_scan_offload_mode_cmd_tlv;
  2006. ops->send_roam_scan_offload_ap_profile_cmd =
  2007. send_roam_scan_offload_ap_profile_cmd_tlv;
  2008. ops->send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv;
  2009. ops->send_roam_scan_offload_scan_period_cmd =
  2010. send_roam_scan_offload_scan_period_cmd_tlv;
  2011. ops->send_roam_scan_offload_chan_list_cmd =
  2012. send_roam_scan_offload_chan_list_cmd_tlv;
  2013. ops->send_roam_scan_offload_rssi_change_cmd =
  2014. send_roam_scan_offload_rssi_change_cmd_tlv;
  2015. ops->send_per_roam_config_cmd = send_per_roam_config_cmd_tlv;
  2016. ops->send_limit_off_chan_cmd = send_limit_off_chan_cmd_tlv;
  2017. ops->send_btm_config = send_btm_config_cmd_tlv;
  2018. ops->send_offload_11k_cmd = send_offload_11k_cmd_tlv;
  2019. ops->send_invoke_neighbor_report_cmd =
  2020. send_invoke_neighbor_report_cmd_tlv;
  2021. ops->send_roam_bss_load_config = send_roam_bss_load_config_tlv;
  2022. wmi_lfr_subnet_detection_attach_tlv(wmi_handle);
  2023. wmi_rssi_monitor_attach_tlv(wmi_handle);
  2024. wmi_ese_attach_tlv(wmi_handle);
  2025. wmi_roam_offload_attach_tlv(wmi_handle);
  2026. wmi_fils_sk_attach_tlv(wmi_handle);
  2027. }