xref: /openbmc/linux/include/trace/events/mptcp.h (revision 5334d983)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM mptcp
4 
5 #if !defined(_TRACE_MPTCP_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_MPTCP_H
7 
8 #include <linux/tracepoint.h>
9 
10 #define show_mapping_status(status)					\
11 	__print_symbolic(status,					\
12 		{ 0, "MAPPING_OK" },					\
13 		{ 1, "MAPPING_INVALID" },				\
14 		{ 2, "MAPPING_EMPTY" },					\
15 		{ 3, "MAPPING_DATA_FIN" },				\
16 		{ 4, "MAPPING_DUMMY" })
17 
18 TRACE_EVENT(mptcp_subflow_get_send,
19 
20 	TP_PROTO(struct mptcp_subflow_context *subflow),
21 
22 	TP_ARGS(subflow),
23 
24 	TP_STRUCT__entry(
25 		__field(bool, active)
26 		__field(bool, free)
27 		__field(u32, snd_wnd)
28 		__field(u32, pace)
29 		__field(u8, backup)
30 		__field(u64, ratio)
31 	),
32 
33 	TP_fast_assign(
34 		struct sock *ssk;
35 
36 		__entry->active = mptcp_subflow_active(subflow);
37 		__entry->backup = subflow->backup;
38 
39 		if (subflow->tcp_sock && sk_fullsock(subflow->tcp_sock))
40 			__entry->free = sk_stream_memory_free(subflow->tcp_sock);
41 		else
42 			__entry->free = 0;
43 
44 		ssk = mptcp_subflow_tcp_sock(subflow);
45 		if (ssk && sk_fullsock(ssk)) {
46 			__entry->snd_wnd = tcp_sk(ssk)->snd_wnd;
47 			__entry->pace = ssk->sk_pacing_rate;
48 		} else {
49 			__entry->snd_wnd = 0;
50 			__entry->pace = 0;
51 		}
52 
53 		if (ssk && sk_fullsock(ssk) && __entry->pace)
54 			__entry->ratio = div_u64((u64)ssk->sk_wmem_queued << 32, __entry->pace);
55 		else
56 			__entry->ratio = 0;
57 	),
58 
59 	TP_printk("active=%d free=%d snd_wnd=%u pace=%u backup=%u ratio=%llu",
60 		  __entry->active, __entry->free,
61 		  __entry->snd_wnd, __entry->pace,
62 		  __entry->backup, __entry->ratio)
63 );
64 
65 DECLARE_EVENT_CLASS(mptcp_dump_mpext,
66 
67 	TP_PROTO(struct mptcp_ext *mpext),
68 
69 	TP_ARGS(mpext),
70 
71 	TP_STRUCT__entry(
72 		__field(u64, data_ack)
73 		__field(u64, data_seq)
74 		__field(u32, subflow_seq)
75 		__field(u16, data_len)
76 		__field(u8, use_map)
77 		__field(u8, dsn64)
78 		__field(u8, data_fin)
79 		__field(u8, use_ack)
80 		__field(u8, ack64)
81 		__field(u8, mpc_map)
82 		__field(u8, frozen)
83 		__field(u8, reset_transient)
84 		__field(u8, reset_reason)
85 	),
86 
87 	TP_fast_assign(
88 		__entry->data_ack = mpext->ack64 ? mpext->data_ack : mpext->data_ack32;
89 		__entry->data_seq = mpext->data_seq;
90 		__entry->subflow_seq = mpext->subflow_seq;
91 		__entry->data_len = mpext->data_len;
92 		__entry->use_map = mpext->use_map;
93 		__entry->dsn64 = mpext->dsn64;
94 		__entry->data_fin = mpext->data_fin;
95 		__entry->use_ack = mpext->use_ack;
96 		__entry->ack64 = mpext->ack64;
97 		__entry->mpc_map = mpext->mpc_map;
98 		__entry->frozen = mpext->frozen;
99 		__entry->reset_transient = mpext->reset_transient;
100 		__entry->reset_reason = mpext->reset_reason;
101 	),
102 
103 	TP_printk("data_ack=%llu data_seq=%llu subflow_seq=%u data_len=%u use_map=%u dsn64=%u data_fin=%u use_ack=%u ack64=%u mpc_map=%u frozen=%u reset_transient=%u reset_reason=%u",
104 		  __entry->data_ack, __entry->data_seq,
105 		  __entry->subflow_seq, __entry->data_len,
106 		  __entry->use_map, __entry->dsn64,
107 		  __entry->data_fin, __entry->use_ack,
108 		  __entry->ack64, __entry->mpc_map,
109 		  __entry->frozen, __entry->reset_transient,
110 		  __entry->reset_reason)
111 );
112 
113 DEFINE_EVENT(mptcp_dump_mpext, get_mapping_status,
114 	TP_PROTO(struct mptcp_ext *mpext),
115 	TP_ARGS(mpext));
116 
117 TRACE_EVENT(ack_update_msk,
118 
119 	TP_PROTO(u64 data_ack, u64 old_snd_una,
120 		 u64 new_snd_una, u64 new_wnd_end,
121 		 u64 msk_wnd_end),
122 
123 	TP_ARGS(data_ack, old_snd_una,
124 		new_snd_una, new_wnd_end,
125 		msk_wnd_end),
126 
127 	TP_STRUCT__entry(
128 		__field(u64, data_ack)
129 		__field(u64, old_snd_una)
130 		__field(u64, new_snd_una)
131 		__field(u64, new_wnd_end)
132 		__field(u64, msk_wnd_end)
133 	),
134 
135 	TP_fast_assign(
136 		__entry->data_ack = data_ack;
137 		__entry->old_snd_una = old_snd_una;
138 		__entry->new_snd_una = new_snd_una;
139 		__entry->new_wnd_end = new_wnd_end;
140 		__entry->msk_wnd_end = msk_wnd_end;
141 	),
142 
143 	TP_printk("data_ack=%llu old_snd_una=%llu new_snd_una=%llu new_wnd_end=%llu msk_wnd_end=%llu",
144 		  __entry->data_ack, __entry->old_snd_una,
145 		  __entry->new_snd_una, __entry->new_wnd_end,
146 		  __entry->msk_wnd_end)
147 );
148 
149 TRACE_EVENT(subflow_check_data_avail,
150 
151 	TP_PROTO(__u8 status, struct sk_buff *skb),
152 
153 	TP_ARGS(status, skb),
154 
155 	TP_STRUCT__entry(
156 		__field(u8, status)
157 		__field(const void *, skb)
158 	),
159 
160 	TP_fast_assign(
161 		__entry->status = status;
162 		__entry->skb = skb;
163 	),
164 
165 	TP_printk("mapping_status=%s, skb=%p",
166 		  show_mapping_status(__entry->status),
167 		  __entry->skb)
168 );
169 
170 #endif /* _TRACE_MPTCP_H */
171 
172 /* This part must be outside protection */
173 #include <trace/define_trace.h>
174