From patchwork Wed Dec 6 08:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 120795 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6755401qgn; Wed, 6 Dec 2017 00:04:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMaDjMHHnY7hzLSoMAzhy+1EAW5E6/jOiAD03wr9P3Lv6eXjI6cLXSJ8bCecMn5el1XJIBmC X-Received: by 10.200.4.7 with SMTP id v7mr3951744qtg.129.1512547457219; Wed, 06 Dec 2017 00:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512547457; cv=none; d=google.com; s=arc-20160816; b=gwMYGlmPZutEXOeW4X42aPgMxZXCnLZ6OU9+Rwp5u5CYRLT/HilNRaYBnt2Isuzs6S TdGiM/+EyaGwXjqMbH/rRZI3qQEUfy0uP8csV/sZlNncpXH+fIpp7p/21Kc3U96NhH0U 2C8GOXE5aS0rRyskLs1CwH3hzK0eSOF3absyGYV592a7NqxZHaheZv4gwYfwFl/hjffb g+628HyGyUKUA9AHJwYbytXgsZP4Eu1/sOg+vTaK5tJW0Dzqi8/eyLAAsrGFZL7RPJ18 ZO3Rqv3b5o3L/r6HG0bPP01nOuBteAbalPElOXFhcnE8qpBPPCMH+LpRJacxRqAXu5hD HeSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=kNtxSLFEy0RP3NKC1tcsfhy7x72zWzIr2jY+MIoWs1E=; b=J3+bw2Lmif5NGjoS+NQk/Oxbk2EEJYAtvgZTFQIE76fKel7XmcYDFlIuF74R+n/GNC E0JV8HbOHPhRTo+XjOT0VbjuY/DFUOlW3laz7XLX62b3F1yc9x77Bn4CK5tfzezaYf5O bFz3ZFnfRbxoSASArU6I0s4VTqLFekP0veAK0uaXQsts/paI+UxcqPYibsSBNabjKxaH cIhRlWf/InfEXDk+VSuORdwMaxFi777iYPANiBg0CM+jVoFRIxWOZsJt7PiQGtGeL/9G qzP2YFcxQMIkwK9Wh2RwLTAJhJuIgNpc4mbC5clAK3Oy2Na3KJsyPcfQLMfbsGR0uR/O MctA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id v37si721232qtg.324.2017.12.06.00.04.16; Wed, 06 Dec 2017 00:04:17 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id D983E60927; Wed, 6 Dec 2017 08:04:16 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL 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 9C34060939; Wed, 6 Dec 2017 08:01:04 +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 DD7E0608BA; Wed, 6 Dec 2017 08:00:36 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 9529560918 for ; Wed, 6 Dec 2017 08:00:13 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward103j.mail.yandex.net (Yandex) with ESMTP id CCDBD34C48E7 for ; Wed, 6 Dec 2017 11:00:11 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FLbsGC27I9-0BjOTQvW; Wed, 06 Dec 2017 11:00:11 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 4V0UNXlOkv-0B6OiIls; Wed, 06 Dec 2017 11:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 6 Dec 2017 11:00:05 +0300 Message-Id: <1512547207-1806-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512547207-1806-1-git-send-email-odpbot@yandex.ru> References: <1512547207-1806-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 323 Subject: [lng-odp] [PATCH 2.0 v1 3/5] linux-dpdk: crypto bug fixes 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" From: Balakrishna Garapati Signed-off-by: Balakrishna Garapati Reviewed-by: Yi He --- /** Email created from pull request 323 (heyi-linaro:2.0-linux-dpdk-make-check) ** https://github.com/Linaro/odp/pull/323 ** Patch: https://github.com/Linaro/odp/pull/323.patch ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537 ** Merge commit sha: 97e968c4c23266a903016fe9bda392687b44b08f **/ platform/linux-dpdk/odp_crypto.c | 77 ++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c index 9844f2dd7..ea014c8e8 100644 --- a/platform/linux-dpdk/odp_crypto.c +++ b/platform/linux-dpdk/odp_crypto.c @@ -808,40 +808,53 @@ int odp_crypto_session_create(odp_crypto_session_param_t *param, /* Default to successful result */ *status = ODP_CRYPTO_SES_CREATE_ERR_NONE; - /* Cipher Data */ - cipher_xform.cipher.key.data = rte_malloc("crypto key", - param->cipher_key.length, 0); - if (cipher_xform.cipher.key.data == NULL) { - ODP_ERR("Failed to allocate memory for cipher key\n"); - /* remove the crypto_session_entry_t */ - memset(entry, 0, sizeof(*entry)); - free_session(entry); - return -1; - } - cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; cipher_xform.next = NULL; - cipher_xform.cipher.key.length = param->cipher_key.length; - memcpy(cipher_xform.cipher.key.data, - param->cipher_key.data, - param->cipher_key.length); - - /* Authentication Data */ - auth_xform.auth.key.data = rte_malloc("auth key", - param->auth_key.length, 0); - if (auth_xform.auth.key.data == NULL) { - ODP_ERR("Failed to allocate memory for auth key\n"); - /* remove the crypto_session_entry_t */ - memset(entry, 0, sizeof(*entry)); - free_session(entry); - return -1; + + if (param->cipher_key.length) { + /* Cipher Data */ + cipher_xform.cipher.key.data = rte_malloc("crypto key", + param->cipher_key.length, 0); + if (cipher_xform.cipher.key.data == NULL) { + ODP_ERR("Failed to allocate memory for cipher key\n"); + /* remove the crypto_session_entry_t */ + memset(entry, 0, sizeof(*entry)); + free_session(entry); + return -1; + } + + cipher_xform.cipher.key.length = param->cipher_key.length; + memcpy(cipher_xform.cipher.key.data, + param->cipher_key.data, + param->cipher_key.length); + } else { + cipher_xform.cipher.key.data = 0; + cipher_xform.cipher.key.length = 0; } + auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; auth_xform.next = NULL; - auth_xform.auth.key.length = param->auth_key.length; - memcpy(auth_xform.auth.key.data, - param->auth_key.data, - param->auth_key.length); + + if (param->auth_key.length) { + /* Authentication Data */ + auth_xform.auth.key.data = rte_malloc("auth key", + param->auth_key.length, 0); + if (auth_xform.auth.key.data == NULL) { + ODP_ERR("Failed to allocate memory for auth key\n"); + /* remove the crypto_session_entry_t */ + memset(entry, 0, sizeof(*entry)); + free_session(entry); + return -1; + } + auth_xform.auth.key.length = param->auth_key.length; + memcpy(auth_xform.auth.key.data, + param->auth_key.data, + param->auth_key.length); + } else { + auth_xform.auth.key.data = 0; + auth_xform.auth.key.length = 0; + } + /* Derive order */ if (ODP_CRYPTO_OP_ENCODE == param->op) @@ -1271,11 +1284,13 @@ int odp_crypto_int(odp_packet_t pkt_in, memcpy(op->sym->cipher.iv.data, param->override_iv_ptr, entry->iv.length); + op->sym->cipher.iv.phys_addr = + rte_malloc_virt2phy(op->sym->cipher.iv.data); + op->sym->cipher.iv.length = entry->iv.length; } else if (entry->iv.data) { memcpy(op->sym->cipher.iv.data, entry->iv.data, entry->iv.length); - op->sym->cipher.iv.phys_addr = rte_malloc_virt2phy(op->sym->cipher.iv.data); op->sym->cipher.iv.length = entry->iv.length; @@ -1326,7 +1341,7 @@ int odp_crypto_int(odp_packet_t pkt_in, (rc_auth == ODP_CRYPTO_ALG_ERR_NONE); _odp_buffer_event_subtype_set(packet_to_buffer(out_pkt), - ODP_EVENT_PACKET_BASIC); + ODP_EVENT_PACKET_CRYPTO); op_result = get_op_result_from_packet(out_pkt); *op_result = local_result;