From patchwork Fri Dec 1 00:00:07 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: 120285 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp455040qgn; Thu, 30 Nov 2017 16:01:31 -0800 (PST) X-Google-Smtp-Source: AGs4zMbagYiIhwvfq5w7T25ax/T8VcVH10VoE09leVpE0hwhAfjui4ez095eeko0wkRFhdOkTRQr X-Received: by 10.200.40.157 with SMTP id i29mr6235445qti.86.1512086491454; Thu, 30 Nov 2017 16:01:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512086491; cv=none; d=google.com; s=arc-20160816; b=LSuhl0fK0Tr+/RMDftRhWDD8l0c43k2GnWj8vqxfvofJg8QXFL/8qDw+79/uSRiScM EAJPdMeIz87xHXarkFNa7nOO41XO4+TaBno6WMZ8aqnShXMI1xDuGoLn3OYKUE1EcHl+ scLsnTisQ1trjgknAqZqrbArklD4PT8589NbNFTOXNEsVxIOwMRfZwwMzrBk5Azy6ycZ qfFOAMtn3pgiwyMpjCfJDBB/sbozqCGugyjX5z9aQpTUeAmDycrX7tD3QYKJ1k8Y7WP5 fcLQder9ZytqhXpeRXXBXP19o1tXh9fyCSdaTvZiUxkDNPdAbOC4rlFF0olSpOkNpqnb VF+w== 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=AjOVflv9k2rPG3ZFZW0XYUeKoOT3HBM/kLU8J3ocyf8=; b=0G9vvyV8qrcX2Xe9ZbGOCgxgbpV43R2fH8RqtzwZTVxWd/jcoLYeHBJfl/vunHdoZw RmbNyKr2la54XwuG87db37jGwF3jaodWbQgDNHdYcHDO898hGFfFwmlNsiPB3eFkdTue GpjGcbvLXuogIQo8agRrd4gKoGBb3FNQ1dSPXdBQfV4e16lntCM/1zclKeQEkuzkavx6 1h4mQqqOKsGiSWPs3Jach/e3AWLJIGwd2Z7YN0ypEV61ueVbS7hmXifPW0L2AbZU09AW 4A7wRadSa/FLlvvBl7KlcDGcgs4bUFEfDXWL02rOy9w/odacfDjCJAawGKGcdkCl4KoX bVmQ== 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 j26si5098895qtj.15.2017.11.30.16.01.31; Thu, 30 Nov 2017 16:01:31 -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 1466760964; Fri, 1 Dec 2017 00:01: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,FREEMAIL_FROM, 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 27F256096A; Fri, 1 Dec 2017 00:00:21 +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 66BF96092D; Fri, 1 Dec 2017 00:00:15 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id A816F60943 for ; Fri, 1 Dec 2017 00:00:12 +0000 (UTC) Received: from mxback13g.mail.yandex.net (mxback13g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:92]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 4366245DC0 for ; Fri, 1 Dec 2017 03:00:11 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback13g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Ve3hce5FkK-0Bk4HMS4; Fri, 01 Dec 2017 03:00:11 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id xYJqeQ91tR-0AveLrte; Fri, 01 Dec 2017 03:00:10 +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: Fri, 1 Dec 2017 03:00:07 +0300 Message-Id: <1512086407-25684-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512086407-25684-1-git-send-email-odpbot@yandex.ru> References: <1512086407-25684-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 317 Subject: [lng-odp] [PATCH 2.0 v1 3/3] 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 --- /** Email created from pull request 317 (GBalakrishna:port_syzmon_crypto_changes) ** https://github.com/Linaro/odp/pull/317 ** Patch: https://github.com/Linaro/odp/pull/317.patch ** Base sha: 00c7441fae53949dd87855d48102f932f8f64537 ** Merge commit sha: 47d0d3921c6a03fb7ac9b994e06521598c5bd982 **/ 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;