@@ -175,6 +175,9 @@ int efadv_query_device(struct ibv_context *ibvctx,
175
175
176
176
if (EFA_DEV_CAP (ctx , UNSOLICITED_WRITE_RECV ))
177
177
attr -> device_caps |= EFADV_DEVICE_ATTR_CAPS_UNSOLICITED_WRITE_RECV ;
178
+
179
+ if (EFA_DEV_CAP (ctx , CQ_WITH_EXT_MEM_DMABUF ))
180
+ attr -> device_caps |= EFADV_DEVICE_ATTR_CAPS_CQ_WITH_EXT_MEM_DMABUF ;
178
181
}
179
182
180
183
if (vext_field_avail (typeof (* attr ), max_rdma_size , inlen )) {
@@ -873,9 +876,9 @@ static void efa_cq_fill_pfns(struct efa_cq *cq,
873
876
if (attr -> wc_flags & IBV_WC_EX_WITH_DLID_PATH_BITS )
874
877
ibvcqx -> read_dlid_path_bits = efa_wc_read_dlid_path_bits ;
875
878
876
- if (efa_attr && ( efa_attr -> wc_flags & EFADV_WC_EX_WITH_SGID ) )
879
+ if (efa_attr -> wc_flags & EFADV_WC_EX_WITH_SGID )
877
880
cq -> dv_cq .wc_read_sgid = efa_wc_read_sgid ;
878
- if (efa_attr && ( efa_attr -> wc_flags & EFADV_WC_EX_WITH_IS_UNSOLICITED ) )
881
+ if (efa_attr -> wc_flags & EFADV_WC_EX_WITH_IS_UNSOLICITED )
879
882
cq -> dv_cq .wc_is_unsolicited = efa_wc_is_unsolicited ;
880
883
}
881
884
@@ -925,12 +928,20 @@ static struct ibv_cq_ex *create_cq(struct ibv_context *ibvctx,
925
928
if (!cq )
926
929
return NULL ;
927
930
928
- if (efa_attr && ( efa_attr -> wc_flags & EFADV_WC_EX_WITH_SGID ) )
931
+ if (efa_attr -> wc_flags & EFADV_WC_EX_WITH_SGID )
929
932
cmd .flags |= EFA_CREATE_CQ_WITH_SGID ;
930
933
931
934
num_sub_cqs = ctx -> sub_cqs_per_cq ;
932
935
cmd .num_sub_cqs = num_sub_cqs ;
933
936
cmd .cq_entry_size = cqe_size ;
937
+
938
+ if (efa_attr -> flags & EFADV_CQ_INIT_FLAGS_EXT_MEM_DMABUF ) {
939
+ cmd .ext_mem_fd = efa_attr -> ext_mem_dmabuf .fd ;
940
+ cmd .ext_mem_offset = efa_attr -> ext_mem_dmabuf .offset ;
941
+ cmd .ext_mem_length = efa_attr -> ext_mem_dmabuf .length ;
942
+ cmd .flags |= EFA_CREATE_CQ_WITH_EXT_MEM_DMABUF ;
943
+ }
944
+
934
945
if (attr -> channel )
935
946
cmd .flags |= EFA_CREATE_CQ_WITH_COMPLETION_CHANNEL ;
936
947
@@ -950,17 +961,18 @@ static struct ibv_cq_ex *create_cq(struct ibv_context *ibvctx,
950
961
cq -> cqe_size = cqe_size ;
951
962
cq -> dev = ibvctx -> device ;
952
963
953
- cq -> buf = mmap (NULL , cq -> buf_size , PROT_READ , MAP_SHARED ,
954
- ibvctx -> cmd_fd , resp .q_mmap_key );
955
- if (cq -> buf == MAP_FAILED )
956
- goto err_destroy_cq ;
957
-
958
- buf = cq -> buf ;
959
- sub_buf_size = cq -> cqe_size * sub_cq_size ;
960
- for (i = 0 ; i < num_sub_cqs ; i ++ ) {
961
- efa_sub_cq_initialize (& cq -> sub_cq_arr [i ], buf , sub_cq_size ,
962
- cq -> cqe_size );
963
- buf += sub_buf_size ;
964
+ if (!(efa_attr -> flags & EFADV_CQ_INIT_FLAGS_EXT_MEM_DMABUF )) {
965
+ cq -> buf = mmap (NULL , cq -> buf_size , PROT_READ , MAP_SHARED , ibvctx -> cmd_fd ,
966
+ resp .q_mmap_key );
967
+ if (cq -> buf == MAP_FAILED )
968
+ goto err_destroy_cq ;
969
+
970
+ buf = cq -> buf ;
971
+ sub_buf_size = cq -> cqe_size * sub_cq_size ;
972
+ for (i = 0 ; i < num_sub_cqs ; i ++ ) {
973
+ efa_sub_cq_initialize (& cq -> sub_cq_arr [i ], buf , sub_cq_size , cq -> cqe_size );
974
+ buf += sub_buf_size ;
975
+ }
964
976
}
965
977
966
978
if (resp .comp_mask & EFA_CREATE_CQ_RESP_DB_OFF ) {
@@ -991,29 +1003,33 @@ static struct ibv_cq_ex *create_cq(struct ibv_context *ibvctx,
991
1003
struct ibv_cq * efa_create_cq (struct ibv_context * ibvctx , int ncqe ,
992
1004
struct ibv_comp_channel * channel , int vec )
993
1005
{
1006
+ struct efadv_cq_init_attr efa_attr = {};
994
1007
struct ibv_cq_init_attr_ex attr_ex = {
995
1008
.cqe = ncqe ,
996
1009
.channel = channel ,
997
1010
.comp_vector = vec
998
1011
};
999
1012
struct ibv_cq_ex * ibvcqx ;
1000
1013
1001
- ibvcqx = create_cq (ibvctx , & attr_ex , NULL );
1014
+ ibvcqx = create_cq (ibvctx , & attr_ex , & efa_attr );
1002
1015
1003
1016
return ibvcqx ? ibv_cq_ex_to_cq (ibvcqx ) : NULL ;
1004
1017
}
1005
1018
1006
1019
struct ibv_cq_ex * efa_create_cq_ex (struct ibv_context * ibvctx ,
1007
1020
struct ibv_cq_init_attr_ex * attr_ex )
1008
1021
{
1009
- return create_cq (ibvctx , attr_ex , NULL );
1022
+ struct efadv_cq_init_attr efa_attr = {};
1023
+
1024
+ return create_cq (ibvctx , attr_ex , & efa_attr );
1010
1025
}
1011
1026
1012
1027
struct ibv_cq_ex * efadv_create_cq (struct ibv_context * ibvctx ,
1013
1028
struct ibv_cq_init_attr_ex * attr_ex ,
1014
1029
struct efadv_cq_init_attr * efa_attr ,
1015
1030
uint32_t inlen )
1016
1031
{
1032
+ struct efadv_cq_init_attr local_efa_attr = {};
1017
1033
uint64_t supp_wc_flags = 0 ;
1018
1034
struct efa_context * ctx ;
1019
1035
@@ -1043,7 +1059,8 @@ struct ibv_cq_ex *efadv_create_cq(struct ibv_context *ibvctx,
1043
1059
return NULL ;
1044
1060
}
1045
1061
1046
- return create_cq (ibvctx , attr_ex , efa_attr );
1062
+ memcpy (& local_efa_attr , efa_attr , min_t (uint32_t , inlen , sizeof (local_efa_attr )));
1063
+ return create_cq (ibvctx , attr_ex , & local_efa_attr );
1047
1064
}
1048
1065
1049
1066
int efadv_query_cq (struct ibv_cq * ibvcq , struct efadv_cq_attr * attr , uint32_t inlen )
0 commit comments