From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-7.cisco.com (alln-iport-7.cisco.com [173.37.142.94]) by dpdk.org (Postfix) with ESMTP id 906022C6B for ; Sat, 11 Jun 2016 19:27:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2215; q=dns/txt; s=iport; t=1465666062; x=1466875662; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=h3lqHaTaiSgaRSZK+ZRflUAgdt+3emHFYzARXLn1WbE=; b=mXhLG4rrGCkw4wGHxGQ2FU2FMZF+QBWDxCSGmW2k7e/gM34p5nAfuIxk v/W6O8R8nA9nP4N0kyW6WZOpYKmB8DF6vUgIb2Pp4pbfUJdxp7HlQEpqb /rZRUlTNxJsY+0ZUF+MW1kzjPGd/FnQ43AAFu9fQjbQHfghzUzR3xtICI s=; X-IronPort-AV: E=Sophos;i="5.26,457,1459814400"; d="scan'208";a="284425761" Received: from alln-core-1.cisco.com ([173.36.13.131]) by alln-iport-7.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Jun 2016 17:27:42 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id u5BHRgi7003932; Sat, 11 Jun 2016 17:27:42 GMT Received: by cisco.com (Postfix, from userid 392789) id 05A4D3FAAE24; Sat, 11 Jun 2016 10:27:42 -0700 (PDT) From: John Daley To: bruce.richardson@intel.com Cc: dev@dpdk.org, John Daley Date: Sat, 11 Jun 2016 10:27:05 -0700 Message-Id: <1465666025-10159-2-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1465666025-10159-1-git-send-email-johndale@cisco.com> References: <20160610092236.GA11860@bricha3-MOBL3> <1465666025-10159-1-git-send-email-johndale@cisco.com> Subject: [dpdk-dev] [PATCH v4 2/2] enic: improve out of resources error handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jun 2016 17:27:43 -0000 If configuration fails due to lack of resources, be more specific about which resources are lacking - work queues, read queues or completion queues. Return -EINVAL instead of -1 if more queeues are requested than are available. Fixes: fefed3d1e62c ("enic: new driver") Signed-off-by: John Daley --- v4: only modify wq/rq/cq counts on success, return -EINVAL on error. drivers/net/enic/enic_main.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 738792e..32ecdae 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -826,22 +826,32 @@ static void enic_dev_deinit(struct enic *enic) int enic_set_vnic_res(struct enic *enic) { struct rte_eth_dev *eth_dev = enic->rte_dev; + int rc = 0; - if ((enic->rq_count < eth_dev->data->nb_rx_queues) || - (enic->wq_count < eth_dev->data->nb_tx_queues)) { - dev_err(dev, "Not enough resources configured, aborting\n"); - return -1; + if (enic->rq_count < eth_dev->data->nb_rx_queues) { + dev_err(dev, "Not enough Receive queues. Requested:%u, Configured:%u\n", + eth_dev->data->nb_rx_queues, enic->rq_count); + rc = -EINVAL; + } + if (enic->wq_count < eth_dev->data->nb_tx_queues) { + dev_err(dev, "Not enough Transmit queues. Requested:%u, Configured:%u\n", + eth_dev->data->nb_tx_queues, enic->wq_count); + rc = -EINVAL; } - enic->rq_count = eth_dev->data->nb_rx_queues; - enic->wq_count = eth_dev->data->nb_tx_queues; if (enic->cq_count < (enic->rq_count + enic->wq_count)) { - dev_err(dev, "Not enough resources configured, aborting\n"); - return -1; + dev_err(dev, "Not enough Completion queues. Required:%u, Configured:%u\n", + enic->rq_count + enic->wq_count, enic->cq_count); + rc = -EINVAL; } - enic->cq_count = enic->rq_count + enic->wq_count; - return 0; + if (rc == 0) { + enic->rq_count = eth_dev->data->nb_rx_queues; + enic->wq_count = eth_dev->data->nb_tx_queues; + enic->cq_count = enic->rq_count + enic->wq_count; + } + + return rc; } static int enic_dev_init(struct enic *enic) -- 2.7.0