All of lore.kernel.org
 help / color / mirror / Atom feed
From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	Deepak SIKRI <deepak.sikri@st.com>
Subject: Re: [net-next 4/7] stmmac: allow mtu bigger than 1500 in case of normal desc (V3)
Date: Tue, 18 Oct 2011 11:26:10 +0200	[thread overview]
Message-ID: <4E9D4632.3000808@st.com> (raw)
In-Reply-To: <1318928605.2657.18.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC>

Hello Eric,

On 10/18/2011 11:03 AM, Eric Dumazet wrote:
> Le mardi 18 octobre 2011 à 10:42 +0200, Giuseppe CAVALLARO a écrit :
>> This patch allows to set the mtu bigger than 1500
>> in case of normal descriptors.
>> This is helping some SPEAr customers.
>>
>> Signed-off-by: Deepak SIKRI <deepak.sikri@st.com>
>> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>> ---
>>  drivers/net/ethernet/stmicro/stmmac/norm_desc.c   |    8 +++++++-
>>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    4 ++--
>>  2 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
>> index 029c2a2..e13226b 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
>> @@ -126,6 +126,7 @@ static void ndesc_init_rx_desc(struct dma_desc *p, unsigned int ring_size,
>>  	for (i = 0; i < ring_size; i++) {
>>  		p->des01.rx.own = 1;
>>  		p->des01.rx.buffer1_size = BUF_SIZE_2KiB - 1;
>> +		p->des01.rx.buffer2_size = BUF_SIZE_2KiB - 1;
>>  		if (i == ring_size - 1)
>>  			p->des01.rx.end_ring = 1;
>>  		if (disable_rx_ic)
>> @@ -183,7 +184,12 @@ static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
>>  				  int csum_flag)
>>  {
>>  	p->des01.tx.first_segment = is_fs;
>> -	p->des01.tx.buffer1_size = len;
>> +
>> +	if (unlikely(len > BUF_SIZE_2KiB)) {
>> +		p->des01.etx.buffer1_size = BUF_SIZE_2KiB - 1;
>> +		p->des01.etx.buffer2_size = len - p->des01.etx.buffer1_size;
>> +	} else
>> +		p->des01.tx.buffer1_size = len;
>>  }
>>  
>>  static void ndesc_clear_tx_ic(struct dma_desc *p)
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> index d0af002..622b7ac 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> @@ -1412,10 +1412,10 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
>>  		return -EBUSY;
>>  	}
>>  
>> -	if (priv->plat->has_gmac)
>> +	if (priv->plat->enh_desc)
>>  		max_mtu = JUMBO_LEN;
>>  	else
>> -		max_mtu = ETH_DATA_LEN;
>> +		max_mtu = BUF_SIZE_4KiB;
>>  
>>  	if ((new_mtu < 46) || (new_mtu > max_mtu)) {
>>  		pr_err("%s: invalid MTU, max MTU is: %d\n", dev->name, max_mtu);
> 
> Problem using big mtu around 4096 bytes is you end allocating (4096
> +NET_SKB_PAD + NET_IP_ALIGN + sizeof(struct skb_shared_info) bytes ->
> 8192 bytes : order-1 pages

yes.

> 
> Maybe it would be better to limit your mtu to SKB_MAX_HEAD(NET_SKB_PAD),
> to have no more than one page per skb ?

ok! ;-)

> I would suggest changing netdev_alloc_skb_ip_align() done in
> init_dma_desc_rings() to use a variant allowing GFP_KERNEL allocations
> and allow your driver to load even in case of memory pressure.
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index c0ee6b6..8ec8057 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -458,11 +458,12 @@ static void init_dma_desc_rings(struct net_device *dev)
>  	for (i = 0; i < rxsize; i++) {
>  		struct dma_desc *p = priv->dma_rx + i;
>  
> -		skb = netdev_alloc_skb_ip_align(dev, bfsize);
> +		skb = __netdev_alloc_skb(dev, bfsize + NET_IP_ALIGN, GFP_KERNEL);
>  		if (unlikely(skb == NULL)) {
>  			pr_err("%s: Rx init fails; skb is NULL\n", __func__);
>  			break;
>  		}
> +		skb_reserve(skb, NET_IP_ALIGN);
>  		priv->rx_skbuff[i] = skb;
>  		priv->rx_skbuff_dma[i] = dma_map_single(priv->device, skb->data,
>  						bfsize, DMA_FROM_DEVICE);
> 
> 
> 


Agree! I'm reviewing the patches and send all again.

Many thanks
Regards
Peppe

  reply	other threads:[~2011-10-18  9:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18  8:42 [net-next 0/7] stmmac: update to Oct 2011 version (V2) Giuseppe CAVALLARO
2011-10-18  8:42 ` [net-next 1/7] stmmac: Stop advertising 1000Base capabilties for non GMII iface (V3) Giuseppe CAVALLARO
2011-10-18  8:42 ` [net-next 2/7] stmmac: protect tx process with lock (V3) Giuseppe CAVALLARO
2011-10-18  8:42 ` [net-next 3/7] stmmac: update the driver version and doc (V3) Giuseppe CAVALLARO
2011-10-18  8:42 ` [net-next 4/7] stmmac: allow mtu bigger than 1500 in case of normal desc (V3) Giuseppe CAVALLARO
2011-10-18  9:03   ` Eric Dumazet
2011-10-18  9:26     ` Giuseppe CAVALLARO [this message]
2011-10-18  8:42 ` [net-next 5/7] stmmac: use predefined macros for HW cap register fields (V3) Giuseppe CAVALLARO
2011-10-18  8:42 ` [net-next 6/7] stmmac: allow mmc usage only if feature actually available (V3) Giuseppe CAVALLARO
2011-10-18  8:42 ` [net-next 7/7] stmmac: add CHAINED descriptor mode support (V3) Giuseppe CAVALLARO
2011-10-18  9:51   ` Giuseppe CAVALLARO
2011-10-18  8:44 ` [net-next 0/7] stmmac: update to Oct 2011 version (V2) Giuseppe CAVALLARO

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=4E9D4632.3000808@st.com \
    --to=peppe.cavallaro@st.com \
    --cc=davem@davemloft.net \
    --cc=deepak.sikri@st.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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.