madwifi: put an upper limit on the amount of sampling that minstrel should do when
[openwrt/svn-archive/archive.git] / package / madwifi / patches / 346-protmode_trig.patch
1 Index: madwifi-trunk-r3314/net80211/ieee80211.c
2 ===================================================================
3 --- madwifi-trunk-r3314.orig/net80211/ieee80211.c 2008-04-21 05:22:20.000000000 +0200
4 +++ madwifi-trunk-r3314/net80211/ieee80211.c 2008-04-21 05:23:46.000000000 +0200
5 @@ -333,7 +333,9 @@
6 IEEE80211_MS_TO_TU(IEEE80211_BMISSTHRESH_DEFAULT_MS),
7 ic->ic_lintval), ic->ic_lintval);
8 }
9 -
10 + ic->ic_protmode_timeout = IEEE80211_PROTMODE_TIMEOUT;
11 + ic->ic_protmode_rssi = IEEE80211_PROTMODE_RSSITHR;
12 +
13 IEEE80211_LOCK_INIT(ic, "ieee80211com");
14 IEEE80211_VAPS_LOCK_INIT(ic, "ieee80211com_vaps");
15 TAILQ_INIT(&ic->ic_vaps);
16 Index: madwifi-trunk-r3314/net80211/ieee80211_input.c
17 ===================================================================
18 --- madwifi-trunk-r3314.orig/net80211/ieee80211_input.c 2008-04-21 05:22:32.000000000 +0200
19 +++ madwifi-trunk-r3314/net80211/ieee80211_input.c 2008-04-21 05:23:46.000000000 +0200
20 @@ -3412,16 +3412,32 @@
21 IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
22
23 /* Assume no ERP IE == 11b AP */
24 - if ((!has_erp || (has_erp && (scan.erp & IEEE80211_ERP_NON_ERP_PRESENT))) &&
25 - !(ic->ic_flags & IEEE80211_F_USEPROT)) {
26 + if ((!has_erp || (has_erp &&
27 + (scan.erp & IEEE80211_ERP_NON_ERP_PRESENT))) &&
28 + (rssi > ic->ic_protmode_rssi)) {
29 struct ieee80211vap *tmpvap;
30
31 - ic->ic_flags |= IEEE80211_F_USEPROT;
32 - TAILQ_FOREACH(tmpvap, &ic->ic_vaps, iv_next) {
33 - tmpvap->iv_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
34 + if (!(ic->ic_flags & IEEE80211_F_USEPROT)) {
35 + ic->ic_flags |= IEEE80211_F_USEPROT;
36 + TAILQ_FOREACH(tmpvap, &ic->ic_vaps, iv_next) {
37 + tmpvap->iv_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
38 + }
39 }
40 + ic->ic_protmode_lasttrig = jiffies;
41 }
42 }
43 + if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
44 + (ic->ic_protmode_lasttrig + ic->ic_protmode_timeout * HZ <
45 + jiffies)) {
46 + struct ieee80211vap *tmpvap;
47 +
48 + /* expire protection mode */
49 + ic->ic_flags &= ~IEEE80211_F_USEPROT;
50 + TAILQ_FOREACH(tmpvap, &ic->ic_vaps, iv_next) {
51 + tmpvap->iv_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
52 + }
53 + }
54 +
55
56 /*
57 * If scanning, just pass information to the scan module.
58 Index: madwifi-trunk-r3314/net80211/ieee80211_ioctl.h
59 ===================================================================
60 --- madwifi-trunk-r3314.orig/net80211/ieee80211_ioctl.h 2008-04-21 05:22:20.000000000 +0200
61 +++ madwifi-trunk-r3314/net80211/ieee80211_ioctl.h 2008-04-21 05:23:46.000000000 +0200
62 @@ -643,6 +643,8 @@
63 IEEE80211_PARAM_BEACON_MISS_THRESH_MS = 74, /* Beacon miss threshold (in ms) */
64 IEEE80211_PARAM_MAXRATE = 75, /* Maximum rate (by table index) */
65 IEEE80211_PARAM_MINRATE = 76, /* Maximum rate (by table index) */
66 + IEEE80211_PARAM_PROTMODE_RSSI = 77, /* RSSI Threshold for enabling protection mode */
67 + IEEE80211_PARAM_PROTMODE_TIMEOUT = 78, /* Timeout for expiring protection mode */
68 };
69
70 #define SIOCG80211STATS (SIOCDEVPRIVATE+2)
71 Index: madwifi-trunk-r3314/net80211/ieee80211_var.h
72 ===================================================================
73 --- madwifi-trunk-r3314.orig/net80211/ieee80211_var.h 2008-04-21 05:22:20.000000000 +0200
74 +++ madwifi-trunk-r3314/net80211/ieee80211_var.h 2008-04-21 05:41:45.000000000 +0200
75 @@ -128,6 +128,9 @@
76
77 #define IEEE80211_APPIE_MAX 1024
78
79 +#define IEEE80211_PROTMODE_RSSITHR 15 /* default rssi threshold for protection mode trigger */
80 +#define IEEE80211_PROTMODE_TIMEOUT 30 /* timeout for keeping protection mode alive */
81 +
82 #define IEEE80211_PWRCONSTRAINT_VAL(ic) \
83 (((ic)->ic_bsschan->ic_maxregpower > (ic)->ic_curchanmaxpwr) ? \
84 (ic)->ic_bsschan->ic_maxregpower - (ic)->ic_curchanmaxpwr : 0)
85 @@ -324,6 +327,9 @@
86 u_int16_t ic_newtxpowlimit; /* tx power limit to change to (in 0.5 dBm) */
87 u_int16_t ic_uapsdmaxtriggers; /* max triggers that could arrive */
88 u_int8_t ic_coverageclass; /* coverage class */
89 + u_int8_t ic_protmode_rssi; /* rssi threshold for protection mode */
90 + u_int64_t ic_protmode_lasttrig; /* last trigger for protection mode */
91 + u_int16_t ic_protmode_timeout; /* protection mode timeout */
92
93 /* Channel state:
94 *
95 Index: madwifi-trunk-r3314/net80211/ieee80211_wireless.c
96 ===================================================================
97 --- madwifi-trunk-r3314.orig/net80211/ieee80211_wireless.c 2008-04-21 05:22:20.000000000 +0200
98 +++ madwifi-trunk-r3314/net80211/ieee80211_wireless.c 2008-04-21 05:23:46.000000000 +0200
99 @@ -2312,6 +2312,12 @@
100 IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan))
101 retv = ENETRESET;
102 break;
103 + case IEEE80211_PARAM_PROTMODE_TIMEOUT:
104 + ic->ic_protmode_timeout = value;
105 + break;
106 + case IEEE80211_PARAM_PROTMODE_RSSI:
107 + ic->ic_protmode_rssi = value;
108 + break;
109 case IEEE80211_PARAM_MCASTCIPHER:
110 if ((vap->iv_caps & cipher2cap(value)) == 0 &&
111 !ieee80211_crypto_available(vap, value))
112 @@ -2955,6 +2961,12 @@
113 case IEEE80211_PARAM_PROTMODE:
114 param[0] = ic->ic_protmode;
115 break;
116 + case IEEE80211_PARAM_PROTMODE_TIMEOUT:
117 + param[0] = ic->ic_protmode_timeout;
118 + break;
119 + case IEEE80211_PARAM_PROTMODE_RSSI:
120 + param[0] = ic->ic_protmode_rssi;
121 + break;
122 case IEEE80211_PARAM_MCASTCIPHER:
123 param[0] = rsn->rsn_mcastcipher;
124 break;
125 @@ -5346,6 +5358,14 @@
126 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "protmode" },
127 { IEEE80211_PARAM_PROTMODE,
128 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_protmode" },
129 + { IEEE80211_PARAM_PROTMODE_RSSI,
130 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "protrssi" },
131 + { IEEE80211_PARAM_PROTMODE_RSSI,
132 + 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_protrssi" },
133 + { IEEE80211_PARAM_PROTMODE_TIMEOUT,
134 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "prottime" },
135 + { IEEE80211_PARAM_PROTMODE_TIMEOUT,
136 + 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_prottime" },
137 { IEEE80211_PARAM_MCASTCIPHER,
138 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "mcastcipher" },
139 { IEEE80211_PARAM_MCASTCIPHER,