1210284Sjmallett/***********************license start*************** 2215990Sjmallett * Copyright (c) 2003-2010 Cavium Networks (support@cavium.com). All rights 3215990Sjmallett * reserved. 4210284Sjmallett * 5210284Sjmallett * 6215990Sjmallett * Redistribution and use in source and binary forms, with or without 7215990Sjmallett * modification, are permitted provided that the following conditions are 8215990Sjmallett * met: 9210284Sjmallett * 10215990Sjmallett * * Redistributions of source code must retain the above copyright 11215990Sjmallett * notice, this list of conditions and the following disclaimer. 12210284Sjmallett * 13215990Sjmallett * * Redistributions in binary form must reproduce the above 14215990Sjmallett * copyright notice, this list of conditions and the following 15215990Sjmallett * disclaimer in the documentation and/or other materials provided 16215990Sjmallett * with the distribution. 17215990Sjmallett 18215990Sjmallett * * Neither the name of Cavium Networks nor the names of 19215990Sjmallett * its contributors may be used to endorse or promote products 20215990Sjmallett * derived from this software without specific prior written 21215990Sjmallett * permission. 22215990Sjmallett 23215990Sjmallett * This Software, including technical data, may be subject to U.S. export control 24215990Sjmallett * laws, including the U.S. Export Administration Act and its associated 25215990Sjmallett * regulations, and may be subject to export or import regulations in other 26215990Sjmallett * countries. 27215990Sjmallett 28215990Sjmallett * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29215990Sjmallett * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR 30215990Sjmallett * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31215990Sjmallett * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32215990Sjmallett * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33215990Sjmallett * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34215990Sjmallett * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35215990Sjmallett * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36215990Sjmallett * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37215990Sjmallett * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38210284Sjmallett ***********************license end**************************************/ 39210284Sjmallett 40210284Sjmallett 41210284Sjmallett 42210284Sjmallett 43210284Sjmallett 44215990Sjmallett 45210284Sjmallett#ifndef __CVMX_LOG_H__ 46210284Sjmallett#define __CVMX_LOG_H__ 47210284Sjmallett 48210284Sjmallett/** 49210284Sjmallett * @file 50210284Sjmallett * 51210284Sjmallett * cvmx-log supplies a fast log buffer implementation. Each core writes 52210284Sjmallett * log data to a differnet buffer to avoid synchronization overhead. Function 53210284Sjmallett * call logging can be turned on with the GCC option "-pg". 54210284Sjmallett * 55215990Sjmallett * <hr>$Revision: 49448 $<hr> 56210284Sjmallett */ 57210284Sjmallett 58210284Sjmallett#ifdef __cplusplus 59210284Sjmallettextern "C" { 60210284Sjmallett#endif 61210284Sjmallett 62210284Sjmallett/* 63210284Sjmallett * Add CVMX_LOG_DISABLE_PC_LOGGING as an attribute to and function prototype 64210284Sjmallett * that you don't want logged when the gcc option "-pg" is supplied. We 65210284Sjmallett * use it on the cvmx-log functions since it is pointless to log the 66210284Sjmallett * calling of a function than in itself writes to the log. 67210284Sjmallett */ 68210284Sjmallett#define CVMX_LOG_DISABLE_PC_LOGGING __attribute__((no_instrument_function)) 69210284Sjmallett 70210284Sjmallett/** 71210284Sjmallett * Log a constant printf style format string with 0 to 4 72210284Sjmallett * arguments. The string must persist until the log is read, 73210284Sjmallett * but the parameters are copied into the log. 74210284Sjmallett * 75210284Sjmallett * @param format Constant printf style format string. 76210284Sjmallett * @param numberx 64bit argument to the printf format string 77210284Sjmallett */ 78210284Sjmallettvoid cvmx_log_printf0(const char *format) CVMX_LOG_DISABLE_PC_LOGGING; 79210284Sjmallettvoid cvmx_log_printf1(const char *format, uint64_t number1) CVMX_LOG_DISABLE_PC_LOGGING; 80210284Sjmallettvoid cvmx_log_printf2(const char *format, uint64_t number1, uint64_t number2) CVMX_LOG_DISABLE_PC_LOGGING; 81210284Sjmallettvoid cvmx_log_printf3(const char *format, uint64_t number1, uint64_t number2, uint64_t number3) CVMX_LOG_DISABLE_PC_LOGGING; 82210284Sjmallettvoid cvmx_log_printf4(const char *format, uint64_t number1, uint64_t number2, uint64_t number3, uint64_t number4) CVMX_LOG_DISABLE_PC_LOGGING; 83210284Sjmallett 84210284Sjmallett/** 85210284Sjmallett * Log an arbitrary block of 64bit words. At most 255 64bit 86210284Sjmallett * words can be logged. The words are copied into the log. 87210284Sjmallett * 88210284Sjmallett * @param size_in_dwords 89210284Sjmallett * Number of 64bit dwords to copy into the log. 90210284Sjmallett * @param data Array of 64bit dwords to copy 91210284Sjmallett */ 92210284Sjmallettvoid cvmx_log_data(uint64_t size_in_dwords, const uint64_t *data) CVMX_LOG_DISABLE_PC_LOGGING; 93210284Sjmallett 94210284Sjmallett/** 95210284Sjmallett * Log a structured data object. Post processing will use the 96210284Sjmallett * debugging information in the ELF file to determine how to 97210284Sjmallett * display the structure. Max of 2032 bytes. 98210284Sjmallett * 99210284Sjmallett * Example: 100210284Sjmallett * cvmx_log_structure("cvmx_wqe_t", work, sizeof(*work)); 101210284Sjmallett * 102210284Sjmallett * @param type C typedef expressed as a string. This will be used to 103210284Sjmallett * lookup the structure in the debugging infirmation. 104210284Sjmallett * @param data Data to be written to the log. 105210284Sjmallett * @param size_in_bytes 106210284Sjmallett * Size if the data in bytes. Normally you'll use the 107210284Sjmallett * sizeof() operator here. 108210284Sjmallett */ 109210284Sjmallettvoid cvmx_log_structure(const char *type, void *data, int size_in_bytes) CVMX_LOG_DISABLE_PC_LOGGING; 110210284Sjmallett 111210284Sjmallett/** 112210284Sjmallett * Setup the mips performance counters 113210284Sjmallett * 114210284Sjmallett * @param counter1 Event type for counter 1 115210284Sjmallett * @param counter2 Event type for counter 2 116210284Sjmallett */ 117215990Sjmallettvoid cvmx_log_perf_setup(cvmx_core_perf_t counter1, cvmx_core_perf_t counter2); 118210284Sjmallett 119210284Sjmallett/** 120210284Sjmallett * Log the performance counters 121210284Sjmallett */ 122210284Sjmallettvoid cvmx_log_perf(void) CVMX_LOG_DISABLE_PC_LOGGING; 123210284Sjmallett 124210284Sjmallett/** 125210284Sjmallett * Display the current log in a human readable format. 126210284Sjmallett */ 127210284Sjmallettvoid cvmx_log_display(void); 128210284Sjmallett 129210284Sjmallett#ifdef __cplusplus 130210284Sjmallett} 131210284Sjmallett#endif 132210284Sjmallett 133210284Sjmallett#endif 134