1/** \file report.h
2 *  \brief Report module API
3 *
4 *  \see report.c
5 */
6/****************************************************************************
7**+-----------------------------------------------------------------------+**
8**|                                                                       |**
9**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
10**| All rights reserved.                                                  |**
11**|                                                                       |**
12**| Redistribution and use in source and binary forms, with or without    |**
13**| modification, are permitted provided that the following conditions    |**
14**| are met:                                                              |**
15**|                                                                       |**
16**|  * Redistributions of source code must retain the above copyright     |**
17**|    notice, this list of conditions and the following disclaimer.      |**
18**|  * Redistributions in binary form must reproduce the above copyright  |**
19**|    notice, this list of conditions and the following disclaimer in    |**
20**|    the documentation and/or other materials provided with the         |**
21**|    distribution.                                                      |**
22**|  * Neither the name Texas Instruments nor the names of its            |**
23**|    contributors may be used to endorse or promote products derived    |**
24**|    from this software without specific prior written permission.      |**
25**|                                                                       |**
26**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
27**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
28**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
29**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
30**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
31**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
32**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
33**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
34**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
35**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
36**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
37**|                                                                       |**
38**+-----------------------------------------------------------------------+**
39****************************************************************************/
40
41/***************************************************************************/
42/*                                                                          */
43/*    MODULE:   report.h                                                    */
44/*    PURPOSE:  Report module internal header API                           */
45/*                                                                          */
46/***************************************************************************/
47#ifndef __REPORT_H__
48#define __REPORT_H__
49
50#include "osTIType.h"
51#include "commonTypes.h"
52#include "osApi.h"
53#include "utils.h"
54
55/* report handle */
56
57#define MAX_STRING_LEN              128
58
59typedef struct
60{
61    TI_HANDLE       hOs;
62    tiUINT8         SeverityTable[WLAN_MAX_SEVERITIES];
63    tiUINT8         ModuleTable[WLAN_MAX_LOG_MODULES];
64    char            moduleDesc[WLAN_MAX_LOG_MODULES][MAX_STRING_LEN];
65} report_t;
66
67
68/* The report mechanism is like that:
69    Each module ahas a report flag. Each severity has a severity flag.
70    Only if bits are enabled, the message is printed */
71/* The modules which have their report flag enable are indicated by a bit map in the reportModule
72    variable contained in the report handle*/
73/* The severities which have are enabled are indicated by a bit map in the reportSeverity
74    variable contained in the report handle*/
75
76#ifdef REPORT_LOG
77
78
79#define WLAN_REPORT_INIT(hReport, module, msg)                        \
80    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_INIT])       && (((report_t *)hReport)->ModuleTable[module]))  \
81       { os_report ("$B%c%s,INIT:",             ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
82#define WLAN_REPORT_INFORMATION(hReport, module, msg)                 \
83    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_INFORMATION]) && (((report_t *)hReport)->ModuleTable[module])) \
84       { os_report ("$C%c%s,INFORMATION:",      ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
85#define WLAN_REPORT_WARNING(hReport, module, msg)                     \
86    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_WARNING])                                                      \
87       { os_report ("$D%c%s,WARNING:",          ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
88#define WLAN_REPORT_ERROR(hReport, module, msg)                       \
89    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_ERROR])                                                        \
90       { os_report ("$E%c%s,ERROR:",            ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
91#define WLAN_REPORT_FATAL_ERROR(hReport, module, msg)                 \
92    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_FATAL_ERROR]) && (((report_t *)hReport)->ModuleTable[module])) \
93       { os_report ("$F%c%s,FATAL ERROR:",      ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
94#define WLAN_REPORT_SM(hReport, module, msg)                          \
95    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_SM])                                                           \
96       { os_report ("$G%c%s,SM:",               ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
97#define WLAN_REPORT_CONSOLE(hReport, module, msg)                     \
98    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_CONSOLE])    && (((report_t *)hReport)->ModuleTable[module]))  \
99       { os_report ("$H%c%s,CONSOLE:",          ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
100#define WLAN_REPORT_DEBUG_RX(hReport, msg)                            \
101    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_DEBUG_RX])                                                     \
102       { os_report ("$AA,DEBUG RX:");                                                                                os_report msg; } } while(0)
103#define WLAN_REPORT_DEBUG_TX(hReport, msg)                            \
104    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_DEBUG_TX])                                                     \
105       { os_report ("$AA,DEBUG TX:");                                                                                os_report msg; } } while(0)
106#define WLAN_REPORT_DEBUG_CONTROL(hReport, msg)                       \
107    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_DEBUG_CONTROL])                                                \
108       { os_report ("$AA,DEBUG CONTROL:");                                                                           os_report msg; } } while(0)
109#define WLAN_REPORT_GWSI_RECORDING(hReport, msg)                      \
110    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_GWSI_RECORDING])                                               \
111       { os_report ("$AA,GWSI RECORDING:");                                                                          os_report msg; } } while(0)
112#define WLAN_REPORT_HEX_INFORMATION(hReport, module, data, datalen)   \
113    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_INFORMATION]) && (((report_t *)hReport)->ModuleTable[module])) \
114       { HexDumpData(data, datalen); } } while(0)
115#define WLAN_REPORT_MSDU_INFORMATION(hReport, module, pMsdu, title)   \
116    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_INFORMATION]) && (((report_t *)hReport)->ModuleTable[module])) \
117       { msduContentDump(pMsdu, title); } } while(0)
118#define WLAN_OS_REPORT(msg)                                           \
119    do { os_report("$AA"); os_report msg;} while(0)
120
121#ifdef INIT_MESSAGES
122#define WLAN_INIT_REPORT(msg)                                         \
123    do { os_report("$AA"); os_report msg;} while(0)
124#else
125#define WLAN_INIT_REPORT(msg)
126#endif
127
128#else   /* REPORT_LOG */
129
130
131/* NOTE: Keep a dummy report function call to treat compilation warnings */
132
133
134#define WLAN_REPORT_INIT(hReport,module,msg)                          \
135    do { if (hReport == NULL) { } } while (0)
136#define WLAN_REPORT_INFORMATION(hReport,module,msg)                   \
137    do { if (hReport == NULL) { } } while (0)
138#define WLAN_REPORT_WARNING(hReport,module,msg)                       \
139    do { if (hReport == NULL) { } } while (0)
140#define WLAN_REPORT_ERROR(hReport,module,msg)                         \
141    do { if (hReport == NULL) { } } while (0)
142#define WLAN_REPORT_FATAL_ERROR(hReport,module,msg)                   \
143    do { if (hReport == NULL) { } } while (0)
144#define WLAN_REPORT_SM(hReport,module,msg)                            \
145    do { if (hReport == NULL) { } } while (0)
146#define WLAN_REPORT_CONSOLE(hReport,module,msg)                       \
147    do { if (hReport == NULL) { } } while (0)
148#define WLAN_REPORT_HEX_INFORMATION(hReport,module,data,datalen)      \
149    do { if (hReport == NULL) { } } while (0)
150#define WLAN_REPORT_DEBUG_RX(hReport,msg)                             \
151    do { if (hReport == NULL) { } } while (0)
152#define WLAN_REPORT_DEBUG_TX(hReport,msg)                             \
153    do { if (hReport == NULL) { } } while (0)
154#define WLAN_REPORT_DEBUG_CONTROL(hReport,msg)                        \
155    do { if (hReport == NULL) { } } while (0)
156#define WLAN_REPORT_GWSI_RECORDING(hReport,msg)                       \
157    do { if (hReport == NULL) { } } while (0)
158#define WLAN_REPORT_MSDU_INFORMATION(hReport,module,pMsdu,title)      \
159    do { if (hReport == NULL) { } } while (0)
160#define WLAN_OS_REPORT(msg)                                           \
161    do { } while (0)
162#define WLAN_INIT_REPORT(msg)                                         \
163    do { } while (0)
164
165#endif  /* REPORT_LOG */
166
167
168/* report module prototypes */
169TI_HANDLE report_create (TI_HANDLE hOs);
170TI_STATUS report_config (TI_HANDLE hReport, TI_HANDLE hOs, reportInitParams_t * init_params);
171TI_STATUS report_unLoad (TI_HANDLE hReport);
172
173void report_setReportModule (TI_HANDLE hReport, tiUINT8 module_index);
174void report_clearReportModule (TI_HANDLE hReport, tiUINT8 module_index);
175void report_getReportModuleTable (TI_HANDLE hReport, tiUINT8 *pModules);
176void report_setReportModuleTable (TI_HANDLE hReport, tiUINT8 *pModules);
177void report_setReportSeverity (TI_HANDLE hReport, tiUINT8 severity_index);
178void report_clearReportSeverity (TI_HANDLE hReport, tiUINT8 severity_index);
179void report_getReportSeverityTable (TI_HANDLE hReport, tiUINT8 *pSeverities);
180void report_setReportSeverityTable (TI_HANDLE hReport, tiUINT8 *pSeverities);
181TI_STATUS report_setParam (TI_HANDLE hReport, whalParamInfo_t *pParam);
182TI_STATUS report_getParam (TI_HANDLE hReport, whalParamInfo_t *pParam);
183void report_dummy (const char* fmt, ...);
184
185#endif /* __REPORT_H__ */
186