summaryrefslogtreecommitdiff
path: root/network/wlan/WDI/COMMON/DrvLogImp.h
blob: b84846f817912aae204203d711cf89b218042958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef __INC_DRV_LOG_IMP_H
#define __INC_DRV_LOG_IMP_H

#include "DrvLog.h"

#if DRV_LOG

#define MAX_LOG_DESC_LEN 64
typedef struct _DRV_LOG_TYPE_ATTR_IMP_T
{
	unsigned int	MaxLogCountPwr; // 2's power, reprent for max number of logs of this type kept in driver, e.g. 5 means at most 2^5 logs kept.
	char			Description[MAX_LOG_DESC_LEN]; // Null terminated string.
}DRV_LOG_TYPE_ATTR_IMP_T, *PDRV_LOG_TYPE_ATTR_IMP_T;

typedef struct _DRV_LOG_ATTR_IMP_T
{
	unsigned int	Type; // Key to assoicated with DRV_LOG_TYPE_ATTRIBUTE_T.
	char			Description[MAX_LOG_DESC_LEN]; // Null terminated string.
}DRV_LOG_ATTR_IMP_T, *PDRV_LOG_ATTR_IMP_T;

#define MAX_LOG_BUFFER_LEN 256 // 070227, rcnjko: This is for max IE size is 255.
typedef struct _DRV_LOG_DATA_IMP_T
{
	unsigned int	Id; // Key to associated with DRV_LOG_ATTRIBUTE_T.
	unsigned int	TimeStampLow;
	unsigned int	TimeStampHigh;
	unsigned int	BufferLenUsed; 
	unsigned char	Buffer[MAX_LOG_BUFFER_LEN];
}DRV_LOG_DATA_IMP_T, *PDRV_LOG_DATA_IMP_T;

//
//	Description:
//		ID for each catagory of log. 
//		To add new type, one must also update g_LogTypes[].
//		We will allocate an DRV_LOG_POOL_T object for each type.
//
//
typedef enum _DRV_LOG_TYPE_E
{
	LTYPE_ERROR,
	LTYPE_DOT11D,

	LTYPE_TOTAL_COUNT, // Assumption: Always keep it in last one.
}DRV_LOG_TYPE_E;


//
//	Description:
//		ID for each log instance.
//		To add new log, one MUST also udpate g_LogAttributes[].
//
typedef enum _DRV_LOG_ID_E
{
	LID_DOT11D_RESET,
	LID_DOT11D_GET_COUNTRY_IE,
	LID_DOT11D_ACTIVE_SCAN_CHNL,
	LID_DOT11D_ACTIVE_SCAN_TXPWR,
	LID_DOT11D_PASSIVE_SCAN_CHNL,

	LID_TOTAL_COUNT, // Assumption: Always keep it in last one.
}DRV_LOG_ID_E;

extern DRV_LOG_TYPE_ATTR_IMP_T g_LogTypes[LTYPE_TOTAL_COUNT];
extern DRV_LOG_ATTR_IMP_T g_LogAttributes[LID_TOTAL_COUNT];

typedef struct _DRV_LOG_POOL_T
{
	unsigned int		LogStartIndex;
	unsigned int		LogCountUsed;
	PDRV_LOG_DATA_IMP_T	pLogDataRing;
}DRV_LOG_POOL_T, *PDRV_LOG_POOL_T;

#define GET_DRV_LOG_POOLS_HANDLE(__pAdapter) (DRV_LOG_POOL_T **)((__pAdapter)->ppLogPools)
//#define SET_DRV_LOG_POOLS_HANDLE(__pAdapter, __pTmp) GET_DRV_LOG_POOLS_HANDLE(__pAdapter) = (__pTmp)
#define SET_DRV_LOG_POOLS_HANDLE(__pAdapter, __pTmp) __pAdapter->ppLogPools = (void**)(__pTmp)


//
// Get pointer to specified log pool
//
#define GET_DRV_LOG_POOL(__pAdapter, __idx) (*(GET_DRV_LOG_POOLS_HANDLE(__pAdapter)+(__idx)))

//
// Set up address of specified pool.
//
#define SET_DRV_LOG_POOL(__pAdapter, __idx, __pTmp) GET_DRV_LOG_POOL(__pAdapter, __idx) = (PDRV_LOG_POOL_T)(__pTmp)

//
// Get current number of log of specified type. 
//
#define GetDrvLogCnt(__pAdapter, __eLogType) GET_DRV_LOG_POOL(pAdapter, eLogType)->LogCountUsed


BOOLEAN
AllocDrvLogMemory(
	IN	PADAPTER		pAdapter
	);

VOID
FreeDrvLogMemory(
	IN	PADAPTER		pAdapter
	);

VOID
AddDrvLog(
	IN	PADAPTER		pAdapter,
	IN	DRV_LOG_ID_E	eLogId,
	IN	pu1Byte			pBuffer,
	IN	u4Byte			BufferLen	
	);

BOOLEAN
RemoveDrvLog(
	IN	PADAPTER		pAdapter,
	IN	DRV_LOG_TYPE_E	eLogType,	
	OUT	PDRV_LOG_DATA_T	pDstLogData
	);


#else

#define AllocDrvLogMemory(pAdapter) TRUE 
#define FreeDrvLogMemory(pAdapter) 
#define AddDrvLog(pAdapter, eLogId, pBuffer, BufferLen)  
#define RemoveDrvLog(pAdapter, eLogType, pDstLogData) FALSE 
#define GetDrvLogCnt(__pAdapter, __eLogType) 0 

#endif // #if DRV_LOG

#endif // #ifndef __INC_DRV_LOG_IMP_H