| 392 | /* >8 End of crypto enqueue. */ |
| 393 | |
| 394 | static int |
| 395 | l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, |
| 396 | struct rte_crypto_op *op, |
| 397 | struct l2fwd_crypto_params *cparams) |
| 398 | { |
| 399 | struct rte_ether_hdr *eth_hdr; |
| 400 | struct rte_ipv4_hdr *ip_hdr; |
| 401 | |
| 402 | uint32_t ipdata_offset, data_len; |
| 403 | uint32_t pad_len = 0; |
| 404 | char *padding; |
| 405 | |
| 406 | eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); |
| 407 | |
| 408 | if (eth_hdr->ether_type != rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) |
| 409 | return -1; |
| 410 | |
| 411 | ipdata_offset = sizeof(struct rte_ether_hdr); |
| 412 | |
| 413 | ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) + |
| 414 | ipdata_offset); |
| 415 | |
| 416 | ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK) |
| 417 | * RTE_IPV4_IHL_MULTIPLIER; |
| 418 | |
| 419 | |
| 420 | /* Zero pad data to be crypto'd so it is block aligned */ |
| 421 | data_len = rte_pktmbuf_data_len(m) - ipdata_offset; |
| 422 | |
| 423 | if ((cparams->do_hash || cparams->do_aead) && cparams->hash_verify) |
| 424 | data_len -= cparams->digest_length; |
| 425 | |
| 426 | if (cparams->do_cipher) { |
| 427 | /* |
| 428 | * Following algorithms are block cipher algorithms, |
| 429 | * and might need padding |
| 430 | */ |
| 431 | switch (cparams->cipher_algo) { |
| 432 | case RTE_CRYPTO_CIPHER_AES_CBC: |
| 433 | case RTE_CRYPTO_CIPHER_AES_ECB: |
| 434 | case RTE_CRYPTO_CIPHER_DES_CBC: |
| 435 | case RTE_CRYPTO_CIPHER_3DES_CBC: |
| 436 | case RTE_CRYPTO_CIPHER_3DES_ECB: |
| 437 | if (data_len % cparams->block_size) |
| 438 | pad_len = cparams->block_size - |
| 439 | (data_len % cparams->block_size); |
| 440 | break; |
| 441 | case RTE_CRYPTO_CIPHER_AES_XTS: |
| 442 | if (cparams->cipher_dataunit_len != 0 && |
| 443 | (data_len % cparams->cipher_dataunit_len)) |
| 444 | pad_len = cparams->cipher_dataunit_len - |
| 445 | (data_len % cparams->cipher_dataunit_len); |
| 446 | break; |
| 447 | default: |
| 448 | pad_len = 0; |
| 449 | } |
| 450 | |
| 451 | if (pad_len) { |
no test coverage detected