1 /*******************************************************************************
2 Copyright (C) Marvell International Ltd. and its affiliates
4 This software file (the "File") is owned and distributed by Marvell
5 International Ltd. and/or its affiliates ("Marvell") under the following
6 alternative licensing terms. Once you have made an election to distribute the
7 File under one of the following license alternatives, please (i) delete this
8 introductory statement regarding license alternatives, (ii) delete the two
9 license alternatives that you have not elected to use and (iii) preserve the
10 Marvell copyright notice above.
12 ********************************************************************************
13 Marvell Commercial License Option
15 If you received this File from Marvell and you have entered into a commercial
16 license agreement (a "Commercial License") with Marvell, the File is licensed
17 to you under the terms of the applicable Commercial License.
19 ********************************************************************************
20 Marvell GPL License Option
22 If you received this File from Marvell, you may opt to use, redistribute and/or
23 modify this File in accordance with the terms and conditions of the General
24 Public License Version 2, June 1991 (the "GPL License"), a copy of which is
25 available along with the File in the license.txt file or by writing to the Free
26 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or
27 on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
29 THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED
30 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY
31 DISCLAIMED. The GPL License provides additional details about this warranty
33 ********************************************************************************
34 Marvell BSD License Option
36 If you received this File from Marvell, you may opt to use, redistribute and/or
37 modify this File under the following licensing terms.
38 Redistribution and use in source and binary forms, with or without modification,
39 are permitted provided that the following conditions are met:
41 * Redistributions of source code must retain the above copyright notice,
42 this list of conditions and the following disclaimer.
44 * Redistributions in binary form must reproduce the above copyright
45 notice, this list of conditions and the following disclaimer in the
46 documentation and/or other materials provided with the distribution.
48 * Neither the name of Marvell nor the names of its contributors may be
49 used to endorse or promote products derived from this software without
50 specific prior written permission.
52 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
53 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
54 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
55 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
56 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
57 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
58 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
59 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 *******************************************************************************/
73 /* Global variables effect on behave MV_DEBUG_PRINT and MV_DEBUG_CODE macros
74 * mvDebug - map of bits (one for each module) bit=1 means enable
75 * debug code and messages for this module
76 * mvModuleDebug - array of 32 bits varables one for each module
79 MV_U32 mvDebugModules
[MV_MODULE_MAX
];
81 /* Init mvModuleDebug array to default values */
82 void mvDebugInit(void)
87 for(bit
=0; bit
<MV_MODULE_MAX
; bit
++)
89 mvDebugModules
[bit
] = MV_DEBUG_FLAG_ERR
| MV_DEBUG_FLAG_STATS
;
90 mvDebug
|= MV_BIT_MASK(bit
);
94 void mvDebugModuleEnable(MV_MODULE_ID module
, MV_BOOL isEnable
)
98 MV_BIT_SET(mvDebug
, module
);
101 MV_BIT_CLEAR(mvDebug
, module
);
104 void mvDebugModuleSetFlags(MV_MODULE_ID module
, MV_U32 flags
)
106 mvDebugModules
[module
] |= flags
;
109 void mvDebugModuleClearFlags(MV_MODULE_ID module
, MV_U32 flags
)
111 mvDebugModules
[module
] &= ~flags
;
114 /* Dump memory in specific format:
115 * address: X1X1X1X1 X2X2X2X2 ... X8X8X8X8
117 void mvDebugMemDump(void* addr
, int size
, int access
)
120 MV_U32 memAddr
= (MV_U32
)addr
;
125 if( (access
!= 4) && (access
!= 2) && (access
!= 1) )
127 mvOsPrintf("%d wrong access size. Access must be 1 or 2 or 4\n",
131 memAddr
= MV_ALIGN_DOWN( (unsigned int)addr
, 4);
132 size
= MV_ALIGN_UP(size
, 4);
133 addr
= (void*)MV_ALIGN_DOWN( (unsigned int)addr
, access
);
136 mvOsPrintf("%08x: ", memAddr
);
138 /* 32 bytes in the line */
141 if(memAddr
>= (MV_U32
)addr
)
146 if( memAddr
== CPU_PHY_MEM(memAddr
) )
148 mvOsPrintf("%02x ", MV_MEMIO8_READ(memAddr
));
152 mvOsPrintf("%02x ", *((MV_U8
*)memAddr
));
157 if( memAddr
== CPU_PHY_MEM(memAddr
) )
159 mvOsPrintf("%04x ", MV_MEMIO16_READ(memAddr
));
163 mvOsPrintf("%04x ", *((MV_U16
*)memAddr
));
168 if( memAddr
== CPU_PHY_MEM(memAddr
) )
170 mvOsPrintf("%08x ", MV_MEMIO32_READ(memAddr
));
174 mvOsPrintf("%08x ", *((MV_U32
*)memAddr
));
181 for(j
=0; j
<(access
*2+1); j
++)
194 void mvDebugPrintBufInfo(BUF_INFO
* pBufInfo
, int size
, int access
)
198 mvOsPrintf("\n!!! pBufInfo = NULL\n");
201 mvOsPrintf("\n*** pBufInfo=0x%x, cmdSts=0x%08x, pBuf=0x%x, bufSize=%d\n",
202 (unsigned int)pBufInfo
,
203 (unsigned int)pBufInfo
->cmdSts
,
204 (unsigned int)pBufInfo
->pBuff
,
205 (unsigned int)pBufInfo
->bufSize
);
206 mvOsPrintf("pData=0x%x, byteCnt=%d, pNext=0x%x, uInfo1=0x%x, uInfo2=0x%x\n",
207 (unsigned int)pBufInfo
->pData
,
208 (unsigned int)pBufInfo
->byteCnt
,
209 (unsigned int)pBufInfo
->pNextBufInfo
,
210 (unsigned int)pBufInfo
->userInfo1
,
211 (unsigned int)pBufInfo
->userInfo2
);
212 if(pBufInfo
->pData
!= NULL
)
214 if(size
> pBufInfo
->byteCnt
)
215 size
= pBufInfo
->byteCnt
;
216 mvDebugMemDump(pBufInfo
->pData
, size
, access
);
220 void mvDebugPrintPktInfo(MV_PKT_INFO
* pPktInfo
, int size
, int access
)
226 mvOsPrintf("\n!!! pPktInfo = NULL\n");
229 mvOsPrintf("\npPkt=%p, stat=0x%08x, numFr=%d, size=%d, pFr=%p, osInfo=0x%lx\n",
230 pPktInfo
, pPktInfo
->status
, pPktInfo
->numFrags
, pPktInfo
->pktSize
,
231 pPktInfo
->pFrags
, pPktInfo
->osInfo
);
233 for(frag
=0; frag
<pPktInfo
->numFrags
; frag
++)
235 mvOsPrintf("#%2d. bufVirt=%p, bufSize=%d\n",
236 frag
, pPktInfo
->pFrags
[frag
].bufVirtPtr
,
237 pPktInfo
->pFrags
[frag
].bufSize
);
240 len
= MV_MIN((int)pPktInfo
->pFrags
[frag
].bufSize
, size
);
241 mvDebugMemDump(pPktInfo
->pFrags
[frag
].bufVirtPtr
, len
, access
);
248 void mvDebugPrintIpAddr(MV_U32 ipAddr
)
250 mvOsPrintf("%d.%d.%d.%d", ((ipAddr
>> 24) & 0xFF), ((ipAddr
>> 16) & 0xFF),
251 ((ipAddr
>> 8) & 0xFF), ((ipAddr
>> 0) & 0xFF));
254 void mvDebugPrintMacAddr(const MV_U8
* pMacAddr
)
258 mvOsPrintf("%02x", (unsigned int)pMacAddr
[0]);
259 for(i
=1; i
<MV_MAC_ADDR_SIZE
; i
++)
261 mvOsPrintf(":%02x", pMacAddr
[i
]);
263 /* mvOsPrintf("\n");*/
267 /******* There are three functions deals with MV_DEBUG_TIMES structure ********/
269 /* Reset MV_DEBUG_TIMES entry */
270 void mvDebugResetTimeEntry(MV_DEBUG_TIMES
* pTimeEntry
, int count
, char* pName
)
272 pTimeEntry
->begin
= 0;
273 pTimeEntry
->count
= count
;
275 pTimeEntry
->left
= pTimeEntry
->count
;
276 pTimeEntry
->total
= 0;
277 pTimeEntry
->min
= 0xFFFFFFFF;
278 pTimeEntry
->max
= 0x0;
279 strncpy(pTimeEntry
->name
, pName
, sizeof(pTimeEntry
->name
)-1);
280 pTimeEntry
->name
[sizeof(pTimeEntry
->name
)-1] = '\0';
283 /* Print out MV_DEBUG_TIMES entry */
284 void mvDebugPrintTimeEntry(MV_DEBUG_TIMES
* pTimeEntry
, MV_BOOL isTitle
)
288 if(isTitle
== MV_TRUE
)
289 mvOsPrintf("Event NumOfEvents TotalTime Average Min Max\n");
291 num
= pTimeEntry
->count
-pTimeEntry
->left
;
294 mvOsPrintf("%-11s %6u 0x%08lx %6lu %6lu %6lu\n",
295 pTimeEntry
->name
, num
, pTimeEntry
->total
, pTimeEntry
->total
/num
,
296 pTimeEntry
->min
, pTimeEntry
->max
);
300 /* Update MV_DEBUG_TIMES entry */
301 void mvDebugUpdateTimeEntry(MV_DEBUG_TIMES
* pTimeEntry
)
305 if(pTimeEntry
->left
> 0)
307 if(pTimeEntry
->end
<= pTimeEntry
->begin
)
309 delta
= pTimeEntry
->begin
- pTimeEntry
->end
;
313 delta
= ((MV_U32
)0x10000 - pTimeEntry
->end
) + pTimeEntry
->begin
;
315 pTimeEntry
->total
+= delta
;
317 if(delta
< pTimeEntry
->min
)
318 pTimeEntry
->min
= delta
;
320 if(delta
> pTimeEntry
->max
)
321 pTimeEntry
->max
= delta
;
This page took 0.061833 seconds and 5 git commands to generate.