DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros
@ 2015-06-05 14:55 Daniel Mrzyglod
  2015-06-05 15:31 ` Dumitrescu, Cristian
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Mrzyglod @ 2015-06-05 14:55 UTC (permalink / raw)
  To: dev

Fix RTE_MBUF_METADATA macros to allow for unaligned accesses to
meta-data fields.
Forcing aligned accesses is not really required, so this is removing an
unneeded constraint.
This issue was met during testing of the new version of the ip_pipeline
application. There is no performance impact.
This change has no ABI impact, as the previous code that uses aligned
accesses continues to run without any issues.

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
 lib/librte_pipeline/rte_pipeline.c      |  8 --------
 lib/librte_port/rte_port.h              | 26 +++++++++++++-------------
 lib/librte_table/rte_table_array.c      |  4 +---
 lib/librte_table/rte_table_hash_ext.c   | 13 -------------
 lib/librte_table/rte_table_hash_key16.c | 24 ------------------------
 lib/librte_table/rte_table_hash_key32.c | 24 ------------------------
 lib/librte_table/rte_table_hash_key8.c  | 24 ------------------------
 lib/librte_table/rte_table_hash_lru.c   | 13 -------------
 lib/librte_table/rte_table_lpm.c        |  4 ----
 lib/librte_table/rte_table_lpm_ipv6.c   |  4 ----
 10 files changed, 14 insertions(+), 130 deletions(-)

diff --git a/lib/librte_pipeline/rte_pipeline.c b/lib/librte_pipeline/rte_pipeline.c
index 36d92c9..b777cf1 100644
--- a/lib/librte_pipeline/rte_pipeline.c
+++ b/lib/librte_pipeline/rte_pipeline.c
@@ -175,14 +175,6 @@ rte_pipeline_check_params(struct rte_pipeline_params *params)
 		return -EINVAL;
 	}
 
-	/* offset_port_id */
-	if (params->offset_port_id & 0x3) {
-		RTE_LOG(ERR, PIPELINE,
-			"%s: Incorrect value for parameter offset_port_id\n",
-			__func__);
-		return -EINVAL;
-	}
-
 	return 0;
 }
 
diff --git a/lib/librte_port/rte_port.h b/lib/librte_port/rte_port.h
index d84e5a1..c3a0cca 100644
--- a/lib/librte_port/rte_port.h
+++ b/lib/librte_port/rte_port.h
@@ -54,23 +54,23 @@ extern "C" {
  * Macros to allow accessing metadata stored in the mbuf headroom
  * just beyond the end of the mbuf data structure returned by a port
  */
-#define RTE_MBUF_METADATA_UINT8(mbuf, offset)              \
-	(((uint8_t *)&(mbuf)[1])[offset])
-#define RTE_MBUF_METADATA_UINT16(mbuf, offset)             \
-	(((uint16_t *)&(mbuf)[1])[offset/sizeof(uint16_t)])
-#define RTE_MBUF_METADATA_UINT32(mbuf, offset)             \
-	(((uint32_t *)&(mbuf)[1])[offset/sizeof(uint32_t)])
-#define RTE_MBUF_METADATA_UINT64(mbuf, offset)             \
-	(((uint64_t *)&(mbuf)[1])[offset/sizeof(uint64_t)])
-
 #define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset)          \
-	(&RTE_MBUF_METADATA_UINT8(mbuf, offset))
+	(&((uint8_t *) &(mbuf)[1])[offset])
 #define RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset)         \
-	(&RTE_MBUF_METADATA_UINT16(mbuf, offset))
+	((uint16_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
 #define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset)         \
-	(&RTE_MBUF_METADATA_UINT32(mbuf, offset))
+	((uint32_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
 #define RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset)         \
-	(&RTE_MBUF_METADATA_UINT64(mbuf, offset))
+	((uint64_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
+
+#define RTE_MBUF_METADATA_UINT8(mbuf, offset)              \
+	(* RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset))
+#define RTE_MBUF_METADATA_UINT16(mbuf, offset)             \
+	(* RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset))
+#define RTE_MBUF_METADATA_UINT32(mbuf, offset)             \
+	(* RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset))
+#define RTE_MBUF_METADATA_UINT64(mbuf, offset)             \
+	(* RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset))
 /**@}*/
 
 /*
diff --git a/lib/librte_table/rte_table_array.c b/lib/librte_table/rte_table_array.c
index c031070..b00ca67 100644
--- a/lib/librte_table/rte_table_array.c
+++ b/lib/librte_table/rte_table_array.c
@@ -66,10 +66,8 @@ rte_table_array_create(void *params, int socket_id, uint32_t entry_size)
 	/* Check input parameters */
 	if ((p == NULL) ||
 	    (p->n_entries == 0) ||
-		(!rte_is_power_of_2(p->n_entries)) ||
-		((p->offset & 0x3) != 0)) {
+		(!rte_is_power_of_2(p->n_entries)))
 		return NULL;
-	}
 
 	/* Memory allocation */
 	total_cl_size = (sizeof(struct rte_table_array) +
diff --git a/lib/librte_table/rte_table_hash_ext.c b/lib/librte_table/rte_table_hash_ext.c
index 66e416b..73beeaf 100644
--- a/lib/librte_table/rte_table_hash_ext.c
+++ b/lib/librte_table/rte_table_hash_ext.c
@@ -149,19 +149,6 @@ check_params_create(struct rte_table_hash_ext_params *params)
 		return -EINVAL;
 	}
 
-	/* signature offset */
-	if ((params->signature_offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: signature_offset invalid value\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	/* key offset */
-	if ((params->key_offset & 0x7) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: key_offset invalid value\n", __func__);
-		return -EINVAL;
-	}
-
 	return 0;
 }
 
diff --git a/lib/librte_table/rte_table_hash_key16.c b/lib/librte_table/rte_table_hash_key16.c
index f87ea0e..67a4249 100644
--- a/lib/librte_table/rte_table_hash_key16.c
+++ b/lib/librte_table/rte_table_hash_key16.c
@@ -89,18 +89,6 @@ check_params_create_lru(struct rte_table_hash_key16_lru_params *params) {
 		return -EINVAL;
 	}
 
-	/* signature offset */
-	if ((params->signature_offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid signature_offset\n", __func__);
-		return -EINVAL;
-	}
-
-	/* key offset */
-	if ((params->key_offset & 0x7) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid key_offset\n", __func__);
-		return -EINVAL;
-	}
-
 	/* f_hash */
 	if (params->f_hash == NULL) {
 		RTE_LOG(ERR, TABLE,
@@ -307,18 +295,6 @@ check_params_create_ext(struct rte_table_hash_key16_ext_params *params) {
 		return -EINVAL;
 	}
 
-	/* signature offset */
-	if ((params->signature_offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid signature offset\n", __func__);
-		return -EINVAL;
-	}
-
-	/* key offset */
-	if ((params->key_offset & 0x7) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid key offset\n", __func__);
-		return -EINVAL;
-	}
-
 	/* f_hash */
 	if (params->f_hash == NULL) {
 		RTE_LOG(ERR, TABLE,
diff --git a/lib/librte_table/rte_table_hash_key32.c b/lib/librte_table/rte_table_hash_key32.c
index 6790594..1fdb75d 100644
--- a/lib/librte_table/rte_table_hash_key32.c
+++ b/lib/librte_table/rte_table_hash_key32.c
@@ -89,18 +89,6 @@ check_params_create_lru(struct rte_table_hash_key32_lru_params *params) {
 		return -EINVAL;
 	}
 
-	/* signature offset */
-	if ((params->signature_offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid signature offset\n", __func__);
-		return -EINVAL;
-	}
-
-	/* key offset */
-	if ((params->key_offset & 0x7) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid key offset\n", __func__);
-		return -EINVAL;
-	}
-
 	/* f_hash */
 	if (params->f_hash == NULL) {
 		RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n",
@@ -309,18 +297,6 @@ check_params_create_ext(struct rte_table_hash_key32_ext_params *params) {
 		return -EINVAL;
 	}
 
-	/* signature offset */
-	if ((params->signature_offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid signature offset\n", __func__);
-		return -EINVAL;
-	}
-
-	/* key offset */
-	if ((params->key_offset & 0x7) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid key offset\n", __func__);
-		return -EINVAL;
-	}
-
 	/* f_hash */
 	if (params->f_hash == NULL) {
 		RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n",
diff --git a/lib/librte_table/rte_table_hash_key8.c b/lib/librte_table/rte_table_hash_key8.c
index 6803eb2..4dfa3c8 100644
--- a/lib/librte_table/rte_table_hash_key8.c
+++ b/lib/librte_table/rte_table_hash_key8.c
@@ -86,18 +86,6 @@ check_params_create_lru(struct rte_table_hash_key8_lru_params *params) {
 		return -EINVAL;
 	}
 
-	/* signature offset */
-	if ((params->signature_offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid signature_offset\n", __func__);
-		return -EINVAL;
-	}
-
-	/* key offset */
-	if ((params->key_offset & 0x7) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid key_offset\n", __func__);
-		return -EINVAL;
-	}
-
 	/* f_hash */
 	if (params->f_hash == NULL) {
 		RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n",
@@ -300,18 +288,6 @@ check_params_create_ext(struct rte_table_hash_key8_ext_params *params) {
 		return -EINVAL;
 	}
 
-	/* signature offset */
-	if ((params->signature_offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid signature_offset\n", __func__);
-		return -EINVAL;
-	}
-
-	/* key offset */
-	if ((params->key_offset & 0x7) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: invalid key_offset\n", __func__);
-		return -EINVAL;
-	}
-
 	/* f_hash */
 	if (params->f_hash == NULL) {
 		RTE_LOG(ERR, TABLE, "%s: f_hash function pointer is NULL\n",
diff --git a/lib/librte_table/rte_table_hash_lru.c b/lib/librte_table/rte_table_hash_lru.c
index c9a8afd..b5393f0 100644
--- a/lib/librte_table/rte_table_hash_lru.c
+++ b/lib/librte_table/rte_table_hash_lru.c
@@ -126,19 +126,6 @@ check_params_create(struct rte_table_hash_lru_params *params)
 		return -EINVAL;
 	}
 
-	/* signature offset */
-	if ((params->signature_offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: signature_offset invalid value\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	/* key offset */
-	if ((params->key_offset & 0x7) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: key_offset invalid value\n", __func__);
-		return -EINVAL;
-	}
-
 	return 0;
 }
 
diff --git a/lib/librte_table/rte_table_lpm.c b/lib/librte_table/rte_table_lpm.c
index 64c684d..3f60672 100644
--- a/lib/librte_table/rte_table_lpm.c
+++ b/lib/librte_table/rte_table_lpm.c
@@ -87,10 +87,6 @@ rte_table_lpm_create(void *params, int socket_id, uint32_t entry_size)
 			__func__);
 		return NULL;
 	}
-	if ((p->offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid offset\n", __func__);
-		return NULL;
-	}
 
 	entry_size = RTE_ALIGN(entry_size, sizeof(uint64_t));
 
diff --git a/lib/librte_table/rte_table_lpm_ipv6.c b/lib/librte_table/rte_table_lpm_ipv6.c
index ce4ddc0..df83ecf 100644
--- a/lib/librte_table/rte_table_lpm_ipv6.c
+++ b/lib/librte_table/rte_table_lpm_ipv6.c
@@ -93,10 +93,6 @@ rte_table_lpm_ipv6_create(void *params, int socket_id, uint32_t entry_size)
 			__func__);
 		return NULL;
 	}
-	if ((p->offset & 0x3) != 0) {
-		RTE_LOG(ERR, TABLE, "%s: Invalid offset\n", __func__);
-		return NULL;
-	}
 
 	entry_size = RTE_ALIGN(entry_size, sizeof(uint64_t));
 
-- 
2.1.0

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

* Re: [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros
  2015-06-05 14:55 [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros Daniel Mrzyglod
@ 2015-06-05 15:31 ` Dumitrescu, Cristian
  2015-06-22 20:16   ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Dumitrescu, Cristian @ 2015-06-05 15:31 UTC (permalink / raw)
  To: Mrzyglod, DanielX T, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daniel Mrzyglod
