Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * mac80211 debugfs for wireless PHYs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright 2013-2014  Intel Mobile Communications GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 2018 - 2019 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/rtnetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "ieee80211_i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "driver-ops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "rate.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "debugfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define DEBUGFS_FORMAT_BUFFER_SIZE 100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) int mac80211_format_buffer(char __user *userbuf, size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 				  loff_t *ppos, char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	va_start(args, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	res = vscnprintf(buf, sizeof(buf), fmt, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define DEBUGFS_READONLY_FILE_FN(name, fmt, value...)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static ssize_t name## _read(struct file *file, char __user *userbuf,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 			    size_t count, loff_t *ppos)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct ieee80211_local *local = file->private_data;		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	return mac80211_format_buffer(userbuf, count, ppos, 		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 				      fmt "\n", ##value);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define DEBUGFS_READONLY_FILE_OPS(name)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static const struct file_operations name## _ops = {			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	.read = name## _read,						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	.open = simple_open,						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	.llseek = generic_file_llseek,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define DEBUGFS_READONLY_FILE(name, fmt, value...)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	DEBUGFS_READONLY_FILE_FN(name, fmt, value)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	DEBUGFS_READONLY_FILE_OPS(name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define DEBUGFS_ADD(name)						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	debugfs_create_file(#name, 0400, phyd, local, &name## _ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define DEBUGFS_ADD_MODE(name, mode)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	debugfs_create_file(#name, mode, phyd, local, &name## _ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) DEBUGFS_READONLY_FILE(hw_conf, "%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		      local->hw.conf.flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) DEBUGFS_READONLY_FILE(user_power, "%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		      local->user_power_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) DEBUGFS_READONLY_FILE(power, "%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		      local->hw.conf.power_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) DEBUGFS_READONLY_FILE(total_ps_buffered, "%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		      local->total_ps_buffered);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) DEBUGFS_READONLY_FILE(wep_iv, "%#08x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		      local->wep_iv & 0xffffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static ssize_t aqm_read(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct fq *fq = &local->fq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	char buf[200];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	spin_lock_bh(&local->fq.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	len = scnprintf(buf, sizeof(buf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			"access name value\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			"R fq_flows_cnt %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			"R fq_backlog %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			"R fq_overlimit %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			"R fq_overmemory %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			"R fq_collisions %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			"R fq_memory_usage %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			"RW fq_memory_limit %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			"RW fq_limit %u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			"RW fq_quantum %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			fq->flows_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			fq->backlog,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			fq->overmemory,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			fq->overlimit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			fq->collisions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			fq->memory_usage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			fq->memory_limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			fq->limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			fq->quantum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	spin_unlock_bh(&local->fq.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	return simple_read_from_buffer(user_buf, count, ppos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 				       buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static ssize_t aqm_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			 const char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			 size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			 loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	char buf[100];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	if (count >= sizeof(buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	if (copy_from_user(buf, user_buf, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	if (count && buf[count - 1] == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		buf[count - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		buf[count] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	if (sscanf(buf, "fq_limit %u", &local->fq.limit) == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	else if (sscanf(buf, "fq_memory_limit %u", &local->fq.memory_limit) == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	else if (sscanf(buf, "fq_quantum %u", &local->fq.quantum) == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static const struct file_operations aqm_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	.write = aqm_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	.read = aqm_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	.open = simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	.llseek = default_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static ssize_t airtime_flags_read(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				  char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 				  size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	char buf[128] = {}, *pos, *end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	pos = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	end = pos + sizeof(buf) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	if (local->airtime_flags & AIRTIME_USE_TX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		pos += scnprintf(pos, end - pos, "AIRTIME_TX\t(%lx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				 AIRTIME_USE_TX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if (local->airtime_flags & AIRTIME_USE_RX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		pos += scnprintf(pos, end - pos, "AIRTIME_RX\t(%lx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 				 AIRTIME_USE_RX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	return simple_read_from_buffer(user_buf, count, ppos, buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 				       strlen(buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static ssize_t airtime_flags_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 				   const char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 				   size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	char buf[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	if (count >= sizeof(buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (copy_from_user(buf, user_buf, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	if (count && buf[count - 1] == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		buf[count - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		buf[count] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	if (kstrtou16(buf, 0, &local->airtime_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static const struct file_operations airtime_flags_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	.write = airtime_flags_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	.read = airtime_flags_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	.open = simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	.llseek = default_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static ssize_t aql_txq_limit_read(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				  char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				  size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 				  loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	char buf[400];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	len = scnprintf(buf, sizeof(buf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			"AC	AQL limit low	AQL limit high\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			"VO	%u		%u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 			"VI	%u		%u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			"BE	%u		%u\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			"BK	%u		%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			local->aql_txq_limit_low[IEEE80211_AC_VO],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			local->aql_txq_limit_high[IEEE80211_AC_VO],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			local->aql_txq_limit_low[IEEE80211_AC_VI],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			local->aql_txq_limit_high[IEEE80211_AC_VI],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			local->aql_txq_limit_low[IEEE80211_AC_BE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			local->aql_txq_limit_high[IEEE80211_AC_BE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			local->aql_txq_limit_low[IEEE80211_AC_BK],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			local->aql_txq_limit_high[IEEE80211_AC_BK]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	return simple_read_from_buffer(user_buf, count, ppos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				       buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static ssize_t aql_txq_limit_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				   const char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				   size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 				   loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	char buf[100];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	u32 ac, q_limit_low, q_limit_high, q_limit_low_old, q_limit_high_old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	if (count >= sizeof(buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	if (copy_from_user(buf, user_buf, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	if (count && buf[count - 1] == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		buf[count - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		buf[count] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	if (sscanf(buf, "%u %u %u", &ac, &q_limit_low, &q_limit_high) != 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	if (ac >= IEEE80211_NUM_ACS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	q_limit_low_old = local->aql_txq_limit_low[ac];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	q_limit_high_old = local->aql_txq_limit_high[ac];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	local->aql_txq_limit_low[ac] = q_limit_low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	local->aql_txq_limit_high[ac] = q_limit_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	mutex_lock(&local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	list_for_each_entry(sta, &local->sta_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		/* If a sta has customized queue limits, keep it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		if (sta->airtime[ac].aql_limit_low == q_limit_low_old &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		    sta->airtime[ac].aql_limit_high == q_limit_high_old) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 			sta->airtime[ac].aql_limit_low = q_limit_low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 			sta->airtime[ac].aql_limit_high = q_limit_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	mutex_unlock(&local->sta_mtx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static const struct file_operations aql_txq_limit_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	.write = aql_txq_limit_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	.read = aql_txq_limit_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	.open = simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	.llseek = default_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) static ssize_t force_tx_status_read(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 				    char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 				    size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 				    loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	char buf[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	len = scnprintf(buf, sizeof(buf), "%d\n", (int)local->force_tx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	return simple_read_from_buffer(user_buf, count, ppos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 				       buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) static ssize_t force_tx_status_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 				     const char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 				     size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 				     loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	char buf[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	if (count >= sizeof(buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	if (copy_from_user(buf, user_buf, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	if (count && buf[count - 1] == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		buf[count - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		buf[count] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	if (buf[0] == '0' && buf[1] == '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		local->force_tx_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	else if (buf[0] == '1' && buf[1] == '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		local->force_tx_status = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) static const struct file_operations force_tx_status_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	.write = force_tx_status_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	.read = force_tx_status_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	.open = simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	.llseek = default_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) static ssize_t reset_write(struct file *file, const char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			   size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	rtnl_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	__ieee80211_suspend(&local->hw, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	__ieee80211_resume(&local->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	rtnl_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) static const struct file_operations reset_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	.write = reset_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	.open = simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	.llseek = noop_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static const char *hw_flag_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) #define FLAG(F)	[IEEE80211_HW_##F] = #F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	FLAG(HAS_RATE_CONTROL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	FLAG(RX_INCLUDES_FCS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	FLAG(HOST_BROADCAST_PS_BUFFERING),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	FLAG(SIGNAL_UNSPEC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	FLAG(SIGNAL_DBM),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	FLAG(NEED_DTIM_BEFORE_ASSOC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	FLAG(SPECTRUM_MGMT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	FLAG(AMPDU_AGGREGATION),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	FLAG(SUPPORTS_PS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	FLAG(PS_NULLFUNC_STACK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	FLAG(SUPPORTS_DYNAMIC_PS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	FLAG(MFP_CAPABLE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	FLAG(WANT_MONITOR_VIF),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	FLAG(NO_AUTO_VIF),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	FLAG(SW_CRYPTO_CONTROL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	FLAG(SUPPORT_FAST_XMIT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	FLAG(REPORTS_TX_ACK_STATUS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	FLAG(CONNECTION_MONITOR),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	FLAG(QUEUE_CONTROL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	FLAG(SUPPORTS_PER_STA_GTK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	FLAG(AP_LINK_PS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	FLAG(TX_AMPDU_SETUP_IN_HW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	FLAG(SUPPORTS_RC_TABLE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	FLAG(P2P_DEV_ADDR_FOR_INTF),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	FLAG(TIMING_BEACON_ONLY),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	FLAG(SUPPORTS_HT_CCK_RATES),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	FLAG(CHANCTX_STA_CSA),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	FLAG(SUPPORTS_CLONED_SKBS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	FLAG(SINGLE_SCAN_ON_ALL_BANDS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	FLAG(TDLS_WIDER_BW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	FLAG(SUPPORTS_AMSDU_IN_AMPDU),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	FLAG(BEACON_TX_STATUS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	FLAG(NEEDS_UNIQUE_STA_ADDR),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	FLAG(SUPPORTS_REORDERING_BUFFER),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	FLAG(USES_RSS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	FLAG(TX_AMSDU),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	FLAG(TX_FRAG_LIST),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	FLAG(REPORTS_LOW_ACK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	FLAG(SUPPORTS_TX_FRAG),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	FLAG(SUPPORTS_TDLS_BUFFER_STA),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	FLAG(DEAUTH_NEED_MGD_TX_PREP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	FLAG(DOESNT_SUPPORT_QOS_NDP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	FLAG(BUFF_MMPDU_TXQ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	FLAG(SUPPORTS_VHT_EXT_NSS_BW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	FLAG(STA_MMPDU_TXQ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	FLAG(TX_STATUS_NO_AMPDU_LEN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	FLAG(SUPPORTS_MULTI_BSSID),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	FLAG(SUPPORTS_ONLY_HE_MULTI_BSSID),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	FLAG(AMPDU_KEYBORDER_SUPPORT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	FLAG(SUPPORTS_TX_ENCAP_OFFLOAD),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) #undef FLAG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) static ssize_t hwflags_read(struct file *file, char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 			    size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	size_t bufsz = 30 * NUM_IEEE80211_HW_FLAGS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	char *buf = kzalloc(bufsz, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	char *pos = buf, *end = buf + bufsz - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	ssize_t rv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	/* fail compilation if somebody adds or removes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	 * a flag without updating the name array above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	BUILD_BUG_ON(ARRAY_SIZE(hw_flag_names) != NUM_IEEE80211_HW_FLAGS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	for (i = 0; i < NUM_IEEE80211_HW_FLAGS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 		if (test_bit(i, local->hw.flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 			pos += scnprintf(pos, end - pos, "%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 					 hw_flag_names[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	return rv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) static ssize_t misc_read(struct file *file, char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 			 size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	/* Max len of each line is 16 characters, plus 9 for 'pending:\n' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	char *pos, *end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	ssize_t rv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	int ln;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	buf = kzalloc(bufsz, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	pos = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	end = buf + bufsz - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	pos += scnprintf(pos, end - pos, "pending:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 		ln = skb_queue_len(&local->pending[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		pos += scnprintf(pos, end - pos, "[%i] %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 				 i, ln);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	return rv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) static ssize_t queues_read(struct file *file, char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 			   size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	struct ieee80211_local *local = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	char buf[IEEE80211_MAX_QUEUES * 20];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	int q, res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	for (q = 0; q < local->hw.queues; q++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 		res += sprintf(buf + res, "%02d: %#.8lx/%d\n", q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 				local->queue_stop_reasons[q],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 				skb_queue_len(&local->pending[q]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	return simple_read_from_buffer(user_buf, count, ppos, buf, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) DEBUGFS_READONLY_FILE_OPS(hwflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) DEBUGFS_READONLY_FILE_OPS(queues);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) DEBUGFS_READONLY_FILE_OPS(misc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) /* statistics stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) static ssize_t format_devstat_counter(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	char __user *userbuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	size_t count, loff_t *ppos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 			  int buflen))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	struct ieee80211_low_level_stats stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	char buf[20];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	rtnl_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	res = drv_get_stats(local, &stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	rtnl_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	if (res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	res = printvalue(&stats, buf, sizeof(buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) #define DEBUGFS_DEVSTATS_FILE(name)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) static int print_devstats_##name(struct ieee80211_low_level_stats *stats,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 				 char *buf, int buflen)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	return scnprintf(buf, buflen, "%u\n", stats->name);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) static ssize_t stats_ ##name## _read(struct file *file,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 				     char __user *userbuf,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 				     size_t count, loff_t *ppos)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	return format_devstat_counter(file->private_data,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 				      userbuf,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 				      count,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 				      ppos,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 				      print_devstats_##name);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) static const struct file_operations stats_ ##name## _ops = {		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	.read = stats_ ##name## _read,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	.open = simple_open,						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	.llseek = generic_file_llseek,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) #define DEBUGFS_STATS_ADD(name)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	debugfs_create_u32(#name, 0400, statsd, &local->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) #define DEBUGFS_DEVSTATS_ADD(name)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	debugfs_create_file(#name, 0400, statsd, local, &stats_ ##name## _ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) DEBUGFS_DEVSTATS_FILE(dot11ACKFailureCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) DEBUGFS_DEVSTATS_FILE(dot11RTSFailureCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) DEBUGFS_DEVSTATS_FILE(dot11FCSErrorCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) DEBUGFS_DEVSTATS_FILE(dot11RTSSuccessCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) void debugfs_hw_add(struct ieee80211_local *local)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	struct dentry *phyd = local->hw.wiphy->debugfsdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	struct dentry *statsd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	if (!phyd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	local->debugfs.keys = debugfs_create_dir("keys", phyd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	DEBUGFS_ADD(total_ps_buffered);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	DEBUGFS_ADD(wep_iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	DEBUGFS_ADD(rate_ctrl_alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	DEBUGFS_ADD(queues);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	DEBUGFS_ADD(misc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	DEBUGFS_ADD_MODE(reset, 0200);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	DEBUGFS_ADD(hwflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	DEBUGFS_ADD(user_power);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	DEBUGFS_ADD(power);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	DEBUGFS_ADD(hw_conf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	DEBUGFS_ADD_MODE(force_tx_status, 0600);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	if (local->ops->wake_tx_queue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		DEBUGFS_ADD_MODE(aqm, 0600);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	DEBUGFS_ADD_MODE(airtime_flags, 0600);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	DEBUGFS_ADD(aql_txq_limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	debugfs_create_u32("aql_threshold", 0600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 			   phyd, &local->aql_threshold);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	statsd = debugfs_create_dir("statistics", phyd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	/* if the dir failed, don't put all the other things into the root! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	if (!statsd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	DEBUGFS_STATS_ADD(dot11TransmittedFragmentCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	DEBUGFS_STATS_ADD(dot11MulticastTransmittedFrameCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	DEBUGFS_STATS_ADD(dot11FailedCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	DEBUGFS_STATS_ADD(dot11RetryCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	DEBUGFS_STATS_ADD(dot11MultipleRetryCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	DEBUGFS_STATS_ADD(dot11FrameDuplicateCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	DEBUGFS_STATS_ADD(dot11ReceivedFragmentCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	DEBUGFS_STATS_ADD(dot11MulticastReceivedFrameCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	DEBUGFS_STATS_ADD(dot11TransmittedFrameCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	DEBUGFS_STATS_ADD(tx_handlers_drop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	DEBUGFS_STATS_ADD(tx_handlers_queued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	DEBUGFS_STATS_ADD(tx_handlers_drop_wep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	DEBUGFS_STATS_ADD(tx_handlers_drop_not_assoc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	DEBUGFS_STATS_ADD(tx_handlers_drop_unauth_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	DEBUGFS_STATS_ADD(rx_handlers_drop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	DEBUGFS_STATS_ADD(rx_handlers_queued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	DEBUGFS_STATS_ADD(rx_handlers_drop_nullfunc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	DEBUGFS_STATS_ADD(rx_handlers_drop_defrag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	DEBUGFS_STATS_ADD(tx_expand_skb_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 	DEBUGFS_STATS_ADD(tx_expand_skb_head_cloned);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	DEBUGFS_STATS_ADD(rx_expand_skb_head_defrag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	DEBUGFS_STATS_ADD(rx_handlers_fragments);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	DEBUGFS_STATS_ADD(tx_status_drop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	DEBUGFS_DEVSTATS_ADD(dot11ACKFailureCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 	DEBUGFS_DEVSTATS_ADD(dot11RTSFailureCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	DEBUGFS_DEVSTATS_ADD(dot11FCSErrorCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	DEBUGFS_DEVSTATS_ADD(dot11RTSSuccessCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }