18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright(c) 2013 - 2018 Intel Corporation. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci/* Modeled on trace-events-sample.h */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci/* The trace subsystem name for iavf will be "iavf".
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This file is named iavf_trace.h.
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * Since this include file's name is different from the trace
118c2ecf20Sopenharmony_ci * subsystem name, we'll have to define TRACE_INCLUDE_FILE at the end
128c2ecf20Sopenharmony_ci * of this file.
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci#undef TRACE_SYSTEM
158c2ecf20Sopenharmony_ci#define TRACE_SYSTEM iavf
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* See trace-events-sample.h for a detailed description of why this
188c2ecf20Sopenharmony_ci * guard clause is different from most normal include files.
198c2ecf20Sopenharmony_ci */
208c2ecf20Sopenharmony_ci#if !defined(_IAVF_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
218c2ecf20Sopenharmony_ci#define _IAVF_TRACE_H_
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <linux/tracepoint.h>
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/*
268c2ecf20Sopenharmony_ci * iavf_trace() macro enables shared code to refer to trace points
278c2ecf20Sopenharmony_ci * like:
288c2ecf20Sopenharmony_ci *
298c2ecf20Sopenharmony_ci * trace_iavf{,vf}_example(args...)
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci * ... as:
328c2ecf20Sopenharmony_ci *
338c2ecf20Sopenharmony_ci * iavf_trace(example, args...)
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci * ... to resolve to the PF or VF version of the tracepoint without
368c2ecf20Sopenharmony_ci * ifdefs, and to allow tracepoints to be disabled entirely at build
378c2ecf20Sopenharmony_ci * time.
388c2ecf20Sopenharmony_ci *
398c2ecf20Sopenharmony_ci * Trace point should always be referred to in the driver via this
408c2ecf20Sopenharmony_ci * macro.
418c2ecf20Sopenharmony_ci *
428c2ecf20Sopenharmony_ci * Similarly, iavf_trace_enabled(trace_name) wraps references to
438c2ecf20Sopenharmony_ci * trace_iavf{,vf}_<trace_name>_enabled() functions.
448c2ecf20Sopenharmony_ci */
458c2ecf20Sopenharmony_ci#define _IAVF_TRACE_NAME(trace_name) (trace_ ## iavf ## _ ## trace_name)
468c2ecf20Sopenharmony_ci#define IAVF_TRACE_NAME(trace_name) _IAVF_TRACE_NAME(trace_name)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define iavf_trace(trace_name, args...) IAVF_TRACE_NAME(trace_name)(args)
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define iavf_trace_enabled(trace_name) IAVF_TRACE_NAME(trace_name##_enabled)()
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* Events common to PF and VF. Corresponding versions will be defined
538c2ecf20Sopenharmony_ci * for both, named trace_iavf_* and trace_iavf_*. The iavf_trace()
548c2ecf20Sopenharmony_ci * macro above will select the right trace point name for the driver
558c2ecf20Sopenharmony_ci * being built from shared code.
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/* Events related to a vsi & ring */
598c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(
608c2ecf20Sopenharmony_ci	iavf_tx_template,
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	TP_PROTO(struct iavf_ring *ring,
638c2ecf20Sopenharmony_ci		 struct iavf_tx_desc *desc,
648c2ecf20Sopenharmony_ci		 struct iavf_tx_buffer *buf),
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	TP_ARGS(ring, desc, buf),
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	/* The convention here is to make the first fields in the
698c2ecf20Sopenharmony_ci	 * TP_STRUCT match the TP_PROTO exactly. This enables the use
708c2ecf20Sopenharmony_ci	 * of the args struct generated by the tplist tool (from the
718c2ecf20Sopenharmony_ci	 * bcc-tools package) to be used for those fields. To access
728c2ecf20Sopenharmony_ci	 * fields other than the tracepoint args will require the
738c2ecf20Sopenharmony_ci	 * tplist output to be adjusted.
748c2ecf20Sopenharmony_ci	 */
758c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
768c2ecf20Sopenharmony_ci		__field(void*, ring)
778c2ecf20Sopenharmony_ci		__field(void*, desc)
788c2ecf20Sopenharmony_ci		__field(void*, buf)
798c2ecf20Sopenharmony_ci		__string(devname, ring->netdev->name)
808c2ecf20Sopenharmony_ci	),
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	TP_fast_assign(
838c2ecf20Sopenharmony_ci		__entry->ring = ring;
848c2ecf20Sopenharmony_ci		__entry->desc = desc;
858c2ecf20Sopenharmony_ci		__entry->buf = buf;
868c2ecf20Sopenharmony_ci		__assign_str(devname, ring->netdev->name);
878c2ecf20Sopenharmony_ci	),
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	TP_printk(
908c2ecf20Sopenharmony_ci		"netdev: %s ring: %p desc: %p buf %p",
918c2ecf20Sopenharmony_ci		__get_str(devname), __entry->ring,
928c2ecf20Sopenharmony_ci		__entry->desc, __entry->buf)
938c2ecf20Sopenharmony_ci);
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ciDEFINE_EVENT(
968c2ecf20Sopenharmony_ci	iavf_tx_template, iavf_clean_tx_irq,
978c2ecf20Sopenharmony_ci	TP_PROTO(struct iavf_ring *ring,
988c2ecf20Sopenharmony_ci		 struct iavf_tx_desc *desc,
998c2ecf20Sopenharmony_ci		 struct iavf_tx_buffer *buf),
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	TP_ARGS(ring, desc, buf));
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ciDEFINE_EVENT(
1048c2ecf20Sopenharmony_ci	iavf_tx_template, iavf_clean_tx_irq_unmap,
1058c2ecf20Sopenharmony_ci	TP_PROTO(struct iavf_ring *ring,
1068c2ecf20Sopenharmony_ci		 struct iavf_tx_desc *desc,
1078c2ecf20Sopenharmony_ci		 struct iavf_tx_buffer *buf),
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	TP_ARGS(ring, desc, buf));
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(
1128c2ecf20Sopenharmony_ci	iavf_rx_template,
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	TP_PROTO(struct iavf_ring *ring,
1158c2ecf20Sopenharmony_ci		 union iavf_32byte_rx_desc *desc,
1168c2ecf20Sopenharmony_ci		 struct sk_buff *skb),
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	TP_ARGS(ring, desc, skb),
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
1218c2ecf20Sopenharmony_ci		__field(void*, ring)
1228c2ecf20Sopenharmony_ci		__field(void*, desc)
1238c2ecf20Sopenharmony_ci		__field(void*, skb)
1248c2ecf20Sopenharmony_ci		__string(devname, ring->netdev->name)
1258c2ecf20Sopenharmony_ci	),
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	TP_fast_assign(
1288c2ecf20Sopenharmony_ci		__entry->ring = ring;
1298c2ecf20Sopenharmony_ci		__entry->desc = desc;
1308c2ecf20Sopenharmony_ci		__entry->skb = skb;
1318c2ecf20Sopenharmony_ci		__assign_str(devname, ring->netdev->name);
1328c2ecf20Sopenharmony_ci	),
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci	TP_printk(
1358c2ecf20Sopenharmony_ci		"netdev: %s ring: %p desc: %p skb %p",
1368c2ecf20Sopenharmony_ci		__get_str(devname), __entry->ring,
1378c2ecf20Sopenharmony_ci		__entry->desc, __entry->skb)
1388c2ecf20Sopenharmony_ci);
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ciDEFINE_EVENT(
1418c2ecf20Sopenharmony_ci	iavf_rx_template, iavf_clean_rx_irq,
1428c2ecf20Sopenharmony_ci	TP_PROTO(struct iavf_ring *ring,
1438c2ecf20Sopenharmony_ci		 union iavf_32byte_rx_desc *desc,
1448c2ecf20Sopenharmony_ci		 struct sk_buff *skb),
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	TP_ARGS(ring, desc, skb));
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ciDEFINE_EVENT(
1498c2ecf20Sopenharmony_ci	iavf_rx_template, iavf_clean_rx_irq_rx,
1508c2ecf20Sopenharmony_ci	TP_PROTO(struct iavf_ring *ring,
1518c2ecf20Sopenharmony_ci		 union iavf_32byte_rx_desc *desc,
1528c2ecf20Sopenharmony_ci		 struct sk_buff *skb),
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	TP_ARGS(ring, desc, skb));
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(
1578c2ecf20Sopenharmony_ci	iavf_xmit_template,
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci	TP_PROTO(struct sk_buff *skb,
1608c2ecf20Sopenharmony_ci		 struct iavf_ring *ring),
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	TP_ARGS(skb, ring),
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
1658c2ecf20Sopenharmony_ci		__field(void*, skb)
1668c2ecf20Sopenharmony_ci		__field(void*, ring)
1678c2ecf20Sopenharmony_ci		__string(devname, ring->netdev->name)
1688c2ecf20Sopenharmony_ci	),
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	TP_fast_assign(
1718c2ecf20Sopenharmony_ci		__entry->skb = skb;
1728c2ecf20Sopenharmony_ci		__entry->ring = ring;
1738c2ecf20Sopenharmony_ci		__assign_str(devname, ring->netdev->name);
1748c2ecf20Sopenharmony_ci	),
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	TP_printk(
1778c2ecf20Sopenharmony_ci		"netdev: %s skb: %p ring: %p",
1788c2ecf20Sopenharmony_ci		__get_str(devname), __entry->skb,
1798c2ecf20Sopenharmony_ci		__entry->ring)
1808c2ecf20Sopenharmony_ci);
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ciDEFINE_EVENT(
1838c2ecf20Sopenharmony_ci	iavf_xmit_template, iavf_xmit_frame_ring,
1848c2ecf20Sopenharmony_ci	TP_PROTO(struct sk_buff *skb,
1858c2ecf20Sopenharmony_ci		 struct iavf_ring *ring),
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	TP_ARGS(skb, ring));
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ciDEFINE_EVENT(
1908c2ecf20Sopenharmony_ci	iavf_xmit_template, iavf_xmit_frame_ring_drop,
1918c2ecf20Sopenharmony_ci	TP_PROTO(struct sk_buff *skb,
1928c2ecf20Sopenharmony_ci		 struct iavf_ring *ring),
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	TP_ARGS(skb, ring));
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci/* Events unique to the VF. */
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci#endif /* _IAVF_TRACE_H_ */
1998c2ecf20Sopenharmony_ci/* This must be outside ifdef _IAVF_TRACE_H */
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci/* This trace include file is not located in the .../include/trace
2028c2ecf20Sopenharmony_ci * with the kernel tracepoint definitions, because we're a loadable
2038c2ecf20Sopenharmony_ci * module.
2048c2ecf20Sopenharmony_ci */
2058c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_PATH
2068c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_PATH .
2078c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_FILE
2088c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_FILE iavf_trace
2098c2ecf20Sopenharmony_ci#include <trace/define_trace.h>
210