1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
3 
4 #undef TRACE_SYSTEM
5 #define TRACE_SYSTEM mlx5
6 
7 #if !defined(_MLX5_SF_TP_) || defined(TRACE_HEADER_MULTI_READ)
8 #define _MLX5_SF_TP_
9 
10 #include <linux/tracepoint.h>
11 #include <linux/mlx5/driver.h>
12 #include "sf/vhca_event.h"
13 
14 TRACE_EVENT(mlx5_sf_add,
15 	    TP_PROTO(const struct mlx5_core_dev *dev,
16 		     unsigned int port_index,
17 		     u32 controller,
18 		     u16 hw_fn_id,
19 		     u32 sfnum),
20 	    TP_ARGS(dev, port_index, controller, hw_fn_id, sfnum),
21 	    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
22 			     __field(unsigned int, port_index)
23 			     __field(u32, controller)
24 			     __field(u16, hw_fn_id)
25 			     __field(u32, sfnum)
26 			    ),
27 	    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
28 		    __entry->port_index = port_index;
29 		    __entry->controller = controller;
30 		    __entry->hw_fn_id = hw_fn_id;
31 		    __entry->sfnum = sfnum;
32 	    ),
33 	    TP_printk("(%s) port_index=%u controller=%u hw_id=0x%x sfnum=%u\n",
34 		      __get_str(devname), __entry->port_index, __entry->controller,
35 		      __entry->hw_fn_id, __entry->sfnum)
36 );
37 
38 TRACE_EVENT(mlx5_sf_free,
39 	    TP_PROTO(const struct mlx5_core_dev *dev,
40 		     unsigned int port_index,
41 		     u32 controller,
42 		     u16 hw_fn_id),
43 	    TP_ARGS(dev, port_index, controller, hw_fn_id),
44 	    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
45 			     __field(unsigned int, port_index)
46 			     __field(u32, controller)
47 			     __field(u16, hw_fn_id)
48 			    ),
49 	    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
50 		    __entry->port_index = port_index;
51 		    __entry->controller = controller;
52 		    __entry->hw_fn_id = hw_fn_id;
53 	    ),
54 	    TP_printk("(%s) port_index=%u controller=%u hw_id=0x%x\n",
55 		      __get_str(devname), __entry->port_index, __entry->controller,
56 		      __entry->hw_fn_id)
57 );
58 
59 TRACE_EVENT(mlx5_sf_hwc_alloc,
60 	    TP_PROTO(const struct mlx5_core_dev *dev,
61 		     u32 controller,
62 		     u16 hw_fn_id,
63 		     u32 sfnum),
64 	    TP_ARGS(dev, controller, hw_fn_id, sfnum),
65 	    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
66 			     __field(u32, controller)
67 			     __field(u16, hw_fn_id)
68 			     __field(u32, sfnum)
69 			    ),
70 	    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
71 		    __entry->controller = controller;
72 		    __entry->hw_fn_id = hw_fn_id;
73 		    __entry->sfnum = sfnum;
74 	    ),
75 	    TP_printk("(%s) controller=%u hw_id=0x%x sfnum=%u\n",
76 		      __get_str(devname), __entry->controller, __entry->hw_fn_id,
77 		      __entry->sfnum)
78 );
79 
80 TRACE_EVENT(mlx5_sf_hwc_free,
81 	    TP_PROTO(const struct mlx5_core_dev *dev,
82 		     u16 hw_fn_id),
83 	    TP_ARGS(dev, hw_fn_id),
84 	    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
85 			     __field(u16, hw_fn_id)
86 			    ),
87 	    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
88 		    __entry->hw_fn_id = hw_fn_id;
89 	    ),
90 	    TP_printk("(%s) hw_id=0x%x\n", __get_str(devname), __entry->hw_fn_id)
91 );
92 
93 TRACE_EVENT(mlx5_sf_hwc_deferred_free,
94 	    TP_PROTO(const struct mlx5_core_dev *dev,
95 		     u16 hw_fn_id),
96 	    TP_ARGS(dev, hw_fn_id),
97 	    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
98 			     __field(u16, hw_fn_id)
99 			    ),
100 	    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
101 		    __entry->hw_fn_id = hw_fn_id;
102 	    ),
103 	    TP_printk("(%s) hw_id=0x%x\n", __get_str(devname), __entry->hw_fn_id)
104 );
105 
106 DECLARE_EVENT_CLASS(mlx5_sf_state_template,
107 		    TP_PROTO(const struct mlx5_core_dev *dev,
108 			     u32 port_index,
109 			     u32 controller,
110 			     u16 hw_fn_id),
111 		    TP_ARGS(dev, port_index, controller, hw_fn_id),
112 		    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
113 				     __field(unsigned int, port_index)
114 				     __field(u32, controller)
115 				     __field(u16, hw_fn_id)),
116 		    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
117 				   __entry->port_index = port_index;
118 				   __entry->controller = controller;
119 				   __entry->hw_fn_id = hw_fn_id;
120 		    ),
121 		    TP_printk("(%s) port_index=%u controller=%u hw_id=0x%x\n",
122 			      __get_str(devname), __entry->port_index, __entry->controller,
123 			      __entry->hw_fn_id)
124 );
125 
126 DEFINE_EVENT(mlx5_sf_state_template, mlx5_sf_activate,
127 	     TP_PROTO(const struct mlx5_core_dev *dev,
128 		      u32 port_index,
129 		      u32 controller,
130 		      u16 hw_fn_id),
131 	     TP_ARGS(dev, port_index, controller, hw_fn_id)
132 	     );
133 
134 DEFINE_EVENT(mlx5_sf_state_template, mlx5_sf_deactivate,
135 	     TP_PROTO(const struct mlx5_core_dev *dev,
136 		      u32 port_index,
137 		      u32 controller,
138 		      u16 hw_fn_id),
139 	     TP_ARGS(dev, port_index, controller, hw_fn_id)
140 	     );
141 
142 TRACE_EVENT(mlx5_sf_update_state,
143 	    TP_PROTO(const struct mlx5_core_dev *dev,
144 		     unsigned int port_index,
145 		     u32 controller,
146 		     u16 hw_fn_id,
147 		     u8 state),
148 	    TP_ARGS(dev, port_index, controller, hw_fn_id, state),
149 	    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
150 			     __field(unsigned int, port_index)
151 			     __field(u32, controller)
152 			     __field(u16, hw_fn_id)
153 			     __field(u8, state)
154 			    ),
155 	    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
156 		    __entry->port_index = port_index;
157 		    __entry->controller = controller;
158 		    __entry->hw_fn_id = hw_fn_id;
159 		    __entry->state = state;
160 	    ),
161 	    TP_printk("(%s) port_index=%u controller=%u hw_id=0x%x state=%u\n",
162 		      __get_str(devname), __entry->port_index, __entry->controller,
163 		      __entry->hw_fn_id, __entry->state)
164 );
165 
166 #endif /* _MLX5_SF_TP_ */
167 
168 /* This part must be outside protection */
169 #undef TRACE_INCLUDE_PATH
170 #define TRACE_INCLUDE_PATH sf/diag
171 #undef TRACE_INCLUDE_FILE
172 #define TRACE_INCLUDE_FILE sf_tracepoint
173 #include <trace/define_trace.h>
174