From patchwork Tue Feb 7 18:06:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Eremin-Solenikov X-Patchwork-Id: 93577 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2318871qgi; Tue, 7 Feb 2017 10:06:32 -0800 (PST) X-Received: by 10.55.127.4 with SMTP id a4mr17551547qkd.215.1486490792266; Tue, 07 Feb 2017 10:06:32 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z59si3533346qtd.75.2017.02.07.10.06.31; Tue, 07 Feb 2017 10:06:32 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 8A38B62FA2; Tue, 7 Feb 2017 18:06:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id BD2DB62F23; Tue, 7 Feb 2017 18:06:27 +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 7882962F7A; Tue, 7 Feb 2017 18:06:25 +0000 (UTC) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by lists.linaro.org (Postfix) with ESMTPS id 2F38060EAB for ; Tue, 7 Feb 2017 18:06:23 +0000 (UTC) Received: by mail-lf0-f54.google.com with SMTP id v186so67746174lfa.1 for ; Tue, 07 Feb 2017 10:06:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QgMFjpTIxhGbwpa0sd3iORNS3pqwcoUsFuzslp9Yew0=; b=VAB6LV0iDwvkMpoQHIOLkkiKGPGbssQ4Qv4e3r5HouwWf/lPqz2iFqOPzOIQ8w3idt z25I9EuYdXLrtY9Q9cxehLJcXapFsiHj3XQ8bn/Y7Dw+0j3ipWbNrH06BpDbaOdDZkwE UwRu3+Tt85/IrG3n/JSb7KJKyg+MPZXou/Svy2T7MQhfGdBBE0kL/Yr5I4nigx60HrYu XeERG4FHHdFT3kwykKk9bR9aqzYMxx5rLlbI45kOuIKCLg++SKGZave3UrpOerwV8Lb3 AFmgeE190zcCS58zlrTmDzXv16etKvPW7FowpdbbcYJFhP9D3lsJEkmD4cCkwZ00TQoh VEcg== X-Gm-Message-State: AIkVDXIWt2e8VlsBEGfN9AKeXCF7Mxue3v/l2q6P/xWOPzFkYq1gjL/UtmoxpcFxt3U5zGy0Q6Y= X-Received: by 10.25.92.217 with SMTP id u86mr6542655lfi.5.1486490781690; Tue, 07 Feb 2017 10:06:21 -0800 (PST) Received: from forlindon.lumag.auriga.ru ([93.185.26.131]) by smtp.gmail.com with ESMTPSA id s20sm1548331lfe.41.2017.02.07.10.06.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 10:06:20 -0800 (PST) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Tue, 7 Feb 2017 21:06:15 +0300 Message-Id: <20170207180617.5169-1-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [lng-odp] [PATCH v2 1/3] linux-generic: crypto: add missing include X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" OpenSSL 1.1.0 headers do not include , so include it manually to fix the following error: In file included from ./include/odp_packet_internal.h:28:0, from odp_classification.c:13: ./include/odp_crypto_internal.h:55:5: error: unknown type name ‘EVP_CIPHER_CTX’ EVP_CIPHER_CTX *ctx; ^~~~~~~~~~~~~~ Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/include/odp_crypto_internal.h | 1 + 1 file changed, 1 insertion(+) -- 2.11.0 Reviewed-by: Bill Fischofer diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h index c7b893aa..f85b76ea 100644 --- a/platform/linux-generic/include/odp_crypto_internal.h +++ b/platform/linux-generic/include/odp_crypto_internal.h @@ -13,6 +13,7 @@ extern "C" { #include #include +#include #define MAX_IV_LEN 64 #define OP_RESULT_MAGIC 0x91919191 From patchwork Tue Feb 7 18:06:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Eremin-Solenikov X-Patchwork-Id: 93578 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2319092qgi; Tue, 7 Feb 2017 10:06:56 -0800 (PST) X-Received: by 10.237.53.164 with SMTP id c33mr16816692qte.121.1486490816283; Tue, 07 Feb 2017 10:06:56 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g5si3529036qtf.86.2017.02.07.10.06.55; Tue, 07 Feb 2017 10:06:56 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 816BD62F80; Tue, 7 Feb 2017 18:06:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3685062F82; Tue, 7 Feb 2017 18:06:29 +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 8586A62F7A; Tue, 7 Feb 2017 18:06:26 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id 784C662EA2 for ; Tue, 7 Feb 2017 18:06:24 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id z134so67705691lff.3 for ; Tue, 07 Feb 2017 10:06:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=rKxedAa6Gn8vGHPnFUA7R7dvLTyrdeIG1FYEeN6dYZ4=; b=J/PkyB6URDDOBR1QhR1PT6xts9YTZBZPYgsD15AjsJu9wytdRqV19cv6FfXNpjoBgL 32IGBAaUTcwifSjtFDHLIDnOmwT8+zO0K1t/HE7zoM3eCNG4fFbGcZiRZi4s9iN/PdXz ZTx+bHy3B7DZCPeiS6FRvtEOR1Wqd4FUpuEpzMAzt1CR8vs9nYbNpi5wiLAJ9d4NcfAa 1O2BX+JpIc1J7uaYGC4hnMSzTAS4O76o7OI6kNK9hlzdp99fDxMjA5JNkJ9sVCM/dwQ+ 2wmRWqIb0863uDhdm92oL98PSDvu3Cm8sxzadFwhkZORnjyB5+chnQ842AmY+zswLQcK jzNw== X-Gm-Message-State: AIkVDXLflrYZpm7bX7jbkhheSBGfU46m8Ve9GYOvIFdasUpXVQgOQHDMf7VUDOVsYyCuZcd7j7o= X-Received: by 10.25.56.70 with SMTP id d6mr6181219lfj.2.1486490783185; Tue, 07 Feb 2017 10:06:23 -0800 (PST) Received: from forlindon.lumag.auriga.ru ([93.185.26.131]) by smtp.gmail.com with ESMTPSA id s20sm1548331lfe.41.2017.02.07.10.06.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 10:06:22 -0800 (PST) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Tue, 7 Feb 2017 21:06:16 +0300 Message-Id: <20170207180617.5169-2-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170207180617.5169-1-dmitry.ereminsolenikov@linaro.org> References: <20170207180617.5169-1-dmitry.ereminsolenikov@linaro.org> Subject: [lng-odp] [PATCH v2 2/3] linux-generic: crypto: move OpenSSL locks out of global crypto data X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" In preparation to update crypto code for OpenSSL 1.1.0 move locks out of global data. Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 67 ++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 20 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index b53b0fc1..d83b8e09 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -64,7 +64,6 @@ typedef struct odp_crypto_global_s odp_crypto_global_t; struct odp_crypto_global_s { odp_spinlock_t lock; - odp_ticketlock_t **openssl_lock; odp_crypto_generic_session_t *free; odp_crypto_generic_session_t sessions[0]; }; @@ -954,16 +953,53 @@ static unsigned long openssl_thread_id(void) return (unsigned long)odp_thread_id(); } +odp_ticketlock_t *openssl_locks; + static void openssl_lock(int mode, int n, const char *file ODP_UNUSED, int line ODP_UNUSED) { if (mode & CRYPTO_LOCK) - odp_ticketlock_lock((odp_ticketlock_t *) - &global->openssl_lock[n]); + odp_ticketlock_lock(&openssl_locks[n]); else - odp_ticketlock_unlock((odp_ticketlock_t *) - &global->openssl_lock[n]); + odp_ticketlock_unlock(&openssl_locks[n]); +} + +static void openssl_init_locks(void) +{ + int nlocks; + size_t mem_size; + odp_shm_t shm; + int idx; + + nlocks = CRYPTO_num_locks(); + if (nlocks <= 0) + return; + + mem_size = nlocks * sizeof(odp_ticketlock_t); + + /* Allocate our globally shared memory */ + shm = odp_shm_reserve("crypto_openssl_locks", mem_size, + ODP_CACHE_LINE_SIZE, 0); + + openssl_locks = odp_shm_addr(shm); + + /* Clear it out */ + memset(openssl_locks, 0, mem_size); + + for (idx = 0; idx < nlocks; idx++) + odp_ticketlock_init(&openssl_locks[idx]); + + CRYPTO_set_id_callback(openssl_thread_id); + CRYPTO_set_locking_callback(openssl_lock); +} + +static int openssl_term_locks(void) +{ + CRYPTO_set_locking_callback(NULL); + CRYPTO_set_id_callback(NULL); + + return odp_shm_free(odp_shm_lookup("crypto_openssl_locks")); } int @@ -972,12 +1008,10 @@ odp_crypto_init_global(void) size_t mem_size; odp_shm_t shm; int idx; - int nlocks = CRYPTO_num_locks(); /* Calculate the memory size we need */ mem_size = sizeof(*global); mem_size += (MAX_SESSIONS * sizeof(odp_crypto_generic_session_t)); - mem_size += nlocks * sizeof(odp_ticketlock_t); /* Allocate our globally shared memory */ shm = odp_shm_reserve("crypto_pool", mem_size, @@ -995,17 +1029,7 @@ odp_crypto_init_global(void) } odp_spinlock_init(&global->lock); - if (nlocks > 0) { - global->openssl_lock = - (odp_ticketlock_t **)&global->sessions[MAX_SESSIONS]; - - for (idx = 0; idx < nlocks; idx++) - odp_ticketlock_init((odp_ticketlock_t *) - &global->openssl_lock[idx]); - - CRYPTO_set_id_callback(openssl_thread_id); - CRYPTO_set_locking_callback(openssl_lock); - } + openssl_init_locks(); return 0; } @@ -1024,8 +1048,11 @@ int odp_crypto_term_global(void) rc = -1; } - CRYPTO_set_locking_callback(NULL); - CRYPTO_set_id_callback(NULL); + ret = openssl_term_locks(); + if (ret < 0) { + ODP_ERR("shm free failed for crypto_openssl_locks\n"); + rc = -1; + } ret = odp_shm_free(odp_shm_lookup("crypto_pool")); if (ret < 0) { From patchwork Tue Feb 7 18:06:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Eremin-Solenikov X-Patchwork-Id: 93579 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2319340qgi; Tue, 7 Feb 2017 10:07:25 -0800 (PST) X-Received: by 10.233.235.66 with SMTP id b63mr16768301qkg.144.1486490845707; Tue, 07 Feb 2017 10:07:25 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d68si3528464qkg.155.2017.02.07.10.07.25; Tue, 07 Feb 2017 10:07:25 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 34FD862F82; Tue, 7 Feb 2017 18:07:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 8BB9F62FA2; Tue, 7 Feb 2017 18:06:34 +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 E11E362F82; Tue, 7 Feb 2017 18:06:27 +0000 (UTC) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by lists.linaro.org (Postfix) with ESMTPS id DC73F60EAB for ; Tue, 7 Feb 2017 18:06:25 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id x1so67774273lff.0 for ; Tue, 07 Feb 2017 10:06:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=EEBl9nEOd1QbCzHSigujBqqUuq6WeoFtFARutyk81zs=; b=o9r/YQXRhc/oITYyaCGoWwFCX0uhKw10bOeyHfFSLl3eLHgyUnGmzdW0DMcl03yHsM 8x00qjUy+UZeR9WO0JTeVAwnhy3bQiNSxPlO4PetbeDxIEJCmhE+oFuyOMWBPKK8FeEZ AXURs7Rlz19AzSFatZ1/zcVnX43tdR1Yh4JdbhxAFt/RCW766fOxra/nFMsTObwZgo2S qm8EKAiZJfjZNpvI6d7Uqhf0edTkxuwtTHC5pF7C/COv8qtad1H1CbmP0qgjVVc6fOBB eYlJn5H58DBGnLkdbpL1s5GQar71HjxH5HB+ajR7JlQXGb3CndhmuKyJMQssQkO4LfRM etHA== X-Gm-Message-State: AMke39lpKPrq5yqk65tO5quS0cAXYn5wtGciSAmH4jqo/lde6PfbFMjGOa/juecI4zZBYOH1Si4= X-Received: by 10.25.15.68 with SMTP id e65mr6302598lfi.117.1486490784591; Tue, 07 Feb 2017 10:06:24 -0800 (PST) Received: from forlindon.lumag.auriga.ru ([93.185.26.131]) by smtp.gmail.com with ESMTPSA id s20sm1548331lfe.41.2017.02.07.10.06.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 10:06:23 -0800 (PST) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Tue, 7 Feb 2017 21:06:17 +0300 Message-Id: <20170207180617.5169-3-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170207180617.5169-1-dmitry.ereminsolenikov@linaro.org> References: <20170207180617.5169-1-dmitry.ereminsolenikov@linaro.org> Subject: [lng-odp] [PATCH v2 3/3] linux-generic: crypto: support OpenSSL 1.1.0 X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" OpenSSL 1.1.0 uses new threading API. It is no longer necessary to set locking callbacks to use OpenSSL in a multi-threaded environment. The old threading API should no longer be used. So don't allocate/set locking callbacks with new OpenSSL. Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index d83b8e09..d1d32497 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -26,6 +26,7 @@ #include #include #include +#include #define MAX_SESSIONS 32 @@ -948,16 +949,18 @@ odp_crypto_operation(odp_crypto_op_param_t *param, return 0; } -static unsigned long openssl_thread_id(void) +static +unsigned long ODP_UNUSED openssl_thread_id(void) { return (unsigned long)odp_thread_id(); } odp_ticketlock_t *openssl_locks; -static void openssl_lock(int mode, int n, - const char *file ODP_UNUSED, - int line ODP_UNUSED) +static +void ODP_UNUSED openssl_lock(int mode, int n, + const char *file ODP_UNUSED, + int line ODP_UNUSED) { if (mode & CRYPTO_LOCK) odp_ticketlock_lock(&openssl_locks[n]); @@ -972,6 +975,10 @@ static void openssl_init_locks(void) odp_shm_t shm; int idx; + /* OpenSSL does not need locks after 1.1.0 */ + if (OPENSSL_VERSION_NUMBER >= 0x10100000L) + return; + nlocks = CRYPTO_num_locks(); if (nlocks <= 0) return; @@ -996,6 +1003,10 @@ static void openssl_init_locks(void) static int openssl_term_locks(void) { + /* OpenSSL does not need locks after 1.1.0 */ + if (OPENSSL_VERSION_NUMBER >= 0x10100000L) + return 0; + CRYPTO_set_locking_callback(NULL); CRYPTO_set_id_callback(NULL);