NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_control_pipe_sample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #include <string.h>
27 #include <unistd.h>
28 
29 #include <rte_byteorder.h>
30 
31 #include <doca_flow.h>
32 #include <doca_log.h>
33 #include <doca_bitfield.h>
34 
35 #include "flow_common.h"
36 
37 DOCA_LOG_REGISTER(FLOW_CONTROL_PIPE);
38 
39 #define NB_ACTION_DESC (1)
40 #define DEFAULT_CTRL_PIPE_SIZE (8192)
41 
42 /*
43  * Create DOCA Flow pipe that match VXLAN traffic with changeable VXLAN tunnel ID and decap action
44  *
45  * @port [in]: port of the pipe
46  * @port_id [in]: port ID of the pipe
47  * @pipe [out]: created pipe pointer
48  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
49  */
50 static doca_error_t create_vxlan_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
51 {
52  struct doca_flow_match match;
53  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
54  struct doca_flow_fwd fwd;
55  struct doca_flow_pipe_cfg *pipe_cfg;
57 
58  memset(&match, 0, sizeof(match));
59  memset(&actions, 0, sizeof(actions));
60  memset(&fwd, 0, sizeof(fwd));
61 
64  match.tun.vxlan_tun_id = 0xffffffff;
65 
67  actions.decap_cfg.is_l2 = true;
68  actions_arr[0] = &actions;
69 
70  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
71  if (result != DOCA_SUCCESS) {
72  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
73  return result;
74  }
75 
76  result = set_flow_pipe_cfg(pipe_cfg, "VXLAN_PIPE", DOCA_FLOW_PIPE_BASIC, false);
77  if (result != DOCA_SUCCESS) {
78  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
79  goto destroy_pipe_cfg;
80  }
81  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
82  if (result != DOCA_SUCCESS) {
83  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
84  goto destroy_pipe_cfg;
85  }
86  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
87  if (result != DOCA_SUCCESS) {
88  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
89  goto destroy_pipe_cfg;
90  }
91 
93  fwd.port_id = port_id ^ 1;
94 
95  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
98  return result;
99 }
100 
101 /*
102  * Add DOCA Flow pipe entry with example VXLAN tunnel ID to match
103  *
104  * @pipe [in]: pipe of the entry
105  * @status [in]: user context for adding entry
106  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
107  */
108 static doca_error_t add_vxlan_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
109 {
110  struct doca_flow_match match;
111  struct doca_flow_actions actions;
112  struct doca_flow_pipe_entry *entry;
113 
114  doca_be32_t vxlan_tun_id = DOCA_HTOBE32(0xcdab12);
116 
117  memset(&match, 0, sizeof(match));
118  memset(&actions, 0, sizeof(actions));
119 
120  match.tun.vxlan_tun_id = vxlan_tun_id;
121  actions.action_idx = 0;
122 
124  pipe,
125  &match,
126  &actions,
127  NULL,
128  NULL,
130  status,
131  &entry);
132  if (result != DOCA_SUCCESS)
133  return result;
134 
135  return DOCA_SUCCESS;
136 }
137 
138 /*
139  * Create DOCA Flow pipe that match VXLAN-GPE traffic with changeable VXLAN tunnel ID/next
140  * protocol and fwd to peer port
141  *
142  * @port [in]: port of the pipe
143  * @port_id [in]: port ID of the pipe
144  * @pipe [out]: created pipe pointer
145  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
146  */
147 static doca_error_t create_vxlan_gpe_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
148 {
149  struct doca_flow_match match;
150  struct doca_flow_fwd fwd;
151  struct doca_flow_pipe_cfg *pipe_cfg;
153  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
154  uint8_t src_mac[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
155  uint8_t dst_mac[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
156 
157  memset(&match, 0, sizeof(match));
158  memset(&fwd, 0, sizeof(fwd));
159  memset(&actions, 0, sizeof(actions));
160 
161  match.tun.type = DOCA_FLOW_TUN_VXLAN;
163  match.tun.vxlan_tun_id = 0xffffffff;
164  match.tun.vxlan_gpe_next_protocol = 0xff;
165  match.tun.vxlan_gpe_flags = 0xff;
166 
168  actions.decap_cfg.is_l2 = false;
169  /* append eth header after decap vxlan-gpe tunnel for case next_proto is IPV4 */
171  src_mac[0],
172  src_mac[1],
173  src_mac[2],
174  src_mac[3],
175  src_mac[4],
176  src_mac[5]);
178  dst_mac[0],
179  dst_mac[1],
180  dst_mac[2],
181  dst_mac[3],
182  dst_mac[4],
183  dst_mac[5]);
185  actions_arr[0] = &actions;
186 
187  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
188  if (result != DOCA_SUCCESS) {
189  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
190  return result;
191  }
192 
193  result = set_flow_pipe_cfg(pipe_cfg, "VXLAN_PIPE_GPE", DOCA_FLOW_PIPE_BASIC, false);
194  if (result != DOCA_SUCCESS) {
195  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
196  goto destroy_pipe_cfg;
197  }
198 
199  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
200  if (result != DOCA_SUCCESS) {
201  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
202  goto destroy_pipe_cfg;
203  }
204 
205  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
206  if (result != DOCA_SUCCESS) {
207  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
208  goto destroy_pipe_cfg;
209  }
210 
212  fwd.port_id = port_id ^ 1;
213 
214  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
216  doca_flow_pipe_cfg_destroy(pipe_cfg);
217  return result;
218 }
219 
220 /*
221  * Add DOCA Flow pipe entry with example VXLAN-GPE tunnel ID to match
222  *
223  * @pipe [in]: pipe of the entry
224  * @status [in]: user context for adding entry
225  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
226  */
227 static doca_error_t add_vxlan_gpe_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
228 {
229  struct doca_flow_match match;
230  struct doca_flow_pipe_entry *entry;
231 
232  doca_be32_t vxlan_tun_id = DOCA_HTOBE32(0xcdab12);
234 
235  memset(&match, 0, sizeof(match));
236 
237  match.tun.vxlan_tun_id = vxlan_tun_id;
239  match.tun.vxlan_gpe_flags = 0xF;
240 
242  if (result != DOCA_SUCCESS)
243  return result;
244 
245  return DOCA_SUCCESS;
246 }
247 
248 /*
249  * Create DOCA Flow pipe that match MPLS traffic with changeable MPLS tunnel ID and decap action
250  *
251  * @port [in]: port of the pipe
252  * @port_id [in]: port ID of the pipe
253  * @pipe [out]: created pipe pointer
254  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
255  */
256 static doca_error_t create_mpls_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
257 {
258  struct doca_flow_match match;
260  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
261  struct doca_flow_fwd fwd;
262  struct doca_flow_pipe_cfg *pipe_cfg;
263  uint8_t src_mac[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
264  uint8_t dst_mac[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
266 
267  memset(&match, 0, sizeof(match));
268  memset(&match_mask, 0, sizeof(match_mask));
269  memset(&actions, 0, sizeof(actions));
270  memset(&fwd, 0, sizeof(fwd));
271 
273  actions.decap_cfg.is_l2 = false;
274  /* append eth header after decap MPLS tunnel */
276  src_mac[0],
277  src_mac[1],
278  src_mac[2],
279  src_mac[3],
280  src_mac[4],
281  src_mac[5]);
283  dst_mac[0],
284  dst_mac[1],
285  dst_mac[2],
286  dst_mac[3],
287  dst_mac[4],
288  dst_mac[5]);
290  actions_arr[0] = &actions;
291 
293  match.outer.udp.l4_port.dst_port = rte_cpu_to_be_16(DOCA_FLOW_MPLS_DEFAULT_PORT);
295  match.tun.mpls[2].label = 0xffffffff;
296 
297  result = doca_flow_mpls_label_encode(0xfffff, 0, 0, true, &match_mask.tun.mpls[2]);
298  if (result != DOCA_SUCCESS)
299  return result;
300 
301  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
302  if (result != DOCA_SUCCESS) {
303  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
304  return result;
305  }
306 
307  result = set_flow_pipe_cfg(pipe_cfg, "MPLS_PIPE", DOCA_FLOW_PIPE_BASIC, false);
308  if (result != DOCA_SUCCESS) {
309  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
310  goto destroy_pipe_cfg;
311  }
312  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, &match_mask);
313  if (result != DOCA_SUCCESS) {
314  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
315  goto destroy_pipe_cfg;
316  }
317  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
318  if (result != DOCA_SUCCESS) {
319  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
320  goto destroy_pipe_cfg;
321  }
322 
324  fwd.port_id = port_id ^ 1;
325 
326  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
328  doca_flow_pipe_cfg_destroy(pipe_cfg);
329  return result;
330 }
331 
332 /*
333  * Add DOCA Flow pipe entry with example MPLS tunnel ID to match
334  *
335  * @pipe [in]: pipe of the entry
336  * @status [in]: user context for adding entry
337  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
338  */
339 static doca_error_t add_mpls_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
340 {
341  struct doca_flow_match match;
342  struct doca_flow_actions actions;
343  struct doca_flow_pipe_entry *entry;
345 
346  memset(&match, 0, sizeof(match));
347  memset(&actions, 0, sizeof(actions));
348 
349  actions.action_idx = 0;
350 
351  result = doca_flow_mpls_label_encode(0xababa, 0, 0, true, &match.tun.mpls[2]);
352  if (result != DOCA_SUCCESS)
353  return result;
354 
356  pipe,
357  &match,
358  &actions,
359  NULL,
360  NULL,
362  status,
363  &entry);
364  if (result != DOCA_SUCCESS)
365  return result;
366 
367  return DOCA_SUCCESS;
368 }
369 
370 /*
371  * Create DOCA Flow pipe that match GRE traffic with changeable GRE key and decap action
372  *
373  * @port [in]: port of the pipe
374  * @port_id [in]: port ID of the pipe
375  * @pipe [out]: created pipe pointer
376  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
377  */
378 static doca_error_t create_gre_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
379 {
380  struct doca_flow_match match;
381  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
382  struct doca_flow_fwd fwd;
383  struct doca_flow_pipe_cfg *pipe_cfg;
384  uint8_t src_mac[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
385  uint8_t dst_mac[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
387 
388  memset(&match, 0, sizeof(match));
389  memset(&actions, 0, sizeof(actions));
390  memset(&fwd, 0, sizeof(fwd));
391 
392  match.tun.type = DOCA_FLOW_TUN_GRE;
393  match.tun.key_present = true;
394  match.tun.gre_key = 0xffffffff;
395 
397  actions.decap_cfg.is_l2 = false;
398 
399  /* append eth header after decap GRE tunnel */
401  src_mac[0],
402  src_mac[1],
403  src_mac[2],
404  src_mac[3],
405  src_mac[4],
406  src_mac[5]);
408  dst_mac[0],
409  dst_mac[1],
410  dst_mac[2],
411  dst_mac[3],
412  dst_mac[4],
413  dst_mac[5]);
415  actions_arr[0] = &actions;
416 
417  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
418  if (result != DOCA_SUCCESS) {
419  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
420  return result;
421  }
422 
423  result = set_flow_pipe_cfg(pipe_cfg, "GRE_PIPE", DOCA_FLOW_PIPE_BASIC, false);
424  if (result != DOCA_SUCCESS) {
425  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
426  goto destroy_pipe_cfg;
427  }
428  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
429  if (result != DOCA_SUCCESS) {
430  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
431  goto destroy_pipe_cfg;
432  }
433  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
434  if (result != DOCA_SUCCESS) {
435  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
436  goto destroy_pipe_cfg;
437  }
438 
440  fwd.port_id = port_id ^ 1;
441 
442  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
444  doca_flow_pipe_cfg_destroy(pipe_cfg);
445  return result;
446 }
447 
448 /*
449  * Add DOCA Flow pipe entry with example GRE key to match
450  *
451  * @pipe [in]: pipe of the entry
452  * @status [in]: user context for adding entry
453  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
454  */
455 static doca_error_t add_gre_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
456 {
457  struct doca_flow_match match;
458  struct doca_flow_actions actions;
459  struct doca_flow_pipe_entry *entry;
460  doca_be32_t gre_key = RTE_BE32(900);
462 
463  memset(&match, 0, sizeof(match));
464  memset(&actions, 0, sizeof(actions));
465 
466  match.tun.gre_key = gre_key;
467  actions.action_idx = 0;
468 
469  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, DOCA_FLOW_NO_WAIT, status, &entry);
470  if (result != DOCA_SUCCESS)
471  return result;
472 
473  return DOCA_SUCCESS;
474 }
475 
476 /*
477  * Create DOCA Flow pipe and entry that match NVGRE traffic with changeable vs_id/flow_id and
478  * do hairpin action
479  *
480  * @port [in]: port of the pipe
481  * @port_id [in]: port ID of the pipe
482  * @status [in]: user context for adding entry
483  * @num_of_entries [in]: total entry number
484  * @pipe [out]: created pipe pointer
485  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
486  */
487 static doca_error_t create_nvgre_pipe_and_entry(struct doca_flow_port *port,
488  int port_id,
489  struct entries_status *status,
490  int *num_of_entries,
491  struct doca_flow_pipe **pipe)
492 {
493  struct doca_flow_match match;
494  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
495  struct doca_flow_fwd fwd;
496  struct doca_flow_pipe_cfg *pipe_cfg;
497  struct doca_flow_pipe_entry *entry;
499 
500  memset(&match, 0, sizeof(match));
501  memset(&actions, 0, sizeof(actions));
502  memset(&fwd, 0, sizeof(fwd));
503 
504  match.tun.type = DOCA_FLOW_TUN_GRE;
506  match.tun.protocol = RTE_BE16(DOCA_FLOW_ETHER_TYPE_TEB);
507  match.tun.nvgre_vs_id = 0xffffffff;
508  match.tun.nvgre_flow_id = 0xff;
509  match.inner.eth.type = RTE_BE16(DOCA_FLOW_ETHER_TYPE_IPV4);
513  match.inner.udp.l4_port.src_port = RTE_BE16(1111);
514 
515  actions_arr[0] = &actions;
516 
517  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
518  if (result != DOCA_SUCCESS) {
519  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
520  return result;
521  }
522 
523  result = set_flow_pipe_cfg(pipe_cfg, "NVGRE_PIPE", DOCA_FLOW_PIPE_BASIC, false);
524  if (result != DOCA_SUCCESS) {
525  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
526  goto destroy_pipe_cfg;
527  }
528  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
529  if (result != DOCA_SUCCESS) {
530  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
531  goto destroy_pipe_cfg;
532  }
533  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
534  if (result != DOCA_SUCCESS) {
535  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
536  goto destroy_pipe_cfg;
537  }
538 
540  fwd.port_id = port_id ^ 1;
541 
542  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
543  if (result != DOCA_SUCCESS) {
544  DOCA_LOG_ERR("Failed to create nvgre pipe: %s", doca_error_get_descr(result));
545  goto destroy_pipe_cfg;
546  }
547 
548  memset(&match, 0, sizeof(match));
549  memset(&actions, 0, sizeof(actions));
550 
551  match.tun.nvgre_vs_id = RTE_BE32((uint32_t)0x123456 << 8);
552  match.tun.nvgre_flow_id = 0x78;
553  actions.action_idx = 0;
554 
555  result = doca_flow_pipe_add_entry(0, *pipe, &match, &actions, NULL, NULL, DOCA_FLOW_NO_WAIT, status, &entry);
556  if (result == DOCA_SUCCESS) {
557  (*num_of_entries)++;
558  }
560  doca_flow_pipe_cfg_destroy(pipe_cfg);
561  return result;
562 }
563 
564 /*
565  * Create DOCA Flow control pipe
566  *
567  * @port [in]: port of the pipe
568  * @pipe [out]: created pipe pointer
569  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
570  */
571 static doca_error_t create_control_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
572 {
573  struct doca_flow_pipe_cfg *pipe_cfg;
575 
576  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
577  if (result != DOCA_SUCCESS) {
578  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
579  return result;
580  }
581 
582  result = set_flow_pipe_cfg(pipe_cfg, "CONTROL_PIPE", DOCA_FLOW_PIPE_CONTROL, true);
583  if (result != DOCA_SUCCESS) {
584  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
585  goto destroy_pipe_cfg;
586  }
587 
588  result = doca_flow_pipe_create(pipe_cfg, NULL, NULL, pipe);
590  doca_flow_pipe_cfg_destroy(pipe_cfg);
591  return result;
592 }
593 
594 /*
595  * Add DOCA Flow control entry jump to the NVGRE pipe
596  *
597  * @control_pipe [in]: the control pipe
598  * @nvgre_pipe [in]: the nvgre pipe
599  * @status [in]: user context for adding entry
600  * @priority [in]: the priority of the new entry
601  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
602  */
603 static doca_error_t control_add_nvgre_entry(struct doca_flow_pipe *control_pipe,
604  struct doca_flow_pipe *nvgre_pipe,
605  struct entries_status *status,
606  uint8_t priority)
607 {
608  struct doca_flow_match match;
609  struct doca_flow_fwd fwd;
610 
611  memset(&match, 0, sizeof(match));
612  memset(&fwd, 0, sizeof(fwd));
613 
617  match.tun.type = DOCA_FLOW_TUN_GRE;
619  match.tun.protocol = RTE_BE16(DOCA_FLOW_ETHER_TYPE_TEB);
620 
622  fwd.next_pipe = nvgre_pipe;
623 
625  priority,
626  control_pipe,
627  &match,
628  NULL,
629  NULL,
630  NULL,
631  NULL,
632  NULL,
633  NULL,
634  &fwd,
635  status,
636  NULL);
637 }
638 
639 /*
640  * Add DOCA Flow pipe entries to the control pipe:
641  * - entry with VXLAN match that forward the matched packet to vxlan_pipe
642  * - entry with VXLAN-GPE match that forward the matched packet to vxlan_gpe_pipe
643  * - entry with MPLS match that forward the matched packet to mpls_pipe
644  * - entry with GRE match that forward the matched packet to gre_pipe
645  *
646  * @control_pipe [in]: pipe of the entry
647  * @vxlan_pipe [in]: pipe to forward VXLAN traffic
648  * @vxlan_gpe_pipe [in]: pipe to forward VXLAN-GPE traffic
649  * @mpls_pipe [in]: pipe to forward MPLS traffic
650  * @gre_pipe [in]: pipe to forward GRE traffic
651  * @nvgre_pipe [in]: pipe to forward NVGRE traffic
652  * @status [in]: user context for adding entry
653  * @num_of_entries [in]: total entry number
654  * @shared_counter_id [in]: shared counter id
655  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
656  */
657 static doca_error_t add_control_pipe_entries(struct doca_flow_pipe *control_pipe,
658  struct doca_flow_pipe *vxlan_pipe,
659  struct doca_flow_pipe *vxlan_gpe_pipe,
660  struct doca_flow_pipe *mpls_pipe,
661  struct doca_flow_pipe *gre_pipe,
662  struct doca_flow_pipe *nvgre_pipe,
663  struct entries_status *status,
664  int *num_of_entries,
665  int shared_counter_id)
666 {
667  struct doca_flow_match match;
668  struct doca_flow_fwd fwd;
669  struct doca_flow_monitor monitor;
670  uint8_t priority = 0;
672 
673  memset(&match, 0, sizeof(match));
674  memset(&fwd, 0, sizeof(fwd));
675  memset(&monitor, 0, sizeof(monitor));
676 
677  /* set shared counter ID */
679  monitor.shared_counter.shared_counter_id = shared_counter_id;
680 
684  match.outer.udp.l4_port.dst_port = rte_cpu_to_be_16(DOCA_FLOW_VXLAN_GPE_DEFAULT_PORT);
685 
687  fwd.next_pipe = vxlan_gpe_pipe;
688 
690  priority,
691  control_pipe,
692  &match,
693  NULL,
694  NULL,
695  NULL,
696  NULL,
697  NULL,
698  &monitor,
699  &fwd,
700  status,
701  NULL);
702  if (result != DOCA_SUCCESS) {
703  DOCA_LOG_ERR("Failed to add control pipe entry: %s", doca_error_get_descr(result));
704  return result;
705  }
706  (*num_of_entries)++;
707 
708  memset(&match, 0, sizeof(match));
709  memset(&fwd, 0, sizeof(fwd));
710 
714  match.outer.udp.l4_port.dst_port = rte_cpu_to_be_16(DOCA_FLOW_VXLAN_DEFAULT_PORT);
715 
717  fwd.next_pipe = vxlan_pipe;
718 
720  priority,
721  control_pipe,
722  &match,
723  NULL,
724  NULL,
725  NULL,
726  NULL,
727  NULL,
728  &monitor,
729  &fwd,
730  status,
731  NULL);
732  if (result != DOCA_SUCCESS) {
733  DOCA_LOG_ERR("Failed to add control pipe entry: %s", doca_error_get_descr(result));
734  return result;
735  }
736  (*num_of_entries)++;
737 
738  memset(&match, 0, sizeof(match));
739  memset(&fwd, 0, sizeof(fwd));
740 
744  match.outer.udp.l4_port.dst_port = rte_cpu_to_be_16(DOCA_FLOW_MPLS_DEFAULT_PORT);
745 
747  fwd.next_pipe = mpls_pipe;
748 
750  priority,
751  control_pipe,
752  &match,
753  NULL,
754  NULL,
755  NULL,
756  NULL,
757  NULL,
758  &monitor,
759  &fwd,
760  status,
761  NULL);
762  if (result != DOCA_SUCCESS) {
763  DOCA_LOG_ERR("Failed to add control pipe entry: %s", doca_error_get_descr(result));
764  return result;
765  }
766  (*num_of_entries)++;
767 
768  memset(&match, 0, sizeof(match));
769  memset(&fwd, 0, sizeof(fwd));
770 
774 
776  fwd.next_pipe = gre_pipe;
777 
779  priority + 1,
780  control_pipe,
781  &match,
782  NULL,
783  NULL,
784  NULL,
785  NULL,
786  NULL,
787  &monitor,
788  &fwd,
789  status,
790  NULL);
791  if (result != DOCA_SUCCESS) {
792  DOCA_LOG_ERR("Failed to add control pipe entry: %s", doca_error_get_descr(result));
793  return result;
794  }
795  (*num_of_entries)++;
796 
797  if (nvgre_pipe) {
798  result = control_add_nvgre_entry(control_pipe, nvgre_pipe, status, priority);
799  if (result != DOCA_SUCCESS) {
800  DOCA_LOG_ERR("Failed to add control pipe entry: %s", doca_error_get_descr(result));
801  return result;
802  }
803  (*num_of_entries)++;
804  }
805  return DOCA_SUCCESS;
806 }
807 
808 /*
809  * Run flow_control_pipe sample
810  *
811  * @nb_queues [in]: number of queues the sample will use
812  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
813  */
815 {
816  int nb_ports = 2;
817  struct flow_resources resource = {0};
818  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
819  struct doca_flow_port *ports[nb_ports];
820  struct doca_dev *dev_arr[nb_ports];
821  uint32_t actions_mem_size[nb_ports];
822  struct doca_flow_pipe *vxlan_pipe;
823  struct doca_flow_pipe *vxlan_gpe_pipe;
824  struct doca_flow_pipe *mpls_pipe;
825  struct doca_flow_pipe *gre_pipe;
826  struct doca_flow_pipe *nvgre_pipe;
827  struct doca_flow_pipe *control_pipe;
828  struct entries_status status;
829  int num_of_entries = 0;
831  int port_id;
832  uint32_t shared_counter_ids[] = {0, 1};
833  struct doca_flow_shared_resource_cfg cfg = {0};
834  struct doca_flow_resource_query query_results_array[nb_ports];
835 
836  nr_shared_resources[DOCA_FLOW_SHARED_RESOURCE_COUNTER] = 2;
837  result = init_doca_flow(nb_queues, "vnf,hws", &resource, nr_shared_resources);
838  if (result != DOCA_SUCCESS) {
839  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
840  return result;
841  }
842 
843  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
846  if (result != DOCA_SUCCESS) {
847  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
849  return result;
850  }
851 
852  for (port_id = 0; port_id < nb_ports; port_id++, num_of_entries = 0) {
853  memset(&status, 0, sizeof(status));
854 
855  /* config and bind shared counter to port */
857  if (result != DOCA_SUCCESS) {
858  DOCA_LOG_ERR("Failed to configure shared counter to port %d", port_id);
861  return result;
862  }
863 
865  &shared_counter_ids[port_id],
866  1,
867  ports[port_id]);
868  if (result != DOCA_SUCCESS) {
869  DOCA_LOG_ERR("Failed to bind shared counter to pipe");
872  return result;
873  }
874 
875  result = create_vxlan_pipe(ports[port_id], port_id, &vxlan_pipe);
876  if (result != DOCA_SUCCESS) {
877  DOCA_LOG_ERR("Failed to add vxlan pipe: %s", doca_error_get_descr(result));
880  return result;
881  }
882 
883  result = add_vxlan_pipe_entry(vxlan_pipe, &status);
884  if (result != DOCA_SUCCESS) {
885  DOCA_LOG_ERR("Failed to add vxlan pipe entry: %s", doca_error_get_descr(result));
888  return result;
889  }
890  num_of_entries++;
891 
892  result = create_vxlan_gpe_pipe(ports[port_id], port_id, &vxlan_gpe_pipe);
893  if (result != DOCA_SUCCESS) {
894  DOCA_LOG_ERR("Failed to add vxlan gpe pipe: %s", doca_error_get_descr(result));
897  return result;
898  }
899 
900  result = add_vxlan_gpe_pipe_entry(vxlan_gpe_pipe, &status);
901  if (result != DOCA_SUCCESS) {
902  DOCA_LOG_ERR("Failed to add vxlan gpe pipe entry: %s", doca_error_get_descr(result));
905  return result;
906  }
907  num_of_entries++;
908 
909  result = create_mpls_pipe(ports[port_id], port_id, &mpls_pipe);
910  if (result != DOCA_SUCCESS) {
911  DOCA_LOG_ERR("Failed to add mpls pipe: %s", doca_error_get_descr(result));
914  return result;
915  }
916 
917  result = add_mpls_pipe_entry(mpls_pipe, &status);
918  if (result != DOCA_SUCCESS) {
919  DOCA_LOG_ERR("Failed to add mpls pipe entry: %s", doca_error_get_descr(result));
922  return result;
923  }
924  num_of_entries++;
925 
926  result = create_gre_pipe(ports[port_id], port_id, &gre_pipe);
927  if (result != DOCA_SUCCESS) {
928  DOCA_LOG_ERR("Failed to add gre pipe: %s", doca_error_get_descr(result));
931  return result;
932  }
933 
934  result = add_gre_pipe_entry(gre_pipe, &status);
935  if (result != DOCA_SUCCESS) {
936  DOCA_LOG_ERR("Failed to add gre pipe entry: %s", doca_error_get_descr(result));
939  return result;
940  }
941  num_of_entries++;
942 
943  result = create_nvgre_pipe_and_entry(ports[port_id], port_id, &status, &num_of_entries, &nvgre_pipe);
944  if (result != DOCA_SUCCESS) {
945  DOCA_LOG_ERR("Failed to add gre pipe or entry: %s", doca_error_get_descr(result));
948  return result;
949  }
950 
951  result = create_control_pipe(ports[port_id], &control_pipe);
952  if (result != DOCA_SUCCESS) {
953  DOCA_LOG_ERR("Failed to create control pipe: %s", doca_error_get_descr(result));
956  return result;
957  }
958 
959  result = add_control_pipe_entries(control_pipe,
960  vxlan_pipe,
961  vxlan_gpe_pipe,
962  mpls_pipe,
963  gre_pipe,
964  nvgre_pipe,
965  &status,
966  &num_of_entries,
967  shared_counter_ids[port_id]);
968  if (result != DOCA_SUCCESS) {
971  return result;
972  }
973 
974  result = doca_flow_entries_process(ports[port_id], 0, DEFAULT_TIMEOUT_US, num_of_entries);
975  if (result != DOCA_SUCCESS) {
976  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
979  return result;
980  }
981 
982  if (status.nb_processed != num_of_entries || status.failure) {
983  DOCA_LOG_ERR("Failed to process entries");
986  return DOCA_ERROR_BAD_STATE;
987  }
988  }
989 
990  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
991  sleep(10);
992 
994  shared_counter_ids,
995  query_results_array,
996  nb_ports);
997  if (result != DOCA_SUCCESS) {
998  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
1001  return result;
1002  }
1003 
1004  for (port_id = 0; port_id < nb_ports; port_id++) {
1005  DOCA_LOG_INFO("Port %d:", port_id);
1006  DOCA_LOG_INFO("Total bytes: %ld", query_results_array[port_id].counter.total_bytes);
1007  DOCA_LOG_INFO("Total packets: %ld", query_results_array[port_id].counter.total_pkts);
1008  }
1009 
1012  return result;
1013 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
Definition: flow.c:37
#define SET_MAC_ADDR(addr, a, b, c, d, e, f)
Definition: flow_common.h:60
static doca_error_t create_vxlan_gpe_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
static doca_error_t create_control_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
static doca_error_t add_vxlan_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t control_add_nvgre_entry(struct doca_flow_pipe *control_pipe, struct doca_flow_pipe *nvgre_pipe, struct entries_status *status, uint8_t priority)
static doca_error_t add_vxlan_gpe_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t create_nvgre_pipe_and_entry(struct doca_flow_port *port, int port_id, struct entries_status *status, int *num_of_entries, struct doca_flow_pipe **pipe)
DOCA_LOG_REGISTER(FLOW_CONTROL_PIPE)
static doca_error_t add_mpls_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t create_vxlan_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
#define DEFAULT_CTRL_PIPE_SIZE
doca_error_t flow_control_pipe(int nb_queues)
static doca_error_t create_mpls_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
static doca_error_t add_gre_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t add_control_pipe_entries(struct doca_flow_pipe *control_pipe, struct doca_flow_pipe *vxlan_pipe, struct doca_flow_pipe *vxlan_gpe_pipe, struct doca_flow_pipe *mpls_pipe, struct doca_flow_pipe *gre_pipe, struct doca_flow_pipe *nvgre_pipe, struct entries_status *status, int *num_of_entries, int shared_counter_id)
static doca_error_t create_gre_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static struct doca_flow_actions actions
Definition: flow_parser.c:107
static struct doca_flow_monitor monitor
Definition: flow_parser.c:108
static struct doca_flow_fwd fwd
Definition: flow_parser.c:109
static struct doca_flow_match match_mask
Definition: flow_parser.c:106
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
#define DEFAULT_TIMEOUT_US
Definition: flow_skeleton.c:36
#define DOCA_HTOBE32(_x)
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_BAD_STATE
Definition: doca_error.h:56
@ DOCA_SUCCESS
Definition: doca_error.h:38
#define DOCA_FLOW_MPLS_DEFAULT_PORT
Definition: doca_flow_net.h:51
#define DOCA_FLOW_VXLAN_GPE_DEFAULT_PORT
Definition: doca_flow_net.h:50
#define DOCA_FLOW_VXLAN_DEFAULT_PORT
Definition: doca_flow_net.h:49
#define DOCA_FLOW_PROTO_GRE
Definition: doca_flow_net.h:44
#define DOCA_FLOW_PROTO_UDP
Definition: doca_flow_net.h:42
#define DOCA_FLOW_VXLAN_GPE_TYPE_IPV4
Definition: doca_flow_net.h:98
#define DOCA_FLOW_ETHER_TYPE_TEB
Definition: doca_flow_net.h:59
#define DOCA_FLOW_ETHER_TYPE_IPV4
Definition: doca_flow_net.h:57
@ DOCA_FLOW_L4_TYPE_EXT_UDP
@ DOCA_FLOW_L3_TYPE_IP4
@ DOCA_FLOW_TUN_EXT_VXLAN_STANDARD
@ DOCA_FLOW_TUN_EXT_VXLAN_GPE
@ DOCA_FLOW_TUN_GRE
@ DOCA_FLOW_TUN_VXLAN
@ DOCA_FLOW_TUN_MPLS_O_UDP
@ DOCA_FLOW_TUN_EXT_GRE_NVGRE
@ DOCA_FLOW_TUN_EXT_GRE_STANDARD
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_destroy(struct doca_flow_pipe_cfg *cfg)
Destroy DOCA Flow pipe configuration struct.
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_create(struct doca_flow_pipe_cfg **cfg, struct doca_flow_port *port)
Create DOCA Flow pipe configuration struct.
DOCA_STABLE doca_error_t doca_flow_entries_process(struct doca_flow_port *port, uint16_t pipe_queue, uint64_t timeout, uint32_t max_processed_entries)
Process entries in queue.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_cfg_set_match(struct doca_flow_pipe_cfg *cfg, const struct doca_flow_match *match, const struct doca_flow_match *match_mask)
Set pipe's match and match mask.
DOCA_STABLE doca_error_t doca_flow_shared_resources_bind(enum doca_flow_shared_resource_type type, uint32_t *res_array, uint32_t res_array_len, void *bindable_obj)
Binds a bulk of shared resources to a bindable object.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_control_add_entry(uint16_t pipe_queue, uint32_t priority, struct doca_flow_pipe *pipe, const struct doca_flow_match *match, const struct doca_flow_match *match_mask, const struct doca_flow_match_condition *condition, const struct doca_flow_actions *actions, const struct doca_flow_actions *actions_mask, const struct doca_flow_action_descs *action_descs, const struct doca_flow_monitor *monitor, const struct doca_flow_fwd *fwd, void *usr_ctx, struct doca_flow_pipe_entry **entry)
Add one new entry to a control pipe.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_create(const struct doca_flow_pipe_cfg *cfg, const struct doca_flow_fwd *fwd, const struct doca_flow_fwd *fwd_miss, struct doca_flow_pipe **pipe)
Create one new pipe.
DOCA_EXPERIMENTAL doca_error_t doca_flow_shared_resource_set_cfg(enum doca_flow_shared_resource_type type, uint32_t id, struct doca_flow_shared_resource_cfg *cfg)
Configure a single shared resource.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_cfg_set_actions(struct doca_flow_pipe_cfg *cfg, struct doca_flow_actions *const *actions, struct doca_flow_actions *const *actions_masks, struct doca_flow_action_descs *const *action_descs, size_t nr_actions)
Set pipe's actions, actions mask and actions descriptor.
DOCA_EXPERIMENTAL doca_error_t doca_flow_mpls_label_encode(uint32_t label, uint8_t traffic_class, uint8_t ttl, bool bottom_of_stack, struct doca_flow_header_mpls *mpls)
Prepare an MPLS label header in big-endian.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_add_entry(uint16_t pipe_queue, struct doca_flow_pipe *pipe, const struct doca_flow_match *match, const struct doca_flow_actions *actions, const struct doca_flow_monitor *monitor, const struct doca_flow_fwd *fwd, uint32_t flags, void *usr_ctx, struct doca_flow_pipe_entry **entry)
Add one new entry to a pipe.
DOCA_STABLE void doca_flow_destroy(void)
Destroy the doca flow.
DOCA_EXPERIMENTAL doca_error_t doca_flow_shared_resources_query(enum doca_flow_shared_resource_type type, uint32_t *res_array, struct doca_flow_resource_query *query_results_array, uint32_t array_len)
Extract information about shared counter.
@ DOCA_FLOW_SHARED_RESOURCE_COUNTER
Definition: doca_flow.h:95
@ DOCA_FLOW_PIPE_CONTROL
Definition: doca_flow.h:223
@ DOCA_FLOW_PIPE_BASIC
Definition: doca_flow.h:221
@ DOCA_FLOW_L3_META_IPV4
Definition: doca_flow.h:296
@ DOCA_FLOW_NO_WAIT
Definition: doca_flow.h:115
@ DOCA_FLOW_WAIT_FOR_BATCH
Definition: doca_flow.h:117
@ DOCA_FLOW_RESOURCE_TYPE_SHARED
Definition: doca_flow.h:614
@ DOCA_FLOW_RESOURCE_TYPE_NON_SHARED
Definition: doca_flow.h:615
@ DOCA_FLOW_FWD_PORT
Definition: doca_flow.h:744
@ DOCA_FLOW_FWD_PIPE
Definition: doca_flow.h:746
@ DOCA_FLOW_L4_META_UDP
Definition: doca_flow.h:310
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
Definition: doca_log.h:486
uint32_t doca_be32_t
Definition: doca_types.h:121
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
doca_error_t stop_doca_flow_ports(int nb_ports, struct doca_flow_port *ports[])
Definition: flow_common.c:240
doca_error_t init_doca_flow_ports(int nb_ports, struct doca_flow_port *ports[], bool is_hairpin, struct doca_dev *dev_arr[], uint32_t actions_mem_size[])
Definition: flow_common.c:296
doca_error_t set_flow_pipe_cfg(struct doca_flow_pipe_cfg *cfg, const char *name, enum doca_flow_pipe_type type, bool is_root)
Definition: flow_common.c:305
#define NB_ACTIONS_ARR
Definition: flow_common.h:58
#define SHARED_RESOURCE_NUM_VALUES
Definition: flow_common.h:59
#define ACTIONS_MEM_SIZE(nr_queues, entries)
Definition: flow_common.h:66
#define ARRAY_INIT(array, val)
Definition: flow_common.h:71
doca flow actions information
Definition: doca_flow.h:684
enum doca_flow_resource_type decap_type
Definition: doca_flow.h:689
struct doca_flow_resource_decap_cfg decap_cfg
Definition: doca_flow.h:692
uint8_t action_idx
Definition: doca_flow.h:685
forwarding configuration
Definition: doca_flow.h:779
struct doca_flow_pipe * next_pipe
Definition: doca_flow.h:800
uint16_t port_id
Definition: doca_flow.h:795
enum doca_flow_fwd_type type
Definition: doca_flow.h:780
uint8_t dst_mac[DOCA_FLOW_ETHER_ADDR_LEN]
uint8_t src_mac[DOCA_FLOW_ETHER_ADDR_LEN]
struct doca_flow_header_ip4 ip4
Definition: doca_flow.h:449
enum doca_flow_l4_type_ext l4_type_ext
Definition: doca_flow.h:454
struct doca_flow_header_eth eth
Definition: doca_flow.h:440
struct doca_flow_header_udp udp
Definition: doca_flow.h:459
enum doca_flow_l3_type l3_type
Definition: doca_flow.h:446
struct doca_flow_header_l4_port l4_port
doca flow matcher information
Definition: doca_flow.h:491
struct doca_flow_header_format inner
Definition: doca_flow.h:502
struct doca_flow_parser_meta parser_meta
Definition: doca_flow.h:496
struct doca_flow_header_format outer
Definition: doca_flow.h:498
struct doca_flow_tun tun
Definition: doca_flow.h:500
doca monitor action configuration
Definition: doca_flow.h:968
struct doca_flow_monitor::@103::@107 shared_counter
enum doca_flow_resource_type counter_type
Definition: doca_flow.h:988
uint32_t shared_counter_id
Definition: doca_flow.h:992
enum doca_flow_l3_meta outer_l3_type
Definition: doca_flow.h:382
enum doca_flow_l4_meta outer_l4_type
Definition: doca_flow.h:383
struct doca_flow_header_eth eth
Definition: doca_flow.h:673
flow resource query
Definition: doca_flow.h:1101
struct doca_flow_resource_query::@115::@117 counter
doca flow shared resource configuration
Definition: doca_flow.h:953
enum doca_flow_tun_type type
doca_be32_t nvgre_vs_id
doca_be32_t vxlan_tun_id
enum doca_flow_tun_ext_gre_type gre_type
uint8_t nvgre_flow_id
enum doca_flow_tun_ext_vxlan_type vxlan_type
doca_be16_t protocol
struct doca_flow_header_mpls mpls[DOCA_FLOW_MPLS_LABELS_MAX]
uint8_t vxlan_gpe_next_protocol
doca_be32_t gre_key
uint8_t vxlan_gpe_flags
user context struct that will be used in entries process callback
Definition: flow_common.h:78
static int nb_ports
Definition: switch_core.c:44
static uint32_t actions_mem_size[FLOW_SWITCH_PORTS_MAX]
Definition: switch_core.c:43
static struct doca_flow_port * ports[FLOW_SWITCH_PORTS_MAX]
Definition: switch_core.c:42