1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(C) 2024 Marvell. 3 */ 4 5 #ifndef __CN10K_CRYPTODEV_SEC_H__ 6 #define __CN10K_CRYPTODEV_SEC_H__ 7 8 #include <rte_common.h> 9 #include <rte_security.h> 10 11 #include "roc_constants.h" 12 #include "roc_cpt.h" 13 14 #include "cn10k_ipsec.h" 15 #include "cn10k_tls.h" 16 17 #define SEC_SESS_SIZE sizeof(struct rte_security_session) 18 19 struct cn10k_tls_opt { 20 uint16_t pad_shift : 3; 21 uint16_t enable_padding : 1; 22 uint16_t tail_fetch_len : 2; 23 uint16_t tls_ver : 2; 24 uint16_t is_write : 1; 25 uint16_t mac_len : 7; 26 }; 27 __rte_aligned(ROC_ALIGN)28struct __rte_aligned(ROC_ALIGN) cn10k_sec_session { 29 uint8_t rte_sess[SEC_SESS_SIZE]; 30 31 /** PMD private space */ 32 alignas(RTE_CACHE_LINE_MIN_SIZE) RTE_MARKER cacheline1; 33 34 /** Pre-populated CPT inst words */ 35 struct cnxk_cpt_inst_tmpl inst; 36 uint16_t max_extended_len; 37 uint16_t iv_offset; 38 uint8_t proto; 39 uint8_t iv_length; 40 union { 41 uint16_t u16; 42 struct cn10k_tls_opt tls_opt; 43 struct { 44 uint8_t ip_csum; 45 uint8_t is_outbound : 1; 46 } ipsec; 47 }; 48 /** Queue pair */ 49 struct cnxk_cpt_qp *qp; 50 /** Userdata to be set for Rx inject */ 51 void *userdata; 52 53 /** 54 * End of SW mutable area 55 */ 56 union { 57 struct cn10k_ipsec_sa sa; 58 struct cn10k_tls_record tls_rec; 59 }; 60 }; 61 62 static inline uint64_t cpt_inst_w7_get(struct roc_cpt * roc_cpt,void * cptr)63cpt_inst_w7_get(struct roc_cpt *roc_cpt, void *cptr) 64 { 65 union cpt_inst_w7 w7; 66 67 w7.u64 = 0; 68 w7.s.egrp = roc_cpt->eng_grp[CPT_ENG_TYPE_IE]; 69 w7.s.ctx_val = 1; 70 w7.s.cptr = (uint64_t)cptr; 71 rte_mb(); 72 73 return w7.u64; 74 } 75 76 void cn10k_sec_ops_override(void); 77 78 #endif /* __CN10K_CRYPTODEV_SEC_H__ */ 79