Changeset View
Changeset View
Standalone View
Standalone View
sys/opencrypto/cryptodev.h
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
* Materiel Command, USAF, under agreement number F30602-01-2-0537. | * Materiel Command, USAF, under agreement number F30602-01-2-0537. | ||||
* | * | ||||
*/ | */ | ||||
#ifndef _CRYPTO_CRYPTO_H_ | #ifndef _CRYPTO_CRYPTO_H_ | ||||
#define _CRYPTO_CRYPTO_H_ | #define _CRYPTO_CRYPTO_H_ | ||||
#include <sys/ioccom.h> | #include <sys/ioccom.h> | ||||
#include <machine/vmparam.h> | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#include <opencrypto/_cryptodev.h> | #include <opencrypto/_cryptodev.h> | ||||
#include <sys/_task.h> | #include <sys/_task.h> | ||||
#endif | #endif | ||||
/* Some initial values */ | /* Some initial values */ | ||||
#define CRYPTO_DRIVERS_INITIAL 4 | #define CRYPTO_DRIVERS_INITIAL 4 | ||||
▲ Show 20 Lines • Show All 308 Lines • ▼ Show 20 Lines | int csp_auth_mlen; /* Number of digest bytes to use. | ||||
0 means all. */ | 0 means all. */ | ||||
}; | }; | ||||
enum crypto_buffer_type { | enum crypto_buffer_type { | ||||
CRYPTO_BUF_NONE = 0, | CRYPTO_BUF_NONE = 0, | ||||
CRYPTO_BUF_CONTIG, | CRYPTO_BUF_CONTIG, | ||||
CRYPTO_BUF_UIO, | CRYPTO_BUF_UIO, | ||||
CRYPTO_BUF_MBUF, | CRYPTO_BUF_MBUF, | ||||
#if PMAP_HAS_DMAP | |||||
CRYPTO_BUF_VMPAGE, | |||||
CRYPTO_BUF_LAST = CRYPTO_BUF_VMPAGE | |||||
#else | |||||
CRYPTO_BUF_LAST = CRYPTO_BUF_MBUF | CRYPTO_BUF_LAST = CRYPTO_BUF_MBUF | ||||
#endif /* PMAP_HAS_DMAP */ | |||||
}; | }; | ||||
/* | /* | ||||
* Description of a data buffer for a request. Requests can either | * Description of a data buffer for a request. Requests can either | ||||
* have a single buffer that is modified in place or separate input | * have a single buffer that is modified in place or separate input | ||||
* and output buffers. | * and output buffers. | ||||
*/ | */ | ||||
struct crypto_buffer { | struct crypto_buffer { | ||||
union { | union { | ||||
struct { | struct { | ||||
char *cb_buf; | char *cb_buf; | ||||
int cb_buf_len; | int cb_buf_len; | ||||
}; | }; | ||||
struct mbuf *cb_mbuf; | struct mbuf *cb_mbuf; | ||||
#if PMAP_HAS_DMAP | |||||
struct { | |||||
vm_page_t *cb_vm_page; | |||||
int cb_vm_page_len; | |||||
int cb_vm_page_offset; | |||||
}; | |||||
#endif /* PMAP_HAS_DMAP */ | |||||
struct uio *cb_uio; | struct uio *cb_uio; | ||||
}; | }; | ||||
enum crypto_buffer_type cb_type; | enum crypto_buffer_type cb_type; | ||||
}; | }; | ||||
/* | /* | ||||
* A cursor is used to iterate through a crypto request data buffer. | * A cursor is used to iterate through a crypto request data buffer. | ||||
*/ | */ | ||||
struct crypto_buffer_cursor { | struct crypto_buffer_cursor { | ||||
union { | union { | ||||
char *cc_buf; | char *cc_buf; | ||||
struct mbuf *cc_mbuf; | struct mbuf *cc_mbuf; | ||||
struct iovec *cc_iov; | struct iovec *cc_iov; | ||||
#if PMAP_HAS_DMAP | |||||
vm_page_t *cc_vm_page; | |||||
#endif /* PMAP_HAS_DMAP */ | |||||
}; | }; | ||||
union { | /* Optional bytes of valid data remaining */ | ||||
int cc_buf_len; | int cc_buf_len; | ||||
/* | |||||
* Optional offset within the current buffer segment where | |||||
* valid data begins | |||||
*/ | |||||
size_t cc_offset; | size_t cc_offset; | ||||
jhb: In general style(9) wants a blank line before comments (here and many other places throughout) | |||||
}; | |||||
enum crypto_buffer_type cc_type; | enum crypto_buffer_type cc_type; | ||||
}; | }; | ||||
/* Structure describing complete operation */ | /* Structure describing complete operation */ | ||||
struct cryptop { | struct cryptop { | ||||
TAILQ_ENTRY(cryptop) crp_next; | TAILQ_ENTRY(cryptop) crp_next; | ||||
struct task crp_task; | struct task crp_task; | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
static __inline void | static __inline void | ||||
_crypto_use_mbuf(struct crypto_buffer *cb, struct mbuf *m) | _crypto_use_mbuf(struct crypto_buffer *cb, struct mbuf *m) | ||||
{ | { | ||||
cb->cb_mbuf = m; | cb->cb_mbuf = m; | ||||
cb->cb_type = CRYPTO_BUF_MBUF; | cb->cb_type = CRYPTO_BUF_MBUF; | ||||
} | } | ||||
#if PMAP_HAS_DMAP | |||||
static __inline void | static __inline void | ||||
_crypto_use_vm_page(struct crypto_buffer *cb, vm_page_t *pages, int len, | |||||
int offset) | |||||
{ | |||||
cb->cb_vm_page = pages; | |||||
cb->cb_vm_page_len = len; | |||||
cb->cb_vm_page_offset = offset; | |||||
cb->cb_type = CRYPTO_BUF_VMPAGE; | |||||
} | |||||
#endif /* PMAP_HAS_DMAP */ | |||||
static __inline void | |||||
_crypto_use_uio(struct crypto_buffer *cb, struct uio *uio) | _crypto_use_uio(struct crypto_buffer *cb, struct uio *uio) | ||||
{ | { | ||||
cb->cb_uio = uio; | cb->cb_uio = uio; | ||||
cb->cb_type = CRYPTO_BUF_UIO; | cb->cb_type = CRYPTO_BUF_UIO; | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_buf(struct cryptop *crp, void *buf, int len) | crypto_use_buf(struct cryptop *crp, void *buf, int len) | ||||
{ | { | ||||
_crypto_use_buf(&crp->crp_buf, buf, len); | _crypto_use_buf(&crp->crp_buf, buf, len); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_mbuf(struct cryptop *crp, struct mbuf *m) | crypto_use_mbuf(struct cryptop *crp, struct mbuf *m) | ||||
{ | { | ||||
_crypto_use_mbuf(&crp->crp_buf, m); | _crypto_use_mbuf(&crp->crp_buf, m); | ||||
} | } | ||||
#if PMAP_HAS_DMAP | |||||
static __inline void | static __inline void | ||||
crypto_use_vm_page(struct cryptop *crp, vm_page_t *pages, int len, | |||||
int offset) | |||||
{ | |||||
_crypto_use_vm_page(&crp->crp_buf, pages, len, offset); | |||||
} | |||||
#endif /* PMAP_HAS_DMAP */ | |||||
static __inline void | |||||
crypto_use_uio(struct cryptop *crp, struct uio *uio) | crypto_use_uio(struct cryptop *crp, struct uio *uio) | ||||
{ | { | ||||
_crypto_use_uio(&crp->crp_buf, uio); | _crypto_use_uio(&crp->crp_buf, uio); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_output_buf(struct cryptop *crp, void *buf, int len) | crypto_use_output_buf(struct cryptop *crp, void *buf, int len) | ||||
{ | { | ||||
_crypto_use_buf(&crp->crp_obuf, buf, len); | _crypto_use_buf(&crp->crp_obuf, buf, len); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_output_mbuf(struct cryptop *crp, struct mbuf *m) | crypto_use_output_mbuf(struct cryptop *crp, struct mbuf *m) | ||||
{ | { | ||||
_crypto_use_mbuf(&crp->crp_obuf, m); | _crypto_use_mbuf(&crp->crp_obuf, m); | ||||
} | } | ||||
#if PMAP_HAS_DMAP | |||||
static __inline void | |||||
crypto_use_output_vm_page(struct cryptop *crp, vm_page_t *pages, int len, | |||||
int offset) | |||||
{ | |||||
_crypto_use_vm_page(&crp->crp_obuf, pages, len, offset); | |||||
} | |||||
#endif /* PMAP_HAS_DMAP */ | |||||
static __inline void | static __inline void | ||||
crypto_use_output_uio(struct cryptop *crp, struct uio *uio) | crypto_use_output_uio(struct cryptop *crp, struct uio *uio) | ||||
{ | { | ||||
_crypto_use_uio(&crp->crp_obuf, uio); | _crypto_use_uio(&crp->crp_obuf, uio); | ||||
} | } | ||||
#define CRYPTOP_ASYNC(crp) \ | #define CRYPTOP_ASYNC(crp) \ | ||||
▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines |
In general style(9) wants a blank line before comments (here and many other places throughout)