代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/rdma-core 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 0b33b387d5b806804ae9278d3911289f8619dfd2 Mon Sep 17 00:00:00 2001
From: Chengchang Tang <tangchengchang@huawei.com>
Date: Tue, 26 Sep 2023 19:19:07 +0800
Subject: [PATCH 15/18] libhns: return error when post send in reset state
driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I98HQV
--------------------------------------------------------------------------
If the device has been resetted, the original business will not be able
to continue. The current design is to allow users to continue issuing IO.
Such a design is meaningless, the user should perceive the exception and
restore the business as soon as possible.
The current kernel mode directly returns an error when device has been
resetted, and this patch can unify the behavior of the kernel mode and
user mode.
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
---
providers/hns/hns_roce_u_hw_v2.c | 66 ++++++++++++++++++++++++--------
1 file changed, 51 insertions(+), 15 deletions(-)
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index 2119c4c..fe22b43 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -956,14 +956,24 @@ static int hns_roce_u_v2_arm_cq(struct ibv_cq *ibvcq, int solicited)
return 0;
}
-static inline int check_qp_send(struct ibv_qp *qp)
+static int check_qp_send(struct hns_roce_qp *qp, struct hns_roce_context *ctx)
{
- if (unlikely(qp->state == IBV_QPS_RESET ||
- qp->state == IBV_QPS_INIT ||
- qp->state == IBV_QPS_RTR))
+ struct ibv_qp *ibvqp = &qp->verbs_qp.qp;
+ int ret = 0;
+
+ if (unlikely(ibvqp->state == IBV_QPS_RESET ||
+ ibvqp->state == IBV_QPS_INIT ||
+ ibvqp->state == IBV_QPS_RTR)){
+ verbs_err(verbs_get_ctx(qp->verbs_qp.qp.context),
+ "unsupported qp state, state = %d.\n", ibvqp->state);
return EINVAL;
+ } else if (unlikely(hns_roce_reseted(ctx))) {
+ verbs_err_datapath(&ctx->ibv_ctx,
+ "failed to send, device has been reseted!\n");
+ return EIO;
+ }
- return 0;
+ return ret;
}
static void set_rc_sge(struct hns_roce_v2_wqe_data_seg *dseg,
@@ -1453,7 +1463,7 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
unsigned int wqe_idx, nreq;
int ret;
- ret = check_qp_send(ibvqp);
+ ret = check_qp_send(qp, ctx);
if (unlikely(ret)) {
*bad_wr = wr;
return ret;
@@ -1531,12 +1541,22 @@ out:
return ret;
}
-static inline int check_qp_recv(struct ibv_qp *qp)
+static int check_qp_recv(struct hns_roce_qp *qp, struct hns_roce_context *ctx)
{
- if (qp->state == IBV_QPS_RESET)
+ struct ibv_qp *ibvqp = &qp->verbs_qp.qp;
+ int ret = 0;
+
+ if (ibvqp->state == IBV_QPS_RESET) {
+ verbs_err(verbs_get_ctx(qp->verbs_qp.qp.context),
+ "unsupported qp state, state = %d.\n", ibvqp->state);
return EINVAL;
+ } else if (unlikely(hns_roce_reseted(ctx))) {
+ verbs_err_datapath(&ctx->ibv_ctx,
+ "fail to recv, device has been reseted!\n");
+ return EIO;
+ }
- return 0;
+ return ret;
}
static void fill_recv_sge_to_wqe(struct ibv_recv_wr *wr, void *wqe,
@@ -1603,7 +1623,7 @@ static int hns_roce_u_v2_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,
struct ibv_qp_attr attr = {};
int ret;
- ret = check_qp_recv(ibvqp);
+ ret = check_qp_recv(qp, ctx);
if (unlikely(ret)) {
*bad_wr = wr;
return ret;
@@ -1933,6 +1953,16 @@ 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_reseted(ctx)) {
+ verbs_err_datapath(&ctx->ibv_ctx,
+ "srq failed to recv, device has been reseted!\n");
+ 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)
@@ -1944,6 +1974,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;
@@ -2751,13 +2787,13 @@ 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_context *ctx = to_hr_ctx(ibv_qp->qp_base.context);
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) {
- qp->err = EINVAL;
+ ret = check_qp_send(qp, ctx);
+ if (ret) {
+ qp->err = ret;
return;
}
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。