From patchwork Thu May 5 15:35:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 67210 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp815776qge; Thu, 5 May 2016 08:36:57 -0700 (PDT) X-Received: by 10.107.137.166 with SMTP id t38mr18289158ioi.31.1462462617465; Thu, 05 May 2016 08:36:57 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id oo7si4150599igb.67.2016.05.05.08.36.57; Thu, 05 May 2016 08:36:57 -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; 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; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id F28E0615CE; Thu, 5 May 2016 15:36:56 +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, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 D4ED961606; Thu, 5 May 2016 15:36:00 +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 6C546615E8; Thu, 5 May 2016 15:35:51 +0000 (UTC) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by lists.linaro.org (Postfix) with ESMTPS id 5AE8E615CE for ; Thu, 5 May 2016 15:35:48 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id g17so34140539wme.1 for ; Thu, 05 May 2016 08:35:48 -0700 (PDT) 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=YQGJn7MSuH0vdiHBbbJb7Q7GLv8XZmvTUH6flp9L3Ig=; b=GgWLDH2bdfgV6rLzndtWPUUuFLpuXV/rMVlOsjCFOx4rXZoGt1cFsaP1CeYPcczj3H 09lRPVoQ+icpJlnrmOcMNzi9jcsFp3CA19B8IGYattm1bhreYjDSJsgsz+wTx2tJ14y0 LpdqvLxnTvZFRU70LePQGMxTZqNGf3olcDRpkI4soG1xUL8CjaAp0upINEo1JpzhKR18 dZQohMMGl8jbI0vx/zdcs2jLI/E8PWPtxGYdzS/FQNBf8ANJnoMEXhbXKp+lOBL+gTOV YK3v0V2Z2gEUAC5MBw/x5lBchwTSX8KFded8kp+Ut7MNc976cyowKIza86AvTduqZsN6 aTvw== X-Gm-Message-State: AOPr4FWgUsaWOTssM2MkZ6XpEFYiByBEUCWDRC3mSjGUXKY2vj3lMk5Rrs6xCj+/kb77bv5iE1M= X-Received: by 10.28.230.137 with SMTP id e9mr4375523wmi.0.1462462547534; Thu, 05 May 2016 08:35:47 -0700 (PDT) Received: from localhost.localdomain ([195.11.233.227]) by smtp.googlemail.com with ESMTPSA id f8sm10302731wjm.13.2016.05.05.08.35.46 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 May 2016 08:35:46 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Thu, 5 May 2016 16:35:08 +0100 Message-Id: <1462462509-13337-3-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462462509-13337-1-git-send-email-zoltan.kiss@linaro.org> References: <1462462509-13337-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: Classification patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [PATCH v2 2/3] linux-generic: pktio: classification error handling fixes for loop 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" Several minor changes: - remove 'int j' as it no longer has function - add 'int failed' to count errors, and return it (or 0 if no failure) - in_errors counts the packet numbers, not the octets - in_discards the same, count it with 'discarded' - in_ucast_pkts should not count these packets - as a side effect, separate this code path from normal handling completely Signed-off-by: Zoltan Kiss --- v2: - rebase - fixs discards as well platform/linux-generic/pktio/loop.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index f7ccbd9..f4883c1 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -51,7 +51,7 @@ static int loopback_close(pktio_entry_t *pktio_entry) static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[], unsigned len) { - int nbr, i, j; + int nbr, i; odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX]; queue_entry_t *qentry; odp_packet_hdr_t *pkt_hdr; @@ -72,7 +72,8 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[], } if (pktio_cls_enabled(pktio_entry)) { - for (i = 0, j = 0; i < nbr; i++) { + int failed = 0, discarded = 0; + for (i = 0; i < nbr; i++) { int ret; pkt = _odp_packet_from_buffer(odp_hdr_to_buf (hdr_tbl[i])); @@ -87,18 +88,19 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[], odp_packet_len(pkt); break; case -ENOENT: - pktio_entry->s.stats.in_discards += - odp_packet_len(pkt); + discarded++; break; case -EFAULT: - pktio_entry->s.stats.in_errors += - odp_packet_len(pkt); + failed++; break; default: ret = queue_enq(qentry, hdr_tbl[i], 0); } } - nbr = j; + pktio_entry->s.stats.in_errors += failed; + pktio_entry->s.stats.in_discards += discarded; + pktio_entry->s.stats.in_ucast_pkts += nbr - failed - discarded; + return -failed; } else { for (i = 0; i < nbr; ++i) { pkts[i] = _odp_packet_from_buffer(odp_hdr_to_buf @@ -110,11 +112,9 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[], pktio_entry->s.stats.in_octets += odp_packet_len(pkts[i]); } + pktio_entry->s.stats.in_ucast_pkts += nbr; + return nbr; } - - pktio_entry->s.stats.in_ucast_pkts += nbr; - - return nbr; } static int loopback_send(pktio_entry_t *pktio_entry,