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

Function crypto_proc

freebsd/opencrypto/crypto.c:1947–2088  ·  view source on GitHub ↗

* Crypto thread, dispatches crypto requests. */

Source from the content-addressed store, hash-verified

1945 * Crypto thread, dispatches crypto requests.
1946 */
1947static void
1948crypto_proc(void)
1949{
1950 struct cryptop *crp, *submit;
1951 struct cryptkop *krp;
1952 struct cryptocap *cap;
1953 int result, hint;
1954
1955#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__)
1956 fpu_kern_thread(FPU_KERN_NORMAL);
1957#endif
1958
1959 CRYPTO_Q_LOCK();
1960 for (;;) {
1961 /*
1962 * Find the first element in the queue that can be
1963 * processed and look-ahead to see if multiple ops
1964 * are ready for the same driver.
1965 */
1966 submit = NULL;
1967 hint = 0;
1968 TAILQ_FOREACH(crp, &crp_q, crp_next) {
1969 cap = crp->crp_session->cap;
1970 /*
1971 * Driver cannot disappeared when there is an active
1972 * session.
1973 */
1974 KASSERT(cap != NULL, ("%s:%u Driver disappeared.",
1975 __func__, __LINE__));
1976 if (cap->cc_flags & CRYPTOCAP_F_CLEANUP) {
1977 /* Op needs to be migrated, process it. */
1978 if (submit == NULL)
1979 submit = crp;
1980 break;
1981 }
1982 if (!cap->cc_qblocked) {
1983 if (submit != NULL) {
1984 /*
1985 * We stop on finding another op,
1986 * regardless whether its for the same
1987 * driver or not. We could keep
1988 * searching the queue but it might be
1989 * better to just use a per-driver
1990 * queue instead.
1991 */
1992 if (submit->crp_session->cap == cap)
1993 hint = CRYPTO_HINT_MORE;
1994 break;
1995 } else {
1996 submit = crp;
1997 if ((submit->crp_flags & CRYPTO_F_BATCH) == 0)
1998 break;
1999 /* keep scanning for more are q'd */
2000 }
2001 }
2002 }
2003 if (submit != NULL) {
2004 TAILQ_REMOVE(&crp_q, submit, crp_next);

Callers

nothing calls this directly

Calls 5

crypto_invokeFunction · 0.85
cap_releFunction · 0.85
crypto_kinvokeFunction · 0.85
crypto_finisFunction · 0.85
fpu_kern_threadFunction · 0.50

Tested by

no test coverage detected