09f178a3fcabb4082229a4f4985fc47295482d7f
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / diag / fs_tracepoint.h
1 /*
2  * Copyright (c) 2017, Mellanox Technologies. All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32
33 #if !defined(_MLX5_FS_TP_) || defined(TRACE_HEADER_MULTI_READ)
34 #define _MLX5_FS_TP_
35
36 #include <linux/tracepoint.h>
37 #include <linux/trace_seq.h>
38 #include "../fs_core.h"
39
40 #undef TRACE_SYSTEM
41 #define TRACE_SYSTEM mlx5
42
43 #define __parse_fs_hdrs(match_criteria_enable, mouter, mmisc, minner, vouter, \
44                         vinner, vmisc)                                        \
45         parse_fs_hdrs(p, match_criteria_enable, mouter, mmisc, minner, vouter,\
46                       vinner, vmisc)
47
48 const char *parse_fs_hdrs(struct trace_seq *p,
49                           u8 match_criteria_enable,
50                           const u32 *mask_outer,
51                           const u32 *mask_misc,
52                           const u32 *mask_inner,
53                           const u32 *value_outer,
54                           const u32 *value_misc,
55                           const u32 *value_inner);
56
57 #define __parse_fs_dst(dst, counter_id) \
58         parse_fs_dst(p, (const struct mlx5_flow_destination *)dst, counter_id)
59
60 const char *parse_fs_dst(struct trace_seq *p,
61                          const struct mlx5_flow_destination *dst,
62                          u32 counter_id);
63
64 TRACE_EVENT(mlx5_fs_add_fg,
65             TP_PROTO(const struct mlx5_flow_group *fg),
66             TP_ARGS(fg),
67             TP_STRUCT__entry(
68                 __field(const struct mlx5_flow_group *, fg)
69                 __field(const struct mlx5_flow_table *, ft)
70                 __field(u32, start_index)
71                 __field(u32, end_index)
72                 __field(u32, id)
73                 __field(u8, mask_enable)
74                 __array(u32, mask_outer, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4))
75                 __array(u32, mask_inner, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4))
76                 __array(u32, mask_misc, MLX5_ST_SZ_DW(fte_match_set_misc))
77             ),
78             TP_fast_assign(
79                            __entry->fg = fg;
80                            fs_get_obj(__entry->ft, fg->node.parent);
81                            __entry->start_index = fg->start_index;
82                            __entry->end_index = fg->start_index + fg->max_ftes;
83                            __entry->id = fg->id;
84                            __entry->mask_enable = fg->mask.match_criteria_enable;
85                            memcpy(__entry->mask_outer,
86                                   MLX5_ADDR_OF(fte_match_param,
87                                                &fg->mask.match_criteria,
88                                                outer_headers),
89                                   sizeof(__entry->mask_outer));
90                            memcpy(__entry->mask_inner,
91                                   MLX5_ADDR_OF(fte_match_param,
92                                                &fg->mask.match_criteria,
93                                                inner_headers),
94                                   sizeof(__entry->mask_inner));
95                            memcpy(__entry->mask_misc,
96                                   MLX5_ADDR_OF(fte_match_param,
97                                                &fg->mask.match_criteria,
98                                                misc_parameters),
99                                   sizeof(__entry->mask_misc));
100
101             ),
102             TP_printk("fg=%p ft=%p id=%u start=%u end=%u bit_mask=%02x %s\n",
103                       __entry->fg, __entry->ft, __entry->id,
104                       __entry->start_index, __entry->end_index,
105                       __entry->mask_enable,
106                       __parse_fs_hdrs(__entry->mask_enable,
107                                       __entry->mask_outer,
108                                       __entry->mask_misc,
109                                       __entry->mask_inner,
110                                       __entry->mask_outer,
111                                       __entry->mask_misc,
112                                       __entry->mask_inner))
113             );
114
115 TRACE_EVENT(mlx5_fs_del_fg,
116             TP_PROTO(const struct mlx5_flow_group *fg),
117             TP_ARGS(fg),
118             TP_STRUCT__entry(
119                 __field(const struct mlx5_flow_group *, fg)
120                 __field(u32, id)
121             ),
122             TP_fast_assign(
123                            __entry->fg = fg;
124                            __entry->id = fg->id;
125
126             ),
127             TP_printk("fg=%p id=%u\n",
128                       __entry->fg, __entry->id)
129             );
130
131 #define ACTION_FLAGS \
132         {MLX5_FLOW_CONTEXT_ACTION_ALLOW,         "ALLOW"},\
133         {MLX5_FLOW_CONTEXT_ACTION_DROP,          "DROP"},\
134         {MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,      "FWD"},\
135         {MLX5_FLOW_CONTEXT_ACTION_COUNT,         "CNT"},\
136         {MLX5_FLOW_CONTEXT_ACTION_ENCAP,         "ENCAP"},\
137         {MLX5_FLOW_CONTEXT_ACTION_DECAP,         "DECAP"},\
138         {MLX5_FLOW_CONTEXT_ACTION_MOD_HDR,       "MOD_HDR"},\
139         {MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH,     "VLAN_PUSH"},\
140         {MLX5_FLOW_CONTEXT_ACTION_VLAN_POP,      "VLAN_POP"},\
141         {MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO, "NEXT_PRIO"}
142
143 TRACE_EVENT(mlx5_fs_set_fte,
144             TP_PROTO(const struct fs_fte *fte, int new_fte),
145             TP_ARGS(fte, new_fte),
146             TP_STRUCT__entry(
147                 __field(const struct fs_fte *, fte)
148                 __field(const struct mlx5_flow_group *, fg)
149                 __field(u32, group_index)
150                 __field(u32, index)
151                 __field(u32, action)
152                 __field(u32, flow_tag)
153                 __field(u8,  mask_enable)
154                 __field(int, new_fte)
155                 __array(u32, mask_outer, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4))
156                 __array(u32, mask_inner, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4))
157                 __array(u32, mask_misc, MLX5_ST_SZ_DW(fte_match_set_misc))
158                 __array(u32, value_outer, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4))
159                 __array(u32, value_inner, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4))
160                 __array(u32, value_misc, MLX5_ST_SZ_DW(fte_match_set_misc))
161             ),
162             TP_fast_assign(
163                            __entry->fte = fte;
164                            __entry->new_fte = new_fte;
165                            fs_get_obj(__entry->fg, fte->node.parent);
166                            __entry->group_index = __entry->fg->id;
167                            __entry->index = fte->index;
168                            __entry->action = fte->action.action;
169                            __entry->mask_enable = __entry->fg->mask.match_criteria_enable;
170                            __entry->flow_tag = fte->action.flow_tag;
171                            memcpy(__entry->mask_outer,
172                                   MLX5_ADDR_OF(fte_match_param,
173                                                &__entry->fg->mask.match_criteria,
174                                                outer_headers),
175                                   sizeof(__entry->mask_outer));
176                            memcpy(__entry->mask_inner,
177                                   MLX5_ADDR_OF(fte_match_param,
178                                                &__entry->fg->mask.match_criteria,
179                                                inner_headers),
180                                   sizeof(__entry->mask_inner));
181                            memcpy(__entry->mask_misc,
182                                   MLX5_ADDR_OF(fte_match_param,
183                                                &__entry->fg->mask.match_criteria,
184                                                misc_parameters),
185                                   sizeof(__entry->mask_misc));
186                            memcpy(__entry->value_outer,
187                                   MLX5_ADDR_OF(fte_match_param,
188                                                &fte->val,
189                                                outer_headers),
190                                   sizeof(__entry->value_outer));
191                            memcpy(__entry->value_inner,
192                                   MLX5_ADDR_OF(fte_match_param,
193                                                &fte->val,
194                                                inner_headers),
195                                   sizeof(__entry->value_inner));
196                            memcpy(__entry->value_misc,
197                                   MLX5_ADDR_OF(fte_match_param,
198                                                &fte->val,
199                                                misc_parameters),
200                                   sizeof(__entry->value_misc));
201
202             ),
203             TP_printk("op=%s fte=%p fg=%p index=%u group_index=%u action=<%s> flow_tag=%x %s\n",
204                       __entry->new_fte ? "add" : "set",
205                       __entry->fte, __entry->fg, __entry->index,
206                       __entry->group_index, __print_flags(__entry->action, "|",
207                                                           ACTION_FLAGS),
208                       __entry->flow_tag,
209                       __parse_fs_hdrs(__entry->mask_enable,
210                                       __entry->mask_outer,
211                                       __entry->mask_misc,
212                                       __entry->mask_inner,
213                                       __entry->value_outer,
214                                       __entry->value_misc,
215                                       __entry->value_inner))
216             );
217
218 TRACE_EVENT(mlx5_fs_del_fte,
219             TP_PROTO(const struct fs_fte *fte),
220             TP_ARGS(fte),
221             TP_STRUCT__entry(
222                 __field(const struct fs_fte *, fte)
223                 __field(u32, index)
224             ),
225             TP_fast_assign(
226                            __entry->fte = fte;
227                            __entry->index = fte->index;
228
229             ),
230             TP_printk("fte=%p index=%u\n",
231                       __entry->fte, __entry->index)
232             );
233
234 TRACE_EVENT(mlx5_fs_add_rule,
235             TP_PROTO(const struct mlx5_flow_rule *rule),
236             TP_ARGS(rule),
237             TP_STRUCT__entry(
238                 __field(const struct mlx5_flow_rule *, rule)
239                 __field(const struct fs_fte *, fte)
240                 __field(u32, sw_action)
241                 __field(u32, index)
242                 __field(u32, counter_id)
243                 __array(u8, destination, sizeof(struct mlx5_flow_destination))
244             ),
245             TP_fast_assign(
246                            __entry->rule = rule;
247                            fs_get_obj(__entry->fte, rule->node.parent);
248                            __entry->index = __entry->fte->dests_size - 1;
249                            __entry->sw_action = rule->sw_action;
250                            memcpy(__entry->destination,
251                                   &rule->dest_attr,
252                                   sizeof(__entry->destination));
253                            if (rule->dest_attr.type & MLX5_FLOW_DESTINATION_TYPE_COUNTER &&
254                                rule->dest_attr.counter)
255                                 __entry->counter_id =
256                                 rule->dest_attr.counter->id;
257             ),
258             TP_printk("rule=%p fte=%p index=%u sw_action=<%s> [dst] %s\n",
259                       __entry->rule, __entry->fte, __entry->index,
260                       __print_flags(__entry->sw_action, "|", ACTION_FLAGS),
261                       __parse_fs_dst(__entry->destination, __entry->counter_id))
262             );
263
264 TRACE_EVENT(mlx5_fs_del_rule,
265             TP_PROTO(const struct mlx5_flow_rule *rule),
266             TP_ARGS(rule),
267             TP_STRUCT__entry(
268                 __field(const struct mlx5_flow_rule *, rule)
269                 __field(const struct fs_fte *, fte)
270             ),
271             TP_fast_assign(
272                            __entry->rule = rule;
273                            fs_get_obj(__entry->fte, rule->node.parent);
274             ),
275             TP_printk("rule=%p fte=%p\n",
276                       __entry->rule, __entry->fte)
277             );
278 #endif
279
280 #undef TRACE_INCLUDE_PATH
281 #define TRACE_INCLUDE_PATH ./diag
282 #undef TRACE_INCLUDE_FILE
283 #define TRACE_INCLUDE_FILE fs_tracepoint
284 #include <trace/define_trace.h>