[ofa-general] Number of devices returned by ibv_get_device_list()

Jack Morgenstein jackm at dev.mellanox.co.il
Sun Aug 30 08:45:38 PDT 2009


On Wednesday 26 August 2009 02:03, MANIKANTAN KALAIYA wrote:
> Resending to the mailing list...
> 
> We have Ofed1.3.1 installed, one of the sub packages is libibverbs version 1.1.1. We have a small program that lists the number of IB cards available in the system through ibv_get_device_list(). See below for the sample code.

libibverbs reads the number of devices ONCE, at calling process startup (as part of its initialization).
To get a new device count, you need to restart your program.

- Jack

> The system has two IB cards, the value returned by ibv_get_device_list() in 'num_devices' is two, as expected.
> 
> However, when we disable one of the cards using the modprobe command, the program continues to return two cards present (monitoring is continuous in a while loop).
> Killing and restarting the sample test process results in reporting correct number of IB cards available (returns one after it is restarted). One of the prior versions was known to report the correct number of IB cards without requiring to restart the program.
> 
> We would like to determine the number of cards present without having to go through a restart. Any inputs on this behavior is appreciated.
> 
> modprobe command - "sudo modprobe -r ib_mthca"
> 
> Test program:
> =================================================
> #include <stdio.h>
> #include <infiniband/verbs.h>
> 
> int main(int argc, char **argv)
> {
>     int ret, num_devices;
>     struct ibv_device      **dev_list;
> 
>     while(1) {
> 
>         dev_list = ibv_get_device_list(&num_devices);
> 
>         if (num_devices != 0) {
>             printf("IB ADAPTER AVAILABLE:%d\n", num_devices);
>         }
>         else {
>             printf("IB ADAPTER UNAVAILABLE\n");
>         }
>         sleep(2);
>         ibv_free_device_list(dev_list);
>     }
> 
>     return(0);
> }
> =================================================
> 
> Thanks,
> Mani.
> 



More information about the general mailing list