NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_geneve_encap_sample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 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_GENEVE_ENCAP);
36 
37 /*
38  * Create DOCA Flow pipe with 5 tuple match and set pkt meta value
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_match_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
46 {
47  struct doca_flow_match match;
48  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
49  struct doca_flow_fwd fwd;
50  struct doca_flow_pipe_cfg *pipe_cfg;
52 
53  memset(&match, 0, sizeof(match));
54  memset(&actions, 0, sizeof(actions));
55  memset(&fwd, 0, sizeof(fwd));
56 
57  /* 5 tuple match */
62  match.outer.ip4.src_ip = 0xffffffff;
63  match.outer.ip4.dst_ip = 0xffffffff;
64  match.outer.tcp.l4_port.src_port = 0xffff;
65  match.outer.tcp.l4_port.dst_port = 0xffff;
66 
67  /* set meta data to match on the egress domain */
68  actions.meta.pkt_meta = UINT32_MAX;
69  actions_arr[0] = &actions;
70 
71  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
72  if (result != DOCA_SUCCESS) {
73  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
74  return result;
75  }
76 
77  result = set_flow_pipe_cfg(pipe_cfg, "MATCH_PIPE", DOCA_FLOW_PIPE_BASIC, true);
78  if (result != DOCA_SUCCESS) {
79  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
80  goto destroy_pipe_cfg;
81  }
82  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
83  if (result != DOCA_SUCCESS) {
84  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
85  goto destroy_pipe_cfg;
86  }
87  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
88  if (result != DOCA_SUCCESS) {
89  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
90  goto destroy_pipe_cfg;
91  }
92 
93  /* forwarding traffic to other port */
95  fwd.port_id = port_id ^ 1;
96 
97  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
100  return result;
101 }
102 
103 /*
104  * Create DOCA Flow pipe on EGRESS domain with match on the packet meta and encap action with changeable values
105  *
106  * @port [in]: port of the pipe
107  * @port_id [in]: pipe port ID
108  * @pipe [out]: created pipe pointer
109  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
110  */
111 static doca_error_t create_geneve_encap_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
112 {
113  struct doca_flow_match match;
115  struct doca_flow_actions actions1, actions2, actions3, actions4, *actions_arr[4];
116  struct doca_flow_fwd fwd;
117  struct doca_flow_pipe_cfg *pipe_cfg;
118  int i;
120 
121  memset(&match, 0, sizeof(match));
122  memset(&match_mask, 0, sizeof(match_mask));
123  memset(&actions1, 0, sizeof(actions1));
124  memset(&actions2, 0, sizeof(actions2));
125  memset(&actions3, 0, sizeof(actions3));
126  memset(&actions4, 0, sizeof(actions4));
127  memset(&fwd, 0, sizeof(fwd));
128 
129  /* match on pkt meta */
130  match_mask.meta.pkt_meta = UINT32_MAX;
131 
132  /* build basic outer GENEVE L3 encap data */
134  actions1.encap_cfg.is_l2 = false;
135  SET_MAC_ADDR(actions1.encap_cfg.encap.outer.eth.src_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
136  SET_MAC_ADDR(actions1.encap_cfg.encap.outer.eth.dst_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
138  actions1.encap_cfg.encap.outer.ip4.src_ip = 0xffffffff;
139  actions1.encap_cfg.encap.outer.ip4.dst_ip = 0xffffffff;
140  actions1.encap_cfg.encap.outer.ip4.ttl = 0xff;
144  actions1.encap_cfg.encap.tun.geneve.vni = 0xffffffff;
145  actions1.encap_cfg.encap.tun.geneve.next_proto = rte_cpu_to_be_16(DOCA_FLOW_ETHER_TYPE_IPV4);
146  actions_arr[0] = &actions1;
147 
148  /* build basic outer GENEVE + options L3 encap data */
150  actions2.encap_cfg.is_l2 = false;
151  SET_MAC_ADDR(actions2.encap_cfg.encap.outer.eth.src_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
152  SET_MAC_ADDR(actions2.encap_cfg.encap.outer.eth.dst_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
154  actions2.encap_cfg.encap.outer.ip4.src_ip = 0xffffffff;
155  actions2.encap_cfg.encap.outer.ip4.dst_ip = 0xffffffff;
156  actions2.encap_cfg.encap.outer.ip4.ttl = 0xff;
160  actions2.encap_cfg.encap.tun.geneve.vni = 0xffffffff;
161  actions2.encap_cfg.encap.tun.geneve.next_proto = rte_cpu_to_be_16(DOCA_FLOW_ETHER_TYPE_IPV4);
162  actions2.encap_cfg.encap.tun.geneve.ver_opt_len = 5;
163  for (i = 0; i < actions2.encap_cfg.encap.tun.geneve.ver_opt_len; i++)
164  actions2.encap_cfg.encap.tun.geneve_options[i].data = 0xffffffff;
165  actions_arr[1] = &actions2;
166 
167  /* build basic outer GENEVE L2 encap data */
169  actions3.encap_cfg.is_l2 = true;
170  SET_MAC_ADDR(actions3.encap_cfg.encap.outer.eth.src_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
171  SET_MAC_ADDR(actions3.encap_cfg.encap.outer.eth.dst_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
173  actions3.encap_cfg.encap.outer.ip4.src_ip = 0xffffffff;
174  actions3.encap_cfg.encap.outer.ip4.dst_ip = 0xffffffff;
175  actions3.encap_cfg.encap.outer.ip4.ttl = 0xff;
179  actions3.encap_cfg.encap.tun.geneve.vni = 0xffffffff;
180  actions3.encap_cfg.encap.tun.geneve.next_proto = rte_cpu_to_be_16(DOCA_FLOW_ETHER_TYPE_TEB);
181  actions_arr[2] = &actions3;
182 
183  /* build basic outer GENEVE + options L2 encap data */
185  actions4.encap_cfg.is_l2 = true;
186  SET_MAC_ADDR(actions4.encap_cfg.encap.outer.eth.src_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
187  SET_MAC_ADDR(actions4.encap_cfg.encap.outer.eth.dst_mac, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
189  actions4.encap_cfg.encap.outer.ip4.src_ip = 0xffffffff;
190  actions4.encap_cfg.encap.outer.ip4.dst_ip = 0xffffffff;
191  actions4.encap_cfg.encap.outer.ip4.ttl = 0xff;
193  actions4.encap_cfg.encap.tun.geneve.vni = 0xffffffff;
196  actions4.encap_cfg.encap.tun.geneve.next_proto = rte_cpu_to_be_16(DOCA_FLOW_ETHER_TYPE_TEB);
197  actions4.encap_cfg.encap.tun.geneve.ver_opt_len = 5;
198  for (i = 0; i < actions4.encap_cfg.encap.tun.geneve.ver_opt_len; i++)
199  actions4.encap_cfg.encap.tun.geneve_options[i].data = 0xffffffff;
200  actions_arr[3] = &actions4;
201 
202  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
203  if (result != DOCA_SUCCESS) {
204  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
205  return result;
206  }
207 
208  result = set_flow_pipe_cfg(pipe_cfg, "GENEVE_ENCAP_PIPE", DOCA_FLOW_PIPE_BASIC, true);
209  if (result != DOCA_SUCCESS) {
210  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
211  goto destroy_pipe_cfg;
212  }
214  if (result != DOCA_SUCCESS) {
215  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg domain: %s", doca_error_get_descr(result));
216  goto destroy_pipe_cfg;
217  }
218  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, &match_mask);
219  if (result != DOCA_SUCCESS) {
220  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
221  goto destroy_pipe_cfg;
222  }
223  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, 4);
224  if (result != DOCA_SUCCESS) {
225  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
226  goto destroy_pipe_cfg;
227  }
228 
229  /* forwarding traffic to the wire */
231  fwd.port_id = port_id;
232 
233  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
235  doca_flow_pipe_cfg_destroy(pipe_cfg);
236  return result;
237 }
238 
239 /*
240  * Add DOCA Flow pipe entry with example 5 tuple match
241  *
242  * @pipe [in]: pipe of the entry
243  * @status [in]: user context for adding entry
244  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
245  */
246 static doca_error_t add_match_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
247 {
248  struct doca_flow_match match;
249  struct doca_flow_actions actions;
250  struct doca_flow_pipe_entry *entry;
252 
253  memset(&match, 0, sizeof(match));
254  memset(&actions, 0, sizeof(actions));
255 
256  match.outer.ip4.dst_ip = BE_IPV4_ADDR(8, 8, 8, 8);
257  match.outer.ip4.src_ip = BE_IPV4_ADDR(1, 2, 3, 4);
258  match.outer.tcp.l4_port.dst_port = rte_cpu_to_be_16(80);
259  match.outer.tcp.l4_port.src_port = rte_cpu_to_be_16(1234);
260 
262  actions.action_idx = 0;
263 
264  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
265  if (result != DOCA_SUCCESS)
266  return result;
267 
268  match.outer.tcp.l4_port.src_port = rte_cpu_to_be_16(2345);
270 
271  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
272  if (result != DOCA_SUCCESS)
273  return result;
274 
275  match.outer.tcp.l4_port.src_port = rte_cpu_to_be_16(3456);
277 
278  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
279  if (result != DOCA_SUCCESS)
280  return result;
281 
282  match.outer.tcp.l4_port.src_port = rte_cpu_to_be_16(4567);
284 
285  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
286  if (result != DOCA_SUCCESS)
287  return result;
288 
289  return DOCA_SUCCESS;
290 }
291 
292 /*
293  * Add DOCA Flow pipe entry with example encap values
294  *
295  * @pipe [in]: pipe of the entry
296  * @status [in]: user context for adding entry
297  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
298  */
299 static doca_error_t add_geneve_encap_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
300 {
301  struct doca_flow_match match;
302  struct doca_flow_actions actions;
303  struct doca_flow_pipe_entry *entry;
305 
306  doca_be32_t encap_dst_ip_addr = BE_IPV4_ADDR(81, 81, 81, 81);
307  doca_be32_t encap_src_ip_addr = BE_IPV4_ADDR(11, 21, 31, 41);
308  uint8_t encap_ttl = 17;
309  uint8_t src_mac[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
310  uint8_t dst_mac[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
311 
312  memset(&match, 0, sizeof(match));
313  memset(&actions, 0, sizeof(actions));
314 
316  src_mac[0],
317  src_mac[1],
318  src_mac[2],
319  src_mac[3],
320  src_mac[4],
321  src_mac[5]);
323  dst_mac[0],
324  dst_mac[1],
325  dst_mac[2],
326  dst_mac[3],
327  dst_mac[4],
328  dst_mac[5]);
330  actions.encap_cfg.encap.outer.ip4.src_ip = encap_src_ip_addr;
331  actions.encap_cfg.encap.outer.ip4.dst_ip = encap_dst_ip_addr;
332  actions.encap_cfg.encap.outer.ip4.ttl = encap_ttl;
334 
335  /* L3 encap - GENEVE header only */
338  actions.action_idx = 0;
339  match.meta.pkt_meta = DOCA_HTOBE32(1);
340 
341  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
342  if (result != DOCA_SUCCESS)
343  return result;
344 
345  /* L3 encap - GENEVE header */
349  /* First option */
350  actions.encap_cfg.encap.tun.geneve_options[0].class_id = rte_cpu_to_be_16(0x0107);
353  actions.encap_cfg.encap.tun.geneve_options[1].data = rte_cpu_to_be_32(0x01234567);
354  actions.encap_cfg.encap.tun.geneve_options[2].data = rte_cpu_to_be_32(0x89abcdef);
355  /* Second option */
356  actions.encap_cfg.encap.tun.geneve_options[3].class_id = rte_cpu_to_be_16(0x0107);
359  actions.encap_cfg.encap.tun.geneve_options[4].data = rte_cpu_to_be_32(0xabbadeba);
360  actions.action_idx = 1;
361  match.meta.pkt_meta = DOCA_HTOBE32(2);
362 
363  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
364  if (result != DOCA_SUCCESS)
365  return result;
366 
367  /* L2 encap - GENEVE header only */
371  actions.action_idx = 2;
372  match.meta.pkt_meta = DOCA_HTOBE32(3);
373 
374  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
375  if (result != DOCA_SUCCESS)
376  return result;
377 
378  /* L2 encap - GENEVE header */
382  /* Option header */
383  actions.encap_cfg.encap.tun.geneve_options[0].class_id = rte_cpu_to_be_16(0x0107);
386  /* Option data */
387  actions.encap_cfg.encap.tun.geneve_options[1].data = rte_cpu_to_be_32(0x11223344);
388  actions.encap_cfg.encap.tun.geneve_options[2].data = rte_cpu_to_be_32(0x55667788);
389  actions.encap_cfg.encap.tun.geneve_options[3].data = rte_cpu_to_be_32(0x99aabbcc);
390  actions.encap_cfg.encap.tun.geneve_options[4].data = rte_cpu_to_be_32(0xddeeff00);
391  actions.action_idx = 3;
392  match.meta.pkt_meta = DOCA_HTOBE32(4);
393 
394  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &entry);
395  if (result != DOCA_SUCCESS)
396  return result;
397 
398  return DOCA_SUCCESS;
399 }
400 
401 /*
402  * Run flow_geneve_encap sample
403  *
404  * @nb_queues [in]: number of queues the sample will use
405  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
406  */
408 {
409  int nb_ports = 2;
410  struct flow_resources resource = {0};
411  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
412  struct doca_flow_port *ports[nb_ports];
413  struct doca_dev *dev_arr[nb_ports];
414  uint32_t actions_mem_size[nb_ports];
415  struct doca_flow_pipe *pipe;
416  struct entries_status status_ingress;
417  uint32_t num_of_entries_ingress = 4;
418  struct entries_status status_egress;
419  uint32_t num_of_entries_egress = 4;
421  int port_id;
422 
423  result = init_doca_flow(nb_queues, "vnf,hws", &resource, nr_shared_resources);
424  if (result != DOCA_SUCCESS) {
425  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
426  return result;
427  }
428 
429  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
430  ARRAY_INIT(actions_mem_size, ACTIONS_MEM_SIZE(nb_queues, num_of_entries_ingress + num_of_entries_egress));
432  if (result != DOCA_SUCCESS) {
433  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
435  return result;
436  }
437 
438  for (port_id = 0; port_id < nb_ports; port_id++) {
439  memset(&status_ingress, 0, sizeof(status_ingress));
440  memset(&status_egress, 0, sizeof(status_egress));
441 
442  result = create_match_pipe(ports[port_id], port_id, &pipe);
443  if (result != DOCA_SUCCESS) {
444  DOCA_LOG_ERR("Failed to create match pipe: %s", doca_error_get_descr(result));
447  return result;
448  }
449 
450  result = add_match_pipe_entries(pipe, &status_ingress);
451  if (result != DOCA_SUCCESS) {
452  DOCA_LOG_ERR("Failed to add entries to match pipe: %s", doca_error_get_descr(result));
455  return result;
456  }
457 
458  result = create_geneve_encap_pipe(ports[port_id ^ 1], port_id ^ 1, &pipe);
459  if (result != DOCA_SUCCESS) {
460  DOCA_LOG_ERR("Failed to create geneve encap pipe: %s", doca_error_get_descr(result));
463  return result;
464  }
465 
466  result = add_geneve_encap_pipe_entries(pipe, &status_egress);
467  if (result != DOCA_SUCCESS) {
468  DOCA_LOG_ERR("Failed to add entries to geneve encap pipe: %s", doca_error_get_descr(result));
471  return result;
472  }
473 
474  result = flow_process_entries(ports[port_id], &status_ingress, num_of_entries_ingress);
475  if (result != DOCA_SUCCESS) {
476  DOCA_LOG_ERR("Failed to process ingress entries: %s", doca_error_get_descr(result));
479  return result;
480  }
481 
482  result = flow_process_entries(ports[port_id ^ 1], &status_egress, num_of_entries_egress);
483  if (result != DOCA_SUCCESS) {
484  DOCA_LOG_ERR("Failed to process egress entries: %s", doca_error_get_descr(result));
487  return result;
488  }
489  }
490 
491  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
492  sleep(5);
493 
496  return result;
497 }
#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 doca_error_t add_geneve_encap_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
doca_error_t flow_geneve_encap(int nb_queues)
DOCA_LOG_REGISTER(FLOW_GENEVE_ENCAP)
static doca_error_t create_geneve_encap_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
static doca_error_t add_match_pipe_entries(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)
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 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_SUCCESS
Definition: doca_error.h:38
#define DOCA_FLOW_GENEVE_DEFAULT_PORT
Definition: doca_flow_net.h:52
#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_TCP
@ DOCA_FLOW_L4_TYPE_EXT_UDP
@ DOCA_FLOW_L3_TYPE_IP4
@ DOCA_FLOW_TUN_GENEVE
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_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_L4_META_TCP
Definition: doca_flow.h:308
@ 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
doca_error_t flow_process_entries(struct doca_flow_port *port, struct entries_status *status, uint32_t nr_entries)
Definition: flow_common.c:338
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 BUILD_VNI(uint24_vni)
Definition: flow_common.h:56
#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
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
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_tcp tcp
Definition: doca_flow.h:461
struct doca_flow_header_l4_port l4_port
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
enum doca_flow_l4_meta outer_l4_type
Definition: doca_flow.h:383
struct doca_flow_encap_action encap
Definition: doca_flow.h:663
enum doca_flow_tun_type type
union doca_flow_geneve_option geneve_options[DOCA_FLOW_GENEVE_OPT_LEN_MAX]
struct doca_flow_header_geneve geneve
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