aboutsummaryrefslogtreecommitdiffstats
path: root/package/madwifi/patches-r3776/316-ani_fix.patch
blob: d14deac528ed66ec7d8ee4a4573090d75aa09b0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
Index: madwifi-trunk-r3776/ath/if_ath.c
===================================================================
--- madwifi-trunk-r3776.orig/ath/if_ath.c	2008-07-17 03:06:03.000000000 +0200
+++ madwifi-trunk-r3776/ath/if_ath.c	2008-07-17 03:53:09.000000000 +0200
@@ -343,6 +343,8 @@
 		unsigned int param, unsigned int value);
 
 static u_int32_t ath_get_real_maxtxpower(struct ath_softc *sc);
+static int ath_setintmit(struct ath_softc *sc);
+static u_int32_t ath_calcrxfilter(struct ath_softc *sc);
 
 #ifdef AR_DEBUG
 static int ath_txq_check(struct ath_softc *sc, struct ath_txq *txq, const char *msg);
@@ -356,7 +358,6 @@
 static char *ratectl = DEF_RATE_CTL;
 static int rfkill = 0;
 static int hal_tpc = 0;
-static int intmit = 0;
 static int countrycode = CTRY_DEFAULT;
 static int maxvaps = ATH_MAXVAPS_DEFAULT;
 static int outdoor = 0;
@@ -398,7 +399,6 @@
 #endif
 MODULE_PARM(autocreate, "s");
 MODULE_PARM(ratectl, "s");
-MODULE_PARM(intmit, "i");
 #else
 #include <linux/moduleparam.h>
 module_param(beacon_cal, int, 0600);
@@ -412,7 +412,6 @@
 #endif
 module_param(autocreate, charp, 0600);
 module_param(ratectl, charp, 0600);
-module_param(intmit, int, 0600);
 #endif
 MODULE_PARM_DESC(countrycode, "Override default country code.  Default is 0.");
 MODULE_PARM_DESC(maxvaps, "Maximum VAPs.  Default is 4.");
@@ -428,7 +427,6 @@
 		"'none' to disable");
 MODULE_PARM_DESC(ratectl, "Rate control algorithm [amrr|minstrel|onoe|sample], "
 		"defaults to '" DEF_RATE_CTL "'");
-MODULE_PARM_DESC(intmit, "Enable interference mitigation by default.  Default is 0.");
 
 #ifdef AR_DEBUG
 static int	ath_debug = 0;
@@ -585,23 +583,13 @@
 	if (ath_hal_hastxpowlimit(ah)) {
 		ic->ic_caps |= IEEE80211_C_TXPMGT;
 	}
-	/* Interference mitigation/ambient noise immunity (ANI).
-	 * In modes other than HAL_M_STA, it causes receive sensitivity
-	 * problems for OFDM. */
+	/* Interference mitigation/ambient noise immunity (ANI). */
 	sc->sc_hasintmit = ath_hal_hasintmit(ah);
-	sc->sc_useintmit = (intmit && sc->sc_hasintmit);
-	if (!sc->sc_hasintmit && intmit) {
-		WPRINTF(sc, "Interference mitigation was requested, but is not"
-				"supported by the HAL/hardware.\n");
-		intmit = 0; /* Stop use in future ath_attach(). */
-	}
-	else {
-		ath_hal_setintmit(ah, sc->sc_useintmit);
-		DPRINTF(sc, ATH_DEBUG_ANY, "Interference mitigation is "
-			"supported.  Currently %s.\n",
-			(sc->sc_useintmit ? "enabled" : "disabled"));
-	}
 
+	/* auto, mode dependent */
+	sc->sc_useintmit = -1;
+	sc->sc_noise_immunity = -1;
+	sc->sc_ofdm_weak_det = -1;
 	sc->sc_dmasize_stomp = 0;
 
 	/*
@@ -614,15 +602,6 @@
 	sc->sc_mrretry = ath_hal_setupxtxdesc(ah, NULL, 0,0, 0,0, 0,0);
 
 	/*
-	 * Check if the device has hardware counters for PHY
-	 * errors.  If so we need to enable the MIB interrupt
-	 * so we can act on stat triggers.
-	 */
-	sc->sc_needmib = ath_hal_hwphycounters(ah) && 
-		sc->sc_hasintmit && 
-		sc->sc_useintmit;
-
-	/*
 	 * Get the hardware key cache size.
 	 */
 	sc->sc_keymax = ath_hal_keycachesize(ah);
@@ -1593,37 +1572,6 @@
 	ath_init(dev);
 }
 
