diff options
author | Cristian Stoica <cristian.stoica@nxp.com> | 2016-01-25 11:19:43 +0200 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2016-08-12 11:41:02 -0300 |
commit | b8e3085e4e9608b301121c7065c84a3e51b94c74 (patch) | |
tree | 27dd6761bb8a8b9a3ce311bab1155a15badaec5e /recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch | |
parent | 578ab5d071729c9677d928467a2b48bcb0017139 (diff) | |
download | meta-freescale-b8e3085e4e9608b301121c7065c84a3e51b94c74.tar.gz |
cryptodev-qoriq: upgrade to 1.8 plus fsl patches
upstream commit: 87b56e04b24c6d4be145483477eff7d3153290e9
Also:
- move all fsl patches on top of cryptodev-1.8
- add CIOCHASH ioctl
- fix incorrect tests initializations
- modify yocto patches to match updated Makefiles
Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
Diffstat (limited to 'recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch')
-rw-r--r-- | recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch b/recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch new file mode 100644 index 00000000..5b96e841 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch | |||
@@ -0,0 +1,213 @@ | |||
1 | From d98f979d76c30058da24e62220f19c5b8c627819 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
3 | Date: Fri, 7 Mar 2014 07:24:00 +0545 | ||
4 | Subject: [PATCH 05/38] Asynchronous interface changes in cryptodev | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
9 | --- | ||
10 | cryptlib.h | 7 ++++- | ||
11 | crypto/cryptodev.h | 10 ++++++- | ||
12 | cryptodev_int.h | 10 ++++++- | ||
13 | ioctl.c | 76 +++++++++++++++++++++++++++++++++++++----------------- | ||
14 | 4 files changed, 76 insertions(+), 27 deletions(-) | ||
15 | |||
16 | diff --git a/cryptlib.h b/cryptlib.h | ||
17 | index 56d325a..7ffa54c 100644 | ||
18 | --- a/cryptlib.h | ||
19 | +++ b/cryptlib.h | ||
20 | @@ -113,7 +113,12 @@ struct cryptodev_pkc { | ||
21 | struct pkc_request req; /* PKC request structure allocated | ||
22 | from CryptoAPI */ | ||
23 | enum offload_type type; /* Synchronous Vs Asynchronous request */ | ||
24 | - void *cookie; /*Additional opaque cookie to be used in future */ | ||
25 | + /* | ||
26 | + * cookie used for transfering tranparent information from async | ||
27 | + * submission to async fetch. Currently some dynamic allocated | ||
28 | + * buffers are maintained which will be freed later during fetch | ||
29 | + */ | ||
30 | + void *cookie; | ||
31 | struct crypt_priv *priv; | ||
32 | }; | ||
33 | |||
34 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
35 | index 96675fe..4436fbf 100644 | ||
36 | --- a/crypto/cryptodev.h | ||
37 | +++ b/crypto/cryptodev.h | ||
38 | @@ -254,6 +254,14 @@ struct crypt_kop { | ||
39 | void *cookie; | ||
40 | }; | ||
41 | |||
42 | +#define MAX_COOKIES 4 | ||
43 | + | ||
44 | +struct pkc_cookie_list_s { | ||
45 | + int cookie_available; | ||
46 | + void *cookie[MAX_COOKIES]; | ||
47 | + int status[MAX_COOKIES]; | ||
48 | +}; | ||
49 | + | ||
50 | enum cryptodev_crk_op_t { | ||
51 | CRK_MOD_EXP = 0, | ||
52 | CRK_MOD_EXP_CRT = 1, | ||
53 | @@ -298,5 +306,5 @@ enum cryptodev_crk_op_t { | ||
54 | #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) | ||
55 | /* additional ioctls for asynchronous operation for asymmetric ciphers*/ | ||
56 | #define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) | ||
57 | -#define CIOCASYMASYNFETCH _IOR('c', 113, struct crypt_kop) | ||
58 | +#define CIOCASYMFETCHCOOKIE _IOR('c', 113, struct pkc_cookie_list_s) | ||
59 | #endif /* L_CRYPTODEV_H */ | ||
60 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
61 | index cf54dac..5347cae 100644 | ||
62 | --- a/cryptodev_int.h | ||
63 | +++ b/cryptodev_int.h | ||
64 | @@ -93,6 +93,12 @@ struct compat_crypt_kop { | ||
65 | compat_uptr_t cookie; | ||
66 | }; | ||
67 | |||
68 | +struct compat_pkc_cookie_list_s { | ||
69 | + int cookie_available; | ||
70 | + compat_uptr_t cookie[MAX_COOKIES]; | ||
71 | + int status[MAX_COOKIES]; | ||
72 | +}; | ||
73 | + | ||
74 | /* input of CIOCAUTHCRYPT */ | ||
75 | struct compat_crypt_auth_op { | ||
76 | uint32_t ses; /* session identifier */ | ||
77 | @@ -126,11 +132,13 @@ struct compat_crypt_auth_op { | ||
78 | /* compat ioctls, defined for the above structs */ | ||
79 | #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) | ||
80 | #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) | ||
81 | +#define COMPAT_CIOCKEY _IOW('c', 105, struct compat_crypt_kop) | ||
82 | #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) | ||
83 | #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) | ||
84 | #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) | ||
85 | #define COMPAT_CIOCASYMASYNCRYPT _IOW('c', 110, struct compat_crypt_kop) | ||
86 | -#define COMPAT_CIOCASYMASYNFETCH _IOR('c', 111, struct compat_crypt_kop) | ||
87 | +#define COMPAT_CIOCASYMFETCHCOOKIE _IOR('c', 111, \ | ||
88 | + struct compat_pkc_cookie_list_s) | ||
89 | |||
90 | #endif /* CONFIG_COMPAT */ | ||
91 | |||
92 | diff --git a/ioctl.c b/ioctl.c | ||
93 | index 9431025..e2f407f 100644 | ||
94 | --- a/ioctl.c | ||
95 | +++ b/ioctl.c | ||
96 | @@ -105,8 +105,6 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) | ||
97 | crypto_free_pkc(pkc->s); | ||
98 | res->err = err; | ||
99 | if (pkc->type == SYNCHRONOUS) { | ||
100 | - if (err == -EINPROGRESS) | ||
101 | - return; | ||
102 | complete(&res->completion); | ||
103 | } else { | ||
104 | struct crypt_priv *pcr = pkc->priv; | ||
105 | @@ -1051,26 +1049,41 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
106 | ret = 0; | ||
107 | } | ||
108 | return ret; | ||
109 | - case CIOCASYMASYNFETCH: | ||
110 | + case CIOCASYMFETCHCOOKIE: | ||
111 | { | ||
112 | struct cryptodev_pkc *pkc; | ||
113 | unsigned long flags; | ||
114 | + int i; | ||
115 | + struct pkc_cookie_list_s cookie_list; | ||
116 | |||
117 | spin_lock_irqsave(&pcr->completion_lock, flags); | ||
118 | - if (list_empty(&pcr->asym_completed_list)) { | ||
119 | - spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
120 | - return -ENOMEM; | ||
121 | + cookie_list.cookie_available = 0; | ||
122 | + for (i = 0; i < MAX_COOKIES; i++) { | ||
123 | + if (!list_empty(&pcr->asym_completed_list)) { | ||
124 | + /* Run a loop in the list for upto elements | ||
125 | + and copy their response back */ | ||
126 | + pkc = | ||
127 | + list_first_entry(&pcr->asym_completed_list, | ||
128 | + struct cryptodev_pkc, list); | ||
129 | + list_del(&pkc->list); | ||
130 | + ret = crypto_async_fetch_asym(pkc); | ||
131 | + if (!ret) { | ||
132 | + cookie_list.cookie_available++; | ||
133 | + cookie_list.cookie[i] = | ||
134 | + pkc->kop.kop.cookie; | ||
135 | + cookie_list.status[i] = pkc->result.err; | ||
136 | + } | ||
137 | + kfree(pkc); | ||
138 | + } else { | ||
139 | + break; | ||
140 | + } | ||
141 | } | ||
142 | - pkc = list_first_entry(&pcr->asym_completed_list, | ||
143 | - struct cryptodev_pkc, list); | ||
144 | - list_del(&pkc->list); | ||
145 | spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
146 | - ret = crypto_async_fetch_asym(pkc); | ||
147 | |||
148 | /* Reflect the updated request to user-space */ | ||
149 | - if (!ret) | ||
150 | - kop_to_user(&pkc->kop, arg); | ||
151 | - kfree(pkc); | ||
152 | + if (cookie_list.cookie_available) | ||
153 | + copy_to_user(arg, &cookie_list, | ||
154 | + sizeof(struct pkc_cookie_list_s)); | ||
155 | } | ||
156 | return ret; | ||
157 | default: | ||
158 | @@ -1345,26 +1358,41 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
159 | ret = 0; | ||
160 | } | ||
161 | return ret; | ||
162 | - case COMPAT_CIOCASYMASYNFETCH: | ||
163 | + case COMPAT_CIOCASYMFETCHCOOKIE: | ||
164 | { | ||
165 | struct cryptodev_pkc *pkc; | ||
166 | unsigned long flags; | ||
167 | + int i = 0; | ||
168 | + struct compat_pkc_cookie_list_s cookie_list; | ||
169 | |||
170 | spin_lock_irqsave(&pcr->completion_lock, flags); | ||
171 | - if (list_empty(&pcr->asym_completed_list)) { | ||
172 | - spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
173 | - return -ENOMEM; | ||
174 | + cookie_list.cookie_available = 0; | ||
175 | + | ||
176 | + for (i = 0; i < MAX_COOKIES; i++) { | ||
177 | + if (!list_empty(&pcr->asym_completed_list)) { | ||
178 | + /* Run a loop in the list for upto elements | ||
179 | + and copy their response back */ | ||
180 | + pkc = | ||
181 | + list_first_entry(&pcr->asym_completed_list, | ||
182 | + struct cryptodev_pkc, list); | ||
183 | + list_del(&pkc->list); | ||
184 | + ret = crypto_async_fetch_asym(pkc); | ||
185 | + if (!ret) { | ||
186 | + cookie_list.cookie_available++; | ||
187 | + cookie_list.cookie[i] = | ||
188 | + pkc->kop.kop.cookie; | ||
189 | + } | ||
190 | + kfree(pkc); | ||
191 | + } else { | ||
192 | + break; | ||
193 | + } | ||
194 | } | ||
195 | - pkc = list_first_entry(&pcr->asym_completed_list, | ||
196 | - struct cryptodev_pkc, list); | ||
197 | - list_del(&pkc->list); | ||
198 | spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
199 | - ret = crypto_async_fetch_asym(pkc); | ||
200 | |||
201 | /* Reflect the updated request to user-space */ | ||
202 | - if (!ret) | ||
203 | - compat_kop_to_user(&pkc->kop, arg); | ||
204 | - kfree(pkc); | ||
205 | + if (cookie_list.cookie_available) | ||
206 | + copy_to_user(arg, &cookie_list, | ||
207 | + sizeof(struct compat_pkc_cookie_list_s)); | ||
208 | } | ||
209 | return ret; | ||
210 | default: | ||
211 | -- | ||
212 | 2.7.0 | ||
213 | |||