xref: /dflybsd-src/sys/dev/crypto/hifn/hifn7751reg.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /* $FreeBSD: src/sys/dev/hifn/hifn7751reg.h,v 1.1.2.1 2002/11/21 23:37:11 sam Exp $ */
286d7f5d3SJohn Marino /* $DragonFly: src/sys/dev/crypto/hifn/hifn7751reg.h,v 1.3 2007/12/04 09:11:12 hasso Exp $ */
386d7f5d3SJohn Marino /*	$OpenBSD: hifn7751reg.h,v 1.35 2002/04/08 17:49:42 jason Exp $	*/
486d7f5d3SJohn Marino 
586d7f5d3SJohn Marino /*-
686d7f5d3SJohn Marino  * Invertex AEON / Hifn 7751 driver
786d7f5d3SJohn Marino  * Copyright (c) 1999 Invertex Inc. All rights reserved.
886d7f5d3SJohn Marino  * Copyright (c) 1999 Theo de Raadt
986d7f5d3SJohn Marino  * Copyright (c) 2000-2001 Network Security Technologies, Inc.
1086d7f5d3SJohn Marino  *			http://www.netsec.net
1186d7f5d3SJohn Marino  *
1286d7f5d3SJohn Marino  * Please send any comments, feedback, bug-fixes, or feature requests to
1386d7f5d3SJohn Marino  * software@invertex.com.
1486d7f5d3SJohn Marino  *
1586d7f5d3SJohn Marino  * Redistribution and use in source and binary forms, with or without
1686d7f5d3SJohn Marino  * modification, are permitted provided that the following conditions
1786d7f5d3SJohn Marino  * are met:
1886d7f5d3SJohn Marino  *
1986d7f5d3SJohn Marino  * 1. Redistributions of source code must retain the above copyright
2086d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer.
2186d7f5d3SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
2286d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
2386d7f5d3SJohn Marino  *    documentation and/or other materials provided with the distribution.
2486d7f5d3SJohn Marino  * 3. The name of the author may not be used to endorse or promote products
2586d7f5d3SJohn Marino  *    derived from this software without specific prior written permission.
2686d7f5d3SJohn Marino  *
2786d7f5d3SJohn Marino  *
2886d7f5d3SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2986d7f5d3SJohn Marino  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
3086d7f5d3SJohn Marino  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
3186d7f5d3SJohn Marino  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
3286d7f5d3SJohn Marino  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
3386d7f5d3SJohn Marino  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3486d7f5d3SJohn Marino  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3586d7f5d3SJohn Marino  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3686d7f5d3SJohn Marino  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3786d7f5d3SJohn Marino  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3886d7f5d3SJohn Marino  *
3986d7f5d3SJohn Marino  * Effort sponsored in part by the Defense Advanced Research Projects
4086d7f5d3SJohn Marino  * Agency (DARPA) and Air Force Research Laboratory, Air Force
4186d7f5d3SJohn Marino  * Materiel Command, USAF, under agreement number F30602-01-2-0537.
4286d7f5d3SJohn Marino  *
4386d7f5d3SJohn Marino  */
4486d7f5d3SJohn Marino #ifndef __HIFN_H__
4586d7f5d3SJohn Marino #define	__HIFN_H__
4686d7f5d3SJohn Marino 
4786d7f5d3SJohn Marino #include <sys/endian.h>
4886d7f5d3SJohn Marino 
4986d7f5d3SJohn Marino /*
5086d7f5d3SJohn Marino  * Some PCI configuration space offset defines.  The names were made
5186d7f5d3SJohn Marino  * identical to the names used by the Linux kernel.
5286d7f5d3SJohn Marino  */
5386d7f5d3SJohn Marino #ifdef notyet
5486d7f5d3SJohn Marino #define	HIFN_BAR0		(PCIR_MAPS+0x0)	/* PUC register map */
5586d7f5d3SJohn Marino #define	HIFN_BAR1		(PCIR_MAPS+0x4)	/* DMA register map */
5686d7f5d3SJohn Marino #else
5786d7f5d3SJohn Marino #define	HIFN_BAR0		PCIR_BAR(0)	/* PUC register map */
5886d7f5d3SJohn Marino #define	HIFN_BAR1		PCIR_BAR(1)	/* DMA register map */
5986d7f5d3SJohn Marino #endif
6086d7f5d3SJohn Marino #define	HIFN_TRDY_TIMEOUT	0x40
6186d7f5d3SJohn Marino #define	HIFN_RETRY_TIMEOUT	0x41
6286d7f5d3SJohn Marino 
6386d7f5d3SJohn Marino /*
6486d7f5d3SJohn Marino  * PCI vendor and device identifiers
6586d7f5d3SJohn Marino  * (the names are preserved from their OpenBSD source).
6686d7f5d3SJohn Marino  */
6786d7f5d3SJohn Marino #define	PCI_VENDOR_HIFN		0x13a3		/* Hifn */
6886d7f5d3SJohn Marino #define	PCI_PRODUCT_HIFN_7751	0x0005		/* 7751 */
6986d7f5d3SJohn Marino #define	PCI_PRODUCT_HIFN_6500	0x0006		/* 6500 */
7086d7f5d3SJohn Marino #define	PCI_PRODUCT_HIFN_7811	0x0007		/* 7811 */
7186d7f5d3SJohn Marino #define	PCI_PRODUCT_HIFN_7951	0x0012		/* 7951 */
7286d7f5d3SJohn Marino #define	PCI_PRODUCT_HIFN_7955	0x0020		/* 7954/7955 */
7386d7f5d3SJohn Marino #define	PCI_PRODUCT_HIFN_7956	0x001d		/* 7956 */
7486d7f5d3SJohn Marino 
7586d7f5d3SJohn Marino #define	PCI_VENDOR_INVERTEX	0x14e1		/* Invertex */
7686d7f5d3SJohn Marino #define	PCI_PRODUCT_INVERTEX_AEON 0x0005	/* AEON */
7786d7f5d3SJohn Marino 
7886d7f5d3SJohn Marino #define	PCI_VENDOR_NETSEC	0x1660		/* NetSec */
7986d7f5d3SJohn Marino #define	PCI_PRODUCT_NETSEC_7751	0x7751		/* 7751 */
8086d7f5d3SJohn Marino 
8186d7f5d3SJohn Marino /*
8286d7f5d3SJohn Marino  * The values below should multiple of 4 -- and be large enough to handle
8386d7f5d3SJohn Marino  * any command the driver implements.
8486d7f5d3SJohn Marino  *
8586d7f5d3SJohn Marino  * MAX_COMMAND = base command + mac command + encrypt command +
8686d7f5d3SJohn Marino  *			mac-key + rc4-key
8786d7f5d3SJohn Marino  * MAX_RESULT  = base result + mac result + mac + encrypt result
8886d7f5d3SJohn Marino  *
8986d7f5d3SJohn Marino  *
9086d7f5d3SJohn Marino  */
9186d7f5d3SJohn Marino #define	HIFN_MAX_COMMAND	(8 + 8 + 8 + 64 + 260)
9286d7f5d3SJohn Marino #define	HIFN_MAX_RESULT		(8 + 4 + 20 + 4)
9386d7f5d3SJohn Marino 
9486d7f5d3SJohn Marino /*
9586d7f5d3SJohn Marino  * hifn_desc_t
9686d7f5d3SJohn Marino  *
9786d7f5d3SJohn Marino  * Holds an individual descriptor for any of the rings.
9886d7f5d3SJohn Marino  */
9986d7f5d3SJohn Marino typedef struct hifn_desc {
10086d7f5d3SJohn Marino 	volatile u_int32_t l;		/* length and status bits */
10186d7f5d3SJohn Marino 	volatile u_int32_t p;
10286d7f5d3SJohn Marino } hifn_desc_t;
10386d7f5d3SJohn Marino 
10486d7f5d3SJohn Marino /*
10586d7f5d3SJohn Marino  * Masks for the "length" field of struct hifn_desc.
10686d7f5d3SJohn Marino  */
10786d7f5d3SJohn Marino #define	HIFN_D_LENGTH		0x0000ffff	/* length bit mask */
10886d7f5d3SJohn Marino #define	HIFN_D_MASKDONEIRQ	0x02000000	/* mask the done interrupt */
10986d7f5d3SJohn Marino #define	HIFN_D_DESTOVER		0x04000000	/* destination overflow */
11086d7f5d3SJohn Marino #define	HIFN_D_OVER		0x08000000	/* overflow */
11186d7f5d3SJohn Marino #define	HIFN_D_LAST		0x20000000	/* last descriptor in chain */
11286d7f5d3SJohn Marino #define	HIFN_D_JUMP		0x40000000	/* jump descriptor */
11386d7f5d3SJohn Marino #define	HIFN_D_VALID		0x80000000	/* valid bit */
11486d7f5d3SJohn Marino 
11586d7f5d3SJohn Marino 
11686d7f5d3SJohn Marino /*
11786d7f5d3SJohn Marino  * Processing Unit Registers (offset from BASEREG0)
11886d7f5d3SJohn Marino  */
11986d7f5d3SJohn Marino #define	HIFN_0_PUDATA		0x00	/* Processing Unit Data */
12086d7f5d3SJohn Marino #define	HIFN_0_PUCTRL		0x04	/* Processing Unit Control */
12186d7f5d3SJohn Marino #define	HIFN_0_PUISR		0x08	/* Processing Unit Interrupt Status */
12286d7f5d3SJohn Marino #define	HIFN_0_PUCNFG		0x0c	/* Processing Unit Configuration */
12386d7f5d3SJohn Marino #define	HIFN_0_PUIER		0x10	/* Processing Unit Interrupt Enable */
12486d7f5d3SJohn Marino #define	HIFN_0_PUSTAT		0x14	/* Processing Unit Status/Chip ID */
12586d7f5d3SJohn Marino #define	HIFN_0_FIFOSTAT		0x18	/* FIFO Status */
12686d7f5d3SJohn Marino #define	HIFN_0_FIFOCNFG		0x1c	/* FIFO Configuration */
12786d7f5d3SJohn Marino #define	HIFN_0_PUCTRL2		0x28	/* Processing Unit Control (2nd map) */
12886d7f5d3SJohn Marino #define	HIFN_0_SPACESIZE	0x20	/* Register space size */
12986d7f5d3SJohn Marino 
13086d7f5d3SJohn Marino /* Processing Unit Control Register (HIFN_0_PUCTRL) */
13186d7f5d3SJohn Marino #define	HIFN_PUCTRL_CLRSRCFIFO	0x0010	/* clear source fifo */
13286d7f5d3SJohn Marino #define	HIFN_PUCTRL_STOP	0x0008	/* stop pu */
13386d7f5d3SJohn Marino #define	HIFN_PUCTRL_LOCKRAM	0x0004	/* lock ram */
13486d7f5d3SJohn Marino #define	HIFN_PUCTRL_DMAENA	0x0002	/* enable dma */
13586d7f5d3SJohn Marino #define	HIFN_PUCTRL_RESET	0x0001	/* Reset processing unit */
13686d7f5d3SJohn Marino 
13786d7f5d3SJohn Marino /* Processing Unit Interrupt Status Register (HIFN_0_PUISR) */
13886d7f5d3SJohn Marino #define	HIFN_PUISR_CMDINVAL	0x8000	/* Invalid command interrupt */
13986d7f5d3SJohn Marino #define	HIFN_PUISR_DATAERR	0x4000	/* Data error interrupt */
14086d7f5d3SJohn Marino #define	HIFN_PUISR_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
14186d7f5d3SJohn Marino #define	HIFN_PUISR_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
14286d7f5d3SJohn Marino #define	HIFN_PUISR_DSTOVER	0x0200	/* Destination overrun interrupt */
14386d7f5d3SJohn Marino #define	HIFN_PUISR_SRCCMD	0x0080	/* Source command interrupt */
14486d7f5d3SJohn Marino #define	HIFN_PUISR_SRCCTX	0x0040	/* Source context interrupt */
14586d7f5d3SJohn Marino #define	HIFN_PUISR_SRCDATA	0x0020	/* Source data interrupt */
14686d7f5d3SJohn Marino #define	HIFN_PUISR_DSTDATA	0x0010	/* Destination data interrupt */
14786d7f5d3SJohn Marino #define	HIFN_PUISR_DSTRESULT	0x0004	/* Destination result interrupt */
14886d7f5d3SJohn Marino 
14986d7f5d3SJohn Marino /* Processing Unit Configuration Register (HIFN_0_PUCNFG) */
15086d7f5d3SJohn Marino #define	HIFN_PUCNFG_DRAMMASK	0xe000	/* DRAM size mask */
15186d7f5d3SJohn Marino #define	HIFN_PUCNFG_DSZ_256K	0x0000	/* 256k dram */
15286d7f5d3SJohn Marino #define	HIFN_PUCNFG_DSZ_512K	0x2000	/* 512k dram */
15386d7f5d3SJohn Marino #define	HIFN_PUCNFG_DSZ_1M	0x4000	/* 1m dram */
15486d7f5d3SJohn Marino #define	HIFN_PUCNFG_DSZ_2M	0x6000	/* 2m dram */
15586d7f5d3SJohn Marino #define	HIFN_PUCNFG_DSZ_4M	0x8000	/* 4m dram */
15686d7f5d3SJohn Marino #define	HIFN_PUCNFG_DSZ_8M	0xa000	/* 8m dram */
15786d7f5d3SJohn Marino #define	HIFN_PUNCFG_DSZ_16M	0xc000	/* 16m dram */
15886d7f5d3SJohn Marino #define	HIFN_PUCNFG_DSZ_32M	0xe000	/* 32m dram */
15986d7f5d3SJohn Marino #define	HIFN_PUCNFG_DRAMREFRESH	0x1800	/* DRAM refresh rate mask */
16086d7f5d3SJohn Marino #define	HIFN_PUCNFG_DRFR_512	0x0000	/* 512 divisor of ECLK */
16186d7f5d3SJohn Marino #define	HIFN_PUCNFG_DRFR_256	0x0800	/* 256 divisor of ECLK */
16286d7f5d3SJohn Marino #define	HIFN_PUCNFG_DRFR_128	0x1000	/* 128 divisor of ECLK */
16386d7f5d3SJohn Marino #define	HIFN_PUCNFG_TCALLPHASES	0x0200	/* your guess is as good as mine... */
16486d7f5d3SJohn Marino #define	HIFN_PUCNFG_TCDRVTOTEM	0x0100	/* your guess is as good as mine... */
16586d7f5d3SJohn Marino #define	HIFN_PUCNFG_BIGENDIAN	0x0080	/* DMA big endian mode */
16686d7f5d3SJohn Marino #define	HIFN_PUCNFG_BUS32	0x0040	/* Bus width 32bits */
16786d7f5d3SJohn Marino #define	HIFN_PUCNFG_BUS16	0x0000	/* Bus width 16 bits */
16886d7f5d3SJohn Marino #define	HIFN_PUCNFG_CHIPID	0x0020	/* Allow chipid from PUSTAT */
16986d7f5d3SJohn Marino #define	HIFN_PUCNFG_DRAM	0x0010	/* Context RAM is DRAM */
17086d7f5d3SJohn Marino #define	HIFN_PUCNFG_SRAM	0x0000	/* Context RAM is SRAM */
17186d7f5d3SJohn Marino #define	HIFN_PUCNFG_COMPSING	0x0004	/* Enable single compression context */
17286d7f5d3SJohn Marino #define	HIFN_PUCNFG_ENCCNFG	0x0002	/* Encryption configuration */
17386d7f5d3SJohn Marino 
17486d7f5d3SJohn Marino /* Processing Unit Interrupt Enable Register (HIFN_0_PUIER) */
17586d7f5d3SJohn Marino #define	HIFN_PUIER_CMDINVAL	0x8000	/* Invalid command interrupt */
17686d7f5d3SJohn Marino #define	HIFN_PUIER_DATAERR	0x4000	/* Data error interrupt */
17786d7f5d3SJohn Marino #define	HIFN_PUIER_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
17886d7f5d3SJohn Marino #define	HIFN_PUIER_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
17986d7f5d3SJohn Marino #define	HIFN_PUIER_DSTOVER	0x0200	/* Destination overrun interrupt */
18086d7f5d3SJohn Marino #define	HIFN_PUIER_SRCCMD	0x0080	/* Source command interrupt */
18186d7f5d3SJohn Marino #define	HIFN_PUIER_SRCCTX	0x0040	/* Source context interrupt */
18286d7f5d3SJohn Marino #define	HIFN_PUIER_SRCDATA	0x0020	/* Source data interrupt */
18386d7f5d3SJohn Marino #define	HIFN_PUIER_DSTDATA	0x0010	/* Destination data interrupt */
18486d7f5d3SJohn Marino #define	HIFN_PUIER_DSTRESULT	0x0004	/* Destination result interrupt */
18586d7f5d3SJohn Marino 
18686d7f5d3SJohn Marino /* Processing Unit Status Register/Chip ID (HIFN_0_PUSTAT) */
18786d7f5d3SJohn Marino #define	HIFN_PUSTAT_CMDINVAL	0x8000	/* Invalid command interrupt */
18886d7f5d3SJohn Marino #define	HIFN_PUSTAT_DATAERR	0x4000	/* Data error interrupt */
18986d7f5d3SJohn Marino #define	HIFN_PUSTAT_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
19086d7f5d3SJohn Marino #define	HIFN_PUSTAT_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
19186d7f5d3SJohn Marino #define	HIFN_PUSTAT_DSTOVER	0x0200	/* Destination overrun interrupt */
19286d7f5d3SJohn Marino #define	HIFN_PUSTAT_SRCCMD	0x0080	/* Source command interrupt */
19386d7f5d3SJohn Marino #define	HIFN_PUSTAT_SRCCTX	0x0040	/* Source context interrupt */
19486d7f5d3SJohn Marino #define	HIFN_PUSTAT_SRCDATA	0x0020	/* Source data interrupt */
19586d7f5d3SJohn Marino #define	HIFN_PUSTAT_DSTDATA	0x0010	/* Destination data interrupt */
19686d7f5d3SJohn Marino #define	HIFN_PUSTAT_DSTRESULT	0x0004	/* Destination result interrupt */
19786d7f5d3SJohn Marino #define	HIFN_PUSTAT_CHIPREV	0x00ff	/* Chip revision mask */
19886d7f5d3SJohn Marino #define	HIFN_PUSTAT_CHIPENA	0xff00	/* Chip enabled mask */
19986d7f5d3SJohn Marino #define	HIFN_PUSTAT_ENA_2	0x1100	/* Level 2 enabled */
20086d7f5d3SJohn Marino #define	HIFN_PUSTAT_ENA_1	0x1000	/* Level 1 enabled */
20186d7f5d3SJohn Marino #define	HIFN_PUSTAT_ENA_0	0x3000	/* Level 0 enabled */
20286d7f5d3SJohn Marino #define	HIFN_PUSTAT_REV_2	0x0020	/* 7751 PT6/2 */
20386d7f5d3SJohn Marino #define	HIFN_PUSTAT_REV_3	0x0030	/* 7751 PT6/3 */
20486d7f5d3SJohn Marino 
20586d7f5d3SJohn Marino /* FIFO Status Register (HIFN_0_FIFOSTAT) */
20686d7f5d3SJohn Marino #define	HIFN_FIFOSTAT_SRC	0x7f00	/* Source FIFO available */
20786d7f5d3SJohn Marino #define	HIFN_FIFOSTAT_DST	0x007f	/* Destination FIFO available */
20886d7f5d3SJohn Marino 
20986d7f5d3SJohn Marino /* FIFO Configuration Register (HIFN_0_FIFOCNFG) */
21086d7f5d3SJohn Marino #define	HIFN_FIFOCNFG_THRESHOLD	0x0400	/* must be written as 1 */
21186d7f5d3SJohn Marino 
21286d7f5d3SJohn Marino /*
21386d7f5d3SJohn Marino  * DMA Interface Registers (offset from BASEREG1)
21486d7f5d3SJohn Marino  */
21586d7f5d3SJohn Marino #define	HIFN_1_DMA_CRAR		0x0c	/* DMA Command Ring Address */
21686d7f5d3SJohn Marino #define	HIFN_1_DMA_SRAR		0x1c	/* DMA Source Ring Address */
21786d7f5d3SJohn Marino #define	HIFN_1_DMA_RRAR		0x2c	/* DMA Result Ring Address */
21886d7f5d3SJohn Marino #define	HIFN_1_DMA_DRAR		0x3c	/* DMA Destination Ring Address */
21986d7f5d3SJohn Marino #define	HIFN_1_DMA_CSR		0x40	/* DMA Status and Control */
22086d7f5d3SJohn Marino #define	HIFN_1_DMA_IER		0x44	/* DMA Interrupt Enable */
22186d7f5d3SJohn Marino #define	HIFN_1_DMA_CNFG		0x48	/* DMA Configuration */
22286d7f5d3SJohn Marino #define	HIFN_1_PLL		0x4c	/* 7955/7956: PLL config */
22386d7f5d3SJohn Marino #define	HIFN_1_7811_RNGENA	0x60	/* 7811: rng enable */
22486d7f5d3SJohn Marino #define	HIFN_1_7811_RNGCFG	0x64	/* 7811: rng config */
22586d7f5d3SJohn Marino #define	HIFN_1_7811_RNGDAT	0x68	/* 7811: rng data */
22686d7f5d3SJohn Marino #define	HIFN_1_7811_RNGSTS	0x6c	/* 7811: rng status */
22786d7f5d3SJohn Marino #define	HIFN_1_DMA_CNFG2	0x6c	/* 7955/7956: dma config #2 */
22886d7f5d3SJohn Marino #define	HIFN_1_7811_MIPSRST	0x94	/* 7811: MIPS reset */
22986d7f5d3SJohn Marino #define	HIFN_1_REVID		0x98	/* Revision ID */
23086d7f5d3SJohn Marino 
23186d7f5d3SJohn Marino #define	HIFN_1_PUB_RESET	0x204	/* Public/RNG Reset */
23286d7f5d3SJohn Marino #define	HIFN_1_PUB_BASE		0x300	/* Public Base Address */
23386d7f5d3SJohn Marino #define	HIFN_1_PUB_OPLEN	0x304	/* Public Operand Length */
23486d7f5d3SJohn Marino #define	HIFN_1_PUB_OP		0x308	/* Public Operand */
23586d7f5d3SJohn Marino #define	HIFN_1_PUB_STATUS	0x30c	/* Public Status */
23686d7f5d3SJohn Marino #define	HIFN_1_PUB_IEN		0x310	/* Public Interrupt nable */
23786d7f5d3SJohn Marino #define	HIFN_1_RNG_CONFIG	0x314	/* RNG config */
23886d7f5d3SJohn Marino #define	HIFN_1_RNG_DATA		0x318	/* RNG data */
23986d7f5d3SJohn Marino #define	HIFN_1_PUB_MEM		0x400	/* start of Public key memory */
24086d7f5d3SJohn Marino #define	HIFN_1_PUB_MEMEND	0xbff	/* end of Public key memory */
24186d7f5d3SJohn Marino 
24286d7f5d3SJohn Marino /* DMA Status and Control Register (HIFN_1_DMA_CSR) */
24386d7f5d3SJohn Marino #define	HIFN_DMACSR_D_CTRLMASK	0xc0000000	/* Destinition Ring Control */
24486d7f5d3SJohn Marino #define	HIFN_DMACSR_D_CTRL_NOP	0x00000000	/* Dest. Control: no-op */
24586d7f5d3SJohn Marino #define	HIFN_DMACSR_D_CTRL_DIS	0x40000000	/* Dest. Control: disable */
24686d7f5d3SJohn Marino #define	HIFN_DMACSR_D_CTRL_ENA	0x80000000	/* Dest. Control: enable */
24786d7f5d3SJohn Marino #define	HIFN_DMACSR_D_ABORT	0x20000000	/* Destinition Ring PCIAbort */
24886d7f5d3SJohn Marino #define	HIFN_DMACSR_D_DONE	0x10000000	/* Destinition Ring Done */
24986d7f5d3SJohn Marino #define	HIFN_DMACSR_D_LAST	0x08000000	/* Destinition Ring Last */
25086d7f5d3SJohn Marino #define	HIFN_DMACSR_D_WAIT	0x04000000	/* Destinition Ring Waiting */
25186d7f5d3SJohn Marino #define	HIFN_DMACSR_D_OVER	0x02000000	/* Destinition Ring Overflow */
25286d7f5d3SJohn Marino #define	HIFN_DMACSR_R_CTRL	0x00c00000	/* Result Ring Control */
25386d7f5d3SJohn Marino #define	HIFN_DMACSR_R_CTRL_NOP	0x00000000	/* Result Control: no-op */
25486d7f5d3SJohn Marino #define	HIFN_DMACSR_R_CTRL_DIS	0x00400000	/* Result Control: disable */
25586d7f5d3SJohn Marino #define	HIFN_DMACSR_R_CTRL_ENA	0x00800000	/* Result Control: enable */
25686d7f5d3SJohn Marino #define	HIFN_DMACSR_R_ABORT	0x00200000	/* Result Ring PCI Abort */
25786d7f5d3SJohn Marino #define	HIFN_DMACSR_R_DONE	0x00100000	/* Result Ring Done */
25886d7f5d3SJohn Marino #define	HIFN_DMACSR_R_LAST	0x00080000	/* Result Ring Last */
25986d7f5d3SJohn Marino #define	HIFN_DMACSR_R_WAIT	0x00040000	/* Result Ring Waiting */
26086d7f5d3SJohn Marino #define	HIFN_DMACSR_R_OVER	0x00020000	/* Result Ring Overflow */
26186d7f5d3SJohn Marino #define	HIFN_DMACSR_S_CTRL	0x0000c000	/* Source Ring Control */
26286d7f5d3SJohn Marino #define	HIFN_DMACSR_S_CTRL_NOP	0x00000000	/* Source Control: no-op */
26386d7f5d3SJohn Marino #define	HIFN_DMACSR_S_CTRL_DIS	0x00004000	/* Source Control: disable */
26486d7f5d3SJohn Marino #define	HIFN_DMACSR_S_CTRL_ENA	0x00008000	/* Source Control: enable */
26586d7f5d3SJohn Marino #define	HIFN_DMACSR_S_ABORT	0x00002000	/* Source Ring PCI Abort */
26686d7f5d3SJohn Marino #define	HIFN_DMACSR_S_DONE	0x00001000	/* Source Ring Done */
26786d7f5d3SJohn Marino #define	HIFN_DMACSR_S_LAST	0x00000800	/* Source Ring Last */
26886d7f5d3SJohn Marino #define	HIFN_DMACSR_S_WAIT	0x00000400	/* Source Ring Waiting */
26986d7f5d3SJohn Marino #define	HIFN_DMACSR_ILLW	0x00000200	/* Illegal write (7811 only) */
27086d7f5d3SJohn Marino #define	HIFN_DMACSR_ILLR	0x00000100	/* Illegal read (7811 only) */
27186d7f5d3SJohn Marino #define	HIFN_DMACSR_C_CTRL	0x000000c0	/* Command Ring Control */
27286d7f5d3SJohn Marino #define	HIFN_DMACSR_C_CTRL_NOP	0x00000000	/* Command Control: no-op */
27386d7f5d3SJohn Marino #define	HIFN_DMACSR_C_CTRL_DIS	0x00000040	/* Command Control: disable */
27486d7f5d3SJohn Marino #define	HIFN_DMACSR_C_CTRL_ENA	0x00000080	/* Command Control: enable */
27586d7f5d3SJohn Marino #define	HIFN_DMACSR_C_ABORT	0x00000020	/* Command Ring PCI Abort */
27686d7f5d3SJohn Marino #define	HIFN_DMACSR_C_DONE	0x00000010	/* Command Ring Done */
27786d7f5d3SJohn Marino #define	HIFN_DMACSR_C_LAST	0x00000008	/* Command Ring Last */
27886d7f5d3SJohn Marino #define	HIFN_DMACSR_C_WAIT	0x00000004	/* Command Ring Waiting */
27986d7f5d3SJohn Marino #define	HIFN_DMACSR_PUBDONE	0x00000002	/* Public op done (7951 only) */
28086d7f5d3SJohn Marino #define	HIFN_DMACSR_ENGINE	0x00000001	/* Command Ring Engine IRQ */
28186d7f5d3SJohn Marino 
28286d7f5d3SJohn Marino /* DMA Interrupt Enable Register (HIFN_1_DMA_IER) */
28386d7f5d3SJohn Marino #define	HIFN_DMAIER_D_ABORT	0x20000000	/* Destination Ring PCIAbort */
28486d7f5d3SJohn Marino #define	HIFN_DMAIER_D_DONE	0x10000000	/* Destination Ring Done */
28586d7f5d3SJohn Marino #define	HIFN_DMAIER_D_LAST	0x08000000	/* Destination Ring Last */
28686d7f5d3SJohn Marino #define	HIFN_DMAIER_D_WAIT	0x04000000	/* Destination Ring Waiting */
28786d7f5d3SJohn Marino #define	HIFN_DMAIER_D_OVER	0x02000000	/* Destination Ring Overflow */
28886d7f5d3SJohn Marino #define	HIFN_DMAIER_R_ABORT	0x00200000	/* Result Ring PCI Abort */
28986d7f5d3SJohn Marino #define	HIFN_DMAIER_R_DONE	0x00100000	/* Result Ring Done */
29086d7f5d3SJohn Marino #define	HIFN_DMAIER_R_LAST	0x00080000	/* Result Ring Last */
29186d7f5d3SJohn Marino #define	HIFN_DMAIER_R_WAIT	0x00040000	/* Result Ring Waiting */
29286d7f5d3SJohn Marino #define	HIFN_DMAIER_R_OVER	0x00020000	/* Result Ring Overflow */
29386d7f5d3SJohn Marino #define	HIFN_DMAIER_S_ABORT	0x00002000	/* Source Ring PCI Abort */
29486d7f5d3SJohn Marino #define	HIFN_DMAIER_S_DONE	0x00001000	/* Source Ring Done */
29586d7f5d3SJohn Marino #define	HIFN_DMAIER_S_LAST	0x00000800	/* Source Ring Last */
29686d7f5d3SJohn Marino #define	HIFN_DMAIER_S_WAIT	0x00000400	/* Source Ring Waiting */
29786d7f5d3SJohn Marino #define	HIFN_DMAIER_ILLW	0x00000200	/* Illegal write (7811 only) */
29886d7f5d3SJohn Marino #define	HIFN_DMAIER_ILLR	0x00000100	/* Illegal read (7811 only) */
29986d7f5d3SJohn Marino #define	HIFN_DMAIER_C_ABORT	0x00000020	/* Command Ring PCI Abort */
30086d7f5d3SJohn Marino #define	HIFN_DMAIER_C_DONE	0x00000010	/* Command Ring Done */
30186d7f5d3SJohn Marino #define	HIFN_DMAIER_C_LAST	0x00000008	/* Command Ring Last */
30286d7f5d3SJohn Marino #define	HIFN_DMAIER_C_WAIT	0x00000004	/* Command Ring Waiting */
30386d7f5d3SJohn Marino #define	HIFN_DMAIER_PUBDONE	0x00000002	/* public op done (7951 only) */
30486d7f5d3SJohn Marino #define	HIFN_DMAIER_ENGINE	0x00000001	/* Engine IRQ */
30586d7f5d3SJohn Marino 
30686d7f5d3SJohn Marino /* DMA Configuration Register (HIFN_1_DMA_CNFG) */
30786d7f5d3SJohn Marino #define	HIFN_DMACNFG_BIGENDIAN	0x10000000	/* big endian mode */
30886d7f5d3SJohn Marino #define	HIFN_DMACNFG_POLLFREQ	0x00ff0000	/* Poll frequency mask */
30986d7f5d3SJohn Marino #define	HIFN_DMACNFG_UNLOCK	0x00000800
31086d7f5d3SJohn Marino #define	HIFN_DMACNFG_POLLINVAL	0x00000700	/* Invalid Poll Scalar */
31186d7f5d3SJohn Marino #define	HIFN_DMACNFG_LAST	0x00000010	/* Host control LAST bit */
31286d7f5d3SJohn Marino #define	HIFN_DMACNFG_MODE	0x00000004	/* DMA mode */
31386d7f5d3SJohn Marino #define	HIFN_DMACNFG_DMARESET	0x00000002	/* DMA Reset # */
31486d7f5d3SJohn Marino #define	HIFN_DMACNFG_MSTRESET	0x00000001	/* Master Reset # */
31586d7f5d3SJohn Marino 
31686d7f5d3SJohn Marino /* DMA Configuration Register (HIFN_1_DMA_CNFG2) */
31786d7f5d3SJohn Marino #define	HIFN_DMACNFG2_PKSWAP32	(1 << 19)	/* swap the OPLEN/OP reg */
31886d7f5d3SJohn Marino #define	HIFN_DMACNFG2_PKSWAP8	(1 << 18)	/* swap the bits of OPLEN/OP */
31986d7f5d3SJohn Marino #define	HIFN_DMACNFG2_BAR0_SWAP32 (1<<17)	/* swap the bytes of BAR0 */
32086d7f5d3SJohn Marino #define	HIFN_DMACNFG2_BAR1_SWAP8 (1<<16)	/* swap the bits  of BAR0 */
32186d7f5d3SJohn Marino #define	HIFN_DMACNFG2_INIT_WRITE_BURST_SHIFT 12
32286d7f5d3SJohn Marino #define	HIFN_DMACNFG2_INIT_READ_BURST_SHIFT 8
32386d7f5d3SJohn Marino #define	HIFN_DMACNFG2_TGT_WRITE_BURST_SHIFT 4
32486d7f5d3SJohn Marino #define	HIFN_DMACNFG2_TGT_READ_BURST_SHIFT  0
32586d7f5d3SJohn Marino 
32686d7f5d3SJohn Marino /* 7811 RNG Enable Register (HIFN_1_7811_RNGENA) */
32786d7f5d3SJohn Marino #define	HIFN_7811_RNGENA_ENA	0x00000001	/* enable RNG */
32886d7f5d3SJohn Marino 
32986d7f5d3SJohn Marino /* 7811 RNG Config Register (HIFN_1_7811_RNGCFG) */
33086d7f5d3SJohn Marino #define	HIFN_7811_RNGCFG_PRE1	0x00000f00	/* first prescalar */
33186d7f5d3SJohn Marino #define	HIFN_7811_RNGCFG_OPRE	0x00000080	/* output prescalar */
33286d7f5d3SJohn Marino #define	HIFN_7811_RNGCFG_DEFL	0x00000f80	/* 2 words/ 1/100 sec */
33386d7f5d3SJohn Marino 
33486d7f5d3SJohn Marino /* 7811 RNG Status Register (HIFN_1_7811_RNGSTS) */
33586d7f5d3SJohn Marino #define	HIFN_7811_RNGSTS_RDY	0x00004000	/* two numbers in FIFO */
33686d7f5d3SJohn Marino #define	HIFN_7811_RNGSTS_UFL	0x00001000	/* rng underflow */
33786d7f5d3SJohn Marino 
33886d7f5d3SJohn Marino /* 7811 MIPS Reset Register (HIFN_1_7811_MIPSRST) */
33986d7f5d3SJohn Marino #define	HIFN_MIPSRST_BAR2SIZE	0xffff0000	/* sdram size */
34086d7f5d3SJohn Marino #define	HIFN_MIPSRST_GPRAMINIT	0x00008000	/* gpram can be accessed */
34186d7f5d3SJohn Marino #define	HIFN_MIPSRST_CRAMINIT	0x00004000	/* ctxram can be accessed */
34286d7f5d3SJohn Marino #define	HIFN_MIPSRST_LED2	0x00000400	/* external LED2 */
34386d7f5d3SJohn Marino #define	HIFN_MIPSRST_LED1	0x00000200	/* external LED1 */
34486d7f5d3SJohn Marino #define	HIFN_MIPSRST_LED0	0x00000100	/* external LED0 */
34586d7f5d3SJohn Marino #define	HIFN_MIPSRST_MIPSDIS	0x00000004	/* disable MIPS */
34686d7f5d3SJohn Marino #define	HIFN_MIPSRST_MIPSRST	0x00000002	/* warm reset MIPS */
34786d7f5d3SJohn Marino #define	HIFN_MIPSRST_MIPSCOLD	0x00000001	/* cold reset MIPS */
34886d7f5d3SJohn Marino 
34986d7f5d3SJohn Marino /* Public key reset register (HIFN_1_PUB_RESET) */
35086d7f5d3SJohn Marino #define	HIFN_PUBRST_RESET	0x00000001	/* reset public/rng unit */
35186d7f5d3SJohn Marino 
35286d7f5d3SJohn Marino /* Public operation register (HIFN_1_PUB_OP) */
35386d7f5d3SJohn Marino #define	HIFN_PUBOP_AOFFSET	0x0000003e	/* A offset */
35486d7f5d3SJohn Marino #define	HIFN_PUBOP_BOFFSET	0x00000fc0	/* B offset */
35586d7f5d3SJohn Marino #define	HIFN_PUBOP_MOFFSET	0x0003f000	/* M offset */
35686d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_MASK	0x003c0000	/* Opcode: */
35786d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_NOP	0x00000000	/*  NOP */
35886d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_ADD	0x00040000	/*  ADD */
35986d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_ADDC	0x00080000	/*  ADD w/carry */
36086d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_SUB	0x000c0000	/*  SUB */
36186d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_SUBC	0x00100000	/*  SUB w/carry */
36286d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_MODADD	0x00140000	/*  Modular ADD */
36386d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_MODSUB	0x00180000	/*  Modular SUB */
36486d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_INCA	0x001c0000	/*  INC A */
36586d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_DECA	0x00200000	/*  DEC A */
36686d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_MULT	0x00240000	/*  MULT */
36786d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_MODMULT	0x00280000	/*  Modular MULT */
36886d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_MODRED	0x002c0000	/*  Modular Red */
36986d7f5d3SJohn Marino #define	HIFN_PUBOP_OP_MODEXP	0x00300000	/*  Modular Exp */
37086d7f5d3SJohn Marino 
37186d7f5d3SJohn Marino /* Public operand length register (HIFN_1_PUB_OPLEN) */
37286d7f5d3SJohn Marino #define	HIFN_PUBOPLEN_MODLEN	0x0000007f
37386d7f5d3SJohn Marino #define	HIFN_PUBOPLEN_EXPLEN	0x0003ff80
37486d7f5d3SJohn Marino #define	HIFN_PUBOPLEN_REDLEN	0x003c0000
37586d7f5d3SJohn Marino 
37686d7f5d3SJohn Marino /* Public status register (HIFN_1_PUB_STATUS) */
37786d7f5d3SJohn Marino #define	HIFN_PUBSTS_DONE	0x00000001	/* operation done */
37886d7f5d3SJohn Marino #define	HIFN_PUBSTS_CARRY	0x00000002	/* carry */
37986d7f5d3SJohn Marino 
38086d7f5d3SJohn Marino /* Public interrupt enable register (HIFN_1_PUB_IEN) */
38186d7f5d3SJohn Marino #define	HIFN_PUBIEN_DONE	0x00000001	/* operation done interrupt */
38286d7f5d3SJohn Marino 
38386d7f5d3SJohn Marino /* Random number generator config register (HIFN_1_RNG_CONFIG) */
38486d7f5d3SJohn Marino #define	HIFN_RNGCFG_ENA		0x00000001	/* enable rng */
38586d7f5d3SJohn Marino 
38686d7f5d3SJohn Marino /*
38786d7f5d3SJohn Marino  * Register offsets in register set 1
38886d7f5d3SJohn Marino  */
38986d7f5d3SJohn Marino 
39086d7f5d3SJohn Marino #define	HIFN_UNLOCK_SECRET1	0xf4
39186d7f5d3SJohn Marino #define	HIFN_UNLOCK_SECRET2	0xfc
39286d7f5d3SJohn Marino 
39386d7f5d3SJohn Marino /*
39486d7f5d3SJohn Marino  * PLL config register
39586d7f5d3SJohn Marino  *
39686d7f5d3SJohn Marino  * This register is present only on 7954/7955/7956 parts. It must be
39786d7f5d3SJohn Marino  * programmed according to the bus interface method used by the h/w.
39886d7f5d3SJohn Marino  * Note that the parts require a stable clock.  Since the PCI clock
39986d7f5d3SJohn Marino  * may vary the reference clock must usually be used.  To avoid
40086d7f5d3SJohn Marino  * overclocking the core logic, setup must be done carefully, refer
40186d7f5d3SJohn Marino  * to the driver for details.  The exact multiplier required varies
40286d7f5d3SJohn Marino  * by part and system configuration; refer to the Hifn documentation.
40386d7f5d3SJohn Marino  */
40486d7f5d3SJohn Marino #define	HIFN_PLL_REF_SEL	0x00000001	/* REF/HBI clk selection */
40586d7f5d3SJohn Marino #define	HIFN_PLL_BP		0x00000002	/* bypass (used during setup) */
40686d7f5d3SJohn Marino /* bit 2 reserved */
40786d7f5d3SJohn Marino #define	HIFN_PLL_PK_CLK_SEL	0x00000008	/* public key clk select */
40886d7f5d3SJohn Marino #define	HIFN_PLL_PE_CLK_SEL	0x00000010	/* packet engine clk select */
40986d7f5d3SJohn Marino /* bits 5-9 reserved */
41086d7f5d3SJohn Marino #define	HIFN_PLL_MBSET		0x00000400	/* must be set to 1 */
41186d7f5d3SJohn Marino #define	HIFN_PLL_ND		0x00003800	/* Fpll_ref multiplier select */
41286d7f5d3SJohn Marino #define	HIFN_PLL_ND_SHIFT	11
41386d7f5d3SJohn Marino #define	HIFN_PLL_ND_2		0x00000000	/* 2x */
41486d7f5d3SJohn Marino #define	HIFN_PLL_ND_4		0x00000800	/* 4x */
41586d7f5d3SJohn Marino #define	HIFN_PLL_ND_6		0x00001000	/* 6x */
41686d7f5d3SJohn Marino #define	HIFN_PLL_ND_8		0x00001800	/* 8x */
41786d7f5d3SJohn Marino #define	HIFN_PLL_ND_10		0x00002000	/* 10x */
41886d7f5d3SJohn Marino #define	HIFN_PLL_ND_12		0x00002800	/* 12x */
41986d7f5d3SJohn Marino /* bits 14-15 reserved */
42086d7f5d3SJohn Marino #define	HIFN_PLL_IS		0x00010000	/* charge pump current select */
42186d7f5d3SJohn Marino /* bits 17-31 reserved */
42286d7f5d3SJohn Marino 
42386d7f5d3SJohn Marino /*
42486d7f5d3SJohn Marino  * Board configuration specifies only these bits.
42586d7f5d3SJohn Marino  */
42686d7f5d3SJohn Marino #define        HIFN_PLL_CONFIG         (HIFN_PLL_IS|HIFN_PLL_ND|HIFN_PLL_REF_SEL)
42786d7f5d3SJohn Marino 
42886d7f5d3SJohn Marino /*********************************************************************
42986d7f5d3SJohn Marino  * Structs for board commands
43086d7f5d3SJohn Marino  *
43186d7f5d3SJohn Marino  *********************************************************************/
43286d7f5d3SJohn Marino 
43386d7f5d3SJohn Marino /*
43486d7f5d3SJohn Marino  * Structure to help build up the command data structure.
43586d7f5d3SJohn Marino  */
43686d7f5d3SJohn Marino typedef struct hifn_base_command {
43786d7f5d3SJohn Marino 	volatile u_int16_t masks;
43886d7f5d3SJohn Marino 	volatile u_int16_t session_num;
43986d7f5d3SJohn Marino 	volatile u_int16_t total_source_count;
44086d7f5d3SJohn Marino 	volatile u_int16_t total_dest_count;
44186d7f5d3SJohn Marino } hifn_base_command_t;
44286d7f5d3SJohn Marino 
44386d7f5d3SJohn Marino #define	HIFN_BASE_CMD_COMP		0x0100	/* enable compression engine */
44486d7f5d3SJohn Marino #define	HIFN_BASE_CMD_PAD		0x0200	/* enable padding engine */
44586d7f5d3SJohn Marino #define	HIFN_BASE_CMD_MAC		0x0400
44686d7f5d3SJohn Marino #define	HIFN_BASE_CMD_CRYPT		0x0800
44786d7f5d3SJohn Marino #define	HIFN_BASE_CMD_DECODE		0x2000
44886d7f5d3SJohn Marino #define	HIFN_BASE_CMD_SRCLEN_M		0xc000
44986d7f5d3SJohn Marino #define	HIFN_BASE_CMD_SRCLEN_S		14
45086d7f5d3SJohn Marino #define	HIFN_BASE_CMD_DSTLEN_M		0x3000
45186d7f5d3SJohn Marino #define	HIFN_BASE_CMD_DSTLEN_S		12
45286d7f5d3SJohn Marino #define	HIFN_BASE_CMD_LENMASK_HI	0x30000
45386d7f5d3SJohn Marino #define	HIFN_BASE_CMD_LENMASK_LO	0x0ffff
45486d7f5d3SJohn Marino 
45586d7f5d3SJohn Marino /*
45686d7f5d3SJohn Marino  * Structure to help build up the command data structure.
45786d7f5d3SJohn Marino  */
45886d7f5d3SJohn Marino typedef struct hifn_crypt_command {
45986d7f5d3SJohn Marino 	volatile u_int16_t masks;
46086d7f5d3SJohn Marino 	volatile u_int16_t header_skip;
46186d7f5d3SJohn Marino 	volatile u_int16_t source_count;
46286d7f5d3SJohn Marino 	volatile u_int16_t reserved;
46386d7f5d3SJohn Marino } hifn_crypt_command_t;
46486d7f5d3SJohn Marino 
46586d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_ALG_MASK		0x0003		/* algorithm: */
46686d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_ALG_DES		0x0000		/*   DES */
46786d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_ALG_3DES		0x0001		/*   3DES */
46886d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_ALG_RC4		0x0002		/*   RC4 */
46986d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_ALG_AES		0x0003		/*   AES */
47086d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_MODE_MASK	0x0018		/* Encrypt/DES mode: */
47186d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_MODE_ECB		0x0000		/*   ECB */
47286d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_MODE_CBC		0x0008		/*   CBC */
47386d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_MODE_CFB		0x0010		/*   CFB */
47486d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_MODE_OFB		0x0018		/*   OFB */
47586d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_CLR_CTX		0x0040		/* clear context */
47686d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_NEW_KEY		0x0800		/* expect new key */
47786d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_NEW_IV		0x1000		/* expect new iv */
47886d7f5d3SJohn Marino 
47986d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_SRCLEN_M		0xc000
48086d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_SRCLEN_S		14
48186d7f5d3SJohn Marino 
48286d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_KSZ_MASK		0x0600		/* AES key size: */
48386d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_KSZ_128		0x0000		/*  128 bit */
48486d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_KSZ_192		0x0200		/*  192 bit */
48586d7f5d3SJohn Marino #define	HIFN_CRYPT_CMD_KSZ_256		0x0400		/*  256 bit */
48686d7f5d3SJohn Marino 
48786d7f5d3SJohn Marino /*
48886d7f5d3SJohn Marino  * Structure to help build up the command data structure.
48986d7f5d3SJohn Marino  */
49086d7f5d3SJohn Marino typedef struct hifn_mac_command {
49186d7f5d3SJohn Marino 	volatile u_int16_t masks;
49286d7f5d3SJohn Marino 	volatile u_int16_t header_skip;
49386d7f5d3SJohn Marino 	volatile u_int16_t source_count;
49486d7f5d3SJohn Marino 	volatile u_int16_t reserved;
49586d7f5d3SJohn Marino } hifn_mac_command_t;
49686d7f5d3SJohn Marino 
49786d7f5d3SJohn Marino #define	HIFN_MAC_CMD_ALG_MASK		0x0001
49886d7f5d3SJohn Marino #define	HIFN_MAC_CMD_ALG_SHA1		0x0000
49986d7f5d3SJohn Marino #define	HIFN_MAC_CMD_ALG_MD5		0x0001
50086d7f5d3SJohn Marino #define	HIFN_MAC_CMD_MODE_MASK		0x000c
50186d7f5d3SJohn Marino #define	HIFN_MAC_CMD_MODE_HMAC		0x0000
50286d7f5d3SJohn Marino #define	HIFN_MAC_CMD_MODE_SSL_MAC	0x0004
50386d7f5d3SJohn Marino #define	HIFN_MAC_CMD_MODE_HASH		0x0008
50486d7f5d3SJohn Marino #define	HIFN_MAC_CMD_MODE_FULL		0x0004
50586d7f5d3SJohn Marino #define	HIFN_MAC_CMD_TRUNC		0x0010
50686d7f5d3SJohn Marino #define	HIFN_MAC_CMD_RESULT		0x0020
50786d7f5d3SJohn Marino #define	HIFN_MAC_CMD_APPEND		0x0040
50886d7f5d3SJohn Marino #define	HIFN_MAC_CMD_SRCLEN_M		0xc000
50986d7f5d3SJohn Marino #define	HIFN_MAC_CMD_SRCLEN_S		14
51086d7f5d3SJohn Marino 
51186d7f5d3SJohn Marino /*
51286d7f5d3SJohn Marino  * MAC POS IPsec initiates authentication after encryption on encodes
51386d7f5d3SJohn Marino  * and before decryption on decodes.
51486d7f5d3SJohn Marino  */
51586d7f5d3SJohn Marino #define	HIFN_MAC_CMD_POS_IPSEC		0x0200
51686d7f5d3SJohn Marino #define	HIFN_MAC_CMD_NEW_KEY		0x0800
51786d7f5d3SJohn Marino 
51886d7f5d3SJohn Marino struct hifn_comp_command {
51986d7f5d3SJohn Marino 	volatile u_int16_t masks;
52086d7f5d3SJohn Marino 	volatile u_int16_t header_skip;
52186d7f5d3SJohn Marino 	volatile u_int16_t source_count;
52286d7f5d3SJohn Marino 	volatile u_int16_t reserved;
52386d7f5d3SJohn Marino };
52486d7f5d3SJohn Marino 
52586d7f5d3SJohn Marino #define	HIFN_COMP_CMD_SRCLEN_M		0xc000
52686d7f5d3SJohn Marino #define	HIFN_COMP_CMD_SRCLEN_S		14
52786d7f5d3SJohn Marino #define	HIFN_COMP_CMD_ONE		0x0100	/* must be one */
52886d7f5d3SJohn Marino #define	HIFN_COMP_CMD_CLEARHIST		0x0010	/* clear history */
52986d7f5d3SJohn Marino #define	HIFN_COMP_CMD_UPDATEHIST	0x0008	/* update history */
53086d7f5d3SJohn Marino #define	HIFN_COMP_CMD_LZS_STRIP0	0x0004	/* LZS: strip zero */
53186d7f5d3SJohn Marino #define	HIFN_COMP_CMD_MPPC_RESTART	0x0004	/* MPPC: restart */
53286d7f5d3SJohn Marino #define	HIFN_COMP_CMD_ALG_MASK		0x0001	/* compression mode: */
53386d7f5d3SJohn Marino #define	HIFN_COMP_CMD_ALG_MPPC		0x0001	/*   MPPC */
53486d7f5d3SJohn Marino #define	HIFN_COMP_CMD_ALG_LZS		0x0000	/*   LZS */
53586d7f5d3SJohn Marino 
53686d7f5d3SJohn Marino struct hifn_base_result {
53786d7f5d3SJohn Marino 	volatile u_int16_t flags;
53886d7f5d3SJohn Marino 	volatile u_int16_t session;
53986d7f5d3SJohn Marino 	volatile u_int16_t src_cnt;		/* 15:0 of source count */
54086d7f5d3SJohn Marino 	volatile u_int16_t dst_cnt;		/* 15:0 of dest count */
54186d7f5d3SJohn Marino };
54286d7f5d3SJohn Marino 
54386d7f5d3SJohn Marino #define	HIFN_BASE_RES_DSTOVERRUN	0x0200	/* destination overrun */
54486d7f5d3SJohn Marino #define	HIFN_BASE_RES_SRCLEN_M		0xc000	/* 17:16 of source count */
54586d7f5d3SJohn Marino #define	HIFN_BASE_RES_SRCLEN_S		14
54686d7f5d3SJohn Marino #define	HIFN_BASE_RES_DSTLEN_M		0x3000	/* 17:16 of dest count */
54786d7f5d3SJohn Marino #define	HIFN_BASE_RES_DSTLEN_S		12
54886d7f5d3SJohn Marino 
54986d7f5d3SJohn Marino struct hifn_comp_result {
55086d7f5d3SJohn Marino 	volatile u_int16_t flags;
55186d7f5d3SJohn Marino 	volatile u_int16_t crc;
55286d7f5d3SJohn Marino };
55386d7f5d3SJohn Marino 
55486d7f5d3SJohn Marino #define	HIFN_COMP_RES_LCB_M		0xff00	/* longitudinal check byte */
55586d7f5d3SJohn Marino #define	HIFN_COMP_RES_LCB_S		8
55686d7f5d3SJohn Marino #define	HIFN_COMP_RES_RESTART		0x0004	/* MPPC: restart */
55786d7f5d3SJohn Marino #define	HIFN_COMP_RES_ENDMARKER		0x0002	/* LZS: end marker seen */
55886d7f5d3SJohn Marino #define	HIFN_COMP_RES_SRC_NOTZERO	0x0001	/* source expired */
55986d7f5d3SJohn Marino 
56086d7f5d3SJohn Marino struct hifn_mac_result {
56186d7f5d3SJohn Marino 	volatile u_int16_t flags;
56286d7f5d3SJohn Marino 	volatile u_int16_t reserved;
56386d7f5d3SJohn Marino 	/* followed by 0, 6, 8, or 10 u_int16_t's of the MAC, then crypt */
56486d7f5d3SJohn Marino };
56586d7f5d3SJohn Marino 
56686d7f5d3SJohn Marino #define	HIFN_MAC_RES_MISCOMPARE		0x0002	/* compare failed */
56786d7f5d3SJohn Marino #define	HIFN_MAC_RES_SRC_NOTZERO	0x0001	/* source expired */
56886d7f5d3SJohn Marino 
56986d7f5d3SJohn Marino struct hifn_crypt_result {
57086d7f5d3SJohn Marino 	volatile u_int16_t flags;
57186d7f5d3SJohn Marino 	volatile u_int16_t reserved;
57286d7f5d3SJohn Marino };
57386d7f5d3SJohn Marino 
57486d7f5d3SJohn Marino #define	HIFN_CRYPT_RES_SRC_NOTZERO	0x0001	/* source expired */
57586d7f5d3SJohn Marino 
57686d7f5d3SJohn Marino /*
57786d7f5d3SJohn Marino  * The poll frequency and poll scalar defines are unshifted values used
57886d7f5d3SJohn Marino  * to set fields in the DMA Configuration Register.
57986d7f5d3SJohn Marino  */
58086d7f5d3SJohn Marino #ifndef HIFN_POLL_FREQUENCY
58186d7f5d3SJohn Marino #define	HIFN_POLL_FREQUENCY	0x1
58286d7f5d3SJohn Marino #endif
58386d7f5d3SJohn Marino 
58486d7f5d3SJohn Marino #ifndef HIFN_POLL_SCALAR
58586d7f5d3SJohn Marino #define	HIFN_POLL_SCALAR	0x0
58686d7f5d3SJohn Marino #endif
58786d7f5d3SJohn Marino 
58886d7f5d3SJohn Marino #define	HIFN_MAX_SEGLEN 	0xffff		/* maximum dma segment len */
58986d7f5d3SJohn Marino #define	HIFN_MAX_DMALEN		0x3ffff		/* maximum dma length */
59086d7f5d3SJohn Marino #endif /* __HIFN_H__ */
591