cm-kernel /drivers/net/wireless/tiwlan1251/common/src/BusAccess/Shm_Common/whalTrace.c

Language C Lines 294
MD5 Hash 7b3cb697c35483f1c97e493418f8ff3f Estimated Cost $2,789 (why?)
Repository git://github.com/CyanogenMod/cm-kernel.git View Raw File View Project SPDX
  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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/****************************************************************************
**+-----------------------------------------------------------------------+**
**|                                                                       |**
**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
**| All rights reserved.                                                  |**
**|                                                                       |**
**| Redistribution and use in source and binary forms, with or without    |**
**| modification, are permitted provided that the following conditions    |**
**| are met:                                                              |**
**|                                                                       |**
**|  * Redistributions of source code must retain the above copyright     |**
**|    notice, this list of conditions and the following disclaimer.      |**
**|  * Redistributions in binary form must reproduce the above copyright  |**
**|    notice, this list of conditions and the following disclaimer in    |**
**|    the documentation and/or other materials provided with the         |**
**|    distribution.                                                      |**
**|  * Neither the name Texas Instruments nor the names of its            |**
**|    contributors may be used to endorse or promote products derived    |**
**|    from this software without specific prior written permission.      |**
**|                                                                       |**
**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
**|                                                                       |**
**+-----------------------------------------------------------------------+**
****************************************************************************/

/****************************************************************************
 *
 *   MODULE:  whalTrace.c
 *   PURPOSE: Trace on Rx/Tx packets
 *   
 ****************************************************************************/

#include "whalCommon.h"
#include "TNETWIF.h"
#include "whalTrace.h"


#define SEQUNCE_TRACE		

#define TRACE_INTERRUPT		0x0001	/* Trace the recieved interupt only */
#define TRACE_TX			0x0002	/* Trace all Tx path (os ->>core ->> hal) */
#define TRACE_RX			0x0004	/* Trace all Rx path (hal ->> core ->> os) */
#define TRACE_COPY_ONLY		0x0008	/* Trace the copy of data from and to the FW only  - for slave mode*/
#define TRACE_BUG_ONLY		0x0010	/* Trace the ctrls that only presents an unexpected case*/
#define TRACE_All			0xffff	/* Trace all. */


 
/****************************************************************************
 *                      OBJECT DATA BASE
 ****************************************************************************
 *
 *	TrcDb - Rx Trace buffer of 5000 packets
 *
 ****************************************************************************/
int whal_tracePrintLine(WhalTrace_T *pTrc, int EventIndex);

void local_string_copy(char *str1, char *str2, int size)
{
	int i;
	for (i=0; i<size; i++)
	{
		str1[i] = str2[i];
		if (str2[i] == 0)
			break;
	}
}
/****************************************************************************
 *                      whal_traceCreate()
 ****************************************************************************
 * DESCRIPTION:	Create the whal trace object
 * 
 * INPUTS:	
 * 
 * OUTPUT:	None
 * 
 * RETURNS:	The Created object
 ****************************************************************************/
WhalTrace_T *whal_traceCreate(TI_HANDLE hOs)
{
	WhalTrace_T *pObj;

	pObj = os_memoryAlloc(hOs, sizeof(WhalTrace_T));
	if (pObj == NULL)
		return NULL;

	os_memoryZero(hOs, pObj, sizeof(WhalTrace_T));

	pObj->hOs = hOs;
	pObj->hProtect = os_protectCreate(pObj->hOs);
	if (pObj->hProtect == NULL)
	{
		whal_traceDestroy(pObj);
		return NULL;
	}

	return(pObj);
}

/****************************************************************************
 *                      whal_traceDestroy()
 ****************************************************************************
 * DESCRIPTION:	Destroy the object 
 * 
 * INPUTS:	
 *		pTrc		The object to free
 * 
 * OUTPUT:	None
 * 
 * RETURNS:	OK or NOK
 ****************************************************************************/
int whal_traceDestroy(WhalTrace_T *pTrc)
{
	if (pTrc == NULL)
		return OK;

	if (pTrc->hProtect)
		os_protectDestroy(pTrc->hOs, pTrc->hProtect);
	os_memoryFree(pTrc->hOs, pTrc, sizeof(WhalTrace_T));
	return OK;
}

/****************************************************************************
 *                      whal_traceConfig()
 ****************************************************************************
 * DESCRIPTION:	Config the object 
 * 
 * INPUTS:	
 *		pTrc		The object
 *		hReport		The reports objects
 * 
 * OUTPUT:	None
 * 
 * RETURNS:	OK or NOK
 ****************************************************************************/
