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 cd289985b5247fe9f1d1f58753717bd5659bd7d0 (commit) via 38fb73d6ed79d649fdec726ca4bacc93747daa9b (commit) from 5b915893c793ffb3d49152d480d084dba32a5a74 (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 cd289985b5247fe9f1d1f58753717bd5659bd7d0 Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Dec 21 17:13:12 2017 +0200
linux-gen: packet: inline layer pointers
Inline L2/L3/L4 pointer functions. Packet map function is exported to backup the unlikely case when offset is not within the first segment. Always use the inlined version within the implementation itself.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
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 aa9ba812..4314619a 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -18,6 +18,11 @@ #include <odp/api/packet_io.h> #include <odp/api/hints.h>
+/** @internal Inline function @param pkt_ptr @param offset @param seg_len + * @param seg_idx @return */ +void *_odp_packet_map(void *pkt_ptr, uint32_t offset, uint32_t *seg_len, + int *seg_idx); + /** @internal Inline function offsets */ extern const _odp_packet_inline_offset_t _odp_packet_inline;
@@ -126,6 +131,63 @@ static inline uint32_t _odp_packet_l4_offset(odp_packet_t pkt) return _odp_pkt_get(pkt, uint16_t, l4_offset); }
+/** @internal Inline function @param pkt @param len @return */ +static inline void *_odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) +{ + uint32_t offset = _odp_packet_l2_offset(pkt); + uint32_t seg_len = _odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)_odp_packet_data(pkt); + + if (odp_unlikely(offset >= seg_len)) { + void *pkt_hdr = (void *)pkt; + + return _odp_packet_map(pkt_hdr, offset, len, NULL); + } + + if (len) + *len = seg_len - offset; + + return data + offset; +} + +/** @internal Inline function @param pkt @param len @return */ +static inline void *_odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) +{ + uint32_t offset = _odp_packet_l3_offset(pkt); + uint32_t seg_len = _odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)_odp_packet_data(pkt); + + if (odp_unlikely(offset >= seg_len)) { + void *pkt_hdr = (void *)pkt; + + return _odp_packet_map(pkt_hdr, offset, len, NULL); + } + + if (len) + *len = seg_len - offset; + + return data + offset; +} + +/** @internal Inline function @param pkt @param len @return */ +static inline void *_odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) +{ + uint32_t offset = _odp_packet_l4_offset(pkt); + uint32_t seg_len = _odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)_odp_packet_data(pkt); + + if (odp_unlikely(offset >= seg_len)) { + void *pkt_hdr = (void *)pkt; + + return _odp_packet_map(pkt_hdr, offset, len, NULL); + } + + if (len) + *len = seg_len - offset; + + return data + offset; +} + /** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_flow_hash(odp_packet_t pkt) { diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h index 84b4f08a..c90a69c5 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h @@ -83,6 +83,21 @@ _ODP_INLINE uint32_t odp_packet_l4_offset(odp_packet_t pkt) return _odp_packet_l4_offset(pkt); }
+_ODP_INLINE void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) +{ + return _odp_packet_l2_ptr(pkt, len); +} + +_ODP_INLINE void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) +{ + return _odp_packet_l3_ptr(pkt, len); +} + +_ODP_INLINE void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) +{ + return _odp_packet_l4_ptr(pkt, len); +} + _ODP_INLINE uint32_t odp_packet_flow_hash(odp_packet_t pkt) { return _odp_packet_flow_hash(pkt); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 3f0d764f..446d8efa 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -278,11 +278,12 @@ static inline void packet_seg_copy_md(odp_packet_hdr_t *dst, */ }
-static inline void *packet_map(odp_packet_hdr_t *pkt_hdr, - uint32_t offset, uint32_t *seg_len, int *seg_idx) +static inline void *packet_map(void *pkt_ptr, uint32_t offset, + uint32_t *seg_len, int *seg_idx) { void *addr; uint32_t len; + odp_packet_hdr_t *pkt_hdr = pkt_ptr; int seg_id = 0; int seg_count = pkt_hdr->buf_hdr.segcount;
@@ -323,6 +324,18 @@ static inline void *packet_map(odp_packet_hdr_t *pkt_hdr, return addr; }
+#include <odp/visibility_begin.h> + +/* This file uses the inlined version directly. Inlined API calls use this when + * offset does not point to the first segment. */ +void *_odp_packet_map(void *pkt_ptr, uint32_t offset, uint32_t *seg_len, + int *seg_idx) +{ + return packet_map(pkt_ptr, offset, seg_len, seg_idx); +} + +#include <odp/visibility_end.h> + void packet_parse_reset(odp_packet_hdr_t *pkt_hdr) { /* Reset parser metadata before new parse */ @@ -1207,15 +1220,6 @@ void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ctx) packet_hdr(pkt)->buf_hdr.buf_cctx = ctx; }
-void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - if (!packet_hdr_has_l2(pkt_hdr)) - return NULL; - return packet_map(pkt_hdr, pkt_hdr->p.l2_offset, len, NULL); -} - int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1228,13 +1232,6 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) return 0; }
-void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return packet_map(pkt_hdr, pkt_hdr->p.l3_offset, len, NULL); -} - int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1246,13 +1243,6 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) return 0; }
-void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return packet_map(pkt_hdr, pkt_hdr->p.l4_offset, len, NULL); -} - int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index e22a33f2..556b2a1f 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -1928,7 +1928,7 @@ static void egress_vlan_marking(tm_vlan_marking_t *vlan_marking, uint32_t hdr_len; uint16_t old_tci, new_tci;
- ether_hdr_ptr = odp_packet_l2_ptr(odp_pkt, &hdr_len); + ether_hdr_ptr = _odp_packet_l2_ptr(odp_pkt, &hdr_len); vlan_hdr_ptr = (_odp_vlanhdr_t *)(ether_hdr_ptr + 1);
/* If the split_hdr variable below is TRUE, then this indicates that @@ -1968,7 +1968,7 @@ static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, uint8_t old_tos, new_tos, ecn;
l3_offset = _odp_packet_l3_offset(odp_pkt); - ipv4_hdr_ptr = odp_packet_l3_ptr(odp_pkt, &hdr_len); + ipv4_hdr_ptr = _odp_packet_l3_ptr(odp_pkt, &hdr_len);
/* If the split_hdr variable below is TRUE, then this indicates that * for this odp (output) packet the IPv4 header is not all in the same @@ -2034,7 +2034,7 @@ static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, uint8_t old_tc, new_tc, ecn;
l3_offset = _odp_packet_l3_offset(odp_pkt); - ipv6_hdr_ptr = odp_packet_l3_ptr(odp_pkt, &hdr_len); + ipv6_hdr_ptr = _odp_packet_l3_ptr(odp_pkt, &hdr_len);
/* If the split_hdr variable below is TRUE, then this indicates that * for this odp (output) packet the IPv6 header is not all in the same
commit 38fb73d6ed79d649fdec726ca4bacc93747daa9b Author: Petri Savolainen petri.savolainen@linaro.org Date: Thu Dec 21 16:09:07 2017 +0200
linux-gen: packet: inline layer offsets
Inline L2/L3/L4 offset read functions. Always use the inlined version within the implementation itself.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
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 c808f2d6..aa9ba812 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -108,6 +108,24 @@ static inline uint32_t _odp_packet_user_area_size(odp_packet_t pkt) return _odp_pool_get(pool, uint32_t, uarea_size); }
+/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_l2_offset(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint16_t, l2_offset); +} + +/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_l3_offset(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint16_t, l3_offset); +} + +/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_l4_offset(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint16_t, l4_offset); +} + /** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_flow_hash(odp_packet_t pkt) { diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h index 233bc876..84b4f08a 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h @@ -68,6 +68,21 @@ _ODP_INLINE uint32_t odp_packet_user_area_size(odp_packet_t pkt) return _odp_packet_user_area_size(pkt); }
+_ODP_INLINE uint32_t odp_packet_l2_offset(odp_packet_t pkt) +{ + return _odp_packet_l2_offset(pkt); +} + +_ODP_INLINE uint32_t odp_packet_l3_offset(odp_packet_t pkt) +{ + return _odp_packet_l3_offset(pkt); +} + +_ODP_INLINE uint32_t odp_packet_l4_offset(odp_packet_t pkt) +{ + return _odp_packet_l4_offset(pkt); +} + _ODP_INLINE uint32_t odp_packet_flow_hash(odp_packet_t pkt) { return _odp_packet_flow_hash(pkt); diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h index 009a3aa7..5b44c09c 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_types.h @@ -94,6 +94,12 @@ typedef struct _odp_packet_inline_offset_t { /** @internal field offset */ uint16_t user_area; /** @internal field offset */ + uint16_t l2_offset; + /** @internal field offset */ + uint16_t l3_offset; + /** @internal field offset */ + uint16_t l4_offset; + /** @internal field offset */ uint16_t flow_hash; /** @internal field offset */ uint16_t timestamp; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 04f1f33b..3f0d764f 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -37,6 +37,9 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = { .segcount = offsetof(odp_packet_hdr_t, buf_hdr.segcount), .user_ptr = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx), .user_area = offsetof(odp_packet_hdr_t, buf_hdr.uarea_addr), + .l2_offset = offsetof(odp_packet_hdr_t, p.l2_offset), + .l3_offset = offsetof(odp_packet_hdr_t, p.l3_offset), + .l4_offset = offsetof(odp_packet_hdr_t, p.l4_offset), .flow_hash = offsetof(odp_packet_hdr_t, flow_hash), .timestamp = offsetof(odp_packet_hdr_t, timestamp), .input_flags = offsetof(odp_packet_hdr_t, p.input_flags) @@ -1213,15 +1216,6 @@ void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) return packet_map(pkt_hdr, pkt_hdr->p.l2_offset, len, NULL); }
-uint32_t odp_packet_l2_offset(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - if (!packet_hdr_has_l2(pkt_hdr)) - return ODP_PACKET_OFFSET_INVALID; - return pkt_hdr->p.l2_offset; -} - int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1241,13 +1235,6 @@ void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) return packet_map(pkt_hdr, pkt_hdr->p.l3_offset, len, NULL); }
-uint32_t odp_packet_l3_offset(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return pkt_hdr->p.l3_offset; -} - int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1266,13 +1253,6 @@ void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) return packet_map(pkt_hdr, pkt_hdr->p.l4_offset, len, NULL); }
-uint32_t odp_packet_l4_offset(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return pkt_hdr->p.l4_offset; -} - int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index ab06b3c0..e22a33f2 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -26,6 +26,7 @@ #include <protocols/eth.h> #include <protocols/ip.h> #include <odp_traffic_mngr_internal.h> +#include <odp/api/plat/packet_inlines.h>
/* Local vars */ static const @@ -1966,7 +1967,7 @@ static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, uint32_t hdr_len, l3_offset, old_chksum, ones_compl_sum, tos_diff; uint8_t old_tos, new_tos, ecn;
- l3_offset = odp_packet_l3_offset(odp_pkt); + l3_offset = _odp_packet_l3_offset(odp_pkt); ipv4_hdr_ptr = odp_packet_l3_ptr(odp_pkt, &hdr_len);
/* If the split_hdr variable below is TRUE, then this indicates that @@ -2032,7 +2033,7 @@ static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, uint32_t hdr_len, old_ver_tc_flow, new_ver_tc_flow, l3_offset; uint8_t old_tc, new_tc, ecn;
- l3_offset = odp_packet_l3_offset(odp_pkt); + l3_offset = _odp_packet_l3_offset(odp_pkt); ipv6_hdr_ptr = odp_packet_l3_ptr(odp_pkt, &hdr_len);
/* If the split_hdr variable below is TRUE, then this indicates that
-----------------------------------------------------------------------
Summary of changes: .../include/odp/api/plat/packet_inlines.h | 80 ++++++++++++++++++++++ .../include/odp/api/plat/packet_inlines_api.h | 30 ++++++++ .../include/odp/api/plat/packet_types.h | 6 ++ platform/linux-generic/odp_packet.c | 66 +++++------------- platform/linux-generic/odp_traffic_mngr.c | 11 +-- 5 files changed, 140 insertions(+), 53 deletions(-)
hooks/post-receive