diff --git a/umac/cfr/dispatcher/inc/wlan_cfr_ucfg_api.h b/umac/cfr/dispatcher/inc/wlan_cfr_ucfg_api.h index 93674052915e..ae89540a82b7 100644 --- a/umac/cfr/dispatcher/inc/wlan_cfr_ucfg_api.h +++ b/umac/cfr/dispatcher/inc/wlan_cfr_ucfg_api.h @@ -117,6 +117,26 @@ int ucfg_cfr_get_timer(struct wlan_objmgr_pdev *pdev); */ QDF_STATUS ucfg_cfr_stop_indication(struct wlan_objmgr_vdev *vdev); +#ifdef WLAN_CFR_ADRASTEA +/** + * ucfg_cfr_capture_data() - API called when HTT msg for CFR dump ind received + * @psoc: pointer to psoc object + * @vdev_id : vdev id + * @hdr: CFR header + * @mem_index: start offset index of dump in mem + * + * Return: None + */ +void ucfg_cfr_capture_data(struct wlan_objmgr_psoc *psoc, uint32_t vdev_id, + struct csi_cfr_header *hdr, uint32_t mem_index); +#else +static inline +void ucfg_cfr_capture_data(struct wlan_objmgr_psoc *psoc, uint32_t vdev_id, + struct csi_cfr_header *hdr, uint32_t mem_index) +{ +} +#endif + #ifdef WLAN_ENH_CFR_ENABLE /* Channel capture recipe filters */ enum capture_type { diff --git a/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h b/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h index d4f62311ecda..02cd878cc4ea 100644 --- a/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h +++ b/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h @@ -46,6 +46,7 @@ #define MAX_CFR_ENABLED_CLIENTS 10 #define CFR_CAPTURE_HOST_MEM_REQ_ID 9 #define CFR_HOST_MEM_READ_INDEX_DEFAULT 8 +#define CFR_VENDOR_ID 0x8cfdf0 #ifdef WLAN_ENH_CFR_ENABLE #define MAX_CFR_MU_USERS 4 #define NUM_CHAN_CAPTURE_STATUS 4 diff --git a/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c b/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c index 499881feef64..610d53e528c4 100644 --- a/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c +++ b/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c @@ -374,6 +374,93 @@ QDF_STATUS ucfg_cfr_stop_indication(struct wlan_objmgr_vdev *vdev) return cfr_stop_indication(vdev); } +#ifdef WLAN_CFR_ADRASTEA +void ucfg_cfr_capture_data(struct wlan_objmgr_psoc *psoc, uint32_t vdev_id, + struct csi_cfr_header *hdr, uint32_t mem_index) +{ + struct wlan_objmgr_vdev *vdev; + struct wlan_objmgr_pdev *pdev; + struct pdev_cfr *pcfr; + uint32_t end_magic_num = 0xBEAFDEAD; + void *vaddr, *payload; + u32 *rindex, *windex, payload_len; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, + WLAN_CFR_ID); + if (!vdev) { + cfr_err("vdev is NULL"); + return; + } + + pdev = wlan_vdev_get_pdev(vdev); + if (!pdev) { + cfr_err("pdev is NULL"); + wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); + return; + } + + status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_CFR_ID); + if (status != QDF_STATUS_SUCCESS) { + cfr_err("Failed to get pdev reference"); + wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); + return; + } + + pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev, + WLAN_UMAC_COMP_CFR); + if (!pcfr) { + cfr_err("pdev is NULL"); + goto exit; + } + + if (!pcfr->is_cfr_capable) { + cfr_err("CFR not supported on this chip"); + goto exit; + } + + hdr->vendorid = CFR_VENDOR_ID; + hdr->cfr_metadata_version = CFR_META_VERSION_1; + hdr->cfr_data_version = CFR_DATA_VERSION_1; + hdr->chip_type = CFR_CAPTURE_RADIO_ADRASTEA; + hdr->pltform_type = CFR_PLATFORM_TYPE_ARM; + hdr->Reserved = 0; + + vaddr = pcfr->cfr_mem_chunk.vaddr; + rindex = (u32 *)vaddr; + windex = rindex + 1; + + /* + * mem_index is having the index of the address where CFR dump wrriten, + * find data pointer from mem index and start address of memory. + */ + payload = vaddr + mem_index; + payload_len = hdr->u.meta_v1.length; + + /* Write data into streamfs */ + tgt_cfr_info_send(pdev, hdr, sizeof(struct csi_cfr_header), + payload, payload_len, &end_magic_num, + sizeof(uint32_t)); + + /* + * Updating the read index to the number of bytes read by host, it will + * help in writing next capture. + * ignoring 4 byte for FW magic number from the actual allocated memory + * length to avoid corruption in magic number. This memory is circular + * so after complation of one round, Skipping the first 8 byte as they + * are for read index and write index. + */ + if (((*rindex) + payload_len) <= (pcfr->cfr_mem_chunk.len - 4)) + (*rindex) += payload_len; + else if (((*rindex) + payload_len) > (pcfr->cfr_mem_chunk.len - 4)) + (*rindex) = (payload_len + 8); + +exit: + wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); + wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); +} +#endif + #ifdef WLAN_ENH_CFR_ENABLE static inline