linux/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h
<<
>>
Prefs
   1/*
   2 * Copyright (c) 2010 Broadcom Corporation
   3 *
   4 * Permission to use, copy, modify, and/or distribute this software for any
   5 * purpose with or without fee is hereby granted, provided that the above
   6 * copyright notice and this permission notice appear in all copies.
   7 *
   8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15 */
  16
  17#ifndef _BRCMF_DBG_H_
  18#define _BRCMF_DBG_H_
  19
  20/* message levels */
  21#define BRCMF_TRACE_VAL 0x00000002
  22#define BRCMF_INFO_VAL  0x00000004
  23#define BRCMF_DATA_VAL  0x00000008
  24#define BRCMF_CTL_VAL   0x00000010
  25#define BRCMF_TIMER_VAL 0x00000020
  26#define BRCMF_HDRS_VAL  0x00000040
  27#define BRCMF_BYTES_VAL 0x00000080
  28#define BRCMF_INTR_VAL  0x00000100
  29#define BRCMF_GLOM_VAL  0x00000200
  30#define BRCMF_EVENT_VAL 0x00000400
  31#define BRCMF_BTA_VAL   0x00000800
  32#define BRCMF_FIL_VAL   0x00001000
  33#define BRCMF_USB_VAL   0x00002000
  34#define BRCMF_SCAN_VAL  0x00004000
  35#define BRCMF_CONN_VAL  0x00008000
  36#define BRCMF_CDC_VAL   0x00010000
  37#define BRCMF_SDIO_VAL  0x00020000
  38
  39/* set default print format */
  40#undef pr_fmt
  41#define pr_fmt(fmt)             KBUILD_MODNAME ": " fmt
  42
  43/* Macro for error messages. net_ratelimit() is used when driver
  44 * debugging is not selected. When debugging the driver error
  45 * messages are as important as other tracing or even more so.
  46 */
  47#ifndef CONFIG_BRCM_TRACING
  48#ifdef CONFIG_BRCMDBG
  49#define brcmf_err(fmt, ...)     pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
  50#else
  51#define brcmf_err(fmt, ...)                                             \
  52        do {                                                            \
  53                if (net_ratelimit())                                    \
  54                        pr_err("%s: " fmt, __func__, ##__VA_ARGS__);    \
  55        } while (0)
  56#endif
  57#else
  58__printf(2, 3)
  59void __brcmf_err(const char *func, const char *fmt, ...);
  60#define brcmf_err(fmt, ...) \
  61        __brcmf_err(__func__, fmt, ##__VA_ARGS__)
  62#endif
  63
  64#if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
  65__printf(3, 4)
  66void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...);
  67#define brcmf_dbg(level, fmt, ...)                              \
  68do {                                                            \
  69        __brcmf_dbg(BRCMF_##level##_VAL, __func__,              \
  70                    fmt, ##__VA_ARGS__);                        \
  71} while (0)
  72#define BRCMF_DATA_ON()         (brcmf_msg_level & BRCMF_DATA_VAL)
  73#define BRCMF_CTL_ON()          (brcmf_msg_level & BRCMF_CTL_VAL)
  74#define BRCMF_HDRS_ON()         (brcmf_msg_level & BRCMF_HDRS_VAL)
  75#define BRCMF_BYTES_ON()        (brcmf_msg_level & BRCMF_BYTES_VAL)
  76#define BRCMF_GLOM_ON()         (brcmf_msg_level & BRCMF_GLOM_VAL)
  77#define BRCMF_EVENT_ON()        (brcmf_msg_level & BRCMF_EVENT_VAL)
  78#define BRCMF_FIL_ON()          (brcmf_msg_level & BRCMF_FIL_VAL)
  79
  80#else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
  81
  82#define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
  83
  84#define BRCMF_DATA_ON()         0
  85#define BRCMF_CTL_ON()          0
  86#define BRCMF_HDRS_ON()         0
  87#define BRCMF_BYTES_ON()        0
  88#define BRCMF_GLOM_ON()         0
  89#define BRCMF_EVENT_ON()        0
  90#define BRCMF_FIL_ON()          0
  91
  92#endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
  93
  94#define brcmf_dbg_hex_dump(test, data, len, fmt, ...)                   \
  95do {                                                                    \
  96        trace_brcmf_hexdump((void *)data, len);                         \
  97        if (test)                                                       \
  98                brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__);      \
  99} while (0)
 100
 101extern int brcmf_msg_level;
 102
 103/*
 104 * hold counter variables used in brcmfmac sdio driver.
 105 */
 106struct brcmf_sdio_count {
 107        uint intrcount;         /* Count of device interrupt callbacks */
 108        uint lastintrs;         /* Count as of last watchdog timer */
 109        uint pollcnt;           /* Count of active polls */
 110        uint regfails;          /* Count of R_REG failures */
 111        uint tx_sderrs;         /* Count of tx attempts with sd errors */
 112        uint fcqueued;          /* Tx packets that got queued */
 113        uint rxrtx;             /* Count of rtx requests (NAK to dongle) */
 114        uint rx_toolong;        /* Receive frames too long to receive */
 115        uint rxc_errors;        /* SDIO errors when reading control frames */
 116        uint rx_hdrfail;        /* SDIO errors on header reads */
 117        uint rx_badhdr;         /* Bad received headers (roosync?) */
 118        uint rx_badseq;         /* Mismatched rx sequence number */
 119        uint fc_rcvd;           /* Number of flow-control events received */
 120        uint fc_xoff;           /* Number which turned on flow-control */
 121        uint fc_xon;            /* Number which turned off flow-control */
 122        uint rxglomfail;        /* Failed deglom attempts */
 123        uint rxglomframes;      /* Number of glom frames (superframes) */
 124        uint rxglompkts;        /* Number of packets from glom frames */
 125        uint f2rxhdrs;          /* Number of header reads */
 126        uint f2rxdata;          /* Number of frame data reads */
 127        uint f2txdata;          /* Number of f2 frame writes */
 128        uint f1regdata;         /* Number of f1 register accesses */
 129        uint tickcnt;           /* Number of watchdog been schedule */
 130        ulong tx_ctlerrs;       /* Err of sending ctrl frames */
 131        ulong tx_ctlpkts;       /* Ctrl frames sent to dongle */
 132        ulong rx_ctlerrs;       /* Err of processing rx ctrl frames */
 133        ulong rx_ctlpkts;       /* Ctrl frames processed from dongle */
 134        ulong rx_readahead_cnt; /* packets where header read-ahead was used */
 135};
 136
 137struct brcmf_fws_stats {
 138        u32 tlv_parse_failed;
 139        u32 tlv_invalid_type;
 140        u32 header_only_pkt;
 141        u32 header_pulls;
 142        u32 pkt2bus;
 143        u32 send_pkts[5];
 144        u32 requested_sent[5];
 145        u32 generic_error;
 146        u32 mac_update_failed;
 147        u32 mac_ps_update_failed;
 148        u32 if_update_failed;
 149        u32 packet_request_failed;
 150        u32 credit_request_failed;
 151        u32 rollback_success;
 152        u32 rollback_failed;
 153        u32 delayq_full_error;
 154        u32 supprq_full_error;
 155        u32 txs_indicate;
 156        u32 txs_discard;
 157        u32 txs_supp_core;
 158        u32 txs_supp_ps;
 159        u32 txs_tossed;
 160        u32 txs_host_tossed;
 161        u32 bus_flow_block;
 162        u32 fws_flow_block;
 163};
 164
 165struct brcmf_pub;
 166#ifdef DEBUG
 167void brcmf_debugfs_init(void);
 168void brcmf_debugfs_exit(void);
 169int brcmf_debugfs_attach(struct brcmf_pub *drvr);
 170void brcmf_debugfs_detach(struct brcmf_pub *drvr);
 171struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
 172void brcmf_debugfs_create_sdio_count(struct brcmf_pub *drvr,
 173                                     struct brcmf_sdio_count *sdcnt);
 174void brcmf_debugfs_create_fws_stats(struct brcmf_pub *drvr,
 175                                    struct brcmf_fws_stats *stats);
 176#else
 177static inline void brcmf_debugfs_init(void)
 178{
 179}
 180static inline void brcmf_debugfs_exit(void)
 181{
 182}
 183static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr)
 184{
 185        return 0;
 186}
 187static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr)
 188{
 189}
 190static inline void brcmf_debugfs_create_fws_stats(struct brcmf_pub *drvr,
 191                                                  struct brcmf_fws_stats *stats)
 192{
 193}
 194#endif
 195
 196#endif                          /* _BRCMF_DBG_H_ */
 197