From patchwork Thu Sep 29 17:08:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 12994467 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8FFDC43217 for ; Thu, 29 Sep 2022 17:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236115AbiI2RJS (ORCPT ); Thu, 29 Sep 2022 13:09:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236112AbiI2RJN (ORCPT ); Thu, 29 Sep 2022 13:09:13 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E35451CEDDE for ; Thu, 29 Sep 2022 10:09:12 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id n83so2237540oif.11 for ; Thu, 29 Sep 2022 10:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Z7E0TVledxyghIEb8qD3FQSUbtEKPG3PWt+9xJJJOXs=; b=G6jB/Uw6Ch5h35H6rTOjHb83vItvzaQMfkXSSgMYG2oOoRVXeYYJqpBPVPqRXWW+aQ 4mxf514pTlQuvFe/nOzwSKh5AkQkPPuveFSw5dgXcc9PmpU8/0h5jpBhTcjv4JnArjny XhjA5opATs5OKktT6bZGuQyEKLYrfMbS6dwQA6w2WoNYipYZ99Sg0DN138S5NKp1Ac89 oRS4xD9kmAd4oqWIbvElJ5EdNeXsY3MptBXgaghNnNBcqeu8pBVVejajCxTIyBANSPSb lBHdszZCjqsWk9wxZvgPHyhjdbuXkva0jAeACAUL7lI2yHKYzUjVqT90kUtt5rAlq2cw maeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Z7E0TVledxyghIEb8qD3FQSUbtEKPG3PWt+9xJJJOXs=; b=vDgVofc7xEttfIXVmYPepENc0owkksGaT3VhZ8psKhfkbQ0eI/5NKE0yGF6vA2y8d+ iXF9qu4iWwF7GrpsgOFTVgzr/n9LHY/SzYFJ6tZcP6CdoOI442FVpU66xngJGkjwZytD Cetoo2YYiXMcNkQjggCxSe7gf93056qFQoWZGj+VfdkqtPVkrxbHz2OVL9mF3ArHswm8 dFkKh/vFzeh+JkWy2RVsBhGbCXbJbcVCp5+o2qgR7EgiPaGmn+xNYLFEzVAvaI0rmJJW DnXaElzMjtUTdQs4u+HUxdDnQn0+9m82MO9vgyqJyalQo9micgzXx7jLa4IpnMe+lfOR G/3g== X-Gm-Message-State: ACrzQf1oYrzsIAotvN9vL6cIsfh+uhP19Pz+h8cZo4SYIGGw3+DiJ4tJ YV/icuZxTtUOyz0ihVucYbg= X-Google-Smtp-Source: AMsMyM7OEZnRFI5MeRd+9CgAPArpNfQ4qtTXDUJYJfMifB3V5NF5kpqlKpUz879qrmWj/IXHnziRDA== X-Received: by 2002:a05:6808:1997:b0:34f:d372:b790 with SMTP id bj23-20020a056808199700b0034fd372b790mr2038970oib.2.1664471352186; Thu, 29 Sep 2022 10:09:12 -0700 (PDT) Received: from ubuntu-22.tx.rr.com (2603-8081-140c-1a00-c4e7-bfae-90ed-ac81.res6.spectrum.com. [2603:8081:140c:1a00:c4e7:bfae:90ed:ac81]) by smtp.googlemail.com with ESMTPSA id v17-20020a056808005100b00349a06c581fsm2798557oic.3.2022.09.29.10.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 10:09:11 -0700 (PDT) From: Bob Pearson To: jgg@nvidia.com, zyjzyj2000@gmail.com, linux-rdma@vger.kernel.org Cc: Bob Pearson Subject: [PATCH for-next v2 06/13] RDMA/rxe: Implement open_xrcd and close_xrcd Date: Thu, 29 Sep 2022 12:08:30 -0500 Message-Id: <20220929170836.17838-7-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220929170836.17838-1-rpearsonhpe@gmail.com> References: <20220929170836.17838-1-rpearsonhpe@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Add rxe_open_xrcd() and rxe_close_xrcd() and add xrcd objects to rxe object pools to implement ib_open_xrcd() and ib_close_xrcd(). Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe.c | 2 ++ drivers/infiniband/sw/rxe/rxe_param.h | 3 +++ drivers/infiniband/sw/rxe/rxe_pool.c | 8 ++++++++ drivers/infiniband/sw/rxe/rxe_pool.h | 1 + drivers/infiniband/sw/rxe/rxe_verbs.c | 23 +++++++++++++++++++++++ drivers/infiniband/sw/rxe/rxe_verbs.h | 11 +++++++++++ 6 files changed, 48 insertions(+) diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c index 51daac5c4feb..acd22980836e 100644 --- a/drivers/infiniband/sw/rxe/rxe.c +++ b/drivers/infiniband/sw/rxe/rxe.c @@ -23,6 +23,7 @@ void rxe_dealloc(struct ib_device *ib_dev) rxe_pool_cleanup(&rxe->uc_pool); rxe_pool_cleanup(&rxe->pd_pool); rxe_pool_cleanup(&rxe->ah_pool); + rxe_pool_cleanup(&rxe->xrcd_pool); rxe_pool_cleanup(&rxe->srq_pool); rxe_pool_cleanup(&rxe->qp_pool); rxe_pool_cleanup(&rxe->cq_pool); @@ -120,6 +121,7 @@ static void rxe_init_pools(struct rxe_dev *rxe) rxe_pool_init(rxe, &rxe->uc_pool, RXE_TYPE_UC); rxe_pool_init(rxe, &rxe->pd_pool, RXE_TYPE_PD); rxe_pool_init(rxe, &rxe->ah_pool, RXE_TYPE_AH); + rxe_pool_init(rxe, &rxe->xrcd_pool, RXE_TYPE_XRCD); rxe_pool_init(rxe, &rxe->srq_pool, RXE_TYPE_SRQ); rxe_pool_init(rxe, &rxe->qp_pool, RXE_TYPE_QP); rxe_pool_init(rxe, &rxe->cq_pool, RXE_TYPE_CQ); diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h index 86c7a8bf3cbb..fa4bf177e123 100644 --- a/drivers/infiniband/sw/rxe/rxe_param.h +++ b/drivers/infiniband/sw/rxe/rxe_param.h @@ -86,6 +86,9 @@ enum rxe_device_param { RXE_MAX_QP_INDEX = DEFAULT_MAX_VALUE, RXE_MAX_QP = DEFAULT_MAX_VALUE - RXE_MIN_QP_INDEX, + RXE_MIN_XRCD_INDEX = 1, + RXE_MAX_XRCD_INDEX = 128, + RXE_MAX_XRCD = 128, RXE_MIN_SRQ_INDEX = 0x00020001, RXE_MAX_SRQ_INDEX = DEFAULT_MAX_VALUE, RXE_MAX_SRQ = DEFAULT_MAX_VALUE - RXE_MIN_SRQ_INDEX, diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index f50620f5a0a1..b54453b68169 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -42,6 +42,14 @@ static const struct rxe_type_info { .max_index = RXE_MAX_AH_INDEX, .max_elem = RXE_MAX_AH_INDEX - RXE_MIN_AH_INDEX + 1, }, + [RXE_TYPE_XRCD] = { + .name = "xrcd", + .size = sizeof(struct rxe_xrcd), + .elem_offset = offsetof(struct rxe_xrcd, elem), + .min_index = RXE_MIN_XRCD_INDEX, + .max_index = RXE_MAX_XRCD_INDEX, + .max_elem = RXE_MAX_XRCD_INDEX - RXE_MIN_XRCD_INDEX + 1, + }, [RXE_TYPE_SRQ] = { .name = "srq", .size = sizeof(struct rxe_srq), diff --git a/drivers/infiniband/sw/rxe/rxe_pool.h b/drivers/infiniband/sw/rxe/rxe_pool.h index 9d83cb32092f..35ac0746a4b8 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.h +++ b/drivers/infiniband/sw/rxe/rxe_pool.h @@ -11,6 +11,7 @@ enum rxe_elem_type { RXE_TYPE_UC, RXE_TYPE_PD, RXE_TYPE_AH, + RXE_TYPE_XRCD, RXE_TYPE_SRQ, RXE_TYPE_QP, RXE_TYPE_CQ, diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 88825edc7dce..c7641bdf3ba1 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -280,6 +280,26 @@ static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr) return err; } +static int rxe_alloc_xrcd(struct ib_xrcd *ibxrcd, struct ib_udata *udata) +{ + struct rxe_dev *rxe = to_rdev(ibxrcd->device); + struct rxe_xrcd *xrcd = to_rxrcd(ibxrcd); + int err; + + err = rxe_add_to_pool(&rxe->xrcd_pool, xrcd); + + return err; +} + +static int rxe_dealloc_xrcd(struct ib_xrcd *ibxrcd, struct ib_udata *udata) +{ + struct rxe_xrcd *xrcd = to_rxrcd(ibxrcd); + + rxe_cleanup(xrcd); + + return 0; +} + static int rxe_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init, struct ib_udata *udata) { @@ -1053,6 +1073,7 @@ static const struct ib_device_ops rxe_dev_ops = { .alloc_mw = rxe_alloc_mw, .alloc_pd = rxe_alloc_pd, .alloc_ucontext = rxe_alloc_ucontext, + .alloc_xrcd = rxe_alloc_xrcd, .attach_mcast = rxe_attach_mcast, .create_ah = rxe_create_ah, .create_cq = rxe_create_cq, @@ -1063,6 +1084,7 @@ static const struct ib_device_ops rxe_dev_ops = { .dealloc_mw = rxe_dealloc_mw, .dealloc_pd = rxe_dealloc_pd, .dealloc_ucontext = rxe_dealloc_ucontext, + .dealloc_xrcd = rxe_dealloc_xrcd, .dereg_mr = rxe_dereg_mr, .destroy_ah = rxe_destroy_ah, .destroy_cq = rxe_destroy_cq, @@ -1101,6 +1123,7 @@ static const struct ib_device_ops rxe_dev_ops = { INIT_RDMA_OBJ_SIZE(ib_cq, rxe_cq, ibcq), INIT_RDMA_OBJ_SIZE(ib_pd, rxe_pd, ibpd), INIT_RDMA_OBJ_SIZE(ib_qp, rxe_qp, ibqp), + INIT_RDMA_OBJ_SIZE(ib_xrcd, rxe_xrcd, ibxrcd), INIT_RDMA_OBJ_SIZE(ib_srq, rxe_srq, ibsrq), INIT_RDMA_OBJ_SIZE(ib_ucontext, rxe_ucontext, ibuc), INIT_RDMA_OBJ_SIZE(ib_mw, rxe_mw, ibmw), diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index 5f5cbfcb3569..fb2fbf281232 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -93,6 +93,11 @@ struct rxe_rq { struct rxe_queue *queue; }; +struct rxe_xrcd { + struct ib_xrcd ibxrcd; + struct rxe_pool_elem elem; +}; + struct rxe_srq { struct ib_srq ibsrq; struct rxe_pool_elem elem; @@ -381,6 +386,7 @@ struct rxe_dev { struct rxe_pool uc_pool; struct rxe_pool pd_pool; struct rxe_pool ah_pool; + struct rxe_pool xrcd_pool; struct rxe_pool srq_pool; struct rxe_pool qp_pool; struct rxe_pool cq_pool; @@ -430,6 +436,11 @@ static inline struct rxe_ah *to_rah(struct ib_ah *ah) return ah ? container_of(ah, struct rxe_ah, ibah) : NULL; } +static inline struct rxe_xrcd *to_rxrcd(struct ib_xrcd *ibxrcd) +{ + return ibxrcd ? container_of(ibxrcd, struct rxe_xrcd, ibxrcd) : NULL; +} + static inline struct rxe_srq *to_rsrq(struct ib_srq *srq) { return srq ? container_of(srq, struct rxe_srq, ibsrq) : NULL;