From 70480abe44fe00556b6d6748d74be548af9b9a4d Mon Sep 17 00:00:00 2001 From: narayan Date: Mon, 18 Feb 2019 11:44:11 +0530 Subject: [PATCH] qca-wifi: CFR feature Component Support Add CFR component support for legacy chipsets including the implementation of stream filesystem interfacing Change-Id: Id92a4592425e901cc86061ae5eccefc5438efd45 CRs-Fixed: 2397716 --- qal/inc/qal_streamfs.h | 47 ++- qal/linux/src/qal_streamfs.c | 52 +++ target_if/cfr/inc/target_if_cfr.h | 83 +++++ target_if/cfr/src/target_if_cfr.c | 66 +++- target_if/cfr/src/target_if_cfr_wifi2_0.c | 340 +++++++++++++++++++ tools/linux/cfr_test_app.c | 2 +- umac/cfr/core/inc/cfr_defs_i.h | 40 +++ umac/cfr/core/src/cfr_common.c | 165 ++++++++- umac/cfr/dispatcher/inc/wlan_cfr_tgt_api.h | 26 +- umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h | 45 ++- umac/cfr/dispatcher/src/wlan_cfr_tgt_api.c | 47 +++ umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c | 7 + umac/cfr/dispatcher/src/wlan_cfr_utils_api.c | 43 ++- wmi/src/wmi_unified_non_tlv.c | 48 +++ 14 files changed, 985 insertions(+), 26 deletions(-) create mode 100644 target_if/cfr/src/target_if_cfr_wifi2_0.c diff --git a/qal/inc/qal_streamfs.h b/qal/inc/qal_streamfs.h index 0f5ec4c0a4..2fc623c80d 100644 --- a/qal/inc/qal_streamfs.h +++ b/qal/inc/qal_streamfs.h @@ -32,6 +32,48 @@ struct qal_dentry_t; struct qal_streamfs_chan_callbacks; struct qal_streamfs_chan_buf; +/** + * qal_streamfs_create_dir() - Create streamfs directory + * @name: name of directory to create + * @parent: dentry of parent directory, NULL for root directory + * + * Returns directory dentry pointer if successful, NULL otherwise. + */ +struct qal_dentry_t * +qal_streamfs_create_dir(const char *name, struct qal_dentry_t *parent); + +/** + * qal_streamfs_create_file() - Create streamfs chan buffer file + * @name: base name of file to create + * @mode: filemode + * @parent: dentry of parent directory, NULL for root directory + * @buf: pointer to chan buffer + * + * Returns file dentry pointer if successful, NULL otherwise. + */ +struct qal_dentry_t * +qal_streamfs_create_file(const char *name, uint16_t mode, + struct qal_dentry_t *parent, + struct qal_streamfs_chan_buf *buf); + +/** + * qal_streamfs_remove_dir_recursive() - Remove streamfs directory recursive + * @d: dentry of the directory + */ +void qal_streamfs_remove_dir_recursive(struct qal_dentry_t *d); + +/** + * qal_streamfs_remove_dir() - Remove streamfs directory + * @d: dentry of the directory + */ +void qal_streamfs_remove_dir(struct qal_dentry_t *d); + +/** + * qal_streamfs_remove_file() - Remove streamfs chan buffer file + * @d: dentry of the buffer file + */ +void qal_streamfs_remove_file(struct qal_dentry_t *d); + /** * qal_streamfs_open() - Create streamfs channel for data trasfer * @base_filename: base name of files to create, %NULL for buffering only @@ -98,9 +140,8 @@ void qal_streamfs_subbufs_consumed(struct qal_streamfs_chan *chan, * * Writes data into the current cpu's channel buffer. */ -inline void qal_streamfs_write(struct qal_streamfs_chan *chan, - const void *data, - size_t length); +void qal_streamfs_write(struct qal_streamfs_chan *chan, const void *data, + size_t length); /** * qal_streamfs_buf_full - boolean, is the channel buffer full? diff --git a/qal/linux/src/qal_streamfs.c b/qal/linux/src/qal_streamfs.c index 45ebc25829..2be7ddc8e0 100644 --- a/qal/linux/src/qal_streamfs.c +++ b/qal/linux/src/qal_streamfs.c @@ -23,6 +23,58 @@ #include #include #include +#include + +struct qal_dentry_t * +qal_streamfs_create_dir(const char *name, struct qal_dentry_t *parent) +{ + struct dentry *dir = NULL; + + if (!name) + return NULL; + + dir = debugfs_create_dir(name, (struct dentry *)parent); + + return (struct qal_dentry_t *)dir; +} +qdf_export_symbol(qal_streamfs_create_dir); + +struct qal_dentry_t * +qal_streamfs_create_file(const char *name, uint16_t mode, + struct qal_dentry_t *parent, + struct qal_streamfs_chan_buf *buf) +{ + struct dentry *file = NULL; + + if (!name) + return NULL; + + file = debugfs_create_file(name, mode, (struct dentry *)parent, + (struct rchan_buf *)buf, + &relay_file_operations); + + return (struct qal_dentry_t *)file; +} +qdf_export_symbol(qal_streamfs_create_file); + +void qal_streamfs_remove_dir_recursive(struct qal_dentry_t *d) +{ + debugfs_remove_recursive((struct dentry *)d); +} +qdf_export_symbol(qal_streamfs_remove_dir_recursive); + +void qal_streamfs_remove_dir(struct qal_dentry_t *d) +{ + debugfs_remove((struct dentry *)d); +} +qdf_export_symbol(qal_streamfs_remove_dir); + +void qal_streamfs_remove_file(struct qal_dentry_t *d) +{ + debugfs_remove((struct dentry *)d); +} +qdf_export_symbol(qal_streamfs_remove_file); + /** * qal_streamfs_open() - Create streamfs channel for data trasfer diff --git a/target_if/cfr/inc/target_if_cfr.h b/target_if/cfr/inc/target_if_cfr.h index 6beff1357a..0d1e39d47c 100644 --- a/target_if/cfr/inc/target_if_cfr.h +++ b/target_if/cfr/inc/target_if_cfr.h @@ -23,6 +23,38 @@ #define PEER_CFR_CAPTURE_ENABLE 1 #define PEER_CFR_CAPTURE_DISABLE 0 +#define IEEE80211_ADDR_LEN 6 + +struct cfr_metadata_version_1 { + u_int8_t peer_addr[IEEE80211_ADDR_LEN]; + u_int8_t status; + u_int8_t capture_bw; + u_int8_t channel_bw; + u_int8_t phy_mode; + u_int16_t prim20_chan; + u_int16_t center_freq1; + u_int16_t center_freq2; + u_int8_t capture_mode; + u_int8_t capture_type; + u_int8_t sts_count; + u_int8_t num_rx_chain; + u_int32_t timestamp; + u_int32_t length; +} __attribute__ ((__packed__)); + +struct csi_cfr_header { + u_int32_t start_magic_num; + u_int32_t vendorid; + u_int8_t cfr_metadata_version; + u_int8_t cfr_data_version; + u_int8_t chip_type; + u_int8_t pltform_type; + u_int32_t Reserved; + + union { + struct cfr_metadata_version_1 meta_v1; + } u; +} __attribute__ ((__packed__)); /** * target_if_cfr_init_pdev() - Inits cfr pdev and registers necessary handlers. @@ -90,3 +122,54 @@ int target_if_cfr_start_capture(struct wlan_objmgr_pdev *pdev, */ int target_if_cfr_stop_capture(struct wlan_objmgr_pdev *pdev, struct wlan_objmgr_peer *peer); + +/** + * target_if_cfr_get_target_type() - Function to get target type + * @psoc: pointer to psoc object + * + * Return: target type of target + */ +int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc); + +/** + * target_if_cfr_set_cfr_support() - Function to set cfr support + * @psoc: pointer to psoc object + * @value: value to be set + */ +void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc, + uint8_t value); + +/** + * target_if_cfr_info_send() - Function to send cfr info to upper layers + * @pdev: pointer to pdev object + * @head: pointer to cfr info head + * @hlen: head len + * @data: pointer to cfr info data + * @dlen: data len + * @tail: pointer to cfr info tail + * @tlen: tail len + */ +void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head, + size_t hlen, void *data, size_t dlen, void *tail, + size_t tlen); + +/** + * cfr_wifi2_0_init_pdev() - Function to init legacy pdev + * @psoc: pointer to psoc object + * @pdev: pointer to pdev object + * + * Return: success/failure status of init + */ +QDF_STATUS cfr_wifi2_0_init_pdev(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev); + +/** + * cfr_wifi2_0_deinit_pdev() - Function to deinit legacy pdev + * @psoc: pointer to psoc object + * @pdev: pointer to pdev object + * + * Return: success/failure status of deinit + */ +QDF_STATUS cfr_wifi2_0_deinit_pdev(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev); + diff --git a/target_if/cfr/src/target_if_cfr.c b/target_if/cfr/src/target_if_cfr.c index 6a6f31f37b..5616c5831e 100644 --- a/target_if/cfr/src/target_if_cfr.c +++ b/target_if/cfr/src/target_if_cfr.c @@ -27,6 +27,7 @@ #include #include #include +#include #include int target_if_cfr_stop_capture(struct wlan_objmgr_pdev *pdev, @@ -73,7 +74,6 @@ int target_if_cfr_start_capture(struct wlan_objmgr_pdev *pdev, param.capture_method = cfr_params->method; retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, ¶m); - return retv; } @@ -131,18 +131,51 @@ int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc) int target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc, struct wlan_objmgr_pdev *pdev) { - if (target_if_cfr_get_target_type(psoc) == TARGET_TYPE_QCA8074V2) + uint32_t target_type; + struct pdev_cfr *pa; + struct psoc_cfr *cfr_sc; + + pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); + if (pa == NULL) + return QDF_STATUS_E_FAILURE; + + cfr_sc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_CFR); + + if (cfr_sc == NULL) + return QDF_STATUS_E_FAILURE; + + target_type = target_if_cfr_get_target_type(psoc); + + if (target_type == TARGET_TYPE_QCA8074V2) { return cfr_8074v2_init_pdev(psoc, pdev); - else - return -EINVAL; + } else if ((target_type == TARGET_TYPE_IPQ4019) || + (target_type == TARGET_TYPE_QCA9984) || + (target_type == TARGET_TYPE_QCA9888)) { + + pa->is_cfr_capable = cfr_sc->is_cfr_capable; + + return cfr_wifi2_0_init_pdev(psoc, pdev); + } else + return QDF_STATUS_E_NOSUPPORT; } int target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc, struct wlan_objmgr_pdev *pdev) { - if (target_if_cfr_get_target_type(psoc) == TARGET_TYPE_QCA8074V2) + uint32_t target_type; + + target_type = target_if_cfr_get_target_type(psoc); + + if (target_type == TARGET_TYPE_QCA8074V2) { return cfr_8074v2_deinit_pdev(psoc, pdev); - return 0; + } else if ((target_type == TARGET_TYPE_IPQ4019) || + (target_type == TARGET_TYPE_QCA9984) || + (target_type == TARGET_TYPE_QCA9888)) { + + return cfr_wifi2_0_deinit_pdev(psoc, pdev); + } else + return QDF_STATUS_E_NOSUPPORT; } void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) @@ -158,3 +191,24 @@ void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) tx_ops->cfr_tx_ops.cfr_stop_capture = target_if_cfr_stop_capture; } + +void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc, + uint8_t value) +{ + if (psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_support_set) + psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_support_set(psoc, value); +} + +void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head, + size_t hlen, void *data, size_t dlen, void *tail, + size_t tlen) +{ + struct wlan_objmgr_psoc *psoc; + + psoc = wlan_pdev_get_psoc(pdev); + + if (psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_info_send) + psoc->soc_cb.rx_ops.cfr_rx_ops.cfr_info_send(pdev, head, hlen, + data, dlen, tail, + tlen); +} diff --git a/target_if/cfr/src/target_if_cfr_wifi2_0.c b/target_if/cfr/src/target_if_cfr_wifi2_0.c new file mode 100644 index 0000000000..e544f73b03 --- /dev/null +++ b/target_if/cfr/src/target_if_cfr_wifi2_0.c @@ -0,0 +1,340 @@ +/* + * Copyright (c) 2019 The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* hardcoded for CFR specific Shared memory */ +#define CFR_CAPTURE_HOST_MEM_REQ_ID 9 +#define CFR_CAPTURE_HOST_MEM_DEFAULT_READ_OFFSET 8 + +/* max subbuf size and number for 2 chains */ +#define MAX_SUBBUF_2S 1100 +#define NUM_SUBBUF_2S 2200 + +/* max subbuf size and number for 4 chains */ +#define MAX_SUBBUF_4S 2304 +#define NUM_SUBBUF_4S 910 +#define MAX_CFR_CLIENTS_LEGACY 10 + +enum cfrmetaversion { + CFR_META_VERSION_NONE, + CFR_META_VERSION_1, + CFR_META_VERSION_MAX = 0xFF, +}; + +enum cfrdataversion { + CFR_DATA_VERSION_NONE, + CFR_DATA_VERSION_1, + CFR_DATA_VERSION_MAX = 0xFF, +}; + +enum cfrplatformtype { + CFR_PLATFORM_TYPE_NONE, + CFR_PLATFORM_TYPE_MIPS, + CFR_PLATFORM_TYPE_ARM, + CFR_PLATFFORM_TYPE_MAX = 0xFF, +}; + +enum cfrradiotype { + CFR_CAPTURE_RADIO_NONE, + CFR_CAPTURE_RADIO_OSPREY, + CFR_CAPTURE_RADIO_PEAKCOCK, + CFR_CAPTURE_RADIO_SCORPION, + CFR_CAPTURE_RADIO_HONEYBEE, + CFR_CAPTURE_RADIO_DRAGONFLY, + CFR_CAPTURE_RADIO_JET, + CFR_CAPTURE_RADIO_PEREGRINE = 17, + CFR_CAPTURE_RADIO_SWIFT, + CFR_CAPTURE_RADIO_BEELINER, + CFR_CAPTURE_RADIO_CASCADE, + CFR_CAPTURE_RADIO_DAKOTA, + CFR_CAPTURE_RADIO_BESRA, + CFR_CAPTURE_RADIO_MAX = 0xFF, +}; + +static u_int8_t * +target_if_mac_addr_deswizzle(u_int8_t *tgt_mac_addr, u_int8_t *buffer) +{ +#if BIG_ENDIAN_HOST + /* + * The host endianness is opposite of the target endianness. + * To make u_int32_t elements come out correctly, the target->host + * upload has swizzled the bytes in each u_int32_t element of the + * message. + * For byte-array message fields like the MAC address, this + * upload swizzling puts the bytes in the wrong order, and needs + * to be undone. + */ + buffer[0] = tgt_mac_addr[3]; + buffer[1] = tgt_mac_addr[2]; + buffer[2] = tgt_mac_addr[1]; + buffer[3] = tgt_mac_addr[0]; + buffer[4] = tgt_mac_addr[7]; + buffer[5] = tgt_mac_addr[6]; + return buffer; +#else + /* + * The host endianness matches the target endianness - + * we can use the mac addr directly from the message buffer. + */ + return tgt_mac_addr; +#endif +} + +int ol_txrx_htt_cfr_rx_ind_handler(void *pdev_ptr, + uint32_t *msg_word, size_t msg_len) +{ + struct wlan_objmgr_pdev *pdev; + struct wlan_objmgr_psoc *psoc; + struct wlan_objmgr_vdev *vdev; + struct pdev_cfr *pa; + u_int32_t *vaddr; + u_int32_t msg_info, cfr_msg_type; + u_int8_t cfr_cap_status, cfr_vdev_id; + u_int32_t cfr_dump_len, cfr_dump_index; + uint32_t status, target_type; + void *prindex = NULL; + + struct csi_cfr_header cfr_header = {0}; + u_int32_t end_magic = 0xBEAFDEAD; + + pdev = (struct wlan_objmgr_pdev *)pdev_ptr; + + status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_CFR_ID); + + if (QDF_IS_STATUS_ERROR(status)) { + qdf_print("%s, %d unable to get reference", __func__, __LINE__); + return status; + } + + pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); + if (pa == NULL) { + wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); + return -1; + } + + if (!pa->is_cfr_capable) { + qdf_print("CFR capture not enabled/supported in Host SW\n"); + wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); + return -1; + } + + psoc = wlan_pdev_get_psoc(pdev); + target_type = target_if_cfr_get_target_type(psoc); + + /* This CFR msg info (bit 8:31) should be checked for any new element + * added in this capture type. Ex:Rssi. TODO: pass msg info,capture type + * and msgword+3 to CFR file, to avoid additional copy? + */ + + msg_info = *msg_word; + cfr_msg_type = *(msg_word + 1); + + /* TODO: Need predefined values for Radio and platform, versions */ + + cfr_header.start_magic_num = 0xDEADBEAF; + cfr_header.vendorid = 0x8cfdf0; + cfr_header.cfr_metadata_version = CFR_META_VERSION_1; + cfr_header.cfr_data_version = CFR_DATA_VERSION_1; + + if (target_type == TARGET_TYPE_IPQ4019) + cfr_header.chip_type = CFR_CAPTURE_RADIO_DAKOTA; + else if (target_type == TARGET_TYPE_QCA9888) + cfr_header.chip_type = CFR_CAPTURE_RADIO_BESRA; + else if (target_type == TARGET_TYPE_QCA9984) + cfr_header.chip_type = CFR_CAPTURE_RADIO_CASCADE; + else + cfr_header.chip_type = CFR_CAPTURE_RADIO_NONE; + + cfr_header.pltform_type = CFR_PLATFORM_TYPE_ARM; + cfr_header.Reserved = 0; + + switch (cfr_msg_type) { + + u_int8_t *peeraddr; + + case HTT_PEER_CFR_CAPTURE_MSG_TYPE_1: + + cfr_header.u.meta_v1.status = + HTT_T2H_CFR_DUMP_TYPE1_STATUS_GET(*(msg_word + 2)); + cfr_cap_status = cfr_header.u.meta_v1.status; + cfr_header.u.meta_v1.capture_bw = + HTT_T2H_CFR_DUMP_TYPE1_CAP_BW_GET(*(msg_word + 2)); + cfr_header.u.meta_v1.capture_mode = + HTT_T2H_CFR_DUMP_TYPE1_MODE_GET(*(msg_word + 2)); + cfr_header.u.meta_v1.sts_count = + HTT_T2H_CFR_DUMP_TYPE1_STS_GET(*(msg_word + 2)); + cfr_header.u.meta_v1.channel_bw = + HTT_T2H_CFR_DUMP_TYPE1_CHAN_BW_GET(*(msg_word + 2)); + cfr_header.u.meta_v1.capture_type = + HTT_T2H_CFR_DUMP_TYPE1_CAP_TYPE_GET(*(msg_word + 2)); + cfr_vdev_id = HTT_T2H_CFR_DUMP_TYPE1_VDEV_ID_GET(*(msg_word + 2)); + + vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, cfr_vdev_id, + WLAN_CFR_ID); + if (vdev == NULL) + cfr_header.u.meta_v1.num_rx_chain = 0; + else { + cfr_header.u.meta_v1.num_rx_chain = + wlan_vdev_mlme_get_rxchainmask(vdev); + wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); + } + + peeraddr = target_if_mac_addr_deswizzle((u_int8_t *) (msg_word+3), + cfr_header.u.meta_v1.peer_addr); + + memcpy(cfr_header.u.meta_v1.peer_addr, peeraddr, 6); + + cfr_dump_index = *(msg_word + 5); + cfr_header.u.meta_v1.length = *(msg_word + 6); + cfr_dump_len = cfr_header.u.meta_v1.length; + cfr_header.u.meta_v1.timestamp = *(msg_word + 7); + cfr_header.u.meta_v1.prim20_chan = *(msg_word + 9); + cfr_header.u.meta_v1.center_freq1 = *(msg_word + 10); + cfr_header.u.meta_v1.center_freq2 = *(msg_word + 11); + cfr_header.u.meta_v1.phy_mode = *(msg_word + 12); + + break; + + default: + qdf_print(" Unsupported CFR capture type:%d\n", cfr_msg_type); + wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); + return -1; + } + + vaddr = pa->cfr_mem_chunk.vaddr; + + if (cfr_cap_status == 1) { + prindex = (void *)((u_int8_t *)vaddr + cfr_dump_index); + + target_if_cfr_info_send(pdev, &cfr_header, + sizeof(struct csi_cfr_header), + prindex, cfr_dump_len, &end_magic, 4); + + *vaddr = cfr_dump_index + cfr_dump_len; + + } else if (cfr_cap_status == 0) { + target_if_cfr_info_send(pdev, &cfr_header, + sizeof(struct csi_cfr_header), + prindex, cfr_dump_len, &end_magic, 4); + } + + wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); + + return 0; +} +EXPORT_SYMBOL(ol_txrx_htt_cfr_rx_ind_handler); + +QDF_STATUS +cfr_wifi2_0_init_pdev(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev) +{ + int idx; + u_int32_t *read_offset; + struct pdev_cfr *pa; + struct target_psoc_info *tgt_hdl; + struct tgt_info *info; + uint32_t target_type; + + pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); + + if (pa == NULL) + return QDF_STATUS_E_FAILURE; + + target_type = target_if_cfr_get_target_type(psoc); + tgt_hdl = (struct target_psoc_info *)wlan_psoc_get_tgt_if_handle(psoc); + + if (tgt_hdl) + info = (&(tgt_hdl->info)); + else + return QDF_STATUS_E_FAILURE; + + if (pa->is_cfr_capable) { + + for (idx = 0; idx < info->num_mem_chunks; ++idx) { + + if (info->mem_chunks[idx].req_id == + CFR_CAPTURE_HOST_MEM_REQ_ID) { + + pa->cfr_mem_chunk.req_id = + info->mem_chunks[idx].req_id; + pa->cfr_mem_chunk.paddr = + info->mem_chunks[idx].paddr; + pa->cfr_mem_chunk.vaddr = + info->mem_chunks[idx].vaddr; + pa->cfr_mem_chunk.len = + info->mem_chunks[idx].len; + read_offset = pa->cfr_mem_chunk.vaddr; + (*read_offset) = + CFR_CAPTURE_HOST_MEM_DEFAULT_READ_OFFSET; + qdf_print("CFR:%s reqid=%d len=%d\n", __func__, + pa->cfr_mem_chunk.req_id, + pa->cfr_mem_chunk.len); + } + + if (idx >= info->num_mem_chunks) { + pa->is_cfr_capable = 0; + qdf_print("WLAN_CSI: Shared memory not allocated + for CSI\n"); + return QDF_STATUS_E_NOMEM; + } + + } + + /* TODO: These values need to be fine-tuned for better optimisation, + * LOW_MEM_SUPPORT ? + */ + + if ((target_type == TARGET_TYPE_IPQ4019) || + (target_type == TARGET_TYPE_QCA9888)) { + pa->cfr_max_sta_count = MAX_CFR_CLIENTS_LEGACY; + pa->subbuf_size = MAX_SUBBUF_2S; + pa->num_subbufs = NUM_SUBBUF_2S; + } else if (target_type == TARGET_TYPE_QCA9984) { + pa->cfr_max_sta_count = MAX_CFR_CLIENTS_LEGACY; + pa->subbuf_size = MAX_SUBBUF_4S; + pa->num_subbufs = NUM_SUBBUF_4S; + } else + return QDF_STATUS_E_NOSUPPORT; + + } else + return QDF_STATUS_E_NOSUPPORT; + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS +cfr_wifi2_0_deinit_pdev(struct wlan_objmgr_psoc *psoc, + struct wlan_objmgr_pdev *pdev) { + + /* TODO:No cleanup action need for now */ + return QDF_STATUS_SUCCESS; +} diff --git a/tools/linux/cfr_test_app.c b/tools/linux/cfr_test_app.c index ac7ec3965f..417e3e386c 100644 --- a/tools/linux/cfr_test_app.c +++ b/tools/linux/cfr_test_app.c @@ -39,7 +39,7 @@ #include #include -#define CFR_DUMP_STREAMFS_FILE "/sys/kernel/debug/%s/cfr_dump0" +#define CFR_DUMP_STREAMFS_FILE "/sys/kernel/debug/cfr%s/cfr_dump0" #define CFR_DUMP_FILE "/tmp/cfr_dump_%s.bin" #define MAX_CAPTURE_SIZE 2048 diff --git a/umac/cfr/core/inc/cfr_defs_i.h b/umac/cfr/core/inc/cfr_defs_i.h index f7aabe509c..3e10f294e4 100644 --- a/umac/cfr/core/inc/cfr_defs_i.h +++ b/umac/cfr/core/inc/cfr_defs_i.h @@ -102,4 +102,44 @@ wlan_cfr_peer_obj_create_handler(struct wlan_objmgr_peer *peer, void *arg); */ QDF_STATUS wlan_cfr_peer_obj_destroy_handler(struct wlan_objmgr_peer *peer, void *arg); + +/** + * cfr_streamfs_init() - stream filesystem init + * @pdev - pointer to pdev object + * + * Return: status of fs init + */ +QDF_STATUS +cfr_streamfs_init(struct wlan_objmgr_pdev *pdev); + +/** + * cfr_streamfs_remove() - stream filesystem remove + * @pdev - pointer to pdev object + * + * Return: status of fs remove + */ +QDF_STATUS +cfr_streamfs_remove(struct wlan_objmgr_pdev *pdev); + +/** + * cfr_streamfs_write() - write to stream filesystem + * @pa - pointer to pdev_cfr object + * @write_data - Pointer to data + * @write_len - data len + * + * Return: status of fs write + */ +QDF_STATUS +cfr_streamfs_write(struct pdev_cfr *pa, const void *write_data, + size_t write_len); + +/** + * cfr_streamfs_flush() - flush the write to streamfs + * @pa - pointer to pdev_cfr object + * + * Return: status of fs flush + */ +QDF_STATUS +cfr_streamfs_flush(struct pdev_cfr *pa); + #endif diff --git a/umac/cfr/core/src/cfr_common.c b/umac/cfr/core/src/cfr_common.c index 9e04f4f25d..9f5de520a2 100644 --- a/umac/cfr/core/src/cfr_common.c +++ b/umac/cfr/core/src/cfr_common.c @@ -19,12 +19,17 @@ #include #include #include -#include +#include +#include +#include +#include +#include +#include +#include QDF_STATUS wlan_cfr_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, void *arg) { - /* CFR is per pdev; psoc doesn't contain any private object for now */ struct psoc_cfr *cfr_sc = NULL; cfr_sc = (struct psoc_cfr *)qdf_mem_malloc(sizeof(struct psoc_cfr)); @@ -34,7 +39,6 @@ wlan_cfr_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, void *arg) } cfr_sc->psoc_obj = psoc; - cfr_sc->is_cfr_capable = 1; wlan_objmgr_psoc_component_obj_attach(psoc, WLAN_UMAC_COMP_CFR, (void *)cfr_sc, @@ -75,10 +79,7 @@ wlan_cfr_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev, void *arg) return QDF_STATUS_E_NOMEM; } - qdf_mem_zero(pa, sizeof(struct pdev_cfr)); pa->pdev_obj = pdev; - pa->is_cfr_capable = 1; /* derive for WMI Service ready capable */ - pa->cfr_timer_enable = 0; wlan_objmgr_pdev_component_obj_attach(pdev, WLAN_UMAC_COMP_CFR, (void *)pa, QDF_STATUS_SUCCESS); @@ -122,7 +123,6 @@ wlan_cfr_peer_obj_create_handler(struct wlan_objmgr_peer *peer, void *arg) return QDF_STATUS_E_FAILURE; } - qdf_mem_zero(pe, sizeof(struct peer_cfr)); pe->peer_obj = peer; /* Remaining will be populated when we give CFR capture command */ @@ -150,3 +150,154 @@ wlan_cfr_peer_obj_destroy_handler(struct wlan_objmgr_peer *peer, void *arg) return QDF_STATUS_SUCCESS; } + +/** + * create_buf_file_handler() - Create streamfs buffer file + * @filename: base name of files to create, NULL for buffering only + * @parent: dentry of parent directory, NULL for root directory + * @mode: filemode + * @rchan_buf: streamfs channel buf + * + * Returns dentry if successful, NULL otherwise. + */ +static struct dentry *create_buf_file_handler(const char *filename, + struct dentry *parent, + umode_t mode, + struct rchan_buf *buf, + int *is_global) +{ + struct qal_dentry_t *buf_file; + *is_global = 1; + buf_file = qal_streamfs_create_file(filename, mode, + (struct qal_dentry_t *)parent, + (struct qal_streamfs_chan_buf *)buf); + + if (!buf_file) { + cfr_err("Chan buffer creation failed\n"); + return NULL; + } + + return (struct dentry *)buf_file; +} + +/** + * remove_buf_file_handler() - Remove streamfs buffer file + * @dentry:dentry + */ +static int remove_buf_file_handler(struct dentry *dentry) +{ + qal_streamfs_remove_file((struct qal_dentry_t *)dentry); + + return 0; +} + +static struct rchan_callbacks cfr_streamfs_cb = { + .create_buf_file = create_buf_file_handler, + .remove_buf_file = remove_buf_file_handler, +}; + +QDF_STATUS cfr_streamfs_init(struct wlan_objmgr_pdev *pdev) +{ + struct pdev_cfr *pa = NULL; + char folder[32]; + struct net_device *pdev_netdev; + struct ol_ath_softc_net80211 *scn; + struct target_pdev_info *tgt_hdl; + + if (pdev == NULL) { + cfr_err("PDEV is NULL\n"); + return QDF_STATUS_E_FAILURE; + } + + tgt_hdl = wlan_pdev_get_tgt_if_handle(pdev); + + if (!tgt_hdl) { + cfr_err("target_pdev_info is NULL\n"); + return QDF_STATUS_E_FAILURE; + } + + scn = target_pdev_get_feature_ptr(tgt_hdl); + pdev_netdev = scn->netdev; + pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); + + if (pa == NULL) { + cfr_err("pdev_cfr is NULL\n"); + return QDF_STATUS_E_FAILURE; + } + + if (!pa->is_cfr_capable) { + cfr_err("CFR IS NOT SUPPORTED\n"); + return QDF_STATUS_E_FAILURE; + } + + snprintf(folder, sizeof(folder), "cfr%s", pdev_netdev->name); + + pa->dir_ptr = qal_streamfs_create_dir((const char *)folder, NULL); + + if (!pa->dir_ptr) { + cfr_err("Directory create failed"); + return QDF_STATUS_E_FAILURE; + } + + pa->chan_ptr = qal_streamfs_open("cfr_dump", pa->dir_ptr, + pa->subbuf_size, pa->num_subbufs, + (struct qal_streamfs_chan_callbacks *)&cfr_streamfs_cb, + NULL); + + if (!pa->chan_ptr) { + cfr_err("Chan create failed"); + qal_streamfs_remove_dir_recursive(pa->dir_ptr); + pa->dir_ptr = NULL; + return QDF_STATUS_E_FAILURE; + } + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS cfr_streamfs_remove(struct wlan_objmgr_pdev *pdev) +{ + struct pdev_cfr *pa = NULL; + + pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); + if (pa) { + if (pa->chan_ptr) { + qal_streamfs_close(pa->chan_ptr); + pa->chan_ptr = NULL; + } + + if (pa->dir_ptr) { + qal_streamfs_remove_dir_recursive(pa->dir_ptr); + pa->dir_ptr = NULL; + } + + } else + return QDF_STATUS_E_FAILURE; + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS cfr_streamfs_write(struct pdev_cfr *pa, const void *write_data, + size_t write_len) +{ + if (pa->chan_ptr) { + + /* write to channel buffer */ + qal_streamfs_write(pa->chan_ptr, (const void *)write_data, + write_len); + } else + return QDF_STATUS_E_FAILURE; + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS cfr_streamfs_flush(struct pdev_cfr *pa) +{ + if (pa->chan_ptr) { + + /* Flush the data write to channel buffer */ + qal_streamfs_flush(pa->chan_ptr); + } else + return QDF_STATUS_E_FAILURE; + + return QDF_STATUS_SUCCESS; +} diff --git a/umac/cfr/dispatcher/inc/wlan_cfr_tgt_api.h b/umac/cfr/dispatcher/inc/wlan_cfr_tgt_api.h index af796ad711..a0e9a1ffbe 100644 --- a/umac/cfr/dispatcher/inc/wlan_cfr_tgt_api.h +++ b/umac/cfr/dispatcher/inc/wlan_cfr_tgt_api.h @@ -78,9 +78,31 @@ int tgt_cfr_stop_capture(struct wlan_objmgr_pdev *pdev, * tgt_cfr_enable_cfr_timer() - API to enable cfr timer * @pdev: pointer to pdev_object * @cfr_timer: Amount of time this timer has to run. If 0, it disables timer. - * - * Return: success/failure of init */ void tgt_cfr_enable_cfr_timer(struct wlan_objmgr_pdev *pdev, uint32_t cfr_timer); + +/** + * tgt_cfr_support_set() - API to set cfr support + * @psoc: pointer to psoc_object + * @value: value to be set + */ +void tgt_cfr_support_set(struct wlan_objmgr_psoc *psoc, uint32_t value); + +/** + * tgt_cfr_info_send() - API to send cfr info + * @pdev: pointer to pdev_object + * @head: pointer to cfr info head + * @hlen: head len + * @data: pointer to cfr info data + * @dlen: data len + * @tail: pointer to cfr info tail + * @tlen: tail len + * + * Return: success/failure of cfr info send + */ +uint32_t tgt_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head, + size_t hlen, void *data, size_t dlen, void *tail, + size_t tlen); + #endif diff --git a/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h b/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h index ffc771515a..016bb195cc 100644 --- a/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h +++ b/umac/cfr/dispatcher/inc/wlan_cfr_utils_api.h @@ -18,7 +18,9 @@ #ifndef _WLAN_CFR_UTILS_API_H_ #define _WLAN_CFR_UTILS_API_H_ + #include +#include /** * struct cfr_capture_params - structure to store cfr config param @@ -42,6 +44,20 @@ struct psoc_cfr { uint8_t is_cfr_capable; }; +/** + * struct cfr_wmi_host_mem_chunk - wmi mem chunk related + * vaddr: pointer to virtual address + * paddr: physical address + * len: len of the mem chunk allocated + * req_id: reqid related to the mem chunk + */ +struct cfr_wmi_host_mem_chunk { + uint32_t *vaddr; + uint32_t paddr; + uint32_t len; + uint32_t req_id; +}; + /** * struct pdev_cfr - private pdev object for cfr * pdev_obj: pointer to pdev object @@ -56,11 +72,14 @@ struct pdev_cfr { struct wlan_objmgr_pdev *pdev_obj; uint8_t is_cfr_capable; uint8_t cfr_timer_enable; - /* - * RealyFS data stucts can be here - * or add RealyFS object speperately per pdev - */ + struct cfr_wmi_host_mem_chunk cfr_mem_chunk; + uint16_t cfr_max_sta_count; + uint16_t cfr_current_sta_count; + uint32_t num_subbufs; + uint32_t subbuf_size; + struct qal_streamfs_chan *chan_ptr; + struct qal_dentry_t *dir_ptr; /* * More fileds will come for data interface * to stitch Tx completion & D-DMA completions @@ -77,12 +96,28 @@ struct pdev_cfr { */ struct peer_cfr { struct wlan_objmgr_peer *peer_obj; - u_int8_t request; /* start/stop */ + u_int8_t request; /* start/stop */ u_int8_t bandwidth; u_int32_t period; u_int8_t capture_method; }; +/** + * cfr_initialize_pdev() - cfr initialize pdev + * @pdev: Pointer to pdev_obj + * + * Return: status of cfr pdev init + */ +QDF_STATUS cfr_initialize_pdev(struct wlan_objmgr_pdev *pdev); + +/** + * cfr_deinitialize_pdev() - cfr deinitialize pdev + * @pdev: Pointer to pdev_obj + * + * Return: status of cfr pdev deinit + */ +QDF_STATUS cfr_deinitialize_pdev(struct wlan_objmgr_pdev *pdev); + /** * wlan_cfr_init() - Global init for cfr. * diff --git a/umac/cfr/dispatcher/src/wlan_cfr_tgt_api.c b/umac/cfr/dispatcher/src/wlan_cfr_tgt_api.c index df8544d1f1..b5cd0f6cea 100644 --- a/umac/cfr/dispatcher/src/wlan_cfr_tgt_api.c +++ b/umac/cfr/dispatcher/src/wlan_cfr_tgt_api.c @@ -24,6 +24,52 @@ #include #include #include +#include + +uint32_t tgt_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head, + size_t hlen, void *data, size_t dlen, void *tail, + size_t tlen) +{ + struct pdev_cfr *pa; + uint32_t status; + + pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); + + if (pa == NULL) { + cfr_err("pdev_cfr is NULL\n"); + return -1; + } + + if (head) + status = cfr_streamfs_write(pa, (const void *)head, hlen); + + if (data) + status = cfr_streamfs_write(pa, (const void *)data, dlen); + + if (tail) + status = cfr_streamfs_write(pa, (const void *)tail, tlen); + + + /* finalise the write */ + status = cfr_streamfs_flush(pa); + + return status; +} + +void tgt_cfr_support_set(struct wlan_objmgr_psoc *psoc, uint32_t value) +{ + struct psoc_cfr *cfr_sc; + + if (psoc == NULL) + return; + + cfr_sc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_CFR); + if (cfr_sc == NULL) + return; + + cfr_sc->is_cfr_capable = !!value; +} static inline struct wlan_lmac_if_cfr_tx_ops * wlan_psoc_get_cfr_txops(struct wlan_objmgr_psoc *psoc) @@ -125,4 +171,5 @@ tgt_cfr_enable_cfr_timer(struct wlan_objmgr_pdev *pdev, uint32_t cfr_timer) if (cfr_tx_ops->cfr_enable_cfr_timer) cfr_tx_ops->cfr_enable_cfr_timer(pdev, cfr_timer); + } diff --git a/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c b/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c index 778564bc8e..5d025438a2 100644 --- a/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c +++ b/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c @@ -50,6 +50,13 @@ int ucfg_cfr_start_capture(struct wlan_objmgr_pdev *pdev, pe->period = params->period; pe->capture_method = params->method; + if (params->period != 0) { + if (!(params->period % 10)) + tgt_cfr_enable_cfr_timer(pdev, 1); + else + return -EINVAL; + } + return tgt_cfr_start_capture(pdev, peer, params); } diff --git a/umac/cfr/dispatcher/src/wlan_cfr_utils_api.c b/umac/cfr/dispatcher/src/wlan_cfr_utils_api.c index cc734c22bd..018086d0f3 100644 --- a/umac/cfr/dispatcher/src/wlan_cfr_utils_api.c +++ b/umac/cfr/dispatcher/src/wlan_cfr_utils_api.c @@ -21,6 +21,7 @@ #include #include "../../core/inc/cfr_defs_i.h" #include +#include QDF_STATUS wlan_cfr_init(void) { @@ -95,11 +96,25 @@ QDF_STATUS wlan_cfr_deinit(void) QDF_STATUS wlan_cfr_pdev_open(struct wlan_objmgr_pdev *pdev) { - int status = QDF_STATUS_SUCCESS; + int status; + /* chip specific init */ status = tgt_cfr_init_pdev(pdev); - return status; + if (status != QDF_STATUS_SUCCESS) { + cfr_err("tgt_cfr_init_pdev failed with %d\n", status); + return QDF_STATUS_SUCCESS; + } + + /* RealyFS init */ + status = cfr_streamfs_init(pdev); + + if (status != QDF_STATUS_SUCCESS) { + cfr_err("cfr_streamfs_init failed with %d\n", status); + return QDF_STATUS_SUCCESS; + } + + return QDF_STATUS_SUCCESS; } QDF_STATUS wlan_cfr_pdev_close(struct wlan_objmgr_pdev *pdev) @@ -110,7 +125,31 @@ QDF_STATUS wlan_cfr_pdev_close(struct wlan_objmgr_pdev *pdev) * but this is getting added as part for new gerrit * Once we have that support we will add it. */ + status = cfr_streamfs_remove(pdev); + + return status; +} + +QDF_STATUS cfr_initialize_pdev(struct wlan_objmgr_pdev *pdev) +{ + int status = QDF_STATUS_SUCCESS; + + /* chip specific init */ + + status = tgt_cfr_init_pdev(pdev); + + return status; +} +qdf_export_symbol(cfr_initialize_pdev); + +QDF_STATUS cfr_deinitialize_pdev(struct wlan_objmgr_pdev *pdev) +{ + int status = QDF_STATUS_SUCCESS; + + /* chip specific deinit */ + status = tgt_cfr_deinit_pdev(pdev); return status; } +qdf_export_symbol(cfr_deinitialize_pdev); diff --git a/wmi/src/wmi_unified_non_tlv.c b/wmi/src/wmi_unified_non_tlv.c index 7d1cb8b3ea..d532ee3aae 100644 --- a/wmi/src/wmi_unified_non_tlv.c +++ b/wmi/src/wmi_unified_non_tlv.c @@ -452,6 +452,47 @@ static QDF_STATUS send_setup_install_key_cmd_non_tlv(wmi_unified_t wmi_handle, } +#ifdef WLAN_CFR_ENABLE +/** + * send_peer_cfr_capture_cmd_non_tlv() - configure cfr params in fw + * @wmi_handle: wmi handle + * @param: pointer to hold peer cfr config parameter + * + * Return: 0 for success or error code + */ +static QDF_STATUS send_peer_cfr_capture_cmd_non_tlv(wmi_unified_t wmi_handle, + struct peer_cfr_params *param) +{ + wmi_peer_cfr_capture_cmd *cmd; + wmi_buf_t buf; + int len = sizeof(wmi_peer_cfr_capture_cmd); + int ret; + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + qdf_print("%s:wmi_buf_alloc failed\n", __func__); + return QDF_STATUS_E_NOMEM; + } + + cmd = (wmi_peer_cfr_capture_cmd *)wmi_buf_data(buf); + WMI_CHAR_ARRAY_TO_MAC_ADDR(param->macaddr, &cmd->mac_addr); + cmd->request = param->request; + cmd->vdev_id = param->vdev_id; + cmd->periodicity = param->periodicity; + cmd->bandwidth = param->bandwidth; + cmd->capture_method = param->capture_method; + + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_PEER_CFR_CAPTURE_CMDID); + if (QDF_IS_STATUS_ERROR(ret)) { + WMI_LOGE("Failed to send WMI_PEER_CFR_CAPTURE_CMDID"); + wmi_buf_free(buf); + } + + return ret; +} +#endif + /** * send_peer_flush_tids_cmd_non_tlv() - flush peer tids packets in fw * @wmi_handle: wmi handle @@ -8912,6 +8953,9 @@ struct wmi_ops non_tlv_ops = { .send_vdev_delete_cmd = send_vdev_delete_cmd_non_tlv, .send_vdev_down_cmd = send_vdev_down_cmd_non_tlv, .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_non_tlv, +#ifdef WLAN_CFR_ENABLE + .send_peer_cfr_capture_cmd = send_peer_cfr_capture_cmd_non_tlv, +#endif .send_peer_param_cmd = send_peer_param_cmd_non_tlv, .send_vdev_up_cmd = send_vdev_up_cmd_non_tlv, .send_peer_create_cmd = send_peer_create_cmd_non_tlv, @@ -9366,6 +9410,8 @@ static void populate_non_tlv_service(uint32_t *wmi_service) WMI_SERVICE_UNAVAILABLE; wmi_service[wmi_service_host_dfs_check_support] = WMI_SERVICE_HOST_DFS_CHECK_SUPPORT; + wmi_service[wmi_service_cfr_capture_support] = + WMI_SERVICE_CFR_CAPTURE_SUPPORT; } /** @@ -9719,6 +9765,8 @@ static void populate_pdev_param_non_tlv(uint32_t *pdev_param) WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB; pdev_param[wmi_pdev_param_enable_peer_retry_stats] = WMI_PDEV_PARAM_ENABLE_PEER_RETRY_STATS; + pdev_param[wmi_pdev_param_per_peer_prd_cfr_enable] = + WMI_PDEV_PARAM_PER_PEER_PERIODIC_CFR_ENABLE; } /**