From: Radu Nicolau <radu.nicolau@intel.com>
To: Kai Ji <kai.ji@intel.com>
Cc: dev@dpdk.org, Radu Nicolau <radu.nicolau@intel.com>
Subject: [PATCH] crypto/qat: disable ZUC 256 on selected devices
Date: Wed, 23 Apr 2025 11:50:06 +0100 [thread overview]
Message-ID: <20250423105007.3285717-1-radu.nicolau@intel.com> (raw)
Disable ZUC 256 cipher on selected devices.
Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
drivers/common/qat/qat_common.h | 2 ++
drivers/common/qat/qat_device.c | 9 +++++++++
drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c | 5 ++++-
drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c | 9 +++++++++
drivers/crypto/qat/qat_sym_session.c | 6 ++++++
5 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/common/qat/qat_common.h b/drivers/common/qat/qat_common.h
index 51d20267bd..8476021e01 100644
--- a/drivers/common/qat/qat_common.h
+++ b/drivers/common/qat/qat_common.h
@@ -26,6 +26,8 @@ struct qat_options {
/**< Wireless Slices supported */
uint8_t legacy_alg;
/**< are legacy algorithm supported */
+ uint8_t zuc_256_disabled;
+ /**< is ZUC 256 algorithm disabled */
};
enum qat_device_gen {
diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c
index b582e3bf8b..35c664e529 100644
--- a/drivers/common/qat/qat_device.c
+++ b/drivers/common/qat/qat_device.c
@@ -169,6 +169,13 @@ wireless_slice_support(uint16_t pci_dev_id)
pci_dev_id == 0x4947;
}
+static int
+zuc_256_disabled(uint16_t pci_dev_id)
+{
+ return pci_dev_id == 0x578b ||
+ pci_dev_id == 0x4947;
+}
+
/* This function base on the atoi function peculiarity, non integral part
* other than the equals sign is ignored. It will not work with other conversion
* functions like strt*.
@@ -332,6 +339,8 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev)
if (wireless_slice_support(pci_dev->id.device_id))
qat_dev->options.has_wireless_slice = 1;
+ if (zuc_256_disabled(pci_dev->id.device_id))
+ qat_dev->options.zuc_256_disabled = 1;
ops_hw = qat_dev_hw_spec[qat_dev->qat_dev_gen];
NOT_NULL(ops_hw->qat_dev_get_misc_bar, goto error,
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
index af664fb9b9..11541ee51d 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
@@ -295,7 +295,10 @@ qat_sym_crypto_cap_get_gen3(struct qat_cryptodev_private *internals,
check_cipher_capa(&capabilities[iter],
RTE_CRYPTO_CIPHER_ZUC_EEA3))) {
cap = addr + curr_capa;
- cap->sym.cipher.key_size.max = 32;
+ if (internals->qat_dev->options.zuc_256_disabled)
+ cap->sym.cipher.key_size.max = 16;
+ else
+ cap->sym.cipher.key_size.max = 32;
cap->sym.cipher.key_size.increment = 16;
cap->sym.cipher.iv_size.max = 25;
cap->sym.cipher.iv_size.increment = 1;
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c
index e1302e9b36..70ede22042 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c
@@ -205,6 +205,15 @@ qat_sym_crypto_cap_get_gen5(struct qat_cryptodev_private *internals,
memcpy(addr + curr_capa, capabilities + iter,
sizeof(struct rte_cryptodev_capabilities));
+
+ if (check_cipher_capa(&capabilities[iter],
+ RTE_CRYPTO_CIPHER_ZUC_EEA3)) {
+ struct rte_cryptodev_capabilities *cap =
+ addr + curr_capa;
+ if (internals->qat_dev->options.zuc_256_disabled)
+ cap->sym.cipher.key_size.max = 16;
+ }
+
curr_capa++;
}
internals->qat_dev_capabilities = internals->capa_mz->addr;
diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c
index 7f370f03fb..2481ed7ce5 100644
--- a/drivers/crypto/qat/qat_sym_session.c
+++ b/drivers/crypto/qat/qat_sym_session.c
@@ -526,6 +526,12 @@ qat_sym_session_configure_cipher(struct rte_cryptodev *dev,
session->qat_mode = ICP_QAT_HW_CIPHER_CBC_MODE;
break;
case RTE_CRYPTO_CIPHER_ZUC_EEA3:
+ if (internals->qat_dev->options.zuc_256_disabled &&
+ cipher_xform->key.length == ICP_QAT_HW_ZUC_256_KEY_SZ) {
+ QAT_LOG(ERR, "ZUC 256 disabled on this device");
+ ret = -ENOTSUP;
+ goto error_out;
+ }
if (!qat_is_cipher_alg_supported(
cipher_xform->algo, internals)) {
QAT_LOG(ERR, "%s not supported on this device",
--
2.43.0
reply other threads:[~2025-04-23 10:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250423105007.3285717-1-radu.nicolau@intel.com \
--to=radu.nicolau@intel.com \
--cc=dev@dpdk.org \
--cc=kai.ji@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).