Commit 82e3be32 authored by Nathan Fontenot's avatar Nathan Fontenot Committed by David S. Miller

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: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2510babc
...@@ -461,7 +461,7 @@ static void release_rx_pools(struct ibmvnic_adapter *adapter) ...@@ -461,7 +461,7 @@ static void release_rx_pools(struct ibmvnic_adapter *adapter)
if (!adapter->rx_pool) if (!adapter->rx_pool)
return; return;
for (i = 0; i < adapter->num_active_rx_scrqs; i++) { for (i = 0; i < adapter->num_active_rx_pools; i++) {
rx_pool = &adapter->rx_pool[i]; rx_pool = &adapter->rx_pool[i];
netdev_dbg(adapter->netdev, "Releasing rx_pool[%d]\n", i); netdev_dbg(adapter->netdev, "Releasing rx_pool[%d]\n", i);
...@@ -484,6 +484,7 @@ static void release_rx_pools(struct ibmvnic_adapter *adapter) ...@@ -484,6 +484,7 @@ static void release_rx_pools(struct ibmvnic_adapter *adapter)
kfree(adapter->rx_pool); kfree(adapter->rx_pool);
adapter->rx_pool = NULL; adapter->rx_pool = NULL;
adapter->num_active_rx_pools = 0;
} }
static int init_rx_pools(struct net_device *netdev) static int init_rx_pools(struct net_device *netdev)
...@@ -508,6 +509,8 @@ static int init_rx_pools(struct net_device *netdev) ...@@ -508,6 +509,8 @@ static int init_rx_pools(struct net_device *netdev)
return -1; return -1;
} }
adapter->num_active_rx_pools = rxadd_subcrqs;
for (i = 0; i < rxadd_subcrqs; i++) { for (i = 0; i < rxadd_subcrqs; i++) {
rx_pool = &adapter->rx_pool[i]; rx_pool = &adapter->rx_pool[i];
...@@ -608,7 +611,7 @@ static void release_tx_pools(struct ibmvnic_adapter *adapter) ...@@ -608,7 +611,7 @@ static void release_tx_pools(struct ibmvnic_adapter *adapter)
if (!adapter->tx_pool) if (!adapter->tx_pool)
return; return;
for (i = 0; i < adapter->num_active_tx_scrqs; i++) { for (i = 0; i < adapter->num_active_tx_pools; i++) {
netdev_dbg(adapter->netdev, "Releasing tx_pool[%d]\n", i); netdev_dbg(adapter->netdev, "Releasing tx_pool[%d]\n", i);
tx_pool = &adapter->tx_pool[i]; tx_pool = &adapter->tx_pool[i];
kfree(tx_pool->tx_buff); kfree(tx_pool->tx_buff);
...@@ -619,6 +622,7 @@ static void release_tx_pools(struct ibmvnic_adapter *adapter) ...@@ -619,6 +622,7 @@ static void release_tx_pools(struct ibmvnic_adapter *adapter)
kfree(adapter->tx_pool); kfree(adapter->tx_pool);
adapter->tx_pool = NULL; adapter->tx_pool = NULL;
adapter->num_active_tx_pools = 0;
} }
static int init_tx_pools(struct net_device *netdev) static int init_tx_pools(struct net_device *netdev)
...@@ -635,6 +639,8 @@ static int init_tx_pools(struct net_device *netdev) ...@@ -635,6 +639,8 @@ static int init_tx_pools(struct net_device *netdev)
if (!adapter->tx_pool) if (!adapter->tx_pool)
return -1; return -1;
adapter->num_active_tx_pools = tx_subcrqs;
for (i = 0; i < tx_subcrqs; i++) { for (i = 0; i < tx_subcrqs; i++) {
tx_pool = &adapter->tx_pool[i]; tx_pool = &adapter->tx_pool[i];
...@@ -745,6 +751,7 @@ static int init_napi(struct ibmvnic_adapter *adapter) ...@@ -745,6 +751,7 @@ static int init_napi(struct ibmvnic_adapter *adapter)
ibmvnic_poll, NAPI_POLL_WEIGHT); ibmvnic_poll, NAPI_POLL_WEIGHT);
} }
adapter->num_active_rx_napi = adapter->req_rx_queues;
return 0; return 0;
} }
...@@ -755,7 +762,7 @@ static void release_napi(struct ibmvnic_adapter *adapter) ...@@ -755,7 +762,7 @@ static void release_napi(struct ibmvnic_adapter *adapter)
if (!adapter->napi) if (!adapter->napi)
return; return;
for (i = 0; i < adapter->num_active_rx_scrqs; i++) { for (i = 0; i < adapter->num_active_rx_napi; i++) {
if (&adapter->napi[i]) { if (&adapter->napi[i]) {
netdev_dbg(adapter->netdev, netdev_dbg(adapter->netdev,
"Releasing napi[%d]\n", i); "Releasing napi[%d]\n", i);
...@@ -765,6 +772,7 @@ static void release_napi(struct ibmvnic_adapter *adapter) ...@@ -765,6 +772,7 @@ static void release_napi(struct ibmvnic_adapter *adapter)
kfree(adapter->napi); kfree(adapter->napi);
adapter->napi = NULL; adapter->napi = NULL;
adapter->num_active_rx_napi = 0;
} }
static int ibmvnic_login(struct net_device *netdev) static int ibmvnic_login(struct net_device *netdev)
...@@ -998,10 +1006,6 @@ static int init_resources(struct ibmvnic_adapter *adapter) ...@@ -998,10 +1006,6 @@ static int init_resources(struct ibmvnic_adapter *adapter)
return rc; return rc;
rc = init_tx_pools(netdev); rc = init_tx_pools(netdev);
adapter->num_active_tx_scrqs = adapter->req_tx_queues;
adapter->num_active_rx_scrqs = adapter->req_rx_queues;
return rc; return rc;
} }
...@@ -1706,9 +1710,6 @@ static int do_reset(struct ibmvnic_adapter *adapter, ...@@ -1706,9 +1710,6 @@ static int do_reset(struct ibmvnic_adapter *adapter,
release_napi(adapter); release_napi(adapter);
init_napi(adapter); init_napi(adapter);
adapter->num_active_tx_scrqs = adapter->req_tx_queues;
adapter->num_active_rx_scrqs = adapter->req_rx_queues;
} else { } else {
rc = reset_tx_pools(adapter); rc = reset_tx_pools(adapter);
if (rc) if (rc)
...@@ -2398,19 +2399,10 @@ static struct ibmvnic_sub_crq_queue *init_sub_crq_queue(struct ibmvnic_adapter ...@@ -2398,19 +2399,10 @@ static struct ibmvnic_sub_crq_queue *init_sub_crq_queue(struct ibmvnic_adapter
static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free) static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free)
{ {
u64 num_tx_scrqs, num_rx_scrqs;
int i; int i;
if (adapter->state == VNIC_PROBED) {
num_tx_scrqs = adapter->req_tx_queues;
num_rx_scrqs = adapter->req_rx_queues;
} else {
num_tx_scrqs = adapter->num_active_tx_scrqs;
num_rx_scrqs = adapter->num_active_rx_scrqs;
}
if (adapter->tx_scrq) { if (adapter->tx_scrq) {
for (i = 0; i < num_tx_scrqs; i++) { for (i = 0; i < adapter->num_active_tx_scrqs; i++) {
if (!adapter->tx_scrq[i]) if (!adapter->tx_scrq[i])
continue; continue;
...@@ -2429,10 +2421,11 @@ static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free) ...@@ -2429,10 +2421,11 @@ static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free)
kfree(adapter->tx_scrq); kfree(adapter->tx_scrq);
adapter->tx_scrq = NULL; adapter->tx_scrq = NULL;
adapter->num_active_tx_scrqs = 0;
} }
if (adapter->rx_scrq) { if (adapter->rx_scrq) {
for (i = 0; i < num_rx_scrqs; i++) { for (i = 0; i < adapter->num_active_rx_scrqs; i++) {
if (!adapter->rx_scrq[i]) if (!adapter->rx_scrq[i])
continue; continue;
...@@ -2451,6 +2444,7 @@ static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free) ...@@ -2451,6 +2444,7 @@ static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free)
kfree(adapter->rx_scrq); kfree(adapter->rx_scrq);
adapter->rx_scrq = NULL; adapter->rx_scrq = NULL;
adapter->num_active_rx_scrqs = 0;
} }
} }
...@@ -2718,6 +2712,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter) ...@@ -2718,6 +2712,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter)
for (i = 0; i < adapter->req_tx_queues; i++) { for (i = 0; i < adapter->req_tx_queues; i++) {
adapter->tx_scrq[i] = allqueues[i]; adapter->tx_scrq[i] = allqueues[i];
adapter->tx_scrq[i]->pool_index = i; adapter->tx_scrq[i]->pool_index = i;
adapter->num_active_tx_scrqs++;
} }
adapter->rx_scrq = kcalloc(adapter->req_rx_queues, adapter->rx_scrq = kcalloc(adapter->req_rx_queues,
...@@ -2728,6 +2723,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter) ...@@ -2728,6 +2723,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter)
for (i = 0; i < adapter->req_rx_queues; i++) { for (i = 0; i < adapter->req_rx_queues; i++) {
adapter->rx_scrq[i] = allqueues[i + adapter->req_tx_queues]; adapter->rx_scrq[i] = allqueues[i + adapter->req_tx_queues];
adapter->rx_scrq[i]->scrq_num = i; adapter->rx_scrq[i]->scrq_num = i;
adapter->num_active_rx_scrqs++;
} }
kfree(allqueues); kfree(allqueues);
......
...@@ -1092,8 +1092,11 @@ struct ibmvnic_adapter { ...@@ -1092,8 +1092,11 @@ struct ibmvnic_adapter {
u64 opt_rxba_entries_per_subcrq; u64 opt_rxba_entries_per_subcrq;
__be64 tx_rx_desc_req; __be64 tx_rx_desc_req;
u8 map_id; u8 map_id;
u64 num_active_rx_scrqs; u32 num_active_rx_scrqs;
u64 num_active_tx_scrqs; u32 num_active_rx_pools;
u32 num_active_rx_napi;
u32 num_active_tx_scrqs;
u32 num_active_tx_pools;
struct tasklet_struct tasklet; struct tasklet_struct tasklet;
enum vnic_state state; enum vnic_state state;
......
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