xref: /openbmc/linux/net/l2tp/trace.h (revision dd1fc3c5)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM l2tp
4 
5 #if !defined(_TRACE_L2TP_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_L2TP_H
7 
8 #include <linux/tracepoint.h>
9 #include <linux/l2tp.h>
10 #include "l2tp_core.h"
11 
12 #define encap_type_name(e) { L2TP_ENCAPTYPE_##e, #e }
13 #define show_encap_type_name(val) \
14 	__print_symbolic(val, \
15 			encap_type_name(UDP), \
16 			encap_type_name(IP))
17 
18 #define pw_type_name(p) { L2TP_PWTYPE_##p, #p }
19 #define show_pw_type_name(val) \
20 	__print_symbolic(val, \
21 	pw_type_name(ETH_VLAN), \
22 	pw_type_name(ETH), \
23 	pw_type_name(PPP), \
24 	pw_type_name(PPP_AC), \
25 	pw_type_name(IP))
26 
27 DECLARE_EVENT_CLASS(tunnel_only_evt,
28 	TP_PROTO(struct l2tp_tunnel *tunnel),
29 	TP_ARGS(tunnel),
30 	TP_STRUCT__entry(
31 		__array(char, name, L2TP_TUNNEL_NAME_MAX)
32 	),
33 	TP_fast_assign(
34 		memcpy(__entry->name, tunnel->name, L2TP_TUNNEL_NAME_MAX);
35 	),
36 	TP_printk("%s", __entry->name)
37 );
38 
39 DECLARE_EVENT_CLASS(session_only_evt,
40 	TP_PROTO(struct l2tp_session *session),
41 	TP_ARGS(session),
42 	TP_STRUCT__entry(
43 		__array(char, name, L2TP_SESSION_NAME_MAX)
44 	),
45 	TP_fast_assign(
46 		memcpy(__entry->name, session->name, L2TP_SESSION_NAME_MAX);
47 	),
48 	TP_printk("%s", __entry->name)
49 );
50 
51 TRACE_EVENT(register_tunnel,
52 	TP_PROTO(struct l2tp_tunnel *tunnel),
53 	TP_ARGS(tunnel),
54 	TP_STRUCT__entry(
55 		__array(char, name, L2TP_TUNNEL_NAME_MAX)
56 		__field(int, fd)
57 		__field(u32, tid)
58 		__field(u32, ptid)
59 		__field(int, version)
60 		__field(enum l2tp_encap_type, encap)
61 	),
62 	TP_fast_assign(
63 		memcpy(__entry->name, tunnel->name, L2TP_TUNNEL_NAME_MAX);
64 		__entry->fd = tunnel->fd;
65 		__entry->tid = tunnel->tunnel_id;
66 		__entry->ptid = tunnel->peer_tunnel_id;
67 		__entry->version = tunnel->version;
68 		__entry->encap = tunnel->encap;
69 	),
70 	TP_printk("%s: type=%s encap=%s version=L2TPv%d tid=%u ptid=%u fd=%d",
71 		__entry->name,
72 		__entry->fd > 0 ? "managed" : "unmanaged",
73 		show_encap_type_name(__entry->encap),
74 		__entry->version,
75 		__entry->tid,
76 		__entry->ptid,
77 		__entry->fd)
78 );
79 
80 DEFINE_EVENT(tunnel_only_evt, delete_tunnel,
81 	TP_PROTO(struct l2tp_tunnel *tunnel),
82 	TP_ARGS(tunnel)
83 );
84 
85 DEFINE_EVENT(tunnel_only_evt, free_tunnel,
86 	TP_PROTO(struct l2tp_tunnel *tunnel),
87 	TP_ARGS(tunnel)
88 );
89 
90 TRACE_EVENT(register_session,
91 	TP_PROTO(struct l2tp_session *session),
92 	TP_ARGS(session),
93 	TP_STRUCT__entry(
94 		__array(char, name, L2TP_SESSION_NAME_MAX)
95 		__field(u32, tid)
96 		__field(u32, ptid)
97 		__field(u32, sid)
98 		__field(u32, psid)
99 		__field(enum l2tp_pwtype, pwtype)
100 	),
101 	TP_fast_assign(
102 		memcpy(__entry->name, session->name, L2TP_SESSION_NAME_MAX);
103 		__entry->tid = session->tunnel ? session->tunnel->tunnel_id : 0;
104 		__entry->ptid = session->tunnel ? session->tunnel->peer_tunnel_id : 0;
105 		__entry->sid = session->session_id;
106 		__entry->psid = session->peer_session_id;
107 		__entry->pwtype = session->pwtype;
108 	),
109 	TP_printk("%s: pseudowire=%s sid=%u psid=%u tid=%u ptid=%u",
110 		__entry->name,
111 		show_pw_type_name(__entry->pwtype),
112 		__entry->sid,
113 		__entry->psid,
114 		__entry->sid,
115 		__entry->psid)
116 );
117 
118 DEFINE_EVENT(session_only_evt, delete_session,
119 	TP_PROTO(struct l2tp_session *session),
120 	TP_ARGS(session)
121 );
122 
123 DEFINE_EVENT(session_only_evt, free_session,
124 	TP_PROTO(struct l2tp_session *session),
125 	TP_ARGS(session)
126 );
127 
128 DEFINE_EVENT(session_only_evt, session_seqnum_lns_enable,
129 	TP_PROTO(struct l2tp_session *session),
130 	TP_ARGS(session)
131 );
132 
133 DEFINE_EVENT(session_only_evt, session_seqnum_lns_disable,
134 	TP_PROTO(struct l2tp_session *session),
135 	TP_ARGS(session)
136 );
137 
138 DECLARE_EVENT_CLASS(session_seqnum_evt,
139 	TP_PROTO(struct l2tp_session *session),
140 	TP_ARGS(session),
141 	TP_STRUCT__entry(
142 		__array(char, name, L2TP_SESSION_NAME_MAX)
143 		__field(u32, ns)
144 		__field(u32, nr)
145 	),
146 	TP_fast_assign(
147 		memcpy(__entry->name, session->name, L2TP_SESSION_NAME_MAX);
148 		__entry->ns = session->ns;
149 		__entry->nr = session->nr;
150 	),
151 	TP_printk("%s: ns=%u nr=%u",
152 		__entry->name,
153 		__entry->ns,
154 		__entry->nr)
155 );
156 
157 DEFINE_EVENT(session_seqnum_evt, session_seqnum_update,
158 	TP_PROTO(struct l2tp_session *session),
159 	TP_ARGS(session)
160 );
161 
162 DEFINE_EVENT(session_seqnum_evt, session_seqnum_reset,
163 	TP_PROTO(struct l2tp_session *session),
164 	TP_ARGS(session)
165 );
166 
167 DECLARE_EVENT_CLASS(session_pkt_discard_evt,
168 	TP_PROTO(struct l2tp_session *session, u32 pkt_ns),
169 	TP_ARGS(session, pkt_ns),
170 	TP_STRUCT__entry(
171 		__array(char, name, L2TP_SESSION_NAME_MAX)
172 		__field(u32, pkt_ns)
173 		__field(u32, my_nr)
174 		__field(u32, reorder_q_len)
175 	),
176 	TP_fast_assign(
177 		memcpy(__entry->name, session->name, L2TP_SESSION_NAME_MAX);
178 		__entry->pkt_ns = pkt_ns,
179 		__entry->my_nr = session->nr;
180 		__entry->reorder_q_len = skb_queue_len(&session->reorder_q);
181 	),
182 	TP_printk("%s: pkt_ns=%u my_nr=%u reorder_q_len=%u",
183 		__entry->name,
184 		__entry->pkt_ns,
185 		__entry->my_nr,
186 		__entry->reorder_q_len)
187 );
188 
189 DEFINE_EVENT(session_pkt_discard_evt, session_pkt_expired,
190 	TP_PROTO(struct l2tp_session *session, u32 pkt_ns),
191 	TP_ARGS(session, pkt_ns)
192 );
193 
194 DEFINE_EVENT(session_pkt_discard_evt, session_pkt_outside_rx_window,
195 	TP_PROTO(struct l2tp_session *session, u32 pkt_ns),
196 	TP_ARGS(session, pkt_ns)
197 );
198 
199 DEFINE_EVENT(session_pkt_discard_evt, session_pkt_oos,
200 	TP_PROTO(struct l2tp_session *session, u32 pkt_ns),
201 	TP_ARGS(session, pkt_ns)
202 );
203 
204 #endif /* _TRACE_L2TP_H */
205 
206 /* This part must be outside protection */
207 #undef TRACE_INCLUDE_PATH
208 #define TRACE_INCLUDE_PATH .
209 #undef TRACE_INCLUDE_FILE
210 #define TRACE_INCLUDE_FILE trace
211 #include <trace/define_trace.h>
212