consolidate callback optimization check in one location by adding a flag
for crypto operations that indicates the crypto code should do the check in crypto_done MFC after: 1 day
This commit is contained in:
parent
9b6e332f08
commit
d8409aaf6e
@ -687,16 +687,7 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
|
||||
|
||||
/* Crypto operation descriptor. */
|
||||
crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */
|
||||
crp->crp_flags = CRYPTO_F_IMBUF;
|
||||
/*
|
||||
* When using crypto support the operates "synchronously" (e.g.
|
||||
* software crypto) mark the operation for immediate callback to
|
||||
* avoid the context switch. This increases the amount of kernel
|
||||
* stack required to process a frame but we assume there is enough
|
||||
* to do this.
|
||||
*/
|
||||
if (CRYPTO_SESID2CAPS(sav->tdb_cryptoid) & CRYPTOCAP_F_SYNC)
|
||||
crp->crp_flags |= CRYPTO_F_CBIMM;
|
||||
crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC;
|
||||
crp->crp_buf = (caddr_t) m;
|
||||
crp->crp_callback = ah_input_cb;
|
||||
crp->crp_sid = sav->tdb_cryptoid;
|
||||
@ -1099,16 +1090,7 @@ ah_output(
|
||||
|
||||
/* Crypto operation descriptor. */
|
||||
crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */
|
||||
crp->crp_flags = CRYPTO_F_IMBUF;
|
||||
/*
|
||||
* When using crypto support the operates "synchronously" (e.g.
|
||||
* software crypto) mark the operation for immediate callback to
|
||||
* avoid the context switch. This increases the amount of kernel
|
||||
* stack required to process a frame but we assume there is enough
|
||||
* to do this.
|
||||
*/
|
||||
if (CRYPTO_SESID2CAPS(sav->tdb_cryptoid) & CRYPTOCAP_F_SYNC)
|
||||
crp->crp_flags |= CRYPTO_F_CBIMM;
|
||||
crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC;
|
||||
crp->crp_buf = (caddr_t) m;
|
||||
crp->crp_callback = ah_output_cb;
|
||||
crp->crp_sid = sav->tdb_cryptoid;
|
||||
|
@ -395,16 +395,7 @@ esp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
|
||||
|
||||
/* Crypto operation descriptor */
|
||||
crp->crp_ilen = m->m_pkthdr.len; /* Total input length */
|
||||
crp->crp_flags = CRYPTO_F_IMBUF;
|
||||
/*
|
||||
* When using crypto support the operates "synchronously" (e.g.
|
||||
* software crypto) mark the operation for immediate callback to
|
||||
* avoid the context switch. This increases the amount of kernel
|
||||
* stack required to process a frame but we assume there is enough
|
||||
* to do this.
|
||||
*/
|
||||
if (CRYPTO_SESID2CAPS(sav->tdb_cryptoid) & CRYPTOCAP_F_SYNC)
|
||||
crp->crp_flags |= CRYPTO_F_CBIMM;
|
||||
crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC;
|
||||
crp->crp_buf = (caddr_t) m;
|
||||
crp->crp_callback = esp_input_cb;
|
||||
crp->crp_sid = sav->tdb_cryptoid;
|
||||
@ -842,16 +833,7 @@ esp_output(
|
||||
|
||||
/* Crypto operation descriptor. */
|
||||
crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */
|
||||
crp->crp_flags = CRYPTO_F_IMBUF;
|
||||
/*
|
||||
* When using crypto support the operates "synchronously" (e.g.
|
||||
* software crypto) mark the operation for immediate callback to
|
||||
* avoid the context switch. This increases the amount of kernel
|
||||
* stack required to process a frame but we assume there is enough
|
||||
* to do this.
|
||||
*/
|
||||
if (CRYPTO_SESID2CAPS(sav->tdb_cryptoid) & CRYPTOCAP_F_SYNC)
|
||||
crp->crp_flags |= CRYPTO_F_CBIMM;
|
||||
crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC;
|
||||
crp->crp_buf = (caddr_t) m;
|
||||
crp->crp_callback = esp_output_cb;
|
||||
crp->crp_opaque = (caddr_t) tc;
|
||||
|
@ -173,16 +173,7 @@ ipcomp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
|
||||
|
||||
/* Crypto operation descriptor */
|
||||
crp->crp_ilen = m->m_pkthdr.len - (skip + hlen);
|
||||
crp->crp_flags = CRYPTO_F_IMBUF;
|
||||
/*
|
||||
* When using crypto support the operates "synchronously" (e.g.
|
||||
* software crypto) mark the operation for immediate callback to
|
||||
* avoid the context switch. This increases the amount of kernel
|
||||
* stack required to process a frame but we assume there is enough
|
||||
* to do this.
|
||||
*/
|
||||
if (CRYPTO_SESID2CAPS(sav->tdb_cryptoid) & CRYPTOCAP_F_SYNC)
|
||||
crp->crp_flags |= CRYPTO_F_CBIMM;
|
||||
crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC;
|
||||
crp->crp_buf = (caddr_t) m;
|
||||
crp->crp_callback = ipcomp_input_cb;
|
||||
crp->crp_sid = sav->tdb_cryptoid;
|
||||
@ -486,16 +477,7 @@ ipcomp_output(
|
||||
|
||||
/* Crypto operation descriptor */
|
||||
crp->crp_ilen = m->m_pkthdr.len; /* Total input length */
|
||||
crp->crp_flags = CRYPTO_F_IMBUF;
|
||||
/*
|
||||
* When using crypto support the operates "synchronously" (e.g.
|
||||
* software crypto) mark the operation for immediate callback to
|
||||
* avoid the context switch. This increases the amount of kernel
|
||||
* stack required to process a frame but we assume there is enough
|
||||
* to do this.
|
||||
*/
|
||||
if (CRYPTO_SESID2CAPS(sav->tdb_cryptoid) & CRYPTOCAP_F_SYNC)
|
||||
crp->crp_flags |= CRYPTO_F_CBIMM;
|
||||
crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC;
|
||||
crp->crp_buf = (caddr_t) m;
|
||||
crp->crp_callback = ipcomp_output_cb;
|
||||
crp->crp_opaque = (caddr_t) tc;
|
||||
|
@ -950,7 +950,16 @@ crypto_done(struct cryptop *crp)
|
||||
if (crypto_timing)
|
||||
crypto_tstat(&cryptostats.cs_done, &crp->crp_tstamp);
|
||||
#endif
|
||||
if (crp->crp_flags & CRYPTO_F_CBIMM) {
|
||||
/*
|
||||
* CBIMM means unconditionally do the callback immediately;
|
||||
* CBIFSYNC means do the callback immediately only if the
|
||||
* operation was done synchronously. Both are used to avoid
|
||||
* doing extraneous context switches; the latter is mostly
|
||||
* used with the software crypto driver.
|
||||
*/
|
||||
if ((crp->crp_flags & CRYPTO_F_CBIMM) ||
|
||||
((crp->crp_flags & CRYPTO_F_CBIFSYNC) &&
|
||||
(CRYPTO_SESID2CAPS(crp->crp_sid) & CRYPTOCAP_F_SYNC))) {
|
||||
/*
|
||||
* Do the callback directly. This is ok when the
|
||||
* callback routine does very little (e.g. the
|
||||
|
@ -259,12 +259,13 @@ struct cryptop {
|
||||
*/
|
||||
int crp_flags;
|
||||
|
||||
#define CRYPTO_F_IMBUF 0x0001 /* Input/output are mbuf chains, otherwise contig */
|
||||
#define CRYPTO_F_IOV 0x0002 /* Input/output are uio */
|
||||
#define CRYPTO_F_REL 0x0004 /* Must return data in same place */
|
||||
#define CRYPTO_F_BATCH 0x0008 /* Batch op if possible */
|
||||
#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */
|
||||
#define CRYPTO_F_DONE 0x0020 /* Operation completed */
|
||||
#define CRYPTO_F_IMBUF 0x0001 /* Input/output are mbuf chains */
|
||||
#define CRYPTO_F_IOV 0x0002 /* Input/output are uio */
|
||||
#define CRYPTO_F_REL 0x0004 /* Must return data in same place */
|
||||
#define CRYPTO_F_BATCH 0x0008 /* Batch op if possible */
|
||||
#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */
|
||||
#define CRYPTO_F_DONE 0x0020 /* Operation completed */
|
||||
#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */
|
||||
|
||||
caddr_t crp_buf; /* Data to be processed */
|
||||
caddr_t crp_opaque; /* Opaque pointer, passed along */
|
||||
|
Loading…
Reference in New Issue
Block a user