1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
19 enum tf_em_table_type {
27 struct tf_em_page_tbl {
40 uint32_t page_cnt[PT_LVL_MAX];
41 uint64_t num_data_pages;
44 struct tf_em_page_tbl pg_tbl[PT_LVL_MAX];
47 struct tf_em_ctx_mem_info {
48 struct tf_em_table em_tables[MAX_TABLE];
51 /** table scope control block content */
55 uint32_t max_entries_supported;
56 uint16_t key_entry_size;
57 uint16_t record_entry_size;
58 uint16_t efc_entry_size;
61 /** Invalid table scope id */
62 #define TF_TBL_SCOPE_INVALID 0xffffffff
65 * Table Scope Control Block
67 * Holds private data for a table scope. Only one instance of a table
68 * scope with Internal EM is supported.
70 struct tf_tbl_scope_cb {
71 uint32_t tbl_scope_id;
73 struct tf_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
74 struct tf_em_caps em_caps[TF_DIR_MAX];
75 struct stack ext_pool[TF_DIR_MAX][TF_EXT_POOL_CNT_MAX];
76 uint32_t *ext_pool_mem[TF_DIR_MAX][TF_EXT_POOL_CNT_MAX];
79 /** Hardware Page sizes supported for EEM: 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G.
80 * Round-down other page sizes to the lower hardware page size supported.
82 #define PAGE_SHIFT 22 /** 2M */
84 #if (PAGE_SHIFT < 12) /** < 4K >> 4K */
85 #define TF_EM_PAGE_SHIFT 12
86 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4K
87 #elif (PAGE_SHIFT <= 13) /** 4K, 8K */
88 #define TF_EM_PAGE_SHIFT 13
89 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_8K
90 #elif (PAGE_SHIFT < 16) /** 16K, 32K >> 8K */
91 #define TF_EM_PAGE_SHIFT 15
92 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_32K
93 #elif (PAGE_SHIFT <= 17) /** 64K, 128K >> 64K */
94 #define TF_EM_PAGE_SHIFT 16
95 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_64K
96 #elif (PAGE_SHIFT <= 19) /** 256K, 512K >> 256K */
97 #define TF_EM_PAGE_SHIFT 18
98 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_256K
99 #elif (PAGE_SHIFT <= 21) /** 1M */
100 #define TF_EM_PAGE_SHIFT 20
101 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1M
102 #elif (PAGE_SHIFT <= 22) /** 2M, 4M */
103 #define TF_EM_PAGE_SHIFT 21
104 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_2M
105 #elif (PAGE_SHIFT <= 29) /** 8M ... 512M >> 4M */
106 #define TF_EM_PAGE_SHIFT 22
107 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4M
108 #else /** >= 1G >> 1G */
109 #define TF_EM_PAGE_SHIFT 30
110 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1G
113 #define TF_EM_PAGE_SIZE (1 << TF_EM_PAGE_SHIFT)
114 #define TF_EM_PAGE_ALIGNMENT (1 << TF_EM_PAGE_SHIFT)
117 * Initialize table pool structure to indicate
118 * no table scope has been associated with the
119 * external pool of indexes.
124 tf_init_tbl_pool(struct tf_session *session);
126 #endif /* _TF_TBL_H_ */