1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
6 #ifndef _TF_EM_COMMON_H_
7 #define _TF_EM_COMMON_H_
10 #include "tf_session.h"
14 * Function to search for table scope control block structure
15 * with specified table scope ID.
18 * Table scope ID to search for
21 * Pointer to the found table scope control block struct or NULL if
22 * table scope control block struct not found
24 struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
27 * Table scope control block content
32 uint32_t max_entries_supported;
33 uint16_t key_entry_size;
34 uint16_t record_entry_size;
35 uint16_t efc_entry_size;
41 * Link list of ext em data allocated and managed by EEM module
42 * for a TruFlow session.
45 struct ll tbl_scope_ll;
46 struct rm_db *eem_db[TF_DIR_MAX];
50 * Table Scope Control Block
52 * Holds private data for a table scope.
54 struct tf_tbl_scope_cb {
56 * Linked list of tbl_scope
58 struct ll_entry ll_entry; /* For inserting in link list, must be
59 * first field of struct.
62 uint32_t tbl_scope_id;
64 /** The pf or parent pf of the vf used for table scope creation
67 struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
68 struct tf_em_caps em_caps[TF_DIR_MAX];
69 struct stack ext_act_pool[TF_DIR_MAX];
70 uint32_t *ext_act_pool_mem[TF_DIR_MAX];
74 * Create and initialize a stack to use for action entries
81 * Number of EEM entries
87 * -ENOMEM - Out of memory
90 int tf_create_tbl_pool_external(enum tf_dir dir,
91 struct tf_tbl_scope_cb *tbl_scope_cb,
93 uint32_t entry_sz_bytes);
96 * Delete and cleanup action record allocation stack
104 void tf_destroy_tbl_pool_external(enum tf_dir dir,
105 struct tf_tbl_scope_cb *tbl_scope_cb);
108 * Get hash mask for current EEM table size
111 * Number of EEM entries
113 uint32_t tf_em_get_key_mask(int num_entries);
123 * Completed key record
125 void tf_em_create_key_entry(struct cfa_p4_eem_entry_hdr *result,
127 struct cfa_p4_eem_64b_entry *key_entry);
130 * Find base page address for offset into specified table type
144 * Void pointer to page base address - Success
146 void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
149 enum hcapi_cfa_em_table_type table_type);
152 * Validates EM number of entries requested
155 * Pointer to table scope control block to be populated
158 * Pointer to input parameters
162 * -EINVAL - Parameter error
164 int tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,
165 struct tf_alloc_tbl_scope_parms *parms);
168 * Size the EM table based on capabilities
175 * - EINVAL - Parameter error
176 * - ENOMEM - Out of memory
178 int tf_em_size_table(struct hcapi_cfa_em_table *tbl,
183 * Look up table scope control block using tbl_scope_id from
187 * Pointer to Truflow Handle
193 * - Pointer to the tf_tbl_scope_cb, if found.
194 * - (NULL) on failure, not found.
196 struct tf_tbl_scope_cb *
197 tf_em_ext_common_tbl_scope_find(struct tf *tfp,
198 uint32_t tbl_scope_id);
200 #endif /* _TF_EM_COMMON_H_ */