1 This adds a bwmode debugfs file which can be used to set alternate
2 channel operating bandwidths. Only tested with AR5413 and only at
5 Signed-off-by: Pat Erley <pat-lkml at erley.org>
7 Other devices will need to be added to the switch in write_file_bwmode
9 drivers/net/wireless/ath/ath5k/debug.c | 86 ++++++++++++++++++++++++++++++++
10 1 files changed, 86 insertions(+), 0 deletions(-)
12 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath5k/debug.c
13 ===================================================================
14 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath5k/debug.c
15 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath5k/debug.c
16 @@ -822,6 +822,97 @@ static const struct file_operations fops
17 .llseek = default_llseek,
20 +/* debugfs: bwmode */
22 +static ssize_t read_file_bwmode(struct file *file, char __user *user_buf,
23 + size_t count, loff_t *ppos)
25 + struct ath5k_hw *ah = file->private_data;
27 + unsigned int len = 0;
29 + int cur_ah_bwmode = ah->ah_bwmode_debug;
31 +#define print_selected(MODE, LABEL) \
32 + if (cur_ah_bwmode == MODE) \
33 + len += snprintf(buf+len, sizeof(buf)-len, "[%s]", LABEL); \
35 + len += snprintf(buf+len, sizeof(buf)-len, "%s", LABEL); \
36 + len += snprintf(buf+len, sizeof(buf)-len, " ");
38 + print_selected(AR5K_BWMODE_5MHZ, "5");
39 + print_selected(AR5K_BWMODE_10MHZ, "10");
40 + print_selected(AR5K_BWMODE_DEFAULT, "20");
41 + print_selected(AR5K_BWMODE_40MHZ, "40");
42 +#undef print_selected
44 + len += snprintf(buf+len, sizeof(buf)-len, "\n");
46 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
49 +static ssize_t write_file_bwmode(struct file *file,
50 + const char __user *userbuf,
51 + size_t count, loff_t *ppos)
53 + struct ath5k_hw *ah = file->private_data;
56 + int tobwmode = AR5K_BWMODE_DEFAULT;
58 + if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
61 + /* TODO: Add check for active interface */
63 + if(strncmp(buf, "5", 1) == 0 ) {
64 + tobwmode = AR5K_BWMODE_5MHZ;
66 + } else if ( strncmp(buf, "10", 2) == 0 ) {
67 + tobwmode = AR5K_BWMODE_10MHZ;
69 + } else if ( strncmp(buf, "20", 2) == 0 ) {
70 + tobwmode = AR5K_BWMODE_DEFAULT;
72 + } else if ( strncmp(buf, "40", 2) == 0 ) {
73 + tobwmode = AR5K_BWMODE_40MHZ;
78 + ATH5K_INFO(ah, "Changing to %imhz channel width[%i]\n",
81 + switch (ah->ah_radio) {
82 + /* TODO: only define radios that actually support 5/10mhz channels */
91 + if(ah->ah_bwmode_debug != tobwmode) {
92 + mutex_lock(&ah->lock);
93 + ah->ah_bwmode = tobwmode;
94 + ah->ah_bwmode_debug = tobwmode;
95 + mutex_unlock(&ah->lock);
104 +static const struct file_operations fops_bwmode = {
105 + .read = read_file_bwmode,
106 + .write = write_file_bwmode,
107 + .open = simple_open,
108 + .owner = THIS_MODULE,
109 + .llseek = default_llseek,
112 /* debugfs: queues etc */
114 @@ -1016,6 +1107,8 @@ ath5k_debug_init_device(struct ath5k_hw
115 debugfs_create_file("queue", 0600, phydir, ah, &fops_queue);
116 debugfs_create_bool("32khz_clock", 0600, phydir,
117 &ah->ah_use_32khz_clock);
118 + debugfs_create_file("bwmode", S_IWUSR | S_IRUSR, phydir, ah,
122 /* functions used in other places */
123 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath5k/ath5k.h
124 ===================================================================
125 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath5k/ath5k.h
126 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath5k/ath5k.h
127 @@ -1372,6 +1372,7 @@ struct ath5k_hw {
128 u8 ah_coverage_class;
129 bool ah_ack_bitrate_high;
131 + u8 ah_bwmode_debug;
134 /* Antenna Control */
135 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath5k/base.c
136 ===================================================================
137 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath5k/base.c
138 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath5k/base.c
139 @@ -466,6 +466,9 @@ ath5k_chan_set(struct ath5k_hw *ah, stru
143 + if (ah->ah_bwmode_debug != AR5K_BWMODE_DEFAULT)
144 + ah->ah_bwmode = ah->ah_bwmode_debug;
147 * To switch channels clear any pending DMA operations;
148 * wait long enough for the RX fifo to drain, reset the