-/* NB: Int. mit. was not implemented so that it could be enabled/disabled,
- * and actually in 0.9.30.13 HAL it really can't even be disabled because
- * it will start adjusting registers even when we turn off the capability
- * in the HAL.
- *
- * NB: This helper function basically clobbers all the related registers
- * if we have disabled int. mit. cap, allowing us to turn it on and off and
- * work around the bug preventing it from being disabled. */
-static inline void ath_override_intmit_if_disabled(struct ath_softc *sc) {
-	/* Restore int. mit. registers if they were turned off. */
-	if (sc->sc_hasintmit && !sc->sc_useintmit)
-		ath_hal_restore_default_intmit(sc->sc_ah);
-	/* Sanity check... remove later. */
-	if (!sc->sc_useintmit) {
-		ath_hal_verify_default_intmit(sc->sc_ah);
-		/* If we don't have int. mit. and we don't have DFS on channel,
-		 * it is safe to filter error packets. */
-		if (!ath_radar_is_dfs_required(sc, &sc->sc_curchan)) {
-			ath_hal_setrxfilter(sc->sc_ah,
-				ath_hal_getrxfilter(sc->sc_ah) & 
-				~HAL_RX_FILTER_PHYERR);
-		}
-	}
-	else {
-		/* Make sure that we have errors in RX filter because ANI needs
-		 * them. */
-		ath_hal_setrxfilter(sc->sc_ah, 
-			ath_hal_getrxfilter(sc->sc_ah) | HAL_RX_FILTER_PHYERR);
-	}
-}
-
 static HAL_BOOL ath_hw_reset(struct ath_softc *sc, HAL_OPMODE opmode,
 		HAL_CHANNEL *channel, HAL_BOOL bChannelChange,
 		HAL_STATUS *status)
@@ -1698,11 +1646,7 @@
 		ath_hal_settpc(sc->sc_ah, hal_tpc);
 	}
 #endif
-#if 0 /* Setting via HAL does not work, so it is done manually below. */
-	if (sc->sc_hasintmit)
-		ath_hal_setintmit(sc->sc_ah, sc->sc_useintmit);
-#endif
-	ath_override_intmit_if_disabled(sc);
+	ath_setintmit(sc);
 	if (sc->sc_dmasize_stomp)
 		ath_hal_set_dmasize_pcie(sc->sc_ah);
 	if (sc->sc_softled)
@@ -2496,7 +2440,6 @@
 
 			/* Let the HAL handle the event. */
 			ath_hal_mibevent(ah, &sc->sc_halstats);
-			ath_override_intmit_if_disabled(sc);
 		}
 	}
 	if (needmark)
@@ -2564,6 +2507,55 @@
 	return flags;
 }
 
+static int ath_setintmit(struct ath_softc *sc)
+{
+	struct ath_hal *ah = sc->sc_ah;
+	int ret;
+	int val;
+
+	if (!sc->sc_hasintmit)
+		return 0;
+
+	switch(sc->sc_useintmit) {
+		case 0: /* disabled */
+		case 1: /* enabled */
+			val = sc->sc_useintmit;
+			break;
+		default:
+			if (sc->sc_opmode != IEEE80211_M_MONITOR)
+				val = 1;
+			else
+				val = 0;
+			break;
+	}
+	ret = ath_hal_setintmit(ah, val);
+	if (val)
+		goto done;
+
+	/* manual settings */
+	if ((sc->sc_noise_immunity >= 0) && (sc->sc_noise_immunity <= 5))
+		ath_hal_setcapability(ah, HAL_CAP_INTMIT, 2, sc->sc_noise_immunity, NULL);
+	if ((sc->sc_ofdm_weak_det == 0) || (sc->sc_ofdm_weak_det == 1))
+		ath_hal_setcapability(ah, HAL_CAP_INTMIT, 3, sc->sc_ofdm_weak_det, NULL);
+
+done:
+	if (!sc->sc_imask)
+		goto out;
+
+	/* MIB interrupt handling */
+	sc->sc_needmib = ath_hal_hwphycounters(ah) &&
+		sc->sc_useintmit;
+	if (sc->sc_needmib)
+		sc->sc_imask |= HAL_INT_MIB;
+	else
+		sc->sc_imask &= ~HAL_INT_MIB;
+	ath_hal_intrset(sc->sc_ah, sc->sc_imask);
+	ath_calcrxfilter(sc);
+
+out:
+	return ret;
+}
+
 /*
  * Context: process context
  */
@@ -4248,8 +4240,7 @@
 	u_int32_t rfilt;
 
 	/* Preserve the current Phy. radar and err. filters. */
-	rfilt = (ath_hal_getrxfilter(ah) &
-			(HAL_RX_FILTER_PHYERR | HAL_RX_FILTER_PHYRADAR)) |
+	rfilt = (ath_hal_getrxfilter(ah) & HAL_RX_FILTER_PHYRADAR) |
 		 HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST |
 		 HAL_RX_FILTER_MCAST;
 	if (ic->ic_opmode != IEEE80211_M_STA)
