From patchwork Sun Dec 11 09:11:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13070538 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 A3819C001B2 for ; Sun, 11 Dec 2022 09:12:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbiLKJMN (ORCPT ); Sun, 11 Dec 2022 04:12:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbiLKJMK (ORCPT ); Sun, 11 Dec 2022 04:12:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3BF5E009 for ; Sun, 11 Dec 2022 01:12:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 75B67B8098E for ; Sun, 11 Dec 2022 09:12:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADF5EC433D2; Sun, 11 Dec 2022 09:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670749927; bh=iu2nUNmzcVOx5tj19oGLKZc2ubvjtbqBy1EM/ziSJns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pI0KzBjQShBBCeB6+/odhupR4GoQuZrMgM0Efx/JqtfZy51FmoUHMOh8yBc6hUnCw jSJBbpU8BzHTBUHov8BuJPKPzQ9aUjL+fEuIbNtTNJblpejmm3iIGrph6Wy5U82U6W 0juhQeohWyr75nkxbleOhtBL+VBV4ExWMvCtgb0uJzDsz+lScJbxVMTDQrsA97g9qz 2E915ivzr4TN/EPbljlKby5s8Ez3Caobk57XfCy8nbdnXw46ehB3yLo2nG9afml6og a5nHD9zCDrfYMJzJoVXhbiHKV7TCFuUxUL7VwGbTsrMVmrqdW2doipzrBPjDbXATEo IzpZqBfy1ENLg== From: Leon Romanovsky To: Jason Gunthorpe Cc: Maor Gottlieb , Daniel Jurgens , linux-rdma@vger.kernel.org, Moni Shoua , Parav Pandit , Patrisious Haddad , Shay Drory , Yishai Hadas Subject: [PATCH rdma-next 2/2] RDMA/mlx5: Fix validation of max_rd_atomic caps for DC Date: Sun, 11 Dec 2022 11:11:52 +0200 Message-Id: <193aa04bce4609df7d86250da3e2886f26f266cf.1670749789.git.leonro@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Maor Gottlieb Currently, when modifying DC, we validate max_rd_atomic user attribute against the RC cap, fix it to validate against DC. Fixes: c32a4f296e1d ("IB/mlx5: Add support for DC Initiator QP") Signed-off-by: Maor Gottlieb Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/qp.c | 49 +++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 0d2374a04064..b6f1bc11e4ac 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -4504,6 +4504,40 @@ static bool mlx5_ib_modify_qp_allowed(struct mlx5_ib_dev *dev, return false; } +static int validate_rd_atomic(struct mlx5_ib_dev *dev, struct ib_qp_attr *attr, + int attr_mask, enum ib_qp_type qp_type) +{ + int log_max_ra_res; + int log_max_ra_req; + + if (qp_type == MLX5_IB_QPT_DCI) { + log_max_ra_res = 1 << MLX5_CAP_GEN(dev->mdev, + log_max_ra_res_dc); + log_max_ra_req = 1 << MLX5_CAP_GEN(dev->mdev, + log_max_ra_req_dc); + } else { + log_max_ra_res = 1 << MLX5_CAP_GEN(dev->mdev, + log_max_ra_res_qp); + log_max_ra_req = 1 << MLX5_CAP_GEN(dev->mdev, + log_max_ra_req_qp); + } + + if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC && + attr->max_rd_atomic > log_max_ra_res) { + mlx5_ib_dbg(dev, "invalid max_rd_atomic value %d\n", + attr->max_rd_atomic); + return false; + } + + if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC && + attr->max_dest_rd_atomic > log_max_ra_req) { + mlx5_ib_dbg(dev, "invalid max_dest_rd_atomic value %d\n", + attr->max_dest_rd_atomic); + return false; + } + return true; +} + int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, struct ib_udata *udata) { @@ -4591,21 +4625,8 @@ int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, goto out; } - if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC && - attr->max_rd_atomic > - (1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_res_qp))) { - mlx5_ib_dbg(dev, "invalid max_rd_atomic value %d\n", - attr->max_rd_atomic); - goto out; - } - - if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC && - attr->max_dest_rd_atomic > - (1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_req_qp))) { - mlx5_ib_dbg(dev, "invalid max_dest_rd_atomic value %d\n", - attr->max_dest_rd_atomic); + if (!validate_rd_atomic(dev, attr, attr_mask, qp_type)) goto out; - } if (cur_state == new_state && cur_state == IB_QPS_RESET) { err = 0;