DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples
@ 2014-06-18 14:50 Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 01/10] ip_frag: rename RTE_IP_FRAG_ASSERT to IP_FRAG_ASSERT Anatoly Burakov
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev

This patchset fixes a few issues found during validation, and also
does a bunch of renames (so that internally-used data structures aren't
starting with rte_) and fixes a few typos.

Anatoly Burakov (10):
  ip_frag: rename RTE_IP_FRAG_ASSERT to IP_FRAG_ASSERT
  ip_frag: fix debug macros
  ip_frag: renaming rte_ip_frag_pkt to ip_frag_pkt
  ip_frag: fix stats macro, rename rte_ip_frag_tbl_stat structure
  ip_frag: small fix, replace hardcode with a macro
  ip_frag: replace memmove with custom copying
  ip_frag: fix order of arguments to key compare function
  ip_fragmentation: small fixes
  ip_reassembly: small fixes
  rte_ip_frag: API header file fix

 config/common_bsdapp                        |  1 +
 config/common_linuxapp                      |  1 +
 examples/ip_fragmentation/main.c            |  6 +++++-
 examples/ip_reassembly/main.c               | 16 ++++++++++------
 lib/librte_ip_frag/ip_frag_common.h         | 22 +++++++++++-----------
 lib/librte_ip_frag/ip_frag_internal.c       | 28 ++++++++++++++--------------
 lib/librte_ip_frag/rte_ip_frag.h            | 20 ++++++++++----------
 lib/librte_ip_frag/rte_ipv4_fragmentation.c |  2 +-
 lib/librte_ip_frag/rte_ipv4_reassembly.c    | 10 +++++-----
 lib/librte_ip_frag/rte_ipv6_fragmentation.c |  2 +-
 lib/librte_ip_frag/rte_ipv6_reassembly.c    | 16 +++++++++++++---
 11 files changed, 72 insertions(+), 52 deletions(-)

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 01/10] ip_frag: rename RTE_IP_FRAG_ASSERT to IP_FRAG_ASSERT
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 02/10] ip_frag: fix debug macros Anatoly Burakov
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev


Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ip_frag/ip_frag_common.h         | 4 ++--
 lib/librte_ip_frag/rte_ipv4_fragmentation.c | 2 +-
 lib/librte_ip_frag/rte_ipv6_fragmentation.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h
index ac5cd61..5ad0a0b 100644
--- a/lib/librte_ip_frag/ip_frag_common.h
+++ b/lib/librte_ip_frag/ip_frag_common.h
@@ -41,14 +41,14 @@
 
 #define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, USER1, fmt, ##args)
 
-#define	RTE_IP_FRAG_ASSERT(exp)					\
+#define	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)
+#define IP_FRAG_ASSERT(exp)	do { } while(0)
 #endif /* IP_FRAG_DEBUG */
 
 #define IPV4_KEYLEN 1
diff --git a/lib/librte_ip_frag/rte_ipv4_fragmentation.c b/lib/librte_ip_frag/rte_ipv4_fragmentation.c
index 3ab665f..9d4e1f7 100644
--- a/lib/librte_ip_frag/rte_ipv4_fragmentation.c
+++ b/lib/librte_ip_frag/rte_ipv4_fragmentation.c
@@ -107,7 +107,7 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
 	frag_size = (uint16_t)(mtu_size - sizeof(struct ipv4_hdr));
 
 	/* Fragment size should be a multiply of 8. */
-	RTE_IP_FRAG_ASSERT((frag_size & IPV4_HDR_FO_MASK) == 0);
+	IP_FRAG_ASSERT((frag_size & IPV4_HDR_FO_MASK) == 0);
 
 	in_hdr = (struct ipv4_hdr *) pkt_in->pkt.data;
 	flag_offset = rte_cpu_to_be_16(in_hdr->fragment_offset);
diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
index 6b660c4..fa04991 100644
--- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c
+++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
@@ -118,7 +118,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
 	frag_size = (uint16_t)(mtu_size - sizeof(struct ipv6_hdr));
 
 	/* Fragment size should be a multiple of 8. */
