Add initial support for DPDK 21.11
[samplevnf.git] / VNFs / DPPD-PROX / prox_args.c
index 08f27e9..09e903b 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.
 #include "defaults.h"
 #include "prox_lua.h"
 #include "cqm.h"
+#include "defines.h"
+#include "prox_ipv6.h"
 #include "prox_compat.h"
+#include "ip_subnet.h"
 
 #define MAX_RTE_ARGV 64
-#define MAX_ARG_LEN  64
+#define MAX_ARG_LEN  256
 
 struct cfg_depr {
        const char *opt;
@@ -137,6 +140,15 @@ static struct cfg_section core_cfg = {
        .error  = 0
 };
 
+struct deferred_port {
+       struct task_args *targ;
+       char name[256];
+       uint8_t is_rx_port;
+};
+
+static struct deferred_port deferred_port[PROX_MAX_PORTS];
+static int n_deferred_ports = 0;
+
 static void set_errf(const char *format, ...)
 {
        va_list ap;
@@ -263,7 +275,7 @@ static int get_lua_cfg(__attribute__((unused)) unsigned sindex, __attribute__((u
        struct lua_State *l = prox_lua();
 
        char str_cpy[1024];
-       strncpy(str_cpy, str, sizeof(str_cpy));
+       prox_strncpy(str_cpy, str, sizeof(str_cpy));
        uint32_t len = strlen(str_cpy);
        str_cpy[len++] = '\n';
        str_cpy[len++] = 0;
@@ -338,6 +350,12 @@ static int get_global_cfg(__attribute__((unused))unsigned sindex, char *str, voi
        if (STR_EQ(str, "enable bypass")) {
                return parse_flag(&pset->flags, DSF_ENABLE_BYPASS, pkey);
        }
+       if (STR_EQ(str, "poll timeout")) {
+               return parse_int(&pset->poll_timeout, pkey);
+       }
+       if (STR_EQ(str, "heartbeat timeout")) {
+               return parse_int(&pset->heartbeat_timeout, pkey);
+       }
 
        if (STR_EQ(str, "cpe table map")) {
                /* The config defined ports through 0, 1, 2 ... which
@@ -514,7 +532,7 @@ static int get_port_cfg(unsigned sindex, char *str, void *data)
        }
        else if (STR_EQ(str, "name")) {
                uint32_t val;
-               strncpy(cfg->name, pkey, MAX_NAME_SIZE);
+               prox_strncpy(cfg->names[0], pkey, MAX_NAME_SIZE);
                PROX_ASSERT(cur_if < PROX_MAX_PORTS);
                return add_port_name(cur_if, pkey);
        }
@@ -524,6 +542,16 @@ static int get_port_cfg(unsigned sindex, char *str, void *data)
        else if (STR_EQ(str, "tx desc")) {
                return parse_int(&cfg->n_txd, pkey);
        }
+       else if (STR_EQ(str, "ipv6 mask length")) {
+               return parse_int(&cfg->v6_mask_length, pkey);
+       }
+       else if (STR_EQ(str, "all_rx_queues")) {
+               uint32_t val;
+               if (parse_bool(&val, pkey)) {
+                       return -1;
+               }
+               cfg->all_rx_queues = val;
+       }
        else if (STR_EQ(str, "promiscuous")) {
                uint32_t val;
                if (parse_bool(&val, pkey)) {
@@ -531,6 +559,17 @@ static int get_port_cfg(unsigned sindex, char *str, void *data)
                }
                cfg->promiscuous = val;
        }
+       else if (STR_EQ(str, "multicast")) {
+               uint32_t val;
+               if (cfg->nb_mc_addr >= NB_MCAST_ADDR) {
+                       plog_err("too many multicast addresses\n");
+                       return -1;
+               }
+               if (parse_mac(&cfg->mc_addr[cfg->nb_mc_addr], pkey)) {
+                       return -1;
+               }
+               cfg->nb_mc_addr++ ;
+       }
        else if (STR_EQ(str, "lsc")) {
                cfg->lsc_set_explicitely = 1;
                uint32_t val;
@@ -539,13 +578,94 @@ static int get_port_cfg(unsigned sindex, char *str, void *data)
                }
                cfg->lsc_val = val;
        }
+       else if (STR_EQ(str, "local ipv4")) {
+               if (parse_ip_set(cfg->ip_addr, pkey, PROX_MAX_VLAN_TAGS) != 0) {
+                       cfg->ip_addr[0].ip = 24;
+                       return parse_ip(&cfg->ip_addr[0].ip, pkey);
+               }
+               return 0;
+       }
+       else if (STR_EQ(str, "virtual")) {
+               uint32_t val;
+               if (parse_bool(&val, pkey)) {
+                       return -1;
+               }
+               cfg->virtual = val;
+       }
+       else if (STR_EQ(str, "vdev")) {
+               prox_strncpy(cfg->vdev, pkey, MAX_NAME_SIZE);
+       }
+#if RTE_VERSION >= RTE_VERSION_NUM(18,8,0,1)
+       else if (STR_EQ(str, "disable tx offload")) {
+               uint32_t val;
+               if (parse_int(&val, pkey)) {
+                       return -1;
+               }
+               if (val)
+                       cfg->disabled_tx_offload = val;
+       }
+#endif
        else if (STR_EQ(str, "strip crc")) {
                uint32_t val;
                if (parse_bool(&val, pkey)) {
                        return -1;
                }
-               cfg->port_conf.rxmode.hw_strip_crc = val;
+#if defined(DEV_RX_OFFLOAD_CRC_STRIP)
+               if (val)
+                       cfg->requested_rx_offload |= DEV_RX_OFFLOAD_CRC_STRIP;
+               else
+                       cfg->requested_rx_offload &= ~DEV_RX_OFFLOAD_CRC_STRIP;
+#else
+#if defined (DEV_RX_OFFLOAD_KEEP_CRC)
+               if (val)
+                       cfg->requested_rx_offload &= ~DEV_RX_OFFLOAD_KEEP_CRC;
+               else
+#endif
+                       cfg->requested_rx_offload |= DEV_RX_OFFLOAD_KEEP_CRC;
+#endif
+
+       }
+       else if (STR_EQ(str, "vlan tag")) {
+               return parse_int_set(cfg->vlan_tags, pkey, sizeof(cfg->vlan_tags) / sizeof(cfg->vlan_tags[0]));
+       }
+       else if (STR_EQ(str, "vlan")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(18,8,0,1)
+               uint32_t val;
+               if (parse_bool(&val, pkey)) {
+                       return -1;
+               }
+               if (val) {
+                       cfg->requested_rx_offload |= DEV_RX_OFFLOAD_VLAN_STRIP;
+                       cfg->requested_tx_offload |= DEV_TX_OFFLOAD_VLAN_INSERT;
+               } else {
+                       cfg->requested_rx_offload &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
+                       cfg->requested_tx_offload &= ~DEV_TX_OFFLOAD_VLAN_INSERT;
+               }
+#else
+               plog_warn("vlan option not supported : update DPDK at least to 18.08 to support this option\n");
+#endif
+       }
+       else if (STR_EQ(str, "mtu size")) {
+               uint32_t val;
+               if (parse_int(&val, pkey)) {
+                       return -1;
+               }
+               if (val) {
+                       cfg->mtu = val;
+                       // A frame of 1526 bytes (1500 bytes mtu, 14 bytes hdr, 4 bytes crc and 8 bytes vlan)
+                       // should not be considered as a jumbo frame. However rte_ethdev.c considers that
+                       // the max_rx_pkt_len for a non jumbo frame is 1518
+#if RTE_VERSION < RTE_VERSION_NUM(21,11,0,0)
+                       cfg->port_conf.rxmode.max_rx_pkt_len = cfg->mtu + PROX_RTE_ETHER_HDR_LEN + PROX_RTE_ETHER_CRC_LEN;
+                       if (cfg->port_conf.rxmode.max_rx_pkt_len > PROX_RTE_ETHER_MAX_LEN)
+#else
+                       cfg->port_conf.rxmode.mtu = cfg->mtu;
+                       if (cfg->port_conf.rxmode.mtu > PROX_RTE_ETHER_MAX_LEN - PROX_RTE_ETHER_HDR_LEN - PROX_RTE_ETHER_CRC_LEN)
+#endif
+                               cfg->requested_rx_offload |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+               }
        }
+
        else if (STR_EQ(str, "rss")) {
                uint32_t val;
                if (parse_bool(&val, pkey)) {
@@ -806,10 +926,10 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
        if (STR_EQ(str, "fast path handle arp")) {
                return parse_flag(&targ->runtime_flags, TASK_FP_HANDLE_ARP, pkey);
        }
-       if (STR_EQ(str, "multiple arp")) {
-               return parse_flag(&targ->flags, TASK_MULTIPLE_MAC, pkey);
-       }
 
+       if (STR_EQ(str, "do not forward geneve")) {
+               return parse_flag(&targ->runtime_flags, TASK_DO_NOT_FWD_GENEVE, pkey);
+       }
        /* Using tx port name, only a _single_ port can be assigned to a task. */
        if (STR_EQ(str, "tx port")) {
                if (targ->nb_txports > 0) {
@@ -821,7 +941,17 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                uint32_t ports[PROX_MAX_PORTS];
 
                if(parse_port_name_list(ports, &n_if, PROX_MAX_PORTS, pkey)) {
-                       return -1;
+                       // Port name not found, but could be a virtual device of a secondary process
+                       // As DPDK not started yet, we can only check the config file to see whether we are a secondary process
+                       if (rte_cfg.eal &&
+                                       (strstr(rte_cfg.eal, "secondary") || strstr(rte_cfg.eal, "auto")) &&
+                                       (n_deferred_ports < PROX_MAX_PORTS)) {
+                               prox_strncpy(deferred_port[n_deferred_ports].name, pkey, sizeof(deferred_port[n_deferred_ports].name));
+                               deferred_port[n_deferred_ports].is_rx_port = 0;
+                               deferred_port[n_deferred_ports++].targ = targ;
+                               return 0;
+                       } else
+                               return -1;
                }
 
                PROX_ASSERT(n_if-1 < PROX_MAX_PORTS);
@@ -877,6 +1007,9 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
        if (STR_EQ(str, "streams")) {
                return parse_str(targ->streams, pkey, sizeof(targ->streams));
        }
+       if (STR_EQ(str, "Unsollicited NA")) {
+               return parse_flag(&targ->flags, TASK_ARG_SEND_NA_AT_STARTUP, pkey);
+       }
        if (STR_EQ(str, "local lpm")) {
                return parse_flag(&targ->flags, TASK_ARG_LOCAL_LPM, pkey);
        }
@@ -896,6 +1029,18 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
        if (STR_EQ(str, "random")) {
                return parse_str(targ->rand_str[targ->n_rand_str++], pkey, sizeof(targ->rand_str[0]));
        }
+       if (STR_EQ(str, "range")) {
+               int rc = parse_range(&targ->range[targ->n_ranges].min, &targ->range[targ->n_ranges].max, pkey);
+               targ->n_ranges++;
+               return rc;
+       }
+       if (STR_EQ(str, "range_offset")) {
+               if (targ->n_ranges == 0) {
+                       set_errf("No range defined previously (use range=...)");
+                       return -1;
+               }
+               return parse_int(&targ->range[targ->n_ranges - 1].offset, pkey);
+       }
        if (STR_EQ(str, "rand_offset")) {
                if (targ->n_rand_str == 0) {
                        set_errf("No random defined previously (use random=...)");
@@ -910,6 +1055,34 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
        if (STR_EQ(str, "pcap file")) {
                return parse_str(targ->pcap_file, pkey, sizeof(targ->pcap_file));
        }
+       if (STR_EQ(str, "imix")) {
+               char pkey2[MAX_CFG_STRING_LEN], *ptr;
+               if (parse_str(pkey2, pkey, sizeof(pkey2)) != 0) {
+                       set_errf("Error while parsing imix, too long\n");
+                       return -1;
+               }
+               const size_t pkey_len = strlen(pkey2);
+               targ->imix_nb_pkts = 0;
+               ptr = pkey2;
+               while (targ->imix_nb_pkts < MAX_IMIX_PKTS) {
+                       if (parse_int(&targ->imix_pkt_sizes[targ->imix_nb_pkts], ptr) != 0)
+                               break;
+                       targ->imix_nb_pkts++;
+                       if ((ptr = strchr(ptr, ',')) == NULL)
+                               break;
+                       ptr++;
+                       if (targ->imix_nb_pkts == MAX_IMIX_PKTS) {
+                               set_errf("Too many packet sizes specified");
+                               return -1;
+                       }
+               }
+               plog_info("%d IMIX packets:", targ->imix_nb_pkts);
+               for (size_t i = 0; i < targ->imix_nb_pkts; ++i) {
+                       plog_info("%d ", targ->imix_pkt_sizes[i]);
+               }
+               plog_info("\n");
+               return 0;
+       }
        if (STR_EQ(str, "pkt inline")) {
                char pkey2[MAX_CFG_STRING_LEN];
                if (parse_str(pkey2, pkey, sizeof(pkey2)) != 0) {
@@ -959,7 +1132,8 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                                return -1;
                        }
                        if (targ->pkt_size == sizeof(targ->pkt_inline)) {
-                               set_errf("Inline packet definition can't be longer than 1518");
+                               set_errf("Inline packet definition can't be longer than %u", sizeof(targ->pkt_inline));
+                               return -1;
                        }
 
                        targ->pkt_inline[targ->pkt_size++] = byte;
@@ -977,6 +1151,9 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
        if (STR_EQ(str, "latency buffer size")) {
                return parse_int(&targ->latency_buffer_size, pkey);
        }
+       if (STR_EQ(str, "loss buffer size")) {
+               return parse_int(&targ->loss_buffer_size, pkey);
+       }
        if (STR_EQ(str, "accuracy pos")) {
                return parse_int(&targ->accur_pos, pkey);
        }
@@ -993,7 +1170,16 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
        if (STR_EQ(str, "packet id pos")) {
                return parse_int(&targ->packet_id_pos, pkey);
        }
-       if (STR_EQ(str, "probability")) {
+       if (STR_EQ(str, "flow id pos")) {
+               return parse_int(&targ->flow_id_pos, pkey);
+       }
+       if (STR_EQ(str, "packet id in flow pos")) {
+               return parse_int(&targ->packet_id_in_flow_pos, pkey);
+       }
+       if (STR_EQ(str, "flow count")) {
+               return parse_int(&targ->flow_count, pkey);
+       }
+       if (STR_EQ(str, "probability")) { // old - use "probability no drop" instead
                float probability;
                int rc = parse_float(&probability, pkey);
                if (probability == 0) {
@@ -1003,9 +1189,44 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                        set_errf("Probability must be < 100\n");
                        return -1;
                }
-               targ->probability = probability * 10000;
+               targ->probability_no_drop = probability * 10000;
                return rc;
        }
+       if (STR_EQ(str, "proba no drop")) {
+               float probability;
+               int rc = parse_float(&probability, pkey);
+               if (probability == 0) {
+                       set_errf("probability no drop must be != 0\n");
+                       return -1;
+               } else if (probability > 100.0) {
+                       set_errf("Probability must be < 100\n");
+                       return -1;
+               }
+               targ->probability_no_drop = probability * 10000;
+               return rc;
+       }
+       if (STR_EQ(str, "proba delay")) {
+               float probability;
+               int rc = parse_float(&probability, pkey);
+               if (probability > 100.0) {
+                       set_errf("Probability must be < 100\n");
+                       return -1;
+               }
+               targ->probability_delay = probability * 10000;
+               return rc;
+       }
+#if RTE_VERSION >= RTE_VERSION_NUM(19,11,0,0)
+       if (STR_EQ(str, "proba duplicate")) {
+               float probability;
+               int rc = parse_float(&probability, pkey);
+               if (probability > 100.0) {
+                       set_errf("probability duplicate must be < 100\n");
+                       return -1;
+               }
+               targ->probability_duplicate = probability * 10000;
+               return rc;
+       }
+#endif
        if (STR_EQ(str, "concur conn")) {
                return parse_int(&targ->n_concur_conn, pkey);
        }
@@ -1030,7 +1251,17 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                uint32_t n_if;
 
                 if (parse_port_name_list(vals, &n_if, PROX_MAX_PORTS, pkey)) {
-                        return -1;
+                       // Port name not found, but could be a virtual device of a secondary process
+                       // As DPDK not started yet, we can only check the config file to see whether we are a secondary process
+                       if (rte_cfg.eal &&
+                                       (strstr(rte_cfg.eal, "secondary") || strstr(rte_cfg.eal, "auto")) &&
+                                       (n_deferred_ports < PROX_MAX_PORTS)) {
+                               prox_strncpy(deferred_port[n_deferred_ports].name, pkey, sizeof(deferred_port[n_deferred_ports].name));
+                               deferred_port[n_deferred_ports].is_rx_port = 1;
+                               deferred_port[n_deferred_ports++].targ = targ;
+                               return 0;
+                       } else
+                               return -1;
                 }
 
                 for (uint8_t i = 0; i < n_if; ++i) {
@@ -1204,7 +1435,6 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
        }
 
        else if (STR_EQ(str, "mbuf size")) {
-               targ->mbuf_size_set_explicitely = 1;
                return parse_int(&targ->mbuf_size, pkey);
        }
        if (STR_EQ(str, "memcache size")) {
@@ -1215,6 +1445,9 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                return parse_int(&targ->byte_offset, pkey);
        }
 
+       if (STR_EQ(str, "realtime scheduling")) {
+               return parse_flag(&lconf->flags, LCONF_FLAG_SCHED_RR, pkey);
+       }
        if (STR_EQ(str, "name")) {
                return parse_str(lconf->name, pkey, sizeof(lconf->name));
        }
@@ -1241,7 +1474,7 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
 
                targ->task_init = to_task_init(mode_str, sub_mode_str);
                if (!targ->task_init) {
-                       if (strcmp(sub_mode_str, "l3") != 0) {
+                       if ((strcmp(sub_mode_str, "l3") != 0) && (strcmp(sub_mode_str, "ndp") != 0)) {
                                set_errf("sub mode %s not supported for mode %s", sub_mode_str, mode_str);
                                return -1;
                        }
@@ -1252,9 +1485,13 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                        }
                }
                if (strcmp(sub_mode_str, "l3") == 0) {
-                       prox_cfg.flags |= DSF_CTRL_PLANE_ENABLED;
+                       prox_cfg.flags |= DSF_L3_ENABLED;
                        targ->flags |= TASK_ARG_L3;
                        strcpy(targ->sub_mode_str, "l3");
+               } else if (strcmp(sub_mode_str, "ndp") == 0) {
+                       prox_cfg.flags |= DSF_NDP_ENABLED;
+                       targ->flags |= TASK_ARG_NDP;
+                       strcpy(targ->sub_mode_str, "ndp");
                } else {
                        strcpy(targ->sub_mode_str, targ->task_init->sub_mode_str);
                }
@@ -1303,20 +1540,89 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                targ->flags |= TASK_ARG_SRC_MAC_SET;
                return 0;
        }
+       if (STR_EQ(str, "igmp ipv4")) { /* IGMP Group */
+               return parse_ip(&targ->igmp_address, pkey);
+       }
        if (STR_EQ(str, "gateway ipv4")) { /* Gateway IP address used when generating */
+               if ((targ->flags & TASK_ARG_L3) == 0)
+                       plog_warn("gateway ipv4 configured but L3 sub mode not enabled\n");
+               if (targ->local_ipv4)
+                       targ->local_prefix = 32;
                return parse_ip(&targ->gateway_ipv4, pkey);
        }
+       if (STR_EQ(str, "ipv6 router")) { /* we simulate an IPV6 router */
+               int rc = parse_flag(&targ->ipv6_router, 1, pkey);
+               if (!rc && targ->ipv6_router) {
+                       plog_info("\tipv6 router configured => NDP enabled\n");
+                       prox_cfg.flags |= DSF_NDP_ENABLED;
+                       targ->flags |= TASK_ARG_NDP;
+                       strcpy(targ->sub_mode_str, "ndp");
+               }
+               return 0;
+       }
+       if (STR_EQ(str, "gateway ipv6")) { /* Gateway IP address used when generating */
+               if ((targ->flags & TASK_ARG_NDP) == 0)
+                       plog_warn("gateway ipv6 configured but NDP sub mode not enabled\n");
+               return parse_ip6(&targ->gateway_ipv6, pkey);
+       }
        if (STR_EQ(str, "local ipv4")) { /* source IP address to be used for packets */
-               return parse_ip(&targ->local_ipv4, pkey);
+               struct ip4_subnet cidr;
+               if (parse_ip4_and_prefix(&cidr, pkey) != 0) {
+                       if (targ->gateway_ipv4)
+                               targ->local_prefix = 32;
+                       else
+                               targ->local_prefix = 0;
+                       return parse_ip(&targ->local_ipv4, pkey);
+               } else {
+                       targ->local_ipv4 = cidr.ip;
+                       targ->local_prefix = cidr.prefix;
+                       return 0;
+               }
        }
        if (STR_EQ(str, "remote ipv4")) { /* source IP address to be used for packets */
                return parse_ip(&targ->remote_ipv4, pkey);
        }
+        if (STR_EQ(str, "global ipv6")) {
+               if (parse_ip6(&targ->global_ipv6, pkey) == 0) {
+                       plog_info("\tglobal ipv6 configured => NDP enabled\n");
+                       targ->flags |= TASK_ARG_NDP;
+                       prox_cfg.flags |= DSF_NDP_ENABLED;
+                       strcpy(targ->sub_mode_str, "ndp");
+               } else {
+                       plog_err("Unable to parse content of local ipv6: %s\n", pkey);
+                       return -1;
+               }
+               return 0;
+       }
         if (STR_EQ(str, "local ipv6")) { /* source IPv6 address to be used for packets */
-                return parse_ip6(&targ->local_ipv6, pkey);
+               if (parse_ip6(&targ->local_ipv6, pkey) == 0) {
+                       plog_info("\tlocal ipv6 configured => NDP enabled\n");
+                       targ->flags |= TASK_ARG_NDP;
+                       prox_cfg.flags |= DSF_NDP_ENABLED;
+                       strcpy(targ->sub_mode_str, "ndp");
+               } else {
+                       plog_err("Unable to parse content of local ipv6: %s\n", pkey);
+                       return -1;
+               }
+               return 0;
         }
+        if (STR_EQ(str, "router prefix")) {
+               if (parse_ip6(&targ->router_prefix, pkey) == 0) {
+                       plog_info("\trouter prefix set to "IPv6_BYTES_FMT" (%s)\n", IPv6_BYTES(targ->router_prefix.bytes), IP6_Canonical(&targ->router_prefix));
+               } else {
+                       plog_err("Unable to parse content of router prefix: %s\n", pkey);
+                       return -1;
+               }
+               return 0;
+       }
+       if (STR_EQ(str, "arp timeout"))
+               return parse_int(&targ->reachable_timeout, pkey);
+       if (STR_EQ(str, "arp update time"))
+               return parse_int(&targ->arp_ndp_retransmit_timeout, pkey);
        if (STR_EQ(str, "number of packets"))
                return parse_int(&targ->n_pkts, pkey);
+       if (STR_EQ(str, "store size"))
+               return parse_int(&targ->store_max, pkey);
        if (STR_EQ(str, "pipes")) {
                uint32_t val;
                int err = parse_int(&val, pkey);
@@ -1336,30 +1642,84 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                if (err) {
                        return -1;
                }
-
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               targ->qos_conf.subport_params[0].qsize[0] = val;
+               targ->qos_conf.subport_params[0].qsize[1] = val;
+               targ->qos_conf.subport_params[0].qsize[2] = val;
+               targ->qos_conf.subport_params[0].qsize[3] = val;
+#else
                targ->qos_conf.port_params.qsize[0] = val;
                targ->qos_conf.port_params.qsize[1] = val;
                targ->qos_conf.port_params.qsize[2] = val;
                targ->qos_conf.port_params.qsize[3] = val;
+#endif
                return 0;
        }
        if (STR_EQ(str, "subport tb rate")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               return parse_u64(&targ->qos_conf.port_params.subport_profiles->tb_rate, pkey);
+#else
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.subport_params[0].tb_rate, pkey);
+#else
                return parse_int(&targ->qos_conf.subport_params[0].tb_rate, pkey);
+#endif
+#endif
        }
        if (STR_EQ(str, "subport tb size")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               return parse_u64(&targ->qos_conf.port_params.subport_profiles->tb_size, pkey);
+#else
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.subport_params[0].tb_size, pkey);
+#else
                return parse_int(&targ->qos_conf.subport_params[0].tb_size, pkey);
+#endif
+#endif
        }
        if (STR_EQ(str, "subport tc 0 rate")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               return parse_u64(&targ->qos_conf.port_params.subport_profiles->tc_rate[0], pkey);
+#else
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.subport_params[0].tc_rate[0], pkey);
+#else
                return parse_int(&targ->qos_conf.subport_params[0].tc_rate[0], pkey);
+#endif
+#endif
        }
        if (STR_EQ(str, "subport tc 1 rate")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               return parse_u64(&targ->qos_conf.port_params.subport_profiles->tc_rate[1], pkey);
+#else
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.subport_params[0].tc_rate[1], pkey);
+#else
                return parse_int(&targ->qos_conf.subport_params[0].tc_rate[1], pkey);
+#endif
+#endif
        }
        if (STR_EQ(str, "subport tc 2 rate")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               return parse_u64(&targ->qos_conf.port_params.subport_profiles->tc_rate[2], pkey);
+#else
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.subport_params[0].tc_rate[2], pkey);
+#else
                return parse_int(&targ->qos_conf.subport_params[0].tc_rate[2], pkey);
+#endif
+#endif
        }
        if (STR_EQ(str, "subport tc 3 rate")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               return parse_u64(&targ->qos_conf.port_params.subport_profiles->tc_rate[3], pkey);
+#else
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.subport_params[0].tc_rate[3], pkey);
+#else
                return parse_int(&targ->qos_conf.subport_params[0].tc_rate[3], pkey);
+#endif
+#endif
        }
 
        if (STR_EQ(str, "subport tc rate")) {
@@ -1369,21 +1729,44 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                        return -1;
                }
 
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               targ->qos_conf.port_params.subport_profiles->tc_rate[0] = val;
+               targ->qos_conf.port_params.subport_profiles->tc_rate[1] = val;
+               targ->qos_conf.port_params.subport_profiles->tc_rate[2] = val;
+               targ->qos_conf.port_params.subport_profiles->tc_rate[3] = val;
+#else
                targ->qos_conf.subport_params[0].tc_rate[0] = val;
                targ->qos_conf.subport_params[0].tc_rate[1] = val;
                targ->qos_conf.subport_params[0].tc_rate[2] = val;
                targ->qos_conf.subport_params[0].tc_rate[3] = val;
+#endif
 
                return 0;
        }
        if (STR_EQ(str, "subport tc period")) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               return parse_u64(&targ->qos_conf.port_params.subport_profiles->tc_period, pkey);
+#else
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.subport_params[0].tc_period, pkey);
+#else
                return parse_int(&targ->qos_conf.subport_params[0].tc_period, pkey);
+#endif
+#endif
        }
        if (STR_EQ(str, "pipe tb rate")) {
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.pipe_params[0].tb_rate, pkey);
+#else
                return parse_int(&targ->qos_conf.pipe_params[0].tb_rate, pkey);
+#endif
        }
        if (STR_EQ(str, "pipe tb size")) {
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.pipe_params[0].tb_size, pkey);
+#else
                return parse_int(&targ->qos_conf.pipe_params[0].tb_size, pkey);
+#endif
        }
        if (STR_EQ(str, "pipe tc rate")) {
                uint32_t val;
@@ -1399,19 +1782,39 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                return 0;
        }
        if (STR_EQ(str, "pipe tc 0 rate")) {
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.pipe_params[0].tc_rate[0], pkey);
+#else
                return parse_int(&targ->qos_conf.pipe_params[0].tc_rate[0], pkey);
+#endif
        }
        if (STR_EQ(str, "pipe tc 1 rate")) {
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.pipe_params[0].tc_rate[1], pkey);
+#else
                return parse_int(&targ->qos_conf.pipe_params[0].tc_rate[1], pkey);
