crypto/octeontx: add session management operations
[dpdk.git] / drivers / common / cpt / cpt_ucode.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Cavium, Inc
3  */
4
5 #ifndef _CPT_UCODE_H_
6 #define _CPT_UCODE_H_
7
8 #include "cpt_mcode_defines.h"
9
10 /*
11  * This file defines functions that are interfaces to microcode spec.
12  *
13  */
14
15 static __rte_always_inline int
16 cpt_is_algo_supported(struct rte_crypto_sym_xform *xform)
17 {
18         /*
19          * Microcode only supports the following combination.
20          * Encryption followed by authentication
21          * Authentication followed by decryption
22          */
23         if (xform->next) {
24                 if ((xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) &&
25                     (xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER) &&
26                     (xform->next->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)) {
27                         /* Unsupported as of now by microcode */
28                         CPT_LOG_DP_ERR("Unsupported combination");
29                         return -1;
30                 }
31                 if ((xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) &&
32                     (xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH) &&
33                     (xform->cipher.op == RTE_CRYPTO_CIPHER_OP_DECRYPT)) {
34                         /* For GMAC auth there is no cipher operation */
35                         if (xform->aead.algo != RTE_CRYPTO_AEAD_AES_GCM ||
36                             xform->next->auth.algo !=
37                             RTE_CRYPTO_AUTH_AES_GMAC) {
38                                 /* Unsupported as of now by microcode */
39                                 CPT_LOG_DP_ERR("Unsupported combination");
40                                 return -1;
41                         }
42                 }
43         }
44         return 0;
45 }
46
47 #endif /*_CPT_UCODE_H_ */