update madwifi to latest trunk - performance enhancements
[openwrt.git] / package / madwifi / patches / 305-pureg_fix.patch
1 diff -urN madwifi-ng-r2377-20070526.old/ath/if_ath.c madwifi-ng-r2377-20070526.dev/ath/if_ath.c
2 --- madwifi-ng-r2377-20070526.old/ath/if_ath.c  2007-05-26 18:51:09.426654472 +0200
3 +++ madwifi-ng-r2377-20070526.dev/ath/if_ath.c  2007-05-26 18:51:09.440652344 +0200
4 @@ -3383,7 +3383,9 @@
5                 rfilt |= HAL_RX_FILTER_PROM;
6         if (ic->ic_opmode == IEEE80211_M_STA ||
7             sc->sc_opmode == HAL_M_IBSS ||      /* NB: AHDEMO too */
8 -           (sc->sc_nostabeacons) || sc->sc_scanning)
9 +           (sc->sc_nostabeacons) || sc->sc_scanning ||
10 +               ((ic->ic_opmode == IEEE80211_M_HOSTAP) &&
11 +                (ic->ic_protmode != IEEE80211_PROT_NONE)))
12                 rfilt |= HAL_RX_FILTER_BEACON;
13         if (sc->sc_nmonvaps > 0) 
14                 rfilt |= (HAL_RX_FILTER_CONTROL | HAL_RX_FILTER_BEACON | 
15 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_input.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_input.c
16 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_input.c    2007-05-26 18:51:09.429654016 +0200
17 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_input.c    2007-05-26 18:51:09.443651888 +0200
18 @@ -343,11 +343,12 @@
19                                 bssid = wh->i_addr3;
20                         }
21                         /*
22 -                        * Validate the bssid.
23 +                        * Validate the bssid. Let beacons get through though for 11g protection mode.
24                          */
25  #ifdef ATH_SUPERG_XR
26                         if (!IEEE80211_ADDR_EQ(bssid, vap->iv_bss->ni_bssid) &&
27 -                           !IEEE80211_ADDR_EQ(bssid, dev->broadcast)) {
28 +                           !IEEE80211_ADDR_EQ(bssid, dev->broadcast) &&
29 +                               (subtype != IEEE80211_FC0_SUBTYPE_BEACON)) {
30                                 /*
31                                  * allow MGT frames to vap->iv_xrvap.
32                                  * this will allow roaming between  XR and normal vaps
33 @@ -366,7 +367,8 @@
34                         }
35  #else
36                         if (!IEEE80211_ADDR_EQ(bssid, vap->iv_bss->ni_bssid) &&
37 -                           !IEEE80211_ADDR_EQ(bssid, dev->broadcast)) {
38 +                           !IEEE80211_ADDR_EQ(bssid, dev->broadcast) &&
39 +                               (subtype != IEEE80211_FC0_SUBTYPE_BEACON)) {
40                                 /* not interested in */
41                                 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
42                                         bssid, NULL, "%s", "not to bss");
43 @@ -2593,7 +2595,7 @@
44         u_int8_t *frm, *efrm;
45         u_int8_t *ssid, *rates, *xrates, *wpa, *rsn, *wme, *ath;
46         u_int8_t rate;
47 -       int reassoc, resp, allocbs = 0;
48 +       int reassoc, resp, allocbs = 0, has_erp = 0;
49         u_int8_t qosinfo;
50  
51         wh = (struct ieee80211_frame *) skb->data;
52 @@ -2615,11 +2617,15 @@
53                  *    o station mode when associated (to collect state
54                  *      updates such as 802.11g slot time), or
55                  *    o adhoc mode (to discover neighbors)
56 +                *    o ap mode in protection mode (beacons only)
57                  * Frames otherwise received are discarded.
58                  */ 
59                 if (!((ic->ic_flags & IEEE80211_F_SCAN) ||
60                     (vap->iv_opmode == IEEE80211_M_STA && ni->ni_associd) ||
61 -                   vap->iv_opmode == IEEE80211_M_IBSS)) {
62 +                   (vap->iv_opmode == IEEE80211_M_IBSS) ||
63 +                       ((subtype == IEEE80211_FC0_SUBTYPE_BEACON) &&
64 +                        (vap->iv_opmode == IEEE80211_M_HOSTAP) &&
65 +                        (ic->ic_protmode != IEEE80211_PROT_NONE)))) {
66                         vap->iv_stats.is_rx_mgtdiscard++;
67                         return;
68                 }
69 @@ -2702,6 +2708,7 @@
70                                         break;
71                                 }
72                                 scan.erp = frm[2];
73 +                               has_erp = 1;
74                                 break;
75                         case IEEE80211_ELEMID_RSN:
76                                 scan.rsn = frm;
77 @@ -2855,7 +2862,7 @@
78                             vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) {
79                                 mod_timer(&vap->iv_swbmiss, jiffies + vap->iv_swbmiss_period);
80                         }
81 -                       
82 +
83                         /*
84                          * If scanning, pass the info to the scan module.
85                          * Otherwise, check if it's the right time to do
86 @@ -2877,6 +2884,20 @@
87                                 ieee80211_bg_scan(vap);
88                         return;
89                 }
90 +
91 +               /* Update AP protection mode when in 11G mode */
92 +               if ((vap->iv_opmode == IEEE80211_M_HOSTAP) &&
93 +                       IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
94 +                               
95 +                       /* Assume no ERP IE == 11b AP */
96 +                       if ((!has_erp || (has_erp && (scan.erp & IEEE80211_ERP_NON_ERP_PRESENT))) &&
97 +                               !(ic->ic_flags & IEEE80211_F_USEPROT)) {
98 +                               
99 +                               ic->ic_flags |= IEEE80211_F_USEPROT;
100 +                               ic->ic_flags_ext |= IEEE80211_FEXT_ERPUPDATE;
101 +                       }
102 +               }
103 +
104                 /*
105                  * If scanning, just pass information to the scan module.
106                  */
107 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_node.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_node.c
108 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_node.c     2007-05-26 18:51:09.430653864 +0200
109 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_node.c     2007-05-26 18:51:09.444651736 +0200
110 @@ -332,10 +332,16 @@
111         /* Update country ie information */
112         ieee80211_build_countryie(ic);
113  
114 -       if (IEEE80211_IS_CHAN_HALF(chan))
115 +       if (IEEE80211_IS_CHAN_HALF(chan)) {
116                 ni->ni_rates = ic->ic_sup_half_rates;
117 -       else if (IEEE80211_IS_CHAN_QUARTER(chan))
118 +       } else if (IEEE80211_IS_CHAN_QUARTER(chan)) {
119                 ni->ni_rates = ic->ic_sup_quarter_rates;
120 +       }
121 +
122 +       if ((vap->iv_flags & IEEE80211_F_PUREG) &&
123 +               IEEE80211_IS_CHAN_ANYG(chan)) {
124 +               ieee80211_setpuregbasicrates(&ni->ni_rates); 
125 +       }
126  
127         (void) ieee80211_sta_join1(PASS_NODE(ni));
128  }
129 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_proto.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_proto.c
130 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_proto.c    2007-05-26 18:51:09.431653712 +0200
131 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_proto.c    2007-05-26 18:51:09.445651584 +0200
132 @@ -586,6 +586,28 @@
133      { 4, { 2, 4, 11, 22 } },   /* IEEE80211_MODE_TURBO_G (mixed b/g) */
134  };
135  
136 +static const struct ieee80211_rateset basicpureg[] = {
137 +    { 7, {2, 4, 11, 22, 12, 24, 48 } },
138 +};
139 +
140 +/*
141 + * Mark basic rates for the 11g rate table based on the pureg setting
142 + */
143 +void
144 +ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs)
145 +{
146 +       int i, j;
147 +
148 +       for (i = 0; i < rs->rs_nrates; i++) {
149 +               rs->rs_rates[i] &= IEEE80211_RATE_VAL;
150 +               for (j = 0; j < basicpureg[0].rs_nrates; j++)
151 +                       if (basicpureg[0].rs_rates[j] == rs->rs_rates[i]) {
152 +                               rs->rs_rates[i] |= IEEE80211_RATE_BASIC;
153 +                               break;
154 +                       }
155 +       }
156 +}
157 +
158  /*
159   * Mark the basic rates for the 11g rate table based on the
160   * specified mode.  For 11b compatibility we mark only 11b
161 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_var.h madwifi-ng-r2377-20070526.dev/net80211/ieee80211_var.h
162 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_var.h      2007-05-26 18:51:09.321670432 +0200
163 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_var.h      2007-05-26 18:51:09.445651584 +0200
164 @@ -584,6 +584,8 @@
165  void ieee80211_build_countryie(struct ieee80211com *);
166  int ieee80211_media_setup(struct ieee80211com *, struct ifmedia *, u_int32_t,
167         ifm_change_cb_t, ifm_stat_cb_t);
168 +void ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs);
169 +               
170  
171  /* Key update synchronization methods.  XXX should not be visible. */
172  static __inline void