diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-01-18 20:17:18 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-01-18 20:17:18 +0000 |
commit | 2a76888e3f403821d79d62aa09c1e698da8f835a (patch) | |
tree | f5b1ef683bca120f77b53e601a7d2ee127e549f1 /target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c | |
parent | 8b61d50febc941e1b4e30e5ba103340c8637ae6a (diff) | |
download | master-187ad058-2a76888e3f403821d79d62aa09c1e698da8f835a.tar.gz master-187ad058-2a76888e3f403821d79d62aa09c1e698da8f835a.tar.bz2 master-187ad058-2a76888e3f403821d79d62aa09c1e698da8f835a.zip |
ralink: correct handle hardware rx 2bytes offset
Signed-off-by: michael lee <igvtee@gmail.com>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@44045 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c')
-rw-r--r-- | target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c index 28650bbceb..5a681f8e43 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/ralink_soc_eth.c @@ -41,9 +41,8 @@ #include "ralink_ethtool.h" #define MAX_RX_LENGTH 1536 -#define FE_RX_OFFSET (NET_SKB_PAD + NET_IP_ALIGN) -#define FE_RX_HLEN (FE_RX_OFFSET + VLAN_ETH_HLEN + VLAN_HLEN + \ - ETH_FCS_LEN) +#define FE_RX_HLEN (NET_SKB_PAD + VLAN_ETH_HLEN + VLAN_HLEN + \ + + NET_IP_ALIGN + ETH_FCS_LEN) #define DMA_DUMMY_DESC 0xffffffff #define FE_DEFAULT_MSG_ENABLE \ (NETIF_MSG_DRV | \ @@ -239,7 +238,7 @@ static void fe_clean_rx(struct fe_priv *priv) static int fe_alloc_rx(struct fe_priv *priv) { struct net_device *netdev = priv->netdev; - int i; + int i, pad; priv->rx_data = kcalloc(NUM_DMA_DESC, sizeof(*priv->rx_data), GFP_KERNEL); @@ -259,9 +258,13 @@ static int fe_alloc_rx(struct fe_priv *priv) if (!priv->rx_dma) goto no_rx_mem; + if (priv->flags & FE_FLAG_RX_2B_OFFSET) + pad = 0; + else + pad = NET_IP_ALIGN; for (i = 0; i < NUM_DMA_DESC; i++) { dma_addr_t dma_addr = dma_map_single(&netdev->dev, - priv->rx_data[i] + FE_RX_OFFSET, + priv->rx_data[i] + NET_SKB_PAD + pad, priv->rx_buf_size, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(&netdev->dev, dma_addr))) @@ -752,7 +755,7 @@ static int fe_poll_rx(struct napi_struct *napi, int budget, struct sk_buff *skb; u8 *data, *new_data; struct fe_rx_dma *rxd, trxd; - int done = 0; + int done = 0, pad; bool rx_vlan = netdev->features & NETIF_F_HW_VLAN_CTAG_RX; if (netdev->features & NETIF_F_RXCSUM) @@ -760,6 +763,10 @@ static int fe_poll_rx(struct napi_struct *napi, int budget, else checksum_bit = 0; + if (priv->flags & FE_FLAG_RX_2B_OFFSET) + pad = 0; + else + pad = NET_IP_ALIGN; while (done < budget) { unsigned int pktlen; dma_addr_t dma_addr; @@ -778,7 +785,7 @@ static int fe_poll_rx(struct napi_struct *napi, int budget, goto release_desc; } dma_addr = dma_map_single(&netdev->dev, - new_data + FE_RX_OFFSET, + new_data + NET_SKB_PAD + pad, priv->rx_buf_size, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(&netdev->dev, dma_addr))) { @@ -792,7 +799,7 @@ static int fe_poll_rx(struct napi_struct *napi, int budget, put_page(virt_to_head_page(new_data)); goto release_desc; } - skb_reserve(skb, FE_RX_OFFSET); + skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN); dma_unmap_single(&netdev->dev, trxd.rxd1, priv->rx_buf_size, DMA_FROM_DEVICE); @@ -1115,6 +1122,8 @@ static int fe_open(struct net_device *dev) napi_enable(&priv->rx_napi); val = FE_TX_WB_DDONE | FE_RX_DMA_EN | FE_TX_DMA_EN; + if (priv->flags & FE_FLAG_RX_2B_OFFSET) + val |= FE_RX_2B_OFFSET; val |= priv->soc->pdma_glo_cfg; fe_reg_w32(val, FE_REG_PDMA_GLO_CFG); |