Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: hisilicon/qm - add UACCE_CMD_QM_SET_QP_INFO support

To be compatible with accelerator devices of different
versions, 'UACCE_CMD_QM_SET_QP_INFO' ioctl is added to obtain
queue information in userspace, including queue depth and buffer
description size.

Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Weili Qian and committed by
Herbert Xu
c832da79 129a9f34

+34 -4
+18 -3
drivers/crypto/hisilicon/qm.c
··· 3430 3430 unsigned long arg) 3431 3431 { 3432 3432 struct hisi_qp *qp = q->priv; 3433 + struct hisi_qp_info qp_info; 3433 3434 struct hisi_qp_ctx qp_ctx; 3434 3435 3435 3436 if (cmd == UACCE_CMD_QM_SET_QP_CTX) { ··· 3447 3446 if (copy_to_user((void __user *)arg, &qp_ctx, 3448 3447 sizeof(struct hisi_qp_ctx))) 3449 3448 return -EFAULT; 3450 - } else { 3451 - return -EINVAL; 3449 + 3450 + return 0; 3451 + } else if (cmd == UACCE_CMD_QM_SET_QP_INFO) { 3452 + if (copy_from_user(&qp_info, (void __user *)arg, 3453 + sizeof(struct hisi_qp_info))) 3454 + return -EFAULT; 3455 + 3456 + qp_info.sqe_size = qp->qm->sqe_size; 3457 + qp_info.sq_depth = qp->sq_depth; 3458 + qp_info.cq_depth = qp->cq_depth; 3459 + 3460 + if (copy_to_user((void __user *)arg, &qp_info, 3461 + sizeof(struct hisi_qp_info))) 3462 + return -EFAULT; 3463 + 3464 + return 0; 3452 3465 } 3453 3466 3454 - return 0; 3467 + return -EINVAL; 3455 3468 } 3456 3469 3457 3470 static const struct uacce_ops uacce_qm_ops = {
+16 -1
include/uapi/misc/uacce/hisi_qm.h
··· 14 14 __u16 qc_type; 15 15 }; 16 16 17 + /** 18 + * struct hisi_qp_info - User data for hisi qp. 19 + * @sqe_size: Submission queue element size 20 + * @sq_depth: The number of sqe 21 + * @cq_depth: The number of cqe 22 + * @reserved: Reserved data 23 + */ 24 + struct hisi_qp_info { 25 + __u32 sqe_size; 26 + __u16 sq_depth; 27 + __u16 cq_depth; 28 + __u64 reserved; 29 + }; 30 + 17 31 #define HISI_QM_API_VER_BASE "hisi_qm_v1" 18 32 #define HISI_QM_API_VER2_BASE "hisi_qm_v2" 19 33 #define HISI_QM_API_VER3_BASE "hisi_qm_v3" 20 34 21 35 /* UACCE_CMD_QM_SET_QP_CTX: Set qp algorithm type */ 22 36 #define UACCE_CMD_QM_SET_QP_CTX _IOWR('H', 10, struct hisi_qp_ctx) 23 - 37 + /* UACCE_CMD_QM_SET_QP_INFO: Set qp depth and BD size */ 38 + #define UACCE_CMD_QM_SET_QP_INFO _IOWR('H', 11, struct hisi_qp_info) 24 39 #endif