From patchwork Fri Jan 12 16:00:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124367 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2223394qgn; Fri, 12 Jan 2018 08:03:10 -0800 (PST) X-Google-Smtp-Source: ACJfBosSk3V+E8kr+y2g1R1Z69M6FGoWuESKy44eB5GxgDCSejBfE9U5/vCn1gljD/lALx208reL X-Received: by 10.55.190.129 with SMTP id o123mr38030880qkf.333.1515772990327; Fri, 12 Jan 2018 08:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515772990; cv=none; d=google.com; s=arc-20160816; b=y6LcgbYWyg5UuWjEGJXlOYbAE9Adq4vQA7qE+iXlm36FqakQU0Wu59syAdRqcSxS81 Dx4we/ssBr/L6VsjOMZheVv+31Z8QvX2undMz9hOiovlTvceh+L1H83mF8GeQ+YjAPV5 1dhJgXQUjiCAyLnWEs+b6iD2EILsojz59S3mJmYYTDzfIcGYLQMvMPdVHbItATkV/R85 hqS3Sh6+1b3A466sF2loAi2EjintMR1B3yQUsTObKvOgCswHquZO8bTIgjWr5YpiX2FU UC5yHTzGe2uqG3Ni+XMSMdkxsWhCBo2Q//JJEx3OsfRm7EhxNvxSzIcziUOYka/Hbgnc BIng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=2bpYW7M4r7gsLLPmL1s80/VtfsnXtiOWonRfrhHfXk0=; b=X96yAwbPfRQ/7ZPvd96Dio/zdgLq2lW4RbFzp7n0AsTX1ZOUCvALAKFakPeOH9epLi 5hcUBvMpZWc6sxvJzQ6OuyYw0IQxfRC1sslIugLkb8l6OdqHmTL2JDNt+hcVlYq0WYJ5 krd2Iftxtoaeu8WS3OlX9bhMd9cCB0/Dw1s7//ngtPNSLC+/vQ5vjZOZtvDAB17XrDWT uIKS8lkDH3dotmrGuzOeZrGQrswFkTgLpMGNmoayr3WxeJqyRoIU31fm+Vcmtzs/5RP3 +WL3g1eDLOE+PXSSW6VKGSWfSx+gReK58IvibldntMWrdOrVcxcLAANaiRh2LMkrWRFW BCkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id m4si2314143qkc.171.2018.01.12.08.03.10; Fri, 12 Jan 2018 08:03:10 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 03D70616F5; Fri, 12 Jan 2018 16:03:10 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 63D0961725; Fri, 12 Jan 2018 16:01:14 +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 C216960961; Fri, 12 Jan 2018 16:00:56 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 1010E6171C for ; Fri, 12 Jan 2018 16:00:18 +0000 (UTC) Received: from mxback6o.mail.yandex.net (mxback6o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::20]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 25CE72D808C0 for ; Fri, 12 Jan 2018 19:00:16 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback6o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id VqyBBKAiMV-0GVmlLVm; Fri, 12 Jan 2018 19:00:16 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id rFPUuYkDkq-0FhKKC1Z; Fri, 12 Jan 2018 19:00:15 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 12 Jan 2018 19:00:10 +0300 Message-Id: <1515772811-30441-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515772811-30441-1-git-send-email-odpbot@yandex.ru> References: <1515772811-30441-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 388 Subject: [lng-odp] [PATCH API-NEXT v1 4/5] linux-gen: packet: initialize user ptr to NULL 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Use a flag to record if user pointer has been set. This avoids resetting the pointer in every alloc. Signed-off-by: Petri Savolainen --- /** Email created from pull request 388 (psavol:next-user-ptr-init) ** https://github.com/Linaro/odp/pull/388 ** Patch: https://github.com/Linaro/odp/pull/388.patch ** Base sha: 6303c7d0e98fafe0f14c8c4dd9989b3b7633ebf4 ** Merge commit sha: 9eaabe631329dd5cc41960f7cfb5592d60ff0499 **/ platform/linux-generic/include/odp/api/plat/packet_inlines.h | 7 +++++++ platform/linux-generic/include/odp/api/plat/packet_types.h | 12 +++++++++--- platform/linux-generic/odp_packet.c | 8 ++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index b00b9c923..64c12377b 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -98,6 +98,13 @@ static inline int _odp_packet_num_segs(odp_packet_t pkt) /** @internal Inline function @param pkt @return */ static inline void *_odp_packet_user_ptr(odp_packet_t pkt) { + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + + if (flags.user_ptr_set == 0) + return NULL; + return _odp_pkt_get(pkt, void *, user_ptr); } diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h index 14810e585..79398f1bc 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_types.h @@ -91,6 +91,7 @@ typedef struct _odp_packet_inline_offset_t { uint16_t flow_hash; uint16_t timestamp; uint16_t input_flags; + uint16_t flags; } _odp_packet_inline_offset_t; @@ -156,7 +157,12 @@ typedef union { uint32_t all_flags; struct { - uint32_t reserved1: 12; + uint32_t reserved1: 11; + + /* + * Init flags + */ + uint32_t user_ptr_set: 1; /* Ptr has been set vs. NULL */ /* * Packet output flags @@ -182,8 +188,8 @@ typedef union { /* Flag groups */ struct { - uint32_t reserved2: 12; - uint32_t other: 12; /* All other flags */ + uint32_t reserved2: 11; + uint32_t other: 13; /* All other flags */ uint32_t error: 8; /* All error flags */ } all; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index ada5dca47..c2e05801e 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -42,7 +42,8 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = { .l4_offset = offsetof(odp_packet_hdr_t, p.l4_offset), .flow_hash = offsetof(odp_packet_hdr_t, flow_hash), .timestamp = offsetof(odp_packet_hdr_t, timestamp), - .input_flags = offsetof(odp_packet_hdr_t, p.input_flags) + .input_flags = offsetof(odp_packet_hdr_t, p.input_flags), + .flags = offsetof(odp_packet_hdr_t, p.flags) }; @@ -1259,7 +1260,10 @@ int odp_packet_input_index(odp_packet_t pkt) void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ptr) { - packet_hdr(pkt)->buf_hdr.user_ptr = ptr; + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + + pkt_hdr->buf_hdr.user_ptr = ptr; + pkt_hdr->p.flags.user_ptr_set = 1; } int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset)