1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
6 #ifndef _TF_EM_COMMON_H_
7 #define _TF_EM_COMMON_H_
10 #include "tf_session.h"
13 * Function to search for table scope control block structure
14 * with specified table scope ID.
17 * Table scope ID to search for
20 * Pointer to the found table scope control block struct or NULL if
21 * table scope control block struct not found
23 struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
26 * Table Scope Allocate
28 * Allocate a table scope
30 * [in/out] pointer to tbl_scope_id
36 int tf_tbl_scope_alloc(uint32_t *tbl_scope_id);
43 * [in] tbl_scope_id to free
49 int tf_tbl_scope_free(uint32_t tbl_scope_id);
52 * Create and initialize a stack to use for action entries
59 * Number of EEM entries
65 * -ENOMEM - Out of memory
68 int tf_create_tbl_pool_external(enum tf_dir dir,
69 struct tf_tbl_scope_cb *tbl_scope_cb,
71 uint32_t entry_sz_bytes);
74 * Delete and cleanup action record allocation stack
82 void tf_destroy_tbl_pool_external(enum tf_dir dir,
83 struct tf_tbl_scope_cb *tbl_scope_cb);
86 * Get hash mask for current EEM table size
89 * Number of EEM entries
91 uint32_t tf_em_get_key_mask(int num_entries);
101 * Completed key record
103 void tf_em_create_key_entry(struct cfa_p4_eem_entry_hdr *result,
105 struct cfa_p4_eem_64b_entry *key_entry);
108 * Find base page address for offset into specified table type
122 * Void pointer to page base address - Success
124 void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
127 enum hcapi_cfa_em_table_type table_type);
130 * Validates EM number of entries requested
133 * Pointer to table scope control block to be populated
136 * Pointer to input parameters
140 * -EINVAL - Parameter error
142 int tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,
143 struct tf_alloc_tbl_scope_parms *parms);
146 * Size the EM table based on capabilities
153 * - EINVAL - Parameter error
154 * - ENOMEM - Out of memory
156 int tf_em_size_table(struct hcapi_cfa_em_table *tbl,
159 #endif /* _TF_EM_COMMON_H_ */