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$ 27171095Ssam */ 28173139Srwatson 29171095Ssam#include "xge_log.h" 30171095Ssam 31173139Srwatson/** 32173139Srwatson * xge_print_hwstats 33173139Srwatson * Prints/logs hardware statistics 34173139Srwatson * 35173139Srwatson * @hw_stats Hardware statistics 36173139Srwatson * @device_id Device ID 37173139Srwatson */ 38171095Ssamvoid 39173139Srwatsonxge_print_hwstats(void *hw_stats, unsigned short device_id) 40171095Ssam{ 41173139Srwatson int index = 0, count = 0; 42171095Ssam 43173139Srwatson count = XGE_COUNT_STATS - 44173139Srwatson ((device_id == DEVICE_ID_XFRAME_II) ? 0 : XGE_COUNT_EXTENDED_STATS); 45171095Ssam 46173139Srwatson fdAll = fopen("stats.log", "w+"); 47173139Srwatson if(!fdAll) 48173139Srwatson goto _exit; 49173139Srwatson 50173139Srwatson XGE_PRINT_HEADER_STATS(fdAll); 51173139Srwatson for(index = 0; index < count ; index++) { 52173139Srwatson switch(statsInfo[index].type) { 53173139Srwatson case 2: 54173139Srwatson statsInfo[index].value = 55173139Srwatson *((u16 *)((unsigned char *)hw_stats + 56173139Srwatson GET_OFFSET_STATS(index))); 57173139Srwatson break; 58173139Srwatson case 4: 59173139Srwatson statsInfo[index].value = 60173139Srwatson *((u32 *)((unsigned char *) hw_stats + 61173139Srwatson GET_OFFSET_STATS(index))); 62173139Srwatson break; 63173139Srwatson case 8: 64173139Srwatson statsInfo[index].value = 65173139Srwatson *((u64 *)((unsigned char *)hw_stats + 66173139Srwatson GET_OFFSET_STATS(index))); 67173139Srwatson break; 68173139Srwatson } 69173139Srwatson 70173139Srwatson XGE_PRINT_STATS(fdAll,(const char *) statsInfo[index].name, 71173139Srwatson statsInfo[index].value); 72173139Srwatson } 73173139Srwatson XGE_PRINT_LINE(fdAll); 74173139Srwatson fclose(fdAll); 75173139Srwatson_exit: 76173139Srwatson return; 77171095Ssam} 78171095Ssam 79173139Srwatson/** 80173139Srwatson * xge_print_pciconf 81173139Srwatson * Prints/logs PCI configuration space 82173139Srwatson * 83173139Srwatson * @pci_conf PCI Configuration 84173139Srwatson */ 85173139Srwatsonvoid 86173139Srwatsonxge_print_pciconf(void * pci_conf) 87171095Ssam{ 88173139Srwatson int index = 0; 89171095Ssam 90173139Srwatson fdAll = fopen("pciconf.log", "w+"); 91173139Srwatson if(!fdAll) 92173139Srwatson goto _exit; 93171095Ssam 94173139Srwatson XGE_PRINT_HEADER_PCICONF(fdAll); 95173139Srwatson for(index = 0; index < XGE_COUNT_PCICONF; index++) { 96173139Srwatson pciconfInfo[index].value = *((u16 *)((unsigned char *)pci_conf + 97173139Srwatson GET_OFFSET_PCICONF(index))); 98173139Srwatson XGE_PRINT_PCICONF(fdAll,(const char *) pciconfInfo[index].name, 99173139Srwatson GET_OFFSET_PCICONF(index), pciconfInfo[index].value); 100173139Srwatson } 101171095Ssam 102173139Srwatson XGE_PRINT_LINE(fdAll); 103173139Srwatson fclose(fdAll); 104173139Srwatson 105173139Srwatson_exit: 106173139Srwatson return; 107171095Ssam} 108171095Ssam 109173139Srwatson/** 110173139Srwatson * xge_print_devconf 111173139Srwatson * Prints/logs Device Configuration 112173139Srwatson * 113173139Srwatson * @dev_conf Device Configuration 114173139Srwatson */ 115171095Ssamvoid 116173139Srwatsonxge_print_devconf(void * dev_conf) 117171095Ssam{ 118173139Srwatson int index = 0; 119171095Ssam 120173139Srwatson fdAll = fopen("devconf.log", "w+"); 121173139Srwatson if(!fdAll) 122173139Srwatson goto _exit; 123171095Ssam 124173139Srwatson XGE_PRINT_HEADER_DEVCONF(fdAll); 125171095Ssam 126173139Srwatson for(index = 0; index < XGE_COUNT_DEVCONF; index++) { 127173139Srwatson devconfInfo[index].value = *((u32 *)((unsigned char *)dev_conf + 128173139Srwatson (index * (sizeof(int))))); 129173139Srwatson XGE_PRINT_DEVCONF(fdAll,(const char *) devconfInfo[index].name, 130173139Srwatson devconfInfo[index].value); 131173139Srwatson } 132173139Srwatson 133173139Srwatson XGE_PRINT_LINE(fdAll); 134173139Srwatson fclose( fdAll ); 135173139Srwatson 136173139Srwatson_exit: 137173139Srwatson return; 138171095Ssam} 139171095Ssam 140173139Srwatson/** 141173139Srwatson * xge_print_registers 142173139Srwatson * Prints/logs Register values 143173139Srwatson * 144173139Srwatson * @registers Register values 145173139Srwatson */ 146171095Ssamvoid 147173139Srwatsonxge_print_registers(void * registers) 148171095Ssam{ 149173139Srwatson int index = 0; 150171095Ssam 151173139Srwatson fdAll = fopen("reginfo.log", "w+"); 152173139Srwatson if(!fdAll) 153173139Srwatson goto _exit; 154171095Ssam 155173139Srwatson XGE_PRINT_HEADER_REGS(fdAll); 156171095Ssam 157173139Srwatson for(index = 0; index < XGE_COUNT_REGS; index++) { 158173139Srwatson regInfo[index].value = *((u64 *)((unsigned char *)registers + 159173139Srwatson regInfo[index].offset)); 160173139Srwatson XGE_PRINT_REGS(fdAll,(const char *) regInfo[index].name, 161173139Srwatson regInfo[index].offset, regInfo[index].value); 162173139Srwatson } 163173139Srwatson 164173139Srwatson XGE_PRINT_LINE(fdAll); 165173139Srwatson fclose(fdAll); 166173139Srwatson_exit: 167173139Srwatson return; 168171095Ssam} 169173139Srwatson 170173139Srwatson/** 171173139Srwatson * xge_print_register 172173139Srwatson * Prints/logs a register value 173173139Srwatson * 174173139Srwatson * @offset Offset of the register 175173139Srwatson * @temp??? 176173139Srwatson */ 177171095Ssamvoid 178173139Srwatsonxge_print_register(u64 offset, u64 value) 179171095Ssam{ 180173139Srwatson int index = 0; 181173139Srwatson 182173139Srwatson fdAll = fopen("readreg.log", "w+"); 183173139Srwatson if(!fdAll) 184173139Srwatson goto _exit; 185173139Srwatson 186171095Ssam XGE_PRINT_READ_HEADER_REGS(fdAll); 187173139Srwatson regInfo[index].offset = offset; 188173139Srwatson regInfo[index].value = value; 189173139Srwatson printf("0x%.8X\t0x%.16llX\n", regInfo[index].offset, 190173139Srwatson regInfo[index].value); 191173139Srwatson XGE_PRINT_LINE(fdAll); 192173139Srwatson fclose(fdAll); 193171095Ssam 194173139Srwatson_exit: 195173139Srwatson return; 196171095Ssam} 197173139Srwatson 198173139Srwatson/** 199173139Srwatson * xge_print_devstats 200173139Srwatson * Prints Device Statistics 201173139Srwatson * 202173139Srwatson * @dev_stats Device Statistics 203173139Srwatson */ 204171095Ssamvoid 205173139Srwatsonxge_print_devstats(void *dev_stats) 206171095Ssam{ 207173139Srwatson int index = 0; 208171095Ssam 209173139Srwatson fdAll = fopen("intrstats.log", "w+"); 210173139Srwatson if(!fdAll) 211173139Srwatson goto _exit; 212171095Ssam 213173139Srwatson XGE_PRINT_HEADER_STATS(fdAll); 214173139Srwatson for(index = 0; index < XGE_COUNT_INTRSTAT; index++) { 215173139Srwatson intrInfo[index].value = *((u32 *)((unsigned char *)dev_stats + 216173139Srwatson (index * (sizeof(u32))))); 217173139Srwatson XGE_PRINT_STATS(fdAll,(const char *) intrInfo[index].name, 218173139Srwatson intrInfo[index].value); 219173139Srwatson } 220171095Ssam 221173139Srwatson XGE_PRINT_LINE(fdAll); 222173139Srwatson fclose(fdAll); 223173139Srwatson_exit: 224173139Srwatson return; 225171095Ssam} 226171095Ssam 227173139Srwatson/** 228173139Srwatson * xge_print_swstats 229173139Srwatson * Prints/logs Software Statistics 230173139Srwatson * 231173139Srwatson * @sw_stats Software statistics 232173139Srwatson */ 233171095Ssamvoid 234173139Srwatsonxge_print_swstats(void * sw_stats) 235171095Ssam{ 236173139Srwatson int index = 0; 237171095Ssam 238173139Srwatson fdAll = fopen("tcodestats.log", "w+"); 239173139Srwatson if(!fdAll) 240173139Srwatson goto _exit; 241171095Ssam 242173139Srwatson XGE_PRINT_HEADER_STATS(fdAll); 243173139Srwatson for(index = 0; index < XGE_COUNT_SWSTAT; index++) { 244173139Srwatson if(!(tcodeInfo[index].flag)) { 245173139Srwatson switch(tcodeInfo[index].type) { 246173139Srwatson case 2: 247173139Srwatson tcodeInfo[index].value = 248173139Srwatson *((u16 *)((unsigned char *)sw_stats + 249173139Srwatson (index * (sizeof(u16))))); 250173139Srwatson break; 251173139Srwatson case 4: 252173139Srwatson tcodeInfo[index].value = 253173139Srwatson *((u32 *)((unsigned char *)sw_stats + 254173139Srwatson (index * (sizeof(u32))))); 255173139Srwatson break; 256173139Srwatson } 257173139Srwatson XGE_PRINT_STATS(fdAll,(const char *) tcodeInfo[index].name, 258173139Srwatson tcodeInfo[index].value); 259173139Srwatson } 260173139Srwatson } 261171095Ssam 262173139Srwatson XGE_PRINT_LINE(fdAll); 263173139Srwatson fclose(fdAll); 264173139Srwatson 265173139Srwatson_exit: 266173139Srwatson return; 267171095Ssam} 268171095Ssam 269173139Srwatson/** 270173139Srwatson * xge_print_drv_version 271173139Srwatson * Prints/logs driver version 272173139Srwatson * 273173139Srwatson * @version Driver version 274173139Srwatson */ 275171095Ssamvoid 276173139Srwatsonxge_print_drv_version(char *version) 277171095Ssam{ 278173139Srwatson fdAll = fopen("driverinfo.log", "w+"); 279173139Srwatson if(!fdAll) 280173139Srwatson goto _exit; 281173139Srwatson 282173139Srwatson XGE_PRINT_LINE(fdAll); 283173139Srwatson printf("Driver Version: %s\n", version); 284173139Srwatson XGE_PRINT_LINE(fdAll); 285173139Srwatson fclose(fdAll); 286173139Srwatson 287173139Srwatson_exit: 288173139Srwatson return; 289171095Ssam} 290171095Ssam 291173139Srwatson/** 292173139Srwatson * xge_print_drvstats 293173139Srwatson * Prints/logs Driver Statistics 294173139Srwatson * 295173139Srwatson * @driver_stats Driver Statistics 296173139Srwatson */ 297173139Srwatsonvoid 298173139Srwatsonxge_print_drvstats(void * driver_stats) 299173139Srwatson{ 300173139Srwatson int index = 0; 301173139Srwatson 302173139Srwatson fdAll = fopen("driver_stats.log", "w+"); 303173139Srwatson if(!fdAll) 304173139Srwatson goto _exit; 305173139Srwatson 306173139Srwatson XGE_PRINT_HEADER_STATS(fdAll); 307173139Srwatson 308173139Srwatson for(index = 0; index < XGE_COUNT_DRIVERSTATS; index++) { 309173139Srwatson driverInfo[index].value = *((u64 *)((unsigned char *)driver_stats + 310173139Srwatson (index * (sizeof(u64))))); 311173139Srwatson XGE_PRINT_STATS(fdAll,(const char *) driverInfo[index].name, 312173139Srwatson driverInfo[index].value); 313173139Srwatson } 314173139Srwatson 315173139Srwatson XGE_PRINT_LINE(fdAll); 316173139Srwatson fclose( fdAll ); 317173139Srwatson 318173139Srwatson_exit: 319173139Srwatson return; 320173139Srwatson} 321173139Srwatson 322