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