target_if_cfr.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /*
  2. * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include <target_if_cfr.h>
  20. #include <wlan_tgt_def_config.h>
  21. #include <target_type.h>
  22. #include <hif_hw_version.h>
  23. #include <target_if.h>
  24. #include <wlan_lmac_if_def.h>
  25. #include <wlan_osif_priv.h>
  26. #include <init_deinit_lmac.h>
  27. #include <wlan_cfr_utils_api.h>
  28. #include <wlan_objmgr_pdev_obj.h>
  29. #include <target_if_cfr_enh.h>
  30. #ifdef CFR_USE_FIXED_FOLDER
  31. #include "target_if_cfr_6490.h"
  32. #include "target_if_cfr_adrastea.h"
  33. #include "wlan_reg_services_api.h"
  34. #else
  35. #include <target_if_cfr_dbr.h>
  36. #endif
  37. int target_if_cfr_stop_capture(struct wlan_objmgr_pdev *pdev,
  38. struct wlan_objmgr_peer *peer)
  39. {
  40. struct peer_cfr *pe;
  41. struct peer_cfr_params param = {0};
  42. struct wmi_unified *pdev_wmi_handle = NULL;
  43. struct wlan_objmgr_vdev *vdev = {0};
  44. struct pdev_cfr *pdev_cfrobj;
  45. int retv = 0;
  46. pe = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_UMAC_COMP_CFR);
  47. if (pe == NULL)
  48. return -EINVAL;
  49. pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  50. if (!pdev_wmi_handle) {
  51. cfr_err("pdev wmi handle NULL");
  52. return -EINVAL;
  53. }
  54. vdev = wlan_peer_get_vdev(peer);
  55. qdf_mem_set(&param, sizeof(param), 0);
  56. param.request = PEER_CFR_CAPTURE_DISABLE;
  57. param.macaddr = wlan_peer_get_macaddr(peer);
  58. param.vdev_id = wlan_vdev_get_id(vdev);
  59. param.periodicity = pe->period;
  60. param.bandwidth = pe->bandwidth;
  61. param.capture_method = pe->capture_method;
  62. retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, &param);
  63. pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  64. WLAN_UMAC_COMP_CFR);
  65. if (!pdev_cfrobj) {
  66. cfr_err("pdev object for CFR is null");
  67. return -EINVAL;
  68. }
  69. cfr_err("CFR capture stats for this capture:");
  70. cfr_err("DBR event count = %llu, Tx event count = %llu "
  71. "Release count = %llu",
  72. pdev_cfrobj->dbr_evt_cnt, pdev_cfrobj->tx_evt_cnt,
  73. pdev_cfrobj->release_cnt);
  74. cfr_err("tx_peer_status_cfr_fail = %llu",
  75. pdev_cfrobj->tx_peer_status_cfr_fail = 0);
  76. cfr_err("tx_evt_status_cfr_fail = %llu",
  77. pdev_cfrobj->tx_evt_status_cfr_fail);
  78. cfr_err("tx_dbr_cookie_lookup_fail = %llu",
  79. pdev_cfrobj->tx_dbr_cookie_lookup_fail);
  80. pdev_cfrobj->dbr_evt_cnt = 0;
  81. pdev_cfrobj->tx_evt_cnt = 0;
  82. pdev_cfrobj->release_cnt = 0;
  83. pdev_cfrobj->tx_peer_status_cfr_fail = 0;
  84. pdev_cfrobj->tx_evt_status_cfr_fail = 0;
  85. pdev_cfrobj->tx_dbr_cookie_lookup_fail = 0;
  86. return retv;
  87. }
  88. int target_if_cfr_start_capture(struct wlan_objmgr_pdev *pdev,
  89. struct wlan_objmgr_peer *peer,
  90. struct cfr_capture_params *cfr_params)
  91. {
  92. struct peer_cfr_params param = {0};
  93. struct wmi_unified *pdev_wmi_handle = NULL;
  94. struct wlan_objmgr_vdev *vdev;
  95. int retv = 0;
  96. pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  97. if (!pdev_wmi_handle) {
  98. cfr_err("pdev wmi handle NULL");
  99. return -EINVAL;
  100. }
  101. vdev = wlan_peer_get_vdev(peer);
  102. qdf_mem_set(&param, sizeof(param), 0);
  103. param.request = PEER_CFR_CAPTURE_ENABLE;
  104. param.macaddr = wlan_peer_get_macaddr(peer);
  105. param.vdev_id = wlan_vdev_get_id(vdev);
  106. param.periodicity = cfr_params->period;
  107. param.bandwidth = cfr_params->bandwidth;
  108. param.capture_method = cfr_params->method;
  109. retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, &param);
  110. return retv;
  111. }
  112. #ifdef ENABLE_HOST_TO_TARGET_CONVERSION
  113. int target_if_cfr_periodic_peer_cfr_enable(struct wlan_objmgr_pdev *pdev,
  114. uint32_t param_value)
  115. {
  116. struct pdev_params pparam;
  117. uint32_t pdev_id;
  118. struct wmi_unified *pdev_wmi_handle = NULL;
  119. pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
  120. if (pdev_id < 0)
  121. return -EINVAL;
  122. pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  123. if (!pdev_wmi_handle) {
  124. cfr_err("pdev wmi handle NULL");
  125. return -EINVAL;
  126. }
  127. qdf_mem_set(&pparam, sizeof(pparam), 0);
  128. pparam.param_id = wmi_pdev_param_per_peer_prd_cfr_enable;
  129. pparam.param_value = param_value;
  130. return wmi_unified_pdev_param_send(pdev_wmi_handle,
  131. &pparam, pdev_id);
  132. }
  133. #else
  134. int target_if_cfr_periodic_peer_cfr_enable(struct wlan_objmgr_pdev *pdev,
  135. uint32_t param_value)
  136. {
  137. struct pdev_params pparam;
  138. uint32_t pdev_id;
  139. struct wmi_unified *pdev_wmi_handle = NULL;
  140. pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
  141. if (pdev_id < 0)
  142. return -EINVAL;
  143. pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  144. if (!pdev_wmi_handle) {
  145. cfr_err("pdev wmi handle NULL");
  146. return -EINVAL;
  147. }
  148. qdf_mem_set(&pparam, sizeof(pparam), 0);
  149. pparam.param_id = WMI_PDEV_PARAM_PER_PEER_PERIODIC_CFR_ENABLE;
  150. pparam.param_value = param_value;
  151. return wmi_unified_pdev_param_send(pdev_wmi_handle,
  152. &pparam, pdev_id);
  153. }
  154. #endif
  155. int target_if_cfr_enable_cfr_timer(struct wlan_objmgr_pdev *pdev,
  156. uint32_t cfr_timer)
  157. {
  158. struct pdev_cfr *pa;
  159. int retval;
  160. pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
  161. if (pa == NULL)
  162. return QDF_STATUS_E_FAILURE;
  163. if (!cfr_timer) {
  164. /* disable periodic cfr capture */
  165. retval =
  166. target_if_cfr_periodic_peer_cfr_enable(pdev,
  167. WMI_HOST_PEER_CFR_TIMER_DISABLE);
  168. if (retval == QDF_STATUS_SUCCESS)
  169. pa->cfr_timer_enable = 0;
  170. } else {
  171. /* enable periodic cfr capture (default base timer is 10ms ) */
  172. retval =
  173. target_if_cfr_periodic_peer_cfr_enable(pdev,
  174. WMI_HOST_PEER_CFR_TIMER_ENABLE);
  175. if (retval == QDF_STATUS_SUCCESS)
  176. pa->cfr_timer_enable = 1;
  177. }
  178. return retval;
  179. }
  180. int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc)
  181. {
  182. uint32_t target_type = 0;
  183. struct wlan_lmac_if_target_tx_ops *target_type_tx_ops;
  184. struct wlan_lmac_if_tx_ops *tx_ops;
  185. tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
  186. if (!tx_ops) {
  187. cfr_err("tx_ops is NULL");
  188. return target_type;
  189. }
  190. target_type_tx_ops = &tx_ops->target_tx_ops;
  191. if (target_type_tx_ops->tgt_get_tgt_type)
  192. target_type = target_type_tx_ops->tgt_get_tgt_type(psoc);
  193. return target_type;
  194. }
  195. void target_if_cfr_fill_header(struct csi_cfr_header *hdr,
  196. bool is_wifi_2_0,
  197. uint32_t target_type,
  198. bool is_rcc)
  199. {
  200. hdr->cmn.start_magic_num = 0xDEADBEAF;
  201. hdr->cmn.vendorid = 0x8cfdf0;
  202. hdr->cmn.pltform_type = CFR_PLATFORM_TYPE_ARM;
  203. hdr->cmn.cfr_metadata_len = CFR_META_DATA_LEN;
  204. hdr->cmn.cfr_data_version = CFR_DATA_VERSION_1;
  205. if (is_wifi_2_0) {
  206. hdr->cmn.cfr_metadata_version = CFR_META_VERSION_1;
  207. if (target_type == TARGET_TYPE_IPQ4019)
  208. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_DAKOTA;
  209. else if (target_type == TARGET_TYPE_QCA9888)
  210. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_BESRA;
  211. else if (target_type == TARGET_TYPE_QCA9984)
  212. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_CASCADE;
  213. else
  214. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_NONE;
  215. } else if (target_type == TARGET_TYPE_QCA8074V2) {
  216. hdr->cmn.cfr_metadata_version = CFR_META_VERSION_6;
  217. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_HKV2;
  218. } else if (target_type == TARGET_TYPE_QCA9574) {
  219. hdr->cmn.cfr_metadata_version = CFR_META_VERSION_6;
  220. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_ALDER;
  221. } else {
  222. if (target_type == TARGET_TYPE_QCN9000 ||
  223. target_type == TARGET_TYPE_QCN9224)
  224. hdr->cmn.cfr_metadata_version = CFR_META_VERSION_7;
  225. else if ((target_type == TARGET_TYPE_QCA6018) ||
  226. ((target_type == TARGET_TYPE_QCA5018) && (!is_rcc)))
  227. hdr->cmn.cfr_metadata_version = CFR_META_VERSION_5;
  228. else
  229. hdr->cmn.cfr_metadata_version = CFR_META_VERSION_3;
  230. if (target_type == TARGET_TYPE_QCN9000)
  231. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_PINE;
  232. else if (target_type == TARGET_TYPE_QCA5018)
  233. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_MAPLE;
  234. else if (target_type == TARGET_TYPE_QCN6122)
  235. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_SPRUCE;
  236. else if (target_type == TARGET_TYPE_QCN9224)
  237. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_WAIKIKI;
  238. else
  239. hdr->cmn.chip_type = CFR_CAPTURE_RADIO_CYP;
  240. }
  241. }
  242. #ifdef CFR_USE_FIXED_FOLDER
  243. static QDF_STATUS target_if_cfr_init_target(struct wlan_objmgr_psoc *psoc,
  244. struct wlan_objmgr_pdev *pdev,
  245. uint32_t target)
  246. {
  247. struct pdev_cfr *cfr_pdev;
  248. struct psoc_cfr *cfr_psoc;
  249. struct wmi_unified *wmi_handle = NULL;
  250. bool cfr_capable;
  251. QDF_STATUS status;
  252. if (!psoc || !pdev) {
  253. cfr_err("null pdev or psoc");
  254. return QDF_STATUS_E_FAILURE;
  255. }
  256. cfr_pdev = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  257. WLAN_UMAC_COMP_CFR);
  258. if (!cfr_pdev) {
  259. cfr_err("null pdev cfr");
  260. return QDF_STATUS_E_FAILURE;
  261. }
  262. cfr_psoc = wlan_objmgr_psoc_get_comp_private_obj(psoc,
  263. WLAN_UMAC_COMP_CFR);
  264. if (!cfr_psoc) {
  265. cfr_err("null psoc cfr");
  266. return QDF_STATUS_E_FAILURE;
  267. }
  268. wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  269. if (!wmi_handle) {
  270. cfr_err("null wmi handle");
  271. return QDF_STATUS_E_FAILURE;
  272. }
  273. if (wlan_cfr_is_feature_disabled(pdev)) {
  274. cfr_pdev->is_cfr_capable = 0;
  275. cfr_psoc->is_cfr_capable = 0;
  276. cfr_info("cfr disabled");
  277. return QDF_STATUS_SUCCESS;
  278. }
  279. cfr_capable = wmi_service_enabled(wmi_handle,
  280. wmi_service_cfr_capture_support);
  281. cfr_pdev->is_cfr_capable = cfr_capable;
  282. cfr_psoc->is_cfr_capable = cfr_capable;
  283. if (!cfr_capable) {
  284. cfr_err("FW doesn't support CFR");
  285. return QDF_STATUS_SUCCESS;
  286. }
  287. status = cfr_enh_init_pdev(psoc, pdev);
  288. if (target == TARGET_TYPE_QCA6490)
  289. cfr_pdev->chip_type = CFR_CAPTURE_RADIO_HSP;
  290. else if (target == TARGET_TYPE_QCA6750)
  291. cfr_pdev->chip_type = CFR_CAPTURE_RADIO_MOSELLE;
  292. return status;
  293. }
  294. static QDF_STATUS target_if_cfr_deinit_target(struct wlan_objmgr_psoc *psoc,
  295. struct wlan_objmgr_pdev *pdev)
  296. {
  297. struct pdev_cfr *pcfr;
  298. if (!psoc || !pdev) {
  299. cfr_err("null pdev or psoc");
  300. return QDF_STATUS_E_FAILURE;
  301. }
  302. pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  303. WLAN_UMAC_COMP_CFR);
  304. if (!pcfr) {
  305. cfr_err("null pdev cfr");
  306. return QDF_STATUS_E_FAILURE;
  307. }
  308. if (!pcfr->is_cfr_capable) {
  309. cfr_info("cfr disabled or FW not support");
  310. return QDF_STATUS_SUCCESS;
  311. }
  312. return cfr_enh_deinit_pdev(psoc, pdev);
  313. }
  314. QDF_STATUS
  315. target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc,
  316. struct wlan_objmgr_pdev *pdev)
  317. {
  318. uint32_t target_type;
  319. QDF_STATUS status;
  320. target_type = target_if_cfr_get_target_type(psoc);
  321. if (target_type == TARGET_TYPE_QCA6490 ||
  322. target_type == TARGET_TYPE_QCA6750) {
  323. status = target_if_cfr_init_target(psoc,
  324. pdev, target_type);
  325. } else if (target_type == TARGET_TYPE_ADRASTEA) {
  326. status = cfr_adrastea_init_pdev(psoc, pdev);
  327. } else {
  328. cfr_info("unsupport chip");
  329. status = QDF_STATUS_SUCCESS;
  330. }
  331. return status;
  332. }
  333. QDF_STATUS
  334. target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc,
  335. struct wlan_objmgr_pdev *pdev)
  336. {
  337. uint32_t target_type;
  338. QDF_STATUS status;
  339. target_type = target_if_cfr_get_target_type(psoc);
  340. if (target_type == TARGET_TYPE_QCA6490 ||
  341. target_type == TARGET_TYPE_QCA6750) {
  342. status = target_if_cfr_deinit_target(psoc, pdev);
  343. } else if (target_type == TARGET_TYPE_ADRASTEA) {
  344. status = cfr_adrastea_deinit_pdev(psoc, pdev);
  345. } else {
  346. cfr_info("unsupport chip");
  347. status = QDF_STATUS_SUCCESS;
  348. }
  349. return status;
  350. }
  351. #else
  352. QDF_STATUS
  353. target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc,
  354. struct wlan_objmgr_pdev *pdev)
  355. {
  356. uint32_t target_type;
  357. struct pdev_cfr *pa;
  358. struct psoc_cfr *cfr_sc;
  359. if (wlan_cfr_is_feature_disabled(pdev)) {
  360. cfr_err("cfr is disabled");
  361. return QDF_STATUS_E_NOSUPPORT;
  362. }
  363. pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
  364. if (pa == NULL)
  365. return QDF_STATUS_E_FAILURE;
  366. /* Reset unassociated entries for every init */
  367. qdf_mem_zero(&pa->unassoc_pool[0], MAX_CFR_ENABLED_CLIENTS *
  368. sizeof(struct unassoc_pool_entry));
  369. cfr_sc = wlan_objmgr_psoc_get_comp_private_obj(psoc,
  370. WLAN_UMAC_COMP_CFR);
  371. if (cfr_sc == NULL)
  372. return QDF_STATUS_E_FAILURE;
  373. target_type = target_if_cfr_get_target_type(psoc);
  374. if ((target_type == TARGET_TYPE_QCA8074V2) ||
  375. (target_type == TARGET_TYPE_QCA9574)) {
  376. pa->is_cfr_capable = cfr_sc->is_cfr_capable;
  377. return cfr_dbr_init_pdev(psoc, pdev);
  378. } else if ((target_type == TARGET_TYPE_IPQ4019) ||
  379. (target_type == TARGET_TYPE_QCA9984) ||
  380. (target_type == TARGET_TYPE_QCA9888)) {
  381. pa->is_cfr_capable = cfr_sc->is_cfr_capable;
  382. return cfr_wifi2_0_init_pdev(psoc, pdev);
  383. } else if ((target_type == TARGET_TYPE_QCA6018) ||
  384. (target_type == TARGET_TYPE_QCN9000) ||
  385. (target_type == TARGET_TYPE_QCN6122) ||
  386. (target_type == TARGET_TYPE_QCA5018)) {
  387. pa->is_cfr_capable = cfr_sc->is_cfr_capable;
  388. return cfr_enh_init_pdev(psoc, pdev);
  389. } else
  390. return QDF_STATUS_E_NOSUPPORT;
  391. }
  392. QDF_STATUS
  393. target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc,
  394. struct wlan_objmgr_pdev *pdev)
  395. {
  396. uint32_t target_type;
  397. if (wlan_cfr_is_feature_disabled(pdev)) {
  398. cfr_err("cfr is disabled");
  399. return QDF_STATUS_E_NOSUPPORT;
  400. }
  401. target_type = target_if_cfr_get_target_type(psoc);
  402. if ((target_type == TARGET_TYPE_QCA8074V2) ||
  403. (target_type == TARGET_TYPE_QCA9574)) {
  404. return cfr_dbr_deinit_pdev(psoc, pdev);
  405. } else if ((target_type == TARGET_TYPE_IPQ4019) ||
  406. (target_type == TARGET_TYPE_QCA9984) ||
  407. (target_type == TARGET_TYPE_QCA9888)) {
  408. return cfr_wifi2_0_deinit_pdev(psoc, pdev);
  409. } else if ((target_type == TARGET_TYPE_QCA6018) ||
  410. (target_type == TARGET_TYPE_QCN9000) ||
  411. (target_type == TARGET_TYPE_QCN6122) ||
  412. (target_type == TARGET_TYPE_QCA5018)) {
  413. return cfr_enh_deinit_pdev(psoc, pdev);
  414. } else
  415. return QDF_STATUS_E_NOSUPPORT;
  416. }
  417. #endif
  418. #ifdef WLAN_ENH_CFR_ENABLE
  419. #if defined(QCA_WIFI_QCA6490) || defined(QCA_WIFI_WCN7850)
  420. static uint8_t target_if_cfr_get_mac_id(struct wlan_objmgr_pdev *pdev)
  421. {
  422. struct wlan_objmgr_vdev *vdev;
  423. struct wlan_channel *bss_chan;
  424. struct pdev_cfr *pcfr;
  425. uint8_t mac_id = 0;
  426. if (!pdev) {
  427. cfr_err("null pdev");
  428. return mac_id;
  429. }
  430. mac_id = wlan_objmgr_pdev_get_pdev_id(pdev);
  431. pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
  432. if (!pcfr) {
  433. cfr_err("null pcfr");
  434. return mac_id;
  435. }
  436. if (pcfr->rcc_param.vdev_id == CFR_INVALID_VDEV_ID)
  437. return mac_id;
  438. vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev,
  439. pcfr->rcc_param.vdev_id,
  440. WLAN_CFR_ID);
  441. if (!vdev) {
  442. cfr_err("null vdev");
  443. return mac_id;
  444. }
  445. bss_chan = wlan_vdev_mlme_get_bss_chan(vdev);
  446. if (!bss_chan) {
  447. cfr_info("null bss chan");
  448. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  449. return mac_id;
  450. }
  451. cfr_debug("bss freq %d", bss_chan->ch_freq);
  452. if (wlan_reg_is_24ghz_ch_freq(bss_chan->ch_freq))
  453. mac_id = CFR_MAC_ID_24G;
  454. else
  455. mac_id = CFR_MAC_ID_5G;
  456. pcfr->rcc_param.srng_id = mac_id;
  457. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  458. return mac_id;
  459. }
  460. static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev)
  461. {
  462. return target_if_cfr_get_mac_id(pdev);
  463. }
  464. #else
  465. static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev)
  466. {
  467. return wlan_objmgr_pdev_get_pdev_id(pdev);
  468. }
  469. #endif /* QCA_WIFI_QCA6490 */
  470. QDF_STATUS target_if_cfr_config_rcc(struct wlan_objmgr_pdev *pdev,
  471. struct cfr_rcc_param *rcc_info)
  472. {
  473. QDF_STATUS status;
  474. struct wmi_unified *pdev_wmi_handle = NULL;
  475. pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  476. if (!pdev_wmi_handle) {
  477. cfr_err("pdev_wmi_handle is null");
  478. return QDF_STATUS_E_NULL_VALUE;
  479. }
  480. rcc_info->pdev_id = target_if_cfr_get_pdev_id(pdev);
  481. rcc_info->num_grp_tlvs =
  482. count_set_bits(rcc_info->modified_in_curr_session);
  483. status = wmi_unified_send_cfr_rcc_cmd(pdev_wmi_handle, rcc_info);
  484. return status;
  485. }
  486. void target_if_cfr_default_ta_ra_config(struct cfr_rcc_param *rcc_info,
  487. bool allvalid, uint16_t reset_cfg)
  488. {
  489. struct ta_ra_cfr_cfg *curr_cfg = NULL;
  490. int grp_id;
  491. unsigned long bitmap = reset_cfg;
  492. uint8_t def_mac[QDF_MAC_ADDR_SIZE] = {0xFF, 0xFF, 0xFF,
  493. 0xFF, 0xFF, 0xFF};
  494. uint8_t null_mac[QDF_MAC_ADDR_SIZE] = {0x00, 0x00, 0x00,
  495. 0x00, 0x00, 0x00};
  496. for (grp_id = 0; grp_id < MAX_TA_RA_ENTRIES; grp_id++) {
  497. if (qdf_test_bit(grp_id, &bitmap)) {
  498. curr_cfg = &rcc_info->curr[grp_id];
  499. qdf_mem_copy(curr_cfg->tx_addr,
  500. null_mac, QDF_MAC_ADDR_SIZE);
  501. qdf_mem_copy(curr_cfg->tx_addr_mask,
  502. def_mac, QDF_MAC_ADDR_SIZE);
  503. qdf_mem_copy(curr_cfg->rx_addr,
  504. null_mac, QDF_MAC_ADDR_SIZE);
  505. qdf_mem_copy(curr_cfg->rx_addr_mask,
  506. def_mac, QDF_MAC_ADDR_SIZE);
  507. curr_cfg->bw = 0xf;
  508. curr_cfg->nss = 0xff;
  509. curr_cfg->mgmt_subtype_filter = 0;
  510. curr_cfg->ctrl_subtype_filter = 0;
  511. curr_cfg->data_subtype_filter = 0;
  512. if (!allvalid) {
  513. curr_cfg->valid_ta = 0;
  514. curr_cfg->valid_ta_mask = 0;
  515. curr_cfg->valid_ra = 0;
  516. curr_cfg->valid_ra_mask = 0;
  517. curr_cfg->valid_bw_mask = 0;
  518. curr_cfg->valid_nss_mask = 0;
  519. curr_cfg->valid_mgmt_subtype = 0;
  520. curr_cfg->valid_ctrl_subtype = 0;
  521. curr_cfg->valid_data_subtype = 0;
  522. } else {
  523. curr_cfg->valid_ta = 1;
  524. curr_cfg->valid_ta_mask = 1;
  525. curr_cfg->valid_ra = 1;
  526. curr_cfg->valid_ra_mask = 1;
  527. curr_cfg->valid_bw_mask = 1;
  528. curr_cfg->valid_nss_mask = 1;
  529. curr_cfg->valid_mgmt_subtype = 1;
  530. curr_cfg->valid_ctrl_subtype = 1;
  531. curr_cfg->valid_data_subtype = 1;
  532. }
  533. }
  534. }
  535. }
  536. #endif
  537. #ifdef WLAN_ENH_CFR_ENABLE
  538. #ifdef CFR_USE_FIXED_FOLDER
  539. static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  540. {
  541. tx_ops->cfr_tx_ops.cfr_subscribe_ppdu_desc =
  542. target_if_cfr_subscribe_ppdu_desc;
  543. }
  544. #else
  545. static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  546. {
  547. }
  548. #endif /* CFR_USE_FIXED_FOLDER */
  549. static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  550. {
  551. tx_ops->cfr_tx_ops.cfr_config_rcc =
  552. target_if_cfr_config_rcc;
  553. tx_ops->cfr_tx_ops.cfr_start_lut_timer =
  554. target_if_cfr_start_lut_age_timer;
  555. tx_ops->cfr_tx_ops.cfr_stop_lut_timer =
  556. target_if_cfr_stop_lut_age_timer;
  557. tx_ops->cfr_tx_ops.cfr_default_ta_ra_cfg =
  558. target_if_cfr_default_ta_ra_config;
  559. tx_ops->cfr_tx_ops.cfr_dump_lut_enh =
  560. target_if_cfr_dump_lut_enh;
  561. tx_ops->cfr_tx_ops.cfr_rx_tlv_process =
  562. target_if_cfr_rx_tlv_process;
  563. tx_ops->cfr_tx_ops.cfr_update_global_cfg =
  564. target_if_cfr_update_global_cfg;
  565. target_if_enh_cfr_add_ops(tx_ops);
  566. }
  567. #else
  568. static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  569. {
  570. }
  571. #endif
  572. void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
  573. {
  574. tx_ops->cfr_tx_ops.cfr_init_pdev =
  575. target_if_cfr_init_pdev;
  576. tx_ops->cfr_tx_ops.cfr_deinit_pdev =
  577. target_if_cfr_deinit_pdev;
  578. tx_ops->cfr_tx_ops.cfr_enable_cfr_timer =
  579. target_if_cfr_enable_cfr_timer;
  580. tx_ops->cfr_tx_ops.cfr_start_capture =
  581. target_if_cfr_start_capture;
  582. tx_ops->cfr_tx_ops.cfr_stop_capture =
  583. target_if_cfr_stop_capture;
  584. target_if_enh_cfr_tx_ops(tx_ops);
  585. }
  586. void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc,
  587. uint8_t value)
  588. {
  589. struct wlan_lmac_if_rx_ops *rx_ops;
  590. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  591. if (!rx_ops) {
  592. cfr_err("rx_ops is NULL");
  593. return;
  594. }
  595. if (rx_ops->cfr_rx_ops.cfr_support_set)
  596. rx_ops->cfr_rx_ops.cfr_support_set(psoc, value);
  597. }
  598. QDF_STATUS
  599. target_if_cfr_set_capture_count_support(struct wlan_objmgr_psoc *psoc,
  600. uint8_t value)
  601. {
  602. struct wlan_lmac_if_rx_ops *rx_ops;
  603. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  604. if (!rx_ops) {
  605. cfr_err("rx_ops is NULL");
  606. return QDF_STATUS_E_INVAL;
  607. }
  608. if (rx_ops->cfr_rx_ops.cfr_capture_count_support_set)
  609. return rx_ops->cfr_rx_ops.cfr_capture_count_support_set(
  610. psoc, value);
  611. return QDF_STATUS_E_INVAL;
  612. }
  613. QDF_STATUS
  614. target_if_cfr_set_mo_marking_support(struct wlan_objmgr_psoc *psoc,
  615. uint8_t value)
  616. {
  617. struct wlan_lmac_if_rx_ops *rx_ops;
  618. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  619. if (!rx_ops) {
  620. cfr_err("rx_ops is NULL");
  621. return QDF_STATUS_E_INVAL;
  622. }
  623. if (rx_ops->cfr_rx_ops.cfr_mo_marking_support_set)
  624. return rx_ops->cfr_rx_ops.cfr_mo_marking_support_set(
  625. psoc, value);
  626. return QDF_STATUS_E_INVAL;
  627. }
  628. QDF_STATUS
  629. target_if_cfr_set_aoa_for_rcc_support(struct wlan_objmgr_psoc *psoc,
  630. uint8_t value)
  631. {
  632. struct wlan_lmac_if_rx_ops *rx_ops;
  633. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  634. if (!rx_ops) {
  635. cfr_err("rx_ops is NULL");
  636. return QDF_STATUS_E_INVAL;
  637. }
  638. if (rx_ops->cfr_rx_ops.cfr_aoa_for_rcc_support_set)
  639. return rx_ops->cfr_rx_ops.cfr_aoa_for_rcc_support_set(
  640. psoc, value);
  641. return QDF_STATUS_E_INVAL;
  642. }
  643. void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head,
  644. size_t hlen, void *data, size_t dlen, void *tail,
  645. size_t tlen)
  646. {
  647. struct wlan_objmgr_psoc *psoc;
  648. struct wlan_lmac_if_rx_ops *rx_ops;
  649. psoc = wlan_pdev_get_psoc(pdev);
  650. rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
  651. if (!rx_ops) {
  652. cfr_err("rx_ops is NULL");
  653. return;
  654. }
  655. if (rx_ops->cfr_rx_ops.cfr_info_send)
  656. rx_ops->cfr_rx_ops.cfr_info_send(pdev, head, hlen, data, dlen,
  657. tail, tlen);
  658. }