Root/package/mac80211/patches/541-ath9k_nf_validate.patch

1--- a/drivers/net/wireless/ath/ath9k/calib.c
2+++ b/drivers/net/wireless/ath/ath9k/calib.c
3@@ -19,8 +19,7 @@
4 
5 /* Common calibration code */
6 
7-/* We can tune this as we go by monitoring really low values */
8-#define ATH9K_NF_TOO_LOW -60
9+#define ATH9K_NF_TOO_HIGH -60
10 
11 static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)
12 {
13@@ -45,11 +44,35 @@ static int16_t ath9k_hw_get_nf_hist_mid(
14     return nfval;
15 }
16 
17-static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h,
18+static struct ath_nf_limits *ath9k_hw_get_nf_limits(struct ath_hw *ah,
19+ struct ath9k_channel *chan)
20+{
21+ struct ath_nf_limits *limit;
22+
23+ if (!chan || IS_CHAN_2GHZ(chan))
24+ limit = &ah->nf_2g;
25+ else
26+ limit = &ah->nf_5g;
27+
28+ return limit;
29+}
30+
31+static s16 ath9k_hw_get_default_nf(struct ath_hw *ah,
32+ struct ath9k_channel *chan)
33+{
34+ return ath9k_hw_get_nf_limits(ah, chan)->nominal;
35+}
36+
37+
38+static void ath9k_hw_update_nfcal_hist_buffer(struct ath_hw *ah,
39+ struct ath9k_nfcal_hist *h,
40                           int16_t *nfarray)
41 {
42+ struct ath_nf_limits *limit;
43     int i;
44 
45+ limit = ath9k_hw_get_nf_limits(ah, ah->curchan);
46+
47     for (i = 0; i < NUM_NF_READINGS; i++) {
48         h[i].nfCalBuffer[h[i].currIndex] = nfarray[i];
49 
50@@ -63,6 +86,9 @@ static void ath9k_hw_update_nfcal_hist_b
51             h[i].privNF =
52                 ath9k_hw_get_nf_hist_mid(h[i].nfCalBuffer);
53         }
54+
55+ if (h[i].privNF > limit->max)
56+ h[i].privNF = limit->max;
57     }
58 }
59 
60@@ -104,19 +130,6 @@ void ath9k_hw_reset_calibration(struct a
61     ah->cal_samples = 0;
62 }
63 
64-static s16 ath9k_hw_get_default_nf(struct ath_hw *ah,
65- struct ath9k_channel *chan)
66-{
67- struct ath_nf_limits *limit;
68-
69- if (!chan || IS_CHAN_2GHZ(chan))
70- limit = &ah->nf_2g;
71- else
72- limit = &ah->nf_5g;
73-
74- return limit->nominal;
75-}
76-
77 /* This is done for the currently configured channel */
78 bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
79 {
80@@ -277,10 +290,10 @@ static void ath9k_hw_nf_sanitize(struct
81               "NF calibrated [%s] [chain %d] is %d\n",
82               (i >= 3 ? "ext" : "ctl"), i % 3, nf[i]);
83 
84- if (nf[i] > limit->max) {
85+ if (nf[i] > ATH9K_NF_TOO_HIGH) {
86             ath_print(common, ATH_DBG_CALIBRATE,
87                   "NF[%d] (%d) > MAX (%d), correcting to MAX",
88- i, nf[i], limit->max);
89+ i, nf[i], ATH9K_NF_TOO_HIGH);
90             nf[i] = limit->max;
91         } else if (nf[i] < limit->min) {
92             ath_print(common, ATH_DBG_CALIBRATE,
93@@ -326,7 +339,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, s
94 
95     h = caldata->nfCalHist;
96     caldata->nfcal_pending = false;
97- ath9k_hw_update_nfcal_hist_buffer(h, nfarray);
98+ ath9k_hw_update_nfcal_hist_buffer(ah, h, nfarray);
99     caldata->rawNoiseFloor = h[0].privNF;
100     return true;
101 }
102

Archive Download this file



interactive