1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /* Stage 5 definitions for creating trace events */
4 
5 /*
6  * remember the offset of each array from the beginning of the event.
7  */
8 
9 #undef __entry
10 #define __entry entry
11 
12 #undef __field
13 #define __field(type, item)
14 
15 #undef __field_ext
16 #define __field_ext(type, item, filter_type)
17 
18 #undef __field_struct
19 #define __field_struct(type, item)
20 
21 #undef __field_struct_ext
22 #define __field_struct_ext(type, item, filter_type)
23 
24 #undef __array
25 #define __array(type, item, len)
26 
27 #undef __dynamic_array
28 #define __dynamic_array(type, item, len)				\
29 	__item_length = (len) * sizeof(type);				\
30 	__data_offsets->item = __data_size +				\
31 			       offsetof(typeof(*entry), __data);	\
32 	__data_offsets->item |= __item_length << 16;			\
33 	__data_size += __item_length;
34 
35 #undef __string
36 #define __string(item, src) __dynamic_array(char, item,			\
37 		    strlen((src) ? (const char *)(src) : "(null)") + 1)
38 
39 #undef __string_len
40 #define __string_len(item, src, len) __dynamic_array(char, item, (len) + 1)
41 
42 #undef __vstring
43 #define __vstring(item, fmt, ap) __dynamic_array(char, item,		\
44 		      __trace_event_vstr_len(fmt, ap))
45 
46 #undef __rel_dynamic_array
47 #define __rel_dynamic_array(type, item, len)				\
48 	__item_length = (len) * sizeof(type);				\
49 	__data_offsets->item = __data_size +				\
50 			       offsetof(typeof(*entry), __data) -	\
51 			       offsetof(typeof(*entry), __rel_loc_##item) -	\
52 			       sizeof(u32);				\
53 	__data_offsets->item |= __item_length << 16;			\
54 	__data_size += __item_length;
55 
56 #undef __rel_string
57 #define __rel_string(item, src) __rel_dynamic_array(char, item,			\
58 		    strlen((src) ? (const char *)(src) : "(null)") + 1)
59 
60 #undef __rel_string_len
61 #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, (len) + 1)
62 /*
63  * __bitmask_size_in_bytes_raw is the number of bytes needed to hold
64  * num_possible_cpus().
65  */
66 #define __bitmask_size_in_bytes_raw(nr_bits)	\
67 	(((nr_bits) + 7) / 8)
68 
69 #define __bitmask_size_in_longs(nr_bits)			\
70 	((__bitmask_size_in_bytes_raw(nr_bits) +		\
71 	  ((BITS_PER_LONG / 8) - 1)) / (BITS_PER_LONG / 8))
72 
73 /*
74  * __bitmask_size_in_bytes is the number of bytes needed to hold
75  * num_possible_cpus() padded out to the nearest long. This is what
76  * is saved in the buffer, just to be consistent.
77  */
78 #define __bitmask_size_in_bytes(nr_bits)				\
79 	(__bitmask_size_in_longs(nr_bits) * (BITS_PER_LONG / 8))
80 
81 #undef __bitmask
82 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item,	\
83 					 __bitmask_size_in_longs(nr_bits))
84 
85 #undef __rel_bitmask
86 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item,	\
87 					 __bitmask_size_in_longs(nr_bits))
88 
89 #undef __sockaddr
90 #define __sockaddr(field, len) __dynamic_array(u8, field, len)
91 
92 #undef __rel_sockaddr
93 #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
94