Commit ea866e65 authored by Santiago Leon's avatar Santiago Leon Committed by Benjamin Herrenschmidt

ibmveth: Automatically enable larger rx buffer pools for larger mtu

Activates larger rx buffer pools when the MTU is changed to a larger
value.  This patch de-activates the large rx buffer pools when the MTU
changes to a smaller value.
Signed-off-by: default avatarSantiago Leon <santil@us.ibm.com>
Signed-off-by: default avatarRobert Jennings <rcj@linux.vnet.ibm.com>
Acked-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 22e1a4dd
...@@ -1054,7 +1054,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu) ...@@ -1054,7 +1054,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
{ {
struct ibmveth_adapter *adapter = dev->priv; struct ibmveth_adapter *adapter = dev->priv;
int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH; int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH;
int reinit = 0;
int i, rc; int i, rc;
if (new_mtu < IBMVETH_MAX_MTU) if (new_mtu < IBMVETH_MAX_MTU)
...@@ -1067,15 +1066,21 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu) ...@@ -1067,15 +1066,21 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
if (i == IbmVethNumBufferPools) if (i == IbmVethNumBufferPools)
return -EINVAL; return -EINVAL;
/* Deactivate all the buffer pools so that the next loop can activate
only the buffer pools necessary to hold the new MTU */
for (i = 0; i < IbmVethNumBufferPools; i++)
if (adapter->rx_buff_pool[i].active) {
ibmveth_free_buffer_pool(adapter,
&adapter->rx_buff_pool[i]);
adapter->rx_buff_pool[i].active = 0;
}
/* Look for an active buffer pool that can hold the new MTU */ /* Look for an active buffer pool that can hold the new MTU */
for(i = 0; i<IbmVethNumBufferPools; i++) { for(i = 0; i<IbmVethNumBufferPools; i++) {
if (!adapter->rx_buff_pool[i].active) {
adapter->rx_buff_pool[i].active = 1; adapter->rx_buff_pool[i].active = 1;
reinit = 1;
}
if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) { if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
if (reinit && netif_running(adapter->netdev)) { if (netif_running(adapter->netdev)) {
adapter->pool_config = 1; adapter->pool_config = 1;
ibmveth_close(adapter->netdev); ibmveth_close(adapter->netdev);
adapter->pool_config = 0; adapter->pool_config = 0;
...@@ -1402,14 +1407,15 @@ const char * buf, size_t count) ...@@ -1402,14 +1407,15 @@ const char * buf, size_t count)
return -EPERM; return -EPERM;
} }
pool->active = 0;
if (netif_running(netdev)) { if (netif_running(netdev)) {
adapter->pool_config = 1; adapter->pool_config = 1;
ibmveth_close(netdev); ibmveth_close(netdev);
pool->active = 0;
adapter->pool_config = 0; adapter->pool_config = 0;
if ((rc = ibmveth_open(netdev))) if ((rc = ibmveth_open(netdev)))
return rc; return rc;
} }
pool->active = 0;
} }
} else if (attr == &veth_num_attr) { } else if (attr == &veth_num_attr) {
if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT) if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT)
......
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