net/bnxt: add core changes for EM and EEM lookups
[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 SUPPORT_CFA_HW_P4 1
13 #define SUPPORT_CFA_HW_P58 0
14 #define SUPPORT_CFA_HW_P59 0
15 #define SUPPORT_CFA_HW_ALL 0
16
17 #include "hcapi/hcapi_cfa_defs.h"
18
19 #define TF_HW_EM_KEY_MAX_SIZE 52
20 #define TF_EM_KEY_RECORD_SIZE 64
21
22 /*
23  * Used to build GFID:
24  *
25  *   15           2  0
26  *  +--------------+--+
27  *  |   Index      |E |
28  *  +--------------+--+
29  *
30  * E = Entry (bucket inndex)
31  */
32 #define TF_EM_INTERNAL_INDEX_SHIFT 2
33 #define TF_EM_INTERNAL_INDEX_MASK 0xFFFC
34 #define TF_EM_INTERNAL_ENTRY_MASK  0x3
35
36 /** EM Entry
37  *  Each EM entry is 512-bit (64-bytes) but ordered differently to
38  *  EEM.
39  */
40 struct tf_em_64b_entry {
41         /** Header is 8 bytes long */
42         struct cfa_p4_eem_entry_hdr hdr;
43         /** Key is 448 bits - 56 bytes */
44         uint8_t key[TF_EM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)];
45 };
46
47 /**
48  * Allocates EEM Table scope
49  *
50  * [in] tfp
51  *   Pointer to TruFlow handle
52  *
53  * [in] parms
54  *   Pointer to input parameters
55  *
56  * Returns:
57  *   0       - Success
58  *   -EINVAL - Parameter error
59  *   -ENOMEM - Out of memory
60  */
61 int tf_alloc_eem_tbl_scope(struct tf *tfp,
62                            struct tf_alloc_tbl_scope_parms *parms);
63
64 /**
65  * Free's EEM Table scope control block
66  *
67  * [in] tfp
68  *   Pointer to TruFlow handle
69  *
70  * [in] parms
71  *   Pointer to input parameters
72  *
73  * Returns:
74  *   0       - Success
75  *   -EINVAL - Parameter error
76  */
77 int tf_free_eem_tbl_scope_cb(struct tf *tfp,
78                              struct tf_free_tbl_scope_parms *parms);
79
80 /**
81  * Function to search for table scope control block structure
82  * with specified table scope ID.
83  *
84  * [in] session
85  *   Session to use for the search of the table scope control block
86  * [in] tbl_scope_id
87  *   Table scope ID to search for
88  *
89  * Returns:
90  *  Pointer to the found table scope control block struct or NULL if
91  *  table scope control block struct not found
92  */
93 struct tf_tbl_scope_cb *tbl_scope_cb_find(struct tf_session *session,
94                                           uint32_t tbl_scope_id);
95
96 void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
97                            enum tf_dir dir,
98                            uint32_t offset,
99                            enum hcapi_cfa_em_table_type table_type);
100
101 int tf_em_insert_entry(struct tf *tfp,
102                        struct tf_insert_em_entry_parms *parms);
103
104 int tf_em_delete_entry(struct tf *tfp,
105                        struct tf_delete_em_entry_parms *parms);
106 #endif /* _TF_EM_H_ */