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 3e9560480627196a26d702be045ff22191b9a6c1 (commit) from a97db1b8b46b9656f964ccf09ce28941ae062507 (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 3e9560480627196a26d702be045ff22191b9a6c1 Author: Yi He yi.he@linaro.org Date: Mon Jul 4 07:53:22 2016 +0000
linux-gen: remove all dependencies to helper
Remove all dependencies to helper by copying protocol header definitions into linux-generic, checked and decoupled all odph_* ODPH_* references.
Signed-off-by: Yi He yi.he@linaro.org Reviewed-and-tested-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 469869e..c8fd8cb 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -6,8 +6,6 @@ include $(top_srcdir)/platform/@with_platform@/Makefile.inc
AM_CFLAGS += -I$(srcdir)/include AM_CFLAGS += -I$(top_srcdir)/include -AM_CFLAGS += -I$(top_srcdir)/helper/include -AM_CFLAGS += -I$(top_srcdir)/helper
include_HEADERS = \ $(top_srcdir)/include/odp.h \ @@ -125,6 +123,11 @@ noinst_HEADERS = \ ${srcdir}/include/odp_timer_internal.h \ ${srcdir}/include/odp_timer_wheel_internal.h \ ${srcdir}/include/odp_traffic_mngr_internal.h \ + ${srcdir}/include/protocols/eth.h \ + ${srcdir}/include/protocols/ip.h \ + ${srcdir}/include/protocols/ipsec.h \ + ${srcdir}/include/protocols/tcp.h \ + ${srcdir}/include/protocols/udp.h \ ${srcdir}/Makefile.inc
__LIB__libodp_linux_la_SOURCES = \ diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index 611d706..b839197 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -19,11 +19,11 @@ extern "C" { #endif
#include <odp/api/debug.h> -#include <odp/helper/eth.h> -#include <odp/helper/ip.h> -#include <odp/helper/ipsec.h> -#include <odp/helper/udp.h> -#include <odp/helper/tcp.h> +#include <protocols/eth.h> +#include <protocols/ip.h> +#include <protocols/ipsec.h> +#include <protocols/udp.h> +#include <protocols/tcp.h> #include <odp_packet_internal.h>
/* PMR term value verification function @@ -45,11 +45,11 @@ static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr, odp_packet_hdr_t *pkt_hdr, pmr_term_value_t *term_value) { - const odph_ipv4hdr_t *ip; + const _odp_ipv4hdr_t *ip; uint8_t proto; if (!pkt_hdr->p.input_flags.ipv4) return 0; - ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); + ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); proto = ip->proto; if (term_value->match.value == (proto & term_value->match.mask)) return 1; @@ -61,11 +61,11 @@ static inline int verify_pmr_ipv4_saddr(const uint8_t *pkt_addr, odp_packet_hdr_t *pkt_hdr, pmr_term_value_t *term_value) { - const odph_ipv4hdr_t *ip; + const _odp_ipv4hdr_t *ip; uint32_t ipaddr; if (!pkt_hdr->p.input_flags.ipv4) return 0; - ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); + ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); ipaddr = odp_be_to_cpu_32(ip->src_addr); if (term_value->match.value == (ipaddr & term_value->match.mask)) return 1; @@ -77,11 +77,11 @@ static inline int verify_pmr_ipv4_daddr(const uint8_t *pkt_addr, odp_packet_hdr_t *pkt_hdr, pmr_term_value_t *term_value) { - const odph_ipv4hdr_t *ip; + const _odp_ipv4hdr_t *ip; uint32_t ipaddr; if (!pkt_hdr->p.input_flags.ipv4) return 0; - ip = (const odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); + ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset); ipaddr = odp_be_to_cpu_32(ip->dst_addr); if (term_value->match.value == (ipaddr & term_value->match.mask)) return 1; @@ -94,10 +94,10 @@ static inline int verify_pmr_tcp_sport(const uint8_t *pkt_addr, pmr_term_value_t *term_value) { uint16_t sport; - const odph_tcphdr_t *tcp; + const _odp_tcphdr_t *tcp; if (!pkt_hdr->p.input_flags.tcp) return 0; - tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); + tcp = (const _odp_tcphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); sport = odp_be_to_cpu_16(tcp->src_port); if (term_value->match.value == (sport & term_value->match.mask)) return 1; @@ -110,10 +110,10 @@ static inline int verify_pmr_tcp_dport(const uint8_t *pkt_addr, pmr_term_value_t *term_value) { uint16_t dport; - const odph_tcphdr_t *tcp; + const _odp_tcphdr_t *tcp; if (!pkt_hdr->p.input_flags.tcp) return 0; - tcp = (const odph_tcphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); + tcp = (const _odp_tcphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); dport = odp_be_to_cpu_16(tcp->dst_port); if (term_value->match.value == (dport & term_value->match.mask)) return 1; @@ -126,10 +126,10 @@ static inline int verify_pmr_udp_dport(const uint8_t *pkt_addr, pmr_term_value_t *term_value) { uint16_t dport; - const odph_udphdr_t *udp; + const _odp_udphdr_t *udp; if (!pkt_hdr->p.input_flags.udp) return 0; - udp = (const odph_udphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); + udp = (const _odp_udphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); dport = odp_be_to_cpu_16(udp->dst_port); if (term_value->match.value == (dport & term_value->match.mask)) return 1; @@ -142,11 +142,11 @@ static inline int verify_pmr_udp_sport(const uint8_t *pkt_addr, pmr_term_value_t *term_value) { uint16_t sport; - const odph_udphdr_t *udp; + const _odp_udphdr_t *udp;
if (!pkt_hdr->p.input_flags.udp) return 0; - udp = (const odph_udphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); + udp = (const _odp_udphdr_t *)(pkt_addr + pkt_hdr->p.l4_offset); sport = odp_be_to_cpu_16(udp->src_port); if (term_value->match.value == (sport & term_value->match.mask)) return 1; @@ -160,19 +160,19 @@ static inline int verify_pmr_dmac(const uint8_t *pkt_addr, { uint64_t dmac = 0; uint64_t dmac_be = 0; - const odph_ethhdr_t *eth; + const _odp_ethhdr_t *eth;
if (!packet_hdr_has_eth(pkt_hdr)) return 0;
- eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset); - memcpy(&dmac_be, eth->dst.addr, ODPH_ETHADDR_LEN); + eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset); + memcpy(&dmac_be, eth->dst.addr, _ODP_ETHADDR_LEN); dmac = odp_be_to_cpu_64(dmac_be); /* since we are converting a 48 bit ethernet address from BE to cpu format using odp_be_to_cpu_64() the last 16 bits needs to be right shifted */ if (dmac_be != dmac) - dmac = dmac >> (64 - (ODPH_ETHADDR_LEN * 8)); + dmac = dmac >> (64 - (_ODP_ETHADDR_LEN * 8));
if (term_value->match.value == (dmac & term_value->match.mask)) return 1; @@ -220,11 +220,11 @@ static inline int verify_pmr_ipsec_spi(const uint8_t *pkt_addr, pkt_addr += pkt_hdr->p.l4_offset;
if (pkt_hdr->p.input_flags.ipsec_ah) { - const odph_ahhdr_t *ahhdr = (const odph_ahhdr_t *)pkt_addr; + const _odp_ahhdr_t *ahhdr = (const _odp_ahhdr_t *)pkt_addr;
spi = odp_be_to_cpu_32(ahhdr->spi); } else if (pkt_hdr->p.input_flags.ipsec_esp) { - const odph_esphdr_t *esphdr = (const odph_esphdr_t *)pkt_addr; + const _odp_esphdr_t *esphdr = (const _odp_esphdr_t *)pkt_addr;
spi = odp_be_to_cpu_32(esphdr->spi); } else { diff --git a/platform/linux-generic/include/odp_name_table_internal.h b/platform/linux-generic/include/odp_name_table_internal.h index 21ae42d..52b202c 100644 --- a/platform/linux-generic/include/odp_name_table_internal.h +++ b/platform/linux-generic/include/odp_name_table_internal.h @@ -21,7 +21,7 @@ typedef enum { ODP_PKTIO_HANDLE, ODP_POOL_HANDLE, ODP_QUEUE_HANDLE, - ODPH_RING_HANDLE, + ODP_RING_HANDLE, ODP_SHM_HANDLE, ODP_TIMER_POOL_HANDLE, ODP_TM_HANDLE, diff --git a/platform/linux-generic/include/protocols/eth.h b/platform/linux-generic/include/protocols/eth.h new file mode 100644 index 0000000..6d00e7f --- /dev/null +++ b/platform/linux-generic/include/protocols/eth.h @@ -0,0 +1,113 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP ethernet header + */ + +#ifndef ODP_ETH_H_ +#define ODP_ETH_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp_api.h> + +/** @addtogroup odp_header ODP HEADER + * @{ + */ + +#define _ODP_ETHADDR_LEN 6 /**< Ethernet address length */ +#define _ODP_ETHHDR_LEN 14 /**< Ethernet header length */ +#define _ODP_VLANHDR_LEN 4 /**< VLAN header length */ +#define _ODP_ETH_LEN_MIN 60 /**< Min frame length (excl CRC 4 bytes) */ +#define _ODP_ETH_LEN_MIN_CRC 64 /**< Min frame length (incl CRC 4 bytes) */ +#define _ODP_ETH_LEN_MAX 1514 /**< Max frame length (excl CRC 4 bytes) */ +#define _ODP_ETH_LEN_MAX_CRC 1518 /**< Max frame length (incl CRC 4 bytes) */ + +/* The two byte _odp_vlanhdr_t tci field is composed of the following three + * subfields - a three bit Priority Code Point (PCP), a one bit Drop + * Eligibility Indicator (DEI) and a twelve bit VLAN Identifier (VID). The + * following constants can be used to extract or modify these subfields, once + * the tci field has been read in and converted to host byte order. Note + * that the DEI subfield used to be the CFI bit. + */ +#define _ODP_VLANHDR_MAX_PRIO 7 /**< Max value of the 3 bit priority */ +#define _ODP_VLANHDR_PCP_MASK 0xE000 /**< PCP field bit mask */ +#define _ODP_VLANHDR_PCP_SHIFT 13 /**< PCP field shift */ +#define _ODP_VLANHDR_DEI_MASK 0x1000 /**< DEI field bit mask */ +#define _ODP_VLANHDR_DEI_SHIFT 12 /**< DEI field shift */ +#define _ODP_VLANHDR_MAX_VID 0x0FFF /**< Max value of the 12 bit VID field */ +#define _ODP_VLANHDR_VID_MASK 0x0FFF /**< VID field bit mask */ +#define _ODP_VLANHDR_VID_SHIFT 0 /**< VID field shift */ + +/** + * Ethernet MAC address + */ +typedef struct ODP_PACKED { + uint8_t addr[_ODP_ETHADDR_LEN]; /**< @private Address */ +} _odp_ethaddr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_ethaddr_t) == _ODP_ETHADDR_LEN, + "_ODP_ETHADDR_T__SIZE_ERROR"); + +/** + * Ethernet header + */ +typedef struct ODP_PACKED { + _odp_ethaddr_t dst; /**< Destination address */ + _odp_ethaddr_t src; /**< Source address */ + odp_u16be_t type; /**< EtherType */ +} _odp_ethhdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_ethhdr_t) == _ODP_ETHHDR_LEN, + "_ODP_ETHHDR_T__SIZE_ERROR"); + +/** + * IEEE 802.1Q VLAN header + * + * This field is present when the EtherType (the _odp_ethhdr_t type field) of + * the preceding ethernet header is _ODP_ETHTYPE_VLAN. The inner EtherType + * (the _odp_vlanhdr_t type field) then indicates what comes next. Note that + * the so called TPID field isn't here because it overlaps with the + * _odp_ethhdr_t type field. + */ +typedef struct ODP_PACKED { + odp_u16be_t tci; /**< Priority / CFI / VLAN ID */ + odp_u16be_t type; /**< Inner EtherType */ +} _odp_vlanhdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_vlanhdr_t) == _ODP_VLANHDR_LEN, + "_ODP_VLANHDR_T__SIZE_ERROR"); + +/* Ethernet header Ether Type ('type') values, a selected few */ +#define _ODP_ETHTYPE_IPV4 0x0800 /**< Internet Protocol version 4 */ +#define _ODP_ETHTYPE_ARP 0x0806 /**< Address Resolution Protocol */ +#define _ODP_ETHTYPE_RARP 0x8035 /**< Reverse Address Resolution Protocol*/ +#define _ODP_ETHTYPE_VLAN 0x8100 /**< VLAN-tagged frame IEEE 802.1Q */ +#define _ODP_ETHTYPE_VLAN_OUTER 0x88A8 /**< Stacked VLANs/QinQ, outer-tag/S-TAG*/ +#define _ODP_ETHTYPE_IPV6 0x86dd /**< Internet Protocol version 6 */ +#define _ODP_ETHTYPE_FLOW_CTRL 0x8808 /**< Ethernet flow control */ +#define _ODP_ETHTYPE_MPLS 0x8847 /**< MPLS unicast */ +#define _ODP_ETHTYPE_MPLS_MCAST 0x8848 /**< MPLS multicast */ +#define _ODP_ETHTYPE_MACSEC 0x88E5 /**< MAC security IEEE 802.1AE */ +#define _ODP_ETHTYPE_1588 0x88F7 /**< Precision Time Protocol IEEE 1588 */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/protocols/ip.h b/platform/linux-generic/include/protocols/ip.h new file mode 100644 index 0000000..d5277fb --- /dev/null +++ b/platform/linux-generic/include/protocols/ip.h @@ -0,0 +1,168 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP IP header + */ + +#ifndef ODP_IP_H_ +#define ODP_IP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp_api.h> + +/** @addtogroup odp_header ODP HEADER + * @{ + */ + +#define _ODP_IPV4 4 /**< IP version 4 */ +#define _ODP_IPV4HDR_LEN 20 /**< Min length of IP header (no options) */ +#define _ODP_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ +#define _ODP_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ + +/** The one byte IPv4 tos or IPv6 tc field is composed of the following two + * subfields - a six bit Differentiated Service Code Point (DSCP) and a two + * bit Explicit Congestion Notification (ECN) subfield. The following + * constants can be used to extract or modify these fields. Despite the + * name prefix being _ODP_IP_TOS_* these constants apply equally well for + * the IPv6 Traffic Class (tc) field. + */ +#define _ODP_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value 63 */ +#define _ODP_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ +#define _ODP_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by 2 */ +#define _ODP_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value 3 */ +#define _ODP_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ +#define _ODP_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ + +/** The following constants give names to the four possible ECN values, + * as described in RFC 3168. + */ +#define _ODP_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN */ +#define _ODP_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ +#define _ODP_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ +#define _ODP_IP_ECN_CE 3 /**< Used to signal Congestion Experienced */ + +/** @internal Returns IPv4 version */ +#define _ODP_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) + +/** @internal Returns IPv4 header length */ +#define _ODP_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) + +/** @internal Returns IPv4 DSCP */ +#define _ODP_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) + +/** @internal Returns IPv4 Don't fragment */ +#define _ODP_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & 0x4000) + +/** @internal Returns IPv4 more fragments */ +#define _ODP_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & 0x2000) + +/** @internal Returns IPv4 fragment offset */ +#define _ODP_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) + +/** @internal Returns true if IPv4 packet is a fragment */ +#define _ODP_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) + +/** IPv4 header */ +typedef struct ODP_PACKED { + uint8_t ver_ihl; /**< Version / Header length */ + uint8_t tos; /**< Type of service */ + odp_u16be_t tot_len; /**< Total length */ + odp_u16be_t id; /**< ID */ + odp_u16be_t frag_offset;/**< Fragmentation offset */ + uint8_t ttl; /**< Time to live */ + uint8_t proto; /**< Protocol */ + odp_u16sum_t chksum; /**< Checksum */ + odp_u32be_t src_addr; /**< Source address */ + odp_u32be_t dst_addr; /**< Destination address */ +} _odp_ipv4hdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_ipv4hdr_t) == _ODP_IPV4HDR_LEN, + "_ODP_IPV4HDR_T__SIZE_ERROR"); + +/** IPv6 version */ +#define _ODP_IPV6 6 + +/** IPv6 header length */ +#define _ODP_IPV6HDR_LEN 40 + +/** IPv6 address length in bytes */ +#define _ODP_IPV6ADDR_LEN 16 + +/** The following constants can be used to access the three subfields + * of the 4 byte ver_tc_flow field - namely the four bit Version subfield, + * the eight bit Traffic Class subfield (TC) and the twenty bit Flow Label + * subfield. Note that the IPv6 TC field is analogous to the IPv4 TOS + * field and is composed of the DSCP and ECN subfields. Use the _ODP_IP_TOS_* + * constants above to access these subfields. + */ +#define _ODP_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit mask */ +#define _ODP_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift */ +#define _ODP_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ +#define _ODP_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ +#define _ODP_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask */ +#define _ODP_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ + +/** @internal Returns IPv6 DSCP */ +#define _ODP_IPV6HDR_DSCP(ver_tc_flow) \ + (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) + +/** + * IPv6 header + */ +typedef struct ODP_PACKED { + odp_u32be_t ver_tc_flow; /**< Version / Traffic class / Flow label */ + odp_u16be_t payload_len; /**< Payload length */ + uint8_t next_hdr; /**< Next header */ + uint8_t hop_limit; /**< Hop limit */ + uint8_t src_addr[16]; /**< Source address */ + uint8_t dst_addr[16]; /**< Destination address */ +} _odp_ipv6hdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_ipv6hdr_t) == _ODP_IPV6HDR_LEN, + "_ODP_IPV6HDR_T__SIZE_ERROR"); + +/** + * IPv6 Header extensions + */ +typedef struct ODP_PACKED { + uint8_t next_hdr; /**< Protocol of next header */ + uint8_t ext_len; /**< Length of this extension in 8 byte units, + not counting first 8 bytes, so 0 = 8 bytes + 1 = 16 bytes, etc. */ + uint8_t filler[6]; /**< Fill out first 8 byte segment */ +} _odp_ipv6hdr_ext_t; + +/** @name + * IP protocol values (IPv4:'proto' or IPv6:'next_hdr') + * @{*/ +#define _ODP_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */ +#define _ODP_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol (1) */ +#define _ODP_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */ +#define _ODP_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */ +#define _ODP_IPPROTO_ROUTE 0x2B /**< IPv6 Routing header (43) */ +#define _ODP_IPPROTO_FRAG 0x2C /**< IPv6 Fragment (44) */ +#define _ODP_IPPROTO_AH 0x33 /**< Authentication Header (51) */ +#define _ODP_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */ +#define _ODP_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */ + +/**@}*/ + +/** + * @} + */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/protocols/ipsec.h b/platform/linux-generic/include/protocols/ipsec.h new file mode 100644 index 0000000..093177f --- /dev/null +++ b/platform/linux-generic/include/protocols/ipsec.h @@ -0,0 +1,81 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP IPSec headers + */ + +#ifndef ODP_IPSEC_H_ +#define ODP_IPSEC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp_api.h> + +/** @addtogroup odp_header ODP HEADER + * @{ + */ + +#define _ODP_ESPHDR_LEN 8 /**< IPSec ESP header length */ +#define _ODP_ESPTRL_LEN 2 /**< IPSec ESP trailer length */ +#define _ODP_AHHDR_LEN 12 /**< IPSec AH header length */ + +/** + * IPSec ESP header + */ +typedef struct ODP_PACKED { + odp_u32be_t spi; /**< Security Parameter Index */ + odp_u32be_t seq_no; /**< Sequence Number */ + uint8_t iv[0]; /**< Initialization vector */ +} _odp_esphdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_esphdr_t) == _ODP_ESPHDR_LEN, + "_ODP_ESPHDR_T__SIZE_ERROR"); + +/** + * IPSec ESP trailer + */ +typedef struct ODP_PACKED { + uint8_t pad_len; /**< Padding length (0-255) */ + uint8_t next_header; /**< Next header protocol */ + uint8_t icv[0]; /**< Integrity Check Value (optional) */ +} _odp_esptrl_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_esptrl_t) == _ODP_ESPTRL_LEN, + "_ODP_ESPTRL_T__SIZE_ERROR"); + +/** + * IPSec AH header + */ +typedef struct ODP_PACKED { + uint8_t next_header; /**< Next header protocol */ + uint8_t ah_len; /**< AH header length */ + odp_u16be_t pad; /**< Padding (must be 0) */ + odp_u32be_t spi; /**< Security Parameter Index */ + odp_u32be_t seq_no; /**< Sequence Number */ + uint8_t icv[0]; /**< Integrity Check Value */ +} _odp_ahhdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_ahhdr_t) == _ODP_AHHDR_LEN, + "_ODP_AHHDR_T__SIZE_ERROR"); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/protocols/tcp.h b/platform/linux-generic/include/protocols/tcp.h new file mode 100644 index 0000000..4e92e4b --- /dev/null +++ b/platform/linux-generic/include/protocols/tcp.h @@ -0,0 +1,89 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP TCP header + */ + +#ifndef ODP_TCP_H_ +#define ODP_TCP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp_api.h> + +/** @addtogroup odp_header ODP HEADER + * @{ + */ + +#define _ODP_TCPHDR_LEN 20 /**< Min length of TCP header (no options) */ + +/** TCP header */ +typedef struct ODP_PACKED { + odp_u16be_t src_port; /**< Source port */ + odp_u16be_t dst_port; /**< Destination port */ + odp_u32be_t seq_no; /**< Sequence number */ + odp_u32be_t ack_no; /**< Acknowledgment number */ + union { + odp_u16be_t doffset_flags; +#if defined(ODP_BIG_ENDIAN_BITFIELD) + struct { + odp_u16be_t rsvd1:8; + odp_u16be_t flags:8; /**< TCP flags as a byte */ + }; + struct { + odp_u16be_t hl:4; /**< Hdr len, in words */ + odp_u16be_t rsvd3:4; /**< Reserved */ + odp_u16be_t cwr:1; + odp_u16be_t ece:1; + odp_u16be_t urg:1; + odp_u16be_t ack:1; + odp_u16be_t psh:1; + odp_u16be_t rst:1; + odp_u16be_t syn:1; + odp_u16be_t fin:1; + }; +#elif defined(ODP_LITTLE_ENDIAN_BITFIELD) + struct { + odp_u16be_t flags:8; + odp_u16be_t rsvd1:8; /**< TCP flags as a byte */ + }; + struct { + odp_u16be_t rsvd3:4; /**< Reserved */ + odp_u16be_t hl:4; /**< Hdr len, in words */ + odp_u16be_t fin:1; + odp_u16be_t syn:1; + odp_u16be_t rst:1; + odp_u16be_t psh:1; + odp_u16be_t ack:1; + odp_u16be_t urg:1; + odp_u16be_t ece:1; + odp_u16be_t cwr:1; + }; + +#else +#error "Endian BitField order not defined!" +#endif + }; + odp_u16be_t window; /**< Window size */ + odp_u16be_t cksm; /**< Checksum */ + odp_u16be_t urgptr; /**< Urgent pointer */ +} _odp_tcphdr_t; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/protocols/udp.h b/platform/linux-generic/include/protocols/udp.h new file mode 100644 index 0000000..535aba8 --- /dev/null +++ b/platform/linux-generic/include/protocols/udp.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP UDP header + */ + +#ifndef ODP_UDP_H_ +#define ODP_UDP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp_api.h> + +/** @addtogroup odp_header ODP HEADER + * @{ + */ + +/** UDP header length */ +#define _ODP_UDPHDR_LEN 8 + +/** UDP header */ +typedef struct ODP_PACKED { + odp_u16be_t src_port; /**< Source port */ + odp_u16be_t dst_port; /**< Destination port */ + odp_u16be_t length; /**< UDP datagram length in bytes (header+data) */ + odp_u16be_t chksum; /**< UDP header and data checksum (0 if not used)*/ +} _odp_udphdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_udphdr_t) == _ODP_UDPHDR_LEN, + "_ODP_UDPHDR_T__SIZE_ERROR"); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 027a7ce..ea223bf 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -18,7 +18,8 @@ #include <odp_classification_internal.h> #include <odp_pool_internal.h> #include <odp/api/shared_memory.h> -#include <odp/helper/eth.h> +#include <protocols/eth.h> +#include <protocols/ip.h> #include <string.h> #include <errno.h> #include <stdbool.h> @@ -841,16 +842,16 @@ cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr, { uint8_t dscp; cos_t *cos = NULL; - const odph_ipv4hdr_t *ipv4; - const odph_ipv6hdr_t *ipv6; + const _odp_ipv4hdr_t *ipv4; + const _odp_ipv6hdr_t *ipv6;
if (hdr->p.input_flags.l3 && hdr->p.input_flags.ipv4) { - ipv4 = (const odph_ipv4hdr_t *)(pkt_addr + hdr->p.l3_offset); - dscp = ODPH_IPV4HDR_DSCP(ipv4->tos); + ipv4 = (const _odp_ipv4hdr_t *)(pkt_addr + hdr->p.l3_offset); + dscp = _ODP_IPV4HDR_DSCP(ipv4->tos); cos = l3_cos->cos[dscp]; } else if (hdr->p.input_flags.l3 && hdr->p.input_flags.ipv6) { - ipv6 = (const odph_ipv6hdr_t *)(pkt_addr + hdr->p.l3_offset); - dscp = ODPH_IPV6HDR_DSCP(ipv6->ver_tc_flow); + ipv6 = (const _odp_ipv6hdr_t *)(pkt_addr + hdr->p.l3_offset); + dscp = _ODP_IPV6HDR_DSCP(ipv6->ver_tc_flow); cos = l3_cos->cos[dscp]; }
@@ -861,14 +862,14 @@ cos_t *match_qos_l2_cos(pmr_l2_cos_t *l2_cos, const uint8_t *pkt_addr, odp_packet_hdr_t *hdr) { cos_t *cos = NULL; - const odph_ethhdr_t *eth; - const odph_vlanhdr_t *vlan; + const _odp_ethhdr_t *eth; + const _odp_vlanhdr_t *vlan; uint16_t qos;
if (packet_hdr_has_l2(hdr) && hdr->p.input_flags.vlan && packet_hdr_has_eth(hdr)) { - eth = (const odph_ethhdr_t *)(pkt_addr + hdr->p.l2_offset); - vlan = (const odph_vlanhdr_t *)(eth + 1); + eth = (const _odp_ethhdr_t *)(pkt_addr + hdr->p.l2_offset); + vlan = (const _odp_vlanhdr_t *)(eth + 1); qos = odp_be_to_cpu_16(vlan->tci); qos = ((qos >> 13) & 0x07); cos = l2_cos->cos[qos]; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 0a868e9..0e319d2 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -10,10 +10,10 @@ #include <odp/api/hints.h> #include <odp/api/byteorder.h>
-#include <odp/helper/eth.h> -#include <odp/helper/ip.h> -#include <odp/helper/tcp.h> -#include <odp/helper/udp.h> +#include <protocols/eth.h> +#include <protocols/ip.h> +#include <protocols/tcp.h> +#include <protocols/udp.h>
#include <errno.h> #include <string.h> @@ -991,15 +991,15 @@ int _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt) static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, uint32_t *offset, uint32_t frame_len) { - const odph_ipv4hdr_t *ipv4 = (const odph_ipv4hdr_t *)*parseptr; - uint8_t ver = ODPH_IPV4HDR_VER(ipv4->ver_ihl); - uint8_t ihl = ODPH_IPV4HDR_IHL(ipv4->ver_ihl); + const _odp_ipv4hdr_t *ipv4 = (const _odp_ipv4hdr_t *)*parseptr; + uint8_t ver = _ODP_IPV4HDR_VER(ipv4->ver_ihl); + uint8_t ihl = _ODP_IPV4HDR_IHL(ipv4->ver_ihl); uint16_t frag_offset; uint32_t dstaddr = odp_be_to_cpu_32(ipv4->dst_addr);
prs->l3_len = odp_be_to_cpu_16(ipv4->tot_len);
- if (odp_unlikely(ihl < ODPH_IPV4HDR_IHL_MIN) || + if (odp_unlikely(ihl < _ODP_IPV4HDR_IHL_MIN) || odp_unlikely(ver != 4) || (prs->l3_len > frame_len - *offset)) { prs->error_flags.ip_err = 1; @@ -1009,7 +1009,7 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, *offset += ihl * 4; *parseptr += ihl * 4;
- if (odp_unlikely(ihl > ODPH_IPV4HDR_IHL_MIN)) + if (odp_unlikely(ihl > _ODP_IPV4HDR_IHL_MIN)) prs->input_flags.ipopt = 1;
/* A packet is a fragment if: @@ -1018,7 +1018,7 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, * "fragment offset" field is nonzero (all fragments except the first) */ frag_offset = odp_be_to_cpu_16(ipv4->frag_offset); - if (odp_unlikely(ODPH_IPV4HDR_IS_FRAGMENT(frag_offset))) + if (odp_unlikely(_ODP_IPV4HDR_IS_FRAGMENT(frag_offset))) prs->input_flags.ipfrag = 1;
/* Handle IPv4 broadcast / multicast */ @@ -1035,12 +1035,12 @@ static inline uint8_t parse_ipv6(packet_parser_t *prs, const uint8_t **parseptr, uint32_t *offset, uint32_t frame_len, uint32_t seg_len) { - const odph_ipv6hdr_t *ipv6 = (const odph_ipv6hdr_t *)*parseptr; - const odph_ipv6hdr_ext_t *ipv6ext; + const _odp_ipv6hdr_t *ipv6 = (const _odp_ipv6hdr_t *)*parseptr; + const _odp_ipv6hdr_ext_t *ipv6ext; uint32_t dstaddr0 = odp_be_to_cpu_32(ipv6->dst_addr[0]);
prs->l3_len = odp_be_to_cpu_16(ipv6->payload_len) + - ODPH_IPV6HDR_LEN; + _ODP_IPV6HDR_LEN;
/* Basic sanity checks on IPv6 header */ if ((odp_be_to_cpu_32(ipv6->ver_tc_flow) >> 28) != 6 || @@ -1054,22 +1054,22 @@ static inline uint8_t parse_ipv6(packet_parser_t *prs, const uint8_t **parseptr, prs->input_flags.ip_bcast = 0;
/* Skip past IPv6 header */ - *offset += sizeof(odph_ipv6hdr_t); - *parseptr += sizeof(odph_ipv6hdr_t); + *offset += sizeof(_odp_ipv6hdr_t); + *parseptr += sizeof(_odp_ipv6hdr_t);
/* Skip past any IPv6 extension headers */ - if (ipv6->next_hdr == ODPH_IPPROTO_HOPOPTS || - ipv6->next_hdr == ODPH_IPPROTO_ROUTE) { + if (ipv6->next_hdr == _ODP_IPPROTO_HOPOPTS || + ipv6->next_hdr == _ODP_IPPROTO_ROUTE) { prs->input_flags.ipopt = 1;
do { - ipv6ext = (const odph_ipv6hdr_ext_t *)*parseptr; + ipv6ext = (const _odp_ipv6hdr_ext_t *)*parseptr; uint16_t extlen = 8 + ipv6ext->ext_len * 8;
*offset += extlen; *parseptr += extlen; - } while ((ipv6ext->next_hdr == ODPH_IPPROTO_HOPOPTS || - ipv6ext->next_hdr == ODPH_IPPROTO_ROUTE) && + } while ((ipv6ext->next_hdr == _ODP_IPPROTO_HOPOPTS || + ipv6ext->next_hdr == _ODP_IPPROTO_ROUTE) && *offset < seg_len);
if (*offset >= prs->l3_offset + @@ -1078,13 +1078,13 @@ static inline uint8_t parse_ipv6(packet_parser_t *prs, const uint8_t **parseptr, return 0; }
- if (ipv6ext->next_hdr == ODPH_IPPROTO_FRAG) + if (ipv6ext->next_hdr == _ODP_IPPROTO_FRAG) prs->input_flags.ipfrag = 1;
return ipv6ext->next_hdr; }
- if (odp_unlikely(ipv6->next_hdr == ODPH_IPPROTO_FRAG)) { + if (odp_unlikely(ipv6->next_hdr == _ODP_IPPROTO_FRAG)) { prs->input_flags.ipopt = 1; prs->input_flags.ipfrag = 1; } @@ -1098,11 +1098,11 @@ static inline uint8_t parse_ipv6(packet_parser_t *prs, const uint8_t **parseptr, static inline void parse_tcp(packet_parser_t *prs, const uint8_t **parseptr, uint32_t *offset) { - const odph_tcphdr_t *tcp = (const odph_tcphdr_t *)*parseptr; + const _odp_tcphdr_t *tcp = (const _odp_tcphdr_t *)*parseptr;
- if (tcp->hl < sizeof(odph_tcphdr_t) / sizeof(uint32_t)) + if (tcp->hl < sizeof(_odp_tcphdr_t) / sizeof(uint32_t)) prs->error_flags.tcp_err = 1; - else if ((uint32_t)tcp->hl * 4 > sizeof(odph_tcphdr_t)) + else if ((uint32_t)tcp->hl * 4 > sizeof(_odp_tcphdr_t)) prs->input_flags.tcpopt = 1;
prs->l4_len = prs->l3_len + @@ -1119,10 +1119,10 @@ static inline void parse_tcp(packet_parser_t *prs, static inline void parse_udp(packet_parser_t *prs, const uint8_t **parseptr, uint32_t *offset) { - const odph_udphdr_t *udp = (const odph_udphdr_t *)*parseptr; + const _odp_udphdr_t *udp = (const _odp_udphdr_t *)*parseptr; uint32_t udplen = odp_be_to_cpu_16(udp->length);
- if (udplen < sizeof(odph_udphdr_t) || + if (udplen < sizeof(_odp_udphdr_t) || udplen > (prs->l3_len + prs->l4_offset - prs->l3_offset)) { prs->error_flags.udp_err = 1; @@ -1131,8 +1131,8 @@ static inline void parse_udp(packet_parser_t *prs, prs->l4_len = udplen;
if (offset) - *offset += sizeof(odph_udphdr_t); - *parseptr += sizeof(odph_udphdr_t); + *offset += sizeof(_odp_udphdr_t); + *parseptr += sizeof(_odp_udphdr_t); }
/** @@ -1146,7 +1146,7 @@ void packet_parse_l2(packet_parser_t *prs, uint32_t frame_len) prs->input_flags.eth = 1;
/* Detect jumbo frames */ - if (frame_len > ODPH_ETH_LEN_MAX) + if (frame_len > _ODP_ETH_LEN_MAX) prs->input_flags.jumbo = 1;
/* Assume valid L2 header, no CRC/FCS check in SW */ @@ -1164,19 +1164,19 @@ void packet_parse_l2(packet_parser_t *prs, uint32_t frame_len) int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, uint32_t frame_len, uint32_t seg_len) { - const odph_ethhdr_t *eth; - const odph_vlanhdr_t *vlan; + const _odp_ethhdr_t *eth; + const _odp_vlanhdr_t *vlan; uint16_t ethtype; uint32_t offset; uint8_t ip_proto = 0; const uint8_t *parseptr; uint16_t macaddr0, macaddr2, macaddr4;
- offset = sizeof(odph_ethhdr_t); + offset = sizeof(_odp_ethhdr_t); if (packet_parse_l2_not_done(prs)) packet_parse_l2(prs, frame_len);
- eth = (const odph_ethhdr_t *)ptr; + eth = (const _odp_ethhdr_t *)ptr;
/* Handle Ethernet broadcast/multicast addresses */ macaddr0 = odp_be_to_cpu_16(*((const uint16_t *)(const void *)eth)); @@ -1200,7 +1200,7 @@ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, parseptr = (const uint8_t *)(eth + 1);
/* Check for SNAP vs. DIX */ - if (ethtype < ODPH_ETH_LEN_MAX) { + if (ethtype < _ODP_ETH_LEN_MAX) { prs->input_flags.snap = 1; if (ethtype > frame_len - offset) { prs->error_flags.snap_len = 1; @@ -1213,22 +1213,22 @@ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, }
/* Parse the VLAN header(s), if present */ - if (ethtype == ODPH_ETHTYPE_VLAN_OUTER) { + if (ethtype == _ODP_ETHTYPE_VLAN_OUTER) { prs->input_flags.vlan_qinq = 1; prs->input_flags.vlan = 1;
- vlan = (const odph_vlanhdr_t *)parseptr; + vlan = (const _odp_vlanhdr_t *)parseptr; ethtype = odp_be_to_cpu_16(vlan->type); - offset += sizeof(odph_vlanhdr_t); - parseptr += sizeof(odph_vlanhdr_t); + offset += sizeof(_odp_vlanhdr_t); + parseptr += sizeof(_odp_vlanhdr_t); }
- if (ethtype == ODPH_ETHTYPE_VLAN) { + if (ethtype == _ODP_ETHTYPE_VLAN) { prs->input_flags.vlan = 1; - vlan = (const odph_vlanhdr_t *)parseptr; + vlan = (const _odp_vlanhdr_t *)parseptr; ethtype = odp_be_to_cpu_16(vlan->type); - offset += sizeof(odph_vlanhdr_t); - parseptr += sizeof(odph_vlanhdr_t); + offset += sizeof(_odp_vlanhdr_t); + parseptr += sizeof(_odp_vlanhdr_t); }
/* Set l3_offset+flag only for known ethtypes */ @@ -1237,18 +1237,18 @@ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr,
/* Parse Layer 3 headers */ switch (ethtype) { - case ODPH_ETHTYPE_IPV4: + case _ODP_ETHTYPE_IPV4: prs->input_flags.ipv4 = 1; ip_proto = parse_ipv4(prs, &parseptr, &offset, frame_len); break;
- case ODPH_ETHTYPE_IPV6: + case _ODP_ETHTYPE_IPV6: prs->input_flags.ipv6 = 1; ip_proto = parse_ipv6(prs, &parseptr, &offset, frame_len, seg_len); break;
- case ODPH_ETHTYPE_ARP: + case _ODP_ETHTYPE_ARP: prs->input_flags.arp = 1; ip_proto = 255; /* Reserved invalid by IANA */ break; @@ -1265,30 +1265,30 @@ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr,
/* Parse Layer 4 headers */ switch (ip_proto) { - case ODPH_IPPROTO_ICMP: + case _ODP_IPPROTO_ICMP: prs->input_flags.icmp = 1; break;
- case ODPH_IPPROTO_TCP: - if (odp_unlikely(offset + ODPH_TCPHDR_LEN > seg_len)) + case _ODP_IPPROTO_TCP: + if (odp_unlikely(offset + _ODP_TCPHDR_LEN > seg_len)) return -1; prs->input_flags.tcp = 1; parse_tcp(prs, &parseptr, NULL); break;
- case ODPH_IPPROTO_UDP: - if (odp_unlikely(offset + ODPH_UDPHDR_LEN > seg_len)) + case _ODP_IPPROTO_UDP: + if (odp_unlikely(offset + _ODP_UDPHDR_LEN > seg_len)) return -1; prs->input_flags.udp = 1; parse_udp(prs, &parseptr, NULL); break;
- case ODPH_IPPROTO_AH: + case _ODP_IPPROTO_AH: prs->input_flags.ipsec = 1; prs->input_flags.ipsec_ah = 1; break;
- case ODPH_IPPROTO_ESP: + case _ODP_IPPROTO_ESP: prs->input_flags.ipsec = 1; prs->input_flags.ipsec_esp = 1; break; diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 9cfa1fc..aa14b6b 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -19,8 +19,8 @@ #include <unistd.h> #include <pthread.h> #include <odp/api/std_types.h> -#include <odp/helper/eth.h> -#include <odp/helper/ip.h> +#include <protocols/eth.h> +#include <protocols/ip.h> #include <odp_traffic_mngr_internal.h>
/* Local vars */ @@ -1899,14 +1899,14 @@ static int tm_enqueue(tm_system_t *tm_system, static void egress_vlan_marking(tm_vlan_marking_t *vlan_marking, odp_packet_t odp_pkt) { - odph_vlanhdr_t vlan_hdr, *vlan_hdr_ptr; - odph_ethhdr_t *ether_hdr_ptr; + _odp_vlanhdr_t vlan_hdr, *vlan_hdr_ptr; + _odp_ethhdr_t *ether_hdr_ptr; odp_bool_t split_hdr; uint32_t hdr_len; uint16_t old_tci, new_tci;
ether_hdr_ptr = odp_packet_l2_ptr(odp_pkt, &hdr_len); - vlan_hdr_ptr = (odph_vlanhdr_t *)(ether_hdr_ptr + 1); + vlan_hdr_ptr = (_odp_vlanhdr_t *)(ether_hdr_ptr + 1);
/* If the split_hdr variable below is TRUE, then this indicates that * for this odp (output) packet the VLAN header is not all in the same @@ -1915,31 +1915,31 @@ static void egress_vlan_marking(tm_vlan_marking_t *vlan_marking, * handle this case for correctness, but because of the rarity the * code handling this is more optimized for ease of understanding and * correctness rather then performance. */ - split_hdr = hdr_len < (ODPH_ETHHDR_LEN + ODPH_VLANHDR_LEN); + split_hdr = hdr_len < (_ODP_ETHHDR_LEN + _ODP_VLANHDR_LEN); if (split_hdr) { - odp_packet_copy_to_mem(odp_pkt, ODPH_ETHHDR_LEN, - ODPH_VLANHDR_LEN, &vlan_hdr); + odp_packet_copy_to_mem(odp_pkt, _ODP_ETHHDR_LEN, + _ODP_VLANHDR_LEN, &vlan_hdr); vlan_hdr_ptr = &vlan_hdr; }
old_tci = odp_be_to_cpu_16(vlan_hdr_ptr->tci); new_tci = old_tci; if (vlan_marking->drop_eligible_enabled) - new_tci |= ODPH_VLANHDR_DEI_MASK; + new_tci |= _ODP_VLANHDR_DEI_MASK;
if (new_tci == old_tci) return;
vlan_hdr_ptr->tci = odp_cpu_to_be_16(new_tci); if (split_hdr) - odp_packet_copy_from_mem(odp_pkt, ODPH_ETHHDR_LEN, - ODPH_VLANHDR_LEN, &vlan_hdr); + odp_packet_copy_from_mem(odp_pkt, _ODP_ETHHDR_LEN, + _ODP_VLANHDR_LEN, &vlan_hdr); }
static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, odp_packet_t odp_pkt) { - odph_ipv4hdr_t ipv4_hdr, *ipv4_hdr_ptr; + _odp_ipv4hdr_t ipv4_hdr, *ipv4_hdr_ptr; odp_bool_t split_hdr; uint32_t hdr_len, l3_offset, old_chksum, ones_compl_sum, tos_diff; uint8_t old_tos, new_tos, ecn; @@ -1957,7 +1957,7 @@ static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, split_hdr = hdr_len < 12; if (split_hdr) { odp_packet_copy_to_mem(odp_pkt, l3_offset, - ODPH_IPV4HDR_LEN, &ipv4_hdr); + _ODP_IPV4HDR_LEN, &ipv4_hdr); ipv4_hdr_ptr = &ipv4_hdr; }
@@ -1968,10 +1968,10 @@ static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, tos_marking->shifted_dscp;
if (tos_marking->ecn_ce_enabled && odp_packet_has_tcp(odp_pkt)) { - ecn = old_tos & ODPH_IP_TOS_ECN_MASK; - if ((ecn == ODPH_IP_ECN_ECT0) || (ecn == ODPH_IP_ECN_ECT1)) - new_tos = (new_tos & ~ODPH_IP_TOS_ECN_MASK) | - (ODPH_IP_ECN_CE << ODPH_IP_TOS_ECN_SHIFT); + ecn = old_tos & _ODP_IP_TOS_ECN_MASK; + if ((ecn == _ODP_IP_ECN_ECT0) || (ecn == _ODP_IP_ECN_ECT1)) + new_tos = (new_tos & ~_ODP_IP_TOS_ECN_MASK) | + (_ODP_IP_ECN_CE << _ODP_IP_TOS_ECN_SHIFT); }
if (new_tos == old_tos) @@ -1999,13 +1999,13 @@ static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, ipv4_hdr_ptr->chksum = odp_cpu_to_be_16((~ones_compl_sum) & 0xFFFF); if (split_hdr) odp_packet_copy_from_mem(odp_pkt, l3_offset, - ODPH_IPV4HDR_LEN, &ipv4_hdr); + _ODP_IPV4HDR_LEN, &ipv4_hdr); }
static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, odp_packet_t odp_pkt) { - odph_ipv6hdr_t ipv6_hdr, *ipv6_hdr_ptr; + _odp_ipv6hdr_t ipv6_hdr, *ipv6_hdr_ptr; odp_bool_t split_hdr; uint32_t hdr_len, old_ver_tc_flow, new_ver_tc_flow, l3_offset; uint8_t old_tc, new_tc, ecn; @@ -2023,13 +2023,13 @@ static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, split_hdr = hdr_len < 4; if (split_hdr) { odp_packet_copy_to_mem(odp_pkt, l3_offset, - ODPH_IPV6HDR_LEN, &ipv6_hdr); + _ODP_IPV6HDR_LEN, &ipv6_hdr); ipv6_hdr_ptr = &ipv6_hdr; }
old_ver_tc_flow = odp_be_to_cpu_32(ipv6_hdr_ptr->ver_tc_flow); - old_tc = (old_ver_tc_flow & ODPH_IPV6HDR_TC_MASK) - >> ODPH_IPV6HDR_TC_SHIFT; + old_tc = (old_ver_tc_flow & _ODP_IPV6HDR_TC_MASK) + >> _ODP_IPV6HDR_TC_SHIFT; new_tc = old_tc;
if (tos_marking->drop_prec_enabled) @@ -2037,22 +2037,22 @@ static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, tos_marking->shifted_dscp;
if (tos_marking->ecn_ce_enabled && odp_packet_has_tcp(odp_pkt)) { - ecn = old_tc & ODPH_IP_TOS_ECN_MASK; - if ((ecn == ODPH_IP_ECN_ECT0) || (ecn == ODPH_IP_ECN_ECT1)) - new_tc = (new_tc & ~ODPH_IP_TOS_ECN_MASK) | - (ODPH_IP_ECN_CE << ODPH_IP_TOS_ECN_SHIFT); + ecn = old_tc & _ODP_IP_TOS_ECN_MASK; + if ((ecn == _ODP_IP_ECN_ECT0) || (ecn == _ODP_IP_ECN_ECT1)) + new_tc = (new_tc & ~_ODP_IP_TOS_ECN_MASK) | + (_ODP_IP_ECN_CE << _ODP_IP_TOS_ECN_SHIFT); }
if (new_tc == old_tc) return;
- new_ver_tc_flow = (old_ver_tc_flow & ~ODPH_IPV6HDR_TC_MASK) | - (new_tc << ODPH_IPV6HDR_TC_SHIFT); + new_ver_tc_flow = (old_ver_tc_flow & ~_ODP_IPV6HDR_TC_MASK) | + (new_tc << _ODP_IPV6HDR_TC_SHIFT); ipv6_hdr_ptr->ver_tc_flow = odp_cpu_to_be_32(new_ver_tc_flow);
if (split_hdr) odp_packet_copy_from_mem(odp_pkt, l3_offset, - ODPH_IPV6HDR_LEN, &ipv6_hdr); + _ODP_IPV6HDR_LEN, &ipv6_hdr); }
static void tm_egress_marking(tm_system_t *tm_system, odp_packet_t odp_pkt) @@ -2868,9 +2868,9 @@ int odp_tm_drop_prec_marking(odp_tm_t odp_tm, if (drop_prec_enabled) { new_dscp = new_dscp & dscp_mask; inverted_mask = (uint8_t)~dscp_mask; - tos_mask = (inverted_mask << ODPH_IP_TOS_DSCP_SHIFT) | - ODPH_IP_TOS_ECN_MASK; - shifted_dscp = new_dscp << ODPH_IP_TOS_DSCP_SHIFT; + tos_mask = (inverted_mask << _ODP_IP_TOS_DSCP_SHIFT) | + _ODP_IP_TOS_ECN_MASK; + shifted_dscp = new_dscp << _ODP_IP_TOS_DSCP_SHIFT; } else { tos_mask = 0xFF; /* Note that this is an inverted mask */ shifted_dscp = 0; diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 245ff7b..c21c703 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -19,7 +19,7 @@ #include <odp_packet_dpdk.h> #include <odp_debug_internal.h>
-#include <odp/helper/eth.h> +#include <protocols/eth.h>
#include <rte_config.h> #include <rte_mbuf.h> @@ -590,7 +590,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, ODP_ERR("Failed to read interface MTU\n"); return -1; } - pkt_dpdk->mtu = mtu + ODPH_ETHHDR_LEN; + pkt_dpdk->mtu = mtu + _ODP_ETHHDR_LEN;
/* Some DPDK PMD virtual devices, like PCAP, do not support promisc * mode change. Use system call for them. */ diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 1febacd..ac16c41 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -12,8 +12,8 @@ #include <odp_debug_internal.h> #include <odp/api/hints.h>
-#include <odp/helper/eth.h> -#include <odp/helper/ip.h> +#include <protocols/eth.h> +#include <protocols/ip.h>
#include <errno.h> #include <inttypes.h> diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 08e49f4..d69df6b 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -12,7 +12,7 @@ #include <odp_packet_netmap.h> #include <odp_packet_socket.h> #include <odp_debug_internal.h> -#include <odp/helper/eth.h> +#include <protocols/eth.h>
#include <sys/ioctl.h> #include <poll.h> @@ -410,7 +410,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, ODP_ERR("Unable to read interface MTU\n"); goto error; } - mtu += ODPH_ETHHDR_LEN; + mtu += _ODP_ETHHDR_LEN; pkt_nm->mtu = (mtu < buf_size) ? mtu : buf_size;
/* Check if RSS is supported. If not, set 'max_input_queues' to 1. */ @@ -605,7 +605,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, return -1; }
- if (odp_unlikely(len < ODPH_ETH_LEN_MIN)) { + if (odp_unlikely(len < _ODP_ETH_LEN_MIN)) { ODP_ERR("RX: Frame truncated: %" PRIu16 "\n", len); return -1; } diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index 2fb2a5b..be9049a 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -40,7 +40,7 @@ #include <odp_packet_internal.h> #include <odp_packet_io_internal.h>
-#include <odp/helper/eth.h> +#include <protocols/eth.h>
#include <errno.h> #include <pcap/pcap.h> @@ -349,9 +349,9 @@ static uint32_t pcapif_mtu_get(pktio_entry_t *pktio_entry ODP_UNUSED) static int pcapif_mac_addr_get(pktio_entry_t *pktio_entry ODP_UNUSED, void *mac_addr) { - memcpy(mac_addr, pcap_mac, ODPH_ETHADDR_LEN); + memcpy(mac_addr, pcap_mac, _ODP_ETHADDR_LEN);
- return ODPH_ETHADDR_LEN; + return _ODP_ETHADDR_LEN; }
static int pcapif_capability(pktio_entry_t *pktio_entry ODP_UNUSED, diff --git a/platform/linux-generic/pktio/ring.c b/platform/linux-generic/pktio/ring.c index 3024f4a..cc84e8a 100644 --- a/platform/linux-generic/pktio/ring.c +++ b/platform/linux-generic/pktio/ring.c @@ -75,7 +75,6 @@ #include <string.h> #include <stdbool.h> #include <inttypes.h> -#include "odph_debug.h" #include <odp_packet_io_ring_internal.h> #include <odp_internal.h>
@@ -167,9 +166,9 @@ _ring_create(const char *name, unsigned count, unsigned flags)
/* count must be a power of 2 */ if (!RING_VAL_IS_POWER_2(count) || (count > _RING_SZ_MASK)) { - ODPH_ERR("Requested size is invalid, must be power of 2," - "and do not exceed the size limit %u\n", - _RING_SZ_MASK); + ODP_ERR("Requested size is invalid, must be power of 2," + "and do not exceed the size limit %u\n", + _RING_SZ_MASK); __odp_errno = EINVAL; return NULL; } @@ -204,7 +203,7 @@ _ring_create(const char *name, unsigned count, unsigned flags) TAILQ_INSERT_TAIL(&odp_ring_list, r, next); } else { __odp_errno = ENOMEM; - ODPH_ERR("Cannot reserve memory\n"); + ODP_ERR("Cannot reserve memory\n"); }
odp_rwlock_write_unlock(&qlock); diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 8f86dda..5d85ef5 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -43,8 +43,8 @@ #include <odp_classification_internal.h> #include <odp/api/hints.h>
-#include <odp/helper/eth.h> -#include <odp/helper/ip.h> +#include <protocols/eth.h> +#include <protocols/ip.h>
static int sock_stats_reset(pktio_entry_t *pktio_entry);
@@ -84,8 +84,8 @@ int sendmmsg(int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) /** Eth buffer start offset from u32-aligned address to make sure the following * header (e.g. IP) starts at a 32-bit aligned address. */ -#define ETHBUF_OFFSET (ODP_ALIGN_ROUNDUP(ODPH_ETHHDR_LEN, sizeof(uint32_t)) \ - - ODPH_ETHHDR_LEN) +#define ETHBUF_OFFSET (ODP_ALIGN_ROUNDUP(_ODP_ETHHDR_LEN, sizeof(uint32_t)) \ + - _ODP_ETHHDR_LEN)
/** Round up buffer address to get a properly aliged eth buffer, i.e. aligned * so that the next header always starts at a 32bit aligned address. diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 420cd26..11bb7d6 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -32,8 +32,8 @@ #include <odp_classification_internal.h> #include <odp/api/hints.h>
-#include <odp/helper/eth.h> -#include <odp/helper/ip.h> +#include <protocols/eth.h> +#include <protocols/ip.h>
static int set_pkt_sock_fanout_mmap(pkt_sock_mmap_t *const pkt_sock, int sock_group_idx) @@ -115,8 +115,8 @@ static uint8_t *pkt_mmap_vlan_insert(uint8_t *l2_hdr_ptr, uint16_t vlan_tci, int *pkt_len_ptr) { - odph_ethhdr_t *eth_hdr; - odph_vlanhdr_t *vlan_hdr; + _odp_ethhdr_t *eth_hdr; + _odp_vlanhdr_t *vlan_hdr; uint8_t *new_l2_ptr; int orig_pkt_len;
@@ -124,17 +124,17 @@ static uint8_t *pkt_mmap_vlan_insert(uint8_t *l2_hdr_ptr, * shifting the Ethernet header down to open up space for the IEEE * 802.1Q vlan header. */ - if (ODPH_VLANHDR_LEN < mac_offset) { + if (_ODP_VLANHDR_LEN < mac_offset) { orig_pkt_len = *pkt_len_ptr; - new_l2_ptr = l2_hdr_ptr - ODPH_VLANHDR_LEN; - memmove(new_l2_ptr, l2_hdr_ptr, ODPH_ETHHDR_LEN); + new_l2_ptr = l2_hdr_ptr - _ODP_VLANHDR_LEN; + memmove(new_l2_ptr, l2_hdr_ptr, _ODP_ETHHDR_LEN);
- eth_hdr = (odph_ethhdr_t *)new_l2_ptr; - vlan_hdr = (odph_vlanhdr_t *)(new_l2_ptr + ODPH_ETHHDR_LEN); + eth_hdr = (_odp_ethhdr_t *)new_l2_ptr; + vlan_hdr = (_odp_vlanhdr_t *)(new_l2_ptr + _ODP_ETHHDR_LEN); vlan_hdr->tci = odp_cpu_to_be_16(vlan_tci); vlan_hdr->type = eth_hdr->type; - eth_hdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN); - *pkt_len_ptr = orig_pkt_len + ODPH_VLANHDR_LEN; + eth_hdr->type = odp_cpu_to_be_16(_ODP_ETHTYPE_VLAN); + *pkt_len_ptr = orig_pkt_len + _ODP_VLANHDR_LEN; return new_l2_ptr; }
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/Makefile.am | 7 +- .../include/odp_classification_inlines.h | 50 +++--- .../include/odp_name_table_internal.h | 2 +- platform/linux-generic/include/protocols/eth.h | 113 ++++++++++++++ platform/linux-generic/include/protocols/ip.h | 168 +++++++++++++++++++++ .../linux-generic/include/protocols}/ipsec.h | 40 ++--- .../linux-generic/include/protocols}/tcp.h | 12 +- platform/linux-generic/include/protocols/udp.h | 49 ++++++ platform/linux-generic/odp_classification.c | 23 +-- platform/linux-generic/odp_packet.c | 106 ++++++------- platform/linux-generic/odp_traffic_mngr.c | 64 ++++---- platform/linux-generic/pktio/dpdk.c | 4 +- platform/linux-generic/pktio/loop.c | 4 +- platform/linux-generic/pktio/netmap.c | 6 +- platform/linux-generic/pktio/pcap.c | 6 +- platform/linux-generic/pktio/ring.c | 9 +- platform/linux-generic/pktio/socket.c | 8 +- platform/linux-generic/pktio/socket_mmap.c | 22 +-- 18 files changed, 513 insertions(+), 180 deletions(-) create mode 100644 platform/linux-generic/include/protocols/eth.h create mode 100644 platform/linux-generic/include/protocols/ip.h copy {helper/include/odp/helper => platform/linux-generic/include/protocols}/ipsec.h (53%) copy {helper/include/odp/helper => platform/linux-generic/include/protocols}/tcp.h (88%) create mode 100644 platform/linux-generic/include/protocols/udp.h
hooks/post-receive