From patchwork Wed Mar 2 20:05:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 63417 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2573005lbc; Wed, 2 Mar 2016 12:06:06 -0800 (PST) X-Received: by 10.140.239.66 with SMTP id k63mr38081098qhc.11.1456949166149; Wed, 02 Mar 2016 12:06:06 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f185si11943376qkb.71.2016.03.02.12.06.05; Wed, 02 Mar 2016 12:06:06 -0800 (PST) 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 5E0FB650E8; Wed, 2 Mar 2016 20:06:05 +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 622BD622A6; Wed, 2 Mar 2016 20:06:00 +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 54792622B1; Wed, 2 Mar 2016 20:05:55 +0000 (UTC) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by lists.linaro.org (Postfix) with ESMTPS id AB1A661D49 for ; Wed, 2 Mar 2016 20:05:53 +0000 (UTC) Received: by mail-wm0-f42.google.com with SMTP id n186so102647096wmn.1 for ; Wed, 02 Mar 2016 12:05:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=r1Y1Quc8hXO8OoFtTJ8C34rGRos2cknH7Ln2U2fVx9Q=; b=FN86Iy/5WEyPj+WPHl1DfsZHQ2FJPx3rNw7TQYmYd9oshyzIu3tYGaKjQIfwbmOmac o/+dF1hCz3qQnZrEYKlyUL4UW8rAen3jG6IebtPHrgiXEDv9g7oQHsKWuKDQ4IVWysIp kvliRFAGP5DhOGCo+uk7HffxMR8WM/+d/wjS3VBc/556MkLPGrXqKE5amNJqmNqEoF1s pl3717JzLO5tHEuzNSsTDxyhdHCFFI+3jjrF9bJjNFZQRUa1VdTJ4ACORLWu5mCFi86d PPR+4H8jTNKjcykuYSR7u7Mahzyc8FWInYhjjFPjQ78f3UQztkDJo2WjVrti1viTUHpt FtJA== X-Gm-Message-State: AD7BkJKzGljSgww/sivbatmit2mBecEuCv2RrEFF9iRQK/aJ87NC6KqfS/l+LTJ2SqCLJLi4TTY= X-Received: by 10.28.92.13 with SMTP id q13mr1658959wmb.43.1456949152902; Wed, 02 Mar 2016 12:05:52 -0800 (PST) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id z6sm5687302wme.9.2016.03.02.12.05.52 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 Mar 2016 12:05:52 -0800 (PST) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Wed, 2 Mar 2016 20:05:40 +0000 Message-Id: <1456949141-32378-2-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456949141-32378-1-git-send-email-zoltan.kiss@linaro.org> References: <1456949141-32378-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 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 Reviewed-by: Balasubramanian Manoharan --- 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 96cf77e..2318349 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 (!odp_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 85d4924..d9fe544 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -258,6 +258,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 odp_packet_hdr_has_l2(odp_packet_hdr_t *pkt_hdr) +{ + return pkt_hdr->input_flags.l2; +} + +static inline int odp_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 da195ad..4551951 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -1003,8 +1003,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 (odp_packet_hdr_has_l2(hdr) && hdr->input_flags.vlan && + odp_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);