1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
16 #include "hcapi_cfa_defs.h"
18 #define INVALID_U64 (0xFFFFFFFFFFFFFFFFULL)
19 #define INVALID_U32 (0xFFFFFFFFUL)
20 #define INVALID_U16 (0xFFFFUL)
21 #define INVALID_U8 (0xFFUL)
23 struct hcapi_cfa_devops;
26 * CFA device information
28 struct hcapi_cfa_devinfo {
29 /** [out] CFA device ops function pointer table */
30 const struct hcapi_cfa_devops *devops;
34 * \defgroup CFA_HCAPI_DEVICE_API
35 * HCAPI used for writing to the hardware
39 /** CFA device specific function hooks structure
41 * The following device hooks can be defined; unless noted otherwise, they are
42 * optional and can be filled with a null pointer. The purpose of these hooks
43 * to support CFA device operations for different device variants.
45 struct hcapi_cfa_devops {
46 /** calculate a key hash for the provided key_data
48 * This API computes hash for a key.
51 * A pointer of the key data buffer
54 * Number of bits of the key data
57 * 0 for SUCCESS, negative value for FAILURE
59 uint64_t (*hcapi_cfa_key_hash)(uint64_t *key_data, uint16_t bitlen);
61 /** hardware operation on the CFA EM key
63 * This API provides the functionality to program the exact match and
64 * key data to exact match record memory.
67 * A pointer to the Hardware operation parameter
70 * A pointer to the off-chip EM key table (applicable to EEM and
71 * SR2 EM only), set to NULL for on-chip EM key table or WC
74 * @param[in/out] key_obj
75 * A pointer to the key data object for the hardware operation which
76 * has the following contents:
77 * 1. key record memory offset (index to WC TCAM or EM key hash
80 * When using the HWOP PUT, the key_obj holds the LREC and key to
82 * When using the HWOP GET, the key_obj be populated with the LREC
83 * and key which was specified by the key location object.
85 * @param[in/out] key_loc
86 * When using the HWOP PUT, this is a pointer to the key location
87 * data structure which holds the information of where the EM key
88 * is stored. It holds the bucket index and the data pointer of
89 * a dynamic bucket that is chained to static bucket
90 * When using the HWOP GET, this is a pointer to the key location
91 * which should be retrieved.
93 * (valid for SR2 only).
95 * 0 for SUCCESS, negative value for FAILURE
97 int (*hcapi_cfa_key_hw_op)(struct hcapi_cfa_hwop *op,
98 struct hcapi_cfa_key_tbl *key_tbl,
99 struct hcapi_cfa_key_data *key_data,
100 struct hcapi_cfa_key_loc *key_loc);
105 extern const size_t CFA_RM_HANDLE_DATA_SIZE;
107 #if SUPPORT_CFA_HW_ALL
108 extern const struct hcapi_cfa_devops cfa_p4_devops;
109 extern const struct hcapi_cfa_devops cfa_p58_devops;
111 #elif defined(SUPPORT_CFA_HW_P4) && SUPPORT_CFA_HW_P4
112 extern const struct hcapi_cfa_devops cfa_p4_devops;
113 uint64_t hcapi_cfa_p4_key_hash(uint64_t *key_data, uint16_t bitlen);
114 /* SUPPORT_CFA_HW_P4 */
115 #elif defined(SUPPORT_CFA_HW_P58) && SUPPORT_CFA_HW_P58
116 extern const struct hcapi_cfa_devops cfa_p58_devops;
117 uint64_t hcapi_cfa_p58_key_hash(uint64_t *key_data, uint16_t bitlen);
118 /* SUPPORT_CFA_HW_P58 */
121 #endif /* HCAPI_CFA_H_ */