aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2018-01-16 21:09:35 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-01-18 22:19:45 +0300
commit5a4502fc6bc53e6503169da3028f456b64811a0b (patch)
tree61a249560d8c4dfa7232676c326088a8f12ec923 /platform/linux-generic/include
parentccb6eb85729ad0657b5c852cb2a6ddb519d60898 (diff)
linux-gen: align: Fix alignment for typedef definitions
* typedef struct { } ODP_ALIGN() test_t; is correct * typedef struct ODP_ALIGN() {} test_t; is correct and preferred from gcc standards * typedef struct {} test_t ODP_ALIGN() discards align Had segfauls on gcc-7 using that Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic/include')
-rw-r--r--platform/linux-generic/include/odp/api/plat/static_inline.h43
-rw-r--r--platform/linux-generic/include/odp_atomic_internal.h9
-rw-r--r--platform/linux-generic/include/odp_buffer_internal.h4
-rw-r--r--platform/linux-generic/include/odp_ipsec_internal.h2
-rw-r--r--platform/linux-generic/include/odp_packet_dpdk.h8
-rw-r--r--platform/linux-generic/include/odp_packet_internal.h2
-rw-r--r--platform/linux-generic/include/odp_packet_io_ring_internal.h10
-rw-r--r--platform/linux-generic/include/odp_packet_netmap.h4
-rw-r--r--platform/linux-generic/include/odp_packet_socket.h6
-rw-r--r--platform/linux-generic/include/odp_pool_internal.h10
-rw-r--r--platform/linux-generic/include/odp_queue_internal.h4
-rw-r--r--platform/linux-generic/include/odp_queue_scalable_internal.h4
-rw-r--r--platform/linux-generic/include/odp_ring_internal.h4
-rw-r--r--platform/linux-generic/include/odp_schedule_scalable.h24
-rw-r--r--platform/linux-generic/include/odp_schedule_scalable_ordered.h8
15 files changed, 92 insertions, 50 deletions
diff --git a/platform/linux-generic/include/odp/api/plat/static_inline.h b/platform/linux-generic/include/odp/api/plat/static_inline.h
new file mode 100644
index 000000000..633e2f273
--- /dev/null
+++ b/platform/linux-generic/include/odp/api/plat/static_inline.h
@@ -0,0 +1,43 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * Macro for static inline functions
+ */
+
+#ifndef ODP_PLAT_STATIC_INLINE_H_
+#define ODP_PLAT_STATIC_INLINE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @internal
+ * @def ODP_ABI_COMPAT
+ * Control ABI compatibility
+ */
+
+/**
+ * @internal
+ * @def _ODP_INLINE
+ * Define a function as inlined or not inlined (for ABI compatibility)
+ */
+#if 1
+#define ODP_ABI_COMPAT 1
+#define _ODP_INLINE
+#else
+#define ODP_ABI_COMPAT 0
+#define _ODP_INLINE static inline
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/include/odp_atomic_internal.h b/platform/linux-generic/include/odp_atomic_internal.h
index f3696a994..43c29a761 100644
--- a/platform/linux-generic/include/odp_atomic_internal.h
+++ b/platform/linux-generic/include/odp_atomic_internal.h
@@ -29,10 +29,9 @@ extern "C" {
/**
* Pointer atomic type
*/
-typedef struct {
+typedef struct ODP_ALIGNED(sizeof(void *)) {
void *v; /**< Actual storage for the atomic variable */
-} _odp_atomic_ptr_t
-ODP_ALIGNED(sizeof(void *)); /* Enforce alignement! */
+} _odp_atomic_ptr_t;
/**
* Atomic flag (boolean) type
@@ -709,9 +708,9 @@ static inline void _odp_atomic_flag_clear(_odp_atomic_flag_t *flag)
typedef __int128 _uint128_t;
/** Atomic 128-bit type */
-typedef struct {
+typedef struct ODP_ALIGNED(16) {
_uint128_t v; /**< Actual storage for the atomic variable */
-} _odp_atomic_u128_t ODP_ALIGNED(16);
+} _odp_atomic_u128_t;
/**
* 16-byte atomic exchange operation
diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
index c56c5b01b..b52669387 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -42,7 +42,7 @@ typedef struct seg_entry_t {
} seg_entry_t;
/* Common buffer header */
-struct odp_buffer_hdr_t {
+struct ODP_ALIGNED_CACHE odp_buffer_hdr_t {
/* Buffer index in the pool */
uint32_t index;
@@ -110,7 +110,7 @@ struct odp_buffer_hdr_t {
/* Data or next header */
uint8_t data[0];
-} ODP_ALIGNED_CACHE;
+};
ODP_STATIC_ASSERT(CONFIG_PACKET_SEGS_PER_HDR < 256,
"CONFIG_PACKET_SEGS_PER_HDR_TOO_LARGE");
diff --git a/platform/linux-generic/include/odp_ipsec_internal.h b/platform/linux-generic/include/odp_ipsec_internal.h
index 70a583c5b..dbdcbb917 100644
--- a/platform/linux-generic/include/odp_ipsec_internal.h
+++ b/platform/linux-generic/include/odp_ipsec_internal.h
@@ -92,7 +92,7 @@ int _odp_ipsec_status_send(odp_queue_t queue,
#define ODP_CONFIG_IPSEC_SAS 8
struct ipsec_sa_s {
- odp_atomic_u32_t state ODP_ALIGNED_CACHE;
+ odp_atomic_u32_t ODP_ALIGNED_CACHE state;
uint32_t ipsec_sa_idx;
odp_ipsec_sa_t ipsec_sa_hdl;
diff --git a/platform/linux-generic/include/odp_packet_dpdk.h b/platform/linux-generic/include/odp_packet_dpdk.h
index 05f00ad34..242926555 100644
--- a/platform/linux-generic/include/odp_packet_dpdk.h
+++ b/platform/linux-generic/include/odp_packet_dpdk.h
@@ -41,13 +41,13 @@ struct pkt_cache_t {
unsigned count; /**< packets in cache */
};
-typedef union {
+typedef union ODP_ALIGNED_CACHE {
struct pkt_cache_t s;
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pkt_cache_t))];
-} pkt_cache_t ODP_ALIGNED_CACHE;
+} pkt_cache_t;
/** Packet IO using DPDK interface */
-typedef struct {
+typedef struct ODP_ALIGNED_CACHE {
odp_pool_t pool; /**< pool to alloc packets from */
struct rte_mempool *pkt_pool; /**< DPDK packet pool */
uint32_t data_room; /**< maximum packet length */
@@ -64,6 +64,6 @@ typedef struct {
odp_ticketlock_t tx_lock[PKTIO_MAX_QUEUES]; /**< TX queue locks */
/** cache for storing extra RX packets */
pkt_cache_t rx_cache[PKTIO_MAX_QUEUES];
-} pkt_dpdk_t ODP_ALIGNED_CACHE;
+} pkt_dpdk_t;
#endif
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 712799d71..01e0cae17 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -156,7 +156,7 @@ typedef struct {
/* Type of extra data */
uint8_t extra_type;
/* Extra space for packet descriptors. E.g. DPDK mbuf */
- uint8_t extra[PKT_EXTRA_LEN] ODP_ALIGNED_CACHE;
+ uint8_t ODP_ALIGNED_CACHE extra[PKT_EXTRA_LEN];
#endif
/* Context for IPsec */
diff --git a/platform/linux-generic/include/odp_packet_io_ring_internal.h b/platform/linux-generic/include/odp_packet_io_ring_internal.h
index d044f9319..5a60a4ee3 100644
--- a/platform/linux-generic/include/odp_packet_io_ring_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_ring_internal.h
@@ -132,26 +132,26 @@ typedef struct _ring {
int flags;
/** @private Producer */
- struct _prod {
+ struct ODP_ALIGNED_CACHE _prod {
uint32_t watermark; /* Maximum items */
uint32_t sp_enqueue; /* True, if single producer. */
uint32_t size; /* Size of ring. */
uint32_t mask; /* Mask (size-1) of ring. */
volatile uint32_t head; /* Producer head. */
volatile uint32_t tail; /* Producer tail. */
- } prod ODP_ALIGNED_CACHE;
+ } prod;
/** @private Consumer */
- struct _cons {
+ struct ODP_ALIGNED_CACHE _cons {
uint32_t sc_dequeue; /* True, if single consumer. */
uint32_t size; /* Size of the ring. */
uint32_t mask; /* Mask (size-1) of ring. */
volatile uint32_t head; /* Consumer head. */
volatile uint32_t tail; /* Consumer tail. */
- } cons ODP_ALIGNED_CACHE;
+ } cons;
/** @private Memory space of ring starts here. */
- void *ring[0] ODP_ALIGNED_CACHE;
+ void ODP_ALIGNED_CACHE *ring[0];
} _ring_t;
/* The default enqueue is "single-producer".*/
diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_packet_netmap.h
index 876c7e465..616541b5e 100644
--- a/platform/linux-generic/include/odp_packet_netmap.h
+++ b/platform/linux-generic/include/odp_packet_netmap.h
@@ -30,10 +30,10 @@ struct netmap_ring_t {
odp_ticketlock_t lock; /**< Queue lock */
};
-typedef union {
+typedef union ODP_ALIGNED_CACHE {
struct netmap_ring_t s;
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct netmap_ring_t))];
-} netmap_ring_t ODP_ALIGNED_CACHE;
+} netmap_ring_t;
/** Netmap ring slot */
typedef struct {
diff --git a/platform/linux-generic/include/odp_packet_socket.h b/platform/linux-generic/include/odp_packet_socket.h
index 0e61f6f0c..52d2776b7 100644
--- a/platform/linux-generic/include/odp_packet_socket.h
+++ b/platform/linux-generic/include/odp_packet_socket.h
@@ -67,11 +67,11 @@ ODP_STATIC_ASSERT(offsetof(struct ring, mm_space) <= ODP_CACHE_LINE_SIZE,
/** Packet socket using mmap rings for both Rx and Tx */
typedef struct {
/** Packet mmap ring for Rx */
- struct ring rx_ring ODP_ALIGNED_CACHE;
+ struct ring ODP_ALIGNED_CACHE rx_ring;
/** Packet mmap ring for Tx */
- struct ring tx_ring ODP_ALIGNED_CACHE;
+ struct ring ODP_ALIGNED_CACHE tx_ring;
- int sockfd ODP_ALIGNED_CACHE;
+ int ODP_ALIGNED_CACHE sockfd;
odp_pool_t pool;
size_t frame_offset; /**< frame start offset from start of pkt buf */
uint8_t *mmap_base;
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index 61ec5ccc5..8284bcd7d 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -26,27 +26,27 @@ extern "C" {
#include <odp_ring_internal.h>
#include <odp/api/plat/strong_types.h>
-typedef struct pool_cache_t {
+typedef struct ODP_ALIGNED_CACHE pool_cache_t {
uint32_t num;
uint32_t buf_index[CONFIG_POOL_CACHE_SIZE];
-} pool_cache_t ODP_ALIGNED_CACHE;
+} pool_cache_t;
/* Buffer header ring */
-typedef struct {
+typedef struct ODP_ALIGNED_CACHE {
/* Ring header */
ring_t hdr;
/* Ring data: buffer handles */
uint32_t buf[CONFIG_POOL_MAX_NUM];
-} pool_ring_t ODP_ALIGNED_CACHE;
+} pool_ring_t;
/* Callback function for pool destroy */
typedef void (*pool_destroy_cb_fn)(void *pool);
typedef struct pool_t {
- odp_ticketlock_t lock ODP_ALIGNED_CACHE;
+ odp_ticketlock_t ODP_ALIGNED_CACHE lock;
char name[ODP_POOL_NAME_LEN];
odp_pool_param_t params;
diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h
index df1b29ff8..158b1d5f1 100644
--- a/platform/linux-generic/include/odp_queue_internal.h
+++ b/platform/linux-generic/include/odp_queue_internal.h
@@ -37,13 +37,13 @@ extern "C" {
#define QUEUE_STATUS_SCHED 4
struct queue_entry_s {
- odp_ticketlock_t lock ODP_ALIGNED_CACHE;
+ odp_ticketlock_t ODP_ALIGNED_CACHE lock;
odp_buffer_hdr_t *head;
odp_buffer_hdr_t *tail;
int status;
- queue_enq_fn_t enqueue ODP_ALIGNED_CACHE;
+ queue_enq_fn_t ODP_ALIGNED_CACHE enqueue;
queue_deq_fn_t dequeue;
queue_enq_multi_fn_t enqueue_multi;
queue_deq_multi_fn_t dequeue_multi;
diff --git a/platform/linux-generic/include/odp_queue_scalable_internal.h b/platform/linux-generic/include/odp_queue_scalable_internal.h
index 58d64aa5b..605d87502 100644
--- a/platform/linux-generic/include/odp_queue_scalable_internal.h
+++ b/platform/linux-generic/include/odp_queue_scalable_internal.h
@@ -34,10 +34,10 @@ extern "C" {
struct queue_entry_s {
sched_elem_t sched_elem;
- odp_ticketlock_t lock ODP_ALIGNED_CACHE;
+ odp_ticketlock_t ODP_ALIGNED_CACHE lock;
int status;
- queue_enq_fn_t enqueue ODP_ALIGNED_CACHE;
+ queue_enq_fn_t ODP_ALIGNED_CACHE enqueue;
queue_deq_fn_t dequeue;
queue_enq_multi_fn_t enqueue_multi;
queue_deq_multi_fn_t dequeue_multi;
diff --git a/platform/linux-generic/include/odp_ring_internal.h b/platform/linux-generic/include/odp_ring_internal.h
index 44b83c603..c2eedb8e2 100644
--- a/platform/linux-generic/include/odp_ring_internal.h
+++ b/platform/linux-generic/include/odp_ring_internal.h
@@ -25,7 +25,7 @@ extern "C" {
* must be a power of two. Also ring size must be larger than the maximum
* number of data items that will be stored on it (there's no check against
* overwriting). */
-typedef struct {
+typedef struct ODP_ALIGNED_CACHE {
/* Writer head and tail */
odp_atomic_u32_t w_head;
odp_atomic_u32_t w_tail;
@@ -36,7 +36,7 @@ typedef struct {
odp_atomic_u32_t r_tail;
uint32_t data[0];
-} ring_t ODP_ALIGNED_CACHE;
+} ring_t;
/* Initialize ring */
static inline void ring_init(ring_t *ring)
diff --git a/platform/linux-generic/include/odp_schedule_scalable.h b/platform/linux-generic/include/odp_schedule_scalable.h
index ac357b015..92d60276b 100644
--- a/platform/linux-generic/include/odp_schedule_scalable.h
+++ b/platform/linux-generic/include/odp_schedule_scalable.h
@@ -29,7 +29,7 @@
#define ODP_SCHED_PRIO_PKTIN 8
#define ODP_SCHED_PRIO_NUM 9
-typedef struct {
+typedef struct ODP_ALIGNED_CACHE {
union {
struct {
struct llqueue llq;
@@ -37,16 +37,16 @@ typedef struct {
};
char line[ODP_CACHE_LINE_SIZE];
};
-} sched_queue_t ODP_ALIGNED_CACHE;
+} sched_queue_t;
#define TICKET_INVALID (uint16_t)(~0U)
-typedef struct {
+typedef struct ODP_ALIGNED(sizeof(uint64_t)) {
int32_t numevts;
uint16_t wrr_budget;
uint8_t cur_ticket;
uint8_t nxt_ticket;
-} qschedstate_t ODP_ALIGNED(sizeof(uint64_t));
+} qschedstate_t;
typedef uint32_t ringidx_t;
@@ -58,7 +58,7 @@ typedef uint32_t ringidx_t;
#define ODP_NO_SCHED_QUEUE (ODP_SCHED_SYNC_ORDERED + 1)
-typedef struct {
+typedef struct ODP_ALIGNED_CACHE {
struct llnode node;
sched_queue_t *schedq;
#ifdef CONFIG_QSCHST_LOCK
@@ -89,7 +89,7 @@ typedef struct {
#define cons_type qschst_type
#endif
odp_schedule_group_t sched_grp;
-} sched_elem_t ODP_ALIGNED_CACHE;
+} sched_elem_t;
/* Number of scheduling groups */
#define MAX_SCHED_GROUP (sizeof(sched_group_mask_t) * CHAR_BIT)
@@ -98,7 +98,7 @@ typedef bitset_t sched_group_mask_t;
typedef struct {
/* Threads currently associated with the sched group */
- bitset_t thr_actual[ODP_SCHED_PRIO_NUM] ODP_ALIGNED_CACHE;
+ bitset_t ODP_ALIGNED_CACHE thr_actual[ODP_SCHED_PRIO_NUM];
bitset_t thr_wanted;
/* Used to spread queues over schedq's */
uint32_t xcount[ODP_SCHED_PRIO_NUM];
@@ -106,13 +106,13 @@ typedef struct {
uint32_t xfactor;
char name[ODP_SCHED_GROUP_NAME_LEN];
/* ODP_SCHED_PRIO_NUM * xfactor. Must be last. */
- sched_queue_t schedq[1] ODP_ALIGNED_CACHE;
+ sched_queue_t ODP_ALIGNED_CACHE schedq[1];
} sched_group_t;
/* Number of reorder contexts per thread */
#define TS_RVEC_SIZE 16
-typedef struct {
+typedef struct ODP_ALIGNED_CACHE {
/* Atomic queue currently being processed or NULL */
sched_elem_t *atomq;
/* Schedq the currently processed queue was popped from */
@@ -135,10 +135,10 @@ typedef struct {
sched_group_mask_t sg_wanted[ODP_SCHED_PRIO_NUM];
bitset_t priv_rvec_free;
/* Bitset of free entries in rvec[] */
- bitset_t rvec_free ODP_ALIGNED_CACHE;
+ bitset_t ODP_ALIGNED_CACHE rvec_free;
/* Reordering contexts to allocate from */
- reorder_context_t rvec[TS_RVEC_SIZE] ODP_ALIGNED_CACHE;
-} sched_scalable_thread_state_t ODP_ALIGNED_CACHE;
+ reorder_context_t ODP_ALIGNED_CACHE rvec[TS_RVEC_SIZE];
+} sched_scalable_thread_state_t;
void sched_update_enq(sched_elem_t *q, uint32_t actual);
void sched_update_enq_sp(sched_elem_t *q, uint32_t actual);
diff --git a/platform/linux-generic/include/odp_schedule_scalable_ordered.h b/platform/linux-generic/include/odp_schedule_scalable_ordered.h
index c493dead4..14e411e23 100644
--- a/platform/linux-generic/include/odp_schedule_scalable_ordered.h
+++ b/platform/linux-generic/include/odp_schedule_scalable_ordered.h
@@ -57,12 +57,12 @@
* We need a point of synchronisation where this knowledge and potential state
* change can be transferred between threads.
*/
-typedef struct hc {
+typedef struct ODP_ALIGNED(sizeof(uint64_t)) hc {
/* First missing context */
uint32_t head;
/* Change indicator */
uint32_t chgi;
-} hc_t ODP_ALIGNED(sizeof(uint64_t));
+} hc_t;
/* Number of reorder contects in the reorder window.
* Should be at least one per CPU.
@@ -90,7 +90,7 @@ typedef struct reorder_window {
*/
#define RC_EVT_SIZE 18
-struct reorder_context {
+struct ODP_ALIGNED_CACHE reorder_context {
/* Reorder window to which this context belongs */
reorder_window_t *rwin;
/* Pointer to TS->rvec_free */
@@ -109,7 +109,7 @@ struct reorder_context {
/* Events stored in this context */
odp_buffer_hdr_t *events[RC_EVT_SIZE];
queue_entry_t *destq[RC_EVT_SIZE];
-} ODP_ALIGNED_CACHE;
+};
reorder_window_t *rwin_alloc(_odp_ishm_pool_t *pool,
unsigned lock_count);