Re: [PATCH 3/4] crypto: ccp - CCP versioning support

2016-03-03 Thread Tom Lendacky
On 03/01/2016 01:49 PM, Gary R Hook wrote:
> Future hardware may introduce new algorithms wherein the
> driver will need to manage resources for different versions
> of the cryptographic coprocessor. This precursor patch
> determines the version of the available device, and marks
> and registers algorithms accordingly. A structure is added
> which manages the version-specific data.
> 
> Signed-off-by: Gary R Hook 

Acked-by: Tom Lendacky 

> ---
>  drivers/crypto/ccp/ccp-crypto-aes.c |   12 ++-
>  drivers/crypto/ccp/ccp-crypto-sha.c |9 +++-
>  drivers/crypto/ccp/ccp-dev.c|   27 
>  drivers/crypto/ccp/ccp-dev.h|8 +++
>  drivers/crypto/ccp/ccp-pci.c|8 ++-
>  drivers/crypto/ccp/ccp-platform.c   |   39 
> +--
>  include/linux/ccp.h |   17 +++
>  7 files changed, 115 insertions(+), 5 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] crypto: ccp - CCP versioning support

2016-03-01 Thread Gary R Hook
Future hardware may introduce new algorithms wherein the
driver will need to manage resources for different versions
of the cryptographic coprocessor. This precursor patch
determines the version of the available device, and marks
and registers algorithms accordingly. A structure is added
which manages the version-specific data.

Signed-off-by: Gary R Hook 
---
 drivers/crypto/ccp/ccp-crypto-aes.c |   12 ++-
 drivers/crypto/ccp/ccp-crypto-sha.c |9 +++-
 drivers/crypto/ccp/ccp-dev.c|   27 
 drivers/crypto/ccp/ccp-dev.h|8 +++
 drivers/crypto/ccp/ccp-pci.c|8 ++-
 drivers/crypto/ccp/ccp-platform.c   |   39 +--
 include/linux/ccp.h |   17 +++
 7 files changed, 115 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-crypto-aes.c 
b/drivers/crypto/ccp/ccp-crypto-aes.c
index 7984f91..89291c1 100644
--- a/drivers/crypto/ccp/ccp-crypto-aes.c
+++ b/drivers/crypto/ccp/ccp-crypto-aes.c
@@ -1,7 +1,7 @@
 /*
  * AMD Cryptographic Coprocessor (CCP) AES crypto API support
  *
- * Copyright (C) 2013 Advanced Micro Devices, Inc.
+ * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
  *
  * Author: Tom Lendacky 
  *
@@ -259,6 +259,7 @@ static struct crypto_alg ccp_aes_rfc3686_defaults = {
 
 struct ccp_aes_def {
enum ccp_aes_mode mode;
+   unsigned int version;
const char *name;
const char *driver_name;
unsigned int blocksize;
@@ -269,6 +270,7 @@ struct ccp_aes_def {
 static struct ccp_aes_def aes_algs[] = {
{
.mode   = CCP_AES_MODE_ECB,
+   .version= CCP_VERSION(3, 0),
.name   = "ecb(aes)",
.driver_name= "ecb-aes-ccp",
.blocksize  = AES_BLOCK_SIZE,
@@ -277,6 +279,7 @@ static struct ccp_aes_def aes_algs[] = {
},
{
.mode   = CCP_AES_MODE_CBC,
+   .version= CCP_VERSION(3, 0),
.name   = "cbc(aes)",
.driver_name= "cbc-aes-ccp",
.blocksize  = AES_BLOCK_SIZE,
@@ -285,6 +288,7 @@ static struct ccp_aes_def aes_algs[] = {
},
{
.mode   = CCP_AES_MODE_CFB,
+   .version= CCP_VERSION(3, 0),
.name   = "cfb(aes)",
.driver_name= "cfb-aes-ccp",
.blocksize  = AES_BLOCK_SIZE,
@@ -293,6 +297,7 @@ static struct ccp_aes_def aes_algs[] = {
},
{
.mode   = CCP_AES_MODE_OFB,
+   .version= CCP_VERSION(3, 0),
.name   = "ofb(aes)",
.driver_name= "ofb-aes-ccp",
.blocksize  = 1,
@@ -301,6 +306,7 @@ static struct ccp_aes_def aes_algs[] = {
},
{
.mode   = CCP_AES_MODE_CTR,
+   .version= CCP_VERSION(3, 0),
.name   = "ctr(aes)",
.driver_name= "ctr-aes-ccp",
.blocksize  = 1,
@@ -309,6 +315,7 @@ static struct ccp_aes_def aes_algs[] = {
},
{
.mode   = CCP_AES_MODE_CTR,
+   .version= CCP_VERSION(3, 0),
.name   = "rfc3686(ctr(aes))",
.driver_name= "rfc3686-ctr-aes-ccp",
.blocksize  = 1,
@@ -357,8 +364,11 @@ static int ccp_register_aes_alg(struct list_head *head,
 int ccp_register_aes_algs(struct list_head *head)
 {
int i, ret;
+   unsigned int ccpversion = ccp_version();
 
for (i = 0; i < ARRAY_SIZE(aes_algs); i++) {
+   if (aes_algs[i].version > ccpversion)
+   continue;
ret = ccp_register_aes_alg(head, &aes_algs[i]);
if (ret)
return ret;
diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c 
b/drivers/crypto/ccp/ccp-crypto-sha.c
index 8ef06fa..b5ad728 100644
--- a/drivers/crypto/ccp/ccp-crypto-sha.c
+++ b/drivers/crypto/ccp/ccp-crypto-sha.c
@@ -1,7 +1,7 @@
 /*
  * AMD Cryptographic Coprocessor (CCP) SHA crypto API support
  *
- * Copyright (C) 2013 Advanced Micro Devices, Inc.
+ * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
  *
  * Author: Tom Lendacky 
  *
@@ -341,6 +341,7 @@ static void ccp_hmac_sha_cra_exit(struct crypto_tfm *tfm)
 }
 
 struct ccp_sha_def {
+   unsigned int version;
const char *name;
const char *drv_name;
enum ccp_sha_type type;
@@ -350,6 +351,7 @@ struct ccp_sha_def {
 
 static struct ccp_sha_def sha_algs[] = {
{
+   .version= CCP_VERSION(3, 0),
.name   = "sha1",
.drv_name   = "sha1-ccp",
.type   = CCP_SHA_TYPE_1,
@@ -357,6 +359,7 @@ static struct ccp_sha_def sha_algs[] = {
.block_size