(SPAM?) [openib-general] [RFC] new ibv_get_devices() API -- avoid dlists

Michael S. Tsirkin mst at mellanox.co.il
Thu Nov 10 21:42:33 PST 2005


Quoting r. Roland Dreier <rolandd at cisco.com>:
> Subject: Re: (SPAM?) [openib-general] [RFC] new ibv_get_devices() API -- avoid dlists
> 
>  > The const confuses me somewhat.
> 
> Yeah, and thinking about it more, the memory really belongs to the
> consumer of the function.  So I don't think the const is even correct.
> 
>  > > extern int ibv_get_device_list(struct ibv_device ***list);
> 
>  > Is ***list really what we want here?  Can we just get away with **list?
> 
> Yes -- a single device is represented by a struct ibv_device *.
> So an array of devices is represented by a struct ibv_device **.
> And a pointer to such an array is struct ibv_device ***.
> 
> But the following is OK too I think:
> 
> 	extern int ibv_get_device_list(struct ibv_device **list[]);
> 	extern void ibv_free_device_list(struct ibv_device *list[]);
> 
> is that clearer?  (a pointer to an array of pointers to struct ibv_device).

Yes, this looks good.

>  > Would something like:
>  > 
>  > struct ibv_device * ibv_get_device(index);
>  > 
>  > work as well?
> 
> That could work as well.  But it doesn't handle hotplug quite as well.
> By returning a snapshot of all the known devices at a given moment, we
> at least have a chance at doing something sensible with devices
> appearing or disappearing.
> 
>  - R.

I agree. With ibv_free_device_list we just need to document that
the application is supposed to close devices it doesnt listen
for hotplug on.

-- 
MST



More information about the general mailing list