| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2016 Broadcom |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License, version 2, as |
|---|
| 6 | | - * published by the Free Software Foundation (the "GPL"). |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 9 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 11 | | - * General Public License version 2 (GPLv2) for more details. |
|---|
| 12 | | - * |
|---|
| 13 | | - * You should have received a copy of the GNU General Public License |
|---|
| 14 | | - * version 2 (GPLv2) along with this source code. |
|---|
| 15 | 4 | */ |
|---|
| 16 | 5 | |
|---|
| 17 | 6 | #include <linux/debugfs.h> |
|---|
| .. | .. |
|---|
| 201 | 190 | char ctx[]; |
|---|
| 202 | 191 | }; |
|---|
| 203 | 192 | |
|---|
| 204 | | -/* do a synchronous decrypt operation */ |
|---|
| 205 | | -int do_decrypt(char *alg_name, |
|---|
| 206 | | - void *key_ptr, unsigned int key_len, |
|---|
| 207 | | - void *iv_ptr, void *src_ptr, void *dst_ptr, |
|---|
| 208 | | - unsigned int block_len) |
|---|
| 209 | | -{ |
|---|
| 210 | | - struct scatterlist sg_in[1], sg_out[1]; |
|---|
| 211 | | - struct crypto_blkcipher *tfm = |
|---|
| 212 | | - crypto_alloc_blkcipher(alg_name, 0, CRYPTO_ALG_ASYNC); |
|---|
| 213 | | - struct blkcipher_desc desc = {.tfm = tfm, .flags = 0 }; |
|---|
| 214 | | - int ret = 0; |
|---|
| 215 | | - void *iv; |
|---|
| 216 | | - int ivsize; |
|---|
| 217 | | - |
|---|
| 218 | | - flow_log("%s() name:%s block_len:%u\n", __func__, alg_name, block_len); |
|---|
| 219 | | - |
|---|
| 220 | | - if (IS_ERR(tfm)) |
|---|
| 221 | | - return PTR_ERR(tfm); |
|---|
| 222 | | - |
|---|
| 223 | | - crypto_blkcipher_setkey((void *)tfm, key_ptr, key_len); |
|---|
| 224 | | - |
|---|
| 225 | | - sg_init_table(sg_in, 1); |
|---|
| 226 | | - sg_set_buf(sg_in, src_ptr, block_len); |
|---|
| 227 | | - |
|---|
| 228 | | - sg_init_table(sg_out, 1); |
|---|
| 229 | | - sg_set_buf(sg_out, dst_ptr, block_len); |
|---|
| 230 | | - |
|---|
| 231 | | - iv = crypto_blkcipher_crt(tfm)->iv; |
|---|
| 232 | | - ivsize = crypto_blkcipher_ivsize(tfm); |
|---|
| 233 | | - memcpy(iv, iv_ptr, ivsize); |
|---|
| 234 | | - |
|---|
| 235 | | - ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in, block_len); |
|---|
| 236 | | - crypto_free_blkcipher(tfm); |
|---|
| 237 | | - |
|---|
| 238 | | - if (ret < 0) |
|---|
| 239 | | - pr_err("aes_decrypt failed %d\n", ret); |
|---|
| 240 | | - |
|---|
| 241 | | - return ret; |
|---|
| 242 | | -} |
|---|
| 243 | | - |
|---|
| 244 | 193 | /** |
|---|
| 245 | 194 | * do_shash() - Do a synchronous hash operation in software |
|---|
| 246 | 195 | * @name: The name of the hash algorithm |
|---|
| .. | .. |
|---|
| 282 | 231 | goto do_shash_err; |
|---|
| 283 | 232 | } |
|---|
| 284 | 233 | sdesc->shash.tfm = hash; |
|---|
| 285 | | - sdesc->shash.flags = 0x0; |
|---|
| 286 | 234 | |
|---|
| 287 | 235 | if (key_len > 0) { |
|---|
| 288 | 236 | rc = crypto_shash_setkey(hash, key, key_len); |
|---|
| .. | .. |
|---|
| 418 | 366 | |
|---|
| 419 | 367 | ipriv = filp->private_data; |
|---|
| 420 | 368 | out_offset = 0; |
|---|
| 421 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 369 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 422 | 370 | "Number of SPUs.........%u\n", |
|---|
| 423 | 371 | ipriv->spu.num_spu); |
|---|
| 424 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 372 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 425 | 373 | "Current sessions.......%u\n", |
|---|
| 426 | 374 | atomic_read(&ipriv->session_count)); |
|---|
| 427 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 375 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 428 | 376 | "Session count..........%u\n", |
|---|
| 429 | 377 | atomic_read(&ipriv->stream_count)); |
|---|
| 430 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 378 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 431 | 379 | "Cipher setkey..........%u\n", |
|---|
| 432 | 380 | atomic_read(&ipriv->setkey_cnt[SPU_OP_CIPHER])); |
|---|
| 433 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 381 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 434 | 382 | "Cipher Ops.............%u\n", |
|---|
| 435 | 383 | atomic_read(&ipriv->op_counts[SPU_OP_CIPHER])); |
|---|
| 436 | 384 | for (alg = 0; alg < CIPHER_ALG_LAST; alg++) { |
|---|
| 437 | 385 | for (mode = 0; mode < CIPHER_MODE_LAST; mode++) { |
|---|
| 438 | 386 | op_cnt = atomic_read(&ipriv->cipher_cnt[alg][mode]); |
|---|
| 439 | 387 | if (op_cnt) { |
|---|
| 440 | | - out_offset += snprintf(buf + out_offset, |
|---|
| 388 | + out_offset += scnprintf(buf + out_offset, |
|---|
| 441 | 389 | out_count - out_offset, |
|---|
| 442 | 390 | " %-13s%11u\n", |
|---|
| 443 | 391 | spu_alg_name(alg, mode), op_cnt); |
|---|
| 444 | 392 | } |
|---|
| 445 | 393 | } |
|---|
| 446 | 394 | } |
|---|
| 447 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 395 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 448 | 396 | "Hash Ops...............%u\n", |
|---|
| 449 | 397 | atomic_read(&ipriv->op_counts[SPU_OP_HASH])); |
|---|
| 450 | 398 | for (alg = 0; alg < HASH_ALG_LAST; alg++) { |
|---|
| 451 | 399 | op_cnt = atomic_read(&ipriv->hash_cnt[alg]); |
|---|
| 452 | 400 | if (op_cnt) { |
|---|
| 453 | | - out_offset += snprintf(buf + out_offset, |
|---|
| 401 | + out_offset += scnprintf(buf + out_offset, |
|---|
| 454 | 402 | out_count - out_offset, |
|---|
| 455 | 403 | " %-13s%11u\n", |
|---|
| 456 | 404 | hash_alg_name[alg], op_cnt); |
|---|
| 457 | 405 | } |
|---|
| 458 | 406 | } |
|---|
| 459 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 407 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 460 | 408 | "HMAC setkey............%u\n", |
|---|
| 461 | 409 | atomic_read(&ipriv->setkey_cnt[SPU_OP_HMAC])); |
|---|
| 462 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 410 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 463 | 411 | "HMAC Ops...............%u\n", |
|---|
| 464 | 412 | atomic_read(&ipriv->op_counts[SPU_OP_HMAC])); |
|---|
| 465 | 413 | for (alg = 0; alg < HASH_ALG_LAST; alg++) { |
|---|
| 466 | 414 | op_cnt = atomic_read(&ipriv->hmac_cnt[alg]); |
|---|
| 467 | 415 | if (op_cnt) { |
|---|
| 468 | | - out_offset += snprintf(buf + out_offset, |
|---|
| 416 | + out_offset += scnprintf(buf + out_offset, |
|---|
| 469 | 417 | out_count - out_offset, |
|---|
| 470 | 418 | " %-13s%11u\n", |
|---|
| 471 | 419 | hash_alg_name[alg], op_cnt); |
|---|
| 472 | 420 | } |
|---|
| 473 | 421 | } |
|---|
| 474 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 422 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 475 | 423 | "AEAD setkey............%u\n", |
|---|
| 476 | 424 | atomic_read(&ipriv->setkey_cnt[SPU_OP_AEAD])); |
|---|
| 477 | 425 | |
|---|
| 478 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 426 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 479 | 427 | "AEAD Ops...............%u\n", |
|---|
| 480 | 428 | atomic_read(&ipriv->op_counts[SPU_OP_AEAD])); |
|---|
| 481 | 429 | for (alg = 0; alg < AEAD_TYPE_LAST; alg++) { |
|---|
| 482 | 430 | op_cnt = atomic_read(&ipriv->aead_cnt[alg]); |
|---|
| 483 | 431 | if (op_cnt) { |
|---|
| 484 | | - out_offset += snprintf(buf + out_offset, |
|---|
| 432 | + out_offset += scnprintf(buf + out_offset, |
|---|
| 485 | 433 | out_count - out_offset, |
|---|
| 486 | 434 | " %-13s%11u\n", |
|---|
| 487 | 435 | aead_alg_name[alg], op_cnt); |
|---|
| 488 | 436 | } |
|---|
| 489 | 437 | } |
|---|
| 490 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 438 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 491 | 439 | "Bytes of req data......%llu\n", |
|---|
| 492 | 440 | (u64)atomic64_read(&ipriv->bytes_out)); |
|---|
| 493 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 441 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 494 | 442 | "Bytes of resp data.....%llu\n", |
|---|
| 495 | 443 | (u64)atomic64_read(&ipriv->bytes_in)); |
|---|
| 496 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 444 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 497 | 445 | "Mailbox full...........%u\n", |
|---|
| 498 | 446 | atomic_read(&ipriv->mb_no_spc)); |
|---|
| 499 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 447 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 500 | 448 | "Mailbox send failures..%u\n", |
|---|
| 501 | 449 | atomic_read(&ipriv->mb_send_fail)); |
|---|
| 502 | | - out_offset += snprintf(buf + out_offset, out_count - out_offset, |
|---|
| 450 | + out_offset += scnprintf(buf + out_offset, out_count - out_offset, |
|---|
| 503 | 451 | "Check ICV errors.......%u\n", |
|---|
| 504 | 452 | atomic_read(&ipriv->bad_icv)); |
|---|
| 505 | 453 | if (ipriv->spu.spu_type == SPU_TYPE_SPUM) |
|---|
| .. | .. |
|---|
| 507 | 455 | spu_ofifo_ctrl = ioread32(ipriv->spu.reg_vbase[i] + |
|---|
| 508 | 456 | SPU_OFIFO_CTRL); |
|---|
| 509 | 457 | fifo_len = spu_ofifo_ctrl & SPU_FIFO_WATERMARK; |
|---|
| 510 | | - out_offset += snprintf(buf + out_offset, |
|---|
| 458 | + out_offset += scnprintf(buf + out_offset, |
|---|
| 511 | 459 | out_count - out_offset, |
|---|
| 512 | 460 | "SPU %d output FIFO high water.....%u\n", |
|---|
| 513 | 461 | i, fifo_len); |
|---|