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_ft, 65 TP_PROTO(const struct mlx5_flow_table *ft), 66 TP_ARGS(ft), 67 TP_STRUCT__entry( 68 __field(const struct mlx5_flow_table *, ft) 69 __field(u32, id) 70 __field(u32, level) 71 __field(u32, type) 72 ), 73 TP_fast_assign( 74 __entry->ft = ft; 75 __entry->id = ft->id; 76 __entry->level = ft->level; 77 __entry->type = ft->type; 78 ), 79 TP_printk("ft=%p id=%u level=%u type=%u \n", 80 __entry->ft, __entry->id, __entry->level, __entry->type) 81 ); 82 83 TRACE_EVENT(mlx5_fs_del_ft, 84 TP_PROTO(const struct mlx5_flow_table *ft), 85 TP_ARGS(ft), 86 TP_STRUCT__entry( 87 __field(const struct mlx5_flow_table *, ft) 88 __field(u32, id) 89 ), 90 TP_fast_assign( 91 __entry->ft = ft; 92 __entry->id = ft->id; 93 94 ), 95 TP_printk("ft=%p id=%u\n", 96 __entry->ft, __entry->id) 97 ); 98 99 TRACE_EVENT(mlx5_fs_add_fg, 100 TP_PROTO(const struct mlx5_flow_group *fg), 101 TP_ARGS(fg), 102 TP_STRUCT__entry( 103 __field(const struct mlx5_flow_group *, fg) 104 __field(const struct mlx5_flow_table *, ft) 105 __field(u32, start_index) 106 __field(u32, end_index) 107 __field(u32, id) 108 __field(u8, mask_enable) 109 __array(u32, mask_outer, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4)) 110 __array(u32, mask_inner, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4)) 111 __array(u32, mask_misc, MLX5_ST_SZ_DW(fte_match_set_misc)) 112 ), 113 TP_fast_assign( 114 __entry->fg = fg; 115 fs_get_obj(__entry->ft, fg->node.parent); 116 __entry->start_index = fg->start_index; 117 __entry->end_index = fg->start_index + fg->max_ftes; 118 __entry->id = fg->id; 119 __entry->mask_enable = fg->mask.match_criteria_enable; 120 memcpy(__entry->mask_outer, 121 MLX5_ADDR_OF(fte_match_param, 122 &fg->mask.match_criteria, 123 outer_headers), 124 sizeof(__entry->mask_outer)); 125 memcpy(__entry->mask_inner, 126 MLX5_ADDR_OF(fte_match_param, 127 &fg->mask.match_criteria, 128 inner_headers), 129 sizeof(__entry->mask_inner)); 130 memcpy(__entry->mask_misc, 131 MLX5_ADDR_OF(fte_match_param, 132 &fg->mask.match_criteria, 133 misc_parameters), 134 sizeof(__entry->mask_misc)); 135 136 ), 137 TP_printk("fg=%p ft=%p id=%u start=%u end=%u bit_mask=%02x %s\n", 138 __entry->fg, __entry->ft, __entry->id, 139 __entry->start_index, __entry->end_index, 140 __entry->mask_enable, 141 __parse_fs_hdrs(__entry->mask_enable, 142 __entry->mask_outer, 143 __entry->mask_misc, 144 __entry->mask_inner, 145 __entry->mask_outer, 146 __entry->mask_misc, 147 __entry->mask_inner)) 148 ); 149 150 TRACE_EVENT(mlx5_fs_del_fg, 151 TP_PROTO(const struct mlx5_flow_group *fg), 152 TP_ARGS(fg), 153 TP_STRUCT__entry( 154 __field(const struct mlx5_flow_group *, fg) 155 __field(u32, id) 156 ), 157 TP_fast_assign( 158 __entry->fg = fg; 159 __entry->id = fg->id; 160 161 ), 162 TP_printk("fg=%p id=%u\n", 163 __entry->fg, __entry->id) 164 ); 165 166 #define ACTION_FLAGS \ 167 {MLX5_FLOW_CONTEXT_ACTION_ALLOW, "ALLOW"},\ 168 {MLX5_FLOW_CONTEXT_ACTION_DROP, "DROP"},\ 169 {MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, "FWD"},\ 170 {MLX5_FLOW_CONTEXT_ACTION_COUNT, "CNT"},\ 171 {MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT, "REFORMAT"},\ 172 {MLX5_FLOW_CONTEXT_ACTION_DECAP, "DECAP"},\ 173 {MLX5_FLOW_CONTEXT_ACTION_MOD_HDR, "MOD_HDR"},\ 174 {MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH, "VLAN_PUSH"},\ 175 {MLX5_FLOW_CONTEXT_ACTION_VLAN_POP, "VLAN_POP"},\ 176 {MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH_2, "VLAN_PUSH_2"},\ 177 {MLX5_FLOW_CONTEXT_ACTION_VLAN_POP_2, "VLAN_POP_2"},\ 178 {MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO, "NEXT_PRIO"} 179 180 TRACE_EVENT(mlx5_fs_set_fte, 181 TP_PROTO(const struct fs_fte *fte, int new_fte), 182 TP_ARGS(fte, new_fte), 183 TP_STRUCT__entry( 184 __field(const struct fs_fte *, fte) 185 __field(const struct mlx5_flow_group *, fg) 186 __field(u32, group_index) 187 __field(u32, index) 188 __field(u32, action) 189 __field(u32, flow_tag) 190 __field(u8, mask_enable) 191 __field(int, new_fte) 192 __array(u32, mask_outer, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4)) 193 __array(u32, mask_inner, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4)) 194 __array(u32, mask_misc, MLX5_ST_SZ_DW(fte_match_set_misc)) 195 __array(u32, value_outer, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4)) 196 __array(u32, value_inner, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4)) 197 __array(u32, value_misc, MLX5_ST_SZ_DW(fte_match_set_misc)) 198 ), 199 TP_fast_assign( 200 __entry->fte = fte; 201 __entry->new_fte = new_fte; 202 fs_get_obj(__entry->fg, fte->node.parent); 203 __entry->group_index = __entry->fg->id; 204 __entry->index = fte->index; 205 __entry->action = fte->action.action; 206 __entry->mask_enable = __entry->fg->mask.match_criteria_enable; 207 __entry->flow_tag = fte->action.flow_tag; 208 memcpy(__entry->mask_outer, 209 MLX5_ADDR_OF(fte_match_param, 210 &__entry->fg->mask.match_criteria, 211 outer_headers), 212 sizeof(__entry->mask_outer)); 213 memcpy(__entry->mask_inner, 214 MLX5_ADDR_OF(fte_match_param, 215 &__entry->fg->mask.match_criteria, 216 inner_headers), 217 sizeof(__entry->mask_inner)); 218 memcpy(__entry->mask_misc, 219 MLX5_ADDR_OF(fte_match_param, 220 &__entry->fg->mask.match_criteria, 221 misc_parameters), 222 sizeof(__entry->mask_misc)); 223 memcpy(__entry->value_outer, 224 MLX5_ADDR_OF(fte_match_param, 225 &fte->val, 226 outer_headers), 227 sizeof(__entry->value_outer)); 228 memcpy(__entry->value_inner, 229 MLX5_ADDR_OF(fte_match_param, 230 &fte->val, 231 inner_headers), 232 sizeof(__entry->value_inner)); 233 memcpy(__entry->value_misc, 234 MLX5_ADDR_OF(fte_match_param, 235 &fte->val, 236 misc_parameters), 237 sizeof(__entry->value_misc)); 238 239 ), 240 TP_printk("op=%s fte=%p fg=%p index=%u group_index=%u action=<%s> flow_tag=%x %s\n", 241 __entry->new_fte ? "add" : "set", 242 __entry->fte, __entry->fg, __entry->index, 243 __entry->group_index, __print_flags(__entry->action, "|", 244 ACTION_FLAGS), 245 __entry->flow_tag, 246 __parse_fs_hdrs(__entry->mask_enable, 247 __entry->mask_outer, 248 __entry->mask_misc, 249 __entry->mask_inner, 250 __entry->value_outer, 251 __entry->value_misc, 252 __entry->value_inner)) 253 ); 254 255 TRACE_EVENT(mlx5_fs_del_fte, 256 TP_PROTO(const struct fs_fte *fte), 257 TP_ARGS(fte), 258 TP_STRUCT__entry( 259 __field(const struct fs_fte *, fte) 260 __field(u32, index) 261 ), 262 TP_fast_assign( 263 __entry->fte = fte; 264 __entry->index = fte->index; 265 266 ), 267 TP_printk("fte=%p index=%u\n", 268 __entry->fte, __entry->index) 269 ); 270 271 TRACE_EVENT(mlx5_fs_add_rule, 272 TP_PROTO(const struct mlx5_flow_rule *rule), 273 TP_ARGS(rule), 274 TP_STRUCT__entry( 275 __field(const struct mlx5_flow_rule *, rule) 276 __field(const struct fs_fte *, fte) 277 __field(u32, sw_action) 278 __field(u32, index) 279 __field(u32, counter_id) 280 __array(u8, destination, sizeof(struct mlx5_flow_destination)) 281 ), 282 TP_fast_assign( 283 __entry->rule = rule; 284 fs_get_obj(__entry->fte, rule->node.parent); 285 __entry->index = __entry->fte->dests_size - 1; 286 __entry->sw_action = rule->sw_action; 287 memcpy(__entry->destination, 288 &rule->dest_attr, 289 sizeof(__entry->destination)); 290 if (rule->dest_attr.type & 291 MLX5_FLOW_DESTINATION_TYPE_COUNTER) 292 __entry->counter_id = 293 rule->dest_attr.counter_id; 294 ), 295 TP_printk("rule=%p fte=%p index=%u sw_action=<%s> [dst] %s\n", 296 __entry->rule, __entry->fte, __entry->index, 297 __print_flags(__entry->sw_action, "|", ACTION_FLAGS), 298 __parse_fs_dst(__entry->destination, __entry->counter_id)) 299 ); 300 301 TRACE_EVENT(mlx5_fs_del_rule, 302 TP_PROTO(const struct mlx5_flow_rule *rule), 303 TP_ARGS(rule), 304 TP_STRUCT__entry( 305 __field(const struct mlx5_flow_rule *, rule) 306 __field(const struct fs_fte *, fte) 307 ), 308 TP_fast_assign( 309 __entry->rule = rule; 310 fs_get_obj(__entry->fte, rule->node.parent); 311 ), 312 TP_printk("rule=%p fte=%p\n", 313 __entry->rule, __entry->fte) 314 ); 315 #endif 316 317 #undef TRACE_INCLUDE_PATH 318 #define TRACE_INCLUDE_PATH ./diag 319 #undef TRACE_INCLUDE_FILE 320 #define TRACE_INCLUDE_FILE fs_tracepoint 321 #include <trace/define_trace.h> 322