Home | History | Annotate | Line # | Download | only in pci
      1  1.9  riastrad /*	$NetBSD: hifn7751reg.h,v 1.9 2020/05/17 00:51:27 riastradh Exp $	*/
      2  1.9  riastrad /*	$OpenBSD: hifn7751reg.h,v 1.46 2014/12/19 22:44:58 guenther Exp $	*/
      3  1.1    itojun 
      4  1.1    itojun /*
      5  1.4  jonathan  * Invertex AEON / Hifn 7751 driver
      6  1.1    itojun  * Copyright (c) 1999 Invertex Inc. All rights reserved.
      7  1.1    itojun  * Copyright (c) 1999 Theo de Raadt
      8  1.4  jonathan  * Copyright (c) 2000-2001 Network Security Technologies, Inc.
      9  1.1    itojun  *			http://www.netsec.net
     10  1.1    itojun  *
     11  1.1    itojun  * Please send any comments, feedback, bug-fixes, or feature requests to
     12  1.1    itojun  * software (at) invertex.com.
     13  1.1    itojun  *
     14  1.1    itojun  * Redistribution and use in source and binary forms, with or without
     15  1.1    itojun  * modification, are permitted provided that the following conditions
     16  1.1    itojun  * are met:
     17  1.1    itojun  *
     18  1.1    itojun  * 1. Redistributions of source code must retain the above copyright
     19  1.1    itojun  *    notice, this list of conditions and the following disclaimer.
     20  1.1    itojun  * 2. Redistributions in binary form must reproduce the above copyright
     21  1.1    itojun  *    notice, this list of conditions and the following disclaimer in the
     22  1.1    itojun  *    documentation and/or other materials provided with the distribution.
     23  1.1    itojun  * 3. The name of the author may not be used to endorse or promote products
     24  1.1    itojun  *    derived from this software without specific prior written permission.
     25  1.1    itojun  *
     26  1.1    itojun  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     27  1.1    itojun  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     28  1.1    itojun  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     29  1.1    itojun  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     30  1.1    itojun  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     31  1.1    itojun  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     32  1.1    itojun  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     33  1.1    itojun  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     34  1.1    itojun  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     35  1.1    itojun  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     36  1.4  jonathan  *
     37  1.4  jonathan  * Effort sponsored in part by the Defense Advanced Research Projects
     38  1.4  jonathan  * Agency (DARPA) and Air Force Research Laboratory, Air Force
     39  1.4  jonathan  * Materiel Command, USAF, under agreement number F30602-01-2-0537.
     40  1.4  jonathan  *
     41  1.1    itojun  */
     42  1.1    itojun #ifndef __DEV_PCI_HIFN7751REG_H__
     43  1.1    itojun #define __DEV_PCI_HIFN7751REG_H__
     44  1.1    itojun 
     45  1.9  riastrad #include <sys/endian.h>
     46  1.1    itojun 
     47  1.1    itojun /*
     48  1.1    itojun  * Some PCI configuration space offset defines.  The names were made
     49  1.1    itojun  * identical to the names used by the Linux kernel.
     50  1.1    itojun  */
     51  1.9  riastrad #define	HIFN_BAR0		(PCI_MAPREG_START + 0)	/* PUC register map */
     52  1.9  riastrad #define	HIFN_BAR1		(PCI_MAPREG_START + 4)	/* DMA register map */
     53  1.4  jonathan #define	HIFN_RETRY_TIMEOUT	0x41
     54  1.4  jonathan #define	HIFN_TRDY_TIMEOUT	0x40
     55  1.1    itojun 
     56  1.1    itojun /*
     57  1.1    itojun  * The values below should multiple of 4 -- and be large enough to handle
     58  1.1    itojun  * any command the driver implements.
     59  1.1    itojun  *
     60  1.1    itojun  * MAX_COMMAND = base command + mac command + encrypt command +
     61  1.4  jonathan  *			mac-key + rc4-key
     62  1.4  jonathan  * MAX_RESULT  = base result + comp result + mac result + mac + encrypt result
     63  1.7     perry  *
     64  1.1    itojun  *
     65  1.1    itojun  */
     66  1.4  jonathan #define	HIFN_MAX_COMMAND	(8 + 8 + 8 + 64 + 260)
     67  1.4  jonathan #define	HIFN_MAX_RESULT		(8 + 4 + 4 + 20 + 4)
     68  1.1    itojun 
     69  1.1    itojun /*
     70  1.1    itojun  * hifn_desc_t
     71  1.1    itojun  *
     72  1.1    itojun  * Holds an individual descriptor for any of the rings.
     73  1.1    itojun  */
     74  1.4  jonathan struct hifn_desc {
     75  1.1    itojun 	volatile u_int32_t l;		/* length and status bits */
     76  1.1    itojun 	volatile u_int32_t p;
     77  1.4  jonathan };
     78  1.1    itojun 
     79  1.1    itojun /*
     80  1.1    itojun  * Masks for the "length" field of struct hifn_desc.
     81  1.1    itojun  */
     82  1.4  jonathan #define	HIFN_D_LENGTH		0x0000ffff	/* length bit mask */
     83  1.1    itojun #define	HIFN_D_MASKDONEIRQ	0x02000000	/* mask the done interrupt */
     84  1.1    itojun #define	HIFN_D_DESTOVER		0x04000000	/* destination overflow */
     85  1.1    itojun #define	HIFN_D_OVER		0x08000000	/* overflow */
     86  1.1    itojun #define	HIFN_D_LAST		0x20000000	/* last descriptor in chain */
     87  1.1    itojun #define	HIFN_D_JUMP		0x40000000	/* jump descriptor */
     88  1.1    itojun #define	HIFN_D_VALID		0x80000000	/* valid bit */
     89  1.1    itojun 
     90  1.1    itojun /*
     91  1.1    itojun  * Processing Unit Registers (offset from BASEREG0)
     92  1.1    itojun  */
     93  1.1    itojun #define	HIFN_0_PUDATA		0x00	/* Processing Unit Data */
     94  1.1    itojun #define	HIFN_0_PUCTRL		0x04	/* Processing Unit Control */
     95  1.1    itojun #define	HIFN_0_PUISR		0x08	/* Processing Unit Interrupt Status */
     96  1.1    itojun #define	HIFN_0_PUCNFG		0x0c	/* Processing Unit Configuration */
     97  1.1    itojun #define	HIFN_0_PUIER		0x10	/* Processing Unit Interrupt Enable */
     98  1.1    itojun #define	HIFN_0_PUSTAT		0x14	/* Processing Unit Status/Chip ID */
     99  1.1    itojun #define	HIFN_0_FIFOSTAT		0x18	/* FIFO Status */
    100  1.1    itojun #define	HIFN_0_FIFOCNFG		0x1c	/* FIFO Configuration */
    101  1.1    itojun #define	HIFN_0_SPACESIZE	0x20	/* Register space size */
    102  1.1    itojun 
    103  1.1    itojun /* Processing Unit Control Register (HIFN_0_PUCTRL) */
    104  1.1    itojun #define	HIFN_PUCTRL_CLRSRCFIFO	0x0010	/* clear source fifo */
    105  1.1    itojun #define	HIFN_PUCTRL_STOP	0x0008	/* stop pu */
    106  1.1    itojun #define	HIFN_PUCTRL_LOCKRAM	0x0004	/* lock ram */
    107  1.1    itojun #define	HIFN_PUCTRL_DMAENA	0x0002	/* enable dma */
    108  1.1    itojun #define	HIFN_PUCTRL_RESET	0x0001	/* Reset processing unit */
    109  1.1    itojun 
    110  1.1    itojun /* Processing Unit Interrupt Status Register (HIFN_0_PUISR) */
    111  1.1    itojun #define	HIFN_PUISR_CMDINVAL	0x8000	/* Invalid command interrupt */
    112  1.1    itojun #define	HIFN_PUISR_DATAERR	0x4000	/* Data error interrupt */
    113  1.1    itojun #define	HIFN_PUISR_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
    114  1.1    itojun #define	HIFN_PUISR_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
    115  1.1    itojun #define	HIFN_PUISR_DSTOVER	0x0200	/* Destination overrun interrupt */
    116  1.1    itojun #define	HIFN_PUISR_SRCCMD	0x0080	/* Source command interrupt */
    117  1.1    itojun #define	HIFN_PUISR_SRCCTX	0x0040	/* Source context interrupt */
    118  1.1    itojun #define	HIFN_PUISR_SRCDATA	0x0020	/* Source data interrupt */
    119  1.1    itojun #define	HIFN_PUISR_DSTDATA	0x0010	/* Destination data interrupt */
    120  1.1    itojun #define	HIFN_PUISR_DSTRESULT	0x0004	/* Destination result interrupt */
    121  1.1    itojun 
    122  1.1    itojun /* Processing Unit Configuration Register (HIFN_0_PUCNFG) */
    123  1.1    itojun #define	HIFN_PUCNFG_DRAMMASK	0xe000	/* DRAM size mask */
    124  1.1    itojun #define	HIFN_PUCNFG_DSZ_256K	0x0000	/* 256k dram */
    125  1.1    itojun #define	HIFN_PUCNFG_DSZ_512K	0x2000	/* 512k dram */
    126  1.1    itojun #define	HIFN_PUCNFG_DSZ_1M	0x4000	/* 1m dram */
    127  1.1    itojun #define	HIFN_PUCNFG_DSZ_2M	0x6000	/* 2m dram */
    128  1.1    itojun #define	HIFN_PUCNFG_DSZ_4M	0x8000	/* 4m dram */
    129  1.1    itojun #define	HIFN_PUCNFG_DSZ_8M	0xa000	/* 8m dram */
    130  1.1    itojun #define	HIFN_PUNCFG_DSZ_16M	0xc000	/* 16m dram */
    131  1.1    itojun #define	HIFN_PUCNFG_DSZ_32M	0xe000	/* 32m dram */
    132  1.1    itojun #define	HIFN_PUCNFG_DRAMREFRESH	0x1800	/* DRAM refresh rate mask */
    133  1.1    itojun #define	HIFN_PUCNFG_DRFR_512	0x0000	/* 512 divisor of ECLK */
    134  1.1    itojun #define	HIFN_PUCNFG_DRFR_256	0x0800	/* 256 divisor of ECLK */
    135  1.1    itojun #define	HIFN_PUCNFG_DRFR_128	0x1000	/* 128 divisor of ECLK */
    136  1.1    itojun #define	HIFN_PUCNFG_TCALLPHASES	0x0200	/* your guess is as good as mine... */
    137  1.1    itojun #define	HIFN_PUCNFG_TCDRVTOTEM	0x0100	/* your guess is as good as mine... */
    138  1.1    itojun #define	HIFN_PUCNFG_BIGENDIAN	0x0080	/* DMA big endian mode */
    139  1.1    itojun #define	HIFN_PUCNFG_BUS32	0x0040	/* Bus width 32bits */
    140  1.1    itojun #define	HIFN_PUCNFG_BUS16	0x0000	/* Bus width 16 bits */
    141  1.1    itojun #define	HIFN_PUCNFG_CHIPID	0x0020	/* Allow chipid from PUSTAT */
    142  1.1    itojun #define	HIFN_PUCNFG_DRAM	0x0010	/* Context RAM is DRAM */
    143  1.1    itojun #define	HIFN_PUCNFG_SRAM	0x0000	/* Context RAM is SRAM */
    144  1.1    itojun #define	HIFN_PUCNFG_COMPSING	0x0004	/* Enable single compression context */
    145  1.1    itojun #define	HIFN_PUCNFG_ENCCNFG	0x0002	/* Encryption configuration */
    146  1.1    itojun 
    147  1.1    itojun /* Processing Unit Interrupt Enable Register (HIFN_0_PUIER) */
    148  1.1    itojun #define	HIFN_PUIER_CMDINVAL	0x8000	/* Invalid command interrupt */
    149  1.1    itojun #define	HIFN_PUIER_DATAERR	0x4000	/* Data error interrupt */
    150  1.1    itojun #define	HIFN_PUIER_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
    151  1.1    itojun #define	HIFN_PUIER_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
    152  1.1    itojun #define	HIFN_PUIER_DSTOVER	0x0200	/* Destination overrun interrupt */
    153  1.1    itojun #define	HIFN_PUIER_SRCCMD	0x0080	/* Source command interrupt */
    154  1.1    itojun #define	HIFN_PUIER_SRCCTX	0x0040	/* Source context interrupt */
    155  1.1    itojun #define	HIFN_PUIER_SRCDATA	0x0020	/* Source data interrupt */
    156  1.1    itojun #define	HIFN_PUIER_DSTDATA	0x0010	/* Destination data interrupt */
    157  1.1    itojun #define	HIFN_PUIER_DSTRESULT	0x0004	/* Destination result interrupt */
    158  1.1    itojun 
    159  1.1    itojun /* Processing Unit Status Register/Chip ID (HIFN_0_PUSTAT) */
    160  1.1    itojun #define	HIFN_PUSTAT_CMDINVAL	0x8000	/* Invalid command interrupt */
    161  1.1    itojun #define	HIFN_PUSTAT_DATAERR	0x4000	/* Data error interrupt */
    162  1.1    itojun #define	HIFN_PUSTAT_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
    163  1.1    itojun #define	HIFN_PUSTAT_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
    164  1.1    itojun #define	HIFN_PUSTAT_DSTOVER	0x0200	/* Destination overrun interrupt */
    165  1.1    itojun #define	HIFN_PUSTAT_SRCCMD	0x0080	/* Source command interrupt */
    166  1.1    itojun #define	HIFN_PUSTAT_SRCCTX	0x0040	/* Source context interrupt */
    167  1.1    itojun #define	HIFN_PUSTAT_SRCDATA	0x0020	/* Source data interrupt */
    168  1.1    itojun #define	HIFN_PUSTAT_DSTDATA	0x0010	/* Destination data interrupt */
    169  1.1    itojun #define	HIFN_PUSTAT_DSTRESULT	0x0004	/* Destination result interrupt */
    170  1.1    itojun #define	HIFN_PUSTAT_CHIPREV	0x00ff	/* Chip revision mask */
    171  1.1    itojun #define	HIFN_PUSTAT_CHIPENA	0xff00	/* Chip enabled mask */
    172  1.1    itojun #define	HIFN_PUSTAT_ENA_2	0x1100	/* Level 2 enabled */
    173  1.1    itojun #define	HIFN_PUSTAT_ENA_1	0x1000	/* Level 1 enabled */
    174  1.1    itojun #define	HIFN_PUSTAT_ENA_0	0x3000	/* Level 0 enabled */
    175  1.1    itojun #define	HIFN_PUSTAT_REV_2	0x0020	/* 7751 PT6/2 */
    176  1.1    itojun #define	HIFN_PUSTAT_REV_3	0x0030	/* 7751 PT6/3 */
    177  1.1    itojun 
    178  1.1    itojun /* FIFO Status Register (HIFN_0_FIFOSTAT) */
    179  1.1    itojun #define	HIFN_FIFOSTAT_SRC	0x7f00	/* Source FIFO available */
    180  1.1    itojun #define	HIFN_FIFOSTAT_DST	0x007f	/* Destination FIFO available */
    181  1.1    itojun 
    182  1.1    itojun /* FIFO Configuration Register (HIFN_0_FIFOCNFG) */
    183  1.1    itojun #define	HIFN_FIFOCNFG_THRESHOLD	0x0400	/* must be written as 1 */
    184  1.1    itojun 
    185  1.1    itojun /*
    186  1.1    itojun  * DMA Interface Registers (offset from BASEREG1)
    187  1.1    itojun  */
    188  1.1    itojun #define	HIFN_1_DMA_CRAR		0x0c	/* DMA Command Ring Address */
    189  1.1    itojun #define	HIFN_1_DMA_SRAR		0x1c	/* DMA Source Ring Address */
    190  1.4  jonathan #define	HIFN_1_DMA_RRAR		0x2c	/* DMA Result Ring Address */
    191  1.1    itojun #define	HIFN_1_DMA_DRAR		0x3c	/* DMA Destination Ring Address */
    192  1.1    itojun #define	HIFN_1_DMA_CSR		0x40	/* DMA Status and Control */
    193  1.1    itojun #define	HIFN_1_DMA_IER		0x44	/* DMA Interrupt Enable */
    194  1.1    itojun #define	HIFN_1_DMA_CNFG		0x48	/* DMA Configuration */
    195  1.5  jonathan #define	HIFN_1_PLL		0x4c	/* 795x: PLL config */
    196  1.4  jonathan #define	HIFN_1_7811_RNGENA	0x60	/* 7811: rng enable */
    197  1.4  jonathan #define	HIFN_1_7811_RNGCFG	0x64	/* 7811: rng config */
    198  1.4  jonathan #define	HIFN_1_7811_RNGDAT	0x68	/* 7811: rng data */
    199  1.4  jonathan #define	HIFN_1_7811_RNGSTS	0x6c	/* 7811: rng status */
    200  1.4  jonathan #define	HIFN_1_7811_MIPSRST	0x94	/* 7811: MIPS reset */
    201  1.1    itojun #define	HIFN_1_REVID		0x98	/* Revision ID */
    202  1.4  jonathan #define	HIFN_1_UNLOCK_SECRET1	0xf4
    203  1.4  jonathan #define	HIFN_1_UNLOCK_SECRET2	0xfc
    204  1.4  jonathan #define	HIFN_1_PUB_RESET	0x204	/* Public/RNG Reset */
    205  1.4  jonathan #define	HIFN_1_PUB_BASE		0x300	/* Public Base Address */
    206  1.4  jonathan #define	HIFN_1_PUB_OPLEN	0x304	/* Public Operand Length */
    207  1.4  jonathan #define	HIFN_1_PUB_OP		0x308	/* Public Operand */
    208  1.4  jonathan #define	HIFN_1_PUB_STATUS	0x30c	/* Public Status */
    209  1.4  jonathan #define	HIFN_1_PUB_IEN		0x310	/* Public Interrupt enable */
    210  1.4  jonathan #define	HIFN_1_RNG_CONFIG	0x314	/* RNG config */
    211  1.4  jonathan #define	HIFN_1_RNG_DATA		0x318	/* RNG data */
    212  1.4  jonathan #define	HIFN_1_PUB_MEM		0x400	/* start of Public key memory */
    213  1.4  jonathan #define	HIFN_1_PUB_MEMEND	0xbff	/* end of Public key memory */
    214  1.1    itojun 
    215  1.1    itojun /* DMA Status and Control Register (HIFN_1_DMA_CSR) */
    216  1.1    itojun #define	HIFN_DMACSR_D_CTRLMASK	0xc0000000	/* Destinition Ring Control */
    217  1.1    itojun #define	HIFN_DMACSR_D_CTRL_NOP	0x00000000	/* Dest. Control: no-op */
    218  1.1    itojun #define	HIFN_DMACSR_D_CTRL_DIS	0x40000000	/* Dest. Control: disable */
    219  1.1    itojun #define	HIFN_DMACSR_D_CTRL_ENA	0x80000000	/* Dest. Control: enable */
    220  1.1    itojun #define	HIFN_DMACSR_D_ABORT	0x20000000	/* Destinition Ring PCIAbort */
    221  1.1    itojun #define	HIFN_DMACSR_D_DONE	0x10000000	/* Destinition Ring Done */
    222  1.1    itojun #define	HIFN_DMACSR_D_LAST	0x08000000	/* Destinition Ring Last */
    223  1.1    itojun #define	HIFN_DMACSR_D_WAIT	0x04000000	/* Destinition Ring Waiting */
    224  1.1    itojun #define	HIFN_DMACSR_D_OVER	0x02000000	/* Destinition Ring Overflow */
    225  1.1    itojun #define	HIFN_DMACSR_R_CTRL	0x00c00000	/* Result Ring Control */
    226  1.1    itojun #define	HIFN_DMACSR_R_CTRL_NOP	0x00000000	/* Result Control: no-op */
    227  1.1    itojun #define	HIFN_DMACSR_R_CTRL_DIS	0x00400000	/* Result Control: disable */
    228  1.1    itojun #define	HIFN_DMACSR_R_CTRL_ENA	0x00800000	/* Result Control: enable */
    229  1.1    itojun #define	HIFN_DMACSR_R_ABORT	0x00200000	/* Result Ring PCI Abort */
    230  1.1    itojun #define	HIFN_DMACSR_R_DONE	0x00100000	/* Result Ring Done */
    231  1.1    itojun #define	HIFN_DMACSR_R_LAST	0x00080000	/* Result Ring Last */
    232  1.1    itojun #define	HIFN_DMACSR_R_WAIT	0x00040000	/* Result Ring Waiting */
    233  1.1    itojun #define	HIFN_DMACSR_R_OVER	0x00020000	/* Result Ring Overflow */
    234  1.1    itojun #define	HIFN_DMACSR_S_CTRL	0x0000c000	/* Source Ring Control */
    235  1.1    itojun #define	HIFN_DMACSR_S_CTRL_NOP	0x00000000	/* Source Control: no-op */
    236  1.1    itojun #define	HIFN_DMACSR_S_CTRL_DIS	0x00004000	/* Source Control: disable */
    237  1.1    itojun #define	HIFN_DMACSR_S_CTRL_ENA	0x00008000	/* Source Control: enable */
    238  1.1    itojun #define	HIFN_DMACSR_S_ABORT	0x00002000	/* Source Ring PCI Abort */
    239  1.1    itojun #define	HIFN_DMACSR_S_DONE	0x00001000	/* Source Ring Done */
    240  1.1    itojun #define	HIFN_DMACSR_S_LAST	0x00000800	/* Source Ring Last */
    241  1.1    itojun #define	HIFN_DMACSR_S_WAIT	0x00000400	/* Source Ring Waiting */
    242  1.4  jonathan #define	HIFN_DMACSR_ILLW	0x00000200	/* Illegal write (7811 only) */
    243  1.4  jonathan #define	HIFN_DMACSR_ILLR	0x00000100	/* Illegal read (7811 only) */
    244  1.1    itojun #define	HIFN_DMACSR_C_CTRL	0x000000c0	/* Command Ring Control */
    245  1.1    itojun #define	HIFN_DMACSR_C_CTRL_NOP	0x00000000	/* Command Control: no-op */
    246  1.1    itojun #define	HIFN_DMACSR_C_CTRL_DIS	0x00000040	/* Command Control: disable */
    247  1.1    itojun #define	HIFN_DMACSR_C_CTRL_ENA	0x00000080	/* Command Control: enable */
    248  1.1    itojun #define	HIFN_DMACSR_C_ABORT	0x00000020	/* Command Ring PCI Abort */
    249  1.1    itojun #define	HIFN_DMACSR_C_DONE	0x00000010	/* Command Ring Done */
    250  1.1    itojun #define	HIFN_DMACSR_C_LAST	0x00000008	/* Command Ring Last */
    251  1.1    itojun #define	HIFN_DMACSR_C_WAIT	0x00000004	/* Command Ring Waiting */
    252  1.4  jonathan #define	HIFN_DMACSR_PUBDONE	0x00000002	/* Public op done (7951 only) */
    253  1.4  jonathan #define	HIFN_DMACSR_ENGINE	0x00000001	/* Command Ring Engine IRQ */
    254  1.1    itojun 
    255  1.1    itojun /* DMA Interrupt Enable Register (HIFN_1_DMA_IER) */
    256  1.1    itojun #define	HIFN_DMAIER_D_ABORT	0x20000000	/* Destination Ring PCIAbort */
    257  1.1    itojun #define	HIFN_DMAIER_D_DONE	0x10000000	/* Destination Ring Done */
    258  1.1    itojun #define	HIFN_DMAIER_D_LAST	0x08000000	/* Destination Ring Last */
    259  1.1    itojun #define	HIFN_DMAIER_D_WAIT	0x04000000	/* Destination Ring Waiting */
    260  1.1    itojun #define	HIFN_DMAIER_D_OVER	0x02000000	/* Destination Ring Overflow */
    261  1.1    itojun #define	HIFN_DMAIER_R_ABORT	0x00200000	/* Result Ring PCI Abort */
    262  1.1    itojun #define	HIFN_DMAIER_R_DONE	0x00100000	/* Result Ring Done */
    263  1.1    itojun #define	HIFN_DMAIER_R_LAST	0x00080000	/* Result Ring Last */
    264  1.1    itojun #define	HIFN_DMAIER_R_WAIT	0x00040000	/* Result Ring Waiting */
    265  1.1    itojun #define	HIFN_DMAIER_R_OVER	0x00020000	/* Result Ring Overflow */
    266  1.1    itojun #define	HIFN_DMAIER_S_ABORT	0x00002000	/* Source Ring PCI Abort */
    267  1.1    itojun #define	HIFN_DMAIER_S_DONE	0x00001000	/* Source Ring Done */
    268  1.1    itojun #define	HIFN_DMAIER_S_LAST	0x00000800	/* Source Ring Last */
    269  1.1    itojun #define	HIFN_DMAIER_S_WAIT	0x00000400	/* Source Ring Waiting */
    270  1.4  jonathan #define	HIFN_DMAIER_ILLW	0x00000200	/* Illegal write (7811 only) */
    271  1.4  jonathan #define	HIFN_DMAIER_ILLR	0x00000100	/* Illegal read (7811 only) */
    272  1.1    itojun #define	HIFN_DMAIER_C_ABORT	0x00000020	/* Command Ring PCI Abort */
    273  1.1    itojun #define	HIFN_DMAIER_C_DONE	0x00000010	/* Command Ring Done */
    274  1.1    itojun #define	HIFN_DMAIER_C_LAST	0x00000008	/* Command Ring Last */
    275  1.1    itojun #define	HIFN_DMAIER_C_WAIT	0x00000004	/* Command Ring Waiting */
    276  1.4  jonathan #define	HIFN_DMAIER_PUBDONE	0x00000002	/* public op done (7951 only) */
    277  1.1    itojun #define	HIFN_DMAIER_ENGINE	0x00000001	/* Engine IRQ */
    278  1.1    itojun 
    279  1.1    itojun /* DMA Configuration Register (HIFN_1_DMA_CNFG) */
    280  1.1    itojun #define	HIFN_DMACNFG_BIGENDIAN	0x10000000	/* big endian mode */
    281  1.1    itojun #define	HIFN_DMACNFG_POLLFREQ	0x00ff0000	/* Poll frequency mask */
    282  1.1    itojun #define	HIFN_DMACNFG_UNLOCK	0x00000800
    283  1.1    itojun #define	HIFN_DMACNFG_POLLINVAL	0x00000700	/* Invalid Poll Scalar */
    284  1.1    itojun #define	HIFN_DMACNFG_LAST	0x00000010	/* Host control LAST bit */
    285  1.1    itojun #define	HIFN_DMACNFG_MODE	0x00000004	/* DMA mode */
    286  1.1    itojun #define	HIFN_DMACNFG_DMARESET	0x00000002	/* DMA Reset # */
    287  1.1    itojun #define	HIFN_DMACNFG_MSTRESET	0x00000001	/* Master Reset # */
    288  1.1    itojun 
    289  1.4  jonathan /* 7811 RNG Enable Register (HIFN_1_7811_RNGENA) */
    290  1.4  jonathan #define	HIFN_7811_RNGENA_ENA	0x00000001	/* enable RNG */
    291  1.1    itojun 
    292  1.4  jonathan /* 7811 RNG Config Register (HIFN_1_7811_RNGCFG) */
    293  1.4  jonathan #define	HIFN_7811_RNGCFG_PRE1	0x00000f00	/* first prescalar */
    294  1.4  jonathan #define	HIFN_7811_RNGCFG_OPRE	0x00000080	/* output prescalar */
    295  1.4  jonathan #define	HIFN_7811_RNGCFG_DEFL	0x00000f80	/* 2 words/ 1/100 sec */
    296  1.4  jonathan 
    297  1.4  jonathan /* 7811 RNG Status Register (HIFN_1_7811_RNGSTS) */
    298  1.4  jonathan #define	HIFN_7811_RNGSTS_RDY	0x00004000	/* two numbers in FIFO */
    299  1.4  jonathan #define	HIFN_7811_RNGSTS_UFL	0x00001000	/* rng underflow */
    300  1.4  jonathan 
    301  1.4  jonathan /* 7811 MIPS Reset Register (HIFN_1_7811_MIPSRST) */
    302  1.4  jonathan #define	HIFN_MIPSRST_BAR2SIZE	0xffff0000	/* sdram size */
    303  1.4  jonathan #define	HIFN_MIPSRST_GPRAMINIT	0x00008000	/* gpram can be accessed */
    304  1.4  jonathan #define	HIFN_MIPSRST_CRAMINIT	0x00004000	/* ctxram can be accessed */
    305  1.4  jonathan #define	HIFN_MIPSRST_LED2	0x00000400	/* external LED2 */
    306  1.4  jonathan #define	HIFN_MIPSRST_LED1	0x00000200	/* external LED1 */
    307  1.4  jonathan #define	HIFN_MIPSRST_LED0	0x00000100	/* external LED0 */
    308  1.4  jonathan #define	HIFN_MIPSRST_MIPSDIS	0x00000004	/* disable MIPS */
    309  1.4  jonathan #define	HIFN_MIPSRST_MIPSRST	0x00000002	/* warm reset MIPS */
    310  1.4  jonathan #define	HIFN_MIPSRST_MIPSCOLD	0x00000001	/* cold reset MIPS */
    311  1.4  jonathan 
    312  1.9  riastrad /* PLL config register (HIFN_1_PLL) */
    313  1.9  riastrad #define	HIFN_PLL_7956		0x00001d18	/* 7956 PLL config value */
    314  1.9  riastrad 
    315  1.4  jonathan /* Revision ID */
    316  1.4  jonathan #define	HIFN_REVID_7811_PB3_2	0x00000002	/* 7811PB3/2 */
    317  1.4  jonathan 
    318  1.4  jonathan /* Public key reset register (HIFN_1_PUB_RESET) */
    319  1.4  jonathan #define	HIFN_PUBRST_RESET	0x00000001	/* reset public/rng unit */
    320  1.4  jonathan 
    321  1.4  jonathan /* Public base address register (HIFN_1_PUB_BASE) */
    322  1.4  jonathan #define	HIFN_PUBBASE_ADDR	0x00003fff	/* base address */
    323  1.4  jonathan 
    324  1.4  jonathan /* Public operand length register (HIFN_1_PUB_OPLEN) */
    325  1.4  jonathan #define	HIFN_PUBOPLEN_MOD_M	0x0000007f	/* modulus length mask */
    326  1.4  jonathan #define	HIFN_PUBOPLEN_MOD_S	0		/* modulus length shift */
    327  1.4  jonathan #define	HIFN_PUBOPLEN_EXP_M	0x0003ff80	/* exponent length mask */
    328  1.6       wiz #define	HIFN_PUBOPLEN_EXP_S	7		/* exponent length shift */
    329  1.4  jonathan #define	HIFN_PUBOPLEN_RED_M	0x003c0000	/* reducend length mask */
    330  1.4  jonathan #define	HIFN_PUBOPLEN_RED_S	18		/* reducend length shift */
    331  1.4  jonathan 
    332  1.4  jonathan /* Public operation register (HIFN_1_PUB_OP) */
    333  1.4  jonathan #define	HIFN_PUBOP_AOFFSET_M	0x0000007f	/* A offset mask */
    334  1.4  jonathan #define	HIFN_PUBOP_AOFFSET_S	0		/* A offset shift */
    335  1.4  jonathan #define	HIFN_PUBOP_BOFFSET_M	0x00000f80	/* B offset mask */
    336  1.4  jonathan #define	HIFN_PUBOP_BOFFSET_S	7		/* B offset shift */
    337  1.4  jonathan #define	HIFN_PUBOP_MOFFSET_M	0x0003f000	/* M offset mask */
    338  1.4  jonathan #define	HIFN_PUBOP_MOFFSET_S	12		/* M offset shift */
    339  1.4  jonathan #define	HIFN_PUBOP_OP_MASK	0x003c0000	/* Opcode: */
    340  1.4  jonathan #define	HIFN_PUBOP_OP_NOP	0x00000000	/*  NOP */
    341  1.4  jonathan #define	HIFN_PUBOP_OP_ADD	0x00040000	/*  ADD */
    342  1.4  jonathan #define	HIFN_PUBOP_OP_ADDC	0x00080000	/*  ADD w/carry */
    343  1.4  jonathan #define	HIFN_PUBOP_OP_SUB	0x000c0000	/*  SUB */
    344  1.4  jonathan #define	HIFN_PUBOP_OP_SUBC	0x00100000	/*  SUB w/carry */
    345  1.4  jonathan #define	HIFN_PUBOP_OP_MODADD	0x00140000	/*  Modular ADD */
    346  1.4  jonathan #define	HIFN_PUBOP_OP_MODSUB	0x00180000	/*  Modular SUB */
    347  1.4  jonathan #define	HIFN_PUBOP_OP_INCA	0x001c0000	/*  INC A */
    348  1.4  jonathan #define	HIFN_PUBOP_OP_DECA	0x00200000	/*  DEC A */
    349  1.4  jonathan #define	HIFN_PUBOP_OP_MULT	0x00240000	/*  MULT */
    350  1.4  jonathan #define	HIFN_PUBOP_OP_MODMULT	0x00280000	/*  Modular MULT */
    351  1.4  jonathan #define	HIFN_PUBOP_OP_MODRED	0x002c0000	/*  Modular RED */
    352  1.4  jonathan #define	HIFN_PUBOP_OP_MODEXP	0x00300000	/*  Modular EXP */
    353  1.4  jonathan 
    354  1.4  jonathan /* Public status register (HIFN_1_PUB_STATUS) */
    355  1.4  jonathan #define	HIFN_PUBSTS_DONE	0x00000001	/* operation done */
    356  1.4  jonathan #define	HIFN_PUBSTS_CARRY	0x00000002	/* carry */
    357  1.1    itojun 
    358  1.4  jonathan /* Public interrupt enable register (HIFN_1_PUB_IEN) */
    359  1.4  jonathan #define	HIFN_PUBIEN_DONE	0x00000001	/* operation done interrupt */
    360  1.1    itojun 
    361  1.4  jonathan /* Random number generator config register (HIFN_1_RNG_CONFIG) */
    362  1.4  jonathan #define	HIFN_RNGCFG_ENA		0x00000001	/* enable rng */
    363  1.1    itojun 
    364  1.1    itojun /*********************************************************************
    365  1.7     perry  * Structs for board commands
    366  1.1    itojun  *
    367  1.1    itojun  *********************************************************************/
    368  1.1    itojun 
    369  1.1    itojun /*
    370  1.1    itojun  * Structure to help build up the command data structure.
    371  1.1    itojun  */
    372  1.4  jonathan struct hifn_base_command {
    373  1.1    itojun 	volatile u_int16_t masks;
    374  1.1    itojun 	volatile u_int16_t session_num;
    375  1.1    itojun 	volatile u_int16_t total_source_count;
    376  1.1    itojun 	volatile u_int16_t total_dest_count;
    377  1.4  jonathan };
    378  1.1    itojun 
    379  1.4  jonathan #define	HIFN_BASE_CMD_COMP		0x0100	/* enable compression engine */
    380  1.4  jonathan #define	HIFN_BASE_CMD_PAD		0x0200	/* enable padding engine */
    381  1.4  jonathan #define	HIFN_BASE_CMD_MAC		0x0400	/* enable MAC engine */
    382  1.4  jonathan #define	HIFN_BASE_CMD_CRYPT		0x0800	/* enable crypt engine */
    383  1.4  jonathan #define	HIFN_BASE_CMD_DECODE		0x2000
    384  1.4  jonathan #define	HIFN_BASE_CMD_SRCLEN_M		0xc000
    385  1.4  jonathan #define	HIFN_BASE_CMD_SRCLEN_S		14
    386  1.4  jonathan #define	HIFN_BASE_CMD_DSTLEN_M		0x3000
    387  1.4  jonathan #define	HIFN_BASE_CMD_DSTLEN_S		12
    388  1.4  jonathan #define	HIFN_BASE_CMD_LENMASK_HI	0x30000
    389  1.4  jonathan #define	HIFN_BASE_CMD_LENMASK_LO	0x0ffff
    390  1.1    itojun 
    391  1.1    itojun /*
    392  1.1    itojun  * Structure to help build up the command data structure.
    393  1.1    itojun  */
    394  1.4  jonathan struct hifn_crypt_command {
    395  1.1    itojun 	volatile u_int16_t masks;
    396  1.1    itojun 	volatile u_int16_t header_skip;
    397  1.4  jonathan 	volatile u_int16_t source_count;
    398  1.4  jonathan 	volatile u_int16_t reserved;
    399  1.4  jonathan };
    400  1.4  jonathan 
    401  1.4  jonathan #define	HIFN_CRYPT_CMD_ALG_MASK		0x0003		/* algorithm: */
    402  1.4  jonathan #define	HIFN_CRYPT_CMD_ALG_DES		0x0000		/*   DES */
    403  1.4  jonathan #define	HIFN_CRYPT_CMD_ALG_3DES		0x0001		/*   3DES */
    404  1.4  jonathan #define	HIFN_CRYPT_CMD_ALG_RC4		0x0002		/*   RC4 */
    405  1.5  jonathan #define	HIFN_CRYPT_CMD_ALG_AES		0x0003		/*   AES */
    406  1.5  jonathan #define	HIFN_CRYPT_CMD_MODE_MASK	0x0018		/* Encrypt mode: */
    407  1.4  jonathan #define	HIFN_CRYPT_CMD_MODE_ECB		0x0000		/*   ECB */
    408  1.4  jonathan #define	HIFN_CRYPT_CMD_MODE_CBC		0x0008		/*   CBC */
    409  1.4  jonathan #define	HIFN_CRYPT_CMD_MODE_CFB		0x0010		/*   CFB */
    410  1.4  jonathan #define	HIFN_CRYPT_CMD_MODE_OFB		0x0018		/*   OFB */
    411  1.4  jonathan #define	HIFN_CRYPT_CMD_CLR_CTX		0x0040		/* clear context */
    412  1.9  riastrad #define	HIFN_CRYPT_CMD_KSZ_MASK		0x0600		/* AES key size: */
    413  1.9  riastrad #define	HIFN_CRYPT_CMD_KSZ_128		0x0000		/*  128 bit */
    414  1.9  riastrad #define	HIFN_CRYPT_CMD_KSZ_192		0x0200		/*  192 bit */
    415  1.9  riastrad #define	HIFN_CRYPT_CMD_KSZ_256		0x0400		/*  256 bit */
    416  1.4  jonathan #define	HIFN_CRYPT_CMD_NEW_KEY		0x0800		/* expect new key */
    417  1.4  jonathan #define	HIFN_CRYPT_CMD_NEW_IV		0x1000		/* expect new iv */
    418  1.4  jonathan #define	HIFN_CRYPT_CMD_SRCLEN_M		0xc000
    419  1.4  jonathan #define	HIFN_CRYPT_CMD_SRCLEN_S		14
    420  1.5  jonathan 
    421  1.1    itojun /*
    422  1.1    itojun  * Structure to help build up the command data structure.
    423  1.1    itojun  */
    424  1.4  jonathan struct hifn_mac_command {
    425  1.1    itojun 	volatile u_int16_t masks;
    426  1.1    itojun 	volatile u_int16_t header_skip;
    427  1.4  jonathan 	volatile u_int16_t source_count;
    428  1.4  jonathan 	volatile u_int16_t reserved;
    429  1.4  jonathan };
    430  1.4  jonathan 
    431  1.4  jonathan #define	HIFN_MAC_CMD_ALG_MASK		0x0001
    432  1.4  jonathan #define	HIFN_MAC_CMD_ALG_SHA1		0x0000
    433  1.4  jonathan #define	HIFN_MAC_CMD_ALG_MD5		0x0001
    434  1.4  jonathan #define	HIFN_MAC_CMD_MODE_MASK		0x000c
    435  1.4  jonathan #define	HIFN_MAC_CMD_MODE_HMAC		0x0000
    436  1.4  jonathan #define	HIFN_MAC_CMD_MODE_SSL_MAC	0x0004
    437  1.4  jonathan #define	HIFN_MAC_CMD_MODE_HASH		0x0008
    438  1.4  jonathan #define	HIFN_MAC_CMD_MODE_FULL		0x0004
    439  1.4  jonathan #define	HIFN_MAC_CMD_TRUNC		0x0010
    440  1.4  jonathan #define	HIFN_MAC_CMD_RESULT		0x0020
    441  1.4  jonathan #define	HIFN_MAC_CMD_APPEND		0x0040
    442  1.4  jonathan #define	HIFN_MAC_CMD_SRCLEN_M		0xc000
    443  1.4  jonathan #define	HIFN_MAC_CMD_SRCLEN_S		14
    444  1.1    itojun 
    445  1.1    itojun /*
    446  1.4  jonathan  * MAC POS IPsec initiates authentication after encryption on encodes
    447  1.1    itojun  * and before decryption on decodes.
    448  1.1    itojun  */
    449  1.4  jonathan #define	HIFN_MAC_CMD_POS_IPSEC		0x0200
    450  1.4  jonathan #define	HIFN_MAC_CMD_NEW_KEY		0x0800
    451  1.4  jonathan 
    452  1.4  jonathan struct hifn_comp_command {
    453  1.4  jonathan 	volatile u_int16_t masks;
    454  1.4  jonathan 	volatile u_int16_t header_skip;
    455  1.4  jonathan 	volatile u_int16_t source_count;
    456  1.4  jonathan 	volatile u_int16_t reserved;
    457  1.4  jonathan };
    458  1.4  jonathan 
    459  1.4  jonathan #define	HIFN_COMP_CMD_SRCLEN_M		0xc000
    460  1.4  jonathan #define	HIFN_COMP_CMD_SRCLEN_S		14
    461  1.4  jonathan #define	HIFN_COMP_CMD_ONE		0x0100	/* must be one */
    462  1.4  jonathan #define	HIFN_COMP_CMD_CLEARHIST		0x0010	/* clear history */
    463  1.4  jonathan #define	HIFN_COMP_CMD_UPDATEHIST	0x0008	/* update history */
    464  1.4  jonathan #define	HIFN_COMP_CMD_LZS_STRIP0	0x0004	/* LZS: strip zero */
    465  1.4  jonathan #define	HIFN_COMP_CMD_MPPC_RESTART	0x0004	/* MPPC: restart */
    466  1.4  jonathan #define	HIFN_COMP_CMD_ALG_MASK		0x0001	/* compression mode: */
    467  1.4  jonathan #define	HIFN_COMP_CMD_ALG_MPPC		0x0001	/*   MPPC */
    468  1.4  jonathan #define	HIFN_COMP_CMD_ALG_LZS		0x0000	/*   LZS */
    469  1.4  jonathan 
    470  1.4  jonathan struct hifn_base_result {
    471  1.4  jonathan 	volatile u_int16_t flags;
    472  1.4  jonathan 	volatile u_int16_t session;
    473  1.4  jonathan 	volatile u_int16_t src_cnt;		/* 15:0 of source count */
    474  1.4  jonathan 	volatile u_int16_t dst_cnt;		/* 15:0 of dest count */
    475  1.4  jonathan };
    476  1.4  jonathan 
    477  1.4  jonathan #define	HIFN_BASE_RES_DSTOVERRUN	0x0200	/* destination overrun */
    478  1.4  jonathan #define	HIFN_BASE_RES_SRCLEN_M		0xc000	/* 17:16 of source count */
    479  1.4  jonathan #define	HIFN_BASE_RES_SRCLEN_S		14
    480  1.4  jonathan #define	HIFN_BASE_RES_DSTLEN_M		0x3000	/* 17:16 of dest count */
    481  1.4  jonathan #define	HIFN_BASE_RES_DSTLEN_S		12
    482  1.4  jonathan 
    483  1.4  jonathan struct hifn_comp_result {
    484  1.4  jonathan 	volatile u_int16_t flags;
    485  1.4  jonathan 	volatile u_int16_t crc;
    486  1.4  jonathan };
    487  1.4  jonathan 
    488  1.4  jonathan #define	HIFN_COMP_RES_LCB_M		0xff00	/* longitudinal check byte */
    489  1.4  jonathan #define	HIFN_COMP_RES_LCB_S		8
    490  1.4  jonathan #define	HIFN_COMP_RES_RESTART		0x0004	/* MPPC: restart */
    491  1.4  jonathan #define	HIFN_COMP_RES_ENDMARKER		0x0002	/* LZS: end marker seen */
    492  1.4  jonathan #define	HIFN_COMP_RES_SRC_NOTZERO	0x0001	/* source expired */
    493  1.4  jonathan 
    494  1.4  jonathan struct hifn_mac_result {
    495  1.4  jonathan 	volatile u_int16_t flags;
    496  1.4  jonathan 	volatile u_int16_t reserved;
    497  1.4  jonathan 	/* followed by 0, 6, 8, or 10 u_int16_t's of the MAC, then crypt */
    498  1.4  jonathan };
    499  1.4  jonathan 
    500  1.4  jonathan #define	HIFN_MAC_RES_MISCOMPARE		0x0002	/* compare failed */
    501  1.4  jonathan #define	HIFN_MAC_RES_SRC_NOTZERO	0x0001	/* source expired */
    502  1.4  jonathan 
    503  1.4  jonathan struct hifn_crypt_result {
    504  1.4  jonathan 	volatile u_int16_t flags;
    505  1.4  jonathan 	volatile u_int16_t reserved;
    506  1.4  jonathan };
    507  1.4  jonathan 
    508  1.4  jonathan #define	HIFN_CRYPT_RES_SRC_NOTZERO	0x0001	/* source expired */
    509  1.1    itojun 
    510  1.1    itojun /*
    511  1.1    itojun  * The poll frequency and poll scalar defines are unshifted values used
    512  1.1    itojun  * to set fields in the DMA Configuration Register.
    513  1.1    itojun  */
    514  1.1    itojun #ifndef HIFN_POLL_FREQUENCY
    515  1.9  riastrad #define	HIFN_POLL_FREQUENCY	0x1
    516  1.1    itojun #endif
    517  1.1    itojun 
    518  1.1    itojun #ifndef HIFN_POLL_SCALAR
    519  1.9  riastrad #define	HIFN_POLL_SCALAR	0x0
    520  1.1    itojun #endif
    521  1.1    itojun 
    522  1.4  jonathan #define	HIFN_MAX_SEGLEN 	0xffff		/* maximum dma segment len */
    523  1.4  jonathan #define	HIFN_MAX_DMALEN		0x3ffff		/* maximum dma length */
    524  1.1    itojun #endif /* __DEV_PCI_HIFN7751REG_H__ */
    525