LINUX.ORG.RU

ath9k_htc борьба с дропами wifi под нагрузкой клиентов и в шумной среде. патчи и настройки.

 , , , ,


2

2

Оставляю здесь плод годичных мучений... Я не знаю как вы юзаете свои Atheros, но у меня на 3-х роутерах и двух usb-свистках был один и тот же не проходящий симптом: рандомный дроп wifi под нагрузкой c исчезновением ssid до перезапуска. Ага. на разных прошивках на разных драйверах на разных патчах на разном оборудовании... всегда одно и тоже... чуть с ума не сошел. вот скрипт сборки стека драйверов ( AR9271 ) и пару патчей :

$ cat build.sh

#!/bin/bash

uname -a


####  https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-testing.                                                                                                                      git/snapshot/wireless-testing-5.0-rc1.tar.gz

#######Это текущие не патченные драйверы
#######wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.19.4.t                                                                                                                      ar.xz
#######tar -xvJf linux-4.19.4.tar.xz

#######Это backport, последнее обновление 2018 года
######wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/backports/s                                                                                                                      table/v4.19.7/backports-4.19.7-1.tar.xz
######tar -xvJf backports-4.19.7-1.tar.xz

#Это с патчами при сбросе после ошибочной калибровки !!!! и вроде к ядру как раз                                                                                                                       4.19 !!!
#git clone https://github.com/intel/mainline-tracking/

wget https://github.com/intel/mainline-tracking/archive/master.zip
unzip -qo master.zip
BUILD_DIR=mainline-tracking-master
patch -d $BUILD_DIR -p1 < v2-2-3-ath9k_htc-enable-ANI-debug-output.diff
patch -d $BUILD_DIR -p1 < linux-4.9.28-ath9k_htc-misc.patch
#patch -d $BUILD_DIR -p1 < ath9k-will-not-tx-packets-sometimes..diff
#patch -d $BUILD_DIR -p1 < RFC-v2-1-2-ath9k-work-around-AR_CFG-0xdeadbeef-chip-h                                                                                                                      ang.diff
#patch -d $BUILD_DIR -p1 < RFC-v2-2-2-ath9k-Reset-chip-on-potential-deaf-state.d                                                                                                                      iff

echo "sleep 20s"
sleep 20

cd $BUILD_DIR

make clean
make mrproper

cp -v -r /usr/lib/modules/$(uname -r)/build/.config ./
cp -r /usr/lib/modules/$(uname -r)/build/* ./

#cp -v /usr/lib/modules/$(uname -r)/build/.config ./
#cp -v /usr/lib/modules/$(uname -r)/build/Kconfig ./
#cp -v /usr/lib/modules/$(uname -r)/build/Module.symvers ./
#cp -v /usr/lib/modules/$(uname -r)/build/Makefile ./

#cp -v /usr/lib/modules/$(uname -r)/build/drivers/net/wireless/ath/ath9k/Kconfig                                                                                                                       ./drivers/net/wireless/ath/ath9k/
#cp -v /usr/lib/modules/$(uname -r)/build/net/wireless/Kconfig ./net/wireless/
#cp -v /usr/lib/modules/$(uname -r)/build/net/mac80211/Kconfig ./net/mac80211/
#cp -v -r /usr/lib/modules/$(uname -r)/build/net/mac80211/ ./net/mac80211/

#make menuconfig
#make oldconfig
echo "CONFIG_CARL9170_HWRNG=y" >> .config
echo "CONFIG_CRYPTO_SPECK=y" >> .config
echo "CONFIG_ATH_DEBUG=y" >> .config
echo "CONFIG_ATH_TRACEPOINTS=n" >> .config

find ./ -iname *.ko.xz -exec rm {} \;
find ./ -iname *.ko -exec rm {} \;

make modules_prepare

make M=drivers/net/wireless/ath/ath9k/
make M=net/wireless/
make M=net/mac80211/

find ./ -iname *.ko -exec xz {} \;

#В archlinux каталог updates имет приоритет
mkdir -p /usr/lib/modules/`uname -r`/updates/

sudo find /usr/lib/modules/`uname -r`/updates/ -iname "*ath*" -exec rm -v {} \;
sudo find /usr/lib/modules/`uname -r`/updates/ -iname "*80211*" -exec rm -v {} \                                                                                                                      ;

sudo find ./ -iname *.ko.xz -exec cp -v {} /usr/lib/modules/`uname -r`/updates/                                                                                                                       \;
sudo depmod -a

ls /usr/lib/modules/`uname -r`/updates/

$ cat linux-4.9.28-ath9k_htc-misc.patch


diff -Naur linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/common-init.c linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/common-init.c
--- linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/common-init.c 2017-05-15 17:23:14.000000000 +0200
+++ linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/common-init.c 2017-07-05 22:29:13.285134611 +0200
@@ -22,14 +22,14 @@
        .band = NL80211_BAND_2GHZ, \
        .center_freq = (_freq), \
        .hw_value = (_idx), \
-       .max_power = 20, \
+       .max_power = 30, \
 }

 #define CHAN5G(_freq, _idx) { \
        .band = NL80211_BAND_5GHZ, \
        .center_freq = (_freq), \
        .hw_value = (_idx), \
-       .max_power = 20, \
+       .max_power = 30, \
 }

 /* Some 2 GHz radios are actually tunable on 2312-2732
@@ -37,6 +37,27 @@
  * we have calibration data for all cards though to make
  * this static */
 static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