int whal_traceConfig(WhalTrace_T *pTrc, TI_HANDLE hTNETWIF, TI_HANDLE hReport)
{
	pTrc->hReport = hReport;
	pTrc->hTNETWIF = hTNETWIF;
	pTrc->Enable = 0; /*Hardcoded*/
	pTrc->Idx = 0;
	pTrc->Num = 0;
	pTrc->MaxFreeBlks = 0;

	/* configured the trace mask flag */
	pTrc->traceMask = TRACE_BUG_ONLY;
	return OK;
}

/****************************************************************************
 *                      whal_traceAddTx()
 ****************************************************************************
 * DESCRIPTION:	Add Tx info line to the DB
 * 
 * INPUTS:	
 * 
 * OUTPUT:	None
 * 
 * RETURNS:	OK or NOK
 ****************************************************************************/

#ifdef TNETW_MASTER_MODE

int whal_traceAddTx(WhalTrace_T *pTrc, HwTxDesc_T *pHwTxDesc, char *Action)
{
	TRACER_EVENT *pEvt;
	UINT32 FrameAddress;
	DbTescriptor local_TxDesc;
	TRACER_DATA	*pData;

#ifdef SEQUNCE_TRACE
	return 1;
#endif
	/* Dm: os_protectLock(pTrc->hOs, pTrc->hProtect); */

	pEvt = &pTrc->Evt[pTrc->Idx];
	pData = &pEvt->Info.TrcData;
	
	/*
	 * Common
	 */
	local_string_copy(pEvt->Action, Action, TRACER_MAX_ACT_LEN-1);
	local_string_copy(pEvt->Object, "Tx", TRACER_MAX_OBJ_LEN-1);

    pEvt->TimStamp = os_timeStampUs(pTrc->hOs);

	/* 
	 * Data
	 */
	whal_hwTxDesc_Copy(pHwTxDesc, &local_TxDesc);

	pData->MpduLen	= local_TxDesc.length;
	pData->Ctl		= local_TxDesc.ctl;
	pData->Rate		= (UINT16)local_TxDesc.rate;

    pData->Status[0] = 0;
	pData->Status[1] = 0;
	pData->Status[3] = 0;

    /*
	pData->Status[0] = local_TxDesc.ctrl2;
	pData->Status[1] = local_TxDesc.ackFailures;
	pData->Status[3] = local_TxDesc.rtsFailures;
    */

	FrameAddress = 4+whal_hwTxDesc_GetAcxBufAddr(pHwTxDesc);
	TNETWIF_ReadMemSync(pTrc->hTNETWIF,
						(UINT32)((char *)FrameAddress),
						(UINT8 *)((char *)&pData->FrameHeader),
						  TRACER_HDR_LEN);

	pData->FrameHeader.fc = ENDIAN_HANDLE_WORD(pData->FrameHeader.fc);
	pData->FrameHeader.seqCtrl = ENDIAN_HANDLE_WORD(pData->FrameHeader.seqCtrl);
	pData->FrameHeader.duration = ENDIAN_HANDLE_WORD(pData->FrameHeader.duration);
	TNETWIF_ReadMemSync(pTrc->hTNETWIF,
						(UINT32)((char *)FrameAddress+TRACER_HDR_LEN),
						(UINT8 *)((char *)&pData->FrameData),
						  4);


	/* 
	 * Prepare next index
	 */
	if (++pTrc->Idx >= TRACER_MAX_EVENTS)
		pTrc->Idx = 0;

	if (pTrc->Num < TRACER_MAX_EVENTS)
		pTrc->Num++;

	/* Dm: os_protectUnlock(pTrc->hOs, pTrc->hProtect); */

	return(0);
}

#endif  /* TNETW_MASTER_MODE */


/****************************************************************************
 *                      whal_traceIsEnable()
 ****************************************************************************
 * DESCRIPTION:	return the enable value
 * 
 * INPUTS:	None
 * 
 * OUTPUT:	None
 * 
 * RETURNS:	Enable value
 ****************************************************************************/
int whal_traceIsEnable(WhalTrace_T *pTrc)
{
	return pTrc->Enable;
}

/****************************************************************************
 *                      whal_traceEnable()
 ****************************************************************************
 * DESCRIPTION:	enable the tracing
 * 
 * INPUTS:	None
 * 
 * OUTPUT:	None
 * 
 * RETURNS:	None
 ****************************************************************************/
void whal_traceEnable(WhalTrace_T *pTrc, int val)
{
	pTrc->Enable = val;
	
	if(val == 1) /* Enable case*/
	{
		pTrc->MinNumDescriptorFree = 0xff;
		pTrc->MacOccupiedDescriptor = 0;
		pTrc->MaxClearDescriptor = 0;
		pTrc->BugCounter = 0;
		pTrc->reBug = 0;
		pTrc->MaxFreeBlks = 0;
	}

	
}
Back to Top