From efbf69f6c7d036e06939079fa01fe8e4c4400f15 Mon Sep 17 00:00:00 2001 From: Shi Jin Date: Fri, 3 Jan 2025 22:21:47 +0000 Subject: [PATCH] prov/efa: Migrate efa_dgram_ep to efa_ep Migrate dgram/efa_dgram_ep.c to efa_ep.c as a common ep interface for both dgram and rdm ep type. dgram repo now has nothing and is removed. Signed-off-by: Shi Jin --- prov/efa/Makefile.include | 4 +- prov/efa/src/dgram/efa_dgram_ep.h | 18 --- prov/efa/src/efa_base_ep.h | 3 + prov/efa/src/efa_cq.c | 1 - prov/efa/src/efa_domain.c | 3 +- .../src/{dgram/efa_dgram_ep.c => efa_ep.c} | 134 +++++++++--------- prov/efa/test/efa_unit_test_cq.c | 2 - 7 files changed, 73 insertions(+), 92 deletions(-) delete mode 100644 prov/efa/src/dgram/efa_dgram_ep.h rename prov/efa/src/{dgram/efa_dgram_ep.c => efa_ep.c} (65%) diff --git a/prov/efa/Makefile.include b/prov/efa/Makefile.include index db5e44df1f0..a5c2842d389 100644 --- a/prov/efa/Makefile.include +++ b/prov/efa/Makefile.include @@ -50,7 +50,7 @@ _efa_files = \ prov/efa/src/efa_msg.c \ prov/efa/src/efa_rma.c \ prov/efa/src/efa_cq.c \ - prov/efa/src/dgram/efa_dgram_ep.c \ + prov/efa/src/efa_ep.c \ prov/efa/src/rdm/efa_rdm_peer.c \ prov/efa/src/rdm/efa_rdm_cq.c \ prov/efa/src/rdm/efa_rdm_ep_utils.c \ @@ -94,7 +94,6 @@ _efa_headers = \ prov/efa/src/efa_prov.h \ prov/efa/src/efa_env.h \ prov/efa/src/fi_ext_efa.h \ - prov/efa/src/dgram/efa_dgram_ep.h \ prov/efa/src/rdm/efa_rdm_peer.h \ prov/efa/src/rdm/efa_rdm_cq.h \ prov/efa/src/rdm/efa_rdm_ep.h \ @@ -187,7 +186,6 @@ endif ENABLE_EFA_UNIT_TEST efa_CPPFLAGS += \ -I$(top_srcdir)/prov/efa/src/ \ - -I$(top_srcdir)/prov/efa/src/dgram/ \ -I$(top_srcdir)/prov/efa/src/rdm/ rdmainclude_HEADERS += \ diff --git a/prov/efa/src/dgram/efa_dgram_ep.h b/prov/efa/src/dgram/efa_dgram_ep.h deleted file mode 100644 index 18ab0dc8703..00000000000 --- a/prov/efa/src/dgram/efa_dgram_ep.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-only */ -/* SPDX-FileCopyrightText: Copyright Amazon.com, Inc. or its affiliates. All rights reserved. */ - -#include "efa_base_ep.h" - -#ifndef EFA_DGRAM_H -#define EFA_DGRAM_H - -struct efa_dgram_ep { - struct efa_base_ep base_ep; -}; - -int efa_dgram_ep_open(struct fid_domain *domain_fid, struct fi_info *info, - struct fid_ep **ep_fid, void *context); - -extern struct fi_ops_msg efa_dgram_ep_msg_ops; -extern struct fi_ops_rma efa_dgram_ep_rma_ops; -#endif diff --git a/prov/efa/src/efa_base_ep.h b/prov/efa/src/efa_base_ep.h index a7d1526919e..d8d205815b7 100644 --- a/prov/efa/src/efa_base_ep.h +++ b/prov/efa/src/efa_base_ep.h @@ -82,6 +82,9 @@ int efa_base_ep_construct(struct efa_base_ep *base_ep, int efa_base_ep_getname(fid_t fid, void *addr, size_t *addrlen); +int efa_ep_open(struct fid_domain *domain_fid, struct fi_info *user_info, + struct fid_ep **ep_fid, void *context); + int efa_qp_create(struct efa_qp **qp, struct ibv_qp_init_attr_ex *init_attr_ex, uint32_t tclass); void efa_qp_destruct(struct efa_qp *qp); diff --git a/prov/efa/src/efa_cq.c b/prov/efa/src/efa_cq.c index a5b737d89ac..ea9f13c365e 100644 --- a/prov/efa/src/efa_cq.c +++ b/prov/efa/src/efa_cq.c @@ -6,7 +6,6 @@ #include #include "config.h" #include -#include "dgram/efa_dgram_ep.h" #include "efa.h" #include "efa_av.h" #include "efa_cntr.h" diff --git a/prov/efa/src/efa_domain.c b/prov/efa/src/efa_domain.c index 17e948c7eef..34de62cebac 100644 --- a/prov/efa/src/efa_domain.c +++ b/prov/efa/src/efa_domain.c @@ -11,7 +11,6 @@ #include "efa_cntr.h" #include "rdm/efa_rdm_cq.h" #include "rdm/efa_rdm_atomic.h" -#include "dgram/efa_dgram_ep.h" struct dlist_entry g_efa_domain_list; @@ -33,7 +32,7 @@ static struct fi_ops_domain efa_ops_domain_dgram = { .size = sizeof(struct fi_ops_domain), .av_open = efa_av_open, .cq_open = efa_cq_open, - .endpoint = efa_dgram_ep_open, + .endpoint = efa_ep_open, .scalable_ep = fi_no_scalable_ep, .cntr_open = efa_cntr_open, .poll_open = fi_no_poll_open, diff --git a/prov/efa/src/dgram/efa_dgram_ep.c b/prov/efa/src/efa_ep.c similarity index 65% rename from prov/efa/src/dgram/efa_dgram_ep.c rename to prov/efa/src/efa_ep.c index 3119b8bee72..3b8b9190629 100644 --- a/prov/efa/src/dgram/efa_dgram_ep.c +++ b/prov/efa/src/efa_ep.c @@ -3,14 +3,16 @@ /* SPDX-FileCopyrightText: Copyright Amazon.com, Inc. or its affiliates. All rights reserved. */ #include "config.h" -#include "efa_dgram_ep.h" #include "efa.h" #include "efa_av.h" #include "efa_cq.h" #include -static int efa_dgram_ep_getopt(fid_t fid, int level, int optname, +extern struct fi_ops_msg efa_msg_ops; +extern struct fi_ops_rma efa_rma_ops; + +static int efa_ep_getopt(fid_t fid, int level, int optname, void *optval, size_t *optlen) { switch (level) { @@ -22,7 +24,7 @@ static int efa_dgram_ep_getopt(fid_t fid, int level, int optname, return 0; } -static int efa_dgram_ep_setopt(fid_t fid, int level, int optname, const void *optval, size_t optlen) +static int efa_ep_setopt(fid_t fid, int level, int optname, const void *optval, size_t optlen) { switch (level) { case FI_OPT_ENDPOINT: @@ -33,22 +35,22 @@ static int efa_dgram_ep_setopt(fid_t fid, int level, int optname, const void *op return 0; } -static struct fi_ops_ep efa_dgram_ep_base_ops = { +static struct fi_ops_ep efa_ep_base_ops = { .size = sizeof(struct fi_ops_ep), .cancel = fi_no_cancel, - .getopt = efa_dgram_ep_getopt, - .setopt = efa_dgram_ep_setopt, + .getopt = efa_ep_getopt, + .setopt = efa_ep_setopt, .tx_ctx = fi_no_tx_ctx, .rx_ctx = fi_no_rx_ctx, .rx_size_left = fi_no_rx_size_left, .tx_size_left = fi_no_tx_size_left, }; -static void efa_dgram_ep_destroy(struct efa_dgram_ep *ep) +static void efa_ep_destroy(struct efa_base_ep *ep) { int ret; - ret = efa_base_ep_destruct(&ep->base_ep); + ret = efa_base_ep_destruct(ep); if (ret) { EFA_WARN(FI_LOG_EP_CTRL, "Unable to close base endpoint\n"); } @@ -56,20 +58,20 @@ static void efa_dgram_ep_destroy(struct efa_dgram_ep *ep) free(ep); } -static int efa_dgram_ep_close(fid_t fid) +static int efa_ep_close(fid_t fid) { - struct efa_dgram_ep *ep; + struct efa_base_ep *ep; - ep = container_of(fid, struct efa_dgram_ep, base_ep.util_ep.ep_fid.fid); + ep = container_of(fid, struct efa_base_ep, util_ep.ep_fid.fid); - efa_dgram_ep_destroy(ep); + efa_ep_destroy(ep); return 0; } -static int efa_dgram_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags) +static int efa_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags) { - struct efa_dgram_ep *ep; + struct efa_base_ep *ep; struct efa_cq *cq; struct efa_av *av; struct efa_domain *efa_domain; @@ -77,7 +79,7 @@ static int efa_dgram_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags) struct util_cntr *cntr; int ret; - ep = container_of(fid, struct efa_dgram_ep, base_ep.util_ep.ep_fid.fid); + ep = container_of(fid, struct efa_base_ep, util_ep.ep_fid.fid); ret = ofi_ep_bind_valid(&efa_prov, bfid, flags); if (ret) return ret; @@ -96,31 +98,31 @@ static int efa_dgram_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags) cq = container_of(bfid, struct efa_cq, util_cq.cq_fid); efa_domain = container_of(cq->util_cq.domain, struct efa_domain, util_domain); - if (ep->base_ep.domain != efa_domain) + if (ep->domain != efa_domain) return -FI_EINVAL; - ret = ofi_ep_bind_cq(&ep->base_ep.util_ep, &cq->util_cq, flags); + ret = ofi_ep_bind_cq(&ep->util_ep, &cq->util_cq, flags); if (ret) return ret; break; case FI_CLASS_AV: av = container_of(bfid, struct efa_av, util_av.av_fid.fid); - ret = efa_base_ep_bind_av(&ep->base_ep, av); + ret = efa_base_ep_bind_av(ep, av); if (ret) return ret; break; case FI_CLASS_CNTR: cntr = container_of(bfid, struct util_cntr, cntr_fid.fid); - ret = ofi_ep_bind_cntr(&ep->base_ep.util_ep, cntr, flags); + ret = ofi_ep_bind_cntr(&ep->util_ep, cntr, flags); if (ret) return ret; break; case FI_CLASS_EQ: eq = container_of(bfid, struct util_eq, eq_fid.fid); - ret = ofi_ep_bind_eq(&ep->base_ep.util_ep, eq); + ret = ofi_ep_bind_eq(&ep->util_ep, eq); if (ret) return ret; break; @@ -131,11 +133,11 @@ static int efa_dgram_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags) return 0; } -static int efa_dgram_ep_getflags(struct fid_ep *ep_fid, uint64_t *flags) +static int efa_ep_getflags(struct fid_ep *ep_fid, uint64_t *flags) { - struct efa_dgram_ep *ep = container_of(ep_fid, struct efa_dgram_ep, base_ep.util_ep.ep_fid); - struct fi_tx_attr *tx_attr = ep->base_ep.info->tx_attr; - struct fi_rx_attr *rx_attr = ep->base_ep.info->rx_attr; + struct efa_base_ep *ep = container_of(ep_fid, struct efa_base_ep, util_ep.ep_fid); + struct fi_tx_attr *tx_attr = ep->info->tx_attr; + struct fi_rx_attr *rx_attr = ep->info->rx_attr; if ((*flags & FI_TRANSMIT) && (*flags & FI_RECV)) { EFA_WARN(FI_LOG_EP_CTRL, "Both Tx/Rx flags cannot be specified\n"); @@ -151,11 +153,11 @@ static int efa_dgram_ep_getflags(struct fid_ep *ep_fid, uint64_t *flags) return 0; } -static int efa_dgram_ep_setflags(struct fid_ep *ep_fid, uint64_t flags) +static int efa_ep_setflags(struct fid_ep *ep_fid, uint64_t flags) { - struct efa_dgram_ep *ep = container_of(ep_fid, struct efa_dgram_ep, base_ep.util_ep.ep_fid); - struct fi_tx_attr *tx_attr = ep->base_ep.info->tx_attr; - struct fi_rx_attr *rx_attr = ep->base_ep.info->rx_attr; + struct efa_base_ep *ep = container_of(ep_fid, struct efa_base_ep, util_ep.ep_fid); + struct fi_tx_attr *tx_attr = ep->info->tx_attr; + struct fi_rx_attr *rx_attr = ep->info->rx_attr; if ((flags & FI_TRANSMIT) && (flags & FI_RECV)) { EFA_WARN(FI_LOG_EP_CTRL, "Both Tx/Rx flags cannot be specified.\n"); @@ -174,17 +176,17 @@ static int efa_dgram_ep_setflags(struct fid_ep *ep_fid, uint64_t flags) return 0; } -static int efa_dgram_ep_enable(struct fid_ep *ep_fid) +static int efa_ep_enable(struct fid_ep *ep_fid) { struct ibv_qp_init_attr_ex attr_ex = { 0 }; - struct efa_dgram_ep *ep; + struct efa_base_ep *ep; struct efa_cq *scq, *rcq; int err; - ep = container_of(ep_fid, struct efa_dgram_ep, base_ep.util_ep.ep_fid); + ep = container_of(ep_fid, struct efa_base_ep, util_ep.ep_fid); - scq = ep->base_ep.util_ep.tx_cq ? container_of(ep->base_ep.util_ep.tx_cq, struct efa_cq, util_cq) : NULL; - rcq = ep->base_ep.util_ep.rx_cq ? container_of(ep->base_ep.util_ep.rx_cq, struct efa_cq, util_cq) : NULL; + scq = ep->util_ep.tx_cq ? container_of(ep->util_ep.tx_cq, struct efa_cq, util_cq) : NULL; + rcq = ep->util_ep.rx_cq ? container_of(ep->util_ep.rx_cq, struct efa_cq, util_cq) : NULL; if (!scq && !rcq) { EFA_WARN(FI_LOG_EP_CTRL, @@ -192,53 +194,53 @@ static int efa_dgram_ep_enable(struct fid_ep *ep_fid) return -FI_ENOCQ; } - if (!scq && ofi_needs_tx(ep->base_ep.info->caps)) { + if (!scq && ofi_needs_tx(ep->info->caps)) { EFA_WARN(FI_LOG_EP_CTRL, "Endpoint is not bound to a send completion queue when it has transmit capabilities enabled (FI_SEND).\n"); return -FI_ENOCQ; } - if (!rcq && ofi_needs_rx(ep->base_ep.info->caps)) { + if (!rcq && ofi_needs_rx(ep->info->caps)) { EFA_WARN(FI_LOG_EP_CTRL, "Endpoint is not bound to a receive completion queue when it has receive capabilities enabled. (FI_RECV)\n"); return -FI_ENOCQ; } if (scq) { - attr_ex.cap.max_send_wr = ep->base_ep.info->tx_attr->size; - attr_ex.cap.max_send_sge = ep->base_ep.info->tx_attr->iov_limit; + attr_ex.cap.max_send_wr = ep->info->tx_attr->size; + attr_ex.cap.max_send_sge = ep->info->tx_attr->iov_limit; attr_ex.send_cq = ibv_cq_ex_to_cq(scq->ibv_cq.ibv_cq_ex); } else { attr_ex.send_cq = ibv_cq_ex_to_cq(rcq->ibv_cq.ibv_cq_ex); } if (rcq) { - attr_ex.cap.max_recv_wr = ep->base_ep.info->rx_attr->size; - attr_ex.cap.max_recv_sge = ep->base_ep.info->rx_attr->iov_limit; + attr_ex.cap.max_recv_wr = ep->info->rx_attr->size; + attr_ex.cap.max_recv_sge = ep->info->rx_attr->iov_limit; attr_ex.recv_cq = ibv_cq_ex_to_cq(rcq->ibv_cq.ibv_cq_ex); } else { attr_ex.recv_cq = ibv_cq_ex_to_cq(scq->ibv_cq.ibv_cq_ex); } attr_ex.cap.max_inline_data = - ep->base_ep.domain->device->efa_attr.inline_buf_size; + ep->domain->device->efa_attr.inline_buf_size; - assert(EFA_EP_TYPE_IS_DGRAM(ep->base_ep.domain->info)); + assert(EFA_EP_TYPE_IS_DGRAM(ep->domain->info)); attr_ex.qp_type = IBV_QPT_UD; attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD; - attr_ex.pd = container_of(ep->base_ep.util_ep.domain, struct efa_domain, util_domain)->ibv_pd; + attr_ex.pd = container_of(ep->util_ep.domain, struct efa_domain, util_domain)->ibv_pd; attr_ex.qp_context = ep; attr_ex.sq_sig_all = 1; - err = efa_base_ep_create_qp(&ep->base_ep, &attr_ex); + err = efa_base_ep_create_qp(ep, &attr_ex); if (err) return err; - return efa_base_ep_enable(&ep->base_ep); + return efa_base_ep_enable(ep); } -static int efa_dgram_ep_control(struct fid *fid, int command, void *arg) +static int efa_ep_control(struct fid *fid, int command, void *arg) { struct fid_ep *ep_fid; @@ -247,11 +249,11 @@ static int efa_dgram_ep_control(struct fid *fid, int command, void *arg) ep_fid = container_of(fid, struct fid_ep, fid); switch (command) { case FI_GETOPSFLAG: - return efa_dgram_ep_getflags(ep_fid, (uint64_t *)arg); + return efa_ep_getflags(ep_fid, (uint64_t *)arg); case FI_SETOPSFLAG: - return efa_dgram_ep_setflags(ep_fid, *(uint64_t *)arg); + return efa_ep_setflags(ep_fid, *(uint64_t *)arg); case FI_ENABLE: - return efa_dgram_ep_enable(ep_fid); + return efa_ep_enable(ep_fid); default: return -FI_ENOSYS; } @@ -261,11 +263,11 @@ static int efa_dgram_ep_control(struct fid *fid, int command, void *arg) } } -static struct fi_ops efa_dgram_ep_ops = { +static struct fi_ops efa_ep_ops = { .size = sizeof(struct fi_ops), - .close = efa_dgram_ep_close, - .bind = efa_dgram_ep_bind, - .control = efa_dgram_ep_control, + .close = efa_ep_close, + .bind = efa_ep_bind, + .control = efa_ep_control, .ops_open = fi_no_ops_open, }; @@ -282,7 +284,7 @@ void efa_ep_progress_no_op(struct util_ep *util_ep) return; } -static struct fi_ops_atomic efa_dgram_ep_atomic_ops = { +static struct fi_ops_atomic efa_atomic_ops = { .size = sizeof(struct fi_ops_atomic), .write = fi_no_atomic_write, .writev = fi_no_atomic_writev, @@ -299,7 +301,7 @@ static struct fi_ops_atomic efa_dgram_ep_atomic_ops = { .compwritevalid = fi_no_atomic_compwritevalid, }; -struct fi_ops_cm efa_dgram_ep_cm_ops = { +struct fi_ops_cm efa_ep_cm_ops = { .size = sizeof(struct fi_ops_cm), .setname = fi_no_setname, .getname = efa_base_ep_getname, @@ -312,12 +314,12 @@ struct fi_ops_cm efa_dgram_ep_cm_ops = { .join = fi_no_join, }; -int efa_dgram_ep_open(struct fid_domain *domain_fid, struct fi_info *user_info, +int efa_ep_open(struct fid_domain *domain_fid, struct fi_info *user_info, struct fid_ep **ep_fid, void *context) { struct efa_domain *domain; const struct fi_info *prov_info; - struct efa_dgram_ep *ep; + struct efa_base_ep *ep; int ret; domain = container_of(domain_fid, struct efa_domain, @@ -355,7 +357,7 @@ int efa_dgram_ep_open(struct fid_domain *domain_fid, struct fi_info *user_info, if (!ep) return -FI_ENOMEM; - ret = efa_base_ep_construct(&ep->base_ep, domain_fid, user_info, efa_ep_progress_no_op, context); + ret = efa_base_ep_construct(ep, domain_fid, user_info, efa_ep_progress_no_op, context); if (ret) goto err_ep_destroy; @@ -364,21 +366,21 @@ int efa_dgram_ep_open(struct fid_domain *domain_fid, struct fi_info *user_info, */ assert(user_info->tx_attr->iov_limit <= 2); - ep->base_ep.domain = domain; + ep->domain = domain; - *ep_fid = &ep->base_ep.util_ep.ep_fid; + *ep_fid = &ep->util_ep.ep_fid; (*ep_fid)->fid.fclass = FI_CLASS_EP; (*ep_fid)->fid.context = context; - (*ep_fid)->fid.ops = &efa_dgram_ep_ops; - (*ep_fid)->ops = &efa_dgram_ep_base_ops; - (*ep_fid)->msg = &efa_dgram_ep_msg_ops; - (*ep_fid)->cm = &efa_dgram_ep_cm_ops; - (*ep_fid)->rma = &efa_dgram_ep_rma_ops; - (*ep_fid)->atomic = &efa_dgram_ep_atomic_ops; + (*ep_fid)->fid.ops = &efa_ep_ops; + (*ep_fid)->ops = &efa_ep_base_ops; + (*ep_fid)->msg = &efa_msg_ops; + (*ep_fid)->cm = &efa_ep_cm_ops; + (*ep_fid)->rma = &efa_rma_ops; + (*ep_fid)->atomic = &efa_atomic_ops; return 0; err_ep_destroy: - efa_dgram_ep_destroy(ep); + efa_ep_destroy(ep); return ret; } diff --git a/prov/efa/test/efa_unit_test_cq.c b/prov/efa/test/efa_unit_test_cq.c index e69fb8b432e..e939d182b60 100644 --- a/prov/efa/test/efa_unit_test_cq.c +++ b/prov/efa/test/efa_unit_test_cq.c @@ -2,7 +2,6 @@ /* SPDX-FileCopyrightText: Copyright Amazon.com, Inc. or its affiliates. All rights reserved. */ #include "efa_unit_tests.h" -#include "dgram/efa_dgram_ep.h" #include "rdm/efa_rdm_cq.h" #include "efa_av.h" @@ -25,7 +24,6 @@ void test_impl_cq_read_empty_cq(struct efa_resource *resource, enum fi_ep_type e efa_unit_test_resource_construct(resource, ep_type); efa_base_ep = container_of(resource->ep, struct efa_base_ep, util_ep.ep_fid); - ibv_cqx = container_of(efa_base_ep->util_ep.rx_cq, struct efa_cq, util_cq)->ibv_cq.ibv_cq_ex; ibv_cqx->start_poll = &efa_mock_ibv_start_poll_return_mock;