This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via c15da68b8dc3187c1929ff7d7705a0958856cbad (commit) via 16dd00616f73f7e49c53e4b0ea957ac789125b25 (commit) from a5609cc551f4bc71fb69746f3d6cafaf64b87fbf (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit c15da68b8dc3187c1929ff7d7705a0958856cbad Author: Petri Savolainen petri.savolainen@nokia.com Date: Fri Jan 20 11:14:03 2017 +0200
linux-gen: align: clean up macros
Removed unused macros from odp_align_internal.h. Renamed remaining macros without ODP_ prefix and with shorter names.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-and-tested-by: Yi He yi.he@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_align_internal.h b/platform/linux-generic/include/odp_align_internal.h index e5b2f37..61ff200 100644 --- a/platform/linux-generic/include/odp_align_internal.h +++ b/platform/linux-generic/include/odp_align_internal.h @@ -20,14 +20,6 @@ extern "C" { #include <odp/api/align.h> #include <stdint.h>
-/** @addtogroup odp_compiler_optim - * @{ - */ - -/* - * Round up - */ - /* Macros to calculate ODP_ROUNDUP_POWER2_U32() in five rounds of shift * and OR operations. */ #define _RSHIFT_U32(x, y) (((uint32_t)(x)) >> (y)) @@ -42,95 +34,31 @@ extern "C" { * The value is not round up, if it's already a power of two (including 1). * The value must be larger than 0 and not exceed 0x80000000. */ -#define ODP_ROUNDUP_POWER2_U32(x) \ +#define ROUNDUP_POWER2_U32(x) \ ((((uint32_t)(x)) > 0x80000000) ? 0 : (_POW2_U32_R5(x - 1) + 1))
-/** - * @internal +/* * Round up 'x' to alignment 'align' */ -#define ODP_ALIGN_ROUNDUP(x, align)\ +#define ROUNDUP_ALIGN(x, align)\ ((align) * (((x) + (align) - 1) / (align)))
-/** - * @internal - * Round up pointer 'x' to alignment 'align' - */ -#define ODP_ALIGN_ROUNDUP_PTR(x, align)\ - ((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x), (uintptr_t)(align))) - -/** - * @internal +/* * Round up 'x' to cache line size alignment */ -#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\ - ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE) - -/** - * @internal - * Round up pointer 'x' to cache line size alignment - */ -#define ODP_CACHE_LINE_SIZE_ROUNDUP_PTR(x)\ - ((void *)ODP_CACHE_LINE_SIZE_ROUNDUP((uintptr_t)(x))) - -/** - * @internal - * Round up 'x' to page size alignment - */ -#define ODP_PAGE_SIZE_ROUNDUP(x)\ - ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE) +#define ROUNDUP_CACHE_LINE(x)\ + ROUNDUP_ALIGN(x, ODP_CACHE_LINE_SIZE)
/* - * Round down - */ - -/** - * @internal * Round down 'x' to 'align' alignment, which is a power of two */ -#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\ +#define ROUNDDOWN_POWER2(x, align)\ ((x) & (~((align) - 1))) -/** - * @internal - * Round down 'x' to cache line size alignment - */ -#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\ - ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE) - -/** - * @internal - * Round down pointer 'x' to 'align' alignment, which is a power of two - */ -#define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\ -((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x), (uintptr_t)(align))) - -/** - * @internal - * Round down pointer 'x' to cache line size alignment - */ -#define ODP_CACHE_LINE_SIZE_ROUNDDOWN_PTR(x)\ - ((void *)ODP_CACHE_LINE_SIZE_ROUNDDOWN((uintptr_t)(x)))
/* - * Check align - */ - -/** - * @internal - * Check if pointer 'x' is aligned to 'align', which is a power of two - */ -#define ODP_ALIGNED_CHECK_POWER_2(x, align)\ - ((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0) - -/** - * @internal * Check if value is a power of two */ -#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0) - -/** - * @} - */ +#define CHECK_IS_POWER2(x) ((((x) - 1) & (x)) == 0)
#ifdef __cplusplus } diff --git a/platform/linux-generic/include/odp_classification_datamodel.h b/platform/linux-generic/include/odp_classification_datamodel.h index 8505c67..f6393ee 100644 --- a/platform/linux-generic/include/odp_classification_datamodel.h +++ b/platform/linux-generic/include/odp_classification_datamodel.h @@ -92,7 +92,7 @@ struct cos_s {
typedef union cos_u { struct cos_s s; - uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct cos_s))]; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct cos_s))]; } cos_t;
@@ -112,7 +112,7 @@ struct pmr_s {
typedef union pmr_u { struct pmr_s s; - uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pmr_s))]; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pmr_s))]; } pmr_t;
/** diff --git a/platform/linux-generic/include/odp_packet_dpdk.h b/platform/linux-generic/include/odp_packet_dpdk.h index c63685e..4d7e0fc 100644 --- a/platform/linux-generic/include/odp_packet_dpdk.h +++ b/platform/linux-generic/include/odp_packet_dpdk.h @@ -42,7 +42,7 @@ struct pkt_cache_t {
typedef union { struct pkt_cache_t s; - uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pkt_cache_t))]; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pkt_cache_t))]; } pkt_cache_t ODP_ALIGNED_CACHE;
/** Packet IO using DPDK interface */ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 2001c42..89bb6f3 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -176,7 +176,7 @@ struct pktio_entry {
typedef union { struct pktio_entry s; - uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pktio_entry))]; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pktio_entry))]; } pktio_entry_t;
typedef struct { diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_packet_netmap.h index 2aadbed..a6f68d5 100644 --- a/platform/linux-generic/include/odp_packet_netmap.h +++ b/platform/linux-generic/include/odp_packet_netmap.h @@ -32,7 +32,7 @@ struct netmap_ring_t {
typedef union { struct netmap_ring_t s; - uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct netmap_ring_t))]; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct netmap_ring_t))]; } netmap_ring_t ODP_ALIGNED_CACHE;
/** Netmap ring slot */ diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index 8b55de1..560f826 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -79,7 +79,7 @@ struct queue_entry_s {
union queue_entry_u { struct queue_entry_s s; - uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct queue_entry_s))]; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct queue_entry_s))]; };
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index f632a51..34d720c 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1498,7 +1498,7 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len,
if (seglen >= len) { misalign = align <= 1 ? 0 : - ODP_ALIGN_ROUNDUP(uaddr, align) - uaddr; + ROUNDUP_ALIGN(uaddr, align) - uaddr; if (misalign == 0) return 0; shift = align - misalign; @@ -1508,7 +1508,7 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len, shift = len - seglen; uaddr -= shift; misalign = align <= 1 ? 0 : - ODP_ALIGN_ROUNDUP(uaddr, align) - uaddr; + ROUNDUP_ALIGN(uaddr, align) - uaddr; if (misalign) shift += align - misalign; } diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 0d12d0b..cf7c2c4 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -311,7 +311,7 @@ static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
/* Validate requested buffer alignment */ if (align > ODP_CONFIG_BUFFER_ALIGN_MAX || - align != ODP_ALIGN_ROUNDDOWN_POWER_2(align, align)) { + align != ROUNDDOWN_POWER2(align, align)) { ODP_ERR("Bad align requirement"); return ODP_POOL_INVALID; } @@ -349,7 +349,7 @@ static odp_pool_t pool_create(const char *name, odp_pool_param_t *params, }
if (uarea_size) - uarea_size = ODP_CACHE_LINE_SIZE_ROUNDUP(uarea_size); + uarea_size = ROUNDUP_CACHE_LINE(uarea_size);
pool = reserve_pool();
@@ -373,15 +373,15 @@ static odp_pool_t pool_create(const char *name, odp_pool_param_t *params, pool->params = *params;
hdr_size = sizeof(odp_packet_hdr_t); - hdr_size = ODP_CACHE_LINE_SIZE_ROUNDUP(hdr_size); + hdr_size = ROUNDUP_CACHE_LINE(hdr_size);
- block_size = ODP_CACHE_LINE_SIZE_ROUNDUP(hdr_size + align + headroom + - data_size + tailroom); + block_size = ROUNDUP_CACHE_LINE(hdr_size + align + headroom + + data_size + tailroom);
if (num <= RING_SIZE_MIN) ring_size = RING_SIZE_MIN; else - ring_size = ODP_ROUNDUP_POWER2_U32(num); + ring_size = ROUNDUP_POWER2_U32(num);
pool->ring_mask = ring_size - 1; pool->num = num; diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 645630a..e14d145 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -82,20 +82,20 @@ ODP_STATIC_ASSERT((ODP_SCHED_PRIO_NORMAL > 0) && #define PRIO_QUEUE_EMPTY ((uint32_t)-1)
/* For best performance, the number of queues should be a power of two. */ -ODP_STATIC_ASSERT(ODP_VAL_IS_POWER_2(ODP_CONFIG_QUEUES), +ODP_STATIC_ASSERT(CHECK_IS_POWER2(ODP_CONFIG_QUEUES), "Number_of_queues_is_not_power_of_two");
/* Ring size must be power of two, so that MAX_QUEUE_IDX_MASK can be used. */ -ODP_STATIC_ASSERT(ODP_VAL_IS_POWER_2(PRIO_QUEUE_RING_SIZE), +ODP_STATIC_ASSERT(CHECK_IS_POWER2(PRIO_QUEUE_RING_SIZE), "Ring_size_is_not_power_of_two");
/* Ring size must be power of two, so that PKTIO_RING_MASK can be used. */ -ODP_STATIC_ASSERT(ODP_VAL_IS_POWER_2(PKTIO_RING_SIZE), +ODP_STATIC_ASSERT(CHECK_IS_POWER2(PKTIO_RING_SIZE), "pktio_ring_size_is_not_power_of_two");
/* Number of commands queues must be power of two, so that PKTIO_CMD_QUEUE_MASK * can be used. */ -ODP_STATIC_ASSERT(ODP_VAL_IS_POWER_2(PKTIO_CMD_QUEUES), +ODP_STATIC_ASSERT(CHECK_IS_POWER2(PKTIO_CMD_QUEUES), "pktio_cmd_queues_is_not_power_of_two");
/* Mask of queues per priority */ diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 5ccd32d..ad01bfe 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -27,18 +27,17 @@ #define PKTIN_PRIO (NUM_PRIO - 1) #define CMD_QUEUE 0 #define CMD_PKTIO 1 -#define ROUNDUP_CACHE(x) ODP_CACHE_LINE_SIZE_ROUNDUP(x) #define GROUP_ALL ODP_SCHED_GROUP_ALL #define GROUP_WORKER ODP_SCHED_GROUP_WORKER #define GROUP_CONTROL ODP_SCHED_GROUP_CONTROL #define GROUP_PKTIN GROUP_ALL
/* Maximum number of commands: one priority/group for all queues and pktios */ -#define RING_SIZE (ODP_ROUNDUP_POWER2_U32(NUM_QUEUE + NUM_PKTIO)) +#define RING_SIZE (ROUNDUP_POWER2_U32(NUM_QUEUE + NUM_PKTIO)) #define RING_MASK (RING_SIZE - 1)
/* Ring size must be power of two */ -ODP_STATIC_ASSERT(ODP_VAL_IS_POWER_2(RING_SIZE), +ODP_STATIC_ASSERT(CHECK_IS_POWER2(RING_SIZE), "Ring_size_is_not_power_of_two");
ODP_STATIC_ASSERT(NUM_ORDERED_LOCKS <= CONFIG_QUEUE_MAX_ORD_LOCKS, @@ -60,7 +59,7 @@ struct sched_cmd_s {
typedef struct sched_cmd_t { struct sched_cmd_s s; - uint8_t pad[ROUNDUP_CACHE(sizeof(struct sched_cmd_s)) - + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct sched_cmd_s)) - sizeof(struct sched_cmd_s)]; } sched_cmd_t ODP_ALIGNED_CACHE;
diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 53fec08..cf610bf 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -233,12 +233,9 @@ static odp_timer_pool_t odp_timer_pool_new(const char *name, __odp_errno = ENFILE; /* Table overflow */ return ODP_TIMER_POOL_INVALID; } - size_t sz0 = ODP_ALIGN_ROUNDUP(sizeof(odp_timer_pool), - ODP_CACHE_LINE_SIZE); - size_t sz1 = ODP_ALIGN_ROUNDUP(sizeof(tick_buf_t) * param->num_timers, - ODP_CACHE_LINE_SIZE); - size_t sz2 = ODP_ALIGN_ROUNDUP(sizeof(odp_timer) * param->num_timers, - ODP_CACHE_LINE_SIZE); + size_t sz0 = ROUNDUP_CACHE_LINE(sizeof(odp_timer_pool)); + size_t sz1 = ROUNDUP_CACHE_LINE(sizeof(tick_buf_t) * param->num_timers); + size_t sz2 = ROUNDUP_CACHE_LINE(sizeof(odp_timer) * param->num_timers); odp_shm_t shm = odp_shm_reserve(name, sz0 + sz1 + sz2, ODP_CACHE_LINE_SIZE, ODP_SHM_SW_ONLY); if (odp_unlikely(shm == ODP_SHM_INVALID))
commit 16dd00616f73f7e49c53e4b0ea957ac789125b25 Author: Petri Savolainen petri.savolainen@nokia.com Date: Fri Jan 20 11:14:02 2017 +0200
linux-gen: align: round up power of two as macro
Implement round up to power of two as a macro. Macro enables preprocessor to calculate the constant value and avoid code generation. Also dependency to __builtin_clz() is not needed anymore.
Signed-off-by: Petri Savolainen petri.savolainen@nokia.com Reviewed-and-tested-by: Yi He yi.he@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_align_internal.h b/platform/linux-generic/include/odp_align_internal.h index d9cd30b..e5b2f37 100644 --- a/platform/linux-generic/include/odp_align_internal.h +++ b/platform/linux-generic/include/odp_align_internal.h @@ -18,6 +18,7 @@ extern "C" { #endif
#include <odp/api/align.h> +#include <stdint.h>
/** @addtogroup odp_compiler_optim * @{ @@ -27,6 +28,23 @@ extern "C" { * Round up */
+/* Macros to calculate ODP_ROUNDUP_POWER2_U32() in five rounds of shift + * and OR operations. */ +#define _RSHIFT_U32(x, y) (((uint32_t)(x)) >> (y)) +#define _POW2_U32_R1(x) (((uint32_t)(x)) | _RSHIFT_U32(x, 1)) +#define _POW2_U32_R2(x) (_POW2_U32_R1(x) | _RSHIFT_U32(_POW2_U32_R1(x), 2)) +#define _POW2_U32_R3(x) (_POW2_U32_R2(x) | _RSHIFT_U32(_POW2_U32_R2(x), 4)) +#define _POW2_U32_R4(x) (_POW2_U32_R3(x) | _RSHIFT_U32(_POW2_U32_R3(x), 8)) +#define _POW2_U32_R5(x) (_POW2_U32_R4(x) | _RSHIFT_U32(_POW2_U32_R4(x), 16)) + +/* Round up a uint32_t value 'x' to the next power of two. + * + * The value is not round up, if it's already a power of two (including 1). + * The value must be larger than 0 and not exceed 0x80000000. + */ +#define ODP_ROUNDUP_POWER2_U32(x) \ + ((((uint32_t)(x)) > 0x80000000) ? 0 : (_POW2_U32_R5(x - 1) + 1)) + /** * @internal * Round up 'x' to alignment 'align' @@ -36,14 +54,6 @@ extern "C" {
/** * @internal - * When 'x' is not already a power of two, round it up to the next - * power of two value. Zero is not supported as an input value. - */ -#define ODP_ROUNDUP_POWER_2(x)\ - (1 << (((int)(8 * sizeof(x))) - __builtin_clz((x) - 1))) - -/** - * @internal * Round up pointer 'x' to alignment 'align' */ #define ODP_ALIGN_ROUNDUP_PTR(x, align)\ diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 090a55f..0d12d0b 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -381,7 +381,7 @@ static odp_pool_t pool_create(const char *name, odp_pool_param_t *params, if (num <= RING_SIZE_MIN) ring_size = RING_SIZE_MIN; else - ring_size = ODP_ROUNDUP_POWER_2(num); + ring_size = ODP_ROUNDUP_POWER2_U32(num);
pool->ring_mask = ring_size - 1; pool->num = num; diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 5150d28..5ccd32d 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -34,7 +34,7 @@ #define GROUP_PKTIN GROUP_ALL
/* Maximum number of commands: one priority/group for all queues and pktios */ -#define RING_SIZE (ODP_ROUNDUP_POWER_2(NUM_QUEUE + NUM_PKTIO)) +#define RING_SIZE (ODP_ROUNDUP_POWER2_U32(NUM_QUEUE + NUM_PKTIO)) #define RING_MASK (RING_SIZE - 1)
/* Ring size must be power of two */
-----------------------------------------------------------------------
Summary of changes: .../linux-generic/include/odp_align_internal.h | 108 +++++---------------- .../include/odp_classification_datamodel.h | 4 +- platform/linux-generic/include/odp_packet_dpdk.h | 2 +- .../linux-generic/include/odp_packet_io_internal.h | 2 +- platform/linux-generic/include/odp_packet_netmap.h | 2 +- .../linux-generic/include/odp_queue_internal.h | 2 +- platform/linux-generic/odp_packet.c | 4 +- platform/linux-generic/odp_pool.c | 12 +-- platform/linux-generic/odp_schedule.c | 8 +- platform/linux-generic/odp_schedule_sp.c | 7 +- platform/linux-generic/odp_timer.c | 9 +- 11 files changed, 47 insertions(+), 113 deletions(-)
hooks/post-receive