Commit 86f669b2 authored by Nathan Fontenot's avatar Nathan Fontenot Committed by David S. Miller

ibmvnic: Make napi usage dynamic

In order to handle the number of rx sub crqs changing during a driver
reset, the ibmvnic driver also needs to update the number of napi.
To do this the code to init and free napi's is moved to their own
routines so they can be called during the reset process.
Signed-off-by: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d7c0ef36
......@@ -730,6 +730,43 @@ static void ibmvnic_napi_disable(struct ibmvnic_adapter *adapter)
adapter->napi_enabled = false;
}
static int init_napi(struct ibmvnic_adapter *adapter)
{
int i;
adapter->napi = kcalloc(adapter->req_rx_queues,
sizeof(struct napi_struct), GFP_KERNEL);
if (!adapter->napi)
return -ENOMEM;
for (i = 0; i < adapter->req_rx_queues; i++) {
netdev_dbg(adapter->netdev, "Adding napi[%d]\n", i);
netif_napi_add(adapter->netdev, &adapter->napi[i],
ibmvnic_poll, NAPI_POLL_WEIGHT);
}
return 0;
}
static void release_napi(struct ibmvnic_adapter *adapter)
{
int i;
if (!adapter->napi)
return;
for (i = 0; i < adapter->num_active_rx_scrqs; i++) {
if (&adapter->napi[i]) {
netdev_dbg(adapter->netdev,
"Releasing napi[%d]\n", i);
netif_napi_del(&adapter->napi[i]);
}
}
kfree(adapter->napi);
adapter->napi = NULL;
}
static int ibmvnic_login(struct net_device *netdev)
{
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
......@@ -795,8 +832,6 @@ static void release_login_rsp_buffer(struct ibmvnic_adapter *adapter)
static void release_resources(struct ibmvnic_adapter *adapter)
{
int i;
release_vpd_data(adapter);
release_tx_pools(adapter);
......@@ -805,19 +840,7 @@ static void release_resources(struct ibmvnic_adapter *adapter)
release_stats_token(adapter);
release_stats_buffers(adapter);
release_error_buffers(adapter);
if (adapter->napi) {
for (i = 0; i < adapter->req_rx_queues; i++) {
if (&adapter->napi[i]) {
netdev_dbg(adapter->netdev,
"Releasing napi[%d]\n", i);
netif_napi_del(&adapter->napi[i]);
}
}
}
kfree(adapter->napi);
adapter->napi = NULL;
release_napi(adapter);
release_login_rsp_buffer(adapter);
}
......@@ -937,7 +960,7 @@ static int ibmvnic_get_vpd(struct ibmvnic_adapter *adapter)
static int init_resources(struct ibmvnic_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
int i, rc;
int rc;
rc = set_real_num_queues(netdev);
if (rc)
......@@ -963,16 +986,10 @@ static int init_resources(struct ibmvnic_adapter *adapter)
}
adapter->map_id = 1;
adapter->napi = kcalloc(adapter->req_rx_queues,
sizeof(struct napi_struct), GFP_KERNEL);
if (!adapter->napi)
return -ENOMEM;
for (i = 0; i < adapter->req_rx_queues; i++) {
netdev_dbg(netdev, "Adding napi[%d]\n", i);
netif_napi_add(netdev, &adapter->napi[i], ibmvnic_poll,
NAPI_POLL_WEIGHT);
}
rc = init_napi(adapter);
if (rc)
return rc;
send_map_query(adapter);
......@@ -1687,6 +1704,9 @@ static int do_reset(struct ibmvnic_adapter *adapter,
init_rx_pools(netdev);
init_tx_pools(netdev);
release_napi(adapter);
init_napi(adapter);
adapter->num_active_tx_scrqs = adapter->req_tx_queues;
adapter->num_active_rx_scrqs = adapter->req_rx_queues;
} else {
......
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