All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data
@ 2012-07-12 14:19 Eric Dumazet
  2012-07-12 14:35 ` Po-Yu Chuang
  2012-07-18 16:42 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Dumazet @ 2012-07-12 14:19 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Po-Yu Chuang

From: Eric Dumazet <edumazet@google.com>

Drivers should pull only ethernet header from page frag
to skb->head.

Pulling 64 bytes is too much for TCP (without options) on IPv4.

However, it makes sense to pull all the frame if it fits the
128 bytes bloc allocated for skb->head, to free one page per
small incoming frame.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Po-Yu Chuang <ratbert@faraday-tech.com>
---
 drivers/net/ethernet/faraday/ftgmac100.c |    9 +++++++--
 drivers/net/ethernet/faraday/ftmac100.c  |   11 +++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 16b0704..74d749e 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -479,9 +479,14 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
 		rxdes = ftgmac100_current_rxdes(priv);
 	} while (!done);
 
-	if (skb->len <= 64)
+	/* Small frames are copied into linear part of skb to free one page */
+	if (skb->len <= 128) {
 		skb->truesize -= PAGE_SIZE;
-	__pskb_pull_tail(skb, min(skb->len, 64U));
+		__pskb_pull_tail(skb, skb->len);
+	} else {
+		/* We pull the minimum amount into linear part */
+		__pskb_pull_tail(skb, ETH_HLEN);
+	}
 	skb->protocol = eth_type_trans(skb, netdev);
 
 	netdev->stats.rx_packets++;
diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
index 829b109..b901a01 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -441,11 +441,14 @@ static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
 	skb->len += length;
 	skb->data_len += length;
 
-	/* page might be freed in __pskb_pull_tail() */
-	if (length > 64)
+	if (length > 128) {
 		skb->truesize += PAGE_SIZE;
-	__pskb_pull_tail(skb, min(length, 64));
-
+		/* We pull the minimum amount into linear part */
+		__pskb_pull_tail(skb, ETH_HLEN);
+	} else {
+		/* Small frames are copied into linear part to free one page */
+		__pskb_pull_tail(skb, length);
+	}
 	ftmac100_alloc_rx_page(priv, rxdes, GFP_ATOMIC);
 
 	ftmac100_rx_pointer_advance(priv);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data
  2012-07-12 14:19 [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data Eric Dumazet
@ 2012-07-12 14:35 ` Po-Yu Chuang
  2012-07-12 14:38   ` David Miller
  2012-07-18 16:42 ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Po-Yu Chuang @ 2012-07-12 14:35 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Po-Yu Chuang

Thank you Eric. :-)

regards,
Po-Yu Chuang

On Thu, Jul 12, 2012 at 10:19 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> From: Eric Dumazet <edumazet@google.com>
>
> Drivers should pull only ethernet header from page frag
> to skb->head.
>
> Pulling 64 bytes is too much for TCP (without options) on IPv4.
>
> However, it makes sense to pull all the frame if it fits the
> 128 bytes bloc allocated for skb->head, to free one page per
> small incoming frame.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Po-Yu Chuang <ratbert@faraday-tech.com>
> ---
>  drivers/net/ethernet/faraday/ftgmac100.c |    9 +++++++--
>  drivers/net/ethernet/faraday/ftmac100.c  |   11 +++++++----
>  2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 16b0704..74d749e 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -479,9 +479,14 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
>                 rxdes = ftgmac100_current_rxdes(priv);
>         } while (!done);
>
> -       if (skb->len <= 64)
> +       /* Small frames are copied into linear part of skb to free one page */
> +       if (skb->len <= 128) {
>                 skb->truesize -= PAGE_SIZE;
> -       __pskb_pull_tail(skb, min(skb->len, 64U));
> +               __pskb_pull_tail(skb, skb->len);
> +       } else {
> +               /* We pull the minimum amount into linear part */
> +               __pskb_pull_tail(skb, ETH_HLEN);
> +       }
>         skb->protocol = eth_type_trans(skb, netdev);
>
>         netdev->stats.rx_packets++;
> diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
> index 829b109..b901a01 100644
> --- a/drivers/net/ethernet/faraday/ftmac100.c
> +++ b/drivers/net/ethernet/faraday/ftmac100.c
> @@ -441,11 +441,14 @@ static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
>         skb->len += length;
>         skb->data_len += length;
>
> -       /* page might be freed in __pskb_pull_tail() */
> -       if (length > 64)
> +       if (length > 128) {
>                 skb->truesize += PAGE_SIZE;
> -       __pskb_pull_tail(skb, min(length, 64));
> -
> +               /* We pull the minimum amount into linear part */
> +               __pskb_pull_tail(skb, ETH_HLEN);
> +       } else {
> +               /* Small frames are copied into linear part to free one page */
> +               __pskb_pull_tail(skb, length);
> +       }
>         ftmac100_alloc_rx_page(priv, rxdes, GFP_ATOMIC);
>
>         ftmac100_rx_pointer_advance(priv);
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data
  2012-07-12 14:35 ` Po-Yu Chuang
