John Lo | 55bf5c9 | 2016-07-04 23:23:32 -0400 | [diff] [blame] | 1 | From db0a30a2e61a3bf2f6cb8e74203dab84280b0419 Mon Sep 17 00:00:00 2001 |
| 2 | From: John Daley <johndale@cisco.com> |
| 3 | Date: Sat, 11 Jun 2016 10:27:05 -0700 |
| 4 | Subject: [PATCH 22/25] net/enic: improve out of resources error handling |
| 5 | |
| 6 | If configuration fails due to lack of resources, be more specific |
| 7 | about which resources are lacking - work queues, read queues or |
| 8 | completion queues. Return -EINVAL instead of -1 if more queeues |
| 9 | are requested than are available. |
| 10 | |
| 11 | Fixes: fefed3d1e62c ("enic: new driver") |
| 12 | |
| 13 | Signed-off-by: John Daley <johndale@cisco.com> |
| 14 | --- |
| 15 | drivers/net/enic/enic_main.c | 30 ++++++++++++++++++++---------- |
| 16 | 1 file changed, 20 insertions(+), 10 deletions(-) |
| 17 | |
| 18 | diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c |
| 19 | index 4e5594f..43e4af1 100644 |
| 20 | --- a/drivers/net/enic/enic_main.c |
| 21 | +++ b/drivers/net/enic/enic_main.c |
| 22 | @@ -970,22 +970,32 @@ static void enic_dev_deinit(struct enic *enic) |
| 23 | int enic_set_vnic_res(struct enic *enic) |
| 24 | { |
| 25 | struct rte_eth_dev *eth_dev = enic->rte_dev; |
| 26 | + int rc = 0; |
| 27 | |
| 28 | - if ((enic->rq_count < eth_dev->data->nb_rx_queues) || |
| 29 | - (enic->wq_count < eth_dev->data->nb_tx_queues)) { |
| 30 | - dev_err(dev, "Not enough resources configured, aborting\n"); |
| 31 | - return -1; |
| 32 | + if (enic->rq_count < eth_dev->data->nb_rx_queues) { |
| 33 | + dev_err(dev, "Not enough Receive queues. Requested:%u, Configured:%u\n", |
| 34 | + eth_dev->data->nb_rx_queues, enic->rq_count); |
| 35 | + rc = -EINVAL; |
| 36 | + } |
| 37 | + if (enic->wq_count < eth_dev->data->nb_tx_queues) { |
| 38 | + dev_err(dev, "Not enough Transmit queues. Requested:%u, Configured:%u\n", |
| 39 | + eth_dev->data->nb_tx_queues, enic->wq_count); |
| 40 | + rc = -EINVAL; |
| 41 | } |
| 42 | |
| 43 | - enic->rq_count = eth_dev->data->nb_rx_queues; |
| 44 | - enic->wq_count = eth_dev->data->nb_tx_queues; |
| 45 | if (enic->cq_count < (enic->rq_count + enic->wq_count)) { |
| 46 | - dev_err(dev, "Not enough resources configured, aborting\n"); |
| 47 | - return -1; |
| 48 | + dev_err(dev, "Not enough Completion queues. Required:%u, Configured:%u\n", |
| 49 | + enic->rq_count + enic->wq_count, enic->cq_count); |
| 50 | + rc = -EINVAL; |
| 51 | } |
| 52 | |
| 53 | - enic->cq_count = enic->rq_count + enic->wq_count; |
| 54 | - return 0; |
| 55 | + if (rc == 0) { |
| 56 | + enic->rq_count = eth_dev->data->nb_rx_queues; |
| 57 | + enic->wq_count = eth_dev->data->nb_tx_queues; |
| 58 | + enic->cq_count = enic->rq_count + enic->wq_count; |
| 59 | + } |
| 60 | + |
| 61 | + return rc; |
| 62 | } |
| 63 | |
| 64 | static int enic_dev_init(struct enic *enic) |
| 65 | -- |
| 66 | 2.7.0 |
| 67 | |