AnilKumar Chimata | e78789a | 2017-04-07 12:18:46 -0700 | [diff] [blame] | 1 | #ifndef _UAPI_COMPAT_QCEDEV__H |
| 2 | #define _UAPI_COMPAT_QCEDEV__H |
| 3 | |
| 4 | #include <linux/types.h> |
| 5 | #include <linux/ioctl.h> |
| 6 | |
| 7 | #if IS_ENABLED(CONFIG_COMPAT) |
| 8 | #include <linux/compat.h> |
| 9 | |
| 10 | /** |
| 11 | * struct compat_buf_info - Buffer information |
| 12 | * @offset: Offset from the base address of the buffer |
| 13 | * (Used when buffer is allocated using PMEM) |
| 14 | * @vaddr: Virtual buffer address pointer |
| 15 | * @len: Size of the buffer |
| 16 | */ |
| 17 | struct compat_buf_info { |
| 18 | union { |
| 19 | compat_ulong_t offset; |
| 20 | compat_uptr_t vaddr; |
| 21 | }; |
| 22 | compat_ulong_t len; |
| 23 | }; |
| 24 | |
| 25 | /** |
| 26 | * struct compat_qcedev_vbuf_info - Source and destination Buffer information |
| 27 | * @src: Array of buf_info for input/source |
| 28 | * @dst: Array of buf_info for output/destination |
| 29 | */ |
| 30 | struct compat_qcedev_vbuf_info { |
| 31 | struct compat_buf_info src[QCEDEV_MAX_BUFFERS]; |
| 32 | struct compat_buf_info dst[QCEDEV_MAX_BUFFERS]; |
| 33 | }; |
| 34 | |
| 35 | /** |
| 36 | * struct compat_qcedev_pmem_info - Stores PMEM buffer information |
| 37 | * @fd_src: Handle to /dev/adsp_pmem used to allocate |
| 38 | * memory for input/src buffer |
| 39 | * @src: Array of buf_info for input/source |
| 40 | * @fd_dst: Handle to /dev/adsp_pmem used to allocate |
| 41 | * memory for output/dst buffer |
| 42 | * @dst: Array of buf_info for output/destination |
| 43 | * @pmem_src_offset: The offset from input/src buffer |
| 44 | * (allocated by PMEM) |
| 45 | */ |
| 46 | struct compat_qcedev_pmem_info { |
| 47 | compat_int_t fd_src; |
| 48 | struct compat_buf_info src[QCEDEV_MAX_BUFFERS]; |
| 49 | compat_int_t fd_dst; |
| 50 | struct compat_buf_info dst[QCEDEV_MAX_BUFFERS]; |
| 51 | }; |
| 52 | |
| 53 | /** |
| 54 | * struct compat_qcedev_cipher_op_req - Holds the ciphering request information |
| 55 | * @use_pmem (IN): Flag to indicate if buffer source is PMEM |
| 56 | * QCEDEV_USE_PMEM/QCEDEV_NO_PMEM |
| 57 | * @pmem (IN): Stores PMEM buffer information. |
| 58 | * Refer struct qcedev_pmem_info |
| 59 | * @vbuf (IN/OUT): Stores Source and destination Buffer information |
| 60 | * Refer to struct qcedev_vbuf_info |
| 61 | * @data_len (IN): Total Length of input/src and output/dst in bytes |
| 62 | * @in_place_op (IN): Indicates whether the operation is inplace where |
| 63 | * source == destination |
| 64 | * When using PMEM allocated memory, must set this to 1 |
| 65 | * @enckey (IN): 128 bits of confidentiality key |
| 66 | * enckey[0] bit 127-120, enckey[1] bit 119-112,.. |
| 67 | * enckey[15] bit 7-0 |
| 68 | * @encklen (IN): Length of the encryption key(set to 128 bits/16 |
| 69 | * bytes in the driver) |
| 70 | * @iv (IN/OUT): Initialization vector data |
| 71 | * This is updated by the driver, incremented by |
| 72 | * number of blocks encrypted/decrypted. |
| 73 | * @ivlen (IN): Length of the IV |
| 74 | * @byteoffset (IN): Offset in the Cipher BLOCK (applicable and to be set |
| 75 | * for AES-128 CTR mode only) |
| 76 | * @alg (IN): Type of ciphering algorithm: AES/DES/3DES |
| 77 | * @mode (IN): Mode use when using AES algorithm: ECB/CBC/CTR |
| 78 | * Applicable when using AES algorithm only |
| 79 | * @op (IN): Type of operation: QCEDEV_OPER_DEC/QCEDEV_OPER_ENC or |
| 80 | * QCEDEV_OPER_ENC_NO_KEY/QCEDEV_OPER_DEC_NO_KEY |
| 81 | * |
| 82 | * If use_pmem is set to 0, the driver assumes that memory was not allocated |
| 83 | * via PMEM, and kernel will need to allocate memory and copy data from user |
| 84 | * space buffer (data_src/dta_dst) and process accordingly and copy data back |
| 85 | * to the user space buffer |
| 86 | * |
| 87 | * If use_pmem is set to 1, the driver assumes that memory was allocated via |
| 88 | * PMEM. |
| 89 | * The kernel driver will use the fd_src to determine the kernel virtual address |
| 90 | * base that maps to the user space virtual address base for the buffer |
| 91 | * allocated in user space. |
| 92 | * The final input/src and output/dst buffer pointer will be determined |
| 93 | * by adding the offsets to the kernel virtual addr. |
| 94 | * |
| 95 | * If use of hardware key is supported in the target, user can configure the |
| 96 | * key parameters (encklen, enckey) to use the hardware key. |
| 97 | * In order to use the hardware key, set encklen to 0 and set the enckey |
| 98 | * data array to 0. |
| 99 | */ |
| 100 | struct compat_qcedev_cipher_op_req { |
| 101 | uint8_t use_pmem; |
| 102 | union { |
| 103 | struct compat_qcedev_pmem_info pmem; |
| 104 | struct compat_qcedev_vbuf_info vbuf; |
| 105 | }; |
| 106 | compat_ulong_t entries; |
| 107 | compat_ulong_t data_len; |
| 108 | uint8_t in_place_op; |
| 109 | uint8_t enckey[QCEDEV_MAX_KEY_SIZE]; |
| 110 | compat_ulong_t encklen; |
| 111 | uint8_t iv[QCEDEV_MAX_IV_SIZE]; |
| 112 | compat_ulong_t ivlen; |
| 113 | compat_ulong_t byteoffset; |
| 114 | enum qcedev_cipher_alg_enum alg; |
| 115 | enum qcedev_cipher_mode_enum mode; |
| 116 | enum qcedev_oper_enum op; |
| 117 | }; |
| 118 | |
| 119 | /** |
| 120 | * struct qcedev_sha_op_req - Holds the hashing request information |
| 121 | * @data (IN): Array of pointers to the data to be hashed |
| 122 | * @entries (IN): Number of buf_info entries in the data array |
| 123 | * @data_len (IN): Length of data to be hashed |
| 124 | * @digest (IN/OUT): Returns the hashed data information |
| 125 | * @diglen (OUT): Size of the hashed/digest data |
| 126 | * @authkey (IN): Pointer to authentication key for HMAC |
| 127 | * @authklen (IN): Size of the authentication key |
| 128 | * @alg (IN): Secure Hash algorithm |
| 129 | */ |
| 130 | struct compat_qcedev_sha_op_req { |
| 131 | struct compat_buf_info data[QCEDEV_MAX_BUFFERS]; |
| 132 | compat_ulong_t entries; |
| 133 | compat_ulong_t data_len; |
| 134 | uint8_t digest[QCEDEV_MAX_SHA_DIGEST]; |
| 135 | compat_ulong_t diglen; |
| 136 | compat_uptr_t authkey; |
| 137 | compat_ulong_t authklen; |
| 138 | enum qcedev_sha_alg_enum alg; |
| 139 | }; |
| 140 | |
| 141 | struct file; |
| 142 | extern long compat_qcedev_ioctl(struct file *file, |
| 143 | unsigned int cmd, unsigned long arg); |
| 144 | |
| 145 | #define COMPAT_QCEDEV_IOCTL_ENC_REQ \ |
| 146 | _IOWR(QCEDEV_IOC_MAGIC, 1, struct compat_qcedev_cipher_op_req) |
| 147 | #define COMPAT_QCEDEV_IOCTL_DEC_REQ \ |
| 148 | _IOWR(QCEDEV_IOC_MAGIC, 2, struct compat_qcedev_cipher_op_req) |
| 149 | #define COMPAT_QCEDEV_IOCTL_SHA_INIT_REQ \ |
| 150 | _IOWR(QCEDEV_IOC_MAGIC, 3, struct compat_qcedev_sha_op_req) |
| 151 | #define COMPAT_QCEDEV_IOCTL_SHA_UPDATE_REQ \ |
| 152 | _IOWR(QCEDEV_IOC_MAGIC, 4, struct compat_qcedev_sha_op_req) |
| 153 | #define COMPAT_QCEDEV_IOCTL_SHA_FINAL_REQ \ |
| 154 | _IOWR(QCEDEV_IOC_MAGIC, 5, struct compat_qcedev_sha_op_req) |
| 155 | #define COMPAT_QCEDEV_IOCTL_GET_SHA_REQ \ |
| 156 | _IOWR(QCEDEV_IOC_MAGIC, 6, struct compat_qcedev_sha_op_req) |
| 157 | #define COMPAT_QCEDEV_IOCTL_LOCK_CE \ |
| 158 | _IO(QCEDEV_IOC_MAGIC, 7) |
| 159 | #define COMPAT_QCEDEV_IOCTL_UNLOCK_CE \ |
| 160 | _IO(QCEDEV_IOC_MAGIC, 8) |
| 161 | #define COMPAT_QCEDEV_IOCTL_GET_CMAC_REQ \ |
| 162 | _IOWR(QCEDEV_IOC_MAGIC, 9, struct compat_qcedev_sha_op_req) |
| 163 | |
| 164 | #endif /* CONFIG_COMPAT */ |
| 165 | #endif /* _UAPI_COMPAT_QCEDEV__H */ |