Skip to content

Commit 82e3be3

Browse files
nfontdavem330
authored andcommitted
ibmvnic: Split counters for scrq/pools/napi
The approach of one counter to rule them all when tracking the number of active sub-crqs, pools, and napi has problems handling some failover scenarios. This is due to the split in initializing the sub crqs, pools and napi in different places and the placement of updating the active counts. This patch simplifies this by having a counter for tx and rx sub-crqs, pools, and napi. Signed-off-by: Nathan Fontenot <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2510bab commit 82e3be3

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static void release_rx_pools(struct ibmvnic_adapter *adapter)
461461
if (!adapter->rx_pool)
462462
return;
463463

464-
for (i = 0; i < adapter->num_active_rx_scrqs; i++) {
464+
for (i = 0; i < adapter->num_active_rx_pools; i++) {
465465
rx_pool = &adapter->rx_pool[i];
466466

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

485485
kfree(adapter->rx_pool);
486486
adapter->rx_pool = NULL;
487+
adapter->num_active_rx_pools = 0;
487488
}
488489

489490
static int init_rx_pools(struct net_device *netdev)
@@ -508,6 +509,8 @@ static int init_rx_pools(struct net_device *netdev)
508509
return -1;
509510
}
510511

512+
adapter->num_active_rx_pools = rxadd_subcrqs;
513+
511514
for (i = 0; i < rxadd_subcrqs; i++) {
512515
rx_pool = &adapter->rx_pool[i];
513516

@@ -608,7 +611,7 @@ static void release_tx_pools(struct ibmvnic_adapter *adapter)
608611
if (!adapter->tx_pool)
609612
return;
610613

611-
for (i = 0; i < adapter->num_active_tx_scrqs; i++) {
614+
for (i = 0; i < adapter->num_active_tx_pools; i++) {
612615
netdev_dbg(adapter->netdev, "Releasing tx_pool[%d]\n", i);
613616
tx_pool = &adapter->tx_pool[i];
614617
kfree(tx_pool->tx_buff);
@@ -619,6 +622,7 @@ static void release_tx_pools(struct ibmvnic_adapter *adapter)
619622

620623
kfree(adapter->tx_pool);
621624
adapter->tx_pool = NULL;
625+
adapter->num_active_tx_pools = 0;
622626
}
623627

624628
static int init_tx_pools(struct net_device *netdev)
@@ -635,6 +639,8 @@ static int init_tx_pools(struct net_device *netdev)
635639
if (!adapter->tx_pool)
636640
return -1;
637641

642+
adapter->num_active_tx_pools = tx_subcrqs;
643+
638644
for (i = 0; i < tx_subcrqs; i++) {
639645
tx_pool = &adapter->tx_pool[i];
640646

@@ -745,6 +751,7 @@ static int init_napi(struct ibmvnic_adapter *adapter)
745751
ibmvnic_poll, NAPI_POLL_WEIGHT);
746752
}
747753

754+
adapter->num_active_rx_napi = adapter->req_rx_queues;
748755
return 0;
749756
}
750757

@@ -755,7 +762,7 @@ static void release_napi(struct ibmvnic_adapter *adapter)
755762
if (!adapter->napi)
756763
return;
757764

