xge_log.c revision 171095
1171095Ssam/*- 2171095Ssam * Copyright (c) 2002-2007 Neterion, Inc. 3171095Ssam * All rights reserved. 4171095Ssam * 5171095Ssam * Redistribution and use in source and binary forms, with or without 6171095Ssam * modification, are permitted provided that the following conditions 7171095Ssam * are met: 8171095Ssam * 1. Redistributions of source code must retain the above copyright 9171095Ssam * notice, this list of conditions and the following disclaimer. 10171095Ssam * 2. Redistributions in binary form must reproduce the above copyright 11171095Ssam * notice, this list of conditions and the following disclaimer in the 12171095Ssam * documentation and/or other materials provided with the distribution. 13171095Ssam * 14171095Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15171095Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16171095Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17171095Ssam * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18171095Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19171095Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20171095Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21171095Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22171095Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23171095Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24171095Ssam * SUCH DAMAGE. 25171095Ssam * 26171095Ssam * $FreeBSD: head/tools/tools/nxge/xge_log.c 171095 2007-06-29 22:47:18Z sam $ 27171095Ssam */ 28171095Ssam#include "xge_log.h" 29171095Ssam 30171095Ssamvoid 31171095SsamlogStats( void *hwStats, unsigned short device_id ) 32171095Ssam{ 33171095Ssam int index = 0; 34171095Ssam int count = 0; 35171095Ssam count = XGE_COUNT_STATS - ((device_id == DEVICE_ID_XFRAME_II) ? 0 : XGE_COUNT_EXTENDED_STATS); 36171095Ssam fdAll = fopen( "stats.log", "w+" ); 37171095Ssam if( fdAll ) 38171095Ssam { 39171095Ssam XGE_PRINT_HEADER_STATS(fdAll); 40171095Ssam 41171095Ssam for( index = 0; index < count ; index++ ) 42171095Ssam { 43171095Ssam switch( statsInfo[index].type ) 44171095Ssam { 45171095Ssam case 2: 46171095Ssam { 47171095Ssam statsInfo[index].value = 48171095Ssam *( ( u16 * )( ( unsigned char * ) hwStats + 49171095Ssam GET_OFFSET_STATS( index ) ) ); 50171095Ssam break; 51171095Ssam } 52171095Ssam case 4: 53171095Ssam { 54171095Ssam statsInfo[index].value = 55171095Ssam *( ( u32 * )( ( unsigned char * ) hwStats + 56171095Ssam GET_OFFSET_STATS( index ) ) ); 57171095Ssam break; 58171095Ssam } 59171095Ssam case 8: 60171095Ssam { 61171095Ssam statsInfo[index].value = 62171095Ssam *( ( u64 * )( ( unsigned char * ) hwStats + 63171095Ssam GET_OFFSET_STATS( index ) ) ); 64171095Ssam break; 65171095Ssam } 66171095Ssam } 67171095Ssam 68171095Ssam XGE_PRINT_STATS(fdAll,(const char *) statsInfo[index].name, 69171095Ssam statsInfo[index].value); 70171095Ssam } 71171095Ssam XGE_PRINT_LINE(fdAll); 72171095Ssam fclose(fdAll); 73171095Ssam } 74171095Ssam} 75171095Ssam 76171095Ssamvoid 77171095SsamlogPciConf( void * pciConf ) 78171095Ssam{ 79171095Ssam int index = 0; 80171095Ssam 81171095Ssam fdAll = fopen( "pciconf.log", "w+" ); 82171095Ssam if( fdAll ) 83171095Ssam { 84171095Ssam XGE_PRINT_HEADER_PCICONF(fdAll); 85171095Ssam 86171095Ssam for( index = 0; index < XGE_COUNT_PCICONF; index++ ) 87171095Ssam { 88171095Ssam pciconfInfo[index].value = 89171095Ssam *( ( u16 * )( ( unsigned char * )pciConf + 90171095Ssam GET_OFFSET_PCICONF(index) ) ); 91171095Ssam XGE_PRINT_PCICONF(fdAll,(const char *) pciconfInfo[index].name, 92171095Ssam GET_OFFSET_PCICONF(index), pciconfInfo[index].value); 93171095Ssam } 94171095Ssam 95171095Ssam XGE_PRINT_LINE(fdAll); 96171095Ssam fclose(fdAll); 97171095Ssam } 98171095Ssam} 99171095Ssam 100171095Ssamvoid 101171095SsamlogDevConf( void * devConf ) 102171095Ssam{ 103171095Ssam int index = 0; 104171095Ssam 105171095Ssam fdAll = fopen( "devconf.log", "w+" ); 106171095Ssam if( fdAll ) 107171095Ssam { 108171095Ssam XGE_PRINT_HEADER_DEVCONF(fdAll); 109171095Ssam 110171095Ssam for( index = 0; index < XGE_COUNT_DEVCONF; index++ ) 111171095Ssam { 112171095Ssam devconfInfo[index].value = 113171095Ssam *( ( u32 * )( ( unsigned char * )devConf + 114171095Ssam ( index * ( sizeof( int ) ) ) ) ); 115171095Ssam XGE_PRINT_DEVCONF(fdAll,(const char *) devconfInfo[index].name, 116171095Ssam devconfInfo[index].value); 117171095Ssam } 118171095Ssam 119171095Ssam XGE_PRINT_LINE(fdAll); 120171095Ssam fclose( fdAll ); 121171095Ssam } 122171095Ssam} 123171095Ssam 124171095Ssamvoid 125171095SsamlogRegInfo( void * regBuffer ) 126171095Ssam{ 127171095Ssam int index = 0; 128171095Ssam 129171095Ssam fdAll = fopen( "reginfo.log", "w+" ); 130171095Ssam if( fdAll ) 131171095Ssam { 132171095Ssam XGE_PRINT_HEADER_REGS(fdAll); 133171095Ssam 134171095Ssam for( index = 0; index < XGE_COUNT_REGS; index++ ) 135171095Ssam { 136171095Ssam regInfo[index].value = 137171095Ssam *( ( u64 * )( ( unsigned char * )regBuffer + 138171095Ssam regInfo[index].offset ) ); 139171095Ssam XGE_PRINT_REGS(fdAll,(const char *) regInfo[index].name, 140171095Ssam regInfo[index].offset, regInfo[index].value); 141171095Ssam } 142171095Ssam 143171095Ssam XGE_PRINT_LINE(fdAll); 144171095Ssam fclose(fdAll); 145171095Ssam } 146171095Ssam} 147171095Ssamvoid 148171095SsamlogReadReg(u64 offset,u64 temp) 149171095Ssam{ 150171095Ssam int index=0; 151171095Ssam 152171095Ssam fdAll = fopen( "readreg.log", "w+"); 153171095Ssam if( fdAll ) 154171095Ssam { 155171095Ssam XGE_PRINT_READ_HEADER_REGS(fdAll); 156171095Ssam 157171095Ssam regInfo[index].offset = offset ; 158171095Ssam 159171095Ssam regInfo[index].value = temp ; 160171095Ssam 161171095Ssam printf("0x%.8X\t0x%.16llX\n",regInfo[index].offset, regInfo[index].value); 162171095Ssam 163171095Ssam XGE_PRINT_LINE(fdAll); 164171095Ssam fclose(fdAll); 165171095Ssam } 166171095Ssam} 167171095Ssamvoid 168171095SsamlogIntrStats( void * intrStats ) 169171095Ssam{ 170171095Ssam int index = 0; 171171095Ssam 172171095Ssam fdAll = fopen( "intrstats.log", "w+" ); 173171095Ssam if(fdAll) 174171095Ssam { 175171095Ssam XGE_PRINT_HEADER_STATS(fdAll); 176171095Ssam 177171095Ssam for( index = 0; index < XGE_COUNT_INTRSTAT; index++ ) 178171095Ssam { 179171095Ssam intrInfo[index].value = 180171095Ssam *( ( u32 * )( ( unsigned char * )intrStats + 181171095Ssam ( index * ( sizeof( u32 ) ) ) ) ); 182171095Ssam XGE_PRINT_STATS(fdAll,(const char *) intrInfo[index].name, 183171095Ssam intrInfo[index].value); 184171095Ssam } 185171095Ssam 186171095Ssam XGE_PRINT_LINE(fdAll); 187171095Ssam fclose(fdAll); 188171095Ssam } 189171095Ssam} 190171095Ssam 191171095Ssamvoid 192171095SsamlogTcodeStats( void * tcodeStats ) 193171095Ssam{ 194171095Ssam int index = 0; 195171095Ssam 196171095Ssam fdAll = fopen( "tcodestats.log", "w+" ); 197171095Ssam if(fdAll) 198171095Ssam { 199171095Ssam XGE_PRINT_HEADER_STATS(fdAll); 200171095Ssam 201171095Ssam for( index = 0; index < XGE_COUNT_TCODESTAT; index++ ) 202171095Ssam { 203171095Ssam if(!(tcodeInfo[index].flag)) 204171095Ssam { 205171095Ssam switch( tcodeInfo[index].type ) 206171095Ssam { 207171095Ssam case 2: 208171095Ssam { 209171095Ssam tcodeInfo[index].value = 210171095Ssam *( ( u16 * )( ( unsigned char * )tcodeStats + 211171095Ssam ( index * ( sizeof( u16 ) ) ) ) ); 212171095Ssam break; 213171095Ssam } 214171095Ssam case 4: 215171095Ssam { 216171095Ssam tcodeInfo[index].value = 217171095Ssam *( ( u32 * )( ( unsigned char * )tcodeStats + 218171095Ssam ( index * ( sizeof( u32 ) ) ) ) ); 219171095Ssam break; 220171095Ssam } 221171095Ssam } 222171095Ssam 223171095Ssam XGE_PRINT_STATS(fdAll,(const char *) tcodeInfo[index].name, 224171095Ssam tcodeInfo[index].value); 225171095Ssam } 226171095Ssam } 227171095Ssam 228171095Ssam XGE_PRINT_LINE(fdAll); 229171095Ssam fclose(fdAll); 230171095Ssam } 231171095Ssam} 232171095Ssam 233171095Ssamvoid 234171095SsamlogDriverInfo( char *version ) 235171095Ssam{ 236171095Ssam fdAll = fopen( "driverinfo.log", "w+"); 237171095Ssam if (fdAll) 238171095Ssam { 239171095Ssam XGE_PRINT_LINE(fdAll); 240171095Ssam printf("DRIVER VERSION : %s\n",version); 241171095Ssam XGE_PRINT_LINE(fdAll); 242171095Ssam fclose(fdAll); 243171095Ssam } 244171095Ssam 245171095Ssam} 246171095Ssam 247