From patchwork Fri Dec 1 00:00:06 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: 120284 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp454372qgn; Thu, 30 Nov 2017 16:00:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMaf0X4JZIvJGlMo3eD3b6AsVFnNPKNXLHrBOEB3KQFotiJ2pbXEi/fXzFaj2JR4vGFP/W02 X-Received: by 10.55.127.193 with SMTP id a184mr5381837qkd.119.1512086454718; Thu, 30 Nov 2017 16:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512086454; cv=none; d=google.com; s=arc-20160816; b=fp1WMZC2xUD4tKjill9X1/tG+s4EKxV6otrPUuctnDeEJMXAB0V33oVfitGt+bLxxB DjTfXLHgerGftVs5MNa425UyejAHm/R34D2EfmHp9az7YUBoWyLgwHLFq44eK9qtV2L5 gCG89Rwb4U/4DX9iAAjBj6vVGWMUfINWExnzQA3N7zHyl7aR4OTg/3+2SvkNSobEZg89 ytxSY5eLuaNV0V6dLc8Yk9wO6tn1YCqfLFZmmmF2atipqWsFQnCwkPTZR0YE03BTeA1T YUsz2GMvyABvwr5Fb2/P8tiqFOslgnsaeS2rshs1LEAmNOr5JGzBUPhoXyrWSrHKQ/aE ygrA== 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=Vt9E5L6oj2T9ORpep2U5s9uOjXGu2uBtMJVwhm9FXWg=; b=QWY70Gh6h4XO09pNFT/CUv/DaCM+JdQS71Zm4aBA4hXf7cs1SUPnTmIwSb5vEuei3/ b5oI6wsbl3GkbI2fyMXtHi5gzKoNHlhqqiafeFvgCtllwBcTr5tBfbTTDd3nlK08A7+i +DUDO+kpICdLDFleByVJzflznm4LFXAZOCfWQ91l25nJ89S3xLc9ffP+6PzZH32AGj/N 0npWnjZQUR1cLOWa3FTyx4iKVoDzSzwe2gxcevCqhgTLVylEIc7l5ufWr1LA7xQ0wk2b 2vjXFiOtatv0huTQJQvmeZ1716ShUylQ7yiQBrVhrCTxOerxB6R70fidNe5UJsmHDV9s H5RQ== 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 f95si3120156qkh.109.2017.11.30.16.00.54; Thu, 30 Nov 2017 16:00:54 -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 5D6D060972; Fri, 1 Dec 2017 00:00:54 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 C1C1C60958; Fri, 1 Dec 2017 00:00:17 +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 20DCB6092D; Fri, 1 Dec 2017 00:00:15 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id 237F76092D for ; Fri, 1 Dec 2017 00:00:12 +0000 (UTC) Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 9D22B4441604 for ; Fri, 1 Dec 2017 03:00:10 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id DhVvyHrdlV-0A4KwNsk; Fri, 01 Dec 2017 03:00:10 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id xYJqeQ91tR-0AvqPgga; 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:06 +0300 Message-Id: <1512086407-25684-3-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 2/3] linux-dpdk: Changes which are needed for odp_crypto to work. 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 All the changes are within the linux-dpdk/odp_crypto.c file: 1) Added missing brackets which made it impossible to to create a crypto session 2) Increased the number of queues created, from nb_queue_pairs - 1 to nb_queue_pairs, what seems to work better 3) Removed a memory leak - the memory allocated for iv and aad were not freed Signed-off-by: Szymon Sliwa 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 | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c index 8e0f8a9df..9844f2dd7 100644 --- a/platform/linux-dpdk/odp_crypto.c +++ b/platform/linux-dpdk/odp_crypto.c @@ -271,7 +271,7 @@ int odp_crypto_init_global(void) qp_conf.nb_descriptors = NB_MBUF; - for (queue_pair = 0; queue_pair < nb_queue_pairs - 1; + for (queue_pair = 0; queue_pair < nb_queue_pairs; queue_pair++) { rc = rte_cryptodev_queue_pair_setup(cdev_id, queue_pair, @@ -898,11 +898,12 @@ int odp_crypto_session_create(odp_crypto_session_param_t *param, /* Setup session */ session = rte_cryptodev_sym_session_create(cdev_id, first_xform); - if (session == NULL) + if (session == NULL) { /* remove the crypto_session_entry_t */ memset(entry, 0, sizeof(*entry)); free_session(entry); return -1; + } entry->rte_session = (intptr_t)session; entry->cipher_xform = cipher_xform; @@ -1216,6 +1217,9 @@ int odp_crypto_int(odp_packet_t pkt_in, goto err; } + op->sym->auth.aad.data = NULL; + op->sym->cipher.iv.data = NULL; + odp_spinlock_unlock(&global->lock); /* Set crypto operation data parameters */ @@ -1242,9 +1246,8 @@ int odp_crypto_int(odp_packet_t pkt_in, if (aad_len > 0) { op->sym->auth.aad.data = rte_malloc("aad", aad_len, 0); if (op->sym->auth.aad.data == NULL) { - rte_crypto_op_free(op); ODP_ERR("Failed to allocate memory for AAD"); - goto err; + goto err_op_free; } memcpy(op->sym->auth.aad.data, aad_head, aad_len); @@ -1254,16 +1257,14 @@ int odp_crypto_int(odp_packet_t pkt_in, } if (entry->iv.length == 0) { - rte_crypto_op_free(op); ODP_ERR("Wrong IV length"); - goto err; + goto err_op_free; } op->sym->cipher.iv.data = rte_malloc("iv", entry->iv.length, 0); if (op->sym->cipher.iv.data == NULL) { - rte_crypto_op_free(op); ODP_ERR("Failed to allocate memory for IV"); - goto err; + goto err_op_free; } if (param->override_iv_ptr) { @@ -1300,18 +1301,16 @@ int odp_crypto_int(odp_packet_t pkt_in, rc = rte_cryptodev_enqueue_burst(rte_session->dev_id, queue_pair, &op, 1); if (rc == 0) { - rte_crypto_op_free(op); ODP_ERR("Failed to enqueue packet"); - goto err; + goto err_op_free; } rc = rte_cryptodev_dequeue_burst(rte_session->dev_id, queue_pair, &op, 1); if (rc == 0) { - rte_crypto_op_free(op); ODP_ERR("Failed to dequeue packet"); - goto err; + goto err_op_free; } out_pkt = (odp_packet_t)op->sym->m_src; @@ -1331,6 +1330,8 @@ int odp_crypto_int(odp_packet_t pkt_in, op_result = get_op_result_from_packet(out_pkt); *op_result = local_result; + rte_free(op->sym->cipher.iv.data); + rte_free(op->sym->auth.aad.data); rte_crypto_op_free(op); /* Synchronous, simply return results */ @@ -1338,6 +1339,11 @@ int odp_crypto_int(odp_packet_t pkt_in, return 0; +err_op_free: + rte_free(op->sym->cipher.iv.data); + rte_free(op->sym->auth.aad.data); + rte_crypto_op_free(op); + err: if (allocated) { odp_packet_free(out_pkt);