From patchwork Sat Aug 15 04:58:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715725 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6765D109B for ; Sat, 15 Aug 2020 21:57:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E49922BED for ; Sat, 15 Aug 2020 21:57:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hzztmP4Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726417AbgHOV5I (ORCPT ); Sat, 15 Aug 2020 17:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729012AbgHOVwK (ORCPT ); Sat, 15 Aug 2020 17:52:10 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79530C0612FF for ; Fri, 14 Aug 2020 21:59:38 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id j7so10012401oij.9 for ; Fri, 14 Aug 2020 21:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=opQ5PQYAFjcFf54uc0HWsHLrSgEnDQ3xUI0E2iiCI/g=; b=hzztmP4Q3XvogBg+dZXVPOcFzJsWNoJK/EZ2fEX9POpTJRawCRUhug0GlcCx/CCckF WbQNxvZ2oqH62YFzrM1b1V6Sa47WVWbUpvSauP+I14AN0roaKqVQ7qCeyHu4W/e2vwJb hb8mZ/V4tVaoyPCUwEWiQ17m72kwmHs/Zj2+34aEe4xrzfPSANGbPuak7rSr4MA+NOg4 lfXRC5eU19gF4LC5kozBWKfyB8A67wNUqf+2v7c6jfTYuI0Io+zmLNS3x4q6nSE1sduk SGHU62BtEldx5AbGfUdi41NFpczIRyfIYEReial4jy0JHr9WGDuAjCY7sORn8rQEEYQA Et/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=opQ5PQYAFjcFf54uc0HWsHLrSgEnDQ3xUI0E2iiCI/g=; b=cfHCbKUkFPLR5EB6IA7xQUws7cSKZlM2dlJjyo0yOA5c/abB7sju4ASdgBeVEYq7lx YhmbB4m8LB2AQT9i9K9tr5MMdgOgU5MTP6FxfFAjXRcgKyD+KUL1pB0I6nOFYwh3VL0T Oz1GCiEbg4tid0lysblSt3SDWXXZgVANUIcWDYmOOnr8XlczfObhtRQ1B1mA7A8qztTr /zcDIk73ZS82WEJCaRkE4vMi+AHXAuDv0cBkGPC9pfc76Gl7cDqMT+r8wa3/J0idnzuz 2RTl8QzkwGdXLB2AjmKiWsBPVRNNCBoYFPrEjBFwMFC3UyxhirHeUTMpjhW4s2qIDAMa t4JA== X-Gm-Message-State: AOAM531zCpbfZMAIXfP+Ggvz6Aj3Mcr0moW2qCNIPl0U2TehE/406BzV POl3hZZNOzR+Y7/w9BouAPHntN7mDJaMOA== X-Google-Smtp-Source: ABdhPJytR0QkHf/vBzFuBJFyXZNODGjjlIeXrZtJ/AutcF0DFxG0rcwya4TlbrkZrYkmDhxgr9UxPg== X-Received: by 2002:aca:504f:: with SMTP id e76mr3399452oib.87.1597467577281; Fri, 14 Aug 2020 21:59:37 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id h68sm2077710otb.50.2020.08.14.21.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 21:59:36 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 01/20] Added ib_uverbs_wc_opcode to ib_user_verbs.h Date: Fri, 14 Aug 2020 23:58:25 -0500 Message-Id: <20200815045912.8626-2-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This enum plays the same role as ib_uverbs_wr_opcode documenting the opcodes in the user space API. It plays a role for software drivers like rxe. Signed-off-by: Bob Pearson --- include/uapi/rdma/ib_user_verbs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index 0474c7400268..456438c18c2c 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h @@ -457,6 +457,17 @@ struct ib_uverbs_poll_cq { __u32 ne; }; +enum ib_uverbs_wc_opcode { + IB_UVERBS_WC_SEND = 0, + IB_UVERBS_WC_RDMA_WRITE = 1, + IB_UVERBS_WC_RDMA_READ = 2, + IB_UVERBS_WC_COMP_SWAP = 3, + IB_UVERBS_WC_FETCH_ADD = 4, + IB_UVERBS_WC_BIND_MW = 5, + IB_UVERBS_WC_LOCAL_INV = 6, + IB_UVERBS_WC_TSO = 7, +}; + struct ib_uverbs_wc { __aligned_u64 wr_id; __u32 status; From patchwork Sat Aug 15 04:58:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715775 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60145109B for ; Sat, 15 Aug 2020 22:02:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45A85205CB for ; Sat, 15 Aug 2020 22:02:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VMpGp3IH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728767AbgHOVvZ (ORCPT ); Sat, 15 Aug 2020 17:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728704AbgHOVvW (ORCPT ); Sat, 15 Aug 2020 17:51:22 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04DC5C0612A0 for ; Fri, 14 Aug 2020 21:59:40 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id x6so2344016ooe.8 for ; Fri, 14 Aug 2020 21:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=429me9TE7Vhzd2q6YVBMVKKbtkPoL3HxIm0ExCPvfUs=; b=VMpGp3IHovoVx0NlJXVNclR1tuGP2zqKlt/8gLr+Ae/pEVZCYo8NhUqqOcWpXDCIhu poMZzpfxKxvhjQA3/CkBGLcD8kwiYQQdDzL7Q1tndFzEFgJFdIgM1F1vFzXGmMDP95Pc 1JcyJUXZYysXIytudfgJwnqfm8feu1pyno7lycCzSw9JWnz+v3vnbSw/VSgJxG0uH6nB pvZqpuGIMOA2tiEdb3CwcaX4B8X5FoncJLGRPaWeQBydDlcr+zg8hLVjpEWY0KMggotO 5/HgF/yefiVJKSskoid783bmbvF9fPhRdvoGZ4aP3S6RYMYtz5jm2HGeodKXwmm3Nhdt XgxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=429me9TE7Vhzd2q6YVBMVKKbtkPoL3HxIm0ExCPvfUs=; b=OwRySXxGzAZDyl+v+sBrMlL/1UEb07yNeq4Hdjm4fDflC9Ttv9mPYcfj6SSKPJlwgq U/z2yFbKrzLuim7BGHa502zydfvyyAM6Zn5ccsmhCx2fPfxPr0X8kkF3VVD97s4+r0Qi M3K7guqx1e9uh6d/C7ZaZtWvm1Oj7xjFoRqzwdtIYP0y1a0bMVdppgEIyEsL+rBY/IcD QtntevlGasM9HagigIzGWlH6wTvfTxPObaYVRMK6niEMX7HG7xjLQHVyYeYOeK+cSuXP Q7l4h3/TBm5KEAsUQ1IgcpRQs3Tr5EocccDmsdHrTRbm4SWmiKrpQMgQp0MrAjoU+f3O YC5w== X-Gm-Message-State: AOAM5320NA8OXVtFHrUPt/Cj5+cSgkuuYADLyUh5c9LSSRbrZvf1ivOl 59BnqpajBWrc507oObs5dr8I8MczLqROnA== X-Google-Smtp-Source: ABdhPJy1CVL8rwhdcx3trnDX5VSjDHn8fIukm9ncF5G9ipqQnyDdGMideToZoAN2JxF5ZWrO1mWTdA== X-Received: by 2002:a4a:b983:: with SMTP id e3mr3967506oop.91.1597467579364; Fri, 14 Aug 2020 21:59:39 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id e194sm2200597oib.41.2020.08.14.21.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 21:59:39 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 02/20] Added missing IB_WR_BIND_MW opcode Date: Fri, 14 Aug 2020 23:58:26 -0500 Message-Id: <20200815045912.8626-3-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Also assigned the IB_WC_XXX to the IB_UVERBS_WC_XXX where they are defined. This follows the same pattern as the IB_WR_XXX opcodes. This fixes an incorrect value for LSO that had crept in but was not used. Signed-off-by: Bob Pearson --- include/rdma/ib_verbs.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index c0b2fa7e9b95..05362947322b 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -952,13 +952,14 @@ enum ib_wc_status { const char *__attribute_const__ ib_wc_status_msg(enum ib_wc_status status); enum ib_wc_opcode { - IB_WC_SEND, - IB_WC_RDMA_WRITE, - IB_WC_RDMA_READ, - IB_WC_COMP_SWAP, - IB_WC_FETCH_ADD, - IB_WC_LSO, - IB_WC_LOCAL_INV, + IB_WC_SEND = IB_UVERBS_WC_SEND, + IB_WC_RDMA_WRITE = IB_UVERBS_WC_RDMA_WRITE, + IB_WC_RDMA_READ = IB_UVERBS_WC_RDMA_READ, + IB_WC_COMP_SWAP = IB_UVERBS_WC_COMP_SWAP, + IB_WC_FETCH_ADD = IB_UVERBS_WC_FETCH_ADD, + IB_WC_BIND_MW = IB_UVERBS_WC_BIND_MW, + IB_WC_LOCAL_INV = IB_UVERBS_WC_LOCAL_INV, + IB_WC_LSO = IB_UVERBS_WC_TSO, IB_WC_REG_MR, IB_WC_MASKED_COMP_SWAP, IB_WC_MASKED_FETCH_ADD, @@ -1291,6 +1292,7 @@ enum ib_wr_opcode { IB_WR_RDMA_READ = IB_UVERBS_WR_RDMA_READ, IB_WR_ATOMIC_CMP_AND_SWP = IB_UVERBS_WR_ATOMIC_CMP_AND_SWP, IB_WR_ATOMIC_FETCH_AND_ADD = IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD, + IB_WR_BIND_MW = IB_UVERBS_WR_BIND_MW, IB_WR_LSO = IB_UVERBS_WR_TSO, IB_WR_SEND_WITH_INV = IB_UVERBS_WR_SEND_WITH_INV, IB_WR_RDMA_READ_WITH_INV = IB_UVERBS_WR_RDMA_READ_WITH_INV, From patchwork Sat Aug 15 04:58:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715763 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80F0F109B for ; Sat, 15 Aug 2020 22:01:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67897205CB for ; Sat, 15 Aug 2020 22:01:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fH0gyA3O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728959AbgHOWBQ (ORCPT ); Sat, 15 Aug 2020 18:01:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728262AbgHOVvd (ORCPT ); Sat, 15 Aug 2020 17:51:33 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E27C0612A1 for ; Fri, 14 Aug 2020 21:59:41 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id h22so9245224otq.11 for ; Fri, 14 Aug 2020 21:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bl+KzOl0h1ask77zaCl2Ubc4SzpRw3GKwaNcRyo1yz0=; b=fH0gyA3OygtpI4VQEyUgxucN0EgGZfo6h/VQP3nKoKfITsn5fYqbZeB5MNI0KCrNh7 DeW3Z7dJnIjOP3pR4LNqZeVZEaHkodidBIKrbXB348D1sRqa+XPFM0401LA39O0MHF+s IiATMtPod9mf7mgMBd61RtmGgQUub4yX1kgnCIWVSw/gUj/clXZyYyz6Wg/0ffF5r0ad iJAMvoLmH8UGlt9tH8zaNvuTE+mYOL/kIFzqw6PzWmYZPnr4aqCqEzqgV17EP0I3tZVW OJgAidRa0z3ZJQlCvl1mu1K5guDhkzRED/J6YiaciUP4Fr3C5igNNmSDp3jEyv5TraYo naGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bl+KzOl0h1ask77zaCl2Ubc4SzpRw3GKwaNcRyo1yz0=; b=dYKY/XjTtjXrCLoRo80tJ4Hm6At43xbDLj4lW7DFi7Hj6vtYkLgwHiQZnhUFATRyz+ CFGiZLMz4wJQ89sPWuvsslPWazaI9Vo+L1xZ6wj0J72nvzJpes+x6B1mno1ny7ZlxJSC IOB8A8pITYWtJJ6L6pqIUiNQIstiQ7G7+mSTZB+KsC8imhG0vcB41aV+A+CWJjUXETR8 t9KKotdr0Ab0BxW8ULjjNzDdO5U1KWTXTjSgA76wN783pUvo0rVp+fFBE0NXRUjnVwmD 0DD1+NcJQ0yJLIMi1f0g/1Ww0mU9kuZNxK9A81V6zRQhD9HfoQTgqY3HyYn6iAB9J8vy Fmjg== X-Gm-Message-State: AOAM532QF3TMv51jUKVysvVGR509XWBdPZCYODOb+LlQIA6GXFBqg33A UGnm9LkceJ9rwPi6gn8Vv+qTgFHg3R5vig== X-Google-Smtp-Source: ABdhPJzo5nkoRQJzG4xz9CnM0hzImTODI21ddPGzTULjOtxYIK1+ubxR1FLpru6YyjZSRJgr9LnXww== X-Received: by 2002:a9d:25:: with SMTP id 34mr4068930ota.343.1597467581174; Fri, 14 Aug 2020 21:59:41 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id b17sm2098832otj.73.2020.08.14.21.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 21:59:40 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 03/20] Added bind_mw parameters to rxe_send_wr. Date: Fri, 14 Aug 2020 23:58:27 -0500 Message-Id: <20200815045912.8626-4-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This is a first prototype version of the user/kernel ABI extension to add memory windows functionality to the rxe driver. It evolves later. Signed-off-by: Bob Pearson --- include/uapi/rdma/rdma_user_rxe.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/uapi/rdma/rdma_user_rxe.h b/include/uapi/rdma/rdma_user_rxe.h index aae2e696bb38..f88867d85c3f 100644 --- a/include/uapi/rdma/rdma_user_rxe.h +++ b/include/uapi/rdma/rdma_user_rxe.h @@ -93,6 +93,14 @@ struct rxe_send_wr { __u32 remote_qkey; __u16 pkey_index; } ud; + struct { + __aligned_u64 addr; + __aligned_u64 length; + __u32 mr_rkey; + __u32 mw_rkey; + __u32 rkey; + __u32 access; + } bind_mw; /* reg is only used by the kernel and is not part of the uapi */ struct { union { From patchwork Sat Aug 15 04:58:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715733 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92865109B for ; Sat, 15 Aug 2020 21:57:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B766206B6 for ; Sat, 15 Aug 2020 21:57:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vHVhJQKF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729302AbgHOV51 (ORCPT ); Sat, 15 Aug 2020 17:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728989AbgHOVwG (ORCPT ); Sat, 15 Aug 2020 17:52:06 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 698C0C0612A2 for ; Fri, 14 Aug 2020 21:59:53 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id q9so9261265oth.5 for ; Fri, 14 Aug 2020 21:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OFiXWVNDlXpo9SVgxkQ2DmbUogJKMp46f6P28S9Kqw0=; b=vHVhJQKFdbP5GGzx3LI4g7rY7xmBJgI95BmOOfHExHNhIcgUZjriDSVcVWAt/XTxcP Adq+hSRsdgukqek0kGdXJy0GEtWV8BO+WGSlzKMp2Gtzqu9e8qlYvo/4kFtc6kiFmfXW q9idA7HzkkNBrzUCWTZeJoHnThesXVQt3fAR+nK+iowlPd6MOJB9Dawxul47OdT3wMnh yWlx5Ou54k1DY2GjqjSvZI7acBKbLvDlxy4r2q95m13KKWO/nQB243Cod6dzlkZ1f0dC UJzLqxcPdysQb1CO962+OYJrQ54CtgMKvUNA7oJhn9DfbuAnOAKKJiuZi7ed0zxqmlnb /VpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OFiXWVNDlXpo9SVgxkQ2DmbUogJKMp46f6P28S9Kqw0=; b=fxmFGwnlwp6Qv+qmxkjnP4nFDlntaeo2KtruzsNmkqiF/l8AXIUffh2LDaFqBUPPMM tPY6pXc7OI8Mqp3GU4wRVxxW15FbQvE9Dz1RqvpTQ4PwkhAO+2oZkhcq/97ole1IMjYB ix+EIZbPVpNnUE+BWfCNLrnDg+gM0GJBotGuwPshATk1KSdrPvVKkAp2jgtMDQO/dthg AJSLENoVVoVzcRMpVLQdEk0tD2TRtsYc6pOS8pwF3IReJ5LdBxFeyX/uozvLxpJ53wnO rTctUJhvoxda71ebv3N6ieg8/O5VZzQhMHfBraujUc8fo8/eWZZ0uDNhZ3LYKwz9FxAX rvKg== X-Gm-Message-State: AOAM5301BCiY/Y80hFsxPGueZRg2IJINKsWb97XAdpE7IBYi+iQGkpQ4 kwZEHvMTqJn9zSOBqeBUT61E/vvqrPwt4w== X-Google-Smtp-Source: ABdhPJwG1Ivp2YLVZs8xksuNA8e39C0GxYidiEQlPH++mUnbrpnq+noCoauN+QreyXq80nFRzQe9vQ== X-Received: by 2002:a9d:7f8e:: with SMTP id t14mr4390772otp.63.1597467592379; Fri, 14 Aug 2020 21:59:52 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id y15sm2089439oto.60.2020.08.14.21.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 21:59:52 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 04/20] Added stubs for alloc_mw and dealloc_mw verbs. Date: Fri, 14 Aug 2020 23:58:28 -0500 Message-Id: <20200815045912.8626-5-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Added a new file focused on memory windows, rxe_mw.c and adds stubbed out kernel verbs API for alloc_mw and dealloc_mw. These functios are added to the context ops struct and bits added to the supported APIs mask. These APIs allow progress on the rdma-core user space testing. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/Makefile | 1 + drivers/infiniband/sw/rxe/rxe_loc.h | 5 +++ drivers/infiniband/sw/rxe/rxe_mw.c | 49 +++++++++++++++++++++++++++ drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +++ 4 files changed, 59 insertions(+) create mode 100644 drivers/infiniband/sw/rxe/rxe_mw.c diff --git a/drivers/infiniband/sw/rxe/Makefile b/drivers/infiniband/sw/rxe/Makefile index 66af72dca759..1e24673e9318 100644 --- a/drivers/infiniband/sw/rxe/Makefile +++ b/drivers/infiniband/sw/rxe/Makefile @@ -15,6 +15,7 @@ rdma_rxe-y := \ rxe_qp.o \ rxe_cq.o \ rxe_mr.o \ + rxe_mw.o \ rxe_opcode.o \ rxe_mmap.o \ rxe_icrc.o \ diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 39dc3bfa5d5d..02f8ff4ed8f2 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -136,6 +136,11 @@ void rxe_mem_cleanup(struct rxe_pool_entry *arg); int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); +/* rxe_mw.c */ +struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, + struct ib_udata *udata); +int rxe_dealloc_mw(struct ib_mw *ibmw); + /* rxe_net.c */ void rxe_loopback(struct sk_buff *skb); int rxe_send(struct rxe_pkt_info *pkt, struct sk_buff *skb); diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c new file mode 100644 index 000000000000..6139dc9d8dd8 --- /dev/null +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 Hewlett Packard Enterprise, Inc. All rights reserved. + * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. + * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "rxe.h" +#include "rxe_loc.h" + +struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, + struct ib_udata *udata) +{ + pr_err_once("rxe_alloc_mw: not implemented\n"); + return ERR_PTR(-ENOSYS); +} + +int rxe_dealloc_mw(struct ib_mw *ibmw) +{ + pr_err_once("rxe_dealloc_mw: not implemented\n"); + return -ENOSYS; +} diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index bb61e534e468..1dbc69b86859 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -1128,6 +1128,8 @@ static const struct ib_device_ops rxe_dev_ops = { .reg_user_mr = rxe_reg_user_mr, .req_notify_cq = rxe_req_notify_cq, .resize_cq = rxe_resize_cq, + .alloc_mw = rxe_alloc_mw, + .dealloc_mw = rxe_dealloc_mw, INIT_RDMA_OBJ_SIZE(ib_ah, rxe_ah, ibah), INIT_RDMA_OBJ_SIZE(ib_cq, rxe_cq, ibcq), @@ -1189,6 +1191,8 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name) | BIT_ULL(IB_USER_VERBS_CMD_DESTROY_AH) | BIT_ULL(IB_USER_VERBS_CMD_ATTACH_MCAST) | BIT_ULL(IB_USER_VERBS_CMD_DETACH_MCAST) + | BIT_ULL(IB_USER_VERBS_CMD_ALLOC_MW) + | BIT_ULL(IB_USER_VERBS_CMD_DEALLOC_MW) ; ib_set_device_ops(dev, &rxe_dev_ops); From patchwork Sat Aug 15 04:58:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715663 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 349EF913 for ; Sat, 15 Aug 2020 21:52:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B2342053B for ; Sat, 15 Aug 2020 21:52:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VFRmNOc1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729024AbgHOVwN (ORCPT ); Sat, 15 Aug 2020 17:52:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728990AbgHOVwG (ORCPT ); Sat, 15 Aug 2020 17:52:06 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DB06C0612A3 for ; Fri, 14 Aug 2020 21:59:55 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id g18so2358665ooa.0 for ; Fri, 14 Aug 2020 21:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=evvrC1lIMM019VSZG2fO7JgYxDLtlrdmFi31nJrVZBQ=; b=VFRmNOc1rtuoAl5Ro5Bt8Kdl5LzybkcBaCi8wpYrowX4RsO991fFAr0FXyXOfTN5Ta kac4Mrml64FWEyaeWJBG19/x8YEHCggoYR/eKUh39DgzLN0iajYyTv1gxzHy1+Y6uI4l eT7b7/btRminNIBXhQ89BXsPWdjkkY+CD90lksTVk/jc7oHT9NHdEFIPXaRaObWrXO/+ ndZ/e6+2UFzTZOTYZ0mZkm9UT9xghlGCKCsJSd5HWPmVlK4hKem5jGvcvugGo0kL96Zs nfrwbfsA47/apDXuu7J3wYTrwJpYT5kxhYqC0q4pslRJdmYSMEPf/OpjXiz8kW6wH2t8 pkaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=evvrC1lIMM019VSZG2fO7JgYxDLtlrdmFi31nJrVZBQ=; b=r+kNR6Zq2nCy7vHp6Gk4DOUXoAb6TuqlktBPTtDUI4iOlbhcjoFLss204kNHUdKXlF yjGgpfC+F+TBaaj/zH6pMhKfCpZS6QH86MrurW0dj6dQ5f0gtwDiaeEOjbwgjklz9L6z zvuXWGsw6bkWL7cW50WXNp31sadjBchYWEvYBN6bxWQ+9OCJPSLFczTYpIMzz1RqWncP EUKe/CefHmK+OmzGGQcB/gWQplLTwbr8ryidbMaWMlwxXPZtn7kiRyK02eRi+dnQ68Yc ysA11U9Hwg3uR2InLjASyjeh3uHOnvXDSebPLXewq2VKZbKePLOfriTldr5kVBUX2TYB BDLQ== X-Gm-Message-State: AOAM532MZxudRlmd6f7IELymxpM9sSLoatWP5Uh9zrgVcn62eiUhImXD 0wnsOxKyilF9AETzG80W82nA8YIBlGsTIw== X-Google-Smtp-Source: ABdhPJzVV/pSwUqO7rL13gQhL9yGkrSCtL3UqdxXDbNJ9jc/9X5IwLb3bt4F6yNCVQlNRrhBgCbwlQ== X-Received: by 2002:a4a:614f:: with SMTP id u15mr4065689ooe.53.1597467594248; Fri, 14 Aug 2020 21:59:54 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id b26sm2200667oib.47.2020.08.14.21.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 21:59:53 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 05/20] Separated MR and MW objects. Date: Fri, 14 Aug 2020 23:58:29 -0500 Message-Id: <20200815045912.8626-6-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org In the original rxe implementation it was intended to use a common object to represent MRs and MWs but it became clear that they are different enough to separate these into two objects. This allows replacing the mem name with mr for MRs which is less likely to be confusing. This is a long patch that just changes mem to mr everywhere it made sense. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 4 +- drivers/infiniband/sw/rxe/rxe_loc.h | 26 +-- drivers/infiniband/sw/rxe/rxe_mr.c | 258 +++++++++++++------------- drivers/infiniband/sw/rxe/rxe_pool.c | 6 +- drivers/infiniband/sw/rxe/rxe_req.c | 6 +- drivers/infiniband/sw/rxe/rxe_resp.c | 30 +-- drivers/infiniband/sw/rxe/rxe_verbs.c | 19 +- drivers/infiniband/sw/rxe/rxe_verbs.h | 31 ++-- 8 files changed, 189 insertions(+), 191 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index 4bc88708b355..b9b8c4e115f4 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -372,7 +372,7 @@ static inline enum comp_state do_read(struct rxe_qp *qp, ret = copy_data(qp->pd, IB_ACCESS_LOCAL_WRITE, &wqe->dma, payload_addr(pkt), - payload_size(pkt), to_mem_obj, NULL); + payload_size(pkt), to_mr_obj, NULL); if (ret) return COMPST_ERROR; @@ -392,7 +392,7 @@ static inline enum comp_state do_atomic(struct rxe_qp *qp, ret = copy_data(qp->pd, IB_ACCESS_LOCAL_WRITE, &wqe->dma, &atomic_orig, - sizeof(u64), to_mem_obj, NULL); + sizeof(u64), to_mr_obj, NULL); if (ret) return COMPST_ERROR; else diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 02f8ff4ed8f2..42375af68f48 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -99,40 +99,40 @@ int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); /* rxe_mr.c */ enum copy_direction { - to_mem_obj, - from_mem_obj, + to_mr_obj, + from_mr_obj, }; -void rxe_mem_init_dma(struct rxe_pd *pd, - int access, struct rxe_mem *mem); +int rxe_mr_init_dma(struct rxe_pd *pd, + int access, struct rxe_mr *mr); -int rxe_mem_init_user(struct rxe_pd *pd, u64 start, +int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova, int access, struct ib_udata *udata, - struct rxe_mem *mr); + struct rxe_mr *mr); -int rxe_mem_init_fast(struct rxe_pd *pd, - int max_pages, struct rxe_mem *mem); +int rxe_mr_init_fast(struct rxe_pd *pd, + int max_pages, struct rxe_mr *mr); -int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr, +int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, enum copy_direction dir, u32 *crcp); int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma, void *addr, int length, enum copy_direction dir, u32 *crcp); -void *iova_to_vaddr(struct rxe_mem *mem, u64 iova, int length); +void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length); enum lookup_type { lookup_local, lookup_remote, }; -struct rxe_mem *lookup_mem(struct rxe_pd *pd, int access, u32 key, +struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, enum lookup_type type); -int mem_check_range(struct rxe_mem *mem, u64 iova, size_t length); +int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); -void rxe_mem_cleanup(struct rxe_pool_entry *arg); +void rxe_mr_cleanup(struct rxe_pool_entry *arg); int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index cdd811a45120..0606f04e1d18 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -51,17 +51,17 @@ static u8 rxe_get_key(void) return key; } -int mem_check_range(struct rxe_mem *mem, u64 iova, size_t length) +int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length) { - switch (mem->type) { + switch (mr->type) { case RXE_MEM_TYPE_DMA: return 0; case RXE_MEM_TYPE_MR: case RXE_MEM_TYPE_FMR: - if (iova < mem->iova || - length > mem->length || - iova > mem->iova + mem->length - length) + if (iova < mr->iova || + length > mr->length || + iova > mr->iova + mr->length - length) return -EFAULT; return 0; @@ -74,90 +74,90 @@ int mem_check_range(struct rxe_mem *mem, u64 iova, size_t length) | IB_ACCESS_REMOTE_WRITE \ | IB_ACCESS_REMOTE_ATOMIC) -static void rxe_mem_init(int access, struct rxe_mem *mem) +static void rxe_mr_init(int access, struct rxe_mr *mr) { - u32 lkey = mem->pelem.index << 8 | rxe_get_key(); + u32 lkey = mr->pelem.index << 8 | rxe_get_key(); u32 rkey = (access & IB_ACCESS_REMOTE) ? lkey : 0; - if (mem->pelem.pool->type == RXE_TYPE_MR) { - mem->ibmr.lkey = lkey; - mem->ibmr.rkey = rkey; + if (mr->pelem.pool->type == RXE_TYPE_MR) { + mr->ibmr.lkey = lkey; + mr->ibmr.rkey = rkey; } - mem->lkey = lkey; - mem->rkey = rkey; - mem->state = RXE_MEM_STATE_INVALID; - mem->type = RXE_MEM_TYPE_NONE; - mem->map_shift = ilog2(RXE_BUF_PER_MAP); + mr->lkey = lkey; + mr->rkey = rkey; + mr->state = RXE_MEM_STATE_INVALID; + mr->type = RXE_MEM_TYPE_NONE; + mr->map_shift = ilog2(RXE_BUF_PER_MAP); } -void rxe_mem_cleanup(struct rxe_pool_entry *arg) +void rxe_mr_cleanup(struct rxe_pool_entry *arg) { - struct rxe_mem *mem = container_of(arg, typeof(*mem), pelem); + struct rxe_mr *mr = container_of(arg, typeof(*mr), pelem); int i; - ib_umem_release(mem->umem); + ib_umem_release(mr->umem); - if (mem->map) { - for (i = 0; i < mem->num_map; i++) - kfree(mem->map[i]); + if (mr->map) { + for (i = 0; i < mr->num_map; i++) + kfree(mr->map[i]); - kfree(mem->map); + kfree(mr->map); } } -static int rxe_mem_alloc(struct rxe_mem *mem, int num_buf) +static int rxe_mr_alloc(struct rxe_mr *mr, int num_buf) { int i; int num_map; - struct rxe_map **map = mem->map; + struct rxe_map **map = mr->map; num_map = (num_buf + RXE_BUF_PER_MAP - 1) / RXE_BUF_PER_MAP; - mem->map = kmalloc_array(num_map, sizeof(*map), GFP_KERNEL); - if (!mem->map) + mr->map = kmalloc_array(num_map, sizeof(*map), GFP_KERNEL); + if (!mr->map) goto err1; for (i = 0; i < num_map; i++) { - mem->map[i] = kmalloc(sizeof(**map), GFP_KERNEL); - if (!mem->map[i]) + mr->map[i] = kmalloc(sizeof(**map), GFP_KERNEL); + if (!mr->map[i]) goto err2; } BUILD_BUG_ON(!is_power_of_2(RXE_BUF_PER_MAP)); - mem->map_shift = ilog2(RXE_BUF_PER_MAP); - mem->map_mask = RXE_BUF_PER_MAP - 1; + mr->map_shift = ilog2(RXE_BUF_PER_MAP); + mr->map_mask = RXE_BUF_PER_MAP - 1; - mem->num_buf = num_buf; - mem->num_map = num_map; - mem->max_buf = num_map * RXE_BUF_PER_MAP; + mr->num_buf = num_buf; + mr->num_map = num_map; + mr->max_buf = num_map * RXE_BUF_PER_MAP; return 0; err2: for (i--; i >= 0; i--) - kfree(mem->map[i]); + kfree(mr->map[i]); - kfree(mem->map); + kfree(mr->map); err1: return -ENOMEM; } -void rxe_mem_init_dma(struct rxe_pd *pd, - int access, struct rxe_mem *mem) +void rxe_mr_init_dma(struct rxe_pd *pd, + int access, struct rxe_mr *mr) { - rxe_mem_init(access, mem); + rxe_mr_init(access, mr); - mem->pd = pd; - mem->access = access; - mem->state = RXE_MEM_STATE_VALID; - mem->type = RXE_MEM_TYPE_DMA; + mr->pd = pd; + mr->access = access; + mr->state = RXE_MEM_STATE_VALID; + mr->type = RXE_MEM_TYPE_DMA; } -int rxe_mem_init_user(struct rxe_pd *pd, u64 start, +int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova, int access, struct ib_udata *udata, - struct rxe_mem *mem) + struct rxe_mr *mr) { struct rxe_map **map; struct rxe_phys_buf *buf = NULL; @@ -175,23 +175,23 @@ int rxe_mem_init_user(struct rxe_pd *pd, u64 start, goto err1; } - mem->umem = umem; + mr->umem = umem; num_buf = ib_umem_num_pages(umem); - rxe_mem_init(access, mem); + rxe_mr_init(access, mr); - err = rxe_mem_alloc(mem, num_buf); + err = rxe_mr_alloc(mr, num_buf); if (err) { - pr_warn("err %d from rxe_mem_alloc\n", err); + pr_warn("err %d from rxe_mr_alloc\n", err); ib_umem_release(umem); goto err1; } - mem->page_shift = PAGE_SHIFT; - mem->page_mask = PAGE_SIZE - 1; + mr->page_shift = PAGE_SHIFT; + mr->page_mask = PAGE_SIZE - 1; num_buf = 0; - map = mem->map; + map = mr->map; if (length > 0) { buf = map[0]->buf; @@ -217,15 +217,15 @@ int rxe_mem_init_user(struct rxe_pd *pd, u64 start, } } - mem->pd = pd; - mem->umem = umem; - mem->access = access; - mem->length = length; - mem->iova = iova; - mem->va = start; - mem->offset = ib_umem_offset(umem); - mem->state = RXE_MEM_STATE_VALID; - mem->type = RXE_MEM_TYPE_MR; + mr->pd = pd; + mr->umem = umem; + mr->access = access; + mr->length = length; + mr->iova = iova; + mr->va = start; + mr->offset = ib_umem_offset(umem); + mr->state = RXE_MEM_STATE_VALID; + mr->type = RXE_MEM_TYPE_MR; return 0; @@ -233,24 +233,24 @@ int rxe_mem_init_user(struct rxe_pd *pd, u64 start, return err; } -int rxe_mem_init_fast(struct rxe_pd *pd, - int max_pages, struct rxe_mem *mem) +int rxe_mr_init_fast(struct rxe_pd *pd, + int max_pages, struct rxe_mr *mr) { int err; - rxe_mem_init(0, mem); + rxe_mr_init(0, mr); /* In fastreg, we also set the rkey */ - mem->ibmr.rkey = mem->ibmr.lkey; + mr->ibmr.rkey = mr->ibmr.lkey; - err = rxe_mem_alloc(mem, max_pages); + err = rxe_mr_alloc(mr, max_pages); if (err) goto err1; - mem->pd = pd; - mem->max_buf = max_pages; - mem->state = RXE_MEM_STATE_FREE; - mem->type = RXE_MEM_TYPE_MR; + mr->pd = pd; + mr->max_buf = max_pages; + mr->state = RXE_MEM_STATE_FREE; + mr->type = RXE_MEM_TYPE_MR; return 0; @@ -259,27 +259,27 @@ int rxe_mem_init_fast(struct rxe_pd *pd, } static void lookup_iova( - struct rxe_mem *mem, + struct rxe_mr *mr, u64 iova, int *m_out, int *n_out, size_t *offset_out) { - size_t offset = iova - mem->iova + mem->offset; + size_t offset = iova - mr->iova + mr->offset; int map_index; int buf_index; u64 length; - if (likely(mem->page_shift)) { - *offset_out = offset & mem->page_mask; - offset >>= mem->page_shift; - *n_out = offset & mem->map_mask; - *m_out = offset >> mem->map_shift; + if (likely(mr->page_shift)) { + *offset_out = offset & mr->page_mask; + offset >>= mr->page_shift; + *n_out = offset & mr->map_mask; + *m_out = offset >> mr->map_shift; } else { map_index = 0; buf_index = 0; - length = mem->map[map_index]->buf[buf_index].size; + length = mr->map[map_index]->buf[buf_index].size; while (offset >= length) { offset -= length; @@ -289,7 +289,7 @@ static void lookup_iova( map_index++; buf_index = 0; } - length = mem->map[map_index]->buf[buf_index].size; + length = mr->map[map_index]->buf[buf_index].size; } *m_out = map_index; @@ -298,48 +298,48 @@ static void lookup_iova( } } -void *iova_to_vaddr(struct rxe_mem *mem, u64 iova, int length) +void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) { size_t offset; int m, n; void *addr; - if (mem->state != RXE_MEM_STATE_VALID) { - pr_warn("mem not in valid state\n"); + if (mr->state != RXE_MEM_STATE_VALID) { + pr_warn("mr not in valid state\n"); addr = NULL; goto out; } - if (!mem->map) { + if (!mr->map) { addr = (void *)(uintptr_t)iova; goto out; } - if (mem_check_range(mem, iova, length)) { + if (mr_check_range(mr, iova, length)) { pr_warn("range violation\n"); addr = NULL; goto out; } - lookup_iova(mem, iova, &m, &n, &offset); + lookup_iova(mr, iova, &m, &n, &offset); - if (offset + length > mem->map[m]->buf[n].size) { + if (offset + length > mr->map[m]->buf[n].size) { pr_warn("crosses page boundary\n"); addr = NULL; goto out; } - addr = (void *)(uintptr_t)mem->map[m]->buf[n].addr + offset; + addr = (void *)(uintptr_t)mr->map[m]->buf[n].addr + offset; out: return addr; } /* copy data from a range (vaddr, vaddr+length-1) to or from - * a mem object starting at iova. Compute incremental value of - * crc32 if crcp is not zero. caller must hold a reference to mem + * a mr object starting at iova. Compute incremental value of + * crc32 if crcp is not zero. caller must hold a reference to mr */ -int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr, int length, +int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, enum copy_direction dir, u32 *crcp) { int err; @@ -355,43 +355,43 @@ int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr, int length, if (length == 0) return 0; - if (mem->type == RXE_MEM_TYPE_DMA) { + if (mr->type == RXE_MEM_TYPE_DMA) { u8 *src, *dest; - src = (dir == to_mem_obj) ? + src = (dir == to_mr_obj) ? addr : ((void *)(uintptr_t)iova); - dest = (dir == to_mem_obj) ? + dest = (dir == to_mr_obj) ? ((void *)(uintptr_t)iova) : addr; memcpy(dest, src, length); if (crcp) - *crcp = rxe_crc32(to_rdev(mem->pd->ibpd.device), + *crcp = rxe_crc32(to_rdev(mr->pd->ibpd.device), *crcp, dest, length); return 0; } - WARN_ON_ONCE(!mem->map); + WARN_ON_ONCE(!mr->map); - err = mem_check_range(mem, iova, length); + err = mr_check_range(mr, iova, length); if (err) { err = -EFAULT; goto err1; } - lookup_iova(mem, iova, &m, &i, &offset); + lookup_iova(mr, iova, &m, &i, &offset); - map = mem->map + m; + map = mr->map + m; buf = map[0]->buf + i; while (length > 0) { u8 *src, *dest; va = (u8 *)(uintptr_t)buf->addr + offset; - src = (dir == to_mem_obj) ? addr : va; - dest = (dir == to_mem_obj) ? va : addr; + src = (dir == to_mr_obj) ? addr : va; + dest = (dir == to_mr_obj) ? va : addr; bytes = buf->size - offset; @@ -401,7 +401,7 @@ int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr, int length, memcpy(dest, src, bytes); if (crcp) - crc = rxe_crc32(to_rdev(mem->pd->ibpd.device), + crc = rxe_crc32(to_rdev(mr->pd->ibpd.device), crc, dest, bytes); length -= bytes; @@ -443,7 +443,7 @@ int copy_data( struct rxe_sge *sge = &dma->sge[dma->cur_sge]; int offset = dma->sge_offset; int resid = dma->resid; - struct rxe_mem *mem = NULL; + struct rxe_mr *mr = NULL; u64 iova; int err; @@ -456,8 +456,8 @@ int copy_data( } if (sge->length && (offset < sge->length)) { - mem = lookup_mem(pd, access, sge->lkey, lookup_local); - if (!mem) { + mr = lookup_mr(pd, access, sge->lkey, lookup_local); + if (!mr) { err = -EINVAL; goto err1; } @@ -467,9 +467,9 @@ int copy_data( bytes = length; if (offset >= sge->length) { - if (mem) { - rxe_drop_ref(mem); - mem = NULL; + if (mr) { + rxe_drop_ref(mr); + mr = NULL; } sge++; dma->cur_sge++; @@ -481,9 +481,9 @@ int copy_data( } if (sge->length) { - mem = lookup_mem(pd, access, sge->lkey, + mr = lookup_mr(pd, access, sge->lkey, lookup_local); - if (!mem) { + if (!mr) { err = -EINVAL; goto err1; } @@ -498,7 +498,7 @@ int copy_data( if (bytes > 0) { iova = sge->addr + offset; - err = rxe_mem_copy(mem, iova, addr, bytes, dir, crcp); + err = rxe_mr_copy(mr, iova, addr, bytes, dir, crcp); if (err) goto err2; @@ -512,14 +512,14 @@ int copy_data( dma->sge_offset = offset; dma->resid = resid; - if (mem) - rxe_drop_ref(mem); + if (mr) + rxe_drop_ref(mr); return 0; err2: - if (mem) - rxe_drop_ref(mem); + if (mr) + rxe_drop_ref(mr); err1: return err; } @@ -557,31 +557,31 @@ int advance_dma_data(struct rxe_dma_info *dma, unsigned int length) return 0; } -/* (1) find the mem (mr or mw) corresponding to lkey/rkey +/* (1) find the mr (mr or mw) corresponding to lkey/rkey * depending on lookup_type - * (2) verify that the (qp) pd matches the mem pd - * (3) verify that the mem can support the requested access - * (4) verify that mem state is valid + * (2) verify that the (qp) pd matches the mr pd + * (3) verify that the mr can support the requested access + * (4) verify that mr state is valid */ -struct rxe_mem *lookup_mem(struct rxe_pd *pd, int access, u32 key, +struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, enum lookup_type type) { - struct rxe_mem *mem; + struct rxe_mr *mr; struct rxe_dev *rxe = to_rdev(pd->ibpd.device); int index = key >> 8; - mem = rxe_pool_get_index(&rxe->mr_pool, index); - if (!mem) + mr = rxe_pool_get_index(&rxe->mr_pool, index); + if (!mr) return NULL; - if (unlikely((type == lookup_local && mem->lkey != key) || - (type == lookup_remote && mem->rkey != key) || - mem->pd != pd || - (access && !(access & mem->access)) || - mem->state != RXE_MEM_STATE_VALID)) { - rxe_drop_ref(mem); - mem = NULL; + if (unlikely((type == lookup_local && mr->lkey != key) || + (type == lookup_remote && mr->rkey != key) || + mr->pd != pd || + (access && !(access & mr->access)) || + mr->state != RXE_MEM_STATE_VALID)) { + rxe_drop_ref(mr); + mr = NULL; } - return mem; + return mr; } diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index fbcbac52290b..ba002fed8051 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -77,15 +77,15 @@ struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = { }, [RXE_TYPE_MR] = { .name = "rxe-mr", - .size = sizeof(struct rxe_mem), - .cleanup = rxe_mem_cleanup, + .size = sizeof(struct rxe_mr), + .cleanup = rxe_mr_cleanup, .flags = RXE_POOL_INDEX, .max_index = RXE_MAX_MR_INDEX, .min_index = RXE_MIN_MR_INDEX, }, [RXE_TYPE_MW] = { .name = "rxe-mw", - .size = sizeof(struct rxe_mem), + .size = sizeof(struct rxe_mr), .flags = RXE_POOL_INDEX, .max_index = RXE_MAX_MW_INDEX, .min_index = RXE_MIN_MW_INDEX, diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index 34df2b55e650..c566372eebf8 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -492,7 +492,7 @@ static int fill_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe, } else { err = copy_data(qp->pd, 0, &wqe->dma, payload_addr(pkt), paylen, - from_mem_obj, + from_mr_obj, &crc); if (err) return err; @@ -624,7 +624,7 @@ int rxe_requester(void *arg) if (wqe->mask & WR_REG_MASK) { if (wqe->wr.opcode == IB_WR_LOCAL_INV) { struct rxe_dev *rxe = to_rdev(qp->ibqp.device); - struct rxe_mem *rmr; + struct rxe_mr *rmr; rmr = rxe_pool_get_index(&rxe->mr_pool, wqe->wr.ex.invalidate_rkey >> 8); @@ -640,7 +640,7 @@ int rxe_requester(void *arg) wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; } else if (wqe->wr.opcode == IB_WR_REG_MR) { - struct rxe_mem *rmr = to_rmr(wqe->wr.wr.reg.mr); + struct rxe_mr *rmr = to_rmr(wqe->wr.wr.reg.mr); rmr->state = RXE_MEM_STATE_VALID; rmr->access = wqe->wr.wr.reg.access; diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index c4a8195bf670..d54b5e7dad39 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -417,7 +417,7 @@ static enum resp_states check_length(struct rxe_qp *qp, static enum resp_states check_rkey(struct rxe_qp *qp, struct rxe_pkt_info *pkt) { - struct rxe_mem *mem = NULL; + struct rxe_mr *mr = NULL; u64 va; u32 rkey; u32 resid; @@ -456,18 +456,18 @@ static enum resp_states check_rkey(struct rxe_qp *qp, resid = qp->resp.resid; pktlen = payload_size(pkt); - mem = lookup_mem(qp->pd, access, rkey, lookup_remote); - if (!mem) { + mr = lookup_mr(qp->pd, access, rkey, lookup_remote); + if (!mr) { state = RESPST_ERR_RKEY_VIOLATION; goto err; } - if (unlikely(mem->state == RXE_MEM_STATE_FREE)) { + if (unlikely(mr->state == RXE_MEM_STATE_FREE)) { state = RESPST_ERR_RKEY_VIOLATION; goto err; } - if (mem_check_range(mem, va, resid)) { + if (mr_check_range(mr, va, resid)) { state = RESPST_ERR_RKEY_VIOLATION; goto err; } @@ -495,12 +495,12 @@ static enum resp_states check_rkey(struct rxe_qp *qp, WARN_ON_ONCE(qp->resp.mr); - qp->resp.mr = mem; + qp->resp.mr = mr; return RESPST_EXECUTE; err: - if (mem) - rxe_drop_ref(mem); + if (mr) + rxe_drop_ref(mr); return state; } @@ -510,7 +510,7 @@ static enum resp_states send_data_in(struct rxe_qp *qp, void *data_addr, int err; err = copy_data(qp->pd, IB_ACCESS_LOCAL_WRITE, &qp->resp.wqe->dma, - data_addr, data_len, to_mem_obj, NULL); + data_addr, data_len, to_mr_obj, NULL); if (unlikely(err)) return (err == -ENOSPC) ? RESPST_ERR_LENGTH : RESPST_ERR_MALFORMED_WQE; @@ -525,8 +525,8 @@ static enum resp_states write_data_in(struct rxe_qp *qp, int err; int data_len = payload_size(pkt); - err = rxe_mem_copy(qp->resp.mr, qp->resp.va, payload_addr(pkt), - data_len, to_mem_obj, NULL); + err = rxe_mr_copy(qp->resp.mr, qp->resp.va, payload_addr(pkt), + data_len, to_mr_obj, NULL); if (err) { rc = RESPST_ERR_RKEY_VIOLATION; goto out; @@ -548,7 +548,7 @@ static enum resp_states process_atomic(struct rxe_qp *qp, u64 iova = atmeth_va(pkt); u64 *vaddr; enum resp_states ret; - struct rxe_mem *mr = qp->resp.mr; + struct rxe_mr *mr = qp->resp.mr; if (mr->state != RXE_MEM_STATE_VALID) { ret = RESPST_ERR_RKEY_VIOLATION; @@ -727,8 +727,8 @@ static enum resp_states read_reply(struct rxe_qp *qp, if (!skb) return RESPST_ERR_RNR; - err = rxe_mem_copy(res->read.mr, res->read.va, payload_addr(&ack_pkt), - payload, from_mem_obj, &icrc); + err = rxe_mr_copy(res->read.mr, res->read.va, payload_addr(&ack_pkt), + payload, from_mr_obj, &icrc); if (err) pr_err("Failed copying memory\n"); @@ -910,7 +910,7 @@ static enum resp_states do_complete(struct rxe_qp *qp, } if (pkt->mask & RXE_IETH_MASK) { - struct rxe_mem *rmr; + struct rxe_mr *rmr; wc->wc_flags |= IB_WC_WITH_INVALIDATE; wc->ex.invalidate_rkey = ieth_rkey(pkt); diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 1dbc69b86859..cac0f3f0c7c1 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -890,7 +890,7 @@ static struct ib_mr *rxe_get_dma_mr(struct ib_pd *ibpd, int access) { struct rxe_dev *rxe = to_rdev(ibpd->device); struct rxe_pd *pd = to_rpd(ibpd); - struct rxe_mem *mr; + struct rxe_mr *mr; mr = rxe_alloc(&rxe->mr_pool); if (!mr) @@ -898,7 +898,8 @@ static struct ib_mr *rxe_get_dma_mr(struct ib_pd *ibpd, int access) rxe_add_index(mr); rxe_add_ref(pd); - rxe_mem_init_dma(pd, access, mr); + + rxe_mr_init_dma(pd, access, mr); return &mr->ibmr; } @@ -912,7 +913,7 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, int err; struct rxe_dev *rxe = to_rdev(ibpd->device); struct rxe_pd *pd = to_rpd(ibpd); - struct rxe_mem *mr; + struct rxe_mr *mr; mr = rxe_alloc(&rxe->mr_pool); if (!mr) { @@ -924,7 +925,7 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, rxe_add_ref(pd); - err = rxe_mem_init_user(pd, start, length, iova, + err = rxe_mr_init_user(pd, start, length, iova, access, udata, mr); if (err) goto err3; @@ -941,7 +942,7 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, static int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) { - struct rxe_mem *mr = to_rmr(ibmr); + struct rxe_mr *mr = to_rmr(ibmr); mr->state = RXE_MEM_STATE_ZOMBIE; rxe_drop_ref(mr->pd); @@ -955,7 +956,7 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type, { struct rxe_dev *rxe = to_rdev(ibpd->device); struct rxe_pd *pd = to_rpd(ibpd); - struct rxe_mem *mr; + struct rxe_mr *mr; int err; if (mr_type != IB_MR_TYPE_MEM_REG) @@ -971,7 +972,7 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type, rxe_add_ref(pd); - err = rxe_mem_init_fast(pd, max_num_sg, mr); + err = rxe_mr_init_fast(pd, max_num_sg, mr); if (err) goto err2; @@ -987,7 +988,7 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type, static int rxe_set_page(struct ib_mr *ibmr, u64 addr) { - struct rxe_mem *mr = to_rmr(ibmr); + struct rxe_mr *mr = to_rmr(ibmr); struct rxe_map *map; struct rxe_phys_buf *buf; @@ -1007,7 +1008,7 @@ static int rxe_set_page(struct ib_mr *ibmr, u64 addr) static int rxe_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, unsigned int *sg_offset) { - struct rxe_mem *mr = to_rmr(ibmr); + struct rxe_mr *mr = to_rmr(ibmr); int n; mr->nbuf = 0; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index c664c7f36ab5..f3f1a58e894b 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -183,7 +183,7 @@ struct resp_res { struct sk_buff *skb; } atomic; struct { - struct rxe_mem *mr; + struct rxe_mr *mr; u64 va_org; u32 rkey; u32 length; @@ -210,7 +210,7 @@ struct rxe_resp_info { /* RDMA read / atomic only */ u64 va; - struct rxe_mem *mr; + struct rxe_mr *mr; u32 resid; u32 rkey; u32 length; @@ -289,14 +289,14 @@ struct rxe_qp { struct execute_work cleanup_work; }; -enum rxe_mem_state { +enum rxe_mr_state { RXE_MEM_STATE_ZOMBIE, RXE_MEM_STATE_INVALID, RXE_MEM_STATE_FREE, RXE_MEM_STATE_VALID, }; -enum rxe_mem_type { +enum rxe_mr_type { RXE_MEM_TYPE_NONE, RXE_MEM_TYPE_DMA, RXE_MEM_TYPE_MR, @@ -315,12 +315,9 @@ struct rxe_map { struct rxe_phys_buf buf[RXE_BUF_PER_MAP]; }; -struct rxe_mem { +struct rxe_mr { struct rxe_pool_entry pelem; - union { - struct ib_mr ibmr; - struct ib_mw ibmw; - }; + struct ib_mr ibmr; struct rxe_pd *pd; struct ib_umem *umem; @@ -328,8 +325,8 @@ struct rxe_mem { u32 lkey; u32 rkey; - enum rxe_mem_state state; - enum rxe_mem_type type; + enum rxe_mr_state state; + enum rxe_mr_type type; u64 va; u64 iova; size_t length; @@ -455,15 +452,15 @@ static inline struct rxe_cq *to_rcq(struct ib_cq *cq) return cq ? container_of(cq, struct rxe_cq, ibcq) : NULL; } -static inline struct rxe_mem *to_rmr(struct ib_mr *mr) +static inline struct rxe_mr *to_rmr(struct ib_mr *mr) { - return mr ? container_of(mr, struct rxe_mem, ibmr) : NULL; + return mr ? container_of(mr, struct rxe_mr, ibmr) : NULL; } -static inline struct rxe_mem *to_rmw(struct ib_mw *mw) -{ - return mw ? container_of(mw, struct rxe_mem, ibmw) : NULL; -} +//static inline struct rxe_mw *to_rmw(struct ib_mw *mw) +//{ + //return mw ? container_of(mw, struct rxe_mw, ibmw) : NULL; +//} int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name); From patchwork Sat Aug 15 04:58:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715827 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33B5A161F for ; Sat, 15 Aug 2020 22:07:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BF6920639 for ; Sat, 15 Aug 2020 22:07:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W9SVVxvW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbgHOWGl (ORCPT ); Sat, 15 Aug 2020 18:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728394AbgHOVus (ORCPT ); Sat, 15 Aug 2020 17:50:48 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D330C0612A4 for ; Fri, 14 Aug 2020 21:59:56 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id a65so9253212otc.8 for ; Fri, 14 Aug 2020 21:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S3qntwX4yEDo69n93Mf+8W7+8dALiakTimw2ltgpgv0=; b=W9SVVxvWSLNf6Mto2VLLU8l/ImQNwSQzKxvbQ84uCO77HPZBbCqGzxBa9iwao9btPo NixmMULeLw5vh3J24Zp53YOHAfqVz5M7+uLUIUFVHtq1pbdYPA0euMG5uH50le0PWsWf 5j//xFARDlyWXkbR+bRX2rFhSsVfytWTgYUuEXkfhK4rLTLfLRUYl3jQZmwViRhCbhDx L4LhWFYpeGsw6TjHMOnDQnwHsmft4Csu7xjuC3ShUonwf+c/ZiVwiboDSPePC4bHQgRN APW31kxhrmrOS9kJPzOluXmFNJG5GDtrsLs1OXevHffo35DbTIwNgSuGo16Cq2ZfLEiX G4lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S3qntwX4yEDo69n93Mf+8W7+8dALiakTimw2ltgpgv0=; b=YYIDmehNK+bIuvupUApb1wRR4RygFLmkgt2JMSy1Je9QkntzllGUaTyaUiM/I6LMwy sFWdiHHjqnYHcY0xebwpwAjl/q0RJXV9Gi1llxpOaTzwnjONqceB0kUA26ypXSaQqLLI 25jBs/+iT7izTuz2mn9TXHwjKVX2VYmwPyNbbo7SzHpkt2pPSHsaS0xb5algdkEw6e5A epe95hT3GS8pfMI0UX0O9tGb3mKGr2/hMQQcjHNvbRHjYPKxKzzjvZhuo+DM31LHu3r5 AxlNWFw9bafBsojN98YYG0DKY1RHkou5vW/jFSnFkDGryBFlMPEP1xamryfEKhrxgaPS 1Jhg== X-Gm-Message-State: AOAM533+f2Bk+PbCMQwyuYfSA1CKpl4+5LHYIDtNsSSUVV/Z4xdBv0QG edzGwhVHIvxUrUqBDBUgc13l7I7k/Gvb0g== X-Google-Smtp-Source: ABdhPJwv4ODi30u7z9YAX9oF7FVaFK/vAc8h5BDm0+XNYVanaE8pCTW8bKNUgAXbw/Z1MTscC8/URg== X-Received: by 2002:a05:6830:20d3:: with SMTP id z19mr4005766otq.189.1597467595881; Fri, 14 Aug 2020 21:59:55 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id 1sm2099128otc.44.2020.08.14.21.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 21:59:55 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 06/20] Added a basic rxe_mw struct Date: Fri, 14 Aug 2020 23:58:30 -0500 Message-Id: <20200815045912.8626-7-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Created the new basic rxe_mw structure. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_verbs.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index f3f1a58e894b..6a4486893b86 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -347,6 +347,20 @@ struct rxe_mr { struct rxe_map **map; }; +enum rxe_mw_state { + RXE_MW_STATE_INVALID, + RXE_MW_STATE_FREE, + RXE_MW_STATE_VALID, +}; + +struct rxe_mw { + struct rxe_pool_entry pelem; + struct ib_mw ibmw; + struct rxe_qp *qp; /* type 2B only */ + struct rxe_mem *mr; + enum rxe_mw_state state; +}; + struct rxe_mc_grp { struct rxe_pool_entry pelem; spinlock_t mcg_lock; /* guard group */ @@ -457,10 +471,10 @@ static inline struct rxe_mr *to_rmr(struct ib_mr *mr) return mr ? container_of(mr, struct rxe_mr, ibmr) : NULL; } -//static inline struct rxe_mw *to_rmw(struct ib_mw *mw) -//{ - //return mw ? container_of(mw, struct rxe_mw, ibmw) : NULL; -//} +static inline struct rxe_mw *to_rmw(struct ib_mw *mw) +{ + return mw ? container_of(mw, struct rxe_mw, ibmw) : NULL; +} int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name); From patchwork Sat Aug 15 04:58:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715761 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D7D8618 for ; Sat, 15 Aug 2020 22:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E2AD20781 for ; Sat, 15 Aug 2020 22:01:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RrK7fBzO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729375AbgHOWA5 (ORCPT ); Sat, 15 Aug 2020 18:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728745AbgHOVvd (ORCPT ); Sat, 15 Aug 2020 17:51:33 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1D78C0612A5 for ; Fri, 14 Aug 2020 21:59:58 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id o21so9985683oie.12 for ; Fri, 14 Aug 2020 21:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zHoZbA1tC1xepQAj2KQqj/5mC7x+Sm/ybnYQAjWhwzc=; b=RrK7fBzOw7k0JLH6TKSKXov550rKzh/2y+xULwZjkjWYuA51PJXukE6zZ/+LBkYcLO UR+qmMgtvbHxDSjXPZZvK8iuiXZw2KmLYTBuexfvKAG3H1HLb3ZOmnY9Lpa+gj8Ymhad 4z2EJrYg6x3I7/Tem27gVvUXE+OY6kmeJcN0evE6oKuYKpIzs6KFPqLvSIBnXd2TW7ir 4d2PW2WEdzg8c5WHCs8dQ5/6GuYT2pT2OPUfQDOqYv6qez2ZKfRoDD8hiLejCMbFo3Km sC1mQC9BGhAu8YKsgnmqfhEGd1I6eKekb28ZOEEGJSH1Avrw+MOFTf930vorGGLA1MwE 7kBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zHoZbA1tC1xepQAj2KQqj/5mC7x+Sm/ybnYQAjWhwzc=; b=OXu26F8ZyDjyhN9J6q2XRaqoEd0FOOZ4mWJwJG9Yt0EerKREQCBIbIIUsxlIkN+oL7 SiA4AIhw8OhvAgcPEIAGHUdAtOZHy8rYSnps31pNYEdbKOrBQoDWkWocESUdLIrnjeWH u3J4d7YOOuZI26IfY7MSHFlAM3MIcSxW7Fj6LBzqFgkl9xJae9bXyL/jnMU7EbbKGr8n Ixu00yT8lImcZqbfWKfXA1RjxLAAbyn402ivFL9kYLEawgj3WTCZMI1M1KtPVEIgFG4b WrPVxvCK368V5b6BiAjL1jaeAW59FXHRF38eYnwrST89F6zc/Y+tDh60EtCY3Iul6odK XQ/g== X-Gm-Message-State: AOAM531FdMgVjesLbYlzrtdRP3oo4Qr4D7AV+/MSxQKpJD8WF02fGrvM LcmyWLdHiSlrGsAoPWjrECq5R6r6f7FPew== X-Google-Smtp-Source: ABdhPJyYy5p/9KCqIM1Rd0LNw4Q5J8FJe1uDIhU/514wtjm83kewXjCu9mROKihnNrZhgahni8UFFQ== X-Received: by 2002:aca:eb84:: with SMTP id j126mr3564707oih.30.1597467597653; Fri, 14 Aug 2020 21:59:57 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id l128sm2194872oib.4.2020.08.14.21.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 21:59:57 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 07/20] Implemented functional alloc_mw and dealloc_mw APIs Date: Fri, 14 Aug 2020 23:58:31 -0500 Message-Id: <20200815045912.8626-8-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Created basic functional alloc_mw and dealloc_mw funnctions and changed the parameters in rxe_param.h so that MWs can actually be created. This change supported running user space test cases for these APIs. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe.c | 1 + drivers/infiniband/sw/rxe/rxe_mw.c | 57 +++++++++++++++++++++++++-- drivers/infiniband/sw/rxe/rxe_param.h | 10 +++-- drivers/infiniband/sw/rxe/rxe_pool.c | 2 +- drivers/infiniband/sw/rxe/rxe_verbs.h | 4 ++ 5 files changed, 65 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c index 907203afbd99..25bd25371f8e 100644 --- a/drivers/infiniband/sw/rxe/rxe.c +++ b/drivers/infiniband/sw/rxe/rxe.c @@ -79,6 +79,7 @@ static void rxe_init_device_param(struct rxe_dev *rxe) rxe->attr.max_cq = RXE_MAX_CQ; rxe->attr.max_cqe = (1 << RXE_MAX_LOG_CQE) - 1; rxe->attr.max_mr = RXE_MAX_MR; + rxe->attr.max_mw = RXE_MAX_MW; rxe->attr.max_pd = RXE_MAX_PD; rxe->attr.max_qp_rd_atom = RXE_MAX_QP_RD_ATOM; rxe->attr.max_res_rd_atom = RXE_MAX_RES_RD_ATOM; diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index 6139dc9d8dd8..50cd451751b8 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -35,15 +35,64 @@ #include "rxe.h" #include "rxe_loc.h" +/* place holder alloc and dealloc routines + * need to add cross references between qp and mr with mw + * and cleanup when one side is deleted. Enough to make + * verbs function correctly for now */ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, struct ib_udata *udata) { - pr_err_once("rxe_alloc_mw: not implemented\n"); - return ERR_PTR(-ENOSYS); + struct rxe_pd *pd = to_rpd(ibpd); + struct rxe_dev *rxe = to_rdev(ibpd->device); + struct rxe_mw *mw; + u32 rkey; + u8 key; + + if (unlikely((type != IB_MW_TYPE_1) && + (type != IB_MW_TYPE_2))) + return ERR_PTR(-EINVAL); + + rxe_add_ref(pd); + + mw = rxe_alloc(&rxe->mw_pool); + if (!mw) { + rxe_drop_ref(pd); + return ERR_PTR(-ENOMEM); + } + + /* pick a random key part as a starting point */ + rxe_add_index(mw); + get_random_bytes(&key, sizeof(key)); + rkey = mw->pelem.index << 8 | key; + + spin_lock_init(&mw->lock); + mw->qp = NULL; + mw->mr = NULL; + mw->addr = 0; + mw->length = 0; + mw->ibmw.pd = ibpd; + mw->ibmw.type = type; + mw->ibmw.rkey = rkey; + mw->state = (type == IB_MW_TYPE_2) ? + RXE_MW_STATE_FREE : + RXE_MW_STATE_VALID; + + return &mw->ibmw; } int rxe_dealloc_mw(struct ib_mw *ibmw) { - pr_err_once("rxe_dealloc_mw: not implemented\n"); - return -ENOSYS; + struct rxe_mw *mw = to_rmw(ibmw); + struct rxe_pd *pd = to_rpd(ibmw->pd); + unsigned long flags; + + spin_lock_irqsave(&mw->lock, flags); + mw->state = RXE_MW_STATE_INVALID; + spin_unlock_irqrestore(&mw->lock, flags); + + rxe_drop_ref(pd); + rxe_drop_index(mw); + rxe_drop_ref(mw); + + return 0; } diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h index 2f381aeafcb5..7f914dde98a7 100644 --- a/drivers/infiniband/sw/rxe/rxe_param.h +++ b/drivers/infiniband/sw/rxe/rxe_param.h @@ -85,7 +85,8 @@ enum rxe_device_param { RXE_MAX_SGE_RD = 32, RXE_MAX_CQ = 16384, RXE_MAX_LOG_CQE = 15, - RXE_MAX_MR = 256 * 1024, + RXE_MAX_MR = 0x40000, + RXE_MAX_MW = 0x40000, RXE_MAX_PD = 0x7ffc, RXE_MAX_QP_RD_ATOM = 128, RXE_MAX_RES_RD_ATOM = 0x3f000, @@ -114,9 +115,10 @@ enum rxe_device_param { RXE_MAX_SRQ_INDEX = 0x00040000, RXE_MIN_MR_INDEX = 0x00000001, - RXE_MAX_MR_INDEX = 0x00040000, - RXE_MIN_MW_INDEX = 0x00040001, - RXE_MAX_MW_INDEX = 0x00060000, + RXE_MAX_MR_INDEX = RXE_MIN_MR_INDEX + RXE_MAX_MR - 1, + RXE_MIN_MW_INDEX = RXE_MIN_MR_INDEX + RXE_MAX_MR, + RXE_MAX_MW_INDEX = RXE_MIN_MW_INDEX + RXE_MAX_MW - 1, + RXE_MAX_PKT_PER_ACK = 64, RXE_MAX_UNACKED_PSNS = 128, diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index ba002fed8051..32b86a9979e6 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -85,7 +85,7 @@ struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = { }, [RXE_TYPE_MW] = { .name = "rxe-mw", - .size = sizeof(struct rxe_mr), + .size = sizeof(struct rxe_mw), .flags = RXE_POOL_INDEX, .max_index = RXE_MAX_MW_INDEX, .min_index = RXE_MIN_MW_INDEX, diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index 6a4486893b86..ebe4157fbcdd 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -358,7 +358,11 @@ struct rxe_mw { struct ib_mw ibmw; struct rxe_qp *qp; /* type 2B only */ struct rxe_mem *mr; + spinlock_t lock; enum rxe_mw_state state; + u32 access; + u64 addr; + u64 length; }; struct rxe_mc_grp { From patchwork Sat Aug 15 04:58:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715723 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70D8914F6 for ; Sat, 15 Aug 2020 21:57:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D68920791 for ; Sat, 15 Aug 2020 21:57:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nMV+lPxC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729444AbgHOV44 (ORCPT ); Sat, 15 Aug 2020 17:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729013AbgHOVwK (ORCPT ); Sat, 15 Aug 2020 17:52:10 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79109C0612A6 for ; Fri, 14 Aug 2020 22:00:01 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id a24so10022941oia.6 for ; Fri, 14 Aug 2020 22:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EWlpvldw1UL3R7mZHWBRz4v8hVMQtua8A/LbwQdpQtw=; b=nMV+lPxCnAb50yklbrNOHp1mek+D13K3FIeNoIXhpF3m2SN4U3r1CVQfoM8ywFe6tQ Y3vXEZ/EpuG7nTBpljBwnMrQ5i49oy40NQoytiTm2Tb3A1KHaFfAMRcf6ZG7lFkSZVtA wkT0gi0jc9sB5FS7b5XVxWLn2V/IbhvPe1Ch+fnc2fnGIltKNvPAMHHSg7OG7coWJ15C c5I0JgNMUA2DIhveV5zUW+EyYsN8YkY8rBD1lHPTBeDfNa9ZoYSsEwUwkkNFX25/e97l 9KsMKgLzA9y82IRPLwLrpv6FWfJkWjel1tmE/E4ADlgQcOdz9twnE8PNLWPhcjQ7Z4K2 0tOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EWlpvldw1UL3R7mZHWBRz4v8hVMQtua8A/LbwQdpQtw=; b=XakRlxUzqGewsqF8F7LVq8JnMYHtaM/dq1RN2E33Izj+EopPJq+tLc+Xaz2xLp2exm aiF/ZlVxCIgdRQEfKAYbmD4KtluBcD5iD5S10DCGldJKHU1vIcdO9w+wfDKPrj2++Cgk 99bclZS+wbgqemZxsI+icgxjn52GHPl/LmAQOisrzHLTc5U2GHDuXA+rSMLtNYhPtkZo jbNYuJ1Vt7HBTlBJa6Yg4+WgRzYCyhvVANb1gO9UaUvoUqmRFw6I6jFUdjk+m6lmkLge moHJbv2ElR7q00x2q60ZDgY+mB1cKpy1422GsBs+RyJf7vXKPc0DWNWMiN2q6PzPGFzw 2uew== X-Gm-Message-State: AOAM530AfqmDMHY8Cxv1leSG4VhuK3GH37eFqGoFaDNTBosGFA7d1Xnb JXwpvh1k/PqE1Fnr+T1lGJ+YK8W+lncgHg== X-Google-Smtp-Source: ABdhPJwV7jecvFxf48NKvt3HqlwDnU2NSdL+e5Kx7363bf4aQlKIdaQ9uU0ynDsgn6Ez7K6r9BC4BQ== X-Received: by 2002:aca:5489:: with SMTP id i131mr3604274oib.157.1597467600499; Fri, 14 Aug 2020 22:00:00 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id 105sm2100438oti.13.2020.08.14.22.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:00 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 08/20] Added a stubbed bind_mw API. Date: Fri, 14 Aug 2020 23:58:32 -0500 Message-Id: <20200815045912.8626-9-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Added code to implement the path to rxe_bind_mw which is still a stub. Now the ibv_bind_mw verb can be called. Added bind_mw work requests to the opcodes file and added the new local operation to rxe_req. Changed WR_REG_MASK to WR_LOCAL_MASK since it is used to identify local operations. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 3 + drivers/infiniband/sw/rxe/rxe_loc.h | 1 + drivers/infiniband/sw/rxe/rxe_mw.c | 6 ++ drivers/infiniband/sw/rxe/rxe_opcode.c | 11 +++- drivers/infiniband/sw/rxe/rxe_req.c | 76 +++++++++++++++++++++----- drivers/infiniband/sw/rxe/rxe_task.h | 2 + 6 files changed, 84 insertions(+), 15 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index b9b8c4e115f4..caa8ad990337 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -130,6 +130,7 @@ static enum ib_wc_opcode wr_to_wc_opcode(enum ib_wr_opcode opcode) case IB_WR_RDMA_READ_WITH_INV: return IB_WC_RDMA_READ; case IB_WR_LOCAL_INV: return IB_WC_LOCAL_INV; case IB_WR_REG_MR: return IB_WC_REG_MR; + case IB_WR_BIND_MW: return IB_WC_BIND_MW; default: return 0xff; @@ -787,6 +788,8 @@ int rxe_completer(void *arg) */ WARN_ON_ONCE(skb); rxe_drop_ref(qp); + // TODO this seems plain backwards + // EAGAIN normally means call me again return -EAGAIN; done: diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 42375af68f48..02df9bf76d1a 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -140,6 +140,7 @@ int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, struct ib_udata *udata); int rxe_dealloc_mw(struct ib_mw *ibmw); +int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe); /* rxe_net.c */ void rxe_loopback(struct sk_buff *skb); diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index 50cd451751b8..230263c6d3e5 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -96,3 +96,9 @@ int rxe_dealloc_mw(struct ib_mw *ibmw) return 0; } + +int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) +{ + pr_err("rxe_bind_mw: not implemented\n"); + return -ENOSYS; +} diff --git a/drivers/infiniband/sw/rxe/rxe_opcode.c b/drivers/infiniband/sw/rxe/rxe_opcode.c index 4cf11063e0b5..d2f2092f0be5 100644 --- a/drivers/infiniband/sw/rxe/rxe_opcode.c +++ b/drivers/infiniband/sw/rxe/rxe_opcode.c @@ -114,13 +114,20 @@ struct rxe_wr_opcode_info rxe_wr_opcode_info[] = { [IB_WR_LOCAL_INV] = { .name = "IB_WR_LOCAL_INV", .mask = { - [IB_QPT_RC] = WR_REG_MASK, + [IB_QPT_RC] = WR_LOCAL_MASK, }, }, [IB_WR_REG_MR] = { .name = "IB_WR_REG_MR", .mask = { - [IB_QPT_RC] = WR_REG_MASK, + [IB_QPT_RC] = WR_LOCAL_MASK, + }, + }, + [IB_WR_BIND_MW] = { + .name = "IB_WR_BIND_MW", + .mask = { + [IB_QPT_RC] = WR_LOCAL_MASK, + [IB_QPT_UC] = WR_LOCAL_MASK, }, }, }; diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index c566372eebf8..b402eb82b402 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -586,6 +586,8 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, int rxe_requester(void *arg) { struct rxe_qp *qp = (struct rxe_qp *)arg; + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); + struct rxe_mr *rmr; struct rxe_pkt_info pkt; struct sk_buff *skb; struct rxe_send_wqe *wqe; @@ -596,9 +598,17 @@ int rxe_requester(void *arg) int ret; struct rxe_send_wqe rollback_wqe; u32 rollback_psn; + int entered; rxe_add_ref(qp); + // this code is 'guaranteed' to never be entered more + // than once. Check to make sure that this is the case + entered = atomic_inc_return(&qp->req.task.entered); + if (entered > 1) { + pr_err("rxe_requester: entered %d times\n", entered); + } + next_wqe: if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) goto exit; @@ -621,13 +631,11 @@ int rxe_requester(void *arg) if (unlikely(!wqe)) goto exit; - if (wqe->mask & WR_REG_MASK) { - if (wqe->wr.opcode == IB_WR_LOCAL_INV) { - struct rxe_dev *rxe = to_rdev(qp->ibqp.device); - struct rxe_mr *rmr; - + if (wqe->mask & WR_LOCAL_MASK) { + switch (wqe->wr.opcode) { + case IB_WR_LOCAL_INV: rmr = rxe_pool_get_index(&rxe->mr_pool, - wqe->wr.ex.invalidate_rkey >> 8); + wqe->wr.ex.invalidate_rkey >> 8); if (!rmr) { pr_err("No mr for key %#x\n", wqe->wr.ex.invalidate_rkey); @@ -635,13 +643,16 @@ int rxe_requester(void *arg) wqe->status = IB_WC_MW_BIND_ERR; goto exit; } + // TODO this can race with external access + // to the MR in rxe_resp unless you can know + // that all accesses are done rmr->state = RXE_MEM_STATE_FREE; rxe_drop_ref(rmr); wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; - } else if (wqe->wr.opcode == IB_WR_REG_MR) { - struct rxe_mr *rmr = to_rmr(wqe->wr.wr.reg.mr); - + break; + case IB_WR_REG_MR: + rmr = to_rmr(wqe->wr.wr.reg.mr); rmr->state = RXE_MEM_STATE_VALID; rmr->access = wqe->wr.wr.reg.access; rmr->lkey = wqe->wr.wr.reg.key; @@ -649,7 +660,21 @@ int rxe_requester(void *arg) rmr->iova = wqe->wr.wr.reg.mr->iova; wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; - } else { + break; + case IB_WR_BIND_MW: + ret = rxe_bind_mw(qp, wqe); + if (ret) { + wqe->state = wqe_state_done; + wqe->status = IB_WC_MW_BIND_ERR; + // TODO err: will change status + // probably should not + goto err; + } + wqe->state = wqe_state_done; + wqe->status = IB_WC_SUCCESS; + break; + default: + pr_err("rxe_requester: unexpected LOCAL WR opcode = %d\n", wqe->wr.opcode); goto exit; } if ((wqe->wr.send_flags & IB_SEND_SIGNALED) || @@ -704,9 +729,10 @@ int rxe_requester(void *arg) qp->req.wqe_index); wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; + // TODO why?? why not just treat the same as a + // successful wqe and go to next wqe? __rxe_do_task(&qp->comp.task); - rxe_drop_ref(qp); - return 0; + goto again; } payload = mtu; } @@ -750,12 +776,36 @@ int rxe_requester(void *arg) goto next_wqe; + // TODO this can be cleaned up err: + /* we come here if an error occured while processing + * a send wqe. The completer will put the qp in error + * state and no more wqes will be processed unless + * the qp is cleaned up and restarted. We do not want + * to be called again */ wqe->status = IB_WC_LOC_PROT_ERR; wqe->state = wqe_state_error; __rxe_do_task(&qp->comp.task); + ret = -EAGAIN; + goto done; exit: + /* we come here if either there are no more wqes in the send + * queue or we are blocked waiting for some resource or event. + * The current wqe will be restarted or new wqe started when + * there is work to do. */ + ret = -EAGAIN; + goto done; + +again: + /* we come here if we are done with the current wqe but want to + * get called again. Mostly we loop back to next wqe so should + * be all one way or the other */ + ret = 0; + goto done; + +done: + atomic_dec(&qp->req.task.entered); rxe_drop_ref(qp); - return -EAGAIN; + return ret; } diff --git a/drivers/infiniband/sw/rxe/rxe_task.h b/drivers/infiniband/sw/rxe/rxe_task.h index 08ff42d451c6..e33806c6f5a4 100644 --- a/drivers/infiniband/sw/rxe/rxe_task.h +++ b/drivers/infiniband/sw/rxe/rxe_task.h @@ -55,6 +55,8 @@ struct rxe_task { int ret; char name[16]; bool destroyed; + // debug code, delete me when done + atomic_t entered; }; /* From patchwork Sat Aug 15 04:58:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715729 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 432D4109B for ; Sat, 15 Aug 2020 21:57:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2720820791 for ; Sat, 15 Aug 2020 21:57:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MWkvOgJo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729152AbgHOV5V (ORCPT ); Sat, 15 Aug 2020 17:57:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728993AbgHOVwG (ORCPT ); Sat, 15 Aug 2020 17:52:06 -0400 Received: from mail-oo1-xc44.google.com (mail-oo1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 692EEC0612A7 for ; Fri, 14 Aug 2020 22:00:02 -0700 (PDT) Received: by mail-oo1-xc44.google.com with SMTP id u28so2336777ooe.12 for ; Fri, 14 Aug 2020 22:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L8saovlFiJ1HP/0sHmhYkqR6KqLV+uMKX5f2u2I1MM8=; b=MWkvOgJoAHcNJ49DlQ9JPTj3FivmsmyLvPY/wrJWTS/L2GRWdrwj9uoyEiBX3aGHP4 fQPRQ4t2aDJa5XAaxGwNSdTUw/4WW6YdnUTYjacQgbWL5h9YLTlkWtdpruaKrMBigiGx be1w3Xuxl3PqdtwXNVTZn0RaIgP6HqETgo9Ykvx0ioovv2Ua6W3QIxOFFu0XTy9d76hK 9Z8vsH8gZ0xnFazgaQMXNp/tBtUEqgqoDPZ74VNnhr6mVGD2KgbYs+1ucVhDm4LFlKc+ TaulRT0PQ9SgTFcfdGFZ89qYmMp4xJJoq9nFao4QMOxbR0s4MJqi/zfxYXC76dauGYca o1Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L8saovlFiJ1HP/0sHmhYkqR6KqLV+uMKX5f2u2I1MM8=; b=GQU2IP1oyzPxlHzI/Dn2SnmJmPGLwylhaZbs5Fle1ZlXdn+ejpll1iRn6WQjuQE2id +lHPonBmNi4HQx5aafO9oCR7rbcVHdfF5UB7oyfv36B8DsXM1A9Yh4NYeMZ4SCITD+9o //7gqeufJ0zqHazruw+NRKtgyUGGWp8rlAHFrChPRk2oHAucxikPdaHi6MPHOghWPlN1 IZp52tb5OXH6AEaH5sfBzCs6Z7xZeiWHUeqxBzHGoNgXyyx0RR5iEduGcCXvkdABfnYi R2iv5F/LJl1CP2yMowmBokpFv0XHs5v9kRU7iRBs3CITACVG6QnzslWUP6rPCZgIUEUa HQkA== X-Gm-Message-State: AOAM532WJG755TbQZsGjdZ1Ll24tOvdHQbgExXy9838bAEeqm0Dz8mMI kEuIcLnia/duYZ8K2h6KYY3j3sw1aF5LpA== X-Google-Smtp-Source: ABdhPJyzKIg8byscNSnEkJ3EEnrgqulf/E4lbGSF1XgJhQauIuNi7GeYySWSwVgSeaMh3Jjb46wa/g== X-Received: by 2002:a4a:aa0e:: with SMTP id x14mr3981071oom.27.1597467601416; Fri, 14 Aug 2020 22:00:01 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id z32sm2084160ota.53.2020.08.14.22.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:00 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 09/20] Fixed error logic in rxe_req.c Date: Fri, 14 Aug 2020 23:58:33 -0500 Message-Id: <20200815045912.8626-10-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Fixed returned status so each error return can set status. Now the bind_mw verb returns the correct (error) status in the wc. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_req.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index b402eb82b402..e0564d7b0ff7 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -740,12 +740,14 @@ int rxe_requester(void *arg) skb = init_req_packet(qp, wqe, opcode, payload, &pkt); if (unlikely(!skb)) { pr_err("qp#%d Failed allocating skb\n", qp_num(qp)); + wqe->status = IB_WC_LOC_PROT_ERR; goto err; } if (fill_packet(qp, wqe, &pkt, skb, payload)) { pr_debug("qp#%d Error during fill packet\n", qp_num(qp)); kfree_skb(skb); + wqe->status = IB_WC_LOC_PROT_ERR; goto err; } @@ -769,6 +771,7 @@ int rxe_requester(void *arg) goto exit; } + wqe->status = IB_WC_LOC_PROT_ERR; // ?? FIXME goto err; } @@ -783,8 +786,10 @@ int rxe_requester(void *arg) * state and no more wqes will be processed unless * the qp is cleaned up and restarted. We do not want * to be called again */ - wqe->status = IB_WC_LOC_PROT_ERR; wqe->state = wqe_state_error; + // ?? we want to force the qp into error state before + // anyone else has a chance to process another wqe but + // this could collide with an already running completer __rxe_do_task(&qp->comp.task); ret = -EAGAIN; goto done; From patchwork Sat Aug 15 04:58:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715691 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40AD314F6 for ; Sat, 15 Aug 2020 21:54:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23E362053B for ; Sat, 15 Aug 2020 21:54:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tspgzCQj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbgHOVyV (ORCPT ); Sat, 15 Aug 2020 17:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729111AbgHOVwg (ORCPT ); Sat, 15 Aug 2020 17:52:36 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FCABC0612A8 for ; Fri, 14 Aug 2020 22:00:03 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id y30so2348820ooj.3 for ; Fri, 14 Aug 2020 22:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F8ZzdTqBaA6hLa0ubKxz+8bLIrVTULNlByYnBjQyRg0=; b=tspgzCQjDE0lvZZChKO/Xko38qBhhIcQJjYKC+RE4ZBeVlUwkGn4T34OBeev8C8UNy 6t28w3kxKn+ItdWaJcHMl7wIPLbfv2ZvOaaretFTP2kOhHi3RTCK+NEG+P+Tz7anDNad WrOrDRoCFdaelaXyzEqA3qiM+H7Zd5q45rzahtzlTCtkxf+0zZk68a7edHyUMYUvBspO AuSb8+1CCTEnreaIT34PpPh/1KsWHIJ8m59pCBYdM7HfO/njbpr4rHLOzRsCRF1IUnu5 m+rfQTp1rrrbLi363cbkt/Riz5kl8Yt6yBnRmUr/qdN+LSpW7OednhEHih1n/Fmik6on HRQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F8ZzdTqBaA6hLa0ubKxz+8bLIrVTULNlByYnBjQyRg0=; b=J6UKjghlmlAWaPBxa/n8rQl1ig8d7Pu21nFr8PFryCfa38U5SOadgUp0VJkZ6/OxPb l8SDsM4qc/0exwWiuALV9argb/ozsAT65BpuXHmGdNShC5jjlKmrQHdXJiZ+/rypmQ39 f2vKQlfkrWL9Eon7fwSwTYW4n+/JDuVHvph8l+Xs8MgHKNx2780vEs3za5sJCzYfqtXs iA85VmQfJN5woLOTuDbvm+UGyfKcrlpKb10IjjA5ThKU5/JmFjSOFFVwmq7B7IzeSsqy 4UA6xWTRCXoE1CSLUdhp/NSQaXvl+7Ks5cjCME3InZePRQMCNnAYzCbKgipz/UWSV1oU h5EQ== X-Gm-Message-State: AOAM530M+xQUf4GX1KGiaMYjYlrtH/RKmBuoE6cFJSJqaF3GTsrcjzu3 HP6KHZshodepI4nCpdhC3ELwwHlzLVeX6A== X-Google-Smtp-Source: ABdhPJzOOphD+EfQrmuXIQhGnKcggrgjt2HbQh3iju8pIfmo8AIQTJ30xIdUwrEGrwzY6YQ6u+s8rw== X-Received: by 2002:a4a:3443:: with SMTP id n3mr4137494oof.30.1597467602299; Fri, 14 Aug 2020 22:00:02 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id r124sm2207636oib.22.2020.08.14.22.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:01 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 10/20] Extended pools to support both keys and indices Date: Fri, 14 Aug 2020 23:58:34 -0500 Message-Id: <20200815045912.8626-11-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Allowed both indices and keys to exist for objects in the pools. Previously you were limited to one or the other. This will support allowing the keys on MWs to change. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_pool.c | 73 ++++++++++++++-------------- drivers/infiniband/sw/rxe/rxe_pool.h | 32 +++++++----- 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index 32b86a9979e6..e157bf945175 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -177,18 +177,18 @@ static int rxe_pool_init_index(struct rxe_pool *pool, u32 max, u32 min) goto out; } - pool->max_index = max; - pool->min_index = min; + pool->index.max_index = max; + pool->index.min_index = min; size = BITS_TO_LONGS(max - min + 1) * sizeof(long); - pool->table = kmalloc(size, GFP_KERNEL); - if (!pool->table) { + pool->index.table = kmalloc(size, GFP_KERNEL); + if (!pool->index.table) { err = -ENOMEM; goto out; } - pool->table_size = size; - bitmap_zero(pool->table, max - min + 1); + pool->index.table_size = size; + bitmap_zero(pool->index.table, max - min + 1); out: return err; @@ -210,7 +210,8 @@ int rxe_pool_init( pool->max_elem = max_elem; pool->elem_size = ALIGN(size, RXE_POOL_ALIGN); pool->flags = rxe_type_info[type].flags; - pool->tree = RB_ROOT; + pool->index.tree = RB_ROOT; + pool->key.tree = RB_ROOT; pool->cleanup = rxe_type_info[type].cleanup; atomic_set(&pool->num_elem, 0); @@ -228,8 +229,8 @@ int rxe_pool_init( } if (rxe_type_info[type].flags & RXE_POOL_KEY) { - pool->key_offset = rxe_type_info[type].key_offset; - pool->key_size = rxe_type_info[type].key_size; + pool->key.key_offset = rxe_type_info[type].key_offset; + pool->key.key_size = rxe_type_info[type].key_size; } pool->state = RXE_POOL_STATE_VALID; @@ -243,7 +244,7 @@ static void rxe_pool_release(struct kref *kref) struct rxe_pool *pool = container_of(kref, struct rxe_pool, ref_cnt); pool->state = RXE_POOL_STATE_INVALID; - kfree(pool->table); + kfree(pool->index.table); } static void rxe_pool_put(struct rxe_pool *pool) @@ -268,27 +269,27 @@ void rxe_pool_cleanup(struct rxe_pool *pool) static u32 alloc_index(struct rxe_pool *pool) { u32 index; - u32 range = pool->max_index - pool->min_index + 1; + u32 range = pool->index.max_index - pool->index.min_index + 1; - index = find_next_zero_bit(pool->table, range, pool->last); + index = find_next_zero_bit(pool->index.table, range, pool->index.last); if (index >= range) - index = find_first_zero_bit(pool->table, range); + index = find_first_zero_bit(pool->index.table, range); WARN_ON_ONCE(index >= range); - set_bit(index, pool->table); - pool->last = index; - return index + pool->min_index; + set_bit(index, pool->index.table); + pool->index.last = index; + return index + pool->index.min_index; } static void insert_index(struct rxe_pool *pool, struct rxe_pool_entry *new) { - struct rb_node **link = &pool->tree.rb_node; + struct rb_node **link = &pool->index.tree.rb_node; struct rb_node *parent = NULL; struct rxe_pool_entry *elem; while (*link) { parent = *link; - elem = rb_entry(parent, struct rxe_pool_entry, node); + elem = rb_entry(parent, struct rxe_pool_entry, index_node); if (elem->index == new->index) { pr_warn("element already exists!\n"); @@ -301,25 +302,25 @@ static void insert_index(struct rxe_pool *pool, struct rxe_pool_entry *new) link = &(*link)->rb_right; } - rb_link_node(&new->node, parent, link); - rb_insert_color(&new->node, &pool->tree); + rb_link_node(&new->index_node, parent, link); + rb_insert_color(&new->index_node, &pool->index.tree); out: return; } static void insert_key(struct rxe_pool *pool, struct rxe_pool_entry *new) { - struct rb_node **link = &pool->tree.rb_node; + struct rb_node **link = &pool->key.tree.rb_node; struct rb_node *parent = NULL; struct rxe_pool_entry *elem; int cmp; while (*link) { parent = *link; - elem = rb_entry(parent, struct rxe_pool_entry, node); + elem = rb_entry(parent, struct rxe_pool_entry, key_node); - cmp = memcmp((u8 *)elem + pool->key_offset, - (u8 *)new + pool->key_offset, pool->key_size); + cmp = memcmp((u8 *)elem + pool->key.key_offset, + (u8 *)new + pool->key.key_offset, pool->key.key_size); if (cmp == 0) { pr_warn("key already exists!\n"); @@ -332,8 +333,8 @@ static void insert_key(struct rxe_pool *pool, struct rxe_pool_entry *new) link = &(*link)->rb_right; } - rb_link_node(&new->node, parent, link); - rb_insert_color(&new->node, &pool->tree); + rb_link_node(&new->key_node, parent, link); + rb_insert_color(&new->key_node, &pool->key.tree); out: return; } @@ -345,7 +346,7 @@ void rxe_add_key(void *arg, void *key) unsigned long flags; write_lock_irqsave(&pool->pool_lock, flags); - memcpy((u8 *)elem + pool->key_offset, key, pool->key_size); + memcpy((u8 *)elem + pool->key.key_offset, key, pool->key.key_size); insert_key(pool, elem); write_unlock_irqrestore(&pool->pool_lock, flags); } @@ -357,7 +358,7 @@ void rxe_drop_key(void *arg) unsigned long flags; write_lock_irqsave(&pool->pool_lock, flags); - rb_erase(&elem->node, &pool->tree); + rb_erase(&elem->key_node, &pool->key.tree); write_unlock_irqrestore(&pool->pool_lock, flags); } @@ -380,8 +381,8 @@ void rxe_drop_index(void *arg) unsigned long flags; write_lock_irqsave(&pool->pool_lock, flags); - clear_bit(elem->index - pool->min_index, pool->table); - rb_erase(&elem->node, &pool->tree); + clear_bit(elem->index - pool->index.min_index, pool->index.table); + rb_erase(&elem->index_node, &pool->index.tree); write_unlock_irqrestore(&pool->pool_lock, flags); } @@ -485,10 +486,10 @@ void *rxe_pool_get_index(struct rxe_pool *pool, u32 index) if (pool->state != RXE_POOL_STATE_VALID) goto out; - node = pool->tree.rb_node; + node = pool->index.tree.rb_node; while (node) { - elem = rb_entry(node, struct rxe_pool_entry, node); + elem = rb_entry(node, struct rxe_pool_entry, index_node); if (elem->index > index) node = node->rb_left; @@ -517,13 +518,13 @@ void *rxe_pool_get_key(struct rxe_pool *pool, void *key) if (pool->state != RXE_POOL_STATE_VALID) goto out; - node = pool->tree.rb_node; + node = pool->key.tree.rb_node; while (node) { - elem = rb_entry(node, struct rxe_pool_entry, node); + elem = rb_entry(node, struct rxe_pool_entry, key_node); - cmp = memcmp((u8 *)elem + pool->key_offset, - key, pool->key_size); + cmp = memcmp((u8 *)elem + pool->key.key_offset, + key, pool->key.key_size); if (cmp > 0) node = node->rb_left; diff --git a/drivers/infiniband/sw/rxe/rxe_pool.h b/drivers/infiniband/sw/rxe/rxe_pool.h index 2f2cff1cbe43..bd684df6d847 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.h +++ b/drivers/infiniband/sw/rxe/rxe_pool.h @@ -84,8 +84,11 @@ struct rxe_pool_entry { struct kref ref_cnt; struct list_head list; - /* only used if indexed or keyed */ - struct rb_node node; + /* only used if keyed */ + struct rb_node key_node; + + /* only used if indexed */ + struct rb_node index_node; u32 index; }; @@ -102,15 +105,22 @@ struct rxe_pool { unsigned int max_elem; atomic_t num_elem; - /* only used if indexed or keyed */ - struct rb_root tree; - unsigned long *table; - size_t table_size; - u32 max_index; - u32 min_index; - u32 last; - size_t key_offset; - size_t key_size; + /* only used if indexed */ + struct { + struct rb_root tree; + unsigned long *table; + size_t table_size; + u32 last; + u32 max_index; + u32 min_index; + } index; + + /* only used if keyed */ + struct { + struct rb_root tree; + size_t key_offset; + size_t key_size; + } key; }; /* initialize slab caches for managed objects */ From patchwork Sat Aug 15 04:58:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715747 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06FDA913 for ; Sat, 15 Aug 2020 21:58:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA164206B6 for ; Sat, 15 Aug 2020 21:58:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fo/bk+X7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728943AbgHOV6l (ORCPT ); Sat, 15 Aug 2020 17:58:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728945AbgHOVv4 (ORCPT ); Sat, 15 Aug 2020 17:51:56 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 316DFC0612A9 for ; Fri, 14 Aug 2020 22:00:04 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id v6so9231626ota.13 for ; Fri, 14 Aug 2020 22:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TNn6DgF0DEbAh+W686WloM5i48GDC+a89KgrtroiUmU=; b=fo/bk+X7uP/mRjG2CA40VzsFYEr/KbI3JoEPYa31jkdBMdalfUdTB8DDxB8q+dinaT VUqHdoLr6fNsmjGtkGKO3UU/jMLD+qQnWGvGfTBIjqClOcJ2qtuTTOrL941iZqhRCc9c /J6RhZ+i8vhl+n8ocH16TOr68hOovia45xiCducI7waInpplEttwgVG5R4/mZzPckOBu ftEjnUJ52OJ44CvmD1N7iRgolT1Q+q5sWf76/oEzl2bpJQCDPAKZs05ZRICpewMqshad As+dkQNa//Ya555Owcn++FJcgDN1outJJCHDchMIW92Mf3JRpAWN3MzKIC/CidjlDK9S GKiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TNn6DgF0DEbAh+W686WloM5i48GDC+a89KgrtroiUmU=; b=j0SVZzotrsi0CXjwpB7oC0o/afoE2YsgRKvijScF5T+KV4JIlDsusSnWTMscNZkQ7j q076PahlTWm1EPQbhDyON6eEYCV+yNBS5chp5FXeqsEyVDAuUzk8iXaABLMtVtfEZyM7 Ry+5ujV0B0/KtrXPm9qif9u5O7xWmhq6qca4/xH7mC2cbGpGKLBBoOvW3H83pmpv9rTk okMRAbaI0uhgiDA2FzLyOEHCNAEj7VVOM3cXzq5Qy5tdOglCVIUeSqfijAiklJaMx7cv Jh5uDktM/VM5gLmQCQZWic1ce9P4Ce/vh3a38OHUH+QcQHs6pLxz0iqJntU7NTZvyhhQ euxA== X-Gm-Message-State: AOAM530Wm8mcHMB1NhWno1uty930NasBYld+A84r7MCIvYwgmVRvQPOz y1xiCwSkKya2q1ItVJPv9ydbyj+nYTXppw== X-Google-Smtp-Source: ABdhPJz9kAuXAheuMALlKHzaXjUh11JgZPzXQw1lH1jKLWJ3vXGYBn1CocGrI0cMebdeDs/Lh31Unw== X-Received: by 2002:a9d:454d:: with SMTP id p13mr4021976oti.294.1597467603153; Fri, 14 Aug 2020 22:00:03 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id 3sm2194979oix.24.2020.08.14.22.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:02 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 11/20] Gave MRs and MWs both keys and indices Date: Fri, 14 Aug 2020 23:58:35 -0500 Message-Id: <20200815045912.8626-12-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Finished decoupling indices and keys for MW and MR objects. Now user space can refer to an object by index and kernel can lookup object with l/rkey. Tweaked the user/kernel ABI for rxe WQEs to use indices instead of rkeys to identify MWs and MRs. Type 1 MWs can now be bound with the ibv_bind_mw api. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_loc.h | 3 + drivers/infiniband/sw/rxe/rxe_mr.c | 55 +++++++----- drivers/infiniband/sw/rxe/rxe_mw.c | 116 ++++++++++++++++++++++---- drivers/infiniband/sw/rxe/rxe_pool.c | 30 ++++--- drivers/infiniband/sw/rxe/rxe_pool.h | 2 +- drivers/infiniband/sw/rxe/rxe_verbs.c | 28 ++++++- include/uapi/rdma/rdma_user_rxe.h | 34 +++++++- 7 files changed, 212 insertions(+), 56 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 02df9bf76d1a..87d323b1ba07 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -98,6 +98,8 @@ struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev, u32 size, int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); /* rxe_mr.c */ +void rxe_set_mr_lkey(struct rxe_mr *mr); + enum copy_direction { to_mr_obj, from_mr_obj, @@ -137,6 +139,7 @@ void rxe_mr_cleanup(struct rxe_pool_entry *arg); int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); /* rxe_mw.c */ +void rxe_set_mw_rkey(struct rxe_mw *mw); struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, struct ib_udata *udata); int rxe_dealloc_mw(struct ib_mw *ibmw); diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index 0606f04e1d18..ba4e33227633 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -34,6 +34,23 @@ #include "rxe.h" #include "rxe_loc.h" +/* choose a unique non zero random number for lkey */ +void rxe_set_mr_lkey(struct rxe_mr *mr) +{ + int ret; + u32 lkey; + +next_lkey: + get_random_bytes(&lkey, sizeof(lkey)); + lkey &= 0x7fffffff; + if (unlikely(lkey == 0)) + goto next_lkey; + ret = rxe_add_key(mr, &lkey); + if (unlikely(ret == -EAGAIN)) + goto next_lkey; +} + +#if 0 /* * lfsr (linear feedback shift register) with period 255 */ @@ -50,6 +67,7 @@ static u8 rxe_get_key(void) return key; } +#endif int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length) { @@ -76,16 +94,16 @@ int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length) static void rxe_mr_init(int access, struct rxe_mr *mr) { - u32 lkey = mr->pelem.index << 8 | rxe_get_key(); - u32 rkey = (access & IB_ACCESS_REMOTE) ? lkey : 0; + rxe_set_mr_lkey(mr); - if (mr->pelem.pool->type == RXE_TYPE_MR) { - mr->ibmr.lkey = lkey; - mr->ibmr.rkey = rkey; - } + if (access & IB_ACCESS_REMOTE) + mr->ibmr.rkey = mr->ibmr.lkey; + else + mr->ibmr.rkey = 0; - mr->lkey = lkey; - mr->rkey = rkey; + // TODO we shouldn't carry two copies + mr->lkey = mr->ibmr.lkey; + mr->rkey = mr->ibmr.rkey; mr->state = RXE_MEM_STATE_INVALID; mr->type = RXE_MEM_TYPE_NONE; mr->map_shift = ilog2(RXE_BUF_PER_MAP); @@ -155,9 +173,9 @@ void rxe_mr_init_dma(struct rxe_pd *pd, mr->type = RXE_MEM_TYPE_DMA; } -int rxe_mr_init_user(struct rxe_pd *pd, u64 start, - u64 length, u64 iova, int access, struct ib_udata *udata, - struct rxe_mr *mr) +int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, + u64 iova, int access, struct ib_udata *udata, + struct rxe_mr *mr) { struct rxe_map **map; struct rxe_phys_buf *buf = NULL; @@ -233,15 +251,15 @@ int rxe_mr_init_user(struct rxe_pd *pd, u64 start, return err; } -int rxe_mr_init_fast(struct rxe_pd *pd, - int max_pages, struct rxe_mr *mr) +int rxe_mr_init_fast(struct rxe_pd *pd, int max_pages, + struct rxe_mr *mr) { int err; rxe_mr_init(0, mr); /* In fastreg, we also set the rkey */ - mr->ibmr.rkey = mr->ibmr.lkey; + mr->rkey = mr->ibmr.rkey = mr->ibmr.lkey; err = rxe_mr_alloc(mr, max_pages); if (err) @@ -564,18 +582,17 @@ int advance_dma_data(struct rxe_dma_info *dma, unsigned int length) * (4) verify that mr state is valid */ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, - enum lookup_type type) + enum lookup_type type) { struct rxe_mr *mr; struct rxe_dev *rxe = to_rdev(pd->ibpd.device); - int index = key >> 8; - mr = rxe_pool_get_index(&rxe->mr_pool, index); + mr = rxe_pool_get_key(&rxe->mr_pool, &key); if (!mr) return NULL; - if (unlikely((type == lookup_local && mr->lkey != key) || - (type == lookup_remote && mr->rkey != key) || + if (unlikely((type == lookup_local && mr->ibmr.lkey != key) || + (type == lookup_remote && mr->ibmr.rkey != key) || mr->pd != pd || (access && !(access & mr->access)) || mr->state != RXE_MEM_STATE_VALID)) { diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index 230263c6d3e5..b45a04efa4a0 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -35,49 +35,95 @@ #include "rxe.h" #include "rxe_loc.h" +/* choose a unique non zero random number for rkey */ +void rxe_set_mw_rkey(struct rxe_mw *mw) +{ + int ret; + u32 rkey; + +next_rkey: + get_random_bytes(&rkey, sizeof(rkey)); + if (unlikely(rkey == 0)) + goto next_rkey; + rkey |= 0x80000000; + ret = rxe_add_key(mw, &rkey); + if (unlikely(ret == -EAGAIN)) + goto next_rkey; +} + /* place holder alloc and dealloc routines - * need to add cross references between qp and mr with mw + * TODO add cross references between qp and mr with mw * and cleanup when one side is deleted. Enough to make * verbs function correctly for now */ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, struct ib_udata *udata) { + int ret; + struct rxe_mw *mw; struct rxe_pd *pd = to_rpd(ibpd); struct rxe_dev *rxe = to_rdev(ibpd->device); - struct rxe_mw *mw; - u32 rkey; - u8 key; + struct rxe_alloc_mw_resp __user *uresp; + + if (udata) { + if (udata->outlen < sizeof(*uresp)) { + ret = -EINVAL; + goto err1; + } + } if (unlikely((type != IB_MW_TYPE_1) && - (type != IB_MW_TYPE_2))) - return ERR_PTR(-EINVAL); + (type != IB_MW_TYPE_2))) { + ret = -EINVAL; + goto err1; + } rxe_add_ref(pd); mw = rxe_alloc(&rxe->mw_pool); if (!mw) { rxe_drop_ref(pd); - return ERR_PTR(-ENOMEM); + ret = -ENOMEM; + goto err1; } - /* pick a random key part as a starting point */ rxe_add_index(mw); - get_random_bytes(&key, sizeof(key)); - rkey = mw->pelem.index << 8 | key; + rxe_set_mw_rkey(mw); + + pr_info("rxe_alloc_mw: index = 0x%08x, rkey = 0x%08x\n", + mw->pelem.index, mw->ibmw.rkey); spin_lock_init(&mw->lock); + + if (type == IB_MW_TYPE_2) { + mw->state = RXE_MW_STATE_FREE; + } else { + mw->state = RXE_MW_STATE_VALID; + } + mw->qp = NULL; mw->mr = NULL; mw->addr = 0; mw->length = 0; mw->ibmw.pd = ibpd; mw->ibmw.type = type; - mw->ibmw.rkey = rkey; - mw->state = (type == IB_MW_TYPE_2) ? - RXE_MW_STATE_FREE : - RXE_MW_STATE_VALID; + + if (udata) { + uresp = udata->outbuf; + if (copy_to_user(&uresp->index, &mw->pelem.index, + sizeof(u32))) { + ret = -EFAULT; + goto err2; + } + } return &mw->ibmw; +err2: + rxe_drop_key(mw); + rxe_drop_index(mw); + rxe_drop_ref(mw); + rxe_drop_ref(pd); +err1: + return ERR_PTR(ret); } int rxe_dealloc_mw(struct ib_mw *ibmw) @@ -90,8 +136,9 @@ int rxe_dealloc_mw(struct ib_mw *ibmw) mw->state = RXE_MW_STATE_INVALID; spin_unlock_irqrestore(&mw->lock, flags); - rxe_drop_ref(pd); + rxe_drop_key(mw); rxe_drop_index(mw); + rxe_drop_ref(pd); rxe_drop_ref(mw); return 0; @@ -99,6 +146,41 @@ int rxe_dealloc_mw(struct ib_mw *ibmw) int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) { - pr_err("rxe_bind_mw: not implemented\n"); - return -ENOSYS; + struct rxe_mw *mw; + struct rxe_mr *mr; + + pr_info("rxe_bind_mw: called\n"); + + if (qp->is_user) { + } else { + mw = to_rmw(wqe->wr.wr.kmw.ibmw); + mr = to_rmr(wqe->wr.wr.kmw.ibmr); + } + +#if 0 + wqe->wr.wr.bind_mw + __aligned_u64 addr; + __aligned_u64 length; + __u32 mr_rkey; + __u32 mw_rkey; + __u32 rkey; + __u32 access; + + mw + struct rxe_pool_entry pelem; // alloc + struct ib_mw ibmw; // alloc + struct ib_device *device; // alloc + struct ib_pd *pd; // alloc + struct ib_uobject *uobject; // alloc + u32 rkey; + enum ib_mw_type type; // alloc + struct rxe_qp *qp; // bind + struct rxe_mem *mr; // bind + spinlock_t lock; // alloc + enum rxe_mw_state state; // all + u32 access; // bind + u64 addr; // bind + u64 length; // bind +#endif + return 0; } diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index e157bf945175..35e9646e104c 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -34,10 +34,6 @@ #include "rxe.h" #include "rxe_loc.h" -/* info about object pools - * note that mr and mw share a single index space - * so that one can map an lkey to the correct type of object - */ struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = { [RXE_TYPE_UC] = { .name = "rxe-uc", @@ -79,16 +75,22 @@ struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = { .name = "rxe-mr", .size = sizeof(struct rxe_mr), .cleanup = rxe_mr_cleanup, - .flags = RXE_POOL_INDEX, + .flags = RXE_POOL_INDEX + | RXE_POOL_KEY, .max_index = RXE_MAX_MR_INDEX, .min_index = RXE_MIN_MR_INDEX, + .key_offset = offsetof(struct rxe_mr, ibmr.lkey), + .key_size = sizeof(u32), }, [RXE_TYPE_MW] = { .name = "rxe-mw", .size = sizeof(struct rxe_mw), - .flags = RXE_POOL_INDEX, + .flags = RXE_POOL_INDEX + | RXE_POOL_KEY, .max_index = RXE_MAX_MW_INDEX, .min_index = RXE_MIN_MW_INDEX, + .key_offset = offsetof(struct rxe_mw, ibmw.rkey), + .key_size = sizeof(u32), }, [RXE_TYPE_MC_GRP] = { .name = "rxe-mc_grp", @@ -308,8 +310,9 @@ static void insert_index(struct rxe_pool *pool, struct rxe_pool_entry *new) return; } -static void insert_key(struct rxe_pool *pool, struct rxe_pool_entry *new) +static int insert_key(struct rxe_pool *pool, struct rxe_pool_entry *new) { + int ret; struct rb_node **link = &pool->key.tree.rb_node; struct rb_node *parent = NULL; struct rxe_pool_entry *elem; @@ -323,7 +326,7 @@ static void insert_key(struct rxe_pool *pool, struct rxe_pool_entry *new) (u8 *)new + pool->key.key_offset, pool->key.key_size); if (cmp == 0) { - pr_warn("key already exists!\n"); + ret = -EAGAIN; goto out; } @@ -335,20 +338,25 @@ static void insert_key(struct rxe_pool *pool, struct rxe_pool_entry *new) rb_link_node(&new->key_node, parent, link); rb_insert_color(&new->key_node, &pool->key.tree); + + ret = 0; out: - return; + return ret; } -void rxe_add_key(void *arg, void *key) +int rxe_add_key(void *arg, void *key) { + int ret; struct rxe_pool_entry *elem = arg; struct rxe_pool *pool = elem->pool; unsigned long flags; write_lock_irqsave(&pool->pool_lock, flags); memcpy((u8 *)elem + pool->key.key_offset, key, pool->key.key_size); - insert_key(pool, elem); + ret = insert_key(pool, elem); write_unlock_irqrestore(&pool->pool_lock, flags); + + return ret; } void rxe_drop_key(void *arg) diff --git a/drivers/infiniband/sw/rxe/rxe_pool.h b/drivers/infiniband/sw/rxe/rxe_pool.h index bd684df6d847..0ba811456f79 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.h +++ b/drivers/infiniband/sw/rxe/rxe_pool.h @@ -156,7 +156,7 @@ void rxe_drop_index(void *elem); /* assign a key to a keyed object and insert object into * pool's rb tree */ -void rxe_add_key(void *elem, void *key); +int rxe_add_key(void *elem, void *key); /* remove elem from rb tree */ void rxe_drop_key(void *elem); diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index cac0f3f0c7c1..29191cacfc56 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -911,9 +911,20 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, int access, struct ib_udata *udata) { int err; + struct rxe_mr *mr; struct rxe_dev *rxe = to_rdev(ibpd->device); struct rxe_pd *pd = to_rpd(ibpd); - struct rxe_mr *mr; + struct rxe_reg_mr_resp __user *uresp = NULL; + + if (udata) { + if (udata->outlen < sizeof(*uresp)) { + err = -EINVAL; + goto err2; + } + uresp = udata->outbuf; + } + + rxe_add_ref(pd); mr = rxe_alloc(&rxe->mr_pool); if (!mr) { @@ -923,19 +934,28 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, rxe_add_index(mr); - rxe_add_ref(pd); - err = rxe_mr_init_user(pd, start, length, iova, access, udata, mr); if (err) goto err3; + pr_info("rxe_reg_user_mr: index = 0x%08x, rkey = 0x%08x\n", + mr->pelem.index, mr->ibmr.rkey); + + if (uresp) { + if (copy_to_user(&uresp->index, &mr->pelem.index, + sizeof(uresp->index))) { + err = -EFAULT; + goto err3; + } + } + return &mr->ibmr; err3: - rxe_drop_ref(pd); rxe_drop_index(mr); rxe_drop_ref(mr); + rxe_drop_ref(pd); err2: return ERR_PTR(err); } diff --git a/include/uapi/rdma/rdma_user_rxe.h b/include/uapi/rdma/rdma_user_rxe.h index f88867d85c3f..c1e84cd69c37 100644 --- a/include/uapi/rdma/rdma_user_rxe.h +++ b/include/uapi/rdma/rdma_user_rxe.h @@ -96,12 +96,28 @@ struct rxe_send_wr { struct { __aligned_u64 addr; __aligned_u64 length; - __u32 mr_rkey; - __u32 mw_rkey; + __u32 mr_index; + __u32 pad1; + __u32 mw_index; + __u32 pad2; __u32 rkey; __u32 access; - } bind_mw; - /* reg is only used by the kernel and is not part of the uapi */ + } umw; + /* below are only used by the kernel */ + struct { + __aligned_u64 addr; + __aligned_u64 length; + union { + struct ib_mr *ibmr; + __aligned_u64 reserved1; + }; + union { + struct ib_mw *ibmw; + __aligned_u64 reserved2; + }; + __u32 rkey; + __u32 access; + } kmw; struct { union { struct ib_mr *mr; @@ -183,4 +199,14 @@ struct rxe_modify_srq_cmd { __aligned_u64 mmap_info_addr; }; +struct rxe_reg_mr_resp { + __u32 index; + __u32 reserved; +}; + +struct rxe_alloc_mw_resp { + __u32 index; + __u32 reserved; +}; + #endif /* RDMA_USER_RXE_H */ From patchwork Sat Aug 15 04:58:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715821 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40F8D109B for ; Sat, 15 Aug 2020 22:06:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DEB620639 for ; Sat, 15 Aug 2020 22:06:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SyOBAWcq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728417AbgHOWGh (ORCPT ); Sat, 15 Aug 2020 18:06:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbgHOVut (ORCPT ); Sat, 15 Aug 2020 17:50:49 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BB38C0612B0 for ; Fri, 14 Aug 2020 22:00:04 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id n128so6180020oif.0 for ; Fri, 14 Aug 2020 22:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Dx1W7Pc1FkT5qtletWAtG1Oo4D9aKHZMfp3GhhOA64=; b=SyOBAWcqHY0EydWOuYRVcWLjGnBOiDFvK7VvdVIbcq7Ld5apSDSNRUkNZeU4G6XLlK ODq7hl/sgqrelIyGPiAqUagxExZPpSQLYLd1qPM+6KHzgADJEv+4T4WNenxrjob4Qi4C P8VTKRnZSPu3q6g0tzdfzPn9QCUtOWvVht0z3Zo8Xxn9nEneRd617WKb+rOS8fhpD7bo xGlxTpM49JfCAWbE3HB5Vqj0csjha8Ju6rHFS8P2PsC6n3M28zj+wkFW5k840HLrgnqS FkWDA4vS8BC4RBGgMHuJwYx1gNwUSobPxrJWXeIRi1TZFXe+DAY+4I6+AEJjBnDPZYAq yiVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Dx1W7Pc1FkT5qtletWAtG1Oo4D9aKHZMfp3GhhOA64=; b=E5gUdXxKiNxLveCkrHbypUf1DLgMq7vmYCni1skikHuUgMv7dRDdfkb1yq/05gWX7W 8FqOxK4gmP4Z073OkTptkEeaFkstLiqInouS4wzgh4M/96bQQf2ueWSwcP6Nj4lXC7Bd eRcWCOk/6uLkFpgJYJfIjxCG5hwczrlfRER9OHV5ZMB0xR+0WpZSO9aFp9S3UkeqPb09 L+Snqjh1VPOB/vPqn8kcjVdnwLk0/a+xXIl0+6uI3ekTOzPIvz+0RdjZehaqLdrZYGkt k07pfcKFzf8yrUh+g1C1o8zZfIFw3DUYR68WNWCgY4cWnnXymVY5apGIG/kdydyvfXcv 2yZA== X-Gm-Message-State: AOAM530cXmXR1xUVRHAqr9wzUkUR7GwiIqVclXRUfgy4IDaLcR39adA4 7P+BYMdbjWtyXLxfLT8v8Y9yikv23ZkNwQ== X-Google-Smtp-Source: ABdhPJyNQKDo/i+Efoa30CKCHJ+7RkdksqKaB4eA/VUylyr2uuuAiwr+Rst6y91gCpYMK+1+u1FC+Q== X-Received: by 2002:aca:aa13:: with SMTP id t19mr3553194oie.59.1597467603875; Fri, 14 Aug 2020 22:00:03 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id l17sm2100611otp.70.2020.08.14.22.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:03 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 12/20] Cleanup after git pull Date: Fri, 14 Aug 2020 23:58:36 -0500 Message-Id: <20200815045912.8626-13-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org An experiment with rebase made a tiny mess which I cleaned up. This one slipped through. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_loc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 87d323b1ba07..03eb74947d62 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -105,7 +105,7 @@ enum copy_direction { from_mr_obj, }; -int rxe_mr_init_dma(struct rxe_pd *pd, +void rxe_mr_init_dma(struct rxe_pd *pd, int access, struct rxe_mr *mr); int rxe_mr_init_user(struct rxe_pd *pd, u64 start, From patchwork Sat Aug 15 04:58:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715745 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36E42913 for ; Sat, 15 Aug 2020 21:58:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B70022BED for ; Sat, 15 Aug 2020 21:58:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LeFI7B6I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729048AbgHOV6m (ORCPT ); Sat, 15 Aug 2020 17:58:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728944AbgHOVv4 (ORCPT ); Sat, 15 Aug 2020 17:51:56 -0400 Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39E71C0612B2 for ; Fri, 14 Aug 2020 22:00:06 -0700 (PDT) Received: by mail-oo1-xc36.google.com with SMTP id x1so2353074oox.6 for ; Fri, 14 Aug 2020 22:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FNH0D3OCw0/3bR6FAwuz4sebVNlKM6WDdrOt2LSSOsg=; b=LeFI7B6Ip3x5YI3AyISR06GrcgrT/NOVdB76HPCbIblJoVdDOP1N0fOLaveZ9RnxlY nkX1y/30Cq0KLlou8hQm9y9bdZXfn+eNhvVZcBiNaX6vY1Tu+MfhFlMEnCGKRUHXa3ZX QeEceUwwbLWkccHxY6OHn3Rm59It08TmdsLJyneJ+lLqEl/f2gG6RzJM++0O+FpX4Sri 68oTaNhonhBB0wSKUUcXdhVYn6QdwAeIC5hI16d3ffUz5pjr+lo77Abc1QKb8bDhvDWA gSMzq7nm0P9H53/IRbPFK97XdNIU5KlZiRT9A8PCJHL90/8GnqXrWf6i48WuhjaracFf L3qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FNH0D3OCw0/3bR6FAwuz4sebVNlKM6WDdrOt2LSSOsg=; b=pR/WVx80HhqR/Rk05zj4WJUPrMT8MeveixSojUDmtV7OvuvA2hKiY0xUwFp4xuO9kP sqs+/G+jqCLWnzuyZ/3Uc6a+4RC+2S0T787+m1c8E46i05z1scV+zT5aVzLRnw8WfArm bTa5CEAnP0TiywVQovLBpZvswjjs/NoktzU4FCe9iZKgMWKQd+Dr7sRaHfGFON1wGgQR due+Zq6WE3Ri5zYOuThOZ18qocJ26HpLj2XREe7VQiaIHaZlrPET+JAbyrTfEgybmIIG 6iXFytHJ7eB72310/2UO53KU7GMrTmjnSzFvc28iJMyY8FMNaiuiebI8iIkpXG9eRgDK hsEQ== X-Gm-Message-State: AOAM531/knWT2RhXRvqDxB/qJC4rAGFnWlX63wctCHx5BBOGuCfkx+Ah 742MVlh0gm0F5V4ngEevr7knn2n4WEY1PQ== X-Google-Smtp-Source: ABdhPJyOQYYBroprosQYzmaXlqedECDPHwC3GxC70g3ssoTrksmLbQbOzuDReJ24rzqOc4Q+bWcacQ== X-Received: by 2002:a4a:9cd6:: with SMTP id d22mr4152903ook.0.1597467604685; Fri, 14 Aug 2020 22:00:04 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id j2sm2120889ooo.6.2020.08.14.22.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:04 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 13/20] add debug print statements Date: Fri, 14 Aug 2020 23:58:37 -0500 Message-Id: <20200815045912.8626-14-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Added some debug prints to help out. They will go away later. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_verbs.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 29191cacfc56..b91364ba2c68 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -172,6 +172,8 @@ static int rxe_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) struct rxe_dev *rxe = to_rdev(ibpd->device); struct rxe_pd *pd = to_rpd(ibpd); + pr_info("rxe_alloc_pd: called\n"); + return rxe_add_to_pool(&rxe->pd_pool, &pd->pelem); } @@ -179,6 +181,8 @@ static void rxe_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) { struct rxe_pd *pd = to_rpd(ibpd); + pr_info("rxe_dealloc_pd: called\n"); + rxe_drop_ref(pd); } @@ -410,6 +414,8 @@ static struct ib_qp *rxe_create_qp(struct ib_pd *ibpd, struct rxe_qp *qp; struct rxe_create_qp_resp __user *uresp = NULL; + pr_info("rxe_create_qp: called\n"); + if (udata) { if (udata->outlen < sizeof(*uresp)) return ERR_PTR(-EINVAL); @@ -457,6 +463,8 @@ static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, struct rxe_dev *rxe = to_rdev(ibqp->device); struct rxe_qp *qp = to_rqp(ibqp); + pr_info("rxe_modify_qp: called\n"); + err = rxe_qp_chk_attr(rxe, qp, attr, mask); if (err) goto err1; @@ -476,6 +484,8 @@ static int rxe_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, { struct rxe_qp *qp = to_rqp(ibqp); + pr_info("rxe_query_qp: called\n"); + rxe_qp_to_init(qp, init); rxe_qp_to_attr(qp, attr, mask); @@ -486,6 +496,8 @@ static int rxe_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) { struct rxe_qp *qp = to_rqp(ibqp); + pr_info("rxe_destroy_qp: called\n"); + rxe_qp_destroy(qp); rxe_drop_index(qp); rxe_drop_ref(qp); @@ -782,6 +794,8 @@ static int rxe_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, struct rxe_cq *cq = to_rcq(ibcq); struct rxe_create_cq_resp __user *uresp = NULL; + pr_info("rxe_create_cq: called\n"); + if (udata) { if (udata->outlen < sizeof(*uresp)) return -EINVAL; @@ -807,6 +821,8 @@ static void rxe_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) { struct rxe_cq *cq = to_rcq(ibcq); + pr_info("rxe_destroy_cq: called\n"); + rxe_cq_disable(cq); rxe_drop_ref(cq); @@ -846,6 +862,8 @@ static int rxe_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) struct rxe_cqe *cqe; unsigned long flags; + pr_info("rxe_poll_cq: called\n"); + spin_lock_irqsave(&cq->cq_lock, flags); for (i = 0; i < num_entries; i++) { cqe = queue_head(cq->queue); @@ -916,6 +934,8 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, struct rxe_pd *pd = to_rpd(ibpd); struct rxe_reg_mr_resp __user *uresp = NULL; + pr_info("rxe_reg_user_mr: called\n"); + if (udata) { if (udata->outlen < sizeof(*uresp)) { err = -EINVAL; @@ -939,9 +959,6 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, if (err) goto err3; - pr_info("rxe_reg_user_mr: index = 0x%08x, rkey = 0x%08x\n", - mr->pelem.index, mr->ibmr.rkey); - if (uresp) { if (copy_to_user(&uresp->index, &mr->pelem.index, sizeof(uresp->index))) { @@ -964,6 +981,8 @@ static int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) { struct rxe_mr *mr = to_rmr(ibmr); + pr_info("rxe_dereg_user_mr: called\n"); + mr->state = RXE_MEM_STATE_ZOMBIE; rxe_drop_ref(mr->pd); rxe_drop_index(mr); From patchwork Sat Aug 15 04:58:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715657 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FBD4109B for ; Sat, 15 Aug 2020 21:51:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 285242053B for ; Sat, 15 Aug 2020 21:51:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BU8x6KkN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728758AbgHOVvZ (ORCPT ); Sat, 15 Aug 2020 17:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728706AbgHOVvW (ORCPT ); Sat, 15 Aug 2020 17:51:22 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E7DDC0612B1 for ; Fri, 14 Aug 2020 22:00:06 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id h16so9263931oti.7 for ; Fri, 14 Aug 2020 22:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ayZBf+VDszLARBRcSdBoT4Z20ZJ+0ZRAbW3EEZQYw4=; b=BU8x6KkNDaowY6cbAnVEsnCyMyLT9/G8wa36pVfqyVmrLDBCDnQUE/hJRv/Y9fY49j 7HcmVDNBhGlFegyqmW1qzsFujoRqgtM1Q9G5vf4o/0yYBha3y2ihE3TqATP1cDASFgEc gqUQE2zRVeiEFcCzdnzavVgAVZDNTYLuKs1mpZtE/Ie3+jZkh9fasObySFz070NsHsl2 9CTubjeIxoCDeTTIxMnDx3J9FQ1gx1bcU4XwpsF89JqkcUzA8oTkkrBspXL/Uv3JgZ/V os4McXzUuiNaBQKDD1EW1GFAZSxisa0NUj3CNTBbEc9gDPm5VgStyF8DgWqDQCLCya2b ZjmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ayZBf+VDszLARBRcSdBoT4Z20ZJ+0ZRAbW3EEZQYw4=; b=PVwJJ83E3C1au0gphQdtuQE4sooIh9+wRB3PWLnO+EIJo5FN0IIwreHjrgKXrkQUsK rIqzt+gDlCvchXzWMTyHjpv7DHiMOEKplRLmTYVxDPozx9xz/cJs18hCzxvwYpboMH8o QOYBpv4X/5Y1537qiVok+2CV4/B/N0Ircn6HhSb0wrFP/44rOGpAG73U9z49Bue7XBeN cRDLyZCqSANsAERWKnjcd8XY9R45jkdfBipC0MZHGKbhzhEG6K6JQu4cksOrJATcm8ZQ yQBRD6NDgQkbHtIfpIhmkWn0kqI9c3m2gOA3xVCSug+bWnP5d+nBIcUBp1Ya0ZWRIeVR iWxg== X-Gm-Message-State: AOAM531CN0tehaFiOZ+jfbb6IhqaSZ7Iq0qtskg/o1jLk8dqP64zh4m2 +dFbqym527Kjxl+ugVadVTFZmdZJPz8FuQ== X-Google-Smtp-Source: ABdhPJznVVUeb5czsQMypc2sil6PNz+Rx+s/TWjrM0tGUF59WnArDAdQ/vA9i8Q+sGGBS1TIynbisw== X-Received: by 2002:a9d:7f89:: with SMTP id t9mr4399095otp.278.1597467605392; Fri, 14 Aug 2020 22:00:05 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id m8sm2195715oim.23.2020.08.14.22.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:05 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 14/20] Addresses an issue with hardened user copy Date: Fri, 14 Aug 2020 23:58:38 -0500 Message-Id: <20200815045912.8626-15-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Copying to user space from the stack instead of slab cache cured a kernel oops that was toubling me.A Signed-off-by: Bob Pearson --- drivers/infiniband/core/uverbs_std_types_qp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/uverbs_std_types_qp.c b/drivers/infiniband/core/uverbs_std_types_qp.c index 3bf8dcdfe7eb..2f8b14003b95 100644 --- a/drivers/infiniband/core/uverbs_std_types_qp.c +++ b/drivers/infiniband/core/uverbs_std_types_qp.c @@ -98,6 +98,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)( struct ib_device *device; u64 user_handle; int ret; + int qp_num; ret = uverbs_copy_from_or_zero(&cap, attrs, UVERBS_ATTR_CREATE_QP_CAP); @@ -293,9 +294,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)( if (ret) return ret; + /* copy from stack to avoid whitelisting issues */ + qp_num = qp->qp_num; ret = uverbs_copy_to(attrs, UVERBS_ATTR_CREATE_QP_RESP_QP_NUM, - &qp->qp_num, - sizeof(qp->qp_num)); + &qp_num, sizeof(qp_num)); return ret; err_put: From patchwork Sat Aug 15 04:58:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715759 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7309109B for ; Sat, 15 Aug 2020 22:00:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85591205CB for ; Sat, 15 Aug 2020 22:00:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZXgoXIme" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729115AbgHOWA5 (ORCPT ); Sat, 15 Aug 2020 18:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728816AbgHOVve (ORCPT ); Sat, 15 Aug 2020 17:51:34 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD586C061242 for ; Fri, 14 Aug 2020 22:00:06 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id l204so10017011oib.3 for ; Fri, 14 Aug 2020 22:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v0Hc1+OSuo7YChLGC59HHK+vRdciDCQlRnhy6pM56xE=; b=ZXgoXIme/3P+ylcI3FVGR4IPJRdwnsyNpL/Lc/kNivsiL1RjPklXJrgbnL29ITmnLz yrW1mc8sC0EL2E8JsZ+PE9oJUbm3tdby53nZOxY3QuxBQOWT7TS4YZO3iltbAjGJK832 LvzdtLsY3SPsyVrbd1LFJb5m7R69FEj0z4adFLIj3XOLcuVK/LD5dAKZ2JKoS9DZzYfU WPcbweDKJMAGlxL/V2Ntq6lN45F0wMCzLuDDiGtWL+ltg37jAw+EviVFmNdhaSBoylNz CJT8HM3H1f1daWbD4/SzwzWvE0BOIwpf56lnPuu5OasawH46yCeZa/jBlVp+nnV9p6LH knKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v0Hc1+OSuo7YChLGC59HHK+vRdciDCQlRnhy6pM56xE=; b=jjlvD+zxHJYE4fGaJENBnhGMpkxE4sZqOeBdfyJYPHkVMRo7Q/mXqhdf/z3g52jU9t ZOuVKs4/lGA3o2+KwBIv2fOTw0VHCGBeLthPQs94zgy4hLukFtcJ1H4tkga//ObwVoGv 13J6fl5bcP116w6JXyT7VqAN5l2ABW7izCN+7FSjAPWQLgWTjQAIPIBrN/0FKvO2XgEt 4QVwUogS9waA265QICpei8HFd0i8pLUp9b2Vx9cc/Zw+5S8clVu8JNtVXDTjOTTzuX76 Cdzdi6WR//5F0xIz3wRuFJx3qin6tGeY72ipSso8D/eudrrO4zAzPuQyhJUIBEC2sb2g th2A== X-Gm-Message-State: AOAM530TMjBH1eZ8kTctglXa8w5nUMxEPrlxlELFdWDha7IJtBfhX8SC a95Xu0pX+cdYWEx6gEzHz7eX2JG11Uf3IQ== X-Google-Smtp-Source: ABdhPJwehWbjshGKcH1QD/2bpoDFzv7aTLYrqcCxRVfob0SHLodiDTsaV8l2uMMYSwK9SZUwd15OPg== X-Received: by 2002:a54:4791:: with SMTP id o17mr3385026oic.4.1597467606122; Fri, 14 Aug 2020 22:00:06 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id r197sm1865301oie.43.2020.08.14.22.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:05 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 15/20] Fixed a dumb bug Date: Fri, 14 Aug 2020 23:58:39 -0500 Message-Id: <20200815045912.8626-16-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org added code to prevent infinite loops in get l/rkey added a drop_key in mr dereg (fixing the root cause of loops) Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_mr.c | 22 +++++++++++----------- drivers/infiniband/sw/rxe/rxe_mw.c | 24 +++++++++++++----------- drivers/infiniband/sw/rxe/rxe_verbs.c | 1 + 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index ba4e33227633..533b02fc2d0e 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -34,20 +34,20 @@ #include "rxe.h" #include "rxe_loc.h" -/* choose a unique non zero random number for lkey */ +/* choose a unique non zero random number for lkey + * use high order bit to indicate MR vs MW */ void rxe_set_mr_lkey(struct rxe_mr *mr) { - int ret; u32 lkey; - -next_lkey: - get_random_bytes(&lkey, sizeof(lkey)); - lkey &= 0x7fffffff; - if (unlikely(lkey == 0)) - goto next_lkey; - ret = rxe_add_key(mr, &lkey); - if (unlikely(ret == -EAGAIN)) - goto next_lkey; + int tries = 0; + + do { + get_random_bytes(&lkey, sizeof(lkey)); + lkey &= 0x7fffffff; + if (likely(lkey && (rxe_add_key(mr, &lkey) == 0))) + return; + } while (tries++ < 10); + pr_err("rxe_set_mr_lkey: unable to get random lkey\n"); } #if 0 diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index b45a04efa4a0..a0ff2543d0cd 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -35,22 +35,24 @@ #include "rxe.h" #include "rxe_loc.h" -/* choose a unique non zero random number for rkey */ +/* choose a unique non zero random number for rkey + * use high order bit to indicate MR vs MW */ void rxe_set_mw_rkey(struct rxe_mw *mw) { - int ret; u32 rkey; - -next_rkey: - get_random_bytes(&rkey, sizeof(rkey)); - if (unlikely(rkey == 0)) - goto next_rkey; - rkey |= 0x80000000; - ret = rxe_add_key(mw, &rkey); - if (unlikely(ret == -EAGAIN)) - goto next_rkey; + int tries = 0; + + do { + get_random_bytes(&rkey, sizeof(rkey)); + rkey |= 0x80000000; + if (likely((rkey & 0x7fffffff) && + (rxe_add_key(mw, &rkey) == 0))) + return; + } while (tries++ < 10); + pr_err("rxe_set_mw_rkey: unable to get random rkey\n"); } + /* place holder alloc and dealloc routines * TODO add cross references between qp and mr with mw * and cleanup when one side is deleted. Enough to make diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index b91364ba2c68..476d90e3f91f 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -986,6 +986,7 @@ static int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) mr->state = RXE_MEM_STATE_ZOMBIE; rxe_drop_ref(mr->pd); rxe_drop_index(mr); + rxe_drop_key(mr); rxe_drop_ref(mr); return 0; } From patchwork Sat Aug 15 04:58:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715677 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9DC9913 for ; Sat, 15 Aug 2020 21:53:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A63D82053B for ; Sat, 15 Aug 2020 21:53:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KA3TTFWB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728432AbgHOVxC (ORCPT ); Sat, 15 Aug 2020 17:53:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729165AbgHOVwo (ORCPT ); Sat, 15 Aug 2020 17:52:44 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2A64C061243 for ; Fri, 14 Aug 2020 22:00:07 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id x6so2344135ooe.8 for ; Fri, 14 Aug 2020 22:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gVtEoMqulKDOUrrxvXAqf3eIjysZTgBICD+riQ2EMsE=; b=KA3TTFWB1XPLkBkzsvLSJpnKE+KE8g2MucR98zp5H1UnuZ4khMQn+jZg21Z4Xm44bS 9K0LhP7o7FJ8sXqpechZ0z1u8YRPzbnz+v02x4wKkL0kCCbGuif0XyjgXijCSEDJDeOl Px54HFuf5bXva27sFtpumylLCVRgLmQ48MAEUq2TUvksK9Isc4K7JKYwAPWqkAmpZo68 rw5kg+39MR1XxXK3SeBfiniMfiksE73Ae20IKYJS5ZlxoiAgNsEaHk50n3DjwFW1AOx+ rLDd/pB9HR43mOrjNht4CZBxi4R7C8Rxsd4ownCIhGTstFaQ9XBSzg8+CJvT3qKXLmx7 lVXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gVtEoMqulKDOUrrxvXAqf3eIjysZTgBICD+riQ2EMsE=; b=T+KXJFZU0cAhPl/ykhx/q/prHEXSXiuVCWtGZJaookVPJ69JabkuDCxPpz0BasYHJp Gh5IUBO1msDOB7AwQFWZpDusCs15UU3/Kce5QmGcBSZWFFZ3FAiIs+/YlJ8WNDr8I9Ng 1xqwhciBKpBNaRZTyG5JXRxQ+jfCTttx1zdDioeXWoC8ZrV1KDFdIL5elVM5S/ggcYDj uHS9EUgHfr4fki+E+uFxqMBjDqYnnGLEjSlsELLKSy1+UatXjCT4wA3ZgPe1wcnRPi5t f4tKywpRSsmPEArU9Ps2TDF6ZO2NCukWxAlgTrFhdrVEnNxB3RJI4p/UzhzhP2rluBZv WOqw== X-Gm-Message-State: AOAM530OY7o4y2yY1tbEyPuychFqU6z/jjuTSwLTkYOLtAmaxh01Ujj6 yJEF76fnsxLBh+BBakw3GLarroRvNVaqmw== X-Google-Smtp-Source: ABdhPJwZQx4SXdU/cZkk/qn2eAIfpn6Zv/QrJPF9n7jVWHzLf7NVOtUsK/iintpT0GGD2lQNHeI+PA== X-Received: by 2002:a4a:9f93:: with SMTP id z19mr4079761ool.58.1597467606895; Fri, 14 Aug 2020 22:00:06 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id j2sm2120924ooo.6.2020.08.14.22.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:06 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 16/20] Implemented stubbed invalidate APIs Date: Fri, 14 Aug 2020 23:58:40 -0500 Message-Id: <20200815045912.8626-17-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Fixed a bug in rxe_req that killed the last WC in error. Added a teardown/completion routine for MWs. Invalidate routines are still stubs. Still need to clean up some error path code for both MR and MW. Added atomics to detect reentrancy in the tasklets for now. Will go away later. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 18 ++++-- drivers/infiniband/sw/rxe/rxe_loc.h | 3 + drivers/infiniband/sw/rxe/rxe_mr.c | 17 ++++- drivers/infiniband/sw/rxe/rxe_mw.c | 33 +++++++--- drivers/infiniband/sw/rxe/rxe_pool.c | 11 ++++ drivers/infiniband/sw/rxe/rxe_req.c | 91 +++++++++++++++------------ drivers/infiniband/sw/rxe/rxe_resp.c | 57 +++++++++++++---- drivers/infiniband/sw/rxe/rxe_verbs.c | 4 -- 8 files changed, 162 insertions(+), 72 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index caa8ad990337..d2a094621486 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -563,12 +563,20 @@ int rxe_completer(void *arg) struct sk_buff *skb = NULL; struct rxe_pkt_info *pkt = NULL; enum comp_state state; + int entered; rxe_add_ref(qp); + // this code is 'guaranteed' to never be entered more + // than once. Check to make sure that this is the case + entered = atomic_inc_return(&qp->comp.task.entered); + if (entered > 1) { + pr_err("rxe_completer: entered %d times\n", entered); + } + if (!qp->valid || qp->req.state == QP_STATE_ERROR || qp->req.state == QP_STATE_RESET) { - rxe_drain_resp_pkts(qp, qp->valid && + rxe_drain_resp_pkts(qp, qp->valid && qp->req.state == QP_STATE_ERROR); goto exit; } @@ -782,14 +790,14 @@ int rxe_completer(void *arg) } } + /* these are the same. need to merge them TODO */ exit: /* we come here if we are done with processing and want the task to - * exit from the loop calling us + * exit from the loop calling us -- to call us again later */ WARN_ON_ONCE(skb); + atomic_dec(&qp->comp.task.entered); rxe_drop_ref(qp); - // TODO this seems plain backwards - // EAGAIN normally means call me again return -EAGAIN; done: @@ -797,6 +805,8 @@ int rxe_completer(void *arg) * us again to see if there is anything else to do */ WARN_ON_ONCE(skb); + atomic_dec(&qp->comp.task.entered); rxe_drop_ref(qp); return 0; + } diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 03eb74947d62..1ddd1b5721d8 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -137,6 +137,7 @@ int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); void rxe_mr_cleanup(struct rxe_pool_entry *arg); int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); +int rxe_invalidate_mr(struct rxe_mr *mr, int remote); /* rxe_mw.c */ void rxe_set_mw_rkey(struct rxe_mw *mw); @@ -144,6 +145,8 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, struct ib_udata *udata); int rxe_dealloc_mw(struct ib_mw *ibmw); int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe); +void rxe_mw_cleanup(struct rxe_pool_entry *arg); +int rxe_invalidate_mw(struct rxe_mw *mw, int remote); /* rxe_net.c */ void rxe_loopback(struct sk_buff *skb); diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index 533b02fc2d0e..bebcce06e804 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -47,7 +47,7 @@ void rxe_set_mr_lkey(struct rxe_mr *mr) if (likely(lkey && (rxe_add_key(mr, &lkey) == 0))) return; } while (tries++ < 10); - pr_err("rxe_set_mr_lkey: unable to get random lkey\n"); + pr_err("unable to get random key for mr\n"); } #if 0 @@ -114,7 +114,8 @@ void rxe_mr_cleanup(struct rxe_pool_entry *arg) struct rxe_mr *mr = container_of(arg, typeof(*mr), pelem); int i; - ib_umem_release(mr->umem); + if (mr->umem) + ib_umem_release(mr->umem); if (mr->map) { for (i = 0; i < mr->num_map; i++) @@ -122,6 +123,9 @@ void rxe_mr_cleanup(struct rxe_pool_entry *arg) kfree(mr->map); } + + rxe_drop_index(mr); + rxe_drop_key(mr); } static int rxe_mr_alloc(struct rxe_mr *mr, int num_buf) @@ -602,3 +606,12 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, return mr; } + +int rxe_invalidate_mr(struct rxe_mr *mr, int remote) +{ + // more TODO here, can fail + + mr->state = RXE_MEM_STATE_FREE; + + return 0; +} diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index a0ff2543d0cd..7092045a2691 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -49,7 +49,7 @@ void rxe_set_mw_rkey(struct rxe_mw *mw) (rxe_add_key(mw, &rkey) == 0))) return; } while (tries++ < 10); - pr_err("rxe_set_mw_rkey: unable to get random rkey\n"); + pr_err("unable to get random rkey for mw\n"); } @@ -91,9 +91,6 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, rxe_add_index(mw); rxe_set_mw_rkey(mw); - pr_info("rxe_alloc_mw: index = 0x%08x, rkey = 0x%08x\n", - mw->pelem.index, mw->ibmw.rkey); - spin_lock_init(&mw->lock); if (type == IB_MW_TYPE_2) { @@ -120,8 +117,6 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, return &mw->ibmw; err2: - rxe_drop_key(mw); - rxe_drop_index(mw); rxe_drop_ref(mw); rxe_drop_ref(pd); err1: @@ -138,8 +133,6 @@ int rxe_dealloc_mw(struct ib_mw *ibmw) mw->state = RXE_MW_STATE_INVALID; spin_unlock_irqrestore(&mw->lock, flags); - rxe_drop_key(mw); - rxe_drop_index(mw); rxe_drop_ref(pd); rxe_drop_ref(mw); @@ -151,8 +144,6 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) struct rxe_mw *mw; struct rxe_mr *mr; - pr_info("rxe_bind_mw: called\n"); - if (qp->is_user) { } else { mw = to_rmw(wqe->wr.wr.kmw.ibmw); @@ -186,3 +177,25 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) #endif return 0; } + +void rxe_mw_cleanup(struct rxe_pool_entry *arg) +{ + struct rxe_mw *mw = container_of(arg, typeof(*mw), pelem); + + rxe_drop_index(mw); + rxe_drop_key(mw); +} + +int rxe_invalidate_mw(struct rxe_mw *mw, int remote) +{ + /* type 1 MWs don't support invalidate */ + if (mw->ibmw.type == IB_MW_TYPE_1) { + pr_err("attempt to %s-invalidate a type 1 mw\n", + remote ? "send" : "local"); + return -EINVAL; + } + + mw->state = RXE_MEM_STATE_FREE; + + return 0; +} diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index 35e9646e104c..df3e2a514ce3 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -85,6 +85,7 @@ struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = { [RXE_TYPE_MW] = { .name = "rxe-mw", .size = sizeof(struct rxe_mw), + .cleanup = rxe_mw_cleanup, .flags = RXE_POOL_INDEX | RXE_POOL_KEY, .max_index = RXE_MAX_MW_INDEX, @@ -365,6 +366,11 @@ void rxe_drop_key(void *arg) struct rxe_pool *pool = elem->pool; unsigned long flags; + if (elem == NULL) { + pr_warn("rxe_drop_key: called with null pointer\n"); + return; + } + write_lock_irqsave(&pool->pool_lock, flags); rb_erase(&elem->key_node, &pool->key.tree); write_unlock_irqrestore(&pool->pool_lock, flags); @@ -388,6 +394,11 @@ void rxe_drop_index(void *arg) struct rxe_pool *pool = elem->pool; unsigned long flags; + if (elem == NULL) { + pr_warn("rxe_drop_index: called with null pointer\n"); + return; + } + write_lock_irqsave(&pool->pool_lock, flags); clear_bit(elem->index - pool->index.min_index, pool->index.table); rb_erase(&elem->index_node, &pool->index.tree); diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index e0564d7b0ff7..2a38b7cdf4a8 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -583,11 +583,32 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, jiffies + qp->qp_timeout_jiffies); } +static int local_invalidate(struct rxe_dev *rxe, struct rxe_send_wqe *wqe) +{ + int ret; + struct rxe_mr *mr; + struct rxe_mw *mw; + u32 key = wqe->wr.ex.invalidate_rkey; + + if ((mr = rxe_pool_get_key(&rxe->mr_pool, &key))) { + ret = rxe_invalidate_mr(mr, 0); + rxe_drop_ref(mr); + } else if ((mw = rxe_pool_get_key(&rxe->mw_pool, &key))) { + ret = rxe_invalidate_mw(mw, 0); + rxe_drop_ref(mw); + } else { + ret = -EINVAL; + pr_err("No mr/mw for rkey %#x\n", key); + } + + return ret; +} + int rxe_requester(void *arg) { struct rxe_qp *qp = (struct rxe_qp *)arg; struct rxe_dev *rxe = to_rdev(qp->ibqp.device); - struct rxe_mr *rmr; + struct rxe_mr *mr; struct rxe_pkt_info pkt; struct sk_buff *skb; struct rxe_send_wqe *wqe; @@ -600,6 +621,8 @@ int rxe_requester(void *arg) u32 rollback_psn; int entered; + pr_info("rxe_requester: called\n"); + rxe_add_ref(qp); // this code is 'guaranteed' to never be entered more @@ -631,57 +654,47 @@ int rxe_requester(void *arg) if (unlikely(!wqe)) goto exit; + /* process local operations */ if (wqe->mask & WR_LOCAL_MASK) { + wqe->state = wqe_state_done; + wqe->status = IB_WC_SUCCESS; + switch (wqe->wr.opcode) { case IB_WR_LOCAL_INV: - rmr = rxe_pool_get_index(&rxe->mr_pool, - wqe->wr.ex.invalidate_rkey >> 8); - if (!rmr) { - pr_err("No mr for key %#x\n", - wqe->wr.ex.invalidate_rkey); - wqe->state = wqe_state_error; - wqe->status = IB_WC_MW_BIND_ERR; - goto exit; - } - // TODO this can race with external access - // to the MR in rxe_resp unless you can know - // that all accesses are done - rmr->state = RXE_MEM_STATE_FREE; - rxe_drop_ref(rmr); - wqe->state = wqe_state_done; - wqe->status = IB_WC_SUCCESS; + if ((ret = local_invalidate(rxe, wqe))) + wqe->status = IB_WC_LOC_QP_OP_ERR; break; case IB_WR_REG_MR: - rmr = to_rmr(wqe->wr.wr.reg.mr); - rmr->state = RXE_MEM_STATE_VALID; - rmr->access = wqe->wr.wr.reg.access; - rmr->lkey = wqe->wr.wr.reg.key; - rmr->rkey = wqe->wr.wr.reg.key; - rmr->iova = wqe->wr.wr.reg.mr->iova; - wqe->state = wqe_state_done; - wqe->status = IB_WC_SUCCESS; + mr = to_rmr(wqe->wr.wr.reg.mr); + mr->state = RXE_MEM_STATE_VALID; + mr->access = wqe->wr.wr.reg.access; + mr->lkey = wqe->wr.wr.reg.key; + mr->rkey = wqe->wr.wr.reg.key; + mr->iova = wqe->wr.wr.reg.mr->iova; break; case IB_WR_BIND_MW: - ret = rxe_bind_mw(qp, wqe); - if (ret) { - wqe->state = wqe_state_done; + if ((ret = rxe_bind_mw(qp, wqe))) wqe->status = IB_WC_MW_BIND_ERR; - // TODO err: will change status - // probably should not - goto err; - } - wqe->state = wqe_state_done; - wqe->status = IB_WC_SUCCESS; break; default: - pr_err("rxe_requester: unexpected LOCAL WR opcode = %d\n", wqe->wr.opcode); - goto exit; + pr_err("rxe_requester: unexpected local WR opcode = %d\n", + wqe->wr.opcode); + wqe->status = IB_WC_LOC_QP_OP_ERR; } + + /* we're done processing the wqe so move index */ + qp->req.wqe_index = next_index(qp->sq.queue, qp->req.wqe_index); + + /* if an error occurred do a completion pass now + * (below) and then quit processing more wqes */ + if (wqe->status != IB_WC_SUCCESS) + goto err; + + /* if the wqe is signalled schedule a completion pass */ if ((wqe->wr.send_flags & IB_SEND_SIGNALED) || - qp->sq_sig_type == IB_SIGNAL_ALL_WR) + (qp->sq_sig_type == IB_SIGNAL_ALL_WR)) rxe_run_task(&qp->comp.task, 1); - qp->req.wqe_index = next_index(qp->sq.queue, - qp->req.wqe_index); + goto next_wqe; } diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index d54b5e7dad39..aac50c0a43c7 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -834,14 +834,38 @@ static enum resp_states execute(struct rxe_qp *qp, struct rxe_pkt_info *pkt) return RESPST_CLEANUP; } +static int send_invalidate(struct rxe_dev *rxe, u32 rkey) +{ + int ret; + struct rxe_mr *mr; + struct rxe_mw *mw; + + pr_info("send_invalidate: called\n"); + + if ((mr = rxe_pool_get_key(&rxe->mr_pool, &rkey))) { + ret = rxe_invalidate_mr(mr, 1); + rxe_drop_ref(mr); + } else if ((mw = rxe_pool_get_key(&rxe->mw_pool, &rkey))) { + ret = rxe_invalidate_mw(mw, 1); + rxe_drop_ref(mw); + } else { + pr_err("send invalidate failed for rkey = 0x%x\n", rkey); + ret = -EINVAL; + } + + return ret; +} + static enum resp_states do_complete(struct rxe_qp *qp, struct rxe_pkt_info *pkt) { + int ret; struct rxe_cqe cqe; struct ib_wc *wc = &cqe.ibwc; struct ib_uverbs_wc *uwc = &cqe.uibwc; struct rxe_recv_wqe *wqe = qp->resp.wqe; struct rxe_dev *rxe = to_rdev(qp->ibqp.device); + u32 rkey = ieth_rkey(pkt); if (unlikely(!wqe)) return RESPST_CLEANUP; @@ -858,6 +882,14 @@ static enum resp_states do_complete(struct rxe_qp *qp, wc->wr_id = wqe->wr_id; } + if (pkt->mask & RXE_IETH_MASK) { + ret = send_invalidate(rxe, rkey); + if (ret) { + pr_err("do_complete: send invalidate failed\n"); + // TODO + } + } + if (wc->status == IB_WC_SUCCESS) { rxe_counter_inc(rxe, RXE_CNT_RDMA_RECV); wc->opcode = (pkt->mask & RXE_IMMDT_MASK && @@ -881,7 +913,7 @@ static enum resp_states do_complete(struct rxe_qp *qp, if (pkt->mask & RXE_IETH_MASK) { uwc->wc_flags |= IB_WC_WITH_INVALIDATE; - uwc->ex.invalidate_rkey = ieth_rkey(pkt); + uwc->ex.invalidate_rkey = rkey; } uwc->qp_num = qp->ibqp.qp_num; @@ -910,20 +942,8 @@ static enum resp_states do_complete(struct rxe_qp *qp, } if (pkt->mask & RXE_IETH_MASK) { - struct rxe_mr *rmr; - wc->wc_flags |= IB_WC_WITH_INVALIDATE; wc->ex.invalidate_rkey = ieth_rkey(pkt); - - rmr = rxe_pool_get_index(&rxe->mr_pool, - wc->ex.invalidate_rkey >> 8); - if (unlikely(!rmr)) { - pr_err("Bad rkey %#x invalidation\n", - wc->ex.invalidate_rkey); - return RESPST_ERROR; - } - rmr->state = RXE_MEM_STATE_FREE; - rxe_drop_ref(rmr); } wc->qp = &qp->ibqp; @@ -933,6 +953,8 @@ static enum resp_states do_complete(struct rxe_qp *qp, wc->port_num = qp->attr.port_num; } + } else { + // TODO what??? } /* have copy for srq and reference for !srq */ @@ -1224,9 +1246,17 @@ int rxe_responder(void *arg) enum resp_states state; struct rxe_pkt_info *pkt = NULL; int ret = 0; + int entered; rxe_add_ref(qp); + // this code is 'guaranteed' to never be entered more + // than once. Check to make sure that this is the case + entered = atomic_inc_return(&qp->resp.task.entered); + if (entered > 1) { + pr_err("rxe_responder: entered %d times\n", entered); + } + qp->resp.aeth_syndrome = AETH_ACK_UNLIMITED; if (!qp->valid) { @@ -1405,6 +1435,7 @@ int rxe_responder(void *arg) exit: ret = -EAGAIN; done: + atomic_dec(&qp->resp.task.entered); rxe_drop_ref(qp); return ret; } diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 476d90e3f91f..b11ab3ae87a3 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -970,7 +970,6 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, return &mr->ibmr; err3: - rxe_drop_index(mr); rxe_drop_ref(mr); rxe_drop_ref(pd); err2: @@ -985,8 +984,6 @@ static int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) mr->state = RXE_MEM_STATE_ZOMBIE; rxe_drop_ref(mr->pd); - rxe_drop_index(mr); - rxe_drop_key(mr); rxe_drop_ref(mr); return 0; } @@ -1020,7 +1017,6 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type, err2: rxe_drop_ref(pd); - rxe_drop_index(mr); rxe_drop_ref(mr); err1: return ERR_PTR(err); From patchwork Sat Aug 15 04:58:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715693 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 403EB913 for ; Sat, 15 Aug 2020 21:54:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E0FC2053B for ; Sat, 15 Aug 2020 21:54:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gR8LI3dV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728792AbgHOVyX (ORCPT ); Sat, 15 Aug 2020 17:54:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729115AbgHOVwg (ORCPT ); Sat, 15 Aug 2020 17:52:36 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DFECC061244 for ; Fri, 14 Aug 2020 22:00:09 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id h3so9986526oie.11 for ; Fri, 14 Aug 2020 22:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t17wqw+dfna8L/zhx55t2XMFpesJUAGIa/Mi9u6M7/o=; b=gR8LI3dV66T+Q3qzkfQFc5dmFqGDZnGBsk5WwjBbvWX5xffjT1SuBbdKtgkgrlvNTa QDAaCBrN01iw77mutgdw5IMtvdk56FnuCVAquVJn9tm6lYvFhvcVlIjehWuq+iA21R5/ x4ZTmaG6f7ZCi+ZBf2qrMc3Ns7KNCHuZzOO8kGBZF1xwCXTLwQNESHdaf8LtagumMAA/ 49Yu1jkmoscfBGc6+bO1w/dkIZnqQxWvQ0tGUHVVpA33HfdkE6m9M6cGUhRxc9CQYZl7 5h4gD8zPAyp6PCUf6R49mZ84hId9Yb03QPftnmPL3PVhK88mFldBuxJtRt/0N/GknIaY sW4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t17wqw+dfna8L/zhx55t2XMFpesJUAGIa/Mi9u6M7/o=; b=thR17XG4G+OTx9nESxwFQ0onskiKDnBfW+QRC2FKcCJwcj0VOK88cw0ZBQVUCKqPXc PwnRTAYV3LfCuC40LnNa1ePA7hwuxzg6uy7Ed9vbWoSp7XI0AzT87SFyrKqSRHEFMQPZ XGjtWQN8CtOU83gZxUaTRzUp/6ZOQ9CLP1rk4VlCdtaXGvYCeZNvzU3HdreEnB/cOHgS VA7o0zqqUyjBWOrGgQdG6XhxQP8FeNwVgKK4iEQSCmMY2bqhifP1ARGCAWAjStMTKlyh HVowcotEpkHa4PjcNS2BHVgewXU7SP+XAWOVihyrUfXwxeiDAilbGDdGXUrPvlkc56+1 eGGg== X-Gm-Message-State: AOAM530jMEPo4FNvLPZiHTlCaN+XeAJl3OmP0LVrVK75IOANRGzM2kD9 gldObIPOqiY0lfJVcPuIHqNCR6gztdt0Zg== X-Google-Smtp-Source: ABdhPJwnR+pP8Uz9iAPymU5AJrSHda5dFsnnkgVE//7uyMPCWDn3zRqgXqJ+Xk5aJMhOcIJgWM7S7Q== X-Received: by 2002:aca:fc4e:: with SMTP id a75mr3691102oii.46.1597467607669; Fri, 14 Aug 2020 22:00:07 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id l4sm2091823oog.1.2020.08.14.22.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:07 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 17/20] Implemented functional invalidate APIs Date: Fri, 14 Aug 2020 23:58:41 -0500 Message-Id: <20200815045912.8626-18-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Made progress on details of mw alloc, bind, invalidate and dealloc. added a private flags field in rxe_send_wqe to allow ibv_bind_mw to safely tell the kernel that bind has come through ibv_bind_mw. The IBA requires that type 1 MWs can only be bound by the ibv_bind_mw API and type 2 MWs by send WRs. But we implement the bind_mw call with WRs too since rdma-core does not implement the verbs call. Need to cleanly separate the two cases. After implementing the checking core for MWs it is clear that MRs require more effort to comply with the standard. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_loc.h | 4 +- drivers/infiniband/sw/rxe/rxe_mr.c | 44 +-- drivers/infiniband/sw/rxe/rxe_mw.c | 383 ++++++++++++++++++++------ drivers/infiniband/sw/rxe/rxe_param.h | 2 + drivers/infiniband/sw/rxe/rxe_req.c | 23 +- drivers/infiniband/sw/rxe/rxe_resp.c | 12 +- drivers/infiniband/sw/rxe/rxe_verbs.c | 25 +- drivers/infiniband/sw/rxe/rxe_verbs.h | 9 +- include/uapi/rdma/rdma_user_rxe.h | 2 + 9 files changed, 366 insertions(+), 138 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 1ddd1b5721d8..652e0d67fe5c 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -137,7 +137,7 @@ int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); void rxe_mr_cleanup(struct rxe_pool_entry *arg); int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); -int rxe_invalidate_mr(struct rxe_mr *mr, int remote); +int rxe_invalidate_mr(struct rxe_qp *qp, struct rxe_mr *mr); /* rxe_mw.c */ void rxe_set_mw_rkey(struct rxe_mw *mw); @@ -146,7 +146,7 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, int rxe_dealloc_mw(struct ib_mw *ibmw); int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe); void rxe_mw_cleanup(struct rxe_pool_entry *arg); -int rxe_invalidate_mw(struct rxe_mw *mw, int remote); +int rxe_invalidate_mw(struct rxe_qp *qp, struct rxe_mw *mw); /* rxe_net.c */ void rxe_loopback(struct sk_buff *skb); diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index bebcce06e804..a983a838bf4c 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -109,25 +109,6 @@ static void rxe_mr_init(int access, struct rxe_mr *mr) mr->map_shift = ilog2(RXE_BUF_PER_MAP); } -void rxe_mr_cleanup(struct rxe_pool_entry *arg) -{ - struct rxe_mr *mr = container_of(arg, typeof(*mr), pelem); - int i; - - if (mr->umem) - ib_umem_release(mr->umem); - - if (mr->map) { - for (i = 0; i < mr->num_map; i++) - kfree(mr->map[i]); - - kfree(mr->map); - } - - rxe_drop_index(mr); - rxe_drop_key(mr); -} - static int rxe_mr_alloc(struct rxe_mr *mr, int num_buf) { int i; @@ -607,11 +588,32 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, return mr; } -int rxe_invalidate_mr(struct rxe_mr *mr, int remote) +int rxe_invalidate_mr(struct rxe_qp *qp, struct rxe_mr *mr) { - // more TODO here, can fail + // much more TODO here, can fail + // mw is closer to what is needed + // but for another day mr->state = RXE_MEM_STATE_FREE; return 0; } + +void rxe_mr_cleanup(struct rxe_pool_entry *arg) +{ + struct rxe_mr *mr = container_of(arg, typeof(*mr), pelem); + int i; + + if (mr->umem) + ib_umem_release(mr->umem); + + if (mr->map) { + for (i = 0; i < mr->num_map; i++) + kfree(mr->map[i]); + + kfree(mr->map); + } + + rxe_drop_index(mr); + rxe_drop_key(mr); +} diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index 7092045a2691..0c774aadf6c7 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -52,29 +52,17 @@ void rxe_set_mw_rkey(struct rxe_mw *mw) pr_err("unable to get random rkey for mw\n"); } - -/* place holder alloc and dealloc routines - * TODO add cross references between qp and mr with mw - * and cleanup when one side is deleted. Enough to make - * verbs function correctly for now */ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, struct ib_udata *udata) { int ret; + int index; struct rxe_mw *mw; struct rxe_pd *pd = to_rpd(ibpd); struct rxe_dev *rxe = to_rdev(ibpd->device); struct rxe_alloc_mw_resp __user *uresp; - if (udata) { - if (udata->outlen < sizeof(*uresp)) { - ret = -EINVAL; - goto err1; - } - } - - if (unlikely((type != IB_MW_TYPE_1) && - (type != IB_MW_TYPE_2))) { + if (unlikely(udata && (udata->outlen < sizeof(*uresp)))) { ret = -EINVAL; goto err1; } @@ -82,22 +70,29 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, rxe_add_ref(pd); mw = rxe_alloc(&rxe->mw_pool); - if (!mw) { - rxe_drop_ref(pd); + if (unlikely(!mw)) { ret = -ENOMEM; - goto err1; + goto err2; } - rxe_add_index(mw); - rxe_set_mw_rkey(mw); + switch (type) { + case IB_MW_TYPE_1: + mw->state = RXE_MW_STATE_VALID; + break; + case IB_MW_TYPE_2: + mw->state = RXE_MW_STATE_FREE; + break; + default: + pr_err("attempt to allocate MW with unknown type\n"); + ret = -EINVAL; + goto err3; + } - spin_lock_init(&mw->lock); + rxe_add_index(mw); + index = mw->pelem.index; - if (type == IB_MW_TYPE_2) { - mw->state = RXE_MW_STATE_FREE; - } else { - mw->state = RXE_MW_STATE_VALID; - } + /* o10-37.2.32: */ + rxe_set_mw_rkey(mw); mw->qp = NULL; mw->mr = NULL; @@ -106,96 +101,330 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, mw->ibmw.pd = ibpd; mw->ibmw.type = type; + spin_lock_init(&mw->lock); + if (udata) { uresp = udata->outbuf; - if (copy_to_user(&uresp->index, &mw->pelem.index, - sizeof(u32))) { + if (copy_to_user(&uresp->index, &index, sizeof(index))) { ret = -EFAULT; - goto err2; + goto err3; } } return &mw->ibmw; -err2: +err3: rxe_drop_ref(mw); +err2: rxe_drop_ref(pd); err1: return ERR_PTR(ret); } -int rxe_dealloc_mw(struct ib_mw *ibmw) +/* Check the rules for bind MW oepration. */ +static int check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, + struct rxe_mw *mw, struct rxe_mr *mr) { - struct rxe_mw *mw = to_rmw(ibmw); - struct rxe_pd *pd = to_rpd(ibmw->pd); - unsigned long flags; + /* check to see if bind operation came through + * ibv_bind_mw verbs API. */ + switch (mw->ibmw.type) { + case IB_MW_TYPE_1: + /* o10-37.2.34: */ + if (unlikely(!(wqe->wr.wr.umw.flags & RXE_BIND_MW))) { + pr_err("attempt to bind type 1 MW with send WR\n"); + return -EINVAL; + } + break; + case IB_MW_TYPE_2: + /* o10-37.2.35: */ + if (unlikely(wqe->wr.wr.umw.flags & RXE_BIND_MW)) { + pr_err("attempt to bind type 2 MW with verbs API\n"); + return -EINVAL; + } - spin_lock_irqsave(&mw->lock, flags); - mw->state = RXE_MW_STATE_INVALID; - spin_unlock_irqrestore(&mw->lock, flags); + /* C10-72: */ + if (unlikely(qp->pd != to_rpd(mw->ibmw.pd))) { + pr_err("attempt to bind type 2 MW with qp" + " with different PD\n"); + return -EINVAL; + } - rxe_drop_ref(pd); - rxe_drop_ref(mw); + /* o10-37.2.40: */ + if (unlikely(wqe->wr.wr.umw.length == 0)) { + pr_err("attempt to invalidate type 2 MW by" + " binding with zero length\n"); + return -EINVAL; + } + + if (unlikely(!mr)) { + pr_err("attempt to invalidate type 2 MW by" + " binding to NULL mr\n"); + return -EINVAL; + } + break; + default: + return -EINVAL; + } + + if (unlikely((mw->ibmw.type == IB_MW_TYPE_1) && + (mw->state != RXE_MW_STATE_VALID))) { + pr_err("attempt to bind a type 1 MW not in the" + " valid state\n"); + return -EINVAL; + } + + /* o10-36.2.2: */ + if (unlikely((mw->access & IB_ZERO_BASED) && + (mw->ibmw.type == IB_MW_TYPE_1))) { + pr_err("attempt to bind a zero based type 1 MW\n"); + return -EINVAL; + } + + if ((wqe->wr.wr.umw.rkey & 0xff) == (mw->ibmw.rkey & 0xff)) { + pr_err("attempt to bind MW with same key\n"); + return -EINVAL; + } + + /* remaining checks only apply to a nonzero MR */ + if (!mr) + return 0; + + if (unlikely(mr->access & IB_ZERO_BASED)) { + pr_err("attempt to bind MW to zero based MR\n"); + return -EINVAL; + } + + /* o10-37.2.30: */ + if (unlikely((mw->ibmw.type == IB_MW_TYPE_2) && + (mw->state != RXE_MW_STATE_FREE))) { + pr_err("attempt to bind a type 2 MW not in the" + " free state\n"); + return -EINVAL; + } + + /* C10-73: */ + if (unlikely(!(mr->access & IB_ACCESS_MW_BIND))) { + pr_err("attempt to bind an MW to an MR without" + " bind access\n"); + return -EINVAL; + } + + /* C10-74: */ + if (unlikely((mw->access & (IB_ACCESS_REMOTE_WRITE | + IB_ACCESS_REMOTE_ATOMIC)) && + !(mr->access & IB_ACCESS_LOCAL_WRITE))) { + pr_err("attempt to bind an MW with write/atomic" + " access to an MR without local write access\n"); + return -EINVAL; + } + + /* MR duplicates address and length in the private and ib + * parts of the rxe_mr struct. TODO should only keep one. */ + + /* C10-75: */ + if (mw->access & IB_ZERO_BASED) { + if (unlikely(wqe->wr.wr.umw.length > mr->length)) { + pr_err("attempt to bind a ZB MW outside" + " of the MR\n"); + return -EINVAL; + } + } else { + if (unlikely((wqe->wr.wr.umw.addr < mr->iova) || + ((wqe->wr.wr.umw.addr + wqe->wr.wr.umw.length) > + (mr->iova + mr->length)))) { + pr_err("attempt to bind a VA MW outside" + " of the MR\n"); + return -EINVAL; + } + } return 0; } +static void do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, + struct rxe_mw *mw, struct rxe_mr *mr) +{ + u32 rkey; + + mw->access = wqe->wr.wr.umw.access; + mw->state = RXE_MW_STATE_VALID; + mw->addr = wqe->wr.wr.umw.addr; + mw->length = wqe->wr.wr.umw.length; + + /* get rid of existing MR if any, type 1 only */ + if (mw->mr) { + rxe_drop_ref(mw->mr); + atomic_dec(&mw->mr->num_mw); + mw->mr = NULL; + } + + /* if length != 0 bind to new MR */ + if (mw->length) { + mw->mr = mr; + atomic_inc(&mr->num_mw); + rxe_add_ref(mr); + } + + /* remember qp if type 2, cleared by invalidate + * this is weak since qp can go away legally + * only used to compare with qp used to perform + * memory ops */ + if (mw->ibmw.type == IB_MW_TYPE_2) { + mw->qp = qp; + } + + /* key part of new rkey is provided by user for type 2 + * and ibv_bind_mw() for type 1 MWs */ + rkey = mw->ibmw.rkey; + rxe_drop_key(mw); + rkey = (rkey & 0xffffff00) | (wqe->wr.wr.umw.rkey & 0x000000ff); + rxe_add_key(mw, &rkey); + + return; +} + int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) { + int ret; struct rxe_mw *mw; struct rxe_mr *mr; + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); + unsigned long flags; if (qp->is_user) { + mw = rxe_pool_get_index(&rxe->mw_pool, + wqe->wr.wr.umw.mw_index); + if (!mw) { + pr_err("mw with index = %d not found\n", + wqe->wr.wr.umw.mw_index); + ret = -EINVAL; + goto err1; + } + mr = rxe_pool_get_index(&rxe->mr_pool, + wqe->wr.wr.umw.mr_index); + if (!mr && wqe->wr.wr.umw.length) { + pr_err("mr with index = %d not found\n", + wqe->wr.wr.umw.mr_index); + ret = -EINVAL; + goto err2; + } } else { mw = to_rmw(wqe->wr.wr.kmw.ibmw); - mr = to_rmr(wqe->wr.wr.kmw.ibmr); - } - -#if 0 - wqe->wr.wr.bind_mw - __aligned_u64 addr; - __aligned_u64 length; - __u32 mr_rkey; - __u32 mw_rkey; - __u32 rkey; - __u32 access; - - mw - struct rxe_pool_entry pelem; // alloc - struct ib_mw ibmw; // alloc - struct ib_device *device; // alloc - struct ib_pd *pd; // alloc - struct ib_uobject *uobject; // alloc - u32 rkey; - enum ib_mw_type type; // alloc - struct rxe_qp *qp; // bind - struct rxe_mem *mr; // bind - spinlock_t lock; // alloc - enum rxe_mw_state state; // all - u32 access; // bind - u64 addr; // bind - u64 length; // bind -#endif + rxe_add_ref(mw); + if (wqe->wr.wr.kmw.ibmr) { + mr = to_rmr(wqe->wr.wr.kmw.ibmr); + rxe_add_ref(mr); + } else { + mr = NULL; + } + } + + spin_lock_irqsave(&mw->lock, flags); + + /* check the rules */ + ret = check_bind_mw(qp, wqe, mw, mr); + if (ret) + goto err3; + + /* implement the change */ + do_bind_mw(qp, wqe, mw, mr); +err3: + spin_unlock_irqrestore(&mw->lock, flags); + + if (mr) + rxe_drop_ref(mr); +err2: + rxe_drop_ref(mw); +err1: + return ret; +} + +static int check_invalidate_mw(struct rxe_qp *qp, struct rxe_mw *mw) +{ + /* o10-37.2.26: */ + if (unlikely(mw->ibmw.type == IB_MW_TYPE_1)) { + pr_err("attempt to invalidate a type 1 MW\n"); + return -EINVAL; + } + + if (unlikely(mw->state != RXE_MW_STATE_VALID)) { + pr_warn("attempt to invalidate a MW that" + " is not valid\n"); + return -EINVAL; + } + return 0; } -void rxe_mw_cleanup(struct rxe_pool_entry *arg) +static void do_invalidate_mw(struct rxe_mw *mw) { - struct rxe_mw *mw = container_of(arg, typeof(*mw), pelem); + mw->qp = NULL; - rxe_drop_index(mw); - rxe_drop_key(mw); + rxe_drop_ref(mw->mr); + atomic_dec(&mw->mr->num_mw); + mw->mr = NULL; + + mw->access = 0; + mw->addr = 0; + mw->length = 0; + mw->state = RXE_MW_STATE_FREE; } -int rxe_invalidate_mw(struct rxe_mw *mw, int remote) +int rxe_invalidate_mw(struct rxe_qp *qp, struct rxe_mw *mw) { - /* type 1 MWs don't support invalidate */ - if (mw->ibmw.type == IB_MW_TYPE_1) { - pr_err("attempt to %s-invalidate a type 1 mw\n", - remote ? "send" : "local"); - return -EINVAL; + int ret; + unsigned long flags; + + spin_lock_irqsave(&mw->lock, flags); + + ret = check_invalidate_mw(qp, mw); + if (ret) + goto err; + + do_invalidate_mw(mw); +err: + spin_unlock_irqrestore(&mw->lock, flags); + + return ret; +} + +static void do_deallocate_mw(struct rxe_mw *mw) +{ + mw->qp = NULL; + + if (mw->mr) { + rxe_drop_ref(mw->mr); + atomic_dec(&mw->mr->num_mw); + mw->mr = NULL; } - mw->state = RXE_MEM_STATE_FREE; + mw->access = 0; + mw->addr = 0; + mw->length = 0; + mw->state = RXE_MW_STATE_INVALID; +} + +int rxe_dealloc_mw(struct ib_mw *ibmw) +{ + struct rxe_mw *mw = to_rmw(ibmw); + struct rxe_pd *pd = to_rpd(ibmw->pd); + unsigned long flags; + + spin_lock_irqsave(&mw->lock, flags); + + do_deallocate_mw(mw); + + spin_unlock_irqrestore(&mw->lock, flags); + + rxe_drop_ref(pd); + rxe_drop_ref(mw); return 0; } + +void rxe_mw_cleanup(struct rxe_pool_entry *arg) +{ + struct rxe_mw *mw = container_of(arg, typeof(*mw), pelem); + + rxe_drop_index(mw); + rxe_drop_key(mw); +} diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h index 7f914dde98a7..41e7b74efcbc 100644 --- a/drivers/infiniband/sw/rxe/rxe_param.h +++ b/drivers/infiniband/sw/rxe/rxe_param.h @@ -75,7 +75,9 @@ enum rxe_device_param { | IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN | IB_DEVICE_SRQ_RESIZE + | IB_DEVICE_MEM_WINDOW | IB_DEVICE_MEM_MGT_EXTENSIONS + | IB_DEVICE_MEM_WINDOW_TYPE_2B | IB_DEVICE_ALLOW_USER_UNREG, RXE_MAX_SGE = 32, RXE_MAX_WQE_SIZE = sizeof(struct rxe_send_wqe) + diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index 2a38b7cdf4a8..ad747f230318 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -583,18 +583,19 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, jiffies + qp->qp_timeout_jiffies); } -static int local_invalidate(struct rxe_dev *rxe, struct rxe_send_wqe *wqe) +static int local_invalidate(struct rxe_qp *qp, struct rxe_send_wqe *wqe) { int ret; struct rxe_mr *mr; struct rxe_mw *mw; + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); u32 key = wqe->wr.ex.invalidate_rkey; if ((mr = rxe_pool_get_key(&rxe->mr_pool, &key))) { - ret = rxe_invalidate_mr(mr, 0); + ret = rxe_invalidate_mr(qp, mr); rxe_drop_ref(mr); } else if ((mw = rxe_pool_get_key(&rxe->mw_pool, &key))) { - ret = rxe_invalidate_mw(mw, 0); + ret = rxe_invalidate_mw(qp, mw); rxe_drop_ref(mw); } else { ret = -EINVAL; @@ -607,7 +608,6 @@ static int local_invalidate(struct rxe_dev *rxe, struct rxe_send_wqe *wqe) int rxe_requester(void *arg) { struct rxe_qp *qp = (struct rxe_qp *)arg; - struct rxe_dev *rxe = to_rdev(qp->ibqp.device); struct rxe_mr *mr; struct rxe_pkt_info pkt; struct sk_buff *skb; @@ -621,8 +621,6 @@ int rxe_requester(void *arg) u32 rollback_psn; int entered; - pr_info("rxe_requester: called\n"); - rxe_add_ref(qp); // this code is 'guaranteed' to never be entered more @@ -655,13 +653,18 @@ int rxe_requester(void *arg) goto exit; /* process local operations */ + /* current behavior if an error occurs + * for any of these local operations + * is to generate an error work completion + * then error the QP and flush any + * remaining WRs */ if (wqe->mask & WR_LOCAL_MASK) { wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; switch (wqe->wr.opcode) { case IB_WR_LOCAL_INV: - if ((ret = local_invalidate(rxe, wqe))) + if ((ret = local_invalidate(qp, wqe))) wqe->status = IB_WC_LOC_QP_OP_ERR; break; case IB_WR_REG_MR: @@ -677,8 +680,10 @@ int rxe_requester(void *arg) wqe->status = IB_WC_MW_BIND_ERR; break; default: - pr_err("rxe_requester: unexpected local WR opcode = %d\n", - wqe->wr.opcode); + pr_err("rxe_requester: unexpected local" + " WR opcode = %d\n", wqe->wr.opcode); + /* these should be memory operation errors + * but there isn't one available */ wqe->status = IB_WC_LOC_QP_OP_ERR; } diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index aac50c0a43c7..49cd77cd6264 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -834,19 +834,17 @@ static enum resp_states execute(struct rxe_qp *qp, struct rxe_pkt_info *pkt) return RESPST_CLEANUP; } -static int send_invalidate(struct rxe_dev *rxe, u32 rkey) +static int send_invalidate(struct rxe_qp *qp, struct rxe_dev *rxe, u32 rkey) { int ret; struct rxe_mr *mr; struct rxe_mw *mw; - pr_info("send_invalidate: called\n"); - if ((mr = rxe_pool_get_key(&rxe->mr_pool, &rkey))) { - ret = rxe_invalidate_mr(mr, 1); + ret = rxe_invalidate_mr(qp, mr); rxe_drop_ref(mr); } else if ((mw = rxe_pool_get_key(&rxe->mw_pool, &rkey))) { - ret = rxe_invalidate_mw(mw, 1); + ret = rxe_invalidate_mw(qp, mw); rxe_drop_ref(mw); } else { pr_err("send invalidate failed for rkey = 0x%x\n", rkey); @@ -883,9 +881,9 @@ static enum resp_states do_complete(struct rxe_qp *qp, } if (pkt->mask & RXE_IETH_MASK) { - ret = send_invalidate(rxe, rkey); + ret = send_invalidate(qp, rxe, rkey); if (ret) { - pr_err("do_complete: send invalidate failed\n"); + pr_err("send with invalidate failed\n"); // TODO } } diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index b11ab3ae87a3..caaacfabadbc 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -172,8 +172,6 @@ static int rxe_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) struct rxe_dev *rxe = to_rdev(ibpd->device); struct rxe_pd *pd = to_rpd(ibpd); - pr_info("rxe_alloc_pd: called\n"); - return rxe_add_to_pool(&rxe->pd_pool, &pd->pelem); } @@ -181,8 +179,6 @@ static void rxe_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) { struct rxe_pd *pd = to_rpd(ibpd); - pr_info("rxe_dealloc_pd: called\n"); - rxe_drop_ref(pd); } @@ -414,8 +410,6 @@ static struct ib_qp *rxe_create_qp(struct ib_pd *ibpd, struct rxe_qp *qp; struct rxe_create_qp_resp __user *uresp = NULL; - pr_info("rxe_create_qp: called\n"); - if (udata) { if (udata->outlen < sizeof(*uresp)) return ERR_PTR(-EINVAL); @@ -463,8 +457,6 @@ static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, struct rxe_dev *rxe = to_rdev(ibqp->device); struct rxe_qp *qp = to_rqp(ibqp); - pr_info("rxe_modify_qp: called\n"); - err = rxe_qp_chk_attr(rxe, qp, attr, mask); if (err) goto err1; @@ -484,8 +476,6 @@ static int rxe_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, { struct rxe_qp *qp = to_rqp(ibqp); - pr_info("rxe_query_qp: called\n"); - rxe_qp_to_init(qp, init); rxe_qp_to_attr(qp, attr, mask); @@ -496,8 +486,6 @@ static int rxe_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) { struct rxe_qp *qp = to_rqp(ibqp); - pr_info("rxe_destroy_qp: called\n"); - rxe_qp_destroy(qp); rxe_drop_index(qp); rxe_drop_ref(qp); @@ -794,8 +782,6 @@ static int rxe_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, struct rxe_cq *cq = to_rcq(ibcq); struct rxe_create_cq_resp __user *uresp = NULL; - pr_info("rxe_create_cq: called\n"); - if (udata) { if (udata->outlen < sizeof(*uresp)) return -EINVAL; @@ -821,8 +807,6 @@ static void rxe_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) { struct rxe_cq *cq = to_rcq(ibcq); - pr_info("rxe_destroy_cq: called\n"); - rxe_cq_disable(cq); rxe_drop_ref(cq); @@ -862,8 +846,6 @@ static int rxe_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) struct rxe_cqe *cqe; unsigned long flags; - pr_info("rxe_poll_cq: called\n"); - spin_lock_irqsave(&cq->cq_lock, flags); for (i = 0; i < num_entries; i++) { cqe = queue_head(cq->queue); @@ -934,8 +916,6 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, struct rxe_pd *pd = to_rpd(ibpd); struct rxe_reg_mr_resp __user *uresp = NULL; - pr_info("rxe_reg_user_mr: called\n"); - if (udata) { if (udata->outlen < sizeof(*uresp)) { err = -EINVAL; @@ -980,7 +960,10 @@ static int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) { struct rxe_mr *mr = to_rmr(ibmr); - pr_info("rxe_dereg_user_mr: called\n"); + if (atomic_read(&mr->num_mw)) { + pr_err("attempt to dereg MR with bound MWs\n"); + return -EBUSY; + } mr->state = RXE_MEM_STATE_ZOMBIE; rxe_drop_ref(mr->pd); diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index ebe4157fbcdd..2fe8433d0801 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -344,6 +344,8 @@ struct rxe_mr { u32 max_buf; u32 num_map; + atomic_t num_mw; + struct rxe_map **map; }; @@ -353,11 +355,16 @@ enum rxe_mw_state { RXE_MW_STATE_VALID, }; +enum rxe_send_flags { + /* flag indicaes bind call came through verbs API */ + RXE_BIND_MW = (1 << 0), +}; + struct rxe_mw { struct rxe_pool_entry pelem; struct ib_mw ibmw; + struct rxe_mr *mr; struct rxe_qp *qp; /* type 2B only */ - struct rxe_mem *mr; spinlock_t lock; enum rxe_mw_state state; u32 access; diff --git a/include/uapi/rdma/rdma_user_rxe.h b/include/uapi/rdma/rdma_user_rxe.h index c1e84cd69c37..05fe8bef947d 100644 --- a/include/uapi/rdma/rdma_user_rxe.h +++ b/include/uapi/rdma/rdma_user_rxe.h @@ -102,6 +102,7 @@ struct rxe_send_wr { __u32 pad2; __u32 rkey; __u32 access; + __u32 flags; } umw; /* below are only used by the kernel */ struct { @@ -117,6 +118,7 @@ struct rxe_send_wr { }; __u32 rkey; __u32 access; + __u32 flags; } kmw; struct { union { From patchwork Sat Aug 15 04:58:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715823 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5239161F for ; Sat, 15 Aug 2020 22:06:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B406520639 for ; Sat, 15 Aug 2020 22:06:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jnxu74mY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729673AbgHOWGg (ORCPT ); Sat, 15 Aug 2020 18:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728236AbgHOVuu (ORCPT ); Sat, 15 Aug 2020 17:50:50 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80EC0C061245 for ; Fri, 14 Aug 2020 22:00:09 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id a24so10023116oia.6 for ; Fri, 14 Aug 2020 22:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=InR5d1hd9b3FcLVrQ7NRWlNcnQGBJgEgwy2RYEL1XZo=; b=jnxu74mYdJVmYo1k15ZooLlwGdJ98vWku7mv4wCGuSCylz4A2JBgbgKRvg/YLQqsVI kJ5Yvq2NqApYox9QVOvE2kP+IVg6Optn5NmqwX3pUBui4S2PWpKljIxLwqwXVyJLPJYv m39IKATmRH3JEPSkGBM9ODydwQtEjpz7b2A49j2bepP9U3dSZayUWaCTTdAw7aVcrlHr slv8FP5OQYZY3sOQrwG7BaDHeGIi4O99g4BbLqxNtJCiCh68hf6WdNDl+0kkgr7RZFbk vJkuN40xBTUVTZrUDIJR8uNA08jWxgaH/3WjpKkxKmFI0RXueOIrPRLa9/LFggXc+Osf GLVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=InR5d1hd9b3FcLVrQ7NRWlNcnQGBJgEgwy2RYEL1XZo=; b=DilYA1U4DcN5fSgkO98j/DU/OAQI8wHzNb8MueRCDLF2RDV3hFzbOzzwWk6XprXxJ8 h9R6XL3uNt1uKHXeeiY5mcD3Jn2hWc6NDAFJY0OJq6XOOd3WxolhodGGjpeqykvDrjQU f4/zR/Boq/tvtacWHL1IAEOh6PAktkYoEd+MRu58i8lx8wcGmh9x9yvjePtV2ebk5SUb EghUS7HCtHxQxgSVTGTQ8cSsqpK247S2BKczarWlreNT13alqkiAYG2x/saljrwzWMoK mwuVhPHHcS9EyP3yXj1KMvGuqhlbOnVVrcrtg+o50ztAhvuaYblLL15mQ+PI/dFYPn5h MpuA== X-Gm-Message-State: AOAM533TYAgA4CZWwkKHQGBxEe2bM46IQ/qc6QsunW84A6OCMEJ1Y8gK 1IWyJCt2Jhrkn6vAhccHh82QyRQCgEnBfw== X-Google-Smtp-Source: ABdhPJykrlBB7jxlE0D79tuII6qHhJY4nT9REdPMvtozxkfaCc64EY8xN6zhmdEOnc7lAEbaZN2hSQ== X-Received: by 2002:aca:306:: with SMTP id 6mr3456506oid.53.1597467608350; Fri, 14 Aug 2020 22:00:08 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id 1sm2099287otc.44.2020.08.14.22.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:08 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 18/20] cleanup Date: Fri, 14 Aug 2020 23:58:42 -0500 Message-Id: <20200815045912.8626-19-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This patch culls some left over comments and made things a little neater. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 10 +-- drivers/infiniband/sw/rxe/rxe_loc.h | 37 +++------ drivers/infiniband/sw/rxe/rxe_mr.c | 106 ++++++++++++------------ drivers/infiniband/sw/rxe/rxe_mw.c | 115 +++++++++++++++++++------- drivers/infiniband/sw/rxe/rxe_req.c | 33 +++----- drivers/infiniband/sw/rxe/rxe_resp.c | 57 ++++++++----- drivers/infiniband/sw/rxe/rxe_verbs.h | 17 ++-- 7 files changed, 208 insertions(+), 167 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index d2a094621486..ed9e27eeaadd 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -790,23 +790,19 @@ int rxe_completer(void *arg) } } - /* these are the same. need to merge them TODO */ exit: /* we come here if we are done with processing and want the task to - * exit from the loop calling us -- to call us again later - */ + * exit from the loop calling us */ WARN_ON_ONCE(skb); atomic_dec(&qp->comp.task.entered); rxe_drop_ref(qp); return -EAGAIN; done: - /* we come here if we have processed a packet we want the task to call - * us again to see if there is anything else to do - */ + /* we come here if we have processed a packet and we want + * to be called again to see if there is anything else to do */ WARN_ON_ONCE(skb); atomic_dec(&qp->comp.task.entered); rxe_drop_ref(qp); return 0; - } diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 652e0d67fe5c..2421ca311845 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -99,45 +99,26 @@ int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); /* rxe_mr.c */ void rxe_set_mr_lkey(struct rxe_mr *mr); - enum copy_direction { to_mr_obj, from_mr_obj, }; - -void rxe_mr_init_dma(struct rxe_pd *pd, - int access, struct rxe_mr *mr); - -int rxe_mr_init_user(struct rxe_pd *pd, u64 start, - u64 length, u64 iova, int access, struct ib_udata *udata, - struct rxe_mr *mr); - -int rxe_mr_init_fast(struct rxe_pd *pd, - int max_pages, struct rxe_mr *mr); - +void rxe_mr_init_dma(struct rxe_pd *pd, int access, struct rxe_mr *mr); +int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, + u64 iova, int access, struct ib_udata *udata, + struct rxe_mr *mr); +int rxe_mr_init_fast(struct rxe_pd *pd, int max_pages, struct rxe_mr *mr); int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, - int length, enum copy_direction dir, u32 *crcp); - + int length, enum copy_direction dir, u32 *crcp); int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma, void *addr, int length, enum copy_direction dir, u32 *crcp); - void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length); - -enum lookup_type { - lookup_local, - lookup_remote, -}; - -struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, - enum lookup_type type); - -int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); - void rxe_mr_cleanup(struct rxe_pool_entry *arg); - int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); int rxe_invalidate_mr(struct rxe_qp *qp, struct rxe_mr *mr); +int rxe_mr_check_access(struct rxe_qp *qp, struct rxe_mr *mr, + int access, u64 va, u32 resid); /* rxe_mw.c */ void rxe_set_mw_rkey(struct rxe_mw *mw); @@ -147,6 +128,8 @@ int rxe_dealloc_mw(struct ib_mw *ibmw); int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe); void rxe_mw_cleanup(struct rxe_pool_entry *arg); int rxe_invalidate_mw(struct rxe_qp *qp, struct rxe_mw *mw); +int rxe_mw_check_access(struct rxe_qp *qp, struct rxe_mw *mw, + int access, u64 va, u32 resid); /* rxe_net.c */ void rxe_loopback(struct sk_buff *skb); diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index a983a838bf4c..ce64d4101888 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -43,33 +43,14 @@ void rxe_set_mr_lkey(struct rxe_mr *mr) do { get_random_bytes(&lkey, sizeof(lkey)); - lkey &= 0x7fffffff; + lkey &= ~IS_MW; if (likely(lkey && (rxe_add_key(mr, &lkey) == 0))) return; } while (tries++ < 10); pr_err("unable to get random key for mr\n"); } -#if 0 -/* - * lfsr (linear feedback shift register) with period 255 - */ -static u8 rxe_get_key(void) -{ - static u32 key = 1; - - key = key << 1; - - key |= (0 != (key & 0x100)) ^ (0 != (key & 0x10)) - ^ (0 != (key & 0x80)) ^ (0 != (key & 0x40)); - - key &= 0xff; - - return key; -} -#endif - -int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length) +static int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length) { switch (mr->type) { case RXE_MEM_TYPE_DMA: @@ -430,6 +411,25 @@ int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, return err; } +static struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 lkey) +{ + struct rxe_mr *mr; + struct rxe_dev *rxe = to_rdev(pd->ibpd.device); + + mr = rxe_pool_get_key(&rxe->mr_pool, &lkey); + if (!mr) + return NULL; + + if (unlikely((mr->ibmr.lkey != lkey) || (mr->pd != pd) || + (access && !(access & mr->access)) || + (mr->state != RXE_MEM_STATE_VALID))) { + rxe_drop_ref(mr); + return NULL; + } + + return mr; +} + /* copy data in or out of a wqe, i.e. sg list * under the control of a dma descriptor */ @@ -459,7 +459,7 @@ int copy_data( } if (sge->length && (offset < sge->length)) { - mr = lookup_mr(pd, access, sge->lkey, lookup_local); + mr = lookup_mr(pd, access, sge->lkey); if (!mr) { err = -EINVAL; goto err1; @@ -484,8 +484,7 @@ int copy_data( } if (sge->length) { - mr = lookup_mr(pd, access, sge->lkey, - lookup_local); + mr = lookup_mr(pd, access, sge->lkey); if (!mr) { err = -EINVAL; goto err1; @@ -560,34 +559,6 @@ int advance_dma_data(struct rxe_dma_info *dma, unsigned int length) return 0; } -/* (1) find the mr (mr or mw) corresponding to lkey/rkey - * depending on lookup_type - * (2) verify that the (qp) pd matches the mr pd - * (3) verify that the mr can support the requested access - * (4) verify that mr state is valid - */ -struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, - enum lookup_type type) -{ - struct rxe_mr *mr; - struct rxe_dev *rxe = to_rdev(pd->ibpd.device); - - mr = rxe_pool_get_key(&rxe->mr_pool, &key); - if (!mr) - return NULL; - - if (unlikely((type == lookup_local && mr->ibmr.lkey != key) || - (type == lookup_remote && mr->ibmr.rkey != key) || - mr->pd != pd || - (access && !(access & mr->access)) || - mr->state != RXE_MEM_STATE_VALID)) { - rxe_drop_ref(mr); - mr = NULL; - } - - return mr; -} - int rxe_invalidate_mr(struct rxe_qp *qp, struct rxe_mr *mr) { // much more TODO here, can fail @@ -599,6 +570,37 @@ int rxe_invalidate_mr(struct rxe_qp *qp, struct rxe_mr *mr) return 0; } +int rxe_mr_check_access(struct rxe_qp *qp, struct rxe_mr *mr, + int access, u64 va, u32 resid) +{ + int ret; + struct rxe_pd *pd = to_rpd(mr->ibmr.pd); + + if (unlikely(mr->state != RXE_MEM_STATE_VALID)) { + pr_err("attempt to access a MR that is" + " not in the valid state\n"); + return -EINVAL; + } + + /* C10-56 */ + if (unlikely(pd != qp->pd)) { + pr_err("attempt to access a MR with a" + " different PD than the QP\n"); + return -EINVAL; + } + + /* C10-57 */ + if (unlikely(access && !(access & mr->access))) { + pr_err("attempt to access a MR that does" + " not have the required access rights\n"); + return -EINVAL; + } + + ret = mr_check_range(mr, va, resid); + + return ret; +} + void rxe_mr_cleanup(struct rxe_pool_entry *arg) { struct rxe_mr *mr = container_of(arg, typeof(*mr), pelem); diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index 0c774aadf6c7..6b998527b34b 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -44,8 +44,8 @@ void rxe_set_mw_rkey(struct rxe_mw *mw) do { get_random_bytes(&rkey, sizeof(rkey)); - rkey |= 0x80000000; - if (likely((rkey & 0x7fffffff) && + rkey |= IS_MW; + if (likely((rkey & ~IS_MW) && (rxe_add_key(mw, &rkey) == 0))) return; } while (tries++ < 10); @@ -77,10 +77,10 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, switch (type) { case IB_MW_TYPE_1: - mw->state = RXE_MW_STATE_VALID; + mw->state = RXE_MEM_STATE_VALID; break; case IB_MW_TYPE_2: - mw->state = RXE_MW_STATE_FREE; + mw->state = RXE_MEM_STATE_FREE; break; default: pr_err("attempt to allocate MW with unknown type\n"); @@ -166,7 +166,7 @@ static int check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, } if (unlikely((mw->ibmw.type == IB_MW_TYPE_1) && - (mw->state != RXE_MW_STATE_VALID))) { + (mw->state != RXE_MEM_STATE_VALID))) { pr_err("attempt to bind a type 1 MW not in the" " valid state\n"); return -EINVAL; @@ -195,7 +195,7 @@ static int check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, /* o10-37.2.30: */ if (unlikely((mw->ibmw.type == IB_MW_TYPE_2) && - (mw->state != RXE_MW_STATE_FREE))) { + (mw->state != RXE_MEM_STATE_FREE))) { pr_err("attempt to bind a type 2 MW not in the" " free state\n"); return -EINVAL; @@ -217,9 +217,6 @@ static int check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, return -EINVAL; } - /* MR duplicates address and length in the private and ib - * parts of the rxe_mr struct. TODO should only keep one. */ - /* C10-75: */ if (mw->access & IB_ZERO_BASED) { if (unlikely(wqe->wr.wr.umw.length > mr->length)) { @@ -240,13 +237,29 @@ static int check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, return 0; } -static void do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, +static int do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, struct rxe_mw *mw, struct rxe_mr *mr) { + int ret; u32 rkey; + u32 new_rkey; + + /* key part of new rkey is provided by user for type 2 + * and ibv_bind_mw() for type 1 MWs */ + rkey = mw->ibmw.rkey; + rxe_drop_key(mw); + new_rkey = (rkey & 0xffffff00) | (wqe->wr.wr.umw.rkey & 0x000000ff); + ret = rxe_add_key(mw, &new_rkey); + if (ret) { + /* this should never happen */ + pr_err("shouldn't happen unable to set new rkey\n"); + /* try to put back the old one */ + rxe_add_key(mw, &rkey); + return ret; + } mw->access = wqe->wr.wr.umw.access; - mw->state = RXE_MW_STATE_VALID; + mw->state = RXE_MEM_STATE_VALID; mw->addr = wqe->wr.wr.umw.addr; mw->length = wqe->wr.wr.umw.length; @@ -272,14 +285,7 @@ static void do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, mw->qp = qp; } - /* key part of new rkey is provided by user for type 2 - * and ibv_bind_mw() for type 1 MWs */ - rkey = mw->ibmw.rkey; - rxe_drop_key(mw); - rkey = (rkey & 0xffffff00) | (wqe->wr.wr.umw.rkey & 0x000000ff); - rxe_add_key(mw, &rkey); - - return; + return 0; } int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) @@ -326,7 +332,7 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) goto err3; /* implement the change */ - do_bind_mw(qp, wqe, mw, mr); + ret = do_bind_mw(qp, wqe, mw, mr); err3: spin_unlock_irqrestore(&mw->lock, flags); @@ -340,15 +346,15 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) static int check_invalidate_mw(struct rxe_qp *qp, struct rxe_mw *mw) { - /* o10-37.2.26: */ - if (unlikely(mw->ibmw.type == IB_MW_TYPE_1)) { - pr_err("attempt to invalidate a type 1 MW\n"); + if (unlikely(mw->state != RXE_MEM_STATE_VALID)) { + pr_warn("attempt to invalidate a MW that" + " is not valid\n"); return -EINVAL; } - if (unlikely(mw->state != RXE_MW_STATE_VALID)) { - pr_warn("attempt to invalidate a MW that" - " is not valid\n"); + /* o10-37.2.26: */ + if (unlikely(mw->ibmw.type == IB_MW_TYPE_1)) { + pr_err("attempt to invalidate a type 1 MW\n"); return -EINVAL; } @@ -366,7 +372,7 @@ static void do_invalidate_mw(struct rxe_mw *mw) mw->access = 0; mw->addr = 0; mw->length = 0; - mw->state = RXE_MW_STATE_FREE; + mw->state = RXE_MEM_STATE_FREE; } int rxe_invalidate_mw(struct rxe_qp *qp, struct rxe_mw *mw) @@ -387,7 +393,7 @@ int rxe_invalidate_mw(struct rxe_qp *qp, struct rxe_mw *mw) return ret; } -static void do_deallocate_mw(struct rxe_mw *mw) +static void do_dealloc_mw(struct rxe_mw *mw) { mw->qp = NULL; @@ -397,10 +403,11 @@ static void do_deallocate_mw(struct rxe_mw *mw) mw->mr = NULL; } + mw->ibmw.pd = NULL; mw->access = 0; mw->addr = 0; mw->length = 0; - mw->state = RXE_MW_STATE_INVALID; + mw->state = RXE_MEM_STATE_INVALID; } int rxe_dealloc_mw(struct ib_mw *ibmw) @@ -411,7 +418,7 @@ int rxe_dealloc_mw(struct ib_mw *ibmw) spin_lock_irqsave(&mw->lock, flags); - do_deallocate_mw(mw); + do_dealloc_mw(mw); spin_unlock_irqrestore(&mw->lock, flags); @@ -421,6 +428,54 @@ int rxe_dealloc_mw(struct ib_mw *ibmw) return 0; } +int rxe_mw_check_access(struct rxe_qp *qp, struct rxe_mw *mw, + int access, u64 va, u32 resid) +{ + struct rxe_pd *pd = to_rpd(mw->ibmw.pd); + + if (unlikely(mw->state != RXE_MEM_STATE_VALID)) { + pr_err("attempt to access a MW that is" + " not in the valid state\n"); + return -EINVAL; + } + + /* C10-76.2.1 */ + if (unlikely((mw->ibmw.type == IB_MW_TYPE_1) && (pd != qp->pd))) { + pr_err("attempt to access a type 1 MW with a" + " different PD than the QP\n"); + return -EINVAL; + } + + /* o10-37.2.43 */ + if (unlikely((mw->ibmw.type == IB_MW_TYPE_2) && (mw->qp != qp))) { + pr_err("attempt to access a type 2 MW that is" + " associated with a different QP\n"); + return -EINVAL; + } + + /* C10-77 */ + if (unlikely(access && !(access & mw->access))) { + pr_err("attempt to access a MW that does" + " not have the required access rights\n"); + return -EINVAL; + } + + if (mw->access & IB_ZERO_BASED) { + if (unlikely((va + resid) > mw->length)) { + pr_err("attempt to access a MW out of bounds\n"); + return -EINVAL; + } + } else { + if (unlikely((va < mw->addr) || + ((va + resid) > (mw->addr + mw->length)))) { + pr_err("attempt to access a MW out of bounds\n"); + return -EINVAL; + } + } + + return 0; +} + void rxe_mw_cleanup(struct rxe_pool_entry *arg) { struct rxe_mw *mw = container_of(arg, typeof(*mw), pelem); diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index ad747f230318..f0fa195fcc70 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -591,7 +591,7 @@ static int local_invalidate(struct rxe_qp *qp, struct rxe_send_wqe *wqe) struct rxe_dev *rxe = to_rdev(qp->ibqp.device); u32 key = wqe->wr.ex.invalidate_rkey; - if ((mr = rxe_pool_get_key(&rxe->mr_pool, &key))) { + if (!(key & IS_MW) && (mr = rxe_pool_get_key(&rxe->mr_pool, &key))) { ret = rxe_invalidate_mr(qp, mr); rxe_drop_ref(mr); } else if ((mw = rxe_pool_get_key(&rxe->mw_pool, &key))) { @@ -732,12 +732,7 @@ int rxe_requester(void *arg) payload = (mask & RXE_WRITE_OR_SEND) ? wqe->dma.resid : 0; if (payload > mtu) { if (qp_type(qp) == IB_QPT_UD) { - /* C10-93.1.1: If the total sum of all the buffer lengths specified for a - * UD message exceeds the MTU of the port as returned by QueryHCA, the CI - * shall not emit any packets for this message. Further, the CI shall not - * generate an error due to this condition. - */ - + /* C10-93.1.1 */ /* fake a successful UD send */ wqe->first_psn = qp->req.psn; wqe->last_psn = qp->req.psn; @@ -747,8 +742,13 @@ int rxe_requester(void *arg) qp->req.wqe_index); wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; - // TODO why?? why not just treat the same as a - // successful wqe and go to next wqe? + + /* TODO why?? why not just treat the same as a + * successful wqe and go to next wqe? + * __rxe_do_task probably shouldn't be used + * it reenters the completion task which may + * already be running + */ __rxe_do_task(&qp->comp.task); goto again; } @@ -789,7 +789,7 @@ int rxe_requester(void *arg) goto exit; } - wqe->status = IB_WC_LOC_PROT_ERR; // ?? FIXME + wqe->status = IB_WC_LOC_PROT_ERR; goto err; } @@ -797,17 +797,12 @@ int rxe_requester(void *arg) goto next_wqe; - // TODO this can be cleaned up err: /* we come here if an error occured while processing * a send wqe. The completer will put the qp in error * state and no more wqes will be processed unless - * the qp is cleaned up and restarted. We do not want - * to be called again */ + * the qp is cleaned up and restarted. */ wqe->state = wqe_state_error; - // ?? we want to force the qp into error state before - // anyone else has a chance to process another wqe but - // this could collide with an already running completer __rxe_do_task(&qp->comp.task); ret = -EAGAIN; goto done; @@ -816,14 +811,12 @@ int rxe_requester(void *arg) /* we come here if either there are no more wqes in the send * queue or we are blocked waiting for some resource or event. * The current wqe will be restarted or new wqe started when - * there is work to do. */ + * there is something to do. */ ret = -EAGAIN; goto done; again: - /* we come here if we are done with the current wqe but want to - * get called again. Mostly we loop back to next wqe so should - * be all one way or the other */ + /* we come here if we need to exit and reenter the task */ ret = 0; goto done; diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index 49cd77cd6264..0bfea50505d1 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -417,7 +417,9 @@ static enum resp_states check_length(struct rxe_qp *qp, static enum resp_states check_rkey(struct rxe_qp *qp, struct rxe_pkt_info *pkt) { - struct rxe_mr *mr = NULL; + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); + struct rxe_mr *mr; + struct rxe_mw *mw; u64 va; u32 rkey; u32 resid; @@ -425,6 +427,7 @@ static enum resp_states check_rkey(struct rxe_qp *qp, int mtu = qp->mtu; enum resp_states state; int access; + unsigned long flags; if (pkt->mask & (RXE_READ_MASK | RXE_WRITE_MASK)) { if (pkt->mask & RXE_RETH_MASK) { @@ -432,13 +435,16 @@ static enum resp_states check_rkey(struct rxe_qp *qp, qp->resp.rkey = reth_rkey(pkt); qp->resp.resid = reth_len(pkt); qp->resp.length = reth_len(pkt); + qp->resp.offset = 0; } - access = (pkt->mask & RXE_READ_MASK) ? IB_ACCESS_REMOTE_READ - : IB_ACCESS_REMOTE_WRITE; + access = (pkt->mask & RXE_READ_MASK) + ? IB_ACCESS_REMOTE_READ + : IB_ACCESS_REMOTE_WRITE; } else if (pkt->mask & RXE_ATOMIC_MASK) { qp->resp.va = atmeth_va(pkt); qp->resp.rkey = atmeth_rkey(pkt); qp->resp.resid = sizeof(u64); + qp->resp.offset = 0; access = IB_ACCESS_REMOTE_ATOMIC; } else { return RESPST_EXECUTE; @@ -456,18 +462,31 @@ static enum resp_states check_rkey(struct rxe_qp *qp, resid = qp->resp.resid; pktlen = payload_size(pkt); - mr = lookup_mr(qp->pd, access, rkey, lookup_remote); - if (!mr) { - state = RESPST_ERR_RKEY_VIOLATION; - goto err; - } + if ((rkey & IS_MW) && (mw = rxe_pool_get_key(&rxe->mw_pool, &rkey))) { + spin_lock_irqsave(&mw->lock, flags); + if (rxe_mw_check_access(qp, mw, access, va, resid)) { + spin_unlock_irqrestore(&mw->lock, flags); + rxe_drop_ref(mw); + state = RESPST_ERR_RKEY_VIOLATION; + goto err; + } - if (unlikely(mr->state == RXE_MEM_STATE_FREE)) { - state = RESPST_ERR_RKEY_VIOLATION; - goto err; - } + mr = mw->mr; + rxe_add_ref(mr); + + if (mw->access & IB_ZERO_BASED) + qp->resp.offset = mw->addr; - if (mr_check_range(mr, va, resid)) { + spin_unlock_irqrestore(&mw->lock, flags); + rxe_drop_ref(mw); + } else if ((mr = rxe_pool_get_key(&rxe->mr_pool, &rkey)) && + (mr->rkey == rkey)) { + if (rxe_mr_check_access(qp, mr, access, va, resid)) { + state = RESPST_ERR_RKEY_VIOLATION; + goto err; + } + } else { + pr_err("no MR/MW found with rkey = 0x%08x\n", rkey); state = RESPST_ERR_RKEY_VIOLATION; goto err; } @@ -525,8 +544,8 @@ static enum resp_states write_data_in(struct rxe_qp *qp, int err; int data_len = payload_size(pkt); - err = rxe_mr_copy(qp->resp.mr, qp->resp.va, payload_addr(pkt), - data_len, to_mr_obj, NULL); + err = rxe_mr_copy(qp->resp.mr, qp->resp.va + qp->resp.offset, + payload_addr(pkt), data_len, to_mr_obj, NULL); if (err) { rc = RESPST_ERR_RKEY_VIOLATION; goto out; @@ -545,17 +564,11 @@ static DEFINE_SPINLOCK(atomic_ops_lock); static enum resp_states process_atomic(struct rxe_qp *qp, struct rxe_pkt_info *pkt) { - u64 iova = atmeth_va(pkt); u64 *vaddr; enum resp_states ret; struct rxe_mr *mr = qp->resp.mr; - if (mr->state != RXE_MEM_STATE_VALID) { - ret = RESPST_ERR_RKEY_VIOLATION; - goto out; - } - - vaddr = iova_to_vaddr(mr, iova, sizeof(u64)); + vaddr = iova_to_vaddr(mr, qp->resp.va + qp->resp.offset, sizeof(u64)); /* check vaddr is 8 bytes aligned. */ if (!vaddr || (uintptr_t)vaddr & 7) { diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index 2fe8433d0801..b4855d3ea6f4 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -210,6 +210,7 @@ struct rxe_resp_info { /* RDMA read / atomic only */ u64 va; + u64 offset; struct rxe_mr *mr; u32 resid; u32 rkey; @@ -289,7 +290,8 @@ struct rxe_qp { struct execute_work cleanup_work; }; -enum rxe_mr_state { +/* common state for rxe_mr and rxe_mw */ +enum rxe_mem_state { RXE_MEM_STATE_ZOMBIE, RXE_MEM_STATE_INVALID, RXE_MEM_STATE_FREE, @@ -325,7 +327,7 @@ struct rxe_mr { u32 lkey; u32 rkey; - enum rxe_mr_state state; + enum rxe_mem_state state; enum rxe_mr_type type; u64 va; u64 iova; @@ -349,24 +351,21 @@ struct rxe_mr { struct rxe_map **map; }; -enum rxe_mw_state { - RXE_MW_STATE_INVALID, - RXE_MW_STATE_FREE, - RXE_MW_STATE_VALID, -}; - enum rxe_send_flags { /* flag indicaes bind call came through verbs API */ RXE_BIND_MW = (1 << 0), }; +/* use high order bit to separate MW and MR rkeys */ +#define IS_MW (1 << 31) + struct rxe_mw { struct rxe_pool_entry pelem; struct ib_mw ibmw; struct rxe_mr *mr; struct rxe_qp *qp; /* type 2B only */ spinlock_t lock; - enum rxe_mw_state state; + enum rxe_mem_state state; u32 access; u64 addr; u64 length; From patchwork Sat Aug 15 04:58:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715685 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A2FD913 for ; Sat, 15 Aug 2020 21:53:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70552204FD for ; Sat, 15 Aug 2020 21:53:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q5888Tf0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726708AbgHOVxj (ORCPT ); Sat, 15 Aug 2020 17:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729148AbgHOVwl (ORCPT ); Sat, 15 Aug 2020 17:52:41 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B50BDC061246 for ; Fri, 14 Aug 2020 22:00:09 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id v21so9247900otj.9 for ; Fri, 14 Aug 2020 22:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I02BPlvFy618itBX0mtykTToAXHctOOIS2ZLlT6vRJk=; b=Q5888Tf00gbqvTzCMbG6sF/oQLu8rDP5TTkp/YhE0Mu8qi9reUTfEaIMHqR/v6yq9p NSEkRSxTIbM4wVdBCrkgAnr3CsHV1ESW4m3d0HoCF1h4izI/dE8/UQr1ipc+UgR1eCLI eTt/GMoWym03yXmnbf6bnbpaLNYZT3V1aRQjcWCYewi1R3YhMhovjtbyvrqPda/5O1TD 2cwmKg6dIs35zPeOhc2Pvu9Wd/UbtDMcO3UmUCfMb3YZZXihI9Jco0aRxwdoiDL9e1ox bGsVbcWuIfThkpLVgGkGFGgSN+SHApjYS4S9JOPbP8Tgf4KFa7Ra+e36tvBf8ef8cgdX ZyzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I02BPlvFy618itBX0mtykTToAXHctOOIS2ZLlT6vRJk=; b=XCZc52jh4kcMHIUdj/ajcSlNq7uNn92KF4PeGUpF5TxboAkgVo3VC0OiIBNiShrL7B OrpBDZpSpwK5BIulXkO530jN/sliIumbgLd6jqyDpa2gXFWiFhbSQ3dlgm45oCFfRwjY dVkF+/w9/b5MTPVmv2lH7KGJFS/zTetLNbPtrUDe9U19KkJy8t5oh+kdU6YfkOt4twhr fqgbZjdZgYg0fw/cx952A9RmZWbJOaeNlYBljpPgSlHf910vrtZLVhvtzjw0wIuP73Pv DRbHGyjI6Bql4hU9tFE+uBN3UGdRczjYAQ19UUCTltBVbAFRACbabY9RhAQEQz9+t70z FUdw== X-Gm-Message-State: AOAM531pueb/YrV89Ym0gJUt8EpaxY1j2H6jikV4Xfp+g5CMvcqS70nB 9TSUEGKXOHx+6CHaYu+X3STHNEsoWTpCKQ== X-Google-Smtp-Source: ABdhPJzBmHjlYbwpPnAMNlyp7T4vmCIYr5gz3gv23YrspzfeLfwEFYOfGzfjz+dVSJ7QLL+1fT2YIA== X-Received: by 2002:a9d:2f23:: with SMTP id h32mr4370729otb.334.1597467609042; Fri, 14 Aug 2020 22:00:09 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id l17sm2125126otn.2.2020.08.14.22.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:08 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 19/20] fixed white space issues Date: Fri, 14 Aug 2020 23:58:43 -0500 Message-Id: <20200815045912.8626-20-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Checkpatch reported some trailing whitespace. Trying to fix that here. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_mw.c | 4 ++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index 6b998527b34b..ae7f5710f7dd 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -370,7 +370,7 @@ static void do_invalidate_mw(struct rxe_mw *mw) mw->mr = NULL; mw->access = 0; - mw->addr = 0; + mw->addr = 0; mw->length = 0; mw->state = RXE_MEM_STATE_FREE; } @@ -405,7 +405,7 @@ static void do_dealloc_mw(struct rxe_mw *mw) mw->ibmw.pd = NULL; mw->access = 0; - mw->addr = 0; + mw->addr = 0; mw->length = 0; mw->state = RXE_MEM_STATE_INVALID; } diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index b4855d3ea6f4..c990654e396d 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -66,7 +66,7 @@ struct rxe_ucontext { }; struct rxe_pd { - struct ib_pd ibpd; + struct ib_pd ibpd; struct rxe_pool_entry pelem; }; @@ -309,8 +309,8 @@ enum rxe_mr_type { #define RXE_BUF_PER_MAP (PAGE_SIZE / sizeof(struct rxe_phys_buf)) struct rxe_phys_buf { - u64 addr; - u64 size; + u64 addr; + u64 size; }; struct rxe_map { From patchwork Sat Aug 15 04:58:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 11715825 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A279F109B for ; Sat, 15 Aug 2020 22:06:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6820220639 for ; Sat, 15 Aug 2020 22:06:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XaHxxkSM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729494AbgHOWGg (ORCPT ); Sat, 15 Aug 2020 18:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728398AbgHOVuu (ORCPT ); Sat, 15 Aug 2020 17:50:50 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8488DC061247 for ; Fri, 14 Aug 2020 22:00:13 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id v21so9247994otj.9 for ; Fri, 14 Aug 2020 22:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eRibimADuzuSML9VI3K1x9yLKpeJEahrh1omDAsSoUw=; b=XaHxxkSMWcVsVPUB7h+hQc+7B+fn2rFH4Lzlpdp8DDUie4WMMbTF9cETklMWlRhAAI BnjcbPlUwG2SOgQIBlgcqXlVgmenOIekihQgIwLDfkoOF+WSb5wvQdeKinZc7mnm2cpj yhdQIZuHFcvTEtSBOWtyTJr2miDMuA5EBD9U8eZXAC/o3pfQGx9lCFX6tw8bJcGVkguf zsMGO4oGH0hC6oSRL8VWL3H6i6/6JKC7xnFb46q6x/1cY/CIbuVUrC2Ngut4M1JN4Qgo Y/M7ILOpcUw4FwpPdgDGFFa7MZLqIdjMdqt6TNDPtI28pexfde69aacOTEop9ef3jt8J ZAlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eRibimADuzuSML9VI3K1x9yLKpeJEahrh1omDAsSoUw=; b=uUNhnd8qTFLs8rjeccSKMAY5PzMWj/rV8JaYMRof8GAhnbWnDQFkmWshwxQBQQtmqn 7j2q3FiCAgP8kJAHQe6lqEfA3sU/Ua5wKcQ7xYg3lDH/7BNj05Qq7NrTJQkitZ9U30wa P2RJBGgxMRJxtcM10vSbmROY9q/cICgdF8NTI7WzsHQ2mAIONyN8oiN2QBTvPWmP/c9P wWcJ/XMH6Z7DDsqzb/sp+sQrAXy3OmnfB88Hy+Jm2hBeKO6XWnJEUCO8MEjEO9XFnHqr SLo2OO0nNp5gpxXM71dmMkRHPFe67mU6QC56LaFBeS+3r9+69CoDLg4Tl+aQXm+F27hh kDJw== X-Gm-Message-State: AOAM530r3Bfx1QW0SGM5/B6shAAu7XrMNJuTph1GrmmGeSGNA8lZXVU4 +rZ9Bt4P38xfwniPHQPNTff2z7qUptQaaA== X-Google-Smtp-Source: ABdhPJxtT1L5qLV71UVYoVtBs7Ncyx0cfEn6G28op9QzW8076jgzeQQrI565asRLShQB5tWLsz+6PQ== X-Received: by 2002:a9d:824:: with SMTP id 33mr4494069oty.35.1597467609904; Fri, 14 Aug 2020 22:00:09 -0700 (PDT) Received: from localhost ([2605:6000:8b03:f000:b453:c5f2:2895:a54c]) by smtp.gmail.com with ESMTPSA id y15sm2089618oto.60.2020.08.14.22.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 22:00:09 -0700 (PDT) From: Bob Pearson X-Google-Original-From: Bob Pearson To: linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH 20/20] fixed checkpatch issues for all files in rxe Date: Fri, 14 Aug 2020 23:58:44 -0500 Message-Id: <20200815045912.8626-21-rpearson@hpe.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200815045912.8626-1-rpearson@hpe.com> References: <20200815045912.8626-1-rpearson@hpe.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Went through all the files in the rxe dirextory and fixed all issues reported by checkpatch. Removed remaining debugging code. Added SPDX headers. Signed-off-by: Bob Pearson Reported-by: kernel test robot --- drivers/infiniband/sw/rxe/rxe.c | 31 +--- drivers/infiniband/sw/rxe/rxe.h | 31 +--- drivers/infiniband/sw/rxe/rxe_av.c | 31 +--- drivers/infiniband/sw/rxe/rxe_comp.c | 54 ++---- drivers/infiniband/sw/rxe/rxe_cq.c | 31 +--- drivers/infiniband/sw/rxe/rxe_hdr.h | 67 +++----- drivers/infiniband/sw/rxe/rxe_hw_counters.c | 61 ++----- drivers/infiniband/sw/rxe/rxe_hw_counters.h | 31 +--- drivers/infiniband/sw/rxe/rxe_icrc.c | 31 +--- drivers/infiniband/sw/rxe/rxe_loc.h | 38 +---- drivers/infiniband/sw/rxe/rxe_mcast.c | 31 +--- drivers/infiniband/sw/rxe/rxe_mmap.c | 31 +--- drivers/infiniband/sw/rxe/rxe_mr.c | 59 ++----- drivers/infiniband/sw/rxe/rxe_mw.c | 176 ++++++++------------ drivers/infiniband/sw/rxe/rxe_net.c | 37 +--- drivers/infiniband/sw/rxe/rxe_net.h | 31 +--- drivers/infiniband/sw/rxe/rxe_opcode.c | 33 +--- drivers/infiniband/sw/rxe/rxe_opcode.h | 31 +--- drivers/infiniband/sw/rxe/rxe_param.h | 31 +--- drivers/infiniband/sw/rxe/rxe_pool.c | 43 +---- drivers/infiniband/sw/rxe/rxe_pool.h | 31 +--- drivers/infiniband/sw/rxe/rxe_qp.c | 53 ++---- drivers/infiniband/sw/rxe/rxe_queue.c | 31 +--- drivers/infiniband/sw/rxe/rxe_queue.h | 31 +--- drivers/infiniband/sw/rxe/rxe_recv.c | 31 +--- drivers/infiniband/sw/rxe/rxe_req.c | 122 ++++++-------- drivers/infiniband/sw/rxe/rxe_resp.c | 170 +++++++++---------- drivers/infiniband/sw/rxe/rxe_srq.c | 31 +--- drivers/infiniband/sw/rxe/rxe_sysfs.c | 34 +--- drivers/infiniband/sw/rxe/rxe_task.c | 31 +--- drivers/infiniband/sw/rxe/rxe_task.h | 33 +--- drivers/infiniband/sw/rxe/rxe_verbs.c | 51 ++---- drivers/infiniband/sw/rxe/rxe_verbs.h | 34 +--- 33 files changed, 384 insertions(+), 1208 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c index 25bd25371f8e..97ed495c840e 100644 --- a/drivers/infiniband/sw/rxe/rxe.c +++ b/drivers/infiniband/sw/rxe/rxe.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include diff --git a/drivers/infiniband/sw/rxe/rxe.h b/drivers/infiniband/sw/rxe/rxe.h index fb07eed9e402..87a75943ac27 100644 --- a/drivers/infiniband/sw/rxe/rxe.h +++ b/drivers/infiniband/sw/rxe/rxe.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_H diff --git a/drivers/infiniband/sw/rxe/rxe_av.c b/drivers/infiniband/sw/rxe/rxe_av.c index 81ee756c19b8..9ab524ae4517 100644 --- a/drivers/infiniband/sw/rxe/rxe_av.c +++ b/drivers/infiniband/sw/rxe/rxe_av.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_av.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include "rxe.h" diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index ed9e27eeaadd..681e2b9811f2 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_comp.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include @@ -563,21 +538,13 @@ int rxe_completer(void *arg) struct sk_buff *skb = NULL; struct rxe_pkt_info *pkt = NULL; enum comp_state state; - int entered; rxe_add_ref(qp); - // this code is 'guaranteed' to never be entered more - // than once. Check to make sure that this is the case - entered = atomic_inc_return(&qp->comp.task.entered); - if (entered > 1) { - pr_err("rxe_completer: entered %d times\n", entered); - } - if (!qp->valid || qp->req.state == QP_STATE_ERROR || qp->req.state == QP_STATE_RESET) { - rxe_drain_resp_pkts(qp, qp->valid && - qp->req.state == QP_STATE_ERROR); + rxe_drain_resp_pkts(qp, qp->valid && + qp->req.state == QP_STATE_ERROR); goto exit; } @@ -699,9 +666,8 @@ int rxe_completer(void *arg) */ /* there is nothing to retry in this case */ - if (!wqe || (wqe->state == wqe_state_posted)) { + if (!wqe || (wqe->state == wqe_state_posted)) goto exit; - } /* if we've started a retry, don't start another * retry sequence, unless this is a timeout. @@ -792,17 +758,17 @@ int rxe_completer(void *arg) exit: /* we come here if we are done with processing and want the task to - * exit from the loop calling us */ + * exit from the loop calling us + */ WARN_ON_ONCE(skb); - atomic_dec(&qp->comp.task.entered); rxe_drop_ref(qp); return -EAGAIN; done: /* we come here if we have processed a packet and we want - * to be called again to see if there is anything else to do */ + * to be called again to see if there is anything else to do + */ WARN_ON_ONCE(skb); - atomic_dec(&qp->comp.task.entered); rxe_drop_ref(qp); return 0; } diff --git a/drivers/infiniband/sw/rxe/rxe_cq.c b/drivers/infiniband/sw/rxe/rxe_cq.c index ad3090131126..20e4d8bfd2e7 100644 --- a/drivers/infiniband/sw/rxe/rxe_cq.c +++ b/drivers/infiniband/sw/rxe/rxe_cq.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_cq.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include #include "rxe.h" diff --git a/drivers/infiniband/sw/rxe/rxe_hdr.h b/drivers/infiniband/sw/rxe/rxe_hdr.h index ce003666b800..3edd49bb331c 100644 --- a/drivers/infiniband/sw/rxe/rxe_hdr.h +++ b/drivers/infiniband/sw/rxe/rxe_hdr.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_hdr.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_HDR_H @@ -83,9 +58,9 @@ static inline struct sk_buff *PKT_TO_SKB(struct rxe_pkt_info *pkt) #define RXE_ICRC_SIZE (4) #define RXE_MAX_HDR_LENGTH (80) -/****************************************************************************** +/* * Base Transport Header - ******************************************************************************/ + */ struct rxe_bth { u8 opcode; u8 flags; @@ -450,9 +425,9 @@ static inline void bth_init(struct rxe_pkt_info *pkt, u8 opcode, int se, bth->apsn = cpu_to_be32(psn); } -/****************************************************************************** +/* * Reliable Datagram Extended Transport Header - ******************************************************************************/ + */ struct rxe_rdeth { __be32 een; }; @@ -485,9 +460,9 @@ static inline void rdeth_set_een(struct rxe_pkt_info *pkt, u32 een) + rxe_opcode[pkt->opcode].offset[RXE_RDETH], een); } -/****************************************************************************** +/* * Datagram Extended Transport Header - ******************************************************************************/ + */ struct rxe_deth { __be32 qkey; __be32 sqp; @@ -548,9 +523,9 @@ static inline void deth_set_sqp(struct rxe_pkt_info *pkt, u32 sqp) + rxe_opcode[pkt->opcode].offset[RXE_DETH], sqp); } -/****************************************************************************** +/* * RDMA Extended Transport Header - ******************************************************************************/ + */ struct rxe_reth { __be64 va; __be32 rkey; @@ -635,9 +610,9 @@ static inline void reth_set_len(struct rxe_pkt_info *pkt, u32 len) + rxe_opcode[pkt->opcode].offset[RXE_RETH], len); } -/****************************************************************************** +/* * Atomic Extended Transport Header - ******************************************************************************/ + */ struct rxe_atmeth { __be64 va; __be32 rkey; @@ -749,9 +724,9 @@ static inline void atmeth_set_comp(struct rxe_pkt_info *pkt, u64 comp) + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], comp); } -/****************************************************************************** +/* * Ack Extended Transport Header - ******************************************************************************/ + */ struct rxe_aeth { __be32 smsn; }; @@ -829,9 +804,9 @@ static inline void aeth_set_msn(struct rxe_pkt_info *pkt, u32 msn) + rxe_opcode[pkt->opcode].offset[RXE_AETH], msn); } -/****************************************************************************** +/* * Atomic Ack Extended Transport Header - ******************************************************************************/ + */ struct rxe_atmack { __be64 orig; }; @@ -862,9 +837,9 @@ static inline void atmack_set_orig(struct rxe_pkt_info *pkt, u64 orig) + rxe_opcode[pkt->opcode].offset[RXE_ATMACK], orig); } -/****************************************************************************** +/* * Immediate Extended Transport Header - ******************************************************************************/ + */ struct rxe_immdt { __be32 imm; }; @@ -895,9 +870,9 @@ static inline void immdt_set_imm(struct rxe_pkt_info *pkt, __be32 imm) + rxe_opcode[pkt->opcode].offset[RXE_IMMDT], imm); } -/****************************************************************************** +/* * Invalidate Extended Transport Header - ******************************************************************************/ + */ struct rxe_ieth { __be32 rkey; }; diff --git a/drivers/infiniband/sw/rxe/rxe_hw_counters.c b/drivers/infiniband/sw/rxe/rxe_hw_counters.c index 636edb5f4cf4..d61e484f034e 100644 --- a/drivers/infiniband/sw/rxe/rxe_hw_counters.c +++ b/drivers/infiniband/sw/rxe/rxe_hw_counters.c @@ -1,54 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* - * Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: + * drivers/infiniband/sw/rxe/rxe_hw_counters.c * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved. */ #include "rxe.h" #include "rxe_hw_counters.h" static const char * const rxe_counter_name[] = { - [RXE_CNT_SENT_PKTS] = "sent_pkts", - [RXE_CNT_RCVD_PKTS] = "rcvd_pkts", - [RXE_CNT_DUP_REQ] = "duplicate_request", - [RXE_CNT_OUT_OF_SEQ_REQ] = "out_of_seq_request", - [RXE_CNT_RCV_RNR] = "rcvd_rnr_err", - [RXE_CNT_SND_RNR] = "send_rnr_err", - [RXE_CNT_RCV_SEQ_ERR] = "rcvd_seq_err", - [RXE_CNT_COMPLETER_SCHED] = "ack_deferred", - [RXE_CNT_RETRY_EXCEEDED] = "retry_exceeded_err", - [RXE_CNT_RNR_RETRY_EXCEEDED] = "retry_rnr_exceeded_err", - [RXE_CNT_COMP_RETRY] = "completer_retry_err", - [RXE_CNT_SEND_ERR] = "send_err", - [RXE_CNT_LINK_DOWNED] = "link_downed", - [RXE_CNT_RDMA_SEND] = "rdma_sends", - [RXE_CNT_RDMA_RECV] = "rdma_recvs", + [RXE_CNT_SENT_PKTS] = "sent_pkts", + [RXE_CNT_RCVD_PKTS] = "rcvd_pkts", + [RXE_CNT_DUP_REQ] = "duplicate_request", + [RXE_CNT_OUT_OF_SEQ_REQ] = "out_of_seq_request", + [RXE_CNT_RCV_RNR] = "rcvd_rnr_err", + [RXE_CNT_SND_RNR] = "send_rnr_err", + [RXE_CNT_RCV_SEQ_ERR] = "rcvd_seq_err", + [RXE_CNT_COMPLETER_SCHED] = "ack_deferred", + [RXE_CNT_RETRY_EXCEEDED] = "retry_exceeded_err", + [RXE_CNT_RNR_RETRY_EXCEEDED] = "retry_rnr_exceeded_err", + [RXE_CNT_COMP_RETRY] = "completer_retry_err", + [RXE_CNT_SEND_ERR] = "send_err", + [RXE_CNT_LINK_DOWNED] = "link_downed", + [RXE_CNT_RDMA_SEND] = "rdma_sends", + [RXE_CNT_RDMA_RECV] = "rdma_recvs", }; int rxe_ib_get_hw_stats(struct ib_device *ibdev, diff --git a/drivers/infiniband/sw/rxe/rxe_hw_counters.h b/drivers/infiniband/sw/rxe/rxe_hw_counters.h index 72c0d63c79e0..a3c26f66a76c 100644 --- a/drivers/infiniband/sw/rxe/rxe_hw_counters.h +++ b/drivers/infiniband/sw/rxe/rxe_hw_counters.h @@ -1,33 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* - * Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: + * drivers/infiniband/sw/rxe/rxe_hw_counters.h * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved. */ #ifndef RXE_HW_COUNTERS_H diff --git a/drivers/infiniband/sw/rxe/rxe_icrc.c b/drivers/infiniband/sw/rxe/rxe_icrc.c index 39e0be31aab1..d02eca260053 100644 --- a/drivers/infiniband/sw/rxe/rxe_icrc.c +++ b/drivers/infiniband/sw/rxe/rxe_icrc.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_icrc.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include "rxe.h" diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 2421ca311845..e0f566b48c71 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_loc.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_LOC_H @@ -145,8 +120,8 @@ int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid); /* rxe_qp.c */ int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init); -int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, - struct ib_qp_init_attr *init, +int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, + struct rxe_pd *pd, struct ib_qp_init_attr *init, struct rxe_create_qp_resp __user *uresp, struct ib_pd *ibpd, struct ib_udata *udata); @@ -219,7 +194,8 @@ int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq, int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq, struct ib_srq_attr *attr, enum ib_srq_attr_mask mask, - struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata); + struct rxe_modify_srq_cmd *ucmd, + struct ib_udata *udata); void rxe_dealloc(struct ib_device *ib_dev); diff --git a/drivers/infiniband/sw/rxe/rxe_mcast.c b/drivers/infiniband/sw/rxe/rxe_mcast.c index 522a7942c56c..244e47759aa2 100644 --- a/drivers/infiniband/sw/rxe/rxe_mcast.c +++ b/drivers/infiniband/sw/rxe/rxe_mcast.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_mcast.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include "rxe.h" diff --git a/drivers/infiniband/sw/rxe/rxe_mmap.c b/drivers/infiniband/sw/rxe/rxe_mmap.c index 7887f623f62c..0640578c1ae3 100644 --- a/drivers/infiniband/sw/rxe/rxe_mmap.c +++ b/drivers/infiniband/sw/rxe/rxe_mmap.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_mmap.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index ce64d4101888..e49251ed38a4 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -1,41 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_mr.c + * + * Copyright (c) 2020 Hewlett Packard Enterprise, Inc. All rights reserved. * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include "rxe.h" #include "rxe_loc.h" -/* choose a unique non zero random number for lkey - * use high order bit to indicate MR vs MW */ +/* + * choose a unique non zero random number for lkey + * use high order bit to indicate MR vs MW + */ void rxe_set_mr_lkey(struct rxe_mr *mr) { u32 lkey; @@ -82,7 +60,6 @@ static void rxe_mr_init(int access, struct rxe_mr *mr) else mr->ibmr.rkey = 0; - // TODO we shouldn't carry two copies mr->lkey = mr->ibmr.lkey; mr->rkey = mr->ibmr.rkey; mr->state = RXE_MEM_STATE_INVALID; @@ -319,7 +296,8 @@ void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) return addr; } -/* copy data from a range (vaddr, vaddr+length-1) to or from +/* + * copy data from a range (vaddr, vaddr+length-1) to or from * a mr object starting at iova. Compute incremental value of * crc32 if crcp is not zero. caller must hold a reference to mr */ @@ -430,7 +408,8 @@ static struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 lkey) return mr; } -/* copy data in or out of a wqe, i.e. sg list +/* + * copy data in or out of a wqe, i.e. sg list * under the control of a dma descriptor */ int copy_data( @@ -559,12 +538,9 @@ int advance_dma_data(struct rxe_dma_info *dma, unsigned int length) return 0; } +/* this is a placeholder. there is lots more to do */ int rxe_invalidate_mr(struct rxe_qp *qp, struct rxe_mr *mr) { - // much more TODO here, can fail - // mw is closer to what is needed - // but for another day - mr->state = RXE_MEM_STATE_FREE; return 0; @@ -577,22 +553,19 @@ int rxe_mr_check_access(struct rxe_qp *qp, struct rxe_mr *mr, struct rxe_pd *pd = to_rpd(mr->ibmr.pd); if (unlikely(mr->state != RXE_MEM_STATE_VALID)) { - pr_err("attempt to access a MR that is" - " not in the valid state\n"); + pr_err("attempt to access a MR that is not in the valid state\n"); return -EINVAL; } /* C10-56 */ if (unlikely(pd != qp->pd)) { - pr_err("attempt to access a MR with a" - " different PD than the QP\n"); + pr_err("attempt to access a MR with a different PD than the QP\n"); return -EINVAL; } /* C10-57 */ if (unlikely(access && !(access & mr->access))) { - pr_err("attempt to access a MR that does" - " not have the required access rights\n"); + pr_err("attempt to access a MR that does not have the required access rights\n"); return -EINVAL; } diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c index ae7f5710f7dd..735b83a7eb49 100644 --- a/drivers/infiniband/sw/rxe/rxe_mw.c +++ b/drivers/infiniband/sw/rxe/rxe_mw.c @@ -1,52 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_mw.c + * * Copyright (c) 2020 Hewlett Packard Enterprise, Inc. All rights reserved. * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include "rxe.h" #include "rxe_loc.h" -/* choose a unique non zero random number for rkey - * use high order bit to indicate MR vs MW */ -void rxe_set_mw_rkey(struct rxe_mw *mw) +static void set_mw_rkey(struct rxe_mw *mw) { u32 rkey; int tries = 0; + /* + * there is a very rare chance the RNG will produce all zeros + * or that it will produce a duplicate to an existing MW + * just try again + */ do { get_random_bytes(&rkey, sizeof(rkey)); rkey |= IS_MW; if (likely((rkey & ~IS_MW) && - (rxe_add_key(mw, &rkey) == 0))) + (rxe_add_key(mw, &rkey) == 0))) return; } while (tries++ < 10); pr_err("unable to get random rkey for mw\n"); @@ -83,7 +61,8 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, mw->state = RXE_MEM_STATE_FREE; break; default: - pr_err("attempt to allocate MW with unknown type\n"); + pr_err_once("attempt to allocate MW with bad type = %d\n", + type); ret = -EINVAL; goto err3; } @@ -91,15 +70,15 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, rxe_add_index(mw); index = mw->pelem.index; - /* o10-37.2.32: */ - rxe_set_mw_rkey(mw); + /* o10-37.2.32 */ + set_mw_rkey(mw); mw->qp = NULL; mw->mr = NULL; mw->addr = 0; mw->length = 0; - mw->ibmw.pd = ibpd; - mw->ibmw.type = type; + mw->ibmw.pd = ibpd; + mw->ibmw.type = type; spin_lock_init(&mw->lock); @@ -120,44 +99,39 @@ struct ib_mw *rxe_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, return ERR_PTR(ret); } -/* Check the rules for bind MW oepration. */ static int check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, struct rxe_mw *mw, struct rxe_mr *mr) { - /* check to see if bind operation came through - * ibv_bind_mw verbs API. */ + /* check to see if bind operation came through verbs API. */ switch (mw->ibmw.type) { case IB_MW_TYPE_1: - /* o10-37.2.34: */ + /* o10-37.2.34 */ if (unlikely(!(wqe->wr.wr.umw.flags & RXE_BIND_MW))) { pr_err("attempt to bind type 1 MW with send WR\n"); return -EINVAL; } break; case IB_MW_TYPE_2: - /* o10-37.2.35: */ + /* o10-37.2.35 */ if (unlikely(wqe->wr.wr.umw.flags & RXE_BIND_MW)) { - pr_err("attempt to bind type 2 MW with verbs API\n"); + pr_err_once("attempt to bind type 2 MW with verbs API\n"); return -EINVAL; } - /* C10-72: */ + /* C10-72 */ if (unlikely(qp->pd != to_rpd(mw->ibmw.pd))) { - pr_err("attempt to bind type 2 MW with qp" - " with different PD\n"); + pr_err_once("attempt to bind type 2 MW with qp with different PD\n"); return -EINVAL; } - /* o10-37.2.40: */ + /* o10-37.2.40 */ if (unlikely(wqe->wr.wr.umw.length == 0)) { - pr_err("attempt to invalidate type 2 MW by" - " binding with zero length\n"); + pr_err_once("attempt to invalidate type 2 MW by binding with zero length\n"); return -EINVAL; } if (unlikely(!mr)) { - pr_err("attempt to invalidate type 2 MW by" - " binding to NULL mr\n"); + pr_err_once("attempt to bind type 2 MW to NULL MR\n"); return -EINVAL; } break; @@ -167,20 +141,19 @@ static int check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, if (unlikely((mw->ibmw.type == IB_MW_TYPE_1) && (mw->state != RXE_MEM_STATE_VALID))) { - pr_err("attempt to bind a type 1 MW not in the" - " valid state\n"); + pr_err_once("attempt to bind an invalid type 1 MW\n"); return -EINVAL; } - /* o10-36.2.2: */ + /* o10-36.2.2 */ if (unlikely((mw->access & IB_ZERO_BASED) && (mw->ibmw.type == IB_MW_TYPE_1))) { - pr_err("attempt to bind a zero based type 1 MW\n"); + pr_err_once("attempt to bind a zero based type 1 MW\n"); return -EINVAL; } if ((wqe->wr.wr.umw.rkey & 0xff) == (mw->ibmw.rkey & 0xff)) { - pr_err("attempt to bind MW with same key\n"); + pr_err_once("attempt to bind a MW with same key\n"); return -EINVAL; } @@ -189,47 +162,42 @@ static int check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, return 0; if (unlikely(mr->access & IB_ZERO_BASED)) { - pr_err("attempt to bind MW to zero based MR\n"); + pr_err_once("attempt to bind MW to zero based MR\n"); return -EINVAL; } - /* o10-37.2.30: */ + /* o10-37.2.30 */ if (unlikely((mw->ibmw.type == IB_MW_TYPE_2) && (mw->state != RXE_MEM_STATE_FREE))) { - pr_err("attempt to bind a type 2 MW not in the" - " free state\n"); + pr_err_once("attempt to bind a not free type 2 MW\n"); return -EINVAL; } - /* C10-73: */ + /* C10-73 */ if (unlikely(!(mr->access & IB_ACCESS_MW_BIND))) { - pr_err("attempt to bind an MW to an MR without" - " bind access\n"); + pr_err_once("attempt to bind an MW to an MR without bind access\n"); return -EINVAL; } - /* C10-74: */ + /* C10-74 */ if (unlikely((mw->access & (IB_ACCESS_REMOTE_WRITE | IB_ACCESS_REMOTE_ATOMIC)) && !(mr->access & IB_ACCESS_LOCAL_WRITE))) { - pr_err("attempt to bind an MW with write/atomic" - " access to an MR without local write access\n"); + pr_err_once("attempt to bind an MW with write/atomic access to an MR without local write access\n"); return -EINVAL; } - /* C10-75: */ + /* C10-75 */ if (mw->access & IB_ZERO_BASED) { if (unlikely(wqe->wr.wr.umw.length > mr->length)) { - pr_err("attempt to bind a ZB MW outside" - " of the MR\n"); + pr_err_once("attempt to bind a MW out of the MR\n"); return -EINVAL; } } else { if (unlikely((wqe->wr.wr.umw.addr < mr->iova) || ((wqe->wr.wr.umw.addr + wqe->wr.wr.umw.length) > (mr->iova + mr->length)))) { - pr_err("attempt to bind a VA MW outside" - " of the MR\n"); + pr_err_once("attempt to bind a MW out of the MR\n"); return -EINVAL; } } @@ -243,47 +211,48 @@ static int do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, int ret; u32 rkey; u32 new_rkey; + struct rxe_mw *duplicate_mw; + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); - /* key part of new rkey is provided by user for type 2 - * and ibv_bind_mw() for type 1 MWs */ + /* + * key part of new rkey is provided by user for type 2 + * and ibv_bind_mw() for type 1 MWs + * there is a very rare chance that the new rkey will + * collide with an existing MW. Return an error if this + * occurs + */ rkey = mw->ibmw.rkey; - rxe_drop_key(mw); new_rkey = (rkey & 0xffffff00) | (wqe->wr.wr.umw.rkey & 0x000000ff); - ret = rxe_add_key(mw, &new_rkey); - if (ret) { - /* this should never happen */ - pr_err("shouldn't happen unable to set new rkey\n"); - /* try to put back the old one */ - rxe_add_key(mw, &rkey); - return ret; + + duplicate_mw = rxe_get_key(rxe, &new_key); + if (duplicate_mw) { + pr_err_once("new MW key is a duplicate, try another\n"); + rxe_drop_ref(duplicate_mw); + return -EINVAL; } + rxe_drop_key(mw); + rxe_add_key(mw, &new_rkey); + mw->access = wqe->wr.wr.umw.access; mw->state = RXE_MEM_STATE_VALID; mw->addr = wqe->wr.wr.umw.addr; mw->length = wqe->wr.wr.umw.length; - /* get rid of existing MR if any, type 1 only */ if (mw->mr) { rxe_drop_ref(mw->mr); atomic_dec(&mw->mr->num_mw); mw->mr = NULL; } - /* if length != 0 bind to new MR */ if (mw->length) { mw->mr = mr; atomic_inc(&mr->num_mw); rxe_add_ref(mr); } - /* remember qp if type 2, cleared by invalidate - * this is weak since qp can go away legally - * only used to compare with qp used to perform - * memory ops */ - if (mw->ibmw.type == IB_MW_TYPE_2) { + if (mw->ibmw.type == IB_MW_TYPE_2) mw->qp = qp; - } return 0; } @@ -300,7 +269,7 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) mw = rxe_pool_get_index(&rxe->mw_pool, wqe->wr.wr.umw.mw_index); if (!mw) { - pr_err("mw with index = %d not found\n", + pr_err_once("mw with index = %d not found\n", wqe->wr.wr.umw.mw_index); ret = -EINVAL; goto err1; @@ -308,7 +277,7 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) mr = rxe_pool_get_index(&rxe->mr_pool, wqe->wr.wr.umw.mr_index); if (!mr && wqe->wr.wr.umw.length) { - pr_err("mr with index = %d not found\n", + pr_err_once("mr with index = %d not found\n", wqe->wr.wr.umw.mr_index); ret = -EINVAL; goto err2; @@ -326,12 +295,10 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) spin_lock_irqsave(&mw->lock, flags); - /* check the rules */ ret = check_bind_mw(qp, wqe, mw, mr); if (ret) goto err3; - /* implement the change */ ret = do_bind_mw(qp, wqe, mw, mr); err3: spin_unlock_irqrestore(&mw->lock, flags); @@ -347,14 +314,13 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) static int check_invalidate_mw(struct rxe_qp *qp, struct rxe_mw *mw) { if (unlikely(mw->state != RXE_MEM_STATE_VALID)) { - pr_warn("attempt to invalidate a MW that" - " is not valid\n"); + pr_err_once("attempt to invalidate a MW that is not valid\n"); return -EINVAL; } - /* o10-37.2.26: */ + /* o10-37.2.26 */ if (unlikely(mw->ibmw.type == IB_MW_TYPE_1)) { - pr_err("attempt to invalidate a type 1 MW\n"); + pr_err_once("attempt to invalidate a type 1 MW\n"); return -EINVAL; } @@ -434,41 +400,37 @@ int rxe_mw_check_access(struct rxe_qp *qp, struct rxe_mw *mw, struct rxe_pd *pd = to_rpd(mw->ibmw.pd); if (unlikely(mw->state != RXE_MEM_STATE_VALID)) { - pr_err("attempt to access a MW that is" - " not in the valid state\n"); + pr_err_once("attempt to access a MW that is not in the valid state\n"); return -EINVAL; } /* C10-76.2.1 */ if (unlikely((mw->ibmw.type == IB_MW_TYPE_1) && (pd != qp->pd))) { - pr_err("attempt to access a type 1 MW with a" - " different PD than the QP\n"); + pr_err_once("attempt to access a type 1 MW with a different PD than the QP\n"); return -EINVAL; } /* o10-37.2.43 */ if (unlikely((mw->ibmw.type == IB_MW_TYPE_2) && (mw->qp != qp))) { - pr_err("attempt to access a type 2 MW that is" - " associated with a different QP\n"); + pr_err_once("attempt to access a type 2 MW that is associated with a different QP\n"); return -EINVAL; } /* C10-77 */ if (unlikely(access && !(access & mw->access))) { - pr_err("attempt to access a MW that does" - " not have the required access rights\n"); + pr_err_once("attempt to access a MW that does not have the required access rights\n"); return -EINVAL; } if (mw->access & IB_ZERO_BASED) { if (unlikely((va + resid) > mw->length)) { - pr_err("attempt to access a MW out of bounds\n"); + pr_err_once("attempt to access a MW out of bounds\n"); return -EINVAL; } } else { if (unlikely((va < mw->addr) || ((va + resid) > (mw->addr + mw->length)))) { - pr_err("attempt to access a MW out of bounds\n"); + pr_err_once("attempt to access a MW out of bounds\n"); return -EINVAL; } } diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 0c3808611f95..e9b6f491e922 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_net.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include @@ -120,7 +95,7 @@ static struct dst_entry *rxe_find_route6(struct net_device *ndev, ndst = ipv6_stub->ipv6_dst_lookup_flow(sock_net(recv_sockets.sk6->sk), recv_sockets.sk6->sk, &fl6, NULL); - if (unlikely(IS_ERR(ndst))) { + if (IS_ERR(ndst)) { pr_err_ratelimited("no route to %pI6\n", daddr); return NULL; } @@ -333,8 +308,8 @@ static void prepare_ipv6_hdr(struct dst_entry *dst, struct sk_buff *skb, ip6h = ipv6_hdr(skb); ip6_flow_hdr(ip6h, prio, htonl(0)); ip6h->payload_len = htons(skb->len); - ip6h->nexthdr = proto; - ip6h->hop_limit = ttl; + ip6h->nexthdr = proto; + ip6h->hop_limit = ttl; ip6h->daddr = *daddr; ip6h->saddr = *saddr; ip6h->payload_len = htons(skb->len - sizeof(*ip6h)); diff --git a/drivers/infiniband/sw/rxe/rxe_net.h b/drivers/infiniband/sw/rxe/rxe_net.h index 2ca71d3d245c..1142dd4b47cb 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.h +++ b/drivers/infiniband/sw/rxe/rxe_net.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_net.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_NET_H diff --git a/drivers/infiniband/sw/rxe/rxe_opcode.c b/drivers/infiniband/sw/rxe/rxe_opcode.c index d2f2092f0be5..31065d772f10 100644 --- a/drivers/infiniband/sw/rxe/rxe_opcode.c +++ b/drivers/infiniband/sw/rxe/rxe_opcode.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_opcode.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include @@ -397,7 +372,7 @@ struct rxe_opcode_info rxe_opcode[RXE_NUM_OPCODE] = { .name = "IB_OPCODE_RC_SEND_ONLY_INV", .mask = RXE_IETH_MASK | RXE_PAYLOAD_MASK | RXE_REQ_MASK | RXE_COMP_MASK | RXE_RWR_MASK | RXE_SEND_MASK - | RXE_END_MASK | RXE_START_MASK, + | RXE_END_MASK | RXE_START_MASK, .length = RXE_BTH_BYTES + RXE_IETH_BYTES, .offset = { [RXE_BTH] = 0, diff --git a/drivers/infiniband/sw/rxe/rxe_opcode.h b/drivers/infiniband/sw/rxe/rxe_opcode.h index 307604e9c78d..7a42bfab1d45 100644 --- a/drivers/infiniband/sw/rxe/rxe_opcode.h +++ b/drivers/infiniband/sw/rxe/rxe_opcode.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_opcode.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_OPCODE_H diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h index 41e7b74efcbc..c24d90911434 100644 --- a/drivers/infiniband/sw/rxe/rxe_param.h +++ b/drivers/infiniband/sw/rxe/rxe_param.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_param.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_PARAM_H diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index df3e2a514ce3..0f8b83f0965a 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_pool.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include "rxe.h" @@ -38,7 +13,7 @@ struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = { [RXE_TYPE_UC] = { .name = "rxe-uc", .size = sizeof(struct rxe_ucontext), - .flags = RXE_POOL_NO_ALLOC, + .flags = RXE_POOL_NO_ALLOC, }, [RXE_TYPE_PD] = { .name = "rxe-pd", @@ -68,7 +43,7 @@ struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = { [RXE_TYPE_CQ] = { .name = "rxe-cq", .size = sizeof(struct rxe_cq), - .flags = RXE_POOL_NO_ALLOC, + .flags = RXE_POOL_NO_ALLOC, .cleanup = rxe_cq_cleanup, }, [RXE_TYPE_MR] = { @@ -366,10 +341,8 @@ void rxe_drop_key(void *arg) struct rxe_pool *pool = elem->pool; unsigned long flags; - if (elem == NULL) { - pr_warn("rxe_drop_key: called with null pointer\n"); + if (elem == NULL) return; - } write_lock_irqsave(&pool->pool_lock, flags); rb_erase(&elem->key_node, &pool->key.tree); @@ -394,10 +367,8 @@ void rxe_drop_index(void *arg) struct rxe_pool *pool = elem->pool; unsigned long flags; - if (elem == NULL) { - pr_warn("rxe_drop_index: called with null pointer\n"); + if (elem == NULL) return; - } write_lock_irqsave(&pool->pool_lock, flags); clear_bit(elem->index - pool->index.min_index, pool->index.table); diff --git a/drivers/infiniband/sw/rxe/rxe_pool.h b/drivers/infiniband/sw/rxe/rxe_pool.h index 0ba811456f79..43c38f67fa26 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.h +++ b/drivers/infiniband/sw/rxe/rxe_pool.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_pool.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_POOL_H diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index 6c11c3aeeca6..0b09ab0b1543 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_qp.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include @@ -217,7 +192,8 @@ static void rxe_qp_init_misc(struct rxe_dev *rxe, struct rxe_qp *qp, } static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, - struct ib_qp_init_attr *init, struct ib_udata *udata, + struct ib_qp_init_attr *init, + struct ib_udata *udata, struct rxe_create_qp_resp __user *uresp) { int err; @@ -331,7 +307,8 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp, } /* called by the create qp verb */ -int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd, +int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, + struct rxe_pd *pd, struct ib_qp_init_attr *init, struct rxe_create_qp_resp __user *uresp, struct ib_pd *ibpd, @@ -413,7 +390,7 @@ int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp, struct ib_qp_attr *attr, int mask) { enum ib_qp_state cur_state = (mask & IB_QP_CUR_STATE) ? - attr->cur_qp_state : qp->attr.qp_state; + attr->cur_qp_state : qp->attr.qp_state; enum ib_qp_state new_state = (mask & IB_QP_STATE) ? attr->qp_state : cur_state; @@ -628,9 +605,8 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask, if (mask & IB_QP_QKEY) qp->attr.qkey = attr->qkey; - if (mask & IB_QP_AV) { + if (mask & IB_QP_AV) rxe_init_av(&attr->ah_attr, &qp->pri_av); - } if (mask & IB_QP_ALT_PATH) { rxe_init_av(&attr->alt_ah_attr, &qp->alt_av); @@ -649,7 +625,10 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask, if (attr->timeout == 0) { qp->qp_timeout_jiffies = 0; } else { - /* According to the spec, timeout = 4.096 * 2 ^ attr->timeout [us] */ + /* + * According to the spec, + * timeout = 4.096 * 2 ^ attr->timeout [us] + */ int j = nsecs_to_jiffies(4096ULL << attr->timeout); qp->qp_timeout_jiffies = j ? j : 1; @@ -687,7 +666,8 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask, qp->attr.sq_psn = (attr->sq_psn & BTH_PSN_MASK); qp->req.psn = qp->attr.sq_psn; qp->comp.psn = qp->attr.sq_psn; - pr_debug("qp#%d set req psn = 0x%x\n", qp_num(qp), qp->req.psn); + pr_debug("qp#%d set req psn = 0x%x\n", + qp_num(qp), qp->req.psn); } if (mask & IB_QP_PATH_MIG_STATE) @@ -803,7 +783,8 @@ void rxe_qp_destroy(struct rxe_qp *qp) /* called when the last reference to the qp is dropped */ static void rxe_qp_do_cleanup(struct work_struct *work) { - struct rxe_qp *qp = container_of(work, typeof(*qp), cleanup_work.work); + struct rxe_qp *qp = container_of(work, typeof(*qp), + cleanup_work.work); rxe_drop_all_mcast_groups(qp); diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c index 245040c3a35d..f761943e7467 100644 --- a/drivers/infiniband/sw/rxe/rxe_queue.c +++ b/drivers/infiniband/sw/rxe/rxe_queue.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_queue.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must retailuce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include diff --git a/drivers/infiniband/sw/rxe/rxe_queue.h b/drivers/infiniband/sw/rxe/rxe_queue.h index 8ef17d617022..98fb2f50621a 100644 --- a/drivers/infiniband/sw/rxe/rxe_queue.h +++ b/drivers/infiniband/sw/rxe/rxe_queue.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_queue.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_QUEUE_H diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c index 7e123d3c4d09..9eb38008f603 100644 --- a/drivers/infiniband/sw/rxe/rxe_recv.c +++ b/drivers/infiniband/sw/rxe/rxe_recv.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_recv.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index f0fa195fcc70..61f41cfdfefd 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -1,34 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_req.c + * + * Copyright (c) 2020 Hewlett Packard Enterprise, Inc. All rights reserved. * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include @@ -135,7 +111,8 @@ static struct rxe_send_wqe *req_next_wqe(struct rxe_qp *qp) unsigned long flags; if (unlikely(qp->req.state == QP_STATE_DRAIN)) { - /* check to see if we are drained; + /* + * check to see if we are drained; * state_lock used by requester and completer */ spin_lock_irqsave(&qp->state_lock, flags); @@ -345,7 +322,8 @@ static int next_opcode(struct rxe_qp *qp, struct rxe_send_wqe *wqe, return -EINVAL; } -static inline int check_init_depth(struct rxe_qp *qp, struct rxe_send_wqe *wqe) +static inline int check_init_depth(struct rxe_qp *qp, + struct rxe_send_wqe *wqe) { int depth; @@ -394,9 +372,7 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp, /* length from start of bth to end of icrc */ paylen = rxe_opcode[opcode].length + payload + pad + RXE_ICRC_SIZE; - /* pkt->hdr, rxe, port_num and mask are initialized in ifc - * layer - */ + /* pkt->hdr, rxe, port_num and mask are initialized in ifc layer */ pkt->opcode = opcode; pkt->qp = qp; pkt->psn = qp->req.psn; @@ -551,9 +527,9 @@ static void save_state(struct rxe_send_wqe *wqe, struct rxe_send_wqe *rollback_wqe, u32 *rollback_psn) { - rollback_wqe->state = wqe->state; + rollback_wqe->state = wqe->state; rollback_wqe->first_psn = wqe->first_psn; - rollback_wqe->last_psn = wqe->last_psn; + rollback_wqe->last_psn = wqe->last_psn; *rollback_psn = qp->req.psn; } @@ -591,18 +567,25 @@ static int local_invalidate(struct rxe_qp *qp, struct rxe_send_wqe *wqe) struct rxe_dev *rxe = to_rdev(qp->ibqp.device); u32 key = wqe->wr.ex.invalidate_rkey; - if (!(key & IS_MW) && (mr = rxe_pool_get_key(&rxe->mr_pool, &key))) { - ret = rxe_invalidate_mr(qp, mr); - rxe_drop_ref(mr); - } else if ((mw = rxe_pool_get_key(&rxe->mw_pool, &key))) { + if (key & IS_MW) { + mw = rxe_pool_get_key(&rxe->mw_pool, &key); + if (!mw) + goto err; ret = rxe_invalidate_mw(qp, mw); rxe_drop_ref(mw); - } else { - ret = -EINVAL; - pr_err("No mr/mw for rkey %#x\n", key); + return ret; } + mr = rxe_pool_get_key(&rxe->mr_pool, &key); + if (!mr) + goto err; + ret = rxe_invalidate_mr(qp, mr); + rxe_drop_ref(mr); return ret; + +err: + pr_err("No mr/mw for rkey 0x%x\n", key); + return -EINVAL; } int rxe_requester(void *arg) @@ -619,17 +602,9 @@ int rxe_requester(void *arg) int ret; struct rxe_send_wqe rollback_wqe; u32 rollback_psn; - int entered; rxe_add_ref(qp); - // this code is 'guaranteed' to never be entered more - // than once. Check to make sure that this is the case - entered = atomic_inc_return(&qp->req.task.entered); - if (entered > 1) { - pr_err("rxe_requester: entered %d times\n", entered); - } - next_wqe: if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) goto exit; @@ -652,19 +627,21 @@ int rxe_requester(void *arg) if (unlikely(!wqe)) goto exit; - /* process local operations */ - /* current behavior if an error occurs + /* + * process local operations + * current behavior if an error occurs * for any of these local operations * is to generate an error work completion * then error the QP and flush any - * remaining WRs */ + * remaining WRs + */ if (wqe->mask & WR_LOCAL_MASK) { wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; switch (wqe->wr.opcode) { case IB_WR_LOCAL_INV: - if ((ret = local_invalidate(qp, wqe))) + if (local_invalidate(qp, wqe)) wqe->status = IB_WC_LOC_QP_OP_ERR; break; case IB_WR_REG_MR: @@ -676,22 +653,26 @@ int rxe_requester(void *arg) mr->iova = wqe->wr.wr.reg.mr->iova; break; case IB_WR_BIND_MW: - if ((ret = rxe_bind_mw(qp, wqe))) + if (rxe_bind_mw(qp, wqe)) wqe->status = IB_WC_MW_BIND_ERR; break; default: - pr_err("rxe_requester: unexpected local" - " WR opcode = %d\n", wqe->wr.opcode); - /* these should be memory operation errors - * but there isn't one available */ + pr_err("unexpected local WR opcode = %d\n", + wqe->wr.opcode); + /* + * these should be memory operation errors + * but there isn't one available + */ wqe->status = IB_WC_LOC_QP_OP_ERR; } /* we're done processing the wqe so move index */ qp->req.wqe_index = next_index(qp->sq.queue, qp->req.wqe_index); - /* if an error occurred do a completion pass now - * (below) and then quit processing more wqes */ + /* + * if an error occurred do a completion pass now + * (below) and then quit processing more wqes + */ if (wqe->status != IB_WC_SUCCESS) goto err; @@ -743,12 +724,6 @@ int rxe_requester(void *arg) wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; - /* TODO why?? why not just treat the same as a - * successful wqe and go to next wqe? - * __rxe_do_task probably shouldn't be used - * it reenters the completion task which may - * already be running - */ __rxe_do_task(&qp->comp.task); goto again; } @@ -798,20 +773,24 @@ int rxe_requester(void *arg) goto next_wqe; err: - /* we come here if an error occured while processing + /* + * we come here if an error occured while processing * a send wqe. The completer will put the qp in error * state and no more wqes will be processed unless - * the qp is cleaned up and restarted. */ + * the qp is cleaned up and restarted. + */ wqe->state = wqe_state_error; __rxe_do_task(&qp->comp.task); ret = -EAGAIN; goto done; exit: - /* we come here if either there are no more wqes in the send + /* + * we come here if either there are no more wqes in the send * queue or we are blocked waiting for some resource or event. * The current wqe will be restarted or new wqe started when - * there is something to do. */ + * there is something to do. + */ ret = -EAGAIN; goto done; @@ -821,7 +800,6 @@ int rxe_requester(void *arg) goto done; done: - atomic_dec(&qp->req.task.entered); rxe_drop_ref(qp); return ret; } diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index 0bfea50505d1..0696ca85161e 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -1,34 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_resp.c + * + * Copyright (c) 2020 Hewlett Packard Enterprise, Inc. All rights reserved. * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include @@ -71,36 +47,36 @@ enum resp_states { }; static char *resp_state_name[] = { - [RESPST_NONE] = "NONE", - [RESPST_GET_REQ] = "GET_REQ", - [RESPST_CHK_PSN] = "CHK_PSN", - [RESPST_CHK_OP_SEQ] = "CHK_OP_SEQ", - [RESPST_CHK_OP_VALID] = "CHK_OP_VALID", - [RESPST_CHK_RESOURCE] = "CHK_RESOURCE", - [RESPST_CHK_LENGTH] = "CHK_LENGTH", - [RESPST_CHK_RKEY] = "CHK_RKEY", - [RESPST_EXECUTE] = "EXECUTE", - [RESPST_READ_REPLY] = "READ_REPLY", - [RESPST_COMPLETE] = "COMPLETE", - [RESPST_ACKNOWLEDGE] = "ACKNOWLEDGE", - [RESPST_CLEANUP] = "CLEANUP", - [RESPST_DUPLICATE_REQUEST] = "DUPLICATE_REQUEST", - [RESPST_ERR_MALFORMED_WQE] = "ERR_MALFORMED_WQE", - [RESPST_ERR_UNSUPPORTED_OPCODE] = "ERR_UNSUPPORTED_OPCODE", - [RESPST_ERR_MISALIGNED_ATOMIC] = "ERR_MISALIGNED_ATOMIC", - [RESPST_ERR_PSN_OUT_OF_SEQ] = "ERR_PSN_OUT_OF_SEQ", - [RESPST_ERR_MISSING_OPCODE_FIRST] = "ERR_MISSING_OPCODE_FIRST", - [RESPST_ERR_MISSING_OPCODE_LAST_C] = "ERR_MISSING_OPCODE_LAST_C", - [RESPST_ERR_MISSING_OPCODE_LAST_D1E] = "ERR_MISSING_OPCODE_LAST_D1E", - [RESPST_ERR_TOO_MANY_RDMA_ATM_REQ] = "ERR_TOO_MANY_RDMA_ATM_REQ", - [RESPST_ERR_RNR] = "ERR_RNR", - [RESPST_ERR_RKEY_VIOLATION] = "ERR_RKEY_VIOLATION", - [RESPST_ERR_LENGTH] = "ERR_LENGTH", - [RESPST_ERR_CQ_OVERFLOW] = "ERR_CQ_OVERFLOW", - [RESPST_ERROR] = "ERROR", - [RESPST_RESET] = "RESET", - [RESPST_DONE] = "DONE", - [RESPST_EXIT] = "EXIT", + [RESPST_NONE] = "NONE", + [RESPST_GET_REQ] = "GET_REQ", + [RESPST_CHK_PSN] = "CHK_PSN", + [RESPST_CHK_OP_SEQ] = "CHK_OP_SEQ", + [RESPST_CHK_OP_VALID] = "CHK_OP_VALID", + [RESPST_CHK_RESOURCE] = "CHK_RESOURCE", + [RESPST_CHK_LENGTH] = "CHK_LENGTH", + [RESPST_CHK_RKEY] = "CHK_RKEY", + [RESPST_EXECUTE] = "EXECUTE", + [RESPST_READ_REPLY] = "READ_REPLY", + [RESPST_COMPLETE] = "COMPLETE", + [RESPST_ACKNOWLEDGE] = "ACKNOWLEDGE", + [RESPST_CLEANUP] = "CLEANUP", + [RESPST_DUPLICATE_REQUEST] = "DUPLICATE_REQUEST", + [RESPST_ERR_MALFORMED_WQE] = "ERR_MALFORMED_WQE", + [RESPST_ERR_UNSUPPORTED_OPCODE] = "ERR_UNSUPPORTED_OPCODE", + [RESPST_ERR_MISALIGNED_ATOMIC] = "ERR_MISALIGNED_ATOMIC", + [RESPST_ERR_PSN_OUT_OF_SEQ] = "ERR_PSN_OUT_OF_SEQ", + [RESPST_ERR_MISSING_OPCODE_FIRST] = "ERR_MISSING_OPCODE_FIRST", + [RESPST_ERR_MISSING_OPCODE_LAST_C] = "ERR_MISSING_OPCODE_LAST_C", + [RESPST_ERR_MISSING_OPCODE_LAST_D1E] = "ERR_MISSING_OPCODE_LAST_D1E", + [RESPST_ERR_TOO_MANY_RDMA_ATM_REQ] = "ERR_TOO_MANY_RDMA_ATM_REQ", + [RESPST_ERR_RNR] = "ERR_RNR", + [RESPST_ERR_RKEY_VIOLATION] = "ERR_RKEY_VIOLATION", + [RESPST_ERR_LENGTH] = "ERR_LENGTH", + [RESPST_ERR_CQ_OVERFLOW] = "ERR_CQ_OVERFLOW", + [RESPST_ERROR] = "ERROR", + [RESPST_RESET] = "RESET", + [RESPST_DONE] = "DONE", + [RESPST_EXIT] = "EXIT", }; /* rxe_recv calls here to add a request packet to the input queue */ @@ -462,7 +438,13 @@ static enum resp_states check_rkey(struct rxe_qp *qp, resid = qp->resp.resid; pktlen = payload_size(pkt); - if ((rkey & IS_MW) && (mw = rxe_pool_get_key(&rxe->mw_pool, &rkey))) { + if (rkey & IS_MW) { + mw = rxe_pool_get_key(&rxe->mw_pool, &rkey); + if (!mw) { + state = RESPST_ERR_RKEY_VIOLATION; + goto err; + } + spin_lock_irqsave(&mw->lock, flags); if (rxe_mw_check_access(qp, mw, access, va, resid)) { spin_unlock_irqrestore(&mw->lock, flags); @@ -479,16 +461,19 @@ static enum resp_states check_rkey(struct rxe_qp *qp, spin_unlock_irqrestore(&mw->lock, flags); rxe_drop_ref(mw); - } else if ((mr = rxe_pool_get_key(&rxe->mr_pool, &rkey)) && - (mr->rkey == rkey)) { + } else { + mr = rxe_pool_get_key(&rxe->mr_pool, &rkey); + if (!mr || mr->rkey != rkey) { + if (mr) + rxe_drop_ref(mr); + state = RESPST_ERR_RKEY_VIOLATION; + goto err; + } + if (rxe_mr_check_access(qp, mr, access, va, resid)) { state = RESPST_ERR_RKEY_VIOLATION; goto err; } - } else { - pr_err("no MR/MW found with rkey = 0x%08x\n", rkey); - state = RESPST_ERR_RKEY_VIOLATION; - goto err; } if (pkt->mask & RXE_WRITE_MASK) { @@ -853,15 +838,22 @@ static int send_invalidate(struct rxe_qp *qp, struct rxe_dev *rxe, u32 rkey) struct rxe_mr *mr; struct rxe_mw *mw; - if ((mr = rxe_pool_get_key(&rxe->mr_pool, &rkey))) { - ret = rxe_invalidate_mr(qp, mr); - rxe_drop_ref(mr); - } else if ((mw = rxe_pool_get_key(&rxe->mw_pool, &rkey))) { + if (rkey & IS_MW) { + mw = rxe_pool_get_key(&rxe->mw_pool, &rkey); + if (!mw) { + pr_err("no MW found for rkey = 0x%x\n", rkey); + ret = -EINVAL; + } ret = rxe_invalidate_mw(qp, mw); rxe_drop_ref(mw); } else { - pr_err("send invalidate failed for rkey = 0x%x\n", rkey); - ret = -EINVAL; + mr = rxe_pool_get_key(&rxe->mr_pool, &rkey); + if (!mr) { + pr_err("no MR found for rkey = 0x%x\n", rkey); + ret = -EINVAL; + } + ret = rxe_invalidate_mr(qp, mr); + rxe_drop_ref(mr); } return ret; @@ -884,13 +876,13 @@ static enum resp_states do_complete(struct rxe_qp *qp, memset(&cqe, 0, sizeof(cqe)); if (qp->rcq->is_user) { - uwc->status = qp->resp.status; - uwc->qp_num = qp->ibqp.qp_num; - uwc->wr_id = wqe->wr_id; + uwc->status = qp->resp.status; + uwc->qp_num = qp->ibqp.qp_num; + uwc->wr_id = wqe->wr_id; } else { - wc->status = qp->resp.status; - wc->qp = &qp->ibqp; - wc->wr_id = wqe->wr_id; + wc->status = qp->resp.status; + wc->qp = &qp->ibqp; + wc->wr_id = wqe->wr_id; } if (pkt->mask & RXE_IETH_MASK) { @@ -909,7 +901,8 @@ static enum resp_states do_complete(struct rxe_qp *qp, wc->vendor_err = 0; wc->byte_len = (pkt->mask & RXE_IMMDT_MASK && pkt->mask & RXE_WRITE_MASK) ? - qp->resp.length : wqe->dma.length - wqe->dma.resid; + qp->resp.length : + wqe->dma.length - wqe->dma.resid; /* fields after byte_len are different between kernel and user * space @@ -936,7 +929,8 @@ static enum resp_states do_complete(struct rxe_qp *qp, } else { struct sk_buff *skb = PKT_TO_SKB(pkt); - wc->wc_flags = IB_WC_GRH | IB_WC_WITH_NETWORK_HDR_TYPE; + wc->wc_flags = IB_WC_GRH | + IB_WC_WITH_NETWORK_HDR_TYPE; if (skb->protocol == htons(ETH_P_IP)) wc->network_hdr_type = RDMA_NETWORK_IPV4; else @@ -1175,7 +1169,7 @@ static enum resp_states duplicate_request(struct rxe_qp *qp, /* Resend the result. */ rc = rxe_xmit_packet(qp, pkt, res->atomic.skb); if (rc) { - pr_err("Failed resending result. This flow is not handled - skb ignored\n"); + pr_err("Failed resending result\n"); rc = RESPST_CLEANUP; goto out; } @@ -1189,7 +1183,9 @@ static enum resp_states duplicate_request(struct rxe_qp *qp, return rc; } -/* Process a class A or C. Both are treated the same in this implementation. */ +/* Process a class A or C. Both are treated the same + * in this implementation. + */ static void do_class_ac_error(struct rxe_qp *qp, u8 syndrome, enum ib_wc_status status) { @@ -1257,17 +1253,9 @@ int rxe_responder(void *arg) enum resp_states state; struct rxe_pkt_info *pkt = NULL; int ret = 0; - int entered; rxe_add_ref(qp); - // this code is 'guaranteed' to never be entered more - // than once. Check to make sure that this is the case - entered = atomic_inc_return(&qp->resp.task.entered); - if (entered > 1) { - pr_err("rxe_responder: entered %d times\n", entered); - } - qp->resp.aeth_syndrome = AETH_ACK_UNLIMITED; if (!qp->valid) { @@ -1330,7 +1318,8 @@ int rxe_responder(void *arg) break; case RESPST_ERR_PSN_OUT_OF_SEQ: /* RC only - Class B. Drop packet. */ - send_ack(qp, pkt, AETH_NAK_PSN_SEQ_ERROR, qp->resp.psn); + send_ack(qp, pkt, AETH_NAK_PSN_SEQ_ERROR, + qp->resp.psn); state = RESPST_CLEANUP; break; @@ -1446,7 +1435,6 @@ int rxe_responder(void *arg) exit: ret = -EAGAIN; done: - atomic_dec(&qp->resp.task.entered); rxe_drop_ref(qp); return ret; } diff --git a/drivers/infiniband/sw/rxe/rxe_srq.c b/drivers/infiniband/sw/rxe/rxe_srq.c index d8459431534e..81394bab2c0f 100644 --- a/drivers/infiniband/sw/rxe/rxe_srq.c +++ b/drivers/infiniband/sw/rxe/rxe_srq.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_srq.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include diff --git a/drivers/infiniband/sw/rxe/rxe_sysfs.c b/drivers/infiniband/sw/rxe/rxe_sysfs.c index ccda5f5a3bc0..39aa0c04dde8 100644 --- a/drivers/infiniband/sw/rxe/rxe_sysfs.c +++ b/drivers/infiniband/sw/rxe/rxe_sysfs.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_sysfs.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include "rxe.h" @@ -92,7 +67,8 @@ static int rxe_param_set_add(const char *val, const struct kernel_param *kp) return err; } -static int rxe_param_set_remove(const char *val, const struct kernel_param *kp) +static int rxe_param_set_remove(const char *val, + const struct kernel_param *kp) { int len; char intf[32]; diff --git a/drivers/infiniband/sw/rxe/rxe_task.c b/drivers/infiniband/sw/rxe/rxe_task.c index 08f05ac5f5d5..44c3b908b9f4 100644 --- a/drivers/infiniband/sw/rxe/rxe_task.c +++ b/drivers/infiniband/sw/rxe/rxe_task.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_task.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include diff --git a/drivers/infiniband/sw/rxe/rxe_task.h b/drivers/infiniband/sw/rxe/rxe_task.h index e33806c6f5a4..836b21dcf2ae 100644 --- a/drivers/infiniband/sw/rxe/rxe_task.h +++ b/drivers/infiniband/sw/rxe/rxe_task.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_task.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_TASK_H @@ -55,8 +30,6 @@ struct rxe_task { int ret; char name[16]; bool destroyed; - // debug code, delete me when done - atomic_t entered; }; /* diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index caaacfabadbc..7ddf97fac67d 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -1,34 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* + * drivers/infiniband/sw/rxe/rxe_verbs.c + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #include @@ -133,7 +108,8 @@ static enum rdma_link_layer rxe_get_link_layer(struct ib_device *dev, return IB_LINK_LAYER_ETHERNET; } -static int rxe_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata) +static int rxe_alloc_ucontext(struct ib_ucontext *uctx, + struct ib_udata *udata) { struct rxe_dev *rxe = to_rdev(uctx->device); struct rxe_ucontext *uc = to_ruc(uctx); @@ -376,7 +352,8 @@ static void rxe_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) rxe_drop_ref(srq); } -static int rxe_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, +static int rxe_post_srq_recv(struct ib_srq *ibsrq, + const struct ib_recv_wr *wr, const struct ib_recv_wr **bad_wr) { int err = 0; @@ -605,8 +582,9 @@ static int init_send_wqe(struct rxe_qp *qp, const struct ib_send_wr *ibwr, wqe->mask = mask; wqe->state = wqe_state_posted; return 0; - } else - memcpy(wqe->dma.sge, ibwr->sg_list, + } + + memcpy(wqe->dma.sge, ibwr->sg_list, num_sge * sizeof(struct ib_sge)); wqe->iova = mask & WR_ATOMIC_MASK ? atomic_wr(ibwr)->remote_addr : @@ -664,7 +642,8 @@ static int post_one_send(struct rxe_qp *qp, const struct ib_send_wr *ibwr, return err; } -static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr, +static int rxe_post_send_kernel(struct rxe_qp *qp, + const struct ib_send_wr *wr, const struct ib_send_wr **bad_wr) { int err = 0; @@ -773,7 +752,8 @@ static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, return err; } -static int rxe_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, +static int rxe_create_cq(struct ib_cq *ibcq, + const struct ib_cq_init_attr *attr, struct ib_udata *udata) { int err; @@ -868,7 +848,8 @@ static int rxe_peek_cq(struct ib_cq *ibcq, int wc_cnt) return (count > wc_cnt) ? wc_cnt : count; } -static int rxe_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) +static int rxe_req_notify_cq(struct ib_cq *ibcq, + enum ib_cq_notify_flags flags) { struct rxe_cq *cq = to_rcq(ibcq); unsigned long irq_flags; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index c990654e396d..b738f1603d13 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -1,34 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* + * drivers/infiniband/sw/rxe/rxe_verbs.h + * * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #ifndef RXE_VERBS_H @@ -436,7 +411,8 @@ struct rxe_dev { struct crypto_shash *tfm; }; -static inline void rxe_counter_inc(struct rxe_dev *rxe, enum rxe_counters index) +static inline void rxe_counter_inc(struct rxe_dev *rxe, + enum rxe_counters index) { atomic64_inc(&rxe->stats_counters[index]); }