1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2018-2020 Hisilicon Limited. */
4 /* This must be outside ifdef _HCLGE_TRACE_H */
6 #define TRACE_SYSTEM hns3
8 #if !defined(_HCLGE_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
9 #define _HCLGE_TRACE_H_
11 #include <linux/tracepoint.h>
13 #define PF_DESC_LEN (sizeof(struct hclge_desc) / sizeof(u32))
14 #define PF_GET_MBX_LEN (sizeof(struct hclge_mbx_vf_to_pf_cmd) / sizeof(u32))
15 #define PF_SEND_MBX_LEN (sizeof(struct hclge_mbx_pf_to_vf_cmd) / sizeof(u32))
17 TRACE_EVENT(hclge_pf_mbx_get
,
19 struct hclge_dev
*hdev
,
20 struct hclge_mbx_vf_to_pf_cmd
*req
),
27 __string(pciname
, pci_name(hdev
->pdev
))
28 __string(devname
, hdev
->vport
[0].nic
.kinfo
.netdev
->name
)
29 __array(u32
, mbx_data
, PF_GET_MBX_LEN
)
33 __entry
->vfid
= req
->mbx_src_vfid
;
34 __entry
->code
= req
->msg
.code
;
35 __entry
->subcode
= req
->msg
.subcode
;
36 __assign_str(pciname
);
37 __assign_str(devname
);
38 memcpy(__entry
->mbx_data
, req
,
39 sizeof(struct hclge_mbx_vf_to_pf_cmd
));
43 "%s %s vfid:%u code:%u subcode:%u data:%s",
44 __get_str(pciname
), __get_str(devname
), __entry
->vfid
,
45 __entry
->code
, __entry
->subcode
,
46 __print_array(__entry
->mbx_data
, PF_GET_MBX_LEN
, sizeof(u32
))
50 TRACE_EVENT(hclge_pf_mbx_send
,
52 struct hclge_dev
*hdev
,
53 struct hclge_mbx_pf_to_vf_cmd
*req
),
59 __string(pciname
, pci_name(hdev
->pdev
))
60 __string(devname
, hdev
->vport
[0].nic
.kinfo
.netdev
->name
)
61 __array(u32
, mbx_data
, PF_SEND_MBX_LEN
)
65 __entry
->vfid
= req
->dest_vfid
;
66 __entry
->code
= le16_to_cpu(req
->msg
.code
);
67 __assign_str(pciname
);
68 __assign_str(devname
);
69 memcpy(__entry
->mbx_data
, req
,
70 sizeof(struct hclge_mbx_pf_to_vf_cmd
));
74 "%s %s vfid:%u code:%u data:%s",
75 __get_str(pciname
), __get_str(devname
), __entry
->vfid
,
77 __print_array(__entry
->mbx_data
, PF_SEND_MBX_LEN
, sizeof(u32
))
81 DECLARE_EVENT_CLASS(hclge_pf_cmd_template
,
82 TP_PROTO(struct hclge_comm_hw
*hw
,
83 struct hclge_desc
*desc
,
86 TP_ARGS(hw
, desc
, index
, num
),
88 TP_STRUCT__entry(__field(u16
, opcode
)
94 __string(pciname
, pci_name(hw
->cmq
.csq
.pdev
))
95 __array(u32
, data
, HCLGE_DESC_DATA_LEN
)),
98 __entry
->opcode
= le16_to_cpu(desc
->opcode
);
99 __entry
->flag
= le16_to_cpu(desc
->flag
);
100 __entry
->retval
= le16_to_cpu(desc
->retval
);
101 __entry
->rsv
= le16_to_cpu(desc
->rsv
);
102 __entry
->index
= index
;
104 __assign_str(pciname
);
105 for (i
= 0; i
< HCLGE_DESC_DATA_LEN
; i
++)
106 __entry
->data
[i
] = le32_to_cpu(desc
->data
[i
]);),
108 TP_printk("%s opcode:0x%04x %d-%d flag:0x%04x retval:0x%04x rsv:0x%04x data:%s",
109 __get_str(pciname
), __entry
->opcode
,
110 __entry
->index
, __entry
->num
,
111 __entry
->flag
, __entry
->retval
, __entry
->rsv
,
112 __print_array(__entry
->data
,
113 HCLGE_DESC_DATA_LEN
, sizeof(u32
)))
116 DEFINE_EVENT(hclge_pf_cmd_template
, hclge_pf_cmd_send
,
117 TP_PROTO(struct hclge_comm_hw
*hw
,
118 struct hclge_desc
*desc
,
121 TP_ARGS(hw
, desc
, index
, num
)
124 DEFINE_EVENT(hclge_pf_cmd_template
, hclge_pf_cmd_get
,
125 TP_PROTO(struct hclge_comm_hw
*hw
,
126 struct hclge_desc
*desc
,
129 TP_ARGS(hw
, desc
, index
, num
)
132 DECLARE_EVENT_CLASS(hclge_pf_special_cmd_template
,
133 TP_PROTO(struct hclge_comm_hw
*hw
,
137 TP_ARGS(hw
, data
, index
, num
),
139 TP_STRUCT__entry(__field(int, index
)
141 __string(pciname
, pci_name(hw
->cmq
.csq
.pdev
))
142 __array(u32
, data
, PF_DESC_LEN
)),
144 TP_fast_assign(int i
;
145 __entry
->index
= index
;
147 __assign_str(pciname
);
148 for (i
= 0; i
< PF_DESC_LEN
; i
++)
149 __entry
->data
[i
] = le32_to_cpu(data
[i
]);
152 TP_printk("%s %d-%d data:%s",
154 __entry
->index
, __entry
->num
,
155 __print_array(__entry
->data
,
156 PF_DESC_LEN
, sizeof(u32
)))
159 DEFINE_EVENT(hclge_pf_special_cmd_template
, hclge_pf_special_cmd_send
,
160 TP_PROTO(struct hclge_comm_hw
*hw
,
164 TP_ARGS(hw
, desc
, index
, num
));
166 DEFINE_EVENT(hclge_pf_special_cmd_template
, hclge_pf_special_cmd_get
,
167 TP_PROTO(struct hclge_comm_hw
*hw
,
171 TP_ARGS(hw
, desc
, index
, num
)
174 #endif /* _HCLGE_TRACE_H_ */
176 /* This must be outside ifdef _HCLGE_TRACE_H */
177 #undef TRACE_INCLUDE_PATH
178 #define TRACE_INCLUDE_PATH .
179 #undef TRACE_INCLUDE_FILE
180 #define TRACE_INCLUDE_FILE hclge_trace
181 #include <trace/define_trace.h>