2 * Copyright (c) 2002-2007 Neterion, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
33 * Prints/logs hardware statistics
35 * @hw_stats Hardware statistics
36 * @device_id Device ID
39 xge_print_hwstats(void *hw_stats, unsigned short device_id)
41 int index = 0, count = 0;
43 count = XGE_COUNT_STATS -
44 ((device_id == DEVICE_ID_XFRAME_II) ? 0 : XGE_COUNT_EXTENDED_STATS);
46 fdAll = fopen("stats.log", "w+");
50 XGE_PRINT_HEADER_STATS(fdAll);
51 for(index = 0; index < count ; index++) {
52 switch(statsInfo[index].type) {
54 statsInfo[index].value =
55 *((u16 *)((unsigned char *)hw_stats +
56 GET_OFFSET_STATS(index)));
59 statsInfo[index].value =
60 *((u32 *)((unsigned char *) hw_stats +
61 GET_OFFSET_STATS(index)));
64 statsInfo[index].value =
65 *((u64 *)((unsigned char *)hw_stats +
66 GET_OFFSET_STATS(index)));
70 XGE_PRINT_STATS(fdAll,(const char *) statsInfo[index].name,
71 statsInfo[index].value);
73 XGE_PRINT_LINE(fdAll);
81 * Prints/logs PCI configuration space
83 * @pci_conf PCI Configuration
86 xge_print_pciconf(void * pci_conf)
90 fdAll = fopen("pciconf.log", "w+");
94 XGE_PRINT_HEADER_PCICONF(fdAll);
95 for(index = 0; index < XGE_COUNT_PCICONF; index++) {
96 pciconfInfo[index].value = *((u16 *)((unsigned char *)pci_conf +
97 GET_OFFSET_PCICONF(index)));
98 XGE_PRINT_PCICONF(fdAll,(const char *) pciconfInfo[index].name,
99 GET_OFFSET_PCICONF(index), pciconfInfo[index].value);
102 XGE_PRINT_LINE(fdAll);
111 * Prints/logs Device Configuration
113 * @dev_conf Device Configuration
116 xge_print_devconf(void * dev_conf)
120 fdAll = fopen("devconf.log", "w+");
124 XGE_PRINT_HEADER_DEVCONF(fdAll);
126 for(index = 0; index < XGE_COUNT_DEVCONF; index++) {
127 devconfInfo[index].value = *((u32 *)((unsigned char *)dev_conf +
128 (index * (sizeof(int)))));
129 XGE_PRINT_DEVCONF(fdAll,(const char *) devconfInfo[index].name,
130 devconfInfo[index].value);
133 XGE_PRINT_LINE(fdAll);
141 * xge_print_registers
142 * Prints/logs Register values
144 * @registers Register values
147 xge_print_registers(void * registers)
151 fdAll = fopen("reginfo.log", "w+");
155 XGE_PRINT_HEADER_REGS(fdAll);
157 for(index = 0; index < XGE_COUNT_REGS; index++) {
158 regInfo[index].value = *((u64 *)((unsigned char *)registers +
159 regInfo[index].offset));
160 XGE_PRINT_REGS(fdAll,(const char *) regInfo[index].name,
161 regInfo[index].offset, regInfo[index].value);
164 XGE_PRINT_LINE(fdAll);
172 * Prints/logs a register value
174 * @offset Offset of the register
178 xge_print_register(u64 offset, u64 value)
182 fdAll = fopen("readreg.log", "w+");
186 XGE_PRINT_READ_HEADER_REGS(fdAll);
187 regInfo[index].offset = offset;
188 regInfo[index].value = value;
189 printf("0x%.8X\t0x%.16llX\n", regInfo[index].offset,
190 regInfo[index].value);
191 XGE_PRINT_LINE(fdAll);
200 * Prints Device Statistics
202 * @dev_stats Device Statistics
205 xge_print_devstats(void *dev_stats)
209 fdAll = fopen("intrstats.log", "w+");
213 XGE_PRINT_HEADER_STATS(fdAll);
214 for(index = 0; index < XGE_COUNT_INTRSTAT; index++) {
215 intrInfo[index].value = *((u32 *)((unsigned char *)dev_stats +
216 (index * (sizeof(u32)))));
217 XGE_PRINT_STATS(fdAll,(const char *) intrInfo[index].name,
218 intrInfo[index].value);
221 XGE_PRINT_LINE(fdAll);
229 * Prints/logs Software Statistics
231 * @sw_stats Software statistics
234 xge_print_swstats(void * sw_stats)
238 fdAll = fopen("tcodestats.log", "w+");
242 XGE_PRINT_HEADER_STATS(fdAll);
243 for(index = 0; index < XGE_COUNT_SWSTAT; index++) {
244 if(!(tcodeInfo[index].flag)) {
245 switch(tcodeInfo[index].type) {
247 tcodeInfo[index].value =
248 *((u16 *)((unsigned char *)sw_stats +
249 (index * (sizeof(u16)))));
252 tcodeInfo[index].value =
253 *((u32 *)((unsigned char *)sw_stats +
254 (index * (sizeof(u32)))));
257 XGE_PRINT_STATS(fdAll,(const char *) tcodeInfo[index].name,
258 tcodeInfo[index].value);
262 XGE_PRINT_LINE(fdAll);
270 * xge_print_drv_version
271 * Prints/logs driver version
273 * @version Driver version
276 xge_print_drv_version(char *version)
278 fdAll = fopen("driverinfo.log", "w+");
282 XGE_PRINT_LINE(fdAll);
283 printf("Driver Version: %s\n", version);
284 XGE_PRINT_LINE(fdAll);
293 * Prints/logs Driver Statistics
295 * @driver_stats Driver Statistics
298 xge_print_drvstats(void * driver_stats)
302 fdAll = fopen("driver_stats.log", "w+");
306 XGE_PRINT_HEADER_STATS(fdAll);
308 for(index = 0; index < XGE_COUNT_DRIVERSTATS; index++) {
309 driverInfo[index].value = *((u64 *)((unsigned char *)driver_stats +
310 (index * (sizeof(u64)))));
311 XGE_PRINT_STATS(fdAll,(const char *) driverInfo[index].name,
312 driverInfo[index].value);
315 XGE_PRINT_LINE(fdAll);