c1805df73e42a9bad36f51e1c649ce5b3d885c2a
[dpdk.git] / drivers / net / bnxt / tf_core / tf_em.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _TF_EM_H_
7 #define _TF_EM_H_
8
9 #include "tf_core.h"
10 #include "tf_session.h"
11
12 #define TF_HW_EM_KEY_MAX_SIZE 52
13 #define TF_EM_KEY_RECORD_SIZE 64
14
15 /*
16  * Used to build GFID:
17  *
18  *   15           2  0
19  *  +--------------+--+
20  *  |   Index      |E |
21  *  +--------------+--+
22  *
23  * E = Entry (bucket inndex)
24  */
25 #define TF_EM_INTERNAL_INDEX_SHIFT 2
26 #define TF_EM_INTERNAL_INDEX_MASK 0xFFFC
27 #define TF_EM_INTERNAL_ENTRY_MASK  0x3
28
29 /** EEM Entry header
30  *
31  */
32 struct tf_eem_entry_hdr {
33         uint32_t pointer;
34         uint32_t word1;  /*
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.
39                           */
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
58 };
59
60 /** EEM Entry
61  *  Each EEM entry is 512-bit (64-bytes)
62  */
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;
68 };
69
70 /** EM Entry
71  *  Each EM entry is 512-bit (64-bytes) but ordered differently to
72  *  EEM.
73  */
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)];
79 };
80
81 /**
82  * Allocates EEM Table scope
83  *
84  * [in] tfp
85  *   Pointer to TruFlow handle
86  *
87  * [in] parms
88  *   Pointer to input parameters
89  *
90  * Returns:
91  *   0       - Success
92  *   -EINVAL - Parameter error
93  *   -ENOMEM - Out of memory
94  */
95 int tf_alloc_eem_tbl_scope(struct tf *tfp,
96                            struct tf_alloc_tbl_scope_parms *parms);
97
98 /**
99  * Free's EEM Table scope control block
100  *
101  * [in] tfp
102  *   Pointer to TruFlow handle
103  *
104  * [in] parms
105  *   Pointer to input parameters
106  *
107  * Returns:
108  *   0       - Success
109  *   -EINVAL - Parameter error
110  */
111 int tf_free_eem_tbl_scope_cb(struct tf *tfp,
112                              struct tf_free_tbl_scope_parms *parms);
113
114 /**
115  * Function to search for table scope control block structure
116  * with specified table scope ID.
117  *
118  * [in] session
119  *   Session to use for the search of the table scope control block
120  * [in] tbl_scope_id
121  *   Table scope ID to search for
122  *
123  * Returns:
124  *  Pointer to the found table scope control block struct or NULL if
125  *  table scope control block struct not found
126  */
127 struct tf_tbl_scope_cb *tbl_scope_cb_find(struct tf_session *session,
128                                           uint32_t tbl_scope_id);
129
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);
133
134 int tf_insert_em_internal_entry(struct tf *tfp,
135                                 struct tf_insert_em_entry_parms *parms);
136
137 int tf_delete_eem_entry(struct tf *tfp,
138                         struct tf_delete_em_entry_parms *parms);
139
140 int tf_delete_em_internal_entry(struct tf                       *tfp,
141                                 struct tf_delete_em_entry_parms *parms);
142
143 void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
144                            enum tf_dir dir,
145                            uint32_t offset,
146                            enum tf_em_table_type table_type);
147
148 #endif /* _TF_EM_H_ */