DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/enic: fix checking for sufficient resources
@ 2016-07-06 23:21 Nelson Escobar
  2016-07-08 16:04 ` Bruce Richardson
  0 siblings, 1 reply; 2+ messages in thread
From: Nelson Escobar @ 2016-07-06 23:21 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Nelson Escobar

The enic PMD was using the same variables in the enic structure to
track two different things.  Initially rq_count, wq_count, cq_count,
and intr_count were set to the values obtained from the VIC adapters
as the maximum resources allocated on the VIC, then in
enic_set_vnic_res(), they were set to the counts of resources actually
used, discarding the initial values. The checks in enic_set_vnic_res()
were technically incorrect if it is called more than once on a port,
which happens when using bonding, but were harmless in practice as the
checks couldn't fail on the second call.

The enic rx-scatter patch misunderstood the subtleties of
enic_set_vnic_res(), and naively added a multiply by two to the
rq_count check. This resulted in the rq_count check failing when
enic_set_vnic_res() was called a second time, ie when using bonding.

This patch adds new variables to the enic structure to track the
maximum resources the VIC is configured to provide so that the
information isn't later lost and calls to enic_set_vnic_res() do
the expected thing.

Fixes: 856d7ba7ed22 ("net/enic: support scattered Rx")

Signed-off-by: Nelson Escobar <neescoba@cisco.com>
---
 drivers/net/enic/enic.h        |  6 ++++++
 drivers/net/enic/enic_ethdev.c |  5 +++--
 drivers/net/enic/enic_main.c   | 14 ++++++++------
 drivers/net/enic/enic_res.c    | 12 ++++++------
 4 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 53fed0b..33057d4 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -152,6 +152,12 @@ struct enic {
 	/* software counters */
 	struct enic_soft_stats soft_stats;
 
+	/* configured resources on vic */
+	unsigned int conf_rq_count;
+	unsigned int conf_wq_count;
+	unsigned int conf_cq_count;
+	unsigned int conf_intr_count;
+
 	/* linked list storing memory allocations */
 	LIST_HEAD(enic_memzone_list, enic_memzone_entry) memzone_list;
 	rte_spinlock_t memzone_list_lock;
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index a7ce064..66b81a2 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -436,8 +436,9 @@ static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
 	struct enic *enic = pmd_priv(eth_dev);
 
 	ENICPMD_FUNC_TRACE();
-	device_info->max_rx_queues = enic->rq_count;
-	device_info->max_tx_queues = enic->wq_count;
+	/* Scattered Rx uses two receive queues per rx queue exposed to dpdk */
+	device_info->max_rx_queues = enic->conf_rq_count / 2;
+	device_info->max_tx_queues = enic->conf_wq_count;
 	device_info->min_rx_bufsize = ENIC_MIN_MTU;
 	device_info->max_rx_pktlen = enic->rte_dev->data->mtu
 				   + ETHER_HDR_LEN + 4;
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index 0475cc1..d4e43b5 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1016,21 +1016,23 @@ int enic_set_vnic_res(struct enic *enic)
 	/* With Rx scatter support, two RQs are now used per RQ used by
 	 * the application.
 	 */
-	if (enic->rq_count < (eth_dev->data->nb_rx_queues * 2)) {
+	if (enic->conf_rq_count < eth_dev->data->nb_rx_queues) {
 		dev_err(dev, "Not enough Receive queues. Requested:%u which uses %d RQs on VIC, Configured:%u\n",
 			eth_dev->data->nb_rx_queues,
-			eth_dev->data->nb_rx_queues * 2, enic->rq_count);
+			eth_dev->data->nb_rx_queues * 2, enic->conf_rq_count);
 		rc = -EINVAL;
 	}
-	if (enic->wq_count < eth_dev->data->nb_tx_queues) {
+	if (enic->conf_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);
+			eth_dev->data->nb_tx_queues, enic->conf_wq_count);
 		rc = -EINVAL;
 	}
 
-	if (enic->cq_count < (enic->rq_count + enic->wq_count)) {
+	if (enic->conf_cq_count < (eth_dev->data->nb_rx_queues +
+				   eth_dev->data->nb_tx_queues)) {
 		dev_err(dev, "Not enough Completion queues. Required:%u, Configured:%u\n",
-			enic->rq_count + enic->wq_count, enic->cq_count);
+			(eth_dev->data->nb_rx_queues +
+			 eth_dev->data->nb_tx_queues), enic->conf_cq_count);
 		rc = -EINVAL;
 	}
 
diff --git a/drivers/net/enic/enic_res.c b/drivers/net/enic/enic_res.c
index b271d34..84c5d33 100644
--- a/drivers/net/enic/enic_res.c
+++ b/drivers/net/enic/enic_res.c
@@ -215,14 +215,14 @@ void enic_free_vnic_resources(struct enic *enic)
 
 void enic_get_res_counts(struct enic *enic)
 {
-	enic->wq_count = vnic_dev_get_res_count(enic->vdev, RES_TYPE_WQ);
-	enic->rq_count = vnic_dev_get_res_count(enic->vdev, RES_TYPE_RQ);
-	enic->cq_count = vnic_dev_get_res_count(enic->vdev, RES_TYPE_CQ);
-	enic->intr_count = vnic_dev_get_res_count(enic->vdev,
+	enic->conf_wq_count = vnic_dev_get_res_count(enic->vdev, RES_TYPE_WQ);
+	enic->conf_rq_count = vnic_dev_get_res_count(enic->vdev, RES_TYPE_RQ);
+	enic->conf_cq_count = vnic_dev_get_res_count(enic->vdev, RES_TYPE_CQ);
+	enic->conf_intr_count = vnic_dev_get_res_count(enic->vdev,
 		RES_TYPE_INTR_CTRL);
 
 	dev_info(enic_get_dev(enic),
 		"vNIC resources avail: wq %d rq %d cq %d intr %d\n",
-		enic->wq_count, enic->rq_count,
-		enic->cq_count, enic->intr_count);
+		enic->conf_wq_count, enic->conf_rq_count,
+		enic->conf_cq_count, enic->conf_intr_count);
 }
-- 
2.7.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/enic: fix checking for sufficient resources
  2016-07-06 23:21 [dpdk-dev] [PATCH] net/enic: fix checking for sufficient resources Nelson Escobar
@ 2016-07-08 16:04 ` Bruce Richardson
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Richardson @ 2016-07-08 16:04 UTC (permalink / raw)
  To: Nelson Escobar; +Cc: dev

