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

Function crypto_ret_proc

freebsd/opencrypto/crypto.c:2095–2149  ·  view source on GitHub ↗

* Crypto returns thread, does callbacks for processed crypto requests. * Callbacks are done here, rather than in the crypto drivers, because * callbacks typically are expensive and would slow interrupt handling. */

Source from the content-addressed store, hash-verified

2093 * callbacks typically are expensive and would slow interrupt handling.
2094 */
2095static void
2096crypto_ret_proc(struct crypto_ret_worker *ret_worker)
2097{
2098 struct cryptop *crpt;
2099 struct cryptkop *krpt;
2100
2101 CRYPTO_RETW_LOCK(ret_worker);
2102 for (;;) {
2103 /* Harvest return q's for completed ops */
2104 crpt = TAILQ_FIRST(&ret_worker->crp_ordered_ret_q);
2105 if (crpt != NULL) {
2106 if (crpt->crp_seq == ret_worker->reorder_cur_seq) {
2107 TAILQ_REMOVE(&ret_worker->crp_ordered_ret_q, crpt, crp_next);
2108 ret_worker->reorder_cur_seq++;
2109 } else {
2110 crpt = NULL;
2111 }
2112 }
2113
2114 if (crpt == NULL) {
2115 crpt = TAILQ_FIRST(&ret_worker->crp_ret_q);
2116 if (crpt != NULL)
2117 TAILQ_REMOVE(&ret_worker->crp_ret_q, crpt, crp_next);
2118 }
2119
2120 krpt = TAILQ_FIRST(&ret_worker->crp_ret_kq);
2121 if (krpt != NULL)
2122 TAILQ_REMOVE(&ret_worker->crp_ret_kq, krpt, krp_next);
2123
2124 if (crpt != NULL || krpt != NULL) {
2125 CRYPTO_RETW_UNLOCK(ret_worker);
2126 /*
2127 * Run callbacks unlocked.
2128 */
2129 if (crpt != NULL)
2130 crpt->crp_callback(crpt);
2131 if (krpt != NULL)
2132 krpt->krp_callback(krpt);
2133 CRYPTO_RETW_LOCK(ret_worker);
2134 } else {
2135 /*
2136 * Nothing more to be processed. Sleep until we're
2137 * woken because there are more returns to process.
2138 */
2139 msleep(&ret_worker->crp_ret_q, &ret_worker->crypto_ret_mtx, PWAIT,
2140 "crypto_ret_wait", 0);
2141 if (ret_worker->cryptoretproc == NULL)
2142 break;
2143 CRYPTOSTAT_INC(cs_rets);
2144 }
2145 }
2146 CRYPTO_RETW_UNLOCK(ret_worker);
2147
2148 crypto_finis(&ret_worker->crp_ret_q);
2149}
2150
2151#ifdef DDB
2152static void

Callers

nothing calls this directly

Calls 1

crypto_finisFunction · 0.85

Tested by

no test coverage detected