+       CHAN2G(2312, 34), /* Channel XX */
+       CHAN2G(2317, 35), /* Channel XX */
+       CHAN2G(2322, 36), /* Channel XX */
+       CHAN2G(2327, 37), /* Channel XX */
+       CHAN2G(2332, 38), /* Channel XX */
+       CHAN2G(2337, 39), /* Channel XX */
+       CHAN2G(2342, 40), /* Channel XX */
+       CHAN2G(2347, 41), /* Channel XX */
+       CHAN2G(2352, 42), /* Channel XX */
+       CHAN2G(2357, 43), /* Channel XX */
+       CHAN2G(2362, 44), /* Channel XX */
+       CHAN2G(2367, 45), /* Channel XX */
+       CHAN2G(2372, 46), /* Channel XX */
+       CHAN2G(2377, 47), /* Channel XX */
+       CHAN2G(2382, 48), /* Channel XX */
+       CHAN2G(2387, 49), /* Channel XX */
+       CHAN2G(2392, 50), /* Channel XX */
+       CHAN2G(2397, 51), /* Channel XX */
+       CHAN2G(2402, 52), /* Channel XX */
+       CHAN2G(2407, 53), /* Channel XX */
+
        CHAN2G(2412, 0), /* Channel 1 */
        CHAN2G(2417, 1), /* Channel 2 */
        CHAN2G(2422, 2), /* Channel 3 */
@@ -50,7 +71,31 @@
        CHAN2G(2462, 10), /* Channel 11 */
        CHAN2G(2467, 11), /* Channel 12 */
        CHAN2G(2472, 12), /* Channel 13 */
-       CHAN2G(2484, 13), /* Channel 14 */
+
+       CHAN2G(2477, 13), /* Channel XX */
+       CHAN2G(2478, 14), /* Channel XX */
+       CHAN2G(2482, 15), /* Channel XX */
+
+       CHAN2G(2484, 16), /* Channel 14 */
+
+       CHAN2G(2487, 17), /* Channel XX */
+       CHAN2G(2489, 18), /* Channel XX */
+       CHAN2G(2492, 19), /* Channel XX */
+       CHAN2G(2494, 20), /* Channel XX */
+       CHAN2G(2497, 21), /* Channel XX */
+       CHAN2G(2499, 22), /* Channel XX */
+       CHAN2G(2512, 23), /* Channel XX */
+       CHAN2G(2532, 24), /* Channel XX */
+       CHAN2G(2572, 25), /* Channel XX */
+       CHAN2G(2592, 26), /* Channel XX */
+       CHAN2G(2612, 27), /* Channel XX */
+       CHAN2G(2632, 28), /* Channel XX */
+       CHAN2G(2652, 29), /* Channel XX */
+       CHAN2G(2672, 30), /* Channel XX */
+       CHAN2G(2692, 31), /* Channel XX */
+       CHAN2G(2712, 32), /* Channel XX */
+       CHAN2G(2732, 33), /* Channel XX */
+
 };

 /* Some 5 GHz radios are actually tunable on XXXX-YYYY
@@ -58,34 +103,39 @@
  * we have calibration data for all cards though to make
  * this static */
 static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
+       CHAN5G(4920, 54), /* Channel XX */
+       CHAN5G(4940, 55), /* Channel XX */
+       CHAN5G(4960, 56), /* Channel XX */
+       CHAN5G(4980, 57), /* Channel XX */
+
        /* _We_ call this UNII 1 */
-       CHAN5G(5180, 14), /* Channel 36 */
-       CHAN5G(5200, 15), /* Channel 40 */
-       CHAN5G(5220, 16), /* Channel 44 */
-       CHAN5G(5240, 17), /* Channel 48 */
+       CHAN5G(5180, 58), /* Channel 36 */
+       CHAN5G(5200, 59), /* Channel 40 */
+       CHAN5G(5220, 60), /* Channel 44 */
+       CHAN5G(5240, 61), /* Channel 48 */
        /* _We_ call this UNII 2 */
