Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2021 Marvell.
3 : : */
4 : :
5 : : #include "roc_api.h"
6 : : #include "roc_priv.h"
7 : :
8 : : uint8_t
9 : 0 : roc_npc_get_key_type(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
10 : : {
11 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
12 : :
13 : 0 : return npc_get_key_type(npc, flow);
14 : : }
15 : :
16 : : uint8_t
17 : 0 : roc_npc_kex_key_type_config_get(struct roc_npc *roc_npc)
18 : : {
19 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
20 : :
21 : 0 : return npc_kex_key_type_config_get(npc);
22 : : }
23 : :
24 : : int
25 : 0 : roc_npc_mark_actions_get(struct roc_npc *roc_npc)
26 : : {
27 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
28 : :
29 : 0 : return npc->mark_actions;
30 : : }
31 : :
32 : : int
33 : 0 : roc_npc_mark_actions_sub_return(struct roc_npc *roc_npc, uint32_t count)
34 : : {
35 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
36 : :
37 : 0 : npc->mark_actions -= count;
38 : 0 : return npc->mark_actions;
39 : : }
40 : :
41 : : int
42 : 0 : roc_npc_vtag_actions_get(struct roc_npc *roc_npc)
43 : : {
44 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
45 : :
46 : 0 : return npc->vtag_strip_actions;
47 : : }
48 : :
49 : : int
50 : 0 : roc_npc_vtag_actions_sub_return(struct roc_npc *roc_npc, uint32_t count)
51 : : {
52 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
53 : :
54 : 0 : npc->vtag_strip_actions -= count;
55 : 0 : return npc->vtag_strip_actions;
56 : : }
57 : :
58 : : int
59 : 0 : roc_npc_mcam_free_counter(struct roc_npc *roc_npc, uint16_t ctr_id)
60 : : {
61 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
62 : :
63 : 0 : return npc_mcam_free_counter(npc->mbox, ctr_id);
64 : : }
65 : :
66 : : int
67 : 0 : roc_npc_inl_mcam_read_counter(uint32_t ctr_id, uint64_t *count)
68 : : {
69 : : struct nix_inl_dev *inl_dev = NULL;
70 : : struct idev_cfg *idev;
71 : :
72 : 0 : idev = idev_get_cfg();
73 [ # # ]: 0 : if (idev)
74 : 0 : inl_dev = idev->nix_inl_dev;
75 [ # # ]: 0 : if (!inl_dev)
76 : : return 0;
77 : 0 : return npc_mcam_read_counter(inl_dev->dev.mbox, ctr_id, count);
78 : : }
79 : :
80 : : int
81 : 0 : roc_npc_inl_mcam_clear_counter(uint32_t ctr_id)
82 : : {
83 : : struct nix_inl_dev *inl_dev = NULL;
84 : : struct idev_cfg *idev;
85 : :
86 : 0 : idev = idev_get_cfg();
87 [ # # ]: 0 : if (idev)
88 : 0 : inl_dev = idev->nix_inl_dev;
89 [ # # ]: 0 : if (!inl_dev)
90 : : return 0;
91 : :
92 : 0 : return npc_mcam_clear_counter(inl_dev->dev.mbox, ctr_id);
93 : : }
94 : :
95 : : int
96 : 0 : roc_npc_mcam_alloc_counter(struct roc_npc *roc_npc, uint16_t *ctr_id)
97 : : {
98 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
99 : :
100 : 0 : return npc_mcam_alloc_counter(npc->mbox, ctr_id);
101 : : }
102 : :
103 : : int
104 : 0 : roc_npc_get_free_mcam_entry(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
105 : : {
106 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
107 : :
108 : 0 : return npc_get_free_mcam_entry(npc->mbox, flow, npc);
109 : : }
110 : :
111 : : int
112 : 0 : roc_npc_mcam_read_counter(struct roc_npc *roc_npc, uint32_t ctr_id, uint64_t *count)
113 : : {
114 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
115 : :
116 : 0 : return npc_mcam_read_counter(npc->mbox, ctr_id, count);
117 : : }
118 : :
119 : : int
120 : 0 : roc_npc_mcam_get_stats(struct roc_npc *roc_npc, struct roc_npc_flow *flow, uint64_t *count)
121 : : {
122 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
123 : :
124 : 0 : return npc_mcam_get_stats(npc->mbox, flow, count);
125 : : }
126 : :
127 : : int
128 : 0 : roc_npc_mcam_clear_counter(struct roc_npc *roc_npc, uint32_t ctr_id)
129 : : {
130 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
131 : :
132 : 0 : return npc_mcam_clear_counter(npc->mbox, ctr_id);
133 : : }
134 : :
135 : : int
136 : 0 : roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry)
137 : : {
138 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
139 : :
140 : 0 : return npc_mcam_free_entry(npc->mbox, entry);
141 : : }
142 : :
143 : : int
144 : 0 : roc_npc_mcam_free(struct roc_npc *roc_npc, struct roc_npc_flow *mcam)
145 : : {
146 : : int rc = 0;
147 : :
148 [ # # ]: 0 : if (mcam->use_ctr) {
149 : 0 : rc = roc_npc_mcam_clear_counter(roc_npc, mcam->ctr_id);
150 [ # # ]: 0 : if (rc)
151 : : return rc;
152 : :
153 : 0 : rc = roc_npc_mcam_free_counter(roc_npc, mcam->ctr_id);
154 [ # # ]: 0 : if (rc)
155 : : return rc;
156 : : }
157 : :
158 : 0 : return roc_npc_mcam_free_entry(roc_npc, mcam->mcam_id);
159 : : }
160 : :
161 : : int
162 : 0 : roc_npc_mcam_init(struct roc_npc *roc_npc, struct roc_npc_flow *flow,
163 : : int mcam_id)
164 : : {
165 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
166 : : int rc;
167 : :
168 : 0 : rc = npc_mcam_init(npc, flow, mcam_id);
169 [ # # ]: 0 : if (rc != 0) {
170 : 0 : plt_err("npc: mcam initialisation write failed");
171 : 0 : return rc;
172 : : }
173 : : return 0;
174 : : }
175 : :
176 : : int
177 : 0 : roc_npc_mcam_move(struct roc_npc *roc_npc, uint16_t old_ent, uint16_t new_ent)
178 : : {
179 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
180 : 0 : struct mbox *mbox = npc->mbox;
181 : : int rc;
182 : :
183 : 0 : rc = npc_mcam_move(mbox, old_ent, new_ent);
184 [ # # ]: 0 : if (rc)
185 : 0 : return rc;
186 : :
187 : : return 0;
188 : : }
189 : :
190 : : int
191 : 0 : roc_npc_mcam_free_all_resources(struct roc_npc *roc_npc)
192 : : {
193 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
194 : :
195 : 0 : return npc_flow_free_all_resources(npc);
196 : : }
197 : :
198 : : int
199 : 0 : roc_npc_mcam_alloc_entries(struct roc_npc *roc_npc, int ref_entry, int *alloc_entry, int req_count,
200 : : int priority, int *resp_count, bool is_conti)
201 : : {
202 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
203 : :
204 : 0 : return npc_mcam_alloc_entries(npc->mbox, ref_entry, alloc_entry, req_count, priority,
205 : : resp_count, is_conti);
206 : : }
207 : :
208 : : int
209 : 0 : roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, bool enable)
210 : : {
211 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
212 : :
213 : 0 : return npc_flow_enable_all_entries(npc, enable);
214 : : }
215 : :
216 : : void
217 : 0 : roc_npc_defrag_mcam_banks(struct roc_npc *roc_npc)
218 : : {
219 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
220 : 0 : struct mbox *mbox = mbox_get(npc->mbox);
221 : : struct npc_mcam_defrag_req *req;
222 : : struct npc_mcam_defrag_rsp *rsp;
223 : : int rc = 0;
224 : :
225 : 0 : req = (struct npc_mcam_defrag_req *)mbox_alloc_msg_npc_defrag(mbox);
226 [ # # ]: 0 : if (req == NULL)
227 : 0 : goto exit;
228 : :
229 : : rc = mbox_process_msg(mbox, (void *)&rsp);
230 [ # # ]: 0 : if (rc)
231 : 0 : plt_err("Error when defragmenting MCAM banks.");
232 : :
233 : 0 : exit:
234 : : mbox_put(mbox);
235 : 0 : }
236 : :
237 : : int
238 : 0 : roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam,
239 : : struct roc_npc_flow *ref_mcam, int prio, int *resp_count)
240 : : {
241 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
242 : :
243 : 0 : return npc_mcam_alloc_entry(npc, mcam, ref_mcam, prio, resp_count);
244 : : }
245 : :
246 : : int
247 : 0 : roc_npc_mcam_ena_dis_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam,
248 : : bool enable)
249 : : {
250 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
251 : :
252 : 0 : return npc_mcam_ena_dis_entry(npc, mcam, enable);
253 : : }
254 : :
255 : : int
256 : 0 : roc_npc_mcam_write_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam)
257 : : {
258 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
259 : :
260 : 0 : return npc_mcam_write_entry(npc->mbox, mcam);
261 : : }
262 : :
263 : : int
264 [ # # ]: 0 : roc_npc_get_low_priority_mcam(struct roc_npc *roc_npc)
265 : : {
266 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
267 : :
268 [ # # ]: 0 : if (roc_model_is_cn20k())
269 : 0 : return (npc->mcam_entries - NPC_MCAME_RESVD_10XX - 1);
270 [ # # ]: 0 : else if (roc_model_is_cn10k())
271 : 0 : return (npc->mcam_entries - NPC_MCAME_RESVD_10XX - 1);
272 [ # # ]: 0 : else if (roc_model_is_cn98xx())
273 : 0 : return (npc->mcam_entries - NPC_MCAME_RESVD_98XX - 1);
274 : : else
275 : 0 : return (npc->mcam_entries - NPC_MCAME_RESVD_9XXX - 1);
276 : : }
277 : :
278 : : static int
279 : : npc_mcam_tot_entries(void)
280 : : {
281 : : /* FIXME: change to reading in AF from NPC_AF_CONST1/2
282 : : * MCAM_BANK_DEPTH(_EXT) * MCAM_BANKS
283 : : */
284 [ # # ]: 0 : if (roc_model_is_cn20k())
285 : : return 2 * 8192; /* MCAM_BANKS = 2, BANK_DEPTH_EXT = 8192 */
286 [ # # # # ]: 0 : else if (roc_model_is_cn10k() || roc_model_is_cn98xx())
287 : : return 16 * 1024; /* MCAM_BANKS = 4, BANK_DEPTH_EXT = 4096 */
288 : : else
289 : 0 : return 4 * 1024; /* MCAM_BANKS = 4, BANK_DEPTH_EXT = 1024 */
290 : : }
291 : :
292 : : const char *
293 : 0 : roc_npc_profile_name_get(struct roc_npc *roc_npc)
294 : : {
295 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
296 : :
297 : 0 : return (char *)npc->profile_name;
298 : : }
299 : :
300 : : int
301 : 0 : roc_npc_kex_capa_get(struct roc_nix *roc_nix, uint64_t *kex_capability)
302 : : {
303 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
304 : : struct npc npc;
305 : : int rc = 0;
306 : :
307 : : memset(&npc, 0, sizeof(npc));
308 : :
309 : 0 : npc.mbox = (&nix->dev)->mbox;
310 : :
311 : 0 : rc = npc_mcam_fetch_kex_cfg(&npc);
312 [ # # ]: 0 : if (rc)
313 : : return rc;
314 : :
315 : 0 : rc = npc_mcam_fetch_hw_cap(&npc, &npc.hash_extract_cap);
316 [ # # ]: 0 : if (rc)
317 : : return rc;
318 : :
319 : 0 : *kex_capability = npc_get_kex_capability(&npc);
320 : :
321 : 0 : return 0;
322 : : }
323 : :
324 : : int
325 : 0 : roc_npc_init(struct roc_npc *roc_npc)
326 : : {
327 : : uint8_t *mem = NULL, *nix_mem = NULL, *npc_mem = NULL;
328 [ # # ]: 0 : struct nix *nix = roc_nix_to_nix_priv(roc_npc->roc_nix);
329 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
330 : : uint32_t bmap_sz;
331 : : int rc = 0, idx;
332 : : size_t sz;
333 : :
334 : : PLT_STATIC_ASSERT(sizeof(struct npc) <= ROC_NPC_MEM_SZ);
335 : :
336 : : memset(npc, 0, sizeof(*npc));
337 : 0 : npc->mbox = (&nix->dev)->mbox;
338 : 0 : roc_npc->channel = nix->rx_chan_base;
339 : 0 : roc_npc->pf_func = (&nix->dev)->pf_func;
340 : 0 : npc->channel = roc_npc->channel;
341 : 0 : npc->pf_func = roc_npc->pf_func;
342 : 0 : npc->flow_max_priority = roc_npc->flow_max_priority;
343 : 0 : npc->switch_header_type = roc_npc->switch_header_type;
344 : 0 : npc->flow_prealloc_size = roc_npc->flow_prealloc_size;
345 : :
346 [ # # ]: 0 : if (npc->mbox == NULL)
347 : : return NPC_ERR_PARAM;
348 : :
349 : 0 : rc = npc_mcam_fetch_kex_cfg(npc);
350 [ # # ]: 0 : if (rc)
351 : 0 : goto done;
352 : :
353 : 0 : rc = npc_mcam_fetch_hw_cap(npc, &npc->hash_extract_cap);
354 [ # # ]: 0 : if (rc)
355 : 0 : goto done;
356 : :
357 : 0 : roc_npc->kex_capability = npc_get_kex_capability(npc);
358 [ # # ]: 0 : roc_npc->rx_parse_nibble = npc->keyx_supp_nmask[NPC_MCAM_RX];
359 : :
360 : 0 : npc->mcam_entries = npc_mcam_tot_entries() >> npc->keyw[NPC_MCAM_RX];
361 : 0 : nix->exact_match_ena = npc->exact_match_ena;
362 : 0 : roc_npc->max_entries = npc->mcam_entries;
363 : :
364 : : /* Free, free_rev, live and live_rev entries */
365 : 0 : bmap_sz = plt_bitmap_get_memory_footprint(npc->mcam_entries);
366 : 0 : mem = plt_zmalloc(4 * bmap_sz * npc->flow_max_priority, 0);
367 [ # # ]: 0 : if (mem == NULL) {
368 : 0 : plt_err("Bmap alloc failed");
369 : : rc = NPC_ERR_NO_MEM;
370 : 0 : return rc;
371 : : }
372 : :
373 : 0 : sz = npc->flow_max_priority * sizeof(struct npc_flow_list);
374 : 0 : npc->flow_list = plt_zmalloc(sz, 0);
375 [ # # ]: 0 : if (npc->flow_list == NULL) {
376 : 0 : plt_err("flow_list alloc failed");
377 : : rc = NPC_ERR_NO_MEM;
378 : 0 : goto done;
379 : : }
380 : :
381 : 0 : sz = npc->flow_max_priority * sizeof(struct npc_prio_flow_list_head);
382 : 0 : npc->prio_flow_list = plt_zmalloc(sz, 0);
383 [ # # ]: 0 : if (npc->prio_flow_list == NULL) {
384 : 0 : plt_err("prio_flow_list alloc failed");
385 : : rc = NPC_ERR_NO_MEM;
386 : 0 : goto done;
387 : : }
388 : :
389 : : npc_mem = mem;
390 : :
391 : 0 : TAILQ_INIT(&npc->ipsec_list);
392 : 0 : TAILQ_INIT(&npc->age_flow_list);
393 [ # # ]: 0 : for (idx = 0; idx < npc->flow_max_priority; idx++) {
394 : 0 : TAILQ_INIT(&npc->flow_list[idx]);
395 : 0 : TAILQ_INIT(&npc->prio_flow_list[idx]);
396 : : }
397 : :
398 : 0 : npc->rss_grps = NPC_RSS_GRPS;
399 : :
400 : 0 : bmap_sz = plt_bitmap_get_memory_footprint(npc->rss_grps);
401 : 0 : nix_mem = plt_zmalloc(bmap_sz, 0);
402 [ # # ]: 0 : if (nix_mem == NULL) {
403 : 0 : plt_err("Bmap alloc failed");
404 : : rc = NPC_ERR_NO_MEM;
405 : 0 : goto done;
406 : : }
407 : :
408 : 0 : npc->rss_grp_entries = plt_bitmap_init(npc->rss_grps, nix_mem, bmap_sz);
409 : :
410 [ # # ]: 0 : if (!npc->rss_grp_entries) {
411 : 0 : plt_err("bitmap init failed");
412 : : rc = NPC_ERR_NO_MEM;
413 : 0 : goto done;
414 : : }
415 : :
416 : : /* Group 0 will be used for RSS,
417 : : * 1 -7 will be used for npc_flow RSS action
418 : : */
419 : : plt_bitmap_set(npc->rss_grp_entries, 0);
420 : :
421 : 0 : roc_npc->flow_age.age_flow_refcnt = 0;
422 : :
423 : 0 : return rc;
424 : :
425 : 0 : done:
426 [ # # ]: 0 : if (npc->flow_list)
427 : 0 : plt_free(npc->flow_list);
428 [ # # ]: 0 : if (npc->prio_flow_list)
429 : 0 : plt_free(npc->prio_flow_list);
430 [ # # ]: 0 : if (npc_mem)
431 : 0 : plt_free(npc_mem);
432 : : return rc;
433 : : }
434 : :
435 : : int
436 [ # # ]: 0 : roc_npc_fini(struct roc_npc *roc_npc)
437 : : {
438 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
439 : : int rc;
440 : :
441 [ # # ]: 0 : if (!roc_npc->flow_age.aged_flows_get_thread_exit)
442 : 0 : npc_aging_ctrl_thread_destroy(roc_npc);
443 : :
444 : 0 : rc = npc_flow_free_all_resources(npc);
445 [ # # ]: 0 : if (rc) {
446 : 0 : plt_err("Error when deleting NPC MCAM entries, counters");
447 : 0 : return rc;
448 : : }
449 : :
450 [ # # ]: 0 : if (npc->flow_list) {
451 : 0 : plt_free(npc->flow_list);
452 : 0 : npc->flow_list = NULL;
453 : : }
454 : :
455 [ # # ]: 0 : if (npc->prio_flow_list) {
456 : 0 : plt_free(npc->prio_flow_list);
457 : 0 : npc->prio_flow_list = NULL;
458 : : }
459 : :
460 : : return 0;
461 : : }
462 : :
463 : : int
464 : 0 : roc_npc_validate_portid_action(struct roc_npc *roc_npc_src,
465 : : struct roc_npc *roc_npc_dst)
466 : : {
467 : 0 : struct roc_nix *roc_nix_src = roc_npc_src->roc_nix;
468 : : struct nix *nix_src = roc_nix_to_nix_priv(roc_nix_src);
469 : 0 : struct roc_nix *roc_nix_dst = roc_npc_dst->roc_nix;
470 : : struct nix *nix_dst = roc_nix_to_nix_priv(roc_nix_dst);
471 : :
472 [ # # ]: 0 : if (roc_nix_is_pf(roc_npc_dst->roc_nix)) {
473 : 0 : plt_err("Output port should be VF");
474 : 0 : return -EINVAL;
475 : : }
476 : :
477 [ # # ]: 0 : if (nix_dst->dev.vf >= nix_src->dev.maxvf) {
478 : 0 : plt_err("Invalid VF for output port");
479 : 0 : return -EINVAL;
480 : : }
481 : :
482 [ # # ]: 0 : if (nix_src->dev.pf != nix_dst->dev.pf) {
483 : 0 : plt_err("Output port should be VF of ingress PF");
484 : 0 : return -EINVAL;
485 : : }
486 : : return 0;
487 : : }
488 : :
489 : : static int
490 : 0 : npc_parse_spi_to_sa_action(struct roc_npc *roc_npc, const struct roc_npc_action *act,
491 : : struct roc_npc_flow *flow, uint8_t *has_spi_to_sa_action)
492 : : {
493 : : const struct roc_npc_sec_action *sec_action;
494 : : struct nix_spi_to_sa_add_req *req;
495 : : struct nix_spi_to_sa_add_rsp *rsp;
496 : : struct nix_inl_dev *inl_dev;
497 : : struct idev_cfg *idev;
498 : : union {
499 : : uint64_t reg;
500 : : union nix_rx_vtag_action_u act;
501 : : } vtag_act;
502 : : struct mbox *mbox;
503 : : int rc;
504 : :
505 [ # # # # ]: 0 : if (roc_npc->roc_nix->custom_sa_action == 0 || roc_model_is_cn9k() == 1 ||
506 [ # # # # ]: 0 : act->conf == NULL || flow->is_validate)
507 : : return 0;
508 : :
509 : 0 : *has_spi_to_sa_action = true;
510 : 0 : sec_action = act->conf;
511 : :
512 : 0 : vtag_act.reg = 0;
513 : 0 : vtag_act.act.sa_xor = sec_action->sa_xor;
514 : 0 : vtag_act.act.sa_hi = sec_action->sa_hi;
515 : 0 : vtag_act.act.sa_lo = sec_action->sa_lo;
516 : :
517 : 0 : idev = idev_get_cfg();
518 [ # # ]: 0 : if (!idev)
519 : : return -1;
520 : :
521 : 0 : inl_dev = idev->nix_inl_dev;
522 : :
523 [ # # # # : 0 : switch (sec_action->alg) {
# # ]
524 : : case ROC_NPC_SEC_ACTION_ALG0:
525 : : break;
526 : 0 : case ROC_NPC_SEC_ACTION_ALG1:
527 : : vtag_act.act.vtag1_valid = false;
528 : 0 : vtag_act.act.vtag1_lid = ROC_NPC_SEC_ACTION_ALG1;
529 : 0 : break;
530 : 0 : case ROC_NPC_SEC_ACTION_ALG2:
531 : : vtag_act.act.vtag1_valid = false;
532 : 0 : vtag_act.act.vtag1_lid = ROC_NPC_SEC_ACTION_ALG2;
533 : 0 : break;
534 : 0 : case ROC_NPC_SEC_ACTION_ALG3:
535 : : vtag_act.act.vtag1_valid = false;
536 : 0 : vtag_act.act.vtag1_lid = ROC_NPC_SEC_ACTION_ALG3;
537 : 0 : break;
538 : 0 : case ROC_NPC_SEC_ACTION_ALG4:
539 : : vtag_act.act.vtag1_valid = false;
540 : : vtag_act.act.vtag1_lid = 0;
541 : 0 : mbox = inl_dev->dev.mbox;
542 : 0 : req = mbox_alloc_msg_nix_spi_to_sa_add(mbox);
543 [ # # ]: 0 : if (req == NULL)
544 : : return -ENOSPC;
545 : 0 : req->sa_index = sec_action->sa_index;
546 [ # # ]: 0 : req->spi_index = plt_be_to_cpu_32(flow->spi_to_sa_info.spi);
547 : 0 : req->match_id = flow->match_id;
548 : 0 : req->valid = true;
549 : : rc = mbox_process_msg(mbox, (void *)&rsp);
550 [ # # ]: 0 : if (rc)
551 : : return rc;
552 : 0 : flow->spi_to_sa_info.hash_index = rsp->hash_index;
553 : 0 : flow->spi_to_sa_info.way = rsp->way;
554 : 0 : flow->spi_to_sa_info.duplicate = rsp->is_duplicate;
555 : 0 : flow->spi_to_sa_info.has_action = true;
556 : 0 : break;
557 : : default:
558 : : return -1;
559 : : }
560 : :
561 : 0 : flow->vtag_action = vtag_act.reg;
562 : :
563 : 0 : return 0;
564 : : }
565 : :
566 : : static int
567 : 0 : roc_npc_process_sample_action(struct roc_npc *roc_npc,
568 : : const struct roc_npc_action_sample *sample_action,
569 : : struct roc_npc_flow *flow)
570 : : {
571 : 0 : struct nix *nix = roc_nix_to_nix_priv(roc_npc->roc_nix);
572 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
573 : :
574 : 0 : flow->is_sampling_rule = true;
575 : :
576 [ # # # # ]: 0 : switch (sample_action->action_type) {
577 : 0 : case ROC_NPC_ACTION_TYPE_PORT_ID:
578 : 0 : flow->mcast_pf_funcs[0] = sample_action->pf_func;
579 : 0 : flow->mcast_channels[0] = sample_action->channel;
580 : 0 : break;
581 : 0 : case ROC_NPC_ACTION_TYPE_PF:
582 : 0 : flow->mcast_pf_funcs[0] = roc_npc->pf_func;
583 : 0 : flow->mcast_channels[0] = npc->channel;
584 : 0 : break;
585 : 0 : case ROC_NPC_ACTION_TYPE_VF:
586 [ # # ]: 0 : if (sample_action->pf_func >= nix->dev.maxvf)
587 : : return -EINVAL;
588 : 0 : flow->mcast_pf_funcs[0] =
589 : 0 : ((roc_npc->pf_func & 0xfc00) | (sample_action->pf_func + 1));
590 : 0 : flow->mcast_channels[0] = npc->channel;
591 : 0 : break;
592 : : default:
593 : : return -EINVAL;
594 : : }
595 : :
596 : : return 0;
597 : : }
598 : :
599 : : static int
600 : 0 : npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
601 : : const struct roc_npc_action actions[], struct roc_npc_flow *flow,
602 : : uint16_t dst_pf_func)
603 : : {
604 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
605 : : const struct roc_npc_action *sec_action = NULL;
606 : : const struct roc_npc_action_sample *act_sample;
607 : 0 : struct roc_nix *roc_nix = roc_npc->roc_nix;
608 : : const struct roc_npc_action_mark *act_mark;
609 : : const struct roc_npc_action_meter *act_mtr;
610 : : const struct roc_npc_action_queue *act_q;
611 : : const struct roc_npc_action_vf *vf_act;
612 : : bool vlan_insert_action = false;
613 : 0 : uint8_t has_spi_to_sa_act = 0;
614 : : int sel_act, req_act = 0;
615 : : uint16_t pf_func, vf_id;
616 : : int errcode = 0;
617 : : int mark = 0;
618 : : int rq = 0;
619 : : int rc = 0;
620 : :
621 : : /* Initialize actions */
622 : 0 : flow->ctr_id = NPC_COUNTER_NONE;
623 : 0 : flow->mtr_id = ROC_NIX_MTR_ID_INVALID;
624 : 0 : pf_func = npc->pf_func;
625 [ # # ]: 0 : if (flow->has_rep)
626 : 0 : pf_func = flow->rep_pf_func;
627 : :
628 [ # # ]: 0 : for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) {
629 [ # # # # : 0 : switch (actions->type) {
# # # # #
# # # # #
# # # #
# ]
630 : : case ROC_NPC_ACTION_TYPE_VOID:
631 : : break;
632 : 0 : case ROC_NPC_ACTION_TYPE_MARK:
633 : 0 : act_mark = (const struct roc_npc_action_mark *)
634 : : actions->conf;
635 [ # # ]: 0 : if (act_mark->id > (NPC_FLOW_FLAG_VAL - 2)) {
636 : 0 : plt_err("mark value must be < 0xfffe");
637 : 0 : goto err_exit;
638 : : }
639 : 0 : mark = act_mark->id + 1;
640 : 0 : req_act |= ROC_NPC_ACTION_TYPE_MARK;
641 : 0 : npc->mark_actions += 1;
642 : 0 : flow->match_id = mark;
643 : 0 : break;
644 : :
645 : 0 : case ROC_NPC_ACTION_TYPE_FLAG:
646 : : mark = NPC_FLOW_FLAG_VAL;
647 : 0 : req_act |= ROC_NPC_ACTION_TYPE_FLAG;
648 : 0 : npc->mark_actions += 1;
649 : 0 : break;
650 : :
651 : 0 : case ROC_NPC_ACTION_TYPE_COUNT:
652 : : /* Indicates, need a counter */
653 : 0 : flow->use_ctr = 1;
654 : 0 : req_act |= ROC_NPC_ACTION_TYPE_COUNT;
655 : 0 : break;
656 : :
657 : 0 : case ROC_NPC_ACTION_TYPE_DROP:
658 : 0 : req_act |= ROC_NPC_ACTION_TYPE_DROP;
659 : 0 : break;
660 : :
661 : 0 : case ROC_NPC_ACTION_TYPE_PF:
662 : 0 : req_act |= ROC_NPC_ACTION_TYPE_PF;
663 : 0 : pf_func &= (0xfc00);
664 : 0 : break;
665 : :
666 : 0 : case ROC_NPC_ACTION_TYPE_VF:
667 : 0 : vf_act = (const struct roc_npc_action_vf *)actions->conf;
668 [ # # ]: 0 : req_act |= ROC_NPC_ACTION_TYPE_VF;
669 [ # # ]: 0 : if (roc_model_is_cn20k())
670 : 0 : vf_id = vf_act->id & RVU_PFVF_FUNC_MASK_CN20K;
671 : : else
672 : 0 : vf_id = vf_act->id & RVU_PFVF_FUNC_MASK;
673 : 0 : pf_func &= (0xfc00);
674 : 0 : pf_func = (pf_func | (vf_id + 1));
675 : 0 : break;
676 : :
677 : 0 : case ROC_NPC_ACTION_TYPE_PORT_ID:
678 : : pf_func = dst_pf_func;
679 : 0 : req_act |= ROC_NPC_ACTION_TYPE_VF;
680 : 0 : break;
681 : :
682 : 0 : case ROC_NPC_ACTION_TYPE_QUEUE:
683 : 0 : act_q = (const struct roc_npc_action_queue *)actions->conf;
684 : 0 : rq = act_q->index & 0xFFFFF;
685 : 0 : req_act |= ROC_NPC_ACTION_TYPE_QUEUE;
686 : 0 : break;
687 : :
688 : 0 : case ROC_NPC_ACTION_TYPE_RSS:
689 : 0 : req_act |= ROC_NPC_ACTION_TYPE_RSS;
690 : 0 : break;
691 : :
692 : 0 : case ROC_NPC_ACTION_TYPE_SEC:
693 : : /* Assumes user has already configured security
694 : : * session for this flow. Associated conf is
695 : : * opaque. When security is implemented,
696 : : * we need to verify that for specified security
697 : : * session:
698 : : * action_type ==
699 : : * NPC_SECURITY_ACTION_TYPE_INLINE_PROTOCOL &&
700 : : * session_protocol ==
701 : : * NPC_SECURITY_PROTOCOL_IPSEC
702 : : */
703 : 0 : req_act |= ROC_NPC_ACTION_TYPE_SEC;
704 : : rq = 0;
705 : 0 : roc_nix = roc_npc->roc_nix;
706 : :
707 : : /* Special processing when with inline device */
708 [ # # # # ]: 0 : if (roc_nix_inb_is_with_inl_dev(roc_nix) &&
709 : 0 : roc_nix_inl_dev_is_probed()) {
710 : : struct roc_nix_rq *inl_rq;
711 : :
712 : 0 : inl_rq = roc_nix_inl_dev_rq(roc_nix);
713 [ # # ]: 0 : if (!inl_rq) {
714 : : errcode = NPC_ERR_INTERNAL;
715 : 0 : goto err_exit;
716 : : }
717 : 0 : rq = inl_rq->qid;
718 : 0 : pf_func = nix_inl_dev_pffunc_get();
719 : : }
720 : :
721 [ # # ]: 0 : if (roc_nix_inl_dev_is_probed())
722 : 0 : flow->is_inline_dev = 1;
723 : : sec_action = actions;
724 : : break;
725 : 0 : case ROC_NPC_ACTION_TYPE_VLAN_STRIP:
726 : 0 : req_act |= ROC_NPC_ACTION_TYPE_VLAN_STRIP;
727 : 0 : break;
728 : 0 : case ROC_NPC_ACTION_TYPE_VLAN_INSERT:
729 : 0 : req_act |= ROC_NPC_ACTION_TYPE_VLAN_INSERT;
730 : 0 : break;
731 : 0 : case ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT:
732 : 0 : req_act |= ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT;
733 : 0 : break;
734 : 0 : case ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT:
735 : 0 : req_act |= ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT;
736 : 0 : break;
737 : 0 : case ROC_NPC_ACTION_TYPE_METER:
738 : 0 : act_mtr = (const struct roc_npc_action_meter *)
739 : : actions->conf;
740 : 0 : flow->mtr_id = act_mtr->mtr_id;
741 : 0 : req_act |= ROC_NPC_ACTION_TYPE_METER;
742 : 0 : break;
743 : 0 : case ROC_NPC_ACTION_TYPE_AGE:
744 [ # # ]: 0 : if (flow->is_validate == true)
745 : : break;
746 : : plt_seqcount_init(&roc_npc->flow_age.seq_cnt);
747 : 0 : errcode = npc_aging_ctrl_thread_create(roc_npc,
748 : 0 : actions->conf,
749 : : flow);
750 [ # # ]: 0 : if (errcode != 0)
751 : 0 : goto err_exit;
752 : 0 : req_act |= ROC_NPC_ACTION_TYPE_AGE;
753 : 0 : break;
754 : 0 : case ROC_NPC_ACTION_TYPE_SAMPLE:
755 : 0 : req_act |= ROC_NPC_ACTION_TYPE_SAMPLE;
756 : 0 : act_sample = actions->conf;
757 : 0 : errcode = roc_npc_process_sample_action(roc_npc, act_sample, flow);
758 [ # # ]: 0 : if (errcode)
759 : 0 : goto err_exit;
760 : : break;
761 : 0 : default:
762 : : errcode = NPC_ERR_ACTION_NOTSUP;
763 : 0 : goto err_exit;
764 : : }
765 : : }
766 : :
767 [ # # ]: 0 : if (sec_action) {
768 : 0 : rc = npc_parse_spi_to_sa_action(roc_npc, sec_action, flow, &has_spi_to_sa_act);
769 [ # # ]: 0 : if (rc) {
770 : : errcode = NPC_ERR_ACTION_NOTSUP;
771 : 0 : goto err_exit;
772 : : }
773 : : }
774 : :
775 [ # # ]: 0 : if (req_act & (ROC_NPC_ACTION_TYPE_VLAN_INSERT | ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT |
776 : : ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT))
777 : : vlan_insert_action = true;
778 : :
779 [ # # ]: 0 : if ((req_act & (ROC_NPC_ACTION_TYPE_VLAN_INSERT | ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT |
780 : : ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT)) ==
781 : : ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT) {
782 : 0 : plt_err("PCP insert action can't be supported alone");
783 : : errcode = NPC_ERR_ACTION_NOTSUP;
784 : 0 : goto err_exit;
785 : : }
786 : :
787 [ # # # # ]: 0 : if (has_spi_to_sa_act && (vlan_insert_action ||
788 [ # # ]: 0 : (req_act & ROC_NPC_ACTION_TYPE_VLAN_STRIP))) {
789 : 0 : plt_err("Both MSNS and VLAN insert/strip action can't be supported"
790 : : " together");
791 : : errcode = NPC_ERR_ACTION_NOTSUP;
792 : 0 : goto err_exit;
793 : : }
794 : :
795 : : /* Both STRIP and INSERT actions are not supported */
796 [ # # # # ]: 0 : if (vlan_insert_action && (req_act & ROC_NPC_ACTION_TYPE_VLAN_STRIP)) {
797 : : errcode = NPC_ERR_ACTION_NOTSUP;
798 : 0 : goto err_exit;
799 : : }
800 : :
801 [ # # ]: 0 : if (req_act & ROC_NPC_ACTION_TYPE_SAMPLE) {
802 : : /* One entry for the mce list PF and channel comes from the sample subaction.
803 : : * Another one is the action target of the flow rule getting created.
804 : : */
805 : 0 : flow->mcast_pf_funcs[1] = pf_func;
806 : 0 : flow->mcast_channels[1] = npc->channel;
807 [ # # ]: 0 : if (req_act & (ROC_NPC_ACTION_TYPE_DROP | ROC_NPC_ACTION_TYPE_SEC |
808 : : ROC_NPC_ACTION_TYPE_RSS)) {
809 : 0 : plt_err("Drop/RSS/SEC not supported with action type sample");
810 : 0 : return -EINVAL;
811 : : }
812 [ # # ]: 0 : if (flow->mcast_pf_funcs[0] == flow->mcast_pf_funcs[1]) {
813 : 0 : plt_err("Sample destination and target cannot be same");
814 : 0 : return -EINVAL;
815 : : }
816 [ # # # # ]: 0 : if ((attr->egress) && (flow->mcast_channels[0] == flow->mcast_channels[1])) {
817 : 0 : plt_err("Mirroring within PF and VF not allowed");
818 : 0 : return -EINVAL;
819 : : }
820 : : }
821 : :
822 : : /* Check if actions specified are compatible */
823 [ # # ]: 0 : if (attr->egress) {
824 [ # # ]: 0 : if (req_act & ROC_NPC_ACTION_TYPE_VLAN_STRIP) {
825 : 0 : plt_err("VLAN pop action is not supported on Egress");
826 : : errcode = NPC_ERR_ACTION_NOTSUP;
827 : 0 : goto err_exit;
828 : : }
829 : :
830 [ # # ]: 0 : if (req_act &
831 : : ~(ROC_NPC_ACTION_TYPE_VLAN_INSERT | ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT |
832 : : ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT | ROC_NPC_ACTION_TYPE_DROP |
833 : : ROC_NPC_ACTION_TYPE_COUNT | ROC_NPC_ACTION_TYPE_SAMPLE)) {
834 : 0 : plt_err("Only VLAN insert, drop, count, sample supported on Egress");
835 : : errcode = NPC_ERR_ACTION_NOTSUP;
836 : 0 : goto err_exit;
837 : : }
838 : :
839 [ # # ]: 0 : if (vlan_insert_action &&
840 [ # # ]: 0 : (req_act & ROC_NPC_ACTION_TYPE_DROP)) {
841 : 0 : plt_err("Both VLAN insert and drop actions cannot be supported");
842 : : errcode = NPC_ERR_ACTION_NOTSUP;
843 : 0 : goto err_exit;
844 : : }
845 : :
846 [ # # ]: 0 : if (req_act & ROC_NPC_ACTION_TYPE_DROP) {
847 : 0 : flow->npc_action = NIX_TX_ACTIONOP_DROP;
848 [ # # # # ]: 0 : } else if ((req_act & ROC_NPC_ACTION_TYPE_COUNT) || vlan_insert_action) {
849 : 0 : flow->npc_action = NIX_TX_ACTIONOP_UCAST_DEFAULT;
850 [ # # ]: 0 : if (flow->rep_act_rep) {
851 : : flow->npc_action = NIX_TX_ACTIONOP_UCAST_CHAN;
852 : 0 : flow->npc_action |= (uint64_t)0x3f << 12;
853 : : }
854 : : } else {
855 : 0 : plt_err("Unsupported action for egress");
856 : : errcode = NPC_ERR_ACTION_NOTSUP;
857 : 0 : goto err_exit;
858 : : }
859 : :
860 [ # # ]: 0 : if (req_act & ROC_NPC_ACTION_TYPE_SAMPLE) {
861 : 0 : flow->mcast_pf_funcs[1] = pf_func;
862 : 0 : flow->mcast_channels[1] = npc->channel;
863 : : }
864 : :
865 : : /* PF func who is sending the packet */
866 : 0 : flow->tx_pf_func = pf_func;
867 : 0 : goto done;
868 : : } else {
869 [ # # ]: 0 : if (vlan_insert_action) {
870 : : errcode = NPC_ERR_ACTION_NOTSUP;
871 : 0 : goto err_exit;
872 : : }
873 : : }
874 : :
875 : : /* We have already verified the attr, this is ingress.
876 : : * - Exactly one terminating action is supported
877 : : * - Exactly one of MARK or FLAG is supported
878 : : * - If terminating action is DROP, only count is valid.
879 : : */
880 : 0 : sel_act = req_act & NPC_ACTION_TERM;
881 [ # # ]: 0 : if ((sel_act & (sel_act - 1)) != 0) {
882 : : errcode = NPC_ERR_ACTION_NOTSUP;
883 : 0 : goto err_exit;
884 : : }
885 : :
886 [ # # ]: 0 : if (req_act & ROC_NPC_ACTION_TYPE_DROP) {
887 : 0 : sel_act = req_act & ~ROC_NPC_ACTION_TYPE_COUNT;
888 [ # # ]: 0 : if ((sel_act & (sel_act - 1)) != 0) {
889 : : errcode = NPC_ERR_ACTION_NOTSUP;
890 : 0 : goto err_exit;
891 : : }
892 : : }
893 : :
894 [ # # ]: 0 : if ((req_act & (ROC_NPC_ACTION_TYPE_FLAG | ROC_NPC_ACTION_TYPE_MARK)) ==
895 : : (ROC_NPC_ACTION_TYPE_FLAG | ROC_NPC_ACTION_TYPE_MARK)) {
896 : : errcode = NPC_ERR_ACTION_NOTSUP;
897 : 0 : goto err_exit;
898 : : }
899 : :
900 [ # # ]: 0 : if (req_act & ROC_NPC_ACTION_TYPE_VLAN_STRIP)
901 : 0 : npc->vtag_strip_actions++;
902 : :
903 : : /* Set NIX_RX_ACTIONOP */
904 [ # # ]: 0 : if (req_act == ROC_NPC_ACTION_TYPE_VLAN_STRIP) {
905 : : /* Only VLAN action is provided */
906 : 0 : flow->npc_action = NIX_RX_ACTIONOP_UCAST;
907 [ # # ]: 0 : } else if (req_act & (ROC_NPC_ACTION_TYPE_PF | ROC_NPC_ACTION_TYPE_VF)) {
908 : : /* Check if any other action is set */
909 [ # # ]: 0 : if ((req_act == ROC_NPC_ACTION_TYPE_PF) || (req_act == ROC_NPC_ACTION_TYPE_VF)) {
910 : 0 : flow->npc_action = NIX_RX_ACTIONOP_DEFAULT;
911 : : } else {
912 : 0 : flow->npc_action = NIX_RX_ACTIONOP_UCAST;
913 [ # # ]: 0 : if (req_act & ROC_NPC_ACTION_TYPE_QUEUE)
914 : 0 : flow->recv_queue = rq;
915 : : }
916 [ # # ]: 0 : } else if (req_act & ROC_NPC_ACTION_TYPE_DROP) {
917 : 0 : flow->npc_action = NIX_RX_ACTIONOP_DROP;
918 [ # # ]: 0 : } else if (req_act & ROC_NPC_ACTION_TYPE_QUEUE) {
919 : 0 : flow->npc_action = NIX_RX_ACTIONOP_UCAST;
920 : 0 : flow->recv_queue = rq;
921 [ # # ]: 0 : } else if (req_act & ROC_NPC_ACTION_TYPE_RSS) {
922 : 0 : flow->npc_action = NIX_RX_ACTIONOP_UCAST;
923 [ # # ]: 0 : } else if (req_act & ROC_NPC_ACTION_TYPE_SEC) {
924 [ # # ]: 0 : if (roc_model_is_cn20k()) {
925 : : flow->npc_action = NIX_RX_ACTIONOP_UCAST_CPT;
926 : 0 : flow->npc_action |= (uint64_t)rq << 20;
927 : 0 : flow->npc_action2 =
928 : 0 : roc_nix_inl_inb_ipsec_profile_id_get(roc_nix, true) << 8;
929 : : } else {
930 : : flow->npc_action = NIX_RX_ACTIONOP_UCAST_IPSEC;
931 : 0 : flow->npc_action |= (uint64_t)rq << 20;
932 : : }
933 [ # # ]: 0 : } else if (req_act & (ROC_NPC_ACTION_TYPE_FLAG | ROC_NPC_ACTION_TYPE_MARK)) {
934 : 0 : flow->npc_action = NIX_RX_ACTIONOP_UCAST;
935 [ # # ]: 0 : } else if (req_act & ROC_NPC_ACTION_TYPE_COUNT) {
936 : : /* Keep ROC_NPC_ACTION_TYPE_COUNT_ACT always at the end
937 : : * This is default action, when user specify only
938 : : * COUNT ACTION
939 : : */
940 : 0 : flow->npc_action = NIX_RX_ACTIONOP_UCAST;
941 : : } else {
942 : : /* Should never reach here */
943 : : errcode = NPC_ERR_ACTION_NOTSUP;
944 : 0 : goto err_exit;
945 : : }
946 : :
947 [ # # ]: 0 : if (req_act & ROC_NPC_ACTION_TYPE_SAMPLE)
948 : 0 : flow->npc_action = NIX_RX_ACTIONOP_MCAST;
949 : :
950 [ # # ]: 0 : if (mark)
951 : 0 : flow->npc_action |= (uint64_t)mark << 40;
952 : :
953 : : /* Ideally AF must ensure that correct pf_func is set */
954 : 0 : flow->npc_action |= (uint64_t)pf_func << 4;
955 : :
956 : : done:
957 : : return 0;
958 : :
959 : : err_exit:
960 : : return errcode;
961 : : }
962 : :
963 : : typedef int (*npc_parse_stage_func_t)(struct npc_parse_state *pst);
964 : :
965 : : static int
966 : 0 : npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[],
967 : : struct roc_npc_flow *flow, struct npc_parse_state *pst)
968 : : {
969 : 0 : npc_parse_stage_func_t parse_stage_funcs[] = {
970 : : npc_parse_meta_items, npc_parse_port_representor_id,
971 : : npc_parse_mark_item, npc_parse_pre_l2,
972 : : npc_parse_cpt_hdr, npc_parse_higig2_hdr,
973 : : npc_parse_tx_queue, npc_parse_la,
974 : : npc_parse_lb, npc_parse_lc,
975 : : npc_parse_ld, npc_parse_le,
976 : : npc_parse_lf, npc_parse_lg,
977 : : npc_parse_lh,
978 : : };
979 : : uint8_t layer = 0;
980 : : int key_offset;
981 : : int rc;
982 : :
983 [ # # ]: 0 : if (pattern == NULL)
984 : : return NPC_ERR_PARAM;
985 : :
986 : 0 : pst->npc = npc;
987 : 0 : pst->flow = flow;
988 : 0 : pst->nix_intf = flow->nix_intf;
989 : :
990 : : /* Use integral byte offset */
991 : : key_offset = pst->npc->keyx_len[flow->nix_intf];
992 : : key_offset = (key_offset + 7) / 8;
993 : :
994 : : /* Location where LDATA would begin */
995 : 0 : pst->mcam_data = (uint8_t *)flow->mcam_data;
996 : 0 : pst->mcam_mask = (uint8_t *)flow->mcam_mask;
997 : :
998 [ # # # # ]: 0 : while (pattern->type != ROC_NPC_ITEM_TYPE_END && layer < PLT_DIM(parse_stage_funcs)) {
999 : : /* Skip place-holders */
1000 : 0 : pattern = npc_parse_skip_void_and_any_items(pattern);
1001 [ # # ]: 0 : if (pattern->type == ROC_NPC_ITEM_TYPE_END)
1002 : : break;
1003 : :
1004 : 0 : pst->pattern = pattern;
1005 : 0 : rc = parse_stage_funcs[layer](pst);
1006 [ # # ]: 0 : if (rc != 0)
1007 : 0 : return rc;
1008 : :
1009 : 0 : layer++;
1010 : :
1011 : : /*
1012 : : * Parse stage function sets pst->pattern to
1013 : : * 1 past the last item it consumed.
1014 : : */
1015 : 0 : pattern = pst->pattern;
1016 : :
1017 [ # # ]: 0 : if (pst->terminate)
1018 : : break;
1019 : : }
1020 : :
1021 : : /* Skip trailing place-holders */
1022 : 0 : pattern = npc_parse_skip_void_and_any_items(pattern);
1023 : :
1024 : : /* Are there more items than what we can handle? */
1025 [ # # ]: 0 : if (pattern->type != ROC_NPC_ITEM_TYPE_END)
1026 : 0 : return NPC_ERR_PATTERN_NOTSUP;
1027 : :
1028 : : return 0;
1029 : : }
1030 : :
1031 : : static int
1032 : : npc_parse_attr(struct npc *npc, const struct roc_npc_attr *attr,
1033 : : struct roc_npc_flow *flow)
1034 : : {
1035 : 0 : if (attr == NULL)
1036 : : return NPC_ERR_PARAM;
1037 [ # # ]: 0 : else if (attr->priority >= npc->flow_max_priority)
1038 : : return NPC_ERR_PARAM;
1039 [ # # ]: 0 : else if ((!attr->egress && !attr->ingress) ||
1040 : : (attr->egress && attr->ingress))
1041 : : return NPC_ERR_PARAM;
1042 : :
1043 [ # # ]: 0 : if (attr->ingress)
1044 : 0 : flow->nix_intf = ROC_NPC_INTF_RX;
1045 : : else
1046 : 0 : flow->nix_intf = ROC_NPC_INTF_TX;
1047 : :
1048 : 0 : flow->priority = attr->priority;
1049 : : return 0;
1050 : : }
1051 : :
1052 : : static int
1053 [ # # ]: 0 : npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
1054 : : const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[],
1055 : : struct roc_npc_flow *flow, struct npc_parse_state *pst)
1056 : : {
1057 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
1058 : 0 : struct roc_nix *roc_nix = roc_npc->roc_nix;
1059 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1060 : : int err;
1061 : :
1062 [ # # ]: 0 : pst->nb_tx_queues = nix->nb_tx_queues;
1063 : :
1064 : : /* Check attr */
1065 : : err = npc_parse_attr(npc, attr, flow);
1066 : : if (err)
1067 : : return err;
1068 : :
1069 : : /* Check pattern */
1070 : 0 : err = npc_parse_pattern(npc, pattern, flow, pst);
1071 [ # # ]: 0 : if (err)
1072 : : return err;
1073 : :
1074 : : /* Check action */
1075 : 0 : err = npc_parse_actions(roc_npc, attr, actions, flow, pst->dst_pf_func);
1076 [ # # ]: 0 : if (err)
1077 : 0 : return err;
1078 : : return 0;
1079 : : }
1080 : :
1081 : : int
1082 : 0 : roc_npc_flow_parse(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
1083 : : const struct roc_npc_item_info pattern[],
1084 : : const struct roc_npc_action actions[],
1085 : : struct roc_npc_flow *flow)
1086 : : {
1087 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
1088 : 0 : struct npc_parse_state parse_state = {0};
1089 : : int rc;
1090 : :
1091 : 0 : rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state);
1092 [ # # ]: 0 : if (rc)
1093 : : return rc;
1094 : :
1095 : 0 : parse_state.is_vf = !roc_nix_is_pf(roc_npc->roc_nix);
1096 : :
1097 : 0 : return npc_program_mcam(npc, &parse_state, 0);
1098 : : }
1099 : :
1100 : : int
1101 : 0 : npc_rss_free_grp_get(struct npc *npc, uint32_t *pos)
1102 : : {
1103 : 0 : struct plt_bitmap *bmap = npc->rss_grp_entries;
1104 : :
1105 [ # # ]: 0 : for (*pos = 0; *pos < ROC_NIX_RSS_GRPS; ++*pos) {
1106 [ # # ]: 0 : if (!plt_bitmap_get(bmap, *pos))
1107 : : break;
1108 : : }
1109 [ # # ]: 0 : return *pos < ROC_NIX_RSS_GRPS ? 0 : -1;
1110 : : }
1111 : :
1112 : : int
1113 : 0 : npc_rss_action_configure(struct roc_npc *roc_npc, const struct roc_npc_action_rss *rss,
1114 : : uint8_t *alg_idx, uint32_t *rss_grp, uint32_t mcam_id,
1115 : : uint16_t rss_repte_pf_func)
1116 : : {
1117 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
1118 : 0 : struct roc_nix *roc_nix = roc_npc->roc_nix;
1119 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1120 : : uint32_t flowkey_cfg, rss_grp_idx, i, rem;
1121 : : uint8_t key[ROC_NIX_RSS_KEY_LEN];
1122 : : const uint8_t *key_ptr;
1123 : : uint8_t flowkey_algx;
1124 : : uint32_t key_len;
1125 : : uint16_t *reta;
1126 : : int rc;
1127 : :
1128 : 0 : roc_nix_rss_key_get(roc_nix, key);
1129 [ # # ]: 0 : if (rss->key == NULL) {
1130 : : key_ptr = key;
1131 : : } else {
1132 : 0 : key_len = rss->key_len;
1133 : : if (key_len > ROC_NIX_RSS_KEY_LEN)
1134 : : key_len = ROC_NIX_RSS_KEY_LEN;
1135 : :
1136 [ # # ]: 0 : for (i = 0; i < key_len; i++) {
1137 [ # # ]: 0 : if (key[i] != rss->key[i]) {
1138 : 0 : plt_err("RSS key config not supported");
1139 : 0 : plt_err("New Key:");
1140 [ # # ]: 0 : for (i = 0; i < key_len; i++)
1141 : 0 : plt_dump_no_nl("0x%.2x ", rss->key[i]);
1142 : 0 : plt_dump_no_nl("\n");
1143 : 0 : plt_err("Configured Key:");
1144 [ # # ]: 0 : for (i = 0; i < ROC_NIX_RSS_KEY_LEN; i++)
1145 : 0 : plt_dump_no_nl("0x%.2x ", key[i]);
1146 : 0 : plt_dump_no_nl("\n");
1147 : 0 : return -ENOTSUP;
1148 : : }
1149 : : }
1150 : : key_ptr = rss->key;
1151 : : }
1152 : :
1153 : 0 : rc = npc_rss_free_grp_get(npc, &rss_grp_idx);
1154 : : /* RSS group :0 is not usable for flow rss action */
1155 [ # # # # ]: 0 : if (rc < 0 || rss_grp_idx == 0)
1156 : : return -ENOSPC;
1157 : :
1158 [ # # # # ]: 0 : for (i = 0; (i < rss->queue_num) && !rss_repte_pf_func; i++) {
1159 [ # # ]: 0 : if (rss->queue[i] >= nix->nb_rx_queues) {
1160 : 0 : plt_err("queue id > max number of queues");
1161 : 0 : return -EINVAL;
1162 : : }
1163 : : }
1164 : :
1165 : 0 : *rss_grp = rss_grp_idx;
1166 : :
1167 : 0 : roc_nix_rss_key_set(roc_nix, key_ptr);
1168 : :
1169 : : /* If queue count passed in the rss action is less than
1170 : : * HW configured reta size, replicate rss action reta
1171 : : * across HW reta table.
1172 : : */
1173 : 0 : reta = nix->reta[rss_grp_idx];
1174 : :
1175 [ # # ]: 0 : if (rss->queue_num > nix->reta_sz) {
1176 : 0 : plt_err("too many queues for RSS context");
1177 : 0 : return -ENOTSUP;
1178 : : }
1179 : :
1180 [ # # ]: 0 : for (i = 0; i < (nix->reta_sz / rss->queue_num); i++)
1181 : 0 : memcpy(reta + i * rss->queue_num, rss->queue,
1182 : 0 : sizeof(uint16_t) * rss->queue_num);
1183 : :
1184 : 0 : rem = nix->reta_sz % rss->queue_num;
1185 [ # # ]: 0 : if (rem)
1186 : 0 : memcpy(&reta[i * rss->queue_num], rss->queue, rem * sizeof(uint16_t));
1187 : :
1188 : 0 : rc = nix_rss_reta_pffunc_set(roc_nix, *rss_grp, reta, rss_repte_pf_func);
1189 [ # # ]: 0 : if (rc) {
1190 : 0 : plt_err("Failed to init rss table rc = %d", rc);
1191 : 0 : return rc;
1192 : : }
1193 : :
1194 : 0 : flowkey_cfg = roc_npc->flowkey_cfg_state;
1195 : :
1196 : 0 : rc = nix_rss_flowkey_pffunc_set(roc_nix, &flowkey_algx, flowkey_cfg, *rss_grp, mcam_id,
1197 : : rss_repte_pf_func);
1198 [ # # ]: 0 : if (rc) {
1199 : 0 : plt_err("Failed to set rss hash function rc = %d", rc);
1200 : 0 : return rc;
1201 : : }
1202 : :
1203 : 0 : *alg_idx = flowkey_algx;
1204 : :
1205 : 0 : plt_bitmap_set(npc->rss_grp_entries, *rss_grp);
1206 : :
1207 : 0 : return 0;
1208 : : }
1209 : :
1210 : : int
1211 : 0 : npc_rss_action_program(struct roc_npc *roc_npc,
1212 : : const struct roc_npc_action actions[],
1213 : : struct roc_npc_flow *flow)
1214 : : {
1215 : : const struct roc_npc_action_rss *rss;
1216 : : struct roc_npc *npc = roc_npc;
1217 : : uint32_t rss_grp;
1218 : : uint8_t alg_idx;
1219 : : int rc;
1220 : :
1221 [ # # ]: 0 : if (flow->has_rep) {
1222 : 0 : npc = roc_npc->rep_npc;
1223 : 0 : npc->flowkey_cfg_state = roc_npc->flowkey_cfg_state;
1224 : : }
1225 : :
1226 [ # # ]: 0 : for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) {
1227 [ # # ]: 0 : if (actions->type == ROC_NPC_ACTION_TYPE_RSS) {
1228 : 0 : rss = (const struct roc_npc_action_rss *)actions->conf;
1229 : 0 : rc = npc_rss_action_configure(npc, rss, &alg_idx, &rss_grp, flow->mcam_id,
1230 : 0 : actions->rss_repte_pf_func);
1231 [ # # ]: 0 : if (rc)
1232 : : return rc;
1233 : :
1234 : 0 : flow->npc_action &= (~(0xfULL));
1235 : 0 : flow->npc_action |= NIX_RX_ACTIONOP_RSS;
1236 : 0 : flow->npc_action |=
1237 : 0 : ((uint64_t)(alg_idx & NPC_RSS_ACT_ALG_MASK)
1238 : 0 : << NPC_RSS_ACT_ALG_OFFSET) |
1239 : 0 : ((uint64_t)(rss_grp & NPC_RSS_ACT_GRP_MASK)
1240 : 0 : << NPC_RSS_ACT_GRP_OFFSET);
1241 : 0 : break;
1242 : : }
1243 : : }
1244 : : return 0;
1245 : : }
1246 : :
1247 : : static int
1248 : 0 : npc_vtag_cfg_delete(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
1249 : : {
1250 : 0 : struct roc_nix *roc_nix = roc_npc->roc_nix;
1251 : : struct nix_vtag_config *vtag_cfg;
1252 : : struct nix_vtag_config_rsp *rsp;
1253 : : struct mbox *mbox, *ombox;
1254 : : struct nix *nix;
1255 : : int rc = 0;
1256 : :
1257 : : union {
1258 : : uint64_t reg;
1259 : : struct nix_tx_vtag_action_s act;
1260 : : } tx_vtag_action;
1261 : :
1262 : : nix = roc_nix_to_nix_priv(roc_nix);
1263 : 0 : ombox = (&nix->dev)->mbox;
1264 [ # # ]: 0 : if (flow->has_rep)
1265 : 0 : ombox = flow->rep_mbox;
1266 : : mbox = mbox_get(ombox);
1267 : :
1268 : 0 : tx_vtag_action.reg = flow->vtag_action;
1269 : 0 : vtag_cfg = mbox_alloc_msg_nix_vtag_cfg(mbox);
1270 : :
1271 [ # # ]: 0 : if (vtag_cfg == NULL) {
1272 : : rc = -ENOSPC;
1273 : 0 : goto exit;
1274 : : }
1275 : :
1276 : 0 : vtag_cfg->cfg_type = VTAG_TX;
1277 : 0 : vtag_cfg->vtag_size = NIX_VTAGSIZE_T4;
1278 : 0 : vtag_cfg->tx.vtag0_idx = tx_vtag_action.act.vtag0_def;
1279 : 0 : vtag_cfg->tx.free_vtag0 = true;
1280 : :
1281 [ # # ]: 0 : if (flow->vtag_insert_count == 2) {
1282 : 0 : vtag_cfg->tx.vtag1_idx = tx_vtag_action.act.vtag1_def;
1283 : 0 : vtag_cfg->tx.free_vtag1 = true;
1284 : : }
1285 : :
1286 : : rc = mbox_process_msg(mbox, (void *)&rsp);
1287 [ # # ]: 0 : if (rc)
1288 : 0 : goto exit;
1289 : :
1290 : : rc = 0;
1291 : 0 : exit:
1292 : : mbox_put(mbox);
1293 : 0 : return rc;
1294 : : }
1295 : :
1296 : : static int
1297 : 0 : npc_vtag_insert_action_parse(const struct roc_npc_action actions[],
1298 : : struct roc_npc_flow *flow,
1299 : : struct npc_action_vtag_info *vlan_info,
1300 : : int *parsed_cnt)
1301 : : {
1302 : : bool vlan_id_found = false, ethtype_found = false, pcp_found = false;
1303 : : int count = 0;
1304 : :
1305 : 0 : *parsed_cnt = 0;
1306 : :
1307 : : /* This function parses parameters of one VLAN. When a parameter is
1308 : : * found repeated, it treats it as the end of first VLAN's parameters
1309 : : * and returns. The caller calls again to parse the parameters of the
1310 : : * second VLAN.
1311 : : */
1312 : :
1313 [ # # ]: 0 : for (; count < NPC_ACTION_MAX_VLAN_PARAMS; count++, actions++) {
1314 [ # # ]: 0 : if (actions->type == ROC_NPC_ACTION_TYPE_VLAN_INSERT) {
1315 [ # # ]: 0 : if (vlan_id_found)
1316 : : return 0;
1317 : :
1318 : 0 : const struct roc_npc_action_of_set_vlan_vid *vtag =
1319 : : (const struct roc_npc_action_of_set_vlan_vid *)
1320 : : actions->conf;
1321 : :
1322 [ # # ]: 0 : vlan_info->vlan_id = plt_be_to_cpu_16(vtag->vlan_vid);
1323 : :
1324 [ # # ]: 0 : if (vlan_info->vlan_id > 0xfff) {
1325 : 0 : plt_err("Invalid vlan_id for set vlan action");
1326 : 0 : return -EINVAL;
1327 : : }
1328 : :
1329 : 0 : flow->vtag_insert_enabled = true;
1330 : 0 : (*parsed_cnt)++;
1331 : : vlan_id_found = true;
1332 [ # # ]: 0 : } else if (actions->type ==
1333 : : ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT) {
1334 [ # # ]: 0 : if (ethtype_found)
1335 : : return 0;
1336 : :
1337 : 0 : const struct roc_npc_action_of_push_vlan *ethtype =
1338 : : (const struct roc_npc_action_of_push_vlan *)
1339 : : actions->conf;
1340 : 0 : vlan_info->vlan_ethtype =
1341 [ # # ]: 0 : plt_be_to_cpu_16(ethtype->ethertype);
1342 [ # # ]: 0 : if (vlan_info->vlan_ethtype != ROC_ETHER_TYPE_VLAN &&
1343 : : vlan_info->vlan_ethtype != ROC_ETHER_TYPE_QINQ) {
1344 : 0 : plt_err("Invalid ethtype specified for push"
1345 : : " vlan action");
1346 : 0 : return -EINVAL;
1347 : : }
1348 : 0 : flow->vtag_insert_enabled = true;
1349 : 0 : (*parsed_cnt)++;
1350 : : ethtype_found = true;
1351 [ # # ]: 0 : } else if (actions->type ==
1352 : : ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT) {
1353 [ # # ]: 0 : if (pcp_found)
1354 : : return 0;
1355 : 0 : const struct roc_npc_action_of_set_vlan_pcp *pcp =
1356 : : (const struct roc_npc_action_of_set_vlan_pcp *)
1357 : : actions->conf;
1358 : 0 : vlan_info->vlan_pcp = pcp->vlan_pcp;
1359 [ # # ]: 0 : if (vlan_info->vlan_pcp > 0x7) {
1360 : 0 : plt_err("Invalid PCP value for pcp action");
1361 : 0 : return -EINVAL;
1362 : : }
1363 : 0 : flow->vtag_insert_enabled = true;
1364 : 0 : (*parsed_cnt)++;
1365 : : pcp_found = true;
1366 : : } else {
1367 : : return 0;
1368 : : }
1369 : : }
1370 : :
1371 : : return 0;
1372 : : }
1373 : :
1374 : : static int
1375 : 0 : npc_vtag_insert_action_configure(struct mbox *mbox, struct roc_npc_flow *flow,
1376 : : struct npc_action_vtag_info *vlan_info)
1377 : : {
1378 : : struct nix_vtag_config *vtag_cfg;
1379 : : struct nix_vtag_config_rsp *rsp;
1380 : : int rc = 0;
1381 : :
1382 : : union {
1383 : : uint64_t reg;
1384 : : struct nix_tx_vtag_action_s act;
1385 : : } tx_vtag_action;
1386 : :
1387 : 0 : vtag_cfg = mbox_alloc_msg_nix_vtag_cfg(mbox_get(mbox));
1388 : :
1389 [ # # ]: 0 : if (vtag_cfg == NULL) {
1390 : : rc = -ENOSPC;
1391 : 0 : goto exit;
1392 : : }
1393 : :
1394 : 0 : vtag_cfg->cfg_type = VTAG_TX;
1395 : 0 : vtag_cfg->vtag_size = NIX_VTAGSIZE_T4;
1396 : 0 : vtag_cfg->tx.vtag0 =
1397 : 0 : (((uint32_t)vlan_info[0].vlan_ethtype << 16) |
1398 : 0 : (vlan_info[0].vlan_pcp << 13) | vlan_info[0].vlan_id);
1399 : :
1400 : 0 : vtag_cfg->tx.cfg_vtag0 = 1;
1401 : :
1402 [ # # ]: 0 : if (flow->vtag_insert_count == 2) {
1403 : 0 : vtag_cfg->tx.vtag1 =
1404 : 0 : (((uint32_t)vlan_info[1].vlan_ethtype << 16) |
1405 : 0 : (vlan_info[1].vlan_pcp << 13) | vlan_info[1].vlan_id);
1406 : :
1407 : 0 : vtag_cfg->tx.cfg_vtag1 = 1;
1408 : : }
1409 : :
1410 : : rc = mbox_process_msg(mbox, (void *)&rsp);
1411 [ # # ]: 0 : if (rc)
1412 : 0 : goto exit;
1413 : :
1414 [ # # ]: 0 : if (rsp->vtag0_idx < 0 ||
1415 [ # # # # ]: 0 : ((flow->vtag_insert_count == 2) && (rsp->vtag1_idx < 0))) {
1416 : 0 : plt_err("Failed to config TX VTAG action");
1417 : : rc = -EINVAL;
1418 : 0 : goto exit;
1419 : : }
1420 : :
1421 : 0 : tx_vtag_action.reg = 0;
1422 : 0 : tx_vtag_action.act.vtag0_def = rsp->vtag0_idx;
1423 : : tx_vtag_action.act.vtag0_lid = NPC_LID_LA;
1424 : 0 : tx_vtag_action.act.vtag0_op = NIX_TX_VTAGOP_INSERT;
1425 : 0 : tx_vtag_action.act.vtag0_relptr = NIX_TX_VTAGACTION_VTAG0_RELPTR;
1426 : :
1427 [ # # ]: 0 : if (flow->vtag_insert_count == 2) {
1428 : 0 : tx_vtag_action.act.vtag1_def = rsp->vtag1_idx;
1429 : : tx_vtag_action.act.vtag1_lid = NPC_LID_LA;
1430 : 0 : tx_vtag_action.act.vtag1_op = NIX_TX_VTAGOP_INSERT;
1431 : : /* NIX_TX_VTAG_ACTION_S
1432 : : * If Vtag 0 is inserted, hardware adjusts the Vtag 1 byte
1433 : : * offset accordingly. Thus, if the two offsets are equal in
1434 : : * the structure, hardware inserts Vtag 1 immediately after
1435 : : * Vtag 0 in the packet.
1436 : : */
1437 : 0 : tx_vtag_action.act.vtag1_relptr =
1438 : : NIX_TX_VTAGACTION_VTAG0_RELPTR;
1439 : : }
1440 : :
1441 : 0 : flow->vtag_action = tx_vtag_action.reg;
1442 : :
1443 : : rc = 0;
1444 : 0 : exit:
1445 : : mbox_put(mbox);
1446 : 0 : return rc;
1447 : : }
1448 : :
1449 : : static int
1450 : 0 : npc_vtag_strip_action_configure(struct mbox *mbox,
1451 : : const struct roc_npc_action actions[],
1452 : : struct roc_npc_flow *flow, int *strip_cnt)
1453 : : {
1454 : : struct nix_vtag_config *vtag_cfg;
1455 : : uint64_t rx_vtag_action = 0;
1456 : : int count = 0, rc = 0;
1457 : :
1458 : 0 : *strip_cnt = 0;
1459 : :
1460 [ # # ]: 0 : for (; count < NPC_ACTION_MAX_VLANS_STRIPPED; count++, actions++) {
1461 [ # # ]: 0 : if (actions->type == ROC_NPC_ACTION_TYPE_VLAN_STRIP)
1462 : 0 : (*strip_cnt)++;
1463 : : }
1464 : :
1465 : 0 : vtag_cfg = mbox_alloc_msg_nix_vtag_cfg(mbox_get(mbox));
1466 : :
1467 [ # # ]: 0 : if (vtag_cfg == NULL) {
1468 : : rc = -ENOSPC;
1469 : 0 : goto exit;
1470 : : }
1471 : :
1472 : 0 : vtag_cfg->cfg_type = VTAG_RX;
1473 : 0 : vtag_cfg->rx.strip_vtag = 1;
1474 : : /* Always capture */
1475 : 0 : vtag_cfg->rx.capture_vtag = 1;
1476 : 0 : vtag_cfg->vtag_size = NIX_VTAGSIZE_T4;
1477 : 0 : vtag_cfg->rx.vtag_type = 0;
1478 : :
1479 : 0 : rc = mbox_process(mbox);
1480 [ # # ]: 0 : if (rc)
1481 : 0 : goto exit;
1482 : :
1483 : : rx_vtag_action |= (NIX_RX_VTAGACTION_VTAG_VALID << 15);
1484 : : rx_vtag_action |= ((uint64_t)NPC_LID_LB << 8);
1485 : : rx_vtag_action |= ((uint64_t)NIX_RX_VTAG_TYPE6 << 12);
1486 : : rx_vtag_action |= NIX_RX_VTAGACTION_VTAG0_RELPTR;
1487 : :
1488 [ # # ]: 0 : if (*strip_cnt == 2) {
1489 : : rx_vtag_action |= (NIX_RX_VTAGACTION_VTAG_VALID << 47);
1490 : : rx_vtag_action |= ((uint64_t)NPC_LID_LB << 40);
1491 : : rx_vtag_action |= NIX_RX_VTAGACTION_VTAG0_RELPTR << 32;
1492 : : }
1493 : 0 : flow->vtag_action = rx_vtag_action;
1494 : :
1495 : : rc = 0;
1496 : 0 : exit:
1497 : : mbox_put(mbox);
1498 : 0 : return rc;
1499 : : }
1500 : :
1501 : : static int
1502 : 0 : npc_vtag_action_program(struct roc_npc *roc_npc,
1503 : : const struct roc_npc_action actions[],
1504 : : struct roc_npc_flow *flow)
1505 : : {
1506 : : bool vlan_strip_parsed = false, vlan_insert_parsed = false;
1507 : : const struct roc_npc_action *insert_actions;
1508 : 0 : struct roc_nix *roc_nix = roc_npc->roc_nix;
1509 : : struct npc_action_vtag_info vlan_info[2];
1510 : 0 : int parsed_cnt = 0, strip_cnt = 0;
1511 : : int tot_vlan_params = 0;
1512 : : struct mbox *mbox;
1513 : : struct nix *nix;
1514 : : int i, rc;
1515 : :
1516 : : nix = roc_nix_to_nix_priv(roc_nix);
1517 : 0 : mbox = (&nix->dev)->mbox;
1518 [ # # ]: 0 : if (flow->has_rep)
1519 : 0 : mbox = flow->rep_mbox;
1520 : :
1521 : : memset(vlan_info, 0, sizeof(vlan_info));
1522 : :
1523 : 0 : flow->vtag_insert_enabled = false;
1524 : :
1525 [ # # ]: 0 : for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) {
1526 [ # # ]: 0 : if (actions->type == ROC_NPC_ACTION_TYPE_VLAN_STRIP) {
1527 [ # # ]: 0 : if (vlan_strip_parsed) {
1528 : 0 : plt_err("Incorrect VLAN strip actions");
1529 : 0 : return -EINVAL;
1530 : : }
1531 : 0 : rc = npc_vtag_strip_action_configure(mbox, actions,
1532 : : flow, &strip_cnt);
1533 [ # # ]: 0 : if (rc)
1534 : 0 : return rc;
1535 : :
1536 : 0 : plt_npc_dbg("VLAN strip action, strip_cnt %d", strip_cnt);
1537 [ # # ]: 0 : if (strip_cnt == 2)
1538 : 0 : actions++;
1539 : :
1540 : : vlan_strip_parsed = true;
1541 [ # # ]: 0 : } else if (actions->type == ROC_NPC_ACTION_TYPE_VLAN_INSERT ||
1542 : : actions->type ==
1543 [ # # ]: 0 : ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT ||
1544 : : actions->type ==
1545 : : ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT) {
1546 [ # # ]: 0 : if (vlan_insert_parsed) {
1547 : 0 : plt_err("Incorrect VLAN insert actions");
1548 : 0 : return -EINVAL;
1549 : : }
1550 : :
1551 : : insert_actions = actions;
1552 : :
1553 [ # # ]: 0 : for (i = 0; i < 2; i++) {
1554 : 0 : rc = npc_vtag_insert_action_parse(
1555 : : insert_actions, flow, &vlan_info[i],
1556 : : &parsed_cnt);
1557 : :
1558 [ # # ]: 0 : if (rc)
1559 : 0 : return rc;
1560 : :
1561 [ # # ]: 0 : if (parsed_cnt) {
1562 : 0 : insert_actions += parsed_cnt;
1563 : 0 : tot_vlan_params += parsed_cnt;
1564 : 0 : flow->vtag_insert_count++;
1565 : : }
1566 : : }
1567 : 0 : actions += tot_vlan_params - 1;
1568 : : vlan_insert_parsed = true;
1569 : : }
1570 : : }
1571 : :
1572 [ # # ]: 0 : if (flow->vtag_insert_enabled) {
1573 : 0 : rc = npc_vtag_insert_action_configure(mbox, flow, vlan_info);
1574 : :
1575 [ # # ]: 0 : if (rc)
1576 : 0 : return rc;
1577 : : }
1578 : : return 0;
1579 : : }
1580 : :
1581 : : static int
1582 : 0 : npc_inline_dev_ipsec_action_free(struct npc *npc, struct roc_npc_flow *flow)
1583 : : {
1584 : : struct nix_inl_dev *inl_dev;
1585 : : struct idev_cfg *idev;
1586 : : int rc;
1587 : :
1588 : : PLT_SET_USED(npc);
1589 : :
1590 : 0 : idev = idev_get_cfg();
1591 [ # # ]: 0 : if (!idev)
1592 : : return 1;
1593 : :
1594 : 0 : inl_dev = idev->nix_inl_dev;
1595 : :
1596 [ # # # # : 0 : if (flow->nix_intf == NIX_INTF_RX && inl_dev && inl_dev->ipsec_index &&
# # # # ]
1597 [ # # ]: 0 : roc_npc_action_is_rx_inline(flow->npc_action)) {
1598 : 0 : inl_dev->curr_ipsec_idx--;
1599 : 0 : inl_dev->ipsec_index[inl_dev->curr_ipsec_idx] = flow->mcam_id;
1600 : 0 : flow->enable = 0;
1601 [ # # ]: 0 : if (flow->use_ctr) {
1602 : 0 : rc = npc_mcam_clear_counter(inl_dev->dev.mbox, flow->ctr_id);
1603 [ # # ]: 0 : if (rc)
1604 : : return rc;
1605 : :
1606 : 0 : rc = npc_mcam_free_counter(inl_dev->dev.mbox, flow->ctr_id);
1607 [ # # ]: 0 : if (rc)
1608 : : return rc;
1609 : : }
1610 : 0 : return npc_mcam_write_entry(inl_dev->dev.mbox, flow);
1611 : : }
1612 : :
1613 : : return 1;
1614 : : }
1615 : :
1616 : : void
1617 : 0 : roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t *chan_mask)
1618 : : {
1619 : 0 : struct roc_nix *roc_nix = roc_npc->roc_nix;
1620 : : struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1621 : : uint16_t num_chan, range, num_bits = 0;
1622 : : uint16_t mask = 0;
1623 : :
1624 : 0 : *chan_base = nix->rx_chan_base;
1625 : 0 : num_chan = nix->rx_chan_cnt - 1;
1626 [ # # ]: 0 : if (num_chan) {
1627 : 0 : range = *chan_base ^ (*chan_base + num_chan);
1628 : 0 : num_bits = (sizeof(uint32_t) * 8) - plt_clz32(range) - 1;
1629 : : /* Set mask for (15 - numbits) MSB bits */
1630 : 0 : *chan_mask = (uint16_t)~GENMASK(num_bits, 0);
1631 : 0 : *chan_mask &= 0xFFF;
1632 : : } else {
1633 : 0 : *chan_mask = (uint16_t)GENMASK(11, 0);
1634 : : }
1635 : :
1636 : 0 : mask = (uint16_t)GENMASK(num_bits, 0);
1637 [ # # ]: 0 : if (mask > num_chan + 1)
1638 : 0 : plt_warn(
1639 : : "npc: SDP channel base:%x, channel count:%x. channel mask:%x covers more than channel count",
1640 : : *chan_base, nix->rx_chan_cnt, *chan_mask);
1641 : 0 : }
1642 : :
1643 : : struct roc_npc_flow *
1644 : 0 : roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
1645 : : const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[],
1646 : : uint16_t dst_pf_func, int *errcode)
1647 : : {
1648 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
1649 : 0 : uint16_t sdp_chan_base = 0, sdp_chan_mask = 0;
1650 : : struct roc_npc_flow *flow, *flow_iter;
1651 : : struct npc_parse_state parse_state;
1652 : : struct npc_flow_list *list;
1653 : : int rc;
1654 : :
1655 : 0 : npc->channel = roc_npc->channel;
1656 : 0 : npc->is_sdp_link = roc_nix_is_sdp(roc_npc->roc_nix);
1657 [ # # ]: 0 : if (npc->is_sdp_link) {
1658 [ # # ]: 0 : if (roc_npc->is_sdp_mask_set) {
1659 : 0 : npc->sdp_channel = roc_npc->sdp_channel;
1660 : 0 : npc->sdp_channel_mask = roc_npc->sdp_channel_mask;
1661 : : } else {
1662 : 0 : roc_npc_sdp_channel_get(roc_npc, &sdp_chan_base, &sdp_chan_mask);
1663 : 0 : npc->sdp_channel = sdp_chan_base;
1664 : 0 : npc->sdp_channel_mask = sdp_chan_mask;
1665 : : }
1666 : : }
1667 : :
1668 : 0 : flow = plt_zmalloc(sizeof(*flow), 0);
1669 [ # # ]: 0 : if (flow == NULL) {
1670 : 0 : *errcode = NPC_ERR_NO_MEM;
1671 : 0 : return NULL;
1672 : : }
1673 : : memset(flow, 0, sizeof(*flow));
1674 : : memset(&parse_state, 0, sizeof(parse_state));
1675 : :
1676 : 0 : flow->port_id = -1;
1677 [ # # ]: 0 : if (roc_npc->rep_npc) {
1678 : 0 : flow->rep_channel =
1679 [ # # ]: 0 : (roc_npc->rep_rx_channel == 0) ?
1680 : 0 : roc_nix_to_nix_priv(roc_npc->rep_npc->roc_nix)->rx_chan_base :
1681 : : roc_npc->rep_rx_channel;
1682 : 0 : flow->rep_pf_func = roc_npc->rep_pf_func;
1683 : 0 : flow->rep_act_pf_func = roc_npc->rep_act_pf_func;
1684 : 0 : flow->rep_act_rep = roc_npc->rep_act_rep;
1685 : 0 : flow->rep_mbox = roc_npc_to_npc_priv(roc_npc->rep_npc)->mbox;
1686 : 0 : flow->has_rep = true;
1687 : 0 : flow->is_rep_vf = !roc_nix_is_pf(roc_npc->rep_npc->roc_nix);
1688 : 0 : flow->port_id = roc_npc->rep_port_id;
1689 : 0 : flow->rep_npc = roc_npc_to_npc_priv(roc_npc->rep_npc);
1690 : 0 : roc_npc->rep_act_rep = false;
1691 : 0 : roc_npc->rep_act_pf_func = 0;
1692 : 0 : roc_npc->rep_rx_channel = 0;
1693 : : }
1694 : :
1695 : 0 : parse_state.dst_pf_func = dst_pf_func;
1696 : :
1697 : 0 : rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state);
1698 [ # # ]: 0 : if (rc != 0) {
1699 : 0 : *errcode = rc;
1700 : 0 : goto err_exit;
1701 : : }
1702 : :
1703 : 0 : rc = npc_vtag_action_program(roc_npc, actions, flow);
1704 [ # # ]: 0 : if (rc != 0) {
1705 : 0 : *errcode = rc;
1706 : 0 : goto err_exit;
1707 : : }
1708 : :
1709 : 0 : parse_state.is_vf = !roc_nix_is_pf(roc_npc->roc_nix);
1710 : :
1711 : 0 : rc = npc_program_mcam(npc, &parse_state, 1);
1712 [ # # ]: 0 : if (rc != 0) {
1713 : 0 : *errcode = rc;
1714 : 0 : goto err_exit;
1715 : : }
1716 : :
1717 : : /* If Egress mirror requested then enable TL3_TL2_LINK_CFG */
1718 [ # # # # ]: 0 : if (flow->is_sampling_rule && (flow->nix_intf == NIX_INTF_TX)) {
1719 [ # # ]: 0 : if (flow->mcast_pf_funcs[0] == npc->pf_func)
1720 : 0 : rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
1721 : 0 : flow->mcast_pf_funcs[1], true);
1722 : : else
1723 : 0 : rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
1724 : : flow->mcast_pf_funcs[0], true);
1725 [ # # ]: 0 : if (rc) {
1726 : 0 : plt_err("Adding egress mirror failed");
1727 : 0 : *errcode = rc;
1728 : 0 : goto err_exit;
1729 : : }
1730 : : }
1731 : :
1732 : 0 : rc = npc_rss_action_program(roc_npc, actions, flow);
1733 [ # # ]: 0 : if (rc != 0) {
1734 : 0 : *errcode = rc;
1735 : 0 : goto set_rss_failed;
1736 : : }
1737 : 0 : roc_npc->rep_npc = NULL;
1738 : 0 : roc_npc->rep_act_pf_func = 0;
1739 : :
1740 [ # # ]: 0 : if (flow->has_age_action)
1741 : 0 : npc_age_flow_list_entry_add(roc_npc, flow);
1742 : :
1743 [ # # ]: 0 : if (flow->use_pre_alloc == 0)
1744 : 0 : list = &npc->flow_list[flow->priority];
1745 : : else
1746 : 0 : list = &npc->ipsec_list;
1747 : : /* List in ascending order of mcam entries */
1748 [ # # ]: 0 : TAILQ_FOREACH(flow_iter, list, next) {
1749 [ # # ]: 0 : if (flow_iter->mcam_id > flow->mcam_id) {
1750 : 0 : TAILQ_INSERT_BEFORE(flow_iter, flow, next);
1751 : 0 : roc_npc->rep_npc = NULL;
1752 : 0 : return flow;
1753 : : }
1754 : : }
1755 : 0 : TAILQ_INSERT_TAIL(list, flow, next);
1756 : :
1757 : 0 : return flow;
1758 : :
1759 : : set_rss_failed:
1760 : 0 : roc_npc->rep_npc = NULL;
1761 : 0 : roc_npc->rep_act_pf_func = 0;
1762 [ # # ]: 0 : if (flow->use_pre_alloc == 0) {
1763 : 0 : rc = roc_npc_mcam_free_entry(roc_npc, flow->mcam_id);
1764 [ # # ]: 0 : if (rc != 0) {
1765 : 0 : *errcode = rc;
1766 : 0 : plt_free(flow);
1767 : 0 : return NULL;
1768 : : }
1769 : : } else {
1770 : 0 : npc_inline_dev_ipsec_action_free(npc, flow);
1771 : : }
1772 : 0 : err_exit:
1773 : 0 : roc_npc->rep_npc = NULL;
1774 : 0 : roc_npc->rep_act_pf_func = 0;
1775 : 0 : plt_free(flow);
1776 : 0 : return NULL;
1777 : : }
1778 : :
1779 : : int
1780 : 0 : npc_rss_group_free(struct npc *npc, struct roc_npc_flow *flow)
1781 : : {
1782 : : struct npc *lnpc = npc;
1783 : : uint32_t rss_grp;
1784 : :
1785 [ # # ]: 0 : if (flow->has_rep)
1786 : 0 : lnpc = flow->rep_npc;
1787 : :
1788 [ # # ]: 0 : if ((flow->npc_action & 0xF) == NIX_RX_ACTIONOP_RSS) {
1789 : 0 : rss_grp = (flow->npc_action >> NPC_RSS_ACT_GRP_OFFSET) &
1790 : : NPC_RSS_ACT_GRP_MASK;
1791 [ # # # # ]: 0 : if (rss_grp == 0 || rss_grp >= npc->rss_grps)
1792 : : return -EINVAL;
1793 : :
1794 : 0 : plt_bitmap_clear(lnpc->rss_grp_entries, rss_grp);
1795 : : }
1796 : :
1797 : : return 0;
1798 : : }
1799 : :
1800 : : static int
1801 : 0 : roc_npc_delete_spi_to_sa_action(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
1802 : : {
1803 : : struct nix_spi_to_sa_delete_req *req;
1804 : : struct nix_inl_dev *inl_dev;
1805 : : struct idev_cfg *idev;
1806 : : struct mbox *mbox;
1807 : :
1808 : : PLT_SET_USED(roc_npc);
1809 : :
1810 [ # # # # ]: 0 : if (!flow->spi_to_sa_info.has_action || flow->spi_to_sa_info.duplicate)
1811 : : return 0;
1812 : :
1813 : 0 : idev = idev_get_cfg();
1814 [ # # ]: 0 : if (!idev)
1815 : : return -1;
1816 : :
1817 : 0 : inl_dev = idev->nix_inl_dev;
1818 : 0 : mbox = inl_dev->dev.mbox;
1819 : 0 : req = mbox_alloc_msg_nix_spi_to_sa_delete(mbox);
1820 [ # # ]: 0 : if (req == NULL)
1821 : : return -ENOSPC;
1822 : 0 : req->hash_index = flow->spi_to_sa_info.hash_index;
1823 : 0 : req->way = flow->spi_to_sa_info.way;
1824 : 0 : return mbox_process_msg(mbox, NULL);
1825 : : }
1826 : :
1827 : : int
1828 : 0 : roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
1829 : : {
1830 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
1831 : : int rc;
1832 : :
1833 : 0 : rc = roc_npc_delete_spi_to_sa_action(roc_npc, flow);
1834 [ # # ]: 0 : if (rc)
1835 : : return rc;
1836 : :
1837 [ # # ]: 0 : if (npc_inline_dev_ipsec_action_free(npc, flow) == 0) {
1838 [ # # ]: 0 : TAILQ_REMOVE(&npc->ipsec_list, flow, next);
1839 : 0 : goto done;
1840 : : }
1841 : :
1842 : 0 : rc = npc_rss_group_free(npc, flow);
1843 [ # # ]: 0 : if (rc != 0) {
1844 : 0 : plt_err("Failed to free rss action rc = %d", rc);
1845 : 0 : return rc;
1846 : : }
1847 : :
1848 [ # # ]: 0 : if (flow->vtag_insert_enabled) {
1849 : 0 : rc = npc_vtag_cfg_delete(roc_npc, flow);
1850 [ # # ]: 0 : if (rc != 0)
1851 : : return rc;
1852 : : }
1853 : :
1854 : : /* Disable egress mirror rule */
1855 [ # # # # ]: 0 : if (flow->is_sampling_rule && (flow->nix_intf == NIX_INTF_TX)) {
1856 [ # # ]: 0 : if (flow->mcast_pf_funcs[0] == npc->pf_func)
1857 : 0 : rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
1858 : 0 : flow->mcast_pf_funcs[1], false);
1859 : : else
1860 : 0 : rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix,
1861 : : flow->mcast_pf_funcs[0], false);
1862 [ # # ]: 0 : if (rc)
1863 : 0 : plt_err("Failed to remove egress mirror rule");
1864 : : }
1865 [ # # ]: 0 : if (flow->is_sampling_rule)
1866 : 0 : roc_nix_mcast_list_free(npc->mbox, flow->mcast_grp_index);
1867 : :
1868 : 0 : rc = roc_npc_mcam_free(roc_npc, flow);
1869 [ # # ]: 0 : if (rc != 0)
1870 : : return rc;
1871 : :
1872 [ # # ]: 0 : TAILQ_REMOVE(&npc->flow_list[flow->priority], flow, next);
1873 : :
1874 : 0 : npc_delete_prio_list_entry(npc, flow);
1875 : :
1876 [ # # ]: 0 : if (flow->has_age_action)
1877 : 0 : npc_age_flow_list_entry_delete(roc_npc, flow);
1878 : :
1879 [ # # ]: 0 : if (roc_npc->flow_age.age_flow_refcnt == 0)
1880 : 0 : npc_aging_ctrl_thread_destroy(roc_npc);
1881 : :
1882 : 0 : done:
1883 : 0 : plt_free(flow);
1884 : 0 : return 0;
1885 : : }
1886 : :
1887 : : void
1888 : 0 : roc_npc_flow_dump(FILE *file, struct roc_npc *roc_npc, int rep_port_id)
1889 : : {
1890 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
1891 : : struct roc_npc_flow *flow_iter;
1892 : : struct npc_flow_list *list;
1893 : : uint32_t max_prio, i;
1894 : :
1895 : 0 : max_prio = npc->flow_max_priority;
1896 : :
1897 [ # # ]: 0 : for (i = 0; i < max_prio; i++) {
1898 : 0 : list = &npc->flow_list[i];
1899 : :
1900 : : /* List in ascending order of mcam entries */
1901 [ # # ]: 0 : TAILQ_FOREACH(flow_iter, list, next) {
1902 [ # # # # ]: 0 : if (rep_port_id == -1 || rep_port_id == flow_iter->port_id)
1903 : 0 : roc_npc_flow_mcam_dump(file, roc_npc, flow_iter);
1904 : : }
1905 : : }
1906 : :
1907 [ # # ]: 0 : TAILQ_FOREACH(flow_iter, &npc->ipsec_list, next) {
1908 [ # # # # ]: 0 : if (rep_port_id == -1 || rep_port_id == flow_iter->port_id)
1909 : 0 : roc_npc_flow_mcam_dump(file, roc_npc, flow_iter);
1910 : : }
1911 : 0 : }
1912 : :
1913 : : int
1914 : 0 : roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
1915 : : {
1916 : : struct npc *npc = roc_npc_to_npc_priv(roc_npc);
1917 : 0 : struct mbox *mbox = mbox_get(npc->mbox);
1918 : : int idx, rc;
1919 : :
1920 [ # # ]: 0 : if (roc_nix_is_pf(roc_npc->roc_nix)) {
1921 : : rc = 0;
1922 : 0 : goto exit;
1923 : : }
1924 : :
1925 [ # # ]: 0 : if (roc_model_is_cn20k()) {
1926 : : struct npc_cn20k_mcam_read_base_rule_rsp *base_rule_rsp;
1927 : : struct cn20k_mcam_entry *base_entry;
1928 : :
1929 : 0 : (void)mbox_alloc_msg_npc_cn20k_read_base_steer_rule(mbox);
1930 : : rc = mbox_process_msg(mbox, (void *)&base_rule_rsp);
1931 [ # # ]: 0 : if (rc) {
1932 : 0 : plt_err("Failed to fetch VF's base MCAM entry");
1933 : 0 : goto exit;
1934 : : }
1935 : 0 : base_entry = &base_rule_rsp->entry;
1936 [ # # ]: 0 : for (idx = 0; idx < ROC_NPC_MAX_MCAM_WIDTH_DWORDS; idx++) {
1937 : 0 : flow->mcam_data[idx] |= base_entry->kw[idx];
1938 : 0 : flow->mcam_mask[idx] |= base_entry->kw_mask[idx];
1939 : : }
1940 : :
1941 : : } else {
1942 : : struct npc_mcam_read_base_rule_rsp *base_rule_rsp;
1943 : : struct mcam_entry *base_entry;
1944 : :
1945 : 0 : (void)mbox_alloc_msg_npc_read_base_steer_rule(mbox);
1946 : : rc = mbox_process_msg(mbox, (void *)&base_rule_rsp);
1947 [ # # ]: 0 : if (rc) {
1948 : 0 : plt_err("Failed to fetch VF's base MCAM entry");
1949 : 0 : goto exit;
1950 : : }
1951 : 0 : base_entry = &base_rule_rsp->entry_data;
1952 [ # # ]: 0 : for (idx = 0; idx < ROC_NPC_MAX_MCAM_WIDTH_DWORDS; idx++) {
1953 : 0 : flow->mcam_data[idx] |= base_entry->kw[idx];
1954 : 0 : flow->mcam_mask[idx] |= base_entry->kw_mask[idx];
1955 : : }
1956 : : }
1957 : : rc = 0;
1958 : 0 : exit:
1959 : : mbox_put(mbox);
1960 : 0 : return rc;
1961 : : }
|