aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ibmveth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ibmveth.c')
-rw-r--r--drivers/net/ibmveth.c80
1 files changed, 54 insertions, 26 deletions
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 3bec0f733f01..6ec3d500f334 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -915,17 +915,36 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
915{ 915{
916 struct ibmveth_adapter *adapter = dev->priv; 916 struct ibmveth_adapter *adapter = dev->priv;
917 int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH; 917 int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH;
918 int i; 918 int reinit = 0;
919 int i, rc;
919 920
920 if (new_mtu < IBMVETH_MAX_MTU) 921 if (new_mtu < IBMVETH_MAX_MTU)
921 return -EINVAL; 922 return -EINVAL;
922 923
924 for (i = 0; i < IbmVethNumBufferPools; i++)
925 if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size)
926 break;
927
928 if (i == IbmVethNumBufferPools)
929 return -EINVAL;
930
923 /* Look for an active buffer pool that can hold the new MTU */ 931 /* Look for an active buffer pool that can hold the new MTU */
924 for(i = 0; i<IbmVethNumBufferPools; i++) { 932 for(i = 0; i<IbmVethNumBufferPools; i++) {
925 if (!adapter->rx_buff_pool[i].active) 933 if (!adapter->rx_buff_pool[i].active) {
926 continue; 934 adapter->rx_buff_pool[i].active = 1;
935 reinit = 1;
936 }
937
927 if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) { 938 if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
928 dev->mtu = new_mtu; 939 if (reinit && netif_running(adapter->netdev)) {
940 adapter->pool_config = 1;
941 ibmveth_close(adapter->netdev);
942 adapter->pool_config = 0;
943 dev->mtu = new_mtu;
944 if ((rc = ibmveth_open(adapter->netdev)))
945 return rc;
946 } else
947 dev->mtu = new_mtu;
929 return 0; 948 return 0;
930 } 949 }
931 } 950 }
@@ -1243,16 +1262,19 @@ const char * buf, size_t count)
1243 1262
1244 if (attr == &veth_active_attr) { 1263 if (attr == &veth_active_attr) {
1245 if (value && !pool->active) { 1264 if (value && !pool->active) {
1246 if(ibmveth_alloc_buffer_pool(pool)) { 1265 if (netif_running(netdev)) {
1247 ibmveth_error_printk("unable to alloc pool\n"); 1266 if(ibmveth_alloc_buffer_pool(pool)) {
1248 return -ENOMEM; 1267 ibmveth_error_printk("unable to alloc pool\n");
1249 } 1268 return -ENOMEM;
1250 pool->active = 1; 1269 }
1251 adapter->pool_config = 1; 1270 pool->active = 1;
1252 ibmveth_close(netdev); 1271 adapter->pool_config = 1;
1253 adapter->pool_config = 0; 1272 ibmveth_close(netdev);
1254 if ((rc = ibmveth_open(netdev))) 1273 adapter->pool_config = 0;
1255 return rc; 1274 if ((rc = ibmveth_open(netdev)))
1275 return rc;
1276 } else
1277 pool->active = 1;
1256 } else if (!value && pool->active) { 1278 } else if (!value && pool->active) {
1257 int mtu = netdev->mtu + IBMVETH_BUFF_OH; 1279 int mtu = netdev->mtu + IBMVETH_BUFF_OH;
1258 int i; 1280 int i;
@@ -1281,23 +1303,29 @@ const char * buf, size_t count)
1281 if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT) 1303 if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT)
1282 return -EINVAL; 1304 return -EINVAL;
1283 else { 1305 else {
1284 adapter->pool_config = 1; 1306 if (netif_running(netdev)) {
1285 ibmveth_close(netdev); 1307 adapter->pool_config = 1;
1286 adapter->pool_config = 0; 1308 ibmveth_close(netdev);
1287 pool->size = value; 1309 adapter->pool_config = 0;
1288 if ((rc = ibmveth_open(netdev))) 1310 pool->size = value;
1289 return rc; 1311 if ((rc = ibmveth_open(netdev)))
1312 return rc;
1313 } else
1314 pool->size = value;
1290 } 1315 }
1291 } else if (attr == &veth_size_attr) { 1316 } else if (attr == &veth_size_attr) {
1292 if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE) 1317 if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE)
1293 return -EINVAL; 1318 return -EINVAL;
1294 else { 1319 else {
1295 adapter->pool_config = 1; 1320 if (netif_running(netdev)) {
1296 ibmveth_close(netdev); 1321 adapter->pool_config = 1;
1297 adapter->pool_config = 0; 1322 ibmveth_close(netdev);
1298 pool->buff_size = value; 1323 adapter->pool_config = 0;
1299 if ((rc = ibmveth_open(netdev))) 1324 pool->buff_size = value;
1300 return rc; 1325 if ((rc = ibmveth_open(netdev)))
1326 return rc;
1327 } else
1328 pool->buff_size = value;
1301 } 1329 }
1302 } 1330 }
1303 1331