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