blob: 8cefd6ed981da76c5a27637238c12dbd1d8b11bf [file] [log] [blame]
Tony Krowiake7fc5142016-11-08 07:09:13 +01001/*
2 * Adjunct processor (AP) interfaces
3 *
4 * Copyright IBM Corp. 2017
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only)
8 * as published by the Free Software Foundation.
9 *
10 * Author(s): Tony Krowiak <akrowia@linux.vnet.ibm.com>
11 * Martin Schwidefsky <schwidefsky@de.ibm.com>
12 * Harald Freudenberger <freude@de.ibm.com>
13 */
14
15#ifndef _ASM_S390_AP_H_
16#define _ASM_S390_AP_H_
17
18/**
19 * The ap_qid_t identifier of an ap queue.
20 * If the AP facilities test (APFT) facility is available,
21 * card and queue index are 8 bit values, otherwise
22 * card index is 6 bit and queue index a 4 bit value.
23 */
24typedef unsigned int ap_qid_t;
25
26#define AP_MKQID(_card, _queue) (((_card) & 63) << 8 | ((_queue) & 255))
27#define AP_QID_CARD(_qid) (((_qid) >> 8) & 63)
28#define AP_QID_QUEUE(_qid) ((_qid) & 255)
29
30/**
31 * struct ap_queue_status - Holds the AP queue status.
32 * @queue_empty: Shows if queue is empty
33 * @replies_waiting: Waiting replies
34 * @queue_full: Is 1 if the queue is full
35 * @irq_enabled: Shows if interrupts are enabled for the AP
36 * @response_code: Holds the 8 bit response code
37 *
38 * The ap queue status word is returned by all three AP functions
39 * (PQAP, NQAP and DQAP). There's a set of flags in the first
40 * byte, followed by a 1 byte response code.
41 */
42struct ap_queue_status {
43 unsigned int queue_empty : 1;
44 unsigned int replies_waiting : 1;
45 unsigned int queue_full : 1;
46 unsigned int _pad1 : 4;
47 unsigned int irq_enabled : 1;
48 unsigned int response_code : 8;
49 unsigned int _pad2 : 16;
50};
51
52/**
53 * ap_test_queue(): Test adjunct processor queue.
54 * @qid: The AP queue number
55 * @tbit: Test facilities bit
56 * @info: Pointer to queue descriptor
57 *
58 * Returns AP queue status structure.
59 */
60struct ap_queue_status ap_test_queue(ap_qid_t qid,
61 int tbit,
62 unsigned long *info);
63
Harald Freudenberger050349b2016-11-08 11:54:28 +010064struct ap_config_info {
65 unsigned int apsc : 1; /* S bit */
66 unsigned int apxa : 1; /* N bit */
67 unsigned int qact : 1; /* C bit */
68 unsigned int rc8a : 1; /* R bit */
69 unsigned char _reserved1 : 4;
70 unsigned char _reserved2[3];
71 unsigned char Na; /* max # of APs - 1 */
72 unsigned char Nd; /* max # of Domains - 1 */
73 unsigned char _reserved3[10];
74 unsigned int apm[8]; /* AP ID mask */
75 unsigned int aqm[8]; /* AP queue mask */
76 unsigned int adm[8]; /* AP domain mask */
77 unsigned char _reserved4[16];
78} __aligned(8);
79
80/*
81 * ap_query_configuration(): Fetch cryptographic config info
82 *
83 * Returns the ap configuration info fetched via PQAP(QCI).
84 * On success 0 is returned, on failure a negative errno
85 * is returned, e.g. if the PQAP(QCI) instruction is not
86 * available, the return value will be -EOPNOTSUPP.
87 */
88int ap_query_configuration(struct ap_config_info *info);
89
Tony Krowiake7fc5142016-11-08 07:09:13 +010090#endif /* _ASM_S390_AP_H_ */