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