X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ip_frag%2Fip_frag_common.h;h=835e4f93f657ad4d7b309124491932801e5f9622;hb=df52cb3b6e132603b00e55cbaf8071811bd8b20e;hp=ac5cd618ae0231f9857fca5b42761141f4540612;hpb=4f1a8f6338620091835b31ee4eee085183516a68;p=dpdk.git diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h index ac5cd618ae..835e4f93f6 100644 --- a/lib/librte_ip_frag/ip_frag_common.h +++ b/lib/librte_ip_frag/ip_frag_common.h @@ -38,17 +38,9 @@ /* logging macros. */ #ifdef RTE_LIBRTE_IP_FRAG_DEBUG - #define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, USER1, fmt, ##args) - -#define RTE_IP_FRAG_ASSERT(exp) \ -if (!(exp)) { \ - rte_panic("function %s, line%d\tassert \"" #exp "\" failed\n", \ - __func__, __LINE__); \ -} #else #define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0) -#define RTE_IP_FRAG_ASSERT(exp) do { } while(0) #endif /* IP_FRAG_DEBUG */ #define IPV4_KEYLEN 1 @@ -63,21 +55,21 @@ if (!(exp)) { \ "%08" PRIx64 "%08" PRIx64 "%08" PRIx64 "%08" PRIx64 /* internal functions declarations */ -struct rte_mbuf * ip_frag_process(struct rte_ip_frag_pkt *fp, +struct rte_mbuf * ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint16_t ofs, uint16_t len, uint16_t more_frags); -struct rte_ip_frag_pkt * ip_frag_find(struct rte_ip_frag_tbl *tbl, +struct ip_frag_pkt * ip_frag_find(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr, const struct ip_frag_key *key, uint64_t tms); -struct rte_ip_frag_pkt * ip_frag_lookup(struct rte_ip_frag_tbl *tbl, +struct ip_frag_pkt * ip_frag_lookup(struct rte_ip_frag_tbl *tbl, const struct ip_frag_key *key, uint64_t tms, - struct rte_ip_frag_pkt **free, struct rte_ip_frag_pkt **stale); + struct ip_frag_pkt **free, struct ip_frag_pkt **stale); /* these functions need to be declared here as ip_frag_process relies on them */ -struct rte_mbuf * ipv4_frag_reassemble(const struct rte_ip_frag_pkt *fp); -struct rte_mbuf * ipv6_frag_reassemble(const struct rte_ip_frag_pkt *fp); +struct rte_mbuf *ipv4_frag_reassemble(struct ip_frag_pkt *fp); +struct rte_mbuf *ipv6_frag_reassemble(struct ip_frag_pkt *fp); @@ -90,7 +82,7 @@ static inline int ip_frag_key_is_empty(const struct ip_frag_key * key) { uint32_t i; - for (i = 0; i < key->key_len; i++) + for (i = 0; i < RTE_MIN(key->key_len, RTE_DIM(key->src_dst)); i++) if (key->src_dst[i] != 0) return 0; return 1; @@ -122,7 +114,7 @@ ip_frag_key_cmp(const struct ip_frag_key * k1, const struct ip_frag_key * k2) /* put fragment on death row */ static inline void -ip_frag_free(struct rte_ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr) +ip_frag_free(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr) { uint32_t i, k; @@ -140,7 +132,7 @@ ip_frag_free(struct rte_ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr) /* if key is empty, mark key as in use */ static inline void -ip_frag_inuse(struct rte_ip_frag_tbl *tbl, const struct rte_ip_frag_pkt *fp) +ip_frag_inuse(struct rte_ip_frag_tbl *tbl, const struct ip_frag_pkt *fp) { if (ip_frag_key_is_empty(&fp->key)) { TAILQ_REMOVE(&tbl->lru, fp, lru); @@ -150,7 +142,7 @@ ip_frag_inuse(struct rte_ip_frag_tbl *tbl, const struct rte_ip_frag_pkt *fp) /* reset the fragment */ static inline void -ip_frag_reset(struct rte_ip_frag_pkt *fp, uint64_t tms) +ip_frag_reset(struct ip_frag_pkt *fp, uint64_t tms) { static const struct ip_frag zero_frag = { .ofs = 0, @@ -166,28 +158,4 @@ ip_frag_reset(struct rte_ip_frag_pkt *fp, uint64_t tms) fp->frags[IP_FIRST_FRAG_IDX] = zero_frag; } -/* chain two mbufs */ -static inline void -ip_frag_chain(struct rte_mbuf *mn, struct rte_mbuf *mp) -{ - struct rte_mbuf *ms; - - /* adjust start of the last fragment data. */ - rte_pktmbuf_adj(mp, (uint16_t)(mp->pkt.vlan_macip.f.l2_len + - mp->pkt.vlan_macip.f.l3_len)); - - /* chain two fragments. */ - ms = rte_pktmbuf_lastseg(mn); - ms->pkt.next = mp; - - /* accumulate number of segments and total length. */ - mn->pkt.nb_segs = (uint8_t)(mn->pkt.nb_segs + mp->pkt.nb_segs); - mn->pkt.pkt_len += mp->pkt.pkt_len; - - /* reset pkt_len and nb_segs for chained fragment. */ - mp->pkt.pkt_len = mp->pkt.data_len; - mp->pkt.nb_segs = 1; -} - - #endif /* _IP_FRAG_COMMON_H_ */