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