[PATCHv2] linux-dpdk: fix build when running with --disable-abi-compat

Message ID 1494435757-25407-1-git-send-email-balakrishna.garapati@linaro.org
State New
Headers show

Commit Message

Balakrishna Garapati May 10, 2017, 5:02 p.m.
Suggested-by: Matias Elo <matias.elo@nokia.com>
Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
---
 since v1: Fixed all the comments from v1

 .../linux-dpdk/include/odp/api/plat/buffer_types.h |  2 +-
 .../linux-dpdk/include/odp/api/plat/event_types.h  |  2 +-
 .../include/odp/api/plat/packet_flags_inlines.h    | 10 ++-
 .../include/odp/api/plat/packet_inlines.h          | 95 +++++++++++++---------
 .../linux-dpdk/include/odp/api/plat/packet_types.h | 35 ++++++++
 platform/linux-dpdk/include/odp_packet_internal.h  |  6 +-
 platform/linux-dpdk/m4/configure.m4                |  1 +
 platform/linux-dpdk/odp_packet.c                   | 45 +++++-----
 platform/linux-dpdk/odp_std_clib.c                 |  4 +-
 9 files changed, 126 insertions(+), 74 deletions(-)

--
1.9.1

Comments

Matias Elo May 11, 2017, 9:35 a.m. | #1
Comments below.

-Matias

> diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h

> 
> /*
>  * NOTE: These functions are inlined because they are on a performance hot path.
>  * As we can't force the application to directly include DPDK headers we have to
> 

This comment block can now be removed.

> @@ -52,9 +38,13 @@ extern const uint64_t rss_flag;
> /** @internal Inline function @param pkt @return */
> static inline void *_odp_packet_data(odp_packet_t pkt)
> {
> -	char **buf_addr = (char **)(void *)((char *)pkt + buf_addr_offset);
> +	char **buf_addr = (char **)(void *)((char *)pkt +
> +			   _odp_packet_inline.mb +
> +			   _odp_packet_inline.buf_addr);

Comment below regarding _odp_packet_inline_offset_t values. Repeated
multiple times in this file.


> 
> /** @internal Inline function @param pkt @return */
> static inline int _odp_packet_num_segs(odp_packet_t pkt)
> {
> -	struct rte_mbuf *mb = &(odp_packet_hdr(pkt)->buf_hdr.mb);
> +	struct rte_mbuf *mb = (struct rte_mbuf *)((uint8_t *)pkt +
> +			      _odp_packet_inline.mb);
> 
> 	return mb->nb_segs;

This offset can be added to _odp_packet_inline_offset_t.

> 
> diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c
> +/* Fill in packet header field offsets for inline functions */
> +
> +const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
> +	.mb               = offsetof(odp_packet_hdr_t, buf_hdr.mb),
> +	.pool             = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
> +	.input            = offsetof(odp_packet_hdr_t, input),
> +	.user_ptr         = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx),
> +	.timestamp        = offsetof(odp_packet_hdr_t, timestamp),
> +	.buf_addr         = offsetof(const struct rte_mbuf, buf_addr),
> +	.data             = offsetof(struct rte_mbuf, data_off),
> +	.pkt_len          = (size_t)&rte_pktmbuf_pkt_len((struct rte_mbuf *)0),
> +	.seg_len          = (size_t)&rte_pktmbuf_data_len((struct rte_mbuf *)0),
> +	.udata_len        = offsetof(odp_packet_hdr_t, uarea_size),
> +	.udata            = sizeof(odp_packet_hdr_t),
> +	.rss              = offsetof(struct rte_mbuf, hash.rss),
> +	.ol_flags         = offsetof(struct rte_mbuf, ol_flags),
> +	.rss_flag         = PKT_RX_RSS_HASH
> +};

I would suggest calculating all final offsets here. This makes the functions in packet_inlines.h simpler as you don't need to combine multiple offsets to get the required value.

E.g.

const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
	.mb               = offsetof(odp_packet_hdr_t, buf_hdr.mb),
	.pool             = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
	.input            = offsetof(odp_packet_hdr_t, input),
	.user_ptr         = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx),
	.timestamp        = offsetof(odp_packet_hdr_t, timestamp),
	.buf_addr         = offsetof(odp_packet_hdr_t, buf_hdr.mb.buf_addr),
	.data             = offsetof(odp_packet_hdr_t, buf_hdr.mb.data_off),
	.pkt_len          = offsetof(odp_packet_hdr_t, buf_hdr.mb) +
		(size_t)&rte_pktmbuf_pkt_len((struct rte_mbuf *)0),
	.seg_len          = offsetof(odp_packet_hdr_t, buf_hdr.mb) +
		(size_t)&rte_pktmbuf_data_len((struct rte_mbuf *)0),
	.udata_len        = offsetof(odp_packet_hdr_t, uarea_size),
	.udata            = sizeof(odp_packet_hdr_t),
	.rss              = offsetof(odp_packet_hdr_t, buf_hdr.mb.hash.rss),
	.ol_flags         = offsetof(odp_packet_hdr_t, buf_hdr.mb.ol_flags),
	.rss_flag         = PKT_RX_RSS_HASH
};


