ar71xx: ag71xx: store RX buffer size in the ag71xx struct
authorGabor Juhos <juhosg@openwrt.org>
Tue, 17 Dec 2013 16:27:44 +0000 (16:27 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Tue, 17 Dec 2013 16:27:44 +0000 (16:27 +0000)
This allows to change the value dynamically.

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

target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c

index 68d26910406d6a1bfe7cdc0624ce5469d3df1461..f3f9f148014c29d2b387dcecb60f2b3874901f9d 100644 (file)
@@ -53,7 +53,6 @@
 #define AG71XX_TX_MTU_LEN      1540
 #define AG71XX_RX_PKT_SIZE     \
        (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
-#define AG71XX_RX_BUF_SIZE (AG71XX_RX_PKT_SIZE + NET_SKB_PAD + NET_IP_ALIGN)
 
 #define AG71XX_TX_RING_SIZE_DEFAULT    32
 #define AG71XX_RX_RING_SIZE_DEFAULT    128
@@ -169,6 +168,7 @@ struct ag71xx {
        int                     duplex;
 
        unsigned int            max_frame_len;
+       unsigned int            rx_buf_size;
 
        struct work_struct      restart_work;
        struct delayed_work     link_work;
index 281d0f568609a68a6b1d3f75cec51898e9cd226b..04e1e586c2afd63665bc7a7fac31ec2a041130bb 100644 (file)
@@ -191,7 +191,7 @@ static void ag71xx_ring_rx_clean(struct ag71xx *ag)
        for (i = 0; i < ring->size; i++)
                if (ring->buf[i].rx_buf) {
                        dma_unmap_single(&ag->dev->dev, ring->buf[i].dma_addr,
-                                        AG71XX_RX_BUF_SIZE, DMA_FROM_DEVICE);
+                                        ag->rx_buf_size, DMA_FROM_DEVICE);
                        kfree(ring->buf[i].rx_buf);
                }
 }
@@ -217,15 +217,15 @@ static bool ag71xx_fill_rx_buf(struct ag71xx *ag, struct ag71xx_buf *buf,
 {
        void *data;
 
-       data = kmalloc(AG71XX_RX_BUF_SIZE +
+       data = kmalloc(ag->rx_buf_size +
                       SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
                       GFP_ATOMIC);
        if (!data)
                return false;
 
        buf->rx_buf = data;
-       buf->dma_addr = dma_map_single(&ag->dev->dev, data,
-                                      AG71XX_RX_BUF_SIZE, DMA_FROM_DEVICE);
+       buf->dma_addr = dma_map_single(&ag->dev->dev, data, ag->rx_buf_size,
+                                      DMA_FROM_DEVICE);
        buf->desc->data = (u32) buf->dma_addr + offset;
        return true;
 }
@@ -609,6 +609,8 @@ static int ag71xx_open(struct net_device *dev)
        struct ag71xx *ag = netdev_priv(dev);
        int ret;
 
+       ag->rx_buf_size = AG71XX_RX_PKT_SIZE + NET_SKB_PAD + NET_IP_ALIGN;
+
        ret = ag71xx_rings_init(ag);
        if (ret)
                goto err;
@@ -890,7 +892,7 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
                pktlen -= ETH_FCS_LEN;
 
                dma_unmap_single(&dev->dev, ring->buf[i].dma_addr,
-                                AG71XX_RX_BUF_SIZE, DMA_FROM_DEVICE);
+                                ag->rx_buf_size, DMA_FROM_DEVICE);
 
                dev->stats.rx_packets++;
                dev->stats.rx_bytes += pktlen;