1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name *
5*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for any
6*5113495bSYour Name * purpose with or without fee is hereby granted, provided that the above
7*5113495bSYour Name * copyright notice and this permission notice appear in all copies.
8*5113495bSYour Name *
9*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*5113495bSYour Name * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*5113495bSYour Name * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*5113495bSYour Name * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*5113495bSYour Name * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*5113495bSYour Name * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*5113495bSYour Name * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*5113495bSYour Name */
17*5113495bSYour Name
18*5113495bSYour Name #include "osdep.h"
19*5113495bSYour Name #include "wmi.h"
20*5113495bSYour Name #include "wmi_unified_priv.h"
21*5113495bSYour Name
22*5113495bSYour Name /**
23*5113495bSYour Name * extract_dcs_interference_type_tlv() - extract dcs interference type
24*5113495bSYour Name * from event
25*5113495bSYour Name * @wmi_handle: wmi handle
26*5113495bSYour Name * @evt_buf: pointer to event buffer
27*5113495bSYour Name * @param: Pointer to hold dcs interference param
28*5113495bSYour Name *
29*5113495bSYour Name * Return: 0 for success or error code
30*5113495bSYour Name */
extract_dcs_interference_type_tlv(wmi_unified_t wmi_handle,void * evt_buf,struct wlan_host_dcs_interference_param * param)31*5113495bSYour Name static QDF_STATUS extract_dcs_interference_type_tlv(
32*5113495bSYour Name wmi_unified_t wmi_handle,
33*5113495bSYour Name void *evt_buf, struct wlan_host_dcs_interference_param *param)
34*5113495bSYour Name {
35*5113495bSYour Name WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
36*5113495bSYour Name
37*5113495bSYour Name param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *)evt_buf;
38*5113495bSYour Name if (!param_buf) {
39*5113495bSYour Name wmi_err("Invalid dcs interference event buffer");
40*5113495bSYour Name return QDF_STATUS_E_INVAL;
41*5113495bSYour Name }
42*5113495bSYour Name
43*5113495bSYour Name if (!param_buf->fixed_param) {
44*5113495bSYour Name wmi_err("Invalid fixed param");
45*5113495bSYour Name return QDF_STATUS_E_INVAL;
46*5113495bSYour Name }
47*5113495bSYour Name
48*5113495bSYour Name param->interference_type = param_buf->fixed_param->interference_type;
49*5113495bSYour Name /* Just support tlv currently */
50*5113495bSYour Name param->pdev_id = wmi_handle->ops->convert_target_pdev_id_to_host(
51*5113495bSYour Name wmi_handle,
52*5113495bSYour Name param_buf->fixed_param->pdev_id);
53*5113495bSYour Name
54*5113495bSYour Name return QDF_STATUS_SUCCESS;
55*5113495bSYour Name }
56*5113495bSYour Name
57*5113495bSYour Name /**
58*5113495bSYour Name * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
59*5113495bSYour Name * @wmi_handle: wmi handle
60*5113495bSYour Name * @evt_buf: pointer to event buffer
61*5113495bSYour Name * @wlan_stat: Pointer to hold wlan stats
62*5113495bSYour Name *
63*5113495bSYour Name * Return: 0 for success or error code
64*5113495bSYour Name */
extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,void * evt_buf,struct wlan_host_dcs_im_tgt_stats * wlan_stat)65*5113495bSYour Name static QDF_STATUS extract_dcs_im_tgt_stats_tlv(
66*5113495bSYour Name wmi_unified_t wmi_handle,
67*5113495bSYour Name void *evt_buf,
68*5113495bSYour Name struct wlan_host_dcs_im_tgt_stats *wlan_stat)
69*5113495bSYour Name {
70*5113495bSYour Name WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
71*5113495bSYour Name wlan_dcs_im_tgt_stats_t *ev;
72*5113495bSYour Name
73*5113495bSYour Name param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *)evt_buf;
74*5113495bSYour Name if (!param_buf) {
75*5113495bSYour Name wmi_err("Invalid dcs interference event buffer");
76*5113495bSYour Name return QDF_STATUS_E_INVAL;
77*5113495bSYour Name }
78*5113495bSYour Name
79*5113495bSYour Name ev = param_buf->wlan_stat;
80*5113495bSYour Name if (!ev) {
81*5113495bSYour Name wmi_err("Invalid wlan stat");
82*5113495bSYour Name return QDF_STATUS_E_INVAL;
83*5113495bSYour Name }
84*5113495bSYour Name
85*5113495bSYour Name wlan_stat->reg_tsf32 = ev->reg_tsf32;
86*5113495bSYour Name wlan_stat->last_ack_rssi = ev->last_ack_rssi;
87*5113495bSYour Name wlan_stat->tx_waste_time = ev->tx_waste_time;
88*5113495bSYour Name wlan_stat->rx_time = ev->rx_time;
89*5113495bSYour Name wlan_stat->phyerr_cnt = ev->phyerr_cnt;
90*5113495bSYour Name wlan_stat->mib_stats.listen_time = ev->listen_time;
91*5113495bSYour Name wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
92*5113495bSYour Name wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
93*5113495bSYour Name wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
94*5113495bSYour Name wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
95*5113495bSYour Name wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
96*5113495bSYour Name wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
97*5113495bSYour Name wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
98*5113495bSYour Name wlan_stat->chan_nf = ev->chan_nf;
99*5113495bSYour Name wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
100*5113495bSYour Name
101*5113495bSYour Name return QDF_STATUS_SUCCESS;
102*5113495bSYour Name }
103*5113495bSYour Name
104*5113495bSYour Name /*
105*5113495bSYour Name * extract_dcs_awgn_info_tlv() - extract DCS AWGN interference from event
106*5113495bSYour Name * @wmi_handle: wmi handle
107*5113495bSYour Name * @param evt_buf: pointer to event buffer
108*5113495bSYour Name * @param awgn_info: Pointer to hold cw interference
109*5113495bSYour Name *
110*5113495bSYour Name * Return: QDF_STATUS_SUCCESS for success or QDF_STATUS_E_* for error
111*5113495bSYour Name */
112*5113495bSYour Name static QDF_STATUS
extract_dcs_awgn_info_tlv(wmi_unified_t wmi_handle,void * evt_buf,struct wlan_host_dcs_awgn_info * awgn_info)113*5113495bSYour Name extract_dcs_awgn_info_tlv(wmi_unified_t wmi_handle, void *evt_buf,
114*5113495bSYour Name struct wlan_host_dcs_awgn_info *awgn_info)
115*5113495bSYour Name {
116*5113495bSYour Name WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
117*5113495bSYour Name wmi_dcs_awgn_int_t *ev;
118*5113495bSYour Name
119*5113495bSYour Name param_buf = evt_buf;
120*5113495bSYour Name if (!param_buf)
121*5113495bSYour Name return QDF_STATUS_E_INVAL;
122*5113495bSYour Name
123*5113495bSYour Name ev = param_buf->awgn_int;
124*5113495bSYour Name if (!ev) {
125*5113495bSYour Name wmi_err("Invalid awgn info");
126*5113495bSYour Name return QDF_STATUS_E_INVAL;
127*5113495bSYour Name }
128*5113495bSYour Name
129*5113495bSYour Name awgn_info->channel_width = wmi_map_ch_width(ev->channel_width);
130*5113495bSYour Name awgn_info->center_freq = (qdf_freq_t)ev->chan_freq;
131*5113495bSYour Name awgn_info->center_freq0 = (qdf_freq_t)ev->center_freq0;
132*5113495bSYour Name awgn_info->center_freq1 = (qdf_freq_t)ev->center_freq1;
133*5113495bSYour Name awgn_info->chan_bw_intf_bitmap = ev->chan_bw_interference_bitmap;
134*5113495bSYour Name wmi_debug("width: %u, freq: %u, freq0: %u, freq1: %u, bitmap: 0x%x",
135*5113495bSYour Name awgn_info->channel_width, awgn_info->center_freq,
136*5113495bSYour Name awgn_info->center_freq0, awgn_info->center_freq1,
137*5113495bSYour Name awgn_info->chan_bw_intf_bitmap);
138*5113495bSYour Name
139*5113495bSYour Name return QDF_STATUS_SUCCESS;
140*5113495bSYour Name }
141*5113495bSYour Name
wmi_dcs_attach_tlv(wmi_unified_t wmi_handle)142*5113495bSYour Name void wmi_dcs_attach_tlv(wmi_unified_t wmi_handle)
143*5113495bSYour Name {
144*5113495bSYour Name struct wmi_ops *ops = wmi_handle->ops;
145*5113495bSYour Name
146*5113495bSYour Name ops->extract_dcs_interference_type = extract_dcs_interference_type_tlv;
147*5113495bSYour Name ops->extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv;
148*5113495bSYour Name ops->extract_dcs_awgn_info = extract_dcs_awgn_info_tlv;
149*5113495bSYour Name }
150*5113495bSYour Name
151