Skip to content

Commit 18b0aff

Browse files
committed
Merge branch 'ibmvnic-reset-behavior-fixes'
John Allen says: ==================== ibmvnic: Reset behavior fixes This patchset fixes a number of issues related to ibmvnic reset uncovered from testing new Power9 machines with Everglades adapters and the new functionality to change mtu and other parameters in the driver. Changes since v1: -In patch 1/3, added the line to free the long term buffers before allocating a new one. This change inadvertently uncovered the problem that the number of queues can change after a failover as well. To fix this, we check whether or not the number of queues has changed in do_reset and if they have, we do a full release and init of the queues. -In patch 1/3, added variables to the adapter struct to track how many rx/tx pools have actually been allocated and modify the release pools routines to use these values rather than the possibly incorrect req_rx/tx_queues values. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b589513 + 69d08dc commit 18b0aff

File tree

2 files changed

+60
-15
lines changed

2 files changed

+60
-15
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 58 additions & 15 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

@@ -860,7 +881,7 @@ static int ibmvnic_get_vpd(struct ibmvnic_adapter *adapter)
860881
if (adapter->vpd->buff)
861882
len = adapter->vpd->len;
862883

863-
reinit_completion(&adapter->fw_done);
884+
init_completion(&adapter->fw_done);
864885
crq.get_vpd_size.first = IBMVNIC_CRQ_CMD;
865886
crq.get_vpd_size.cmd = GET_VPD_SIZE;
866887
ibmvnic_send_crq(adapter, &crq);
@@ -922,6 +943,13 @@ static int init_resources(struct ibmvnic_adapter *adapter)
922943
if (!adapter->vpd)
923944
return -ENOMEM;
924945

946+
/* Vital Product Data (VPD) */
947+
rc = ibmvnic_get_vpd(adapter);
948+
if (rc) {
949+
netdev_err(netdev, "failed to initialize Vital Product Data (VPD)\n");
950+
return rc;
951+
}
952+
925953
adapter->map_id = 1;
926954
adapter->napi = kcalloc(adapter->req_rx_queues,
927955
sizeof(struct napi_struct), GFP_KERNEL);
@@ -995,7 +1023,7 @@ static int __ibmvnic_open(struct net_device *netdev)
9951023
static int ibmvnic_open(struct net_device *netdev)
9961024
{
9971025
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
998-
int rc, vpd;
1026+
int rc;
9991027

10001028
mutex_lock(&adapter->reset_lock);
10011029

@@ -1018,11 +1046,6 @@ static int ibmvnic_open(struct net_device *netdev)
10181046
rc = __ibmvnic_open(netdev);
10191047
netif_carrier_on(netdev);
10201048

1021-
/* Vital Product Data (VPD) */
1022-
vpd = ibmvnic_get_vpd(adapter);
1023-
if (vpd)
1024-
netdev_err(netdev, "failed to initialize Vital Product Data (VPD)\n");
1025-
10261049
mutex_unlock(&adapter->reset_lock);
10271050

10281051
return rc;
@@ -1548,6 +1571,7 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
15481571
static int do_reset(struct ibmvnic_adapter *adapter,
15491572
struct ibmvnic_rwi *rwi, u32 reset_state)
15501573
{
1574+
u64 old_num_rx_queues, old_num_tx_queues;
15511575
struct net_device *netdev = adapter->netdev;
15521576
int i, rc;
15531577

@@ -1557,6 +1581,9 @@ static int do_reset(struct ibmvnic_adapter *adapter,
15571581
netif_carrier_off(netdev);
15581582
adapter->reset_reason = rwi->reset_reason;
15591583

1584+
old_num_rx_queues = adapter->req_rx_queues;
1585+
old_num_tx_queues = adapter->req_tx_queues;
1586+
15601587
if (rwi->reset_reason == VNIC_RESET_MOBILITY) {
15611588
rc = ibmvnic_reenable_crq_queue(adapter);
15621589
if (rc)
@@ -1601,6 +1628,12 @@ static int do_reset(struct ibmvnic_adapter *adapter,
16011628
rc = init_resources(adapter);
16021629
if (rc)
16031630
return rc;
1631+
} else if (adapter->req_rx_queues != old_num_rx_queues ||
1632+
adapter->req_tx_queues != old_num_tx_queues) {
1633+
release_rx_pools(adapter);
1634+
release_tx_pools(adapter);
1635+
init_rx_pools(netdev);
1636+
init_tx_pools(netdev);
16041637
} else {
16051638
rc = reset_tx_pools(adapter);
16061639
if (rc)
@@ -3592,7 +3625,17 @@ static void handle_request_cap_rsp(union ibmvnic_crq *crq,
35923625
*req_value,
35933626
(long int)be64_to_cpu(crq->request_capability_rsp.
35943627
number), name);
3595-
*req_value = be64_to_cpu(crq->request_capability_rsp.number);
3628+
3629+
if (be16_to_cpu(crq->request_capability_rsp.capability) ==
3630+
REQ_MTU) {
3631+
pr_err("mtu of %llu is not supported. Reverting.\n",
3632+
*req_value);
3633+
*req_value = adapter->fallback.mtu;
3634+
} else {
3635+
*req_value =
3636+
be64_to_cpu(crq->request_capability_rsp.number);
3637+
}
3638+
35963639
ibmvnic_send_req_caps(adapter, 1);
35973640
return;
35983641
default:

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)