NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_parser.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-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 <inttypes.h>
27 #include <string.h>
28 #include <stdlib.h>
29 
30 #include <cmdline.h>
31 #include <cmdline_parse.h>
32 #include <cmdline_parse_num.h>
33 #include <cmdline_parse_string.h>
34 #include <cmdline_socket.h>
35 #include <rte_byteorder.h>
36 
37 #include <doca_log.h>
38 
39 #include "flow_parser.h"
40 #include "utils.h"
41 
42 DOCA_LOG_REGISTER(FLOW_PARSER);
43 
44 #define MAX_CMDLINE_INPUT_LEN 512 /* Maximum size of input command */
45 #define MAC_ADDR_LEN 6 /* MAC address size in bytes */
46 #define IP_ADDR_LEN 4 /* IP address size in bytes */
47 #define MAX_FIELD_INPUT_LEN 128 /* Maximum size of field input */
48 #define NAME_STR_LEN 5 /* Name string size */
49 #define FWD_STR_LEN 4 /* Forward string size */
50 #define MISS_FWD_STR_LEN 9 /* Forward miss string size */
51 #define MATCH_MASK_STR_LEN 11 /* Match mask string size */
52 #define MONITOR_STR_LEN 8 /* Monitor string size */
53 #define ROOT_ENABLE_STR_LEN 12 /* Root enable string size */
54 #define PORT_ID_STR_LEN 8 /* Port ID string size */
55 #define PIPE_ID_STR_LEN 8 /* Pipe ID string size */
56 #define ENTRY_ID_STR_LEN 9 /* Entry ID string size */
57 #define PIPE_QUEUE_STR_LEN 11 /* Pipe queue string size */
58 #define PRIORITY_STR_LEN 9 /* Priority string size */
59 #define FILE_STR_LEN 5 /* File string size */
60 #define TYPE_STR_LEN 5 /* Type enable string size */
61 #define HEXADECIMAL_BASE 1 /* Hex base */
62 #define UINT32_CHANGEABLE_FIELD "0xffffffff" /* DOCA flow masking for 32 bits value */
63 
64 #define BE_IPV4_ADDR(a, b, c, d) (RTE_BE32((a << 24) + (b << 16) + (c << 8) + d)) /* Big endian conversion */
65 
66 /* Set match l4 port */
67 #define SET_L4_PORT(layer, port, value) \
68  do { \
69  if (match->layer.l4_type_ext == DOCA_FLOW_L4_TYPE_EXT_TCP) \
70  match->layer.tcp.l4_port.port = (value); \
71  else if (match->layer.l4_type_ext == DOCA_FLOW_L4_TYPE_EXT_UDP) \
72  match->layer.udp.l4_port.port = (value); \
73  } while (0)
74 
75 static void (*destroy_pipe_func)(uint64_t); /* Callback for destroy pipe command */
76 static void (*remove_entry_func)(uint16_t, uint64_t, uint32_t); /* Callback for remove entry command */
77 static void (*remove_fw_entry_func)(uint64_t); /* Callback for FW remove entry command */
78 static void (*port_pipes_flush_func)(uint16_t); /* Callback for port pipes flush command */
79 static void (*query_func)(uint64_t, struct doca_flow_resource_query *); /* Callback query command */
80 static void (*port_pipes_dump_func)(uint16_t, FILE *); /* Callback for port pipes dump command */
81 static void (*create_pipe_func)(struct doca_flow_pipe_cfg *,
82  uint16_t,
83  struct doca_flow_fwd *,
84  uint64_t,
85  struct doca_flow_fwd *,
86  uint64_t); /* Callback for create pipe command */
87 static void (*add_entry_func)(uint16_t,
88  uint64_t,
89  struct doca_flow_match *,
90  struct doca_flow_actions *,
91  struct doca_flow_monitor *,
92  struct doca_flow_fwd *,
93  uint64_t,
94  uint32_t); /* Callback for add entry command */
95 static void (*add_fw_entry_func)(uint16_t, struct doca_flow_match *); /* Callback for FW add entry command */
96 static void (*add_control_pipe_entry_func)(uint16_t,
97  uint8_t,
98  uint64_t,
99  struct doca_flow_match *,
100  struct doca_flow_match *,
101  struct doca_flow_fwd *,
102  uint64_t); /* Callback for add control pipe entry command */
103 
104 static struct doca_flow_match pipe_match; /* DOCA Flow pipe match structure */
105 static struct doca_flow_match entry_match; /* DOCA Flow entry match structure */
106 static struct doca_flow_match match_mask; /* DOCA Flow match mask structure */
107 static struct doca_flow_actions actions; /* DOCA Flow actions structure */
108 static struct doca_flow_monitor monitor; /* DOCA Flow monitor structure */
109 static struct doca_flow_fwd fwd; /* DOCA Flow forward structure */
110 static struct doca_flow_fwd fwd_miss; /* DOCA Flow forward miss structure */
111 static uint16_t pipe_port_id; /* DOCA Flow pipe port id */
112 static uint64_t fwd_next_pipe_id; /* DOCA Flow next fwd pipe id */
113 static uint64_t fwd_miss_next_pipe_id; /* DOCA Flow next miss fwd pipe id */
114 static uint16_t *rss_queues; /* DOCA Flow RSS queues */
115 
116 /* Create pipe command result */
118  cmdline_fixed_string_t create; /* Command first segment */
119  cmdline_fixed_string_t pipe; /* Command second segment */
120  cmdline_fixed_string_t params; /* Command last segment */
121 };
122 
123 /* Add entry command result */
125  cmdline_fixed_string_t add; /* Command first segment */
126  cmdline_fixed_string_t entry; /* Command second segment */
127  cmdline_fixed_string_t params; /* Command last segment */
128 };
129 
130 /* Add control pipe command result */
132  cmdline_fixed_string_t add; /* Command first segment */
133  cmdline_fixed_string_t control_pipe; /* Command second segment */
134  cmdline_fixed_string_t entry; /* Command third segment */
135  cmdline_fixed_string_t params; /* Command last segment */
136 };
137 
138 /* Destroy pipe command result */
140  cmdline_fixed_string_t destroy; /* Command first segment */
141  cmdline_fixed_string_t pipe; /* Command second segment */
142  cmdline_fixed_string_t params; /* Command last segment */
143 };
144 
145 /* Remove entry command result */
147  cmdline_fixed_string_t rm; /* Command first segment */
148  cmdline_fixed_string_t entry; /* Command second segment */
149  cmdline_fixed_string_t params; /* Command last segment */
150 };
151 
152 /* Flush pipes command result */
154  cmdline_fixed_string_t port; /* Command first segment */
155  cmdline_fixed_string_t pipes; /* Command second segment */
156  cmdline_fixed_string_t flush; /* Command third segment */
157  cmdline_fixed_string_t port_id; /* Command last segment */
158 };
159 
160 /* Query command result */
162  cmdline_fixed_string_t query; /* Command first segment */
163  cmdline_fixed_string_t params; /* Command second segment */
164 };
165 
166 /* Dump pipe command result */
168  cmdline_fixed_string_t port; /* Command first segment */
169  cmdline_fixed_string_t pipes; /* Command second segment */
170  cmdline_fixed_string_t dump; /* Command third segment */
171  cmdline_fixed_string_t params; /* Command last segment */
172 };
173 
174 /* Create flow structure command result */
176  cmdline_fixed_string_t create; /* Command first segment */
177  cmdline_fixed_string_t flow_struct; /* Command second segment */
178  cmdline_multi_string_t flow_struct_input; /* Command last segment */
179 };
180 
181 /* Quit command result */
183  cmdline_fixed_string_t quit; /* Command first segment */
184 };
185 
186 void set_pipe_create(void (*action)(struct doca_flow_pipe_cfg *,
187  uint16_t,
188  struct doca_flow_fwd *,
189  uint64_t,
190  struct doca_flow_fwd *,
191  uint64_t))
192 {
193  create_pipe_func = action;
194 }
195 
196 void set_pipe_add_entry(void (*action)(uint16_t,
197  uint64_t,
198  struct doca_flow_match *,
199  struct doca_flow_actions *,
200  struct doca_flow_monitor *,
201  struct doca_flow_fwd *,
202  uint64_t,
203  uint32_t))
204 {
205  add_entry_func = action;
206 }
207 
208 void set_pipe_fw_add_entry(void (*action)(uint16_t, struct doca_flow_match *))
209 {
210  add_fw_entry_func = action;
211 }
212 
213 void set_pipe_control_add_entry(void (*action)(uint16_t,
214  uint8_t,
215  uint64_t,
216  struct doca_flow_match *,
217  struct doca_flow_match *,
218  struct doca_flow_fwd *,
219  uint64_t))
220 {
222 }
223 
224 void set_pipe_destroy(void (*action)(uint64_t))
225 {
226  destroy_pipe_func = action;
227 }
228 
229 void set_pipe_rm_entry(void (*action)(uint16_t, uint64_t, uint32_t))
230 {
231  remove_entry_func = action;
232 }
233 
234 void set_pipe_fw_rm_entry(void (*action)(uint64_t))
235 {
236  remove_fw_entry_func = action;
237 }
238 
239 void set_port_pipes_flush(void (*action)(uint16_t))
240 {
241  port_pipes_flush_func = action;
242 }
243 
244 void set_query(void (*action)(uint64_t, struct doca_flow_resource_query *))
245 {
246  query_func = action;
247 }
248 
249 void set_port_pipes_dump(void (*action)(uint16_t, FILE *))
250 {
251  port_pipes_dump_func = action;
252 }
253 
254 /*
255  * Reset DOCA Flow structures
256  */
257 static void reset_doca_flow_structs(void)
258 {
259  memset(&pipe_match, 0, sizeof(pipe_match));
260  memset(&entry_match, 0, sizeof(entry_match));
261  memset(&match_mask, 0, sizeof(match_mask));
262  memset(&actions, 0, sizeof(actions));
263  memset(&monitor, 0, sizeof(monitor));
264  memset(&fwd, 0, sizeof(fwd));
265  memset(&fwd_miss, 0, sizeof(fwd_miss));
266 }
267 
268 doca_error_t parse_ipv4_str(const char *str_ip, doca_be32_t *ipv4_addr)
269 {
270  char *ptr;
271  int i;
272  uint32_t ips[4];
273 
274  if (strcmp(str_ip, UINT32_CHANGEABLE_FIELD) == 0) {
275  *ipv4_addr = UINT32_MAX;
276  return DOCA_SUCCESS;
277  }
278  for (i = 0; i < 3; i++) {
279  ips[i] = atoi(str_ip);
280  ptr = strchr(str_ip, '.');
281  if (ptr == NULL) {
282  DOCA_LOG_ERR("Wrong format of ip string");
284  }
285  str_ip = ++ptr;
286  }
287  ips[3] = atoi(ptr);
288  *ipv4_addr = BE_IPV4_ADDR(ips[0], ips[1], ips[2], ips[3]);
289  return DOCA_SUCCESS;
290 }
291 
293 {
294  if (strcmp(protocol_str, "tcp") == 0)
296  else if (strcmp(protocol_str, "udp") == 0)
298  else {
299  DOCA_LOG_ERR("Protocol type %s is not supported", protocol_str);
301  }
302  return DOCA_SUCCESS;
303 }
304 
305 /*
306  * Parse pipe id
307  *
308  * @pipe_id_str [in]: String to parse from
309  * @pipe_id [out]: Pipe id
310  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
311  */
312 static doca_error_t parse_pipe_id_input(char *pipe_id_str, uint64_t *pipe_id)
313 {
314  if (strncmp(pipe_id_str, "pipe_id=", PIPE_ID_STR_LEN) != 0) {
315  DOCA_LOG_ERR("Wrong format of pipe id string: \'pipe_id=<pipe_id>\'");
317  }
318  pipe_id_str += PIPE_ID_STR_LEN;
319  *pipe_id = strtoull(pipe_id_str, NULL, 0);
320  return DOCA_SUCCESS;
321 }
322 
323 /*
324  * Parse port id
325  *
326  * @port_id_str [in]: String to parse from
327  * @port_id [out]: Port id
328  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
329  */
330 static doca_error_t parse_port_id_input(const char *port_id_str, int *port_id)
331 {
332  if (strncmp(port_id_str, "port_id=", PORT_ID_STR_LEN) != 0) {
333  DOCA_LOG_ERR("Wrong format of port id string: \'port_id=<port_id>\'");
335  }
336  port_id_str += PORT_ID_STR_LEN;
337  *port_id = strtol(port_id_str, NULL, 0);
338  return DOCA_SUCCESS;
339 }
340 
341 /*
342  * Parse tunnel type
343  *
344  * @tun_type_str [in]: String to parse from
345  * @tun_type [out]: Tunnel type
346  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
347  */
348 static doca_error_t parse_tun_type_string(const char *tun_type_str, enum doca_flow_tun_type *tun_type)
349 {
350  if (strcmp(tun_type_str, "vxlan") == 0)
351  *tun_type = DOCA_FLOW_TUN_VXLAN;
352  else if (strcmp(tun_type_str, "gtpu") == 0)
353  *tun_type = DOCA_FLOW_TUN_GTPU;
354  else if (strcmp(tun_type_str, "gre") == 0)
355  *tun_type = DOCA_FLOW_TUN_GRE;
356  else {
357  DOCA_LOG_ERR("Tunnel type %s is not supported", tun_type_str);
359  }
360  return DOCA_SUCCESS;
361 }
362 
363 /*
364  * Parse forward type
365  *
366  * @fwd_str [in]: String to parse from
367  * @fwd [out]: Forward type
368  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
369  */
370 static doca_error_t parse_fwd_type(const char *fwd_str, enum doca_flow_fwd_type *fwd)
371 {
372  if (strcmp(fwd_str, "rss") == 0)
374  else if (strcmp(fwd_str, "port") == 0)
376  else if (strcmp(fwd_str, "pipe") == 0)
378  else if (strcmp(fwd_str, "drop") == 0)
380  else {
381  DOCA_LOG_ERR("FWD type %s is not supported", fwd_str);
383  }
384  return DOCA_SUCCESS;
385 }
386 
387 /*
388  * Parse forward rss type
389  *
390  * @rss_type_str [in]: String to parse from
391  * @fwd [out]: Forward RSS type
392  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
393  */
394 static doca_error_t parse_fwd_rss_type(const char *rss_type_str, enum doca_flow_resource_type *type)
395 {
396  if (strcmp(rss_type_str, "shared") == 0)
398  else if (strcmp(rss_type_str, "immediate") == 0)
400  else {
401  DOCA_LOG_ERR("FWD rss type %s is not supported", rss_type_str);
403  }
404  return DOCA_SUCCESS;
405 }
406 
407 /*
408  * Parse pipe type
409  *
410  * @pipe_type [in]: String to parse from
411  * @cfg [out]: Pipe configuration
412  * @type [out]: Pipe type
413  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
414  */
415 static doca_error_t parse_pipe_type(const char *pipe_type,
416  struct doca_flow_pipe_cfg *cfg,
418 {
420 
421  if (strcmp(pipe_type, "basic") == 0) {
423  if (result != DOCA_SUCCESS) {
424  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg type: %s", doca_error_get_descr(result));
425  return result;
426  }
428  } else if (strcmp(pipe_type, "control") == 0) {
430  if (result != DOCA_SUCCESS) {
431  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg type: %s", doca_error_get_descr(result));
432  return result;
433  }
435  } else {
436  DOCA_LOG_ERR("Pipe type %s is not supported", pipe_type);
438  }
439  return DOCA_SUCCESS;
440 }
441 
442 /*
443  * Parse ip type
444  *
445  * @ip_type_str [in]: String to parse from
446  * @ip_type [out]: Ip type
447  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
448  */
449 static doca_error_t parse_ip_type(const char *ip_type_str, enum doca_flow_l3_type *ip_type)
450 {
451  if (strcmp(ip_type_str, "ipv4") == 0)
452  *ip_type = DOCA_FLOW_L3_TYPE_IP4;
453  else if (strcmp(ip_type_str, "ipv6") == 0)
454  *ip_type = DOCA_FLOW_L3_TYPE_IP6;
455  else {
456  DOCA_LOG_ERR("IP type %s is not supported", ip_type_str);
458  }
459  return DOCA_SUCCESS;
460 }
461 
462 /*
463  * Parse l3 type
464  *
465  * @l3_type_str [in]: String to parse from
466  * @l3_type [out]: layer 3 type
467  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
468  */
469 static doca_error_t parse_l3_type(const char *l3_type_str, enum doca_flow_l3_type *l3_type)
470 {
471  if (strcmp(l3_type_str, "ipv4") == 0)
472  *l3_type = DOCA_FLOW_L3_TYPE_IP4;
473  else if (strcmp(l3_type_str, "ipv6") == 0)
474  *l3_type = DOCA_FLOW_L3_TYPE_IP6;
475  else {
476  DOCA_LOG_ERR("IP type %s is not supported", l3_type_str);
478  }
479  return DOCA_SUCCESS;
480 }
481 
482 /*
483  * Parse TCP flag
484  *
485  * @tcp_flag_str [in]: String to parse from
486  * @tcp_flag [out]: TCP flag
487  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
488  */
489 static doca_error_t parse_tcp_flag_string(const char *tcp_flag_str, uint8_t *tcp_flag)
490 {
491  if (strcmp(tcp_flag_str, "FIN") == 0)
492  *tcp_flag = DOCA_FLOW_MATCH_TCP_FLAG_FIN;
493  else if (strcmp(tcp_flag_str, "SYN") == 0)
494  *tcp_flag = DOCA_FLOW_MATCH_TCP_FLAG_SYN;
495  else if (strcmp(tcp_flag_str, "RST") == 0)
496  *tcp_flag = DOCA_FLOW_MATCH_TCP_FLAG_RST;
497  else if (strcmp(tcp_flag_str, "PSH") == 0)
498  *tcp_flag = DOCA_FLOW_MATCH_TCP_FLAG_PSH;
499  else if (strcmp(tcp_flag_str, "ACK") == 0)
500  *tcp_flag = DOCA_FLOW_MATCH_TCP_FLAG_ACK;
501  else if (strcmp(tcp_flag_str, "URG") == 0)
502  *tcp_flag = DOCA_FLOW_MATCH_TCP_FLAG_URG;
503  else if (strcmp(tcp_flag_str, "ECE") == 0)
504  *tcp_flag = DOCA_FLOW_MATCH_TCP_FLAG_ECE;
505  else if (strcmp(tcp_flag_str, "CWR") == 0)
506  *tcp_flag = DOCA_FLOW_MATCH_TCP_FLAG_CWR;
507  else {
508  DOCA_LOG_ERR("TCP flag %s is not supported", tcp_flag_str);
510  }
511  return DOCA_SUCCESS;
512 }
513 
514 /*
515  * Parse MAC address
516  *
517  * @mac_addr_str [in]: String to parse from
518  * @mac_addr [out]: MAC address
519  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
520  */
521 static doca_error_t parse_mac_address(char *mac_addr_str, uint8_t *mac_addr)
522 {
523  char *ptr;
524  int i;
525 
526  for (i = 0; i < MAC_ADDR_LEN - 1; i++) {
527  mac_addr[i] = strtol(mac_addr_str, NULL, HEXADECIMAL_BASE);
528  ptr = strchr(mac_addr_str, ':');
529  if (ptr)
530  mac_addr_str = ++ptr;
531  else {
532  DOCA_LOG_ERR("Wrong format of mac address");
534  }
535  }
536  mac_addr[MAC_ADDR_LEN - 1] = strtol(ptr, NULL, HEXADECIMAL_BASE);
537  return DOCA_SUCCESS;
538 }
539 
540 /*
541  * Parse IPv6 address
542  *
543  * @str_ip [in]: String to parse from
544  * @ipv6_addr [out]: IPv6 address
545  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
546  */
547 static doca_error_t parse_ipv6_str(const char *str_ip, doca_be32_t *ipv6_addr)
548 {
549  char *ptr;
550  int i;
551  int j;
552 
553  for (i = 0; i < IP_ADDR_LEN; i++) {
554  int ips[2];
555 
556  for (j = 0; j < 2; j++) {
557  ips[j] = strtol(str_ip, &ptr, HEXADECIMAL_BASE);
558  if (ptr)
559  str_ip = ++ptr;
560  else {
561  DOCA_LOG_ERR("Wrong format of ip string");
563  }
564  }
565  ipv6_addr[i] = RTE_BE32((ips[0] << 16) + ips[1]);
566  }
567  return DOCA_SUCCESS;
568 }
569 
570 /*
571  * Parse rss queues
572  *
573  * @rss_queues_str [in]: String to parse from
574  * @num_of_queues [in]: Number of queues
575  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
576  */
577 static doca_error_t parse_rss_queues(char *rss_queues_str, int num_of_queues)
578 {
579  int i;
580 
581  if (rss_queues)
582  free(rss_queues);
583  rss_queues = malloc(sizeof(uint16_t) * num_of_queues);
584  if (rss_queues == NULL) {
585  DOCA_LOG_ERR("Failed to allocate rss queues");
586  return DOCA_ERROR_NO_MEMORY;
587  }
588 
589  for (i = 0; i < num_of_queues - 1; i++) {
590  rss_queues[i] = strtol(rss_queues_str, NULL, 0);
591  rss_queues_str = rss_queues_str + 2;
592  }
593  rss_queues[num_of_queues - 1] = strtol(rss_queues_str, NULL, 0);
594  return DOCA_SUCCESS;
595 }
596 
597 /*
598  * Parse DOCA Flow monitor field
599  *
600  * @field_name [in]: Field to parse
601  * @value [in]: Value to read
602  * @struct_ptr [out]: Monitor struct to fill
603  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
604  */
605 static doca_error_t parse_monitor_field(char *field_name, char *value, void *struct_ptr)
606 {
607  struct doca_flow_monitor *monitor = (struct doca_flow_monitor *)struct_ptr;
608  uint64_t flags;
609 
610  if (strcmp(field_name, "flags") == 0) {
611  flags = (uint8_t)strtol(value, NULL, 0);
612  if (flags & 2)
614  if (flags & 4)
616  } else if (strcmp(field_name, "cir") == 0) {
617  monitor->non_shared_meter.cir = strtoull(value, NULL, 0);
618  } else if (strcmp(field_name, "cbs") == 0) {
619  monitor->non_shared_meter.cbs = strtoull(value, NULL, 0);
620  } else if (strcmp(field_name, "aging_sec") == 0) {
621  monitor->aging_sec = strtol(value, NULL, 0);
622  } else {
623  DOCA_LOG_ERR("The %s is not supported field in monitor", field_name);
625  }
626  return DOCA_SUCCESS;
627 }
628 
629 /*
630  * Parse DOCA Flow forward field
631  *
632  * @field_name [in]: Field to parse
633  * @value [in]: Value to read
634  * @struct_ptr [out]: Forward struct to fill
635  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
636  */
637 static doca_error_t parse_fwd_field(char *field_name, char *value, void *struct_ptr)
638 {
640  struct doca_flow_fwd *fwd = (struct doca_flow_fwd *)struct_ptr;
641 
642  if (strcmp(field_name, "type") == 0) {
644  if (result != DOCA_SUCCESS)
645  return result;
646  } else if (strcmp(field_name, "rss_type") == 0) {
648  if (result != DOCA_SUCCESS)
649  return result;
650  } else if (strcmp(field_name, "rss_outer_flags") == 0)
651  fwd->rss.outer_flags = strtol(value, NULL, 0);
652  else if (strcmp(field_name, "rss_inner_flags") == 0)
653  fwd->rss.inner_flags = strtol(value, NULL, 0);
654 
655  else if (strcmp(field_name, "rss_queues") == 0) {
657  if (result != DOCA_SUCCESS)
658  return result;
660  } else if (strcmp(field_name, "num_of_queues") == 0)
661  fwd->rss.nr_queues = strtol(value, NULL, 0);
662 
663  else if (strcmp(field_name, "port_id") == 0)
664  fwd->port_id = strtol(value, NULL, 0);
665 
666  else if (strcmp(field_name, "next_pipe_id") == 0)
667  fwd_next_pipe_id = strtoull(value, NULL, 0);
668 
669  else {
670  DOCA_LOG_ERR("The %s is not supported field in fwd", field_name);
672  }
673  return DOCA_SUCCESS;
674 }
675 
676 /*
677  * Parse DOCA Flow forward miss field
678  *
679  * @field_name [in]: Field to parse
680  * @value [in]: Value to read
681  * @struct_ptr [out]: Forward miss struct to fill
682  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
683  */
684 static doca_error_t parse_fwd_miss_field(char *field_name, char *value, void *struct_ptr)
685 {
687  struct doca_flow_fwd *fwd_miss = (struct doca_flow_fwd *)struct_ptr;
688 
689  if (strcmp(field_name, "type") == 0) {
691  if (result != DOCA_SUCCESS)
692  return result;
693  } else if (strcmp(field_name, "rss_type") == 0) {
695  if (result != DOCA_SUCCESS)
696  return result;
697  } else if (strcmp(field_name, "rss_outer_flags") == 0)
698  fwd_miss->rss.outer_flags = strtol(value, NULL, 0);
699  else if (strcmp(field_name, "rss_inner_flags") == 0)
700  fwd_miss->rss.inner_flags = strtol(value, NULL, 0);
701 
702  else if (strcmp(field_name, "rss_queues") == 0) {
704  if (result != DOCA_SUCCESS)
705  return result;
707  } else if (strcmp(field_name, "num_of_queues") == 0)
708  fwd_miss->rss.nr_queues = strtol(value, NULL, 0);
709 
710  else if (strcmp(field_name, "port_id") == 0)
711  fwd_miss->port_id = strtol(value, NULL, 0);
712 
713  else if (strcmp(field_name, "next_pipe_id") == 0)
714  fwd_miss_next_pipe_id = strtoull(value, NULL, 0);
715 
716  else {
717  DOCA_LOG_ERR("The %s is not supported field in fwd_miss", field_name);
719  }
720  return DOCA_SUCCESS;
721 }
722 
723 /*
724  * Parse DOCA Flow actions field
725  *
726  * @field_name [in]: Field to parse
727  * @value [in]: Value to read
728  * @struct_ptr [out]: Actions struct to fill
729  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
730  */
731 static doca_error_t parse_actions_field(char *field_name, char *value, void *struct_ptr)
732 {
734  struct doca_flow_actions *action = (struct doca_flow_actions *)struct_ptr;
735 
736  if (strcmp(field_name, "outer.eth.src_mac") == 0) {
738  if (result != DOCA_SUCCESS)
739  return result;
740  } else if (strcmp(field_name, "outer.eth.dst_mac") == 0) {
742  if (result != DOCA_SUCCESS)
743  return result;
744  } else if (strcmp(field_name, "outer.l3_type") == 0) {
745  result = parse_ip_type(value, &action->outer.l3_type);
746  if (result != DOCA_SUCCESS)
747  return result;
748  } else if (strcmp(field_name, "outer.src_ip_addr") == 0) {
749  if (action->outer.l3_type == DOCA_FLOW_L3_TYPE_IP4) {
750  result = parse_ipv4_str(value, &action->outer.ip4.src_ip);
751  if (result != DOCA_SUCCESS)
752  return result;
753  } else if (action->outer.l3_type == DOCA_FLOW_L3_TYPE_IP6) {
755  if (result != DOCA_SUCCESS)
756  return result;
757  } else {
758  DOCA_LOG_ERR("Source IP type is not set, need to set IP type before address");
760  }
761  } else if (strcmp(field_name, "outer.dst_ip_addr") == 0) {
762  if (action->outer.l3_type == DOCA_FLOW_L3_TYPE_IP4) {
763  result = parse_ipv4_str(value, &action->outer.ip4.dst_ip);
764  if (result != DOCA_SUCCESS)
765  return result;
766  } else if (action->outer.l3_type == DOCA_FLOW_L3_TYPE_IP6) {
768  if (result != DOCA_SUCCESS)
769  return result;
770  } else {
771  DOCA_LOG_ERR("Destination IP type is not set, need to set IP type before address");
773  }
774  } else if (strcmp(field_name, "outer.l4_type_ext") == 0) {
776  if (result != DOCA_SUCCESS)
777  return result;
778  } else if (strcmp(field_name, "outer.tcp_src_port") == 0)
779  action->outer.tcp.l4_port.src_port = strtol(value, NULL, 0);
780 
781  else if (strcmp(field_name, "outer.tcp_dst_port") == 0)
782  action->outer.tcp.l4_port.dst_port = strtol(value, NULL, 0);
783 
784  else if (strcmp(field_name, "outer.udp_src_port") == 0)
785  action->outer.udp.l4_port.src_port = strtol(value, NULL, 0);
786 
787  else if (strcmp(field_name, "outer.udp_dst_port") == 0)
788  action->outer.udp.l4_port.dst_port = strtol(value, NULL, 0);
789 
790  else if (strcmp(field_name, "outer.ip4.ttl") == 0)
791  action->outer.ip4.ttl = strtol(value, NULL, 0);
792 
793  else if (strcmp(field_name, "encap_src_mac") == 0) {
795  if (result != DOCA_SUCCESS)
796  return result;
797  } else if (strcmp(field_name, "encap_dst_mac") == 0) {
799  if (result != DOCA_SUCCESS)
800  return result;
801  } else if (strcmp(field_name, "encap_src_ip_type") == 0) {
803  if (result != DOCA_SUCCESS)
804  return result;
805  } else if (strcmp(field_name, "encap_src_ip_addr") == 0) {
808  if (result != DOCA_SUCCESS)
809  return result;
810  } else if (action->encap_cfg.encap.outer.l3_type == DOCA_FLOW_L3_TYPE_IP6) {
812  if (result != DOCA_SUCCESS)
813  return result;
814  } else {
815  DOCA_LOG_ERR("Encap source IP type is not set, need to set IP type before address");
817  }
818  } else if (strcmp(field_name, "encap_dst_ip_type") == 0) {
820  if (result != DOCA_SUCCESS)
821  return result;
822  } else if (strcmp(field_name, "encap_dst_ip_addr") == 0) {
825  if (result != DOCA_SUCCESS)
826  return result;
827  } else if (action->encap_cfg.encap.outer.l3_type == DOCA_FLOW_L3_TYPE_IP6) {
829  if (result != DOCA_SUCCESS)
830  return result;
831  } else {
832  DOCA_LOG_ERR("Encap destination IP type is not set, need to set IP type before address");
834  }
835  } else if (strcmp(field_name, "encap_tun_type") == 0) {
837  if (result != DOCA_SUCCESS)
838  return result;
839  } else if (strcmp(field_name, "encap_vxlan_tun_id") == 0)
840  action->encap_cfg.encap.tun.vxlan_tun_id = strtol(value, NULL, 0);
841 
842  else if (strcmp(field_name, "encap_gre_key") == 0)
843  action->encap_cfg.encap.tun.gre_key = strtol(value, NULL, 0);
844 
845  else if (strcmp(field_name, "encap_gtp_teid") == 0)
846  action->encap_cfg.encap.tun.gtp_teid = strtol(value, NULL, 0);
847 
848  else {
849  DOCA_LOG_ERR("The %s is not supported field in actions", field_name);
851  }
852  return DOCA_SUCCESS;
853 }
854 
855 /*
856  * Parse DOCA Flow match field
857  *
858  * @field_name [in]: Field to parse
859  * @value [in]: Value to read
860  * @struct_ptr [out]: Match struct to fill
861  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
862  */
863 static doca_error_t parse_match_field(char *field_name, char *value, void *struct_ptr)
864 {
866  struct doca_flow_match *match = (struct doca_flow_match *)struct_ptr;
867 
868  if (strcmp(field_name, "flags") == 0)
869  match->flags = (uint32_t)strtol(value, NULL, HEXADECIMAL_BASE);
870 
871  else if (strcmp(field_name, "port_meta") == 0)
872  match->parser_meta.port_id = (uint32_t)strtol(value, NULL, 0);
873 
874  else if (strcmp(field_name, "outer.eth.src_mac") == 0) {
876  if (result != DOCA_SUCCESS)
877  return result;
878  } else if (strcmp(field_name, "outer.eth.dst_mac") == 0) {
880  if (result != DOCA_SUCCESS)
881  return result;
882  } else if (strcmp(field_name, "outer.eth.type") == 0)
883  match->outer.eth.type = (uint16_t)strtol(value, NULL, HEXADECIMAL_BASE);
884 
885  else if (strcmp(field_name, "outer.eth_vlan[0].tci") == 0)
886  match->outer.eth_vlan[0].tci = (uint16_t)strtol(value, NULL, 0);
887 
888  else if (strcmp(field_name, "outer.eth_vlan[1].tci") == 0)
889  match->outer.eth_vlan[1].tci = (uint16_t)strtol(value, NULL, 0);
890 
891  else if (strcmp(field_name, "outer.l3_type") == 0) {
892  result = parse_l3_type(value, &match->outer.l3_type);
893  if (result != DOCA_SUCCESS)
894  return result;
895  } else if (strcmp(field_name, "outer.src_ip_addr") == 0) {
896  if (match->outer.l3_type == DOCA_FLOW_L3_TYPE_IP4) {
898  if (result != DOCA_SUCCESS)
899  return result;
900  } else if (match->outer.l3_type == DOCA_FLOW_L3_TYPE_IP6) {
902  if (result != DOCA_SUCCESS)
903  return result;
904  } else {
905  DOCA_LOG_ERR("Source IP type is not set, need to set IP type before address");
907  }
908  } else if (strcmp(field_name, "outer.dst_ip_addr") == 0) {
909  if (match->outer.l3_type == DOCA_FLOW_L3_TYPE_IP4) {
911  if (result != DOCA_SUCCESS)
912  return result;
913  } else if (match->outer.l3_type == DOCA_FLOW_L3_TYPE_IP6) {
915  if (result != DOCA_SUCCESS)
916  return result;
917  } else {
918  DOCA_LOG_ERR("Destination IP type is not set, need to set IP type before address");
920  }
921  } else if (strcmp(field_name, "outer.l4_type_ext") == 0) {
923  if (result != DOCA_SUCCESS)
924  return result;
925  } else if (strcmp(field_name, "outer.tcp.flags") == 0) {
927  if (result != DOCA_SUCCESS)
928  return result;
929  } else if (strcmp(field_name, "outer.tcp_src_port") == 0) {
930  match->outer.tcp.l4_port.src_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
931  } else if (strcmp(field_name, "outer.tcp_dst_port") == 0) {
932  match->outer.tcp.l4_port.dst_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
933  } else if (strcmp(field_name, "outer.udp_src_port") == 0) {
934  match->outer.udp.l4_port.src_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
935  } else if (strcmp(field_name, "outer.udp_dst_port") == 0) {
936  match->outer.udp.l4_port.dst_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
937  } else if (strcmp(field_name, "tun_type") == 0) {
939  if (result != DOCA_SUCCESS)
940  return result;
941  } else if (strcmp(field_name, "vxlan_tun_id") == 0)
942  match->tun.vxlan_tun_id = strtol(value, NULL, 0);
943 
944  else if (strcmp(field_name, "gre_key") == 0)
945  match->tun.gre_key = strtol(value, NULL, 0);
946 
947  else if (strcmp(field_name, "gtp_teid") == 0)
948  match->tun.gtp_teid = strtol(value, NULL, 0);
949 
950  else if (strcmp(field_name, "inner.eth.src_mac") == 0) {
952  if (result != DOCA_SUCCESS)
953  return result;
954  } else if (strcmp(field_name, "inner.eth.dst_mac") == 0) {
956  if (result != DOCA_SUCCESS)
957  return result;
958  } else if (strcmp(field_name, "inner.eth.type") == 0)
959  match->inner.eth.type = (uint16_t)strtol(value, NULL, HEXADECIMAL_BASE);
960 
961  else if (strcmp(field_name, "inner.eth_vlan[0].tci") == 0)
962  match->inner.eth_vlan[0].tci = (uint16_t)strtol(value, NULL, 0);
963 
964  else if (strcmp(field_name, "inner.eth_vlan[1].tci") == 0)
965  match->inner.eth_vlan[1].tci = (uint16_t)strtol(value, NULL, 0);
966 
967  else if (strcmp(field_name, "inner.l3_type") == 0) {
968  result = parse_l3_type(value, &match->inner.l3_type);
969  if (result != DOCA_SUCCESS)
970  return result;
971  } else if (strcmp(field_name, "inner.src_ip_addr") == 0) {
972  if (match->inner.l3_type == DOCA_FLOW_L3_TYPE_IP4) {
974  if (result != DOCA_SUCCESS)
975  return result;
976  } else if (match->inner.l3_type == DOCA_FLOW_L3_TYPE_IP6) {
978  if (result != DOCA_SUCCESS)
979  return result;
980  } else {
981  DOCA_LOG_ERR("Inner source IP type is not set, need to set IP type before address");
983  }
984  } else if (strcmp(field_name, "inner.dst_ip_addr") == 0) {
985  if (match->inner.l3_type == DOCA_FLOW_L3_TYPE_IP4) {
987  if (result != DOCA_SUCCESS)
988  return result;
989  } else if (match->inner.l3_type == DOCA_FLOW_L3_TYPE_IP6) {
991  if (result != DOCA_SUCCESS)
992  return result;
993  } else {
994  DOCA_LOG_ERR("Inner destination IP type is not set, need to set IP type before address");
996  }
997  } else if (strcmp(field_name, "inner.l4_type_ext") == 0) {
999  if (result != DOCA_SUCCESS)
1000  return result;
1001  } else if (strcmp(field_name, "inner.tcp.flags") == 0) {
1003  if (result != DOCA_SUCCESS)
1004  return result;
1005  } else if (strcmp(field_name, "inner.tcp_src_port") == 0) {
1006  match->outer.tcp.l4_port.src_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
1007  } else if (strcmp(field_name, "inner.tcp_dst_port") == 0) {
1008  match->outer.tcp.l4_port.dst_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
1009  } else if (strcmp(field_name, "inner.udp_src_port") == 0) {
1010  match->outer.udp.l4_port.src_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
1011  } else if (strcmp(field_name, "inner.udp_dst_port") == 0) {
1012  match->outer.udp.l4_port.dst_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
1013  } else {
1014  DOCA_LOG_ERR("The %s is not supported field in match", field_name);
1015  return DOCA_ERROR_INVALID_VALUE;
1016  }
1017  return DOCA_SUCCESS;
1018 }
1019 
1020 /*
1021  * Parse DOCA Flow match field
1022  *
1023  * @field_name [in]: Field to parse
1024  * @value [in]: Value to read
1025  * @struct_ptr [out]: Match struct to fill
1026  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1027  */
1028 static doca_error_t parse_fw_match_field(char *field_name, char *value, void *struct_ptr)
1029 {
1031  struct doca_flow_match *match = (struct doca_flow_match *)struct_ptr;
1032 
1034  if (strcmp(field_name, "outer.src_ip_addr") == 0) {
1035  result = parse_ipv4_str(value, &match->outer.ip4.src_ip);
1036  if (result != DOCA_SUCCESS)
1037  return result;
1038  } else if (strcmp(field_name, "outer.dst_ip_addr") == 0) {
1039  result = parse_ipv4_str(value, &match->outer.ip4.dst_ip);
1040  if (result != DOCA_SUCCESS)
1041  return result;
1042  } else if (strcmp(field_name, "outer.l4_type_ext") == 0) {
1044  if (result != DOCA_SUCCESS)
1045  return result;
1046  } else if (strcmp(field_name, "outer.tcp_src_port") == 0) {
1047  match->outer.tcp.l4_port.src_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
1048  } else if (strcmp(field_name, "outer.tcp_dst_port") == 0) {
1049  match->outer.tcp.l4_port.dst_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
1050  } else if (strcmp(field_name, "outer.udp_src_port") == 0) {
1051  match->outer.udp.l4_port.src_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
1052  } else if (strcmp(field_name, "outer.udp_dst_port") == 0) {
1053  match->outer.udp.l4_port.dst_port = rte_cpu_to_be_16(strtol(value, NULL, 0));
1054  } else {
1055  DOCA_LOG_ERR("The %s is not supported field in match", field_name);
1056  return DOCA_ERROR_INVALID_VALUE;
1057  }
1058  return DOCA_SUCCESS;
1059 }
1060 
1061 /*
1062  * Parse DOCA Flow struct
1063  *
1064  * @struct_str [in]: Struct to parse
1065  * @fill_struct [in]: Function callback to do the actual filling
1066  * @struct_ptr [out]: Struct to fill
1067  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1068  */
1069 static doca_error_t parse_struct(char *struct_str,
1070  doca_error_t (*fill_struct)(char *, char *, void *),
1071  void *struct_ptr)
1072 {
1074  char ptr[MAX_CMDLINE_INPUT_LEN];
1075  char *tmp;
1076  char field_name[MAX_FIELD_INPUT_LEN];
1077  char value[MAX_FIELD_INPUT_LEN];
1078  char tmp_char;
1079 
1080  do {
1081  strlcpy(ptr, struct_str, MAX_CMDLINE_INPUT_LEN);
1082  tmp = strtok(ptr, "=");
1083  if (tmp == NULL) {
1084  DOCA_LOG_ERR("Invalid format for create struct command");
1085  return DOCA_ERROR_INVALID_VALUE;
1086  }
1087  strlcpy(field_name, tmp, MAX_FIELD_INPUT_LEN);
1088  struct_str += strlen(field_name) + 1;
1089 
1090  strlcpy(ptr, struct_str, MAX_CMDLINE_INPUT_LEN);
1091  tmp = strtok(ptr, ",");
1092  if (tmp == NULL) {
1093  DOCA_LOG_ERR("Invalid format for create struct command");
1094  return DOCA_ERROR_INVALID_VALUE;
1095  }
1097 
1098  DOCA_LOG_DBG("The parsing result are field_name: %s, value: %s", field_name, value);
1099 
1100  struct_str += strlen(value);
1101  tmp_char = struct_str[0];
1102  struct_str++;
1103  result = (*fill_struct)(field_name, value, struct_ptr);
1104  if (result != DOCA_SUCCESS)
1105  return result;
1106 
1107  } while (tmp_char == ',');
1108 
1109  return DOCA_SUCCESS;
1110 }
1111 
1112 /*
1113  * Parse boolean user input
1114  *
1115  * @params_str [in]: String to parse
1116  * @param_str_len [in]: Length of boolean value
1117  * @take_action [out]: Boolean to fill
1118  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1119  */
1120 static doca_error_t parse_bool_params_input(char **params_str, int param_str_len, bool *take_action)
1121 {
1122  int value;
1123  char *ptr;
1124 
1125  *params_str += param_str_len;
1126 
1127  value = strtol(*params_str, &ptr, 0);
1128  if (ptr == *params_str)
1129  return DOCA_ERROR_INVALID_VALUE;
1130  if (value == 1)
1131  *take_action = true;
1132  else if (value != 0)
1133  return DOCA_ERROR_BAD_STATE;
1134 
1135  *params_str += 1;
1136 
1137  return DOCA_SUCCESS;
1138 }
1139 
1140 /*
1141  * Parse create pipe parameters
1142  *
1143  * @params_str [in]: String to parse
1144  * @cfg [out]: DOCA Flow pipe configuration
1145  * @fwd_action [out]: Boolean to indicate if forward is needed
1146  * @fwd_miss_action [out]: Boolean to indicate if forward miss is needed
1147  * @is_match_mask [out]: Boolean to indicate if match mask is needed
1148  * @type [out]: The pipe type that was set
1149  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1150  */
1151 static doca_error_t parse_create_pipe_params(char *params_str,
1152  struct doca_flow_pipe_cfg *cfg,
1153  bool *fwd_action,
1154  bool *fwd_miss_action,
1155  bool *is_match_mask,
1156  enum doca_flow_pipe_type *type)
1157 {
1159  char ptr[MAX_CMDLINE_INPUT_LEN];
1160  char *param_str_value;
1161  char *type_str;
1162  char *end;
1163  int value;
1164  char tmp_char;
1165  bool has_port_id = false;
1166  bool take_action = false;
1167 
1168  do {
1169  if (strncmp(params_str, "port_id=", PORT_ID_STR_LEN) == 0) {
1170  params_str += PORT_ID_STR_LEN;
1171  strlcpy(ptr, params_str, MAX_CMDLINE_INPUT_LEN);
1172  value = strtol(ptr, &end, 0);
1173  if (end == ptr) {
1174  DOCA_LOG_ERR("Invalid port_id");
1175  return DOCA_ERROR_INVALID_VALUE;
1176  }
1177  param_str_value = strtok(ptr, ",");
1178  params_str += strlen(param_str_value);
1179  pipe_port_id = value;
1180  has_port_id = true;
1181  } else if (strncmp(params_str, "name=", NAME_STR_LEN) == 0) {
1182  params_str += NAME_STR_LEN;
1183  strlcpy(ptr, params_str, MAX_CMDLINE_INPUT_LEN);
1184  param_str_value = strtok(ptr, ",");
1185  params_str += strlen(param_str_value);
1186  result = doca_flow_pipe_cfg_set_name(cfg, param_str_value);
1187  if (result != DOCA_SUCCESS) {
1188  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg name: %s", doca_error_get_descr(result));
1189  return result;
1190  }
1191  } else if (strncmp(params_str, "root_enable=", ROOT_ENABLE_STR_LEN) == 0) {
1192  result = parse_bool_params_input(&params_str, ROOT_ENABLE_STR_LEN, &take_action);
1193  if (result != DOCA_SUCCESS) {
1194  DOCA_LOG_ERR("The param root_enable must be 1 for using or 0 for not");
1195  return result;
1196  }
1197  if (take_action) {
1199  if (result != DOCA_SUCCESS) {
1200  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg is_root: %s",
1202  return result;
1203  }
1204  }
1205  take_action = false;
1206  } else if (strncmp(params_str, "monitor=", MONITOR_STR_LEN) == 0) {
1207  result = parse_bool_params_input(&params_str, MONITOR_STR_LEN, &take_action);
1208  if (result != DOCA_SUCCESS) {
1209  DOCA_LOG_ERR("Monitor must be 1 for using or 0 for not");
1210  return result;
1211  }
1212  if (take_action) {
1214  if (result != DOCA_SUCCESS) {
1215  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg monitor: %s",
1217  return result;
1218  }
1219  }
1220  take_action = false;
1221  } else if (strncmp(params_str, "match_mask=", MATCH_MASK_STR_LEN) == 0) {
1222  result = parse_bool_params_input(&params_str, MATCH_MASK_STR_LEN, &take_action);
1223  if (result != DOCA_SUCCESS) {
1224  DOCA_LOG_ERR("The param match_mask value must be 1 for using or 0 for not");
1225  return result;
1226  }
1227  if (take_action)
1228  *is_match_mask = true;
1229  take_action = false;
1230  } else if (strncmp(params_str, "fwd_miss=", MISS_FWD_STR_LEN) == 0) {
1231  result = parse_bool_params_input(&params_str, MISS_FWD_STR_LEN, fwd_miss_action);
1232  if (result != DOCA_SUCCESS) {
1233  DOCA_LOG_ERR("The param fwd_miss value must be 1 for using or 0 for not");
1234  return result;
1235  }
1236  } else if (strncmp(params_str, "fwd=", FWD_STR_LEN) == 0) {
1237  result = parse_bool_params_input(&params_str, FWD_STR_LEN, fwd_action);
1238  if (result != DOCA_SUCCESS) {
1239  DOCA_LOG_ERR("FWD value must be 1 for using or 0 for not");
1240  return result;
1241  }
1242  } else if (strncmp(params_str, "type=", TYPE_STR_LEN) == 0) {
1243  params_str += TYPE_STR_LEN;
1244  strlcpy(ptr, params_str, MAX_FIELD_INPUT_LEN);
1245  type_str = strtok(ptr, ",");
1246  result = parse_pipe_type(type_str, cfg, type);
1247  if (result != DOCA_SUCCESS)
1248  return result;
1249  params_str += strlen(type_str);
1250  } else {
1251  strlcpy(ptr, params_str, MAX_FIELD_INPUT_LEN);
1252  param_str_value = strtok(ptr, "=");
1253  DOCA_LOG_ERR("The %s is not a valid parameter for create pipe command", param_str_value);
1254  return DOCA_ERROR_INVALID_VALUE;
1255  }
1256  tmp_char = params_str[0];
1257  params_str++;
1258  } while (tmp_char == ',');
1259 
1260  if (!has_port_id) {
1261  DOCA_LOG_ERR("The param port_id is a mandatory input and was not given");
1262  return result;
1263  }
1264  return DOCA_SUCCESS;
1265 }
1266 
1267 /*
1268  * Parse add entry parameters
1269  *
1270  * @params_str [in]: String to parse
1271  * @fwd_action [out]: Boolean to indicate if forward is needed
1272  * @monitor_action [out]: Boolean to indicate if monitor action is needed
1273  * @pipe_id [out]: Pipe ID
1274  * @pipe_queue [out]: Pipe queue number
1275  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1276  */
1277 static doca_error_t parse_add_entry_params(char *params_str,
1278  bool *fwd_action,
1279  bool *monitor_action,
1280  uint64_t *pipe_id,
1281  int *pipe_queue)
1282 {
1284  char tmp_char;
1285  char ptr[MAX_CMDLINE_INPUT_LEN];
1286  char *tmp;
1287  char *param_str_name;
1288  bool has_pipe_id = false;
1289  bool has_pipe_queue = false;
1290  do {
1291  if (strncmp(params_str, "pipe_id=", PIPE_ID_STR_LEN) == 0) {
1292  params_str += PIPE_ID_STR_LEN;
1293  tmp = params_str;
1294  *pipe_id = strtoull(tmp, &params_str, 0);
1295  has_pipe_id = true;
1296  } else if (strncmp(params_str, "pipe_queue=", PIPE_QUEUE_STR_LEN) == 0) {
1297  params_str += PIPE_QUEUE_STR_LEN;
1298  tmp = params_str;
1299  *pipe_queue = strtol(tmp, &params_str, 0);
1300  has_pipe_queue = true;
1301  } else if (strncmp(params_str, "monitor=", MONITOR_STR_LEN) == 0) {
1302  result = parse_bool_params_input(&params_str, MONITOR_STR_LEN, monitor_action);
1303  if (result != DOCA_SUCCESS) {
1304  DOCA_LOG_ERR("FWD value must be 1 for using or 0 for not");
1305  return DOCA_ERROR_INVALID_VALUE;
1306  }
1307  } else if (strncmp(params_str, "fwd=", FWD_STR_LEN) == 0) {
1308  result = parse_bool_params_input(&params_str, FWD_STR_LEN, fwd_action);
1309  if (result != DOCA_SUCCESS) {
1310  DOCA_LOG_ERR("FWD value must be 1 for using or 0 for not");
1311  return DOCA_ERROR_INVALID_VALUE;
1312  }
1313  } else {
1314  strlcpy(ptr, params_str, MAX_CMDLINE_INPUT_LEN);
1315  param_str_name = strtok(ptr, "=");
1316  DOCA_LOG_ERR("The %s is not a valid parameter for pipe add entry command", param_str_name);
1317  return DOCA_ERROR_INVALID_VALUE;
1318  }
1319  tmp_char = params_str[0];
1320  params_str++;
1321  } while (tmp_char == ',');
1322 
1323  if (!has_pipe_id) {
1324  DOCA_LOG_ERR("The param pipe_id is a mandatory input and was not given");
1325  return DOCA_ERROR_INVALID_VALUE;
1326  }
1327 
1328  if (!has_pipe_queue) {
1329  DOCA_LOG_ERR("The param pipe_queue is a mandatory input and was not given");
1330  return DOCA_ERROR_INVALID_VALUE;
1331  }
1332 
1333  return DOCA_SUCCESS;
1334 }
1335 
1336 /*
1337  * Parse FW add entry parameters
1338  *
1339  * @params_str [in]: String to parse
1340  * @port_id [out]: Port ID
1341  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1342  */
1343 static doca_error_t parse_fw_add_entry_params(char *params_str, uint16_t *port_id)
1344 {
1345  char *param_str_name;
1346  bool has_port_id = false;
1347  char *tmp;
1348 
1349  if (strncmp(params_str, "port_id=", PORT_ID_STR_LEN) == 0) {
1350  params_str += PORT_ID_STR_LEN;
1351  tmp = params_str;
1352  *port_id = strtoull(tmp, &params_str, 0);
1353  has_port_id = true;
1354  } else {
1355  param_str_name = strtok(params_str, "=");
1356  DOCA_LOG_ERR("The %s is not a valid parameter for pipe add entry command", param_str_name);
1357  return DOCA_ERROR_INVALID_VALUE;
1358  }
1359 
1360  if (!has_port_id) {
1361  DOCA_LOG_ERR("The param port_id is a mandatory input and was not given");
1362  return DOCA_ERROR_INVALID_VALUE;
1363  }
1364 
1365  return DOCA_SUCCESS;
1366 }
1367 
1368 /*
1369  * Parse add control pipe entry parameters
1370  *
1371  * @params_str [in]: String to parse
1372  * @fwd_action [out]: Boolean to indicate if forward is needed
1373  * @match_mask_action [out]: Boolean to indicate if mask action is needed
1374  * @pipe_id [out]: Pipe ID
1375  * @pipe_queue [out]: Pipe queue number
1376  * @priority [out]: DOCA Flow priority
1377  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1378  */
1380  bool *fwd_action,
1381  bool *match_mask_action,
1382  uint64_t *pipe_id,
1383  uint16_t *pipe_queue,
1384  uint8_t *priority)
1385 {
1387  char tmp_char;
1388  char *param_str_name;
1389  char *tmp;
1390  bool has_pipe_id = false;
1391  bool has_pipe_queue = false;
1392  bool has_priority = false;
1393 
1394  do {
1395  if (strncmp(params_str, "pipe_id=", PIPE_ID_STR_LEN) == 0) {
1396  params_str += PIPE_ID_STR_LEN;
1397  tmp = params_str;
1398  *pipe_id = strtoull(tmp, &params_str, 0);
1399  has_pipe_id = true;
1400  } else if (strncmp(params_str, "pipe_queue=", PIPE_QUEUE_STR_LEN) == 0) {
1401  params_str += PIPE_QUEUE_STR_LEN;
1402  tmp = params_str;
1403  *pipe_queue = strtol(tmp, &params_str, 0);
1404  has_pipe_queue = true;
1405  } else if (strncmp(params_str, "priority=", PRIORITY_STR_LEN) == 0) {
1406  params_str += PRIORITY_STR_LEN;
1407  tmp = params_str;
1408  *priority = strtol(tmp, &params_str, 0);
1409  has_priority = true;
1410  } else if (strncmp(params_str, "match_mask=", MATCH_MASK_STR_LEN) == 0) {
1411  result = parse_bool_params_input(&params_str, MATCH_MASK_STR_LEN, match_mask_action);
1412  if (result != DOCA_SUCCESS) {
1413  DOCA_LOG_ERR("The param match_mask value must be 1 for using or 0 for not");
1414  return DOCA_ERROR_INVALID_VALUE;
1415  }
1416  } else if (strncmp(params_str, "fwd=", FWD_STR_LEN) == 0) {
1417  result = parse_bool_params_input(&params_str, FWD_STR_LEN, fwd_action);
1418  if (result != DOCA_SUCCESS) {
1419  DOCA_LOG_ERR("The param fwd value must be 1 for using or 0 for not");
1420  return DOCA_ERROR_INVALID_VALUE;
1421  }
1422  } else {
1423  param_str_name = strtok(params_str, "=");
1424  DOCA_LOG_ERR("The param %s is not a valid parameter for control pipe add entry command",
1425  param_str_name);
1426  return DOCA_ERROR_INVALID_VALUE;
1427  }
1428  tmp_char = params_str[0];
1429  params_str++;
1430  } while (tmp_char == ',');
1431 
1432  if (!has_pipe_id) {
1433  DOCA_LOG_ERR("The param pipe_id is a mandatory input and was not given");
1434  return DOCA_ERROR_INVALID_VALUE;
1435  }
1436 
1437  if (!has_pipe_queue) {
1438  DOCA_LOG_ERR("The param pipe_queue is a mandatory input and was not given");
1439  return DOCA_ERROR_INVALID_VALUE;
1440  }
1441 
1442  if (!has_priority) {
1443  DOCA_LOG_ERR("Priority is a mandatory input and was not given");
1444  return DOCA_ERROR_INVALID_VALUE;
1445  }
1446  return DOCA_SUCCESS;
1447 }
1448 
1449 /*
1450  * Parse entry parameters
1451  *
1452  * @params [in]: String to parse
1453  * @pipe_queue_mandatory [in]: Boolean to indicate if pipe queue is mandatory
1454  * @pipe_queue [out]: Pipe queue number
1455  * @entry_id [out]: Entry ID
1456  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1457  */
1458 static doca_error_t parse_entry_params(char *params, bool pipe_queue_mandatory, uint16_t *pipe_queue, uint64_t *entry_id)
1459 {
1460  char tmp_char;
1461  char *param_str_name;
1462  char *tmp;
1463  bool has_pipe_queue = false;
1464  bool has_entry_id = false;
1465 
1466  do {
1467  if (strncmp(params, "pipe_queue=", PIPE_QUEUE_STR_LEN) == 0) {
1468  params += PIPE_QUEUE_STR_LEN;
1469  tmp = params;
1470  if (pipe_queue != NULL)
1471  *pipe_queue = strtol(tmp, &params, 0);
1472  has_pipe_queue = true;
1473  } else if (strncmp(params, "entry_id=", ENTRY_ID_STR_LEN) == 0) {
1474  params += ENTRY_ID_STR_LEN;
1475  tmp = params;
1476  *entry_id = strtoull(tmp, &params, 0);
1477  has_entry_id = true;
1478  } else {
1479  param_str_name = strtok(params, "=");
1480  DOCA_LOG_ERR("The param %s is not a valid parameter for rm/query entry command",
1481  param_str_name);
1482  return DOCA_ERROR_INVALID_VALUE;
1483  }
1484  tmp_char = params[0];
1485  params++;
1486  } while (tmp_char == ',');
1487 
1488  if (pipe_queue_mandatory && !has_pipe_queue) {
1489  DOCA_LOG_ERR("The param pipe_queue is a mandatory input and was not given");
1490  return DOCA_ERROR_INVALID_VALUE;
1491  }
1492 
1493  if (!has_entry_id) {
1494  DOCA_LOG_ERR("The param entry_id is a mandatory input and was not given");
1495  return DOCA_ERROR_INVALID_VALUE;
1496  }
1497  return DOCA_SUCCESS;
1498 }
1499 
1500 /*
1501  * Parse FW entry parameters
1502  *
1503  * @params [in]: String to parse
1504  * @entry_id [out]: Entry ID
1505  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1506  */
1507 static doca_error_t parse_fw_entry_params(char *params, uint64_t *entry_id)
1508 {
1509  char *param_str_name;
1510  char *tmp;
1511  bool has_entry_id = false;
1512 
1513  if (strncmp(params, "entry_id=", ENTRY_ID_STR_LEN) == 0) {
1514  params += ENTRY_ID_STR_LEN;
1515  tmp = params;
1516  *entry_id = strtoull(tmp, &params, 0);
1517  has_entry_id = true;
1518  } else {
1519  param_str_name = strtok(params, "=");
1520  DOCA_LOG_ERR("The param %s is not a valid parameter for rm entry command", param_str_name);
1521  return DOCA_ERROR_INVALID_VALUE;
1522  }
1523 
1524  if (!has_entry_id) {
1525  DOCA_LOG_ERR("The param entry_id is a mandatory input and was not given");
1526  return DOCA_ERROR_INVALID_VALUE;
1527  }
1528  return DOCA_SUCCESS;
1529 }
1530 
1531 /*
1532  * Parse dump pipe parameters
1533  *
1534  * @params [in]: String to parse
1535  * @port_id [out]: Port ID
1536  * @file [out]: File to dump information into
1537  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
1538  */
1539 static doca_error_t parse_dump_pipe_params(char *params, uint16_t *port_id, FILE **file)
1540 {
1541  char tmp_char;
1542  char *name;
1543  char ptr[MAX_CMDLINE_INPUT_LEN];
1544  char *param_str_name;
1545  char *tmp;
1546  bool has_port_id = false;
1547  bool has_file = false;
1548 
1549  do {
1550  if (strncmp(params, "port_id=", PORT_ID_STR_LEN) == 0) {
1551  params += PORT_ID_STR_LEN;
1552  tmp = params;
1553  *port_id = strtol(tmp, &params, 0);
1554  has_port_id = true;
1555  } else if (strncmp(params, "file=", FILE_STR_LEN) == 0) {
1556  if (has_file) {
1557  DOCA_LOG_ERR("File should be provided only once");
1558  fclose(*file);
1559  *file = NULL;
1560  return DOCA_ERROR_INVALID_VALUE;
1561  }
1562  params += FILE_STR_LEN;
1563  strlcpy(ptr, params, MAX_CMDLINE_INPUT_LEN);
1564  name = strtok(ptr, ",");
1565  params += strlen(name);
1566  *file = fopen(name, "w");
1567  if (*file == NULL) {
1568  DOCA_LOG_ERR("Failed opening the file %s", name);
1569  return DOCA_ERROR_INVALID_VALUE;
1570  }
1571  has_file = true;
1572  } else {
1573  param_str_name = strtok(params, "=");
1574  DOCA_LOG_ERR("The param %s is not a valid parameter for port pipes dump command",
1575  param_str_name);
1576  return DOCA_ERROR_INVALID_VALUE;
1577  }
1578  tmp_char = params[0];
1579  params++;
1580  } while (tmp_char == ',');
1581 
1582  if (!has_port_id) {
1583  DOCA_LOG_ERR("The param port_id is a mandatory input and was not given");
1584  return DOCA_ERROR_INVALID_VALUE;
1585  }
1586 
1587  if (!has_file) {
1588  DOCA_LOG_DBG("The param file name was not given, default name is port_info.txt");
1589  *file = fopen("port_info.txt", "w");
1590  if (*file == NULL) {
1591  DOCA_LOG_ERR("Failed opening the file port_info.txt");
1592  return DOCA_ERROR_IO_FAILED;
1593  }
1594  }
1595  return DOCA_SUCCESS;
1596 }
1597 
1598 /*
1599  * Parse create pipe command and call command's callback
1600  *
1601  * @parsed_result [in]: Command line interface input with user input
1602  */
1603 static void cmd_create_pipe_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
1604 {
1605  struct cmd_create_pipe_result *create_pipe_data = (struct cmd_create_pipe_result *)parsed_result;
1606  struct doca_flow_fwd *tmp_fwd = NULL;
1607  struct doca_flow_fwd *tmp_fwd_miss = NULL;
1608  struct doca_flow_pipe_cfg *pipe_cfg;
1609  struct doca_flow_actions *actions_arr[1];
1610  bool is_fwd = false;
1611  bool is_fwd_miss = false;
1612  bool is_match_mask = false;
1615 
1616  if (create_pipe_func == NULL) {
1617  DOCA_LOG_ERR("Pipe creation action was not inserted");
1618  return;
1619  }
1620 
1622  if (result != DOCA_SUCCESS) {
1623  DOCA_LOG_ERR("Failed to create doca_flow_pipe_cfg: %s", doca_error_get_descr(result));
1624  return;
1625  }
1626 
1627  result = parse_create_pipe_params(create_pipe_data->params,
1628  pipe_cfg,
1629  &is_fwd,
1630  &is_fwd_miss,
1631  &is_match_mask,
1632  &type);
1633  if (result != DOCA_SUCCESS)
1634  goto destroy_pipe_cfg;
1635  if (type != DOCA_FLOW_PIPE_CONTROL) {
1636  result = doca_flow_pipe_cfg_set_match(pipe_cfg, &pipe_match, is_match_mask ? &match_mask : NULL);
1637  if (result != DOCA_SUCCESS) {
1638  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg match: %s", doca_error_get_descr(result));
1639  goto destroy_pipe_cfg;
1640  }
1641  actions_arr[0] = &actions;
1642  result = doca_flow_pipe_cfg_set_actions(pipe_cfg, actions_arr, NULL, NULL, 1);
1643  if (result != DOCA_SUCCESS) {
1644  DOCA_LOG_ERR("Failed to set doca_flow_pipe_cfg actions: %s", doca_error_get_descr(result));
1645  goto destroy_pipe_cfg;
1646  }
1647  }
1648  if (is_fwd)
1649  tmp_fwd = &fwd;
1650 
1651  if (is_fwd_miss)
1652  tmp_fwd_miss = &fwd_miss;
1653 
1654  (*create_pipe_func)(pipe_cfg, pipe_port_id, tmp_fwd, fwd_next_pipe_id, tmp_fwd_miss, fwd_miss_next_pipe_id);
1655 
1657  doca_flow_pipe_cfg_destroy(pipe_cfg);
1658 }
1659 
1660 /* Define the token of create */
1661 static cmdline_parse_token_string_t cmd_create_pipe_create_tok =
1662  TOKEN_STRING_INITIALIZER(struct cmd_create_pipe_result, create, "create");
1663 
1664 /* Define the token of pipe */
1665 static cmdline_parse_token_string_t cmd_create_pipe_pipe_tok =
1666  TOKEN_STRING_INITIALIZER(struct cmd_create_pipe_result, pipe, "pipe");
1667 
1668 /* Define the token of optional params */
1669 static cmdline_parse_token_string_t cmd_create_pipe_optional_fields_tok =
1670  TOKEN_STRING_INITIALIZER(struct cmd_create_pipe_result, params, NULL);
1671 
1672 /* Define create pipe command structure for parsing */
1673 static cmdline_parse_inst_t cmd_create_pipe = {
1674  .f = cmd_create_pipe_parsed, /* Function to call */
1675  .data = NULL, /* 2nd arg of func */
1676  .help_str = "create pipe port_id=[port_id],[optional params]", /* Command print usage */
1677  .tokens =
1678  {
1679  /* Token list, NULL terminated */
1680  (void *)&cmd_create_pipe_create_tok,
1681  (void *)&cmd_create_pipe_pipe_tok,
1683  NULL,
1684  },
1685 };
1686 
1687 /*
1688  * Parse add entry command and call command's callback
1689  *
1690  * @parsed_result [in]: Command line interface input with user input
1691  */
1692 static void cmd_add_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
1693 {
1694  struct cmd_add_entry_result *add_entry_data = (struct cmd_add_entry_result *)parsed_result;
1695  struct doca_flow_fwd *tmp_fwd = NULL;
1696  struct doca_flow_monitor *tmp_monitor = NULL;
1697  bool is_fwd = false;
1698  bool is_monitor = false;
1699  uint64_t pipe_id = 0;
1700  int pipe_queue = 0;
1702 
1703  if (add_entry_func == NULL) {
1704  DOCA_LOG_ERR("Entry creation action was not inserted");
1705  return;
1706  }
1707 
1708  result = parse_add_entry_params(add_entry_data->params, &is_fwd, &is_monitor, &pipe_id, &pipe_queue);
1709  if (result != DOCA_SUCCESS)
1710  return;
1711 
1712  if (is_fwd)
1713  tmp_fwd = &fwd;
1714 
1715  if (is_monitor)
1716  tmp_monitor = &monitor;
1717 
1718  (*add_entry_func)(pipe_queue,
1719  pipe_id,
1720  &entry_match,
1721  &actions,
1722  tmp_monitor,
1723  tmp_fwd,
1726 }
1727 
1728 /*
1729  * Parse FW add entry command and call command's callback
1730  *
1731  * @parsed_result [in]: Command line interface input with user input
1732  */
1733 static void cmd_fw_add_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
1734 {
1735  struct cmd_add_entry_result *add_entry_data = (struct cmd_add_entry_result *)parsed_result;
1736  uint16_t port_id = 0;
1738 
1739  if (add_fw_entry_func == NULL) {
1740  DOCA_LOG_ERR("Entry creation action was not inserted");
1741  return;
1742  }
1743 
1744  result = parse_fw_add_entry_params(add_entry_data->params, &port_id);
1745  if (result != DOCA_SUCCESS)
1746  return;
1747 
1748  (*add_fw_entry_func)(port_id, &entry_match);
1749 }
1750 
1751 /* Define the token of add */
1752 static cmdline_parse_token_string_t cmd_add_entry_add_tok =
1753  TOKEN_STRING_INITIALIZER(struct cmd_add_entry_result, add, "add");
1754 
1755 /* Define the token of entry */
1756 static cmdline_parse_token_string_t cmd_add_entry_entry_tok =
1757  TOKEN_STRING_INITIALIZER(struct cmd_add_entry_result, entry, "entry");
1758 
1759 /* Define the token of optional params */
1760 static cmdline_parse_token_string_t cmd_add_entry_optional_fields_tok =
1761  TOKEN_STRING_INITIALIZER(struct cmd_add_entry_result, params, NULL);
1762 
1763 /* Define add entry command structure for parsing */
1764 static cmdline_parse_inst_t cmd_add_entry = {
1765  .f = cmd_add_entry_parsed, /* Function to call */
1766  .data = NULL, /* 2nd arg of func */
1767  .help_str = "add entry pipe_id=[pipe_id],pipe_queue=[pipe_queue],[optional fields]", /* Command print usage */
1768  .tokens =
1769  {
1770  /* Token list, NULL terminated */
1771  (void *)&cmd_add_entry_add_tok,
1772  (void *)&cmd_add_entry_entry_tok,
1774  NULL,
1775  },
1776 };
1777 
1778 /* Define add entry command structure for parsing for the FW application */
1779 static cmdline_parse_inst_t cmd_fw_add_entry = {
1780  .f = cmd_fw_add_entry_parsed, /* Function to call */
1781  .data = NULL, /* 2nd arg of func */
1782  .help_str = "add entry port_id=[port_id]", /* Command print usage */
1783  .tokens =
1784  {
1785  /* Token list, NULL terminated */
1786  (void *)&cmd_add_entry_add_tok,
1787  (void *)&cmd_add_entry_entry_tok,
1789  NULL,
1790  },
1791 };
1792 
1793 /*
1794  * Parse add control pipe entry command and call command's callback
1795  *
1796  * @parsed_result [in]: Command line interface input with user input
1797  */
1798 static void cmd_add_control_pipe_entry_parsed(void *parsed_result,
1799  __rte_unused struct cmdline *cl,
1800  __rte_unused void *data)
1801 {
1802  struct cmd_add_control_pipe_entry_result *add_entry_data =
1803  (struct cmd_add_control_pipe_entry_result *)parsed_result;
1804  struct doca_flow_fwd *tmp_fwd = NULL;
1805  struct doca_flow_match *tmp_match_mask = NULL;
1806  bool is_fwd = false;
1807  bool is_match_mask = false;
1808  uint64_t pipe_id = 0;
1809  uint16_t pipe_queue = 0;
1810  uint8_t priority = 0;
1812 
1814  DOCA_LOG_ERR("Control pipe entry creation action was not inserted");
1815  return;
1816  }
1817 
1819  &is_fwd,
1820  &is_match_mask,
1821  &pipe_id,
1822  &pipe_queue,
1823  &priority);
1824  if (result != DOCA_SUCCESS)
1825  return;
1826 
1827  if (is_fwd)
1828  tmp_fwd = &fwd;
1829  if (is_match_mask)
1830  tmp_match_mask = &match_mask;
1831 
1832  (*add_control_pipe_entry_func)(pipe_queue,
1833  priority,
1834  pipe_id,
1835  &entry_match,
1836  tmp_match_mask,
1837  tmp_fwd,
1839 }
1840 
1841 /* Define the token of add */
1842 static cmdline_parse_token_string_t cmd_add_control_pipe_entry_add_tok =
1843  TOKEN_STRING_INITIALIZER(struct cmd_add_control_pipe_entry_result, add, "add");
1844 
1845 /* Define the token of control_pipe */
1846 static cmdline_parse_token_string_t cmd_add_control_pipe_entry_control_pipe_tok =
1847  TOKEN_STRING_INITIALIZER(struct cmd_add_control_pipe_entry_result, control_pipe, "control_pipe");
1848 
1849 /* Define the token of entry */
1850 static cmdline_parse_token_string_t cmd_add_control_pipe_entry_entry_tok =
1851  TOKEN_STRING_INITIALIZER(struct cmd_add_control_pipe_entry_result, entry, "entry");
1852 
1853 /* Define the token of optional params */
1854 static cmdline_parse_token_string_t cmd_add_control_pipe_entry_optional_fields_tok =
1855  TOKEN_STRING_INITIALIZER(struct cmd_add_control_pipe_entry_result, params, NULL);
1856 
1857 /* Define add control pipe entry command structure for parsing */
1858 static cmdline_parse_inst_t cmd_add_control_pipe_entry = {
1859  .f = cmd_add_control_pipe_entry_parsed, /* Function to call */
1860  .data = NULL, /* 2nd arg of func */
1861  .help_str = /* Command print usage */
1862  "add control_pipe entry priority=[priority],port_id=[port_id],pipe_id=[pipe_id],pipe_queue=[pipe_queue],[optional fields]",
1863  .tokens =
1864  {
1865  /* Token list, NULL terminated */
1870  NULL,
1871  },
1872 };
1873 
1874 /*
1875  * Parse destroy pipe command and call command's callback
1876  *
1877  * @parsed_result [in]: Command line interface input with user input
1878  */
1879 static void cmd_destroy_pipe_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
1880 {
1881  struct cmd_destroy_pipe_result *destroy_pipe_data = (struct cmd_destroy_pipe_result *)parsed_result;
1882  uint64_t pipe_id;
1884 
1885  if (destroy_pipe_func == NULL) {
1886  DOCA_LOG_ERR("Pipe destruction action was not inserted");
1887  return;
1888  }
1889 
1890  result = parse_pipe_id_input(destroy_pipe_data->params, &pipe_id);
1891  if (result != DOCA_SUCCESS)
1892  return;
1893 
1894  (*destroy_pipe_func)(pipe_id);
1895 }
1896 
1897 /* Define the token of destroy */
1898 static cmdline_parse_token_string_t cmd_destroy_pipe_destroy_tok =
1899  TOKEN_STRING_INITIALIZER(struct cmd_destroy_pipe_result, destroy, "destroy");
1900 
1901 /* Define the token of pipe */
1902 static cmdline_parse_token_string_t cmd_destroy_pipe_pipe_tok =
1903  TOKEN_STRING_INITIALIZER(struct cmd_destroy_pipe_result, pipe, "pipe");
1904 
1905 /* Define the token of optional params */
1906 static cmdline_parse_token_string_t cmd_destroy_pipe_params_tok =
1907  TOKEN_STRING_INITIALIZER(struct cmd_destroy_pipe_result, params, NULL);
1908 
1909 /* Define destroy pipe command structure for parsing */
1910 static cmdline_parse_inst_t cmd_destroy_pipe = {
1911  .f = cmd_destroy_pipe_parsed, /* Function to call */
1912  .data = NULL, /* 2nd arg of func */
1913  .help_str = "destroy pipe pipe_id=[pipe_id]", /* Command print usage */
1914  .tokens =
1915  {
1916  /* Token list, NULL terminated */
1918  (void *)&cmd_destroy_pipe_pipe_tok,
1919  (void *)&cmd_destroy_pipe_params_tok,
1920  NULL,
1921  },
1922 };
1923 
1924 /*
1925  * Parse remove entry command and call command's callback
1926  *
1927  * @parsed_result [in]: Command line interface input with user input
1928  */
1929 static void cmd_rm_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
1930 {
1931  struct cmd_rm_entry_result *rm_entry_data = (struct cmd_rm_entry_result *)parsed_result;
1932  uint64_t entry_id = 0;
1933  uint16_t pipe_queue = 0;
1935 
1936  if (remove_entry_func == NULL) {
1937  DOCA_LOG_ERR("Entry destruction action was not inserted");
1938  return;
1939  }
1940 
1941  result = parse_entry_params(rm_entry_data->params, true, &pipe_queue, &entry_id);
1942  if (result != DOCA_SUCCESS)
1943  return;
1944 
1945  (*remove_entry_func)(pipe_queue, entry_id, DOCA_FLOW_NO_WAIT);
1946 }
1947 
1948 /*
1949  * Parse FW remove entry command and call command's callback
1950  *
1951  * @parsed_result [in]: Command line interface input with user input
1952  */
1953 static void cmd_fw_rm_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
1954 {
1955  struct cmd_rm_entry_result *rm_entry_data = (struct cmd_rm_entry_result *)parsed_result;
1956  uint64_t entry_id = 0;
1958 
1959  if (remove_fw_entry_func == NULL) {
1960  DOCA_LOG_ERR("Entry destruction action was not inserted");
1961  return;
1962  }
1963 
1964  result = parse_fw_entry_params(rm_entry_data->params, &entry_id);
1965  if (result != DOCA_SUCCESS)
1966  return;
1967 
1968  (*remove_fw_entry_func)(entry_id);
1969 }
1970 
1971 /* Define the token of remove */
1972 static cmdline_parse_token_string_t cmd_rm_entry_rm_tok =
1973  TOKEN_STRING_INITIALIZER(struct cmd_rm_entry_result, rm, "rm");
1974 
1975 /* Define the token of entry */
1976 static cmdline_parse_token_string_t cmd_rm_entry_entry_tok =
1977  TOKEN_STRING_INITIALIZER(struct cmd_rm_entry_result, entry, "entry");
1978 
1979 /* Define the token of optional params */
1980 static cmdline_parse_token_string_t cmd_rm_entry_params_tok =
1981  TOKEN_STRING_INITIALIZER(struct cmd_rm_entry_result, params, NULL);
1982 
1983 /* Define remove entry command structure for parsing */
1984 static cmdline_parse_inst_t cmd_rm_entry = {
1985  .f = cmd_rm_entry_parsed, /* Function to call */
1986  .data = NULL, /* 2nd arg of func */
1987  .help_str = "rm entry pipe_queue=[pipe_queue],entry_id=[entry_id]", /* Command print usage */
1988  .tokens =
1989  {
1990  /* Token list, NULL terminated */
1991  (void *)&cmd_rm_entry_rm_tok,
1992  (void *)&cmd_rm_entry_entry_tok,
1993  (void *)&cmd_rm_entry_params_tok,
1994  NULL,
1995  },
1996 };
1997 
1998 /* Define remove entry command structure for parsing for the FW application */
1999 static cmdline_parse_inst_t cmd_fw_rm_entry = {
2000  .f = cmd_fw_rm_entry_parsed, /* Function to call */
2001  .data = NULL, /* 2nd arg of func */
2002  .help_str = "rm entry entry_id=[entry_id]", /* Command print usage */
2003  .tokens =
2004  {
2005  /* Token list, NULL terminated */
2006  (void *)&cmd_rm_entry_rm_tok,
2007  (void *)&cmd_rm_entry_entry_tok,
2008  (void *)&cmd_rm_entry_params_tok,
2009  NULL,
2010  },
2011 };
2012 
2013 /*
2014  * Parse flush pipes command and call command's callback
2015  *
2016  * @parsed_result [in]: Command line interface input with user input
2017  */
2018 static void cmd_flush_pipes_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
2019 {
2020  struct cmd_flush_pipes_result *flush_pipes_data = (struct cmd_flush_pipes_result *)parsed_result;
2021  int port_id;
2023 
2024  if (port_pipes_flush_func == NULL) {
2025  DOCA_LOG_ERR("Pipes flushing action was not inserted");
2026  return;
2027  }
2028 
2029  result = parse_port_id_input(flush_pipes_data->port_id, &port_id);
2030  if (result != DOCA_SUCCESS)
2031  return;
2032 
2033  (*port_pipes_flush_func)(port_id);
2034 }
2035 
2036 /* Define the token of port */
2037 static cmdline_parse_token_string_t cmd_flush_pipes_port_tok =
2038  TOKEN_STRING_INITIALIZER(struct cmd_flush_pipes_result, port, "port");
2039 
2040 /* Define the token of pipes */
2041 static cmdline_parse_token_string_t cmd_flush_pipes_pipes_tok =
2042  TOKEN_STRING_INITIALIZER(struct cmd_flush_pipes_result, pipes, "pipes");
2043 
2044 /* Define the token of flush */
2045 static cmdline_parse_token_string_t cmd_flush_pipes_flush_tok =
2046  TOKEN_STRING_INITIALIZER(struct cmd_flush_pipes_result, flush, "flush");
2047 
2048 /* Define the token of optional params */
2049 static cmdline_parse_token_string_t cmd_flush_pipes_port_id_tok =
2050  TOKEN_STRING_INITIALIZER(struct cmd_flush_pipes_result, port_id, NULL);
2051 
2052 /* Define flush pipes command structure for parsing */
2053 static cmdline_parse_inst_t cmd_flush_pipe = {
2054  .f = cmd_flush_pipes_parsed, /* Function to call */
2055  .data = NULL, /* 2nd arg of func */
2056  .help_str = "port pipes flush port_id=[port_id]", /* Command print usage */
2057  .tokens =
2058  {
2059  /* Token list, NULL terminated */
2060  (void *)&cmd_flush_pipes_port_tok,
2061  (void *)&cmd_flush_pipes_pipes_tok,
2062  (void *)&cmd_flush_pipes_flush_tok,
2063  (void *)&cmd_flush_pipes_port_id_tok,
2064  NULL,
2065  },
2066 };
2067 
2068 /*
2069  * Parse query command and call command's callback
2070  *
2071  * @parsed_result [in]: Command line interface input with user input
2072  */
2073 static void cmd_query_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
2074 {
2075  struct cmd_query_result *query_data = (struct cmd_query_result *)parsed_result;
2076  struct doca_flow_resource_query query_stats;
2077  uint64_t entry_id = 0;
2079 
2080  if (query_func == NULL) {
2081  DOCA_LOG_ERR("Query action was not inserted");
2082  return;
2083  }
2084 
2085  result = parse_entry_params(query_data->params, false, NULL, &entry_id);
2086  if (result != DOCA_SUCCESS)
2087  return;
2088 
2089  (*query_func)(entry_id, &query_stats);
2090 
2091  DOCA_LOG_INFO("Total bytes: %ld", query_stats.counter.total_bytes);
2092  DOCA_LOG_INFO("Total packets: %ld", query_stats.counter.total_pkts);
2093 }
2094 
2095 /* Define the token of query */
2096 static cmdline_parse_token_string_t cmd_query_query_tok =
2097  TOKEN_STRING_INITIALIZER(struct cmd_query_result, query, "query");
2098 
2099 /* Define the token of optional params */
2100 static cmdline_parse_token_string_t cmd_query_params_tok =
2101  TOKEN_STRING_INITIALIZER(struct cmd_query_result, params, NULL);
2102 
2103 /* Define entry query command structure for parsing */
2104 static cmdline_parse_inst_t cmd_query = {
2105  .f = cmd_query_parsed, /* Function to call */
2106  .data = NULL, /* 2nd arg of func */
2107  .help_str = "query entry_id=[entry_id]", /* Command print usage */
2108  .tokens =
2109  {
2110  /* Token list, NULL terminated */
2111  (void *)&cmd_query_query_tok,
2112  (void *)&cmd_query_params_tok,
2113  NULL,
2114  },
2115 };
2116 
2117 /*
2118  * Parse dump pipe command and call command's callback
2119  *
2120  * @parsed_result [in]: Command line interface input with user input
2121  */
2122 static void cmd_dump_pipe_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
2123 {
2124  struct cmd_dump_pipe_result *dump_pipe_data = (struct cmd_dump_pipe_result *)parsed_result;
2125  uint16_t port_id = 0;
2126  FILE *fd = NULL;
2128 
2129  if (port_pipes_dump_func == NULL) {
2130  DOCA_LOG_ERR("Pipe dumping action was not inserted");
2131  return;
2132  }
2133 
2134  result = parse_dump_pipe_params(dump_pipe_data->params, &port_id, &fd);
2135  if (result != DOCA_SUCCESS) {
2136  if (fd)
2137  fclose(fd);
2138  return;
2139  }
2140 
2141  (*port_pipes_dump_func)(port_id, fd);
2142 
2143  fclose(fd);
2144 }
2145 
2146 /* Define the token of port */
2147 static cmdline_parse_token_string_t cmd_port_pipes_dump_port_tok =
2148  TOKEN_STRING_INITIALIZER(struct cmd_dump_pipe_result, port, "port");
2149 
2150 /* Define the token of pipes */
2151 static cmdline_parse_token_string_t cmd_port_pipes_dump_pipes_tok =
2152  TOKEN_STRING_INITIALIZER(struct cmd_dump_pipe_result, pipes, "pipes");
2153 
2154 /* Define the token of dump */
2155 static cmdline_parse_token_string_t cmd_port_pipes_dump_dump_tok =
2156  TOKEN_STRING_INITIALIZER(struct cmd_dump_pipe_result, dump, "dump");
2157 
2158 /* Define the token of optional params */
2159 static cmdline_parse_token_string_t cmd_dump_pipe_params_tok =
2160  TOKEN_STRING_INITIALIZER(struct cmd_dump_pipe_result, params, NULL);
2161 
2162 /* Define dump pipe command structure for parsing */
2163 static cmdline_parse_inst_t cmd_dump_pipe = {
2164  .f = cmd_dump_pipe_parsed, /* Function to call */
2165  .data = NULL, /* 2nd arg of func */
2166  .help_str = "port pipes dump port_id=[port_id],file=[file name]", /* Command print usage */
2167  .tokens =
2168  {
2169  /* Token list, NULL terminated */
2173  (void *)&cmd_dump_pipe_params_tok,
2174  NULL,
2175  },
2176 };
2177 
2178 /*
2179  * Parse create DOCA Flow struct command
2180  *
2181  * @parsed_result [in]: Command line interface input with user input
2182  */
2183 static void cmd_create_struct_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
2184 {
2185  struct cmd_create_struct_result *struct_data = (struct cmd_create_struct_result *)parsed_result;
2186 
2187  if (strcmp(struct_data->flow_struct, "pipe_match") == 0) {
2188  memset(&pipe_match, 0, sizeof(pipe_match));
2189  parse_struct(struct_data->flow_struct_input, &parse_match_field, (void *)&pipe_match);
2190  } else if (strcmp(struct_data->flow_struct, "entry_match") == 0) {
2191  memset(&entry_match, 0, sizeof(entry_match));
2192  parse_struct(struct_data->flow_struct_input, &parse_match_field, (void *)&entry_match);
2193  } else if (strcmp(struct_data->flow_struct, "match_mask") == 0) {
2194  memset(&match_mask, 0, sizeof(match_mask));
2195  parse_struct(struct_data->flow_struct_input, &parse_match_field, (void *)&match_mask);
2196  } else if (strcmp(struct_data->flow_struct, "actions") == 0) {
2197  memset(&actions, 0, sizeof(actions));
2198  parse_struct(struct_data->flow_struct_input, &parse_actions_field, (void *)&actions);
2199  } else if (strcmp(struct_data->flow_struct, "monitor") == 0) {
2200  memset(&monitor, 0, sizeof(monitor));
2201  parse_struct(struct_data->flow_struct_input, &parse_monitor_field, (void *)&monitor);
2202  } else if (strcmp(struct_data->flow_struct, "fwd") == 0) {
2203  memset(&fwd, 0, sizeof(fwd));
2204  parse_struct(struct_data->flow_struct_input, &parse_fwd_field, (void *)&fwd);
2205  } else if (strcmp(struct_data->flow_struct, "fwd_miss") == 0) {
2206  memset(&fwd_miss, 0, sizeof(fwd_miss));
2207  parse_struct(struct_data->flow_struct_input, &parse_fwd_miss_field, (void *)&fwd_miss);
2208  }
2209 }
2210 
2211 /* Define the token of create */
2212 static cmdline_parse_token_string_t cmd_create_struct_update_tok =
2213  TOKEN_STRING_INITIALIZER(struct cmd_create_struct_result, create, "create");
2214 
2215 /* Define the token of flow type */
2216 static cmdline_parse_token_string_t cmd_create_struct_struct_tok =
2217  TOKEN_STRING_INITIALIZER(struct cmd_create_struct_result,
2218  flow_struct,
2219  "pipe_match#entry_match#match_mask#actions#monitor#fwd#fwd_miss");
2220 
2221 /* Define the token of flow structure */
2222 static cmdline_parse_token_string_t cmd_create_struct_input_tok =
2223  TOKEN_STRING_INITIALIZER(struct cmd_create_struct_result, flow_struct_input, TOKEN_STRING_MULTI);
2224 
2225 static cmdline_parse_inst_t cmd_update_struct = {
2226  .f = cmd_create_struct_parsed, /* Function to call */
2227  .data = NULL, /* 2nd arg of func */
2228  .help_str = /* Command print usage */
2229  "create pipe_match|entry_match|match_mask|actions|monitor|fwd|fwd_miss <struct fields>",
2230  .tokens =
2231  {
2232  /* Token list, NULL terminated */
2235  (void *)&cmd_create_struct_input_tok,
2236  NULL,
2237  },
2238 };
2239 
2240 /*
2241  * Parse create DOCA Flow struct command for FW app
2242  *
2243  * @parsed_result [in]: Command line interface input with user input
2244  */
2245 static void cmd_fw_create_struct_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
2246 {
2247  struct cmd_create_struct_result *struct_data = (struct cmd_create_struct_result *)parsed_result;
2248 
2249  memset(&entry_match, 0, sizeof(entry_match));
2251 }
2252 
2253 /* Define the token of flow type */
2254 static cmdline_parse_token_string_t cmd_fw_create_struct_struct_tok =
2255  TOKEN_STRING_INITIALIZER(struct cmd_create_struct_result, flow_struct, "entry_match");
2256 
2257 /* Define the token of flow structure */
2258 static cmdline_parse_token_string_t cmd_fw_create_struct_input_tok =
2259  TOKEN_STRING_INITIALIZER(struct cmd_create_struct_result, flow_struct_input, TOKEN_STRING_MULTI);
2260 
2261 static cmdline_parse_inst_t cmd_fw_create_match_struct = {
2262  .f = cmd_fw_create_struct_parsed, /* Function to call */
2263  .data = NULL, /* 2nd arg of func */
2264  .help_str = /* Command print usage */
2265  "create entry_match <struct fields>",
2266  .tokens =
2267  {
2268  /* Token list, NULL terminated */
2272  NULL,
2273  },
2274 };
2275 
2276 /*
2277  * Quit command line interface
2278  *
2279  * @cl [in]: Command line
2280  */
2281 static void cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data)
2282 {
2283  cmdline_quit(cl);
2284 }
2285 
2286 /* Define the token of quit */
2287 static cmdline_parse_token_string_t cmd_quit_tok = TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
2288 
2289 /* Define quit command structure for parsing */
2290 static cmdline_parse_inst_t cmd_quit = {
2291  .f = cmd_quit_parsed, /* Function to call */
2292  .data = NULL, /* 2nd arg of func */
2293  .help_str = "Exit application", /* Command print usage */
2294  .tokens =
2295  {
2296  /* Token list, NULL terminated */
2297  (void *)&cmd_quit_tok,
2298  NULL,
2299  },
2300 };
2301 
2302 /* Command line interface context */
2303 static cmdline_parse_ctx_t main_ctx[] = {
2304  (cmdline_parse_inst_t *)&cmd_quit,
2305  (cmdline_parse_inst_t *)&cmd_update_struct,
2306  (cmdline_parse_inst_t *)&cmd_create_pipe,
2307  (cmdline_parse_inst_t *)&cmd_add_entry,
2308  (cmdline_parse_inst_t *)&cmd_add_control_pipe_entry,
2309  (cmdline_parse_inst_t *)&cmd_destroy_pipe,
2310  (cmdline_parse_inst_t *)&cmd_rm_entry,
2311  (cmdline_parse_inst_t *)&cmd_flush_pipe,
2312  (cmdline_parse_inst_t *)&cmd_dump_pipe,
2313  (cmdline_parse_inst_t *)&cmd_query,
2314  NULL,
2315 };
2316 
2317 /* CLI Subset for the FW application */
2318 static cmdline_parse_ctx_t fw_subset_ctx[] = {
2319  (cmdline_parse_inst_t *)&cmd_quit,
2320  (cmdline_parse_inst_t *)&cmd_fw_create_match_struct,
2321  (cmdline_parse_inst_t *)&cmd_fw_add_entry,
2322  (cmdline_parse_inst_t *)&cmd_fw_rm_entry,
2323  (cmdline_parse_inst_t *)&cmd_flush_pipe,
2324  (cmdline_parse_inst_t *)&cmd_dump_pipe,
2325  NULL,
2326 };
2327 
2328 doca_error_t flow_parser_init(char *shell_prompt, bool fw_subset)
2329 {
2330  struct cmdline *cl = NULL;
2331 
2333 
2334  if (!fw_subset)
2335  cl = cmdline_stdin_new(main_ctx, shell_prompt);
2336  else
2337  cl = cmdline_stdin_new(fw_subset_ctx, shell_prompt);
2338 
2339  if (cl == NULL)
2340  return DOCA_ERROR_INVALID_VALUE;
2341  cmdline_interact(cl);
2342  cmdline_stdin_exit(cl);
2343 
2344  return DOCA_SUCCESS;
2345 }
2346 
2348 {
2349  if (rss_queues)
2350  free(rss_queues);
2351 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
#define MAX_FIELD_INPUT_LEN
Definition: flow_parser.c:47
static doca_error_t parse_tun_type_string(const char *tun_type_str, enum doca_flow_tun_type *tun_type)
Definition: flow_parser.c:348
static cmdline_parse_token_string_t cmd_port_pipes_dump_port_tok
Definition: flow_parser.c:2147
static cmdline_parse_token_string_t cmd_rm_entry_entry_tok
Definition: flow_parser.c:1976
#define PRIORITY_STR_LEN
Definition: flow_parser.c:58
static doca_error_t parse_monitor_field(char *field_name, char *value, void *struct_ptr)
Definition: flow_parser.c:605
#define ROOT_ENABLE_STR_LEN
Definition: flow_parser.c:53
#define PIPE_ID_STR_LEN
Definition: flow_parser.c:55
static doca_error_t parse_fw_match_field(char *field_name, char *value, void *struct_ptr)
Definition: flow_parser.c:1028
static void cmd_fw_rm_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:1953
static struct doca_flow_fwd fwd_miss
Definition: flow_parser.c:110
static cmdline_parse_inst_t cmd_quit
Definition: flow_parser.c:2290
static doca_error_t parse_fwd_field(char *field_name, char *value, void *struct_ptr)
Definition: flow_parser.c:637
static void(* port_pipes_flush_func)(uint16_t)
Definition: flow_parser.c:78
static cmdline_parse_inst_t cmd_add_entry
Definition: flow_parser.c:1764
static cmdline_parse_token_string_t cmd_fw_create_struct_input_tok
Definition: flow_parser.c:2258
static void cmd_query_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:2073
static doca_error_t parse_mac_address(char *mac_addr_str, uint8_t *mac_addr)
Definition: flow_parser.c:521
static void cmd_create_pipe_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:1603
#define MONITOR_STR_LEN
Definition: flow_parser.c:52
static doca_error_t parse_entry_params(char *params, bool pipe_queue_mandatory, uint16_t *pipe_queue, uint64_t *entry_id)
Definition: flow_parser.c:1458
#define PORT_ID_STR_LEN
Definition: flow_parser.c:54
static cmdline_parse_token_string_t cmd_destroy_pipe_params_tok
Definition: flow_parser.c:1906
static struct doca_flow_match pipe_match
Definition: flow_parser.c:104
static void(* remove_entry_func)(uint16_t, uint64_t, uint32_t)
Definition: flow_parser.c:76
static cmdline_parse_token_string_t cmd_destroy_pipe_pipe_tok
Definition: flow_parser.c:1902
static void cmd_add_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:1692
static cmdline_parse_token_string_t cmd_dump_pipe_params_tok
Definition: flow_parser.c:2159
void set_pipe_control_add_entry(void(*action)(uint16_t, uint8_t, uint64_t, struct doca_flow_match *, struct doca_flow_match *, struct doca_flow_fwd *, uint64_t))
Definition: flow_parser.c:213
static doca_error_t parse_ipv6_str(const char *str_ip, doca_be32_t *ipv6_addr)
Definition: flow_parser.c:547
static doca_error_t parse_fwd_rss_type(const char *rss_type_str, enum doca_flow_resource_type *type)
Definition: flow_parser.c:394
static void cmd_rm_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:1929
static doca_error_t parse_add_control_pipe_entry_params(char *params_str, bool *fwd_action, bool *match_mask_action, uint64_t *pipe_id, uint16_t *pipe_queue, uint8_t *priority)
Definition: flow_parser.c:1379
static doca_error_t parse_dump_pipe_params(char *params, uint16_t *port_id, FILE **file)
Definition: flow_parser.c:1539
static doca_error_t parse_add_entry_params(char *params_str, bool *fwd_action, bool *monitor_action, uint64_t *pipe_id, int *pipe_queue)
Definition: flow_parser.c:1277
doca_error_t parse_protocol_string(const char *protocol_str, enum doca_flow_l4_type_ext *protocol)
Definition: flow_parser.c:292
static cmdline_parse_inst_t cmd_fw_add_entry
Definition: flow_parser.c:1779
static void cmd_create_struct_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:2183
#define NAME_STR_LEN
Definition: flow_parser.c:48
static uint16_t * rss_queues
Definition: flow_parser.c:114
static cmdline_parse_token_string_t cmd_add_entry_optional_fields_tok
Definition: flow_parser.c:1760
static cmdline_parse_inst_t cmd_update_struct
Definition: flow_parser.c:2225
static void cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:2281
void set_pipe_destroy(void(*action)(uint64_t))
Definition: flow_parser.c:224
#define MAX_CMDLINE_INPUT_LEN
Definition: flow_parser.c:44
static uint64_t fwd_miss_next_pipe_id
Definition: flow_parser.c:113
doca_error_t parse_ipv4_str(const char *str_ip, doca_be32_t *ipv4_addr)
Definition: flow_parser.c:268
static cmdline_parse_inst_t cmd_create_pipe
Definition: flow_parser.c:1673
static void cmd_flush_pipes_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:2018
static doca_error_t parse_fw_add_entry_params(char *params_str, uint16_t *port_id)
Definition: flow_parser.c:1343
static doca_error_t parse_pipe_id_input(char *pipe_id_str, uint64_t *pipe_id)
Definition: flow_parser.c:312
static cmdline_parse_inst_t cmd_fw_rm_entry
Definition: flow_parser.c:1999
static cmdline_parse_token_string_t cmd_flush_pipes_pipes_tok
Definition: flow_parser.c:2041
void set_query(void(*action)(uint64_t, struct doca_flow_resource_query *))
Definition: flow_parser.c:244
static void(* add_fw_entry_func)(uint16_t, struct doca_flow_match *)
Definition: flow_parser.c:95
void set_pipe_fw_add_entry(void(*action)(uint16_t, struct doca_flow_match *))
Definition: flow_parser.c:208
static cmdline_parse_token_string_t cmd_create_pipe_optional_fields_tok
Definition: flow_parser.c:1669
static doca_error_t parse_fw_entry_params(char *params, uint64_t *entry_id)
Definition: flow_parser.c:1507
#define MAC_ADDR_LEN
Definition: flow_parser.c:45
static void(* port_pipes_dump_func)(uint16_t, FILE *)
Definition: flow_parser.c:80
static cmdline_parse_token_string_t cmd_rm_entry_rm_tok
Definition: flow_parser.c:1972
static doca_error_t parse_actions_field(char *field_name, char *value, void *struct_ptr)
Definition: flow_parser.c:731
void set_pipe_add_entry(void(*action)(uint16_t, uint64_t, struct doca_flow_match *, struct doca_flow_actions *, struct doca_flow_monitor *, struct doca_flow_fwd *, uint64_t, uint32_t))
Definition: flow_parser.c:196
static void(* create_pipe_func)(struct doca_flow_pipe_cfg *, uint16_t, struct doca_flow_fwd *, uint64_t, struct doca_flow_fwd *, uint64_t)
Definition: flow_parser.c:81
static cmdline_parse_inst_t cmd_query
Definition: flow_parser.c:2104
#define UINT32_CHANGEABLE_FIELD
Definition: flow_parser.c:62
static struct doca_flow_actions actions
Definition: flow_parser.c:107
static cmdline_parse_token_string_t cmd_flush_pipes_flush_tok
Definition: flow_parser.c:2045
static cmdline_parse_token_string_t cmd_create_struct_update_tok
Definition: flow_parser.c:2212
static cmdline_parse_inst_t cmd_rm_entry
Definition: flow_parser.c:1984
static cmdline_parse_token_string_t cmd_create_struct_struct_tok
Definition: flow_parser.c:2216
#define FWD_STR_LEN
Definition: flow_parser.c:49
static cmdline_parse_token_string_t cmd_add_control_pipe_entry_entry_tok
Definition: flow_parser.c:1850
static cmdline_parse_inst_t cmd_destroy_pipe
Definition: flow_parser.c:1910
void set_pipe_fw_rm_entry(void(*action)(uint64_t))
Definition: flow_parser.c:234
static cmdline_parse_token_string_t cmd_fw_create_struct_struct_tok
Definition: flow_parser.c:2254
static cmdline_parse_token_string_t cmd_add_entry_add_tok
Definition: flow_parser.c:1752
#define TYPE_STR_LEN
Definition: flow_parser.c:60
doca_error_t flow_parser_init(char *shell_prompt, bool fw_subset)
Definition: flow_parser.c:2328
static void(* remove_fw_entry_func)(uint64_t)
Definition: flow_parser.c:77
static void cmd_fw_create_struct_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:2245
void set_port_pipes_flush(void(*action)(uint16_t))
Definition: flow_parser.c:239
void set_pipe_rm_entry(void(*action)(uint16_t, uint64_t, uint32_t))
Definition: flow_parser.c:229
static cmdline_parse_token_string_t cmd_flush_pipes_port_tok
Definition: flow_parser.c:2037
static cmdline_parse_token_string_t cmd_port_pipes_dump_dump_tok
Definition: flow_parser.c:2155
void set_port_pipes_dump(void(*action)(uint16_t, FILE *))
Definition: flow_parser.c:249
static cmdline_parse_token_string_t cmd_quit_tok
Definition: flow_parser.c:2287
static cmdline_parse_token_string_t cmd_add_control_pipe_entry_optional_fields_tok
Definition: flow_parser.c:1854
static void(* add_entry_func)(uint16_t, uint64_t, struct doca_flow_match *, struct doca_flow_actions *, struct doca_flow_monitor *, struct doca_flow_fwd *, uint64_t, uint32_t)
Definition: flow_parser.c:87
static cmdline_parse_inst_t cmd_dump_pipe
Definition: flow_parser.c:2163
static cmdline_parse_token_string_t cmd_create_struct_input_tok
Definition: flow_parser.c:2222
static cmdline_parse_token_string_t cmd_query_params_tok
Definition: flow_parser.c:2100
static cmdline_parse_token_string_t cmd_create_pipe_create_tok
Definition: flow_parser.c:1661
static doca_error_t parse_match_field(char *field_name, char *value, void *struct_ptr)
Definition: flow_parser.c:863
#define PIPE_QUEUE_STR_LEN
Definition: flow_parser.c:57
static cmdline_parse_token_string_t cmd_port_pipes_dump_pipes_tok
Definition: flow_parser.c:2151
static cmdline_parse_token_string_t cmd_add_entry_entry_tok
Definition: flow_parser.c:1756
static cmdline_parse_token_string_t cmd_create_pipe_pipe_tok
Definition: flow_parser.c:1665
#define BE_IPV4_ADDR(a, b, c, d)
Definition: flow_parser.c:64
static struct doca_flow_match entry_match
Definition: flow_parser.c:105
static doca_error_t parse_create_pipe_params(char *params_str, struct doca_flow_pipe_cfg *cfg, bool *fwd_action, bool *fwd_miss_action, bool *is_match_mask, enum doca_flow_pipe_type *type)
Definition: flow_parser.c:1151
static void cmd_destroy_pipe_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:1879
static cmdline_parse_token_string_t cmd_flush_pipes_port_id_tok
Definition: flow_parser.c:2049
void set_pipe_create(void(*action)(struct doca_flow_pipe_cfg *, uint16_t, struct doca_flow_fwd *, uint64_t, struct doca_flow_fwd *, uint64_t))
Definition: flow_parser.c:186
#define ENTRY_ID_STR_LEN
Definition: flow_parser.c:56
static struct doca_flow_monitor monitor
Definition: flow_parser.c:108
static void(* add_control_pipe_entry_func)(uint16_t, uint8_t, uint64_t, struct doca_flow_match *, struct doca_flow_match *, struct doca_flow_fwd *, uint64_t)
Definition: flow_parser.c:96
static struct doca_flow_fwd fwd
Definition: flow_parser.c:109
static void cmd_dump_pipe_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:2122
static doca_error_t parse_bool_params_input(char **params_str, int param_str_len, bool *take_action)
Definition: flow_parser.c:1120
static cmdline_parse_inst_t cmd_add_control_pipe_entry
Definition: flow_parser.c:1858
static void(* destroy_pipe_func)(uint64_t)
Definition: flow_parser.c:75
static void cmd_fw_add_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:1733
void flow_parser_cleanup(void)
Definition: flow_parser.c:2347
#define MISS_FWD_STR_LEN
Definition: flow_parser.c:50
static doca_error_t parse_rss_queues(char *rss_queues_str, int num_of_queues)
Definition: flow_parser.c:577
static doca_error_t parse_ip_type(const char *ip_type_str, enum doca_flow_l3_type *ip_type)
Definition: flow_parser.c:449
static doca_error_t parse_port_id_input(const char *port_id_str, int *port_id)
Definition: flow_parser.c:330
static cmdline_parse_token_string_t cmd_add_control_pipe_entry_add_tok
Definition: flow_parser.c:1842
static cmdline_parse_token_string_t cmd_rm_entry_params_tok
Definition: flow_parser.c:1980
DOCA_LOG_REGISTER(FLOW_PARSER)
static doca_error_t parse_struct(char *struct_str, doca_error_t(*fill_struct)(char *, char *, void *), void *struct_ptr)
Definition: flow_parser.c:1069
static cmdline_parse_token_string_t cmd_query_query_tok
Definition: flow_parser.c:2096
#define FILE_STR_LEN
Definition: flow_parser.c:59
#define HEXADECIMAL_BASE
Definition: flow_parser.c:61
static doca_error_t parse_l3_type(const char *l3_type_str, enum doca_flow_l3_type *l3_type)
Definition: flow_parser.c:469
static cmdline_parse_ctx_t main_ctx[]
Definition: flow_parser.c:2303
static void cmd_add_control_pipe_entry_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
Definition: flow_parser.c:1798
static doca_error_t parse_tcp_flag_string(const char *tcp_flag_str, uint8_t *tcp_flag)
Definition: flow_parser.c:489
#define MATCH_MASK_STR_LEN
Definition: flow_parser.c:51
#define IP_ADDR_LEN
Definition: flow_parser.c:46
static doca_error_t parse_fwd_type(const char *fwd_str, enum doca_flow_fwd_type *fwd)
Definition: flow_parser.c:370
static cmdline_parse_ctx_t fw_subset_ctx[]
Definition: flow_parser.c:2318
static uint16_t pipe_port_id
Definition: flow_parser.c:111
static doca_error_t parse_fwd_miss_field(char *field_name, char *value, void *struct_ptr)
Definition: flow_parser.c:684
static doca_error_t parse_pipe_type(const char *pipe_type, struct doca_flow_pipe_cfg *cfg, enum doca_flow_pipe_type *type)
Definition: flow_parser.c:415
static void(* query_func)(uint64_t, struct doca_flow_resource_query *)
Definition: flow_parser.c:79
static cmdline_parse_token_string_t cmd_destroy_pipe_destroy_tok
Definition: flow_parser.c:1898
static cmdline_parse_token_string_t cmd_add_control_pipe_entry_control_pipe_tok
Definition: flow_parser.c:1846
static uint64_t fwd_next_pipe_id
Definition: flow_parser.c:112
static cmdline_parse_inst_t cmd_fw_create_match_struct
Definition: flow_parser.c:2261
static struct doca_flow_match match_mask
Definition: flow_parser.c:106
static void reset_doca_flow_structs(void)
Definition: flow_parser.c:257
static cmdline_parse_inst_t cmd_flush_pipe
Definition: flow_parser.c:2053
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
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_INVALID_VALUE
Definition: doca_error.h:44
@ 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_ERROR_NO_MEMORY
Definition: doca_error.h:45
doca_flow_l4_type_ext
doca flow layer 4 packet extend type
doca_flow_l3_type
doca flow layer 3 packet type
doca_flow_tun_type
doca flow tunnel type
@ DOCA_FLOW_L4_TYPE_EXT_TCP
@ DOCA_FLOW_L4_TYPE_EXT_UDP
@ DOCA_FLOW_L3_TYPE_IP6
@ DOCA_FLOW_L3_TYPE_IP4
@ DOCA_FLOW_TUN_GRE
@ DOCA_FLOW_TUN_GTPU
@ DOCA_FLOW_TUN_VXLAN
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_pipe_cfg_set_name(struct doca_flow_pipe_cfg *cfg, const char *name)
Set pipe's name.
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_pipe_cfg_set_is_root(struct doca_flow_pipe_cfg *cfg, bool is_root)
Set if pipe is root or not.
doca_flow_pipe_type
doca flow pipe type
Definition: doca_flow.h:220
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_set_type(struct doca_flow_pipe_cfg *cfg, enum doca_flow_pipe_type type)
Set pipe's type.
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_flow_resource_type
doca flow resource type
Definition: doca_flow.h:612
doca_flow_fwd_type
forwarding action type
Definition: doca_flow.h:739
DOCA_STABLE struct doca_flow_port * doca_flow_port_switch_get(const struct doca_flow_port *port)
Get doca flow switch port.
@ 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_MATCH_TCP_FLAG_URG
Definition: doca_flow.h:413
@ DOCA_FLOW_MATCH_TCP_FLAG_FIN
Definition: doca_flow.h:403
@ DOCA_FLOW_MATCH_TCP_FLAG_ECE
Definition: doca_flow.h:415
@ DOCA_FLOW_MATCH_TCP_FLAG_CWR
Definition: doca_flow.h:417
@ DOCA_FLOW_MATCH_TCP_FLAG_RST
Definition: doca_flow.h:407
@ DOCA_FLOW_MATCH_TCP_FLAG_PSH
Definition: doca_flow.h:409
@ DOCA_FLOW_MATCH_TCP_FLAG_SYN
Definition: doca_flow.h:405
@ DOCA_FLOW_MATCH_TCP_FLAG_ACK
Definition: doca_flow.h:411
@ DOCA_FLOW_RESOURCE_TYPE_SHARED
Definition: doca_flow.h:614
@ 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_FWD_RSS
Definition: doca_flow.h:742
#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
#define DOCA_LOG_DBG(format,...)
Generates a DEBUG application log message.
Definition: doca_log.h:496
uint32_t doca_be32_t
Definition: doca_types.h:121
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
type value
uint8_t type
Definition: packets.h:0
Definition: flow_parser.c:131
cmdline_fixed_string_t add
Definition: flow_parser.c:132
cmdline_fixed_string_t entry
Definition: flow_parser.c:134
cmdline_fixed_string_t control_pipe
Definition: flow_parser.c:133
cmdline_fixed_string_t params
Definition: flow_parser.c:135
Definition: flow_parser.c:124
cmdline_fixed_string_t params
Definition: flow_parser.c:127
cmdline_fixed_string_t add
Definition: flow_parser.c:125
cmdline_fixed_string_t entry
Definition: flow_parser.c:126
cmdline_fixed_string_t params
Definition: flow_parser.c:120
cmdline_fixed_string_t create
Definition: flow_parser.c:118
cmdline_fixed_string_t pipe
Definition: flow_parser.c:119
cmdline_fixed_string_t flow_struct
Definition: flow_parser.c:177
cmdline_fixed_string_t create
Definition: flow_parser.c:176
cmdline_multi_string_t flow_struct_input
Definition: flow_parser.c:178
cmdline_fixed_string_t params
Definition: flow_parser.c:142
cmdline_fixed_string_t pipe
Definition: flow_parser.c:141
cmdline_fixed_string_t destroy
Definition: flow_parser.c:140
cmdline_fixed_string_t params
Definition: flow_parser.c:171
cmdline_fixed_string_t pipes
Definition: flow_parser.c:169
cmdline_fixed_string_t dump
Definition: flow_parser.c:170
cmdline_fixed_string_t port
Definition: flow_parser.c:168
cmdline_fixed_string_t pipes
Definition: flow_parser.c:155
cmdline_fixed_string_t flush
Definition: flow_parser.c:156
cmdline_fixed_string_t port
Definition: flow_parser.c:154
cmdline_fixed_string_t port_id
Definition: flow_parser.c:157
cmdline_fixed_string_t params
Definition: flow_parser.c:163
cmdline_fixed_string_t query
Definition: flow_parser.c:162
cmdline_fixed_string_t quit
Definition: flow_parser.c:183
Definition: flow_parser.c:146
cmdline_fixed_string_t entry
Definition: flow_parser.c:148
cmdline_fixed_string_t rm
Definition: flow_parser.c:147
cmdline_fixed_string_t params
Definition: flow_parser.c:149
doca flow actions information
Definition: doca_flow.h:684
struct doca_flow_resource_encap_cfg encap_cfg
Definition: doca_flow.h:710
struct doca_flow_header_format outer
Definition: doca_flow.h:703
struct doca_flow_tun tun
Definition: doca_flow.h:569
struct doca_flow_header_format outer
Definition: doca_flow.h:567
forwarding configuration
Definition: doca_flow.h:779
uint16_t port_id
Definition: doca_flow.h:795
enum doca_flow_fwd_type type
Definition: doca_flow.h:780
enum doca_flow_resource_type rss_type
Definition: doca_flow.h:784
struct doca_flow_resource_rss_cfg rss
Definition: doca_flow.h:787
uint8_t dst_mac[DOCA_FLOW_ETHER_ADDR_LEN]
uint8_t src_mac[DOCA_FLOW_ETHER_ADDR_LEN]
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_eth eth
Definition: doca_flow.h:440
struct doca_flow_header_eth_vlan eth_vlan[DOCA_FLOW_VLAN_MAX]
Definition: doca_flow.h:444
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_tcp tcp
Definition: doca_flow.h:461
struct doca_flow_header_ip6 ip6
Definition: doca_flow.h:451
doca_be32_t dst_ip[4]
doca_be32_t src_ip[4]
struct doca_flow_header_l4_port l4_port
struct doca_flow_header_l4_port l4_port
doca flow matcher information
Definition: doca_flow.h:491
struct doca_flow_header_format inner
Definition: doca_flow.h:502
struct doca_flow_parser_meta parser_meta
Definition: doca_flow.h:496
struct doca_flow_header_format outer
Definition: doca_flow.h:498
struct doca_flow_tun tun
Definition: doca_flow.h:500
uint32_t flags
Definition: doca_flow.h:492
doca monitor action configuration
Definition: doca_flow.h:968
struct doca_flow_monitor::@101::@105 non_shared_meter
enum doca_flow_resource_type counter_type
Definition: doca_flow.h:988
enum doca_flow_resource_type meter_type
Definition: doca_flow.h:969
uint32_t aging_sec
Definition: doca_flow.h:1000
struct doca_flow_encap_action encap
Definition: doca_flow.h:663
flow resource query
Definition: doca_flow.h:1101
struct doca_flow_resource_query::@115::@117 counter
enum doca_flow_tun_type type
doca_be32_t vxlan_tun_id
doca_be32_t gtp_teid
doca_be32_t gre_key
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: utils.c:123