@@ -4265,6 +4256,8 @@
 	if (sc->sc_nmonvaps > 0)
 		rfilt |= (HAL_RX_FILTER_CONTROL | HAL_RX_FILTER_BEACON |
 			  HAL_RX_FILTER_PROBEREQ | HAL_RX_FILTER_PROM);
+	if (sc->sc_hasintmit && !sc->sc_needmib && ath_hal_getintmit(ah, NULL))
+		rfilt |= HAL_RX_FILTER_PHYERR;
 	if (sc->sc_curchan.privFlags & CHANNEL_DFS)
 		rfilt |= (HAL_RX_FILTER_PHYERR | HAL_RX_FILTER_PHYRADAR);
 	return rfilt;
@@ -6809,8 +6802,7 @@
 	dev->quota -= bf_processed;
 #endif
 
-	if (sc->sc_useintmit) 
-		ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
+	ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
 	if (!bf_processed)
 		DPRINTF(sc, ATH_DEBUG_RX_PROC,
 			"Warning: %s got scheduled when no receive "
@@ -8726,7 +8718,6 @@
 	ath_hal_rxena(ah);		/* enable recv descriptors */
 	ath_mode_init(dev);		/* set filters, etc. */
 	ath_hal_startpcurecv(ah);	/* re-enable PCU/DMA engine */
-	ath_override_intmit_if_disabled(sc);
 	return 0;
 }
 
@@ -10632,8 +10623,10 @@
 	ATH_RP_IGNORED 		= 24,
 	ATH_RADAR_IGNORED       = 25,
 	ATH_MAXVAPS  		= 26,
-        ATH_INTMIT 		= 27,
-	ATH_DISTANCE		= 28,
+	ATH_DISTANCE		= 27,
+	ATH_INTMIT			= 28,
+	ATH_NOISE_IMMUNITY	= 29,
+	ATH_OFDM_WEAK_DET	= 30
 };
 
 static inline int 
@@ -10695,6 +10688,48 @@
 }
 
 static int