758-
for (i = 0; i < adapter->num_active_rx_scrqs; i++) {
765+
for (i = 0; i < adapter->num_active_rx_napi; i++) {
759766
if (&adapter->napi[i]) {
760767
netdev_dbg(adapter->netdev,
761768
"Releasing napi[%d]\n", i);
@@ -765,6 +772,7 @@ static void release_napi(struct ibmvnic_adapter *adapter)
765772

766773
kfree(adapter->napi);
767774
adapter->napi = NULL;
775+
adapter->num_active_rx_napi = 0;
768776
}
769777

770778
static int ibmvnic_login(struct net_device *netdev)
@@ -998,10 +1006,6 @@ static int init_resources(struct ibmvnic_adapter *adapter)
9981006
return rc;
9991007

10001008
rc = init_tx_pools(netdev);
1001-
1002-
adapter->num_active_tx_scrqs = adapter->req_tx_queues;
1003-
adapter->num_active_rx_scrqs = adapter->req_rx_queues;
1004-
10051009
return rc;
10061010
}
10071011

@@ -1706,9 +1710,6 @@ static int do_reset(struct ibmvnic_adapter *adapter,
17061710

17071711
release_napi(adapter);
17081712
init_napi(adapter);
1709-
1710-
adapter->num_active_tx_scrqs = adapter->req_tx_queues;
1711-
adapter->num_active_rx_scrqs = adapter->req_rx_queues;
17121713
} else {
17131714
rc = reset_tx_pools(adapter);
17141715
if (rc)
@@ -2398,19 +2399,10 @@ static struct ibmvnic_sub_crq_queue *init_sub_crq_queue(struct ibmvnic_adapter
23982399

23992400
static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free)
24002401
{
2401-
u64 num_tx_scrqs, num_rx_scrqs;
24022402
int i;
24032403

2404-
if (adapter->state == VNIC_PROBED) {
2405-
num_tx_scrqs = adapter->req_tx_queues;
2406-
num_rx_scrqs = adapter->req_rx_queues;
2407-
} else {
2408-
num_tx_scrqs = adapter->num_active_tx_scrqs;
2409-
num_rx_scrqs = adapter->num_active_rx_scrqs;
2410-
}
2411-
24122404
if (adapter->tx_scrq) {
2413-
for (i = 0; i < num_tx_scrqs; i++) {
2405+
for (i = 0; i < adapter->num_active_tx_scrqs; i++) {
24142406
if (!adapter->tx_scrq[i])
24152407
continue;
24162408

@@ -2429,10 +2421,11 @@ static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free)
24292421

24302422
kfree(adapter->tx_scrq);
24312423
adapter->tx_scrq = NULL;
2424+
adapter->num_active_tx_scrqs = 0;
24322425
}
24332426

24342427
if (adapter->rx_scrq) {
2435-
for (i = 0; i < num_rx_scrqs; i++) {
2428+
for (i = 0; i < adapter->num_active_rx_scrqs; i++) {
24362429
if (!adapter->rx_scrq[i])
24372430
continue;
24382431

@@ -2451,6 +2444,7 @@ static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free)
24512444

24522445
kfree(adapter->rx_scrq);
24532446
adapter->rx_scrq = NULL;
2447+
adapter->num_active_rx_scrqs = 0;
24542448
}
24552449
}
24562450

@@ -2718,6 +2712,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter)
27182712
for (i = 0; i < adapter->req_tx_queues; i++) {
27192713
adapter->tx_scrq[i] = allqueues[i];
27202714
adapter->tx_scrq[i]->pool_index = i;
2715+
adapter->num_active_tx_scrqs++;
27212716
}
27222717

27232718
adapter->rx_scrq = kcalloc(adapter->req_rx_queues,
@@ -2728,6 +2723,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter)
27282723
for (i = 0; i < adapter->req_rx_queues; i++) {
27292724
adapter->rx_scrq[i] = allqueues[i + adapter->req_tx_queues];
27302725
adapter->rx_scrq[i]->scrq_num = i;
2726+
adapter->num_active_rx_scrqs++;
27312727
}
27322728

27332729
kfree(allqueues);

drivers/net/ethernet/ibm/ibmvnic.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,11 @@ struct ibmvnic_adapter {
10921092
u64 opt_rxba_entries_per_subcrq;
10931093
__be64 tx_rx_desc_req;
10941094
u8 map_id;
1095-
u64 num_active_rx_scrqs;
1096-
u64 num_active_tx_scrqs;
1095+
u32 num_active_rx_scrqs;
1096+
u32 num_active_rx_pools;
1097+
u32 num_active_rx_napi;
1098+
u32 num_active_tx_scrqs;
1099+
u32 num_active_tx_pools;
10971100

10981101
struct tasklet_struct tasklet;
10991102
enum vnic_state state;

0 commit comments

Comments
 (0)