Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / hypervisor / src / include / ncs_api.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* Hypervisor Software File: ncs_api.h
5*
6* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
7*
8* - Do no alter or remove copyright notices
9*
10* - Redistribution and use of this software in source and binary forms, with
11* or without modification, are permitted provided that the following
12* conditions are met:
13*
14* - Redistribution of source code must retain the above copyright notice,
15* this list of conditions and the following disclaimer.
16*
17* - Redistribution in binary form must reproduce the above copyright notice,
18* this list of conditions and the following disclaimer in the
19* documentation and/or other materials provided with the distribution.
20*
21* Neither the name of Sun Microsystems, Inc. or the names of contributors
22* may be used to endorse or promote products derived from this software
23* without specific prior written permission.
24*
25* This software is provided "AS IS," without a warranty of any kind.
26* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
27* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
28* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
29* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
30* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
31* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
32* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
33* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
34* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
35* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
36* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
37*
38* You acknowledge that this software is not designed, licensed or
39* intended for use in the design, construction, operation or maintenance of
40* any nuclear facility.
41*
42* ========== Copyright Header End ============================================
43*/
44/*
45 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
46 * Use is subject to license terms.
47 */
48
49#ifndef _NCS_API_H
50#define _NCS_API_H
51
52#pragma ident "@(#)ncs_api.h 1.4 07/05/03 SMI"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#include <mau_api.h>
59
60/*
61 * NCS API v1.0 definitions (PSARC/2005/125)
62 */
63
64/*
65 * NCS Crypto Function Numbers
66 */
67#define NCS_V10_QCONF 0x1
68#define NCS_V10_QTAIL_UPDATE 0x2
69
70/*
71 * The following are parameters to the NCS_QTAIL_UPDATE calls:
72 *
73 * NCS_SYNC Perform MA/SPU operations synchronously,
74 * i.e. wait for all enqueued operations
75 * to complete before progressing to
76 * next one.
77 * NCS_ASYNC Perform MA/SPU operations asynchronously,
78 * i.e. kick off the next MA/SPU operation
79 * without waiting for its completion.
80 */
81#define NCS_SYNC 0
82#define NCS_ASYNC 1
83
84/*
85 * Pointers passed to NCS must be on 8-byte boundary.
86 */
87#define NCS_PTR_ALIGN 8
88
89/*
90 * CWQ pointers must be on 64-byte boundary.
91 */
92#define NCS_CWQ_PTR_ALIGN 64
93
94#ifndef _ASM
95
96typedef struct ncs_qconf_arg {
97 uint64_t nq_mid;
98 uint64_t nq_base;
99 uint64_t nq_end;
100 uint64_t nq_nentries;
101} ncs_qconf_arg_t;
102
103typedef struct ncs_qtail_update_arg {
104 uint64_t nu_mid;
105 uint64_t nu_tail;
106 uint64_t nu_syncflag;
107} ncs_qtail_update_arg_t;
108
109/*
110 * The interface to the MAU is via the following data structures. The
111 * structure consists of a copy of all relevant registers required to perform
112 * the requested operation.
113 */
114typedef struct ma_regs {
115 union ma_ctl mr_ctl;
116 union ma_mpa mr_mpa;
117 union ma_ma mr_ma;
118 uint64_t mr_np;
119} ma_regs_t;
120
121typedef union cwq_cw_ret {
122 uint64_t cw_ret_dst_addr;
123 uint64_t cw_ret_csr;
124} cwq_cw_ret_t;
125
126typedef struct cwq_cw {
127 uint64_t cw_ctlbits;
128 uint64_t cw_src_addr;
129 uint64_t cw_auth_key_addr;
130 uint64_t cw_auth_iv_addr;
131 uint64_t cw_final_auth_state_addr;
132 uint64_t cw_enc_key_addr;
133 uint64_t cw_enc_iv_addr;
134 cwq_cw_ret_t cw_ret;
135} cwq_cw_t;
136
137#endif /* !_ASM */
138
139/*
140 * struct ncs_hvdesc.nhd_state
141 */
142#define ND_STATE_FREE 0
143#define ND_STATE_PENDING 1
144#define ND_STATE_BUSY 2
145#define ND_STATE_DONE 3
146#define ND_STATE_ERROR 4
147/*
148 * struct ncs_hvdesc.nhd_type
149 */
150#define ND_TYPE_UNASSIGNED 0x00
151#define ND_TYPE_MA 0x01
152
153#ifndef _ASM
154/*
155 * NCS HV descriptor structure (ncs_hvdesc) MUST MATCH
156 * corresponding one in kernel/driver.
157 * Structure padded to the next power of 2.
158 */
159struct ncs_hvdesc {
160 uint64_t nhd_state; /* set in OS/HV */
161 uint64_t nhd_type; /* set in OS */
162 ma_regs_t nhd_regs; /* used in HV */
163 uint64_t nhd_errstatus; /* set in HV (v2.0) */
164 uint64_t _padding;
165};
166
167#endif /* !_ASM */
168
169/*
170 * NCS HV API v2.0 definitions (FWARC/2006/174)
171 *
172 * Some of the structures above (v1.0) are inherited for v2.0
173 */
174/*
175 * In v2.0, the nhd_type field has the following values
176 * when non-zero (unassigned). The nhd_type field indicates
177 * whether the descriptor is the beginning of a crypto job,
178 * the continuation, or the end/last descriptor in a job.
179 * A job may be comprised of multiple descriptors.
180 */
181#define ND_TYPE_START 0x01
182#define ND_TYPE_CONT 0x02
183#define ND_TYPE_END 0x80
184
185#define ND_ERR_OK 0x00
186#define ND_ERR_INVOP 0x01
187#define ND_ERR_HWE 0x02
188
189/*
190 * Types of queues supported by NCS
191 */
192#define NCS_QTYPE_MAU 0x1
193#define NCS_QTYPE_CWQ 0x2
194
195#ifdef __cplusplus
196}
197#endif
198
199#endif /* _NCS_API_H */