From patchwork Wed Dec 6 08:00:04 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: 120792 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6753031qgn; Wed, 6 Dec 2017 00:01:44 -0800 (PST) X-Google-Smtp-Source: AGs4zMaKLV1vAeN+CQiE9VBot1bKdJIPapKII+70OOJs/bD0z8PMqu1WoBYPlfidSD5iCC+BC7As X-Received: by 10.200.3.8 with SMTP id q8mr3855751qtg.212.1512547304027; Wed, 06 Dec 2017 00:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512547304; cv=none; d=google.com; s=arc-20160816; b=JwNNjISBU4mx0reE6YZfrzw4iOSVsu+GKQVJQrd32M96Jp++2AIbL/4ddPyRvkS67C iqojqsZDNYQnbVPBWYP1nvcc1aMXYLblJUseWxxCHnhuNqv5MNwpWuGITxjStbnNKkhc wSdD8r9cttN4iNe0ZEV4PDl7bGvqrP+YBEn+oImhroxxVgsxSLHHc2FbW04QL6Z1PyfR VihNC6Vt5YIY+DpnD/qEanOpzvqyn+rHM75yY2MRvSy12jUWHYtZl4lDRu1QpEpEDu8+ UqM6/QSMLKGhLVP5VLwGoQt8XePoLrafkchGaVsP/ckeGS/TdoSL1tyFSz5dysezu7cA i0bA== 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=3/NyGS4mqON54QRgN7L5tltQ4X9cj+LE5oZSvzEXWVc=; b=chSS1WcOYQOuvPu7mjQ1egFB/CRYuquZ1BoAwjCBZQQ+2Vr9o3weNR3aM4rlDmUTKJ YoRc3JV/Ywb3wsSxhxcdniL6qL7iU3y9YGiBRA95J3kWCRYJvkNwFXGYyKf7xDRGVRjQ Ehz8idEDrcf7/TWjuF0fAgPia6h9Yb64VDffnl5T8d5lQ0Xqyb2HNt6ppC7LInL7b7Td Z2JEUtu/lft6W+DjxWhGjeZY4PFlpLSdEAuBOXrxr0yXnfdqWfbXRb+/aJhTYXaDgFPr 85NdPq/+gOszIPRyVm39MB4CKrhmfXVtqMKJL7Y4SIR6P/dWjPlnEbS53h1oI2olTiBX YX7w== 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 82si715721qko.420.2017.12.06.00.01.43; Wed, 06 Dec 2017 00:01:44 -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 54105608FD; Wed, 6 Dec 2017 08:01:43 +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 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 D800D608BC; Wed, 6 Dec 2017 08:00:44 +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 232A360903; Wed, 6 Dec 2017 08:00:29 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id ED123607FB for ; Wed, 6 Dec 2017 08:00:12 +0000 (UTC) Received: from mxback7o.mail.yandex.net (mxback7o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::21]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 4FF657845D1 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 mxback7o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Ar4wlw45Az-0BkS7a7Y; Wed, 06 Dec 2017 11:00:11 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 4V0UNXlOkv-096m2KtB; Wed, 06 Dec 2017 11:00:09 +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:04 +0300 Message-Id: <1512547207-1806-3-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 2/5] 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 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 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 | 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);