NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_switch_direction_info_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_DIRECTION_INFO);
38 
39 #define NB_ENTRIES 6
40 
41 static struct doca_flow_pipe_entry *entries[NB_ENTRIES]; /* array for storing created entries */
42 static uint8_t entry_idx = 0;
43 
44 /*
45  * Create DOCA Flow pipe with match on ipv4 and next_proto
46  * Matched traffic will be forwarded to the port defined per entry.
47  * Unmatched traffic will be dropped.
48  *
49  * @sw_port [in]: switch port
50  * @pipe [out]: created pipe pointer
51  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
52  */
53 static doca_error_t create_network_to_host_pipe(struct doca_flow_port *sw_port, struct doca_flow_pipe **pipe)
54 {
55  struct doca_flow_match match;
58  struct doca_flow_fwd fwd;
59  struct doca_flow_fwd fwd_miss;
60  struct doca_flow_pipe_cfg *pipe_cfg;
62 
63  memset(&match, 0, sizeof(match));
64  memset(&match_mask, 0, sizeof(match_mask));
65  memset(&monitor, 0, sizeof(monitor));
66  memset(&fwd, 0, sizeof(fwd));
67  memset(&fwd_miss, 0, sizeof(fwd_miss));
68 
71  match.outer.ip4.next_proto = UINT8_MAX;
72 
75  match_mask.outer.ip4.next_proto = UINT8_MAX;
76 
78 
79  /* Port ID to forward to is defined per entry */
80  fwd.port_id = UINT16_MAX;
81 
82  /* Unmatched packets will be dropped */
84 
86 
87  result = doca_flow_pipe_cfg_create(&pipe_cfg, sw_port);
88  if (result != DOCA_SUCCESS) {
89  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
90  return result;
91  }
92 
93  result = set_flow_pipe_cfg(pipe_cfg, "N2H_PIPE", DOCA_FLOW_PIPE_BASIC, false);
94  if (result != DOCA_SUCCESS) {
95  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
96  goto destroy_pipe_cfg;
97  }
99  if (result != DOCA_SUCCESS) {
100  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg nr_entries: %s", doca_error_get_descr(result));
101  goto destroy_pipe_cfg;
102  }
104  if (result != DOCA_SUCCESS) {
105  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg dir_info: %s", doca_error_get_descr(result));
106  goto destroy_pipe_cfg;
107  }
108  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, &match_mask);
109  if (result != DOCA_SUCCESS) {
110  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
111  goto destroy_pipe_cfg;
112  }
114  if (result != DOCA_SUCCESS) {
115  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
116  goto destroy_pipe_cfg;
117  }
118 
119  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
121  doca_flow_pipe_cfg_destroy(pipe_cfg);
122  return result;
123 }
124 
125 /*
126  * Add DOCA Flow pipe entry to the pipe
127  *
128  * @pipe [in]: pipe of the entry
129  * @status [in]: user context for adding entry
130  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
131  */
132 static doca_error_t add_network_to_host_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
133 {
134  struct doca_flow_match match;
135  struct doca_flow_fwd fwd;
137 
138  memset(&fwd, 0, sizeof(fwd));
139  memset(&match, 0, sizeof(match));
140 
143 
144  /* tcp traffic from the network forwards to port 1 */
145  fwd.port_id = 1;
147 
149  pipe,
150  &match,
151  NULL,
152  NULL,
153  &fwd,
155  status,
156  &entries[entry_idx++]);
157  if (result != DOCA_SUCCESS) {
158  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
159  return result;
160  }
161 
162  /* udp traffic from the network forwards to port 2 */
163  fwd.port_id = 2;
165 
167  pipe,
168  &match,
169  NULL,
170  NULL,
171  &fwd,
173  status,
174  &entries[entry_idx++]);
175  if (result != DOCA_SUCCESS) {
176  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
177  return result;
178  }
179 
180  return DOCA_SUCCESS;
181 }
182 
183 /*
184  * Create DOCA Flow pipe with match packets with dst_max = aa:aa:aa:aa:aa:aa
185  * Matched traffic will be forwarded to the port defined per entry.
186  * Unmatched traffic will be dropped.
187  *
188  * @sw_port [in]: switch port
189  * @pipe [out]: created pipe pointer
190  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
191  */
192 static doca_error_t create_host_to_network_pipe(struct doca_flow_port *sw_port, struct doca_flow_pipe **pipe)
193 {
194  struct doca_flow_match match;
195  struct doca_flow_monitor monitor;
196  struct doca_flow_fwd fwd;
197  struct doca_flow_fwd fwd_miss;
198  struct doca_flow_pipe_cfg *pipe_cfg;
200 
201  memset(&match, 0, sizeof(match));
202  memset(&monitor, 0, sizeof(monitor));
203  memset(&fwd_miss, 0, sizeof(fwd_miss));
204 
206  fwd.port_id = UINT16_MAX;
207 
208  memset(&match.outer.eth.src_mac, 0xaa, DOCA_FLOW_ETHER_ADDR_LEN);
209 
210  /* Unmatched packets will be dropped */
212 
214 
215  result = doca_flow_pipe_cfg_create(&pipe_cfg, sw_port);
216  if (result != DOCA_SUCCESS) {
217  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
218  return result;
219  }
220 
221  result = set_flow_pipe_cfg(pipe_cfg, "H2N_PIPE", DOCA_FLOW_PIPE_BASIC, false);
222  if (result != DOCA_SUCCESS) {
223  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
224  goto destroy_pipe_cfg;
225  }
227  if (result != DOCA_SUCCESS) {
228  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg nr_entries: %s", doca_error_get_descr(result));
229  goto destroy_pipe_cfg;
230  }
232  if (result != DOCA_SUCCESS) {
233  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg dir_info: %s", doca_error_get_descr(result));
234  goto destroy_pipe_cfg;
235  }
236  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
237  if (result != DOCA_SUCCESS) {
238  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
239  goto destroy_pipe_cfg;
240  }
242  if (result != DOCA_SUCCESS) {
243  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
244  goto destroy_pipe_cfg;
245  }
246 
247  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
249  doca_flow_pipe_cfg_destroy(pipe_cfg);
250  return result;
251 }
252 
253 /*
254  * Add DOCA Flow pipe entry to the pipe
255  *
256  * @pipe [in]: pipe of the entry
257  * @status [in]: user context for adding entry
258  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
259  */
260 static doca_error_t add_host_to_network_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
261 {
262  struct doca_flow_match match;
263  struct doca_flow_fwd fwd;
265 
266  memset(&match, 0, sizeof(match));
267  memset(&fwd, 0, sizeof(fwd));
268 
270  fwd.port_id = 0;
271 
273  pipe,
274  &match,
275  NULL,
276  NULL,
277  &fwd,
279  status,
280  &entries[entry_idx++]);
281  if (result != DOCA_SUCCESS) {
282  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
283  return result;
284  }
285 
286  return DOCA_SUCCESS;
287 }
288 
289 /*
290  * Create DOCA Flow pipe with match on port_id
291  * Matched traffic will be forwarded to the pipe defined per entry.
292  * Unmatched traffic will be dropped.
293  *
294  * @sw_port [in]: switch port
295  * @nb_ports [in]: number of ports
296  * @pipe [out]: created pipe pointer
297  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
298  */
299 static doca_error_t create_switch_pipe(struct doca_flow_port *sw_port, int nb_ports, struct doca_flow_pipe **pipe)
300 {
301  struct doca_flow_match match;
303  struct doca_flow_monitor monitor;
304  struct doca_flow_fwd fwd_miss;
305  struct doca_flow_pipe_cfg *pipe_cfg;
308 
309  memset(&match, 0, sizeof(match));
310  memset(&match_mask, 0, sizeof(match_mask));
311  memset(&monitor, 0, sizeof(monitor));
312  memset(&fwd_miss, 0, sizeof(fwd_miss));
313 
314  match.parser_meta.port_id = UINT16_MAX;
315  match_mask.parser_meta.port_id = UINT16_MAX;
316 
317  /* Unmatched packets will be dropped */
319 
321 
322  result = doca_flow_pipe_cfg_create(&pipe_cfg, sw_port);
323  if (result != DOCA_SUCCESS) {
324  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
325  return result;
326  }
327 
328  result = set_flow_pipe_cfg(pipe_cfg, "SWITCH_PIPE", DOCA_FLOW_PIPE_BASIC, true);
329  if (result != DOCA_SUCCESS) {
330  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
331  goto destroy_pipe_cfg;
332  }
334  if (result != DOCA_SUCCESS) {
335  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg nr_entries: %s", doca_error_get_descr(result));
336  goto destroy_pipe_cfg;
337  }
338  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, &match_mask);
339  if (result != DOCA_SUCCESS) {
340  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
341  goto destroy_pipe_cfg;
342  }
344  if (result != DOCA_SUCCESS) {
345  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
346  goto destroy_pipe_cfg;
347  }
348 
349  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
351  doca_flow_pipe_cfg_destroy(pipe_cfg);
352  return result;
353 }
354 
355 /*
356  * Add DOCA Flow pipe entry to the pipe
357  *
358  * @pipe [in]: pipe of the entry
359  * @n2h_pipe [in]: next pipe for network to host traffic
360  * @h2n_pipe [in]: next pipe for host to network traffic
361  * @status [in]: user context for adding entry
362  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
363  */
364 static doca_error_t add_switch_pipe_entries(struct doca_flow_pipe *pipe,
365  struct doca_flow_pipe *n2h_pipe,
366  struct doca_flow_pipe *h2n_pipe,
367  struct entries_status *status)
368 {
369  struct doca_flow_match match;
370  struct doca_flow_fwd fwd;
372 
373  memset(&fwd, 0, sizeof(fwd));
374  memset(&match, 0, sizeof(match));
375 
376  match.parser_meta.port_id = 0;
378  fwd.next_pipe = n2h_pipe;
379 
381  pipe,
382  &match,
383  NULL,
384  NULL,
385  &fwd,
387  status,
388  &entries[entry_idx++]);
389  if (result != DOCA_SUCCESS) {
390  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
391  return result;
392  }
393 
394  match.parser_meta.port_id = 1;
396  fwd.next_pipe = h2n_pipe;
397 
399  pipe,
400  &match,
401  NULL,
402  NULL,
403  &fwd,
405  status,
406  &entries[entry_idx++]);
407  if (result != DOCA_SUCCESS) {
408  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
409  return result;
410  }
411 
412  match.parser_meta.port_id = 2;
414  fwd.next_pipe = h2n_pipe;
415 
417  pipe,
418  &match,
419  NULL,
420  NULL,
421  &fwd,
423  status,
424  &entries[entry_idx++]);
425  if (result != DOCA_SUCCESS) {
426  DOCA_LOG_ERR("Failed to add pipe entry: %s", doca_error_get_descr(result));
427  return result;
428  }
429 
430  return DOCA_SUCCESS;
431 }
432 /*
433  * Run flow_switch_direction_info sample
434  *
435  * @nb_queues [in]: number of queues the sample will use
436  * @nb_ports [in]: number of ports the sample will use
437  * @ctx [in]: flow switch context the sample will use
438  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
439  */
441 {
442  struct flow_resources resource = {0};
443  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
444  struct doca_flow_port *ports[nb_ports];
445  struct doca_dev *dev_arr[nb_ports];
446  uint32_t actions_mem_size[nb_ports];
447  struct doca_flow_pipe *root_pipe;
448  struct doca_flow_pipe *n2h_pipe;
449  struct doca_flow_pipe *h2n_pipe;
450  struct doca_flow_resource_query query_stats;
451  struct entries_status status;
453  int entry_idx;
454 
455  memset(&status, 0, sizeof(status));
456  resource.nr_counters = NB_ENTRIES; /* counter per entry */
457 
458  result = init_doca_flow(nb_queues, "switch,hws", &resource, nr_shared_resources);
459  if (result != DOCA_SUCCESS) {
460  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
461  return result;
462  }
463 
464  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
465  dev_arr[0] = ctx->doca_dev[0];
467  result = init_doca_flow_ports(nb_ports, ports, false /* is_hairpin */, dev_arr, actions_mem_size);
468  if (result != DOCA_SUCCESS) {
469  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
471  return result;
472  }
473 
475  if (result != DOCA_SUCCESS) {
476  DOCA_LOG_ERR("Failed to create network to host pipe: %s", doca_error_get_descr(result));
479  return result;
480  }
481 
482  result = add_network_to_host_pipe_entries(n2h_pipe, &status);
483  if (result != DOCA_SUCCESS) {
484  DOCA_LOG_ERR("Failed to add entries to network to host pipe: %s", doca_error_get_descr(result));
487  return result;
488  }
489 
491  if (result != DOCA_SUCCESS) {
492  DOCA_LOG_ERR("Failed to create host to network pipe: %s", doca_error_get_descr(result));
495  return result;
496  }
497 
498  result = add_host_to_network_pipe_entries(h2n_pipe, &status);
499  if (result != DOCA_SUCCESS) {
500  DOCA_LOG_ERR("Failed to add entries to host to network pipe: %s", doca_error_get_descr(result));
503  return result;
504  }
505 
507  if (result != DOCA_SUCCESS) {
508  DOCA_LOG_ERR("Failed to create switch pipe: %s", doca_error_get_descr(result));
511  return result;
512  }
513 
514  result = add_switch_pipe_entries(root_pipe, n2h_pipe, h2n_pipe, &status);
515  if (result != DOCA_SUCCESS) {
516  DOCA_LOG_ERR("Failed to add entries to switch pipe: %s", doca_error_get_descr(result));
519  return result;
520  }
521 
523  if (result != DOCA_SUCCESS) {
524  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
527  return result;
528  }
529 
530  if (status.nb_processed != NB_ENTRIES || status.failure) {
531  DOCA_LOG_ERR("Failed to process entries");
534  return DOCA_ERROR_BAD_STATE;
535  }
536 
537  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
538  sleep(15);
539 
540  /* dump entries counters */
541  for (entry_idx = 0; entry_idx < NB_ENTRIES; entry_idx++) {
543  if (result != DOCA_SUCCESS) {
544  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
547  return result;
548  }
549  DOCA_LOG_INFO("Entry in index: %d", entry_idx);
550  DOCA_LOG_INFO("Total bytes: %ld", query_stats.counter.total_bytes);
551  DOCA_LOG_INFO("Total packets: %ld", query_stats.counter.total_pkts);
552  }
553 
556  return result;
557 }
#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 struct doca_flow_monitor monitor
Definition: flow_parser.c:108
static struct doca_flow_fwd fwd
Definition: flow_parser.c:109
static struct doca_flow_match match_mask
Definition: flow_parser.c:106
#define DEFAULT_TIMEOUT_US
Definition: flow_skeleton.c:36
static doca_error_t create_switch_pipe(struct doca_flow_port *sw_port, int nb_ports, struct doca_flow_pipe **pipe)
DOCA_LOG_REGISTER(FLOW_SWITCH_DIRECTION_INFO)
static doca_error_t add_host_to_network_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
static struct doca_flow_pipe_entry * entries[NB_ENTRIES]
static doca_error_t add_switch_pipe_entries(struct doca_flow_pipe *pipe, struct doca_flow_pipe *n2h_pipe, struct doca_flow_pipe *h2n_pipe, struct entries_status *status)
static doca_error_t add_network_to_host_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status)
doca_error_t flow_switch_direction_info(int nb_queues, int nb_ports, struct flow_switch_ctx *ctx)
static doca_error_t create_network_to_host_pipe(struct doca_flow_port *sw_port, struct doca_flow_pipe **pipe)
static uint8_t entry_idx
static doca_error_t create_host_to_network_pipe(struct doca_flow_port *sw_port, struct doca_flow_pipe **pipe)
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_PROTO_UDP
Definition: doca_flow_net.h:42
#define DOCA_FLOW_PROTO_TCP
Definition: doca_flow_net.h:41
#define DOCA_FLOW_ETHER_ADDR_LEN
Definition: doca_flow_net.h:36
@ 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_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_EXPERIMENTAL doca_error_t doca_flow_pipe_cfg_set_dir_info(struct doca_flow_pipe_cfg *cfg, enum doca_flow_direction_info dir_info)
Set pipe's Direction info.
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_DIRECTION_HOST_TO_NETWORK
Definition: doca_flow.h:1095
@ DOCA_FLOW_DIRECTION_NETWORK_TO_HOST
Definition: doca_flow.h:1094
@ DOCA_FLOW_PIPE_BASIC
Definition: doca_flow.h:221
@ DOCA_FLOW_L3_META_IPV4
Definition: doca_flow.h:296
@ DOCA_FLOW_NO_WAIT
Definition: doca_flow.h:115
@ DOCA_FLOW_WAIT_FOR_BATCH
Definition: doca_flow.h:117
@ DOCA_FLOW_RESOURCE_TYPE_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_FWD_CHANGEABLE
Definition: doca_flow.h:756
@ DOCA_FLOW_FWD_DROP
Definition: doca_flow.h:748
#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
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
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
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
struct doca_flow_header_eth eth
Definition: doca_flow.h:440
enum doca_flow_l3_type l3_type
Definition: doca_flow.h:446
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
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