crypto: hisilicon/qm - split 'qm_qp_ctx_cfg' into smaller pieces
'qm_qp_ctx_cfg' initializes configuration of SQ and CQ, split it into two pieces to improve code readability. Signed-off-by: Weili Qian <qianweili@huawei.com> Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
09493afbc6
commit
3bf1ef9d51
|
@ -1735,19 +1735,15 @@ void hisi_qm_release_qp(struct hisi_qp *qp)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(hisi_qm_release_qp);
|
EXPORT_SYMBOL_GPL(hisi_qm_release_qp);
|
||||||
|
|
||||||
static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid)
|
static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
|
||||||
{
|
{
|
||||||
struct hisi_qm *qm = qp->qm;
|
struct hisi_qm *qm = qp->qm;
|
||||||
struct device *dev = &qm->pdev->dev;
|
struct device *dev = &qm->pdev->dev;
|
||||||
enum qm_hw_ver ver = qm->ver;
|
enum qm_hw_ver ver = qm->ver;
|
||||||
struct qm_sqc *sqc;
|
struct qm_sqc *sqc;
|
||||||
struct qm_cqc *cqc;
|
|
||||||
dma_addr_t sqc_dma;
|
dma_addr_t sqc_dma;
|
||||||
dma_addr_t cqc_dma;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
qm_init_qp_status(qp);
|
|
||||||
|
|
||||||
sqc = kzalloc(sizeof(struct qm_sqc), GFP_KERNEL);
|
sqc = kzalloc(sizeof(struct qm_sqc), GFP_KERNEL);
|
||||||
if (!sqc)
|
if (!sqc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -1772,12 +1768,23 @@ static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid)
|
||||||
ret = qm_mb(qm, QM_MB_CMD_SQC, sqc_dma, qp_id, 0);
|
ret = qm_mb(qm, QM_MB_CMD_SQC, sqc_dma, qp_id, 0);
|
||||||
dma_unmap_single(dev, sqc_dma, sizeof(struct qm_sqc), DMA_TO_DEVICE);
|
dma_unmap_single(dev, sqc_dma, sizeof(struct qm_sqc), DMA_TO_DEVICE);
|
||||||
kfree(sqc);
|
kfree(sqc);
|
||||||
if (ret)
|
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
|
||||||
|
{
|
||||||
|
struct hisi_qm *qm = qp->qm;
|
||||||
|
struct device *dev = &qm->pdev->dev;
|
||||||
|
enum qm_hw_ver ver = qm->ver;
|
||||||
|
struct qm_cqc *cqc;
|
||||||
|
dma_addr_t cqc_dma;
|
||||||
|
int ret;
|
||||||
|
|
||||||
cqc = kzalloc(sizeof(struct qm_cqc), GFP_KERNEL);
|
cqc = kzalloc(sizeof(struct qm_cqc), GFP_KERNEL);
|
||||||
if (!cqc)
|
if (!cqc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc),
|
cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc),
|
||||||
DMA_TO_DEVICE);
|
DMA_TO_DEVICE);
|
||||||
if (dma_mapping_error(dev, cqc_dma)) {
|
if (dma_mapping_error(dev, cqc_dma)) {
|
||||||
|
@ -1792,7 +1799,7 @@ static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid)
|
||||||
cqc->w8 = cpu_to_le16(QM_Q_DEPTH - 1);
|
cqc->w8 = cpu_to_le16(QM_Q_DEPTH - 1);
|
||||||
} else {
|
} else {
|
||||||
cqc->dw3 = cpu_to_le32(QM_MK_CQC_DW3_V2(QM_QC_CQE_SIZE));
|
cqc->dw3 = cpu_to_le32(QM_MK_CQC_DW3_V2(QM_QC_CQE_SIZE));
|
||||||
cqc->w8 = 0;
|
cqc->w8 = 0; /* rand_qc */
|
||||||
}
|
}
|
||||||
cqc->dw6 = cpu_to_le32(1 << QM_CQ_PHASE_SHIFT | 1 << QM_CQ_FLAG_SHIFT);
|
cqc->dw6 = cpu_to_le32(1 << QM_CQ_PHASE_SHIFT | 1 << QM_CQ_FLAG_SHIFT);
|
||||||
|
|
||||||
|
@ -1803,6 +1810,19 @@ static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
qm_init_qp_status(qp);
|
||||||
|
|
||||||
|
ret = qm_sq_ctx_cfg(qp, qp_id, pasid);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return qm_cq_ctx_cfg(qp, qp_id, pasid);
|
||||||
|
}
|
||||||
|
|
||||||
static int qm_start_qp_nolock(struct hisi_qp *qp, unsigned long arg)
|
static int qm_start_qp_nolock(struct hisi_qp *qp, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct hisi_qm *qm = qp->qm;
|
struct hisi_qm *qm = qp->qm;
|
||||||
|
|
Loading…
Reference in New Issue