From patchwork Tue Dec 9 12:23:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 5462401 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0921CBEEA8 for ; Tue, 9 Dec 2014 12:24:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 202DC2011D for ; Tue, 9 Dec 2014 12:24:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C2A4200D9 for ; Tue, 9 Dec 2014 12:24:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756767AbaLIMX7 (ORCPT ); Tue, 9 Dec 2014 07:23:59 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:50649 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756257AbaLIMX6 (ORCPT ); Tue, 9 Dec 2014 07:23:58 -0500 Received: by mail-pd0-f182.google.com with SMTP id p10so460476pdj.27 for ; Tue, 09 Dec 2014 04:23:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=FcMkvvhHiZ/7Xd8BKbVDnu4ub5oABqBpuhBBZ4El6TE=; b=yAsXpvD1rTw6BJ+/vqXoMIVXH9d3IhTteDkF54MOeQVS6drRyZ/KVvm47KEK4jFk1y yhS+W+ombFEwVGBdGFKUMZFZ2ujIAkI1ltneI63+yqXo5p8khIAyi5R/dVYaFoyFydQG p/97mVyFeXPRy8b8L8f2rZ+whzcBVPjRTH92fkCT+TZLN8EkbVt0ihw89JYLPOqRc80A YUAmpIkwyWUSX+BIfoGwZxwWXjCb34Dk2ae+TsKF/0jnI0ZLdyCZnWtYTlIIhw5DkHlZ CMvUsKJSaUQMl967GON1srJTF2gdZY19OzqXASroOKLy/yjhwdGCla8YXdNXVS4+Q226 5SHg== X-Received: by 10.66.235.37 with SMTP id uj5mr5035657pac.72.1418127838318; Tue, 09 Dec 2014 04:23:58 -0800 (PST) Received: from localhost.localdomain (p5095-ipngn6701marunouchi.tokyo.ocn.ne.jp. [153.174.4.95]) by mx.google.com with ESMTPSA id my2sm1359526pdb.86.2014.12.09.04.23.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Dec 2014 04:23:57 -0800 (PST) From: Yoshihiro Kaneko To: netdev@vger.kernel.org Cc: "David S. Miller" , Simon Horman , Magnus Damm , linux-sh@vger.kernel.org Subject: [PATCH v3] sh_eth: Optimization for RX excess judgement Date: Tue, 9 Dec 2014 21:23:42 +0900 Message-Id: <1418127822-16904-1-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mitsuhiro Kimura Both of 'boguscnt' and 'quota' have nearly meaning as the condition of the reception loop. In order to cut down redundant processing, this patch changes excess judgement. Signed-off-by: Mitsuhiro Kimura Signed-off-by: Yoshihiro Kaneko --- This patch is based on net-next tree. v3 [Yoshihiro Kaneko] * fixes the calculation error of *quota. v2 [Yoshihiro Kaneko] * re-spin for net-next. * remove unneeded check of "quota". * remove unneeded incrementation of "boguscnt". * drop the change of the return statement. drivers/net/ethernet/renesas/sh_eth.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index dbe8606..f94bbf5 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1394,10 +1394,13 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) int entry = mdp->cur_rx % mdp->num_rx_ring; int boguscnt = (mdp->dirty_rx + mdp->num_rx_ring) - mdp->cur_rx; + int limit; struct sk_buff *skb; u16 pkt_len = 0; u32 desc_status; + boguscnt = min(boguscnt, *quota); + limit = boguscnt; rxdesc = &mdp->rx_ring[entry]; while (!(rxdesc->status & cpu_to_edmac(mdp, RD_RACT))) { desc_status = edmac_to_cpu(mdp, rxdesc->status); @@ -1406,11 +1409,6 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) if (--boguscnt < 0) break; - if (*quota <= 0) - break; - - (*quota)--; - if (!(desc_status & RDFEND)) ndev->stats.rx_length_errors++; @@ -1501,6 +1499,8 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) sh_eth_write(ndev, EDRRR_R, EDRRR); } + *quota -= limit - boguscnt - 1; + return *quota <= 0; }