Skip to content

Commit b503436

Browse files
authored
Merge pull request #1626 from amzn/parent_domains
efa: Parent domains and thread domains support
2 parents c0d5740 + ee1b331 commit b503436

File tree

4 files changed

+241
-16
lines changed

4 files changed

+241
-16
lines changed

providers/efa/efa.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
22
/*
3-
* Copyright 2019-2024 Amazon.com, Inc. or its affiliates. All rights reserved.
3+
* Copyright 2019-2025 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#include <stdio.h>
@@ -28,13 +28,16 @@ static const struct verbs_match_ent efa_table[] = {
2828

2929
static const struct verbs_context_ops efa_ctx_ops = {
3030
.alloc_pd = efa_alloc_pd,
31+
.alloc_parent_domain = efa_alloc_parent_domain,
32+
.alloc_td = efa_alloc_td,
3133
.create_ah = efa_create_ah,
3234
.create_cq = efa_create_cq,
3335
.create_cq_ex = efa_create_cq_ex,
3436
.create_qp = efa_create_qp,
3537
.create_qp_ex = efa_create_qp_ex,
3638
.cq_event = efa_cq_event,
3739
.dealloc_pd = efa_dealloc_pd,
40+
.dealloc_td = efa_dealloc_td,
3841
.dereg_mr = efa_dereg_mr,
3942
.destroy_ah = efa_destroy_ah,
4043
.destroy_cq = efa_destroy_cq,

providers/efa/efa.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ struct efa_context {
5151
struct efa_pd {
5252
struct ibv_pd ibvpd;
5353
uint16_t pdn;
54+
/* Pointer to original PD used to create parent domain */
55+
struct efa_pd *orig_pd;
56+
/* Number of parent domains referencing this PD */
57+
atomic_int refcount;
58+
};
59+
60+
struct efa_td {
61+
struct ibv_td ibvtd;
62+
/* Number of parent domains referencing this TD */
63+
atomic_int refcount;
64+
};
65+
66+
struct efa_parent_domain {
67+
struct efa_pd pd;
68+
struct efa_td *td;
69+
/* Number of objects referencing this parent domain */
70+
atomic_int refcount;
71+
void *pd_context;
5472
};
5573

5674
struct efa_sub_cq {
@@ -81,6 +99,7 @@ struct efa_cq {
8199
struct efa_wq *cur_wq;
82100
struct efa_io_cdesc_common *cur_cqe;
83101
struct ibv_device *dev;
102+
struct efa_parent_domain *parent_domain;
84103
struct efa_sub_cq sub_cq_arr[];
85104
};
86105

@@ -102,6 +121,7 @@ struct efa_wq {
102121
int max_sge;
103122
int phase;
104123
pthread_spinlock_t wqlock;
124+
bool need_lock;
105125

106126
uint32_t *db;
107127
uint16_t sub_cq_idx;
@@ -140,6 +160,7 @@ struct efa_qp {
140160
int sq_sig_all;
141161
int wr_session_err;
142162
struct ibv_device *dev;
163+
struct efa_parent_domain *parent_domain;
143164
};
144165

145166
struct efa_mr {
@@ -201,6 +222,16 @@ static inline struct efa_ah *to_efa_ah(struct ibv_ah *ibvah)
201222
return container_of(ibvah, struct efa_ah, ibvah);
202223
}
203224

225+
static inline struct efa_td *to_efa_td(struct ibv_td *ibvtd)
226+
{
227+
return container_of(ibvtd, struct efa_td, ibvtd);
228+
}
229+
230+
static inline struct efa_parent_domain *to_efa_parent_domain(struct ibv_pd *ibvpd)
231+
{
232+
return container_of(ibvpd, struct efa_parent_domain, pd.ibvpd);
233+
}
234+
204235
bool is_efa_dev(struct ibv_device *device);
205236

206237
#endif /* __EFA_H__ */

0 commit comments

Comments
 (0)