net/bnxt: support EM and TCAM lookup with table scope
[dpdk.git] / drivers / net / bnxt / tf_core / tf_em_system.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #include <string.h>
7 #include <rte_common.h>
8 #include <rte_errno.h>
9 #include <rte_log.h>
10
11 #include "tf_core.h"
12 #include "tf_em.h"
13 #include "tf_em_common.h"
14 #include "tf_msg.h"
15 #include "tfp.h"
16 #include "lookup3.h"
17 #include "tf_ext_flow_handle.h"
18
19 #include "bnxt.h"
20
21
22 /** insert EEM entry API
23  *
24  * returns:
25  *  0
26  *  TF_ERR          - unable to get lock
27  *
28  * insert callback returns:
29  *   0
30  *   TF_ERR_EM_DUP  - key is already in table
31  */
32 static int
33 tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb __rte_unused,
34                     struct tf_insert_em_entry_parms *parms __rte_unused)
35 {
36         return 0;
37 }
38
39 /** delete EEM hash entry API
40  *
41  * returns:
42  *   0
43  *   -EINVAL      - parameter error
44  *   TF_NO_SESSION    - bad session ID
45  *   TF_ERR_TBL_SCOPE - invalid table scope
46  *   TF_ERR_TBL_IF    - invalid table interface
47  *
48  * insert callback returns
49  *   0
50  *   TF_NO_EM_MATCH - entry not found
51  */
52 static int
53 tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb __rte_unused,
54                     struct tf_delete_em_entry_parms *parms __rte_unused)
55 {
56         return 0;
57 }
58
59 /** insert EM hash entry API
60  *
61  *    returns:
62  *    0       - Success
63  *    -EINVAL - Error
64  */
65 int
66 tf_em_insert_ext_sys_entry(struct tf *tfp,
67                            struct tf_insert_em_entry_parms *parms)
68 {
69         struct tf_tbl_scope_cb *tbl_scope_cb;
70
71         tbl_scope_cb = tbl_scope_cb_find
72                 ((struct tf_session *)(tfp->session->core_data),
73                 parms->tbl_scope_id);
74         if (tbl_scope_cb == NULL) {
75                 TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
76                 return -EINVAL;
77         }
78
79         return tf_insert_eem_entry
80                 (tbl_scope_cb, parms);
81 }
82
83 /** Delete EM hash entry API
84  *
85  *    returns:
86  *    0       - Success
87  *    -EINVAL - Error
88  */
89 int
90 tf_em_delete_ext_sys_entry(struct tf *tfp,
91                            struct tf_delete_em_entry_parms *parms)
92 {
93         struct tf_tbl_scope_cb *tbl_scope_cb;
94
95         tbl_scope_cb = tbl_scope_cb_find
96                 ((struct tf_session *)(tfp->session->core_data),
97                 parms->tbl_scope_id);
98         if (tbl_scope_cb == NULL) {
99                 TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
100                 return -EINVAL;
101         }
102
103         return tf_delete_eem_entry(tbl_scope_cb, parms);
104 }
105
106 int
107 tf_em_ext_system_alloc(struct tf *tfp __rte_unused,
108                        struct tf_alloc_tbl_scope_parms *parms __rte_unused)
109 {
110         return 0;
111 }
112
113 int
114 tf_em_ext_system_free(struct tf *tfp __rte_unused,
115                       struct tf_free_tbl_scope_parms *parms __rte_unused)
116 {
117         return 0;
118 }