From patchwork Fri Mar 18 17:20:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 64089 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp83794lbc; Fri, 18 Mar 2016 10:21:21 -0700 (PDT) X-Received: by 10.140.97.202 with SMTP id m68mr23522767qge.102.1458321681615; Fri, 18 Mar 2016 10:21:21 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t90si238693qgd.103.2016.03.18.10.21.21; Fri, 18 Mar 2016 10:21:21 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 15B50669B5; Fri, 18 Mar 2016 17:21:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id C32BB6698E; Fri, 18 Mar 2016 17:20:53 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id DDA226699D; Fri, 18 Mar 2016 17:20:48 +0000 (UTC) Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by lists.linaro.org (Postfix) with ESMTPS id 9B9B7667C6 for ; Fri, 18 Mar 2016 17:20:47 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id l124so39058731wmf.1 for ; Fri, 18 Mar 2016 10:20:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lMNnzrZyljxz+bbpfNFChJfLyWLyYUVMGPG2GkSJVG8=; b=VfgUzSH11lGiVGQIc7TCA3ebDZyTIQhos1Pb9EnQwRe4yFwkc0WMFOjXlv+yqk4r2K 92F+29JrZhTO0AA7cBar6AXAlkiOPlSu/ygjnwEdd9e+Yvic8SD8qKOgWFdL8Nt55EPl E4uemBxUGqoT5xGRQIzgaSxmUiVkqvQl/rCs9NyW0jB6jYONhN/qW20uAaKv9Gjx2VCm x1KEwZD5y2uTuG/zpQbEizAGO8NBUsHoSWqP9jH49A9rhYgX6NBVHyCn4w3DsqxzBi6h V3LBWfXEWuV21nvZ6sArAXZmqF9w87rkZzaaPnad/GE4oEZ+3Ok5x35e1yDUxc9NCrI+ mXqw== X-Gm-Message-State: AD7BkJK5R6RJp+tPB5NzUYF8iwYQ78kEISMzNjXcDw+LbJKJRQv0BPtU4IiFVokrwlsgDdhgqDQ= X-Received: by 10.28.145.196 with SMTP id t187mr464256wmd.81.1458321646791; Fri, 18 Mar 2016 10:20:46 -0700 (PDT) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id fv6sm13086038wjc.12.2016.03.18.10.20.46 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Mar 2016 10:20:46 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 18 Mar 2016 17:20:03 +0000 Message-Id: <1458321603-23979-3-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458321603-23979-1-git-send-email-zoltan.kiss@linaro.org> References: <1458321603-23979-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCH v2 2/2] linux-generic: packet: don't look for L2 header if there isn't any X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" The L2 offset functions should consider the L2 flag: return negative answer if there isn't any, and implicitly set it when offset is set. E.g. user created packets don't have L2 headers immediately. Signed-off-by: Zoltan Kiss --- platform/linux-generic/include/odp_packet_internal.h | 5 +++++ platform/linux-generic/odp_packet.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 7974a20..92b770f 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -272,6 +272,11 @@ static inline int packet_hdr_has_l2(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->input_flags.l2; } +static inline void packet_hdr_has_l2_set(odp_packet_hdr_t *pkt_hdr, int val) +{ + pkt_hdr->input_flags.l2 = val; +} + static inline int packet_hdr_has_eth(odp_packet_hdr_t *pkt_hdr) { return pkt_hdr->input_flags.eth; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index aac42b6..2c44316 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -353,12 +353,16 @@ uint32_t odp_packet_user_area_size(odp_packet_t pkt) void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + if (!packet_hdr_has_l2(pkt_hdr)) + return NULL; return packet_map(pkt_hdr, pkt_hdr->l2_offset, len); } uint32_t odp_packet_l2_offset(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + if (!packet_hdr_has_l2(pkt_hdr)) + return ODP_PACKET_OFFSET_INVALID; return pkt_hdr->l2_offset; } @@ -369,6 +373,7 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) if (offset >= pkt_hdr->frame_len) return -1; + packet_hdr_has_l2_set(pkt_hdr, 1); pkt_hdr->l2_offset = offset; return 0; }