diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2008-12-11 20:58:04 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-11 20:58:04 -0800 |
commit | 82a9928db560c429807f02467d22394f944a8916 (patch) | |
tree | fbcde186821bb2f305d71c0a2b6c7f934f2bf86c /drivers/net/tc35815.c | |
parent | 2cb377283f3469d66f0ea7358015abfe8366e5d0 (diff) |
tc35815: Enable StripCRC feature
The chip can strip CRC automatically on receiving. Enable it.
Also fix potential RX_BUF_SIZE calculation bug which was obscured by
alignment. And use proper symbols (NET_IP_ALIGN, ETH_FCS_LEN, etc.)
instead of magic numbers.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tc35815.c')
-rw-r--r-- | drivers/net/tc35815.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c index 44126c463fa..308f365270e 100644 --- a/drivers/net/tc35815.c +++ b/drivers/net/tc35815.c @@ -37,6 +37,7 @@ static const char *version = "tc35815.c:v" DRV_VERSION "\n"; #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/in.h> +#include <linux/if_vlan.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/spinlock.h> @@ -341,7 +342,7 @@ struct BDesc { Tx_En) /* maybe 0x7b01 */ #endif #define RX_CTL_CMD (Rx_EnGood | Rx_EnRxPar | Rx_EnLongErr | Rx_EnOver \ - | Rx_EnCRCErr | Rx_EnAlign | Rx_RxEn) /* maybe 0x6f01 */ + | Rx_EnCRCErr | Rx_EnAlign | Rx_StripCRC | Rx_RxEn) /* maybe 0x6f11 */ #define INT_EN_CMD (Int_NRAbtEn | \ Int_DmParErrEn | Int_DParDEn | Int_DParErrEn | \ Int_SSysErrEn | Int_RMasAbtEn | Int_RTargAbtEn | \ @@ -373,9 +374,11 @@ struct BDesc { #if RX_CTL_CMD & Rx_LongEn #define RX_BUF_SIZE PAGE_SIZE #elif RX_CTL_CMD & Rx_StripCRC -#define RX_BUF_SIZE ALIGN(ETH_FRAME_LEN + 4 + 2, 32) /* +2: reserve */ +#define RX_BUF_SIZE \ + L1_CACHE_ALIGN(ETH_FRAME_LEN + VLAN_HLEN + NET_IP_ALIGN) #else -#define RX_BUF_SIZE ALIGN(ETH_FRAME_LEN + 2, 32) /* +2: reserve */ +#define RX_BUF_SIZE \ + L1_CACHE_ALIGN(ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN + NET_IP_ALIGN) #endif #endif /* TC35815_USE_PACKEDBUFFER */ #define RX_FD_RESERVE (2 / 2) /* max 2 BD per RxFD */ @@ -1666,7 +1669,7 @@ tc35815_rx(struct net_device *dev) struct RxFD *next_rfd; #endif #if (RX_CTL_CMD & Rx_StripCRC) == 0 - pkt_len -= 4; + pkt_len -= ETH_FCS_LEN; #endif if (netif_msg_rx_status(lp)) @@ -1685,14 +1688,14 @@ tc35815_rx(struct net_device *dev) #endif #ifdef TC35815_USE_PACKEDBUFFER BUG_ON(bd_count > 2); - skb = dev_alloc_skb(pkt_len + 2); /* +2: for reserve */ + skb = dev_alloc_skb(pkt_len + NET_IP_ALIGN); if (skb == NULL) { printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); dev->stats.rx_dropped++; break; } - skb_reserve(skb, 2); /* 16 bit alignment */ + skb_reserve(skb, NET_IP_ALIGN); data = skb_put(skb, pkt_len); @@ -1744,8 +1747,9 @@ tc35815_rx(struct net_device *dev) pci_unmap_single(lp->pci_dev, lp->rx_skbs[cur_bd].skb_dma, RX_BUF_SIZE, PCI_DMA_FROMDEVICE); - if (!HAVE_DMA_RXALIGN(lp)) - memmove(skb->data, skb->data - 2, pkt_len); + if (!HAVE_DMA_RXALIGN(lp) && NET_IP_ALIGN) + memmove(skb->data, skb->data - NET_IP_ALIGN, + pkt_len); data = skb_put(skb, pkt_len); #endif /* TC35815_USE_PACKEDBUFFER */ if (netif_msg_pktdata(lp)) |