From patchwork Tue Dec 16 18:18:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 42346 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DBDF925E25 for ; Tue, 16 Dec 2014 18:18:28 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf9043551lab.3 for ; Tue, 16 Dec 2014 10:18:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=eh/qQn4rT19GOhMvFbKzJfKQ+uwKrlY0hR9GVKP00c8=; b=aOxKXv2We+hs3cLPeR/1uPIBuEFu8bdfjOu4jilxj0M2Xc1ejEY2VOgruYtqp67/hA 4c2s0qTUdSfrj2UeU7viXEEGf238GYAwiQsa10wj/nxWXfx8/M6kojaqkB+5vTGSrl98 6ajApq9aPh8IRzUVRiVLumcTfcJLgESVn0ugIrVfRaFNLxNGIKdtr1MA30SskdCDTldy sAjRK9hxRYSrzg1TS8M02CB9qpvZ7VaMycgIitDREHZXnwI4FciK1QfnUfW/TBNXlzey 5hB2/o4g67FK4b/GCFjL6jsQrh2V/WghbrQZfDSPG2gIuZHnJxlTPJBRHvYxKYMPUguX P82A== X-Gm-Message-State: ALoCoQlFPpB1mgpYMUim8Gd87HBC5GP3QEIm4YTBQt4icWMI0M8DOIwzgMyDcnvStygGNfwY+5na X-Received: by 10.180.8.232 with SMTP id u8mr511700wia.7.1418753907652; Tue, 16 Dec 2014 10:18:27 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.71 with SMTP id t7ls884401lae.11.gmail; Tue, 16 Dec 2014 10:18:27 -0800 (PST) X-Received: by 10.112.139.196 with SMTP id ra4mr37270828lbb.95.1418753907285; Tue, 16 Dec 2014 10:18:27 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id j5si1490572lbs.110.2014.12.16.10.18.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 10:18:27 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hs14so11580720lab.25 for ; Tue, 16 Dec 2014 10:18:27 -0800 (PST) X-Received: by 10.112.141.42 with SMTP id rl10mr36823384lbb.98.1418753907170; Tue, 16 Dec 2014 10:18:27 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp1121032lbb; Tue, 16 Dec 2014 10:18:26 -0800 (PST) X-Received: by 10.140.35.114 with SMTP id m105mr64203026qgm.79.1418753905676; Tue, 16 Dec 2014 10:18:25 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id q8si1777551qco.8.2014.12.16.10.18.24 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 16 Dec 2014 10:18:25 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y0whS-0001o4-40; Tue, 16 Dec 2014 18:18:22 +0000 Received: from mail-oi0-f47.google.com ([209.85.218.47]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y0whL-0001n7-0w for lng-odp@lists.linaro.org; Tue, 16 Dec 2014 18:18:15 +0000 Received: by mail-oi0-f47.google.com with SMTP id v63so9990520oia.20 for ; Tue, 16 Dec 2014 10:18:09 -0800 (PST) X-Received: by 10.182.231.230 with SMTP id tj6mr5280729obc.58.1418753889624; Tue, 16 Dec 2014 10:18:09 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id w189sm627638oig.0.2014.12.16.10.18.08 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 10:18:08 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 16 Dec 2014 12:18:03 -0600 Message-Id: <1418753883-27568-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: add support for ODP_PACKET_OFFSET_INVALID X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Fix for Bug #1004. Signed-off-by: Bill Fischofer --- platform/linux-generic/include/api/odp_packet.h | 7 +++++-- .../linux-generic/include/api/odp_platform_types.h | 3 +++ .../linux-generic/include/odp_packet_internal.h | 22 ++++++++++++++++++---- platform/linux-generic/odp_packet.c | 10 ++++++---- 4 files changed, 32 insertions(+), 10 deletions(-) -- 1.8.3.2 diff --git a/platform/linux-generic/include/api/odp_packet.h b/platform/linux-generic/include/api/odp_packet.h index 97c2cb6..d0f15ac 100644 --- a/platform/linux-generic/include/api/odp_packet.h +++ b/platform/linux-generic/include/api/odp_packet.h @@ -469,6 +469,7 @@ void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len); * @param pkt Packet handle * * @return Layer 2 start offset + * @retval ODP_PACKET_OFFSET_INVALID If not found */ uint32_t odp_packet_l2_offset(odp_packet_t pkt); @@ -514,7 +515,8 @@ void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len); * * @param pkt Packet handle * - * @return Layer 3 start offset or ODP_PACKET_OFFSET_INVALID if not found + * @return Layer 3 start offset + * @retval ODP_PACKET_OFFSET_INVALID If not found */ uint32_t odp_packet_l3_offset(odp_packet_t pkt); @@ -560,7 +562,8 @@ void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len); * * @param pkt Packet handle * - * @return Layer 4 start offset or ODP_PACKET_OFFSET_INVALID if not found + * @return Layer 4 start offset + * @retval ODP_PACKET_OFFSET_INVALID If not found */ uint32_t odp_packet_l4_offset(odp_packet_t pkt); diff --git a/platform/linux-generic/include/api/odp_platform_types.h b/platform/linux-generic/include/api/odp_platform_types.h index 2cfba87..8671b42 100644 --- a/platform/linux-generic/include/api/odp_platform_types.h +++ b/platform/linux-generic/include/api/odp_platform_types.h @@ -47,6 +47,9 @@ typedef odp_buffer_t odp_packet_t; /** Invalid packet */ #define ODP_PACKET_INVALID ODP_BUFFER_INVALID +/** Invalid packet offset */ +#define ODP_PACKET_OFFSET_INVALID (0xffffffff) + /** ODP packet segment */ typedef odp_buffer_t odp_packet_seg_t; diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index a0eff30..515c127 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -169,6 +169,12 @@ static inline void packet_init(pool_entry_t *pool, len = sizeof(odp_packet_hdr_t) - start_offset; memset(start, 0, len); + /* Set metadata items that initialize to non-zero values */ + pkt_hdr->l2_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->payload_offset = ODP_PACKET_OFFSET_INVALID; + /* * Packet headroom is set from the pool's headroom * Packet tailroom is rounded up to fill the last @@ -192,15 +198,23 @@ static inline void *packet_map(odp_packet_hdr_t *pkt_hdr, pkt_hdr->headroom + pkt_hdr->frame_len); } -#define pull_offset(x, len) (x = x < len ? 0 : x - len) +#define pull_offset(x, len) do { \ + if (x != ODP_PACKET_OFFSET_INVALID) \ + x = x < len ? ODP_PACKET_OFFSET_INVALID : x - len; \ + } while (0) + +#define push_offset(x, len) do { \ + if (x != ODP_PACKET_OFFSET_INVALID) \ + x += len; \ + } while (0) static inline void push_head(odp_packet_hdr_t *pkt_hdr, size_t len) { pkt_hdr->headroom -= len; pkt_hdr->frame_len += len; - pkt_hdr->l2_offset += len; - pkt_hdr->l3_offset += len; - pkt_hdr->l4_offset += len; + push_offset(pkt_hdr->l2_offset, len); + push_offset(pkt_hdr->l3_offset, len); + push_offset(pkt_hdr->l4_offset, len); } static inline void pull_head(odp_packet_hdr_t *pkt_hdr, size_t len) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 0ab9866..65e6288 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -776,10 +776,10 @@ int _odp_packet_parse(odp_packet_t pkt) pkt_hdr->error_flags.all = 0; pkt_hdr->input_flags.all = 0; pkt_hdr->output_flags.all = 0; - pkt_hdr->l2_offset = 0; - pkt_hdr->l3_offset = 0; - pkt_hdr->l4_offset = 0; - pkt_hdr->payload_offset = 0; + pkt_hdr->l2_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->payload_offset = ODP_PACKET_OFFSET_INVALID; pkt_hdr->vlan_s_tag = 0; pkt_hdr->vlan_c_tag = 0; pkt_hdr->l3_protocol = 0; @@ -861,6 +861,7 @@ int _odp_packet_parse(odp_packet_t pkt) default: pkt_hdr->input_flags.l3 = 0; + pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID; ip_proto = 255; /* Reserved invalid by IANA */ } @@ -892,6 +893,7 @@ int _odp_packet_parse(odp_packet_t pkt) default: pkt_hdr->input_flags.l4 = 0; + pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID; break; }