From patchwork Thu Nov 13 07:00:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 5293861 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 018CC9F440 for ; Thu, 13 Nov 2014 07:01:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2ED27201E4 for ; Thu, 13 Nov 2014 07:01:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2231201C7 for ; Thu, 13 Nov 2014 07:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751730AbaKMHBX (ORCPT ); Thu, 13 Nov 2014 02:01:23 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:38772 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbaKMHBW (ORCPT ); Thu, 13 Nov 2014 02:01:22 -0500 Received: by mail-pa0-f48.google.com with SMTP id rd3so1128082pab.7 for ; Wed, 12 Nov 2014 23:01:22 -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=anoeShSQ8cIdks+GqxaDEV+izFOr2UjJGoZxttFVPHs=; b=bMjRlEib5Y7oP9//brbJaONH/P0MuNsVbo0R0AmU8RW9R3jqsDsYZVNTn1QZdf0qCr FsxyKIHaw8HSWMuYCdc7TgTqyW7VdN3zoxpcyt1CbKVuJi3mIpiNPp8Wx9ZGuyaYEwFU WfZ+wi+m8VYwaFk/wqhSZMp7f8dwuRHdfApncXyRY94Kt6pfO5N86YG7RjFcucfHN/1l Zs9i8l9fnavrwHmIGzc42ZFPpqOKlNnchRHn6kMzUSP2evBKl0aFP/mvaGrrUH5S8LuQ rxx+aiAWhE0MlVFDe7e5WjhHxDNy7/Zx7mKxEjyUYrf1J51wBt8CG0EuLDwxq6tp7gjW /Rrg== X-Received: by 10.68.213.138 with SMTP id ns10mr767347pbc.50.1415862082162; Wed, 12 Nov 2014 23:01:22 -0800 (PST) Received: from localhost.localdomain (p5095-ipngn6701marunouchi.tokyo.ocn.ne.jp. [153.174.4.95]) by mx.google.com with ESMTPSA id h3sm23968721pdl.22.2014.11.12.23.01.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Nov 2014 23:01:21 -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] sh_eth: Optimization for RX excess judgement Date: Thu, 13 Nov 2014 16:00:31 +0900 Message-Id: <1415862031-27925-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=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 tree. drivers/net/ethernet/renesas/sh_eth.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 60e9c2c..7d46326 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1394,10 +1394,15 @@ 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 = boguscnt; struct sk_buff *skb; u16 pkt_len = 0; u32 desc_status; + if (quota) { + 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 +1411,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,7 +1501,10 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) sh_eth_write(ndev, EDRRR_R, EDRRR); } - return *quota <= 0; + if (quota) + *quota -= limit - (++boguscnt); + + return (boguscnt <= 0); } static void sh_eth_rcv_snd_disable(struct net_device *ndev)