xref: /openbmc/linux/arch/s390/include/asm/ap.h (revision 4a3fad70)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Adjunct processor (AP) interfaces
4  *
5  * Copyright IBM Corp. 2017
6  *
7  * Author(s): Tony Krowiak <akrowia@linux.vnet.ibm.com>
8  *	      Martin Schwidefsky <schwidefsky@de.ibm.com>
9  *	      Harald Freudenberger <freude@de.ibm.com>
10  */
11 
12 #ifndef _ASM_S390_AP_H_
13 #define _ASM_S390_AP_H_
14 
15 /**
16  * The ap_qid_t identifier of an ap queue.
17  * If the AP facilities test (APFT) facility is available,
18  * card and queue index are 8 bit values, otherwise
19  * card index is 6 bit and queue index a 4 bit value.
20  */
21 typedef unsigned int ap_qid_t;
22 
23 #define AP_MKQID(_card, _queue) (((_card) & 63) << 8 | ((_queue) & 255))
24 #define AP_QID_CARD(_qid) (((_qid) >> 8) & 63)
25 #define AP_QID_QUEUE(_qid) ((_qid) & 255)
26 
27 /**
28  * struct ap_queue_status - Holds the AP queue status.
29  * @queue_empty: Shows if queue is empty
30  * @replies_waiting: Waiting replies
31  * @queue_full: Is 1 if the queue is full
32  * @irq_enabled: Shows if interrupts are enabled for the AP
33  * @response_code: Holds the 8 bit response code
34  *
35  * The ap queue status word is returned by all three AP functions
36  * (PQAP, NQAP and DQAP).  There's a set of flags in the first
37  * byte, followed by a 1 byte response code.
38  */
39 struct ap_queue_status {
40 	unsigned int queue_empty	: 1;
41 	unsigned int replies_waiting	: 1;
42 	unsigned int queue_full		: 1;
43 	unsigned int _pad1		: 4;
44 	unsigned int irq_enabled	: 1;
45 	unsigned int response_code	: 8;
46 	unsigned int _pad2		: 16;
47 };
48 
49 /**
50  * ap_test_queue(): Test adjunct processor queue.
51  * @qid: The AP queue number
52  * @tbit: Test facilities bit
53  * @info: Pointer to queue descriptor
54  *
55  * Returns AP queue status structure.
56  */
57 struct ap_queue_status ap_test_queue(ap_qid_t qid,
58 				     int tbit,
59 				     unsigned long *info);
60 
61 struct ap_config_info {
62 	unsigned int apsc	 : 1;	/* S bit */
63 	unsigned int apxa	 : 1;	/* N bit */
64 	unsigned int qact	 : 1;	/* C bit */
65 	unsigned int rc8a	 : 1;	/* R bit */
66 	unsigned char _reserved1 : 4;
67 	unsigned char _reserved2[3];
68 	unsigned char Na;		/* max # of APs - 1 */
69 	unsigned char Nd;		/* max # of Domains - 1 */
70 	unsigned char _reserved3[10];
71 	unsigned int apm[8];		/* AP ID mask */
72 	unsigned int aqm[8];		/* AP queue mask */
73 	unsigned int adm[8];		/* AP domain mask */
74 	unsigned char _reserved4[16];
75 } __aligned(8);
76 
77 /*
78  * ap_query_configuration(): Fetch cryptographic config info
79  *
80  * Returns the ap configuration info fetched via PQAP(QCI).
81  * On success 0 is returned, on failure a negative errno
82  * is returned, e.g. if the PQAP(QCI) instruction is not
83  * available, the return value will be -EOPNOTSUPP.
84  */
85 int ap_query_configuration(struct ap_config_info *info);
86 
87 /*
88  * struct ap_qirq_ctrl - convenient struct for easy invocation
89  * of the ap_queue_irq_ctrl() function. This struct is passed
90  * as GR1 parameter to the PQAP(AQIC) instruction. For details
91  * please see the AR documentation.
92  */
93 struct ap_qirq_ctrl {
94 	unsigned int _res1 : 8;
95 	unsigned int zone  : 8;  /* zone info */
96 	unsigned int ir    : 1;  /* ir flag: enable (1) or disable (0) irq */
97 	unsigned int _res2 : 4;
98 	unsigned int gisc  : 3;  /* guest isc field */
99 	unsigned int _res3 : 6;
100 	unsigned int gf    : 2;  /* gisa format */
101 	unsigned int _res4 : 1;
102 	unsigned int gisa  : 27; /* gisa origin */
103 	unsigned int _res5 : 1;
104 	unsigned int isc   : 3;  /* irq sub class */
105 };
106 
107 /**
108  * ap_queue_irq_ctrl(): Control interruption on a AP queue.
109  * @qid: The AP queue number
110  * @qirqctrl: struct ap_qirq_ctrl, see above
111  * @ind: The notification indicator byte
112  *
113  * Returns AP queue status.
114  *
115  * Control interruption on the given AP queue.
116  * Just a simple wrapper function for the low level PQAP(AQIC)
117  * instruction available for other kernel modules.
118  */
119 struct ap_queue_status ap_queue_irq_ctrl(ap_qid_t qid,
120 					 struct ap_qirq_ctrl qirqctrl,
121 					 void *ind);
122 
123 #endif /* _ASM_S390_AP_H_ */
124