target_if_cfr.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. /*
  2. * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <target_if_cfr.h>
  19. #include <wlan_tgt_def_config.h>
  20. #include <target_type.h>
  21. #include <hif_hw_version.h>
  22. #include <target_if.h>
  23. #include <wlan_lmac_if_def.h>
  24. #include <wlan_osif_priv.h>
  25. #include <init_deinit_lmac.h>
  26. #include <wlan_cfr_utils_api.h>
  27. #include <wlan_objmgr_pdev_obj.h>
  28. #include <target_if_cfr_6018.h>
  29. #ifdef CFR_USE_FIXED_FOLDER
  30. #include "target_if_cfr_6490.h"
  31. #include "wlan_reg_services_api.h"
  32. #else
  33. #include <target_if_cfr_8074v2.h>
  34. #endif
  35. int target_if_cfr_stop_capture(struct wlan_objmgr_pdev *pdev,
  36. struct wlan_objmgr_peer *peer)
  37. {
  38. struct peer_cfr *pe;
  39. struct peer_cfr_params param = {0};
  40. struct wmi_unified *pdev_wmi_handle = NULL;
  41. struct wlan_objmgr_vdev *vdev = {0};
  42. struct pdev_cfr *pdev_cfrobj;
  43. int retv = 0;
  44. pe = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_UMAC_COMP_CFR);
  45. if (pe == NULL)
  46. return -EINVAL;
  47. pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  48. vdev = wlan_peer_get_vdev(peer);
  49. qdf_mem_set(&param, sizeof(param), 0);
  50. param.request = PEER_CFR_CAPTURE_DISABLE;
  51. param.macaddr = wlan_peer_get_macaddr(peer);
  52. param.vdev_id = wlan_vdev_get_id(vdev);
  53. param.periodicity = pe->period;
  54. param.bandwidth = pe->bandwidth;
  55. param.capture_method = pe->capture_method;
  56. retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, &param);
  57. pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  58. WLAN_UMAC_COMP_CFR);
  59. if (!pdev_cfrobj) {
  60. cfr_err("pdev object for CFR is null");
  61. return -EINVAL;
  62. }
  63. cfr_err("CFR capture stats for this capture:");
  64. cfr_err("DBR event count = %llu, Tx event count = %llu "
  65. "Release count = %llu",
  66. pdev_cfrobj->dbr_evt_cnt, pdev_cfrobj->tx_evt_cnt,
  67. pdev_cfrobj->release_cnt);
  68. pdev_cfrobj->dbr_evt_cnt = 0;
  69. pdev_cfrobj->tx_evt_cnt = 0;
  70. pdev_cfrobj->release_cnt = 0;
  71. return retv;
  72. }
  73. int target_if_cfr_start_capture(struct wlan_objmgr_pdev *pdev,
  74. struct wlan_objmgr_peer *peer,
  75. struct cfr_capture_params *cfr_params)
  76. {
  77. struct peer_cfr_params param = {0};
  78. struct wmi_unified *pdev_wmi_handle = NULL;
  79. struct wlan_objmgr_vdev *vdev;
  80. int retv = 0;
  81. pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  82. vdev = wlan_peer_get_vdev(peer);
  83. qdf_mem_set(&param, sizeof(param), 0);
  84. param.request = PEER_CFR_CAPTURE_ENABLE;
  85. param.macaddr = wlan_peer_get_macaddr(peer);
  86. param.vdev_id = wlan_vdev_get_id(vdev);
  87. param.periodicity = cfr_params->period;
  88. param.bandwidth = cfr_params->bandwidth;
  89. param.capture_method = cfr_params->method;
  90. retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, &param);
  91. return retv;
  92. }
  93. int target_if_cfr_pdev_set_param(struct wlan_objmgr_pdev *pdev,
  94. uint32_t param_id, uint32_t param_value)
  95. {
  96. struct pdev_params pparam;
  97. uint32_t pdev_id;
  98. pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
  99. if (pdev_id < 0)
  100. return -EINVAL;
  101. qdf_mem_set(&pparam, sizeof(pparam), 0);
  102. pparam.param_id = param_id;
  103. pparam.param_value = param_value;
  104. return wmi_unified_pdev_param_send(lmac_get_pdev_wmi_handle(pdev),
  105. &pparam, pdev_id);
  106. }
  107. int target_if_cfr_enable_cfr_timer(struct wlan_objmgr_pdev *pdev,
  108. uint32_t cfr_timer)
  109. {
  110. struct pdev_cfr *pa;
  111. int retval;
  112. pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
  113. if (pa == NULL)
  114. return QDF_STATUS_E_FAILURE;
  115. if (!cfr_timer) {
  116. /* disable periodic cfr capture */
  117. retval =
  118. target_if_cfr_pdev_set_param(pdev,
  119. wmi_pdev_param_per_peer_prd_cfr_enable,
  120. WMI_HOST_PEER_CFR_TIMER_DISABLE);
  121. if (retval == QDF_STATUS_SUCCESS)
  122. pa->cfr_timer_enable = 0;
  123. } else {
  124. /* enable periodic cfr capture (default base timer is 10ms ) */
  125. retval =
  126. target_if_cfr_pdev_set_param(pdev,
  127. wmi_pdev_param_per_peer_prd_cfr_enable,
  128. WMI_HOST_PEER_CFR_TIMER_ENABLE);
  129. if (retval == QDF_STATUS_SUCCESS)
  130. pa->cfr_timer_enable = 1;
  131. }
  132. return retval;
  133. }
  134. int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc)
  135. {
  136. uint32_t target_type = 0;
  137. struct wlan_lmac_if_target_tx_ops *target_type_tx_ops;
  138. target_type_tx_ops = &psoc->soc_cb.tx_ops.target_tx_ops;
  139. if (target_type_tx_ops->tgt_get_tgt_type)
  140. target_type = target_type_tx_ops->tgt_get_tgt_type(psoc);
  141. return target_type;
  142. }
  143. #ifdef CFR_USE_FIXED_FOLDER
  144. int target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc,
  145. struct wlan_objmgr_pdev *pdev)
  146. {
  147. uint32_t target_type;
  148. QDF_STATUS status;
  149. target_type = target_if_cfr_get_target_type(psoc);
  150. if (target_type == TARGET_TYPE_QCA6490) {
  151. status = cfr_6490_init_pdev(psoc, pdev);
  152. } else {
  153. cfr_info("unsupport chip");
  154. status = QDF_STATUS_SUCCESS;
  155. }
  156. return qdf_status_to_os_return(status);
  157. }
  158. int target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc,
  159. struct wlan_objmgr_pdev *pdev)
  160. {
  161. uint32_t target_type;
  162. QDF_STATUS status;
  163. target_type = target_if_cfr_get_target_type(psoc);
  164. if (target_type == TARGET_TYPE_QCA6490) {
  165. status = cfr_6490_deinit_pdev(psoc, pdev);
  166. } else {
  167. cfr_info("unsupport chip");
  168. status = QDF_STATUS_SUCCESS;
  169. }
  170. return qdf_status_to_os_return(status);
  171. }
  172. #else
  173. int target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc,
  174. struct wlan_objmgr_pdev *pdev)
  175. {
  176. uint32_t target_type;
  177. struct pdev_cfr *pa;
  178. struct psoc_cfr *cfr_sc;
  179. pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
  180. if (pa == NULL)
  181. return QDF_STATUS_E_FAILURE;
  182. /* Reset unassociated entries for every init */
  183. qdf_mem_zero(&pa->unassoc_pool[0], MAX_CFR_ENABLED_CLIENTS *
  184. sizeof(struct unassoc_pool_entry));
  185. cfr_sc = wlan_objmgr_psoc_get_comp_private_obj(psoc,
  186. WLAN_UMAC_COMP_CFR);
  187. if (cfr_sc == NULL)
  188. return QDF_STATUS_E_FAILURE;
  189. target_type = target_if_cfr_get_target_type(psoc);
  190. if (target_type == TARGET_TYPE_QCA8074V2) {
  191. pa->is_cfr_capable = cfr_sc->is_cfr_capable;
  192. return cfr_8074v2_init_pdev(psoc, pdev);
  193. } else if ((target_type == TARGET_TYPE_IPQ4019) ||
  194. (target_type == TARGET_TYPE_QCA9984) ||
  195. (target_type == TARGET_TYPE_QCA9888)) {
  196. pa->is_cfr_capable = cfr_sc->is_cfr_capable;
  197. return cfr_wifi2_0_init_pdev(psoc, pdev);
  198. } else if (target_type == TARGET_TYPE_QCA6018) {
  199. pa->is_cfr_capable = cfr_sc->is_cfr_capable;
  200. return cfr_6018_init_pdev(psoc, pdev);
  201. } else
  202. return QDF_STATUS_E_NOSUPPORT;
  203. }
  204. int target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc,
  205. struct wlan_objmgr_pdev *pdev)
  206. {
  207. uint32_t target_type;
  208. target_type = target_if_cfr_get_target_type(psoc);
  209. if (target_type == TARGET_TYPE_QCA8074V2) {
  210. return cfr_8074v2_deinit_pdev(psoc, pdev);
  211. } else if ((target_type == TARGET_TYPE_IPQ4019) ||
  212. (target_type == TARGET_TYPE_QCA9984) ||
  213. (target_type == TARGET_TYPE_QCA9888)) {
  214. return cfr_wifi2_0_deinit_pdev(psoc, pdev);
  215. } else if (target_type == TARGET_TYPE_QCA6018) {
  216. return cfr_6018_deinit_pdev(psoc, pdev);
  217. } else
  218. return QDF_STATUS_E_NOSUPPORT;
  219. }
  220. #endif
  221. #ifdef WLAN_ENH_CFR_ENABLE
  222. #ifdef QCA_WIFI_QCA6490
  223. static uint8_t target_if_cfr_get_mac_id(struct wlan_objmgr_pdev *pdev)
  224. {
  225. struct wlan_objmgr_vdev *vdev;
  226. struct wlan_channel *bss_chan;
  227. struct pdev_cfr *pcfr;
  228. uint8_t mac_id = 0;
  229. if (!pdev) {
  230. cfr_err("null pdev");
  231. return mac_id;
  232. }
  233. mac_id = wlan_objmgr_pdev_get_pdev_id(pdev);
  234. pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
  235. if (!pcfr) {
  236. cfr_err("null pcfr");
  237. return mac_id;
  238. }
  239. if (pcfr->rcc_param.vdev_id == CFR_INVALID_VDEV_ID)
  240. return mac_id;
  241. vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev,
  242. pcfr->rcc_param.vdev_id,
  243. WLAN_CFR_ID);
  244. if (!vdev) {
  245. cfr_err("null vdev");
  246. return mac_id;
  247. }
  248. bss_chan = wlan_vdev_mlme_get_bss_chan(vdev);
  249. if (!bss_chan) {
  250. cfr_info("null bss chan");
  251. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  252. return mac_id;
  253. }
  254. cfr_debug("bss freq %d", bss_chan->ch_freq);
  255. if (wlan_reg_is_24ghz_ch_freq(bss_chan->ch_freq))
  256. mac_id = CFR_MAC_ID_24G;
  257. else
  258. mac_id = CFR_MAC_ID_5G;
  259. pcfr->rcc_param.srng_id = mac_id;
  260. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  261. return mac_id;
  262. }
  263. static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev)
  264. {
  265. return target_if_cfr_get_mac_id(pdev);
  266. }
  267. #else
  268. static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev)
  269. {
  270. return wlan_objmgr_pdev_get_pdev_id(pdev);
  271. }
  272. #endif /* QCA_WIFI_QCA6490 */
  273. QDF_STATUS target_if_cfr_config_rcc(struct wlan_objmgr_pdev *pdev,
  274. struct cfr_rcc_param *rcc_info)
  275. {
  276. QDF_STATUS status;
  277. struct wmi_unified *pdev_wmi_handle = NULL;
  278. pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
  279. if (!pdev_wmi_handle) {
  280. cfr_err("pdev_wmi_handle is null");
  281. return QDF_STATUS_E_NULL_VALUE;
  282. }
  283. rcc_info->pdev_id = target_if_cfr_get_pdev_id(pdev);
  284. rcc_info->num_grp_tlvs =
  285. count_set_bits(rcc_info->modified_in_curr_session);
  286. status = wmi_unified_send_cfr_rcc_cmd(pdev_wmi_handle, rcc_info);
  287. return status;
  288. }
  289. void target_if_cfr_default_ta_ra_config(struct cfr_rcc_param *rcc_info,
  290. bool allvalid, uint16_t reset_cfg)
  291. {
  292. struct ta_ra_cfr_cfg *curr_cfg = NULL;
  293. int grp_id;
  294. uint8_t def_mac[QDF_MAC_ADDR_SIZE] = {0xFF, 0xFF, 0xFF,
  295. 0xFF, 0xFF, 0xFF};
  296. uint8_t null_mac[QDF_MAC_ADDR_SIZE] = {0x00, 0x00, 0x00,
  297. 0x00, 0x00, 0x00};
  298. for (grp_id = 0; grp_id < MAX_TA_RA_ENTRIES; grp_id++) {
  299. if (qdf_test_bit(grp_id, (unsigned long *)&reset_cfg)) {
  300. curr_cfg = &rcc_info->curr[grp_id];
  301. qdf_mem_copy(curr_cfg->tx_addr,
  302. null_mac, QDF_MAC_ADDR_SIZE);
  303. qdf_mem_copy(curr_cfg->tx_addr_mask,
  304. def_mac, QDF_MAC_ADDR_SIZE);
  305. qdf_mem_copy(curr_cfg->rx_addr,
  306. null_mac, QDF_MAC_ADDR_SIZE);
  307. qdf_mem_copy(curr_cfg->rx_addr_mask,
  308. def_mac, QDF_MAC_ADDR_SIZE);
  309. curr_cfg->bw = 0xf;
  310. curr_cfg->nss = 0xff;
  311. curr_cfg->mgmt_subtype_filter = 0;
  312. curr_cfg->ctrl_subtype_filter = 0;
  313. curr_cfg->data_subtype_filter = 0;
  314. if (!allvalid) {
  315. curr_cfg->valid_ta = 0;
  316. curr_cfg->valid_ta_mask = 0;
  317. curr_cfg->valid_ra = 0;
  318. curr_cfg->valid_ra_mask = 0;
  319. curr_cfg->valid_bw_mask = 0;
  320. curr_cfg->valid_nss_mask = 0;
  321. curr_cfg->valid_mgmt_subtype = 0;
  322. curr_cfg->valid_ctrl_subtype = 0;
  323. curr_cfg->valid_data_subtype = 0;
  324. } else {
  325. curr_cfg->valid_ta = 1;
  326. curr_cfg->valid_ta_mask = 1;
  327. curr_cfg->valid_ra = 1;
  328. curr_cfg->valid_ra_mask = 1;
  329. curr_cfg->valid_bw_mask = 1;
  330. curr_cfg->valid_nss_mask = 1;
  331. curr_cfg->valid_mgmt_subtype = 1;
  332. curr_cfg->valid_ctrl_subtype = 1;
  333. curr_cfg->valid_data_subtype = 1;
  334. }
  335. }
  336. }
  337. }
  338. #endif
  339. #ifdef WLAN_ENH_CFR_ENABLE
  340. #ifdef CFR_USE_FIXED_FOLDER
  341. static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  342. {
  343. tx_ops->cfr_tx_ops.cfr_subscribe_ppdu_desc =
  344. target_if_cfr_subscribe_ppdu_desc;
  345. }
  346. #else
  347. static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  348. {
  349. }
  350. #endif /* CFR_USE_FIXED_FOLDER */
  351. static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  352. {
  353. tx_ops->cfr_tx_ops.cfr_config_rcc =
  354. target_if_cfr_config_rcc;
  355. tx_ops->cfr_tx_ops.cfr_start_lut_timer =
  356. target_if_cfr_start_lut_age_timer;
  357. tx_ops->cfr_tx_ops.cfr_stop_lut_timer =
  358. target_if_cfr_stop_lut_age_timer;
  359. tx_ops->cfr_tx_ops.cfr_default_ta_ra_cfg =
  360. target_if_cfr_default_ta_ra_config;
  361. tx_ops->cfr_tx_ops.cfr_dump_lut_enh =
  362. target_if_cfr_dump_lut_enh;
  363. tx_ops->cfr_tx_ops.cfr_rx_tlv_process =
  364. target_if_cfr_rx_tlv_process;
  365. tx_ops->cfr_tx_ops.cfr_update_global_cfg =
  366. target_if_cfr_update_global_cfg;
  367. target_if_enh_cfr_add_ops(tx_ops);
  368. }
  369. #else
  370. static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  371. {
  372. }
  373. #endif
  374. void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
  375. {
  376. tx_ops->cfr_tx_ops.cfr_init_pdev =
  377. target_if_cfr_init_pdev;
  378. tx_ops->cfr_tx_ops.cfr_deinit_pdev =
  379. target_if_cfr_deinit_pdev;
  380. tx_ops->cfr_tx_ops.cfr_enable_cfr_timer =
  381. target_if_cfr_enable_cfr_timer;
  382. tx_ops->cfr_tx_ops.cfr_start_capture =
  383. target_if_cfr_start_capture;
  384. tx_ops->cfr_tx_ops.cfr_stop_capture =
  385. target_if_cfr_stop_capture;
  386. target_if_enh_cfr_tx_ops(tx_ops);
  387. }
  388. void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc,
  389. uint8_t value)
  390. {
  391. if (psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_support_set)
  392. psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_support_set(psoc, value);
  393. }
  394. void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head,
  395. size_t hlen, void *data, size_t dlen, void *tail,
  396. size_t tlen)
  397. {
  398. struct wlan_objmgr_psoc *psoc;
  399. psoc = wlan_pdev_get_psoc(pdev);
  400. if (psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_info_send)
  401. psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_info_send(pdev, head, hlen,
  402. data, dlen, tail,
  403. tlen);
  404. }