diff mbox series

[API-NEXT,v2,2/3] linux-gen: crypto: set packet error flag depending on crypto result operation

Message ID 1510538405-474-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v2,1/3] linux-gen: crypto: drop extra memcpy on result return | expand

Commit Message

Github ODP bot Nov. 13, 2017, 2 a.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


To speed up fast path of crypto packet operations, set error flag
depending on the crypto result operation. This allows applications to
fast-forward packets w/o errors and inspect crypto result only for
erroneous packets.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 294 (lumag:crypto-err-flag)
 ** https://github.com/Linaro/odp/pull/294
 ** Patch: https://github.com/Linaro/odp/pull/294.patch
 ** Base sha: a908a4dead95321e84d6a8a23de060051dcd8969
 ** Merge commit sha: d4ef7e80916d7a2c5f5fb1032bed9e07488cbe69
 **/
 platform/linux-generic/include/odp_packet_internal.h | 1 +
 platform/linux-generic/odp_crypto.c                  | 4 ++++
 2 files changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index fc10d61c8..6473a1aae 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -55,6 +55,7 @@  typedef union {
 		uint32_t tcp_err:1;   /**< TCP error, checks TBD */
 		uint32_t udp_err:1;   /**< UDP error, checks TBD */
 		uint32_t l4_chksum:1; /**< L4 checksum error */
+		uint32_t crypto_err:1; /**< Crypto packet operation error */
 	};
 } error_flags_t;
 
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 79be510d4..ea49e9807 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -1161,6 +1161,7 @@  int odp_crypto_int(odp_packet_t pkt_in,
 	odp_bool_t allocated = false;
 	odp_packet_t out_pkt = *pkt_out;
 	odp_crypto_packet_result_t *op_result;
+	odp_packet_hdr_t *pkt_hdr;
 
 	session = (odp_crypto_generic_session_t *)(intptr_t)param->session;
 
@@ -1214,6 +1215,9 @@  int odp_crypto_int(odp_packet_t pkt_in,
 		(rc_cipher == ODP_CRYPTO_ALG_ERR_NONE) &&
 		(rc_auth == ODP_CRYPTO_ALG_ERR_NONE);
 
+	pkt_hdr = odp_packet_hdr(out_pkt);
+	pkt_hdr->p.error_flags.crypto_err = !op_result->ok;
+
 	/* Synchronous, simply return results */
 	*pkt_out = out_pkt;