NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_ct_aging_sample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 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 <stdlib.h>
27 #include <unistd.h>
28 
29 #include <rte_ethdev.h>
30 
31 #include <doca_log.h>
32 #include <doca_flow.h>
33 #include <doca_flow_ct.h>
34 
35 #include "flow_ct_common.h"
36 #include "flow_common.h"
37 
38 #define N_BURST 32
39 
40 DOCA_LOG_REGISTER(FLOW_CT_AGING);
41 
42 /* user context struct for aging entry */
43 struct aging_user_data {
44  struct entries_status *status; /* status pointer */
45  int entry_num; /* entry number */
46  int port_id; /* port ID of the entry */
47 };
48 
49 /*
50  * Handle all aged flow in a port
51  *
52  * @port [in]: port to remove the aged flow from
53  * @ct_queue [in]: Pipe of the entries
54  * @status [in]: user context for adding entry
55  * @total_counter [in/out]: counter for all aged flows in both ports
56  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
57  */
58 static doca_error_t handle_aged_flow(struct doca_flow_port *port,
59  uint16_t ct_queue,
60  struct entries_status *status,
61  int *total_counter)
62 {
63  int num_of_aged_entries;
65 
66  do {
67  result = flow_ct_queue_reserve(port, ct_queue, status, N_BURST * 2); /* 2 rules per connection */
68  if (result != DOCA_SUCCESS) {
69  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
70  return result;
71  }
72 
73  num_of_aged_entries = doca_flow_aging_handle(port, ct_queue, DEFAULT_TIMEOUT_US, N_BURST);
74  if (num_of_aged_entries == -1 && status->nb_processed > 0) {
75  flow_ct_queue_reserve(port, ct_queue, status, 0); /* wait all pending removal done */
76  DOCA_LOG_INFO("Port aging done: %d", *total_counter);
77  return DOCA_SUCCESS;
78  } else if (num_of_aged_entries < -1) {
79  DOCA_LOG_ERR("Error in aging handle: %d", num_of_aged_entries);
80  return DOCA_ERROR_BAD_STATE;
81  } else if (num_of_aged_entries > 0) {
82  *total_counter += num_of_aged_entries;
83  DOCA_LOG_INFO("Num of aged connections: %d, total: %d", num_of_aged_entries, *total_counter);
84  }
85  } while (num_of_aged_entries > 0);
86 
87  return result;
88 }
89 
90 /*
91  * Entry processing callback
92  *
93  * @entry [in]: DOCA Flow entry pointer
94  * @pipe_queue [in]: queue identifier
95  * @status [in]: DOCA Flow entry status
96  * @op [in]: DOCA Flow entry operation
97  * @user_ctx [out]: user context
98  */
99 static void check_for_valid_entry_aging(struct doca_flow_pipe_entry *entry,
100  uint16_t pipe_queue,
101  enum doca_flow_entry_status status,
102  enum doca_flow_entry_op op,
103  void *user_ctx)
104 {
105  struct aging_user_data *user_data = (struct aging_user_data *)user_ctx;
107 
108  if (user_data == NULL)
109  return;
110 
112  user_data->status->failure = true; /* set failure to true if processing failed */
113 
114  if (op == DOCA_FLOW_ENTRY_OP_AGED) {
115  /* Callback inside doca_flow_aging_handle(), queue room reserved */
117  if (result != DOCA_SUCCESS) {
118  DOCA_LOG_ERR("Failed to remove entry %d: %s",
119  user_data->entry_num,
121  return;
122  } else
123  DOCA_LOG_INFO("CT Entry number %d aged out and removed", user_data->entry_num);
124  } else {
125  DOCA_LOG_INFO("CT Entry number %d processed", user_data->entry_num);
126  /* Callback inside doca_flow_entries_process() */
127  user_data->status->nb_processed++;
128  }
129 }
130 
131 /*
132  * Create CT pipe
133  *
134  * @port [in]: Pipe port
135  * @fwd_pipe [in]: Forward pipe pointer
136  * @pipe [out]: Created pipe pointer
137  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
138  */
139 static doca_error_t create_ct_pipe(struct doca_flow_port *port,
140  struct doca_flow_pipe *fwd_pipe,
141  struct doca_flow_pipe **pipe)
142 {
143  struct doca_flow_match match;
144  struct doca_flow_match mask;
145  struct doca_flow_pipe_cfg *cfg;
146  struct doca_flow_fwd fwd;
147  struct doca_flow_fwd fwd_miss;
149 
150  memset(&match, 0, sizeof(match));
151  memset(&mask, 0, sizeof(mask));
152  memset(&fwd, 0, sizeof(fwd));
153  memset(&fwd_miss, 0, sizeof(fwd));
154 
156  if (result != DOCA_SUCCESS) {
157  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
158  return result;
159  }
160 
161  result = set_flow_pipe_cfg(cfg, "CT_PIPE", DOCA_FLOW_PIPE_CT, false);
162  if (result != DOCA_SUCCESS) {
163  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
164  goto destroy_pipe_cfg;
165  }
166  result = doca_flow_pipe_cfg_set_match(cfg, &match, &mask);
167  if (result != DOCA_SUCCESS) {
168  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
169  goto destroy_pipe_cfg;
170  }
171 
173  fwd.next_pipe = fwd_pipe;
174 
176  fwd_miss.next_pipe = fwd_pipe;
177 
179  if (result != DOCA_SUCCESS)
180  DOCA_LOG_ERR("Failed to add CT pipe: %s", doca_error_get_descr(result));
183  return result;
184 }
185 
186 /*
187  * Create pipe to count packets based on 5 tuple match
188  *
189  * @port [in]: Pipe port
190  * @pipe [out]: Created pipe pointer
191  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
192  */
193 static doca_error_t create_count_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
194 {
195  struct doca_flow_match match;
196  struct doca_flow_monitor monitor;
197  struct doca_flow_fwd fwd;
198  struct doca_flow_pipe_cfg *pipe_cfg;
200 
201  memset(&match, 0, sizeof(match));
202  memset(&monitor, 0, sizeof(monitor));
203  memset(&fwd, 0, sizeof(fwd));
204 
205  /* 5 tuple match */
210  match.outer.ip4.src_ip = 0xffffffff;
211  match.outer.ip4.dst_ip = 0xffffffff;
212  match.outer.udp.l4_port.src_port = 0xffff;
213  match.outer.udp.l4_port.dst_port = 0xffff;
214 
216 
217  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
218  if (result != DOCA_SUCCESS) {
219  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
220  return result;
221  }
222 
223  result = set_flow_pipe_cfg(pipe_cfg, "COUNT_PIPE", DOCA_FLOW_PIPE_BASIC, false);
224  if (result != DOCA_SUCCESS) {
225  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
226  goto destroy_pipe_cfg;
227  }
228  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
229  if (result != DOCA_SUCCESS) {
230  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
231  goto destroy_pipe_cfg;
232  }
234  if (result != DOCA_SUCCESS) {
235  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
236  goto destroy_pipe_cfg;
237  }
238 
240  fwd.port_id = 0;
241 
242  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
243  if (result != DOCA_SUCCESS) {
244  DOCA_LOG_ERR("Failed to create count pipe: %s", doca_error_get_descr(result));
245  goto destroy_pipe_cfg;
246  }
247  doca_flow_pipe_cfg_destroy(pipe_cfg);
248 
249  memset(&match, 0, sizeof(match));
250  match.outer.ip4.dst_ip = BE_IPV4_ADDR(8, 8, 8, 8);
251  match.outer.ip4.src_ip = BE_IPV4_ADDR(1, 2, 3, 4);
252  match.outer.udp.l4_port.dst_port = rte_cpu_to_be_16(80);
253  match.outer.udp.l4_port.src_port = rte_cpu_to_be_16(1234);
254 
255  result = doca_flow_pipe_add_entry(0, *pipe, &match, NULL, NULL, NULL, 0, NULL, NULL);
256  if (result != DOCA_SUCCESS) {
257  DOCA_LOG_ERR("Failed to add count pipe entry: %s", doca_error_get_descr(result));
258  return result;
259  }
260 
262  if (result != DOCA_SUCCESS)
263  DOCA_LOG_ERR("Failed to process count entry: %s", doca_error_get_descr(result));
264 
265  return result;
266 
268  doca_flow_pipe_cfg_destroy(pipe_cfg);
269  return result;
270 }
271 
272 /*
273  * Add DOCA Flow CT pipe entry to be aged
274  *
275  * @port [in]: Pipe port
276  * @ct_queue [in]: Pipe of the entries
277  * @nb_aging_entries [in]: Number of entries to add
278  * @status [in]: User context for adding entry
279  * @user_data [out]: User data for each entry
280  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
281  */
282 static doca_error_t add_age_ct_entries(struct doca_flow_port *port,
283  uint16_t ct_queue,
284  const int nb_aging_entries,
285  struct entries_status *status,
286  struct aging_user_data *user_data[nb_aging_entries])
287 {
288  struct doca_flow_ct_match match_o;
289  struct doca_flow_ct_match match_r;
290  struct doca_flow_pipe_entry *entry;
291  uint32_t aging_sec, flags;
292  int i;
294 
295  memset(status, 0, sizeof(struct entries_status));
296 
297  for (i = 0; i < nb_aging_entries; i++) {
298  user_data[i] = (struct aging_user_data *)malloc(sizeof(struct aging_user_data));
299  if (user_data[i] == NULL) {
300  DOCA_LOG_ERR("Failed to allocate user data");
301  return DOCA_ERROR_NO_MEMORY;
302  }
303 
304  aging_sec = (uint32_t)((rte_rand() % 10) + 3);
305 
306  memset(&match_o, 0, sizeof(match_o));
307  memset(&match_r, 0, sizeof(match_r));
308 
309  match_o.ipv4.src_ip = BE_IPV4_ADDR(1, 2, 3, 4);
310  match_o.ipv4.dst_ip = BE_IPV4_ADDR(8, 8, 8, 8) + i;
311  match_r.ipv4.src_ip = match_o.ipv4.dst_ip;
312  match_r.ipv4.dst_ip = match_o.ipv4.src_ip;
313 
314  match_o.ipv4.l4_port.src_port = rte_cpu_to_be_16(1234);
315  match_o.ipv4.l4_port.dst_port = rte_cpu_to_be_16(80);
316  match_r.ipv4.l4_port.src_port = match_o.ipv4.l4_port.dst_port;
317  match_r.ipv4.l4_port.dst_port = match_o.ipv4.l4_port.src_port;
318 
321 
322  user_data[i]->entry_num = i;
323  user_data[i]->port_id = 0;
324  user_data[i]->status = status;
325 
327  if (i == nb_aging_entries - 1 || ((i + 1) % N_BURST) == 0) {
328  flow_ct_queue_reserve(port, ct_queue, status, N_BURST * 2); /* 2 rules per connection */
329  /* send the last entry with DOCA_FLOW_NO_WAIT flag for pushing all the entries */
331  }
332 
333  /* Allocate CT entry */
335  NULL,
337  &match_o,
338  flow_ct_hash_6tuple(&match_o, 0, false),
339  &match_r,
340  flow_ct_hash_6tuple(&match_r, 0, false),
341  &entry,
342  NULL);
343  if (result != DOCA_SUCCESS) {
344  DOCA_LOG_ERR("Failed to prepare CT entry\n");
345  return result;
346  }
347  result = doca_flow_ct_add_entry(ct_queue,
348  NULL,
349  flags,
350  &match_o,
351  &match_r,
352  NULL,
353  NULL,
354  0,
355  0,
356  aging_sec,
357  user_data[i],
358  entry);
359  if (result != DOCA_SUCCESS) {
360  DOCA_LOG_ERR("Failed to add CT aged entry: %s", doca_error_get_descr(result));
361  return result;
362  }
363  }
364 
365  flow_ct_queue_reserve(port, ct_queue, status, 0);
366 
367  return DOCA_SUCCESS;
368 }
369 
370 /*
371  * Run flow_ct_aging sample
372  *
373  * @nb_queues [in]: number of queues the sample will use
374  * @ct_dev [in]: Flow CT device
375  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
376  */
377 doca_error_t flow_ct_aging(uint16_t nb_queues, struct doca_dev *ct_dev)
378 {
379  const int nb_ports = 1, nb_aged_entries = 600;
380  int entry_idx, aged_entry_counter = 0;
381  struct flow_resources resource;
382  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
383  struct doca_flow_pipe *count_pipe, *ct_pipe = NULL, *udp_pipe;
384  struct doca_flow_port *ports[nb_ports];
385  struct doca_flow_meta o_zone_mask, o_modify_mask, r_zone_mask, r_modify_mask;
386  struct aging_user_data *user_data[nb_aged_entries];
387  struct doca_dev *dev_arr[nb_ports];
388  uint32_t actions_mem_size[nb_ports];
389  struct entries_status ct_status;
390  uint32_t ct_flags = 0, nb_arm_queues = 1, nb_ctrl_queues = 1, nb_user_actions = 0,
391  nb_ipv6_sessions = 0; /* On BF2 should always be 0 */
392  uint16_t ct_queue = nb_queues;
394 
395  memset(&ct_status, 0, sizeof(ct_status));
396  memset(&resource, 0, sizeof(resource));
397  memset(user_data, 0, sizeof(struct aging_user_data *) * nb_aged_entries);
398 
399  resource.nr_counters = 1;
400 
401  result = init_doca_flow_cb(nb_queues,
402  "switch,hws",
403  &resource,
404  nr_shared_resources,
406  NULL,
407  NULL);
408  if (result != DOCA_SUCCESS) {
409  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
410  return result;
411  }
412 
413  /* Dont use zone masking */
414  memset(&o_zone_mask, 0, sizeof(o_zone_mask));
415  memset(&o_modify_mask, 0, sizeof(o_modify_mask));
416  memset(&r_zone_mask, 0, sizeof(r_zone_mask));
417  memset(&r_modify_mask, 0, sizeof(r_modify_mask));
418 
419  result = init_doca_flow_ct(ct_flags,
420  nb_arm_queues,
421  nb_ctrl_queues,
422  nb_user_actions,
423  NULL,
424  nb_aged_entries,
425  nb_ipv6_sessions,
426  0,
427  false,
428  &o_zone_mask,
429  &o_modify_mask,
430  false,
431  &r_zone_mask,
432  &r_modify_mask);
433  if (result != DOCA_SUCCESS) {
435  return result;
436  }
437 
438  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
439  dev_arr[0] = ct_dev;
440  ARRAY_INIT(actions_mem_size, ACTIONS_MEM_SIZE(nb_queues, nb_aged_entries));
442  if (result != DOCA_SUCCESS) {
443  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
446  return result;
447  }
448 
449  result = create_count_pipe(ports[0], &count_pipe);
450  if (result != DOCA_SUCCESS)
451  goto cleanup;
452 
453  result = create_ct_pipe(ports[0], count_pipe, &ct_pipe);
454  if (result != DOCA_SUCCESS)
455  goto cleanup;
456 
457  result = add_age_ct_entries(ports[0], ct_queue, nb_aged_entries, &ct_status, user_data);
458  if (result != DOCA_SUCCESS)
459  goto cleanup;
460 
461  result = create_ct_root_pipe(ports[0], true, false, DOCA_FLOW_L4_META_UDP, ct_pipe, NULL, &udp_pipe);
462  if (result != DOCA_SUCCESS)
463  goto entries_cleanup;
464 
465  flow_ct_queue_reserve(ports[0], ct_queue, &ct_status, 0);
466 
467  /* handle aging in loop until all entries aged out */
468  memset(&ct_status, 0, sizeof(ct_status));
469  while (aged_entry_counter < nb_aged_entries) {
470  sleep(1);
471  result = handle_aged_flow(ports[0], ct_queue, &ct_status, &aged_entry_counter);
472  if (result != DOCA_SUCCESS)
473  break;
474  }
475 
476 entries_cleanup:
477  for (entry_idx = 0; entry_idx < nb_aged_entries; entry_idx++) {
478  if (user_data[entry_idx] != NULL)
479  free(user_data[entry_idx]);
480  }
481 
482 cleanup:
483  cleanup_procedure(ct_pipe, nb_ports, ports);
484  return result;
485 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
static void cleanup(struct cache_invalidate_sample_state *state)
DOCA_LOG_REGISTER(FLOW_CT_AGING)
#define N_BURST
static doca_error_t create_count_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
static void check_for_valid_entry_aging(struct doca_flow_pipe_entry *entry, uint16_t pipe_queue, enum doca_flow_entry_status status, enum doca_flow_entry_op op, void *user_ctx)
static doca_error_t create_ct_pipe(struct doca_flow_port *port, struct doca_flow_pipe *fwd_pipe, struct doca_flow_pipe **pipe)
doca_error_t flow_ct_aging(uint16_t nb_queues, struct doca_dev *ct_dev)
static doca_error_t add_age_ct_entries(struct doca_flow_port *port, uint16_t ct_queue, const int nb_aging_entries, struct entries_status *status, struct aging_user_data *user_data[nb_aging_entries])
static doca_error_t handle_aged_flow(struct doca_flow_port *port, uint16_t ct_queue, struct entries_status *status, int *total_counter)
uint32_t flow_ct_hash_6tuple(const struct doca_flow_ct_match *match, doca_be32_t zone_field, bool is_ipv6)
doca_error_t init_doca_flow_ct(uint32_t flags, uint32_t nb_arm_queues, uint32_t nb_ctrl_queues, uint32_t nb_user_actions, doca_flow_ct_entry_finalize_cb entry_finalize_cb, uint32_t nb_ipv4_sessions, uint32_t nb_ipv6_sessions, uint32_t dup_filter_sz, bool o_match_inner, struct doca_flow_meta *o_zone_mask, struct doca_flow_meta *o_modify_mask, bool r_match_inner, struct doca_flow_meta *r_zone_mask, struct doca_flow_meta *r_modify_mask)
doca_error_t create_ct_root_pipe(struct doca_flow_port *port, bool is_ipv4, bool is_ipv6, enum doca_flow_l4_meta l4_type, struct doca_flow_pipe *fwd_pipe, struct entries_status *status, struct doca_flow_pipe **pipe)
doca_error_t flow_ct_queue_reserve(struct doca_flow_port *port, uint16_t ct_queue, struct entries_status *status, uint32_t room)
void cleanup_procedure(struct doca_flow_pipe *ct_pipe, int nb_ports, struct doca_flow_port *ports[])
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
#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]
#define DEFAULT_TIMEOUT_US
Definition: flow_skeleton.c:36
static uint8_t entry_idx
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_ERROR_NO_MEMORY
Definition: doca_error.h:45
DOCA_EXPERIMENTAL doca_error_t doca_flow_ct_add_entry(uint16_t queue, struct doca_flow_pipe *pipe, uint32_t flags, struct doca_flow_ct_match *match_origin, struct doca_flow_ct_match *match_reply, const struct doca_flow_ct_actions *actions_origin, const struct doca_flow_ct_actions *actions_reply, uint32_t fwd_handle_origin, uint32_t fwd_handle_reply, uint32_t timeout_s, void *usr_ctx, struct doca_flow_pipe_entry *entry)
Add new entry to doca flow CT pipe.
DOCA_EXPERIMENTAL void doca_flow_ct_destroy(void)
Destroy the doca flow ct.
DOCA_EXPERIMENTAL doca_error_t doca_flow_ct_rm_entry(uint16_t queue, struct doca_flow_pipe *pipe, uint32_t flags, struct doca_flow_pipe_entry *entry)
remove CT entry.
DOCA_EXPERIMENTAL doca_error_t doca_flow_ct_entry_prepare(uint16_t queue, struct doca_flow_pipe *pipe, uint32_t flags, struct doca_flow_ct_match *match_origin, uint32_t hash_origin, struct doca_flow_ct_match *match_reply, uint32_t hash_reply, struct doca_flow_pipe_entry **entry, bool *conn_found)
Lookup recent CT entry and create on miss.
@ DOCA_FLOW_CT_ENTRY_FLAGS_DIR_ORIGIN
Definition: doca_flow_ct.h:667
@ DOCA_FLOW_CT_ENTRY_FLAGS_NO_WAIT
Definition: doca_flow_ct.h:665
@ DOCA_FLOW_CT_ENTRY_FLAGS_DIR_REPLY
Definition: doca_flow_ct.h:669
@ DOCA_FLOW_CT_ENTRY_FLAGS_ALLOC_ON_MISS
Definition: doca_flow_ct.h:683
#define DOCA_FLOW_PROTO_UDP
Definition: doca_flow_net.h:42
@ 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_flow_entry_op
doca flow entry operation
Definition: doca_flow.h:146
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_STABLE int doca_flow_aging_handle(struct doca_flow_port *port, uint16_t queue, uint64_t quota, uint64_t max_entries)
Handle aging of entries.
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_flow_entry_status
doca flow entry status
Definition: doca_flow.h:160
DOCA_STABLE void doca_flow_destroy(void)
Destroy the doca flow.
@ DOCA_FLOW_ENTRY_OP_AGED
Definition: doca_flow.h:153
@ DOCA_FLOW_PIPE_CT
Definition: doca_flow.h:227
@ 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_ENTRY_STATUS_SUCCESS
Definition: doca_flow.h:163
@ DOCA_FLOW_L4_META_UDP
Definition: doca_flow.h:310
#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
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
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
doca_error_t init_doca_flow_cb(int nb_queues, const char *mode, struct flow_resources *resource, uint32_t nr_shared_resources[], doca_flow_entry_process_cb cb, doca_flow_pipe_process_cb pipe_process_cb, struct doca_flow_definitions *defs)
Definition: flow_common.c:79
#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
struct entries_status * status
struct doca_flow_header_l4_port l4_port
Definition: doca_flow_ct.h:623
doca_be32_t src_ip
Definition: doca_flow_ct.h:625
doca_be32_t dst_ip
Definition: doca_flow_ct.h:627
doca flow CT match pattern
Definition: doca_flow_ct.h:654
struct doca_flow_ct_match4 ipv4
Definition: doca_flow_ct.h:656
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
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_udp udp
Definition: doca_flow.h:459
enum doca_flow_l3_type l3_type
Definition: doca_flow.h:446
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 flow meta data
Definition: doca_flow.h:358
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
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