From patchwork Thu Mar 26 19:23:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 46381 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 4DC1821585 for ; Thu, 26 Mar 2015 19:24:25 +0000 (UTC) Received: by labow10 with SMTP id ow10sf7952004lab.1 for ; Thu, 26 Mar 2015 12:24:24 -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:from:to:date:message-id:in-reply-to :references: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=LxUUqIEyQLAHt0n3wb0U5qYS7gweD0ff2h0hj976qy8=; b=bX3er/JKCl5NVFmR5v1l3yOF2n4PYY7RTGNF6wef9VQX5VPkL4KLEscZ4haFu7tLSN NqTt5tF5gvlAD/k5XjohJ2fu4mDB7iWaPJNrhvaWgnTUEMb0BiVFa6vpQvzsl5TIDGfa /pmdsJ0Uh5NPoGu4iOuAx2v6VT+grXCZLSeAt/tv8LfrU2zgNBqukSDGKvjWKnhCyliX oNiZ8K93ltpaZFPZZ8HPTC3lbaTbtoMlZbrRR4IR8KiMyaQ8ZH2xiciNTVapUkYtr23+ kjLmbVNRQbJX9U1xg0sWvDQHEM2rjpNOlaWORfTs9TKRcIhFe2q4Ta5taLj1wyP3lJlP C5FQ== X-Gm-Message-State: ALoCoQkYTE7sJofVtw9Fk3G1zbdfesBqTcI30HSaplxgzOBA3xBytsgTdNRRPGd36bdv8Uu4Zy8W X-Received: by 10.152.88.33 with SMTP id bd1mr3761878lab.2.1427397864289; Thu, 26 Mar 2015 12:24:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.97 with SMTP id it1ls298374lac.1.gmail; Thu, 26 Mar 2015 12:24:24 -0700 (PDT) X-Received: by 10.112.141.202 with SMTP id rq10mr14771443lbb.88.1427397864115; Thu, 26 Mar 2015 12:24:24 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id s10si5343379lae.17.2015.03.26.12.24.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Mar 2015 12:24:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by lahp7 with SMTP id p7so34901836lah.2 for ; Thu, 26 Mar 2015 12:24:23 -0700 (PDT) X-Received: by 10.152.197.34 with SMTP id ir2mr14723824lac.36.1427397863696; Thu, 26 Mar 2015 12:24:23 -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.57.201 with SMTP id k9csp813570lbq; Thu, 26 Mar 2015 12:24:22 -0700 (PDT) X-Received: by 10.140.236.151 with SMTP id h145mr21102669qhc.9.1427397862321; Thu, 26 Mar 2015 12:24:22 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id t74si5899991qga.36.2015.03.26.12.24.21 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 26 Mar 2015 12:24:22 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YbDO7-0000Bl-As; Thu, 26 Mar 2015 19:24:19 +0000 Received: from mail-wg0-f48.google.com ([74.125.82.48]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YbDNY-00006Z-MD for lng-odp@lists.linaro.org; Thu, 26 Mar 2015 19:23:44 +0000 Received: by wgra20 with SMTP id a20so75373953wgr.3 for ; Thu, 26 Mar 2015 12:23:39 -0700 (PDT) X-Received: by 10.195.12.97 with SMTP id ep1mr31769590wjd.134.1427397819291; Thu, 26 Mar 2015 12:23:39 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id g5sm9673433wjr.19.2015.03.26.12.23.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2015 12:23:38 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Thu, 26 Mar 2015 19:23:21 +0000 Message-Id: <1427397805-27395-3-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427397805-27395-1-git-send-email-zoltan.kiss@linaro.org> References: <1427397805-27395-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v2 2/6] netdev-odp: refactor error handling in netdev_odp_rxq_recv X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zoltan.kiss@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.53 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 Refactor how odp_pktio_recv errors handled, including: - use OVS_(UN)LIKELY - set *c in error cases - some code style fix at the definitions - remove stale printf from the end Signed-off-by: Zoltan Kiss --- lib/netdev-odp.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c index a7968dc..385401f 100644 --- a/lib/netdev-odp.c +++ b/lib/netdev-odp.c @@ -581,27 +581,28 @@ netdev_odp_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets, struct netdev_odp *netdev = netdev_odp_cast(rx->up.netdev); int pkts, pkts_ok, ret = 0; size_t rx_bytes = 0; - unsigned long err_cnt = 0; - int i; - odp_packet_t pkt_tbl[NETDEV_MAX_RX_BATCH]; + unsigned long err_cnt = 0; + int i; + odp_packet_t pkt_tbl[NETDEV_MAX_RX_BATCH]; pkts = odp_pktio_recv(netdev->pktio, pkt_tbl, NETDEV_MAX_RX_BATCH); - if (pkts < 0) { - return EINVAL; - } - if (!pkts) { - return EAGAIN; - } - - if (pkts > 0) { + if (OVS_LIKELY(pkts > 0)) { pkts_ok = drop_err_pkts(pkt_tbl, pkts); - if (odp_unlikely(pkts_ok != pkts)) - VLOG_ERR("Dropped frames:%u - err_cnt:%lu\n", + if (OVS_UNLIKELY(pkts_ok != pkts)) + VLOG_ERR_RL(&rl, "Dropped frames:%u - err_cnt:%lu\n", pkts-pkts_ok, ++err_cnt); - if (!pkts_ok) { + if (OVS_UNLIKELY(!pkts_ok)) { + VLOG_ERR_RL(&rl, "ODP: All %d packets dropped!\n", pkts); + *c = 0; ret = EAGAIN; goto out_stats; } + } else { + *c = 0; + if (!pkts) + return EAGAIN; + VLOG_ERR_RL(&rl, "ODP: Packet receive error (%d)\n", pkts); + return EINVAL; } /* Allocate an ofpbuf for each valid packet */ @@ -620,8 +621,6 @@ netdev_odp_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets, *c = pkts_ok; - printf("ODP: received %d packets\n", pkts_ok); - out_stats: ovs_mutex_lock(&netdev->mutex); netdev->stats.rx_packets += pkts_ok;