package/madwifi: mark as broken for linux 3.1
[openwrt.git] / package / madwifi / patches / 424-timing.patch
1 --- a/ath/if_ath.c
2 +++ b/ath/if_ath.c
3 @@ -382,6 +382,7 @@ static u_int32_t ath_set_clamped_maxtxpo
4 static void ath_poll_disable(struct net_device *dev);
5 static void ath_poll_enable(struct net_device *dev);
6 static void ath_fetch_idle_time(struct ath_softc *sc);
7 +static void ath_set_timing(struct ath_softc *sc);
8
9 /* calibrate every 30 secs in steady state but check every second at first. */
10 static int ath_calinterval = ATH_SHORT_CALINTERVAL;
11 @@ -1185,6 +1186,7 @@ ath_attach(u_int16_t devid, struct net_d
12 sc->sc_intmit = -1;
13 sc->sc_noise_immunity = -1;
14 sc->sc_ofdm_weak_det = -1;
15 + sc->sc_coverage = 7; /* 2100 meters */
16
17 return 0;
18 bad3:
19 @@ -2673,6 +2675,7 @@ ath_init(struct net_device *dev)
20 */
21 ath_chan_change(sc, ic->ic_curchan);
22 ath_set_ack_bitrate(sc, sc->sc_ackrate);
23 + ath_set_timing(sc);
24 dev->flags |= IFF_RUNNING; /* we are ready to go */
25 ieee80211_start_running(ic); /* start all VAPs */
26 #ifdef ATH_TX99_DIAG
27 @@ -4484,17 +4487,52 @@ ath_mode_init(struct net_device *dev)
28 * Set the slot time based on the current setting.
29 */
30 static void
31 -ath_settiming(struct ath_softc *sc)
32 +ath_set_timing(struct ath_softc *sc)
33 {
34 + struct ieee80211com *ic = &sc->sc_ic;
35 struct ath_hal *ah = sc->sc_ah;
36 - u_int offset = getTimingOffset(sc);
37 + struct ath_timings *t = &sc->sc_timings;
38 + u_int offset = 9;
39 +
40 + t->sifs = 16;
41 + if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
42 + offset = 20;
43 + if (ic->ic_flags & IEEE80211_F_SHSLOT)
44 + offset = 9;
45 + } else if (IEEE80211_IS_CHAN_A(ic->ic_curchan)) {
46 + offset = 9;
47 + }
48 +
49 + if (IEEE80211_IS_CHAN_TURBO(ic->ic_curchan)) {
50 + offset = 6;
51 + t->sifs = 8;
52 + } else if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan)) {
53 + offset = 13;
54 + t->sifs = 32;
55 + } else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan)) {
56 + offset = 21;
57 + t->sifs = 64;
58 + }
59 +
60 + t->slot = offset + sc->sc_coverage;
61 + t->ack = t->slot * 2 + 3;
62 + t->cts = t->slot * 2 + 3;
63
64 if (sc->sc_slottimeconf > 0)
65 - ath_hal_setslottime(ah, offset + sc->sc_slottimeconf);
66 + t->slot = sc->sc_slottimeconf;
67 if (sc->sc_acktimeconf > 0)
68 - ath_hal_setacktimeout(ah, 2 * offset + sc->sc_acktimeconf);
69 + t->ack = sc->sc_acktimeconf;
70 if (sc->sc_ctstimeconf > 0)
71 - ath_hal_setctstimeout(ah, 2 * offset + sc->sc_ctstimeconf);
72 + t->cts = sc->sc_ctstimeconf;
73 +
74 + t->difs = 2 * t->sifs + t->slot;
75 + t->eifs = t->sifs + t->difs + 3;
76 +
77 + ath_hal_setslottime(ah, t->slot);
78 + ath_hal_setacktimeout(ah, t->ack);
79 + ath_hal_setctstimeout(ah, t->cts);
80 + ath_hal_seteifstime(ah, t->eifs);
81 +
82 sc->sc_updateslot = OK;
83 }
84
85 @@ -4516,7 +4554,7 @@ ath_updateslot(struct net_device *dev)
86 if (ic->ic_opmode == IEEE80211_M_HOSTAP)
87 sc->sc_updateslot = UPDATE;
88 else if (dev->flags & IFF_RUNNING)
89 - ath_settiming(sc);
90 + ath_set_timing(sc);
91 }
92
93 #ifdef ATH_SUPERG_DYNTURBO
94 @@ -5360,7 +5398,7 @@ ath_beacon_send(struct ath_softc *sc, in
95 sc->sc_updateslot = COMMIT; /* commit next beacon */
96 sc->sc_slotupdate = slot;
97 } else if ((sc->sc_updateslot == COMMIT) && (sc->sc_slotupdate == slot))
98 - ath_settiming(sc); /* commit change to hardware */
99 + ath_set_timing(sc); /* commit change to hardware */
100
101 if (bfaddr != 0) {
102 /*
103 @@ -9433,7 +9471,8 @@ ath_set_coverageclass(struct ieee80211co
104 {
105 struct ath_softc *sc = ic->ic_dev->priv;
106
107 - ath_hal_setcoverageclass(sc->sc_ah, ic->ic_coverageclass, 0);
108 + sc->sc_coverage = ic->ic_coverageclass * 3;
109 + ath_set_timing(sc);
110
111 return;
112 }
113 @@ -10956,6 +10995,7 @@ enum {
114 ATH_OFDM_WEAK_DET = 29,
115 ATH_CHANBW = 30,
116 ATH_OUTDOOR = 31,
117 + ATH_DISTANCE = 32,
118 };
119
120 /*
121 @@ -11168,21 +11208,31 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
122 sc->sc_slottimeconf = val;
123 else
124 sc->sc_slottimeconf = 0;
125 - ath_settiming(sc);
126 + ath_set_timing(sc);
127 break;
128 case ATH_ACKTIMEOUT:
129 if (val > 0)
130 sc->sc_acktimeconf = val;
131 else
132 sc->sc_acktimeconf = 0;
133 - ath_settiming(sc);
134 + ath_set_timing(sc);
135 break;
136 case ATH_CTSTIMEOUT:
137 if (val > 0)
138 sc->sc_ctstimeconf = val;
139 else
140 sc->sc_ctstimeconf = 0;
141 - ath_settiming(sc);
142 + ath_set_timing(sc);
143 + break;
144 + case ATH_DISTANCE:
145 + if (val > 0) {
146 + sc->sc_coverage = ((val - 1) / 300) + 1;
147 + ic->ic_coverageclass = ((sc->sc_coverage - 1) / 3) + 1;
148 + } else {
149 + sc->sc_coverage = 0;
150 + ic->ic_coverageclass = 0;
151 + }
152 + ath_set_timing(sc);
153 break;
154 case ATH_SOFTLED:
155 if (val != sc->sc_softled) {
156 @@ -11338,6 +11388,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
157 case ATH_CHANBW:
158 val = sc->sc_chanbw ?: 20;
159 break;
160 + case ATH_DISTANCE:
161 + val = sc->sc_coverage * 300;
162 + break;
163 case ATH_SLOTTIME:
164 val = ath_hal_getslottime(ah);
165 break;
166 @@ -11459,6 +11512,12 @@ static const ctl_table ath_sysctl_templa
167 .extra2 = (void *)ATH_CTSTIMEOUT,
168 },
169 { .ctl_name = CTL_AUTO,
170 + .procname = "distance",
171 + .mode = 0644,
172 + .proc_handler = ath_sysctl_halparam,
173 + .extra2 = (void *)ATH_DISTANCE,
174 + },
175 + { .ctl_name = CTL_AUTO,
176 .procname = "softled",
177 .mode = 0644,
178 .proc_handler = ath_sysctl_halparam,
179 --- a/ath/if_ath_hal.h
180 +++ b/ath/if_ath_hal.h
181 @@ -284,6 +284,17 @@ static inline u_int ath_hal_getslottime(
182 return ret;
183 }
184
185 +static inline u_int ath_hal_geteifstime(struct ath_hal *ah)
186 +{
187 + u_int ret;
188 + ATH_HAL_LOCK_IRQ(ah->ah_sc);
189 + ath_hal_set_function(__func__);
190 + ret = ah->ah_getEifsTime(ah);
191 + ath_hal_set_function(NULL);
192 + ATH_HAL_UNLOCK_IRQ(ah->ah_sc);
193 + return ret;
194 +}
195 +
196 static inline void ath_hal_beaconinit(struct ath_hal *ah, u_int32_t nexttbtt,
197 u_int32_t intval)
198 {
199 @@ -839,6 +850,17 @@ static inline HAL_BOOL ath_hal_setslotti
200 ath_hal_set_function(NULL);
201 ATH_HAL_UNLOCK_IRQ(ah->ah_sc);
202 return ret;
203 +}
204 +
205 +static inline HAL_BOOL ath_hal_seteifstime(struct ath_hal *ah, u_int a1)
206 +{
207 + HAL_BOOL ret;
208 + ATH_HAL_LOCK_IRQ(ah->ah_sc);
209 + ath_hal_set_function(__func__);
210 + ret = ah->ah_setEifsTime(ah, a1);
211 + ath_hal_set_function(NULL);
212 + ATH_HAL_UNLOCK_IRQ(ah->ah_sc);
213 + return ret;
214 }
215
216 static inline void ath_hal_setledstate(struct ath_hal *ah, HAL_LED_STATE a1)
217 --- a/ath/if_athvar.h
218 +++ b/ath/if_athvar.h
219 @@ -613,6 +613,15 @@ struct ath_rp {
220 int rp_analyzed;
221 };
222
223 +struct ath_timings {
224 + u_int slot;
225 + u_int ack;
226 + u_int cts;
227 + u_int sifs;
228 + u_int difs;
229 + u_int eifs;
230 +};
231 +
232 struct ath_softc {
233 struct ieee80211com sc_ic; /* NB: must be first */
234 struct net_device *sc_dev;
235 @@ -839,6 +848,8 @@ struct ath_softc {
236 * detected radars */
237 u_int32_t sc_nexttbtt;
238 u_int64_t sc_last_tsf;
239 + u_int sc_coverage;
240 + struct ath_timings sc_timings;
241 };
242
243 typedef void (*ath_callback) (struct ath_softc *);
244 @@ -946,49 +957,76 @@ int ar_device(int devid);
245 DEV_NAME(_v->iv_ic->ic_dev))
246
247 void ath_radar_detected(struct ath_softc *sc, const char* message);
248 -static inline u_int getTimingOffset(struct ath_softc *sc)
249 -{
250 - struct ieee80211com *ic = &sc->sc_ic;
251 - u_int usec = 9;
252 - if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
253 - usec = 20;
254 - if (ic->ic_flags & IEEE80211_F_SHSLOT)
255 - usec = 9;
256 - } else if (IEEE80211_IS_CHAN_A(ic->ic_curchan))
257 - usec = 9;
258 -
259 - if (IEEE80211_IS_CHAN_TURBO(ic->ic_curchan))
260 - usec = 6;
261 -
262 - if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan))
263 - usec = 13;
264 - else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan))
265 - usec = 21;
266 - return usec;
267 -}
268
269 -static inline void ath_get_timings(struct ath_softc *sc, u_int *t_slot, u_int *t_sifs, u_int *t_difs)
270 -{
271 - struct ieee80211_channel *c = sc->sc_ic.ic_curchan;
272 +#ifndef MIN
273 +#define MIN(a,b) ((a) < (b) ? (a) : (b))
274 +#endif
275 +#ifndef MAX
276 +#define MAX(a,b) ((a) > (b) ? (a) : (b))
277 +#endif
278
279 - *t_slot = getTimingOffset(sc) + sc->sc_slottimeconf;
280
281 - if (IEEE80211_IS_CHAN_HALF(c)) {
282 - *t_sifs = 32;
283 - *t_difs = 56;
284 - } else if (IEEE80211_IS_CHAN_QUARTER(c)) {
285 - *t_sifs = 64;
286 - *t_difs = 112;
287 - } else if (IEEE80211_IS_CHAN_TURBO(c)) {
288 - *t_sifs = 8;
289 - *t_difs = 28;
290 - } else {
291 - *t_sifs = 16;
292 - *t_difs = 28;
293 - }
294 +/* Calculate the transmit duration of a frame. */
295 +static inline unsigned
296 +calc_usecs_unicast_packet(struct ath_softc *sc, int length,
297 + int rix, int short_retries, int long_retries)
298 +{
299 + const HAL_RATE_TABLE *rt = sc->sc_currates;
300 + struct ieee80211com *ic = &sc->sc_ic;
301 + struct ath_timings *t = &sc->sc_timings;
302 + unsigned int x = 0, tt = 0;
303 + unsigned int cix = rt->info[rix].controlRate;
304 + int rts = 0, cts = 0;
305 + int cw = ATH_DEFAULT_CWMIN;
306 +
307 + KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
308 +
309 + if (!rt->info[rix].rateKbps) {
310 + printk(KERN_WARNING "rix %d (%d) bad ratekbps %d mode %u\n",
311 + rix, rt->info[rix].dot11Rate,
312 + rt->info[rix].rateKbps,
313 + sc->sc_curmode);
314 + return 0;
315 + }
316 +
317 + if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
318 + (rt->info[rix].phy == IEEE80211_T_OFDM)) {
319 +
320 + if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
321 + rts = 1;
322 + else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY)
323 + cts = 1;
324 +
325 + cix = rt->info[sc->sc_protrix].controlRate;
326 + }
327 +
328 + if ((rts || cts) && rt->info[cix].rateKbps) {
329 + int ctsrate = rt->info[cix].rateCode;
330 + int ctsduration = 0;
331 +
332 + ctsrate |= rt->info[cix].shortPreamble;
333 + if (rts) /* SIFS + CTS */
334 + ctsduration += rt->info[cix].spAckDuration;
335 +
336 + ctsduration += ath_hal_computetxtime(sc->sc_ah,
337 + rt, length, rix, AH_TRUE);
338 +
339 + if (cts) /* SIFS + ACK */
340 + ctsduration += rt->info[cix].spAckDuration;
341 +
342 + tt += (short_retries + 1) * ctsduration;
343 + }
344 + tt += t->difs;
345 + tt += (long_retries + 1) * (t->sifs + rt->info[rix].spAckDuration);
346 + tt += (long_retries + 1) * ath_hal_computetxtime(sc->sc_ah, rt, length,
347 + rix, AH_TRUE);
348 + for (x = 0; x <= short_retries + long_retries; x++) {
349 + cw = MIN(ATH_DEFAULT_CWMAX, (cw + 1) * 2);
350 + tt += (t->slot * cw / 2);
351 + }
352 + return tt;
353 }
354
355 -
356 struct ath_hw_detect {
357 const char *vendor_name;
358 const char *card_name;
359 --- a/ath_rate/minstrel/minstrel.c
360 +++ b/ath_rate/minstrel/minstrel.c
361 @@ -170,85 +170,6 @@ rate_to_ndx(struct minstrel_node *sn, in
362 return -1;
363 }
364
365 -/* Calculate the transmit duration of a frame. */
366 -static unsigned
367 -calc_usecs_unicast_packet(struct ath_softc *sc, int length,
368 - int rix, int short_retries, int long_retries)
369 -{
370 - const HAL_RATE_TABLE *rt = sc->sc_currates;
371 - struct ieee80211com *ic = &sc->sc_ic;
372 - unsigned t_slot = 20;
373 - unsigned t_difs = 50;
374 - unsigned t_sifs = 10;
375 - unsigned int x = 0, tt = 0;
376 - unsigned int cix = rt->info[rix].controlRate;
377 - int rts = 0, cts = 0;
378 - int cw = ATH_DEFAULT_CWMIN;
379 -
380 - KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
381 -
382 - if (!rt->info[rix].rateKbps) {
383 - printk(KERN_WARNING "rix %d (%d) bad ratekbps %d mode %u\n",
384 - rix, rt->info[rix].dot11Rate,
385 - rt->info[rix].rateKbps,
386 - sc->sc_curmode);
387 - return 0;
388 - }
389 -
390 - ath_get_timings(sc, &t_slot, &t_sifs, &t_difs);
391 - if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
392 - (rt->info[rix].phy == IEEE80211_T_OFDM)) {
393 - if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
394 - rts = 1;
395 - else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY)
396 - cts = 1;
397 -
398 - cix = rt->info[sc->sc_protrix].controlRate;
399 - }
400 -
401 -#if 0
402 - if (length > ic->ic_rtsthreshold)
403 - rts = 1;
404 -#endif
405 -
406 - if (rts || cts) {
407 - int ctsrate = rt->info[cix].rateCode;
408 - int ctsduration = 0;
409 -
410 - if (!rt->info[cix].rateKbps) {
411 -#if 0
412 - printk(KERN_WARNING "cix %d (%d) bad ratekbps %d mode %u\n",
413 - cix, rt->info[cix].dot11Rate,
414 - rt->info[cix].rateKbps,
415 - sc->sc_curmode);
416 -#endif
417 - return 0;
418 - }
419 -
420 -
421 - ctsrate |= rt->info[cix].shortPreamble;
422 - if (rts) /* SIFS + CTS */
423 - ctsduration += rt->info[cix].spAckDuration;
424 -
425 - ctsduration += ath_hal_computetxtime(sc->sc_ah,
426 - rt, length, rix, AH_TRUE);
427 -
428 - if (cts) /* SIFS + ACK */
429 - ctsduration += rt->info[cix].spAckDuration;
430 -
431 - tt += (short_retries + 1) * ctsduration;
432 - }
433 - tt += t_difs;
434 - tt += (long_retries + 1) * (t_sifs + rt->info[rix].spAckDuration);
435 - tt += (long_retries + 1) * ath_hal_computetxtime(sc->sc_ah, rt, length,
436 - rix, AH_TRUE);
437 - for (x = 0; x <= short_retries + long_retries; x++) {
438 - cw = MIN(ATH_DEFAULT_CWMAX, (cw + 1) * 2);
439 - tt += (t_slot * cw / 2);
440 - }
441 - return tt;
442 -}
443 -
444 static void
445 ath_rate_node_init(struct ath_softc *sc, struct ath_node *an)
446 {
447 --- a/ath_rate/sample/sample.c
448 +++ b/ath_rate/sample/sample.c
449 @@ -137,92 +137,6 @@ rate_to_ndx(struct sample_node *sn, int
450 return -1;
451 }
452
453 -/*
454 - * Calculate the transmit duration of a frame.
455 - */
456 -static unsigned
457 -calc_usecs_unicast_packet(struct ath_softc *sc, int length,
458 - int rix, int short_retries, int long_retries)
459 -{
460 - const HAL_RATE_TABLE *rt = sc->sc_currates;
461 - int rts, cts;
462 -
463 - unsigned t_slot;
464 - unsigned t_difs;
465 - unsigned t_sifs;
466 - struct ieee80211com *ic = &sc->sc_ic;
467 - unsigned int tt = 0;
468 - unsigned int x;
469 - unsigned int cw = ATH_DEFAULT_CWMIN;
470 - unsigned int cix = rt->info[rix].controlRate;
471 - KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
472 -
473 - if (!rt->info[rix].rateKbps) {
474 - printk(KERN_WARNING "rix %u (%u) bad ratekbps %u mode %u\n",
475 - rix, rt->info[rix].dot11Rate,
476 - rt->info[rix].rateKbps,
477 - sc->sc_curmode);
478 -
479 - return 0;
480 - }
481 -
482 - cix = rt->info[rix].controlRate;
483 - /*
484 - * XXX getting mac/phy level timings should be fixed for turbo
485 - * rates, and there is probably a way to get this from the
486 - * hal...
487 - */
488 - ath_get_timings(sc, &t_slot, &t_sifs, &t_difs);
489 - rts = cts = 0;
490 -
491 - if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
492 - rt->info[rix].phy == IEEE80211_T_OFDM) {
493 - if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
494 - rts = 1;
495 - else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY)
496 - cts = 1;
497 -
498 - cix = rt->info[sc->sc_protrix].controlRate;
499 - }
500 -
501 - if (0 /*length > ic->ic_rtsthreshold */)
502 - rts = 1;
503 -
504 - if (rts || cts) {
505 - int ctsrate;
506 - int ctsduration = 0;
507 -
508 - if (!rt->info[cix].rateKbps) {
509 - printk(KERN_WARNING "cix %u (%u) bad ratekbps %u mode %u\n",
510 - cix, rt->info[cix].dot11Rate,
511 - rt->info[cix].rateKbps,
512 - sc->sc_curmode);
513 - return 0;
514 - }
515 -
516 -
517 - ctsrate = rt->info[cix].rateCode | rt->info[cix].shortPreamble;
518 - if (rts) /* SIFS + CTS */
519 - ctsduration += rt->info[cix].spAckDuration;
520 -
521 - ctsduration += ath_hal_computetxtime(sc->sc_ah,
522 - rt, length, rix, AH_TRUE);
523 -
524 - if (cts) /* SIFS + ACK */
525 - ctsduration += rt->info[cix].spAckDuration;
526 -
527 - tt += (short_retries + 1) * ctsduration;
528 - }
529 - tt += t_difs;
530 - tt += (long_retries+1)*(t_sifs + rt->info[rix].spAckDuration);
531 - tt += (long_retries+1)*ath_hal_computetxtime(sc->sc_ah, rt, length,
532 - rix, AH_TRUE);
533 - for (x = 0; x <= short_retries + long_retries; x++) {
534 - cw = MIN(ATH_DEFAULT_CWMAX, (cw + 1) * 2);
535 - tt += (t_slot * cw / 2);
536 - }
537 - return tt;
538 -}
539
540 static void
541 ath_rate_node_init(struct ath_softc *sc, struct ath_node *an)
542 --- a/net80211/ieee80211_wireless.c
543 +++ b/net80211/ieee80211_wireless.c
544 @@ -2745,6 +2745,7 @@ ieee80211_ioctl_setparam(struct net_devi
545 case IEEE80211_PARAM_COVERAGE_CLASS:
546 if (value <= IEEE80211_COVERAGE_CLASS_MAX) {
547 ic->ic_coverageclass = value;
548 + ic->ic_set_coverageclass(ic);
549 if (IS_UP_AUTO(vap))
550 ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
551 retv = 0;
552 --- a/net80211/ieee80211_var.h
553 +++ b/net80211/ieee80211_var.h
554 @@ -94,7 +94,7 @@
555
556 #define IEEE80211_BGSCAN_TRIGGER_INTVL 20 /* min trigger interval for thresh based bgscan (secs) */
557
558 -#define IEEE80211_COVERAGE_CLASS_MAX 31 /* max coverage class */
559 +#define IEEE80211_COVERAGE_CLASS_MAX 255 /* max coverage class */
560 #define IEEE80211_REGCLASSIDS_MAX 10 /* max regclass id list */
561
562 #define IEEE80211_PS_SLEEP 0x1 /* STA is in power saving mode */
563 --- a/tools/Makefile
564 +++ b/tools/Makefile
565 @@ -50,7 +50,7 @@ all: compile
566
567 DEBUG = -DAR_DEBUG
568
569 -ALLPROGS= athstats 80211stats athkey athchans athctrl \
570 +ALLPROGS= athstats 80211stats athkey athchans \
571 $(if $(DEBUG),athdebug 80211debug) wlanconfig ath_info
572
573 OBJS= $(patsubst %,%.o,$(ALLPROGS))
574 --- a/tools/athctrl.c
575 +++ /dev/null
576 @@ -1,133 +0,0 @@
577 -/*-
578 - * Copyright (c) 2002-2004 Gunter Burchardt, Local-Web AG
579 - * All rights reserved.
580 - *
581 - * Redistribution and use in source and binary forms, with or without
582 - * modification, are permitted provided that the following conditions
583 - * are met:
584 - * 1. Redistributions of source code must retain the above copyright
585 - * notice, this list of conditions and the following disclaimer,
586 - * without modification.
587 - * 2. Redistributions in binary form must reproduce at minimum a disclaimer
588 - * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
589 - * redistribution must be conditioned upon including a substantially
590 - * similar Disclaimer requirement for further binary redistribution.
591 - * 3. Neither the names of the above-listed copyright holders nor the names
592 - * of any contributors may be used to endorse or promote products derived
593 - * from this software without specific prior written permission.
594 - *
595 - * Alternatively, this software may be distributed under the terms of the
596 - * GNU General Public License ("GPL") version 2 as published by the Free
597 - * Software Foundation.
598 - *
599 - * NO WARRANTY
600 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
601 - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
602 - * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
603 - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
604 - * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
605 - * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
606 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
607 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
608 - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
609 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
610 - * THE POSSIBILITY OF SUCH DAMAGES.
611 - *
612 - * $Id: athctrl.c 2394 2007-05-30 01:41:18Z mtaylor $
613 - */
614 -
615 -/*
616 - * Simple Atheros-specific tool to inspect and set atheros specific values
617 - * athctrl [-i interface] [-d distance]
618 - * (default interface is wifi0).
619 - */
620 -#include <sys/types.h>
621 -#include <sys/file.h>
622 -
623 -#include <getopt.h>
624 -
625 -#include <stdio.h>
626 -#include <string.h>
627 -#include <stdlib.h>
628 -#include <err.h>
629 -
630 -#include <net/if.h>
631 -#include "do_multi.h"
632 -
633 -static int
634 -setsysctrl(const char *dev, const char *control , u_long value)
635 -{
636 - char buffer[256];
637 - FILE * fd;
638 -
639 - snprintf(buffer, sizeof(buffer), "/proc/sys/dev/%s/%s", dev, control);
640 - fd = fopen(buffer, "w");
641 - if (fd != NULL) {
642 - fprintf(fd, "%li", value);
643 - fclose(fd);
644 - } else
645 - fprintf(stderr, "Could not open %s for writing!\n", buffer);
646 -
647 - return 0;
648 -}
649 -
650 -static void usage(void)
651 -{
652 - fprintf(stderr,
653 - "Atheros driver control\n"
654 - "Copyright (c) 2002-2004 Gunter Burchardt, Local-Web AG\n"
655 - "\n"
656 - "usage: athctrl [-i interface] [-d distance]\n"
657 - "\n"
658 - "options:\n"
659 - " -h show this usage\n"
660 - " -i interface (default interface is wifi0)\n"
661 - " -d specify the maximum distance of a sta or the distance\n"
662 - " of the master\n");
663 -
664 - exit(1);
665 -}
666 -
667 -int
668 -CMD(athctrl)(int argc, char *argv[])
669 -{
670 - char device[IFNAMSIZ + 1];
671 - int distance = -1;
672 - int c;
673 -
674 - strncpy(device, "wifi0", sizeof (device));
675 -
676 - for (;;) {
677 - c = getopt(argc, argv, "d:i:h");
678 - if (c < 0)
679 - break;
680 - switch (c) {
681 - case 'h':
682 - usage();
683 - break;
684 - case 'd':
685 - distance = atoi(optarg);
686 - break;
687 - case 'i':
688 - strncpy(device, optarg, sizeof (device));
689 - break;
690 - default:
691 - usage();
692 - break;
693 - }
694 - }
695 -
696 - if (distance >= 0) {
697 - int slottime = (distance / 300) + ((distance % 300) ? 1 : 0);
698 - int acktimeout = slottime * 2 + 3;
699 - int ctstimeout = slottime * 2 + 3;
700 -
701 - printf("Setting distance on interface %s to %i meters\n",
702 - device, distance);
703 - setsysctrl(device, "slottime", slottime);
704 - setsysctrl(device, "acktimeout", acktimeout);
705 - setsysctrl(device, "ctstimeout", ctstimeout);
706 - } else
707 - usage();
708 - return 0;
709 -}
710 --- a/tools/do_multi.c
711 +++ b/tools/do_multi.c
712 @@ -18,8 +18,6 @@ main(int argc, char *argv[])
713 ret = a80211stats_init(argc, argv);
714 if(strcmp(progname, "athchans") == 0)
715 ret = athchans_init(argc, argv);
716 - if(strcmp(progname, "athctrl") == 0)
717 - ret = athctrl_init(argc, argv);
718 #ifdef AR_DEBUG
719 if(strcmp(progname, "athdebug") == 0)
720 ret = athdebug_init(argc, argv);
721 --- a/tools/do_multi.h
722 +++ b/tools/do_multi.h
723 @@ -2,7 +2,6 @@
724 int a80211debug_init(int argc, char *argv[]);
725 int a80211stats_init(int argc, char *argv[]);
726 int athchans_init(int argc, char *argv[]);
727 -int athctrl_init(int argc, char *argv[]);
728 int athdebug_init(int argc, char *argv[]);
729 int athkey_init(int argc, char *argv[]);
730 int athstats_init(int argc, char *argv[]);
731 --- a/ath_rate/minstrel/minstrel.h
732 +++ b/ath_rate/minstrel/minstrel.h
733 @@ -172,14 +172,6 @@ struct minstrel_node {
734
735 #define ATH_NODE_MINSTREL(an) ((struct minstrel_node *)&an[1])
736
737 -
738 -#ifndef MIN
739 -#define MIN(a,b) ((a) < (b) ? (a) : (b))
740 -#endif
741 -#ifndef MAX
742 -#define MAX(a,b) ((a) > (b) ? (a) : (b))
743 -#endif
744 -
745 /*
746 * Definitions for pulling the rate and trie counts from
747 * a 5212 h/w descriptor. These Don't belong here; the
748 --- a/ath_rate/sample/sample.h
749 +++ b/ath_rate/sample/sample.h
750 @@ -98,14 +98,6 @@ struct sample_node {
751 };
752 #define ATH_NODE_SAMPLE(an) ((struct sample_node *)&an[1])
753
754 -
755 -#ifndef MIN
756 -#define MIN(a,b) ((a) < (b) ? (a) : (b))
757 -#endif
758 -#ifndef MAX
759 -#define MAX(a,b) ((a) > (b) ? (a) : (b))
760 -#endif
761 -
762 /*
763 * Definitions for pulling the rate and trie counts from
764 * a 5212 h/w descriptor. These Don't belong here; the
This page took 0.100601 seconds and 5 git commands to generate.