Merge "Add support for DPDK 17.11"
authorDeepak S <deepak.s@linux.intel.com>
Tue, 16 Jan 2018 12:51:27 +0000 (12:51 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Tue, 16 Jan 2018 12:51:27 +0000 (12:51 +0000)
VNFs/DPPD-PROX/handle_esp.c
VNFs/DPPD-PROX/handle_l2fwd.c
VNFs/DPPD-PROX/handle_lat.c
VNFs/DPPD-PROX/handle_swap.c
VNFs/DPPD-PROX/lconf.c
VNFs/DPPD-PROX/prox_args.c
VNFs/DPPD-PROX/rx_pkt.c
VNFs/DPPD-PROX/task_base.h

index ebdd2dc..ab61f66 100644 (file)
@@ -309,7 +309,6 @@ static inline uint8_t handle_esp_ah_enc(struct task_esp_enc *task, struct rte_mb
         struct ether_addr dst_mac  = peth->d_addr;
         uint32_t          src_addr = pip4->src_addr;
         uint32_t          dst_addr = pip4->dst_addr;
-        uint8_t           ttl      = pip4->time_to_live;
         uint8_t           version_ihl = pip4->version_ihl;
 
         peth = (struct ether_hdr *)rte_pktmbuf_prepend(mbuf, extra_space); // encap + prefix
@@ -329,13 +328,14 @@ static inline uint8_t handle_esp_ah_enc(struct task_esp_enc *task, struct rte_mb
         pip4 = (struct ipv4_hdr *)(peth + 1);
         pip4->src_addr = task->local_ipv4;
         pip4->dst_addr = task->remote_ipv4;
-        pip4->time_to_live = ttl;
         pip4->next_proto_id = IPPROTO_ESP; // 50 for ESP, ip in ip next proto trailer
         pip4->version_ihl = version_ihl; // 20 bytes, ipv4
         pip4->total_length = rte_cpu_to_be_16(ipv4_length + sizeof(struct ipv4_hdr) + 4 + 4 + CIPHER_IV_LENGTH_AES_CBC + padding + 1 + 1 + DIGEST_BYTE_LENGTH_SHA1); // iphdr+SPI+SN+IV+payload+padding+padlen+next header + crc + auth
         pip4->packet_id = 0x0101;
         pip4->type_of_service = 0;
         pip4->time_to_live = 64;
+        pip4->fragment_offset = rte_cpu_to_be_16(0x4000);
+       pip4->hdr_checksum = 0;
         prox_ip_cksum_sw(pip4);
 
         //find the SA when there will be more than one
@@ -458,12 +458,11 @@ static inline uint8_t handle_esp_ah_dec_finish(struct task_esp_dec *task, struct
 
         int len = rte_pktmbuf_pkt_len(mbuf);
         rte_pktmbuf_trim(mbuf, len - sizeof (struct ether_hdr) - ipv4_length);
-        prox_ip_cksum_sw(pip4);
-        peth = rte_pktmbuf_mtod(mbuf, struct ether_hdr *);
-
 #if 1
         do_ipv4_swap(task, mbuf);
 #endif
+        pip4->hdr_checksum = 0;
+        prox_ip_cksum_sw(pip4);
 //              one key for them all for now
 //              set key
 //      struct crypto_aes_ctx ctx;
index 79a5f02..faebe6f 100644 (file)
@@ -69,17 +69,21 @@ static void init_task_l2fwd(struct task_base *tbase, struct task_args *targ)
        struct ether_addr *src_addr, *dst_addr;
 
        /*
-        * Destination MAC can come from
-        *    - pre-configured mac in case 'dst mac=xx:xx:xx:xx:xx:xx' in config file
-        *    - src mac from the packet in case 'dst mac=packet' in config file
-        *    - not written in case 'dst mac=no' in config file
-        *    - (default - no 'dst mac') src mac from the packet
-        * Source MAC can come from
-        *    - pre-configured mac in case 'src mac=xx:xx:xx:xx:xx:xx' in config file
-        *    - dst mac from the packet in case 'src mac=packet' in config file
-        *    - not written in case 'src mac=no' in config file
-        *    - (default - no 'src mac') if (tx_port) port mac
-        *    - (default - no 'src mac') if (no tx_port) dst mac from the packet
+        * The destination MAC of the outgoing packet is based on the config file:
+        *    - 'dst mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as dst mac
+        *    - 'dst mac=packet'            => the src mac of the incoming packet is used as dst mac
+        *    - 'dst mac=no'                => the dst mac is untouched
+        *    - (default - no 'dst mac')    => the src mac from the incoming packet is used as dst mac
+        *
+        * The source MAC of the outgoing packet is based on the config file:
+        *    - 'src mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as src mac
+        *    - 'src mac=packet'            => the dst mac of the incoming packet is used as src mac
+        *    - 'src mac=hw'                => the mac address of the tx port is used as src mac
+        *                                     An error is returned if there are no physical tx ports
+        *    - 'src mac=no'                => the src mac is untouched
+        *    - (default - no 'src mac')    => if there is physical tx port, the mac of that port is used as src mac
+        *    - (default - no 'src mac')       if there are no physical tx ports the dst mac of the incoming packet
+                                                    is used as src mac
         */
 
        if (targ->flags & TASK_ARG_DST_MAC_SET) {
@@ -92,6 +96,8 @@ static void init_task_l2fwd(struct task_base *tbase, struct task_args *targ)
                memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr));
                plog_info("\t\tCore %d: src mac set from config file\n", targ->lconf->id);
        } else if ((targ->flags & TASK_ARG_DO_NOT_SET_SRC_MAC) == 0) {
+               if (targ->flags & TASK_ARG_HW_SRC_MAC)
+                       PROX_PANIC(targ->nb_txports == 0, "src mac set to hw but no tx port\n");
                if (targ->nb_txports) {
                        src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr;
                        targ->flags |= TASK_ARG_SRC_MAC_SET;
index 0b7ad56..95ebcc7 100644 (file)
@@ -611,6 +611,9 @@ static void init_task_lat(struct task_base *tbase, struct task_args *targ)
 
        task->lat_pos = targ->lat_pos;
        task->accur_pos = targ->accur_pos;
+       task->sig_pos = targ->sig_pos;
+       task->sig = targ->sig;
+
        task->unique_id_pos = targ->packet_id_pos;
        task->latency_buffer_size = targ->latency_buffer_size;
 
index 516d3f6..68dfe2b 100644 (file)
@@ -203,17 +203,18 @@ static void init_task_swap(struct task_base *tbase, struct task_args *targ)
        struct ether_addr *src_addr, *dst_addr;
 
        /*
-        * Destination MAC can come from
-        *    - pre-configured mac in case 'dst mac=xx:xx:xx:xx:xx:xx' in config file
-        *    - src mac from the packet in case 'dst mac=packet' in config file
-        *    - not written in case 'dst mac=no' in config file
-        *    - (default - no 'dst mac') src mac from the packet
-        * Source MAC can come from
-        *    - pre-configured mac in case 'src mac=xx:xx:xx:xx:xx:xx' in config file
-        *    - dst mac from the packet in case 'src mac=packet' in config file
-        *    - not written in case 'src mac=no' in config file
-        *    - (default - no 'src mac') if (tx_port) port mac
-        *    - (default - no 'src mac') if (no tx_port) dst mac from the packet
+        * The destination MAC of the outgoing packet is based on the config file:
+        *    - 'dst mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as dst mac
+        *    - 'dst mac=packet'            => the src mac of the incoming packet is used as dst mac
+        *    - (default - no 'dst mac')    => the src mac from the incoming packet is used as dst mac
+        *
+        * The source MAC of the outgoing packet is based on the config file:
+        *    - 'src mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as src mac
+        *    - 'src mac=packet'            => the dst mac of the incoming packet is used as src mac
+        *    - 'src mac=hw'                => the mac address of the tx port is used as src mac
+        *                                     An error is returned if there are no physical tx ports
+        *    - (default - no 'src mac')    => if there is physical tx port, the mac of that port is used as src mac
+        *    - (default - no 'src mac')       if there are no physical tx ports the dst mac of the incoming packet
         */
 
        if (targ->flags & TASK_ARG_DST_MAC_SET) {
@@ -221,14 +222,19 @@ static void init_task_swap(struct task_base *tbase, struct task_args *targ)
                memcpy(&task->src_dst_mac[0], dst_addr, sizeof(*src_addr));
        }
 
+       PROX_PANIC(targ->flags & TASK_ARG_DO_NOT_SET_SRC_MAC, "src mac must be set in swap mode, by definition => src mac=no is not supported\n");
+       PROX_PANIC(targ->flags & TASK_ARG_DO_NOT_SET_DST_MAC, "dst mac must be set in swap mode, by definition => dst mac=no is not supported\n");
+
        if (targ->flags & TASK_ARG_SRC_MAC_SET) {
                src_addr =  &targ->esaddr;
                memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr));
                plog_info("\t\tCore %d: src mac set from config file\n", targ->lconf->id);
-       } else if (targ->nb_txports) {
-               src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr;
-               memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr));
-               if (targ->flags & TASK_ARG_HW_SRC_MAC){
+       } else {
+               if (targ->flags & TASK_ARG_HW_SRC_MAC)
+                       PROX_PANIC(targ->nb_txports == 0, "src mac set to hw but no tx port\n");
+               if (targ->nb_txports) {
+                       src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr;
+                       memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr));
                        targ->flags |= TASK_ARG_SRC_MAC_SET;
                        plog_info("\t\tCore %d: src mac set from port\n", targ->lconf->id);
                }
