From patchwork Thu Mar 19 19:13:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 46076 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 39AD22153C for ; Thu, 19 Mar 2015 19:14:27 +0000 (UTC) Received: by lbvn10 with SMTP id n10sf14190656lbv.1 for ; Thu, 19 Mar 2015 12:14:26 -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=lyjdtdj24LLX7m4UBHdBcWZPT7x2L+Inq3030TSJZujfo81isZT+BgZ9x5YXN2iX3K Uf35Ty181wlsYhN9vcPk/7i82ToRcpjoXT6dDup6gpMrSFRirYcuazHIMLVvS7ygF/Le ePskHg78Up+sdS0jpA7jqhDJsMGg4oZzjc+c2+eCnykHPPIZJiAoXnlwaHtIkIIizwW0 jtBC6rZtpIRgDMBkvcYIfkrBEpJZUkUq9N/W/os5EIPA2kJ3JFhqahGW7dnE8i0iXzt9 AO5lO69NI2kIYzPOpYgLqfet9d40Ix7UwMeVhO7IXVhqxI3qv+Z+ocL6+sLMNkrfDfLM MkQw== X-Gm-Message-State: ALoCoQm4GXVQr19SJkTPwbo8msmO0pB+Bs+UfwCFhzE7ZHRHCUrBossShH8KDRA28NQ95sXPGgJ0 X-Received: by 10.180.182.201 with SMTP id eg9mr2051821wic.3.1426792466167; Thu, 19 Mar 2015 12:14:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.181.137 with SMTP id dw9ls305388lac.85.gmail; Thu, 19 Mar 2015 12:14:26 -0700 (PDT) X-Received: by 10.112.133.2 with SMTP id oy2mr18239156lbb.124.1426792465998; Thu, 19 Mar 2015 12:14:25 -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 p2si1612319lag.109.2015.03.19.12.14.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2015 12:14:25 -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 lagg8 with SMTP id g8so70288966lag.1 for ; Thu, 19 Mar 2015 12:14:25 -0700 (PDT) X-Received: by 10.152.26.201 with SMTP id n9mr69241114lag.29.1426792465869; Thu, 19 Mar 2015 12:14:25 -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.35.133 with SMTP id h5csp588988lbj; Thu, 19 Mar 2015 12:14:25 -0700 (PDT) X-Received: by 10.229.184.66 with SMTP id cj2mr97020368qcb.6.1426792464649; Thu, 19 Mar 2015 12:14:24 -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 b79si2092812qge.107.2015.03.19.12.14.23 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 19 Mar 2015 12:14:24 -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 1YYftd-0001Br-GN; Thu, 19 Mar 2015 19:14:21 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YYftR-0001AP-1J for lng-odp@lists.linaro.org; Thu, 19 Mar 2015 19:14:09 +0000 Received: by wibg7 with SMTP id g7so14844743wib.1 for ; Thu, 19 Mar 2015 12:14:03 -0700 (PDT) X-Received: by 10.180.184.136 with SMTP id eu8mr18909869wic.45.1426792443521; Thu, 19 Mar 2015 12:14:03 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id s19sm8680658wik.18.2015.03.19.12.14.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Mar 2015 12:14:02 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Thu, 19 Mar 2015 19:13:42 +0000 Message-Id: <1426792426-12507-3-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426792426-12507-1-git-send-email-zoltan.kiss@linaro.org> References: <1426792426-12507-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 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;