> 
> /* The last bit is an expanded version of offsetof(), to make sure that if
>  * rte_pktmbuf_[pkt|data]_len() changes, we will either adapt automatically, or
>  * throw a compile failure
>  */

This commend applied pkt_len_offset and seg_len_offset only.

> -
> -const unsigned int udata_len_offset = offsetof(odp_packet_hdr_t, uarea_size);
> -const unsigned int udata_offset = sizeof(odp_packet_hdr_t);
> -const unsigned int rss_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
> -				offsetof(struct odp_buffer_hdr_t, mb) +
> -				offsetof(struct rte_mbuf, hash.rss);
> -const unsigned int ol_flags_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
> -				     offsetof(struct odp_buffer_hdr_t, mb) +
> -				     offsetof(struct rte_mbuf, ol_flags);
> -const uint64_t rss_flag = PKT_RX_RSS_HASH;
> +

Double blank line.

> 
> struct rte_mbuf dummy;
> ODP_STATIC_ASSERT(sizeof(dummy.data_off) == sizeof(uint16_t),
> @@ -61,7 +57,6 @@ ODP_STATIC_ASSERT(sizeof(dummy.hash.rss) == sizeof(uint32_t),
> 		  "hash.rss should be uint32_t");
> ODP_STATIC_ASSERT(sizeof(dummy.ol_flags) == sizeof(uint64_t),
> 		  "ol_flags should be uint64_t");
> -
>
Balakrishna Garapati May 11, 2017, 4:06 p.m. | #2
On 11 May 2017 at 11:35, Elo, Matias (Nokia - FI/Espoo) <
matias.elo@nokia.com> wrote:

> Comments below.
>
> -Matias
>
> > diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
> b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
>
> >
> > /*
> >  * NOTE: These functions are inlined because they are on a performance
> hot path.
> >  * As we can't force the application to directly include DPDK headers we
> have to
> >
>
> This comment block can now be removed.
>
> > @@ -52,9 +38,13 @@ extern const uint64_t rss_flag;
> > /** @internal Inline function @param pkt @return */
> > static inline void *_odp_packet_data(odp_packet_t pkt)
> > {
> > -     char **buf_addr = (char **)(void *)((char *)pkt + buf_addr_offset);
> > +     char **buf_addr = (char **)(void *)((char *)pkt +
> > +                        _odp_packet_inline.mb +
> > +                        _odp_packet_inline.buf_addr);
>
> Comment below regarding _odp_packet_inline_offset_t values. Repeated
> multiple times in this file.
>
>
> >
> > /** @internal Inline function @param pkt @return */
> > static inline int _odp_packet_num_segs(odp_packet_t pkt)
> > {
> > -     struct rte_mbuf *mb = &(odp_packet_hdr(pkt)->buf_hdr.mb);
> > +     struct rte_mbuf *mb = (struct rte_mbuf *)((uint8_t *)pkt +
> > +                           _odp_packet_inline.mb);
> >
> >       return mb->nb_segs;
>
> This offset can be added to _odp_packet_inline_offset_t.
>
We are not returning the offset here.

/Krishna

>
> >
> > diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_
> packet.c
> > +/* Fill in packet header field offsets for inline functions */
> > +
> > +const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE
> = {
> > +     .mb               = offsetof(odp_packet_hdr_t, buf_hdr.mb),
> > +     .pool             = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
> > +     .input            = offsetof(odp_packet_hdr_t, input),
> > +     .user_ptr         = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx),
> > +     .timestamp        = offsetof(odp_packet_hdr_t, timestamp),
> > +     .buf_addr         = offsetof(const struct rte_mbuf, buf_addr),
> > +     .data             = offsetof(struct rte_mbuf, data_off),
> > +     .pkt_len          = (size_t)&rte_pktmbuf_pkt_len((struct rte_mbuf
> *)0),
> > +     .seg_len          = (size_t)&rte_pktmbuf_data_len((struct
> rte_mbuf *)0),
> > +     .udata_len        = offsetof(odp_packet_hdr_t, uarea_size),
> > +     .udata            = sizeof(odp_packet_hdr_t),
> > +     .rss              = offsetof(struct rte_mbuf, hash.rss),
> > +     .ol_flags         = offsetof(struct rte_mbuf, ol_flags),
> > +     .rss_flag         = PKT_RX_RSS_HASH
> > +};
>
> I would suggest calculating all final offsets here. This makes the
> functions in packet_inlines.h simpler as you don't need to combine multiple
> offsets to get the required value.
>
> E.g.
>
> const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
>         .mb               = offsetof(odp_packet_hdr_t, buf_hdr.mb),
>         .pool             = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
>         .input            = offsetof(odp_packet_hdr_t, input),
>         .user_ptr         = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx),
>         .timestamp        = offsetof(odp_packet_hdr_t, timestamp),
>         .buf_addr         = offsetof(odp_packet_hdr_t,
> buf_hdr.mb.buf_addr),
>         .data             = offsetof(odp_packet_hdr_t,
> buf_hdr.mb.data_off),
>         .pkt_len          = offsetof(odp_packet_hdr_t, buf_hdr.mb) +
>                 (size_t)&rte_pktmbuf_pkt_len((struct rte_mbuf *)0),
>         .seg_len          = offsetof(odp_packet_hdr_t, buf_hdr.mb) +
>                 (size_t)&rte_pktmbuf_data_len((struct rte_mbuf *)0),
>         .udata_len        = offsetof(odp_packet_hdr_t, uarea_size),
>         .udata            = sizeof(odp_packet_hdr_t),
>         .rss              = offsetof(odp_packet_hdr_t,
> buf_hdr.mb.hash.rss),
>         .ol_flags         = offsetof(odp_packet_hdr_t,
> buf_hdr.mb.ol_flags),
>         .rss_flag         = PKT_RX_RSS_HASH
> };
>
>
> >
> > /* The last bit is an expanded version of offsetof(), to make sure that
> if
> >  * rte_pktmbuf_[pkt|data]_len() changes, we will either adapt
> automatically, or
> >  * throw a compile failure
> >  */
>
> This commend applied pkt_len_offset and seg_len_offset only.
>
> > -
> > -const unsigned int udata_len_offset = offsetof(odp_packet_hdr_t,
> uarea_size);
> > -const unsigned int udata_offset = sizeof(odp_packet_hdr_t);
> > -const unsigned int rss_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
> > -                             offsetof(struct odp_buffer_hdr_t, mb) +
> > -                             offsetof(struct rte_mbuf, hash.rss);
> > -const unsigned int ol_flags_offset = offsetof(odp_packet_hdr_t,
> buf_hdr) +
> > -                                  offsetof(struct odp_buffer_hdr_t, mb)
> +
> > -                                  offsetof(struct rte_mbuf, ol_flags);
> > -const uint64_t rss_flag = PKT_RX_RSS_HASH;
> > +
>
> Double blank line.
>
> >
> > struct rte_mbuf dummy;
> > ODP_STATIC_ASSERT(sizeof(dummy.data_off) == sizeof(uint16_t),
> > @@ -61,7 +57,6 @@ ODP_STATIC_ASSERT(sizeof(dummy.hash.rss) ==
> sizeof(uint32_t),
> >                 "hash.rss should be uint32_t");
> > ODP_STATIC_ASSERT(sizeof(dummy.ol_flags) == sizeof(uint64_t),
> >                 "ol_flags should be uint64_t");
> > -
> >
>
>
Balakrishna Garapati May 11, 2017, 10:56 p.m. | #3
On 11 May 2017 at 18:06, Krishna Garapati <balakrishna.garapati@linaro.org>
wrote:

>
>
> On 11 May 2017 at 11:35, Elo, Matias (Nokia - FI/Espoo) <
> matias.elo@nokia.com> wrote:
>
>> Comments below.
>>
>> -Matias
>>
>> > diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
>> b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
>>
>> >
>> > /*
>> >  * NOTE: These functions are inlined because they are on a performance
>> hot path.
>> >  * As we can't force the application to directly include DPDK headers
>> we have to
>> >
>>
>> This comment block can now be removed.
>>
>> > @@ -52,9 +38,13 @@ extern const uint64_t rss_flag;
>> > /** @internal Inline function @param pkt @return */
>> > static inline void *_odp_packet_data(odp_packet_t pkt)
>> > {
>> > -     char **buf_addr = (char **)(void *)((char *)pkt +
>> buf_addr_offset);
>> > +     char **buf_addr = (char **)(void *)((char *)pkt +
>> > +                        _odp_packet_inline.mb +
>> > +                        _odp_packet_inline.buf_addr);
>>
>> Comment below regarding _odp_packet_inline_offset_t values. Repeated
>> multiple times in this file.
>>
>>
>> >
>> > /** @internal Inline function @param pkt @return */
>> > static inline int _odp_packet_num_segs(odp_packet_t pkt)
>> > {
>> > -     struct rte_mbuf *mb = &(odp_packet_hdr(pkt)->buf_hdr.mb);
>> > +     struct rte_mbuf *mb = (struct rte_mbuf *)((uint8_t *)pkt +
>> > +                           _odp_packet_inline.mb);
>> >
>> >       return mb->nb_segs;
>>
>> This offset can be added to _odp_packet_inline_offset_t.
>>
> We are not returning the offset here.
>
> /Krishna
>

I see what you meant. Sent v4.

/Krishna

>
>
>>
>>
> >
>> > diff --git a/platform/linux-dpdk/odp_packet.c
>> b/platform/linux-dpdk/odp_packet.c
>> > +/* Fill in packet header field offsets for inline functions */
>> > +
>> > +const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE
>> = {
>> > +     .mb               = offsetof(odp_packet_hdr_t, buf_hdr.mb),
>> > +     .pool             = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
>> > +     .input            = offsetof(odp_packet_hdr_t, input),
>> > +     .user_ptr         = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx),
>> > +     .timestamp        = offsetof(odp_packet_hdr_t, timestamp),
>> > +     .buf_addr         = offsetof(const struct rte_mbuf, buf_addr),
>> > +     .data             = offsetof(struct rte_mbuf, data_off),
>> > +     .pkt_len          = (size_t)&rte_pktmbuf_pkt_len((struct
>> rte_mbuf *)0),
>> > +     .seg_len          = (size_t)&rte_pktmbuf_data_len((struct
>> rte_mbuf *)0),
>> > +     .udata_len        = offsetof(odp_packet_hdr_t, uarea_size),
>> > +     .udata            = sizeof(odp_packet_hdr_t),
>> > +     .rss              = offsetof(struct rte_mbuf, hash.rss),
>> > +     .ol_flags         = offsetof(struct rte_mbuf, ol_flags),
>> > +     .rss_flag         = PKT_RX_RSS_HASH
>> > +};
>>
>> I would suggest calculating all final offsets here. This makes the
>> functions in packet_inlines.h simpler as you don't need to combine multiple
>> offsets to get the required value.
>>
>> E.g.
>>
>> const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
>>         .mb               = offsetof(odp_packet_hdr_t, buf_hdr.mb),
>>         .pool             = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
>>         .input            = offsetof(odp_packet_hdr_t, input),
>>         .user_ptr         = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx),
>>         .timestamp        = offsetof(odp_packet_hdr_t, timestamp),
>>         .buf_addr         = offsetof(odp_packet_hdr_t,
>> buf_hdr.mb.buf_addr),
>>         .data             = offsetof(odp_packet_hdr_t,
>> buf_hdr.mb.data_off),
>>         .pkt_len          = offsetof(odp_packet_hdr_t, buf_hdr.mb) +
>>                 (size_t)&rte_pktmbuf_pkt_len((struct rte_mbuf *)0),
>>         .seg_len          = offsetof(odp_packet_hdr_t, buf_hdr.mb) +
>>                 (size_t)&rte_pktmbuf_data_len((struct rte_mbuf *)0),
>>         .udata_len        = offsetof(odp_packet_hdr_t, uarea_size),
>>         .udata            = sizeof(odp_packet_hdr_t),
>>         .rss              = offsetof(odp_packet_hdr_t,
>> buf_hdr.mb.hash.rss),
>>         .ol_flags         = offsetof(odp_packet_hdr_t,
>> buf_hdr.mb.ol_flags),
>>         .rss_flag         = PKT_RX_RSS_HASH
>> };
>>
>>
>> >
>> > /* The last bit is an expanded version of offsetof(), to make sure that
>> if
>> >  * rte_pktmbuf_[pkt|data]_len() changes, we will either adapt
>> automatically, or
>> >  * throw a compile failure
>> >  */
>>
>> This commend applied pkt_len_offset and seg_len_offset only.
>>
>> > -
>> > -const unsigned int udata_len_offset = offsetof(odp_packet_hdr_t,
>> uarea_size);
>> > -const unsigned int udata_offset = sizeof(odp_packet_hdr_t);
>> > -const unsigned int rss_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
>> > -                             offsetof(struct odp_buffer_hdr_t, mb) +
>> > -                             offsetof(struct rte_mbuf, hash.rss);
>> > -const unsigned int ol_flags_offset = offsetof(odp_packet_hdr_t,
>> buf_hdr) +
>> > -                                  offsetof(struct odp_buffer_hdr_t,
>> mb) +
>> > -                                  offsetof(struct rte_mbuf, ol_flags);
>> > -const uint64_t rss_flag = PKT_RX_RSS_HASH;
>> > +
>>
>> Double blank line.
>>
>> >
>> > struct rte_mbuf dummy;
>> > ODP_STATIC_ASSERT(sizeof(dummy.data_off) == sizeof(uint16_t),
>> > @@ -61,7 +57,6 @@ ODP_STATIC_ASSERT(sizeof(dummy.hash.rss) ==
>> sizeof(uint32_t),
>> >                 "hash.rss should be uint32_t");
>> > ODP_STATIC_ASSERT(sizeof(dummy.ol_flags) == sizeof(uint64_t),
>> >                 "ol_flags should be uint64_t");
>> > -
>> >
>>
>>
>

Patch hide | download patch | download mbox

diff --git a/platform/linux-dpdk/include/odp/api/plat/buffer_types.h b/platform/linux-dpdk/include/odp/api/plat/buffer_types.h
index 46dad9a..b23a5d1 100644
--- a/platform/linux-dpdk/include/odp/api/plat/buffer_types.h
+++ b/platform/linux-dpdk/include/odp/api/plat/buffer_types.h
@@ -36,7 +36,7 @@  extern "C" {

 typedef ODP_HANDLE_T(odp_buffer_t);

-#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, NULL)
+#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0xffffffff)

 typedef ODP_HANDLE_T(odp_buffer_seg_t);

diff --git a/platform/linux-dpdk/include/odp/api/plat/event_types.h b/platform/linux-dpdk/include/odp/api/plat/event_types.h
index b6349c6..086e83d 100644
--- a/platform/linux-dpdk/include/odp/api/plat/event_types.h
+++ b/platform/linux-dpdk/include/odp/api/plat/event_types.h
@@ -32,7 +32,7 @@  extern "C" {

 typedef ODP_HANDLE_T(odp_event_t);

-#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, NULL)
+#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0xffffffff)

 /**
  * Event types
diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_flags_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_flags_inlines.h
index e92f7cf..03d9e0c 100644
--- a/platform/linux-dpdk/include/odp/api/plat/packet_flags_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/packet_flags_inlines.h
@@ -17,8 +17,8 @@ 
 extern "C" {
 #endif

-extern const unsigned int ol_flags_offset;
-extern const uint64_t rss_flag;
+/** @internal Inline function offsets */
+extern const _odp_packet_inline_offset_t _odp_packet_inline;

 /*
  * NOTE: These functions are inlined because they are on a performance hot path.
@@ -29,12 +29,14 @@  extern const uint64_t rss_flag;
  */
 _ODP_INLINE int odp_packet_has_flow_hash(odp_packet_t pkt)
 {
-	return *(uint64_t *)((char *)pkt + ol_flags_offset) & rss_flag;
+	return *(uint64_t *)((char *)pkt + _odp_packet_inline.ol_flags) &
+					   _odp_packet_inline.rss_flag;
 }

 _ODP_INLINE void odp_packet_has_flow_hash_clr(odp_packet_t pkt)
 {
-	*(uint64_t *)((char *)pkt + ol_flags_offset) &= ~rss_flag;
+	*(uint64_t *)((char *)pkt + _odp_packet_inline.ol_flags) &=
+				    ~_odp_packet_inline.rss_flag;
 }

 #ifdef __cplusplus
diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
index a0d92fd..91a5c0e 100644
--- a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
@@ -21,26 +21,12 @@  extern "C" {
 #include <odp/api/pool.h>
 #include <odp/api/packet_io.h>
 #include <odp/api/hints.h>
-#include <odp_packet_internal.h>
-
-extern const unsigned int buf_addr_offset;
-extern const unsigned int data_off_offset;
-extern const unsigned int pkt_len_offset;
-extern const unsigned int seg_len_offset;
-extern const unsigned int udata_len_offset;
-extern const unsigned int udata_offset;
-extern const unsigned int rss_offset;
-extern const unsigned int ol_flags_offset;
-extern const uint64_t rss_flag;

-/* Include inlined versions of API functions */
-#include <odp/api/plat/static_inline.h>
-
-#if ODP_ABI_COMPAT == 0
+#include <rte_mbuf.h>

-#include <odp/api/plat/packet_inlines_api.h>
+/** @internal Inline function offsets */
+extern const _odp_packet_inline_offset_t _odp_packet_inline;

-#endif /* ODP_ABI_COMPAT */
 /*
  * NOTE: These functions are inlined because they are on a performance hot path.
  * As we can't force the application to directly include DPDK headers we have to
@@ -52,9 +38,13 @@  extern const uint64_t rss_flag;
 /** @internal Inline function @param pkt @return */
 static inline void *_odp_packet_data(odp_packet_t pkt)
 {
-	char **buf_addr = (char **)(void *)((char *)pkt + buf_addr_offset);
+	char **buf_addr = (char **)(void *)((char *)pkt +
+			   _odp_packet_inline.mb +
+			   _odp_packet_inline.buf_addr);
 	uint16_t data_off =
-		*(uint16_t *)(void *)((char *)pkt + data_off_offset);
+		*(uint16_t *)(void *)((char *)pkt +
+		  _odp_packet_inline.mb +
+		  _odp_packet_inline.data);

 	return (void *)(*buf_addr + data_off);
 }
@@ -62,19 +52,24 @@  static inline void *_odp_packet_data(odp_packet_t pkt)
 /** @internal Inline function @param pkt @return */
 static inline uint32_t _odp_packet_seg_len(odp_packet_t pkt)
 {
-	return *(uint16_t *)(void *)((char *)pkt + seg_len_offset);
+	return *(uint16_t *)(void *)((char *)pkt +
+		  _odp_packet_inline.mb +
+		 _odp_packet_inline.seg_len);
 }

 /** @internal Inline function @param pkt @return */
 static inline uint32_t _odp_packet_len(odp_packet_t pkt)
 {
-	return *(uint32_t *)(void *)((char *)pkt + pkt_len_offset);
+	return *(uint32_t *)(void *)((char *)pkt +
+		 _odp_packet_inline.mb +
+		 _odp_packet_inline.pkt_len);
 }

 /** @internal Inline function @param pkt @return */
 static inline uint32_t _odp_packet_headroom(odp_packet_t pkt)
 {
-	struct rte_mbuf *mb = &(odp_packet_hdr(pkt)->buf_hdr.mb);
+	struct rte_mbuf *mb = (struct rte_mbuf *)((uint8_t *)pkt +
+			      _odp_packet_inline.mb);

 	return rte_pktmbuf_headroom(mb);
 }
@@ -82,7 +77,8 @@  static inline uint32_t _odp_packet_headroom(odp_packet_t pkt)
 /** @internal Inline function @param pkt @return */
 static inline uint32_t _odp_packet_tailroom(odp_packet_t pkt)
 {
-	struct rte_mbuf *mb = &(odp_packet_hdr(pkt)->buf_hdr.mb);
+	struct rte_mbuf *mb = (struct rte_mbuf *)((uint8_t *)pkt +
+			      _odp_packet_inline.mb);

 	return rte_pktmbuf_tailroom(rte_pktmbuf_lastseg(mb));
 }
@@ -90,19 +86,22 @@  static inline uint32_t _odp_packet_tailroom(odp_packet_t pkt)
 /** @internal Inline function @param pkt @return */
 static inline odp_pool_t _odp_packet_pool(odp_packet_t pkt)
 {
-	return odp_packet_hdr(pkt)->buf_hdr.pool_hdl;
+	return *(odp_pool_t *)(uintptr_t)((uint8_t *)pkt +
+	       _odp_packet_inline.pool);
 }

 /** @internal Inline function @param pkt @return */
 static inline odp_pktio_t _odp_packet_input(odp_packet_t pkt)
 {
-	return odp_packet_hdr(pkt)->input;
+	return *(odp_pktio_t *)(uintptr_t)((uint8_t *)pkt +
+	       _odp_packet_inline.input);
 }

 /** @internal Inline function @param pkt @return */
 static inline int _odp_packet_num_segs(odp_packet_t pkt)
 {
-	struct rte_mbuf *mb = &(odp_packet_hdr(pkt)->buf_hdr.mb);
+	struct rte_mbuf *mb = (struct rte_mbuf *)((uint8_t *)pkt +
+			      _odp_packet_inline.mb);

 	return mb->nb_segs;
 }
@@ -110,52 +109,60 @@  static inline int _odp_packet_num_segs(odp_packet_t pkt)
 /** @internal Inline function @param pkt @return */
 static inline void *_odp_packet_user_ptr(odp_packet_t pkt)
 {
-	return odp_packet_hdr(pkt)->buf_hdr.buf_ctx;
+	return *(void **)(uintptr_t)((uint8_t *)pkt +
+	       _odp_packet_inline.user_ptr);
 }

 /** @internal Inline function @param pkt @return */
 static inline void *_odp_packet_user_area(odp_packet_t pkt)
 {
-	return (void *)((char *)pkt + udata_offset);
+	return (void *)((char *)pkt + _odp_packet_inline.udata);
 }

 /** @internal Inline function @param pkt @return */
 static inline uint32_t _odp_packet_user_area_size(odp_packet_t pkt)
 {
-	return *(uint32_t *)(void *)((char *)pkt + udata_len_offset);
+	return *(uint32_t *)(void *)((char *)pkt +
+		 _odp_packet_inline.udata_len);
 }

 /** @internal Inline function @param pkt @return */
 static inline uint32_t _odp_packet_flow_hash(odp_packet_t pkt)
 {
-	return *(uint32_t *)(void *)((char *)pkt + rss_offset);
+	return *(uint32_t *)(void *)((char *)pkt +
+		 _odp_packet_inline.mb +
+		 _odp_packet_inline.rss);
 }

 /** @internal Inline function @param pkt @param flow_hash */
 static inline void _odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash)
 {
-	*(uint32_t *)(void *)((char *)pkt + rss_offset) = flow_hash;
-	*(uint64_t *)(void *)((char *)pkt + ol_flags_offset) |= rss_flag;
+	*(uint32_t *)(void *)((char *)pkt + _odp_packet_inline.rss)
+	  = flow_hash;
+	*(uint64_t *)(void *)((char *)pkt +
+	  _odp_packet_inline.mb +
+	  _odp_packet_inline.ol_flags)
+	  |= _odp_packet_inline.rss_flag;
 }

 /** @internal Inline function @param pkt @return */
 static inline odp_time_t _odp_packet_ts(odp_packet_t pkt)
 {
-	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
-
-	return pkt_hdr->timestamp;
+	return *(odp_time_t *)(uintptr_t)((uint8_t *)pkt +
+		 _odp_packet_inline.timestamp);
 }

 /** @internal Inline function @param pkt @return */
 static inline void *_odp_packet_head(odp_packet_t pkt)
 {
-	return odp_buffer_addr(_odp_packet_to_buffer(pkt));
+	return (uint8_t *)_odp_packet_data(pkt) - _odp_packet_headroom(pkt);
 }

 /** @internal Inline function @param pkt @return */
 static inline int _odp_packet_is_segmented(odp_packet_t pkt)
 {
-	return !rte_pktmbuf_is_contiguous(&odp_packet_hdr(pkt)->buf_hdr.mb);
+	return !rte_pktmbuf_is_contiguous((struct rte_mbuf *)((uint8_t *)pkt +
+					   _odp_packet_inline.mb));
 }

 /** @internal Inline function @param pkt @return */
@@ -167,7 +174,8 @@  static inline odp_packet_seg_t _odp_packet_first_seg(odp_packet_t pkt)
 /** @internal Inline function @param pkt @return */
 static inline odp_packet_seg_t _odp_packet_last_seg(odp_packet_t pkt)
 {
-	struct rte_mbuf *mb = &(odp_packet_hdr(pkt)->buf_hdr.mb);
+	struct rte_mbuf *mb = (struct rte_mbuf *)((uint8_t *)pkt +
+			      _odp_packet_inline.mb);

 	return (odp_packet_seg_t)(uintptr_t)rte_pktmbuf_lastseg(mb);
 }
@@ -187,13 +195,22 @@  static inline odp_packet_seg_t _odp_packet_next_seg(odp_packet_t pkt ODP_UNUSED,
 /** @internal Inline function @param pkt @param offset @param len */
 static inline void _odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, uint32_t len)
 {
-	const char *addr = (char *)odp_packet_data(pkt) + offset;
+	const char *addr = (char *)_odp_packet_data(pkt) + offset;
 	size_t ofs;

 	for (ofs = 0; ofs < len; ofs += RTE_CACHE_LINE_SIZE)
 		rte_prefetch0(addr + ofs);
 }

+/* Include inlined versions of API functions */
+#include <odp/api/plat/static_inline.h>
+
+#if ODP_ABI_COMPAT == 0
+
+#include <odp/api/plat/packet_inlines_api.h>
+
+#endif /* ODP_ABI_COMPAT */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_types.h b/platform/linux-dpdk/include/odp/api/plat/packet_types.h
index af8b422..d43f697 100644
--- a/platform/linux-dpdk/include/odp/api/plat/packet_types.h
+++ b/platform/linux-dpdk/include/odp/api/plat/packet_types.h
@@ -18,6 +18,8 @@ 
 extern "C" {
 #endif

+#include <stddef.h>
+
 #include <odp/api/plat/static_inline.h>
 #if ODP_ABI_COMPAT == 1
 #include <odp/api/abi/packet.h>
@@ -55,6 +57,39 @@  typedef enum {

 #endif

+/** @internal Packet header field offsets for inline functions */
+typedef struct _odp_packet_inline_offset_t {
+	/** @internal field offset */
+	size_t mb;
+	/** @internal field offset */
+	size_t pool;
+	/** @internal field offset */
+	size_t input;
+	/** @internal field offset */
+	size_t user_ptr;
+	/** @internal field offset */
+	size_t timestamp;
+	/** @internal field offset */
+	unsigned int buf_addr;
+	/** @internal field offset */
+	unsigned int data;
+	/** @internal field offset */
+	unsigned int pkt_len;
+	/** @internal field offset */
+	unsigned int seg_len;
+	/** @internal field offset */
+	unsigned int udata_len;
+	/** @internal field offset */
+	unsigned int udata;
+	/** @internal field offset */
+	unsigned int rss;
+	/** @internal field offset */
+	unsigned int ol_flags;
+	/** @internal field offset */
+	uint64_t rss_flag;
+
+} _odp_packet_inline_offset_t;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
index b01225e..162a1fc 100644
--- a/platform/linux-dpdk/include/odp_packet_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_internal.h
@@ -231,7 +231,7 @@  static inline void copy_packet_cls_metadata(odp_packet_hdr_t *src_hdr,

 static inline uint32_t packet_len(odp_packet_hdr_t *pkt_hdr)
 {
-	return odp_packet_len((odp_packet_t)pkt_hdr);
+	return rte_pktmbuf_pkt_len(&pkt_hdr->buf_hdr.mb);
 }

 static inline void packet_set_len(odp_packet_hdr_t *pkt_hdr, uint32_t len)
@@ -274,13 +274,15 @@  static inline void _odp_packet_reset_parse(odp_packet_t pkt)
 {
 	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);

+	uint32_t frame_len = rte_pktmbuf_pkt_len(&pkt_hdr->buf_hdr.mb);
+
 	pkt_hdr->p.parsed_layers = LAYER_NONE;
 	pkt_hdr->p.input_flags.all = 0;
 	pkt_hdr->p.output_flags.all = 0;
 	pkt_hdr->p.error_flags.all = 0;
 	pkt_hdr->p.l2_offset = 0;

-	packet_parse_l2(&pkt_hdr->p, odp_packet_len(pkt));
+	packet_parse_l2(&pkt_hdr->p, frame_len);
 }

 /* Perform packet parse up to a given protocol layer */
diff --git a/platform/linux-dpdk/m4/configure.m4 b/platform/linux-dpdk/m4/configure.m4
index d238556..fb9a913 100644
--- a/platform/linux-dpdk/m4/configure.m4
+++ b/platform/linux-dpdk/m4/configure.m4
@@ -38,6 +38,7 @@  m4_include([platform/linux-dpdk/m4/odp_openssl.m4])
 # DPDK build variables
 ##########################################################################
 DPDK_DRIVER_DIR=/usr/lib/$(uname -m)-linux-gnu
+AS_CASE($host_cpu, [x86_64], [AM_CPPFLAGS="$AM_CPPFLAGS -msse4.2"])
 if test ${DPDK_DEFAULT_DIR} = 1; then
     AM_CPPFLAGS="$AM_CPPFLAGS -I/usr/include/dpdk"
 else
diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c
index 996670e..d82df9f 100644
--- a/platform/linux-dpdk/odp_packet.c
+++ b/platform/linux-dpdk/odp_packet.c
@@ -7,9 +7,9 @@ 
 #include <odp/api/plat/packet_inlines.h>
 #include <odp/api/packet.h>
 #include <odp_packet_internal.h>
+#include <odp_debug_internal.h>
 #include <odp/api/hints.h>
 #include <odp/api/byteorder.h>
-#include <odp_debug_internal.h>

 #include <protocols/eth.h>
 #include <protocols/ip.h>
@@ -21,34 +21,30 @@ 
 #include <stddef.h>
 #include <inttypes.h>

-/* These are the offsets for packet accessors for inlining. */
-const unsigned int buf_addr_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
-				     offsetof(struct odp_buffer_hdr_t, mb) +
-				     offsetof(struct rte_mbuf, buf_addr);
-const unsigned int data_off_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
-				     offsetof(struct odp_buffer_hdr_t, mb) +
-				     offsetof(struct rte_mbuf, data_off);
+/* Fill in packet header field offsets for inline functions */
+
+const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
+	.mb               = offsetof(odp_packet_hdr_t, buf_hdr.mb),
+	.pool             = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
+	.input            = offsetof(odp_packet_hdr_t, input),
+	.user_ptr         = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx),
+	.timestamp        = offsetof(odp_packet_hdr_t, timestamp),
+	.buf_addr         = offsetof(const struct rte_mbuf, buf_addr),
+	.data             = offsetof(struct rte_mbuf, data_off),
+	.pkt_len          = (size_t)&rte_pktmbuf_pkt_len((struct rte_mbuf *)0),
+	.seg_len          = (size_t)&rte_pktmbuf_data_len((struct rte_mbuf *)0),
+	.udata_len        = offsetof(odp_packet_hdr_t, uarea_size),
+	.udata            = sizeof(odp_packet_hdr_t),
+	.rss              = offsetof(struct rte_mbuf, hash.rss),
+	.ol_flags         = offsetof(struct rte_mbuf, ol_flags),
+	.rss_flag         = PKT_RX_RSS_HASH
+};

 /* The last bit is an expanded version of offsetof(), to make sure that if
  * rte_pktmbuf_[pkt|data]_len() changes, we will either adapt automatically, or
  * throw a compile failure
  */
-const unsigned int pkt_len_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
-				    offsetof(struct odp_buffer_hdr_t, mb) +
-				    (size_t)&rte_pktmbuf_pkt_len((struct rte_mbuf *)0);
-const unsigned int seg_len_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
-				    offsetof(struct odp_buffer_hdr_t, mb) +
-				    (size_t)&rte_pktmbuf_data_len((struct rte_mbuf *)0);
-
-const unsigned int udata_len_offset = offsetof(odp_packet_hdr_t, uarea_size);
-const unsigned int udata_offset = sizeof(odp_packet_hdr_t);
-const unsigned int rss_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
-				offsetof(struct odp_buffer_hdr_t, mb) +
-				offsetof(struct rte_mbuf, hash.rss);
-const unsigned int ol_flags_offset = offsetof(odp_packet_hdr_t, buf_hdr) +
-				     offsetof(struct odp_buffer_hdr_t, mb) +
-				     offsetof(struct rte_mbuf, ol_flags);
-const uint64_t rss_flag = PKT_RX_RSS_HASH;
+

 struct rte_mbuf dummy;
 ODP_STATIC_ASSERT(sizeof(dummy.data_off) == sizeof(uint16_t),
@@ -61,7 +57,6 @@  ODP_STATIC_ASSERT(sizeof(dummy.hash.rss) == sizeof(uint32_t),
 		  "hash.rss should be uint32_t");
 ODP_STATIC_ASSERT(sizeof(dummy.ol_flags) == sizeof(uint64_t),
 		  "ol_flags should be uint64_t");
-
 /*
  *
  * Alloc and free
diff --git a/platform/linux-dpdk/odp_std_clib.c b/platform/linux-dpdk/odp_std_clib.c
index 2a00cfe..3f52c3a 100644
--- a/platform/linux-dpdk/odp_std_clib.c
+++ b/platform/linux-dpdk/odp_std_clib.c
@@ -13,7 +13,7 @@  extern "C" {
 #include <odp/api/std_clib.h>

 #if ODP_ABI_COMPAT == 0
-#include <odp/api/visibility_begin.h>
+#include <odp/visibility_begin.h>
 #endif

 #if defined(__arm__) || defined(__aarch64__)
@@ -28,7 +28,7 @@  void* (*const dpdk_memcpy)(void*, const void*, size_t) = &rte_memcpy;
 #endif

 #if ODP_ABI_COMPAT == 0
-#include <odp/api/visibility_end.h>
+#include <odp/visibility_end.h>
 #else
 #include <odp/api/plat/std_clib_inlines.h>
 #endif