target_if_cfr_8074v2.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*
  2. * Copyright (c) 2019 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 <ol_if_athvar.h>
  23. #include <target_if.h>
  24. #include <wlan_lmac_if_def.h>
  25. #include <wlan_osif_priv.h>
  26. #include <wlan_mlme_dispatcher.h>
  27. #include <init_deinit_lmac.h>
  28. #include <wlan_cfr_utils_api.h>
  29. #include <target_if_cfr_8074v2.h>
  30. #ifdef DIRECT_BUF_RX_ENABLE
  31. #include <target_if_direct_buf_rx_api.h>
  32. #endif
  33. static u_int32_t end_magic = 0xBEAFDEAD;
  34. int dump_lut(struct wlan_objmgr_pdev *pdev)
  35. {
  36. struct pdev_cfr *pdev_cfrobj;
  37. struct look_up_table *lut = NULL;
  38. int i = 0;
  39. pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  40. WLAN_UMAC_COMP_CFR);
  41. if (!pdev_cfrobj) {
  42. cfr_err("pdev object for CFR is null");
  43. return -EINVAL;
  44. }
  45. for (i = 0; i < 136; i++) {
  46. lut = &pdev_cfrobj->lut[i];
  47. cfr_err("idx:%d dbrevnt: %d txevent: %d dbrppdu:0x%x txppdu:0x%x\n",
  48. i, lut->dbr_recv, lut->tx_recv,
  49. lut->dbr_ppdu_id, lut->tx_ppdu_id);
  50. }
  51. return 0;
  52. }
  53. #ifdef DIRECT_BUF_RX_ENABLE
  54. void dump_dma_hdr(struct whal_cfir_dma_hdr *dma_hdr, int error)
  55. {
  56. if (!error) {
  57. cfr_debug("Tag: 0x%02x Length: %d udone: %d ctype: %d preamble: %d",
  58. dma_hdr->tag, dma_hdr->length, dma_hdr->upload_done,
  59. dma_hdr->capture_type, dma_hdr->preamble_type);
  60. cfr_debug("Nss: %d num_chains: %d bw: %d", dma_hdr->nss,
  61. dma_hdr->num_chains, dma_hdr->upload_pkt_bw);
  62. cfr_debug("peervalid: %d peer_id: %d ppdu_id: 0x%04x",
  63. dma_hdr->sw_peer_id_valid, dma_hdr->sw_peer_id,
  64. dma_hdr->phy_ppdu_id);
  65. } else {
  66. cfr_err("Tag: 0x%02x Length: %d udone: %d ctype: %d preamble: %d",
  67. dma_hdr->tag, dma_hdr->length, dma_hdr->upload_done,
  68. dma_hdr->capture_type, dma_hdr->preamble_type);
  69. cfr_err("Nss: %d num_chains: %d bw: %d", dma_hdr->nss,
  70. dma_hdr->num_chains, dma_hdr->upload_pkt_bw);
  71. cfr_err("peervalid: %d peer_id: %d ppdu_id: 0x%04x",
  72. dma_hdr->sw_peer_id_valid, dma_hdr->sw_peer_id,
  73. dma_hdr->phy_ppdu_id);
  74. }
  75. }
  76. int compute_length(struct whal_cfir_dma_hdr *dma_hdr)
  77. {
  78. uint8_t bw = dma_hdr->upload_pkt_bw;
  79. uint8_t preamble = dma_hdr->preamble_type;
  80. switch (preamble) {
  81. case 0:
  82. case 2:
  83. switch (bw) {
  84. case 0:
  85. return TONES_IN_20MHZ;
  86. case 1: /* DUP40/VHT40 */
  87. return TONES_IN_40MHZ;
  88. case 2: /* DUP80/VHT80 */
  89. return TONES_IN_80MHZ;
  90. case 3: /* DUP160/VHT160 */
  91. return TONES_IN_160MHZ;
  92. }
  93. case 1:
  94. switch (bw) {
  95. case 0:
  96. return TONES_IN_20MHZ;
  97. case 1:
  98. return TONES_IN_40MHZ;
  99. }
  100. }
  101. return TONES_INVALID;
  102. }
  103. int release_lut_entry(struct wlan_objmgr_pdev *pdev,
  104. struct look_up_table *lut)
  105. {
  106. lut->dbr_recv = false;
  107. lut->tx_recv = false;
  108. lut->data = NULL;
  109. lut->data_len = 0;
  110. lut->dbr_ppdu_id = 0;
  111. lut->tx_ppdu_id = 0;
  112. qdf_mem_zero(&lut->header, sizeof(struct csi_cfr_header));
  113. return 0;
  114. }
  115. int correlate_and_relay(struct wlan_objmgr_pdev *pdev, uint32_t cookie,
  116. struct look_up_table *lut, uint8_t module_id)
  117. {
  118. struct pdev_cfr *pdev_cfrobj;
  119. if (module_id > 1) {
  120. cfr_err("Received request with invalid mod id. Investigate!!");
  121. QDF_ASSERT(0);
  122. return STATUS_ERROR;
  123. }
  124. pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  125. WLAN_UMAC_COMP_CFR);
  126. if (module_id == CORRELATE_TX_EV_MODULE_ID) {
  127. pdev_cfrobj->tx_evt_cnt++;
  128. lut->tx_recv = true;
  129. } else if (module_id == CORRELATE_DBR_MODULE_ID) {
  130. pdev_cfrobj->dbr_evt_cnt++;
  131. lut->dbr_recv = true;
  132. }
  133. if ((lut->dbr_recv == true) && (lut->tx_recv == true)) {
  134. if (lut->dbr_ppdu_id == lut->tx_ppdu_id) {
  135. pdev_cfrobj->release_cnt++;
  136. return STATUS_STREAM_AND_RELEASE;
  137. } else {
  138. /*
  139. * When there is a ppdu id mismatch, discard the other
  140. * older event's data and wait hold for new event
  141. */
  142. if (module_id == CORRELATE_TX_EV_MODULE_ID) {
  143. cfr_debug("Received new tx event for same cookie %u",
  144. cookie);
  145. lut->dbr_recv = false;
  146. lut->data = NULL;
  147. lut->data_len = 0;
  148. lut->dbr_ppdu_id = 0;
  149. qdf_mem_zero(&lut->dbr_address, sizeof(lut->dbr_address));
  150. } else if (module_id == CORRELATE_DBR_MODULE_ID) {
  151. cfr_debug("Received new dbr event for same cookie %u",
  152. cookie);
  153. lut->tx_recv = false;
  154. lut->tx_ppdu_id = 0;
  155. }
  156. /*
  157. * This is condition can occur if DBR buffer did not get
  158. * released or leaked either by Host / Target
  159. * we may need to add recovery here.
  160. *
  161. * 1. Stop all captures
  162. * 2. Flush/release DBR buffer and LUT
  163. * 3. Start capture again
  164. */
  165. if (pdev_cfrobj->dbr_evt_cnt - pdev_cfrobj->release_cnt > 1) {
  166. cfr_err("cookie = %u dbr_cnt = %d, release_cnt = %d",
  167. cookie, pdev_cfrobj->dbr_evt_cnt,
  168. pdev_cfrobj->release_cnt);
  169. dump_lut(pdev);
  170. dump_dma_hdr(&lut->dma_hdr, 1);
  171. cfr_debug("correlation_info1: 0x%08x correlation_info2 0x%08x",
  172. lut->tx_address1, lut->tx_address2);
  173. }
  174. return STATUS_HOLD;
  175. }
  176. } else {
  177. return STATUS_HOLD;
  178. }
  179. }
  180. bool cfr_dbr_event_handler(struct wlan_objmgr_pdev *pdev,
  181. struct direct_buf_rx_data *payload)
  182. {
  183. uint8_t *data = payload->vaddr;
  184. uint32_t cookie = payload->cookie;
  185. struct whal_cfir_dma_hdr dma_hdr = {0};
  186. int length = 8, tones = 0, status = 0;
  187. struct wlan_objmgr_psoc *psoc;
  188. struct pdev_cfr *pdev_cfrobj;
  189. struct look_up_table *lut = NULL;
  190. struct csi_cfr_header *header = NULL;
  191. if ((!pdev) || (!payload)) {
  192. cfr_err("pdev or payload is null");
  193. return true;
  194. }
  195. psoc = wlan_pdev_get_psoc(pdev);
  196. if (!psoc) {
  197. cfr_err("psoc is null");
  198. return true;
  199. }
  200. pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  201. WLAN_UMAC_COMP_CFR);
  202. if (!pdev_cfrobj) {
  203. cfr_err("pdev object for CFR is null");
  204. return true;
  205. }
  206. cfr_debug("bufferaddr: 0x%pK cookie: %u", payload->paddr, cookie);
  207. qdf_mem_copy(&dma_hdr, &data[0], sizeof(struct whal_cfir_dma_hdr));
  208. dump_dma_hdr(&dma_hdr, 0);
  209. tones = compute_length(&dma_hdr);
  210. if (tones == TONES_INVALID) {
  211. cfr_err("Number of tones received is invalid. Investigate!");
  212. return true;
  213. }
  214. length += tones * (dma_hdr.num_chains + 1);
  215. lut = &pdev_cfrobj->lut[cookie];
  216. lut->data = data;
  217. lut->data_len = length;
  218. lut->dbr_ppdu_id = dma_hdr.phy_ppdu_id;
  219. lut->dbr_address = payload->paddr;
  220. qdf_mem_copy(&lut->dma_hdr, &dma_hdr, sizeof(struct whal_cfir_dma_hdr));
  221. header = &lut->header;
  222. header->u.meta_v1.capture_bw = dma_hdr.upload_pkt_bw;
  223. header->u.meta_v1.num_rx_chain = dma_hdr.num_chains + 1;
  224. header->u.meta_v1.length = length;
  225. status = correlate_and_relay(pdev, cookie, lut,
  226. CORRELATE_DBR_MODULE_ID);
  227. if (status == STATUS_STREAM_AND_RELEASE) {
  228. /*
  229. * Message format
  230. * Meta data Header + actual payload + trailer
  231. */
  232. status = psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_info_send(pdev, &lut->header,
  233. sizeof(struct csi_cfr_header),
  234. lut->data, lut->data_len, &end_magic, 4);
  235. release_lut_entry(pdev, lut);
  236. cfr_debug("Data sent to upper layers, released look up table");
  237. return true;
  238. } else if (status == STATUS_HOLD) {
  239. cfr_debug("Tx event not received yet. Buffer is not released");
  240. return false;
  241. } else {
  242. cfr_err("Correlation returned invalid status!!");
  243. return true;
  244. }
  245. return true;
  246. }
  247. #endif
  248. void dump_cfr_peer_tx_event(wmi_cfr_peer_tx_event_param *event)
  249. {
  250. cfr_debug("CFR capture method: %d vdev_id: %d mac: %s",
  251. event->capture_method, event->vdev_id,
  252. ether_sprintf(&event->peer_mac_addr.bytes[0]));
  253. cfr_debug("Chan: %d bw: %d phymode: %d cfreq1: %d cfrq2: %d nss: %d",
  254. event->primary_20mhz_chan, event->bandwidth,
  255. event->phy_mode, event->band_center_freq1,
  256. event->band_center_freq2, event->spatial_streams);
  257. cfr_debug("Correlation_info1: 0x%08x Correlation_info2: 0x%08x",
  258. event->correlation_info_1, event->correlation_info_2);
  259. cfr_debug("status: 0x%x ts: %d counter: %d rssi0: 0x%08x",
  260. event->status, event->timestamp_us, event->counter,
  261. event->chain_rssi[0]);
  262. }
  263. static int
  264. target_if_peer_capture_event(ol_scn_t sc, uint8_t *data, uint32_t datalen)
  265. {
  266. QDF_STATUS retval = 0;
  267. ol_ath_soc_softc_t *scn = (ol_ath_soc_softc_t *)sc;
  268. struct common_wmi_handle *wmi_handle;
  269. struct wlan_objmgr_psoc *psoc;
  270. struct wlan_objmgr_pdev *pdev;
  271. struct wlan_objmgr_vdev *vdev;
  272. uint32_t cookie;
  273. struct pdev_cfr *pdev_cfrobj;
  274. struct look_up_table *lut = NULL;
  275. struct csi_cfr_header *header = NULL;
  276. wmi_cfr_peer_tx_event_param tx_evt_param = {0};
  277. qdf_dma_addr_t buf_addr = 0, buf_addr_temp = 0;
  278. int status;
  279. psoc = scn->psoc_obj;
  280. if (!psoc) {
  281. cfr_err("psoc is null");
  282. return -EINVAL;
  283. }
  284. retval = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_CFR_ID);
  285. if (QDF_IS_STATUS_ERROR(retval)) {
  286. cfr_err("unable to get psoc reference");
  287. return -EINVAL;
  288. }
  289. wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc);
  290. if (!wmi_handle) {
  291. cfr_err("wmi_handle is null");
  292. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  293. return -EINVAL;
  294. }
  295. retval = wmi_extract_cfr_peer_tx_event_param(wmi_handle, data,
  296. &tx_evt_param);
  297. if (retval != QDF_STATUS_SUCCESS) {
  298. cfr_err("Failed to extract cfr tx event param");
  299. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  300. return -EINVAL;
  301. }
  302. dump_cfr_peer_tx_event(&tx_evt_param);
  303. vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, tx_evt_param.vdev_id,
  304. WLAN_CFR_ID);
  305. if (!vdev) {
  306. cfr_err("vdev is null");
  307. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  308. return -EINVAL;
  309. }
  310. pdev = wlan_vdev_get_pdev(vdev);
  311. if (!pdev) {
  312. cfr_err("pdev is null");
  313. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  314. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  315. return -EINVAL;
  316. }
  317. retval = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_CFR_ID);
  318. if (retval != QDF_STATUS_SUCCESS){
  319. cfr_err("failed to get pdev reference");
  320. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  321. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  322. return -EINVAL;
  323. }
  324. pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  325. WLAN_UMAC_COMP_CFR);
  326. if (!pdev_cfrobj) {
  327. cfr_err("pdev object for CFR is NULL");
  328. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  329. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  330. wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
  331. return -EINVAL;
  332. }
  333. if ((tx_evt_param.status & PEER_CFR_CAPTURE_EVT_STATUS_MASK) == 0) {
  334. cfr_debug("CFR capture failed for peer : %s",
  335. ether_sprintf(&tx_evt_param.peer_mac_addr.bytes[0]));
  336. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  337. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  338. wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
  339. return -EINVAL;
  340. }
  341. if (tx_evt_param.status & CFR_TX_EVT_STATUS_MASK) {
  342. cfr_debug("TX packet returned status %d for peer: %s",
  343. tx_evt_param.status & CFR_TX_EVT_STATUS_MASK,
  344. ether_sprintf(&tx_evt_param.peer_mac_addr.bytes[0]));
  345. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  346. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  347. wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
  348. return -EINVAL;
  349. }
  350. buf_addr_temp = (tx_evt_param.correlation_info_2 & 0x0f);
  351. buf_addr = (tx_evt_param.correlation_info_1 |((uint64_t)buf_addr_temp << 32));
  352. if (target_if_dbr_cookie_lookup(pdev, DBR_MODULE_CFR, buf_addr,
  353. &cookie)) {
  354. cfr_debug("Cookie lookup failure for addr: 0x%pK status: 0x%x",
  355. buf_addr, tx_evt_param.status);
  356. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  357. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  358. wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
  359. return -EINVAL;
  360. }
  361. cfr_debug("buffer address: 0x%pK cookie: %u", buf_addr, cookie);
  362. lut = &pdev_cfrobj->lut[cookie];
  363. lut->tx_ppdu_id = (tx_evt_param.correlation_info_2 >> 16);
  364. lut->tx_address1 = tx_evt_param.correlation_info_1;
  365. lut->tx_address2 = tx_evt_param.correlation_info_2;
  366. header = &lut->header;
  367. header->start_magic_num = 0xDEADBEAF;
  368. header->vendorid = 0x8cfdf0;
  369. header->cfr_metadata_version = CFR_META_VERSION_1;
  370. header->cfr_data_version = CFR_DATA_VERSION_1;
  371. header->chip_type = CFR_CAPTURE_RADIO_HKV2;
  372. header->pltform_type = CFR_PLATFORM_TYPE_ARM;
  373. header->Reserved = 0;
  374. header->u.meta_v1.status = (tx_evt_param.status &
  375. PEER_CFR_CAPTURE_EVT_STATUS_MASK)?0:1;
  376. header->u.meta_v1.channel_bw = tx_evt_param.bandwidth;
  377. header->u.meta_v1.phy_mode = tx_evt_param.phy_mode;
  378. header->u.meta_v1.prim20_chan = tx_evt_param.primary_20mhz_chan;
  379. header->u.meta_v1.center_freq1 = tx_evt_param.band_center_freq1;
  380. header->u.meta_v1.center_freq2 = tx_evt_param.band_center_freq2;
  381. header->u.meta_v1.capture_type = tx_evt_param.capture_method;
  382. header->u.meta_v1.sts_count = tx_evt_param.spatial_streams;
  383. header->u.meta_v1.timestamp = tx_evt_param.timestamp_us;
  384. qdf_mem_copy(&header->u.meta_v1.peer_addr[0],
  385. &tx_evt_param.peer_mac_addr.bytes[0], IEEE80211_ADDR_LEN);
  386. status = correlate_and_relay(pdev, cookie, lut,
  387. CORRELATE_TX_EV_MODULE_ID);
  388. if (status == STATUS_STREAM_AND_RELEASE) {
  389. status = psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_info_send(pdev, &lut->header,
  390. sizeof(struct csi_cfr_header),
  391. lut->data, lut->data_len, &end_magic, 4);
  392. release_lut_entry(pdev, lut);
  393. target_if_dbr_buf_release(pdev, DBR_MODULE_CFR, buf_addr,
  394. cookie);
  395. cfr_debug("Data sent to upper layers, releasing look up table");
  396. } else if (status == STATUS_HOLD) {
  397. cfr_debug("HOLD for buffer address: 0x%pK cookie: %u",
  398. buf_addr, cookie);
  399. } else {
  400. cfr_err("Correlation returned invalid status!!");
  401. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  402. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  403. wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
  404. return -EINVAL;
  405. }
  406. wlan_objmgr_psoc_release_ref(psoc, WLAN_CFR_ID);
  407. wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
  408. wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
  409. return 0;
  410. }
  411. int
  412. target_if_register_tx_completion_event_handler(struct wlan_objmgr_psoc *psoc)
  413. {
  414. /* Register completion handler here */
  415. wmi_unified_t wmi_hdl;
  416. int ret = 0;
  417. wmi_hdl = get_wmi_unified_hdl_from_psoc(psoc);
  418. if (!wmi_hdl) {
  419. cfr_err("Unable to get wmi handle");
  420. return -EINVAL;
  421. }
  422. ret = wmi_unified_register_event_handler(wmi_hdl,
  423. wmi_peer_cfr_capture_event_id,
  424. target_if_peer_capture_event,
  425. WMI_RX_UMAC_CTX);
  426. /*
  427. * Event registration is called per pdev
  428. * Ignore erorr if event is alreday registred.
  429. */
  430. if (ret == QDF_STATUS_E_FAILURE)
  431. ret = QDF_STATUS_SUCCESS;
  432. return ret;
  433. }
  434. int
  435. target_if_unregister_tx_completion_event_handler(struct wlan_objmgr_psoc *psoc)
  436. {
  437. /* Unregister completion handler here */
  438. wmi_unified_t wmi_hdl;
  439. int status = 0;
  440. wmi_hdl = get_wmi_unified_hdl_from_psoc(psoc);
  441. if (!wmi_hdl) {
  442. cfr_err("Unable to get wmi handle");
  443. return -EINVAL;
  444. }
  445. status = wmi_unified_unregister_event(wmi_hdl,
  446. wmi_peer_cfr_capture_event_id);
  447. return status;
  448. }
  449. #ifdef DIRECT_BUF_RX_ENABLE
  450. QDF_STATUS
  451. target_if_register_to_dbr(struct wlan_objmgr_pdev *pdev)
  452. {
  453. struct wlan_objmgr_psoc *psoc;
  454. struct wlan_lmac_if_direct_buf_rx_tx_ops *dbr_tx_ops = NULL;
  455. psoc = wlan_pdev_get_psoc(pdev);
  456. dbr_tx_ops = &psoc->soc_cb.tx_ops.dbr_tx_ops;
  457. if (dbr_tx_ops->direct_buf_rx_module_register) {
  458. return dbr_tx_ops->direct_buf_rx_module_register
  459. (pdev, DBR_MODULE_CFR,
  460. cfr_dbr_event_handler);
  461. }
  462. return QDF_STATUS_SUCCESS;
  463. }
  464. QDF_STATUS
  465. target_if_unregister_to_dbr(struct wlan_objmgr_pdev *pdev)
  466. {
  467. struct wlan_objmgr_psoc *psoc;
  468. struct wlan_lmac_if_direct_buf_rx_tx_ops *dbr_tx_ops = NULL;
  469. psoc = wlan_pdev_get_psoc(pdev);
  470. dbr_tx_ops = &psoc->soc_cb.tx_ops.dbr_tx_ops;
  471. if (dbr_tx_ops->direct_buf_rx_module_register) {
  472. return dbr_tx_ops->direct_buf_rx_module_unregister
  473. (pdev, DBR_MODULE_CFR);
  474. }
  475. return QDF_STATUS_SUCCESS;
  476. }
  477. struct module_ring_params*
  478. target_if_dbr_get_ring_params(struct wlan_objmgr_pdev *pdev)
  479. {
  480. struct wlan_objmgr_psoc *psoc;
  481. struct wlan_lmac_if_direct_buf_rx_tx_ops *dbr_tx_ops = NULL;
  482. struct module_ring_params *param = {0};
  483. psoc = wlan_pdev_get_psoc(pdev);
  484. dbr_tx_ops = &psoc->soc_cb.tx_ops.dbr_tx_ops;
  485. if(dbr_tx_ops->direct_buf_rx_get_ring_params)
  486. dbr_tx_ops->direct_buf_rx_get_ring_params(pdev, param,
  487. DBR_MODULE_CFR);
  488. return param;
  489. }
  490. #else
  491. QDF_STATUS
  492. target_if_cfr_register_to_dbr(struct wlan_objmgr_pdev *pdev)
  493. {
  494. return QDF_STATUS_SUCCESS;
  495. }
  496. QDF_STATUS
  497. target_if_unregister_to_dbr(struct wlan_objmgr_pdev *pdev)
  498. {
  499. return QDF_STATUS_SUCCESS;
  500. }
  501. struct module_ring_params*
  502. target_if_dbr_get_ring_params(struct wlan_objmgr_pdev *pdev)
  503. {
  504. return NULL;
  505. }
  506. #endif
  507. int cfr_8074v2_init_pdev(struct wlan_objmgr_psoc *psoc,
  508. struct wlan_objmgr_pdev *pdev)
  509. {
  510. int status;
  511. struct pdev_cfr *pdev_cfrobj;
  512. pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
  513. WLAN_UMAC_COMP_CFR);
  514. if (!pdev_cfrobj)
  515. return -EINVAL;
  516. status = target_if_register_to_dbr(pdev);
  517. if (QDF_STATUS_SUCCESS != status) {
  518. cfr_err("Failed to register with dbr");
  519. return -EINVAL;
  520. }
  521. status = target_if_register_tx_completion_event_handler(psoc);
  522. if (QDF_STATUS_SUCCESS != status) {
  523. cfr_err("Failed to register with tx event handler");
  524. return -EINVAL;
  525. }
  526. pdev_cfrobj->cfr_max_sta_count = MAX_PEERS_HKV2;
  527. pdev_cfrobj->subbuf_size = STREAMFS_MAX_SUBBUF_8S;
  528. pdev_cfrobj->num_subbufs = STREAMFS_NUM_SUBBUF_8S;
  529. return status;
  530. }
  531. int cfr_8074v2_deinit_pdev(struct wlan_objmgr_psoc *psoc,
  532. struct wlan_objmgr_pdev *pdev)
  533. {
  534. int status;
  535. status = target_if_unregister_to_dbr(pdev);
  536. if (QDF_STATUS_SUCCESS != status) {
  537. cfr_err("Failed to register with dbr");
  538. }
  539. status = target_if_unregister_tx_completion_event_handler(psoc);
  540. return status;
  541. }