1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
10 #include "tf_session.h"
12 #define TF_HW_EM_KEY_MAX_SIZE 52
13 #define TF_EM_KEY_RECORD_SIZE 64
23 * E = Entry (bucket inndex)
25 #define TF_EM_INTERNAL_INDEX_SHIFT 2
26 #define TF_EM_INTERNAL_INDEX_MASK 0xFFFC
27 #define TF_EM_INTERNAL_ENTRY_MASK 0x3
32 struct tf_eem_entry_hdr {
35 * The header is made up of two words,
36 * this is the first word. This field has multiple
37 * subfields, there is no suitable single name for
38 * it so just going with word1.
40 #define TF_LKUP_RECORD_VALID_SHIFT 31
41 #define TF_LKUP_RECORD_VALID_MASK 0x80000000
42 #define TF_LKUP_RECORD_L1_CACHEABLE_SHIFT 30
43 #define TF_LKUP_RECORD_L1_CACHEABLE_MASK 0x40000000
44 #define TF_LKUP_RECORD_STRENGTH_SHIFT 28
45 #define TF_LKUP_RECORD_STRENGTH_MASK 0x30000000
46 #define TF_LKUP_RECORD_RESERVED_SHIFT 17
47 #define TF_LKUP_RECORD_RESERVED_MASK 0x0FFE0000
48 #define TF_LKUP_RECORD_KEY_SIZE_SHIFT 8
49 #define TF_LKUP_RECORD_KEY_SIZE_MASK 0x0001FF00
50 #define TF_LKUP_RECORD_ACT_REC_SIZE_SHIFT 3
51 #define TF_LKUP_RECORD_ACT_REC_SIZE_MASK 0x000000F8
52 #define TF_LKUP_RECORD_ACT_REC_INT_SHIFT 2
53 #define TF_LKUP_RECORD_ACT_REC_INT_MASK 0x00000004
54 #define TF_LKUP_RECORD_EXT_FLOW_CTR_SHIFT 1
55 #define TF_LKUP_RECORD_EXT_FLOW_CTR_MASK 0x00000002
56 #define TF_LKUP_RECORD_ACT_PTR_MSB_SHIFT 0
57 #define TF_LKUP_RECORD_ACT_PTR_MSB_MASK 0x00000001
61 * Each EEM entry is 512-bit (64-bytes)
63 struct tf_eem_64b_entry {
64 /** Key is 448 bits - 56 bytes */
65 uint8_t key[TF_EM_KEY_RECORD_SIZE - sizeof(struct tf_eem_entry_hdr)];
66 /** Header is 8 bytes long */
67 struct tf_eem_entry_hdr hdr;
71 * Each EM entry is 512-bit (64-bytes) but ordered differently to
74 struct tf_em_64b_entry {
75 /** Header is 8 bytes long */
76 struct tf_eem_entry_hdr hdr;
77 /** Key is 448 bits - 56 bytes */
78 uint8_t key[TF_EM_KEY_RECORD_SIZE - sizeof(struct tf_eem_entry_hdr)];
82 * Allocates EEM Table scope
85 * Pointer to TruFlow handle
88 * Pointer to input parameters
92 * -EINVAL - Parameter error
93 * -ENOMEM - Out of memory
95 int tf_alloc_eem_tbl_scope(struct tf *tfp,
96 struct tf_alloc_tbl_scope_parms *parms);
99 * Free's EEM Table scope control block
102 * Pointer to TruFlow handle
105 * Pointer to input parameters
109 * -EINVAL - Parameter error
111 int tf_free_eem_tbl_scope_cb(struct tf *tfp,
112 struct tf_free_tbl_scope_parms *parms);
115 * Function to search for table scope control block structure
116 * with specified table scope ID.
119 * Session to use for the search of the table scope control block
121 * Table scope ID to search for
124 * Pointer to the found table scope control block struct or NULL if
125 * table scope control block struct not found
127 struct tf_tbl_scope_cb *tbl_scope_cb_find(struct tf_session *session,
128 uint32_t tbl_scope_id);
130 int tf_insert_eem_entry(struct tf_session *session,
131 struct tf_tbl_scope_cb *tbl_scope_cb,
132 struct tf_insert_em_entry_parms *parms);
134 int tf_insert_em_internal_entry(struct tf *tfp,
135 struct tf_insert_em_entry_parms *parms);
137 int tf_delete_eem_entry(struct tf *tfp,
138 struct tf_delete_em_entry_parms *parms);
140 int tf_delete_em_internal_entry(struct tf *tfp,
141 struct tf_delete_em_entry_parms *parms);
143 void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
146 enum tf_em_table_type table_type);
148 #endif /* _TF_EM_H_ */