File tree Expand file tree Collapse file tree 1 file changed +8
-29
lines changed Expand file tree Collapse file tree 1 file changed +8
-29
lines changed Original file line number Diff line number Diff line change @@ -652,38 +652,17 @@ pub fn mlx5dv_supported() -> bool {
652652fn mlx5dv_supported_impl ( ) -> bool {
653653 // SAFETY: We are calling C functions from libibverbs and libmlx5.
654654 unsafe {
655+ let mut mlx5dv_supported = false ;
655656 let mut num_devices = 0 ;
656657 let device_list = rdmaxcel_sys:: ibv_get_device_list ( & mut num_devices) ;
657-
658- // Compute result in a block, ensuring cleanup happens afterward
659- let result = {
660- if device_list. is_null ( ) || num_devices == 0 {
661- false
662- } else {
663- // Try to open the first device and check mlx5dv support
664- let device = * device_list;
665- let mut mlx5dv_supported = false ;
666-
667- if !device. is_null ( ) {
668- let context = rdmaxcel_sys:: ibv_open_device ( device) ;
669- if !context. is_null ( ) {
670- // Try to query device capabilities with mlx5dv
671- let mut attrs_out = rdmaxcel_sys:: mlx5dv_context:: default ( ) ;
672-
673- // mlx5dv_query_device returns 0 on success
674- if rdmaxcel_sys:: mlx5dv_query_device ( context, & mut attrs_out) == 0 {
675- mlx5dv_supported = true ;
676- }
677-
678- rdmaxcel_sys:: ibv_close_device ( context) ;
679- }
680- }
681- mlx5dv_supported
658+ if !device_list. is_null ( ) && num_devices > 0 {
659+ let device = * device_list;
660+ if !device. is_null ( ) {
661+ mlx5dv_supported = rdmaxcel_sys:: mlx5dv_is_supported ( device) ;
682662 }
683- } ;
684-
685- rdmaxcel_sys:: ibv_free_device_list ( device_list) ;
686- result
663+ rdmaxcel_sys:: ibv_free_device_list ( device_list) ;
664+ }
665+ mlx5dv_supported
687666 }
688667}
689668
You can’t perform that action at this time.
0 commit comments