From patchwork Fri Mar 18 17:20:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 64090 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp84380lbc; Fri, 18 Mar 2016 10:22:34 -0700 (PDT) X-Received: by 10.107.8.144 with SMTP id h16mr19760825ioi.122.1458321754324; Fri, 18 Mar 2016 10:22:34 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m10si250690igx.14.2016.03.18.10.22.20; Fri, 18 Mar 2016 10:22:34 -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 C8630619C1; Fri, 18 Mar 2016 17:22:20 +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 69B14669B6; Fri, 18 Mar 2016 17:20:56 +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 E55F8669B4; Fri, 18 Mar 2016 17:20:52 +0000 (UTC) Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by lists.linaro.org (Postfix) with ESMTPS id D1E4C6698C for ; Fri, 18 Mar 2016 17:20:46 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id p65so46653838wmp.0 for ; Fri, 18 Mar 2016 10:20:46 -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=9puXfd4n1Pk70Ex7KTp1Kzd0fy4YVfFtFQ+qYZxM1Y8=; b=L70lf4pFcIBaUpbVYd20+JeSX7fELqmzYSJqa0YtyW7xX7JUtnYXx+iTa04p0kKxOZ wCHu1pJXB63bb7he8FPWHKOwkhlX8gp37uIUSZx29dvt6kloRH+VKt5YSAvl5ubAX51i mZq9/gVVhZQyb3sbbdtZaRbop3sh9DQHkkmT4kcILY0o3oMpqE8roaQS2Rp6LMfDJSf3 68yW+3gfJBxyn4qFBDiIceDOj9LlVzHPJY4KFHzMm8JJkPuhfNGs3fYJVI3z2Sld30c1 svlYdV8Y3xt58Ax1jG+xSRPhZxUv1VQFY694PzeWVg/ZvEt4gwTL6lg7fOS4X1bObzIU ycSw== X-Gm-Message-State: AD7BkJKQaaBQ35HUSZpQ++yrkpYOX3wzqv0iF2pMLbz1WxqcrZH56a++kzgH0b4xx6jFJ01qrI8= X-Received: by 10.194.93.42 with SMTP id cr10mr17280610wjb.33.1458321646012; 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.45 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Mar 2016 10:20:45 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 18 Mar 2016 17:20:02 +0000 Message-Id: <1458321603-23979-2-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 1/2] linux-generic: packet_flags: use accessors to modify eth and l2 flag 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" This makes it possible for other implementations like ODP-DPDK to reuse classification code while using a different packet API. Signed-off-by: Zoltan Kiss --- platform/linux-generic/include/odp_classification_inlines.h | 2 +- platform/linux-generic/include/odp_packet_internal.h | 10 ++++++++++ platform/linux-generic/odp_classification.c | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index 8bd010d..bac5b48 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -162,7 +162,7 @@ static inline int verify_pmr_dmac(const uint8_t *pkt_addr, uint64_t dmac_be = 0; const odph_ethhdr_t *eth; - if (!pkt_hdr->input_flags.eth) + if (!packet_hdr_has_eth(pkt_hdr)) return 0; eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->l2_offset); diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index b632ece..7974a20 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -267,6 +267,16 @@ odp_buffer_t _odp_packet_to_buffer(odp_packet_t pkt); /* Convert a buffer handle to a packet handle */ odp_packet_t _odp_packet_from_buffer(odp_buffer_t buf); +static inline int packet_hdr_has_l2(odp_packet_hdr_t *pkt_hdr) +{ + return pkt_hdr->input_flags.l2; +} + +static inline int packet_hdr_has_eth(odp_packet_hdr_t *pkt_hdr) +{ + return pkt_hdr->input_flags.eth; +} + int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr); int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr); diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 6c9f7c1..f5e4673 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -843,8 +843,8 @@ cos_t *match_qos_l2_cos(pmr_l2_cos_t *l2_cos, const uint8_t *pkt_addr, const odph_vlanhdr_t *vlan; uint16_t qos; - if (hdr->input_flags.l2 && hdr->input_flags.vlan && - hdr->input_flags.eth) { + if (packet_hdr_has_l2(hdr) && hdr->input_flags.vlan && + packet_hdr_has_eth(hdr)) { eth = (const odph_ethhdr_t *)(pkt_addr + hdr->l2_offset); vlan = (const odph_vlanhdr_t *)(ð->type); qos = odp_be_to_cpu_16(vlan->tci);