/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_CRYPTO_DCA_H
#define _SYS_CRYPTO_DCA_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Deimos - cryptographic acceleration based upon Broadcom 582x.
*
* Note: Everything in this file is private to the Deimos device
* driver! Do not include this in any other file.
*/
#ifdef _KERNEL
/*
* Tunables.
*/
/*
* These are constants. Do not change them.
*/
#else
#endif
/*
* Mechanism info structure passed to KCF during registration.
*/
/*
* RSA implementation.
*/
#define DCA_RSA_ENC 0
/*
* DSA implementation.
*/
#define DCA_DSA_SIGN 0
/*
* FMA eclass index definitions. Note that this enum must be consistent
* with the dca_fma_eclass_sca1000 and dca_fma_eclass_sca500 string arrays.
*/
typedef enum dca_fma_eclass {
/*
* Forward typedefs.
*/
/*
* This structure is used to identify a specific board.
*/
struct dca_device {
char *dd_model;
};
/*
* Structure representing a node in a DMA chain. (Broadcom calls
* these "Data Buffer Chain Entries".)
*
* note, this structure must be a multiple of sizeof (intptr_t)
*/
struct dca_chain {
/* the descriptor */
/* and the buffer to which it points */
/* physical addresses */
};
/*
* Linked-list linkage.
*/
struct dca_listnode {
};
typedef enum dca_mech_type {
struct dca_rng {
};
union dca_parameters {
};
typedef struct dca_ctx {
/*
* The following are context fields for Deimos 2.0.
*/
/* Fields for RSA and DSA */
/* Fields for DES and 3DES */
int residlen;
int activeresidlen;
} dca_ctx_t;
/*
* Work structure. One of these per actual job submitted to an MCR.
* Contains everything we need to submit the job, and everything we
* need to notify caller and release resources when the completion
* interrupt comes.
*/
struct dca_request {
/*
* Consumer's I/O buffers.
*/
/*
* Chains and DMA structures.
*/
/*
* Scratch input buffer.
*/
/*
* Scratch output buffer.
*/
/*
* Values to program MCR with.
*/
/*
* Callback.
*/
/*
* Other stuff.
*/
/*
* Algorithm specific parameters.
*/
void *dr_context;
/*
* Statistics.
*/
int dr_job_stat;
int dr_byte_stat;
/* Pre-mapped input and output data buffer chain support */
/*
* User buffers are mapped to DMA handles dynamically. The physically
* contigous blocks ( >= a page) are built into a data buffer chain.
*/
/* Offset in the context page for storing dynamic buffer chains */
int dr_offset;
/* Destroy this request if true */
int destroy;
};
/*
* Request flags (dca_request_t.dr_flags).
*/
struct dca_work {
/* DMA access to the MCR and context */
};
/*
* MCRs.
*/
struct dca_worklist {
int dwl_mcr;
int dwl_count;
int dwl_busy;
int dwl_lowater;
int dwl_hiwater;
int dwl_reqspermcr;
/* Kstats */
};
/*
* Operations for MCR1 (bulk stuff).
*/
/*
* Operations for MCR2 (key stuff).
*/
/*
* Kstats.
*/
#define DS_3DESJOBS 0
#if 0
/*
* note that when reenabling any of these stats, DS_MAX will need to
* be adjusted.
*/
#define DS_RC4JOBS 11
#define DS_RC4BYTES 12
#define DS_DHPUBLIC 13
#define DS_DHSECRET 14
#endif
struct dca_stat {
struct {
};
/*
* Blocking structure for ioctls.
*/
struct dca_cookie {
int dc_outstanding;
int dc_status;
};
/*
* Per instance structure.
*/
struct dca {
/*
* Work requests.
*/
/*
* hardware model
*/
char *dca_model;
/*
* Kstats. There is no standard for what standards
* Cryptographic Providers should supply, so we're
* making them up for now.
*/
/* For the local random number pool used internally by the dca driver */
char *dca_buf1;
char *dca_buf2;
char *dca_buf_ptr;
int dca_index;
/* FMA capabilities */
};
/*
* Device flags (dca_t.dca_flags)
*/
/*
*/
typedef enum dca_sg_param {
#define FALSE 0
/*
* PCI configuration registers.
*/
/*
* PCI configuration register bit values.
*/
/* Note: 5820 errata: BIST feature does not work */
/*
* Command and Status Registers.
*/
/*
* Command and status register bits.
*/
/*
* Offsets of things relative to an MCR.
*/
/*
* Basis for size (should be optimized by constant folding):
* 4 bytes for flags and #packets.
* for each packet:
* 2 descriptors (DESC_SIZE)
* 4 bytes for context address
* 4 bytes for packet length and reserved
*/
/*
* MCR flags.
*/
/*
* Fields within a descriptor (data buffer chain).
*/
/*
* Offsets of fields within context structures, see Broadcom spec.
*/
/*
* Values for specific operations.
*/
/*
* Macros to access fields within the MCR. Note that this includes the
* context fields as well, since the context is just offset from the
* base of the MCR.
*/
/* XXX: define the GET forms for descriptors only if needed */
/*
* Register access.
*/
/*
* Used to guarantee alignment.
*/
/*
* Driver hardening related.
*/
/*
* Other utility macros.
*/
/*
* Debug stuff.
*/
#ifdef DEBUG
void dca_dprintf(dca_t *, int, const char *, ...);
#else
#endif
/*
* Some pkcs#11 defines as there are no pkcs#11 header files included.
*/
/*
* Driver globals.
*/
extern int dca_mindma;
extern int dca_hardening;
/*
* Prototypes.
*/
/*
*/
void dca_diperror(dev_info_t *, const char *, ...);
/*
*/
int, int);
crypto_req_handle_t, int);
crypto_req_handle_t, int);
int, crypto_req_handle_t, int);
void dca_3desctxfree(void *);
/*
*/
crypto_req_handle_t, int);
void dca_rsactxfree(void *);
int, crypto_req_handle_t, int);
/*
*/
int);
void dca_dsactxfree(void *);
int, crypto_req_handle_t, int);
/*
*/
int dca_random_init();
void dca_random_fini();
/*
*/
void dca_ksinit(dca_t *);
/*
* dca.c
*/
void dca_rmqueue(dca_listnode_t *);
void dca_freereq(dca_request_t *);
int dca_unbindchains(dca_request_t *);
void dca_done(dca_request_t *, int);
void dca_destroyreq(dca_request_t *);
int dca_length(crypto_data_t *);
int dca_gather(crypto_data_t *, char *, int, int);
int dca_resid_gather(crypto_data_t *, char *, int *, char *, int);
int dca_scatter(const char *, crypto_data_t *, int, int);
uint32_t *);
uint64_t, void **, unsigned int *);
void dca_rcoalesce(dca_request_t *, int);
void dca_runcoalesce(dca_request_t *);
int dca_bitlen(unsigned char *, int);
uint16_t dca_padhalf(int);
uint16_t dca_padfull(int);
void dca_reverse(void *, void *, int, int);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_CRYPTO_DCA_H */