From patchwork Sun Mar 27 07:30:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoxiu Zeng X-Patchwork-Id: 8675511 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8F179C0553 for ; Sun, 27 Mar 2016 07:31:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C4A02021A for ; Sun, 27 Mar 2016 07:31:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9DFD20219 for ; Sun, 27 Mar 2016 07:31:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751806AbcC0HbZ (ORCPT ); Sun, 27 Mar 2016 03:31:25 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:35750 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751331AbcC0HbY (ORCPT ); Sun, 27 Mar 2016 03:31:24 -0400 Received: by mail-pa0-f66.google.com with SMTP id fl4so11435377pad.2; Sun, 27 Mar 2016 00:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:cc:to:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=GlJvcTHuP8qeBQqo57SdEtOfDfTWdIa0H7xl6DuppBY=; b=FmbSFidk87QLIQ9GjhUclKnSegrt88DDbTR4hO/lO9/608FfcOIEqzfZBt0djl8wve RM84lHP7R+etypX538HdR8ZEznBiKsySh9yIMy3rGMorWuO+50+MKZx897l5eGwTY9ok gUU7YyW0XXeD+VEIDV7/c1VhP6hRr+CjipD6n+5+7CZn5PvGHFbHGJMEgEHwwJ9oaQP4 rgyaJC0yH7JHKt6yllB8SoOzPCcno8TAaK9FtPAn/rEognjTgSmW7hcu20WPb4ZRczh3 xifuF/mHmYldlWQuK6qQe11W5+uekAM4LoLt8Ltq9B7cufTg5KE1bPYPL98JxDcN7Rqm kSTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:references:cc:to:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=GlJvcTHuP8qeBQqo57SdEtOfDfTWdIa0H7xl6DuppBY=; b=VsAnb62C9rOT3yZezxvn4PCWgupHYxsShAuZyf5xIY603OBMTizQA3XPprJ3gZ3PlX dciFTVje/ywXT6j3vjbuRq0MEk4l/Qkb7kEd9pNeDIf/mTGRS5SOVov/uCYpKnxak5V0 oVTnMz+8Go5E+5lEEq8QcixqKRjovXRs05MeNucvTD6XAMRbFR9YHT6KVlNAOFjKZwmF 3YK8MJGEqLqi8mwXBv+mnlRd4F6TEkZLwqDH7IRPbaaoN2zDlkHFLpGxLAMvo8RjPyRd ybP8l1QLtibwreXEROl3cGuPaGxJRVA1gJ8XmkaB4wkJaBYIuJDWJQYDJWWUvCE4zRkw CNYg== X-Gm-Message-State: AD7BkJKk5GXWfI7KGVvaKEjaeDIHhPLfyaOVrhJXT07YOMKIU3LB/3DTGl/gzIrf1gZMQQ== X-Received: by 10.66.229.35 with SMTP id sn3mr33062342pac.77.1459063883808; Sun, 27 Mar 2016 00:31:23 -0700 (PDT) Received: from [0.0.0.0] (politkovskaja.torservers.net. [77.247.181.165]) by smtp.googlemail.com with ESMTPSA id h85sm27064734pfj.52.2016.03.27.00.30.59 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2016 00:31:23 -0700 (PDT) Subject: [PATCH 23/31] crypto: qat: use parity functions in qat_hal.c References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Cc: linux-kernel@vger.kernel.org, qat-linux@intel.com, linux-crypto@vger.kernel.org To: Tadeusz Struk , Herbert Xu , "David S. Miller" , Pingchao Yang , Bruce Allan From: "zhaoxiu.zeng" Message-ID: <56F78C27.6010307@gmail.com> Date: Sun, 27 Mar 2016 15:30:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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: Zeng Zhaoxiu Signed-off-by: Zeng Zhaoxiu --- 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); }