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_MIX 0
329 #define TRAFFIC_TYPE_IPV4 4
330 #define TRAFFIC_TYPE_IPV6 6
332 #define CGNAPT_MAX_PUB_IP 256
336 * A structure defining public ip and associated client count.
340 rte_atomic16_t count; /* how many clients are using the public_ip */
341 } all_public_ip[CGNAPT_MAX_PUB_IP];
344 * Command to dump number of clients using an IP address.
346 void print_num_ip_clients(void);
348 extern struct rte_hash *napt_common_table;
349 extern struct public_ip all_public_ip[CGNAPT_MAX_PUB_IP];
352 * A structure defining pipeline_cgnapt - placeholder for all
353 * CGNAPT pipeline variables
357 struct pipeline_cgnapt {
359 pipeline_msg_req_handler custom_handlers[PIPELINE_CGNAPT_MSG_REQS];
364 uint32_t hash_offset;
368 /* Dynamic NAPT Start */
369 uint8_t is_static_cgnapt;
370 uint16_t max_port_per_client;
371 uint16_t max_clients_per_ip;
373 struct pub_ip_port_set *pub_ip_port_set;
374 uint8_t pub_ip_count;
375 struct pub_ip_range *pub_ip_range;
376 uint8_t pub_ip_range_count;
378 struct napt_port_alloc_elem *allocated_ports;
379 struct napt_port_alloc_elem *free_ports;
380 struct rte_ring *port_alloc_ring;
383 uint16_t port_map_array_size;
385 uint64_t n_cgnapt_entry_deleted;
386 uint64_t n_cgnapt_entry_added;
387 uint64_t naptedPktCount;
388 uint64_t naptDroppedPktCount;
390 uint64_t inaptedPktCount;
391 uint64_t enaptedPktCount;
392 uint64_t receivedPktCount;
393 uint64_t missedPktCount;
394 uint64_t dynCgnaptCount;
395 uint64_t arpicmpPktCount;
397 uint64_t app_params_addr;
398 uint8_t pipeline_num;
399 uint8_t pkt_burst_cnt;
400 uint8_t hw_checksum_reqd;
401 uint8_t traffic_type;
402 uint8_t links_map[PIPELINE_MAX_PORT_IN];
403 uint8_t outport_id[PIPELINE_MAX_PORT_IN];
405 struct pipeline_cgnapt_entry_key
406 cgnapt_dyn_ent_table[RTE_PORT_IN_BURST_SIZE_MAX];
407 uint32_t cgnapt_dyn_ent_index[RTE_PORT_IN_BURST_SIZE_MAX];
409 /* table lookup keys */
410 struct pipeline_cgnapt_entry_key keys[RTE_HASH_LOOKUP_BULK_MAX];
411 /* pointers to table lookup keys */
412 void *key_ptrs[RTE_HASH_LOOKUP_BULK_MAX];
413 /* table lookup results */
414 int32_t lkup_indx[RTE_HASH_LOOKUP_BULK_MAX];
415 /* entries used for pkts fwd */
416 struct rte_pipeline_table_entry *entries[RTE_HASH_LOOKUP_BULK_MAX];
417 uint64_t valid_packets; /* bitmap of valid packets to process */
418 uint64_t invalid_packets;/* bitmap of invalid packets to be dropped */
420 uint8_t vnf_set; /* to identify as separate LB-CGNAPT set */
422 /* Local ARP & ND Tables */
423 struct lib_arp_route_table_entry
424 local_lib_arp_route_table[MAX_ARP_RT_ENTRY];
425 uint8_t local_lib_arp_route_ent_cnt;
426 struct lib_nd_route_table_entry
427 local_lib_nd_route_table[MAX_ND_RT_ENTRY];
428 uint8_t local_lib_nd_route_ent_cnt;
430 /* For internal debugging purpose */
431 #ifdef CGNAPT_TIMING_INST
432 uint64_t in_port_exit_timestamp;
433 uint64_t external_time_sum;
434 uint64_t internal_time_sum;
435 uint32_t time_measurements;
436 uint32_t max_time_mesurements;
437 uint8_t time_measurements_on;
440 #ifdef CGNAPT_DEBUGGING
442 uint32_t naptDebugCount;
444 uint64_t naptDroppedPktCount1;
445 uint64_t naptDroppedPktCount2;
446 uint64_t naptDroppedPktCount3;
447 uint64_t naptDroppedPktCount4;
448 uint64_t naptDroppedPktCount5;
449 uint64_t naptDroppedPktCount6;
453 uint64_t missedpktcount1;
454 uint64_t missedpktcount2;
455 uint64_t missedpktcount3;
456 uint64_t missedpktcount4;
457 uint64_t missedpktcount5;
458 uint64_t missedpktcount6;
459 uint64_t missedpktcount7;
460 uint64_t missedpktcount8;
461 uint64_t missedpktcount9;
462 uint64_t missedpktcount10;
464 uint64_t missedpktcount11;
465 uint64_t missedpktcount12;
468 uint64_t max_port_dec_err1;
469 uint64_t max_port_dec_err2;
470 uint64_t max_port_dec_err3;
471 uint64_t max_port_dec_success;
482 } __rte_cache_aligned;
485 * A structure defining the CG-NAPT input port handler arg.
487 struct pipeline_cgnapt_in_port_h_arg {
488 struct pipeline_cgnapt *p;
497 uint16_t cgnapt_meta_offset;
498 uint8_t dual_stack_enable;
499 uint16_t dest_if_offset;
500 uint8_t nat_only_config_flag;
501 uint8_t CGNAPT_DEBUG;
503 #if (RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN)
504 /* x86 == little endian */
505 /* network == big endian */
506 #define CHECK_ENDIAN_16(x) rte_be_to_cpu_16(x)
508 #define CHECK_ENDIAN_16(x) (x)
510 #define IP_VHL_DEF (0x40 | 0x05)
511 struct rte_mempool *cgnapt_icmp_pktmbuf_tx_pool;
512 struct rte_mbuf *cgnapt_icmp_pkt;
513 struct rte_pipeline *myP;
514 uint8_t icmp_pool_init;
516 #define MAX_NUM_LOCAL_MAC_ADDRESS 16
518 /***** NAT64 NSP declarations *****/
520 * A structure defining nsp node.
522 struct cgnapt_nsp_node {
523 struct pipeline_cgnapt_nsp_t nsp;
524 struct cgnapt_nsp_node *next;
527 struct cgnapt_nsp_node *nsp_ll;
529 /***** Common Table declarations *****/
530 #define IP_VERSION_4 4
531 #define IP_VERSION_6 6
532 #define MAX_NAPT_ENTRIES 16777216 /* 0x1000000 */
533 #define NUM_NAPT_PORT_BULK_ALLOC 250
536 struct rte_hash *napt_common_table;
537 struct cgnapt_table_entry *napt_hash_tbl_entries;
539 /***** Multiple NAT IP declarations *****/
542 * A structure defining public ip and associated port range set
544 struct pub_ip_port_set {
551 * A structure defining public ip range
553 struct pub_ip_range {
558 /***** Common Port Allocation declarations *****/
560 int create_napt_common_table(uint32_t nFlows);
561 struct rte_mempool *napt_port_pool;
563 #define MAX_CGNAPT_SETS 16
566 * A structure defining a bulk port allocation element.
568 struct napt_port_alloc_elem {
570 uint32_t ip_addr[NUM_NAPT_PORT_BULK_ALLOC];
571 uint16_t ports[NUM_NAPT_PORT_BULK_ALLOC];
574 int napt_port_alloc_init(struct pipeline_cgnapt *p_nat);
575 void release_iport(uint16_t port, uint32_t public_ip,
576 struct pipeline_cgnapt *p_nat);
577 int get_free_iport(struct pipeline_cgnapt *p_nat, uint32_t *public_ip);
579 /***************************** Function declarations *************************/
582 pkt4_work_cgnapt_ipv6_prv(struct rte_mbuf **pkts,
584 void *arg, struct pipeline_cgnapt *p_nat);
586 pkt_work_cgnapt_ipv6_prv(struct rte_mbuf *pkts,
588 void *arg, struct pipeline_cgnapt *p_nat);
591 pkt4_work_cgnapt_ipv6_pub(struct rte_mbuf **pkts,
593 void *arg, struct pipeline_cgnapt *p_nat);
595 pkt_work_cgnapt_ipv6_pub(struct rte_mbuf *pkt,
597 void *arg, struct pipeline_cgnapt *p_nat);
600 pkt4_work_cgnapt_ipv4_prv(struct rte_mbuf **pkts,
602 void *arg, struct pipeline_cgnapt *p_nat);
605 pkt_work_cgnapt_ipv4_prv(struct rte_mbuf **pkts,
607 void *arg, struct pipeline_cgnapt *p_nat);
610 pkt4_work_cgnapt_ipv4_pub(struct rte_mbuf **pkts,
612 void *arg, struct pipeline_cgnapt *p_nat);
614 pkt_work_cgnapt_ipv4_pub(struct rte_mbuf **pkts,
616 void *arg, struct pipeline_cgnapt *p_nat);
618 /* in port handler key functions */
620 pkt4_work_cgnapt_key_ipv4_prv(struct rte_mbuf **pkts,
622 void *arg, struct pipeline_cgnapt *p_nat);
625 pkt_work_cgnapt_key_ipv4_prv(struct rte_mbuf *pkt,
627 void *arg, struct pipeline_cgnapt *p_nat);
630 pkt4_work_cgnapt_key_ipv4_pub(struct rte_mbuf **pkts,
632 void *arg, struct pipeline_cgnapt *p_nat);
635 pkt_work_cgnapt_key_ipv4_pub(struct rte_mbuf *pkt,
637 void *arg, struct pipeline_cgnapt *p_nat);
639 pkt4_work_cgnapt_key_ipv6_pub(struct rte_mbuf **pkts,
641 void *arg, struct pipeline_cgnapt *p_nat);
643 pkt_work_cgnapt_key_ipv6_pub(struct rte_mbuf *pkts,
645 void *arg, struct pipeline_cgnapt *p_nat);
647 pkt4_work_cgnapt_key_ipv6_prv(struct rte_mbuf **pkts,
649 void *arg, struct pipeline_cgnapt *p_nat);
651 pkt_work_cgnapt_key_ipv6_prv(struct rte_mbuf *pkt,
653 void *arg, struct pipeline_cgnapt *p_nat);
655 void send_icmp_dest_unreachable_msg(void);
656 unsigned short cksum_calc(unsigned short *addr, int len);
657 void print_mbuf(const char *rx_tx, unsigned int portid, struct rte_mbuf *mbuf,
661 /* Max port per client declarations */
663 * A structure defining maximun ports per client
665 struct max_port_per_client {
667 uint32_t prv_phy_port;
668 uint8_t max_port_cnt;
672 * A structure defining maximun ports per client key
674 struct max_port_per_client_key {
676 uint32_t prv_phy_port;
679 struct rte_hash *max_port_per_client_hash;
680 struct max_port_per_client *max_port_per_client_array;
683 int init_max_port_per_client(struct pipeline_cgnapt *p_nat);
684 int is_max_port_per_client_reached(uint32_t prv_ip_param,
685 uint32_t prv_phy_port_param,
686 struct pipeline_cgnapt *p_nat);
687 int increment_max_port_counter(uint32_t prv_ip_param,
688 uint32_t prv_phy_port_param,
689 struct pipeline_cgnapt *p_nat);
690 int decrement_max_port_counter(uint32_t prv_ip_param,
691 uint32_t prv_phy_port_param,
692 struct pipeline_cgnapt *p_nat);
693 int max_port_per_client_add_entry(uint32_t prv_ip_param,
694 uint32_t prv_phy_port_param,
695 struct pipeline_cgnapt *p_nat);
696 int max_port_per_client_del_entry(uint32_t prv_ip_param,
697 uint32_t prv_phy_port_param,
698 struct pipeline_cgnapt *p_nat);
700 /* Print functions */
701 void print_pkt(struct rte_mbuf *pkt);
702 void log_pkt(struct rte_mbuf *pkt);
703 void print_key(struct pipeline_cgnapt_entry_key *key);
704 void print_entry1(struct rte_pipeline_table_entry *entry);
705 void print_cgnapt_entry(struct cgnapt_table_entry *entry);
706 void my_print_entry(struct cgnapt_table_entry *ent);
708 /* CLI custom handler back-end helper functions */
710 void *pipeline_cgnapt_msg_req_custom_handler(
714 void *pipeline_cgnapt_msg_req_entry_add_handler(
718 void *pipeline_cgnapt_msg_req_entry_del_handler(
722 void *pipeline_cgnapt_msg_req_entry_sync_handler(
726 void *pipeline_cgnapt_msg_req_entry_dbg_handler(
730 void *pipeline_cgnapt_msg_req_entry_addm_handler(
734 void *pipeline_cgnapt_msg_req_ver_handler(
738 void *pipeline_cgnapt_msg_req_nsp_add_handler(
742 void *pipeline_cgnapt_msg_req_nsp_del_handler(
746 extern void *pipeline_cgnapt_msg_req_pcp_handler(
751 int pipeline_cgnapt_msg_req_entry_addm_pair(
752 struct pipeline *p, void *msg,
753 uint32_t src_ip, uint16_t src_port,
754 uint32_t dest_ip, uint16_t dest_port,
755 uint16_t rx_port, uint32_t ttl,
756 uint8_t type, uint8_t src_ipv6[16]);
758 /* CGNAPT Functions */
759 extern void rte_pipeline_action_handler_port_ext(
760 struct rte_pipeline *p,
762 struct rte_pipeline_table_entry **entries);
764 uint64_t pkt_miss_cgnapt(
765 struct pipeline_cgnapt_entry_key *key,
766 struct rte_mbuf *pkt,
767 struct rte_pipeline_table_entry **table_entry,
772 struct cgnapt_table_entry *add_dynamic_cgnapt_entry(
774 struct pipeline_cgnapt_entry_key *key,
782 void calculate_hw_checksum(
783 struct rte_mbuf *pkt,
787 uint64_t nextPowerOf2(uint64_t n);
788 struct ether_addr *get_local_link_hw_addr(uint8_t out_port);
789 uint8_t local_dest_mac_present(uint8_t out_port);
797 void hw_checksum(struct rte_mbuf *pkt, enum PKT_TYPE ver);
798 void sw_checksum(struct rte_mbuf *pkt, enum PKT_TYPE ver);
799 int rte_get_pkt_ver(struct rte_mbuf *pkt);
800 void print_common_table(void);
802 extern int add_dynamic_cgnapt_entry_alg(
804 struct pipeline_cgnapt_entry_key *key,
805 struct cgnapt_table_entry **entry_ptr1,
806 struct cgnapt_table_entry **entry_ptr2);