1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, v.1, (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://opensource.org/licenses/CDDL-1.0. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2014-2017 Cavium, Inc. 24 * The contents of this file are subject to the terms of the Common Development 25 * and Distribution License, v.1, (the "License"). 26 27 * You may not use this file except in compliance with the License. 28 29 * You can obtain a copy of the License at available 30 * at http://opensource.org/licenses/CDDL-1.0 31 32 * See the License for the specific language governing permissions and 33 * limitations under the License. 34 */ 35 36 /* To use this file, please define the following macros: 37 * MFWT_ALLOC(size) - allocate memory for array 38 * MFWT_FREE(void *) - free memory 39 * MFWT_STRNCPY(d,s,n) - copy string up to size n 40 * MFWT_ERROR(fmt, ...) - error print 41 * MFWT_TRACE(fmt, ...) - debug trace 42 * ENOMEM - return value for: Out of memory 43 * EINVAL - return value for: Invalid argument 44 */ 45 #ifndef MFW_TRACE_H 46 #define MFW_TRACE_H 47 48 #include "mfw_hsi.h" 49 50 struct mfw_trace_fmt; 51 52 struct mfw_trace_meta { 53 unsigned int modules_num; 54 char **modules; 55 unsigned int fmts_num; 56 struct mfw_trace_fmt *fmts; 57 }; 58 59 /** 60 * @brief mfw_trace_load_meta_data - load the meta data into memory 61 * 62 * This function allocates memory for all the formats. The 63 * mfw_trace_free_meta_data should be called to release this memory. 64 * 65 * @param input_str - the content of the meta data 66 * @param p_meta - the output struct that will contain all the allocated 67 * memory for the fromats 68 * 69 * @status - 0 on success 70 */ 71 u32 mfw_trace_load_meta_data(const char *input_str, 72 struct mfw_trace_meta *p_meta); 73 74 /** 75 * @brief mfw_trace_free_meta_data - releases all the allocated memory 76 * 77 * This function releases the memory allocated by mfw_trace_load_meta_data. 78 * 79 * @param p_meta 80 */ 81 void mfw_trace_free_meta_data(struct mfw_trace_meta *p_meta); 82 83 /** 84 * @brief mfw_trace_parse_trace - releases all the allocated memory 85 * 86 * This function releases the memory allocated by mfw_trace_load_meta_data. 87 * 88 * @param trace_buffer - the buffer read from the chip 89 * @param p_meta - the parsed meta data 90 * @param p_print - the function used to print the parsed trace 91 * 92 * @status - 0 on success 93 */ 94 typedef int (*output_printf) (const char *fmt, ...); 95 u32 mfw_trace_parse_trace(struct mcp_trace *p_trace, 96 struct mfw_trace_meta *p_meta, 97 output_printf p_print); 98 99 #endif /* MFW_TRACE_H */ 100