NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_switch_single_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 <rte_byteorder.h>
30 
31 #include <doca_log.h>
32 #include <doca_flow.h>
33 
34 #include "flow_common.h"
35 #include "flow_switch_common.h"
36 
37 DOCA_LOG_REGISTER(FLOW_SWITCH);
38 
39 #define NB_ENTRIES 2
40 #define TOTAL_ENTRIES (NB_ENTRIES + 2)
41 
42 static struct doca_flow_pipe_entry *entries[NB_ENTRIES]; /* array for storing created entries */
43 static struct doca_flow_pipe_entry *to_kernel_entry;
44 static struct doca_flow_pipe *pipe_rss;
45 static struct doca_flow_pipe_entry *rss_entry;
46 
47 /*
48  * Create DOCA Flow pipe for ipv4 and forward RSS
49  *
50  * @port [in]: port of the pipe
51  * @pipe [out]: created pipe pointer
52  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
53  */
54 static doca_error_t create_rss_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
55 {
56  struct doca_flow_match match;
58  struct doca_flow_fwd fwd;
59  struct doca_flow_pipe_cfg *pipe_cfg;
60  uint16_t rss_queues[1];
62 
63  memset(&match, 0, sizeof(match));
64  memset(&fwd, 0, sizeof(fwd));
65  memset(&monitor, 0, sizeof(monitor));
66 
68 
69  /* L3 match */
71 
72  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
73  if (result != DOCA_SUCCESS) {
74  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
75  return result;
76  }
77 
78  result = set_flow_pipe_cfg(pipe_cfg, "RSS_META_PIPE", DOCA_FLOW_PIPE_BASIC, false);
79  if (result != DOCA_SUCCESS) {
80  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
81  goto destroy_pipe_cfg;
82  }
83  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
84  if (result != DOCA_SUCCESS) {
85  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
86  goto destroy_pipe_cfg;
87  }
89  if (result != DOCA_SUCCESS) {
90  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
91  goto destroy_pipe_cfg;
92  }
93 
94  /* RSS queue - send matched traffic to queue 0 */
95  rss_queues[0] = 0;
100  fwd.rss.nr_queues = 1;
101 
102  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
104  doca_flow_pipe_cfg_destroy(pipe_cfg);
105  return result;
106 }
107 
108 /*
109  * Add DOCA Flow pipe entry
110  *
111  * @pipe [in]: pipe of the entry
112  * @status [in]: user context for adding entry
113  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
114  */
115 static doca_error_t add_rss_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
116 {
117  struct doca_flow_match match;
118  struct doca_flow_actions actions;
120 
121  memset(&match, 0, sizeof(match));
122  memset(&actions, 0, sizeof(actions));
123 
124  actions.action_idx = 0;
125 
126  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &rss_entry);
127  if (result != DOCA_SUCCESS) {
128  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
129  return result;
130  }
131 
132  return DOCA_SUCCESS;
133 }
134 
135 /*
136  * Create DOCA Flow pipe with to_kernel match that forwards the matched traffic to kernel
137  *
138  * @miss_pipe [in]: miss pipe for forward miss
139  * @pipe [out]: created pipe pointer
140  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
141  */
142 static doca_error_t create_to_kernel_pipe(struct doca_flow_pipe *miss_pipe, struct doca_flow_pipe **pipe)
143 {
144  struct doca_flow_match match;
145  struct doca_flow_monitor monitor;
146  struct doca_flow_fwd fwd;
147  struct doca_flow_fwd fwd_miss;
148  struct doca_flow_pipe_cfg *pipe_cfg;
149  struct doca_flow_port *port = doca_flow_port_switch_get(NULL);
150  struct doca_flow_target *kernel_target;
152 
153  if (!port) {
154  DOCA_LOG_ERR("Failed to create pipe: port=NULL");
156  }
157 
158  memset(&match, 0, sizeof(match));
159  memset(&monitor, 0, sizeof(monitor));
160  memset(&fwd, 0, sizeof(fwd));
161  memset(&fwd_miss, 0, sizeof(fwd_miss));
162 
165 
167 
168  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
169  if (result != DOCA_SUCCESS) {
170  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
171  return result;
172  }
173 
174  result = set_flow_pipe_cfg(pipe_cfg, "TO_KERNEL_IPv4_PIPE", DOCA_FLOW_PIPE_BASIC, false);
175  if (result != DOCA_SUCCESS) {
176  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
177  goto destroy_pipe_cfg;
178  }
179  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
180  if (result != DOCA_SUCCESS) {
181  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
182  goto destroy_pipe_cfg;
183  }
185  if (result != DOCA_SUCCESS) {
186  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
187  goto destroy_pipe_cfg;
188  }
189 
191  if (result != DOCA_SUCCESS) {
192  DOCA_LOG_ERR("Failed to get kernel target: %s", doca_error_get_descr(result));
193  goto destroy_pipe_cfg;
194  }
195  /* forwarding traffic to kernel */
197  fwd.target = kernel_target;
198 
199  /* Unmatched packets will be forwarded to miss_pipe */
201  fwd_miss.next_pipe = miss_pipe;
202 
203  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
205  doca_flow_pipe_cfg_destroy(pipe_cfg);
206  return result;
207 }
208 
209 /*
210  * Add DOCA Flow pipe entry to the to_kernel pipe
211  *
212  * @pipe [in]: pipe of the entry
213  * @status [in]: user context for adding entry
214  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
215  */
216 static doca_error_t add_to_kernel_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
217 {
218  struct doca_flow_match match;
219  struct doca_flow_actions actions;
221 
222  memset(&match, 0, sizeof(match));
223  memset(&actions, 0, sizeof(actions));
224 
226 
227  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, &to_kernel_entry);
228  if (result != DOCA_SUCCESS) {
229  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
230  return result;
231  }
232 
233  return DOCA_SUCCESS;
234 }
235 
236 /*
237  * Create DOCA Flow pipe with 5 tuple match on the switch port.
238  * Matched traffic will be forwarded to the port defined per entry.
239  * Unmatched traffic will be dropped.
240  *
241  * @miss_pipe [in]: miss pipe for forward miss
242  * @pipe [out]: created pipe pointer
243  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
244  */
245 static doca_error_t create_switch_pipe(struct doca_flow_pipe *miss_pipe, struct doca_flow_pipe **pipe)
246 {
247  struct doca_flow_match match;
248  struct doca_flow_monitor monitor;
249  struct doca_flow_fwd fwd;
250  struct doca_flow_fwd fwd_miss;
251  struct doca_flow_pipe_cfg *pipe_cfg;
252  struct doca_flow_port *port = doca_flow_port_switch_get(NULL);
254 
255  memset(&match, 0, sizeof(match));
256  memset(&monitor, 0, sizeof(monitor));
257  memset(&fwd, 0, sizeof(fwd));
258  memset(&fwd_miss, 0, sizeof(fwd_miss));
259 
264 
265  /* Source, destination IP addresses and source, destination TCP ports are defined per entry */
266  match.outer.ip4.src_ip = 0xffffffff;
267  match.outer.ip4.dst_ip = 0xffffffff;
268  match.outer.tcp.l4_port.src_port = 0xffff;
269  match.outer.tcp.l4_port.dst_port = 0xffff;
270 
272 
273  /* Port ID to forward to is defined per entry */
274  fwd.port_id = 0xffff;
275 
276  /* Unmatched packets will be forwarded to miss_pipe */
278  fwd_miss.next_pipe = miss_pipe;
279 
281 
282  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
283  if (result != DOCA_SUCCESS) {
284  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
285  return result;
286  }
287 
288  result = set_flow_pipe_cfg(pipe_cfg, "SWITCH_PIPE", DOCA_FLOW_PIPE_BASIC, true);
289  if (result != DOCA_SUCCESS) {
290  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
291  goto destroy_pipe_cfg;
292  }
294  if (result != DOCA_SUCCESS) {
295  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg nr_entries: %s", doca_error_get_descr(result));
296  goto destroy_pipe_cfg;
297  }
298  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
299  if (result != DOCA_SUCCESS) {
300  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
301  goto destroy_pipe_cfg;
302  }
304  if (result != DOCA_SUCCESS) {
305  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
306  goto destroy_pipe_cfg;
307  }
308 
309  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
311  doca_flow_pipe_cfg_destroy(pipe_cfg);
312  return result;
313 }
314 
315 /*
316  * Add DOCA Flow pipe entry to the pipe
317  *
318  * @pipe [in]: pipe of the entry
319  * @status [in]: user context for adding entry
320  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
321  */
322 static doca_error_t add_switch_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
323 {
324  struct doca_flow_match match;
325  struct doca_flow_fwd fwd;
328  int entry_index = 0;
329 
330  doca_be32_t dst_ip_addr;
331  doca_be32_t src_ip_addr;
334 
335  memset(&fwd, 0, sizeof(fwd));
336  memset(&match, 0, sizeof(match));
337 
338  for (entry_index = 0; entry_index < NB_ENTRIES; entry_index++) {
339  dst_ip_addr = BE_IPV4_ADDR(8, 8, 8, 8 + entry_index);
340  src_ip_addr = BE_IPV4_ADDR(1, 2, 3, 4 + entry_index);
341  dst_port = rte_cpu_to_be_16(80);
342  src_port = rte_cpu_to_be_16(1234);
343 
344  match.outer.ip4.dst_ip = dst_ip_addr;
345  match.outer.ip4.src_ip = src_ip_addr;
348 
350  fwd.port_id = entry_index + 1; /* The port to forward to is defined based on the entry index */
351 
352  /* last entry should be inserted with DOCA_FLOW_NO_WAIT flag */
353  if (entry_index == NB_ENTRIES - 1)
354  flags = DOCA_FLOW_NO_WAIT;
355 
357  pipe,
358  &match,
359  NULL,
360  NULL,
361  &fwd,
362  flags,
363  status,
364  &entries[entry_index]);
365 
366  if (result != DOCA_SUCCESS) {
367  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
368  return result;
369  }
370  }
371 
372  return DOCA_SUCCESS;
373 }
374 /*
375  * Run flow_switch sample
376  *
377  * @nb_queues [in]: number of queues the sample will use
378  * @nb_ports [in]: number of ports the sample will use
379  * @ctx [in]: flow switch context the sample will use
380  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
381  */
383 {
384  struct flow_resources resource = {0};
385  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
386  struct doca_flow_port *ports[nb_ports];
387  struct doca_dev *dev_arr[nb_ports];
388  uint32_t actions_mem_size[nb_ports];
389  struct doca_flow_pipe *pipe;
390  struct doca_flow_pipe *to_kernel_pipe;
391  struct doca_flow_resource_query query_stats;
392  struct entries_status status;
394  int entry_idx;
395 
396  memset(&status, 0, sizeof(status));
397  resource.nr_counters = TOTAL_ENTRIES; /* counter per entry */
398 
399  result = init_doca_flow(nb_queues, "switch,isolated,hws", &resource, nr_shared_resources);
400  if (result != DOCA_SUCCESS) {
401  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
402  return result;
403  }
404 
405  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
406  dev_arr[0] = ctx->doca_dev[0];
408  result = init_doca_flow_ports(nb_ports, ports, false /* is_hairpin */, dev_arr, actions_mem_size);
409  if (result != DOCA_SUCCESS) {
410  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
412  return result;
413  }
414 
415  /* Create rss pipe and entry */
417  if (result != DOCA_SUCCESS) {
418  DOCA_LOG_ERR("Failed to create rss pipe: %s", doca_error_get_descr(result));
421  return result;
422  }
423 
424  result = add_rss_pipe_entry(pipe_rss, &status);
425  if (result != DOCA_SUCCESS) {
426  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
429  return result;
430  }
431 
432  result = create_to_kernel_pipe(pipe_rss, &to_kernel_pipe);
433  if (result != DOCA_SUCCESS) {
434  DOCA_LOG_ERR("Failed to create to_kernel pipe: %s", doca_error_get_descr(result));
437  return result;
438  }
439 
440  result = add_to_kernel_pipe_entry(to_kernel_pipe, &status);
441  if (result != DOCA_SUCCESS) {
442  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
445  return result;
446  }
447 
448  result = create_switch_pipe(to_kernel_pipe, &pipe);
449  if (result != DOCA_SUCCESS) {
450  DOCA_LOG_ERR("Failed to create pipe: %s", doca_error_get_descr(result));
453  return result;
454  }
455 
456  result = add_switch_pipe_entries(pipe, &status);
457  if (result != DOCA_SUCCESS) {
458  DOCA_LOG_ERR("Failed to add entries to the pipe: %s", doca_error_get_descr(result));
461  return result;
462  }
463 
465  if (result != DOCA_SUCCESS) {
466  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
469  return result;
470  }
471 
472  if (status.nb_processed != TOTAL_ENTRIES || status.failure) {
473  DOCA_LOG_ERR("Failed to process entries");
476  return DOCA_ERROR_BAD_STATE;
477  }
478 
479  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
480  sleep(15);
481 
482  /* dump entries counters */
483  for (entry_idx = 0; entry_idx < NB_ENTRIES; entry_idx++) {
485  if (result != DOCA_SUCCESS) {
486  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
489  return result;
490  }
491  DOCA_LOG_INFO("Entry in index: %d", entry_idx);
492  DOCA_LOG_INFO("Total bytes: %ld", query_stats.counter.total_bytes);
493  DOCA_LOG_INFO("Total packets: %ld", query_stats.counter.total_pkts);
494  }
496  if (result != DOCA_SUCCESS) {
497  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
500  return result;
501  }
502  DOCA_LOG_INFO("To kernel Entry:");
503  DOCA_LOG_INFO("Total bytes: %ld", query_stats.counter.total_bytes);
504  DOCA_LOG_INFO("Total packets: %ld", query_stats.counter.total_pkts);
505 
507  if (result != DOCA_SUCCESS) {
508  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
511  return result;
512  }
513  DOCA_LOG_INFO("RSS Entry:");
514  DOCA_LOG_INFO("Total bytes: %ld", query_stats.counter.total_bytes);
515  DOCA_LOG_INFO("Total packets: %ld", query_stats.counter.total_pkts);
516 
519  return result;
520 }
#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
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static struct doca_flow_fwd fwd_miss
Definition: flow_parser.c:110
static uint16_t * rss_queues
Definition: flow_parser.c:114
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_monitor monitor
Definition: flow_parser.c:108
static struct doca_flow_fwd fwd
Definition: flow_parser.c:109
#define DEFAULT_TIMEOUT_US
Definition: flow_skeleton.c:36
static uint8_t entry_idx
static struct doca_flow_pipe * pipe_rss
static doca_error_t add_rss_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static struct doca_flow_pipe_entry * to_kernel_entry
DOCA_LOG_REGISTER(FLOW_SWITCH)
static doca_error_t add_to_kernel_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static struct doca_flow_pipe_entry * entries[NB_ENTRIES]
doca_error_t flow_switch(int nb_queues, int nb_ports, struct flow_switch_ctx *ctx)
#define NB_ENTRIES
static doca_error_t create_to_kernel_pipe(struct doca_flow_pipe *miss_pipe, struct doca_flow_pipe **pipe)
#define TOTAL_ENTRIES
static doca_error_t create_rss_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
static struct doca_flow_pipe_entry * rss_entry
static doca_error_t create_switch_pipe(struct doca_flow_pipe *miss_pipe, struct doca_flow_pipe **pipe)
static doca_error_t add_switch_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
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
@ DOCA_FLOW_L4_TYPE_EXT_TCP
@ DOCA_FLOW_L3_TYPE_IP4
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_flow_flags_type
doca flow flags type
Definition: doca_flow.h:114
DOCA_EXPERIMENTAL doca_error_t doca_flow_get_target(enum doca_flow_target_type type, struct doca_flow_target **target)
Get doca flow forward target.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_cfg_set_monitor(struct doca_flow_pipe_cfg *cfg, const struct doca_flow_monitor *monitor)
Set pipe's monitor.
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_nr_entries(struct doca_flow_pipe_cfg *cfg, uint32_t nr_entries)
Set pipe's maximum number of flow rules.
DOCA_STABLE struct doca_flow_port * doca_flow_port_switch_get(const struct doca_flow_port *port)
Get doca flow switch port.
DOCA_EXPERIMENTAL doca_error_t doca_flow_resource_query_entry(struct doca_flow_pipe_entry *entry, struct doca_flow_resource_query *query_stats)
Extract information about specific entry.
@ DOCA_FLOW_RSS_TCP
Definition: doca_flow.h:770
@ DOCA_FLOW_RSS_IPV4
Definition: doca_flow.h:764
@ 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_TARGET_KERNEL
Definition: doca_flow.h:733
@ DOCA_FLOW_RESOURCE_TYPE_NON_SHARED
Definition: doca_flow.h:615
@ DOCA_FLOW_FWD_PORT
Definition: doca_flow.h:744
@ DOCA_FLOW_FWD_TARGET
Definition: doca_flow.h:750
@ DOCA_FLOW_FWD_PIPE
Definition: doca_flow.h:746
@ DOCA_FLOW_FWD_RSS
Definition: doca_flow.h:742
@ DOCA_FLOW_L4_META_UDP
Definition: doca_flow.h:310
@ DOCA_FLOW_L4_META_TCP
Definition: doca_flow.h:308
#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 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
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
struct doca_flow_pipe * pipe
Definition: doca_flow.h:806
struct doca_flow_target * target
Definition: doca_flow.h:812
uint16_t port_id
Definition: doca_flow.h:795
enum doca_flow_fwd_type type
Definition: doca_flow.h:780
enum doca_flow_resource_type rss_type
Definition: doca_flow.h:784
struct doca_flow_resource_rss_cfg rss
Definition: doca_flow.h:787
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
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
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
doca monitor action configuration
Definition: doca_flow.h:968
enum doca_flow_resource_type counter_type
Definition: doca_flow.h:988
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
flow resource query
Definition: doca_flow.h:1101
struct doca_flow_resource_query::@115::@117 counter
user context struct that will be used in entries process callback
Definition: flow_common.h:78
uint32_t nr_counters
Definition: flow_common.h:96
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
struct upf_accel_ctx * ctx