@@ -531,7 +531,7 @@ static int rdma_read_keys(struct pingpong_dest *rem_dest,
531531}
532532
533533#ifdef HAVE_GID_TYPE
534- // declaration is copied from rdma-core, since it is private there.
534+ #ifndef HAVE_GID_TYPE_DECLARED
535535enum ibv_gid_type
536536{
537537 IBV_GID_TYPE_IB_ROCE_V1 ,
@@ -541,6 +541,7 @@ enum ibv_gid_type
541541int ibv_query_gid_type (struct ibv_context * context , uint8_t port_num ,
542542 unsigned int index , enum ibv_gid_type * type );
543543
544+ #endif
544545
545546enum who_is_better {LEFT_IS_BETTER , EQUAL , RIGHT_IS_BETTER };
546547
@@ -550,10 +551,17 @@ struct roce_version_sorted_enum {
550551};
551552
552553/* This struct defines which RoCE version is more important for default usage */
554+ #ifndef HAVE_GID_TYPE_DECLARED
553555struct roce_version_sorted_enum roce_versions_sorted [] = {
554556 {IBV_GID_TYPE_IB_ROCE_V1 , 1 },
555557 {IBV_GID_TYPE_ROCE_V2 , 2 },
556558};
559+ #else
560+ struct roce_version_sorted_enum roce_versions_sorted [] = {
561+ {IBV_GID_TYPE_ROCE_V1 , 1 },
562+ {IBV_GID_TYPE_ROCE_V2 , 2 },
563+ };
564+ #endif
557565
558566int find_roce_version_rate (enum ibv_gid_type roce_ver ) {
559567 int i ;
@@ -609,6 +617,20 @@ static int get_best_gid_index (struct pingpong_context *ctx,
609617 gid_index = i ;
610618#ifdef HAVE_GID_TYPE
611619 else {
620+ #ifdef HAVE_GID_TYPE_DECLARED
621+ struct ibv_gid_entry roce_version , roce_version_rival ;
622+
623+ if (ibv_query_gid_ex (ctx -> context , port , gid_index , & roce_version , 0 ))
624+ continue ;
625+
626+ if (ibv_query_gid_ex (ctx -> context , port , i , & roce_version_rival , 0 ))
627+ continue ;
628+
629+ if (check_better_roce_version (roce_version .gid_type , roce_version_rival .gid_type ) == RIGHT_IS_BETTER ) {
630+ gid_index = i ;
631+ }
632+
633+ #else
612634 enum ibv_gid_type roce_version , roce_version_rival ;
613635
614636 if (ibv_query_gid_type (ctx -> context , port , gid_index , & roce_version ))
@@ -617,8 +639,10 @@ static int get_best_gid_index (struct pingpong_context *ctx,
617639 if (ibv_query_gid_type (ctx -> context , port , i , & roce_version_rival ))
618640 continue ;
619641
620- if (check_better_roce_version (roce_version , roce_version_rival ) == RIGHT_IS_BETTER )
621- gid_index = i ;
642+ if (check_better_roce_version (roce_version , roce_version_rival ) == RIGHT_IS_BETTER ) {
643+ gid_index = i ;
644+ }
645+ #endif
622646 }
623647#endif
624648 }
0 commit comments