NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_shared_mirror_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 #include <rte_ethdev.h>
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_SHARED_MIRROR);
38 
39 /* Set match l4 port */
40 #define SET_L4_PORT(layer, port, value) \
41  do { \
42  if (match.layer.l4_type_ext == DOCA_FLOW_L4_TYPE_EXT_TCP) \
43  match.layer.tcp.l4_port.port = (value); \
44  else if (match.layer.l4_type_ext == DOCA_FLOW_L4_TYPE_EXT_UDP) \
45  match.layer.udp.l4_port.port = (value); \
46  } while (0)
47 
48 #define SAMPLE_MIRROR_CONTROL_ENTRY_MAX 2
49 #define SAMPLE_MIRROR_ENTRY_MAX 4
50 #define SAMPLE_ENTRY_TOTAL (SAMPLE_MIRROR_CONTROL_ENTRY_MAX + SAMPLE_MIRROR_ENTRY_MAX)
51 
52 static struct doca_flow_pipe_entry *mirror_entries[SAMPLE_MIRROR_ENTRY_MAX];
53 static uint32_t mirror_idx = 0;
54 
55 /*
56  * Create DOCA Flow pipe with 5 tuple match and monitor with shared mirror ID
57  *
58  * @port [in]: port of the pipe
59  * @out_l4_type [in]: l4 type to match: UDP/TCP
60  * @fwd [in]: pipe fwd
61  * @match_src [in]: pipe match with src
62  * @mirror_id [in]: pipe mirror_id
63  * @pipe [out]: created pipe pointer
64  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
65  */
66 static doca_error_t create_shared_mirror_pipe(struct doca_flow_port *port,
67  enum doca_flow_l4_type_ext out_l4_type,
68  struct doca_flow_fwd *fwd,
69  bool match_src,
70  uint32_t mirror_id,
71  struct doca_flow_pipe **pipe)
72 {
73  struct doca_flow_match match;
75  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
76  struct doca_flow_pipe_cfg *pipe_cfg;
78 
79  memset(&match, 0, sizeof(match));
80  memset(&monitor, 0, sizeof(monitor));
81  memset(&actions, 0, sizeof(actions));
82 
83  /* 5 tuple match */
84  match.outer.l4_type_ext = out_l4_type;
86  if (match_src)
87  match.outer.ip4.src_ip = UINT32_MAX;
88  else
89  match.outer.ip4.dst_ip = UINT32_MAX;
90  SET_L4_PORT(outer, src_port, UINT16_MAX);
91  SET_L4_PORT(outer, dst_port, UINT16_MAX);
92 
93  actions_arr[0] = &actions;
94 
95  monitor.shared_mirror_id = mirror_id;
97 
98  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
99  if (result != DOCA_SUCCESS) {
100  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
101  return result;
102  }
103 
104  result = set_flow_pipe_cfg(pipe_cfg, "SHARED_MIRROR_PIPE", DOCA_FLOW_PIPE_BASIC, false);
105  if (result != DOCA_SUCCESS) {
106  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
107  goto destroy_pipe_cfg;
108  }
109  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
110  if (result != DOCA_SUCCESS) {
111  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
112  goto destroy_pipe_cfg;
113  }
114  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
115  if (result != DOCA_SUCCESS) {
116  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
117  goto destroy_pipe_cfg;
118  }
120  if (result != DOCA_SUCCESS) {
121  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
122  goto destroy_pipe_cfg;
123  }
124 
125  result = doca_flow_pipe_create(pipe_cfg, fwd, NULL, pipe);
127  doca_flow_pipe_cfg_destroy(pipe_cfg);
128  return result;
129 }
130 
131 /*
132  * Add DOCA Flow pipe entry to the shared mirror pipe
133  *
134  * @pipe [in]: pipe of the entry
135  * @out_l4_type [in]: l4 type to match: UDP/TCP
136  * @fwd [in]: entry fwd
137  * @match_src [in]: match with src
138  * @shared_mirror_id [in]: ID of the shared mirror
139  * @status [in]: user context for adding entry
140  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
141  */
142 static doca_error_t add_shared_mirror_pipe_entry(struct doca_flow_pipe *pipe,
143  enum doca_flow_l4_type_ext out_l4_type,
144  struct doca_flow_fwd *fwd,
145  bool match_src,
146  uint32_t shared_mirror_id,
147  struct entries_status *status)
148 {
149  struct doca_flow_match match;
150  struct doca_flow_actions actions;
151  struct doca_flow_monitor monitor;
152  struct doca_flow_pipe_entry *entry;
154 
155  /* example 5-tuple to match */
156  doca_be32_t dst_ip_addr = BE_IPV4_ADDR(8, 8, 8, 8);
157  doca_be32_t src_ip_addr = BE_IPV4_ADDR(1, 2, 3, 4);
158  doca_be16_t dst_port = rte_cpu_to_be_16(80);
159  doca_be16_t src_port = rte_cpu_to_be_16(1234);
160 
161  memset(&match, 0, sizeof(match));
162  memset(&actions, 0, sizeof(actions));
163  memset(&monitor, 0, sizeof(monitor));
164 
165  /* set shared mirror ID */
166  monitor.shared_mirror_id = shared_mirror_id;
167 
168  if (match_src)
169  match.outer.ip4.src_ip = src_ip_addr;
170  else
171  match.outer.ip4.dst_ip = dst_ip_addr;
172  match.outer.l4_type_ext = out_l4_type;
173  SET_L4_PORT(outer, dst_port, dst_port);
174  SET_L4_PORT(outer, src_port, src_port);
175 
176  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, &monitor, fwd, 0, status, &entry);
177  if (result != DOCA_SUCCESS) {
178  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
179  return result;
180  }
182 
183  return DOCA_SUCCESS;
184 }
185 
186 /*
187  * Add DOCA Flow control pipe
188  *
189  * @port [in]: port of the pipe
190  * @pipe [out]: created pipe pointer
191  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
192  */
193 static doca_error_t create_control_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
194 {
195  struct doca_flow_pipe_cfg *pipe_cfg;
197 
198  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
199  if (result != DOCA_SUCCESS) {
200  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
201  return result;
202  }
203 
204  result = set_flow_pipe_cfg(pipe_cfg, "CONTROL_PIPE", DOCA_FLOW_PIPE_CONTROL, true);
205  if (result != DOCA_SUCCESS) {
206  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
207  goto destroy_pipe_cfg;
208  }
209 
210  result = doca_flow_pipe_create(pipe_cfg, NULL, NULL, pipe);
212  doca_flow_pipe_cfg_destroy(pipe_cfg);
213  return result;
214 }
215 
216 /*
217  * Add DOCA Flow pipe entries to the control pipe. First entry forwards UDP packets to udp_pipe and the second
218  * forwards TCP packets to tcp_pipe
219  *
220  * @control_pipe [in]: pipe of the entries
221  * @tcp_pipe [in]: pointer to the TCP pipe to forward packets to
222  * @udp_pipe [in]: pointer to the UDP pipe to forward packets to
223  * @status [in]: user context for adding entry
224  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
225  */
226 static doca_error_t add_control_pipe_entries(struct doca_flow_pipe *control_pipe,
227  struct doca_flow_pipe *tcp_pipe,
228  struct doca_flow_pipe *udp_pipe,
229  struct entries_status *status)
230 {
231  struct doca_flow_match match = {0};
232  struct doca_flow_fwd fwd = {0};
236  };
237  struct doca_flow_pipe *next_pipe[SAMPLE_MIRROR_CONTROL_ENTRY_MAX] = {
238  udp_pipe,
239  tcp_pipe,
240  };
241  uint8_t priority = 0;
242  uint32_t i;
244 
247  for (i = 0; i < SAMPLE_MIRROR_CONTROL_ENTRY_MAX; i++) {
248  match.parser_meta.outer_l4_type = l4_meta_type[i];
249  fwd.next_pipe = next_pipe[i];
250 
252  priority,
253  control_pipe,
254  &match,
255  NULL,
256  NULL,
257  NULL,
258  NULL,
259  NULL,
260  NULL,
261  &fwd,
262  status,
263  NULL);
264  if (result != DOCA_SUCCESS) {
265  DOCA_LOG_ERR("Failed to add control pipe entry: %s", doca_error_get_descr(result));
266  return result;
267  }
268  }
269 
270  return DOCA_SUCCESS;
271 }
272 
273 /*
274  * Run flow_shared_mirror sample
275  *
276  * @nb_ports [in]: number of ports the sample will use
277  * @nb_queues [in]: number of queues the sample will use
278  * @ctx [in]: flow switch context the sample will use
279  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
280  */
282 {
283  struct flow_resources resource = {0};
284  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
285  struct doca_flow_port *ports[nb_ports];
286  struct doca_dev *dev_arr[nb_ports];
287  uint32_t actions_mem_size[nb_ports];
288  struct doca_flow_pipe *tcp_pipe, *udp_pipe, *pipe;
289  uint32_t shared_mirror_ids[] = {1, 2};
290  struct doca_flow_mirror_target target = {0};
291  struct doca_flow_shared_resource_cfg cfg = {0};
292  struct doca_flow_resource_mirror_cfg mirror_cfg = {0};
293  struct entries_status status;
294  struct doca_flow_fwd fwd = {0};
295  int num_of_entries = SAMPLE_ENTRY_TOTAL;
296  struct doca_flow_resource_query query_stats;
297  int i;
299 
302 
303  result = init_doca_flow(nb_queues, "switch,hws,isolated", &resource, nr_shared_resources);
304  if (result != DOCA_SUCCESS) {
305  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
306  return result;
307  }
308 
309  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
310  dev_arr[0] = ctx->doca_dev[0];
311  ARRAY_INIT(actions_mem_size, ACTIONS_MEM_SIZE(nb_queues, num_of_entries));
313  if (result != DOCA_SUCCESS) {
314  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
316  return result;
317  }
318 
319  mirror_cfg.nr_targets = 1;
320  target.fwd.type = DOCA_FLOW_FWD_PORT;
321  target.fwd.port_id = 1;
322  mirror_cfg.target = &target;
323  cfg.mirror_cfg = mirror_cfg;
324 
325  memset(&status, 0, sizeof(status));
326 
327  /* config shared mirror without FWD */
329  if (result != DOCA_SUCCESS) {
330  DOCA_LOG_ERR("Failed to cfg shared mirror");
333  return result;
334  }
335 
336  /* config shared mirror with FWD */
337  target.fwd.port_id = 0;
338  cfg.mirror_cfg.fwd.type = DOCA_FLOW_FWD_PORT;
339  cfg.mirror_cfg.fwd.port_id = 0;
341  if (result != DOCA_SUCCESS) {
342  DOCA_LOG_ERR("Failed to cfg shared mirror");
345  return result;
346  }
347 
348  /* bind shared mirror to port */
350  if (result != DOCA_SUCCESS) {
351  DOCA_LOG_ERR("Failed to bind shared mirror to port");
354  return result;
355  }
356 
357  /* 1. Pipe with constant has_fwd mirror and NULL FWD */
360  NULL,
361  false,
362  shared_mirror_ids[1],
363  &tcp_pipe);
364  if (result != DOCA_SUCCESS) {
365  DOCA_LOG_ERR("Failed to create pipe: %s", doca_error_get_descr(result));
368  return result;
369  }
370 
371  result = add_shared_mirror_pipe_entry(tcp_pipe, DOCA_FLOW_L4_TYPE_EXT_TCP, NULL, false, 0, &status);
372  if (result != DOCA_SUCCESS) {
373  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
376  return result;
377  }
378 
379  /* 2. Pipe with dynamic has_fwd mirror and NULL FWD */
380  result = create_shared_mirror_pipe(ports[0], DOCA_FLOW_L4_TYPE_EXT_UDP, NULL, false, UINT32_MAX, &udp_pipe);
381  if (result != DOCA_SUCCESS) {
382  DOCA_LOG_ERR("Failed to create pipe: %s", doca_error_get_descr(result));
385  return result;
386  }
387 
390  NULL,
391  false,
392  shared_mirror_ids[1],
393  &status);
394  if (result != DOCA_SUCCESS) {
395  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
398  return result;
399  }
400 
401  /* config fwd */
402  memset(&fwd, 0, sizeof(fwd));
404 
405  /* 3. Pipe with constant mirror and constant FWD */
406  fwd.next_pipe = tcp_pipe;
409  &fwd,
410  true,
411  shared_mirror_ids[0],
412  &tcp_pipe);
413  if (result != DOCA_SUCCESS) {
414  DOCA_LOG_ERR("Failed to create pipe: %s", doca_error_get_descr(result));
417  return result;
418  }
419 
420  result = add_shared_mirror_pipe_entry(tcp_pipe, DOCA_FLOW_L4_TYPE_EXT_TCP, NULL, true, 0, &status);
421  if (result != DOCA_SUCCESS) {
422  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
425  return result;
426  }
427 
428  /* 4. Pipe with dynamic mirror and constant FWD */
429  fwd.next_pipe = udp_pipe;
430  result = create_shared_mirror_pipe(ports[0], DOCA_FLOW_L4_TYPE_EXT_UDP, &fwd, true, UINT32_MAX, &udp_pipe);
431  if (result != DOCA_SUCCESS) {
432  DOCA_LOG_ERR("Failed to create pipe: %s", doca_error_get_descr(result));
435  return result;
436  }
437 
440  NULL,
441  true,
442  shared_mirror_ids[0],
443  &status);
444  if (result != DOCA_SUCCESS) {
445  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
448  return result;
449  }
450 
451  result = create_control_pipe(ports[0], &pipe);
452  if (result != DOCA_SUCCESS) {
453  DOCA_LOG_ERR("Failed to create control pipe: %s", doca_error_get_descr(result));
456  return result;
457  }
458 
459  result = add_control_pipe_entries(pipe, tcp_pipe, udp_pipe, &status);
460  if (result != DOCA_SUCCESS) {
463  return result;
464  }
465 
466  result = doca_flow_entries_process(ports[0], 0, DEFAULT_TIMEOUT_US, num_of_entries);
467  if (result != DOCA_SUCCESS) {
468  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
471  return result;
472  }
473 
474  if (status.nb_processed != num_of_entries || status.failure) {
475  DOCA_LOG_ERR("Failed to process entries");
478  return DOCA_ERROR_BAD_STATE;
479  }
480 
481  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
482  sleep(15);
483 
484  for (i = 0; i < SAMPLE_MIRROR_ENTRY_MAX; i++) {
486  if (result != DOCA_SUCCESS) {
487  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
490  return result;
491  }
492  DOCA_LOG_INFO("Mirror Entry in index: %d", i);
493  DOCA_LOG_INFO("Total bytes: %ld", query_stats.counter.total_bytes);
494  DOCA_LOG_INFO("Total packets: %ld", query_stats.counter.total_pkts);
495  }
496 
499  return result;
500 }
#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_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
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
static struct doca_flow_pipe_entry * mirror_entries[SAMPLE_MIRROR_ENTRY_MAX]
static doca_error_t create_control_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
doca_error_t flow_shared_mirror(int nb_ports, int nb_queues, struct flow_switch_ctx *ctx)
static uint32_t mirror_idx
#define SAMPLE_ENTRY_TOTAL
#define SAMPLE_MIRROR_ENTRY_MAX
static doca_error_t add_control_pipe_entries(struct doca_flow_pipe *control_pipe, struct doca_flow_pipe *tcp_pipe, struct doca_flow_pipe *udp_pipe, struct entries_status *status)
#define SET_L4_PORT(layer, port, value)
#define SAMPLE_MIRROR_CONTROL_ENTRY_MAX
static doca_error_t add_shared_mirror_pipe_entry(struct doca_flow_pipe *pipe, enum doca_flow_l4_type_ext out_l4_type, struct doca_flow_fwd *fwd, bool match_src, uint32_t shared_mirror_id, struct entries_status *status)
static doca_error_t create_shared_mirror_pipe(struct doca_flow_port *port, enum doca_flow_l4_type_ext out_l4_type, struct doca_flow_fwd *fwd, bool match_src, uint32_t mirror_id, struct doca_flow_pipe **pipe)
DOCA_LOG_REGISTER(FLOW_SHARED_MIRROR)
#define DEFAULT_TIMEOUT_US
Definition: flow_skeleton.c:36
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
doca_flow_l4_type_ext
doca flow layer 4 packet extend type
@ DOCA_FLOW_L4_TYPE_EXT_TCP
@ DOCA_FLOW_L4_TYPE_EXT_UDP
@ 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_STABLE doca_error_t doca_flow_shared_resources_bind(enum doca_flow_shared_resource_type type, uint32_t *res_array, uint32_t res_array_len, void *bindable_obj)
Binds a bulk of shared resources to a bindable object.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_control_add_entry(uint16_t pipe_queue, uint32_t priority, struct doca_flow_pipe *pipe, const struct doca_flow_match *match, const struct doca_flow_match *match_mask, const struct doca_flow_match_condition *condition, const struct doca_flow_actions *actions, const struct doca_flow_actions *actions_mask, const struct doca_flow_action_descs *action_descs, const struct doca_flow_monitor *monitor, const struct doca_flow_fwd *fwd, void *usr_ctx, struct doca_flow_pipe_entry **entry)
Add one new entry to a control pipe.
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_shared_resource_set_cfg(enum doca_flow_shared_resource_type type, uint32_t id, struct doca_flow_shared_resource_cfg *cfg)
Configure a single shared resource.
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_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_flow_l4_meta
doca flow l4 valid type for parser meta
Definition: doca_flow.h:305
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_SHARED_RESOURCE_MIRROR
Definition: doca_flow.h:99
@ DOCA_FLOW_PIPE_CONTROL
Definition: doca_flow.h:223
@ 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_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
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
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
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
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
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 flow mirror target
Definition: doca_flow.h:929
struct doca_flow_fwd fwd
Definition: doca_flow.h:934
doca monitor action configuration
Definition: doca_flow.h:968
uint32_t shared_mirror_id
Definition: doca_flow.h:997
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
doca flow mirror resource configuration
Definition: doca_flow.h:941
struct doca_flow_mirror_target * target
Definition: doca_flow.h:944
flow resource query
Definition: doca_flow.h:1101
struct doca_flow_resource_query::@115::@117 counter
doca flow shared resource configuration
Definition: doca_flow.h:953
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