-	RTE_IP_FRAG_ASSERT((frag_size & IPV6_HDR_FO_MASK) == 0);
+	IP_FRAG_ASSERT((frag_size & IPV6_HDR_FO_MASK) == 0);
 
 	/* Check that pkts_out is big enough to hold all fragments */
 	if (unlikely (frag_size * nb_pkts_out <
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 02/10] ip_frag: fix debug macros
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 01/10] ip_frag: rename RTE_IP_FRAG_ASSERT to IP_FRAG_ASSERT Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 03/10] ip_frag: renaming rte_ip_frag_pkt to ip_frag_pkt Anatoly Burakov
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev


Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ip_frag/rte_ipv4_reassembly.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c b/lib/librte_ip_frag/rte_ipv4_reassembly.c
index cbac413..c14c677 100644
--- a/lib/librte_ip_frag/rte_ipv4_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c
@@ -145,7 +145,7 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 		"tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, "
 		"max_entries: %u, use_entries: %u\n\n",
 		__func__, __LINE__,
-		mb, tms, key.src_dst, key.id, ip_ofs, ip_len, ip_flag,
+		mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, ip_flag,
 		tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries,
 		tbl->use_entries);
 
@@ -161,7 +161,7 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 		", total_size: %u, frag_size: %u, last_idx: %u\n\n",
 		__func__, __LINE__,
 		tbl, tbl->max_entries, tbl->use_entries,
-		fp, fp->key.src_dst, fp->key.id, fp->start,
+		fp, fp->key.src_dst[0], fp->key.id, fp->start,
 		fp->total_size, fp->frag_size, fp->last_idx);
 
 
@@ -176,7 +176,7 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 		", total_size: %u, frag_size: %u, last_idx: %u\n\n",
 		__func__, __LINE__, mb,
 		tbl, tbl->max_entries, tbl->use_entries,
-		fp, fp->key.src_dst, fp->key.id, fp->start,
+		fp, fp->key.src_dst[0], fp->key.id, fp->start,
 		fp->total_size, fp->frag_size, fp->last_idx);
 
 	return (mb);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 03/10] ip_frag: renaming rte_ip_frag_pkt to ip_frag_pkt
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 01/10] ip_frag: rename RTE_IP_FRAG_ASSERT to IP_FRAG_ASSERT Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 02/10] ip_frag: fix debug macros Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 04/10] ip_frag: fix stats macro, rename rte_ip_frag_tbl_stat structure Anatoly Burakov
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev


Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ip_frag/ip_frag_common.h      | 18 +++++++++---------
 lib/librte_ip_frag/ip_frag_internal.c    | 20 ++++++++++----------
 lib/librte_ip_frag/rte_ip_frag.h         | 12 ++++++------
 lib/librte_ip_frag/rte_ipv4_reassembly.c |  4 ++--
 lib/librte_ip_frag/rte_ipv6_reassembly.c |  4 ++--
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h
index 5ad0a0b..9df8074 100644
--- a/lib/librte_ip_frag/ip_frag_common.h
+++ b/lib/librte_ip_frag/ip_frag_common.h
@@ -63,21 +63,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(const struct ip_frag_pkt *fp);
+struct rte_mbuf * ipv6_frag_reassemble(const struct ip_frag_pkt *fp);
 
 
 
@@ -122,7 +122,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 +140,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 +150,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,
diff --git a/lib/librte_ip_frag/ip_frag_internal.c b/lib/librte_ip_frag/ip_frag_internal.c
index cfcab1b..219221f 100644
--- a/lib/librte_ip_frag/ip_frag_internal.c
+++ b/lib/librte_ip_frag/ip_frag_internal.c
@@ -54,7 +54,7 @@
 /* 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 rte_ip_frag_pkt *fp)
+	struct ip_frag_pkt *fp)
 {
 	ip_frag_free(fp, dr);
 	ip_frag_key_invalidate(&fp->key);
@@ -64,7 +64,7 @@ ip_frag_tbl_del(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr,
 }
 
 static inline void
-ip_frag_tbl_add(struct rte_ip_frag_tbl *tbl,  struct rte_ip_frag_pkt *fp,
+ip_frag_tbl_add(struct rte_ip_frag_tbl *tbl,  struct ip_frag_pkt *fp,
 	const struct ip_frag_key *key, uint64_t tms)
 {
 	fp->key = key[0];
@@ -76,7 +76,7 @@ ip_frag_tbl_add(struct rte_ip_frag_tbl *tbl,  struct rte_ip_frag_pkt *fp,
 
 static inline void
 ip_frag_tbl_reuse(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr,
-	struct rte_ip_frag_pkt *fp, uint64_t tms)
+	struct ip_frag_pkt *fp, uint64_t tms)
 {
 	ip_frag_free(fp, dr);
 	ip_frag_reset(fp, tms);
@@ -137,7 +137,7 @@ ipv6_frag_hash(const struct ip_frag_key *key, uint32_t *v1, uint32_t *v2)
 }
 
 struct rte_mbuf *
-ip_frag_process(struct rte_ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr,
+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)
 {
 	uint32_t idx;
@@ -268,11 +268,11 @@ ip_frag_process(struct rte_ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr,
  * If such entry is not present, then allocate a new one.
  * If the entry is stale, then free and reuse it.
  */
