ar71xx: ag71xx: store descriptor packet length mask in ag71xx struct

The currently used bitmask is not correct for all SoCs.
Introduce a new field in struct ag71xx and store the
bitmask in that. Use the current value for now, it will
be adjusted for each SoCs in further patches.

Aslo use the new field directly in the ag71xx_rx_packets
and ag71xx_hard_start_xmit() functions and remove the
ag71xx_desc_pktlen() helper.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39144
This commit is contained in:
Gabor Juhos 2013-12-20 11:41:16 +00:00
parent 2b22d909fd
commit 9be1e508f9
2 changed files with 5 additions and 7 deletions

View file

@ -166,6 +166,7 @@ struct ag71xx {
int duplex; int duplex;
unsigned int max_frame_len; unsigned int max_frame_len;
unsigned int desc_pktlen_mask;
unsigned int rx_buf_size; unsigned int rx_buf_size;
struct work_struct restart_work; struct work_struct restart_work;
@ -198,11 +199,6 @@ static inline int ag71xx_desc_empty(struct ag71xx_desc *desc)
return (desc->ctrl & DESC_EMPTY) != 0; return (desc->ctrl & DESC_EMPTY) != 0;
} }
static inline int ag71xx_desc_pktlen(struct ag71xx_desc *desc)
{
return desc->ctrl & DESC_PKTLEN_M;
}
/* Register offsets */ /* Register offsets */
#define AG71XX_REG_MAC_CFG1 0x0000 #define AG71XX_REG_MAC_CFG1 0x0000
#define AG71XX_REG_MAC_CFG2 0x0004 #define AG71XX_REG_MAC_CFG2 0x0004

View file

@ -692,7 +692,7 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
/* setup descriptor fields */ /* setup descriptor fields */
desc->data = (u32) dma_addr; desc->data = (u32) dma_addr;
desc->ctrl = (skb->len & DESC_PKTLEN_M); desc->ctrl = skb->len & ag->desc_pktlen_mask;
/* flush descriptor */ /* flush descriptor */
wmb(); wmb();
@ -866,6 +866,7 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
struct net_device *dev = ag->dev; struct net_device *dev = ag->dev;
struct ag71xx_ring *ring = &ag->rx_ring; struct ag71xx_ring *ring = &ag->rx_ring;
int offset = ag71xx_buffer_offset(ag); int offset = ag71xx_buffer_offset(ag);
unsigned int pktlen_mask = ag->desc_pktlen_mask;
int done = 0; int done = 0;
DBG("%s: rx packets, limit=%d, curr=%u, dirty=%u\n", DBG("%s: rx packets, limit=%d, curr=%u, dirty=%u\n",
@ -888,7 +889,7 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR); ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
pktlen = ag71xx_desc_pktlen(desc); pktlen = desc->ctrl & pktlen_mask;
pktlen -= ETH_FCS_LEN; pktlen -= ETH_FCS_LEN;
dma_unmap_single(&dev->dev, ring->buf[i].dma_addr, dma_unmap_single(&dev->dev, ring->buf[i].dma_addr,
@ -1169,6 +1170,7 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->rx_ring.size = AG71XX_RX_RING_SIZE_DEFAULT; ag->rx_ring.size = AG71XX_RX_RING_SIZE_DEFAULT;
ag->max_frame_len = AG71XX_TX_MTU_LEN; ag->max_frame_len = AG71XX_TX_MTU_LEN;
ag->desc_pktlen_mask = DESC_PKTLEN_MASK;
ag->stop_desc = dma_alloc_coherent(NULL, ag->stop_desc = dma_alloc_coherent(NULL,
sizeof(struct ag71xx_desc), &ag->stop_desc_dma, GFP_KERNEL); sizeof(struct ag71xx_desc), &ag->stop_desc_dma, GFP_KERNEL);