From patchwork Mon Nov 29 22:54:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sindhu Devale X-Patchwork-Id: 12646037 X-Patchwork-Delegate: leon@leon.nu Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ECC1C433FE for ; Mon, 29 Nov 2021 22:56:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235325AbhK2W74 (ORCPT ); Mon, 29 Nov 2021 17:59:56 -0500 Received: from mga11.intel.com ([192.55.52.93]:35265 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236009AbhK2W7O (ORCPT ); Mon, 29 Nov 2021 17:59:14 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10183"; a="233593336" X-IronPort-AV: E=Sophos;i="5.87,273,1631602800"; d="scan'208";a="233593336" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2021 14:55:15 -0800 X-IronPort-AV: E=Sophos;i="5.87,273,1631602800"; d="scan'208";a="511902785" Received: from sindhude-mobl.amr.corp.intel.com ([10.255.35.224]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2021 14:55:14 -0800 From: Sindhu Devale To: jgg@nvidia.com, leon@kernel.org, tatyana.e.nikolova@intel.com Cc: linux-rdma@vger.kernel.org, shiraz.saleem@intel.com, mustafa.ismail@intel.com, "Sindhu, Devale" Subject: [PATCH rdma-core 1/2] providers/irdma: Report correct WC errors Date: Mon, 29 Nov 2021 16:54:45 -0600 Message-Id: <20211129225446.691-2-sindhu.devale@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211129225446.691-1-sindhu.devale@intel.com> References: <20211129225446.691-1-sindhu.devale@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: "Sindhu, Devale" Return specific WC errors for certain type of error events as opposed to a generic IBV_WC_FATAL_ERR. In particular, Return IBV_WC_MW_BIND_ERR for memory window related asynchronous events. Return IBV_WC_REM_INV_REQ_ERR for errors which is detected when the remote side detects an operation outside of the established use for the transport. Return IBV_WC_RETRY_EXC_ERR when transport retry counter is exceeded. Fixes: 14a0fc824f16 ("rdma-core/irdma: Implement device supported verb APIs") Signed-off-by: Sindhu, Devale --- providers/irdma/uverbs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/providers/irdma/uverbs.c b/providers/irdma/uverbs.c index edd8821f..c8222d14 100644 --- a/providers/irdma/uverbs.c +++ b/providers/irdma/uverbs.c @@ -556,6 +556,12 @@ static enum ibv_wc_status irdma_flush_err_to_ib_wc_status(enum irdma_flush_opcod return IBV_WC_LOC_LEN_ERR; case FLUSH_GENERAL_ERR: return IBV_WC_WR_FLUSH_ERR; + case FLUSH_MW_BIND_ERR: + return IBV_WC_MW_BIND_ERR; + case FLUSH_REM_INV_REQ_ERR: + return IBV_WC_REM_INV_REQ_ERR; + case FLUSH_RETRY_EXC_ERR: + return IBV_WC_RETRY_EXC_ERR; case FLUSH_FATAL_ERR: default: return IBV_WC_FATAL_ERR; From patchwork Mon Nov 29 22:54:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sindhu Devale X-Patchwork-Id: 12646039 X-Patchwork-Delegate: leon@leon.nu Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B903EC433F5 for ; Mon, 29 Nov 2021 22:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236103AbhK2XBU (ORCPT ); Mon, 29 Nov 2021 18:01:20 -0500 Received: from mga11.intel.com ([192.55.52.93]:35313 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236077AbhK2W7s (ORCPT ); Mon, 29 Nov 2021 17:59:48 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10183"; a="233593347" X-IronPort-AV: E=Sophos;i="5.87,273,1631602800"; d="scan'208";a="233593347" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2021 14:55:19 -0800 X-IronPort-AV: E=Sophos;i="5.87,273,1631602800"; d="scan'208";a="511902799" Received: from sindhude-mobl.amr.corp.intel.com ([10.255.35.224]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2021 14:55:18 -0800 From: Sindhu Devale To: jgg@nvidia.com, leon@kernel.org, tatyana.e.nikolova@intel.com Cc: linux-rdma@vger.kernel.org, shiraz.saleem@intel.com, mustafa.ismail@intel.com, "Sindhu, Devale" Subject: [PATCH rdma-core 2/2] providers/irdma: Validate input before memory window bind Date: Mon, 29 Nov 2021 16:54:46 -0600 Message-Id: <20211129225446.691-3-sindhu.devale@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211129225446.691-1-sindhu.devale@intel.com> References: <20211129225446.691-1-sindhu.devale@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: "Sindhu, Devale" Check for a non null MR, address and length before allowing bind operation. Also, add check to make sure the MR and MW are in same PD before posting a bind MW op. Fixes: 14a0fc824f16 ("rdma-core/irdma: Implement device supported verb APIs") Signed-off-by: Sindhu, Devale --- providers/irdma/uverbs.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/providers/irdma/uverbs.c b/providers/irdma/uverbs.c index c8222d14..dc7cf41a 100644 --- a/providers/irdma/uverbs.c +++ b/providers/irdma/uverbs.c @@ -206,19 +206,30 @@ int irdma_ubind_mw(struct ibv_qp *qp, struct ibv_mw *mw, struct ibv_mw_bind *mw_bind) { struct ibv_mw_bind_info *bind_info = &mw_bind->bind_info; - struct verbs_mr *vmr = verbs_get_mr(bind_info->mr); - struct irdma_umr *umr = container_of(vmr, struct irdma_umr, vmr); + struct verbs_mr *vmr; + struct irdma_umr *umr; struct ibv_send_wr wr = {}; struct ibv_send_wr *bad_wr; int err; - if (vmr->mr_type != IBV_MR_TYPE_MR || mw->type != IBV_MW_TYPE_1) - return ENOTSUP; - - if (umr->acc_flags & IBV_ACCESS_ZERO_BASED) + if (!bind_info->mr && (bind_info->addr || bind_info->length)) return EINVAL; + if (bind_info->mr) { + vmr = verbs_get_mr(bind_info->mr); + umr = container_of(vmr, struct irdma_umr, vmr); + + if (vmr->mr_type != IBV_MR_TYPE_MR || mw->type != IBV_MW_TYPE_1) + return ENOTSUP; + + if (umr->acc_flags & IBV_ACCESS_ZERO_BASED) + return EINVAL; + + if (mw->pd != bind_info->mr->pd) + return EPERM; + } + wr.opcode = IBV_WR_BIND_MW; wr.bind_mw.bind_info = mw_bind->bind_info; wr.bind_mw.mw = mw;