1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
10 #define ROC_AE_CPT_BLOCK_TYPE1 0
11 #define ROC_AE_CPT_BLOCK_TYPE2 1
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
18 #define ROC_CPT_MAX_LFS 64
19 #define ROC_CN10K_CPT_INST_DW_M1 \
20 ((uint64_t)(((sizeof(struct cpt_inst_s) / 16) - 1) & 0x7))
21 #define ROC_CN10K_TWO_CPT_INST_DW_M1 \
22 ((uint64_t)(((sizeof(struct cpt_inst_s) * 2 / 16) - 1) & 0x7))
24 /* Vector of sizes in the burst of 16 CPT inst except first in 63:19 of
27 #define ROC_CN10K_CPT_LMT_ARG \
28 (ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 0) | \
29 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 1) | \
30 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 2) | \
31 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 3) | \
32 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 4) | \
33 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 5) | \
34 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 6) | \
35 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 7) | \
36 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 8) | \
37 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 9) | \
38 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 10) | \
39 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 11) | \
40 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 12) | \
41 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 13) | \
42 ROC_CN10K_CPT_INST_DW_M1 << (19 + 3 * 14))
44 /* CPT helper macros */
45 #define ROC_CPT_AH_HDR_LEN 12
46 #define ROC_CPT_AES_GCM_IV_LEN 8
47 #define ROC_CPT_AES_GCM_MAC_LEN 16
48 #define ROC_CPT_AES_CBC_IV_LEN 16
49 #define ROC_CPT_SHA1_HMAC_LEN 12
50 #define ROC_CPT_AUTH_KEY_LEN_MAX 64
52 #define ROC_CPT_DES3_KEY_LEN 24
53 #define ROC_CPT_AES128_KEY_LEN 16
54 #define ROC_CPT_AES192_KEY_LEN 24
55 #define ROC_CPT_AES256_KEY_LEN 32
56 #define ROC_CPT_MD5_KEY_LENGTH 16
57 #define ROC_CPT_SHA1_KEY_LENGTH 20
58 #define ROC_CPT_SHA256_KEY_LENGTH 32
59 #define ROC_CPT_SHA384_KEY_LENGTH 48
60 #define ROC_CPT_SHA512_KEY_LENGTH 64
61 #define ROC_CPT_AUTH_KEY_LEN_MAX 64
63 #define ROC_CPT_DES_BLOCK_LENGTH 8
64 #define ROC_CPT_AES_BLOCK_LENGTH 16
66 #define ROC_CPT_AES_GCM_ROUNDUP_BYTE_LEN 4
67 #define ROC_CPT_AES_CBC_ROUNDUP_BYTE_LEN 16
69 /* Salt length for AES-CTR/GCM/CCM and AES-GMAC */
70 #define ROC_CPT_SALT_LEN 4
72 #define ROC_CPT_ESP_HDR_LEN 8
73 #define ROC_CPT_ESP_TRL_LEN 2
74 #define ROC_CPT_AH_HDR_LEN 12
75 #define ROC_CPT_TUNNEL_IPV4_HDR_LEN 20
76 #define ROC_CPT_TUNNEL_IPV6_HDR_LEN 40
78 struct roc_cpt_lmtline {
85 /* Input parameters */
88 /* End of Input parameters */
89 struct plt_pci_device *pci_dev;
91 struct roc_cpt *roc_cpt;
99 struct roc_nix *inl_outb_nix;
100 } __plt_cache_aligned;
103 struct plt_pci_device *pci_dev;
104 struct roc_cpt_lf *lf[ROC_CPT_MAX_LFS];
106 uint16_t nb_lf_avail;
108 /**< CPT device capabilities */
109 union cpt_eng_caps hw_caps[CPT_MAX_ENG_TYPES];
110 uint8_t eng_grp[CPT_MAX_ENG_TYPES];
112 #define ROC_CPT_MEM_SZ (6 * 1024)
113 uint8_t reserved[ROC_CPT_MEM_SZ] __plt_cache_aligned;
114 } __plt_cache_aligned;
116 struct roc_cpt_rxc_time_cfg {
118 uint16_t active_limit;
119 uint16_t active_thres;
120 uint16_t zombie_limit;
121 uint16_t zombie_thres;
124 int __roc_api roc_cpt_rxc_time_cfg(struct roc_cpt *roc_cpt,
125 struct roc_cpt_rxc_time_cfg *cfg);
126 int __roc_api roc_cpt_dev_init(struct roc_cpt *roc_cpt);
127 int __roc_api roc_cpt_dev_fini(struct roc_cpt *roc_cpt);
128 int __roc_api roc_cpt_eng_grp_add(struct roc_cpt *roc_cpt,
129 enum cpt_eng_type eng_type);
130 int __roc_api roc_cpt_dev_configure(struct roc_cpt *roc_cpt, int nb_lf);
131 void __roc_api roc_cpt_dev_clear(struct roc_cpt *roc_cpt);
132 int __roc_api roc_cpt_lf_init(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf);
133 void __roc_api roc_cpt_lf_fini(struct roc_cpt_lf *lf);
134 int __roc_api roc_cpt_lf_ctx_flush(struct roc_cpt_lf *lf, uint64_t cptr);
135 int __roc_api roc_cpt_inline_ipsec_cfg(struct dev *dev, uint8_t slot,
136 struct roc_nix *nix);
137 int __roc_api roc_cpt_inline_ipsec_inb_cfg(struct roc_cpt *roc_cpt,
138 uint16_t param1, uint16_t param2);
139 int __roc_api roc_cpt_afs_print(struct roc_cpt *roc_cpt);
140 int __roc_api roc_cpt_lfs_print(struct roc_cpt *roc_cpt);
141 void __roc_api roc_cpt_iq_disable(struct roc_cpt_lf *lf);
142 void __roc_api roc_cpt_iq_enable(struct roc_cpt_lf *lf);
143 int __roc_api roc_cpt_lmtline_init(struct roc_cpt *roc_cpt,
144 struct roc_cpt_lmtline *lmtline, int lf_id);
146 #endif /* _ROC_CPT_H_ */