[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1324273530-18499-1-git-send-email-peppe.cavallaro@st.com>
Date: Mon, 19 Dec 2011 06:45:30 +0100
From: Giuseppe CAVALLARO <peppe.cavallaro@...com>
To: netdev@...r.kernel.org
Cc: rubini@...dd.com, giancarlo.asnaghi@...com
Subject: [PATCH] stmmac: reduce queue lengths if MTU is very large
From: Alessandro Rubini <rubini@...dd.com>
In my use case (STA2X11 IO-Hub), the alloc_coherent, map_single and
friends map to a reserved area set up in swiotlb. With the default
MTU each packet takes 2kB, but with jumbo frames it increases to 16kB
and consumes up my area (it takes 8MB instead of 1MB).
Instead of increasing the reserved (== wasted) preallocated area in
swiotlb, this patch rescales the user-selected queue lengths if the MTU
is modified at runtime to be larger than the default. User choices
are still obeyed (compiled default, module parameter, command line)
Signed-off-by: Alessandro Rubini <rubini@...dd.com>
Acked-by: Giancarlo Asnaghi <giancarlo.asnaghi@...com>
Acked-by: Giuseppe Cavallaro <peppe.cavallaro@...com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 72cd190..e8ebb6e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -413,9 +413,8 @@ static void init_dma_desc_rings(struct net_device *dev)
int i;
struct stmmac_priv *priv = netdev_priv(dev);
struct sk_buff *skb;
- unsigned int txsize = priv->dma_tx_size;
- unsigned int rxsize = priv->dma_rx_size;
- unsigned int bfsize;
+ unsigned int txsize, rxsize;
+ unsigned int bfsize = priv->dma_buf_sz;
int dis_ic = 0;
int des3_as_data_buf = 0;
@@ -428,6 +427,20 @@ static void init_dma_desc_rings(struct net_device *dev)
else
bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz);
+ /*
+ * If we use jumbo frames, we end up consuming too much memory
+ * in the coherent buffer, so reduce the queue lenght according
+ * to the increase in frame size over the default.
+ */
+ i = bfsize / BUF_SIZE_2KiB;
+ if (i > 1) {
+ pr_warning("%s: reducing queue length by %i\n", __func__, i);
+ priv->dma_tx_size /= i;
+ priv->dma_rx_size /= i;
+ }
+ txsize = priv->dma_tx_size;
+ rxsize = priv->dma_rx_size;
+
#ifdef CONFIG_STMMAC_TIMER
/* Disable interrupts on completion for the reception if timer is on */
if (likely(priv->tm->enable))
--
1.7.4.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists