Skip to content

Commit 896d869

Browse files
jallen93davem330
authored andcommitted
ibmvnic: Modify buffer size and number of queues on failover
Using newer backing devices can cause the required padding at the end of buffer as well as the number of queues to change after a failover. Since we currently assume that these values never change, after a failover to a backing device with different capabilities, we can get errors from the vnic server, attempt to free long term buffers that are no longer there, or not free long term buffers that should be freed. This patch resolves the issue by checking whether any of these values change, and if so perform the necessary re-allocations. Signed-off-by: John Allen <[email protected]> Reviewed-by: Nathan Fontenot <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b589513 commit 896d869

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,28 @@ static int reset_rx_pools(struct ibmvnic_adapter *adapter)
410410
struct ibmvnic_rx_pool *rx_pool;
411411
int rx_scrqs;
412412
int i, j, rc;
413+
u64 *size_array;
414+
415+
size_array = (u64 *)((u8 *)(adapter->login_rsp_buf) +
416+
be32_to_cpu(adapter->login_rsp_buf->off_rxadd_buff_size));
413417

414418
rx_scrqs = be32_to_cpu(adapter->login_rsp_buf->num_rxadd_subcrqs);
415419
for (i = 0; i < rx_scrqs; i++) {
416420
rx_pool = &adapter->rx_pool[i];
417421

418422
netdev_dbg(adapter->netdev, "Re-setting rx_pool[%d]\n", i);
419423

420-
rc = reset_long_term_buff(adapter, &rx_pool->long_term_buff);
424+
if (rx_pool->buff_size != be64_to_cpu(size_array[i])) {
425+
free_long_term_buff(adapter, &rx_pool->long_term_buff);
426+
rx_pool->buff_size = be64_to_cpu(size_array[i]);
427+
alloc_long_term_buff(adapter, &rx_pool->long_term_buff,
428+
rx_pool->size *
429+
rx_pool->buff_size);
430+
} else {
431+
rc = reset_long_term_buff(adapter,
432+
&rx_pool->long_term_buff);
433+
}
434+
421435
if (rc)
422436
return rc;
423437

@@ -439,14 +453,12 @@ static int reset_rx_pools(struct ibmvnic_adapter *adapter)
439453
static void release_rx_pools(struct ibmvnic_adapter *adapter)
440454
{
441455
struct ibmvnic_rx_pool *rx_pool;
442-
int rx_scrqs;
443456
int i, j;
444457

445458
if (!adapter->rx_pool)
446459
return;
447460

448-
rx_scrqs = be32_to_cpu(adapter->login_rsp_buf->num_rxadd_subcrqs);
449-
for (i = 0; i < rx_scrqs; i++) {
461+
for (i = 0; i < adapter->num_active_rx_pools; i++) {
450462
rx_pool = &adapter->rx_pool[i];
451463

452464
netdev_dbg(adapter->netdev, "Releasing rx_pool[%d]\n", i);
@@ -469,6 +481,7 @@ static void release_rx_pools(struct ibmvnic_adapter *adapter)
469481

470482
kfree(adapter->rx_pool);
471483
adapter->rx_pool = NULL;
484+
adapter->num_active_rx_pools = 0;
472485
}
473486

474487
static int init_rx_pools(struct net_device *netdev)
@@ -493,6 +506,8 @@ static int init_rx_pools(struct net_device *netdev)
493506
return -1;
494507
}
495508

509+
adapter->num_active_rx_pools = 0;
510+
496511
for (i = 0; i < rxadd_subcrqs; i++) {
497512
rx_pool = &adapter->rx_pool[i];
498513

@@ -536,6 +551,8 @@ static int init_rx_pools(struct net_device *netdev)
536551
rx_pool->next_free = 0;
537552
}
538553

554+
adapter->num_active_rx_pools = rxadd_subcrqs;
555+
539556
return 0;
540557
}
541558

@@ -586,13 +603,12 @@ static void release_vpd_data(struct ibmvnic_adapter *adapter)
586603
static void release_tx_pools(struct ibmvnic_adapter *adapter)
587604
{
588605
struct ibmvnic_tx_pool *tx_pool;
589-
int i, tx_scrqs;
606+
int i;
590607

591608
if (!adapter->tx_pool)
592609
return;
593610

594-
tx_scrqs = be32_to_cpu(adapter->login_rsp_buf->num_txsubm_subcrqs);
595-
for (i = 0; i < tx_scrqs; i++) {
611+
for (i = 0; i < adapter->num_active_tx_pools; i++) {
596612
netdev_dbg(adapter->netdev, "Releasing tx_pool[%d]\n", i);
597613
tx_pool = &adapter->tx_pool[i];
598614
kfree(tx_pool->tx_buff);
@@ -603,6 +619,7 @@ static void release_tx_pools(struct ibmvnic_adapter *adapter)
603619

604620
kfree(adapter->tx_pool);
605621
adapter->tx_pool = NULL;
622+
adapter->num_active_tx_pools = 0;
606623
}
607624

608625
static int init_tx_pools(struct net_device *netdev)
@@ -619,6 +636,8 @@ static int init_tx_pools(struct net_device *netdev)
619636
if (!adapter->tx_pool)
620637
return -1;
621638

639+
adapter->num_active_tx_pools = 0;
640+
622641
for (i = 0; i < tx_subcrqs; i++) {
623642
tx_pool = &adapter->tx_pool[i];
624643

@@ -666,6 +685,8 @@ static int init_tx_pools(struct net_device *netdev)
666685
tx_pool->producer_index = 0;
667686
}
668687

688+
adapter->num_active_tx_pools = tx_subcrqs;
689+
669690
return 0;
670691
}
671692

@@ -1548,6 +1569,7 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
15481569
static int do_reset(struct ibmvnic_adapter *adapter,
15491570
struct ibmvnic_rwi *rwi, u32 reset_state)
15501571
{
1572+
u64 old_num_rx_queues, old_num_tx_queues;
15511573
struct net_device *netdev = adapter->netdev;
15521574
int i, rc;
15531575

@@ -1557,6 +1579,9 @@ static int do_reset(struct ibmvnic_adapter *adapter,
15571579
netif_carrier_off(netdev);
15581580
adapter->reset_reason = rwi->reset_reason;
15591581

1582+
old_num_rx_queues = adapter->req_rx_queues;
1583+
old_num_tx_queues = adapter->req_tx_queues;
1584+
15601585
if (rwi->reset_reason == VNIC_RESET_MOBILITY) {
15611586
rc = ibmvnic_reenable_crq_queue(adapter);
15621587
if (rc)
@@ -1601,6 +1626,12 @@ static int do_reset(struct ibmvnic_adapter *adapter,
16011626
rc = init_resources(adapter);
16021627
if (rc)
16031628
return rc;
1629+
} else if (adapter->req_rx_queues != old_num_rx_queues ||
1630+
adapter->req_tx_queues != old_num_tx_queues) {
1631+
release_rx_pools(adapter);
1632+
release_tx_pools(adapter);
1633+
init_rx_pools(netdev);
1634+
init_tx_pools(netdev);
16041635
} else {
16051636
rc = reset_tx_pools(adapter);
16061637
if (rc)

drivers/net/ethernet/ibm/ibmvnic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,8 @@ struct ibmvnic_adapter {
10911091
u64 opt_rxba_entries_per_subcrq;
10921092
__be64 tx_rx_desc_req;
10931093
u8 map_id;
1094+
u64 num_active_rx_pools;
1095+
u64 num_active_tx_pools;
10941096

10951097
struct tasklet_struct tasklet;
10961098
enum vnic_state state;

0 commit comments

Comments
 (0)