NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_shared_meter_sample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 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 DOCA_LOG_REGISTER(FLOW_SHARED_METER);
37 
38 /* Meter colors green, yellow, red use 2 bits mask */
39 #define METER_COLOR_MASK 3
40 
41 /* Set match l4 port */
42 #define SET_L4_PORT(layer, port, value) \
43  do { \
44  if (match.layer.l4_type_ext == DOCA_FLOW_L4_TYPE_EXT_TCP) \
45  match.layer.tcp.l4_port.port = (value); \
46  else if (match.layer.l4_type_ext == DOCA_FLOW_L4_TYPE_EXT_UDP) \
47  match.layer.udp.l4_port.port = (value); \
48  } while (0)
49 
50 /*
51  * Create DOCA Flow control pipe with match on greed/red colors and their respective forwarding.
52  *
53  * @port [in]: port of the pipe
54  * @fwd_on_green [in]: the forwarding in case there is a green color match
55  * @fwd_on_red [in]: the forwarding in case there is a red color match
56  * @color_pipe [out]: created pipe pointer
57  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
58  */
59 static doca_error_t create_color_matched_pipe(struct doca_flow_port *port,
60  const struct doca_flow_fwd *fwd_on_green,
61  const struct doca_flow_fwd *fwd_on_red,
62  struct doca_flow_pipe **color_pipe)
63 {
65  struct doca_flow_pipe_cfg *pipe_cfg;
66  struct doca_flow_match red_match, red_match_mask;
67  struct doca_flow_match green_match, green_match_mask;
68 
69  memset(&red_match, 0, sizeof(red_match));
70  memset(&red_match_mask, 0, sizeof(red_match_mask));
71  memset(&green_match, 0, sizeof(green_match));
72  memset(&green_match_mask, 0, sizeof(green_match_mask));
73 
74  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
75  if (result != DOCA_SUCCESS) {
76  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
77  return result;
78  }
79 
80  result = set_flow_pipe_cfg(pipe_cfg, "MTR_CTRL_PIPE", DOCA_FLOW_PIPE_CONTROL, false);
81  if (result != DOCA_SUCCESS) {
82  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
83  goto destroy_pipe_cfg;
84  }
85 
86  result = doca_flow_pipe_create(pipe_cfg, NULL, NULL, color_pipe);
87  if (result != DOCA_SUCCESS)
88  goto destroy_pipe_cfg;
90 
91  red_match.parser_meta.meter_color = DOCA_FLOW_METER_COLOR_RED;
92  *(uint8_t *)&red_match_mask.parser_meta.meter_color = METER_COLOR_MASK;
93  green_match.parser_meta.meter_color = DOCA_FLOW_METER_COLOR_GREEN;
94  *(uint8_t *)&green_match_mask.parser_meta.meter_color = METER_COLOR_MASK;
95 
97  0,
98  *color_pipe,
99  &red_match,
100  &red_match_mask,
101  NULL,
102  NULL,
103  NULL,
104  NULL,
105  NULL,
106  fwd_on_red,
107  NULL,
108  NULL);
109  if (result)
110  return result;
112  0,
113  *color_pipe,
114  &green_match,
115  &green_match_mask,
116  NULL,
117  NULL,
118  NULL,
119  NULL,
120  NULL,
121  fwd_on_green,
122  NULL,
123  NULL);
124  if (result)
125  return result;
126 
127  return DOCA_SUCCESS;
128 
130  doca_flow_pipe_cfg_destroy(pipe_cfg);
131  return result;
132 }
133 
134 /*
135  * Create DOCA Flow pipe with 5 tuple match and monitor on shared meter ID
136  *
137  * @port [in]: port of the pipe
138  * @out_l4_meta_type [in]: l4 meta type to match: UDP/TCP
139  * @out_l4_type [in]: l4 type to match: UDP/TCP
140  * @color_pipe [in]: next forwarded pipe to match on color
141  * @pipe [out]: created pipe pointer
142  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
143  */
144 static doca_error_t create_shared_meter_mark_pipe(struct doca_flow_port *port,
145  enum doca_flow_l4_meta out_l4_meta_type,
146  enum doca_flow_l4_type_ext out_l4_type,
147  struct doca_flow_pipe *color_pipe,
148  struct doca_flow_pipe **pipe)
149 {
150  struct doca_flow_match match;
151  struct doca_flow_monitor monitor;
152  struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
153  struct doca_flow_fwd fwd;
154  struct doca_flow_pipe_cfg *pipe_cfg;
156 
157  memset(&match, 0, sizeof(match));
158  memset(&monitor, 0, sizeof(monitor));
159  memset(&actions, 0, sizeof(actions));
160  memset(&fwd, 0, sizeof(fwd));
161 
162  /* 5 tuple match */
163  match.parser_meta.outer_l4_type = out_l4_meta_type;
165  match.outer.l4_type_ext = out_l4_type;
167  match.outer.ip4.src_ip = 0xffffffff;
168  match.outer.ip4.dst_ip = 0xffffffff;
169  SET_L4_PORT(outer, src_port, 0xffff);
170  SET_L4_PORT(outer, dst_port, 0xffff);
171 
172  actions_arr[0] = &actions;
173 
174  /* monitor with changeable shared meter ID */
176  monitor.shared_meter.shared_meter_id = 0xffffffff;
177 
178  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
179  if (result != DOCA_SUCCESS) {
180  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
181  return result;
182  }
183 
184  result = set_flow_pipe_cfg(pipe_cfg, "SHARED_METER_PIPE", DOCA_FLOW_PIPE_BASIC, false);
185  if (result != DOCA_SUCCESS) {
186  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
187  goto destroy_pipe_cfg;
188  }
189  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &match, NULL);
190  if (result != DOCA_SUCCESS) {
191  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
192  goto destroy_pipe_cfg;
193  }
194  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, NB_ACTIONS_ARR);
195  if (result != DOCA_SUCCESS) {
196  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
197  goto destroy_pipe_cfg;
198  }
200  if (result != DOCA_SUCCESS) {
201  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s", doca_error_get_descr(result));
202  goto destroy_pipe_cfg;
203  }
204 
205  /* Forward to next pipe to match on marked meter color */
207  fwd.next_pipe = color_pipe;
208 
209  result = doca_flow_pipe_create(pipe_cfg, &fwd, NULL, pipe);
211  doca_flow_pipe_cfg_destroy(pipe_cfg);
212  return result;
213 }
214 
215 /*
216  * Add DOCA Flow pipe entry to the shared meter pipe
217  *
218  * @pipe [in]: pipe of the entry
219  * @out_l4_type [in]: l4 type to match: UDP/TCP
220  * @shared_meter_id [in]: ID of the shared meter
221  * @status [in]: user context for adding entry
222  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
223  */
224 static doca_error_t add_shared_meter_pipe_entry(struct doca_flow_pipe *pipe,
225  enum doca_flow_l4_type_ext out_l4_type,
226  uint32_t shared_meter_id,
227  struct entries_status *status)
228 {
229  struct doca_flow_match match;
230  struct doca_flow_actions actions;
231  struct doca_flow_monitor monitor;
232  struct doca_flow_pipe_entry *entry;
234 
235  /* example 5-tuple to match */
236  doca_be32_t dst_ip_addr = BE_IPV4_ADDR(8, 8, 8, 8);
237  doca_be32_t src_ip_addr = BE_IPV4_ADDR(1, 2, 3, 4);
238  doca_be16_t dst_port = rte_cpu_to_be_16(80);
239  doca_be16_t src_port = rte_cpu_to_be_16(1234);
240 
241  memset(&match, 0, sizeof(match));
242  memset(&actions, 0, sizeof(actions));
243  memset(&monitor, 0, sizeof(monitor));
244 
245  /* set shared meter ID */
247  monitor.shared_meter.shared_meter_id = shared_meter_id;
248 
249  match.outer.ip4.dst_ip = dst_ip_addr;
250  match.outer.ip4.src_ip = src_ip_addr;
251  match.outer.l4_type_ext = out_l4_type;
252  SET_L4_PORT(outer, dst_port, dst_port);
253  SET_L4_PORT(outer, src_port, src_port);
254 
255  result = doca_flow_pipe_add_entry(0, pipe, &match, &actions, &monitor, NULL, 0, status, &entry);
256  if (result != DOCA_SUCCESS) {
257  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
258  return result;
259  }
260 
261  return DOCA_SUCCESS;
262 }
263 
264 /*
265  * Add DOCA Flow control pipe
266  *
267  * @port [in]: port of the pipe
268  * @pipe [out]: created pipe pointer
269  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
270  */
271 static doca_error_t create_control_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
272 {
273  struct doca_flow_pipe_cfg *pipe_cfg;
275 
276  result = doca_flow_pipe_cfg_create(&pipe_cfg, port);
277  if (result != DOCA_SUCCESS) {
278  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
279  return result;
280  }
281 
282  result = set_flow_pipe_cfg(pipe_cfg, "CONTROL_PIPE", DOCA_FLOW_PIPE_CONTROL, true);
283  if (result != DOCA_SUCCESS) {
284  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
285  goto destroy_pipe_cfg;
286  }
287 
288  result = doca_flow_pipe_create(pipe_cfg, NULL, NULL, pipe);
290  doca_flow_pipe_cfg_destroy(pipe_cfg);
291  return result;
292 }
293 
294 /*
295  * Add DOCA Flow pipe entries to the control pipe. First entry forwards UDP packets to udp_pipe and the second
296  * forwards TCP packets to tcp_pipe
297  *
298  * @control_pipe [in]: pipe of the entries
299  * @tcp_pipe [in]: pointer to the TCP pipe to forward packets to
300  * @udp_pipe [in]: pointer to the UDP pipe to forward packets to
301  * @status [in]: user context for adding entry
302  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
303  */
304 static doca_error_t add_control_pipe_entries(struct doca_flow_pipe *control_pipe,
305  struct doca_flow_pipe *tcp_pipe,
306  struct doca_flow_pipe *udp_pipe,
307  struct entries_status *status)
308 {
309  struct doca_flow_match match;
310  struct doca_flow_fwd fwd;
311  uint8_t priority = 0;
313 
314  memset(&match, 0, sizeof(match));
315  memset(&fwd, 0, sizeof(fwd));
316 
319 
321  fwd.next_pipe = udp_pipe;
322 
324  priority,
325  control_pipe,
326  &match,
327  NULL,
328  NULL,
329  NULL,
330  NULL,
331  NULL,
332  NULL,
333  &fwd,
334  status,
335  NULL);
336  if (result != DOCA_SUCCESS) {
337  DOCA_LOG_ERR("Failed to add control pipe entry: %s", doca_error_get_descr(result));
338  return result;
339  }
340 
341  memset(&match, 0, sizeof(match));
342  memset(&fwd, 0, sizeof(fwd));
343 
346 
348  fwd.next_pipe = tcp_pipe;
349 
351  priority,
352  control_pipe,
353  &match,
354  NULL,
355  NULL,
356  NULL,
357  NULL,
358  NULL,
359  NULL,
360  &fwd,
361  status,
362  NULL);
363  if (result != DOCA_SUCCESS) {
364  DOCA_LOG_ERR("Failed to add control pipe entry: %s", doca_error_get_descr(result));
365  return result;
366  }
367  return DOCA_SUCCESS;
368 }
369 
370 /*
371  * Run flow_shared_meter sample
372  *
373  * @nb_queues [in]: number of queues the sample will use
374  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
375  */
377 {
378  int nb_ports = 2;
379  struct flow_resources resource = {0};
380  uint32_t nr_shared_resources[SHARED_RESOURCE_NUM_VALUES] = {0};
381  struct doca_flow_port *ports[nb_ports];
382  struct doca_dev *dev_arr[nb_ports];
383  uint32_t actions_mem_size[nb_ports];
384  struct doca_flow_pipe *tcp_pipe, *udp_pipe, *pipe, *color_pipe;
385  int port_id;
386  uint32_t shared_meter_ids[] = {0, 1};
387  struct doca_flow_shared_resource_cfg cfg = {0};
388  struct doca_flow_resource_meter_cfg meter_cfg = {0};
389  struct doca_flow_fwd fwd_on_green, fwd_on_red;
390  struct entries_status status;
391  int num_of_entries = 4;
393 
394  nr_shared_resources[DOCA_FLOW_SHARED_RESOURCE_METER] = 2;
395 
396  result = init_doca_flow(nb_queues, "vnf,hws", &resource, nr_shared_resources);
397  if (result != DOCA_SUCCESS) {
398  DOCA_LOG_ERR("Failed to init DOCA Flow: %s", doca_error_get_descr(result));
399  return result;
400  }
401 
402  memset(dev_arr, 0, sizeof(struct doca_dev *) * nb_ports);
403  ARRAY_INIT(actions_mem_size, ACTIONS_MEM_SIZE(nb_queues, num_of_entries));
405  if (result != DOCA_SUCCESS) {
406  DOCA_LOG_ERR("Failed to init DOCA ports: %s", doca_error_get_descr(result));
408  return result;
409  }
410 
414  meter_cfg.cir = 1024;
415  meter_cfg.cbs = 1024;
416  meter_cfg.rfc2697.ebs = 0;
417  cfg.meter_cfg = meter_cfg;
418  for (port_id = 0; port_id < nb_ports; port_id++) {
419  memset(&status, 0, sizeof(status));
420  /* config shared meter with cir and cbs, based on RFC 2697 */
422  shared_meter_ids[port_id],
423  &cfg);
424  if (result != DOCA_SUCCESS) {
425  DOCA_LOG_ERR("Failed to cfg shared meter");
428  return result;
429  }
430  /* bind shared meter to port */
432  &shared_meter_ids[port_id],
433  1,
434  ports[port_id]);
435  if (result != DOCA_SUCCESS) {
436  DOCA_LOG_ERR("Failed to bind shared meter to port");
439  return result;
440  }
441 
442  /* forwarding traffic to other port for passed (green) traffic */
443  memset(&fwd_on_green, 0, sizeof(fwd_on_green));
444  fwd_on_green.type = DOCA_FLOW_FWD_PORT;
445  fwd_on_green.port_id = port_id ^ 1;
446  /* drop on failed (red) traffic */
447  memset(&fwd_on_red, 0, sizeof(fwd_on_red));
448  fwd_on_red.type = DOCA_FLOW_FWD_DROP;
449 
450  result = create_color_matched_pipe(ports[port_id], &fwd_on_green, &fwd_on_red, &color_pipe);
451  if (result != DOCA_SUCCESS) {
452  DOCA_LOG_ERR("Failed to create color pipe: %s", doca_error_get_descr(result));
455  return result;
456  }
457 
461  color_pipe,
462  &tcp_pipe);
463  if (result != DOCA_SUCCESS) {
464  DOCA_LOG_ERR("Failed to create pipe: %s", doca_error_get_descr(result));
467  return result;
468  }
469 
472  shared_meter_ids[port_id],
473  &status);
474  if (result != DOCA_SUCCESS) {
475  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
478  return result;
479  }
480 
481  result = create_color_matched_pipe(ports[port_id], &fwd_on_green, &fwd_on_red, &color_pipe);
482  if (result != DOCA_SUCCESS) {
483  DOCA_LOG_ERR("Failed to create color pipe: %s", doca_error_get_descr(result));
486  return result;
487  }
488 
492  color_pipe,
493  &udp_pipe);
494  if (result != DOCA_SUCCESS) {
495  DOCA_LOG_ERR("Failed to create pipe: %s", doca_error_get_descr(result));
498  return result;
499  }
500 
503  shared_meter_ids[port_id],
504  &status);
505  if (result != DOCA_SUCCESS) {
506  DOCA_LOG_ERR("Failed to add entry: %s", doca_error_get_descr(result));
509  return result;
510  }
511  result = create_control_pipe(ports[port_id], &pipe);
512  if (result != DOCA_SUCCESS) {
513  DOCA_LOG_ERR("Failed to create control pipe: %s", doca_error_get_descr(result));
516  return result;
517  }
518 
519  result = add_control_pipe_entries(pipe, tcp_pipe, udp_pipe, &status);
520  if (result != DOCA_SUCCESS) {
523  return result;
524  }
525 
526  result = doca_flow_entries_process(ports[port_id], 0, DEFAULT_TIMEOUT_US, num_of_entries);
527  if (result != DOCA_SUCCESS) {
528  DOCA_LOG_ERR("Failed to process entries: %s", doca_error_get_descr(result));
531  return result;
532  }
533 
534  if (status.nb_processed != num_of_entries || status.failure) {
535  DOCA_LOG_ERR("Failed to process entries");
538  return DOCA_ERROR_BAD_STATE;
539  }
540  }
541 
542  DOCA_LOG_INFO("Wait few seconds for packets to arrive");
543  sleep(5);
544 
547  return result;
548 }
#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 doca_error_t create_control_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
DOCA_LOG_REGISTER(FLOW_SHARED_METER)
static doca_error_t add_shared_meter_pipe_entry(struct doca_flow_pipe *pipe, enum doca_flow_l4_type_ext out_l4_type, uint32_t shared_meter_id, struct entries_status *status)
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)
static doca_error_t create_color_matched_pipe(struct doca_flow_port *port, const struct doca_flow_fwd *fwd_on_green, const struct doca_flow_fwd *fwd_on_red, struct doca_flow_pipe **color_pipe)
#define SET_L4_PORT(layer, port, value)
doca_error_t flow_shared_meter(int nb_queues)
static doca_error_t create_shared_meter_mark_pipe(struct doca_flow_port *port, enum doca_flow_l4_meta out_l4_meta_type, enum doca_flow_l4_type_ext out_l4_type, struct doca_flow_pipe *color_pipe, struct doca_flow_pipe **pipe)
#define METER_COLOR_MASK
#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_FLOW_SHARED_RESOURCE_METER
Definition: doca_flow.h:93
@ 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_METER_COLOR_MODE_BLIND
Definition: doca_flow.h:854
@ DOCA_FLOW_RESOURCE_TYPE_SHARED
Definition: doca_flow.h:614
@ 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_METER_ALGORITHM_TYPE_RFC2697
Definition: doca_flow.h:830
@ DOCA_FLOW_METER_LIMIT_TYPE_BYTES
Definition: doca_flow.h:843
@ 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 monitor action configuration
Definition: doca_flow.h:968
struct doca_flow_monitor::@101::@106 shared_meter
enum doca_flow_resource_type meter_type
Definition: doca_flow.h:969
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
enum doca_flow_meter_color meter_color
Definition: doca_flow.h:380
doca flow meter resource configuration
Definition: doca_flow.h:863
enum doca_flow_meter_color_mode color_mode
Definition: doca_flow.h:866
enum doca_flow_meter_limit_type limit_type
Definition: doca_flow.h:864
struct doca_flow_resource_meter_cfg::@94::@96 rfc2697
enum doca_flow_meter_algorithm_type alg
Definition: doca_flow.h:868
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
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