Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2019-2023 Broadcom
3 : : * All rights reserved.
4 : : */
5 : :
6 : : #include <string.h>
7 : : #include <rte_common.h>
8 : :
9 : : #include "tf_core.h"
10 : :
11 : : #include "tf_tcam_shared.h"
12 : : #include "tf_tcam.h"
13 : : #include "tf_common.h"
14 : : #include "tf_util.h"
15 : : #include "tf_rm.h"
16 : : #include "tf_device.h"
17 : : #include "tfp.h"
18 : : #include "tf_session.h"
19 : : #include "tf_msg.h"
20 : : #include "bitalloc.h"
21 : : #include "tf_tcam_mgr_msg.h"
22 : :
23 : : /**
24 : : * tf_tcam_shared_bind
25 : : */
26 : : int
27 : 0 : tf_tcam_shared_bind(struct tf *tfp,
28 : : struct tf_tcam_cfg_parms *parms)
29 : : {
30 : : int rc;
31 : :
32 [ # # ]: 0 : TF_CHECK_PARMS2(tfp, parms);
33 : :
34 : : /* Perform normal bind
35 : : */
36 : 0 : rc = tf_tcam_bind(tfp, parms);
37 : 0 : return rc;
38 : :
39 : : }
40 : : /**
41 : : * tf_tcam_shared_unbind
42 : : */
43 : : int
44 : 0 : tf_tcam_shared_unbind(struct tf *tfp)
45 : : {
46 : : int rc;
47 : :
48 [ # # ]: 0 : TF_CHECK_PARMS1(tfp);
49 : :
50 : 0 : rc = tf_tcam_unbind(tfp);
51 : 0 : return rc;
52 : : }
53 : :
54 : : /**
55 : : * tf_tcam_shared_alloc
56 : : */
57 : : int
58 : 0 : tf_tcam_shared_alloc(struct tf *tfp,
59 : : struct tf_tcam_alloc_parms *parms)
60 : : {
61 : : int rc;
62 : :
63 [ # # ]: 0 : TF_CHECK_PARMS2(tfp, parms);
64 : :
65 : 0 : rc = tf_tcam_alloc(tfp, parms);
66 : 0 : return rc;
67 : : }
68 : :
69 : : int
70 : 0 : tf_tcam_shared_free(struct tf *tfp,
71 : : struct tf_tcam_free_parms *parms)
72 : : {
73 : : int rc;
74 : :
75 [ # # ]: 0 : TF_CHECK_PARMS2(tfp, parms);
76 : :
77 : 0 : rc = tf_tcam_free(tfp, parms);
78 : 0 : return rc;
79 : : }
80 : :
81 : : int
82 : 0 : tf_tcam_shared_set(struct tf *tfp __rte_unused,
83 : : struct tf_tcam_set_parms *parms __rte_unused)
84 : : {
85 : : int rc;
86 : :
87 [ # # ]: 0 : TF_CHECK_PARMS2(tfp, parms);
88 : :
89 : 0 : rc = tf_tcam_set(tfp, parms);
90 : 0 : return rc;
91 : : }
92 : :
93 : : int
94 : 0 : tf_tcam_shared_get(struct tf *tfp __rte_unused,
95 : : struct tf_tcam_get_parms *parms)
96 : : {
97 : : int rc;
98 : :
99 [ # # ]: 0 : TF_CHECK_PARMS2(tfp, parms);
100 : :
101 : 0 : rc = tf_tcam_get(tfp, parms);
102 : 0 : return rc;
103 : : }
104 : :
105 : : /** Move all shared WC TCAM entries from the high pool into the low pool
106 : : * and clear out the high pool entries.
107 : : */
108 : : static
109 : 0 : int tf_tcam_shared_move(struct tf *tfp,
110 : : struct tf_move_tcam_shared_entries_parms *parms)
111 : : {
112 : : struct tf_session *tfs;
113 : : int rc;
114 : :
115 [ # # ]: 0 : TF_CHECK_PARMS2(tfp, parms);
116 : :
117 : : /* Retrieve the session information */
118 : 0 : rc = tf_session_get_session_internal(tfp, &tfs);
119 [ # # ]: 0 : if (rc)
120 : : return rc;
121 : :
122 : : /* If we aren't the shared session or one of our
123 : : * special types
124 : : */
125 [ # # ]: 0 : if (!tf_session_is_shared_session(tfs) ||
126 [ # # ]: 0 : (parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
127 : : parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW)) {
128 : 0 : TFP_DRV_LOG(ERR,
129 : : "%s: Session must be shared with HI/LO type\n",
130 : : tf_dir_2_str(parms->dir));
131 : 0 : return -EOPNOTSUPP;
132 : : }
133 : :
134 : 0 : rc = tf_tcam_mgr_shared_move_msg(tfp, parms);
135 : 0 : return rc;
136 : : }
137 : :
138 : : int
139 : 0 : tf_tcam_shared_move_p4(struct tf *tfp,
140 : : struct tf_move_tcam_shared_entries_parms *parms)
141 : : {
142 : : int rc = 0;
143 : 0 : rc = tf_tcam_shared_move(tfp,
144 : : parms);
145 : 0 : return rc;
146 : : }
147 : :
148 : : int
149 : 0 : tf_tcam_shared_move_p58(struct tf *tfp,
150 : : struct tf_move_tcam_shared_entries_parms *parms)
151 : : {
152 : : int rc = 0;
153 : 0 : rc = tf_tcam_shared_move(tfp,
154 : : parms);
155 : 0 : return rc;
156 : : }
157 : :
158 : : int
159 : 0 : tf_tcam_shared_clear(struct tf *tfp,
160 : : struct tf_clear_tcam_shared_entries_parms *parms)
161 : : {
162 : : int rc = 0;
163 : : struct tf_session *tfs;
164 : :
165 [ # # ]: 0 : TF_CHECK_PARMS2(tfp, parms);
166 : :
167 : : /* Retrieve the session information */
168 : 0 : rc = tf_session_get_session_internal(tfp, &tfs);
169 [ # # ]: 0 : if (rc)
170 : : return rc;
171 : :
172 [ # # ]: 0 : if (!tf_session_is_shared_session(tfs) ||
173 [ # # ]: 0 : (parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
174 : : parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW))
175 : : return -EOPNOTSUPP;
176 : :
177 : 0 : rc = tf_tcam_mgr_shared_clear_msg(tfp, parms);
178 : 0 : return rc;
179 : : }
|