xref: /OK3568_Linux_fs/kernel/arch/s390/include/asm/trace/zcrypt.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Tracepoint definitions for the s390 zcrypt device driver
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright IBM Corp. 2016
6*4882a593Smuzhiyun  * Author(s): Harald Freudenberger <freude@de.ibm.com>
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Currently there are two tracepoint events defined here.
9*4882a593Smuzhiyun  * An s390_zcrypt_req request event occurs as soon as the request is
10*4882a593Smuzhiyun  * recognized by the zcrypt ioctl function. This event may act as some kind
11*4882a593Smuzhiyun  * of request-processing-starts-now indication.
12*4882a593Smuzhiyun  * As late as possible within the zcrypt ioctl function there occurs the
13*4882a593Smuzhiyun  * s390_zcrypt_rep event which may act as the point in time where the
14*4882a593Smuzhiyun  * request has been processed by the kernel and the result is about to be
15*4882a593Smuzhiyun  * transferred back to userspace.
16*4882a593Smuzhiyun  * The glue which binds together request and reply event is the ptr
17*4882a593Smuzhiyun  * parameter, which is the local buffer address where the request from
18*4882a593Smuzhiyun  * userspace has been stored by the ioctl function.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * The main purpose of this zcrypt tracepoint api is to get some data for
21*4882a593Smuzhiyun  * performance measurements together with information about on which card
22*4882a593Smuzhiyun  * and queue the request has been processed. It is not an ffdc interface as
23*4882a593Smuzhiyun  * there is already code in the zcrypt device driver to serve the s390
24*4882a593Smuzhiyun  * debug feature interface.
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #undef TRACE_SYSTEM
28*4882a593Smuzhiyun #define TRACE_SYSTEM s390
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #if !defined(_TRACE_S390_ZCRYPT_H) || defined(TRACE_HEADER_MULTI_READ)
31*4882a593Smuzhiyun #define _TRACE_S390_ZCRYPT_H
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #include <linux/tracepoint.h>
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #define TP_ICARSAMODEXPO  0x0001
36*4882a593Smuzhiyun #define TP_ICARSACRT	  0x0002
37*4882a593Smuzhiyun #define TB_ZSECSENDCPRB   0x0003
38*4882a593Smuzhiyun #define TP_ZSENDEP11CPRB  0x0004
39*4882a593Smuzhiyun #define TP_HWRNGCPRB	  0x0005
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #define show_zcrypt_tp_type(type)				\
42*4882a593Smuzhiyun 	__print_symbolic(type,					\
43*4882a593Smuzhiyun 			 { TP_ICARSAMODEXPO, "ICARSAMODEXPO" }, \
44*4882a593Smuzhiyun 			 { TP_ICARSACRT, "ICARSACRT" },		\
45*4882a593Smuzhiyun 			 { TB_ZSECSENDCPRB, "ZSECSENDCPRB" },	\
46*4882a593Smuzhiyun 			 { TP_ZSENDEP11CPRB, "ZSENDEP11CPRB" }, \
47*4882a593Smuzhiyun 			 { TP_HWRNGCPRB, "HWRNGCPRB" })
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun /**
50*4882a593Smuzhiyun  * trace_s390_zcrypt_req - zcrypt request tracepoint function
51*4882a593Smuzhiyun  * @ptr:  Address of the local buffer where the request from userspace
52*4882a593Smuzhiyun  *	  is stored. Can be used as a unique id to relate together
53*4882a593Smuzhiyun  *	  request and reply.
54*4882a593Smuzhiyun  * @type: One of the TP_ defines above.
55*4882a593Smuzhiyun  *
56*4882a593Smuzhiyun  * Called when a request from userspace is recognised within the ioctl
57*4882a593Smuzhiyun  * function of the zcrypt device driver and may act as an entry
58*4882a593Smuzhiyun  * timestamp.
59*4882a593Smuzhiyun  */
60*4882a593Smuzhiyun TRACE_EVENT(s390_zcrypt_req,
61*4882a593Smuzhiyun 	    TP_PROTO(void *ptr, u32 type),
62*4882a593Smuzhiyun 	    TP_ARGS(ptr, type),
63*4882a593Smuzhiyun 	    TP_STRUCT__entry(
64*4882a593Smuzhiyun 		    __field(void *, ptr)
65*4882a593Smuzhiyun 		    __field(u32, type)),
66*4882a593Smuzhiyun 	    TP_fast_assign(
67*4882a593Smuzhiyun 		    __entry->ptr = ptr;
68*4882a593Smuzhiyun 		    __entry->type = type;),
69*4882a593Smuzhiyun 	    TP_printk("ptr=%p type=%s",
70*4882a593Smuzhiyun 		      __entry->ptr,
71*4882a593Smuzhiyun 		      show_zcrypt_tp_type(__entry->type))
72*4882a593Smuzhiyun );
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun /**
75*4882a593Smuzhiyun  * trace_s390_zcrypt_rep - zcrypt reply tracepoint function
76*4882a593Smuzhiyun  * @ptr:  Address of the local buffer where the request from userspace
77*4882a593Smuzhiyun  *	  is stored. Can be used as a unique id to match together
78*4882a593Smuzhiyun  *	  request and reply.
79*4882a593Smuzhiyun  * @fc:   Function code.
80*4882a593Smuzhiyun  * @rc:   The bare returncode as returned by the device driver ioctl
81*4882a593Smuzhiyun  *	  function.
82*4882a593Smuzhiyun  * @dev:  The adapter nr where this request was actually processed.
83*4882a593Smuzhiyun  * @dom:  Domain id of the device where this request was processed.
84*4882a593Smuzhiyun  *
85*4882a593Smuzhiyun  * Called upon recognising the reply from the crypto adapter. This
86*4882a593Smuzhiyun  * message may act as the exit timestamp for the request but also
87*4882a593Smuzhiyun  * carries some info about on which adapter the request was processed
88*4882a593Smuzhiyun  * and the returncode from the device driver.
89*4882a593Smuzhiyun  */
90*4882a593Smuzhiyun TRACE_EVENT(s390_zcrypt_rep,
91*4882a593Smuzhiyun 	    TP_PROTO(void *ptr, u32 fc, u32 rc, u16 dev, u16 dom),
92*4882a593Smuzhiyun 	    TP_ARGS(ptr, fc, rc, dev, dom),
93*4882a593Smuzhiyun 	    TP_STRUCT__entry(
94*4882a593Smuzhiyun 		    __field(void *, ptr)
95*4882a593Smuzhiyun 		    __field(u32, fc)
96*4882a593Smuzhiyun 		    __field(u32, rc)
97*4882a593Smuzhiyun 		    __field(u16, device)
98*4882a593Smuzhiyun 		    __field(u16, domain)),
99*4882a593Smuzhiyun 	    TP_fast_assign(
100*4882a593Smuzhiyun 		    __entry->ptr = ptr;
101*4882a593Smuzhiyun 		    __entry->fc = fc;
102*4882a593Smuzhiyun 		    __entry->rc = rc;
103*4882a593Smuzhiyun 		    __entry->device = dev;
104*4882a593Smuzhiyun 		    __entry->domain = dom;),
105*4882a593Smuzhiyun 	    TP_printk("ptr=%p fc=0x%04x rc=%d dev=0x%02hx domain=0x%04hx",
106*4882a593Smuzhiyun 		      __entry->ptr,
107*4882a593Smuzhiyun 		      (unsigned int) __entry->fc,
108*4882a593Smuzhiyun 		      (int) __entry->rc,
109*4882a593Smuzhiyun 		      (unsigned short) __entry->device,
110*4882a593Smuzhiyun 		      (unsigned short) __entry->domain)
111*4882a593Smuzhiyun );
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun #endif /* _TRACE_S390_ZCRYPT_H */
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun /* This part must be outside protection */
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun #undef TRACE_INCLUDE_PATH
118*4882a593Smuzhiyun #undef TRACE_INCLUDE_FILE
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun #define TRACE_INCLUDE_PATH asm/trace
121*4882a593Smuzhiyun #define TRACE_INCLUDE_FILE zcrypt
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun #include <trace/define_trace.h>
124