Commit 657ad678 authored by Giovanni Cabiddu's avatar Giovanni Cabiddu Committed by Herbert Xu

crypto: qat - allow for instances in different banks

Allow for crypto instances to be configured with symmetric crypto rings
that belong to a bank that is different from the one where asymmetric
crypto rings are located.

This is to allow for devices with banks made of a single ring pair.
In these, crypto instances will be composed of two separate banks.

Changed string literals are not exposed to the user space.
Signed-off-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: default avatarWojciech Ziemba <wojciech.ziemba@intel.com>
Reviewed-by: default avatarFiona Trahe <fiona.trahe@intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 54e3d753
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
#define ADF_RING_DC_TX "RingTx" #define ADF_RING_DC_TX "RingTx"
#define ADF_RING_DC_RX "RingRx" #define ADF_RING_DC_RX "RingRx"
#define ADF_ETRMGR_BANK "Bank" #define ADF_ETRMGR_BANK "Bank"
#define ADF_RING_BANK_NUM "BankNumber" #define ADF_RING_SYM_BANK_NUM "BankSymNumber"
#define ADF_RING_ASYM_BANK_NUM "BankAsymNumber"
#define ADF_CY "Cy" #define ADF_CY "Cy"
#define ADF_DC "Dc" #define ADF_DC "Dc"
#define ADF_ETRMGR_COALESCING_ENABLED "InterruptCoalescingEnabled" #define ADF_ETRMGR_COALESCING_ENABLED "InterruptCoalescingEnabled"
......
...@@ -138,7 +138,13 @@ int qat_crypto_dev_config(struct adf_accel_dev *accel_dev) ...@@ -138,7 +138,13 @@ int qat_crypto_dev_config(struct adf_accel_dev *accel_dev)
for (i = 0; i < instances; i++) { for (i = 0; i < instances; i++) {
val = i; val = i;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_BANK_NUM, i); snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_BANK_NUM, i);
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
key, &val, ADF_DEC);
if (ret)
goto err;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_BANK_NUM, i);
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC, ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
key, &val, ADF_DEC); key, &val, ADF_DEC);
if (ret) if (ret)
...@@ -217,9 +223,10 @@ EXPORT_SYMBOL_GPL(qat_crypto_dev_config); ...@@ -217,9 +223,10 @@ EXPORT_SYMBOL_GPL(qat_crypto_dev_config);
static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev) static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev)
{ {
unsigned long bank, num_inst, num_msg_sym, num_msg_asym; unsigned long num_inst, num_msg_sym, num_msg_asym;
char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES]; char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES]; char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES];
unsigned long sym_bank, asym_bank;
struct qat_crypto_instance *inst; struct qat_crypto_instance *inst;
int msg_size; int msg_size;
int ret; int ret;
...@@ -246,14 +253,25 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev) ...@@ -246,14 +253,25 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev)
inst->id = i; inst->id = i;
atomic_set(&inst->refctr, 0); atomic_set(&inst->refctr, 0);
inst->accel_dev = accel_dev; inst->accel_dev = accel_dev;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_BANK_NUM, i);
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_BANK_NUM, i);
ret = adf_cfg_get_param_value(accel_dev, SEC, key, val);
if (ret)
goto err;
ret = kstrtoul(val, 10, &sym_bank);
if (ret)
goto err;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_BANK_NUM, i);
ret = adf_cfg_get_param_value(accel_dev, SEC, key, val); ret = adf_cfg_get_param_value(accel_dev, SEC, key, val);
if (ret) if (ret)
goto err; goto err;
ret = kstrtoul(val, 10, &bank); ret = kstrtoul(val, 10, &asym_bank);
if (ret) if (ret)
goto err; goto err;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_SIZE, i); snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_SIZE, i);
ret = adf_cfg_get_param_value(accel_dev, SEC, key, val); ret = adf_cfg_get_param_value(accel_dev, SEC, key, val);
if (ret) if (ret)
...@@ -277,28 +295,28 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev) ...@@ -277,28 +295,28 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev)
msg_size = ICP_QAT_FW_REQ_DEFAULT_SZ; msg_size = ICP_QAT_FW_REQ_DEFAULT_SZ;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_TX, i); snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_TX, i);
ret = adf_create_ring(accel_dev, SEC, bank, num_msg_sym, ret = adf_create_ring(accel_dev, SEC, sym_bank, num_msg_sym,
msg_size, key, NULL, 0, &inst->sym_tx); msg_size, key, NULL, 0, &inst->sym_tx);
if (ret) if (ret)
goto err; goto err;
msg_size = msg_size >> 1; msg_size = msg_size >> 1;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_TX, i); snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_TX, i);
ret = adf_create_ring(accel_dev, SEC, bank, num_msg_asym, ret = adf_create_ring(accel_dev, SEC, asym_bank, num_msg_asym,
msg_size, key, NULL, 0, &inst->pke_tx); msg_size, key, NULL, 0, &inst->pke_tx);
if (ret) if (ret)
goto err; goto err;
msg_size = ICP_QAT_FW_RESP_DEFAULT_SZ; msg_size = ICP_QAT_FW_RESP_DEFAULT_SZ;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_RX, i); snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_RX, i);
ret = adf_create_ring(accel_dev, SEC, bank, num_msg_sym, ret = adf_create_ring(accel_dev, SEC, sym_bank, num_msg_sym,
msg_size, key, qat_alg_callback, 0, msg_size, key, qat_alg_callback, 0,
&inst->sym_rx); &inst->sym_rx);
if (ret) if (ret)
goto err; goto err;
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_RX, i); snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_RX, i);
ret = adf_create_ring(accel_dev, SEC, bank, num_msg_asym, ret = adf_create_ring(accel_dev, SEC, asym_bank, num_msg_asym,
msg_size, key, qat_alg_asym_callback, 0, msg_size, key, qat_alg_asym_callback, 0,
&inst->pke_rx); &inst->pke_rx);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment