Commit 972c40b5 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

KS8851: Correct RX packet allocation

Use netdev_alloc_skb_ip_align() helper and do correct allocation
Tested-by: default avatarAbraham Arce <x0066660@ti.com>
Signed-off-by: default avatarAbraham Arce <x0066660@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 719f8358
......@@ -503,21 +503,23 @@ 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 */
}
/* 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);
if (rxlen > 4) {
unsigned int rxalign;
rxlen -= 4;
rxalign = ALIGN(rxlen, 4);
skb = netdev_alloc_skb_ip_align(ks->netdev, rxalign);
if (skb) {
/* 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);
......@@ -526,7 +528,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
netif_rx(skb);
ks->netdev->stats.rx_packets++;
ks->netdev->stats.rx_bytes += rxlen - 4;
ks->netdev->stats.rx_bytes += rxlen;
}
}
ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment