Skip to content

Commit 2266421

Browse files
committed
crypto: qat - rename and relocate GEN2 config function
jira LE-1907 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author Giovanni Cabiddu <[email protected]> commit 93b2f57 Rename qat_crypto_dev_config() in adf_gen2_dev_config() and relocate it to the newly created file adf_gen2_config.c. This function is specific to QAT GEN2 devices and will be used also to configure the compression service. In addition change the drivers to use the dev_config() in the hardware data structure (which for GEN2 devices now points to adf_gen2_dev_config()), for consistency. Signed-off-by: Giovanni Cabiddu <[email protected]> Reviewed-by: Wojciech Ziemba <[email protected]> Reviewed-by: Adam Guerin <[email protected]> Signed-off-by: Herbert Xu <[email protected]> (cherry picked from commit 93b2f57) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 2baa595 commit 2266421

File tree

14 files changed

+158
-123
lines changed

14 files changed

+158
-123
lines changed

drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright(c) 2014 - 2021 Intel Corporation */
33
#include <adf_accel_devices.h>
44
#include <adf_common_drv.h>
5+
#include <adf_gen2_config.h>
56
#include <adf_gen2_hw_data.h>
67
#include <adf_gen2_pfvf.h>
78
#include "adf_c3xxx_hw_data.h"
@@ -124,6 +125,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data)
124125
hw_data->reset_device = adf_reset_flr;
125126
hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer;
126127
hw_data->disable_iov = adf_disable_sriov;
128+
hw_data->dev_config = adf_gen2_dev_config;
127129

128130
adf_gen2_init_pf_pfvf_ops(&hw_data->pfvf_ops);
129131
adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);

drivers/crypto/qat/qat_c3xxx/adf_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
201201
goto out_err_disable_aer;
202202
}
203203

204-
ret = qat_crypto_dev_config(accel_dev);
204+
ret = hw_data->dev_config(accel_dev);
205205
if (ret)
206206
goto out_err_disable_aer;
207207

drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright(c) 2015 - 2021 Intel Corporation */
33
#include <adf_accel_devices.h>
44
#include <adf_common_drv.h>
5+
#include <adf_gen2_config.h>
56
#include <adf_gen2_hw_data.h>
67
#include <adf_gen2_pfvf.h>
78
#include <adf_pfvf_vf_msg.h>
@@ -86,6 +87,7 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)
8687
hw_data->get_sku = get_sku;
8788
hw_data->enable_ints = adf_vf_void_noop;
8889
hw_data->dev_class->instances++;
90+
hw_data->dev_config = adf_gen2_dev_config;
8991
adf_devmgr_update_class_index(hw_data);
9092
adf_gen2_init_vf_pfvf_ops(&hw_data->pfvf_ops);
9193
adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);

drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright(c) 2014 - 2021 Intel Corporation */
33
#include <adf_accel_devices.h>
44
#include <adf_common_drv.h>
5+
#include <adf_gen2_config.h>
56
#include <adf_gen2_hw_data.h>
67
#include <adf_gen2_pfvf.h>
78
#include "adf_c62x_hw_data.h"
@@ -126,6 +127,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data)
126127
hw_data->reset_device = adf_reset_flr;
127128
hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer;
128129
hw_data->disable_iov = adf_disable_sriov;
130+
hw_data->dev_config = adf_gen2_dev_config;
129131

130132
adf_gen2_init_pf_pfvf_ops(&hw_data->pfvf_ops);
131133
adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);

drivers/crypto/qat/qat_c62x/adf_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
201201
goto out_err_disable_aer;
202202
}
203203

204-
ret = qat_crypto_dev_config(accel_dev);
204+
ret = hw_data->dev_config(accel_dev);
205205
if (ret)
206206
goto out_err_disable_aer;
207207

drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright(c) 2015 - 2021 Intel Corporation */
33
#include <adf_accel_devices.h>
44
#include <adf_common_drv.h>
5+
#include <adf_gen2_config.h>
56
#include <adf_gen2_hw_data.h>
67
#include <adf_gen2_pfvf.h>
78
#include <adf_pfvf_vf_msg.h>
@@ -86,6 +87,7 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data)
8687
hw_data->get_sku = get_sku;
8788
hw_data->enable_ints = adf_vf_void_noop;
8889
hw_data->dev_class->instances++;
90+
hw_data->dev_config = adf_gen2_dev_config;
8991
adf_devmgr_update_class_index(hw_data);
9092
adf_gen2_init_vf_pfvf_ops(&hw_data->pfvf_ops);
9193
adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);

drivers/crypto/qat/qat_common/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ intel_qat-objs := adf_cfg.o \
1212
adf_hw_arbiter.o \
1313
adf_sysfs.o \
1414
adf_gen2_hw_data.o \
15+
adf_gen2_config.o \
1516
adf_gen4_hw_data.o \
1617
adf_gen4_pm.o \
1718
qat_crypto.o \

