2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #ifndef __INCLUDE_PIPELINE_CGNAPT_COMMON_H__
18 #define __INCLUDE_PIPELINE_CGNAPT_COMMON_H__
20 #include "pipeline_common_fe.h"
22 extern uint8_t CGNAPT_DEBUG;
24 struct pipeline_cgnapt_entry_key {
26 uint16_t port; /* L4 port */
27 uint16_t pid; /* if port id */
33 enum cgnapt_entry_type {
40 * An enum defining the CG-NAPT entry creation type
50 struct app_pipeline_cgnapt_entry_params {
51 enum cgnapt_entry_type type;
53 uint32_t prv_ip; /* private ip address */
55 uint16_t u16_prv_ipv6[8];
56 uint32_t u32_prv_ipv6[4];
59 uint16_t prv_port; /* private port */
60 uint32_t pub_ip; /* public ip address */
61 uint16_t pub_port; /* public port */
62 uint16_t prv_phy_port; /* physical port on private side */
63 uint16_t pub_phy_port; /* physical port on public side */
64 uint32_t ttl; /* time to live */
65 long long int timeout;
67 struct rte_timer *timer;
75 struct cgnapt_table_entry {
76 struct rte_pipeline_table_entry head;
77 struct app_pipeline_cgnapt_entry_params data;
78 } __rte_cache_aligned;
81 * A structure defining the CG-NAPT multiple entry parameter.
83 struct app_pipeline_cgnapt_mentry_params {
84 enum cgnapt_entry_type type;
86 uint32_t prv_ip; /* private ip address */
88 uint16_t u16_prv_ipv6[8];
89 uint32_t u32_prv_ipv6[4];
91 uint32_t prv_ip; /* private ip address */
92 uint16_t prv_port; /* private port start */
93 uint32_t pub_ip; /* public ip address */
94 uint16_t pub_port; /* public port start */
95 uint16_t prv_phy_port; /* physical port on private side */
96 uint16_t pub_phy_port; /* physical port on public side */
97 uint32_t ttl; /* time to live */
98 uint32_t num_ue; /* number of UEs to add */
99 uint16_t prv_port_max; /* max value for private port */
100 uint16_t pub_port_max; /* max value for public port */
104 * A structure defining the NAT64 Network Specific Prefix.
106 struct pipeline_cgnapt_nsp_t {
115 enum pipeline_cgnapt_msg_req_type {
116 PIPELINE_CGNAPT_MSG_REQ_ENTRY_ADD,
117 PIPELINE_CGNAPT_MSG_REQ_ENTRY_DEL,
118 /* to be used for periodic synchronization */
119 PIPELINE_CGNAPT_MSG_REQ_ENTRY_SYNC,
120 /* to be used for debug purposes */
121 PIPELINE_CGNAPT_MSG_REQ_ENTRY_DBG,
122 /* Multiple (bulk) add */
123 PIPELINE_CGNAPT_MSG_REQ_ENTRY_ADDM,
124 PIPELINE_CGNAPT_MSG_REQ_VER,
125 PIPELINE_CGNAPT_MSG_REQ_NSP_ADD,
126 PIPELINE_CGNAPT_MSG_REQ_NSP_DEL,
128 PIPELINE_CGNAPT_MSG_REQ_PCP,
130 PIPELINE_CGNAPT_MSG_REQS
134 * A structure defining MSG ENTRY ADD request.
136 struct pipeline_cgnapt_entry_add_msg_req {
137 enum pipeline_msg_req_type type;
138 enum pipeline_cgnapt_msg_req_type subtype;
141 struct pipeline_cgnapt_entry_key key;
144 struct app_pipeline_cgnapt_entry_params data;
148 * A structure defining MSG ENTRY ADD response.
150 struct pipeline_cgnapt_entry_add_msg_rsp {
157 * A structure defining MSG ENTRY MADD request.
159 struct pipeline_cgnapt_entry_addm_msg_req {
160 enum pipeline_msg_req_type type;
161 enum pipeline_cgnapt_msg_req_type subtype;
164 struct app_pipeline_cgnapt_mentry_params data;
167 struct pipeline_cgnapt_entry_addm_msg_rsp {
174 * A structure defining MSG ENTRY DELETE request.
176 struct pipeline_cgnapt_entry_delete_msg_req {
177 enum pipeline_msg_req_type type;
178 enum pipeline_cgnapt_msg_req_type subtype;
181 struct pipeline_cgnapt_entry_key key;
185 * A structure defining MSG ENTRY DELETE response.
187 struct pipeline_cgnapt_entry_delete_msg_rsp {
195 struct pipeline_cgnapt_entry_sync_msg_req {
196 enum pipeline_msg_req_type type;
197 enum pipeline_cgnapt_msg_req_type subtype;
200 struct app_pipeline_cgnapt_entry_params data;
203 struct pipeline_cgnapt_entry_sync_msg_rsp {
209 * A structure defining the debug command response message.
211 struct pipeline_cgnapt_entry_dbg_msg_rsp {
217 * A structure defining the NSP add request.
219 struct pipeline_cgnapt_nsp_add_msg_req {
220 enum pipeline_msg_req_type type;
221 enum pipeline_cgnapt_msg_req_type subtype;
223 /* Network Specific Prefix and prefix length */
224 struct pipeline_cgnapt_nsp_t nsp;
228 * A structure defining the NSP add response.
230 struct pipeline_cgnapt_nsp_add_msg_rsp {
236 * A structure defining MSG NSP DEL request
238 struct pipeline_cgnapt_nsp_del_msg_req {
239 enum pipeline_msg_req_type type;
240 enum pipeline_cgnapt_msg_req_type subtype;
242 /* Network Specific Prefix and prefix length */
243 struct pipeline_cgnapt_nsp_t nsp;
248 * A structure defining MSG NSP DEL response
250 struct pipeline_cgnapt_nsp_del_msg_rsp {
256 * A structure defining the debug command request message.
258 struct pipeline_cgnapt_entry_dbg_msg_req {
259 enum pipeline_msg_req_type type;
260 enum pipeline_cgnapt_msg_req_type subtype;
266 extern struct pipeline_be_ops pipeline_cgnapt_be_ops;
267 void print_num_ip_clients(void);
268 void all_cgnapt_stats(char *);
269 void all_cgnapt_clear_stats(char *);
270 void print_static_cgnapt_entries(void);