common/cnxk: add AE definitions for asymmetric crypto
[dpdk.git] / drivers / common / cnxk / roc_cpt.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef _ROC_CPT_H_
6 #define _ROC_CPT_H_
7
8 #include "roc_api.h"
9
10 #define ROC_AE_CPT_BLOCK_TYPE1 0
11 #define ROC_AE_CPT_BLOCK_TYPE2 1
12
13 /* Default engine groups */
14 #define ROC_CPT_DFLT_ENG_GRP_SE    0UL
15 #define ROC_CPT_DFLT_ENG_GRP_SE_IE 1UL
16 #define ROC_CPT_DFLT_ENG_GRP_AE    2UL
17
18 #define ROC_CPT_MAX_LFS 64
19
20 /* CPT helper macros */
21 #define ROC_CPT_AH_HDR_LEN       12
22 #define ROC_CPT_AES_GCM_IV_LEN   8
23 #define ROC_CPT_AES_GCM_MAC_LEN  16
24 #define ROC_CPT_AES_CBC_IV_LEN   16
25 #define ROC_CPT_SHA1_HMAC_LEN    12
26 #define ROC_CPT_AUTH_KEY_LEN_MAX 64
27
28 #define ROC_CPT_DES3_KEY_LEN      24
29 #define ROC_CPT_AES128_KEY_LEN    16
30 #define ROC_CPT_AES192_KEY_LEN    24
31 #define ROC_CPT_AES256_KEY_LEN    32
32 #define ROC_CPT_MD5_KEY_LENGTH    16
33 #define ROC_CPT_SHA1_KEY_LENGTH   20
34 #define ROC_CPT_SHA256_KEY_LENGTH 32
35 #define ROC_CPT_SHA384_KEY_LENGTH 48
36 #define ROC_CPT_SHA512_KEY_LENGTH 64
37 #define ROC_CPT_AUTH_KEY_LEN_MAX  64
38
39 #define ROC_CPT_DES_BLOCK_LENGTH 8
40 #define ROC_CPT_AES_BLOCK_LENGTH 16
41
42 #define ROC_CPT_AES_GCM_ROUNDUP_BYTE_LEN 4
43 #define ROC_CPT_AES_CBC_ROUNDUP_BYTE_LEN 16
44
45 /* Salt length for AES-CTR/GCM/CCM and AES-GMAC */
46 #define ROC_CPT_SALT_LEN 4
47
48 #define ROC_CPT_ESP_HDR_LEN         8
49 #define ROC_CPT_ESP_TRL_LEN         2
50 #define ROC_CPT_AH_HDR_LEN          12
51 #define ROC_CPT_TUNNEL_IPV4_HDR_LEN 20
52 #define ROC_CPT_TUNNEL_IPV6_HDR_LEN 40
53
54 struct roc_cpt_lf {
55         /* Input parameters */
56         uint16_t lf_id;
57         uint32_t nb_desc;
58         /* End of Input parameters */
59         struct plt_pci_device *pci_dev;
60         struct dev *dev;
61         struct roc_cpt *roc_cpt;
62         uintptr_t rbase;
63         uintptr_t lmt_base;
64         uint16_t msixoff;
65         uint16_t pf_func;
66         uint64_t *fc_addr;
67         uint64_t io_addr;
68         uint8_t *iq_vaddr;
69         struct roc_nix *inl_outb_nix;
70 } __plt_cache_aligned;
71
72 struct roc_cpt {
73         struct plt_pci_device *pci_dev;
74         struct roc_cpt_lf *lf[ROC_CPT_MAX_LFS];
75         uint16_t nb_lf;
76         uint16_t nb_lf_avail;
77         uintptr_t lmt_base;
78         /**< CPT device capabilities */
79         union cpt_eng_caps hw_caps[CPT_MAX_ENG_TYPES];
80         uint8_t eng_grp[CPT_MAX_ENG_TYPES];
81
82 #define ROC_CPT_MEM_SZ (6 * 1024)
83         uint8_t reserved[ROC_CPT_MEM_SZ] __plt_cache_aligned;
84 } __plt_cache_aligned;
85
86 struct roc_cpt_rxc_time_cfg {
87         uint32_t step;
88         uint16_t active_limit;
89         uint16_t active_thres;
90         uint16_t zombie_limit;
91         uint16_t zombie_thres;
92 };
93
94 int __roc_api roc_cpt_rxc_time_cfg(struct roc_cpt *roc_cpt,
95                                    struct roc_cpt_rxc_time_cfg *cfg);
96 int __roc_api roc_cpt_dev_init(struct roc_cpt *roc_cpt);
97 int __roc_api roc_cpt_dev_fini(struct roc_cpt *roc_cpt);
98 int __roc_api roc_cpt_eng_grp_add(struct roc_cpt *roc_cpt,
99                                   enum cpt_eng_type eng_type);
100 int __roc_api roc_cpt_dev_configure(struct roc_cpt *roc_cpt, int nb_lf);
101 void __roc_api roc_cpt_dev_clear(struct roc_cpt *roc_cpt);
102 int __roc_api roc_cpt_lf_init(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf);
103 void __roc_api roc_cpt_lf_fini(struct roc_cpt_lf *lf);
104 int __roc_api roc_cpt_lf_ctx_flush(struct roc_cpt_lf *lf, uint64_t cptr);
105 int __roc_api roc_cpt_inline_ipsec_cfg(struct dev *dev, uint8_t slot,
106                                        struct roc_nix *nix);
107 int __roc_api roc_cpt_inline_ipsec_inb_cfg(struct roc_cpt *roc_cpt,
108                                            uint16_t param1, uint16_t param2);
109 int __roc_api roc_cpt_afs_print(struct roc_cpt *roc_cpt);
110 int __roc_api roc_cpt_lfs_print(struct roc_cpt *roc_cpt);
111 void __roc_api roc_cpt_iq_disable(struct roc_cpt_lf *lf);
112
113 #endif /* _ROC_CPT_H_ */