Commit 619e464a authored by Shukun Tan's avatar Shukun Tan Committed by Herbert Xu

crypto: hisilicon - put vfs_num into struct hisi_qm

We plan to move vfs_num related code into qm.c, put the param
vfs_num into struct hisi_qm first.
Signed-off-by: default avatarShukun Tan <tanshukun1@huawei.com>
Reviewed-by: default avatarZhou Wang <wangzhou1@hisilicon.com>
Reviewed-by: default avatarZaibo Xu <xuzaibo@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 3c8e0bd1
...@@ -47,7 +47,6 @@ struct hpre_debug { ...@@ -47,7 +47,6 @@ struct hpre_debug {
struct hpre { struct hpre {
struct hisi_qm qm; struct hisi_qm qm;
struct hpre_debug debug; struct hpre_debug debug;
u32 num_vfs;
unsigned long status; unsigned long status;
}; };
......
...@@ -354,9 +354,7 @@ static u32 hpre_current_qm_read(struct hpre_debugfs_file *file) ...@@ -354,9 +354,7 @@ static u32 hpre_current_qm_read(struct hpre_debugfs_file *file)
static int hpre_current_qm_write(struct hpre_debugfs_file *file, u32 val) static int hpre_current_qm_write(struct hpre_debugfs_file *file, u32 val)
{ {
struct hisi_qm *qm = hpre_file_to_qm(file); struct hisi_qm *qm = hpre_file_to_qm(file);
struct hpre_debug *debug = file->debug; u32 num_vfs = qm->vfs_num;
struct hpre *hpre = container_of(debug, struct hpre, debug);
u32 num_vfs = hpre->num_vfs;
u32 vfq_num, tmp; u32 vfq_num, tmp;
...@@ -827,7 +825,7 @@ static int hpre_vf_q_assign(struct hpre *hpre, int num_vfs) ...@@ -827,7 +825,7 @@ static int hpre_vf_q_assign(struct hpre *hpre, int num_vfs)
static int hpre_clear_vft_config(struct hpre *hpre) static int hpre_clear_vft_config(struct hpre *hpre)
{ {
struct hisi_qm *qm = &hpre->qm; struct hisi_qm *qm = &hpre->qm;
u32 num_vfs = hpre->num_vfs; u32 num_vfs = qm->vfs_num;
int ret; int ret;
u32 i; u32 i;
...@@ -836,7 +834,7 @@ static int hpre_clear_vft_config(struct hpre *hpre) ...@@ -836,7 +834,7 @@ static int hpre_clear_vft_config(struct hpre *hpre)
if (ret) if (ret)
return ret; return ret;
} }
hpre->num_vfs = 0; qm->vfs_num = 0;
return 0; return 0;
} }
...@@ -860,7 +858,7 @@ static int hpre_sriov_enable(struct pci_dev *pdev, int max_vfs) ...@@ -860,7 +858,7 @@ static int hpre_sriov_enable(struct pci_dev *pdev, int max_vfs)
return ret; return ret;
} }
hpre->num_vfs = num_vfs; hpre->qm.vfs_num = num_vfs;
ret = pci_enable_sriov(pdev, num_vfs); ret = pci_enable_sriov(pdev, num_vfs);
if (ret) { if (ret) {
...@@ -903,7 +901,7 @@ static void hpre_remove(struct pci_dev *pdev) ...@@ -903,7 +901,7 @@ static void hpre_remove(struct pci_dev *pdev)
hpre_algs_unregister(); hpre_algs_unregister();
hisi_qm_del_from_list(qm, &hpre_devices); hisi_qm_del_from_list(qm, &hpre_devices);
if (qm->fun_type == QM_HW_PF && hpre->num_vfs != 0) { if (qm->fun_type == QM_HW_PF && qm->vfs_num) {
ret = hpre_sriov_disable(pdev); ret = hpre_sriov_disable(pdev);
if (ret) { if (ret) {
pci_err(pdev, "Disable SRIOV fail!\n"); pci_err(pdev, "Disable SRIOV fail!\n");
......
...@@ -161,6 +161,7 @@ struct hisi_qm { ...@@ -161,6 +161,7 @@ struct hisi_qm {
u32 qp_num; u32 qp_num;
u32 qp_in_used; u32 qp_in_used;
u32 ctrl_qp_num; u32 ctrl_qp_num;
u32 vfs_num;
struct list_head list; struct list_head list;
struct qm_dma qdma; struct qm_dma qdma;
......
...@@ -172,7 +172,6 @@ struct sec_dev { ...@@ -172,7 +172,6 @@ struct sec_dev {
struct sec_debug debug; struct sec_debug debug;
u32 ctx_q_num; u32 ctx_q_num;
bool iommu_used; bool iommu_used;
u32 num_vfs;
unsigned long status; unsigned long status;
}; };
......
...@@ -424,23 +424,22 @@ static u32 sec_current_qm_read(struct sec_debug_file *file) ...@@ -424,23 +424,22 @@ static u32 sec_current_qm_read(struct sec_debug_file *file)
static int sec_current_qm_write(struct sec_debug_file *file, u32 val) static int sec_current_qm_write(struct sec_debug_file *file, u32 val)
{ {
struct hisi_qm *qm = file->qm; struct hisi_qm *qm = file->qm;
struct sec_dev *sec = container_of(qm, struct sec_dev, qm);
u32 vfq_num; u32 vfq_num;
u32 tmp; u32 tmp;
if (val > sec->num_vfs) if (val > qm->vfs_num)
return -EINVAL; return -EINVAL;
/* According PF or VF Dev ID to calculation curr_qm_qp_num and store */ /* According PF or VF Dev ID to calculation curr_qm_qp_num and store */
if (!val) { if (!val) {
qm->debug.curr_qm_qp_num = qm->qp_num; qm->debug.curr_qm_qp_num = qm->qp_num;
} else { } else {
vfq_num = (qm->ctrl_qp_num - qm->qp_num) / sec->num_vfs; vfq_num = (qm->ctrl_qp_num - qm->qp_num) / qm->vfs_num;
if (val == sec->num_vfs) if (val == qm->vfs_num)
qm->debug.curr_qm_qp_num = qm->debug.curr_qm_qp_num =
qm->ctrl_qp_num - qm->qp_num - qm->ctrl_qp_num - qm->qp_num -
(sec->num_vfs - 1) * vfq_num; (qm->vfs_num - 1) * vfq_num;
else else
qm->debug.curr_qm_qp_num = vfq_num; qm->debug.curr_qm_qp_num = vfq_num;
} }
...@@ -926,7 +925,7 @@ static int sec_vf_q_assign(struct sec_dev *sec, u32 num_vfs) ...@@ -926,7 +925,7 @@ static int sec_vf_q_assign(struct sec_dev *sec, u32 num_vfs)
static int sec_clear_vft_config(struct sec_dev *sec) static int sec_clear_vft_config(struct sec_dev *sec)
{ {
struct hisi_qm *qm = &sec->qm; struct hisi_qm *qm = &sec->qm;
u32 num_vfs = sec->num_vfs; u32 num_vfs = qm->vfs_num;
int ret; int ret;
u32 i; u32 i;
...@@ -936,7 +935,7 @@ static int sec_clear_vft_config(struct sec_dev *sec) ...@@ -936,7 +935,7 @@ static int sec_clear_vft_config(struct sec_dev *sec)
return ret; return ret;
} }
sec->num_vfs = 0; qm->vfs_num = 0;
return 0; return 0;
} }
...@@ -962,7 +961,7 @@ static int sec_sriov_enable(struct pci_dev *pdev, int max_vfs) ...@@ -962,7 +961,7 @@ static int sec_sriov_enable(struct pci_dev *pdev, int max_vfs)
return ret; return ret;
} }
sec->num_vfs = num_vfs; sec->qm.vfs_num = num_vfs;
ret = pci_enable_sriov(pdev, num_vfs); ret = pci_enable_sriov(pdev, num_vfs);
if (ret) { if (ret) {
...@@ -1006,7 +1005,7 @@ static void sec_remove(struct pci_dev *pdev) ...@@ -1006,7 +1005,7 @@ static void sec_remove(struct pci_dev *pdev)
hisi_qm_del_from_list(qm, &sec_devices); hisi_qm_del_from_list(qm, &sec_devices);
if (qm->fun_type == QM_HW_PF && sec->num_vfs) if (qm->fun_type == QM_HW_PF && qm->vfs_num)
(void)sec_sriov_disable(pdev); (void)sec_sriov_disable(pdev);
sec_debugfs_exit(sec); sec_debugfs_exit(sec);
......
...@@ -134,7 +134,6 @@ struct ctrl_debug_file { ...@@ -134,7 +134,6 @@ struct ctrl_debug_file {
* Just relevant for PF. * Just relevant for PF.
*/ */
struct hisi_zip_ctrl { struct hisi_zip_ctrl {
u32 num_vfs;
struct hisi_zip *hisi_zip; struct hisi_zip *hisi_zip;
struct dentry *debug_root; struct dentry *debug_root;
struct ctrl_debug_file files[HZIP_DEBUG_FILE_NUM]; struct ctrl_debug_file files[HZIP_DEBUG_FILE_NUM];
...@@ -342,21 +341,20 @@ static u32 current_qm_read(struct ctrl_debug_file *file) ...@@ -342,21 +341,20 @@ static u32 current_qm_read(struct ctrl_debug_file *file)
static int current_qm_write(struct ctrl_debug_file *file, u32 val) static int current_qm_write(struct ctrl_debug_file *file, u32 val)
{ {
struct hisi_qm *qm = file_to_qm(file); struct hisi_qm *qm = file_to_qm(file);
struct hisi_zip_ctrl *ctrl = file->ctrl;
u32 vfq_num; u32 vfq_num;
u32 tmp; u32 tmp;
if (val > ctrl->num_vfs) if (val > qm->vfs_num)
return -EINVAL; return -EINVAL;
/* Calculate curr_qm_qp_num and store */ /* Calculate curr_qm_qp_num and store */
if (val == 0) { if (val == 0) {
qm->debug.curr_qm_qp_num = qm->qp_num; qm->debug.curr_qm_qp_num = qm->qp_num;
} else { } else {
vfq_num = (qm->ctrl_qp_num - qm->qp_num) / ctrl->num_vfs; vfq_num = (qm->ctrl_qp_num - qm->qp_num) / qm->vfs_num;
if (val == ctrl->num_vfs) if (val == qm->vfs_num)
qm->debug.curr_qm_qp_num = qm->ctrl_qp_num - qm->debug.curr_qm_qp_num = qm->ctrl_qp_num -
qm->qp_num - (ctrl->num_vfs - 1) * vfq_num; qm->qp_num - (qm->vfs_num - 1) * vfq_num;
else else
qm->debug.curr_qm_qp_num = vfq_num; qm->debug.curr_qm_qp_num = vfq_num;
} }
...@@ -686,9 +684,8 @@ static int hisi_zip_vf_q_assign(struct hisi_zip *hisi_zip, int num_vfs) ...@@ -686,9 +684,8 @@ static int hisi_zip_vf_q_assign(struct hisi_zip *hisi_zip, int num_vfs)
static int hisi_zip_clear_vft_config(struct hisi_zip *hisi_zip) static int hisi_zip_clear_vft_config(struct hisi_zip *hisi_zip)
{ {
struct hisi_zip_ctrl *ctrl = hisi_zip->ctrl;
struct hisi_qm *qm = &hisi_zip->qm; struct hisi_qm *qm = &hisi_zip->qm;
u32 i, num_vfs = ctrl->num_vfs; u32 i, num_vfs = qm->vfs_num;
int ret; int ret;
for (i = 1; i <= num_vfs; i++) { for (i = 1; i <= num_vfs; i++) {
...@@ -697,7 +694,7 @@ static int hisi_zip_clear_vft_config(struct hisi_zip *hisi_zip) ...@@ -697,7 +694,7 @@ static int hisi_zip_clear_vft_config(struct hisi_zip *hisi_zip)
return ret; return ret;
} }
ctrl->num_vfs = 0; qm->vfs_num = 0;
return 0; return 0;
} }
...@@ -723,7 +720,7 @@ static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs) ...@@ -723,7 +720,7 @@ static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs)
return ret; return ret;
} }
hisi_zip->ctrl->num_vfs = num_vfs; hisi_zip->qm.vfs_num = num_vfs;
ret = pci_enable_sriov(pdev, num_vfs); ret = pci_enable_sriov(pdev, num_vfs);
if (ret) { if (ret) {
...@@ -852,7 +849,7 @@ static void hisi_zip_remove(struct pci_dev *pdev) ...@@ -852,7 +849,7 @@ static void hisi_zip_remove(struct pci_dev *pdev)
struct hisi_zip *hisi_zip = pci_get_drvdata(pdev); struct hisi_zip *hisi_zip = pci_get_drvdata(pdev);
struct hisi_qm *qm = &hisi_zip->qm; struct hisi_qm *qm = &hisi_zip->qm;
if (qm->fun_type == QM_HW_PF && hisi_zip->ctrl->num_vfs != 0) if (qm->fun_type == QM_HW_PF && qm->vfs_num)
hisi_zip_sriov_disable(pdev); hisi_zip_sriov_disable(pdev);
hisi_zip_debugfs_exit(hisi_zip); hisi_zip_debugfs_exit(hisi_zip);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment