* [PATCH] KS8851: Correct RX packet allocation
@ 2010-09-08 23:26 Arce, Abraham
2010-09-09 4:47 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Arce, Abraham @ 2010-09-08 23:26 UTC (permalink / raw)
To: Eric Dumazet, David Miller
Cc: netdev@vger.kernel.org, Shilimkar, Santosh, Ha, Tristram
From: Eric Dumazet <eric.dumazet@gmail.com>
Use netdev_alloc_skb_ip_align() helper and do correct allocation
Tested-by: Abraham Arce <x0066660@ti.com>
Signed-off-by: Abraham Arce <x0066660@ti.com>
---
drivers/net/ks8851.c | 39 +++++++++++++++++++++------------------
1 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index b4fb07a..51919fc 100644
--- a/drivers/net/ks8851.c
+++ b/drivers/net/ks8851.c
@@ -503,30 +503,33 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
ks8851_wrreg16(ks, KS_RXQCR,
ks->rc_rxqcr | RXQCR_SDA | RXQCR_ADRFE);
- if (rxlen > 0) {
- skb = netdev_alloc_skb(ks->netdev, rxlen + 2 + 8);
- if (!skb) {
- /* todo - dump frame and move on */
- }
+ if (rxlen > 4) {
+ unsigned int rxalign;
+
+ rxlen -= 4;
+ rxalign = ALIGN(rxlen, 4);
+ skb = netdev_alloc_skb_ip_align(ks->netdev, rxalign);
+ if (skb) {
- /* two bytes to ensure ip is aligned, and four bytes
- * for the status header and 4 bytes of garbage */
- skb_reserve(skb, 2 + 4 + 4);
+ /* 4 bytes of status header + 4 bytes of
+ * garbage: we put them before ethernet
+ * header, so that they are copied,
+ * but ignored.
+ */
- rxpkt = skb_put(skb, rxlen - 4) - 8;
+ rxpkt = skb_put(skb, rxlen) - 8;
- /* align the packet length to 4 bytes, and add 4 bytes
- * as we're getting the rx status header as well */
- ks8851_rdfifo(ks, rxpkt, ALIGN(rxlen, 4) + 8);
+ ks8851_rdfifo(ks, rxpkt, rxalign + 8);
- if (netif_msg_pktdata(ks))
- ks8851_dbg_dumpkkt(ks, rxpkt);
+ if (netif_msg_pktdata(ks))
+ ks8851_dbg_dumpkkt(ks, rxpkt);
- skb->protocol = eth_type_trans(skb, ks->netdev);
- netif_rx(skb);
+ skb->protocol = eth_type_trans(skb, ks->netdev);
+ netif_rx(skb);
- ks->netdev->stats.rx_packets++;
- ks->netdev->stats.rx_bytes += rxlen - 4;
+ ks->netdev->stats.rx_packets++;
+ ks->netdev->stats.rx_bytes += rxlen;
+ }
}
ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
--
1.5.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KS8851: Correct RX packet allocation
2010-09-08 23:26 [PATCH] KS8851: Correct RX packet allocation Arce, Abraham
@ 2010-09-09 4:47 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-09-09 4:47 UTC (permalink / raw)
To: x0066660; +Cc: eric.dumazet, netdev, santosh.shilimkar, Tristram.Ha
From: "Arce, Abraham" <x0066660@ti.com>
Date: Wed, 8 Sep 2010 18:26:55 -0500
> From: Eric Dumazet <eric.dumazet@gmail.com>
>
> Use netdev_alloc_skb_ip_align() helper and do correct allocation
>
> Tested-by: Abraham Arce <x0066660@ti.com>
> Signed-off-by: Abraham Arce <x0066660@ti.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-09 4:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-08 23:26 [PATCH] KS8851: Correct RX packet allocation Arce, Abraham
2010-09-09 4:47 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).