diff options
author | Matias Elo <matias.elo@nokia.com> | 2017-05-16 16:48:08 +0300 |
---|---|---|
committer | Balakrishna Garapati <balakrishna.garapati@linaro.org> | 2017-05-17 10:22:53 +0200 |
commit | 55c3a23f6cfedb678dca8891499f1af3caa065fd (patch) | |
tree | 3ee926cd6d5f01bd0bc059a3098cf358bbab3871 | |
parent | fd145cc6837b269e680878870b80f0b4d5260eb2 (diff) |
Port bd9f5847 "linux-gen: packet: inline flag functions"
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-and-tested-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
-rw-r--r-- | platform/linux-dpdk/Makefile.am | 3 | ||||
-rw-r--r-- | platform/linux-dpdk/include/odp/api/packet_flags.h | 19 | ||||
-rw-r--r-- | platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h | 94 | ||||
-rw-r--r-- | platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines_api.h | 46 | ||||
-rw-r--r-- | platform/linux-dpdk/include/odp/api/plat/packet_flags_inlines.h | 46 | ||||
-rw-r--r-- | platform/linux-dpdk/include/odp/api/plat/packet_types.h | 50 | ||||
-rw-r--r-- | platform/linux-dpdk/include/odp_packet_internal.h | 55 | ||||
-rw-r--r-- | platform/linux-dpdk/odp_packet.c | 1 | ||||
-rw-r--r-- | platform/linux-dpdk/odp_packet_flags.c | 38 |
9 files changed, 204 insertions, 148 deletions
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index 08c2c4607..9ffd6fd00 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -88,7 +88,8 @@ odpapiplatinclude_HEADERS = \ $(srcdir)/include/odp/api/plat/crypto_types.h \ $(srcdir)/include/odp/api/plat/event_types.h \ $(srcdir)/include/odp/api/plat/init_types.h \ - $(srcdir)/include/odp/api/plat/packet_flags_inlines.h \ + $(srcdir)/include/odp/api/plat/packet_flag_inlines.h \ + $(srcdir)/include/odp/api/plat/packet_flag_inlines_api.h \ $(srcdir)/include/odp/api/plat/packet_inlines.h \ $(srcdir)/include/odp/api/plat/packet_inlines_api.h \ $(srcdir)/include/odp/api/plat/packet_io_types.h \ diff --git a/platform/linux-dpdk/include/odp/api/packet_flags.h b/platform/linux-dpdk/include/odp/api/packet_flags.h index d5fa75541..e3725a60f 100644 --- a/platform/linux-dpdk/include/odp/api/packet_flags.h +++ b/platform/linux-dpdk/include/odp/api/packet_flags.h @@ -7,7 +7,7 @@ /** * @file * - * ODP packet descriptor + * ODP packet flags */ #ifndef ODP_PLAT_PACKET_FLAGS_H_ @@ -17,26 +17,11 @@ extern "C" { #endif -#include <odp/api/std_types.h> -#include <odp/api/plat/event_types.h> -#include <odp/api/plat/packet_io_types.h> -#include <odp/api/plat/packet_types.h> -#include <odp/api/plat/buffer_types.h> -#include <odp/api/plat/pool_types.h> - -/** @ingroup odp_packet - * @{ - */ - #include <odp/api/plat/static_inline.h> #if ODP_ABI_COMPAT == 0 -#include <odp/api/plat/packet_flags_inlines.h> +#include <odp/api/plat/packet_flag_inlines.h> #endif -/** - * @} - */ - #include <odp/api/spec/packet_flags.h> #ifdef __cplusplus diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h new file mode 100644 index 000000000..fef6ff97b --- /dev/null +++ b/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h @@ -0,0 +1,94 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Packet flag inline functions + */ + +#ifndef _ODP_PLAT_PACKET_FLAG_INLINES_H_ +#define _ODP_PLAT_PACKET_FLAG_INLINES_H_ + +#include <odp/api/plat/packet_types.h> + +/** @internal Inline function offsets */ +extern const _odp_packet_inline_offset_t _odp_packet_inline; + +/** @internal Inline function @param pkt @return */ +static inline uint64_t _odp_packet_input_flags(odp_packet_t pkt) +{ + return *(uint64_t *)(uintptr_t)((uint8_t *)pkt + + _odp_packet_inline.input_flags); +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_l2(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.l2; +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_eth(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.eth; +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_jumbo(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.jumbo; +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_flow_hash(odp_packet_t pkt) +{ + return *(uint64_t *)((char *)pkt + _odp_packet_inline.ol_flags) & + _odp_packet_inline.rss_flag; +} + +/** @internal Inline function @param pkt */ +static inline void _odp_packet_has_flow_hash_clr(odp_packet_t pkt) +{ + *(uint64_t *)((char *)pkt + _odp_packet_inline.ol_flags) &= + ~_odp_packet_inline.rss_flag; +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_ts(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.timestamp; +} + +/* Include inlined versions of API functions */ +#include <odp/api/plat/static_inline.h> +#if ODP_ABI_COMPAT == 0 + +/** @ingroup odp_packet + * @{ + */ + +#include <odp/api/plat/packet_flag_inlines_api.h> + +/** + * @} + */ + +#endif + +#endif diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines_api.h b/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines_api.h new file mode 100644 index 000000000..24062bf26 --- /dev/null +++ b/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines_api.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Packet flag inline functions + */ + +#ifndef _ODP_PLAT_PACKET_FLAG_INLINES_API_H_ +#define _ODP_PLAT_PACKET_FLAG_INLINES_API_H_ + +_ODP_INLINE int odp_packet_has_l2(odp_packet_t pkt) +{ + return _odp_packet_has_l2(pkt); +} + +_ODP_INLINE int odp_packet_has_eth(odp_packet_t pkt) +{ + return _odp_packet_has_eth(pkt); +} + +_ODP_INLINE int odp_packet_has_jumbo(odp_packet_t pkt) +{ + return _odp_packet_has_jumbo(pkt); +} + +_ODP_INLINE int odp_packet_has_flow_hash(odp_packet_t pkt) +{ + return _odp_packet_has_flow_hash(pkt); +} + +_ODP_INLINE void odp_packet_has_flow_hash_clr(odp_packet_t pkt) +{ + _odp_packet_has_flow_hash_clr(pkt); +} + +_ODP_INLINE int odp_packet_has_ts(odp_packet_t pkt) +{ + return _odp_packet_has_ts(pkt); +} + +#endif 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 deleted file mode 100644 index 03d9e0c4a..000000000 --- a/platform/linux-dpdk/include/odp/api/plat/packet_flags_inlines.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet flags inline functions - */ - -#ifndef ODP_PLAT_PACKET_FLAGS_INLINES_H_ -#define ODP_PLAT_PACKET_FLAGS_INLINES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @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. - * As we can't force the application to directly include DPDK headers we have to - * export these fields through constants calculated compile time in - * odp_packet.c, where we can see the DPDK definitions. - * - */ -_ODP_INLINE int odp_packet_has_flow_hash(odp_packet_t pkt) -{ - 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 + _odp_packet_inline.ol_flags) &= - ~_odp_packet_inline.rss_flag; -} - -#ifdef __cplusplus -} -#endif - -#endif /* ODP_PLAT_PACKET_FLAGS_INLINES_H_ */ 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 f054c37b3..c6ee3966f 100644 --- a/platform/linux-dpdk/include/odp/api/plat/packet_types.h +++ b/platform/linux-dpdk/include/odp/api/plat/packet_types.h @@ -70,6 +70,8 @@ typedef struct _odp_packet_inline_offset_t { /** @internal field offset */ size_t timestamp; /** @internal field offset */ + size_t input_flags; + /** @internal field offset */ unsigned int buf_addr; /** @internal field offset */ unsigned int data; @@ -92,6 +94,54 @@ typedef struct _odp_packet_inline_offset_t { } _odp_packet_inline_offset_t; +/** @internal Packet input & protocol flags */ +typedef union { + /** All input flags */ + uint64_t all; + + struct { + uint64_t parsed_l2:1; /**< L2 parsed */ + uint64_t dst_queue:1; /**< Dst queue present */ + + uint64_t timestamp:1; /**< Timestamp present */ + + uint64_t l2:1; /**< known L2 protocol present */ + uint64_t l3:1; /**< known L3 protocol present */ + uint64_t l4:1; /**< known L4 protocol present */ + + uint64_t eth:1; /**< Ethernet */ + uint64_t eth_bcast:1; /**< Ethernet broadcast */ + uint64_t eth_mcast:1; /**< Ethernet multicast */ + uint64_t jumbo:1; /**< Jumbo frame */ + uint64_t vlan:1; /**< VLAN hdr found */ + uint64_t vlan_qinq:1; /**< Stacked VLAN found, QinQ */ + + uint64_t snap:1; /**< SNAP */ + uint64_t arp:1; /**< ARP */ + + uint64_t ipv4:1; /**< IPv4 */ + uint64_t ipv6:1; /**< IPv6 */ + uint64_t ip_bcast:1; /**< IP broadcast */ + uint64_t ip_mcast:1; /**< IP multicast */ + uint64_t ipfrag:1; /**< IP fragment */ + uint64_t ipopt:1; /**< IP optional headers */ + + uint64_t ipsec:1; /**< IPSec packet. Required by the + odp_packet_has_ipsec_set() func. */ + uint64_t ipsec_ah:1; /**< IPSec authentication header */ + uint64_t ipsec_esp:1; /**< IPSec encapsulating security + payload */ + uint64_t udp:1; /**< UDP */ + uint64_t tcp:1; /**< TCP */ + uint64_t tcpopt:1; /**< TCP options present */ + uint64_t sctp:1; /**< SCTP */ + uint64_t icmp:1; /**< ICMP */ + + uint64_t color:2; /**< Packet color for traffic mgmt */ + uint64_t nodrop:1; /**< Drop eligibility status */ + }; +} _odp_packet_input_flags_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 162a1fcd7..d3f00847e 100644 --- a/platform/linux-dpdk/include/odp_packet_internal.h +++ b/platform/linux-dpdk/include/odp_packet_internal.h @@ -29,63 +29,14 @@ extern "C" { #include <odp/api/crypto.h> #include <odp_crypto_internal.h> #include <protocols/eth.h> +#include <odp/api/plat/packet_types.h> #include <rte_acl_osdep.h> /** Minimum segment length expected by packet_parse_common() */ #define PACKET_PARSE_SEG_LEN 96 -/** - * Packet input & protocol flags - */ -typedef union { - /* All input flags */ - uint64_t all; - - struct { - uint64_t parsed_l2:1; /**< L2 parsed */ - uint64_t dst_queue:1; /**< Dst queue present */ - - uint64_t timestamp:1; /**< Timestamp present */ - - uint64_t l2:1; /**< known L2 protocol present */ - uint64_t l3:1; /**< known L3 protocol present */ - uint64_t l4:1; /**< known L4 protocol present */ - - uint64_t eth:1; /**< Ethernet */ - uint64_t eth_bcast:1; /**< Ethernet broadcast */ - uint64_t eth_mcast:1; /**< Ethernet multicast */ - uint64_t jumbo:1; /**< Jumbo frame */ - uint64_t vlan:1; /**< VLAN hdr found */ - uint64_t vlan_qinq:1; /**< Stacked VLAN found, QinQ */ - - uint64_t snap:1; /**< SNAP */ - uint64_t arp:1; /**< ARP */ - - uint64_t ipv4:1; /**< IPv4 */ - uint64_t ipv6:1; /**< IPv6 */ - uint64_t ip_bcast:1; /**< IP broadcast */ - uint64_t ip_mcast:1; /**< IP multicast */ - uint64_t ipfrag:1; /**< IP fragment */ - uint64_t ipopt:1; /**< IP optional headers */ - - uint64_t ipsec:1; /**< IPSec packet. Required by the - odp_packet_has_ipsec_set() func. */ - uint64_t ipsec_ah:1; /**< IPSec authentication header */ - uint64_t ipsec_esp:1; /**< IPSec encapsulating security - payload */ - uint64_t udp:1; /**< UDP */ - uint64_t tcp:1; /**< TCP */ - uint64_t tcpopt:1; /**< TCP options present */ - uint64_t sctp:1; /**< SCTP */ - uint64_t icmp:1; /**< ICMP */ - - uint64_t color:2; /**< Packet color for traffic mgmt */ - uint64_t nodrop:1; /**< Drop eligibility status */ - }; -} input_flags_t; - -ODP_STATIC_ASSERT(sizeof(input_flags_t) == sizeof(uint64_t), +ODP_STATIC_ASSERT(sizeof(_odp_packet_input_flags_t) == sizeof(uint64_t), "INPUT_FLAGS_SIZE_ERROR"); /** @@ -148,7 +99,7 @@ typedef enum { * Packet parser metadata */ typedef struct { - input_flags_t input_flags; + _odp_packet_input_flags_t input_flags; error_flags_t error_flags; output_flags_t output_flags; diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c index 62df07569..68ad26b29 100644 --- a/platform/linux-dpdk/odp_packet.c +++ b/platform/linux-dpdk/odp_packet.c @@ -29,6 +29,7 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = { .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), + .input_flags = offsetof(odp_packet_hdr_t, p.input_flags), .buf_addr = offsetof(odp_packet_hdr_t, buf_hdr.mb) + offsetof(const struct rte_mbuf, buf_addr), .data = offsetof(odp_packet_hdr_t, buf_hdr.mb) + diff --git a/platform/linux-dpdk/odp_packet_flags.c b/platform/linux-dpdk/odp_packet_flags.c index 18c30bb15..20517e164 100644 --- a/platform/linux-dpdk/odp_packet_flags.c +++ b/platform/linux-dpdk/odp_packet_flags.c @@ -4,13 +4,10 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include <odp/api/plat/packet_flag_inlines.h> #include <odp/api/packet_flags.h> #include <odp_packet_internal.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/plat/packet_flags_inlines.h> -#endif - #define retflag(pkt, x, layer) do { \ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \ if (pkt_hdr->p.parsed_layers < layer) \ @@ -35,13 +32,6 @@ int odp_packet_has_error(odp_packet_t pkt) /* Get Input Flags */ -int odp_packet_has_l2(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.l2; -} - int odp_packet_has_l2_error(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); @@ -82,13 +72,6 @@ int odp_packet_has_l4_error(odp_packet_t pkt) return pkt_hdr->p.error_flags.tcp_err | pkt_hdr->p.error_flags.udp_err; } -int odp_packet_has_eth(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.eth; -} - int odp_packet_has_eth_bcast(odp_packet_t pkt) { retflag(pkt, input_flags.eth_bcast, LAYER_L2); @@ -99,13 +82,6 @@ int odp_packet_has_eth_mcast(odp_packet_t pkt) retflag(pkt, input_flags.eth_mcast, LAYER_L2); } -int odp_packet_has_jumbo(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.jumbo; -} - int odp_packet_has_vlan(odp_packet_t pkt) { retflag(pkt, input_flags.vlan, LAYER_L2); @@ -176,13 +152,6 @@ int odp_packet_has_icmp(odp_packet_t pkt) retflag(pkt, input_flags.icmp, LAYER_L4); } -int odp_packet_has_ts(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.timestamp; -} - odp_packet_color_t odp_packet_color(odp_packet_t pkt) { retflag(pkt, input_flags.color, LAYER_ALL); @@ -341,3 +310,8 @@ void odp_packet_has_ts_clr(odp_packet_t pkt) pkt_hdr->p.input_flags.timestamp = 0; } + +/* Include non-inlined versions of API functions */ +#if ODP_ABI_COMPAT == 1 +#include <odp/api/plat/packet_flag_inlines_api.h> +#endif |