1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2021-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
6*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name * above copyright notice and this permission notice appear in all
8*5113495bSYour Name * copies.
9*5113495bSYour Name *
10*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name */
19*5113495bSYour Name
20*5113495bSYour Name /**
21*5113495bSYour Name * DOC: wlan_hdd_sysfs.c
22*5113495bSYour Name *
23*5113495bSYour Name * WLAN Host Device Driver implementation
24*5113495bSYour Name *
25*5113495bSYour Name */
26*5113495bSYour Name
27*5113495bSYour Name #include <linux/module.h>
28*5113495bSYour Name #include <linux/kobject.h>
29*5113495bSYour Name #include <linux/fs.h>
30*5113495bSYour Name #include <linux/string.h>
31*5113495bSYour Name #include "wlan_hdd_includes.h"
32*5113495bSYour Name #include "wlan_hdd_sysfs.h"
33*5113495bSYour Name #include "qwlan_version.h"
34*5113495bSYour Name #include "cds_api.h"
35*5113495bSYour Name #include <wlan_osif_request_manager.h>
36*5113495bSYour Name #include <qdf_mem.h>
37*5113495bSYour Name #ifdef WLAN_POWER_DEBUG
38*5113495bSYour Name #include <sir_api.h>
39*5113495bSYour Name #endif
40*5113495bSYour Name #include "osif_sync.h"
41*5113495bSYour Name #include "wlan_hdd_sysfs_sta_info.h"
42*5113495bSYour Name #include "wlan_hdd_sysfs_channel.h"
43*5113495bSYour Name #include <wlan_hdd_sysfs_fw_mode_config.h>
44*5113495bSYour Name #include <wlan_hdd_sysfs_reassoc.h>
45*5113495bSYour Name #include <wlan_hdd_sysfs_mem_stats.h>
46*5113495bSYour Name #include "wlan_hdd_sysfs_crash_inject.h"
47*5113495bSYour Name #include "wlan_hdd_sysfs_suspend_resume.h"
48*5113495bSYour Name #include "wlan_hdd_sysfs_unit_test.h"
49*5113495bSYour Name #include "wlan_hdd_sysfs_modify_acl.h"
50*5113495bSYour Name #include "wlan_hdd_sysfs_connect_info.h"
51*5113495bSYour Name #include <wlan_hdd_sysfs_scan_disable.h>
52*5113495bSYour Name #include "wlan_hdd_sysfs_dcm.h"
53*5113495bSYour Name #include <wlan_hdd_sysfs_wow_ito.h>
54*5113495bSYour Name #include <wlan_hdd_sysfs_wowl_add_ptrn.h>
55*5113495bSYour Name #include <wlan_hdd_sysfs_wowl_del_ptrn.h>
56*5113495bSYour Name #include <wlan_hdd_sysfs_tx_stbc.h>
57*5113495bSYour Name #include <wlan_hdd_sysfs_wlan_dbg.h>
58*5113495bSYour Name #include <wlan_hdd_sysfs_txrx_fw_st_rst.h>
59*5113495bSYour Name #include <wlan_hdd_sysfs_gtx_bw_mask.h>
60*5113495bSYour Name #include <wlan_hdd_sysfs_scan_config.h>
61*5113495bSYour Name #include <wlan_hdd_sysfs_monitor_mode_channel.h>
62*5113495bSYour Name #include <wlan_hdd_sysfs_range_ext.h>
63*5113495bSYour Name #include <wlan_hdd_sysfs_radar.h>
64*5113495bSYour Name #include <wlan_hdd_sysfs_rts_cts.h>
65*5113495bSYour Name #include <wlan_hdd_sysfs_he_bss_color.h>
66*5113495bSYour Name #include <wlan_hdd_sysfs_txrx_fw_stats.h>
67*5113495bSYour Name #include <wlan_hdd_sysfs_txrx_stats.h>
68*5113495bSYour Name #include <wlan_hdd_sysfs_dp_trace.h>
69*5113495bSYour Name #include <wlan_hdd_sysfs_stats.h>
70*5113495bSYour Name #include <wlan_hdd_sysfs_tdls_peers.h>
71*5113495bSYour Name #include <wlan_hdd_sysfs_temperature.h>
72*5113495bSYour Name #include <wlan_hdd_sysfs_thermal_cfg.h>
73*5113495bSYour Name #include <wlan_hdd_sysfs_motion_detection.h>
74*5113495bSYour Name #include <wlan_hdd_sysfs_ipa.h>
75*5113495bSYour Name #include <wlan_hdd_sysfs_pkt_log.h>
76*5113495bSYour Name #include <wlan_hdd_sysfs_policy_mgr.h>
77*5113495bSYour Name #include <wlan_hdd_sysfs_dp_aggregation.h>
78*5113495bSYour Name #include <wlan_hdd_sysfs_dl_modes.h>
79*5113495bSYour Name #include <wlan_hdd_sysfs_swlm.h>
80*5113495bSYour Name #include <wlan_hdd_sysfs_dump_in_progress.h>
81*5113495bSYour Name #include <wlan_hdd_sysfs_txrx_stats_console.h>
82*5113495bSYour Name #include <wlan_hdd_sysfs_add_timestamp.h>
83*5113495bSYour Name #include "wma_api.h"
84*5113495bSYour Name #include "wlan_hdd_eht.h"
85*5113495bSYour Name #include <wlan_hdd_sysfs_bmiss.h>
86*5113495bSYour Name #include <wlan_hdd_sysfs_get_freq_for_pwr.h>
87*5113495bSYour Name #include <wlan_hdd_sysfs_dp_tx_delay_stats.h>
88*5113495bSYour Name #include <wlan_hdd_sysfs_wifi_features.h>
89*5113495bSYour Name #include <wlan_hdd_sysfs_dp_traffic_end_indication.h>
90*5113495bSYour Name #include <wlan_hdd_sysfs_eht_rate.h>
91*5113495bSYour Name #include <wlan_hdd_sysfs_direct_link_ut_cmd.h>
92*5113495bSYour Name #include <wlan_hdd_sysfs_runtime_pm.h>
93*5113495bSYour Name #include <wlan_hdd_sysfs_log_buffer.h>
94*5113495bSYour Name #include <wlan_hdd_sysfs_dfsnol.h>
95*5113495bSYour Name #include <wlan_hdd_sysfs_wds_mode.h>
96*5113495bSYour Name #include <wlan_hdd_sysfs_roam_trigger_bitmap.h>
97*5113495bSYour Name #include <wlan_hdd_sysfs_bitrates.h>
98*5113495bSYour Name #include <wlan_hdd_sysfs_rf_test_mode.h>
99*5113495bSYour Name #include "wlan_module_ids.h"
100*5113495bSYour Name #include <wlan_coex_ucfg_api.h>
101*5113495bSYour Name
102*5113495bSYour Name #define MAX_PSOC_ID_SIZE 10
103*5113495bSYour Name
104*5113495bSYour Name #ifdef MULTI_IF_NAME
105*5113495bSYour Name #define DRIVER_NAME MULTI_IF_NAME
106*5113495bSYour Name #else
107*5113495bSYour Name #define DRIVER_NAME "wifi"
108*5113495bSYour Name #endif
109*5113495bSYour Name
110*5113495bSYour Name static struct kobject *wlan_kobject;
111*5113495bSYour Name static struct kobject *driver_kobject;
112*5113495bSYour Name static struct kobject *fw_kobject;
113*5113495bSYour Name static struct kobject *psoc_kobject;
114*5113495bSYour Name static struct kobject *wifi_kobject;
115*5113495bSYour Name
116*5113495bSYour Name int
hdd_sysfs_validate_and_copy_buf(char * dest_buf,size_t dest_buf_size,char const * source_buf,size_t source_buf_size)117*5113495bSYour Name hdd_sysfs_validate_and_copy_buf(char *dest_buf, size_t dest_buf_size,
118*5113495bSYour Name char const *source_buf, size_t source_buf_size)
119*5113495bSYour Name {
120*5113495bSYour Name if (source_buf_size > (dest_buf_size - 1)) {
121*5113495bSYour Name hdd_err_rl("Command length is larger than %zu bytes",
122*5113495bSYour Name dest_buf_size);
123*5113495bSYour Name return -EINVAL;
124*5113495bSYour Name }
125*5113495bSYour Name
126*5113495bSYour Name /* sysfs already provides kernel space buffer so copy from user
127*5113495bSYour Name * is not needed. Doing this extra copy operation just to ensure
128*5113495bSYour Name * the local buf is properly null-terminated.
129*5113495bSYour Name */
130*5113495bSYour Name strlcpy(dest_buf, source_buf, dest_buf_size);
131*5113495bSYour Name /* default 'echo' cmd takes new line character to here */
132*5113495bSYour Name if (dest_buf[source_buf_size - 1] == '\n')
133*5113495bSYour Name dest_buf[source_buf_size - 1] = '\0';
134*5113495bSYour Name
135*5113495bSYour Name return 0;
136*5113495bSYour Name }
137*5113495bSYour Name
__show_driver_version(char * buf)138*5113495bSYour Name static ssize_t __show_driver_version(char *buf)
139*5113495bSYour Name {
140*5113495bSYour Name return scnprintf(buf, PAGE_SIZE, QWLAN_VERSIONSTR);
141*5113495bSYour Name }
142*5113495bSYour Name
show_driver_version(struct kobject * kobj,struct kobj_attribute * attr,char * buf)143*5113495bSYour Name static ssize_t show_driver_version(struct kobject *kobj,
144*5113495bSYour Name struct kobj_attribute *attr,
145*5113495bSYour Name char *buf)
146*5113495bSYour Name {
147*5113495bSYour Name struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
148*5113495bSYour Name struct osif_psoc_sync *psoc_sync;
149*5113495bSYour Name ssize_t length;
150*5113495bSYour Name int errno;
151*5113495bSYour Name
152*5113495bSYour Name errno = wlan_hdd_validate_context(hdd_ctx);
153*5113495bSYour Name if (errno)
154*5113495bSYour Name return errno;
155*5113495bSYour Name
156*5113495bSYour Name errno = osif_psoc_sync_op_start(hdd_ctx->parent_dev, &psoc_sync);
157*5113495bSYour Name if (errno)
158*5113495bSYour Name return errno;
159*5113495bSYour Name
160*5113495bSYour Name length = __show_driver_version(buf);
161*5113495bSYour Name
162*5113495bSYour Name osif_psoc_sync_op_stop(psoc_sync);
163*5113495bSYour Name
164*5113495bSYour Name return length;
165*5113495bSYour Name }
166*5113495bSYour Name
__show_fw_version(struct hdd_context * hdd_ctx,char * buf)167*5113495bSYour Name static ssize_t __show_fw_version(struct hdd_context *hdd_ctx,
168*5113495bSYour Name char *buf)
169*5113495bSYour Name {
170*5113495bSYour Name hdd_debug("Rcvd req for FW version");
171*5113495bSYour Name
172*5113495bSYour Name return scnprintf(buf, PAGE_SIZE,
173*5113495bSYour Name "FW:%d.%d.%d.%d.%d.%d HW:%s Board version: %x Ref design id: %x Customer id: %x Project id: %x Board Data Rev: %x\n",
174*5113495bSYour Name hdd_ctx->fw_version_info.major_spid,
175*5113495bSYour Name hdd_ctx->fw_version_info.minor_spid,
176*5113495bSYour Name hdd_ctx->fw_version_info.siid,
177*5113495bSYour Name hdd_ctx->fw_version_info.rel_id,
178*5113495bSYour Name hdd_ctx->fw_version_info.crmid,
179*5113495bSYour Name hdd_ctx->fw_version_info.sub_id,
180*5113495bSYour Name hdd_ctx->target_hw_name,
181*5113495bSYour Name hdd_ctx->hw_bd_info.bdf_version,
182*5113495bSYour Name hdd_ctx->hw_bd_info.ref_design_id,
183*5113495bSYour Name hdd_ctx->hw_bd_info.customer_id,
184*5113495bSYour Name hdd_ctx->hw_bd_info.project_id,
185*5113495bSYour Name hdd_ctx->hw_bd_info.board_data_rev);
186*5113495bSYour Name }
187*5113495bSYour Name
show_fw_version(struct kobject * kobj,struct kobj_attribute * attr,char * buf)188*5113495bSYour Name static ssize_t show_fw_version(struct kobject *kobj,
189*5113495bSYour Name struct kobj_attribute *attr,
190*5113495bSYour Name char *buf)
191*5113495bSYour Name {
192*5113495bSYour Name struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
193*5113495bSYour Name struct osif_psoc_sync *psoc_sync;
194*5113495bSYour Name ssize_t length;
195*5113495bSYour Name int errno;
196*5113495bSYour Name
197*5113495bSYour Name errno = wlan_hdd_validate_context(hdd_ctx);
198*5113495bSYour Name if (errno)
199*5113495bSYour Name return errno;
200*5113495bSYour Name
201*5113495bSYour Name errno = osif_psoc_sync_op_start(hdd_ctx->parent_dev, &psoc_sync);
202*5113495bSYour Name if (errno)
203*5113495bSYour Name return errno;
204*5113495bSYour Name
205*5113495bSYour Name length = __show_fw_version(hdd_ctx, buf);
206*5113495bSYour Name
207*5113495bSYour Name osif_psoc_sync_op_stop(psoc_sync);
208*5113495bSYour Name
209*5113495bSYour Name return length;
210*5113495bSYour Name };
211*5113495bSYour Name
212*5113495bSYour Name #ifdef WLAN_POWER_DEBUG
213*5113495bSYour Name struct power_stats_priv {
214*5113495bSYour Name struct power_stats_response power_stats;
215*5113495bSYour Name };
216*5113495bSYour Name
hdd_power_debugstats_dealloc(void * priv)217*5113495bSYour Name static void hdd_power_debugstats_dealloc(void *priv)
218*5113495bSYour Name {
219*5113495bSYour Name struct power_stats_priv *stats = priv;
220*5113495bSYour Name
221*5113495bSYour Name qdf_mem_free(stats->power_stats.debug_registers);
222*5113495bSYour Name stats->power_stats.debug_registers = NULL;
223*5113495bSYour Name }
224*5113495bSYour Name
hdd_power_debugstats_cb(struct power_stats_response * response,void * context)225*5113495bSYour Name static void hdd_power_debugstats_cb(struct power_stats_response *response,
226*5113495bSYour Name void *context)
227*5113495bSYour Name {
228*5113495bSYour Name struct osif_request *request;
229*5113495bSYour Name struct power_stats_priv *priv;
230*5113495bSYour Name uint32_t *debug_registers;
231*5113495bSYour Name uint32_t debug_registers_len;
232*5113495bSYour Name
233*5113495bSYour Name hdd_enter();
234*5113495bSYour Name
235*5113495bSYour Name request = osif_request_get(context);
236*5113495bSYour Name if (!request) {
237*5113495bSYour Name hdd_err("Obsolete request");
238*5113495bSYour Name return;
239*5113495bSYour Name }
240*5113495bSYour Name
241*5113495bSYour Name priv = osif_request_priv(request);
242*5113495bSYour Name
243*5113495bSYour Name /* copy fixed-sized data */
244*5113495bSYour Name priv->power_stats = *response;
245*5113495bSYour Name
246*5113495bSYour Name /* copy variable-size data */
247*5113495bSYour Name if (response->num_debug_register) {
248*5113495bSYour Name debug_registers_len = (sizeof(response->debug_registers[0]) *
249*5113495bSYour Name response->num_debug_register);
250*5113495bSYour Name debug_registers = qdf_mem_malloc(debug_registers_len);
251*5113495bSYour Name priv->power_stats.debug_registers = debug_registers;
252*5113495bSYour Name if (debug_registers) {
253*5113495bSYour Name qdf_mem_copy(debug_registers,
254*5113495bSYour Name response->debug_registers,
255*5113495bSYour Name debug_registers_len);
256*5113495bSYour Name } else {
257*5113495bSYour Name hdd_err("Power stats memory alloc fails!");
258*5113495bSYour Name priv->power_stats.num_debug_register = 0;
259*5113495bSYour Name }
260*5113495bSYour Name }
261*5113495bSYour Name osif_request_complete(request);
262*5113495bSYour Name osif_request_put(request);
263*5113495bSYour Name hdd_exit();
264*5113495bSYour Name }
265*5113495bSYour Name
__show_device_power_stats(struct hdd_context * hdd_ctx,char * buf)266*5113495bSYour Name static ssize_t __show_device_power_stats(struct hdd_context *hdd_ctx,
267*5113495bSYour Name char *buf)
268*5113495bSYour Name {
269*5113495bSYour Name QDF_STATUS status;
270*5113495bSYour Name struct power_stats_response *chip_power_stats;
271*5113495bSYour Name ssize_t ret_cnt = 0;
272*5113495bSYour Name int j;
273*5113495bSYour Name void *cookie;
274*5113495bSYour Name struct osif_request *request;
275*5113495bSYour Name struct power_stats_priv *priv;
276*5113495bSYour Name static const struct osif_request_params params = {
277*5113495bSYour Name .priv_size = sizeof(*priv),
278*5113495bSYour Name .timeout_ms = WLAN_WAIT_TIME_STATS,
279*5113495bSYour Name .dealloc = hdd_power_debugstats_dealloc,
280*5113495bSYour Name };
281*5113495bSYour Name
282*5113495bSYour Name hdd_enter();
283*5113495bSYour Name
284*5113495bSYour Name request = osif_request_alloc(¶ms);
285*5113495bSYour Name if (!request) {
286*5113495bSYour Name hdd_err("Request allocation failure");
287*5113495bSYour Name return -ENOMEM;
288*5113495bSYour Name }
289*5113495bSYour Name cookie = osif_request_cookie(request);
290*5113495bSYour Name
291*5113495bSYour Name status = sme_power_debug_stats_req(hdd_ctx->mac_handle,
292*5113495bSYour Name hdd_power_debugstats_cb,
293*5113495bSYour Name cookie);
294*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
295*5113495bSYour Name hdd_err("chip power stats request failed");
296*5113495bSYour Name ret_cnt = qdf_status_to_os_return(status);
297*5113495bSYour Name goto cleanup;
298*5113495bSYour Name }
299*5113495bSYour Name
300*5113495bSYour Name ret_cnt = osif_request_wait_for_response(request);
301*5113495bSYour Name if (ret_cnt) {
302*5113495bSYour Name hdd_err("Target response timed out Power stats");
303*5113495bSYour Name sme_reset_power_debug_stats_cb(hdd_ctx->mac_handle);
304*5113495bSYour Name ret_cnt = -ETIMEDOUT;
305*5113495bSYour Name goto cleanup;
306*5113495bSYour Name }
307*5113495bSYour Name priv = osif_request_priv(request);
308*5113495bSYour Name chip_power_stats = &priv->power_stats;
309*5113495bSYour Name
310*5113495bSYour Name ret_cnt += scnprintf(buf, PAGE_SIZE,
311*5113495bSYour Name "POWER DEBUG STATS\n=================\n"
312*5113495bSYour Name "cumulative_sleep_time_ms: %d\n"
313*5113495bSYour Name "cumulative_total_on_time_ms: %d\n"
314*5113495bSYour Name "deep_sleep_enter_counter: %d\n"
315*5113495bSYour Name "last_deep_sleep_enter_tstamp_ms: %d\n"
316*5113495bSYour Name "debug_register_fmt: %d\n"
317*5113495bSYour Name "num_debug_register: %d\n",
318*5113495bSYour Name chip_power_stats->cumulative_sleep_time_ms,
319*5113495bSYour Name chip_power_stats->cumulative_total_on_time_ms,
320*5113495bSYour Name chip_power_stats->deep_sleep_enter_counter,
321*5113495bSYour Name chip_power_stats->last_deep_sleep_enter_tstamp_ms,
322*5113495bSYour Name chip_power_stats->debug_register_fmt,
323*5113495bSYour Name chip_power_stats->num_debug_register);
324*5113495bSYour Name
325*5113495bSYour Name for (j = 0; j < chip_power_stats->num_debug_register; j++) {
326*5113495bSYour Name if ((PAGE_SIZE - ret_cnt) > 0)
327*5113495bSYour Name ret_cnt += scnprintf(buf + ret_cnt,
328*5113495bSYour Name PAGE_SIZE - ret_cnt,
329*5113495bSYour Name "debug_registers[%d]: 0x%x\n", j,
330*5113495bSYour Name chip_power_stats->debug_registers[j]);
331*5113495bSYour Name else
332*5113495bSYour Name j = chip_power_stats->num_debug_register;
333*5113495bSYour Name }
334*5113495bSYour Name
335*5113495bSYour Name cleanup:
336*5113495bSYour Name osif_request_put(request);
337*5113495bSYour Name hdd_exit();
338*5113495bSYour Name return ret_cnt;
339*5113495bSYour Name }
340*5113495bSYour Name
show_device_power_stats(struct kobject * kobj,struct kobj_attribute * attr,char * buf)341*5113495bSYour Name static ssize_t show_device_power_stats(struct kobject *kobj,
342*5113495bSYour Name struct kobj_attribute *attr,
343*5113495bSYour Name char *buf)
344*5113495bSYour Name {
345*5113495bSYour Name struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
346*5113495bSYour Name struct osif_psoc_sync *psoc_sync;
347*5113495bSYour Name ssize_t length;
348*5113495bSYour Name int errno;
349*5113495bSYour Name
350*5113495bSYour Name errno = wlan_hdd_validate_context(hdd_ctx);
351*5113495bSYour Name if (errno)
352*5113495bSYour Name return errno;
353*5113495bSYour Name
354*5113495bSYour Name errno = osif_psoc_sync_op_start(hdd_ctx->parent_dev, &psoc_sync);
355*5113495bSYour Name if (errno)
356*5113495bSYour Name return errno;
357*5113495bSYour Name
358*5113495bSYour Name length = __show_device_power_stats(hdd_ctx, buf);
359*5113495bSYour Name
360*5113495bSYour Name osif_psoc_sync_op_stop(psoc_sync);
361*5113495bSYour Name
362*5113495bSYour Name return length;
363*5113495bSYour Name }
364*5113495bSYour Name #endif
365*5113495bSYour Name
366*5113495bSYour Name #ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
367*5113495bSYour Name struct beacon_reception_stats_priv {
368*5113495bSYour Name struct bcn_reception_stats_rsp beacon_stats;
369*5113495bSYour Name };
370*5113495bSYour Name
hdd_beacon_debugstats_cb(struct bcn_reception_stats_rsp * response,void * context)371*5113495bSYour Name static void hdd_beacon_debugstats_cb(struct bcn_reception_stats_rsp
372*5113495bSYour Name *response,
373*5113495bSYour Name void *context)
374*5113495bSYour Name {
375*5113495bSYour Name struct osif_request *request;
376*5113495bSYour Name struct beacon_reception_stats_priv *priv;
377*5113495bSYour Name
378*5113495bSYour Name hdd_enter();
379*5113495bSYour Name
380*5113495bSYour Name request = osif_request_get(context);
381*5113495bSYour Name if (!request) {
382*5113495bSYour Name hdd_err("Obsolete request");
383*5113495bSYour Name return;
384*5113495bSYour Name }
385*5113495bSYour Name
386*5113495bSYour Name priv = osif_request_priv(request);
387*5113495bSYour Name
388*5113495bSYour Name /* copy fixed-sized data */
389*5113495bSYour Name priv->beacon_stats = *response;
390*5113495bSYour Name
391*5113495bSYour Name osif_request_complete(request);
392*5113495bSYour Name osif_request_put(request);
393*5113495bSYour Name hdd_exit();
394*5113495bSYour Name }
395*5113495bSYour Name
__show_beacon_reception_stats(struct net_device * net_dev,char * buf)396*5113495bSYour Name static ssize_t __show_beacon_reception_stats(struct net_device *net_dev,
397*5113495bSYour Name char *buf)
398*5113495bSYour Name {
399*5113495bSYour Name struct hdd_adapter *adapter = netdev_priv(net_dev);
400*5113495bSYour Name struct bcn_reception_stats_rsp *beacon_stats;
401*5113495bSYour Name int ret_val, j;
402*5113495bSYour Name void *cookie;
403*5113495bSYour Name struct osif_request *request;
404*5113495bSYour Name struct beacon_reception_stats_priv *priv;
405*5113495bSYour Name static const struct osif_request_params params = {
406*5113495bSYour Name .priv_size = sizeof(*priv),
407*5113495bSYour Name .timeout_ms = WLAN_WAIT_TIME_STATS,
408*5113495bSYour Name };
409*5113495bSYour Name struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
410*5113495bSYour Name QDF_STATUS status;
411*5113495bSYour Name
412*5113495bSYour Name ret_val = wlan_hdd_validate_context(hdd_ctx);
413*5113495bSYour Name if (ret_val)
414*5113495bSYour Name return ret_val;
415*5113495bSYour Name
416*5113495bSYour Name if (!adapter || adapter->magic != WLAN_HDD_ADAPTER_MAGIC) {
417*5113495bSYour Name hdd_err("Invalid adapter or adapter has invalid magic");
418*5113495bSYour Name return -EINVAL;
419*5113495bSYour Name }
420*5113495bSYour Name
421*5113495bSYour Name if (!test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) {
422*5113495bSYour Name hdd_err("Interface is not enabled");
423*5113495bSYour Name return -EINVAL;
424*5113495bSYour Name }
425*5113495bSYour Name
426*5113495bSYour Name if (!(adapter->device_mode == QDF_STA_MODE ||
427*5113495bSYour Name adapter->device_mode == QDF_P2P_CLIENT_MODE)) {
428*5113495bSYour Name hdd_err("Beacon Reception Stats only supported in STA or P2P CLI modes!");
429*5113495bSYour Name return -ENOTSUPP;
430*5113495bSYour Name }
431*5113495bSYour Name
432*5113495bSYour Name if (!hdd_cm_is_vdev_associated(adapter->deflink)) {
433*5113495bSYour Name hdd_err("Adapter is not in connected state");
434*5113495bSYour Name return -EINVAL;
435*5113495bSYour Name }
436*5113495bSYour Name
437*5113495bSYour Name request = osif_request_alloc(¶ms);
438*5113495bSYour Name if (!request) {
439*5113495bSYour Name hdd_err("Request allocation failure");
440*5113495bSYour Name return -ENOMEM;
441*5113495bSYour Name }
442*5113495bSYour Name cookie = osif_request_cookie(request);
443*5113495bSYour Name
444*5113495bSYour Name status = sme_beacon_debug_stats_req(hdd_ctx->mac_handle,
445*5113495bSYour Name adapter->deflink->vdev_id,
446*5113495bSYour Name hdd_beacon_debugstats_cb,
447*5113495bSYour Name cookie);
448*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
449*5113495bSYour Name hdd_err("chip power stats request failed");
450*5113495bSYour Name ret_val = -EINVAL;
451*5113495bSYour Name goto cleanup;
452*5113495bSYour Name }
453*5113495bSYour Name
454*5113495bSYour Name ret_val = osif_request_wait_for_response(request);
455*5113495bSYour Name if (ret_val) {
456*5113495bSYour Name hdd_err("Target response timed out Power stats");
457*5113495bSYour Name ret_val = -ETIMEDOUT;
458*5113495bSYour Name goto cleanup;
459*5113495bSYour Name }
460*5113495bSYour Name priv = osif_request_priv(request);
461*5113495bSYour Name beacon_stats = &priv->beacon_stats;
462*5113495bSYour Name
463*5113495bSYour Name ret_val += scnprintf(buf, PAGE_SIZE,
464*5113495bSYour Name "BEACON RECEPTION STATS\n=================\n"
465*5113495bSYour Name "vdev id: %u\n"
466*5113495bSYour Name "Total Beacon Count: %u\n"
467*5113495bSYour Name "Total Beacon Miss Count: %u\n",
468*5113495bSYour Name beacon_stats->vdev_id,
469*5113495bSYour Name beacon_stats->total_bcn_cnt,
470*5113495bSYour Name beacon_stats->total_bmiss_cnt);
471*5113495bSYour Name
472*5113495bSYour Name ret_val += scnprintf(buf + ret_val, PAGE_SIZE - ret_val,
473*5113495bSYour Name "Beacon Miss Bit map ");
474*5113495bSYour Name
475*5113495bSYour Name for (j = 0; j < MAX_BCNMISS_BITMAP; j++) {
476*5113495bSYour Name if ((PAGE_SIZE - ret_val) > 0) {
477*5113495bSYour Name ret_val += scnprintf(buf + ret_val,
478*5113495bSYour Name PAGE_SIZE - ret_val,
479*5113495bSYour Name "[0x%x] ",
480*5113495bSYour Name beacon_stats->bmiss_bitmap[j]);
481*5113495bSYour Name }
482*5113495bSYour Name }
483*5113495bSYour Name
484*5113495bSYour Name if ((PAGE_SIZE - ret_val) > 0)
485*5113495bSYour Name ret_val += scnprintf(buf + ret_val,
486*5113495bSYour Name PAGE_SIZE - ret_val,
487*5113495bSYour Name "\n");
488*5113495bSYour Name cleanup:
489*5113495bSYour Name osif_request_put(request);
490*5113495bSYour Name hdd_exit();
491*5113495bSYour Name return ret_val;
492*5113495bSYour Name }
493*5113495bSYour Name
show_beacon_reception_stats(struct device * dev,struct device_attribute * attr,char * buf)494*5113495bSYour Name static ssize_t show_beacon_reception_stats(struct device *dev,
495*5113495bSYour Name struct device_attribute *attr,
496*5113495bSYour Name char *buf)
497*5113495bSYour Name {
498*5113495bSYour Name struct net_device *net_dev = container_of(dev, struct net_device, dev);
499*5113495bSYour Name struct osif_vdev_sync *vdev_sync;
500*5113495bSYour Name ssize_t err_size;
501*5113495bSYour Name
502*5113495bSYour Name err_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
503*5113495bSYour Name if (err_size)
504*5113495bSYour Name return err_size;
505*5113495bSYour Name
506*5113495bSYour Name err_size = __show_beacon_reception_stats(net_dev, buf);
507*5113495bSYour Name
508*5113495bSYour Name osif_vdev_sync_op_stop(vdev_sync);
509*5113495bSYour Name
510*5113495bSYour Name return err_size;
511*5113495bSYour Name }
512*5113495bSYour Name
513*5113495bSYour Name static DEVICE_ATTR(beacon_stats, 0444,
514*5113495bSYour Name show_beacon_reception_stats, NULL);
515*5113495bSYour Name #endif
516*5113495bSYour Name
517*5113495bSYour Name static struct kobj_attribute dr_ver_attribute =
518*5113495bSYour Name __ATTR(driver_version, 0440, show_driver_version, NULL);
519*5113495bSYour Name static struct kobj_attribute fw_ver_attribute =
520*5113495bSYour Name __ATTR(version, 0440, show_fw_version, NULL);
521*5113495bSYour Name #ifdef WLAN_POWER_DEBUG
522*5113495bSYour Name static struct kobj_attribute power_stats_attribute =
523*5113495bSYour Name __ATTR(power_stats, 0444, show_device_power_stats, NULL);
524*5113495bSYour Name #endif
525*5113495bSYour Name
hdd_sysfs_create_version_interface(struct wlan_objmgr_psoc * psoc)526*5113495bSYour Name static void hdd_sysfs_create_version_interface(struct wlan_objmgr_psoc *psoc)
527*5113495bSYour Name {
528*5113495bSYour Name int error = 0;
529*5113495bSYour Name uint32_t psoc_id;
530*5113495bSYour Name char buf[MAX_PSOC_ID_SIZE];
531*5113495bSYour Name
532*5113495bSYour Name if (!driver_kobject || !wlan_kobject) {
533*5113495bSYour Name hdd_err("could not get driver kobject!");
534*5113495bSYour Name return;
535*5113495bSYour Name }
536*5113495bSYour Name
537*5113495bSYour Name error = sysfs_create_file(wlan_kobject, &dr_ver_attribute.attr);
538*5113495bSYour Name if (error) {
539*5113495bSYour Name hdd_err("could not create wlan sysfs file");
540*5113495bSYour Name return;
541*5113495bSYour Name }
542*5113495bSYour Name
543*5113495bSYour Name fw_kobject = kobject_create_and_add("fw", wlan_kobject);
544*5113495bSYour Name if (!fw_kobject) {
545*5113495bSYour Name hdd_err("could not allocate fw kobject");
546*5113495bSYour Name goto free_fw_kobj;
547*5113495bSYour Name }
548*5113495bSYour Name
549*5113495bSYour Name psoc_id = wlan_psoc_get_nif_phy_version(psoc);
550*5113495bSYour Name scnprintf(buf, PAGE_SIZE, "%d", psoc_id);
551*5113495bSYour Name
552*5113495bSYour Name psoc_kobject = kobject_create_and_add(buf, fw_kobject);
553*5113495bSYour Name if (!psoc_kobject) {
554*5113495bSYour Name hdd_err("could not allocate psoc kobject");
555*5113495bSYour Name goto free_fw_kobj;
556*5113495bSYour Name }
557*5113495bSYour Name
558*5113495bSYour Name error = sysfs_create_file(psoc_kobject, &fw_ver_attribute.attr);
559*5113495bSYour Name if (error) {
560*5113495bSYour Name hdd_err("could not create fw sysfs file");
561*5113495bSYour Name goto free_psoc_kobj;
562*5113495bSYour Name }
563*5113495bSYour Name
564*5113495bSYour Name return;
565*5113495bSYour Name
566*5113495bSYour Name free_psoc_kobj:
567*5113495bSYour Name kobject_put(psoc_kobject);
568*5113495bSYour Name psoc_kobject = NULL;
569*5113495bSYour Name
570*5113495bSYour Name free_fw_kobj:
571*5113495bSYour Name kobject_put(fw_kobject);
572*5113495bSYour Name fw_kobject = NULL;
573*5113495bSYour Name }
574*5113495bSYour Name
hdd_sysfs_destroy_version_interface(void)575*5113495bSYour Name static void hdd_sysfs_destroy_version_interface(void)
576*5113495bSYour Name {
577*5113495bSYour Name if (psoc_kobject) {
578*5113495bSYour Name kobject_put(psoc_kobject);
579*5113495bSYour Name psoc_kobject = NULL;
580*5113495bSYour Name kobject_put(fw_kobject);
581*5113495bSYour Name fw_kobject = NULL;
582*5113495bSYour Name }
583*5113495bSYour Name }
584*5113495bSYour Name
585*5113495bSYour Name #ifdef WLAN_POWER_DEBUG
hdd_sysfs_create_powerstats_interface(void)586*5113495bSYour Name static void hdd_sysfs_create_powerstats_interface(void)
587*5113495bSYour Name {
588*5113495bSYour Name int error;
589*5113495bSYour Name
590*5113495bSYour Name if (!driver_kobject) {
591*5113495bSYour Name hdd_err("could not get driver kobject!");
592*5113495bSYour Name return;
593*5113495bSYour Name }
594*5113495bSYour Name
595*5113495bSYour Name error = sysfs_create_file(driver_kobject, &power_stats_attribute.attr);
596*5113495bSYour Name if (error)
597*5113495bSYour Name hdd_err("could not create power_stats sysfs file");
598*5113495bSYour Name }
599*5113495bSYour Name
hdd_sysfs_destroy_powerstats_interface(void)600*5113495bSYour Name static void hdd_sysfs_destroy_powerstats_interface(void)
601*5113495bSYour Name {
602*5113495bSYour Name if (!driver_kobject) {
603*5113495bSYour Name hdd_err("could not get driver kobject!");
604*5113495bSYour Name return;
605*5113495bSYour Name }
606*5113495bSYour Name sysfs_remove_file(driver_kobject, &power_stats_attribute.attr);
607*5113495bSYour Name }
608*5113495bSYour Name #else
hdd_sysfs_create_powerstats_interface(void)609*5113495bSYour Name static void hdd_sysfs_create_powerstats_interface(void)
610*5113495bSYour Name {
611*5113495bSYour Name }
612*5113495bSYour Name
hdd_sysfs_destroy_powerstats_interface(void)613*5113495bSYour Name static void hdd_sysfs_destroy_powerstats_interface(void)
614*5113495bSYour Name {
615*5113495bSYour Name }
616*5113495bSYour Name #endif
617*5113495bSYour Name
618*5113495bSYour Name static ssize_t
hdd_sysfs_wakeup_logs_to_console_store(struct kobject * kobj,struct kobj_attribute * attr,char const * buf,size_t count)619*5113495bSYour Name hdd_sysfs_wakeup_logs_to_console_store(struct kobject *kobj,
620*5113495bSYour Name struct kobj_attribute *attr,
621*5113495bSYour Name char const *buf, size_t count)
622*5113495bSYour Name {
623*5113495bSYour Name char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
624*5113495bSYour Name int ret, value;
625*5113495bSYour Name char *sptr, *token;
626*5113495bSYour Name
627*5113495bSYour Name ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
628*5113495bSYour Name buf, count);
629*5113495bSYour Name if (ret) {
630*5113495bSYour Name hdd_err_rl("invalid input");
631*5113495bSYour Name return ret;
632*5113495bSYour Name }
633*5113495bSYour Name
634*5113495bSYour Name sptr = buf_local;
635*5113495bSYour Name token = strsep(&sptr, " ");
636*5113495bSYour Name if (!token)
637*5113495bSYour Name return -EINVAL;
638*5113495bSYour Name if (kstrtou32(token, 0, &value))
639*5113495bSYour Name return -EINVAL;
640*5113495bSYour Name
641*5113495bSYour Name wma_set_wakeup_logs_to_console(value);
642*5113495bSYour Name
643*5113495bSYour Name return count;
644*5113495bSYour Name }
645*5113495bSYour Name
646*5113495bSYour Name static struct kobj_attribute wakeup_logs_to_console_attribute =
647*5113495bSYour Name __ATTR(wakeup_logs_to_console, 0220, NULL,
648*5113495bSYour Name hdd_sysfs_wakeup_logs_to_console_store);
649*5113495bSYour Name
hdd_sysfs_create_wakeup_logs_to_console(void)650*5113495bSYour Name static void hdd_sysfs_create_wakeup_logs_to_console(void)
651*5113495bSYour Name {
652*5113495bSYour Name int error;
653*5113495bSYour Name
654*5113495bSYour Name if (!driver_kobject) {
655*5113495bSYour Name hdd_err("could not get driver kobject!");
656*5113495bSYour Name return;
657*5113495bSYour Name }
658*5113495bSYour Name
659*5113495bSYour Name error = sysfs_create_file(driver_kobject,
660*5113495bSYour Name &wakeup_logs_to_console_attribute.attr);
661*5113495bSYour Name if (error)
662*5113495bSYour Name hdd_err("could not create power_stats sysfs file");
663*5113495bSYour Name }
664*5113495bSYour Name
hdd_sysfs_destroy_wakeup_logs_to_console(void)665*5113495bSYour Name static void hdd_sysfs_destroy_wakeup_logs_to_console(void)
666*5113495bSYour Name {
667*5113495bSYour Name if (!driver_kobject) {
668*5113495bSYour Name hdd_err("could not get driver kobject!");
669*5113495bSYour Name return;
670*5113495bSYour Name }
671*5113495bSYour Name sysfs_remove_file(driver_kobject,
672*5113495bSYour Name &wakeup_logs_to_console_attribute.attr);
673*5113495bSYour Name }
674*5113495bSYour Name
hdd_sysfs_create_driver_root_obj(void)675*5113495bSYour Name static void hdd_sysfs_create_driver_root_obj(void)
676*5113495bSYour Name {
677*5113495bSYour Name driver_kobject = kobject_create_and_add(DRIVER_NAME, kernel_kobj);
678*5113495bSYour Name if (!driver_kobject) {
679*5113495bSYour Name hdd_err("could not allocate driver kobject");
680*5113495bSYour Name return;
681*5113495bSYour Name }
682*5113495bSYour Name
683*5113495bSYour Name wlan_kobject = kobject_create_and_add("wlan", driver_kobject);
684*5113495bSYour Name if (!wlan_kobject) {
685*5113495bSYour Name hdd_err("could not allocate wlan kobject");
686*5113495bSYour Name kobject_put(driver_kobject);
687*5113495bSYour Name driver_kobject = NULL;
688*5113495bSYour Name }
689*5113495bSYour Name }
690*5113495bSYour Name
hdd_sysfs_destroy_driver_root_obj(void)691*5113495bSYour Name static void hdd_sysfs_destroy_driver_root_obj(void)
692*5113495bSYour Name {
693*5113495bSYour Name if (wlan_kobject) {
694*5113495bSYour Name kobject_put(wlan_kobject);
695*5113495bSYour Name wlan_kobject = NULL;
696*5113495bSYour Name }
697*5113495bSYour Name
698*5113495bSYour Name if (driver_kobject) {
699*5113495bSYour Name kobject_put(driver_kobject);
700*5113495bSYour Name driver_kobject = NULL;
701*5113495bSYour Name }
702*5113495bSYour Name }
703*5113495bSYour Name
hdd_sysfs_create_wifi_root_obj(void)704*5113495bSYour Name void hdd_sysfs_create_wifi_root_obj(void)
705*5113495bSYour Name {
706*5113495bSYour Name if (wifi_kobject) {
707*5113495bSYour Name hdd_debug("wifi kobj already created");
708*5113495bSYour Name return;
709*5113495bSYour Name }
710*5113495bSYour Name wifi_kobject = pld_get_wifi_kobj(NULL);
711*5113495bSYour Name if (wifi_kobject) {
712*5113495bSYour Name hdd_debug("wifi_kobject created by platform");
713*5113495bSYour Name return;
714*5113495bSYour Name }
715*5113495bSYour Name wifi_kobject = kobject_create_and_add("wifi", NULL);
716*5113495bSYour Name if (!wifi_kobject)
717*5113495bSYour Name hdd_err("could not allocate wifi kobject");
718*5113495bSYour Name }
719*5113495bSYour Name
hdd_sysfs_destroy_wifi_root_obj(void)720*5113495bSYour Name void hdd_sysfs_destroy_wifi_root_obj(void)
721*5113495bSYour Name {
722*5113495bSYour Name if (pld_get_wifi_kobj(NULL)) {
723*5113495bSYour Name hdd_debug("wifi_kobject created by platform");
724*5113495bSYour Name wifi_kobject = NULL;
725*5113495bSYour Name return;
726*5113495bSYour Name }
727*5113495bSYour Name
728*5113495bSYour Name if (!wifi_kobject) {
729*5113495bSYour Name hdd_err("could not get wifi kobject!");
730*5113495bSYour Name return;
731*5113495bSYour Name }
732*5113495bSYour Name kobject_put(wifi_kobject);
733*5113495bSYour Name wifi_kobject = NULL;
734*5113495bSYour Name }
735*5113495bSYour Name
hdd_create_wifi_feature_interface_sysfs_file(void)736*5113495bSYour Name void hdd_create_wifi_feature_interface_sysfs_file(void)
737*5113495bSYour Name {
738*5113495bSYour Name hdd_sysfs_create_wifi_feature_interface(wifi_kobject);
739*5113495bSYour Name }
740*5113495bSYour Name
hdd_destroy_wifi_feature_interface_sysfs_file(void)741*5113495bSYour Name void hdd_destroy_wifi_feature_interface_sysfs_file(void)
742*5113495bSYour Name {
743*5113495bSYour Name hdd_sysfs_destroy_wifi_feature_interface(wifi_kobject);
744*5113495bSYour Name }
745*5113495bSYour Name
hdd_sysfs_print(void * ctx,const char * fmt,...)746*5113495bSYour Name int hdd_sysfs_print(void *ctx, const char *fmt, ...)
747*5113495bSYour Name {
748*5113495bSYour Name va_list args;
749*5113495bSYour Name int ret = -1;
750*5113495bSYour Name struct hdd_sysfs_print_ctx *p_ctx = ctx;
751*5113495bSYour Name
752*5113495bSYour Name va_start(args, fmt);
753*5113495bSYour Name
754*5113495bSYour Name if (ctx) {
755*5113495bSYour Name ret = vscnprintf(p_ctx->buf + p_ctx->idx,
756*5113495bSYour Name PAGE_SIZE - p_ctx->idx, fmt, args);
757*5113495bSYour Name p_ctx->idx += ret;
758*5113495bSYour Name if (p_ctx->new_line) {
759*5113495bSYour Name ret += scnprintf(p_ctx->buf + p_ctx->idx,
760*5113495bSYour Name PAGE_SIZE - p_ctx->idx,
761*5113495bSYour Name "\n");
762*5113495bSYour Name p_ctx->idx += ret;
763*5113495bSYour Name }
764*5113495bSYour Name }
765*5113495bSYour Name
766*5113495bSYour Name va_end(args);
767*5113495bSYour Name return ret;
768*5113495bSYour Name }
769*5113495bSYour Name
770*5113495bSYour Name #ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
hdd_sysfs_create_bcn_reception_interface(struct hdd_adapter * adapter)771*5113495bSYour Name static int hdd_sysfs_create_bcn_reception_interface(struct hdd_adapter
772*5113495bSYour Name *adapter)
773*5113495bSYour Name {
774*5113495bSYour Name int error;
775*5113495bSYour Name
776*5113495bSYour Name error = device_create_file(&adapter->dev->dev, &dev_attr_beacon_stats);
777*5113495bSYour Name if (error)
778*5113495bSYour Name hdd_err("could not create beacon stats sysfs file");
779*5113495bSYour Name
780*5113495bSYour Name return error;
781*5113495bSYour Name }
782*5113495bSYour Name
hdd_sysfs_destroy_bcn_reception_interface(struct hdd_adapter * adapter)783*5113495bSYour Name static void hdd_sysfs_destroy_bcn_reception_interface(struct hdd_adapter
784*5113495bSYour Name *adapter)
785*5113495bSYour Name {
786*5113495bSYour Name device_remove_file(&adapter->dev->dev, &dev_attr_beacon_stats);
787*5113495bSYour Name }
788*5113495bSYour Name #else /* !WLAN_FEATURE_BEACON_RECEPTION_STATS */
789*5113495bSYour Name static inline int
hdd_sysfs_create_bcn_reception_interface(struct hdd_adapter * adapter)790*5113495bSYour Name hdd_sysfs_create_bcn_reception_interface(struct hdd_adapter *adapter)
791*5113495bSYour Name {
792*5113495bSYour Name return 0;
793*5113495bSYour Name }
794*5113495bSYour Name
795*5113495bSYour Name static inline void
hdd_sysfs_destroy_bcn_reception_interface(struct hdd_adapter * adapter)796*5113495bSYour Name hdd_sysfs_destroy_bcn_reception_interface(struct hdd_adapter *adapter)
797*5113495bSYour Name {
798*5113495bSYour Name }
799*5113495bSYour Name
800*5113495bSYour Name #endif /* WLAN_FEATURE_BEACON_RECEPTION_STATS */
801*5113495bSYour Name
802*5113495bSYour Name #define MAX_USER_COMMAND_SIZE_LOGGING_CONFIG 256
803*5113495bSYour Name #define MAX_SYS_LOGGING_CONFIG_COEX_NUM 7
804*5113495bSYour Name /**
805*5113495bSYour Name * __hdd_sysfs_logging_config_store() - This API will store the values in local
806*5113495bSYour Name * buffer.
807*5113495bSYour Name * @hdd_ctx: hdd context
808*5113495bSYour Name * @buf: input buffer
809*5113495bSYour Name * @count: size fo buffer
810*5113495bSYour Name *
811*5113495bSYour Name * Return: local buffer count for success case, otherwise error
812*5113495bSYour Name */
__hdd_sysfs_logging_config_store(struct hdd_context * hdd_ctx,const char * buf,size_t count)813*5113495bSYour Name static ssize_t __hdd_sysfs_logging_config_store(struct hdd_context *hdd_ctx,
814*5113495bSYour Name const char *buf, size_t count)
815*5113495bSYour Name {
816*5113495bSYour Name char buf_local[MAX_USER_COMMAND_SIZE_LOGGING_CONFIG + 1];
817*5113495bSYour Name char *sptr, *token;
818*5113495bSYour Name uint32_t apps_args[WMI_UNIT_TEST_MAX_NUM_ARGS];
819*5113495bSYour Name int module_id, args_num, ret, i;
820*5113495bSYour Name QDF_STATUS status;
821*5113495bSYour Name
822*5113495bSYour Name ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
823*5113495bSYour Name buf, count);
824*5113495bSYour Name if (ret) {
825*5113495bSYour Name hdd_err_rl("invalid input");
826*5113495bSYour Name return ret;
827*5113495bSYour Name }
828*5113495bSYour Name
829*5113495bSYour Name hdd_nofl_info("logging_config: count %zu buf_local:(%s)", count,
830*5113495bSYour Name buf_local);
831*5113495bSYour Name
832*5113495bSYour Name sptr = buf_local;
833*5113495bSYour Name /* Get module_id */
834*5113495bSYour Name token = strsep(&sptr, " ");
835*5113495bSYour Name if (!token)
836*5113495bSYour Name return -EINVAL;
837*5113495bSYour Name if (kstrtou32(token, 0, &module_id))
838*5113495bSYour Name return -EINVAL;
839*5113495bSYour Name
840*5113495bSYour Name if (module_id < WLAN_MODULE_ID_MIN ||
841*5113495bSYour Name module_id >= WLAN_MODULE_ID_MAX) {
842*5113495bSYour Name hdd_err_rl("Invalid MODULE ID %d", module_id);
843*5113495bSYour Name return -EINVAL;
844*5113495bSYour Name }
845*5113495bSYour Name
846*5113495bSYour Name /* Get args_num */
847*5113495bSYour Name token = strsep(&sptr, " ");
848*5113495bSYour Name if (!token)
849*5113495bSYour Name return -EINVAL;
850*5113495bSYour Name if (kstrtou32(token, 0, &args_num))
851*5113495bSYour Name return -EINVAL;
852*5113495bSYour Name
853*5113495bSYour Name if (args_num > WMI_UNIT_TEST_MAX_NUM_ARGS) {
854*5113495bSYour Name hdd_err_rl("Too many args %d", args_num);
855*5113495bSYour Name return -EINVAL;
856*5113495bSYour Name }
857*5113495bSYour Name
858*5113495bSYour Name for (i = 0; i < args_num; i++) {
859*5113495bSYour Name token = strsep(&sptr, " ");
860*5113495bSYour Name if (!token) {
861*5113495bSYour Name hdd_err_rl("not enough args(%d), expected args_num:%d",
862*5113495bSYour Name i, args_num);
863*5113495bSYour Name return -EINVAL;
864*5113495bSYour Name }
865*5113495bSYour Name if (kstrtou32(token, 0, &apps_args[i]))
866*5113495bSYour Name return -EINVAL;
867*5113495bSYour Name }
868*5113495bSYour Name
869*5113495bSYour Name switch (module_id) {
870*5113495bSYour Name case WLAN_MODULE_COEX:
871*5113495bSYour Name if (args_num > MAX_SYS_LOGGING_CONFIG_COEX_NUM) {
872*5113495bSYour Name hdd_err_rl("arg num %d exceeds max limit %d", args_num,
873*5113495bSYour Name MAX_SYS_LOGGING_CONFIG_COEX_NUM);
874*5113495bSYour Name return -EINVAL;
875*5113495bSYour Name }
876*5113495bSYour Name
877*5113495bSYour Name status = ucfg_coex_send_logging_config(hdd_ctx->psoc,
878*5113495bSYour Name &apps_args[0]);
879*5113495bSYour Name if (status != QDF_STATUS_SUCCESS) {
880*5113495bSYour Name hdd_err_rl("ucfg_coex_send_logging_config returned %d",
881*5113495bSYour Name status);
882*5113495bSYour Name return -EINVAL;
883*5113495bSYour Name }
884*5113495bSYour Name break;
885*5113495bSYour Name
886*5113495bSYour Name default:
887*5113495bSYour Name hdd_debug_rl("module id not recognized");
888*5113495bSYour Name break;
889*5113495bSYour Name }
890*5113495bSYour Name
891*5113495bSYour Name return count;
892*5113495bSYour Name }
893*5113495bSYour Name
894*5113495bSYour Name /**
895*5113495bSYour Name * hdd_sysfs_logging_config_store() - This API will store the values in local
896*5113495bSYour Name * buffer.
897*5113495bSYour Name * @kobj: sysfs wifi kobject
898*5113495bSYour Name * @attr: pointer to kobj_attribute structure
899*5113495bSYour Name * @buf: input buffer
900*5113495bSYour Name * @count: size fo buffer
901*5113495bSYour Name *
902*5113495bSYour Name * Return: local buffer count for success case, otherwise error
903*5113495bSYour Name */
hdd_sysfs_logging_config_store(struct kobject * kobj,struct kobj_attribute * attr,char const * buf,size_t count)904*5113495bSYour Name static ssize_t hdd_sysfs_logging_config_store(struct kobject *kobj,
905*5113495bSYour Name struct kobj_attribute *attr,
906*5113495bSYour Name char const *buf, size_t count)
907*5113495bSYour Name {
908*5113495bSYour Name struct osif_psoc_sync *psoc_sync;
909*5113495bSYour Name struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
910*5113495bSYour Name ssize_t errno_size;
911*5113495bSYour Name int ret;
912*5113495bSYour Name
913*5113495bSYour Name ret = wlan_hdd_validate_context(hdd_ctx);
914*5113495bSYour Name if (ret != 0)
915*5113495bSYour Name return ret;
916*5113495bSYour Name
917*5113495bSYour Name if (!wlan_hdd_validate_modules_state(hdd_ctx))
918*5113495bSYour Name return -EINVAL;
919*5113495bSYour Name
920*5113495bSYour Name errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
921*5113495bSYour Name &psoc_sync);
922*5113495bSYour Name if (errno_size)
923*5113495bSYour Name return errno_size;
924*5113495bSYour Name
925*5113495bSYour Name errno_size = __hdd_sysfs_logging_config_store(hdd_ctx, buf, count);
926*5113495bSYour Name
927*5113495bSYour Name osif_psoc_sync_op_stop(psoc_sync);
928*5113495bSYour Name
929*5113495bSYour Name return errno_size;
930*5113495bSYour Name }
931*5113495bSYour Name
932*5113495bSYour Name static struct kobj_attribute logging_config_attribute =
933*5113495bSYour Name __ATTR(logging_config, 0220, NULL, hdd_sysfs_logging_config_store);
934*5113495bSYour Name
935*5113495bSYour Name /**
936*5113495bSYour Name * hdd_sysfs_create_logging_config_interface() - API to create logging config
937*5113495bSYour Name * sysfs file
938*5113495bSYour Name * @driver_kobject: sysfs driver kobject
939*5113495bSYour Name *
940*5113495bSYour Name * Return: None
941*5113495bSYour Name */
942*5113495bSYour Name static void
hdd_sysfs_create_logging_config_interface(struct kobject * driver_kobject)943*5113495bSYour Name hdd_sysfs_create_logging_config_interface(struct kobject *driver_kobject)
944*5113495bSYour Name {
945*5113495bSYour Name int error;
946*5113495bSYour Name
947*5113495bSYour Name if (!driver_kobject) {
948*5113495bSYour Name hdd_err("could not get wifi kobject!");
949*5113495bSYour Name return;
950*5113495bSYour Name }
951*5113495bSYour Name
952*5113495bSYour Name error = sysfs_create_file(driver_kobject,
953*5113495bSYour Name &logging_config_attribute.attr);
954*5113495bSYour Name if (error)
955*5113495bSYour Name hdd_err("could not create logging config sysfs file");
956*5113495bSYour Name }
957*5113495bSYour Name
958*5113495bSYour Name /**
959*5113495bSYour Name * hdd_sysfs_destroy_logging_config_interface() - API to destroy logging config
960*5113495bSYour Name * sysfs file
961*5113495bSYour Name * @driver_kobject: sysfs driver kobject
962*5113495bSYour Name *
963*5113495bSYour Name * Return: None
964*5113495bSYour Name */
965*5113495bSYour Name static void
hdd_sysfs_destroy_logging_config_interface(struct kobject * driver_kobject)966*5113495bSYour Name hdd_sysfs_destroy_logging_config_interface(struct kobject *driver_kobject)
967*5113495bSYour Name {
968*5113495bSYour Name if (!driver_kobject) {
969*5113495bSYour Name hdd_err("could not get wifi kobject!");
970*5113495bSYour Name return;
971*5113495bSYour Name }
972*5113495bSYour Name
973*5113495bSYour Name sysfs_remove_file(driver_kobject, &logging_config_attribute.attr);
974*5113495bSYour Name }
975*5113495bSYour Name
976*5113495bSYour Name static void
hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter * adapter)977*5113495bSYour Name hdd_sysfs_create_sta_adapter_root_obj(struct hdd_adapter *adapter)
978*5113495bSYour Name {
979*5113495bSYour Name hdd_sysfs_create_bcn_reception_interface(adapter);
980*5113495bSYour Name hdd_sysfs_reassoc_create(adapter);
981*5113495bSYour Name hdd_sysfs_crash_inject_create(adapter);
982*5113495bSYour Name hdd_sysfs_suspend_create(adapter);
983*5113495bSYour Name hdd_sysfs_resume_create(adapter);
984*5113495bSYour Name hdd_sysfs_unit_test_target_create(adapter);
985*5113495bSYour Name hdd_sysfs_connect_info_interface_create(adapter);
986*5113495bSYour Name hdd_sysfs_dcm_create(adapter);
987*5113495bSYour Name hdd_sysfs_wowl_add_ptrn_create(adapter);
988*5113495bSYour Name hdd_sysfs_wowl_del_ptrn_create(adapter);
989*5113495bSYour Name hdd_sysfs_tx_stbc_create(adapter);
990*5113495bSYour Name hdd_sysfs_txrx_fw_st_rst_create(adapter);
991*5113495bSYour Name hdd_sysfs_gtx_bw_mask_create(adapter);
992*5113495bSYour Name hdd_sysfs_rts_cts_create(adapter);
993*5113495bSYour Name hdd_sysfs_stats_create(adapter);
994*5113495bSYour Name hdd_sysfs_txrx_fw_stats_create(adapter);
995*5113495bSYour Name hdd_sysfs_txrx_stats_create(adapter);
996*5113495bSYour Name hdd_sysfs_tdls_peers_interface_create(adapter);
997*5113495bSYour Name hdd_sysfs_temperature_create(adapter);
998*5113495bSYour Name hdd_sysfs_motion_detection_create(adapter);
999*5113495bSYour Name hdd_sysfs_range_ext_create(adapter);
1000*5113495bSYour Name hdd_sysfs_dl_modes_create(adapter);
1001*5113495bSYour Name hdd_sysfs_11be_rate_create(adapter);
1002*5113495bSYour Name hdd_sysfs_bmiss_create(adapter);
1003*5113495bSYour Name hdd_sysfs_dp_tx_delay_stats_create(adapter);
1004*5113495bSYour Name hdd_sysfs_direct_link_ut_cmd_create(adapter);
1005*5113495bSYour Name hdd_sysfs_sta_bitrates_create(adapter);
1006*5113495bSYour Name }
1007*5113495bSYour Name
1008*5113495bSYour Name static void
hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter * adapter)1009*5113495bSYour Name hdd_sysfs_destroy_sta_adapter_root_obj(struct hdd_adapter *adapter)
1010*5113495bSYour Name {
1011*5113495bSYour Name hdd_sysfs_sta_bitrates_destroy(adapter);
1012*5113495bSYour Name hdd_sysfs_direct_link_ut_destroy(adapter);
1013*5113495bSYour Name hdd_sysfs_dp_tx_delay_stats_destroy(adapter);
1014*5113495bSYour Name hdd_sysfs_bmiss_destroy(adapter);
1015*5113495bSYour Name hdd_sysfs_11be_rate_destroy(adapter);
1016*5113495bSYour Name hdd_sysfs_dl_modes_destroy(adapter);
1017*5113495bSYour Name hdd_sysfs_range_ext_destroy(adapter);
1018*5113495bSYour Name hdd_sysfs_motion_detection_destroy(adapter);
1019*5113495bSYour Name hdd_sysfs_temperature_destroy(adapter);
1020*5113495bSYour Name hdd_sysfs_tdls_peers_interface_destroy(adapter);
1021*5113495bSYour Name hdd_sysfs_txrx_stats_destroy(adapter);
1022*5113495bSYour Name hdd_sysfs_txrx_fw_stats_destroy(adapter);
1023*5113495bSYour Name hdd_sysfs_stats_destroy(adapter);
1024*5113495bSYour Name hdd_sysfs_rts_cts_destroy(adapter);
1025*5113495bSYour Name hdd_sysfs_gtx_bw_mask_destroy(adapter);
1026*5113495bSYour Name hdd_sysfs_txrx_fw_st_rst_destroy(adapter);
1027*5113495bSYour Name hdd_sysfs_tx_stbc_destroy(adapter);
1028*5113495bSYour Name hdd_sysfs_wowl_del_ptrn_destroy(adapter);
1029*5113495bSYour Name hdd_sysfs_wowl_add_ptrn_destroy(adapter);
1030*5113495bSYour Name hdd_sysfs_dcm_destroy(adapter);
1031*5113495bSYour Name hdd_sysfs_connect_info_interface_destroy(adapter);
1032*5113495bSYour Name hdd_sysfs_unit_test_target_destroy(adapter);
1033*5113495bSYour Name hdd_sysfs_resume_destroy(adapter);
1034*5113495bSYour Name hdd_sysfs_suspend_destroy(adapter);
1035*5113495bSYour Name hdd_sysfs_crash_inject_destroy(adapter);
1036*5113495bSYour Name hdd_sysfs_reassoc_destroy(adapter);
1037*5113495bSYour Name hdd_sysfs_destroy_bcn_reception_interface(adapter);
1038*5113495bSYour Name }
1039*5113495bSYour Name
1040*5113495bSYour Name static void
hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter * adapter)1041*5113495bSYour Name hdd_sysfs_create_sap_adapter_root_obj(struct hdd_adapter *adapter)
1042*5113495bSYour Name {
1043*5113495bSYour Name hdd_sysfs_channel_interface_create(adapter);
1044*5113495bSYour Name hdd_sysfs_sta_info_interface_create(adapter);
1045*5113495bSYour Name hdd_sysfs_crash_inject_create(adapter);
1046*5113495bSYour Name hdd_sysfs_suspend_create(adapter);
1047*5113495bSYour Name hdd_sysfs_resume_create(adapter);
1048*5113495bSYour Name hdd_sysfs_unit_test_target_create(adapter);
1049*5113495bSYour Name hdd_sysfs_modify_acl_create(adapter);
1050*5113495bSYour Name hdd_sysfs_connect_info_interface_create(adapter);
1051*5113495bSYour Name hdd_sysfs_tx_stbc_create(adapter);
1052*5113495bSYour Name hdd_sysfs_txrx_fw_st_rst_create(adapter);
1053*5113495bSYour Name hdd_sysfs_gtx_bw_mask_create(adapter);
1054*5113495bSYour Name hdd_sysfs_dcm_create(adapter);
1055*5113495bSYour Name hdd_sysfs_radar_create(adapter);
1056*5113495bSYour Name hdd_sysfs_rts_cts_create(adapter);
1057*5113495bSYour Name hdd_sysfs_stats_create(adapter);
1058*5113495bSYour Name hdd_sysfs_he_bss_color_create(adapter);
1059*5113495bSYour Name hdd_sysfs_txrx_fw_stats_create(adapter);
1060*5113495bSYour Name hdd_sysfs_txrx_stats_create(adapter);
1061*5113495bSYour Name hdd_sysfs_temperature_create(adapter);
1062*5113495bSYour Name hdd_sysfs_range_ext_create(adapter);
1063*5113495bSYour Name hdd_sysfs_ipa_create(adapter);
1064*5113495bSYour Name hdd_sysfs_dl_modes_create(adapter);
1065*5113495bSYour Name hdd_sysfs_11be_rate_create(adapter);
1066*5113495bSYour Name hdd_sysfs_dp_tx_delay_stats_create(adapter);
1067*5113495bSYour Name hdd_sysfs_dp_traffic_end_indication_create(adapter);
1068*5113495bSYour Name hdd_sysfs_direct_link_ut_cmd_create(adapter);
1069*5113495bSYour Name hdd_sysfs_dfsnol_create(adapter);
1070*5113495bSYour Name hdd_sysfs_sap_bitrates_create(adapter);
1071*5113495bSYour Name }
1072*5113495bSYour Name
1073*5113495bSYour Name static void
hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter * adapter)1074*5113495bSYour Name hdd_sysfs_destroy_sap_adapter_root_obj(struct hdd_adapter *adapter)
1075*5113495bSYour Name {
1076*5113495bSYour Name hdd_sysfs_sap_bitrates_destroy(adapter);
1077*5113495bSYour Name hdd_sysfs_dfsnol_destroy(adapter);
1078*5113495bSYour Name hdd_sysfs_direct_link_ut_destroy(adapter);
1079*5113495bSYour Name hdd_sysfs_dp_traffic_end_indication_destroy(adapter);
1080*5113495bSYour Name hdd_sysfs_dp_tx_delay_stats_destroy(adapter);
1081*5113495bSYour Name hdd_sysfs_11be_rate_destroy(adapter);
1082*5113495bSYour Name hdd_sysfs_dl_modes_destroy(adapter);
1083*5113495bSYour Name hdd_sysfs_ipa_destroy(adapter);
1084*5113495bSYour Name hdd_sysfs_range_ext_destroy(adapter);
1085*5113495bSYour Name hdd_sysfs_temperature_destroy(adapter);
1086*5113495bSYour Name hdd_sysfs_txrx_stats_destroy(adapter);
1087*5113495bSYour Name hdd_sysfs_txrx_fw_stats_destroy(adapter);
1088*5113495bSYour Name hdd_sysfs_he_bss_color_destroy(adapter);
1089*5113495bSYour Name hdd_sysfs_stats_destroy(adapter);
1090*5113495bSYour Name hdd_sysfs_rts_cts_destroy(adapter);
1091*5113495bSYour Name hdd_sysfs_radar_destroy(adapter);
1092*5113495bSYour Name hdd_sysfs_dcm_destroy(adapter);
1093*5113495bSYour Name hdd_sysfs_gtx_bw_mask_destroy(adapter);
1094*5113495bSYour Name hdd_sysfs_txrx_fw_st_rst_destroy(adapter);
1095*5113495bSYour Name hdd_sysfs_tx_stbc_destroy(adapter);
1096*5113495bSYour Name hdd_sysfs_connect_info_interface_destroy(adapter);
1097*5113495bSYour Name hdd_sysfs_modify_acl_destroy(adapter);
1098*5113495bSYour Name hdd_sysfs_unit_test_target_destroy(adapter);
1099*5113495bSYour Name hdd_sysfs_resume_destroy(adapter);
1100*5113495bSYour Name hdd_sysfs_suspend_destroy(adapter);
1101*5113495bSYour Name hdd_sysfs_crash_inject_destroy(adapter);
1102*5113495bSYour Name hdd_sysfs_sta_info_interface_destroy(adapter);
1103*5113495bSYour Name hdd_sysfs_channel_interface_destroy(adapter);
1104*5113495bSYour Name }
1105*5113495bSYour Name
1106*5113495bSYour Name static void
hdd_sysfs_create_monitor_adapter_root_obj(struct hdd_adapter * adapter)1107*5113495bSYour Name hdd_sysfs_create_monitor_adapter_root_obj(struct hdd_adapter *adapter)
1108*5113495bSYour Name {
1109*5113495bSYour Name hdd_sysfs_monitor_mode_channel_create(adapter);
1110*5113495bSYour Name }
1111*5113495bSYour Name
1112*5113495bSYour Name static void
hdd_sysfs_destroy_monitor_adapter_root_obj(struct hdd_adapter * adapter)1113*5113495bSYour Name hdd_sysfs_destroy_monitor_adapter_root_obj(struct hdd_adapter *adapter)
1114*5113495bSYour Name {
1115*5113495bSYour Name hdd_sysfs_monitor_mode_channel_destroy(adapter);
1116*5113495bSYour Name }
1117*5113495bSYour Name
hdd_create_sysfs_files(struct hdd_context * hdd_ctx)1118*5113495bSYour Name void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
1119*5113495bSYour Name {
1120*5113495bSYour Name hdd_sysfs_create_driver_root_obj();
1121*5113495bSYour Name hdd_sysfs_create_version_interface(hdd_ctx->psoc);
1122*5113495bSYour Name hdd_sysfs_mem_stats_create(wlan_kobject);
1123*5113495bSYour Name if (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) {
1124*5113495bSYour Name hdd_sysfs_create_powerstats_interface();
1125*5113495bSYour Name hdd_sysfs_create_dump_in_progress_interface(wifi_kobject);
1126*5113495bSYour Name hdd_sysfs_fw_mode_config_create(driver_kobject);
1127*5113495bSYour Name hdd_sysfs_scan_disable_create(driver_kobject);
1128*5113495bSYour Name hdd_sysfs_wow_ito_create(driver_kobject);
1129*5113495bSYour Name hdd_sysfs_wlan_dbg_create(driver_kobject);
1130*5113495bSYour Name hdd_sysfs_scan_config_create(driver_kobject);
1131*5113495bSYour Name hdd_sysfs_dp_trace_create(driver_kobject);
1132*5113495bSYour Name hdd_sysfs_thermal_cfg_create(driver_kobject);
1133*5113495bSYour Name hdd_sysfs_pktlog_create(driver_kobject);
1134*5113495bSYour Name hdd_sysfs_pm_cinfo_create(driver_kobject);
1135*5113495bSYour Name hdd_sysfs_pm_pcl_create(driver_kobject);
1136*5113495bSYour Name hdd_sysfs_dp_aggregation_create(driver_kobject);
1137*5113495bSYour Name hdd_sysfs_dp_swlm_create(driver_kobject);
1138*5113495bSYour Name hdd_sysfs_create_wakeup_logs_to_console();
1139*5113495bSYour Name hdd_sysfs_dp_txrx_stats_sysfs_create(driver_kobject);
1140*5113495bSYour Name hdd_sysfs_get_valid_freq_for_power_create(driver_kobject);
1141*5113495bSYour Name hdd_sysfs_dp_pkt_add_ts_create(driver_kobject);
1142*5113495bSYour Name hdd_sysfs_runtime_pm_create(driver_kobject);
1143*5113495bSYour Name hdd_sysfs_log_buffer_create(driver_kobject);
1144*5113495bSYour Name hdd_sysfs_wds_mode_create(driver_kobject);
1145*5113495bSYour Name hdd_sysfs_roam_trigger_bitmap_create(driver_kobject);
1146*5113495bSYour Name hdd_sysfs_rf_test_mode_create(driver_kobject);
1147*5113495bSYour Name hdd_sysfs_create_logging_config_interface(driver_kobject);
1148*5113495bSYour Name }
1149*5113495bSYour Name }
1150*5113495bSYour Name
hdd_destroy_sysfs_files(void)1151*5113495bSYour Name void hdd_destroy_sysfs_files(void)
1152*5113495bSYour Name {
1153*5113495bSYour Name if (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) {
1154*5113495bSYour Name hdd_sysfs_destroy_logging_config_interface(driver_kobject);
1155*5113495bSYour Name hdd_sysfs_rf_test_mode_destroy(driver_kobject);
1156*5113495bSYour Name hdd_sysfs_roam_trigger_bitmap_destroy(driver_kobject);
1157*5113495bSYour Name hdd_sysfs_wds_mode_destroy(driver_kobject);
1158*5113495bSYour Name hdd_sysfs_log_buffer_destroy(driver_kobject);
1159*5113495bSYour Name hdd_sysfs_runtime_pm_destroy(driver_kobject);
1160*5113495bSYour Name hdd_sysfs_dp_pkt_add_ts_destroy(driver_kobject);
1161*5113495bSYour Name hdd_sysfs_get_valid_freq_for_power_destroy(driver_kobject);
1162*5113495bSYour Name hdd_sysfs_dp_txrx_stats_sysfs_destroy(driver_kobject);
1163*5113495bSYour Name hdd_sysfs_destroy_wakeup_logs_to_console();
1164*5113495bSYour Name hdd_sysfs_dp_swlm_destroy(driver_kobject);
1165*5113495bSYour Name hdd_sysfs_dp_aggregation_destroy(driver_kobject);
1166*5113495bSYour Name hdd_sysfs_pm_pcl_destroy(driver_kobject);
1167*5113495bSYour Name hdd_sysfs_pm_cinfo_destroy(driver_kobject);
1168*5113495bSYour Name hdd_sysfs_pktlog_destroy(driver_kobject);
1169*5113495bSYour Name hdd_sysfs_thermal_cfg_destroy(driver_kobject);
1170*5113495bSYour Name hdd_sysfs_dp_trace_destroy(driver_kobject);
1171*5113495bSYour Name hdd_sysfs_scan_config_destroy(driver_kobject);
1172*5113495bSYour Name hdd_sysfs_wlan_dbg_destroy(driver_kobject);
1173*5113495bSYour Name hdd_sysfs_wow_ito_destroy(driver_kobject);
1174*5113495bSYour Name hdd_sysfs_scan_disable_destroy(driver_kobject);
1175*5113495bSYour Name hdd_sysfs_fw_mode_config_destroy(driver_kobject);
1176*5113495bSYour Name hdd_sysfs_destroy_dump_in_progress_interface(wifi_kobject);
1177*5113495bSYour Name hdd_sysfs_destroy_powerstats_interface();
1178*5113495bSYour Name }
1179*5113495bSYour Name hdd_sysfs_mem_stats_destroy(wlan_kobject);
1180*5113495bSYour Name hdd_sysfs_destroy_version_interface();
1181*5113495bSYour Name hdd_sysfs_destroy_driver_root_obj();
1182*5113495bSYour Name }
1183*5113495bSYour Name
1184*5113495bSYour Name static
hdd_sysfs_create_ftm_adapter_root_obj(struct hdd_adapter * adapter)1185*5113495bSYour Name void hdd_sysfs_create_ftm_adapter_root_obj(struct hdd_adapter *adapter)
1186*5113495bSYour Name {
1187*5113495bSYour Name hdd_sysfs_unit_test_target_create(adapter);
1188*5113495bSYour Name }
1189*5113495bSYour Name
1190*5113495bSYour Name static void
hdd_sysfs_create_ndi_adapter_root_obj(struct hdd_adapter * adapter)1191*5113495bSYour Name hdd_sysfs_create_ndi_adapter_root_obj(struct hdd_adapter *adapter)
1192*5113495bSYour Name {
1193*5113495bSYour Name hdd_sysfs_unit_test_target_create(adapter);
1194*5113495bSYour Name hdd_sysfs_11be_rate_create(adapter);
1195*5113495bSYour Name }
1196*5113495bSYour Name
1197*5113495bSYour Name static void
hdd_sysfs_destroy_ndi_adapter_root_obj(struct hdd_adapter * adapter)1198*5113495bSYour Name hdd_sysfs_destroy_ndi_adapter_root_obj(struct hdd_adapter *adapter)
1199*5113495bSYour Name {
1200*5113495bSYour Name hdd_sysfs_11be_rate_destroy(adapter);
1201*5113495bSYour Name hdd_sysfs_unit_test_target_destroy(adapter);
1202*5113495bSYour Name }
1203*5113495bSYour Name
hdd_create_adapter_sysfs_files(struct hdd_adapter * adapter)1204*5113495bSYour Name void hdd_create_adapter_sysfs_files(struct hdd_adapter *adapter)
1205*5113495bSYour Name {
1206*5113495bSYour Name int device_mode = adapter->device_mode;
1207*5113495bSYour Name
1208*5113495bSYour Name if (hdd_adapter_is_link_adapter(adapter)) {
1209*5113495bSYour Name hdd_err("link adapter returning!!");
1210*5113495bSYour Name return;
1211*5113495bSYour Name }
1212*5113495bSYour Name
1213*5113495bSYour Name switch (device_mode){
1214*5113495bSYour Name case QDF_STA_MODE:
1215*5113495bSYour Name case QDF_P2P_DEVICE_MODE:
1216*5113495bSYour Name case QDF_P2P_CLIENT_MODE:
1217*5113495bSYour Name hdd_sysfs_create_sta_adapter_root_obj(adapter);
1218*5113495bSYour Name break;
1219*5113495bSYour Name case QDF_SAP_MODE:
1220*5113495bSYour Name case QDF_P2P_GO_MODE:
1221*5113495bSYour Name hdd_sysfs_create_sap_adapter_root_obj(adapter);
1222*5113495bSYour Name break;
1223*5113495bSYour Name case QDF_MONITOR_MODE:
1224*5113495bSYour Name hdd_sysfs_create_monitor_adapter_root_obj(adapter);
1225*5113495bSYour Name break;
1226*5113495bSYour Name case QDF_FTM_MODE:
1227*5113495bSYour Name hdd_sysfs_create_ftm_adapter_root_obj(adapter);
1228*5113495bSYour Name break;
1229*5113495bSYour Name case QDF_NDI_MODE:
1230*5113495bSYour Name hdd_sysfs_create_ndi_adapter_root_obj(adapter);
1231*5113495bSYour Name break;
1232*5113495bSYour Name default:
1233*5113495bSYour Name break;
1234*5113495bSYour Name }
1235*5113495bSYour Name }
1236*5113495bSYour Name
1237*5113495bSYour Name static
hdd_sysfs_destroy_ftm_adapter_root_obj(struct hdd_adapter * adapter)1238*5113495bSYour Name void hdd_sysfs_destroy_ftm_adapter_root_obj(struct hdd_adapter *adapter)
1239*5113495bSYour Name {
1240*5113495bSYour Name hdd_sysfs_unit_test_target_destroy(adapter);
1241*5113495bSYour Name }
1242*5113495bSYour Name
hdd_destroy_adapter_sysfs_files(struct hdd_adapter * adapter)1243*5113495bSYour Name void hdd_destroy_adapter_sysfs_files(struct hdd_adapter *adapter)
1244*5113495bSYour Name {
1245*5113495bSYour Name int device_mode = adapter->device_mode;
1246*5113495bSYour Name
1247*5113495bSYour Name if (hdd_adapter_is_link_adapter(adapter)) {
1248*5113495bSYour Name hdd_err("link adapter returning!!");
1249*5113495bSYour Name return;
1250*5113495bSYour Name }
1251*5113495bSYour Name switch (device_mode){
1252*5113495bSYour Name case QDF_STA_MODE:
1253*5113495bSYour Name case QDF_P2P_DEVICE_MODE:
1254*5113495bSYour Name case QDF_P2P_CLIENT_MODE:
1255*5113495bSYour Name hdd_sysfs_destroy_sta_adapter_root_obj(adapter);
1256*5113495bSYour Name break;
1257*5113495bSYour Name case QDF_SAP_MODE:
1258*5113495bSYour Name case QDF_P2P_GO_MODE:
1259*5113495bSYour Name hdd_sysfs_destroy_sap_adapter_root_obj(adapter);
1260*5113495bSYour Name break;
1261*5113495bSYour Name case QDF_MONITOR_MODE:
1262*5113495bSYour Name hdd_sysfs_destroy_monitor_adapter_root_obj(adapter);
1263*5113495bSYour Name break;
1264*5113495bSYour Name case QDF_FTM_MODE:
1265*5113495bSYour Name hdd_sysfs_destroy_ftm_adapter_root_obj(adapter);
1266*5113495bSYour Name break;
1267*5113495bSYour Name case QDF_NDI_MODE:
1268*5113495bSYour Name hdd_sysfs_destroy_ndi_adapter_root_obj(adapter);
1269*5113495bSYour Name break;
1270*5113495bSYour Name default:
1271*5113495bSYour Name break;
1272*5113495bSYour Name }
1273*5113495bSYour Name }
1274