NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_pipe_resize_sample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #include <string.h>
27 #include <unistd.h>
28 
29 #include <doca_log.h>
30 #include <doca_flow.h>
31 
32 #include "flow_common.h"
33 #include "flow_switch_common.h"
34 
35 DOCA_LOG_REGISTER(FLOW_PIPE_RESIZE);
36 
37 #define PIPE_SIZE 10
38 #define PERCENTAGE 80
39 #define MAX_ENTRIES 80
40 static bool resize_cb_received;
41 static bool congestion_notified;
42 
44 
45 static struct doca_flow_port *ports[3];
46 static struct doca_flow_pipe_entry *entry[MAX_ENTRIES];
47 struct entry_ctx {
48  struct entries_status entry_status; /* Entry status */
49  uint32_t index; /* Entry index */
50 };
51 static struct entry_ctx entry_ctx[MAX_ENTRIES];
52 
53 /*
54  * pipe number of entries changed callback
55  *
56  * @pipe_user_ctx [in]: DOCA Flow pipe user context pointer
57  * @nr_entries [in]: DOCA Flow new number of entries
58  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
59  */
60 static doca_error_t pipe_resize_sample_nr_entries_changed_cb(void *pipe_user_ctx, uint32_t nr_entries)
61 {
62  DOCA_LOG_INFO("Pipe user context %p: entries increased to %u", pipe_user_ctx, nr_entries);
63 
64  return DOCA_SUCCESS;
65 }
66 
67 /*
68  * pipe entry relocated callback
69  *
70  * @pipe_user_ctx [in]: DOCA Flow pipe user context pointer
71  * @pipe_queue [in]: DOCA Flow pipe queue id
72  * @entry_user_ctx [in]: DOCA Flow entry user context pointer
73  * @new_entry_user_ctx [out]: DOCA Flow updated entry user context pointer
74  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
75  */
77  uint16_t pipe_queue,
78  void *entry_user_ctx,
79  void **new_entry_user_ctx)
80 {
81  struct entry_ctx *entry_ctx = (struct entry_ctx *)entry_user_ctx;
82 
83  DOCA_LOG_INFO("Pipe %p entry context %p (%u) relocated on queue %u",
84  pipe_user_ctx,
85  entry_ctx,
87  pipe_queue);
88 
89  *new_entry_user_ctx = entry_ctx;
90 
91  return DOCA_SUCCESS;
92 }
93 
96 
97 /*
98  * Create DOCA Flow control pipe
99  *
100  * @port [in]: port of the pipe
101  * @is_basic_pipe [in]: flag to indicate if to resize a basic pipe
102  * @pipe [out]: created pipe pointer
103  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
104  */
105 static doca_error_t create_resizable_pipe(struct doca_flow_port *port,
106  bool is_basic_pipe,
107  uint16_t nb_queues,
108  struct doca_flow_pipe **pipe)
109 {
110  struct doca_flow_pipe_cfg *pipe_cfg;
112  struct doca_flow_match match;
113  struct doca_flow_monitor monitor;
114  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
115  struct doca_flow_fwd fwd;
116  uint16_t port_id = 0;
117  uint16_t queue_id;
118 
119  if (is_basic_pipe) {
120  memset(&match, 0, sizeof(match));
121  memset(&monitor, 0, sizeof(monitor));
122  memset(&actions, 0, sizeof(actions));
123  memset(&fwd, 0, sizeof(fwd));
124 
125  /* 5 tuple match */
128  match.outer.ip4.src_ip = 0xffffffff;
129  match.outer.ip4.dst_ip = 0xffffffff;
130  match.outer.tcp.l4_port.dst_port = 0xffff;
131  match.outer.tcp.l4_port.src_port = 0xffff;
132 
133  actions_arr[0] = &actions;
134  }
135 
136  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
137  if (result != DOCA_SUCCESS) {
138  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
139  return result;
140  }
141 
142  if (is_basic_pipe)
143  result = set_flow_pipe_cfg(pipe_cfg, "RESIZABLE_BASIC_PIPE", DOCA_FLOW_PIPE_BASIC, true);
144  else
145  result = set_flow_pipe_cfg(pipe_cfg, "RESIZABLE_CTRL_PIPE", DOCA_FLOW_PIPE_CONTROL, true);
146 
147  if (result != DOCA_SUCCESS) {
148  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
149  goto destroy_pipe_cfg;
150  }
152  if (result != DOCA_SUCCESS) {
153  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg nr_entries: %s", doca_error_get_descr(result));
154  goto destroy_pipe_cfg;
155  }
157  if (result != DOCA_SUCCESS) {
158  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg congestion_level_threshold: %s",
160  goto destroy_pipe_cfg;
161  }
163  if (result != DOCA_SUCCESS) {
164  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg is_resizable: %s", doca_error_get_descr(result));
165  goto destroy_pipe_cfg;
166  }
168  if (result != DOCA_SUCCESS) {
169  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg user_ctx: %s", doca_error_get_descr(result));
170  goto destroy_pipe_cfg;
171  }
172  for (queue_id = 1; queue_id < nb_queues; queue_id += 2) {
173  /* Exclude odd queue numbers */
175  if (result != DOCA_SUCCESS) {
176  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg queue (%u) exclusion: %s",
177  queue_id,
179  goto destroy_pipe_cfg;
180  }
181  }
182 
183  if (is_basic_pipe) {
184  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
185  if (result != DOCA_SUCCESS) {
186  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
187  goto destroy_pipe_cfg;
188  }
189  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
190  if (result != DOCA_SUCCESS) {
191  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
192  goto destroy_pipe_cfg;
193  }
194 
196  fwd.port_id = port_id ^ 1;
197 
198  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL /* fwd_miss */, pipe);
199  } else
200  result = doca_flow_pipe_create(pipe_cfg, NULL /* fwd */, NULL /* fwd_miss */, pipe);
201 
203  doca_flow_pipe_cfg_destroy(pipe_cfg);
204  return result;
205 }
206 
207 /*
208  * Remove DOCA Flow pipe entry from the resizable control pipe.
209  *
210  * @pipe [in]: entry's pipe
211  * @port_id [in]: port id of incoming packets
212  * @status [in]: user context for adding entry
213  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
214  */
216 {
217  int i;
218  int rc;
219 
220  for (i = 0; i < MAX_ENTRIES; i++) {
222  if (rc)
223  DOCA_LOG_WARN("Failed removing entry %d %p", i, entry[i]);
224  }
225 }
226 
227 /*
228  * Add DOCA Flow pipe entry to the resizable control pipe that matches
229  * multiple ipv4 traffic and forward to peer port.
230  *
231  * @pipe [in]: entry's pipe
232  * @port_id [in]: port id of incoming packets
233  * @nb_queues [in]: number of queues the sample will use
234  * @is_basic_pipe [in]: flag to indicate if to add entries to basic pipe
235  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
236  */
237 static doca_error_t add_resizable_pipe_entries(struct doca_flow_pipe *pipe,
238  int port_id,
239  uint16_t nb_queues,
240  bool is_basic_pipe)
241 {
242  int i;
243  struct doca_flow_fwd fwd;
244  int rc;
245  uint16_t queue_id;
246 
247  struct doca_flow_match match;
248  struct doca_flow_actions actions;
250 
251  /* example 5-tuple to forward */
252  doca_be32_t dst_ip_addr = BE_IPV4_ADDR(8, 8, 8, 8);
253  doca_be32_t src_ip_addr = BE_IPV4_ADDR(1, 2, 3, 4);
254  doca_be16_t dst_port = rte_cpu_to_be_16(80);
255  doca_be16_t src_port = rte_cpu_to_be_16(1234);
256 
257  memset(&match, 0, sizeof(match));
258  memset(&actions, 0, sizeof(actions));
259  memset(&fwd, 0, sizeof(fwd));
260 
261  /* 5 tuple match */
262  match.outer.ip4.dst_ip = dst_ip_addr;
263  match.outer.ip4.src_ip = src_ip_addr;
268 
269  /* forwarding traffic to other port */
271  fwd.port_id = port_id ^ 1;
272 
273  memset(entry_ctx, 0, sizeof(entry_ctx));
274  for (i = 0; i < MAX_ENTRIES; i++)
275  entry_ctx[i].index = i;
276 
277  for (i = 0; i < MAX_ENTRIES; i++) {
278  match.outer.ip4.dst_ip++;
279 
280  if (is_basic_pipe)
282  pipe,
283  &match,
284  &actions,
285  NULL /* monitor */,
286  NULL /* fwd */,
287  0,
288  &entry_ctx[i],
289  &entry[i]);
290  else
291  result = doca_flow_pipe_control_add_entry(0 /* pipe_queue */,
292  1 /*priority */,
293  pipe,
294  &match,
295  NULL /* match_mask */,
296  NULL,
297  &actions,
298  NULL /* actions_mask */,
299  NULL /* action_descs */,
300  NULL /* monitor */,
301  &fwd,
302  &entry_ctx[i],
303  &entry[i]);
304  if (result != DOCA_SUCCESS)
305  return result;
306 
307  if (congestion_notified == true) {
308  DOCA_LOG_INFO("Calling resize on pipe %p", pipe);
309  rc = doca_flow_pipe_resize(pipe,
310  50 /* New congestion in percentage */,
313 
314  if (rc == 0)
315  DOCA_LOG_INFO("Pipe %p successfully called resize operation", pipe);
316  else
317  DOCA_LOG_WARN("Pipe %p call to resize failed. rc=%d", pipe, rc);
318 
319  do {
320  for (queue_id = 0; queue_id < nb_queues; queue_id++) {
321  /* Skip processing excluded queue #1.
322  * The RESIZED callback can't be
323  * invoked on excluded queues, but
324  * there is no prevention from calling
325  * entries_process on excluded queues
326  * in favour of other pipes (where
327  * those queues are not excluded). */
328  if (queue_id == 1)
329  continue;
331  if (result != DOCA_SUCCESS) {
332  DOCA_LOG_ERR("Failed to process entries on queue id %u: %s",
333  queue_id,
335  goto failure;
336  }
337  }
338  } while (resize_cb_received == false);
339  resize_cb_received = false;
340  congestion_notified = false;
341  }
342  }
343 
344  if (is_basic_pipe) {
345  /*
346  * Complete the last add entries calls by calling entries process.
347  * It is only required for basic pipe.
348  */
349 
350  for (i = 0; i < MAX_ENTRIES; i++) {
351  if (entry_ctx[i].entry_status.nb_processed != 0)
352  continue;
353 
354  DOCA_LOG_INFO("%d entries left to be processed", MAX_ENTRIES - i);
356  if (result != DOCA_SUCCESS) {
357  DOCA_LOG_ERR("Failed to process entries");
358  goto failure;
359  }
360  break;
361  }
362 
363  for (; i < MAX_ENTRIES; i++) {
364  if (entry_ctx[i].entry_status.nb_processed != 1 || entry_ctx[i].entry_status.failure) {
365  DOCA_LOG_ERR("Entry %d completed with error", i);
367  goto failure;
368  }
369  }
370  }
371 
372  return DOCA_SUCCESS;
373 
374 failure:
377  return result;
378 }
379 
380 /*
381  * pipe process callback
382  *
383  * @pipe [in]: DOCA Flow pipe pointer
384  * @status [in]: DOCA Flow pipe status
385  * @op [in]: DOCA Flow pipe operation
386  * @user_ctx [out]: user context
387  */
388 static void pipe_process_cb(struct doca_flow_pipe *pipe,
389  enum doca_flow_pipe_status status,
390  enum doca_flow_pipe_op op,
391  void *user_ctx)
392 {
393  const char *op_str;
394  bool is_err = false;
395 
396  (void)user_ctx;
397  if (status != DOCA_FLOW_PIPE_STATUS_SUCCESS)
398  is_err = true;
399 
400  switch (op) {
402  op_str = "CONGESTION_REACHED";
403  congestion_notified = true;
404  break;
406  op_str = "RESIZED";
407  resize_cb_received = true;
408  break;
410  op_str = "DESTROYED";
411  break;
412  default:
413  op_str = "UNKNOWN";
414  break;
415  }
416 
417  if (is_err)
418  DOCA_LOG_INFO("Pipe %p received a %s operation callback. Errors encountered", pipe, op_str);
419  else
420  DOCA_LOG_INFO("Pipe %p successfully received a %s operation callback", pipe, op_str);
421 }
422 
423 /*
424  * Run flow_pipe_resize sample
425  *
426  * @nb_queues [in]: number of queues the sample will use
427  * @ctx [in]: flow switch context the sample will use
428  * @is_basic_pipe [in]: flag to indicate if to resize a basic pipe
429  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
430  */
431 doca_error_t flow_pipe_resize(uint16_t nb_queues, struct flow_switch_ctx *ctx, bool is_basic_pipe)
432 {
433  const int nb_ports = 3;
434  struct doca_dev *dev_arr[nb_ports];
435  uint32_t actions_mem_size[nb_ports];
436  struct flow_resources resource = {0};
437  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
438  struct doca_flow_pipe *resizable_pipe;
440  int port_id;
441 
442  /* DOCA flow mode: switch, hardware steering, control pipe dynamic size */
443  result = init_doca_flow_cb(nb_queues,
444  "switch,hws,cpds",
445  &resource,
446  nr_shared_resources,
449  NULL);
450  if (result != DOCA_SUCCESS) {
451  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
452  return result;
453  }
454 
455  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
456  dev_arr[0] = ctx->doca_dev[0];
459  if (result != DOCA_SUCCESS) {
460  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
462  return result;
463  }
464 
465  port_id = 0;
466  result = create_resizable_pipe(ports[port_id], is_basic_pipe, nb_queues, &resizable_pipe);
467  if (result != DOCA_SUCCESS) {
468  DOCA_LOG_ERR("Failed to create resizable pipe: %s", doca_error_get_descr(result));
471  return result;
472  }
473 
474  resize_cb_received = false;
475  congestion_notified = false;
476 
477  result = add_resizable_pipe_entries(resizable_pipe, port_id, nb_queues, is_basic_pipe);
478  if (result != DOCA_SUCCESS) {
479  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
482  return result;
483  }
484 
485  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
486  sleep(5);
487 
489 
492  return result;
493 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
static void check_for_valid_entry(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)
Definition: flow_common.c:50
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 int congestion_reached_flag
static doca_error_t create_resizable_pipe(struct doca_flow_port *port, bool is_basic_pipe, uint16_t nb_queues, struct doca_flow_pipe **pipe)
static struct entry_ctx entry_ctx[MAX_ENTRIES]
static bool congestion_notified
static void pipe_process_cb(struct doca_flow_pipe *pipe, enum doca_flow_pipe_status status, enum doca_flow_pipe_op op, void *user_ctx)
static doca_error_t pipe_resize_sample_entry_relocate_cb(void *pipe_user_ctx, uint16_t pipe_queue, void *entry_user_ctx, void **new_entry_user_ctx)
static doca_flow_pipe_resize_nr_entries_changed_cb nr_entries_changed_cb
static doca_flow_pipe_resize_entry_relocate_cb entry_relocation_cb
static struct doca_flow_port * ports[3]
#define PERCENTAGE
doca_error_t flow_pipe_resize(uint16_t nb_queues, struct flow_switch_ctx *ctx, bool is_basic_pipe)
static doca_error_t add_resizable_pipe_entries(struct doca_flow_pipe *pipe, int port_id, uint16_t nb_queues, bool is_basic_pipe)
#define PIPE_SIZE
DOCA_LOG_REGISTER(FLOW_PIPE_RESIZE)
#define MAX_ENTRIES
static doca_error_t pipe_resize_sample_nr_entries_changed_cb(void *pipe_user_ctx, uint32_t nr_entries)
static bool resize_cb_received
static void remove_resizable_pipe_entries(void)
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
#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_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_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_error_t(* doca_flow_pipe_resize_entry_relocate_cb)(void *pipe_user_ctx, uint16_t pipe_queue, void *entry_user_ctx, void **new_entry_user_ctx)
doca flow pipe entry relocation callback.
Definition: doca_flow.h:1456
doca_flow_pipe_op
doca flow pipe operation
Definition: doca_flow.h:124
DOCA_STABLE doca_error_t doca_flow_pipe_resize(struct doca_flow_pipe *pipe, uint8_t new_congestion_level, doca_flow_pipe_resize_nr_entries_changed_cb nr_entries_changed_cb, doca_flow_pipe_resize_entry_relocate_cb entry_relocation_cb)
Resize 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_STABLE doca_error_t doca_flow_pipe_cfg_set_user_ctx(struct doca_flow_pipe_cfg *cfg, void *user_ctx)
Set pipe's user context.
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_set_congestion_level_threshold(struct doca_flow_pipe_cfg *cfg, uint8_t congestion_level_threshold)
Set pipe's congestion level threshold.
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_set_is_resizable(struct doca_flow_pipe_cfg *cfg, bool is_resizable)
Set if the pipe supports the resize operation.
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_flow_pipe_status
doca flow pipe status
Definition: doca_flow.h:136
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 doca_error_t doca_flow_pipe_remove_entry(uint16_t pipe_queue, uint32_t flags, struct doca_flow_pipe_entry *entry)
Free one pipe entry.
doca_error_t(* doca_flow_pipe_resize_nr_entries_changed_cb)(void *pipe_user_ctx, uint32_t nr_entries)
doca flow pipe resize number of entries changed callback.
Definition: doca_flow.h:1435
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_excluded_queue(struct doca_flow_pipe_cfg *cfg, uint16_t pipe_queue)
Set pipe_queue as excluded in the pipe.
@ DOCA_FLOW_PIPE_OP_DESTROYED
Definition: doca_flow.h:129
@ DOCA_FLOW_PIPE_OP_CONGESTION_REACHED
Definition: doca_flow.h:125
@ DOCA_FLOW_PIPE_OP_RESIZED
Definition: doca_flow.h:127
@ DOCA_FLOW_PIPE_CONTROL
Definition: doca_flow.h:223
@ DOCA_FLOW_PIPE_BASIC
Definition: doca_flow.h:221
@ DOCA_FLOW_NO_WAIT
Definition: doca_flow.h:115
@ DOCA_FLOW_PIPE_STATUS_SUCCESS
Definition: doca_flow.h:137
@ DOCA_FLOW_FWD_PORT
Definition: doca_flow.h:744
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
Definition: doca_log.h:476
#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 queue_id
Definition: ip_frag_dp.c:1
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
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 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 * 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
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_header_format outer
Definition: doca_flow.h:498
doca monitor action configuration
Definition: doca_flow.h:968
user context struct that will be used in entries process callback
Definition: flow_common.h:78
struct entries_status entry_status
static int nb_ports
Definition: switch_core.c:44
static uint32_t actions_mem_size[FLOW_SWITCH_PORTS_MAX]
Definition: switch_core.c:43
struct upf_accel_ctx * ctx