From patchwork Thu Jan 21 15:29:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 60095 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp72528lbb; Thu, 21 Jan 2016 07:29:25 -0800 (PST) X-Received: by 10.55.52.211 with SMTP id b202mr53333713qka.27.1453390165636; Thu, 21 Jan 2016 07:29:25 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d63si1736020qga.118.2016.01.21.07.29.25; Thu, 21 Jan 2016 07:29:25 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 49A3B6179B; Thu, 21 Jan 2016 15:29:24 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=Crmvkg13; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 8AAC66179C; Thu, 21 Jan 2016 15:29:19 +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 7929F617A5; Thu, 21 Jan 2016 15:29:17 +0000 (UTC) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by lists.linaro.org (Postfix) with ESMTPS id 46BD66179B for ; Thu, 21 Jan 2016 15:29:16 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id 123so178935880wmz.0 for ; Thu, 21 Jan 2016 07:29:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zwePpm7RUdhIYnz8d6O4Fp/sy2j+PRZ6rB6ulLxrOm8=; b=Crmvkg13c5pw9YNF0pvupWbnn1oFLD/2xQv2DEmlpedzxOmrKYrXdGO5wvZPP7U8TR iG2o/djBT1501VPuhqsStNiVUHHevSIJVsfE4hLGw5PjMhrtdjs+IYJC2vm45VBnL93F /gIqGj//YGx8P2Oq0g60KAFln7eE4ewN+m35s= 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=zwePpm7RUdhIYnz8d6O4Fp/sy2j+PRZ6rB6ulLxrOm8=; b=CgjpnthmlZvCJjLXOIlB8CsypDd9sriePpcyTCbx//lH6YYy7VESRpr2korbVeza/x VF7nnyHqKTiK3l0x56JLwAS1fM85jm7/yNbfLfC6KXrHCX5Q2JtqoYjRcX4vDibe4m1q 1GDYzt+VkbNTKnGer2QXQFggRFnKgLKgVgByI5qC+nzS2H7DxeqUk+Rlx3ongZnYfdfu UvD3D+9uX/mWnuZ1VsIi2y0YVC7+kvobgEFY1+4uPk+ybqHhXTC0VOBGt9xDOxBNKiZb W1Ssq917tbtEGg/1gKHputZQ6jM+odZQMi8yovcHtDFkxXhBQoUfSkO1SH01v/doN7dl bW6Q== X-Gm-Message-State: AG10YOSEg8x0UDlSTkLYY5JLbOFC07OA5fc7AWfzmJs20DoEdOHEg+3hdrMCGERuIZAQOwZAEhA= X-Received: by 10.28.194.69 with SMTP id s66mr11780689wmf.93.1453390155443; Thu, 21 Jan 2016 07:29:15 -0800 (PST) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id di8sm1927333wjc.34.2016.01.21.07.29.14 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Jan 2016 07:29:14 -0800 (PST) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Thu, 21 Jan 2016 15:29:01 +0000 Message-Id: <1453390141-30539-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453307831-15459-2-git-send-email-zoltan.kiss@linaro.org> References: <1453307831-15459-2-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCH 1/2 v2] linux-generic: packet: hide frame_len behind accessor 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 classification code accesses this variable directly, which prevents reusing that code e.g. in ODP-DPDK. Signed-off-by: Zoltan Kiss Reviewed-by: Balasubramanian Manoharan --- v2: rename it packet_len(), to align with packet_set_len() platform/linux-generic/include/odp_classification_inlines.h | 5 +++-- platform/linux-generic/include/odp_packet_internal.h | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index e9739aa..5f0b564 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -24,6 +24,7 @@ extern "C" { #include #include #include +#include /* PMR term value verification function These functions verify the given PMR term value with the value in the packet @@ -33,7 +34,7 @@ These following functions return 1 on success and 0 on failure static inline int verify_pmr_packet_len(odp_packet_hdr_t *pkt_hdr, pmr_term_value_t *term_value) { - if (term_value->val == (pkt_hdr->frame_len & + if (term_value->val == (packet_len(pkt_hdr) & term_value->mask)) return 1; @@ -240,7 +241,7 @@ static inline int verify_pmr_custom_frame(const uint8_t *pkt_addr, ODP_ASSERT(val_sz <= ODP_PMR_TERM_BYTES_MAX); - if (pkt_hdr->frame_len <= offset + val_sz) + if (packet_len(pkt_hdr) <= offset + val_sz) return 0; memcpy(&val, pkt_addr + offset, val_sz); diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 12e9cca..5078cc2 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -214,6 +214,11 @@ static inline void pull_tail(odp_packet_hdr_t *pkt_hdr, size_t len) pkt_hdr->frame_len -= len; } +static inline uint32_t packet_len(odp_packet_hdr_t* pkt_hdr) +{ + return pkt_hdr->frame_len; +} + static inline void packet_set_len(odp_packet_t pkt, uint32_t len) { odp_packet_hdr(pkt)->frame_len = len;