Support packets in flight
[samplevnf.git] / VNFs / DPPD-PROX / task_base.h
index 62841e9..89e5bb9 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.
@@ -36,6 +36,7 @@
 #define TASK_FP_HANDLE_ARP             0x0040
 #define TASK_TX_CRC                    0x0080
 #define TASK_L3                        0x0100
+#define TASK_DO_NOT_FWD_GENEVE         0x0200
 
 // flag_features 64 bits
 #define TASK_FEATURE_ROUTING           0x0001
@@ -44,7 +45,7 @@
 #define TASK_FEATURE_NEVER_DISCARDS            0x0008
 #define TASK_FEATURE_NO_RX                     0x0010
 #define TASK_FEATURE_TXQ_FLAGS_NOOFFLOADS      0x0020
-#define TASK_FEATURE_TXQ_FLAGS_NOMULTSEGS      0x0040
+#define TASK_FEATURE_TXQ_FLAGS_MULTSEGS        0x0040
 #define TASK_FEATURE_ZERO_RX                   0x0080
 #define TASK_FEATURE_TXQ_FLAGS_REFCOUNT        0x0100
 #define TASK_FEATURE_TSC_RX                    0x0200
 #define TASK_FEATURE_LUT_QINQ_RSS              0x2000
 #define TASK_FEATURE_LUT_QINQ_HASH             0x4000
 #define TASK_FEATURE_RX_ALL                    0x8000
-#define TASK_MULTIPLE_MAC                      0x10000
-#define TASK_FEATURE_L3                                0x20000
+#define TASK_FEATURE_TXQ_FLAGS_MULTIPLE_MEMPOOL        0x20000
 
-#define FLAG_TX_FLUSH                  0x01
-#define FLAG_NEVER_FLUSH               0x02
+#define TBASE_FLAG_TX_FLUSH             0x01
+#define TBASE_FLAG_NEVER_FLUSH          0x02
 // Task specific flags
-#define BASE_FLAG_LUT_QINQ_HASH        0x08
-#define BASE_FLAG_LUT_QINQ_RSS         0x10
+#define TBASE_FLAG_LUT_QINQ_HASH               0x08
+#define TBASE_FLAG_LUT_QINQ_RSS        0x10
 
 #define OUT_DISCARD 0xFF
 #define OUT_HANDLED 0xFE
@@ -144,6 +144,9 @@ struct task_base;
 
 #define MAX_RX_PKT_ALL 16384
 
+#define RX_BUCKET_SIZE (2 * MAX_RING_BURST + 1) /* Limit RX bucket size */
+#define TX_BUCKET_SIZE (MAX_RING_BURST +1)
+
 #define MAX_STACKED_RX_FUCTIONS 16
 
 typedef uint16_t (*rx_pkt_func) (struct task_base *tbase, struct rte_mbuf ***mbufs);
@@ -151,7 +154,6 @@ typedef uint16_t (*rx_pkt_func) (struct task_base *tbase, struct rte_mbuf ***mbu
 struct task_base_aux {
        /* Not used when PROX_STATS is not defined */
        struct task_rt_stats stats;
-       struct task_rt_dump task_rt_dump;
 
        /* Used if TASK_TSC_RX is enabled*/
        struct {
@@ -161,20 +163,23 @@ struct task_base_aux {
 
        struct  rte_mbuf **all_mbufs;
 
-       int      rx_prev_count;
-       int      rx_prev_idx;
+       uint16_t      rx_prev_count;
+       uint16_t      rx_prev_idx;
        uint16_t (*rx_pkt_prev[MAX_STACKED_RX_FUCTIONS])(struct task_base *tbase, struct rte_mbuf ***mbufs);
 
-       uint32_t rx_bucket[MAX_RING_BURST + 1];
-       uint32_t tx_bucket[MAX_RING_BURST + 1];
+       uint32_t rx_bucket[RX_BUCKET_SIZE];
+       uint32_t tx_bucket[TX_BUCKET_SIZE];
        int (*tx_pkt_l2)(struct task_base *tbase, struct rte_mbuf **mbufs, const uint16_t n_pkts, uint8_t *out);
        int (*tx_pkt_orig)(struct task_base *tbase, struct rte_mbuf **mbufs, const uint16_t n_pkts, uint8_t *out);
        int (*tx_pkt_hw)(struct task_base *tbase, struct rte_mbuf **mbufs, const uint16_t n_pkts, uint8_t *out);
        uint16_t (*tx_pkt_try)(struct task_base *tbase, struct rte_mbuf **mbufs, const uint16_t n_pkts);
        void (*stop)(struct task_base *tbase);
+       int (*tx_ctrlplane_pkt)(struct task_base *tbase, struct rte_mbuf **mbufs, const uint16_t n_pkts, uint8_t *out);
        void (*start)(struct task_base *tbase);
        void (*stop_last)(struct task_base *tbase);
        void (*start_first)(struct task_base *tbase);
+       struct task_rt_dump task_rt_dump;
+       struct rte_mbuf *mbuf;
 };
 
 /* The task_base is accessed for _all_ task types. In case
@@ -205,7 +210,6 @@ struct task_base {
                struct tx_params_hw_sw tx_params_hw_sw;
        };
        struct l3_base l3;
-       uint32_t local_ipv4;
 } __attribute__((packed)) __rte_cache_aligned;
 
 static void task_base_add_rx_pkt_function(struct task_base *tbase, rx_pkt_func to_add)
@@ -214,8 +218,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;
@@ -227,8 +231,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) {