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

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
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ struct hpre_debug {
struct hpre {
	struct hisi_qm qm;
	struct hpre_debug debug;
	u32 num_vfs;
	unsigned long status;
};

+5 −7
Original line number Diff line number Diff line
@@ -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)
{
	struct hisi_qm *qm = hpre_file_to_qm(file);
	struct hpre_debug *debug = file->debug;
	struct hpre *hpre = container_of(debug, struct hpre, debug);
	u32 num_vfs = hpre->num_vfs;
	u32 num_vfs = qm->vfs_num;
	u32 vfq_num, tmp;


@@ -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)
{
	struct hisi_qm *qm = &hpre->qm;
	u32 num_vfs = hpre->num_vfs;
	u32 num_vfs = qm->vfs_num;
	int ret;
	u32 i;

@@ -836,7 +834,7 @@ static int hpre_clear_vft_config(struct hpre *hpre)
		if (ret)
			return ret;
	}
	hpre->num_vfs = 0;
	qm->vfs_num = 0;

	return 0;
}
@@ -860,7 +858,7 @@ static int hpre_sriov_enable(struct pci_dev *pdev, int max_vfs)
		return ret;
	}

	hpre->num_vfs = num_vfs;
	hpre->qm.vfs_num = num_vfs;

	ret = pci_enable_sriov(pdev, num_vfs);
	if (ret) {
@@ -903,7 +901,7 @@ static void hpre_remove(struct pci_dev *pdev)

	hpre_algs_unregister();
	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);
		if (ret) {
			pci_err(pdev, "Disable SRIOV fail!\n");
+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ struct hisi_qm {
	u32 qp_num;
	u32 qp_in_used;
	u32 ctrl_qp_num;
	u32 vfs_num;
	struct list_head list;

	struct qm_dma qdma;
+0 −1
Original line number Diff line number Diff line
@@ -172,7 +172,6 @@ struct sec_dev {
	struct sec_debug debug;
	u32 ctx_q_num;
	bool iommu_used;
	u32 num_vfs;
	unsigned long status;
};

+8 −9
Original line number Diff line number Diff line
@@ -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)
{
	struct hisi_qm *qm = file->qm;
	struct sec_dev *sec = container_of(qm, struct sec_dev, qm);
	u32 vfq_num;
	u32 tmp;

	if (val > sec->num_vfs)
	if (val > qm->vfs_num)
		return -EINVAL;

	/* According PF or VF Dev ID to calculation curr_qm_qp_num and store */
	if (!val) {
		qm->debug.curr_qm_qp_num = qm->qp_num;
	} 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->ctrl_qp_num - qm->qp_num -
				(sec->num_vfs - 1) * vfq_num;
				(qm->vfs_num - 1) * vfq_num;
		else
			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)
static int sec_clear_vft_config(struct sec_dev *sec)
{
	struct hisi_qm *qm = &sec->qm;
	u32 num_vfs = sec->num_vfs;
	u32 num_vfs = qm->vfs_num;
	int ret;
	u32 i;

@@ -936,7 +935,7 @@ static int sec_clear_vft_config(struct sec_dev *sec)
			return ret;
	}

	sec->num_vfs = 0;
	qm->vfs_num = 0;

	return 0;
}
@@ -962,7 +961,7 @@ static int sec_sriov_enable(struct pci_dev *pdev, int max_vfs)
		return ret;
	}

	sec->num_vfs = num_vfs;
	sec->qm.vfs_num = num_vfs;

	ret = pci_enable_sriov(pdev, num_vfs);
	if (ret) {
@@ -1006,7 +1005,7 @@ static void sec_remove(struct pci_dev *pdev)

	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);

	sec_debugfs_exit(sec);
Loading