1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /* Stage 3 definitions for creating trace events */
4 
5 #undef __entry
6 #define __entry field
7 
8 #undef TP_printk
9 #define TP_printk(fmt, args...) fmt "\n", args
10 
11 #undef __get_dynamic_array
12 #define __get_dynamic_array(field)	\
13 		((void *)__entry + (__entry->__data_loc_##field & 0xffff))
14 
15 #undef __get_dynamic_array_len
16 #define __get_dynamic_array_len(field)	\
17 		((__entry->__data_loc_##field >> 16) & 0xffff)
18 
19 #undef __get_str
20 #define __get_str(field) ((char *)__get_dynamic_array(field))
21 
22 #undef __get_rel_dynamic_array
23 #define __get_rel_dynamic_array(field)					\
24 		((void *)__entry + 					\
25 		 offsetof(typeof(*__entry), __rel_loc_##field) +	\
26 		 sizeof(__entry->__rel_loc_##field) +			\
27 		 (__entry->__rel_loc_##field & 0xffff))
28 
29 #undef __get_rel_dynamic_array_len
30 #define __get_rel_dynamic_array_len(field)	\
31 		((__entry->__rel_loc_##field >> 16) & 0xffff)
32 
33 #undef __get_rel_str
34 #define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field))
35 
36 #undef __get_bitmask
37 #define __get_bitmask(field)						\
38 	({								\
39 		void *__bitmask = __get_dynamic_array(field);		\
40 		unsigned int __bitmask_size;				\
41 		__bitmask_size = __get_dynamic_array_len(field);	\
42 		trace_print_bitmask_seq(p, __bitmask, __bitmask_size);	\
43 	})
44 
45 #undef __get_cpumask
46 #define __get_cpumask(field) __get_bitmask(field)
47 
48 #undef __get_rel_bitmask
49 #define __get_rel_bitmask(field)						\
50 	({								\
51 		void *__bitmask = __get_rel_dynamic_array(field);		\
52 		unsigned int __bitmask_size;				\
53 		__bitmask_size = __get_rel_dynamic_array_len(field);	\
54 		trace_print_bitmask_seq(p, __bitmask, __bitmask_size);	\
55 	})
56 
57 #undef __get_rel_cpumask
58 #define __get_rel_cpumask(field) __get_rel_bitmask(field)
59 
60 #undef __get_sockaddr
61 #define __get_sockaddr(field)	((struct sockaddr *)__get_dynamic_array(field))
62 
63 #undef __get_rel_sockaddr
64 #define __get_rel_sockaddr(field)	((struct sockaddr *)__get_rel_dynamic_array(field))
65 
66 #undef __print_flags
67 #define __print_flags(flag, delim, flag_array...)			\
68 	({								\
69 		static const struct trace_print_flags __flags[] =	\
70 			{ flag_array, { -1, NULL }};			\
71 		trace_print_flags_seq(p, delim, flag, __flags);	\
72 	})
73 
74 #undef __print_symbolic
75 #define __print_symbolic(value, symbol_array...)			\
76 	({								\
77 		static const struct trace_print_flags symbols[] =	\
78 			{ symbol_array, { -1, NULL }};			\
79 		trace_print_symbols_seq(p, value, symbols);		\
80 	})
81 
82 #undef __print_flags_u64
83 #undef __print_symbolic_u64
84 #if BITS_PER_LONG == 32
85 #define __print_flags_u64(flag, delim, flag_array...)			\
86 	({								\
87 		static const struct trace_print_flags_u64 __flags[] =	\
88 			{ flag_array, { -1, NULL } };			\
89 		trace_print_flags_seq_u64(p, delim, flag, __flags);	\
90 	})
91 
92 #define __print_symbolic_u64(value, symbol_array...)			\
93 	({								\
94 		static const struct trace_print_flags_u64 symbols[] =	\
95 			{ symbol_array, { -1, NULL } };			\
96 		trace_print_symbols_seq_u64(p, value, symbols);	\
97 	})
98 #else
99 #define __print_flags_u64(flag, delim, flag_array...)			\
100 			__print_flags(flag, delim, flag_array)
101 
102 #define __print_symbolic_u64(value, symbol_array...)			\
103 			__print_symbolic(value, symbol_array)
104 #endif
105 
106 #undef __print_hex
107 #define __print_hex(buf, buf_len)					\
108 	trace_print_hex_seq(p, buf, buf_len, false)
109 
110 #undef __print_hex_str
111 #define __print_hex_str(buf, buf_len)					\
112 	trace_print_hex_seq(p, buf, buf_len, true)
113 
114 #undef __print_array
115 #define __print_array(array, count, el_size)				\
116 	({								\
117 		BUILD_BUG_ON(el_size != 1 && el_size != 2 &&		\
118 			     el_size != 4 && el_size != 8);		\
119 		trace_print_array_seq(p, array, count, el_size);	\
120 	})
121 
122 #undef __print_hex_dump
123 #define __print_hex_dump(prefix_str, prefix_type,			\
124 			 rowsize, groupsize, buf, len, ascii)		\
125 	trace_print_hex_dump_seq(p, prefix_str, prefix_type,		\
126 				 rowsize, groupsize, buf, len, ascii)
127 
128 #undef __print_ns_to_secs
129 #define __print_ns_to_secs(value)			\
130 	({						\
131 		u64 ____val = (u64)(value);		\
132 		do_div(____val, NSEC_PER_SEC);		\
133 		____val;				\
134 	})
135 
136 #undef __print_ns_without_secs
137 #define __print_ns_without_secs(value)			\
138 	({						\
139 		u64 ____val = (u64)(value);		\
140 		(u32) do_div(____val, NSEC_PER_SEC);	\
141 	})
142 
143 #undef __get_buf
144 #define __get_buf(len)		trace_seq_acquire(p, (len))
145