From 15c52e32f7f49111c161145a1de6fbc381365c09 Mon Sep 17 00:00:00 2001 From: Yu Wang Date: Thu, 6 May 2021 17:15:29 +0800 Subject: [PATCH] qcacmn: Add WMI support for AWGN interference detection Add APIs to extract AWGN information from the DCS WMI interference event received from FW. Change-Id: I4b2f9f4ef012553dac2a405dc7ac12aef9452354 CRs-Fixed: 2958675 --- .../dispatcher/inc/wlan_dcs_public_structs.h | 20 ++++- wmi/inc/wmi_unified_dcs_api.h | 14 +++- wmi/inc/wmi_unified_priv.h | 3 + wmi/src/wmi_unified_dcs_api.c | 12 ++- wmi/src/wmi_unified_dcs_tlv.c | 77 ++++++++++++++++++- 5 files changed, 122 insertions(+), 4 deletions(-) diff --git a/umac/dcs/dispatcher/inc/wlan_dcs_public_structs.h b/umac/dcs/dispatcher/inc/wlan_dcs_public_structs.h index 426b99cb77..44817a1be0 100644 --- a/umac/dcs/dispatcher/inc/wlan_dcs_public_structs.h +++ b/umac/dcs/dispatcher/inc/wlan_dcs_public_structs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, 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 @@ -101,4 +101,22 @@ struct wlan_host_dcs_im_user_stats { uint32_t my_bss_rx_cycle_count; }; +/** + * struct wlan_host_dcs_awgn_info - DCS AWGN info + * @channel_width: Channel width, enum phy_ch_width + * @center_freq: Center frequency of primary channel + * @center_freq0: Center frequency of segment 1 + * @center_freq1: Center frequency of segment 2 + * @chan_bw_intf_bitmap: Per-20MHz interference bitmap, each bit + * indicates 20MHz in which interference is seen, e.g. + * bit0 - primary 20MHz, bit1 - secondary 20MHz, + * bit2 - secondary 40MHz Lower, bit3 - secondary 40MHz Upper + */ +struct wlan_host_dcs_awgn_info { + enum phy_ch_width channel_width; + qdf_freq_t center_freq; + qdf_freq_t center_freq0; + qdf_freq_t center_freq1; + uint32_t chan_bw_intf_bitmap; +}; #endif diff --git a/wmi/inc/wmi_unified_dcs_api.h b/wmi/inc/wmi_unified_dcs_api.h index 057689475d..4a14ead756 100644 --- a/wmi/inc/wmi_unified_dcs_api.h +++ b/wmi/inc/wmi_unified_dcs_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, 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 @@ -57,6 +57,18 @@ QDF_STATUS wmi_extract_dcs_im_tgt_stats( void *evt_buf, struct wlan_host_dcs_im_tgt_stats *wlan_stat); +/* + * wmi_extract_dcs_awgn_info() - extract DCS AWGN interference info from event + * @wmi_handle: WMI handle + * @evt_buf: Pointer to event buffer + * @awgn_info: Pointer to hold AWGN interference info + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS +wmi_extract_dcs_awgn_info(wmi_unified_t wmi_hdl, void *evt_buf, + struct wlan_host_dcs_awgn_info *awgn_info); + /** * wmi_send_dcs_pdev_param() - send dcs pdev param * @wmi_handle: wmi handle diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 5ece381bfd..e61d674f64 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1642,6 +1642,9 @@ QDF_STATUS (*extract_dcs_im_tgt_stats)( wmi_unified_t wmi_handle, void *evt_buf, struct wlan_host_dcs_im_tgt_stats *wlan_stat); + +QDF_STATUS (*extract_dcs_awgn_info)(wmi_unified_t wmi_handle, void *evt_buf, + struct wlan_host_dcs_awgn_info *awgn_info); #else QDF_STATUS (*extract_dcs_interference_type)(wmi_unified_t wmi_handle, void *evt_buf, struct wmi_host_dcs_interference_param *param); diff --git a/wmi/src/wmi_unified_dcs_api.c b/wmi/src/wmi_unified_dcs_api.c index 012c073d0b..073e0465c7 100644 --- a/wmi/src/wmi_unified_dcs_api.c +++ b/wmi/src/wmi_unified_dcs_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, 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 @@ -49,6 +49,16 @@ QDF_STATUS wmi_extract_dcs_im_tgt_stats( return QDF_STATUS_E_FAILURE; } +QDF_STATUS wmi_extract_dcs_awgn_info(wmi_unified_t wmi_hdl, void *evt_buf, + struct wlan_host_dcs_awgn_info *awgn_info) +{ + if (wmi_hdl && wmi_hdl->ops->extract_dcs_awgn_info) + return wmi_hdl->ops->extract_dcs_awgn_info(wmi_hdl, evt_buf, + awgn_info); + + return QDF_STATUS_E_FAILURE; +} + #ifdef ENABLE_HOST_TO_TARGET_CONVERSION QDF_STATUS wmi_send_dcs_pdev_param(wmi_unified_t wmi_handle, uint32_t pdev_idx, diff --git a/wmi/src/wmi_unified_dcs_tlv.c b/wmi/src/wmi_unified_dcs_tlv.c index e7149bd4b0..9a8aa9354e 100644 --- a/wmi/src/wmi_unified_dcs_tlv.c +++ b/wmi/src/wmi_unified_dcs_tlv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, 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 @@ -100,11 +100,86 @@ static QDF_STATUS extract_dcs_im_tgt_stats_tlv( return QDF_STATUS_SUCCESS; } +#ifdef WLAN_FEATURE_11BE +#define WLAN_PHY_CH_WIDTH_320MHZ CH_WIDTH_320MHZ +#else +#define WLAN_PHY_CH_WIDTH_320MHZ CH_WIDTH_INVALID +#endif + +/* + * wmi_map_ch_width() - map wmi channel width to host channel width + * @wmi_width: wmi channel width enum + * + * Return: host channel width, enum phy_ch_width + */ +static inline enum phy_ch_width wmi_map_ch_width(wmi_channel_width wmi_width) +{ + switch (wmi_width) { + case WMI_CHAN_WIDTH_20: + return CH_WIDTH_20MHZ; + case WMI_CHAN_WIDTH_40: + return CH_WIDTH_40MHZ; + case WMI_CHAN_WIDTH_80: + return CH_WIDTH_80MHZ; + case WMI_CHAN_WIDTH_160: + return CH_WIDTH_160MHZ; + case WMI_CHAN_WIDTH_80P80: + return CH_WIDTH_80P80MHZ; + case WMI_CHAN_WIDTH_5: + return CH_WIDTH_5MHZ; + case WMI_CHAN_WIDTH_10: + return CH_WIDTH_10MHZ; + case WMI_CHAN_WIDTH_320: + return WLAN_PHY_CH_WIDTH_320MHZ; + default: + return CH_WIDTH_INVALID; + } +} + +/* + * extract_dcs_awgn_info_tlv() - extract DCS AWGN interference from event + * @wmi_handle: wmi handle + * @param evt_buf: pointer to event buffer + * @param awgn_info: Pointer to hold cw interference + * + * Return: QDF_STATUS_SUCCESS for success or QDF_STATUS_E_* for error + */ +static QDF_STATUS +extract_dcs_awgn_info_tlv(wmi_unified_t wmi_handle, void *evt_buf, + struct wlan_host_dcs_awgn_info *awgn_info) +{ + WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf; + wmi_dcs_awgn_int_t *ev; + + param_buf = evt_buf; + if (!param_buf) + return QDF_STATUS_E_INVAL; + + ev = param_buf->awgn_int; + if (!ev) { + wmi_err("Invalid awgn info"); + return QDF_STATUS_E_INVAL; + } + + awgn_info->channel_width = wmi_map_ch_width(ev->channel_width); + awgn_info->center_freq = (qdf_freq_t)ev->chan_freq; + awgn_info->center_freq0 = (qdf_freq_t)ev->center_freq0; + awgn_info->center_freq1 = (qdf_freq_t)ev->center_freq1; + awgn_info->chan_bw_intf_bitmap = ev->chan_bw_interference_bitmap; + wmi_debug("width: %u, freq: %u, freq0: %u, freq1: %u, bitmap: 0x%x", + awgn_info->channel_width, awgn_info->center_freq, + awgn_info->center_freq0, awgn_info->center_freq1, + awgn_info->chan_bw_intf_bitmap); + + return QDF_STATUS_SUCCESS; +} + void wmi_dcs_attach_tlv(wmi_unified_t wmi_handle) { struct wmi_ops *ops = wmi_handle->ops; ops->extract_dcs_interference_type = extract_dcs_interference_type_tlv; ops->extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv; + ops->extract_dcs_awgn_info = extract_dcs_awgn_info_tlv; }