* Add a crypto request to a queue, to be processed by the kernel thread. */
| 1410 | * Add a crypto request to a queue, to be processed by the kernel thread. |
| 1411 | */ |
| 1412 | int |
| 1413 | crypto_dispatch(struct cryptop *crp) |
| 1414 | { |
| 1415 | struct cryptocap *cap; |
| 1416 | int result; |
| 1417 | |
| 1418 | #ifdef INVARIANTS |
| 1419 | crp_sanity(crp); |
| 1420 | #endif |
| 1421 | |
| 1422 | CRYPTOSTAT_INC(cs_ops); |
| 1423 | |
| 1424 | crp->crp_retw_id = crp->crp_session->id % crypto_workers_num; |
| 1425 | |
| 1426 | if (CRYPTOP_ASYNC(crp)) { |
| 1427 | if (crp->crp_flags & CRYPTO_F_ASYNC_KEEPORDER) { |
| 1428 | struct crypto_ret_worker *ret_worker; |
| 1429 | |
| 1430 | ret_worker = CRYPTO_RETW(crp->crp_retw_id); |
| 1431 | |
| 1432 | CRYPTO_RETW_LOCK(ret_worker); |
| 1433 | crp->crp_seq = ret_worker->reorder_ops++; |
| 1434 | CRYPTO_RETW_UNLOCK(ret_worker); |
| 1435 | } |
| 1436 | |
| 1437 | TASK_INIT(&crp->crp_task, 0, crypto_task_invoke, crp); |
| 1438 | taskqueue_enqueue(crypto_tq, &crp->crp_task); |
| 1439 | return (0); |
| 1440 | } |
| 1441 | |
| 1442 | if ((crp->crp_flags & CRYPTO_F_BATCH) == 0) { |
| 1443 | /* |
| 1444 | * Caller marked the request to be processed |
| 1445 | * immediately; dispatch it directly to the |
| 1446 | * driver unless the driver is currently blocked. |
| 1447 | */ |
| 1448 | cap = crp->crp_session->cap; |
| 1449 | if (!cap->cc_qblocked) { |
| 1450 | result = crypto_invoke(cap, crp, 0); |
| 1451 | if (result != ERESTART) |
| 1452 | return (result); |
| 1453 | /* |
| 1454 | * The driver ran out of resources, put the request on |
| 1455 | * the queue. |
| 1456 | */ |
| 1457 | } |
| 1458 | } |
| 1459 | crypto_batch_enqueue(crp); |
| 1460 | return 0; |
| 1461 | } |
| 1462 | |
| 1463 | void |
| 1464 | crypto_batch_enqueue(struct cryptop *crp) |
no test coverage detected