Skip to content

Commit 2966d9d

Browse files
yekai123123herbertx
authored andcommitted
crypto: hisilicon/qm - add pf ping single vf function
According to the function communication, add pf ping single vf function to be used in the vf read QoS. Signed-off-by: Kai Ye <yekai13@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 362c50b commit 2966d9d

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

  • drivers/crypto/hisilicon

drivers/crypto/hisilicon/qm.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,42 @@ static void qm_trigger_pf_interrupt(struct hisi_qm *qm)
21422142
writel(val, qm->io_base + QM_IFC_INT_SET_V);
21432143
}
21442144

2145+
static int qm_ping_single_vf(struct hisi_qm *qm, u64 cmd, u32 fun_num)
2146+
{
2147+
struct device *dev = &qm->pdev->dev;
2148+
struct qm_mailbox mailbox;
2149+
int cnt = 0;
2150+
u64 val;
2151+
int ret;
2152+
2153+
qm_mb_pre_init(&mailbox, QM_MB_CMD_SRC, cmd, fun_num, 0);
2154+
mutex_lock(&qm->mailbox_lock);
2155+
ret = qm_mb_nolock(qm, &mailbox);
2156+
if (ret) {
2157+
dev_err(dev, "failed to send command to vf(%u)!\n", fun_num);
2158+
goto err_unlock;
2159+
}
2160+
2161+
qm_trigger_vf_interrupt(qm, fun_num);
2162+
while (true) {
2163+
msleep(QM_WAIT_DST_ACK);
2164+
val = readq(qm->io_base + QM_IFC_READY_STATUS);
2165+
/* if VF respond, PF notifies VF successfully. */
2166+
if (!(val & BIT(fun_num)))
2167+
goto err_unlock;
2168+
2169+
if (++cnt > QM_MAX_PF_WAIT_COUNT) {
2170+
dev_err(dev, "failed to get response from VF(%u)!\n", fun_num);
2171+
ret = -ETIMEDOUT;
2172+
break;
2173+
}
2174+
}
2175+
2176+
err_unlock:
2177+
mutex_unlock(&qm->mailbox_lock);
2178+
return ret;
2179+
}
2180+
21452181
static int qm_ping_all_vfs(struct hisi_qm *qm, u64 cmd)
21462182
{
21472183
struct device *dev = &qm->pdev->dev;

0 commit comments

Comments
 (0)