1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2018-2020 Hisilicon Limited. */
3 
4 /* This must be outside ifdef _HCLGE_TRACE_H */
5 #undef TRACE_SYSTEM
6 #define TRACE_SYSTEM hns3
7 
8 #if !defined(_HCLGE_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
9 #define _HCLGE_TRACE_H_
10 
11 #include <linux/tracepoint.h>
12 
13 #define PF_GET_MBX_LEN	(sizeof(struct hclge_mbx_vf_to_pf_cmd) / sizeof(u32))
14 #define PF_SEND_MBX_LEN	(sizeof(struct hclge_mbx_pf_to_vf_cmd) / sizeof(u32))
15 
16 TRACE_EVENT(hclge_pf_mbx_get,
17 	TP_PROTO(
18 		struct hclge_dev *hdev,
19 		struct hclge_mbx_vf_to_pf_cmd *req),
20 	TP_ARGS(hdev, req),
21 
22 	TP_STRUCT__entry(
23 		__field(u8, vfid)
24 		__field(u8, code)
25 		__field(u8, subcode)
26 		__string(pciname, pci_name(hdev->pdev))
27 		__string(devname, &hdev->vport[0].nic.kinfo.netdev->name)
28 		__array(u32, mbx_data, PF_GET_MBX_LEN)
29 	),
30 
31 	TP_fast_assign(
32 		__entry->vfid = req->mbx_src_vfid;
33 		__entry->code = req->msg.code;
34 		__entry->subcode = req->msg.subcode;
35 		__assign_str(pciname, pci_name(hdev->pdev));
36 		__assign_str(devname, &hdev->vport[0].nic.kinfo.netdev->name);
37 		memcpy(__entry->mbx_data, req,
38 		       sizeof(struct hclge_mbx_vf_to_pf_cmd));
39 	),
40 
41 	TP_printk(
42 		"%s %s vfid:%u code:%u subcode:%u data:%s",
43 		__get_str(pciname), __get_str(devname), __entry->vfid,
44 		__entry->code, __entry->subcode,
45 		__print_array(__entry->mbx_data, PF_GET_MBX_LEN, sizeof(u32))
46 	)
47 );
48 
49 TRACE_EVENT(hclge_pf_mbx_send,
50 	TP_PROTO(
51 		struct hclge_dev *hdev,
52 		struct hclge_mbx_pf_to_vf_cmd *req),
53 	TP_ARGS(hdev, req),
54 
55 	TP_STRUCT__entry(
56 		__field(u8, vfid)
57 		__field(u16, code)
58 		__string(pciname, pci_name(hdev->pdev))
59 		__string(devname, &hdev->vport[0].nic.kinfo.netdev->name)
60 		__array(u32, mbx_data, PF_SEND_MBX_LEN)
61 	),
62 
63 	TP_fast_assign(
64 		__entry->vfid = req->dest_vfid;
65 		__entry->code = req->msg.code;
66 		__assign_str(pciname, pci_name(hdev->pdev));
67 		__assign_str(devname, &hdev->vport[0].nic.kinfo.netdev->name);
68 		memcpy(__entry->mbx_data, req,
69 		       sizeof(struct hclge_mbx_pf_to_vf_cmd));
70 	),
71 
72 	TP_printk(
73 		"%s %s vfid:%u code:%u data:%s",
74 		__get_str(pciname), __get_str(devname), __entry->vfid,
75 		__entry->code,
76 		__print_array(__entry->mbx_data, PF_SEND_MBX_LEN, sizeof(u32))
77 	)
78 );
79 
80 #endif /* _HCLGE_TRACE_H_ */
81 
82 /* This must be outside ifdef _HCLGE_TRACE_H */
83 #undef TRACE_INCLUDE_PATH
84 #define TRACE_INCLUDE_PATH .
85 #undef TRACE_INCLUDE_FILE
86 #define TRACE_INCLUDE_FILE hclge_trace
87 #include <trace/define_trace.h>
88