+#endif
        }
        if (STR_EQ(str, "pipe tc 2 rate")) {
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.pipe_params[0].tc_rate[2], pkey);
+#else
                return parse_int(&targ->qos_conf.pipe_params[0].tc_rate[2], pkey);
+#endif
        }
        if (STR_EQ(str, "pipe tc 3 rate")) {
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.pipe_params[0].tc_rate[3], pkey);
+#else
                return parse_int(&targ->qos_conf.pipe_params[0].tc_rate[3], pkey);
+#endif
        }
        if (STR_EQ(str, "pipe tc period")) {
+#if RTE_VERSION > RTE_VERSION_NUM(19,11,0,0)
+               return parse_u64(&targ->qos_conf.pipe_params[0].tc_period, pkey);
+#else
                return parse_int(&targ->qos_conf.pipe_params[0].tc_period, pkey);
+#endif
        }
        if (STR_EQ(str, "police action")) {
                char *in = strstr(pkey, " io=");
@@ -1474,6 +1877,10 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                if (err) {
                        return -1;
                }
+               if (queue_id >= RTE_SCHED_BE_QUEUES_PER_PIPE) {
+                       set_errf("queue_id must be < %d", RTE_SCHED_BE_QUEUES_PER_PIPE);
+                       return -1;
+               }
                targ->qos_conf.pipe_params[0].wrr_weights[queue_id] = val;
                return 0;
        }
