aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoria Geanta <horia.geanta@freescale.com>2012-08-02 10:16:40 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2012-08-28 11:56:27 -0400
commit79fd31d355f7e315025a330adc2183fb5ae8f22d (patch)
treee32735f1d0dc615bf9ff66a2b01a4dcef381a0a2
parent2a1cfe46b17f6dd43fcd8eb2b5e5deaa2a94e4bb (diff)
crypto: talitos - support for assoc data provided as scatterlist
Generate a link table in case assoc data is a scatterlist. While at it, add support for handling non-contiguous assoc data and iv. Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/talitos.c176
1 files changed, 125 insertions, 51 deletions
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index 2cba392f1682..bea25e291a5a 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -714,10 +714,13 @@ badkey:
714 714
715/* 715/*
716 * talitos_edesc - s/w-extended descriptor 716 * talitos_edesc - s/w-extended descriptor
717 * @assoc_nents: number of segments in associated data scatterlist
717 * @src_nents: number of segments in input scatterlist 718 * @src_nents: number of segments in input scatterlist
718 * @dst_nents: number of segments in output scatterlist 719 * @dst_nents: number of segments in output scatterlist
720 * @assoc_chained: whether assoc is chained or not
719 * @src_chained: whether src is chained or not 721 * @src_chained: whether src is chained or not
720 * @dst_chained: whether dst is chained or not 722 * @dst_chained: whether dst is chained or not
723 * @iv_dma: dma address of iv for checking continuity and link table
721 * @dma_len: length of dma mapped link_tbl space 724 * @dma_len: length of dma mapped link_tbl space
722 * @dma_link_tbl: bus physical address of link_tbl 725 * @dma_link_tbl: bus physical address of link_tbl
723 * @desc: h/w descriptor 726 * @desc: h/w descriptor
@@ -728,10 +731,13 @@ badkey:
728 * of link_tbl data 731 * of link_tbl data
729 */ 732 */
730struct talitos_edesc { 733struct talitos_edesc {
734 int assoc_nents;
731 int src_nents; 735 int src_nents;
732 int dst_nents; 736 int dst_nents;
737 bool assoc_chained;
733 bool src_chained; 738 bool src_chained;
734 bool dst_chained; 739 bool dst_chained;
740 dma_addr_t iv_dma;
735 int dma_len; 741 int dma_len;
736 dma_addr_t dma_link_tbl; 742 dma_addr_t dma_link_tbl;
737 struct talitos_desc desc; 743 struct talitos_desc desc;
@@ -799,7 +805,13 @@ static void ipsec_esp_unmap(struct device *dev,
799 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE); 805 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE);
800 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[0], DMA_TO_DEVICE); 806 unmap_single_talitos_ptr(dev, &edesc->desc.ptr[0], DMA_TO_DEVICE);
801 807
802 dma_unmap_sg(dev, areq->assoc, 1, DMA_TO_DEVICE); 808 if (edesc->assoc_chained)
809 talitos_unmap_sg_chain(dev, areq->assoc, DMA_TO_DEVICE);
810 else
811 /* assoc_nents counts also for IV in non-contiguous cases */
812 dma_unmap_sg(dev, areq->assoc,
813 edesc->assoc_nents ? edesc->assoc_nents - 1 : 1,
814 DMA_TO_DEVICE);
803 815
804 talitos_sg_unmap(dev, edesc, areq->src, areq->dst); 816 talitos_sg_unmap(dev, edesc, areq->src, areq->dst);
805 817
@@ -829,7 +841,8 @@ static void ipsec_esp_encrypt_done(struct device *dev,
829 /* copy the generated ICV to dst */ 841 /* copy the generated ICV to dst */
830 if (edesc->dst_nents) { 842 if (edesc->dst_nents) {
831 icvdata = &edesc->link_tbl[edesc->src_nents + 843 icvdata = &edesc->link_tbl[edesc->src_nents +
832 edesc->dst_nents + 2]; 844 edesc->dst_nents + 2 +
845 edesc->assoc_nents];
833 sg = sg_last(areq->dst, edesc->dst_nents); 846 sg = sg_last(areq->dst, edesc->dst_nents);
834 memcpy((char *)sg_virt(sg) + sg->length - ctx->authsize, 847 memcpy((char *)sg_virt(sg) + sg->length - ctx->authsize,
835 icvdata, ctx->authsize); 848 icvdata, ctx->authsize);
@@ -859,7 +872,8 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev,
859 /* auth check */ 872 /* auth check */
860 if (edesc->dma_len) 873 if (edesc->dma_len)
861 icvdata = &edesc->link_tbl[edesc->src_nents + 874 icvdata = &edesc->link_tbl[edesc->src_nents +
862 edesc->dst_nents + 2]; 875 edesc->dst_nents + 2 +
876 edesc->assoc_nents];
863 else 877 else
864 icvdata = &edesc->link_tbl[0]; 878 icvdata = &edesc->link_tbl[0];
865 879
@@ -934,10 +948,9 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
934 * fill in and submit ipsec_esp descriptor 948 * fill in and submit ipsec_esp descriptor
935 */ 949 */
936static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, 950static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
937 u8 *giv, u64 seq, 951 u64 seq, void (*callback) (struct device *dev,
938 void (*callback) (struct device *dev, 952 struct talitos_desc *desc,
939 struct talitos_desc *desc, 953 void *context, int error))
940 void *context, int error))
941{ 954{
942 struct crypto_aead *aead = crypto_aead_reqtfm(areq); 955 struct crypto_aead *aead = crypto_aead_reqtfm(areq);
943 struct talitos_ctx *ctx = crypto_aead_ctx(aead); 956 struct talitos_ctx *ctx = crypto_aead_ctx(aead);
@@ -952,12 +965,42 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
952 /* hmac key */ 965 /* hmac key */
953 map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key, 966 map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key,
954 0, DMA_TO_DEVICE); 967 0, DMA_TO_DEVICE);
968
955 /* hmac data */ 969 /* hmac data */
956 map_single_talitos_ptr(dev, &desc->ptr[1], areq->assoclen + ivsize, 970 desc->ptr[1].len = cpu_to_be16(areq->assoclen + ivsize);
957 sg_virt(areq->assoc), 0, DMA_TO_DEVICE); 971 if (edesc->assoc_nents) {
972 int tbl_off = edesc->src_nents + edesc->dst_nents + 2;
973 struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off];
974
975 to_talitos_ptr(&desc->ptr[1], edesc->dma_link_tbl + tbl_off *
976 sizeof(struct talitos_ptr));
977 desc->ptr[1].j_extent = DESC_PTR_LNKTBL_JUMP;
978
979 /* assoc_nents - 1 entries for assoc, 1 for IV */
980 sg_count = sg_to_link_tbl(areq->assoc, edesc->assoc_nents - 1,
981 areq->assoclen, tbl_ptr);
982
983 /* add IV to link table */
984 tbl_ptr += sg_count - 1;
985 tbl_ptr->j_extent = 0;
986 tbl_ptr++;
987 to_talitos_ptr(tbl_ptr, edesc->iv_dma);
988 tbl_ptr->len = cpu_to_be16(ivsize);
989 tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN;
990
991 dma_sync_single_for_device(dev, edesc->dma_link_tbl,
992 edesc->dma_len, DMA_BIDIRECTIONAL);
993 } else {
994 to_talitos_ptr(&desc->ptr[1], sg_dma_address(areq->assoc));
995 desc->ptr[1].j_extent = 0;
996 }
997
958 /* cipher iv */ 998 /* cipher iv */
959 map_single_talitos_ptr(dev, &desc->ptr[2], ivsize, giv ?: areq->iv, 0, 999 to_talitos_ptr(&desc->ptr[2], edesc->iv_dma);
960 DMA_TO_DEVICE); 1000 desc->ptr[2].len = cpu_to_be16(ivsize);
1001 desc->ptr[2].j_extent = 0;
1002 /* Sync needed for the aead_givencrypt case */
1003 dma_sync_single_for_device(dev, edesc->iv_dma, ivsize, DMA_TO_DEVICE);
961 1004
962 /* cipher key */ 1005 /* cipher key */
963 map_single_talitos_ptr(dev, &desc->ptr[3], ctx->enckeylen, 1006 map_single_talitos_ptr(dev, &desc->ptr[3], ctx->enckeylen,
@@ -1013,26 +1056,25 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
1013 if (sg_count == 1) { 1056 if (sg_count == 1) {
1014 to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst)); 1057 to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst));
1015 } else { 1058 } else {
1016 struct talitos_ptr *link_tbl_ptr = 1059 int tbl_off = edesc->src_nents + 1;
1017 &edesc->link_tbl[edesc->src_nents + 1]; 1060 struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off];
1018 1061
1019 to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl + 1062 to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl +
1020 (edesc->src_nents + 1) * 1063 tbl_off * sizeof(struct talitos_ptr));
1021 sizeof(struct talitos_ptr));
1022 sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen, 1064 sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen,
1023 link_tbl_ptr); 1065 tbl_ptr);
1024 1066
1025 /* Add an entry to the link table for ICV data */ 1067 /* Add an entry to the link table for ICV data */
1026 link_tbl_ptr += sg_count - 1; 1068 tbl_ptr += sg_count - 1;
1027 link_tbl_ptr->j_extent = 0; 1069 tbl_ptr->j_extent = 0;
1028 sg_count++; 1070 tbl_ptr++;
1029 link_tbl_ptr++; 1071 tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN;
1030 link_tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN; 1072 tbl_ptr->len = cpu_to_be16(authsize);
1031 link_tbl_ptr->len = cpu_to_be16(authsize);
1032 1073
1033 /* icv data follows link tables */ 1074 /* icv data follows link tables */
1034 to_talitos_ptr(link_tbl_ptr, edesc->dma_link_tbl + 1075 to_talitos_ptr(tbl_ptr, edesc->dma_link_tbl +
1035 (edesc->src_nents + edesc->dst_nents + 2) * 1076 (tbl_off + edesc->dst_nents + 1 +
1077 edesc->assoc_nents) *
1036 sizeof(struct talitos_ptr)); 1078 sizeof(struct talitos_ptr));
1037 desc->ptr[5].j_extent |= DESC_PTR_LNKTBL_JUMP; 1079 desc->ptr[5].j_extent |= DESC_PTR_LNKTBL_JUMP;
1038 dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl, 1080 dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl,
@@ -1133,16 +1175,21 @@ static size_t sg_copy_end_to_buffer(struct scatterlist *sgl, unsigned int nents,
1133 * allocate and map the extended descriptor 1175 * allocate and map the extended descriptor
1134 */ 1176 */
1135static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, 1177static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1178 struct scatterlist *assoc,
1136 struct scatterlist *src, 1179 struct scatterlist *src,
1137 struct scatterlist *dst, 1180 struct scatterlist *dst,
1181 u8 *iv,
1182 unsigned int assoclen,
1138 unsigned int cryptlen, 1183 unsigned int cryptlen,
1139 unsigned int authsize, 1184 unsigned int authsize,
1185 unsigned int ivsize,
1140 int icv_stashing, 1186 int icv_stashing,
1141 u32 cryptoflags) 1187 u32 cryptoflags)
1142{ 1188{
1143 struct talitos_edesc *edesc; 1189 struct talitos_edesc *edesc;
1144 int src_nents, dst_nents, alloc_len, dma_len; 1190 int assoc_nents = 0, src_nents, dst_nents, alloc_len, dma_len;
1145 bool src_chained, dst_chained = false; 1191 bool assoc_chained = false, src_chained = false, dst_chained = false;
1192 dma_addr_t iv_dma = 0;
1146 gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : 1193 gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
1147 GFP_ATOMIC; 1194 GFP_ATOMIC;
1148 1195
@@ -1151,6 +1198,25 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1151 return ERR_PTR(-EINVAL); 1198 return ERR_PTR(-EINVAL);
1152 } 1199 }
1153 1200
1201 if (iv)
1202 iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE);
1203
1204 if (assoc) {
1205 /*
1206 * Currently it is assumed that iv is provided whenever assoc
1207 * is.
1208 */
1209 BUG_ON(!iv);
1210
1211 assoc_nents = sg_count(assoc, assoclen, &assoc_chained);
1212 talitos_map_sg(dev, assoc, assoc_nents, DMA_TO_DEVICE,
1213 assoc_chained);
1214 assoc_nents = (assoc_nents == 1) ? 0 : assoc_nents;
1215
1216 if (assoc_nents || sg_dma_address(assoc) + assoclen != iv_dma)
1217 assoc_nents = assoc_nents ? assoc_nents + 1 : 2;
1218 }
1219
1154 src_nents = sg_count(src, cryptlen + authsize, &src_chained); 1220 src_nents = sg_count(src, cryptlen + authsize, &src_chained);
1155 src_nents = (src_nents == 1) ? 0 : src_nents; 1221 src_nents = (src_nents == 1) ? 0 : src_nents;
1156 1222
@@ -1172,9 +1238,9 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1172 * and the ICV data itself 1238 * and the ICV data itself
1173 */ 1239 */
1174 alloc_len = sizeof(struct talitos_edesc); 1240 alloc_len = sizeof(struct talitos_edesc);
1175 if (src_nents || dst_nents) { 1241 if (assoc_nents || src_nents || dst_nents) {
1176 dma_len = (src_nents + dst_nents + 2) * 1242 dma_len = (src_nents + dst_nents + 2 + assoc_nents) *
1177 sizeof(struct talitos_ptr) + authsize; 1243 sizeof(struct talitos_ptr) + authsize;
1178 alloc_len += dma_len; 1244 alloc_len += dma_len;
1179 } else { 1245 } else {
1180 dma_len = 0; 1246 dma_len = 0;
@@ -1183,14 +1249,20 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1183 1249
1184 edesc = kmalloc(alloc_len, GFP_DMA | flags); 1250 edesc = kmalloc(alloc_len, GFP_DMA | flags);
1185 if (!edesc) { 1251 if (!edesc) {
1252 talitos_unmap_sg_chain(dev, assoc, DMA_TO_DEVICE);
1253 if (iv_dma)
1254 dma_unmap_single(dev, iv_dma, ivsize, DMA_TO_DEVICE);
1186 dev_err(dev, "could not allocate edescriptor\n"); 1255 dev_err(dev, "could not allocate edescriptor\n");
1187 return ERR_PTR(-ENOMEM); 1256 return ERR_PTR(-ENOMEM);
1188 } 1257 }
1189 1258
1259 edesc->assoc_nents = assoc_nents;
1190 edesc->src_nents = src_nents; 1260 edesc->src_nents = src_nents;
1191 edesc->dst_nents = dst_nents; 1261 edesc->dst_nents = dst_nents;
1262 edesc->assoc_chained = assoc_chained;
1192 edesc->src_chained = src_chained; 1263 edesc->src_chained = src_chained;
1193 edesc->dst_chained = dst_chained; 1264 edesc->dst_chained = dst_chained;
1265 edesc->iv_dma = iv_dma;
1194 edesc->dma_len = dma_len; 1266 edesc->dma_len = dma_len;
1195 if (dma_len) 1267 if (dma_len)
1196 edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0], 1268 edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0],
@@ -1200,14 +1272,16 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1200 return edesc; 1272 return edesc;
1201} 1273}
1202 1274
1203static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, 1275static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv,
1204 int icv_stashing) 1276 int icv_stashing)
1205{ 1277{
1206 struct crypto_aead *authenc = crypto_aead_reqtfm(areq); 1278 struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
1207 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 1279 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
1280 unsigned int ivsize = crypto_aead_ivsize(authenc);
1208 1281
1209 return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, 1282 return talitos_edesc_alloc(ctx->dev, areq->assoc, areq->src, areq->dst,
1210 areq->cryptlen, ctx->authsize, icv_stashing, 1283 iv, areq->assoclen, areq->cryptlen,
1284 ctx->authsize, ivsize, icv_stashing,
1211 areq->base.flags); 1285 areq->base.flags);
1212} 1286}
1213 1287
@@ -1218,14 +1292,14 @@ static int aead_encrypt(struct aead_request *req)
1218 struct talitos_edesc *edesc; 1292 struct talitos_edesc *edesc;
1219 1293
1220 /* allocate extended descriptor */ 1294 /* allocate extended descriptor */
1221 edesc = aead_edesc_alloc(req, 0); 1295 edesc = aead_edesc_alloc(req, req->iv, 0);
1222 if (IS_ERR(edesc)) 1296 if (IS_ERR(edesc))
1223 return PTR_ERR(edesc); 1297 return PTR_ERR(edesc);
1224 1298
1225 /* set encrypt */ 1299 /* set encrypt */
1226 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT; 1300 edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT;
1227 1301
1228 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_encrypt_done); 1302 return ipsec_esp(edesc, req, 0, ipsec_esp_encrypt_done);
1229} 1303}
1230 1304
1231static int aead_decrypt(struct aead_request *req) 1305static int aead_decrypt(struct aead_request *req)
@@ -1241,7 +1315,7 @@ static int aead_decrypt(struct aead_request *req)
1241 req->cryptlen -= authsize; 1315 req->cryptlen -= authsize;
1242 1316
1243 /* allocate extended descriptor */ 1317 /* allocate extended descriptor */
1244 edesc = aead_edesc_alloc(req, 1); 1318 edesc = aead_edesc_alloc(req, req->iv, 1);
1245 if (IS_ERR(edesc)) 1319 if (IS_ERR(edesc))
1246 return PTR_ERR(edesc); 1320 return PTR_ERR(edesc);
1247 1321
@@ -1257,9 +1331,7 @@ static int aead_decrypt(struct aead_request *req)
1257 /* reset integrity check result bits */ 1331 /* reset integrity check result bits */
1258 edesc->desc.hdr_lo = 0; 1332 edesc->desc.hdr_lo = 0;
1259 1333
1260 return ipsec_esp(edesc, req, NULL, 0, 1334 return ipsec_esp(edesc, req, 0, ipsec_esp_decrypt_hwauth_done);
1261 ipsec_esp_decrypt_hwauth_done);
1262
1263 } 1335 }
1264 1336
1265 /* Have to check the ICV with software */ 1337 /* Have to check the ICV with software */
@@ -1268,7 +1340,8 @@ static int aead_decrypt(struct aead_request *req)
1268 /* stash incoming ICV for later cmp with ICV generated by the h/w */ 1340 /* stash incoming ICV for later cmp with ICV generated by the h/w */
1269 if (edesc->dma_len) 1341 if (edesc->dma_len)
1270 icvdata = &edesc->link_tbl[edesc->src_nents + 1342 icvdata = &edesc->link_tbl[edesc->src_nents +
1271 edesc->dst_nents + 2]; 1343 edesc->dst_nents + 2 +
1344 edesc->assoc_nents];
1272 else 1345 else
1273 icvdata = &edesc->link_tbl[0]; 1346 icvdata = &edesc->link_tbl[0];
1274 1347
@@ -1277,7 +1350,7 @@ static int aead_decrypt(struct aead_request *req)
1277 memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize, 1350 memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize,
1278 ctx->authsize); 1351 ctx->authsize);
1279 1352
1280 return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_swauth_done); 1353 return ipsec_esp(edesc, req, 0, ipsec_esp_decrypt_swauth_done);
1281} 1354}
1282 1355
1283static int aead_givencrypt(struct aead_givcrypt_request *req) 1356static int aead_givencrypt(struct aead_givcrypt_request *req)
@@ -1288,7 +1361,7 @@ static int aead_givencrypt(struct aead_givcrypt_request *req)
1288 struct talitos_edesc *edesc; 1361 struct talitos_edesc *edesc;
1289 1362
1290 /* allocate extended descriptor */ 1363 /* allocate extended descriptor */
1291 edesc = aead_edesc_alloc(areq, 0); 1364 edesc = aead_edesc_alloc(areq, req->giv, 0);
1292 if (IS_ERR(edesc)) 1365 if (IS_ERR(edesc))
1293 return PTR_ERR(edesc); 1366 return PTR_ERR(edesc);
1294 1367
@@ -1299,8 +1372,7 @@ static int aead_givencrypt(struct aead_givcrypt_request *req)
1299 /* avoid consecutive packets going out with same IV */ 1372 /* avoid consecutive packets going out with same IV */
1300 *(__be64 *)req->giv ^= cpu_to_be64(req->seq); 1373 *(__be64 *)req->giv ^= cpu_to_be64(req->seq);
1301 1374
1302 return ipsec_esp(edesc, areq, req->giv, req->seq, 1375 return ipsec_esp(edesc, areq, req->seq, ipsec_esp_encrypt_done);
1303 ipsec_esp_encrypt_done);
1304} 1376}
1305 1377
1306static int ablkcipher_setkey(struct crypto_ablkcipher *cipher, 1378static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
@@ -1356,7 +1428,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
1356 struct device *dev = ctx->dev; 1428 struct device *dev = ctx->dev;
1357 struct talitos_desc *desc = &edesc->desc; 1429 struct talitos_desc *desc = &edesc->desc;
1358 unsigned int cryptlen = areq->nbytes; 1430 unsigned int cryptlen = areq->nbytes;
1359 unsigned int ivsize; 1431 unsigned int ivsize = crypto_ablkcipher_ivsize(cipher);
1360 int sg_count, ret; 1432 int sg_count, ret;
1361 1433
1362 /* first DWORD empty */ 1434 /* first DWORD empty */
@@ -1365,9 +1437,9 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
1365 desc->ptr[0].j_extent = 0; 1437 desc->ptr[0].j_extent = 0;
1366 1438
1367 /* cipher iv */ 1439 /* cipher iv */
1368 ivsize = crypto_ablkcipher_ivsize(cipher); 1440 to_talitos_ptr(&desc->ptr[1], edesc->iv_dma);
1369 map_single_talitos_ptr(dev, &desc->ptr[1], ivsize, areq->info, 0, 1441 desc->ptr[1].len = cpu_to_be16(ivsize);
1370 DMA_TO_DEVICE); 1442 desc->ptr[1].j_extent = 0;
1371 1443
1372 /* cipher key */ 1444 /* cipher key */
1373 map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen, 1445 map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen,
@@ -1449,9 +1521,11 @@ static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request *
1449{ 1521{
1450 struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); 1522 struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
1451 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); 1523 struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
1524 unsigned int ivsize = crypto_ablkcipher_ivsize(cipher);
1452 1525
1453 return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, areq->nbytes, 1526 return talitos_edesc_alloc(ctx->dev, NULL, areq->src, areq->dst,
1454 0, 0, areq->base.flags); 1527 areq->info, 0, areq->nbytes, 0, ivsize, 0,
1528 areq->base.flags);
1455} 1529}
1456 1530
1457static int ablkcipher_encrypt(struct ablkcipher_request *areq) 1531static int ablkcipher_encrypt(struct ablkcipher_request *areq)
@@ -1629,8 +1703,8 @@ static struct talitos_edesc *ahash_edesc_alloc(struct ahash_request *areq,
1629 struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); 1703 struct talitos_ctx *ctx = crypto_ahash_ctx(tfm);
1630 struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); 1704 struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
1631 1705
1632 return talitos_edesc_alloc(ctx->dev, req_ctx->psrc, NULL, nbytes, 0, 0, 1706 return talitos_edesc_alloc(ctx->dev, NULL, req_ctx->psrc, NULL, NULL, 0,
1633 areq->base.flags); 1707 nbytes, 0, 0, 0, areq->base.flags);
1634} 1708}
1635 1709
1636static int ahash_init(struct ahash_request *areq) 1710static int ahash_init(struct ahash_request *areq)