ip_frag: add function to delete expired entries
[dpdk.git] / lib / librte_ip_frag / ip_frag_common.h
index 197acf8..0fdcc7d 100644 (file)
 #define IPv6_KEY_BYTES_FMT \
        "%08" PRIx64 "%08" PRIx64 "%08" PRIx64 "%08" PRIx64
 
+#ifdef RTE_LIBRTE_IP_FRAG_TBL_STAT
+#define        IP_FRAG_TBL_STAT_UPDATE(s, f, v)        ((s)->f += (v))
+#else
+#define        IP_FRAG_TBL_STAT_UPDATE(s, f, v)        do {} while (0)
+#endif /* IP_FRAG_TBL_STAT */
+
 /* internal functions declarations */
 struct rte_mbuf * ip_frag_process(struct ip_frag_pkt *fp,
                struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb,
@@ -149,4 +155,16 @@ ip_frag_reset(struct ip_frag_pkt *fp, uint64_t tms)
        fp->frags[IP_FIRST_FRAG_IDX] = zero_frag;
 }
 
+/* local frag table helper functions */
+static inline void
+ip_frag_tbl_del(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr,
+       struct ip_frag_pkt *fp)
+{
+       ip_frag_free(fp, dr);
+       ip_frag_key_invalidate(&fp->key);
+       TAILQ_REMOVE(&tbl->lru, fp, lru);
+       tbl->use_entries--;
+       IP_FRAG_TBL_STAT_UPDATE(&tbl->stat, del_num, 1);
+}
+
 #endif /* _IP_FRAG_COMMON_H_ */