1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2019-2020 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef _TF_EM_COMMON_H_ 7 #define _TF_EM_COMMON_H_ 8 9 #include "tf_core.h" 10 #include "tf_session.h" 11 12 13 /** 14 * Function to search for table scope control block structure 15 * with specified table scope ID. 16 * 17 * [in] tbl_scope_id 18 * Table scope ID to search for 19 * 20 * Returns: 21 * Pointer to the found table scope control block struct or NULL if 22 * table scope control block struct not found 23 */ 24 struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id); 25 26 /** 27 * Create and initialize a stack to use for action entries 28 * 29 * [in] dir 30 * Direction 31 * [in] tbl_scope_id 32 * Table scope ID 33 * [in] num_entries 34 * Number of EEM entries 35 * [in] entry_sz_bytes 36 * Size of the entry 37 * 38 * Returns: 39 * 0 - Success 40 * -ENOMEM - Out of memory 41 * -EINVAL - Failure 42 */ 43 int tf_create_tbl_pool_external(enum tf_dir dir, 44 struct tf_tbl_scope_cb *tbl_scope_cb, 45 uint32_t num_entries, 46 uint32_t entry_sz_bytes); 47 48 /** 49 * Delete and cleanup action record allocation stack 50 * 51 * [in] dir 52 * Direction 53 * [in] tbl_scope_id 54 * Table scope ID 55 * 56 */ 57 void tf_destroy_tbl_pool_external(enum tf_dir dir, 58 struct tf_tbl_scope_cb *tbl_scope_cb); 59 60 /** 61 * Get hash mask for current EEM table size 62 * 63 * [in] num_entries 64 * Number of EEM entries 65 */ 66 uint32_t tf_em_get_key_mask(int num_entries); 67 68 /** 69 * Populate key_entry 70 * 71 * [in] result 72 * Entry data 73 * [in] in_key 74 * Key data 75 * [out] key_entry 76 * Completed key record 77 */ 78 void tf_em_create_key_entry(struct cfa_p4_eem_entry_hdr *result, 79 uint8_t *in_key, 80 struct cfa_p4_eem_64b_entry *key_entry); 81 82 /** 83 * Find base page address for offset into specified table type 84 * 85 * [in] tbl_scope_cb 86 * Table scope 87 * [in] dir 88 * Direction 89 * [in] Offset 90 * Offset in to table 91 * [in] table_type 92 * Table type 93 * 94 * Returns: 95 * 96 * 0 - Failure 97 * Void pointer to page base address - Success 98 */ 99 void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb, 100 enum tf_dir dir, 101 uint32_t offset, 102 enum hcapi_cfa_em_table_type table_type); 103 104 /** 105 * Validates EM number of entries requested 106 * 107 * [in] tbl_scope_cb 108 * Pointer to table scope control block to be populated 109 * 110 * [in] parms 111 * Pointer to input parameters 112 * 113 * Returns: 114 * 0 - Success 115 * -EINVAL - Parameter error 116 */ 117 int tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb, 118 struct tf_alloc_tbl_scope_parms *parms); 119 120 /** 121 * Size the EM table based on capabilities 122 * 123 * [in] tbl 124 * EM table to size 125 * 126 * Returns: 127 * 0 - Success 128 * - EINVAL - Parameter error 129 * - ENOMEM - Out of memory 130 */ 131 int tf_em_size_table(struct hcapi_cfa_em_table *tbl, 132 uint32_t page_size); 133 134 #endif /* _TF_EM_COMMON_H_ */ 135