crypto: hisilicon - add vfs_num module parameter for hpre/sec
The vfs_num module parameter has been used in zip driver, this patch adds this for HPRE and SEC driver. Signed-off-by: Hao Fang <fanghao11@huawei.com> Signed-off-by: Shukun Tan <tanshukun1@huawei.com> Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com> Reviewed-by: Zaibo Xu <xuzaibo@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
@@ -195,6 +195,15 @@ static u32 hpre_pf_q_num = HPRE_PF_DEF_Q_NUM;
|
|||||||
module_param_cb(hpre_pf_q_num, &hpre_pf_q_num_ops, &hpre_pf_q_num, 0444);
|
module_param_cb(hpre_pf_q_num, &hpre_pf_q_num_ops, &hpre_pf_q_num, 0444);
|
||||||
MODULE_PARM_DESC(hpre_pf_q_num, "Number of queues in PF of CS(1-1024)");
|
MODULE_PARM_DESC(hpre_pf_q_num, "Number of queues in PF of CS(1-1024)");
|
||||||
|
|
||||||
|
static const struct kernel_param_ops vfs_num_ops = {
|
||||||
|
.set = vfs_num_set,
|
||||||
|
.get = param_get_int,
|
||||||
|
};
|
||||||
|
|
||||||
|
static u32 vfs_num;
|
||||||
|
module_param_cb(vfs_num, &vfs_num_ops, &vfs_num, 0444);
|
||||||
|
MODULE_PARM_DESC(vfs_num, "Number of VFs to enable(1-63), 0(default)");
|
||||||
|
|
||||||
struct hisi_qp *hpre_create_qp(void)
|
struct hisi_qp *hpre_create_qp(void)
|
||||||
{
|
{
|
||||||
int node = cpu_to_node(smp_processor_id());
|
int node = cpu_to_node(smp_processor_id());
|
||||||
@@ -777,8 +786,18 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||||||
pci_err(pdev, "fail to register algs to crypto!\n");
|
pci_err(pdev, "fail to register algs to crypto!\n");
|
||||||
goto err_with_qm_start;
|
goto err_with_qm_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qm->fun_type == QM_HW_PF && vfs_num) {
|
||||||
|
ret = hisi_qm_sriov_enable(pdev, vfs_num);
|
||||||
|
if (ret < 0)
|
||||||
|
goto err_with_crypto_register;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_with_crypto_register:
|
||||||
|
hpre_algs_unregister();
|
||||||
|
|
||||||
err_with_qm_start:
|
err_with_qm_start:
|
||||||
hisi_qm_del_from_list(qm, &hpre_devices);
|
hisi_qm_del_from_list(qm, &hpre_devices);
|
||||||
hisi_qm_stop(qm);
|
hisi_qm_stop(qm);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
|
|
||||||
|
#define QM_MAX_VFS_NUM_V2 63
|
||||||
|
|
||||||
/* qm user domain */
|
/* qm user domain */
|
||||||
#define QM_ARUSER_M_CFG_1 0x100088
|
#define QM_ARUSER_M_CFG_1 0x100088
|
||||||
#define AXUSER_SNOOP_ENABLE BIT(30)
|
#define AXUSER_SNOOP_ENABLE BIT(30)
|
||||||
@@ -235,6 +237,24 @@ struct hisi_qp {
|
|||||||
struct uacce_queue *uacce_q;
|
struct uacce_queue *uacce_q;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline int vfs_num_set(const char *val, const struct kernel_param *kp)
|
||||||
|
{
|
||||||
|
u32 n;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!val)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
ret = kstrtou32(val, 10, &n);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (n > QM_MAX_VFS_NUM_V2)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return param_set_int(val, kp);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void hisi_qm_init_list(struct hisi_qm_list *qm_list)
|
static inline void hisi_qm_init_list(struct hisi_qm_list *qm_list)
|
||||||
{
|
{
|
||||||
INIT_LIST_HEAD(&qm_list->list);
|
INIT_LIST_HEAD(&qm_list->list);
|
||||||
|
|||||||
@@ -207,6 +207,15 @@ static u32 ctx_q_num = SEC_CTX_Q_NUM_DEF;
|
|||||||
module_param_cb(ctx_q_num, &sec_ctx_q_num_ops, &ctx_q_num, 0444);
|
module_param_cb(ctx_q_num, &sec_ctx_q_num_ops, &ctx_q_num, 0444);
|
||||||
MODULE_PARM_DESC(ctx_q_num, "Queue num in ctx (24 default, 2, 4, ..., 32)");
|
MODULE_PARM_DESC(ctx_q_num, "Queue num in ctx (24 default, 2, 4, ..., 32)");
|
||||||
|
|
||||||
|
static const struct kernel_param_ops vfs_num_ops = {
|
||||||
|
.set = vfs_num_set,
|
||||||
|
.get = param_get_int,
|
||||||
|
};
|
||||||
|
|
||||||
|
static u32 vfs_num;
|
||||||
|
module_param_cb(vfs_num, &vfs_num_ops, &vfs_num, 0444);
|
||||||
|
MODULE_PARM_DESC(vfs_num, "Number of VFs to enable(1-63), 0(default)");
|
||||||
|
|
||||||
void sec_destroy_qps(struct hisi_qp **qps, int qp_num)
|
void sec_destroy_qps(struct hisi_qp **qps, int qp_num)
|
||||||
{
|
{
|
||||||
hisi_qm_free_qps(qps, qp_num);
|
hisi_qm_free_qps(qps, qp_num);
|
||||||
@@ -876,8 +885,17 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||||||
goto err_remove_from_list;
|
goto err_remove_from_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qm->fun_type == QM_HW_PF && vfs_num) {
|
||||||
|
ret = hisi_qm_sriov_enable(pdev, vfs_num);
|
||||||
|
if (ret < 0)
|
||||||
|
goto err_crypto_unregister;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_crypto_unregister:
|
||||||
|
sec_unregister_from_crypto();
|
||||||
|
|
||||||
err_remove_from_list:
|
err_remove_from_list:
|
||||||
hisi_qm_del_from_list(qm, &sec_devices);
|
hisi_qm_del_from_list(qm, &sec_devices);
|
||||||
sec_debugfs_exit(sec);
|
sec_debugfs_exit(sec);
|
||||||
|
|||||||
@@ -231,9 +231,14 @@ static u32 pf_q_num = HZIP_PF_DEF_Q_NUM;
|
|||||||
module_param_cb(pf_q_num, &pf_q_num_ops, &pf_q_num, 0444);
|
module_param_cb(pf_q_num, &pf_q_num_ops, &pf_q_num, 0444);
|
||||||
MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 1-4096, v2 1-1024)");
|
MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 1-4096, v2 1-1024)");
|
||||||
|
|
||||||
|
static const struct kernel_param_ops vfs_num_ops = {
|
||||||
|
.set = vfs_num_set,
|
||||||
|
.get = param_get_int,
|
||||||
|
};
|
||||||
|
|
||||||
static u32 vfs_num;
|
static u32 vfs_num;
|
||||||
module_param(vfs_num, uint, 0444);
|
module_param_cb(vfs_num, &vfs_num_ops, &vfs_num, 0444);
|
||||||
MODULE_PARM_DESC(vfs_num, "Number of VFs to enable(1-63)");
|
MODULE_PARM_DESC(vfs_num, "Number of VFs to enable(1-63), 0(default)");
|
||||||
|
|
||||||
static const struct pci_device_id hisi_zip_dev_ids[] = {
|
static const struct pci_device_id hisi_zip_dev_ids[] = {
|
||||||
{ PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_ZIP_PF) },
|
{ PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_ZIP_PF) },
|
||||||
|
|||||||
Reference in New Issue
Block a user