All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Sven Joachim <svenjoac@gmx.de>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH net-next] sky2: enforce minimum ring size
Date: Thu, 17 Nov 2011 16:37:23 -0800	[thread overview]
Message-ID: <20111117163723.67964841@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <874ny2bgqa.fsf@turtle.gmx.de>

The hardware has a restriction that the minimum ring size possible
is 128. The number of elements used is controlled by tx_pending and
the overall number of elements in the ring tx_ring_size, therefore it
is okay to limit the number of elements in use to a small value (63)
but still provide a bigger ring.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/drivers/net/ethernet/marvell/sky2.c	2011-11-17 16:25:40.079898621 -0800
+++ b/drivers/net/ethernet/marvell/sky2.c	2011-11-17 16:33:19.088438709 -0800
@@ -4092,6 +4092,16 @@ static int sky2_set_coalesce(struct net_
 	return 0;
 }
 
+/*
+ * Hardware is limited to min of 128 and max of 2048 for ring size
+ * and  rounded up to next power of two
+ * to avoid division in modulus calclation
+ */
+static unsigned long roundup_ring_size(unsigned long pending)
+{
+	return max(128ul, roundup_pow_of_two(pending+1));
+}
+
 static void sky2_get_ringparam(struct net_device *dev,
 			       struct ethtool_ringparam *ering)
 {
@@ -4119,7 +4129,7 @@ static int sky2_set_ringparam(struct net
 
 	sky2->rx_pending = ering->rx_pending;
 	sky2->tx_pending = ering->tx_pending;
-	sky2->tx_ring_size = roundup_pow_of_two(sky2->tx_pending+1);
+	sky2->tx_ring_size = roundup_ring_size(sky2->tx_pending);
 
 	return sky2_reattach(dev);
 }
@@ -4714,7 +4724,7 @@ static __devinit struct net_device *sky2
 	spin_lock_init(&sky2->phy_lock);
 
 	sky2->tx_pending = TX_DEF_PENDING;
-	sky2->tx_ring_size = roundup_pow_of_two(TX_DEF_PENDING+1);
+	sky2->tx_ring_size = roundup_ring_size(TX_DEF_PENDING);
 	sky2->rx_pending = RX_DEF_PENDING;
 
 	hw->dev[port] = dev;

  parent reply	other threads:[~2011-11-18  0:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16 23:42 [PATCH 0/6] sky2 patches for net-next Stephen Hemminger
2011-11-16 23:42 ` [PATCH 1/6] sky2: fix hang on shutdown (and other irq issues) Stephen Hemminger
2011-11-17  8:46   ` Sven Joachim
2011-11-17 17:01     ` Stephen Hemminger
2011-11-17 18:37       ` Sven Joachim
2011-11-17 19:18         ` Stephen Hemminger
2011-11-17 20:57           ` Sven Joachim
2011-11-18  0:37     ` [PATCH net-next] sky2: fix hang in napi_disable Stephen Hemminger
2011-11-18  1:52       ` David Miller
2011-11-18  2:10         ` Stephen Hemminger
2011-11-18  2:15           ` David Miller
2011-11-18  2:44       ` David Miller
2011-11-16 23:42 ` [PATCH 2/6] sky2: pci posting issues Stephen Hemminger
2011-11-16 23:42 ` [PATCH 3/6] sky2: rename up/down functions Stephen Hemminger
2011-11-16 23:42 ` [PATCH 4/6] sky2: reduce default Tx ring size Stephen Hemminger
2011-11-17 21:07   ` Sven Joachim
2011-11-17 22:41     ` Stephen Hemminger
2011-11-18  0:37     ` Stephen Hemminger [this message]
2011-11-18  2:44       ` [PATCH net-next] sky2: enforce minimum " David Miller
2011-11-16 23:42 ` [PATCH 5/6] sky2: used fixed RSS key Stephen Hemminger
2011-11-16 23:43 ` [PATCH 6/6] sky2: version 1.30 Stephen Hemminger
2011-11-17  1:36 ` [PATCH 0/6] sky2 patches for net-next David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111117163723.67964841@nehalam.linuxnetplumber.net \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=svenjoac@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.