28 #include <linux/module.h>
32 #include <linux/slab.h>
34 #include <asm/uaccess.h>
43 #define PCIXCC_MIN_MOD_SIZE 16
44 #define PCIXCC_MIN_MOD_SIZE_OLD 64
45 #define PCIXCC_MAX_MOD_SIZE 256
46 #define CEX3C_MIN_MOD_SIZE PCIXCC_MIN_MOD_SIZE
47 #define CEX3C_MAX_MOD_SIZE 512
49 #define PCIXCC_MCL2_SPEED_RATING 7870
50 #define PCIXCC_MCL3_SPEED_RATING 7870
51 #define CEX2C_SPEED_RATING 7000
52 #define CEX3C_SPEED_RATING 6500
54 #define PCIXCC_MAX_ICA_MESSAGE_SIZE 0x77c
55 #define PCIXCC_MAX_ICA_RESPONSE_SIZE 0x77c
57 #define PCIXCC_MAX_XCRB_MESSAGE_SIZE (12*1024)
59 #define PCIXCC_CLEANUP_TIME (15*HZ)
61 #define CEIL4(x) ((((x)+3)/4)*4)
67 #define PCIXCC_RESPONSE_TYPE_ICA 0
68 #define PCIXCC_RESPONSE_TYPE_XCRB 1
80 "Copyright IBM Corp. 2001, 2012");
83 static int zcrypt_pcixcc_probe(
struct ap_device *ap_dev);
84 static void zcrypt_pcixcc_remove(
struct ap_device *ap_dev);
86 static struct ap_driver zcrypt_pcixcc_driver = {
87 .probe = zcrypt_pcixcc_probe,
88 .remove = zcrypt_pcixcc_remove,
89 .ids = zcrypt_pcixcc_ids,
98 static int zcrypt_pcixcc_mcl(
struct ap_device *ap_dev)
100 static unsigned char msg[] = {
101 0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
102 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
103 0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,
104 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
105 0x43,0x41,0x00,0x00,0x00,0x00,0x00,0x00,
106 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
107 0x00,0x00,0x00,0x00,0x50,0x4B,0x00,0x00,
108 0x00,0x00,0x01,0xC4,0x00,0x00,0x00,0x00,
109 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
110 0x00,0x00,0x07,0x24,0x00,0x00,0x00,0x00,
111 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
112 0x00,0xDC,0x02,0x00,0x00,0x00,0x54,0x32,
113 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE8,
114 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x24,
115 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
116 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
117 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
118 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
119 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
120 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
121 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
122 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
123 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
124 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
125 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
126 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
127 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
128 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
129 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
130 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
131 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
132 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
133 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
134 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
135 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
136 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
137 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
138 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
139 0x00,0x00,0x00,0x00,0x50,0x4B,0x00,0x0A,
140 0x4D,0x52,0x50,0x20,0x20,0x20,0x20,0x20,
141 0x00,0x42,0x00,0x01,0x02,0x03,0x04,0x05,
142 0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,
143 0x0E,0x0F,0x00,0x11,0x22,0x33,0x44,0x55,
144 0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,
145 0xEE,0xFF,0xFF,0xEE,0xDD,0xCC,0xBB,0xAA,
146 0x99,0x88,0x77,0x66,0x55,0x44,0x33,0x22,
147 0x11,0x00,0x01,0x23,0x45,0x67,0x89,0xAB,
148 0xCD,0xEF,0xFE,0xDC,0xBA,0x98,0x76,0x54,
149 0x32,0x10,0x00,0x9A,0x00,0x98,0x00,0x00,
150 0x1E,0x00,0x00,0x94,0x00,0x00,0x00,0x00,
151 0x04,0x00,0x00,0x8C,0x00,0x00,0x00,0x40,
152 0x02,0x00,0x00,0x40,0xBA,0xE8,0x23,0x3C,
153 0x75,0xF3,0x91,0x61,0xD6,0x73,0x39,0xCF,
154 0x7B,0x6D,0x8E,0x61,0x97,0x63,0x9E,0xD9,
155 0x60,0x55,0xD6,0xC7,0xEF,0xF8,0x1E,0x63,
156 0x95,0x17,0xCC,0x28,0x45,0x60,0x11,0xC5,
157 0xC4,0x4E,0x66,0xC6,0xE6,0xC3,0xDE,0x8A,
158 0x19,0x30,0xCF,0x0E,0xD7,0xAA,0xDB,0x01,
159 0xD8,0x00,0xBB,0x8F,0x39,0x9F,0x64,0x28,
160 0xF5,0x7A,0x77,0x49,0xCC,0x6B,0xA3,0x91,
161 0x97,0x70,0xE7,0x60,0x1E,0x39,0xE1,0xE5,
162 0x33,0xE1,0x15,0x63,0x69,0x08,0x80,0x4C,
163 0x67,0xC4,0x41,0x8F,0x48,0xDF,0x26,0x98,
164 0xF1,0xD5,0x8D,0x88,0xD9,0x6A,0xA4,0x96,
165 0xC5,0x84,0xD9,0x30,0x49,0x67,0x7D,0x19,
166 0xB1,0xB3,0x45,0x4D,0xB2,0x53,0x9A,0x47,
167 0x3C,0x7C,0x55,0xBF,0xCC,0x85,0x00,0x36,
170 unsigned long long psmid;
179 rc =
ap_send(ap_dev->
qid, 0x0102030405060708ULL, msg,
sizeof(msg));
184 for (i = 0; i < 6; i++) {
186 rc =
ap_recv(ap_dev->
qid, &psmid, reply, 4096);
187 if (rc == 0 && psmid == 0x0102030405060708ULL)
197 cprbx = (
struct CPRBX *) (reply + 48);
214 static int zcrypt_pcixcc_rng_supported(
struct ap_device *ap_dev)
217 unsigned long long psmid;
225 ap_init_message(&ap_msg);
230 rng_type6CPRB_msgX(ap_dev, &ap_msg, 4);
231 rc =
ap_send(ap_dev->
qid, 0x0102030405060708ULL, ap_msg.message,
237 for (i = 0; i < 2 *
HZ; i++) {
239 rc =
ap_recv(ap_dev->
qid, &psmid, ap_msg.message, 4096);
240 if (rc == 0 && psmid == 0x0102030405060708ULL)
250 reply = ap_msg.message;
251 if (reply->cprbx.ccp_rtcode == 0 && reply->cprbx.ccp_rscode == 0)
256 free_page((
unsigned long) ap_msg.message);
267 static int zcrypt_pcixcc_probe(
struct ap_device *ap_dev)
279 rc = zcrypt_pcixcc_mcl(ap_dev);
319 rc = zcrypt_pcixcc_rng_supported(ap_dev);
348 static void zcrypt_pcixcc_remove(
struct ap_device *ap_dev)