drivers/crypto/qat/qat_common/adf_common_drv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ int adf_init_etr_data(struct adf_accel_dev *accel_dev);
110110
void adf_cleanup_etr_data(struct adf_accel_dev *accel_dev);
111111
int qat_crypto_register(void);
112112
int qat_crypto_unregister(void);
113-
int qat_crypto_dev_config(struct adf_accel_dev *accel_dev);
114113
int qat_crypto_vf_dev_config(struct adf_accel_dev *accel_dev);
115114
struct qat_crypto_instance *qat_crypto_get_instance_node(int node);
116115
void qat_crypto_put_instance(struct qat_crypto_instance *inst);
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/* Copyright(c) 2022 Intel Corporation */
3+
#include "adf_accel_devices.h"
4+
#include "adf_cfg.h"
5+
#include "adf_cfg_strings.h"
6+
#include "adf_gen2_config.h"
7+
#include "adf_common_drv.h"
8+
#include "qat_crypto.h"
9+
#include "adf_transport_access_macros.h"
10+
11+
static int adf_gen2_crypto_dev_config(struct adf_accel_dev *accel_dev)
12+
{
13+
char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
14+
int banks = GET_MAX_BANKS(accel_dev);
15+
int cpus = num_online_cpus();
16+
unsigned long val;
17+
int instances;
18+
int ret;
19+
int i;
20+
21+
if (adf_hw_dev_has_crypto(accel_dev))
22+
instances = min(cpus, banks);
23+
else
24+
instances = 0;
25+
26+
ret = adf_cfg_section_add(accel_dev, ADF_KERNEL_SEC);
27+
if (ret)
28+
goto err;
29+
30+
ret = adf_cfg_section_add(accel_dev, "Accelerator0");
31+
if (ret)
32+
goto err;
33+
34+
for (i = 0; i < instances; i++) {
35+
val = i;
36+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_BANK_NUM, i);
37+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
38+
key, &val, ADF_DEC);
39+
if (ret)
40+
goto err;
41+
42+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_BANK_NUM, i);
43+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
44+
key, &val, ADF_DEC);
45+
if (ret)
46+
goto err;
47+
48+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_ETRMGR_CORE_AFFINITY,
49+
i);
50+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
51+
key, &val, ADF_DEC);
52+
if (ret)
53+
goto err;
54+
55+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_SIZE, i);
56+
val = 128;
57+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
58+
key, &val, ADF_DEC);
59+
if (ret)
60+
goto err;
61+
62+
val = 512;
63+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_SIZE, i);
64+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
65+
key, &val, ADF_DEC);
66+
if (ret)
67+
goto err;
68+
69+
val = 0;
70+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_TX, i);
71+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
72+
key, &val, ADF_DEC);
73+
if (ret)
74+
goto err;
75+
76+
val = 2;
77+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_TX, i);
78+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
79+
key, &val, ADF_DEC);
80+
if (ret)
81+
goto err;
82+
83+
val = 8;
84+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_RX, i);
85+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
86+
key, &val, ADF_DEC);
87+
if (ret)
88+
goto err;
89+
90+
val = 10;
91+
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_RX, i);
92+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
93+
key, &val, ADF_DEC);
94+
if (ret)
95+
goto err;
96+
97+
val = ADF_COALESCING_DEF_TIME;
98+
snprintf(key, sizeof(key), ADF_ETRMGR_COALESCE_TIMER_FORMAT, i);
99+
ret = adf_cfg_add_key_value_param(accel_dev, "Accelerator0",
100+
key, &val, ADF_DEC);
101+
if (ret)
102+
goto err;
103+
}
104+
105+
val = i;
106+
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC, ADF_NUM_CY,
107+
&val, ADF_DEC);
108+
if (ret)
109+
goto err;
110+
111+
set_bit(ADF_STATUS_CONFIGURED, &accel_dev->status);
112+
return 0;
113+
err:
114+
dev_err(&GET_DEV(accel_dev), "Failed to start QAT accel dev\n");
115+
return ret;
116+
}
117+
118+
/**
119+
* adf_gen2_dev_config() - create dev config required to create instances
120+
*
121+
* @accel_dev: Pointer to acceleration device.
122+
*
123+
* Function creates device configuration required to create instances
124+
*
125+
* Return: 0 on success, error code otherwise.
126+
*/
127+
int adf_gen2_dev_config(struct adf_accel_dev *accel_dev)
128+
{
129+
return adf_gen2_crypto_dev_config(accel_dev);
130+
}
131+
EXPORT_SYMBOL_GPL(adf_gen2_dev_config);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/* Copyright(c) 2022 Intel Corporation */
3+
#ifndef ADF_GEN2_CONFIG_H_
4+
#define ADF_GEN2_CONFIG_H_
5+
6+
#include "adf_accel_devices.h"
7+
8+
int adf_gen2_dev_config(struct adf_accel_dev *accel_dev);
9+
10+
#endif

0 commit comments

Comments
 (0)