@@ -1500,31 +1907,41 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                return parse_int(&targ->n_max_rules, pkey);
        }
 
-        if (STR_EQ(str, "tunnel hop limit")) {
-                uint32_t val;
-                int err = parse_int(&val, pkey);
-                if (err) {
-                        return -1;
-                }
-                targ->tunnel_hop_limit = val;
-                return 0;
-        }
+       if (STR_EQ(str, "tunnel hop limit")) {
+               uint32_t val;
+               int err = parse_int(&val, pkey);
+               if (err) {
+                       return -1;
+               }
+               targ->tunnel_hop_limit = val;
+               return 0;
+       }
 
-        if (STR_EQ(str, "lookup port mask")) {
-                uint32_t val;
-                int err = parse_int(&val, pkey);
-                if (err) {
-                        return -1;
-                }
-                targ->lookup_port_mask = val;
-                return 0;
-        }
+       if (STR_EQ(str, "lookup port mask")) {
+               uint32_t val;
+               int err = parse_int(&val, pkey);
+               if (err) {
+                       return -1;
+               }
+               targ->lookup_port_mask = val;
+               return 0;
+       }
 
        if (STR_EQ(str, "irq debug")) {
                parse_int(&targ->irq_debug, pkey);
                return 0;
        }
 
+       if (STR_EQ(str, "multiplier")) {
+               parse_int(&targ->multiplier, pkey);
+               return 0;
+       }
+
+       if (STR_EQ(str, "mirror size")) {
+               parse_int(&targ->mirror_size, pkey);
+               return 0;
+       }
+
        set_errf("Option '%s' is not known", str);
        /* fail on unknown keys */
        return -1;
