From: Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com
Subject: [PATCH 1/8] crypto: qat - validate service in rate limiting sysfs api
Date: Thu, 10 Jul 2025 14:33:40 +0100 [thread overview]
Message-ID: <20250710133347.566310-2-suman.kumar.chakraborty@intel.com> (raw)
In-Reply-To: <20250710133347.566310-1-suman.kumar.chakraborty@intel.com>
The sysfs interface 'qat_rl/srv' currently allows all valid services,
even if a service is not configured for the device. This leads to a failure
when attempting to add the SLA using 'qat_rl/sla_op'.
Add a check using is_service_enabled() to ensure the requested service is
enabled. If not, return -EINVAL to prevent invalid configurations.
Signed-off-by: Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
---
drivers/crypto/intel/qat/qat_common/adf_rl.c | 3 +--
drivers/crypto/intel/qat/qat_common/adf_rl.h | 1 +
drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c | 8 ++++++++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl.c b/drivers/crypto/intel/qat/qat_common/adf_rl.c
index e782c23fc1bf..d320bfcb9919 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_rl.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_rl.c
@@ -209,8 +209,7 @@ u32 adf_rl_get_sla_arr_of_type(struct adf_rl *rl_data, enum rl_node_type type,
}
}
-static bool is_service_enabled(struct adf_accel_dev *accel_dev,
- enum adf_base_services rl_srv)
+bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv)
{
enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(rl_srv);
struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev);
diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl.h b/drivers/crypto/intel/qat/qat_common/adf_rl.h
index bfe750ea0e83..9b4678cee1fd 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_rl.h
+++ b/drivers/crypto/intel/qat/qat_common/adf_rl.h
@@ -175,5 +175,6 @@ u32 adf_rl_calculate_ae_cycles(struct adf_accel_dev *accel_dev, u32 sla_val,
enum adf_base_services svc_type);
u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val,
enum adf_base_services svc_type);
+bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv);
#endif /* ADF_RL_H_ */
diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c
index bedb514d4e30..a8c3be24b3b4 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c
@@ -291,14 +291,22 @@ static ssize_t srv_show(struct device *dev, struct device_attribute *attr,
static ssize_t srv_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct adf_accel_dev *accel_dev;
unsigned int val;
int ret;
+ accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
+ if (!accel_dev)
+ return -EINVAL;
+
ret = sysfs_match_string(rl_services, buf);
if (ret < 0)
return ret;
val = ret;
+ if (!is_service_enabled(accel_dev, val))
+ return -EINVAL;
+
ret = set_param_u(dev, SRV, val);
if (ret)
return ret;
--
2.40.1
next prev parent reply other threads:[~2025-07-10 13:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 13:33 [PATCH 0/8] crypto: qat - add rate limiting (RL) support for GEN6 devices Suman Kumar Chakraborty
2025-07-10 13:33 ` Suman Kumar Chakraborty [this message]
2025-07-10 13:33 ` [PATCH 2/8] crypto: qat - add decompression service for rate limiting Suman Kumar Chakraborty
2025-07-10 13:33 ` [PATCH 3/8] crypto: qat - consolidate service enums Suman Kumar Chakraborty
2025-07-10 13:33 ` [PATCH 4/8] crypto: qat - relocate service related functions Suman Kumar Chakraborty
2025-07-10 13:33 ` [PATCH 5/8] crypto: qat - add adf_rl_get_num_svc_aes() in rate limiting Suman Kumar Chakraborty
2025-07-10 13:33 ` [PATCH 6/8] crypto: qat - add get_svc_slice_cnt() in device data structure Suman Kumar Chakraborty
2025-07-10 13:33 ` [PATCH 7/8] crypto: qat - add compression slice count for rate limiting Suman Kumar Chakraborty
2025-07-10 13:33 ` [PATCH 8/8] crypto: qat - enable rate limiting feature for GEN6 devices Suman Kumar Chakraborty
2025-07-18 11:12 ` [PATCH 0/8] crypto: qat - add rate limiting (RL) support " Herbert Xu
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=20250710133347.566310-2-suman.kumar.chakraborty@intel.com \
--to=suman.kumar.chakraborty@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=qat-linux@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).