-       CHAN5G(5260, 18), /* Channel 52 */
-       CHAN5G(5280, 19), /* Channel 56 */
-       CHAN5G(5300, 20), /* Channel 60 */
-       CHAN5G(5320, 21), /* Channel 64 */
+       CHAN5G(5260, 62), /* Channel 52 */
+       CHAN5G(5280, 63), /* Channel 56 */
+       CHAN5G(5300, 64), /* Channel 60 */
+       CHAN5G(5320, 65), /* Channel 64 */
        /* _We_ call this "Middle band" */
-       CHAN5G(5500, 22), /* Channel 100 */
-       CHAN5G(5520, 23), /* Channel 104 */
-       CHAN5G(5540, 24), /* Channel 108 */
-       CHAN5G(5560, 25), /* Channel 112 */
-       CHAN5G(5580, 26), /* Channel 116 */
-       CHAN5G(5600, 27), /* Channel 120 */
-       CHAN5G(5620, 28), /* Channel 124 */
-       CHAN5G(5640, 29), /* Channel 128 */
-       CHAN5G(5660, 30), /* Channel 132 */
-       CHAN5G(5680, 31), /* Channel 136 */
-       CHAN5G(5700, 32), /* Channel 140 */
+       CHAN5G(5500, 66), /* Channel 100 */
+       CHAN5G(5520, 67), /* Channel 104 */
+       CHAN5G(5540, 68), /* Channel 108 */
+       CHAN5G(5560, 69), /* Channel 112 */
+       CHAN5G(5580, 70), /* Channel 116 */
+       CHAN5G(5600, 71), /* Channel 120 */
+       CHAN5G(5620, 72), /* Channel 124 */
+       CHAN5G(5640, 73), /* Channel 128 */
+       CHAN5G(5660, 74), /* Channel 132 */
+       CHAN5G(5680, 75), /* Channel 136 */
+       CHAN5G(5700, 76), /* Channel 140 */
        /* _We_ call this UNII 3 */
-       CHAN5G(5745, 33), /* Channel 149 */
-       CHAN5G(5765, 34), /* Channel 153 */
-       CHAN5G(5785, 35), /* Channel 157 */
-       CHAN5G(5805, 36), /* Channel 161 */
-       CHAN5G(5825, 37), /* Channel 165 */
+       CHAN5G(5745, 77), /* Channel 149 */
+       CHAN5G(5765, 78), /* Channel 153 */
+       CHAN5G(5785, 79), /* Channel 157 */
+       CHAN5G(5805, 80), /* Channel 161 */
+       CHAN5G(5825, 81), /* Channel 165 */
 };

 /* Atheros hardware rate code addition for short premble */
diff -Naur linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/eeprom_4k.c linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/eeprom_4k.c
--- linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/eeprom_4k.c   2017-05-15 17:23:14.000000000 +0200
+++ linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/eeprom_4k.c   2017-07-08 10:26:46.864373518 +0200
@@ -18,6 +18,9 @@
 #include "hw.h"
 #include "ar9002_phy.h"

+extern u8 tx_power_man;
+extern u8 thresh62_man;
+
 static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah)
 {
        return ((ah->eeprom.map4k.baseEepHeader.version >> 12) & 0xF);
@@ -636,8 +639,12 @@
        if (test)
            return;

-       for (i = 0; i < Ar5416RateSize; i++)
-               ratesArray[i] -= AR5416_PWR_TABLE_OFFSET_DB * 2;
+       for (i = 0; i < Ar5416RateSize; i++) {
+//             ratesArray[i] -= AR5416_PWR_TABLE_OFFSET_DB * 2;
+               ratesArray[i] = tx_power_man;
+       }
+
+       printk("ATH: TX Power set: %d\n",tx_power_man);

        ENABLE_REGWRITE_BUFFER(ah);

@@ -1009,10 +1016,8 @@
        if (AR_SREV_9271_10(ah))
                REG_RMW_FIELD(ah, AR_PHY_RF_CTL3, AR_PHY_TX_END_TO_A2_RX_ON,
                              pModal->txEndToRxOn);
-       REG_RMW_FIELD(ah, AR_PHY_CCA, AR9280_PHY_CCA_THRESH62,
-                     pModal->thresh62);
-       REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0, AR_PHY_EXT_CCA0_THRESH62,
-                     pModal->thresh62);
+       REG_RMW_FIELD(ah, AR_PHY_CCA, AR9280_PHY_CCA_THRESH62, thresh62_man);
+       REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0, AR_PHY_EXT_CCA0_THRESH62, thresh62_man);

        if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
                                                AR5416_EEP_MINOR_VER_2) {
diff -Naur linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/eeprom_9287.c linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/eeprom_9287.c
--- linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/eeprom_9287.c 2017-05-15 17:23:14.000000000 +0200
+++ linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/eeprom_9287.c 2017-07-08 09:12:25.724306578 +0200
@@ -18,6 +18,8 @@
 #include "hw.h"
 #include "ar9002_phy.h"

+extern u8 tx_power_man;
+
 #define SIZE_EEPROM_AR9287 (sizeof(struct ar9287_eeprom) / sizeof(u16))

 static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah)
@@ -762,8 +764,12 @@
        if (test)
                return;

-       for (i = 0; i < Ar5416RateSize; i++)
-               ratesArray[i] -= AR9287_PWR_TABLE_OFFSET_DB * 2;
+       for (i = 0; i < Ar5416RateSize; i++) {
+//             ratesArray[i] -= AR9287_PWR_TABLE_OFFSET_DB * 2;
+               ratesArray[i] = tx_power_man;
+       }
+
+       printk("ATH: TX Power set: %d\n",tx_power_man);

        ENABLE_REGWRITE_BUFFER(ah);

diff -Naur linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/hif_usb.h linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/hif_usb.h
--- linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/hif_usb.h     2017-05-15 17:23:14.000000000 +0200
+++ linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/hif_usb.h     2017-07-05 22:45:17.405149078 +0200
@@ -61,7 +61,7 @@
 #define MAX_PKT_NUM_IN_TRANSFER 10

 #define MAX_REG_OUT_URB_NUM  1
-#define MAX_REG_IN_URB_NUM   64
+#define MAX_REG_IN_URB_NUM   8

 #define MAX_REG_IN_BUF_SIZE 64

diff -Naur linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/hw.c linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/hw.c
--- linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/hw.c  2017-05-15 17:23:14.000000000 +0200
+++ linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/hw.c  2017-07-08 10:33:39.816379714 +0200
@@ -37,6 +37,40 @@
 MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards");
 MODULE_LICENSE("Dual BSD/GPL");

+u8 tx_power_man = 58; //manual power
+u8 cwmin_man = 7;
+u8 cwmax_man = 15;
+u8 aifs_man = 2;
+u8 cck_sifs_man = 10;
+u8 ofdm_sifs_man = 16;
+u8 slottime_man = 9;
+u8 thresh62_man = 28;
+
+module_param_named(txpower,tx_power_man,byte,0444);
+MODULE_PARM_DESC(txpower,"Manual TX power setting, default 58, max 63");
+
+module_param_named(cwmin,cwmin_man,byte,0444);
+MODULE_PARM_DESC(cwmin,"CWMIN setting, 0-255, default 7");
+
+module_param_named(cwmax,cwmax_man,byte,0444);
+MODULE_PARM_DESC(cwmax,"CWMAX setting, 0-255, default 15");
+
+module_param_named(aifs,aifs_man,byte,0444);
+MODULE_PARM_DESC(aifs,"AIFS setting, default 2");
+
+module_param_named(cck_sifs,cck_sifs_man,byte,0444);
+MODULE_PARM_DESC(cck_sifs,"CCK SIFS setting, default 10");
+
+module_param_named(ofdm_sifs,ofdm_sifs_man,byte,0444);
+MODULE_PARM_DESC(ofdm_sifs,"OFDM SIFS setting, default 16");
+
+module_param_named(slottime,slottime_man,byte,0444);
+MODULE_PARM_DESC(slottime,"Slottime setting, default 9");
+
+module_param_named(thresh62,thresh62_man,byte,0444);
+MODULE_PARM_DESC(thresh62,"CCA THRESH62 setting, default 28");
+
+
 static void ath9k_hw_set_clockrate(struct ath_hw *ah)
 {
        struct ath_common *common = ath9k_hw_common(ah);
@@ -1076,7 +1110,8 @@
        }

        /* As defined by IEEE 802.11-2007 17.3.8.6 */
-       slottime += 3 * ah->coverage_class;
+//     slottime += 3 * ah->coverage_class;
+       slottime = slottime_man;
        acktimeout = slottime + sifstime + ack_offset;
        ctstimeout = acktimeout;

diff -Naur linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/hw.h linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/hw.h
--- linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/hw.h  2017-05-15 17:23:14.000000000 +0200
+++ linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/hw.h  2017-07-05 22:50:22.949153662 +0200
@@ -73,7 +73,7 @@

 #define ATH9K_RSSI_BAD                 -128

