cvmx-log.h revision 215990
1/***********************license start*************** 2 * Copyright (c) 2003-2010 Cavium Networks (support@cavium.com). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 18 * * Neither the name of Cavium Networks nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 23 * This Software, including technical data, may be subject to U.S. export control 24 * laws, including the U.S. Export Administration Act and its associated 25 * regulations, and may be subject to export or import regulations in other 26 * countries. 27 28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR 30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38 ***********************license end**************************************/ 39 40 41 42 43 44 45#ifndef __CVMX_LOG_H__ 46#define __CVMX_LOG_H__ 47 48/** 49 * @file 50 * 51 * cvmx-log supplies a fast log buffer implementation. Each core writes 52 * log data to a differnet buffer to avoid synchronization overhead. Function 53 * call logging can be turned on with the GCC option "-pg". 54 * 55 * <hr>$Revision: 49448 $<hr> 56 */ 57 58#ifdef __cplusplus 59extern "C" { 60#endif 61 62/* 63 * Add CVMX_LOG_DISABLE_PC_LOGGING as an attribute to and function prototype 64 * that you don't want logged when the gcc option "-pg" is supplied. We 65 * use it on the cvmx-log functions since it is pointless to log the 66 * calling of a function than in itself writes to the log. 67 */ 68#define CVMX_LOG_DISABLE_PC_LOGGING __attribute__((no_instrument_function)) 69 70/** 71 * Log a constant printf style format string with 0 to 4 72 * arguments. The string must persist until the log is read, 73 * but the parameters are copied into the log. 74 * 75 * @param format Constant printf style format string. 76 * @param numberx 64bit argument to the printf format string 77 */ 78void cvmx_log_printf0(const char *format) CVMX_LOG_DISABLE_PC_LOGGING; 79void cvmx_log_printf1(const char *format, uint64_t number1) CVMX_LOG_DISABLE_PC_LOGGING; 80void cvmx_log_printf2(const char *format, uint64_t number1, uint64_t number2) CVMX_LOG_DISABLE_PC_LOGGING; 81void cvmx_log_printf3(const char *format, uint64_t number1, uint64_t number2, uint64_t number3) CVMX_LOG_DISABLE_PC_LOGGING; 82void cvmx_log_printf4(const char *format, uint64_t number1, uint64_t number2, uint64_t number3, uint64_t number4) CVMX_LOG_DISABLE_PC_LOGGING; 83 84/** 85 * Log an arbitrary block of 64bit words. At most 255 64bit 86 * words can be logged. The words are copied into the log. 87 * 88 * @param size_in_dwords 89 * Number of 64bit dwords to copy into the log. 90 * @param data Array of 64bit dwords to copy 91 */ 92void cvmx_log_data(uint64_t size_in_dwords, const uint64_t *data) CVMX_LOG_DISABLE_PC_LOGGING; 93 94/** 95 * Log a structured data object. Post processing will use the 96 * debugging information in the ELF file to determine how to 97 * display the structure. Max of 2032 bytes. 98 * 99 * Example: 100 * cvmx_log_structure("cvmx_wqe_t", work, sizeof(*work)); 101 * 102 * @param type C typedef expressed as a string. This will be used to 103 * lookup the structure in the debugging infirmation. 104 * @param data Data to be written to the log. 105 * @param size_in_bytes 106 * Size if the data in bytes. Normally you'll use the 107 * sizeof() operator here. 108 */ 109void cvmx_log_structure(const char *type, void *data, int size_in_bytes) CVMX_LOG_DISABLE_PC_LOGGING; 110 111/** 112 * Setup the mips performance counters 113 * 114 * @param counter1 Event type for counter 1 115 * @param counter2 Event type for counter 2 116 */ 117void cvmx_log_perf_setup(cvmx_core_perf_t counter1, cvmx_core_perf_t counter2); 118 119/** 120 * Log the performance counters 121 */ 122void cvmx_log_perf(void) CVMX_LOG_DISABLE_PC_LOGGING; 123 124/** 125 * Display the current log in a human readable format. 126 */ 127void cvmx_log_display(void); 128 129#ifdef __cplusplus 130} 131#endif 132 133#endif 134