1d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez/* 2d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * Copyright (c) 2008-2009 Atheros Communications Inc. 3d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * 4d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * Permission to use, copy, modify, and/or distribute this software for any 5d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * purpose with or without fee is hereby granted, provided that the above 6d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * copyright notice and this permission notice appear in all copies. 7d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * 8d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez */ 16d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez 17d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez#ifndef ATH_H 18d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez#define ATH_H 19d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez 20d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez#include <linux/skbuff.h> 21bcd8f54a84ce99ade91c250a9bc850a9fd3389c1Luis R. Rodriguez#include <linux/if_ether.h> 22b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau#include <linux/spinlock.h> 23b002a4a950e41326310795cf4a0c74d0e90fa70aLuis R. Rodriguez#include <net/mac80211.h> 24d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez 257e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez/* 267e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez * The key cache is used for h/w cipher state and also for 277e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez * tracking station state such as the current tx antenna. 287e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez * We also setup a mapping table between key cache slot indices 297e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez * and station state to short-circuit node lookups on rx. 307e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez * Different parts have different size key caches. We handle 317e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez * up to ATH_KEYMAX entries (could dynamically allocate state). 327e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez */ 337e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez#define ATH_KEYMAX 128 /* max key cache size we handle */ 347e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez 3517753748e15eaf29c8db15c5c05b8dde5db6e64dLuis R. Rodriguezstatic const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 3617753748e15eaf29c8db15c5c05b8dde5db6e64dLuis R. Rodriguez 373d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguezstruct ath_ani { 383d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez bool caldone; 393d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez unsigned int longcal_timer; 403d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez unsigned int shortcal_timer; 413d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez unsigned int resetcal_timer; 423d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez unsigned int checkani_timer; 433d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez struct timer_list timer; 443d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez}; 453d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez 46b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkaustruct ath_cycle_counters { 47b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau u32 cycles; 48b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau u32 rx_busy; 49b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau u32 rx_frame; 50b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau u32 tx_frame; 51b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau}; 52b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau 53211f5859af951788a3fe4752142a5e9047afa5d8Luis R. Rodriguezenum ath_device_state { 54211f5859af951788a3fe4752142a5e9047afa5d8Luis R. Rodriguez ATH_HW_UNAVAILABLE, 55211f5859af951788a3fe4752142a5e9047afa5d8Luis R. Rodriguez ATH_HW_INITIALIZED, 56211f5859af951788a3fe4752142a5e9047afa5d8Luis R. Rodriguez}; 57211f5859af951788a3fe4752142a5e9047afa5d8Luis R. Rodriguez 58497ad9adf44013dc9054f80c627acc44d4c90d37Sujithenum ath_bus_type { 59497ad9adf44013dc9054f80c627acc44d4c90d37Sujith ATH_PCI, 60497ad9adf44013dc9054f80c627acc44d4c90d37Sujith ATH_AHB, 61497ad9adf44013dc9054f80c627acc44d4c90d37Sujith ATH_USB, 62497ad9adf44013dc9054f80c627acc44d4c90d37Sujith}; 63497ad9adf44013dc9054f80c627acc44d4c90d37Sujith 64608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguezstruct reg_dmn_pair_mapping { 65608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez u16 regDmnEnum; 66608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez u16 reg_5ghz_ctl; 67608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez u16 reg_2ghz_ctl; 68608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez}; 69608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez 70608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguezstruct ath_regulatory { 71608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez char alpha2[2]; 72608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez u16 country_code; 73608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez u16 max_power_level; 74608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez u16 current_rd; 75608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez int16_t power_limit; 76608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez struct reg_dmn_pair_mapping *regpair; 77608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez}; 78608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez 7934a1305137f484ee1806df5a00b9d8ee8d4ef758Bruno Randolfenum ath_crypt_caps { 80ce2220d1da0bad9583af38a03ad508968d554c0fBruno Randolf ATH_CRYPT_CAP_CIPHER_AESCCM = BIT(0), 81ce2220d1da0bad9583af38a03ad508968d554c0fBruno Randolf ATH_CRYPT_CAP_MIC_COMBINED = BIT(1), 8234a1305137f484ee1806df5a00b9d8ee8d4ef758Bruno Randolf}; 8334a1305137f484ee1806df5a00b9d8ee8d4ef758Bruno Randolf 841bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolfstruct ath_keyval { 851bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf u8 kv_type; 861bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf u8 kv_pad; 871bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf u16 kv_len; 881bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf u8 kv_val[16]; /* TK */ 891bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf u8 kv_mic[8]; /* Michael MIC key */ 901bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf u8 kv_txmic[8]; /* Michael MIC TX key (used only if the hardware 911bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf * supports both MIC keys in the same key cache entry; 921bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf * in that case, kv_mic is the RX key) */ 931bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf}; 941bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf 951bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolfenum ath_cipher { 961bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf ATH_CIPHER_WEP = 0, 971bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf ATH_CIPHER_AES_OCB = 1, 981bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf ATH_CIPHER_AES_CCM = 2, 991bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf ATH_CIPHER_CKIP = 3, 1001bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf ATH_CIPHER_TKIP = 4, 1011bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf ATH_CIPHER_CLR = 5, 1021bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf ATH_CIPHER_MIC = 127 1031bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf}; 1041bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf 10550f56316aed044e42c1bcd7572926e80aac9af46Sujith/** 10650f56316aed044e42c1bcd7572926e80aac9af46Sujith * struct ath_ops - Register read/write operations 10750f56316aed044e42c1bcd7572926e80aac9af46Sujith * 10850f56316aed044e42c1bcd7572926e80aac9af46Sujith * @read: Register read 10909a525d33870e8a16076ec0200cc5002f6bef35dSujith Manoharan * @multi_read: Multiple register read 11050f56316aed044e42c1bcd7572926e80aac9af46Sujith * @write: Register write 11150f56316aed044e42c1bcd7572926e80aac9af46Sujith * @enable_write_buffer: Enable multiple register writes 112435c1610f46dc4d86a6633adb037b18109e6ffdcFelix Fietkau * @write_flush: flush buffered register writes and disable buffering 11350f56316aed044e42c1bcd7572926e80aac9af46Sujith */ 1149e4bffd233f27fe83fc48efb01935aee7d0685bfLuis R. Rodriguezstruct ath_ops { 1159e4bffd233f27fe83fc48efb01935aee7d0685bfLuis R. Rodriguez unsigned int (*read)(void *, u32 reg_offset); 11609a525d33870e8a16076ec0200cc5002f6bef35dSujith Manoharan void (*multi_read)(void *, u32 *addr, u32 *val, u16 count); 11750f56316aed044e42c1bcd7572926e80aac9af46Sujith void (*write)(void *, u32 val, u32 reg_offset); 11850f56316aed044e42c1bcd7572926e80aac9af46Sujith void (*enable_write_buffer)(void *); 11950f56316aed044e42c1bcd7572926e80aac9af46Sujith void (*write_flush) (void *); 120845e03c93dda2c00ffb5c68a1f7c8efc412d7c1aFelix Fietkau u32 (*rmw)(void *, u32 reg_offset, u32 set, u32 clr); 1219e4bffd233f27fe83fc48efb01935aee7d0685bfLuis R. Rodriguez}; 1229e4bffd233f27fe83fc48efb01935aee7d0685bfLuis R. Rodriguez 1235bb127913299b37fceecf66ce86ee8ede70e7d13Luis R. Rodriguezstruct ath_common; 1240cb9e06b6359bfa82f46c38a0b43e72d90b84081Felix Fietkaustruct ath_bus_ops; 1255bb127913299b37fceecf66ce86ee8ede70e7d13Luis R. Rodriguez 126d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguezstruct ath_common { 12713b81559200b8e54473e5b140323cbb5f2bb21c0Luis R. Rodriguez void *ah; 128bc974f4a230756faf4f69114f271de2e678b363bLuis R. Rodriguez void *priv; 129b002a4a950e41326310795cf4a0c74d0e90fa70aLuis R. Rodriguez struct ieee80211_hw *hw; 130c46917bb53a546f60c7d3103407fe953c418dd5bLuis R. Rodriguez int debug_mask; 131211f5859af951788a3fe4752142a5e9047afa5d8Luis R. Rodriguez enum ath_device_state state; 132c46917bb53a546f60c7d3103407fe953c418dd5bLuis R. Rodriguez 1333d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez struct ath_ani ani; 1343d536acf45ba65acb15fc65bf46f8d6c7ad6c463Luis R. Rodriguez 135d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez u16 cachelsz; 1361510718d0fd6e20803aac95fe1d8a44846098a34Luis R. Rodriguez u16 curaid; 1371510718d0fd6e20803aac95fe1d8a44846098a34Luis R. Rodriguez u8 macaddr[ETH_ALEN]; 1381510718d0fd6e20803aac95fe1d8a44846098a34Luis R. Rodriguez u8 curbssid[ETH_ALEN]; 1391510718d0fd6e20803aac95fe1d8a44846098a34Luis R. Rodriguez u8 bssidmask[ETH_ALEN]; 140c46917bb53a546f60c7d3103407fe953c418dd5bLuis R. Rodriguez 141cc861f7468724e66567baf087b4e413e91b18150Luis R. Rodriguez u32 rx_bufsize; 142cc861f7468724e66567baf087b4e413e91b18150Luis R. Rodriguez 1437e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez u32 keymax; 1447e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez DECLARE_BITMAP(keymap, ATH_KEYMAX); 14556363ddeeed3afc5277ca227209773bc1042cc7bFelix Fietkau DECLARE_BITMAP(tkip_keymap, ATH_KEYMAX); 146aeb0da0b585868aed04e53afd1234791efcfac08Felix Fietkau DECLARE_BITMAP(ccmp_keymap, ATH_KEYMAX); 14734a1305137f484ee1806df5a00b9d8ee8d4ef758Bruno Randolf enum ath_crypt_caps crypt_caps; 1487e86c1048a9f5f1e157daf28411f3526f0b9f7b6Luis R. Rodriguez 149dfdac8ac033c9ad048a5c68563bd41bda6c5e60bFelix Fietkau unsigned int clockrate; 150dfdac8ac033c9ad048a5c68563bd41bda6c5e60bFelix Fietkau 151b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau spinlock_t cc_lock; 152b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau struct ath_cycle_counters cc_ani; 153b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau struct ath_cycle_counters cc_survey; 154b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkau 155608b88cb34b0e70a538ee1fc334cc833ef691836Luis R. Rodriguez struct ath_regulatory regulatory; 156de1c732b1891a25f3f2f52ef7211a3d567bbd588Luis R. Rodriguez struct ath_regulatory reg_world_copy; 1579adca126dbf4bf099bc7051deb6b566725a046dcLuis R. Rodriguez const struct ath_ops *ops; 1585bb127913299b37fceecf66ce86ee8ede70e7d13Luis R. Rodriguez const struct ath_bus_ops *bus_ops; 1598f5dcb1cfb71ce832f53a4723deba72e6695078bVasanthakumar Thiagarajan 1608f5dcb1cfb71ce832f53a4723deba72e6695078bVasanthakumar Thiagarajan bool btcoex_enabled; 16105c0be2f7f10404e5b3bc4105f9206096e9b8767Mohammed Shafi Shajakhan bool disable_ani; 162d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez}; 163d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez 164d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguezstruct sk_buff *ath_rxbuf_alloc(struct ath_common *common, 165d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez u32 len, 166d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez gfp_t gfp_mask); 167d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez 16813b81559200b8e54473e5b140323cbb5f2bb21c0Luis R. Rodriguezvoid ath_hw_setbssidmask(struct ath_common *common); 1691bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolfvoid ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key); 1701bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolfint ath_key_config(struct ath_common *common, 1711bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf struct ieee80211_vif *vif, 1721bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf struct ieee80211_sta *sta, 1731bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolf struct ieee80211_key_conf *key); 1741bba5b7329e15555dab90071b24ca84d0afcc635Bruno Randolfbool ath_hw_keyreset(struct ath_common *common, u16 entry); 175b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkauvoid ath_hw_cycle_counters_update(struct ath_common *common); 176b5bfc5683db44a121ad47ec0a9f4efd4aac040e0Felix Fietkauint32_t ath_hw_get_listen_time(struct ath_common *common); 17713b81559200b8e54473e5b140323cbb5f2bb21c0Luis R. Rodriguez 17898b36a029550def4b3e76cc44d4345bf20a729bdBen Greear__printf(3, 4) 17998b36a029550def4b3e76cc44d4345bf20a729bdBen Greearvoid ath_printk(const char *level, const struct ath_common *common, 18098b36a029550def4b3e76cc44d4345bf20a729bdBen Greear const char *fmt, ...); 18121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 18221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ath_emerg(common, fmt, ...) \ 18398b36a029550def4b3e76cc44d4345bf20a729bdBen Greear ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__) 18421a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ath_alert(common, fmt, ...) \ 18598b36a029550def4b3e76cc44d4345bf20a729bdBen Greear ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__) 18621a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ath_crit(common, fmt, ...) \ 18798b36a029550def4b3e76cc44d4345bf20a729bdBen Greear ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__) 18821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ath_err(common, fmt, ...) \ 18998b36a029550def4b3e76cc44d4345bf20a729bdBen Greear ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__) 19021a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ath_warn(common, fmt, ...) \ 19198b36a029550def4b3e76cc44d4345bf20a729bdBen Greear ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__) 19221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ath_notice(common, fmt, ...) \ 19398b36a029550def4b3e76cc44d4345bf20a729bdBen Greear ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__) 19421a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ath_info(common, fmt, ...) \ 19598b36a029550def4b3e76cc44d4345bf20a729bdBen Greear ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__) 19621a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 19721a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches/** 19821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * enum ath_debug_level - atheros wireless debug level 19921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * 20021a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_RESET: reset processing 20121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_QUEUE: hardware queue management 20221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_EEPROM: eeprom processing 20321a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_CALIBRATE: periodic calibration 20421a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_INTERRUPT: interrupt processing 20521a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_REGULATORY: regulatory processing 20621a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_ANI: adaptive noise immunitive processing 20721a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_XMIT: basic xmit operation 20821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_BEACON: beacon handling 20921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_CONFIG: configuration of the hardware 21021a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_FATAL: fatal errors, this is the default, DBG_DEFAULT 21121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_PS: power save processing 21221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_HWTIMER: hardware timer handling 21321a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_BTCOEX: bluetooth coexistance 21421a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_BSTUCK: stuck beacons 21555e435de9153581fda21631f0e68bb793072234dLuis R. Rodriguez * @ATH_DBG_MCI: Message Coexistence Interface, a private protocol 21655e435de9153581fda21631f0e68bb793072234dLuis R. Rodriguez * used exclusively for WLAN-BT coexistence starting from 21755e435de9153581fda21631f0e68bb793072234dLuis R. Rodriguez * AR9462. 2189b203c8fc2aa05d7bc28261d7c2bee52a0945789Zefir Kurtisi * @ATH_DBG_DFS: radar datection 21921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * @ATH_DBG_ANY: enable all debugging 22021a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * 22121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * The debug level is used to control the amount and type of debugging output 22221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * we want to see. Each driver has its own method for enabling debugging and 22321a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * modifying debug level states -- but this is typically done through a 22421a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * module parameter 'debug' along with a respective 'debug' debugfs file 22521a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches * entry. 22621a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches */ 22721a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perchesenum ATH_DEBUG { 22821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_RESET = 0x00000001, 22921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_QUEUE = 0x00000002, 23021a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_EEPROM = 0x00000004, 23121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_CALIBRATE = 0x00000008, 23221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_INTERRUPT = 0x00000010, 23321a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_REGULATORY = 0x00000020, 23421a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_ANI = 0x00000040, 23521a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_XMIT = 0x00000080, 23621a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_BEACON = 0x00000100, 23721a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_CONFIG = 0x00000200, 23821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_FATAL = 0x00000400, 23921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_PS = 0x00000800, 24021a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_HWTIMER = 0x00001000, 24121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_BTCOEX = 0x00002000, 24221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_WMI = 0x00004000, 24321a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_BSTUCK = 0x00008000, 2447dc181c273861c4d96991f59a4fdcda3a3eaccaeRajkumar Manoharan ATH_DBG_MCI = 0x00010000, 2459b203c8fc2aa05d7bc28261d7c2bee52a0945789Zefir Kurtisi ATH_DBG_DFS = 0x00020000, 24621a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches ATH_DBG_ANY = 0xffffffff 24721a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches}; 24821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 24921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ATH_DBG_DEFAULT (ATH_DBG_FATAL) 25021a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 25121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#ifdef CONFIG_ATH_DEBUG 25221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 2537b8112d6db0cc67dd2a722ca5bf707768890ac9dJoe Perches#define ath_dbg(common, dbg_mask, fmt, ...) \ 2547b8112d6db0cc67dd2a722ca5bf707768890ac9dJoe Perchesdo { \ 255d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perches if ((common)->debug_mask & ATH_DBG_##dbg_mask) \ 25698b36a029550def4b3e76cc44d4345bf20a729bdBen Greear ath_printk(KERN_DEBUG, common, fmt, ##__VA_ARGS__); \ 2577b8112d6db0cc67dd2a722ca5bf707768890ac9dJoe Perches} while (0) 2587b8112d6db0cc67dd2a722ca5bf707768890ac9dJoe Perches 25921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ATH_DBG_WARN(foo, arg...) WARN(foo, arg) 260d7fd1b50a51be3fe6554fbab8953fa8a3ff4009bBen Greear#define ATH_DBG_WARN_ON_ONCE(foo) WARN_ON_ONCE(foo) 26121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 26221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#else 26321a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 264b9075fa968a0a4347aef35e235e2995c0e57ddddJoe Perchesstatic inline __attribute__ ((format (printf, 3, 4))) 265d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perchesvoid _ath_dbg(struct ath_common *common, enum ATH_DEBUG dbg_mask, 2667b8112d6db0cc67dd2a722ca5bf707768890ac9dJoe Perches const char *fmt, ...) 26721a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches{ 26821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches} 269d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perches#define ath_dbg(common, dbg_mask, fmt, ...) \ 270d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perches _ath_dbg(common, ATH_DBG_##dbg_mask, fmt, ##__VA_ARGS__) 271d2182b69dcb6a68b1ef6070b2efd094e13dea3f1Joe Perches 27221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#define ATH_DBG_WARN(foo, arg...) do {} while (0) 273b7613370db5ba66ad81e41cd3a5417fde4d5e03cJohn W. Linville#define ATH_DBG_WARN_ON_ONCE(foo) ({ \ 274b7613370db5ba66ad81e41cd3a5417fde4d5e03cJohn W. Linville int __ret_warn_once = !!(foo); \ 275b7613370db5ba66ad81e41cd3a5417fde4d5e03cJohn W. Linville unlikely(__ret_warn_once); \ 276b7613370db5ba66ad81e41cd3a5417fde4d5e03cJohn W. Linville}) 27721a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 27821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#endif /* CONFIG_ATH_DEBUG */ 27921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 28021a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches/** Returns string describing opmode, or NULL if unknown mode. */ 28121a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#ifdef CONFIG_ATH_DEBUG 28221a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perchesconst char *ath_opmode_to_string(enum nl80211_iftype opmode); 28321a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#else 28421a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perchesstatic inline const char *ath_opmode_to_string(enum nl80211_iftype opmode) 28521a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches{ 28621a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches return "UNKNOWN"; 28721a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches} 28821a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches#endif 28921a99f934949807dc0c9dc7642bbf0081b7582f9Joe Perches 290d15dd3e5d74186a3b0a4db271b440bbdc0f6da36Luis R. Rodriguez#endif /* ATH_H */ 291