1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 #ifndef __HIFN_H__
42 #define __HIFN_H__
43
44 #include <machine/endian.h>
45
46
47
48
49
50 #define HIFN_BAR0 (PCI_MAPREG_START + 0)
51 #define HIFN_BAR1 (PCI_MAPREG_START + 4)
52 #define HIFN_RETRY_TIMEOUT 0x41
53 #define HIFN_TRDY_TIMEOUT 0x40
54
55
56
57
58
59
60
61
62
63
64
65 #define HIFN_MAX_COMMAND (8 + 8 + 8 + 64 + 260)
66 #define HIFN_MAX_RESULT (8 + 4 + 4 + 20 + 4)
67
68
69
70
71
72
73 struct hifn_desc {
74 volatile u_int32_t l;
75 volatile u_int32_t p;
76 };
77
78
79
80
81 #define HIFN_D_LENGTH 0x0000ffff
82 #define HIFN_D_MASKDONEIRQ 0x02000000
83 #define HIFN_D_DESTOVER 0x04000000
84 #define HIFN_D_OVER 0x08000000
85 #define HIFN_D_LAST 0x20000000
86 #define HIFN_D_JUMP 0x40000000
87 #define HIFN_D_VALID 0x80000000
88
89
90
91
92 #define HIFN_0_PUDATA 0x00
93 #define HIFN_0_PUCTRL 0x04
94 #define HIFN_0_PUISR 0x08
95 #define HIFN_0_PUCNFG 0x0c
96 #define HIFN_0_PUIER 0x10
97 #define HIFN_0_PUSTAT 0x14
98 #define HIFN_0_FIFOSTAT 0x18
99 #define HIFN_0_FIFOCNFG 0x1c
100 #define HIFN_0_SPACESIZE 0x20
101
102
103 #define HIFN_PUCTRL_CLRSRCFIFO 0x0010
104 #define HIFN_PUCTRL_STOP 0x0008
105 #define HIFN_PUCTRL_LOCKRAM 0x0004
106 #define HIFN_PUCTRL_DMAENA 0x0002
107 #define HIFN_PUCTRL_RESET 0x0001
108
109
110 #define HIFN_PUISR_CMDINVAL 0x8000
111 #define HIFN_PUISR_DATAERR 0x4000
112 #define HIFN_PUISR_SRCFIFO 0x2000
113 #define HIFN_PUISR_DSTFIFO 0x1000
114 #define HIFN_PUISR_DSTOVER 0x0200
115 #define HIFN_PUISR_SRCCMD 0x0080
116 #define HIFN_PUISR_SRCCTX 0x0040
117 #define HIFN_PUISR_SRCDATA 0x0020
118 #define HIFN_PUISR_DSTDATA 0x0010
119 #define HIFN_PUISR_DSTRESULT 0x0004
120
121
122 #define HIFN_PUCNFG_DRAMMASK 0xe000
123 #define HIFN_PUCNFG_DSZ_256K 0x0000
124 #define HIFN_PUCNFG_DSZ_512K 0x2000
125 #define HIFN_PUCNFG_DSZ_1M 0x4000
126 #define HIFN_PUCNFG_DSZ_2M 0x6000
127 #define HIFN_PUCNFG_DSZ_4M 0x8000
128 #define HIFN_PUCNFG_DSZ_8M 0xa000
129 #define HIFN_PUNCFG_DSZ_16M 0xc000
130 #define HIFN_PUCNFG_DSZ_32M 0xe000
131 #define HIFN_PUCNFG_DRAMREFRESH 0x1800
132 #define HIFN_PUCNFG_DRFR_512 0x0000
133 #define HIFN_PUCNFG_DRFR_256 0x0800
134 #define HIFN_PUCNFG_DRFR_128 0x1000
135 #define HIFN_PUCNFG_TCALLPHASES 0x0200
136 #define HIFN_PUCNFG_TCDRVTOTEM 0x0100
137 #define HIFN_PUCNFG_BIGENDIAN 0x0080
138 #define HIFN_PUCNFG_BUS32 0x0040
139 #define HIFN_PUCNFG_BUS16 0x0000
140 #define HIFN_PUCNFG_CHIPID 0x0020
141 #define HIFN_PUCNFG_DRAM 0x0010
142 #define HIFN_PUCNFG_SRAM 0x0000
143 #define HIFN_PUCNFG_COMPSING 0x0004
144 #define HIFN_PUCNFG_ENCCNFG 0x0002
145
146
147 #define HIFN_PUIER_CMDINVAL 0x8000
148 #define HIFN_PUIER_DATAERR 0x4000
149 #define HIFN_PUIER_SRCFIFO 0x2000
150 #define HIFN_PUIER_DSTFIFO 0x1000
151 #define HIFN_PUIER_DSTOVER 0x0200
152 #define HIFN_PUIER_SRCCMD 0x0080
153 #define HIFN_PUIER_SRCCTX 0x0040
154 #define HIFN_PUIER_SRCDATA 0x0020
155 #define HIFN_PUIER_DSTDATA 0x0010
156 #define HIFN_PUIER_DSTRESULT 0x0004
157
158
159 #define HIFN_PUSTAT_CMDINVAL 0x8000
160 #define HIFN_PUSTAT_DATAERR 0x4000
161 #define HIFN_PUSTAT_SRCFIFO 0x2000
162 #define HIFN_PUSTAT_DSTFIFO 0x1000
163 #define HIFN_PUSTAT_DSTOVER 0x0200
164 #define HIFN_PUSTAT_SRCCMD 0x0080
165 #define HIFN_PUSTAT_SRCCTX 0x0040
166 #define HIFN_PUSTAT_SRCDATA 0x0020
167 #define HIFN_PUSTAT_DSTDATA 0x0010
168 #define HIFN_PUSTAT_DSTRESULT 0x0004
169 #define HIFN_PUSTAT_CHIPREV 0x00ff
170 #define HIFN_PUSTAT_CHIPENA 0xff00
171 #define HIFN_PUSTAT_ENA_2 0x1100
172 #define HIFN_PUSTAT_ENA_1 0x1000
173 #define HIFN_PUSTAT_ENA_0 0x3000
174 #define HIFN_PUSTAT_REV_2 0x0020
175 #define HIFN_PUSTAT_REV_3 0x0030
176
177
178 #define HIFN_FIFOSTAT_SRC 0x7f00
179 #define HIFN_FIFOSTAT_DST 0x007f
180
181
182 #define HIFN_FIFOCNFG_THRESHOLD 0x0400
183
184
185
186
187 #define HIFN_1_DMA_CRAR 0x0c
188 #define HIFN_1_DMA_SRAR 0x1c
189 #define HIFN_1_DMA_RRAR 0x2c
190 #define HIFN_1_DMA_DRAR 0x3c
191 #define HIFN_1_DMA_CSR 0x40
192 #define HIFN_1_DMA_IER 0x44
193 #define HIFN_1_DMA_CNFG 0x48
194 #define HIFN_1_PLL 0x4c
195 #define HIFN_1_7811_RNGENA 0x60
196 #define HIFN_1_7811_RNGCFG 0x64
197 #define HIFN_1_7811_RNGDAT 0x68
198 #define HIFN_1_7811_RNGSTS 0x6c
199 #define HIFN_1_7811_MIPSRST 0x94
200 #define HIFN_1_REVID 0x98
201 #define HIFN_1_UNLOCK_SECRET1 0xf4
202 #define HIFN_1_UNLOCK_SECRET2 0xfc
203 #define HIFN_1_PUB_RESET 0x204
204 #define HIFN_1_PUB_BASE 0x300
205 #define HIFN_1_PUB_OPLEN 0x304
206 #define HIFN_1_PUB_OP 0x308
207 #define HIFN_1_PUB_STATUS 0x30c
208 #define HIFN_1_PUB_IEN 0x310
209 #define HIFN_1_RNG_CONFIG 0x314
210 #define HIFN_1_RNG_DATA 0x318
211 #define HIFN_1_PUB_MEM 0x400
212 #define HIFN_1_PUB_MEMEND 0xbff
213
214
215 #define HIFN_DMACSR_D_CTRLMASK 0xc0000000
216 #define HIFN_DMACSR_D_CTRL_NOP 0x00000000
217 #define HIFN_DMACSR_D_CTRL_DIS 0x40000000
218 #define HIFN_DMACSR_D_CTRL_ENA 0x80000000
219 #define HIFN_DMACSR_D_ABORT 0x20000000
220 #define HIFN_DMACSR_D_DONE 0x10000000
221 #define HIFN_DMACSR_D_LAST 0x08000000
222 #define HIFN_DMACSR_D_WAIT 0x04000000
223 #define HIFN_DMACSR_D_OVER 0x02000000
224 #define HIFN_DMACSR_R_CTRL 0x00c00000
225 #define HIFN_DMACSR_R_CTRL_NOP 0x00000000
226 #define HIFN_DMACSR_R_CTRL_DIS 0x00400000
227 #define HIFN_DMACSR_R_CTRL_ENA 0x00800000
228 #define HIFN_DMACSR_R_ABORT 0x00200000
229 #define HIFN_DMACSR_R_DONE 0x00100000
230 #define HIFN_DMACSR_R_LAST 0x00080000
231 #define HIFN_DMACSR_R_WAIT 0x00040000
232 #define HIFN_DMACSR_R_OVER 0x00020000
233 #define HIFN_DMACSR_S_CTRL 0x0000c000
234 #define HIFN_DMACSR_S_CTRL_NOP 0x00000000
235 #define HIFN_DMACSR_S_CTRL_DIS 0x00004000
236 #define HIFN_DMACSR_S_CTRL_ENA 0x00008000
237 #define HIFN_DMACSR_S_ABORT 0x00002000
238 #define HIFN_DMACSR_S_DONE 0x00001000
239 #define HIFN_DMACSR_S_LAST 0x00000800
240 #define HIFN_DMACSR_S_WAIT 0x00000400
241 #define HIFN_DMACSR_ILLW 0x00000200
242 #define HIFN_DMACSR_ILLR 0x00000100
243 #define HIFN_DMACSR_C_CTRL 0x000000c0
244 #define HIFN_DMACSR_C_CTRL_NOP 0x00000000
245 #define HIFN_DMACSR_C_CTRL_DIS 0x00000040
246 #define HIFN_DMACSR_C_CTRL_ENA 0x00000080
247 #define HIFN_DMACSR_C_ABORT 0x00000020
248 #define HIFN_DMACSR_C_DONE 0x00000010
249 #define HIFN_DMACSR_C_LAST 0x00000008
250 #define HIFN_DMACSR_C_WAIT 0x00000004
251 #define HIFN_DMACSR_PUBDONE 0x00000002
252 #define HIFN_DMACSR_ENGINE 0x00000001
253
254
255 #define HIFN_DMAIER_D_ABORT 0x20000000
256 #define HIFN_DMAIER_D_DONE 0x10000000
257 #define HIFN_DMAIER_D_LAST 0x08000000
258 #define HIFN_DMAIER_D_WAIT 0x04000000
259 #define HIFN_DMAIER_D_OVER 0x02000000
260 #define HIFN_DMAIER_R_ABORT 0x00200000
261 #define HIFN_DMAIER_R_DONE 0x00100000
262 #define HIFN_DMAIER_R_LAST 0x00080000
263 #define HIFN_DMAIER_R_WAIT 0x00040000
264 #define HIFN_DMAIER_R_OVER 0x00020000
265 #define HIFN_DMAIER_S_ABORT 0x00002000
266 #define HIFN_DMAIER_S_DONE 0x00001000
267 #define HIFN_DMAIER_S_LAST 0x00000800
268 #define HIFN_DMAIER_S_WAIT 0x00000400
269 #define HIFN_DMAIER_ILLW 0x00000200
270 #define HIFN_DMAIER_ILLR 0x00000100
271 #define HIFN_DMAIER_C_ABORT 0x00000020
272 #define HIFN_DMAIER_C_DONE 0x00000010
273 #define HIFN_DMAIER_C_LAST 0x00000008
274 #define HIFN_DMAIER_C_WAIT 0x00000004
275 #define HIFN_DMAIER_PUBDONE 0x00000002
276 #define HIFN_DMAIER_ENGINE 0x00000001
277
278
279 #define HIFN_DMACNFG_BIGENDIAN 0x10000000
280 #define HIFN_DMACNFG_POLLFREQ 0x00ff0000
281 #define HIFN_DMACNFG_UNLOCK 0x00000800
282 #define HIFN_DMACNFG_POLLINVAL 0x00000700
283 #define HIFN_DMACNFG_LAST 0x00000010
284 #define HIFN_DMACNFG_MODE 0x00000004
285 #define HIFN_DMACNFG_DMARESET 0x00000002
286 #define HIFN_DMACNFG_MSTRESET 0x00000001
287
288
289 #define HIFN_7811_RNGENA_ENA 0x00000001
290
291
292 #define HIFN_7811_RNGCFG_PRE1 0x00000f00
293 #define HIFN_7811_RNGCFG_OPRE 0x00000080
294 #define HIFN_7811_RNGCFG_DEFL 0x00000f80
295
296
297 #define HIFN_7811_RNGSTS_RDY 0x00004000
298 #define HIFN_7811_RNGSTS_UFL 0x00001000
299
300
301 #define HIFN_MIPSRST_BAR2SIZE 0xffff0000
302 #define HIFN_MIPSRST_GPRAMINIT 0x00008000
303 #define HIFN_MIPSRST_CRAMINIT 0x00004000
304 #define HIFN_MIPSRST_LED2 0x00000400
305 #define HIFN_MIPSRST_LED1 0x00000200
306 #define HIFN_MIPSRST_LED0 0x00000100
307 #define HIFN_MIPSRST_MIPSDIS 0x00000004
308 #define HIFN_MIPSRST_MIPSRST 0x00000002
309 #define HIFN_MIPSRST_MIPSCOLD 0x00000001
310
311
312 #define HIFN_PLL_7956 0x00001d18
313
314
315 #define HIFN_REVID_7811_PB3_2 0x00000002
316
317
318 #define HIFN_PUBRST_RESET 0x00000001
319
320
321 #define HIFN_PUBBASE_ADDR 0x00003fff
322
323
324 #define HIFN_PUBOPLEN_MOD_M 0x0000007f
325 #define HIFN_PUBOPLEN_MOD_S 0
326 #define HIFN_PUBOPLEN_EXP_M 0x0003ff80
327 #define HIFN_PUBOPLEN_EXP_S 7
328 #define HIFN_PUBOPLEN_RED_M 0x003c0000
329 #define HIFN_PUBOPLEN_RED_S 18
330
331
332 #define HIFN_PUBOP_AOFFSET_M 0x0000007f
333 #define HIFN_PUBOP_AOFFSET_S 0
334 #define HIFN_PUBOP_BOFFSET_M 0x00000f80
335 #define HIFN_PUBOP_BOFFSET_S 7
336 #define HIFN_PUBOP_MOFFSET_M 0x0003f000
337 #define HIFN_PUBOP_MOFFSET_S 12
338 #define HIFN_PUBOP_OP_MASK 0x003c0000
339 #define HIFN_PUBOP_OP_NOP 0x00000000
340 #define HIFN_PUBOP_OP_ADD 0x00040000
341 #define HIFN_PUBOP_OP_ADDC 0x00080000
342 #define HIFN_PUBOP_OP_SUB 0x000c0000
343 #define HIFN_PUBOP_OP_SUBC 0x00100000
344 #define HIFN_PUBOP_OP_MODADD 0x00140000
345 #define HIFN_PUBOP_OP_MODSUB 0x00180000
346 #define HIFN_PUBOP_OP_INCA 0x001c0000
347 #define HIFN_PUBOP_OP_DECA 0x00200000
348 #define HIFN_PUBOP_OP_MULT 0x00240000
349 #define HIFN_PUBOP_OP_MODMULT 0x00280000
350 #define HIFN_PUBOP_OP_MODRED 0x002c0000
351 #define HIFN_PUBOP_OP_MODEXP 0x00300000
352
353
354 #define HIFN_PUBSTS_DONE 0x00000001
355 #define HIFN_PUBSTS_CARRY 0x00000002
356
357
358 #define HIFN_PUBIEN_DONE 0x00000001
359
360
361 #define HIFN_RNGCFG_ENA 0x00000001
362
363
364
365
366
367
368
369
370
371 struct hifn_base_command {
372 volatile u_int16_t masks;
373 volatile u_int16_t session_num;
374 volatile u_int16_t total_source_count;
375 volatile u_int16_t total_dest_count;
376 };
377
378 #define HIFN_BASE_CMD_COMP 0x0100
379 #define HIFN_BASE_CMD_PAD 0x0200
380 #define HIFN_BASE_CMD_MAC 0x0400
381 #define HIFN_BASE_CMD_CRYPT 0x0800
382 #define HIFN_BASE_CMD_DECODE 0x2000
383 #define HIFN_BASE_CMD_SRCLEN_M 0xc000
384 #define HIFN_BASE_CMD_SRCLEN_S 14
385 #define HIFN_BASE_CMD_DSTLEN_M 0x3000
386 #define HIFN_BASE_CMD_DSTLEN_S 12
387 #define HIFN_BASE_CMD_LENMASK_HI 0x30000
388 #define HIFN_BASE_CMD_LENMASK_LO 0x0ffff
389
390
391
392
393 struct hifn_crypt_command {
394 volatile u_int16_t masks;
395 volatile u_int16_t header_skip;
396 volatile u_int16_t source_count;
397 volatile u_int16_t reserved;
398 };
399
400 #define HIFN_CRYPT_CMD_ALG_MASK 0x0003
401 #define HIFN_CRYPT_CMD_ALG_DES 0x0000
402 #define HIFN_CRYPT_CMD_ALG_3DES 0x0001
403 #define HIFN_CRYPT_CMD_ALG_RC4 0x0002
404 #define HIFN_CRYPT_CMD_ALG_AES 0x0003
405 #define HIFN_CRYPT_CMD_MODE_MASK 0x0018
406 #define HIFN_CRYPT_CMD_MODE_ECB 0x0000
407 #define HIFN_CRYPT_CMD_MODE_CBC 0x0008
408 #define HIFN_CRYPT_CMD_MODE_CFB 0x0010
409 #define HIFN_CRYPT_CMD_MODE_OFB 0x0018
410 #define HIFN_CRYPT_CMD_CLR_CTX 0x0040
411 #define HIFN_CRYPT_CMD_KSZ_MASK 0x0600
412 #define HIFN_CRYPT_CMD_KSZ_128 0x0000
413 #define HIFN_CRYPT_CMD_KSZ_192 0x0200
414 #define HIFN_CRYPT_CMD_KSZ_256 0x0400
415 #define HIFN_CRYPT_CMD_NEW_KEY 0x0800
416 #define HIFN_CRYPT_CMD_NEW_IV 0x1000
417 #define HIFN_CRYPT_CMD_SRCLEN_M 0xc000
418 #define HIFN_CRYPT_CMD_SRCLEN_S 14
419
420
421
422
423 struct hifn_mac_command {
424 volatile u_int16_t masks;
425 volatile u_int16_t header_skip;
426 volatile u_int16_t source_count;
427 volatile u_int16_t reserved;
428 };
429
430 #define HIFN_MAC_CMD_ALG_MASK 0x0001
431 #define HIFN_MAC_CMD_ALG_SHA1 0x0000
432 #define HIFN_MAC_CMD_ALG_MD5 0x0001
433 #define HIFN_MAC_CMD_MODE_MASK 0x000c
434 #define HIFN_MAC_CMD_MODE_HMAC 0x0000
435 #define HIFN_MAC_CMD_MODE_SSL_MAC 0x0004
436 #define HIFN_MAC_CMD_MODE_HASH 0x0008
437 #define HIFN_MAC_CMD_MODE_FULL 0x0004
438 #define HIFN_MAC_CMD_TRUNC 0x0010
439 #define HIFN_MAC_CMD_RESULT 0x0020
440 #define HIFN_MAC_CMD_APPEND 0x0040
441 #define HIFN_MAC_CMD_SRCLEN_M 0xc000
442 #define HIFN_MAC_CMD_SRCLEN_S 14
443
444
445
446
447
448 #define HIFN_MAC_CMD_POS_IPSEC 0x0200
449 #define HIFN_MAC_CMD_NEW_KEY 0x0800
450
451 struct hifn_comp_command {
452 volatile u_int16_t masks;
453 volatile u_int16_t header_skip;
454 volatile u_int16_t source_count;
455 volatile u_int16_t reserved;
456 };
457
458 #define HIFN_COMP_CMD_SRCLEN_M 0xc000
459 #define HIFN_COMP_CMD_SRCLEN_S 14
460 #define HIFN_COMP_CMD_ONE 0x0100
461 #define HIFN_COMP_CMD_CLEARHIST 0x0010
462 #define HIFN_COMP_CMD_UPDATEHIST 0x0008
463 #define HIFN_COMP_CMD_LZS_STRIP0 0x0004
464 #define HIFN_COMP_CMD_MPPC_RESTART 0x0004
465 #define HIFN_COMP_CMD_ALG_MASK 0x0001
466 #define HIFN_COMP_CMD_ALG_MPPC 0x0001
467 #define HIFN_COMP_CMD_ALG_LZS 0x0000
468
469 struct hifn_base_result {
470 volatile u_int16_t flags;
471 volatile u_int16_t session;
472 volatile u_int16_t src_cnt;
473 volatile u_int16_t dst_cnt;
474 };
475
476 #define HIFN_BASE_RES_DSTOVERRUN 0x0200
477 #define HIFN_BASE_RES_SRCLEN_M 0xc000
478 #define HIFN_BASE_RES_SRCLEN_S 14
479 #define HIFN_BASE_RES_DSTLEN_M 0x3000
480 #define HIFN_BASE_RES_DSTLEN_S 12
481
482 struct hifn_comp_result {
483 volatile u_int16_t flags;
484 volatile u_int16_t crc;
485 };
486
487 #define HIFN_COMP_RES_LCB_M 0xff00
488 #define HIFN_COMP_RES_LCB_S 8
489 #define HIFN_COMP_RES_RESTART 0x0004
490 #define HIFN_COMP_RES_ENDMARKER 0x0002
491 #define HIFN_COMP_RES_SRC_NOTZERO 0x0001
492
493 struct hifn_mac_result {
494 volatile u_int16_t flags;
495 volatile u_int16_t reserved;
496
497 };
498
499 #define HIFN_MAC_RES_MISCOMPARE 0x0002
500 #define HIFN_MAC_RES_SRC_NOTZERO 0x0001
501
502 struct hifn_crypt_result {
503 volatile u_int16_t flags;
504 volatile u_int16_t reserved;
505 };
506
507 #define HIFN_CRYPT_RES_SRC_NOTZERO 0x0001
508
509
510
511
512
513 #ifndef HIFN_POLL_FREQUENCY
514 #define HIFN_POLL_FREQUENCY 0x1
515 #endif
516
517 #ifndef HIFN_POLL_SCALAR
518 #define HIFN_POLL_SCALAR 0x0
519 #endif
520
521 #define HIFN_MAX_SEGLEN 0xffff
522 #define HIFN_MAX_DMALEN 0x3ffff
523 #endif