madwifi: don't poll the channel noise in a performance critical path
[openwrt.git] / package / madwifi / patches / 121-ibss_hostap.patch
1 Index: madwifi-ng-r2756-20071018/ath/if_ath.c
2 ===================================================================
3 --- madwifi-ng-r2756-20071018.orig/ath/if_ath.c 2007-10-24 06:20:18.881765287 +0200
4 +++ madwifi-ng-r2756-20071018/ath/if_ath.c 2007-10-24 06:20:19.097777599 +0200
5 @@ -409,7 +409,6 @@
6 * and use the next two bits as the index of the VAP.
7 */
8 #define ATH_SET_VAP_BSSID_MASK(bssid_mask) ((bssid_mask)[0] &= ~(((ATH_BCBUF-1)<<2)|0x02))
9 -#define ATH_GET_VAP_ID(bssid) ((bssid)[0] >> 2)
10 #define ATH_SET_VAP_BSSID(bssid, id) \
11 do { \
12 if (id) \
13 @@ -1059,9 +1058,12 @@
14 ic_opmode = opmode;
15 break;
16 case IEEE80211_M_IBSS:
17 - if (sc->sc_nvaps != 0) /* only one */
18 - return NULL;
19 - ic_opmode = opmode;
20 + if (sc->sc_nvaps == 0) /* only one */
21 + ic_opmode = opmode;
22 + else
23 + ic_opmode = IEEE80211_M_HOSTAP;
24 +
25 + sc->sc_nibssvaps++;
26 break;
27 case IEEE80211_M_AHDEMO:
28 case IEEE80211_M_MONITOR:
29 @@ -1091,7 +1093,7 @@
30 return NULL;
31 }
32
33 - if (sc->sc_nvaps >= ATH_BCBUF) {
34 + if (sc->sc_nvaps + sc->sc_nibssvaps >= ATH_BCBUF) {
35 printk(KERN_WARNING "too many virtual APs (already got %d)\n", sc->sc_nvaps);
36 return NULL;
37 }
38 @@ -1127,6 +1129,7 @@
39 if (opmode == IEEE80211_M_MONITOR)
40 dev->type = ARPHRD_IEEE80211_RADIOTAP;
41
42 + avp->av_bslot = -1;
43 if ((flags & IEEE80211_CLONE_BSSID) &&
44 opmode != IEEE80211_M_WDS && sc->sc_hasbmask) {
45 struct ieee80211vap *v;
46 @@ -1141,18 +1144,22 @@
47
48 /* do a full search to mark all the allocated VAPs */
49 id_mask = 0;
50 - TAILQ_FOREACH(v, &ic->ic_vaps, iv_next)
51 - id_mask |= (1 << ATH_GET_VAP_ID(v->iv_myaddr));
52 + TAILQ_FOREACH(v, &ic->ic_vaps, iv_next) {
53 + struct ath_vap *a = (struct ath_vap *) v->iv_dev->priv;
54 + if (a->av_bslot >= 0)
55 + id_mask |= (1 << a->av_bslot);
56 + }
57
58 - for (id = 1; id < ATH_BCBUF; id++) {
59 + /* IBSS mode has local always set, so don't hand out beacon slot 0 to an IBSS vap */
60 + for (id = (opmode == IEEE80211_M_IBSS ? 1 : 0); id < ATH_BCBUF; id++) {
61 /* get the first available slot */
62 if ((id_mask & (1 << id)) == 0) {
63 ATH_SET_VAP_BSSID(vap->iv_myaddr, id);
64 + avp->av_bslot = id;
65 break;
66 }
67 }
68 }
69 - avp->av_bslot = -1;
70 STAILQ_INIT(&avp->av_mcastq.axq_q);
71 ATH_TXQ_LOCK_INIT(&avp->av_mcastq);
72 if (opmode == IEEE80211_M_HOSTAP || opmode == IEEE80211_M_IBSS) {
73 @@ -1162,33 +1169,14 @@
74 */
75 avp->av_bcbuf = STAILQ_FIRST(&sc->sc_bbuf);
76 STAILQ_REMOVE_HEAD(&sc->sc_bbuf, bf_list);
77 - if (opmode == IEEE80211_M_HOSTAP || !sc->sc_hasveol) {
78 + if ((opmode == IEEE80211_M_IBSS) || (opmode == IEEE80211_M_HOSTAP) || !sc->sc_hasveol) {
79 unsigned int slot;
80 - /*
81 - * Assign the VAP to a beacon xmit slot. As
82 - * above, this cannot fail to find one.
83 - */
84 - avp->av_bslot = 0;
85 - for (slot = 0; slot < ATH_BCBUF; slot++)
86 - if (sc->sc_bslot[slot] == NULL) {
87 - /*
88 - * XXX hack, space out slots to better
89 - * deal with misses
90 - */
91 - if (slot + 1 < ATH_BCBUF &&
92 - sc->sc_bslot[slot+1] == NULL) {
93 - avp->av_bslot = slot + 1;
94 - break;
95 - }
96 - avp->av_bslot = slot;
97 - /* NB: keep looking for a double slot */
98 - }
99 KASSERT(sc->sc_bslot[avp->av_bslot] == NULL,
100 ("beacon slot %u not empty?", avp->av_bslot));
101 sc->sc_bslot[avp->av_bslot] = vap;
102 sc->sc_nbcnvaps++;
103 }
104 - if ((opmode == IEEE80211_M_HOSTAP) && (sc->sc_hastsfadd)) {
105 + if ((sc->sc_opmode == IEEE80211_M_HOSTAP) && (sc->sc_hastsfadd)) {
106 /*
107 * Multiple VAPs are to transmit beacons and we
108 * have h/w support for TSF adjusting; enable use
109 @@ -1298,7 +1286,9 @@
110 sc->sc_stagbeacons = 0;
111 }
112
113 - if (vap->iv_opmode == IEEE80211_M_STA) {
114 + if (vap->iv_opmode == IEEE80211_M_IBSS) {
115 + sc->sc_nibssvaps--;
116 + } else if (vap->iv_opmode == IEEE80211_M_STA) {
117 sc->sc_nstavaps--;
118 sc->sc_nostabeacons = 0;
119 } else if (vap->iv_opmode == IEEE80211_M_MONITOR)
120 @@ -3517,7 +3507,7 @@
121 sc->sc_opmode == HAL_M_IBSS || /* NB: AHDEMO too */
122 (sc->sc_nostabeacons) || sc->sc_scanning)
123 rfilt |= HAL_RX_FILTER_BEACON;
124 - if (sc->sc_nmonvaps > 0)
125 + if ((sc->sc_nmonvaps > 0) || ((sc->sc_nvaps > 0) && (sc->sc_nibssvaps > 0)))
126 rfilt |= (HAL_RX_FILTER_CONTROL | HAL_RX_FILTER_BEACON |
127 HAL_RX_FILTER_PROBEREQ | HAL_RX_FILTER_PROM);
128 return rfilt;
129 @@ -5953,12 +5943,20 @@
130 type = ieee80211_input(ni, skb, rs->rs_rssi, rs_tsf);
131 ieee80211_unref_node(&ni);
132 } else {
133 + const struct ieee80211_frame_min *wh = (const struct ieee80211_frame_min *) skb->data;
134 /*
135 * No key index or no entry, do a lookup and
136 * add the node to the mapping table if possible.
137 */
138 - ni = ieee80211_find_rxnode(ic,
139 - (const struct ieee80211_frame_min *) skb->data);
140 + if (((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_PROBE_REQ) &&
141 + (sc->sc_nibssvaps > 0))
142 + /* if this is a probe request, send it to all vaps
143 + * when looking up nodes, hostap will be preferred over ibss,
144 + * because ibss will catch all nodes */
145 + ni = NULL;
146 + else
147 + ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) skb->data);
148 +
149 if (ni != NULL) {
150 struct ath_node *an = ATH_NODE(ni);
151 ieee80211_keyix_t keyix;
152 Index: madwifi-ng-r2756-20071018/ath/if_athvar.h
153 ===================================================================
154 --- madwifi-ng-r2756-20071018.orig/ath/if_athvar.h 2007-10-24 06:20:16.501629651 +0200
155 +++ madwifi-ng-r2756-20071018/ath/if_athvar.h 2007-10-24 06:20:19.101777824 +0200
156 @@ -209,7 +209,7 @@
157 #define ATH_RXBUF 40 /* number of RX buffers */
158 #define ATH_TXBUF 200 /* number of TX buffers */
159
160 -#define ATH_BCBUF 4 /* number of beacon buffers */
161 +#define ATH_BCBUF 8 /* number of beacon buffers */
162
163 /* free buffer threshold to restart net dev */
164 #define ATH_TXBUF_FREE_THRESHOLD (ATH_TXBUF / 20)
165 @@ -610,6 +610,7 @@
166 u_int16_t sc_nvaps; /* # of active virtual APs */
167 u_int8_t sc_nstavaps; /* # of active station VAPs */
168 u_int8_t sc_nmonvaps; /* # of monitor VAPs */
169 + u_int8_t sc_nibssvaps; /* # of active ibss vaps */
170 u_int8_t sc_nbcnvaps; /* # of vaps sending beacons */
171 u_int sc_fftxqmin; /* aggregation threshold */
172 HAL_INT sc_imask; /* interrupt mask copy */
173 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_beacon.c
174 ===================================================================
175 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_beacon.c 2007-10-24 06:20:16.505629880 +0200
176 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_beacon.c 2007-10-24 06:20:19.109778282 +0200
177 @@ -111,7 +111,7 @@
178 bo->bo_tim = frm;
179
180 /* IBSS/TIM */
181 - if (vap->iv_opmode == IEEE80211_M_IBSS) {
182 + if (ic->ic_opmode == IEEE80211_M_IBSS) {
183 *frm++ = IEEE80211_ELEMID_IBSSPARMS;
184 *frm++ = 2;
185 *frm++ = 0; *frm++ = 0; /* TODO: ATIM window */
186 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_input.c
187 ===================================================================
188 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_input.c 2007-10-24 06:20:16.513630337 +0200
189 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_input.c 2007-10-24 06:20:19.113778513 +0200
190 @@ -2990,7 +2990,13 @@
191 return;
192 }
193 if (ni == vap->iv_bss) {
194 - if (vap->iv_opmode == IEEE80211_M_IBSS) {
195 + /* this probe request may have been sent to all vaps
196 + * to give each a chance of creating a node for this.
197 + * important for hostap+ibss mode */
198 + ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) skb->data);
199 + if (ni) {
200 + allocbs = 0;
201 + } else if (vap->iv_opmode == IEEE80211_M_IBSS) {
202 /*
203 * XXX Cannot tell if the sender is operating
204 * in ibss mode. But we need a new node to
205 @@ -2999,12 +3005,13 @@
206 */
207 ni = ieee80211_fakeup_adhoc_node(vap,
208 wh->i_addr2);
209 + allocbs = 1;
210 } else {
211 ni = ieee80211_dup_bss(vap, wh->i_addr2, 1);
212 + allocbs = 1;
213 }
214 if (ni == NULL)
215 return;
216 - allocbs = 1;
217 }
218
219 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_INPUT, wh->i_addr2,
220 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_node.c
221 ===================================================================
222 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_node.c 2007-10-24 06:20:18.437739986 +0200
223 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_node.c 2007-10-24 06:20:19.113778513 +0200
224 @@ -1084,8 +1084,25 @@
225 IEEE80211_NODE_TABLE_LOCK_ASSERT(nt);
226
227 hash = IEEE80211_NODE_HASH(macaddr);
228 +
229 + /* look for non-ibss nodes first */
230 + LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
231 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) && ni->ni_vap->iv_opmode != IEEE80211_M_IBSS) {
232 + ieee80211_ref_node(ni); /* mark referenced */
233 +#ifdef IEEE80211_DEBUG_REFCNT
234 + IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,
235 + "%s (%s:%u) %p<%s> refcnt %d\n", __func__,
236 + func, line,
237 + ni, ether_sprintf(ni->ni_macaddr),
238 + ieee80211_node_refcnt(ni));
239 +#endif
240 + return ni;
241 + }
242 + }
243 +
244 + /* now look for ibss nodes */
245 LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
246 - if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) {
247 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) && ni->ni_vap->iv_opmode == IEEE80211_M_IBSS) {
248 ieee80211_ref_node(ni); /* mark referenced */
249 #ifdef IEEE80211_DEBUG_REFCNT
250 IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,
This page took 0.054564 seconds and 5 git commands to generate.