aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>2016-03-24 16:45:07 +0200
committerIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>2016-03-24 20:06:29 +0200
commit50e39f8d2538b02255caffab551f690d8983c874 (patch)
tree89d83ae9da41d9d0a5ad2450fa3e21e260417f67
parentb51120de9b46f56f9081a239cac15176544c2c6a (diff)
downloadodp-keystone2-50e39f8d2538b02255caffab551f690d8983c874.tar.gz
linux-ks2: crypto: correct sync/async/out packet behavior
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
-rw-r--r--platform/linux-keystone2/odp_crypto.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/platform/linux-keystone2/odp_crypto.c b/platform/linux-keystone2/odp_crypto.c
index ddbe1b2e..b5129880 100644
--- a/platform/linux-keystone2/odp_crypto.c
+++ b/platform/linux-keystone2/odp_crypto.c
@@ -49,6 +49,8 @@ struct odp_crypto_session_s {
odp_pool_t out_pool;
cppi_flow_entry_t *cppi_flow;
odp_queue_t compl_queue;
+ odp_crypto_op_mode_t pref_mode;
+
struct {
odp_cipher_alg_t alg;
struct iv_full iv;
@@ -175,7 +177,6 @@ int odp_crypto_session_create(odp_crypto_session_params_t *params,
*status = ODP_CRYPTO_SES_CREATE_ERR_NONE;
*session_out = ODP_CRYPTO_SESSION_INVALID;
-
/* Allocate memory for this session */
session = alloc_session();
if (!session) {
@@ -187,6 +188,7 @@ int odp_crypto_session_create(odp_crypto_session_params_t *params,
session->op = params->op;
session->cipher.alg = params->cipher_alg;
session->auth.alg = params->auth_alg;
+ session->pref_mode = params->pref_mode;
if (sizeof(session->cipher.iv.data) < params->iv.length) {
*status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
return -1;
@@ -390,59 +392,57 @@ int odp_crypto_operation(odp_crypto_op_params_t *params,
NULL);
desc = Osal_qmssConvertDescVirtToPhy(0, desc);
-
Qmss_queuePushDescSizeRaw(dm_cmd_info->txQueue,
desc,
NWAL_DESC_SIZE);
- if (params->out_pkt == ODP_PACKET_INVALID) {
+ odp_event_t event;
+ Cppi_HostDesc *rx_desc;
+ if (params->out_pkt != ODP_PACKET_INVALID ||
+ session->pref_mode == ODP_CRYPTO_SYNC) {
+ /* Poll completion queue for results */
+ do {
+ rx_desc = (void *)QMSS_DESC_PTR(Qmss_queuePop(session->dm_ps_cmdinfo.rxSbSaQ));
+ event = _cppi_desc_to_odp_ev(rx_desc);
+ } while (event == ODP_EVENT_INVALID);
+ } else {
*posted = 1;
return 0;
}
/* if out packet is specified copy event then*/
- //if (params->out_pkt == params->pkt) {
- odp_event_t event;
- Cppi_HostDesc *rx_desc;
- odp_crypto_compl_t compl_event;
-
- /* Poll completion queue for results */
- do {
- rx_desc = (void *)QMSS_DESC_PTR(Qmss_queuePop(session->dm_ps_cmdinfo.rxSbSaQ));
- event = _cppi_desc_to_odp_ev(rx_desc);
- } while (event == ODP_EVENT_INVALID);
-
- Cppi_HostDesc *out_desc = _odp_pkt_to_cppi_desc(params->out_pkt);
- uint32_t pkt_len = _cppi_desc_pkt_len(out_desc);
-
- /* copy packet data */
- out_desc->buffPtr = (uint32_t)_odp_mem_phys_to_virt((odp_pa_t )out_desc->buffPtr);
- packet_data_copy(out_desc, 0, rx_desc, 0, pkt_len);
-
- /* copy packet header */
- out_desc->origBuffPtr = (uint32_t)_odp_mem_phys_to_virt((odp_pa_t )out_desc->origBuffPtr);
- packet_header_copy(_odp_pkt_hdr(params->out_pkt),
- _odp_pkt_hdr(_odp_ev_to_pkt(event)));
- /* copy PS data */
- Cppi_copyPSData((Cppi_Desc *)out_desc, (Cppi_Desc *)rx_desc);
-
- odp_packet_free(_odp_ev_to_pkt(event));
- event = odp_packet_to_event(params->out_pkt);
+ if (params->out_pkt != ODP_PACKET_INVALID) {
+ Cppi_HostDesc *out_desc = _odp_pkt_to_cppi_desc(params->out_pkt);
+ uint32_t pkt_len = _cppi_desc_pkt_len(out_desc);
+
+ /* copy packet data */
+ out_desc->buffPtr = (uint32_t)_odp_mem_phys_to_virt((odp_pa_t )out_desc->buffPtr);
+ packet_data_copy(out_desc, 0, rx_desc, 0, pkt_len);
+
+ /* copy packet header */
+ out_desc->origBuffPtr = (uint32_t)_odp_mem_phys_to_virt((odp_pa_t )out_desc->origBuffPtr);
+ packet_header_copy(_odp_pkt_hdr(params->out_pkt),
+ _odp_pkt_hdr(_odp_ev_to_pkt(event)));
+ /* copy PS data */
+ Cppi_copyPSData((Cppi_Desc *)out_desc, (Cppi_Desc *)rx_desc);
+
+ odp_packet_free(_odp_ev_to_pkt(event));
+ event = odp_packet_to_event(params->out_pkt);
+ }
- if (ODP_QUEUE_INVALID == session->compl_queue) {
+ if (session->pref_mode == ODP_CRYPTO_SYNC ||
+ params->out_pkt != ODP_PACKET_INVALID) {
+ odp_crypto_compl_t compl_event;
compl_event = odp_crypto_compl_from_event(event);
odp_crypto_compl_result(compl_event, result);
odp_crypto_compl_free(compl_event);
*posted = 0;
- return 0;
}
- /*
- * if specified return queue, return the copied packet
- * to the queue then
- */
- odp_queue_enq(session->compl_queue, event);
- *posted = 1;
+ if (params->out_pkt != ODP_PACKET_INVALID) {
+ odp_queue_enq(session->compl_queue, event);
+ *posted = 1;
+ }
return 0;
}