+ath_sysctl_set_intmit(struct ath_softc *sc, long ctl, u_int val)
+{
+	int ret;
+
+	switch(ctl) {
+	case ATH_INTMIT:
+		sc->sc_intmit = val;
+		break;
+	case ATH_NOISE_IMMUNITY:
+		sc->sc_noise_immunity = val;
+		break;
+	case ATH_OFDM_WEAK_DET:
+		sc->sc_ofdm_weak_det = val;
+		break;
+	default:
+		return -EINVAL;
+	}
+	ret = ath_setintmit(sc);
+	return ret;
+}
+
+static int
+ath_sysctl_get_intmit(struct ath_softc *sc, long ctl, u_int *val)
+{
+	struct ath_hal *ah = sc->sc_ah;
+
+	switch(ctl) {
+	case ATH_INTMIT:
+		*val = (ath_hal_getcapability(ah, HAL_CAP_INTMIT, 1, NULL) == HAL_OK);
+		break;
+	case ATH_NOISE_IMMUNITY:
+		return ath_hal_getcapability(ah, HAL_CAP_INTMIT, 2, val);
+	case ATH_OFDM_WEAK_DET:
+		return ath_hal_getcapability(ah, HAL_CAP_INTMIT, 3, val);
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+
+static int
 ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos)
 {
 	struct ath_softc *sc = ctl->extra1;
@@ -10933,30 +10968,13 @@
 				sc->sc_radar_ignored = val;
 				break;
 			case ATH_INTMIT:
-				if (!sc->sc_hasintmit) {
+			case ATH_NOISE_IMMUNITY:
+			case ATH_OFDM_WEAK_DET:
+				if (!sc->sc_hasintmit)
 					ret = -EOPNOTSUPP;
-					break;
-				}
-				if (sc->sc_useintmit == val)
-					break;
-				sc->sc_useintmit = val; 
-				sc->sc_needmib = ath_hal_hwphycounters(ah) && 
-					sc->sc_useintmit;
-				/* Update the HAL and MIB interrupt mask bits */
-				ath_hal_setintmit(ah, !!val); 
-				sc->sc_imask = (sc->sc_imask & ~HAL_INT_MIB) | 
-					(sc->sc_needmib ? HAL_INT_MIB : 0);
-				ath_hal_intrset(sc->sc_ah, sc->sc_imask);
-				/* Only do a reset if device is valid and UP 
-				 * and we just made a change to the settings. */
-				if (sc->sc_dev && !sc->sc_invalid &&
-				    (sc->sc_dev->flags & IFF_RUNNING))
-					ath_reset(sc->sc_dev); 
-				/* NB: Run this step to cleanup if HAL doesn't 
-				 * obey capability flags and hangs onto ANI
-				 * settings. */
-				ath_override_intmit_if_disabled(sc);
-                                break; 
+				else
+					ret = ath_sysctl_set_intmit(sc, (long)ctl->extra2, val);
+				break;
 			default:
 				ret = -EINVAL;
 				break;
@@ -11028,9 +11046,14 @@
 		case ATH_RADAR_IGNORED:
 			val = sc->sc_radar_ignored;
 			break;
-                case ATH_INTMIT: 
-			val = sc->sc_useintmit; 
-			break; 
+		case ATH_INTMIT:
+		case ATH_NOISE_IMMUNITY:
+		case ATH_OFDM_WEAK_DET:
+			if (!sc->sc_hasintmit)
+				ret = -EOPNOTSUPP;
+			else
+				ret = ath_sysctl_get_intmit(sc, (long)ctl->extra2, &val);
+			break;
 		default:
 			ret = -EINVAL;
 			break;
@@ -11412,6 +11435,24 @@
 	  .maxlen	= sizeof(ath_xchanmode),
 	  .proc_handler	= proc_dointvec
 	},
+	{ .ctl_name	= CTL_AUTO,
+	  .procname     = "intmit",
+	  .mode         = 0644,
+	  .proc_handler = ath_sysctl_halparam,
+	  .extra2	= (void *)ATH_INTMIT,
+	},
+	{ .ctl_name	= CTL_AUTO,
+	  .procname     = "noise_immunity",
+	  .mode         = 0644,
+	  .proc_handler = ath_sysctl_halparam,
+	  .extra2	= (void *)ATH_NOISE_IMMUNITY,
+	},
+	{ .ctl_name	= CTL_AUTO,
+	  .procname     = "ofdm_weak_det",
+	  .mode         = 0644,
+	  .proc_handler = ath_sysctl_halparam,
+	  .extra2	= (void *)ATH_OFDM_WEAK_DET,
+	},
 	{ 0 }
 };
 static ctl_table ath_ath_table[] = {
Index: madwifi-trunk-r3776/ath/if_athvar.h
===================================================================
--- madwifi-trunk-r3776.orig/ath/if_athvar.h	2008-07-17 03:04:02.000000000 +0200
+++ madwifi-trunk-r3776/ath/if_athvar.h	2008-07-17 03:12:36.000000000 +0200
@@ -712,6 +712,10 @@
 	unsigned int sc_txcont_power; /* Continuous transmit power in 0.5dBm units */
 	unsigned int sc_txcont_rate;  /* Continuous transmit rate in Mbps */
 
+	int8_t sc_intmit; /* Interference mitigation enabled, -1 = auto, based on mode, 0/1 = off/on */
+	int8_t sc_noise_immunity; /* Noise immunity level, 0-4, -1 == auto) */
+	int8_t sc_ofdm_weak_det; /* OFDM weak frames detection, -1 == auto */
+
 	/* rate tables */
 	const HAL_RATE_TABLE *sc_rates[IEEE80211_MODE_MAX];
 	const HAL_RATE_TABLE *sc_currates;	/* current rate table */
Index: madwifi-trunk-r3776/ath/if_ath_hal_extensions.h
===================================================================
--- madwifi-trunk-r3776.orig/ath/if_ath_hal_extensions.h	2008-07-17 00:21:39.000000000 +0200
+++ madwifi-trunk-r3776/ath/if_ath_hal_extensions.h	2008-07-17 03:50:03.000000000 +0200
@@ -237,296 +237,18 @@
 	AR5K_DMASIZE_512B
 };
 
-
-int ath_set_ack_bitrate(struct ath_softc *sc, int);
-int ar_device(int devid);
-const char * ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val);
-
-static inline unsigned long field_width(unsigned long mask, unsigned long shift)
-{
-	unsigned long r = 0;
-	unsigned long x = mask >> shift;
-	if ( 0 == mask )  return  0;
-#if  BITS_PER_LONG >= 64
-	if ( x & (~0UL<<32) )  { x >>= 32;  r += 32; }
-#endif
-	if ( x & 0xffff0000 )  { x >>= 16;  r += 16; }
-	if ( x & 0x0000ff00 )  { x >>=  8;  r +=  8; }
-	if ( x & 0x000000f0 )  { x >>=  4;  r +=  4; }
-	if ( x & 0x0000000c )  { x >>=  2;  r +=  2; }
-	if ( x & 0x00000002 )  {            r +=  1; }
-	return r+1;
-}
-
-static inline u_int32_t get_field(struct ath_hal *ah, u_int32_t reg, u_int32_t mask, u_int32_t shift, int is_signed) {
-	unsigned long x = ((OS_REG_READ(ah, reg) & mask) >> shift);
-	if (is_signed) {
-		unsigned long c =(-1) << (field_width(mask, shift)-1);
-		return (x + c) ^ c;
-	}
-	return x;
-}
-
 static inline void set_field(struct ath_hal *ah, u_int32_t reg, u_int32_t mask, u_int32_t shift, u_int32_t value) {
 	OS_REG_WRITE(ah, reg, 
 			  (OS_REG_READ(ah, reg) & ~mask) | 
 			  ((value << shift) & mask));
 }
 