On Wed, Jul 06, 2016 at 04:21:59PM -0700, Nelson Escobar wrote:
> The enic PMD was using the same variables in the enic structure to
> track two different things.  Initially rq_count, wq_count, cq_count,
> and intr_count were set to the values obtained from the VIC adapters
> as the maximum resources allocated on the VIC, then in
> enic_set_vnic_res(), they were set to the counts of resources actually
> used, discarding the initial values. The checks in enic_set_vnic_res()
> were technically incorrect if it is called more than once on a port,
> which happens when using bonding, but were harmless in practice as the
> checks couldn't fail on the second call.
> 
> The enic rx-scatter patch misunderstood the subtleties of
> enic_set_vnic_res(), and naively added a multiply by two to the
> rq_count check. This resulted in the rq_count check failing when
> enic_set_vnic_res() was called a second time, ie when using bonding.
> 
> This patch adds new variables to the enic structure to track the
> maximum resources the VIC is configured to provide so that the
> information isn't later lost and calls to enic_set_vnic_res() do
> the expected thing.
> 
> Fixes: 856d7ba7ed22 ("net/enic: support scattered Rx")
> 
> Signed-off-by: Nelson Escobar <neescoba@cisco.com>

Applied to dpdk-next-net/rel_16_07

/Bruce

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-08 16:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-06 23:21 [dpdk-dev] [PATCH] net/enic: fix checking for sufficient resources Nelson Escobar
2016-07-08 16:04 ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).