aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2011-11-17 09:37:23 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-17 21:43:57 -0500
commit738a849c8eef4787a526d95763f985b8c1cb68e4 (patch)
tree8e172b7f8b7d02929cc2045b7bd26e66d4248b24 /drivers/net/ethernet/marvell
parent4a8bb7e27fbb68da888b55f26defd2855225b2d5 (diff)
sky2: enforce minimum ring size
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell')
-rw-r--r--drivers/net/ethernet/marvell/sky2.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 539de09cffc9..d99687177704 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4088,6 +4088,16 @@ static int sky2_set_coalesce(struct net_device *dev,
4088 return 0; 4088 return 0;
4089} 4089}
4090 4090
4091/*
4092 * Hardware is limited to min of 128 and max of 2048 for ring size
4093 * and rounded up to next power of two
4094 * to avoid division in modulus calclation
4095 */
4096static unsigned long roundup_ring_size(unsigned long pending)
4097{
4098 return max(128ul, roundup_pow_of_two(pending+1));
4099}
4100
4091static void sky2_get_ringparam(struct net_device *dev, 4101static void sky2_get_ringparam(struct net_device *dev,
4092 struct ethtool_ringparam *ering) 4102 struct ethtool_ringparam *ering)
4093{ 4103{
@@ -4115,7 +4125,7 @@ static int sky2_set_ringparam(struct net_device *dev,
4115 4125
4116 sky2->rx_pending = ering->rx_pending; 4126 sky2->rx_pending = ering->rx_pending;
4117 sky2->tx_pending = ering->tx_pending; 4127 sky2->tx_pending = ering->tx_pending;
4118 sky2->tx_ring_size = roundup_pow_of_two(sky2->tx_pending+1); 4128 sky2->tx_ring_size = roundup_ring_size(sky2->tx_pending);
4119 4129
4120 return sky2_reattach(dev); 4130 return sky2_reattach(dev);
4121} 4131}
@@ -4709,7 +4719,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
4709 spin_lock_init(&sky2->phy_lock); 4719 spin_lock_init(&sky2->phy_lock);
4710 4720
4711 sky2->tx_pending = TX_DEF_PENDING; 4721 sky2->tx_pending = TX_DEF_PENDING;
4712 sky2->tx_ring_size = roundup_pow_of_two(TX_DEF_PENDING+1); 4722 sky2->tx_ring_size = roundup_ring_size(TX_DEF_PENDING);
4713 sky2->rx_pending = RX_DEF_PENDING; 4723 sky2->rx_pending = RX_DEF_PENDING;
4714 4724
4715 hw->dev[port] = dev; 4725 hw->dev[port] = dev;