port: fix unaligned access to metadata

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>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
Daniel Mrzyglod 2015-06-05 16:55:10 +02:00 committed by Thomas Monjalon
parent 6c7216eefd
commit 1129992baa
10 changed files with 14 additions and 130 deletions

View File

@ -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;
}

View File

@ -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))
/**@}*/
/*

View File

@ -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) +

View File

@ -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;
}

View File

@ -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,

View File

@ -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",

View File

@ -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",

View File

@ -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;
}

View File

@ -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));

View File

@ -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));