diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index 3e726454e9..3faea337ad 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -4217,23 +4217,6 @@ wmi_unified_send_injector_frame_config_cmd(wmi_unified_t wmi_handle, QDF_STATUS wmi_unified_send_cp_stats_cmd(wmi_unified_t wmi_handle, void *buf_ptr, uint32_t buf_len); -#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS -/** - * wmi_unified_extract_infra_cp_stats() - extract various infra cp statistics - * @wmi_handle: wmi handle - * @evt_buf: event buffer - * @evt_buf_len: length of event buffer - * @params: pointer to store the extracted event info - * - * This function extracts the infra cp statistics from the event - * - * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure - */ -QDF_STATUS -wmi_unified_extract_infra_cp_stats(wmi_unified_t wmi_handle, - void *evt_buf, uint32_t evt_buf_len, - struct infra_cp_stats_event *params); -#endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */ /** * wmi_unified_extract_cp_stats_more_pending() - extract more flag diff --git a/wmi/inc/wmi_unified_cp_stats_api.h b/wmi/inc/wmi_unified_cp_stats_api.h index cbd4f00080..1a1b8ac9d3 100644 --- a/wmi/inc/wmi_unified_cp_stats_api.h +++ b/wmi/inc/wmi_unified_cp_stats_api.h @@ -38,6 +38,30 @@ QDF_STATUS wmi_unified_infra_cp_stats_request_send( wmi_unified_t wmi_handle, struct infra_cp_stats_cmd_info *param); + +/** + * wmi_unified_extract_infra_cp_stats() - extract various infra cp statistics + * @wmi_handle: wmi handle + * @evt_buf: event buffer + * @evt_buf_len: length of event buffer + * @params: pointer to store the extracted event info + * + * This function extracts the infra cp statistics from the event + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS +wmi_unified_extract_infra_cp_stats(wmi_unified_t wmi_handle, + void *evt_buf, uint32_t evt_buf_len, + struct infra_cp_stats_event *params); + +QDF_STATUS wmi_stats_handler(void *buff, int32_t len, + struct infra_cp_stats_event *params); + +QDF_STATUS +extract_infra_cp_stats_tlv(wmi_unified_t wmi_handle, void *evt_buf, + uint32_t evt_buf_len, + struct infra_cp_stats_event *params); #endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */ /** diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 41d5cd4ac5..44e776ea9f 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -3327,22 +3327,6 @@ QDF_STATUS wmi_unified_send_cp_stats_cmd(wmi_unified_t wmi_handle, return QDF_STATUS_E_FAILURE; } -#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS -QDF_STATUS -wmi_unified_extract_infra_cp_stats(wmi_unified_t wmi_handle, - void *evt_buf, uint32_t evt_buf_len, - struct infra_cp_stats_event *params) -{ - if (wmi_handle->ops->extract_infra_cp_stats) - return wmi_handle->ops->extract_infra_cp_stats(wmi_handle, - evt_buf, - evt_buf_len, - params); - - return QDF_STATUS_E_FAILURE; -} -#endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */ - QDF_STATUS wmi_unified_extract_cp_stats_more_pending(wmi_unified_t wmi_handle, void *evt_buf, uint32_t *more_flag) diff --git a/wmi/src/wmi_unified_cp_stats_api.c b/wmi/src/wmi_unified_cp_stats_api.c index 42633c6922..7311dce6b6 100644 --- a/wmi/src/wmi_unified_cp_stats_api.c +++ b/wmi/src/wmi_unified_cp_stats_api.c @@ -33,6 +33,21 @@ wmi_unified_infra_cp_stats_request_send(wmi_unified_t wmi_handle, return QDF_STATUS_E_FAILURE; } + +QDF_STATUS +wmi_unified_extract_infra_cp_stats(wmi_unified_t wmi_handle, + void *evt_buf, uint32_t evt_buf_len, + struct infra_cp_stats_event *params) +{ + if (wmi_handle->ops->extract_infra_cp_stats) + return wmi_handle->ops->extract_infra_cp_stats(wmi_handle, + evt_buf, + evt_buf_len, + params); + + return QDF_STATUS_E_FAILURE; +} + #endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */ QDF_STATUS wmi_unified_stats_request_send(wmi_unified_t wmi_handle, diff --git a/wmi/src/wmi_unified_cp_stats_tlv.c b/wmi/src/wmi_unified_cp_stats_tlv.c index bdd8e225d5..ee846b9b62 100644 --- a/wmi/src/wmi_unified_cp_stats_tlv.c +++ b/wmi/src/wmi_unified_cp_stats_tlv.c @@ -28,13 +28,188 @@ get_stats_req_twt_dialog_id(struct infra_cp_stats_cmd_info *req) { return req->dialog_id; } + +static inline +void wmi_extract_ctrl_path_twt_stats_tlv(void *tag_buf, + struct twt_infra_cp_stats_event *param) +{ + wmi_ctrl_path_twt_stats_struct *wmi_stats_buf = + (wmi_ctrl_path_twt_stats_struct *)tag_buf; + + param->dialog_id = wmi_stats_buf->dialog_id; + param->status = wmi_stats_buf->status; + param->num_sp_cycles = wmi_stats_buf->num_sp_cycles; + param->avg_sp_dur_us = wmi_stats_buf->avg_sp_dur_us; + param->min_sp_dur_us = wmi_stats_buf->min_sp_dur_us; + param->max_sp_dur_us = wmi_stats_buf->max_sp_dur_us; + param->tx_mpdu_per_sp = wmi_stats_buf->tx_mpdu_per_sp; + param->rx_mpdu_per_sp = wmi_stats_buf->rx_mpdu_per_sp; + param->tx_bytes_per_sp = wmi_stats_buf->tx_bytes_per_sp; + param->rx_bytes_per_sp = wmi_stats_buf->rx_bytes_per_sp; + + wmi_debug("dialog_id = %u status = %u", wmi_stats_buf->dialog_id, + wmi_stats_buf->status); + wmi_debug("num_sp_cycles = %u avg_sp_dur_us = 0x%x, \ + min_sp_dur_us = 0x%x, max_sp_dur_us = 0x%x", + wmi_stats_buf->num_sp_cycles, wmi_stats_buf->avg_sp_dur_us, + wmi_stats_buf->min_sp_dur_us, wmi_stats_buf->max_sp_dur_us); + wmi_debug("tx_mpdu_per_sp 0x%x, rx_mpdu_per_sp = 0x%x, \ + tx_bytes_per_sp = 0x%x, rx_bytes_per_sp = 0x%x", + wmi_stats_buf->tx_mpdu_per_sp, wmi_stats_buf->rx_mpdu_per_sp, + wmi_stats_buf->tx_bytes_per_sp, + wmi_stats_buf->rx_bytes_per_sp); +} + +static void wmi_twt_extract_stats_struct(void *tag_buf, + struct infra_cp_stats_event *params) +{ + struct twt_infra_cp_stats_event *twt_params; + + twt_params = params->twt_infra_cp_stats + + params->num_twt_infra_cp_stats; + + wmi_debug("TWT stats struct found - num_twt_cp_stats %d", + params->num_twt_infra_cp_stats); + + params->num_twt_infra_cp_stats++; + wmi_extract_ctrl_path_twt_stats_tlv(tag_buf, twt_params); +} #else static inline uint32_t get_stats_req_twt_dialog_id(struct infra_cp_stats_cmd_info *req) { return 0; } -#endif + +static void wmi_twt_extract_stats_struct(void *tag_buf, + struct infra_cp_stats_event *params) +{ +} +#endif /* WLAN_SUPPORT_TWT */ + +/* + * wmi_stats_extract_tag_struct: function to extract tag structs + * @tag_type: tag type that is to be printed + * @tag_buf: pointer to the tag structure + * @params: buffer to hold parameters extracted from response event + * + * Return: None + */ +static void wmi_stats_extract_tag_struct(uint32_t tag_type, void *tag_buf, + struct infra_cp_stats_event *params) +{ + wmi_debug("tag_type %d", tag_type); + + switch (tag_type) { + case WMITLV_TAG_STRUC_wmi_ctrl_path_pdev_stats_struct: + break; + + case WMITLV_TAG_STRUC_wmi_ctrl_path_mem_stats_struct: + break; + + case WMITLV_TAG_STRUC_wmi_ctrl_path_twt_stats_struct: + wmi_twt_extract_stats_struct(tag_buf, params); + break; + + default: + break; + } +} + +/* + * wmi_stats_handler: parse the wmi event and fill the stats values + * @buff: Buffer containing wmi event + * @len: length of event buffer + * @params: buffer to hold parameters extracted from response event + * + * Return: QDF_STATUS_SUCCESS on success, else other qdf error values + */ +QDF_STATUS wmi_stats_handler(void *buff, int32_t len, + struct infra_cp_stats_event *params) +{ + WMI_CTRL_PATH_STATS_EVENTID_param_tlvs *param_buf; + wmi_ctrl_path_stats_event_fixed_param *ev; + uint8_t *buf_ptr = (uint8_t *)buff; + uint32_t curr_tlv_tag; + uint32_t curr_tlv_len; + uint8_t *tag_start_ptr; + + param_buf = (WMI_CTRL_PATH_STATS_EVENTID_param_tlvs *)buff; + if (!param_buf) + return QDF_STATUS_E_FAILURE; + ev = (wmi_ctrl_path_stats_event_fixed_param *)param_buf->fixed_param; + + curr_tlv_tag = WMITLV_GET_TLVTAG(ev->tlv_header); + curr_tlv_len = WMITLV_GET_TLVLEN(ev->tlv_header); + buf_ptr = (uint8_t *)param_buf->fixed_param; + wmi_debug("Fixed param more %d req_id %d status %d", ev->more, + ev->request_id, ev->status); + params->request_id = ev->request_id; + params->status = ev->status; + + /* buffer should point to next TLV in event */ + buf_ptr += (curr_tlv_len + WMI_TLV_HDR_SIZE); + len -= (curr_tlv_len + WMI_TLV_HDR_SIZE); + + curr_tlv_tag = WMITLV_GET_TLVTAG(WMITLV_GET_HDR(buf_ptr)); + curr_tlv_len = WMITLV_GET_TLVLEN(WMITLV_GET_HDR(buf_ptr)); + + wmi_debug("curr_tlv_len %d curr_tlv_tag %d rem_len %d", len, + curr_tlv_len, curr_tlv_tag); + + while ((len >= curr_tlv_len) && + (curr_tlv_tag >= WMITLV_TAG_FIRST_ARRAY_ENUM)) { + if (curr_tlv_tag == WMITLV_TAG_ARRAY_STRUC) { + /* Move to next WMITLV_TAG_ARRAY_STRUC */ + buf_ptr += WMI_TLV_HDR_SIZE; + len -= WMI_TLV_HDR_SIZE; + if (len <= 0) + break; + } + curr_tlv_tag = WMITLV_GET_TLVTAG(WMITLV_GET_HDR(buf_ptr)); + curr_tlv_len = WMITLV_GET_TLVLEN(WMITLV_GET_HDR(buf_ptr)); + + wmi_debug("curr_tlv_len %d curr_tlv_tag %d rem_len %d", + len, curr_tlv_len, curr_tlv_tag); + if (curr_tlv_len) { + /* point to the tag inside WMITLV_TAG_ARRAY_STRUC */ + tag_start_ptr = buf_ptr + WMI_TLV_HDR_SIZE; + curr_tlv_tag = WMITLV_GET_TLVTAG( + WMITLV_GET_HDR(tag_start_ptr)); + wmi_stats_extract_tag_struct(curr_tlv_tag, + (void *)tag_start_ptr, + params); + } + /* Move to next tag */ + buf_ptr += curr_tlv_len + WMI_TLV_HDR_SIZE; + len -= (curr_tlv_len + WMI_TLV_HDR_SIZE); + + if (len <= 0) + break; + } + + return QDF_STATUS_SUCCESS; +} + +/** + * extract_infra_cp_stats_tlv - api to extract stats information from + * event buffer + * @wmi_handle: wmi handle + * @evt_buf: event buffer + * @evt_buf_len: length of the event buffer + * @params: buffer to populate more flag + * + * Return: QDF_STATUS_SUCCESS on success, else other qdf error values + */ +QDF_STATUS +extract_infra_cp_stats_tlv(wmi_unified_t wmi_handle, void *evt_buf, + uint32_t evt_buf_len, + struct infra_cp_stats_event *params) +{ + wmi_stats_handler(evt_buf, evt_buf_len, params); + return QDF_STATUS_SUCCESS; +} + /** * prepare_infra_cp_stats_buf() - Allocate and prepate wmi cmd request buffer * @wmi_handle: wmi handle diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index a0c34a081c..bfafdf0e88 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -4819,184 +4819,6 @@ static QDF_STATUS send_cp_stats_cmd_tlv(wmi_unified_t wmi_handle, return QDF_STATUS_SUCCESS; } -#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS -#ifdef WLAN_SUPPORT_TWT -static inline -void wmi_extract_ctrl_path_twt_stats_tlv(void *tag_buf, - struct twt_infra_cp_stats_event *param) -{ - wmi_ctrl_path_twt_stats_struct *wmi_stats_buf = - (wmi_ctrl_path_twt_stats_struct *)tag_buf; - - param->dialog_id = wmi_stats_buf->dialog_id; - param->status = wmi_stats_buf->status; - param->num_sp_cycles = wmi_stats_buf->num_sp_cycles; - param->avg_sp_dur_us = wmi_stats_buf->avg_sp_dur_us; - param->min_sp_dur_us = wmi_stats_buf->min_sp_dur_us; - param->max_sp_dur_us = wmi_stats_buf->max_sp_dur_us; - param->tx_mpdu_per_sp = wmi_stats_buf->tx_mpdu_per_sp; - param->rx_mpdu_per_sp = wmi_stats_buf->rx_mpdu_per_sp; - param->tx_bytes_per_sp = wmi_stats_buf->tx_bytes_per_sp; - param->rx_bytes_per_sp = wmi_stats_buf->rx_bytes_per_sp; - - wmi_debug("dialog_id = %u status = %u", wmi_stats_buf->dialog_id, - wmi_stats_buf->status); - wmi_debug("num_sp_cycles = %u avg_sp_dur_us = 0x%x, \ - min_sp_dur_us = 0x%x, max_sp_dur_us = 0x%x", - wmi_stats_buf->num_sp_cycles, wmi_stats_buf->avg_sp_dur_us, - wmi_stats_buf->min_sp_dur_us, wmi_stats_buf->max_sp_dur_us); - wmi_debug("tx_mpdu_per_sp 0x%x, rx_mpdu_per_sp = 0x%x, \ - tx_bytes_per_sp = 0x%x, rx_bytes_per_sp = 0x%x", - wmi_stats_buf->tx_mpdu_per_sp, wmi_stats_buf->rx_mpdu_per_sp, - wmi_stats_buf->tx_bytes_per_sp, - wmi_stats_buf->rx_bytes_per_sp); -} - -static void wmi_twt_extract_stats_struct(void *tag_buf, - struct infra_cp_stats_event *params) -{ - struct twt_infra_cp_stats_event *twt_params; - - twt_params = params->twt_infra_cp_stats + - params->num_twt_infra_cp_stats; - - wmi_debug("TWT stats struct found - num_twt_cp_stats %d", - params->num_twt_infra_cp_stats); - - params->num_twt_infra_cp_stats++; - wmi_extract_ctrl_path_twt_stats_tlv(tag_buf, twt_params); -} -#else -static void wmi_twt_extract_stats_struct(void *tag_buf, - struct infra_cp_stats_event *params) -{ -} -#endif - -/* - * wmi_stats_extract_tag_struct: function to extract tag structs - * @tag_type: tag type that is to be printed - * @tag_buf: pointer to the tag structure - * @params: buffer to hold parameters extracted from response event - * - * Return: None - */ -static void wmi_stats_extract_tag_struct(uint32_t tag_type, void *tag_buf, - struct infra_cp_stats_event *params) -{ - wmi_debug("tag_type %d", tag_type); - - switch (tag_type) { - case WMITLV_TAG_STRUC_wmi_ctrl_path_pdev_stats_struct: - break; - - case WMITLV_TAG_STRUC_wmi_ctrl_path_mem_stats_struct: - break; - - case WMITLV_TAG_STRUC_wmi_ctrl_path_twt_stats_struct: - wmi_twt_extract_stats_struct(tag_buf, params); - break; - - default: - break; - } -} - -/* - * wmi_stats_handler: parse the wmi event and fill the stats values - * @buff: Buffer containing wmi event - * @len: length of event buffer - * @params: buffer to hold parameters extracted from response event - * - * Return: QDF_STATUS_SUCCESS on success, else other qdf error values - */ -static QDF_STATUS wmi_stats_handler(void *buff, int32_t len, - struct infra_cp_stats_event *params) -{ - WMI_CTRL_PATH_STATS_EVENTID_param_tlvs *param_buf; - wmi_ctrl_path_stats_event_fixed_param *ev; - uint8_t *buf_ptr = (uint8_t *)buff; - uint32_t curr_tlv_tag; - uint32_t curr_tlv_len; - uint8_t *tag_start_ptr; - - param_buf = (WMI_CTRL_PATH_STATS_EVENTID_param_tlvs *)buff; - if (!param_buf) - return QDF_STATUS_E_FAILURE; - ev = (wmi_ctrl_path_stats_event_fixed_param *)param_buf->fixed_param; - - curr_tlv_tag = WMITLV_GET_TLVTAG(ev->tlv_header); - curr_tlv_len = WMITLV_GET_TLVLEN(ev->tlv_header); - buf_ptr = (uint8_t *)param_buf->fixed_param; - wmi_debug("Fixed param more %d req_id %d status %d", ev->more, - ev->request_id, ev->status); - params->request_id = ev->request_id; - params->status = ev->status; - - /* buffer should point to next TLV in event */ - buf_ptr += (curr_tlv_len + WMI_TLV_HDR_SIZE); - len -= (curr_tlv_len + WMI_TLV_HDR_SIZE); - - curr_tlv_tag = WMITLV_GET_TLVTAG(WMITLV_GET_HDR(buf_ptr)); - curr_tlv_len = WMITLV_GET_TLVLEN(WMITLV_GET_HDR(buf_ptr)); - - wmi_debug("curr_tlv_len %d curr_tlv_tag %d rem_len %d", len, - curr_tlv_len, curr_tlv_tag); - - while ((len >= curr_tlv_len) && - (curr_tlv_tag >= WMITLV_TAG_FIRST_ARRAY_ENUM)) { - if (curr_tlv_tag == WMITLV_TAG_ARRAY_STRUC) { - /* Move to next WMITLV_TAG_ARRAY_STRUC */ - buf_ptr += WMI_TLV_HDR_SIZE; - len -= WMI_TLV_HDR_SIZE; - if (len <= 0) - break; - } - curr_tlv_tag = WMITLV_GET_TLVTAG(WMITLV_GET_HDR(buf_ptr)); - curr_tlv_len = WMITLV_GET_TLVLEN(WMITLV_GET_HDR(buf_ptr)); - - wmi_debug("curr_tlv_len %d curr_tlv_tag %d rem_len %d", - len, curr_tlv_len, curr_tlv_tag); - if (curr_tlv_len) { - /* point to the tag inside WMITLV_TAG_ARRAY_STRUC */ - tag_start_ptr = buf_ptr + WMI_TLV_HDR_SIZE; - curr_tlv_tag = WMITLV_GET_TLVTAG( - WMITLV_GET_HDR(tag_start_ptr)); - wmi_stats_extract_tag_struct(curr_tlv_tag, - (void *)tag_start_ptr, - params); - } - /* Move to next tag */ - buf_ptr += curr_tlv_len + WMI_TLV_HDR_SIZE; - len -= (curr_tlv_len + WMI_TLV_HDR_SIZE); - - if (len <= 0) - break; - } - - return QDF_STATUS_SUCCESS; -} - -/** - * extract_infra_cp_stats_tlv - api to extract stats information from - * event buffer - * @wmi_handle: wmi handle - * @evt_buf: event buffer - * @evt_buf_len: length of the event buffer - * @params: buffer to populate more flag - * - * Return: QDF_STATUS_SUCCESS on success, else other qdf error values - */ -static QDF_STATUS -extract_infra_cp_stats_tlv(wmi_unified_t wmi_handle, void *evt_buf, - uint32_t evt_buf_len, - struct infra_cp_stats_event *params) -{ - wmi_stats_handler(evt_buf, evt_buf_len, params); - return QDF_STATUS_SUCCESS; -} -#endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */ - /** * extract_cp_stats_more_pending_tlv - api to extract more flag from event data * @wmi_handle: wmi handle