From patchwork Tue Apr 7 17:34:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Streetman X-Patchwork-Id: 6174151 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 EA640BF4A6 for ; Tue, 7 Apr 2015 17:37:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E74B1203A5 for ; Tue, 7 Apr 2015 17:37:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C468020263 for ; Tue, 7 Apr 2015 17:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753525AbbDGRfZ (ORCPT ); Tue, 7 Apr 2015 13:35:25 -0400 Received: from mail-ie0-f176.google.com ([209.85.223.176]:35620 "EHLO mail-ie0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753450AbbDGRfW (ORCPT ); Tue, 7 Apr 2015 13:35:22 -0400 Received: by ierf6 with SMTP id f6so53248923ier.2; Tue, 07 Apr 2015 10:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0DJQuL5tRVEFLCZyJR8dYipDIYHLe2biqifw/S3OEdI=; b=c1TC3e5h6JeSnvLB5y4qxJuOXCO9KxImJ8xZJlyAjr7VoW/oVOv5y9g4TmXz3ELmAJ OiW76kvwnVhIp5GKvUWzY7uKiY+1kN+xeE1AWSW2dsFGmVtJ8A5iKnOWqD6aJo4eEZgv jtHvlrXLKNu46MbYEWyAbUi9T9UFxrTieZUpYiMU/IFiwHiNhBxA5WbyEa5fYThMXVwG cXjkXQDq1S5Ax8ryioKc+MCkPJ9kK+ItxzHJOauwC4kStHDE8Q9kIA6jRe/jCRzDxW4I 4ASnZ3+aLpUR9uz+rU3MwrHt1dj46kgc8MAbt3TAJKKKhqmpLnWCiUbvAXl7kSCbzxy0 UfUA== X-Received: by 10.43.6.65 with SMTP id oj1mr26658056icb.75.1428428121946; Tue, 07 Apr 2015 10:35:21 -0700 (PDT) Received: from toughbook.com (user-0c8ho8q.cable.mindspring.com. [24.136.225.26]) by mx.google.com with ESMTPSA id i20sm5139261igh.16.2015.04.07.10.35.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 10:35:21 -0700 (PDT) From: Dan Streetman To: Herbert Xu , "David S. Miller" , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Cc: Seth Jennings , Robert Jennings , Marcelo Henrique Cerri , Fionnuala Gunter , linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Dan Streetman Subject: [PATCH 06/11] drivers/crypto/nx: add nx842 constraints Date: Tue, 7 Apr 2015 13:34:25 -0400 Message-Id: <1428428070-17803-7-git-send-email-ddstreet@ieee.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1428428070-17803-1-git-send-email-ddstreet@ieee.org> References: <1428428070-17803-1-git-send-email-ddstreet@ieee.org> 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 Add "constraints" for the NX-842 driver. The constraints are used to indicate what the current NX-842 platform driver is capable of. The constraints tell the NX-842 user what alignment, min and max length, and length multiple each provided buffers should conform to. These are required because the 842 hardware requires buffers to meet specific constraints that vary based on platform - for example, the pSeries max length is much lower than the PowerNV max length. These constraints are used by a later patch that improves the crypto 842 driver. Signed-off-by: Dan Streetman --- drivers/crypto/nx/nx-842-pseries.c | 10 ++++++++++ drivers/crypto/nx/nx-842.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/crypto/nx/nx-842.h | 2 ++ include/linux/nx842.h | 9 +++++++++ 4 files changed, 59 insertions(+) diff --git a/drivers/crypto/nx/nx-842-pseries.c b/drivers/crypto/nx/nx-842-pseries.c index 728a148..baa2e52 100644 --- a/drivers/crypto/nx/nx-842-pseries.c +++ b/drivers/crypto/nx/nx-842-pseries.c @@ -40,6 +40,13 @@ MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); /* IO buffer must be 128 byte aligned */ #define IO_BUFFER_ALIGN 128 +static struct nx842_constraints nx842_pseries_constraints = { + .alignment = IO_BUFFER_ALIGN, + .multiple = DDE_BUFFER_LAST_MULT, + .minimum = IO_BUFFER_ALIGN, + .maximum = PAGE_SIZE, /* dynamic, max_sync_size */ +}; + struct nx842_header { int blocks_nr; /* number of compressed blocks */ int offset; /* offset of the first block (from beginning of header) */ @@ -840,6 +847,8 @@ static int nx842_OF_upd_maxsyncop(struct nx842_devdata *devdata, goto out; } + nx842_pseries_constraints.maximum = devdata->max_sync_size; + devdata->max_sync_sg = (unsigned int)min(maxsynccop->comp_sg_limit, maxsynccop->decomp_sg_limit); if (devdata->max_sync_sg < 1) { @@ -1113,6 +1122,7 @@ static struct attribute_group nx842_attribute_group = { static struct nx842_driver nx842_pseries_driver = { .owner = THIS_MODULE, + .constraints = &nx842_pseries_constraints, .compress = nx842_pseries_compress, .decompress = nx842_pseries_decompress, }; diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c index 815d277..279a38e 100644 --- a/drivers/crypto/nx/nx-842.c +++ b/drivers/crypto/nx/nx-842.c @@ -86,6 +86,44 @@ static void put_driver(struct nx842_driver *driver) module_put(driver->owner); } +/** + * nx842_constraints + * + * This provides the driver's constraints. Different nx842 implementations + * may have varying requirements. The constraints are: + * @alignment: All buffers should be aligned to this + * @multiple: All buffer lengths should be a multiple of this + * @minimum: Buffer lengths must not be less than this amount + * @maximum: Buffer lengths must not be more than this amount + * + * The constraints apply to all buffers and lengths, both input and output, + * for both compression and decompression, except for the minimum which + * only applies to compression input and decompression output; the + * compressed data can be less than the minimum constraint. It can be + * assumed that compressed data will always adhere to the multiple + * constraint. + * + * The driver may succeed even if these constraints are violated; + * however the driver can return failure or suffer reduced performance + * if any constraint is not met. + */ +int nx842_constraints(struct nx842_constraints *c) +{ + struct nx842_driver *driver = get_driver(); + int ret = 0; + + if (!driver) + return -ENODEV; + + BUG_ON(!c); + memcpy(c, driver->constraints, sizeof(*c)); + + put_driver(driver); + + return ret; +} +EXPORT_SYMBOL_GPL(nx842_constraints); + int nx842_compress(const unsigned char *in, unsigned int in_len, unsigned char *out, unsigned int *out_len, void *wrkmem) diff --git a/drivers/crypto/nx/nx-842.h b/drivers/crypto/nx/nx-842.h index 2a5d4e1..c6ceb0f 100644 --- a/drivers/crypto/nx/nx-842.h +++ b/drivers/crypto/nx/nx-842.h @@ -12,6 +12,8 @@ struct nx842_driver { struct module *owner; + struct nx842_constraints *constraints; + int (*compress)(const unsigned char *in, unsigned int in_len, unsigned char *out, unsigned int *out_len, void *wrkmem); diff --git a/include/linux/nx842.h b/include/linux/nx842.h index 778e3ab..883b474 100644 --- a/include/linux/nx842.h +++ b/include/linux/nx842.h @@ -5,6 +5,15 @@ #define NX842_MEM_COMPRESS __NX842_PSERIES_MEM_COMPRESS +struct nx842_constraints { + int alignment; + int multiple; + int minimum; + int maximum; +}; + +int nx842_constraints(struct nx842_constraints *constraints); + int nx842_compress(const unsigned char *in, unsigned int in_len, unsigned char *out, unsigned int *out_len, void *wrkmem); int nx842_decompress(const unsigned char *in, unsigned int in_len,