24 #include <crypto/aes.h>
25 #include <crypto/sha.h>
28 #include <linux/module.h>
30 #include <linux/types.h>
34 #include <linux/device.h>
55 struct vio_pfo_op *
op,
65 }
while ((rc == -
EBUSY && !may_sleep && retries--) ||
69 dev_dbg(&viodev->
dev,
"vio_h_cop_sync failed: rc: %d "
70 "hcall rc: %ld\n", rc, op->hcall_err);
98 unsigned int sg_len = 0;
100 u64 sg_addr = (
u64)start_addr;
105 if (is_vmalloc_addr(start_addr))
109 sg_addr =
__pa(sg_addr);
111 end_addr = sg_addr +
len;
119 for (sg = sg_head; sg_len <
len; sg++) {
125 if ((sg - sg_head) == sgmax) {
126 pr_err(
"nx: scatter/gather list overflow, pid: %d\n",
149 unsigned int src_len)
160 if (start < offset + sg_src->
length)
164 sg_src = scatterwalk_sg_next(sg_src);
169 scatterwalk_advance(&walk, start - offset);
171 while (
len && nx_sg) {
172 n = scatterwalk_clamp(&walk,
len);
175 n = scatterwalk_clamp(&walk,
len);
182 scatterwalk_unmap(dst);
183 scatterwalk_advance(&walk, n);
218 blkcipher_walk_init(&walk, dst, src, nbytes);
249 nx_ctx->
op.inlen = (nx_ctx->
in_sg - nx_insg) *
sizeof(
struct nx_sg);
250 nx_ctx->
op.outlen = (nx_ctx->
out_sg - nx_outsg) *
sizeof(
struct nx_sg);
266 nx_ctx->
op.flags =
function;
274 nx_ctx->
op_aead.flags =
function;
281 static void nx_of_update_status(
struct device *
dev,
289 dev_info(dev,
"%s: status '%s' is not 'okay'\n", __func__,
294 static void nx_of_update_sglen(
struct device *dev,
299 dev_err(dev,
"%s: unexpected format for "
300 "ibm,max-sg-len property\n", __func__);
301 dev_dbg(dev,
"%s: ibm,max-sg-len is %d bytes "
302 "long, expected %zd bytes\n", __func__,
311 static void nx_of_update_msc(
struct device *dev,
317 unsigned int bytes_so_far,
i, lenp;
328 while ((bytes_so_far +
sizeof(
struct max_sync_cop)) <= lenp) {
334 ((bytes_so_far +
sizeof(
struct msc_triplet)) <= lenp) &&
338 dev_err(dev,
"unknown function code/mode "
339 "combo: %d/%d (ignored)\n", msc->
fc,
347 props->
ap[msc->
fc][msc->
mode][0].databytelen =
349 props->
ap[msc->
fc][msc->
mode][0].sglen =
353 props->
ap[msc->
fc][msc->
mode][1].databytelen =
355 props->
ap[msc->
fc][msc->
mode][1].sglen =
362 props->
ap[msc->
fc][msc->
mode][2].sglen =
368 props->
ap[msc->
fc][msc->
mode][1].sglen =
372 "code/key bit len combo"
373 ": (%u/256)\n", msc->
fc);
377 props->
ap[msc->
fc][msc->
mode][2].databytelen =
379 props->
ap[msc->
fc][msc->
mode][2].sglen =
383 dev_warn(dev,
"unknown function code/key bit "
384 "len combo: (%u/%u)\n", msc->
fc,
410 static void nx_of_init(
struct device *dev,
struct nx_of *props)
417 dev_info(dev,
"%s: property 'status' not found\n", __func__);
419 nx_of_update_status(dev, p, props);
423 dev_info(dev,
"%s: property 'ibm,max-sg-len' not found\n",
426 nx_of_update_sglen(dev, p, props);
430 dev_info(dev,
"%s: property 'ibm,max-sync-cop' not found\n",
433 nx_of_update_msc(dev, p, props);
445 static int nx_register_algs(
void)
476 goto out_unreg_ctr3686;
484 goto out_unreg_gcm4106;
492 goto out_unreg_ccm4309;
540 pr_err(
"Attempt to initialize NX crypto context while device "
541 "is not available!\n");
580 return nx_crypto_ctx_init(crypto_tfm_ctx(tfm),
NX_FC_AES,
586 return nx_crypto_ctx_init(crypto_tfm_ctx(tfm),
NX_FC_AES,
592 return nx_crypto_ctx_init(crypto_tfm_ctx(tfm),
NX_FC_AES,
598 return nx_crypto_ctx_init(crypto_tfm_ctx(tfm),
NX_FC_AES,
604 return nx_crypto_ctx_init(crypto_tfm_ctx(tfm),
NX_FC_AES,
615 return nx_crypto_ctx_init(crypto_tfm_ctx(tfm),
NX_FC_AES,
641 dev_dbg(&viodev->
dev,
"driver probed: %s resource id: 0x%x\n",
642 viodev->name, viodev->resource_id);
645 dev_err(&viodev->
dev,
"%s: Attempt to register more than one "
646 "instance of the hardware\n", __func__);
654 return nx_register_algs();
659 dev_dbg(&viodev->
dev,
"entering nx_remove for UA 0x%x\n",
660 viodev->unit_address);
683 static int __init nx_init(
void)
688 static void __exit nx_fini(
void)
694 {
"ibm,sym-encryption-v1",
"ibm,sym-encryption" },
702 .id_table = nx_crypto_driver_ids,