Fix potential core dump when closing ports at exit
[samplevnf.git] / VNFs / DPPD-PROX / prox_compat.h
index ee61ee4..091c2cc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-// Copyright (c) 2010-2017 Intel Corporation
+// Copyright (c) 2010-2020 Intel Corporation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // See the License for the specific language governing permissions and
 // limitations under the License.
 */
+#ifndef _PROX_COMPAT_H_
+#define _PROX_COMPAT_H_
 #include <rte_common.h>
 #include <rte_table_hash.h>
 #include <rte_hash_crc.h>
+#include <rte_cryptodev.h>
 #include "hash_utils.h"
 
 /* This is a copy of the rte_table_hash_params from DPDK 17.11  *
@@ -33,6 +36,12 @@ struct prox_rte_table_params {
        uint64_t seed;
 };
 
+#if RTE_VERSION < RTE_VERSION_NUM(16,4,0,1)
+typedef uint8_t prox_next_hop_index_type;
+#else
+typedef uint32_t prox_next_hop_index_type;
+#endif
+
 #if RTE_VERSION < RTE_VERSION_NUM(17,11,0,0)
 
 static void *prox_rte_table_create(struct prox_rte_table_params *params, int socket_id, uint32_t entry_size)
@@ -117,3 +126,142 @@ static void *prox_rte_table_create(struct prox_rte_table_params *params, int soc
 #define prox_rte_table_key8_stats       rte_table_hash_key8_ext_ops.f_stats
 
 #endif
+
+#if RTE_VERSION < RTE_VERSION_NUM(18,8,0,0)
+#define rte_cryptodev_sym_get_private_session_size rte_cryptodev_get_private_session_size
+#endif
+
+#ifndef DEV_RX_OFFLOAD_JUMBO_FRAME
+#define DEV_RX_OFFLOAD_JUMBO_FRAME 0x00000800
+#endif
+
+#ifndef DEV_RX_OFFLOAD_KEEP_CRC
+#ifndef DEV_RX_OFFLOAD_CRC_STRIP
+#define DEV_RX_OFFLOAD_CRC_STRIP 0x00001000
+#endif
+#endif
+
+#if RTE_VERSION < RTE_VERSION_NUM(19,2,0,0)
+#define RTE_COLOR_GREEN e_RTE_METER_GREEN
+#define RTE_COLOR_YELLOW e_RTE_METER_YELLOW
+#define RTE_COLOR_RED e_RTE_METER_RED
+#define prox_rte_color rte_meter_color
+#define prox_rte_sched_port_pkt_read_tree_path(A,B,C,D,E,F) rte_sched_port_pkt_read_tree_path(B,C,D,E,F)
+#define prox_rte_sched_port_pkt_write(A,B,C,D,E,F,G) rte_sched_port_pkt_write(B,C,D,E,F,G);
+#else
+#define prox_rte_color rte_color
+#define prox_rte_sched_port_pkt_read_tree_path(A,B,C,D,E,F) rte_sched_port_pkt_read_tree_path(A,B,C,D,E,F)
+#define prox_rte_sched_port_pkt_write(A,B,C,D,E,F,G) rte_sched_port_pkt_write(A,B,C,D,E,F,G);
+#endif
+
+#if RTE_VERSION < RTE_VERSION_NUM(19,8,0,0)
+#if RTE_VERSION >= RTE_VERSION_NUM(18,5,0,0)
+typedef struct vxlan_gpe_hdr prox_rte_vxlan_gpe_hdr;
+#endif
+#define PROX_RTE_ETHER_CRC_LEN ETHER_CRC_LEN
+#define PROX_RTE_ETHER_MIN_LEN ETHER_MIN_LEN
+#define PROX_RTE_ETHER_MAX_LEN ETHER_MAX_LEN
+#define PROX_RTE_ETHER_HDR_LEN ETHER_HDR_LEN
+#define PROX_RTE_TCP_SYN_FLAG TCP_SYN_FLAG
+#define PROX_RTE_TCP_FIN_FLAG TCP_FIN_FLAG
+#define PROX_RTE_TCP_RST_FLAG TCP_RST_FLAG
+#define PROX_RTE_TCP_ACK_FLAG TCP_ACK_FLAG
+#define PROX_RTE_IP_ICMP_ECHO_REPLY IP_ICMP_ECHO_REPLY
+#define PROX_RTE_IP_ICMP_ECHO_REQUEST IP_ICMP_ECHO_REQUEST
+
+#define prox_rte_ether_addr_copy ether_addr_copy
+#define prox_rte_eth_random_addr eth_random_addr
+
+typedef struct ipv6_hdr prox_rte_ipv6_hdr;
+typedef struct ipv4_hdr prox_rte_ipv4_hdr;
+typedef struct ether_addr prox_rte_ether_addr;
+typedef struct ether_hdr prox_rte_ether_hdr;
+typedef struct vlan_hdr prox_rte_vlan_hdr;
+typedef struct udp_hdr prox_rte_udp_hdr;
+typedef struct tcp_hdr prox_rte_tcp_hdr;
+typedef struct icmp_hdr prox_rte_icmp_hdr;
+
+#ifndef RTE_SCHED_BE_QUEUES_PER_PIPE
+#define RTE_SCHED_BE_QUEUES_PER_PIPE RTE_SCHED_QUEUES_PER_PIPE
+#endif
+
+#define PROX_RTE_IS_IPV4_MCAST IS_IPV4_MCAST
+#define prox_rte_is_same_ether_addr is_same_ether_addr
+#define prox_rte_is_zero_ether_addr is_zero_ether_addr
+#else
+
+#define PROX_RTE_ETHER_CRC_LEN RTE_ETHER_CRC_LEN
+#define PROX_RTE_ETHER_MIN_LEN RTE_ETHER_MIN_LEN
+#define PROX_RTE_ETHER_MAX_LEN RTE_ETHER_MAX_LEN
+#define PROX_RTE_ETHER_HDR_LEN RTE_ETHER_HDR_LEN
+#define PROX_RTE_TCP_SYN_FLAG RTE_TCP_SYN_FLAG
+#define PROX_RTE_TCP_FIN_FLAG RTE_TCP_FIN_FLAG
+#define PROX_RTE_TCP_RST_FLAG RTE_TCP_RST_FLAG
+#define PROX_RTE_TCP_ACK_FLAG RTE_TCP_ACK_FLAG
+#define PROX_RTE_IP_ICMP_ECHO_REPLY RTE_IP_ICMP_ECHO_REPLY
+#define PROX_RTE_IP_ICMP_ECHO_REQUEST RTE_IP_ICMP_ECHO_REQUEST
+
+#define prox_rte_ether_addr_copy rte_ether_addr_copy
+#define prox_rte_eth_random_addr rte_eth_random_addr
+
+typedef struct rte_ipv6_hdr prox_rte_ipv6_hdr;
+typedef struct rte_ipv4_hdr prox_rte_ipv4_hdr;
+typedef struct rte_ether_addr prox_rte_ether_addr;
+typedef struct rte_ether_hdr prox_rte_ether_hdr;
+typedef struct rte_vlan_hdr prox_rte_vlan_hdr;
+typedef struct rte_vxlan_gpe_hdr prox_rte_vxlan_gpe_hdr;
+typedef struct rte_udp_hdr prox_rte_udp_hdr;
+typedef struct rte_tcp_hdr prox_rte_tcp_hdr;
+typedef struct rte_icmp_hdr prox_rte_icmp_hdr;
+
+#define PROX_RTE_IS_IPV4_MCAST  RTE_IS_IPV4_MCAST
+#define prox_rte_is_same_ether_addr rte_is_same_ether_addr
+#define prox_rte_is_zero_ether_addr rte_is_zero_ether_addr
+
+#endif
+
+char *prox_strncpy(char * dest, const char * src, size_t count);
+
+#ifdef RTE_LIBRTE_PMD_AESNI_MB
+#if RTE_VERSION < RTE_VERSION_NUM(19,5,0,0)
+//RFC4303
+struct prox_esp_hdr {
+        uint32_t spi;
+        uint32_t seq;
+};
+struct prox_rte_cryptodev_qp_conf {
+       uint32_t nb_descriptors; /**< Number of descriptors per queue pair */
+       struct rte_mempool *    mp_session;
+       struct rte_mempool *    mp_session_private;
+};
+
+static int prox_rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, struct prox_rte_cryptodev_qp_conf *qp_conf, int socket_id)
+{
+       struct rte_mempool *session_pool = qp_conf->mp_session;
+       return rte_cryptodev_queue_pair_setup(dev_id, queue_pair_id, (struct rte_cryptodev_qp_conf *)qp_conf, socket_id, session_pool);
+}
+
+#else
+#define prox_rte_cryptodev_qp_conf rte_cryptodev_qp_conf
+static int prox_rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, struct prox_rte_cryptodev_qp_conf *qp_conf, int socket_id)
+{
+       return rte_cryptodev_queue_pair_setup(dev_id, queue_pair_id, (struct rte_cryptodev_qp_conf *)qp_conf, socket_id);
+}
+
+#if RTE_VERSION < RTE_VERSION_NUM(19,8,0,0)
+#define prox_esp_hdr esp_hdr
+
+#else  // From DPDK 19.08
+#define prox_esp_hdr rte_esp_hdr
+
+#endif
+#endif
+#endif // CONFIG_RTE_LIBRTE_PMD_AESNI_MB
+
+#if RTE_VERSION < RTE_VERSION_NUM(19,11,0,0)
+#define prox_rte_eth_dev_count_avail() rte_eth_dev_count()
+#else
+#define prox_rte_eth_dev_count_avail() rte_eth_dev_count_avail()
+#endif
+
+#endif // _PROX_COMPAT_H