examples/ipsec-secgw: add check for unprotected port mask
[dpdk.git] / examples / ipsec-secgw / ipsec-secgw.h
index 96e22de..ac4fa5e 100644 (file)
@@ -6,9 +6,6 @@
 
 #include <stdbool.h>
 
-#ifndef STATS_INTERVAL
-#define STATS_INTERVAL 0
-#endif
 
 #define NB_SOCKETS 4
 
@@ -83,7 +80,17 @@ struct ethaddr_info {
        uint64_t src, dst;
 };
 
-#if (STATS_INTERVAL > 0)
+struct ipsec_spd_stats {
+       uint64_t protect;
+       uint64_t bypass;
+       uint64_t discard;
+};
+
+struct ipsec_sa_stats {
+       uint64_t hit;
+       uint64_t miss;
+};
+
 struct ipsec_core_statistics {
        uint64_t tx;
        uint64_t rx;
@@ -91,10 +98,29 @@ struct ipsec_core_statistics {
        uint64_t tx_call;
        uint64_t dropped;
        uint64_t burst_rx;
+
+       struct {
+               struct ipsec_spd_stats spd4;
+               struct ipsec_spd_stats spd6;
+               struct ipsec_sa_stats sad;
+       } outbound;
+
+       struct {
+               struct ipsec_spd_stats spd4;
+               struct ipsec_spd_stats spd6;
+               struct ipsec_sa_stats sad;
+       } inbound;
+
+       struct {
+               uint64_t miss;
+       } lpm4;
+
+       struct {
+               uint64_t miss;
+       } lpm6;
 } __rte_cache_aligned;
 
-struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE];
-#endif /* STATS_INTERVAL */
+extern struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE];
 
 extern struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS];
 
@@ -106,6 +132,8 @@ extern uint32_t single_sa_idx;
 
 extern volatile bool force_quit;
 
+extern uint32_t nb_bufs_in_pool;
+
 static inline uint8_t
 is_unprotected_port(uint16_t port_id)
 {
@@ -115,38 +143,26 @@ is_unprotected_port(uint16_t port_id)
 static inline void
 core_stats_update_rx(int n)
 {
-#if (STATS_INTERVAL > 0)
        int lcore_id = rte_lcore_id();
        core_statistics[lcore_id].rx += n;
        core_statistics[lcore_id].rx_call++;
        if (n == MAX_PKT_BURST)
                core_statistics[lcore_id].burst_rx += n;
-#else
-       RTE_SET_USED(n);
-#endif /* STATS_INTERVAL */
 }
 
 static inline void
 core_stats_update_tx(int n)
 {
-#if (STATS_INTERVAL > 0)
        int lcore_id = rte_lcore_id();
        core_statistics[lcore_id].tx += n;
        core_statistics[lcore_id].tx_call++;
-#else
-       RTE_SET_USED(n);
-#endif /* STATS_INTERVAL */
 }
 
 static inline void
 core_stats_update_drop(int n)
 {
-#if (STATS_INTERVAL > 0)
        int lcore_id = rte_lcore_id();
        core_statistics[lcore_id].dropped += n;
-#else
-       RTE_SET_USED(n);
-#endif /* STATS_INTERVAL */
 }
 
 /* helper routine to free bulk of packets */