-static inline u_int32_t field_eq(struct ath_hal *ah, u_int32_t reg, 
-				 u_int32_t mask, u_int32_t shift, 
-				 u_int32_t value, int is_signed) {
-	return  (get_field(ah, reg, mask, shift, is_signed) & (mask >> shift)) == 
-		(value & (mask >> shift));
-}
-
-static inline void override_warning(struct ath_hal *ah, const char *name,
-				    u_int32_t reg, u_int32_t mask,
-				    u_int32_t shift, u_int32_t expected, int is_signed) {
-
-	if (!field_eq(ah, reg, mask, shift, expected, is_signed)) 
-		printk("%s: Correcting 0x%04x[%s] from 0x%x (%d) to 0x%x (%d).\n", 
-		       SC_DEV_NAME(ah->ah_sc),
-		       reg,
-		       name, 
-		       (get_field(ah, reg, mask, shift, is_signed) & (mask >> shift)),
-		       get_field(ah, reg, mask, shift, is_signed), 
-		       (expected & (mask >> shift)), /* not sign extended */
-		       expected);
-#if 0 /* NB: For checking to see if HAL is fixed or not */
-	else {
-			printk("%s: Keeping 0x%04x[%s] - 0x%x (%d).\n",
-			       SC_DEV_NAME(ah->ah_sc),
-			       reg,
-			       name, 
-			       (get_field(ah, reg, mask, shift, is_signed) & (mask >> shift)),
-			       get_field(ah, reg, mask, shift, is_signed));
-	}
-#endif
-}
-
-static inline void verification_warning(struct ath_hal *ah, const char *name,
-    u_int32_t reg, u_int32_t mask, 
-    u_int32_t shift, u_int32_t expected, int is_signed) {
-
-	int ret = field_eq(ah, reg, mask, shift, expected, is_signed);
-	if (!ret) {
-		printk("%s: %s verification of %s default value "
-		       "[found=0x%x (%d) expected=0x%x (%d)].\n", 
-		       SC_DEV_NAME(ah->ah_sc),
-		       (ret ? "PASSED" : "FAILED"),
-			name, 
-		       (get_field(ah, reg, mask, shift, is_signed) & (mask >> shift)), 
-		       get_field(ah, reg, mask, shift, is_signed), 
-		       (expected & (mask >> shift)), /* not sign extended */
-		       expected);
-		ath_hal_print_decoded_register(ah, NULL, reg, 
-					       OS_REG_READ(ah, reg), OS_REG_READ(ah, reg), 0);
-	}
-}
-
-#define GET_FIELD(ah, __reg, __mask, __signed) \
-	get_field(ah, __reg, __mask, __mask ## _S, __signed)
 #define SET_FIELD(ah, __reg, __mask, __value) \
 	set_field(ah, __reg, __mask, __mask ## _S, __value);
-#define FIELD_EQ(ah, __reg, __mask, __value, __signed) \
-	field_eq(ah, __reg, __mask, __mask ## _S, __value, __signed)
-
-#if 0 /* NB: These are working at this point, and HAL tweaks them a lot */
-#define OVERRIDE_WARNING(ah, __reg, __mask, __expected, __signed) \
-	override_warning(ah, #__mask, __reg, __mask, __mask ## _S, __expected, __signed)
-#else
-#define OVERRIDE_WARNING(ah, __reg, __mask, __expected, __signed) 
-#endif
-	
-#define VERIFICATION_WARNING(ah, __reg, __mask, __signed) \
-	verification_warning(ah, #__mask, __reg, __mask, __mask ## _S, DEFAULT_ ## __mask, __signed)
-#define VERIFICATION_WARNING_SW(ah, __reg, __mask, __signed) \
-	verification_warning(ah, #__mask, __reg, __mask, __mask ## _S, DEFAULT_ENABLE_ ## __reg ? __mask ## _ON : __mask ## _OFF, __signed)
-
-static inline void ath_hal_set_noise_immunity(struct ath_hal *ah,
-					      int agc_desired_size, 
-					      int agc_coarse_hi,
-					      int agc_coarse_lo, 
-					      int sig_firpwr) 
-{
-	ATH_HAL_LOCK_IRQ(ah->ah_sc);
-	ath_hal_set_function(__func__);
-	ath_hal_set_device(SC_DEV_NAME(ah->ah_sc));
-
-#if 0 /* NB: These are working at this point, and HAL tweaks them a lot */
-	OVERRIDE_WARNING(ah, AR5K_PHY_AGCSIZE, AR5K_PHY_AGCSIZE_DESIRED, agc_desired_size, 1);
-	OVERRIDE_WARNING(ah, AR5K_PHY_AGCCOARSE, AR5K_PHY_AGCCOARSE_LO, agc_coarse_lo, 1);
-	OVERRIDE_WARNING(ah, AR5K_PHY_AGCCOARSE, AR5K_PHY_AGCCOARSE_HI, agc_coarse_hi, 1);
-	OVERRIDE_WARNING(ah, AR5K_PHY_SIG, AR5K_PHY_SIG_FIRPWR, sig_firpwr, 1);
-#endif
-
-	SET_FIELD(ah, AR5K_PHY_AGCSIZE, AR5K_PHY_AGCSIZE_DESIRED, agc_desired_size);
-	SET_FIELD(ah, AR5K_PHY_AGCCOARSE, AR5K_PHY_AGCCOARSE_LO, agc_coarse_lo);
-	SET_FIELD(ah, AR5K_PHY_AGCCOARSE, AR5K_PHY_AGCCOARSE_HI, agc_coarse_hi);
-	SET_FIELD(ah, AR5K_PHY_SIG, AR5K_PHY_SIG_FIRPWR, sig_firpwr);
-
-	ath_hal_set_function(NULL);
-	ath_hal_set_device(NULL);
-	ATH_HAL_UNLOCK_IRQ(ah->ah_sc);
-}
-
-static inline void ath_hal_set_ofdm_weak_det(struct ath_hal *ah, 
-	int low_m1, int low_m2, int low_m2_count, int low_self_corr,
-	int high_m1, int high_m2, int high_m2_count)
-{
-	ATH_HAL_LOCK_IRQ(ah->ah_sc);
-	ath_hal_set_function(__func__);
-	ath_hal_set_device(SC_DEV_NAME(ah->ah_sc));
-
-	OVERRIDE_WARNING(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M1, low_m1, 0);
-	OVERRIDE_WARNING(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M2, low_m2, 0);
-	OVERRIDE_WARNING(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M2_COUNT, low_m2_count, 0);
-	OVERRIDE_WARNING(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_SELFCOR, low_self_corr, 0);
-	OVERRIDE_WARNING(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M1, high_m1, 0);
-	OVERRIDE_WARNING(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M2, high_m2, 0);
-	OVERRIDE_WARNING(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M2_COUNT, high_m2_count, 0);
-
-	SET_FIELD(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M1, low_m1);
-	SET_FIELD(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M2, low_m2);
-	SET_FIELD(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M2_COUNT, low_m2_count);
-	SET_FIELD(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_SELFCOR, low_self_corr);
-	SET_FIELD(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M1, high_m1);
-	SET_FIELD(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M2, high_m2);
-	SET_FIELD(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M2_COUNT, high_m2_count);
-
-	ath_hal_set_function(NULL);
-	ath_hal_set_device(NULL);
-	ATH_HAL_UNLOCK_IRQ(ah->ah_sc);
-}
-
-static inline void ath_hal_set_cck_weak_det(struct ath_hal *ah, int thresh)
-{
-	ATH_HAL_LOCK_IRQ(ah->ah_sc);
-	ath_hal_set_function(__func__);
-	ath_hal_set_device(SC_DEV_NAME(ah->ah_sc));
-
-	OVERRIDE_WARNING(ah, AR5K_PHY_WEAK_CCK, AR5K_PHY_WEAK_CCK_THRESH, thresh, 0);
-
-	SET_FIELD(ah, AR5K_PHY_WEAK_CCK, AR5K_PHY_WEAK_CCK_THRESH, thresh);
-
-	ath_hal_set_function(NULL);
-	ath_hal_set_device(NULL);
-	ATH_HAL_UNLOCK_IRQ(ah->ah_sc);
-}
-
-static inline void ath_hal_set_sig_firstep(struct ath_hal *ah, int firstep)
-{
-	ATH_HAL_LOCK_IRQ(ah->ah_sc);
-	ath_hal_set_function(__func__);
-	ath_hal_set_device(SC_DEV_NAME(ah->ah_sc));
 
-	OVERRIDE_WARNING(ah, AR5K_PHY_SIG, AR5K_PHY_SIG_FIRSTEP, firstep, 0);
-
-	SET_FIELD(ah, AR5K_PHY_SIG, AR5K_PHY_SIG_FIRSTEP, firstep);
-
-	ath_hal_set_function(NULL);
-	ath_hal_set_device(NULL);
-	ATH_HAL_UNLOCK_IRQ(ah->ah_sc);
-}
-
-static inline void ath_hal_set_spur_immunity(struct ath_hal *ah, int thresh)
-{
-	ATH_HAL_LOCK_IRQ(ah->ah_sc);
-	ath_hal_set_function(__func__);
-	ath_hal_set_device(SC_DEV_NAME(ah->ah_sc));
-
-	OVERRIDE_WARNING(ah, AR5K_PHY_SPUR, AR5K_PHY_SPUR_THRESH, thresh, 0);
-
-	SET_FIELD(ah, AR5K_PHY_SPUR, AR5K_PHY_SPUR_THRESH, thresh);
-
-	ath_hal_set_function(NULL);
-	ath_hal_set_device(NULL);
-	ATH_HAL_UNLOCK_IRQ(ah->ah_sc);
-}
-
-static inline void ath_hal_restore_default_noise_immunity(struct ath_hal *ah) {
-
-	ath_hal_set_noise_immunity(ah, 
-		DEFAULT_AR5K_PHY_AGCSIZE_DESIRED, 
-		DEFAULT_AR5K_PHY_AGCCOARSE_HI,
-		DEFAULT_AR5K_PHY_AGCCOARSE_LO,
-		DEFAULT_AR5K_PHY_SIG_FIRPWR);
-}
-
-static inline void ath_hal_enable_ofdm_weak_det(struct ath_hal *ah, int enable) {
-	if (enable)
-		ath_hal_set_ofdm_weak_det(ah, 
-			AR5K_PHY_WEAK_OFDM_LOW_M1_ON,
-			AR5K_PHY_WEAK_OFDM_LOW_M2_ON,
-			AR5K_PHY_WEAK_OFDM_LOW_M2_COUNT_ON,
-		        AR5K_PHY_WEAK_OFDM_LOW_SELFCOR_ON,
-			AR5K_PHY_WEAK_OFDM_HIGH_M1_ON,
-			AR5K_PHY_WEAK_OFDM_HIGH_M2_ON,
-			AR5K_PHY_WEAK_OFDM_HIGH_M2_COUNT_ON);
-	else
-		ath_hal_set_ofdm_weak_det(ah, 
-			AR5K_PHY_WEAK_OFDM_LOW_M1_OFF,
-			AR5K_PHY_WEAK_OFDM_LOW_M2_OFF,
-			AR5K_PHY_WEAK_OFDM_LOW_M2_COUNT_OFF,
-			AR5K_PHY_WEAK_OFDM_LOW_SELFCOR_OFF,
-			AR5K_PHY_WEAK_OFDM_HIGH_M1_OFF,
-			AR5K_PHY_WEAK_OFDM_HIGH_M2_OFF,
-			AR5K_PHY_WEAK_OFDM_HIGH_M2_COUNT_OFF);
-}
-
-static inline void ath_hal_enable_cck_weak_det(struct ath_hal *ah, int enable) {
-	ath_hal_set_cck_weak_det(ah, enable 
-				 ? AR5K_PHY_WEAK_CCK_THRESH_ON 
-				 : AR5K_PHY_WEAK_CCK_THRESH_OFF);
-}
-
-static inline void ath_hal_restore_default_ofdm_weak_det(struct ath_hal *ah) {
-	ath_hal_enable_ofdm_weak_det(ah, DEFAULT_ENABLE_AR5K_PHY_WEAK_OFDM);
-}
-
-static inline void ath_hal_restore_default_cck_weak_det(struct ath_hal *ah) {
-	ath_hal_enable_cck_weak_det(ah, DEFAULT_ENABLE_AR5K_PHY_WEAK_CCK);
-}
-
-static inline void ath_hal_restore_default_sig_firstep(struct ath_hal *ah) {
-
-	ath_hal_set_sig_firstep(ah, 
-		DEFAULT_AR5K_PHY_SIG_FIRSTEP);
-}
-
-static inline void ath_hal_restore_default_spur_immunity(struct ath_hal *ah) {
-
-	ath_hal_set_spur_immunity(ah, 
-		DEFAULT_AR5K_PHY_SPUR_THRESH);
-}
-
-static inline void ath_hal_restore_default_intmit(struct ath_hal *ah) {
-	ath_hal_restore_default_noise_immunity(ah);
-	ath_hal_restore_default_ofdm_weak_det(ah);
-	ath_hal_restore_default_cck_weak_det(ah);
-	ath_hal_restore_default_sig_firstep(ah);
-	ath_hal_restore_default_spur_immunity(ah);
-
-}
-
-static inline void ath_hal_verify_default_intmit(struct ath_hal *ah) {
-	/* Just a list of all the fields above, for sanity checks... */
-	VERIFICATION_WARNING(ah, AR5K_PHY_AGCSIZE, AR5K_PHY_AGCSIZE_DESIRED, 1);
-	VERIFICATION_WARNING(ah, AR5K_PHY_AGCCOARSE, AR5K_PHY_AGCCOARSE_LO, 1);
-	VERIFICATION_WARNING(ah, AR5K_PHY_AGCCOARSE, AR5K_PHY_AGCCOARSE_HI, 1);
-	VERIFICATION_WARNING(ah, AR5K_PHY_SIG, AR5K_PHY_SIG_FIRPWR, 1);
-	VERIFICATION_WARNING_SW(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M1, 0);
-	VERIFICATION_WARNING_SW(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M2, 0);
-	VERIFICATION_WARNING_SW(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_M2_COUNT, 0);
-	VERIFICATION_WARNING_SW(ah, AR5K_PHY_WEAK_OFDM_LOW, AR5K_PHY_WEAK_OFDM_LOW_SELFCOR, 0);
-	VERIFICATION_WARNING_SW(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M1, 0);
-	VERIFICATION_WARNING_SW(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M2, 0);
-	VERIFICATION_WARNING_SW(ah, AR5K_PHY_WEAK_OFDM_HIGH, AR5K_PHY_WEAK_OFDM_HIGH_M2_COUNT, 0);
-	VERIFICATION_WARNING_SW(ah, AR5K_PHY_WEAK_CCK, AR5K_PHY_WEAK_CCK_THRESH, 0);
-	VERIFICATION_WARNING(ah, AR5K_PHY_SIG, AR5K_PHY_SIG_FIRSTEP, 0);
-	VERIFICATION_WARNING(ah, AR5K_PHY_SPUR, AR5K_PHY_SPUR_THRESH, 0);
-}
+int ath_set_ack_bitrate(struct ath_softc *sc, int);
+int ar_device(int devid);
+const char * ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val);
 
 static inline void ath_hal_set_dmasize_pcie(struct ath_hal *ah) {
 	SET_FIELD(ah, AR5K_TXCFG, AR5K_TXCFG_SDMAMR, AR5K_DMASIZE_128B);
Index: madwifi-trunk-r3776/ath/if_ath_hal.h
===================================================================
--- madwifi-trunk-r3776.orig/ath/if_ath_hal.h	2008-07-17 00:53:20.000000000 +0200
+++ madwifi-trunk-r3776/ath/if_ath_hal.h	2008-07-17 03:41:25.000000000 +0200
@@ -79,7 +79,7 @@
 	ath_hal_set_function(__func__);
 	ath_hal_set_device(SC_DEV_NAME(ah->ah_sc));
 	ret =
-	    ah->ah_getDiagState(ah, request, args, argsize, *result,
+	    ah->ah_getDiagState(ah, request, args, argsize, result,
 				resultsize);
 	ath_hal_set_function(NULL);
 	ath_hal_set_device(NULL);
Index: madwifi-trunk-r3776/scripts/if_ath_hal_generator.pl
===================================================================
--- madwifi-trunk-r3776.orig/scripts/if_ath_hal_generator.pl	2008-07-17 00:21:30.000000000 +0200
+++ madwifi-trunk-r3776/scripts/if_ath_hal_generator.pl	2008-07-17 03:46:30.000000000 +0200
@@ -145,7 +145,9 @@
     "ah_waitForBeaconDone"        => "ath_hal_waitforbeacon",
     "ah_writeAssocid"             => "ath_hal_setassocid",
     "ah_clrMulticastFilterIndex"  => "ath_hal_clearmcastfilter",
-    "ah_detectCardPresent"        => "ath_hal_detectcardpresent"
+    "ah_detectCardPresent"        => "ath_hal_detectcardpresent",
+    "ah_setSifsTime"              => "ath_hal_setsifstime",
+    "ah_getSifsTime"              => "ath_hal_getsifstime"
 );
 
 #
@@ -254,7 +256,7 @@
 
     foreach (@parameters) {
         s/ \*/\* /;
-        /^((?:(?:const|struct|\*)\s*)*)([^\s]+\*?)\s*([^\s]*)\s*/;
+        /^((?:(?:const|struct|\*)\s*)*)([^\s]+\**)\s*([^\s]*)\s*/;
         my $type = "$1$2";
         my $name = "$3";
         if ( 0 == length($name) ) {