NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_vxlan_encap_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 <doca_log.h>
30 #include <doca_flow.h>
31 #include <doca_bitfield.h>
32 
33 #include "flow_common.h"
34 
35 DOCA_LOG_REGISTER(FLOW_VXLAN_ENCAP);
36 
37 /*
38  * Create DOCA Flow pipe with match on header types to filter out non IPV4 packets.
39  *
40  * @port [in]: port of the pipe
41  * @port_id [in]: port ID of the pipe
42  * @pipe [out]: created pipe pointer
43  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
44  */
45 static doca_error_t create_classifier_pipe(struct doca_flow_port *port,
46  struct doca_flow_pipe *match_pipe,
47  struct doca_flow_pipe **pipe)
48 {
49  struct doca_flow_match match;
50  struct doca_flow_fwd fwd;
51  struct doca_flow_pipe_cfg *pipe_cfg;
53 
54  memset(&match, 0, sizeof(match));
55  memset(&fwd, 0, sizeof(fwd));
56 
58 
59  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
60  if (result != DOCA_SUCCESS) {
61  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
62  return result;
63  }
64 
65  result = set_flow_pipe_cfg(pipe_cfg, "CLASSIFIER_PIPE", DOCA_FLOW_PIPE_BASIC, true);
66  if (result != DOCA_SUCCESS) {
67  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
68  goto destroy_pipe_cfg;
69  }
70  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
71  if (result != DOCA_SUCCESS) {
72  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
73  goto destroy_pipe_cfg;
74  }
75 
77  fwd.next_pipe = match_pipe;
78 
79  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
82  return result;
83 }
84 
85 /*
86  * Create DOCA Flow pipe with 5 tuple match and set pkt meta value
87  *
88  * @port [in]: port of the pipe
89  * @port_id [in]: port ID of the pipe
90  * @pipe [out]: created pipe pointer
91  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
92  */
93 static doca_error_t create_match_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
94 {
95  struct doca_flow_match match;
96  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
97  struct doca_flow_fwd fwd;
98  struct doca_flow_pipe_cfg *pipe_cfg;
100 
101  memset(&match, 0, sizeof(match));
102  memset(&actions, 0, sizeof(actions));
103  memset(&fwd, 0, sizeof(fwd));
104 
105  /* 5 tuple match */
108  match.outer.ip4.src_ip = 0xffffffff;
109  match.outer.ip4.dst_ip = 0xffffffff;
111  match.outer.transport.src_port = 0xffff;
112  match.outer.transport.dst_port = 0xffff;
113 
114  /* set meta data to match on the egress domain */
115  actions.meta.pkt_meta = UINT32_MAX;
117  actions.outer.transport.src_port = 0xffff;
118  actions_arr[0] = &actions;
119 
120  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
121  if (result != DOCA_SUCCESS) {
122  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
123  return result;
124  }
125 
126  result = set_flow_pipe_cfg(pipe_cfg, "MATCH_PIPE", DOCA_FLOW_PIPE_BASIC, false);
127  if (result != DOCA_SUCCESS) {
128  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
129  goto destroy_pipe_cfg;
130  }
131  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
132  if (result != DOCA_SUCCESS) {
133  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
134  goto destroy_pipe_cfg;
135  }
136  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
137  if (result != DOCA_SUCCESS) {
138  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
139  goto destroy_pipe_cfg;
140  }
141 
142  /* forwarding traffic to other port */
144  fwd.port_id = port_id ^ 1;
145 
146  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
148  doca_flow_pipe_cfg_destroy(pipe_cfg);
149  return result;
150 }
151 
152 /*
153  * Create DOCA Flow pipe on EGRESS domain with match on the packet meta and encap action with changeable values
154  *
155  * @port [in]: port of the pipe
156  * @port_id [in]: pipe port ID
157  * @vxlan_type [in]: vxlan type
158  * @pipe [out]: created pipe pointer
159  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
160  */
161 static doca_error_t create_vxlan_encap_pipe(struct doca_flow_port *port,
162  int port_id,
163  enum doca_flow_tun_ext_vxlan_type vxlan_type,
164  struct doca_flow_pipe **pipe)
165 {
166  struct doca_flow_match match;
168  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
169  struct doca_flow_fwd fwd;
170  struct doca_flow_pipe_cfg *pipe_cfg;
172 
173  memset(&match, 0, sizeof(match));
174  memset(&match_mask, 0, sizeof(match_mask));
175  memset(&actions, 0, sizeof(actions));
176  memset(&fwd, 0, sizeof(fwd));
177 
178  /* match on pkt meta */
179  match_mask.meta.pkt_meta = UINT32_MAX;
180 
181  /* build basic outer VXLAN encap data*/
183  actions.encap_cfg.is_l2 = true;
184  SET_MAC_ADDR(actions.encap_cfg.encap.outer.eth.src_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
185  SET_MAC_ADDR(actions.encap_cfg.encap.outer.eth.dst_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
187  actions.encap_cfg.encap.outer.ip4.src_ip = 0xffffffff;
188  actions.encap_cfg.encap.outer.ip4.dst_ip = 0xffffffff;
194  actions.encap_cfg.encap.tun.vxlan_tun_id = 0xffffffff;
195  actions_arr[0] = &actions;
196 
197  switch (vxlan_type) {
201  break;
206  break;
208  break;
209  default:
210  DOCA_LOG_ERR("Failed to create vxlan encap pipe: invalid vxlan type %d", vxlan_type);
212  }
213 
214  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
215  if (result != DOCA_SUCCESS) {
216  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
217  return result;
218  }
219 
220  result = set_flow_pipe_cfg(pipe_cfg, "VXLAN_ENCAP_PIPE", DOCA_FLOW_PIPE_BASIC, true);
221  if (result != DOCA_SUCCESS) {
222  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
223  goto destroy_pipe_cfg;
224  }
226  if (result != DOCA_SUCCESS) {
227  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg domain: %s", doca_error_get_descr(result));
228  goto destroy_pipe_cfg;
229  }
230  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, &match_mask);
231  if (result != DOCA_SUCCESS) {
232  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
233  goto destroy_pipe_cfg;
234  }
235  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
236  if (result != DOCA_SUCCESS) {
237  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
238  goto destroy_pipe_cfg;
239  }
240 
241  /* forwarding traffic to the wire */
243  fwd.port_id = port_id;
244 
245  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
247  doca_flow_pipe_cfg_destroy(pipe_cfg);
248  return result;
249 }
250 
251 /*
252  * Add DOCA Flow pipe entry to classifier pipe with all specific values.
253  *
254  * @pipe [in]: pipe of the entry
255  * @status [in]: user context for adding entry
256  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
257  */
258 static doca_error_t add_classifier_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
259 {
260  struct doca_flow_match match;
261  struct doca_flow_pipe_entry *entry;
262 
263  memset(&match, 0, sizeof(match));
264 
265  return doca_flow_pipe_add_entry(0, pipe, &match, NULL, NULL, NULL, 0, status, &entry);
266 }
267 
268 /*
269  * Add DOCA Flow pipe entry with example 5 tuple match
270  *
271  * @pipe [in]: pipe of the entry
272  * @status [in]: user context for adding entry
273  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
274  */
275 static doca_error_t add_match_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
276 {
277  struct doca_flow_match match;
278  struct doca_flow_actions actions;
279  struct doca_flow_pipe_entry *entry;
281 
282  doca_be32_t dst_ip_addr = BE_IPV4_ADDR(8, 8, 8, 8);
283  doca_be32_t src_ip_addr = BE_IPV4_ADDR(1, 2, 3, 4);
284  doca_be16_t dst_port = rte_cpu_to_be_16(80);
285  doca_be16_t src_port = rte_cpu_to_be_16(1234);
286 
287  memset(&match, 0, sizeof(match));
288  memset(&actions, 0, sizeof(actions));
289 
290  match.outer.ip4.dst_ip = dst_ip_addr;
291  match.outer.ip4.src_ip = src_ip_addr;
294 
296  actions.outer.transport.src_port = rte_cpu_to_be_16(1235);
297  actions.action_idx = 0;
298 
299  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
300  if (result != DOCA_SUCCESS)
301  return result;
302 
303  return DOCA_SUCCESS;
304 }
305 
306 /*
307  * Add DOCA Flow pipe entry with example encap values
308  *
309  * @pipe [in]: pipe of the entry
310  * @vxlan_type [in]: vxlan type
311  * @status [in]: user context for adding entry
312  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
313  */
314 static doca_error_t add_vxlan_encap_pipe_entry(struct doca_flow_pipe *pipe,
315  enum doca_flow_tun_ext_vxlan_type vxlan_type,
316  struct entries_status *status)
317 {
318  struct doca_flow_match match;
319  struct doca_flow_actions actions;
320  struct doca_flow_pipe_entry *entry;
322 
323  doca_be32_t encap_dst_ip_addr = BE_IPV4_ADDR(81, 81, 81, 81);
324  doca_be32_t encap_src_ip_addr = BE_IPV4_ADDR(11, 21, 31, 41);
325  doca_be16_t encap_flags_fragment_offset = RTE_BE16(DOCA_FLOW_IP4_FLAG_DONT_FRAGMENT);
326  uint8_t encap_ttl = 17;
327  doca_be32_t encap_vxlan_tun_id = DOCA_HTOBE32(0xadadad);
328  uint8_t src_mac[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
329  uint8_t dst_mac[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
330 
331  memset(&match, 0, sizeof(match));
332  memset(&actions, 0, sizeof(actions));
333 
334  match.meta.pkt_meta = DOCA_HTOBE32(1);
335 
337  src_mac[0],
338  src_mac[1],
339  src_mac[2],
340  src_mac[3],
341  src_mac[4],
342  src_mac[5]);
344  dst_mac[0],
345  dst_mac[1],
346  dst_mac[2],
347  dst_mac[3],
348  dst_mac[4],
349  dst_mac[5]);
351  actions.encap_cfg.encap.outer.ip4.src_ip = encap_src_ip_addr;
352  actions.encap_cfg.encap.outer.ip4.dst_ip = encap_dst_ip_addr;
353  actions.encap_cfg.encap.outer.ip4.flags_fragment_offset = encap_flags_fragment_offset;
354  actions.encap_cfg.encap.outer.ip4.ttl = encap_ttl;
356  actions.encap_cfg.encap.tun.vxlan_tun_id = encap_vxlan_tun_id;
357  actions.action_idx = 0;
358 
359  switch (vxlan_type) {
362  break;
365  break;
367  break;
368  default:
369  DOCA_LOG_ERR("Failed to add vxlan encap entry: invalid vxlan type %d", vxlan_type);
371  }
372 
373  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
374  if (result != DOCA_SUCCESS)
375  return result;
376 
377  return DOCA_SUCCESS;
378 }
379 
380 /*
381  * Run flow_vxlan_encap sample
382  *
383  * @nb_queues [in]: number of queues the sample will use
384  * @vxlan_type [in]: vxlan type
385  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
386  */
388 {
389  int nb_ports = 2;
390  struct flow_resources resource = {0};
391  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
392  struct doca_flow_port *ports[nb_ports];
393  struct doca_dev *dev_arr[nb_ports];
394  uint32_t actions_mem_size[nb_ports];
395  struct doca_flow_pipe *pipe;
396  struct doca_flow_pipe *classifier_pipe;
397  struct entries_status status_ingress;
398  int num_of_entries_ingress = 2;
399  struct entries_status status_egress;
400  int num_of_entries_egress = 1;
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);
411  ARRAY_INIT(actions_mem_size, ACTIONS_MEM_SIZE(nb_queues, num_of_entries_ingress + num_of_entries_egress));
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++) {
420  memset(&status_ingress, 0, sizeof(status_ingress));
421  memset(&status_egress, 0, sizeof(status_egress));
422 
423  result = create_match_pipe(ports[port_id], port_id, &pipe);
424  if (result != DOCA_SUCCESS) {
425  DOCA_LOG_ERR("Failed to create classifier pipe: %s", doca_error_get_descr(result));
428  return result;
429  }
430 
431  result = add_match_pipe_entry(pipe, &status_ingress);
432  if (result != DOCA_SUCCESS) {
433  DOCA_LOG_ERR("Failed to add entry to classifier pipe: %s", doca_error_get_descr(result));
436  return result;
437  }
438 
439  result = create_classifier_pipe(ports[port_id], pipe, &classifier_pipe);
440  if (result != DOCA_SUCCESS) {
441  DOCA_LOG_ERR("Failed to create match pipe: %s", doca_error_get_descr(result));
444  return result;
445  }
446 
447  result = add_classifier_pipe_entry(classifier_pipe, &status_ingress);
448  if (result != DOCA_SUCCESS) {
449  DOCA_LOG_ERR("Failed to add entry to match pipe: %s", doca_error_get_descr(result));
452  return result;
453  }
454 
455  result = create_vxlan_encap_pipe(ports[port_id ^ 1], port_id ^ 1, vxlan_type, &pipe);
456  if (result != DOCA_SUCCESS) {
457  DOCA_LOG_ERR("Failed to create vxlan encap pipe: %s", doca_error_get_descr(result));
460  return result;
461  }
462 
463  result = add_vxlan_encap_pipe_entry(pipe, vxlan_type, &status_egress);
464  if (result != DOCA_SUCCESS) {
465  DOCA_LOG_ERR("Failed to add entry to vxlan encap pipe: %s", doca_error_get_descr(result));
468  return result;
469  }
470 
471  result = doca_flow_entries_process(ports[port_id], 0, DEFAULT_TIMEOUT_US, num_of_entries_ingress);
472  if (result != DOCA_SUCCESS) {
473  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
476  return result;
477  }
478 
479  if (status_ingress.nb_processed != num_of_entries_ingress || status_ingress.failure) {
480  DOCA_LOG_ERR("Failed to process entries");
483  return DOCA_ERROR_BAD_STATE;
484  }
485 
486  result = doca_flow_entries_process(ports[port_id ^ 1], 0, DEFAULT_TIMEOUT_US, num_of_entries_egress);
487  if (result != DOCA_SUCCESS) {
488  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
491  return result;
492  }
493 
494  if (status_egress.nb_processed != num_of_entries_egress || status_egress.failure) {
495  DOCA_LOG_ERR("Failed to process entries");
498  return DOCA_ERROR_BAD_STATE;
499  }
500  }
501 
502  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
503  sleep(10);
504 
507  return result;
508 }
#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)
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_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
DOCA_LOG_REGISTER(FLOW_VXLAN_ENCAP)
static doca_error_t create_classifier_pipe(struct doca_flow_port *port, struct doca_flow_pipe *match_pipe, struct doca_flow_pipe **pipe)
doca_error_t flow_vxlan_encap(int nb_queues, enum doca_flow_tun_ext_vxlan_type vxlan_type)
static doca_error_t add_vxlan_encap_pipe_entry(struct doca_flow_pipe *pipe, enum doca_flow_tun_ext_vxlan_type vxlan_type, struct entries_status *status)
static doca_error_t add_match_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t create_vxlan_encap_pipe(struct doca_flow_port *port, int port_id, enum doca_flow_tun_ext_vxlan_type vxlan_type, struct doca_flow_pipe **pipe)
static doca_error_t add_classifier_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t create_match_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
#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_INVALID_VALUE
Definition: doca_error.h:44
@ 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_tun_ext_vxlan_type
doca flow tunnel extension vxlan type
#define DOCA_FLOW_VXLAN_GPE_TYPE_ETH
@ DOCA_FLOW_L4_TYPE_EXT_UDP
@ DOCA_FLOW_L4_TYPE_EXT_TRANSPORT
@ DOCA_FLOW_L3_TYPE_IP4
@ DOCA_FLOW_IP4_FLAG_DONT_FRAGMENT
@ DOCA_FLOW_TUN_EXT_VXLAN_STANDARD
@ DOCA_FLOW_TUN_EXT_VXLAN_GBP
@ 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_STABLE doca_error_t doca_flow_pipe_cfg_set_domain(struct doca_flow_pipe_cfg *cfg, enum doca_flow_pipe_domain domain)
Set pipe's domain.
@ DOCA_FLOW_PIPE_BASIC
Definition: doca_flow.h:221
@ DOCA_FLOW_L3_META_IPV4
Definition: doca_flow.h:296
@ 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_PIPE_DOMAIN_EGRESS
Definition: doca_flow.h:245
#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
uint16_t doca_be16_t
Declare DOCA endianity types.
Definition: doca_types.h:120
uint16_t src_port
Definition: packets.h:0
uint16_t dst_port
Definition: packets.h:1
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
struct doca_flow_resource_encap_cfg encap_cfg
Definition: doca_flow.h:710
struct doca_flow_header_format outer
Definition: doca_flow.h:703
enum doca_flow_resource_type encap_type
Definition: doca_flow.h:707
struct doca_flow_meta meta
Definition: doca_flow.h:699
uint8_t action_idx
Definition: doca_flow.h:685
struct doca_flow_tun tun
Definition: doca_flow.h:569
struct doca_flow_header_format outer
Definition: doca_flow.h:567
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_l4_port transport
Definition: doca_flow.h:463
struct doca_flow_header_udp udp
Definition: doca_flow.h:459
enum doca_flow_l3_type l3_type
Definition: doca_flow.h:446
doca_be16_t flags_fragment_offset
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_meta meta
Definition: doca_flow.h:494
doca_be32_t pkt_meta
Definition: doca_flow.h:359
enum doca_flow_l3_meta outer_l3_type
Definition: doca_flow.h:382
struct doca_flow_encap_action encap
Definition: doca_flow.h:663
enum doca_flow_tun_type type
doca_be16_t vxlan_gbp_group_policy_id
doca_be32_t vxlan_tun_id
enum doca_flow_tun_ext_vxlan_type vxlan_type
uint8_t vxlan_gpe_next_protocol
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