From patchwork Fri Jan 22 12:16: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: 60141 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp632681lbb; Fri, 22 Jan 2016 04:16:27 -0800 (PST) X-Received: by 10.107.15.139 with SMTP id 11mr3231408iop.66.1453464987611; Fri, 22 Jan 2016 04:16:27 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y79si11850163ioi.7.2016.01.22.04.16.27; Fri, 22 Jan 2016 04:16:27 -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 A789A617E2; Fri, 22 Jan 2016 12:16:26 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=AN7hKdKo; 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 596A7616CA; Fri, 22 Jan 2016 12:16:22 +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 C44D0616F7; Fri, 22 Jan 2016 12:16:19 +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 CF28E616C2 for ; Fri, 22 Jan 2016 12:16:18 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id 123so12406767wmz.0 for ; Fri, 22 Jan 2016 04:16:18 -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=ECfeI71NlAxgelaVrIfIvm7OGGfNRtUspFmhDnDYdV0=; b=AN7hKdKof+bv/NKMLM/tqaN4NPh+ZDwwSNeGGwGVoVqaSAQDMseOYOt4XzoVMDguaI c9NTyRK/mpgrexGgTd1Q7GeBaQaqHuld21fAkoPoNUl/RmBg7eUQRctxLK2P6DprWX2M aZJEwhkCUM5o4putyYhiZ3kcG4AImnpD/TQH4= 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=ECfeI71NlAxgelaVrIfIvm7OGGfNRtUspFmhDnDYdV0=; b=cIgNeL9rFpFg6XrkkIIu0dU+foYfUDBVZHHqQqzk9+SNUU2Rq33G1URGd5jeaUN2cW r/9/XGfC60OIniNpI23nFZcLodh3PYuBg7aYhUEIBcMxVbO3W1Hwritdh3ws996EHlvd OHlyEonevmY8Sx/z5n92U/d4Hcaz9HSUayXcMPwsK7jlqI9b+E7i11252YNtRRZm7kVy 9MB/wUzAorkoN7bTxWJKg65hVNPEyumoxdmCjkTOexxnRx1TYgxCkec1tGVudv50b9qL mpTxU1WU+FGoB7pEE9tZZyeP3r7qGUXMmM5mdXYcRibPeryZS+InlD9YIQeLa4z6x84b dsDQ== X-Gm-Message-State: AG10YOSEQQOfSiJoFB7fPrHNrTaDHKUbhUvj/MiMsqW+K43S168aBy/JSSreu0ZyEtx9jACH5Uo= X-Received: by 10.194.21.101 with SMTP id u5mr3319868wje.53.1453464977224; Fri, 22 Jan 2016 04:16:17 -0800 (PST) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id t3sm5727382wjz.11.2016.01.22.04.16.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jan 2016 04:16:16 -0800 (PST) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 22 Jan 2016 12:16:03 +0000 Message-Id: <1453464963-26449-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453390141-30539-1-git-send-email-zoltan.kiss@linaro.org> References: <1453390141-30539-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCH v3] 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() v3: fix code style 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..85d4924 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;