Commit 9088d9a4 authored by Francois Romieu's avatar Francois Romieu Committed by Jeff Garzik

via-velocity: add velocity_set_rxbufsize helper

It removes a dependancy from velocity_init_rd_ring to dev->mtu.
Signed-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 28133176
...@@ -1207,6 +1207,11 @@ static int velocity_rx_refill(struct velocity_info *vptr) ...@@ -1207,6 +1207,11 @@ static int velocity_rx_refill(struct velocity_info *vptr)
return done; return done;
} }
static void velocity_set_rxbufsize(struct velocity_info *vptr, int mtu)
{
vptr->rx_buf_sz = (mtu <= ETH_DATA_LEN) ? PKT_BUF_SZ : mtu + 32;
}
/** /**
* velocity_init_rd_ring - set up receive ring * velocity_init_rd_ring - set up receive ring
* @vptr: velocity to configure * @vptr: velocity to configure
...@@ -1217,11 +1222,8 @@ static int velocity_rx_refill(struct velocity_info *vptr) ...@@ -1217,11 +1222,8 @@ static int velocity_rx_refill(struct velocity_info *vptr)
static int velocity_init_rd_ring(struct velocity_info *vptr) static int velocity_init_rd_ring(struct velocity_info *vptr)
{ {
int mtu = vptr->dev->mtu;
int ret = -ENOMEM; int ret = -ENOMEM;
vptr->rx_buf_sz = (mtu <= ETH_DATA_LEN) ? PKT_BUF_SZ : mtu + 32;
vptr->rd_info = kcalloc(vptr->options.numrx, vptr->rd_info = kcalloc(vptr->options.numrx,
sizeof(struct velocity_rd_info), GFP_KERNEL); sizeof(struct velocity_rd_info), GFP_KERNEL);
if (!vptr->rd_info) if (!vptr->rd_info)
...@@ -1860,6 +1862,8 @@ static int velocity_open(struct net_device *dev) ...@@ -1860,6 +1862,8 @@ static int velocity_open(struct net_device *dev)
struct velocity_info *vptr = netdev_priv(dev); struct velocity_info *vptr = netdev_priv(dev);
int ret; int ret;
velocity_set_rxbufsize(vptr, dev->mtu);
ret = velocity_init_rings(vptr); ret = velocity_init_rings(vptr);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -1941,6 +1945,8 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu) ...@@ -1941,6 +1945,8 @@ static int velocity_change_mtu(struct net_device *dev, int new_mtu)
dev->mtu = new_mtu; dev->mtu = new_mtu;
velocity_set_rxbufsize(vptr, new_mtu);
ret = velocity_init_rd_ring(vptr); ret = velocity_init_rd_ring(vptr);
if (ret < 0) if (ret < 0)
goto out_unlock; goto out_unlock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment