From patchwork Thu Feb 4 11:25:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Torek X-Patchwork-Id: 44460 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 34E81B7D48 for ; Thu, 4 Feb 2010 22:26:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757280Ab0BDL0J (ORCPT ); Thu, 4 Feb 2010 06:26:09 -0500 Received: from mail.windriver.com ([147.11.1.11]:44480 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756461Ab0BDL0G (ORCPT ); Thu, 4 Feb 2010 06:26:06 -0500 Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144]) by mail.windriver.com (8.14.3/8.14.3) with ESMTP id o14BQ468002792; Thu, 4 Feb 2010 03:26:04 -0800 (PST) Received: from ala-mail06.corp.ad.wrs.com ([147.11.57.147]) by ALA-MAIL03.corp.ad.wrs.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 4 Feb 2010 03:26:03 -0800 Received: from localhost.localdomain ([172.25.39.238]) by ala-mail06.corp.ad.wrs.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 4 Feb 2010 03:26:03 -0800 From: Chris Torek To: sparclinux@vger.kernel.org Cc: chris.torek@gmail.com Subject: [PATCH 1/8] niu configurable parameters Date: Thu, 4 Feb 2010 04:25:55 -0700 Message-Id: X-Mailer: git-send-email 1.6.0.4.766.g6fc4a In-Reply-To: <1265282762-13954-1-git-send-email-chris.torek@windriver.com> References: <1265282762-13954-1-git-send-email-chris.torek@windriver.com> X-OriginalArrivalTime: 04 Feb 2010 11:26:03.0767 (UTC) FILETIME=[D5FDE070:01CAA58C] Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org From: Hong H. Pham Add support for boot or runtime configuration for various NIU driver parameters. Runtime configuration is done through the control files in /sys/modules/niu/parameters/. After changing a configuration parameter, it is recommended that the interface is brought down and up again to accept the new configuration. The following is a list configurable NIU parameters. Parameter Values Description =================== ========= ================================= wred_nonsyn_window 0..15 Weighted Random Early Discard window for non-TCP packets. wred_syn_window 0..15 Weighted Random Early Discard window for TCP packets. rcr_timeout 0..63 RCR timeout for interrupt mitigation rcr_pkt_threshold 0..65535 RCR packet threshold for interrupt mitigation. rbr_refill_min 0..n Minimum RBR refill threshold (note: n is automatically limited to no more than half the Receive Block Rings). Signed-off-by: Hong H. Pham Signed-off-by: Chris Torek --- drivers/net/niu.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 53 insertions(+), 6 deletions(-) diff --git a/drivers/net/niu.c b/drivers/net/niu.c index 8ce58c4..cfb43a4 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c @@ -45,6 +45,37 @@ MODULE_DESCRIPTION("NIU ethernet driver"); MODULE_LICENSE("GPL"); MODULE_VERSION(DRV_MODULE_VERSION); +#define RDC_RED_PARA_WIN_MAX (RDC_RED_PARA_WIN >> RDC_RED_PARA_WIN_SHIFT) +static unsigned int wred_nonsyn_window __read_mostly = 0; +module_param(wred_nonsyn_window, uint, 0644); +MODULE_PARM_DESC(wred_nonsyn_window, + "Weighted Random Early Discard window for non-TCP packets (0-" + __stringify(RDC_RED_PARA_WIN_MAX) ")"); + +#define RDC_RED_PARA_WIN_SYN_MAX \ + (RDC_RED_PARA_WIN_SYN >> RDC_RED_PARA_WIN_SYN_SHIFT) +static unsigned int wred_syn_window __read_mostly = 0; +module_param(wred_syn_window, uint, 0644); +MODULE_PARM_DESC(wred_syn_window, + "Weight Random Early Discard window for TCP packets (0-)" + __stringify(RDC_RED_PARA_WIN_SYN_MAX) ")"); + +#define RCRCFIG_B_TIMEOUT_MAX (RCRCFIG_B_TIMEOUT >> RCRCFIG_B_TIMEOUT_SHIFT) +static unsigned int rcr_timeout __read_mostly = 8; +module_param(rcr_timeout, uint, 0644); +MODULE_PARM_DESC(rcr_timeout, "RCR timeout (0-" + __stringify(RCRCFIG_B_TIMEOUT_MAX) ")"); + +#define RCRCFIG_B_PTHRES_MAX (RCRCFIG_B_PTHRES >> RCRCFIG_B_PTHRES_SHIFT) +static unsigned int rcr_pkt_threshold __read_mostly = 16; +module_param(rcr_pkt_threshold, uint, 0644); +MODULE_PARM_DESC(rcr_pkt_threshold, "RCR packet threshold (0-" + __stringify(RCRCFIG_B_PTHRES_MAX) ")"); + +static unsigned int rbr_refill_min __read_mostly = RBR_REFILL_MIN; +module_param(rbr_refill_min, uint, 0644); +MODULE_PARM_DESC(rbr_refill_min, "Minimum RBR refill threshold"); + #ifndef readq static u64 readq(void __iomem *reg) { @@ -4550,14 +4581,30 @@ static int niu_alloc_channels(struct niu *np) niu_size_rbr(np, rp); - /* XXX better defaults, configurable, etc... XXX */ - rp->nonsyn_window = 64; + if (wred_nonsyn_window > RDC_RED_PARA_WIN_MAX) + wred_nonsyn_window = RDC_RED_PARA_WIN_MAX; + rp->nonsyn_window = wred_nonsyn_window; rp->nonsyn_threshold = rp->rcr_table_size - 64; - rp->syn_window = 64; + + if (wred_syn_window > RDC_RED_PARA_WIN_SYN_MAX) + wred_syn_window = RDC_RED_PARA_WIN_SYN_MAX; + rp->syn_window = wred_syn_window; rp->syn_threshold = rp->rcr_table_size - 64; - rp->rcr_pkt_threshold = 16; - rp->rcr_timeout = 8; - rp->rbr_kick_thresh = RBR_REFILL_MIN; + + if (rcr_pkt_threshold > RCRCFIG_B_PTHRES_MAX) + rcr_pkt_threshold = RCRCFIG_B_PTHRES_MAX; + rp->rcr_pkt_threshold = rcr_pkt_threshold; + + if (rcr_timeout > RCRCFIG_B_TIMEOUT_MAX) + rcr_timeout = RCRCFIG_B_TIMEOUT_MAX; + rp->rcr_timeout = rcr_timeout; + + if (rbr_refill_min < 1) + rbr_refill_min = 1; + if (rbr_refill_min > (rp->rbr_table_size / 2)) + rbr_refill_min = rp->rbr_table_size / 2; + rp->rbr_kick_thresh = rbr_refill_min; + if (rp->rbr_kick_thresh < rp->rbr_blocks_per_page) rp->rbr_kick_thresh = rp->rbr_blocks_per_page;