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_rel_bitmask
46 #define __get_rel_bitmask(field)						\
47 	({								\
48 		void *__bitmask = __get_rel_dynamic_array(field);		\
49 		unsigned int __bitmask_size;				\
50 		__bitmask_size = __get_rel_dynamic_array_len(field);	\
51 		trace_print_bitmask_seq(p, __bitmask, __bitmask_size);	\
52 	})
53 
54 #undef __get_sockaddr
55 #define __get_sockaddr(field)	((struct sockaddr *)__get_dynamic_array(field))
56 
57 #undef __get_rel_sockaddr
58 #define __get_rel_sockaddr(field)	((struct sockaddr *)__get_rel_dynamic_array(field))
59 
60 #undef __print_flags
61 #define __print_flags(flag, delim, flag_array...)			\
62 	({								\
63 		static const struct trace_print_flags __flags[] =	\
64 			{ flag_array, { -1, NULL }};			\
65 		trace_print_flags_seq(p, delim, flag, __flags);	\
66 	})
67 
68 #undef __print_symbolic
69 #define __print_symbolic(value, symbol_array...)			\
70 	({								\
71 		static const struct trace_print_flags symbols[] =	\
72 			{ symbol_array, { -1, NULL }};			\
73 		trace_print_symbols_seq(p, value, symbols);		\
74 	})
75 
76 #undef __print_flags_u64
77 #undef __print_symbolic_u64
78 #if BITS_PER_LONG == 32
79 #define __print_flags_u64(flag, delim, flag_array...)			\
80 	({								\
81 		static const struct trace_print_flags_u64 __flags[] =	\
82 			{ flag_array, { -1, NULL } };			\
83 		trace_print_flags_seq_u64(p, delim, flag, __flags);	\
84 	})
85 
86 #define __print_symbolic_u64(value, symbol_array...)			\
87 	({								\
88 		static const struct trace_print_flags_u64 symbols[] =	\
89 			{ symbol_array, { -1, NULL } };			\
90 		trace_print_symbols_seq_u64(p, value, symbols);	\
91 	})
92 #else
93 #define __print_flags_u64(flag, delim, flag_array...)			\
94 			__print_flags(flag, delim, flag_array)
95 
96 #define __print_symbolic_u64(value, symbol_array...)			\
97 			__print_symbolic(value, symbol_array)
98 #endif
99 
100 #undef __print_hex
101 #define __print_hex(buf, buf_len)					\
102 	trace_print_hex_seq(p, buf, buf_len, false)
103 
104 #undef __print_hex_str
105 #define __print_hex_str(buf, buf_len)					\
106 	trace_print_hex_seq(p, buf, buf_len, true)
107 
108 #undef __print_array
109 #define __print_array(array, count, el_size)				\
110 	({								\
111 		BUILD_BUG_ON(el_size != 1 && el_size != 2 &&		\
112 			     el_size != 4 && el_size != 8);		\
113 		trace_print_array_seq(p, array, count, el_size);	\
114 	})
115 
116 #undef __print_hex_dump
117 #define __print_hex_dump(prefix_str, prefix_type,			\
118 			 rowsize, groupsize, buf, len, ascii)		\
119 	trace_print_hex_dump_seq(p, prefix_str, prefix_type,		\
120 				 rowsize, groupsize, buf, len, ascii)
121 
122 #undef __print_ns_to_secs
123 #define __print_ns_to_secs(value)			\
124 	({						\
125 		u64 ____val = (u64)(value);		\
126 		do_div(____val, NSEC_PER_SEC);		\
127 		____val;				\
128 	})
129 
130 #undef __print_ns_without_secs
131 #define __print_ns_without_secs(value)			\
132 	({						\
133 		u64 ____val = (u64)(value);		\
134 		(u32) do_div(____val, NSEC_PER_SEC);	\
135 	})
136