Added support for DPDK 19.05 / IPSec
[samplevnf.git] / VNFs / DPPD-PROX / prox_compat.h
index ee61ee4..001caa6 100644 (file)
 // 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"
+#include "quit.h"
 
 /* This is a copy of the rte_table_hash_params from DPDK 17.11  *
  * So if DPDK decides to change the structure the modifications *
@@ -117,3 +122,73 @@ 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
+
+static inline char *prox_strncpy(char * dest, const char * src, size_t count)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
+       strncpy(dest, src, count);
+#pragma GCC diagnostic pop
+       PROX_PANIC(dest[count - 1] != 0, "\t\tError in strncpy: buffer overrun (%lu bytes)", count);
+       return dest;
+}
+#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_esp_hdr esp_hdr
+#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);
+}
+
+#endif
+#endif // CONFIG_RTE_LIBRTE_PMD_AESNI_MB
+
+#endif // _PROX_COMPAT_H