From patchwork Wed Jan 3 02:44:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 10141601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 09D7560594 for ; Wed, 3 Jan 2018 02:14:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB67528D5B for ; Wed, 3 Jan 2018 02:14:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E04B328F98; Wed, 3 Jan 2018 02:14:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9272C28F9B for ; Wed, 3 Jan 2018 02:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750865AbeACCOp (ORCPT ); Tue, 2 Jan 2018 21:14:45 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3225 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750997AbeACCOn (ORCPT ); Tue, 2 Jan 2018 21:14:43 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id BD49AB493F56; Wed, 3 Jan 2018 10:14:29 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.361.1; Wed, 3 Jan 2018 10:14:29 +0800 From: Lijun Ou To: , CC: , Subject: [PATCH V5 for-next 4/6] RDMA/hns: Filter for zero length of sge in hip08 kernel mode Date: Wed, 3 Jan 2018 10:44:06 +0800 Message-ID: <1514947448-40475-5-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1514947448-40475-1-git-send-email-oulijun@huawei.com> References: <1514947448-40475-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the length of sge is zero, the driver need to filter it Signed-off-by: Lijun Ou --- V1: - The initial submit --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 8026b11..3d2a175 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -230,26 +230,37 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, V2_RC_SEND_WQE_BYTE_4_INLINE_S, 1); } else { if (wr->num_sge <= 2) { - for (i = 0; i < wr->num_sge; i++) - set_data_seg_v2(dseg + i, - wr->sg_list + i); + for (i = 0; i < wr->num_sge; i++) { + if (likely(wr->sg_list[i].length)) { + set_data_seg_v2(dseg, + wr->sg_list + i); + dseg++; + } + } } else { roce_set_field(rc_sq_wqe->byte_20, V2_RC_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_M, V2_RC_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_S, sge_ind & (qp->sge.sge_cnt - 1)); - for (i = 0; i < 2; i++) - set_data_seg_v2(dseg + i, - wr->sg_list + i); + for (i = 0; i < 2; i++) { + if (likely(wr->sg_list[i].length)) { + set_data_seg_v2(dseg, + wr->sg_list + i); + dseg++; + } + } dseg = get_send_extend_sge(qp, sge_ind & (qp->sge.sge_cnt - 1)); for (i = 0; i < wr->num_sge - 2; i++) { - set_data_seg_v2(dseg + i, - wr->sg_list + 2 + i); - sge_ind++; + if (likely(wr->sg_list[i + 2].length)) { + set_data_seg_v2(dseg, + wr->sg_list + 2 + i); + dseg++; + sge_ind++; + } } }