From: Chengchang Tang tangchengchang@huawei.com
If the device has been reset, fail the post send/recv/srq_recv and return an error to notify user.
Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com --- providers/hns/hns_roce_u_hw_v2.c | 40 ++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index 88bf55fd1..4a24967cb 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -728,6 +728,13 @@ static int hns_roce_poll_one(struct hns_roce_context *ctx, return hns_roce_flush_cqe(*cur_qp, status); }
+static bool hns_roce_is_reset(struct hns_roce_context *ctx) +{ + struct hns_roce_reset_state *state = ctx->reset_state; + + return state && !state->hw_ready; +} + static int hns_roce_u_v2_poll_cq(struct ibv_cq *ibvcq, int ne, struct ibv_wc *wc) { @@ -782,11 +789,16 @@ static int hns_roce_u_v2_arm_cq(struct ibv_cq *ibvcq, int solicited)
static inline int check_qp_send(struct ibv_qp *qp) { + struct hns_roce_context *ctx = to_hr_ctx(qp->context); + if (unlikely(qp->state == IBV_QPS_RESET || qp->state == IBV_QPS_INIT || qp->state == IBV_QPS_RTR)) return EINVAL;
+ if (hns_roce_is_reset(ctx)) + return EIO; + return 0; }
@@ -1357,9 +1369,14 @@ out:
static inline int check_qp_recv(struct ibv_qp *qp) { + struct hns_roce_context *ctx = to_hr_ctx(qp->context); + if (qp->state == IBV_QPS_RESET) return EINVAL;
+ if (hns_roce_is_reset(ctx)) + return EIO; + return 0; }
@@ -1757,6 +1774,14 @@ static void update_srq_db(struct hns_roce_context *ctx, struct hns_roce_db *db, (__le32 *)db); }
+static int check_srq_recv(struct hns_roce_context *ctx) +{ + if (hns_roce_is_reset(ctx)) + return EIO; + + return 0; +} + static int hns_roce_u_v2_post_srq_recv(struct ibv_srq *ib_srq, struct ibv_recv_wr *wr, struct ibv_recv_wr **bad_wr) @@ -1768,6 +1793,12 @@ static int hns_roce_u_v2_post_srq_recv(struct ibv_srq *ib_srq, int ret = 0; void *wqe;
+ ret = check_srq_recv(ctx); + if (ret) { + *bad_wr = wr; + return ret; + } + hns_roce_spin_lock(&srq->hr_lock);
max_sge = srq->max_gs - srq->rsv_sge; @@ -2553,13 +2584,12 @@ static void wr_set_inline_data_list_ud(struct ibv_qp_ex *ibv_qp, size_t num_buf, static void wr_start(struct ibv_qp_ex *ibv_qp) { struct hns_roce_qp *qp = to_hr_qp(&ibv_qp->qp_base); - enum ibv_qp_state state = ibv_qp->qp_base.state; + int ret;
- if (state == IBV_QPS_RESET || - state == IBV_QPS_INIT || - state == IBV_QPS_RTR) { + ret = check_qp_send(&ibv_qp->qp_base); + if (ret) { hns_roce_spin_lock(&qp->sq.hr_lock); - qp->err = EINVAL; + qp->err = ret; return; }