mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
crypto: qat - consolidate services structure
The data structure that associates a service id with its name is replicated across the driver. Remove duplication by moving this data structure to a new include file, adf_cfg_services.h in order to have consistency across the drivers. Note that the data structure is re-instantiated every time the new include is added to a compilation unit. Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
11af152f78
commit
7171376638
@ -11,6 +11,7 @@
|
||||
#include <adf_gen4_pm.h>
|
||||
#include <adf_gen4_timer.h>
|
||||
#include "adf_4xxx_hw_data.h"
|
||||
#include "adf_cfg_services.h"
|
||||
#include "icp_qat_hw.h"
|
||||
|
||||
enum adf_fw_objs {
|
||||
@ -100,30 +101,6 @@ static struct adf_hw_device_class adf_4xxx_class = {
|
||||
.instances = 0,
|
||||
};
|
||||
|
||||
enum dev_services {
|
||||
SVC_CY = 0,
|
||||
SVC_CY2,
|
||||
SVC_DC,
|
||||
SVC_SYM,
|
||||
SVC_ASYM,
|
||||
SVC_DC_ASYM,
|
||||
SVC_ASYM_DC,
|
||||
SVC_DC_SYM,
|
||||
SVC_SYM_DC,
|
||||
};
|
||||
|
||||
static const char *const dev_cfg_services[] = {
|
||||
[SVC_CY] = ADF_CFG_CY,
|
||||
[SVC_CY2] = ADF_CFG_ASYM_SYM,
|
||||
[SVC_DC] = ADF_CFG_DC,
|
||||
[SVC_SYM] = ADF_CFG_SYM,
|
||||
[SVC_ASYM] = ADF_CFG_ASYM,
|
||||
[SVC_DC_ASYM] = ADF_CFG_DC_ASYM,
|
||||
[SVC_ASYM_DC] = ADF_CFG_ASYM_DC,
|
||||
[SVC_DC_SYM] = ADF_CFG_DC_SYM,
|
||||
[SVC_SYM_DC] = ADF_CFG_SYM_DC,
|
||||
};
|
||||
|
||||
static int get_service_enabled(struct adf_accel_dev *accel_dev)
|
||||
{
|
||||
char services[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = {0};
|
||||
@ -137,7 +114,7 @@ static int get_service_enabled(struct adf_accel_dev *accel_dev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = match_string(dev_cfg_services, ARRAY_SIZE(dev_cfg_services),
|
||||
ret = match_string(adf_cfg_services, ARRAY_SIZE(adf_cfg_services),
|
||||
services);
|
||||
if (ret < 0)
|
||||
dev_err(&GET_DEV(accel_dev),
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <adf_heartbeat.h>
|
||||
|
||||
#include "adf_4xxx_hw_data.h"
|
||||
#include "adf_cfg_services.h"
|
||||
#include "qat_compression.h"
|
||||
#include "qat_crypto.h"
|
||||
#include "adf_transport_access_macros.h"
|
||||
@ -23,30 +24,6 @@ static const struct pci_device_id adf_pci_tbl[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(pci, adf_pci_tbl);
|
||||
|
||||
enum configs {
|
||||
DEV_CFG_CY = 0,
|
||||
DEV_CFG_DC,
|
||||
DEV_CFG_SYM,
|
||||
DEV_CFG_ASYM,
|
||||
DEV_CFG_ASYM_SYM,
|
||||
DEV_CFG_ASYM_DC,
|
||||
DEV_CFG_DC_ASYM,
|
||||
DEV_CFG_SYM_DC,
|
||||
DEV_CFG_DC_SYM,
|
||||
};
|
||||
|
||||
static const char * const services_operations[] = {
|
||||
ADF_CFG_CY,
|
||||
ADF_CFG_DC,
|
||||
ADF_CFG_SYM,
|
||||
ADF_CFG_ASYM,
|
||||
ADF_CFG_ASYM_SYM,
|
||||
ADF_CFG_ASYM_DC,
|
||||
ADF_CFG_DC_ASYM,
|
||||
ADF_CFG_SYM_DC,
|
||||
ADF_CFG_DC_SYM,
|
||||
};
|
||||
|
||||
static void adf_cleanup_accel(struct adf_accel_dev *accel_dev)
|
||||
{
|
||||
if (accel_dev->hw_device) {
|
||||
@ -292,16 +269,16 @@ int adf_gen4_dev_config(struct adf_accel_dev *accel_dev)
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = sysfs_match_string(services_operations, services);
|
||||
ret = sysfs_match_string(adf_cfg_services, services);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
switch (ret) {
|
||||
case DEV_CFG_CY:
|
||||
case DEV_CFG_ASYM_SYM:
|
||||
case SVC_CY:
|
||||
case SVC_CY2:
|
||||
ret = adf_crypto_dev_config(accel_dev);
|
||||
break;
|
||||
case DEV_CFG_DC:
|
||||
case SVC_DC:
|
||||
ret = adf_comp_dev_config(accel_dev);
|
||||
break;
|
||||
default:
|
||||
|
32
drivers/crypto/intel/qat/qat_common/adf_cfg_services.h
Normal file
32
drivers/crypto/intel/qat/qat_common/adf_cfg_services.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/* Copyright(c) 2023 Intel Corporation */
|
||||
#ifndef _ADF_CFG_SERVICES_H_
|
||||
#define _ADF_CFG_SERVICES_H_
|
||||
|
||||
#include "adf_cfg_strings.h"
|
||||
|
||||
enum adf_services {
|
||||
SVC_CY = 0,
|
||||
SVC_CY2,
|
||||
SVC_DC,
|
||||
SVC_SYM,
|
||||
SVC_ASYM,
|
||||
SVC_DC_ASYM,
|
||||
SVC_ASYM_DC,
|
||||
SVC_DC_SYM,
|
||||
SVC_SYM_DC,
|
||||
};
|
||||
|
||||
static const char *const adf_cfg_services[] = {
|
||||
[SVC_CY] = ADF_CFG_CY,
|
||||
[SVC_CY2] = ADF_CFG_ASYM_SYM,
|
||||
[SVC_DC] = ADF_CFG_DC,
|
||||
[SVC_SYM] = ADF_CFG_SYM,
|
||||
[SVC_ASYM] = ADF_CFG_ASYM,
|
||||
[SVC_DC_ASYM] = ADF_CFG_DC_ASYM,
|
||||
[SVC_ASYM_DC] = ADF_CFG_ASYM_DC,
|
||||
[SVC_DC_SYM] = ADF_CFG_DC_SYM,
|
||||
[SVC_SYM_DC] = ADF_CFG_SYM_DC,
|
||||
};
|
||||
|
||||
#endif
|
@ -5,6 +5,7 @@
|
||||
#include <linux/pci.h>
|
||||
#include "adf_accel_devices.h"
|
||||
#include "adf_cfg.h"
|
||||
#include "adf_cfg_services.h"
|
||||
#include "adf_common_drv.h"
|
||||
|
||||
static const char * const state_operations[] = {
|
||||
@ -84,18 +85,6 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr,
|
||||
return count;
|
||||
}
|
||||
|
||||
static const char * const services_operations[] = {
|
||||
ADF_CFG_CY,
|
||||
ADF_CFG_DC,
|
||||
ADF_CFG_SYM,
|
||||
ADF_CFG_ASYM,
|
||||
ADF_CFG_ASYM_SYM,
|
||||
ADF_CFG_ASYM_DC,
|
||||
ADF_CFG_DC_ASYM,
|
||||
ADF_CFG_SYM_DC,
|
||||
ADF_CFG_DC_SYM,
|
||||
};
|
||||
|
||||
static ssize_t cfg_services_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
@ -130,7 +119,7 @@ static ssize_t cfg_services_store(struct device *dev, struct device_attribute *a
|
||||
struct adf_accel_dev *accel_dev;
|
||||
int ret;
|
||||
|
||||
ret = sysfs_match_string(services_operations, buf);
|
||||
ret = sysfs_match_string(adf_cfg_services, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@ -144,7 +133,7 @@ static ssize_t cfg_services_store(struct device *dev, struct device_attribute *a
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = adf_sysfs_update_dev_config(accel_dev, services_operations[ret]);
|
||||
ret = adf_sysfs_update_dev_config(accel_dev, adf_cfg_services[ret]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user