1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2022 Marvell.
7 * CNXK PMD specific functions.
14 #include <rte_compat.h>
15 #include <rte_ethdev.h>
16 #include <rte_ether.h>
17 #include <rte_security.h>
19 /** Algorithm type to be used with security action to
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.
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]}
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]}
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.
42 RTE_PMD_CNXK_SEC_ACTION_ALG3,
45 struct rte_pmd_cnxk_sec_action {
46 /** Used as lookup result for ALG3 */
48 /** When true XOR initial SA_INDEX with SA_HI/SA_LO to get SA_MCAM */
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
55 enum rte_pmd_cnxk_sec_action_alg alg;
59 * Read HW SA context from session.
62 * Port identifier of Ethernet device.
64 * Handle of the security session.
66 * Destination pointer to copy SA context for application.
68 * Length of SA context to copy into data parameter.
71 * 0 on success, a negative errno value otherwise.
74 int rte_pmd_cnxk_hw_sa_read(void *device, struct rte_security_session *sess,
75 void *data, uint32_t len);
77 * Write HW SA context to session.
80 * Port identifier of Ethernet device.
82 * Handle of the security session.
84 * Source data pointer from application to copy SA context into session.
86 * Length of SA context to copy from data parameter.
89 * 0 on success, a negative errno value otherwise.
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_ */