diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2013-12-20 11:41:20 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2013-12-20 11:41:20 +0000 |
commit | 1f01aeabb0c6486e966e92b4c4361a12529c7181 (patch) | |
tree | 46dd4234b9cfe352718c2ce25356f71249a3c2c1 | |
parent | 60f7a8a3575c1ce8d2a159cb91dfb4a9d1f3edc4 (diff) | |
download | master-187ad058-1f01aeabb0c6486e966e92b4c4361a12529c7181.tar.gz master-187ad058-1f01aeabb0c6486e966e92b4c4361a12529c7181.tar.bz2 master-187ad058-1f01aeabb0c6486e966e92b4c4361a12529c7181.zip |
ar71xx: ag71xx: calculate max frame len register value from the MTU
Set the MAX_FRAME_LEN register to zero in ag71xx_hw_init()
and write the correct value into that from the ag71xx_open()
and ag71xx_fast_reset() functions.
Also recalculate the RX buffer size based on the actual
maximum frame length value to optimize memory allocation.
Additionaly, disallow to change the MTU value while the
interface it running.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@39147 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c index ce05c10882..715c1cef1b 100644 --- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c +++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c @@ -438,8 +438,8 @@ static void ag71xx_hw_setup(struct ag71xx *ag) ag71xx_sb(ag, AG71XX_REG_MAC_CFG2, MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK); - /* setup max frame length */ - ag71xx_wr(ag, AG71XX_REG_MAC_MFL, ag->max_frame_len); + /* setup max frame length to zero */ + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, 0); /* setup FIFO configuration registers */ ag71xx_wr(ag, AG71XX_REG_FIFO_CFG0, FIFO_CFG0_INIT); @@ -508,6 +508,10 @@ static void ag71xx_fast_reset(struct ag71xx *ag) ag71xx_dma_reset(ag); ag71xx_hw_setup(ag); + /* setup max frame length */ + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, + ag71xx_max_frame_len(ag->dev->mtu)); + ag71xx_wr(ag, AG71XX_REG_RX_DESC, rx_ds); ag71xx_wr(ag, AG71XX_REG_TX_DESC, tx_ds); ag71xx_wr(ag, AG71XX_REG_MII_CFG, mii_reg); @@ -612,9 +616,14 @@ void ag71xx_link_adjust(struct ag71xx *ag) static int ag71xx_open(struct net_device *dev) { struct ag71xx *ag = netdev_priv(dev); + unsigned int max_frame_len; int ret; - ag->rx_buf_size = ag->max_frame_len + NET_SKB_PAD + NET_IP_ALIGN; + max_frame_len = ag71xx_max_frame_len(dev->mtu); + ag->rx_buf_size = max_frame_len + NET_SKB_PAD + NET_IP_ALIGN; + + /* setup max frame length */ + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, max_frame_len); ret = ag71xx_rings_init(ag); if (ret) @@ -1063,6 +1072,9 @@ static int ag71xx_change_mtu(struct net_device *dev, int new_mtu) if (new_mtu < 68 || max_frame_len > ag->max_frame_len) return -EINVAL; + if (netif_running(dev)) + return -EBUSY; + dev->mtu = new_mtu; return 0; } |