d33bc589b17d425b321491a8efd4e216d8f934ff
[openwrt/openwrt.git] / package / madwifi / patches / 305-pureg_fix.patch
1 Index: madwifi-dfs-r2996/ath/if_ath.c
2 ===================================================================
3 --- madwifi-dfs-r2996.orig/ath/if_ath.c 2007-12-01 18:54:22.276777879 +0100
4 +++ madwifi-dfs-r2996/ath/if_ath.c 2007-12-01 18:54:45.982128761 +0100
5 @@ -3998,7 +3998,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) || ((sc->sc_nvaps > 0) && (sc->sc_nibssvaps > 0)))
15 rfilt |= (HAL_RX_FILTER_CONTROL | HAL_RX_FILTER_BEACON |
16 Index: madwifi-dfs-r2996/net80211/ieee80211_input.c
17 ===================================================================
18 --- madwifi-dfs-r2996.orig/net80211/ieee80211_input.c 2007-12-01 18:53:44.638633004 +0100
19 +++ madwifi-dfs-r2996/net80211/ieee80211_input.c 2007-12-01 18:54:45.986128992 +0100
20 @@ -329,11 +329,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_bss->ni_bssid) &&
29 - !IEEE80211_ADDR_EQ(bssid, dev->broadcast)) {
30 + !IEEE80211_ADDR_EQ(bssid, dev->broadcast) &&
31 + (subtype != IEEE80211_FC0_SUBTYPE_BEACON)) {
32 /*
33 * allow MGT frames to vap->iv_xrvap.
34 * this will allow roaming between XR and normal vaps
35 @@ -352,7 +353,8 @@
36 }
37 #else
38 if (!IEEE80211_ADDR_EQ(bssid, vap->iv_bss->ni_bssid) &&
39 - !IEEE80211_ADDR_EQ(bssid, dev->broadcast)) {
40 + !IEEE80211_ADDR_EQ(bssid, dev->broadcast) &&
41 + (subtype != IEEE80211_FC0_SUBTYPE_BEACON)) {
42 /* not interested in */
43 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
44 bssid, NULL, "%s", "not to bss");
45 @@ -2971,7 +2973,7 @@
46 u_int8_t *frm, *efrm;
47 u_int8_t *ssid, *rates, *xrates, *suppchan, *wpa, *rsn, *wme, *ath;
48 u_int8_t rate;
49 - int reassoc, resp, allocbs = 0;
50 + int reassoc, resp, allocbs = 0, has_erp = 0;
51 u_int8_t qosinfo;
52
53 if (ni_or_null == NULL)
54 @@ -2996,11 +2998,15 @@
55 * o station mode when associated (to collect state
56 * updates such as 802.11g slot time), or
57 * o adhoc mode (to discover neighbors)
58 + * o ap mode in protection mode (beacons only)
59 * Frames otherwise received are discarded.
60 */
61 if (!((ic->ic_flags & IEEE80211_F_SCAN) ||
62 (vap->iv_opmode == IEEE80211_M_STA && ni->ni_associd) ||
63 - vap->iv_opmode == IEEE80211_M_IBSS)) {
64 + (vap->iv_opmode == IEEE80211_M_IBSS) ||
65 + ((subtype == IEEE80211_FC0_SUBTYPE_BEACON) &&
66 + (vap->iv_opmode == IEEE80211_M_HOSTAP) &&
67 + (ic->ic_protmode != IEEE80211_PROT_NONE)))) {
68 vap->iv_stats.is_rx_mgtdiscard++;
69 return;
70 }
71 @@ -3083,6 +3089,7 @@
72 break;
73 }
74 scan.erp = frm[2];
75 + has_erp = 1;
76 break;
77 case IEEE80211_ELEMID_RSN:
78 scan.rsn = frm;
79 @@ -3300,6 +3307,20 @@
80 ieee80211_bg_scan(vap);
81 return;
82 }
83 +
84 + /* Update AP protection mode when in 11G mode */
85 + if ((vap->iv_opmode == IEEE80211_M_HOSTAP) &&
86 + IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
87 +
88 + /* Assume no ERP IE == 11b AP */
89 + if ((!has_erp || (has_erp && (scan.erp & IEEE80211_ERP_NON_ERP_PRESENT))) &&
90 + !(ic->ic_flags & IEEE80211_F_USEPROT)) {
91 +
92 + ic->ic_flags |= IEEE80211_F_USEPROT;
93 + ic->ic_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
94 + }
95 + }
96 +
97 /*
98 * If scanning, just pass information to the scan module.
99 */
100 Index: madwifi-dfs-r2996/net80211/ieee80211_node.c
101 ===================================================================
102 --- madwifi-dfs-r2996.orig/net80211/ieee80211_node.c 2007-12-01 18:47:16.968540943 +0100
103 +++ madwifi-dfs-r2996/net80211/ieee80211_node.c 2007-12-01 18:54:45.998129686 +0100
104 @@ -380,10 +380,16 @@
105 /* Update country ie information */
106 ieee80211_build_countryie(ic);
107
108 - if (IEEE80211_IS_CHAN_HALF(chan))
109 + if (IEEE80211_IS_CHAN_HALF(chan)) {
110 ni->ni_rates = ic->ic_sup_half_rates;
111 - else if (IEEE80211_IS_CHAN_QUARTER(chan))
112 + } else if (IEEE80211_IS_CHAN_QUARTER(chan)) {
113 ni->ni_rates = ic->ic_sup_quarter_rates;
114 + }
115 +
116 + if ((vap->iv_flags & IEEE80211_F_PUREG) &&
117 + IEEE80211_IS_CHAN_ANYG(chan)) {
118 + ieee80211_setpuregbasicrates(&ni->ni_rates);
119 + }
120
121 (void) ieee80211_sta_join1(PASS_NODE(ni));
122 }
123 Index: madwifi-dfs-r2996/net80211/ieee80211_proto.c
124 ===================================================================
125 --- madwifi-dfs-r2996.orig/net80211/ieee80211_proto.c 2007-12-01 18:45:14.000000000 +0100
126 +++ madwifi-dfs-r2996/net80211/ieee80211_proto.c 2007-12-01 18:54:46.002129908 +0100
127 @@ -586,6 +586,28 @@
128 { 4, { 2, 4, 11, 22 } }, /* IEEE80211_MODE_TURBO_G (mixed b/g) */
129 };
130
131 +static const struct ieee80211_rateset basicpureg[] = {
132 + { 7, {2, 4, 11, 22, 12, 24, 48 } },
133 +};
134 +
135 +/*
136 + * Mark basic rates for the 11g rate table based on the pureg setting
137 + */
138 +void
139 +ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs)
140 +{
141 + int i, j;
142 +
143 + for (i = 0; i < rs->rs_nrates; i++) {
144 + rs->rs_rates[i] &= IEEE80211_RATE_VAL;
145 + for (j = 0; j < basicpureg[0].rs_nrates; j++)
146 + if (basicpureg[0].rs_rates[j] == rs->rs_rates[i]) {
147 + rs->rs_rates[i] |= IEEE80211_RATE_BASIC;
148 + break;
149 + }
150 + }
151 +}
152 +
153 /*
154 * Mark the basic rates for the 11g rate table based on the
155 * specified mode. For 11b compatibility we mark only 11b
156 Index: madwifi-dfs-r2996/net80211/ieee80211_var.h
157 ===================================================================
158 --- madwifi-dfs-r2996.orig/net80211/ieee80211_var.h 2007-12-01 18:45:14.000000000 +0100
159 +++ madwifi-dfs-r2996/net80211/ieee80211_var.h 2007-12-01 18:55:00.502956262 +0100
160 @@ -668,6 +668,7 @@
161 void ieee80211_build_sc_ie(struct ieee80211com *);
162 void ieee80211_dfs_action(struct ieee80211com *);
163 void ieee80211_expire_channel_non_occupancy_restrictions(struct ieee80211com *);
164 +void ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs);
165
166 /*
167 * Iterate through ic_channels to enumerate all distinct ic_ieee channel numbers.