From patchwork Tue Mar 19 17:40:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Manoil X-Patchwork-Id: 229156 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8D4382C008A for ; Wed, 20 Mar 2013 04:41:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933170Ab3CSRk5 (ORCPT ); Tue, 19 Mar 2013 13:40:57 -0400 Received: from tx2ehsobe005.messaging.microsoft.com ([65.55.88.15]:49851 "EHLO tx2outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932483Ab3CSRk4 (ORCPT ); Tue, 19 Mar 2013 13:40:56 -0400 Received: from mail148-tx2-R.bigfish.com (10.9.14.232) by TX2EHSOBE014.bigfish.com (10.9.40.34) with Microsoft SMTP Server id 14.1.225.23; Tue, 19 Mar 2013 17:40:55 +0000 Received: from mail148-tx2 (localhost [127.0.0.1]) by mail148-tx2-R.bigfish.com (Postfix) with ESMTP id 801991E00BD; Tue, 19 Mar 2013 17:40:55 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h1ee6h1de0h1202h1e76h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah107ah11b5h121eh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14afh1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1155h) Received: from mail148-tx2 (localhost.localdomain [127.0.0.1]) by mail148-tx2 (MessageSwitch) id 1363714853837890_31419; Tue, 19 Mar 2013 17:40:53 +0000 (UTC) Received: from TX2EHSMHS015.bigfish.com (unknown [10.9.14.234]) by mail148-tx2.bigfish.com (Postfix) with ESMTP id C7856E00A7; Tue, 19 Mar 2013 17:40:53 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS015.bigfish.com (10.9.99.115) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 19 Mar 2013 17:40:53 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-005.039d.mgd.msft.net (10.84.1.17) with Microsoft SMTP Server (TLS) id 14.2.328.11; Tue, 19 Mar 2013 17:40:52 +0000 Received: from zro04cle141.ea.freescale.net (udp157456uds.ea.freescale.net [140.101.223.141]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r2JHepZj024188; Tue, 19 Mar 2013 10:40:51 -0700 Received: by zro04cle141.ea.freescale.net (Postfix, from userid 23113) id A2EBA40082; Tue, 19 Mar 2013 19:40:05 +0200 (EET) From: Claudiu Manoil To: CC: Paul Gortmaker , "David S. Miller" Subject: [PATCH 2/4][net-next] gianfar: Poll only active Rx queues Date: Tue, 19 Mar 2013 19:40:03 +0200 Message-ID: <1363714805-9142-3-git-send-email-claudiu.manoil@freescale.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1363714805-9142-1-git-send-email-claudiu.manoil@freescale.com> References: <1363714805-9142-1-git-send-email-claudiu.manoil@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.net Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Split the napi budget fairly among the active queues only, instead of dividing it by the total number of Rx queues assigned to the given interrupt group. Use the h/w indication field RXFi in rstat (receive status register) to identify the active rx queues from the current interrupt group (i.e. receive event occured on ring i, if ring i is part of the current interrupt group). This indication field in rstat, RXFi i=0..7, allows us to find out on which queues of the same interrupt group do we have incomming traffic once we entered the polling routine for the given interrupt group. After servicing the ring i, the corresponding bit RXFi will be written with 1 to clear the active queue indication for that ring. Signed-off-by: Claudiu Manoil --- drivers/net/ethernet/freescale/gianfar.c | 28 +++++++++++++++++++--------- drivers/net/ethernet/freescale/gianfar.h | 4 +++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 1e555a7..3f07dbd 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -2835,15 +2835,20 @@ static int gfar_poll(struct napi_struct *napi, int budget) int work_done = 0, work_done_per_q = 0; int i, budget_per_q; int has_tx_work; - unsigned long serviced_queues = 0; - int num_queues = gfargrp->num_rx_queues; + unsigned long rstat_rxf; + int num_act_queues; - budget_per_q = budget/num_queues; /* Clear IEVENT, so interrupts aren't called again * because of the packets that have already arrived */ gfar_write(®s->ievent, IEVENT_RTX_MASK); + rstat_rxf = gfar_read(®s->rstat) & RSTAT_RXF_MASK; + + num_act_queues = bitmap_weight(&rstat_rxf, MAX_RX_QS); + if (num_act_queues) + budget_per_q = budget/num_act_queues; + while (1) { has_tx_work = 0; for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) { @@ -2856,7 +2861,8 @@ static int gfar_poll(struct napi_struct *napi, int budget) } for_each_set_bit(i, &gfargrp->rx_bit_map, priv->num_rx_queues) { - if (test_bit(i, &serviced_queues)) + /* skip queue if not active */ + if (!(rstat_rxf & (RSTAT_CLEAR_RXF0 >> i))) continue; rx_queue = priv->rx_queue[i]; @@ -2866,20 +2872,24 @@ static int gfar_poll(struct napi_struct *napi, int budget) /* finished processing this queue */ if (work_done_per_q < budget_per_q) { - set_bit(i, &serviced_queues); - num_queues--; - if (!num_queues) + /* clear active queue hw indication */ + gfar_write(®s->rstat, + RSTAT_CLEAR_RXF0 >> i); + rstat_rxf &= ~(RSTAT_CLEAR_RXF0 >> i); + num_act_queues--; + + if (!num_act_queues) break; /* recompute budget per Rx queue */ budget_per_q = - (budget - work_done) / num_queues; + (budget - work_done) / num_act_queues; } } if (work_done >= budget) break; - if (!num_queues && !has_tx_work) { + if (!num_act_queues && !has_tx_work) { napi_complete(napi); diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index 63a28d2..b1d0c1c 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h @@ -291,7 +291,9 @@ extern const char gfar_driver_version[]; #define RCTRL_PADDING(x) ((x << 16) & RCTRL_PAL_MASK) -#define RSTAT_CLEAR_RHALT 0x00800000 +#define RSTAT_CLEAR_RHALT 0x00800000 +#define RSTAT_CLEAR_RXF0 0x00000080 +#define RSTAT_RXF_MASK 0x000000ff #define TCTRL_IPCSEN 0x00004000 #define TCTRL_TUCSEN 0x00002000