xref: /linux/drivers/crypto/intel/qat/qat_common/adf_cfg_services.c (revision 06d07429858317ded2db7986113a9e0129cd599b)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright(c) 2023 Intel Corporation */
3 
4 #include <linux/export.h>
5 #include <linux/pci.h>
6 #include <linux/string.h>
7 #include "adf_cfg.h"
8 #include "adf_cfg_services.h"
9 #include "adf_cfg_strings.h"
10 
11 const char *const adf_cfg_services[] = {
12 	[SVC_CY] = ADF_CFG_CY,
13 	[SVC_CY2] = ADF_CFG_ASYM_SYM,
14 	[SVC_DC] = ADF_CFG_DC,
15 	[SVC_DCC] = ADF_CFG_DCC,
16 	[SVC_SYM] = ADF_CFG_SYM,
17 	[SVC_ASYM] = ADF_CFG_ASYM,
18 	[SVC_DC_ASYM] = ADF_CFG_DC_ASYM,
19 	[SVC_ASYM_DC] = ADF_CFG_ASYM_DC,
20 	[SVC_DC_SYM] = ADF_CFG_DC_SYM,
21 	[SVC_SYM_DC] = ADF_CFG_SYM_DC,
22 };
23 EXPORT_SYMBOL_GPL(adf_cfg_services);
24 
adf_get_service_enabled(struct adf_accel_dev * accel_dev)25 int adf_get_service_enabled(struct adf_accel_dev *accel_dev)
26 {
27 	char services[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = {0};
28 	int ret;
29 
30 	ret = adf_cfg_get_param_value(accel_dev, ADF_GENERAL_SEC,
31 				      ADF_SERVICES_ENABLED, services);
32 	if (ret) {
33 		dev_err(&GET_DEV(accel_dev),
34 			ADF_SERVICES_ENABLED " param not found\n");
35 		return ret;
36 	}
37 
38 	ret = match_string(adf_cfg_services, ARRAY_SIZE(adf_cfg_services),
39 			   services);
40 	if (ret < 0)
41 		dev_err(&GET_DEV(accel_dev),
42 			"Invalid value of " ADF_SERVICES_ENABLED " param: %s\n",
43 			services);
44 
45 	return ret;
46 }
47 EXPORT_SYMBOL_GPL(adf_get_service_enabled);
48