Blame SOURCES/0155-netdrv-net-mlx5e-Reset-RQ-doorbell-counter-before-mo.patch

d8f823
From 4e8d6fa65af502f450f0b460aa34934727bed4e9 Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Tue, 12 May 2020 10:54:22 -0400
d8f823
Subject: [PATCH 155/312] [netdrv] net/mlx5e: Reset RQ doorbell counter before
d8f823
 moving RQ state from RST to RDY
d8f823
d8f823
Message-id: <20200512105530.4207-57-ahleihel@redhat.com>
d8f823
Patchwork-id: 306929
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1789382 056/124] net/mlx5e: Reset RQ doorbell counter before moving RQ state from RST to RDY
d8f823
Bugzilla: 1789382
d8f823
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
d8f823
RH-Acked-by: Kamal Heib <kheib@redhat.com>
d8f823
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
d8f823
d8f823
Bugzilla: http://bugzilla.redhat.com/1789382
d8f823
Upstream: v5.6-rc3
d8f823
d8f823
commit 5ee090ed0da649b1febae2b7c285ac77d1e55a0c
d8f823
Author: Aya Levin <ayal@mellanox.com>
d8f823
Date:   Mon Dec 9 14:08:18 2019 +0200
d8f823
d8f823
    net/mlx5e: Reset RQ doorbell counter before moving RQ state from RST to RDY
d8f823
d8f823
    Initialize RQ doorbell counters to zero prior to moving an RQ from RST
d8f823
    to RDY state. Per HW spec, when RQ is back to RDY state, the descriptor
d8f823
    ID on the completion is reset. The doorbell record must comply.
d8f823
d8f823
    Fixes: 8276ea1353a4 ("net/mlx5e: Report and recover from CQE with error on RQ")
d8f823
    Signed-off-by: Aya Levin <ayal@mellanox.com>
d8f823
    Reported-by: Tariq Toukan <tariqt@mellanox.com>
d8f823
    Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
d8f823
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
d8f823
d8f823
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
d8f823
---
d8f823
 drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h |  8 +++++
d8f823
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c |  3 ++
d8f823
 drivers/net/ethernet/mellanox/mlx5/core/wq.c      | 39 +++++++++++++++++------
d8f823
 drivers/net/ethernet/mellanox/mlx5/core/wq.h      |  2 ++
d8f823
 4 files changed, 43 insertions(+), 9 deletions(-)
d8f823
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
d8f823
index 7c8796d9743f..a226277b0980 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
d8f823
@@ -179,6 +179,14 @@ mlx5e_tx_dma_unmap(struct device *pdev, struct mlx5e_sq_dma *dma)
d8f823
 	}
d8f823
 }
d8f823
 
d8f823
+static inline void mlx5e_rqwq_reset(struct mlx5e_rq *rq)
d8f823
+{
d8f823
+	if (rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
d8f823
+		mlx5_wq_ll_reset(&rq->mpwqe.wq);
d8f823
+	else
d8f823
+		mlx5_wq_cyc_reset(&rq->wqe.wq);
d8f823
+}
d8f823
+
d8f823
 /* SW parser related functions */
d8f823
 
d8f823
 struct mlx5e_swp_spec {
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
d8f823
index 7815cae1af54..c9b9c6cb1677 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
d8f823
@@ -713,6 +713,9 @@ int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state, int next_state)
d8f823
 	if (!in)
d8f823
 		return -ENOMEM;
d8f823
 
d8f823
+	if (curr_state == MLX5_RQC_STATE_RST && next_state == MLX5_RQC_STATE_RDY)
d8f823
+		mlx5e_rqwq_reset(rq);
d8f823
+
d8f823
 	rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
d8f823
 
d8f823
 	MLX5_SET(modify_rq_in, in, rq_state, curr_state);
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.c b/drivers/net/ethernet/mellanox/mlx5/core/wq.c
d8f823
index 02f7e4a39578..01f075fac276 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/wq.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.c
d8f823
@@ -94,6 +94,13 @@ void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides)
d8f823
 	print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, wqe, len, false);
d8f823
 }
d8f823
 
d8f823
+void mlx5_wq_cyc_reset(struct mlx5_wq_cyc *wq)
d8f823
+{
d8f823
+	wq->wqe_ctr = 0;
d8f823
+	wq->cur_sz = 0;
d8f823
+	mlx5_wq_cyc_update_db_record(wq);
d8f823
+}
d8f823
+
d8f823
 int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 		      void *qpc, struct mlx5_wq_qp *wq,
