From patchwork Mon Jun 3 14:50:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Nowak X-Patchwork-Id: 54177 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AE5E81B974; Mon, 3 Jun 2019 16:54:13 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 5FE265424 for ; Mon, 3 Jun 2019 16:54:09 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 07:54:08 -0700 X-ExtLoop1: 1 Received: from damiannx-mobl1.ger.corp.intel.com ([10.103.104.100]) by fmsmga001.fm.intel.com with ESMTP; 03 Jun 2019 07:54:07 -0700 From: Nowak To: dev@dpdk.org Cc: fiona.trahe@intel.com, arkadiuszx.kusztal@intel.com, Damian Nowak Date: Mon, 3 Jun 2019 16:50:40 +0200 Message-Id: <20190603145048.2596-2-damianx.nowak@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190603145048.2596-1-damianx.nowak@intel.com> References: <20190603145048.2596-1-damianx.nowak@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/9] crypto/qat: check buffer size for oop auth-cipher X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Damian Nowak This patch adds condition to be met when using wireless algorithms (SNOW3G, KASUMI, ZUC) in out-of-place auth-cipher operations. It verifies if there is enough room for the digest in the output buffer. Conditions rewritten for better readibility and possible SGL support. Signed-off-by: Damian Nowak --- drivers/crypto/qat/qat_sym.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index 8801ca5..4080c30 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -157,7 +157,7 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, uint32_t min_ofs = 0; uint64_t src_buf_start = 0, dst_buf_start = 0; uint8_t do_sgl = 0; - uint8_t wireless_auth = 0, in_place = 1; + uint8_t wireless_auth = 0, in_place = 1, digest_in_buffer = 0; struct rte_crypto_op *op = (struct rte_crypto_op *)in_op; struct qat_sym_op_cookie *cookie = (struct qat_sym_op_cookie *)op_cookie; @@ -513,6 +513,7 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, qat_req->comn_mid.src_data_addr = cookie->qat_sgl_src_phys_addr; else { + in_place = 0; ret = qat_sgl_fill_array(op->sym->m_dst, (int64_t)(dst_buf_start - rte_pktmbuf_iova(op->sym->m_dst)), @@ -533,18 +534,21 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, } else { qat_req->comn_mid.src_data_addr = src_buf_start; qat_req->comn_mid.dest_data_addr = dst_buf_start; - /* handle case of auth-gen-then-cipher with digest encrypted */ - if (wireless_auth && in_place && - (op->sym->auth.digest.phys_addr == - src_buf_start + auth_ofs + auth_len) && - (auth_ofs + auth_len + ctx->digest_length <= - cipher_ofs + cipher_len)) { - struct icp_qat_fw_comn_req_hdr *header = - &qat_req->comn_hdr; - ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET( - header->serv_specif_flags, - ICP_QAT_FW_LA_DIGEST_IN_BUFFER); - } + } + + /* Handle case of auth-gen-then-cipher with digest encrypted */ + if (wireless_auth && + (auth_ofs + auth_len + ctx->digest_length <= + cipher_ofs + cipher_len) && + (op->sym->auth.digest.phys_addr == + (in_place ? src_buf_start : dst_buf_start) + + auth_ofs + auth_len)) + digest_in_buffer = 1; + if (digest_in_buffer) { + struct icp_qat_fw_comn_req_hdr *header = &qat_req->comn_hdr; + ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET( + header->serv_specif_flags, + ICP_QAT_FW_LA_DIGEST_IN_BUFFER); } #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG