#ifndef _DEV_PCI_UBSECVAR_H
#define _DEV_PCI_UBSECVAR_H
#include <sys/types.h>
#include <sys/rndsource.h>
#ifndef UBS_MAX_NQUEUE
#define UBS_MAX_NQUEUE 60
#endif
#define UBS_MAX_SCATTER 64
#ifndef UBS_MAX_AGGR
#define UBS_MAX_AGGR 17
#endif
#ifndef UBS_MIN_AGGR
#define UBS_MIN_AGGR 5
#endif
#define UBSEC_CARD(sid) (((sid) & 0xf0000000) >> 28)
#define UBSEC_SESSION(sid) ( (sid) & 0x0fffffff)
#define UBSEC_SID(crd, sesn) (((crd) << 28) | ((sesn) & 0x0fffffff))
#define UBS_DEF_RTY 0xff
#define UBS_DEF_TOUT 0xff
#define UBS_DEF_CACHELINE 0x01
struct ubsec_dma_alloc {
u_int32_t dma_paddr;
void * dma_vaddr;
bus_dmamap_t dma_map;
bus_dma_segment_t dma_seg;
bus_size_t dma_size;
int dma_nseg;
};
struct ubsec_q2 {
SIMPLEQ_ENTRY(ubsec_q2) q_next;
struct ubsec_dma_alloc q_mcr;
struct ubsec_dma_alloc q_ctx;
u_int q_type;
};
struct ubsec_q2_rng {
struct ubsec_q2 rng_q;
struct ubsec_dma_alloc rng_buf;
int rng_used;
};
#define UBS_MODEXP_PAR_M 0
#define UBS_MODEXP_PAR_E 1
#define UBS_MODEXP_PAR_N 2
struct ubsec_q2_modexp {
struct ubsec_q2 me_q;
struct cryptkop * me_krp;
struct ubsec_dma_alloc me_M;
struct ubsec_dma_alloc me_E;
struct ubsec_dma_alloc me_C;
struct ubsec_dma_alloc me_epb;
int me_modbits;
int me_shiftbits;
int me_normbits;
};
#define UBS_RSAPRIV_PAR_P 0
#define UBS_RSAPRIV_PAR_Q 1
#define UBS_RSAPRIV_PAR_DP 2
#define UBS_RSAPRIV_PAR_DQ 3
#define UBS_RSAPRIV_PAR_PINV 4
#define UBS_RSAPRIV_PAR_MSGIN 5
#define UBS_RSAPRIV_PAR_MSGOUT 6
struct ubsec_q2_rsapriv {
struct ubsec_q2 rpr_q;
struct cryptkop * rpr_krp;
struct ubsec_dma_alloc rpr_msgin;
struct ubsec_dma_alloc rpr_msgout;
};
#define UBSEC_RNG_BUFSIZ 16
struct ubsec_dmachunk {
struct ubsec_mcr d_mcr;
struct ubsec_mcr_add d_mcradd[UBS_MAX_AGGR-1];
struct ubsec_pktbuf d_sbuf[UBS_MAX_SCATTER-1];
struct ubsec_pktbuf d_dbuf[UBS_MAX_SCATTER-1];
u_int32_t d_macbuf[5];
union {
struct ubsec_pktctx_aes256 ctx_aes256;
struct ubsec_pktctx_aes192 ctx_aes192;
struct ubsec_pktctx_aes128 ctx_aes128;
struct ubsec_pktctx_3des ctx_3des;
struct ubsec_pktctx ctx;
} d_ctx;
};
struct ubsec_dma {
SIMPLEQ_ENTRY(ubsec_dma) d_next;
struct ubsec_dmachunk *d_dma;
struct ubsec_dma_alloc d_alloc;
};
#define UBS_FLAGS_KEY 0x01
#define UBS_FLAGS_LONGCTX 0x02
#define UBS_FLAGS_BIGKEY 0x04
#define UBS_FLAGS_HWNORM 0x08
#define UBS_FLAGS_RNG 0x10
#define UBS_FLAGS_AES 0x20
#define UBS_FLAGS_MULTIMCR 0x40
#define UBS_FLAGS_RNG4 0x80
struct ubsec_q {
SIMPLEQ_ENTRY(ubsec_q) q_next;
int q_nstacked_mcrs;
struct ubsec_q *q_stacked_mcr[UBS_MAX_AGGR-1];
struct cryptop *q_crp;
struct ubsec_dma *q_dma;
struct mbuf *q_src_m, *q_dst_m;
struct uio *q_src_io, *q_dst_io;
int q_sesn;
int q_flags;
bus_dmamap_t q_dst_map;
bus_dmamap_t q_src_map;
bus_dmamap_t q_cached_dst_map;
};
struct ubsec_softc {
device_t sc_dev;
void *sc_ih;
kmutex_t sc_mtx;
pci_chipset_tag_t sc_pct;
bus_space_handle_t sc_sh;
bus_space_tag_t sc_st;
bus_dma_tag_t sc_dmat;
int sc_flags;
int sc_suspended;
int sc_needwakeup;
u_int32_t sc_statmask;
int32_t sc_cid;
int sc_maxaggr;
SIMPLEQ_HEAD(,ubsec_q) sc_queue;
int sc_nqueue;
SIMPLEQ_HEAD(,ubsec_q) sc_qchip;
int sc_nqchip;
SIMPLEQ_HEAD(,ubsec_q) sc_freequeue;
SIMPLEQ_HEAD(,ubsec_q2) sc_queue2;
int sc_nqueue2;
SIMPLEQ_HEAD(,ubsec_q2) sc_qchip2;
SIMPLEQ_HEAD(,ubsec_q2) sc_queue4;
int sc_nqueue4;
SIMPLEQ_HEAD(,ubsec_q2) sc_qchip4;
int sc_nsessions;
struct ubsec_session *sc_sessions;
struct callout sc_rngto;
int sc_rnghz;
struct ubsec_q2_rng sc_rng;
krndsource_t sc_rnd_source;
int sc_rng_need;
struct ubsec_dma sc_dmaa[UBS_MAX_NQUEUE];
struct ubsec_q *sc_queuea[UBS_MAX_NQUEUE];
SIMPLEQ_HEAD(,ubsec_q2) sc_q2free;
bus_size_t sc_memsize;
};
struct ubsec_session {
u_int32_t ses_used;
u_int32_t ses_key[8];
u_int32_t ses_hminner[5];
u_int32_t ses_hmouter[5];
u_int32_t ses_iv[4];
};
struct ubsec_stats {
u_int64_t hst_ibytes;
u_int64_t hst_obytes;
u_int32_t hst_ipackets;
u_int32_t hst_opackets;
u_int32_t hst_invalid;
u_int32_t hst_badsession;
u_int32_t hst_badflags;
u_int32_t hst_nodesc;
u_int32_t hst_badalg;
u_int32_t hst_nomem;
u_int32_t hst_queuefull;
u_int32_t hst_dmaerr;
u_int32_t hst_mcrerr;
u_int32_t hst_nodmafree;
u_int32_t hst_lenmismatch;
u_int32_t hst_skipmismatch;
u_int32_t hst_iovmisaligned;
u_int32_t hst_noirq;
u_int32_t hst_unaligned;
u_int32_t hst_nomap;
u_int32_t hst_noload;
u_int32_t hst_nombuf;
u_int32_t hst_nomcl;
u_int32_t hst_totbatch;
u_int32_t hst_maxbatch;
u_int32_t hst_maxqueue;
u_int32_t hst_maxqchip;
u_int32_t hst_mcr1full;
u_int32_t hst_rng;
u_int32_t hst_modexp;
u_int32_t hst_modexpcrt;
};
#endif