From patchwork Thu Apr 27 06:11:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Amrani, Ram" X-Patchwork-Id: 9702405 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 71740603F9 for ; Thu, 27 Apr 2017 06:12:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61B342860C for ; Thu, 27 Apr 2017 06:12:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 568BA2861F; Thu, 27 Apr 2017 06:12:03 +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 ED7B62860F for ; Thu, 27 Apr 2017 06:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938528AbdD0GL6 (ORCPT ); Thu, 27 Apr 2017 02:11:58 -0400 Received: from mx0b-0016ce01.pphosted.com ([67.231.156.153]:36303 "EHLO mx0b-0016ce01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932866AbdD0GL4 (ORCPT ); Thu, 27 Apr 2017 02:11:56 -0400 Received: from pps.filterd (m0085408.ppops.net [127.0.0.1]) by mx0b-0016ce01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v3R67xXo015219; Wed, 26 Apr 2017 23:11:43 -0700 Received: from avcashub1.qlogic.com ([198.186.0.116]) by mx0b-0016ce01.pphosted.com with ESMTP id 2a3ahu023d-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 26 Apr 2017 23:11:43 -0700 Received: from lb-tlvb-ramrani.il.qlogic.org (10.185.6.119) by qlc.com (10.1.4.191) with Microsoft SMTP Server id 14.3.235.1; Wed, 26 Apr 2017 23:11:42 -0700 From: Ram Amrani To: , , CC: , , , Ram Amrani Subject: [rdma-core 4/4] libqedr: prevent EDPM loopback Date: Thu, 27 Apr 2017 09:11:08 +0300 Message-ID: <1493273468-23774-5-git-send-email-Ram.Amrani@cavium.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1493273468-23774-1-git-send-email-Ram.Amrani@cavium.com> References: <1493273468-23774-1-git-send-email-Ram.Amrani@cavium.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5800 definitions=8510 signatures=668453 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270101 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 HW doesn't support EDPM loopback. Hence disable EDPM if this is a loopback QP. Signed-off-by: Ram Amrani --- providers/qedr/qelr.h | 1 + providers/qedr/qelr_verbs.c | 44 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/providers/qedr/qelr.h b/providers/qedr/qelr.h index b5310b5..0dd6835 100644 --- a/providers/qedr/qelr.h +++ b/providers/qedr/qelr.h @@ -243,6 +243,7 @@ struct qelr_qp { uint32_t qp_id; int sq_sig_all; int atomic_supported; + uint8_t edpm_disabled; }; static inline struct qelr_devctx *get_qelr_ctx(struct ibv_context *ibctx) diff --git a/providers/qedr/qelr_verbs.c b/providers/qedr/qelr_verbs.c index 375664b..676b18c 100644 --- a/providers/qedr/qelr_verbs.c +++ b/providers/qedr/qelr_verbs.c @@ -768,6 +768,7 @@ int qelr_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, struct ibv_modify_qp cmd = {}; struct qelr_qp *qp = get_qelr_qp(ibqp); struct qelr_devctx *cxt = get_qelr_ctx(ibqp->context); + union ibv_gid sgid, *p_dgid; int rc; DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, "QP Modify %p, attr_mask=0x%x\n", @@ -776,14 +777,45 @@ int qelr_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr, qelr_print_qp_attr(cxt, attr); rc = ibv_cmd_modify_qp(ibqp, attr, attr_mask, &cmd, sizeof(cmd)); + if (rc) { + DP_ERR(cxt->dbg_fp, "QP Modify: Failed command. rc=%d\n", rc); + return rc; + } - if (!rc && (attr_mask & IBV_QP_STATE)) { - DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, "QP Modify state %d->%d\n", - qp->state, attr->qp_state); - qelr_update_qp_state(qp, attr->qp_state); + if (attr_mask & IBV_QP_STATE) { + rc = qelr_update_qp_state(qp, attr->qp_state); + DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, + "QP Modify state %d->%d, rc=%d\n", qp->state, + attr->qp_state, rc); + if (rc) { + DP_ERR(cxt->dbg_fp, + "QP Modify: Failed to update state. rc=%d\n", + rc); + + return rc; + } } - return rc; + /* EDPM must be disabled if GIDs match */ + if (attr_mask & IBV_QP_AV) { + rc = ibv_query_gid(ibqp->context, attr->ah_attr.port_num, + attr->ah_attr.grh.sgid_index, &sgid); + + if (!rc) { + p_dgid = &attr->ah_attr.grh.dgid; + qp->edpm_disabled = !memcmp(&sgid, p_dgid, + sizeof(sgid)); + DP_VERBOSE(cxt->dbg_fp, QELR_MSG_QP, + "QP Modify: %p, edpm_disabled=%d\n", qp, + qp->edpm_disabled); + } else { + DP_ERR(cxt->dbg_fp, + "QP Modify: Failed querying GID. rc=%d\n", + rc); + } + } + + return 0; } int qelr_destroy_qp(struct ibv_qp *ibqp) @@ -839,7 +871,7 @@ static inline void qelr_init_edpm_info(struct qelr_devctx *cxt, edpm->is_edpm = 0; if (qelr_chain_is_full(&qp->sq.chain) && - wr->send_flags & IBV_SEND_INLINE) { + wr->send_flags & IBV_SEND_INLINE && !qp->edpm_disabled) { memset(edpm, 0, sizeof(*edpm)); edpm->rdma_ext = (struct qelr_rdma_ext *)&edpm->dpm_payload; edpm->is_edpm = 1;