Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[sfrench/cifs-2.6.git] / drivers / s390 / crypto / z90common.h
1 /*
2  *  linux/drivers/s390/crypto/z90common.h
3  *
4  *  z90crypt 1.3.3
5  *
6  *  Copyright (C)  2001, 2005 IBM Corporation
7  *  Author(s): Robert Burroughs (burrough@us.ibm.com)
8  *             Eric Rossman (edrossma@us.ibm.com)
9  *
10  *  Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  */
26
27 #ifndef _Z90COMMON_H_
28 #define _Z90COMMON_H_
29
30 #define VERSION_Z90COMMON_H "$Revision: 1.17 $"
31
32
33 #define RESPBUFFSIZE 256
34 #define PCI_FUNC_KEY_DECRYPT 0x5044
35 #define PCI_FUNC_KEY_ENCRYPT 0x504B
36 extern int ext_bitlens;
37
38 enum devstat {
39         DEV_GONE,
40         DEV_ONLINE,
41         DEV_QUEUE_FULL,
42         DEV_EMPTY,
43         DEV_NO_WORK,
44         DEV_BAD_MESSAGE,
45         DEV_TSQ_EXCEPTION,
46         DEV_RSQ_EXCEPTION,
47         DEV_SEN_EXCEPTION,
48         DEV_REC_EXCEPTION
49 };
50
51 enum hdstat {
52         HD_NOT_THERE,
53         HD_BUSY,
54         HD_DECONFIGURED,
55         HD_CHECKSTOPPED,
56         HD_ONLINE,
57         HD_TSQ_EXCEPTION
58 };
59
60 #define Z90C_NO_DEVICES         1
61 #define Z90C_AMBIGUOUS_DOMAIN   2
62 #define Z90C_INCORRECT_DOMAIN   3
63 #define ENOTINIT                4
64
65 #define SEN_BUSY         7
66 #define SEN_USER_ERROR   8
67 #define SEN_QUEUE_FULL  11
68 #define SEN_NOT_AVAIL   16
69 #define SEN_PAD_ERROR   17
70 #define SEN_RETRY       18
71 #define SEN_RELEASED    24
72
73 #define REC_EMPTY        4
74 #define REC_BUSY         6
75 #define REC_OPERAND_INV  8
76 #define REC_OPERAND_SIZE 9
77 #define REC_EVEN_MOD    10
78 #define REC_NO_WORK     11
79 #define REC_HARDWAR_ERR 12
80 #define REC_NO_RESPONSE 13
81 #define REC_RETRY_DEV   14
82 #define REC_USER_GONE   15
83 #define REC_BAD_MESSAGE 16
84 #define REC_INVALID_PAD 17
85 #define REC_USE_PCICA   18
86
87 #define WRONG_DEVICE_TYPE 20
88
89 #define REC_FATAL_ERROR 32
90 #define SEN_FATAL_ERROR 33
91 #define TSQ_FATAL_ERROR 34
92 #define RSQ_FATAL_ERROR 35
93
94 #define Z90CRYPT_NUM_TYPES      6
95 #define PCICA           0
96 #define PCICC           1
97 #define PCIXCC_MCL2     2
98 #define PCIXCC_MCL3     3
99 #define CEX2C           4
100 #define CEX2A           5
101 #define NILDEV          -1
102 #define ANYDEV          -1
103 #define PCIXCC_UNK      -2
104
105 enum hdevice_type {
106         PCICC_HW  = 3,
107         PCICA_HW  = 4,
108         PCIXCC_HW = 5,
109         CEX2A_HW  = 6,
110         CEX2C_HW  = 7
111 };
112
113 struct CPRBX {
114         unsigned short cprb_len;
115         unsigned char  cprb_ver_id;
116         unsigned char  pad_000[3];
117         unsigned char  func_id[2];
118         unsigned char  cprb_flags[4];
119         unsigned int   req_parml;
120         unsigned int   req_datal;
121         unsigned int   rpl_msgbl;
122         unsigned int   rpld_parml;
123         unsigned int   rpl_datal;
124         unsigned int   rpld_datal;
125         unsigned int   req_extbl;
126         unsigned char  pad_001[4];
127         unsigned int   rpld_extbl;
128         unsigned char  req_parmb[16];
129         unsigned char  req_datab[16];
130         unsigned char  rpl_parmb[16];
131         unsigned char  rpl_datab[16];
132         unsigned char  req_extb[16];
133         unsigned char  rpl_extb[16];
134         unsigned short ccp_rtcode;
135         unsigned short ccp_rscode;
136         unsigned int   mac_data_len;
137         unsigned char  logon_id[8];
138         unsigned char  mac_value[8];
139         unsigned char  mac_content_flgs;
140         unsigned char  pad_002;
141         unsigned short domain;
142         unsigned char  pad_003[12];
143         unsigned char  pad_004[36];
144 };
145
146 #ifndef DEV_NAME
147 #define DEV_NAME        "z90crypt"
148 #endif
149 #define PRINTK(fmt, args...) \
150         printk(KERN_DEBUG DEV_NAME ": %s -> " fmt, __FUNCTION__ , ## args)
151 #define PRINTKN(fmt, args...) \
152         printk(KERN_DEBUG DEV_NAME ": " fmt, ## args)
153 #define PRINTKW(fmt, args...) \
154         printk(KERN_WARNING DEV_NAME ": %s -> " fmt, __FUNCTION__ , ## args)
155 #define PRINTKC(fmt, args...) \
156         printk(KERN_CRIT DEV_NAME ": %s -> " fmt, __FUNCTION__ , ## args)
157
158 #ifdef Z90CRYPT_DEBUG
159 #define PDEBUG(fmt, args...) \
160         printk(KERN_DEBUG DEV_NAME ": %s -> " fmt, __FUNCTION__ , ## args)
161 #else
162 #define PDEBUG(fmt, args...) do {} while (0)
163 #endif
164
165 #define UMIN(a,b) ((a) < (b) ? (a) : (b))
166 #define IS_EVEN(x) ((x) == (2 * ((x) / 2)))
167
168 #endif