]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/tools/nxge/xge_log.c
This commit was generated by cvs2svn to compensate for changes in r172958,
[FreeBSD/FreeBSD.git] / tools / tools / nxge / xge_log.c
1 /*-
2  * Copyright (c) 2002-2007 Neterion, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 #include "xge_log.h"
29
30 void
31 logStats( void *hwStats, unsigned short device_id )
32 {
33     int index = 0;
34     int count = 0;
35     count = XGE_COUNT_STATS - ((device_id == DEVICE_ID_XFRAME_II) ? 0 : XGE_COUNT_EXTENDED_STATS);
36     fdAll = fopen( "stats.log", "w+" );
37     if( fdAll )
38     {
39         XGE_PRINT_HEADER_STATS(fdAll);
40
41         for( index = 0; index < count ; index++ )
42         {
43             switch( statsInfo[index].type )
44             {
45                 case 2:
46                 {
47                     statsInfo[index].value = 
48                         *( ( u16 * )( ( unsigned char * ) hwStats +
49                         GET_OFFSET_STATS( index ) ) );
50                     break;
51                 }
52                 case 4:
53                 {
54                     statsInfo[index].value =
55                         *( ( u32 * )( ( unsigned char * ) hwStats +
56                         GET_OFFSET_STATS( index ) ) );
57                     break;
58                 }
59                 case 8:
60                 {
61                     statsInfo[index].value =
62                         *( ( u64 * )( ( unsigned char * ) hwStats +
63                         GET_OFFSET_STATS( index ) ) );
64                     break;
65                 }
66             }
67
68             XGE_PRINT_STATS(fdAll,(const char *) statsInfo[index].name,
69                 statsInfo[index].value);
70         }
71         XGE_PRINT_LINE(fdAll);
72         fclose(fdAll);
73     }
74 }
75
76 void 
77 logPciConf( void * pciConf )
78 {
79     int index = 0;
80
81     fdAll = fopen( "pciconf.log", "w+" );
82     if( fdAll )
83     {
84         XGE_PRINT_HEADER_PCICONF(fdAll);
85
86         for( index = 0; index < XGE_COUNT_PCICONF; index++ )
87         {
88             pciconfInfo[index].value =
89                 *( ( u16 * )( ( unsigned char * )pciConf +
90                 GET_OFFSET_PCICONF(index) ) );
91             XGE_PRINT_PCICONF(fdAll,(const char *) pciconfInfo[index].name,
92                 GET_OFFSET_PCICONF(index), pciconfInfo[index].value);
93         }
94
95         XGE_PRINT_LINE(fdAll);
96         fclose(fdAll);
97     }
98 }
99
100 void
101 logDevConf( void * devConf )
102 {
103     int index = 0;
104
105     fdAll = fopen( "devconf.log", "w+" );
106     if( fdAll )
107     {
108         XGE_PRINT_HEADER_DEVCONF(fdAll);
109
110         for( index = 0; index < XGE_COUNT_DEVCONF; index++ )
111         {
112             devconfInfo[index].value =
113                 *( ( u32 * )( ( unsigned char * )devConf +
114                 ( index * ( sizeof( int ) ) ) ) );
115             XGE_PRINT_DEVCONF(fdAll,(const char *) devconfInfo[index].name,
116                 devconfInfo[index].value);
117         }
118
119         XGE_PRINT_LINE(fdAll);
120         fclose( fdAll );
121     }
122 }
123
124 void
125 logRegInfo( void * regBuffer )
126 {
127     int index = 0;
128
129     fdAll = fopen( "reginfo.log", "w+" );
130     if( fdAll )
131     {
132         XGE_PRINT_HEADER_REGS(fdAll);
133
134         for( index = 0; index < XGE_COUNT_REGS; index++ )
135         {
136             regInfo[index].value =
137                 *( ( u64 * )( ( unsigned char * )regBuffer +
138                 regInfo[index].offset ) );
139             XGE_PRINT_REGS(fdAll,(const char *) regInfo[index].name,
140                 regInfo[index].offset, regInfo[index].value);
141         }
142
143         XGE_PRINT_LINE(fdAll);
144         fclose(fdAll);
145     }
146 }
147 void
148 logReadReg(u64 offset,u64 temp)
149 {
150     int index=0;
151     
152     fdAll = fopen( "readreg.log", "w+");
153     if( fdAll )
154     {
155         XGE_PRINT_READ_HEADER_REGS(fdAll);
156                 
157         regInfo[index].offset = offset ; 
158
159         regInfo[index].value = temp ;
160                 
161         printf("0x%.8X\t0x%.16llX\n",regInfo[index].offset, regInfo[index].value);
162                 
163         XGE_PRINT_LINE(fdAll);
164         fclose(fdAll);
165     }
166 }
167 void
168 logIntrStats( void * intrStats )
169 {
170     int index = 0;
171
172     fdAll = fopen( "intrstats.log", "w+" );
173     if(fdAll)
174     {
175         XGE_PRINT_HEADER_STATS(fdAll);
176
177         for( index = 0; index < XGE_COUNT_INTRSTAT; index++ )
178         {
179             intrInfo[index].value =
180                 *( ( u32 * )( ( unsigned char * )intrStats +
181                 ( index * ( sizeof( u32 ) ) ) ) );
182             XGE_PRINT_STATS(fdAll,(const char *) intrInfo[index].name,
183                 intrInfo[index].value);
184         }
185
186         XGE_PRINT_LINE(fdAll);
187         fclose(fdAll);
188     }
189 }
190
191 void
192 logTcodeStats( void * tcodeStats )
193 {
194     int index = 0;
195
196     fdAll = fopen( "tcodestats.log", "w+" );
197     if(fdAll)
198     {
199         XGE_PRINT_HEADER_STATS(fdAll);
200
201         for( index = 0; index < XGE_COUNT_TCODESTAT; index++ )
202         {   
203             if(!(tcodeInfo[index].flag)) 
204             {
205                 switch( tcodeInfo[index].type )
206                 {
207                   case 2:
208                   {
209                       tcodeInfo[index].value =
210                           *( ( u16 * )( ( unsigned char * )tcodeStats +
211                           ( index * ( sizeof( u16 ) ) ) ) );
212                       break;
213                   }
214                   case 4:
215                   {
216                       tcodeInfo[index].value =
217                           *( ( u32 * )( ( unsigned char * )tcodeStats +
218                           ( index * ( sizeof( u32 ) ) ) ) );
219                       break;
220                   }
221                 }
222                             
223             XGE_PRINT_STATS(fdAll,(const char *) tcodeInfo[index].name,
224                 tcodeInfo[index].value);
225             }
226         }  
227
228         XGE_PRINT_LINE(fdAll);
229         fclose(fdAll);
230     }
231 }
232
233 void
234 logDriverInfo( char *version )
235 {
236   fdAll = fopen( "driverinfo.log", "w+");
237   if (fdAll)
238   {
239        XGE_PRINT_LINE(fdAll);
240        printf("DRIVER VERSION : %s\n",version);
241        XGE_PRINT_LINE(fdAll); 
242        fclose(fdAll);
243   }
244   
245 }
246