Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2023 Marvell.
3 : : */
4 : :
5 : : #include "roc_api.h"
6 : : #include "roc_priv.h"
7 : :
8 : : int
9 [ # # ]: 0 : roc_mcs_rsrc_alloc(struct roc_mcs *mcs, struct roc_mcs_alloc_rsrc_req *req,
10 : : struct roc_mcs_alloc_rsrc_rsp *rsp)
11 : : {
12 : : struct mcs_priv *priv = roc_mcs_to_mcs_priv(mcs);
13 : : struct mcs_alloc_rsrc_req *rsrc_req;
14 : : struct mcs_alloc_rsrc_rsp *rsrc_rsp;
15 : : int rc, i;
16 : :
17 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
18 : :
19 [ # # ]: 0 : if (req == NULL || rsp == NULL)
20 : : return -EINVAL;
21 : :
22 : 0 : rsrc_req = mbox_alloc_msg_mcs_alloc_resources(mcs->mbox);
23 [ # # ]: 0 : if (rsrc_req == NULL)
24 : : return -ENOMEM;
25 : :
26 : 0 : rsrc_req->rsrc_type = req->rsrc_type;
27 : 0 : rsrc_req->rsrc_cnt = req->rsrc_cnt;
28 : 0 : rsrc_req->mcs_id = mcs->idx;
29 : 0 : rsrc_req->dir = req->dir;
30 : 0 : rsrc_req->all = req->all;
31 : :
32 : 0 : rc = mbox_process_msg(mcs->mbox, (void *)&rsrc_rsp);
33 [ # # ]: 0 : if (rc)
34 : : return rc;
35 : :
36 [ # # ]: 0 : if (rsrc_rsp->all) {
37 : 0 : rsrc_rsp->rsrc_cnt = 1;
38 : 0 : rsrc_rsp->rsrc_type = 0xFF;
39 : : }
40 : :
41 [ # # ]: 0 : for (i = 0; i < rsrc_rsp->rsrc_cnt; i++) {
42 [ # # # # : 0 : switch (rsrc_rsp->rsrc_type) {
# ]
43 : 0 : case MCS_RSRC_TYPE_FLOWID:
44 : 0 : rsp->flow_ids[i] = rsrc_rsp->flow_ids[i];
45 : 0 : plt_bitmap_set(priv->dev_rsrc.tcam_bmap,
46 : 0 : rsp->flow_ids[i] +
47 [ # # ]: 0 : ((req->dir == MCS_TX) ? priv->tcam_entries : 0));
48 : 0 : break;
49 : 0 : case MCS_RSRC_TYPE_SECY:
50 : 0 : rsp->secy_ids[i] = rsrc_rsp->secy_ids[i];
51 : 0 : plt_bitmap_set(priv->dev_rsrc.secy_bmap,
52 : 0 : rsp->secy_ids[i] +
53 [ # # ]: 0 : ((req->dir == MCS_TX) ? priv->secy_entries : 0));
54 : 0 : break;
55 : 0 : case MCS_RSRC_TYPE_SC:
56 : 0 : rsp->sc_ids[i] = rsrc_rsp->sc_ids[i];
57 : 0 : plt_bitmap_set(priv->dev_rsrc.sc_bmap,
58 : 0 : rsp->sc_ids[i] +
59 [ # # ]: 0 : ((req->dir == MCS_TX) ? priv->sc_entries : 0));
60 : 0 : break;
61 : 0 : case MCS_RSRC_TYPE_SA:
62 : 0 : rsp->sa_ids[i] = rsrc_rsp->sa_ids[i];
63 : 0 : plt_bitmap_set(priv->dev_rsrc.sa_bmap,
64 : 0 : rsp->sa_ids[i] +
65 [ # # ]: 0 : ((req->dir == MCS_TX) ? priv->sa_entries : 0));
66 : 0 : break;
67 : 0 : default:
68 : 0 : rsp->flow_ids[i] = rsrc_rsp->flow_ids[i];
69 : 0 : rsp->secy_ids[i] = rsrc_rsp->secy_ids[i];
70 : 0 : rsp->sc_ids[i] = rsrc_rsp->sc_ids[i];
71 : 0 : rsp->sa_ids[i] = rsrc_rsp->sa_ids[i];
72 : 0 : plt_bitmap_set(priv->dev_rsrc.tcam_bmap,
73 : 0 : rsp->flow_ids[i] +
74 [ # # ]: 0 : ((req->dir == MCS_TX) ? priv->tcam_entries : 0));
75 : 0 : plt_bitmap_set(priv->dev_rsrc.secy_bmap,
76 : 0 : rsp->secy_ids[i] +
77 [ # # ]: 0 : ((req->dir == MCS_TX) ? priv->secy_entries : 0));
78 : 0 : plt_bitmap_set(priv->dev_rsrc.sc_bmap,
79 : 0 : rsp->sc_ids[i] +
80 [ # # ]: 0 : ((req->dir == MCS_TX) ? priv->sc_entries : 0));
81 : 0 : plt_bitmap_set(priv->dev_rsrc.sa_bmap,
82 : 0 : rsp->sa_ids[i] +
83 [ # # ]: 0 : ((req->dir == MCS_TX) ? priv->sa_entries : 0));
84 : 0 : break;
85 : : }
86 : : }
87 : 0 : rsp->rsrc_type = rsrc_rsp->rsrc_type;
88 : 0 : rsp->rsrc_cnt = rsrc_rsp->rsrc_cnt;
89 : 0 : rsp->dir = rsrc_rsp->dir;
90 : 0 : rsp->all = rsrc_rsp->all;
91 : :
92 : 0 : return 0;
93 : : }
94 : :
95 : : int
96 [ # # ]: 0 : roc_mcs_rsrc_free(struct roc_mcs *mcs, struct roc_mcs_free_rsrc_req *free_req)
97 : : {
98 : : struct mcs_priv *priv = roc_mcs_to_mcs_priv(mcs);
99 : : struct mcs_free_rsrc_req *req;
100 : : struct msg_rsp *rsp;
101 : : uint32_t pos;
102 : : int i, rc;
103 : :
104 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
105 : :
106 [ # # ]: 0 : if (free_req == NULL)
107 : : return -EINVAL;
108 : :
109 : 0 : req = mbox_alloc_msg_mcs_free_resources(mcs->mbox);
110 [ # # ]: 0 : if (req == NULL)
111 : : return -ENOMEM;
112 : :
113 : 0 : req->rsrc_id = free_req->rsrc_id;
114 : 0 : req->rsrc_type = free_req->rsrc_type;
115 : 0 : req->mcs_id = mcs->idx;
116 : 0 : req->dir = free_req->dir;
117 : 0 : req->all = free_req->all;
118 : :
119 : 0 : rc = mbox_process_msg(mcs->mbox, (void *)&rsp);
120 [ # # ]: 0 : if (rc)
121 : : return rc;
122 : :
123 [ # # # # : 0 : switch (free_req->rsrc_type) {
# ]
124 : 0 : case MCS_RSRC_TYPE_FLOWID:
125 [ # # ]: 0 : pos = free_req->rsrc_id + ((req->dir == MCS_TX) ? priv->tcam_entries : 0);
126 : 0 : plt_bitmap_clear(priv->dev_rsrc.tcam_bmap, pos);
127 [ # # ]: 0 : for (i = 0; i < MAX_PORTS_PER_MCS; i++) {
128 [ # # ]: 0 : uint32_t set = plt_bitmap_get(priv->port_rsrc[i].tcam_bmap, pos);
129 : :
130 [ # # ]: 0 : if (set) {
131 : 0 : plt_bitmap_clear(priv->port_rsrc[i].tcam_bmap, pos);
132 : 0 : break;
133 : : }
134 : : }
135 : : break;
136 : 0 : case MCS_RSRC_TYPE_SECY:
137 [ # # ]: 0 : pos = free_req->rsrc_id + ((req->dir == MCS_TX) ? priv->secy_entries : 0);
138 : 0 : plt_bitmap_clear(priv->dev_rsrc.secy_bmap, pos);
139 [ # # ]: 0 : for (i = 0; i < MAX_PORTS_PER_MCS; i++) {
140 [ # # ]: 0 : uint32_t set = plt_bitmap_get(priv->port_rsrc[i].secy_bmap, pos);
141 : :
142 [ # # ]: 0 : if (set) {
143 : 0 : plt_bitmap_clear(priv->port_rsrc[i].secy_bmap, pos);
144 : 0 : break;
145 : : }
146 : : }
147 : : break;
148 : 0 : case MCS_RSRC_TYPE_SC:
149 [ # # ]: 0 : pos = free_req->rsrc_id + ((req->dir == MCS_TX) ? priv->sc_entries : 0);
150 : 0 : plt_bitmap_clear(priv->dev_rsrc.sc_bmap, pos);
151 [ # # ]: 0 : for (i = 0; i < MAX_PORTS_PER_MCS; i++) {
152 [ # # ]: 0 : uint32_t set = plt_bitmap_get(priv->port_rsrc[i].sc_bmap, pos);
153 : :
154 [ # # ]: 0 : if (set) {
155 : 0 : plt_bitmap_clear(priv->port_rsrc[i].sc_bmap, pos);
156 : 0 : break;
157 : : }
158 : : }
159 : : break;
160 : 0 : case MCS_RSRC_TYPE_SA:
161 [ # # ]: 0 : pos = free_req->rsrc_id + ((req->dir == MCS_TX) ? priv->sa_entries : 0);
162 : 0 : plt_bitmap_clear(priv->dev_rsrc.sa_bmap, pos);
163 [ # # ]: 0 : for (i = 0; i < MAX_PORTS_PER_MCS; i++) {
164 [ # # ]: 0 : uint32_t set = plt_bitmap_get(priv->port_rsrc[i].sa_bmap, pos);
165 : :
166 [ # # ]: 0 : if (set) {
167 : 0 : plt_bitmap_clear(priv->port_rsrc[i].sa_bmap, pos);
168 : 0 : break;
169 : : }
170 : : }
171 : : break;
172 : : default:
173 : : break;
174 : : }
175 : :
176 : : return rc;
177 : : }
178 : :
179 : : int
180 [ # # ]: 0 : roc_mcs_sa_policy_write(struct roc_mcs *mcs, struct roc_mcs_sa_plcy_write_req *sa_plcy)
181 : : {
182 : : struct mcs_sa_plcy_write_req *sa;
183 : : struct msg_rsp *rsp;
184 : :
185 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
186 : :
187 [ # # ]: 0 : if (sa_plcy == NULL)
188 : : return -EINVAL;
189 : :
190 : 0 : sa = mbox_alloc_msg_mcs_sa_plcy_write(mcs->mbox);
191 [ # # ]: 0 : if (sa == NULL)
192 : : return -ENOMEM;
193 : :
194 : 0 : mbox_memcpy(sa->plcy, sa_plcy->plcy, sizeof(uint64_t) * 2 * 9);
195 : 0 : sa->sa_index[0] = sa_plcy->sa_index[0];
196 : 0 : sa->sa_index[1] = sa_plcy->sa_index[1];
197 : 0 : sa->sa_cnt = sa_plcy->sa_cnt;
198 : 0 : sa->mcs_id = mcs->idx;
199 : 0 : sa->dir = sa_plcy->dir;
200 : :
201 : 0 : return mbox_process_msg(mcs->mbox, (void *)&rsp);
202 : : }
203 : :
204 : : int
205 [ # # ]: 0 : roc_mcs_sa_policy_read(struct roc_mcs *mcs __plt_unused,
206 : : struct roc_mcs_sa_plcy_write_req *sa __plt_unused)
207 : : {
208 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
209 : :
210 : : return -ENOTSUP;
211 : : }
212 : :
213 : : int
214 [ # # ]: 0 : roc_mcs_pn_table_write(struct roc_mcs *mcs, struct roc_mcs_pn_table_write_req *pn_table)
215 : : {
216 : : struct mcs_pn_table_write_req *pn;
217 : : struct msg_rsp *rsp;
218 : :
219 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
220 : :
221 [ # # ]: 0 : if (pn_table == NULL)
222 : : return -EINVAL;
223 : :
224 : 0 : pn = mbox_alloc_msg_mcs_pn_table_write(mcs->mbox);
225 [ # # ]: 0 : if (pn == NULL)
226 : : return -ENOMEM;
227 : :
228 : 0 : pn->next_pn = pn_table->next_pn;
229 : 0 : pn->pn_id = pn_table->pn_id;
230 : 0 : pn->mcs_id = mcs->idx;
231 : 0 : pn->dir = pn_table->dir;
232 : :
233 : 0 : return mbox_process_msg(mcs->mbox, (void *)&rsp);
234 : : }
235 : :
236 : : int
237 [ # # ]: 0 : roc_mcs_pn_table_read(struct roc_mcs *mcs __plt_unused,
238 : : struct roc_mcs_pn_table_write_req *sa __plt_unused)
239 : : {
240 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
241 : :
242 : : return -ENOTSUP;
243 : : }
244 : :
245 : : int
246 [ # # ]: 0 : roc_mcs_rx_sc_cam_write(struct roc_mcs *mcs, struct roc_mcs_rx_sc_cam_write_req *rx_sc_cam)
247 : : {
248 : : struct mcs_priv *priv = roc_mcs_to_mcs_priv(mcs);
249 : : struct mcs_rx_sc_cam_write_req *rx_sc;
250 : : struct msg_rsp *rsp;
251 : : int i, rc;
252 : :
253 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
254 : :
255 [ # # ]: 0 : if (rx_sc_cam == NULL)
256 : : return -EINVAL;
257 : :
258 : 0 : rx_sc = mbox_alloc_msg_mcs_rx_sc_cam_write(mcs->mbox);
259 [ # # ]: 0 : if (rx_sc == NULL)
260 : : return -ENOMEM;
261 : :
262 : 0 : rx_sc->sci = rx_sc_cam->sci;
263 : 0 : rx_sc->secy_id = rx_sc_cam->secy_id;
264 : 0 : rx_sc->sc_id = rx_sc_cam->sc_id;
265 : 0 : rx_sc->mcs_id = mcs->idx;
266 : :
267 : 0 : rc = mbox_process_msg(mcs->mbox, (void *)&rsp);
268 [ # # ]: 0 : if (rc)
269 : : return rc;
270 : :
271 [ # # ]: 0 : for (i = 0; i < MAX_PORTS_PER_MCS; i++) {
272 [ # # ]: 0 : uint32_t set = plt_bitmap_get(priv->port_rsrc[i].secy_bmap, rx_sc_cam->secy_id);
273 : :
274 [ # # ]: 0 : if (set) {
275 : 0 : plt_bitmap_set(priv->port_rsrc[i].sc_bmap, rx_sc_cam->sc_id);
276 : 0 : break;
277 : : }
278 : : }
279 : :
280 : : return 0;
281 : : }
282 : :
283 : : int
284 [ # # ]: 0 : roc_mcs_rx_sc_cam_read(struct roc_mcs *mcs __plt_unused,
285 : : struct roc_mcs_rx_sc_cam_write_req *rx_sc_cam __plt_unused)
286 : : {
287 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
288 : :
289 : : return -ENOTSUP;
290 : : }
291 : :
292 : : int
293 [ # # ]: 0 : roc_mcs_rx_sc_cam_enable(struct roc_mcs *mcs __plt_unused,
294 : : struct roc_mcs_rx_sc_cam_write_req *rx_sc_cam __plt_unused)
295 : : {
296 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
297 : :
298 : : return -ENOTSUP;
299 : : }
300 : :
301 : : int
302 [ # # ]: 0 : roc_mcs_secy_policy_write(struct roc_mcs *mcs, struct roc_mcs_secy_plcy_write_req *secy_plcy)
303 : : {
304 : : struct mcs_secy_plcy_write_req *secy;
305 : : struct msg_rsp *rsp;
306 : :
307 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
308 : :
309 [ # # ]: 0 : if (secy_plcy == NULL)
310 : : return -EINVAL;
311 : :
312 : 0 : secy = mbox_alloc_msg_mcs_secy_plcy_write(mcs->mbox);
313 [ # # ]: 0 : if (secy == NULL)
314 : : return -ENOMEM;
315 : :
316 : 0 : secy->plcy = secy_plcy->plcy;
317 : 0 : secy->secy_id = secy_plcy->secy_id;
318 : 0 : secy->mcs_id = mcs->idx;
319 : 0 : secy->dir = secy_plcy->dir;
320 : :
321 : 0 : return mbox_process_msg(mcs->mbox, (void *)&rsp);
322 : : }
323 : :
324 : : int
325 [ # # ]: 0 : roc_mcs_secy_policy_read(struct roc_mcs *mcs __plt_unused,
326 : : struct roc_mcs_rx_sc_cam_write_req *rx_sc_cam __plt_unused)
327 : : {
328 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
329 : :
330 : : return -ENOTSUP;
331 : : }
332 : :
333 : : int
334 [ # # ]: 0 : roc_mcs_rx_sc_sa_map_write(struct roc_mcs *mcs, struct roc_mcs_rx_sc_sa_map *rx_sc_sa_map)
335 : : {
336 : : struct mcs_priv *priv = roc_mcs_to_mcs_priv(mcs);
337 : : struct mcs_rx_sc_sa_map *sa_map;
338 : : struct msg_rsp *rsp;
339 : : uint16_t sc_id;
340 : : int i, rc;
341 : :
342 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
343 : :
344 [ # # ]: 0 : if (rx_sc_sa_map == NULL)
345 : : return -EINVAL;
346 : :
347 : 0 : sc_id = rx_sc_sa_map->sc_id;
348 : 0 : sa_map = mbox_alloc_msg_mcs_rx_sc_sa_map_write(mcs->mbox);
349 [ # # ]: 0 : if (sa_map == NULL)
350 : : return -ENOMEM;
351 : :
352 : 0 : sa_map->sa_index = rx_sc_sa_map->sa_index;
353 : 0 : sa_map->sa_in_use = rx_sc_sa_map->sa_in_use;
354 : 0 : sa_map->sc_id = rx_sc_sa_map->sc_id;
355 : 0 : sa_map->an = rx_sc_sa_map->an;
356 : 0 : sa_map->mcs_id = mcs->idx;
357 : :
358 : 0 : rc = mbox_process_msg(mcs->mbox, (void *)&rsp);
359 [ # # ]: 0 : if (rc)
360 : : return rc;
361 : :
362 [ # # ]: 0 : for (i = 0; i < MAX_PORTS_PER_MCS; i++) {
363 [ # # ]: 0 : uint32_t set = plt_bitmap_get(priv->port_rsrc[i].sc_bmap, sc_id);
364 : :
365 [ # # ]: 0 : if (set) {
366 : 0 : plt_bitmap_set(priv->port_rsrc[i].sa_bmap, rx_sc_sa_map->sa_index);
367 : 0 : priv->port_rsrc[i].sc_conf[sc_id].rx.sa_idx = rx_sc_sa_map->sa_index;
368 : 0 : priv->port_rsrc[i].sc_conf[sc_id].rx.an = rx_sc_sa_map->an;
369 : 0 : break;
370 : : }
371 : : }
372 : :
373 : : return 0;
374 : : }
375 : :
376 : : int
377 [ # # ]: 0 : roc_mcs_rx_sc_sa_map_read(struct roc_mcs *mcs __plt_unused,
378 : : struct roc_mcs_rx_sc_sa_map *rx_sc_sa_map __plt_unused)
379 : : {
380 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
381 : :
382 : : return -ENOTSUP;
383 : : }
384 : :
385 : : int
386 [ # # ]: 0 : roc_mcs_tx_sc_sa_map_write(struct roc_mcs *mcs, struct roc_mcs_tx_sc_sa_map *tx_sc_sa_map)
387 : : {
388 : : struct mcs_priv *priv = roc_mcs_to_mcs_priv(mcs);
389 : : struct mcs_tx_sc_sa_map *sa_map;
390 : : struct msg_rsp *rsp;
391 : : uint16_t sc_id;
392 : : int i, rc;
393 : :
394 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
395 : :
396 [ # # ]: 0 : if (tx_sc_sa_map == NULL)
397 : : return -EINVAL;
398 : :
399 : 0 : sa_map = mbox_alloc_msg_mcs_tx_sc_sa_map_write(mcs->mbox);
400 [ # # ]: 0 : if (sa_map == NULL)
401 : : return -ENOMEM;
402 : :
403 : 0 : sa_map->sa_index0 = tx_sc_sa_map->sa_index0;
404 : 0 : sa_map->sa_index1 = tx_sc_sa_map->sa_index1;
405 : 0 : sa_map->rekey_ena = tx_sc_sa_map->rekey_ena;
406 : 0 : sa_map->sa_index0_vld = tx_sc_sa_map->sa_index0_vld;
407 : 0 : sa_map->sa_index1_vld = tx_sc_sa_map->sa_index1_vld;
408 : 0 : sa_map->tx_sa_active = tx_sc_sa_map->tx_sa_active;
409 : 0 : sa_map->sectag_sci = tx_sc_sa_map->sectag_sci;
410 : 0 : sa_map->sc_id = tx_sc_sa_map->sc_id;
411 : 0 : sa_map->mcs_id = mcs->idx;
412 : :
413 : 0 : rc = mbox_process_msg(mcs->mbox, (void *)&rsp);
414 [ # # ]: 0 : if (rc)
415 : : return rc;
416 : :
417 : 0 : sc_id = tx_sc_sa_map->sc_id;
418 [ # # ]: 0 : for (i = 0; i < MAX_PORTS_PER_MCS; i++) {
419 [ # # ]: 0 : uint32_t set = plt_bitmap_get(priv->port_rsrc[i].sc_bmap, sc_id + priv->sc_entries);
420 : :
421 [ # # ]: 0 : if (set) {
422 : 0 : uint32_t pos = priv->sa_entries + tx_sc_sa_map->sa_index0;
423 : :
424 : 0 : plt_bitmap_set(priv->port_rsrc[i].sa_bmap, pos);
425 : 0 : priv->port_rsrc[i].sc_conf[sc_id].tx.sa_idx0 = tx_sc_sa_map->sa_index0;
426 : 0 : pos = priv->sa_entries + tx_sc_sa_map->sa_index1;
427 : 0 : plt_bitmap_set(priv->port_rsrc[i].sa_bmap, pos);
428 : 0 : priv->port_rsrc[i].sc_conf[sc_id].tx.sa_idx1 = tx_sc_sa_map->sa_index1;
429 : 0 : priv->port_rsrc[i].sc_conf[sc_id].tx.sci = tx_sc_sa_map->sectag_sci;
430 : 0 : priv->port_rsrc[i].sc_conf[sc_id].tx.rekey_enb = tx_sc_sa_map->rekey_ena;
431 : 0 : break;
432 : : }
433 : : }
434 : :
435 : : return 0;
436 : : }
437 : :
438 : : int
439 [ # # ]: 0 : roc_mcs_tx_sc_sa_map_read(struct roc_mcs *mcs __plt_unused,
440 : : struct roc_mcs_tx_sc_sa_map *tx_sc_sa_map __plt_unused)
441 : : {
442 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
443 : :
444 : : return -ENOTSUP;
445 : : }
446 : :
447 : : int
448 [ # # ]: 0 : roc_mcs_flowid_entry_write(struct roc_mcs *mcs, struct roc_mcs_flowid_entry_write_req *flowid_req)
449 : : {
450 : : struct mcs_priv *priv = roc_mcs_to_mcs_priv(mcs);
451 : : struct mcs_flowid_entry_write_req *flow_req;
452 : : struct msg_rsp *rsp;
453 : : uint8_t port;
454 : : int rc;
455 : :
456 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
457 : :
458 [ # # ]: 0 : if (flowid_req == NULL)
459 : : return -EINVAL;
460 : :
461 : 0 : flow_req = mbox_alloc_msg_mcs_flowid_entry_write(mcs->mbox);
462 [ # # ]: 0 : if (flow_req == NULL)
463 : : return -ENOMEM;
464 : :
465 : 0 : mbox_memcpy(flow_req->data, flowid_req->data, sizeof(uint64_t) * 4);
466 : 0 : mbox_memcpy(flow_req->mask, flowid_req->mask, sizeof(uint64_t) * 4);
467 : 0 : flow_req->sci = flowid_req->sci;
468 : 0 : flow_req->flow_id = flowid_req->flow_id;
469 : 0 : flow_req->secy_id = flowid_req->secy_id;
470 : 0 : flow_req->sc_id = flowid_req->sc_id;
471 : 0 : flow_req->ena = flowid_req->ena;
472 : 0 : flow_req->ctr_pkt = flowid_req->ctr_pkt;
473 : 0 : flow_req->mcs_id = mcs->idx;
474 : 0 : flow_req->dir = flowid_req->dir;
475 : :
476 : 0 : rc = mbox_process_msg(mcs->mbox, (void *)&rsp);
477 [ # # ]: 0 : if (rc)
478 : : return rc;
479 : :
480 [ # # ]: 0 : if (flow_req->mask[3] & (BIT_ULL(10) | BIT_ULL(11)))
481 : : return rc;
482 : :
483 : 0 : port = (flow_req->data[3] >> 10) & 0x3;
484 : :
485 : 0 : plt_bitmap_set(priv->port_rsrc[port].tcam_bmap,
486 : 0 : flowid_req->flow_id +
487 [ # # ]: 0 : ((flowid_req->dir == MCS_TX) ? priv->tcam_entries : 0));
488 : 0 : plt_bitmap_set(priv->port_rsrc[port].secy_bmap,
489 : 0 : flowid_req->secy_id +
490 [ # # ]: 0 : ((flowid_req->dir == MCS_TX) ? priv->secy_entries : 0));
491 : :
492 [ # # ]: 0 : if (flowid_req->dir == MCS_TX)
493 : 0 : plt_bitmap_set(priv->port_rsrc[port].sc_bmap, priv->sc_entries + flowid_req->sc_id);
494 : :
495 : : return 0;
496 : : }
497 : :
498 : : int
499 [ # # ]: 0 : roc_mcs_flowid_entry_read(struct roc_mcs *mcs __plt_unused,
500 : : struct roc_mcs_flowid_entry_write_req *flowid_rsp __plt_unused)
501 : : {
502 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
503 : :
504 : : return -ENOTSUP;
505 : : }
506 : :
507 : : int
508 [ # # ]: 0 : roc_mcs_flowid_entry_enable(struct roc_mcs *mcs, struct roc_mcs_flowid_ena_dis_entry *entry)
509 : : {
510 : : struct mcs_flowid_ena_dis_entry *flow_entry;
511 : : struct msg_rsp *rsp;
512 : :
513 [ # # # # ]: 0 : MCS_SUPPORT_CHECK;
514 : :
515 [ # # ]: 0 : if (entry == NULL)
516 : : return -EINVAL;
517 : :
518 : 0 : flow_entry = mbox_alloc_msg_mcs_flowid_ena_entry(mcs->mbox);
519 [ # # ]: 0 : if (flow_entry == NULL)
520 : : return -ENOMEM;
521 : :
522 : 0 : flow_entry->flow_id = entry->flow_id;
523 : 0 : flow_entry->ena = entry->ena;
524 : 0 : flow_entry->mcs_id = mcs->idx;
525 : 0 : flow_entry->dir = entry->dir;
526 : :
527 : 0 : return mbox_process_msg(mcs->mbox, (void *)&rsp);
528 : : }
529 : :
530 : : void
531 : 0 : roc_mcs_sa_port_map_update(struct roc_mcs *mcs, int sa_id, uint8_t port_id)
532 : : {
533 : 0 : mcs->sa_port_map[sa_id] = port_id;
534 : 0 : }
|