Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(C) 2025 Marvell. 3 : : */ 4 : : 5 : : #ifndef _CN20K_CRYPTODEV_OPS_H_ 6 : : #define _CN20K_CRYPTODEV_OPS_H_ 7 : : 8 : : #include <cryptodev_pmd.h> 9 : : #include <rte_compat.h> 10 : : #include <rte_cryptodev.h> 11 : : #include <rte_eventdev.h> 12 : : 13 : : #if defined(__aarch64__) 14 : : #include "roc_io.h" 15 : : #else 16 : : #include "roc_io_generic.h" 17 : : #endif 18 : : 19 : : #include "cnxk_cryptodev.h" 20 : : 21 : : #define CN20K_PKTS_PER_STEORL 32 22 : : #define CN20K_LMTLINES_PER_STEORL 16 23 : : 24 : : extern struct rte_cryptodev_ops cn20k_cpt_ops; 25 : : 26 : : void cn20k_cpt_set_enqdeq_fns(struct rte_cryptodev *dev); 27 : : 28 : : __rte_internal 29 : : uint16_t __rte_hot cn20k_cryptodev_sec_inb_rx_inject(void *dev, struct rte_mbuf **pkts, 30 : : struct rte_security_session **sess, 31 : : uint16_t nb_pkts); 32 : : 33 : : __rte_internal 34 : : int cn20k_cryptodev_sec_rx_inject_configure(void *device, uint16_t port_id, bool enable); 35 : : 36 : : __rte_internal 37 : : uint16_t __rte_hot cn20k_cpt_crypto_adapter_enqueue(void *ws, struct rte_event ev[], 38 : : uint16_t nb_events); 39 : : 40 : : static __rte_always_inline void __rte_hot 41 : : cn20k_cpt_lmtst_dual_submit(uint64_t *io_addr, const uint16_t lmt_id, int *i) 42 : : { 43 : : uint64_t lmt_arg; 44 : : 45 : : /* Check if the total number of instructions is odd or even. */ 46 : 0 : const int flag_odd = *i & 0x1; 47 : : 48 : : /* Reduce i by 1 when odd number of instructions.*/ 49 : 0 : *i -= flag_odd; 50 : : 51 [ # # # # : 0 : if (*i > CN20K_PKTS_PER_STEORL) { # # # # # # ] 52 : : lmt_arg = ROC_CN20K_DUAL_CPT_LMT_ARG | (CN20K_LMTLINES_PER_STEORL - 1) << 12 | 53 : : (uint64_t)lmt_id; 54 : : roc_lmt_submit_steorl(lmt_arg, *io_addr); 55 : : lmt_arg = ROC_CN20K_DUAL_CPT_LMT_ARG | 56 : : (*i / 2 - CN20K_LMTLINES_PER_STEORL - 1) << 12 | 57 : : (uint64_t)(lmt_id + CN20K_LMTLINES_PER_STEORL); 58 : : roc_lmt_submit_steorl(lmt_arg, *io_addr); 59 [ # # # # : 0 : if (flag_odd) { # # # # # # ] 60 : : *io_addr = (*io_addr & ~(uint64_t)(0x7 << 4)) | 61 : : (ROC_CN20K_CPT_INST_DW_M1 << 4); 62 : : lmt_arg = (uint64_t)(lmt_id + *i / 2); 63 : : roc_lmt_submit_steorl(lmt_arg, *io_addr); 64 : : *io_addr = (*io_addr & ~(uint64_t)(0x7 << 4)) | 65 : : (ROC_CN20K_TWO_CPT_INST_DW_M1 << 4); 66 : 0 : *i += 1; 67 : : } 68 : : } else { 69 : : if (*i != 0) { 70 : : lmt_arg = 71 : : ROC_CN20K_DUAL_CPT_LMT_ARG | (*i / 2 - 1) << 12 | (uint64_t)lmt_id; 72 : : roc_lmt_submit_steorl(lmt_arg, *io_addr); 73 : : } 74 : : 75 [ # # # # : 0 : if (flag_odd) { # # # # # # ] 76 : : *io_addr = (*io_addr & ~(uint64_t)(0x7 << 4)) | 77 : : (ROC_CN20K_CPT_INST_DW_M1 << 4); 78 : : lmt_arg = (uint64_t)(lmt_id + *i / 2); 79 : : roc_lmt_submit_steorl(lmt_arg, *io_addr); 80 : : *io_addr = (*io_addr & ~(uint64_t)(0x7 << 4)) | 81 : : (ROC_CN20K_TWO_CPT_INST_DW_M1 << 4); 82 : 0 : *i += 1; 83 : : } 84 : : } 85 : : 86 : 0 : rte_io_wmb(); 87 : 0 : } 88 : : 89 : : #endif /* _CN20K_CRYPTODEV_OPS_H_ */