DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Shahaf Shuler <shahafs@mellanox.com>, Yongseok Koh <yskoh@mellanox.com>
Cc: dev@dpdk.org, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v1 9/9] net/mlx5: recover secondary process Tx errors
Date: Thu, 30 May 2019 10:20:39 +0000	[thread overview]
Message-ID: <1559211639-17442-10-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1559211639-17442-1-git-send-email-matan@mellanox.com>

The SQ errors recovery mechanism in the PMD invokes a Verbs
functions to modify the RQ states in order to reset the SQ and to
reactivate it.

These Verbs functions are not allowed to be invoked from a secondary
process, hence the PMD skips the recovery when the error is captured
by secondary processes queues.

Using the DPDK IPC mechanism the secondary process can request Verbs
queues state modifications to be done synchronically by the primary
process.

Add support for secondary process Tx errors recovery.

Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxtx.c | 104 ++++++++++++++++++++++++++-----------------
 1 file changed, 62 insertions(+), 42 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index cb3baad..9659478 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -51,6 +51,10 @@
 static __rte_always_inline void
 mprq_buf_replace(struct mlx5_rxq_data *rxq, uint16_t rq_idx);
 
+static int
+mlx5_queue_state_modify(struct rte_eth_dev *dev,
+			struct mlx5_mp_arg_queue_state_modify *sm);
+
 uint32_t mlx5_ptype_table[] __rte_cache_aligned = {
 	[0xff] = RTE_PTYPE_ALL_MASK, /* Last entry for errored packet. */
 };
@@ -570,52 +574,27 @@
 }
 
 /**
- * Move QP from error state to running state.
+ * Move QP from error state to running state and initialize indexes.
  *
- * @param txq
- *   Pointer to TX queue structure.
- * @param qp
- *   The qp pointer for recovery.
+ * @param txq_ctrl
+ *   Pointer to TX queue control structure.
  *
  * @return
- *   0 on success, else errno value.
+ *   0 on success, else -1.
  */
 static int
-tx_recover_qp(struct mlx5_txq_data *txq, struct ibv_qp *qp)
+tx_recover_qp(struct mlx5_txq_ctrl *txq_ctrl)
 {
-	int ret;
-	struct ibv_qp_attr mod = {
-					.qp_state = IBV_QPS_RESET,
-					.port_num = 1,
-				};
-	ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
-	if (ret) {
-		DRV_LOG(ERR, "Cannot change the Tx QP state to RESET %d\n",
-			ret);
-		return ret;
-	}
-	mod.qp_state = IBV_QPS_INIT;
-	ret = mlx5_glue->modify_qp(qp, &mod,
-				   (IBV_QP_STATE | IBV_QP_PORT));
-	if (ret) {
-		DRV_LOG(ERR, "Cannot change Tx QP state to INIT %d\n", ret);
-		return ret;
-	}
-	mod.qp_state = IBV_QPS_RTR;
-	ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
-	if (ret) {
-		DRV_LOG(ERR, "Cannot change Tx QP state to RTR %d\n", ret);
-		return ret;
-	}
-	mod.qp_state = IBV_QPS_RTS;
-	ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
-	if (ret) {
-		DRV_LOG(ERR, "Cannot change Tx QP state to RTS %d\n", ret);
-		return ret;
-	}
-	txq->wqe_ci = 0;
-	txq->wqe_pi = 0;
-	txq->elts_comp = 0;
+	struct mlx5_mp_arg_queue_state_modify sm = {
+			.is_wq = 0,
+			.queue_id = txq_ctrl->txq.idx,
+	};
+
+	if (mlx5_queue_state_modify(ETH_DEV(txq_ctrl->priv), &sm))
+		return -1;
+	txq_ctrl->txq.wqe_ci = 0;
+	txq_ctrl->txq.wqe_pi = 0;
+	txq_ctrl->txq.elts_comp = 0;
 	return 0;
 }
 
@@ -690,8 +669,7 @@
 			 */
 			txq->stats.oerrors += ((txq->wqe_ci & wqe_m) -
 						new_wqe_pi) & wqe_m;
-		if ((rte_eal_process_type() == RTE_PROC_PRIMARY) &&
-		    tx_recover_qp(txq, txq_ctrl->ibv->qp) == 0) {
+		if (tx_recover_qp(txq_ctrl) == 0) {
 			txq->cq_ci++;
 			/* Release all the remaining buffers. */
 			return txq->elts_head;
@@ -2065,6 +2043,48 @@
 			rte_errno = errno;
 			return ret;
 		}
+	} else {
+		struct mlx5_txq_data *txq = (*priv->txqs)[sm->queue_id];
+		struct mlx5_txq_ctrl *txq_ctrl =
+			container_of(txq, struct mlx5_txq_ctrl, txq);
+		struct ibv_qp_attr mod = {
+			.qp_state = IBV_QPS_RESET,
+			.port_num = (uint8_t)priv->ibv_port,
+		};
+		struct ibv_qp *qp = txq_ctrl->ibv->qp;
+
+		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
+		if (ret) {
+			DRV_LOG(ERR, "Cannot change the Tx QP state to RESET "
+				"%s\n", strerror(errno));
+			rte_errno = errno;
+			return ret;
+		}
+		mod.qp_state = IBV_QPS_INIT;
+		ret = mlx5_glue->modify_qp(qp, &mod,
+					   (IBV_QP_STATE | IBV_QP_PORT));
+		if (ret) {
+			DRV_LOG(ERR, "Cannot change Tx QP state to INIT %s\n",
+				strerror(errno));
+			rte_errno = errno;
+			return ret;
+		}
+		mod.qp_state = IBV_QPS_RTR;
+		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
+		if (ret) {
+			DRV_LOG(ERR, "Cannot change Tx QP state to RTR %s\n",
+				strerror(errno));
+			rte_errno = errno;
+			return ret;
+		}
+		mod.qp_state = IBV_QPS_RTS;
+		ret = mlx5_glue->modify_qp(qp, &mod, IBV_QP_STATE);
+		if (ret) {
+			DRV_LOG(ERR, "Cannot change Tx QP state to RTS %s\n",
+				strerror(errno));
+			rte_errno = errno;
+			return ret;
+		}
 	}
 	return 0;
 }
-- 
1.8.3.1


  parent reply	other threads:[~2019-05-30 10:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30 10:20 [dpdk-dev] [PATCH v1 0/9] mlx5: Handle data-path completions with error Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 1/9] net/mlx5: remove Rx queues indexes correlation Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 2/9] net/mlx5: add log file procedure for debug data Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 3/9] net/mlx5: fix device arguments error detection Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 4/9] net/mlx5: mitigate Rx doorbell memory barrier Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 5/9] net/mlx5: separate Rx queue initialization Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 6/9] net/mlx5: extend Rx completion with error handling Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 7/9] net/mlx5: handle Tx completion with error Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 8/9] net/mlx5: recover secondary process Rx errors Matan Azrad
2019-05-30 10:20 ` Matan Azrad [this message]
2019-09-12 12:14 ` [dpdk-dev] [PATCH v1 0/9] mlx5: Handle data-path completions with error Kevin Traynor
2019-09-22  7:03   ` Matan Azrad

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=1559211639-17442-10-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    --cc=stable@dpdk.org \
    --cc=yskoh@mellanox.com \
    /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).