index 399c8a7..682c106 100644 (file)
@@ -307,10 +307,10 @@ int lconf_do_flags(struct lcore_cfg *lconf)
                        t = lconf->tasks_all[task_id];
                        if (t->aux->tx_pkt_orig) {
                                if (t->tx_pkt == tx_pkt_l3) {
-                                       t->tx_pkt = t->aux->tx_pkt_orig;
+                                       t->aux->tx_pkt_l2 = t->aux->tx_pkt_orig;
                                        t->aux->tx_pkt_orig = NULL;
                                } else {
-                                       t->aux->tx_pkt_l2 = t->aux->tx_pkt_orig;
+                                       t->tx_pkt = t->aux->tx_pkt_orig;
                                        t->aux->tx_pkt_orig = NULL;
                                }
                                lconf->flags &= ~LCONF_FLAG_TX_DISTR_ACTIVE;
index 97b4fb1..fb05380 100644 (file)
@@ -1293,7 +1293,7 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
                        }
                        else if (STR_EQ(pkey, "packet"))
                                return 0;
-                       else if (STR_EQ(pkey, "packet")) {
+                       else if (STR_EQ(pkey, "hw")) {
                                targ->flags |= TASK_ARG_HW_SRC_MAC;
                                return 0;
                        } else {
index ec698d9..bd06b26 100644 (file)
@@ -388,13 +388,9 @@ static uint16_t call_prev_rx_pkt(struct task_base *tbase, struct rte_mbuf ***mbu
 {
        uint16_t ret;
 
-       if (tbase->aux->rx_prev_idx + 1 == tbase->aux->rx_prev_count) {
-               ret = tbase->aux->rx_pkt_prev[tbase->aux->rx_prev_idx](tbase, mbufs);
-       } else {
-               tbase->aux->rx_prev_idx++;
-               ret = tbase->aux->rx_pkt_prev[tbase->aux->rx_prev_idx](tbase, mbufs);
-               tbase->aux->rx_prev_idx--;
-       }
+       tbase->aux->rx_prev_idx++;
+       ret = tbase->aux->rx_pkt_prev[tbase->aux->rx_prev_idx - 1](tbase, mbufs);
+       tbase->aux->rx_prev_idx--;
 
        return ret;
 }
index ad00962..f8c0524 100644 (file)
@@ -213,8 +213,8 @@ static void task_base_add_rx_pkt_function(struct task_base *tbase, rx_pkt_func t
                return;
        }
 
-       for (int16_t i = tbase->aux->rx_prev_count; i >= 0; --i) {
-               tbase->aux->rx_pkt_prev[i + 1] = tbase->aux->rx_pkt_prev[i];
+       for (int16_t i = tbase->aux->rx_prev_count; i > 0; --i) {
+               tbase->aux->rx_pkt_prev[i] = tbase->aux->rx_pkt_prev[i - 1];
        }
        tbase->aux->rx_pkt_prev[0] = tbase->rx_pkt;
        tbase->rx_pkt = to_add;
@@ -226,8 +226,13 @@ static void task_base_del_rx_pkt_function(struct task_base *tbase, rx_pkt_func t
        int cur = 0;
        int found = 0;
 
-       if (tbase->aux->rx_prev_count == 1) {
+       if (unlikely(tbase->aux->rx_prev_count == 0)) {
+               return;
+       } else if (tbase->rx_pkt == to_del) {
                tbase->rx_pkt = tbase->aux->rx_pkt_prev[0];
+               for (int16_t i = 0; i < tbase->aux->rx_prev_count - 1; ++i) {
+                       tbase->aux->rx_pkt_prev[i] = tbase->aux->rx_pkt_prev[i + 1];
+               }
                found = 1;
        } else {
                for (int16_t i = 0; i < tbase->aux->rx_prev_count; ++i) {