net/bnxt: add core changes for EM and EEM lookups
[dpdk.git] / drivers / net / bnxt / tf_core / tf_tbl.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _TF_TBL_H_
7 #define _TF_TBL_H_
8
9 #include <stdint.h>
10
11 #include "tf_core.h"
12 #include "stack.h"
13
14 struct tf_session;
15
16 /** table scope control block content */
17 struct tf_em_caps {
18         uint32_t flags;
19         uint32_t supported;
20         uint32_t max_entries_supported;
21         uint16_t key_entry_size;
22         uint16_t record_entry_size;
23         uint16_t efc_entry_size;
24 };
25
26 /** Invalid table scope id */
27 #define TF_TBL_SCOPE_INVALID 0xffffffff
28
29 /**
30  * Table Scope Control Block
31  *
32  * Holds private data for a table scope. Only one instance of a table
33  * scope with Internal EM is supported.
34  */
35 struct tf_tbl_scope_cb {
36         uint32_t tbl_scope_id;
37         int index;
38         struct hcapi_cfa_em_ctx_mem_info  em_ctx_info[TF_DIR_MAX];
39         struct tf_em_caps          em_caps[TF_DIR_MAX];
40         struct stack               ext_act_pool[TF_DIR_MAX];
41         uint32_t                  *ext_act_pool_mem[TF_DIR_MAX];
42 };
43
44 /** Hardware Page sizes supported for EEM: 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G.
45  * Round-down other page sizes to the lower hardware page size supported.
46  */
47 #define TF_EM_PAGE_SIZE_4K 12
48 #define TF_EM_PAGE_SIZE_8K 13
49 #define TF_EM_PAGE_SIZE_64K 16
50 #define TF_EM_PAGE_SIZE_256K 18
51 #define TF_EM_PAGE_SIZE_1M 20
52 #define TF_EM_PAGE_SIZE_2M 21
53 #define TF_EM_PAGE_SIZE_4M 22
54 #define TF_EM_PAGE_SIZE_1G 30
55
56 /* Set page size */
57 #define BNXT_TF_PAGE_SIZE TF_EM_PAGE_SIZE_2M
58
59 #if (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_4K)   /** 4K */
60 #define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_4K
61 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4K
62 #elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_8K) /** 8K */
63 #define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_8K
64 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_8K
65 #elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_64K)        /** 64K */
66 #define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_64K
67 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_64K
68 #elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_256K)       /** 256K */
69 #define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_256K
70 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_256K
71 #elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_1M) /** 1M */
72 #define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_1M
73 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1M
74 #elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_2M) /** 2M */
75 #define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_2M
76 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_2M
77 #elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_4M) /** 4M */
78 #define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_4M
79 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4M
80 #elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_1G) /** 1G */
81 #define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_1G
82 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1G
83 #else
84 #error "Invalid Page Size specified. Please use a TF_EM_PAGE_SIZE_n define"
85 #endif
86
87 #define TF_EM_PAGE_SIZE (1 << TF_EM_PAGE_SHIFT)
88 #define TF_EM_PAGE_ALIGNMENT (1 << TF_EM_PAGE_SHIFT)
89
90 /**
91  * Initialize table pool structure to indicate
92  * no table scope has been associated with the
93  * external pool of indexes.
94  *
95  * [in] session
96  */
97 void
98 tf_init_tbl_pool(struct tf_session *session);
99
100 #endif /* _TF_TBL_H_ */