huge madwifi update (work in progress, disabled by default, compiles but breaks at...
[openwrt.git] / package / madwifi / patches-r3776 / 200-no_debug.patch
1 Index: madwifi-trunk-r3776/ath/if_ath.c
2 ===================================================================
3 --- madwifi-trunk-r3776.orig/ath/if_ath.c       2008-07-17 00:53:04.000000000 +0200
4 +++ madwifi-trunk-r3776/ath/if_ath.c    2008-07-17 01:15:21.000000000 +0200
5 @@ -323,8 +323,10 @@
6  static void ath_set_dfs_cac_time(struct ieee80211com *, unsigned int seconds);
7  
8  static unsigned int ath_test_radar(struct ieee80211com *);
9 -static unsigned int ath_dump_hal_map(struct ieee80211com *ic);
10 +#ifdef AR_DEBUG
11  
12 +static unsigned int ath_dump_hal_map(struct ieee80211com *ic);
13 +#endif
14  static u_int32_t ath_get_clamped_maxtxpower(struct ath_softc *sc);
15  static u_int32_t ath_set_clamped_maxtxpower(struct ath_softc *sc, 
16                 u_int32_t new_clamped_maxtxpower);
17 @@ -334,7 +336,10 @@
18                 unsigned int param, unsigned int value);
19  
20  static u_int32_t ath_get_real_maxtxpower(struct ath_softc *sc);
21 +
22 +#ifdef AR_DEBUG
23  static int ath_txq_check(struct ath_softc *sc, struct ath_txq *txq, const char *msg);
24 +#endif
25  
26  static int ath_countrycode = CTRY_DEFAULT;     /* country code */
27  static int ath_outdoor = AH_FALSE;             /* enable outdoor use */
28 @@ -486,9 +491,11 @@
29         u_int8_t csz;
30  
31         sc->devid = devid;
32 +#ifdef AR_DEBUG
33         ath_debug_global = (ath_debug & ATH_DEBUG_GLOBAL);
34         sc->sc_debug     = (ath_debug & ~ATH_DEBUG_GLOBAL);
35         DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid);
36 +#endif
37  
38         /* Allocate space for dynamically determined maximum VAP count */
39         sc->sc_bslot = 
40 @@ -1014,7 +1021,9 @@
41         ic->ic_vap_delete = ath_vap_delete;
42  
43         ic->ic_test_radar               = ath_test_radar;
44 +#ifdef AR_DEBUG
45         ic->ic_dump_hal_map             = ath_dump_hal_map;
46 +#endif
47  
48         ic->ic_set_dfs_testmode         = ath_set_dfs_testmode;
49         ic->ic_get_dfs_testmode         = ath_get_dfs_testmode;
50 @@ -1285,12 +1294,14 @@
51                 /* If no default VAP debug flags are passed, allow a few to
52                  * transfer down from the driver to new VAPs so we can have load
53                  * time debugging for VAPs too. */
54 +#ifdef AR_DEBUG
55                 vap->iv_debug = 0 |
56                         ((sc->sc_debug & ATH_DEBUG_RATE) ? IEEE80211_MSG_XRATE  : 0) | 
57                         ((sc->sc_debug & ATH_DEBUG_XMIT) ? IEEE80211_MSG_OUTPUT : 0) | 
58                         ((sc->sc_debug & ATH_DEBUG_RECV) ? IEEE80211_MSG_INPUT  : 0) |
59                         0
60                         ;
61 +#endif
62         }
63         ic->ic_debug = (sc->sc_default_ieee80211_debug & IEEE80211_MSG_IC);
64  
65 @@ -2811,6 +2822,7 @@
66  #endif
67  }
68  
69 +#ifdef AR_DEBUG
70  static void
71  ath_txq_dump(struct ath_softc *sc, struct ath_txq *txq)
72  {
73 @@ -2866,6 +2878,7 @@
74  
75         return 1;
76  }
77 +#endif
78  
79  /*
80   * Insert a buffer on a txq
81 @@ -8384,7 +8397,9 @@
82  ath_tx_timeout(struct net_device *dev)
83  {
84         struct ath_softc *sc = dev->priv;
85 +#ifdef AR_DEBUG
86         int i;
87 +#endif
88  
89         if (ath_chan_unavail(sc))
90                 return;
91 @@ -8393,12 +8408,14 @@
92                 (dev->flags & IFF_RUNNING) ? "" : "NOT ",
93                 sc->sc_invalid ? "in" : "");
94  
95 +#ifdef AR_DEBUG
96         for (i = 0; i < HAL_NUM_TX_QUEUES; i++) {
97                 if (ATH_TXQ_SETUP(sc, i)) {
98                         ath_txq_check(sc, &sc->sc_txq[i], __func__);
99                         ath_txq_dump(sc, &sc->sc_txq[i]);
100                 }
101         }
102 +#endif
103  
104         if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
105                 sc->sc_stats.ast_watchdog++;
106 @@ -10638,6 +10655,7 @@
107                                 /* XXX validate? */
108                                 sc->sc_ledpin = val;
109                                 break;
110 +#ifdef AR_DEBUG
111                         case ATH_DEBUG:
112                                 sc->sc_debug     = (val & ~ATH_DEBUG_GLOBAL);
113                                 ath_debug_global = (val &  ATH_DEBUG_GLOBAL);
114 @@ -10645,6 +10663,7 @@
115                                                 "0x%08x.\n", val);
116  
117                                 break;
118 +#endif
119                         case ATH_TXANTENNA:
120                                 /*
121                                  * antenna can be:
122 @@ -10818,9 +10837,11 @@
123                 case ATH_REGDOMAIN:
124                         ath_hal_getregdomain(ah, &val);
125                         break;
126 +#ifdef AR_DEBUG
127                 case ATH_DEBUG:
128                         val = sc->sc_debug | ath_debug_global;
129                         break;
130 +#endif
131                 case ATH_TXANTENNA:
132                         val = sc->sc_txantenna;
133                         break;
134 @@ -11939,6 +11960,7 @@
135  }
136  
137  /* This is called by a private ioctl (iwpriv) to dump the HAL obfuscation table */
138 +#ifdef AR_DEBUG
139  static unsigned int
140  ath_dump_hal_map(struct ieee80211com *ic)
141  {
142 @@ -11947,7 +11969,7 @@
143         ath_hal_dump_map(sc->sc_ah);
144         return 0;
145  }
146 -
147 +#endif
148  /* If we are shutting down or blowing off the DFS channel availability check
149   * then we call this to stop the behavior before we take the rest of the
150   * necessary actions (such as a DFS reaction to radar). */
151 Index: madwifi-trunk-r3776/ath_rate/amrr/amrr.c
152 ===================================================================
153 --- madwifi-trunk-r3776.orig/ath_rate/amrr/amrr.c       2008-07-17 00:21:30.000000000 +0200
154 +++ madwifi-trunk-r3776/ath_rate/amrr/amrr.c    2008-07-17 00:53:20.000000000 +0200
155 @@ -70,7 +70,9 @@
156  
157  #include "amrr.h"
158  
159 +#ifdef AR_DEBUG
160  #define        AMRR_DEBUG
161 +#endif
162  #ifdef AMRR_DEBUG
163  #define        DPRINTF(sc, _fmt, ...) do {                                     \
164         if (sc->sc_debug & 0x10)                                        \
165 Index: madwifi-trunk-r3776/ath_rate/minstrel/minstrel.c
166 ===================================================================
167 --- madwifi-trunk-r3776.orig/ath_rate/minstrel/minstrel.c       2008-07-17 00:47:36.000000000 +0200
168 +++ madwifi-trunk-r3776/ath_rate/minstrel/minstrel.c    2008-07-17 01:16:06.000000000 +0200
169 @@ -117,7 +117,9 @@
170  
171  #include "minstrel.h"
172  
173 +#ifdef AR_DEBUG
174  #define        MINSTREL_DEBUG
175 +#endif
176  #ifdef MINSTREL_DEBUG
177  enum {
178                 ATH_DEBUG_RATE          = 0x00000010    /* rate control */
179 @@ -963,7 +965,9 @@
180                 (struct ieee80211_node_table *)&vap->iv_ic->ic_sta;
181         unsigned int x = 0;
182         unsigned int this_tp, this_prob, this_eprob;
183 -       struct ath_softc *sc = vap->iv_ic->ic_dev->priv;;
184 +#ifdef AR_DEBUG
185 +       struct ath_softc *sc = vap->iv_ic->ic_dev->priv;
186 +#endif
187  
188         IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
189         TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
190 Index: madwifi-trunk-r3776/ath_rate/onoe/onoe.c
191 ===================================================================
192 --- madwifi-trunk-r3776.orig/ath_rate/onoe/onoe.c       2008-07-17 00:21:29.000000000 +0200
193 +++ madwifi-trunk-r3776/ath_rate/onoe/onoe.c    2008-07-17 00:53:20.000000000 +0200
194 @@ -66,7 +66,9 @@
195  
196  #include "onoe.h"
197  
198 +#ifdef AR_DEBUG
199  #define        ONOE_DEBUG
200 +#endif
201  #ifdef ONOE_DEBUG
202  enum {
203         ATH_DEBUG_RATE  = 0x00000010,   /* rate control */
204 Index: madwifi-trunk-r3776/ath_rate/sample/sample.c
205 ===================================================================
206 --- madwifi-trunk-r3776.orig/ath_rate/sample/sample.c   2008-07-17 00:21:30.000000000 +0200
207 +++ madwifi-trunk-r3776/ath_rate/sample/sample.c        2008-07-17 00:53:20.000000000 +0200
208 @@ -68,7 +68,9 @@
209  
210  #include "sample.h"
211  
212 -#define        SAMPLE_DEBUG
213 +#ifdef AR_DEBUG
214 +#define SAMPLE_DEBUG
215 +#endif
216  #ifdef SAMPLE_DEBUG
217  enum {
218         ATH_DEBUG_RATE          = 0x00000010,   /* rate control */
219 Index: madwifi-trunk-r3776/tools/do_multi.c
220 ===================================================================
221 --- madwifi-trunk-r3776.orig/tools/do_multi.c   2008-07-17 00:46:52.000000000 +0200
222 +++ madwifi-trunk-r3776/tools/do_multi.c        2008-07-17 00:53:20.000000000 +0200
223 @@ -9,16 +9,20 @@
224  
225      progname = basename(argv[0]);
226  
227 +#ifdef AR_DEBUG
228      if(strcmp(progname, "80211debug") == 0)
229         ret = a80211debug_init(argc, argv);
230 +#endif
231      if(strcmp(progname, "80211stats") == 0)
232         ret = a80211stats_init(argc, argv);
233      if(strcmp(progname, "athchans") == 0)
234         ret = athchans_init(argc, argv);
235      if(strcmp(progname, "athctrl") == 0)
236         ret =  athctrl_init(argc, argv);
237 +#ifdef AR_DEBUG
238      if(strcmp(progname, "athdebug") == 0)
239         ret =  athdebug_init(argc, argv);
240 +#endif
241      if(strcmp(progname, "athkey") == 0)
242         ret =  athkey_init(argc, argv);
243      if(strcmp(progname, "athstats") == 0)
244 Index: madwifi-trunk-r3776/tools/Makefile
245 ===================================================================
246 --- madwifi-trunk-r3776.orig/tools/Makefile     2008-07-17 00:45:15.000000000 +0200
247 +++ madwifi-trunk-r3776/tools/Makefile  2008-07-17 01:10:33.000000000 +0200
248 @@ -39,6 +39,10 @@
249  
250  ATH_HAL = $(TOP)/ath_hal
251  
252 +ifndef ATH_DEBUG
253 +ATH_DEBUG=1
254 +endif
255 +
256  #
257  # Path to the HAL source code.
258  #
259 @@ -46,17 +50,22 @@
260  HAL = $(TOP)/hal
261  endif
262  
263 +INCS = -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL) -I$(TOP)/ath
264 +CFLAGS = -g -O2 -Wall
265 +ALL_CFLAGS = $(CFLAGS) $(INCS)
266 +LDFLAGS =
267  
268  PROGRAMS = athstats 80211stats athkey athchans athctrl \
269 -       athdebug 80211debug wlanconfig wpakey
270 +       wlanconfig wpakey
271 +
272 +ifeq ($(ATH_DEBUG),1)
273 +  PROGRAMS += athdebug 80211debug
274 +  ALL_CFLAGS += -DAR_DEBUG
275 +endif
276  
277  OBJS = $(patsubst %,%.o,$(PROGRAMS)) ath_info/ath_info.o
278  SUBDIRS = ath_info
279  
280 -INCS = -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL) -I$(TOP)/ath
281 -CFLAGS = -g -O2 -Wall
282 -ALL_CFLAGS = $(CFLAGS) $(INCS)
283 -LDFLAGS =
284  
285  all: all-subdirs compile
286  
287 Index: madwifi-trunk-r3776/ath/if_ath_hal.h
288 ===================================================================
289 --- madwifi-trunk-r3776.orig/ath/if_ath_hal.h   2008-07-17 00:21:39.000000000 +0200
290 +++ madwifi-trunk-r3776/ath/if_ath_hal.h        2008-07-17 00:53:20.000000000 +0200
291 @@ -1263,6 +1263,7 @@
292  
293             tail -f /var/log/messages | sed -f hal_unmangle.sed 
294   */
295 +#ifdef AR_DEBUG
296  static inline void ath_hal_dump_map(struct ath_hal *ah)
297  {
298  #ifdef CONFIG_KALLSYMS
299 @@ -1527,7 +1528,7 @@
300  #endif                         /* #ifndef CONFIG_KALLSYMS */
301  
302  }
303 -
304 +#endif
305  #include "if_ath_hal_wrappers.h"
306  #include "if_ath_hal_extensions.h"
307  
308 Index: madwifi-trunk-r3776/net80211/ieee80211_var.h
309 ===================================================================
310 --- madwifi-trunk-r3776.orig/net80211/ieee80211_var.h   2008-07-17 00:21:29.000000000 +0200
311 +++ madwifi-trunk-r3776/net80211/ieee80211_var.h        2008-07-17 00:53:20.000000000 +0200
312 @@ -495,9 +495,10 @@
313         /* inject a fake radar signal -- used while on a 802.11h DFS channels */
314         unsigned int (*ic_test_radar)(struct ieee80211com *);
315  
316 +#ifdef AR_DEBUG
317         /* dump HAL */
318         unsigned int (*ic_dump_hal_map)(struct ieee80211com *);
319 -
320 +#endif
321         /* DFS channel availability check time (in seconds) */
322         void (*ic_set_dfs_cac_time)(struct ieee80211com *, unsigned int);
323         unsigned int (*ic_get_dfs_cac_time)(struct ieee80211com *);
324 Index: madwifi-trunk-r3776/net80211/ieee80211_wireless.c
325 ===================================================================
326 --- madwifi-trunk-r3776.orig/net80211/ieee80211_wireless.c      2008-07-17 00:21:29.000000000 +0200
327 +++ madwifi-trunk-r3776/net80211/ieee80211_wireless.c   2008-07-17 00:53:20.000000000 +0200
328 @@ -1557,6 +1557,7 @@
329         return 0;
330  }
331  
332 +#ifdef AR_DEBUG
333  static int 
334  ieee80211_ioctl_hal_map(struct net_device *dev, struct iw_request_info *info,
335         void *w, char *extra)
336 @@ -1567,7 +1568,7 @@
337         params[0] = ic->ic_dump_hal_map(ic);
338         return 0;
339  }
340 -
341 +#endif
342  
343  static int
344  ieee80211_ioctl_radar(struct net_device *dev, struct iw_request_info *info,
345 @@ -5296,8 +5297,10 @@
346           IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "getwmmparams" },
347         { IEEE80211_IOCTL_RADAR,
348           0, 0, "doth_radar" },
349 +#ifdef AR_DEBUG
350         { IEEE80211_IOCTL_HALMAP,
351           0, 0, "dump_hal_map" },
352 +#endif
353         /*
354          * These depends on sub-ioctl support which added in version 12.
355          */
356 @@ -5751,7 +5754,9 @@
357         set_priv(IEEE80211_IOCTL_SETMLME, ieee80211_ioctl_setmlme),
358         set_priv(IEEE80211_IOCTL_SETKEY, ieee80211_ioctl_setkey),
359         set_priv(IEEE80211_IOCTL_DELKEY, ieee80211_ioctl_delkey),
360 +#ifdef AR_DEBUG
361         set_priv(IEEE80211_IOCTL_HALMAP, ieee80211_ioctl_hal_map),
362 +#endif
363         set_priv(IEEE80211_IOCTL_ADDMAC, ieee80211_ioctl_addmac),
364         set_priv(IEEE80211_IOCTL_DELMAC, ieee80211_ioctl_delmac),
365         set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsmac),
366 Index: madwifi-trunk-r3776/ath/if_ath_debug.h
367 ===================================================================
368 --- madwifi-trunk-r3776.orig/ath/if_ath_debug.h 2008-07-17 00:21:39.000000000 +0200
369 +++ madwifi-trunk-r3776/ath/if_ath_debug.h      2008-07-17 00:53:20.000000000 +0200
370 @@ -54,6 +54,10 @@
371         ATH_DEBUG_GLOBAL        = (ATH_DEBUG_SKB|ATH_DEBUG_SKB_REF)
372  };
373  
374 +#define        EPRINTF(_sc, _fmt, ...) \
375 +               printk(KERN_ERR "%s: %s: " _fmt, \
376 +                       SC_DEV_NAME(_sc), __func__, ## __VA_ARGS__)
377 +
378  #ifdef AR_DEBUG
379  
380  /* DEBUG-ONLY DEFINITIONS */
381 @@ -68,20 +72,9 @@
382                 ath_keyprint((_sc), __func__, _ix, _hk, _mac);          \
383  } while (0)
384  
385 -#else /* #ifdef AR_DEBUG */
386 -
387 -#define        DFLAG_ISSET(sc, _m)             0
388 -#define        DPRINTF(sc, _m, _fmt, ...)
389 -#define        KEYPRINTF(sc, k, ix, mac)
390 -
391 -#endif /* #ifdef AR_DEBUG */
392  
393  #define        IFF_DUMPPKTS(_sc, _m)   DFLAG_ISSET((_sc), (_m))
394  
395 -#define        EPRINTF(_sc, _fmt, ...) \
396 -               printk(KERN_ERR "%s: %s: " _fmt, \
397 -                       SC_DEV_NAME(_sc), __func__, ## __VA_ARGS__)
398 -
399  #define        WPRINTF(_sc, _fmt, ...) \
400                 printk(KERN_WARNING "%s: %s: " _fmt, \
401                         SC_DEV_NAME(_sc), __func__, ## __VA_ARGS__)
402 @@ -89,5 +82,14 @@
403  #define        IPRINTF(_sc, _fmt, ...) \
404                 printk(KERN_INFO "%s: %s: " _fmt, \
405                         SC_DEV_NAME(_sc), __func__, ## __VA_ARGS__)
406 +#else
407 +#define        DFLAG_ISSET(sc, _m)             0
408 +#define        DPRINTF(sc, _m, _fmt, ...)
409 +#define        KEYPRINTF(sc, k, ix, mac)
410 +#define WPRINTF(...)
411 +#define IPRINTF(...)
412 +#define IFF_DUMPPKTS(...) 0
413 +
414 +#endif
415  
416  #endif /* #ifndef _IF_ATH_DEBUG_H_ */
417 Index: madwifi-trunk-r3776/ath/if_ath_pci.c
418 ===================================================================
419 --- madwifi-trunk-r3776.orig/ath/if_ath_pci.c   2008-07-17 00:21:39.000000000 +0200
420 +++ madwifi-trunk-r3776/ath/if_ath_pci.c        2008-07-17 00:53:20.000000000 +0200
421 @@ -134,8 +134,10 @@
422         u16 vdevice;
423         int i;
424  
425 -       if (pci_enable_device(pdev))
426 +       if (pci_enable_device(pdev)) {
427 +               printk(KERN_ERR "%s: failed to enable PCI device\n", dev_info);
428                 return -EIO;
429 +       }
430  
431         /* XXX 32-bit addressing only */
432         if (pci_set_dma_mask(pdev, 0xffffffff)) {
433 @@ -244,8 +246,10 @@
434                 sc->aps_sc.sc_ledpin = 1;
435         }
436  
437 -       if (ath_attach(vdevice, dev, NULL) != 0)
438 +       if ((i = ath_attach(vdevice, dev, NULL)) != 0) {
439 +               printk(KERN_ERR "%s: ath_attach failed: %d\n", dev_info, i);
440                 goto bad4;
441 +       }
442  
443         athname = ath_hal_probe(id->vendor, vdevice);
444         printk(KERN_INFO "%s: %s: %s: mem=0x%llx, irq=%d\n",