1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(C) 2022 Marvell. 3 */ 4 5 /** 6 * @file rte_pmd_cnxk.h 7 * CNXK PMD specific functions. 8 * 9 **/ 10 11 #ifndef _PMD_CNXK_H_ 12 #define _PMD_CNXK_H_ 13 14 #include <rte_compat.h> 15 #include <rte_ethdev.h> 16 #include <rte_ether.h> 17 #include <rte_security.h> 18 19 /** Algorithm type to be used with security action to 20 * calculate SA_index 21 */ 22 enum rte_pmd_cnxk_sec_action_alg { 23 /** No swizzling of SPI bits into SA index. 24 * SA_index is from SA_XOR if enabled. 25 */ 26 RTE_PMD_CNXK_SEC_ACTION_ALG0, 27 /** SPI<31:28> has 4 upper bits which segment the sequence number space. 28 * Initial SA_index is from SA_XOR if enabled. 29 * SA_alg = { 4'b0, SA_mcam[27:0] + SPI[31:28]} 30 */ 31 RTE_PMD_CNXK_SEC_ACTION_ALG1, 32 /** SPI<27:25> segment the sequence number space. 33 * Initial SA_index is from SA_XOR if enabled. 34 * SA_alg = { 7'b0, SA_mcam[24:0] + SPI[27:25]} 35 */ 36 RTE_PMD_CNXK_SEC_ACTION_ALG2, 37 /** The inbound SPI maybe "random", therefore we want the MCAM to be 38 * capable of remapping the SPI to an arbitrary SA_index. 39 * SPI to SA is done using a lookup in NIX/NPC cam entry with key as 40 * SPI, MATCH_ID, LFID. 41 */ 42 RTE_PMD_CNXK_SEC_ACTION_ALG3, 43 }; 44 45 struct rte_pmd_cnxk_sec_action { 46 /** Used as lookup result for ALG3 */ 47 uint32_t sa_index; 48 /** When true XOR initial SA_INDEX with SA_HI/SA_LO to get SA_MCAM */ 49 bool sa_xor; 50 /** SA_hi and SA_lo values for xor */ 51 uint16_t sa_hi, sa_lo; 52 /** Determines alg to be applied post SA_MCAM computation with/without 53 * XOR. 54 */ 55 enum rte_pmd_cnxk_sec_action_alg alg; 56 }; 57 58 /** 59 * Read HW SA context from session. 60 * 61 * @param device 62 * Port identifier of Ethernet device. 63 * @param sess 64 * Handle of the security session. 65 * @param[out] data 66 * Destination pointer to copy SA context for application. 67 * @param len 68 * Length of SA context to copy into data parameter. 69 * 70 * @return 71 * 0 on success, a negative errno value otherwise. 72 */ 73 __rte_experimental 74 int rte_pmd_cnxk_hw_sa_read(void *device, struct rte_security_session *sess, 75 void *data, uint32_t len); 76 /** 77 * Write HW SA context to session. 78 * 79 * @param device 80 * Port identifier of Ethernet device. 81 * @param sess 82 * Handle of the security session. 83 * @param[in] data 84 * Source data pointer from application to copy SA context into session. 85 * @param len 86 * Length of SA context to copy from data parameter. 87 * 88 * @return 89 * 0 on success, a negative errno value otherwise. 90 */ 91 __rte_experimental 92 int rte_pmd_cnxk_hw_sa_write(void *device, struct rte_security_session *sess, 93 void *data, uint32_t len); 94 #endif /* _PMD_CNXK_H_ */ 95