From patchwork Tue Jul 7 12:17:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 50817 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D332D229FC for ; Tue, 7 Jul 2015 12:17:31 +0000 (UTC) Received: by lagc2 with SMTP id c2sf12324146lag.0 for ; Tue, 07 Jul 2015 05:17:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=DSKqlfJBMTQMTjzuLxKGeeJKyQIkAGU6UnjgH77YFgU=; b=aekcfjuCo2cnL41pPDQLLKYRAZ6lYRj1M7MSPqdEUG6iyjeF5V1p7X1ftmHFyPACci WyVsIKzsvSiwgSfB1mgJkZwo9f8QFovQtLQw+TKFZaf5+UQZFp8zAbl/lFVRFXAptfyh iGhgegZXi5J1n0jdVl8D5Vw4sXduIUMs+Y77UDULZYHvPr+Gagw51bS+Q8krhaq2lZIM x73M/omjV04qmE3gz+V7wwtlbfpiV60hctnadCIrJONopcIy73Hy8wQWzKfLx6jRFepe gLdXdFi8izXHEAjVCypjqyM/+sC4o2xYr1qKIpfFA6Xl9U3l+jiGJ/GIHyG6z2nFR3XT rCxw== X-Gm-Message-State: ALoCoQkQYb5JhM56vOrlABcnSxJP7jr4QID4Okd+spJU5NwVtcBVMB+7wqwf4wXMBDQejUcVc9oJ X-Received: by 10.112.85.69 with SMTP id f5mr2017022lbz.23.1436271450745; Tue, 07 Jul 2015 05:17:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.146 with SMTP id j18ls799271laa.22.gmail; Tue, 07 Jul 2015 05:17:30 -0700 (PDT) X-Received: by 10.112.146.97 with SMTP id tb1mr3896659lbb.12.1436271450582; Tue, 07 Jul 2015 05:17:30 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id s6si17964903las.169.2015.07.07.05.17.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2015 05:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lagx9 with SMTP id x9so192500481lag.1 for ; Tue, 07 Jul 2015 05:17:30 -0700 (PDT) X-Received: by 10.112.128.169 with SMTP id np9mr3745551lbb.73.1436271450461; Tue, 07 Jul 2015 05:17:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2349128lbb; Tue, 7 Jul 2015 05:17:29 -0700 (PDT) X-Received: by 10.140.104.147 with SMTP id a19mr6287639qgf.71.1436271448834; Tue, 07 Jul 2015 05:17:28 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e207si24623006qhc.3.2015.07.07.05.17.27; Tue, 07 Jul 2015 05:17:28 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id 81B3661DD5; Tue, 7 Jul 2015 12:17:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 8B05C61C65; Tue, 7 Jul 2015 12:17:23 +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 A30F461CCB; Tue, 7 Jul 2015 12:17:21 +0000 (UTC) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by lists.linaro.org (Postfix) with ESMTPS id CCA7161B80 for ; Tue, 7 Jul 2015 12:17:20 +0000 (UTC) Received: by wgbgr6 with SMTP id gr6so12291139wgb.3 for ; Tue, 07 Jul 2015 05:17:19 -0700 (PDT) X-Received: by 10.180.206.229 with SMTP id lr5mr99800284wic.86.1436271439739; Tue, 07 Jul 2015 05:17:19 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by mx.google.com with ESMTPSA id eu2sm33566142wic.8.2015.07.07.05.17.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jul 2015 05:17:18 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 7 Jul 2015 15:17:13 +0300 Message-Id: <1436271433-24698-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCHv2] linux-generic: check for event type while converting packet to event X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 All examples of odp code do not check odp_schedule() output, I.e.: ev = odp_schedule() pkt = odp_packet_from_event(ev) Because of ev can be not only packet (timer, crypto operation), add check that only packet event can be converted to packet. Signed-off-by: Maxim Uvarov --- platform/linux-generic/include/odp_packet_internal.h | 5 +++++ platform/linux-generic/odp_crypto.c | 2 +- platform/linux-generic/odp_packet.c | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 8c41491..3d43b25 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -258,6 +258,11 @@ static inline void _odp_packet_reset_parse(odp_packet_t pkt) pkt_hdr->input_flags.all = ODP_PACKET_UNPARSED; } +static inline odp_packet_t _odp_packet_from_event(odp_event_t ev) +{ + return (odp_packet_t)ev; +} + /* Forward declarations */ int _odp_packet_copy_to_packet(odp_packet_t srcpkt, uint32_t srcoffset, odp_packet_t dstpkt, uint32_t dstoffset, diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index d49e256..7a619e0 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -40,7 +40,7 @@ static odp_crypto_global_t *global; static odp_crypto_generic_op_result_t *get_op_result_from_event(odp_event_t ev) { - return &(odp_packet_hdr(odp_packet_from_event(ev))->op_result); + return &(odp_packet_hdr(_odp_packet_from_event(ev))->op_result); } static diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 668ddda..062ad7e 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -77,7 +77,12 @@ odp_buffer_t _odp_packet_to_buffer(odp_packet_t pkt) odp_packet_t odp_packet_from_event(odp_event_t ev) { - return (odp_packet_t)ev; +#ifdef ODP_DEBUG + if (odp_unlikely(odp_event_type(ev) != ODP_EVENT_PACKET)) + ODP_ABORT("Dispatching not packet event %d\n", + odp_event_type(ev)); +#endif + return _odp_packet_from_event(ev); } odp_event_t odp_packet_to_event(odp_packet_t pkt)