| 317 | } |
| 318 | |
| 319 | static int |
| 320 | crypto_init(void) |
| 321 | { |
| 322 | struct crypto_ret_worker *ret_worker; |
| 323 | int error; |
| 324 | |
| 325 | mtx_init(&crypto_drivers_mtx, "crypto", "crypto driver table", |
| 326 | MTX_DEF|MTX_QUIET); |
| 327 | |
| 328 | TAILQ_INIT(&crp_q); |
| 329 | TAILQ_INIT(&crp_kq); |
| 330 | mtx_init(&crypto_q_mtx, "crypto", "crypto op queues", MTX_DEF); |
| 331 | |
| 332 | cryptop_zone = uma_zcreate("cryptop", |
| 333 | sizeof(struct cryptop), NULL, NULL, NULL, NULL, |
| 334 | UMA_ALIGN_PTR, UMA_ZONE_ZINIT); |
| 335 | |
| 336 | crypto_drivers_size = CRYPTO_DRIVERS_INITIAL; |
| 337 | crypto_drivers = malloc(crypto_drivers_size * |
| 338 | sizeof(struct cryptocap), M_CRYPTO_DATA, M_WAITOK | M_ZERO); |
| 339 | |
| 340 | if (crypto_workers_num < 1 || crypto_workers_num > mp_ncpus) |
| 341 | crypto_workers_num = mp_ncpus; |
| 342 | |
| 343 | crypto_tq = taskqueue_create("crypto", M_WAITOK | M_ZERO, |
| 344 | taskqueue_thread_enqueue, &crypto_tq); |
| 345 | |
| 346 | taskqueue_start_threads(&crypto_tq, crypto_workers_num, PRI_MIN_KERN, |
| 347 | "crypto"); |
| 348 | |
| 349 | error = kproc_create((void (*)(void *)) crypto_proc, NULL, |
| 350 | &cryptoproc, 0, 0, "crypto"); |
| 351 | if (error) { |
| 352 | printf("crypto_init: cannot start crypto thread; error %d", |
| 353 | error); |
| 354 | goto bad; |
| 355 | } |
| 356 | |
| 357 | crypto_ret_workers = mallocarray(crypto_workers_num, |
| 358 | sizeof(struct crypto_ret_worker), M_CRYPTO_DATA, M_WAITOK | M_ZERO); |
| 359 | |
| 360 | FOREACH_CRYPTO_RETW(ret_worker) { |
| 361 | TAILQ_INIT(&ret_worker->crp_ordered_ret_q); |
| 362 | TAILQ_INIT(&ret_worker->crp_ret_q); |
| 363 | TAILQ_INIT(&ret_worker->crp_ret_kq); |
| 364 | |
| 365 | ret_worker->reorder_ops = 0; |
| 366 | ret_worker->reorder_cur_seq = 0; |
| 367 | |
| 368 | mtx_init(&ret_worker->crypto_ret_mtx, "crypto", "crypto return queues", MTX_DEF); |
| 369 | |
| 370 | error = kproc_create((void (*)(void *)) crypto_ret_proc, ret_worker, |
| 371 | &ret_worker->cryptoretproc, 0, 0, "crypto returns %td", CRYPTO_RETW_ID(ret_worker)); |
| 372 | if (error) { |
| 373 | printf("crypto_init: cannot start cryptoret thread; error %d", |
| 374 | error); |
| 375 | goto bad; |
| 376 | } |
no test coverage detected