-struct rte_ip_frag_pkt *
+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 *pkt, *free, *stale, *lru;
+	struct ip_frag_pkt *pkt, *free, *stale, *lru;
 	uint64_t max_cycles;
 
 	/*
@@ -330,13 +330,13 @@ ip_frag_find(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr,
 	return (pkt);
 }
 
-struct rte_ip_frag_pkt *
+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)
 {
-	struct rte_ip_frag_pkt *p1, *p2;
-	struct rte_ip_frag_pkt *empty, *old;
+	struct ip_frag_pkt *p1, *p2;
+	struct ip_frag_pkt *empty, *old;
 	uint64_t max_cycles;
 	uint32_t i, assoc, sig1, sig2;
 
diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h
index f1e7036..582a52b 100644
--- a/lib/librte_ip_frag/rte_ip_frag.h
+++ b/lib/librte_ip_frag/rte_ip_frag.h
@@ -75,8 +75,8 @@ struct ip_frag_key {
  * @internal Fragmented packet to reassemble.
  * First two entries in the frags[] array are for the last and first fragments.
  */
-struct rte_ip_frag_pkt {
-	TAILQ_ENTRY(rte_ip_frag_pkt) lru;   /**< LRU list */
+struct ip_frag_pkt {
+	TAILQ_ENTRY(ip_frag_pkt) lru;   /**< LRU list */
 	struct ip_frag_key key;           /**< fragmentation key */
 	uint64_t             start;       /**< creation timestamp */
 	uint32_t             total_size;  /**< expected reassembled size */
@@ -94,7 +94,7 @@ struct rte_ip_frag_death_row {
 	/**< mbufs to be freed */
 };
 
-TAILQ_HEAD(rte_ip_pkt_list, rte_ip_frag_pkt); /**< @internal fragments tailq */
+TAILQ_HEAD(ip_pkt_list, ip_frag_pkt); /**< @internal fragments tailq */
 
 /** fragmentation table statistics */
 struct rte_ip_frag_tbl_stat {
@@ -115,10 +115,10 @@ struct rte_ip_frag_tbl {
 	uint32_t             bucket_entries;  /**< hash assocaitivity. */
 	uint32_t             nb_entries;      /**< total size of the table. */
 	uint32_t             nb_buckets;      /**< num of associativity lines. */
-	struct rte_ip_frag_pkt *last;         /**< last used entry. */
-	struct rte_ip_pkt_list lru;           /**< LRU list for table entries. */
+	struct ip_frag_pkt *last;         /**< last used entry. */
+	struct ip_pkt_list lru;           /**< LRU list for table entries. */
 	struct rte_ip_frag_tbl_stat stat;     /**< statistics counters. */
-	struct rte_ip_frag_pkt pkt[0];        /**< hash table. */
+	struct ip_frag_pkt pkt[0];        /**< hash table. */
 };
 
 /** IPv6 fragment extension header */
diff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c b/lib/librte_ip_frag/rte_ipv4_reassembly.c
index c14c677..a27b23a 100644
--- a/lib/librte_ip_frag/rte_ipv4_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c
@@ -42,7 +42,7 @@
  * Reassemble fragments into one packet.
  */
 struct rte_mbuf *
-ipv4_frag_reassemble(const struct rte_ip_frag_pkt *fp)
+ipv4_frag_reassemble(const struct ip_frag_pkt *fp)
 {
 	struct ipv4_hdr *ip_hdr;
 	struct rte_mbuf *m, *prev;
@@ -119,7 +119,7 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 		struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint64_t tms,
 		struct ipv4_hdr *ip_hdr)
 {
-	struct rte_ip_frag_pkt *fp;
+	struct ip_frag_pkt *fp;
 	struct ip_frag_key key;
 	const uint64_t *psd;
 	uint16_t ip_len;
diff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_frag/rte_ipv6_reassembly.c
index 1d83c79..c622827 100644
--- a/lib/librte_ip_frag/rte_ipv6_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c
@@ -49,7 +49,7 @@
  * Reassemble fragments into one packet.
  */
 struct rte_mbuf *
-ipv6_frag_reassemble(const struct rte_ip_frag_pkt *fp)
+ipv6_frag_reassemble(const struct ip_frag_pkt *fp)
 {
 	struct ipv6_hdr *ip_hdr;
 	struct ipv6_extension_fragment *frag_hdr;
@@ -148,7 +148,7 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 		struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint64_t tms,
 		struct ipv6_hdr *ip_hdr, struct ipv6_extension_fragment *frag_hdr)
 {
-	struct rte_ip_frag_pkt *fp;
+	struct ip_frag_pkt *fp;
 	struct ip_frag_key key;
 	uint16_t ip_len, ip_ofs;
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 04/10] ip_frag: fix stats macro, rename rte_ip_frag_tbl_stat structure
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
                   ` (2 preceding siblings ...)
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 03/10] ip_frag: renaming rte_ip_frag_pkt to ip_frag_pkt Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 05/10] ip_frag: small fix, replace hardcode with a macro Anatoly Burakov
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev

This also makes ip_reassembly sample application statistics to obey the
CONFIG_RTE_LIBRTE_IP_FRAG_FRAG_TBL_STATS config option

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 config/common_bsdapp             | 1 +
 config/common_linuxapp           | 1 +
 examples/ip_reassembly/main.c    | 4 ++--
 lib/librte_ip_frag/rte_ip_frag.h | 4 ++--
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 989e1da..d5db4ab 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -294,6 +294,7 @@ CONFIG_RTE_LIBRTE_NET=y
 CONFIG_RTE_LIBRTE_IP_FRAG=y
 CONFIG_RTE_LIBRTE_IP_FRAG_DEBUG=n
 CONFIG_RTE_LIBRTE_IP_FRAG_MAX_FRAG=4
+CONFIG_RTE_LIBRTE_IP_FRAG_TBL_STAT=n
 
 #
 # Compile librte_meter
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 5b896c3..5ee10c3 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -337,6 +337,7 @@ CONFIG_RTE_LIBRTE_NET=y
 CONFIG_RTE_LIBRTE_IP_FRAG=y
 CONFIG_RTE_LIBRTE_IP_FRAG_DEBUG=n
 CONFIG_RTE_LIBRTE_IP_FRAG_MAX_FRAG=4
+CONFIG_RTE_LIBRTE_IP_FRAG_TBL_STAT=n
 
 #
 # Compile librte_meter
diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index 625d21f..7311b29 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -310,11 +310,11 @@ struct rte_lpm6_config lpm6_config = {
 static struct rte_lpm *socket_lpm[RTE_MAX_NUMA_NODES];
 static struct rte_lpm6 *socket_lpm6[RTE_MAX_NUMA_NODES];
 
-#ifdef IPV6_FRAG_TBL_STAT
+#ifdef RTE_LIBRTE_IP_FRAG_TBL_STAT
 #define TX_LCORE_STAT_UPDATE(s, f, v)   ((s)->f += (v))
 #else
 #define TX_LCORE_STAT_UPDATE(s, f, v)   do {} while (0)
-#endif /* IPV6_FRAG_TBL_STAT */
+#endif /* RTE_LIBRTE_IP_FRAG_TBL_STAT */
 
 /*
  * If number of queued packets reached given threahold, then
diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h
index 582a52b..84952a1 100644
--- a/lib/librte_ip_frag/rte_ip_frag.h
+++ b/lib/librte_ip_frag/rte_ip_frag.h
@@ -97,7 +97,7 @@ struct rte_ip_frag_death_row {
 TAILQ_HEAD(ip_pkt_list, ip_frag_pkt); /**< @internal fragments tailq */
 
 /** fragmentation table statistics */
-struct rte_ip_frag_tbl_stat {
+struct ip_frag_tbl_stat {
 	uint64_t find_num;      /**< total # of find/insert attempts. */
 	uint64_t add_num;       /**< # of add ops. */
 	uint64_t del_num;       /**< # of del ops. */
@@ -117,7 +117,7 @@ struct rte_ip_frag_tbl {
 	uint32_t             nb_buckets;      /**< num of associativity lines. */
 	struct ip_frag_pkt *last;         /**< last used entry. */
 	struct ip_pkt_list lru;           /**< LRU list for table entries. */
-	struct rte_ip_frag_tbl_stat stat;     /**< statistics counters. */
+	struct ip_frag_tbl_stat stat;     /**< statistics counters. */
 	struct ip_frag_pkt pkt[0];        /**< hash table. */
 };
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 05/10] ip_frag: small fix, replace hardcode with a macro
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
                   ` (3 preceding siblings ...)
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 04/10] ip_frag: fix stats macro, rename rte_ip_frag_tbl_stat structure Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 06/10] ip_frag: replace memmove with custom copying Anatoly Burakov
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev


Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ip_frag/ip_frag_internal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ip_frag/ip_frag_internal.c b/lib/librte_ip_frag/ip_frag_internal.c
index 219221f..6203740 100644
--- a/lib/librte_ip_frag/ip_frag_internal.c
+++ b/lib/librte_ip_frag/ip_frag_internal.c
@@ -350,7 +350,7 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
 		return (tbl->last);
 
 	/* different hashing methods for IPv4 and IPv6 */
-	if (key->key_len == 1)
+	if (key->key_len == IPV4_KEYLEN)
 		ipv4_frag_hash(key, &sig1, &sig2);
 	else
 		ipv6_frag_hash(key, &sig1, &sig2);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 06/10] ip_frag: replace memmove with custom copying
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
                   ` (4 preceding siblings ...)
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 05/10] ip_frag: small fix, replace hardcode with a macro Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 07/10] ip_frag: fix order of arguments to key compare function Anatoly Burakov
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev

some implementations of memmove may make a copy of src before writing to
dst. we avoid that by explicitly writing from src to dst backwards.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ip_frag/rte_ipv6_reassembly.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_frag/rte_ipv6_reassembly.c
index c622827..3f06960 100644
--- a/lib/librte_ip_frag/rte_ipv6_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c
@@ -45,6 +45,16 @@
  *
  */
 
+static inline void
+ip_frag_memmove(char *dst, char *src, int len)
+{
+	int i;
+
+	/* go backwards to make sure we don't overwrite anything important */
+	for (i = len - 1; i >= 0; i--)
+		dst[i] = src[i];
+}
+
 /*
  * Reassemble fragments into one packet.
  */
@@ -115,7 +125,7 @@ ipv6_frag_reassemble(const struct ip_frag_pkt *fp)
 	frag_hdr = (struct ipv6_extension_fragment *) (ip_hdr + 1);
 	ip_hdr->proto = frag_hdr->next_header;
 
-	memmove(rte_pktmbuf_mtod(m, char*) + sizeof(*frag_hdr),
+	ip_frag_memmove(rte_pktmbuf_mtod(m, char*) + sizeof(*frag_hdr),
 			rte_pktmbuf_mtod(m, char*), move_len);
 
 	rte_pktmbuf_adj(m, sizeof(*frag_hdr));
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 07/10] ip_frag: fix order of arguments to key compare function
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
                   ` (5 preceding siblings ...)
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 06/10] ip_frag: replace memmove with custom copying Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 08/10] ip_fragmentation: small fixes Anatoly Burakov
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev

