NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_drop_sample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2025 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 
36 typedef enum {
41 
42 DOCA_LOG_REGISTER(FLOW_DROP);
43 
44 /*
45  * Create DOCA Flow pipe that forwards all the traffic to the other port
46  *
47  * @port [in]: port of the pipe
48  * @port_id [in]: port ID of the pipe
49  * @pipe [out]: created pipe pointer
50  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
51  */
52 static doca_error_t create_hairpin_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
53 {
54  struct doca_flow_match match;
56  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
57  struct doca_flow_fwd fwd;
58  struct doca_flow_pipe_cfg *pipe_cfg;
60 
61  memset(&match, 0, sizeof(match));
62  memset(&monitor, 0, sizeof(monitor));
63  memset(&actions, 0, sizeof(actions));
64  memset(&fwd, 0, sizeof(fwd));
65 
67 
68  actions_arr[0] = &actions;
69 
70  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
71  if (result != DOCA_SUCCESS) {
72  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
73  return result;
74  }
75 
76  result = set_flow_pipe_cfg(pipe_cfg, "HAIRPIN_PIPE", DOCA_FLOW_PIPE_BASIC, false);
77  if (result != DOCA_SUCCESS) {
78  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
79  goto destroy_pipe_cfg;
80  }
81  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
82  if (result != DOCA_SUCCESS) {
83  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
84  goto destroy_pipe_cfg;
85  }
86  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
87  if (result != DOCA_SUCCESS) {
88  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
89  goto destroy_pipe_cfg;
90  }
92  if (result != DOCA_SUCCESS) {
93  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
94  goto destroy_pipe_cfg;
95  }
96 
97  /* forwarding traffic to other port */
99  fwd.port_id = port_id ^ 1;
100 
101  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
103  doca_flow_pipe_cfg_destroy(pipe_cfg);
104  return result;
105 }
106 
107 /*
108  * Create DOCA Flow pipe with match on header types to fwd to drop pipe with it's own match logic.
109  * On miss, drop the packet.
110  *
111  * @port [in]: port of the pipe
112  * @drop_pipe [in]: pipe to forward the traffic that didn't hit the pipe rules
113  * @pipe [out]: created pipe pointer
114  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
115  */
116 static doca_error_t create_classifier_pipe(struct doca_flow_port *port,
117  struct doca_flow_pipe *drop_pipe,
118  struct doca_flow_pipe **pipe)
119 {
120  struct doca_flow_match match;
121  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
122  struct doca_flow_monitor monitor;
123  struct doca_flow_fwd fwd;
124  struct doca_flow_fwd fwd_miss;
125  struct doca_flow_pipe_cfg *pipe_cfg;
127 
128  memset(&match, 0, sizeof(match));
129  memset(&actions, 0, sizeof(actions));
130  memset(&monitor, 0, sizeof(monitor));
131  memset(&fwd, 0, sizeof(fwd));
132  memset(&fwd_miss, 0, sizeof(fwd_miss));
133 
134  /* Match on header types */
137 
139 
140  actions_arr[0] = &actions;
141 
142  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
143  if (result != DOCA_SUCCESS) {
144  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
145  return result;
146  }
147 
148  result = set_flow_pipe_cfg(pipe_cfg, "CLASSIFIER_PIPE", DOCA_FLOW_PIPE_BASIC, true);
149  if (result != DOCA_SUCCESS) {
150  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
151  goto destroy_pipe_cfg;
152  }
153  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
154  if (result != DOCA_SUCCESS) {
155  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
156  goto destroy_pipe_cfg;
157  }
158  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
159  if (result != DOCA_SUCCESS) {
160  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
161  goto destroy_pipe_cfg;
162  }
164  if (result != DOCA_SUCCESS) {
165  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
166  goto destroy_pipe_cfg;
167  }
168 
170  fwd.next_pipe = drop_pipe;
171 
173 
174  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
176  doca_flow_pipe_cfg_destroy(pipe_cfg);
177  return result;
178 }
179 
180 /*
181  * Add DOCA Flow pipe entry to the classifier or hairpin pipe
182  *
183  * @pipe [in]: pipe of the entry
184  * @status [in]: user context for adding entry
185  * @entry [out]: created entry pointer
186  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
187  */
188 static doca_error_t add_pipe_entry(struct doca_flow_pipe *pipe,
189  struct entries_status *status,
190  struct doca_flow_pipe_entry **entry)
191 {
192  struct doca_flow_match match;
193 
194  /*
195  * All fields are not changeable, thus we need to add only 1 entry, all values will be
196  * inherited from the pipe creation
197  */
198  memset(&match, 0, sizeof(match));
199 
200  return doca_flow_pipe_add_entry(0, pipe, &match, NULL, NULL, NULL, 0, status, entry);
201 }
202 
203 /*
204  * Create DOCA Flow pipe with match and fwd drop action. miss fwd to hairpin pipe
205  *
206  * @port [in]: port of the pipe
207  * @hairpin_pipe [in]: pipe to forward the traffic that didn't hit the pipe rules
208  * @pipe [out]: created pipe pointer
209  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
210  */
211 static doca_error_t create_drop_pipe(struct doca_flow_port *port,
212  struct doca_flow_pipe *hairpin_pipe,
213  struct doca_flow_pipe **pipe)
214 {
215  struct doca_flow_match match;
216  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
217  struct doca_flow_monitor monitor;
218  struct doca_flow_fwd fwd;
219  struct doca_flow_fwd fwd_miss;
220  struct doca_flow_pipe_cfg *pipe_cfg;
222  const char *label = "Matches IPv4 TCP packets with changeable source and destination IP addresses and ports";
223 
224  memset(&match, 0, sizeof(match));
225  memset(&actions, 0, sizeof(actions));
226  memset(&monitor, 0, sizeof(monitor));
227  memset(&fwd, 0, sizeof(fwd));
228  memset(&fwd_miss, 0, sizeof(fwd_miss));
229  /*
230  * DOCA_FLOW_L3_TYPE_IP4 is a selector of underlying struct, pipe won't match on L3 header
231  * type being IP4. This part is done on previous pipe, a classifier.
232  */
234  match.outer.ip4.src_ip = 0xffffffff;
235  match.outer.ip4.dst_ip = 0xffffffff;
236  /*
237  * DOCA_FLOW_L4_TYPE_EXT_TCP is a selector of underlying struct, pipe won't match on
238  * L4 header type being TCP. This part is done on previous pipe, a classifier.
239  */
241  match.outer.tcp.l4_port.src_port = 0xffff;
242  match.outer.tcp.l4_port.dst_port = 0xffff;
243 
245 
246  actions_arr[0] = &actions;
247 
248  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
249  if (result != DOCA_SUCCESS) {
250  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
251  return result;
252  }
253 
254  result = set_flow_pipe_cfg(pipe_cfg, "DROP_PIPE", DOCA_FLOW_PIPE_BASIC, false);
255  if (result != DOCA_SUCCESS) {
256  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
257  goto destroy_pipe_cfg;
258  }
259  result = doca_flow_pipe_cfg_set_label(pipe_cfg, label);
260  if (result != DOCA_SUCCESS) {
261  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg label: %s", doca_error_get_descr(result));
262  goto destroy_pipe_cfg;
263  }
264  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
265  if (result != DOCA_SUCCESS) {
266  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
267  goto destroy_pipe_cfg;
268  }
269  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
270  if (result != DOCA_SUCCESS) {
271  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
272  goto destroy_pipe_cfg;
273  }
275  if (result != DOCA_SUCCESS) {
276  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
277  goto destroy_pipe_cfg;
278  }
279 
281 
283  fwd_miss.next_pipe = hairpin_pipe;
284 
285  result = doca_flow_pipe_create(pipe_cfg, &fwd, &fwd_miss, pipe);
287  doca_flow_pipe_cfg_destroy(pipe_cfg);
288  return result;
289 }
290 
291 /*
292  * Add DOCA Flow pipe entry to the drop pipe with example 5 tuple to match
293  *
294  * @pipe [in]: pipe of the entry
295  * @status [in]: user context for adding entry
296  * @entry [out]: created entry pointer
297  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
298  */
299 static doca_error_t add_drop_pipe_entry(struct doca_flow_pipe *pipe,
300  struct entries_status *status,
301  struct doca_flow_pipe_entry **entry)
302 {
303  struct doca_flow_match match;
304  struct doca_flow_actions actions;
306 
307  /* example 5-tuple to drop explicitly */
308  doca_be32_t dst_ip_addr = BE_IPV4_ADDR(8, 8, 8, 8);
309  doca_be32_t src_ip_addr = BE_IPV4_ADDR(1, 2, 3, 4);
310  doca_be16_t dst_port = rte_cpu_to_be_16(80);
311  doca_be16_t src_port = rte_cpu_to_be_16(1234);
312 
313  memset(&match, 0, sizeof(match));
314  memset(&actions, 0, sizeof(actions));
315 
316  match.outer.ip4.dst_ip = dst_ip_addr;
317  match.outer.ip4.src_ip = src_ip_addr;
320 
321  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, NULL, NULL, 0, status, entry);
322  if (result != DOCA_SUCCESS)
323  return result;
324 
325  return DOCA_SUCCESS;
326 }
327 
328 /*
329  * Run flow_drop sample
330  *
331  * @nb_queues [in]: number of queues the sample will use
332  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
333  */
334 doca_error_t flow_drop(int nb_queues)
335 {
336  const int nb_ports = 2;
337  struct flow_resources resource = {0};
338  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
339  struct doca_flow_port *ports[nb_ports];
340  uint32_t actions_mem_size[nb_ports];
341  struct doca_dev *dev_arr[nb_ports];
342  struct doca_flow_pipe *classifier_pipe;
343  struct doca_flow_pipe *drop_pipe;
344  struct doca_flow_pipe *hairpin_pipe;
345  /*
346  * Total numbe of entries - 3.
347  * - 1 entry for classifier pipe
348  * - 1 entry for drop pipe
349  * - 1 entry for hairpin pipe
350  */
351  const int nb_entries = 3;
352  struct doca_flow_pipe_entry *entry[nb_ports][nb_entries];
353  struct doca_flow_resource_query query_stats;
354  struct entries_status status;
356  int port_id;
357  FILE *fd;
358  char file_name[128];
359 
360  resource.nr_counters = nb_ports * nb_entries;
361 
362  result = init_doca_flow(nb_queues, "vnf,hws", &resource, nr_shared_resources);
363  if (result != DOCA_SUCCESS) {
364  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
365  return result;
366  }
367 
368  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
371  if (result != DOCA_SUCCESS) {
372  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
374  return result;
375  }
376 
377  for (port_id = 0; port_id < nb_ports; port_id++) {
378  memset(&status, 0, sizeof(status));
379 
380  result = create_hairpin_pipe(ports[port_id], port_id, &hairpin_pipe);
381  if (result != DOCA_SUCCESS) {
382  DOCA_LOG_ERR("Failed to add hairpin pipe: %s", doca_error_get_descr(result));
385  return result;
386  }
387 
388  result = add_pipe_entry(hairpin_pipe, &status, &entry[port_id][HAIRPIN_PIPE_ENTRY]);
389  if (result != DOCA_SUCCESS) {
390  DOCA_LOG_ERR("Failed to add hairpin entry: %s", doca_error_get_descr(result));
393  return result;
394  }
395 
396  result = create_drop_pipe(ports[port_id], hairpin_pipe, &drop_pipe);
397  if (result != DOCA_SUCCESS) {
398  DOCA_LOG_ERR("Failed to create drop pipe: %s", doca_error_get_descr(result));
401  return result;
402  }
403 
404  result = add_drop_pipe_entry(drop_pipe, &status, &entry[port_id][DROP_PIPE_ENTRY]);
405  if (result != DOCA_SUCCESS) {
406  DOCA_LOG_ERR("Failed to add entry to drop pipe: %s", doca_error_get_descr(result));
409  return result;
410  }
411 
412  result = create_classifier_pipe(ports[port_id], drop_pipe, &classifier_pipe);
413  if (result != DOCA_SUCCESS) {
414  DOCA_LOG_ERR("Failed to create classifier pipe: %s", doca_error_get_descr(result));
417  return result;
418  }
419 
420  result = add_pipe_entry(classifier_pipe, &status, &entry[port_id][CLASSIFIER_PIPE_ENTRY]);
421  if (result != DOCA_SUCCESS) {
422  DOCA_LOG_ERR("Failed to add entry to classifier: %s", doca_error_get_descr(result));
425  return result;
426  }
427 
429  if (result != DOCA_SUCCESS) {
430  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
433  return result;
434  }
435 
436  if (status.nb_processed != nb_entries || status.failure) {
437  DOCA_LOG_ERR("Failed to process entries");
440  return DOCA_ERROR_BAD_STATE;
441  }
442  }
443 
444  /* wait few seconds for packets to arrive so query will not return zero */
445  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
446  sleep(5);
447  DOCA_LOG_INFO("===================================================");
448 
449  for (port_id = 0; port_id < nb_ports; port_id++) {
450  snprintf(file_name, sizeof(file_name) - 1, "port_%d_info.txt", port_id);
451 
452  fd = fopen(file_name, "w");
453  if (fd == NULL) {
454  DOCA_LOG_ERR("Failed to open the file %s", file_name);
457  return DOCA_ERROR_IO_FAILED;
458  }
459 
460  /* dump port info to a file */
461  doca_flow_port_pipes_dump(ports[port_id], fd);
462  fclose(fd);
463 
465  if (result != DOCA_SUCCESS) {
466  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
469  return result;
470  }
471  DOCA_LOG_INFO("Port %d:", port_id);
472  DOCA_LOG_INFO("Classifier pipe:");
473  DOCA_LOG_INFO("\tTotal bytes: %ld", query_stats.counter.total_bytes);
474  DOCA_LOG_INFO("\tTotal packets: %ld", query_stats.counter.total_pkts);
475  DOCA_LOG_INFO("--------------");
476 
477  result = doca_flow_resource_query_entry(entry[port_id][DROP_PIPE_ENTRY], &query_stats);
478  if (result != DOCA_SUCCESS) {
479  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
482  return result;
483  }
484  DOCA_LOG_INFO("Drop pipe:");
485  DOCA_LOG_INFO("\tTotal bytes: %ld", query_stats.counter.total_bytes);
486  DOCA_LOG_INFO("\tTotal packets: %ld", query_stats.counter.total_pkts);
487  DOCA_LOG_INFO("--------------");
488 
490  if (result != DOCA_SUCCESS) {
491  DOCA_LOG_ERR("Failed to query entry: %s", doca_error_get_descr(result));
494  return result;
495  }
496  DOCA_LOG_INFO("Hairpin pipe:");
497  DOCA_LOG_INFO("\tTotal bytes: %ld", query_stats.counter.total_bytes);
498  DOCA_LOG_INFO("\tTotal packets: %ld", query_stats.counter.total_pkts);
499  DOCA_LOG_INFO("===================================================");
500  }
501 
504  return result;
505 }
#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 int nb_entries
static doca_error_t create_hairpin_pipe(struct doca_flow_port *port, int port_id, struct doca_flow_pipe **pipe)
DOCA_LOG_REGISTER(FLOW_DROP)
static doca_error_t create_drop_pipe(struct doca_flow_port *port, struct doca_flow_pipe *hairpin_pipe, struct doca_flow_pipe **pipe)
static doca_error_t add_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status, struct doca_flow_pipe_entry **entry)
static doca_error_t create_classifier_pipe(struct doca_flow_port *port, struct doca_flow_pipe *drop_pipe, struct doca_flow_pipe **pipe)
static doca_error_t add_drop_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status, struct doca_flow_pipe_entry **entry)
doca_error_t flow_drop(int nb_queues)
pipe_entry_index
@ CLASSIFIER_PIPE_ENTRY
@ HAIRPIN_PIPE_ENTRY
@ DROP_PIPE_ENTRY
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_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]
#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_ERROR_IO_FAILED
Definition: doca_error.h:55
@ 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_cfg_set_label(struct doca_flow_pipe_cfg *cfg, const char *label)
Sets the label for the given 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_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 void doca_flow_port_pipes_dump(struct doca_flow_port *port, FILE *f)
Dump pipes of one port.
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_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_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_FWD_DROP
Definition: doca_flow.h:748
@ DOCA_FLOW_L4_META_TCP
Definition: doca_flow.h:308
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
Definition: doca_log.h:486
uint32_t doca_be32_t
Definition: doca_types.h:121
uint16_t doca_be16_t
Declare DOCA endianity types.
Definition: doca_types.h:120
uint16_t src_port
Definition: packets.h:0
uint16_t dst_port
Definition: packets.h:1
doca_error_t stop_doca_flow_ports(int nb_ports, struct doca_flow_port *ports[])
Definition: flow_common.c:240
doca_error_t init_doca_flow_ports(int nb_ports, struct doca_flow_port *ports[], bool is_hairpin, struct doca_dev *dev_arr[], uint32_t actions_mem_size[])
Definition: flow_common.c:296
doca_error_t set_flow_pipe_cfg(struct doca_flow_pipe_cfg *cfg, const char *name, enum doca_flow_pipe_type type, bool is_root)
Definition: flow_common.c:305
#define 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
struct doca_flow_header_tcp tcp
Definition: doca_flow.h:461
struct doca_flow_header_l4_port l4_port
doca flow matcher information
Definition: doca_flow.h:491
struct doca_flow_parser_meta parser_meta
Definition: doca_flow.h:496
struct doca_flow_header_format outer
Definition: doca_flow.h:498
doca monitor action configuration
Definition: doca_flow.h:968
enum doca_flow_resource_type counter_type
Definition: doca_flow.h:988
enum doca_flow_l3_meta outer_l3_type
Definition: doca_flow.h:382
enum doca_flow_l4_meta outer_l4_type
Definition: doca_flow.h:383
flow resource query
Definition: doca_flow.h:1101
struct doca_flow_resource_query::@115::@117 counter
user context struct that will be used in entries process callback
Definition: flow_common.h:78
uint32_t nr_counters
Definition: flow_common.h:96
static int nb_ports
Definition: switch_core.c:44
static uint32_t actions_mem_size[FLOW_SWITCH_PORTS_MAX]
Definition: switch_core.c:43
static struct doca_flow_port * ports[FLOW_SWITCH_PORTS_MAX]
Definition: switch_core.c:42