NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_parser.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #ifndef COMMON_FLOW_PARSER_H_
27 #define COMMON_FLOW_PARSER_H_
28 
29 #include <doca_flow.h>
30 
31 /*
32  * Parse IPv4 string
33  *
34  * @str_ip [in]: String to parse
35  * @ipv4_addr [out]: Big endian IPv4 address
36  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
37  */
38 doca_error_t parse_ipv4_str(const char *str_ip, doca_be32_t *ipv4_addr);
39 
40 /*
41  * Parse network layer protocol
42  *
43  * @protocol_str [in]: String to parse
44  * @protocol [out]: Protocol identifier number
45  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
46  */
47 doca_error_t parse_protocol_string(const char *protocol_str, enum doca_flow_l4_type_ext *protocol);
48 
49 /*
50  * Set match l4 protocol
51  *
52  * @format [in]: outer or inner match format
53  * @protocol [in]: protocol
54  */
56 
57 /*
58  * Set the function to be called once pipe create command is entered
59  *
60  * @action [in]: Function callback
61  */
62 void set_pipe_create(void (*action)(struct doca_flow_pipe_cfg *cfg,
63  uint16_t port_id,
64  struct doca_flow_fwd *fwd,
65  uint64_t fw_pipe_id,
66  struct doca_flow_fwd *fwd_miss,
67  uint64_t fw_miss_pipe_id));
68 
69 /*
70  * Set the function to be called once add entry command is entered
71  *
72  * @action [in]: Function callback
73  */
74 void set_pipe_add_entry(void (*action)(uint16_t pipe_queue,
75  uint64_t pipe_id,
76  struct doca_flow_match *match,
77  struct doca_flow_actions *actions,
78  struct doca_flow_monitor *monitor,
79  struct doca_flow_fwd *fwd,
80  uint64_t fw_pipe_id,
81  uint32_t flags));
82 
83 /*
84  * Set the function to be called once add entry command is entered for the Firewall application
85  *
86  * @action [in]: Function callback
87  */
88 void set_pipe_fw_add_entry(void (*action)(uint16_t port_id, struct doca_flow_match *match));
89 
90 /*
91  * Set the function to be called once pipe control add entry command is entered
92  *
93  * @action [in]: Function callback
94  */
95 void set_pipe_control_add_entry(void (*action)(uint16_t pipe_queue,
96  uint8_t priority,
97  uint64_t pipe_id,
98  struct doca_flow_match *match,
100  struct doca_flow_fwd *fwd,
101  uint64_t fw_pipe_id));
102 
103 /*
104  * Set the function to be called once pipe destroy command is entered
105  *
106  * @action [in]: Function callback
107  */
108 void set_pipe_destroy(void (*action)(uint64_t pipe_id));
109 
110 /*
111  * Set the function to be called once remove entry command is entered
112  *
113  * @action [in]: Function callback
114  */
115 void set_pipe_rm_entry(void (*action)(uint16_t pipe_queue, uint64_t entry_id, uint32_t flags));
116 
117 /*
118  * Set the function to be called once FW remove entry command is entered
119  *
120  * @action [in]: Function callback
121  */
122 void set_pipe_fw_rm_entry(void (*action)(uint64_t entry_id));
123 
124 /*
125  * Set the function to be called once pipes flush command is entered
126  *
127  * @action [in]: Function callback
128  */
129 void set_port_pipes_flush(void (*action)(uint16_t port_id));
130 
131 /*
132  * Set the function to be called once set query command is entered
133  *
134  * @action [in]: Function callback
135  */
136 void set_query(void (*action)(uint64_t entry_id, struct doca_flow_resource_query *states));
137 
138 /*
139  * Set the function to be called once port pipes dump command is entered
140  *
141  * @action [in]: Function callback
142  */
143 void set_port_pipes_dump(void (*action)(uint16_t port_id, FILE *fd));
144 
145 /*
146  * Initialize parser and open the command line interface
147  *
148  * @shell_prompt [in]: String for the shell to prompt
149  * @fw_subset [in]: Boolean to decide what CLI should be supported
150  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
151  */
152 doca_error_t flow_parser_init(char *shell_prompt, bool fw_subset);
153 
154 /*
155  * Destroy flow parser structures
156  */
157 void flow_parser_cleanup(void);
158 
159 #endif /* COMMON_FLOW_PARSER_H_ */
static struct doca_flow_fwd fwd_miss
Definition: flow_parser.c:110
static struct doca_flow_actions actions
Definition: flow_parser.c:107
static struct doca_flow_monitor monitor
Definition: flow_parser.c:108
static struct doca_flow_fwd fwd
Definition: flow_parser.c:109
static struct doca_flow_match match_mask
Definition: flow_parser.c:106
void set_pipe_create(void(*action)(struct doca_flow_pipe_cfg *cfg, uint16_t port_id, struct doca_flow_fwd *fwd, uint64_t fw_pipe_id, struct doca_flow_fwd *fwd_miss, uint64_t fw_miss_pipe_id))
void set_pipe_fw_add_entry(void(*action)(uint16_t port_id, struct doca_flow_match *match))
doca_error_t parse_protocol_string(const char *protocol_str, enum doca_flow_l4_type_ext *protocol)
Definition: flow_parser.c:292
void set_pipe_destroy(void(*action)(uint64_t pipe_id))
doca_error_t parse_ipv4_str(const char *str_ip, doca_be32_t *ipv4_addr)
Definition: flow_parser.c:268
void set_pipe_control_add_entry(void(*action)(uint16_t pipe_queue, uint8_t priority, uint64_t pipe_id, struct doca_flow_match *match, struct doca_flow_match *match_mask, struct doca_flow_fwd *fwd, uint64_t fw_pipe_id))
void set_match_l4_protocol(struct doca_flow_header_format *format, uint8_t protocol)
void set_pipe_rm_entry(void(*action)(uint16_t pipe_queue, uint64_t entry_id, uint32_t flags))
void set_port_pipes_flush(void(*action)(uint16_t port_id))
doca_error_t flow_parser_init(char *shell_prompt, bool fw_subset)
Definition: flow_parser.c:2328
void set_pipe_fw_rm_entry(void(*action)(uint64_t entry_id))
void set_port_pipes_dump(void(*action)(uint16_t port_id, FILE *fd))
void set_pipe_add_entry(void(*action)(uint16_t pipe_queue, uint64_t pipe_id, struct doca_flow_match *match, struct doca_flow_actions *actions, struct doca_flow_monitor *monitor, struct doca_flow_fwd *fwd, uint64_t fw_pipe_id, uint32_t flags))
void flow_parser_cleanup(void)
Definition: flow_parser.c:2347
void set_query(void(*action)(uint64_t entry_id, struct doca_flow_resource_query *states))
enum doca_error doca_error_t
DOCA API return codes.
doca_flow_l4_type_ext
doca flow layer 4 packet extend type
uint32_t doca_be32_t
Definition: doca_types.h:121
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
doca flow actions information
Definition: doca_flow.h:684
forwarding configuration
Definition: doca_flow.h:779
doca flow packet format
Definition: doca_flow.h:439
doca flow matcher information
Definition: doca_flow.h:491
doca monitor action configuration
Definition: doca_flow.h:968
flow resource query
Definition: doca_flow.h:1101