Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / n8 / nsp.h
blob50dde5873a207808b609b543270e3f9aa53e6cb0
1 /*-
2 * Copyright (c) 2008 The NetBSD Foundation, Inc.
3 * All rights reserved.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Coyote Point Systems, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _NSP_H
32 #include <dev/pci/pcireg.h>
33 #include <dev/pci/pcivar.h>
34 #include <dev/pci/pcidevs.h>
35 #include <dev/pci/pcidevs.h>
36 #include <opencrypto/cryptodev.h>
37 #include "n8_driver_main.h"
38 #include "n8_pub_symmetric.h"
39 #include "n8_pub_packet.h"
40 #include "config.h"
42 #ifndef PCI_VENDOR_NETOCTAVE
43 #define PCI_VENDOR_NETOCTAVE 0x170b
44 #endif
45 #ifndef PCI_PRODUCT_NETOCTAVE_NSP2000
46 #define PCI_PRODUCT_NETOCTAVE_NSP2000 0x100
47 #endif
49 #define NSP_BAR0 (PCI_MAPREG_START + 0) /* PUC register map */
50 #define NSP_BAR1 (PCI_MAPREG_START + 4) /* DMA register map */
51 #define NSP_TRDY_TIMEOUT 0x40 /* TRDY timeout */
52 #define NSP_RETRY_TIMEOUT 0x41 /* DMA retry timeout */
54 /* DEBUG MESSAGE BIT SELECTORS */
55 #define N8_DBG_GENERAL 1
56 #define N8_DBG_IRQ 2
57 #define N8_DBG_BIGALLOC 4
58 #define N8_DBG_DISPLAY_MEMORY 8
59 #define N8_DBG_DISPLAY_CONTEXT 16
60 #define N8_DBG_DISPLAY_REGISTERS 32
61 #define N8_DBG_DISPLAY_QMGR 64
63 #define DEBUG_GENERAL (N8_Debug_g & N8_DBG_GENERAL)
64 #define DEBUG_IRQ (N8_Debug_g & N8_DBG_IRQ)
65 #define DEBUG_BIGALLOC (N8_Debug_g & N8_DBG_BIGALLOC)
66 #define APRINT if (DEBUG_GENERAL) printf
68 /* The following two values are inSilicon PCI test registers that need */
69 /* to be set to the PCI standards rather than their defaults. */
70 #define INSILICON_PCI_TRDY_TIMEOUT 0x40
71 #define INSILICON_PCI_RETRY_TIMEOUT 0x41
73 #define NSP_MAX_SESSION 1024
74 #define NSP_MAX_KEY_LEN (256*8)
75 #define NSP_MAX_KEY_BYTES ((NSP_MAX_KEY_LEN+7)/8)
77 #define NSP_STATE_INIT 0
79 typedef struct nsp_session {
80 uint32_t magic;
81 uint32_t sid;
82 struct nsp_softc *sc;
83 N8_ContextHandle_t contextHandle; /* Context memory handle */
84 int contextAllocated; /* Boolean flag for cleanup of context */
86 N8_EncryptObject_t crypt; /* Encrypt/Decrypt control data */
87 N8_EncryptCipher_t cipherInfo;
88 uint8_t iv[16];
90 uint8_t mackey[64];
91 uint8_t mackeylen;
93 N8_HashObject_t hash;
95 void *crp_opaque; /* user data to return with result */
96 struct cryptop *crp; /* complete crypto op */
97 struct cryptodesc *crd; /* active crypto op */
98 int crd_id; /* active crd index */
100 int active; /* Boolean: operation active on session */
101 int state;
103 union {
104 struct mbuf *mb;
105 struct uio *io;
106 N8_Buffer_t *ptr;
107 } src;
108 union {
109 struct mbuf *mb;
110 struct uio *io;
111 N8_Buffer_t *ptr;
112 } dst;
113 N8_Buffer_t *mac; /* IOV mode means direct copy for hashes.... !? */
115 struct nsp_session *next; /* next free */
116 } nsp_session_t;
118 struct nsp_softc {
119 struct device device;
120 pci_chipset_tag_t pa_pc;
121 pcitag_t pa_tag;
122 void *int_handle;
123 kmutex_t sc_intrlock;
125 bus_space_handle_t mem_handle;
126 bus_space_tag_t mem_tag;
127 bus_size_t mem_size;
128 bus_dma_tag_t dma_tag;
129 bus_dmamap_t dmamap;
130 int mem_mapped;
131 uint32_t flags;
132 int unit;
133 int sc_suspended;
134 int sc_needwakeup; /* notify crypto layer */
135 u_int32_t sc_statmask; /* interrupt status mask */
136 int32_t cid; /* crypto tag */
137 NspInstance_t *nip;
138 int usage_count;
139 nsp_session_t session[NSP_MAX_SESSION];
140 nsp_session_t *freesession; /* first free session */
143 #endif /* _NSP_H */