> Sent: Friday, June 5, 2015 3:55 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros
> 
> Fix RTE_MBUF_METADATA macros to allow for unaligned accesses to
> meta-data fields.
> Forcing aligned accesses is not really required, so this is removing an
> unneeded constraint.
> This issue was met during testing of the new version of the ip_pipeline
> application. There is no performance impact.
> This change has no ABI impact, as the previous code that uses aligned
> accesses continues to run without any issues.
> 
> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>


Ack-ed by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

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

* Re: [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros
  2015-06-05 15:31 ` Dumitrescu, Cristian
@ 2015-06-22 20:16   ` Thomas Monjalon
  2015-06-22 20:23     ` Cyril Chemparathy
  2015-06-22 20:34     ` Cyril Chemparathy
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Monjalon @ 2015-06-22 20:16 UTC (permalink / raw)
  To: Mrzyglod, DanielX T; +Cc: dev

2015-06-05 15:31, Dumitrescu, Cristian:
> > Fix RTE_MBUF_METADATA macros to allow for unaligned accesses to
> > meta-data fields.
> > Forcing aligned accesses is not really required, so this is removing an
> > unneeded constraint.
> > This issue was met during testing of the new version of the ip_pipeline
> > application. There is no performance impact.
> > This change has no ABI impact, as the previous code that uses aligned
> > accesses continues to run without any issues.
> > 
> > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
> 
> Ack-ed by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks

Cyril, feel free to fix it if it breaks with Tile arch.

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

* Re: [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros
  2015-06-22 20:16   ` Thomas Monjalon
@ 2015-06-22 20:23     ` Cyril Chemparathy
  2015-06-22 20:42       ` Thomas Monjalon
  2015-06-22 20:34     ` Cyril Chemparathy
  1 sibling, 1 reply; 6+ messages in thread
From: Cyril Chemparathy @ 2015-06-22 20:23 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Mon, 22 Jun 2015 22:16:59 +0200
Thomas Monjalon <thomas.monjalon@6wind.com> wrote:

> 2015-06-05 15:31, Dumitrescu, Cristian:
> > > Fix RTE_MBUF_METADATA macros to allow for unaligned accesses to
> > > meta-data fields.
> > > Forcing aligned accesses is not really required, so this is
> > > removing an unneeded constraint.
> > > This issue was met during testing of the new version of the
> > > ip_pipeline application. There is no performance impact.
> > > This change has no ABI impact, as the previous code that uses
> > > aligned accesses continues to run without any issues.
> > > 
> > > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
> > 
> > Ack-ed by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> 
> Applied, thanks
> 
> Cyril, feel free to fix it if it breaks with Tile arch.

Why define these locally within rte_port.h? Shouldn't these macros
really be in rte_mbuf.h?

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

* Re: [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros
  2015-06-22 20:16   ` Thomas Monjalon
  2015-06-22 20:23     ` Cyril Chemparathy
@ 2015-06-22 20:34     ` Cyril Chemparathy
  1 sibling, 0 replies; 6+ messages in thread
From: Cyril Chemparathy @ 2015-06-22 20:34 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Mon, 22 Jun 2015 22:16:59 +0200
Thomas Monjalon <thomas.monjalon@6wind.com> wrote:

> 2015-06-05 15:31, Dumitrescu, Cristian:
> > > Fix RTE_MBUF_METADATA macros to allow for unaligned accesses to
> > > meta-data fields.
> > > Forcing aligned accesses is not really required, so this is
> > > removing an unneeded constraint.
> > > This issue was met during testing of the new version of the
> > > ip_pipeline application. There is no performance impact.
> > > This change has no ABI impact, as the previous code that uses
> > > aligned accesses continues to run without any issues.
> > > 
> > > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
> > 
> > Ack-ed by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> 
> Applied, thanks
> 
> Cyril, feel free to fix it if it breaks with Tile arch.

Also, in the code, doesn't the following break when mbuf_priv_size != 0?

> #define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset)          \
>         (&((uint8_t *) &(mbuf)[1])[offset])


Thanks
-- Cyril.

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

* Re: [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros
  2015-06-22 20:23     ` Cyril Chemparathy
@ 2015-06-22 20:42       ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2015-06-22 20:42 UTC (permalink / raw)
  To: Cyril Chemparathy; +Cc: dev

2015-06-22 13:23, Cyril Chemparathy:
> On Mon, 22 Jun 2015 22:16:59 +0200
> Thomas Monjalon <thomas.monjalon@6wind.com> wrote:
> > Cyril, feel free to fix it if it breaks with Tile arch.
> 
> Why define these locally within rte_port.h? Shouldn't these macros
> really be in rte_mbuf.h?

No, an application is free to put its metadata elsewhere.
The packet framework (port/table/pipeline) did the choice to put
some metadata here but there is no need to enforce it for everybody.

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

end of thread, other threads:[~2015-06-22 20:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-05 14:55 [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros Daniel Mrzyglod
2015-06-05 15:31 ` Dumitrescu, Cristian
2015-06-22 20:16   ` Thomas Monjalon
2015-06-22 20:23     ` Cyril Chemparathy
2015-06-22 20:42       ` Thomas Monjalon
2015-06-22 20:34     ` Cyril Chemparathy

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).