NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_modify_header_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_log.h>
32 #include <doca_flow.h>
33 #include <doca_bitfield.h>
34 
35 #include "flow_common.h"
36 
37 #define NB_ACTION_DESC (1)
38 #define NB_VXLAN_ENTRIES (1)
39 #define NB_GPE_ENTRIES (1)
40 #define NB_MODIFY_HDR_ENTRIES (1)
41 #define TOTAL_ENTRIES (NB_VXLAN_ENTRIES + NB_GPE_ENTRIES + NB_MODIFY_HDR_ENTRIES)
42 
43 DOCA_LOG_REGISTER(FLOW_MODIFY_HEADER);
44 
45 /*
46  * Create DOCA Flow pipe that match VXLAN traffic with changeable VXLAN tunnel ID and modify action
47  *
48  * @port [in]: port of the pipe
49  * @port_id [in]: port ID of the pipe
50  * @pipe [out]: created pipe pointer
51  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
52  */
53 static doca_error_t create_vxlan_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
54 {
55  struct doca_flow_match match;
56  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
57  struct doca_flow_fwd fwd;
58  struct doca_flow_pipe_cfg *pipe_cfg;
60 
61  memset(&match, 0, sizeof(match));
62  memset(&actions, 0, sizeof(actions));
63  memset(&fwd, 0, sizeof(fwd));
64 
68  match.outer.udp.l4_port.dst_port = UINT16_MAX;
71  match.tun.vxlan_tun_id = UINT32_MAX;
72 
73  actions_arr[0] = &actions;
77 
78  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
79  if (result != DOCA_SUCCESS) {
80  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
81  return result;
82  }
83 
84  result = set_flow_pipe_cfg(pipe_cfg, "VXLAN_PIPE", DOCA_FLOW_PIPE_BASIC, false);
85  if (result != DOCA_SUCCESS) {
86  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
87  goto destroy_pipe_cfg;
88  }
89  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
90  if (result != DOCA_SUCCESS) {
91  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
92  goto destroy_pipe_cfg;
93  }
94  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
95  if (result != DOCA_SUCCESS) {
96  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
97  goto destroy_pipe_cfg;
98  }
99 
101  fwd.port_id = port_id ^ 1;
102 
103  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
105  doca_flow_pipe_cfg_destroy(pipe_cfg);
106  return result;
107 }
108 
109 /*
110  * Add DOCA Flow pipe entry with example VXLAN tunnel ID to match and modify the rsvd1 field.
111  *
112  * @pipe [in]: pipe of the entry
113  * @status [in]: user context for adding entry
114  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
115  */
116 static doca_error_t add_vxlan_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
117 {
118  struct doca_flow_match match;
119  struct doca_flow_actions actions;
120  struct doca_flow_pipe_entry *entry;
122 
123  memset(&match, 0, sizeof(match));
124  memset(&actions, 0, sizeof(actions));
125 
130  match.tun.type = DOCA_FLOW_TUN_VXLAN;
132  match.tun.vxlan_tun_id = DOCA_HTOBE32(100);
133 
134  actions.action_idx = 0;
135  actions.tun.vxlan_tun_rsvd1 = 0x12;
136 
138  pipe,
139  &match,
140  &actions,
141  NULL,
142  NULL,
144  status,
145  &entry);
146  if (result != DOCA_SUCCESS)
147  return result;
148 
149  return DOCA_SUCCESS;
150 }
151 
152 /*
153  * Create DOCA Flow pipe that match VXLAN-GPE traffic with changeable VXLAN tunnel ID and modify action
154  *
155  * @port [in]: port of the pipe
156  * @port_id [in]: port ID of the pipe
157  * @miss_pipe [in]: next pipe pointer
158  * @pipe [out]: created pipe pointer
159  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
160  */
161 static doca_error_t create_vxlan_gpe_pipe(struct doca_flow_port *port,
162  int port_id,
163  struct doca_flow_pipe *miss_pipe,
164  struct doca_flow_pipe **pipe)
165 {
166  struct doca_flow_match match;
167  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
168  struct doca_flow_fwd fwd, fwd_miss;
169  struct doca_flow_pipe_cfg *pipe_cfg;
171 
172  memset(&match, 0, sizeof(match));
173  memset(&actions, 0, sizeof(actions));
174  memset(&fwd, 0, sizeof(fwd));
175  memset(&fwd_miss, 0, sizeof(fwd_miss));
176 
180  match.outer.udp.l4_port.dst_port = UINT16_MAX;
181  match.tun.type = DOCA_FLOW_TUN_VXLAN;
183  match.tun.vxlan_tun_id = UINT32_MAX;
184 
185  actions_arr[0] = &actions;
186  actions.tun.vxlan_tun_rsvd1 = 0xFF;
189 
190  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
191  if (result != DOCA_SUCCESS) {
192  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
193  return result;
194  }
195 
196  result = set_flow_pipe_cfg(pipe_cfg, "VXLAN_GPE_PIPE", DOCA_FLOW_PIPE_BASIC, false);
197  if (result != DOCA_SUCCESS) {
198  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
199  goto destroy_pipe_cfg;
200  }
201  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
202  if (result != DOCA_SUCCESS) {
203  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
204  goto destroy_pipe_cfg;
205  }
206  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
207  if (result != DOCA_SUCCESS) {
208  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
209  goto destroy_pipe_cfg;
210  }
211 
213  fwd.port_id = port_id ^ 1;
215  fwd_miss.next_pipe = miss_pipe;
216 
217  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
219  doca_flow_pipe_cfg_destroy(pipe_cfg);
220  return result;
221 }
222 
223 /*
224  * Add DOCA Flow pipe entry with example VXLAN-GPE tunnel ID to match and modify
225  *
226  * @pipe [in]: pipe of the entry
227  * @status [in]: user context for adding entry
228  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
229  */
230 static doca_error_t add_vxlan_gpe_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
231 {
232  struct doca_flow_match match;
233  struct doca_flow_actions actions;
234  struct doca_flow_pipe_entry *entry;
236 
237  memset(&match, 0, sizeof(match));
238  memset(&actions, 0, sizeof(actions));
239 
244  match.tun.type = DOCA_FLOW_TUN_VXLAN;
246  match.tun.vxlan_tun_id = DOCA_HTOBE32(100);
247 
248  actions.action_idx = 0;
249  actions.tun.vxlan_tun_rsvd1 = 0x34;
251 
253  pipe,
254  &match,
255  &actions,
256  NULL,
257  NULL,
259  status,
260  &entry);
261  if (result != DOCA_SUCCESS)
262  return result;
263 
264  return DOCA_SUCCESS;
265 }
266 
267 /*
268  * Create DOCA Flow pipe that match changeable destination IP, modify the destination mac address and decrease TTL value
269  * by one
270  *
271  * @port [in]: port of the pipe
272  * @port_id [in]: port ID of the pipe
273  * @miss_pipe [in]: next pipe pointer
274  * @pipe [out]: created pipe pointer
275  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
276  */
277 static doca_error_t create_modify_header_pipe(struct doca_flow_port *port,
278  int port_id,
279  struct doca_flow_pipe *miss_pipe,
280  struct doca_flow_pipe **pipe)
281 {
282  struct doca_flow_match match;
283  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
284  struct doca_flow_action_descs descs;
285  struct doca_flow_action_descs *descs_arr[NB_ACTIONS_ARR];
286  struct doca_flow_action_desc desc_array[NB_ACTION_DESC] = {0};
287  struct doca_flow_fwd fwd, fwd_miss;
288  struct doca_flow_pipe_cfg *pipe_cfg;
290 
291  memset(&match, 0, sizeof(match));
292  memset(&actions, 0, sizeof(actions));
293  memset(&fwd, 0, sizeof(fwd));
294  memset(&fwd_miss, 0, sizeof(fwd_miss));
295  memset(&descs, 0, sizeof(descs));
296 
299  match.outer.ip4.dst_ip = 0xffffffff;
300 
302  fwd.port_id = port_id ^ 1;
304  fwd_miss.next_pipe = miss_pipe;
305 
306  actions_arr[0] = &actions;
307  descs_arr[0] = &descs;
309  descs.desc_array = desc_array;
310 
311  /* modify vlan */
313  actions.outer.eth_vlan[0].tci = htobe16(0xabc);
314 
315  desc_array[0].type = DOCA_FLOW_ACTION_ADD;
316  desc_array[0].field_op.dst.field_string = "outer.ipv4.ttl";
317  desc_array[0].field_op.dst.bit_offset = 0;
318  desc_array[0].field_op.width = 8;
319  /* set ttl=-1 in doca_flow_actions for decrease TTL value by one */
321  actions.outer.ip4.ttl = UINT8_MAX;
322  /* set changeable modify source mac address */
323  SET_MAC_ADDR(actions.outer.eth.src_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
324 
325  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
326  if (result != DOCA_SUCCESS) {
327  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
328  return result;
329  }
330 
331  result = set_flow_pipe_cfg(pipe_cfg, "MODIFY_HEADER_PIPE", DOCA_FLOW_PIPE_BASIC, true);
332  if (result != DOCA_SUCCESS) {
333  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
334  goto destroy_pipe_cfg;
335  }
336  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
337  if (result != DOCA_SUCCESS) {
338  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
339  goto destroy_pipe_cfg;
340  }
341  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, descs_arr, NB_ACTIONS_ARR);
342  if (result != DOCA_SUCCESS) {
343  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
344  goto destroy_pipe_cfg;
345  }
346 
347  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
349  doca_flow_pipe_cfg_destroy(pipe_cfg);
350  return result;
351 }
352 
353 /*
354  * Add DOCA Flow pipe entry to the pipe with example values.
355  *
356  * @pipe [in]: pipe of the entry
357  * @status [in]: user context for adding entry
358  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
359  */
360 static doca_error_t add_modify_header_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
361 {
362  struct doca_flow_match match;
363  struct doca_flow_actions actions;
364  struct doca_flow_pipe_entry *entry;
366  doca_be32_t dst_ip_addr = BE_IPV4_ADDR(8, 8, 8, 8);
367 
368  memset(&match, 0, sizeof(match));
369  memset(&actions, 0, sizeof(actions));
370 
371  match.outer.ip4.dst_ip = dst_ip_addr;
372  actions.action_idx = 0;
373 
374  /* modify source mac address */
375  SET_MAC_ADDR(actions.outer.eth.src_mac, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff);
376 
377  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
378  if (result != DOCA_SUCCESS)
379  return result;
380 
381  return DOCA_SUCCESS;
382 }
383 
384 /*
385  * Run flow_modify_header sample
386  *
387  * @nb_queues [in]: number of queues the sample will use
388  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
389  */
391 {
392  int nb_ports = 2;
393  struct flow_resources resource = {0};
394  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
395  struct doca_flow_port *ports[nb_ports];
396  struct doca_dev *dev_arr[nb_ports];
397  uint32_t actions_mem_size[nb_ports];
398  struct doca_flow_pipe *pipe, *vxlan_pipe, *vxlan_gpe_pipe;
399  struct entries_status status;
400  int num_of_entries = 0;
402  int port_id;
403 
404  result = init_doca_flow(nb_queues, "vnf,hws", &resource, nr_shared_resources);
405  if (result != DOCA_SUCCESS) {
406  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
407  return result;
408  }
409 
410  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
413  if (result != DOCA_SUCCESS) {
414  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
416  return result;
417  }
418 
419  for (port_id = 0; port_id < nb_ports; port_id++, num_of_entries = 0) {
420  memset(&status, 0, sizeof(status));
421 
422  result = create_vxlan_pipe(ports[port_id], port_id, &vxlan_pipe);
423  if (result != DOCA_SUCCESS) {
424  DOCA_LOG_ERR("Failed to add vxlan pipe: %s", doca_error_get_descr(result));
427  return result;
428  }
429 
430  result = add_vxlan_pipe_entry(vxlan_pipe, &status);
431  if (result != DOCA_SUCCESS) {
432  DOCA_LOG_ERR("Failed to add vxlan pipe entry: %s", doca_error_get_descr(result));
435  return result;
436  }
437  num_of_entries++;
438 
439  result = create_vxlan_gpe_pipe(ports[port_id], port_id, vxlan_pipe, &vxlan_gpe_pipe);
440  if (result != DOCA_SUCCESS) {
441  DOCA_LOG_ERR("Failed to add vxlan gpe pipe: %s", doca_error_get_descr(result));
444  return result;
445  }
446 
447  result = add_vxlan_gpe_pipe_entry(vxlan_gpe_pipe, &status);
448  if (result != DOCA_SUCCESS) {
449  DOCA_LOG_ERR("Failed to add vxlan gpe pipe entry: %s", doca_error_get_descr(result));
452  return result;
453  }
454  num_of_entries++;
455 
456  result = create_modify_header_pipe(ports[port_id], port_id, vxlan_gpe_pipe, &pipe);
457  if (result != DOCA_SUCCESS) {
458  DOCA_LOG_ERR("Failed to create pipe: %s", doca_error_get_descr(result));
461  return result;
462  }
463 
464  result = add_modify_header_pipe_entry(pipe, &status);
465  if (result != DOCA_SUCCESS) {
466  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
469  return result;
470  }
471  num_of_entries++;
472 
473  result = doca_flow_entries_process(ports[port_id], 0, DEFAULT_TIMEOUT_US, num_of_entries);
474  if (result != DOCA_SUCCESS) {
475  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
478  return result;
479  }
480 
481  if (status.nb_processed != num_of_entries || status.failure) {
482  DOCA_LOG_ERR("Failed to process entries");
485  return DOCA_ERROR_BAD_STATE;
486  }
487  }
488 
489  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
490  sleep(5);
491 
494  return result;
495 }
#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 destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
doca_error_t flow_modify_header(int nb_queues)
static doca_error_t add_vxlan_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t add_vxlan_gpe_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t create_vxlan_gpe_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe *miss_pipe, struct doca_flow_pipe **pipe)
#define TOTAL_ENTRIES
static doca_error_t create_vxlan_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
static doca_error_t add_modify_header_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
#define NB_ACTION_DESC
static doca_error_t create_modify_header_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe *miss_pipe, struct doca_flow_pipe **pipe)
DOCA_LOG_REGISTER(FLOW_MODIFY_HEADER)
static struct doca_flow_fwd fwd_miss
Definition: flow_parser.c:110
static struct doca_flow_actions actions
Definition: flow_parser.c:107
#define BE_IPV4_ADDR(a, b, c, d)
Definition: flow_parser.c:64
static struct doca_flow_fwd fwd
Definition: flow_parser.c:109
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_VXLAN_GPE_DEFAULT_PORT
Definition: doca_flow_net.h:50
#define DOCA_FLOW_VXLAN_DEFAULT_PORT
Definition: doca_flow_net.h:49
@ 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_VXLAN
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_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_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_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_FLOW_L2_VALID_HEADER_VLAN_0
Definition: doca_flow.h:430
@ DOCA_FLOW_PIPE_BASIC
Definition: doca_flow.h:221
@ DOCA_FLOW_L3_META_IPV4
Definition: doca_flow.h:296
@ DOCA_FLOW_WAIT_FOR_BATCH
Definition: doca_flow.h:117
@ DOCA_FLOW_ACTION_ADD
Definition: doca_flow.h:1010
@ 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
#define htobe16
Definition: os_utils.hpp:39
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
action description
Definition: doca_flow.h:1019
enum doca_flow_action_type type
Definition: doca_flow.h:1020
struct doca_flow_action_desc::@108::@110 field_op
action descriptor array
Definition: doca_flow.h:1033
struct doca_flow_action_desc * desc_array
Definition: doca_flow.h:1036
doca flow actions information
Definition: doca_flow.h:684
struct doca_flow_tun tun
Definition: doca_flow.h:705
struct doca_flow_header_format outer
Definition: doca_flow.h:703
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 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_eth_vlan eth_vlan[DOCA_FLOW_VLAN_MAX]
Definition: doca_flow.h:444
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_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
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
enum doca_flow_tun_type type
doca_be32_t vxlan_tun_id
uint8_t vxlan_tun_rsvd1
enum doca_flow_tun_ext_vxlan_type vxlan_type
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