18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Tracepoint definitions for the s390 zcrypt device driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright IBM Corp. 2016
68c2ecf20Sopenharmony_ci * Author(s): Harald Freudenberger <freude@de.ibm.com>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Currently there are two tracepoint events defined here.
98c2ecf20Sopenharmony_ci * An s390_zcrypt_req request event occurs as soon as the request is
108c2ecf20Sopenharmony_ci * recognized by the zcrypt ioctl function. This event may act as some kind
118c2ecf20Sopenharmony_ci * of request-processing-starts-now indication.
128c2ecf20Sopenharmony_ci * As late as possible within the zcrypt ioctl function there occurs the
138c2ecf20Sopenharmony_ci * s390_zcrypt_rep event which may act as the point in time where the
148c2ecf20Sopenharmony_ci * request has been processed by the kernel and the result is about to be
158c2ecf20Sopenharmony_ci * transferred back to userspace.
168c2ecf20Sopenharmony_ci * The glue which binds together request and reply event is the ptr
178c2ecf20Sopenharmony_ci * parameter, which is the local buffer address where the request from
188c2ecf20Sopenharmony_ci * userspace has been stored by the ioctl function.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * The main purpose of this zcrypt tracepoint api is to get some data for
218c2ecf20Sopenharmony_ci * performance measurements together with information about on which card
228c2ecf20Sopenharmony_ci * and queue the request has been processed. It is not an ffdc interface as
238c2ecf20Sopenharmony_ci * there is already code in the zcrypt device driver to serve the s390
248c2ecf20Sopenharmony_ci * debug feature interface.
258c2ecf20Sopenharmony_ci */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#undef TRACE_SYSTEM
288c2ecf20Sopenharmony_ci#define TRACE_SYSTEM s390
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#if !defined(_TRACE_S390_ZCRYPT_H) || defined(TRACE_HEADER_MULTI_READ)
318c2ecf20Sopenharmony_ci#define _TRACE_S390_ZCRYPT_H
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#include <linux/tracepoint.h>
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define TP_ICARSAMODEXPO  0x0001
368c2ecf20Sopenharmony_ci#define TP_ICARSACRT	  0x0002
378c2ecf20Sopenharmony_ci#define TB_ZSECSENDCPRB   0x0003
388c2ecf20Sopenharmony_ci#define TP_ZSENDEP11CPRB  0x0004
398c2ecf20Sopenharmony_ci#define TP_HWRNGCPRB	  0x0005
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define show_zcrypt_tp_type(type)				\
428c2ecf20Sopenharmony_ci	__print_symbolic(type,					\
438c2ecf20Sopenharmony_ci			 { TP_ICARSAMODEXPO, "ICARSAMODEXPO" }, \
448c2ecf20Sopenharmony_ci			 { TP_ICARSACRT, "ICARSACRT" },		\
458c2ecf20Sopenharmony_ci			 { TB_ZSECSENDCPRB, "ZSECSENDCPRB" },	\
468c2ecf20Sopenharmony_ci			 { TP_ZSENDEP11CPRB, "ZSENDEP11CPRB" }, \
478c2ecf20Sopenharmony_ci			 { TP_HWRNGCPRB, "HWRNGCPRB" })
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/**
508c2ecf20Sopenharmony_ci * trace_s390_zcrypt_req - zcrypt request tracepoint function
518c2ecf20Sopenharmony_ci * @ptr:  Address of the local buffer where the request from userspace
528c2ecf20Sopenharmony_ci *	  is stored. Can be used as a unique id to relate together
538c2ecf20Sopenharmony_ci *	  request and reply.
548c2ecf20Sopenharmony_ci * @type: One of the TP_ defines above.
558c2ecf20Sopenharmony_ci *
568c2ecf20Sopenharmony_ci * Called when a request from userspace is recognised within the ioctl
578c2ecf20Sopenharmony_ci * function of the zcrypt device driver and may act as an entry
588c2ecf20Sopenharmony_ci * timestamp.
598c2ecf20Sopenharmony_ci */
608c2ecf20Sopenharmony_ciTRACE_EVENT(s390_zcrypt_req,
618c2ecf20Sopenharmony_ci	    TP_PROTO(void *ptr, u32 type),
628c2ecf20Sopenharmony_ci	    TP_ARGS(ptr, type),
638c2ecf20Sopenharmony_ci	    TP_STRUCT__entry(
648c2ecf20Sopenharmony_ci		    __field(void *, ptr)
658c2ecf20Sopenharmony_ci		    __field(u32, type)),
668c2ecf20Sopenharmony_ci	    TP_fast_assign(
678c2ecf20Sopenharmony_ci		    __entry->ptr = ptr;
688c2ecf20Sopenharmony_ci		    __entry->type = type;),
698c2ecf20Sopenharmony_ci	    TP_printk("ptr=%p type=%s",
708c2ecf20Sopenharmony_ci		      __entry->ptr,
718c2ecf20Sopenharmony_ci		      show_zcrypt_tp_type(__entry->type))
728c2ecf20Sopenharmony_ci);
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/**
758c2ecf20Sopenharmony_ci * trace_s390_zcrypt_rep - zcrypt reply tracepoint function
768c2ecf20Sopenharmony_ci * @ptr:  Address of the local buffer where the request from userspace
778c2ecf20Sopenharmony_ci *	  is stored. Can be used as a unique id to match together
788c2ecf20Sopenharmony_ci *	  request and reply.
798c2ecf20Sopenharmony_ci * @fc:   Function code.
808c2ecf20Sopenharmony_ci * @rc:   The bare returncode as returned by the device driver ioctl
818c2ecf20Sopenharmony_ci *	  function.
828c2ecf20Sopenharmony_ci * @dev:  The adapter nr where this request was actually processed.
838c2ecf20Sopenharmony_ci * @dom:  Domain id of the device where this request was processed.
848c2ecf20Sopenharmony_ci *
858c2ecf20Sopenharmony_ci * Called upon recognising the reply from the crypto adapter. This
868c2ecf20Sopenharmony_ci * message may act as the exit timestamp for the request but also
878c2ecf20Sopenharmony_ci * carries some info about on which adapter the request was processed
888c2ecf20Sopenharmony_ci * and the returncode from the device driver.
898c2ecf20Sopenharmony_ci */
908c2ecf20Sopenharmony_ciTRACE_EVENT(s390_zcrypt_rep,
918c2ecf20Sopenharmony_ci	    TP_PROTO(void *ptr, u32 fc, u32 rc, u16 dev, u16 dom),
928c2ecf20Sopenharmony_ci	    TP_ARGS(ptr, fc, rc, dev, dom),
938c2ecf20Sopenharmony_ci	    TP_STRUCT__entry(
948c2ecf20Sopenharmony_ci		    __field(void *, ptr)
958c2ecf20Sopenharmony_ci		    __field(u32, fc)
968c2ecf20Sopenharmony_ci		    __field(u32, rc)
978c2ecf20Sopenharmony_ci		    __field(u16, device)
988c2ecf20Sopenharmony_ci		    __field(u16, domain)),
998c2ecf20Sopenharmony_ci	    TP_fast_assign(
1008c2ecf20Sopenharmony_ci		    __entry->ptr = ptr;
1018c2ecf20Sopenharmony_ci		    __entry->fc = fc;
1028c2ecf20Sopenharmony_ci		    __entry->rc = rc;
1038c2ecf20Sopenharmony_ci		    __entry->device = dev;
1048c2ecf20Sopenharmony_ci		    __entry->domain = dom;),
1058c2ecf20Sopenharmony_ci	    TP_printk("ptr=%p fc=0x%04x rc=%d dev=0x%02hx domain=0x%04hx",
1068c2ecf20Sopenharmony_ci		      __entry->ptr,
1078c2ecf20Sopenharmony_ci		      (unsigned int) __entry->fc,
1088c2ecf20Sopenharmony_ci		      (int) __entry->rc,
1098c2ecf20Sopenharmony_ci		      (unsigned short) __entry->device,
1108c2ecf20Sopenharmony_ci		      (unsigned short) __entry->domain)
1118c2ecf20Sopenharmony_ci);
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#endif /* _TRACE_S390_ZCRYPT_H */
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/* This part must be outside protection */
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_PATH
1188c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_FILE
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_PATH asm/trace
1218c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_FILE zcrypt
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci#include <trace/define_trace.h>
124