From patchwork Thu Jun 11 00:12:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 49733 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9BE2F245D4 for ; Thu, 11 Jun 2015 00:12:35 +0000 (UTC) Received: by laboh3 with SMTP id oh3sf16800570lab.0 for ; Wed, 10 Jun 2015 17:12:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=iKKk/mxxPiNfnIKPVqM3AwzpMzXABJf2HFqErVbOQhM=; b=GPgNLN14du590jqwxb96JWi5IC7AeqrGCHvV9l5HUF79TBevEps9uHTeP/U3CqeUbq MvAJljuhrXVyZfuEDTe6MwbX00EItwwp0Zhc+CNoIM/J5Y7E8qvL948fpj95I96gkKa/ LBMhLsCB0/pxk2p2w5ROPd9wLyuM76mzGaDNIZ+e24fle0QSoBOIZkNGP0yDsul+liP5 nYFheNeAB33SuEGoh6UP/DBVm+Uz9xDmfO/ofDluYMPYOvjIAdfSL679kc1EMSs18+mK 7TGUx8oAsdkT3RSMHZfhEcf+jVKLio+preg1IzXrrx2A3FhWV7+O51QEeAH6L1iT0B8o g+og== X-Gm-Message-State: ALoCoQn368iiVzDqRGonO39VbJIcfPZ/Jt6SDm8fFlmSrWlsqh6hbnX63baS79AGxy5dnHwLbrx5 X-Received: by 10.180.216.12 with SMTP id om12mr6227900wic.1.1433981554473; Wed, 10 Jun 2015 17:12:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.51 with SMTP id o19ls310926laa.95.gmail; Wed, 10 Jun 2015 17:12:34 -0700 (PDT) X-Received: by 10.112.168.165 with SMTP id zx5mr6764372lbb.111.1433981554162; Wed, 10 Jun 2015 17:12:34 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id bc7si10512311lbc.144.2015.06.10.17.12.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jun 2015 17:12:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbqq2 with SMTP id qq2so36876935lbb.3 for ; Wed, 10 Jun 2015 17:12:34 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr6775484lbc.112.1433981553961; Wed, 10 Jun 2015 17:12:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3663184lbb; Wed, 10 Jun 2015 17:12:32 -0700 (PDT) X-Received: by 10.140.235.145 with SMTP id g139mr7970391qhc.81.1433981552349; Wed, 10 Jun 2015 17:12:32 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d95si348925qkh.119.2015.06.10.17.12.31; Wed, 10 Jun 2015 17:12:32 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 2EFCF61FEE; Thu, 11 Jun 2015 00:12:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 32DAB61FE0; Thu, 11 Jun 2015 00:12:26 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 4745661FEC; Thu, 11 Jun 2015 00:12:18 +0000 (UTC) Received: from mail-ob0-f175.google.com (mail-ob0-f175.google.com [209.85.214.175]) by lists.linaro.org (Postfix) with ESMTPS id 5922261F79 for ; Thu, 11 Jun 2015 00:12:17 +0000 (UTC) Received: by obbgp2 with SMTP id gp2so45383499obb.2 for ; Wed, 10 Jun 2015 17:12:16 -0700 (PDT) X-Received: by 10.202.64.195 with SMTP id n186mr4768897oia.53.1433981536837; Wed, 10 Jun 2015 17:12:16 -0700 (PDT) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id o3sm7667241obz.9.2015.06.10.17.12.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jun 2015 17:12:16 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 10 Jun 2015 19:12:14 -0500 Message-Id: <1433981534-31243-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: crypto patch Subject: [lng-odp] [PATCHv2] linux-generic: crypto: eliminate buffer type hack for completions X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Bill Fischofer Reported-by: Christophe Milard --- .../linux-generic/include/odp_buffer_inlines.h | 9 ++++++ .../linux-generic/include/odp_buffer_internal.h | 1 + .../linux-generic/include/odp_packet_internal.h | 4 +++ platform/linux-generic/odp_crypto.c | 32 ++++++---------------- platform/linux-generic/odp_event.c | 7 ++--- platform/linux-generic/odp_pool.c | 1 + 6 files changed, 25 insertions(+), 29 deletions(-) diff --git a/platform/linux-generic/include/odp_buffer_inlines.h b/platform/linux-generic/include/odp_buffer_inlines.h index 2c792e2..91e56bd 100644 --- a/platform/linux-generic/include/odp_buffer_inlines.h +++ b/platform/linux-generic/include/odp_buffer_inlines.h @@ -188,6 +188,15 @@ static inline void *segment_map(odp_buffer_hdr_t *buf, return (void *)seg_addr; } +static inline int _odp_buffer_event_type(odp_buffer_t buf) +{ + return odp_buf_to_hdr(buf)->event_type; +} + +static inline void _odp_buffer_event_type_set(odp_buffer_t buf, int ev) +{ + odp_buf_to_hdr(buf)->event_type = ev; +} #ifdef __cplusplus } diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index e7b7568..a3632fe 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -117,6 +117,7 @@ typedef struct odp_buffer_hdr_t { }; } flags; int type; /* buffer type */ + int event_type; /* for reuse as event */ uint32_t size; /* max data size */ odp_atomic_u32_t ref_count; /* reference count */ odp_pool_t pool_hdl; /* buffer pool handle */ diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 9890dc8..8c41491 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -25,6 +25,8 @@ extern "C" { #include #include #include +#include +#include /** * Packet input & protocol flags @@ -134,6 +136,8 @@ typedef struct { uint32_t tailroom; odp_pktio_t input; + + odp_crypto_generic_op_result_t op_result; /**< Result for crypto */ } odp_packet_hdr_t; typedef struct odp_packet_hdr_stride { diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index b16316c..515f508 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -37,28 +37,10 @@ struct odp_crypto_global_s { static odp_crypto_global_t *global; -/* - * @todo This is a serious hack to allow us to use packet buffer to convey - * crypto operation results by placing them at the very end of the - * packet buffer. The issue should be resolved shortly once the issue - * of packets versus events on completion queues is closed. - */ static odp_crypto_generic_op_result_t *get_op_result_from_event(odp_event_t ev) { - uint8_t *temp; - odp_crypto_generic_op_result_t *result; - odp_buffer_t buf; - - /* HACK: Buffer is not packet any more in the API. - * Implementation still works that way. */ - buf = odp_buffer_from_event(ev); - - temp = odp_buffer_addr(buf); - temp += odp_buffer_size(buf); - temp -= sizeof(*result); - result = (odp_crypto_generic_op_result_t *)(void *)temp; - return result; + return &(odp_packet_hdr(odp_packet_from_event(ev))->op_result); } static @@ -424,9 +406,9 @@ odp_crypto_operation(odp_crypto_op_params_t *params, /* Linux generic will always use packet for completion event */ completion_event = odp_packet_to_event(params->out_pkt); - _odp_buffer_type_set(odp_buffer_from_event(completion_event), - ODP_EVENT_CRYPTO_COMPL); - + _odp_buffer_event_type_set( + odp_buffer_from_event(completion_event), + ODP_EVENT_CRYPTO_COMPL); /* 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; @@ -537,7 +519,9 @@ odp_crypto_compl_result(odp_crypto_compl_t completion_event, } void -odp_crypto_compl_free(odp_crypto_compl_t completion_event ODP_UNUSED) +odp_crypto_compl_free(odp_crypto_compl_t completion_event) { - /* We use the packet as the completion event so nothing to do here */ + _odp_buffer_event_type_set( + odp_buffer_from_event((odp_event_t)completion_event), + ODP_EVENT_PACKET); } diff --git a/platform/linux-generic/odp_event.c b/platform/linux-generic/odp_event.c index 17f4f43..d9e86a9 100644 --- a/platform/linux-generic/odp_event.c +++ b/platform/linux-generic/odp_event.c @@ -8,12 +8,9 @@ #include #include #include +#include int odp_event_type(odp_event_t event) { - odp_buffer_t buf; - - buf = odp_buffer_from_event(event); - - return _odp_buffer_type(buf); + return _odp_buffer_event_type(odp_buffer_from_event(event)); } diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 35e79a0..d92596e 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -364,6 +364,7 @@ odp_pool_t odp_pool_create(const char *name, tmp->size = 0; odp_atomic_init_u32(&tmp->ref_count, 0); tmp->type = params->type; + tmp->event_type = params->type; tmp->pool_hdl = pool->s.pool_hdl; tmp->uarea_addr = (void *)udat; tmp->uarea_size = p_udata_size;