1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #define NOCT_RNG_QLEN 15
35 #define NOCT_RNG_ENTRIES (1 << NOCT_RNG_QLEN)
36 #define NOCT_RNG_BUFSIZE (NOCT_RNG_ENTRIES * sizeof(u_int64_t))
37
38 #define NOCT_PKH_QLEN 15
39 #define NOCT_PKH_ENTRIES (1 << NOCT_PKH_QLEN)
40 #define NOCT_PKH_BUFSIZE (NOCT_PKH_ENTRIES * sizeof(union noct_pkh_cmd))
41
42 #define NOCT_EA_QLEN 15
43 #define NOCT_EA_ENTRIES (1 << NOCT_EA_QLEN)
44 #define NOCT_EA_BUFSIZE (NOCT_EA_ENTRIES * sizeof(struct noct_ea_cmd))
45
46 #define NOCT_BN_CACHE_SIZE ((256) * (128 / 8))
47
48 struct noct_workq {
49 SIMPLEQ_ENTRY(noct_workq) q_next;
50 struct cryptop *q_crp;
51 bus_dmamap_t q_dmamap;
52 bus_dma_segment_t q_dmaseg;
53 caddr_t q_buf;
54 u_int8_t q_macbuf[20];
55 };
56
57 struct noct_softc;
58
59 struct noct_bnc_sw {
60 u_long bn_off;
61 u_long bn_siz;
62 void (*bn_callback)(struct noct_softc *, u_int32_t, int);
63 struct cryptkop *bn_krp;
64 };
65
66 struct noct_softc {
67 struct device sc_dv;
68 bus_space_tag_t sc_st;
69 bus_space_handle_t sc_sh;
70 bus_dma_tag_t sc_dmat;
71 void *sc_ih;
72 bus_size_t sc_rar_last, sc_waw_last;
73 u_int sc_ramsize;
74 int32_t sc_cid;
75
76 u_int64_t *sc_rngbuf;
77 bus_dmamap_t sc_rngmap;
78 struct timeout sc_rngto;
79 int sc_rngtick;
80
81 bus_dmamap_t sc_pkhmap;
82 bus_dmamap_t sc_bnmap;
83 union noct_pkh_cmd *sc_pkhcmd;
84 u_int8_t *sc_bncache;
85 u_int32_t sc_pkhwp;
86 u_int32_t sc_pkhrp;
87 struct extent *sc_pkh_bn;
88 struct noct_bnc_sw sc_pkh_bnsw[NOCT_PKH_ENTRIES];
89
90 bus_dmamap_t sc_eamap;
91 u_int32_t sc_eawp;
92 u_int32_t sc_earp;
93 struct noct_ea_cmd *sc_eacmd;
94
95 SIMPLEQ_HEAD(,noct_workq) sc_inq;
96 SIMPLEQ_HEAD(,noct_workq) sc_chipq;
97 SIMPLEQ_HEAD(,noct_workq) sc_outq;
98 };
99
100 #define NOCT_READ_4(sc,r) noct_read_4((sc), (r))
101 #define NOCT_WRITE_4(sc,r,v) noct_write_4((sc), (r), (v))
102 #define NOCT_READ_8(sc,r) noct_read_8((sc), (r))
103 #define NOCT_WRITE_8(sc,r,v) noct_write_8((sc), (r), (v))
104
105 #define NOCT_CARD(sid) (((sid) & 0xf0000000) >> 28)
106 #define NOCT_SESSION(sid) ( (sid) & 0x0fffffff)
107 #define NOCT_SID(crd, sesn) (((crd) << 28) | ((sesn) & 0x0fffffff))
108
109 #define NOCT_WAKEUP(sc) wakeup(&(sc)->sc_eawp)
110 #define NOCT_SLEEP(sc) tsleep(&(sc)->sc_eawp, PWAIT, "noctea", 0)
111