d8f823
 		      struct mlx5_wq_ctrl *wq_ctrl)
d8f823
@@ -192,6 +199,19 @@ int mlx5_cqwq_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 	return err;
d8f823
 }
d8f823
 
d8f823
+static void mlx5_wq_ll_init_list(struct mlx5_wq_ll *wq)
d8f823
+{
d8f823
+	struct mlx5_wqe_srq_next_seg *next_seg;
d8f823
+	int i;
d8f823
+
d8f823
+	for (i = 0; i < wq->fbc.sz_m1; i++) {
d8f823
+		next_seg = mlx5_wq_ll_get_wqe(wq, i);
d8f823
+		next_seg->next_wqe_index = cpu_to_be16(i + 1);
d8f823
+	}
d8f823
+	next_seg = mlx5_wq_ll_get_wqe(wq, i);
d8f823
+	wq->tail_next = &next_seg->next_wqe_index;
d8f823
+}
d8f823
+
d8f823
 int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 		      void *wqc, struct mlx5_wq_ll *wq,
d8f823
 		      struct mlx5_wq_ctrl *wq_ctrl)
d8f823
@@ -199,9 +219,7 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 	u8 log_wq_stride = MLX5_GET(wq, wqc, log_wq_stride);
d8f823
 	u8 log_wq_sz     = MLX5_GET(wq, wqc, log_wq_sz);
d8f823
 	struct mlx5_frag_buf_ctrl *fbc = &wq->fbc;
d8f823
-	struct mlx5_wqe_srq_next_seg *next_seg;
d8f823
 	int err;
d8f823
-	int i;
d8f823
 
d8f823
 	err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node);
d8f823
 	if (err) {
d8f823
@@ -220,13 +238,7 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 
d8f823
 	mlx5_init_fbc(wq_ctrl->buf.frags, log_wq_stride, log_wq_sz, fbc);
d8f823
 
d8f823
-	for (i = 0; i < fbc->sz_m1; i++) {
d8f823
-		next_seg = mlx5_wq_ll_get_wqe(wq, i);
d8f823
-		next_seg->next_wqe_index = cpu_to_be16(i + 1);
d8f823
-	}
d8f823
-	next_seg = mlx5_wq_ll_get_wqe(wq, i);
d8f823
-	wq->tail_next = &next_seg->next_wqe_index;
d8f823
-
d8f823
+	mlx5_wq_ll_init_list(wq);
d8f823
 	wq_ctrl->mdev = mdev;
d8f823
 
d8f823
 	return 0;
d8f823
@@ -237,6 +249,15 @@ int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 	return err;
d8f823
 }
d8f823
 
d8f823
+void mlx5_wq_ll_reset(struct mlx5_wq_ll *wq)
d8f823
+{
d8f823
+	wq->head = 0;
d8f823
+	wq->wqe_ctr = 0;
d8f823
+	wq->cur_sz = 0;
d8f823
+	mlx5_wq_ll_init_list(wq);
d8f823
+	mlx5_wq_ll_update_db_record(wq);
d8f823
+}
d8f823
+
d8f823
 void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl)
d8f823
 {
d8f823
 	mlx5_frag_buf_free(wq_ctrl->mdev, &wq_ctrl->buf);
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.h b/drivers/net/ethernet/mellanox/mlx5/core/wq.h
d8f823
index d9a94bc223c0..4cadc336593f 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/wq.h
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.h
d8f823
@@ -80,6 +80,7 @@ int mlx5_wq_cyc_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 		       void *wqc, struct mlx5_wq_cyc *wq,
d8f823
 		       struct mlx5_wq_ctrl *wq_ctrl);
d8f823
 void mlx5_wq_cyc_wqe_dump(struct mlx5_wq_cyc *wq, u16 ix, u8 nstrides);
d8f823
+void mlx5_wq_cyc_reset(struct mlx5_wq_cyc *wq);
d8f823
 
d8f823
 int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 		      void *qpc, struct mlx5_wq_qp *wq,
d8f823
@@ -92,6 +93,7 @@ int mlx5_cqwq_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
d8f823
 		      void *wqc, struct mlx5_wq_ll *wq,
d8f823
 		      struct mlx5_wq_ctrl *wq_ctrl);
d8f823
+void mlx5_wq_ll_reset(struct mlx5_wq_ll *wq);
d8f823
 
d8f823
 void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl);
d8f823
 
d8f823
-- 
d8f823
2.13.6
d8f823