Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F133595498
D25691.id74534.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D25691.id74534.diff
View Options
Index: share/man/man9/Makefile
===================================================================
--- share/man/man9/Makefile
+++ share/man/man9/Makefile
@@ -927,9 +927,11 @@
crypto_driver.9 CRYPTODEV_PROCESS.9 \
crypto_driver.9 hmac_init_ipad.9 \
crypto_driver.9 hmac_init_opad.9
-MLINKS+=crypto_request.9 crypto_dispatch.9 \
+MLINKS+=crypto_request.9 crypto_destroyreq.9 \
+ crypto_request.9 crypto_dispatch.9 \
crypto_request.9 crypto_freereq.9 \
crypto_request.9 crypto_getreq.9 \
+ crypto_request.9 crypto_initreq.9 \
crypto_request.9 crypto_use_buf.9 \
crypto_request.9 crypto_use_mbuf.9 \
crypto_request.9 crypto_use_output_buf.9 \
Index: share/man/man9/crypto_request.9
===================================================================
--- share/man/man9/crypto_request.9
+++ share/man/man9/crypto_request.9
@@ -41,10 +41,14 @@
.Ft int
.Fn crypto_dispatch "struct cryptop *crp"
.Ft void
+.Fn crypto_destroyreq "struct cryptop *crp"
+.Ft void
.Fn crypto_freereq "struct cryptop *crp"
.Ft "struct cryptop *"
.Fn crypto_getreq "crypto_session_t cses" "int how"
.Ft void
+.Fn crypto_initreq "crypto_session_t cses" "int how"
+.Ft void
.Fn crypto_use_buf "struct cryptop *crp" "void *buf" "int len"
.Ft void
.Fn crypto_use_mbuf "struct cryptop *crp" "struct mbuf *m"
@@ -62,10 +66,27 @@
.Vt struct cryptop
and is associated with an active session.
.Pp
-New requests are allocated by
-.Fn crypto_getreq .
+Requests can either be allocated dynamically or use caller-supplied
+storage.
+Dynamically allocated requests should be allocated by
+.Fn crypto_getreq
+and freed by
+.Fn crypto_freereq
+once the request has completed.
+Requests using caller-supplied storage should be initialized by
+.Fn crypto_initreq
+at the start of each operation and destroyed by
+.Fn crypto_destroyreq
+once the request has completed.
+.Pp
+For both
+.Fn crypto_getreq
+and
+.Fn crypto_initreq ,
.Fa cses
is a reference to an active session.
+For
+.Fn crypto_getreq ,
.Fa how
is passed to
.Xr malloc 9
@@ -73,7 +94,9 @@
.Dv M_NOWAIT
or
.Dv M_WAITOK .
-The caller should then set fields in the returned structure to describe
+.Pp
+Once a request has been initialized,
+the caller should set fields in the structure to describe
request-specific parameters.
Unused fields should be left as-is.
.Pp
@@ -92,7 +115,9 @@
returns.
.Pp
Once a request has signaled completion by invoking its callback function,
-it should be feed via
+it should be freed via
+.Fn crypto_destroyreq
+or
.Fn crypto_freereq .
.Pp
Cryptographic operations include several fields to describe the request.
Index: sys/opencrypto/crypto.c
===================================================================
--- sys/opencrypto/crypto.c
+++ sys/opencrypto/crypto.c
@@ -1734,12 +1734,8 @@
}
void
-crypto_freereq(struct cryptop *crp)
+crypto_destroyreq(struct cryptop *crp)
{
-
- if (crp == NULL)
- return;
-
#ifdef DIAGNOSTIC
{
struct cryptop *crp2;
@@ -1764,10 +1760,32 @@
}
}
#endif
+}
+void
+crypto_freereq(struct cryptop *crp)
+{
+
+ if (crp == NULL)
+ return;
+
+ crypto_destroyreq(crp);
uma_zfree(cryptop_zone, crp);
}
+static void
+_crypto_initreq(struct cryptop *crp, crypto_session_t cses)
+{
+ crp->crp_session = cses;
+}
+
+void
+crypto_initreq(struct cryptop *crp, crypto_session_t cses)
+{
+ memset(crp, 0, sizeof(*crp));
+ _crypto_initreq(crp, cses);
+}
+
struct cryptop *
crypto_getreq(crypto_session_t cses, int how)
{
@@ -1775,7 +1793,7 @@
MPASS(how == M_WAITOK || how == M_NOWAIT);
crp = uma_zalloc(cryptop_zone, how | M_ZERO);
- crp->crp_session = cses;
+ _crypto_initreq(crp, cses);
return (crp);
}
Index: sys/opencrypto/cryptodev.h
===================================================================
--- sys/opencrypto/cryptodev.h
+++ sys/opencrypto/cryptodev.h
@@ -622,6 +622,8 @@
extern void crypto_kdone(struct cryptkop *);
extern int crypto_getfeat(int *);
+extern void crypto_destroyreq(struct cryptop *crp);
+extern void crypto_initreq(struct cryptop *crp, crypto_session_t cses);
extern void crypto_freereq(struct cryptop *crp);
extern struct cryptop *crypto_getreq(crypto_session_t cses, int how);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 27, 10:02 PM (1 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24318497
Default Alt Text
D25691.id74534.diff (4 KB)
Attached To
Mode
D25691: Add crypto_initreq() and crypto_destroyreq().
Attached
Detach File
Event Timeline
Log In to Comment