diff mbox series

[API-NEXT,v1,3/9] api: crypto: drop async mode support

Message ID 1498838409-4597-4-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v1,1/9] linux-generic: events subtype implementation | expand

Commit Message

Github ODP bot June 30, 2017, 4 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Current Crypto API provides a way to set the 'preferred' mode of
operation, without actually telling if the operation will proceed in
sync or async mode. In preparation of reworking crypto API declare that
all operations always end up processed in sync mode (posted == FALSE).

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

---
/** Email created from pull request 64 (lumag:crypto-packet)
 ** https://github.com/Linaro/odp/pull/64
 ** Patch: https://github.com/Linaro/odp/pull/64.patch
 ** Base sha: 7a5813042d58598e1c66243d8cfed548302edfc4
 ** Merge commit sha: 25273ed7dee29d26a2ef7357e84a36aa4443f63e
 **/
 include/odp/api/spec/crypto.h                      | 10 ++--
 .../linux-generic/include/odp_crypto_internal.h    |  8 ---
 .../linux-generic/include/odp_packet_internal.h    |  4 --
 platform/linux-generic/odp_crypto.c                | 63 +++++-----------------
 platform/linux-generic/odp_packet.c                |  1 -
 5 files changed, 17 insertions(+), 69 deletions(-)
diff mbox series

Patch

diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index 470cba05..01b15d6b 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -640,14 +640,12 @@  void odp_crypto_compl_free(odp_crypto_compl_t completion_event);
  * Crypto per packet operation
  *
  * Performs the cryptographic operations specified during session creation
- * on the packet.  If the operation is performed synchronously, "posted"
- * will return FALSE and the result of the operation is immediately available.
- * If "posted" returns TRUE the result will be delivered via the completion
- * queue specified when the session was created.
+ * on the packet. The operation is performed synchronously, the result of the
+ * operation is immediately available.
  *
  * @param param             Operation parameters
- * @param posted            Pointer to return posted, TRUE for async operation
- * @param result            Results of operation (when posted returns FALSE)
+ * @param posted            Always returns FALSE
+ * @param result            Results of operation
  *
  * @retval 0 on success
  * @retval <0 on failure
diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h
index c3b70b23..52b94d07 100644
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ b/platform/linux-generic/include/odp_crypto_internal.h
@@ -56,14 +56,6 @@  struct odp_crypto_generic_session {
 };
 
 /**
- * Per packet operation result
- */
-typedef struct odp_crypto_generic_op_result {
-	uint32_t magic;
-	odp_crypto_op_result_t result;
-} odp_crypto_generic_op_result_t;
-
-/**
  * Per session creation operation result
  */
 typedef struct odp_crypto_generic_session_result {
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index cdd139bb..9f28fc05 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -128,9 +128,6 @@  typedef struct {
 	/* Classifier destination queue */
 	odp_queue_t dst_queue;
 
-	/* Result for crypto */
-	odp_crypto_generic_op_result_t op_result;
-
 	/* Packet data storage */
 	uint8_t data[0];
 } odp_packet_hdr_t;
@@ -171,7 +168,6 @@  static inline void copy_packet_cls_metadata(odp_packet_hdr_t *src_hdr,
 	dst_hdr->dst_queue = src_hdr->dst_queue;
 	dst_hdr->flow_hash = src_hdr->flow_hash;
 	dst_hdr->timestamp = src_hdr->timestamp;
-	dst_hdr->op_result = src_hdr->op_result;
 }
 
 static inline void pull_tail(odp_packet_hdr_t *pkt_hdr, uint32_t len)
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 0e2adad1..d6a6b7a9 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -88,14 +88,6 @@  struct odp_crypto_global_s {
 static odp_crypto_global_t *global;
 
 static
-odp_crypto_generic_op_result_t *get_op_result_from_event(odp_event_t ev)
-{
-	odp_packet_hdr_t *hdr = odp_packet_hdr(odp_packet_from_event(ev));
-
-	return &hdr->op_result;
-}
-
-static
 odp_crypto_generic_session_t *alloc_session(void)
 {
 	odp_crypto_generic_session_t *session = NULL;
@@ -903,37 +895,14 @@  odp_crypto_operation(odp_crypto_op_param_t *param,
 		(rc_cipher == ODP_CRYPTO_ALG_ERR_NONE) &&
 		(rc_auth == ODP_CRYPTO_ALG_ERR_NONE);
 
-	/* If specified during creation post event to completion queue */
-	if (ODP_QUEUE_INVALID != session->p.compl_queue) {
-		odp_event_t completion_event;
-		odp_crypto_generic_op_result_t *op_result;
-		odp_buffer_t buf;
-
-		/* Linux generic will always use packet for completion event */
-		completion_event = odp_packet_to_event(param->out_pkt);
-		buf = odp_buffer_from_event(completion_event);
-		_odp_buffer_event_type_set(buf, ODP_EVENT_CRYPTO_COMPL);
-		_odp_buffer_event_subtype_set(buf, ODP_EVENT_NO_SUBTYPE);
-		/* Asynchronous, build result (no HW so no errors) and send it*/
-		op_result = get_op_result_from_event(completion_event);
-		op_result->magic = OP_RESULT_MAGIC;
-		op_result->result = local_result;
-		if (odp_queue_enq(session->p.compl_queue, completion_event)) {
-			odp_event_free(completion_event);
-			goto err;
-		}
+	/* Synchronous, simply return results */
+	if (!result)
+		goto err;
+	*result = local_result;
 
-		/* Indicate to caller operation was async */
-		*posted = 1;
-	} else {
-		/* Synchronous, simply return results */
-		if (!result)
-			goto err;
-		*result = local_result;
+	/* Indicate to caller operation was sync */
+	*posted = 0;
 
-		/* Indicate to caller operation was sync */
-		*posted = 0;
-	}
 	return 0;
 
 err:
@@ -1093,27 +1062,21 @@  void
 odp_crypto_compl_result(odp_crypto_compl_t completion_event,
 			odp_crypto_op_result_t *result)
 {
-	odp_event_t ev = odp_crypto_compl_to_event(completion_event);
-	odp_crypto_generic_op_result_t *op_result;
-
-	op_result = get_op_result_from_event(ev);
+	(void) completion_event;
+	(void) result;
 
-	if (OP_RESULT_MAGIC != op_result->magic)
-		ODP_ABORT();
-
-	memcpy(result, &op_result->result, sizeof(*result));
+	/* We won't get such events anyway, so there can be no result */
+	ODP_ASSERT(0);
 }
 
 void
 odp_crypto_compl_free(odp_crypto_compl_t completion_event)
 {
-	odp_buffer_t buf =
-		odp_buffer_from_event((odp_event_t)completion_event);
-
-	_odp_buffer_event_type_set(buf, ODP_EVENT_PACKET);
-	_odp_buffer_event_subtype_set(buf, ODP_EVENT_PACKET_BASIC);
+	odp_event_t ev = odp_crypto_compl_to_event(completion_event);
+	odp_buffer_free(odp_buffer_from_event(ev));
 }
 
+
 void odp_crypto_session_param_init(odp_crypto_session_param_t *param)
 {
 	memset(param, 0, sizeof(odp_crypto_session_param_t));
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 3789feca..22358438 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -166,7 +166,6 @@  static inline void packet_seg_copy_md(odp_packet_hdr_t *dst,
 	dst->dst_queue = src->dst_queue;
 	dst->flow_hash = src->flow_hash;
 	dst->timestamp = src->timestamp;
-	dst->op_result = src->op_result;
 
 	/* buffer header side packet metadata */
 	dst->buf_hdr.buf_u64    = src->buf_hdr.buf_u64;