Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 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 _MSGTRACE_H |
| 18 | #define _MSGTRACE_H |
| 19 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 20 | /* This marks the start of a packed structure section. */ |
| 21 | #include <packed_section_start.h> |
| 22 | |
| 23 | #define MSGTRACE_VERSION 1 |
| 24 | |
| 25 | /* Message trace header */ |
| 26 | typedef BWL_PRE_PACKED_STRUCT struct msgtrace_hdr { |
Greg Kroah-Hartman | de9bca6 | 2010-10-05 10:23:40 -0700 | [diff] [blame] | 27 | u8 version; |
| 28 | u8 spare; |
Greg Kroah-Hartman | 7d4df48 | 2010-10-07 17:04:47 -0700 | [diff] [blame] | 29 | u16 len; /* Len of the trace */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 30 | u32 seqnum; /* Sequence number of message. Useful |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 31 | * if the messsage has been lost |
| 32 | * because of DMA error or a bus reset |
| 33 | * (ex: SDIO Func2) |
| 34 | */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 35 | u32 discarded_bytes; /* Number of discarded bytes because of |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 36 | trace overflow */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 37 | u32 discarded_printf; /* Number of discarded printf |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 38 | because of trace overflow */ |
| 39 | } BWL_POST_PACKED_STRUCT msgtrace_hdr_t; |
| 40 | |
| 41 | #define MSGTRACE_HDRLEN sizeof(msgtrace_hdr_t) |
| 42 | |
| 43 | /* The hbus driver generates traces when sending a trace message. |
| 44 | * This causes endless traces. |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 45 | * This flag must be set to true in any hbus traces. |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 46 | * The flag is reset in the function msgtrace_put. |
| 47 | * This prevents endless traces but generates hasardous |
| 48 | * lost of traces only in bus device code. |
| 49 | * It is recommendat to set this flag in macro SD_TRACE |
| 50 | * but not in SD_ERROR for avoiding missing |
| 51 | * hbus error traces. hbus error trace should not generates endless traces. |
| 52 | */ |
| 53 | extern bool msgtrace_hbus_trace; |
| 54 | |
Greg Kroah-Hartman | de9bca6 | 2010-10-05 10:23:40 -0700 | [diff] [blame] | 55 | typedef void (*msgtrace_func_send_t) (void *hdl1, void *hdl2, u8 *hdr, |
Greg Kroah-Hartman | 7d4df48 | 2010-10-07 17:04:47 -0700 | [diff] [blame] | 56 | u16 hdrlen, u8 *buf, |
| 57 | u16 buflen); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 58 | |
| 59 | extern void msgtrace_sent(void); |
| 60 | extern void msgtrace_put(char *buf, int count); |
| 61 | extern void msgtrace_init(void *hdl1, void *hdl2, |
| 62 | msgtrace_func_send_t func_send); |
| 63 | |
| 64 | /* This marks the end of a packed structure section. */ |
| 65 | #include <packed_section_end.h> |
| 66 | |
| 67 | #endif /* _MSGTRACE_H */ |