From patchwork Mon Jan 22 10:00:18 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: 125375 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1068233ljf; Mon, 22 Jan 2018 02:03:53 -0800 (PST) X-Google-Smtp-Source: AH8x227VxyJefdkxXa+5ZRBg8K6PPw7LBvofx2LqfA3jDMG8tJRN4hSuuiaTevFQfaizOdRrllU0 X-Received: by 10.55.105.129 with SMTP id e123mr8226275qkc.192.1516615433381; Mon, 22 Jan 2018 02:03:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516615433; cv=none; d=google.com; s=arc-20160816; b=mB+mTuosmpC3i7rqpsp3xjYa3yKzamA/l0y4KOR2rAlRCqaT3fQOYLMLBsKrHwG1Bq hJ6kSk/Gm4iEYC3m5Dm3UVJDNDPeriwDuq36yZa0ezx3ZTnq778RJKKoyD2lDnKzfsWt euLViThwO8XuySA3ejgP2EZpSXYK6ai3qbju69BFe2rTIzcq1eNujKnhgWW6E+GENe3m XpSCULK1VR5pyj6Msd1JMCP95hpiQF9f5kJzeLLwaRVDcgd/eBAIqYlPjy/uyQf3TbyQ bw/ob7wpef7WGLNU1e4AVtGbgU/3ODcsIbV3ZTUDt0arZ0Tzeg8B+6IvI8eUju7mID4n Q5xQ== 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=kJUW2BIuvf8yc2OEUNnLsi97tlxUoClY9bbZNQ4wTzg=; b=FObcGIBH1I4dDuatYy75KZa+5CTl3fgBE6kHOyA/KIK7oka/D5AF+Ka2YHaJMMl34d Iik0t0O3wRdmZo4lh8Q+8boh/RuwFzL1mviyk65w3TA5vgK1qvcUVVPms5qRPfVuqjTK Um2vRMsmolSQnn9+waE0SjK8xKPaXzKiIwvHNsbgvgqC+bXF6VCmD0QEAwJZe798t7C7 g3g71gOI+xPjXRmfrv2LXsYDfAJzFGo0wlVWIgycQDByTcUFWM5487wNGZgapT3N8PJd voO7h2+vFVfOSD9nKM9QG7vdrLaSwKgS88soMr+K3lUGQsL0vPCd83Dmefk7wWmWWxFE YGnw== 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 t22si11001622qtj.413.2018.01.22.02.03.53; Mon, 22 Jan 2018 02:03:53 -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 1CA35617F8; Mon, 22 Jan 2018 10:03:53 +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 1F119617C8; Mon, 22 Jan 2018 10:00:55 +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 2FC3C607B5; Mon, 22 Jan 2018 10:00:32 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 5464860997 for ; Mon, 22 Jan 2018 10:00:25 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 28FC92D83173 for ; Mon, 22 Jan 2018 13:00:24 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 0RrQTfvegv-0OdmLVft; Mon, 22 Jan 2018 13:00:24 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id uZYuxzgHNY-0NH8VSfY; Mon, 22 Jan 2018 13:00:23 +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: Mon, 22 Jan 2018 13:00:18 +0300 Message-Id: <1516615219-32202-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516615219-32202-1-git-send-email-odpbot@yandex.ru> References: <1516615219-32202-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 392 Subject: [lng-odp] [PATCH API-NEXT v2 5/6] 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 392 (psavol:next-user-ptr-init-rebase) ** https://github.com/Linaro/odp/pull/392 ** Patch: https://github.com/Linaro/odp/pull/392.patch ** Base sha: f925f103c90591776f73863d30159357b08bf71e ** Merge commit sha: 81c268611ef9755e8347f532022e22148f7d2a09 **/ .../include/odp/api/plat/packet_inline_types.h | 12 +++++++++--- .../linux-generic/include/odp/api/plat/packet_inlines.h | 7 +++++++ platform/linux-generic/odp_packet.c | 13 +++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h index dbfc66411..e8ebdabb1 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h @@ -44,6 +44,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; @@ -109,7 +110,12 @@ typedef union { uint32_t all_flags; struct { - uint32_t reserved1: 12; + uint32_t reserved1: 11; + + /* + * Init flags + */ + uint32_t user_ptr_set: 1; /* User has set a non-NULL value */ /* * Packet output flags @@ -135,8 +141,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/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 3416b9949..fe22d70a8 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -102,6 +102,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/odp_packet.c b/platform/linux-generic/odp_packet.c index 033981dc2..ec460ea04 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_ALIGNED_CACHE _odp_packet_inline = { .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,15 @@ 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); + + if (odp_unlikely(ptr == NULL)) { + pkt_hdr->p.flags.user_ptr_set = 0; + return; + } + + 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)