@@ -1576,14 +1993,14 @@ int prox_parse_args(int argc, char **argv)
                                }
                        }
 
-                       strncpy(prox_cfg.name, cfg_file + offset, MAX_NAME_SIZE);
+                       prox_strncpy(prox_cfg.name, cfg_file + offset, MAX_NAME_SIZE);
                        break;
                case 'v':
                        plog_set_lvl(atoi(optarg));
                        break;
                case 'l':
                        prox_cfg.log_name_pid = 0;
-                       strncpy(prox_cfg.log_name, optarg, MAX_NAME_SIZE);
+                       prox_strncpy(prox_cfg.log_name, optarg, MAX_NAME_SIZE);
                        break;
                case 'p':
                        prox_cfg.log_name_pid = 1;
@@ -1605,7 +2022,7 @@ int prox_parse_args(int argc, char **argv)
                case 'r':
                        if (!str_is_number(optarg) || strlen(optarg) > 11)
                                return -1;
-                       strncpy(prox_cfg.update_interval_str, optarg, sizeof(prox_cfg.update_interval_str));
+                       prox_strncpy(prox_cfg.update_interval_str, optarg, sizeof(prox_cfg.update_interval_str));
                        break;
                case 'o':
                        if (prox_cfg.flags & DSF_DAEMON)
@@ -1670,7 +2087,7 @@ int prox_parse_args(int argc, char **argv)
                            (tmp2 = strchr(tmp, '='))) {
                                *tmp2 = 0;
                                tmp3[0] = '$';
-                               strncpy(tmp3 + 1, tmp, 63);
+                               prox_strncpy(tmp3 + 1, tmp, 63);
                                plog_info("\tAdding variable: %s = %s\n", tmp3, tmp2 + 1);
                                ret = add_var(tmp3, tmp2 + 1, 1);
                                if (ret == -2) {
@@ -1883,10 +2300,14 @@ int prox_setup_rte(const char *prog_name)
        sprintf(rte_arg[++argc], "-c%s", tmp);
        rte_argv[argc] = rte_arg[argc];
 #if RTE_VERSION >= RTE_VERSION_NUM(1,8,0,0)
+       uint32_t master_core = prox_cfg.master;
        if (prox_cfg.flags & DSF_USE_DUMMY_CPU_TOPO)
-               sprintf(rte_arg[++argc], "--master-lcore=%u", 0);
-       else
-               sprintf(rte_arg[++argc], "--master-lcore=%u", prox_cfg.master);
+               master_core = 0;
+#if RTE_VERSION < RTE_VERSION_NUM(21,11,0,0)
+       sprintf(rte_arg[++argc], "--master-lcore=%u", master_core);
+#else
+       sprintf(rte_arg[++argc], "--main-lcore=%u", master_core);
+#endif
        rte_argv[argc] = rte_arg[argc];
 #else
        /* For old DPDK versions, the master core had to be the first
@@ -1949,7 +2370,7 @@ int prox_setup_rte(const char *prog_name)
                        if (ptr) {
                                *ptr++ = '\0';
                        }
-                       strcpy(rte_arg[++argc], ptr2);
+                       prox_strncpy(rte_arg[++argc], ptr2, MAX_ARG_LEN);
                        rte_argv[argc] = rte_arg[argc];
                }
        }
@@ -2000,5 +2421,20 @@ int prox_setup_rte(const char *prog_name)
                        return -1;
                }
        }
+       uint16_t port_id;
+       for (int i = 0; i < n_deferred_ports; i++) {
+               if (prox_rte_eth_dev_get_port_by_name(deferred_port[i].name, &port_id) != 0) {
+                       plog_err("Did not find port name %s used while reading %s\n", deferred_port[i].name, deferred_port[i].is_rx_port ? "rx port" : "tx_port");
+                       return -1;
+               }
+               plog_info("\tport %s is port id %d\n", deferred_port[i].name, port_id);
+               if (deferred_port[i].is_rx_port) {
+                       deferred_port[i].targ->rx_port_queue[0].port = port_id;
+                       deferred_port[i].targ->nb_rxports = 1;
+               } else {
+                       deferred_port[i].targ->tx_port_queue[0].port = port_id;
+                       deferred_port[i].targ->nb_txports = 1;
+               }
+       }
        return 0;
 }