Message ID | 1466478817-29469-1-git-send-email-yi.he@linaro.org |
---|---|
State | Superseded |
Headers | show |
This looks good to me. Needs to have "RFC" removed. On Mon, Jun 20, 2016 at 10:13 PM, Yi He <yi.he@linaro.org> wrote: > 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> > --- > v2 changes the names to _odp_* for internal namespace. > > platform/linux-generic/Makefile.am | 7 +- > .../include/odp_classification_inlines.h | 50 +++--- > .../include/odp_name_table_internal.h | 2 +- > .../linux-generic/include/protocols}/eth.h | 111 ++++++------- > .../linux-generic/include/protocols}/ip.h | 180 > ++++++--------------- > .../linux-generic/include/protocols}/ipsec.h | 40 ++--- > .../linux-generic/include/protocols}/tcp.h | 12 +- > .../linux-generic/include/protocols}/udp.h | 34 +--- > 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, 291 insertions(+), 397 deletions(-) > copy {helper/include/odp/helper => > platform/linux-generic/include/protocols}/eth.h (30%) > copy {helper/include/odp/helper => > platform/linux-generic/include/protocols}/ip.h (41%) > 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%) > copy {helper/include/odp/helper => > platform/linux-generic/include/protocols}/udp.h (47%) > > 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/helper/include/odp/helper/eth.h > b/platform/linux-generic/include/protocols/eth.h > similarity index 30% > copy from helper/include/odp/helper/eth.h > copy to platform/linux-generic/include/protocols/eth.h > index 9f47ddf..6d00e7f 100644 > --- a/helper/include/odp/helper/eth.h > +++ b/platform/linux-generic/include/protocols/eth.h > @@ -1,4 +1,4 @@ > -/* Copyright (c) 2014, Linaro Limited > +/* Copyright (c) 2016, Linaro Limited > * All rights reserved. > * > * SPDX-License-Identifier: BSD-3-Clause > @@ -10,8 +10,8 @@ > * ODP ethernet header > */ > > -#ifndef ODPH_ETH_H_ > -#define ODPH_ETH_H_ > +#ifndef ODP_ETH_H_ > +#define ODP_ETH_H_ > > #ifdef __cplusplus > extern "C" { > @@ -19,105 +19,88 @@ extern "C" { > > #include <odp_api.h> > > -/** @addtogroup odph_header ODPH HEADER > +/** @addtogroup odp_header ODP HEADER > * @{ > */ > > -#define ODPH_ETHADDR_LEN 6 /**< Ethernet address length */ > -#define ODPH_ETHHDR_LEN 14 /**< Ethernet header length */ > -#define ODPH_VLANHDR_LEN 4 /**< VLAN header length */ > -#define ODPH_ETH_LEN_MIN 60 /**< Min frame length (excl CRC 4 > bytes) */ > -#define ODPH_ETH_LEN_MIN_CRC 64 /**< Min frame length (incl CRC 4 > bytes) */ > -#define ODPH_ETH_LEN_MAX 1514 /**< Max frame length (excl CRC 4 > bytes) */ > -#define ODPH_ETH_LEN_MAX_CRC 1518 /**< Max frame length (incl CRC 4 > bytes) */ > +#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 odph_vlanhdr_t tci field is composed of the following > three > +/* 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 ODPH_VLANHDR_MAX_PRIO 7 /**< Max value of the 3 bit > priority */ > -#define ODPH_VLANHDR_PCP_MASK 0xE000 /**< PCP field bit mask */ > -#define ODPH_VLANHDR_PCP_SHIFT 13 /**< PCP field shift */ > -#define ODPH_VLANHDR_DEI_MASK 0x1000 /**< DEI field bit mask */ > -#define ODPH_VLANHDR_DEI_SHIFT 12 /**< DEI field shift */ > -#define ODPH_VLANHDR_MAX_VID 0x0FFF /**< Max value of the 12 bit VID > field */ > -#define ODPH_VLANHDR_VID_MASK 0x0FFF /**< VID field bit mask */ > -#define ODPH_VLANHDR_VID_SHIFT 0 /**< VID field shift */ > +#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[ODPH_ETHADDR_LEN]; /**< @private Address */ > -} odph_ethaddr_t; > + uint8_t addr[_ODP_ETHADDR_LEN]; /**< @private Address */ > +} _odp_ethaddr_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, > - "ODPH_ETHADDR_T__SIZE_ERROR"); > +ODP_STATIC_ASSERT(sizeof(_odp_ethaddr_t) == _ODP_ETHADDR_LEN, > + "_ODP_ETHADDR_T__SIZE_ERROR"); > > /** > * Ethernet header > */ > typedef struct ODP_PACKED { > - odph_ethaddr_t dst; /**< Destination address */ > - odph_ethaddr_t src; /**< Source address */ > + _odp_ethaddr_t dst; /**< Destination address */ > + _odp_ethaddr_t src; /**< Source address */ > odp_u16be_t type; /**< EtherType */ > -} odph_ethhdr_t; > +} _odp_ethhdr_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, > - "ODPH_ETHHDR_T__SIZE_ERROR"); > +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 odph_ethhdr_t type > field) of > - * the preceding ethernet header is ODPH_ETHTYPE_VLAN. The inner > EtherType > - * (the odph_vlanhdr_t type field) then indicates what comes next. Note > that > + * 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 > - * odph_ethhdr_t type field. > + * _odp_ethhdr_t type field. > */ > typedef struct ODP_PACKED { > odp_u16be_t tci; /**< Priority / CFI / VLAN ID */ > odp_u16be_t type; /**< Inner EtherType */ > -} odph_vlanhdr_t; > +} _odp_vlanhdr_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, > - "ODPH_VLANHDR_T__SIZE_ERROR"); > +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 ODPH_ETHTYPE_IPV4 0x0800 /**< Internet Protocol version 4 */ > -#define ODPH_ETHTYPE_ARP 0x0806 /**< Address Resolution Protocol */ > -#define ODPH_ETHTYPE_RARP 0x8035 /**< Reverse Address Resolution > Protocol*/ > -#define ODPH_ETHTYPE_VLAN 0x8100 /**< VLAN-tagged frame IEEE 802.1Q > */ > -#define ODPH_ETHTYPE_VLAN_OUTER 0x88A8 /**< Stacked VLANs/QinQ, > outer-tag/S-TAG*/ > -#define ODPH_ETHTYPE_IPV6 0x86dd /**< Internet Protocol version 6 */ > -#define ODPH_ETHTYPE_FLOW_CTRL 0x8808 /**< Ethernet flow control */ > -#define ODPH_ETHTYPE_MPLS 0x8847 /**< MPLS unicast */ > -#define ODPH_ETHTYPE_MPLS_MCAST 0x8848 /**< MPLS multicast */ > -#define ODPH_ETHTYPE_MACSEC 0x88E5 /**< MAC security IEEE 802.1AE */ > -#define ODPH_ETHTYPE_1588 0x88F7 /**< Precision Time Protocol IEEE > 1588 */ > - > -/** > - * Parse Ethernet from a string > - * > - * Parses Ethernet MAC address from the string which must be passed in > format of > - * six hexadecimal digits delimited by colons (xx:xx:xx:xx:xx:xx). Both > upper > - * and lower case characters are supported. All six digits have to be > present > - * and may have leading zeros. String does not have to be NULL terminated. > - * The address is written only when successful. > - * > - * @param[out] mac Pointer to Ethernet address for output > - * @param str MAC address string to be parsed > - * > - * @retval 0 on success > - * @retval <0 on failure > - */ > -int odph_eth_addr_parse(odph_ethaddr_t *mac, const char *str); > +#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 */ > > /** > * @} > diff --git a/helper/include/odp/helper/ip.h > b/platform/linux-generic/include/protocols/ip.h > similarity index 41% > copy from helper/include/odp/helper/ip.h > copy to platform/linux-generic/include/protocols/ip.h > index 4cfc00f..d5277fb 100644 > --- a/helper/include/odp/helper/ip.h > +++ b/platform/linux-generic/include/protocols/ip.h > @@ -1,4 +1,4 @@ > -/* Copyright (c) 2014, Linaro Limited > +/* Copyright (c) 2016, Linaro Limited > * All rights reserved. > * > * SPDX-License-Identifier: BSD-3-Clause > @@ -10,69 +10,66 @@ > * ODP IP header > */ > > -#ifndef ODPH_IP_H_ > -#define ODPH_IP_H_ > +#ifndef ODP_IP_H_ > +#define ODP_IP_H_ > > #ifdef __cplusplus > extern "C" { > #endif > > #include <odp_api.h> > -#include <odp/helper/chksum.h> > > -#include <string.h> > - > -/** @addtogroup odph_header ODPH HEADER > +/** @addtogroup odp_header ODP HEADER > * @{ > */ > > -#define ODPH_IPV4 4 /**< IP version 4 */ > -#define ODPH_IPV4HDR_LEN 20 /**< Min length of IP header (no > options) */ > -#define ODPH_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ > -#define ODPH_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ > +#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 ODPH_IP_TOS_* these constants apply equally well for > + * name prefix being _ODP_IP_TOS_* these constants apply equally well for > * the IPv6 Traffic Class (tc) field. > */ > -#define ODPH_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value > 63 */ > -#define ODPH_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ > -#define ODPH_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by > 2 */ > -#define ODPH_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value > 3 */ > -#define ODPH_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ > -#define ODPH_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ > +#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 ODPH_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN > */ > -#define ODPH_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ > -#define ODPH_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ > -#define ODPH_IP_ECN_CE 3 /**< Used to signal Congestion > Experienced */ > +#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 ODPH_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) > +#define _ODP_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) > > /** @internal Returns IPv4 header length */ > -#define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) > +#define _ODP_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) > > /** @internal Returns IPv4 DSCP */ > -#define ODPH_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) > +#define _ODP_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) > > /** @internal Returns IPv4 Don't fragment */ > -#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & > 0x4000) > +#define _ODP_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & > 0x4000) > > /** @internal Returns IPv4 more fragments */ > -#define ODPH_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & > 0x2000) > +#define _ODP_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & > 0x2000) > > /** @internal Returns IPv4 fragment offset */ > -#define ODPH_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) > +#define _ODP_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) > > /** @internal Returns true if IPv4 packet is a fragment */ > -#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) > +#define _ODP_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) > > /** IPv4 header */ > typedef struct ODP_PACKED { > @@ -86,91 +83,37 @@ typedef struct ODP_PACKED { > odp_u16sum_t chksum; /**< Checksum */ > odp_u32be_t src_addr; /**< Source address */ > odp_u32be_t dst_addr; /**< Destination address */ > -} odph_ipv4hdr_t; > +} _odp_ipv4hdr_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, > - "ODPH_IPV4HDR_T__SIZE_ERROR"); > - > -/** > - * Check if IPv4 checksum is valid > - * > - * @param pkt ODP packet > - * > - * @return 1 if checksum is valid, otherwise 0 > - */ > -static inline int odph_ipv4_csum_valid(odp_packet_t pkt) > -{ > - odp_u16be_t res = 0; > - uint16_t *w; > - int nleft = sizeof(odph_ipv4hdr_t); > - odph_ipv4hdr_t ip; > - odp_u16be_t chksum; > - > - if (!odp_packet_l3_offset(pkt)) > - return 0; > - > - odp_packet_copy_to_mem(pkt, odp_packet_l3_offset(pkt), > - sizeof(odph_ipv4hdr_t), &ip); > - > - w = (uint16_t *)(void *)&ip; > - chksum = ip.chksum; > - ip.chksum = 0x0; > - > - res = odph_chksum(w, nleft); > - return (res == chksum) ? 1 : 0; > -} > - > -/** > - * Calculate and fill in IPv4 checksum > - * > - * @note when using this api to populate data destined for the wire > - * odp_cpu_to_be_16() can be used to remove sparse warnings > - * > - * @param pkt ODP packet > - * > - * @return IPv4 checksum in host cpu order, or 0 on failure > - */ > -static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) > -{ > - uint16_t *w; > - odph_ipv4hdr_t *ip; > - int nleft = sizeof(odph_ipv4hdr_t); > - > - if (!odp_packet_l3_offset(pkt)) > - return 0; > - > - ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); > - w = (uint16_t *)(void *)ip; > - ip->chksum = odph_chksum(w, nleft); > - return ip->chksum; > -} > +ODP_STATIC_ASSERT(sizeof(_odp_ipv4hdr_t) == _ODP_IPV4HDR_LEN, > + "_ODP_IPV4HDR_T__SIZE_ERROR"); > > /** IPv6 version */ > -#define ODPH_IPV6 6 > +#define _ODP_IPV6 6 > > /** IPv6 header length */ > -#define ODPH_IPV6HDR_LEN 40 > +#define _ODP_IPV6HDR_LEN 40 > > /** IPv6 address length in bytes */ > -#define ODPH_IPV6ADDR_LEN 16 > +#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 > ODPH_IP_TOS_* > + * field and is composed of the DSCP and ECN subfields. Use the > _ODP_IP_TOS_* > * constants above to access these subfields. > */ > -#define ODPH_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit > mask */ > -#define ODPH_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift > */ > -#define ODPH_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ > -#define ODPH_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ > -#define ODPH_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask > */ > -#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ > +#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 ODPH_IPV6HDR_DSCP(ver_tc_flow) \ > +#define _ODP_IPV6HDR_DSCP(ver_tc_flow) \ > (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) > > /** > @@ -183,11 +126,11 @@ typedef struct ODP_PACKED { > uint8_t hop_limit; /**< Hop limit */ > uint8_t src_addr[16]; /**< Source address */ > uint8_t dst_addr[16]; /**< Destination address */ > -} odph_ipv6hdr_t; > +} _odp_ipv6hdr_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, > - "ODPH_IPV6HDR_T__SIZE_ERROR"); > +ODP_STATIC_ASSERT(sizeof(_odp_ipv6hdr_t) == _ODP_IPV6HDR_LEN, > + "_ODP_IPV6HDR_T__SIZE_ERROR"); > > /** > * IPv6 Header extensions > @@ -198,41 +141,24 @@ typedef struct ODP_PACKED { > not counting first 8 bytes, so 0 = 8 > bytes > 1 = 16 bytes, etc. */ > uint8_t filler[6]; /**< Fill out first 8 byte segment */ > -} odph_ipv6hdr_ext_t; > +} _odp_ipv6hdr_ext_t; > > /** @name > * IP protocol values (IPv4:'proto' or IPv6:'next_hdr') > * @{*/ > -#define ODPH_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */ > -#define ODPH_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol > (1) */ > -#define ODPH_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) > */ > -#define ODPH_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */ > -#define ODPH_IPPROTO_ROUTE 0x2B /**< IPv6 Routing header (43) */ > -#define ODPH_IPPROTO_FRAG 0x2C /**< IPv6 Fragment (44) */ > -#define ODPH_IPPROTO_AH 0x33 /**< Authentication Header (51) */ > -#define ODPH_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload > (50) */ > -#define ODPH_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */ > +#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 */ > > /**@}*/ > > /** > - * Parse IPv4 address from a string > - * > - * Parses IPv4 address from the string which must be passed in the format > of > - * four decimal digits delimited by dots (xxx.xxx.xxx.xxx). All four > digits > - * have to be present and may have leading zeros. String does not have to > be > - * NULL terminated. The address is written only when successful. The > address > - * byte order is CPU native. > - * > - * @param[out] ip_addr Pointer to IPv4 address for output (in native > endian) > - * @param str IPv4 address string to be parsed > - * > - * @retval 0 on success > - * @retval <0 on failure > - */ > -int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str); > - > -/** > * @} > */ > #ifdef __cplusplus > diff --git a/helper/include/odp/helper/ipsec.h > b/platform/linux-generic/include/protocols/ipsec.h > similarity index 53% > copy from helper/include/odp/helper/ipsec.h > copy to platform/linux-generic/include/protocols/ipsec.h > index 034a341..093177f 100644 > --- a/helper/include/odp/helper/ipsec.h > +++ b/platform/linux-generic/include/protocols/ipsec.h > @@ -1,4 +1,4 @@ > -/* Copyright (c) 2014, Linaro Limited > +/* Copyright (c) 2016, Linaro Limited > * All rights reserved. > * > * SPDX-License-Identifier: BSD-3-Clause > @@ -11,8 +11,8 @@ > * ODP IPSec headers > */ > > -#ifndef ODPH_IPSEC_H_ > -#define ODPH_IPSEC_H_ > +#ifndef ODP_IPSEC_H_ > +#define ODP_IPSEC_H_ > > #ifdef __cplusplus > extern "C" { > @@ -20,13 +20,13 @@ extern "C" { > > #include <odp_api.h> > > -/** @addtogroup odph_header ODPH HEADER > +/** @addtogroup odp_header ODP HEADER > * @{ > */ > > -#define ODPH_ESPHDR_LEN 8 /**< IPSec ESP header length */ > -#define ODPH_ESPTRL_LEN 2 /**< IPSec ESP trailer length */ > -#define ODPH_AHHDR_LEN 12 /**< IPSec AH header length */ > +#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 > @@ -34,12 +34,12 @@ extern "C" { > typedef struct ODP_PACKED { > odp_u32be_t spi; /**< Security Parameter Index */ > odp_u32be_t seq_no; /**< Sequence Number */ > - uint8_t iv[0]; /**< Initialization vector */ > -} odph_esphdr_t; > + uint8_t iv[0]; /**< Initialization vector */ > +} _odp_esphdr_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, > - "ODPH_ESPHDR_T__SIZE_ERROR"); > +ODP_STATIC_ASSERT(sizeof(_odp_esphdr_t) == _ODP_ESPHDR_LEN, > + "_ODP_ESPHDR_T__SIZE_ERROR"); > > /** > * IPSec ESP trailer > @@ -48,27 +48,27 @@ 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) */ > -} odph_esptrl_t; > +} _odp_esptrl_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN, > - "ODPH_ESPTRL_T__SIZE_ERROR"); > +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 */ > + 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 */ > -} odph_ahhdr_t; > + uint8_t icv[0]; /**< Integrity Check Value */ > +} _odp_ahhdr_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_ahhdr_t) == ODPH_AHHDR_LEN, > - "ODPH_AHHDR_T__SIZE_ERROR"); > +ODP_STATIC_ASSERT(sizeof(_odp_ahhdr_t) == _ODP_AHHDR_LEN, > + "_ODP_AHHDR_T__SIZE_ERROR"); > > /** > * @} > diff --git a/helper/include/odp/helper/tcp.h > b/platform/linux-generic/include/protocols/tcp.h > similarity index 88% > copy from helper/include/odp/helper/tcp.h > copy to platform/linux-generic/include/protocols/tcp.h > index cabef90..4e92e4b 100644 > --- a/helper/include/odp/helper/tcp.h > +++ b/platform/linux-generic/include/protocols/tcp.h > @@ -1,4 +1,4 @@ > -/* Copyright (c) 2014, Linaro Limited > +/* Copyright (c) 2016, Linaro Limited > * All rights reserved. > * > * SPDX-License-Identifier: BSD-3-Clause > @@ -11,8 +11,8 @@ > * ODP TCP header > */ > > -#ifndef ODPH_TCP_H_ > -#define ODPH_TCP_H_ > +#ifndef ODP_TCP_H_ > +#define ODP_TCP_H_ > > #ifdef __cplusplus > extern "C" { > @@ -20,11 +20,11 @@ extern "C" { > > #include <odp_api.h> > > -/** @addtogroup odph_header ODPH HEADER > +/** @addtogroup odp_header ODP HEADER > * @{ > */ > > -#define ODPH_TCPHDR_LEN 20 /**< Min length of TCP header (no options) */ > +#define _ODP_TCPHDR_LEN 20 /**< Min length of TCP header (no options) */ > > /** TCP header */ > typedef struct ODP_PACKED { > @@ -76,7 +76,7 @@ typedef struct ODP_PACKED { > odp_u16be_t window; /**< Window size */ > odp_u16be_t cksm; /**< Checksum */ > odp_u16be_t urgptr; /**< Urgent pointer */ > -} odph_tcphdr_t; > +} _odp_tcphdr_t; > > /** > * @} > diff --git a/helper/include/odp/helper/udp.h > b/platform/linux-generic/include/protocols/udp.h > similarity index 47% > copy from helper/include/odp/helper/udp.h > copy to platform/linux-generic/include/protocols/udp.h > index 1ba2dff..535aba8 100644 > --- a/helper/include/odp/helper/udp.h > +++ b/platform/linux-generic/include/protocols/udp.h > @@ -1,4 +1,4 @@ > -/* Copyright (c) 2014, Linaro Limited > +/* Copyright (c) 2016, Linaro Limited > * All rights reserved. > * > * SPDX-License-Identifier: BSD-3-Clause > @@ -10,22 +10,21 @@ > * ODP UDP header > */ > > -#ifndef ODPH_UDP_H_ > -#define ODPH_UDP_H_ > +#ifndef ODP_UDP_H_ > +#define ODP_UDP_H_ > > #ifdef __cplusplus > extern "C" { > #endif > > #include <odp_api.h> > -#include <odp/helper/chksum.h> > > -/** @addtogroup odph_header ODPH HEADER > +/** @addtogroup odp_header ODP HEADER > * @{ > */ > > /** UDP header length */ > -#define ODPH_UDPHDR_LEN 8 > +#define _ODP_UDPHDR_LEN 8 > > /** UDP header */ > typedef struct ODP_PACKED { > @@ -33,28 +32,11 @@ typedef struct ODP_PACKED { > 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)*/ > -} odph_udphdr_t; > - > -/** > - * UDP checksum > - * > - * This function calculates the UDP checksum given an odp packet. > - * > - * @param pkt calculate chksum for pkt > - * @return checksum value in BE endianness > - */ > -static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt) > -{ > - uint16_t chksum; > - int rc; > - > - rc = odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_RETURN, &chksum); > - return (rc == 0) ? chksum : 0; > -} > +} _odp_udphdr_t; > > /** @internal Compile time assert */ > -ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN, > - "ODPH_UDPHDR_T__SIZE_ERROR"); > +ODP_STATIC_ASSERT(sizeof(_odp_udphdr_t) == _ODP_UDPHDR_LEN, > + "_ODP_UDPHDR_T__SIZE_ERROR"); > > /** > * @} > diff --git a/platform/linux-generic/odp_classification.c > b/platform/linux-generic/odp_classification.c > index 0602a62..f567afe 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 <odp/api/spinlock.h> > @@ -840,16 +841,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]; > } > > @@ -860,14 +861,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 c319833..5f72985 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> > @@ -995,15 +995,15 @@ void _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; > @@ -1013,7 +1013,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: > @@ -1022,7 +1022,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 */ > @@ -1039,12 +1039,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 || > @@ -1058,22 +1058,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 + > @@ -1082,13 +1082,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; > } > @@ -1102,11 +1102,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 + > @@ -1123,10 +1123,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; > @@ -1135,8 +1135,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); > } > > /** > @@ -1150,7 +1150,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 */ > @@ -1168,19 +1168,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)); > @@ -1204,7 +1204,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; > @@ -1217,22 +1217,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 */ > @@ -1241,18 +1241,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; > @@ -1269,30 +1269,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 1fa2d27..b85accb 100644 > --- a/platform/linux-generic/odp_traffic_mngr.c > +++ b/platform/linux-generic/odp_traffic_mngr.c > @@ -17,8 +17,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 */ > @@ -1897,14 +1897,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 > @@ -1913,31 +1913,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; > @@ -1955,7 +1955,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; > } > > @@ -1966,10 +1966,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) > @@ -1997,13 +1997,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; > @@ -2021,13 +2021,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) > @@ -2035,22 +2035,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) > @@ -2866,9 +2866,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 dce33e5..26523f1 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> > > diff --git a/platform/linux-generic/pktio/netmap.c > b/platform/linux-generic/pktio/netmap.c > index 847250b..1728bb2 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> > @@ -408,7 +408,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. > */ > @@ -603,7 +603,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 ec27f2c..517e876 100644 > --- a/platform/linux-generic/pktio/ring.c > +++ b/platform/linux-generic/pktio/ring.c > @@ -73,7 +73,6 @@ > #include <fcntl.h> > #include <stdio.h> > #include <string.h> > -#include "odph_debug.h" > #include <odp_packet_io_ring_internal.h> > #include <odp_internal.h> > > @@ -165,9 +164,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; > } > @@ -202,7 +201,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; > } > > -- > 2.7.4 > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp >
On 07/04/16 03:51, Bill Fischofer wrote: > This looks good to me. Needs to have "RFC" removed. > Yi, please resend patches with Bill's review included. Thank you, Maxim. > On Mon, Jun 20, 2016 at 10:13 PM, Yi He <yi.he@linaro.org> wrote: > >> 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> > > >> --- >> v2 changes the names to _odp_* for internal namespace. >> >> platform/linux-generic/Makefile.am | 7 +- >> .../include/odp_classification_inlines.h | 50 +++--- >> .../include/odp_name_table_internal.h | 2 +- >> .../linux-generic/include/protocols}/eth.h | 111 ++++++------- >> .../linux-generic/include/protocols}/ip.h | 180 >> ++++++--------------- >> .../linux-generic/include/protocols}/ipsec.h | 40 ++--- >> .../linux-generic/include/protocols}/tcp.h | 12 +- >> .../linux-generic/include/protocols}/udp.h | 34 +--- >> 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, 291 insertions(+), 397 deletions(-) >> copy {helper/include/odp/helper => >> platform/linux-generic/include/protocols}/eth.h (30%) >> copy {helper/include/odp/helper => >> platform/linux-generic/include/protocols}/ip.h (41%) >> 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%) >> copy {helper/include/odp/helper => >> platform/linux-generic/include/protocols}/udp.h (47%) >> >> 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/helper/include/odp/helper/eth.h >> b/platform/linux-generic/include/protocols/eth.h >> similarity index 30% >> copy from helper/include/odp/helper/eth.h >> copy to platform/linux-generic/include/protocols/eth.h >> index 9f47ddf..6d00e7f 100644 >> --- a/helper/include/odp/helper/eth.h >> +++ b/platform/linux-generic/include/protocols/eth.h >> @@ -1,4 +1,4 @@ >> -/* Copyright (c) 2014, Linaro Limited >> +/* Copyright (c) 2016, Linaro Limited >> * All rights reserved. >> * >> * SPDX-License-Identifier: BSD-3-Clause >> @@ -10,8 +10,8 @@ >> * ODP ethernet header >> */ >> >> -#ifndef ODPH_ETH_H_ >> -#define ODPH_ETH_H_ >> +#ifndef ODP_ETH_H_ >> +#define ODP_ETH_H_ >> >> #ifdef __cplusplus >> extern "C" { >> @@ -19,105 +19,88 @@ extern "C" { >> >> #include <odp_api.h> >> >> -/** @addtogroup odph_header ODPH HEADER >> +/** @addtogroup odp_header ODP HEADER >> * @{ >> */ >> >> -#define ODPH_ETHADDR_LEN 6 /**< Ethernet address length */ >> -#define ODPH_ETHHDR_LEN 14 /**< Ethernet header length */ >> -#define ODPH_VLANHDR_LEN 4 /**< VLAN header length */ >> -#define ODPH_ETH_LEN_MIN 60 /**< Min frame length (excl CRC 4 >> bytes) */ >> -#define ODPH_ETH_LEN_MIN_CRC 64 /**< Min frame length (incl CRC 4 >> bytes) */ >> -#define ODPH_ETH_LEN_MAX 1514 /**< Max frame length (excl CRC 4 >> bytes) */ >> -#define ODPH_ETH_LEN_MAX_CRC 1518 /**< Max frame length (incl CRC 4 >> bytes) */ >> +#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 odph_vlanhdr_t tci field is composed of the following >> three >> +/* 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 ODPH_VLANHDR_MAX_PRIO 7 /**< Max value of the 3 bit >> priority */ >> -#define ODPH_VLANHDR_PCP_MASK 0xE000 /**< PCP field bit mask */ >> -#define ODPH_VLANHDR_PCP_SHIFT 13 /**< PCP field shift */ >> -#define ODPH_VLANHDR_DEI_MASK 0x1000 /**< DEI field bit mask */ >> -#define ODPH_VLANHDR_DEI_SHIFT 12 /**< DEI field shift */ >> -#define ODPH_VLANHDR_MAX_VID 0x0FFF /**< Max value of the 12 bit VID >> field */ >> -#define ODPH_VLANHDR_VID_MASK 0x0FFF /**< VID field bit mask */ >> -#define ODPH_VLANHDR_VID_SHIFT 0 /**< VID field shift */ >> +#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[ODPH_ETHADDR_LEN]; /**< @private Address */ >> -} odph_ethaddr_t; >> + uint8_t addr[_ODP_ETHADDR_LEN]; /**< @private Address */ >> +} _odp_ethaddr_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, >> - "ODPH_ETHADDR_T__SIZE_ERROR"); >> +ODP_STATIC_ASSERT(sizeof(_odp_ethaddr_t) == _ODP_ETHADDR_LEN, >> + "_ODP_ETHADDR_T__SIZE_ERROR"); >> >> /** >> * Ethernet header >> */ >> typedef struct ODP_PACKED { >> - odph_ethaddr_t dst; /**< Destination address */ >> - odph_ethaddr_t src; /**< Source address */ >> + _odp_ethaddr_t dst; /**< Destination address */ >> + _odp_ethaddr_t src; /**< Source address */ >> odp_u16be_t type; /**< EtherType */ >> -} odph_ethhdr_t; >> +} _odp_ethhdr_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, >> - "ODPH_ETHHDR_T__SIZE_ERROR"); >> +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 odph_ethhdr_t type >> field) of >> - * the preceding ethernet header is ODPH_ETHTYPE_VLAN. The inner >> EtherType >> - * (the odph_vlanhdr_t type field) then indicates what comes next. Note >> that >> + * 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 >> - * odph_ethhdr_t type field. >> + * _odp_ethhdr_t type field. >> */ >> typedef struct ODP_PACKED { >> odp_u16be_t tci; /**< Priority / CFI / VLAN ID */ >> odp_u16be_t type; /**< Inner EtherType */ >> -} odph_vlanhdr_t; >> +} _odp_vlanhdr_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, >> - "ODPH_VLANHDR_T__SIZE_ERROR"); >> +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 ODPH_ETHTYPE_IPV4 0x0800 /**< Internet Protocol version 4 */ >> -#define ODPH_ETHTYPE_ARP 0x0806 /**< Address Resolution Protocol */ >> -#define ODPH_ETHTYPE_RARP 0x8035 /**< Reverse Address Resolution >> Protocol*/ >> -#define ODPH_ETHTYPE_VLAN 0x8100 /**< VLAN-tagged frame IEEE 802.1Q >> */ >> -#define ODPH_ETHTYPE_VLAN_OUTER 0x88A8 /**< Stacked VLANs/QinQ, >> outer-tag/S-TAG*/ >> -#define ODPH_ETHTYPE_IPV6 0x86dd /**< Internet Protocol version 6 */ >> -#define ODPH_ETHTYPE_FLOW_CTRL 0x8808 /**< Ethernet flow control */ >> -#define ODPH_ETHTYPE_MPLS 0x8847 /**< MPLS unicast */ >> -#define ODPH_ETHTYPE_MPLS_MCAST 0x8848 /**< MPLS multicast */ >> -#define ODPH_ETHTYPE_MACSEC 0x88E5 /**< MAC security IEEE 802.1AE */ >> -#define ODPH_ETHTYPE_1588 0x88F7 /**< Precision Time Protocol IEEE >> 1588 */ >> - >> -/** >> - * Parse Ethernet from a string >> - * >> - * Parses Ethernet MAC address from the string which must be passed in >> format of >> - * six hexadecimal digits delimited by colons (xx:xx:xx:xx:xx:xx). Both >> upper >> - * and lower case characters are supported. All six digits have to be >> present >> - * and may have leading zeros. String does not have to be NULL terminated. >> - * The address is written only when successful. >> - * >> - * @param[out] mac Pointer to Ethernet address for output >> - * @param str MAC address string to be parsed >> - * >> - * @retval 0 on success >> - * @retval <0 on failure >> - */ >> -int odph_eth_addr_parse(odph_ethaddr_t *mac, const char *str); >> +#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 */ >> >> /** >> * @} >> diff --git a/helper/include/odp/helper/ip.h >> b/platform/linux-generic/include/protocols/ip.h >> similarity index 41% >> copy from helper/include/odp/helper/ip.h >> copy to platform/linux-generic/include/protocols/ip.h >> index 4cfc00f..d5277fb 100644 >> --- a/helper/include/odp/helper/ip.h >> +++ b/platform/linux-generic/include/protocols/ip.h >> @@ -1,4 +1,4 @@ >> -/* Copyright (c) 2014, Linaro Limited >> +/* Copyright (c) 2016, Linaro Limited >> * All rights reserved. >> * >> * SPDX-License-Identifier: BSD-3-Clause >> @@ -10,69 +10,66 @@ >> * ODP IP header >> */ >> >> -#ifndef ODPH_IP_H_ >> -#define ODPH_IP_H_ >> +#ifndef ODP_IP_H_ >> +#define ODP_IP_H_ >> >> #ifdef __cplusplus >> extern "C" { >> #endif >> >> #include <odp_api.h> >> -#include <odp/helper/chksum.h> >> >> -#include <string.h> >> - >> -/** @addtogroup odph_header ODPH HEADER >> +/** @addtogroup odp_header ODP HEADER >> * @{ >> */ >> >> -#define ODPH_IPV4 4 /**< IP version 4 */ >> -#define ODPH_IPV4HDR_LEN 20 /**< Min length of IP header (no >> options) */ >> -#define ODPH_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ >> -#define ODPH_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ >> +#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 ODPH_IP_TOS_* these constants apply equally well for >> + * name prefix being _ODP_IP_TOS_* these constants apply equally well for >> * the IPv6 Traffic Class (tc) field. >> */ >> -#define ODPH_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value >> 63 */ >> -#define ODPH_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ >> -#define ODPH_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by >> 2 */ >> -#define ODPH_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value >> 3 */ >> -#define ODPH_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ >> -#define ODPH_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ >> +#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 ODPH_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN >> */ >> -#define ODPH_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ >> -#define ODPH_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ >> -#define ODPH_IP_ECN_CE 3 /**< Used to signal Congestion >> Experienced */ >> +#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 ODPH_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) >> +#define _ODP_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) >> >> /** @internal Returns IPv4 header length */ >> -#define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) >> +#define _ODP_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) >> >> /** @internal Returns IPv4 DSCP */ >> -#define ODPH_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) >> +#define _ODP_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) >> >> /** @internal Returns IPv4 Don't fragment */ >> -#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & >> 0x4000) >> +#define _ODP_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & >> 0x4000) >> >> /** @internal Returns IPv4 more fragments */ >> -#define ODPH_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & >> 0x2000) >> +#define _ODP_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & >> 0x2000) >> >> /** @internal Returns IPv4 fragment offset */ >> -#define ODPH_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) >> +#define _ODP_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) >> >> /** @internal Returns true if IPv4 packet is a fragment */ >> -#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) >> +#define _ODP_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) >> >> /** IPv4 header */ >> typedef struct ODP_PACKED { >> @@ -86,91 +83,37 @@ typedef struct ODP_PACKED { >> odp_u16sum_t chksum; /**< Checksum */ >> odp_u32be_t src_addr; /**< Source address */ >> odp_u32be_t dst_addr; /**< Destination address */ >> -} odph_ipv4hdr_t; >> +} _odp_ipv4hdr_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, >> - "ODPH_IPV4HDR_T__SIZE_ERROR"); >> - >> -/** >> - * Check if IPv4 checksum is valid >> - * >> - * @param pkt ODP packet >> - * >> - * @return 1 if checksum is valid, otherwise 0 >> - */ >> -static inline int odph_ipv4_csum_valid(odp_packet_t pkt) >> -{ >> - odp_u16be_t res = 0; >> - uint16_t *w; >> - int nleft = sizeof(odph_ipv4hdr_t); >> - odph_ipv4hdr_t ip; >> - odp_u16be_t chksum; >> - >> - if (!odp_packet_l3_offset(pkt)) >> - return 0; >> - >> - odp_packet_copy_to_mem(pkt, odp_packet_l3_offset(pkt), >> - sizeof(odph_ipv4hdr_t), &ip); >> - >> - w = (uint16_t *)(void *)&ip; >> - chksum = ip.chksum; >> - ip.chksum = 0x0; >> - >> - res = odph_chksum(w, nleft); >> - return (res == chksum) ? 1 : 0; >> -} >> - >> -/** >> - * Calculate and fill in IPv4 checksum >> - * >> - * @note when using this api to populate data destined for the wire >> - * odp_cpu_to_be_16() can be used to remove sparse warnings >> - * >> - * @param pkt ODP packet >> - * >> - * @return IPv4 checksum in host cpu order, or 0 on failure >> - */ >> -static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) >> -{ >> - uint16_t *w; >> - odph_ipv4hdr_t *ip; >> - int nleft = sizeof(odph_ipv4hdr_t); >> - >> - if (!odp_packet_l3_offset(pkt)) >> - return 0; >> - >> - ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); >> - w = (uint16_t *)(void *)ip; >> - ip->chksum = odph_chksum(w, nleft); >> - return ip->chksum; >> -} >> +ODP_STATIC_ASSERT(sizeof(_odp_ipv4hdr_t) == _ODP_IPV4HDR_LEN, >> + "_ODP_IPV4HDR_T__SIZE_ERROR"); >> >> /** IPv6 version */ >> -#define ODPH_IPV6 6 >> +#define _ODP_IPV6 6 >> >> /** IPv6 header length */ >> -#define ODPH_IPV6HDR_LEN 40 >> +#define _ODP_IPV6HDR_LEN 40 >> >> /** IPv6 address length in bytes */ >> -#define ODPH_IPV6ADDR_LEN 16 >> +#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 >> ODPH_IP_TOS_* >> + * field and is composed of the DSCP and ECN subfields. Use the >> _ODP_IP_TOS_* >> * constants above to access these subfields. >> */ >> -#define ODPH_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit >> mask */ >> -#define ODPH_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift >> */ >> -#define ODPH_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ >> -#define ODPH_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ >> -#define ODPH_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask >> */ >> -#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ >> +#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 ODPH_IPV6HDR_DSCP(ver_tc_flow) \ >> +#define _ODP_IPV6HDR_DSCP(ver_tc_flow) \ >> (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) >> >> /** >> @@ -183,11 +126,11 @@ typedef struct ODP_PACKED { >> uint8_t hop_limit; /**< Hop limit */ >> uint8_t src_addr[16]; /**< Source address */ >> uint8_t dst_addr[16]; /**< Destination address */ >> -} odph_ipv6hdr_t; >> +} _odp_ipv6hdr_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, >> - "ODPH_IPV6HDR_T__SIZE_ERROR"); >> +ODP_STATIC_ASSERT(sizeof(_odp_ipv6hdr_t) == _ODP_IPV6HDR_LEN, >> + "_ODP_IPV6HDR_T__SIZE_ERROR"); >> >> /** >> * IPv6 Header extensions >> @@ -198,41 +141,24 @@ typedef struct ODP_PACKED { >> not counting first 8 bytes, so 0 = 8 >> bytes >> 1 = 16 bytes, etc. */ >> uint8_t filler[6]; /**< Fill out first 8 byte segment */ >> -} odph_ipv6hdr_ext_t; >> +} _odp_ipv6hdr_ext_t; >> >> /** @name >> * IP protocol values (IPv4:'proto' or IPv6:'next_hdr') >> * @{*/ >> -#define ODPH_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */ >> -#define ODPH_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol >> (1) */ >> -#define ODPH_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) >> */ >> -#define ODPH_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */ >> -#define ODPH_IPPROTO_ROUTE 0x2B /**< IPv6 Routing header (43) */ >> -#define ODPH_IPPROTO_FRAG 0x2C /**< IPv6 Fragment (44) */ >> -#define ODPH_IPPROTO_AH 0x33 /**< Authentication Header (51) */ >> -#define ODPH_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload >> (50) */ >> -#define ODPH_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */ >> +#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 */ >> >> /**@}*/ >> >> /** >> - * Parse IPv4 address from a string >> - * >> - * Parses IPv4 address from the string which must be passed in the format >> of >> - * four decimal digits delimited by dots (xxx.xxx.xxx.xxx). All four >> digits >> - * have to be present and may have leading zeros. String does not have to >> be >> - * NULL terminated. The address is written only when successful. The >> address >> - * byte order is CPU native. >> - * >> - * @param[out] ip_addr Pointer to IPv4 address for output (in native >> endian) >> - * @param str IPv4 address string to be parsed >> - * >> - * @retval 0 on success >> - * @retval <0 on failure >> - */ >> -int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str); >> - >> -/** >> * @} >> */ >> #ifdef __cplusplus >> diff --git a/helper/include/odp/helper/ipsec.h >> b/platform/linux-generic/include/protocols/ipsec.h >> similarity index 53% >> copy from helper/include/odp/helper/ipsec.h >> copy to platform/linux-generic/include/protocols/ipsec.h >> index 034a341..093177f 100644 >> --- a/helper/include/odp/helper/ipsec.h >> +++ b/platform/linux-generic/include/protocols/ipsec.h >> @@ -1,4 +1,4 @@ >> -/* Copyright (c) 2014, Linaro Limited >> +/* Copyright (c) 2016, Linaro Limited >> * All rights reserved. >> * >> * SPDX-License-Identifier: BSD-3-Clause >> @@ -11,8 +11,8 @@ >> * ODP IPSec headers >> */ >> >> -#ifndef ODPH_IPSEC_H_ >> -#define ODPH_IPSEC_H_ >> +#ifndef ODP_IPSEC_H_ >> +#define ODP_IPSEC_H_ >> >> #ifdef __cplusplus >> extern "C" { >> @@ -20,13 +20,13 @@ extern "C" { >> >> #include <odp_api.h> >> >> -/** @addtogroup odph_header ODPH HEADER >> +/** @addtogroup odp_header ODP HEADER >> * @{ >> */ >> >> -#define ODPH_ESPHDR_LEN 8 /**< IPSec ESP header length */ >> -#define ODPH_ESPTRL_LEN 2 /**< IPSec ESP trailer length */ >> -#define ODPH_AHHDR_LEN 12 /**< IPSec AH header length */ >> +#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 >> @@ -34,12 +34,12 @@ extern "C" { >> typedef struct ODP_PACKED { >> odp_u32be_t spi; /**< Security Parameter Index */ >> odp_u32be_t seq_no; /**< Sequence Number */ >> - uint8_t iv[0]; /**< Initialization vector */ >> -} odph_esphdr_t; >> + uint8_t iv[0]; /**< Initialization vector */ >> +} _odp_esphdr_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, >> - "ODPH_ESPHDR_T__SIZE_ERROR"); >> +ODP_STATIC_ASSERT(sizeof(_odp_esphdr_t) == _ODP_ESPHDR_LEN, >> + "_ODP_ESPHDR_T__SIZE_ERROR"); >> >> /** >> * IPSec ESP trailer >> @@ -48,27 +48,27 @@ 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) */ >> -} odph_esptrl_t; >> +} _odp_esptrl_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN, >> - "ODPH_ESPTRL_T__SIZE_ERROR"); >> +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 */ >> + 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 */ >> -} odph_ahhdr_t; >> + uint8_t icv[0]; /**< Integrity Check Value */ >> +} _odp_ahhdr_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_ahhdr_t) == ODPH_AHHDR_LEN, >> - "ODPH_AHHDR_T__SIZE_ERROR"); >> +ODP_STATIC_ASSERT(sizeof(_odp_ahhdr_t) == _ODP_AHHDR_LEN, >> + "_ODP_AHHDR_T__SIZE_ERROR"); >> >> /** >> * @} >> diff --git a/helper/include/odp/helper/tcp.h >> b/platform/linux-generic/include/protocols/tcp.h >> similarity index 88% >> copy from helper/include/odp/helper/tcp.h >> copy to platform/linux-generic/include/protocols/tcp.h >> index cabef90..4e92e4b 100644 >> --- a/helper/include/odp/helper/tcp.h >> +++ b/platform/linux-generic/include/protocols/tcp.h >> @@ -1,4 +1,4 @@ >> -/* Copyright (c) 2014, Linaro Limited >> +/* Copyright (c) 2016, Linaro Limited >> * All rights reserved. >> * >> * SPDX-License-Identifier: BSD-3-Clause >> @@ -11,8 +11,8 @@ >> * ODP TCP header >> */ >> >> -#ifndef ODPH_TCP_H_ >> -#define ODPH_TCP_H_ >> +#ifndef ODP_TCP_H_ >> +#define ODP_TCP_H_ >> >> #ifdef __cplusplus >> extern "C" { >> @@ -20,11 +20,11 @@ extern "C" { >> >> #include <odp_api.h> >> >> -/** @addtogroup odph_header ODPH HEADER >> +/** @addtogroup odp_header ODP HEADER >> * @{ >> */ >> >> -#define ODPH_TCPHDR_LEN 20 /**< Min length of TCP header (no options) */ >> +#define _ODP_TCPHDR_LEN 20 /**< Min length of TCP header (no options) */ >> >> /** TCP header */ >> typedef struct ODP_PACKED { >> @@ -76,7 +76,7 @@ typedef struct ODP_PACKED { >> odp_u16be_t window; /**< Window size */ >> odp_u16be_t cksm; /**< Checksum */ >> odp_u16be_t urgptr; /**< Urgent pointer */ >> -} odph_tcphdr_t; >> +} _odp_tcphdr_t; >> >> /** >> * @} >> diff --git a/helper/include/odp/helper/udp.h >> b/platform/linux-generic/include/protocols/udp.h >> similarity index 47% >> copy from helper/include/odp/helper/udp.h >> copy to platform/linux-generic/include/protocols/udp.h >> index 1ba2dff..535aba8 100644 >> --- a/helper/include/odp/helper/udp.h >> +++ b/platform/linux-generic/include/protocols/udp.h >> @@ -1,4 +1,4 @@ >> -/* Copyright (c) 2014, Linaro Limited >> +/* Copyright (c) 2016, Linaro Limited >> * All rights reserved. >> * >> * SPDX-License-Identifier: BSD-3-Clause >> @@ -10,22 +10,21 @@ >> * ODP UDP header >> */ >> >> -#ifndef ODPH_UDP_H_ >> -#define ODPH_UDP_H_ >> +#ifndef ODP_UDP_H_ >> +#define ODP_UDP_H_ >> >> #ifdef __cplusplus >> extern "C" { >> #endif >> >> #include <odp_api.h> >> -#include <odp/helper/chksum.h> >> >> -/** @addtogroup odph_header ODPH HEADER >> +/** @addtogroup odp_header ODP HEADER >> * @{ >> */ >> >> /** UDP header length */ >> -#define ODPH_UDPHDR_LEN 8 >> +#define _ODP_UDPHDR_LEN 8 >> >> /** UDP header */ >> typedef struct ODP_PACKED { >> @@ -33,28 +32,11 @@ typedef struct ODP_PACKED { >> 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)*/ >> -} odph_udphdr_t; >> - >> -/** >> - * UDP checksum >> - * >> - * This function calculates the UDP checksum given an odp packet. >> - * >> - * @param pkt calculate chksum for pkt >> - * @return checksum value in BE endianness >> - */ >> -static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt) >> -{ >> - uint16_t chksum; >> - int rc; >> - >> - rc = odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_RETURN, &chksum); >> - return (rc == 0) ? chksum : 0; >> -} >> +} _odp_udphdr_t; >> >> /** @internal Compile time assert */ >> -ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN, >> - "ODPH_UDPHDR_T__SIZE_ERROR"); >> +ODP_STATIC_ASSERT(sizeof(_odp_udphdr_t) == _ODP_UDPHDR_LEN, >> + "_ODP_UDPHDR_T__SIZE_ERROR"); >> >> /** >> * @} >> diff --git a/platform/linux-generic/odp_classification.c >> b/platform/linux-generic/odp_classification.c >> index 0602a62..f567afe 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 <odp/api/spinlock.h> >> @@ -840,16 +841,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]; >> } >> >> @@ -860,14 +861,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 c319833..5f72985 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> >> @@ -995,15 +995,15 @@ void _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; >> @@ -1013,7 +1013,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: >> @@ -1022,7 +1022,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 */ >> @@ -1039,12 +1039,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 || >> @@ -1058,22 +1058,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 + >> @@ -1082,13 +1082,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; >> } >> @@ -1102,11 +1102,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 + >> @@ -1123,10 +1123,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; >> @@ -1135,8 +1135,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); >> } >> >> /** >> @@ -1150,7 +1150,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 */ >> @@ -1168,19 +1168,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)); >> @@ -1204,7 +1204,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; >> @@ -1217,22 +1217,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 */ >> @@ -1241,18 +1241,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; >> @@ -1269,30 +1269,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 1fa2d27..b85accb 100644 >> --- a/platform/linux-generic/odp_traffic_mngr.c >> +++ b/platform/linux-generic/odp_traffic_mngr.c >> @@ -17,8 +17,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 */ >> @@ -1897,14 +1897,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 >> @@ -1913,31 +1913,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; >> @@ -1955,7 +1955,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; >> } >> >> @@ -1966,10 +1966,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) >> @@ -1997,13 +1997,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; >> @@ -2021,13 +2021,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) >> @@ -2035,22 +2035,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) >> @@ -2866,9 +2866,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 dce33e5..26523f1 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> >> >> diff --git a/platform/linux-generic/pktio/netmap.c >> b/platform/linux-generic/pktio/netmap.c >> index 847250b..1728bb2 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> >> @@ -408,7 +408,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. >> */ >> @@ -603,7 +603,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 ec27f2c..517e876 100644 >> --- a/platform/linux-generic/pktio/ring.c >> +++ b/platform/linux-generic/pktio/ring.c >> @@ -73,7 +73,6 @@ >> #include <fcntl.h> >> #include <stdio.h> >> #include <string.h> >> -#include "odph_debug.h" >> #include <odp_packet_io_ring_internal.h> >> #include <odp_internal.h> >> >> @@ -165,9 +164,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; >> } >> @@ -202,7 +201,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; >> } >> >> -- >> 2.7.4 >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> https://lists.linaro.org/mailman/listinfo/lng-odp >> > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp
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/helper/include/odp/helper/eth.h b/platform/linux-generic/include/protocols/eth.h similarity index 30% copy from helper/include/odp/helper/eth.h copy to platform/linux-generic/include/protocols/eth.h index 9f47ddf..6d00e7f 100644 --- a/helper/include/odp/helper/eth.h +++ b/platform/linux-generic/include/protocols/eth.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, Linaro Limited +/* Copyright (c) 2016, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -10,8 +10,8 @@ * ODP ethernet header */ -#ifndef ODPH_ETH_H_ -#define ODPH_ETH_H_ +#ifndef ODP_ETH_H_ +#define ODP_ETH_H_ #ifdef __cplusplus extern "C" { @@ -19,105 +19,88 @@ extern "C" { #include <odp_api.h> -/** @addtogroup odph_header ODPH HEADER +/** @addtogroup odp_header ODP HEADER * @{ */ -#define ODPH_ETHADDR_LEN 6 /**< Ethernet address length */ -#define ODPH_ETHHDR_LEN 14 /**< Ethernet header length */ -#define ODPH_VLANHDR_LEN 4 /**< VLAN header length */ -#define ODPH_ETH_LEN_MIN 60 /**< Min frame length (excl CRC 4 bytes) */ -#define ODPH_ETH_LEN_MIN_CRC 64 /**< Min frame length (incl CRC 4 bytes) */ -#define ODPH_ETH_LEN_MAX 1514 /**< Max frame length (excl CRC 4 bytes) */ -#define ODPH_ETH_LEN_MAX_CRC 1518 /**< Max frame length (incl CRC 4 bytes) */ +#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 odph_vlanhdr_t tci field is composed of the following three +/* 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 ODPH_VLANHDR_MAX_PRIO 7 /**< Max value of the 3 bit priority */ -#define ODPH_VLANHDR_PCP_MASK 0xE000 /**< PCP field bit mask */ -#define ODPH_VLANHDR_PCP_SHIFT 13 /**< PCP field shift */ -#define ODPH_VLANHDR_DEI_MASK 0x1000 /**< DEI field bit mask */ -#define ODPH_VLANHDR_DEI_SHIFT 12 /**< DEI field shift */ -#define ODPH_VLANHDR_MAX_VID 0x0FFF /**< Max value of the 12 bit VID field */ -#define ODPH_VLANHDR_VID_MASK 0x0FFF /**< VID field bit mask */ -#define ODPH_VLANHDR_VID_SHIFT 0 /**< VID field shift */ +#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[ODPH_ETHADDR_LEN]; /**< @private Address */ -} odph_ethaddr_t; + uint8_t addr[_ODP_ETHADDR_LEN]; /**< @private Address */ +} _odp_ethaddr_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, - "ODPH_ETHADDR_T__SIZE_ERROR"); +ODP_STATIC_ASSERT(sizeof(_odp_ethaddr_t) == _ODP_ETHADDR_LEN, + "_ODP_ETHADDR_T__SIZE_ERROR"); /** * Ethernet header */ typedef struct ODP_PACKED { - odph_ethaddr_t dst; /**< Destination address */ - odph_ethaddr_t src; /**< Source address */ + _odp_ethaddr_t dst; /**< Destination address */ + _odp_ethaddr_t src; /**< Source address */ odp_u16be_t type; /**< EtherType */ -} odph_ethhdr_t; +} _odp_ethhdr_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, - "ODPH_ETHHDR_T__SIZE_ERROR"); +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 odph_ethhdr_t type field) of - * the preceding ethernet header is ODPH_ETHTYPE_VLAN. The inner EtherType - * (the odph_vlanhdr_t type field) then indicates what comes next. Note that + * 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 - * odph_ethhdr_t type field. + * _odp_ethhdr_t type field. */ typedef struct ODP_PACKED { odp_u16be_t tci; /**< Priority / CFI / VLAN ID */ odp_u16be_t type; /**< Inner EtherType */ -} odph_vlanhdr_t; +} _odp_vlanhdr_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, - "ODPH_VLANHDR_T__SIZE_ERROR"); +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 ODPH_ETHTYPE_IPV4 0x0800 /**< Internet Protocol version 4 */ -#define ODPH_ETHTYPE_ARP 0x0806 /**< Address Resolution Protocol */ -#define ODPH_ETHTYPE_RARP 0x8035 /**< Reverse Address Resolution Protocol*/ -#define ODPH_ETHTYPE_VLAN 0x8100 /**< VLAN-tagged frame IEEE 802.1Q */ -#define ODPH_ETHTYPE_VLAN_OUTER 0x88A8 /**< Stacked VLANs/QinQ, outer-tag/S-TAG*/ -#define ODPH_ETHTYPE_IPV6 0x86dd /**< Internet Protocol version 6 */ -#define ODPH_ETHTYPE_FLOW_CTRL 0x8808 /**< Ethernet flow control */ -#define ODPH_ETHTYPE_MPLS 0x8847 /**< MPLS unicast */ -#define ODPH_ETHTYPE_MPLS_MCAST 0x8848 /**< MPLS multicast */ -#define ODPH_ETHTYPE_MACSEC 0x88E5 /**< MAC security IEEE 802.1AE */ -#define ODPH_ETHTYPE_1588 0x88F7 /**< Precision Time Protocol IEEE 1588 */ - -/** - * Parse Ethernet from a string - * - * Parses Ethernet MAC address from the string which must be passed in format of - * six hexadecimal digits delimited by colons (xx:xx:xx:xx:xx:xx). Both upper - * and lower case characters are supported. All six digits have to be present - * and may have leading zeros. String does not have to be NULL terminated. - * The address is written only when successful. - * - * @param[out] mac Pointer to Ethernet address for output - * @param str MAC address string to be parsed - * - * @retval 0 on success - * @retval <0 on failure - */ -int odph_eth_addr_parse(odph_ethaddr_t *mac, const char *str); +#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 */ /** * @} diff --git a/helper/include/odp/helper/ip.h b/platform/linux-generic/include/protocols/ip.h similarity index 41% copy from helper/include/odp/helper/ip.h copy to platform/linux-generic/include/protocols/ip.h index 4cfc00f..d5277fb 100644 --- a/helper/include/odp/helper/ip.h +++ b/platform/linux-generic/include/protocols/ip.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, Linaro Limited +/* Copyright (c) 2016, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -10,69 +10,66 @@ * ODP IP header */ -#ifndef ODPH_IP_H_ -#define ODPH_IP_H_ +#ifndef ODP_IP_H_ +#define ODP_IP_H_ #ifdef __cplusplus extern "C" { #endif #include <odp_api.h> -#include <odp/helper/chksum.h> -#include <string.h> - -/** @addtogroup odph_header ODPH HEADER +/** @addtogroup odp_header ODP HEADER * @{ */ -#define ODPH_IPV4 4 /**< IP version 4 */ -#define ODPH_IPV4HDR_LEN 20 /**< Min length of IP header (no options) */ -#define ODPH_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ -#define ODPH_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ +#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 ODPH_IP_TOS_* these constants apply equally well for + * name prefix being _ODP_IP_TOS_* these constants apply equally well for * the IPv6 Traffic Class (tc) field. */ -#define ODPH_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value 63 */ -#define ODPH_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ -#define ODPH_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by 2 */ -#define ODPH_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value 3 */ -#define ODPH_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ -#define ODPH_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ +#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 ODPH_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN */ -#define ODPH_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ -#define ODPH_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ -#define ODPH_IP_ECN_CE 3 /**< Used to signal Congestion Experienced */ +#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 ODPH_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) +#define _ODP_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) /** @internal Returns IPv4 header length */ -#define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) +#define _ODP_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) /** @internal Returns IPv4 DSCP */ -#define ODPH_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) +#define _ODP_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) /** @internal Returns IPv4 Don't fragment */ -#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & 0x4000) +#define _ODP_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & 0x4000) /** @internal Returns IPv4 more fragments */ -#define ODPH_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & 0x2000) +#define _ODP_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & 0x2000) /** @internal Returns IPv4 fragment offset */ -#define ODPH_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) +#define _ODP_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) /** @internal Returns true if IPv4 packet is a fragment */ -#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) +#define _ODP_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) /** IPv4 header */ typedef struct ODP_PACKED { @@ -86,91 +83,37 @@ typedef struct ODP_PACKED { odp_u16sum_t chksum; /**< Checksum */ odp_u32be_t src_addr; /**< Source address */ odp_u32be_t dst_addr; /**< Destination address */ -} odph_ipv4hdr_t; +} _odp_ipv4hdr_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, - "ODPH_IPV4HDR_T__SIZE_ERROR"); - -/** - * Check if IPv4 checksum is valid - * - * @param pkt ODP packet - * - * @return 1 if checksum is valid, otherwise 0 - */ -static inline int odph_ipv4_csum_valid(odp_packet_t pkt) -{ - odp_u16be_t res = 0; - uint16_t *w; - int nleft = sizeof(odph_ipv4hdr_t); - odph_ipv4hdr_t ip; - odp_u16be_t chksum; - - if (!odp_packet_l3_offset(pkt)) - return 0; - - odp_packet_copy_to_mem(pkt, odp_packet_l3_offset(pkt), - sizeof(odph_ipv4hdr_t), &ip); - - w = (uint16_t *)(void *)&ip; - chksum = ip.chksum; - ip.chksum = 0x0; - - res = odph_chksum(w, nleft); - return (res == chksum) ? 1 : 0; -} - -/** - * Calculate and fill in IPv4 checksum - * - * @note when using this api to populate data destined for the wire - * odp_cpu_to_be_16() can be used to remove sparse warnings - * - * @param pkt ODP packet - * - * @return IPv4 checksum in host cpu order, or 0 on failure - */ -static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) -{ - uint16_t *w; - odph_ipv4hdr_t *ip; - int nleft = sizeof(odph_ipv4hdr_t); - - if (!odp_packet_l3_offset(pkt)) - return 0; - - ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); - w = (uint16_t *)(void *)ip; - ip->chksum = odph_chksum(w, nleft); - return ip->chksum; -} +ODP_STATIC_ASSERT(sizeof(_odp_ipv4hdr_t) == _ODP_IPV4HDR_LEN, + "_ODP_IPV4HDR_T__SIZE_ERROR"); /** IPv6 version */ -#define ODPH_IPV6 6 +#define _ODP_IPV6 6 /** IPv6 header length */ -#define ODPH_IPV6HDR_LEN 40 +#define _ODP_IPV6HDR_LEN 40 /** IPv6 address length in bytes */ -#define ODPH_IPV6ADDR_LEN 16 +#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 ODPH_IP_TOS_* + * field and is composed of the DSCP and ECN subfields. Use the _ODP_IP_TOS_* * constants above to access these subfields. */ -#define ODPH_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit mask */ -#define ODPH_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift */ -#define ODPH_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ -#define ODPH_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ -#define ODPH_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask */ -#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ +#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 ODPH_IPV6HDR_DSCP(ver_tc_flow) \ +#define _ODP_IPV6HDR_DSCP(ver_tc_flow) \ (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) /** @@ -183,11 +126,11 @@ typedef struct ODP_PACKED { uint8_t hop_limit; /**< Hop limit */ uint8_t src_addr[16]; /**< Source address */ uint8_t dst_addr[16]; /**< Destination address */ -} odph_ipv6hdr_t; +} _odp_ipv6hdr_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, - "ODPH_IPV6HDR_T__SIZE_ERROR"); +ODP_STATIC_ASSERT(sizeof(_odp_ipv6hdr_t) == _ODP_IPV6HDR_LEN, + "_ODP_IPV6HDR_T__SIZE_ERROR"); /** * IPv6 Header extensions @@ -198,41 +141,24 @@ typedef struct ODP_PACKED { not counting first 8 bytes, so 0 = 8 bytes 1 = 16 bytes, etc. */ uint8_t filler[6]; /**< Fill out first 8 byte segment */ -} odph_ipv6hdr_ext_t; +} _odp_ipv6hdr_ext_t; /** @name * IP protocol values (IPv4:'proto' or IPv6:'next_hdr') * @{*/ -#define ODPH_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */ -#define ODPH_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol (1) */ -#define ODPH_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */ -#define ODPH_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */ -#define ODPH_IPPROTO_ROUTE 0x2B /**< IPv6 Routing header (43) */ -#define ODPH_IPPROTO_FRAG 0x2C /**< IPv6 Fragment (44) */ -#define ODPH_IPPROTO_AH 0x33 /**< Authentication Header (51) */ -#define ODPH_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */ -#define ODPH_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */ +#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 */ /**@}*/ /** - * Parse IPv4 address from a string - * - * Parses IPv4 address from the string which must be passed in the format of - * four decimal digits delimited by dots (xxx.xxx.xxx.xxx). All four digits - * have to be present and may have leading zeros. String does not have to be - * NULL terminated. The address is written only when successful. The address - * byte order is CPU native. - * - * @param[out] ip_addr Pointer to IPv4 address for output (in native endian) - * @param str IPv4 address string to be parsed - * - * @retval 0 on success - * @retval <0 on failure - */ -int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str); - -/** * @} */ #ifdef __cplusplus diff --git a/helper/include/odp/helper/ipsec.h b/platform/linux-generic/include/protocols/ipsec.h similarity index 53% copy from helper/include/odp/helper/ipsec.h copy to platform/linux-generic/include/protocols/ipsec.h index 034a341..093177f 100644 --- a/helper/include/odp/helper/ipsec.h +++ b/platform/linux-generic/include/protocols/ipsec.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, Linaro Limited +/* Copyright (c) 2016, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -11,8 +11,8 @@ * ODP IPSec headers */ -#ifndef ODPH_IPSEC_H_ -#define ODPH_IPSEC_H_ +#ifndef ODP_IPSEC_H_ +#define ODP_IPSEC_H_ #ifdef __cplusplus extern "C" { @@ -20,13 +20,13 @@ extern "C" { #include <odp_api.h> -/** @addtogroup odph_header ODPH HEADER +/** @addtogroup odp_header ODP HEADER * @{ */ -#define ODPH_ESPHDR_LEN 8 /**< IPSec ESP header length */ -#define ODPH_ESPTRL_LEN 2 /**< IPSec ESP trailer length */ -#define ODPH_AHHDR_LEN 12 /**< IPSec AH header length */ +#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 @@ -34,12 +34,12 @@ extern "C" { typedef struct ODP_PACKED { odp_u32be_t spi; /**< Security Parameter Index */ odp_u32be_t seq_no; /**< Sequence Number */ - uint8_t iv[0]; /**< Initialization vector */ -} odph_esphdr_t; + uint8_t iv[0]; /**< Initialization vector */ +} _odp_esphdr_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, - "ODPH_ESPHDR_T__SIZE_ERROR"); +ODP_STATIC_ASSERT(sizeof(_odp_esphdr_t) == _ODP_ESPHDR_LEN, + "_ODP_ESPHDR_T__SIZE_ERROR"); /** * IPSec ESP trailer @@ -48,27 +48,27 @@ 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) */ -} odph_esptrl_t; +} _odp_esptrl_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN, - "ODPH_ESPTRL_T__SIZE_ERROR"); +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 */ + 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 */ -} odph_ahhdr_t; + uint8_t icv[0]; /**< Integrity Check Value */ +} _odp_ahhdr_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ahhdr_t) == ODPH_AHHDR_LEN, - "ODPH_AHHDR_T__SIZE_ERROR"); +ODP_STATIC_ASSERT(sizeof(_odp_ahhdr_t) == _ODP_AHHDR_LEN, + "_ODP_AHHDR_T__SIZE_ERROR"); /** * @} diff --git a/helper/include/odp/helper/tcp.h b/platform/linux-generic/include/protocols/tcp.h similarity index 88% copy from helper/include/odp/helper/tcp.h copy to platform/linux-generic/include/protocols/tcp.h index cabef90..4e92e4b 100644 --- a/helper/include/odp/helper/tcp.h +++ b/platform/linux-generic/include/protocols/tcp.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, Linaro Limited +/* Copyright (c) 2016, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -11,8 +11,8 @@ * ODP TCP header */ -#ifndef ODPH_TCP_H_ -#define ODPH_TCP_H_ +#ifndef ODP_TCP_H_ +#define ODP_TCP_H_ #ifdef __cplusplus extern "C" { @@ -20,11 +20,11 @@ extern "C" { #include <odp_api.h> -/** @addtogroup odph_header ODPH HEADER +/** @addtogroup odp_header ODP HEADER * @{ */ -#define ODPH_TCPHDR_LEN 20 /**< Min length of TCP header (no options) */ +#define _ODP_TCPHDR_LEN 20 /**< Min length of TCP header (no options) */ /** TCP header */ typedef struct ODP_PACKED { @@ -76,7 +76,7 @@ typedef struct ODP_PACKED { odp_u16be_t window; /**< Window size */ odp_u16be_t cksm; /**< Checksum */ odp_u16be_t urgptr; /**< Urgent pointer */ -} odph_tcphdr_t; +} _odp_tcphdr_t; /** * @} diff --git a/helper/include/odp/helper/udp.h b/platform/linux-generic/include/protocols/udp.h similarity index 47% copy from helper/include/odp/helper/udp.h copy to platform/linux-generic/include/protocols/udp.h index 1ba2dff..535aba8 100644 --- a/helper/include/odp/helper/udp.h +++ b/platform/linux-generic/include/protocols/udp.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, Linaro Limited +/* Copyright (c) 2016, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -10,22 +10,21 @@ * ODP UDP header */ -#ifndef ODPH_UDP_H_ -#define ODPH_UDP_H_ +#ifndef ODP_UDP_H_ +#define ODP_UDP_H_ #ifdef __cplusplus extern "C" { #endif #include <odp_api.h> -#include <odp/helper/chksum.h> -/** @addtogroup odph_header ODPH HEADER +/** @addtogroup odp_header ODP HEADER * @{ */ /** UDP header length */ -#define ODPH_UDPHDR_LEN 8 +#define _ODP_UDPHDR_LEN 8 /** UDP header */ typedef struct ODP_PACKED { @@ -33,28 +32,11 @@ typedef struct ODP_PACKED { 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)*/ -} odph_udphdr_t; - -/** - * UDP checksum - * - * This function calculates the UDP checksum given an odp packet. - * - * @param pkt calculate chksum for pkt - * @return checksum value in BE endianness - */ -static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt) -{ - uint16_t chksum; - int rc; - - rc = odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_RETURN, &chksum); - return (rc == 0) ? chksum : 0; -} +} _odp_udphdr_t; /** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN, - "ODPH_UDPHDR_T__SIZE_ERROR"); +ODP_STATIC_ASSERT(sizeof(_odp_udphdr_t) == _ODP_UDPHDR_LEN, + "_ODP_UDPHDR_T__SIZE_ERROR"); /** * @} diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 0602a62..f567afe 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 <odp/api/spinlock.h> @@ -840,16 +841,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]; } @@ -860,14 +861,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 c319833..5f72985 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> @@ -995,15 +995,15 @@ void _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; @@ -1013,7 +1013,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: @@ -1022,7 +1022,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 */ @@ -1039,12 +1039,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 || @@ -1058,22 +1058,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 + @@ -1082,13 +1082,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; } @@ -1102,11 +1102,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 + @@ -1123,10 +1123,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; @@ -1135,8 +1135,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); } /** @@ -1150,7 +1150,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 */ @@ -1168,19 +1168,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)); @@ -1204,7 +1204,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; @@ -1217,22 +1217,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 */ @@ -1241,18 +1241,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; @@ -1269,30 +1269,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 1fa2d27..b85accb 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -17,8 +17,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 */ @@ -1897,14 +1897,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 @@ -1913,31 +1913,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; @@ -1955,7 +1955,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; } @@ -1966,10 +1966,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) @@ -1997,13 +1997,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; @@ -2021,13 +2021,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) @@ -2035,22 +2035,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) @@ -2866,9 +2866,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 dce33e5..26523f1 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> diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 847250b..1728bb2 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> @@ -408,7 +408,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. */ @@ -603,7 +603,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 ec27f2c..517e876 100644 --- a/platform/linux-generic/pktio/ring.c +++ b/platform/linux-generic/pktio/ring.c @@ -73,7 +73,6 @@ #include <fcntl.h> #include <stdio.h> #include <string.h> -#include "odph_debug.h" #include <odp_packet_io_ring_internal.h> #include <odp_internal.h> @@ -165,9 +164,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; } @@ -202,7 +201,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; }
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> --- v2 changes the names to _odp_* for internal namespace. platform/linux-generic/Makefile.am | 7 +- .../include/odp_classification_inlines.h | 50 +++--- .../include/odp_name_table_internal.h | 2 +- .../linux-generic/include/protocols}/eth.h | 111 ++++++------- .../linux-generic/include/protocols}/ip.h | 180 ++++++--------------- .../linux-generic/include/protocols}/ipsec.h | 40 ++--- .../linux-generic/include/protocols}/tcp.h | 12 +- .../linux-generic/include/protocols}/udp.h | 34 +--- 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, 291 insertions(+), 397 deletions(-) copy {helper/include/odp/helper => platform/linux-generic/include/protocols}/eth.h (30%) copy {helper/include/odp/helper => platform/linux-generic/include/protocols}/ip.h (41%) 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%) copy {helper/include/odp/helper => platform/linux-generic/include/protocols}/udp.h (47%)