From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ob0-f171.google.com (mail-ob0-f171.google.com [209.85.214.171]) by dpdk.org (Postfix) with ESMTP id 46523C338 for ; Wed, 3 Jun 2015 21:19:30 +0200 (CEST) Received: by obew15 with SMTP id w15so16081421obe.1 for ; Wed, 03 Jun 2015 12:19:29 -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=VnScuhj7lLiBxNeYeC0vjaRXk4ioS9PLptdmbjQzdhQ=; b=N9DkJQB9I1lvmU4oiicMd9KZUOstXvtNW+ffW8vXCqd+vtI7uLE3f8T5b0aRJoNs79 H4Qxe6DpaBlPKCehgs9/RqwlXWYBzKWWOydy4Ge0i3IpXvli/bHqPYeP5AhkfnaAC1/B M2W0CrOH/2Efg3XoI52njmlucgMyjrRo09loi+knyveG2GxLCKWnqJn+ZKer+LX8q6Me ylbcIBncEeIR9fRY7JpcEemGPqvkKMutv+FKQTlKTRDHN/gOkCqKOzOKkCYArItpL3T5 X76uVbWYW7MPIBr8fT38wkKOSyk5B42sORz+zZSKsMmQAOF7mAYXASQPEIy0PkI2thUO fg/Q== X-Gm-Message-State: ALoCoQkU3pfSY1/nwN5FA2eReBRKbH1YSD69tRzbAse4TUXdAZnLKAUJYPPdHPOJcIsgSPQFI/nc X-Received: by 10.182.102.162 with SMTP id fp2mr28782427obb.39.1433359169641; Wed, 03 Jun 2015 12:19:29 -0700 (PDT) Received: from localhost.localdomain (rrcs-97-77-120-78.sw.biz.rr.com. [97.77.120.78]) by mx.google.com with ESMTPSA id c9sm12039646oih.11.2015.06.03.12.19.27 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jun 2015 12:19:28 -0700 (PDT) From: Jay Rolette To: dev@dpdk.org Date: Wed, 3 Jun 2015 14:18:56 -0500 Message-Id: <1433359137-12720-2-git-send-email-rolette@infiniteio.com> X-Mailer: git-send-email 2.3.2 (Apple Git-55) In-Reply-To: <1433359137-12720-1-git-send-email-rolette@infiniteio.com> References: <1433359137-12720-1-git-send-email-rolette@infiniteio.com> Subject: [dpdk-dev] [PATCH 2/3] kni: minor opto X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2015 19:19:30 -0000 No reason to check out many entries are in kni->rx_q prior to actually pulling them from the fifo. You can't dequeue more than are there anyway. Max entries to dequeue is either the max batch size or however much space is available on kni->free_q (lesser of the two) Signed-off-by: Jay Rolette --- lib/librte_eal/linuxapp/kni/kni_net.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index dd95db5..13ccbb8 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -131,7 +131,7 @@ kni_net_rx_normal(struct kni_dev *kni) { unsigned ret; uint32_t len; - unsigned i, num, num_rq, num_fq; + unsigned i, num, num_fq; struct rte_kni_mbuf *kva; struct rte_kni_mbuf *va[MBUF_BURST_SZ]; void * data_kva; @@ -139,24 +139,19 @@ kni_net_rx_normal(struct kni_dev *kni) struct sk_buff *skb; struct net_device *dev = kni->net_dev; - /* Get the number of entries in rx_q */ - num_rq = kni_fifo_count(kni->rx_q); - /* Get the number of free entries in free_q */ - num_fq = kni_fifo_free_count(kni->free_q); - - /* Calculate the number of entries to dequeue in rx_q */ - num = min(num_rq, num_fq); - num = min(num, (unsigned)MBUF_BURST_SZ); - - /* Return if no entry in rx_q and no free entry in free_q */ - if (num == 0) + if ((num_fq = kni_fifo_free_count(kni->free_q)) == 0) { + /* No room on the free_q, bail out */ return; + } + + /* Calculate the number of entries to dequeue from rx_q */ + num = min(num_fq, (unsigned)MBUF_BURST_SZ); /* Burst dequeue from rx_q */ ret = kni_fifo_get(kni->rx_q, (void **)va, num); if (ret == 0) - return; /* Failing should not happen */ + return; /* Transfer received packets to netif */ for (i = 0; i < num; i++) { -- 2.3.2 (Apple Git-55)