diff options
Diffstat (limited to 'platform/linux-generic/include/odp/api/plat')
8 files changed, 148 insertions, 4 deletions
diff --git a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h index d466a51ad..31d2f1db9 100644 --- a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h @@ -56,7 +56,11 @@ extern "C" { * Don't use this function directly, instead see odp_byteorder.h */ #if GCC_VERSION < 40800 -#define __odp_builtin_bswap16(u16) ((((u16)&0x00ff) << 8) | \ +/* + * We have to explicitly cast back to uint16_t because clang promotes the + * left side of << operator to int. + */ +#define __odp_builtin_bswap16(u16) ((uint16_t)(((u16)&0x00ff) << 8) | \ (((u16)&0xff00) >> 8)) #else #define __odp_builtin_bswap16(u16) __builtin_bswap16(u16) diff --git a/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h b/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h index 547620df6..723e1a3d1 100644 --- a/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h +++ b/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h @@ -15,6 +15,15 @@ extern "C" { /** @cond _ODP_HIDE_FROM_DOXYGEN_ */ +typedef union { + uint32_t all_flags; + + struct { + uint32_t user_flag : 1; + }; + +} _odp_event_vector_flags_t; + /* Event vector field accessors */ #define _odp_event_vect_get(vect, cast, field) \ (*(cast *)(uintptr_t)((uint8_t *)vect + _odp_event_vector_inline.field)) @@ -26,6 +35,9 @@ typedef struct _odp_event_vector_inline_offset_t { uint16_t packet; uint16_t pool; uint16_t size; + uint16_t uarea_addr; + uint16_t flags; + } _odp_event_vector_inline_offset_t; /** @endcond */ diff --git a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h index c5293fc86..b00173aca 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h @@ -27,6 +27,9 @@ extern "C" { #define _odp_pkt_get(pkt, cast, field) \ (*(cast *)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.field)) +#define _odp_pkt_get_ptr(pkt, cast, field) \ + ((cast *)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.field)) + /* Packet header field offsets for inline functions */ typedef struct _odp_packet_inline_offset_t { uint16_t seg_data; @@ -115,12 +118,13 @@ typedef union { uint32_t all_flags; struct { - uint32_t reserved1: 7; + uint32_t reserved1: 6; /* * Init flags */ uint32_t user_ptr_set: 1; /* User has set a non-NULL value */ + uint32_t user_flag: 1; /* * Packet output flags @@ -150,8 +154,8 @@ typedef union { /* Flag groups */ struct { - uint32_t reserved2: 7; - uint32_t other: 18; /* All other flags */ + uint32_t reserved2: 6; + uint32_t other: 19; /* All other flags */ uint32_t error: 7; /* All error flags */ } all; diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 950ede8d7..da4eabe2e 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -44,11 +44,14 @@ #define odp_packet_tailroom __odp_packet_tailroom #define odp_packet_pool __odp_packet_pool #define odp_packet_input __odp_packet_input + #define odp_packet_input_set __odp_packet_input_set #define odp_packet_input_index __odp_packet_input_index #define odp_packet_num_segs __odp_packet_num_segs #define odp_packet_user_ptr __odp_packet_user_ptr #define odp_packet_user_area __odp_packet_user_area #define odp_packet_user_area_size __odp_packet_user_area_size + #define odp_packet_user_flag __odp_packet_user_flag + #define odp_packet_user_flag_set __odp_packet_user_flag_set #define odp_packet_l2_offset __odp_packet_l2_offset #define odp_packet_l3_offset __odp_packet_l3_offset #define odp_packet_l4_offset __odp_packet_l4_offset @@ -76,6 +79,13 @@ #define odp_packet_color __odp_packet_color #define odp_packet_drop_eligible __odp_packet_drop_eligible #define odp_packet_shaper_len_adjust __odp_packet_shaper_len_adjust + #define odp_packet_buf_data_len __odp_packet_buf_data_len + #define odp_packet_buf_size __odp_packet_buf_size + #define odp_packet_buf_head __odp_packet_buf_head + #define odp_packet_buf_data_offset __odp_packet_buf_data_offset + #define odp_packet_buf_data_set __odp_packet_buf_data_set + #define odp_packet_buf_from_head __odp_packet_buf_from_head + #else #undef _ODP_INLINE #define _ODP_INLINE @@ -135,6 +145,13 @@ _ODP_INLINE odp_pktio_t odp_packet_input(odp_packet_t pkt) return _odp_pkt_get(pkt, odp_pktio_t, input); } +_ODP_INLINE void odp_packet_input_set(odp_packet_t pkt, odp_pktio_t pktio) +{ + odp_pktio_t *pktio_ptr = _odp_pkt_get_ptr(pkt, odp_pktio_t, input); + + *pktio_ptr = pktio; +} + _ODP_INLINE int odp_packet_input_index(odp_packet_t pkt) { odp_pktio_t pktio = odp_packet_input(pkt); @@ -171,6 +188,22 @@ _ODP_INLINE uint32_t odp_packet_user_area_size(odp_packet_t pkt) return _odp_pool_get(pool, uint32_t, uarea_size); } +_ODP_INLINE int odp_packet_user_flag(odp_packet_t pkt) +{ + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + + return flags.user_flag; +} + +_ODP_INLINE void odp_packet_user_flag_set(odp_packet_t pkt, int val) +{ + _odp_packet_flags_t *flags = _odp_pkt_get_ptr(pkt, _odp_packet_flags_t, flags); + + flags->user_flag = !!val; +} + _ODP_INLINE uint32_t odp_packet_l2_offset(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint16_t, l2_offset); @@ -400,6 +433,59 @@ _ODP_INLINE int8_t odp_packet_shaper_len_adjust(odp_packet_t pkt) return (int8_t)flags.shaper_len_adj; } +_ODP_INLINE uint32_t odp_packet_buf_data_len(odp_packet_buf_t pkt_buf) +{ + return _odp_pkt_get(pkt_buf, uint32_t, seg_len); +} + +_ODP_INLINE uint32_t odp_packet_buf_size(odp_packet_buf_t pkt_buf) +{ + odp_pool_t pool = _odp_pkt_get(pkt_buf, odp_pool_t, pool); + + return _odp_pool_get(pool, uint32_t, ext_pkt_buf_size) - + _odp_pool_get(pool, uint32_t, ext_head_offset); +} + +_ODP_INLINE void *odp_packet_buf_head(odp_packet_buf_t pkt_buf) +{ + odp_pool_t pool = _odp_pkt_get(pkt_buf, odp_pool_t, pool); + const uint32_t head_offset = _odp_pool_get(pool, uint32_t, ext_head_offset); + + /* Check that pool is external */ + if (odp_unlikely(!head_offset)) + return NULL; + + return (uint8_t *)(uintptr_t)pkt_buf + head_offset; +} + +_ODP_INLINE uint32_t odp_packet_buf_data_offset(odp_packet_buf_t pkt_buf) +{ + return (uint32_t)((uintptr_t)_odp_pkt_get(pkt_buf, void *, seg_data) - + (uintptr_t)odp_packet_buf_head(pkt_buf)); +} + +_ODP_INLINE void odp_packet_buf_data_set(odp_packet_buf_t pkt_buf, uint32_t data_offset, + uint32_t data_len) +{ + uint8_t *head = (uint8_t *)odp_packet_buf_head(pkt_buf); + uint32_t *seg_len = _odp_pkt_get_ptr(pkt_buf, uint32_t, seg_len); + void **seg_data = _odp_pkt_get_ptr(pkt_buf, void *, seg_data); + + *seg_len = data_len; + *seg_data = head + data_offset; +} + +_ODP_INLINE odp_packet_buf_t odp_packet_buf_from_head(odp_pool_t pool, void *head) +{ + const uint32_t head_offset = _odp_pool_get(pool, uint32_t, ext_head_offset); + + /* Check that pool is external */ + if (odp_unlikely(!head_offset)) + return ODP_PACKET_BUF_INVALID; + + return (odp_packet_buf_t)((uintptr_t)head - head_offset); +} + /** @endcond */ #endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h index c8da1b77a..76604dc4f 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h @@ -33,6 +33,9 @@ #define odp_packet_vector_pool __odp_packet_vector_pool #define odp_packet_vector_size __odp_packet_vector_size #define odp_packet_vector_size_set __odp_packet_vector_size_set + #define odp_packet_vector_user_area __odp_packet_vector_user_area + #define odp_packet_vector_user_flag __odp_packet_vector_user_flag + #define odp_packet_vector_user_flag_set __odp_packet_vector_user_flag_set #else #undef _ODP_INLINE #define _ODP_INLINE @@ -74,6 +77,28 @@ _ODP_INLINE void odp_packet_vector_size_set(odp_packet_vector_t pktv, uint32_t s *vector_size = size; } +_ODP_INLINE void *odp_packet_vector_user_area(odp_packet_vector_t pktv) +{ + return _odp_event_vect_get(pktv, void *, uarea_addr); +} + +_ODP_INLINE int odp_packet_vector_user_flag(odp_packet_vector_t pktv) +{ + _odp_event_vector_flags_t flags; + + flags.all_flags = _odp_event_vect_get(pktv, uint32_t, flags); + + return flags.user_flag; +} + +_ODP_INLINE void odp_packet_vector_user_flag_set(odp_packet_vector_t pktv, int val) +{ + _odp_event_vector_flags_t *flags = _odp_event_vect_get_ptr(pktv, _odp_event_vector_flags_t, + flags); + + flags->user_flag = !!val; +} + /** @endcond */ #endif diff --git a/platform/linux-generic/include/odp/api/plat/pool_inline_types.h b/platform/linux-generic/include/odp/api/plat/pool_inline_types.h index 0c356dbf2..9deec89a1 100644 --- a/platform/linux-generic/include/odp/api/plat/pool_inline_types.h +++ b/platform/linux-generic/include/odp/api/plat/pool_inline_types.h @@ -26,7 +26,13 @@ typedef struct _odp_pool_inline_offset_t { /** @internal field offset */ uint16_t index; /** @internal field offset */ + uint16_t seg_len; + /** @internal field offset */ uint16_t uarea_size; + /** @internal field offset */ + uint16_t ext_head_offset; + /** @internal field offset */ + uint16_t ext_pkt_buf_size; } _odp_pool_inline_offset_t; diff --git a/platform/linux-generic/include/odp/api/plat/timer_inline_types.h b/platform/linux-generic/include/odp/api/plat/timer_inline_types.h index e3397c4df..ec6804c72 100644 --- a/platform/linux-generic/include/odp/api/plat/timer_inline_types.h +++ b/platform/linux-generic/include/odp/api/plat/timer_inline_types.h @@ -25,6 +25,7 @@ typedef struct _odp_timeout_inline_offset_t { uint16_t expiration; uint16_t timer; uint16_t user_ptr; + uint16_t uarea_addr; } _odp_timeout_inline_offset_t; diff --git a/platform/linux-generic/include/odp/api/plat/timer_inlines.h b/platform/linux-generic/include/odp/api/plat/timer_inlines.h index 406aefdf6..7642376d0 100644 --- a/platform/linux-generic/include/odp/api/plat/timer_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/timer_inlines.h @@ -24,6 +24,7 @@ extern const _odp_timeout_inline_offset_t _odp_timeout_inline_offset; #define odp_timeout_timer __odp_timeout_timer #define odp_timeout_tick __odp_timeout_tick #define odp_timeout_user_ptr __odp_timeout_user_ptr + #define odp_timeout_user_area __odp_timeout_user_area #define odp_timer_tick_to_ns __odp_timer_tick_to_ns #define odp_timer_ns_to_tick __odp_timer_ns_to_tick #define odp_timeout_from_event __odp_timeout_from_event @@ -47,6 +48,11 @@ _ODP_INLINE void *odp_timeout_user_ptr(odp_timeout_t tmo) return _odp_timeout_hdr_field(tmo, void *, user_ptr); } +_ODP_INLINE void *odp_timeout_user_area(odp_timeout_t tmo) +{ + return _odp_timeout_hdr_field(tmo, void *, uarea_addr); +} + _ODP_INLINE uint64_t odp_timer_tick_to_ns(odp_timer_pool_t tp, uint64_t ticks) { (void)tp; |