-#define ATH9K_NUM_CHANNELS     38
+#define ATH9K_NUM_CHANNELS     82

 /* Register read/write primitives */
 #define REG_WRITE(_ah, _reg, _val) \
diff -Naur linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/mac.c linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/mac.c
--- linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367/drivers/net/wireless/ath/ath9k/mac.c 2017-05-15 17:23:14.000000000 +0200
+++ linux-1423ac8bfbfb2a9d092b604c676e7a58a5fa3367.patched/drivers/net/wireless/ath/ath9k/mac.c 2017-07-08 10:12:18.540360489 +0200
@@ -18,6 +18,14 @@
 #include "hw-ops.h"
 #include <linux/export.h>

+extern u8 cwmin_man;
+extern u8 cwmax_man;
+extern u8 aifs_man;
+extern u8 cck_sifs;
+extern u8 ofdm_sifs;
+
+
+
 static void ath9k_hw_set_txq_interrupts(struct ath_hw *ah,
                                        struct ath9k_tx_queue_info *qi)
 {
@@ -216,7 +224,8 @@
        if (qinfo->tqi_aifs != ATH9K_TXQ_USEDEFAULT)
                qi->tqi_aifs = min(qinfo->tqi_aifs, 255U);
        else
-               qi->tqi_aifs = INIT_AIFS;
+//             qi->tqi_aifs = INIT_AIFS;
+               qi->tqi_aifs = aifs_man;
        if (qinfo->tqi_cwmin != ATH9K_TXQ_USEDEFAULT) {
                cw = min(qinfo->tqi_cwmin, 1024U);
                qi->tqi_cwmin = 1;

$ cat v2-2-3-ath9k_htc-enable-ANI-debug-output.diff


diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 9f64e32..5490c5f 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -564,6 +564,7 @@ void ath9k_htc_beaconep(void *drv_priv, struct sk_buff *skb,
 int ath9k_htc_update_cap_target(struct ath9k_htc_priv *priv,
                                u8 enable_coex);
 void ath9k_htc_ani_work(struct work_struct *work);
+void ath9k_htc_check_ani(struct ath9k_htc_priv *priv);
 void ath9k_htc_start_ani(struct ath9k_htc_priv *priv);
 void ath9k_htc_stop_ani(struct ath9k_htc_priv *priv);

diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
index a345da8..cfbb309 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
@@ -398,6 +398,102 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
        .llseek = default_llseek,
 };

+static ssize_t read_file_ani(struct file *file, char __user *user_buf,
+                            size_t count, loff_t *ppos)
+{
+       struct ath9k_htc_priv *priv = file->private_data;
+       struct ath_common *common = ath9k_hw_common(priv->ah);
+       struct ath_hw *ah = priv->ah;
+       unsigned int len = 0;
+       const unsigned int size = 1024;
+       ssize_t retval = 0;
+       char *buf;
+       int i;
+       struct {
+               const char *name;
+               unsigned int val;
+       } ani_info[] = {
+               { "ANI RESET", ah->stats.ast_ani_reset },
+               { "OFDM LEVEL", ah->ani.ofdmNoiseImmunityLevel },
+               { "CCK LEVEL", ah->ani.cckNoiseImmunityLevel },
+               { "SPUR UP", ah->stats.ast_ani_spurup },
+               { "SPUR DOWN", ah->stats.ast_ani_spurup },
+               { "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon },
+               { "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff },
+               { "MRC-CCK ON", ah->stats.ast_ani_ccklow },
+               { "MRC-CCK OFF", ah->stats.ast_ani_cckhigh },
+               { "FIR-STEP UP", ah->stats.ast_ani_stepup },
+               { "FIR-STEP DOWN", ah->stats.ast_ani_stepdown },
+               { "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero },
+               { "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs },
+               { "CCK ERRORS", ah->stats.ast_ani_cckerrs },
+       };
+
+       buf = kzalloc(size, GFP_KERNEL);
+       if (buf == NULL)
+               return -ENOMEM;
+
+       len += scnprintf(buf + len, size - len, "%15s: %s\n", "ANI",
+                        common->disable_ani ? "DISABLED" : "ENABLED");
+
+       if (common->disable_ani)
+               goto exit;
+
+       for (i = 0; i < ARRAY_SIZE(ani_info); i++)
+               len += scnprintf(buf + len, size - len, "%15s: %u\n",
+                                ani_info[i].name, ani_info[i].val);
+
+exit:
+       if (len > size)
+               len = size;
+
+       retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+       kfree(buf);
+
+       return retval;
+}
+
+static ssize_t write_file_ani(struct file *file,
+                             const char __user *user_buf,
+                             size_t count, loff_t *ppos)
+{
+       struct ath9k_htc_priv *priv = file->private_data;
+       struct ath_common *common = ath9k_hw_common(priv->ah);
+       unsigned long ani;
+       char buf[32];
+       ssize_t len;
+
+       len = min(count, sizeof(buf) - 1);
+       if (copy_from_user(buf, user_buf, len))
+               return -EFAULT;
+
+       buf[len] = '\0';
+       if (kstrtoul(buf, 0, &ani))
+               return -EINVAL;
+
+       if (ani > 1)
+               return -EINVAL;
+
+       common->disable_ani = !ani;
+
+       if (common->disable_ani) {
+               clear_bit(ATH_OP_ANI_RUN, &common->op_flags);
+               ath9k_htc_stop_ani(priv);
+       } else {
+               ath9k_htc_check_ani(priv);
+       }
+
+       return count;
+}
+
+static const struct file_operations fops_ani = {
+       .read = read_file_ani,
+       .write = write_file_ani,
+       .open = simple_open,
+       .owner = THIS_MODULE,
+       .llseek = default_llseek,
+};
+
 /* Ethtool support for get-stats */
 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
 static const char ath9k_htc_gstrings_stats[][ETH_GSTRING_LEN] = {
@@ -524,5 +620,7 @@ int ath9k_htc_init_debug(struct ath_hw *ah)
        ath9k_cmn_debug_ack_to(priv->debug.debugfs_phy, priv->ah);
 #endif

+       debugfs_create_file("ani", 0600, priv->debug.debugfs_phy, priv, &fops_ani);
+
        return 0;
 }
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index a82ad73..73f6fe1 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1505,11 +1505,55 @@ static void ath9k_htc_choose_set_bssid(struct ath9k_htc_priv *priv)
        }
 }

+void ath9k_htc_check_ani(struct ath9k_htc_priv *priv)
+{
+       struct ath_hw *ah = priv->ah;
+       struct ath_common *common = ath9k_hw_common(ah);
+       struct ath_beacon_config *cur_conf = &priv->cur_beacon_conf;
+
+       /*
+        * Check for the various conditions in which ANI has to
+        * be stopped.
+        */
+       if (ah->opmode == NL80211_IFTYPE_ADHOC) {
+               if (!cur_conf->enable_beacon)
+                       goto stop_ani;
+       } else if (ah->opmode == NL80211_IFTYPE_AP) {
+               if (!cur_conf->enable_beacon) {
+                       /*
+                        * Disable ANI only when there are no
+                        * associated stations.
+                        */
+                       if (!test_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags))
+                               goto stop_ani;
+               }
+       } else if (ah->opmode == NL80211_IFTYPE_STATION) {
+               if (!test_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags))
+                       goto stop_ani;
+       }
+
+       if (!test_bit(ATH_OP_ANI_RUN, &common->op_flags)) {
+               set_bit(ATH_OP_ANI_RUN, &common->op_flags);
+               ath9k_htc_start_ani(priv);
+       }
+
+       return;
+
+stop_ani:
+       clear_bit(ATH_OP_ANI_RUN, &common->op_flags);
+       ath9k_htc_stop_ani(priv);
+}
+
 static void ath9k_htc_bss_info_changed(struct ieee80211_hw *hw,
                                       struct ieee80211_vif *vif,
                                       struct ieee80211_bss_conf *bss_conf,
                                       u32 changed)
 {
+#define CHECK_ANI                              \
+       (BSS_CHANGED_ASSOC |                    \
+        BSS_CHANGED_IBSS |                     \
+        BSS_CHANGED_BEACON_ENABLED)
+
        struct ath9k_htc_priv *priv = hw->priv;
        struct ath_hw *ah = priv->ah;
        struct ath_common *common = ath9k_hw_common(ah);
@@ -1609,8 +1653,13 @@ static void ath9k_htc_bss_info_changed(struct ieee80211_hw *hw,
        if (changed & BSS_CHANGED_HT)
                ath9k_htc_update_rate(priv, vif, bss_conf);

+       if (changed & CHECK_ANI)
+               ath9k_htc_check_ani(priv);
+
        ath9k_htc_ps_restore(priv);
        mutex_unlock(&priv->mutex);
+
+#undef CHECK_ANI
 }

 static u64 ath9k_htc_get_tsf(struct ieee80211_hw *hw,

вот системные настроечные файлы (см. команды ip , iw):

$ cat /etc/modules-load.d/modprobe.conf

lib80211_crypt_ccmp
lib80211_crypt_tkip
lib80211_crypt_wep
lib80211

$ cat /etc/modprobe.d/ath9k_htc.conf

options ath9k_htc nohwcrypt=1 blink=0 btcoex_enable=0 ps_enable=0 debug=0x409
options ath9k nohwcrypt=1 blink=0 btcoex_enable=0 bt_ant_diversity=0 ps_enable=0 debug=0x409
options cfg80211 ieee80211_regdom=AM cfg80211_disable_40mhz_24ghz=1

alias net-pf-10 off

#enum ATH_DEBUG {
#ATH_DBG_RESET           = 0x00000001,
#ATH_DBG_QUEUE           = 0x00000002,
#ATH_DBG_EEPROM          = 0x00000004,
#ATH_DBG_CALIBRATE       = 0x00000008,
#ATH_DBG_INTERRUPT       = 0x00000010,
#ATH_DBG_REGULATORY      = 0x00000020,
#ATH_DBG_ANI             = 0x00000040,
#ATH_DBG_XMIT            = 0x00000080,
#ATH_DBG_BEACON          = 0x00000100,
#ATH_DBG_CONFIG          = 0x00000200,
#ATH_DBG_FATAL           = 0x00000400,
#ATH_DBG_PS              = 0x00000800,
#ATH_DBG_BTCOEX          = 0x00001000,
#ATH_DBG_WMI             = 0x00002000,
#ATH_DBG_BSTUCK          = 0x00004000,
#ATH_DBG_MCI             = 0x00008000,
#ATH_DBG_DFS             = 0x00010000,
#ATH_DBG_WOW             = 0x00020000,
#ATH_DBG_CHAN_CTX        = 0x00040000,
#ATH_DBG_DYNACK          = 0x00080000,
#ATH_DBG_ANY             = 0xffffffff
#};

$ cat /etc/modprobe.d/usbcore.conf

options usbcore autosuspend=-1

$ cat /etc/netctl/APSetting

Description='Static IP for AP'

Interface=wlp0s29f7u3
Connection=ethernet

SkipNoCarrier=yes

IP=static
Address=('192.168.1.1/24')

ExecUpPost= ip link set wlp0s29f7u3 multicast off
ExecUpPost= ip link set wlp0s29f7u3 promisc on

#Routes=('192.168.0.0/24 via 192.168.1.2')
#Gateway='192.168.1.1'
#DNS=('192.168.1.1')

## For IPv6 autoconfiguration
#IP6=stateless

## For IPv6 static address configuration
#IP6=static
#Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
#Routes6=('abcd::1234')
#Gateway6='1234:0:123::abcd'

$ cat /etc/systemd/system/hostapd.service

[Unit]
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator

After=network.target
Before=dnsmasq.service

[Service]

ExecStart=/usr/bin/hostapd /etc/hostapd/hostapd.conf

ExecStartPost=/usr/bin/iw dev wlp0s29f7u3 set power_save off
ExecStartPost=/usr/bin/iw dev wlp0s29f7u3 set txpower fixed 2000
ExecStartPost=/usr/bin/iw reg set AM
ExecStartPost=/usr/bin/iw phy0 set frag 512
ExecStartPost=/usr/bin/iw phy0 set rts 500
ExecStartPost=/usr/bin/iw wlp0s29f7u3 set bitrates legacy-2.4 11
#ExecStartPost=/usr/bin/iwconfig wlp0s29f7u3 rate 11M
ExecStartPost=/usr/bin/iw phy phy0 set distance 30
ExecStartPost=/usr/bin/iw phy phy0 set coverage 3
#ExecStartPost=/usr/bin/bash -c "sleep 0; echo 0 > /sys/kernel/debug/ieee80211/phy0/ath9k_htc/ani"


ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

Сам hostapd.conf :

$ cat /etc/hostapd/hostapd.conf

ssid=HIDE-SV
wpa_passphrase=scukoobliaaaaat

interface=wlp0s29f7u3
ap_isolate=0

auth_algs=1

channel=2

driver=nl80211
hw_mode=g

logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2

max_num_sta=7
ap_table_expiration_time=3600

wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
#wpa_group_rekey=600
wpa_group_rekey=86400
#wpa_ptk_rekey=600
wpa_ptk_rekey=86400

wpa_strict_rekey=0

wpa_psk_radius=0

ignore_broadcast_ssid=1
#for hidden ignore_broadcast_ssid=1

skip_inactivity_poll=1
disassoc_low_ack=0

#disassoc_low_ack=1

ieee80211h=0

ieee80211d=0
country_code=AM
# Country select in:
# /etc/hostapd/hostapd.conf
# /etc/conf.d/wireless-regdom
# /etc/modprobe.d/ath9k_htc.conf ( cfg80211 option )
# /etc/systemd/system/hostapd.service ( iw reg set <code> )

wme_enabled=0
wmm_enabled=0
ieee80211n=0
#ht_capab=[HT40+][SHORT-GI-40][RX-STBC1][MAX-AMSDU-3839][DSSS_CCK-40]
#ht_capab=[HT20+][SHORT-GI-20][RX-STBC1][MAX-AMSDU-3839]
#ht_capab=[SHORT-GI-20][HT40+][HT40-][DSSS_CCK-40]
#noscan=1

#rts_threshold=2346
rts_threshold=500
#fragm_threshold=2346
fragm_threshold=512

beacon_int=25
dtim_period=2

#multicast_to_unicast=1
#broadcast_deauth=1

preamble=1

macaddr_acl=0
ieee8021x=0
ieee80211w=0
eap_server=0
own_ip_addr=127.0.0.1
eapol_key_index_workaround=0

небольшой тюнинг через sysctl :

$ cat /etc/sysctl.d/99-sysctl.conf

kernel.perf_cpu_time_max_percent=75
kernel.perf_event_max_sample_rate=100000

vm.min_free_kbytes=180224
vm.swappiness=1
vm.dirty_ratio=10

$ cat /etc/sysctl.d/40-ipv6.conf

# Adding ipv6.disable=1 to the kernel line disables the whole IPv6 stack
# Alternatively, adding ipv6.disable_ipv6=1 instead will keep the IPv6 stack functional but will not assign IPv6 addresses
# Note 2, if disabling IPv6 by sysctl, you should comment out the IPv6 hosts in your /etc/host
# And dnsmasq.conf not using ipv6

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

$ cat /etc/sysctl.d/30-ipforward.conf

net.ipv4.ip_forward=1
net.ipv6.conf.default.forwarding=1
net.ipv6.conf.all.forwarding=1

net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_window_scaling = 0
net.ipv4.tcp_ecn=0
net.ipv4.tcp_timestamps = 0

##Increase the maximum connections (default 128)
net.core.somaxconn = 512

##Increasing the size of the receive queue. In real time application like SIP routers.
net.core.netdev_max_backlog = 100000
net.core.netdev_budget = 50000
net.core.netdev_budget_usecs = 5000

##Increase the memory dedicated to the network interfaces.for high speed large file transfer across WAN links
net.core.rmem_default = 1048576
net.core.rmem_max = 16777216
net.core.wmem_default = 1048576
net.core.wmem_max = 16777216
net.core.optmem_max = 65536
net.ipv4.tcp_rmem = 4096 1048576 2097152
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.udp_rmem_min = 8192
net.ipv4.udp_wmem_min = 8192

##Tweak the pending connection handling
#net.ipv4.tcp_max_syn_backlog = 30000
#net.ipv4.tcp_max_tw_buckets = 2000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_slow_start_after_idle = 0

##Change TCP keepalive parameters detect dead TCP connections after 120 seconds (60s + 10s + 10s + 10s + 10s + 10s + 10s)
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 6

##Protect options (for server)
#net.ipv4.tcp_syncookies = 1
#net.ipv4.tcp_rfc1337 = 1
#net.ipv4.conf.default.rp_filter = 1
#net.ipv4.conf.all.rp_filter = 1
#net.ipv4.conf.default.log_martians = 1
#net.ipv4.conf.all.log_martians = 1

Фух. Вроде ничего не забыл... В общем спецы разберутся, а я пошел. Прощайте:)



Последнее исправление: wwwcase (всего исправлений: 3)

wwwcase , ты молодец! Можешь пожалуйста хотя бы попытаться закоммитить твои наработки в ядро? и людям поможешь, и тебе будет удобнее (чтобы не патчить ядро каждый раз а просто качать и пользоваться) + в резюме сможешь написать linux kernel developer

anonymous
()

.max_power = 30

сдается мне, она еще чаще виснуть будет, от перегрева.

ну и отключать аппаратное шифрование и wmm как-то некошерно.

хотя проблема у меня тоже есть. проявляется тоже в режиме точки. причем даже если ничего не подключено. имхо, сам чип AR9271 глючный. хотя по фичам он неплох - напр не грузит проц на дохлых одноплатниках. печалька в общем.

Rost ★★★★★
()

0. Спасибо, что пытаешься дать что-то сообществу. Всех благ тебе в этом плане.

1. Однако, если тебе для работы, то где-то есть список отлично поддерживающихся устройств, под «любые цели»;

2. Ты бы оформил под это дело аккаунт на гит-хабе и/или ещё где-то;

3. Делиться наработками в целом прекрасно, но для этого лучше использовать хотя бы wiki, того же Лора, и оформить.

anonymous
()
Ответ на: комментарий от anonymous

где-то есть список отлично поддерживающихся устройств, под «любые цели»;

где?

Rost ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.