1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2022 Intel Corporation */ 3 /****************************************************************************** 4 * @file icp_adf_debug.h 5 * 6 * @description 7 * This header file that contains the prototypes and definitions required 8 * for ADF debug feature. 9 * 10 *****************************************************************************/ 11 #ifndef ICP_ADF_DEBUG_H 12 #define ICP_ADF_DEBUG_H 13 14 /* 15 * adf_proc_type_t 16 * Type of proc file. Simple for files where read funct 17 * prints less than page size (4kB) and seq type for files 18 * where read function needs to print more that page size. 19 */ 20 typedef enum adf_proc_type_e { 21 ADF_PROC_SIMPLE = 1, 22 ADF_PROC_SEQ 23 } adf_proc_type_t; 24 25 /* 26 * debug_dir_info_t 27 * Struct which is used to hold information about a debug directory 28 * under the proc filesystem. 29 * Client should only set name and parent fields. 30 */ 31 typedef struct debug_dir_info_s { 32 char *name; 33 struct debug_dir_info_s *parent; 34 /* The below fields are used internally by the driver */ 35 struct debug_dir_info_s *dirChildListHead; 36 struct debug_dir_info_s *dirChildListTail; 37 struct debug_dir_info_s *pNext; 38 struct debug_dir_info_s *pPrev; 39 struct debug_file_info_s *fileListHead; 40 struct debug_file_info_s *fileListTail; 41 void *proc_entry; 42 } debug_dir_info_t; 43 44 /* 45 * Read handle type for simple proc file 46 * Function is called only once and can print up to 4kB (size) 47 * Function should return number of bytes printed. 48 */ 49 typedef int (*file_read)(void *private_data, char *buff, int size); 50 51 /* 52 * Read handle type for sequential proc file 53 * Function can be called more than once. It will be called until the 54 * return value is not 0. offset should be used to mark the starting 55 * point for next step. In one go function can print up to 4kB (size). 56 * Function should return 0 (zero) if all info is printed or 57 * offset from where to start in next step. 58 */ 59 typedef int (*file_read_seq)(void *private_data, 60 char *buff, 61 int size, 62 int offset); 63 64 /* 65 * debug_file_info_t 66 * Struct which is used to hold information about a debug file 67 * under the proc filesystem. 68 * Client should only set name, type, private_data, parent fields, 69 * and read or seq_read pointers depending on type used. 70 */ 71 typedef struct debug_file_info_s { 72 char *name; 73 struct debug_dir_info_s *parent; 74 adf_proc_type_t type; 75 file_read read; 76 file_read_seq seq_read; 77 void *private_data; 78 /* The below fields are used internally by the driver */ 79 struct debug_file_info_s *pNext; 80 struct debug_file_info_s *pPrev; 81 void *page; 82 Cpa32U offset; 83 void *proc_entry; 84 } debug_file_info_t; 85 86 /* 87 * icp_adf_debugAddDir 88 * 89 * Description: 90 * Function used by subsystem to register a new 91 * directory under the proc filesystem 92 * 93 * Returns: 94 * CPA_STATUS_SUCCESS on success 95 * CPA_STATUS_FAIL on failure 96 */ 97 CpaStatus icp_adf_debugAddDir(icp_accel_dev_t *accel_dev, 98 debug_dir_info_t *dir_info); 99 100 /* 101 * icp_adf_debugRemoveDir 102 * 103 * Description: 104 * Function used by subsystem to remove an existing 105 * directory for which debug output may be stored 106 * in the proc filesystem. 107 * 108 */ 109 void icp_adf_debugRemoveDir(debug_dir_info_t *dir_info); 110 111 /* 112 * icp_adf_debugAddFile 113 * 114 * Description: 115 * Function used by subsystem to add a new file under 116 * the proc file system in which debug output may be written 117 * 118 * Returns: 119 * CPA_STATUS_SUCCESS on success 120 * CPA_STATUS_FAIL on failure 121 */ 122 CpaStatus icp_adf_debugAddFile(icp_accel_dev_t *accel_dev, 123 debug_file_info_t *file_info); 124 125 /* 126 * icp_adf_debugRemoveFile 127 * 128 * Description: 129 * Function used by subsystem to remove an existing file under 130 * the proc filesystem in which debug output may be written 131 * 132 */ 133 void icp_adf_debugRemoveFile(debug_file_info_t *file_info); 134 135 #endif /* ICP_ADF_DEBUG_H */ 136