From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 6EE9E5A54 for ; Fri, 5 Jun 2015 16:55:38 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 05 Jun 2015 07:55:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,559,1427785200"; d="scan'208";a="741634112" Received: from unknown ([10.217.248.158]) by orsmga002.jf.intel.com with SMTP; 05 Jun 2015 07:55:35 -0700 Received: by (sSMTP sendmail emulation); Fri, 05 Jun 2015 16:55:13 +0200 From: Daniel Mrzyglod To: dev@dpdk.org Date: Fri, 5 Jun 2015 16:55:10 +0200 Message-Id: <1433516110-11468-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] lib: fix RTE_MBUF_METADATA macros X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jun 2015 14:55:39 -0000 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 --- 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