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_BE_H__
18 #define __INCLUDE_PIPELINE_CGNAPT_BE_H__
22 * Pipeline CG-NAPT BE.
24 * Pipeline CG-NAPT Back End (BE).
25 * Responsible for packet processing.
29 #include "pipeline_common_be.h"
30 #include "vnf_common.h"
31 #include <rte_pipeline.h>
33 #include "pipeline_timer_be.h"
34 #include "pipeline_arpicmp_be.h"
35 #include "cgnapt_pcp_be.h"
38 #define PIPELINE_CGNAPT_KEY_MAX_SIZE 64
40 extern uint8_t CGNAPT_DEBUG;
41 #define CGNAPT_DBG_CMD_OFST 8
42 #define CGNAPT_DBG_CMD_STATS_SHOW 0
43 #define CGNAPT_DBG_CMD_STATS_CLEAR 1
44 #define CGNAPT_DBG_CMD_DBG_LEVEL 2
45 #define CGNAPT_DBG_CMD_DBG_SHOW 3
46 #define CGNAPT_DBG_CMD_LS_ENTRY 4
47 #define CGNAPT_DBG_CMD_DYN 5
48 #define CGNAPT_DBG_CMD_IF_STATS 6
49 #define CGNAPT_DBG_CMD_INSTRUMENTATION 7
50 #define CGNAPT_DBG_CMD_ITER_COM_TBL 8
51 #define CGNAPT_DBG_CMD_MAPS_INFO 9
52 #define CGNAPT_DBG_CMD_OFST1 10
53 #define CGNAPT_DBG_CMD_IPV6 11
54 #define CGNAPT_DBG_CMD_PRINT_DS 12
55 #define CGNAPT_DBG_CMD_PRINT_NSP 13
56 #define CGNAPT_DBG_MAX_CLI_PER_PUB_IP 14
57 #define CGNAPT_DBG_PUB_IP_LIST 15
58 #define CGNAPT_DBG_TIMING_INST 16
63 #define CGNAPT_DBG_PCP 17
64 /* PCP sub commands */
67 CGNAPT_PCP_CMD_PCP_ENABLE,
68 CGNAPT_PCP_CMD_GET_LIFETIME,
69 CGNAPT_PCP_CMD_SET_LIFETIME,
70 CGNAPT_PCP_CMD_OFST = 8,
76 * CGNAPT_DBG_CMD_INSTRUMENTATION Sub commands
78 #define CGNAPT_CMD_INSTRUMENTATION_SUB0 0
79 #define CGNAPT_CMD_INSTRUMENTATION_SUB1 1
80 #define CGNAPT_CMD_INSTRUMENTATION_SUB2 2
83 * CGNAPT_DBG_CMD_IF_STATS Sub commands
85 #define CGNAPT_IF_STATS_HWQ 0
86 #define CGNAPT_IF_STATS_SWQ 1
87 #define CGNAPT_IF_STATS_OTH 2
89 /* Version command info */
90 #define CGNAPT_VER_CMD_OFST 8
91 #define CGNAPT_VER_CMD_VER 1
93 /* Network Specific Prefix commnd */
94 #define CGNAPT_NSP_CMD_OFST 8
96 /* #define PIPELINE_CGNAPT_INSTRUMENTATION */
97 #ifdef PIPELINE_CGNAPT_INSTRUMENTATION
98 void *instrumentation_port_in_arg;
99 struct rte_mempool *cgnapt_test_pktmbuf_pool;
101 #define INST_ARRAY_SIZE 100000
102 #define CGNAPT_INST5_SIG 0xAA
103 #define CGNAPT_INST5_WAIT 200
104 #define CGNAPT_INST5_OFST 10
106 uint64_t *inst_start_time;
107 uint64_t *inst_end_time;
108 uint32_t *inst_diff_time;
110 uint32_t cgnapt_inst_index;
111 uint32_t cgnapt_inst5_flag;
112 uint32_t cgnapt_inst5_wait;
113 uint8_t cgnapt_num_func_to_inst;
117 #define CGNAPT_VERSION "1.8"
118 #define CGNAPT_DYN_TIMEOUT (3*10) /* 30 secs */
119 #define MAX_DYN_ENTRY (70000 * 16)
121 #define NAPT_ENTRY_STALE 1
122 #define NAPT_ENTRY_VALID 0
124 /* For max_port_per_client */
125 #define MAX_PORT_INVALID_KEY -1
126 #define MAX_PORT_NOT_REACHED 0
127 #define MAX_PORT_REACHED 1
129 #define MAX_PORT_INC_SUCCESS 1
130 #define MAX_PORT_INC_REACHED 0
131 #define MAX_PORT_INC_ERROR -1
133 #define MAX_PORT_DEC_SUCCESS 1
134 #define MAX_PORT_DEC_REACHED 0
135 #define MAX_PORT_DEC_ERROR -1
137 #define MAX_PORT_ADD_SUCCESS 1
138 #define MAX_PORT_ADD_UNSUCCESS 0
139 #define MAX_PORT_ADD_ERROR -1
141 #define MAX_PORT_DEL_SUCCESS 1
142 #define MAX_PORT_DEL_UNSUCCESS 0
143 #define MAX_PORT_DEL_ERROR -1
145 #define PIPELINE_CGNAPT_TABLE_AH_HIT(f_ah, f_pkt_work, f_pkt4_work) \
148 struct rte_pipeline *rte_p, \
149 struct rte_mbuf **pkts, \
150 uint64_t pkts_mask, \
151 struct rte_pipeline_table_entry **entries, \
154 uint64_t pkts_in_mask = pkts_mask; \
155 uint64_t pkts_out_mask = pkts_mask; \
156 uint64_t time = rte_rdtsc(); \
158 if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
159 uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
162 for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) { \
163 uint64_t mask = f_pkt4_work(&pkts[i], \
164 &entries[i], i, arg); \
165 pkts_out_mask ^= mask << i; \
168 for ( ; i < n_pkts; i++) { \
169 uint64_t mask = f_pkt_work(pkts[i], \
170 entries[i], i, arg); \
171 pkts_out_mask ^= mask << i; \
174 for ( ; pkts_in_mask; ) { \
175 uint32_t pos = __builtin_ctzll(pkts_in_mask); \
176 uint64_t pkt_mask = 1LLU << pos; \
177 uint64_t mask = f_pkt_work(pkts[pos], \
178 entries[pos], pos, arg); \
180 pkts_in_mask &= ~pkt_mask; \
181 pkts_out_mask ^= mask << pos; \
184 rte_pipeline_ah_packet_drop(rte_p, pkts_out_mask ^ pkts_mask); \
189 #define PIPELINE_CGNAPT_PORT_OUT_AH(f_ah, f_pkt_work, f_pkt4_work) \
192 __rte_unused struct rte_pipeline *rte_p, \
193 struct rte_mbuf **pkt, \
194 uint32_t *pkts_mask, \
197 f_pkt4_work(pkt, arg); \
198 f_pkt_work(*pkt, arg); \
200 int i = *pkts_mask; i++; \
204 #define PIPELINE_CGNAPT_PORT_OUT_BAH(f_ah, f_pkt_work, f_pkt4_work) \
207 __rte_unused struct rte_pipeline *rte_p, \
208 struct rte_mbuf **pkt, \
209 uint32_t *pkts_mask, \
212 f_pkt4_work(pkt, arg); \
214 f_pkt_work(*pkt, arg); \
216 int i = *pkts_mask; i++; \
220 #define PIPELINE_CGNAPT_KEY_PORT_IN_AH(f_ah, f_pkt_work, f_pkt4_work) \
223 struct rte_pipeline *rte_p, \
224 struct rte_mbuf **pkts, \
230 if (CGNAPT_DEBUG > 1) \
231 printf("cgnapt_key hit fn: %"PRIu32"\n", n_pkts); \
234 for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
235 f_pkt4_work(&pkts[i], arg); \
237 for ( ; i < n_pkts; i++) \
238 f_pkt_work(pkts[i], arg); \
245 #define PIPELINE_CGNAPT_TABLE_AH_MISS(f_ah, f_pkt_work, f_pkt4_work) \
248 struct rte_pipeline *rte_p, \
249 struct rte_mbuf **pkts, \
250 uint64_t pkts_mask, \
251 struct rte_pipeline_table_entry **entries, \
254 uint64_t pkts_in_mask = pkts_mask; \
255 uint64_t pkts_out_mask = pkts_mask; \
256 uint64_t time = rte_rdtsc(); \
258 if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
259 uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
262 for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) { \
263 uint64_t mask = f_pkt4_work(&pkts[i], \
264 &entries[i], i, arg); \
265 pkts_out_mask ^= mask << i; \
268 for ( ; i < n_pkts; i++) { \
269 uint64_t mask = f_pkt_work(pkts[i], \
270 entries[i], i, arg); \
271 pkts_out_mask ^= mask << i; \
274 for ( ; pkts_in_mask; ) { \
275 uint32_t pos = __builtin_ctzll(pkts_in_mask); \
276 uint64_t pkt_mask = 1LLU << pos; \
277 uint64_t mask = f_pkt_work(pkts[pos], \
278 entries[pos], pos, arg); \
280 pkts_in_mask &= ~pkt_mask; \
281 pkts_out_mask ^= mask << pos; \
284 rte_pipeline_ah_packet_drop(rte_p, pkts_out_mask ^ pkts_mask); \
290 #define SRC_ADR_OFST_IP4 (MBUF_HDR_ROOM + ETH_HDR_SIZE + IP_HDR_SRC_ADR_OFST)
291 #define DST_ADR_OFST_IP4 (MBUF_HDR_ROOM + ETH_HDR_SIZE + IP_HDR_DST_ADR_OFST)
292 #define SRC_PRT_OFST_IP4_TCP (MBUF_HDR_ROOM + ETH_HDR_SIZE + IP_HDR_SIZE)
293 #define SRC_PRT_OFST_IP4_UDP SRC_PRT_OFST_IP4_TCP
294 #define DST_PRT_OFST_IP4_TCP (MBUF_HDR_ROOM + ETH_HDR_SIZE + IP_HDR_SIZE + 2)
295 #define DST_PRT_OFST_IP4_UDP DST_PRT_OFST_IP4_TCP
296 #define PROT_OFST_IP4 (MBUF_HDR_ROOM + ETH_HDR_SIZE + IP_HDR_PROTOCOL_OFST)
297 #define IDEN_OFST_IP4_ICMP (MBUF_HDR_ROOM + ETH_HDR_SIZE + IP_HDR_SIZE + 4)
298 #define SEQN_OFST_IP4_ICMP (MBUF_HDR_ROOM + ETH_HDR_SIZE + IP_HDR_SIZE + 6)
303 #define SRC_ADR_OFST_IP6 (MBUF_HDR_ROOM + ETH_HDR_SIZE + IPV6_HDR_SRC_ADR_OFST)
304 #define DST_ADR_OFST_IP6 (MBUF_HDR_ROOM + ETH_HDR_SIZE + IPV6_HDR_DST_ADR_OFST)
305 #define SRC_PRT_OFST_IP6 (MBUF_HDR_ROOM + ETH_HDR_SIZE + IPV6_HDR_SIZE)
306 #define DST_PRT_OFST_IP6 (MBUF_HDR_ROOM + ETH_HDR_SIZE + IPV6_HDR_SIZE + 2)
307 #define PROT_OFST_IP6 (MBUF_HDR_ROOM + ETH_HDR_SIZE + IPV6_HDR_PROTOCOL_OFST)
309 /* After IPv6 to IPv4 conversion */
310 #define SRC_ADR_OFST_IP6t4 (20 + MBUF_HDR_ROOM + ETH_HDR_SIZE + \
312 #define DST_ADR_OFST_IP6t4 (20 + MBUF_HDR_ROOM + ETH_HDR_SIZE + \
314 #define SRC_PRT_OFST_IP6t4 (20 + MBUF_HDR_ROOM + ETH_HDR_SIZE + \
316 #define DST_PRT_OFST_IP6t4 (20 + MBUF_HDR_ROOM + ETH_HDR_SIZE + \
318 #define PROT_OFST_IP6t4 (20 + MBUF_HDR_ROOM + ETH_HDR_SIZE + \
319 IP_HDR_PROTOCOL_OFST)
320 #define ETH_OFST_IP6t4 (20 + MBUF_HDR_ROOM)
322 /* After IPv4 to IPv6 conversion */
323 #define DST_PRT_OFST_IP4t6 (MBUF_HDR_ROOM + ETH_HDR_SIZE + \
324 IPV6_HDR_SIZE + 2 - 20)
325 #define DST_ADR_OFST_IP4t6 (MBUF_HDR_ROOM + ETH_HDR_SIZE + \
326 IPV6_HDR_DST_ADR_OFST - 20)
328 #define TRAFFIC_TYPE_IPV4 4
329 #define TRAFFIC_TYPE_IPV6 6
331 #define CGNAPT_MAX_PUB_IP 256
335 * A structure defining public ip and associated client count.
339 rte_atomic16_t count; /* how many clients are using the public_ip */
340 } all_public_ip[CGNAPT_MAX_PUB_IP];
343 * Command to dump number of clients using an IP address.
345 void print_num_ip_clients(void);
347 extern struct rte_hash *napt_common_table;
348 extern struct public_ip all_public_ip[CGNAPT_MAX_PUB_IP];
351 * A structure defining pipeline_cgnapt - placeholder for all
352 * CGNAPT pipeline variables
356 struct pipeline_cgnapt {
358 pipeline_msg_req_handler custom_handlers[PIPELINE_CGNAPT_MSG_REQS];
363 uint32_t hash_offset;
367 /* Dynamic NAPT Start */
368 uint8_t is_static_cgnapt;
369 uint16_t max_port_per_client;
370 uint16_t max_clients_per_ip;
372 struct pub_ip_port_set *pub_ip_port_set;
373 uint8_t pub_ip_count;
374 struct pub_ip_range *pub_ip_range;
375 uint8_t pub_ip_range_count;
377 struct napt_port_alloc_elem *allocated_ports;
378 struct napt_port_alloc_elem *free_ports;
379 struct rte_ring *port_alloc_ring;
382 uint16_t port_map_array_size;
384 uint64_t n_cgnapt_entry_deleted;
385 uint64_t n_cgnapt_entry_added;
386 uint64_t naptedPktCount;
387 uint64_t naptDroppedPktCount;
389 uint64_t inaptedPktCount;
390 uint64_t enaptedPktCount;
391 uint64_t receivedPktCount;
392 uint64_t missedPktCount;
393 uint64_t dynCgnaptCount;
394 uint64_t arpicmpPktCount;
396 uint64_t app_params_addr;
397 uint8_t pipeline_num;
398 uint8_t pkt_burst_cnt;
399 uint8_t hw_checksum_reqd;
400 uint8_t traffic_type;
401 uint8_t links_map[PIPELINE_MAX_PORT_IN];
402 uint8_t outport_id[PIPELINE_MAX_PORT_IN];
404 struct pipeline_cgnapt_entry_key
405 cgnapt_dyn_ent_table[RTE_PORT_IN_BURST_SIZE_MAX];
406 uint32_t cgnapt_dyn_ent_index[RTE_PORT_IN_BURST_SIZE_MAX];
408 /* table lookup keys */
409 struct pipeline_cgnapt_entry_key keys[RTE_HASH_LOOKUP_BULK_MAX];
410 /* pointers to table lookup keys */
411 void *key_ptrs[RTE_HASH_LOOKUP_BULK_MAX];
412 /* table lookup results */
413 int32_t lkup_indx[RTE_HASH_LOOKUP_BULK_MAX];
414 /* entries used for pkts fwd */
415 struct rte_pipeline_table_entry *entries[RTE_HASH_LOOKUP_BULK_MAX];
416 uint64_t valid_packets; /* bitmap of valid packets to process */
417 uint64_t invalid_packets;/* bitmap of invalid packets to be dropped */
419 uint8_t vnf_set; /* to identify as separate LB-CGNAPT set */
421 /* For internal debugging purpose */
422 #ifdef CGNAPT_TIMING_INST
423 uint64_t in_port_exit_timestamp;
424 uint64_t external_time_sum;
425 uint64_t internal_time_sum;
426 uint32_t time_measurements;
427 uint32_t max_time_mesurements;
428 uint8_t time_measurements_on;
431 #ifdef CGNAPT_DEBUGGING
433 uint32_t naptDebugCount;
435 uint64_t naptDroppedPktCount1;
436 uint64_t naptDroppedPktCount2;
437 uint64_t naptDroppedPktCount3;
438 uint64_t naptDroppedPktCount4;
439 uint64_t naptDroppedPktCount5;
440 uint64_t naptDroppedPktCount6;
444 uint64_t missedpktcount1;
445 uint64_t missedpktcount2;
446 uint64_t missedpktcount3;
447 uint64_t missedpktcount4;
448 uint64_t missedpktcount5;
449 uint64_t missedpktcount6;
450 uint64_t missedpktcount7;
451 uint64_t missedpktcount8;
452 uint64_t missedpktcount9;
453 uint64_t missedpktcount10;
455 uint64_t missedpktcount11;
456 uint64_t missedpktcount12;
459 uint64_t max_port_dec_err1;
460 uint64_t max_port_dec_err2;
461 uint64_t max_port_dec_err3;
462 uint64_t max_port_dec_success;
473 } __rte_cache_aligned;
476 * A structure defining the CG-NAPT input port handler arg.
478 struct pipeline_cgnapt_in_port_h_arg {
479 struct pipeline_cgnapt *p;
488 uint16_t cgnapt_meta_offset;
489 uint8_t dual_stack_enable;
490 uint16_t dest_if_offset;
491 uint8_t nat_only_config_flag;
492 uint8_t CGNAPT_DEBUG;
494 #if (RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN)
495 /* x86 == little endian */
496 /* network == big endian */
497 #define CHECK_ENDIAN_16(x) rte_be_to_cpu_16(x)
499 #define CHECK_ENDIAN_16(x) (x)
501 #define IP_VHL_DEF (0x40 | 0x05)
502 struct rte_mempool *cgnapt_icmp_pktmbuf_tx_pool;
503 struct rte_mbuf *cgnapt_icmp_pkt;
504 struct rte_pipeline *myP;
505 uint8_t icmp_pool_init;
507 #define MAX_NUM_LOCAL_MAC_ADDRESS 16
509 /***** NAT64 NSP declarations *****/
511 * A structure defining nsp node.
513 struct cgnapt_nsp_node {
514 struct pipeline_cgnapt_nsp_t nsp;
515 struct cgnapt_nsp_node *next;
518 struct cgnapt_nsp_node *nsp_ll;
520 /***** Common Table declarations *****/
521 #define IP_VERSION_4 4
522 #define IP_VERSION_6 6
523 #define MAX_NAPT_ENTRIES 16777216 /* 0x1000000 */
524 #define NUM_NAPT_PORT_BULK_ALLOC 250
527 struct rte_hash *napt_common_table;
528 struct cgnapt_table_entry *napt_hash_tbl_entries;
530 /***** Multiple NAT IP declarations *****/
533 * A structure defining public ip and associated port range set
535 struct pub_ip_port_set {
542 * A structure defining public ip range
544 struct pub_ip_range {
549 /***** Common Port Allocation declarations *****/
551 int create_napt_common_table(uint32_t nFlows);
552 struct rte_mempool *napt_port_pool;
554 #define MAX_CGNAPT_SETS 16
557 * A structure defining a bulk port allocation element.
559 struct napt_port_alloc_elem {
561 uint32_t ip_addr[NUM_NAPT_PORT_BULK_ALLOC];
562 uint16_t ports[NUM_NAPT_PORT_BULK_ALLOC];
565 int napt_port_alloc_init(struct pipeline_cgnapt *p_nat);
566 void release_iport(uint16_t port, uint32_t public_ip,
567 struct pipeline_cgnapt *p_nat);
568 int get_free_iport(struct pipeline_cgnapt *p_nat, uint32_t *public_ip);
570 /***************************** Function declarations *************************/
573 pkt4_work_cgnapt_ipv6_prv(struct rte_mbuf **pkts,
575 void *arg, struct pipeline_cgnapt *p_nat);
577 pkt_work_cgnapt_ipv6_prv(struct rte_mbuf *pkts,
579 void *arg, struct pipeline_cgnapt *p_nat);
582 pkt4_work_cgnapt_ipv6_pub(struct rte_mbuf **pkts,
584 void *arg, struct pipeline_cgnapt *p_nat);
586 pkt_work_cgnapt_ipv6_pub(struct rte_mbuf *pkt,
588 void *arg, struct pipeline_cgnapt *p_nat);
591 pkt4_work_cgnapt_ipv4_prv(struct rte_mbuf **pkts,
593 void *arg, struct pipeline_cgnapt *p_nat);
596 pkt_work_cgnapt_ipv4_prv(struct rte_mbuf **pkts,
598 void *arg, struct pipeline_cgnapt *p_nat);
601 pkt4_work_cgnapt_ipv4_pub(struct rte_mbuf **pkts,
603 void *arg, struct pipeline_cgnapt *p_nat);
605 pkt_work_cgnapt_ipv4_pub(struct rte_mbuf **pkts,
607 void *arg, struct pipeline_cgnapt *p_nat);
609 /* in port handler key functions */
611 pkt4_work_cgnapt_key_ipv4_prv(struct rte_mbuf **pkts,
613 void *arg, struct pipeline_cgnapt *p_nat);
616 pkt_work_cgnapt_key_ipv4_prv(struct rte_mbuf *pkt,
618 void *arg, struct pipeline_cgnapt *p_nat);
621 pkt4_work_cgnapt_key_ipv4_pub(struct rte_mbuf **pkts,
623 void *arg, struct pipeline_cgnapt *p_nat);
626 pkt_work_cgnapt_key_ipv4_pub(struct rte_mbuf *pkt,
628 void *arg, struct pipeline_cgnapt *p_nat);
630 pkt4_work_cgnapt_key_ipv6_pub(struct rte_mbuf **pkts,
632 void *arg, struct pipeline_cgnapt *p_nat);
634 pkt_work_cgnapt_key_ipv6_pub(struct rte_mbuf *pkts,
636 void *arg, struct pipeline_cgnapt *p_nat);
638 pkt4_work_cgnapt_key_ipv6_prv(struct rte_mbuf **pkts,
640 void *arg, struct pipeline_cgnapt *p_nat);
642 pkt_work_cgnapt_key_ipv6_prv(struct rte_mbuf *pkt,
644 void *arg, struct pipeline_cgnapt *p_nat);
646 void send_icmp_dest_unreachable_msg(void);
647 unsigned short cksum_calc(unsigned short *addr, int len);
648 void print_mbuf(const char *rx_tx, unsigned int portid, struct rte_mbuf *mbuf,
652 /* Max port per client declarations */
654 * A structure defining maximun ports per client
656 struct max_port_per_client {
658 uint32_t prv_phy_port;
659 uint8_t max_port_cnt;
663 * A structure defining maximun ports per client key
665 struct max_port_per_client_key {
667 uint32_t prv_phy_port;
670 struct rte_hash *max_port_per_client_hash;
671 struct max_port_per_client *max_port_per_client_array;
674 int init_max_port_per_client(struct pipeline_cgnapt *p_nat);
675 int is_max_port_per_client_reached(uint32_t prv_ip_param,
676 uint32_t prv_phy_port_param,
677 struct pipeline_cgnapt *p_nat);
678 int increment_max_port_counter(uint32_t prv_ip_param,
679 uint32_t prv_phy_port_param,
680 struct pipeline_cgnapt *p_nat);
681 int decrement_max_port_counter(uint32_t prv_ip_param,
682 uint32_t prv_phy_port_param,
683 struct pipeline_cgnapt *p_nat);
684 int max_port_per_client_add_entry(uint32_t prv_ip_param,
685 uint32_t prv_phy_port_param,
686 struct pipeline_cgnapt *p_nat);
687 int max_port_per_client_del_entry(uint32_t prv_ip_param,
688 uint32_t prv_phy_port_param,
689 struct pipeline_cgnapt *p_nat);
691 /* Print functions */
692 void print_pkt(struct rte_mbuf *pkt);
693 void log_pkt(struct rte_mbuf *pkt);
694 void print_key(struct pipeline_cgnapt_entry_key *key);
695 void print_entry1(struct rte_pipeline_table_entry *entry);
696 void print_cgnapt_entry(struct cgnapt_table_entry *entry);
697 void my_print_entry(struct cgnapt_table_entry *ent);
699 /* CLI custom handler back-end helper functions */
701 void *pipeline_cgnapt_msg_req_custom_handler(
705 void *pipeline_cgnapt_msg_req_entry_add_handler(
709 void *pipeline_cgnapt_msg_req_entry_del_handler(
713 void *pipeline_cgnapt_msg_req_entry_sync_handler(
717 void *pipeline_cgnapt_msg_req_entry_dbg_handler(
721 void *pipeline_cgnapt_msg_req_entry_addm_handler(
725 void *pipeline_cgnapt_msg_req_ver_handler(
729 void *pipeline_cgnapt_msg_req_nsp_add_handler(
733 void *pipeline_cgnapt_msg_req_nsp_del_handler(
737 extern void *pipeline_cgnapt_msg_req_pcp_handler(
742 int pipeline_cgnapt_msg_req_entry_addm_pair(
743 struct pipeline *p, void *msg,
744 uint32_t src_ip, uint16_t src_port,
745 uint32_t dest_ip, uint16_t dest_port,
746 uint16_t rx_port, uint32_t ttl,
747 uint8_t type, uint8_t src_ipv6[16]);
749 /* CGNAPT Functions */
750 uint64_t pkt_miss_cgnapt(
751 struct pipeline_cgnapt_entry_key *key,
752 struct rte_mbuf *pkt,
753 struct rte_pipeline_table_entry **table_entry,
758 struct cgnapt_table_entry *add_dynamic_cgnapt_entry(
760 struct pipeline_cgnapt_entry_key *key,
768 void calculate_hw_checksum(
769 struct rte_mbuf *pkt,
773 uint64_t nextPowerOf2(uint64_t n);
774 uint8_t local_dest_mac_present(uint8_t out_port);
782 void hw_checksum(struct rte_mbuf *pkt, enum PKT_TYPE ver);
783 void sw_checksum(struct rte_mbuf *pkt, enum PKT_TYPE ver);
784 int rte_get_pkt_ver(struct rte_mbuf *pkt);
785 void print_common_table(void);
787 extern int add_dynamic_cgnapt_entry_alg(
789 struct pipeline_cgnapt_entry_key *key,
790 struct cgnapt_table_entry **entry_ptr1,
791 struct cgnapt_table_entry **entry_ptr2);