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_ESW_TP_) || defined(TRACE_HEADER_MULTI_READ)
8 #define _MLX5_ESW_TP_
9 
10 #include <linux/tracepoint.h>
11 #include "eswitch.h"
12 
13 TRACE_EVENT(mlx5_esw_vport_qos_destroy,
14 	    TP_PROTO(const struct mlx5_vport *vport),
15 	    TP_ARGS(vport),
16 	    TP_STRUCT__entry(__string(devname, dev_name(vport->dev->device))
17 			     __field(unsigned short, vport_id)
18 			     __field(unsigned int,   tsar_ix)
19 			     ),
20 	    TP_fast_assign(__assign_str(devname, dev_name(vport->dev->device));
21 		    __entry->vport_id = vport->vport;
22 		    __entry->tsar_ix = vport->qos.esw_tsar_ix;
23 	    ),
24 	    TP_printk("(%s) vport=%hu tsar_ix=%u\n",
25 		      __get_str(devname), __entry->vport_id, __entry->tsar_ix
26 		      )
27 );
28 
29 DECLARE_EVENT_CLASS(mlx5_esw_vport_qos_template,
30 		    TP_PROTO(const struct mlx5_vport *vport, u32 bw_share, u32 max_rate),
31 		    TP_ARGS(vport, bw_share, max_rate),
32 		    TP_STRUCT__entry(__string(devname, dev_name(vport->dev->device))
33 				     __field(unsigned short, vport_id)
34 				     __field(unsigned int, tsar_ix)
35 				     __field(unsigned int, bw_share)
36 				     __field(unsigned int, max_rate)
37 				     __field(void *, group)
38 				     ),
39 		    TP_fast_assign(__assign_str(devname, dev_name(vport->dev->device));
40 			    __entry->vport_id = vport->vport;
41 			    __entry->tsar_ix = vport->qos.esw_tsar_ix;
42 			    __entry->bw_share = bw_share;
43 			    __entry->max_rate = max_rate;
44 			    __entry->group = vport->qos.group;
45 		    ),
46 		    TP_printk("(%s) vport=%hu tsar_ix=%u bw_share=%u, max_rate=%u group=%p\n",
47 			      __get_str(devname), __entry->vport_id, __entry->tsar_ix,
48 			      __entry->bw_share, __entry->max_rate, __entry->group
49 			      )
50 );
51 
52 DEFINE_EVENT(mlx5_esw_vport_qos_template, mlx5_esw_vport_qos_create,
53 	     TP_PROTO(const struct mlx5_vport *vport, u32 bw_share, u32 max_rate),
54 	     TP_ARGS(vport, bw_share, max_rate)
55 	     );
56 
57 DEFINE_EVENT(mlx5_esw_vport_qos_template, mlx5_esw_vport_qos_config,
58 	     TP_PROTO(const struct mlx5_vport *vport, u32 bw_share, u32 max_rate),
59 	     TP_ARGS(vport, bw_share, max_rate)
60 	     );
61 
62 DECLARE_EVENT_CLASS(mlx5_esw_group_qos_template,
63 		    TP_PROTO(const struct mlx5_core_dev *dev,
64 			     const struct mlx5_esw_rate_group *group,
65 			     unsigned int tsar_ix),
66 		    TP_ARGS(dev, group, tsar_ix),
67 		    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
68 				     __field(const void *, group)
69 				     __field(unsigned int, tsar_ix)
70 				     ),
71 		    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
72 			    __entry->group = group;
73 			    __entry->tsar_ix = tsar_ix;
74 		    ),
75 		    TP_printk("(%s) group=%p tsar_ix=%u\n",
76 			      __get_str(devname), __entry->group, __entry->tsar_ix
77 			      )
78 );
79 
80 DEFINE_EVENT(mlx5_esw_group_qos_template, mlx5_esw_group_qos_create,
81 	     TP_PROTO(const struct mlx5_core_dev *dev,
82 		      const struct mlx5_esw_rate_group *group,
83 		      unsigned int tsar_ix),
84 	     TP_ARGS(dev, group, tsar_ix)
85 	     );
86 
87 DEFINE_EVENT(mlx5_esw_group_qos_template, mlx5_esw_group_qos_destroy,
88 	     TP_PROTO(const struct mlx5_core_dev *dev,
89 		      const struct mlx5_esw_rate_group *group,
90 		      unsigned int tsar_ix),
91 	     TP_ARGS(dev, group, tsar_ix)
92 	     );
93 
94 TRACE_EVENT(mlx5_esw_group_qos_config,
95 	    TP_PROTO(const struct mlx5_core_dev *dev,
96 		     const struct mlx5_esw_rate_group *group,
97 		     unsigned int tsar_ix, u32 bw_share, u32 max_rate),
98 	    TP_ARGS(dev, group, tsar_ix, bw_share, max_rate),
99 	    TP_STRUCT__entry(__string(devname, dev_name(dev->device))
100 			     __field(const void *, group)
101 			     __field(unsigned int, tsar_ix)
102 			     __field(unsigned int, bw_share)
103 			     __field(unsigned int, max_rate)
104 			     ),
105 	    TP_fast_assign(__assign_str(devname, dev_name(dev->device));
106 		    __entry->group = group;
107 		    __entry->tsar_ix = tsar_ix;
108 		    __entry->bw_share = bw_share;
109 		    __entry->max_rate = max_rate;
110 	    ),
111 	    TP_printk("(%s) group=%p tsar_ix=%u bw_share=%u max_rate=%u\n",
112 		      __get_str(devname), __entry->group, __entry->tsar_ix,
113 		      __entry->bw_share, __entry->max_rate
114 		      )
115 );
116 #endif /* _MLX5_ESW_TP_ */
117 
118 /* This part must be outside protection */
119 #undef TRACE_INCLUDE_PATH
120 #define TRACE_INCLUDE_PATH esw/diag
121 #undef TRACE_INCLUDE_FILE
122 #define TRACE_INCLUDE_FILE qos_tracepoint
123 #include <trace/define_trace.h>
124