1  /*
2   * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
3   * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
4   *
5   * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
6   *
7   *
8   * Permission to use, copy, modify, and/or distribute this software for
9   * any purpose with or without fee is hereby granted, provided that the
10   * above copyright notice and this permission notice appear in all
11   * copies.
12   *
13   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
14   * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
15   * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
16   * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
17   * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
18   * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19   * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20   * PERFORMANCE OF THIS SOFTWARE.
21   */
22  
23  /*
24   * This file was originally distributed by Qualcomm Atheros, Inc.
25   * under proprietary terms before Copyright ownership was assigned
26   * to the Linux Foundation.
27   */
28  
29  #ifndef _DBGLOG_H_
30  #define _DBGLOG_H_
31  
32  #ifndef ATH_TARGET
33  #include "athstartpack.h"
34  #endif
35  
36  #include <a_types.h> /* A_UINT32 */
37  #include <a_osapi.h> /* PREPACK */
38  #include <wlan_module_ids.h>
39  
40  #ifdef __cplusplus
41  extern "C" {
42  #endif
43  #define DBGLOG_TIMESTAMP_OFFSET          0
44  #define DBGLOG_TIMESTAMP_MASK            0xFFFFFFFF /* Bit 0-15. Contains bit
45                                                         8-23 of the LF0 timer */
46  #define DBGLOG_DBGID_OFFSET              0
47  #define DBGLOG_DBGID_MASK                0x000003FF /* Bit 0-9 */
48  #define DBGLOG_DBGID_NUM_MAX             256 /* Upper limit is width of mask */
49  
50  #define DBGLOG_MODULEID_OFFSET           10
51  #define DBGLOG_MODULEID_MASK             0x0003FC00 /* Bit 10-17 */
52  #define DBGLOG_MODULEID_NUM_MAX          32 /* Upper limit is width of mask */
53  
54  #define DBGLOG_VDEVID_OFFSET              18
55  #define DBGLOG_VDEVID_MASK                0x03FC0000 /* Bit 20-25*/
56  #define DBGLOG_VDEVID_NUM_MAX             16
57  
58  #define DBGLOG_NUM_ARGS_OFFSET             26
59  #define DBGLOG_NUM_ARGS_MASK               0xFC000000 /* Bit 26-31 */
60  #define DBGLOG_NUM_ARGS_MAX                9 /* it is bcoz of limitation
61                                               of corebsp MSG*() to accept max 9 arg  */
62  
63  #define DBGLOG_LOG_BUFFER_SIZE             1500
64  #define DBGLOG_DBGID_DEFINITION_LEN_MAX    90
65  
66  #define DBGLOG_HOST_LOG_BUFFER_SIZE            DBGLOG_LOG_BUFFER_SIZE
67  
68  #define DBGLOG_GET_DBGID(arg) \
69      ((arg & DBGLOG_DBGID_MASK) >> DBGLOG_DBGID_OFFSET)
70  
71  #define DBGLOG_GET_MODULEID(arg) \
72      ((arg & DBGLOG_MODULEID_MASK) >> DBGLOG_MODULEID_OFFSET)
73  
74  #define DBGLOG_GET_VDEVID(arg) \
75      ((arg & DBGLOG_VDEVID_MASK) >> DBGLOG_VDEVID_OFFSET)
76  
77  #define DBGLOG_GET_NUMARGS(arg) \
78      ((arg & DBGLOG_NUM_ARGS_MASK) >> DBGLOG_NUM_ARGS_OFFSET)
79  
80  #define DBGLOG_GET_TIME_STAMP(arg) \
81      ((arg & DBGLOG_TIMESTAMP_MASK) >> DBGLOG_TIMESTAMP_OFFSET)
82  
83  
84  /* Debug Log levels*/
85  
86  typedef enum {
87  	DBGLOG_ML = 0,
88      DBGLOG_VERBOSE = 0,
89      DBGLOG_INFO,
90      DBGLOG_INFO_LVL_1,
91      DBGLOG_INFO_LVL_2,
92      DBGLOG_WARN,
93      DBGLOG_ERR,
94      DBGLOG_LVL_MAX,
95  
96      DBGLOG_INVALID = 0xf
97  }DBGLOG_LOG_LVL;
98  
99  PREPACK struct dbglog_buf_s {
100      struct dbglog_buf_s *next;
101      A_UINT8             *buffer;
102      A_UINT32             bufsize;
103      A_UINT32             length;
104      A_UINT32             count;
105      A_UINT32             free;
106  } POSTPACK;
107  
108  PREPACK struct dbglog_hdr_s {
109      struct dbglog_buf_s *dbuf;
110      A_UINT32             dropped;
111  } POSTPACK;
112  
113  #define DBGLOG_MAX_VDEVID 15 /* 0-15 */
114  
115  #ifdef __cplusplus
116  }
117  #endif
118  
119  
120  #endif /* _DBGLOG_H_ */
121