update to the latest madwifi snapshot
[openwrt.git] / package / madwifi / patches / 305-pureg_fix.patch
1 Index: madwifi-ng-r2525-20070630/ath/if_ath.c
2 ===================================================================
3 --- madwifi-ng-r2525-20070630.orig/ath/if_ath.c 2007-07-03 23:02:33.302125000 +0200
4 +++ madwifi-ng-r2525-20070630/ath/if_ath.c      2007-07-03 23:02:33.594143250 +0200
5 @@ -3392,7 +3392,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-ng-r2525-20070630/net80211/ieee80211_input.c
17 ===================================================================
18 --- madwifi-ng-r2525-20070630.orig/net80211/ieee80211_input.c   2007-07-03 23:02:33.002106250 +0200
19 +++ madwifi-ng-r2525-20070630/net80211/ieee80211_input.c        2007-07-03 23:02:33.598143500 +0200
20 @@ -321,11 +321,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 @@ -344,7 +345,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 @@ -2541,7 +2543,7 @@
46         u_int8_t *frm, *efrm;
47         u_int8_t *ssid, *rates, *xrates, *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         wh = (struct ieee80211_frame *) skb->data;
54 @@ -2563,11 +2565,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 @@ -2650,6 +2656,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 @@ -2867,6 +2874,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-ng-r2525-20070630/net80211/ieee80211_node.c
101 ===================================================================
102 --- madwifi-ng-r2525-20070630.orig/net80211/ieee80211_node.c    2007-07-03 23:02:31.037983500 +0200
103 +++ madwifi-ng-r2525-20070630/net80211/ieee80211_node.c 2007-07-03 23:02:33.598143500 +0200
104 @@ -332,10 +332,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-ng-r2525-20070630/net80211/ieee80211_proto.c
124 ===================================================================
125 --- madwifi-ng-r2525-20070630.orig/net80211/ieee80211_proto.c   2007-07-03 23:02:32.306062750 +0200
126 +++ madwifi-ng-r2525-20070630/net80211/ieee80211_proto.c        2007-07-03 23:02:33.630145500 +0200
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-ng-r2525-20070630/net80211/ieee80211_var.h
157 ===================================================================
158 --- madwifi-ng-r2525-20070630.orig/net80211/ieee80211_var.h     2007-07-03 23:02:32.330064250 +0200
159 +++ madwifi-ng-r2525-20070630/net80211/ieee80211_var.h  2007-07-03 23:02:33.678148500 +0200
160 @@ -592,6 +592,8 @@
161  void ieee80211_build_countryie(struct ieee80211com *);
162  int ieee80211_media_setup(struct ieee80211com *, struct ifmedia *, u_int32_t,
163         ifm_change_cb_t, ifm_stat_cb_t);
164 +void ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs);
165 +
166  
167  /* Key update synchronization methods.  XXX should not be visible. */
168  static __inline void