[openib-general] Re: [PATCH/RFC] change ibv_get_devices() to ibv_get_device_list()
Michael S. Tsirkin
mst at mellanox.co.il
Sat Dec 10 13:48:32 PST 2005
Quoting Roland Dreier <rdreier at cisco.com>:
> --- userspace/mpi/mvapich-gen2/mpid/ch_gen2/viainit.c (revision 4360)
> +++ userspace/mpi/mvapich-gen2/mpid/ch_gen2/viainit.c (working copy)
> @@ -74,13 +74,22 @@ static void set_malloc_options(void)
>
> static void open_hca(void)
> {
> - struct dlist *dev_list;
> struct ibv_device *ib_dev = NULL;
>
> +#ifdef GEN2_OLD_DEVICE_LIST_VERB
> + struct dlist *dev_list;
> +
> dev_list = ibv_get_devices();
>
> dlist_start(dev_list);
> ib_dev = dlist_next(dev_list);
> +#else
> + struct ibv_device **dev_list;
> +
> + dev_list = ibv_get_device_list(NULL);
> + ib_dev = dev_list[0];
> + ibv_free_device_list(dev_list);
> +#endif
>
> if (!ib_dev) {
> fprintf(stderr, "No IB devices found\n");
This wont work for hotplug: you are saving the device pointer
without opening the device, so it might go away from under your feet.
I wander whether we can come up with an API that helps people
get it right more easily?
--
MST
More information about the general
mailing list