developer | 617abbd | 2024-04-23 14:50:01 +0800 | [diff] [blame^] | 1 | From 410e3c08cd5f7bd85e3ca3965fcbf79b9eb6d1e4 Mon Sep 17 00:00:00 2001 |
| 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Tue, 12 Mar 2024 11:26:26 +0800 |
| 4 | Subject: [PATCH 03/61] sync backports patches/ath5k |
| 5 | |
| 6 | --- |
| 7 | drivers/net/wireless/ath/ath5k/ath5k.h | 1 + |
| 8 | drivers/net/wireless/ath/ath5k/base.c | 8 +- |
| 9 | drivers/net/wireless/ath/ath5k/debug.c | 93 +++++++++++++++++++ |
| 10 | drivers/net/wireless/ath/ath5k/dma.c | 8 ++ |
| 11 | drivers/net/wireless/ath/ath5k/initvals.c | 6 ++ |
| 12 | drivers/net/wireless/ath/ath5k/mac80211-ops.c | 9 +- |
| 13 | drivers/net/wireless/ath/ath5k/pci.c | 2 + |
| 14 | drivers/net/wireless/ath/ath5k/reset.c | 2 + |
| 15 | include/linux/ath5k_platform.h | 30 ++++++ |
| 16 | 9 files changed, 150 insertions(+), 9 deletions(-) |
| 17 | create mode 100644 include/linux/ath5k_platform.h |
| 18 | |
| 19 | diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h |
| 20 | index 308a429..0e6d184 100644 |
| 21 | --- a/drivers/net/wireless/ath/ath5k/ath5k.h |
| 22 | +++ b/drivers/net/wireless/ath/ath5k/ath5k.h |
| 23 | @@ -1372,6 +1372,7 @@ struct ath5k_hw { |
| 24 | u8 ah_coverage_class; |
| 25 | bool ah_ack_bitrate_high; |
| 26 | u8 ah_bwmode; |
| 27 | + u8 ah_bwmode_debug; |
| 28 | bool ah_short_slot; |
| 29 | |
| 30 | /* Antenna Control */ |
| 31 | diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c |
| 32 | index bad83fd..fb0366c 100644 |
| 33 | --- a/drivers/net/wireless/ath/ath5k/base.c |
| 34 | +++ b/drivers/net/wireless/ath/ath5k/base.c |
| 35 | @@ -465,6 +465,9 @@ ath5k_chan_set(struct ath5k_hw *ah, struct cfg80211_chan_def *chandef) |
| 36 | return -EINVAL; |
| 37 | } |
| 38 | |
| 39 | + if (ah->ah_bwmode_debug != AR5K_BWMODE_DEFAULT) |
| 40 | + ah->ah_bwmode = ah->ah_bwmode_debug; |
| 41 | + |
| 42 | /* |
| 43 | * To switch channels clear any pending DMA operations; |
| 44 | * wait long enough for the RX fifo to drain, reset the |
| 45 | @@ -2009,7 +2012,7 @@ ath5k_beacon_send(struct ath5k_hw *ah) |
| 46 | } |
| 47 | |
| 48 | if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs + |
| 49 | - ah->num_mesh_vifs > 1) || |
| 50 | + ah->num_adhoc_vifs + ah->num_mesh_vifs > 1) || |
| 51 | ah->opmode == NL80211_IFTYPE_MESH_POINT) { |
| 52 | u64 tsf = ath5k_hw_get_tsf64(ah); |
| 53 | u32 tsftu = TSF_TO_TU(tsf); |
| 54 | @@ -2095,7 +2098,7 @@ ath5k_beacon_update_timers(struct ath5k_hw *ah, u64 bc_tsf) |
| 55 | |
| 56 | intval = ah->bintval & AR5K_BEACON_PERIOD; |
| 57 | if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs |
| 58 | - + ah->num_mesh_vifs > 1) { |
| 59 | + + ah->num_adhoc_vifs + ah->num_mesh_vifs > 1) { |
| 60 | intval /= ATH_BCBUF; /* staggered multi-bss beacons */ |
| 61 | if (intval < 15) |
| 62 | ATH5K_WARN(ah, "intval %u is too low, min 15\n", |
| 63 | @@ -2561,6 +2564,7 @@ static const struct ieee80211_iface_limit if_limits[] = { |
| 64 | BIT(NL80211_IFTYPE_MESH_POINT) | |
| 65 | #endif |
| 66 | BIT(NL80211_IFTYPE_AP) }, |
| 67 | + { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, |
| 68 | }; |
| 69 | |
| 70 | static const struct ieee80211_iface_combination if_comb = { |
| 71 | diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c |
| 72 | index ec13051..239d789 100644 |
| 73 | --- a/drivers/net/wireless/ath/ath5k/debug.c |
| 74 | +++ b/drivers/net/wireless/ath/ath5k/debug.c |
| 75 | @@ -803,6 +803,97 @@ static const struct file_operations fops_ani = { |
| 76 | .llseek = default_llseek, |
| 77 | }; |
| 78 | |
| 79 | +/* debugfs: bwmode */ |
| 80 | + |
| 81 | +static ssize_t read_file_bwmode(struct file *file, char __user *user_buf, |
| 82 | + size_t count, loff_t *ppos) |
| 83 | +{ |
| 84 | + struct ath5k_hw *ah = file->private_data; |
| 85 | + char buf[15]; |
| 86 | + unsigned int len = 0; |
| 87 | + |
| 88 | + int cur_ah_bwmode = ah->ah_bwmode_debug; |
| 89 | + |
| 90 | +#define print_selected(MODE, LABEL) \ |
| 91 | + if (cur_ah_bwmode == MODE) \ |
| 92 | + len += snprintf(buf+len, sizeof(buf)-len, "[%s]", LABEL); \ |
| 93 | + else \ |
| 94 | + len += snprintf(buf+len, sizeof(buf)-len, "%s", LABEL); \ |
| 95 | + len += snprintf(buf+len, sizeof(buf)-len, " "); |
| 96 | + |
| 97 | + print_selected(AR5K_BWMODE_5MHZ, "5"); |
| 98 | + print_selected(AR5K_BWMODE_10MHZ, "10"); |
| 99 | + print_selected(AR5K_BWMODE_DEFAULT, "20"); |
| 100 | + print_selected(AR5K_BWMODE_40MHZ, "40"); |
| 101 | +#undef print_selected |
| 102 | + |
| 103 | + len += snprintf(buf+len, sizeof(buf)-len, "\n"); |
| 104 | + |
| 105 | + return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 106 | +} |
| 107 | + |
| 108 | +static ssize_t write_file_bwmode(struct file *file, |
| 109 | + const char __user *userbuf, |
| 110 | + size_t count, loff_t *ppos) |
| 111 | +{ |
| 112 | + struct ath5k_hw *ah = file->private_data; |
| 113 | + char buf[3]; |
| 114 | + int bw = 20; |
| 115 | + int tobwmode = AR5K_BWMODE_DEFAULT; |
| 116 | + |
| 117 | + if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) |
| 118 | + return -EFAULT; |
| 119 | + |
| 120 | + /* TODO: Add check for active interface */ |
| 121 | + |
| 122 | + if(strncmp(buf, "5", 1) == 0 ) { |
| 123 | + tobwmode = AR5K_BWMODE_5MHZ; |
| 124 | + bw = 5; |
| 125 | + } else if ( strncmp(buf, "10", 2) == 0 ) { |
| 126 | + tobwmode = AR5K_BWMODE_10MHZ; |
| 127 | + bw = 10; |
| 128 | + } else if ( strncmp(buf, "20", 2) == 0 ) { |
| 129 | + tobwmode = AR5K_BWMODE_DEFAULT; |
| 130 | + bw = 20; |
| 131 | + } else if ( strncmp(buf, "40", 2) == 0 ) { |
| 132 | + tobwmode = AR5K_BWMODE_40MHZ; |
| 133 | + bw = 40; |
| 134 | + } else |
| 135 | + return -EINVAL; |
| 136 | + |
| 137 | + ATH5K_INFO(ah, "Changing to %imhz channel width[%i]\n", |
| 138 | + bw, tobwmode); |
| 139 | + |
| 140 | + switch (ah->ah_radio) { |
| 141 | + /* TODO: only define radios that actually support 5/10mhz channels */ |
| 142 | + case AR5K_RF5413: |
| 143 | + case AR5K_RF5110: |
| 144 | + case AR5K_RF5111: |
| 145 | + case AR5K_RF5112: |
| 146 | + case AR5K_RF2413: |
| 147 | + case AR5K_RF2316: |
| 148 | + case AR5K_RF2317: |
| 149 | + case AR5K_RF2425: |
| 150 | + if(ah->ah_bwmode_debug != tobwmode) { |
| 151 | + mutex_lock(&ah->lock); |
| 152 | + ah->ah_bwmode = tobwmode; |
| 153 | + ah->ah_bwmode_debug = tobwmode; |
| 154 | + mutex_unlock(&ah->lock); |
| 155 | + } |
| 156 | + break; |
| 157 | + default: |
| 158 | + return -EOPNOTSUPP; |
| 159 | + } |
| 160 | + return count; |
| 161 | +} |
| 162 | + |
| 163 | +static const struct file_operations fops_bwmode = { |
| 164 | + .read = read_file_bwmode, |
| 165 | + .write = write_file_bwmode, |
| 166 | + .open = simple_open, |
| 167 | + .owner = THIS_MODULE, |
| 168 | + .llseek = default_llseek, |
| 169 | +}; |
| 170 | |
| 171 | /* debugfs: queues etc */ |
| 172 | |
| 173 | @@ -995,6 +1086,8 @@ ath5k_debug_init_device(struct ath5k_hw *ah) |
| 174 | debugfs_create_file("queue", 0600, phydir, ah, &fops_queue); |
| 175 | debugfs_create_bool("32khz_clock", 0600, phydir, |
| 176 | &ah->ah_use_32khz_clock); |
| 177 | + debugfs_create_file("bwmode", S_IWUSR | S_IRUSR, phydir, ah, |
| 178 | + &fops_bwmode); |
| 179 | } |
| 180 | |
| 181 | /* functions used in other places */ |
| 182 | diff --git a/drivers/net/wireless/ath/ath5k/dma.c b/drivers/net/wireless/ath/ath5k/dma.c |
| 183 | index d9e376e..db06ff8 100644 |
| 184 | --- a/drivers/net/wireless/ath/ath5k/dma.c |
| 185 | +++ b/drivers/net/wireless/ath/ath5k/dma.c |
| 186 | @@ -854,10 +854,18 @@ ath5k_hw_dma_init(struct ath5k_hw *ah) |
| 187 | * guess we can tweak it and see how it goes ;-) |
| 188 | */ |
| 189 | if (ah->ah_version != AR5K_AR5210) { |
| 190 | +#if !defined(CONFIG_ATHEROS_AR71XX) && !defined(CONFIG_ATH79) |
| 191 | AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG, |
| 192 | AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B); |
| 193 | AR5K_REG_WRITE_BITS(ah, AR5K_RXCFG, |
| 194 | AR5K_RXCFG_SDMAMW, AR5K_DMASIZE_128B); |
| 195 | +#else |
| 196 | + /* WAR for AR71xx PCI bug */ |
| 197 | + AR5K_REG_WRITE_BITS(ah, AR5K_TXCFG, |
| 198 | + AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B); |
| 199 | + AR5K_REG_WRITE_BITS(ah, AR5K_RXCFG, |
| 200 | + AR5K_RXCFG_SDMAMW, AR5K_DMASIZE_4B); |
| 201 | +#endif |
| 202 | } |
| 203 | |
| 204 | /* Pre-enable interrupts on 5211/5212*/ |
| 205 | diff --git a/drivers/net/wireless/ath/ath5k/initvals.c b/drivers/net/wireless/ath/ath5k/initvals.c |
| 206 | index ee1c2fa..122fe1c 100644 |
| 207 | --- a/drivers/net/wireless/ath/ath5k/initvals.c |
| 208 | +++ b/drivers/net/wireless/ath/ath5k/initvals.c |
| 209 | @@ -62,8 +62,14 @@ static const struct ath5k_ini ar5210_ini[] = { |
| 210 | { AR5K_IMR, 0 }, |
| 211 | { AR5K_IER, AR5K_IER_DISABLE }, |
| 212 | { AR5K_BSR, 0, AR5K_INI_READ }, |
| 213 | +#if !defined(CONFIG_ATHEROS_AR71XX) && !defined(CONFIG_ATH79) |
| 214 | { AR5K_TXCFG, AR5K_DMASIZE_128B }, |
| 215 | { AR5K_RXCFG, AR5K_DMASIZE_128B }, |
| 216 | +#else |
| 217 | + /* WAR for AR71xx PCI bug */ |
| 218 | + { AR5K_TXCFG, AR5K_DMASIZE_128B }, |
| 219 | + { AR5K_RXCFG, AR5K_DMASIZE_4B }, |
| 220 | +#endif |
| 221 | { AR5K_CFG, AR5K_INIT_CFG }, |
| 222 | { AR5K_TOPS, 8 }, |
| 223 | { AR5K_RXNOFRM, 8 }, |
| 224 | diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c |
| 225 | index da9dc62..2fb37d3 100644 |
| 226 | --- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c |
| 227 | +++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c |
| 228 | @@ -86,13 +86,8 @@ ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 229 | goto end; |
| 230 | } |
| 231 | |
| 232 | - /* Don't allow other interfaces if one ad-hoc is configured. |
| 233 | - * TODO: Fix the problems with ad-hoc and multiple other interfaces. |
| 234 | - * We would need to operate the HW in ad-hoc mode to allow TSF updates |
| 235 | - * for the IBSS, but this breaks with additional AP or STA interfaces |
| 236 | - * at the moment. */ |
| 237 | - if (ah->num_adhoc_vifs || |
| 238 | - (ah->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) { |
| 239 | + /* Don't allow more than one ad-hoc interface */ |
| 240 | + if (ah->num_adhoc_vifs && vif->type == NL80211_IFTYPE_ADHOC) { |
| 241 | ATH5K_ERR(ah, "Only one single ad-hoc interface is allowed.\n"); |
| 242 | ret = -ELNRNG; |
| 243 | goto end; |
| 244 | diff --git a/drivers/net/wireless/ath/ath5k/pci.c b/drivers/net/wireless/ath/ath5k/pci.c |
| 245 | index c4315dd..2aae4de 100644 |
| 246 | --- a/drivers/net/wireless/ath/ath5k/pci.c |
| 247 | +++ b/drivers/net/wireless/ath/ath5k/pci.c |
| 248 | @@ -47,6 +47,8 @@ static const struct pci_device_id ath5k_pci_id_table[] = { |
| 249 | { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */ |
| 250 | { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */ |
| 251 | { PCI_VDEVICE(ATHEROS, 0x001d) }, /* 2417 Nala */ |
| 252 | + { PCI_VDEVICE(ATHEROS, 0xff16) }, /* 2413,2414 sx76x on lantiq_danube */ |
| 253 | + { PCI_VDEVICE(ATHEROS, 0xff1a) }, /* 2417 arv45xx on lantiq_danube */ |
| 254 | { PCI_VDEVICE(ATHEROS, 0xff1b) }, /* AR5BXB63 */ |
| 255 | { 0 } |
| 256 | }; |
| 257 | diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c |
| 258 | index 9fdb528..eabf225 100644 |
| 259 | --- a/drivers/net/wireless/ath/ath5k/reset.c |
| 260 | +++ b/drivers/net/wireless/ath/ath5k/reset.c |
| 261 | @@ -1154,6 +1154,7 @@ ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, |
| 262 | tsf_lo = 0; |
| 263 | mode = 0; |
| 264 | |
| 265 | +#if 0 |
| 266 | /* |
| 267 | * Sanity check for fast flag |
| 268 | * Fast channel change only available |
| 269 | @@ -1161,6 +1162,7 @@ ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, |
| 270 | */ |
| 271 | if (fast && (ah->ah_radio != AR5K_RF2413) && |
| 272 | (ah->ah_radio != AR5K_RF5413)) |
| 273 | +#endif |
| 274 | fast = false; |
| 275 | |
| 276 | /* Disable sleep clock operation |
| 277 | diff --git a/include/linux/ath5k_platform.h b/include/linux/ath5k_platform.h |
| 278 | new file mode 100644 |
| 279 | index 0000000..ec85224 |
| 280 | --- /dev/null |
| 281 | +++ b/include/linux/ath5k_platform.h |
| 282 | @@ -0,0 +1,30 @@ |
| 283 | +/* |
| 284 | + * Copyright (c) 2008 Atheros Communications Inc. |
| 285 | + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org> |
| 286 | + * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org> |
| 287 | + * Copyright (c) 2010 Daniel Golle <daniel.golle@gmail.com> |
| 288 | + * |
| 289 | + * Permission to use, copy, modify, and/or distribute this software for any |
| 290 | + * purpose with or without fee is hereby granted, provided that the above |
| 291 | + * copyright notice and this permission notice appear in all copies. |
| 292 | + * |
| 293 | + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 294 | + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 295 | + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 296 | + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 297 | + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 298 | + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 299 | + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 300 | + */ |
| 301 | + |
| 302 | +#ifndef _LINUX_ATH5K_PLATFORM_H |
| 303 | +#define _LINUX_ATH5K_PLATFORM_H |
| 304 | + |
| 305 | +#define ATH5K_PLAT_EEP_MAX_WORDS 2048 |
| 306 | + |
| 307 | +struct ath5k_platform_data { |
| 308 | + u16 *eeprom_data; |
| 309 | + u8 *macaddr; |
| 310 | +}; |
| 311 | + |
| 312 | +#endif /* _LINUX_ATH5K_PLATFORM_H */ |
| 313 | -- |
| 314 | 2.39.2 |
| 315 | |