162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Tracepoint definitions for the s390 zcrypt device driver
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright IBM Corp. 2016
662306a36Sopenharmony_ci * Author(s): Harald Freudenberger <freude@de.ibm.com>
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Currently there are two tracepoint events defined here.
962306a36Sopenharmony_ci * An s390_zcrypt_req request event occurs as soon as the request is
1062306a36Sopenharmony_ci * recognized by the zcrypt ioctl function. This event may act as some kind
1162306a36Sopenharmony_ci * of request-processing-starts-now indication.
1262306a36Sopenharmony_ci * As late as possible within the zcrypt ioctl function there occurs the
1362306a36Sopenharmony_ci * s390_zcrypt_rep event which may act as the point in time where the
1462306a36Sopenharmony_ci * request has been processed by the kernel and the result is about to be
1562306a36Sopenharmony_ci * transferred back to userspace.
1662306a36Sopenharmony_ci * The glue which binds together request and reply event is the ptr
1762306a36Sopenharmony_ci * parameter, which is the local buffer address where the request from
1862306a36Sopenharmony_ci * userspace has been stored by the ioctl function.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci * The main purpose of this zcrypt tracepoint api is to get some data for
2162306a36Sopenharmony_ci * performance measurements together with information about on which card
2262306a36Sopenharmony_ci * and queue the request has been processed. It is not an ffdc interface as
2362306a36Sopenharmony_ci * there is already code in the zcrypt device driver to serve the s390
2462306a36Sopenharmony_ci * debug feature interface.
2562306a36Sopenharmony_ci */
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#undef TRACE_SYSTEM
2862306a36Sopenharmony_ci#define TRACE_SYSTEM s390
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#if !defined(_TRACE_S390_ZCRYPT_H) || defined(TRACE_HEADER_MULTI_READ)
3162306a36Sopenharmony_ci#define _TRACE_S390_ZCRYPT_H
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#include <linux/tracepoint.h>
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define TP_ICARSAMODEXPO  0x0001
3662306a36Sopenharmony_ci#define TP_ICARSACRT	  0x0002
3762306a36Sopenharmony_ci#define TB_ZSECSENDCPRB   0x0003
3862306a36Sopenharmony_ci#define TP_ZSENDEP11CPRB  0x0004
3962306a36Sopenharmony_ci#define TP_HWRNGCPRB	  0x0005
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define show_zcrypt_tp_type(type)				\
4262306a36Sopenharmony_ci	__print_symbolic(type,					\
4362306a36Sopenharmony_ci			 { TP_ICARSAMODEXPO, "ICARSAMODEXPO" }, \
4462306a36Sopenharmony_ci			 { TP_ICARSACRT, "ICARSACRT" },		\
4562306a36Sopenharmony_ci			 { TB_ZSECSENDCPRB, "ZSECSENDCPRB" },	\
4662306a36Sopenharmony_ci			 { TP_ZSENDEP11CPRB, "ZSENDEP11CPRB" }, \
4762306a36Sopenharmony_ci			 { TP_HWRNGCPRB, "HWRNGCPRB" })
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/**
5062306a36Sopenharmony_ci * trace_s390_zcrypt_req - zcrypt request tracepoint function
5162306a36Sopenharmony_ci * @ptr:  Address of the local buffer where the request from userspace
5262306a36Sopenharmony_ci *	  is stored. Can be used as a unique id to relate together
5362306a36Sopenharmony_ci *	  request and reply.
5462306a36Sopenharmony_ci * @type: One of the TP_ defines above.
5562306a36Sopenharmony_ci *
5662306a36Sopenharmony_ci * Called when a request from userspace is recognised within the ioctl
5762306a36Sopenharmony_ci * function of the zcrypt device driver and may act as an entry
5862306a36Sopenharmony_ci * timestamp.
5962306a36Sopenharmony_ci */
6062306a36Sopenharmony_ciTRACE_EVENT(s390_zcrypt_req,
6162306a36Sopenharmony_ci	    TP_PROTO(void *ptr, u32 type),
6262306a36Sopenharmony_ci	    TP_ARGS(ptr, type),
6362306a36Sopenharmony_ci	    TP_STRUCT__entry(
6462306a36Sopenharmony_ci		    __field(void *, ptr)
6562306a36Sopenharmony_ci		    __field(u32, type)),
6662306a36Sopenharmony_ci	    TP_fast_assign(
6762306a36Sopenharmony_ci		    __entry->ptr = ptr;
6862306a36Sopenharmony_ci		    __entry->type = type;),
6962306a36Sopenharmony_ci	    TP_printk("ptr=%p type=%s",
7062306a36Sopenharmony_ci		      __entry->ptr,
7162306a36Sopenharmony_ci		      show_zcrypt_tp_type(__entry->type))
7262306a36Sopenharmony_ci);
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/**
7562306a36Sopenharmony_ci * trace_s390_zcrypt_rep - zcrypt reply tracepoint function
7662306a36Sopenharmony_ci * @ptr:  Address of the local buffer where the request from userspace
7762306a36Sopenharmony_ci *	  is stored. Can be used as a unique id to match together
7862306a36Sopenharmony_ci *	  request and reply.
7962306a36Sopenharmony_ci * @fc:   Function code.
8062306a36Sopenharmony_ci * @rc:   The bare returncode as returned by the device driver ioctl
8162306a36Sopenharmony_ci *	  function.
8262306a36Sopenharmony_ci * @dev:  The adapter nr where this request was actually processed.
8362306a36Sopenharmony_ci * @dom:  Domain id of the device where this request was processed.
8462306a36Sopenharmony_ci *
8562306a36Sopenharmony_ci * Called upon recognising the reply from the crypto adapter. This
8662306a36Sopenharmony_ci * message may act as the exit timestamp for the request but also
8762306a36Sopenharmony_ci * carries some info about on which adapter the request was processed
8862306a36Sopenharmony_ci * and the returncode from the device driver.
8962306a36Sopenharmony_ci */
9062306a36Sopenharmony_ciTRACE_EVENT(s390_zcrypt_rep,
9162306a36Sopenharmony_ci	    TP_PROTO(void *ptr, u32 fc, u32 rc, u16 dev, u16 dom),
9262306a36Sopenharmony_ci	    TP_ARGS(ptr, fc, rc, dev, dom),
9362306a36Sopenharmony_ci	    TP_STRUCT__entry(
9462306a36Sopenharmony_ci		    __field(void *, ptr)
9562306a36Sopenharmony_ci		    __field(u32, fc)
9662306a36Sopenharmony_ci		    __field(u32, rc)
9762306a36Sopenharmony_ci		    __field(u16, device)
9862306a36Sopenharmony_ci		    __field(u16, domain)),
9962306a36Sopenharmony_ci	    TP_fast_assign(
10062306a36Sopenharmony_ci		    __entry->ptr = ptr;
10162306a36Sopenharmony_ci		    __entry->fc = fc;
10262306a36Sopenharmony_ci		    __entry->rc = rc;
10362306a36Sopenharmony_ci		    __entry->device = dev;
10462306a36Sopenharmony_ci		    __entry->domain = dom;),
10562306a36Sopenharmony_ci	    TP_printk("ptr=%p fc=0x%04x rc=%d dev=0x%02hx domain=0x%04hx",
10662306a36Sopenharmony_ci		      __entry->ptr,
10762306a36Sopenharmony_ci		      (unsigned int) __entry->fc,
10862306a36Sopenharmony_ci		      (int) __entry->rc,
10962306a36Sopenharmony_ci		      (unsigned short) __entry->device,
11062306a36Sopenharmony_ci		      (unsigned short) __entry->domain)
11162306a36Sopenharmony_ci);
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci#endif /* _TRACE_S390_ZCRYPT_H */
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/* This part must be outside protection */
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci#undef TRACE_INCLUDE_PATH
11862306a36Sopenharmony_ci#undef TRACE_INCLUDE_FILE
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci#define TRACE_INCLUDE_PATH asm/trace
12162306a36Sopenharmony_ci#define TRACE_INCLUDE_FILE zcrypt
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci#include <trace/define_trace.h>
124