From patchwork Thu Apr 14 03:11:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zengzhaoxiu@163.com X-Patchwork-Id: 8830931 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 355D09F3A0 for ; Thu, 14 Apr 2016 03:11:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C6BB20295 for ; Thu, 14 Apr 2016 03:11:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6072C201F2 for ; Thu, 14 Apr 2016 03:11:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751986AbcDNDLd (ORCPT ); Wed, 13 Apr 2016 23:11:33 -0400 Received: from m50-135.163.com ([123.125.50.135]:56298 "EHLO m50-135.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbcDNDLb (ORCPT ); Wed, 13 Apr 2016 23:11:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=NiySag/IXzNAokTK+x KxZR39sUH2r7UuYsZ5VlJc1aE=; b=Qccqt7I2dmakr3wDdjpDhMz/3pskvHW7cf EocHRl+Vkax7n5QUYQwbozrYn1hPemYDgyudsxUqifSpV8wEks44PYYbNZRYlf53 3UVuxf47bBnFFuHuJI4BTxr7FufF3yI068Z5bnw/SfgMjDJE9//2cd7Zt5Tx2WRo 15Rgkkp5I= Received: from zhaoxiuzeng-VirtualBox.spreadtrum.com (unknown [112.95.225.98]) by smtp5 (Coremail) with SMTP id D9GowACnNcBTCg9X9m_cCQ--.4083S2; Thu, 14 Apr 2016 11:11:19 +0800 (CST) From: zengzhaoxiu@163.com To: linux-kernel@vger.kernel.org Cc: Zhaoxiu Zeng , Tadeusz Struk , Herbert Xu , "David S. Miller" , Pingchao Yang , Bruce Allan , qat-linux@intel.com, linux-crypto@vger.kernel.org Subject: [PATCH V3 21/29] crypto: use parity functions in qat_hal Date: Thu, 14 Apr 2016 11:11:12 +0800 Message-Id: <1460603474-5500-1-git-send-email-zengzhaoxiu@163.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1460601525-3822-1-git-send-email-zengzhaoxiu@163.com> References: <1460601525-3822-1-git-send-email-zengzhaoxiu@163.com> X-CM-TRANSID: D9GowACnNcBTCg9X9m_cCQ--.4083S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxAF4kuF43Zw4rXry3Gr45Jrb_yoW5Wr1DpF Z0yFyxXrWkKFnxuF1DA3W2y3WSq3yqkFy5CayxGw1v939FqFZ8G342kF17Za42vrWDZwsF vFyUJr17Xrsru3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bodgAUUUUU= X-Originating-IP: [112.95.225.98] X-CM-SenderInfo: p2hqw6xkdr5xrx6rljoofrz/1tbivxdLgFWBRQ-PfQAAsP Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Zhaoxiu Zeng Signed-off-by: Zhaoxiu Zeng --- drivers/crypto/qat/qat_common/qat_hal.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c index 1e480f1..318558f 100644 --- a/drivers/crypto/qat/qat_common/qat_hal.c +++ b/drivers/crypto/qat/qat_common/qat_hal.c @@ -546,17 +546,6 @@ static void qat_hal_disable_ctx(struct icp_qat_fw_loader_handle *handle, qat_hal_wr_ae_csr(handle, ae, CTX_ENABLES, ctx); } -static uint64_t qat_hal_parity_64bit(uint64_t word) -{ - word ^= word >> 1; - word ^= word >> 2; - word ^= word >> 4; - word ^= word >> 8; - word ^= word >> 16; - word ^= word >> 32; - return word & 1; -} - static uint64_t qat_hal_set_uword_ecc(uint64_t uword) { uint64_t bit0_mask = 0xff800007fffULL, bit1_mask = 0x1f801ff801fULL, @@ -566,13 +555,13 @@ static uint64_t qat_hal_set_uword_ecc(uint64_t uword) /* clear the ecc bits */ uword &= ~(0x7fULL << 0x2C); - uword |= qat_hal_parity_64bit(bit0_mask & uword) << 0x2C; - uword |= qat_hal_parity_64bit(bit1_mask & uword) << 0x2D; - uword |= qat_hal_parity_64bit(bit2_mask & uword) << 0x2E; - uword |= qat_hal_parity_64bit(bit3_mask & uword) << 0x2F; - uword |= qat_hal_parity_64bit(bit4_mask & uword) << 0x30; - uword |= qat_hal_parity_64bit(bit5_mask & uword) << 0x31; - uword |= qat_hal_parity_64bit(bit6_mask & uword) << 0x32; + uword |= (uint64_t)parity64(bit0_mask & uword) << 0x2C; + uword |= (uint64_t)parity64(bit1_mask & uword) << 0x2D; + uword |= (uint64_t)parity64(bit2_mask & uword) << 0x2E; + uword |= (uint64_t)parity64(bit3_mask & uword) << 0x2F; + uword |= (uint64_t)parity64(bit4_mask & uword) << 0x30; + uword |= (uint64_t)parity64(bit5_mask & uword) << 0x31; + uword |= (uint64_t)parity64(bit6_mask & uword) << 0x32; return uword; } @@ -853,15 +842,14 @@ void qat_hal_wr_umem(struct icp_qat_fw_loader_handle *handle, uaddr |= UA_ECS; qat_hal_wr_ae_csr(handle, ae, USTORE_ADDRESS, uaddr); for (i = 0; i < words_num; i++) { - unsigned int uwrd_lo, uwrd_hi, tmp; + unsigned int uwrd_lo, uwrd_hi; uwrd_lo = ((data[i] & 0xfff0000) << 4) | (0x3 << 18) | ((data[i] & 0xff00) << 2) | (0x3 << 8) | (data[i] & 0xff); uwrd_hi = (0xf << 4) | ((data[i] & 0xf0000000) >> 28); - uwrd_hi |= (hweight32(data[i] & 0xffff) & 0x1) << 8; - tmp = ((data[i] >> 0x10) & 0xffff); - uwrd_hi |= (hweight32(tmp) & 0x1) << 9; + uwrd_hi |= parity16(data[i]) << 8; + uwrd_hi |= parity16(data[i] >> 16) << 9; qat_hal_wr_ae_csr(handle, ae, USTORE_DATA_LOWER, uwrd_lo); qat_hal_wr_ae_csr(handle, ae, USTORE_DATA_UPPER, uwrd_hi); }