From 0e634fab651e1b282191bd8cf444a8037ed28b13 Mon Sep 17 00:00:00 2001 From: Naveen Rawat Date: Fri, 13 Apr 2018 16:38:36 -0700 Subject: [PATCH] qcacmn: Add target_if/wmi implementation of get congestion stats Add changes to support get congestion stats(arp stats) from within cp_stats component. Change-Id: Ic3b2f020c0169c9113c1b40738f782cbb3b8f6c5 CRs-Fixed: 2222781 --- .../cp_stats/src/target_if_mc_cp_stats.c | 34 +++++++++++++++++++ wmi/inc/wmi_unified_api.h | 14 ++++++++ wmi/inc/wmi_unified_param.h | 15 ++++++++ wmi/inc/wmi_unified_priv.h | 5 +++ wmi/src/wmi_unified_api.c | 12 +++++++ wmi/src/wmi_unified_tlv.c | 33 ++++++++++++++++++ 6 files changed, 113 insertions(+) diff --git a/target_if/cp_stats/src/target_if_mc_cp_stats.c b/target_if/cp_stats/src/target_if_mc_cp_stats.c index 7d2fe71b73ef..23acde22545c 100644 --- a/target_if/cp_stats/src/target_if_mc_cp_stats.c +++ b/target_if/cp_stats/src/target_if_mc_cp_stats.c @@ -54,6 +54,8 @@ static void target_if_cp_stats_free_stats_event(struct stats_event *ev) ev->pdev_stats = NULL; qdf_mem_free(ev->peer_stats); ev->peer_stats = NULL; + qdf_mem_free(ev->cca_stats); + ev->cca_stats = NULL; } static QDF_STATUS target_if_cp_stats_extract_pdev_stats( @@ -130,6 +132,33 @@ static QDF_STATUS target_if_cp_stats_extract_peer_stats( return QDF_STATUS_SUCCESS; } +static QDF_STATUS target_if_cp_stats_extract_cca_stats( + struct wmi_unified *wmi_hdl, + wmi_host_stats_event *stats_param, + struct stats_event *ev, uint8_t *data) +{ + QDF_STATUS status; + struct wmi_host_congestion_stats stats = {0}; + + status = wmi_extract_cca_stats(wmi_hdl, data, &stats); + if (QDF_IS_STATUS_ERROR(status)) { + cp_stats_debug("no congestion stats"); + return QDF_STATUS_SUCCESS; + } + + ev->cca_stats = qdf_mem_malloc(sizeof(*ev->cca_stats)); + if (!ev->cca_stats) { + cp_stats_err("malloc failed"); + return QDF_STATUS_E_NOMEM; + } + + + ev->cca_stats->vdev_id = stats.vdev_id; + ev->cca_stats->congestion = stats.congestion; + + return QDF_STATUS_SUCCESS; +} + static QDF_STATUS target_if_cp_stats_extract_event(struct wmi_unified *wmi_hdl, struct stats_event *ev, uint8_t *data) @@ -156,6 +185,11 @@ static QDF_STATUS target_if_cp_stats_extract_event(struct wmi_unified *wmi_hdl, if (QDF_IS_STATUS_ERROR(status)) return status; + status = target_if_cp_stats_extract_cca_stats(wmi_hdl, &stats_param, + ev, data); + if (QDF_IS_STATUS_ERROR(status)) + return status; + return QDF_STATUS_SUCCESS; } diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index d087cc4b6811..59808cdf60f1 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -2252,4 +2252,18 @@ QDF_STATUS wmi_unified_invoke_neighbor_report_cmd(void *wmi_hdl, wmi_host_channel_width wmi_get_ch_width_from_phy_mode(void *wmi_hdl, WMI_HOST_WLAN_PHY_MODE phymode); +#ifdef QCA_SUPPORT_CP_STATS +/** + * wmi_extract_cca_stats() - api to extract congestion stats from event buffer + * @wmi_handle: wma handle + * @evt_buf: event buffer + * @datalen: length of buffer + * @stats: buffer to populated after stats extraction + * + * Return: status of operation + */ +QDF_STATUS wmi_extract_cca_stats(wmi_unified_t wmi_handle, void *evt_buf, + struct wmi_host_congestion_stats *stats); +#endif /* QCA_SUPPORT_CP_STATS */ + #endif /* _WMI_UNIFIED_API_H_ */ diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index 73c19aa940cc..6dc74be63660 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -8391,4 +8391,19 @@ struct wmi_obss_color_collision_info { uint32_t obss_color_bitmap_bit0to31; uint32_t obss_color_bitmap_bit32to63; }; + +#ifdef QCA_SUPPORT_CP_STATS +/** + * struct wmi_host_congestion_stats - host definition of congestion stats + * @vdev_id: ID of the vdev to which this info belongs. + * @congestion: This field holds the congestion percentage = + * (busy_time/total_time)*100 + * for the interval from when the vdev was started to the current time + * (or the time at which the vdev was stopped). + */ +struct wmi_host_congestion_stats { + uint32_t vdev_id; + uint32_t congestion; +}; +#endif #endif /* _WMI_UNIFIED_PARAM_H_ */ diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 6a6d12219692..56b9ae6dbab0 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1616,6 +1616,11 @@ QDF_STATUS (*extract_twt_resume_dialog_comp_event)(wmi_unified_t wmi_handle, uint8_t *evt_buf, struct wmi_twt_resume_dialog_complete_event_param *params); #endif + +#ifdef QCA_SUPPORT_CP_STATS +QDF_STATUS (*extract_cca_stats)(wmi_unified_t wmi_handle, void *evt_buf, + struct wmi_host_congestion_stats *stats); +#endif /* QCA_SUPPORT_CP_STATS */ }; /* Forward declartion for psoc*/ diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 011bfde96238..484c55c0a90a 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -7482,3 +7482,15 @@ wmi_host_channel_width wmi_get_ch_width_from_phy_mode(void *wmi_hdl, else return WMI_HOST_CHAN_WIDTH_20; } + +#ifdef QCA_SUPPORT_CP_STATS +QDF_STATUS wmi_extract_cca_stats(wmi_unified_t wmi_handle, void *evt_buf, + struct wmi_host_congestion_stats *stats) +{ + if (wmi_handle->ops->extract_cca_stats) + return wmi_handle->ops->extract_cca_stats(wmi_handle, evt_buf, + stats); + + return QDF_STATUS_E_FAILURE; +} +#endif /* QCA_SUPPORT_CP_STATS */ diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index d33856f30f2f..a50e7b23339d 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -17806,6 +17806,36 @@ static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle, } #endif +#ifdef QCA_SUPPORT_CP_STATS +/** + * extract_cca_stats_tlv - api to extract congestion stats from event buffer + * @wmi_handle: wma handle + * @evt_buf: event buffer + * @out_buff: buffer to populated after stats extraction + * + * Return: status of operation + */ +static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle, + void *evt_buf, struct wmi_host_congestion_stats *out_buff) +{ + WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf; + wmi_congestion_stats *congestion_stats; + + param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf; + congestion_stats = param_buf->congestion_stats; + if (!congestion_stats) { + WMI_LOGD("%s: no cca stats in event buffer", __func__); + return QDF_STATUS_E_INVAL; + } + + out_buff->vdev_id = congestion_stats->vdev_id; + out_buff->congestion = congestion_stats->congestion; + + WMI_LOGD("%s: cca stats event processed", __func__); + return QDF_STATUS_SUCCESS; +} +#endif /* QCA_SUPPORT_CP_STATS */ + /** * save_service_bitmap_tlv() - save service bitmap * @wmi_handle: wmi handle @@ -22891,6 +22921,9 @@ struct wmi_ops tlv_ops = { extract_obss_color_collision_info_tlv, .extract_comb_phyerr = extract_comb_phyerr_tlv, .extract_single_phyerr = extract_single_phyerr_tlv, +#ifdef QCA_SUPPORT_CP_STATS + .extract_cca_stats = extract_cca_stats_tlv, +#endif }; /**