@ 2012-07-12 14:38   ` David Miller
  2012-07-13  2:21     ` Po-Yu Chuang
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2012-07-12 14:38 UTC (permalink / raw)
  To: ratbert.chuang; +Cc: eric.dumazet, netdev, ratbert

From: Po-Yu Chuang <ratbert.chuang@gmail.com>
Date: Thu, 12 Jul 2012 22:35:18 +0800

> Thank you Eric. :-)

You can thank him by providing an "Acked-by: ..." tag in your
reply.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data
  2012-07-12 14:38   ` David Miller
@ 2012-07-13  2:21     ` Po-Yu Chuang
  2012-07-13  8:31       ` Andrew Yan-Pai Chen
  0 siblings, 1 reply; 6+ messages in thread
From: Po-Yu Chuang @ 2012-07-13  2:21 UTC (permalink / raw)
  To: David Miller
  Cc: eric.dumazet, netdev,
	Andrew Yan-Pai Chen(陳彥百),
	Yan-Pai Chen

On Thu, Jul 12, 2012 at 10:38 PM, David Miller <davem@davemloft.net> wrote:
> From: Po-Yu Chuang <ratbert.chuang@gmail.com>
> Date: Thu, 12 Jul 2012 22:35:18 +0800
>
>> Thank you Eric. :-)
>
> You can thank him by providing an "Acked-by: ..." tag in your
> reply.

I don't have hardware to test this patch now.
CC the current maintainer.

regards,
Po-Yu Chuang

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data
  2012-07-13  2:21     ` Po-Yu Chuang
@ 2012-07-13  8:31       ` Andrew Yan-Pai Chen
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Yan-Pai Chen @ 2012-07-13  8:31 UTC (permalink / raw)
  To: Po-Yu Chuang
  Cc: David Miller, eric.dumazet, netdev,
	Andrew Yan-Pai Chen(陳彥百),
	kernel.jason

On Fri, Jul 13, 2012 at 10:21 AM, Po-Yu Chuang <ratbert.chuang@gmail.com> wrote:
> On Thu, Jul 12, 2012 at 10:38 PM, David Miller <davem@davemloft.net> wrote:
>> From: Po-Yu Chuang <ratbert.chuang@gmail.com>
>> Date: Thu, 12 Jul 2012 22:35:18 +0800
>>
>>> Thank you Eric. :-)
>>
>> You can thank him by providing an "Acked-by: ..." tag in your
>> reply.
>
> I don't have hardware to test this patch now.
> CC the current maintainer.
>
> regards,
> Po-Yu Chuang

Acked-by: Yan-Pai Chen <yanpai.chen@gmail.com>

--
Regards,
Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data
  2012-07-12 14:19 [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data Eric Dumazet
  2012-07-12 14:35 ` Po-Yu Chuang
@ 2012-07-18 16:42 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2012-07-18 16:42 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, ratbert

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 12 Jul 2012 16:19:38 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> Drivers should pull only ethernet header from page frag
> to skb->head.
> 
> Pulling 64 bytes is too much for TCP (without options) on IPv4.
> 
> However, it makes sense to pull all the frame if it fits the
> 128 bytes bloc allocated for skb->head, to free one page per
> small incoming frame.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-07-18 16:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-12 14:19 [PATCH net-next] net: ftgmac100/ftmac100: dont pull too much data Eric Dumazet
2012-07-12 14:35 ` Po-Yu Chuang
2012-07-12 14:38   ` David Miller
2012-07-13  2:21     ` Po-Yu Chuang
2012-07-13  8:31       ` Andrew Yan-Pai Chen
2012-07-18 16:42 ` David Miller

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.