DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com,
	Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
	stable@dpdk.org, Lance Richardson <lance.richardson@broadcom.com>
Subject: [dpdk-dev] [PATCH v2 03/17] net/bnxt: fix rxq stop/start handling
Date: Tue,  1 Oct 2019 22:54:09 -0700	[thread overview]
Message-ID: <20191002055423.99659-4-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20191002055423.99659-1-ajit.khaparde@broadcom.com>

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

Driver should not change "deferred_start" state of the rx queues.
It should get the state in queue_setup_op() and use that value.

Since the deferred start state was being used in the packet receive
functions to determine whether a stopped rx ring should be polled,
introduced a per-rxq flag to track queue stopped/started state.

Fixes: 9b63c6fd70e3 ("net/bnxt: support Rx/Tx queue start/stop")
Cc: stable@dpdk.org
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c       |  2 +-
 drivers/net/bnxt/bnxt_ring.c         |  3 +--
 drivers/net/bnxt/bnxt_rxq.c          | 36 +++++++++++++++++++---------
 drivers/net/bnxt/bnxt_rxq.h          |  1 +
 drivers/net/bnxt/bnxt_rxr.c          |  7 +++---
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c |  2 +-
 6 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 4095e9c720..d1c5acb3e2 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1945,7 +1945,7 @@ bnxt_rxq_info_get_op(struct rte_eth_dev *dev, uint16_t queue_id,
 
 	qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
 	qinfo->conf.rx_drop_en = 0;
-	qinfo->conf.rx_deferred_start = 0;
+	qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
 }
 
 static void
diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 73eee43148..68a690de5a 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -561,8 +561,7 @@ int bnxt_alloc_hwrm_rx_ring(struct bnxt *bp, int queue_index)
 	if (rc)
 		goto err_out;
 
-	if (bp->eth_dev->data->rx_queue_state[queue_index] ==
-	    RTE_ETH_QUEUE_STATE_STARTED) {
+	if (!rxq->rx_started) {
 		if (bnxt_init_one_rx_ring(rxq)) {
 			RTE_LOG(ERR, PMD,
 				"bnxt_init_one_rx_ring failed!\n");
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index 192ffd8780..4b506f8653 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -357,9 +357,19 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	}
 	rte_atomic64_init(&rxq->rx_mbuf_alloc_fail);
 
-	rxq->rx_deferred_start = rx_conf->rx_deferred_start;
-	queue_state = rxq->rx_deferred_start ? RTE_ETH_QUEUE_STATE_STOPPED :
-						RTE_ETH_QUEUE_STATE_STARTED;
+	/* rxq 0 must not be stopped when used as async CPR */
+	if (!BNXT_NUM_ASYNC_CPR(bp) && queue_idx == 0)
+		rxq->rx_deferred_start = false;
+	else
+		rxq->rx_deferred_start = rx_conf->rx_deferred_start;
+
+	if (rxq->rx_deferred_start) {
+		queue_state = RTE_ETH_QUEUE_STATE_STOPPED;
+		rxq->rx_started = false;
+	} else {
+		queue_state = RTE_ETH_QUEUE_STATE_STARTED;
+		rxq->rx_started = true;
+	}
 	eth_dev->data->rx_queue_state[queue_idx] = queue_state;
 	rte_spinlock_init(&rxq->lock);
 
@@ -432,6 +442,11 @@ int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return -EINVAL;
 	}
 
+	/* Set the queue state to started here.
+	 * We check the status of the queue while posting buffer.
+	 * If queue is it started, we do not post buffers for Rx.
+	 */
+	rxq->rx_started = true;
 	bnxt_free_hwrm_rx_ring(bp, rx_queue_id);
 	rc = bnxt_alloc_hwrm_rx_ring(bp, rx_queue_id);
 	if (rc)
@@ -448,20 +463,19 @@ int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 
 			vnic->fw_grp_ids[rx_queue_id] =
 					bp->grp_info[rx_queue_id].fw_grp_id;
+			PMD_DRV_LOG(DEBUG,
+				    "vnic = %p fw_grp_id = %d\n",
+				    vnic, bp->grp_info[rx_queue_id].fw_grp_id);
 		}
 
-		PMD_DRV_LOG(DEBUG,
-			    "vnic = %p fw_grp_id = %d\n",
-			    vnic, bp->grp_info[rx_queue_id].fw_grp_id);
-
 		rc = bnxt_vnic_rss_configure(bp, vnic);
 	}
 
-	if (rc == 0) {
+	if (rc == 0)
 		dev->data->rx_queue_state[rx_queue_id] =
 				RTE_ETH_QUEUE_STATE_STARTED;
-		rxq->rx_deferred_start = false;
-	}
+	else
+		rxq->rx_started = false;
 
 	PMD_DRV_LOG(INFO,
 		    "queue %d, rx_deferred_start %d, state %d!\n",
@@ -500,7 +514,7 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	}
 
 	dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
