| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* Copyright(c) 2014 - 2022 Intel Corporation */ |
| 3 | #ifndef QAT_BL_H |
| 4 | #define QAT_BL_H |
| 5 | #include <linux/crypto.h> |
| 6 | #include <linux/scatterlist.h> |
| 7 | #include <linux/types.h> |
| 8 | |
| 9 | #define QAT_MAX_BUFF_DESC 4 |
| 10 | |
| 11 | struct qat_alg_buf { |
| 12 | u32 len; |
| 13 | u32 resrvd; |
| 14 | u64 addr; |
| 15 | } __packed; |
| 16 | |
| 17 | struct qat_alg_buf_list { |
| 18 | /* New members must be added within the __struct_group() macro below. */ |
| 19 | __struct_group(qat_alg_buf_list_hdr, hdr, __packed, |
| 20 | u64 resrvd; |
| 21 | u32 num_bufs; |
| 22 | u32 num_mapped_bufs; |
| 23 | ); |
| 24 | struct qat_alg_buf buffers[]; |
| 25 | } __packed; |
| 26 | static_assert(offsetof(struct qat_alg_buf_list, buffers) == sizeof(struct qat_alg_buf_list_hdr), |
| 27 | "struct member likely outside of __struct_group()" ); |
| 28 | |
| 29 | struct qat_alg_fixed_buf_list { |
| 30 | struct qat_alg_buf_list_hdr sgl_hdr; |
| 31 | struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC]; |
| 32 | } __packed __aligned(64); |
| 33 | |
| 34 | struct qat_request_buffs { |
| 35 | struct qat_alg_buf_list *bl; |
| 36 | dma_addr_t blp; |
| 37 | struct qat_alg_buf_list *blout; |
| 38 | dma_addr_t bloutp; |
| 39 | size_t sz; |
| 40 | size_t sz_out; |
| 41 | bool sgl_src_valid; |
| 42 | bool sgl_dst_valid; |
| 43 | struct qat_alg_fixed_buf_list sgl_src; |
| 44 | struct qat_alg_fixed_buf_list sgl_dst; |
| 45 | }; |
| 46 | |
| 47 | struct qat_sgl_to_bufl_params { |
| 48 | dma_addr_t ; |
| 49 | size_t ; |
| 50 | unsigned int sskip; |
| 51 | unsigned int dskip; |
| 52 | }; |
| 53 | |
| 54 | void qat_bl_free_bufl(struct adf_accel_dev *accel_dev, |
| 55 | struct qat_request_buffs *buf); |
| 56 | int qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev, |
| 57 | struct scatterlist *sgl, |
| 58 | struct scatterlist *sglout, |
| 59 | struct qat_request_buffs *buf, |
| 60 | struct qat_sgl_to_bufl_params *params, |
| 61 | gfp_t flags); |
| 62 | |
| 63 | static inline gfp_t qat_algs_alloc_flags(struct crypto_async_request *req) |
| 64 | { |
| 65 | return req->flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC; |
| 66 | } |
| 67 | |
| 68 | #endif |
| 69 | |