MCPcopy Create free account
hub / github.com/F-Stack/f-stack / blake2_attach

Function blake2_attach

freebsd/crypto/blake2/blake2_cryptodev.c:118–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118static int
119blake2_attach(device_t dev)
120{
121 struct blake2_softc *sc;
122 int i;
123
124 sc = device_get_softc(dev);
125 sc->dying = false;
126
127 sc->cid = crypto_get_driverid(dev, sizeof(struct blake2_session),
128 CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_SYNC |
129 CRYPTOCAP_F_ACCEL_SOFTWARE);
130 if (sc->cid < 0) {
131 device_printf(dev, "Could not get crypto driver id.\n");
132 return (ENOMEM);
133 }
134
135 ctx_mtx = malloc(sizeof(*ctx_mtx) * (mp_maxid + 1), M_BLAKE2,
136 M_WAITOK | M_ZERO);
137 ctx_fpu = malloc(sizeof(*ctx_fpu) * (mp_maxid + 1), M_BLAKE2,
138 M_WAITOK | M_ZERO);
139
140 CPU_FOREACH(i) {
141#ifdef __amd64__
142 ctx_fpu[i] = fpu_kern_alloc_ctx_domain(
143 pcpu_find(i)->pc_domain, FPU_KERN_NORMAL);
144#else
145 ctx_fpu[i] = fpu_kern_alloc_ctx(FPU_KERN_NORMAL);
146#endif
147 mtx_init(&ctx_mtx[i], "bl2fpumtx", NULL, MTX_DEF | MTX_NEW);
148 }
149
150 rw_init(&sc->lock, "blake2_lock");
151
152 return (0);
153}
154
155static int
156blake2_detach(device_t dev)

Callers

nothing calls this directly

Calls 9

device_get_softcFunction · 0.85
crypto_get_driveridFunction · 0.85
device_printfFunction · 0.85
mallocFunction · 0.85
pcpu_findFunction · 0.85
mtx_initFunction · 0.85
rw_initFunction · 0.85
fpu_kern_alloc_ctxFunction · 0.50

Tested by

no test coverage detected