upgrade madwifi, finally fix the annoying ap auto channel selection bug, default...
[openwrt/svn-archive/archive.git] / package / madwifi / patches / 305-pureg_fix.patch
1 Index: madwifi-dfs-r3246/ath/if_ath.c
2 ===================================================================
3 --- madwifi-dfs-r3246.orig/ath/if_ath.c 2008-01-25 16:30:04.921659489 +0100
4 +++ madwifi-dfs-r3246/ath/if_ath.c 2008-01-25 16:33:11.528293596 +0100
5 @@ -4086,7 +4086,9 @@
6 rfilt |= HAL_RX_FILTER_PROM;
7 if (ic->ic_opmode == IEEE80211_M_STA ||
8 sc->sc_opmode == HAL_M_IBSS || /* NB: AHDEMO too */
9 - (sc->sc_nostabeacons) || sc->sc_scanning)
10 + (sc->sc_nostabeacons) || sc->sc_scanning ||
11 + ((ic->ic_opmode == IEEE80211_M_HOSTAP) &&
12 + (ic->ic_protmode != IEEE80211_PROT_NONE)))
13 rfilt |= HAL_RX_FILTER_BEACON;
14 if (sc->sc_nmonvaps > 0)
15 rfilt |= (HAL_RX_FILTER_CONTROL | HAL_RX_FILTER_BEACON |
16 Index: madwifi-dfs-r3246/net80211/ieee80211_input.c
17 ===================================================================
18 --- madwifi-dfs-r3246.orig/net80211/ieee80211_input.c 2008-01-25 16:32:53.171247487 +0100
19 +++ madwifi-dfs-r3246/net80211/ieee80211_input.c 2008-01-25 16:35:46.341115878 +0100
20 @@ -346,11 +346,12 @@
21 bssid = wh->i_addr3;
22 }
23 /*
24 - * Validate the bssid.
25 + * Validate the bssid. Let beacons get through though for 11g protection mode.
26 */
27 -#ifdef ATH_SUPERG_XR
28 if (!IEEE80211_ADDR_EQ(bssid, vap->iv_bssid) &&
29 - !IEEE80211_ADDR_EQ(bssid, dev->broadcast)) {
30 + !IEEE80211_ADDR_EQ(bssid, dev->broadcast) &&
31 + (subtype != IEEE80211_FC0_SUBTYPE_BEACON)) {
32 +#ifdef ATH_SUPERG_XR
33 /*
34 * allow MGT frames to vap->iv_xrvap.
35 * this will allow roaming between XR and normal vaps
36 @@ -366,18 +367,14 @@
37 vap->iv_stats.is_rx_wrongbss++;
38 goto out;
39 }
40 - }
41 #else
42 - if (!IEEE80211_ADDR_EQ(bssid, vap->iv_bssid) &&
43 - !IEEE80211_ADDR_EQ(bssid, dev->broadcast)) {
44 /* not interested in */
45 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
46 bssid, NULL, "%s", "not to bss");
47 vap->iv_stats.is_rx_wrongbss++;
48 goto out;
49 - }
50 -
51 #endif
52 + }
53 break;
54 case IEEE80211_M_WDS:
55 if (skb->len < sizeof(struct ieee80211_frame_addr4)) {
56 @@ -3023,7 +3020,7 @@
57 u_int8_t *frm, *efrm;
58 u_int8_t *ssid, *rates, *xrates, *suppchan, *wpa, *rsn, *wme, *ath;
59 u_int8_t rate;
60 - int reassoc, resp, allocbs = 0;
61 + int reassoc, resp, allocbs = 0, has_erp = 0;
62 u_int8_t qosinfo;
63
64 if (ni_or_null == NULL)
65 @@ -3053,11 +3050,15 @@
66 * o station mode when associated (to collect state
67 * updates such as 802.11g slot time), or
68 * o adhoc mode (to discover neighbors)
69 + * o ap mode in protection mode (beacons only)
70 * Frames otherwise received are discarded.
71 */
72 if (!((ic->ic_flags & IEEE80211_F_SCAN) ||
73 (vap->iv_opmode == IEEE80211_M_STA && ni->ni_associd) ||
74 - vap->iv_opmode == IEEE80211_M_IBSS)) {
75 + (vap->iv_opmode == IEEE80211_M_IBSS) ||
76 + ((subtype == IEEE80211_FC0_SUBTYPE_BEACON) &&
77 + (vap->iv_opmode == IEEE80211_M_HOSTAP) &&
78 + (ic->ic_protmode != IEEE80211_PROT_NONE)))) {
79 vap->iv_stats.is_rx_mgtdiscard++;
80 return;
81 }
82 @@ -3140,6 +3141,7 @@
83 break;
84 }
85 scan.erp = frm[2];
86 + has_erp = 1;
87 break;
88 case IEEE80211_ELEMID_RSN:
89 scan.rsn = frm;
90 @@ -3357,6 +3359,20 @@
91 ieee80211_bg_scan(vap);
92 return;
93 }
94 +
95 + /* Update AP protection mode when in 11G mode */
96 + if ((vap->iv_opmode == IEEE80211_M_HOSTAP) &&
97 + IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
98 +
99 + /* Assume no ERP IE == 11b AP */
100 + if ((!has_erp || (has_erp && (scan.erp & IEEE80211_ERP_NON_ERP_PRESENT))) &&
101 + !(ic->ic_flags & IEEE80211_F_USEPROT)) {
102 +
103 + ic->ic_flags |= IEEE80211_F_USEPROT;
104 + ic->ic_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
105 + }
106 + }
107 +
108 /*
109 * If scanning, just pass information to the scan module.
110 */
111 Index: madwifi-dfs-r3246/net80211/ieee80211_node.c
112 ===================================================================
113 --- madwifi-dfs-r3246.orig/net80211/ieee80211_node.c 2008-01-25 16:27:28.000000000 +0100
114 +++ madwifi-dfs-r3246/net80211/ieee80211_node.c 2008-01-25 16:33:11.540294282 +0100
115 @@ -383,10 +383,16 @@
116 /* Update country ie information */
117 ieee80211_build_countryie(ic);
118
119 - if (IEEE80211_IS_CHAN_HALF(chan))
120 + if (IEEE80211_IS_CHAN_HALF(chan)) {
121 ni->ni_rates = ic->ic_sup_half_rates;
122 - else if (IEEE80211_IS_CHAN_QUARTER(chan))
123 + } else if (IEEE80211_IS_CHAN_QUARTER(chan)) {
124 ni->ni_rates = ic->ic_sup_quarter_rates;
125 + }
126 +
127 + if ((vap->iv_flags & IEEE80211_F_PUREG) &&
128 + IEEE80211_IS_CHAN_ANYG(chan)) {
129 + ieee80211_setpuregbasicrates(&ni->ni_rates);
130 + }
131
132 (void) ieee80211_sta_join1(PASS_NODE(ni));
133 }
134 Index: madwifi-dfs-r3246/net80211/ieee80211_proto.c
135 ===================================================================
136 --- madwifi-dfs-r3246.orig/net80211/ieee80211_proto.c 2008-01-25 16:27:28.000000000 +0100
137 +++ madwifi-dfs-r3246/net80211/ieee80211_proto.c 2008-01-25 16:33:11.544294507 +0100
138 @@ -595,6 +595,28 @@
139 { 4, { 2, 4, 11, 22 } }, /* IEEE80211_MODE_TURBO_G (mixed b/g) */
140 };
141
142 +static const struct ieee80211_rateset basicpureg[] = {
143 + { 7, {2, 4, 11, 22, 12, 24, 48 } },
144 +};
145 +
146 +/*
147 + * Mark basic rates for the 11g rate table based on the pureg setting
148 + */
149 +void
150 +ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs)
151 +{
152 + int i, j;
153 +
154 + for (i = 0; i < rs->rs_nrates; i++) {
155 + rs->rs_rates[i] &= IEEE80211_RATE_VAL;
156 + for (j = 0; j < basicpureg[0].rs_nrates; j++)
157 + if (basicpureg[0].rs_rates[j] == rs->rs_rates[i]) {
158 + rs->rs_rates[i] |= IEEE80211_RATE_BASIC;
159 + break;
160 + }
161 + }
162 +}
163 +
164 /*
165 * Mark the basic rates for the 11g rate table based on the
166 * specified mode. For 11b compatibility we mark only 11b
167 Index: madwifi-dfs-r3246/net80211/ieee80211_var.h
168 ===================================================================
169 --- madwifi-dfs-r3246.orig/net80211/ieee80211_var.h 2008-01-25 16:27:28.000000000 +0100
170 +++ madwifi-dfs-r3246/net80211/ieee80211_var.h 2008-01-25 16:33:11.548294736 +0100
171 @@ -688,6 +688,7 @@
172 void ieee80211_build_sc_ie(struct ieee80211com *);
173 void ieee80211_dfs_action(struct ieee80211com *);
174 void ieee80211_expire_channel_non_occupancy_restrictions(struct ieee80211com *);
175 +void ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs);
176
177 /*
178 * Iterate through ic_channels to enumerate all distinct ic_ieee channel numbers.