Skip to content

Commit

Permalink
ibmvnic: Clean RX pool buffers during device close
Browse files Browse the repository at this point in the history
During device close or reset, there were some cases of outstanding
RX socket buffers not being freed. Include a function similar to the
one that already exists to clean TX socket buffers in this case.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Thomas Falcon authored and David S. Miller committed Feb 14, 2018
1 parent 4b9b0f0 commit d0869c0
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion drivers/net/ethernet/ibm/ibmvnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,35 @@ static int ibmvnic_open(struct net_device *netdev)
return rc;
}

static void clean_rx_pools(struct ibmvnic_adapter *adapter)
{
struct ibmvnic_rx_pool *rx_pool;
u64 rx_entries;
int rx_scrqs;
int i, j;

if (!adapter->rx_pool)
return;

rx_scrqs = be32_to_cpu(adapter->login_rsp_buf->num_rxadd_subcrqs);
rx_entries = adapter->req_rx_add_entries_per_subcrq;

/* Free any remaining skbs in the rx buffer pools */
for (i = 0; i < rx_scrqs; i++) {
rx_pool = &adapter->rx_pool[i];
if (!rx_pool)
continue;

netdev_dbg(adapter->netdev, "Cleaning rx_pool[%d]\n", i);
for (j = 0; j < rx_entries; j++) {
if (rx_pool->rx_buff[j].skb) {
dev_kfree_skb_any(rx_pool->rx_buff[j].skb);
rx_pool->rx_buff[j].skb = NULL;
}
}
}
}

static void clean_tx_pools(struct ibmvnic_adapter *adapter)
{
struct ibmvnic_tx_pool *tx_pool;
Expand Down Expand Up @@ -1150,7 +1179,7 @@ static int __ibmvnic_close(struct net_device *netdev)
}
}
}

clean_rx_pools(adapter);
clean_tx_pools(adapter);
adapter->state = VNIC_CLOSED;
return rc;
Expand Down

0 comments on commit d0869c0

Please sign in to comment.