@@ -51,6 +51,24 @@ struct efa_context {
5151struct 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
5674struct 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
145166struct 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+
204235bool is_efa_dev (struct ibv_device * device );
205236
206237#endif /* __EFA_H__ */
0 commit comments