when using key compare function, it uses key length of the first
argument to determine how long should be the keys that are compared.
however, currently we are passing a key from the fragmentation table as
first argument. the problem with this is that this key is potentially
uninitialized (i.e. contains all zeroes, including key length). this
leads to a nasty bug of comparing only the key id's and not keys
themselves.

of course, a safer way would be to do RTE_MAX between key lengths, but
since this compare is done per-packet, every cycle counts, so we just
use the key whos length is guaranteed to be correct because it comes
from an actual packet.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ip_frag/ip_frag_internal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ip_frag/ip_frag_internal.c b/lib/librte_ip_frag/ip_frag_internal.c
index 6203740..a2c645b 100644
--- a/lib/librte_ip_frag/ip_frag_internal.c
+++ b/lib/librte_ip_frag/ip_frag_internal.c
@@ -346,7 +346,7 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
 	max_cycles = tbl->max_cycles;
 	assoc = tbl->bucket_entries;
 
-	if (tbl->last != NULL && ip_frag_key_cmp(&tbl->last->key, key) == 0)
+	if (tbl->last != NULL && ip_frag_key_cmp(key, &tbl->last->key) == 0)
 		return (tbl->last);
 
 	/* different hashing methods for IPv4 and IPv6 */
@@ -378,7 +378,7 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
 					p1, i, assoc,
 			IPv6_KEY_BYTES(p1[i].key.src_dst), p1[i].key.id, p1[i].start);
 