-	rxq->rx_deferred_start = true;
+	rxq->rx_started = false;
 	PMD_DRV_LOG(DEBUG, "Rx queue stopped\n");
 
 	if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
diff --git a/drivers/net/bnxt/bnxt_rxq.h b/drivers/net/bnxt/bnxt_rxq.h
index c60b04426c..3693d89a60 100644
--- a/drivers/net/bnxt/bnxt_rxq.h
+++ b/drivers/net/bnxt/bnxt_rxq.h
@@ -30,6 +30,7 @@ struct bnxt_rx_queue {
 	uint16_t		port_id; /* Device port identifier */
 	uint8_t			crc_len; /* 0 if CRC stripped, 4 otherwise */
 	uint8_t			rx_deferred_start; /* not in global dev start */
+	uint8_t			rx_started; /* RX queue is started */
 
 	struct bnxt		*bp;
 	int			index;
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index f60880c63e..b3cc0d8a04 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -574,10 +574,9 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	if (unlikely(is_bnxt_in_error(rxq->bp)))
 		return 0;
 
-	/* If Rx Q was stopped return. RxQ0 cannot be stopped. */
-	if (unlikely(((rxq->rx_deferred_start ||
-		       !rte_spinlock_trylock(&rxq->lock)) &&
-		      rxq->queue_id)))
+	/* If Rx Q was stopped return */
+	if (unlikely(!rxq->rx_started ||
+		     !rte_spinlock_trylock(&rxq->lock)))
 		return 0;
 
 	/* Handle RX burst request */
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
index 2e6e83c949..5ae812f3b9 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
@@ -224,7 +224,7 @@ bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			     0xFF, 0xFF, 0xFF, 0xFF); /* pkt_type (zeroes) */
 
 	/* If Rx Q was stopped return */
-	if (rxq->rx_deferred_start)
+	if (unlikely(!rxq->rx_started))
 		return 0;
 
 	if (rxq->rxrearm_nb >= RTE_BNXT_RXQ_REARM_THRESH)
-- 
2.20.1 (Apple Git-117)


  parent reply	other threads:[~2019-10-02  5:55 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-02  5:54 [dpdk-dev] [PATCH v2 00/17] bnxt patchset Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 01/17] net/bnxt: fix incorrect flow steering Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 02/17] net/bnxt: fix traffic failure with higher mbuf size Ajit Khaparde
2019-10-02  5:54 ` Ajit Khaparde [this message]
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 04/17] net/bnxt: subscribe to link speed change notification Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 05/17] net/bnxt: fix async link handling and update Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 06/17] net/bnxt: fix 40G link failure for Thor Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 07/17] net/bnxt: fix L2 context calculation " Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 08/17] net/bnxt: fix use of deferred start of transmit queues Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 09/17] net/bnxt: remove unnecessary return check Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 10/17] net/bnxt: remove unused macro Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 11/17] net/bnxt: remove unnecessary interrupt disable Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 12/17] net/bnxt: fix accessing variable before null check Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 13/17] net/bnxt: fix Rx queue count devop Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 14/17] net/bnxt: fix mbuf flags for PTP packets in vector mode Rx Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 15/17] net/bnxt: fix a segfault in secondary process Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 16/17] net/bnxt: support for QinQ insertion and stripping Ajit Khaparde
2019-10-02  5:54 ` [dpdk-dev] [PATCH v2 17/17] net/bnxt: use macro for getting default vnic Ajit Khaparde
2019-10-02 17:17 ` [dpdk-dev] [PATCH v3 00/16] bnxt patchset Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 01/16] net/bnxt: fix incorrect flow steering Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 02/16] net/bnxt: fix traffic failure with higher mbuf size Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 03/16] net/bnxt: fix rxq stop/start handling Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 04/16] net/bnxt: subscribe to link speed change notification Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 05/16] net/bnxt: fix async link handling and update Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 06/16] net/bnxt: fix 40G link failure for Thor Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 07/16] net/bnxt: fix L2 context calculation " Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 08/16] net/bnxt: fix use of deferred start of transmit queues Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 09/16] net/bnxt: remove unnecessary return check Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 10/16] net/bnxt: remove unused macro Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 11/16] net/bnxt: remove unnecessary interrupt disable Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 12/16] net/bnxt: fix accessing variable before null check Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 13/16] net/bnxt: fix Rx queue count devop Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 14/16] net/bnxt: fix a segfault in secondary process Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 15/16] net/bnxt: support for QinQ insertion and stripping Ajit Khaparde
2019-10-02 17:17   ` [dpdk-dev] [PATCH v3 16/16] net/bnxt: use macro for getting default vnic Ajit Khaparde
2019-10-02 18:35   ` [dpdk-dev] [PATCH v3 00/16] bnxt patchset Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191002055423.99659-4-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=lance.richardson@broadcom.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).