From patchwork Mon Feb 17 12:14:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Wallen X-Patchwork-Id: 24761 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4BF6A202B2 for ; Mon, 17 Feb 2014 12:15:34 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id m20sf29783498qcx.6 for ; Mon, 17 Feb 2014 04:15:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=0DM7u63aX2p9ARZ6gKJB0ImZTzC9cAND8Se9eh9uynY=; b=Hu20bTWdLlqIBpBq8fjTUtF426Cfev9bH1hQmsn/XKDgF7JTs6sMxHcUWlnBudQC91 mD9nCd9zq/MykzmGqBRaLdOcGP+rloiSxpuAI7aK0Y8JDue8MNc7yhlfkFzfl9PVeV1c eDVoolstmsv1iw3dr/hEtreBQoIjaUJhvMY56jOGaaiT+KALaHDmtwacFYcypXP9HBcb VOtsx+M1Myz1MwoLih/VCoVnc3xt7JZsMbpX+SmgNkwg4lLjukOx1M+3tU/qJIbHN5TQ Lt9PM/QGcNgOK3wdiGu4vkDv5cDf6YNHCm1X2u5El29Z/8atUQ/srhPVGRPgB0BmsouM IKkA== X-Gm-Message-State: ALoCoQmkBh4Bm88ZDEtNuSDvks1uYr1/Ork+seZY8z/ltFX1wFdRWtkRTIl753q4N7oOKk+MHYOo X-Received: by 10.236.26.209 with SMTP id c57mr2314685yha.9.1392639333468; Mon, 17 Feb 2014 04:15:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: lng-odp@linaro.org Received: by 10.140.26.195 with SMTP id 61ls840708qgv.19.gmail; Mon, 17 Feb 2014 04:15:33 -0800 (PST) X-Received: by 10.140.37.146 with SMTP id r18mr31855024qgr.61.1392639332988; Mon, 17 Feb 2014 04:15:32 -0800 (PST) Received: from mail-qc0-f174.google.com (mail-qc0-f174.google.com [209.85.216.174]) by mx.google.com with ESMTPS id z6si8034858qan.95.2014.02.17.04.15.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 04:15:32 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.174 is neither permitted nor denied by best guess record for domain of carl.wallen@linaro.org) client-ip=209.85.216.174; Received: by mail-qc0-f174.google.com with SMTP id x13so23683998qcv.33 for ; Mon, 17 Feb 2014 04:15:32 -0800 (PST) X-Received: by 10.140.22.39 with SMTP id 36mr31493081qgm.59.1392639332803; Mon, 17 Feb 2014 04:15:32 -0800 (PST) Received: from mcint01.emea.nsn-net.net (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id 3sm44637049qan.15.2014.02.17.04.15.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 04:15:32 -0800 (PST) From: Carl Wallen To: lng-odp@linaro.org Cc: Carl Wallen Subject: [lng-odp] [PATCH 2/7] ODP helper: Add IPv6 header and defines. Add & rename IPv4 defines Date: Mon, 17 Feb 2014 14:14:36 +0200 Message-Id: <1392639281-2753-3-git-send-email-carl.wallen@linaro.org> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1392639281-2753-1-git-send-email-carl.wallen@linaro.org> References: <1392639281-2753-1-git-send-email-carl.wallen@linaro.org> X-Original-Sender: carl.wallen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.216.174 is neither permitted nor denied by best guess record for domain of carl.wallen@linaro.org) smtp.mail=carl.wallen@linaro.org Precedence: list Mailing-list: list lng-odp@linaro.org; contact lng-odp+owners@linaro.org List-ID: X-Google-Group-Id: 474323889996 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add IPv6 header and defines along with some new IPv4 defines and renames. Update code using updated definitions. Signed-off-by: Carl Wallen --- include/helper/odp_ip.h | 43 +++++++++++++++++++++++------- platform/linux-generic/source/odp_packet.c | 4 +-- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/include/helper/odp_ip.h b/include/helper/odp_ip.h index d37daca..a5eccc7 100644 --- a/include/helper/odp_ip.h +++ b/include/helper/odp_ip.h @@ -22,12 +22,17 @@ extern "C" { #include #include -#define ODP_IPV4 4 /**< IP version 4 */ -#define ODP_IPHDR_LEN 20 /**< Min length of IP header (no options) */ -#define ODP_IPHDR_IHL_MIN 5 /**< Minimum IHL value*/ +#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_IPHDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) -#define ODP_IPHDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) +#define ODP_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) +#define ODP_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) +#define ODP_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & 0x4000) +#define ODP_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & 0x2000) +#define ODP_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) + +#define ODP_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) typedef struct ODP_PACKED { uint8_t ver_ihl; @@ -42,13 +47,31 @@ typedef struct ODP_PACKED { uint32be_t dst_addr; } odp_ipv4hdr_t; -ODP_ASSERT(sizeof(odp_ipv4hdr_t) == ODP_IPHDR_LEN, ODP_IPV4HDR_T__SIZE_ERROR); +ODP_ASSERT(sizeof(odp_ipv4hdr_t) == ODP_IPV4HDR_LEN, ODP_IPV4HDR_T__SIZE_ERROR); + + +#define ODP_IPV6 6 +#define ODP_IPV6HDR_LEN 40 + +typedef struct ODP_PACKED { + uint32be_t ver_tc_flow; + uint16be_t payload_len; + uint8_t next_hdr; + uint8_t hop_limit; + uint8_t src_addr[16]; + uint8_t dst_addr[16]; +} odp_ipv6hdr_t; -/* IP header protocol ('proto') field values, a selected few */ -#define ODP_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol */ -#define ODP_IPPROTO_TCP 0x06 /**< Transmission Control Protocol */ -#define ODP_IPPROTO_UDP 0x11 /**< User Datagram Protocol */ +ODP_ASSERT(sizeof(odp_ipv6hdr_t) == ODP_IPV6HDR_LEN, ODP_IPV6HDR_T__SIZE_ERROR); +/* IP protocol values (IPv4:'proto' or IPv6:'next_hdr') */ +#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_SCTP 0x84 /**< Stream Control Transmission Protocol (132) */ +#define ODP_IPPROTO_FRAG 0x2C /**< Fragment (44) */ +#define ODP_IPPROTO_AH 0x33 /**< Authentication Header (51) */ +#define ODP_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */ #ifdef __cplusplus } diff --git a/platform/linux-generic/source/odp_packet.c b/platform/linux-generic/source/odp_packet.c index 7cd0d71..6b06f76 100644 --- a/platform/linux-generic/source/odp_packet.c +++ b/platform/linux-generic/source/odp_packet.c @@ -153,8 +153,8 @@ void odp_packet_parse(odp_packet_t pkt, size_t len, size_t l2_offset) pkt_hdr->proto_flags.ipv4 = 1; ip = (odp_ipv4hdr_t *)odp_packet_l3(pkt); - ihl = ODP_IPHDR_IHL(ip->ver_ihl); - if (odp_unlikely(ihl < ODP_IPHDR_IHL_MIN)) { + ihl = ODP_IPV4HDR_IHL(ip->ver_ihl); + if (odp_unlikely(ihl < ODP_IPV4HDR_IHL_MIN)) { pkt_hdr->error_flags.ip_err = 1; return; }