-		if (ip_frag_key_cmp(&p1[i].key, key) == 0)
+		if (ip_frag_key_cmp(key, &p1[i].key) == 0)
 			return (p1 + i);
 		else if (ip_frag_key_is_empty(&p1[i].key))
 			empty = (empty == NULL) ? (p1 + i) : empty;
@@ -404,7 +404,7 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
 					p2, i, assoc,
 			IPv6_KEY_BYTES(p2[i].key.src_dst), p2[i].key.id, p2[i].start);
 
-		if (ip_frag_key_cmp(&p2[i].key, key) == 0)
+		if (ip_frag_key_cmp(key, &p2[i].key) == 0)
 			return (p2 + i);
 		else if (ip_frag_key_is_empty(&p2[i].key))
 			empty = (empty == NULL) ?( p2 + i) : empty;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 08/10] ip_fragmentation: small fixes
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
                   ` (6 preceding siblings ...)
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 07/10] ip_frag: fix order of arguments to key compare function Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 09/10] ip_reassembly: " Anatoly Burakov
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev

Adding check for non-existent ports in portmask.

Also, making everything NUMA-related depend on lcore sockets, not device
sockets. This is because the init_mem() function allocates all data
structures based on NUMA nodes of the lcores in the coremask. Therefore,
when no cores are on socket 0, but there are devices on socket 0, it may
lead to segmentation faults.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 examples/ip_fragmentation/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index 02e40a1..3172ad5 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -886,6 +886,10 @@ MAIN(int argc, char **argv)
 	if (init_mem() < 0)
 		rte_panic("Cannot initialize memory structures!\n");
 
+	/* check if portmask has non-existent ports */
+	if (enabled_port_mask & ~(RTE_LEN2MASK(nb_ports, unsigned)))
+		rte_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n");
+
 	/* initialize all ports */
 	for (portid = 0; portid < nb_ports; portid++) {
 		/* skip ports that are not enabled */
@@ -907,7 +911,7 @@ MAIN(int argc, char **argv)
 			qconf = &lcore_queue_conf[rx_lcore_id];
 		}
 
-		socket = rte_eth_dev_socket_id(portid);
+		socket = (int) rte_lcore_to_socket_id(rx_lcore_id);
 		if (socket == SOCKET_ID_ANY)
 			socket = 0;
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 09/10] ip_reassembly: small fixes
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
                   ` (7 preceding siblings ...)
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 08/10] ip_fragmentation: small fixes Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 10/10] rte_ip_frag: API header file fix Anatoly Burakov
  2014-06-26 21:10 ` [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Thomas Monjalon
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev

Adding check for non-existent ports in portmask.

Also, making everything NUMA-related depend on lcore sockets, not device
sockets. This is because the init_mem() function allocates all data
structures based on NUMA nodes of the lcores in the coremask. Therefore,
when no cores are on socket 0, but there are devices on socket 0, it may
lead to segmentation faults.

Also, making ip_reassembly eat up a bit less memory.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 examples/ip_reassembly/main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index 7311b29..1b60e41 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -942,15 +942,15 @@ setup_queue_tbl(struct rx_queue *rxq, uint32_t lcore, uint32_t queue)
 	}
 
 	/*
-	 * At any given moment up to <max_flow_num * (MAX_FRAG_NUM - 1)>
+	 * At any given moment up to <max_flow_num * (MAX_FRAG_NUM)>
 	 * mbufs could be stored int the fragment table.
 	 * Plus, each TX queue can hold up to <max_flow_num> packets.
 	 */
 
-	nb_mbuf = 2 * RTE_MAX(max_flow_num, 2UL * MAX_PKT_BURST) * MAX_FRAG_NUM;
+	nb_mbuf = RTE_MAX(max_flow_num, 2UL * MAX_PKT_BURST) * MAX_FRAG_NUM;
 	nb_mbuf *= (port_conf.rxmode.max_rx_pkt_len + BUF_SIZE - 1) / BUF_SIZE;
-	nb_mbuf += RTE_TEST_RX_DESC_DEFAULT + RTE_TEST_TX_DESC_DEFAULT;
 	nb_mbuf *= 2; /* ipv4 and ipv6 */
+	nb_mbuf += RTE_TEST_RX_DESC_DEFAULT + RTE_TEST_TX_DESC_DEFAULT;
 
 	nb_mbuf = RTE_MAX(nb_mbuf, (uint32_t)NB_MBUF);
 
@@ -1093,6 +1093,10 @@ MAIN(int argc, char **argv)
 	if (init_mem() < 0)
 		rte_panic("Cannot initialize memory structures!\n");
 
+	/* check if portmask has non-existent ports */
+	if (enabled_port_mask & ~(RTE_LEN2MASK(nb_ports, unsigned)))
+		rte_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n");
+
 	/* initialize all ports */
 	for (portid = 0; portid < nb_ports; portid++) {
 		/* skip ports that are not enabled */
@@ -1114,7 +1118,7 @@ MAIN(int argc, char **argv)
 			qconf = &lcore_queue_conf[rx_lcore_id];
 		}
 
-		socket = rte_eth_dev_socket_id(portid);
+		socket = rte_lcore_to_socket_id(portid);
 		if (socket == SOCKET_ID_ANY)
 			socket = 0;
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 10/10] rte_ip_frag: API header file fix
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
                   ` (8 preceding siblings ...)
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 09/10] ip_reassembly: " Anatoly Burakov
@ 2014-06-18 14:50 ` Anatoly Burakov
  2014-06-26 21:10 ` [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Thomas Monjalon
  10 siblings, 0 replies; 12+ messages in thread
From: Anatoly Burakov @ 2014-06-18 14:50 UTC (permalink / raw)
  To: dev


Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ip_frag/rte_ip_frag.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h
index 84952a1..e0936dc 100644
--- a/lib/librte_ip_frag/rte_ip_frag.h
+++ b/lib/librte_ip_frag/rte_ip_frag.h
@@ -36,9 +36,9 @@
 
 /**
  * @file
- * RTE IPv4 Fragmentation and Reassembly
+ * RTE IP Fragmentation and Reassembly
  *
- * Implementation of IPv4 packet fragmentation and reassembly.
+ * Implementation of IP packet fragmentation and reassembly.
  */
 
 #include <stdint.h>
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples
  2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
                   ` (9 preceding siblings ...)
  2014-06-18 14:50 ` [dpdk-dev] [PATCH 10/10] rte_ip_frag: API header file fix Anatoly Burakov
@ 2014-06-26 21:10 ` Thomas Monjalon
  10 siblings, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2014-06-26 21:10 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev

2014-06-18 15:50, Anatoly Burakov:
> This patchset fixes a few issues found during validation, and also
> does a bunch of renames (so that internally-used data structures aren't
> starting with rte_) and fixes a few typos.
> 
> Anatoly Burakov (10):
>   ip_frag: rename RTE_IP_FRAG_ASSERT to IP_FRAG_ASSERT
>   ip_frag: fix debug macros
>   ip_frag: renaming rte_ip_frag_pkt to ip_frag_pkt
>   ip_frag: fix stats macro, rename rte_ip_frag_tbl_stat structure
>   ip_frag: small fix, replace hardcode with a macro
>   ip_frag: replace memmove with custom copying
>   ip_frag: fix order of arguments to key compare function
>   ip_fragmentation: small fixes
>   ip_reassembly: small fixes
>   rte_ip_frag: API header file fix

Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>

There were a lot of little things in these commits.
In order to tidy them without waiting another version for rc2,
I've splitted, merged and renamed some commits.

Applied for version 1.7.0.

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-06-26 21:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 01/10] ip_frag: rename RTE_IP_FRAG_ASSERT to IP_FRAG_ASSERT Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 02/10] ip_frag: fix debug macros Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 03/10] ip_frag: renaming rte_ip_frag_pkt to ip_frag_pkt Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 04/10] ip_frag: fix stats macro, rename rte_ip_frag_tbl_stat structure Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 05/10] ip_frag: small fix, replace hardcode with a macro Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 06/10] ip_frag: replace memmove with custom copying Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 07/10] ip_frag: fix order of arguments to key compare function Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 08/10] ip_fragmentation: small fixes Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 09/10] ip_reassembly: " Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 10/10] rte_ip_frag: API header file fix Anatoly Burakov
2014-06-26 21:10 ` [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).